@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,142 +1,278 @@
1
- import './setup.js';
2
- import { test, describe } from 'node:test';
3
- import assert from 'node:assert';
4
- import { createGenericKMSAdapter, createGenericLitAdapter, createNodeLitAdapter, } from '../src/crypto/factories.node.js';
5
- import { GenericAesCtrStreamingCrypto } from '../src/crypto/symmetric/generic-aes-ctr-streaming-crypto.js';
6
- import { NodeAesCbcCrypto } from '../src/crypto/symmetric/node-aes-cbc-crypto.js';
7
- import { LitCryptoAdapter } from '../src/crypto/adapters/lit-crypto-adapter.js';
8
- import { KMSCryptoAdapter } from '../src/crypto/adapters/kms-crypto-adapter.js';
1
+ import './setup.js'
2
+ import { test, describe } from 'node:test'
3
+ import assert from 'node:assert'
4
+ import {
5
+ createGenericKMSAdapter,
6
+ createGenericLitAdapter,
7
+ createNodeLitAdapter,
8
+ } from '../src/crypto/factories.node.js'
9
+ import { GenericAesCtrStreamingCrypto } from '../src/crypto/symmetric/generic-aes-ctr-streaming-crypto.js'
10
+ import { NodeAesCbcCrypto } from '../src/crypto/symmetric/node-aes-cbc-crypto.js'
11
+ import { LitCryptoAdapter } from '../src/crypto/adapters/lit-crypto-adapter.js'
12
+ import { KMSCryptoAdapter } from '../src/crypto/adapters/kms-crypto-adapter.js'
9
13
  // Mock Lit client for testing
10
14
  const mockLitClient = /** @type {any} */ ({
11
- connect: () => Promise.resolve(),
12
- disconnect: () => Promise.resolve(),
13
- });
15
+ connect: () => Promise.resolve(),
16
+ disconnect: () => Promise.resolve(),
17
+ })
14
18
  await describe('Crypto Factory Functions', async () => {
15
- await describe('createBrowserLitAdapter', async () => {
16
- await test('should create LitCryptoAdapter with streaming crypto', async () => {
17
- const adapter = createGenericLitAdapter(mockLitClient);
18
- // Verify adapter type
19
- assert(adapter instanceof LitCryptoAdapter, 'Should create LitCryptoAdapter instance');
20
- // Verify symmetric crypto implementation
21
- assert(adapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto, 'Should use GenericAesCtrStreamingCrypto for browser environment');
22
- // Verify lit client is passed through
23
- assert.strictEqual(adapter.litClient, mockLitClient, 'Should pass through the lit client');
24
- });
25
- await test('should create adapter with required interface methods', async () => {
26
- const adapter = createGenericLitAdapter(mockLitClient);
27
- // Verify adapter has all required methods
28
- assert(typeof adapter.encryptStream === 'function', 'Should have encryptStream method');
29
- assert(typeof adapter.decryptStream === 'function', 'Should have decryptStream method');
30
- assert(typeof adapter.encryptSymmetricKey === 'function', 'Should have encryptSymmetricKey method');
31
- assert(typeof adapter.decryptSymmetricKey === 'function', 'Should have decryptSymmetricKey method');
32
- assert(typeof adapter.extractEncryptedMetadata === 'function', 'Should have extractEncryptedMetadata method');
33
- assert(typeof adapter.getEncryptedKey === 'function', 'Should have getEncryptedKey method');
34
- });
35
- await test('should handle null or undefined lit client gracefully', async () => {
36
- // This should still create the adapter (validation happens at runtime)
37
- const adapter = createGenericLitAdapter(/** @type {any} */ (null));
38
- assert(adapter instanceof LitCryptoAdapter, 'Should create adapter even with null client');
39
- });
40
- });
41
- await describe('createNodeLitAdapter', async () => {
42
- await test('should create LitCryptoAdapter with Node crypto', async () => {
43
- const adapter = createNodeLitAdapter(mockLitClient);
44
- // Verify adapter type
45
- assert(adapter instanceof LitCryptoAdapter, 'Should create LitCryptoAdapter instance');
46
- // Verify symmetric crypto implementation
47
- assert(adapter.symmetricCrypto instanceof NodeAesCbcCrypto, 'Should use NodeAesCbcCrypto for Node.js environment');
48
- // Verify lit client is passed through
49
- assert.strictEqual(adapter.litClient, mockLitClient, 'Should pass through the lit client');
50
- });
51
- });
52
- await describe('createBrowserKMSAdapter', async () => {
53
- await test('should create KMSCryptoAdapter with streaming crypto', async () => {
54
- const keyManagerServiceURL = 'https://gateway.example.com';
55
- const keyManagerServiceDID = 'did:web:gateway.example.com';
56
- const adapter = createGenericKMSAdapter(keyManagerServiceURL, keyManagerServiceDID);
57
- // Verify adapter type
58
- assert(adapter instanceof KMSCryptoAdapter, 'Should create KMSCryptoAdapter instance');
59
- // Verify symmetric crypto implementation
60
- assert(adapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto, 'Should use GenericAesCtrStreamingCrypto for browser environment');
61
- // Verify configuration is passed through
62
- assert.strictEqual(adapter.keyManagerServiceURL.toString(), keyManagerServiceURL + '/', 'Should set the key manager service URL');
63
- assert.strictEqual(adapter.keyManagerServiceDID.did(), keyManagerServiceDID, 'Should set the key manager service DID');
64
- });
65
- await test('should accept URL object for gateway URL', async () => {
66
- const keyManagerServiceURL = new URL('https://gateway.example.com');
67
- const keyManagerServiceDID = 'did:web:gateway.example.com';
68
- const adapter = createGenericKMSAdapter(keyManagerServiceURL, keyManagerServiceDID);
69
- assert(adapter instanceof KMSCryptoAdapter, 'Should create KMSCryptoAdapter with URL object');
70
- assert.strictEqual(adapter.keyManagerServiceURL.toString(), keyManagerServiceURL.toString(), 'Should handle URL object input');
71
- });
72
- await test('should enforce HTTPS for security', async () => {
73
- const httpKeyManagerServiceURL = 'http://insecure.example.com';
74
- const keyManagerServiceDID = 'did:web:example.com';
75
- assert.throws(() => createGenericKMSAdapter(httpKeyManagerServiceURL, keyManagerServiceDID), /Key manager service must use HTTPS protocol for security/, 'Should reject HTTP URLs for security');
76
- });
77
- await test('should allow HTTP with explicit insecure option', async () => {
78
- // Note: The current implementation doesn't expose options in the factory
79
- // but we can test this through direct adapter construction
80
- const httpKeyManagerServiceURL = 'http://localhost:3000';
81
- const keyManagerServiceDID = 'did:web:localhost';
82
- assert.throws(() => createGenericKMSAdapter(httpKeyManagerServiceURL, keyManagerServiceDID), /Key manager service must use HTTPS protocol for security/, 'Should reject HTTP URLs even for localhost by default');
83
- });
84
- await test('should have all required KMS adapter methods', async () => {
85
- const adapter = createGenericKMSAdapter('https://gateway.example.com', 'did:web:gateway.example.com');
86
- // Verify adapter has all required methods
87
- assert(typeof adapter.encryptStream === 'function', 'Should have encryptStream method');
88
- assert(typeof adapter.decryptStream === 'function', 'Should have decryptStream method');
89
- assert(typeof adapter.encryptSymmetricKey === 'function', 'Should have encryptSymmetricKey method');
90
- assert(typeof adapter.decryptSymmetricKey === 'function', 'Should have decryptSymmetricKey method');
91
- });
92
- });
93
- await describe('Factory Function Consistency', async () => {
94
- await test('browser factories should use streaming crypto', async () => {
95
- const litAdapter = createGenericLitAdapter(mockLitClient);
96
- const kmsAdapter = createGenericKMSAdapter('https://gateway.example.com', 'did:web:gateway.example.com');
97
- assert(litAdapter.symmetricCrypto.constructor.name ===
98
- 'GenericAesCtrStreamingCrypto', 'Browser Lit adapter should use streaming crypto');
99
- assert(kmsAdapter.symmetricCrypto.constructor.name ===
100
- 'GenericAesCtrStreamingCrypto', 'Browser KMS adapter should use streaming crypto');
101
- });
102
- await test('node factories should use Node crypto', async () => {
103
- const litAdapter = createNodeLitAdapter(mockLitClient);
104
- assert(litAdapter.symmetricCrypto.constructor.name === 'NodeAesCbcCrypto', 'Node Lit adapter should use Node crypto');
105
- });
106
- await test('all adapters should implement the same interface', async () => {
107
- const adapters = [
108
- createGenericLitAdapter(mockLitClient),
109
- createNodeLitAdapter(mockLitClient),
110
- createGenericKMSAdapter('https://gateway.example.com', 'did:web:gateway.example.com'),
111
- createGenericKMSAdapter('https://gateway.example.com', 'did:web:gateway.example.com'),
112
- ];
113
- const requiredMethods = [
114
- 'encryptStream',
115
- 'decryptStream',
116
- 'encryptSymmetricKey',
117
- 'decryptSymmetricKey',
118
- 'extractEncryptedMetadata',
119
- 'getEncryptedKey',
120
- ];
121
- for (const adapter of adapters) {
122
- for (const method of requiredMethods) {
123
- assert(typeof ( /** @type {any} */(adapter)[method]) === 'function', `${adapter.constructor.name} should have ${method} method`);
124
- }
125
- }
126
- });
127
- });
128
- await describe('Memory Usage Verification', async () => {
129
- await test('browser adapters should use memory-efficient streaming crypto', async () => {
130
- const litAdapter = createGenericLitAdapter(mockLitClient);
131
- const kmsAdapter = createGenericKMSAdapter('https://gateway.example.com', 'did:web:gateway.example.com');
132
- // Verify both use the streaming implementation
133
- assert(litAdapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto, 'Lit adapter should use streaming crypto for memory efficiency');
134
- assert(kmsAdapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto, 'KMS adapter should use streaming crypto for memory efficiency');
135
- // Verify they have the streaming characteristics
136
- const testBlob = new Blob([new Uint8Array(1024)]); // 1KB test
137
- const litResult = await litAdapter.encryptStream(testBlob);
138
- assert(litResult.encryptedStream instanceof ReadableStream, 'Should return ReadableStream for streaming');
139
- });
140
- });
141
- });
142
- //# sourceMappingURL=factories.spec.js.map
19
+ await describe('createBrowserLitAdapter', async () => {
20
+ await test('should create LitCryptoAdapter with streaming crypto', async () => {
21
+ const adapter = createGenericLitAdapter(mockLitClient)
22
+ // Verify adapter type
23
+ assert(
24
+ adapter instanceof LitCryptoAdapter,
25
+ 'Should create LitCryptoAdapter instance'
26
+ )
27
+ // Verify symmetric crypto implementation
28
+ assert(
29
+ adapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto,
30
+ 'Should use GenericAesCtrStreamingCrypto for browser environment'
31
+ )
32
+ // Verify lit client is passed through
33
+ assert.strictEqual(
34
+ adapter.litClient,
35
+ mockLitClient,
36
+ 'Should pass through the lit client'
37
+ )
38
+ })
39
+ await test('should create adapter with required interface methods', async () => {
40
+ const adapter = createGenericLitAdapter(mockLitClient)
41
+ // Verify adapter has all required methods
42
+ assert(
43
+ typeof adapter.encryptStream === 'function',
44
+ 'Should have encryptStream method'
45
+ )
46
+ assert(
47
+ typeof adapter.decryptStream === 'function',
48
+ 'Should have decryptStream method'
49
+ )
50
+ assert(
51
+ typeof adapter.encryptSymmetricKey === 'function',
52
+ 'Should have encryptSymmetricKey method'
53
+ )
54
+ assert(
55
+ typeof adapter.decryptSymmetricKey === 'function',
56
+ 'Should have decryptSymmetricKey method'
57
+ )
58
+ assert(
59
+ typeof adapter.extractEncryptedMetadata === 'function',
60
+ 'Should have extractEncryptedMetadata method'
61
+ )
62
+ assert(
63
+ typeof adapter.getEncryptedKey === 'function',
64
+ 'Should have getEncryptedKey method'
65
+ )
66
+ })
67
+ await test('should handle null or undefined lit client gracefully', async () => {
68
+ // This should still create the adapter (validation happens at runtime)
69
+ const adapter = createGenericLitAdapter(/** @type {any} */ (null))
70
+ assert(
71
+ adapter instanceof LitCryptoAdapter,
72
+ 'Should create adapter even with null client'
73
+ )
74
+ })
75
+ })
76
+ await describe('createNodeLitAdapter', async () => {
77
+ await test('should create LitCryptoAdapter with Node crypto', async () => {
78
+ const adapter = createNodeLitAdapter(mockLitClient)
79
+ // Verify adapter type
80
+ assert(
81
+ adapter instanceof LitCryptoAdapter,
82
+ 'Should create LitCryptoAdapter instance'
83
+ )
84
+ // Verify symmetric crypto implementation
85
+ assert(
86
+ adapter.symmetricCrypto instanceof NodeAesCbcCrypto,
87
+ 'Should use NodeAesCbcCrypto for Node.js environment'
88
+ )
89
+ // Verify lit client is passed through
90
+ assert.strictEqual(
91
+ adapter.litClient,
92
+ mockLitClient,
93
+ 'Should pass through the lit client'
94
+ )
95
+ })
96
+ })
97
+ await describe('createBrowserKMSAdapter', async () => {
98
+ await test('should create KMSCryptoAdapter with streaming crypto', async () => {
99
+ const keyManagerServiceURL = 'https://gateway.example.com'
100
+ const keyManagerServiceDID = 'did:web:gateway.example.com'
101
+ const adapter = createGenericKMSAdapter(
102
+ keyManagerServiceURL,
103
+ keyManagerServiceDID
104
+ )
105
+ // Verify adapter type
106
+ assert(
107
+ adapter instanceof KMSCryptoAdapter,
108
+ 'Should create KMSCryptoAdapter instance'
109
+ )
110
+ // Verify symmetric crypto implementation
111
+ assert(
112
+ adapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto,
113
+ 'Should use GenericAesCtrStreamingCrypto for browser environment'
114
+ )
115
+ // Verify configuration is passed through
116
+ assert.strictEqual(
117
+ adapter.keyManagerServiceURL.toString(),
118
+ keyManagerServiceURL + '/',
119
+ 'Should set the key manager service URL'
120
+ )
121
+ assert.strictEqual(
122
+ adapter.keyManagerServiceDID.did(),
123
+ keyManagerServiceDID,
124
+ 'Should set the key manager service DID'
125
+ )
126
+ })
127
+ await test('should accept URL object for gateway URL', async () => {
128
+ const keyManagerServiceURL = new URL('https://gateway.example.com')
129
+ const keyManagerServiceDID = 'did:web:gateway.example.com'
130
+ const adapter = createGenericKMSAdapter(
131
+ keyManagerServiceURL,
132
+ keyManagerServiceDID
133
+ )
134
+ assert(
135
+ adapter instanceof KMSCryptoAdapter,
136
+ 'Should create KMSCryptoAdapter with URL object'
137
+ )
138
+ assert.strictEqual(
139
+ adapter.keyManagerServiceURL.toString(),
140
+ keyManagerServiceURL.toString(),
141
+ 'Should handle URL object input'
142
+ )
143
+ })
144
+ await test('should enforce HTTPS for security', async () => {
145
+ const httpKeyManagerServiceURL = 'http://insecure.example.com'
146
+ const keyManagerServiceDID = 'did:web:example.com'
147
+ assert.throws(
148
+ () =>
149
+ createGenericKMSAdapter(
150
+ httpKeyManagerServiceURL,
151
+ keyManagerServiceDID
152
+ ),
153
+ /Key manager service must use HTTPS protocol for security/,
154
+ 'Should reject HTTP URLs for security'
155
+ )
156
+ })
157
+ await test('should allow HTTP with explicit insecure option', async () => {
158
+ // Note: The current implementation doesn't expose options in the factory
159
+ // but we can test this through direct adapter construction
160
+ const httpKeyManagerServiceURL = 'http://localhost:3000'
161
+ const keyManagerServiceDID = 'did:web:localhost'
162
+ assert.throws(
163
+ () =>
164
+ createGenericKMSAdapter(
165
+ httpKeyManagerServiceURL,
166
+ keyManagerServiceDID
167
+ ),
168
+ /Key manager service must use HTTPS protocol for security/,
169
+ 'Should reject HTTP URLs even for localhost by default'
170
+ )
171
+ })
172
+ await test('should have all required KMS adapter methods', async () => {
173
+ const adapter = createGenericKMSAdapter(
174
+ 'https://gateway.example.com',
175
+ 'did:web:gateway.example.com'
176
+ )
177
+ // Verify adapter has all required methods
178
+ assert(
179
+ typeof adapter.encryptStream === 'function',
180
+ 'Should have encryptStream method'
181
+ )
182
+ assert(
183
+ typeof adapter.decryptStream === 'function',
184
+ 'Should have decryptStream method'
185
+ )
186
+ assert(
187
+ typeof adapter.encryptSymmetricKey === 'function',
188
+ 'Should have encryptSymmetricKey method'
189
+ )
190
+ assert(
191
+ typeof adapter.decryptSymmetricKey === 'function',
192
+ 'Should have decryptSymmetricKey method'
193
+ )
194
+ })
195
+ })
196
+ await describe('Factory Function Consistency', async () => {
197
+ await test('browser factories should use streaming crypto', async () => {
198
+ const litAdapter = createGenericLitAdapter(mockLitClient)
199
+ const kmsAdapter = createGenericKMSAdapter(
200
+ 'https://gateway.example.com',
201
+ 'did:web:gateway.example.com'
202
+ )
203
+ assert(
204
+ litAdapter.symmetricCrypto.constructor.name ===
205
+ 'GenericAesCtrStreamingCrypto',
206
+ 'Browser Lit adapter should use streaming crypto'
207
+ )
208
+ assert(
209
+ kmsAdapter.symmetricCrypto.constructor.name ===
210
+ 'GenericAesCtrStreamingCrypto',
211
+ 'Browser KMS adapter should use streaming crypto'
212
+ )
213
+ })
214
+ await test('node factories should use Node crypto', async () => {
215
+ const litAdapter = createNodeLitAdapter(mockLitClient)
216
+ assert(
217
+ litAdapter.symmetricCrypto.constructor.name === 'NodeAesCbcCrypto',
218
+ 'Node Lit adapter should use Node crypto'
219
+ )
220
+ })
221
+ await test('all adapters should implement the same interface', async () => {
222
+ const adapters = [
223
+ createGenericLitAdapter(mockLitClient),
224
+ createNodeLitAdapter(mockLitClient),
225
+ createGenericKMSAdapter(
226
+ 'https://gateway.example.com',
227
+ 'did:web:gateway.example.com'
228
+ ),
229
+ createGenericKMSAdapter(
230
+ 'https://gateway.example.com',
231
+ 'did:web:gateway.example.com'
232
+ ),
233
+ ]
234
+ const requiredMethods = [
235
+ 'encryptStream',
236
+ 'decryptStream',
237
+ 'encryptSymmetricKey',
238
+ 'decryptSymmetricKey',
239
+ 'extractEncryptedMetadata',
240
+ 'getEncryptedKey',
241
+ ]
242
+ for (const adapter of adapters) {
243
+ for (const method of requiredMethods) {
244
+ assert(
245
+ typeof (/** @type {any} */ (adapter)[method]) === 'function',
246
+ `${adapter.constructor.name} should have ${method} method`
247
+ )
248
+ }
249
+ }
250
+ })
251
+ })
252
+ await describe('Memory Usage Verification', async () => {
253
+ await test('browser adapters should use memory-efficient streaming crypto', async () => {
254
+ const litAdapter = createGenericLitAdapter(mockLitClient)
255
+ const kmsAdapter = createGenericKMSAdapter(
256
+ 'https://gateway.example.com',
257
+ 'did:web:gateway.example.com'
258
+ )
259
+ // Verify both use the streaming implementation
260
+ assert(
261
+ litAdapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto,
262
+ 'Lit adapter should use streaming crypto for memory efficiency'
263
+ )
264
+ assert(
265
+ kmsAdapter.symmetricCrypto instanceof GenericAesCtrStreamingCrypto,
266
+ 'KMS adapter should use streaming crypto for memory efficiency'
267
+ )
268
+ // Verify they have the streaming characteristics
269
+ const testBlob = new Blob([new Uint8Array(1024)]) // 1KB test
270
+ const litResult = await litAdapter.encryptStream(testBlob)
271
+ assert(
272
+ litResult.encryptedStream instanceof ReadableStream,
273
+ 'Should return ReadableStream for streaming'
274
+ )
275
+ })
276
+ })
277
+ })
278
+ //# sourceMappingURL=factories.spec.js.map
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=file-metadata.spec.d.ts.map
1
+ export {}
2
+ //# sourceMappingURL=file-metadata.spec.d.ts.map