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.
Files changed (34) hide show
  1. package/README.md +10 -8
  2. package/dist/src/components/index.d.ts +1 -1
  3. package/dist/src/components/index.js +1 -1
  4. package/dist/src/core/PasswordManager.d.ts +205 -0
  5. package/dist/src/core/PasswordManager.d.ts.map +1 -0
  6. package/dist/src/core/PasswordManager.js +478 -0
  7. package/dist/src/core/PasswordManager.js.map +1 -0
  8. package/dist/src/core/SecureBuffer.d.ts +1 -1
  9. package/dist/src/core/SecureBuffer.js +1 -1
  10. package/dist/src/core/index.d.ts +3 -2
  11. package/dist/src/core/index.d.ts.map +1 -1
  12. package/dist/src/core/index.js +4 -3
  13. package/dist/src/core/index.js.map +1 -1
  14. package/dist/src/index.d.ts +3 -3
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +9 -5
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/mods/PasswordMDict.d.ts +141 -0
  19. package/dist/src/mods/PasswordMDict.d.ts.map +1 -0
  20. package/dist/src/mods/PasswordMDict.js +464 -0
  21. package/dist/src/mods/PasswordMDict.js.map +1 -0
  22. package/dist/src/mods/eff_large_wordlist.txt +7776 -0
  23. package/dist/src/mods/eff_short_wordlist_2_0.txt +1296 -0
  24. package/dist/src/types/PasswordManagerOptions.d.ts +142 -0
  25. package/dist/src/types/PasswordManagerOptions.d.ts.map +1 -0
  26. package/dist/src/types/PasswordManagerOptions.js +4 -0
  27. package/dist/src/types/PasswordManagerOptions.js.map +1 -0
  28. package/dist/src/types/index.d.ts +1 -1
  29. package/dist/src/types/index.js +1 -1
  30. package/dist/src/utils/CryptoAlgorithmUtils.d.ts +1 -1
  31. package/dist/src/utils/CryptoAlgorithmUtils.js +1 -1
  32. package/dist/src/utils/index.d.ts +1 -1
  33. package/dist/src/utils/index.js +1 -1
  34. package/package.json +2 -2
package/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  # XyPriss Security
2
2
 
3
- XyPriss Security is an enterprise-grade cryptographic framework for **Bun** and **Node.js**. It utilizes a high-performance Go-based core engine via native FFI (Foreign Function Interface) to provide military-grade security with sub-millisecond overhead across all major JavaScript environments.
3
+ XyPriss Security is an enterprise-grade cryptographic framework for TypeScript / JavaScript environments. It utilizes a high-performance Go-based core engine compiled as a static, dependency-free CLI binary to provide military-grade security with absolute cross-platform reliability.
4
4
 
5
5
  ## Core Principles
6
6
 
7
- - **Performance**: Optimized atomic FFI calls bypass the overhead of standard JavaScript cryptographic implementations.
8
- - **Cross-Runtime**: First-class support for both Bun (`bun:ffi`) and Node.js (`koffi`), automatically detecting the host environment.
7
+ - **Performance**: Optimized execution using lightweight process spawning, bypassing the overhead of standard JavaScript cryptographic implementations without the complexity of CGO.
8
+ - **Universal Portability**: Zero native compilation required. Statically linked pure Go binaries run flawlessly on Linux, Windows, and macOS (amd64/arm64) via a unified interface.
9
9
  - **Modern Standards**: Native support for AES-256-GCM, Argon2id, PBKDF2, HKDF, and Post-Quantum algorithms (Kyber-768).
10
-
11
10
  - **Security by Default**: Automatic memory sanitization and secure key derivation patterns.
12
- - **Zero-Config Native Performance**: Automatically builds the Go core from source or downloads pre-built binaries for your platform during installation.
11
+ - **Zero-Config Installation**: Automatically downloads the exact pre-built binary for your platform during installation (no local Go toolchain required).
13
12
 
14
13
  ## Documentation
15
14
 
@@ -74,12 +73,15 @@ XyPriss uses Argon2id by default, providing superior resistance to GPU/ASIC crac
74
73
  ```typescript
75
74
  import { pm } from "xypriss-security"; // 'pm' is an alias for PasswordManager
76
75
 
77
- const hash = await pm.hash("user-password-123", {
78
- memoryCost: 65536, // 64MB
76
+ // 1. Configure once per app
77
+ const passwords = new pm({
78
+ memoryCost: 65536, // 64MiB
79
79
  parallelism: 4,
80
80
  });
81
81
 
82
- const isValid = await pm.verify("user-password-123", hash);
82
+ // 2. Use everywhere
83
+ const hash = await passwords.hash("user-password-123");
84
+ const isValid = await passwords.verify("user-password-123", hash);
83
85
  ```
84
86
 
85
87
  ### Ultra-Fast Secure Caching (UFSIMC)
@@ -1,7 +1,7 @@
1
1
  /***************************************************************************
2
2
  * XyPriss Security - Modular Component Registry
3
3
  *
4
- * @author NEHONIX (iDevo - https://github.com/iDevo-ll)
4
+ * @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
5
5
  * @license Nehonix Open Source License (NOSL)
6
6
  ****************************************************************************/
7
7
  export * from "./cache";
@@ -2,7 +2,7 @@
2
2
  /***************************************************************************
3
3
  * XyPriss Security - Modular Component Registry
4
4
  *
5
- * @author NEHONIX (iDevo - https://github.com/iDevo-ll)
5
+ * @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
6
6
  * @license Nehonix Open Source License (NOSL)
7
7
  ****************************************************************************/
8
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -0,0 +1,205 @@
1
+ /***************************************************************************
2
+ * XyPriss Security - Advanced Hyper-Modular Security Framework
3
+ *
4
+ * @author NEHONIX (Nehonix-Team - https://github.com/Nehonix-Team)
5
+ * @license Nehonix Open Source License (NOSL)
6
+ *
7
+ * Copyright (c) 2025 NEHONIX. All rights reserved.
8
+ ****************************************************************************/
9
+ import type { PasswordManagerOptions, BreachCheckResult, PassphraseOptions, PasswordGenerateOptions, PasswordStrengthResult } from "../types/PasswordManagerOptions";
10
+ /***************************************************************************
11
+ * ### PasswordManager
12
+ *
13
+ * A configurable, instance-based password manager.
14
+ * Unlike the static `Password` class, `PasswordManager` is instantiated
15
+ * once with all options pre-configured, so callers only need to pass
16
+ * the raw password string at call time.
17
+ *
18
+ * This is the recommended pattern for large-scale projects:
19
+ * configure once in a dedicated file, export the instance, and reuse
20
+ * everywhere without repeating options.
21
+ *
22
+ * @example
23
+ * // config/security.ts
24
+ * export const passwords = new PasswordManager({
25
+ * algorithm: "argon2id",
26
+ * memoryCost: 65536,
27
+ * parallelism: 4,
28
+ * iterations: 3,
29
+ * pepper: process.env.PASSWORD_PEPPER,
30
+ * });
31
+ *
32
+ * // anywhere in the app:
33
+ * const hash = await passwords.hash("user-raw-password");
34
+ * const valid = await passwords.verify("user-raw-password", hash);
35
+ * const temp = passwords.generate({ length: 24, symbols: true });
36
+ * const passphrase = passwords.generatePassphrase({ wordCount: 5 });
37
+ * const pin = passwords.generatePin(6);
38
+ * const info = passwords.strength("MyP@ss1!");
39
+ * const breach = await passwords.isBreached("hunter2");
40
+ * const stale = passwords.needsRehash(storedHash);
41
+ */
42
+ export declare class PasswordManager {
43
+ private readonly algo;
44
+ private readonly memoryCost;
45
+ private readonly iterations;
46
+ private readonly parallelism;
47
+ private readonly pepper;
48
+ constructor(options?: PasswordManagerOptions);
49
+ /**
50
+ * Hashes a password using the instance's pre-configured options.
51
+ *
52
+ * @param password - The plain-text password to hash.
53
+ * @param overrides - Optional per-call overrides for any constructor option.
54
+ * @returns The encoded hash string, ready to be stored.
55
+ */
56
+ hash(password: string, overrides?: Partial<PasswordManagerOptions>): Promise<string>;
57
+ /**
58
+ * Verifies a plain-text password against a stored hash.
59
+ *
60
+ * @param password - The password to verify.
61
+ * @param hash - The stored hash to compare against.
62
+ * @param overrides - Optional per-call override for the pepper.
63
+ * @returns `true` if the password matches the hash, `false` otherwise.
64
+ */
65
+ verify(password: string, hash: string, overrides?: Pick<PasswordManagerOptions, "pepper">): Promise<boolean>;
66
+ /**
67
+ * Generates a cryptographically secure random password matching the given
68
+ * criteria, with **guaranteed character-type coverage**.
69
+ *
70
+ * Security properties:
71
+ * - Every enabled character type appears **at least once** in the output.
72
+ * - `extra` characters are **injected at cryptographically random positions**
73
+ * rather than appended, ensuring they don't cluster at the end.
74
+ * - The final array is **Fisher-Yates shuffled** via `Random.Int` to remove
75
+ * any positional bias introduced during construction.
76
+ * - `length` is clamped to [8, 512] to prevent misuse.
77
+ * - Throws `RangeError` if no character type is enabled (empty charset).
78
+ *
79
+ * @param options - Character set and length configuration.
80
+ * @returns A plain-text randomly generated password string.
81
+ *
82
+ * @example
83
+ * const pwd = passwords.generate({ length: 24, symbols: true });
84
+ */
85
+ generate(options?: PasswordGenerateOptions): string;
86
+ /**
87
+ * Generates a **memorable, high-entropy passphrase** using a curated
88
+ * 256-word list (similar to Diceware / EFF methodology).
89
+ *
90
+ * Entropy: `log2(256^wordCount)` = `8 * wordCount` bits minimum.
91
+ * With 5 words: ~40 bits base + number suffix ≈ 53 bits total.
92
+ * With 6 words: ~48 bits base + number suffix ≈ 61 bits total.
93
+ *
94
+ * Security note: word selection uses `Random.Int` which must be backed
95
+ * by a CSPRNG (e.g. `crypto.randomInt`).
96
+ *
97
+ * @param options - Passphrase configuration.
98
+ * @returns A plain-text passphrase string.
99
+ *
100
+ * @example
101
+ * passwords.generatePassphrase({ wordCount: 5, separator: "-" });
102
+ * // → "Bold-Cave-Iron-Jump-Warm-4827"
103
+ */
104
+ generatePassphrase(options?: PassphraseOptions): string;
105
+ /**
106
+ * Generates a cryptographically secure numeric PIN.
107
+ *
108
+ * Each digit is drawn independently from the full [0-9] range.
109
+ * The PIN is **zero-padded** to the requested length and returned as a
110
+ * string to preserve leading zeros (e.g. "0472").
111
+ *
112
+ * @param length - Number of digits. Must be between 4 and 32. @default 6
113
+ * @returns A plain-text numeric PIN string.
114
+ *
115
+ * @example
116
+ * passwords.generatePin(6); // → "047291"
117
+ */
118
+ generatePin(length?: number): string;
119
+ /**
120
+ * Evaluates the strength of a password and returns a detailed report.
121
+ *
122
+ * The score is computed from multiple orthogonal criteria:
123
+ * - Length (up to 30 points)
124
+ * - Character variety (up to 50 points)
125
+ * - Absence of repetitions and sequences (up to 20 points deducted)
126
+ *
127
+ * @param password - The password to evaluate.
128
+ * @returns A `PasswordStrengthResult` with score, label, and actionable suggestions.
129
+ *
130
+ * @example
131
+ * const info = passwords.strength("MyP@ssw0rd!");
132
+ * console.log(info.score, info.label); // 82 "strong"
133
+ */
134
+ strength(password: string): PasswordStrengthResult;
135
+ /**
136
+ * Checks whether a password has appeared in a publicly known data breach
137
+ * using the **HaveIBeenPwned Pwned Passwords API v3** with **k-anonymity**.
138
+ *
139
+ * The full password is **never transmitted**. Only the first 5 characters of
140
+ * its SHA-1 hex digest are sent over the network; the remainder of the
141
+ * matching is performed locally.
142
+ *
143
+ * @param password - The plain-text password to check.
144
+ * @returns A `BreachCheckResult` indicating breach status and occurrence count.
145
+ * @throws If the network request fails or returns an unexpected status code.
146
+ *
147
+ * @example
148
+ * const result = await passwords.isBreached("hunter2");
149
+ * if (result.breached) {
150
+ * console.warn(`Password found ${result.occurrences} times in breach databases.`);
151
+ * }
152
+ */
153
+ isBreached(password: string): Promise<BreachCheckResult>;
154
+ /**
155
+ * Determines whether a stored hash was produced with weaker parameters than
156
+ * the instance's current configuration (e.g. after a security upgrade).
157
+ *
158
+ * Supports Argon2id hash strings in the PHC string format:
159
+ * `$argon2id$v=19$m=<mem>,t=<iter>,p=<par>$<salt>$<hash>`
160
+ *
161
+ * For other algorithms, returns `false` (no opinion) so the caller can
162
+ * decide on a case-by-case basis.
163
+ *
164
+ * @param hash - The stored hash string to inspect.
165
+ * @returns `true` if the hash should be re-hashed on next successful login.
166
+ *
167
+ * @example
168
+ * if (passwords.needsRehash(user.passwordHash)) {
169
+ * user.passwordHash = await passwords.hash(rawPassword);
170
+ * await user.save();
171
+ * }
172
+ */
173
+ needsRehash(hash: string): boolean;
174
+ /**
175
+ * Validates and normalizes a raw password string before hashing.
176
+ *
177
+ * Checks performed:
178
+ * - Not empty or whitespace-only.
179
+ * - Minimum length of 8 characters.
180
+ * - Maximum length of 1024 characters (DoS guard against bcrypt-style
181
+ * long-password attacks on other algorithms).
182
+ * - Unicode NFC normalization (prevents homoglyph bypass attacks).
183
+ *
184
+ * @param password - The raw password string from user input.
185
+ * @returns The NFC-normalized password, ready for hashing.
186
+ * @throws `TypeError` if the input is not a string.
187
+ * @throws `RangeError` if the password fails length validation.
188
+ *
189
+ * @example
190
+ * const normalized = passwords.sanitizeInput(req.body.password);
191
+ * const hash = await passwords.hash(normalized);
192
+ */
193
+ sanitizeInput(password: unknown): string;
194
+ /**
195
+ * Returns a summary of the instance's current configuration.
196
+ * The `pepper` is intentionally omitted from the output.
197
+ */
198
+ getConfig(): {
199
+ algorithm: string;
200
+ memoryCost: number;
201
+ iterations: number;
202
+ parallelism: number;
203
+ };
204
+ }
205
+ //# sourceMappingURL=PasswordManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PasswordManager.d.ts","sourceRoot":"","sources":["../../../src/core/PasswordManager.ts"],"names":[],"mappings":"AAAA;;;;;;;8EAO8E;AAY9E,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;gBAEhC,OAAO,GAAE,sBAA2B;IAUhD;;;;;;OAMG;IACU,IAAI,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAC9C,OAAO,CAAC,MAAM,CAAC;IAYlB;;;;;;;OAOG;IACU,MAAM,CACjB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAM,GACrD,OAAO,CAAC,OAAO,CAAC;IAQnB;;;;;;;;;;;;;;;;;;OAkBG;IACI,QAAQ,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM;IA6E9D;;;;;;;;;;;;;;;;;OAiBG;IACI,kBAAkB,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM;IAsDlE;;;;;;;;;;;;OAYG;IACI,WAAW,CAAC,MAAM,GAAE,MAAU,GAAG,MAAM;IAgB9C;;;;;;;;;;;;;;OAcG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB;IA4FzD;;;;;;;;;;;;;;;;;OAiBG;IACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAyCrE;;;;;;;;;;;;;;;;;;OAkBG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAczC;;;;;;;;;;;;;;;;;;OAkBG;IACI,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM;IAiC/C;;;OAGG;IACI,SAAS,IAAI;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB;CAQF"}