MCPcopy Index your code
hub / github.com/nodejs/node / login

Function login

deps/npm/lib/utils/auth.js:71–102  ·  view source on GitHub ↗
(npm, { creds, ...opts })

Source from the content-addressed store, hash-verified

69}
70
71const login = async (npm, { creds, ...opts }) => {
72 const authType = npm.config.get('auth-type')
73 let res
74 if (authType === 'web') {
75 try {
76 res = await loginWeb(createOpener(npm, 'Login at'), opts)
77 } catch (err) {
78 if (err.code === 'ENYI') {
79 log.verbose('web login not supported, trying couch')
80 } else {
81 throw err
82 }
83 }
84 }
85
86 // auth type !== web or ENYI error w/ web login
87 if (!res) {
88 const username = await read.username('Username:', creds.username)
89 const password = await read.password('Password:', creds.password)
90 res = await otplease(npm, opts, (reqOpts) => loginCouch(username, password, reqOpts))
91 }
92
93 // We don't know the username if it was a web login, all we can reliably log is scope and registry
94 const message = `Logged in${opts.scope ? ` to scope ${opts.scope}` : ''} on ${opts.registry}.`
95
96 log.info('login', message)
97
98 return {
99 message,
100 newCreds: { token: res.token },
101 }
102}
103
104module.exports = {
105 adduser,

Callers

nothing calls this directly

Calls 7

createOpenerFunction · 0.85
otpleaseFunction · 0.85
verboseMethod · 0.80
usernameMethod · 0.80
passwordMethod · 0.80
infoMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…