Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

registry-auth-token

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

registry-auth-token - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

yarn.lock

20

base64.js

@@ -1,20 +0,14 @@

function decodeBase64Old(base64) {
return new Buffer(base64, 'base64').toString('utf8')
}
const safeBuffer = require('safe-buffer').Buffer
function decodeBase64New(base64) {
return Buffer.from(base64, 'base64').toString('utf8')
function decodeBase64 (base64) {
return safeBuffer.from(base64, 'base64').toString('utf8')
}
function encodeBase64Old(string) {
return new Buffer(string, 'utf8').toString('base64')
function encodeBase64 (string) {
return safeBuffer.from(string, 'utf8').toString('base64')
}
function encodeBase64New(string) {
return Buffer.from(string, 'utf8').toString('base64')
}
module.exports = {
decodeBase64: Buffer.prototype.from ? decodeBase64New : decodeBase64Old,
encodeBase64: Buffer.prototype.from ? encodeBase64New : encodeBase64Old
decodeBase64: decodeBase64,
encodeBase64: encodeBase64
}

@@ -5,2 +5,34 @@ # Change Log

## [3.3.0] - 2017-04-24
### Changes
- Support legacy auth token config key (Zoltan Kochan)
- Use safe-buffer module for backwards-compatible base64 encoding/decoding (Espen Hovlandsdal)
- Change to standard.js coding style (Espen Hovlandsdal)
## [3.2.0] - 2017-04-20
### Changes
- Allow passing parsed npmrc from outside (Zoltan Kochan)
## [3.1.2] - 2017-04-07
### Changes
- Avoid infinite loop on invalid URL (Zoltan Kochan)
## [3.1.1] - 2017-04-06
### Changes
- Nerf-dart URLs even if recursive is set to false (Espen Hovlandsdal)
## [3.1.0] - 2016-10-19
### Changes
- Return the password and username for Basic authorization (Zoltan Kochan)
## [3.0.1] - 2016-08-07

@@ -59,1 +91,6 @@

[3.0.1]: https://github.com/rexxars/registry-auth-token/compare/v3.0.0...v3.0.1
[3.1.0]: https://github.com/rexxars/registry-auth-token/compare/v3.0.1...v3.1.0
[3.1.1]: https://github.com/rexxars/registry-auth-token/compare/v3.1.0...v3.1.1
[3.1.2]: https://github.com/rexxars/registry-auth-token/compare/v3.1.1...v3.1.2
[3.2.0]: https://github.com/rexxars/registry-auth-token/compare/v3.1.2...v3.2.0
[3.3.0]: https://github.com/rexxars/registry-auth-token/compare/v3.2.0...v3.3.0

@@ -25,6 +25,6 @@ var url = require('url')

checkUrl = checkUrl || options.npmrc.registry
return getRegistryAuthInfo(checkUrl, options)
return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc)
}
function getRegistryAuthInfo(checkUrl, options) {
function getRegistryAuthInfo (checkUrl, options) {
var parsed = url.parse(checkUrl, false, true)

@@ -55,7 +55,14 @@ var pathname

function normalizePath(path) {
function getLegacyAuthInfo (npmrc) {
if (npmrc._auth) {
return getBearerToken(npmrc._auth)
}
return undefined
}
function normalizePath (path) {
return path[path.length - 1] === '/' ? path : path + '/'
}
function getAuthInfoForUrl(regUrl, npmrc) {
function getAuthInfoForUrl (regUrl, npmrc) {
// try to get bearer token

@@ -78,3 +85,3 @@ var bearerAuth = getBearerToken(npmrc[regUrl + tokenKey] || npmrc[regUrl + '/' + tokenKey])

function getBearerToken(tok) {
function getBearerToken (tok) {
if (!tok) {

@@ -92,3 +99,3 @@ return undefined

function getTokenForUsernameAndPassword(username, password) {
function getTokenForUsernameAndPassword (username, password) {
if (!username || !password) {

@@ -95,0 +102,0 @@ return undefined

{
"name": "registry-auth-token",
"version": "3.2.0",
"version": "3.3.0",
"description": "Get the auth token set for an npm registry (if any)",

@@ -8,3 +8,3 @@ "main": "index.js",

"test": "mocha",
"posttest": "eslint .",
"posttest": "standard",
"coverage": "istanbul cover _mocha"

@@ -33,11 +33,16 @@ },

"dependencies": {
"rc": "^1.1.6"
"rc": "^1.1.6",
"safe-buffer": "^5.0.1"
},
"devDependencies": {
"eslint": "^2.4.0",
"eslint-config-bengler": "^1.0.7",
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"require-uncached": "^1.0.2"
"mocha": "^3.3.0",
"require-uncached": "^1.0.2",
"standard": "^10.0.2"
},
"standard": {
"ignore": [
"coverage/**"
]
}
}

@@ -16,3 +16,3 @@ var fs = require('fs')

/*eslint max-nested-callbacks: ["error", 4]*/
/* eslint max-nested-callbacks: ["error", 4] */

@@ -41,3 +41,2 @@ describe('auth-token', function () {

describe('bearer token', function () {
it('should return auth token if registry is defined', function (done) {

@@ -57,2 +56,16 @@ var content = [

it('should return auth token if it is defined in the legacy way via the `_auth` key', function (done) {
var content = [
'_auth=foobar',
'registry=http://registry.foobar.eu/'
].join('\n')
fs.writeFile(npmRcPath, content, function (err) {
var getAuthToken = requireUncached('../index')
assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Bearer'})
done()
})
})
it('should use npmrc passed in', function (done) {

@@ -217,3 +230,2 @@ var content = [

describe('basic token', function () {
it('should return undefined if password or username are missing', function (done, undef) {

@@ -220,0 +232,0 @@ var content = [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc