@provablehq/sdk 0.11.0 → 0.11.2

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 (43) hide show
  1. package/dist/mainnet/browser.cjs +295 -26
  2. package/dist/mainnet/browser.cjs.map +1 -1
  3. package/dist/mainnet/browser.d.cts +3 -2
  4. package/dist/mainnet/browser.d.ts +3 -2
  5. package/dist/mainnet/browser.js +294 -28
  6. package/dist/mainnet/browser.js.map +1 -1
  7. package/dist/mainnet/constants.d.cts +2 -0
  8. package/dist/mainnet/constants.d.ts +2 -0
  9. package/dist/mainnet/integrations/circle/hook-data.d.cts +2 -0
  10. package/dist/mainnet/integrations/circle/hook-data.d.ts +2 -0
  11. package/dist/mainnet/network-client.d.cts +2 -0
  12. package/dist/mainnet/network-client.d.ts +2 -0
  13. package/dist/mainnet/node.cjs +3 -0
  14. package/dist/mainnet/node.cjs.map +1 -1
  15. package/dist/mainnet/node.js +1 -1
  16. package/dist/mainnet/program-manager.d.cts +2 -2
  17. package/dist/mainnet/program-manager.d.ts +2 -2
  18. package/dist/mainnet/utils/index.d.cts +1 -1
  19. package/dist/mainnet/utils/index.d.ts +1 -1
  20. package/dist/mainnet/utils/utils.d.cts +21 -0
  21. package/dist/mainnet/utils/utils.d.ts +21 -0
  22. package/dist/testnet/browser.cjs +295 -26
  23. package/dist/testnet/browser.cjs.map +1 -1
  24. package/dist/testnet/browser.d.cts +3 -2
  25. package/dist/testnet/browser.d.ts +3 -2
  26. package/dist/testnet/browser.js +294 -28
  27. package/dist/testnet/browser.js.map +1 -1
  28. package/dist/testnet/constants.d.cts +2 -0
  29. package/dist/testnet/constants.d.ts +2 -0
  30. package/dist/testnet/integrations/circle/hook-data.d.cts +2 -0
  31. package/dist/testnet/integrations/circle/hook-data.d.ts +2 -0
  32. package/dist/testnet/network-client.d.cts +2 -0
  33. package/dist/testnet/network-client.d.ts +2 -0
  34. package/dist/testnet/node.cjs +3 -0
  35. package/dist/testnet/node.cjs.map +1 -1
  36. package/dist/testnet/node.js +1 -1
  37. package/dist/testnet/program-manager.d.cts +2 -2
  38. package/dist/testnet/program-manager.d.ts +2 -2
  39. package/dist/testnet/utils/index.d.cts +1 -1
  40. package/dist/testnet/utils/index.d.ts +1 -1
  41. package/dist/testnet/utils/utils.d.cts +21 -0
  42. package/dist/testnet/utils/utils.d.ts +21 -0
  43. package/package.json +2 -2
@@ -59,15 +59,16 @@ import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline
59
59
  import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
60
60
  import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./record-scanner.js";
61
61
  import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
62
+ import { generateHookData } from "./integrations/circle/hook-data.js";
62
63
  declare function initializeWasm(): Promise<void>;
63
64
  export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof, programChecksum } from "./program-manager.js";
64
- export { logAndThrow, TransportFunction } from "./utils/utils.js";
65
+ export { logAndThrow, TransportFunction, defaultTransport, cookieAffinityTransport } from "./utils/utils.js";
65
66
  export { setLogLevel, getLogLevel } from "./utils/logger.js";
66
67
  export type { LogLevel } from "./utils/logger.js";
67
68
  export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, DynamicRecord, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, QueryOption, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImportsBuilder, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, stringToField, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, setWasmLogLevel, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "./wasm.js";
68
69
  export { initializeWasm };
69
70
  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, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
70
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
71
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
71
72
  export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
72
73
  export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest, zeroizeBytes } from "./security.js";
73
74
  export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
@@ -59,15 +59,16 @@ import { OfflineKeyProvider, OfflineSearchParams } from "./keys/provider/offline
59
59
  import { BlockHeightSearch, NetworkRecordProvider, RecordProvider } from "./record-provider.js";
60
60
  import { RecordScanner, RecordScannerJWTData, RecordScannerOptions } from "./record-scanner.js";
61
61
  import { SealanceMerkleTree } from "./integrations/sealance/merkle-tree.js";
62
+ import { generateHookData } from "./integrations/circle/hook-data.js";
62
63
  declare function initializeWasm(): Promise<void>;
63
64
  export { ProgramManager, ProvingRequestOptions, ExecuteOptions, FeeAuthorizationOptions, AuthorizationOptions, VerificationOptions, BatchVerificationOptions, inputsToFields, verifyProof, verifyBatchProof, programChecksum } from "./program-manager.js";
64
- export { logAndThrow, TransportFunction } from "./utils/utils.js";
65
+ export { logAndThrow, TransportFunction, defaultTransport, cookieAffinityTransport } from "./utils/utils.js";
65
66
  export { setLogLevel, getLogLevel } from "./utils/logger.js";
66
67
  export type { LogLevel } from "./utils/logger.js";
67
68
  export { Address, Authorization, Boolean, BHP256, BHP512, BHP768, BHP1024, Ciphertext, ComputeKey, DynamicRecord, Execution as FunctionExecution, ExecutionRequest, ExecutionResponse, EncryptionToolkit, Field, GraphKey, Group, I8, I16, I32, I64, I128, OfflineQuery, QueryOption, Pedersen64, Pedersen128, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImportsBuilder, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, RecordCiphertext, RecordPlaintext, Signature, Scalar, stringToField, Transaction, Transition, U8, U16, U32, U64, U128, Value, VerifyingKey, ViewKey, initThreadPool, getOrInitConsensusVersionTestHeights, setWasmLogLevel, snarkVerify, snarkVerifyBatch, verifyFunctionExecution, } from "./wasm.js";
68
69
  export { initializeWasm };
69
70
  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, RECORD_DOMAIN, VALID_TRANSFER_TYPES, } from "./constants.js";
70
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
71
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, AleoNetworkClient, BlockJSON, BlockHeightSearch, BroadcastResponse, BroadcastResult, CachedKeyPair, ConfirmedTransactionJSON, CryptoBoxPubKey, DecryptionNotEnabledError, DeploymentJSON, DeploymentObject, EncryptedProvingRequest, EncryptedRecord, EncryptedRegistrationRequest, EncryptedRecordsResult, EncryptedRecordsSuccess, ExecutionJSON, ExecutionObject, FeeExecutionJSON, FeeExecutionObject, FinalizeJSON, FunctionInput, FunctionObject, FunctionKeyPair, FunctionKeyProvider, generateHookData, Header, isProvingResponse, isProveApiErrorBody, ImportedPrograms, ImportedVerifyingKeys, IndexedDBKeyStore, InputJSON, InputObject, InvalidLocatorError, InvalidLocatorReason, BaseFunctionKeyLocator, KeyFingerprint, KeyLocator, KeyMetadata, KeySearchParams, KeyStore, KeyType, KeyVerificationError, ProvingKeyLocator, provingKeyLocator, TranslationKeyLocator, translationKeyLocator, VerifyingKeyLocator, verifyingKeyLocator, KeyVerifier, MemKeyVerifier, Metadata, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, OutputJSON, OutputObject, OwnedFilter, OwnedRecord, OwnedRecordsResult, OwnedRecordsResponseFilter, OwnedRecordsSuccess, OwnerJSON, PartialSolutionJSON, PlaintextArray, PlaintextLiteral, PlaintextObject, PlaintextStruct, ProgramImports, ProveApiErrorBody, ProvingFailure, ProvingRequestError, ProvingRequestJSON, ProvingResult, ProvingSuccess, ProvingResponse, RatificationJSON, RecordsFilter, RecordsResponseFilter, RecordProvider, RecordScanner, RecordScannerErrorBody, RecordScannerFailure, RecordScannerJWTData, RecordScannerOptions, RecordNotFoundError, RecordScannerRequestError, ViewKeyNotStoredError, RecordSearchParams, RegisterResult, RegisterSuccess, RegistrationResponse, RevokeResult, RevokeSuccess, RevokeResponse, SealanceMerkleTree, SerialNumbersResult, SerialNumbersSuccess, sha256Hex, SolutionJSON, SolutionsJSON, StatusResponse, StatusResult, StatusSuccess, TagsResult, TagsSuccess, TransactionJSON, TransactionObject, TransitionJSON, TransitionObject, UUIDError, VerifyingKeys, };
71
72
  export { KeyVerificationError as ChecksumMismatchError, KeyVerifier as FunctionKeyVerifier, } from "./keys/verifier/interface.js";
72
73
  export { encryptAuthorization, encryptProvingRequest, encryptViewKey, encryptRegistrationRequest, zeroizeBytes } from "./security.js";
73
74
  export { toField, toGroup, toViewKey, toSignature, toAddress, isViewKeyStrategy, isInputIdStrategy, isRecordViewKeyStrategy, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, } from "./external-signing.js";
@@ -1,5 +1,5 @@
1
1
  import 'core-js/proposals/json-parse-with-source.js';
2
- import { ProvingKey, VerifyingKey, ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, Metadata, Program, Plaintext, Transaction, ProvingRequest, RecordPlaintext, Field, Poseidon4, ProgramManager as ProgramManager$1, CallbackQuery, ProgramImports, QueryOption, ExecutionRequest, stringToField, verifyFunctionExecution, Value, Proof, Signature } from '@provablehq/wasm/testnet.js';
2
+ import { ProvingKey, VerifyingKey, ViewKey, ComputeKey, Address, PrivateKeyCiphertext, PrivateKey, RecordCiphertext, EncryptionToolkit, Group, Metadata, Program, Plaintext, Transaction, ProvingRequest, RecordPlaintext, Field, Poseidon4, Scalar, BHP256, ProgramManager as ProgramManager$1, CallbackQuery, ProgramImports, QueryOption, ExecutionRequest, stringToField, verifyFunctionExecution, Value, Proof, Signature } from '@provablehq/wasm/testnet.js';
3
3
  export { Address, Authorization, BHP1024, BHP256, BHP512, BHP768, Boolean, Ciphertext, ComputeKey, DynamicRecord, EncryptionToolkit, ExecutionRequest, ExecutionResponse, Field, Execution as FunctionExecution, GraphKey, Group, I128, I16, I32, I64, I8, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramImports as ProgramImportsBuilder, ProgramManager as ProgramManagerBase, Proof, ProvingKey, ProvingRequest, QueryOption, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, U128, U16, U32, U64, U8, Value, VerifyingKey, ViewKey, getOrInitConsensusVersionTestHeights, initThreadPool, setWasmLogLevel, snarkVerify, snarkVerifyBatch, stringToField, verifyFunctionExecution } from '@provablehq/wasm/testnet.js';
4
4
  import { cryptoBoxSeal } from '@serenity-kit/noble-sodium';
5
5
  import { base64, bech32m } from '@scure/base';
@@ -1022,13 +1022,15 @@ class Account {
1022
1022
 
1023
1023
  function detectBrowser() {
1024
1024
  const userAgent = navigator.userAgent;
1025
- if (/chrome|crios|crmo/i.test(userAgent) && !/edge|edg|opr/i.test(userAgent)) {
1025
+ if (/chrome|crios|crmo/i.test(userAgent) &&
1026
+ !/edge|edg|opr/i.test(userAgent)) {
1026
1027
  return "chrome";
1027
1028
  }
1028
1029
  else if (/firefox|fxios/i.test(userAgent)) {
1029
1030
  return "firefox";
1030
1031
  }
1031
- else if (/safari/i.test(userAgent) && !/chrome|crios|crmo|android/i.test(userAgent)) {
1032
+ else if (/safari/i.test(userAgent) &&
1033
+ !/chrome|crios|crmo|android/i.test(userAgent)) {
1032
1034
  return "safari";
1033
1035
  }
1034
1036
  else if (/edg/i.test(userAgent)) {
@@ -1042,28 +1044,263 @@ function detectBrowser() {
1042
1044
  }
1043
1045
  }
1044
1046
  function isNode() {
1045
- return typeof process !== "undefined" &&
1047
+ return (typeof process !== "undefined" &&
1046
1048
  process.versions != null &&
1047
- process.versions.node != null;
1049
+ process.versions.node != null);
1048
1050
  }
1049
1051
  function environment() {
1050
- if ((typeof process !== 'undefined') &&
1051
- (process.release?.name === 'node')) {
1052
- return 'node';
1052
+ if (typeof process !== "undefined" && process.release?.name === "node") {
1053
+ return "node";
1053
1054
  }
1054
- else if (typeof window !== 'undefined') {
1055
+ else if (typeof window !== "undefined") {
1055
1056
  return detectBrowser();
1056
1057
  }
1057
1058
  else {
1058
- return 'unknown';
1059
+ return "unknown";
1059
1060
  }
1060
1061
  }
1061
1062
  function logAndThrow(message) {
1062
1063
  logger.error(message);
1063
1064
  throw new Error(message);
1064
1065
  }
1066
+ /*
1067
+ * Per-origin cookie jar used by `cookieAffinityTransport`.
1068
+ *
1069
+ * Some Aleo backends sit behind a gateway (e.g. Kong) that uses cookie-based
1070
+ * session affinity: the server sets a routing cookie on the first response and
1071
+ * expects it back on subsequent requests so per-session state stays on the same
1072
+ * upstream instance. Browsers and iOS NSURLSession persist cookies automatically,
1073
+ * but Node `fetch` and bare React Native do not — without a jar, those runtimes
1074
+ * land on a random upstream per request.
1075
+ *
1076
+ * Only cookies named in `AFFINITY_COOKIE_NAMES` are captured. The jar is
1077
+ * module-scoped — the same process shares routing cookies per origin — but the
1078
+ * whitelist keeps unrelated cookies (auth, session, CSRF) out of it, so other
1079
+ * SDK clients hitting the same origin can't accidentally inherit caller state.
1080
+ *
1081
+ * In a browser this jar is effectively a no-op: `Cookie` is a forbidden request
1082
+ * header, so the manual value set here is dropped by the browser and the
1083
+ * browser's own cookie store takes over.
1084
+ */
1085
+ const AFFINITY_COOKIE_NAMES = new Set(["route"]);
1086
+ const cookieJar = new Map();
1087
+ function isRequestLike(value) {
1088
+ return (typeof Request !== "undefined" &&
1089
+ value !== null &&
1090
+ typeof value === "object" &&
1091
+ value instanceof Request);
1092
+ }
1093
+ function isHeadersLike(value) {
1094
+ return (typeof Headers !== "undefined" &&
1095
+ value !== null &&
1096
+ typeof value === "object" &&
1097
+ value instanceof Headers);
1098
+ }
1099
+ function originOf(urlOrReq) {
1100
+ try {
1101
+ const raw = typeof urlOrReq === "string"
1102
+ ? urlOrReq
1103
+ : urlOrReq instanceof URL
1104
+ ? urlOrReq.toString()
1105
+ : isRequestLike(urlOrReq)
1106
+ ? urlOrReq.url
1107
+ : String(urlOrReq);
1108
+ const parsed = new URL(raw);
1109
+ return `${parsed.protocol}//${parsed.host}`;
1110
+ }
1111
+ catch {
1112
+ return null;
1113
+ }
1114
+ }
1115
+ /*
1116
+ * Derives the origin a response's `Set-Cookie` belongs to. `fetch` may follow
1117
+ * redirects across origins (or http→https), in which case the final response
1118
+ * headers belong to `response.url`'s origin, not the request input's. Returns
1119
+ * null when the response has no usable `url` (e.g. the minimal response-like
1120
+ * objects existing SDK tests stub fetch with), so callers can fall back to the
1121
+ * request-derived origin.
1122
+ */
1123
+ function responseOriginOf(response) {
1124
+ if (!response || typeof response !== "object")
1125
+ return null;
1126
+ const url = response.url;
1127
+ if (typeof url !== "string" || url.length === 0)
1128
+ return null;
1129
+ return originOf(url);
1130
+ }
1131
+ function cookieHeaderFor(origin) {
1132
+ if (!origin)
1133
+ return null;
1134
+ const jar = cookieJar.get(origin);
1135
+ if (!jar || jar.size === 0)
1136
+ return null;
1137
+ const parts = [];
1138
+ for (const [name, value] of jar)
1139
+ parts.push(`${name}=${value}`);
1140
+ return parts.join("; ");
1141
+ }
1142
+ /*
1143
+ * Reads Set-Cookie values from a fetch-style response in a defensive way.
1144
+ * Existing test mocks return minimal response-like objects without a
1145
+ * `headers` field, and Node's fetch surfaces multiple Set-Cookie headers via
1146
+ * `getSetCookie()` (not `get('set-cookie')`, which returns null or a
1147
+ * comma-joined string depending on the implementation).
1148
+ */
1149
+ function readSetCookies(response) {
1150
+ if (!response || typeof response !== "object")
1151
+ return [];
1152
+ const headers = response.headers;
1153
+ if (!headers || typeof headers !== "object")
1154
+ return [];
1155
+ const getSetCookie = headers
1156
+ .getSetCookie;
1157
+ if (typeof getSetCookie === "function") {
1158
+ try {
1159
+ const list = getSetCookie.call(headers);
1160
+ if (Array.isArray(list) && list.length > 0)
1161
+ return list;
1162
+ }
1163
+ catch {
1164
+ // fall through to .get()
1165
+ }
1166
+ }
1167
+ const get = headers.get;
1168
+ if (typeof get !== "function")
1169
+ return [];
1170
+ let raw;
1171
+ try {
1172
+ raw = get.call(headers, "set-cookie");
1173
+ }
1174
+ catch {
1175
+ return [];
1176
+ }
1177
+ if (!raw)
1178
+ return [];
1179
+ // Some older runtimes comma-join multiple Set-Cookie headers into a
1180
+ // single string. Split only when the comma is followed by a likely
1181
+ // new cookie name (`alpha[\w-]*=`), which excludes commas inside
1182
+ // `Expires=Wed, 21 Oct 2015 …` date attributes.
1183
+ return raw.split(/, (?=[A-Za-z][\w-]*=)/);
1184
+ }
1185
+ function storeSetCookies(origin, cookies) {
1186
+ if (!origin || cookies.length === 0)
1187
+ return;
1188
+ let jar;
1189
+ for (const cookie of cookies) {
1190
+ if (typeof cookie !== "string" || !cookie)
1191
+ continue;
1192
+ const head = cookie.split(";")[0];
1193
+ const eq = head.indexOf("=");
1194
+ if (eq <= 0)
1195
+ continue;
1196
+ const name = head.slice(0, eq).trim();
1197
+ if (!AFFINITY_COOKIE_NAMES.has(name))
1198
+ continue;
1199
+ if (!jar) {
1200
+ jar = cookieJar.get(origin);
1201
+ if (!jar) {
1202
+ jar = new Map();
1203
+ cookieJar.set(origin, jar);
1204
+ }
1205
+ }
1206
+ jar.set(name, head.slice(eq + 1).trim());
1207
+ }
1208
+ }
1209
+ /*
1210
+ * Returns a fresh HeadersInit with `cookie` attached when the input doesn't
1211
+ * already carry one. NEVER mutates the caller's input — a caller reusing the
1212
+ * same Headers/init across calls to different origins must not see origin A's
1213
+ * jar cookie persist into the call for origin B.
1214
+ */
1215
+ function attachCookie(headersInit, cookie) {
1216
+ if (isHeadersLike(headersInit)) {
1217
+ if (headersInit.has("cookie"))
1218
+ return headersInit;
1219
+ const cloned = new Headers(headersInit);
1220
+ cloned.set("cookie", cookie);
1221
+ return cloned;
1222
+ }
1223
+ if (Array.isArray(headersInit)) {
1224
+ const hasCookie = headersInit.some((pair) => Array.isArray(pair) &&
1225
+ typeof pair[0] === "string" &&
1226
+ pair[0].toLowerCase() === "cookie");
1227
+ return hasCookie ? headersInit : [...headersInit, ["cookie", cookie]];
1228
+ }
1229
+ if (headersInit && typeof headersInit === "object") {
1230
+ const hasCookie = Object.keys(headersInit).some((key) => key.toLowerCase() === "cookie");
1231
+ return hasCookie ? headersInit : { ...headersInit, cookie };
1232
+ }
1233
+ return { cookie };
1234
+ }
1065
1235
  /** Default transport — wraps global fetch to avoid illegal-invocation errors in browsers. */
1066
1236
  const defaultTransport = (...args) => fetch(...args);
1237
+ /**
1238
+ * Opt-in transport that layers a per-origin cookie jar on top of `fetch`.
1239
+ *
1240
+ * Not wired in by default — pass it explicitly as the `transport` option to
1241
+ * `AleoNetworkClient`, `RecordScanner`, `AleoKeyProvider`, etc. (or to the
1242
+ * `get`/`post` helpers) when talking to a backend that uses cookie-based
1243
+ * session affinity. Browsers and iOS NSURLSession persist cookies on their own,
1244
+ * so this is targeted at Node and bare React Native consumers.
1245
+ *
1246
+ * Wraps the global `fetch` (avoiding illegal-invocation errors in browsers when
1247
+ * `fetch` is passed around as a bare reference) and layers a per-origin cookie
1248
+ * jar on top. Responses' `Set-Cookie` headers are captured (filtered by
1249
+ * `AFFINITY_COOKIE_NAMES`) and replayed as a `Cookie` header on subsequent
1250
+ * same-origin requests, which is required for backends that use cookie-based
1251
+ * session affinity (see `cookieJar` above).
1252
+ *
1253
+ * A caller-supplied `Cookie` header is never overwritten — `network-client.ts`
1254
+ * forwards the pubkey-response cookie manually onto delegated-prove requests
1255
+ * for Node compatibility, and that path takes precedence over the jar.
1256
+ */
1257
+ const cookieAffinityTransport = async (input, init) => {
1258
+ const origin = originOf(input);
1259
+ const cookie = cookieHeaderFor(origin);
1260
+ if (cookie) {
1261
+ // Always operate on shallow clones so callers reusing the same
1262
+ // `init` / `Headers` / `Request` across origins don't end up with
1263
+ // origin A's jar cookie persisting into the object and blocking
1264
+ // origin B's correct cookie.
1265
+ if (init?.headers !== undefined && init.headers !== null) {
1266
+ // init.headers, when explicitly set, REPLACES the Request's
1267
+ // headers per the Fetch spec — attach there.
1268
+ init = { ...init, headers: attachCookie(init.headers, cookie) };
1269
+ }
1270
+ else if (isRequestLike(input)) {
1271
+ // Merge the Request's existing headers with the cookie and
1272
+ // pass them via `init.headers` instead of mutating the
1273
+ // Request itself. (Fetch spec: an explicit `init.headers`
1274
+ // replaces Request.headers entirely, so we copy the
1275
+ // originals into the merged set first.)
1276
+ try {
1277
+ const merged = new Headers(input.headers);
1278
+ if (!merged.has("cookie")) {
1279
+ merged.set("cookie", cookie);
1280
+ init = { ...(init ?? {}), headers: merged };
1281
+ }
1282
+ }
1283
+ catch {
1284
+ // Some runtimes restrict Headers construction from a
1285
+ // Request; skip rather than failing the request.
1286
+ }
1287
+ }
1288
+ else if (init) {
1289
+ init = { ...init, headers: attachCookie(undefined, cookie) };
1290
+ }
1291
+ else {
1292
+ init = { headers: attachCookie(undefined, cookie) };
1293
+ }
1294
+ }
1295
+ const response = await fetch(input, init);
1296
+ // A response's `Set-Cookie` belongs to the final response URL's origin,
1297
+ // which can differ from the request input's when fetch follows redirects
1298
+ // (cross-origin or http→https). Prefer `response.url`; fall back to the
1299
+ // request origin for minimal mocked responses that don't expose a `url`.
1300
+ const responseOrigin = responseOriginOf(response) ?? origin;
1301
+ storeSetCookies(responseOrigin, readSetCookies(response));
1302
+ return response;
1303
+ };
1067
1304
  function parseJSON(json) {
1068
1305
  function revive(key, value, context) {
1069
1306
  if (Number.isInteger(value)) {
@@ -1242,6 +1479,11 @@ const RECORD_DOMAIN = "RecordScannerV0";
1242
1479
  const ZERO_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
1243
1480
  const FIVE_MINUTES = 5 * 60 * 1000; // 5 minutes in milliseconds
1244
1481
 
1482
+ const HEADERS = new Set([
1483
+ "x-aleo-sdk-version",
1484
+ "x-aleo-environment",
1485
+ "x-aleo-method",
1486
+ ]);
1245
1487
  /**
1246
1488
  * Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
1247
1489
  * allow users to query public information from the Aleo blockchain and submit transactions to the network.
@@ -1289,7 +1531,7 @@ class AleoNetworkClient {
1289
1531
  else {
1290
1532
  this.headers = {
1291
1533
  // This is replaced by the actual version by a Rollup plugin
1292
- "X-Aleo-SDK-Version": "0.11.0",
1534
+ "X-Aleo-SDK-Version": "0.11.2",
1293
1535
  "X-Aleo-environment": environment(),
1294
1536
  };
1295
1537
  }
@@ -1305,7 +1547,7 @@ class AleoNetworkClient {
1305
1547
  else {
1306
1548
  this.headers = {
1307
1549
  // This is replaced by the actual version by a Rollup plugin
1308
- "X-Aleo-SDK-Version": "0.11.0",
1550
+ "X-Aleo-SDK-Version": "0.11.2",
1309
1551
  "X-Aleo-environment": environment(),
1310
1552
  };
1311
1553
  }
@@ -1421,6 +1663,21 @@ class AleoNetworkClient {
1421
1663
  removeHeader(headerName) {
1422
1664
  delete this.headers[headerName];
1423
1665
  }
1666
+ userHeaders() {
1667
+ const result = {};
1668
+ for (const [key, value] of Object.entries(this.headers)) {
1669
+ if (!HEADERS.has(key.toLowerCase())) {
1670
+ result[key] = value;
1671
+ }
1672
+ }
1673
+ return result;
1674
+ }
1675
+ method(method) {
1676
+ if (this.hasCustomTransport) {
1677
+ return this.userHeaders();
1678
+ }
1679
+ return { ...this.headers, "X-ALEO-METHOD": method };
1680
+ }
1424
1681
  /**
1425
1682
  * Fetches data from the Aleo network and returns it as a JSON object.
1426
1683
  *
@@ -1448,10 +1705,9 @@ class AleoNetworkClient {
1448
1705
  const ctx = { ...this.ctx };
1449
1706
  return await retryWithBackoff(async () => {
1450
1707
  const response = await get(this.host + url, {
1451
- headers: {
1452
- ...this.headers,
1453
- ...ctx,
1454
- },
1708
+ headers: this.hasCustomTransport
1709
+ ? this.userHeaders()
1710
+ : { ...this.headers, ...ctx },
1455
1711
  }, this.transport);
1456
1712
  return await response.text();
1457
1713
  });
@@ -2683,7 +2939,7 @@ class AleoNetworkClient {
2683
2939
  const endpoint = this.verboseErrors ? "transaction/broadcast?check_transaction=true" : "transaction/broadcast";
2684
2940
  const response = await retryWithBackoff(() => this._sendPost(`${this.host}/${endpoint}`, {
2685
2941
  body: transactionString,
2686
- headers: Object.assign({}, { ...this.headers, "X-ALEO-METHOD": "submitTransaction" }, {
2942
+ headers: Object.assign({}, this.method("submitTransaction"), {
2687
2943
  "Content-Type": "application/json",
2688
2944
  }),
2689
2945
  }));
@@ -2709,7 +2965,7 @@ class AleoNetworkClient {
2709
2965
  try {
2710
2966
  const response = await retryWithBackoff(() => post(this.host + "/solution/broadcast", {
2711
2967
  body: solution,
2712
- headers: Object.assign({}, { ...this.headers, "X-ALEO-METHOD": "submitSolution" }, {
2968
+ headers: Object.assign({}, this.method("submitSolution"), {
2713
2969
  "Content-Type": "application/json",
2714
2970
  }),
2715
2971
  }, this.transport));
@@ -2738,7 +2994,8 @@ class AleoNetworkClient {
2738
2994
  }
2739
2995
  const response = await post(`${this.baseUrl}/jwts/${consumerId}`, {
2740
2996
  headers: {
2741
- 'X-Provable-API-Key': apiKey
2997
+ ...this.method("refreshJwt"),
2998
+ 'X-Provable-API-Key': apiKey,
2742
2999
  }
2743
3000
  }, this.transport);
2744
3001
  const authHeader = response.headers.get('authorization');
@@ -2832,8 +3089,7 @@ class AleoNetworkClient {
2832
3089
  }
2833
3090
  // Create the necessary headers to hit the provable api.
2834
3091
  const headers = {
2835
- ...this.headers,
2836
- "X-ALEO-METHOD": "submitProvingRequest",
3092
+ ...this.method("submitProvingRequest"),
2837
3093
  "Content-Type": "application/json",
2838
3094
  };
2839
3095
  if (jwtData?.jwt) {
@@ -2947,10 +3203,7 @@ class AleoNetworkClient {
2947
3203
  }
2948
3204
  try {
2949
3205
  const res = await this.transport(`${this.host}/transaction/confirmed/${transactionId}`, {
2950
- headers: {
2951
- ...this.headers,
2952
- "X-ALEO-METHOD": "waitForTransactionConfirmation",
2953
- },
3206
+ headers: this.method("waitForTransactionConfirmation"),
2954
3207
  });
2955
3208
  if (!res.ok) {
2956
3209
  let text = "";
@@ -5461,6 +5714,19 @@ class SealanceMerkleTree {
5461
5714
  }
5462
5715
  }
5463
5716
 
5717
+ // This method generates the hook data for the Circle USDCx shielded mint flow.
5718
+ function generateHookData(recipientAddress, secretNonce) {
5719
+ // Leo's BHP256::commit_to_field uses the typed plaintext bits, not raw address bits.
5720
+ const recipientBits = Plaintext.fromString(recipientAddress).toBitsLe();
5721
+ const secret = Scalar.fromString(secretNonce);
5722
+ const committedField = new BHP256().commit(recipientBits, secret);
5723
+ const committedBytes = committedField.toBytesLe();
5724
+ const hookData = new Uint8Array(65);
5725
+ hookData[0] = 2;
5726
+ hookData.set(committedBytes, 1);
5727
+ return hookData;
5728
+ }
5729
+
5464
5730
  /**
5465
5731
  * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
5466
5732
  */
@@ -8198,7 +8464,7 @@ class ProgramManager {
8198
8464
  * import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
8199
8465
  *
8200
8466
  * // Initialize the development consensus heights in order to work with devnode.
8201
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
8467
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
8202
8468
  *
8203
8469
  * // Create a new NetworkClient and RecordProvider.
8204
8470
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
@@ -8325,7 +8591,7 @@ class ProgramManager {
8325
8591
  * import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
8326
8592
  *
8327
8593
  * // Initialize the development consensus heights in order to work with a local devnode.
8328
- * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
8594
+ * getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
8329
8595
  *
8330
8596
  * // Create a new NetworkClient, and RecordProvider
8331
8597
  * const recordProvider = new NetworkRecordProvider(account, networkClient);
@@ -8871,5 +9137,5 @@ async function initializeWasm() {
8871
9137
  logger.warn("initializeWasm is deprecated, you no longer need to use it");
8872
9138
  }
8873
9139
 
8874
- export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptViewKey, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, programChecksum, provingKeyLocator, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
9140
+ export { Account, AleoKeyProvider, AleoKeyProviderParams, AleoNetworkClient, BlockHeightSearch, CREDITS_PROGRAM_KEYS, KeyVerificationError as ChecksumMismatchError, DecryptionNotEnabledError, IndexedDBKeyStore, InvalidLocatorError, KEY_STORE, KeyVerificationError, MemKeyVerifier, NetworkRecordProvider, OfflineKeyProvider, OfflineSearchParams, PRIVATE_TO_PUBLIC_TRANSFER, PRIVATE_TRANSFER, PRIVATE_TRANSFER_TYPES, PUBLIC_TO_PRIVATE_TRANSFER, PUBLIC_TRANSFER, PUBLIC_TRANSFER_AS_SIGNER, ProgramManager, RECORD_DOMAIN, RecordNotFoundError, RecordScanner, RecordScannerRequestError, SealanceMerkleTree, UUIDError, VALID_TRANSFER_TYPES, ViewKeyNotStoredError, buildExecutionRequestFromExternallySignedData, computeExternalSigningInputs, cookieAffinityTransport, defaultTransport, encryptAuthorization, encryptProvingRequest, encryptRegistrationRequest, encryptViewKey, generateHookData, getLogLevel, initializeWasm, inputsToFields, isInputIdStrategy, isProveApiErrorBody, isProvingResponse, isRecordViewKeyStrategy, isViewKeyStrategy, logAndThrow, programChecksum, provingKeyLocator, setLogLevel, sha256Hex, toAddress, toField, toGroup, toSignature, toViewKey, translationKeyLocator, verifyBatchProof, verifyProof, verifyingKeyLocator, zeroizeBytes };
8875
9141
  //# sourceMappingURL=browser.js.map