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

registry-auth-token

Package Overview
Dependencies
Maintainers
3
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.4.0 to 4.0.0

package-lock.json

10

CHANGELOG.md

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

## [4.0.0] - 2019-06-17
### BREAKING
- Minimum node.js version requirement is now v6
### Changes
- Upgraded dependencies (Espen Hovlandsdal)
## [3.4.0] - 2019-03-20

@@ -7,0 +17,0 @@

6

index.js

@@ -23,3 +23,3 @@ var url = require('url')

options = options || {}
options.npmrc = options.npmrc || require('rc')('npm', {registry: 'https://registry.npmjs.org/'})
options.npmrc = options.npmrc || require('rc')('npm', { registry: 'https://registry.npmjs.org/' })
checkUrl = checkUrl || options.npmrc.registry

@@ -62,3 +62,3 @@ return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc)

return {token: token, type: 'Basic'}
return { token: token, type: 'Basic' }
}

@@ -102,3 +102,3 @@

return {token: token, type: 'Bearer'}
return { token: token, type: 'Bearer' }
}

@@ -105,0 +105,0 @@

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

@@ -15,2 +15,5 @@ "main": "index.js",

},
"engines": {
"node": ">=6.0.0"
},
"keywords": [

@@ -33,3 +36,3 @@ "npm",

"dependencies": {
"rc": "^1.1.6",
"rc": "^1.2.8",
"safe-buffer": "^5.0.1"

@@ -39,5 +42,5 @@ },

"istanbul": "^0.4.2",
"mocha": "^3.3.0",
"mocha": "^6.1.4",
"require-uncached": "^1.0.2",
"standard": "^10.0.2"
"standard": "^12.0.1"
},

@@ -44,0 +47,0 @@ "standard": {

module.exports = function (scope, npmrc) {
var rc = npmrc || require('rc')('npm', {registry: 'https://registry.npmjs.org/'})
var rc = npmrc || require('rc')('npm', { registry: 'https://registry.npmjs.org/' })
var url = rc[scope + ':registry'] || rc.registry
return url.slice(-1) === '/' ? url : url + '/'
}

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

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Basic'})
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Basic' })
done()

@@ -67,3 +67,3 @@ })

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Basic'})
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Basic' })
delete process.env[environmentVariable]

@@ -86,3 +86,3 @@ done()

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Basic'})
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Basic' })
delete process.env[environmentVariable]

@@ -104,3 +104,3 @@ done()

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Bearer' })
done()

@@ -123,3 +123,3 @@ })

}
assert.deepEqual(getAuthToken({npmrc: npmrc}), {token: 'qar', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken({ npmrc: npmrc }), { token: 'qar', type: 'Bearer' })
done()

@@ -140,3 +140,3 @@ })

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'beepboop', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken(), { token: 'beepboop', type: 'Bearer' })
done()

@@ -157,3 +157,3 @@ })

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Bearer' })
delete process.env[environmentVariable]

@@ -175,3 +175,3 @@ done()

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'foobar', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Bearer' })
delete process.env[environmentVariable]

@@ -191,3 +191,3 @@ done()

assert(!err, err)
assert.deepEqual(getAuthToken(), {token: 'barbaz', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken(), { token: 'barbaz', type: 'Bearer' })
done()

@@ -207,3 +207,3 @@ })

assert(!err, err)
assert.deepEqual(getAuthToken('//registry.blah.foo'), {token: 'whatev', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken('//registry.blah.foo'), { token: 'whatev', type: 'Bearer' })
done()

@@ -214,3 +214,3 @@ })

it('recursively finds registries for deep url if option is set', function (done, undef) {
var opts = {recursive: true}
var opts = { recursive: true }
var content = [

@@ -226,8 +226,8 @@ '//registry.blah.com/foo:_authToken=whatev',

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'})
assert.deepEqual(getAuthToken('http://registry.blah.eu/what/ever', opts), {token: 'yep', type: 'Bearer'})
assert.deepEqual(getAuthToken('http://registry.blah.eu//what/ever', opts), undefined, 'does not hang')
assert.equal(getAuthToken('//some.registry', opts), undef)
assert.deepStrictEqual(getAuthToken('https://registry.blah.edu/foo/bar/baz', opts), { token: 'recurseNoLevel', type: 'Bearer' })
assert.deepStrictEqual(getAuthToken('https://registry.blah.org/foo/bar/baz', opts), { token: 'recurseExactlyOneLevel', type: 'Bearer' })
assert.deepStrictEqual(getAuthToken('https://registry.blah.com/foo/bar/baz', opts), { token: 'whatev', type: 'Bearer' })
assert.deepStrictEqual(getAuthToken('http://registry.blah.eu/what/ever', opts), { token: 'yep', type: 'Bearer' })
assert.deepStrictEqual(getAuthToken('http://registry.blah.eu//what/ever', opts), undefined, 'does not hang')
assert.strictEqual(getAuthToken('//some.registry', opts), undef)
done()

@@ -241,3 +241,3 @@ })

assert(!err, err)
assert.deepEqual(getAuthToken('https://registry.blah.com'), {token: 'whatev', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken('https://registry.blah.com'), { token: 'whatev', type: 'Bearer' })
done()

@@ -259,3 +259,3 @@ })

assert(!err, err)
assert.deepEqual(getAuthToken('//registry.foobar.eu'), {token: 'bearerToken', type: 'Bearer'})
assert.deepStrictEqual(getAuthToken('//registry.foobar.eu'), { token: 'bearerToken', type: 'Bearer' })
done()

@@ -269,5 +269,5 @@ })

assert(!err, err)
assert.deepEqual(
assert.deepStrictEqual(
getAuthToken('https://contoso.pkgs.visualstudio.com/_packaging/MyFeed/npm/registry'),
{token: 'heider', type: 'Bearer'}
{ token: 'heider', type: 'Bearer' }
)

@@ -290,4 +290,4 @@ done()

assert(!err, err)
assert.equal(getAuthToken('//registry.foobar.eu'), undef)
assert.equal(getAuthToken('//registry.foobar.com'), undef)
assert.strictEqual(getAuthToken('//registry.foobar.eu'), undef)
assert.strictEqual(getAuthToken('//registry.foobar.com'), undef)
done()

@@ -308,3 +308,3 @@ })

var token = getAuthToken()
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
token: 'Zm9vYmFyOmZvb2Jhcg==',

@@ -315,3 +315,3 @@ type: 'Basic',

})
assert.equal(decodeBase64(token.token), 'foobar:foobar')
assert.strictEqual(decodeBase64(token.token), 'foobar:foobar')
done()

@@ -334,3 +334,3 @@ })

var token = getAuthToken()
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
token: 'Zm9vYmFyOmZvb2Jhcg==',

@@ -341,3 +341,3 @@ type: 'Basic',

})
assert.equal(decodeBase64(token.token), 'foobar:foobar')
assert.strictEqual(decodeBase64(token.token), 'foobar:foobar')
done()

@@ -360,3 +360,3 @@ })

var token = getAuthToken()
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
type: 'Basic',

@@ -367,3 +367,3 @@ username: 'username',

})
assert.equal(decodeBase64(token.token), 'username:password')
assert.strictEqual(decodeBase64(token.token), 'username:password')
delete process.env[environmentVariable]

@@ -387,3 +387,3 @@ done()

var token = getAuthToken()
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
type: 'Basic',

@@ -394,3 +394,3 @@ username: 'username',

})
assert.equal(decodeBase64(token.token), 'username:password')
assert.strictEqual(decodeBase64(token.token), 'username:password')
delete process.env[environmentVariable]

@@ -412,3 +412,3 @@ done()

var token = getAuthToken()
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
token: 'YmFyYmF6OmJhcmJheQ==',

@@ -419,3 +419,3 @@ type: 'Basic',

})
assert.equal(decodeBase64(token.token), 'barbaz:barbay')
assert.strictEqual(decodeBase64(token.token), 'barbaz:barbay')
done()

@@ -437,3 +437,3 @@ })

var token = getAuthToken('//registry.blah.foo')
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
token: 'YmFyYmF6OmJhcmJheQ==',

@@ -444,3 +444,3 @@ type: 'Basic',

})
assert.equal(decodeBase64(token.token), 'barbaz:barbay')
assert.strictEqual(decodeBase64(token.token), 'barbaz:barbay')
done()

@@ -451,3 +451,3 @@ })

it('recursively finds registries for deep url if option is set', function (done, undef) {
var opts = {recursive: true}
var opts = { recursive: true }
var content = [

@@ -464,3 +464,3 @@ '//registry.blah.com/foo:_password=' + encodeBase64('barbay'),

var token = getAuthToken('https://registry.blah.com/foo/bar/baz', opts)
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
token: 'YmFyYmF6OmJhcmJheQ==',

@@ -471,5 +471,5 @@ type: 'Basic',

})
assert.equal(decodeBase64(token.token), 'barbaz:barbay')
assert.strictEqual(decodeBase64(token.token), 'barbaz:barbay')
token = getAuthToken('https://registry.blah.eu/foo/bar/baz', opts)
assert.deepEqual(token, {
assert.deepStrictEqual(token, {
token: 'YmFyYmF6OmZvb2Jheg==',

@@ -480,4 +480,4 @@ type: 'Basic',

})
assert.equal(decodeBase64(token.token), 'barbaz:foobaz')
assert.equal(getAuthToken('//some.registry', opts), undef)
assert.strictEqual(decodeBase64(token.token), 'barbaz:foobaz')
assert.strictEqual(getAuthToken('//some.registry', opts), undef)
done()

@@ -484,0 +484,0 @@ })

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

assert(!err, err)
assert.equal(getRegistryUrl('@somescope'), 'https://registry.npmjs.org/')
assert.strictEqual(getRegistryUrl('@somescope'), 'https://registry.npmjs.org/')
done()

@@ -38,3 +38,3 @@ })

assert(!err, err)
assert.equal(getRegistryUrl('@somescope'), 'https://some.registry/')
assert.strictEqual(getRegistryUrl('@somescope'), 'https://some.registry/')
done()

@@ -48,3 +48,3 @@ })

assert(!err, err)
assert.equal(getRegistryUrl('@somescope'), 'https://some.registry/')
assert.strictEqual(getRegistryUrl('@somescope'), 'https://some.registry/')
done()

@@ -63,3 +63,3 @@ })

assert(!err, err)
assert.equal(getRegistryUrl(), 'http://registry.foobar.eu/')
assert.strictEqual(getRegistryUrl(), 'http://registry.foobar.eu/')
done()

@@ -66,0 +66,0 @@ })

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