smart-passphrase 1.0.1 → 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.
Files changed (2) hide show
  1. package/README.md +148 -23
  2. package/package.json +1 -1
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 the browser.
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
- ## Features
13
+ ## Install
14
+ ```bash
15
+ npm install smart-passphrase
16
+ ```
8
17
 
9
- * Human-readable passwords
10
- * Cryptographically secure randomness
11
- * Works with React, Next.js, Vite, Node
12
- * TypeScript support
18
+ ## Quick Start
19
+ ```ts
20
+ import { generatePassphrase } from "smart-passphrase";
13
21
 
14
- ---
22
+ const passphrase = generatePassphrase();
23
+ console.log(passphrase);
24
+ ```
15
25
 
16
- ## Install
26
+ ## Example Output
27
+ ```
28
+ SilentGOOSE^mark324
29
+ BrAveTiger#run891
30
+ quickROCKET=jump472
31
+ ```
17
32
 
18
- ```bash
19
- npm install smart-passphrase
33
+ ## Usage in React / Next.js / Vite
34
+ ```tsx
35
+ import { generatePassphrase } from "smart-passphrase";
36
+
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 } });
86
+ ```
87
+
88
+ ### `symbols`
89
+ - `true` (default) to include symbols
90
+ - `string[]` to provide your own symbol list
91
+
92
+ ```ts
93
+ generatePassphrase({ symbols: ["$", "-", "_"] });
20
94
  ```
21
95
 
22
- ---
96
+ ### `uppercaseStyle`
97
+ Controls casing:
98
+
99
+ ```ts
100
+ "none" | "random" | "title" | "upper" | "lower"
101
+ ```
102
+
103
+ Example:
104
+ ```ts
105
+ generatePassphrase({ uppercaseStyle: "title" });
106
+ ```
107
+
108
+ ### `separator`
109
+ String inserted between all parts.
110
+
111
+ ```ts
112
+ generatePassphrase({ separator: "-" });
113
+ ```
23
114
 
24
- ## Usage
115
+ ### `unique`
116
+ Avoid repeating words within the same passphrase.
25
117
 
26
118
  ```ts
27
- import { generatePassword } from "smart-passphrase";
119
+ generatePassphrase({ unique: true });
120
+ ```
28
121
 
29
- const password = generatePassword();
30
- console.log(password);
122
+ ### `strength`
123
+ Preset security tiers:
124
+
125
+ ```ts
126
+ "medium" | "strong" | "ultra"
31
127
  ```
32
128
 
33
- ---
129
+ Each tier increases words, digits, and entropy.
34
130
 
35
- ## Example Output
131
+ ```ts
132
+ generatePassphrase({ strength: "ultra" });
133
+ ```
36
134
 
135
+ ### `pattern`
136
+ Custom order of word types.
137
+
138
+ ```ts
139
+ generatePassphrase({ pattern: ["adj", "noun", "verb"] });
37
140
  ```
38
- theSOON^goose324
39
- Ishow#mark=down
40
- 34Roto)mAsk
141
+
142
+ Available word kinds:
143
+ ```ts
144
+ "adj" | "noun" | "verb"
41
145
  ```
42
146
 
43
- ---
147
+ ### `dictionary`
148
+ Override the default word lists.
44
149
 
45
- ## 📄 License
150
+ ```ts
151
+ generatePassphrase({
152
+ dictionary: {
153
+ adjectives: ["silent", "rapid"],
154
+ nouns: ["fox", "river"],
155
+ verbs: ["glide", "spark"]
156
+ }
157
+ });
158
+ ```
46
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,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-passphrase",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Memorable, secure passphrase generator for web and Node.",
5
5
  "license": "MIT",
6
6
  "author": "Ayush Solanki <ayushsolanki2901@gmail.com> (https://github.com/ayushsolanki29)",