@provablehq/sdk 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/mainnet/account.d.ts +36 -1
  2. package/dist/mainnet/browser.d.ts +35 -35
  3. package/dist/mainnet/browser.js +52 -4
  4. package/dist/mainnet/browser.js.map +1 -1
  5. package/dist/mainnet/constants.d.ts +1 -1
  6. package/dist/mainnet/function-key-provider.d.ts +2 -2
  7. package/dist/mainnet/managed-worker.d.ts +1 -1
  8. package/dist/mainnet/models/authorization.d.ts +6 -0
  9. package/dist/mainnet/models/blockJSON.d.ts +3 -3
  10. package/dist/mainnet/models/confirmed_transaction.d.ts +2 -2
  11. package/dist/mainnet/models/deployment/deploymentObject.d.ts +1 -1
  12. package/dist/mainnet/models/execution/executionJSON.d.ts +1 -1
  13. package/dist/mainnet/models/execution/executionObject.d.ts +1 -1
  14. package/dist/mainnet/models/functionObject.d.ts +1 -1
  15. package/dist/mainnet/models/input/inputObject.d.ts +2 -2
  16. package/dist/mainnet/models/inputID.d.ts +4 -0
  17. package/dist/mainnet/models/output/outputObject.d.ts +2 -2
  18. package/dist/mainnet/models/owner/ownerObject.d.ts +1 -1
  19. package/dist/mainnet/models/plaintext/array.d.ts +2 -2
  20. package/dist/mainnet/models/plaintext/plaintext.d.ts +4 -4
  21. package/dist/mainnet/models/plaintext/struct.d.ts +2 -2
  22. package/dist/mainnet/models/request.d.ts +14 -0
  23. package/dist/mainnet/models/transaction/transactionJSON.d.ts +3 -3
  24. package/dist/mainnet/models/transaction/transactionObject.d.ts +3 -3
  25. package/dist/mainnet/models/transition/transitionJSON.d.ts +2 -2
  26. package/dist/mainnet/models/transition/transitionObject.d.ts +3 -3
  27. package/dist/mainnet/network-client.d.ts +5 -19
  28. package/dist/mainnet/node-polyfill.d.ts +5 -5
  29. package/dist/mainnet/node-polyfill.js.map +1 -1
  30. package/dist/mainnet/node.d.ts +2 -2
  31. package/dist/mainnet/node.js +2 -2
  32. package/dist/mainnet/offline-key-provider.d.ts +2 -2
  33. package/dist/mainnet/{program-manager-DMDKstZ8.js → program-manager-BfZnPCKl.js} +119 -18
  34. package/dist/mainnet/program-manager-BfZnPCKl.js.map +1 -0
  35. package/dist/mainnet/program-manager.d.ts +105 -9
  36. package/dist/mainnet/record-provider.d.ts +3 -3
  37. package/dist/mainnet/wasm.d.ts +1 -1
  38. package/dist/mainnet/worker.d.ts +2 -2
  39. package/dist/mainnet/worker.js +1 -1
  40. package/dist/mainnet/worker.js.map +1 -1
  41. package/dist/testnet/account.d.ts +36 -1
  42. package/dist/testnet/browser.d.ts +35 -35
  43. package/dist/testnet/browser.js +52 -4
  44. package/dist/testnet/browser.js.map +1 -1
  45. package/dist/testnet/constants.d.ts +1 -1
  46. package/dist/testnet/function-key-provider.d.ts +2 -2
  47. package/dist/testnet/managed-worker.d.ts +1 -1
  48. package/dist/testnet/models/authorization.d.ts +6 -0
  49. package/dist/testnet/models/blockJSON.d.ts +3 -3
  50. package/dist/testnet/models/confirmed_transaction.d.ts +2 -2
  51. package/dist/testnet/models/deployment/deploymentObject.d.ts +1 -1
  52. package/dist/testnet/models/execution/executionJSON.d.ts +1 -1
  53. package/dist/testnet/models/execution/executionObject.d.ts +1 -1
  54. package/dist/testnet/models/functionObject.d.ts +1 -1
  55. package/dist/testnet/models/input/inputObject.d.ts +2 -2
  56. package/dist/testnet/models/inputID.d.ts +4 -0
  57. package/dist/testnet/models/output/outputObject.d.ts +2 -2
  58. package/dist/testnet/models/owner/ownerObject.d.ts +1 -1
  59. package/dist/testnet/models/plaintext/array.d.ts +2 -2
  60. package/dist/testnet/models/plaintext/plaintext.d.ts +4 -4
  61. package/dist/testnet/models/plaintext/struct.d.ts +2 -2
  62. package/dist/testnet/models/request.d.ts +14 -0
  63. package/dist/testnet/models/transaction/transactionJSON.d.ts +3 -3
  64. package/dist/testnet/models/transaction/transactionObject.d.ts +3 -3
  65. package/dist/testnet/models/transition/transitionJSON.d.ts +2 -2
  66. package/dist/testnet/models/transition/transitionObject.d.ts +3 -3
  67. package/dist/testnet/network-client.d.ts +5 -19
  68. package/dist/testnet/node-polyfill.d.ts +5 -5
  69. package/dist/testnet/node-polyfill.js.map +1 -1
  70. package/dist/testnet/node.d.ts +2 -2
  71. package/dist/testnet/node.js +2 -2
  72. package/dist/testnet/offline-key-provider.d.ts +2 -2
  73. package/dist/testnet/{program-manager-BTHjM8b7.js → program-manager-kuhVcNPN.js} +119 -18
  74. package/dist/testnet/program-manager-kuhVcNPN.js.map +1 -0
  75. package/dist/testnet/program-manager.d.ts +105 -9
  76. package/dist/testnet/record-provider.d.ts +3 -3
  77. package/dist/testnet/wasm.d.ts +1 -1
  78. package/dist/testnet/worker.d.ts +2 -2
  79. package/dist/testnet/worker.js +1 -1
  80. package/dist/testnet/worker.js.map +1 -1
  81. package/package.json +2 -2
  82. package/dist/mainnet/program-manager-DMDKstZ8.js.map +0 -1
  83. package/dist/testnet/program-manager-BTHjM8b7.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { InputJSON } from "../input/inputJSON";
2
- import { OutputJSON } from "../output/outputJSON";
1
+ import { InputJSON } from "../input/inputJSON.js";
2
+ import { OutputJSON } from "../output/outputJSON.js";
3
3
  export interface TransitionJSON {
4
4
  id: string;
5
5
  program: string;
@@ -1,6 +1,6 @@
1
- import { InputObject } from "../input/inputObject";
2
- import { OutputObject } from "../output/outputObject";
3
- import { Field, Group } from "../../wasm";
1
+ import { InputObject } from "../input/inputObject.js";
2
+ import { OutputObject } from "../output/outputObject.js";
3
+ import { Field, Group } from "../../wasm.js";
4
4
  export interface TransitionObject {
5
5
  id: string;
6
6
  program: string;
@@ -1,8 +1,8 @@
1
- import { Account } from "./account";
2
- import { BlockJSON } from "./models/blockJSON";
3
- import { TransactionJSON } from "./models/transaction/transactionJSON";
4
- import { Address, Plaintext, Program, RecordPlaintext, PrivateKey, Transaction } from "./wasm";
5
- import { ConfirmedTransactionJSON } from "./models/confirmed_transaction";
1
+ import { Account } from "./account.js";
2
+ import { BlockJSON } from "./models/blockJSON.js";
3
+ import { TransactionJSON } from "./models/transaction/transactionJSON.js";
4
+ import { Address, Plaintext, Program, RecordPlaintext, PrivateKey, Transaction } from "./wasm.js";
5
+ import { ConfirmedTransactionJSON } from "./models/confirmed_transaction.js";
6
6
  type ProgramImports = {
7
7
  [key: string]: string | Program;
8
8
  };
@@ -86,20 +86,6 @@ declare class AleoNetworkClient {
86
86
  * networkClient.setHeader('Accept-Language', 'en-US');
87
87
  */
88
88
  setHeader(headerName: string, value: string): void;
89
- /**
90
- * Remove a header from the `AleoNetworkClient`s header map
91
- *
92
- * @param {string} headerName The name of the header to be removed
93
- *
94
- * @example
95
- * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
96
- *
97
- * // Create a networkClient
98
- * const networkClient = new AleoNetworkClient();
99
- *
100
- * // Remove the default `X-Aleo-SDK-Version` header
101
- * networkClient.removeHeader('X-Aleo-SDK-Version');
102
- */
103
89
  removeHeader(headerName: string): void;
104
90
  /**
105
91
  * Fetches data from the Aleo network and returns it as a JSON object.
@@ -1,5 +1,5 @@
1
- import "./polyfill/shared";
2
- import "./polyfill/crypto";
3
- import "./polyfill/fetch";
4
- import "./polyfill/xmlhttprequest";
5
- import "./polyfill/worker";
1
+ import "./polyfill/shared.js";
2
+ import "./polyfill/crypto.js";
3
+ import "./polyfill/fetch.js";
4
+ import "./polyfill/xmlhttprequest.js";
5
+ import "./polyfill/worker.js";
@@ -1 +1 @@
1
- {"version":3,"file":"node-polyfill.js","sources":["../../src/polyfill/crypto.ts","../../src/polyfill/fetch.ts","../../src/polyfill/xmlhttprequest.ts","../../src/polyfill/worker.ts","../../src/node-polyfill.ts"],"sourcesContent":["import { webcrypto } from \"node:crypto\";\n\nif ((globalThis as any).crypto == null) {\n (globalThis as any).crypto = webcrypto;\n}\n","import * as $fs from \"node:fs\";\nimport $mime from \"mime/lite\";\n\n\nconst oldFetch = globalThis.fetch;\n\n\nlet supports: Promise<boolean> | null = null;\n\nasync function checkFetch() {\n try {\n await oldFetch(new URL(\"file:\"));\n return true;\n\n } catch (e) {\n return false;\n }\n}\n\nasync function supportsFetch(): Promise<boolean> {\n if (supports === null) {\n supports = checkFetch();\n }\n\n return await supports;\n}\n\n\n// We always polyfill fetch because Node's fetch doesn't support file URLs.\n(globalThis.fetch as any) = async function (resource: URL | RequestInfo, options: RequestInit | undefined): Promise<Response> {\n const request = new Request(resource, options);\n\n const url = new URL(request.url);\n\n if (!(await supportsFetch()) && url.protocol === \"file:\") {\n const readStream = $fs.createReadStream(url);\n\n const headers: HeadersInit = {};\n\n const type = $mime.getType(url.pathname);\n\n if (type) {\n headers[\"Content-Type\"] = type;\n }\n\n return new Response(readStream as any, {\n status: 200,\n statusText: \"OK\",\n headers,\n });\n\n } else {\n return await oldFetch(request);\n }\n};\n","// @ts-ignore\nimport $xmlhttprequest from \"xmlhttprequest-ssl\";\nimport $request from \"sync-request\";\n\nif (globalThis.XMLHttpRequest == null) {\n globalThis.XMLHttpRequest = class extends $xmlhttprequest.XMLHttpRequest {\n // We have to override the methods inside of the `constructor`\n // because `xmlhttprequest-ssl` doesn't use a regular class,\n // instead it defines all of the methods inside of the constructor.\n constructor(...args: Array<any>) {\n super(...args);\n\n const open = (this as any).open;\n const send = (this as any).send;\n\n let _async: boolean = true;\n let _url: null | string = null;\n let _mime: string = \"text/xml\";\n\n function reset() {\n _async = true;\n _url = null;\n _mime = \"text/xml\";\n }\n\n (this as any).open = function (method: string, url: string, async: boolean, user?: string, password?: string) {\n // Special behavior for synchronous requests\n if (method === \"GET\" && !async && !user && !password) {\n _async = false;\n _url = url;\n\n // Default to the normal polyfill for async requests\n } else {\n reset();\n return open.call(this, method, url, async, user, password);\n }\n };\n\n (this as any).send = function (data: any) {\n if (_async) {\n return send.call(this, data);\n\n // Use `sync-request` for synchronous requests.\n } else {\n const response = $request(\"GET\", _url!, {\n headers: {\n \"Content-Type\": _mime,\n }\n });\n\n const buffer = (response.body as Buffer).buffer as any;\n\n const responseText = new TextDecoder(\"iso-8859-5\", { fatal: true }).decode(buffer);\n\n (this as any).status = 200;\n (this as any).response = (this as any).responseText = responseText;\n\n reset();\n }\n };\n\n (this as any).overrideMimeType = function (mime: string) {\n _mime = mime;\n };\n }\n } as any;\n}\n","import * as $worker from \"node:worker_threads\";\nimport * as $os from \"node:os\";\n\n// This is technically not a part of the Worker polyfill,\n// but Workers are used for multi-threading, so this is often\n// needed when writing Worker code.\nif (globalThis.navigator == null) {\n globalThis.navigator = {\n hardwareConcurrency: $os.cpus().length,\n } as Navigator;\n}\n\nif (globalThis.Worker == null) {\n globalThis.Worker = class Worker extends EventTarget {\n private _worker: import(\"node:worker_threads\").Worker;\n\n constructor(url: string | URL, options?: WorkerOptions | undefined) {\n super();\n\n if (url instanceof URL) {\n if (url.protocol !== \"file:\") {\n throw new Error(\"Worker only supports file: URLs\");\n }\n\n url = url.href;\n\n } else {\n throw new Error(\"Filepaths are unreliable, use `new URL(\\\"...\\\", import.meta.url)` instead.\");\n }\n\n if (!options || options.type !== \"module\") {\n throw new Error(\"Workers must use \\`type: \\\"module\\\"\\`\");\n }\n\n const code = `\n import(\"node:worker_threads\")\n .then(({ workerData }) => {\n return import(workerData.polyfill)\n .then(() => import(workerData.url))\n })\n .catch((e) => {\n // TODO maybe it should send a message to the parent?\n console.error(e.stack);\n });\n `;\n\n this._worker = new $worker.Worker(code, {\n eval: true,\n workerData: {\n url,\n polyfill: new URL(\"node-polyfill.js\", import.meta.url).href,\n },\n });\n\n this._worker.on(\"message\", (data) => {\n this.dispatchEvent(new MessageEvent(\"message\", { data }));\n });\n\n this._worker.on(\"messageerror\", (error) => {\n throw new Error(\"UNIMPLEMENTED\");\n });\n\n this._worker.on(\"error\", (error) => {\n // TODO attach the error to the event somehow\n const event = new Event(\"error\");\n this.dispatchEvent(event);\n });\n }\n\n set onmessage(f: () => void) {\n throw new Error(\"UNIMPLEMENTED\");\n }\n\n set onmessageerror(f: () => void) {\n throw new Error(\"UNIMPLEMENTED\");\n }\n\n set onerror(f: () => void) {\n throw new Error(\"UNIMPLEMENTED\");\n }\n\n postMessage(message: any, transfer: Array<Transferable>): void;\n postMessage(message: any, options?: StructuredSerializeOptions | undefined): void;\n postMessage(value: any, transfer: any) {\n this._worker.postMessage(value, transfer);\n }\n\n terminate() {\n this._worker.terminate();\n }\n\n // This is Node-specific, it allows the process to exit\n // even if the Worker is still running.\n unref() {\n this._worker.unref();\n }\n };\n}\n\n\nif (!$worker.isMainThread) {\n const globals = globalThis as unknown as DedicatedWorkerGlobalScope;\n\n // This is used to create the onmessage, onmessageerror, and onerror setters\n const makeSetter = (prop: string, event: string) => {\n let oldvalue: () => void;\n\n Object.defineProperty(globals, prop, {\n get() {\n return oldvalue;\n },\n set(value) {\n if (oldvalue) {\n globals.removeEventListener(event, oldvalue);\n }\n\n oldvalue = value;\n\n if (oldvalue) {\n globals.addEventListener(event, oldvalue);\n }\n },\n });\n };\n\n // This makes sure that `f` is only run once\n const memoize = (f: () => void) => {\n let run = false;\n\n return () => {\n if (!run) {\n run = true;\n f();\n }\n };\n };\n\n\n // We only start listening for messages / errors when the worker calls addEventListener\n const startOnMessage = memoize(() => {\n $worker.parentPort!.on(\"message\", (data) => {\n workerEvents.dispatchEvent(new MessageEvent(\"message\", { data }));\n });\n });\n\n const startOnMessageError = memoize(() => {\n throw new Error(\"UNIMPLEMENTED\");\n });\n\n const startOnError = memoize(() => {\n $worker.parentPort!.on(\"error\", (data) => {\n workerEvents.dispatchEvent(new Event(\"error\"));\n });\n });\n\n\n // Node workers don't have top-level events, so we have to make our own\n const workerEvents = new EventTarget();\n\n globals.close = () => {\n process.exit();\n };\n\n globals.addEventListener = (type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined) => {\n workerEvents.addEventListener(type, callback, options);\n\n if (type === \"message\") {\n startOnMessage();\n } else if (type === \"messageerror\") {\n startOnMessageError();\n } else if (type === \"error\") {\n startOnError();\n }\n };\n\n globals.removeEventListener = (type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined) => {\n workerEvents.removeEventListener(type, callback, options);\n };\n\n function postMessage(message: any, transfer: Transferable[]): void;\n function postMessage(message: any, options?: StructuredSerializeOptions | undefined): void;\n function postMessage(value: any, transfer: any) {\n $worker.parentPort!.postMessage(value, transfer);\n }\n\n globals.postMessage = postMessage;\n\n makeSetter(\"onmessage\", \"message\");\n makeSetter(\"onmessageerror\", \"messageerror\");\n makeSetter(\"onerror\", \"error\");\n}\n","import \"./polyfill/shared\";\nimport \"./polyfill/crypto\";\nimport \"./polyfill/fetch\";\nimport \"./polyfill/xmlhttprequest\";\nimport \"./polyfill/worker\";\n\nif (!globalThis.self) {\n (globalThis as any).self = globalThis;\n}\n"],"names":[],"mappings":";;;;;;;;;AAEA,IAAK,UAAkB,CAAC,MAAM,IAAI,IAAI,EAAE;AACnC,IAAA,UAAkB,CAAC,MAAM,GAAG,SAAS;AAC1C;;ACAA,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK;AAGjC,IAAI,QAAQ,GAA4B,IAAI;AAE5C,eAAe,UAAU,GAAA;AACrB,IAAA,IAAI;QACA,MAAM,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AAChC,QAAA,OAAO,IAAI;;IAEb,OAAO,CAAC,EAAE;AACR,QAAA,OAAO,KAAK;;AAEpB;AAEA,eAAe,aAAa,GAAA;AACxB,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;QACnB,QAAQ,GAAG,UAAU,EAAE;;IAG3B,OAAO,MAAM,QAAQ;AACzB;AAGA;AACC,UAAU,CAAC,KAAa,GAAG,gBAAgB,QAA2B,EAAE,OAAgC,EAAA;IACrG,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;AAEhC,IAAA,IAAI,E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AAE;;AAEtB,KAAC;IAED,OAAO,CAAC,mBAAmB,GAAG,CAAC,IAAY,EAAE,QAAmD,EAAE,OAAoD,KAAI;QACtJ,YAAY,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC;AAC7D,KAAC;AAID,IAAA,SAAS,WAAW,CAAC,KAAU,EAAE,QAAa,EAAA;QAC1C,OAAO,CAAC,UAAW,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;;AAGpD,IAAA,OAAO,CAAC,WAAW,GAAG,WAAW;AAEjC,IAAA,UAAU,CAAC,WAAW,EAAE,SAAS,CAAC;AAClC,IAAA,UAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC;AAC5C,IAAA,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC;AAClC;;ACxLA,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;AACjB,IAAA,UAAkB,CAAC,IAAI,GAAG,UAAU;AACzC"}
1
+ {"version":3,"file":"node-polyfill.js","sources":["../../src/polyfill/crypto.ts","../../src/polyfill/fetch.ts","../../src/polyfill/xmlhttprequest.ts","../../src/polyfill/worker.ts","../../src/node-polyfill.ts"],"sourcesContent":["import { webcrypto } from \"node:crypto\";\n\nif ((globalThis as any).crypto == null) {\n (globalThis as any).crypto = webcrypto;\n}\n","import * as $fs from \"node:fs\";\nimport $mime from \"mime/lite\";\n\n\nconst oldFetch = globalThis.fetch;\n\n\nlet supports: Promise<boolean> | null = null;\n\nasync function checkFetch() {\n try {\n await oldFetch(new URL(\"file:\"));\n return true;\n\n } catch (e) {\n return false;\n }\n}\n\nasync function supportsFetch(): Promise<boolean> {\n if (supports === null) {\n supports = checkFetch();\n }\n\n return await supports;\n}\n\n\n// We always polyfill fetch because Node's fetch doesn't support file URLs.\n(globalThis.fetch as any) = async function (resource: URL | RequestInfo, options: RequestInit | undefined): Promise<Response> {\n const request = new Request(resource, options);\n\n const url = new URL(request.url);\n\n if (!(await supportsFetch()) && url.protocol === \"file:\") {\n const readStream = $fs.createReadStream(url);\n\n const headers: HeadersInit = {};\n\n const type = $mime.getType(url.pathname);\n\n if (type) {\n headers[\"Content-Type\"] = type;\n }\n\n return new Response(readStream as any, {\n status: 200,\n statusText: \"OK\",\n headers,\n });\n\n } else {\n return await oldFetch(request);\n }\n};\n","// @ts-ignore\nimport $xmlhttprequest from \"xmlhttprequest-ssl\";\nimport $request from \"sync-request\";\n\nif (globalThis.XMLHttpRequest == null) {\n globalThis.XMLHttpRequest = class extends $xmlhttprequest.XMLHttpRequest {\n // We have to override the methods inside of the `constructor`\n // because `xmlhttprequest-ssl` doesn't use a regular class,\n // instead it defines all of the methods inside of the constructor.\n constructor(...args: Array<any>) {\n super(...args);\n\n const open = (this as any).open;\n const send = (this as any).send;\n\n let _async: boolean = true;\n let _url: null | string = null;\n let _mime: string = \"text/xml\";\n\n function reset() {\n _async = true;\n _url = null;\n _mime = \"text/xml\";\n }\n\n (this as any).open = function (method: string, url: string, async: boolean, user?: string, password?: string) {\n // Special behavior for synchronous requests\n if (method === \"GET\" && !async && !user && !password) {\n _async = false;\n _url = url;\n\n // Default to the normal polyfill for async requests\n } else {\n reset();\n return open.call(this, method, url, async, user, password);\n }\n };\n\n (this as any).send = function (data: any) {\n if (_async) {\n return send.call(this, data);\n\n // Use `sync-request` for synchronous requests.\n } else {\n const response = $request(\"GET\", _url!, {\n headers: {\n \"Content-Type\": _mime,\n }\n });\n\n const buffer = (response.body as Buffer).buffer as any;\n\n const responseText = new TextDecoder(\"iso-8859-5\", { fatal: true }).decode(buffer);\n\n (this as any).status = 200;\n (this as any).response = (this as any).responseText = responseText;\n\n reset();\n }\n };\n\n (this as any).overrideMimeType = function (mime: string) {\n _mime = mime;\n };\n }\n } as any;\n}\n","import * as $worker from \"node:worker_threads\";\nimport * as $os from \"node:os\";\n\n// This is technically not a part of the Worker polyfill,\n// but Workers are used for multi-threading, so this is often\n// needed when writing Worker code.\nif (globalThis.navigator == null) {\n globalThis.navigator = {\n hardwareConcurrency: $os.cpus().length,\n } as Navigator;\n}\n\nif (globalThis.Worker == null) {\n globalThis.Worker = class Worker extends EventTarget {\n private _worker: import(\"node:worker_threads\").Worker;\n\n constructor(url: string | URL, options?: WorkerOptions | undefined) {\n super();\n\n if (url instanceof URL) {\n if (url.protocol !== \"file:\") {\n throw new Error(\"Worker only supports file: URLs\");\n }\n\n url = url.href;\n\n } else {\n throw new Error(\"Filepaths are unreliable, use `new URL(\\\"...\\\", import.meta.url)` instead.\");\n }\n\n if (!options || options.type !== \"module\") {\n throw new Error(\"Workers must use \\`type: \\\"module\\\"\\`\");\n }\n\n const code = `\n import(\"node:worker_threads\")\n .then(({ workerData }) => {\n return import(workerData.polyfill)\n .then(() => import(workerData.url))\n })\n .catch((e) => {\n // TODO maybe it should send a message to the parent?\n console.error(e.stack);\n });\n `;\n\n this._worker = new $worker.Worker(code, {\n eval: true,\n workerData: {\n url,\n polyfill: new URL(\"node-polyfill.js\", import.meta.url).href,\n },\n });\n\n this._worker.on(\"message\", (data) => {\n this.dispatchEvent(new MessageEvent(\"message\", { data }));\n });\n\n this._worker.on(\"messageerror\", (error) => {\n throw new Error(\"UNIMPLEMENTED\");\n });\n\n this._worker.on(\"error\", (error) => {\n // TODO attach the error to the event somehow\n const event = new Event(\"error\");\n this.dispatchEvent(event);\n });\n }\n\n set onmessage(f: () => void) {\n throw new Error(\"UNIMPLEMENTED\");\n }\n\n set onmessageerror(f: () => void) {\n throw new Error(\"UNIMPLEMENTED\");\n }\n\n set onerror(f: () => void) {\n throw new Error(\"UNIMPLEMENTED\");\n }\n\n postMessage(message: any, transfer: Array<Transferable>): void;\n postMessage(message: any, options?: StructuredSerializeOptions | undefined): void;\n postMessage(value: any, transfer: any) {\n this._worker.postMessage(value, transfer);\n }\n\n terminate() {\n this._worker.terminate();\n }\n\n // This is Node-specific, it allows the process to exit\n // even if the Worker is still running.\n unref() {\n this._worker.unref();\n }\n };\n}\n\n\nif (!$worker.isMainThread) {\n const globals = globalThis as unknown as DedicatedWorkerGlobalScope;\n\n // This is used to create the onmessage, onmessageerror, and onerror setters\n const makeSetter = (prop: string, event: string) => {\n let oldvalue: () => void;\n\n Object.defineProperty(globals, prop, {\n get() {\n return oldvalue;\n },\n set(value) {\n if (oldvalue) {\n globals.removeEventListener(event, oldvalue);\n }\n\n oldvalue = value;\n\n if (oldvalue) {\n globals.addEventListener(event, oldvalue);\n }\n },\n });\n };\n\n // This makes sure that `f` is only run once\n const memoize = (f: () => void) => {\n let run = false;\n\n return () => {\n if (!run) {\n run = true;\n f();\n }\n };\n };\n\n\n // We only start listening for messages / errors when the worker calls addEventListener\n const startOnMessage = memoize(() => {\n $worker.parentPort!.on(\"message\", (data) => {\n workerEvents.dispatchEvent(new MessageEvent(\"message\", { data }));\n });\n });\n\n const startOnMessageError = memoize(() => {\n throw new Error(\"UNIMPLEMENTED\");\n });\n\n const startOnError = memoize(() => {\n $worker.parentPort!.on(\"error\", (data) => {\n workerEvents.dispatchEvent(new Event(\"error\"));\n });\n });\n\n\n // Node workers don't have top-level events, so we have to make our own\n const workerEvents = new EventTarget();\n\n globals.close = () => {\n process.exit();\n };\n\n globals.addEventListener = (type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined) => {\n workerEvents.addEventListener(type, callback, options);\n\n if (type === \"message\") {\n startOnMessage();\n } else if (type === \"messageerror\") {\n startOnMessageError();\n } else if (type === \"error\") {\n startOnError();\n }\n };\n\n globals.removeEventListener = (type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined) => {\n workerEvents.removeEventListener(type, callback, options);\n };\n\n function postMessage(message: any, transfer: Transferable[]): void;\n function postMessage(message: any, options?: StructuredSerializeOptions | undefined): void;\n function postMessage(value: any, transfer: any) {\n $worker.parentPort!.postMessage(value, transfer);\n }\n\n globals.postMessage = postMessage;\n\n makeSetter(\"onmessage\", \"message\");\n makeSetter(\"onmessageerror\", \"messageerror\");\n makeSetter(\"onerror\", \"error\");\n}\n","import \"./polyfill/shared.js\";\nimport \"./polyfill/crypto.js\";\nimport \"./polyfill/fetch.js\";\nimport \"./polyfill/xmlhttprequest.js\";\nimport \"./polyfill/worker.js\";\n\nif (!globalThis.self) {\n (globalThis as any).self = globalThis;\n}\n"],"names":[],"mappings":";;;;;;;;;AAEA,IAAK,UAAkB,CAAC,MAAM,IAAI,IAAI,EAAE;AACnC,IAAA,UAAkB,CAAC,MAAM,GAAG,SAAS;AAC1C;;ACAA,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK;AAGjC,IAAI,QAAQ,GAA4B,IAAI;AAE5C,eAAe,UAAU,GAAA;AACrB,IAAA,IAAI;QACA,MAAM,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AAChC,QAAA,OAAO,IAAI;;IAEb,OAAO,CAAC,EAAE;AACR,QAAA,OAAO,KAAK;;AAEpB;AAEA,eAAe,aAAa,GAAA;AACxB,IAAA,IAAI,QAAQ,KAAK,IAAI,EAAE;QACnB,QAAQ,GAAG,UAAU,EAAE;;IAG3B,OAAO,MAAM,QAAQ;AACzB;AAGA;AACC,UAAU,CAAC,KAAa,GAAG,gBAAgB,QAA2B,EAAE,OAAgC,EAAA;IACrG,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;AAEhC,IAAA,IAAI,EAAE,MAAM,aAAa,EAAE,CAAC,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE;QACtD,MAAM,UAAU,GAAG,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC;QAE5C,MAAM,OAAO,GAAgB,EAAE;QAE/B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAExC,IAAI,IAAI,EAAE;AACN,YAAA,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;;AAGlC,QAAA,OAA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W,GAAG,WAAW;AAEjC,IAAA,UAAU,CAAC,WAAW,EAAE,SAAS,CAAC;AAClC,IAAA,UAAU,CAAC,gBAAgB,EAAE,cAAc,CAAC;AAC5C,IAAA,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC;AAClC;;ACxLA,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;AACjB,IAAA,UAAkB,CAAC,IAAI,GAAG,UAAU;AACzC"}
@@ -1,2 +1,2 @@
1
- import "./node-polyfill";
2
- export * from "./browser";
1
+ import "./node-polyfill.js";
2
+ export * from "./browser.js";
@@ -1,7 +1,7 @@
1
1
  import './node-polyfill.js';
2
2
  export { Account, BlockHeightSearch, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, createAleoWorker, initializeWasm } from './browser.js';
3
- export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, C as CREDITS_PROGRAM_KEYS, K as KEY_STORE, d as PRIVATE_TO_PUBLIC_TRANSFER, c as PRIVATE_TRANSFER, e as PRIVATE_TRANSFER_TYPES, h as PUBLIC_TO_PRIVATE_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, P as ProgramManager, V as VALID_TRANSFER_TYPES, l as logAndThrow } from './program-manager-DMDKstZ8.js';
4
- export { Address, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
3
+ export { A as AleoKeyProvider, a as AleoKeyProviderParams, b as AleoNetworkClient, C as CREDITS_PROGRAM_KEYS, K as KEY_STORE, d as PRIVATE_TO_PUBLIC_TRANSFER, c as PRIVATE_TRANSFER, e as PRIVATE_TRANSFER_TYPES, h as PUBLIC_TO_PRIVATE_TRANSFER, f as PUBLIC_TRANSFER, g as PUBLIC_TRANSFER_AS_SIGNER, P as ProgramManager, V as VALID_TRANSFER_TYPES, l as logAndThrow } from './program-manager-BfZnPCKl.js';
4
+ export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
5
5
  import 'core-js/proposals/json-parse-with-source.js';
6
6
  import 'node:crypto';
7
7
  import 'node:fs';
@@ -1,5 +1,5 @@
1
- import { CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider";
2
- import { ProvingKey, VerifyingKey } from "./wasm";
1
+ import { CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
2
+ import { ProvingKey, VerifyingKey } from "./wasm.js";
3
3
  /**
4
4
  * Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes
5
5
  * a convenience method for creating a new instance of this class for each function of the credits.aleo program.
@@ -124,7 +124,7 @@ class AleoNetworkClient {
124
124
  else {
125
125
  this.headers = {
126
126
  // This is replaced by the actual version by a Rollup plugin
127
- "X-Aleo-SDK-Version": "0.9.1",
127
+ "X-Aleo-SDK-Version": "0.9.3",
128
128
  "X-Aleo-environment": environment(),
129
129
  };
130
130
  }
@@ -188,20 +188,6 @@ class AleoNetworkClient {
188
188
  setHeader(headerName, value) {
189
189
  this.headers[headerName] = value;
190
190
  }
191
- /**
192
- * Remove a header from the `AleoNetworkClient`s header map
193
- *
194
- * @param {string} headerName The name of the header to be removed
195
- *
196
- * @example
197
- * import { AleoNetworkClient } from "@provablehq/sdk/mainnet.js";
198
- *
199
- * // Create a networkClient
200
- * const networkClient = new AleoNetworkClient();
201
- *
202
- * // Remove the default `X-Aleo-SDK-Version` header
203
- * networkClient.removeHeader('X-Aleo-SDK-Version');
204
- */
205
191
  removeHeader(headerName) {
206
192
  delete this.headers[headerName];
207
193
  }
@@ -2208,7 +2194,7 @@ class ProgramManager {
2208
2194
  * /// Import the mainnet version of the sdk.
2209
2195
  * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
2210
2196
  *
2211
- * // Create a new NetworkClient, KeyProvider, and RecordProvider
2197
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
2212
2198
  * const keyProvider = new AleoKeyProvider();
2213
2199
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
2214
2200
  * keyProvider.useCache = true;
@@ -2255,7 +2241,7 @@ class ProgramManager {
2255
2241
  * /// Import the mainnet version of the sdk.
2256
2242
  * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
2257
2243
  *
2258
- * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
2244
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
2259
2245
  * const keyProvider = new AleoKeyProvider();
2260
2246
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
2261
2247
  * keyProvider.useCache = true;
@@ -2353,6 +2339,121 @@ class ProgramManager {
2353
2339
  // Build an execution transaction
2354
2340
  return await ProgramManager$1.buildExecutionTransaction(executionPrivateKey, program, functionName, inputs, priorityFee, feeRecord, this.host, imports, provingKey, verifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
2355
2341
  }
2342
+ /**
2343
+ * Builds a SnarkVM `Authorization` for a specific function.
2344
+ *
2345
+ * @param {AuthorizationOptions} options - The options for building the `Authorization`
2346
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
2347
+ *
2348
+ * @example
2349
+ * /// Import the mainnet version of the sdk.
2350
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
2351
+ *
2352
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
2353
+ * const keyProvider = new AleoKeyProvider();
2354
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
2355
+ * keyProvider.useCache = true;
2356
+ *
2357
+ * // Initialize a ProgramManager with the key and record providers.
2358
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
2359
+ *
2360
+ * // Build the `Authorization`.
2361
+ * const authorization = await programManager.buildAuthorization({
2362
+ * programName: "credits.aleo",
2363
+ * functionName: "transfer_public",
2364
+ * inputs: [
2365
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
2366
+ * "10000000u64",
2367
+ * ],
2368
+ * });
2369
+ */
2370
+ async buildAuthorization(options) {
2371
+ // Destructure the options object to access the parameters.
2372
+ const { programName, functionName, inputs, } = options;
2373
+ const privateKey = options.privateKey;
2374
+ let program = options.programSource;
2375
+ let imports = options.programImports;
2376
+ // Ensure the function exists on the network.
2377
+ if (program === undefined) {
2378
+ try {
2379
+ program = (await this.networkClient.getProgram(programName));
2380
+ }
2381
+ catch (e) {
2382
+ logAndThrow(`Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`);
2383
+ }
2384
+ }
2385
+ else if (program instanceof Program) {
2386
+ program = program.toString();
2387
+ }
2388
+ // Get the private key from the account if it is not provided in the parameters.
2389
+ let executionPrivateKey = privateKey;
2390
+ if (typeof privateKey === "undefined" &&
2391
+ typeof this.account !== "undefined") {
2392
+ executionPrivateKey = this.account.privateKey();
2393
+ }
2394
+ if (typeof executionPrivateKey === "undefined") {
2395
+ throw "No private key provided and no private key set in the ProgramManager";
2396
+ }
2397
+ // Resolve the program imports if they exist.
2398
+ const numberOfImports = Program.fromString(program).getImports().length;
2399
+ if (numberOfImports > 0 && !imports) {
2400
+ try {
2401
+ imports = (await this.networkClient.getProgramImports(programName));
2402
+ }
2403
+ catch (e) {
2404
+ logAndThrow(`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`);
2405
+ }
2406
+ }
2407
+ // Build and return an `Authorization` for the desired function.
2408
+ return await ProgramManager$1.authorize(executionPrivateKey, program, functionName, inputs, imports);
2409
+ }
2410
+ /**
2411
+ * Builds a SnarkVM fee `Authorization` for `credits.aleo/fee_private` or `credits.aleo/fee_public`. If a record is provided `fee_private` will be executed, otherwise `fee_public` will be executed.
2412
+ *
2413
+ * @param {FeeAuthorizationOptions} options - The options for building the `Authorization`.
2414
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
2415
+ *
2416
+ * @example
2417
+ * /// Import the mainnet version of the sdk.
2418
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
2419
+ *
2420
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
2421
+ * const keyProvider = new AleoKeyProvider();
2422
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
2423
+ * keyProvider.useCache = true;
2424
+ *
2425
+ * // Initialize a ProgramManager with the key and record providers.
2426
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
2427
+ *
2428
+ * // Build a credits.aleo/fee_public `Authorization`.
2429
+ * const feePublicAuthorization = await programManager.authorizeFee({
2430
+ * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
2431
+ * baseFeeCredits: 0.1,
2432
+ * });
2433
+ *
2434
+ * // Build a credits.aleo/fee_private `Authorization`.
2435
+ * const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
2436
+ * const feePrivateAuthorization = await programManager.authorizeFee({
2437
+ * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
2438
+ * baseFeeCredits: 0.1,
2439
+ * feeRecord: record,
2440
+ * });
2441
+ */
2442
+ async buildFeeAuthorization(options) {
2443
+ // Destructure the options object to access the parameters.
2444
+ const { privateKey, deploymentOrExecutionId, baseFeeCredits, priorityFeeCredits, feeRecord, } = options;
2445
+ // Get the private key from the account if it is not provided in the parameters.
2446
+ let executionPrivateKey = privateKey;
2447
+ if (typeof privateKey === "undefined" &&
2448
+ typeof this.account !== "undefined") {
2449
+ executionPrivateKey = this.account.privateKey();
2450
+ }
2451
+ if (typeof executionPrivateKey === "undefined") {
2452
+ throw "No private key provided and no private key set in the ProgramManager";
2453
+ }
2454
+ // Build and return the fee `Authorization`.
2455
+ return await ProgramManager$1.authorizeFee(executionPrivateKey, deploymentOrExecutionId, baseFeeCredits, priorityFeeCredits || 0, feeRecord);
2456
+ }
2356
2457
  /**
2357
2458
  * Builds an execution transaction for submission to the Aleo network.
2358
2459
  *
@@ -3455,4 +3556,4 @@ function validateTransferType(transferType) {
3455
3556
  }
3456
3557
 
3457
3558
  export { AleoKeyProvider as A, CREDITS_PROGRAM_KEYS as C, KEY_STORE as K, ProgramManager as P, VALID_TRANSFER_TYPES as V, AleoKeyProviderParams as a, AleoNetworkClient as b, PRIVATE_TRANSFER as c, PRIVATE_TO_PUBLIC_TRANSFER as d, PRIVATE_TRANSFER_TYPES as e, PUBLIC_TRANSFER as f, PUBLIC_TRANSFER_AS_SIGNER as g, PUBLIC_TO_PRIVATE_TRANSFER as h, logAndThrow as l };
3458
- //# sourceMappingURL=program-manager-DMDKstZ8.js.map
3559
+ //# sourceMappingURL=program-manager-BfZnPCKl.js.map