smart-passphrase 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/cjs/cli.js +5 -3
- package/dist/cjs/generator.js +17 -9
- package/dist/cjs/wordlist.js +18 -7
- package/dist/cli.js +5 -3
- package/dist/generator.js +18 -10
- package/dist/types.d.ts +1 -1
- package/dist/wordlist.d.ts +6 -0
- package/dist/wordlist.js +17 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,11 +98,12 @@ Controls casing style for the words:
|
|
|
98
98
|
### `strength`
|
|
99
99
|
Preset security tiers that adjust words, symbols, and digits.
|
|
100
100
|
|
|
101
|
-
| Tier | Words | Symbols | Digits | Approx. Entropy |
|
|
102
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
101
|
+
| Tier | Words | Symbols | Digits | Formatting | Approx. Entropy |
|
|
102
|
+
| :--- | :--- | :--- | :--- | :--- | :--- |
|
|
103
|
+
| `easy` | 3 | No | 2 | Title-Case-99 | ~30-35 bits |
|
|
104
|
+
| `medium` | 3 | Yes | 3 | raNDomSYmb=123 | ~45-50 bits |
|
|
105
|
+
| `strong` | 4 | Yes | 4 | rAndOMWordS#5432 | ~60-70 bits |
|
|
106
|
+
| `ultra` | 5 | Yes | 5 | vErYStrONgWOrDs%12345 | ~80+ bits |
|
|
106
107
|
|
|
107
108
|
## CLI Reference
|
|
108
109
|
Run `npx smart-passphrase [command] [options]` or install globally.
|
|
@@ -113,10 +114,12 @@ Run `npx smart-passphrase [command] [options]` or install globally.
|
|
|
113
114
|
|
|
114
115
|
### Options
|
|
115
116
|
- `-w, --words <n>` - Set the number of words (default: 3).
|
|
116
|
-
- `-s, --strength <tier>` - Set tier (medium, strong, ultra).
|
|
117
|
+
- `-s, --strength <tier>` - Set tier (easy, medium, strong, ultra).
|
|
117
118
|
- `-c, --copy` - Copy generated passphrase to clipboard.
|
|
118
|
-
- `-n, --
|
|
119
|
-
- `-
|
|
119
|
+
- `-n, --numbers` - Include numbers.
|
|
120
|
+
- `-N, --no-numbers` - Disable numbers.
|
|
121
|
+
- `-S, --symbols` - Include symbols.
|
|
122
|
+
- `-X, --no-symbols` - Disable symbols.
|
|
120
123
|
|
|
121
124
|
## Security Notes
|
|
122
125
|
- Uses `crypto.getRandomValues` for strong randomness.
|
package/dist/cjs/cli.js
CHANGED
|
@@ -16,9 +16,11 @@ program
|
|
|
16
16
|
.description("Generate secure and memorable passphrases with style")
|
|
17
17
|
.version("2.0.0")
|
|
18
18
|
.option("-w, --words <number>", "number of words", (val) => parseInt(val), 3)
|
|
19
|
-
.option("-s, --strength <tier>", "security tier (medium, strong, ultra)", "medium")
|
|
20
|
-
.option("-n, --
|
|
21
|
-
.option("
|
|
19
|
+
.option("-s, --strength <tier>", "security tier (easy, medium, strong, ultra)", "medium")
|
|
20
|
+
.option("-n, --numbers", "include numbers")
|
|
21
|
+
.option("--no-numbers", "exclude numbers")
|
|
22
|
+
.option("-S, --symbols", "include symbols")
|
|
23
|
+
.option("--no-symbols", "exclude symbols")
|
|
22
24
|
.option("-c, --copy", "copy to clipboard")
|
|
23
25
|
.action(async (options) => {
|
|
24
26
|
console.log("");
|
package/dist/cjs/generator.js
CHANGED
|
@@ -6,11 +6,19 @@ exports.entropyEstimate = entropyEstimate;
|
|
|
6
6
|
const wordlist_js_1 = require("./wordlist.js");
|
|
7
7
|
const utils_js_1 = require("./utils.js");
|
|
8
8
|
const strengthDefaults = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
easy: { words: 3, symbols: false, numbers: true, digits: 2, uppercaseStyle: "title", separator: "-" },
|
|
10
|
+
medium: { words: 3, symbols: true, numbers: true, digits: 3 },
|
|
11
|
+
strong: { words: 4, symbols: true, numbers: true, digits: 4 },
|
|
12
|
+
ultra: { words: 5, symbols: true, numbers: true, digits: 5 }
|
|
12
13
|
};
|
|
13
|
-
function buildDictionary(overrides) {
|
|
14
|
+
function buildDictionary(overrides, strength) {
|
|
15
|
+
if (strength === "easy") {
|
|
16
|
+
return {
|
|
17
|
+
adjectives: overrides?.adjectives ?? wordlist_js_1.simpleAdjectives,
|
|
18
|
+
nouns: overrides?.nouns ?? wordlist_js_1.simpleNouns,
|
|
19
|
+
verbs: overrides?.verbs ?? wordlist_js_1.simpleVerbs
|
|
20
|
+
};
|
|
21
|
+
}
|
|
14
22
|
return {
|
|
15
23
|
adjectives: overrides?.adjectives ?? wordlist_js_1.adjectives,
|
|
16
24
|
nouns: overrides?.nouns ?? wordlist_js_1.nouns,
|
|
@@ -50,12 +58,12 @@ function generatePassphrase(options = {}) {
|
|
|
50
58
|
const defaults = options.strength ? strengthDefaults[options.strength] : strengthDefaults.medium;
|
|
51
59
|
const wordCount = options.words ?? defaults.words;
|
|
52
60
|
const useSymbols = options.symbols ?? defaults.symbols;
|
|
53
|
-
const numbersOption = options.numbers ??
|
|
61
|
+
const numbersOption = options.numbers ?? defaults.numbers;
|
|
54
62
|
const digits = typeof numbersOption === "object" ? numbersOption.digits ?? defaults.digits : defaults.digits;
|
|
55
|
-
const separator = options.separator ?? "";
|
|
56
|
-
const uppercaseStyle = options.uppercaseStyle ?? "random";
|
|
63
|
+
const separator = options.separator ?? defaults.separator ?? "";
|
|
64
|
+
const uppercaseStyle = options.uppercaseStyle ?? defaults.uppercaseStyle ?? "random";
|
|
57
65
|
const unique = options.unique ?? true;
|
|
58
|
-
const dictionary = buildDictionary(options.dictionary);
|
|
66
|
+
const dictionary = buildDictionary(options.dictionary, options.strength);
|
|
59
67
|
const pattern = options.pattern ?? defaultPattern(wordCount);
|
|
60
68
|
if (pattern.length !== wordCount) {
|
|
61
69
|
throw new Error("pattern length must match words");
|
|
@@ -86,7 +94,7 @@ function entropyEstimate(options = {}) {
|
|
|
86
94
|
const useSymbols = options.symbols ?? defaults.symbols;
|
|
87
95
|
const numbersOption = options.numbers ?? true;
|
|
88
96
|
const digits = typeof numbersOption === "object" ? numbersOption.digits ?? defaults.digits : defaults.digits;
|
|
89
|
-
const dictionary = buildDictionary(options.dictionary);
|
|
97
|
+
const dictionary = buildDictionary(options.dictionary, options.strength);
|
|
90
98
|
const pattern = options.pattern ?? defaultPattern(wordCount);
|
|
91
99
|
const sizes = pattern.map((kind) => {
|
|
92
100
|
const list = kind === "adj" ? dictionary.adjectives : kind === "noun" ? dictionary.nouns : dictionary.verbs;
|
package/dist/cjs/wordlist.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verbs = exports.nouns = exports.adjectives = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
// Original
|
|
3
|
+
exports.verbs = exports.complexVerbs = exports.simpleVerbs = exports.nouns = exports.complexNouns = exports.simpleNouns = exports.adjectives = exports.complexAdjectives = exports.simpleAdjectives = void 0;
|
|
4
|
+
exports.simpleAdjectives = [
|
|
6
5
|
"quick", "silent", "brave", "fancy", "eager", "bright",
|
|
7
6
|
"gentle", "proud", "curious", "steady", "bold", "calm",
|
|
7
|
+
"happy", "tiny", "large", "blue", "red", "green", "fast",
|
|
8
|
+
"slow", "smart", "kind", "soft", "hard"
|
|
9
|
+
];
|
|
10
|
+
exports.complexAdjectives = [
|
|
8
11
|
// Advanced originals
|
|
9
12
|
"resilient", "ephemeral", "luminous", "tenacious", "serene",
|
|
10
13
|
"voracious", "ethereal", "stoic", "audacious", "fleeting",
|
|
@@ -38,10 +41,14 @@ exports.adjectives = [
|
|
|
38
41
|
"undying",
|
|
39
42
|
"everlasting"
|
|
40
43
|
];
|
|
41
|
-
exports.
|
|
42
|
-
|
|
44
|
+
exports.adjectives = [...exports.simpleAdjectives, ...exports.complexAdjectives];
|
|
45
|
+
exports.simpleNouns = [
|
|
43
46
|
"tiger", "goose", "rocket", "mask", "forest", "ocean",
|
|
44
47
|
"ember", "comet", "cipher", "garden", "river", "mountain",
|
|
48
|
+
"cat", "dog", "bird", "tree", "star", "moon", "sun",
|
|
49
|
+
"book", "pen", "desk", "home", "road"
|
|
50
|
+
];
|
|
51
|
+
exports.complexNouns = [
|
|
45
52
|
// Advanced originals
|
|
46
53
|
"phantom", "echo", "horizon", "sentinel", "abyss", "beacon",
|
|
47
54
|
"shroud", "monolith", "specter", "harbinger", "labyrinth",
|
|
@@ -75,10 +82,13 @@ exports.nouns = [
|
|
|
75
82
|
"archive",
|
|
76
83
|
"chronicle"
|
|
77
84
|
];
|
|
78
|
-
exports.
|
|
79
|
-
|
|
85
|
+
exports.nouns = [...exports.simpleNouns, ...exports.complexNouns];
|
|
86
|
+
exports.simpleVerbs = [
|
|
80
87
|
"run", "jump", "build", "mark", "drift", "spark",
|
|
81
88
|
"forge", "glide", "shift", "trace", "craft", "sprint",
|
|
89
|
+
"walk", "sing", "read", "play", "draw", "smile"
|
|
90
|
+
];
|
|
91
|
+
exports.complexVerbs = [
|
|
82
92
|
// Advanced originals
|
|
83
93
|
"lunge", "flicker", "shatter", "conceal", "summon", "evade",
|
|
84
94
|
"descend", "ascend", "sunder", "kindle", "lurk", "surge",
|
|
@@ -111,3 +121,4 @@ exports.verbs = [
|
|
|
111
121
|
"memorialize",
|
|
112
122
|
"pay homage"
|
|
113
123
|
];
|
|
124
|
+
exports.verbs = [...exports.simpleVerbs, ...exports.complexVerbs];
|
package/dist/cli.js
CHANGED
|
@@ -11,9 +11,11 @@ program
|
|
|
11
11
|
.description("Generate secure and memorable passphrases with style")
|
|
12
12
|
.version("2.0.0")
|
|
13
13
|
.option("-w, --words <number>", "number of words", (val) => parseInt(val), 3)
|
|
14
|
-
.option("-s, --strength <tier>", "security tier (medium, strong, ultra)", "medium")
|
|
15
|
-
.option("-n, --
|
|
16
|
-
.option("
|
|
14
|
+
.option("-s, --strength <tier>", "security tier (easy, medium, strong, ultra)", "medium")
|
|
15
|
+
.option("-n, --numbers", "include numbers")
|
|
16
|
+
.option("--no-numbers", "exclude numbers")
|
|
17
|
+
.option("-S, --symbols", "include symbols")
|
|
18
|
+
.option("--no-symbols", "exclude symbols")
|
|
17
19
|
.option("-c, --copy", "copy to clipboard")
|
|
18
20
|
.action(async (options) => {
|
|
19
21
|
console.log("");
|
package/dist/generator.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import { adjectives, nouns, verbs } from "./wordlist.js";
|
|
1
|
+
import { adjectives, nouns, verbs, simpleAdjectives, simpleNouns, simpleVerbs } from "./wordlist.js";
|
|
2
2
|
import { applyCase, defaultSymbols, randomItem, randomNumberByDigits } from "./utils.js";
|
|
3
3
|
const strengthDefaults = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
easy: { words: 3, symbols: false, numbers: true, digits: 2, uppercaseStyle: "title", separator: "-" },
|
|
5
|
+
medium: { words: 3, symbols: true, numbers: true, digits: 3 },
|
|
6
|
+
strong: { words: 4, symbols: true, numbers: true, digits: 4 },
|
|
7
|
+
ultra: { words: 5, symbols: true, numbers: true, digits: 5 }
|
|
7
8
|
};
|
|
8
|
-
function buildDictionary(overrides) {
|
|
9
|
+
function buildDictionary(overrides, strength) {
|
|
10
|
+
if (strength === "easy") {
|
|
11
|
+
return {
|
|
12
|
+
adjectives: overrides?.adjectives ?? simpleAdjectives,
|
|
13
|
+
nouns: overrides?.nouns ?? simpleNouns,
|
|
14
|
+
verbs: overrides?.verbs ?? simpleVerbs
|
|
15
|
+
};
|
|
16
|
+
}
|
|
9
17
|
return {
|
|
10
18
|
adjectives: overrides?.adjectives ?? adjectives,
|
|
11
19
|
nouns: overrides?.nouns ?? nouns,
|
|
@@ -45,12 +53,12 @@ export function generatePassphrase(options = {}) {
|
|
|
45
53
|
const defaults = options.strength ? strengthDefaults[options.strength] : strengthDefaults.medium;
|
|
46
54
|
const wordCount = options.words ?? defaults.words;
|
|
47
55
|
const useSymbols = options.symbols ?? defaults.symbols;
|
|
48
|
-
const numbersOption = options.numbers ??
|
|
56
|
+
const numbersOption = options.numbers ?? defaults.numbers;
|
|
49
57
|
const digits = typeof numbersOption === "object" ? numbersOption.digits ?? defaults.digits : defaults.digits;
|
|
50
|
-
const separator = options.separator ?? "";
|
|
51
|
-
const uppercaseStyle = options.uppercaseStyle ?? "random";
|
|
58
|
+
const separator = options.separator ?? defaults.separator ?? "";
|
|
59
|
+
const uppercaseStyle = options.uppercaseStyle ?? defaults.uppercaseStyle ?? "random";
|
|
52
60
|
const unique = options.unique ?? true;
|
|
53
|
-
const dictionary = buildDictionary(options.dictionary);
|
|
61
|
+
const dictionary = buildDictionary(options.dictionary, options.strength);
|
|
54
62
|
const pattern = options.pattern ?? defaultPattern(wordCount);
|
|
55
63
|
if (pattern.length !== wordCount) {
|
|
56
64
|
throw new Error("pattern length must match words");
|
|
@@ -81,7 +89,7 @@ export function entropyEstimate(options = {}) {
|
|
|
81
89
|
const useSymbols = options.symbols ?? defaults.symbols;
|
|
82
90
|
const numbersOption = options.numbers ?? true;
|
|
83
91
|
const digits = typeof numbersOption === "object" ? numbersOption.digits ?? defaults.digits : defaults.digits;
|
|
84
|
-
const dictionary = buildDictionary(options.dictionary);
|
|
92
|
+
const dictionary = buildDictionary(options.dictionary, options.strength);
|
|
85
93
|
const pattern = options.pattern ?? defaultPattern(wordCount);
|
|
86
94
|
const sizes = pattern.map((kind) => {
|
|
87
95
|
const list = kind === "adj" ? dictionary.adjectives : kind === "noun" ? dictionary.nouns : dictionary.verbs;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type UppercaseStyle = "none" | "random" | "title" | "upper" | "lower";
|
|
2
|
-
export type Strength = "medium" | "strong" | "ultra";
|
|
2
|
+
export type Strength = "easy" | "medium" | "strong" | "ultra";
|
|
3
3
|
export type WordKind = "adj" | "noun" | "verb";
|
|
4
4
|
export interface Dictionary {
|
|
5
5
|
adjectives: string[];
|
package/dist/wordlist.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export declare const simpleAdjectives: string[];
|
|
2
|
+
export declare const complexAdjectives: string[];
|
|
1
3
|
export declare const adjectives: string[];
|
|
4
|
+
export declare const simpleNouns: string[];
|
|
5
|
+
export declare const complexNouns: string[];
|
|
2
6
|
export declare const nouns: string[];
|
|
7
|
+
export declare const simpleVerbs: string[];
|
|
8
|
+
export declare const complexVerbs: string[];
|
|
3
9
|
export declare const verbs: string[];
|
package/dist/wordlist.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export const
|
|
2
|
-
// Original
|
|
1
|
+
export const simpleAdjectives = [
|
|
3
2
|
"quick", "silent", "brave", "fancy", "eager", "bright",
|
|
4
3
|
"gentle", "proud", "curious", "steady", "bold", "calm",
|
|
4
|
+
"happy", "tiny", "large", "blue", "red", "green", "fast",
|
|
5
|
+
"slow", "smart", "kind", "soft", "hard"
|
|
6
|
+
];
|
|
7
|
+
export const complexAdjectives = [
|
|
5
8
|
// Advanced originals
|
|
6
9
|
"resilient", "ephemeral", "luminous", "tenacious", "serene",
|
|
7
10
|
"voracious", "ethereal", "stoic", "audacious", "fleeting",
|
|
@@ -35,10 +38,14 @@ export const adjectives = [
|
|
|
35
38
|
"undying",
|
|
36
39
|
"everlasting"
|
|
37
40
|
];
|
|
38
|
-
export const
|
|
39
|
-
|
|
41
|
+
export const adjectives = [...simpleAdjectives, ...complexAdjectives];
|
|
42
|
+
export const simpleNouns = [
|
|
40
43
|
"tiger", "goose", "rocket", "mask", "forest", "ocean",
|
|
41
44
|
"ember", "comet", "cipher", "garden", "river", "mountain",
|
|
45
|
+
"cat", "dog", "bird", "tree", "star", "moon", "sun",
|
|
46
|
+
"book", "pen", "desk", "home", "road"
|
|
47
|
+
];
|
|
48
|
+
export const complexNouns = [
|
|
42
49
|
// Advanced originals
|
|
43
50
|
"phantom", "echo", "horizon", "sentinel", "abyss", "beacon",
|
|
44
51
|
"shroud", "monolith", "specter", "harbinger", "labyrinth",
|
|
@@ -72,10 +79,13 @@ export const nouns = [
|
|
|
72
79
|
"archive",
|
|
73
80
|
"chronicle"
|
|
74
81
|
];
|
|
75
|
-
export const
|
|
76
|
-
|
|
82
|
+
export const nouns = [...simpleNouns, ...complexNouns];
|
|
83
|
+
export const simpleVerbs = [
|
|
77
84
|
"run", "jump", "build", "mark", "drift", "spark",
|
|
78
85
|
"forge", "glide", "shift", "trace", "craft", "sprint",
|
|
86
|
+
"walk", "sing", "read", "play", "draw", "smile"
|
|
87
|
+
];
|
|
88
|
+
export const complexVerbs = [
|
|
79
89
|
// Advanced originals
|
|
80
90
|
"lunge", "flicker", "shatter", "conceal", "summon", "evade",
|
|
81
91
|
"descend", "ascend", "sunder", "kindle", "lurk", "surge",
|
|
@@ -108,3 +118,4 @@ export const verbs = [
|
|
|
108
118
|
"memorialize",
|
|
109
119
|
"pay homage"
|
|
110
120
|
];
|
|
121
|
+
export const verbs = [...simpleVerbs, ...complexVerbs];
|
package/package.json
CHANGED