How to use the enquirer.Password function in enquirer

To help you get started, we’ve selected a few enquirer 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 enquirer / enquirer / examples / password / prompt.js View on Github external
'use strict';

const { Password } = require('enquirer');

const prompt = new Password({
  name: 'password',
  message: 'What is your password?'
});

prompt.run()
  .then(answer => console.log('Answer:', answer))
  .catch(console.error);
github enquirer / enquirer / examples / password / option-validate.js View on Github external
'use strict';

const { Password } = require('enquirer');

const prompt = new Password({
  name: 'password',
  message: 'What is your password?',
  validate(value) {
    return (!value || value.length < 7) ? 'Password must be 7 or more chars' : true;
  }
});

prompt.run()
  .then(answer => console.log('Answer:', answer))
  .catch(console.error);
github bunqCommunity / bunq-cli / src / Prompts / api_encryption_key.ts View on Github external
export default async ENCRYPTION_KEY => {
    const prompt = new Select({
        message: "No encryption key is set, would you like to enter one or have one generated for you?",
        choices: [{ message: "Generate a new key", value: "generate" }, { message: "Enter a key", value: "custom" }]
    });

    const encryptionKeyType = await prompt.run();
    if (encryptionKeyType === "generate") {
        return randomHex(32);
    } else {
        const inputPrompt = new Password({
            message: "Enter a 16, 24 or 32 bit hex encoded encryption key",
            initial: ENCRYPTION_KEY ? ENCRYPTION_KEY : ""
        });

        return inputPrompt.run();
    }
};
github bunqCommunity / bunq-cli / src / Prompts / api_key.ts View on Github external
export default async (bunqJSClient: BunqJSClient, API_KEY: string = "") => {
    const prompt = new Select({
        message: "No API key is set, would you like to enter one or have one generated for you?",
        choices: [
            { message: "Generate a new sandbox API key", value: "generate" },
            { message: "Enter a API key manually", value: "custom" }
        ]
    });

    const encryptionKeyType = await prompt.run();
    if (encryptionKeyType === "generate") {
        return bunqJSClient.api.sandboxUser.post();
    } else {
        const inputPrompt = new Password({
            message: "Enter a valid API key",
            validate: value => value && value.length === 64,
            initial: API_KEY ? API_KEY : ""
        });

        return inputPrompt.run();
    }
};