@storacha/encrypt-upload-client 1.1.74 → 1.1.76-rc.0

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 (82) hide show
  1. package/README.md +1 -0
  2. package/dist/config/service.d.ts +13 -13
  3. package/dist/core/client.d.ts +54 -41
  4. package/dist/core/errors.d.ts +6 -6
  5. package/dist/core/metadata/encrypted-metadata.d.ts +13 -8
  6. package/dist/core/metadata/kms-metadata.d.ts +68 -36
  7. package/dist/core/metadata/lit-metadata.d.ts +63 -28
  8. package/dist/crypto/adapters/kms-crypto-adapter.d.ts +172 -137
  9. package/dist/crypto/factories.browser.d.ts +9 -5
  10. package/dist/crypto/index.d.ts +5 -5
  11. package/dist/crypto/symmetric/generic-aes-ctr-streaming-crypto.d.ts +58 -54
  12. package/dist/crypto/symmetric/node-aes-cbc-crypto.d.ts +36 -32
  13. package/dist/examples/decrypt-test.d.ts +2 -0
  14. package/dist/examples/decrypt-test.d.ts.map +1 -0
  15. package/dist/examples/decrypt-test.js +102 -0
  16. package/dist/examples/encrypt-test.d.ts +2 -0
  17. package/dist/examples/encrypt-test.d.ts.map +1 -0
  18. package/dist/examples/encrypt-test.js +93 -0
  19. package/dist/handlers/decrypt-handler.d.ts +19 -5
  20. package/dist/handlers/decrypt-handler.js +10 -5
  21. package/dist/handlers/encrypt-handler.d.ts +9 -3
  22. package/dist/handlers/encrypt-handler.d.ts.map +1 -1
  23. package/dist/handlers/encrypt-handler.js +2 -44
  24. package/dist/index.d.ts +2 -2
  25. package/dist/test/cid-verification.spec.d.ts +2 -0
  26. package/dist/test/cid-verification.spec.d.ts.map +1 -0
  27. package/dist/test/cid-verification.spec.js +314 -0
  28. package/dist/test/crypto-compatibility.spec.d.ts +2 -0
  29. package/dist/test/crypto-compatibility.spec.d.ts.map +1 -0
  30. package/dist/test/crypto-compatibility.spec.js +124 -0
  31. package/dist/test/crypto-counter-security.spec.d.ts +2 -0
  32. package/dist/test/crypto-counter-security.spec.d.ts.map +1 -0
  33. package/dist/test/crypto-counter-security.spec.js +147 -0
  34. package/dist/test/crypto-streaming.spec.d.ts +2 -0
  35. package/dist/test/crypto-streaming.spec.d.ts.map +1 -0
  36. package/dist/test/crypto-streaming.spec.js +129 -0
  37. package/dist/test/encrypted-metadata.spec.d.ts +2 -0
  38. package/dist/test/encrypted-metadata.spec.d.ts.map +1 -0
  39. package/dist/test/encrypted-metadata.spec.js +68 -0
  40. package/dist/test/factories.spec.d.ts +2 -0
  41. package/dist/test/factories.spec.d.ts.map +1 -0
  42. package/dist/test/factories.spec.js +129 -0
  43. package/dist/test/file-metadata.spec.d.ts +2 -0
  44. package/dist/test/file-metadata.spec.d.ts.map +1 -0
  45. package/dist/test/file-metadata.spec.js +433 -0
  46. package/dist/test/fixtures/test-fixtures.d.ts +33 -0
  47. package/dist/test/fixtures/test-fixtures.d.ts.map +1 -0
  48. package/dist/test/fixtures/test-fixtures.js +63 -0
  49. package/dist/test/helpers/test-file-utils.d.ts +65 -0
  50. package/dist/test/helpers/test-file-utils.d.ts.map +1 -0
  51. package/dist/test/helpers/test-file-utils.js +139 -0
  52. package/dist/test/https-enforcement.spec.d.ts +2 -0
  53. package/dist/test/https-enforcement.spec.d.ts.map +1 -0
  54. package/dist/test/https-enforcement.spec.js +125 -0
  55. package/dist/test/kms-crypto-adapter.spec.d.ts +2 -0
  56. package/dist/test/kms-crypto-adapter.spec.d.ts.map +1 -0
  57. package/dist/test/kms-crypto-adapter.spec.js +305 -0
  58. package/dist/test/lit-crypto-adapter.spec.d.ts +2 -0
  59. package/dist/test/lit-crypto-adapter.spec.d.ts.map +1 -0
  60. package/dist/test/lit-crypto-adapter.spec.js +76 -0
  61. package/dist/test/memory-efficiency.spec.d.ts +2 -0
  62. package/dist/test/memory-efficiency.spec.d.ts.map +1 -0
  63. package/dist/test/memory-efficiency.spec.js +93 -0
  64. package/dist/test/mocks/key-manager.d.ts +91 -0
  65. package/dist/test/mocks/key-manager.d.ts.map +1 -0
  66. package/dist/test/mocks/key-manager.js +137 -0
  67. package/dist/test/node-crypto-adapter.spec.d.ts +2 -0
  68. package/dist/test/node-crypto-adapter.spec.d.ts.map +1 -0
  69. package/dist/test/node-crypto-adapter.spec.js +103 -0
  70. package/dist/test/node-generic-crypto-adapter.spec.d.ts +2 -0
  71. package/dist/test/node-generic-crypto-adapter.spec.d.ts.map +1 -0
  72. package/dist/test/node-generic-crypto-adapter.spec.js +95 -0
  73. package/dist/test/setup.d.ts +2 -0
  74. package/dist/test/setup.d.ts.map +1 -0
  75. package/dist/test/setup.js +12 -0
  76. package/dist/tsconfig.spec.tsbuildinfo +1 -0
  77. package/dist/utils/encrypt.d.ts +5 -0
  78. package/dist/utils/encrypt.d.ts.map +1 -0
  79. package/dist/utils/encrypt.js +53 -0
  80. package/dist/utils/file-metadata.d.ts +19 -13
  81. package/dist/utils.d.ts +14 -5
  82. package/package.json +6 -2
package/README.md CHANGED
@@ -93,3 +93,4 @@ Feel free to join in. All welcome. Please [open an issue](https://github.com/sto
93
93
  ## License
94
94
 
95
95
  Dual-licensed under [MIT + Apache 2.0](https://github.com/storacha/upload-service/blob/main/license.md)
96
+
@@ -1,14 +1,14 @@
1
- export const accessServiceURL: URL;
2
- export const accessServicePrincipal: client.PrincipalView<"did:web:web3.storage">;
3
- export const accessServiceConnection: client.ConnectionView<any>;
4
- export const uploadServiceURL: URL;
5
- export const uploadServicePrincipal: client.PrincipalView<"did:web:web3.storage">;
6
- export const uploadServiceConnection: client.ConnectionView<any>;
7
- export const filecoinServiceURL: URL;
8
- export const filecoinServicePrincipal: client.PrincipalView<"did:web:web3.storage">;
9
- export const filecoinServiceConnection: client.ConnectionView<any>;
1
+ export const accessServiceURL: URL
2
+ export const accessServicePrincipal: client.PrincipalView<'did:web:web3.storage'>
3
+ export const accessServiceConnection: client.ConnectionView<any>
4
+ export const uploadServiceURL: URL
5
+ export const uploadServicePrincipal: client.PrincipalView<'did:web:web3.storage'>
6
+ export const uploadServiceConnection: client.ConnectionView<any>
7
+ export const filecoinServiceURL: URL
8
+ export const filecoinServicePrincipal: client.PrincipalView<'did:web:web3.storage'>
9
+ export const filecoinServiceConnection: client.ConnectionView<any>
10
10
  /** @type {import('@storacha/client/types').ServiceConf} */
11
- export const serviceConf: import("@storacha/client/types").ServiceConf;
12
- export const receiptsEndpoint: URL;
13
- import * as client from '@ucanto/client';
14
- //# sourceMappingURL=service.d.ts.map
11
+ export const serviceConf: import('@storacha/client/types').ServiceConf
12
+ export const receiptsEndpoint: URL
13
+ import * as client from '@ucanto/client'
14
+ //# sourceMappingURL=service.d.ts.map
@@ -1,44 +1,57 @@
1
1
  /** @implements {Type.EncryptedClient} */
2
2
  export class EncryptedClient implements Type.EncryptedClient {
3
- /**
4
- * @param {import('@storacha/client').Client} storachaClient
5
- * @param {Type.CryptoAdapter} cryptoAdapter
6
- * @param {URL} gatewayURL
7
- */
8
- constructor(storachaClient: import("@storacha/client").Client, cryptoAdapter: Type.CryptoAdapter, gatewayURL: URL);
9
- /**
10
- * @type {Type.CryptoAdapter}
11
- * @protected
12
- */
13
- protected _cryptoAdapter: Type.CryptoAdapter;
14
- /**
15
- * @type {import('@storacha/client').Client}
16
- * @protected
17
- */
18
- protected _storachaClient: import("@storacha/client").Client;
19
- /**
20
- * @type {URL}
21
- * @protected
22
- */
23
- protected _gatewayURL: URL;
24
- /**
25
- * Encrypt and upload a file to the Storacha network
26
- *
27
- * @param {Type.BlobLike} file - The file to upload
28
- * @param {Type.EncryptionConfig} encryptionConfig - User-provided encryption configuration
29
- * @param {Type.UploadOptions} [uploadOptions] - User-provided upload options
30
- * @returns {Promise<Type.AnyLink>} - The link to the uploaded file
31
- */
32
- encryptAndUploadFile(file: Type.BlobLike, encryptionConfig: Type.EncryptionConfig, uploadOptions?: Type.UploadOptions): Promise<Type.AnyLink>;
33
- /**
34
- * Retrieve and decrypt a file from the Storacha network
35
- *
36
- * @param {Type.AnyLink} cid - The link to the file to retrieve
37
- * @param {Type.DecryptionConfig} decryptionConfig - User-provided decryption config
38
- * @returns {Promise<Type.DecryptionResult>} - The decrypted file with metadata
39
- */
40
- retrieveAndDecryptFile(cid: Type.AnyLink, decryptionConfig: Type.DecryptionConfig): Promise<Type.DecryptionResult>;
3
+ /**
4
+ * @param {import('@storacha/client').Client} storachaClient
5
+ * @param {Type.CryptoAdapter} cryptoAdapter
6
+ * @param {URL} gatewayURL
7
+ */
8
+ constructor(
9
+ storachaClient: import('@storacha/client').Client,
10
+ cryptoAdapter: Type.CryptoAdapter,
11
+ gatewayURL: URL
12
+ )
13
+ /**
14
+ * @type {Type.CryptoAdapter}
15
+ * @protected
16
+ */
17
+ protected _cryptoAdapter: Type.CryptoAdapter
18
+ /**
19
+ * @type {import('@storacha/client').Client}
20
+ * @protected
21
+ */
22
+ protected _storachaClient: import('@storacha/client').Client
23
+ /**
24
+ * @type {URL}
25
+ * @protected
26
+ */
27
+ protected _gatewayURL: URL
28
+ /**
29
+ * Encrypt and upload a file to the Storacha network
30
+ *
31
+ * @param {Type.BlobLike} file - The file to upload
32
+ * @param {Type.EncryptionConfig} encryptionConfig - User-provided encryption configuration
33
+ * @param {Type.UploadOptions} [uploadOptions] - User-provided upload options
34
+ * @returns {Promise<Type.AnyLink>} - The link to the uploaded file
35
+ */
36
+ encryptAndUploadFile(
37
+ file: Type.BlobLike,
38
+ encryptionConfig: Type.EncryptionConfig,
39
+ uploadOptions?: Type.UploadOptions
40
+ ): Promise<Type.AnyLink>
41
+ /**
42
+ * Retrieve and decrypt a file from the Storacha network
43
+ *
44
+ * @param {Type.AnyLink} cid - The link to the file to retrieve
45
+ * @param {Type.DecryptionConfig} decryptionConfig - User-provided decryption config
46
+ * @returns {Promise<Type.DecryptionResult>} - The decrypted file with metadata
47
+ */
48
+ retrieveAndDecryptFile(
49
+ cid: Type.AnyLink,
50
+ decryptionConfig: Type.DecryptionConfig
51
+ ): Promise<Type.DecryptionResult>
41
52
  }
42
- export function create(options: Type.EncryptedClientOptions): Promise<EncryptedClient>;
43
- import * as Type from '../types.js';
44
- //# sourceMappingURL=client.d.ts.map
53
+ export function create(
54
+ options: Type.EncryptedClientOptions
55
+ ): Promise<EncryptedClient>
56
+ import * as Type from '../types.js'
57
+ //# sourceMappingURL=client.d.ts.map
@@ -1,8 +1,8 @@
1
1
  export class UnknownFormat extends Failure {
2
- /** @param {string} [reason] */
3
- constructor(reason?: string);
4
- name: "UnknownFormat";
5
- #private;
2
+ /** @param {string} [reason] */
3
+ constructor(reason?: string)
4
+ name: 'UnknownFormat'
5
+ #private
6
6
  }
7
- import { Failure } from '@ucanto/core';
8
- //# sourceMappingURL=errors.d.ts.map
7
+ import { Failure } from '@ucanto/core'
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -1,8 +1,13 @@
1
- export function extract(archive: Uint8Array): any;
2
- export function create(strategy: "lit" | "kms", data: any): import("../../types.js").LitMetadataView | import("../../types.js").KMSMetadataView;
3
- export function getSupportedVersions(): string[];
4
- export function isVersionSupported(version: string): boolean;
5
- import * as LitMetadata from './lit-metadata.js';
6
- import * as KMSMetadata from './kms-metadata.js';
7
- export { LitMetadata, KMSMetadata };
8
- //# sourceMappingURL=encrypted-metadata.d.ts.map
1
+ export function extract(archive: Uint8Array): any
2
+ export function create(
3
+ strategy: 'lit' | 'kms',
4
+ data: any
5
+ ):
6
+ | import('../../types.js').LitMetadataView
7
+ | import('../../types.js').KMSMetadataView
8
+ export function getSupportedVersions(): string[]
9
+ export function isVersionSupported(version: string): boolean
10
+ import * as LitMetadata from './lit-metadata.js'
11
+ import * as KMSMetadata from './kms-metadata.js'
12
+ export { LitMetadata, KMSMetadata }
13
+ //# sourceMappingURL=encrypted-metadata.d.ts.map
@@ -1,36 +1,68 @@
1
- export const version: "encrypted-metadata@0.2";
2
- export const KMSMetadataSchema: Schema.VariantSchema<{
3
- "encrypted-metadata@0.2": Schema.StructSchema<{
4
- encryptedDataCID: Schema.Schema<Link.Link<unknown, number, number, 0 | 1>, any>;
5
- encryptedSymmetricKey: Schema.StringSchema<string, unknown>;
6
- space: Schema.StringSchema<string, unknown>;
7
- kms: Schema.StructSchema<{
8
- provider: Schema.StringSchema<string, unknown>;
9
- keyId: Schema.StringSchema<string, unknown>;
10
- algorithm: Schema.StringSchema<string, unknown>;
11
- }, any>;
12
- }, unknown>;
13
- }, unknown>;
14
- export const KMSMetadataInputSchema: Schema.StructSchema<{
15
- encryptedDataCID: Schema.StringSchema<string, unknown>;
16
- encryptedSymmetricKey: Schema.StringSchema<string, unknown>;
17
- space: Schema.StringSchema<string, unknown>;
18
- kms: Schema.StructSchema<{
19
- provider: Schema.StringSchema<string, unknown>;
20
- keyId: Schema.StringSchema<string, unknown>;
21
- algorithm: Schema.StringSchema<string, unknown>;
22
- }, any>;
23
- }, unknown>;
24
- export function create(kmsMetadataInput: Types.KMSMetadata | Types.KMSMetadataInput): Types.KMSMetadataView;
25
- export function toJSON(kmsMetadata: Types.KMSMetadataView): Types.KMSMetadataInput;
26
- export function parse(kmsMetadataInput: Types.KMSMetadataInput): Types.KMSMetadata;
27
- export function archiveBlock(kmsMetadataInput: Types.KMSMetadata): Promise<import("@ucanto/interface").Block>;
28
- export function archive(kmsMetadata: Types.KMSMetadata): Promise<Types.Result<Uint8Array>>;
29
- export function extract(archive: Uint8Array): Types.Result<Types.KMSMetadataView, Types.UnknownFormat>;
30
- export function view({ root }: {
31
- root: Types.IPLDBlock;
32
- }): Types.Result<Types.KMSMetadataView, Types.UnknownFormat>;
33
- import * as Link from 'multiformats/link';
34
- import { Schema } from '@ucanto/core';
35
- import * as Types from '../../types.js';
36
- //# sourceMappingURL=kms-metadata.d.ts.map
1
+ export const version: 'encrypted-metadata@0.2'
2
+ export const KMSMetadataSchema: Schema.VariantSchema<
3
+ {
4
+ 'encrypted-metadata@0.2': Schema.StructSchema<
5
+ {
6
+ encryptedDataCID: Schema.Schema<
7
+ Link.Link<unknown, number, number, 0 | 1>,
8
+ any
9
+ >
10
+ encryptedSymmetricKey: Schema.StringSchema<string, unknown>
11
+ space: Schema.StringSchema<string, unknown>
12
+ kms: Schema.StructSchema<
13
+ {
14
+ provider: Schema.StringSchema<string, unknown>
15
+ keyId: Schema.StringSchema<string, unknown>
16
+ algorithm: Schema.StringSchema<string, unknown>
17
+ },
18
+ any
19
+ >
20
+ },
21
+ unknown
22
+ >
23
+ },
24
+ unknown
25
+ >
26
+ export const KMSMetadataInputSchema: Schema.StructSchema<
27
+ {
28
+ encryptedDataCID: Schema.StringSchema<string, unknown>
29
+ encryptedSymmetricKey: Schema.StringSchema<string, unknown>
30
+ space: Schema.StringSchema<string, unknown>
31
+ kms: Schema.StructSchema<
32
+ {
33
+ provider: Schema.StringSchema<string, unknown>
34
+ keyId: Schema.StringSchema<string, unknown>
35
+ algorithm: Schema.StringSchema<string, unknown>
36
+ },
37
+ any
38
+ >
39
+ },
40
+ unknown
41
+ >
42
+ export function create(
43
+ kmsMetadataInput: Types.KMSMetadata | Types.KMSMetadataInput
44
+ ): Types.KMSMetadataView
45
+ export function toJSON(
46
+ kmsMetadata: Types.KMSMetadataView
47
+ ): Types.KMSMetadataInput
48
+ export function parse(
49
+ kmsMetadataInput: Types.KMSMetadataInput
50
+ ): Types.KMSMetadata
51
+ export function archiveBlock(
52
+ kmsMetadataInput: Types.KMSMetadata
53
+ ): Promise<import('@ucanto/interface').Block>
54
+ export function archive(
55
+ kmsMetadata: Types.KMSMetadata
56
+ ): Promise<Types.Result<Uint8Array>>
57
+ export function extract(
58
+ archive: Uint8Array
59
+ ): Types.Result<Types.KMSMetadataView, Types.UnknownFormat>
60
+ export function view({
61
+ root,
62
+ }: {
63
+ root: Types.IPLDBlock
64
+ }): Types.Result<Types.KMSMetadataView, Types.UnknownFormat>
65
+ import * as Link from 'multiformats/link'
66
+ import { Schema } from '@ucanto/core'
67
+ import * as Types from '../../types.js'
68
+ //# sourceMappingURL=kms-metadata.d.ts.map
@@ -1,28 +1,63 @@
1
- export const version: "encrypted-metadata@0.1";
2
- export const LitMetadataSchema: Schema.VariantSchema<{
3
- "encrypted-metadata@0.1": Schema.StructSchema<{
4
- encryptedDataCID: Schema.Schema<Link.Link<unknown, number, number, 0 | 1>, any>;
5
- identityBoundCiphertext: Schema.Schema<Uint8Array<ArrayBufferLike>, unknown>;
6
- plaintextKeyHash: Schema.Schema<Uint8Array<ArrayBufferLike>, unknown>;
7
- accessControlConditions: Schema.Schema<Schema.Dictionary<string, unknown>[], unknown>;
8
- }, unknown>;
9
- }, unknown>;
10
- export const LitMetadataInputSchema: Schema.StructSchema<{
11
- encryptedDataCID: Schema.StringSchema<string, unknown>;
12
- identityBoundCiphertext: Schema.StringSchema<string, unknown>;
13
- plaintextKeyHash: Schema.StringSchema<string, unknown>;
14
- accessControlConditions: Schema.Schema<Schema.Dictionary<string, unknown>[], unknown>;
15
- }, unknown>;
16
- export function create(encryptedMetadataInput: Types.LitMetadata | Types.LitMetadataInput): Types.LitMetadataView;
17
- export function toJSON(encryptedMetadata: Types.LitMetadataView): Types.LitMetadataInput;
18
- export function parse(encryptedMetadataInput: Types.LitMetadataInput): Types.LitMetadata;
19
- export function archiveBlock(encryptedMetadataInput: Types.LitMetadata): Promise<import("@ucanto/interface").Block>;
20
- export function archive(encryptedMetadata: Types.LitMetadata): Promise<Types.Result<Uint8Array>>;
21
- export function extract(archive: Uint8Array): Types.Result<Types.LitMetadataView, Types.UnknownFormat>;
22
- export function view({ root }: {
23
- root: Types.IPLDBlock;
24
- }): Types.Result<Types.LitMetadataView, Types.UnknownFormat>;
25
- import * as Link from 'multiformats/link';
26
- import { Schema } from '@ucanto/core';
27
- import * as Types from '../../types.js';
28
- //# sourceMappingURL=lit-metadata.d.ts.map
1
+ export const version: 'encrypted-metadata@0.1'
2
+ export const LitMetadataSchema: Schema.VariantSchema<
3
+ {
4
+ 'encrypted-metadata@0.1': Schema.StructSchema<
5
+ {
6
+ encryptedDataCID: Schema.Schema<
7
+ Link.Link<unknown, number, number, 0 | 1>,
8
+ any
9
+ >
10
+ identityBoundCiphertext: Schema.Schema<
11
+ Uint8Array<ArrayBufferLike>,
12
+ unknown
13
+ >
14
+ plaintextKeyHash: Schema.Schema<Uint8Array<ArrayBufferLike>, unknown>
15
+ accessControlConditions: Schema.Schema<
16
+ Schema.Dictionary<string, unknown>[],
17
+ unknown
18
+ >
19
+ },
20
+ unknown
21
+ >
22
+ },
23
+ unknown
24
+ >
25
+ export const LitMetadataInputSchema: Schema.StructSchema<
26
+ {
27
+ encryptedDataCID: Schema.StringSchema<string, unknown>
28
+ identityBoundCiphertext: Schema.StringSchema<string, unknown>
29
+ plaintextKeyHash: Schema.StringSchema<string, unknown>
30
+ accessControlConditions: Schema.Schema<
31
+ Schema.Dictionary<string, unknown>[],
32
+ unknown
33
+ >
34
+ },
35
+ unknown
36
+ >
37
+ export function create(
38
+ encryptedMetadataInput: Types.LitMetadata | Types.LitMetadataInput
39
+ ): Types.LitMetadataView
40
+ export function toJSON(
41
+ encryptedMetadata: Types.LitMetadataView
42
+ ): Types.LitMetadataInput
43
+ export function parse(
44
+ encryptedMetadataInput: Types.LitMetadataInput
45
+ ): Types.LitMetadata
46
+ export function archiveBlock(
47
+ encryptedMetadataInput: Types.LitMetadata
48
+ ): Promise<import('@ucanto/interface').Block>
49
+ export function archive(
50
+ encryptedMetadata: Types.LitMetadata
51
+ ): Promise<Types.Result<Uint8Array>>
52
+ export function extract(
53
+ archive: Uint8Array
54
+ ): Types.Result<Types.LitMetadataView, Types.UnknownFormat>
55
+ export function view({
56
+ root,
57
+ }: {
58
+ root: Types.IPLDBlock
59
+ }): Types.Result<Types.LitMetadataView, Types.UnknownFormat>
60
+ import * as Link from 'multiformats/link'
61
+ import { Schema } from '@ucanto/core'
62
+ import * as Types from '../../types.js'
63
+ //# sourceMappingURL=lit-metadata.d.ts.map