@digitaldefiance/ecies-lib 4.3.1 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -0
- package/package.json +6 -2
- package/src/interfaces/configuration-provenance.d.ts +1 -9
- package/src/interfaces/configuration-provenance.d.ts.map +1 -1
- package/src/interfaces/configuration-provenance.js +2 -22
- package/src/interfaces/configuration-provenance.js.map +1 -1
- package/src/interfaces/encrypted-chunk.d.ts +4 -4
- package/src/interfaces/encrypted-chunk.d.ts.map +1 -1
- package/src/interfaces/encrypted-chunk.js.map +1 -1
- package/src/interfaces/encryption-state.d.ts +1 -1
- package/src/interfaces/encryption-state.d.ts.map +1 -1
- package/src/interfaces/encryption-state.js.map +1 -1
- package/src/interfaces/multi-recipient-chunk.d.ts +2 -37
- package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -1
- package/src/interfaces/multi-recipient-chunk.js +2 -38
- package/src/interfaces/multi-recipient-chunk.js.map +1 -1
- package/src/interfaces/stream-header.d.ts +2 -2
- package/src/interfaces/stream-header.d.ts.map +1 -1
- package/src/interfaces/stream-header.js.map +1 -1
- package/src/lib/configuration-provenance-utils.d.ts +11 -0
- package/src/lib/configuration-provenance-utils.d.ts.map +1 -0
- package/src/lib/configuration-provenance-utils.js +23 -0
- package/src/lib/configuration-provenance-utils.js.map +1 -0
- package/src/lib/multi-recipient-chunk-utils.d.ts +38 -0
- package/src/lib/multi-recipient-chunk-utils.d.ts.map +1 -0
- package/src/lib/multi-recipient-chunk-utils.js +41 -0
- package/src/lib/multi-recipient-chunk-utils.js.map +1 -0
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.1
|
|
501
|
+
|
|
502
|
+
- Mainly changes to testing
|
|
503
|
+
- Slight changes to reduce warnings
|
|
504
|
+
|
|
505
|
+
### v4.4.0
|
|
506
|
+
|
|
507
|
+
- Upgrade i18n
|
|
508
|
+
|
|
500
509
|
### v4.3.1
|
|
501
510
|
|
|
502
511
|
- Improving dependency loops/constants/direcular dependency
|
|
@@ -835,6 +844,206 @@ This release focuses on eliminating type safety escape hatches while maintaining
|
|
|
835
844
|
|
|
836
845
|
- Initial release of the ECIES library with multi-recipient support, AES-GCM helpers, PBKDF2 profiles, and password-login tooling
|
|
837
846
|
|
|
847
|
+
## Testing
|
|
848
|
+
|
|
849
|
+
### Testing Approach
|
|
850
|
+
|
|
851
|
+
The ecies-lib package employs a rigorous testing strategy with over 1,200 tests covering all cryptographic operations, protocol flows, and edge cases.
|
|
852
|
+
|
|
853
|
+
**Test Framework**: Jest with TypeScript support
|
|
854
|
+
**Property-Based Testing**: fast-check for cryptographic property validation
|
|
855
|
+
**Coverage Target**: 100% for critical cryptographic paths
|
|
856
|
+
**Binary Compatibility**: Cross-platform tests with node-ecies-lib
|
|
857
|
+
|
|
858
|
+
### Test Structure
|
|
859
|
+
|
|
860
|
+
```
|
|
861
|
+
tests/
|
|
862
|
+
├── unit/ # Unit tests for individual services
|
|
863
|
+
├── integration/ # Integration tests for protocol flows
|
|
864
|
+
├── e2e/ # End-to-end encryption/decryption tests
|
|
865
|
+
├── property/ # Property-based tests for cryptographic properties
|
|
866
|
+
├── compatibility/ # Cross-platform compatibility tests
|
|
867
|
+
└── vectors/ # Test vectors for protocol validation
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
### Running Tests
|
|
871
|
+
|
|
872
|
+
```bash
|
|
873
|
+
# Run all tests
|
|
874
|
+
npm test
|
|
875
|
+
|
|
876
|
+
# Run with coverage
|
|
877
|
+
npm test -- --coverage
|
|
878
|
+
|
|
879
|
+
# Run specific test suite
|
|
880
|
+
npm test -- ecies-service.spec.ts
|
|
881
|
+
|
|
882
|
+
# Run compatibility tests
|
|
883
|
+
npm test -- cross-platform-compatibility.spec.ts
|
|
884
|
+
|
|
885
|
+
# Run in watch mode
|
|
886
|
+
npm test -- --watch
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### Test Patterns
|
|
890
|
+
|
|
891
|
+
#### Testing Encryption/Decryption
|
|
892
|
+
|
|
893
|
+
```typescript
|
|
894
|
+
import { ECIESService, getEciesI18nEngine } from '@digitaldefiance/ecies-lib';
|
|
895
|
+
|
|
896
|
+
describe('ECIES Encryption', () => {
|
|
897
|
+
let ecies: ECIESService;
|
|
898
|
+
|
|
899
|
+
beforeAll(() => {
|
|
900
|
+
getEciesI18nEngine(); // Initialize i18n
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
beforeEach(() => {
|
|
904
|
+
ecies = new ECIESService();
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
it('should encrypt and decrypt data', async () => {
|
|
908
|
+
const mnemonic = ecies.generateNewMnemonic();
|
|
909
|
+
const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(mnemonic);
|
|
910
|
+
|
|
911
|
+
const message = new TextEncoder().encode('Secret Message');
|
|
912
|
+
const encrypted = await ecies.encryptSimpleOrSingle(false, publicKey, message);
|
|
913
|
+
const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encrypted);
|
|
914
|
+
|
|
915
|
+
expect(new TextDecoder().decode(decrypted)).toBe('Secret Message');
|
|
916
|
+
});
|
|
917
|
+
});
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
#### Testing Multi-Recipient Encryption
|
|
921
|
+
|
|
922
|
+
```typescript
|
|
923
|
+
import { ECIESService, Member, MemberType, EmailString } from '@digitaldefiance/ecies-lib';
|
|
924
|
+
|
|
925
|
+
describe('Multi-Recipient Encryption', () => {
|
|
926
|
+
it('should encrypt for multiple recipients', async () => {
|
|
927
|
+
const ecies = new ECIESService();
|
|
928
|
+
|
|
929
|
+
// Create recipients
|
|
930
|
+
const alice = Member.newMember(ecies, MemberType.User, 'Alice', new EmailString('alice@example.com'));
|
|
931
|
+
const bob = Member.newMember(ecies, MemberType.User, 'Bob', new EmailString('bob@example.com'));
|
|
932
|
+
|
|
933
|
+
const message = new TextEncoder().encode('Shared Secret');
|
|
934
|
+
|
|
935
|
+
// Encrypt for both recipients
|
|
936
|
+
const encrypted = await ecies.encryptMultiple(
|
|
937
|
+
[alice.member.publicKey, bob.member.publicKey],
|
|
938
|
+
message
|
|
939
|
+
);
|
|
940
|
+
|
|
941
|
+
// Both can decrypt
|
|
942
|
+
const aliceDecrypted = await ecies.decryptMultiple(
|
|
943
|
+
alice.member.id,
|
|
944
|
+
alice.member.privateKey,
|
|
945
|
+
encrypted
|
|
946
|
+
);
|
|
947
|
+
const bobDecrypted = await ecies.decryptMultiple(
|
|
948
|
+
bob.member.id,
|
|
949
|
+
bob.member.privateKey,
|
|
950
|
+
encrypted
|
|
951
|
+
);
|
|
952
|
+
|
|
953
|
+
expect(new TextDecoder().decode(aliceDecrypted)).toBe('Shared Secret');
|
|
954
|
+
expect(new TextDecoder().decode(bobDecrypted)).toBe('Shared Secret');
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
#### Testing ID Providers
|
|
960
|
+
|
|
961
|
+
```typescript
|
|
962
|
+
import { createRuntimeConfiguration, GuidV4Provider, ObjectIdProvider } from '@digitaldefiance/ecies-lib';
|
|
963
|
+
|
|
964
|
+
describe('ID Provider System', () => {
|
|
965
|
+
it('should work with ObjectId provider', () => {
|
|
966
|
+
const config = createRuntimeConfiguration({
|
|
967
|
+
idProvider: new ObjectIdProvider()
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
const id = config.idProvider.generate();
|
|
971
|
+
expect(id.length).toBe(12); // ObjectId is 12 bytes
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
it('should work with GUID provider', () => {
|
|
975
|
+
const config = createRuntimeConfiguration({
|
|
976
|
+
idProvider: new GuidV4Provider()
|
|
977
|
+
});
|
|
978
|
+
|
|
979
|
+
const id = config.idProvider.generate();
|
|
980
|
+
expect(id.length).toBe(16); // GUID is 16 bytes
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
#### Property-Based Testing for Cryptographic Properties
|
|
986
|
+
|
|
987
|
+
```typescript
|
|
988
|
+
import * as fc from 'fast-check';
|
|
989
|
+
import { ECIESService } from '@digitaldefiance/ecies-lib';
|
|
990
|
+
|
|
991
|
+
describe('Cryptographic Properties', () => {
|
|
992
|
+
it('should maintain round-trip property for any message', async () => {
|
|
993
|
+
const ecies = new ECIESService();
|
|
994
|
+
const { privateKey, publicKey } = ecies.mnemonicToSimpleKeyPair(ecies.generateNewMnemonic());
|
|
995
|
+
|
|
996
|
+
await fc.assert(
|
|
997
|
+
fc.asyncProperty(
|
|
998
|
+
fc.uint8Array({ minLength: 1, maxLength: 1000 }),
|
|
999
|
+
async (message) => {
|
|
1000
|
+
const encrypted = await ecies.encryptSimpleOrSingle(false, publicKey, message);
|
|
1001
|
+
const decrypted = await ecies.decryptSimpleOrSingleWithHeader(false, privateKey, encrypted);
|
|
1002
|
+
|
|
1003
|
+
expect(decrypted).toEqual(message);
|
|
1004
|
+
}
|
|
1005
|
+
),
|
|
1006
|
+
{ numRuns: 100 }
|
|
1007
|
+
);
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
### Testing Best Practices
|
|
1013
|
+
|
|
1014
|
+
1. **Initialize i18n** before running tests with `getEciesI18nEngine()`
|
|
1015
|
+
2. **Test all encryption modes** (Simple, Single, Multiple)
|
|
1016
|
+
3. **Test with different ID providers** to ensure compatibility
|
|
1017
|
+
4. **Use property-based tests** for cryptographic invariants
|
|
1018
|
+
5. **Test error conditions** like invalid keys, corrupted data, and wrong recipients
|
|
1019
|
+
6. **Verify binary compatibility** with node-ecies-lib
|
|
1020
|
+
|
|
1021
|
+
### Cross-Platform Testing
|
|
1022
|
+
|
|
1023
|
+
Testing compatibility with node-ecies-lib:
|
|
1024
|
+
|
|
1025
|
+
```typescript
|
|
1026
|
+
import { ECIESService as BrowserECIES } from '@digitaldefiance/ecies-lib';
|
|
1027
|
+
// In Node.js environment:
|
|
1028
|
+
// import { ECIESService as NodeECIES } from '@digitaldefiance/node-ecies-lib';
|
|
1029
|
+
|
|
1030
|
+
describe('Cross-Platform Compatibility', () => {
|
|
1031
|
+
it('should decrypt node-encrypted data in browser', async () => {
|
|
1032
|
+
// Data encrypted in Node.js
|
|
1033
|
+
const nodeEncrypted = Buffer.from('...'); // From node-ecies-lib
|
|
1034
|
+
|
|
1035
|
+
const browserEcies = new BrowserECIES();
|
|
1036
|
+
const decrypted = await browserEcies.decryptSimpleOrSingleWithHeader(
|
|
1037
|
+
false,
|
|
1038
|
+
privateKey,
|
|
1039
|
+
new Uint8Array(nodeEncrypted)
|
|
1040
|
+
);
|
|
1041
|
+
|
|
1042
|
+
expect(new TextDecoder().decode(decrypted)).toBe('Expected Message');
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
```
|
|
1046
|
+
|
|
838
1047
|
## License
|
|
839
1048
|
|
|
840
1049
|
MIT © Digital Defiance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/ecies-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Digital Defiance ECIES Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"license": "MIT",
|
|
50
50
|
"packageManager": "yarn@4.11.0",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@digitaldefiance/i18n-lib": "3.
|
|
52
|
+
"@digitaldefiance/i18n-lib": "3.8.0",
|
|
53
53
|
"@ethereumjs/wallet": "^10.0.0",
|
|
54
54
|
"@noble/curves": "^2.0.1",
|
|
55
55
|
"@noble/hashes": "^2.0.1",
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
"@digitaldefiance/express-suite-test-utils": "1.0.10",
|
|
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
|
},
|
|
@@ -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":"
|
|
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
|
-
|
|
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":"
|
|
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:
|
|
49
|
-
readonly VERSION:
|
|
48
|
+
readonly MAGIC: 0x45434945;
|
|
49
|
+
readonly VERSION: 0x0001;
|
|
50
50
|
readonly HEADER_SIZE: 32;
|
|
51
|
-
readonly FLAG_IS_LAST:
|
|
52
|
-
readonly FLAG_HAS_CHECKSUM:
|
|
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
|
|
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,
|
|
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"}
|
|
@@ -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,
|
|
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,
|
|
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
|
-
|
|
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;
|
|
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
|
-
|
|
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;
|
|
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:
|
|
26
|
-
readonly VERSION:
|
|
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
|
|
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,
|
|
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"}
|