@storacha/encrypt-upload-client 1.1.58 → 1.1.59

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 +3 -4
  3. package/dist/config/env.d.ts +6 -9
  4. package/dist/config/service.d.ts +13 -13
  5. package/dist/core/client.d.ts +41 -54
  6. package/dist/core/client.js +56 -68
  7. package/dist/core/errors.d.ts +6 -6
  8. package/dist/core/metadata/encrypted-metadata.d.ts +8 -13
  9. package/dist/core/metadata/kms-metadata.d.ts +36 -68
  10. package/dist/core/metadata/lit-metadata.d.ts +28 -63
  11. package/dist/crypto/adapters/kms-crypto-adapter.d.ts +137 -172
  12. package/dist/crypto/adapters/lit-crypto-adapter.d.ts +86 -107
  13. package/dist/crypto/factories.browser.d.ts +5 -9
  14. package/dist/crypto/factories.browser.js +7 -15
  15. package/dist/crypto/factories.node.d.ts +6 -13
  16. package/dist/crypto/factories.node.js +13 -19
  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 +54 -58
  20. package/dist/crypto/symmetric/generic-aes-ctr-streaming-crypto.js +146 -174
  21. package/dist/crypto/symmetric/node-aes-cbc-crypto.d.ts +32 -36
  22. package/dist/crypto/symmetric/node-aes-cbc-crypto.js +95 -101
  23. package/dist/examples/decrypt-test.d.ts +2 -2
  24. package/dist/examples/decrypt-test.js +69 -78
  25. package/dist/examples/encrypt-test.d.ts +3 -5
  26. package/dist/examples/encrypt-test.js +55 -58
  27. package/dist/handlers/decrypt-handler.d.ts +5 -19
  28. package/dist/handlers/encrypt-handler.d.ts +3 -9
  29. package/dist/handlers/encrypt-handler.js +57 -93
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.js +2 -2
  32. package/dist/protocols/lit.d.ts +9 -33
  33. package/dist/protocols/lit.js +98 -134
  34. package/dist/test/cid-verification.spec.d.ts +2 -2
  35. package/dist/test/cid-verification.spec.js +313 -341
  36. package/dist/test/crypto-compatibility.spec.d.ts +2 -2
  37. package/dist/test/crypto-compatibility.spec.js +120 -184
  38. package/dist/test/crypto-counter-security.spec.d.ts +2 -2
  39. package/dist/test/crypto-counter-security.spec.js +138 -177
  40. package/dist/test/crypto-streaming.spec.d.ts +2 -2
  41. package/dist/test/crypto-streaming.spec.js +126 -208
  42. package/dist/test/encrypted-metadata.spec.d.ts +2 -2
  43. package/dist/test/encrypted-metadata.spec.js +62 -89
  44. package/dist/test/factories.spec.d.ts +2 -2
  45. package/dist/test/factories.spec.js +139 -275
  46. package/dist/test/file-metadata.spec.d.ts +2 -2
  47. package/dist/test/file-metadata.spec.js +416 -472
  48. package/dist/test/fixtures/test-fixtures.d.ts +20 -25
  49. package/dist/test/fixtures/test-fixtures.js +53 -61
  50. package/dist/test/helpers/test-file-utils.d.ts +14 -19
  51. package/dist/test/helpers/test-file-utils.js +76 -78
  52. package/dist/test/https-enforcement.spec.d.ts +2 -2
  53. package/dist/test/https-enforcement.spec.js +124 -278
  54. package/dist/test/kms-crypto-adapter.spec.d.ts +2 -2
  55. package/dist/test/kms-crypto-adapter.spec.js +304 -473
  56. package/dist/test/lit-crypto-adapter.spec.d.ts +2 -2
  57. package/dist/test/lit-crypto-adapter.spec.js +118 -206
  58. package/dist/test/memory-efficiency.spec.d.ts +2 -2
  59. package/dist/test/memory-efficiency.spec.js +87 -100
  60. package/dist/test/mocks/key-manager.d.ts +38 -71
  61. package/dist/test/mocks/key-manager.js +113 -129
  62. package/dist/test/node-crypto-adapter.spec.d.ts +2 -2
  63. package/dist/test/node-crypto-adapter.spec.js +102 -155
  64. package/dist/test/node-generic-crypto-adapter.spec.d.ts +2 -2
  65. package/dist/test/node-generic-crypto-adapter.spec.js +94 -134
  66. package/dist/test/setup.d.ts +2 -2
  67. package/dist/test/setup.js +9 -8
  68. package/dist/tsconfig.spec.tsbuildinfo +1 -1
  69. package/dist/types.d.ts +181 -219
  70. package/dist/utils/file-metadata.d.ts +13 -19
  71. package/dist/utils.d.ts +5 -14
  72. package/package.json +4 -4
@@ -7,176 +7,141 @@
7
7
  * @implements {Type.CryptoAdapter}
8
8
  */
9
9
  export class KMSCryptoAdapter implements Type.CryptoAdapter {
10
- /**
11
- * Create a new KMS crypto adapter
12
- *
13
- * @param {Type.SymmetricCrypto} symmetricCrypto - The symmetric crypto implementation (browser or node)
14
- * @param {URL|string} keyManagerServiceURL - The key manager service URL
15
- * @param {`did:${string}:${string}`} keyManagerServiceDID - The key manager service DID
16
- * @param {object} [options] - Optional configuration
17
- * @param {boolean} [options.allowInsecureHttp] - Allow HTTP for testing (NOT for production)
18
- */
19
- constructor(
20
- symmetricCrypto: Type.SymmetricCrypto,
21
- keyManagerServiceURL: URL | string,
22
- keyManagerServiceDID: `did:${string}:${string}`,
23
- options?: {
24
- allowInsecureHttp?: boolean | undefined
25
- }
26
- )
27
- symmetricCrypto: Type.SymmetricCrypto
28
- keyManagerServiceURL: URL
29
- keyManagerServiceDID: import('@ucanto/client').PrincipalView<`did:${string}:${string}`>
30
- /**
31
- * Encrypt a stream of data using the symmetric crypto
32
- *
33
- * @param {Type.BlobLike} data
34
- */
35
- encryptStream(data: Type.BlobLike): Promise<Type.EncryptOutput>
36
- /**
37
- * Decrypt a stream of data using the symmetric crypto
38
- *
39
- * @param {ReadableStream} encryptedData
40
- * @param {Uint8Array} key
41
- * @param {Uint8Array} iv
42
- */
43
- decryptStream(
44
- encryptedData: ReadableStream,
45
- key: Uint8Array,
46
- iv: Uint8Array
47
- ): Promise<ReadableStream<any>>
48
- /**
49
- * Encrypt a symmetric key using the KMS
50
- *
51
- * @param {Uint8Array} key
52
- * @param {Uint8Array} iv
53
- * @param {Type.EncryptionConfig} encryptionConfig
54
- * @returns {Promise<Type.EncryptedKeyResult>}
55
- */
56
- encryptSymmetricKey(
57
- key: Uint8Array,
58
- iv: Uint8Array,
59
- encryptionConfig: Type.EncryptionConfig
60
- ): Promise<Type.EncryptedKeyResult>
61
- /**
62
- * @param {string} encryptedKey
63
- * @param {object} configs
64
- * @param {Type.DecryptionConfig} configs.decryptionConfig
65
- * @param {Type.ExtractedMetadata} configs.metadata
66
- * @param {Type.AnyLink} configs.resourceCID
67
- * @param {import('@storacha/client/types').Signer<import('@storacha/client/types').DID, import('@storacha/client/types').SigAlg>} configs.issuer
68
- * @param {import('@storacha/client/types').DID} configs.audience
69
- */
70
- decryptSymmetricKey(
71
- encryptedKey: string,
72
- configs: {
73
- decryptionConfig: Type.DecryptionConfig
74
- metadata: Type.ExtractedMetadata
75
- resourceCID: Type.AnyLink
76
- issuer: import('@storacha/client/types').Signer<
77
- import('@storacha/client/types').DID,
78
- import('@storacha/client/types').SigAlg
79
- >
80
- audience: import('@storacha/client/types').DID
81
- }
82
- ): Promise<{
83
- key: Uint8Array
84
- iv: Uint8Array
85
- }>
86
- /**
87
- * Get decrypted symmetric key in base64 string from KMS via private gateway
88
- *
89
- * @param {string} encryptedSymmetricKey - The encrypted symmetric key (base64-encoded)
90
- * @param {Type.SpaceDID} spaceDID - The space DID
91
- * @param {import('@ucanto/interface').Proof} decryptionProof - The decryption delegation proof
92
- * @param {import('@ucanto/interface').Proof[]} proofs - The proofs to access the space
93
- * @param {import('@storacha/client/types').Signer<import('@storacha/client/types').DID, import('@storacha/client/types').SigAlg>} issuer - The issuer
94
- * @returns {Promise<{decryptedSymmetricKey: string}>} - The decrypted symmetric key (base64-encoded)
95
- */
96
- getDecryptedSymmetricKey(
97
- encryptedSymmetricKey: string,
98
- spaceDID: Type.SpaceDID,
99
- decryptionProof: import('@ucanto/interface').Proof,
100
- proofs: import('@ucanto/interface').Proof[],
101
- issuer: import('@storacha/client/types').Signer<
102
- import('@storacha/client/types').DID,
103
- import('@storacha/client/types').SigAlg
104
- >
105
- ): Promise<{
106
- decryptedSymmetricKey: string
107
- }>
108
- /**
109
- * Extract the encrypted metadata from the CAR file
110
- * KMS adapter only handles KMS format (encrypted-metadata@0.2)
111
- *
112
- * @param {Uint8Array} car
113
- * @returns {Type.ExtractedMetadata}
114
- */
115
- extractEncryptedMetadata(car: Uint8Array): Type.ExtractedMetadata
116
- /**
117
- * @param {Type.ExtractedMetadata} metadata
118
- * @returns {string}
119
- */
120
- getEncryptedKey(metadata: Type.ExtractedMetadata): string
121
- /**
122
- * Encode metadata for upload
123
- *
124
- * @param {string} encryptedDataCID - The CID of the encrypted data
125
- * @param {string} encryptedKey - The encrypted key
126
- * @param {Type.KMSKeyMetadata} metadata - The metadata to encode
127
- * @returns {Promise<{ cid: import('@storacha/upload-client/types').AnyLink, bytes: Uint8Array }>} - The encoded metadata
128
- */
129
- encodeMetadata(
130
- encryptedDataCID: string,
131
- encryptedKey: string,
132
- metadata: Type.KMSKeyMetadata
133
- ): Promise<{
134
- cid: import('@storacha/upload-client/types').AnyLink
135
- bytes: Uint8Array
136
- }>
137
- /**
138
- * Get the RSA public key from the space/encryption/setup
139
- *
140
- * @param {Type.EncryptionConfig} encryptionConfig
141
- * @returns {Promise<{ publicKey: string, provider: string, algorithm: string }>}
142
- */
143
- getSpacePublicKey(encryptionConfig: Type.EncryptionConfig): Promise<{
144
- publicKey: string
145
- provider: string
146
- algorithm: string
147
- }>
148
- /**
149
- * Get the Web Crypto API SubtleCrypto interface (universal compatibility)
150
- *
151
- * @returns {SubtleCrypto} - The SubtleCrypto interface
152
- */
153
- getSubtleCrypto(): SubtleCrypto
154
- /**
155
- * Encrypt data with RSA-OAEP using the public key
156
- *
157
- * @param {Uint8Array} dataToEncrypt
158
- * @param {string} publicKeyPem
159
- * @returns {Promise<Uint8Array>}
160
- */
161
- encryptWithRSA(
162
- dataToEncrypt: Uint8Array,
163
- publicKeyPem: string
164
- ): Promise<Uint8Array>
165
- /**
166
- * Convert PEM-encoded public key to ArrayBuffer for Web Crypto API
167
- *
168
- * @param {string} pem - PEM-encoded public key string
169
- * @returns {ArrayBuffer} - DER-encoded key data for crypto.subtle.importKey()
170
- */
171
- pemToArrayBuffer(pem: string): ArrayBuffer
172
- newKeyManagerServiceConnection(): import('@ucanto/interface').ConnectionView<any>
173
- /**
174
- * Sanitize the space DID for the KMS key ID
175
- *
176
- * @param {Type.SpaceDID} spaceDID
177
- * @returns {string}
178
- */
179
- sanitizeSpaceDIDForKMSKeyId(spaceDID: Type.SpaceDID): string
10
+ /**
11
+ * Create a new KMS crypto adapter
12
+ *
13
+ * @param {Type.SymmetricCrypto} symmetricCrypto - The symmetric crypto implementation (browser or node)
14
+ * @param {URL|string} keyManagerServiceURL - The key manager service URL
15
+ * @param {`did:${string}:${string}`} keyManagerServiceDID - The key manager service DID
16
+ * @param {object} [options] - Optional configuration
17
+ * @param {boolean} [options.allowInsecureHttp] - Allow HTTP for testing (NOT for production)
18
+ */
19
+ constructor(symmetricCrypto: Type.SymmetricCrypto, keyManagerServiceURL: URL | string, keyManagerServiceDID: `did:${string}:${string}`, options?: {
20
+ allowInsecureHttp?: boolean | undefined;
21
+ });
22
+ symmetricCrypto: Type.SymmetricCrypto;
23
+ keyManagerServiceURL: URL;
24
+ keyManagerServiceDID: import("@ucanto/client").PrincipalView<`did:${string}:${string}`>;
25
+ /**
26
+ * Encrypt a stream of data using the symmetric crypto
27
+ *
28
+ * @param {Type.BlobLike} data
29
+ */
30
+ encryptStream(data: Type.BlobLike): Promise<Type.EncryptOutput>;
31
+ /**
32
+ * Decrypt a stream of data using the symmetric crypto
33
+ *
34
+ * @param {ReadableStream} encryptedData
35
+ * @param {Uint8Array} key
36
+ * @param {Uint8Array} iv
37
+ */
38
+ decryptStream(encryptedData: ReadableStream, key: Uint8Array, iv: Uint8Array): Promise<ReadableStream<any>>;
39
+ /**
40
+ * Encrypt a symmetric key using the KMS
41
+ *
42
+ * @param {Uint8Array} key
43
+ * @param {Uint8Array} iv
44
+ * @param {Type.EncryptionConfig} encryptionConfig
45
+ * @returns {Promise<Type.EncryptedKeyResult>}
46
+ */
47
+ encryptSymmetricKey(key: Uint8Array, iv: Uint8Array, encryptionConfig: Type.EncryptionConfig): Promise<Type.EncryptedKeyResult>;
48
+ /**
49
+ * @param {string} encryptedKey
50
+ * @param {object} configs
51
+ * @param {Type.DecryptionConfig} configs.decryptionConfig
52
+ * @param {Type.ExtractedMetadata} configs.metadata
53
+ * @param {Type.AnyLink} configs.resourceCID
54
+ * @param {import('@storacha/client/types').Signer<import('@storacha/client/types').DID, import('@storacha/client/types').SigAlg>} configs.issuer
55
+ * @param {import('@storacha/client/types').DID} configs.audience
56
+ */
57
+ decryptSymmetricKey(encryptedKey: string, configs: {
58
+ decryptionConfig: Type.DecryptionConfig;
59
+ metadata: Type.ExtractedMetadata;
60
+ resourceCID: Type.AnyLink;
61
+ issuer: import("@storacha/client/types").Signer<import("@storacha/client/types").DID, import("@storacha/client/types").SigAlg>;
62
+ audience: import("@storacha/client/types").DID;
63
+ }): Promise<{
64
+ key: Uint8Array;
65
+ iv: Uint8Array;
66
+ }>;
67
+ /**
68
+ * Get decrypted symmetric key in base64 string from KMS via private gateway
69
+ *
70
+ * @param {string} encryptedSymmetricKey - The encrypted symmetric key (base64-encoded)
71
+ * @param {Type.SpaceDID} spaceDID - The space DID
72
+ * @param {import('@ucanto/interface').Proof} decryptionProof - The decryption delegation proof
73
+ * @param {import('@ucanto/interface').Proof[]} proofs - The proofs to access the space
74
+ * @param {import('@storacha/client/types').Signer<import('@storacha/client/types').DID, import('@storacha/client/types').SigAlg>} issuer - The issuer
75
+ * @returns {Promise<{decryptedSymmetricKey: string}>} - The decrypted symmetric key (base64-encoded)
76
+ */
77
+ getDecryptedSymmetricKey(encryptedSymmetricKey: string, spaceDID: Type.SpaceDID, decryptionProof: import("@ucanto/interface").Proof, proofs: import("@ucanto/interface").Proof[], issuer: import("@storacha/client/types").Signer<import("@storacha/client/types").DID, import("@storacha/client/types").SigAlg>): Promise<{
78
+ decryptedSymmetricKey: string;
79
+ }>;
80
+ /**
81
+ * Extract the encrypted metadata from the CAR file
82
+ * KMS adapter only handles KMS format (encrypted-metadata@0.2)
83
+ *
84
+ * @param {Uint8Array} car
85
+ * @returns {Type.ExtractedMetadata}
86
+ */
87
+ extractEncryptedMetadata(car: Uint8Array): Type.ExtractedMetadata;
88
+ /**
89
+ * @param {Type.ExtractedMetadata} metadata
90
+ * @returns {string}
91
+ */
92
+ getEncryptedKey(metadata: Type.ExtractedMetadata): string;
93
+ /**
94
+ * Encode metadata for upload
95
+ *
96
+ * @param {string} encryptedDataCID - The CID of the encrypted data
97
+ * @param {string} encryptedKey - The encrypted key
98
+ * @param {Type.KMSKeyMetadata} metadata - The metadata to encode
99
+ * @returns {Promise<{ cid: import('@storacha/upload-client/types').AnyLink, bytes: Uint8Array }>} - The encoded metadata
100
+ */
101
+ encodeMetadata(encryptedDataCID: string, encryptedKey: string, metadata: Type.KMSKeyMetadata): Promise<{
102
+ cid: import("@storacha/upload-client/types").AnyLink;
103
+ bytes: Uint8Array;
104
+ }>;
105
+ /**
106
+ * Get the RSA public key from the space/encryption/setup
107
+ *
108
+ * @param {Type.EncryptionConfig} encryptionConfig
109
+ * @returns {Promise<{ publicKey: string, provider: string, algorithm: string }>}
110
+ */
111
+ getSpacePublicKey(encryptionConfig: Type.EncryptionConfig): Promise<{
112
+ publicKey: string;
113
+ provider: string;
114
+ algorithm: string;
115
+ }>;
116
+ /**
117
+ * Get the Web Crypto API SubtleCrypto interface (universal compatibility)
118
+ *
119
+ * @returns {SubtleCrypto} - The SubtleCrypto interface
120
+ */
121
+ getSubtleCrypto(): SubtleCrypto;
122
+ /**
123
+ * Encrypt data with RSA-OAEP using the public key
124
+ *
125
+ * @param {Uint8Array} dataToEncrypt
126
+ * @param {string} publicKeyPem
127
+ * @returns {Promise<Uint8Array>}
128
+ */
129
+ encryptWithRSA(dataToEncrypt: Uint8Array, publicKeyPem: string): Promise<Uint8Array>;
130
+ /**
131
+ * Convert PEM-encoded public key to ArrayBuffer for Web Crypto API
132
+ *
133
+ * @param {string} pem - PEM-encoded public key string
134
+ * @returns {ArrayBuffer} - DER-encoded key data for crypto.subtle.importKey()
135
+ */
136
+ pemToArrayBuffer(pem: string): ArrayBuffer;
137
+ newKeyManagerServiceConnection(): import("@ucanto/interface").ConnectionView<any>;
138
+ /**
139
+ * Sanitize the space DID for the KMS key ID
140
+ *
141
+ * @param {Type.SpaceDID} spaceDID
142
+ * @returns {string}
143
+ */
144
+ sanitizeSpaceDIDForKMSKeyId(spaceDID: Type.SpaceDID): string;
180
145
  }
181
- import * as Type from '../../types.js'
182
- //# sourceMappingURL=kms-crypto-adapter.d.ts.map
146
+ import * as Type from '../../types.js';
147
+ //# sourceMappingURL=kms-crypto-adapter.d.ts.map
@@ -7,111 +7,90 @@
7
7
  * @implements {Type.CryptoAdapter}
8
8
  */
9
9
  export class LitCryptoAdapter implements Type.CryptoAdapter {
10
- /**
11
- * Create a new Lit crypto adapter
12
- *
13
- * @param {Type.SymmetricCrypto} symmetricCrypto - The symmetric crypto implementation (browser or node)
14
- * @param {import('@lit-protocol/lit-node-client').LitNodeClient} litClient - The Lit client instance
15
- */
16
- constructor(
17
- symmetricCrypto: Type.SymmetricCrypto,
18
- litClient: import('@lit-protocol/lit-node-client').LitNodeClient
19
- )
20
- symmetricCrypto: Type.SymmetricCrypto
21
- litClient: import('@lit-protocol/lit-node-client').LitNodeClient
22
- /**
23
- * Encrypt a stream of data using the symmetric crypto implementation
24
- *
25
- * @param {Type.BlobLike} data - The data to encrypt
26
- * @returns {Promise<Type.EncryptOutput>} - The encrypted data
27
- */
28
- encryptStream(data: Type.BlobLike): Promise<Type.EncryptOutput>
29
- /**
30
- * Decrypt a stream of data using the symmetric crypto implementation
31
- *
32
- * @param {ReadableStream} encryptedData - The encrypted data to decrypt
33
- * @param {Uint8Array} key - The key to use for decryption
34
- * @param {Uint8Array} iv - The initialization vector to use for decryption
35
- * @returns {Promise<ReadableStream>} - The decrypted data
36
- */
37
- decryptStream(
38
- encryptedData: ReadableStream,
39
- key: Uint8Array,
40
- iv: Uint8Array
41
- ): Promise<ReadableStream>
42
- /**
43
- * Encrypt a symmetric key using the Lit crypto adapter
44
- *
45
- * @param {Uint8Array} key - The symmetric key to encrypt
46
- * @param {Uint8Array} iv - The initialization vector to encrypt
47
- * @param {Type.EncryptionConfig} encryptionConfig - The encryption configuration
48
- * @returns {Promise<Type.EncryptedKeyResult>} - The encrypted key result
49
- */
50
- encryptSymmetricKey(
51
- key: Uint8Array,
52
- iv: Uint8Array,
53
- encryptionConfig: Type.EncryptionConfig
54
- ): Promise<Type.EncryptedKeyResult>
55
- /**
56
- * Decrypt a symmetric key using the Lit crypto adapter
57
- *
58
- * @param {string} encryptedKey - The encrypted key to decrypt
59
- * @param {object} configs - The decryption configuration
60
- * @param {Type.DecryptionConfig} configs.decryptionConfig - The decryption config
61
- * @param {Type.ExtractedMetadata} configs.metadata - The extracted metadata
62
- * @param {import('@ucanto/interface').Proof} configs.decryptDelegation - The delegation that gives permission to decrypt (required for both strategies)
63
- * @param {Type.AnyLink} configs.resourceCID - The resource CID
64
- * @param {import('@storacha/client/types').Signer<import('@storacha/client/types').DID, import('@storacha/client/types').SigAlg>} configs.issuer - The issuer
65
- * @param {import('@storacha/client/types').DID} configs.audience - The audience
66
- * @returns {Promise<{ key: Uint8Array, iv: Uint8Array }>} - The decrypted key and IV
67
- */
68
- decryptSymmetricKey(
69
- encryptedKey: string,
70
- configs: {
71
- decryptionConfig: Type.DecryptionConfig
72
- metadata: Type.ExtractedMetadata
73
- decryptDelegation: import('@ucanto/interface').Proof
74
- resourceCID: Type.AnyLink
75
- issuer: import('@storacha/client/types').Signer<
76
- import('@storacha/client/types').DID,
77
- import('@storacha/client/types').SigAlg
78
- >
79
- audience: import('@storacha/client/types').DID
80
- }
81
- ): Promise<{
82
- key: Uint8Array
83
- iv: Uint8Array
84
- }>
85
- /**
86
- * Extract encrypted metadata from a CAR file
87
- *
88
- * @param {Uint8Array} car - The CAR file to extract metadata from
89
- * @returns {Type.ExtractedMetadata} - The extracted metadata
90
- */
91
- extractEncryptedMetadata(car: Uint8Array): Type.ExtractedMetadata
92
- /**
93
- * Get the encrypted key from the metadata
94
- *
95
- * @param {Type.ExtractedMetadata} metadata - The metadata to get the encrypted key from
96
- * @returns {string} - The encrypted key
97
- */
98
- getEncryptedKey(metadata: Type.ExtractedMetadata): string
99
- /**
100
- * Encode metadata for upload
101
- *
102
- * @param {string} encryptedDataCID - The CID of the encrypted data
103
- * @param {string} encryptedKey - The encrypted key
104
- * @param {Type.LitKeyMetadata} metadata - The metadata to encode
105
- * @returns {Promise<{ cid: import('@storacha/upload-client/types').AnyLink, bytes: Uint8Array }>} - The encoded metadata
106
- */
107
- encodeMetadata(
108
- encryptedDataCID: string,
109
- encryptedKey: string,
110
- metadata: Type.LitKeyMetadata
111
- ): Promise<{
112
- cid: import('@storacha/upload-client/types').AnyLink
113
- bytes: Uint8Array
114
- }>
10
+ /**
11
+ * Create a new Lit crypto adapter
12
+ *
13
+ * @param {Type.SymmetricCrypto} symmetricCrypto - The symmetric crypto implementation (browser or node)
14
+ * @param {import('@lit-protocol/lit-node-client').LitNodeClient} litClient - The Lit client instance
15
+ */
16
+ constructor(symmetricCrypto: Type.SymmetricCrypto, litClient: import("@lit-protocol/lit-node-client").LitNodeClient);
17
+ symmetricCrypto: Type.SymmetricCrypto;
18
+ litClient: import("@lit-protocol/lit-node-client").LitNodeClient;
19
+ /**
20
+ * Encrypt a stream of data using the symmetric crypto implementation
21
+ *
22
+ * @param {Type.BlobLike} data - The data to encrypt
23
+ * @returns {Promise<Type.EncryptOutput>} - The encrypted data
24
+ */
25
+ encryptStream(data: Type.BlobLike): Promise<Type.EncryptOutput>;
26
+ /**
27
+ * Decrypt a stream of data using the symmetric crypto implementation
28
+ *
29
+ * @param {ReadableStream} encryptedData - The encrypted data to decrypt
30
+ * @param {Uint8Array} key - The key to use for decryption
31
+ * @param {Uint8Array} iv - The initialization vector to use for decryption
32
+ * @returns {Promise<ReadableStream>} - The decrypted data
33
+ */
34
+ decryptStream(encryptedData: ReadableStream, key: Uint8Array, iv: Uint8Array): Promise<ReadableStream>;
35
+ /**
36
+ * Encrypt a symmetric key using the Lit crypto adapter
37
+ *
38
+ * @param {Uint8Array} key - The symmetric key to encrypt
39
+ * @param {Uint8Array} iv - The initialization vector to encrypt
40
+ * @param {Type.EncryptionConfig} encryptionConfig - The encryption configuration
41
+ * @returns {Promise<Type.EncryptedKeyResult>} - The encrypted key result
42
+ */
43
+ encryptSymmetricKey(key: Uint8Array, iv: Uint8Array, encryptionConfig: Type.EncryptionConfig): Promise<Type.EncryptedKeyResult>;
44
+ /**
45
+ * Decrypt a symmetric key using the Lit crypto adapter
46
+ *
47
+ * @param {string} encryptedKey - The encrypted key to decrypt
48
+ * @param {object} configs - The decryption configuration
49
+ * @param {Type.DecryptionConfig} configs.decryptionConfig - The decryption config
50
+ * @param {Type.ExtractedMetadata} configs.metadata - The extracted metadata
51
+ * @param {import('@ucanto/interface').Proof} configs.decryptDelegation - The delegation that gives permission to decrypt (required for both strategies)
52
+ * @param {Type.AnyLink} configs.resourceCID - The resource CID
53
+ * @param {import('@storacha/client/types').Signer<import('@storacha/client/types').DID, import('@storacha/client/types').SigAlg>} configs.issuer - The issuer
54
+ * @param {import('@storacha/client/types').DID} configs.audience - The audience
55
+ * @returns {Promise<{ key: Uint8Array, iv: Uint8Array }>} - The decrypted key and IV
56
+ */
57
+ decryptSymmetricKey(encryptedKey: string, configs: {
58
+ decryptionConfig: Type.DecryptionConfig;
59
+ metadata: Type.ExtractedMetadata;
60
+ decryptDelegation: import("@ucanto/interface").Proof;
61
+ resourceCID: Type.AnyLink;
62
+ issuer: import("@storacha/client/types").Signer<import("@storacha/client/types").DID, import("@storacha/client/types").SigAlg>;
63
+ audience: import("@storacha/client/types").DID;
64
+ }): Promise<{
65
+ key: Uint8Array;
66
+ iv: Uint8Array;
67
+ }>;
68
+ /**
69
+ * Extract encrypted metadata from a CAR file
70
+ *
71
+ * @param {Uint8Array} car - The CAR file to extract metadata from
72
+ * @returns {Type.ExtractedMetadata} - The extracted metadata
73
+ */
74
+ extractEncryptedMetadata(car: Uint8Array): Type.ExtractedMetadata;
75
+ /**
76
+ * Get the encrypted key from the metadata
77
+ *
78
+ * @param {Type.ExtractedMetadata} metadata - The metadata to get the encrypted key from
79
+ * @returns {string} - The encrypted key
80
+ */
81
+ getEncryptedKey(metadata: Type.ExtractedMetadata): string;
82
+ /**
83
+ * Encode metadata for upload
84
+ *
85
+ * @param {string} encryptedDataCID - The CID of the encrypted data
86
+ * @param {string} encryptedKey - The encrypted key
87
+ * @param {Type.LitKeyMetadata} metadata - The metadata to encode
88
+ * @returns {Promise<{ cid: import('@storacha/upload-client/types').AnyLink, bytes: Uint8Array }>} - The encoded metadata
89
+ */
90
+ encodeMetadata(encryptedDataCID: string, encryptedKey: string, metadata: Type.LitKeyMetadata): Promise<{
91
+ cid: import("@storacha/upload-client/types").AnyLink;
92
+ bytes: Uint8Array;
93
+ }>;
115
94
  }
116
- import * as Type from '../../types.js'
117
- //# sourceMappingURL=lit-crypto-adapter.d.ts.map
95
+ import * as Type from '../../types.js';
96
+ //# sourceMappingURL=lit-crypto-adapter.d.ts.map
@@ -8,12 +8,8 @@
8
8
  * @param {object} [options] - Optional configuration
9
9
  * @param {boolean} [options.allowInsecureHttp] - Allow HTTP for testing (NOT for production)
10
10
  */
11
- export function createGenericKMSAdapter(
12
- keyManagerServiceURL: URL | string,
13
- keyManagerServiceDID: string,
14
- options?: {
15
- allowInsecureHttp?: boolean | undefined
16
- }
17
- ): KMSCryptoAdapter
18
- import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js'
19
- //# sourceMappingURL=factories.browser.d.ts.map
11
+ export function createGenericKMSAdapter(keyManagerServiceURL: URL | string, keyManagerServiceDID: string, options?: {
12
+ allowInsecureHttp?: boolean | undefined;
13
+ }): KMSCryptoAdapter;
14
+ import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js';
15
+ //# sourceMappingURL=factories.browser.d.ts.map
@@ -1,5 +1,5 @@
1
- import { GenericAesCtrStreamingCrypto } from './symmetric/generic-aes-ctr-streaming-crypto.js'
2
- import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js'
1
+ import { GenericAesCtrStreamingCrypto } from './symmetric/generic-aes-ctr-streaming-crypto.js';
2
+ import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js';
3
3
  /**
4
4
  * Create a KMS crypto adapter for browser environments
5
5
  * Uses the generic AES-CTR streaming crypto implementation
@@ -10,17 +10,9 @@ import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js'
10
10
  * @param {object} [options] - Optional configuration
11
11
  * @param {boolean} [options.allowInsecureHttp] - Allow HTTP for testing (NOT for production)
12
12
  */
13
- export function createGenericKMSAdapter(
14
- keyManagerServiceURL,
15
- keyManagerServiceDID,
16
- options = {}
17
- ) {
18
- const symmetricCrypto = new GenericAesCtrStreamingCrypto()
19
- return new KMSCryptoAdapter(
20
- symmetricCrypto,
21
- keyManagerServiceURL,
22
- /** @type {`did:${string}:${string}`} */ (keyManagerServiceDID),
23
- options
24
- )
13
+ export function createGenericKMSAdapter(keyManagerServiceURL, keyManagerServiceDID, options = {}) {
14
+ const symmetricCrypto = new GenericAesCtrStreamingCrypto();
15
+ return new KMSCryptoAdapter(symmetricCrypto, keyManagerServiceURL,
16
+ /** @type {`did:${string}:${string}`} */ (keyManagerServiceDID), options);
25
17
  }
26
- //# sourceMappingURL=factories.browser.js.map
18
+ //# sourceMappingURL=factories.browser.js.map
@@ -5,10 +5,7 @@
5
5
  * @param {URL|string} keyManagerServiceURL
6
6
  * @param {string} keyManagerServiceDID
7
7
  */
8
- export function createGenericKMSAdapter(
9
- keyManagerServiceURL: URL | string,
10
- keyManagerServiceDID: string
11
- ): KMSCryptoAdapter
8
+ export function createGenericKMSAdapter(keyManagerServiceURL: URL | string, keyManagerServiceDID: string): KMSCryptoAdapter;
12
9
  /**
13
10
  * Create a Lit crypto adapter for Node.js using AES-CBC (legacy).
14
11
  * Compatible with previous versions of the library.
@@ -16,18 +13,14 @@ export function createGenericKMSAdapter(
16
13
  * @deprecated Use createGenericLitAdapter instead for new uploads.
17
14
  * @param {import('@lit-protocol/lit-node-client').LitNodeClient} litClient
18
15
  */
19
- export function createNodeLitAdapter(
20
- litClient: import('@lit-protocol/lit-node-client').LitNodeClient
21
- ): LitCryptoAdapter
16
+ export function createNodeLitAdapter(litClient: import("@lit-protocol/lit-node-client").LitNodeClient): LitCryptoAdapter;
22
17
  /**
23
18
  * Create a Lit crypto adapter for Node.js using the generic AES-CTR streaming crypto.
24
19
  * Works in Node.js & browser environments.
25
20
  *
26
21
  * @param {import('@lit-protocol/lit-node-client').LitNodeClient} litClient
27
22
  */
28
- export function createGenericLitAdapter(
29
- litClient: import('@lit-protocol/lit-node-client').LitNodeClient
30
- ): LitCryptoAdapter
31
- import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js'
32
- import { LitCryptoAdapter } from './adapters/lit-crypto-adapter.js'
33
- //# sourceMappingURL=factories.node.d.ts.map
23
+ export function createGenericLitAdapter(litClient: import("@lit-protocol/lit-node-client").LitNodeClient): LitCryptoAdapter;
24
+ import { KMSCryptoAdapter } from './adapters/kms-crypto-adapter.js';
25
+ import { LitCryptoAdapter } from './adapters/lit-crypto-adapter.js';
26
+ //# sourceMappingURL=factories.node.d.ts.map