diff --git a/package.json b/package.json index 2aa708e339..f133b5f96b 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,14 @@ "publish-manual-prerelease": "lerna publish prerelease --conventional-commits --conventional-prerelease --exact --no-git-tag-version --no-push --preid next --no-verify-access --dist-tag next", "publish-prerelease": "FORCE_PUBLISH=$(lerna changed --json | jq '. | map(.name) | join (\",\")' -r) && echo $FORCE_PUBLISH && lerna publish --conventional-commits --conventional-prerelease --exact --no-git-tag-version --no-push --preid next --no-verify-access --dist-tag next --yes --force-publish=${FORCE_PUBLISH}", "deploy:contracts": "yarn workspace @requestnetwork/smart-contracts deploy", - "start:request-node": "yarn workspace @requestnetwork/request-node start", + "start:request-node": "LIT_PROTOCOL_NETWORK=datil-dev yarn workspace @requestnetwork/request-node start", "test": "lerna run test", "format": "prettier . -w", "format:check": "prettier . -c", - "link:all": "for d in packages/*; do cd $d; yarn link; cd -; done", - "unlink:all": "for d in packages/*; do cd $d; yarn unlink; cd -; done" + "link:all-npm": "for d in packages/*; do cd $d; npm link; cd -; done", + "unlink:all-npm": "for d in packages/*; do cd $d; npm unlink; cd -; done", + "link:all-yarn": "for d in packages/*; do cd $d; yarn link; cd -; done", + "unlink:all-yarn": "for d in packages/*; do cd $d; yarn unlink; cd -; done" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "4.18.0", diff --git a/packages/ethereum-storage/test/ipfs-manager.test.ts b/packages/ethereum-storage/test/ipfs-manager.test.ts index 65ce06544c..2de522fa2b 100644 --- a/packages/ethereum-storage/test/ipfs-manager.test.ts +++ b/packages/ethereum-storage/test/ipfs-manager.test.ts @@ -3,6 +3,7 @@ import IpfsManager from '../src/ipfs-manager'; import { setupServer } from 'msw/node'; import { HttpResponse, delay, http } from 'msw'; +jest.setTimeout(30000); const testErrorHandling: StorageTypes.IIpfsErrorHandlingConfiguration = { delayBetweenRetries: 0, maxRetries: 0, diff --git a/packages/integration-test/jest.config.js b/packages/integration-test/jest.config.js index be20f1cb6c..e55a286829 100644 --- a/packages/integration-test/jest.config.js +++ b/packages/integration-test/jest.config.js @@ -1,3 +1,8 @@ +// The error ReferenceError: crypto is not defined occurs because the Node.js environment needs the crypto module to be explicitly available. +// For Node.js versions before 19, you need to add the crypto global explicitly. +const { webcrypto } = require('crypto'); +global.crypto = webcrypto; + const jestCommonConfig = require('../../jest.config'); /** @type {import('jest').Config} */ diff --git a/packages/integration-test/package.json b/packages/integration-test/package.json index b3a7407fbd..76359b4571 100644 --- a/packages/integration-test/package.json +++ b/packages/integration-test/package.json @@ -29,7 +29,7 @@ "build": "tsc -b tsconfig.build.json", "clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo", "lint": "eslint \"test/**/*.ts\"", - "test": "run-s test:node test:layers", + "test": "run-s test:lit test:node test:layers", "test:scheduled": "run-s test:erc20 test:any test:erc777 test:eth test:btc ", "test:layers": "jest test/layers.test.ts --forceExit", "test:node": "jest test/node-client.test.ts --forceExit", @@ -37,9 +37,11 @@ "test:eth": "jest test/scheduled/eth*.test.ts --forceExit", "test:erc20": "jest test/scheduled/erc20*.test.ts --forceExit", "test:erc777": "jest test/scheduled/erc777*.test.ts --forceExit", - "test:btc": "jest test/scheduled/btc.test.ts --forceExit" + "test:btc": "jest test/scheduled/btc.test.ts --forceExit", + "test:lit": "jest test/lit-protocol.test.ts --forceExit" }, "devDependencies": { + "@lit-protocol/lit-node-client": "7.0.2", "@requestnetwork/advanced-logic": "0.47.0", "@requestnetwork/currency": "0.21.0", "@requestnetwork/data-access": "0.38.0", diff --git a/packages/integration-test/test/lit-protocol.test.ts b/packages/integration-test/test/lit-protocol.test.ts new file mode 100644 index 0000000000..ac90efaee3 --- /dev/null +++ b/packages/integration-test/test/lit-protocol.test.ts @@ -0,0 +1,220 @@ +import { EthereumPrivateKeySignatureProvider } from '@requestnetwork/epk-signature'; +import { LitProtocolCipherProvider } from '@requestnetwork/lit-protocol-cipher'; +import { RequestNetwork, Types, Utils } from '@requestnetwork/request-client.js'; +import { ethers } from 'ethers'; +import { LitNodeClient } from '@lit-protocol/lit-node-client'; + +jest.setTimeout(30000); +const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); + +async function waitForConfirmation(request: any, maxAttempts = 10, delayMs = 1000): Promise { + let attempts = 0; + while (attempts < maxAttempts) { + try { + const data = await request.getData(); + if (data.state === Types.RequestLogic.STATE.CREATED) { + console.log(`Request confirmed with state: ${data.state}`); + return; + } + console.log( + `Attempt ${attempts + 1}: Request not confirmed yet. Current state: ${data.state}`, + ); + } catch (error) { + console.log(`Attempt ${attempts + 1} failed:`, error); + } + await sleep(delayMs); + attempts++; + } + throw new Error(`Request not confirmed after ${maxAttempts} attempts`); +} + +describe('Lit Protocol Integration Tests', () => { + let requestNetwork: RequestNetwork; + let litProvider: LitProtocolCipherProvider; + let epkSignatureProvider: EthereumPrivateKeySignatureProvider; + let userWallet: ethers.Wallet; + let litClient: LitNodeClient; + + const nodeConnectionConfig = { + baseURL: 'http://localhost:3000', + headers: { + 'Content-Type': 'application/json', + }, + }; + + beforeAll(async () => { + // Create wallet + userWallet = new ethers.Wallet( + '0x7b595b2bb732edddc4d4fe758ae528c7a748c40f0f6220f4494e214f15c5bfeb', + ); + + // Initialize signature provider + epkSignatureProvider = new EthereumPrivateKeySignatureProvider({ + method: Types.Signature.METHOD.ECDSA, + privateKey: userWallet.privateKey, + }); + + // Initialize Lit Protocol client + litClient = new LitNodeClient({ + litNetwork: 'datil-dev', + alertWhenUnauthorized: false, + debug: false, + }); + + // Initialize Lit Protocol provider + litProvider = new LitProtocolCipherProvider(litClient, nodeConnectionConfig); + await litProvider.initializeClient(); + await litProvider.enableDecryption(true); + await litProvider.getSessionSignatures(userWallet, userWallet.address); + + // Initialize Request Network client + requestNetwork = new RequestNetwork({ + nodeConnectionConfig, + signatureProvider: epkSignatureProvider, + cipherProvider: litProvider, + }); + }, 30000); + + afterAll(async () => { + try { + // Get all pending promises + const promises = []; + if (litProvider) { + promises.push(litProvider.disconnectClient()); + promises.push(litProvider.disconnectWallet()); + } + if (litClient) { + promises.push(litClient.disconnect()); + } + + // Wait for all cleanup operations to complete + await Promise.all(promises); + } catch (error) { + console.error('Cleanup error:', error); + } + }); + + it('should encrypt and decrypt data directly', async () => { + const testData = 'test encryption'; + const encryptionParams = [ + { + key: userWallet.address, + method: Types.Encryption.METHOD.KMS, + }, + ]; + + const encrypted = await litProvider.encrypt(testData, { encryptionParams }); + expect(encrypted).toBeDefined(); + expect(encrypted?.ciphertext).toBeDefined(); + expect(encrypted?.dataToEncryptHash).toBeDefined(); + + const decrypted = await litProvider.decrypt(encrypted!, { encryptionParams }); + expect(decrypted).toBe(testData); + }); + + it('should create and encrypt a request', async () => { + const requestParams = { + requestInfo: { + currency: { + type: Types.RequestLogic.CURRENCY.ETH, + value: '0x0000000000000000000000000000000000000000', + network: 'sepolia', + }, + expectedAmount: ethers.utils.parseEther('0.1').toString(), + payee: { + type: Types.Identity.TYPE.ETHEREUM_ADDRESS, + value: userWallet.address, + }, + payer: { + type: Types.Identity.TYPE.ETHEREUM_ADDRESS, + value: '0xb07D2398d2004378cad234DA0EF14f1c94A530e4', + }, + timestamp: Utils.getCurrentTimestampInSecond(), + }, + paymentNetwork: { + id: Types.Extension.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT, + parameters: { + paymentNetworkName: 'sepolia', + paymentAddress: userWallet.address, + feeAddress: '0x0000000000000000000000000000000000000000', + feeAmount: '0', + tokenAddress: '0x0000000000000000000000000000000000000000', + }, + }, + contentData: { + meta: { + format: 'rnf_invoice', + version: '0.0.3', + }, + creationDate: new Date().toISOString(), + invoiceNumber: 'INV-2023-001', + invoiceItems: [ + { + name: 'Test Service', + quantity: 1, + unitPrice: ethers.utils.parseEther('0.1').toString(), + discount: '0', + tax: { + type: 'percentage', + amount: '0', + }, + currency: 'ETH', + }, + ], + }, + signer: { + type: Types.Identity.TYPE.ETHEREUM_ADDRESS, + value: userWallet.address, + }, + }; + + const encryptionParams = [ + { + key: userWallet.address, + method: Types.Encryption.METHOD.KMS, + }, + ]; + + const encryptedRequest = await requestNetwork._createEncryptedRequest( + requestParams as Types.ICreateRequestParameters, + encryptionParams, + ); + + await waitForConfirmation(encryptedRequest, 15, 2000); + + const requestData = await encryptedRequest.getData(); + expect(requestData).toBeDefined(); + expect([Types.RequestLogic.STATE.CREATED]).toContain(requestData.state); + }); + + it('should handle encryption errors gracefully', async () => { + const invalidEncryptionParams = [ + { + key: '', + method: Types.Encryption.METHOD.KMS, + }, + ]; + + await expect( + litProvider.encrypt('test data', { encryptionParams: invalidEncryptionParams }), + ).rejects.toThrow(/invalid.*key/i); + }); + + it('should handle decryption errors gracefully', async () => { + const invalidEncryptedData = { + ciphertext: 'invalid-ciphertext', + dataToEncryptHash: 'invalid-hash', + }; + + await expect( + litProvider.decrypt(invalidEncryptedData, { + encryptionParams: [ + { + key: userWallet.address, + method: Types.Encryption.METHOD.KMS, + }, + ], + }), + ).rejects.toThrow(); + }); +}); diff --git a/packages/integration-test/tsconfig.build.json b/packages/integration-test/tsconfig.build.json index a04a35939e..63a328bca3 100644 --- a/packages/integration-test/tsconfig.build.json +++ b/packages/integration-test/tsconfig.build.json @@ -12,6 +12,7 @@ { "path": "../ethereum-storage/tsconfig.build.json" }, { "path": "../epk-decryption/tsconfig.build.json" }, { "path": "../epk-signature/tsconfig.build.json" }, + { "path": "../lit-protocol-cipher/tsconfig.build.json" }, { "path": "../multi-format/tsconfig.build.json" }, { "path": "../payment-processor/tsconfig.build.json" }, { "path": "../request-logic/tsconfig.build.json" }, diff --git a/packages/lit-protocol-cipher/README.md b/packages/lit-protocol-cipher/README.md index 2ce1a92978..6af641635f 100644 --- a/packages/lit-protocol-cipher/README.md +++ b/packages/lit-protocol-cipher/README.md @@ -1,8 +1,8 @@ # @requestnetwork/lit-protocol-cipher -Lit Protocol Provider. +Lit Protocol Provider for Request Network. -`@requestnetwork/lit-protocol-cipher` is a typescript library part of the [Request Network protocol](https://github.com/RequestNetwork/requestNetwork). +`@requestnetwork/lit-protocol-cipher` is a typescript library part of the [Request Network protocol](https://github.com/RequestNetwork/requestNetwork) that provides encryption and decryption capabilities using the Lit Protocol. ## Installation @@ -12,22 +12,33 @@ npm install @requestnetwork/lit-protocol-cipher ## Usage -The `LitProvider` class provides encryption and decryption capabilities using the Lit Protocol. Here's how to implement and use it: +The `LitProtocolCipherProvider` class provides encryption and decryption capabilities using the Lit Protocol. Here's how to implement and use it: ```typescript import { ethers } from 'ethers'; -import LitProvider from './LitProvider'; +import { LitProtocolCipherProvider } from '@requestnetwork/lit-protocol-cipher'; import { LIT_NETWORKS } from '@lit-protocol/types'; +import { LitNodeClient } from '@lit-protocol/lit-node-client'; // Initialize the provider -const litProvider = new LitProvider( - 'ethereum', // chain - LIT_NETWORKS.MAINNET, // network +const litProvider = new LitProtocolCipherProvider( + new LitNodeClient({ + litNetwork: LIT_NETWORKS.datil, + }), { - nodeUrl: 'https://your-request-network-node.com', + baseURL: 'https://gnosis.gateway.request.network', + headers: { + 'Content-Type': 'application/json', + }, }, // nodeConnectionConfig ); +// Initialize the client +await litProvider.initializeClient(); + +// Enable decryption +await litProvider.enableDecryption(true); + // Example usage with wallet connection async function example() { try { @@ -70,11 +81,11 @@ async function example() { const parsedData = JSON.parse(decryptedData); console.log('Decrypted data:', parsedData); } - - // Disconnect wallet when done - await litProvider.disconnectWallet(); } catch (error) { console.error('Error:', error); + } finally { + // Disconnect wallet when done + await litProvider.disconnectWallet(); } } diff --git a/packages/lit-protocol-cipher/package.json b/packages/lit-protocol-cipher/package.json index cc506e45ea..f7d04cbe5d 100644 --- a/packages/lit-protocol-cipher/package.json +++ b/packages/lit-protocol-cipher/package.json @@ -40,13 +40,13 @@ "test:watch": "yarn test --watch" }, "dependencies": { - "@lit-protocol/auth-helpers": "7.0.0", - "@lit-protocol/constants": "7.0.0", + "@lit-protocol/auth-helpers": "7.0.2", + "@lit-protocol/constants": "7.0.2", "@lit-protocol/contracts": "0.0.74", - "@lit-protocol/encryption": "7.0.0", - "@lit-protocol/lit-node-client": "7.0.0", - "@lit-protocol/lit-node-client-nodejs": "7.0.0", - "@lit-protocol/types": "7.0.0", + "@lit-protocol/encryption": "7.0.2", + "@lit-protocol/lit-node-client": "7.0.2", + "@lit-protocol/lit-node-client-nodejs": "7.0.2", + "@lit-protocol/types": "7.0.2", "@requestnetwork/request-client.js": "0.52.0", "@requestnetwork/types": "0.47.0", "@walletconnect/modal": "2.7.0", diff --git a/packages/lit-protocol-cipher/src/index.ts b/packages/lit-protocol-cipher/src/index.ts index f50bf965d3..4139b73daf 100644 --- a/packages/lit-protocol-cipher/src/index.ts +++ b/packages/lit-protocol-cipher/src/index.ts @@ -1 +1 @@ -export { default as LitProtocolProvider } from './lit-protocol-cipher-provider'; +export { default as LitProtocolCipherProvider } from './lit-protocol-cipher-provider'; diff --git a/packages/lit-protocol-cipher/src/lit-protocol-cipher-provider.ts b/packages/lit-protocol-cipher/src/lit-protocol-cipher-provider.ts index ceaf650065..2637cd8688 100644 --- a/packages/lit-protocol-cipher/src/lit-protocol-cipher-provider.ts +++ b/packages/lit-protocol-cipher/src/lit-protocol-cipher-provider.ts @@ -6,9 +6,7 @@ import { EncryptResponse, AccsDefaultParams, AuthSig, - LIT_NETWORKS_KEYS, AuthCallbackParams, - StorageProvider, } from '@lit-protocol/types'; import { LitAccessControlConditionResource, @@ -17,26 +15,21 @@ import { } from '@lit-protocol/auth-helpers'; import { Signer } from 'ethers'; import { LIT_ABILITY } from '@lit-protocol/constants'; -import { disconnectWeb3, LitNodeClient } from '@lit-protocol/lit-node-client'; -import type { LitNodeClientNodeJs } from '@lit-protocol/lit-node-client'; +import { disconnectWeb3 } from '@lit-protocol/lit-node-client'; +import type { LitNodeClientNodeJs, LitNodeClient } from '@lit-protocol/lit-node-client'; /** - * @class LitProvider + * @class LitProtocolCipherProvider * @description A provider class that simplifies the usage of Lit Protocol for encryption and decryption. * This class can be used with both client-side and Node.js Lit clients. * It implements the `IKmsProvider` interface for a standardized KMS provider structure. */ -export default class LitProvider implements CipherProviderTypes.ICipherProvider { +export default class LitProtocolCipherProvider implements CipherProviderTypes.ICipherProvider { /** * @property {string} chain - The blockchain to use for access control conditions. */ private chain: string; - /** - * @property {string} network - The network to use for access control conditions. - */ - private network: LIT_NETWORKS_KEYS; - /** * @property {DataAccessTypes.IDataAccess} dataAccess - The data access layer for Request Network. */ @@ -50,17 +43,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider /** * @property {LitNodeClient|LitNodeClientNodeJs|null} client - The Lit Protocol client instance. */ - private client: LitNodeClient | LitNodeClientNodeJs | null = null; - - /** - * @property {any} storageProvider - The storage provider for the Node.js Lit client. - */ - private nodeJsStorageProvider: StorageProvider | undefined; - - /** - * @property {boolean} debug - A boolean indicating if debug mode is enabled. - */ - private debug: boolean; + private litClient: LitNodeClient | LitNodeClientNodeJs; /** * @property {boolean} isDecryptionOn - A boolean indicating if decryption is enabled. @@ -73,17 +56,13 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider * @throws {Error} Throws an error if the provided Lit client is invalid. */ constructor( - chain: string, - network: LIT_NETWORKS_KEYS, + litClient: LitNodeClient | LitNodeClientNodeJs, nodeConnectionConfig: NodeConnectionConfig, - debug?: boolean, - nodeJsStorageProvider?: StorageProvider, + chain = 'ethereum', ) { + this.litClient = litClient; this.chain = chain; - this.network = network; this.dataAccess = new HttpDataAccess({ nodeConnectionConfig }); - this.debug = debug || false; - this.nodeJsStorageProvider = nodeJsStorageProvider; } /** @@ -94,23 +73,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider */ public async initializeClient(): Promise { try { - // Using process.browser instead of typeof window - if (typeof window !== 'undefined') { - this.client = new LitNodeClient({ - litNetwork: this.network, - debug: this.debug, - }); - await this.client.connect(); - } else { - const { LitNodeClientNodeJs } = await import('@lit-protocol/lit-node-client'); - this.client = new LitNodeClientNodeJs({ - litNetwork: this.network, - storageProvider: this.nodeJsStorageProvider, - debug: this.debug, - }); - - await this.client.connect(); - } + await this.litClient?.connect(); } catch (error) { throw new Error(`Failed to initialize Lit client: ${error.message}`); } @@ -126,9 +89,6 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider disconnectWeb3(); } this.sessionSigs = null; - if (this.nodeJsStorageProvider) { - this.nodeJsStorageProvider.provider.clear(); - } } /** @@ -138,8 +98,8 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider * @returns {Promise} */ public async disconnectClient(): Promise { - if (this.client) { - await this.client.disconnect(); + if (this.litClient) { + await this.litClient.disconnect(); } } @@ -152,7 +112,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider * @returns {Promise} */ public async getSessionSignatures(signer: Signer, walletAddress: string): Promise { - if (!this.client) { + if (!this.litClient) { throw new Error('Lit client not initialized'); } if (this.sessionSigs) { @@ -164,7 +124,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider : ({} as AuthSig); // Get the latest blockhash - const latestBlockhash = await this.client?.getLatestBlockhash(); + const latestBlockhash = await this.litClient?.getLatestBlockhash(); // Define the authNeededCallback function const authNeededCallback = async (params: AuthCallbackParams) => { @@ -186,7 +146,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider resources: params.resourceAbilityRequests, walletAddress: walletAddress, nonce: latestBlockhash || '', - litNodeClient: this.client, + litNodeClient: this.litClient, }); // Generate the authSig @@ -203,7 +163,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider // Get the session signatures this.sessionSigs = - (await this.client?.getSessionSigs({ + (await this.litClient?.getSessionSigs({ chain: this.chain, capabilityAuthSigs: [capacityDelegationAuthSig], resourceAbilityRequests: [ @@ -231,9 +191,17 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider throw new Error('encryptionParams cannot be empty'); } - const accessControlConditions = []; + // Validate params and sort by key + encryptionParams.forEach((param, index) => { + if (!param.key) + throw new Error(`Invalid encryption parameter at index ${index}: missing key`); + }); + + // Sort by key as lit protocol requires the keys to be in the same order for decryption and encryption + encryptionParams.sort((a, b) => a.key.localeCompare(b.key)); - accessControlConditions.push({ + // Create base condition object + const createCondition = (key: string) => ({ contractAddress: '', standardContractType: '' as AccsDefaultParams['standardContractType'], chain: this.chain as AccsDefaultParams['chain'], @@ -241,28 +209,16 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider parameters: [':userAddress'], returnValueTest: { comparator: '=' as AccsDefaultParams['returnValueTest']['comparator'], - value: encryptionParams[0].key, + value: key, }, }); - for (let i = 1; i < encryptionParams.length; i++) { - accessControlConditions.push( - { operator: 'or' }, - { - contractAddress: '', - standardContractType: '' as AccsDefaultParams['standardContractType'], - chain: this.chain as AccsDefaultParams['chain'], - method: '', - parameters: [':userAddress'], - returnValueTest: { - comparator: '=' as AccsDefaultParams['returnValueTest']['comparator'], - value: encryptionParams[i].key, - }, - }, - ); - } - - return accessControlConditions; + // Build conditions array with 'or' operators between each condition + return encryptionParams.reduce((accessControlConditions, encryptionParam, index) => { + if (index > 0) accessControlConditions.push({ operator: 'or' }); + accessControlConditions.push(createCondition(encryptionParam.key)); + return accessControlConditions; + }, [] as AccessControlConditions); } /** @@ -288,7 +244,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider * @returns {boolean} A boolean indicating if encryption is available. */ public isEncryptionAvailable(): boolean { - return this.client !== null; + return this.litClient !== undefined; } /** @@ -307,7 +263,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider encryptionParams: EncryptionTypes.IEncryptionParameters[]; }, ): Promise { - if (!this.client) { + if (!this.litClient) { throw new Error('Lit client not initialized'); } @@ -317,7 +273,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider options.encryptionParams, ); - return await this.client.encrypt({ + return await this.litClient.encrypt({ accessControlConditions: accessControlConditions, dataToEncrypt: new TextEncoder().encode(stringifiedData), }); @@ -329,7 +285,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider * @returns {boolean} A boolean indicating if decryption is available. */ public isDecryptionAvailable(): boolean { - return this.client !== null && this.sessionSigs !== null && this.decryptionEnabled; + return this.litClient && this.sessionSigs !== null && this.decryptionEnabled; } /** @@ -349,7 +305,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider encryptionParams: EncryptionTypes.IEncryptionParameters[]; }, ): Promise { - if (!this.client) { + if (!this.litClient) { throw new Error('Lit client not initialized'); } @@ -361,7 +317,7 @@ export default class LitProvider implements CipherProviderTypes.ICipherProvider options.encryptionParams, ); - const { decryptedData } = await this.client.decrypt({ + const { decryptedData } = await this.litClient.decrypt({ accessControlConditions: accessControlConditions, chain: this.chain, ciphertext: encryptedData.ciphertext, diff --git a/packages/lit-protocol-cipher/test/index.test.ts b/packages/lit-protocol-cipher/test/index.test.ts index 618fdd312c..f3cfbb919a 100644 --- a/packages/lit-protocol-cipher/test/index.test.ts +++ b/packages/lit-protocol-cipher/test/index.test.ts @@ -15,21 +15,20 @@ jest.mock('@lit-protocol/encryption'); describe('LitProvider', () => { let litProvider: LitProvider; - let mockLitClient: jest.Mocked; // Use Node.js client + let mockLitClient: jest.Mocked; let mockSigner: jest.Mocked; - const mockChain = 'ethereum'; - const mockNetwork = 'datil-test'; const mockNodeConnectionConfig: NodeConnectionConfig = { baseURL: 'http://localhost:3000', headers: {}, }; const mockWalletAddress = '0x1234567890abcdef'; + const mockChain = 'ethereum'; const mockEncryptionParams: EncryptionTypes.IEncryptionParameters[] = [ { key: mockWalletAddress, - method: EncryptionTypes.METHOD.KMS, // Use the enum + method: EncryptionTypes.METHOD.KMS, }, ]; @@ -41,8 +40,17 @@ describe('LitProvider', () => { disconnect: jest.fn().mockReturnValue(Promise.resolve()), getLatestBlockhash: jest.fn().mockReturnValue(Promise.resolve('mock-blockhash')), getSessionSigs: jest.fn().mockReturnValue(Promise.resolve({ 'mock-session': 'mock-sig' })), - encrypt: jest.fn().mockReturnValue(Promise.resolve('mock-encrypted-data')), - decrypt: jest.fn().mockReturnValue(Promise.resolve('mock-decrypted-data')), + encrypt: jest.fn().mockReturnValue( + Promise.resolve({ + ciphertext: 'mock-encrypted-data', + dataToEncryptHash: 'mock-hash', + }), + ), + decrypt: jest.fn().mockReturnValue( + Promise.resolve({ + decryptedData: new TextEncoder().encode('mock-decrypted-data'), + }), + ), } as unknown as jest.Mocked; (LitNodeClientNodeJs as unknown as jest.Mock).mockImplementation(() => mockLitClient); @@ -52,9 +60,7 @@ describe('LitProvider', () => { signMessage: jest.fn().mockReturnValue(Promise.resolve('mock-signature')), } as unknown as jest.Mocked; - const debug = false; - - litProvider = new LitProvider(mockChain, mockNetwork, mockNodeConnectionConfig, debug); + litProvider = new LitProvider(mockLitClient, mockNodeConnectionConfig, mockChain); await litProvider.initializeClient(); }); @@ -65,6 +71,11 @@ describe('LitProvider', () => { nodeConnectionConfig: mockNodeConnectionConfig, }); }); + + it('should use default chain if not provided', () => { + const providerWithDefaultChain = new LitProvider(mockLitClient, mockNodeConnectionConfig); + expect(providerWithDefaultChain['chain']).toBe('ethereum'); + }); }); describe('disconnectWallet', () => { @@ -88,6 +99,53 @@ describe('LitProvider', () => { }); }); + describe('encryption and decryption state', () => { + it('should manage decryption state correctly', () => { + expect(litProvider.isDecryptionEnabled()).toBe(false); + + litProvider.enableDecryption(true); + expect(litProvider.isDecryptionEnabled()).toBe(true); + + litProvider.enableDecryption(false); + expect(litProvider.isDecryptionEnabled()).toBe(false); + }); + + it('should check encryption availability', () => { + // Test with valid client + expect(litProvider.isEncryptionAvailable()).toBe(true); + + // Test with no client + litProvider['litClient'] = undefined as unknown as LitNodeClientNodeJs; + expect(litProvider.isEncryptionAvailable()).toBe(false); + + // Restore client for other tests + litProvider['litClient'] = mockLitClient; + }); + + it('should check decryption availability', () => { + litProvider.enableDecryption(true); + litProvider['sessionSigs'] = { + 'mock-session': { + sig: 'mock-sig', + derivedVia: 'mock', + signedMessage: 'mock', + address: 'mock-address', + }, + }; + expect(litProvider.isDecryptionAvailable()).toBe(true); + + litProvider.enableDecryption(false); + expect(litProvider.isDecryptionAvailable()).toBe(false); + + litProvider.enableDecryption(true); + litProvider['sessionSigs'] = null; + expect(litProvider.isDecryptionAvailable()).toBe(false); + + litProvider['litClient']; + expect(litProvider.isDecryptionAvailable()).toBe(false); + }); + }); + describe('getSessionSignatures', () => { it('should get session signatures successfully', async () => { const mockAuthSig = { @@ -149,7 +207,27 @@ describe('LitProvider', () => { ); }); - // ... (rest of your encrypt tests with necessary adjustments) + it('should encrypt object data successfully', async () => { + const objectData = { test: 'data' }; + const result = await litProvider.encrypt(objectData, { + encryptionParams: mockEncryptionParams, + }); + + expect(result).toEqual(mockEncryptResponse); + expect(mockLitClient.encrypt).toHaveBeenCalledWith( + expect.objectContaining({ + dataToEncrypt: new TextEncoder().encode(JSON.stringify(objectData)), + accessControlConditions: expect.any(Array), + }), + ); + }); + + it('should throw error if client is not initialized', async () => { + litProvider['litClient'] = undefined as unknown as LitNodeClientNodeJs; + await expect( + litProvider.encrypt(mockData, { encryptionParams: mockEncryptionParams }), + ).rejects.toThrow('Lit client not initialized'); + }); }); describe('decrypt', () => { diff --git a/packages/request-node/package.json b/packages/request-node/package.json index c9a8a10280..0ba2097195 100644 --- a/packages/request-node/package.json +++ b/packages/request-node/package.json @@ -42,10 +42,11 @@ }, "dependencies": { "@ethersproject/experimental": "5.7.0", - "@lit-protocol/constants": "7.0.0", + "@lit-protocol/constants": "7.0.2", "@lit-protocol/contracts": "0.0.74", - "@lit-protocol/contracts-sdk": "7.0.0", - "@lit-protocol/lit-node-client": "7.0.0", + "@lit-protocol/contracts-sdk": "7.0.2", + "@lit-protocol/lit-node-client": "7.0.2", + "@lit-protocol/types": "7.0.2", "@requestnetwork/currency": "0.21.0", "@requestnetwork/data-access": "0.38.0", "@requestnetwork/ethereum-storage": "0.38.0", diff --git a/packages/request-node/src/request/getLitCapacityDelegationAuthSig.ts b/packages/request-node/src/request/getLitCapacityDelegationAuthSig.ts index fb95d036d8..6f77a9a82a 100644 --- a/packages/request-node/src/request/getLitCapacityDelegationAuthSig.ts +++ b/packages/request-node/src/request/getLitCapacityDelegationAuthSig.ts @@ -6,7 +6,8 @@ import { StatusCodes } from 'http-status-codes'; import * as config from '../config'; import { LitContracts } from '@lit-protocol/contracts-sdk'; import { utils } from 'ethers'; - +import { LIT_NETWORKS_KEYS } from '@lit-protocol/types'; +import { LIT_NETWORK } from '@lit-protocol/constants'; /** * Handles getLitCapacityDelegationAuthSigHandler. * @@ -30,31 +31,36 @@ export default class GetLitCapacityDelegationAuthSigHandler { const ethersSigner = Wallet.fromMnemonic(config.getMnemonic()).connect( new providers.JsonRpcProvider(config.getLitProtocolRPC()), ); + let tokenId = '0'; + if ((config.getLitProtocolNetwork() as LIT_NETWORKS_KEYS) === LIT_NETWORK.DatilDev) { + tokenId = '0'; + } else { + const litContractClient = new LitContracts({ + signer: ethersSigner, + network: config.getLitProtocolNetwork() as LIT_NETWORKS_KEYS, + }); + await litContractClient.connect(); - const litContractClient = new LitContracts({ - signer: ethersSigner, - network: config.getLitProtocolNetwork(), - }); - await litContractClient.connect(); - - const existingTokens: { tokenId: string }[] = - await litContractClient.rateLimitNftContractUtils.read.getTokensByOwnerAddress( - await ethersSigner.getAddress(), - ); + const existingTokens: { tokenId: string }[] = + await litContractClient.rateLimitNftContractUtils.read.getTokensByOwnerAddress( + await ethersSigner.getAddress(), + ); - if (existingTokens.length === 0) { - serverResponse.status(StatusCodes.UNPROCESSABLE_ENTITY).send('No existing tokens'); - return; + if (existingTokens.length === 0) { + serverResponse.status(StatusCodes.UNPROCESSABLE_ENTITY).send('No existing tokens'); + return; + } + tokenId = `${existingTokens[existingTokens.length - 1].tokenId}`; } const litNodeClient = new LitNodeClientNodeJs({ - litNetwork: config.getLitProtocolNetwork(), + litNetwork: config.getLitProtocolNetwork() as LIT_NETWORKS_KEYS, debug: false, }); await litNodeClient.connect(); const { capacityDelegationAuthSig } = await litNodeClient.createCapacityDelegationAuthSig({ - capacityTokenId: `${existingTokens[existingTokens.length - 1].tokenId}`, + capacityTokenId: tokenId, dAppOwnerWallet: ethersSigner, delegateeAddresses: [`${delegateeAddress}`], uses: `${config.getLitProtocolCapacityCreditsUsage()}`, diff --git a/packages/transaction-manager/test/unit/transactions-factory.test.ts b/packages/transaction-manager/test/unit/transactions-factory.test.ts index f91a0a8bcb..1ced9a5727 100644 --- a/packages/transaction-manager/test/unit/transactions-factory.test.ts +++ b/packages/transaction-manager/test/unit/transactions-factory.test.ts @@ -78,7 +78,7 @@ describe('transaction-factory', () => { TestData.kmsRaw2.encryptionParams, TestData.kmsRaw3.encryptionParams, ], - TestData.fakeLitProtocolProvider, + TestData.fakeLitProtocolCipherProvider, ); // eslint-disable-next-line no-magic-numbers @@ -180,7 +180,7 @@ describe('transaction-factory', () => { data, channelKey, undefined, - TestData.fakeLitProtocolProvider, + TestData.fakeLitProtocolCipherProvider, ); // eslint-disable-next-line no-magic-numbers @@ -216,7 +216,7 @@ describe('transaction-factory', () => { TestData.kmsRaw2.encryptionParams, TestData.kmsRaw3.encryptionParams, ], - TestData.fakeLitProtocolProvider, + TestData.fakeLitProtocolCipherProvider, ); // eslint-disable-next-line no-magic-numbers diff --git a/packages/transaction-manager/test/unit/transactions-parser.test.ts b/packages/transaction-manager/test/unit/transactions-parser.test.ts index 6094b680ab..7564603f43 100644 --- a/packages/transaction-manager/test/unit/transactions-parser.test.ts +++ b/packages/transaction-manager/test/unit/transactions-parser.test.ts @@ -226,7 +226,10 @@ describe('transaction-parser', () => { describe('parse encrypted persisted transaction with LitProtocol', () => { beforeEach(() => { - transactionParser = new TransactionsParser(undefined, TestData.fakeLitProtocolProvider); + transactionParser = new TransactionsParser( + undefined, + TestData.fakeLitProtocolCipherProvider, + ); }); it('can parse encrypted transaction on an unknown channel', async () => { const encryptedParsedTx = await TransactionsFactory.createEncryptedTransactionInNewChannel( @@ -236,7 +239,7 @@ describe('transaction-parser', () => { TestData.kmsRaw2.encryptionParams, TestData.kmsRaw3.encryptionParams, ], - TestData.fakeLitProtocolProvider, + TestData.fakeLitProtocolCipherProvider, ); const ret = await transactionParser.parsePersistedTransaction( @@ -269,7 +272,7 @@ describe('transaction-parser', () => { const encryptedParsedTx = await TransactionsFactory.createEncryptedTransactionInNewChannel( data, [TestData.kmsRaw1.encryptionParams], - TestData.fakeLitProtocolProvider, + TestData.fakeLitProtocolCipherProvider, ); const addRaw1Formatted = `20${TestData.kmsRaw1.encryptionParams.key.slice(2)}`; @@ -298,7 +301,7 @@ describe('transaction-parser', () => { const encryptedParsedTx = await TransactionsFactory.createEncryptedTransactionInNewChannel( data, [TestData.kmsRaw1.encryptionParams, TestData.kmsRaw2.encryptionParams], - TestData.fakeLitProtocolProvider, + TestData.fakeLitProtocolCipherProvider, ); await expect( transactionParser.parsePersistedTransaction( diff --git a/packages/transaction-manager/test/unit/utils/test-data.ts b/packages/transaction-manager/test/unit/utils/test-data.ts index e72e99d0b7..453d126aa6 100644 --- a/packages/transaction-manager/test/unit/utils/test-data.ts +++ b/packages/transaction-manager/test/unit/utils/test-data.ts @@ -176,7 +176,7 @@ export const id3DecryptionProvider: DecryptionProviderTypes.IDecryptionProvider supportedMethods: [EncryptionTypes.METHOD.ECIES], }; -export class FakeLitProtocolProvider implements CipherProviderTypes.ICipherProvider { +export class FakeLitProtocolCipherProvider implements CipherProviderTypes.ICipherProvider { private storedRawData: string; constructor() { @@ -228,5 +228,5 @@ export class FakeLitProtocolProvider implements CipherProviderTypes.ICipherProvi } } -export const fakeLitProtocolProvider: CipherProviderTypes.ICipherProvider = - new FakeLitProtocolProvider(); +export const fakeLitProtocolCipherProvider: CipherProviderTypes.ICipherProvider = + new FakeLitProtocolCipherProvider(); diff --git a/packages/types/package.json b/packages/types/package.json index 7f39f6e5c2..fa405f533b 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -38,7 +38,7 @@ "prepare": "yarn run build" }, "dependencies": { - "@lit-protocol/types": "7.0.0", + "@lit-protocol/types": "7.0.2", "ethers": "5.7.2" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 8744c4dcbc..7ce47847eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3361,20 +3361,21 @@ resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz#2f3a8f1d688935c704dbc89132394a41029acbb8" integrity sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ== -"@lit-protocol/access-control-conditions@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/access-control-conditions/-/access-control-conditions-7.0.0.tgz#9e2c783f87aef3525ed012bab71c6eb1a9a29ee4" - integrity sha512-HzsiJlPQiJEa00syX9r+9ful0NPurgp2i/V0bwe17IyFdg71ENNLRSzCA+O8Yrnox+J6aqMFLwTgTvPXICyZeQ== +"@lit-protocol/access-control-conditions@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/access-control-conditions/-/access-control-conditions-7.0.2.tgz#086e61827c356dd4ba02a7d8933d21dba2eecbd0" + integrity sha512-didWaPND1kCGzGNPI8S9lvQriMf2wIKZHCJIecofAT3JLolrcNk6LqXfIBgPSeZbyOAbH91kpHKN7PI0zyQtEQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3384,17 +3385,17 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/accs-schemas@^0.0.15": - version "0.0.15" - resolved "https://registry.yarnpkg.com/@lit-protocol/accs-schemas/-/accs-schemas-0.0.15.tgz#00e31c6959834da6387049cf52bce29c84f0f9da" - integrity sha512-GYF8BolqrU2H/uXr3D39TUbgFN/3u2d68oHHNfwg926iEsCEHwGmUOPvi4EMprV5lJR3EVn9IQODY/4eokJ6Rg== +"@lit-protocol/accs-schemas@^0.0.20": + version "0.0.20" + resolved "https://registry.yarnpkg.com/@lit-protocol/accs-schemas/-/accs-schemas-0.0.20.tgz#64d1151002f63aa0a54ba2be92bf44edefb0eb1e" + integrity sha512-JHHX0q45nq1uQ4olkg4VIGLW9lzMnRRldeTDuOrOaoPVztz+2iSOjwzb+QmuSuKFQpP5SOej2zoQB+K8b22KDw== dependencies: ajv "^8.12.0" -"@lit-protocol/auth-browser@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/auth-browser/-/auth-browser-7.0.0.tgz#67fe2c9748f9199ef50dcae3cadf916af4d134bd" - integrity sha512-DYoucBiTXCv1sdtUCTbYC4DApuezrtLXTK3bdW0KLLIY9aBBq0C9i4FwIPQjkz9e7S0rXUwI7d0QL3HV5NnK7Q== +"@lit-protocol/auth-browser@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/auth-browser/-/auth-browser-7.0.2.tgz#0e23869c8147fa0739e194ada6bace1d1cd7aeac" + integrity sha512-zXNxJTmQle2rzede2x8L9m0ai72yRwtfye1ugJMBptSaiWMhkZHN3kiwBvXWusy35COOeq08NDVdvr2nsf9pGw== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/bytes" "5.7.0" @@ -3402,13 +3403,13 @@ "@ethersproject/providers" "5.7.2" "@ethersproject/strings" "5.7.0" "@ethersproject/wallet" "5.7.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/misc-browser" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/misc-browser" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3416,21 +3417,22 @@ ethers "^5.7.1" tslib "1.14.1" -"@lit-protocol/auth-helpers@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/auth-helpers/-/auth-helpers-7.0.0.tgz#96081f573082f8d1113fa28e0c5eee549dd6b251" - integrity sha512-7psSirXq6aNJhauzgHgMRFPcBOTZ8BYkaYc70sL70yxVcbjXaoye4pNCyNYNqmvZ8SSxcAaFcwPc5V1SHKNSBw== +"@lit-protocol/auth-helpers@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/auth-helpers/-/auth-helpers-7.0.2.tgz#a9a08c89e11d5c757e245b3e1d5fe5020f5574b5" + integrity sha512-8917XgmuAEzXWPsyYSQcAlzmDWJ4xKabMroGObduY1RtsD0yq1o3azt+8kW0J7YDLmGRBGTGvVh2c1IQpCzXfQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/access-control-conditions" "7.0.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" + "@lit-protocol/access-control-conditions" "7.0.2" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3441,34 +3443,36 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/constants@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/constants/-/constants-7.0.0.tgz#de18cf1392af9de116b3057a20fde900844740ff" - integrity sha512-pIxhY+fTswqWWM/DNRYOOLEYOWE+aQiacvJMl/MXvLk2MjG87AIWdpv5ZNpho5qy6MSfF7ig4WTgv4rjvNwfgA== +"@lit-protocol/constants@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/constants/-/constants-7.0.2.tgz#2c642aa7feff0b667cef06a8cbb59c7044ef3801" + integrity sha512-A2tpsB7pCGHiC+VrPAHBaEGyb/9crCkcSIj8BtGPrLRszFZO8EHKWziM7WiMM2c2mYb+B4dKtGGUkxxCAarqaQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/types" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/types" "7.0.2" "@openagenda/verror" "^3.1.4" depd "^2.0.0" ethers "^5.7.1" siwe "^2.3.2" tslib "1.14.1" -"@lit-protocol/contracts-sdk@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/contracts-sdk/-/contracts-sdk-7.0.0.tgz#7b8ecedb8b532cdf1e0f78e38180e712275cee8b" - integrity sha512-lgNQsyZ0K8W3msW9fDPGF7nx7isQtdAq3dE4S0xUz9FzaOWzO88/z/UpQ4eIABhhCZddZLA2c9397keErl8SnQ== +"@lit-protocol/contracts-sdk@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/contracts-sdk/-/contracts-sdk-7.0.2.tgz#5192071b32f54cceb11aff6b8661e5cbbf3864f2" + integrity sha512-EQs0l3v+tRdItuRamo675obkAPHGmQnef0WZ1cY0nNn97zRBGbkYPfkHMBxrUoGwbcsFQPMHDynrGTzAiUM7Zw== dependencies: "@ethersproject/abi" "5.7.0" "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/types" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/types" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3480,31 +3484,32 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/contracts@0.0.74": +"@lit-protocol/contracts@0.0.74", "@lit-protocol/contracts@^0.0.74": version "0.0.74" resolved "https://registry.yarnpkg.com/@lit-protocol/contracts/-/contracts-0.0.74.tgz#e726a9190c86b10cc6df3a392cd04d19057be27d" integrity sha512-8uV038gzBp7ew7a4884SVt9Zhu8CtiTb+A8dKNnByxVoT1kFt4O4DmsaniV8p9AGjNR13IWfpU1NFChmPHVIpQ== -"@lit-protocol/core@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/core/-/core-7.0.0.tgz#50735e41df9e432f358380ea241e9acd80853cbb" - integrity sha512-O8plnz6jRDus9sF23rjkZ1ANJLUV3tAD/PUWqlcCJsFzuh0Cl62hZx7bRvpMz41wX9P/DPQnSksVEJUq0gM79w== +"@lit-protocol/core@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/core/-/core-7.0.2.tgz#9629ce28a6e33165188a0928207af0b17ba52ac4" + integrity sha512-BANcnKQyqBD5ZGfDAPEJBhtzhc4bYuka8xyb2/ueCleaWOe0NgwW/z/CJ6Q/eSysO9smi0Z7bQy5a4xDBGNjHA== dependencies: "@ethersproject/abi" "5.7.0" "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/access-control-conditions" "7.0.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/contracts-sdk" "7.0.0" - "@lit-protocol/crypto" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/nacl" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" - "@lit-protocol/wasm" "7.0.0" + "@lit-protocol/access-control-conditions" "7.0.2" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/contracts-sdk" "7.0.2" + "@lit-protocol/crypto" "7.0.2" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/nacl" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" + "@lit-protocol/wasm" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3519,22 +3524,23 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/crypto@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/crypto/-/crypto-7.0.0.tgz#edba7706118b3ca348d6e87aaa640bc81ec55603" - integrity sha512-QJPqLkuli/QBxX0en1gSRU0Q9GZfUkFiXdYwclWKhYZFBTXeOWvd0bFIYTzDhU2FpMCtPi12Qw+p7FjHAURdXw== +"@lit-protocol/crypto@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/crypto/-/crypto-7.0.2.tgz#68306d131ecc51526fd4ba85b5cfd8a7594bd006" + integrity sha512-zgnOo3+LnRkIxGHro3QSsDmS3PPIH6nLrkBDp/+DigHL41H0zehdQbHMGxTQqzxtqpMFt9FARdAN0/CfHm/9Ow== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/nacl" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" - "@lit-protocol/wasm" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/nacl" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" + "@lit-protocol/wasm" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3545,20 +3551,21 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/encryption@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/encryption/-/encryption-7.0.0.tgz#b41734fb277b57d6305116be503d8ff5ff593395" - integrity sha512-Ip0+ukmCVYLF5rSMnFWPSIPus05ZP3eAes2iu8Gb4rn7GsTTGnK7qkQ8KFi15D5DYPYu+8x/qARSz1KZPB6tXw== +"@lit-protocol/encryption@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/encryption/-/encryption-7.0.2.tgz#ecf3ffac5a17345a3018e0ff7ffac5cca63dd3d0" + integrity sha512-OeHDPkvVMiY86vkQ1LTNog06QLXmKXMleaz+WmJy4Qc6GkOARuuJtJW/1uZjOcwcaCGzvPSWjBasb8O1K6t4FQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3568,30 +3575,31 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/lit-node-client-nodejs@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client-nodejs/-/lit-node-client-nodejs-7.0.0.tgz#e23f4851981fcc32563e1ca1a6009fd97c1d2113" - integrity sha512-15aCAwZSekZagoHk7ne1DsoB+hFP0y9TR4JhaWQlLExcXrUTcoHdkebmO52XghxxWFLbCRQOpBrv9lBEmx4NWA== +"@lit-protocol/lit-node-client-nodejs@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client-nodejs/-/lit-node-client-nodejs-7.0.2.tgz#a744d86919a6719dba20fdfc83356e08411b92b6" + integrity sha512-HUPCKRFxObK+XM9lPlWtbx+PqQoQl4OrRN7Lw/sIXew+wdozYgcMAMEbrB/xlCmJB+eFccu/06V4URSXQ22jXQ== dependencies: "@ethersproject/abi" "5.7.0" "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" "@ethersproject/transactions" "5.7.0" - "@lit-protocol/access-control-conditions" "7.0.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/auth-helpers" "7.0.0" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/contracts-sdk" "7.0.0" - "@lit-protocol/core" "7.0.0" - "@lit-protocol/crypto" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/misc-browser" "7.0.0" - "@lit-protocol/nacl" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" - "@lit-protocol/wasm" "7.0.0" + "@lit-protocol/access-control-conditions" "7.0.2" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/auth-helpers" "7.0.2" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/contracts-sdk" "7.0.2" + "@lit-protocol/core" "7.0.2" + "@lit-protocol/crypto" "7.0.2" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/misc-browser" "7.0.2" + "@lit-protocol/nacl" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" + "@lit-protocol/wasm" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3608,10 +3616,10 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/lit-node-client@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client/-/lit-node-client-7.0.0.tgz#d5c705a93b2215991e87019fddb20a81687935db" - integrity sha512-qn9DN3bkdWZegmAguGT5WN1IGlWpHuKqgUMjf3rCbQUoJ94sjFW3QCTPEOMCc4AX9yI6e+514/B38+MWAcF+eg== +"@lit-protocol/lit-node-client@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client/-/lit-node-client-7.0.2.tgz#5d53fbf1ee62c167ec5be03ae05195057994c3f9" + integrity sha512-8zESXAA9HdRBLsjyljLuIpS2yzDv7jspW0MUe54XmHYHo87WE4G/q4WCjkKwRnKaeG0Jh5+/kb6j81AnLpWKFQ== dependencies: "@ethersproject/abi" "5.7.0" "@ethersproject/abstract-provider" "5.7.0" @@ -3621,22 +3629,23 @@ "@ethersproject/strings" "5.7.0" "@ethersproject/transactions" "5.7.0" "@ethersproject/wallet" "5.7.0" - "@lit-protocol/access-control-conditions" "7.0.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/auth-browser" "7.0.0" - "@lit-protocol/auth-helpers" "7.0.0" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/contracts-sdk" "7.0.0" - "@lit-protocol/core" "7.0.0" - "@lit-protocol/crypto" "7.0.0" - "@lit-protocol/lit-node-client-nodejs" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/misc" "7.0.0" - "@lit-protocol/misc-browser" "7.0.0" - "@lit-protocol/nacl" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" - "@lit-protocol/wasm" "7.0.0" + "@lit-protocol/access-control-conditions" "7.0.2" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/auth-browser" "7.0.2" + "@lit-protocol/auth-helpers" "7.0.2" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/contracts-sdk" "7.0.2" + "@lit-protocol/core" "7.0.2" + "@lit-protocol/crypto" "7.0.2" + "@lit-protocol/lit-node-client-nodejs" "7.0.2" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/misc" "7.0.2" + "@lit-protocol/misc-browser" "7.0.2" + "@lit-protocol/nacl" "7.0.2" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" + "@lit-protocol/wasm" "7.0.2" "@openagenda/verror" "^3.1.4" "@walletconnect/ethereum-provider" "2.9.2" ajv "^8.12.0" @@ -3655,49 +3664,52 @@ tweetnacl-util "^0.15.1" util "0.12.5" -"@lit-protocol/logger@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/logger/-/logger-7.0.0.tgz#856f91dd62b338be78948c126ad87e1a2d50f422" - integrity sha512-gI/bK+Ea97a8CKMzd4MUoRFSy7eoEMzh6RsJ1lrkgod1tDrW91ktVc0qmzgvwNdwuOM45g+2T77DBDqaaB75iw== +"@lit-protocol/logger@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/logger/-/logger-7.0.2.tgz#2d28eb73ed3a0771655e03efe75bc27ccf3b7c1a" + integrity sha512-44VsSlLWVxIVG9m5GIkvdXSfd4gyCNToNN0uor41cQTYLbyvasgTfyi12XPNwfFZU7FNMrYpt+Jgig2SqrzXVg== dependencies: "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/types" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/types" "7.0.2" "@openagenda/verror" "^3.1.4" depd "^2.0.0" ethers "^5.7.1" siwe "^2.3.2" tslib "1.14.1" -"@lit-protocol/misc-browser@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/misc-browser/-/misc-browser-7.0.0.tgz#c5b1616a01b0761131cd145d961fbae7d02cd8ab" - integrity sha512-x54F4FRhIlugDB5LdErHBZCSlAF8I+Q9qCGObwddut77spYafOuVPsrtrLE/oDLYRcaAFOX7wWKYSxsZpOc53g== +"@lit-protocol/misc-browser@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/misc-browser/-/misc-browser-7.0.2.tgz#2bff97961a17b3fc990974cf296088f6dd7e9e68" + integrity sha512-T9L4j3U6P+/0uI30NB2lCZM2PVPDI6G9JkrBn7PBIgzwynK9jtUHxwmxMk16qrUV9MvVCYSEt+tqEvOI5S/gMg== dependencies: "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/types" "7.0.0" - "@lit-protocol/uint8arrays" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/types" "7.0.2" + "@lit-protocol/uint8arrays" "7.0.2" "@openagenda/verror" "^3.1.4" depd "^2.0.0" ethers "^5.7.1" siwe "^2.3.2" tslib "1.14.1" -"@lit-protocol/misc@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/misc/-/misc-7.0.0.tgz#996f6443bb8884bac8e33f3a9086bd06d2261a55" - integrity sha512-5BDKukR/QzzFjoaYBUdpVM7R/GWIoOuQRzwM3myUjF+d4OR9imcRIeq9k8oQBAEPc+AoTimgn1aWxpEQMFrrGQ== +"@lit-protocol/misc@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/misc/-/misc-7.0.2.tgz#b8da1cb4107d84c8d37391d8c2992960a438f1c9" + integrity sha512-ZUU4j3E+VnCY11oPLGop95UkAUzTiBmPfiCXwFYGmh6PDvHXZlRC1Qc+3aC5lFpocoBTTJ/uE2MQZpHyN0kRlQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/logger" "7.0.0" - "@lit-protocol/types" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/logger" "7.0.2" + "@lit-protocol/types" "7.0.2" "@openagenda/verror" "^3.1.4" ajv "^8.12.0" bech32 "^2.0.0" @@ -3707,44 +3719,45 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/nacl@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/nacl/-/nacl-7.0.0.tgz#a85352050efa9a49d8bad6e08c45b1517ed1fcb6" - integrity sha512-tkcT4pf6kKJKT2h+8tH/qqf/Yi1Wug7lUodbiAxWMM859vjzKc2IKozfw5bcQ7UZsz9+xrHvDnD+d7dD1kHqMQ== +"@lit-protocol/nacl@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/nacl/-/nacl-7.0.2.tgz#31d004c9672078354d258d35e39ccb2d01c944ad" + integrity sha512-jdtquJ1iZCgIdKlVP0zAJlVfttLWLG2T6EsKFDp3o1lxEKtiUkKqbM1VGXihQVJQ6kFtmb3PJdMDRYDkOq1bhw== dependencies: tslib "1.14.1" -"@lit-protocol/types@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/types/-/types-7.0.0.tgz#a37ee86814bbe55e4f0853e956858a22acf9010e" - integrity sha512-QEHeumd5rsfh9XJp7SpCT1b0xy4vzjt0UKssTzsymvBAGkjTXGtNkshO8GHgNm+nf32NmXhncTqTnIGACJw1Ew== +"@lit-protocol/types@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/types/-/types-7.0.2.tgz#2c4c0032a4210ab31f47d25e4266b8731234c8de" + integrity sha512-rEBZoeSByaMxXiP7w3g6/d180d8AbL4xpLqIlZchfJfAcSFkTseByV1d4h/J3LHl+3Q10wQsJT0N+qIi9kZbqA== dependencies: "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "^0.0.15" + "@lit-protocol/accs-schemas" "^0.0.20" depd "^2.0.0" ethers "^5.7.1" siwe "^2.3.2" tslib "1.14.1" -"@lit-protocol/uint8arrays@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-7.0.0.tgz#26fe8b56409db7b63a7ac9bc6e1f62959b6be22a" - integrity sha512-oFZ0nokC67Qd+ilbG2+2V/EnE+1+4NugqWdaMcY7cuBB943D1oC6n6xLiNQcI1wpmB4cAvfvemGJ8toz+JQpZQ== +"@lit-protocol/uint8arrays@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-7.0.2.tgz#2d6f65edca8d82d2c8bc1b654b7b0659c880b331" + integrity sha512-lwytcoJOQGtwrAU5qdRc3nkNWy4uND17HZux447eljgwJUGYeLFxNDfx8qtveues1MKAbvSOHtUmxmhpN1aHyQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "^0.0.15" - "@lit-protocol/constants" "7.0.0" - "@lit-protocol/types" "7.0.0" + "@lit-protocol/accs-schemas" "^0.0.20" + "@lit-protocol/constants" "7.0.2" + "@lit-protocol/contracts" "^0.0.74" + "@lit-protocol/types" "7.0.2" "@openagenda/verror" "^3.1.4" depd "^2.0.0" ethers "^5.7.1" siwe "^2.3.2" tslib "1.14.1" -"@lit-protocol/wasm@7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/wasm/-/wasm-7.0.0.tgz#e26bd21818ad09281b41418cc4d7d5e92cdb4dfe" - integrity sha512-YaADtQ4h/nQ56PRqzDm7sbnJkbdtQkQ27FJfEVtOiUvVRuoaCypLgulcxLbh+7VuNuEZ9ASMVQ0JLqES/+XFDg== +"@lit-protocol/wasm@7.0.2": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@lit-protocol/wasm/-/wasm-7.0.2.tgz#9b27aa18e810911832e02cc2898fadbb9e5a21ed" + integrity sha512-e5sRe6Oi0ZSCjZZjL96jkbPE6UbxM1OYIrL3CFUo6IeoNZ/ZyYudHrM92v3ZEhiTfJDRnJDv0t3b2hpUz88cIQ== dependencies: ethers "^5.7.1" pako "^2.1.0"