@etherspot/remote-signer
Version:
Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler
1 lines • 2.4 kB
Source Map (JSON)
{"version":3,"sources":["../../src/sdk/session-keys/get-session-key.ts"],"sourcesContent":["import { PERMISSIONS_URL } from \"../common/constants\";\nimport { GetSessionKeyResponse } from \"../types/session-key-types\";\n\nexport const getSessionKey = async(\n accountAddress: string,\n chainId: number,\n apiKey: string,\n sessionKey: string\n): Promise<GetSessionKeyResponse> => {\n let response;\n\n if (!accountAddress) {\n throw new Error('Failed to lookup SessionKey in Backend - Account address is required');\n }\n\n if (!chainId) {\n throw new Error('Failed to lookup SessionKey in Backend - Chain ID is required');\n }\n\n if (!apiKey) {\n throw new Error('Failed to lookup SessionKey in Backend - API Key is required');\n }\n\n if (!sessionKey) {\n throw new Error('Failed to lookup SessionKey in Backend - Session Key is required');\n }\n\n try {\n let url = `${PERMISSIONS_URL}/account/getSessionKey?account=${accountAddress}&chainId=${chainId}&apiKey=${apiKey}&sessionKey=${sessionKey}`;\n\n response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status === 200) {\n const responseJson: GetSessionKeyResponse = await response.json();\n return responseJson\n } else {\n const responseJson = await response.json();\n throw new Error(responseJson.message)\n }\n } catch (err) {\n throw new Error(err.message)\n }\n}\n"],"mappings":";;;;;AAGO,IAAM,gBAAgB,OACzB,gBACA,SACA,QACA,eACiC;AACjC,MAAI;AAEJ,MAAI,CAAC,gBAAgB;AACjB,UAAM,IAAI,MAAM,sEAAsE;AAAA,EAC1F;AAEA,MAAI,CAAC,SAAS;AACV,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACnF;AAEA,MAAI,CAAC,QAAQ;AACT,UAAM,IAAI,MAAM,8DAA8D;AAAA,EAClF;AAEA,MAAI,CAAC,YAAY;AACb,UAAM,IAAI,MAAM,kEAAkE;AAAA,EACtF;AAEA,MAAI;AACA,QAAI,MAAM,GAAG,eAAe,kCAAkC,cAAc,YAAY,OAAO,WAAW,MAAM,eAAe,UAAU;AAEzI,eAAW,MAAM,MAAM,KAAK;AAAA,MACxB,QAAQ;AAAA,MACR,SAAS;AAAA,QACL,UAAU;AAAA,QACV,gBAAgB;AAAA,MACpB;AAAA,IACJ,CAAC;AAED,QAAI,SAAS,WAAW,KAAK;AACzB,YAAM,eAAsC,MAAM,SAAS,KAAK;AAChE,aAAO;AAAA,IACX,OAAO;AACH,YAAM,eAAe,MAAM,SAAS,KAAK;AACzC,YAAM,IAAI,MAAM,aAAa,OAAO;AAAA,IACxC;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,IAAI,MAAM,IAAI,OAAO;AAAA,EAC/B;AACJ;","names":[]}