Server : nginx/1.20.1 System : Linux ccpf-production-2021 5.4.0-148-generic #165-Ubuntu SMP Tue Apr 18 08:53:12 UTC 2023 x86_64 User : forge ( 1000) PHP Version : 7.4.21 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/lib/node_modules/npm/lib/ |
module.exports = adduser
const log = require('npmlog')
const npm = require('./npm.js')
const usage = require('./utils/usage')
let crypto
try {
crypto = require('crypto')
} catch (ex) {}
adduser.usage = usage(
'adduser',
'npm adduser [--registry=url] [--scope=@orgname] [--auth-type=legacy] [--always-auth]'
)
function adduser (args, cb) {
if (!crypto) {
return cb(new Error(
'You must compile node with ssl support to use the adduser feature'
))
}
let registry = npm.config.get('registry')
const scope = npm.config.get('scope')
const creds = npm.config.getCredentialsByURI(npm.config.get('registry'))
if (scope) {
const scopedRegistry = npm.config.get(scope + ':registry')
const cliRegistry = npm.config.get('registry', 'cli')
if (scopedRegistry && !cliRegistry) registry = scopedRegistry
}
log.disableProgress()
let auth
try {
auth = require('./auth/' + npm.config.get('auth-type'))
} catch (e) {
return cb(new Error('no such auth module'))
}
auth.login(creds, registry, scope, function (err, newCreds) {
if (err) return cb(err)
npm.config.del('_token', 'user') // prevent legacy pollution
if (scope) npm.config.set(scope + ':registry', registry, 'user')
npm.config.setCredentialsByURI(registry, newCreds)
npm.config.save('user', cb)
})
}