diff --git a/api/package.json b/api/package.json index e9f3d726..f1663260 100644 --- a/api/package.json +++ b/api/package.json @@ -21,9 +21,11 @@ "@didtools/cacao": "^3.0.1", "@elastic/elasticsearch": "^8.6.0", "@ethersproject/keccak256": "^5.7.0", - "@lit-protocol/contracts-sdk": "5.0.0", - "@lit-protocol/lit-node-client-nodejs": "5.0.0", + "@lit-protocol/auth-helpers": "6.0.0-beta.4", + "@lit-protocol/contracts-sdk": "6.0.0-beta.4", + "@lit-protocol/lit-node-client-nodejs": "6.0.0-beta.4", "@lit-protocol/pkp-ethers": "^5.0.0", + "@lit-protocol/types": "6.0.0-beta.4", "@lit-protocol/uint8arrays": "4.1.1", "@mailchimp/mailchimp_marketing": "^3.0.80", "@pinata/sdk": "^2.1.0", diff --git a/api/src/libs/lit/index.js b/api/src/libs/lit/index.js index 220914a1..7723ddb6 100644 --- a/api/src/libs/lit/index.js +++ b/api/src/libs/lit/index.js @@ -382,61 +382,66 @@ export const getPKPSessionForIndexer = async (index) => { }; export const mintPKP = async (ownerAddress, actionCID) => { - const signer = new ethers.Wallet( - process.env.INDEXER_WALLET_PRIVATE_KEY, - provider, - ); - - const litContracts = new LitContracts({ - network: config.litNetwork, - signer: signer, - debug: false, - }); - if (!litContracts.connected) { - await litContracts.connect(); - } - - const signerFunctionV0 = CID.parse(actionCID).toV0().toString(); - const acid = litContracts.utils.getBytesFromMultihash(signerFunctionV0); - - const mintCost = await litContracts.pkpNftContract.read.mintCost(); - const mint = - await litContracts.pkpHelperContract.write.mintNextAndAddAuthMethods( - 2, - [AuthMethodType.EthWallet, AuthMethodType.LitAction], - [ownerAddress.toLowerCase(), acid], - ["0x", "0x"], - [[BigInt(1)], [BigInt(1)]], - true, - true, - { - value: mintCost, - }, + try { + const signer = new ethers.Wallet( + process.env.INDEXER_WALLET_PRIVATE_KEY, + provider, ); - const wait = await mint.wait(1); - /* eslint-disable */ - const tokenIdFromEvent = wait?.logs - ? wait.logs[0].topics[1] - : wait?.logs[0].topics[1]; - const tokenIdNumber = BigInt(tokenIdFromEvent).toString(); - const pkpPublicKey = - await litContracts.pkpNftContract.read.getPubkey(tokenIdFromEvent); + const litContracts = new LitContracts({ + network: config.litNetwork, + signer: signer, + debug: false, + }); + if (!litContracts.connected) { + await litContracts.connect(); + } + + const signerFunctionV0 = CID.parse(actionCID).toV0().toString(); + const acid = litContracts.utils.getBytesFromMultihash(signerFunctionV0); + + const mintCost = await litContracts.pkpNftContract.read.mintCost(); + console.log(mintCost, `mintcost`); + const mint = + await litContracts.pkpHelperContract.write.mintNextAndAddAuthMethods( + 2, + [AuthMethodType.EthWallet, AuthMethodType.LitAction], + [ownerAddress.toLowerCase(), acid], + ["0x", "0x"], + [[BigInt(1)], [BigInt(1)]], + true, + true, + { + value: mintCost, + }, + ); + const wait = await mint.wait(1); + console.log(wait); + /* eslint-disable */ + const tokenIdFromEvent = wait?.logs + ? wait.logs[0].topics[1] + : wait?.logs[0].topics[1]; + const tokenIdNumber = BigInt(tokenIdFromEvent).toString(); + const pkpPublicKey = + await litContracts.pkpNftContract.read.getPubkey(tokenIdFromEvent); - const pubKeyToAddr = await import("ethereum-public-key-to-address"); - sendLit(pubKeyToAddr.default(pkpPublicKey), "0.0001"); //Run in the background + const pubKeyToAddr = await import("ethereum-public-key-to-address"); + sendLit(pubKeyToAddr.default(pkpPublicKey), "0.0001"); //Run in the background - console.log("Minted and loaded!"); + console.log("Minted and loaded!"); - console.log( - `superlog, PKP public key is ${pkpPublicKey} and Token ID is ${tokenIdFromEvent} and Token ID number is ${tokenIdNumber}`, - ); + console.log( + `superlog, PKP public key is ${pkpPublicKey} and Token ID is ${tokenIdFromEvent} and Token ID number is ${tokenIdNumber}`, + ); - return { - tokenIdFromEvent, - tokenIdNumber, - pkpPublicKey, - }; + return { + tokenIdFromEvent, + tokenIdNumber, + pkpPublicKey, + }; + } catch (e) { + console.log(e); + } }; const delay = async (ms) => { diff --git a/api/src/packages/indexer_auth_manager.js b/api/src/packages/indexer_auth_manager.js index cc00e4d4..bfc5463b 100644 --- a/api/src/packages/indexer_auth_manager.js +++ b/api/src/packages/indexer_auth_manager.js @@ -9,17 +9,19 @@ import { Wallet, ethers } from "ethers"; import * as LitJsSdk from "@lit-protocol/lit-node-client-nodejs"; import { LitContracts } from "@lit-protocol/contracts-sdk"; import { - LitAbility, LitPKPResource, LitActionResource, + generateAuthSig, + createSiweMessageWithRecaps, } from "@lit-protocol/auth-helpers"; +import { LitAbility } from "@lit-protocol/types"; import { DIDSession, createDIDCacao, createDIDKey } from "did-session"; import { Cacao, SiweMessage } from "@didtools/cacao"; import { randomBytes, randomString } from "@stablelib/random"; import RedisClient from "../clients/redis.js"; -import { generateLITAction } from "../utils/helpers.js"; +import { fetchModelInfo, generateLITAction } from "../utils/helpers.js"; // Configuration const config = { @@ -96,71 +98,57 @@ async function mintNewCapacityToken() { return capacityTokenIdStr; } -async function authNeededCallback({ resources, expiration, uri }) { - // you can change this resource to anything you would like to specify - const litResource = new LitActionResource("*"); - - const recapObject = - await litNodeClient.generateSessionCapabilityObjectWithWildcards([ - litResource, - ]); - - recapObject.addCapabilityForResource( - litResource, - LitAbility.LitActionExecution, - ); - - const verified = recapObject.verifyCapabilitiesForResource( - litResource, - LitAbility.LitActionExecution, - ); - - if (!verified) { - throw new Error("Failed to verify capabilities for resource"); - } - - let siweMessage = new SiweMessage({ - domain: "index.network", // change to your domain ex: example.app.com - address: indexerWallet.address, - statement: "Index Network says: ", // configure to what ever you would like - uri, - version: "1", - chainId: "1", - expirationTime: expiration, - resources, - }); - - siweMessage = recapObject.addToSiweMessage(siweMessage); - - const messageToSign = siweMessage.toMessage(); - const signature = await indexerWallet.signMessage(messageToSign); - - const authSig = { - sig: signature, - derivedVia: "web3.eth.personal.sign", - signedMessage: messageToSign, - address: indexerWallet.address, - }; - - return authSig; -} - async function generateAndStoreAuthSigs(capacityTokenId) { console.log("Generating and storing authorization signatures..."); const { capacityDelegationAuthSig } = await litNodeClient.createCapacityDelegationAuthSig({ dAppOwnerWallet: indexerWallet, + delegateeAddresses: [indexerWallet.address], capacityTokenId: capacityTokenId, expiration: thirtyDaysLater.toISOString(), }); + const latestBlockhash = await litNodeClient.getLatestBlockhash(); + console.log("latestBlockhash:", latestBlockhash); + const dAppSessionSigs = await litNodeClient.getSessionSigs({ expiration: thirtyDaysLater.toISOString(), chain: "ethereum", resourceAbilityRequests: [ { resource: new LitPKPResource("*"), ability: LitAbility.PKPSigning }, + { + resource: new LitActionResource("*"), + ability: LitAbility.LitActionExecution, + }, ], - authNeededCallback: authNeededCallback, + authNeededCallback: async (params) => { + if (!params.uri) { + throw new Error("uri is required"); + } + if (!params.expiration) { + throw new Error("expiration is required"); + } + + if (!params.resourceAbilityRequests) { + throw new Error("resourceAbilityRequests is required"); + } + + const toSign = await createSiweMessageWithRecaps({ + uri: params.uri, + expiration: params.expiration, + resources: params.resourceAbilityRequests, + walletAddress: indexerWallet.address, + nonce: latestBlockhash, + litNodeClient, + }); + + const authSig = await generateAuthSig({ + signer: indexerWallet, + toSign, + }); + + return authSig; + }, capacityDelegationAuthSig, }); @@ -214,6 +202,7 @@ async function scheduleTokenRefresh() { console.log("Current capacity token is still valid. No action needed."); } } catch (error) { + console.log(error); process.exit(1); } } @@ -237,7 +226,12 @@ async function generateDefaultLitActions() { }, }, ]; - const defaultCID = await generateLITAction(defaultConditions); + + let { runtimeDefinition } = await fetchModelInfo(); + const defaultCID = await generateLITAction( + defaultConditions, + runtimeDefinition, + ); console.log("Default CID", defaultCID); } @@ -281,4 +275,4 @@ async function run() { process.exit(0); } -generateDefaultLitActions(); +run(); diff --git a/api/yarn.lock b/api/yarn.lock index 0fdd1e36..3bafdea1 100644 --- a/api/yarn.lock +++ b/api/yarn.lock @@ -1504,21 +1504,21 @@ resolved "https://registry.yarnpkg.com/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz#353ce4a76c83fadec272ea5674ede767650762fd" integrity sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g== -"@lit-protocol/access-control-conditions@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/access-control-conditions/-/access-control-conditions-5.0.0.tgz#907e64a52d01030aa71eac9c06a1759b99b9ed1c" - integrity sha512-0mBGTAY+yJk0Y3GuUYvbRIM7n0eLOD3WPovoDezmm9/KAWYY81QIKUbuRyhcuo8VlxbXmFlRLDC/55KlSvBpIw== +"@lit-protocol/access-control-conditions@5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@lit-protocol/access-control-conditions/-/access-control-conditions-5.1.0.tgz#38467bb6db90fd1e8b8617c304329b87cccf39cf" + integrity sha512-CPL0vCtNCFDyBLIP1P7l9MiRLQkAiiI4Sz9fiAV7VYRn2jF/ylErXX+BnGaDuOwuH6nbXwj5exAxF+mebTJV4A== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/misc" "5.0.0" - "@lit-protocol/types" "5.0.0" - "@lit-protocol/uint8arrays" "5.0.0" + "@lit-protocol/auth-helpers" "5.1.0" + "@lit-protocol/constants" "5.1.0" + "@lit-protocol/logger" "5.1.0" + "@lit-protocol/misc" "5.1.0" + "@lit-protocol/types" "5.1.0" + "@lit-protocol/uint8arrays" "5.1.0" ajv "^8.12.0" ethers "^5.7.1" jszip "^3.10.1" @@ -1529,28 +1529,26 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/access-control-conditions@5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/access-control-conditions/-/access-control-conditions-5.1.0.tgz#38467bb6db90fd1e8b8617c304329b87cccf39cf" - integrity sha512-CPL0vCtNCFDyBLIP1P7l9MiRLQkAiiI4Sz9fiAV7VYRn2jF/ylErXX+BnGaDuOwuH6nbXwj5exAxF+mebTJV4A== +"@lit-protocol/access-control-conditions@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/access-control-conditions/-/access-control-conditions-6.0.0-beta.4.tgz#0e4093b27f7bef58d0f98a8d1c50e656d8800839" + integrity sha512-QbBa3eQF7A5tkQT2s3+Ygxf3Kdx/OtoRriOyP2kLkpzP8efkGTAOHuvtTWSVQ/5Eww0Jjo8cUoU8ptl0VU9Gyw== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.1.0" - "@lit-protocol/constants" "5.1.0" - "@lit-protocol/logger" "5.1.0" - "@lit-protocol/misc" "5.1.0" - "@lit-protocol/types" "5.1.0" - "@lit-protocol/uint8arrays" "5.1.0" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" ajv "^8.12.0" ethers "^5.7.1" jszip "^3.10.1" punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" uint8arrays "^4.0.3" util "0.12.5" @@ -1596,14 +1594,6 @@ tslib "^2.3.0" uint8arrays "^4.0.3" -"@lit-protocol/auth-helpers@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/auth-helpers/-/auth-helpers-5.0.0.tgz#74c028b7314abfcee0a42f184d6a0373e574cfc0" - integrity sha512-uiTUwhxyzUe7h57i4KhJjL96XP0PcxSufpBq2Z2XjEzWD3ns6ruyy7fWpB7wseR0ePzW3kegEz8fuzhl/HtTfQ== - dependencies: - siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - "@lit-protocol/auth-helpers@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@lit-protocol/auth-helpers/-/auth-helpers-5.1.0.tgz#cc222d5a18b0617c22c2156e8756e440e399260c" @@ -1612,12 +1602,29 @@ siwe "^2.0.5" siwe-recap "0.0.2-alpha.0" -"@lit-protocol/bls-sdk@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/bls-sdk/-/bls-sdk-5.0.0.tgz#699177dd0676cc874682f7e83689c5fc534bfe93" - integrity sha512-PEPB1mJBOh6lgvtZovZUxjRFpJpCc619XeKj97vhj3bMOJakQwHbd903wUNF3VHbZhfDX8RdVonjBfl/yESVzA== +"@lit-protocol/auth-helpers@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/auth-helpers/-/auth-helpers-6.0.0-beta.4.tgz#dbc890d5a3123c65d9eb737566051391938fa834" + integrity sha512-G75ECYkT6MwmDnpDlqojg58UmS2PWmIUC7XTNFhdHhQW4DXZxCDEacMylwwDCx9fpJnRo2exOUmqXNu5sRi91A== dependencies: - tslib "1.14.1" + "@ethersproject/abstract-provider" "5.7.0" + "@ethersproject/contracts" "5.7.0" + "@ethersproject/providers" "5.7.2" + "@lit-protocol/access-control-conditions" "6.0.0-beta.4" + "@lit-protocol/accs-schemas" "0.0.7" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" + ajv "^8.12.0" + ethers "^5.7.1" + jszip "^3.10.1" + punycode "2.3.1" + siwe "^2.0.5" + siwe-recap "0.0.2-alpha.0" + tslib "2.6.0" + uint8arrays "^4.0.3" util "0.12.5" "@lit-protocol/bls-sdk@5.1.0": @@ -1628,20 +1635,13 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/constants@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/constants/-/constants-5.0.0.tgz#6fa307548494facffded7f323d68a5c333019389" - integrity sha512-6zVezFFD/1DhcJn+0xsvEnV4Grpy6GFM3klD3TZInvue10WYJsrSqSfagNraaemfMwf1DDOpdC8jG2J/4Rl78g== +"@lit-protocol/bls-sdk@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/bls-sdk/-/bls-sdk-6.0.0-beta.4.tgz#598346ffd6e94ac14529c240bc57caebe9df2686" + integrity sha512-iec8HC9pJ+CPb+wus13Lgv9iGqOtSdejl8WkXQ/xrPoQ9T/gu5FwsThABIk7RX01YSvE/eAtyi1m+yF5qejleQ== dependencies: - "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/types" "5.0.0" - ethers "^5.7.1" - jszip "^3.10.1" - siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" + util "0.12.5" "@lit-protocol/constants@5.1.0": version "5.1.0" @@ -1658,36 +1658,18 @@ siwe-recap "0.0.2-alpha.0" tslib "^2.3.0" -"@lit-protocol/contracts-sdk@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/contracts-sdk/-/contracts-sdk-5.0.0.tgz#67e0fe63b4a33334a478a300c9a09d6deb2fe04e" - integrity sha512-OhBmloF5GO2UhyFPggE2/FCaH//hfouTOWam9YqAqTFrfVH7DR6SIJYzOdGApX1YEm7Gf/QoBLyjV0wSMMXx8g== +"@lit-protocol/constants@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/constants/-/constants-6.0.0-beta.4.tgz#a7331ceb0e56fc3b44e3e8e696ccb13415b96ad6" + integrity sha512-yWKtwErUTU1gYJCdxy+Jpb4EUgentSoEyMyEzXli/U4TjJXhfhUkioLZMIJUxLGewF18liq3TRYCcpeJ/lxxyQ== dependencies: - "@cosmjs/amino" "0.30.1" - "@cosmjs/crypto" "0.30.1" - "@cosmjs/encoding" "0.30.1" - "@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.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/misc" "5.0.0" - "@lit-protocol/types" "5.0.0" - ajv "^8.12.0" - bitcoinjs-lib "^6.1.0" + "@lit-protocol/types" "6.0.0-beta.4" ethers "^5.7.1" - jose "^4.14.4" jszip "^3.10.1" - process "0.11.10" - punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" - uint8arrays "^4.0.3" - util "0.12.5" + tslib "1.14.1" "@lit-protocol/contracts-sdk@5.1.0": version "5.1.0" @@ -1720,10 +1702,10 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/core@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/core/-/core-5.0.0.tgz#93497148e3977cda6aa9f6379406d4b308c7b26a" - integrity sha512-PrF8L0lQ0W+s7MILY+hEcuEtMFP01vDWJnhxSaLYP6vnEPS8SHlKJbuISh4Q4iEUWVpcNkkgqq232Bp42xzB0w== +"@lit-protocol/contracts-sdk@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/contracts-sdk/-/contracts-sdk-6.0.0-beta.4.tgz#c22ebfd30c81225c96c8cd02def3ee379e8f4e65" + integrity sha512-bgaAsD3G/MaqbAYGanMTcPihLy3rO0q0FMUggpU0SftEf1NQa9If1XHPpaQL8ckxDLUDEPLeHk8AM3nSSielRA== dependencies: "@cosmjs/amino" "0.30.1" "@cosmjs/crypto" "0.30.1" @@ -1732,35 +1714,20 @@ "@ethersproject/abstract-provider" "5.7.0" "@ethersproject/contracts" "5.7.0" "@ethersproject/providers" "5.7.2" - "@lit-protocol/access-control-conditions" "5.0.0" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/bls-sdk" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/contracts-sdk" "5.0.0" - "@lit-protocol/crypto" "5.0.0" - "@lit-protocol/ecdsa-sdk" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/misc" "5.0.0" - "@lit-protocol/nacl" "5.0.0" - "@lit-protocol/sev-snp-utils-sdk" "5.0.0" - "@lit-protocol/types" "5.0.0" - "@lit-protocol/uint8arrays" "5.0.0" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" ajv "^8.12.0" bitcoinjs-lib "^6.1.0" - bs58 "^5.0.0" - cross-fetch "^3.1.4" - date-and-time "^2.4.1" ethers "^5.7.1" jose "^4.14.4" jszip "^3.10.1" - multiformats "^9.7.1" - pako "1.0.11" process "0.11.10" punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" uint8arrays "^4.0.3" util "0.12.5" @@ -1808,34 +1775,45 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/crypto@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/crypto/-/crypto-5.0.0.tgz#c03dff45dde6ef866d8b44d4976fdfb5247c0c0b" - integrity sha512-9qg8ZmuFv0E61o01Ib6COW+w4vjpXlUXJpw4+syp1ZXUCscqmPGwrcFOCMFpye5V0mNE+vtdYg8wFMD1cUjjog== +"@lit-protocol/core@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/core/-/core-6.0.0-beta.4.tgz#cacb05aab635d2f4d81f7c92dffccb9d7b2f8b5a" + integrity sha512-t1QVevz2/J35TU5EEYIxMaUJzNPW9QPBffuQhYqy1f3daZR2zt+OCc19or5xlN3x9rBwZ1pm2Jc1WbcPhO3+JQ== dependencies: + "@cosmjs/amino" "0.30.1" + "@cosmjs/crypto" "0.30.1" + "@cosmjs/encoding" "0.30.1" + "@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" "6.0.0-beta.4" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/bls-sdk" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/ecdsa-sdk" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/misc" "5.0.0" - "@lit-protocol/nacl" "5.0.0" - "@lit-protocol/sev-snp-utils-sdk" "5.0.0" - "@lit-protocol/types" "5.0.0" - "@lit-protocol/uint8arrays" "5.0.0" + "@lit-protocol/bls-sdk" "6.0.0-beta.4" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/contracts-sdk" "6.0.0-beta.4" + "@lit-protocol/crypto" "6.0.0-beta.4" + "@lit-protocol/ecdsa-sdk" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/nacl" "6.0.0-beta.4" + "@lit-protocol/sev-snp-utils-sdk" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" ajv "^8.12.0" - cross-fetch "^3.1.4" + bitcoinjs-lib "^6.1.0" + bs58 "^5.0.0" + cross-fetch "3.1.4" + date-and-time "^2.4.1" ethers "^5.7.1" + jose "^4.14.4" jszip "^3.10.1" + multiformats "^9.7.1" pako "1.0.11" + process "0.11.10" punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" uint8arrays "^4.0.3" util "0.12.5" @@ -1870,12 +1848,33 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/ecdsa-sdk@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/ecdsa-sdk/-/ecdsa-sdk-5.0.0.tgz#fbb20359f09f9e696a65a8b079e17089c742f319" - integrity sha512-rCouRIhqQpa+bqcmYNAZZyJp9gru5LG1B49CzfdgI0ux0XkkJZbBTpUzK9LG04TNEb8oGzeTKgeqfW40cpWWhA== +"@lit-protocol/crypto@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/crypto/-/crypto-6.0.0-beta.4.tgz#b9d5fcc7d3bf942a8ad02ebea981320eecd6afb4" + integrity sha512-6QmN4Qc1fmu+/nwhGNrlaUdd39ANbo+KGUCya4Azth2Y65QeJmXx+tN0nYQpBRubfmhc/GpTLlFZaZMHto3ayQ== dependencies: + "@ethersproject/abstract-provider" "5.7.0" + "@ethersproject/contracts" "5.7.0" + "@ethersproject/providers" "5.7.2" + "@lit-protocol/accs-schemas" "0.0.7" + "@lit-protocol/bls-sdk" "6.0.0-beta.4" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/ecdsa-sdk" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/nacl" "6.0.0-beta.4" + "@lit-protocol/sev-snp-utils-sdk" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" + ajv "^8.12.0" + cross-fetch "3.1.4" + ethers "^5.7.1" + jszip "^3.10.1" + pako "1.0.11" + punycode "2.3.1" + siwe "^2.0.5" tslib "1.14.1" + uint8arrays "^4.0.3" util "0.12.5" "@lit-protocol/ecdsa-sdk@5.1.0": @@ -1886,36 +1885,12 @@ tslib "1.14.1" util "0.12.5" -"@lit-protocol/encryption@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/encryption/-/encryption-5.0.0.tgz#3a917ffba6e38ef27c2c88587532ab4069db729a" - integrity sha512-RwBc3ovTX8UHUUnodR8PuATgY5yyIDHhZYUT5PAswOowjuaTNpV1CSKVdq/jrTVFlxjZ0UONYCpCoI5gPDSCow== +"@lit-protocol/ecdsa-sdk@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/ecdsa-sdk/-/ecdsa-sdk-6.0.0-beta.4.tgz#df16ba1b5087ff079b224c0b9ad496fa47e2296e" + integrity sha512-LpyNl0yEz+RDQVOjS8/KiAShujxPlIxb59oO01KD79dFT1gxhYGL7FoQo2XqS1zZJ765iDCm9mqQaaFbEPd3Hg== dependencies: - "@ethersproject/abstract-provider" "5.7.0" - "@ethersproject/contracts" "5.7.0" - "@ethersproject/providers" "5.7.2" - "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/bls-sdk" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/crypto" "5.0.0" - "@lit-protocol/ecdsa-sdk" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/misc" "5.0.0" - "@lit-protocol/nacl" "5.0.0" - "@lit-protocol/sev-snp-utils-sdk" "5.0.0" - "@lit-protocol/types" "5.0.0" - "@lit-protocol/uint8arrays" "5.0.0" - ajv "^8.12.0" - cross-fetch "^3.1.4" - ethers "^5.7.1" - jszip "^3.10.1" - pako "1.0.11" - punycode "2.3.1" - siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" - uint8arrays "^4.0.3" + tslib "1.14.1" util "0.12.5" "@lit-protocol/encryption@5.1.0": @@ -1950,51 +1925,33 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/lit-node-client-nodejs@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client-nodejs/-/lit-node-client-nodejs-5.0.0.tgz#4fcca86ceb31fa4a452e4c5b79fb3011553533a8" - integrity sha512-AVAYi8ErYn+W4AKkYqdXh8/BQzeJ7VqYIv/rx1XiDYhxeCU8mCmWy0Y0h+Be7ZSKo1SVAnl4zvgo+GWViE4dRw== +"@lit-protocol/encryption@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/encryption/-/encryption-6.0.0-beta.4.tgz#f51947af28771e2eeca366b48d92ec2be347f6ef" + integrity sha512-3aq35fmD858gnK9acwgZUNeHvf+70a9ot7XpJUgVdxZHHweIErbbAfX4AyV11gS37uOM/e9jrZUxZoNXz406xA== dependencies: - "@cosmjs/amino" "0.30.1" - "@cosmjs/crypto" "0.30.1" - "@cosmjs/encoding" "0.30.1" - "@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" "5.0.0" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/bls-sdk" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/contracts-sdk" "5.0.0" - "@lit-protocol/core" "5.0.0" - "@lit-protocol/crypto" "5.0.0" - "@lit-protocol/ecdsa-sdk" "5.0.0" - "@lit-protocol/encryption" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/misc" "5.0.0" - "@lit-protocol/misc-browser" "5.0.0" - "@lit-protocol/nacl" "5.0.0" - "@lit-protocol/sev-snp-utils-sdk" "5.0.0" - "@lit-protocol/types" "5.0.0" - "@lit-protocol/uint8arrays" "5.0.0" + "@lit-protocol/bls-sdk" "6.0.0-beta.4" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/crypto" "6.0.0-beta.4" + "@lit-protocol/ecdsa-sdk" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/nacl" "6.0.0-beta.4" + "@lit-protocol/sev-snp-utils-sdk" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" ajv "^8.12.0" - bitcoinjs-lib "^6.1.0" - bs58 "^5.0.0" - cross-fetch "^3.1.4" - date-and-time "^2.4.1" + cross-fetch "3.1.4" ethers "^5.7.1" - jose "^4.14.4" jszip "^3.10.1" - multiformats "^9.7.1" pako "1.0.11" - process "0.11.10" punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" uint8arrays "^4.0.3" util "0.12.5" @@ -2046,6 +2003,54 @@ uint8arrays "^4.0.3" util "0.12.5" +"@lit-protocol/lit-node-client-nodejs@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client-nodejs/-/lit-node-client-nodejs-6.0.0-beta.4.tgz#9c752423d811ce2c8b42f43a67992ef6c3da4350" + integrity sha512-03f5ZG01HwG0reXx1AmjD03nbQJU6sVRzVDOcESjvSJu/hmOEhAPykTxnEnzV6TKgH/+JOqIVUBWHt8ZDPiBTA== + dependencies: + "@cosmjs/amino" "0.30.1" + "@cosmjs/crypto" "0.30.1" + "@cosmjs/encoding" "0.30.1" + "@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" "6.0.0-beta.4" + "@lit-protocol/accs-schemas" "0.0.7" + "@lit-protocol/auth-helpers" "6.0.0-beta.4" + "@lit-protocol/bls-sdk" "6.0.0-beta.4" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/contracts-sdk" "6.0.0-beta.4" + "@lit-protocol/core" "6.0.0-beta.4" + "@lit-protocol/crypto" "6.0.0-beta.4" + "@lit-protocol/ecdsa-sdk" "6.0.0-beta.4" + "@lit-protocol/encryption" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/misc" "6.0.0-beta.4" + "@lit-protocol/misc-browser" "6.0.0-beta.4" + "@lit-protocol/nacl" "6.0.0-beta.4" + "@lit-protocol/sev-snp-utils-sdk" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" + ajv "^8.12.0" + bitcoinjs-lib "^6.1.0" + bs58 "^5.0.0" + cross-fetch "3.1.4" + date-and-time "^2.4.1" + ethers "^5.7.1" + jose "^4.14.4" + jszip "^3.10.1" + multiformats "^9.7.1" + pako "1.0.11" + process "0.11.10" + punycode "2.3.1" + siwe "^2.0.5" + siwe-recap "0.0.2-alpha.0" + tslib "^2.3.0" + uint8arrays "^4.0.3" + util "0.12.5" + "@lit-protocol/lit-node-client@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@lit-protocol/lit-node-client/-/lit-node-client-5.1.0.tgz#a677e97e073f792758342734499b3b77a8956ca9" @@ -2104,24 +2109,6 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/logger@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/logger/-/logger-5.0.0.tgz#e66fa0d2a5d9fd99b227002e696e986fa6c4507b" - integrity sha512-SXLBv3keMfE1i5Cw3Mlh4y8mXwwB3UzmB1TM+heWBk3wdbG7Gh55burIUF6YYJym78+xI8lz1UymO4s6GHeufw== - dependencies: - "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/types" "5.0.0" - ethers "^5.7.1" - jszip "^3.10.1" - punycode "2.3.1" - siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" - uint8arrays "^4.0.3" - "@lit-protocol/logger@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@lit-protocol/logger/-/logger-5.1.0.tgz#643329593d4610e2e78112d0b78dd8324b7909d6" @@ -2140,22 +2127,21 @@ tslib "^2.3.0" uint8arrays "^4.0.3" -"@lit-protocol/misc-browser@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/misc-browser/-/misc-browser-5.0.0.tgz#fec6025f862d1390844118ebe4eb66099cbd5685" - integrity sha512-zDVYH1/3a5yahILZQ6Hrb2riWYbOBredc1jmpeHVlhx5egya4RZ4RkA3m+Z2/VympsbAsvrMdCt3NqxVXoISvA== +"@lit-protocol/logger@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/logger/-/logger-6.0.0-beta.4.tgz#d971415f1a30fe7a6cee7fe6fb64f8f32c07e31d" + integrity sha512-zFZUi9vXic31hPHSh15Aag3bjoVO1i5N+dN0YAAYFNtegkbQGIkCA/JYGS+wht7GC6Ht+kjWnY+W5X+RdphaCg== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/types" "5.0.0" - "@lit-protocol/uint8arrays" "5.0.0" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" ethers "^5.7.1" jszip "^3.10.1" + punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" + uint8arrays "^4.0.3" "@lit-protocol/misc-browser@5.1.0": version "5.1.0" @@ -2174,28 +2160,20 @@ siwe-recap "0.0.2-alpha.0" tslib "^2.3.0" -"@lit-protocol/misc@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/misc/-/misc-5.0.0.tgz#177a3a3a4e18107b4a35dab40280f52ed98f5084" - integrity sha512-W/26kleFMueqGinZrnIS3WrVf8SQBWrmWAfl26S7jvbEJhGokS5Dca25sB3azPnXoyzsx/7IPb5tHfpZcf+RTA== +"@lit-protocol/misc-browser@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/misc-browser/-/misc-browser-6.0.0-beta.4.tgz#99f60f395ffbbad0f4c9f346380144489f8f083c" + integrity sha512-1FTRkhNRNlAuLgAK/FwYXW5gFGWFHbixCw44lbWA7xn4StvXamdVB1XBc4I8f0xdzrZKh/Pzcx2otWyUiMdaPg== dependencies: "@ethersproject/abstract-provider" "5.7.0" - "@ethersproject/contracts" "5.7.0" - "@ethersproject/providers" "5.7.2" "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - "@lit-protocol/constants" "5.0.0" - "@lit-protocol/logger" "5.0.0" - "@lit-protocol/types" "5.0.0" - ajv "^8.12.0" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + "@lit-protocol/uint8arrays" "6.0.0-beta.4" ethers "^5.7.1" jszip "^3.10.1" - punycode "2.3.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" - uint8arrays "^4.0.3" - util "0.12.5" + tslib "1.14.1" "@lit-protocol/misc@5.1.0": version "5.1.0" @@ -2220,12 +2198,26 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/nacl@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/nacl/-/nacl-5.0.0.tgz#4182adca9f33ca24c2d3c579adb00ec3a31de962" - integrity sha512-RWbj7dQc8Ss+FIc7Rls3mK1hFpfQE5/HYfs+24fBHmVdZlHPnlUXpIaqgWWArGLoGQrZIpnUlblWUII6y8gFpA== +"@lit-protocol/misc@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/misc/-/misc-6.0.0-beta.4.tgz#2a38ac75503e61229dcf217c069669d546a392e4" + integrity sha512-HgvMRxGeTCUUJoxMWX805fF3PlD/FsVpGiW4pTSjMKZdpsFlivvQViFiDRUC0d9/jDmsmmMXgOP4T+ZWLPbTlg== dependencies: + "@ethersproject/abstract-provider" "5.7.0" + "@ethersproject/contracts" "5.7.0" + "@ethersproject/providers" "5.7.2" + "@lit-protocol/accs-schemas" "0.0.7" + "@lit-protocol/constants" "6.0.0-beta.4" + "@lit-protocol/logger" "6.0.0-beta.4" + "@lit-protocol/types" "6.0.0-beta.4" + ajv "^8.12.0" + ethers "^5.7.1" + jszip "^3.10.1" + punycode "2.3.1" + siwe "^2.0.5" tslib "1.14.1" + uint8arrays "^4.0.3" + util "0.12.5" "@lit-protocol/nacl@5.1.0": version "5.1.0" @@ -2234,6 +2226,13 @@ dependencies: tslib "1.14.1" +"@lit-protocol/nacl@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/nacl/-/nacl-6.0.0-beta.4.tgz#77376c5db847ffe803f39e4bfe3d10d504d2b5d2" + integrity sha512-+VlKQQ318a49RSmZGbJW5iLSGLr/JPojM+HHvGm2ZJ4eWPwOcAS9sUx0Q7JvaW5VphymAiz05PnH3FlOEzvtWg== + dependencies: + tslib "1.14.1" + "@lit-protocol/pkp-base@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@lit-protocol/pkp-base/-/pkp-base-5.1.0.tgz#f790457fe80cd9efb085990c069f25c7c5dcc685" @@ -2366,14 +2365,6 @@ uint8arrays "^4.0.3" util "0.12.5" -"@lit-protocol/sev-snp-utils-sdk@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/sev-snp-utils-sdk/-/sev-snp-utils-sdk-5.0.0.tgz#74f889bfefc4b09a6b0c1593505a770b2dca8080" - integrity sha512-RiKR+DENpZ2iS5OLHpkDmKz7IAIVDKStidf6di4yQ1E0yI5VO4oAg7zMXPnCB+7lnsUbPyaSyVKTTuRWvOTlsg== - dependencies: - cross-fetch "^3.1.4" - tslib "1.14.1" - "@lit-protocol/sev-snp-utils-sdk@5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@lit-protocol/sev-snp-utils-sdk/-/sev-snp-utils-sdk-5.1.0.tgz#fc90dec2d8b0c5543d60af83c113635769275062" @@ -2382,19 +2373,13 @@ cross-fetch "^3.1.4" tslib "1.14.1" -"@lit-protocol/types@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/types/-/types-5.0.0.tgz#51bf4d1b59538945b51354597a505e8ccbcdf5fc" - integrity sha512-6r4LCxEe0QiZxFWYQHkTRwedypcEm98kcvBdiGmaoPj8pnbHtjuGOAveG9HumAUvs85rd8psmVh9cl3yLFQYkw== +"@lit-protocol/sev-snp-utils-sdk@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/sev-snp-utils-sdk/-/sev-snp-utils-sdk-6.0.0-beta.4.tgz#52fa2ec900b04d820aa9a12a6547596e0d8ea418" + integrity sha512-kUtMC0uxrHiWZ9eKODuaEY0zCSkeDoXYnDkANI1r4ONg69SaD4cg0fy1bW/3nNEzbrTRiz7ZpCBi0+/W4I/zfg== dependencies: - "@ethersproject/abstract-provider" "5.7.0" - "@lit-protocol/accs-schemas" "0.0.7" - "@lit-protocol/auth-helpers" "5.0.0" - ethers "^5.7.1" - jszip "^3.10.1" - siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + cross-fetch "3.1.4" + tslib "1.14.1" "@lit-protocol/types@5.1.0": version "5.1.0" @@ -2410,6 +2395,18 @@ siwe-recap "0.0.2-alpha.0" tslib "^2.3.0" +"@lit-protocol/types@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/types/-/types-6.0.0-beta.4.tgz#b2ad074094e45395bfd08f3b7422e19401f29bfa" + integrity sha512-JszYSnc4/gbJ26Kfdm9cTuhcaWCYzdL+mQmbtmPX6WNgmsxp5p3GXn7uEsCxzRzs+isucUJECODCkRXX4UBIgg== + dependencies: + "@ethersproject/abstract-provider" "5.7.0" + "@lit-protocol/accs-schemas" "0.0.7" + ethers "^5.7.1" + jszip "^3.10.1" + siwe "^2.0.5" + tslib "1.14.1" + "@lit-protocol/uint8arrays@4.1.1": version "4.1.1" resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-4.1.1.tgz#4ea0ef864cff693e6100d8fd9471a3b0ac3e764a" @@ -2423,10 +2420,10 @@ siwe-recap "0.0.2-alpha.0" tslib "^2.3.0" -"@lit-protocol/uint8arrays@5.0.0": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-5.0.0.tgz#f6764524bcbb85022cd2b76ed33ea2552607e466" - integrity sha512-HB1eqlFOi91Fs5KsFA/9B7IpPmtZanWOddAOs/DXgAX4nsLf1RZJMhKFgb1c0Dro5ANrhMFQ8RotDGeUlKhsUQ== +"@lit-protocol/uint8arrays@5.1.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-5.1.0.tgz#873f44f76e5d2e6b7d60c66d7b8e0bf9b1828bac" + integrity sha512-dRZ0rprsWB8z441QGculhTHahwxMIH2/b7znWnN7s75MhNl4OLh7F/isq7rXq6Q2v/xNxgm/HN58++b5NWbWOQ== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@lit-protocol/accs-schemas" "0.0.7" @@ -2436,18 +2433,17 @@ siwe-recap "0.0.2-alpha.0" tslib "^2.3.0" -"@lit-protocol/uint8arrays@5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-5.1.0.tgz#873f44f76e5d2e6b7d60c66d7b8e0bf9b1828bac" - integrity sha512-dRZ0rprsWB8z441QGculhTHahwxMIH2/b7znWnN7s75MhNl4OLh7F/isq7rXq6Q2v/xNxgm/HN58++b5NWbWOQ== +"@lit-protocol/uint8arrays@6.0.0-beta.4": + version "6.0.0-beta.4" + resolved "https://registry.yarnpkg.com/@lit-protocol/uint8arrays/-/uint8arrays-6.0.0-beta.4.tgz#8af117221a0a66d6f9bbbefac62cb12c97439e15" + integrity sha512-lfCDd4eIbSODfRJx1PX558d11x42l9UlYJQZwEhCh8uqwa103vSMt3O2AUFWhPyk5bt3zrnr9t9GZ43aX8vnxw== dependencies: "@ethersproject/abstract-provider" "5.7.0" "@lit-protocol/accs-schemas" "0.0.7" ethers "^5.7.1" jszip "^3.10.1" siwe "^2.0.5" - siwe-recap "0.0.2-alpha.0" - tslib "^2.3.0" + tslib "1.14.1" "@lit/reactive-element@^1.3.0", "@lit/reactive-element@^1.6.0": version "1.6.3" @@ -5128,6 +5124,13 @@ cross-eventsource@^1.0.0: "@types/eventsource" "^1.1.15" eventsource "^2.0.2" +cross-fetch@3.1.4: + version "3.1.4" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.4.tgz#9723f3a3a247bf8b89039f3a380a9244e8fa2f39" + integrity sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ== + dependencies: + node-fetch "2.6.1" + cross-fetch@^3.1.4, cross-fetch@^3.1.5: version "3.1.8" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" @@ -7953,6 +7956,11 @@ node-fetch-native@^1.6.1, node-fetch-native@^1.6.2, node-fetch-native@^1.6.3: resolved "https://registry.yarnpkg.com/node-fetch-native/-/node-fetch-native-1.6.4.tgz#679fc8fd8111266d47d7e72c379f1bed9acff06e" integrity sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ== +node-fetch@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" + integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== + node-fetch@^2.6.1, node-fetch@^2.6.12, node-fetch@^2.6.8: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" @@ -9534,6 +9542,11 @@ tslib@1.14.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" + integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA== + tslib@^2.1.0, tslib@^2.3.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.5.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" diff --git a/indexer/src/indexer/service/indexer.service.ts b/indexer/src/indexer/service/indexer.service.ts index a7a85cb9..eba67c36 100644 --- a/indexer/src/indexer/service/indexer.service.ts +++ b/indexer/src/indexer/service/indexer.service.ts @@ -1,333 +1,361 @@ import { HttpStatus, Inject, Injectable, Logger } from '@nestjs/common'; -import { Chroma } from "@langchain/community/vectorstores/chroma"; +import { Chroma } from '@langchain/community/vectorstores/chroma'; import { OpenAIEmbeddings } from '@langchain/openai'; -import { UnstructuredLoader } from 'langchain/document_loaders/fs/unstructured' -import { JSONLoader } from "langchain/document_loaders/fs/json"; +import { UnstructuredLoader } from 'langchain/document_loaders/fs/unstructured'; +import { JSONLoader } from 'langchain/document_loaders/fs/json'; import { IndexDeleteQuery, IndexUpdateBody } from '../schema/indexer.schema'; import { HttpService } from '@nestjs/axios'; import * as fs from 'fs'; import { MIME_TYPE } from '../schema/indexer.schema'; -import notionCrawler from "notion-crawler"; -import { TokenTextSplitter } from "langchain/text_splitter"; +import { TokenTextSplitter } from 'langchain/text_splitter'; @Injectable() export class IndexerService { - constructor( - private readonly httpService: HttpService, - @Inject('CHROMA_DB') private readonly chromaClient: Chroma, - ) { + constructor( + private readonly httpService: HttpService, + @Inject('CHROMA_DB') private readonly chromaClient: Chroma, + ) {} + + /** + * @description Crawl any document and return its content + * + * @param url Url to crawl + * @returns Web page content + */ + async crawl(url: string): Promise<{ url: string; content: string }> { + const response = await this.httpService.axiosRef({ + url: url, + method: 'GET', + responseType: 'stream', + headers: { + 'User-Agent': + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36', + }, + }); + + const content_type = response.headers['content-type'].split(';')[0]; + + if (!MIME_TYPE.hasOwnProperty(content_type)) + throw new Error('Unsupported content type'); + + // Write the file to disk + let file_name = `tmp/${Date.now()}.${MIME_TYPE[content_type]}`; + const writer = fs.createWriteStream(file_name); + response.data.pipe(writer); + + // Wait for the file to be written + const status = new Promise((resolve, reject) => { + writer.on('finish', resolve); + writer.on('error', reject); + }); + await status; + + // Check if the file was written + if (!status) throw new Error('Failed to download page'); + + Logger.log(`Downloaded ${url} to ${file_name}`, 'indexerService:crawl'); + + // Add an exception for JSON files + if (MIME_TYPE[content_type] === 'json') { + const loader = new JSONLoader(file_name); + const docs = await loader.load(); + return { + url: url, + content: docs as any, + }; + } + // Check for MIME type relevant to a webpage + if (MIME_TYPE[content_type] === 'html') { + const renderResponse = await fetch(process.env.CRAWLER_HOST, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ url }), + }); + const jsonData = await renderResponse.json(); + if (jsonData && jsonData.content) { + Logger.log(`Crawler was successful.`); + file_name = `tmp/rendered-${Date.now()}.${MIME_TYPE[content_type]}`; + const writerNew = fs.createWriteStream(file_name); + writerNew.write(jsonData.content); + writerNew.end(); + await new Promise((resolve, reject) => { + writerNew.on('finish', resolve); + writerNew.on('error', reject); + }); + } else { + throw new Error('Failed to render page'); + } + + Logger.log( + `Fetched Rendered HTML and saved to ${file_name}`, + 'indexerService:crawl', + ); } - /** - * @description Crawl any document and return its content - * - * @param url Url to crawl - * @returns Web page content - */ - async crawl(url: string): Promise<{ url: string; content: string; }>{ - - if (url.includes('notion')) { - - let rootNotionPageId = url.split('-').at(-1); - // strip numbers in the beginning of rootNotionPageId - rootNotionPageId = rootNotionPageId.replace(/^\d+/, ''); - - Logger.log(`Crawling ${rootNotionPageId}`, 'indexerService:crawlNotion'); - - const { pageBlocks, notionPageIdToSlugMapper, pageMap } = await notionCrawler( - rootNotionPageId, - ); - - Logger.log(`Crawled ${url} with ${pageBlocks.length} blocks`, 'indexerService:crawlNotion'); - Logger.log(`${JSON.stringify(pageBlocks)}`, 'indexerService:crawlnotion'); - Logger.log(`${JSON.stringify(notionPageIdToSlugMapper)}`, 'indexerService:crawlnotion'); - Logger.log(`${JSON.stringify(pageMap)}`, 'indexerService:crawlnotion'); - - return { - url: url, - content: pageBlocks.join(' ') - }; + // Initialize the loader + const loader = new UnstructuredLoader(file_name, { + apiUrl: process.env.UNSTRUCTURED_API_URL, + }); + + // Load the document + const docs = await loader.load(); + + // Delete the file + // fs.unlinkSync(file_name); + + // Merge the documents + let content = docs.map((doc) => doc?.pageContent).join(' '); + + // Clean the content + content = content.replace(/\s+/g, ' ').trim(); + + Logger.log( + `Extracted ${content.length} bytes from ${url}`, + 'indexerService:crawl', + ); + + return { + url: url, + content: content, + }; + } + + /** + * @description Index a web page into ChromaDB with the given metadata + * + * @param body IndexRequestBody + * @returns Success message + */ + async index(indexId: string, body: any): Promise<{ message: string }> { + Logger.log( + `Indexing ${JSON.stringify(body)?.length} bytes`, + 'indexerService:index', + ); + + const chromaID = await this.generateChromaID(indexId, body); + + try { + let payload = {}; + + const payload_keys = Object.keys(body); + + let model_type = ''; + payload_keys.forEach((key) => { + if (key.includes('_')) { + // Get the model type + model_type = key.split('_')[0]; + // Model based keys + let chroma_key = key.split('_')[1]; + payload[chroma_key] = body[key]; + } else { + // Index based keys + if (key !== 'vector') { + payload[key] = body[key]; + } } - - const response = await this.httpService.axiosRef({ - url: url, - method: 'GET', - responseType: 'stream', - headers: { - 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' - } + }); + + payload['model'] = model_type; + let pageContent = JSON.stringify(payload); + + // Reduce the content size for indexing + const splitter = new TokenTextSplitter(); + Logger.log( + `Splitting ${pageContent.length} bytes`, + 'indexerService:index', + ); + let tokens = await splitter.splitText(pageContent); + if (tokens.length > 8000) { + tokens = tokens.slice(0, 8000); + Logger.log( + 'Reducing token length', + 'indexerService:index:tokensLength', + ); + pageContent = tokens.join(' '); + } + + pageContent = pageContent.replace(/(\r\n|\n|\r)/gm, ' '); + pageContent = pageContent.replace(/ +/g, ' '); + pageContent = pageContent.trim(); + + Logger.log(`Reduced ${pageContent}`, 'indexerService:index'); + + const documents = [ + { + pageContent, + metadata: payload, + }, + ]; + + const ids = await this.chromaClient.addDocuments(documents, { + ids: [chromaID], + }); + + Logger.log(`Indexed ${JSON.stringify(ids)}`, 'indexerService:index'); + + return { + message: `Successfully indexed ${body.indexTitle} with id ${ids[0]}`, + }; + } catch (e) { + console.log(e); + throw e; + } + } + + /** + * @description Updates the document at ChromaDB with the given indexId and indexItemId + * + * @param body + * @returns Success or error message + */ + async update( + indexId: string, + indexItemId: string, + body: IndexUpdateBody, + ): Promise<{ message: string }> { + const chromaID = await this.generateChromaID(indexId, indexItemId); + + try { + let updated = { + ids: chromaID, + }; + + if (body.embedding) { + updated['embedding'] = body.embedding; + } + if (body.metadata) { + updated['metadata'] = body.metadata; + } + + const response = await this.chromaClient.collection.update(updated); + + return { + message: `Successfully updated ${chromaID}`, + }; + } catch (e) { + return { + message: `Update error for ${chromaID}`, + }; + } + } + + /** + * @description Deletes the document from ChromaDB with the given indexId and indexItemId + * + * @param body + * @returns Success or error message + */ + async delete( + indexId: string, + indexItemId: string | null, + ): Promise<{ message: string }> { + let response; + + const chromaID = await this.generateChromaID(indexId, indexItemId); + + try { + if (indexItemId) { + const res = await this.chromaClient.collection.get({ + ids: [chromaID], + limit: 1, }); - const content_type = response.headers['content-type'].split(';')[0]; - - if (!MIME_TYPE.hasOwnProperty(content_type)) throw new Error('Unsupported content type'); + if (res.ids.length === 0) + Logger.warn( + 'Delete failed, document not found', + 'indexerService:delete', + ); - // Write the file to disk - const file_name = `tmp/${Date.now()}.${MIME_TYPE[content_type]}`; - const writer = fs.createWriteStream(file_name); - response.data.pipe(writer); - - // Wait for the file to be written - const status = new Promise((resolve, reject) => { - writer.on('finish', resolve); - writer.on('error', reject); + const response = await this.chromaClient.collection.delete({ + ids: [chromaID], }); - await status; - - // Check if the file was written - if (!status) throw new Error('Failed to download page'); - - Logger.log(`Downloaded ${url} to ${file_name}`, 'indexerService:crawl'); - - // Add an exception for JSON files - if (MIME_TYPE[content_type] === 'json') { - const loader = new JSONLoader(file_name); - const docs = await loader.load(); - return { - url: url, - content: docs as any - } - } - // Initialize the loader - const loader = new UnstructuredLoader( - file_name, - { - apiUrl: process.env.UNSTRUCTURED_API_URL, - } + Logger.debug( + `Delete Response ${JSON.stringify(response)}`, + 'indexerService:delete', ); - // Load the document - const docs = await loader.load(); - - // Delete the file - // fs.unlinkSync(file_name); - - // Merge the documents - let content = '' - for (let doc of docs) { - content = content.concat(doc?.pageContent); - } - - // Clean the content - content = content.replace(/(\r\n|\n|\r)/gm, " "); - content = content.replace(/ +/g, " "); - content = content.trim(); - - Logger.log(`Extracted ${content.length} bytes from ${url}`, 'indexerService:crawl'); + // if (!response) throw new Error('Delete failed'); return { - url: url, - content: content + message: `Successfully deleted ${JSON.stringify(response)}`, }; - } - - /** - * @description Index a web page into ChromaDB with the given metadata - * - * @param body IndexRequestBody - * @returns Success message - */ - async index(indexId: string, body: any ): Promise<{ message: string }> { - - Logger.log(`Indexing ${JSON.stringify(body)?.length} bytes`, 'indexerService:index'); - - const chromaID = await this.generateChromaID(indexId, body); - - try { - - let payload = {} - - const payload_keys = Object.keys(body); - - let model_type = ''; - payload_keys.forEach((key) => { - if (key.includes('_')){ - // Get the model type - model_type = key.split('_')[0]; - // Model based keys - let chroma_key = key.split('_')[1]; - payload[chroma_key] = body[key]; - - } else { - // Index based keys - if ( key !== 'vector' ) { payload[key] = body[key]; } - } - }); - - payload['model'] = model_type; - let pageContent = JSON.stringify(payload) - - // Reduce the content size for indexing - const splitter = new TokenTextSplitter(); - Logger.log(`Splitting ${pageContent.length} bytes`, 'indexerService:index'); - let tokens = await splitter.splitText(pageContent); - if ( tokens.length > 8000 ) { - tokens = tokens.slice(0, 8000) ; - Logger.log('Reducing token length', "indexerService:index:tokensLength"); - pageContent = tokens.join(" "); - } - - pageContent = pageContent.replace(/(\r\n|\n|\r)/gm, " "); - pageContent = pageContent.replace(/ +/g, " "); - pageContent = pageContent.trim(); - - Logger.log(`Reduced ${pageContent}`, 'indexerService:index'); - - const documents = [{ - pageContent, - metadata: payload - }] - - const ids = await this.chromaClient.addDocuments(documents, {ids: [chromaID] }); - - Logger.log(`Indexed ${JSON.stringify(ids)}`, 'indexerService:index'); - - return { - message: `Successfully indexed ${body.indexTitle} with id ${ids[0]}` - } - - } catch (e) { - console.log(e); throw e; - } - } - - /** - * @description Updates the document at ChromaDB with the given indexId and indexItemId - * - * @param body - * @returns Success or error message - */ - async update(indexId: string , indexItemId: string, body: IndexUpdateBody): Promise<{ message: string }> { - - const chromaID = await this.generateChromaID(indexId, indexItemId); - - try { - - let updated = { - ids: chromaID - } - - if (body.embedding) { updated['embedding'] = body.embedding; } - if (body.metadata) { updated['metadata'] = body.metadata; } - - const response = await this.chromaClient.collection.update(updated) - - return { - message: `Successfully updated ${chromaID}` - } - - } catch (e) { - return { - message: `Update error for ${chromaID}` - } - } - - } - - - /** - * @description Deletes the document from ChromaDB with the given indexId and indexItemId - * - * @param body - * @returns Success or error message - */ - async delete(indexId: string, indexItemId: string | null): Promise<{ message: string }> { - - let response; - - const chromaID = await this.generateChromaID(indexId, indexItemId); - - try { - - if (indexItemId) { - - const res = await this.chromaClient.collection.get({ - ids: [chromaID], - limit: 1, - }) - - if (res.ids.length === 0) Logger.warn('Delete failed, document not found', 'indexerService:delete'); - - const response = await this.chromaClient.collection.delete({ ids: [chromaID] }) - - Logger.debug(`Delete Response ${JSON.stringify(response)}`, 'indexerService:delete'); - - // if (!response) throw new Error('Delete failed'); - - return { - message: `Successfully deleted ${JSON.stringify(response)}` - } - - } else { - - const res = await this.chromaClient.collection.get({ - where: { "indexId": indexId }, - limit: 1000, - }) - - Logger.log(`Deleting ${JSON.stringify(res?.ids)}`, 'indexerService:delete'); - - response = await this.chromaClient.collection.delete({ ids: res?.ids }) + } else { + const res = await this.chromaClient.collection.get({ + where: { indexId: indexId }, + limit: 1000, + }); - if (!response) Logger.warn(`Delete failed for ${res?.ids}`, 'indexerService:delete'); + Logger.log( + `Deleting ${JSON.stringify(res?.ids)}`, + 'indexerService:delete', + ); - return { - message: `Successfully deleted ${response.ids.length} documents` - } + response = await this.chromaClient.collection.delete({ ids: res?.ids }); - } + if (!response) + Logger.warn(`Delete failed for ${res?.ids}`, 'indexerService:delete'); - } catch (e) { - return { - message: `Delete error for ${indexId}` - } - } + return { + message: `Successfully deleted ${response.ids.length} documents`, + }; + } + } catch (e) { + return { + message: `Delete error for ${indexId}`, + }; } - - /** - * @description Embed a web page into ChromaDB - * - * @param content - * @returns Embedding vector - */ - async embed(content: string | null): Promise<{ model: string; vector: number[]; } | HttpStatus.OK> { - - // If no content, return OK - // This is a temporary fix for the API for now - if (!content) return HttpStatus.OK; - - try { - - const embeddings = new OpenAIEmbeddings({ - modelName: process.env.MODEL_EMBEDDING, - openAIApiKey:process.env.OPENAI_API_KEY - }); - - Logger.log(`Creates embedding ${content.length} bytes of content`, 'indexerService:embed'); - - const embedding = await embeddings.embedDocuments([content]); - - Logger.log(`Embedded successfully, with embed length ${embedding.length}`, 'indexerService:embed'); - - return { - model: process.env.MODEL_EMBEDDING, - vector: embedding[0] - }; - } - catch (e) { - console.log(e.message); - } - + } + + /** + * @description Embed a web page into ChromaDB + * + * @param content + * @returns Embedding vector + */ + async embed( + content: string | null, + ): Promise<{ model: string; vector: number[] } | HttpStatus.OK> { + // If no content, return OK + // This is a temporary fix for the API for now + if (!content) return HttpStatus.OK; + + try { + const embeddings = new OpenAIEmbeddings({ + modelName: process.env.MODEL_EMBEDDING, + openAIApiKey: process.env.OPENAI_API_KEY, + }); + + Logger.log( + `Creates embedding ${content.length} bytes of content`, + 'indexerService:embed', + ); + + const embedding = await embeddings.embedDocuments([content]); + + Logger.log( + `Embedded successfully, with embed length ${embedding.length}`, + 'indexerService:embed', + ); + + return { + model: process.env.MODEL_EMBEDDING, + vector: embedding[0], + }; + } catch (e) { + console.log(e.message); } + } - private async generateChromaID(indexId: string, body: any): Promise { - - // fix id generation - const randseq = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); - - return indexId + '-' + randseq; - } + private async generateChromaID(indexId: string, body: any): Promise { + // fix id generation + const randseq = + Math.random().toString(36).substring(2, 15) + + Math.random().toString(36).substring(2, 15); + return indexId + '-' + randseq; + } } diff --git a/sdk/python/indexclient/client.py b/sdk/python/indexclient/client.py index 3f818680..569435e4 100644 --- a/sdk/python/indexclient/client.py +++ b/sdk/python/indexclient/client.py @@ -147,19 +147,13 @@ def chat(self, id, sources, messages): decoded_line = line.decode('utf-8') yield decoded_line - def add_item_to_index(self, index_id, item_id): - return self._request(f"/indexes/{index_id}/items/{item_id}", "POST") - - def delete_item_from_index(self, index_id, item_id): - return self._request(f"/indexes/{index_id}/items/{item_id}", "DELETE") - def get_ens_name_details(self, ens_name): return self._request(f"/ens/{ens_name}", "GET") - def create_item(self, index_id, item): - return self._request(f"/indexes/{index_id}/items", "POST", item) + def add_item(self, index_id, item): + return self._request(f"/indexes/{index_id}/items/{item_id}", "POST") - def delete_item(self, index_id, item_id): + def remove_item(self, index_id, item_id): return self._request(f"/indexes/{index_id}/items/{item_id}", "DELETE") def star_index(self, did, index_id): diff --git a/web-app/src/components/base/TextArea/index.tsx b/web-app/src/components/base/TextArea/index.tsx index 06a3038a..24adc8b5 100644 --- a/web-app/src/components/base/TextArea/index.tsx +++ b/web-app/src/components/base/TextArea/index.tsx @@ -71,6 +71,10 @@ const TextArea = forwardRef< disabled={disabled} readOnly={readOnly} rows={rows} + style={{ + width: "100%", + overflow: "auto", + }} className={"textarea__textarea"} /> {type === "password" ? renderVisible : addOnAfter} diff --git a/web-app/src/components/sections/AppLeft.tsx b/web-app/src/components/sections/AppLeft.tsx index cdee9cdd..e372a656 100644 --- a/web-app/src/components/sections/AppLeft.tsx +++ b/web-app/src/components/sections/AppLeft.tsx @@ -1,4 +1,5 @@ import { useApp } from "@/context/AppContext"; +import Freizeit from "@/fonts/loader"; import cc from "classcat"; import Avatar from "components/base/Avatar"; import Button from "components/base/Button"; @@ -49,7 +50,10 @@ const AppLeft = () => { <> -
+
{ /* eslint-disable */ viewedProfile?.name || diff --git a/web-app/src/components/sections/IndexConversation/TabContainer/IndexItemsTab.tsx b/web-app/src/components/sections/IndexConversation/TabContainer/IndexItemsTab.tsx index 8a7a20a6..47fa6bed 100644 --- a/web-app/src/components/sections/IndexConversation/TabContainer/IndexItemsTab.tsx +++ b/web-app/src/components/sections/IndexConversation/TabContainer/IndexItemsTab.tsx @@ -171,18 +171,20 @@ export default function IndexItemsTabSection() { return ( - - - - - + {itemsState.items.length > 0 && ( + + + + + + )} {isCreator && ( diff --git a/web-app/src/components/site/index-details/DefaultIndexItem/index.tsx b/web-app/src/components/site/index-details/DefaultIndexItem/index.tsx index d172a3b1..59d90dab 100644 --- a/web-app/src/components/site/index-details/DefaultIndexItem/index.tsx +++ b/web-app/src/components/site/index-details/DefaultIndexItem/index.tsx @@ -1,4 +1,5 @@ import Freizeit from "@/fonts/loader"; +import { shortStr } from "@/utils/helper"; import Button from "components/base/Button"; import IconContextMenu from "components/base/Icon/IconContextMenu"; import Text from "components/base/Text"; @@ -59,7 +60,7 @@ const DefaultIndexItem: React.FC = ({ }} fontWeight={700} dangerouslySetInnerHTML={{ - __html: sanitize(node?.id as string), + __html: sanitize(shortStr(node?.id)), }} > diff --git a/web-app/src/components/site/index-details/IndexIndexItem/index.tsx b/web-app/src/components/site/index-details/IndexIndexItem/index.tsx index eb299989..1d663d9a 100644 --- a/web-app/src/components/site/index-details/IndexIndexItem/index.tsx +++ b/web-app/src/components/site/index-details/IndexIndexItem/index.tsx @@ -1,4 +1,5 @@ import Freizeit from "@/fonts/loader"; +import { shortStr } from "@/utils/helper"; import Button from "components/base/Button"; import IconContextMenu from "components/base/Icon/IconContextMenu"; import Text from "components/base/Text"; @@ -64,7 +65,7 @@ const IndexIndexItem: React.FC = ({ }} fontWeight={700} dangerouslySetInnerHTML={{ - __html: sanitize(node?.title as string), + __html: sanitize(shortStr(node?.title)), }} > {/* dangerouslySetInnerHTML={{ __html: sanitize((node.highlight && item.highlight["link.title"]) ? item.highlight["link.title"] : node?.title as string) }}> */} diff --git a/web-app/src/components/site/index-details/LinkItem/index.tsx b/web-app/src/components/site/index-details/LinkItem/index.tsx index 3ddd58c2..b092ad41 100644 --- a/web-app/src/components/site/index-details/LinkItem/index.tsx +++ b/web-app/src/components/site/index-details/LinkItem/index.tsx @@ -1,4 +1,5 @@ import Freizeit from "@/fonts/loader"; +import { shortStr } from "@/utils/helper"; import Button from "components/base/Button"; import IconContextMenu from "components/base/Icon/IconContextMenu"; import Text from "components/base/Text"; @@ -45,7 +46,7 @@ const LinkItem: React.FC = ({ }} fontWeight={700} dangerouslySetInnerHTML={{ - __html: sanitize(node?.title as string), + __html: sanitize(shortStr(node?.title, 50)), }} > {/* dangerouslySetInnerHTML={{ __html: sanitize((node.highlight && item.highlight["link.title"]) ? item.highlight["link.title"] : node?.title as string) }}> */} @@ -98,7 +99,7 @@ const LinkItem: React.FC = ({ }} /> - {node?.url?.substring(0, 80)} •{" "} + {shortStr(node?.title, 60)} •{" "} {node?.updatedAt ? `Updated ${moment(new Date(node.updatedAt)).fromNow()}` : ""} diff --git a/web-app/src/components/site/index-details/TeamItem/index.tsx b/web-app/src/components/site/index-details/TeamItem/index.tsx index 90721005..810cc212 100644 --- a/web-app/src/components/site/index-details/TeamItem/index.tsx +++ b/web-app/src/components/site/index-details/TeamItem/index.tsx @@ -1,4 +1,5 @@ import Freizeit from "@/fonts/loader"; +import { shortStr } from "@/utils/helper"; import Button from "components/base/Button"; import IconContextMenu from "components/base/Icon/IconContextMenu"; import Text from "components/base/Text"; @@ -44,7 +45,7 @@ const TeamItem: React.FC = ({ }} fontWeight={700} dangerouslySetInnerHTML={{ - __html: sanitize(node?.name as string), + __html: sanitize(shortStr(node?.name)), }} > {/* dangerouslySetInnerHTML={{ __html: sanitize((node.highlight && item.highlight["link.title"]) ? item.highlight["link.title"] : node?.title as string) }}> */} diff --git a/web-app/src/components/site/indexes/Soon/index.tsx b/web-app/src/components/site/indexes/Soon/index.tsx index 2730d9e0..0ec77915 100644 --- a/web-app/src/components/site/indexes/Soon/index.tsx +++ b/web-app/src/components/site/indexes/Soon/index.tsx @@ -1,44 +1,66 @@ +import Freizeit from "@/fonts/loader"; import Header from "components/base/Header"; import Col from "components/layout/base/Grid/Col"; import Row from "components/layout/base/Grid/Row"; import React from "react"; export interface SoonProps { - section?: string; + section?: string; } let text: String; -const Soon: React.VFC = ({ - section, -}) => { - if (section === "access_control") { - text = `This section will allow you to control access to your index using access rules based on NFTs.`; - } else if (section === "ask") { - text = `This section will soon allow you to interact with your index through the LLM algorithms you choose.`; - } else if (section === "chat_history") { - text = `Your chat history will be here soon, with complete privacy.`; - } - return ( - <> - - - { - section === "ask" ? tabsoon : tabsoon - } - - - -
{text}
- -
- - ); +const Soon: React.VFC = ({ section }) => { + if (section === "access_control") { + text = `This section will allow you to control access to your index using access rules based on NFTs.`; + } else if (section === "ask") { + text = `This section will soon allow you to interact with your index through the LLM algorithms you choose.`; + } else if (section === "chat_history") { + text = `Your chat history will be here soon, with complete privacy.`; + } + return ( + <> + + + {section === "ask" ? ( + tabsoon + ) : ( + tabsoon + )} + + +
+ {text} +
+ +
+ + ); }; export default Soon; diff --git a/web-app/src/components/site/input/HeaderInput/index.tsx b/web-app/src/components/site/input/HeaderInput/index.tsx index a5b1d1d8..1d4526a8 100644 --- a/web-app/src/components/site/input/HeaderInput/index.tsx +++ b/web-app/src/components/site/input/HeaderInput/index.tsx @@ -1,22 +1,33 @@ +import Freizeit from "@/fonts/loader"; +import cc from "classcat"; import Input, { InputProps } from "components/base/Input"; +import Spin from "components/base/Spin"; import React from "react"; import { HeaderSizeType } from "types"; -import cc from "classcat"; -import Spin from "components/base/Spin"; export interface HeaderInputProps extends InputProps { - size?: HeaderSizeType; - loading?: boolean; + size?: HeaderSizeType; + loading?: boolean; } -const HeaderInput: React.VFC = ({ size = 3, loading, ...inputProps }) => )} - className={cc([ - "header-input", - "nonstyled", - `header-input-${size}`, - ])} - {...inputProps} />; +const HeaderInput: React.VFC = ({ + size = 3, + loading, + ...inputProps +}) => ( + + } + className={cc([ + Freizeit.className, + "header-input", + "nonstyled", + `header-input-${size}`, + ])} + {...inputProps} + /> +); export default HeaderInput; diff --git a/web-app/src/components/site/input/LinkInput/index.tsx b/web-app/src/components/site/input/LinkInput/index.tsx index 4be3e7fb..a1562900 100644 --- a/web-app/src/components/site/input/LinkInput/index.tsx +++ b/web-app/src/components/site/input/LinkInput/index.tsx @@ -1,5 +1,5 @@ import Input, { InputProps } from "components/base/Input"; -import React, { useState } from "react"; +import React, { useEffect, useMemo, useState } from "react"; import { HeaderSizeType } from "types"; import cc from "classcat"; import IconAdd from "components/base/Icon/IconAdd"; @@ -134,7 +134,18 @@ const LinkInput: React.FC = ({ }) => { const [url, setUrl] = useState(""); const [showMsg, setShowMsg] = useState(false); - const [showPopover, setShowPopover] = useState(true); + const [showPopover, setShowPopover] = useState(false); + + const isPopoverShowed = useMemo(() => { + return localStorage.getItem("popoverShowed") === "true"; + }, []); + + useEffect(() => { + if (!isPopoverShowed) { + localStorage.setItem("popoverShowed", "true"); + setShowPopover(true); + } + }, []); const handleAdd = () => { if (url) { diff --git a/web-app/src/components/site/modal/Common/ConfirmTransaction/index.tsx b/web-app/src/components/site/modal/Common/ConfirmTransaction/index.tsx index 691109ab..2df3d753 100644 --- a/web-app/src/components/site/modal/Common/ConfirmTransaction/index.tsx +++ b/web-app/src/components/site/modal/Common/ConfirmTransaction/index.tsx @@ -1,8 +1,9 @@ -import Text from "components/base/Text"; -import Modal from "components/base/Modal"; -import Row from "components/layout/base/Grid/Row"; +import Freizeit from "@/fonts/loader"; import Header from "components/base/Header"; +import Modal from "components/base/Modal"; +import Text from "components/base/Text"; import Flex from "components/layout/base/Grid/Flex"; +import Row from "components/layout/base/Grid/Row"; const ConfirmTransaction = ({ handleCancel, @@ -45,7 +46,9 @@ const ConfirmTransaction = ({ } header={ <> -
Waiting for network confirmation
+
+ Waiting for network confirmation +
Please wait for a few seconds. diff --git a/web-app/src/utils/helper.ts b/web-app/src/utils/helper.ts index 36db4e02..5af1572a 100644 --- a/web-app/src/utils/helper.ts +++ b/web-app/src/utils/helper.ts @@ -116,3 +116,11 @@ export const isStreamID = (value: string) => { return false; } }; + +export const shortStr = (str: string, maxLen: number = 80) => { + if (str.length > maxLen) { + return `${str.substring(0, maxLen)}...`; + } + + return str; +};