Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unnecessary logging for webauthn auth #5077

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/auth/legacy.js
Expand Up @@ -2,6 +2,7 @@ const profile = require('npm-profile')
const log = require('../utils/log-shim')
const openUrlPrompt = require('../utils/open-url-prompt.js')
const read = require('../utils/read-user-info.js')
const replaceInfo = require('../utils/replace-info.js')

const loginPrompter = async (creds) => {
creds.username = await read.username('Username:', creds.username)
Expand All @@ -14,6 +15,10 @@ const loginPrompter = async (creds) => {
const login = async (npm, opts) => {
let res

if (opts.authType === 'legacy') {
wraithgar marked this conversation as resolved.
Show resolved Hide resolved
log.notice('', `Log in on ${replaceInfo(opts.registry)}`)
}

const requestOTP = async () => {
const otp = await read.otp(
'Enter one-time password: '
Expand Down
3 changes: 3 additions & 0 deletions lib/auth/sso.js
Expand Up @@ -12,6 +12,7 @@ const npmFetch = require('npm-registry-fetch')
const log = require('../utils/log-shim')
const openUrl = require('../utils/open-url.js')
const otplease = require('../utils/otplease.js')
const replaceInfo = require('../utils/replace-info.js')

const pollForSession = ({ registry, token, opts }) => {
log.info('adduser', 'Polling for validated SSO session')
Expand Down Expand Up @@ -39,6 +40,8 @@ const login = async (npm, { creds, registry, scope }) => {
const opts = { ...npm.flatOptions, creds, registry, scope }
const { ssoType } = opts

log.notice('', `Log in on ${replaceInfo(registry)}`)

if (!ssoType) {
throw new Error('Missing option: sso-type')
}
Expand Down
3 changes: 0 additions & 3 deletions lib/commands/adduser.js
@@ -1,5 +1,4 @@
const log = require('../utils/log-shim.js')
const replaceInfo = require('../utils/replace-info.js')
const BaseCommand = require('../base-command.js')
const authTypes = {
legacy: require('../auth/legacy.js'),
Expand Down Expand Up @@ -28,8 +27,6 @@ class AddUser extends BaseCommand {

log.disableProgress()

log.notice('', `Log in on ${replaceInfo(registry)}`)

const { message, newCreds } = await auth(this.npm, {
...this.npm.flatOptions,
creds,
Expand Down
9 changes: 8 additions & 1 deletion test/lib/auth/sso.js
Expand Up @@ -8,12 +8,17 @@ const _flatOptions = {
const token = '24528a24f240'
const SSO_URL = 'https://registry.npmjs.org/{SSO_URL}'
const profile = {}
const npmFetch = {}
const npmFetch = {
cleanUrl: (s) => s,
}
const sso = t.mock('../../../lib/auth/sso.js', {
'proc-log': {
info: (...msgs) => {
log += msgs.join(' ') + '\n'
},
notice: (...msgs) => {
log += msgs.join(' ') + '\n'
},
},
'npm-profile': profile,
'npm-registry-fetch': npmFetch,
Expand Down Expand Up @@ -82,6 +87,7 @@ t.test('simple login', async (t) => {

t.equal(
log,
' Log in on https://registry.npmjs.org/\n' +
'adduser Polling for validated SSO session\nadduser Authorized user foo\n',
'should have correct logged info msg'
)
Expand Down Expand Up @@ -220,6 +226,7 @@ t.test('scoped login', async (t) => {

t.equal(
log,
' Log in on https://diff-registry.npmjs.org/\n' +
'adduser Polling for validated SSO session\nadduser Authorized user foo\n',
'should have correct logged info msg'
)
Expand Down