@lighthouse-web3/sdk
Version:
NPM package and CLI tool to interact with lighthouse protocol
30 lines (29 loc) • 980 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lighthouse_config_1 = require("../../lighthouse.config");
exports.default = async (publicKey, signedMessage) => {
try {
const response = await fetch(lighthouse_config_1.lighthouseConfig.lighthouseAPI + `/api/auth/create_api_key`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
publicKey: publicKey,
signedMessage: signedMessage,
}),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const apiKey = (await response.json());
/*
return:
{ data: { apiKey: '489a497e-4e0c-4cb5-9522-ca07740f6dfb' } }
*/
return { data: { apiKey } };
}
catch (error) {
throw new Error(error.response.data);
}
};