@etherspot/remote-signer
Version:
Etherspot Permissioned Signer SDK - signs the UserOp with SessionKey and sends it to the Bundler
68 lines (65 loc) • 2.43 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/sdk/session-keys/get-session-key.ts
var get_session_key_exports = {};
__export(get_session_key_exports, {
getSessionKey: () => getSessionKey
});
module.exports = __toCommonJS(get_session_key_exports);
// src/sdk/common/constants.ts
var PERMISSIONS_URL = "https://qa-permissions.etherspot.io";
// 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);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getSessionKey
});
//# sourceMappingURL=get-session-key.js.map