@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,7 +1,7 @@
1
- import { CARWriterStream } from 'carstream';
2
- import { createFileEncoderStream } from '@storacha/upload-client/unixfs';
3
- import * as Type from '../types.js';
4
- import { createFileWithMetadata } from '../utils/file-metadata.js';
1
+ import { CARWriterStream } from 'carstream'
2
+ import { createFileEncoderStream } from '@storacha/upload-client/unixfs'
3
+ import * as Type from '../types.js'
4
+ import { createFileWithMetadata } from '../utils/file-metadata.js'
5
5
  /**
6
6
  * Encrypt and upload a file to the Storacha network
7
7
  *
@@ -13,17 +13,31 @@ import { createFileWithMetadata } from '../utils/file-metadata.js';
13
13
  * @param {Type.UploadOptions} [uploadOptions] - User-provided upload options
14
14
  * @returns {Promise<Type.AnyLink>} - The link to the uploaded file
15
15
  */
16
- export const encryptAndUpload = async (storachaClient, cryptoAdapter, file, encryptionConfig, uploadOptions = {}) => {
17
- // Step 1: Validate required configuration
18
- if (!encryptionConfig.spaceDID)
19
- throw new Error('No space selected!');
20
- // Step 2: Encrypt the file using the crypto adapter
21
- const encryptedPayload = await encryptFile(cryptoAdapter, file, encryptionConfig);
22
- // Step 3: Build and upload the encrypted metadata to the Storacha network
23
- const rootCid = await buildAndUploadEncryptedMetadata(storachaClient, encryptedPayload, cryptoAdapter, uploadOptions);
24
- // Step 4: Return the root CID of the encrypted metadata
25
- return rootCid;
26
- };
16
+ export const encryptAndUpload = async (
17
+ storachaClient,
18
+ cryptoAdapter,
19
+ file,
20
+ encryptionConfig,
21
+ uploadOptions = {}
22
+ ) => {
23
+ // Step 1: Validate required configuration
24
+ if (!encryptionConfig.spaceDID) throw new Error('No space selected!')
25
+ // Step 2: Encrypt the file using the crypto adapter
26
+ const encryptedPayload = await encryptFile(
27
+ cryptoAdapter,
28
+ file,
29
+ encryptionConfig
30
+ )
31
+ // Step 3: Build and upload the encrypted metadata to the Storacha network
32
+ const rootCid = await buildAndUploadEncryptedMetadata(
33
+ storachaClient,
34
+ encryptedPayload,
35
+ cryptoAdapter,
36
+ uploadOptions
37
+ )
38
+ // Step 4: Return the root CID of the encrypted metadata
39
+ return rootCid
40
+ }
27
41
  /**
28
42
  * Upload encrypted metadata to the Storacha network
29
43
  *
@@ -33,33 +47,46 @@ export const encryptAndUpload = async (storachaClient, cryptoAdapter, file, encr
33
47
  * @param {Type.UploadOptions} [uploadOptions] - The upload options
34
48
  * @returns {Promise<Type.AnyLink>} - The link to the uploaded metadata
35
49
  */
36
- const buildAndUploadEncryptedMetadata = async (storachaClient, encryptedPayload, cryptoAdapter, uploadOptions) => {
37
- const { encryptedKey, metadata, encryptedBlobLike } = encryptedPayload;
38
- return storachaClient.uploadCAR({
39
- stream() {
40
- /** @type {any} */
41
- let root;
42
- return createFileEncoderStream(encryptedBlobLike)
43
- .pipeThrough(new TransformStream({
44
- transform(block, controller) {
45
- root = block;
46
- controller.enqueue(block);
47
- },
48
- async flush(controller) {
49
- if (!root)
50
- throw new Error('missing root block');
51
- const { cid, bytes } = await cryptoAdapter.encodeMetadata(root.cid.toString(), encryptedKey, metadata);
52
- controller.enqueue({ cid, bytes });
53
- },
54
- }))
55
- .pipeThrough(new CARWriterStream());
56
- },
57
- }, {
58
- ...uploadOptions,
59
- // the encrypted data won't be published to Filecoin, so we need to set pieceHasher to undefined
60
- pieceHasher: undefined,
61
- });
62
- };
50
+ const buildAndUploadEncryptedMetadata = async (
51
+ storachaClient,
52
+ encryptedPayload,
53
+ cryptoAdapter,
54
+ uploadOptions
55
+ ) => {
56
+ const { encryptedKey, metadata, encryptedBlobLike } = encryptedPayload
57
+ return storachaClient.uploadCAR(
58
+ {
59
+ stream() {
60
+ /** @type {any} */
61
+ let root
62
+ return createFileEncoderStream(encryptedBlobLike)
63
+ .pipeThrough(
64
+ new TransformStream({
65
+ transform(block, controller) {
66
+ root = block
67
+ controller.enqueue(block)
68
+ },
69
+ async flush(controller) {
70
+ if (!root) throw new Error('missing root block')
71
+ const { cid, bytes } = await cryptoAdapter.encodeMetadata(
72
+ root.cid.toString(),
73
+ encryptedKey,
74
+ metadata
75
+ )
76
+ controller.enqueue({ cid, bytes })
77
+ },
78
+ })
79
+ )
80
+ .pipeThrough(new CARWriterStream())
81
+ },
82
+ },
83
+ {
84
+ ...uploadOptions,
85
+ // the encrypted data won't be published to Filecoin, so we need to set pieceHasher to undefined
86
+ pieceHasher: undefined,
87
+ }
88
+ )
89
+ }
63
90
  /**
64
91
  * Encrypt a file with embedded metadata using the crypto adapter and return the encrypted payload.
65
92
  * The encrypted payload contains the encrypted file, the encrypted symmetric key, and the metadata.
@@ -71,18 +98,27 @@ const buildAndUploadEncryptedMetadata = async (storachaClient, encryptedPayload,
71
98
  * @returns {Promise<Type.EncryptionPayload>} - The encrypted file
72
99
  */
73
100
  const encryptFile = async (cryptoAdapter, file, encryptionConfig) => {
74
- // Step 1: Embed metadata in file content if provided
75
- const fileWithMetadata = createFileWithMetadata(file, encryptionConfig.fileMetadata);
76
- // Step 2: Encrypt the file (with embedded metadata) using the crypto adapter
77
- const { key, iv, encryptedStream } = await cryptoAdapter.encryptStream(fileWithMetadata);
78
- // Step 3: Use crypto adapter to encrypt the symmetric key
79
- const keyResult = await cryptoAdapter.encryptSymmetricKey(key, iv, encryptionConfig);
80
- // Step 4: Return the encrypted payload (no separate metadata needed)
81
- return {
82
- strategy: keyResult.strategy,
83
- encryptedKey: keyResult.encryptedKey,
84
- metadata: keyResult.metadata,
85
- encryptedBlobLike: { stream: () => encryptedStream },
86
- };
87
- };
88
- //# sourceMappingURL=encrypt-handler.js.map
101
+ // Step 1: Embed metadata in file content if provided
102
+ const fileWithMetadata = createFileWithMetadata(
103
+ file,
104
+ encryptionConfig.fileMetadata
105
+ )
106
+ // Step 2: Encrypt the file (with embedded metadata) using the crypto adapter
107
+ const { key, iv, encryptedStream } = await cryptoAdapter.encryptStream(
108
+ fileWithMetadata
109
+ )
110
+ // Step 3: Use crypto adapter to encrypt the symmetric key
111
+ const keyResult = await cryptoAdapter.encryptSymmetricKey(
112
+ key,
113
+ iv,
114
+ encryptionConfig
115
+ )
116
+ // Step 4: Return the encrypted payload (no separate metadata needed)
117
+ return {
118
+ strategy: keyResult.strategy,
119
+ encryptedKey: keyResult.encryptedKey,
120
+ metadata: keyResult.metadata,
121
+ encryptedBlobLike: { stream: () => encryptedStream },
122
+ }
123
+ }
124
+ //# sourceMappingURL=encrypt-handler.js.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { create } from "./core/client.js";
2
- //# sourceMappingURL=index.d.ts.map
1
+ export { create } from './core/client.js'
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { create } from './core/client.js';
2
- //# sourceMappingURL=index.js.map
1
+ export { create } from './core/client.js'
2
+ //# sourceMappingURL=index.js.map
@@ -1,13 +1,22 @@
1
1
  /**
2
2
  * Get a LitClient instance.
3
3
  */
4
- export function getLitClient(): Promise<LitNodeClient>;
4
+ export function getLitClient(): Promise<LitNodeClient>
5
5
  /**
6
6
  * @param {LitNodeClient} litClient
7
7
  * @param {Type.SessionSignatureOptions} param0
8
8
  * @returns {Promise<import('@lit-protocol/types').SessionSigsMap>}
9
9
  */
10
- export function getSessionSigs(litClient: LitNodeClient, { wallet, accessControlConditions, dataToEncryptHash, expiration, capabilityAuthSigs, }: Type.SessionSignatureOptions): Promise<import("@lit-protocol/types").SessionSigsMap>;
10
+ export function getSessionSigs(
11
+ litClient: LitNodeClient,
12
+ {
13
+ wallet,
14
+ accessControlConditions,
15
+ dataToEncryptHash,
16
+ expiration,
17
+ capabilityAuthSigs,
18
+ }: Type.SessionSignatureOptions
19
+ ): Promise<import('@lit-protocol/types').SessionSigsMap>
11
20
  /**
12
21
  * Get session signatures for a PKP key and auth method.
13
22
  * There is not need to execute the auth callback for this function, because the auth method provided.
@@ -16,10 +25,25 @@ export function getSessionSigs(litClient: LitNodeClient, { wallet, accessControl
16
25
  * @param {Type.PkpSessionSignatureOptions} options
17
26
  * @returns {Promise<import('@lit-protocol/types').SessionSigsMap>}
18
27
  */
19
- export function getPkpSessionSigs(litClient: LitNodeClient, { pkpPublicKey, authMethod, accessControlConditions, dataToEncryptHash, expiration, capabilityAuthSigs, }: Type.PkpSessionSignatureOptions): Promise<import("@lit-protocol/types").SessionSigsMap>;
20
- export { encryptString } from "@lit-protocol/encryption";
21
- export function getAccessControlConditions(spaceDID: Type.SpaceDID): import("@lit-protocol/types").AccessControlConditions;
22
- export function executeUcanValidationAction(litClient: LitNodeClient, options: Type.ExecuteUcanValidationOptions): Promise<any>;
23
- import { LitNodeClient } from '@lit-protocol/lit-node-client';
24
- import * as Type from '../types.js';
25
- //# sourceMappingURL=lit.d.ts.map
28
+ export function getPkpSessionSigs(
29
+ litClient: LitNodeClient,
30
+ {
31
+ pkpPublicKey,
32
+ authMethod,
33
+ accessControlConditions,
34
+ dataToEncryptHash,
35
+ expiration,
36
+ capabilityAuthSigs,
37
+ }: Type.PkpSessionSignatureOptions
38
+ ): Promise<import('@lit-protocol/types').SessionSigsMap>
39
+ export { encryptString } from '@lit-protocol/encryption'
40
+ export function getAccessControlConditions(
41
+ spaceDID: Type.SpaceDID
42
+ ): import('@lit-protocol/types').AccessControlConditions
43
+ export function executeUcanValidationAction(
44
+ litClient: LitNodeClient,
45
+ options: Type.ExecuteUcanValidationOptions
46
+ ): Promise<any>
47
+ import { LitNodeClient } from '@lit-protocol/lit-node-client'
48
+ import * as Type from '../types.js'
49
+ //# sourceMappingURL=lit.d.ts.map
@@ -1,10 +1,15 @@
1
- import { LitNodeClient } from '@lit-protocol/lit-node-client';
2
- import { LIT_ABILITY } from '@lit-protocol/constants';
3
- import { generateAuthSig, LitActionResource, createSiweMessage, LitAccessControlConditionResource, } from '@lit-protocol/auth-helpers';
4
- import env from '../config/env.js';
5
- import * as Type from '../types.js';
6
- import { STORACHA_LIT_ACTION_CID } from '../config/constants.js';
7
- export { encryptString } from '@lit-protocol/encryption';
1
+ import { LitNodeClient } from '@lit-protocol/lit-node-client'
2
+ import { LIT_ABILITY } from '@lit-protocol/constants'
3
+ import {
4
+ generateAuthSig,
5
+ LitActionResource,
6
+ createSiweMessage,
7
+ LitAccessControlConditionResource,
8
+ } from '@lit-protocol/auth-helpers'
9
+ import env from '../config/env.js'
10
+ import * as Type from '../types.js'
11
+ import { STORACHA_LIT_ACTION_CID } from '../config/constants.js'
12
+ export { encryptString } from '@lit-protocol/encryption'
8
13
  /**
9
14
  * Create access control conditions required to use Lit Protocol.
10
15
  * This ensures that the Storacha Lit Action is used to validate decryption permissions for the specified space DID.
@@ -13,68 +18,85 @@ export { encryptString } from '@lit-protocol/encryption';
13
18
  * @returns {import('@lit-protocol/types').AccessControlConditions} - The access control conditions
14
19
  */
15
20
  export const getAccessControlConditions = (spaceDID) => {
16
- return [
17
- {
18
- contractAddress: '',
19
- standardContractType: '',
20
- chain: 'ethereum',
21
- method: '',
22
- parameters: [':currentActionIpfsId', spaceDID],
23
- returnValueTest: {
24
- comparator: '=',
25
- value: STORACHA_LIT_ACTION_CID,
26
- },
27
- },
28
- ];
29
- };
21
+ return [
22
+ {
23
+ contractAddress: '',
24
+ standardContractType: '',
25
+ chain: 'ethereum',
26
+ method: '',
27
+ parameters: [':currentActionIpfsId', spaceDID],
28
+ returnValueTest: {
29
+ comparator: '=',
30
+ value: STORACHA_LIT_ACTION_CID,
31
+ },
32
+ },
33
+ ]
34
+ }
30
35
  /**
31
36
  * Get a LitClient instance.
32
37
  */
33
38
  export async function getLitClient() {
34
- const litNodeClient = new LitNodeClient({
35
- litNetwork: env.LIT_NETWORK,
36
- debug: env.LIT_DEBUG,
37
- });
38
- await litNodeClient.connect();
39
- return litNodeClient;
39
+ const litNodeClient = new LitNodeClient({
40
+ litNetwork: env.LIT_NETWORK,
41
+ debug: env.LIT_DEBUG,
42
+ })
43
+ await litNodeClient.connect()
44
+ return litNodeClient
40
45
  }
41
46
  /**
42
47
  * @param {LitNodeClient} litClient
43
48
  * @param {Type.SessionSignatureOptions} param0
44
49
  * @returns {Promise<import('@lit-protocol/types').SessionSigsMap>}
45
50
  */
46
- export async function getSessionSigs(litClient, { wallet, accessControlConditions, dataToEncryptHash, expiration, capabilityAuthSigs, }) {
47
- const accsResourceString = await LitAccessControlConditionResource.generateResourceString(accessControlConditions, dataToEncryptHash);
48
- const sessionSigs = await litClient.getSessionSigs({
49
- chain: 'ethereum',
50
- capabilityAuthSigs,
51
+ export async function getSessionSigs(
52
+ litClient,
53
+ {
54
+ wallet,
55
+ accessControlConditions,
56
+ dataToEncryptHash,
57
+ expiration,
58
+ capabilityAuthSigs,
59
+ }
60
+ ) {
61
+ const accsResourceString =
62
+ await LitAccessControlConditionResource.generateResourceString(
63
+ accessControlConditions,
64
+ dataToEncryptHash
65
+ )
66
+ const sessionSigs = await litClient.getSessionSigs({
67
+ chain: 'ethereum',
68
+ capabilityAuthSigs,
69
+ expiration,
70
+ resourceAbilityRequests: [
71
+ {
72
+ resource: new LitAccessControlConditionResource(accsResourceString),
73
+ ability: LIT_ABILITY.AccessControlConditionDecryption,
74
+ },
75
+ {
76
+ resource: new LitActionResource('*'),
77
+ ability: LIT_ABILITY.LitActionExecution,
78
+ },
79
+ ],
80
+ authNeededCallback: async ({
81
+ uri,
82
+ expiration,
83
+ resourceAbilityRequests,
84
+ }) => {
85
+ const toSign = await createSiweMessage({
86
+ uri,
51
87
  expiration,
52
- resourceAbilityRequests: [
53
- {
54
- resource: new LitAccessControlConditionResource(accsResourceString),
55
- ability: LIT_ABILITY.AccessControlConditionDecryption,
56
- },
57
- {
58
- resource: new LitActionResource('*'),
59
- ability: LIT_ABILITY.LitActionExecution,
60
- },
61
- ],
62
- authNeededCallback: async ({ uri, expiration, resourceAbilityRequests, }) => {
63
- const toSign = await createSiweMessage({
64
- uri,
65
- expiration,
66
- resources: resourceAbilityRequests,
67
- walletAddress: wallet.address,
68
- nonce: await litClient.getLatestBlockhash(),
69
- litNodeClient: litClient,
70
- });
71
- return await generateAuthSig({
72
- signer: wallet,
73
- toSign,
74
- });
75
- },
76
- });
77
- return sessionSigs;
88
+ resources: resourceAbilityRequests,
89
+ walletAddress: wallet.address,
90
+ nonce: await litClient.getLatestBlockhash(),
91
+ litNodeClient: litClient,
92
+ })
93
+ return await generateAuthSig({
94
+ signer: wallet,
95
+ toSign,
96
+ })
97
+ },
98
+ })
99
+ return sessionSigs
78
100
  }
79
101
  /**
80
102
  * Get session signatures for a PKP key and auth method.
@@ -84,25 +106,39 @@ export async function getSessionSigs(litClient, { wallet, accessControlCondition
84
106
  * @param {Type.PkpSessionSignatureOptions} options
85
107
  * @returns {Promise<import('@lit-protocol/types').SessionSigsMap>}
86
108
  */
87
- export async function getPkpSessionSigs(litClient, { pkpPublicKey, authMethod, accessControlConditions, dataToEncryptHash, expiration, capabilityAuthSigs, }) {
88
- const accsResourceString = await LitAccessControlConditionResource.generateResourceString(accessControlConditions, dataToEncryptHash);
89
- const sessionSigs = await litClient.getPkpSessionSigs({
90
- pkpPublicKey,
91
- authMethods: [authMethod],
92
- resourceAbilityRequests: [
93
- {
94
- resource: new LitAccessControlConditionResource(accsResourceString),
95
- ability: LIT_ABILITY.AccessControlConditionDecryption,
96
- },
97
- {
98
- resource: new LitActionResource('*'),
99
- ability: LIT_ABILITY.LitActionExecution,
100
- },
101
- ],
102
- expiration,
103
- capabilityAuthSigs,
104
- });
105
- return sessionSigs;
109
+ export async function getPkpSessionSigs(
110
+ litClient,
111
+ {
112
+ pkpPublicKey,
113
+ authMethod,
114
+ accessControlConditions,
115
+ dataToEncryptHash,
116
+ expiration,
117
+ capabilityAuthSigs,
118
+ }
119
+ ) {
120
+ const accsResourceString =
121
+ await LitAccessControlConditionResource.generateResourceString(
122
+ accessControlConditions,
123
+ dataToEncryptHash
124
+ )
125
+ const sessionSigs = await litClient.getPkpSessionSigs({
126
+ pkpPublicKey,
127
+ authMethods: [authMethod],
128
+ resourceAbilityRequests: [
129
+ {
130
+ resource: new LitAccessControlConditionResource(accsResourceString),
131
+ ability: LIT_ABILITY.AccessControlConditionDecryption,
132
+ },
133
+ {
134
+ resource: new LitActionResource('*'),
135
+ ability: LIT_ABILITY.LitActionExecution,
136
+ },
137
+ ],
138
+ expiration,
139
+ capabilityAuthSigs,
140
+ })
141
+ return sessionSigs
106
142
  }
107
143
  /**
108
144
  *
@@ -111,24 +147,24 @@ export async function getPkpSessionSigs(litClient, { pkpPublicKey, authMethod, a
111
147
  * @returns
112
148
  */
113
149
  export const executeUcanValidationAction = async (litClient, options) => {
114
- const { sessionSigs, ...jsParams } = options;
115
- const litActionResponse = await litClient.executeJs({
116
- ipfsId: STORACHA_LIT_ACTION_CID,
117
- sessionSigs,
118
- jsParams,
119
- });
120
- if (!litActionResponse.response) {
121
- throw new Error('Error getting lit action response.');
122
- }
123
- const parsedResponse = JSON.parse(
124
- /** @type string*/ (litActionResponse.response));
125
- const decryptedData = parsedResponse.decryptedString;
126
- if (!decryptedData) {
127
- let errorMsg;
128
- if (parsedResponse.error)
129
- errorMsg = parsedResponse.error;
130
- throw new Error(`Decrypted data does not exist! Error message: ${errorMsg}`);
131
- }
132
- return decryptedData;
133
- };
134
- //# sourceMappingURL=lit.js.map
150
+ const { sessionSigs, ...jsParams } = options
151
+ const litActionResponse = await litClient.executeJs({
152
+ ipfsId: STORACHA_LIT_ACTION_CID,
153
+ sessionSigs,
154
+ jsParams,
155
+ })
156
+ if (!litActionResponse.response) {
157
+ throw new Error('Error getting lit action response.')
158
+ }
159
+ const parsedResponse = JSON.parse(
160
+ /** @type string*/ (litActionResponse.response)
161
+ )
162
+ const decryptedData = parsedResponse.decryptedString
163
+ if (!decryptedData) {
164
+ let errorMsg
165
+ if (parsedResponse.error) errorMsg = parsedResponse.error
166
+ throw new Error(`Decrypted data does not exist! Error message: ${errorMsg}`)
167
+ }
168
+ return decryptedData
169
+ }
170
+ //# sourceMappingURL=lit.js.map
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=cid-verification.spec.d.ts.map
1
+ export {}
2
+ //# sourceMappingURL=cid-verification.spec.d.ts.map