Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2022-07-18 23:32:20 +0300
committerNathan Fritz <fritzy@github.com>2022-07-19 22:38:13 +0300
commit51b12a085e087609c99befccfd6a98ef8a9919d0 (patch)
tree9f2a76b35bf3af6d281e2530e8383a15e6367fbe
parent64fe64b74bc66635771ae65003ccc67be5853929 (diff)
deps: npm-registry-fetch@13.3.0
-rw-r--r--node_modules/npm-registry-fetch/lib/auth.js37
-rw-r--r--node_modules/npm-registry-fetch/lib/index.js4
-rw-r--r--node_modules/npm-registry-fetch/package.json2
-rw-r--r--package-lock.json8
-rw-r--r--package.json2
5 files changed, 42 insertions, 11 deletions
diff --git a/node_modules/npm-registry-fetch/lib/auth.js b/node_modules/npm-registry-fetch/lib/auth.js
index 17da6a17d..870ce0d92 100644
--- a/node_modules/npm-registry-fetch/lib/auth.js
+++ b/node_modules/npm-registry-fetch/lib/auth.js
@@ -1,4 +1,5 @@
'use strict'
+const fs = require('fs')
const npa = require('npm-package-arg')
const { URL } = require('url')
@@ -7,7 +8,8 @@ const { URL } = require('url')
const regKeyFromURI = (uri, opts) => {
const parsed = new URL(uri)
// try to find a config key indicating we have auth for this registry
- // can be one of :_authToken, :_auth, or :_password and :username
+ // can be one of :_authToken, :_auth, :_password and :username, or
+ // :certfile and :keyfile
// We walk up the "path" until we're left with just //<host>[:<port>],
// stopping when we reach '//'.
let regKey = `//${parsed.host}${parsed.pathname}`
@@ -26,7 +28,8 @@ const regKeyFromURI = (uri, opts) => {
const hasAuth = (regKey, opts) => (
opts[`${regKey}:_authToken`] ||
opts[`${regKey}:_auth`] ||
- opts[`${regKey}:username`] && opts[`${regKey}:_password`]
+ opts[`${regKey}:username`] && opts[`${regKey}:_password`] ||
+ opts[`${regKey}:certfile`] && opts[`${regKey}:keyfile`]
)
const sameHost = (a, b) => {
@@ -44,6 +47,17 @@ const getRegistry = opts => {
return scopeReg || opts.registry
}
+const maybeReadFile = file => {
+ try {
+ return fs.readFileSync(file, 'utf8')
+ } catch (er) {
+ if (er.code !== 'ENOENT') {
+ throw er
+ }
+ return null
+ }
+}
+
const getAuth = (uri, opts = {}) => {
const { forceAuth } = opts
if (!uri) {
@@ -59,6 +73,8 @@ const getAuth = (uri, opts = {}) => {
username: forceAuth.username,
password: forceAuth._password || forceAuth.password,
auth: forceAuth._auth || forceAuth.auth,
+ certfile: forceAuth.certfile,
+ keyfile: forceAuth.keyfile,
})
}
@@ -82,6 +98,8 @@ const getAuth = (uri, opts = {}) => {
[`${regKey}:username`]: username,
[`${regKey}:_password`]: password,
[`${regKey}:_auth`]: auth,
+ [`${regKey}:certfile`]: certfile,
+ [`${regKey}:keyfile`]: keyfile,
} = opts
return new Auth({
@@ -90,15 +108,19 @@ const getAuth = (uri, opts = {}) => {
auth,
username,
password,
+ certfile,
+ keyfile,
})
}
class Auth {
- constructor ({ token, auth, username, password, scopeAuthKey }) {
+ constructor ({ token, auth, username, password, scopeAuthKey, certfile, keyfile }) {
this.scopeAuthKey = scopeAuthKey
this.token = null
this.auth = null
this.isBasicAuth = false
+ this.cert = null
+ this.key = null
if (token) {
this.token = token
} else if (auth) {
@@ -108,6 +130,15 @@ class Auth {
this.auth = Buffer.from(`${username}:${p}`, 'utf8').toString('base64')
this.isBasicAuth = true
}
+ // mTLS may be used in conjunction with another auth method above
+ if (certfile && keyfile) {
+ const cert = maybeReadFile(certfile, 'utf-8')
+ const key = maybeReadFile(keyfile, 'utf-8')
+ if (cert && key) {
+ this.cert = cert
+ this.key = key
+ }
+ }
}
}
diff --git a/node_modules/npm-registry-fetch/lib/index.js b/node_modules/npm-registry-fetch/lib/index.js
index c788febc3..cc331a50c 100644
--- a/node_modules/npm-registry-fetch/lib/index.js
+++ b/node_modules/npm-registry-fetch/lib/index.js
@@ -112,10 +112,10 @@ function regFetch (uri, /* istanbul ignore next */ opts_ = {}) {
cache: getCacheMode(opts),
cachePath: opts.cache,
ca: opts.ca,
- cert: opts.cert,
+ cert: auth.cert || opts.cert,
headers,
integrity: opts.integrity,
- key: opts.key,
+ key: auth.key || opts.key,
localAddress: opts.localAddress,
maxSockets: opts.maxSockets,
memoize: opts.memoize,
diff --git a/node_modules/npm-registry-fetch/package.json b/node_modules/npm-registry-fetch/package.json
index 5f19697c3..8a0189a9e 100644
--- a/node_modules/npm-registry-fetch/package.json
+++ b/node_modules/npm-registry-fetch/package.json
@@ -1,6 +1,6 @@
{
"name": "npm-registry-fetch",
- "version": "13.2.0",
+ "version": "13.3.0",
"description": "Fetch-based http client for use with npm registry APIs",
"main": "lib",
"files": [
diff --git a/package-lock.json b/package-lock.json
index 5f17c532c..64c8c9e16 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -135,7 +135,7 @@
"npm-package-arg": "^9.1.0",
"npm-pick-manifest": "^7.0.1",
"npm-profile": "^6.2.0",
- "npm-registry-fetch": "^13.2.0",
+ "npm-registry-fetch": "^13.3.0",
"npm-user-validate": "^1.0.1",
"npmlog": "^6.0.2",
"opener": "^1.5.2",
@@ -5188,9 +5188,9 @@
}
},
"node_modules/npm-registry-fetch": {
- "version": "13.2.0",
- "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.2.0.tgz",
- "integrity": "sha512-NEKnK02Co31+cnDtnAvEdq9xn6E9yKPK/aOHXZieVbw/qVOcFd7su6kviZjImYoszjM2GykMfGMiyyPUQjUkag==",
+ "version": "13.3.0",
+ "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.3.0.tgz",
+ "integrity": "sha512-10LJQ/1+VhKrZjIuY9I/+gQTvumqqlgnsCufoXETHAPFTS3+M+Z5CFhZRDHGavmJ6rOye3UvNga88vl8n1r6gg==",
"inBundle": true,
"dependencies": {
"make-fetch-happen": "^10.0.6",
diff --git a/package.json b/package.json
index f762f7e0e..a88e9f74b 100644
--- a/package.json
+++ b/package.json
@@ -103,7 +103,7 @@
"npm-package-arg": "^9.1.0",
"npm-pick-manifest": "^7.0.1",
"npm-profile": "^6.2.0",
- "npm-registry-fetch": "^13.2.0",
+ "npm-registry-fetch": "^13.3.0",
"npm-user-validate": "^1.0.1",
"npmlog": "^6.0.2",
"opener": "^1.5.2",