UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

43 lines (41 loc) • 1.6 kB
const require_services_registry_fastkv = require('../registry/fastkv.cjs'); const require_network = require('../../utils/network.cjs'); const require_near_cli = require('./near-cli.cjs'); let effect = require("effect"); //#region src/services/auth/publish-key.ts /** The FC methods a publish key is scoped to. */ const PUBLISH_FUNCTION_NAMES = ["__fastdata_kv"]; /** * The publish-key mint behind `bos login --key`'s export (ticket #423): * ensure the near CLI, resolve the network + registry * namespace, list any existing publish keys, and add a scoped function-call * key. Callers decide what to do with the listing and the key material. */ async function mintPublishKey(input) { if (!input.account) throw new Error("the authored config has no account to export a publish key for"); await effect.Effect.runPromise(require_near_cli.ensureNearCli); const network = require_network.getNetworkIdForAccount(input.account); const contract = require_services_registry_fastkv.getRegistryNamespaceForAccount(input.account, input.registry); const functionNames = input.functionNames ?? PUBLISH_FUNCTION_NAMES; const oldKeys = await require_near_cli.listPublishKeys({ account: input.account, contract, network }); return { keyPair: await require_near_cli.addFunctionCallAccessKey({ account: input.account, contract, allowance: input.allowance ?? "1NEAR", functionNames, network }), network, contract, oldKeys }; } //#endregion exports.PUBLISH_FUNCTION_NAMES = PUBLISH_FUNCTION_NAMES; exports.mintPublishKey = mintPublishKey; //# sourceMappingURL=publish-key.cjs.map