registry-auth-token
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -5,2 +5,9 @@ # Change Log | ||
## [3.0.1] - 2016-08-07 | ||
### Changes | ||
- Fix recursion bug (Lukas Eipert) | ||
- Implement alternative base64 encoding/decoding implementation for Node 6 (Lukas Eipert) | ||
## [3.0.0] - 2016-08-04 | ||
@@ -7,0 +14,0 @@ |
15
index.js
var url = require('url') | ||
var base64 = require('./base64') | ||
var decodeBase64 = base64.decodeBase64 | ||
var encodeBase64 = base64.encodeBase64 | ||
var tokenKey = ':_authToken' | ||
@@ -26,3 +31,3 @@ var userKey = ':username' | ||
parsed.pathname = url.resolve(pathname, '..') || '/' | ||
parsed.pathname = url.resolve(normalizePath(pathname), '..') || '/' | ||
} | ||
@@ -33,2 +38,6 @@ | ||
function normalizePath(path) { | ||
return path[path.length - 1] === '/' ? path : path + '/' | ||
} | ||
function getAuthInfoForUrl(regUrl, npmrc) { | ||
@@ -72,7 +81,7 @@ // try to get bearer token | ||
// See https://github.com/npm/npm/blob/v3.10.6/lib/config/set-credentials-by-uri.js#L26 | ||
var pass = new Buffer(password, 'base64').toString('utf8') | ||
var pass = decodeBase64(password) | ||
// a basic auth token is base64 encoded 'username:password' | ||
// See https://github.com/npm/npm/blob/v3.10.6/lib/config/get-credentials-by-uri.js#L70 | ||
var token = new Buffer(username + ':' + pass).toString('base64') | ||
var token = encodeBase64(username + ':' + pass) | ||
@@ -79,0 +88,0 @@ // we found a basicToken token so let's exit the loop |
{ | ||
"name": "registry-auth-token", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Get the auth token set for an npm registry (if any)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,10 +12,6 @@ var fs = require('fs') | ||
function decodeBase64(base64) { | ||
return new Buffer(base64, 'base64').toString() | ||
} | ||
var base64 = require('../base64') | ||
var decodeBase64 = base64.decodeBase64 | ||
var encodeBase64 = base64.encodeBase64 | ||
function encodeBase64(string) { | ||
return new Buffer(string, 'utf8').toString('base64') | ||
} | ||
/*eslint max-nested-callbacks: ["error", 4]*/ | ||
@@ -143,2 +139,4 @@ | ||
'//registry.blah.com/foo:_authToken=whatev', | ||
'//registry.blah.org/foo/bar:_authToken=recurseExactlyOneLevel', | ||
'//registry.blah.edu/foo/bar/baz:_authToken=recurseNoLevel', | ||
'//registry.blah.eu:_authToken=yep', '' | ||
@@ -150,2 +148,4 @@ ].join('\n') | ||
assert(!err, err) | ||
assert.deepEqual(getAuthToken('https://registry.blah.edu/foo/bar/baz', opts), {token: 'recurseNoLevel', type: 'Bearer'}) | ||
assert.deepEqual(getAuthToken('https://registry.blah.org/foo/bar/baz', opts), {token: 'recurseExactlyOneLevel', type: 'Bearer'}) | ||
assert.deepEqual(getAuthToken('https://registry.blah.com/foo/bar/baz', opts), {token: 'whatev', type: 'Bearer'}) | ||
@@ -152,0 +152,0 @@ assert.deepEqual(getAuthToken('http://registry.blah.eu/what/ever', opts), {token: 'yep', type: 'Bearer'}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21774
10
402