@digitaldefiance/ecies-lib 4.10.7 → 4.11.0

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 (43) hide show
  1. package/README.md +135 -5
  2. package/package.json +1 -1
  3. package/src/enumerations/guid-brand-type.d.ts +1 -1
  4. package/src/enumerations/guid-brand-type.d.ts.map +1 -1
  5. package/src/enumerations/guid-brand-type.js +1 -1
  6. package/src/enumerations/guid-brand-type.js.map +1 -1
  7. package/src/errors/guid.d.ts +3 -3
  8. package/src/errors/guid.d.ts.map +1 -1
  9. package/src/errors/guid.js.map +1 -1
  10. package/src/examples/typed-configuration-usage.d.ts +12 -0
  11. package/src/examples/typed-configuration-usage.d.ts.map +1 -0
  12. package/src/examples/typed-configuration-usage.js +98 -0
  13. package/src/examples/typed-configuration-usage.js.map +1 -0
  14. package/src/index.d.ts +2 -0
  15. package/src/index.d.ts.map +1 -1
  16. package/src/index.js +2 -0
  17. package/src/index.js.map +1 -1
  18. package/src/interfaces/guid.d.ts +42 -8
  19. package/src/interfaces/guid.d.ts.map +1 -1
  20. package/src/interfaces/platform-id.d.ts +2 -2
  21. package/src/interfaces/platform-id.d.ts.map +1 -1
  22. package/src/lib/guid.d.ts +117 -77
  23. package/src/lib/guid.d.ts.map +1 -1
  24. package/src/lib/guid.js +344 -241
  25. package/src/lib/guid.js.map +1 -1
  26. package/src/lib/id-providers/guidv4-provider.d.ts +4 -3
  27. package/src/lib/id-providers/guidv4-provider.d.ts.map +1 -1
  28. package/src/lib/id-providers/guidv4-provider.js +22 -21
  29. package/src/lib/id-providers/guidv4-provider.js.map +1 -1
  30. package/src/typed-configuration.d.ts +162 -0
  31. package/src/typed-configuration.d.ts.map +1 -0
  32. package/src/typed-configuration.js +247 -0
  33. package/src/typed-configuration.js.map +1 -0
  34. package/src/types/guid-versions.d.ts +34 -0
  35. package/src/types/guid-versions.d.ts.map +1 -0
  36. package/src/types/guid-versions.js +7 -0
  37. package/src/types/guid-versions.js.map +1 -0
  38. package/src/types.d.ts +1 -1
  39. package/src/types.d.ts.map +1 -1
  40. package/src/utils.d.ts +1 -0
  41. package/src/utils.d.ts.map +1 -1
  42. package/src/utils.js +4 -0
  43. package/src/utils.js.map +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ Production-ready, browser-compatible ECIES (Elliptic Curve Integrated Encryption
8
8
 
9
9
  Part of [Express Suite](https://github.com/Digital-Defiance/express-suite)
10
10
 
11
- **Current Version: v4.10.6**
11
+ **Current Version: v4.10.7**
12
12
 
13
13
  This library implements a modern, enterprise-grade ECIES protocol (v4.0) featuring HKDF key derivation, AAD binding, and optimized multi-recipient encryption. It includes a pluggable ID provider system with PlatformID support, memory-efficient streaming encryption, comprehensive internationalization, and a complete cryptographic voting system with 15+ voting methods.
14
14
 
@@ -47,6 +47,7 @@ This library implements a modern, enterprise-grade ECIES protocol (v4.0) featuri
47
47
  - **PlatformID Type**: Generic type system supporting `Uint8Array | GuidV4 | ObjectId | string`
48
48
  - **Auto-Sync**: Configuration automatically adapts all cryptographic constants to the selected ID provider
49
49
  - **Member System**: User abstraction with cryptographic operations, fully integrated with the configured ID provider
50
+ - **Strong Typing**: New typed configuration system provides compile-time type safety for ID operations
50
51
  - **Key Management**:
51
52
  - **BIP39**: Mnemonic phrase generation (12-24 words).
52
53
  - **HD Wallets**: BIP32/BIP44 hierarchical deterministic derivation.
@@ -201,7 +202,8 @@ import {
201
202
  ECIESService,
202
203
  getEciesI18nEngine,
203
204
  createRuntimeConfiguration,
204
- ObjectIdProvider
205
+ ObjectIdProvider,
206
+ getEnhancedIdProvider
205
207
  } from '@digitaldefiance/ecies-lib';
206
208
 
207
209
  // 1. Initialize i18n (required once)
@@ -227,6 +229,12 @@ const encrypted = await ecies.encryptSimpleOrSingle(false, publicKey, message);
227
229
  const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encrypted);
228
230
 
229
231
  console.log(new TextDecoder().decode(decrypted)); // "Hello, Secure World!"
232
+
233
+ // 6. Strong Typing for ID Operations (NEW!)
234
+ const idProvider = getEnhancedIdProvider<ObjectId>();
235
+ const objectId = idProvider.generateTyped(); // Returns ObjectId - strongly typed!
236
+ const serialized = idProvider.serializeTyped(objectId); // Accepts ObjectId directly
237
+ const deserialized = idProvider.deserializeTyped(serialized); // Returns ObjectId
230
238
  ```
231
239
 
232
240
  ## Cryptographic Voting System
@@ -394,7 +402,55 @@ VotingSecurityValidator.validate(VotingMethod.Quadratic); // Throws error
394
402
  VotingSecurityValidator.validate(VotingMethod.Quadratic, { allowInsecure: true });
395
403
  ```
396
404
 
397
- ### 2. Using Custom ID Providers (e.g., GUID)
405
+ ### 2. Strong Typing for ID Providers (NEW!)
406
+
407
+ The library now provides strongly-typed alternatives to the weak typing pattern `Constants.idProvider.generate()`:
408
+
409
+ ```typescript
410
+ import {
411
+ getRuntimeConfiguration,
412
+ getEnhancedIdProvider,
413
+ getTypedIdProvider,
414
+ createObjectIdConfiguration
415
+ } from '@digitaldefiance/ecies-lib';
416
+ import { ObjectId } from 'bson';
417
+
418
+ // BEFORE: Weak typing (still works for compatibility)
419
+ const Constants = getRuntimeConfiguration();
420
+ const rawBytes = Constants.idProvider.generate(); // Returns Uint8Array, no strong typing
421
+ const nativeId = Constants.idProvider.fromBytes(rawBytes); // Returns unknown, requires casting
422
+
423
+ // AFTER: Strong typing - Option 1 (Enhanced Provider - Recommended)
424
+ const enhancedProvider = getEnhancedIdProvider<ObjectId>();
425
+
426
+ // Original methods still work exactly the same
427
+ const rawBytes2 = enhancedProvider.generate(); // Uint8Array (same as before)
428
+ const isValid = enhancedProvider.validate(rawBytes2); // boolean (same as before)
429
+
430
+ // Plus new strongly-typed methods
431
+ const objectId = enhancedProvider.generateTyped(); // ObjectId - strongly typed!
432
+ const validTyped = enhancedProvider.validateTyped(objectId); // boolean, accepts ObjectId
433
+ const serialized = enhancedProvider.serializeTyped(objectId); // string, accepts ObjectId
434
+ const deserialized = enhancedProvider.deserializeTyped(serialized); // ObjectId
435
+
436
+ // AFTER: Strong typing - Option 2 (Simple Typed Provider)
437
+ const typedProvider = getTypedIdProvider<ObjectId>();
438
+ const bytes = typedProvider.generate();
439
+ const typedId = typedProvider.fromBytes(bytes); // Returns ObjectId, not unknown!
440
+
441
+ // AFTER: Strong typing - Option 3 (Configuration Wrapper)
442
+ const config = createObjectIdConfiguration();
443
+ const configId = config.generateId(); // ObjectId directly!
444
+ const configValid = config.validateId(configId); // boolean, accepts ObjectId
445
+ ```
446
+
447
+ **Benefits:**
448
+ - ✅ **Full IntelliSense** - Autocomplete for native ID methods (`objectId.toHexString()`)
449
+ - ✅ **Compile-time checking** - Prevents type mismatches at build time
450
+ - ✅ **Zero breaking changes** - All existing code continues to work
451
+ - ✅ **Multiple migration paths** - Choose the approach that fits your use case
452
+
453
+ ### 3. Using Custom ID Providers (e.g., GUID)
398
454
 
399
455
  ```typescript
400
456
  import {
@@ -413,7 +469,7 @@ const ecies = new ECIESService(config);
413
469
  const id = config.idProvider.generate(); // Returns 16-byte Uint8Array
414
470
  ```
415
471
 
416
- ### 3. Streaming Encryption (Large Files)
472
+ ### 4. Streaming Encryption (Large Files)
417
473
 
418
474
  Encrypt gigabytes of data with minimal memory footprint (<10MB).
419
475
 
@@ -437,7 +493,7 @@ async function processFile(fileStream: ReadableStream, publicKey: Uint8Array) {
437
493
  }
438
494
  ```
439
495
 
440
- ### 4. Member System
496
+ ### 5. Member System
441
497
 
442
498
  The `Member` class provides a high-level user abstraction that integrates keys, IDs, and encryption.
443
499
 
@@ -973,6 +1029,27 @@ class MemberService {
973
1029
  - `get(key)`: Retrieve a configuration.
974
1030
  - **`createRuntimeConfiguration(overrides)`**: Creates a validated configuration object with your overrides.
975
1031
 
1032
+ ### Strong Typing System (NEW!)
1033
+
1034
+ - **`getEnhancedIdProvider<T>(key?)`**: Get a strongly-typed ID provider with enhanced convenience methods
1035
+ - Drop-in replacement for `Constants.idProvider` with both original and typed methods
1036
+ - `generateTyped()`: Generate ID with native type (e.g., `ObjectId`)
1037
+ - `validateTyped(id)`: Validate ID with native type
1038
+ - `serializeTyped(id)`: Serialize ID with native type
1039
+ - `deserializeTyped(str)`: Deserialize to native type
1040
+ - **`getTypedIdProvider<T>(key?)`**: Get a simple strongly-typed ID provider
1041
+ - Minimal API surface with type-safe conversions
1042
+ - `fromBytes(bytes)`: Returns native type instead of `unknown`
1043
+ - **`createObjectIdConfiguration(overrides?)`**: Create ObjectId-typed configuration
1044
+ - **`createGuidV4Configuration(overrides?)`**: Create GuidV4-typed configuration
1045
+ - **`createUint8ArrayConfiguration(overrides?)`**: Create Uint8Array-typed configuration
1046
+ - **`createUuidConfiguration(overrides?)`**: Create UUID string-typed configuration
1047
+ - **`TypedConfiguration<T>`**: Configuration wrapper with strongly-typed ID operations
1048
+ - `generateId()`: Generate ID with native type
1049
+ - `validateId(id)`: Validate ID with native type
1050
+ - `serializeId(id)`: Serialize ID with native type
1051
+ - `deserializeId(str)`: Deserialize to native type
1052
+
976
1053
  ### Secure Primitives
977
1054
 
978
1055
  - **`SecureString` / `SecureBuffer`**:
@@ -1181,6 +1258,59 @@ The library maintains **100% test coverage** with over 1,200 tests, including:
1181
1258
 
1182
1259
  ## ChangeLog
1183
1260
 
1261
+ ### v4.10.7 - Strong Typing for ID Providers
1262
+
1263
+ **Major Features:**
1264
+ - **Strong Typing System**: Added comprehensive strong typing solution for ID provider operations
1265
+ - `getEnhancedIdProvider<T>()`: Drop-in replacement for `Constants.idProvider` with typed methods
1266
+ - `getTypedIdProvider<T>()`: Simple typed provider for minimal API surface
1267
+ - `createObjectIdConfiguration()`: ObjectId-typed configuration factory
1268
+ - `TypedConfiguration<T>`: Configuration wrapper with strongly-typed ID operations
1269
+ - **Enhanced Developer Experience**:
1270
+ - Full IntelliSense support for native ID types (`ObjectId`, `GuidV4`, `string`, etc.)
1271
+ - Compile-time type checking prevents runtime type errors
1272
+ - Multiple migration paths to choose from based on use case
1273
+ - **Zero Breaking Changes**: All existing code continues to work unchanged
1274
+ - Original `Constants.idProvider` pattern still supported
1275
+ - Enhanced providers include all original methods plus typed alternatives
1276
+ - Backward compatibility maintained for all existing APIs
1277
+
1278
+ **New APIs:**
1279
+ - `getEnhancedIdProvider<T>(key?)`: Enhanced provider with typed convenience methods
1280
+ - `getTypedIdProvider<T>(key?)`: Simple typed provider
1281
+ - `createObjectIdConfiguration(overrides?)`: ObjectId-typed configuration
1282
+ - `createGuidV4Configuration(overrides?)`: GuidV4-typed configuration
1283
+ - `createUint8ArrayConfiguration(overrides?)`: Uint8Array-typed configuration
1284
+ - `createUuidConfiguration(overrides?)`: UUID string-typed configuration
1285
+ - `TypedIdProviderWrapper<T>`: Enhanced wrapper with typed methods
1286
+
1287
+ **Migration Examples:**
1288
+ ```typescript
1289
+ // BEFORE: Weak typing
1290
+ const Constants = getRuntimeConfiguration();
1291
+ const id = Constants.idProvider.generate(); // Uint8Array, no strong typing
1292
+
1293
+ // AFTER: Strong typing (multiple options)
1294
+ const enhancedProvider = getEnhancedIdProvider<ObjectId>();
1295
+ const objectId = enhancedProvider.generateTyped(); // ObjectId - strongly typed!
1296
+
1297
+ const typedProvider = getTypedIdProvider<ObjectId>();
1298
+ const typedId = typedProvider.fromBytes(bytes); // ObjectId, not unknown!
1299
+
1300
+ const config = createObjectIdConfiguration();
1301
+ const configId = config.generateId(); // ObjectId directly!
1302
+ ```
1303
+
1304
+ **Documentation:**
1305
+ - Added comprehensive migration guide (`src/migration-guide.md`)
1306
+ - Updated README with strong typing examples
1307
+ - Added usage examples and real-world migration patterns
1308
+
1309
+ **Testing:**
1310
+ - 14 new tests covering all strong typing scenarios
1311
+ - Property-based tests for type safety validation
1312
+ - Migration pattern tests for backward compatibility
1313
+
1184
1314
  ### v4.10.6 - Voting System & PlatformID Integration
1185
1315
 
1186
1316
  **Major Features:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/ecies-lib",
3
- "version": "4.10.7",
3
+ "version": "4.11.0",
4
4
  "description": "Digital Defiance ECIES Library",
5
5
  "homepage": "https://github.com/Digital-Defiance/ecies-lib",
6
6
  "repository": {
@@ -22,6 +22,6 @@ export declare enum GuidBrandType {
22
22
  /**
23
23
  * Raw Guid, in a buffer, 16 bytes
24
24
  */
25
- RawGuidBuffer = "RawGuidBuffer"
25
+ RawGuidPlatformBuffer = "RawGuidPlatformBuffer"
26
26
  }
27
27
  //# sourceMappingURL=guid-brand-type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"guid-brand-type.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/enumerations/guid-brand-type.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB;;;OAGG;IACH,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,YAAY,iBAAiB;IAC7B;;;OAGG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,aAAa,kBAAkB;CAChC"}
1
+ {"version":3,"file":"guid-brand-type.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/enumerations/guid-brand-type.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB;;;OAGG;IACH,WAAW,gBAAgB;IAC3B;;;OAGG;IACH,YAAY,iBAAiB;IAC7B;;;OAGG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,UAAU,eAAe;IACzB;;OAEG;IACH,qBAAqB,0BAA0B;CAChD"}
@@ -26,6 +26,6 @@ var GuidBrandType;
26
26
  /**
27
27
  * Raw Guid, in a buffer, 16 bytes
28
28
  */
29
- GuidBrandType["RawGuidBuffer"] = "RawGuidBuffer";
29
+ GuidBrandType["RawGuidPlatformBuffer"] = "RawGuidPlatformBuffer";
30
30
  })(GuidBrandType || (exports.GuidBrandType = GuidBrandType = {}));
31
31
  //# sourceMappingURL=guid-brand-type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guid-brand-type.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/enumerations/guid-brand-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB;;;OAGG;IACH,4CAA2B,CAAA;IAC3B;;;OAGG;IACH,8CAA6B,CAAA;IAC7B;;;OAGG;IACH,0CAAyB,CAAA;IACzB;;OAEG;IACH,0CAAyB,CAAA;IACzB;;OAEG;IACH,gDAA+B,CAAA;AACjC,CAAC,EAzBW,aAAa,6BAAb,aAAa,QAyBxB"}
1
+ {"version":3,"file":"guid-brand-type.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/enumerations/guid-brand-type.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAyBX;AAzBD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB;;;OAGG;IACH,4CAA2B,CAAA;IAC3B;;;OAGG;IACH,8CAA6B,CAAA;IAC7B;;;OAGG;IACH,0CAAyB,CAAA;IACzB;;OAEG;IACH,0CAAyB,CAAA;IACzB;;OAEG;IACH,gEAA+C,CAAA;AACjD,CAAC,EAzBW,aAAa,6BAAb,aAAa,QAyBxB"}
@@ -2,7 +2,7 @@ import { TypedHandleableError } from '@digitaldefiance/i18n-lib';
2
2
  import { EciesStringKey } from '../enumerations';
3
3
  import { GuidBrandType } from '../enumerations/guid-brand-type';
4
4
  import { GuidErrorType } from '../enumerations/guid-error-type';
5
- import { RawGuidBuffer } from '../types';
5
+ import type { RawGuidPlatformBuffer } from '../types';
6
6
  /**
7
7
  * Error class for handling GUID-related errors.
8
8
  * Provides detailed error information including the error type, optional brand, length, and GUID value.
@@ -17,7 +17,7 @@ import { RawGuidBuffer } from '../types';
17
17
  export declare class GuidError extends TypedHandleableError<typeof GuidErrorType, EciesStringKey> {
18
18
  readonly brand?: GuidBrandType | undefined;
19
19
  readonly length?: number | undefined;
20
- readonly guid?: (RawGuidBuffer | Uint8Array) | undefined;
20
+ readonly guid?: (RawGuidPlatformBuffer | Uint8Array) | undefined;
21
21
  /**
22
22
  * Reason map cache to avoid rebuilding on every error instantiation.
23
23
  * This improves performance in scenarios where many errors are created.
@@ -34,7 +34,7 @@ export declare class GuidError extends TypedHandleableError<typeof GuidErrorType
34
34
  *
35
35
  * @throws {Error} If guid parameter is provided but is not a Buffer.
36
36
  */
37
- constructor(type: GuidErrorType, brand?: GuidBrandType | undefined, length?: number | undefined, guid?: (RawGuidBuffer | Uint8Array) | undefined, language?: string);
37
+ constructor(type: GuidErrorType, brand?: GuidBrandType | undefined, length?: number | undefined, guid?: (RawGuidPlatformBuffer | Uint8Array) | undefined, language?: string);
38
38
  /**
39
39
  * Returns a string representation of the error with all relevant details.
40
40
  * @returns A detailed error string.
@@ -1 +1 @@
1
- {"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/errors/guid.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,qBAAa,SAAU,SAAQ,oBAAoB,CACjD,OAAO,aAAa,EACpB,cAAc,CACf;aA+BmB,KAAK,CAAC,EAAE,aAAa;aACrB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,GAAE,aAAa,GAAG,UAAU;IAhCnD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAWhC;IAEF;;;;;;;;;;OAUG;gBAED,IAAI,EAAE,aAAa,EACH,KAAK,CAAC,EAAE,aAAa,YAAA,EACrB,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,GAAE,aAAa,GAAG,UAAU,aAAA,EACjD,QAAQ,CAAC,EAAE,MAAM;IAoCnB;;;OAGG;IACa,QAAQ,IAAI,MAAM;IAkBlC;;;OAGG;IACa,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CASlD"}
1
+ {"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/errors/guid.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,qBAAa,SAAU,SAAQ,oBAAoB,CACjD,OAAO,aAAa,EACpB,cAAc,CACf;aA+BmB,KAAK,CAAC,EAAE,aAAa;aACrB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,GAAE,qBAAqB,GAAG,UAAU;IAhC3D;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAWhC;IAEF;;;;;;;;;;OAUG;gBAED,IAAI,EAAE,aAAa,EACH,KAAK,CAAC,EAAE,aAAa,YAAA,EACrB,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,GAAE,qBAAqB,GAAG,UAAU,aAAA,EACzD,QAAQ,CAAC,EAAE,MAAM;IAoCnB;;;OAGG;IACa,QAAQ,IAAI,MAAM;IAkBlC;;;OAGG;IACa,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CASlD"}
@@ -1 +1 @@
1
- {"version":3,"file":"guid.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/errors/guid.ts"],"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
2
+ * Examples showing how to use the typed configuration system for strong ID provider typing.
3
+ * This demonstrates the solution to the original problem where Constants.idProvider.generate()
4
+ * had no strong typing.
5
+ */
6
+ declare function beforeExample(): void;
7
+ declare function afterExample(): void;
8
+ declare function realWorldUsage(): void;
9
+ declare function serviceIntegration(): void;
10
+ declare function typeSafetyDemo(): void;
11
+ export { beforeExample, afterExample, realWorldUsage, serviceIntegration, typeSafetyDemo, };
12
+ //# sourceMappingURL=typed-configuration-usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-configuration-usage.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/examples/typed-configuration-usage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,iBAAS,aAAa,SAKrB;AAMD,iBAAS,YAAY,SAsBpB;AAMD,iBAAS,cAAc,SAsBtB;AAMD,iBAAS,kBAAkB,SAU1B;AAMD,iBAAS,cAAc,SAgBtB;AAED,OAAO,EACL,aAAa,EACb,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,cAAc,GACf,CAAC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ /**
3
+ * Examples showing how to use the typed configuration system for strong ID provider typing.
4
+ * This demonstrates the solution to the original problem where Constants.idProvider.generate()
5
+ * had no strong typing.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.beforeExample = beforeExample;
9
+ exports.afterExample = afterExample;
10
+ exports.realWorldUsage = realWorldUsage;
11
+ exports.serviceIntegration = serviceIntegration;
12
+ exports.typeSafetyDemo = typeSafetyDemo;
13
+ const constants_1 = require("../constants");
14
+ const guidv4_provider_1 = require("../lib/id-providers/guidv4-provider");
15
+ const typed_configuration_1 = require("../typed-configuration");
16
+ // ============================================================================
17
+ // BEFORE: Weak typing with getRuntimeConfiguration()
18
+ // ============================================================================
19
+ function beforeExample() {
20
+ // This was the original problem - no strong typing
21
+ const Constants = (0, constants_1.getRuntimeConfiguration)();
22
+ const id = Constants.idProvider.generate(); // Returns Uint8Array, loses type info
23
+ const _nativeId = Constants.idProvider.fromBytes(id); // Returns unknown, no type safety
24
+ }
25
+ // ============================================================================
26
+ // AFTER: Strong typing solutions
27
+ // ============================================================================
28
+ function afterExample() {
29
+ // Solution 1: Direct replacement for Constants.idProvider
30
+ const enhancedProvider = (0, typed_configuration_1.getEnhancedIdProvider)();
31
+ // Original methods still work exactly the same
32
+ const rawBytes = enhancedProvider.generate(); // Uint8Array (same as before)
33
+ const _isValid = enhancedProvider.validate(rawBytes); // boolean (same as before)
34
+ // But now you also have strongly-typed methods
35
+ const objectId = enhancedProvider.generateTyped(); // ObjectId - strongly typed!
36
+ const _validTyped = enhancedProvider.validateTyped(objectId); // boolean, accepts ObjectId
37
+ const serialized = enhancedProvider.serializeTyped(objectId); // string, accepts ObjectId
38
+ const _deserialized = enhancedProvider.deserializeTyped(serialized); // ObjectId
39
+ // Solution 2: Simple typed provider
40
+ const typedProvider = (0, typed_configuration_1.getTypedIdProvider)();
41
+ const bytes = typedProvider.generate();
42
+ const _typedId = typedProvider.fromBytes(bytes); // Returns ObjectId, not unknown!
43
+ // Solution 3: Configuration approach (for more complex scenarios)
44
+ const config = (0, typed_configuration_1.createObjectIdConfiguration)();
45
+ const _configId = config.generateId(); // Returns ObjectId - strongly typed!
46
+ }
47
+ // ============================================================================
48
+ // Real-world usage patterns
49
+ // ============================================================================
50
+ function realWorldUsage() {
51
+ // Pattern 1: Service initialization with strong typing
52
+ const config = (0, typed_configuration_1.createObjectIdConfiguration)();
53
+ // Now you can use config.idProvider with full type safety
54
+ const newId = config.generateId(); // ObjectId
55
+ const _isValid = config.validateId(newId); // boolean
56
+ const _idString = config.serializeId(newId); // string
57
+ // Pattern 2: Custom provider with type inference
58
+ const customProvider = new guidv4_provider_1.GuidProvider();
59
+ const typedConfig = (0, typed_configuration_1.createTypedConfiguration)({
60
+ idProvider: customProvider,
61
+ // Other overrides...
62
+ BcryptRounds: 12,
63
+ });
64
+ const _guidId = typedConfig.generateId(); // GuidV4 - automatically inferred!
65
+ // Pattern 3: Backward compatibility - access underlying constants
66
+ const _underlyingConstants = typedConfig.constants;
67
+ // This still works for existing code that expects IConstants
68
+ }
69
+ // ============================================================================
70
+ // Integration with ECIESService
71
+ // ============================================================================
72
+ function serviceIntegration() {
73
+ // The ECIESService can now use TypedConfiguration for better typing
74
+ const config = (0, typed_configuration_1.createObjectIdConfiguration)();
75
+ // Pass the underlying constants to existing services
76
+ // const service = new ECIESService<ObjectId>(config.constants);
77
+ // Or use the typed config directly for ID operations
78
+ const memberId = config.generateId(); // ObjectId
79
+ const _memberIdString = config.serializeId(memberId); // string
80
+ }
81
+ // ============================================================================
82
+ // Type safety demonstrations
83
+ // ============================================================================
84
+ function typeSafetyDemo() {
85
+ const objectIdConfig = (0, typed_configuration_1.createObjectIdConfiguration)();
86
+ const guidConfig = (0, typed_configuration_1.createGuidV4Configuration)({
87
+ idProvider: new guidv4_provider_1.GuidProvider(),
88
+ });
89
+ const objectId = objectIdConfig.generateId(); // ObjectId
90
+ const guid = guidConfig.generateId(); // GuidV4
91
+ // These operations are now type-safe:
92
+ objectIdConfig.serializeId(objectId); // ✅ Accepts ObjectId
93
+ guidConfig.serializeId(guid); // ✅ Accepts GuidV4
94
+ // These would be compile-time errors:
95
+ // objectIdConfig.serializeId(guid); // ❌ Type error: GuidV4 not assignable to ObjectId
96
+ // guidConfig.serializeId(objectId); // ❌ Type error: ObjectId not assignable to GuidV4
97
+ }
98
+ //# sourceMappingURL=typed-configuration-usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typed-configuration-usage.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/examples/typed-configuration-usage.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAuHD,sCAAa;AACb,oCAAY;AACZ,wCAAc;AACd,gDAAkB;AAClB,wCAAc;AAxHhB,4CAAuD;AACvD,yEAAmE;AACnE,gEAMgC;AAEhC,+EAA+E;AAC/E,qDAAq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AC;IACrD,MAAM,UAAU,GAAG,IAAA,+CAAyB,EAAC;QAC3C,UAAU,EAAE,IAAI,8BAAY,EAAE;KAC/B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC,WAAW;IACzD,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,SAAS;IAE/C,sCAAsC;IACtC,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB;IAC3D,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB;IAEjD,sCAAsC;IACtC,uFAAuF;IACvF,uFAAuF;AACzF,CAAC"}
package/src/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export * from './lib/index';
15
15
  export { EciesComponentId, EciesI18nEngineKey, getEciesI18nEngine, getEciesTranslation, resetEciesI18nEngine, safeEciesTranslation, } from './i18n-setup';
16
16
  export { encryptionTypeEnumToType, encryptionTypeToString, ensureEciesEncryptionTypeEnum, validateEciesEncryptionTypeEnum, } from './utils/encryption-type-utils';
17
17
  export * from './constants';
18
+ export * from './typed-configuration';
18
19
  export * from './email-string';
19
20
  export * from './enumerations';
20
21
  export * from './errors';
@@ -34,6 +35,7 @@ export * from './secure-buffer';
34
35
  export * from './secure-string';
35
36
  export * from './services';
36
37
  export * from './types';
38
+ export * from './types/guid-versions';
37
39
  export * from './utils';
38
40
  export * from './lib/voting';
39
41
  export type { PrivateKey, PublicKey, KeyPair as PaillierKeyPair, } from 'paillier-bigint';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,uBAAuB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAG5B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AASvC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,UAAU,EACV,SAAS,EACT,OAAO,IAAI,eAAe,GAC3B,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,uBAAuB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAG5B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,+BAA+B,GAChC,MAAM,+BAA+B,CAAC;AASvC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,8BAA8B,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,YAAY,EACV,UAAU,EACV,SAAS,EACT,OAAO,IAAI,eAAe,GAC3B,MAAM,iBAAiB,CAAC"}
package/src/index.js CHANGED
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "validateEciesEncryptionTypeEnum", { enumerable:
40
40
  // Note: Existing services will be re-exported once migrated to v2
41
41
  // For now, import from main index.ts for backward compatibility
42
42
  tslib_1.__exportStar(require("./constants"), exports);
43
+ tslib_1.__exportStar(require("./typed-configuration"), exports);
43
44
  tslib_1.__exportStar(require("./email-string"), exports);
44
45
  tslib_1.__exportStar(require("./enumerations"), exports);
45
46
  tslib_1.__exportStar(require("./errors"), exports);
@@ -59,6 +60,7 @@ tslib_1.__exportStar(require("./secure-buffer"), exports);
59
60
  tslib_1.__exportStar(require("./secure-string"), exports);
60
61
  tslib_1.__exportStar(require("./services"), exports);
61
62
  tslib_1.__exportStar(require("./types"), exports);
63
+ tslib_1.__exportStar(require("./types/guid-versions"), exports);
62
64
  tslib_1.__exportStar(require("./utils"), exports);
63
65
  // Voting system exports (IMember already exported from ./interfaces)
64
66
  tslib_1.__exportStar(require("./lib/voting"), exports);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,mEAAmE;AACnE,wEAAwE;AACxE,iCAA+B;AAE/B,kBAAkB;AAClB,2DAAiC;AACjC,uDAA6B;AAC7B,sDAA4B;AAE5B,UAAU;AACV,2CAOsB;AANpB,8GAAA,gBAAgB,OAAA;AAChB,gHAAA,kBAAkB,OAAA;AAClB,gHAAA,kBAAkB,OAAA;AAClB,iHAAA,mBAAmB,OAAA;AACnB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AAGtB,mFAAmF;AACnF,mEAAmE;AACnE,uEAKuC;AAJrC,iIAAA,wBAAwB,OAAA;AACxB,+HAAA,sBAAsB,OAAA;AACtB,sIAAA,6BAA6B,OAAA;AAC7B,wIAAA,+BAA+B,OAAA;AAGjC,2DAA2D;AAC3D,oEAAoE;AACpE,8DAA8D;AAE9D,kEAAkE;AAClE,gEAAgE;AAEhE,sDAA4B;AAC5B,yDAA+B;AAC/B,yDAA+B;AAC/B,mDAAyB;AACzB,uDAA6B;AAC7B,uEAA6C;AAC7C,kEAAyE;AAAhE,4HAAA,wBAAwB,OAAA;AAEjC,qEAA2C;AAC3C,qEAA2C;AAC3C,uEAA6C;AAC7C,6DAAmC;AACnC,4DAAkC;AAClC,mDAAyB;AACzB,4DAAkC;AAClC,yDAA+B;AAC/B,0DAAgC;AAChC,0DAAgC;AAChC,qDAA2B;AAC3B,kDAAwB;AACxB,kDAAwB;AAExB,qEAAqE;AACrE,uDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/digitaldefiance-ecies-lib/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,mEAAmE;AACnE,wEAAwE;AACxE,iCAA+B;AAE/B,kBAAkB;AAClB,2DAAiC;AACjC,uDAA6B;AAC7B,sDAA4B;AAE5B,UAAU;AACV,2CAOsB;AANpB,8GAAA,gBAAgB,OAAA;AAChB,gHAAA,kBAAkB,OAAA;AAClB,gHAAA,kBAAkB,OAAA;AAClB,iHAAA,mBAAmB,OAAA;AACnB,kHAAA,oBAAoB,OAAA;AACpB,kHAAA,oBAAoB,OAAA;AAGtB,mFAAmF;AACnF,mEAAmE;AACnE,uEAKuC;AAJrC,iIAAA,wBAAwB,OAAA;AACxB,+HAAA,sBAAsB,OAAA;AACtB,sIAAA,6BAA6B,OAAA;AAC7B,wIAAA,+BAA+B,OAAA;AAGjC,2DAA2D;AAC3D,oEAAoE;AACpE,8DAA8D;AAE9D,kEAAkE;AAClE,gEAAgE;AAEhE,sDAA4B;AAC5B,gEAAsC;AACtC,yDAA+B;AAC/B,yDAA+B;AAC/B,mDAAyB;AACzB,uDAA6B;AAC7B,uEAA6C;AAC7C,kEAAyE;AAAhE,4HAAA,wBAAwB,OAAA;AAEjC,qEAA2C;AAC3C,qEAA2C;AAC3C,uEAA6C;AAC7C,6DAAmC;AACnC,4DAAkC;AAClC,mDAAyB;AACzB,4DAAkC;AAClC,yDAA+B;AAC/B,0DAAgC;AAChC,0DAAgC;AAChC,qDAA2B;AAC3B,kDAAwB;AACxB,gEAAsC;AACtC,kDAAwB;AAExB,qEAAqE;AACrE,uDAA6B"}
@@ -1,17 +1,18 @@
1
- import { Base64Guid, BigIntGuid, FullHexGuid, RawGuidBuffer, ShortHexGuid } from '../types';
2
- export interface IGuidV4 {
1
+ import type { Base64Guid, BigIntGuid, FullHexGuid, RawGuidPlatformBuffer, ShortHexGuid } from '../types';
2
+ import type { PlatformBuffer } from './platform-buffer';
3
+ export interface IGuid {
3
4
  /**
4
5
  * Returns the GUID as a raw buffer.
5
6
  */
6
- get asRawGuidBuffer(): RawGuidBuffer;
7
+ get asRawGuidPlatformBuffer(): RawGuidPlatformBuffer;
7
8
  /**
8
9
  * Returns the GUID as a full hex string.
9
10
  */
10
11
  get asFullHexGuid(): FullHexGuid;
11
12
  /**
12
- * Returns the GUID as a Uint8Array.
13
+ * Returns the GUID as a PlatformBuffer.
13
14
  */
14
- get asUint8Array(): Uint8Array;
15
+ get asPlatformBuffer(): PlatformBuffer;
15
16
  /**
16
17
  * Returns the GUID as a short hex string.
17
18
  */
@@ -24,6 +25,10 @@ export interface IGuidV4 {
24
25
  * Returns the GUID as a Base64 string.
25
26
  */
26
27
  get asBase64Guid(): Base64Guid;
28
+ /**
29
+ * Returns a URL-safe base64 representation.
30
+ */
31
+ get asUrlSafeBase64(): string;
27
32
  /**
28
33
  * Returns the GUID as a base64 string
29
34
  */
@@ -41,12 +46,12 @@ export interface IGuidV4 {
41
46
  * @param other The GUID to compare to (can be null/undefined)
42
47
  * @param constantTime Use constant-time comparison to prevent timing attacks
43
48
  */
44
- equals(other: IGuidV4 | null | undefined, constantTime?: boolean): boolean;
49
+ equals(other: IGuid | null | undefined, constantTime?: boolean): boolean;
45
50
  /**
46
51
  * Creates a new GuidV4 instance with the same value as this one.
47
52
  * @returns A new GuidV4 instance with identical value
48
53
  */
49
- clone(): IGuidV4;
54
+ clone(): IGuid;
50
55
  /**
51
56
  * Returns the hash code for this GUID based on its buffer content.
52
57
  * Useful for using GUIDs as Map/Set keys.
@@ -63,16 +68,45 @@ export interface IGuidV4 {
63
68
  * @returns The version number (1-5) or undefined
64
69
  */
65
70
  getVersion(): number | undefined;
71
+ /**
72
+ * Extracts the variant from the GUID.
73
+ * @returns The variant (0-2) or undefined
74
+ */
75
+ getVariant(): number | undefined;
76
+ /**
77
+ * Returns the timestamp from a v1 GUID.
78
+ * @returns Date object or undefined if not a v1 GUID
79
+ */
80
+ getTimestamp(): Date | undefined;
81
+ /**
82
+ * Validates that this GUID is a proper v1 GUID according to RFC 4122.
83
+ * @returns True if valid v1 GUID, false otherwise
84
+ */
85
+ isValidV1(): boolean;
86
+ /**
87
+ * Validates that this GUID is a proper v3 GUID according to RFC 4122.
88
+ * @returns True if valid v3 GUID, false otherwise
89
+ */
90
+ isValidV3(): boolean;
66
91
  /**
67
92
  * Validates that this GUID is a proper v4 GUID according to RFC 4122.
68
93
  * @returns True if valid v4 GUID or boundary value, false otherwise
69
94
  */
70
95
  isValidV4(): boolean;
96
+ /**
97
+ * Validates that this GUID is a proper v5 GUID according to RFC 4122.
98
+ * @returns True if valid v5 GUID, false otherwise
99
+ */
100
+ isValidV5(): boolean;
71
101
  /**
72
102
  * Compares two GUIDs for ordering.
73
103
  * @param other The other GUID to compare to
74
104
  * @returns -1 if this < other, 0 if equal, 1 if this > other
75
105
  */
76
- compareTo(other: IGuidV4): number;
106
+ compareTo(other: IGuid): number;
107
+ /**
108
+ * Returns a human-readable debug string.
109
+ */
110
+ toDebugString(): string;
77
111
  }
78
112
  //# sourceMappingURL=guid.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/guid.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EAEV,WAAW,EACX,aAAa,EACb,YAAY,EACb,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,IAAI,eAAe,IAAI,aAAa,CAAC;IACrC;;OAEG;IACH,IAAI,aAAa,IAAI,WAAW,CAAC;IACjC;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAC/B;;OAEG;IACH,IAAI,cAAc,IAAI,YAAY,CAAC;IACnC;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAC/B;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAE/B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IACpB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,IAAI,UAAU,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3E;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC;IACjB;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC"}
1
+ {"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/guid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAEV,WAAW,EACX,qBAAqB,EACrB,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,IAAI,uBAAuB,IAAI,qBAAqB,CAAC;IACrD;;OAEG;IACH,IAAI,aAAa,IAAI,WAAW,CAAC;IACjC;;OAEG;IACH,IAAI,gBAAgB,IAAI,cAAc,CAAC;IACvC;;OAEG;IACH,IAAI,cAAc,IAAI,YAAY,CAAC;IACnC;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAC/B;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,CAAC;IAC/B;;OAEG;IACH,IAAI,eAAe,IAAI,MAAM,CAAC;IAE9B;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IACpB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,IAAI,UAAU,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzE;;;OAGG;IACH,KAAK,IAAI,KAAK,CAAC;IACf;;;;OAIG;IACH,QAAQ,IAAI,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,YAAY,IAAI,IAAI,GAAG,SAAS,CAAC;IACjC;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC;IACrB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;CACzB"}
@@ -1,4 +1,4 @@
1
- import { ObjectId } from 'bson';
2
- import type { GuidV4 } from '../lib';
1
+ import type { ObjectId } from 'bson';
2
+ import type { GuidV4 } from '../types/guid-versions';
3
3
  export type PlatformID = Uint8Array | GuidV4 | ObjectId | string;
4
4
  //# sourceMappingURL=platform-id.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-id.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/platform-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"platform-id.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/platform-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC"}