UNPKG

everything-dev

Version:

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

42 lines (40 loc) • 1.49 kB
import { getRegistryNamespaceForAccount } from "../registry/fastkv.mjs"; import { getNetworkIdForAccount } from "../../utils/network.mjs"; import { addFunctionCallAccessKey, ensureNearCli, listPublishKeys } from "./near-cli.mjs"; import { Effect } from "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.runPromise(ensureNearCli); const network = getNetworkIdForAccount(input.account); const contract = getRegistryNamespaceForAccount(input.account, input.registry); const functionNames = input.functionNames ?? PUBLISH_FUNCTION_NAMES; const oldKeys = await listPublishKeys({ account: input.account, contract, network }); return { keyPair: await addFunctionCallAccessKey({ account: input.account, contract, allowance: input.allowance ?? "1NEAR", functionNames, network }), network, contract, oldKeys }; } //#endregion export { PUBLISH_FUNCTION_NAMES, mintPublishKey }; //# sourceMappingURL=publish-key.mjs.map