How to use npm-user-validate - 8 common examples

To help you get started, we’ve selected a few npm-user-validate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidhealey / waistline / node_modules / npm / lib / adduser.js View on Github external
function readPassword (c, u, cb) {
  var v = userValidate.pw

  var prompt
  if (c.p && !c.changed) {
    prompt = "Password: (or leave unchanged) "
  } else {
    prompt = "Password: "
  }

  read({prompt: prompt, silent: true}, function (er, pw) {
    if (er) {
      return cb(er.message === "cancelled" ? er.message : er)
    }

    if (!c.changed && pw === "") {
      // when the username was not changed,
      // empty response means "use the old value"
github bcoe / nodemailer-mock-transport / index.js View on Github external
function validate (addr) {
  try {
    var err = userValidate.email(addr)
    if (err != null) return err
  } catch (_err) {
    return new Error('Error validating address.')
  }
  return null
}
github npm / npm-profile / cmds / util / read.js View on Github external
function readEmail (email, opts) {
  if (email) {
    const error = userValidate.email(email)
    if (error) {
      opts.log && opts.log.warn(error.message)
    } else {
      return email.trim()
    }
  }

  return read({prompt: 'Email (this IS public): ', default: email || ''})
    .then(username => readEmail(username, opts))
}
github graalvm / graaljs / graal-nodejs / deps / npm / lib / utils / read-user-info.js View on Github external
function readEmail (msg, email, opts, isRetry) {
  if (!msg) msg = 'email (this IS public): '
  if (isRetry && email) {
    const error = userValidate.email(email)
    if (error) {
      opts.log && opts.log.warn(error.message)
    } else {
      return email.trim()
    }
  }

  return read({prompt: msg, default: email || ''})
    .then((username) => readEmail(msg, username, opts, true))
}
github entropic-dev / entropic / services / storage / lib / validations.js View on Github external
const { protocol, username, password, host, pathname } = new URL(
    `ent://${spec}`
  );

  if (protocol !== 'ent:') {
    warnings.push('Contained unexpected protocol portion');
    return false;
  }

  if (password) {
    warnings.push('Contained unexpected password in namespace portion');
    return false;
  }

  try {
    validate.username(username);
  } catch (err) {
    warnings.push('Username: ' + err.message);
    return false;
  }

  const name = pathname.slice(1);
  const errors = packageNameOK(name, username);
  if (errors) {
    warnings.push(String(errors));
    return false;
  }

  return {
    canonical: `${username}@${host}/${encodeURIComponent(name)}`,
    namespace: username,
    host: host,
github npm / npm-profile / cmds / util / read.js View on Github external
function readUsername (username, opts) {
  if (username) {
    const error = userValidate.username(username)
    if (error) {
      opts.log && opts.log.warn(error.message)
    } else {
      return username.trim()
    }
  }

  return read({prompt: 'Username: ', default: username || ''})
    .then(username => readUsername(username, opts))
}
github graalvm / graaljs / graal-nodejs / deps / npm / lib / utils / read-user-info.js View on Github external
function readUsername (msg, username, opts, isRetry) {
  if (!msg) msg = 'npm username: '
  if (isRetry && username) {
    const error = userValidate.username(username)
    if (error) {
      opts.log && opts.log.warn(error.message)
    } else {
      return Promise.resolve(username.trim())
    }
  }

  return read({prompt: msg, default: username || ''})
    .then((username) => readUsername(msg, username, opts, true))
}
github entropic-dev / entropic / services / web / handlers / auth.js View on Github external
async function signupAction(context) {
  const remoteAuth = context.session.get('remoteAuth');

  if (!remoteAuth) {
    return response.redirect('/login');
  }

  const { username, email } = querystring.parse(await text(context.request));
  context.username = username;
  context.email = email;

  try {
    validate.username(username);
  } catch (err) {
    context.errors = { username: err.message };
    return signup(context);
  }

  if (!isEmailMaybe(email)) {
    context.errors = { email: 'Sorry, that does not look like an email.' };
    return signup(context);
  }

  const [err, user] = await context.storageApi
    .signup({
      username,
      email,
      remoteAuth
    })

npm-user-validate

User validations for npm

BSD-2-Clause
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis