/
usr
/
local
/
lib
/
node_modules
/
npm
/
lib
/
utils
/
/usr/local/lib/node_modules/npm/lib/utils
mkdir
upload
Name
Size
Mode
Actions
audit-error.js
1078
0644
edit
dl
rm
auth.js
3288
0644
edit
dl
rm
cmd-list.js
2953
0644
edit
dl
rm
completion.fish
1596
0644
edit
dl
rm
completion.sh
1898
0755
edit
dl
rm
did-you-mean.js
1143
0644
edit
dl
rm
display.js
16760
0644
edit
dl
rm
error-message.js
15775
0644
edit
dl
rm
explain-dep.js
3648
0644
edit
dl
rm
explain-eresolve.js
2582
0644
edit
dl
rm
format-bytes.js
624
0644
edit
dl
rm
format-search-stream.js
4913
0644
edit
dl
rm
format.js
2140
0644
edit
dl
rm
get-identity.js
797
0644
edit
dl
rm
get-workspaces.js
1748
0644
edit
dl
rm
installed-deep.js
1129
0644
edit
dl
rm
installed-shallow.js
583
0644
edit
dl
rm
is-windows.js
177
0644
edit
dl
rm
log-file.js
7860
0644
edit
dl
rm
npm-usage.js
2072
0644
edit
dl
rm
oidc.js
7368
0644
edit
dl
rm
open-url.js
2553
0644
edit
dl
rm
output-error.js
788
0644
edit
dl
rm
ping.js
265
0644
edit
dl
rm
queryable.js
9611
0644
edit
dl
rm
read-user-info.js
2095
0644
edit
dl
rm
reify-finish.js
753
0644
edit
dl
rm
reify-output.js
6475
0644
edit
dl
rm
sbom-cyclonedx.js
5656
0644
edit
dl
rm
sbom-spdx.js
5288
0644
edit
dl
rm
tar.js
3511
0644
edit
dl
rm
timers.js
2120
0644
edit
dl
rm
update-workspaces.js
997
0644
edit
dl
rm
validate-lockfile.js
1023
0644
edit
dl
rm
verify-signatures.js
12499
0644
edit
dl
rm
Edit:
/usr/local/lib/node_modules/npm/lib/utils/auth.js
(3288B)
const { webAuthOpener, adduserWeb, loginWeb, loginCouch, adduserCouch } = require('npm-profile') const { log } = require('proc-log') const { createOpener } = require('../utils/open-url.js') const read = require('../utils/read-user-info.js') const otplease = async (npm, opts, fn) => { try { return await fn(opts) } catch (err) { if (!process.stdin.isTTY || !process.stdout.isTTY) { throw err } // web otp if (err.code === 'EOTP' && err.body?.authUrl && err.body?.doneUrl) { const { token: otp } = await webAuthOpener( createOpener(npm, 'Authenticate your account at'), err.body.authUrl, err.body.doneUrl, opts ) return await fn({ ...opts, otp }) } // classic otp if (err.code === 'EOTP' || (err.code === 'E401' && /one-time pass/.test(err.body))) { const otp = await read.otp('This operation requires a one-time password.\nEnter OTP:') return await fn({ ...opts, otp }) } throw err } } const adduser = async (npm, { creds, ...opts }) => { const authType = npm.config.get('auth-type') let res if (authType === 'web') { try { res = await adduserWeb(createOpener(npm, 'Create your account at'), opts) } catch (err) { if (err.code === 'ENYI') { log.verbose('web add user not supported, trying couch') } else { throw err } } } // auth type !== web or ENYI error w/ web adduser if (!res) { const username = await read.username('Username:', creds.username) const password = await read.password('Password:', creds.password) const email = await read.email('Email (this will be public):', creds.email) // npm registry quirk: // If you "add" an existing user with their current password, it's effectively a login, and if that account has otp you'll be prompted for it. res = await otplease(npm, opts, (reqOpts) => adduserCouch(username, email, password, reqOpts)) } // We don't know the username if it was a web login, all we can reliably log is scope and registry const message = `Logged in${opts.scope ? ` to scope ${opts.scope}` : ''} on ${opts.registry}.` log.info('adduser', message) return { message, newCreds: { token: res.token }, } } const login = async (npm, { creds, ...opts }) => { const authType = npm.config.get('auth-type') let res if (authType === 'web') { try { res = await loginWeb(createOpener(npm, 'Login at'), opts) } catch (err) { if (err.code === 'ENYI') { log.verbose('web login not supported, trying couch') } else { throw err } } } // auth type !== web or ENYI error w/ web login if (!res) { const username = await read.username('Username:', creds.username) const password = await read.password('Password:', creds.password) res = await otplease(npm, opts, (reqOpts) => loginCouch(username, password, reqOpts)) } // We don't know the username if it was a web login, all we can reliably log is scope and registry const message = `Logged in${opts.scope ? ` to scope ${opts.scope}` : ''} on ${opts.registry}.` log.info('login', message) return { message, newCreds: { token: res.token }, } } module.exports = { adduser, login, otplease, }
Save
cmd:
run