UNPKG

@etherspot/remote-signer

Version:

Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler

1 lines 2.08 kB
{"version":3,"sources":["../../src/sdk/session-keys/validate-session-key.ts"],"sourcesContent":["import { PublicClient } from \"viem\";\nimport { GetSessionKeyResponse } from \"../types/session-key-types\";\nimport { getSessionKey } from \"./get-session-key\";\nimport { isSessionKeyLiveOnChain } from \"./erc20-sessionkey-onchain\";\n\nexport const isAValidSessionKey = async(\n publicClient: PublicClient, \n sesssionKeyValidatorAddress: string,\n etherspotWalletAddress: string, \n chainId: number, \n apiKey: string, \n sessionKey: string): Promise<boolean> => {\n\n // get sessionKey from apiKey and account (from remote secure storage)\n const sessionKeyResponse: GetSessionKeyResponse = await getSessionKey(etherspotWalletAddress, chainId, apiKey, sessionKey);\n\n if (!sessionKeyResponse || !sessionKeyResponse.sessionKey || sessionKeyResponse.sessionKey == '') {\n console.log(`Sessionkey: ${sessionKey} not found for etherspotWalletAddress: ${etherspotWalletAddress} and apiKey: ${apiKey} on chainId: ${chainId}`);\n return false;\n }\n\n // check if sessionKey is live onchain (sessionKeyValidator contract)\n const isLiveOnChain = await isSessionKeyLiveOnChain(\n etherspotWalletAddress,\n publicClient,\n sesssionKeyValidatorAddress,\n sessionKeyResponse.sessionKey); \n\n if(!isLiveOnChain) {\n console.warn(`Sessionkey: ${sessionKey} is not live for etherspotWalletAddress: ${etherspotWalletAddress} and apiKey: ${apiKey\n } on chainId: ${chainId}`);\n return false;\n }\n\n return true;\n }\n"],"mappings":";;;;;;;;AAKO,IAAM,qBAAqB,OAChC,cACA,6BACA,wBACA,SACA,QACA,eAAyC;AAGvC,QAAM,qBAA4C,MAAM,cAAc,wBAAwB,SAAS,QAAQ,UAAU;AAEzH,MAAI,CAAC,sBAAsB,CAAC,mBAAmB,cAAc,mBAAmB,cAAc,IAAI;AAChG,YAAQ,IAAI,eAAe,UAAU,0CAA0C,sBAAsB,gBAAgB,MAAM,gBAAgB,OAAO,EAAE;AACpJ,WAAO;AAAA,EACT;AAGA,QAAM,gBAAgB,MAAM;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB;AAAA,EAAU;AAE/B,MAAG,CAAC,eAAe;AACjB,YAAQ,KAAK,eAAe,UAAU,4CAA4C,sBAAsB,gBAAgB,MACxH,gBAAgB,OAAO,EAAE;AACzB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}