"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-registry-client/lib/authify.js" (8 Mar 2017, 673 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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 }