xypriss-security 2.0.9 → 2.1.1
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 +10 -8
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/index.js +1 -1
- package/dist/src/core/PasswordManager.d.ts +205 -0
- package/dist/src/core/PasswordManager.d.ts.map +1 -0
- package/dist/src/core/PasswordManager.js +478 -0
- package/dist/src/core/PasswordManager.js.map +1 -0
- package/dist/src/core/SecureBuffer.d.ts +1 -1
- package/dist/src/core/SecureBuffer.js +1 -1
- package/dist/src/core/index.d.ts +3 -2
- package/dist/src/core/index.d.ts.map +1 -1
- package/dist/src/core/index.js +4 -3
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/mods/PasswordMDict.d.ts +141 -0
- package/dist/src/mods/PasswordMDict.d.ts.map +1 -0
- package/dist/src/mods/PasswordMDict.js +464 -0
- package/dist/src/mods/PasswordMDict.js.map +1 -0
- package/dist/src/mods/eff_large_wordlist.txt +7776 -0
- package/dist/src/mods/eff_short_wordlist_2_0.txt +1296 -0
- package/dist/src/types/PasswordManagerOptions.d.ts +142 -0
- package/dist/src/types/PasswordManagerOptions.d.ts.map +1 -0
- package/dist/src/types/PasswordManagerOptions.js +4 -0
- package/dist/src/types/PasswordManagerOptions.js.map +1 -0
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/utils/CryptoAlgorithmUtils.d.ts +1 -1
- package/dist/src/utils/CryptoAlgorithmUtils.js +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/***************************************************************************
|
|
3
|
+
* XyPriss Security - Advanced Hyper-Modular Security Framework
|
|
4
|
+
*
|
|
5
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
6
|
+
* @license Nehonix Open Source License (NOSL)
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2025 NEHONIX. All rights reserved.
|
|
9
|
+
****************************************************************************/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.PasswordManager = void 0;
|
|
12
|
+
const crypto_1 = require("crypto");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const Password_1 = require("./Password");
|
|
15
|
+
const Random_1 = require("./Random");
|
|
16
|
+
const PasswordMDict_1 = require("../mods/PasswordMDict");
|
|
17
|
+
// ─── PasswordManager ──────────────────────────────────────────────────────────
|
|
18
|
+
/***************************************************************************
|
|
19
|
+
* ### PasswordManager
|
|
20
|
+
*
|
|
21
|
+
* A configurable, instance-based password manager.
|
|
22
|
+
* Unlike the static `Password` class, `PasswordManager` is instantiated
|
|
23
|
+
* once with all options pre-configured, so callers only need to pass
|
|
24
|
+
* the raw password string at call time.
|
|
25
|
+
*
|
|
26
|
+
* This is the recommended pattern for large-scale projects:
|
|
27
|
+
* configure once in a dedicated file, export the instance, and reuse
|
|
28
|
+
* everywhere without repeating options.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // config/security.ts
|
|
32
|
+
* export const passwords = new PasswordManager({
|
|
33
|
+
* algorithm: "argon2id",
|
|
34
|
+
* memoryCost: 65536,
|
|
35
|
+
* parallelism: 4,
|
|
36
|
+
* iterations: 3,
|
|
37
|
+
* pepper: process.env.PASSWORD_PEPPER,
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // anywhere in the app:
|
|
41
|
+
* const hash = await passwords.hash("user-raw-password");
|
|
42
|
+
* const valid = await passwords.verify("user-raw-password", hash);
|
|
43
|
+
* const temp = passwords.generate({ length: 24, symbols: true });
|
|
44
|
+
* const passphrase = passwords.generatePassphrase({ wordCount: 5 });
|
|
45
|
+
* const pin = passwords.generatePin(6);
|
|
46
|
+
* const info = passwords.strength("MyP@ss1!");
|
|
47
|
+
* const breach = await passwords.isBreached("hunter2");
|
|
48
|
+
* const stale = passwords.needsRehash(storedHash);
|
|
49
|
+
*/
|
|
50
|
+
class PasswordManager {
|
|
51
|
+
constructor(options = {}) {
|
|
52
|
+
this.algo = (options.algorithm ?? "argon2id").toLowerCase();
|
|
53
|
+
this.memoryCost = options.memoryCost ?? 65536; // 64 MiB
|
|
54
|
+
this.iterations = options.iterations ?? 3;
|
|
55
|
+
this.parallelism = options.parallelism ?? 4;
|
|
56
|
+
this.pepper = options.pepper;
|
|
57
|
+
}
|
|
58
|
+
// ─── Hashing ───────────────────────────────────────────────────────────────
|
|
59
|
+
/**
|
|
60
|
+
* Hashes a password using the instance's pre-configured options.
|
|
61
|
+
*
|
|
62
|
+
* @param password - The plain-text password to hash.
|
|
63
|
+
* @param overrides - Optional per-call overrides for any constructor option.
|
|
64
|
+
* @returns The encoded hash string, ready to be stored.
|
|
65
|
+
*/
|
|
66
|
+
async hash(password, overrides = {}) {
|
|
67
|
+
const pepper = overrides.pepper ?? this.pepper;
|
|
68
|
+
const finalPassword = pepper ? password + pepper : password;
|
|
69
|
+
return Password_1.Password.hash(finalPassword, {
|
|
70
|
+
algorithm: overrides.algorithm ?? this.algo,
|
|
71
|
+
memoryCost: overrides.memoryCost ?? this.memoryCost,
|
|
72
|
+
iterations: overrides.iterations ?? this.iterations,
|
|
73
|
+
parallelism: overrides.parallelism ?? this.parallelism,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Verifies a plain-text password against a stored hash.
|
|
78
|
+
*
|
|
79
|
+
* @param password - The password to verify.
|
|
80
|
+
* @param hash - The stored hash to compare against.
|
|
81
|
+
* @param overrides - Optional per-call override for the pepper.
|
|
82
|
+
* @returns `true` if the password matches the hash, `false` otherwise.
|
|
83
|
+
*/
|
|
84
|
+
async verify(password, hash, overrides = {}) {
|
|
85
|
+
const pepper = overrides.pepper ?? this.pepper;
|
|
86
|
+
const finalPassword = pepper ? password + pepper : password;
|
|
87
|
+
return Password_1.Password.verify(finalPassword, hash);
|
|
88
|
+
}
|
|
89
|
+
// ─── Generation ────────────────────────────────────────────────────────────
|
|
90
|
+
/**
|
|
91
|
+
* Generates a cryptographically secure random password matching the given
|
|
92
|
+
* criteria, with **guaranteed character-type coverage**.
|
|
93
|
+
*
|
|
94
|
+
* Security properties:
|
|
95
|
+
* - Every enabled character type appears **at least once** in the output.
|
|
96
|
+
* - `extra` characters are **injected at cryptographically random positions**
|
|
97
|
+
* rather than appended, ensuring they don't cluster at the end.
|
|
98
|
+
* - The final array is **Fisher-Yates shuffled** via `Random.Int` to remove
|
|
99
|
+
* any positional bias introduced during construction.
|
|
100
|
+
* - `length` is clamped to [8, 512] to prevent misuse.
|
|
101
|
+
* - Throws `RangeError` if no character type is enabled (empty charset).
|
|
102
|
+
*
|
|
103
|
+
* @param options - Character set and length configuration.
|
|
104
|
+
* @returns A plain-text randomly generated password string.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const pwd = passwords.generate({ length: 24, symbols: true });
|
|
108
|
+
*/
|
|
109
|
+
generate(options = {}) {
|
|
110
|
+
const { uppercase = true, lowercase = true, numbers = true, symbols = true, excludeSimilar = false, extra = "", } = options;
|
|
111
|
+
// ── 1. Clamp & validate length ──────────────────────────────────────────
|
|
112
|
+
const length = Math.min(PasswordMDict_1.MAX_GENERATE_LENGTH, Math.max(PasswordMDict_1.MIN_GENERATE_LENGTH, Math.floor(options.length ?? 20)));
|
|
113
|
+
// ── 2. Build charset ────────────────────────────────────────────────────
|
|
114
|
+
let charset = "";
|
|
115
|
+
const mandatory = []; // at least one char from each active set
|
|
116
|
+
const addSet = (chars, enabled) => {
|
|
117
|
+
if (!enabled)
|
|
118
|
+
return;
|
|
119
|
+
const cleaned = excludeSimilar
|
|
120
|
+
? chars.replace(PasswordMDict_1.CHARSETS.similarChars, "")
|
|
121
|
+
: chars;
|
|
122
|
+
if (cleaned.length === 0)
|
|
123
|
+
return;
|
|
124
|
+
charset += cleaned;
|
|
125
|
+
// Reserve one guaranteed character from this set
|
|
126
|
+
mandatory.push(cleaned[Random_1.Random.Int(0, cleaned.length)]);
|
|
127
|
+
};
|
|
128
|
+
addSet(PasswordMDict_1.CHARSETS.lowercase, lowercase);
|
|
129
|
+
addSet(PasswordMDict_1.CHARSETS.uppercase, uppercase);
|
|
130
|
+
addSet(PasswordMDict_1.CHARSETS.numbers, numbers);
|
|
131
|
+
addSet(PasswordMDict_1.CHARSETS.symbols, symbols);
|
|
132
|
+
if (charset.length === 0) {
|
|
133
|
+
throw new RangeError("PasswordManager.generate: no character types enabled — charset is empty.");
|
|
134
|
+
}
|
|
135
|
+
// Guarantee at least one char per extra string (injected, not appended)
|
|
136
|
+
if (extra) {
|
|
137
|
+
for (const ch of extra) {
|
|
138
|
+
if (!charset.includes(ch))
|
|
139
|
+
charset += ch;
|
|
140
|
+
mandatory.push(ch);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// ── 3. Guard: mandatory set cannot exceed requested length ───────────────
|
|
144
|
+
if (mandatory.length > length) {
|
|
145
|
+
throw new RangeError(`PasswordManager.generate: requested length (${length}) is too short ` +
|
|
146
|
+
`to satisfy all enabled character types (need at least ${mandatory.length}).`);
|
|
147
|
+
}
|
|
148
|
+
// ── 4. Fill remaining slots from full charset ────────────────────────────
|
|
149
|
+
const arr = [...mandatory];
|
|
150
|
+
const remaining = length - arr.length;
|
|
151
|
+
for (let i = 0; i < remaining; i++) {
|
|
152
|
+
arr.push(charset[Random_1.Random.Int(0, charset.length)]);
|
|
153
|
+
}
|
|
154
|
+
// ── 5. Fisher-Yates shuffle (crypto-safe via Random.Int) ─────────────────
|
|
155
|
+
for (let i = arr.length - 1; i > 0; i--) {
|
|
156
|
+
const j = Random_1.Random.Int(0, i + 1);
|
|
157
|
+
[arr[i], arr[j]] = [arr[j], arr[i]];
|
|
158
|
+
}
|
|
159
|
+
return arr.join("");
|
|
160
|
+
}
|
|
161
|
+
// ─── Passphrase Generation ─────────────────────────────────────────────────
|
|
162
|
+
/**
|
|
163
|
+
* Generates a **memorable, high-entropy passphrase** using a curated
|
|
164
|
+
* 256-word list (similar to Diceware / EFF methodology).
|
|
165
|
+
*
|
|
166
|
+
* Entropy: `log2(256^wordCount)` = `8 * wordCount` bits minimum.
|
|
167
|
+
* With 5 words: ~40 bits base + number suffix ≈ 53 bits total.
|
|
168
|
+
* With 6 words: ~48 bits base + number suffix ≈ 61 bits total.
|
|
169
|
+
*
|
|
170
|
+
* Security note: word selection uses `Random.Int` which must be backed
|
|
171
|
+
* by a CSPRNG (e.g. `crypto.randomInt`).
|
|
172
|
+
*
|
|
173
|
+
* @param options - Passphrase configuration.
|
|
174
|
+
* @returns A plain-text passphrase string.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* passwords.generatePassphrase({ wordCount: 5, separator: "-" });
|
|
178
|
+
* // → "Bold-Cave-Iron-Jump-Warm-4827"
|
|
179
|
+
*/
|
|
180
|
+
generatePassphrase(options = {}) {
|
|
181
|
+
const { wordCount = 5, separator = "-", capitalize = true, appendNumbers = true, variant = "large", dir, filePath, allowFallback = "silent", } = options;
|
|
182
|
+
if (wordCount < 3 || wordCount > 20) {
|
|
183
|
+
throw new RangeError("PasswordManager.generatePassphrase: wordCount must be between 3 and 20.");
|
|
184
|
+
}
|
|
185
|
+
// Resolve the bundled mods dir relative to this compiled file
|
|
186
|
+
// dist/src/core/PasswordManager.js → ../../mods (production)
|
|
187
|
+
// src/core/PasswordManager.ts → ../mods (dev/bun direct)
|
|
188
|
+
const modsDir = dir ??
|
|
189
|
+
(0, path_1.join)(__dirname, "..", "mods") +
|
|
190
|
+
// ts-source fallback: if __dirname ends with /core, ../mods resolves correctly
|
|
191
|
+
"";
|
|
192
|
+
const wordlist = (0, PasswordMDict_1.getWordlist)({
|
|
193
|
+
dir: modsDir,
|
|
194
|
+
variant,
|
|
195
|
+
filePath,
|
|
196
|
+
allowFallback,
|
|
197
|
+
});
|
|
198
|
+
const words = [];
|
|
199
|
+
for (let i = 0; i < wordCount; i++) {
|
|
200
|
+
let word = wordlist[Random_1.Random.Int(0, wordlist.length)];
|
|
201
|
+
if (capitalize) {
|
|
202
|
+
word = word.charAt(0).toUpperCase() + word.slice(1);
|
|
203
|
+
}
|
|
204
|
+
words.push(word);
|
|
205
|
+
}
|
|
206
|
+
if (appendNumbers) {
|
|
207
|
+
// 4-digit suffix adds ~13 extra bits of entropy
|
|
208
|
+
const suffix = String(Random_1.Random.Int(1000, 9999));
|
|
209
|
+
words.push(suffix);
|
|
210
|
+
}
|
|
211
|
+
return words.join(separator);
|
|
212
|
+
}
|
|
213
|
+
// ─── PIN Generation ────────────────────────────────────────────────────────
|
|
214
|
+
/**
|
|
215
|
+
* Generates a cryptographically secure numeric PIN.
|
|
216
|
+
*
|
|
217
|
+
* Each digit is drawn independently from the full [0-9] range.
|
|
218
|
+
* The PIN is **zero-padded** to the requested length and returned as a
|
|
219
|
+
* string to preserve leading zeros (e.g. "0472").
|
|
220
|
+
*
|
|
221
|
+
* @param length - Number of digits. Must be between 4 and 32. @default 6
|
|
222
|
+
* @returns A plain-text numeric PIN string.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* passwords.generatePin(6); // → "047291"
|
|
226
|
+
*/
|
|
227
|
+
generatePin(length = 6) {
|
|
228
|
+
if (!Number.isInteger(length) || length < 4 || length > 32) {
|
|
229
|
+
throw new RangeError("PasswordManager.generatePin: length must be an integer between 4 and 32.");
|
|
230
|
+
}
|
|
231
|
+
const digits = [];
|
|
232
|
+
for (let i = 0; i < length; i++) {
|
|
233
|
+
digits.push(String(Random_1.Random.Int(0, 10)));
|
|
234
|
+
}
|
|
235
|
+
return digits.join("");
|
|
236
|
+
}
|
|
237
|
+
// ─── Strength Analysis ─────────────────────────────────────────────────────
|
|
238
|
+
/**
|
|
239
|
+
* Evaluates the strength of a password and returns a detailed report.
|
|
240
|
+
*
|
|
241
|
+
* The score is computed from multiple orthogonal criteria:
|
|
242
|
+
* - Length (up to 30 points)
|
|
243
|
+
* - Character variety (up to 50 points)
|
|
244
|
+
* - Absence of repetitions and sequences (up to 20 points deducted)
|
|
245
|
+
*
|
|
246
|
+
* @param password - The password to evaluate.
|
|
247
|
+
* @returns A `PasswordStrengthResult` with score, label, and actionable suggestions.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* const info = passwords.strength("MyP@ssw0rd!");
|
|
251
|
+
* console.log(info.score, info.label); // 82 "strong"
|
|
252
|
+
*/
|
|
253
|
+
strength(password) {
|
|
254
|
+
const suggestions = [];
|
|
255
|
+
// ── Characteristic flags ────────────────────────────────────────────────
|
|
256
|
+
const hasUppercase = /[A-Z]/.test(password);
|
|
257
|
+
const hasLowercase = /[a-z]/.test(password);
|
|
258
|
+
const hasNumbers = /[0-9]/.test(password);
|
|
259
|
+
const hasSymbols = /[^A-Za-z0-9]/.test(password);
|
|
260
|
+
const hasRepeats = /(.)\1{2,}/.test(password);
|
|
261
|
+
const hasSequences = /(abc|bcd|cde|def|efg|fgh|ghi|hij|ijk|jkl|klm|lmn|mno|nop|opq|pqr|qrs|rst|stu|tuv|uvw|vwx|wxy|xyz|012|123|234|345|456|567|678|789)/i.test(password);
|
|
262
|
+
// ── Length score (0-30) ─────────────────────────────────────────────────
|
|
263
|
+
const len = password.length;
|
|
264
|
+
let lengthScore = 0;
|
|
265
|
+
if (len >= 8)
|
|
266
|
+
lengthScore += 10;
|
|
267
|
+
if (len >= 12)
|
|
268
|
+
lengthScore += 10;
|
|
269
|
+
if (len >= 16)
|
|
270
|
+
lengthScore += 5;
|
|
271
|
+
if (len >= 20)
|
|
272
|
+
lengthScore += 5;
|
|
273
|
+
// ── Variety score (0-50) ────────────────────────────────────────────────
|
|
274
|
+
let varietyScore = 0;
|
|
275
|
+
if (hasLowercase)
|
|
276
|
+
varietyScore += 10;
|
|
277
|
+
if (hasUppercase)
|
|
278
|
+
varietyScore += 10;
|
|
279
|
+
if (hasNumbers)
|
|
280
|
+
varietyScore += 10;
|
|
281
|
+
if (hasSymbols)
|
|
282
|
+
varietyScore += 15;
|
|
283
|
+
if (hasLowercase && hasUppercase && hasNumbers && hasSymbols)
|
|
284
|
+
varietyScore += 5;
|
|
285
|
+
// ── Penalty score (0..20 subtracted) ───────────────────────────────────
|
|
286
|
+
let penaltyScore = 0;
|
|
287
|
+
if (hasRepeats)
|
|
288
|
+
penaltyScore += 10;
|
|
289
|
+
if (hasSequences)
|
|
290
|
+
penaltyScore += 10;
|
|
291
|
+
// ── Entropy estimation (bits) ───────────────────────────────────────────
|
|
292
|
+
let charsetSize = 0;
|
|
293
|
+
if (hasLowercase)
|
|
294
|
+
charsetSize += 26;
|
|
295
|
+
if (hasUppercase)
|
|
296
|
+
charsetSize += 26;
|
|
297
|
+
if (hasNumbers)
|
|
298
|
+
charsetSize += 10;
|
|
299
|
+
if (hasSymbols)
|
|
300
|
+
charsetSize += 32;
|
|
301
|
+
const entropy = charsetSize > 0 ? Math.round(len * Math.log2(charsetSize)) : 0;
|
|
302
|
+
const score = Math.max(0, Math.min(100, lengthScore + varietyScore - penaltyScore));
|
|
303
|
+
// ── Suggestions ────────────────────────────────────────────────────────
|
|
304
|
+
if (len < 8)
|
|
305
|
+
suggestions.push("Use at least 8 characters.");
|
|
306
|
+
if (len < 12)
|
|
307
|
+
suggestions.push("A length of 12 or more is recommended.");
|
|
308
|
+
if (len < 16)
|
|
309
|
+
suggestions.push("Aim for 16+ characters for high-security contexts.");
|
|
310
|
+
if (!hasUppercase)
|
|
311
|
+
suggestions.push("Add uppercase letters (A-Z).");
|
|
312
|
+
if (!hasLowercase)
|
|
313
|
+
suggestions.push("Add lowercase letters (a-z).");
|
|
314
|
+
if (!hasNumbers)
|
|
315
|
+
suggestions.push("Include at least one digit (0-9).");
|
|
316
|
+
if (!hasSymbols)
|
|
317
|
+
suggestions.push("Include at least one special character (!@#$%...).");
|
|
318
|
+
if (hasRepeats)
|
|
319
|
+
suggestions.push("Avoid repeating characters (e.g. 'aaa').");
|
|
320
|
+
if (hasSequences)
|
|
321
|
+
suggestions.push("Avoid common sequences (e.g. '123', 'abc').");
|
|
322
|
+
// ── Label ──────────────────────────────────────────────────────────────
|
|
323
|
+
let label;
|
|
324
|
+
if (score < 20)
|
|
325
|
+
label = "very-weak";
|
|
326
|
+
else if (score < 40)
|
|
327
|
+
label = "weak";
|
|
328
|
+
else if (score < 60)
|
|
329
|
+
label = "fair";
|
|
330
|
+
else if (score < 80)
|
|
331
|
+
label = "strong";
|
|
332
|
+
else
|
|
333
|
+
label = "very-strong";
|
|
334
|
+
return {
|
|
335
|
+
score,
|
|
336
|
+
label,
|
|
337
|
+
suggestions,
|
|
338
|
+
analysis: {
|
|
339
|
+
length: len,
|
|
340
|
+
hasUppercase,
|
|
341
|
+
hasLowercase,
|
|
342
|
+
hasNumbers,
|
|
343
|
+
hasSymbols,
|
|
344
|
+
hasRepeats,
|
|
345
|
+
hasSequences,
|
|
346
|
+
entropy,
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
// ─── Breach Check ──────────────────────────────────────────────────────────
|
|
351
|
+
/**
|
|
352
|
+
* Checks whether a password has appeared in a publicly known data breach
|
|
353
|
+
* using the **HaveIBeenPwned Pwned Passwords API v3** with **k-anonymity**.
|
|
354
|
+
*
|
|
355
|
+
* The full password is **never transmitted**. Only the first 5 characters of
|
|
356
|
+
* its SHA-1 hex digest are sent over the network; the remainder of the
|
|
357
|
+
* matching is performed locally.
|
|
358
|
+
*
|
|
359
|
+
* @param password - The plain-text password to check.
|
|
360
|
+
* @returns A `BreachCheckResult` indicating breach status and occurrence count.
|
|
361
|
+
* @throws If the network request fails or returns an unexpected status code.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* const result = await passwords.isBreached("hunter2");
|
|
365
|
+
* if (result.breached) {
|
|
366
|
+
* console.warn(`Password found ${result.occurrences} times in breach databases.`);
|
|
367
|
+
* }
|
|
368
|
+
*/
|
|
369
|
+
async isBreached(password) {
|
|
370
|
+
const sha1 = (0, crypto_1.createHash)("sha1")
|
|
371
|
+
.update(password)
|
|
372
|
+
.digest("hex")
|
|
373
|
+
.toUpperCase();
|
|
374
|
+
const prefix = sha1.slice(0, 5);
|
|
375
|
+
const suffix = sha1.slice(5);
|
|
376
|
+
const response = await fetch(`https://api.pwnedpasswords.com/range/${prefix}`, {
|
|
377
|
+
headers: {
|
|
378
|
+
// Padding header reduces response-size side-channel leakage
|
|
379
|
+
"Add-Padding": "true",
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
if (!response.ok) {
|
|
383
|
+
throw new Error(`PasswordManager.isBreached: HIBP API returned HTTP ${response.status}.`);
|
|
384
|
+
}
|
|
385
|
+
const body = await response.text();
|
|
386
|
+
// Each line: "<SUFFIX>:<COUNT>" or "<SUFFIX>:0" (padding entries)
|
|
387
|
+
for (const line of body.split("\r\n")) {
|
|
388
|
+
const [hashSuffix, countStr] = line.split(":");
|
|
389
|
+
if (hashSuffix === suffix) {
|
|
390
|
+
const occurrences = parseInt(countStr, 10);
|
|
391
|
+
return { breached: occurrences > 0, occurrences };
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return { breached: false, occurrences: 0 };
|
|
395
|
+
}
|
|
396
|
+
// ─── Rehash Detection ──────────────────────────────────────────────────────
|
|
397
|
+
/**
|
|
398
|
+
* Determines whether a stored hash was produced with weaker parameters than
|
|
399
|
+
* the instance's current configuration (e.g. after a security upgrade).
|
|
400
|
+
*
|
|
401
|
+
* Supports Argon2id hash strings in the PHC string format:
|
|
402
|
+
* `$argon2id$v=19$m=<mem>,t=<iter>,p=<par>$<salt>$<hash>`
|
|
403
|
+
*
|
|
404
|
+
* For other algorithms, returns `false` (no opinion) so the caller can
|
|
405
|
+
* decide on a case-by-case basis.
|
|
406
|
+
*
|
|
407
|
+
* @param hash - The stored hash string to inspect.
|
|
408
|
+
* @returns `true` if the hash should be re-hashed on next successful login.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* if (passwords.needsRehash(user.passwordHash)) {
|
|
412
|
+
* user.passwordHash = await passwords.hash(rawPassword);
|
|
413
|
+
* await user.save();
|
|
414
|
+
* }
|
|
415
|
+
*/
|
|
416
|
+
needsRehash(hash) {
|
|
417
|
+
if (!hash.startsWith("$argon2id$"))
|
|
418
|
+
return false;
|
|
419
|
+
// Parse PHC format: $argon2id$v=19$m=65536,t=3,p=4$...
|
|
420
|
+
const paramsMatch = hash.match(/\$m=(\d+),t=(\d+),p=(\d+)\$/);
|
|
421
|
+
if (!paramsMatch)
|
|
422
|
+
return true; // malformed → force rehash
|
|
423
|
+
const [, m, t, p] = paramsMatch.map(Number);
|
|
424
|
+
return m < this.memoryCost || t < this.iterations || p < this.parallelism;
|
|
425
|
+
}
|
|
426
|
+
// ─── Input Sanitization ────────────────────────────────────────────────────
|
|
427
|
+
/**
|
|
428
|
+
* Validates and normalizes a raw password string before hashing.
|
|
429
|
+
*
|
|
430
|
+
* Checks performed:
|
|
431
|
+
* - Not empty or whitespace-only.
|
|
432
|
+
* - Minimum length of 8 characters.
|
|
433
|
+
* - Maximum length of 1024 characters (DoS guard against bcrypt-style
|
|
434
|
+
* long-password attacks on other algorithms).
|
|
435
|
+
* - Unicode NFC normalization (prevents homoglyph bypass attacks).
|
|
436
|
+
*
|
|
437
|
+
* @param password - The raw password string from user input.
|
|
438
|
+
* @returns The NFC-normalized password, ready for hashing.
|
|
439
|
+
* @throws `TypeError` if the input is not a string.
|
|
440
|
+
* @throws `RangeError` if the password fails length validation.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* const normalized = passwords.sanitizeInput(req.body.password);
|
|
444
|
+
* const hash = await passwords.hash(normalized);
|
|
445
|
+
*/
|
|
446
|
+
sanitizeInput(password) {
|
|
447
|
+
if (typeof password !== "string") {
|
|
448
|
+
throw new TypeError("PasswordManager.sanitizeInput: password must be a string.");
|
|
449
|
+
}
|
|
450
|
+
const trimmed = password.trim();
|
|
451
|
+
if (trimmed.length === 0) {
|
|
452
|
+
throw new RangeError("PasswordManager.sanitizeInput: password must not be empty.");
|
|
453
|
+
}
|
|
454
|
+
if (trimmed.length < 8) {
|
|
455
|
+
throw new RangeError("PasswordManager.sanitizeInput: password must be at least 8 characters long.");
|
|
456
|
+
}
|
|
457
|
+
if (trimmed.length > 1024) {
|
|
458
|
+
throw new RangeError("PasswordManager.sanitizeInput: password exceeds the maximum allowed length (1024).");
|
|
459
|
+
}
|
|
460
|
+
// NFC normalization: prevents ā (U+0101) vs a + combining macron attacks
|
|
461
|
+
return trimmed.normalize("NFC");
|
|
462
|
+
}
|
|
463
|
+
// ─── Utilities ─────────────────────────────────────────────────────────────
|
|
464
|
+
/**
|
|
465
|
+
* Returns a summary of the instance's current configuration.
|
|
466
|
+
* The `pepper` is intentionally omitted from the output.
|
|
467
|
+
*/
|
|
468
|
+
getConfig() {
|
|
469
|
+
return {
|
|
470
|
+
algorithm: this.algo,
|
|
471
|
+
memoryCost: this.memoryCost,
|
|
472
|
+
iterations: this.iterations,
|
|
473
|
+
parallelism: this.parallelism,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
exports.PasswordManager = PasswordManager;
|
|
478
|
+
//# sourceMappingURL=PasswordManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordManager.js","sourceRoot":"","sources":["../../../src/core/PasswordManager.ts"],"names":[],"mappings":";AAAA;;;;;;;8EAO8E;;;AAE9E,mCAAoC;AACpC,+BAA4B;AAC5B,yCAAsC;AACtC,qCAAkC;AAClC,yDAK+B;AAS/B,iFAAiF;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAa,eAAe;IAO1B,YAAY,UAAkC,EAAE;QAC9C,IAAI,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,UAAU,CA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,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,UAAU,CAClB,6EAA6E,CAC9E,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;YAC1B,MAAM,IAAI,UAAU,CAClB,oFAAoF,CACrF,CAAC;QACJ,CAAC;QAED,yEAAyE;QACzE,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,8EAA8E;IAE9E;;;OAGG;IACI,SAAS;QAMd,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,IAAI;YACpB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC;CACF;AA5gBD,0CA4gBC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* An enhanced Uint8Array that provides familiar encoding methods
|
|
5
5
|
* similar to Node.js Buffer, optimized for security operations.
|
|
6
6
|
*
|
|
7
|
-
* @author NEHONIX (
|
|
7
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
8
8
|
* @license Nehonix Open Source License (NOSL)
|
|
9
9
|
****************************************************************************/
|
|
10
10
|
import { __strl__ } from "strulink";
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* An enhanced Uint8Array that provides familiar encoding methods
|
|
6
6
|
* similar to Node.js Buffer, optimized for security operations.
|
|
7
7
|
*
|
|
8
|
-
* @author NEHONIX (
|
|
8
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
9
9
|
* @license Nehonix Open Source License (NOSL)
|
|
10
10
|
****************************************************************************/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
* Provides high-level security classes (Hash, Random, Password, XyPrissSecurity)
|
|
5
5
|
* that wrap the high-performance Go-based core bridge.
|
|
6
6
|
*
|
|
7
|
-
* @author NEHONIX (
|
|
7
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
8
8
|
* @license Nehonix Open Source License (NOSL)
|
|
9
9
|
****************************************************************************/
|
|
10
10
|
export * from "./Hash";
|
|
11
11
|
export * from "./Random";
|
|
12
12
|
export * from "./Password";
|
|
13
|
+
export * from "./PasswordManager";
|
|
13
14
|
export * from "./XyPrissSecurity";
|
|
14
15
|
export * from "./SecureBuffer";
|
|
15
16
|
export * from "./keys";
|
|
16
17
|
export * from "./bridge";
|
|
17
18
|
export { XyPrissSecurity as XSec } from "./XyPrissSecurity";
|
|
18
|
-
export {
|
|
19
|
+
export { PasswordManager as pm } from "./PasswordManager";
|
|
19
20
|
import { Hash } from "./Hash";
|
|
20
21
|
import { Random } from "./Random";
|
|
21
22
|
import { XyPrissSecurity } from "./XyPrissSecurity";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;8EAQ8E;AAE9E,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;8EAQ8E;AAE9E,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,eAAe,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;GAKG;AACH,qBAAa,MAAM;IACjB,oDAAoD;IACpD,gBAAuB,IAAI,cAAQ;IACnC,mEAAmE;IACnE,gBAAuB,MAAM,gBAAU;IACvC,+BAA+B;IAC/B,gBAAuB,MAAM,gBAAU;IACvC,6DAA6D;IAC7D,gBAAuB,IAAI,yBAAmB;CAC/C"}
|
package/dist/src/core/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Provides high-level security classes (Hash, Random, Password, XyPrissSecurity)
|
|
6
6
|
* that wrap the high-performance Go-based core bridge.
|
|
7
7
|
*
|
|
8
|
-
* @author NEHONIX (
|
|
8
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
9
9
|
* @license Nehonix Open Source License (NOSL)
|
|
10
10
|
****************************************************************************/
|
|
11
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -27,14 +27,15 @@ exports.Cipher = exports.pm = exports.XSec = void 0;
|
|
|
27
27
|
__exportStar(require("./Hash"), exports);
|
|
28
28
|
__exportStar(require("./Random"), exports);
|
|
29
29
|
__exportStar(require("./Password"), exports);
|
|
30
|
+
__exportStar(require("./PasswordManager"), exports);
|
|
30
31
|
__exportStar(require("./XyPrissSecurity"), exports);
|
|
31
32
|
__exportStar(require("./SecureBuffer"), exports);
|
|
32
33
|
__exportStar(require("./keys"), exports);
|
|
33
34
|
__exportStar(require("./bridge"), exports);
|
|
34
35
|
var XyPrissSecurity_1 = require("./XyPrissSecurity"); // Alias for XyPrissSecurity
|
|
35
36
|
Object.defineProperty(exports, "XSec", { enumerable: true, get: function () { return XyPrissSecurity_1.XyPrissSecurity; } });
|
|
36
|
-
var
|
|
37
|
-
Object.defineProperty(exports, "pm", { enumerable: true, get: function () { return
|
|
37
|
+
var PasswordManager_1 = require("./PasswordManager"); // Alias for PasswordManager
|
|
38
|
+
Object.defineProperty(exports, "pm", { enumerable: true, get: function () { return PasswordManager_1.PasswordManager; } });
|
|
38
39
|
const Hash_1 = require("./Hash");
|
|
39
40
|
const Random_1 = require("./Random");
|
|
40
41
|
const XyPrissSecurity_2 = require("./XyPrissSecurity");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;8EAQ8E;;;;;;;;;;;;;;;;;AAE9E,yCAAuB;AACvB,2CAAyB;AACzB,6CAA2B;AAC3B,oDAAkC;AAClC,iDAA+B;AAC/B,yCAAuB;AACvB,2CAAyB;AAEzB,qDAA4D,CAAC,4BAA4B;AAAhF,uGAAA,eAAe,OAAQ;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;8EAQ8E;;;;;;;;;;;;;;;;;AAE9E,yCAAuB;AACvB,2CAAyB;AACzB,6CAA2B;AAC3B,oDAAkC;AAClC,oDAAkC;AAClC,iDAA+B;AAC/B,yCAAuB;AACvB,2CAAyB;AAEzB,qDAA4D,CAAC,4BAA4B;AAAhF,uGAAA,eAAe,OAAQ;AAChC,qDAA0D,CAAC,4BAA4B;AAA9E,qGAAA,eAAe,OAAM;AAE9B,iCAA8B;AAC9B,qCAAkC;AAClC,uDAAoD;AAEpD;;;;;GAKG;AACH,MAAa,MAAM;;AAAnB,wBASC;AARC,oDAAoD;AAC7B,WAAI,GAAG,WAAI,CAAC;AACnC,mEAAmE;AAC5C,aAAM,GAAG,eAAM,CAAC;AACvC,+BAA+B;AACR,aAAM,GAAG,eAAM,CAAC;AACvC,6DAA6D;AACtC,WAAI,GAAG,iCAAe,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/***************************************************************************
|
|
2
2
|
* XyPriss Security - Advanced Hyper-Modular Security Framework
|
|
3
3
|
*
|
|
4
|
-
* @author NEHONIX (
|
|
4
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
5
5
|
* @license Nehonix Open Source License (NOSL)
|
|
6
6
|
*
|
|
7
7
|
* Copyright (c) 2025 NEHONIX. All rights reserved.
|
|
8
8
|
****************************************************************************/
|
|
9
|
-
|
|
9
|
+
export { Password } from "./core/Password";
|
|
10
10
|
/**
|
|
11
11
|
* # XyPriss Security
|
|
12
12
|
*
|
|
@@ -18,5 +18,5 @@ export * from "./utils/index";
|
|
|
18
18
|
export * from "./components/encryption/index";
|
|
19
19
|
export * from "./components/serializer";
|
|
20
20
|
export * from "./components/cache/SecureCacheAdapter";
|
|
21
|
-
export
|
|
21
|
+
export { CHARSETS, MIN_GENERATE_LENGTH, MAX_GENERATE_LENGTH, getWordlist, } from "./mods/PasswordMDict";
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;8EAO8E;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAG7B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uCAAuC,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;8EAO8E;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;GAIG;AAGH,cAAc,cAAc,CAAC;AAG7B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uCAAuC,CAAC;AAEtD,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,GACZ,MAAM,sBAAsB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/***************************************************************************
|
|
3
3
|
* XyPriss Security - Advanced Hyper-Modular Security Framework
|
|
4
4
|
*
|
|
5
|
-
* @author NEHONIX (
|
|
5
|
+
* @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
|
|
6
6
|
* @license Nehonix Open Source License (NOSL)
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) 2025 NEHONIX. All rights reserved.
|
|
@@ -22,8 +22,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
22
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
26
|
-
|
|
25
|
+
exports.getWordlist = exports.MAX_GENERATE_LENGTH = exports.MIN_GENERATE_LENGTH = exports.CHARSETS = exports.Password = void 0;
|
|
26
|
+
var Password_1 = require("./core/Password");
|
|
27
|
+
Object.defineProperty(exports, "Password", { enumerable: true, get: function () { return Password_1.Password; } });
|
|
27
28
|
/**
|
|
28
29
|
* # XyPriss Security
|
|
29
30
|
*
|
|
@@ -38,6 +39,9 @@ __exportStar(require("./utils/index"), exports);
|
|
|
38
39
|
__exportStar(require("./components/encryption/index"), exports);
|
|
39
40
|
__exportStar(require("./components/serializer"), exports);
|
|
40
41
|
__exportStar(require("./components/cache/SecureCacheAdapter"), exports);
|
|
41
|
-
|
|
42
|
-
exports
|
|
42
|
+
var PasswordMDict_1 = require("./mods/PasswordMDict");
|
|
43
|
+
Object.defineProperty(exports, "CHARSETS", { enumerable: true, get: function () { return PasswordMDict_1.CHARSETS; } });
|
|
44
|
+
Object.defineProperty(exports, "MIN_GENERATE_LENGTH", { enumerable: true, get: function () { return PasswordMDict_1.MIN_GENERATE_LENGTH; } });
|
|
45
|
+
Object.defineProperty(exports, "MAX_GENERATE_LENGTH", { enumerable: true, get: function () { return PasswordMDict_1.MAX_GENERATE_LENGTH; } });
|
|
46
|
+
Object.defineProperty(exports, "getWordlist", { enumerable: true, get: function () { return PasswordMDict_1.getWordlist; } });
|
|
43
47
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;8EAO8E;;;;;;;;;;;;;;;;;AAE9E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;8EAO8E;;;;;;;;;;;;;;;;;AAE9E,4CAA2C;AAAlC,oGAAA,QAAQ,OAAA;AAEjB;;;;GAIG;AAEH,yDAAyD;AACzD,+CAA6B,CAAC,6CAA6C;AAE3E,oDAAoD;AACpD,qDAAmC;AAEnC,uBAAuB;AACvB,gDAA8B;AAC9B,gEAA8C;AAC9C,0DAAwC;AACxC,wEAAsD;AAEtD,sDAK8B;AAJ5B,yGAAA,QAAQ,OAAA;AACR,oHAAA,mBAAmB,OAAA;AACnB,oHAAA,mBAAmB,OAAA;AACnB,4GAAA,WAAW,OAAA"}
|