1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

passphrase generator on CLI

This commit is contained in:
Kyle Spearrin
2018-10-08 22:57:36 -04:00
parent 0361cd1982
commit bd381073b0
3 changed files with 20 additions and 2 deletions

View File

@@ -15,6 +15,9 @@ export class GenerateCommand {
number: cmd.number || false,
special: cmd.special || false,
length: cmd.length || 14,
type: cmd.passphrase ? 'passphrase' : 'password',
wordSeparator: cmd.separator == null ? '-' : cmd.separator,
numWords: cmd.words || 3,
};
if (!options.uppercase && !options.lowercase && !options.special && !options.number) {
options.lowercase = true;
@@ -24,6 +27,14 @@ export class GenerateCommand {
if (options.length < 5) {
options.length = 5;
}
if (options.numWords < 3) {
options.numWords = 3;
}
if (options.wordSeparator === 'space') {
options.wordSeparator = ' ';
} else if (options.wordSeparator != null && options.wordSeparator.length > 1) {
options.wordSeparator = options.wordSeparator[0];
}
const password = await this.passwordGenerationService.generatePassword(options);
const res = new StringResponse(password);
return Response.success(res);