@storacha/encrypt-upload-client 1.1.56 → 1.1.58

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 (72) hide show
  1. package/dist/config/constants.d.ts +3 -3
  2. package/dist/config/constants.js +4 -3
  3. package/dist/config/env.d.ts +9 -6
  4. package/dist/config/service.d.ts +13 -13
  5. package/dist/core/client.d.ts +54 -41
  6. package/dist/core/client.js +68 -56
  7. package/dist/core/errors.d.ts +6 -6
  8. package/dist/core/metadata/encrypted-metadata.d.ts +13 -8
  9. package/dist/core/metadata/kms-metadata.d.ts +68 -36
  10. package/dist/core/metadata/lit-metadata.d.ts +63 -28
  11. package/dist/crypto/adapters/kms-crypto-adapter.d.ts +172 -137
  12. package/dist/crypto/adapters/lit-crypto-adapter.d.ts +107 -86
  13. package/dist/crypto/factories.browser.d.ts +9 -5
  14. package/dist/crypto/factories.browser.js +15 -7
  15. package/dist/crypto/factories.node.d.ts +13 -6
  16. package/dist/crypto/factories.node.js +19 -13
  17. package/dist/crypto/index.d.ts +5 -5
  18. package/dist/crypto/index.js +5 -5
  19. package/dist/crypto/symmetric/generic-aes-ctr-streaming-crypto.d.ts +58 -54
  20. package/dist/crypto/symmetric/generic-aes-ctr-streaming-crypto.js +174 -146
  21. package/dist/crypto/symmetric/node-aes-cbc-crypto.d.ts +36 -32
  22. package/dist/crypto/symmetric/node-aes-cbc-crypto.js +101 -95
  23. package/dist/examples/decrypt-test.d.ts +2 -2
  24. package/dist/examples/decrypt-test.js +78 -69
  25. package/dist/examples/encrypt-test.d.ts +5 -3
  26. package/dist/examples/encrypt-test.js +58 -55
  27. package/dist/handlers/decrypt-handler.d.ts +19 -5
  28. package/dist/handlers/encrypt-handler.d.ts +9 -3
  29. package/dist/handlers/encrypt-handler.js +93 -57
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +2 -2
  32. package/dist/protocols/lit.d.ts +33 -9
  33. package/dist/protocols/lit.js +134 -98
  34. package/dist/test/cid-verification.spec.d.ts +2 -2
  35. package/dist/test/cid-verification.spec.js +341 -313
  36. package/dist/test/crypto-compatibility.spec.d.ts +2 -2
  37. package/dist/test/crypto-compatibility.spec.js +184 -120
  38. package/dist/test/crypto-counter-security.spec.d.ts +2 -2
  39. package/dist/test/crypto-counter-security.spec.js +177 -138
  40. package/dist/test/crypto-streaming.spec.d.ts +2 -2
  41. package/dist/test/crypto-streaming.spec.js +208 -126
  42. package/dist/test/encrypted-metadata.spec.d.ts +2 -2
  43. package/dist/test/encrypted-metadata.spec.js +89 -62
  44. package/dist/test/factories.spec.d.ts +2 -2
  45. package/dist/test/factories.spec.js +275 -139
  46. package/dist/test/file-metadata.spec.d.ts +2 -2
  47. package/dist/test/file-metadata.spec.js +472 -416
  48. package/dist/test/fixtures/test-fixtures.d.ts +25 -20
  49. package/dist/test/fixtures/test-fixtures.js +61 -53
  50. package/dist/test/helpers/test-file-utils.d.ts +19 -14
  51. package/dist/test/helpers/test-file-utils.js +78 -76
  52. package/dist/test/https-enforcement.spec.d.ts +2 -2
  53. package/dist/test/https-enforcement.spec.js +278 -124
  54. package/dist/test/kms-crypto-adapter.spec.d.ts +2 -2
  55. package/dist/test/kms-crypto-adapter.spec.js +473 -304
  56. package/dist/test/lit-crypto-adapter.spec.d.ts +2 -2
  57. package/dist/test/lit-crypto-adapter.spec.js +206 -118
  58. package/dist/test/memory-efficiency.spec.d.ts +2 -2
  59. package/dist/test/memory-efficiency.spec.js +100 -87
  60. package/dist/test/mocks/key-manager.d.ts +71 -38
  61. package/dist/test/mocks/key-manager.js +129 -113
  62. package/dist/test/node-crypto-adapter.spec.d.ts +2 -2
  63. package/dist/test/node-crypto-adapter.spec.js +155 -102
  64. package/dist/test/node-generic-crypto-adapter.spec.d.ts +2 -2
  65. package/dist/test/node-generic-crypto-adapter.spec.js +134 -94
  66. package/dist/test/setup.d.ts +2 -2
  67. package/dist/test/setup.js +8 -9
  68. package/dist/tsconfig.spec.tsbuildinfo +1 -1
  69. package/dist/types.d.ts +219 -181
  70. package/dist/utils/file-metadata.d.ts +19 -13
  71. package/dist/utils.d.ts +14 -5
  72. package/package.json +4 -4
@@ -1,129 +1,211 @@
1
- import './setup.js';
2
- import { test, describe } from 'node:test';
3
- import assert from 'node:assert';
4
- import { GenericAesCtrStreamingCrypto } from '../src/crypto/symmetric/generic-aes-ctr-streaming-crypto.js';
5
- import { createTestFile, streamToUint8Array, } from './helpers/test-file-utils.js';
1
+ import './setup.js'
2
+ import { test, describe } from 'node:test'
3
+ import assert from 'node:assert'
4
+ import { GenericAesCtrStreamingCrypto } from '../src/crypto/symmetric/generic-aes-ctr-streaming-crypto.js'
5
+ import {
6
+ createTestFile,
7
+ streamToUint8Array,
8
+ } from './helpers/test-file-utils.js'
6
9
  // FIXME (fforbeck) - Remove this skip when ready to run streaming crypto tests. It is failing on CI.
7
10
  await describe.skip('Streaming Crypto - Core Functionality', async () => {
8
- await test('should encrypt and decrypt small files correctly', async () => {
9
- const crypto = new GenericAesCtrStreamingCrypto();
10
- const testFile = createTestFile(0.01); // 10KB (ultra-small for memory safety)
11
- // Encrypt
12
- const { key, iv, encryptedStream } = await crypto.encryptStream(testFile);
13
- assert(key instanceof Uint8Array, 'Key should be Uint8Array');
14
- assert.strictEqual(key.length, 32, 'Key should be 32 bytes');
15
- assert(iv instanceof Uint8Array, 'IV should be Uint8Array');
16
- assert.strictEqual(iv.length, 16, 'IV should be 16 bytes');
17
- // Convert stream to bytes
18
- const encryptedBytes = await streamToUint8Array(encryptedStream);
19
- assert.strictEqual(encryptedBytes.length, testFile.size, 'Encrypted size should match original');
20
- // Decrypt
11
+ await test('should encrypt and decrypt small files correctly', async () => {
12
+ const crypto = new GenericAesCtrStreamingCrypto()
13
+ const testFile = createTestFile(0.01) // 10KB (ultra-small for memory safety)
14
+ // Encrypt
15
+ const { key, iv, encryptedStream } = await crypto.encryptStream(testFile)
16
+ assert(key instanceof Uint8Array, 'Key should be Uint8Array')
17
+ assert.strictEqual(key.length, 32, 'Key should be 32 bytes')
18
+ assert(iv instanceof Uint8Array, 'IV should be Uint8Array')
19
+ assert.strictEqual(iv.length, 16, 'IV should be 16 bytes')
20
+ // Convert stream to bytes
21
+ const encryptedBytes = await streamToUint8Array(encryptedStream)
22
+ assert.strictEqual(
23
+ encryptedBytes.length,
24
+ testFile.size,
25
+ 'Encrypted size should match original'
26
+ )
27
+ // Decrypt
28
+ const encryptedForDecrypt = new ReadableStream({
29
+ start(controller) {
30
+ controller.enqueue(encryptedBytes)
31
+ controller.close()
32
+ },
33
+ })
34
+ const decryptedStream = await crypto.decryptStream(
35
+ encryptedForDecrypt,
36
+ key,
37
+ iv
38
+ )
39
+ const decryptedBytes = await streamToUint8Array(decryptedStream)
40
+ // Verify round-trip
41
+ const originalBytes = new Uint8Array(await testFile.arrayBuffer())
42
+ assert.deepStrictEqual(
43
+ decryptedBytes,
44
+ originalBytes,
45
+ 'Decrypted should match original'
46
+ )
47
+ console.log(`✓ Successfully encrypted/decrypted ${testFile.size} bytes`)
48
+ })
49
+ await test('should handle edge cases', async () => {
50
+ const crypto = new GenericAesCtrStreamingCrypto()
51
+ // Empty file
52
+ const emptyFile = new Blob([])
53
+ const { encryptedStream: emptyEncrypted } = await crypto.encryptStream(
54
+ emptyFile
55
+ )
56
+ const emptyBytes = await streamToUint8Array(emptyEncrypted)
57
+ assert.strictEqual(
58
+ emptyBytes.length,
59
+ 0,
60
+ 'Empty file should produce empty encrypted data'
61
+ )
62
+ // Single byte
63
+ const singleByteFile = new Blob([new Uint8Array([42])])
64
+ const { key, iv, encryptedStream } = await crypto.encryptStream(
65
+ singleByteFile
66
+ )
67
+ const encryptedBytes = await streamToUint8Array(encryptedStream)
68
+ assert.strictEqual(
69
+ encryptedBytes.length,
70
+ 1,
71
+ 'Single byte should produce single encrypted byte'
72
+ )
73
+ // Decrypt single byte
74
+ const encryptedForDecrypt = new ReadableStream({
75
+ start(controller) {
76
+ controller.enqueue(encryptedBytes)
77
+ controller.close()
78
+ },
79
+ })
80
+ const decryptedStream = await crypto.decryptStream(
81
+ encryptedForDecrypt,
82
+ key,
83
+ iv
84
+ )
85
+ const decryptedBytes = await streamToUint8Array(decryptedStream)
86
+ assert.deepStrictEqual(
87
+ decryptedBytes,
88
+ new Uint8Array([42]),
89
+ 'Should decrypt to original byte'
90
+ )
91
+ console.log('✓ Edge cases handled correctly')
92
+ })
93
+ await test('should handle medium-sized files without issues', async () => {
94
+ try {
95
+ const crypto = new GenericAesCtrStreamingCrypto()
96
+ // Test with progressively larger files to show streaming works consistently
97
+ // Reduced sizes for CI stability while still testing streaming functionality
98
+ const testSizes = [0.5, 1, 2] // MB
99
+ for (const sizeMB of testSizes) {
100
+ console.log(`Testing ${sizeMB}MB file...`)
101
+ const testFile = createTestFile(sizeMB)
102
+ const { key, iv, encryptedStream } = await crypto.encryptStream(
103
+ testFile
104
+ )
105
+ // Convert encrypted stream to bytes first
106
+ const encryptedBytes = await streamToUint8Array(encryptedStream)
107
+ // Create a new stream from the encrypted bytes for decryption
21
108
  const encryptedForDecrypt = new ReadableStream({
22
- start(controller) {
23
- controller.enqueue(encryptedBytes);
24
- controller.close();
25
- },
26
- });
27
- const decryptedStream = await crypto.decryptStream(encryptedForDecrypt, key, iv);
28
- const decryptedBytes = await streamToUint8Array(decryptedStream);
29
- // Verify round-trip
30
- const originalBytes = new Uint8Array(await testFile.arrayBuffer());
31
- assert.deepStrictEqual(decryptedBytes, originalBytes, 'Decrypted should match original');
32
- console.log(`✓ Successfully encrypted/decrypted ${testFile.size} bytes`);
33
- });
34
- await test('should handle edge cases', async () => {
35
- const crypto = new GenericAesCtrStreamingCrypto();
36
- // Empty file
37
- const emptyFile = new Blob([]);
38
- const { encryptedStream: emptyEncrypted } = await crypto.encryptStream(emptyFile);
39
- const emptyBytes = await streamToUint8Array(emptyEncrypted);
40
- assert.strictEqual(emptyBytes.length, 0, 'Empty file should produce empty encrypted data');
41
- // Single byte
42
- const singleByteFile = new Blob([new Uint8Array([42])]);
43
- const { key, iv, encryptedStream } = await crypto.encryptStream(singleByteFile);
44
- const encryptedBytes = await streamToUint8Array(encryptedStream);
45
- assert.strictEqual(encryptedBytes.length, 1, 'Single byte should produce single encrypted byte');
46
- // Decrypt single byte
47
- const encryptedForDecrypt = new ReadableStream({
48
- start(controller) {
49
- controller.enqueue(encryptedBytes);
50
- controller.close();
51
- },
52
- });
53
- const decryptedStream = await crypto.decryptStream(encryptedForDecrypt, key, iv);
54
- const decryptedBytes = await streamToUint8Array(decryptedStream);
55
- assert.deepStrictEqual(decryptedBytes, new Uint8Array([42]), 'Should decrypt to original byte');
56
- console.log('✓ Edge cases handled correctly');
57
- });
58
- await test('should handle medium-sized files without issues', async () => {
59
- try {
60
- const crypto = new GenericAesCtrStreamingCrypto();
61
- // Test with progressively larger files to show streaming works consistently
62
- // Reduced sizes for CI stability while still testing streaming functionality
63
- const testSizes = [0.5, 1, 2]; // MB
64
- for (const sizeMB of testSizes) {
65
- console.log(`Testing ${sizeMB}MB file...`);
66
- const testFile = createTestFile(sizeMB);
67
- const { key, iv, encryptedStream } = await crypto.encryptStream(testFile);
68
- // Convert encrypted stream to bytes first
69
- const encryptedBytes = await streamToUint8Array(encryptedStream);
70
- // Create a new stream from the encrypted bytes for decryption
71
- const encryptedForDecrypt = new ReadableStream({
72
- start(controller) {
73
- controller.enqueue(encryptedBytes);
74
- controller.close();
75
- },
76
- });
77
- const decryptedStream = await crypto.decryptStream(encryptedForDecrypt, key, iv);
78
- const decryptedBytes = await streamToUint8Array(decryptedStream);
79
- assert.strictEqual(decryptedBytes.length, sizeMB * 1024 * 1024, `Decrypted file size mismatch for ${sizeMB}MB`);
80
- console.log(`✓ ${sizeMB}MB file encrypted and decrypted successfully`);
81
- }
82
- console.log(' Medium-sized files handled without issues');
83
- }
84
- catch (err) {
85
- console.error('Test error (type):', typeof err, err && err.constructor && err.constructor.name);
86
- console.error('Test error (keys):', err && Object.keys(err));
87
- console.error('Test error (string):', String(err));
88
- console.log(err);
89
- assert.fail('Unable to test medium-sized files');
90
- }
91
- });
92
- await test('should use proper counter arithmetic', async () => {
93
- const crypto = new GenericAesCtrStreamingCrypto();
94
- // Test counter increment function directly
95
- const baseCounter = new Uint8Array([
96
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97
- ]);
98
- // Increment by 1
99
- const counter1 = crypto.incrementCounter(baseCounter, 1);
100
- assert.deepStrictEqual(counter1, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]), 'Should increment last byte by 1');
101
- // Increment by 255
102
- const counter255 = crypto.incrementCounter(baseCounter, 255);
103
- assert.deepStrictEqual(counter255, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255]), 'Should increment last byte by 255');
104
- // Increment by 256 (should carry)
105
- const counter256 = crypto.incrementCounter(baseCounter, 256);
106
- assert.deepStrictEqual(counter256, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]), 'Should carry to second-to-last byte');
107
- console.log(' Counter arithmetic works correctly');
108
- });
109
- await test('should implement complete interface', async () => {
110
- const crypto = new GenericAesCtrStreamingCrypto();
111
- // Check all required methods exist
112
- assert(typeof crypto.generateKey === 'function', 'Should have generateKey method');
113
- assert(typeof crypto.encryptStream === 'function', 'Should have encryptStream method');
114
- assert(typeof crypto.decryptStream === 'function', 'Should have decryptStream method');
115
- assert(typeof crypto.combineKeyAndIV === 'function', 'Should have combineKeyAndIV method');
116
- assert(typeof crypto.splitKeyAndIV === 'function', 'Should have splitKeyAndIV method');
117
- assert(typeof crypto.incrementCounter === 'function', 'Should have incrementCounter method');
118
- // Test combine/split methods
119
- const key = await crypto.generateKey();
120
- const iv = globalThis.crypto.getRandomValues(new Uint8Array(16));
121
- const combined = crypto.combineKeyAndIV(key, iv);
122
- assert.strictEqual(combined.length, 48, 'Combined should be 48 bytes (32 key + 16 IV)');
123
- const { key: splitKey, iv: splitIV } = crypto.splitKeyAndIV(combined);
124
- assert.deepStrictEqual(splitKey, key, 'Split key should match original');
125
- assert.deepStrictEqual(splitIV, iv, 'Split IV should match original');
126
- console.log('Complete interface implemented correctly');
127
- });
128
- });
129
- //# sourceMappingURL=crypto-streaming.spec.js.map
109
+ start(controller) {
110
+ controller.enqueue(encryptedBytes)
111
+ controller.close()
112
+ },
113
+ })
114
+ const decryptedStream = await crypto.decryptStream(
115
+ encryptedForDecrypt,
116
+ key,
117
+ iv
118
+ )
119
+ const decryptedBytes = await streamToUint8Array(decryptedStream)
120
+ assert.strictEqual(
121
+ decryptedBytes.length,
122
+ sizeMB * 1024 * 1024,
123
+ `Decrypted file size mismatch for ${sizeMB}MB`
124
+ )
125
+ console.log(`✓ ${sizeMB}MB file encrypted and decrypted successfully`)
126
+ }
127
+ console.log(' Medium-sized files handled without issues')
128
+ } catch (err) {
129
+ console.error(
130
+ 'Test error (type):',
131
+ typeof err,
132
+ err && err.constructor && err.constructor.name
133
+ )
134
+ console.error('Test error (keys):', err && Object.keys(err))
135
+ console.error('Test error (string):', String(err))
136
+ console.log(err)
137
+ assert.fail('Unable to test medium-sized files')
138
+ }
139
+ })
140
+ await test('should use proper counter arithmetic', async () => {
141
+ const crypto = new GenericAesCtrStreamingCrypto()
142
+ // Test counter increment function directly
143
+ const baseCounter = new Uint8Array([
144
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145
+ ])
146
+ // Increment by 1
147
+ const counter1 = crypto.incrementCounter(baseCounter, 1)
148
+ assert.deepStrictEqual(
149
+ counter1,
150
+ new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]),
151
+ 'Should increment last byte by 1'
152
+ )
153
+ // Increment by 255
154
+ const counter255 = crypto.incrementCounter(baseCounter, 255)
155
+ assert.deepStrictEqual(
156
+ counter255,
157
+ new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255]),
158
+ 'Should increment last byte by 255'
159
+ )
160
+ // Increment by 256 (should carry)
161
+ const counter256 = crypto.incrementCounter(baseCounter, 256)
162
+ assert.deepStrictEqual(
163
+ counter256,
164
+ new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]),
165
+ 'Should carry to second-to-last byte'
166
+ )
167
+ console.log('✓ Counter arithmetic works correctly')
168
+ })
169
+ await test('should implement complete interface', async () => {
170
+ const crypto = new GenericAesCtrStreamingCrypto()
171
+ // Check all required methods exist
172
+ assert(
173
+ typeof crypto.generateKey === 'function',
174
+ 'Should have generateKey method'
175
+ )
176
+ assert(
177
+ typeof crypto.encryptStream === 'function',
178
+ 'Should have encryptStream method'
179
+ )
180
+ assert(
181
+ typeof crypto.decryptStream === 'function',
182
+ 'Should have decryptStream method'
183
+ )
184
+ assert(
185
+ typeof crypto.combineKeyAndIV === 'function',
186
+ 'Should have combineKeyAndIV method'
187
+ )
188
+ assert(
189
+ typeof crypto.splitKeyAndIV === 'function',
190
+ 'Should have splitKeyAndIV method'
191
+ )
192
+ assert(
193
+ typeof crypto.incrementCounter === 'function',
194
+ 'Should have incrementCounter method'
195
+ )
196
+ // Test combine/split methods
197
+ const key = await crypto.generateKey()
198
+ const iv = globalThis.crypto.getRandomValues(new Uint8Array(16))
199
+ const combined = crypto.combineKeyAndIV(key, iv)
200
+ assert.strictEqual(
201
+ combined.length,
202
+ 48,
203
+ 'Combined should be 48 bytes (32 key + 16 IV)'
204
+ )
205
+ const { key: splitKey, iv: splitIV } = crypto.splitKeyAndIV(combined)
206
+ assert.deepStrictEqual(splitKey, key, 'Split key should match original')
207
+ assert.deepStrictEqual(splitIV, iv, 'Split IV should match original')
208
+ console.log('Complete interface implemented correctly')
209
+ })
210
+ })
211
+ //# sourceMappingURL=crypto-streaming.spec.js.map
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=encrypted-metadata.spec.d.ts.map
1
+ export {}
2
+ //# sourceMappingURL=encrypted-metadata.spec.d.ts.map
@@ -1,68 +1,95 @@
1
- import assert from 'node:assert';
2
- import { describe, it } from 'node:test';
3
- import * as Result from '@storacha/client/result';
4
- import * as Types from '../src/types.js';
5
- import { create, extract } from '../src/core/metadata/encrypted-metadata.js';
6
- import { CID } from 'multiformats';
1
+ import assert from 'node:assert'
2
+ import { describe, it } from 'node:test'
3
+ import * as Result from '@storacha/client/result'
4
+ import * as Types from '../src/types.js'
5
+ import { create, extract } from '../src/core/metadata/encrypted-metadata.js'
6
+ import { CID } from 'multiformats'
7
7
  /** @type {Types.LitMetadataInput} */
8
8
  const encryptedMetadataInput = {
9
- encryptedDataCID: 'bafkreids275u5ex6xfw7d4k67afej43c6rhm2kzdox2z6or4jxrndgevae',
10
- identityBoundCiphertext: 'mF3OPa9dQ0wO4B1/XylmAV/eaHhLtM3JUPIbS175bvmqGaJUYroyDbsytV29q0cLD4XCpCRfCinntASNg9s730FIM7f4Mw2hVWeJ5g4akFA6BoZoaKgDC5Ln6MOQK5Ymb1y6No7um7Bn4uIIJTYNuUukDQvVxzY8LcRBc2ySR1Md+VSGzmyEgyvHtAI=',
11
- plaintextKeyHash: '15f39e9a977cca43f16f3cd25237d711cd8130ff9763197b29df52a198607206',
12
- accessControlConditions: [
13
- {
14
- contractAddress: '',
15
- standardContractType: '',
16
- chain: 'ethereum',
17
- method: '',
18
- parameters: [
19
- ':currentActionIpfsId',
20
- 'did:key:z6MktfnQz8Kcz5nsC65oyXWFXhbbAZQavjg6LYuHgv4YbxzN',
21
- ],
22
- returnValueTest: {
23
- comparator: '=',
24
- value: 'QmPFrQGo5RAtdSTZ4bkaeDHVGrmy2TeEUwTu4LuVAPHiMd',
25
- },
26
- },
27
- ],
28
- };
9
+ encryptedDataCID:
10
+ 'bafkreids275u5ex6xfw7d4k67afej43c6rhm2kzdox2z6or4jxrndgevae',
11
+ identityBoundCiphertext:
12
+ 'mF3OPa9dQ0wO4B1/XylmAV/eaHhLtM3JUPIbS175bvmqGaJUYroyDbsytV29q0cLD4XCpCRfCinntASNg9s730FIM7f4Mw2hVWeJ5g4akFA6BoZoaKgDC5Ln6MOQK5Ymb1y6No7um7Bn4uIIJTYNuUukDQvVxzY8LcRBc2ySR1Md+VSGzmyEgyvHtAI=',
13
+ plaintextKeyHash:
14
+ '15f39e9a977cca43f16f3cd25237d711cd8130ff9763197b29df52a198607206',
15
+ accessControlConditions: [
16
+ {
17
+ contractAddress: '',
18
+ standardContractType: '',
19
+ chain: 'ethereum',
20
+ method: '',
21
+ parameters: [
22
+ ':currentActionIpfsId',
23
+ 'did:key:z6MktfnQz8Kcz5nsC65oyXWFXhbbAZQavjg6LYuHgv4YbxzN',
24
+ ],
25
+ returnValueTest: {
26
+ comparator: '=',
27
+ value: 'QmPFrQGo5RAtdSTZ4bkaeDHVGrmy2TeEUwTu4LuVAPHiMd',
28
+ },
29
+ },
30
+ ],
31
+ }
29
32
  /** @type {Types.KMSMetadata} */
30
33
  const kmsMetadataInput = {
31
- encryptedDataCID: CID.parse('bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'),
32
- encryptedSymmetricKey: 'bXlLTVNLZXlCeXRlcw==', // 'myKMSKeyBytes' in base64 for example
33
- space: 'did:key:z6MktfnQz8Kcz5nsC65oyXWFXhbbAZQavjg6LYuHgv4YbxzN',
34
- kms: {
35
- provider: 'google-kms',
36
- keyId: 'test-key',
37
- algorithm: 'RSA-OAEP-2048-SHA256',
38
- },
39
- };
34
+ encryptedDataCID: CID.parse(
35
+ 'bafkreihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku'
36
+ ),
37
+ encryptedSymmetricKey: 'bXlLTVNLZXlCeXRlcw==', // 'myKMSKeyBytes' in base64 for example
38
+ space: 'did:key:z6MktfnQz8Kcz5nsC65oyXWFXhbbAZQavjg6LYuHgv4YbxzN',
39
+ kms: {
40
+ provider: 'google-kms',
41
+ keyId: 'test-key',
42
+ algorithm: 'RSA-OAEP-2048-SHA256',
43
+ },
44
+ }
40
45
  await describe('LitEncrypted Metadata', async () => {
41
- await it('should create a valid block content', async () => {
42
- const encryptedMetadata = create('lit', encryptedMetadataInput);
43
- const block = await encryptedMetadata.archiveBlock();
44
- // Encode the block into a CAR file
45
- const car = await import('@ucanto/core').then((m) => m.CAR.encode({ roots: [block] }));
46
- // Use the extract function to get the JSON object
47
- const extractedData = Result.unwrap(extract(car));
48
- const extractedDataJson = extractedData.toJSON();
49
- assert.equal(extractedDataJson.identityBoundCiphertext, encryptedMetadataInput.identityBoundCiphertext);
50
- assert.equal(extractedDataJson.plaintextKeyHash, encryptedMetadataInput.plaintextKeyHash);
51
- assert.equal(extractedDataJson.encryptedDataCID, encryptedMetadataInput.encryptedDataCID);
52
- assert.deepEqual(extractedDataJson.accessControlConditions, encryptedMetadataInput.accessControlConditions);
53
- });
54
- });
46
+ await it('should create a valid block content', async () => {
47
+ const encryptedMetadata = create('lit', encryptedMetadataInput)
48
+ const block = await encryptedMetadata.archiveBlock()
49
+ // Encode the block into a CAR file
50
+ const car = await import('@ucanto/core').then((m) =>
51
+ m.CAR.encode({ roots: [block] })
52
+ )
53
+ // Use the extract function to get the JSON object
54
+ const extractedData = Result.unwrap(extract(car))
55
+ const extractedDataJson = extractedData.toJSON()
56
+ assert.equal(
57
+ extractedDataJson.identityBoundCiphertext,
58
+ encryptedMetadataInput.identityBoundCiphertext
59
+ )
60
+ assert.equal(
61
+ extractedDataJson.plaintextKeyHash,
62
+ encryptedMetadataInput.plaintextKeyHash
63
+ )
64
+ assert.equal(
65
+ extractedDataJson.encryptedDataCID,
66
+ encryptedMetadataInput.encryptedDataCID
67
+ )
68
+ assert.deepEqual(
69
+ extractedDataJson.accessControlConditions,
70
+ encryptedMetadataInput.accessControlConditions
71
+ )
72
+ })
73
+ })
55
74
  await describe('KMS Encrypted Metadata', async () => {
56
- await it('should create a valid block content', async () => {
57
- const kmsMetadata = create('kms', kmsMetadataInput);
58
- const block = await kmsMetadata.archiveBlock();
59
- const car = await import('@ucanto/core').then((m) => m.CAR.encode({ roots: [block] }));
60
- const extractedData = Result.unwrap(extract(car));
61
- const extractedDataJson = extractedData.toJSON();
62
- assert.equal(extractedDataJson.encryptedSymmetricKey, kmsMetadataInput.encryptedSymmetricKey);
63
- assert.equal(extractedDataJson.encryptedDataCID, kmsMetadataInput.encryptedDataCID);
64
- assert.equal(extractedDataJson.space, kmsMetadataInput.space);
65
- assert.deepEqual(extractedDataJson.kms, kmsMetadataInput.kms);
66
- });
67
- });
68
- //# sourceMappingURL=encrypted-metadata.spec.js.map
75
+ await it('should create a valid block content', async () => {
76
+ const kmsMetadata = create('kms', kmsMetadataInput)
77
+ const block = await kmsMetadata.archiveBlock()
78
+ const car = await import('@ucanto/core').then((m) =>
79
+ m.CAR.encode({ roots: [block] })
80
+ )
81
+ const extractedData = Result.unwrap(extract(car))
82
+ const extractedDataJson = extractedData.toJSON()
83
+ assert.equal(
84
+ extractedDataJson.encryptedSymmetricKey,
85
+ kmsMetadataInput.encryptedSymmetricKey
86
+ )
87
+ assert.equal(
88
+ extractedDataJson.encryptedDataCID,
89
+ kmsMetadataInput.encryptedDataCID
90
+ )
91
+ assert.equal(extractedDataJson.space, kmsMetadataInput.space)
92
+ assert.deepEqual(extractedDataJson.kms, kmsMetadataInput.kms)
93
+ })
94
+ })
95
+ //# sourceMappingURL=encrypted-metadata.spec.js.map
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=factories.spec.d.ts.map
1
+ export {}
2
+ //# sourceMappingURL=factories.spec.d.ts.map