Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
BB.try(() => {
const reg = npmFetch.pickRegistry('foo', opts)
const auth = getAuth(reg, opts)
if (auth.token) {
log.verbose('logout', 'clearing session token for', reg)
return npmFetch(`/-/user/token/${eu(auth.token)}`, opts.concat({
method: 'DELETE',
ignoreBody: true
})).then(() => afterLogout(reg))
} else if (auth.username || auth.password) {
log.verbose('logout', 'clearing user credentials for', reg)
return afterLogout(reg)
} else {
throw new Error(
'Not logged in to', reg + ',', "so can't log out."
)
}
}).nodeify(cb)
}