We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4cca9cb commit ad67461Copy full SHA for ad67461
1 file changed
lib/utils/otplease.js
@@ -0,0 +1,27 @@
1
+'use strict'
2
+
3
+const BB = require('bluebird')
4
5
+const optCheck = require('figgy-pudding')({
6
+ prompt: {default: 'This operation requires a one-time password.\nEnter OTP:'},
7
+ otp: {}
8
+})
9
+const readUserInfo = require('./read-user-info.js')
10
11
+module.exports = otplease
12
+function otplease (opts, fn) {
13
+ opts = opts.concat ? opts : optCheck(opts)
14
+ return BB.try(() => {
15
+ return fn(opts)
16
+ }).catch(err => {
17
+ if (err.code !== 'EOTP' && !(err.code === 'E401' && /one-time pass/.test(err.body))) {
18
+ throw err
19
+ } else if (!process.stdin.isTTY || !process.stdout.isTTY) {
20
21
+ } else {
22
+ return readUserInfo.otp(
23
+ optCheck(opts).prompt
24
+ ).then(otp => fn(opts.concat({otp})))
25
+ }
26
+ })
27
+}
0 commit comments