@etherspot/remote-signer
Version:
Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler
44 lines (42 loc) • 1.32 kB
JavaScript
import {
PERMISSIONS_URL
} from "./chunk-FIVOBZYI.mjs";
// src/sdk/session-keys/get-session-key.ts
var getSessionKey = async (accountAddress, chainId, apiKey, sessionKey) => {
let response;
if (!accountAddress) {
throw new Error("Failed to lookup SessionKey in Backend - Account address is required");
}
if (!chainId) {
throw new Error("Failed to lookup SessionKey in Backend - Chain ID is required");
}
if (!apiKey) {
throw new Error("Failed to lookup SessionKey in Backend - API Key is required");
}
if (!sessionKey) {
throw new Error("Failed to lookup SessionKey in Backend - Session Key is required");
}
try {
let url = `${PERMISSIONS_URL}/account/getSessionKey?account=${accountAddress}&chainId=${chainId}&apiKey=${apiKey}&sessionKey=${sessionKey}`;
response = await fetch(url, {
method: "GET",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
}
});
if (response.status === 200) {
const responseJson = await response.json();
return responseJson;
} else {
const responseJson = await response.json();
throw new Error(responseJson.message);
}
} catch (err) {
throw new Error(err.message);
}
};
export {
getSessionKey
};
//# sourceMappingURL=chunk-YBGMLW7N.mjs.map