(npm, { creds, ...opts })
| 69 | } |
| 70 | |
| 71 | const 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 | |
| 104 | module.exports = { |
| 105 | adduser, |
nothing calls this directly
no test coverage detected
searching dependent graphs…