everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 2.38 kB
Source Map (JSON)
{"version":3,"file":"publish-key.cjs","names":["Effect","ensureNearCli","getNetworkIdForAccount","getRegistryNamespaceForAccount","listPublishKeys","addFunctionCallAccessKey"],"sources":["../../../src/services/auth/publish-key.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { getNetworkIdForAccount } from \"../../utils/network\";\nimport { getRegistryNamespaceForAccount } from \"../registry/fastkv\";\nimport { addFunctionCallAccessKey, ensureNearCli, listPublishKeys } from \"./near-cli\";\n\n/** The FC methods a publish key is scoped to. */\nexport const PUBLISH_FUNCTION_NAMES = [\"__fastdata_kv\"];\n\n/**\n * The publish-key mint behind `bos login --key`'s export (ticket #423):\n * ensure the near CLI, resolve the network + registry\n * namespace, list any existing publish keys, and add a scoped function-call\n * key. Callers decide what to do with the listing and the key material.\n */\nexport async function mintPublishKey(input: {\n account: string;\n registry?: string;\n allowance?: string;\n functionNames?: string[];\n}): Promise<{\n keyPair: { publicKey: string; privateKey: string };\n network: \"mainnet\" | \"testnet\";\n contract: string;\n oldKeys: string[];\n}> {\n if (!input.account) {\n throw new Error(\"the authored config has no account to export a publish key for\");\n }\n\n await Effect.runPromise(ensureNearCli);\n\n const network = getNetworkIdForAccount(input.account);\n const contract = getRegistryNamespaceForAccount(input.account, input.registry);\n const functionNames = input.functionNames ?? PUBLISH_FUNCTION_NAMES;\n const oldKeys = await listPublishKeys({ account: input.account, contract, network });\n\n const keyPair = await addFunctionCallAccessKey({\n account: input.account,\n contract,\n allowance: input.allowance ?? \"1NEAR\",\n functionNames,\n network,\n });\n\n return { keyPair, network, contract, oldKeys };\n}\n"],"mappings":";;;;;;;AAMA,MAAa,yBAAyB,CAAC,eAAe;;;;;;;AAQtD,eAAsB,eAAe,OAUlC;CACD,IAAI,CAAC,MAAM,SACT,MAAM,IAAI,MAAM,gEAAgE;CAGlF,MAAMA,cAAO,WAAWC,8BAAa;CAErC,MAAM,UAAUC,uCAAuB,MAAM,OAAO;CACpD,MAAM,WAAWC,gEAA+B,MAAM,SAAS,MAAM,QAAQ;CAC7E,MAAM,gBAAgB,MAAM,iBAAiB;CAC7C,MAAM,UAAU,MAAMC,iCAAgB;EAAE,SAAS,MAAM;EAAS;EAAU;CAAQ,CAAC;CAUnF,OAAO;EAAE,eARaC,0CAAyB;GAC7C,SAAS,MAAM;GACf;GACA,WAAW,MAAM,aAAa;GAC9B;GACA;EACF,CAAC;EAEiB;EAAS;EAAU;CAAQ;AAC/C"}