smart-passphrase 1.0.0 → 1.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 +148 -23
- package/package.json +45 -45
package/README.md
CHANGED
|
@@ -1,47 +1,172 @@
|
|
|
1
1
|
# smart-passphrase
|
|
2
2
|
|
|
3
|
-
A lightweight, secure, and memorable passphrase generator for Node.js and
|
|
3
|
+
A lightweight, secure, and memorable passphrase generator for Node.js and modern browsers. Built to work smoothly in React, Next.js, Vite, and plain Node projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Features
|
|
6
|
+
- Human‑readable passphrases with strong randomness
|
|
7
|
+
- Cryptographically secure randomness (via `crypto.getRandomValues`)
|
|
8
|
+
- Works in React, Next.js, Vite, and Node 18+
|
|
9
|
+
- Fully typed TypeScript API
|
|
10
|
+
- Configurable casing, symbols, numbers, and word patterns
|
|
11
|
+
- Custom dictionary support
|
|
6
12
|
|
|
7
|
-
##
|
|
13
|
+
## Install
|
|
14
|
+
```bash
|
|
15
|
+
npm install smart-passphrase
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
```ts
|
|
20
|
+
import { generatePassphrase } from "smart-passphrase";
|
|
8
21
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* TypeScript support
|
|
22
|
+
const passphrase = generatePassphrase();
|
|
23
|
+
console.log(passphrase);
|
|
24
|
+
```
|
|
13
25
|
|
|
14
|
-
|
|
26
|
+
## Example Output
|
|
27
|
+
```
|
|
28
|
+
SilentGOOSE^mark324
|
|
29
|
+
BrAveTiger#run891
|
|
30
|
+
quickROCKET=jump472
|
|
31
|
+
```
|
|
15
32
|
|
|
16
|
-
##
|
|
33
|
+
## Usage in React / Next.js / Vite
|
|
34
|
+
```tsx
|
|
35
|
+
import { generatePassphrase } from "smart-passphrase";
|
|
17
36
|
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
export default function App() {
|
|
38
|
+
return <h2>{generatePassphrase()}</h2>;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### `generatePassphrase(options?)`
|
|
45
|
+
Generate a secure, readable passphrase.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
generatePassphrase({
|
|
49
|
+
words: 3,
|
|
50
|
+
numbers: { digits: 3 },
|
|
51
|
+
symbols: true,
|
|
52
|
+
uppercaseStyle: "random",
|
|
53
|
+
separator: ""
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `generatePassword(options?)`
|
|
58
|
+
Alias of `generatePassphrase`.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const password = generatePassword({ strength: "strong" });
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### `entropyEstimate(options?)`
|
|
65
|
+
Estimate entropy in bits based on your options.
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const bits = entropyEstimate({ words: 4, symbols: true, numbers: true });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Options
|
|
72
|
+
|
|
73
|
+
### `words`
|
|
74
|
+
Number of word tokens in the passphrase.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
generatePassphrase({ words: 4 });
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `numbers`
|
|
81
|
+
- `true` (default) to add digits
|
|
82
|
+
- `{ digits: number }` to control length
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
generatePassphrase({ numbers: { digits: 4 } });
|
|
20
86
|
```
|
|
21
87
|
|
|
22
|
-
|
|
88
|
+
### `symbols`
|
|
89
|
+
- `true` (default) to include symbols
|
|
90
|
+
- `string[]` to provide your own symbol list
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
generatePassphrase({ symbols: ["$", "-", "_"] });
|
|
94
|
+
```
|
|
23
95
|
|
|
24
|
-
|
|
96
|
+
### `uppercaseStyle`
|
|
97
|
+
Controls casing:
|
|
25
98
|
|
|
26
99
|
```ts
|
|
27
|
-
|
|
100
|
+
"none" | "random" | "title" | "upper" | "lower"
|
|
101
|
+
```
|
|
28
102
|
|
|
29
|
-
|
|
30
|
-
|
|
103
|
+
Example:
|
|
104
|
+
```ts
|
|
105
|
+
generatePassphrase({ uppercaseStyle: "title" });
|
|
31
106
|
```
|
|
32
107
|
|
|
33
|
-
|
|
108
|
+
### `separator`
|
|
109
|
+
String inserted between all parts.
|
|
34
110
|
|
|
35
|
-
|
|
111
|
+
```ts
|
|
112
|
+
generatePassphrase({ separator: "-" });
|
|
113
|
+
```
|
|
36
114
|
|
|
115
|
+
### `unique`
|
|
116
|
+
Avoid repeating words within the same passphrase.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
generatePassphrase({ unique: true });
|
|
37
120
|
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
121
|
+
|
|
122
|
+
### `strength`
|
|
123
|
+
Preset security tiers:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
"medium" | "strong" | "ultra"
|
|
41
127
|
```
|
|
42
128
|
|
|
43
|
-
|
|
129
|
+
Each tier increases words, digits, and entropy.
|
|
44
130
|
|
|
45
|
-
|
|
131
|
+
```ts
|
|
132
|
+
generatePassphrase({ strength: "ultra" });
|
|
133
|
+
```
|
|
46
134
|
|
|
135
|
+
### `pattern`
|
|
136
|
+
Custom order of word types.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
generatePassphrase({ pattern: ["adj", "noun", "verb"] });
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Available word kinds:
|
|
143
|
+
```ts
|
|
144
|
+
"adj" | "noun" | "verb"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### `dictionary`
|
|
148
|
+
Override the default word lists.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
generatePassphrase({
|
|
152
|
+
dictionary: {
|
|
153
|
+
adjectives: ["silent", "rapid"],
|
|
154
|
+
nouns: ["fox", "river"],
|
|
155
|
+
verbs: ["glide", "spark"]
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Security Notes
|
|
161
|
+
- Uses `crypto.getRandomValues` for strong randomness.
|
|
162
|
+
- Requires Node 18+ or a modern browser runtime.
|
|
163
|
+
- For even higher entropy, increase `words`, `digits`, or use `strength: "ultra"`.
|
|
164
|
+
|
|
165
|
+
## License
|
|
47
166
|
MIT
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
If you want, I can also add:
|
|
170
|
+
1. A `COPY` helper utility example
|
|
171
|
+
2. A CLI usage snippet
|
|
172
|
+
3. A comparison table for `strength` presets
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "smart-passphrase",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Memorable, secure passphrase generator for web and Node.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": "Ayush Solanki <ayushsolanki2901@gmail.com> (https://github.com/ayushsolanki29)",
|
|
7
|
-
"type": "module",
|
|
8
|
-
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/ayushsolanki29/smart-passphrase"
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
"keywords": [
|
|
15
|
-
"password",
|
|
16
|
-
"passphrase",
|
|
17
|
-
"generator",
|
|
18
|
-
"security",
|
|
19
|
-
"typescript"
|
|
20
|
-
],
|
|
21
|
-
|
|
22
|
-
"exports": {
|
|
23
|
-
".": {
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"import": "./dist/esm/index.js",
|
|
26
|
-
"require": "./dist/cjs/index.cjs"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
"main": "./dist/cjs/index.cjs",
|
|
31
|
-
"module": "./dist/esm/index.js",
|
|
32
|
-
"types": "./dist/index.d.ts",
|
|
33
|
-
|
|
34
|
-
"files": ["dist"],
|
|
35
|
-
"sideEffects": false,
|
|
36
|
-
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
39
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
40
|
-
"build": "npm run build:esm && npm run build:cjs"
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"typescript": "^5.5.4"
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "smart-passphrase",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Memorable, secure passphrase generator for web and Node.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Ayush Solanki <ayushsolanki2901@gmail.com> (https://github.com/ayushsolanki29)",
|
|
7
|
+
"type": "module",
|
|
8
|
+
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/ayushsolanki29/smart-passphrase"
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
"keywords": [
|
|
15
|
+
"password",
|
|
16
|
+
"passphrase",
|
|
17
|
+
"generator",
|
|
18
|
+
"security",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/esm/index.js",
|
|
26
|
+
"require": "./dist/cjs/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
"main": "./dist/cjs/index.cjs",
|
|
31
|
+
"module": "./dist/esm/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
|
|
34
|
+
"files": ["dist"],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
39
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
40
|
+
"build": "npm run build:esm && npm run build:cjs"
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.5.4"
|
|
45
|
+
}
|
|
46
46
|
}
|