@digitaldefiance/ecies-lib 1.1.13 → 1.1.15

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 (150) hide show
  1. package/README.md +273 -446
  2. package/dist/constants.js +68 -57
  3. package/dist/constants.js.map +1 -1
  4. package/dist/email-string.js +16 -9
  5. package/dist/email-string.js.map +1 -1
  6. package/dist/enumerations/ecies-encryption-type.js +27 -20
  7. package/dist/enumerations/ecies-encryption-type.js.map +1 -1
  8. package/dist/enumerations/ecies-error-type.js +5 -2
  9. package/dist/enumerations/ecies-error-type.js.map +1 -1
  10. package/dist/enumerations/ecies-string-key.js +5 -2
  11. package/dist/enumerations/ecies-string-key.js.map +1 -1
  12. package/dist/enumerations/guid-brand-type.js +5 -2
  13. package/dist/enumerations/guid-brand-type.js.map +1 -1
  14. package/dist/enumerations/guid-error-type.js +5 -2
  15. package/dist/enumerations/guid-error-type.js.map +1 -1
  16. package/dist/enumerations/index.js +30 -14
  17. package/dist/enumerations/index.js.map +1 -1
  18. package/dist/enumerations/invalid-email-type.js +5 -2
  19. package/dist/enumerations/invalid-email-type.js.map +1 -1
  20. package/dist/enumerations/length-encoding-type.js +5 -2
  21. package/dist/enumerations/length-encoding-type.js.map +1 -1
  22. package/dist/enumerations/length-error-type.js +5 -2
  23. package/dist/enumerations/length-error-type.js.map +1 -1
  24. package/dist/enumerations/member-error-type.js +6 -3
  25. package/dist/enumerations/member-error-type.js.map +1 -1
  26. package/dist/enumerations/member-type.js +6 -3
  27. package/dist/enumerations/member-type.js.map +1 -1
  28. package/dist/enumerations/password-login-error-type.js +5 -2
  29. package/dist/enumerations/password-login-error-type.js.map +1 -1
  30. package/dist/enumerations/pbkdf2-error-type.js +5 -2
  31. package/dist/enumerations/pbkdf2-error-type.js.map +1 -1
  32. package/dist/enumerations/pbkdf2-profile.js +5 -2
  33. package/dist/enumerations/pbkdf2-profile.js.map +1 -1
  34. package/dist/enumerations/secure-storage-error-type.js +5 -2
  35. package/dist/enumerations/secure-storage-error-type.js.map +1 -1
  36. package/dist/errors/disposed.js +8 -4
  37. package/dist/errors/disposed.js.map +1 -1
  38. package/dist/errors/ecies.js +11 -7
  39. package/dist/errors/ecies.js.map +1 -1
  40. package/dist/errors/guid.js +9 -5
  41. package/dist/errors/guid.js.map +1 -1
  42. package/dist/errors/handleable.js +5 -1
  43. package/dist/errors/handleable.js.map +1 -1
  44. package/dist/errors/index.js +27 -11
  45. package/dist/errors/index.js.map +1 -1
  46. package/dist/errors/invalid-email.js +9 -5
  47. package/dist/errors/invalid-email.js.map +1 -1
  48. package/dist/errors/length.js +9 -5
  49. package/dist/errors/length.js.map +1 -1
  50. package/dist/errors/member.js +9 -5
  51. package/dist/errors/member.js.map +1 -1
  52. package/dist/errors/pbkdf2.js +9 -5
  53. package/dist/errors/pbkdf2.js.map +1 -1
  54. package/dist/errors/secure-storage.js +9 -5
  55. package/dist/errors/secure-storage.js.map +1 -1
  56. package/dist/errors/simple-ecies.js +9 -5
  57. package/dist/errors/simple-ecies.js.map +1 -1
  58. package/dist/errors/simple-test-error.js +5 -1
  59. package/dist/errors/simple-test-error.js.map +1 -1
  60. package/dist/errors/translatable.js +6 -2
  61. package/dist/errors/translatable.js.map +1 -1
  62. package/dist/errors/typed-handleable.js +9 -5
  63. package/dist/errors/typed-handleable.js.map +1 -1
  64. package/dist/guid.js +113 -76
  65. package/dist/guid.js.map +1 -1
  66. package/dist/i18n-setup.js +675 -665
  67. package/dist/i18n-setup.js.map +1 -1
  68. package/dist/index.js +30 -14
  69. package/dist/index.js.map +1 -1
  70. package/dist/interfaces/checksum-config.js +2 -1
  71. package/dist/interfaces/checksum-consts.js +2 -1
  72. package/dist/interfaces/constants.js +2 -1
  73. package/dist/interfaces/ecies-config.js +2 -1
  74. package/dist/interfaces/ecies-consts.js +2 -1
  75. package/dist/interfaces/ecies-file-service.js +2 -1
  76. package/dist/interfaces/guid.js +2 -1
  77. package/dist/interfaces/handleable-error-options.js +2 -1
  78. package/dist/interfaces/handleable.js +2 -1
  79. package/dist/interfaces/index.js +31 -15
  80. package/dist/interfaces/index.js.map +1 -1
  81. package/dist/interfaces/library-error.js +2 -1
  82. package/dist/interfaces/member-operational.js +2 -1
  83. package/dist/interfaces/member-storage.js +2 -1
  84. package/dist/interfaces/member-with-mnemonic.js +2 -1
  85. package/dist/interfaces/pbkdf2-config.js +2 -1
  86. package/dist/interfaces/pbkdf2-consts.js +2 -1
  87. package/dist/interfaces/pbkdf2-result.js +2 -1
  88. package/dist/member.js +44 -37
  89. package/dist/member.js.map +1 -1
  90. package/dist/pbkdf2-profiles.js +2 -1
  91. package/dist/regexes.js +5 -2
  92. package/dist/regexes.js.map +1 -1
  93. package/dist/secure-buffer.js +22 -18
  94. package/dist/secure-buffer.js.map +1 -1
  95. package/dist/secure-string.js +24 -20
  96. package/dist/secure-string.js.map +1 -1
  97. package/dist/services/aes-gcm.js +13 -9
  98. package/dist/services/aes-gcm.js.map +1 -1
  99. package/dist/services/ecies/crypto-core.js +35 -31
  100. package/dist/services/ecies/crypto-core.js.map +1 -1
  101. package/dist/services/ecies/example.js +44 -37
  102. package/dist/services/ecies/example.js.map +1 -1
  103. package/dist/services/ecies/file.js +5 -1
  104. package/dist/services/ecies/file.js.map +1 -1
  105. package/dist/services/ecies/index.js +28 -10
  106. package/dist/services/ecies/index.js.map +1 -1
  107. package/dist/services/ecies/integration.js +28 -23
  108. package/dist/services/ecies/integration.js.map +1 -1
  109. package/dist/services/ecies/interfaces.js +2 -1
  110. package/dist/services/ecies/interfaces.js.map +1 -1
  111. package/dist/services/ecies/manual-test.js +34 -26
  112. package/dist/services/ecies/manual-test.js.map +1 -1
  113. package/dist/services/ecies/multi-recipient.js +51 -47
  114. package/dist/services/ecies/multi-recipient.js.map +1 -1
  115. package/dist/services/ecies/service.js +20 -16
  116. package/dist/services/ecies/service.js.map +1 -1
  117. package/dist/services/ecies/signature.js +13 -9
  118. package/dist/services/ecies/signature.js.map +1 -1
  119. package/dist/services/ecies/single-recipient.js +32 -28
  120. package/dist/services/ecies/single-recipient.js.map +1 -1
  121. package/dist/services/index.js +21 -5
  122. package/dist/services/index.js.map +1 -1
  123. package/dist/services/password-login.js +37 -33
  124. package/dist/services/password-login.js.map +1 -1
  125. package/dist/services/pbkdf2.js +12 -8
  126. package/dist/services/pbkdf2.js.map +1 -1
  127. package/dist/services/xor.js +5 -1
  128. package/dist/services/xor.js.map +1 -1
  129. package/dist/types/deep-partial.js +2 -1
  130. package/dist/types.js +2 -1
  131. package/dist/utils.js +69 -51
  132. package/dist/utils.js.map +1 -1
  133. package/package.json +2 -2
  134. package/dist/defaults.d.ts +0 -37
  135. package/dist/defaults.d.ts.map +0 -1
  136. package/dist/defaults.js +0 -323
  137. package/dist/defaults.js.map +0 -1
  138. package/dist/errors/typed.d.ts +0 -14
  139. package/dist/errors/typed.d.ts.map +0 -1
  140. package/dist/errors/typed.js +0 -48
  141. package/dist/errors/typed.js.map +0 -1
  142. package/dist/i18n-config.d.ts +0 -77
  143. package/dist/i18n-config.d.ts.map +0 -1
  144. package/dist/i18n-config.js +0 -88
  145. package/dist/i18n-config.js.map +0 -1
  146. package/dist/interfaces/defaults.d.ts +0 -35
  147. package/dist/interfaces/defaults.d.ts.map +0 -1
  148. package/dist/interfaces/defaults.js +0 -2
  149. package/dist/interfaces/defaults.js.map +0 -1
  150. package/dist/package.json +0 -63
package/README.md CHANGED
@@ -1,33 +1,33 @@
1
1
  # @digitaldefiance/ecies-lib
2
2
 
3
- A production-ready, browser-friendly implementation of Elliptic Curve Integrated Encryption Scheme (ECIES) and related cryptographic primitives for modern TypeScript runtimes. Built on Web Crypto API and @noble/curves, this library provides comprehensive encryption, key management, and authentication services with full internationalization support. This package is also binary compatible with @digitaldefiance/node-ecies-lib, enabling seamless cross-platform cryptographic operations.
3
+ Production-ready, browser-compatible ECIES (Elliptic Curve Integrated Encryption Scheme) library for TypeScript. Built on Web Crypto API and @noble/curves with comprehensive encryption, key management, and authentication services. Binary compatible with @digitaldefiance/node-ecies-lib for seamless cross-platform operations.
4
4
 
5
- ## Key Features
5
+ ## Features
6
6
 
7
7
  ### Core Cryptography
8
- - **ECIES Encryption** – Three modes: Simple (minimal overhead), Single (length-prefixed), and Multiple (multi-recipient)
9
- - **Elliptic Curve Operations** – secp256k1 curve for ECDH key exchange and ECDSA signatures
10
- - **AES-GCM Encryption** – Authenticated symmetric encryption with Web Crypto API
11
- - **PBKDF2 Key Derivation** – Configurable profiles for password-based key generation
8
+ - **ECIES Encryption** – Simple (98-byte overhead), Single (106-byte overhead), Multiple (multi-recipient) modes
9
+ - **secp256k1 Curve** – ECDH key exchange and ECDSA signatures
10
+ - **AES-256-GCM** – Authenticated symmetric encryption via Web Crypto API
11
+ - **PBKDF2** – Configurable password-based key derivation profiles
12
12
 
13
13
  ### Key Management
14
- - **BIP39 Mnemonic Support** – Generate and derive keys from 12/15/18/21/24-word mnemonics
15
- - **HD Wallet Integration** – BIP32/BIP44 hierarchical deterministic key derivation
16
- - **Member System** – Complete user/member abstraction with cryptographic operations
17
- - **Secure Storage** – Memory-safe SecureString and SecureBuffer with auto-zeroing
14
+ - **BIP39 Mnemonics** – 12/15/18/21/24-word phrase generation and key derivation
15
+ - **HD Wallets** – BIP32/BIP44 hierarchical deterministic derivation
16
+ - **Member System** – User abstraction with cryptographic operations
17
+ - **Secure Storage** – Memory-safe SecureString/SecureBuffer with XOR obfuscation and auto-zeroing
18
18
 
19
- ### Advanced Features
20
- - **Multi-Recipient Encryption** – Efficiently encrypt for up to 65,535 recipients
21
- - **File Encryption Service** – Chunked file encryption with streaming support
22
- - **Password Login System** – Complete authentication flow with encrypted key storage
23
- - **Signature Operations** – ECDSA message signing and verification
19
+ ### Advanced
20
+ - **Multi-Recipient** – Encrypt for up to 65,535 recipients efficiently
21
+ - **File Encryption** – Chunked 1MB segments for large files
22
+ - **Password Login** – Complete authentication with encrypted key storage
23
+ - **Signatures** – ECDSA message signing and verification
24
24
 
25
25
  ### Developer Experience
26
- - **Full TypeScript Support** – Comprehensive type definitions and interfaces
27
- - **Internationalization** – Error messages in English, French, Spanish, Chinese, and Ukrainian
28
- - **Runtime Configuration** – Injectable configuration profiles for different security requirements
29
- - **Extensive Testing** – 380+ test specs covering unit, integration, and e2e scenarios
30
- - **Cross-Platform** – Works in Node.js 18+ and modern browsers
26
+ - **TypeScript** – Full type definitions and interfaces
27
+ - **i18n** – Error messages in 8 languages (en-US, en-GB, fr, es, de, zh-CN, ja, uk)
28
+ - **Runtime Config** – Injectable configuration profiles via ConstantsRegistry
29
+ - **Testing** – 32 test files with 389+ specs (unit, integration, e2e)
30
+ - **Cross-Platform** – Node.js 18+ and modern browsers
31
31
 
32
32
  ## Installation
33
33
 
@@ -35,68 +35,43 @@ A production-ready, browser-friendly implementation of Elliptic Curve Integrated
35
35
  npm install @digitaldefiance/ecies-lib
36
36
  # or
37
37
  yarn add @digitaldefiance/ecies-lib
38
- # or
39
- pnpm add @digitaldefiance/ecies-lib
40
38
  ```
41
39
 
42
- ### Runtime Requirements
40
+ ### Requirements
43
41
 
44
- - **Node.js**: Version 18+ (includes Web Crypto API)
45
- - For Node < 18, polyfill `globalThis.crypto` before importing
46
- - **Browsers**: Modern browsers with Web Crypto API and BigInt support
47
- - Chrome/Edge 60+
48
- - Firefox 60+
49
- - Safari 14+
50
- - Opera 47+
42
+ **Node.js**: 18+ (Web Crypto API built-in)
43
+ - For Node < 18: `import { webcrypto } from 'crypto'; globalThis.crypto = webcrypto as unknown as Crypto;`
51
44
 
52
- ### Dependencies
45
+ **Browsers**: Chrome/Edge 60+, Firefox 60+, Safari 14+, Opera 47+
53
46
 
54
- The library has minimal peer dependencies:
55
- - `@digitaldefiance/i18n-lib` - Internationalization engine
56
- - `@noble/curves` - Elliptic curve cryptography
57
- - `@scure/bip32`, `@scure/bip39` - HD wallet and mnemonic support
58
- - `@ethereumjs/wallet` - Ethereum wallet compatibility
47
+ **Dependencies**: `@digitaldefiance/i18n-lib`, `@noble/curves`, `@scure/bip32`, `@scure/bip39`, `@ethereumjs/wallet`, `bson`, `ts-brand`
59
48
 
60
49
  ## Quick Start
61
50
 
62
- ### Basic Encryption/Decryption
51
+ ### Basic Encryption
63
52
 
64
53
  ```typescript
65
54
  import { ECIESService } from '@digitaldefiance/ecies-lib';
66
55
 
67
- // Initialize the service
68
56
  const ecies = new ECIESService();
69
-
70
- // Generate a mnemonic and derive keys
71
57
  const mnemonic = ecies.generateNewMnemonic();
72
58
  const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
73
59
 
74
- // Encrypt a message
60
+ // Encrypt
75
61
  const message = new TextEncoder().encode('Hello, World!');
76
- const encrypted = await ecies.encryptSimpleOrSingle(
77
- false, // false = Single mode (with length prefix)
78
- publicKey,
79
- message
80
- );
81
-
82
- // Decrypt the message
83
- const decrypted = await ecies.decryptSimpleOrSingleWithHeader(
84
- false,
85
- privateKey,
86
- encrypted
87
- );
62
+ const encrypted = await ecies.encryptSimpleOrSingle(false, publicKey, message);
88
63
 
64
+ // Decrypt
65
+ const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encrypted);
89
66
  console.log(new TextDecoder().decode(decrypted)); // "Hello, World!"
90
67
  ```
91
68
 
92
- ### Using the Member System
69
+ ### Member System
93
70
 
94
71
  ```typescript
95
72
  import { ECIESService, Member, MemberType, EmailString } from '@digitaldefiance/ecies-lib';
96
73
 
97
74
  const ecies = new ECIESService();
98
-
99
- // Create a new member with generated keys
100
75
  const { member, mnemonic } = Member.newMember(
101
76
  ecies,
102
77
  MemberType.User,
@@ -104,76 +79,52 @@ const { member, mnemonic } = Member.newMember(
104
79
  new EmailString('alice@example.com')
105
80
  );
106
81
 
107
- // Encrypt data for the member
108
- const data = 'Sensitive information';
109
- const encrypted = await member.encryptData(data);
110
-
111
- // Decrypt the data
82
+ // Encrypt/decrypt
83
+ const encrypted = await member.encryptData('Sensitive data');
112
84
  const decrypted = await member.decryptData(encrypted);
113
- console.log(new TextDecoder().decode(decrypted));
114
85
 
115
- // Sign and verify messages
86
+ // Sign/verify
116
87
  const signature = member.sign(new TextEncoder().encode('Message'));
117
- const isValid = member.verify(signature, new TextEncoder().encode('Message'));
88
+ const valid = member.verify(signature, new TextEncoder().encode('Message'));
118
89
  ```
119
90
 
120
91
  ## Core Services
121
92
 
122
- ### ECIESService - Main Encryption Service
93
+ ### ECIESService
123
94
 
124
- The primary service for ECIES operations:
95
+ Main encryption service with three modes:
125
96
 
126
97
  ```typescript
127
- import { ECIESService, EciesEncryptionTypeEnum } from '@digitaldefiance/ecies-lib';
98
+ import { ECIESService } from '@digitaldefiance/ecies-lib';
128
99
 
129
100
  const ecies = new ECIESService();
130
-
131
- // Generate keys
132
101
  const mnemonic = ecies.generateNewMnemonic();
133
- const { wallet, seed } = ecies.walletAndSeedFromMnemonic(mnemonic);
134
- const { privateKey, publicKey } = ecies.seedToSimpleKeyPair(seed);
135
-
136
- // Simple mode - minimal overhead, no length prefix
137
- const simpleEncrypted = await ecies.encryptSimpleOrSingle(
138
- true, // true = Simple mode
139
- publicKey,
140
- message
141
- );
102
+ const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
142
103
 
143
- // Single mode - includes length prefix for validation
144
- const singleEncrypted = await ecies.encryptSimpleOrSingle(
145
- false, // false = Single mode
146
- publicKey,
147
- message
148
- );
104
+ // Simple mode (98-byte overhead, no length prefix)
105
+ const simple = await ecies.encryptSimpleOrSingle(true, publicKey, message);
106
+
107
+ // Single mode (106-byte overhead, 8-byte length prefix)
108
+ const single = await ecies.encryptSimpleOrSingle(false, publicKey, message);
149
109
 
150
110
  // Decrypt with automatic header parsing
151
- const decrypted = await ecies.decryptSimpleOrSingleWithHeader(
152
- false,
153
- privateKey,
154
- singleEncrypted
155
- );
111
+ const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, single);
156
112
  ```
157
113
 
158
- ### Multi-Recipient Encryption
114
+ ### EciesMultiRecipient
159
115
 
160
- Encrypt once for multiple recipients efficiently:
116
+ Encrypt once for multiple recipients:
161
117
 
162
118
  ```typescript
163
- import {
164
- EciesMultiRecipient,
165
- EciesCryptoCore,
166
- ECIES,
167
- concatUint8Arrays,
168
- } from '@digitaldefiance/ecies-lib';
119
+ import { EciesMultiRecipient, EciesCryptoCore, Constants } from '@digitaldefiance/ecies-lib';
169
120
 
170
121
  const config = {
171
- curveName: ECIES.CURVE_NAME,
172
- primaryKeyDerivationPath: ECIES.PRIMARY_KEY_DERIVATION_PATH,
173
- mnemonicStrength: ECIES.MNEMONIC_STRENGTH,
174
- symmetricAlgorithm: ECIES.SYMMETRIC.ALGORITHM,
175
- symmetricKeyBits: ECIES.SYMMETRIC.KEY_BITS,
176
- symmetricKeyMode: ECIES.SYMMETRIC.MODE,
122
+ curveName: Constants.ECIES.CURVE_NAME,
123
+ primaryKeyDerivationPath: Constants.ECIES.PRIMARY_KEY_DERIVATION_PATH,
124
+ mnemonicStrength: Constants.ECIES.MNEMONIC_STRENGTH,
125
+ symmetricAlgorithm: Constants.ECIES.SYMMETRIC.ALGORITHM,
126
+ symmetricKeyBits: Constants.ECIES.SYMMETRIC.KEY_BITS,
127
+ symmetricKeyMode: Constants.ECIES.SYMMETRIC.MODE,
177
128
  };
178
129
 
179
130
  const multi = new EciesMultiRecipient(config);
@@ -184,71 +135,52 @@ const recipients = await Promise.all(
184
135
  [...Array(3)].map(async () => {
185
136
  const { privateKey, publicKey } = await core.generateEphemeralKeyPair();
186
137
  return {
187
- id: crypto.getRandomValues(new Uint8Array(ECIES.MULTIPLE.RECIPIENT_ID_SIZE)),
138
+ id: crypto.getRandomValues(new Uint8Array(Constants.ECIES.MULTIPLE.RECIPIENT_ID_SIZE)),
188
139
  privateKey,
189
140
  publicKey,
190
141
  };
191
142
  })
192
143
  );
193
144
 
194
- // Encrypt for all recipients
195
- const message = new TextEncoder().encode('Broadcast message');
145
+ // Encrypt for all
196
146
  const encrypted = await multi.encryptMultiple(
197
147
  recipients.map(({ id, publicKey }) => ({ id, publicKey })),
198
- message
199
- );
200
-
201
- // Build transport frame
202
- const frame = concatUint8Arrays(
203
- multi.buildHeader(encrypted),
204
- encrypted.encryptedMessage
148
+ new TextEncoder().encode('Broadcast message')
205
149
  );
206
150
 
207
151
  // Any recipient can decrypt
208
152
  const decrypted = await multi.decryptMultipleForRecipient(
209
- multi.parseMessage(frame),
153
+ multi.parseMessage(multi.buildHeader(encrypted) + encrypted.encryptedMessage),
210
154
  recipients[0].id,
211
155
  recipients[0].privateKey
212
156
  );
213
157
  ```
214
158
 
215
- ### File Encryption Service
159
+ ### EciesFileService
216
160
 
217
- Chunked file encryption for large files:
161
+ Chunked file encryption:
218
162
 
219
163
  ```typescript
220
164
  import { ECIESService, EciesFileService } from '@digitaldefiance/ecies-lib';
221
165
 
222
166
  const ecies = new ECIESService();
223
- const mnemonic = ecies.generateNewMnemonic();
224
- const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
225
-
226
- // Initialize file service with user's private key
167
+ const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(ecies.generateNewMnemonic());
227
168
  const fileService = new EciesFileService(ecies, privateKey);
228
169
 
229
- // Encrypt a file (browser File object)
230
- const file = fileInput.files[0];
170
+ // Encrypt file (1MB chunks)
231
171
  const encrypted = await fileService.encryptFile(file, publicKey);
232
172
 
233
- // Decrypt the file
173
+ // Decrypt file
234
174
  const decrypted = await fileService.decryptFile(encrypted);
235
175
 
236
- // Download encrypted file
176
+ // Download
237
177
  fileService.downloadEncryptedFile(encrypted, 'document.enc');
238
-
239
- // Download decrypted file
240
178
  fileService.downloadDecryptedFile(decrypted, 'document.pdf');
241
179
  ```
242
180
 
243
- The file service:
244
- - Chunks files into 1MB segments for memory efficiency
245
- - Encrypts each chunk independently
246
- - Includes metadata header with chunk information
247
- - Supports files of any size within browser memory limits
181
+ ### PasswordLoginService
248
182
 
249
- ### Password Login Service
250
-
251
- Complete password-based authentication system:
183
+ Password-based authentication:
252
184
 
253
185
  ```typescript
254
186
  import {
@@ -265,204 +197,168 @@ const ecies = new ECIESService();
265
197
  const pbkdf2 = new Pbkdf2Service(engine);
266
198
  const passwordLogin = new PasswordLoginService(ecies, pbkdf2, engine);
267
199
 
268
- // Setup password login (first time)
200
+ // Setup
269
201
  const mnemonic = ecies.generateNewMnemonic();
270
202
  const password = new SecureString('MySecurePassword123!');
271
-
272
- const wallet = await passwordLogin.setupPasswordLoginLocalStorageBundle(
203
+ await passwordLogin.setupPasswordLoginLocalStorageBundle(
273
204
  mnemonic,
274
205
  password,
275
206
  Pbkdf2ProfileEnum.BROWSER_PASSWORD
276
207
  );
277
208
 
278
- // Later: Login with password
279
- const { wallet: recoveredWallet, mnemonic: recoveredMnemonic } =
209
+ // Login
210
+ const { wallet, mnemonic: recovered } =
280
211
  await passwordLogin.getWalletAndMnemonicFromLocalStorageBundle(password);
281
212
 
282
- // Check if password login is configured
213
+ // Check setup
283
214
  if (PasswordLoginService.isPasswordLoginSetup()) {
284
- console.log('Password login is ready');
215
+ console.log('Ready');
285
216
  }
286
217
  ```
287
218
 
288
- ### PBKDF2 Service
219
+ ### Pbkdf2Service
289
220
 
290
- Flexible key derivation with configurable profiles:
221
+ Key derivation with profiles:
291
222
 
292
223
  ```typescript
293
- import {
294
- Pbkdf2Service,
295
- Pbkdf2ProfileEnum,
296
- IPbkdf2Config,
297
- getEciesI18nEngine,
298
- } from '@digitaldefiance/ecies-lib';
224
+ import { Pbkdf2Service, Pbkdf2ProfileEnum, getEciesI18nEngine } from '@digitaldefiance/ecies-lib';
299
225
 
300
- const engine = getEciesI18nEngine();
301
- const pbkdf2 = new Pbkdf2Service(engine);
226
+ const pbkdf2 = new Pbkdf2Service(getEciesI18nEngine());
302
227
 
303
- // Use predefined profiles
304
- const password = new TextEncoder().encode('password123');
228
+ // Use built-in profile
305
229
  const result = await pbkdf2.deriveKeyFromPasswordWithProfileAsync(
306
- password,
230
+ new TextEncoder().encode('password123'),
307
231
  Pbkdf2ProfileEnum.HIGH_SECURITY
308
232
  );
309
233
 
310
234
  console.log(result.hash); // Derived key
311
- console.log(result.salt); // Random salt used
312
- console.log(result.iterations); // Iteration count
235
+ console.log(result.salt); // Salt
236
+ console.log(result.iterations); // 5,000,000
313
237
 
314
238
  // Custom profiles
315
- const customProfiles: Record<string, IPbkdf2Config> = {
239
+ const custom = new Pbkdf2Service(getEciesI18nEngine(), {
316
240
  ULTRA_SECURE: {
317
241
  hashBytes: 64,
318
242
  saltBytes: 32,
319
243
  iterations: 5000000,
320
244
  algorithm: 'SHA-512',
321
245
  },
322
- FAST_DEV: {
323
- hashBytes: 32,
324
- saltBytes: 16,
325
- iterations: 1000,
326
- algorithm: 'SHA-256',
327
- },
328
- };
329
-
330
- const customPbkdf2 = new Pbkdf2Service(engine, customProfiles);
331
- const customResult = await customPbkdf2.deriveKeyFromPasswordWithProfileAsync(
332
- password,
333
- 'ULTRA_SECURE'
334
- );
246
+ });
335
247
  ```
336
248
 
337
249
  **Built-in Profiles:**
338
250
  - `BROWSER_PASSWORD`: 2M iterations, SHA-512, 32-byte hash
339
- - `HIGH_SECURITY`: 5M iterations, SHA-256, 64-byte hash
340
- - `TEST_FAST`: 1K iterations, SHA-512, 32-byte hash (testing only)
251
+ - `HIGH_SECURITY`: 5M iterations, SHA-256, 64-byte hash
252
+ - `TEST_FAST`: 1K iterations, SHA-512, 32-byte hash
341
253
 
342
- ## Runtime configuration registry
254
+ ## Runtime Configuration
343
255
 
344
- Many applications need different cryptographic trade-offs for different surfaces—e.g., a login form that prioritizes speed versus an administrative workflow that prefers extreme iteration counts. The library ships a registry that lets you register, retrieve, and extend immutable configuration profiles without mutating the global defaults.
256
+ Injectable configuration profiles via ConstantsRegistry:
345
257
 
346
- ```ts
258
+ ```typescript
347
259
  import {
348
- DefaultsRegistry,
260
+ ConstantsRegistry,
349
261
  registerRuntimeConfiguration,
350
262
  getRuntimeConfiguration,
351
- unregisterRuntimeConfiguration,
352
263
  ECIESService,
353
264
  Pbkdf2Service,
265
+ getEciesI18nEngine,
354
266
  } from '@digitaldefiance/ecies-lib';
355
267
 
356
- // 1. Register two named profiles
268
+ // Register profiles
357
269
  registerRuntimeConfiguration('security-first', {
358
- PBKDF2: {
359
- ITERATIONS_PER_SECOND: 3_000_000,
360
- },
270
+ PBKDF2: { ITERATIONS_PER_SECOND: 3_000_000 },
361
271
  });
362
272
 
363
- registerRuntimeConfiguration(
364
- 'performance-first',
365
- {
366
- PBKDF2: {
367
- ITERATIONS_PER_SECOND: 250_000,
368
- },
369
- },
370
- { baseKey: DefaultsRegistry.DEFAULT_KEY },
371
- );
372
-
373
- // 2. Spin up services that honor those profiles
374
- const secureDefaults = getRuntimeConfiguration('security-first');
375
- const secureEcies = new ECIESService(undefined, secureDefaults.ECIES);
376
- const securePbkdf2 = new Pbkdf2Service(engine, secureDefaults.PBKDF2_PROFILES, secureDefaults.ECIES, secureDefaults.PBKDF2);
377
-
378
- const perfDefaults = getRuntimeConfiguration('performance-first');
379
- const perfEcies = new ECIESService(undefined, perfDefaults.ECIES);
273
+ registerRuntimeConfiguration('performance-first', {
274
+ PBKDF2: { ITERATIONS_PER_SECOND: 250_000 },
275
+ });
380
276
 
381
- // 3. Optional: create throwaway profiles without registering them
382
- const temporaryDefaults = DefaultsRegistry.create({ BcryptRounds: 8 });
277
+ // Use profiles
278
+ const secureConfig = getRuntimeConfiguration('security-first');
279
+ const secureEcies = new ECIESService(undefined, secureConfig.ECIES);
280
+ const securePbkdf2 = new Pbkdf2Service(
281
+ getEciesI18nEngine(),
282
+ secureConfig.PBKDF2_PROFILES,
283
+ secureConfig.ECIES,
284
+ secureConfig.PBKDF2
285
+ );
383
286
 
384
- // 4. Clean up when a profile is no longer needed
287
+ // Cleanup
385
288
  unregisterRuntimeConfiguration('performance-first');
386
289
  ```
387
290
 
388
- ### Available helpers
291
+ **Registry API:**
292
+ - `ConstantsRegistry.get(key)` – Retrieve configuration
293
+ - `ConstantsRegistry.register(key, config)` – Register new profile
294
+ - `ConstantsRegistry.create(overrides)` – Create without registering
295
+ - `ConstantsRegistry.listKeys()` – List all keys
296
+ - `ConstantsRegistry.has(key)` – Check existence
297
+ - `ConstantsRegistry.unregister(key)` – Remove profile
298
+ - `ConstantsRegistry.clear()` – Reset to defaults
389
299
 
390
- All helpers live in `src/defaults.ts` and are re-exported from the package entry point:
300
+ **Exports:**
301
+ - `Constants` – Frozen default configuration
302
+ - `createRuntimeConfiguration(overrides, base?)` – Deep merge and validate
303
+ - `PASSWORD_REGEX`, `MNEMONIC_REGEX` – Validation patterns
391
304
 
392
- - **`Defaults`** – immutable snapshot of the baked-in configuration. It exposes `Defaults.ECIES`, `Defaults.PBKDF2`, regexes, and other primitives used across the library.
393
- - **`createRuntimeConfiguration(overrides, base?)`** – clones a base configuration, applies partial overrides (deep merge), validates invariants, and returns a deeply frozen instance without touching the registry.
394
- - **`DefaultsRegistry`** – registry API with `get`, `register`, `create`, `listKeys`, `has`, `unregister`, and `clear`. Registered profiles are validated and frozen, so consumers can safely share references.
395
- - **Convenience functions** – `getRuntimeConfiguration`, `registerRuntimeConfiguration`, `unregisterRuntimeConfiguration`, and `clearRuntimeConfigurations` wrap the registry for common flows.
396
- - **Regex exports** – `PASSWORD_REGEX` and `MNEMONIC_REGEX` are exported alongside the defaults for consumers that need the raw patterns.
305
+ ## Secure Memory
397
306
 
398
- Every configuration produced by these helpers is deeply frozen and validated so low-level invariants (public key length, recipient counts, checksum parameters, etc.) stay consistent. Use `clearRuntimeConfigurations()` in tests to reset back to the default profile.
399
-
400
- > **Tip:** Services such as `ECIESService`, `Pbkdf2Service`, `AESGCMService`, and `PasswordLoginService` accept their respective configuration slices as constructor parameters. Wire them up with values from `getRuntimeConfiguration(key)` to scope behavior per feature area or tenant.
401
-
402
- ### Secure Memory Primitives
403
-
404
- Protect sensitive data in memory:
307
+ XOR-obfuscated storage with checksums:
405
308
 
406
309
  ```typescript
407
310
  import { SecureString, SecureBuffer } from '@digitaldefiance/ecies-lib';
408
311
 
409
- // SecureString - for passwords and mnemonics
312
+ // SecureString for passwords/mnemonics
410
313
  const password = new SecureString('MyPassword123');
411
- console.log(password.value); // Access the value
412
- console.log(password.valueAsHexString); // As hex
413
- console.log(password.length); // Get length
314
+ console.log(password.value); // Access value
315
+ console.log(password.valueAsHexString); // Hex format
316
+ console.log(password.length); // Length
414
317
  password.dispose(); // Zero memory
415
318
 
416
- // SecureBuffer - for binary secrets
417
- const privateKey = new Uint8Array(32);
418
- const secureKey = new SecureBuffer(privateKey);
419
- console.log(secureKey.value); // Access as Uint8Array
420
- console.log(secureKey.valueAsString); // As string
421
- console.log(secureKey.valueAsBase64String); // As base64
422
- secureKey.dispose(); // Zero memory
423
-
424
- // Both types:
425
- // - XOR obfuscate data in memory
426
- // - Include checksums for integrity
427
- // - Auto-detect disposal attempts
428
- // - Provide stack traces for debugging
319
+ // SecureBuffer for binary secrets
320
+ const key = new SecureBuffer(new Uint8Array(32));
321
+ console.log(key.value); // Uint8Array
322
+ console.log(key.valueAsString); // String
323
+ console.log(key.valueAsBase64String); // Base64
324
+ key.dispose(); // Zero memory
325
+
326
+ // Features:
327
+ // - XOR obfuscation in memory
328
+ // - Checksum validation
329
+ // - Disposal detection
330
+ // - Stack traces for debugging
429
331
  ```
430
332
 
431
- ### Value Objects
333
+ ## Value Objects
432
334
 
433
- Type-safe wrappers for common data:
335
+ Type-safe wrappers:
434
336
 
435
337
  ```typescript
436
338
  import { EmailString, GuidV4 } from '@digitaldefiance/ecies-lib';
437
339
 
438
- // Validated email addresses
340
+ // Validated emails
439
341
  const email = new EmailString('user@example.com');
440
- console.log(email.toString());
441
- console.log(email.length);
442
-
443
- // Will throw on invalid email:
444
342
  // new EmailString('invalid'); // throws InvalidEmailError
445
343
 
446
- // Type-safe GUIDs with multiple formats
344
+ // GUIDs with multiple formats
447
345
  const guid = GuidV4.new();
448
346
  console.log(guid.asFullHexGuid); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
449
347
  console.log(guid.asShortHexGuid); // "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
450
- console.log(guid.asBase64Guid); // Base64 encoded
451
- console.log(guid.asBigIntGuid); // As BigInt
348
+ console.log(guid.asBase64Guid); // Base64
349
+ console.log(guid.asBigIntGuid); // BigInt
452
350
 
453
- // Create from various formats
351
+ // Create from formats
454
352
  const fromHex = new GuidV4('550e8400-e29b-41d4-a716-446655440000');
455
353
  const fromBase64 = new GuidV4('VQ6EAOKbQdSnFkRmVUQAAA==');
456
354
 
457
- // Compare GUIDs
458
- if (guid.equals(fromHex)) {
459
- console.log('GUIDs match');
460
- }
355
+ // Compare
356
+ if (guid.equals(fromHex)) { /* ... */ }
461
357
  ```
462
358
 
463
359
  ## Error Handling
464
360
 
465
- Comprehensive typed error system with internationalization:
361
+ Typed errors with i18n (8 languages):
466
362
 
467
363
  ```typescript
468
364
  import {
@@ -470,235 +366,127 @@ import {
470
366
  ECIESErrorTypeEnum,
471
367
  MemberError,
472
368
  MemberErrorType,
473
- GuidError,
474
- GuidErrorType,
475
369
  Pbkdf2Error,
476
370
  Pbkdf2ErrorType,
477
371
  } from '@digitaldefiance/ecies-lib';
478
372
 
479
- // ECIES errors
480
373
  try {
481
374
  await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, tamperedData);
482
375
  } catch (error) {
483
376
  if (error instanceof ECIESError) {
484
377
  switch (error.type) {
485
378
  case ECIESErrorTypeEnum.DecryptionFailed:
486
- console.error('Decryption failed - data may be corrupted');
379
+ console.error('Decryption failed');
487
380
  break;
488
381
  case ECIESErrorTypeEnum.InvalidEncryptionType:
489
- console.error('Invalid encryption type in header');
490
- break;
491
- case ECIESErrorTypeEnum.InvalidPublicKey:
492
- console.error('Public key format is invalid');
382
+ console.error('Invalid encryption type');
493
383
  break;
494
384
  }
495
385
  }
496
386
  }
497
387
 
498
- // Member errors
499
- try {
500
- const member = Member.newMember(ecies, MemberType.User, '', email);
501
- } catch (error) {
502
- if (error instanceof MemberError) {
503
- if (error.type === MemberErrorType.MissingMemberName) {
504
- console.error('Member name is required');
505
- }
506
- }
507
- }
508
-
509
- // All errors include:
510
- // - Typed error codes (enums)
511
- // - Localized messages (6 languages)
512
- // - Stack traces
513
- // - Optional context data
388
+ // Error categories:
389
+ // - ECIESError: Encryption/decryption
390
+ // - MemberError: Member operations
391
+ // - GuidError: GUID validation
392
+ // - Pbkdf2Error: Key derivation
393
+ // - LengthError: Data length
394
+ // - SecureStorageError: Memory operations
395
+ // - InvalidEmailError: Email validation
514
396
  ```
515
397
 
516
- **Error Categories:**
517
- - `ECIESError` - Encryption/decryption failures
518
- - `MemberError` - Member operations
519
- - `GuidError` - GUID validation
520
- - `Pbkdf2Error` - Key derivation
521
- - `LengthError` - Data length validation
522
- - `SecureStorageError` - Secure memory operations
523
- - `InvalidEmailError` - Email validation
524
-
525
398
  ## Architecture
526
399
 
527
- ### Project Structure
400
+ ### Structure
528
401
 
529
402
  ```
530
- packages/digitaldefiance-ecies-lib/
531
- ├── src/
532
- │ ├── services/
533
- │ │ ├── ecies/ # ECIES implementation
534
- │ │ ├── service.ts # Main ECIESService
535
- │ │ ├── crypto-core.ts # Core crypto operations
536
- │ │ ├── multi-recipient.ts # Multi-recipient encryption
537
- │ │ ├── single-recipient.ts # Single recipient encryption
538
- │ │ │ ├── file.ts # File encryption service
539
- │ │ └── signature.ts # ECDSA signatures
540
- ├── aes-gcm.ts # AES-GCM encryption
541
- ├── pbkdf2.ts # PBKDF2 key derivation
542
- │ ├── password-login.ts # Password authentication
543
- │ │ └── xor.ts # XOR obfuscation
544
- ├── enumerations/ # Type-safe enums
545
- ├── errors/ # Typed error classes
546
- ├── interfaces/ # TypeScript interfaces
547
- ├── types/ # Type definitions
548
- ├── constants.ts # Library constants
549
- ├── defaults.ts # Default configurations
550
- ├── member.ts # Member abstraction
551
- ├── secure-string.ts # Secure string storage
552
- ├── secure-buffer.ts # Secure buffer storage
553
- ├── email-string.ts # Validated email
554
- ├── guid.ts # GUID utilities
555
- │ ├── utils.ts # Helper functions
556
- │ ├── i18n-setup.ts # Internationalization
557
- │ └── index.ts # Public API
558
- ├── tests/
559
- │ ├── services/ # Service tests
560
- │ ├── *.spec.ts # Unit tests
561
- │ ├── *.e2e.spec.ts # Integration tests
562
- │ └── support/ # Test utilities
563
- └── package.json
403
+ src/
404
+ ├── services/
405
+ │ ├── ecies/
406
+ │ │ ├── service.ts # ECIESService
407
+ │ │ ├── crypto-core.ts # EciesCryptoCore
408
+ │ │ ├── multi-recipient.ts # EciesMultiRecipient
409
+ │ │ ├── single-recipient.ts # EciesSingleRecipient
410
+ │ │ ├── file.ts # EciesFileService
411
+ │ │ └── signature.ts # EciesSignature
412
+ ├── aes-gcm.ts # AESGCMService
413
+ │ ├── pbkdf2.ts # Pbkdf2Service
414
+ │ ├── password-login.ts # PasswordLoginService
415
+ └── xor.ts # XorService
416
+ ├── enumerations/ # Type-safe enums
417
+ ├── errors/ # Typed error classes
418
+ ├── interfaces/ # TypeScript interfaces
419
+ ├── types/ # Type definitions
420
+ ├── constants.ts # Constants & ConstantsRegistry
421
+ ├── member.ts # Member class
422
+ ├── secure-string.ts # SecureString
423
+ ├── secure-buffer.ts # SecureBuffer
424
+ ├── email-string.ts # EmailString
425
+ ├── guid.ts # GuidV4
426
+ ├── utils.ts # Utilities
427
+ ├── i18n-setup.ts # i18n configuration
428
+ └── index.ts # Public API
429
+
430
+ tests/ # 32 test files, 389+ specs
564
431
  ```
565
432
 
566
433
  ### Key Concepts
567
434
 
568
435
  **Encryption Modes:**
569
- - **Simple**: Minimal overhead, no length prefix (98 bytes overhead)
570
- - **Single**: Includes 8-byte length prefix (106 bytes overhead)
571
- - **Multiple**: Shared symmetric key encrypted for each recipient
436
+ - Simple: 98-byte overhead (type + pubkey + IV + tag)
437
+ - Single: 106-byte overhead (Simple + 8-byte length)
438
+ - Multiple: Shared symmetric key per recipient
572
439
 
573
440
  **Key Derivation:**
574
- - BIP39 mnemonics → BIP32 HD keys → secp256k1 key pairs
575
- - Deterministic key generation from mnemonic phrases
576
- - Support for custom derivation paths
577
-
578
- **Security Features:**
579
- - AES-GCM authenticated encryption (256-bit keys)
580
- - ECDH key agreement on secp256k1 curve
581
- - PBKDF2 password hashing with configurable iterations
582
- - Memory-safe storage with automatic zeroing
441
+ - BIP39 mnemonic → BIP32 HD wallet → secp256k1 keypair
442
+ - Deterministic generation
443
+ - Custom derivation paths supported
444
+
445
+ **Security:**
446
+ - AES-256-GCM authenticated encryption
447
+ - ECDH key agreement (secp256k1)
448
+ - PBKDF2 with configurable iterations
449
+ - Memory-safe storage with auto-zeroing
583
450
  - XOR obfuscation for in-memory secrets
584
451
 
585
- ## Quality gates
586
-
587
- The project ships with mandatory linting, formatting, and testing commands:
588
-
589
- ```bash
590
- yarn lint # ESLint across src/**/*.ts
591
- yarn prettier:check # Enforce formatting
592
- yarn test # Jest unit + e2e suites
593
- yarn build # Compile TypeScript into dist/
594
- ```
595
-
596
- Continuous integration mirrors these gates, and the repository currently passes 389 Jest specs (unit + e2e).
597
-
598
- ## Browser vs. Node tips
599
-
600
- - **Node**: Node 18+ exposes `globalThis.crypto`. If you target older runtimes, polyfill before importing the library:
601
-
602
- ```ts
603
- import { webcrypto } from 'crypto';
604
- globalThis.crypto = webcrypto as unknown as Crypto;
605
- ```
606
-
607
- - **Browser bundlers**: the package ships TypeScript sources; rely on your bundler (Vite, Webpack, Next.js) to tree-shake unused exports. All external dependencies are ESM-friendly.
608
- - **Memory hygiene**: many helpers (e.g., `SecureBuffer`) provide `.dispose()` to zero sensitive data. Call them when you’re done.
609
-
610
- ## API Reference
611
-
612
- ### Main Exports
613
-
614
- ```typescript
615
- // Services
616
- export { ECIESService } from './services/ecies/service';
617
- export { EciesCryptoCore } from './services/ecies/crypto-core';
618
- export { EciesMultiRecipient } from './services/ecies/multi-recipient';
619
- export { EciesFileService } from './services/ecies/file';
620
- export { AESGCMService } from './services/aes-gcm';
621
- export { Pbkdf2Service } from './services/pbkdf2';
622
- export { PasswordLoginService } from './services/password-login';
623
- export { XorService } from './services/xor';
624
-
625
- // Member System
626
- export { Member } from './member';
627
- export { MemberType } from './enumerations/member-type';
628
-
629
- // Secure Primitives
630
- export { SecureString } from './secure-string';
631
- export { SecureBuffer } from './secure-buffer';
632
- export { EmailString } from './email-string';
633
- export { GuidV4 } from './guid';
634
-
635
- // Configuration
636
- export { Defaults, ECIES, PBKDF2, CHECKSUM } from './defaults';
637
- export { DefaultsRegistry } from './defaults';
638
- export { Constants } from './constants';
639
-
640
- // Enumerations
641
- export { EciesEncryptionTypeEnum } from './enumerations/ecies-encryption-type';
642
- export { Pbkdf2ProfileEnum } from './enumerations/pbkdf2-profile';
643
- export { MemberErrorType } from './enumerations/member-error-type';
644
- export { ECIESErrorTypeEnum } from './enumerations/ecies-error-type';
645
-
646
- // Errors
647
- export { ECIESError } from './errors/ecies';
648
- export { MemberError } from './errors/member';
649
- export { GuidError } from './errors/guid';
650
- export { Pbkdf2Error } from './errors/pbkdf2';
651
-
652
- // Utilities
653
- export * from './utils';
654
-
655
- // Internationalization
656
- export { getEciesI18nEngine } from './i18n-setup';
657
- ```
658
-
659
452
  ## Development
660
453
 
661
- ### Building
454
+ ### Commands
662
455
 
663
456
  ```bash
664
- yarn install # Install dependencies
665
- yarn build # Compile TypeScript
666
- yarn test # Run test suite
667
- yarn lint # Check code style
668
- yarn format # Fix formatting and linting
457
+ yarn install # Install dependencies
458
+ yarn build # Compile TypeScript
459
+ yarn test # Run all tests (389+ specs)
460
+ yarn test:stream # Stream test output
461
+ yarn lint # ESLint check
462
+ yarn lint:fix # Auto-fix issues
463
+ yarn prettier:check # Format check
464
+ yarn prettier:fix # Auto-format
465
+ yarn format # Fix all (prettier + lint)
669
466
  ```
670
467
 
671
468
  ### Testing
672
469
 
673
- ```bash
674
- yarn test # Run all tests
675
- yarn test:stream # Stream output
676
- yarn test --watch # Watch mode
677
- yarn test file.spec.ts # Run specific test
678
- ```
679
-
680
- The library includes 380+ test specifications covering:
681
- - Unit tests for all services and utilities
682
- - Integration tests for encryption workflows
470
+ 32 test files covering:
471
+ - Unit tests for all services
472
+ - Integration tests for workflows
683
473
  - E2E tests for password login and file encryption
684
- - Cross-platform compatibility tests
474
+ - Cross-platform compatibility
685
475
  - Error handling and edge cases
686
476
 
687
- ### Code Quality
477
+ ### Quality Gates
688
478
 
689
- ```bash
690
- yarn lint # ESLint check
691
- yarn lint:fix # Auto-fix issues
692
- yarn prettier:check # Format check
693
- yarn prettier:fix # Auto-format
694
- yarn format # Fix all issues
695
- ```
479
+ CI enforces:
480
+ - ESLint (no errors)
481
+ - Prettier formatting
482
+ - 389+ Jest specs passing
483
+ - TypeScript compilation
696
484
 
697
- ## Platform-Specific Notes
485
+ ## Platform Notes
698
486
 
699
487
  ### Node.js
700
488
 
701
- Node.js 18+ includes Web Crypto API by default. For older versions:
489
+ Node 18+ includes Web Crypto API. For older versions:
702
490
 
703
491
  ```typescript
704
492
  import { webcrypto } from 'crypto';
@@ -707,17 +495,16 @@ globalThis.crypto = webcrypto as unknown as Crypto;
707
495
 
708
496
  ### Browser
709
497
 
710
- The library works in all modern browsers:
711
- - Uses Web Crypto API for cryptographic operations
712
- - No polyfills required for modern browsers
713
- - Tree-shakeable with modern bundlers (Vite, Webpack, Rollup)
714
- - All dependencies are ESM-compatible
498
+ Works in all modern browsers:
499
+ - Web Crypto API for cryptography
500
+ - No polyfills needed
501
+ - Tree-shakeable with Vite/Webpack/Rollup
502
+ - ESM-compatible dependencies
715
503
 
716
- ### Bundler Configuration
504
+ ### Bundler Config
717
505
 
718
506
  **Vite:**
719
507
  ```javascript
720
- // vite.config.js
721
508
  export default {
722
509
  optimizeDeps: {
723
510
  include: ['@digitaldefiance/ecies-lib']
@@ -727,7 +514,6 @@ export default {
727
514
 
728
515
  **Webpack:**
729
516
  ```javascript
730
- // webpack.config.js
731
517
  module.exports = {
732
518
  resolve: {
733
519
  fallback: {
@@ -740,7 +526,7 @@ module.exports = {
740
526
 
741
527
  ### Memory Management
742
528
 
743
- Always dispose of sensitive data:
529
+ Always dispose sensitive data:
744
530
 
745
531
  ```typescript
746
532
  const password = new SecureString('secret');
@@ -749,13 +535,43 @@ try {
749
535
  } finally {
750
536
  password.dispose(); // Zeros memory
751
537
  }
538
+ ```
752
539
 
753
- const privateKey = new SecureBuffer(keyBytes);
754
- try {
755
- // Use key
756
- } finally {
757
- privateKey.dispose(); // Zeros memory
758
- }
540
+ ## API Reference
541
+
542
+ ### Main Exports
543
+
544
+ ```typescript
545
+ // Services
546
+ export { ECIESService, EciesCryptoCore, EciesMultiRecipient, EciesFileService };
547
+ export { AESGCMService, Pbkdf2Service, PasswordLoginService, XorService };
548
+
549
+ // Member System
550
+ export { Member, MemberType };
551
+
552
+ // Secure Primitives
553
+ export { SecureString, SecureBuffer, EmailString, GuidV4 };
554
+
555
+ // Configuration
556
+ export { Constants, ConstantsRegistry, CHECKSUM, ECIES, PBKDF2 };
557
+ export { createRuntimeConfiguration, getRuntimeConfiguration };
558
+ export { registerRuntimeConfiguration, unregisterRuntimeConfiguration };
559
+ export { PASSWORD_REGEX, MNEMONIC_REGEX };
560
+
561
+ // Enumerations
562
+ export { EciesEncryptionTypeEnum, Pbkdf2ProfileEnum };
563
+ export { MemberErrorType, ECIESErrorTypeEnum };
564
+
565
+ // Errors
566
+ export { ECIESError, MemberError, GuidError, Pbkdf2Error };
567
+ export { LengthError, SecureStorageError, InvalidEmailError };
568
+
569
+ // Utilities
570
+ export { concatUint8Arrays, uint8ArrayToHex, hexToUint8Array };
571
+ export { uint8ArrayToBase64, base64ToUint8Array };
572
+
573
+ // i18n
574
+ export { getEciesI18nEngine, EciesI18nEngine };
759
575
  ```
760
576
 
761
577
  ## Contributing
@@ -776,12 +592,23 @@ If you discover a vulnerability, please **do not** open a public issue. Email <s
776
592
 
777
593
  MIT © Digital Defiance
778
594
 
779
- ## Repository
595
+ ## Links
780
596
 
781
- [https://github.com/Digital-Defiance/ecies-lib](https://github.com/Digital-Defiance/ecies-lib)
597
+ - **Repository:** https://github.com/Digital-Defiance/ecies-lib
598
+ - **npm:** https://www.npmjs.com/package/@digitaldefiance/ecies-lib
599
+ - **Companion:** @digitaldefiance/node-ecies-lib (binary compatible)
782
600
 
783
601
  ## ChangeLog
784
602
 
603
+ ### v1.1.15
604
+
605
+ - CommonJS
606
+ - Update i18n
607
+
608
+ ### v1.1.14
609
+
610
+ - Update readme
611
+
785
612
  ### v1.1.13
786
613
 
787
614
  - Upgrade i18n to plugin engine