Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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);
'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);
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();
}
};
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();
}
};