mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-31 05:22:00 -04:00
fix: installation of private packages
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
"promisequence": "1.1.6",
|
||||
"rc": "1.1.6",
|
||||
"read-pkg-up": "1.0.1",
|
||||
"registry-auth-token": "3.0.1",
|
||||
"registry-auth-token": "3.1.0",
|
||||
"registry-url": "3.1.0",
|
||||
"retry": "0.10.0",
|
||||
"rimraf-then": "1.0.0",
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import {IncomingMessage} from 'http'
|
||||
import pauseStream = require('pause-stream')
|
||||
import getAuthToken = require('registry-auth-token')
|
||||
import getRegistryAuthInfo = require('registry-auth-token')
|
||||
import createCache from './createCache'
|
||||
import memoize = require('lodash.memoize')
|
||||
|
||||
export type RequestParams = {
|
||||
headers?: {
|
||||
authorization: string
|
||||
auth?: {
|
||||
token: string
|
||||
} | {
|
||||
username: string,
|
||||
password: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +72,24 @@ export default (client: NpmRegistryClient, opts: {cachePath: string, cacheTTL: n
|
||||
}
|
||||
|
||||
function createOptions (url: string): RequestParams {
|
||||
const authToken = getAuthToken(url, {recursive: true})
|
||||
if (!authToken) return {}
|
||||
return {
|
||||
headers: {
|
||||
authorization: `${authToken.type} ${authToken.token}`
|
||||
}
|
||||
const authInfo = getRegistryAuthInfo(url, {recursive: true})
|
||||
if (!authInfo) return {}
|
||||
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}'`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user