@provablehq/sdk 0.9.2 → 0.9.4-offline-rc

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 (47) hide show
  1. package/dist/mainnet/account.d.ts +36 -1
  2. package/dist/mainnet/browser.d.ts +5 -4
  3. package/dist/mainnet/browser.js +4415 -570
  4. package/dist/mainnet/browser.js.map +1 -1
  5. package/dist/mainnet/function-key-provider.d.ts +18 -0
  6. package/dist/mainnet/models/authorization.d.ts +6 -0
  7. package/dist/mainnet/models/inputID.d.ts +4 -0
  8. package/dist/mainnet/models/provingRequest.d.ts +6 -0
  9. package/dist/mainnet/models/provingResponse.d.ts +5 -0
  10. package/dist/mainnet/models/request.d.ts +14 -0
  11. package/dist/mainnet/network-client.d.ts +0 -14
  12. package/dist/mainnet/node-polyfill.js.map +1 -1
  13. package/dist/mainnet/node.js +2 -4
  14. package/dist/mainnet/node.js.map +1 -1
  15. package/dist/mainnet/offline-key-provider.d.ts +14 -0
  16. package/dist/mainnet/program-manager.d.ts +209 -6
  17. package/dist/mainnet/wasm.d.ts +1 -1
  18. package/dist/testnet/account.d.ts +36 -1
  19. package/dist/testnet/browser.d.ts +5 -4
  20. package/dist/testnet/browser.js +4415 -570
  21. package/dist/testnet/browser.js.map +1 -1
  22. package/dist/testnet/function-key-provider.d.ts +18 -0
  23. package/dist/testnet/models/authorization.d.ts +6 -0
  24. package/dist/testnet/models/inputID.d.ts +4 -0
  25. package/dist/testnet/models/provingRequest.d.ts +6 -0
  26. package/dist/testnet/models/provingResponse.d.ts +5 -0
  27. package/dist/testnet/models/request.d.ts +14 -0
  28. package/dist/testnet/network-client.d.ts +0 -14
  29. package/dist/testnet/node-polyfill.js.map +1 -1
  30. package/dist/testnet/node.js +2 -4
  31. package/dist/testnet/node.js.map +1 -1
  32. package/dist/testnet/offline-key-provider.d.ts +14 -0
  33. package/dist/testnet/program-manager.d.ts +209 -6
  34. package/dist/testnet/wasm.d.ts +1 -1
  35. package/package.json +2 -2
  36. package/dist/mainnet/managed-worker.d.ts +0 -3
  37. package/dist/mainnet/program-manager-B-18sj9m.js +0 -3458
  38. package/dist/mainnet/program-manager-B-18sj9m.js.map +0 -1
  39. package/dist/mainnet/worker.d.ts +0 -9
  40. package/dist/mainnet/worker.js +0 -78
  41. package/dist/mainnet/worker.js.map +0 -1
  42. package/dist/testnet/managed-worker.d.ts +0 -3
  43. package/dist/testnet/program-manager-BR5taTR7.js +0 -3458
  44. package/dist/testnet/program-manager-BR5taTR7.js.map +0 -1
  45. package/dist/testnet/worker.d.ts +0 -9
  46. package/dist/testnet/worker.js +0 -78
  47. package/dist/testnet/worker.js.map +0 -1
@@ -146,6 +146,12 @@ interface FunctionKeyProvider {
146
146
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
147
147
  */
148
148
  feePublicKeys(): Promise<FunctionKeyPair>;
149
+ /**
150
+ * Get keys for the inclusion proof.
151
+ *
152
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
153
+ */
154
+ inclusionKeys(): Promise<FunctionKeyPair>;
149
155
  /**
150
156
  * Get join function keys from the credits.aleo program
151
157
  *
@@ -314,6 +320,18 @@ declare class AleoKeyProvider implements FunctionKeyProvider {
314
320
  * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
315
321
  */
316
322
  transferKeys(visibility: string): Promise<FunctionKeyPair>;
323
+ /**
324
+ * Returns the proving and verifying keys for the transfer_public function.
325
+ *
326
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer_public function
327
+ */
328
+ transferPublicKeys(): Promise<FunctionKeyPair>;
329
+ /**
330
+ * Returns the proving and verifying keys for the inclusion proof.
331
+ *
332
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion proof.
333
+ */
334
+ inclusionKeys(): Promise<FunctionKeyPair>;
317
335
  /**
318
336
  * Returns the proving and verifying keys for the join function in the credits.aleo program
319
337
  *
@@ -0,0 +1,6 @@
1
+ import { RequestJSON } from "./request";
2
+ import { TransitionJSON } from "./transition/transitionJSON";
3
+ export interface AuthorizationJSON {
4
+ requests: RequestJSON[];
5
+ transitions: TransitionJSON[];
6
+ }
@@ -0,0 +1,4 @@
1
+ export interface InputID {
2
+ type: string;
3
+ id: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { AuthorizationJSON } from "./authorization";
2
+ export interface ProvingRequestJSON {
3
+ authorization: AuthorizationJSON;
4
+ fee_authorization?: AuthorizationJSON;
5
+ broadcast: boolean;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { TransactionJSON } from "./transaction/transactionJSON";
2
+ export interface ProvingResponse {
3
+ transaction: TransactionJSON;
4
+ broadcast?: boolean;
5
+ }
@@ -0,0 +1,14 @@
1
+ import { InputID } from "./inputID";
2
+ export interface RequestJSON {
3
+ signer: string;
4
+ network: string;
5
+ program: string;
6
+ method: string;
7
+ input_ids: InputID[];
8
+ inputs: string[];
9
+ signature: string;
10
+ sk_tag: string;
11
+ tvk: string;
12
+ tcm: string;
13
+ scm: string;
14
+ }
@@ -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 +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.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,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AAA,IAAI,IAAI,KAAK,SAAS,EAAE;AACpB,YAAA,cAAc,EAAE;;AACb,aAAA,IAAI,IAAI,KAAK,cAAc,EAAE;AAChC,YAAA,mBAAmB,EAAE;;AAClB,aAAA,IAAI,IAAI,KAAK,OAAO,EAAE;AACzB,YAAA,YAAY,EAAE;;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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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,7 +1,6 @@
1
1
  import './node-polyfill.js';
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-B-18sj9m.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';
2
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KEY_STORE, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, VALID_TRANSFER_TYPES, initializeWasm, logAndThrow } from './browser.js';
3
+ export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, Group, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution } from '@provablehq/wasm/mainnet.js';
5
4
  import 'core-js/proposals/json-parse-with-source.js';
6
5
  import 'node:crypto';
7
6
  import 'node:fs';
@@ -10,5 +9,4 @@ import 'xmlhttprequest-ssl';
10
9
  import 'sync-request';
11
10
  import 'node:worker_threads';
12
11
  import 'node:os';
13
- import 'comlink';
14
12
  //# sourceMappingURL=node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
1
+ {"version":3,"file":"node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -212,6 +212,12 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
212
212
  * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
213
213
  */
214
214
  feePublicKeys(): Promise<FunctionKeyPair>;
215
+ /**
216
+ * Get the inclusion prover keys from. The keys must be cached prior to calling this method for it to work.
217
+ *
218
+ * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the inclusion prover
219
+ */
220
+ inclusionKeys(): Promise<FunctionKeyPair>;
215
221
  /**
216
222
  * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
217
223
  * method for it to work.
@@ -287,6 +293,14 @@ declare class OfflineKeyProvider implements FunctionKeyProvider {
287
293
  * @param provingKey
288
294
  */
289
295
  insertFeePublicKeys(provingKey: ProvingKey): void;
296
+ /**
297
+ * Insert the proving and verifying keys for the inclusion prover into the cache. Only the proving key needs
298
+ * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
299
+ * that the keys match the expected checksum for the inclusion prover.
300
+ *
301
+ * @param provingKey
302
+ */
303
+ insertInclusionKeys(provingKey: ProvingKey): void;
290
304
  /**
291
305
  * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
292
306
  * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
@@ -3,7 +3,7 @@ import { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports } from "./n
3
3
  import { ImportedPrograms, ImportedVerifyingKeys } from "./models/imports.js";
4
4
  import { RecordProvider, RecordSearchParams } from "./record-provider.js";
5
5
  import { FunctionKeyPair, FunctionKeyProvider, KeySearchParams } from "./function-key-provider.js";
6
- import { ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, VerifyingKey, Transaction } from "./wasm.js";
6
+ import { Authorization, ExecutionResponse, OfflineQuery, RecordPlaintext, PrivateKey, Program, ProvingKey, ProvingRequest, VerifyingKey, Transaction } from "./wasm.js";
7
7
  /**
8
8
  * Represents the options for executing a transaction in the Aleo network.
9
9
  * This interface is used to specify the parameters required for building and submitting an execution transaction.
@@ -39,6 +39,73 @@ interface ExecuteOptions {
39
39
  program?: string | Program;
40
40
  imports?: ProgramImports;
41
41
  }
42
+ /**
43
+ * Options for building an Authorization for a function.
44
+ *
45
+ * @property programName {string} Name of the program containing the function to build the authorization for.
46
+ * @property functionName {string} Name of the function name to build the authorization for.
47
+ * @property inputs {string[]} The inputs to the function.
48
+ * @property programSource {string | Program} The optional source code for the program to build an execution for.
49
+ * @property privateKey {PrivateKey} Optional private key to use to build the authorization.
50
+ * @property programImports {ProgramImports} The other programs the program imports.
51
+ */
52
+ interface AuthorizationOptions {
53
+ programName: string;
54
+ functionName: string;
55
+ inputs: string[];
56
+ programSource?: string | Program;
57
+ privateKey?: PrivateKey;
58
+ programImports?: ProgramImports;
59
+ }
60
+ /**
61
+ * Options for executing a fee authorization.
62
+ *
63
+ * @property deploymentOrExecutionId {string} The id of a previously built Execution or Authorization.
64
+ * @property baseFeeCredits {number} The number of Aleo Credits to pay for the base fee.
65
+ * @property priorityFeeCredits {number} The number of Aleo Credits to pay for the priority fee.
66
+ * @property privateKey {PrivateKey} Optional private key to specify for the authorization.
67
+ * @property feeRecord {RecordPlaintext} A record to specify to pay the private fee. If this is specified a `fee_private` authorization will be built.
68
+ */
69
+ interface FeeAuthorizationOptions {
70
+ deploymentOrExecutionId: string;
71
+ baseFeeCredits: number;
72
+ priorityFeeCredits?: number;
73
+ privateKey?: PrivateKey;
74
+ feeRecord?: RecordPlaintext;
75
+ }
76
+ /**
77
+ * Represents the options for executing a transaction in the Aleo network.
78
+ * This interface is used to specify the parameters required for building and submitting an execution transaction.
79
+ *
80
+ * @property {string} programName - The name of the program containing the function to be executed.
81
+ * @property {string} functionName - The name of the function to execute within the program.
82
+ * @property {number} baseFee - The base fee to be paid for the transaction.
83
+ * @property {number} priorityFee - The optional priority fee to be paid for the transaction.
84
+ * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
85
+ * @property {string[]} inputs - The inputs to the function being executed.
86
+ * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.
87
+ * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.
88
+ * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.
89
+ * @property {string | Program} [program] - Optional program source code to use for the transaction.
90
+ * @property {string} uri - The URI send the ProvingRequest to.
91
+ * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
92
+ * @property {boolean} broadcast - Whether to broadcast the Transaction generated by the remove prover to the Aleo network.
93
+ */
94
+ interface ProvingRequestOptions {
95
+ programName: string;
96
+ functionName: string;
97
+ baseFee: number;
98
+ priorityFee: number;
99
+ privateFee: boolean;
100
+ inputs: string[];
101
+ recordSearchParams?: RecordSearchParams;
102
+ feeRecord?: string | RecordPlaintext;
103
+ privateKey?: PrivateKey;
104
+ programSource?: string | Program;
105
+ programImports?: ProgramImports;
106
+ broadcast?: boolean;
107
+ unchecked?: boolean;
108
+ }
42
109
  /**
43
110
  * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
44
111
  */
@@ -48,6 +115,7 @@ declare class ProgramManager {
48
115
  host: string;
49
116
  networkClient: AleoNetworkClient;
50
117
  recordProvider: RecordProvider | undefined;
118
+ inclusionKeysLoaded: boolean;
51
119
  /** Create a new instance of the ProgramManager
52
120
  *
53
121
  * @param { string | undefined } host A host uri running the official Aleo API
@@ -168,7 +236,7 @@ declare class ProgramManager {
168
236
  * /// Import the mainnet version of the sdk.
169
237
  * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
170
238
  *
171
- * // Create a new NetworkClient, KeyProvider, and RecordProvider
239
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
172
240
  * const keyProvider = new AleoKeyProvider();
173
241
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
174
242
  * keyProvider.useCache = true;
@@ -200,7 +268,7 @@ declare class ProgramManager {
200
268
  * /// Import the mainnet version of the sdk.
201
269
  * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
202
270
  *
203
- * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
271
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
204
272
  * const keyProvider = new AleoKeyProvider();
205
273
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
206
274
  * keyProvider.useCache = true;
@@ -228,6 +296,130 @@ declare class ProgramManager {
228
296
  * }, 10000);
229
297
  */
230
298
  buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction>;
299
+ /**
300
+ * Builds a SnarkVM `Authorization` for a specific function.
301
+ *
302
+ * @param {AuthorizationOptions} options - The options for building the `Authorization`
303
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
304
+ *
305
+ * @example
306
+ * /// Import the mainnet version of the sdk.
307
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
308
+ *
309
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
310
+ * const keyProvider = new AleoKeyProvider();
311
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
312
+ * keyProvider.useCache = true;
313
+ *
314
+ * // Initialize a ProgramManager with the key and record providers.
315
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
316
+ *
317
+ * // Build the `Authorization`.
318
+ * const authorization = await programManager.buildAuthorization({
319
+ * programName: "credits.aleo",
320
+ * functionName: "transfer_public",
321
+ * inputs: [
322
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
323
+ * "10000000u64",
324
+ * ],
325
+ * });
326
+ */
327
+ buildAuthorization(options: AuthorizationOptions): Promise<Authorization>;
328
+ /**
329
+ * Builds a SnarkVM `Authorization` for a specific function without building a circuit first. This should be used when fast authorization generation is needed and the invoker is confident inputs are coorect.
330
+ *
331
+ * @param {AuthorizationOptions} options - The options for building the `Authorization`
332
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
333
+ *
334
+ * @example
335
+ * /// Import the mainnet version of the sdk.
336
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
337
+ *
338
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
339
+ * const keyProvider = new AleoKeyProvider();
340
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
341
+ * keyProvider.useCache = true;
342
+ *
343
+ * // Initialize a ProgramManager with the key and record providers.
344
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
345
+ *
346
+ * // Build the unchecked `Authorization`.
347
+ * const authorization = await programManager.buildAuthorizationUnchecked({
348
+ * programName: "credits.aleo",
349
+ * functionName: "transfer_public",
350
+ * inputs: [
351
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
352
+ * "10000000u64",
353
+ * ],
354
+ * });
355
+ */
356
+ buildAuthorizationUnchecked(options: AuthorizationOptions): Promise<Authorization>;
357
+ /**
358
+ * Builds a `ProvingRequest` for submission to a prover for execution.
359
+ *
360
+ * @param {ProvingRequestOptions} options - The options for building the proving request
361
+ * @returns {Promise<ProvingRequest>} - A promise that resolves to the transaction or an error.
362
+ *
363
+ * @example
364
+ * /// Import the mainnet version of the sdk.
365
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
366
+ *
367
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
368
+ * const keyProvider = new AleoKeyProvider();
369
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
370
+ * keyProvider.useCache = true;
371
+ *
372
+ * // Initialize a ProgramManager with the key and record providers.
373
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
374
+ *
375
+ * // Build the proving request.
376
+ * const provingRequest = await programManager.provingRequest({
377
+ * programName: "credits.aleo",
378
+ * functionName: "transfer_public",
379
+ * baseFee: 100000,
380
+ * priorityFee: 0,
381
+ * privateFee: false,
382
+ * inputs: [
383
+ * "aleo1vwls2ete8dk8uu2kmkmzumd7q38fvshrht8hlc0a5362uq8ftgyqnm3w08",
384
+ * "10000000u64",
385
+ * ],
386
+ * broadcast: false,
387
+ * });
388
+ */
389
+ provingRequest(options: ProvingRequestOptions): Promise<ProvingRequest>;
390
+ /**
391
+ * 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.
392
+ *
393
+ * @param {FeeAuthorizationOptions} options - The options for building the `Authorization`.
394
+ * @returns {Promise<Authorization>} - A promise that resolves to an `Authorization` or throws an Error.
395
+ *
396
+ * @example
397
+ * /// Import the mainnet version of the sdk.
398
+ * import { AleoKeyProvider, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
399
+ *
400
+ * // Create a new NetworkClient, KeyProvider, and RecordProvider.
401
+ * const keyProvider = new AleoKeyProvider();
402
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
403
+ * keyProvider.useCache = true;
404
+ *
405
+ * // Initialize a ProgramManager with the key and record providers.
406
+ * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
407
+ *
408
+ * // Build a credits.aleo/fee_public `Authorization`.
409
+ * const feePublicAuthorization = await programManager.authorizeFee({
410
+ * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
411
+ * baseFeeCredits: 0.1,
412
+ * });
413
+ *
414
+ * // Build a credits.aleo/fee_private `Authorization`.
415
+ * const record = "{ owner: aleo1j7qxyunfldj2lp8hsvy7mw5k8zaqgjfyr72x2gh3x4ewgae8v5gscf5jh3.private, microcredits: 1500000000000000u64.private, _nonce: 3077450429259593211617823051143573281856129402760267155982965992208217472983group.public }";
416
+ * const feePrivateAuthorization = await programManager.authorizeFee({
417
+ * deploymentOrExecutionId: "2423957656946557501636078245035919227529640894159332581642187482178647335171field",
418
+ * baseFeeCredits: 0.1,
419
+ * feeRecord: record,
420
+ * });
421
+ */
422
+ buildFeeAuthorization(options: FeeAuthorizationOptions): Promise<Authorization>;
231
423
  /**
232
424
  * Builds an execution transaction for submission to the Aleo network.
233
425
  *
@@ -841,6 +1033,7 @@ declare class ProgramManager {
841
1033
  * Verify a proof from an offline execution. This is useful when it is desired to do offchain proving and verification.
842
1034
  *
843
1035
  * @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)
1036
+ * @param {blockHeight} blockHeight The ledger height when the execution was generated.
844
1037
  * @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { "programName": "programSourceCode", ... }
845
1038
  * @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { "programName": [["functionName", "verifyingKey"], ...], ... }
846
1039
  * @returns {boolean} True if the proof is valid, false otherwise
@@ -866,10 +1059,20 @@ declare class ProgramManager {
866
1059
  * const importedVerifyingKeys = { "add_it_up.aleo": [["add_it", "verifyingKey1..."]] };
867
1060
  *
868
1061
  * /// Verify the execution.
869
- * const isValid = programManager.verifyExecution(executionResponse, imports, importedVerifyingKeys);
1062
+ * const blockHeight = 9000000;
1063
+ * const isValid = programManager.verifyExecution(executionResponse, blockHeight, imports, importedVerifyingKeys);
870
1064
  * assert(isValid);
871
1065
  */
872
- verifyExecution(executionResponse: ExecutionResponse, imports?: ImportedPrograms, importedVerifyingKeys?: ImportedVerifyingKeys): boolean;
1066
+ verifyExecution(executionResponse: ExecutionResponse, blockHeight: number, imports?: ImportedPrograms, importedVerifyingKeys?: ImportedVerifyingKeys): boolean;
1067
+ /**
1068
+ * Set the inclusion key bytes.
1069
+ *
1070
+ * @param {executionResponse} executionResponse The response from an offline function execution (via the `programManager.run` method)
1071
+ * @param {ImportedPrograms} imports The imported programs used in the execution. Specified as { "programName": "programSourceCode", ... }
1072
+ * @param {ImportedVerifyingKeys} importedVerifyingKeys The verifying keys in the execution. Specified as { "programName": [["functionName", "verifyingKey"], ...], ... }
1073
+ * @returns {boolean} True if the proof is valid, false otherwise
1074
+ *
1075
+
873
1076
  /**
874
1077
  * Create a program object from a program's source code
875
1078
  *
@@ -891,4 +1094,4 @@ declare class ProgramManager {
891
1094
  verifyProgram(program: string): boolean;
892
1095
  getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext>;
893
1096
  }
894
- export { ProgramManager };
1097
+ export { ProgramManager, AuthorizationOptions, FeeAuthorizationOptions, ExecuteOptions, ProvingRequestOptions };
@@ -1 +1 @@
1
- export { Address, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution, ExecutionResponse, Field, Group, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
1
+ export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, EncryptionToolkit, ExecutionRequest, Execution, ExecutionResponse, Field, Group, OfflineQuery, Metadata, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "@provablehq/wasm/mainnet.js";
@@ -1,4 +1,4 @@
1
- import { Address, ComputeKey, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext, RecordPlaintext } from "./wasm.js";
1
+ import { Address, ComputeKey, Field, Group, PrivateKey, Signature, ViewKey, PrivateKeyCiphertext, RecordCiphertext, RecordPlaintext } from "./wasm.js";
2
2
  interface AccountParam {
3
3
  privateKey?: string;
4
4
  seed?: Uint8Array;
@@ -182,6 +182,41 @@ export declare class Account {
182
182
  * const decryptedRecords = account.decryptRecords(records);
183
183
  */
184
184
  decryptRecords(ciphertexts: string[]): RecordPlaintext[];
185
+ /**
186
+ * Generates a record view key from the account owner's view key and the record ciphertext.
187
+ * This key can be used to decrypt the record without revealing the account's view key.
188
+ * @param {RecordCiphertext | string} recordCiphertext The record ciphertext to generate the view key for
189
+ * @returns {Field} The record view key
190
+ *
191
+ * @example
192
+ * // Import the Account class
193
+ * import { Account } from "@provablehq/sdk/testnet.js";
194
+ *
195
+ * // Create an account object from a previously encrypted ciphertext and password.
196
+ * const account = Account.fromCiphertext(process.env.ciphertext!, process.env.password!);
197
+ *
198
+ * // Generate a record view key from the account's view key and a record ciphertext
199
+ * const recordCiphertext = RecordCiphertext.fromString("your_record_ciphertext_here");
200
+ * const recordViewKey = account.generateRecordViewKey(recordCiphertext);
201
+ */
202
+ generateRecordViewKey(recordCiphertext: RecordCiphertext | string): Field;
203
+ /**
204
+ * Generates a transition view key from the account owner's view key and the transition public key.
205
+ * This key can be used to decrypt the private inputs and outputs of a the transition without
206
+ * revealing the account's view key.
207
+ * @param {string | Group} tpk The transition public key
208
+ * @returns {Field} The transition view key
209
+ *
210
+ * @example
211
+ * // Import the Account class
212
+ * import { Account } from "@provablehq/sdk/testnet.js";
213
+ *
214
+ * // Generate a transition view key from the account's view key and a transition public key
215
+ * const tpk = Group.fromString("your_transition_public_key_here");
216
+ *
217
+ * const transitionViewKey = account.generateTransitionViewKey(tpk);
218
+ */
219
+ generateTransitionViewKey(tpk: string | Group): Field;
185
220
  /**
186
221
  * Determines whether the account owns a ciphertext record.
187
222
  * @param {RecordCiphertext | string} ciphertext The record ciphertext to check ownership of
@@ -19,6 +19,8 @@ import { PlaintextArray } from "./models/plaintext/array.js";
19
19
  import { PlaintextLiteral } from "./models/plaintext/literal.js";
20
20
  import { PlaintextObject } from "./models/plaintext/plaintext.js";
21
21
  import { PlaintextStruct } from "./models/plaintext/struct.js";
22
+ import { ProvingRequestJSON } from "./models/provingRequest.js";
23
+ import { ProvingResponse } from "./models/provingResponse.js";
22
24
  import { RatificationJSON } from "./models/ratification.js";
23
25
  import { SolutionsJSON, SolutionJSON, PartialSolutionJSON } from "./models/solution.js";
24
26
  import { TransactionJSON } from "./models/transaction/transactionJSON.js";
@@ -29,10 +31,9 @@ import { AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, Cach
29
31
  import { OfflineKeyProvider, OfflineSearchParams } from "./offline-key-provider.js";
30
32
  import { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams } from "./record-provider.js";
31
33
  declare function initializeWasm(): Promise<void>;
32
- export { createAleoWorker } from "./managed-worker.js";
33
- export { ProgramManager } from "./program-manager.js";
34
+ export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions } from "./program-manager.js";
34
35
  export { logAndThrow } from "./utils.js";
35
- export { Address, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionResponse, Field, Group, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm.js";
36
+ export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, Group, OfflineQuery, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager as ProgramManagerBase, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, Transaction, Transition, VerifyingKey, ViewKey, initThreadPool, verifyFunctionExecution, } from "./wasm.js";
36
37
  export { initializeWasm };
37
38
  export { Key, CREDITS_PROGRAM_KEYS, KEY_STORE, PRIVATE_TRANSFER, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, PUBLIC_TO_PRIVATE_TRANSFER, VALID_TRANSFER_TYPES, } from "./constants.js";
38
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };
39
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, CachedKeyPair, ConfirmedTransactionJSON, DeploymentJSON, DeploymentObject, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, ImportedPrograms, ImportedVerifyingKeys, InputJSON, InputObject, KeySearchParams, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProvingRequestJSON, ProvingResponse, RatificationJSON, RecordProvider, RecordSearchParams, SolutionJSON, SolutionsJSON, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, VerifyingKeys, };