]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/lib/authify.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-registry-client / lib / authify.js
1 module.exports = authify
2
3 function authify (authed, parsed, headers, credentials) {
4   if (credentials && credentials.token) {
5     this.log.verbose('request', 'using bearer token for auth')
6     headers.authorization = 'Bearer ' + credentials.token
7
8     return null
9   }
10
11   if (authed) {
12     if (credentials && credentials.username && credentials.password) {
13       var username = encodeURIComponent(credentials.username)
14       var password = encodeURIComponent(credentials.password)
15       parsed.auth = username + ':' + password
16     } else {
17       return new Error(
18         'This request requires auth credentials. Run `npm login` and repeat the request.'
19       )
20     }
21   }
22 }