PHP 8.2.30
Preview: read-user-info.js Size: 2.00 KB
//proc/self/root/proc/thread-self/root/opt/alt/alt-nodejs19/root/usr/lib/node_modules/npm/lib/utils/read-user-info.js

const read = require('read')
const userValidate = require('npm-user-validate')
const log = require('./log-shim.js')

exports.otp = readOTP
exports.password = readPassword
exports.username = readUsername
exports.email = readEmail

const otpPrompt = `This command requires a one-time password (OTP) from your authenticator app.
Enter one below. You can also pass one on the command line by appending --otp=123456.
For more information, see:
https://docs.npmjs.com/getting-started/using-two-factor-authentication
Enter OTP: `
const passwordPrompt = 'npm password: '
const usernamePrompt = 'npm username: '
const emailPrompt = 'email (this IS public): '

function readWithProgress (opts) {
  log.clearProgress()
  return read(opts).finally(() => log.showProgress())
}

function readOTP (msg = otpPrompt, otp, isRetry) {
  if (isRetry && otp && /^[\d ]+$|^[A-Fa-f0-9]{64,64}$/.test(otp)) {
    return otp.replace(/\s+/g, '')
  }

  return readWithProgress({ prompt: msg, default: otp || '' })
    .then((rOtp) => readOTP(msg, rOtp, true))
}

function readPassword (msg = passwordPrompt, password, isRetry) {
  if (isRetry && password) {
    return password
  }

  return readWithProgress({ prompt: msg, silent: true, default: password || '' })
    .then((rPassword) => readPassword(msg, rPassword, true))
}

function readUsername (msg = usernamePrompt, username, isRetry) {
  if (isRetry && username) {
    const error = userValidate.username(username)
    if (error) {
      log.warn(error.message)
    } else {
      return Promise.resolve(username.trim())
    }
  }

  return readWithProgress({ prompt: msg, default: username || '' })
    .then((rUsername) => readUsername(msg, rUsername, true))
}

function readEmail (msg = emailPrompt, email, isRetry) {
  if (isRetry && email) {
    const error = userValidate.email(email)
    if (error) {
      log.warn(error.message)
    } else {
      return email.trim()
    }
  }

  return readWithProgress({ prompt: msg, default: email || '' })
    .then((username) => readEmail(msg, username, true))
}

Directory Contents

Dirs: 2 × Files: 34

Name Size Perms Modified Actions
- drwxr-xr-x 2024-03-03 22:54:11
Edit Download
config DIR
- drwxr-xr-x 2024-03-03 22:54:11
Edit Download
173 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.02 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.80 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.16 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.56 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.85 KB lrwxr-xr-x 2023-12-06 18:07:50
Edit Download
1.46 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.43 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
13.53 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
6.74 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.50 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.55 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
629 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.93 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
802 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
233 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
7.03 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.68 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.04 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.44 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.09 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.23 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
252 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
412 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
9.56 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.00 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
876 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
4.97 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
807 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.90 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.73 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
4.19 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1023 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
558 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download

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