diff --git a/node_modules/@npmcli/config/lib/index.js b/node_modules/@npmcli/config/lib/index.js index c6a95b14bfd4d..f8ec551b04625 100644 --- a/node_modules/@npmcli/config/lib/index.js +++ b/node_modules/@npmcli/config/lib/index.js @@ -596,27 +596,27 @@ class Config { const creds = {} // you can set always-auth for a single registry, or as a default - const alwaysAuthReg = this[_get](`${nerfed}:always-auth`) + const alwaysAuthReg = this.get(`${nerfed}:always-auth`) if (alwaysAuthReg !== undefined) creds.alwaysAuth = !!alwaysAuthReg else - creds.alwaysAuth = this[_get]('always-auth') + creds.alwaysAuth = this.get('always-auth') - const email = this[_get](`${nerfed}:email`) || this[_get]('email') + const email = this.get(`${nerfed}:email`) || this.get('email') if (email) creds.email = email - const tokenReg = this[_get](`${nerfed}:_authToken`) || - this[_get](`${nerfed}:-authtoken`) || - nerfed === nerfDart(this[_get]('registry')) && this[_get]('_authToken') + const tokenReg = this.get(`${nerfed}:_authToken`) || + this.get(`${nerfed}:-authtoken`) || + nerfed === nerfDart(this.get('registry')) && this.get('_authToken') if (tokenReg) { creds.token = tokenReg return creds } - const userReg = this[_get](`${nerfed}:username`) - const passReg = this[_get](`${nerfed}:_password`) + const userReg = this.get(`${nerfed}:username`) + const passReg = this.get(`${nerfed}:_password`) if (userReg && passReg) { creds.username = userReg creds.password = Buffer.from(passReg, 'base64').toString('utf8') @@ -627,12 +627,12 @@ class Config { // at this point, we can only use the values if the URI is the // default registry. - const defaultNerf = nerfDart(this[_get]('registry')) + const defaultNerf = nerfDart(this.get('registry')) if (nerfed !== defaultNerf) return creds - const userDef = this[_get]('username') - const passDef = this[_get]('_password') + const userDef = this.get('username') + const passDef = this.get('_password') if (userDef && passDef) { creds.username = userDef creds.password = Buffer.from(passDef, 'base64').toString('utf8') @@ -643,7 +643,7 @@ class Config { // Handle the old-style _auth= style for the default // registry, if set. - const auth = this[_get]('_auth') + const auth = this.get('_auth') if (!auth) return creds diff --git a/node_modules/@npmcli/config/package.json b/node_modules/@npmcli/config/package.json index c542b532b7195..ee9db509e1f15 100644 --- a/node_modules/@npmcli/config/package.json +++ b/node_modules/@npmcli/config/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/config", - "version": "1.1.4", + "version": "1.1.5", "files": [ "lib" ], diff --git a/package-lock.json b/package-lock.json index 0313930bc7ed6..8f2daaf9d9f3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,7 +89,7 @@ "dependencies": { "@npmcli/arborist": "^0.0.16", "@npmcli/ci-detect": "^1.2.0", - "@npmcli/config": "^1.1.4", + "@npmcli/config": "^1.1.5", "@npmcli/run-script": "^1.5.0", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", @@ -430,9 +430,9 @@ "inBundle": true }, "node_modules/@npmcli/config": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.1.4.tgz", - "integrity": "sha512-08hINRBFLaVlNNXFfgViejnDMfCpPgrN9iYTRuizCr/PAPhGkQ0lAhLjtdKN9MeT+tDwQQ9k/9C9B5F5/myN1w==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.1.5.tgz", + "integrity": "sha512-pPs8/b4zr/9qI5Kh43mxS41o4V16kfq78AA1ZbDzkr07a1ve4vGSAydb04rO3F7rnQfSebmKtHcwRorqfdDywQ==", "inBundle": true, "dependencies": { "ini": "^1.3.5", @@ -9495,9 +9495,9 @@ "integrity": "sha512-oN3y7FAROHhrAt7Rr7PnTSwrHrZVRTS2ZbyxeQwSSYD0ifwM3YNgQqbaRmjcWoPyq77MjchusjJDspbzMmip1Q==" }, "@npmcli/config": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.1.4.tgz", - "integrity": "sha512-08hINRBFLaVlNNXFfgViejnDMfCpPgrN9iYTRuizCr/PAPhGkQ0lAhLjtdKN9MeT+tDwQQ9k/9C9B5F5/myN1w==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-1.1.5.tgz", + "integrity": "sha512-pPs8/b4zr/9qI5Kh43mxS41o4V16kfq78AA1ZbDzkr07a1ve4vGSAydb04rO3F7rnQfSebmKtHcwRorqfdDywQ==", "requires": { "ini": "^1.3.5", "mkdirp-infer-owner": "^2.0.0", diff --git a/package.json b/package.json index 965ab67e61a61..d61b28e47dd09 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "write-file-atomic": "^2.4.3", "make-fetch-happen": "^8.0.9", "leven": "^3.1.0", - "@npmcli/config": "^1.1.4" + "@npmcli/config": "^1.1.5" }, "bundleDependencies": [ "@npmcli/arborist", diff --git a/test/lib/adduser.js b/test/lib/adduser.js index d6c153cebc878..454ab17b6f2eb 100644 --- a/test/lib/adduser.js +++ b/test/lib/adduser.js @@ -1,7 +1,7 @@ const requireInject = require('require-inject') const { test } = require('tap') -const getCredentialsByURI = require('../../lib/config/get-credentials-by-uri.js') -const setCredentialsByURI = require('../../lib/config/set-credentials-by-uri.js') +const { getCredentialsByURI, setCredentialsByURI } = + require('@npmcli/config').prototype let result = '' @@ -24,6 +24,12 @@ const authDummy = () => Promise.resolve({ } }) +const deleteMock = (key, where) => { + deletedConfig = { + ...deletedConfig, + [key]: where + } +} const adduser = requireInject('../../lib/adduser.js', { npmlog: { disableProgress: () => null @@ -31,23 +37,18 @@ const adduser = requireInject('../../lib/adduser.js', { '../../lib/npm.js': { flatOptions: _flatOptions, config: { - del (key, where) { - deletedConfig = { - ...deletedConfig, - [key]: where - } - }, + del: deleteMock, + delete: deleteMock, get (key, where) { if (!where || where === 'user') { return _flatOptions[key] } }, getCredentialsByURI, - save (_, cb) { + async save () { if (failSave) { - return cb(new Error('error saving user config')) + throw new Error('error saving user config') } - cb() }, set (key, value, where) { setConfig = { @@ -73,6 +74,13 @@ test('simple login', (t) => { deletedConfig, { _token: 'user', + _password: 'user', + username: 'user', + email: 'user', + _auth: 'user', + _authtoken: 'user', + _authToken: 'user', + '//registry.npmjs.org/:-authtoken': undefined, '//registry.npmjs.org/:_authToken': 'user' }, 'should delete token in user config'