Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

Commit b5babf0

Browse filesBrowse files
jdeniauiarna
authored andcommitted
publish: Better message when an "OTP" error occurs
PR-URL: #19580 Credit: @jdeniau Reviewed-By: @iarna
1 parent d2d290b commit b5babf0
Copy full SHA for b5babf0

File tree

Expand file treeCollapse file tree

2 files changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-2
lines changed

‎lib/publish.js

Copy file name to clipboardExpand all lines: lib/publish.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function upload (arg, pkg, isRetry, cached) {
209209
if (err.code !== 'EOTP' && !(err.code === 'E401' && /one-time pass/.test(err.message))) throw err
210210
// we prompt on stdout and read answers from stdin, so they need to be ttys.
211211
if (!process.stdin.isTTY || !process.stdout.isTTY) throw err
212-
return readUserInfo.otp('Enter OTP: ').then((otp) => {
212+
return readUserInfo.otp().then((otp) => {
213213
npm.config.set('otp', otp)
214214
return upload(arg, pkg, isRetry, cached)
215215
})

‎lib/utils/read-user-info.js

Copy file name to clipboardExpand all lines: lib/utils/read-user-info.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ function read (opts) {
1919
}
2020

2121
function readOTP (msg, otp, isRetry) {
22-
if (!msg) msg = 'Enter OTP: '
22+
if (!msg) {
23+
msg = [
24+
'There was an error while trying authentication due to OTP (One-Time-Password).',
25+
'The One-Time-Password is generated via applications like Authy or',
26+
'Google Authenticator, for more information see:',
27+
'https://docs.npmjs.com/getting-started/using-two-factor-authentication',
28+
'Enter OTP: '
29+
].join('\n')
30+
}
2331
if (isRetry && otp && /^[\d ]+$|^[A-Fa-f0-9]{64,64}$/.test(otp)) return otp.replace(/\s+/g, '')
2432

2533
return read({prompt: msg, default: otp || ''})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.