diff --git a/node_modules/npm-profile/lib/index.js b/node_modules/npm-profile/lib/index.js index 74a8084292a6c..eb97c621dd18d 100644 --- a/node_modules/npm-profile/lib/index.js +++ b/node_modules/npm-profile/lib/index.js @@ -2,6 +2,7 @@ const fetch = require('npm-registry-fetch') const { HttpErrorBase } = require('npm-registry-fetch/lib/errors') +const EventEmitter = require('events') const os = require('os') const { URL } = require('url') const log = require('proc-log') @@ -59,6 +60,9 @@ const webAuth = (opener, opts, body) => { ...opts, method: 'POST', body, + headers: { + 'npm-use-webauthn': opts.authType === 'webauthn', + }, }).then(res => { return Promise.all([res, res.json()]) }).then(([res, content]) => { @@ -70,8 +74,23 @@ const webAuth = (opener, opts, body) => { return content }).then(({ doneUrl, loginUrl }) => { log.verbose('web auth', 'opening url pair') - return opener(loginUrl).then( - () => webAuthCheckLogin(doneUrl, { ...opts, cache: false }) + + const doneEmitter = new EventEmitter() + + const openPromise = opener(loginUrl, doneEmitter) + const webAuthCheckPromise = webAuthCheckLogin(doneUrl, { ...opts, cache: false }) + .then(authResult => { + log.verbose('web auth', 'done-check finished') + + // cancel open prompt if it's present + doneEmitter.emit('abort') + + return authResult + }) + + return Promise.all([openPromise, webAuthCheckPromise]).then( + // pick the auth result and pass it along + ([, authResult]) => authResult ) }).catch(er => { if ((er.statusCode >= 400 && er.statusCode <= 499) || er.statusCode === 500) { diff --git a/node_modules/npm-profile/package.json b/node_modules/npm-profile/package.json index 5e8f2d2391abd..4f9da95d73fe8 100644 --- a/node_modules/npm-profile/package.json +++ b/node_modules/npm-profile/package.json @@ -1,6 +1,6 @@ { "name": "npm-profile", - "version": "6.0.3", + "version": "6.1.0", "description": "Library for updating an npmjs.com profile", "keywords": [], "author": "GitHub Inc.", @@ -20,7 +20,7 @@ ], "devDependencies": { "@npmcli/eslint-config": "^3.0.1", - "@npmcli/template-oss": "3.4.1", + "@npmcli/template-oss": "3.4.2", "nock": "^13.2.4", "tap": "^16.0.1" }, @@ -44,6 +44,6 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "3.4.1" + "version": "3.4.2" } } diff --git a/package-lock.json b/package-lock.json index 2880a4c70e1ca..f9bcb2b0bf265 100644 --- a/package-lock.json +++ b/package-lock.json @@ -133,7 +133,7 @@ "npm-install-checks": "^5.0.0", "npm-package-arg": "^9.0.2", "npm-pick-manifest": "^7.0.1", - "npm-profile": "^6.0.3", + "npm-profile": "^6.1.0", "npm-registry-fetch": "^13.1.1", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.2", @@ -5173,9 +5173,9 @@ } }, "node_modules/npm-profile": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.3.tgz", - "integrity": "sha512-TVeHhnol2Iemud+Sr70/uqax5LnLJ9y361w+m5+Z7WYV2B1t6FhRDxDu72+yYYTvsgshkhnXEqbPjuD87kYXfA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.1.0.tgz", + "integrity": "sha512-JHnBzSqS9xPa0M3g90zhaGElSVdxoAipGkraBaM6Jph2XiSiwFN1HmfRTqndYhDkXia2hWRWl8O5RbDvae++GA==", "inBundle": true, "dependencies": { "npm-registry-fetch": "^13.0.1", @@ -13646,9 +13646,9 @@ } }, "npm-profile": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.3.tgz", - "integrity": "sha512-TVeHhnol2Iemud+Sr70/uqax5LnLJ9y361w+m5+Z7WYV2B1t6FhRDxDu72+yYYTvsgshkhnXEqbPjuD87kYXfA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.1.0.tgz", + "integrity": "sha512-JHnBzSqS9xPa0M3g90zhaGElSVdxoAipGkraBaM6Jph2XiSiwFN1HmfRTqndYhDkXia2hWRWl8O5RbDvae++GA==", "requires": { "npm-registry-fetch": "^13.0.1", "proc-log": "^2.0.0" diff --git a/package.json b/package.json index ed03fde449120..c59dac1322a10 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "npm-install-checks": "^5.0.0", "npm-package-arg": "^9.0.2", "npm-pick-manifest": "^7.0.1", - "npm-profile": "^6.0.3", + "npm-profile": "^6.1.0", "npm-registry-fetch": "^13.1.1", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.2",