UNPKG

@lighthouse-web3/sdk

Version:

NPM package and CLI tool to interact with lighthouse protocol

31 lines (30 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lighthouse_config_1 = require("../../lighthouse.config"); exports.default = async (apiKey) => { try { const response = await fetch(lighthouse_config_1.lighthouseConfig.lighthouseAPI + `/api/ipns/generate_key`, { headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json', // Ensure headers are set for JSON }, }); if (!response.ok) { throw new Error(`Request failed with status code ${response.status}`); } const key = (await response.json()); /* return: { data: { "ipnsName": "6cda213e3a534f8388665dee77a26458", "ipnsId": "k51qzi5uqu5dm6uvby6428rfpcv1vcba6hxq6vcu52qtfsx3np4536jkr71gnu" } } */ return { data: key }; } catch (error) { throw new Error(error.message); } };