@digitaldefiance/ecies-lib 4.4.0 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -497,6 +497,15 @@ The library maintains **100% test coverage** with over 1,200 tests, including:
497
497
 
498
498
  ## ChangeLog
499
499
 
500
+ ### v4.4.2
501
+
502
+ - Update test-utils
503
+
504
+ ### v4.4.1
505
+
506
+ - Mainly changes to testing
507
+ - Slight changes to reduce warnings
508
+
500
509
  ### v4.4.0
501
510
 
502
511
  - Upgrade i18n
@@ -839,6 +848,206 @@ This release focuses on eliminating type safety escape hatches while maintaining
839
848
 
840
849
  - Initial release of the ECIES library with multi-recipient support, AES-GCM helpers, PBKDF2 profiles, and password-login tooling
841
850
 
851
+ ## Testing
852
+
853
+ ### Testing Approach
854
+
855
+ The ecies-lib package employs a rigorous testing strategy with over 1,200 tests covering all cryptographic operations, protocol flows, and edge cases.
856
+
857
+ **Test Framework**: Jest with TypeScript support
858
+ **Property-Based Testing**: fast-check for cryptographic property validation
859
+ **Coverage Target**: 100% for critical cryptographic paths
860
+ **Binary Compatibility**: Cross-platform tests with node-ecies-lib
861
+
862
+ ### Test Structure
863
+
864
+ ```
865
+ tests/
866
+ ├── unit/ # Unit tests for individual services
867
+ ├── integration/ # Integration tests for protocol flows
868
+ ├── e2e/ # End-to-end encryption/decryption tests
869
+ ├── property/ # Property-based tests for cryptographic properties
870
+ ├── compatibility/ # Cross-platform compatibility tests
871
+ └── vectors/ # Test vectors for protocol validation
872
+ ```
873
+
874
+ ### Running Tests
875
+
876
+ ```bash
877
+ # Run all tests
878
+ npm test
879
+
880
+ # Run with coverage
881
+ npm test -- --coverage
882
+
883
+ # Run specific test suite
884
+ npm test -- ecies-service.spec.ts
885
+
886
+ # Run compatibility tests
887
+ npm test -- cross-platform-compatibility.spec.ts
888
+
889
+ # Run in watch mode
890
+ npm test -- --watch
891
+ ```
892
+
893
+ ### Test Patterns
894
+
895
+ #### Testing Encryption/Decryption
896
+
897
+ ```typescript
898
+ import { ECIESService, getEciesI18nEngine } from '@digitaldefiance/ecies-lib';
899
+
900
+ describe('ECIES Encryption', () => {
901
+ let ecies: ECIESService;
902
+
903
+ beforeAll(() => {
904
+ getEciesI18nEngine(); // Initialize i18n
905
+ });
906
+
907
+ beforeEach(() => {
908
+ ecies = new ECIESService();
909
+ });
910
+
911
+ it('should encrypt and decrypt data', async () => {
912
+ const mnemonic = ecies.generateNewMnemonic();
913
+ const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
914
+
915
+ const message = new TextEncoder().encode('Secret Message');
916
+ const encrypted = await ecies.encryptSimpleOrSingle(false, publicKey, message);
917
+ const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encrypted);
918
+
919
+ expect(new TextDecoder().decode(decrypted)).toBe('Secret Message');
920
+ });
921
+ });
922
+ ```
923
+
924
+ #### Testing Multi-Recipient Encryption
925
+
926
+ ```typescript
927
+ import { ECIESService, Member, MemberType, EmailString } from '@digitaldefiance/ecies-lib';
928
+
929
+ describe('Multi-Recipient Encryption', () => {
930
+ it('should encrypt for multiple recipients', async () => {
931
+ const ecies = new ECIESService();
932
+
933
+ // Create recipients
934
+ const alice = Member.newMember(ecies, MemberType.User, 'Alice', new EmailString('alice@example.com'));
935
+ const bob = Member.newMember(ecies, MemberType.User, 'Bob', new EmailString('bob@example.com'));
936
+
937
+ const message = new TextEncoder().encode('Shared Secret');
938
+
939
+ // Encrypt for both recipients
940
+ const encrypted = await ecies.encryptMultiple(
941
+ [alice.member.publicKey, bob.member.publicKey],
942
+ message
943
+ );
944
+
945
+ // Both can decrypt
946
+ const aliceDecrypted = await ecies.decryptMultiple(
947
+ alice.member.id,
948
+ alice.member.privateKey,
949
+ encrypted
950
+ );
951
+ const bobDecrypted = await ecies.decryptMultiple(
952
+ bob.member.id,
953
+ bob.member.privateKey,
954
+ encrypted
955
+ );
956
+
957
+ expect(new TextDecoder().decode(aliceDecrypted)).toBe('Shared Secret');
958
+ expect(new TextDecoder().decode(bobDecrypted)).toBe('Shared Secret');
959
+ });
960
+ });
961
+ ```
962
+
963
+ #### Testing ID Providers
964
+
965
+ ```typescript
966
+ import { createRuntimeConfiguration, GuidV4Provider, ObjectIdProvider } from '@digitaldefiance/ecies-lib';
967
+
968
+ describe('ID Provider System', () => {
969
+ it('should work with ObjectId provider', () => {
970
+ const config = createRuntimeConfiguration({
971
+ idProvider: new ObjectIdProvider()
972
+ });
973
+
974
+ const id = config.idProvider.generate();
975
+ expect(id.length).toBe(12); // ObjectId is 12 bytes
976
+ });
977
+
978
+ it('should work with GUID provider', () => {
979
+ const config = createRuntimeConfiguration({
980
+ idProvider: new GuidV4Provider()
981
+ });
982
+
983
+ const id = config.idProvider.generate();
984
+ expect(id.length).toBe(16); // GUID is 16 bytes
985
+ });
986
+ });
987
+ ```
988
+
989
+ #### Property-Based Testing for Cryptographic Properties
990
+
991
+ ```typescript
992
+ import * as fc from 'fast-check';
993
+ import { ECIESService } from '@digitaldefiance/ecies-lib';
994
+
995
+ describe('Cryptographic Properties', () => {
996
+ it('should maintain round-trip property for any message', async () => {
997
+ const ecies = new ECIESService();
998
+ const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(ecies.generateNewMnemonic());
999
+
1000
+ await fc.assert(
1001
+ fc.asyncProperty(
1002
+ fc.uint8Array({ minLength: 1, maxLength: 1000 }),
1003
+ async (message) => {
1004
+ const encrypted = await ecies.encryptSimpleOrSingle(false, publicKey, message);
1005
+ const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encrypted);
1006
+
1007
+ expect(decrypted).toEqual(message);
1008
+ }
1009
+ ),
1010
+ { numRuns: 100 }
1011
+ );
1012
+ });
1013
+ });
1014
+ ```
1015
+
1016
+ ### Testing Best Practices
1017
+
1018
+ 1. **Initialize i18n** before running tests with `getEciesI18nEngine()`
1019
+ 2. **Test all encryption modes** (Simple, Single, Multiple)
1020
+ 3. **Test with different ID providers** to ensure compatibility
1021
+ 4. **Use property-based tests** for cryptographic invariants
1022
+ 5. **Test error conditions** like invalid keys, corrupted data, and wrong recipients
1023
+ 6. **Verify binary compatibility** with node-ecies-lib
1024
+
1025
+ ### Cross-Platform Testing
1026
+
1027
+ Testing compatibility with node-ecies-lib:
1028
+
1029
+ ```typescript
1030
+ import { ECIESService as BrowserECIES } from '@digitaldefiance/ecies-lib';
1031
+ // In Node.js environment:
1032
+ // import { ECIESService as NodeECIES } from '@digitaldefiance/node-ecies-lib';
1033
+
1034
+ describe('Cross-Platform Compatibility', () => {
1035
+ it('should decrypt node-encrypted data in browser', async () => {
1036
+ // Data encrypted in Node.js
1037
+ const nodeEncrypted = Buffer.from('...'); // From node-ecies-lib
1038
+
1039
+ const browserEcies = new BrowserECIES();
1040
+ const decrypted = await browserEcies.decryptSimpleOrSingleWithHeader(
1041
+ false,
1042
+ privateKey,
1043
+ new Uint8Array(nodeEncrypted)
1044
+ );
1045
+
1046
+ expect(new TextDecoder().decode(decrypted)).toBe('Expected Message');
1047
+ });
1048
+ });
1049
+ ```
1050
+
842
1051
  ## License
843
1052
 
844
1053
  MIT © Digital Defiance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/ecies-lib",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "description": "Digital Defiance ECIES Library",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -58,12 +58,16 @@
58
58
  "ts-brand": "^0.2.0"
59
59
  },
60
60
  "devDependencies": {
61
- "@digitaldefiance/express-suite-test-utils": "1.0.10",
61
+ "@digitaldefiance/express-suite-test-utils": "1.0.11",
62
62
  "@swc/core": "^1.15.3",
63
63
  "@swc/jest": "^0.2.39",
64
+ "@typescript-eslint/eslint-plugin": "^8.48.0",
65
+ "@typescript-eslint/parser": "^8.48.0",
66
+ "eslint-plugin-import": "^2.32.0",
67
+ "eslint-plugin-prettier": "^5.5.4",
64
68
  "fast-check": "^4.3.0",
65
69
  "madge": "^8.0.0"
66
70
  },
67
- "module": "./src/index.js",
71
+ "module": "./../../dist/packages/digitaldefiance-ecies-lib/packages/digitaldefiance-ecies-lib/src/index.js",
68
72
  "type": "module"
69
73
  }
@@ -39,13 +39,5 @@ export interface IConfigurationProvenance {
39
39
  */
40
40
  readonly creationStack?: string;
41
41
  }
42
- /**
43
- * Calculates a checksum for a configuration object.
44
- * Uses SHA-256 of JSON representation.
45
- */
46
- export declare function calculateConfigChecksum(config: IConstants): string;
47
- /**
48
- * Captures a stack trace for provenance tracking
49
- */
50
- export declare function captureCreationStack(): string;
42
+ export { calculateConfigChecksum, captureCreationStack, } from '../lib/configuration-provenance-utils';
51
43
  //# sourceMappingURL=configuration-provenance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configuration-provenance.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/configuration-provenance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAElD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAMlE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAO7C"}
1
+ {"version":3,"file":"configuration-provenance.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/configuration-provenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAElD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAGD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC"}
@@ -1,23 +1,3 @@
1
- import { createHash } from 'crypto';
2
- /**
3
- * Calculates a checksum for a configuration object.
4
- * Uses SHA-256 of JSON representation.
5
- */
6
- export function calculateConfigChecksum(config) {
7
- // Create a stable JSON representation with BigInt support
8
- const replacer = (key, value) => typeof value === 'bigint' ? value.toString() : value;
9
- const stable = JSON.stringify(config, replacer);
10
- return createHash('sha256').update(stable).digest('hex');
11
- }
12
- /**
13
- * Captures a stack trace for provenance tracking
14
- */
15
- export function captureCreationStack() {
16
- const stack = new Error().stack;
17
- if (!stack)
18
- return 'stack unavailable';
19
- // Remove the first two lines (Error message and this function)
20
- const lines = stack.split('\n').slice(2);
21
- return lines.join('\n');
22
- }
1
+ // Re-export utility functions from lib
2
+ export { calculateConfigChecksum, captureCreationStack, } from '../lib/configuration-provenance-utils';
23
3
  //# sourceMappingURL=configuration-provenance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configuration-provenance.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/configuration-provenance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAkDpC;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAkB;IACxD,0DAA0D;IAC1D,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE,CAC3C,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,mBAAmB,CAAC;IAEvC,+DAA+D;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
1
+ {"version":3,"file":"configuration-provenance.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/configuration-provenance.ts"],"names":[],"mappings":"AAiDA,uCAAuC;AACvC,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC"}
@@ -45,11 +45,11 @@ export interface IChunkHeader {
45
45
  * Constants for chunk format
46
46
  */
47
47
  export declare const CHUNK_CONSTANTS: {
48
- readonly MAGIC: 1162037573;
49
- readonly VERSION: 1;
48
+ readonly MAGIC: 0x45434945;
49
+ readonly VERSION: 0x0001;
50
50
  readonly HEADER_SIZE: 32;
51
- readonly FLAG_IS_LAST: 1;
52
- readonly FLAG_HAS_CHECKSUM: 2;
51
+ readonly FLAG_IS_LAST: 0x01;
52
+ readonly FLAG_HAS_CHECKSUM: 0x02;
53
53
  readonly CHECKSUM_SIZE: 32;
54
54
  };
55
55
  //# sourceMappingURL=encrypted-chunk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encrypted-chunk.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encrypted-chunk.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,sCAAsC;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;CAOlB,CAAC"}
1
+ {"version":3,"file":"encrypted-chunk.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encrypted-chunk.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,4BAA4B;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,sCAAsC;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE;IAC5B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;IAC5B,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;CAQnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"encrypted-chunk.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encrypted-chunk.ts"],"names":[],"mappings":"AA8CA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,UAAU,EAAE,SAAS;IAC5B,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,EAAE,EAAE,UAAU;CACrB,CAAC"}
1
+ {"version":3,"file":"encrypted-chunk.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encrypted-chunk.ts"],"names":[],"mappings":"AA8CA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAOxB;IACF,KAAK,EAAE,UAAU,EAAE,SAAS;IAC5B,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,EAAE,EAAE,UAAU;CACrB,CAAC"}
@@ -14,5 +14,5 @@ export interface IEncryptionState {
14
14
  timestamp: number;
15
15
  hmac?: string;
16
16
  }
17
- export declare const ENCRYPTION_STATE_VERSION = 1;
17
+ export declare const ENCRYPTION_STATE_VERSION: number;
18
18
  //# sourceMappingURL=encryption-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encryption-state.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encryption-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,uBAAuB,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,wBAAwB,IAAI,CAAC"}
1
+ {"version":3,"file":"encryption-state.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encryption-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,uBAAuB,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAU,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"encryption-state.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encryption-state.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"encryption-state.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/encryption-state.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,wBAAwB,GAAW,CAAC,CAAC"}
@@ -49,41 +49,6 @@ export interface IMultiRecipientChunk {
49
49
  /** Number of recipients */
50
50
  recipientCount: number;
51
51
  }
52
- /**
53
- * Multi-recipient format constants structure
54
- */
55
- export interface IMultiRecipientConstants {
56
- readonly MAGIC: number;
57
- readonly VERSION: number;
58
- readonly HEADER_SIZE: number;
59
- readonly RECIPIENT_ID_SIZE: number;
60
- readonly KEY_SIZE_BYTES: number;
61
- readonly FLAG_IS_LAST: number;
62
- readonly FLAG_HAS_CHECKSUM: number;
63
- readonly MAX_RECIPIENTS: number;
64
- }
65
- /**
66
- * Get multi-recipient constants for a specific recipient ID size.
67
- * This allows the format to adapt to different ID providers.
68
- *
69
- * @param recipientIdSize - The byte length of recipient IDs (from ID provider)
70
- * @returns Frozen constants object for the multi-recipient format
71
- *
72
- * @example
73
- * ```typescript
74
- * // For ObjectID (12 bytes)
75
- * const constants = getMultiRecipientConstants(12);
76
- *
77
- * // For GUID (16 bytes)
78
- * const constants = getMultiRecipientConstants(16);
79
- * ```
80
- */
81
- export declare function getMultiRecipientConstants(recipientIdSize: number): IMultiRecipientConstants;
82
- /**
83
- * Default multi-recipient constants using ObjectID size (12 bytes).
84
- *
85
- * @deprecated Use getMultiRecipientConstants(config.idProvider.byteLength) instead
86
- * for dynamic ID size support. This constant is provided for backward compatibility only.
87
- */
88
- export declare const MULTI_RECIPIENT_CONSTANTS: IMultiRecipientConstants;
52
+ export { MULTI_RECIPIENT_CONSTANTS, getMultiRecipientConstants, } from '../lib/multi-recipient-chunk-utils';
53
+ export type { IMultiRecipientConstants } from '../lib/multi-recipient-chunk-utils';
89
54
  //# sourceMappingURL=multi-recipient-chunk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-recipient-chunk.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/multi-recipient-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,EAAE,EAAE,UAAU,CAAC;IACf,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,YAAY,EAAE,UAAU,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,IAAI,EAAE,UAAU,CAAC;IACjB,qCAAqC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,GACtB,wBAAwB,CAiB1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,0BAAiC,CAAC"}
1
+ {"version":3,"file":"multi-recipient-chunk.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/multi-recipient-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,EAAE,EAAE,UAAU,CAAC;IACf,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,YAAY,EAAE,UAAU,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kBAAkB;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,IAAI,EAAE,UAAU,CAAC;IACjB,qCAAqC;IACrC,MAAM,EAAE,OAAO,CAAC;IAChB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC"}
@@ -6,42 +6,6 @@
6
6
  * - Recipient headers (variable): encrypted symmetric keys for each recipient
7
7
  * - Encrypted data (variable): data encrypted with symmetric key
8
8
  */
9
- /**
10
- * Get multi-recipient constants for a specific recipient ID size.
11
- * This allows the format to adapt to different ID providers.
12
- *
13
- * @param recipientIdSize - The byte length of recipient IDs (from ID provider)
14
- * @returns Frozen constants object for the multi-recipient format
15
- *
16
- * @example
17
- * ```typescript
18
- * // For ObjectID (12 bytes)
19
- * const constants = getMultiRecipientConstants(12);
20
- *
21
- * // For GUID (16 bytes)
22
- * const constants = getMultiRecipientConstants(16);
23
- * ```
24
- */
25
- export function getMultiRecipientConstants(recipientIdSize) {
26
- if (!Number.isInteger(recipientIdSize) || recipientIdSize < 1 || recipientIdSize > 255) {
27
- throw new Error(`Invalid recipientIdSize: ${recipientIdSize}. Must be an integer between 1 and 255.`);
28
- }
29
- return Object.freeze({
30
- MAGIC: 0x4D524543, // "MREC"
31
- VERSION: 0x0002, // Updated to 0x0002 for Shared Ephemeral Key support
32
- HEADER_SIZE: 64, // Increased to 64 bytes to accommodate Ephemeral Public Key (33 bytes)
33
- RECIPIENT_ID_SIZE: recipientIdSize,
34
- KEY_SIZE_BYTES: 2,
35
- FLAG_IS_LAST: 0x01,
36
- FLAG_HAS_CHECKSUM: 0x02,
37
- MAX_RECIPIENTS: 65535,
38
- });
39
- }
40
- /**
41
- * Default multi-recipient constants using ObjectID size (12 bytes).
42
- *
43
- * @deprecated Use getMultiRecipientConstants(config.idProvider.byteLength) instead
44
- * for dynamic ID size support. This constant is provided for backward compatibility only.
45
- */
46
- export const MULTI_RECIPIENT_CONSTANTS = getMultiRecipientConstants(12);
9
+ // Re-export interface (type-only), utility function and constant from lib
10
+ export { MULTI_RECIPIENT_CONSTANTS, getMultiRecipientConstants, } from '../lib/multi-recipient-chunk-utils';
47
11
  //# sourceMappingURL=multi-recipient-chunk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-recipient-chunk.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/multi-recipient-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA8DH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CACxC,eAAuB;IAEvB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,GAAG,EAAE,CAAC;QACvF,MAAM,IAAI,KAAK,CACb,4BAA4B,eAAe,yCAAyC,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,UAAU,EAAE,SAAS;QAC5B,OAAO,EAAE,MAAM,EAAE,qDAAqD;QACtE,WAAW,EAAE,EAAE,EAAE,uEAAuE;QACxF,iBAAiB,EAAE,eAAe;QAClC,cAAc,EAAE,CAAC;QACjB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,KAAK;KACtB,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"multi-recipient-chunk.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/multi-recipient-chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgDH,0EAA0E;AAC1E,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,oCAAoC,CAAC"}
@@ -22,8 +22,8 @@ export interface IStreamHeader {
22
22
  * Constants for stream header format
23
23
  */
24
24
  export declare const STREAM_HEADER_CONSTANTS: {
25
- readonly MAGIC: 1162040148;
26
- readonly VERSION: 1;
25
+ readonly MAGIC: 0x45435354;
26
+ readonly VERSION: 0x0001;
27
27
  readonly HEADER_SIZE: 128;
28
28
  };
29
29
  //# sourceMappingURL=stream-header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream-header.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/stream-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,cAAc,EAAE,uBAAuB,CAAC;IACxC,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
1
+ {"version":3,"file":"stream-header.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/stream-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,cAAc,EAAE,uBAAuB,CAAC;IACxC,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE;IACpC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC;CAKlB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"stream-header.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/stream-header.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,KAAK,EAAE,UAAU,EAAE,SAAS;IAC5B,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,GAAG;CACR,CAAC"}
1
+ {"version":3,"file":"stream-header.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/interfaces/stream-header.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAIhC;IACF,KAAK,EAAE,UAAU,EAAE,SAAS;IAC5B,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,GAAG;CACR,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { IConstants } from '../interfaces/constants';
2
+ /**
3
+ * Calculates a checksum for a configuration object.
4
+ * Uses SHA-256 of JSON representation.
5
+ */
6
+ export declare function calculateConfigChecksum(config: IConstants): string;
7
+ /**
8
+ * Captures a stack trace for provenance tracking
9
+ */
10
+ export declare function captureCreationStack(): string;
11
+ //# sourceMappingURL=configuration-provenance-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-provenance-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/configuration-provenance-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAMlE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAO7C"}
@@ -0,0 +1,23 @@
1
+ import { createHash } from 'crypto';
2
+ /**
3
+ * Calculates a checksum for a configuration object.
4
+ * Uses SHA-256 of JSON representation.
5
+ */
6
+ export function calculateConfigChecksum(config) {
7
+ // Create a stable JSON representation with BigInt support
8
+ const replacer = (_key, value) => typeof value === 'bigint' ? value.toString() : value;
9
+ const stable = JSON.stringify(config, replacer);
10
+ return createHash('sha256').update(stable).digest('hex');
11
+ }
12
+ /**
13
+ * Captures a stack trace for provenance tracking
14
+ */
15
+ export function captureCreationStack() {
16
+ const stack = new Error().stack;
17
+ if (!stack)
18
+ return 'stack unavailable';
19
+ // Remove the first two lines (Error message and this function)
20
+ const lines = stack.split('\n').slice(2);
21
+ return lines.join('\n');
22
+ }
23
+ //# sourceMappingURL=configuration-provenance-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration-provenance-utils.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/configuration-provenance-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAkB;IACxD,0DAA0D;IAC1D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAAU,EAAE,EAAE,CAC5C,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,mBAAmB,CAAC;IAEvC,+DAA+D;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Multi-recipient format constants structure
3
+ */
4
+ export interface IMultiRecipientConstants {
5
+ readonly MAGIC: number;
6
+ readonly VERSION: number;
7
+ readonly HEADER_SIZE: number;
8
+ readonly RECIPIENT_ID_SIZE: number;
9
+ readonly KEY_SIZE_BYTES: number;
10
+ readonly FLAG_IS_LAST: number;
11
+ readonly FLAG_HAS_CHECKSUM: number;
12
+ readonly MAX_RECIPIENTS: number;
13
+ }
14
+ /**
15
+ * Get multi-recipient constants for a specific recipient ID size.
16
+ * This allows the format to adapt to different ID providers.
17
+ *
18
+ * @param recipientIdSize - The byte length of recipient IDs (from ID provider)
19
+ * @returns Frozen constants object for the multi-recipient format
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // For ObjectID (12 bytes)
24
+ * const constants = getMultiRecipientConstants(12);
25
+ *
26
+ * // For GUID (16 bytes)
27
+ * const constants = getMultiRecipientConstants(16);
28
+ * ```
29
+ */
30
+ export declare function getMultiRecipientConstants(recipientIdSize: number): IMultiRecipientConstants;
31
+ /**
32
+ * Default multi-recipient constants using ObjectID size (12 bytes).
33
+ *
34
+ * @deprecated Use getMultiRecipientConstants(config.idProvider.byteLength) instead
35
+ * for dynamic ID size support. This constant is provided for backward compatibility only.
36
+ */
37
+ export declare const MULTI_RECIPIENT_CONSTANTS: IMultiRecipientConstants;
38
+ //# sourceMappingURL=multi-recipient-chunk-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-recipient-chunk-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/multi-recipient-chunk-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,MAAM,GACtB,wBAAwB,CAqB1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,wBACR,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Get multi-recipient constants for a specific recipient ID size.
3
+ * This allows the format to adapt to different ID providers.
4
+ *
5
+ * @param recipientIdSize - The byte length of recipient IDs (from ID provider)
6
+ * @returns Frozen constants object for the multi-recipient format
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // For ObjectID (12 bytes)
11
+ * const constants = getMultiRecipientConstants(12);
12
+ *
13
+ * // For GUID (16 bytes)
14
+ * const constants = getMultiRecipientConstants(16);
15
+ * ```
16
+ */
17
+ export function getMultiRecipientConstants(recipientIdSize) {
18
+ if (!Number.isInteger(recipientIdSize) ||
19
+ recipientIdSize < 1 ||
20
+ recipientIdSize > 255) {
21
+ throw new Error(`Invalid recipientIdSize: ${recipientIdSize}. Must be an integer between 1 and 255.`);
22
+ }
23
+ return Object.freeze({
24
+ MAGIC: 0x4d524543, // "MREC"
25
+ VERSION: 0x0002, // Updated to 0x0002 for Shared Ephemeral Key support
26
+ HEADER_SIZE: 64, // Increased to 64 bytes to accommodate Ephemeral Public Key (33 bytes)
27
+ RECIPIENT_ID_SIZE: recipientIdSize,
28
+ KEY_SIZE_BYTES: 2,
29
+ FLAG_IS_LAST: 0x01,
30
+ FLAG_HAS_CHECKSUM: 0x02,
31
+ MAX_RECIPIENTS: 65535,
32
+ });
33
+ }
34
+ /**
35
+ * Default multi-recipient constants using ObjectID size (12 bytes).
36
+ *
37
+ * @deprecated Use getMultiRecipientConstants(config.idProvider.byteLength) instead
38
+ * for dynamic ID size support. This constant is provided for backward compatibility only.
39
+ */
40
+ export const MULTI_RECIPIENT_CONSTANTS = getMultiRecipientConstants(12);
41
+ //# sourceMappingURL=multi-recipient-chunk-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-recipient-chunk-utils.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-ecies-lib/src/lib/multi-recipient-chunk-utils.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CACxC,eAAuB;IAEvB,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC;QAClC,eAAe,GAAG,CAAC;QACnB,eAAe,GAAG,GAAG,EACrB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,4BAA4B,eAAe,yCAAyC,CACrF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,UAAU,EAAE,SAAS;QAC5B,OAAO,EAAE,MAAM,EAAE,qDAAqD;QACtE,WAAW,EAAE,EAAE,EAAE,uEAAuE;QACxF,iBAAiB,EAAE,eAAe;QAClC,cAAc,EAAE,CAAC;QACjB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,KAAK;KACtB,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,0BAA0B,CAAC,EAAE,CAAC,CAAC"}