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
path: root/lib/auth
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-10-23 21:15:35 +0300
committerisaacs <i@izs.me>2020-10-23 21:23:15 +0300
commit47640eb2c3cd9891e904e3f6bc705b6618096103 (patch)
tree8b1b635135a5672ed0da4d8e6feade0f9d8fa60d /lib/auth
parentb737ee99961364827bacf210a3e5ca5d2b7edad2 (diff)
update lint rules to match @npmcli/arborist
Diffstat (limited to 'lib/auth')
-rw-r--r--lib/auth/legacy.js17
-rw-r--r--lib/auth/sso.js16
2 files changed, 16 insertions, 17 deletions
diff --git a/lib/auth/legacy.js b/lib/auth/legacy.js
index 883a32fd5..4178c40b9 100644
--- a/lib/auth/legacy.js
+++ b/lib/auth/legacy.js
@@ -47,11 +47,10 @@ const login = async (opts) => {
opts
)
} catch (err) {
- if (err.code === 'EOTP') {
+ if (err.code === 'EOTP')
newUser = await requestOTP()
- } else {
+ else
throw err
- }
}
return newUser
@@ -65,20 +64,20 @@ const login = async (opts) => {
opts.creds.username &&
opts.creds.password &&
opts.creds.email)
- if (err.code === 'EOTP') {
+ if (err.code === 'EOTP')
res = await requestOTP()
- } else if (needsMoreInfo) {
+ else if (needsMoreInfo)
throw err
- } else {
+ else {
// TODO: maybe this needs to check for err.code === 'E400' instead?
res = await addNewUser()
}
}
const newCreds = {}
- if (res && res.token) {
+ if (res && res.token)
newCreds.token = res.token
- } else {
+ else {
newCreds.username = opts.creds.username
newCreds.password = opts.creds.password
newCreds.email = opts.creds.email
@@ -94,7 +93,7 @@ const login = async (opts) => {
return {
message,
- newCreds
+ newCreds,
}
}
diff --git a/lib/auth/sso.js b/lib/auth/sso.js
index 5444e9ca0..8e4c34531 100644
--- a/lib/auth/sso.js
+++ b/lib/auth/sso.js
@@ -30,9 +30,8 @@ const pollForSession = ({ registry, token, opts }) => {
return sleep(opts.ssoPollFrequency).then(() => {
return pollForSession({ registry, token, opts })
})
- } else {
+ } else
throw err
- }
}
)
}
@@ -47,9 +46,8 @@ const login = async ({ creds, registry, scope }) => {
const opts = { ...npm.flatOptions, creds, registry, scope }
const { ssoType } = opts
- if (!ssoType) {
+ if (!ssoType)
throw new Error('Missing option: sso-type')
- }
// We're reusing the legacy login endpoint, so we need some dummy
// stuff here to pass validation. They're never used.
@@ -57,15 +55,17 @@ const login = async ({ creds, registry, scope }) => {
username: 'npm_' + ssoType + '_auth_dummy_user',
password: 'placeholder',
email: 'support@npmjs.com',
- authType: ssoType
+ authType: ssoType,
}
const { token, sso } = await otplease(opts,
opts => profile.loginCouch(auth.username, auth.password, opts)
)
- if (!token) { throw new Error('no SSO token returned') }
- if (!sso) { throw new Error('no SSO URL returned by services') }
+ if (!token)
+ throw new Error('no SSO token returned')
+ if (!sso)
+ throw new Error('no SSO URL returned by services')
await openUrl(sso, 'to complete your login please visit')
@@ -78,7 +78,7 @@ const login = async ({ creds, registry, scope }) => {
return {
message,
- newCreds: { token }
+ newCreds: { token },
}
}