registry-auth-token
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -5,2 +5,8 @@ # Change Log | ||
## [4.1.0] - 2020-01-17 | ||
### Changes | ||
- Add support for legacy auth token on the registry url (Gustav Blomér) | ||
## [4.0.0] - 2019-06-17 | ||
@@ -7,0 +13,0 @@ |
17
index.js
@@ -8,2 +8,3 @@ var url = require('url') | ||
var tokenKey = ':_authToken' | ||
var legacyTokenKey = ':_auth' | ||
var userKey = ':username' | ||
@@ -84,2 +85,7 @@ var passwordKey = ':_password' | ||
var basicAuthWithToken = getLegacyAuthToken(npmrc[regUrl + legacyTokenKey] || npmrc[regUrl + '/' + legacyTokenKey]) | ||
if (basicAuthWithToken) { | ||
return basicAuthWithToken | ||
} | ||
return undefined | ||
@@ -126,1 +132,12 @@ } | ||
} | ||
function getLegacyAuthToken (tok) { | ||
if (!tok) { | ||
return undefined | ||
} | ||
// check if legacy auth token is set as environment variable | ||
var token = replaceEnvironmentVariable(tok) | ||
return { token: token, type: 'Basic' } | ||
} |
{ | ||
"name": "registry-auth-token", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Get the auth token set for an npm registry (if any)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -303,2 +303,21 @@ var fs = require('fs') | ||
it('should return basic token if _auth is base64 encoded', function (done) { | ||
var content = [ | ||
'registry=http://registry.foobar.eu/', | ||
'//registry.foobar.eu/:_auth=' + encodeBase64('foobar:foobar') | ||
].join('\n') | ||
fs.writeFile(npmRcPath, content, function (err) { | ||
var getAuthToken = requireUncached('../index') | ||
assert(!err, err) | ||
var token = getAuthToken() | ||
assert.deepStrictEqual(token, { | ||
token: 'Zm9vYmFyOmZvb2Jhcg==', | ||
type: 'Basic' | ||
}) | ||
assert.strictEqual(decodeBase64(token.token), 'foobar:foobar') | ||
done() | ||
}) | ||
}) | ||
it('should return basic token if registry url has port specified', function (done) { | ||
@@ -305,0 +324,0 @@ var content = [ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
31280
9
606