Comparing version 0.41.1 to 0.41.2
import { IncomingMessage } from 'http'; | ||
export declare type RequestParams = { | ||
headers?: { | ||
authorization: string; | ||
auth?: { | ||
token: string; | ||
} | { | ||
username: string; | ||
password: string; | ||
}; | ||
@@ -6,0 +9,0 @@ }; |
@@ -11,3 +11,3 @@ "use strict"; | ||
const pauseStream = require('pause-stream'); | ||
const getAuthToken = require('registry-auth-token'); | ||
const getRegistryAuthInfo = require('registry-auth-token'); | ||
const createCache_1 = require('./createCache'); | ||
@@ -65,10 +65,22 @@ const memoize = require('lodash.memoize'); | ||
function createOptions(url) { | ||
const authToken = getAuthToken(url, { recursive: true }); | ||
if (!authToken) | ||
const authInfo = getRegistryAuthInfo(url, { recursive: true }); | ||
if (!authInfo) | ||
return {}; | ||
return { | ||
headers: { | ||
authorization: `${authToken.type} ${authToken.token}` | ||
} | ||
}; | ||
switch (authInfo.type) { | ||
case 'Bearer': | ||
return { | ||
auth: { | ||
token: authInfo.token | ||
} | ||
}; | ||
case 'Basic': | ||
return { | ||
auth: { | ||
username: authInfo.username, | ||
password: authInfo.password | ||
} | ||
}; | ||
default: | ||
throw new Error(`Unsupported authorization type '${authInfo.type}'`); | ||
} | ||
} | ||
@@ -75,0 +87,0 @@ return { |
@@ -57,1 +57,2 @@ # Change Log | ||
[3.0.0]: https://github.com/rexxars/registry-auth-token/compare/v2.1.1...v3.0.0 | ||
[3.0.1]: https://github.com/rexxars/registry-auth-token/compare/v3.0.0...v3.0.1 |
@@ -86,3 +86,8 @@ var url = require('url') | ||
// we found a basicToken token so let's exit the loop | ||
return {token: token, type: 'Basic'} | ||
return { | ||
token: token, | ||
type: 'Basic', | ||
password: pass, | ||
username: username | ||
} | ||
} |
@@ -5,8 +5,8 @@ { | ||
{ | ||
"raw": "registry-auth-token@3.0.1", | ||
"raw": "registry-auth-token@3.1.0", | ||
"scope": null, | ||
"escapedName": "registry-auth-token", | ||
"name": "registry-auth-token", | ||
"rawSpec": "3.0.1", | ||
"spec": "3.0.1", | ||
"rawSpec": "3.1.0", | ||
"spec": "3.1.0", | ||
"type": "version" | ||
@@ -17,10 +17,10 @@ }, | ||
], | ||
"_from": "registry-auth-token@3.0.1", | ||
"_id": "registry-auth-token@3.0.1", | ||
"_from": "registry-auth-token@3.1.0", | ||
"_id": "registry-auth-token@3.1.0", | ||
"_inCache": true, | ||
"_location": "/registry-auth-token", | ||
"_nodeVersion": "6.2.2", | ||
"_nodeVersion": "6.6.0", | ||
"_npmOperationalInternal": { | ||
"host": "packages-12-west.internal.npmjs.com", | ||
"tmp": "tmp/registry-auth-token-3.0.1.tgz_1470562717176_0.6900515060406178" | ||
"tmp": "tmp/registry-auth-token-3.1.0.tgz_1476906788283_0.3755947477184236" | ||
}, | ||
@@ -31,11 +31,11 @@ "_npmUser": { | ||
}, | ||
"_npmVersion": "3.9.5", | ||
"_npmVersion": "3.10.3", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"raw": "registry-auth-token@3.0.1", | ||
"raw": "registry-auth-token@3.1.0", | ||
"scope": null, | ||
"escapedName": "registry-auth-token", | ||
"name": "registry-auth-token", | ||
"rawSpec": "3.0.1", | ||
"spec": "3.0.1", | ||
"rawSpec": "3.1.0", | ||
"spec": "3.1.0", | ||
"type": "version" | ||
@@ -47,6 +47,6 @@ }, | ||
], | ||
"_resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.0.1.tgz", | ||
"_shasum": "c3ee5ec585bce29f88bf41629a3944c71ed53e25", | ||
"_resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.1.0.tgz", | ||
"_shasum": "997c08256e0c7999837b90e944db39d8a790276b", | ||
"_shrinkwrap": null, | ||
"_spec": "registry-auth-token@3.0.1", | ||
"_spec": "registry-auth-token@3.1.0", | ||
"_where": "/home/zkochan/src/pnpm", | ||
@@ -73,6 +73,6 @@ "author": { | ||
"dist": { | ||
"shasum": "c3ee5ec585bce29f88bf41629a3944c71ed53e25", | ||
"tarball": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.0.1.tgz" | ||
"shasum": "997c08256e0c7999837b90e944db39d8a790276b", | ||
"tarball": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.1.0.tgz" | ||
}, | ||
"gitHead": "9a20b880b63c25340e426d82d23663bf26bdfdfd", | ||
"gitHead": "349c63e86949846b70bc57e6801018800dc76382", | ||
"homepage": "https://github.com/rexxars/registry-auth-token#readme", | ||
@@ -113,3 +113,3 @@ "keywords": [ | ||
}, | ||
"version": "3.0.1" | ||
"version": "3.1.0" | ||
} |
@@ -212,3 +212,8 @@ var fs = require('fs') | ||
var token = getAuthToken() | ||
assert.deepEqual(token, {token: 'Zm9vYmFyOmZvb2Jhcg==', type: 'Basic'}) | ||
assert.deepEqual(token, { | ||
token: 'Zm9vYmFyOmZvb2Jhcg==', | ||
type: 'Basic', | ||
username: 'foobar', | ||
password: 'foobar' | ||
}) | ||
assert.equal(decodeBase64(token.token), 'foobar:foobar') | ||
@@ -232,3 +237,8 @@ done() | ||
var token = getAuthToken() | ||
assert.deepEqual(token, {token: 'Zm9vYmFyOmZvb2Jhcg==', type: 'Basic'}) | ||
assert.deepEqual(token, { | ||
token: 'Zm9vYmFyOmZvb2Jhcg==', | ||
type: 'Basic', | ||
username: 'foobar', | ||
password: 'foobar' | ||
}) | ||
assert.equal(decodeBase64(token.token), 'foobar:foobar') | ||
@@ -250,3 +260,8 @@ done() | ||
var token = getAuthToken() | ||
assert.deepEqual(token, {token: 'YmFyYmF6OmJhcmJheQ==', type: 'Basic'}) | ||
assert.deepEqual(token, { | ||
token: 'YmFyYmF6OmJhcmJheQ==', | ||
type: 'Basic', | ||
password: 'barbay', | ||
username: 'barbaz' | ||
}) | ||
assert.equal(decodeBase64(token.token), 'barbaz:barbay') | ||
@@ -269,3 +284,8 @@ done() | ||
var token = getAuthToken('//registry.blah.foo') | ||
assert.deepEqual(token, {token: 'YmFyYmF6OmJhcmJheQ==', type: 'Basic'}) | ||
assert.deepEqual(token, { | ||
token: 'YmFyYmF6OmJhcmJheQ==', | ||
type: 'Basic', | ||
password: 'barbay', | ||
username: 'barbaz' | ||
}) | ||
assert.equal(decodeBase64(token.token), 'barbaz:barbay') | ||
@@ -289,6 +309,16 @@ done() | ||
var token = getAuthToken('https://registry.blah.com/foo/bar/baz', opts) | ||
assert.deepEqual(token, {token: 'YmFyYmF6OmJhcmJheQ==', type: 'Basic'}) | ||
assert.deepEqual(token, { | ||
token: 'YmFyYmF6OmJhcmJheQ==', | ||
type: 'Basic', | ||
password: 'barbay', | ||
username: 'barbaz' | ||
}) | ||
assert.equal(decodeBase64(token.token), 'barbaz:barbay') | ||
token = getAuthToken('https://registry.blah.eu/foo/bar/baz', opts) | ||
assert.deepEqual(token, {token: 'YmFyYmF6OmZvb2Jheg==', type: 'Basic'}) | ||
assert.deepEqual(token, { | ||
token: 'YmFyYmF6OmZvb2Jheg==', | ||
type: 'Basic', | ||
password: 'foobaz', | ||
username: 'barbaz' | ||
}) | ||
assert.equal(decodeBase64(token.token), 'barbaz:foobaz') | ||
@@ -295,0 +325,0 @@ assert.equal(getAuthToken('//some.registry', opts), undef) |
{ | ||
"name": "pnpm", | ||
"description": "A fast implementation of npm install", | ||
"version": "0.41.1", | ||
"version": "0.41.2", | ||
"author": "Rico Sta. Cruz <rico@ricostacruz.com>", | ||
@@ -53,3 +53,3 @@ "bin": { | ||
"read-pkg-up": "1.0.1", | ||
"registry-auth-token": "3.0.1", | ||
"registry-auth-token": "3.1.0", | ||
"registry-url": "3.1.0", | ||
@@ -56,0 +56,0 @@ "retry": "0.10.0", |
Sorry, the diff of this file is not supported yet
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
13816279
219334