Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-10-04 20:15:47 +0300
committerRebecca Turner <me@re-becca.org>2018-02-07 03:16:22 +0300
commitf8b1f6aecadd3b9953c2b8b05d15f3a9cff67cfd (patch)
treefdab6c92ab0c88b2ee7cabd83fdf66591e6a49ac /lib/profile.js
parentd259ab014748634a89cad5b20eb7a40f3223c0d5 (diff)
auth, token: Make new commands support legacy auths
Diffstat (limited to 'lib/profile.js')
-rw-r--r--lib/profile.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/profile.js b/lib/profile.js
index 587a26ca8..797c3cca4 100644
--- a/lib/profile.js
+++ b/lib/profile.js
@@ -82,7 +82,18 @@ function config () {
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
- conf.auth = npm.config.getCredentialsByURI(conf.registry)
+ const creds = npm.config.getCredentialsByURI(conf.registry)
+ if (creds.token) {
+ conf.auth = {token: creds.token}
+ } else if (creds.username) {
+ conf.auth = {basic: {username: creds.username, password: creds.password}}
+ } else if (creds.auth) {
+ const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
+ conf.auth = {basic: {username: auth[0], password: auth[1]}}
+ } else {
+ conf.auth = {}
+ }
+
if (conf.otp) conf.auth.otp = conf.otp
return conf
}