PHP 8.2.30
Preview: otplease.js Size: 1.23 KB
/proc/thread-self/root/proc/self/root/opt/alt/alt-nodejs16/root/lib/node_modules/npm/lib/utils/otplease.js

const log = require('./log-shim')
async function otplease (npm, opts, fn) {
  try {
    return await fn(opts)
  } catch (err) {
    if (!process.stdin.isTTY || !process.stdout.isTTY) {
      throw err
    }

    if (isWebOTP(err)) {
      log.disableProgress()
      const webAuth = require('./web-auth')
      const openUrlPrompt = require('./open-url-prompt')

      const openerPromise = (url, emitter) =>
        openUrlPrompt(
          npm,
          url,
          'Authenticate your account at',
          'Press ENTER to open in the browser...',
          emitter
        )
      const otp = await webAuth(openerPromise, err.body.authUrl, err.body.doneUrl, opts)
      return await fn({ ...opts, otp })
    }

    if (isClassicOTP(err)) {
      const readUserInfo = require('./read-user-info.js')
      const otp = await readUserInfo.otp('This operation requires a one-time password.\nEnter OTP:')
      return await fn({ ...opts, otp })
    }

    throw err
  }
}

function isWebOTP (err) {
  if (!err.code === 'EOTP' || !err.body) {
    return false
  }
  return err.body.authUrl && err.body.doneUrl
}

function isClassicOTP (err) {
  return err.code === 'EOTP' || (err.code === 'E401' && /one-time pass/.test(err.body))
}

module.exports = otplease

Directory Contents

Dirs: 2 × Files: 32

Name Size Perms Modified Actions
- drwxr-xr-x 2026-03-19 07:09:42
Edit Download
config DIR
- drwxr-xr-x 2026-03-19 07:09:42
Edit Download
173 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
978 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
2.46 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.85 KB lrwxr-xr-x 2026-03-09 06:51:26
Edit Download
1.46 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
2.84 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
12.64 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
6.77 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
3.73 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
2.56 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
629 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
3.93 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
740 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
233 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
7.64 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.68 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.95 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.54 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.17 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.23 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
252 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
412 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
9.58 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1.99 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
876 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
4.96 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
807 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
3.73 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
3.18 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
4.45 KB lrw-r--r-- 2026-03-09 06:51:26
Edit Download
1023 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download
558 B lrw-r--r-- 2026-03-09 06:51:26
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).