@digitaldefiance/ecies-lib 1.0.24 → 1.0.26-b

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 (48) hide show
  1. package/README.md +71 -1
  2. package/dist/constants.d.ts +0 -13
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +3 -164
  5. package/dist/constants.js.map +1 -1
  6. package/dist/defaults.d.ts +37 -0
  7. package/dist/defaults.d.ts.map +1 -0
  8. package/dist/defaults.js +323 -0
  9. package/dist/defaults.js.map +1 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/interfaces/constants.d.ts +2 -29
  15. package/dist/interfaces/constants.d.ts.map +1 -1
  16. package/dist/interfaces/defaults.d.ts +35 -0
  17. package/dist/interfaces/defaults.d.ts.map +1 -0
  18. package/dist/interfaces/defaults.js +2 -0
  19. package/dist/interfaces/defaults.js.map +1 -0
  20. package/dist/interfaces/index.d.ts +1 -0
  21. package/dist/interfaces/index.d.ts.map +1 -1
  22. package/dist/interfaces/index.js +1 -0
  23. package/dist/interfaces/index.js.map +1 -1
  24. package/dist/member.js +1 -1
  25. package/dist/member.js.map +1 -1
  26. package/dist/regexes.d.ts +3 -0
  27. package/dist/regexes.d.ts.map +1 -0
  28. package/dist/regexes.js +3 -0
  29. package/dist/regexes.js.map +1 -0
  30. package/dist/services/aes-gcm.js +1 -1
  31. package/dist/services/aes-gcm.js.map +1 -1
  32. package/dist/services/ecies/crypto-core.js +1 -1
  33. package/dist/services/ecies/crypto-core.js.map +1 -1
  34. package/dist/services/ecies/multi-recipient.js +1 -1
  35. package/dist/services/ecies/multi-recipient.js.map +1 -1
  36. package/dist/services/ecies/service.js +6 -6
  37. package/dist/services/ecies/service.js.map +1 -1
  38. package/dist/services/ecies/single-recipient.js +1 -1
  39. package/dist/services/ecies/single-recipient.js.map +1 -1
  40. package/dist/services/password-login.js +1 -1
  41. package/dist/services/password-login.js.map +1 -1
  42. package/dist/services/pbkdf2.js +1 -1
  43. package/dist/services/pbkdf2.js.map +1 -1
  44. package/dist/types/deep-partial.d.ts +4 -0
  45. package/dist/types/deep-partial.d.ts.map +1 -0
  46. package/dist/types/deep-partial.js +2 -0
  47. package/dist/types/deep-partial.js.map +1 -0
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -207,6 +207,66 @@ const result = await customPbkdf2Service.deriveKeyFromPasswordWithProfileAsync(
207
207
 
208
208
  This design allows for dependency injection of PBKDF2 profiles while maintaining backward compatibility with the default configurations.
209
209
 
210
+ ## Runtime configuration registry
211
+
212
+ 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.
213
+
214
+ ```ts
215
+ import {
216
+ DefaultsRegistry,
217
+ registerRuntimeConfiguration,
218
+ getRuntimeConfiguration,
219
+ unregisterRuntimeConfiguration,
220
+ ECIESService,
221
+ Pbkdf2Service,
222
+ } from '@digitaldefiance/ecies-lib';
223
+
224
+ // 1. Register two named profiles
225
+ registerRuntimeConfiguration('security-first', {
226
+ PBKDF2: {
227
+ ITERATIONS_PER_SECOND: 3_000_000,
228
+ },
229
+ });
230
+
231
+ registerRuntimeConfiguration(
232
+ 'performance-first',
233
+ {
234
+ PBKDF2: {
235
+ ITERATIONS_PER_SECOND: 250_000,
236
+ },
237
+ },
238
+ { baseKey: DefaultsRegistry.DEFAULT_KEY },
239
+ );
240
+
241
+ // 2. Spin up services that honor those profiles
242
+ const secureDefaults = getRuntimeConfiguration('security-first');
243
+ const secureEcies = new ECIESService(undefined, secureDefaults.ECIES);
244
+ const securePbkdf2 = new Pbkdf2Service(engine, secureDefaults.PBKDF2_PROFILES, secureDefaults.ECIES, secureDefaults.PBKDF2);
245
+
246
+ const perfDefaults = getRuntimeConfiguration('performance-first');
247
+ const perfEcies = new ECIESService(undefined, perfDefaults.ECIES);
248
+
249
+ // 3. Optional: create throwaway profiles without registering them
250
+ const temporaryDefaults = DefaultsRegistry.create({ BcryptRounds: 8 });
251
+
252
+ // 4. Clean up when a profile is no longer needed
253
+ unregisterRuntimeConfiguration('performance-first');
254
+ ```
255
+
256
+ ### Available helpers
257
+
258
+ All helpers live in `src/defaults.ts` and are re-exported from the package entry point:
259
+
260
+ - **`Defaults`** – immutable snapshot of the baked-in configuration. It exposes `Defaults.ECIES`, `Defaults.PBKDF2`, regexes, and other primitives used across the library.
261
+ - **`createRuntimeConfiguration(overrides, base?)`** – clones a base configuration, applies partial overrides (deep merge), validates invariants, and returns a deeply frozen instance without touching the registry.
262
+ - **`DefaultsRegistry`** – registry API with `get`, `register`, `create`, `listKeys`, `has`, `unregister`, and `clear`. Registered profiles are validated and frozen, so consumers can safely share references.
263
+ - **Convenience functions** – `getRuntimeConfiguration`, `registerRuntimeConfiguration`, `unregisterRuntimeConfiguration`, and `clearRuntimeConfigurations` wrap the registry for common flows.
264
+ - **Regex exports** – `PASSWORD_REGEX` and `MNEMONIC_REGEX` are exported alongside the defaults for consumers that need the raw patterns.
265
+
266
+ 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.
267
+
268
+ > **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.
269
+
210
270
  ## Secure primitives & value objects
211
271
 
212
272
  - `SecureString` / `SecureBuffer`: auto-zero, opt-in disposal, and helper methods for dealing with sensitive material.
@@ -235,7 +295,7 @@ try {
235
295
 
236
296
  ## Project structure
237
297
 
238
- ```
298
+ ```text
239
299
  packages/digitaldefiance-ecies-lib/
240
300
  ├─ src/
241
301
  │ ├─ services/ # ECIES, AES-GCM, PBKDF2, password login
@@ -301,6 +361,16 @@ MIT © Digital Defiance
301
361
 
302
362
  ## ChangeLog
303
363
 
364
+ ### v1.0.26: Quick bump, export IConstants
365
+
366
+ - Sun Oct 12 2025 21:11:00 GMT-0700 (Pacific Daylight Time)
367
+ - export IConstants
368
+
369
+ ### v1.0.25: Rework configuration system again
370
+
371
+ - Sun Oct 12 2025 21:02:00 GMT-0700 (Pacific Daylight Time)
372
+ - Rework various services to support user-provided configurations
373
+
304
374
  ### v1.0.24: Rework pbdkf2 services, and other things and provide ways of overriding constants
305
375
 
306
376
  - Sun Oct 12 2025 18:25:00 GMT-0700 (Pacific Daylight Time)
@@ -1,8 +1,4 @@
1
- import { IChecksumConsts } from './interfaces';
2
1
  import { IConstants } from './interfaces/constants';
3
- import { IECIESConstants } from './interfaces/ecies-consts';
4
- import { IPBkdf2Consts } from './interfaces/pbkdf2-consts';
5
- import { Pbkdf2Profiles } from './pbkdf2-profiles';
6
2
  export declare const UINT8_SIZE: number;
7
3
  export declare const UINT16_SIZE: number;
8
4
  export declare const UINT16_MAX: number;
@@ -14,14 +10,5 @@ export declare const UINT64_MAX: bigint;
14
10
  * Standard size of a UUID v4 in bytes.
15
11
  */
16
12
  export declare const GUID_SIZE: number;
17
- /**
18
- * Constants for checksum operations
19
- * These values are critical for data integrity and MUST NOT be changed
20
- * in an already established system as it will break all existing checksums.
21
- */
22
- export declare const CHECKSUM: IChecksumConsts;
23
- export declare const PBKDF2: IPBkdf2Consts;
24
- export declare const PBKDF2_PROFILES: Pbkdf2Profiles;
25
- export declare const ECIES: IECIESConstants;
26
13
  export declare const Constants: IConstants;
27
14
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE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,SAAS,EAAE,UAiBb,CAAC"}
package/dist/constants.js CHANGED
@@ -1,8 +1,5 @@
1
1
  import { ObjectId } from 'bson';
2
- import { ECIESErrorTypeEnum } from './enumerations';
3
- import { Pbkdf2ProfileEnum } from './enumerations/pbkdf2-profile';
4
- import { ECIESError } from './errors/ecies';
5
- import { getCompatibleEciesEngine } from './i18n-setup';
2
+ import { MNEMONIC_REGEX, PASSWORD_REGEX } from './regexes';
6
3
  export const UINT8_SIZE = 1;
7
4
  export const UINT16_SIZE = 2;
8
5
  export const UINT16_MAX = 65535;
@@ -14,122 +11,6 @@ export const UINT64_MAX = 18446744073709551615n;
14
11
  * Standard size of a UUID v4 in bytes.
15
12
  */
16
13
  export const GUID_SIZE = 16;
17
- /**
18
- * Constants for checksum operations
19
- * These values are critical for data integrity and MUST NOT be changed
20
- * in an already established system as it will break all existing checksums.
21
- */
22
- export const CHECKSUM = Object.freeze({
23
- /** Default hash bits for SHA3 */
24
- SHA3_DEFAULT_HASH_BITS: 512,
25
- /** Length of a SHA3 checksum buffer in bytes */
26
- SHA3_BUFFER_LENGTH: 64,
27
- /** algorithm to use for checksum */
28
- ALGORITHM: 'sha3-512',
29
- /** encoding to use for checksum */
30
- ENCODING: 'hex',
31
- });
32
- export const PBKDF2 = Object.freeze({
33
- ALGORITHM: 'SHA-256',
34
- SALT_BYTES: 32,
35
- /**
36
- * Number of pbkdf2 iterations per second when hashing a password.
37
- * This is the high-security default for user login operations.
38
- */
39
- ITERATIONS_PER_SECOND: 1304000,
40
- });
41
- export const PBKDF2_PROFILES = Object.freeze({
42
- [Pbkdf2ProfileEnum.BROWSER_PASSWORD]: Object.freeze({
43
- hashBytes: 32,
44
- saltBytes: 64,
45
- iterations: 2000000,
46
- algorithm: 'SHA-512',
47
- }),
48
- [Pbkdf2ProfileEnum.HIGH_SECURITY]: Object.freeze({
49
- hashBytes: 64,
50
- saltBytes: 32,
51
- iterations: 5000000,
52
- algorithm: 'SHA-256',
53
- }),
54
- [Pbkdf2ProfileEnum.TEST_FAST]: Object.freeze({
55
- hashBytes: 32,
56
- saltBytes: 64,
57
- iterations: 1000,
58
- algorithm: 'SHA-512',
59
- }),
60
- });
61
- const ECIES_SYMMETRIC_KEY_SIZE = 32;
62
- const ECIES_PUBLIC_KEY_LENGTH = 65;
63
- const ECIES_RAW_PUBLIC_KEY_LENGTH = 64;
64
- const ECIES_IV_SIZE = 16;
65
- const ECIES_AUTH_TAG_SIZE = 16;
66
- const ECIES_MULTIPLE_RECIPIENT_ID_SIZE = 16;
67
- // Define the expected value for SIMPLE.FIXED_OVERHEAD_SIZE
68
- const expectedSimpleOverhead = UINT8_SIZE + ECIES_PUBLIC_KEY_LENGTH + ECIES_IV_SIZE + ECIES_AUTH_TAG_SIZE;
69
- // Define the expected value for MULTIPLE.FIXED_OVERHEAD_SIZE
70
- // Includes: type (1) + IV (16) + auth tag (16) = 33 (no CRC, AES-GCM provides authentication)
71
- const expectedMultipleOverhead = UINT8_SIZE + ECIES_IV_SIZE + ECIES_AUTH_TAG_SIZE;
72
- // Update ENCRYPTED_KEY_SIZE to match Simple encryption (no CRC)
73
- const expectedMultipleEncryptedKeySize = ECIES_PUBLIC_KEY_LENGTH +
74
- ECIES_IV_SIZE +
75
- ECIES_AUTH_TAG_SIZE +
76
- ECIES_SYMMETRIC_KEY_SIZE;
77
- export const ECIES = Object.freeze({
78
- /** The elliptic curve to use for all ECDSA operations */
79
- CURVE_NAME: 'secp256k1',
80
- /** The primary key derivation path for HD wallets */
81
- PRIMARY_KEY_DERIVATION_PATH: "m/44'/60'/0'/0/0",
82
- SYMMETRIC_ALGORITHM_CONFIGURATION: 'aes-256-gcm',
83
- /** Length of ECDSA signatures in bytes */
84
- SIGNATURE_SIZE: 64,
85
- /** Length of raw public keys in bytes (without 0x04 prefix) */
86
- RAW_PUBLIC_KEY_LENGTH: ECIES_RAW_PUBLIC_KEY_LENGTH,
87
- /** Length of public keys in bytes (with 0x04 prefix) */
88
- PUBLIC_KEY_LENGTH: ECIES_PUBLIC_KEY_LENGTH,
89
- PUBLIC_KEY_MAGIC: 0x04,
90
- /** Mnemonic strength in bits. This will produce a 32-bit key for ECDSA */
91
- MNEMONIC_STRENGTH: 256,
92
- /** Symmetric encryption algorithm configuration */
93
- SYMMETRIC: Object.freeze({
94
- ALGORITHM: 'aes',
95
- MODE: 'gcm',
96
- KEY_BITS: 256,
97
- KEY_SIZE: ECIES_SYMMETRIC_KEY_SIZE, // KEY_BITS / 8
98
- }),
99
- IV_SIZE: ECIES_IV_SIZE,
100
- AUTH_TAG_SIZE: ECIES_AUTH_TAG_SIZE,
101
- MAX_RAW_DATA_SIZE: 9007199254740991, // 2^53 - 1 (max safe integer for JS)
102
- /**
103
- * Message encrypts without data length or crc
104
- */
105
- SIMPLE: Object.freeze({
106
- FIXED_OVERHEAD_SIZE: expectedSimpleOverhead, // type (1) + public key (65) + IV (16) + auth tag (16)
107
- DATA_LENGTH_SIZE: 0,
108
- }),
109
- /**
110
- * Message encrypts with data length but no CRC (AES-GCM provides authentication)
111
- */
112
- SINGLE: Object.freeze({
113
- FIXED_OVERHEAD_SIZE: 106, // type (1) + public key (65) + IV (16) + auth tag (16) + data length (8)
114
- DATA_LENGTH_SIZE: 8,
115
- }),
116
- /**
117
- * Message encrypts for multiple recipients
118
- */
119
- MULTIPLE: Object.freeze({
120
- FIXED_OVERHEAD_SIZE: expectedMultipleOverhead, // type (1) + IV (16) + auth tag (16), no CRC
121
- ENCRYPTED_KEY_SIZE: expectedMultipleEncryptedKeySize, // 129
122
- MAX_RECIPIENTS: 65535,
123
- RECIPIENT_ID_SIZE: ECIES_MULTIPLE_RECIPIENT_ID_SIZE,
124
- RECIPIENT_COUNT_SIZE: 2,
125
- DATA_LENGTH_SIZE: 8,
126
- }),
127
- ENCRYPTION_TYPE: Object.freeze({
128
- SIMPLE: 33,
129
- SINGLE: 66,
130
- MULTIPLE: 99,
131
- }),
132
- });
133
14
  const objectIdLength = new ObjectId().toHexString().length / 2;
134
15
  export const Constants = Object.freeze({
135
16
  /**
@@ -145,52 +26,10 @@ export const Constants = Object.freeze({
145
26
  UINT64_MAX: UINT64_MAX,
146
27
  HEX_RADIX: 16,
147
28
  GUID_SIZE: GUID_SIZE,
148
- CHECKSUM: CHECKSUM,
149
- ECIES: ECIES,
150
- PBKDF2: PBKDF2,
151
- PBKDF2_PROFILES: PBKDF2_PROFILES,
152
- /**
153
- * Number of rounds for bcrypt hashing. Higher values increase security but also consume more CPU resources.
154
- */
155
- BcryptRounds: 10,
156
- /**
157
- * Minimum password length
158
- */
159
- PasswordMinLength: 8,
160
- /**
161
- * The regular expression for valid passwords.
162
- */
163
- PasswordRegex: /^(?=.*[A-Za-z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?])[A-Za-z\d!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]{8,}$/,
164
- /**
165
- * The regular expression for valid mnemonic phrases.
166
- * BIP39 - supports 12, 15, 18, 21, or 24 word mnemonics
167
- */
168
- MnemonicRegex: /^(?:\w+\s){11}\w+$|^(?:\w+\s){14}\w+$|^(?:\w+\s){17}\w+$|^(?:\w+\s){20}\w+$|^(?:\w+\s){23}\w+$/i,
169
- /**
170
- * Matches a 64-character hexadecimal string (SHA-256).
171
- */
172
- HmacRegex: /^[a-f0-9]{64}$/,
29
+ PasswordRegex: PASSWORD_REGEX,
30
+ MnemonicRegex: MNEMONIC_REGEX,
173
31
  });
174
- if (CHECKSUM.SHA3_BUFFER_LENGTH !== CHECKSUM.SHA3_DEFAULT_HASH_BITS / 8 ||
175
- CHECKSUM.SHA3_BUFFER_LENGTH !== CHECKSUM.SHA3_DEFAULT_HASH_BITS / 8) {
176
- throw new Error('Invalid checksum constants');
177
- }
178
32
  if (objectIdLength !== 12) {
179
33
  console.warn('ObjectID length may have changed, breaking encryption', objectIdLength);
180
34
  }
181
- if (ECIES.MULTIPLE.ENCRYPTED_KEY_SIZE !== 129) {
182
- throw new ECIESError(ECIESErrorTypeEnum.InvalidECIESMultipleEncryptedKeySize, getCompatibleEciesEngine());
183
- }
184
- if (ECIES.PUBLIC_KEY_LENGTH !== ECIES.RAW_PUBLIC_KEY_LENGTH + 1) {
185
- throw new ECIESError(ECIESErrorTypeEnum.InvalidECIESPublicKeyLength, getCompatibleEciesEngine());
186
- }
187
- if (ECIES.MULTIPLE.RECIPIENT_COUNT_SIZE !== UINT16_SIZE) {
188
- throw new ECIESError(ECIESErrorTypeEnum.InvalidECIESMultipleRecipientCountSize, getCompatibleEciesEngine());
189
- }
190
- if (ECIES.MULTIPLE.DATA_LENGTH_SIZE !== UINT64_SIZE) {
191
- throw new ECIESError(ECIESErrorTypeEnum.InvalidECIESMultipleDataLengthSize, getCompatibleEciesEngine());
192
- }
193
- if (ECIES.MULTIPLE.RECIPIENT_ID_SIZE !== GUID_SIZE) {
194
- throw new ECIESError(ECIESErrorTypeEnum.InvalidECIESMultipleRecipientIdSize, getCompatibleEciesEngine());
195
- }
196
35
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAOxD,MAAM,CAAC,MAAM,UAAU,GAAW,CAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAW,CAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAW,KAAc,CAAC;AACjD,MAAM,CAAC,MAAM,WAAW,GAAW,CAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAW,UAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,WAAW,GAA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1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3D,MAAM,CAAC,MAAM,UAAU,GAAW,CAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,WAAW,GAAW,CAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAW,KAAc,CAAC;AACjD,MAAM,CAAC,MAAM,WAAW,GAAW,CAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAW,UAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,WAAW,GAAW,CAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAW,qBAA8B,CAAC;AACjE;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAW,EAAW,CAAC;AAE7C,MAAM,cAAc,GAAG,IAAI,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,SAAS,GAAe,MAAM,CAAC,MAAM,CAAC;IACjD;;OAEG;IACH,gBAAgB,EAAE,cAAc;IAEhC,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,WAAW;IACxB,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,WAAW;IACxB,UAAU,EAAE,UAAU;IACtB,WAAW,EAAE,WAAW;IACxB,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,EAAW;IACtB,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,cAAc;IAC7B,aAAa,EAAE,cAAc;CACrB,CAAC,CAAC;AAEZ,IAAI,cAAc,KAAK,EAAE,EAAE,CAAC;IAC1B,OAAO,CAAC,IAAI,CACV,uDAAuD,EACvD,cAAc,CACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { IChecksumConsts } from './interfaces';
2
+ import { IDefaults, IDefaultsOverrides } from './interfaces/defaults';
3
+ import { IECIESConstants } from './interfaces/ecies-consts';
4
+ import { IPBkdf2Consts } from './interfaces/pbkdf2-consts';
5
+ import { Pbkdf2Profiles } from './pbkdf2-profiles';
6
+ /**
7
+ * Constants for checksum operations
8
+ * These values are critical for data integrity and MUST NOT be changed
9
+ * in an already established system as it will break all existing checksums.
10
+ */
11
+ export declare const CHECKSUM: IChecksumConsts;
12
+ export declare const PBKDF2: IPBkdf2Consts;
13
+ export declare const PBKDF2_PROFILES: Pbkdf2Profiles;
14
+ export declare const ECIES: IECIESConstants;
15
+ export declare const Defaults: IDefaults;
16
+ export type ConfigurationKey = string | symbol;
17
+ export declare function createRuntimeConfiguration(overrides?: IDefaultsOverrides, base?: IDefaults): IDefaults;
18
+ export declare class DefaultsRegistry {
19
+ static readonly DEFAULT_KEY: ConfigurationKey;
20
+ static listKeys(): ConfigurationKey[];
21
+ static has(key: ConfigurationKey): boolean;
22
+ static get(key?: ConfigurationKey): IDefaults;
23
+ static create(overrides?: IDefaultsOverrides, baseKey?: ConfigurationKey): IDefaults;
24
+ static register(key: ConfigurationKey, configOrOverrides?: IDefaultsOverrides | IDefaults, options?: {
25
+ baseKey?: ConfigurationKey;
26
+ }): IDefaults;
27
+ static unregister(key: ConfigurationKey): boolean;
28
+ static clear(): void;
29
+ }
30
+ export declare function getRuntimeConfiguration(key?: ConfigurationKey): IDefaults;
31
+ export declare function registerRuntimeConfiguration(key: ConfigurationKey, configOrOverrides?: IDefaultsOverrides | IDefaults, options?: {
32
+ baseKey?: ConfigurationKey;
33
+ }): IDefaults;
34
+ export declare function unregisterRuntimeConfiguration(key: ConfigurationKey): boolean;
35
+ export declare function clearRuntimeConfigurations(): void;
36
+ export { PASSWORD_REGEX, MNEMONIC_REGEX } from './regexes';
37
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mapp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