@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.
- package/dist/mainnet/browser.cjs +295 -26
- package/dist/mainnet/browser.cjs.map +1 -1
- package/dist/mainnet/browser.d.cts +3 -2
- package/dist/mainnet/browser.d.ts +3 -2
- package/dist/mainnet/browser.js +294 -28
- package/dist/mainnet/browser.js.map +1 -1
- package/dist/mainnet/constants.d.cts +2 -0
- package/dist/mainnet/constants.d.ts +2 -0
- package/dist/mainnet/integrations/circle/hook-data.d.cts +2 -0
- package/dist/mainnet/integrations/circle/hook-data.d.ts +2 -0
- package/dist/mainnet/network-client.d.cts +2 -0
- package/dist/mainnet/network-client.d.ts +2 -0
- package/dist/mainnet/node.cjs +3 -0
- package/dist/mainnet/node.cjs.map +1 -1
- package/dist/mainnet/node.js +1 -1
- package/dist/mainnet/program-manager.d.cts +2 -2
- package/dist/mainnet/program-manager.d.ts +2 -2
- package/dist/mainnet/utils/index.d.cts +1 -1
- package/dist/mainnet/utils/index.d.ts +1 -1
- package/dist/mainnet/utils/utils.d.cts +21 -0
- package/dist/mainnet/utils/utils.d.ts +21 -0
- package/dist/testnet/browser.cjs +295 -26
- package/dist/testnet/browser.cjs.map +1 -1
- package/dist/testnet/browser.d.cts +3 -2
- package/dist/testnet/browser.d.ts +3 -2
- package/dist/testnet/browser.js +294 -28
- package/dist/testnet/browser.js.map +1 -1
- package/dist/testnet/constants.d.cts +2 -0
- package/dist/testnet/constants.d.ts +2 -0
- package/dist/testnet/integrations/circle/hook-data.d.cts +2 -0
- package/dist/testnet/integrations/circle/hook-data.d.ts +2 -0
- package/dist/testnet/network-client.d.cts +2 -0
- package/dist/testnet/network-client.d.ts +2 -0
- package/dist/testnet/node.cjs +3 -0
- package/dist/testnet/node.cjs.map +1 -1
- package/dist/testnet/node.js +1 -1
- package/dist/testnet/program-manager.d.cts +2 -2
- package/dist/testnet/program-manager.d.ts +2 -2
- package/dist/testnet/utils/index.d.cts +1 -1
- package/dist/testnet/utils/index.d.ts +1 -1
- package/dist/testnet/utils/utils.d.cts +21 -0
- package/dist/testnet/utils/utils.d.ts +21 -0
- package/package.json +2 -2
package/dist/mainnet/browser.cjs
CHANGED
|
@@ -1023,13 +1023,15 @@ class Account {
|
|
|
1023
1023
|
|
|
1024
1024
|
function detectBrowser() {
|
|
1025
1025
|
const userAgent = navigator.userAgent;
|
|
1026
|
-
if (/chrome|crios|crmo/i.test(userAgent) &&
|
|
1026
|
+
if (/chrome|crios|crmo/i.test(userAgent) &&
|
|
1027
|
+
!/edge|edg|opr/i.test(userAgent)) {
|
|
1027
1028
|
return "chrome";
|
|
1028
1029
|
}
|
|
1029
1030
|
else if (/firefox|fxios/i.test(userAgent)) {
|
|
1030
1031
|
return "firefox";
|
|
1031
1032
|
}
|
|
1032
|
-
else if (/safari/i.test(userAgent) &&
|
|
1033
|
+
else if (/safari/i.test(userAgent) &&
|
|
1034
|
+
!/chrome|crios|crmo|android/i.test(userAgent)) {
|
|
1033
1035
|
return "safari";
|
|
1034
1036
|
}
|
|
1035
1037
|
else if (/edg/i.test(userAgent)) {
|
|
@@ -1043,28 +1045,263 @@ function detectBrowser() {
|
|
|
1043
1045
|
}
|
|
1044
1046
|
}
|
|
1045
1047
|
function isNode() {
|
|
1046
|
-
return typeof process !== "undefined" &&
|
|
1048
|
+
return (typeof process !== "undefined" &&
|
|
1047
1049
|
process.versions != null &&
|
|
1048
|
-
process.versions.node != null;
|
|
1050
|
+
process.versions.node != null);
|
|
1049
1051
|
}
|
|
1050
1052
|
function environment() {
|
|
1051
|
-
if (
|
|
1052
|
-
|
|
1053
|
-
return 'node';
|
|
1053
|
+
if (typeof process !== "undefined" && process.release?.name === "node") {
|
|
1054
|
+
return "node";
|
|
1054
1055
|
}
|
|
1055
|
-
else if (typeof window !==
|
|
1056
|
+
else if (typeof window !== "undefined") {
|
|
1056
1057
|
return detectBrowser();
|
|
1057
1058
|
}
|
|
1058
1059
|
else {
|
|
1059
|
-
return
|
|
1060
|
+
return "unknown";
|
|
1060
1061
|
}
|
|
1061
1062
|
}
|
|
1062
1063
|
function logAndThrow(message) {
|
|
1063
1064
|
logger.error(message);
|
|
1064
1065
|
throw new Error(message);
|
|
1065
1066
|
}
|
|
1067
|
+
/*
|
|
1068
|
+
* Per-origin cookie jar used by `cookieAffinityTransport`.
|
|
1069
|
+
*
|
|
1070
|
+
* Some Aleo backends sit behind a gateway (e.g. Kong) that uses cookie-based
|
|
1071
|
+
* session affinity: the server sets a routing cookie on the first response and
|
|
1072
|
+
* expects it back on subsequent requests so per-session state stays on the same
|
|
1073
|
+
* upstream instance. Browsers and iOS NSURLSession persist cookies automatically,
|
|
1074
|
+
* but Node `fetch` and bare React Native do not — without a jar, those runtimes
|
|
1075
|
+
* land on a random upstream per request.
|
|
1076
|
+
*
|
|
1077
|
+
* Only cookies named in `AFFINITY_COOKIE_NAMES` are captured. The jar is
|
|
1078
|
+
* module-scoped — the same process shares routing cookies per origin — but the
|
|
1079
|
+
* whitelist keeps unrelated cookies (auth, session, CSRF) out of it, so other
|
|
1080
|
+
* SDK clients hitting the same origin can't accidentally inherit caller state.
|
|
1081
|
+
*
|
|
1082
|
+
* In a browser this jar is effectively a no-op: `Cookie` is a forbidden request
|
|
1083
|
+
* header, so the manual value set here is dropped by the browser and the
|
|
1084
|
+
* browser's own cookie store takes over.
|
|
1085
|
+
*/
|
|
1086
|
+
const AFFINITY_COOKIE_NAMES = new Set(["route"]);
|
|
1087
|
+
const cookieJar = new Map();
|
|
1088
|
+
function isRequestLike(value) {
|
|
1089
|
+
return (typeof Request !== "undefined" &&
|
|
1090
|
+
value !== null &&
|
|
1091
|
+
typeof value === "object" &&
|
|
1092
|
+
value instanceof Request);
|
|
1093
|
+
}
|
|
1094
|
+
function isHeadersLike(value) {
|
|
1095
|
+
return (typeof Headers !== "undefined" &&
|
|
1096
|
+
value !== null &&
|
|
1097
|
+
typeof value === "object" &&
|
|
1098
|
+
value instanceof Headers);
|
|
1099
|
+
}
|
|
1100
|
+
function originOf(urlOrReq) {
|
|
1101
|
+
try {
|
|
1102
|
+
const raw = typeof urlOrReq === "string"
|
|
1103
|
+
? urlOrReq
|
|
1104
|
+
: urlOrReq instanceof URL
|
|
1105
|
+
? urlOrReq.toString()
|
|
1106
|
+
: isRequestLike(urlOrReq)
|
|
1107
|
+
? urlOrReq.url
|
|
1108
|
+
: String(urlOrReq);
|
|
1109
|
+
const parsed = new URL(raw);
|
|
1110
|
+
return `${parsed.protocol}//${parsed.host}`;
|
|
1111
|
+
}
|
|
1112
|
+
catch {
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
/*
|
|
1117
|
+
* Derives the origin a response's `Set-Cookie` belongs to. `fetch` may follow
|
|
1118
|
+
* redirects across origins (or http→https), in which case the final response
|
|
1119
|
+
* headers belong to `response.url`'s origin, not the request input's. Returns
|
|
1120
|
+
* null when the response has no usable `url` (e.g. the minimal response-like
|
|
1121
|
+
* objects existing SDK tests stub fetch with), so callers can fall back to the
|
|
1122
|
+
* request-derived origin.
|
|
1123
|
+
*/
|
|
1124
|
+
function responseOriginOf(response) {
|
|
1125
|
+
if (!response || typeof response !== "object")
|
|
1126
|
+
return null;
|
|
1127
|
+
const url = response.url;
|
|
1128
|
+
if (typeof url !== "string" || url.length === 0)
|
|
1129
|
+
return null;
|
|
1130
|
+
return originOf(url);
|
|
1131
|
+
}
|
|
1132
|
+
function cookieHeaderFor(origin) {
|
|
1133
|
+
if (!origin)
|
|
1134
|
+
return null;
|
|
1135
|
+
const jar = cookieJar.get(origin);
|
|
1136
|
+
if (!jar || jar.size === 0)
|
|
1137
|
+
return null;
|
|
1138
|
+
const parts = [];
|
|
1139
|
+
for (const [name, value] of jar)
|
|
1140
|
+
parts.push(`${name}=${value}`);
|
|
1141
|
+
return parts.join("; ");
|
|
1142
|
+
}
|
|
1143
|
+
/*
|
|
1144
|
+
* Reads Set-Cookie values from a fetch-style response in a defensive way.
|
|
1145
|
+
* Existing test mocks return minimal response-like objects without a
|
|
1146
|
+
* `headers` field, and Node's fetch surfaces multiple Set-Cookie headers via
|
|
1147
|
+
* `getSetCookie()` (not `get('set-cookie')`, which returns null or a
|
|
1148
|
+
* comma-joined string depending on the implementation).
|
|
1149
|
+
*/
|
|
1150
|
+
function readSetCookies(response) {
|
|
1151
|
+
if (!response || typeof response !== "object")
|
|
1152
|
+
return [];
|
|
1153
|
+
const headers = response.headers;
|
|
1154
|
+
if (!headers || typeof headers !== "object")
|
|
1155
|
+
return [];
|
|
1156
|
+
const getSetCookie = headers
|
|
1157
|
+
.getSetCookie;
|
|
1158
|
+
if (typeof getSetCookie === "function") {
|
|
1159
|
+
try {
|
|
1160
|
+
const list = getSetCookie.call(headers);
|
|
1161
|
+
if (Array.isArray(list) && list.length > 0)
|
|
1162
|
+
return list;
|
|
1163
|
+
}
|
|
1164
|
+
catch {
|
|
1165
|
+
// fall through to .get()
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
const get = headers.get;
|
|
1169
|
+
if (typeof get !== "function")
|
|
1170
|
+
return [];
|
|
1171
|
+
let raw;
|
|
1172
|
+
try {
|
|
1173
|
+
raw = get.call(headers, "set-cookie");
|
|
1174
|
+
}
|
|
1175
|
+
catch {
|
|
1176
|
+
return [];
|
|
1177
|
+
}
|
|
1178
|
+
if (!raw)
|
|
1179
|
+
return [];
|
|
1180
|
+
// Some older runtimes comma-join multiple Set-Cookie headers into a
|
|
1181
|
+
// single string. Split only when the comma is followed by a likely
|
|
1182
|
+
// new cookie name (`alpha[\w-]*=`), which excludes commas inside
|
|
1183
|
+
// `Expires=Wed, 21 Oct 2015 …` date attributes.
|
|
1184
|
+
return raw.split(/, (?=[A-Za-z][\w-]*=)/);
|
|
1185
|
+
}
|
|
1186
|
+
function storeSetCookies(origin, cookies) {
|
|
1187
|
+
if (!origin || cookies.length === 0)
|
|
1188
|
+
return;
|
|
1189
|
+
let jar;
|
|
1190
|
+
for (const cookie of cookies) {
|
|
1191
|
+
if (typeof cookie !== "string" || !cookie)
|
|
1192
|
+
continue;
|
|
1193
|
+
const head = cookie.split(";")[0];
|
|
1194
|
+
const eq = head.indexOf("=");
|
|
1195
|
+
if (eq <= 0)
|
|
1196
|
+
continue;
|
|
1197
|
+
const name = head.slice(0, eq).trim();
|
|
1198
|
+
if (!AFFINITY_COOKIE_NAMES.has(name))
|
|
1199
|
+
continue;
|
|
1200
|
+
if (!jar) {
|
|
1201
|
+
jar = cookieJar.get(origin);
|
|
1202
|
+
if (!jar) {
|
|
1203
|
+
jar = new Map();
|
|
1204
|
+
cookieJar.set(origin, jar);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
jar.set(name, head.slice(eq + 1).trim());
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
/*
|
|
1211
|
+
* Returns a fresh HeadersInit with `cookie` attached when the input doesn't
|
|
1212
|
+
* already carry one. NEVER mutates the caller's input — a caller reusing the
|
|
1213
|
+
* same Headers/init across calls to different origins must not see origin A's
|
|
1214
|
+
* jar cookie persist into the call for origin B.
|
|
1215
|
+
*/
|
|
1216
|
+
function attachCookie(headersInit, cookie) {
|
|
1217
|
+
if (isHeadersLike(headersInit)) {
|
|
1218
|
+
if (headersInit.has("cookie"))
|
|
1219
|
+
return headersInit;
|
|
1220
|
+
const cloned = new Headers(headersInit);
|
|
1221
|
+
cloned.set("cookie", cookie);
|
|
1222
|
+
return cloned;
|
|
1223
|
+
}
|
|
1224
|
+
if (Array.isArray(headersInit)) {
|
|
1225
|
+
const hasCookie = headersInit.some((pair) => Array.isArray(pair) &&
|
|
1226
|
+
typeof pair[0] === "string" &&
|
|
1227
|
+
pair[0].toLowerCase() === "cookie");
|
|
1228
|
+
return hasCookie ? headersInit : [...headersInit, ["cookie", cookie]];
|
|
1229
|
+
}
|
|
1230
|
+
if (headersInit && typeof headersInit === "object") {
|
|
1231
|
+
const hasCookie = Object.keys(headersInit).some((key) => key.toLowerCase() === "cookie");
|
|
1232
|
+
return hasCookie ? headersInit : { ...headersInit, cookie };
|
|
1233
|
+
}
|
|
1234
|
+
return { cookie };
|
|
1235
|
+
}
|
|
1066
1236
|
/** Default transport — wraps global fetch to avoid illegal-invocation errors in browsers. */
|
|
1067
1237
|
const defaultTransport = (...args) => fetch(...args);
|
|
1238
|
+
/**
|
|
1239
|
+
* Opt-in transport that layers a per-origin cookie jar on top of `fetch`.
|
|
1240
|
+
*
|
|
1241
|
+
* Not wired in by default — pass it explicitly as the `transport` option to
|
|
1242
|
+
* `AleoNetworkClient`, `RecordScanner`, `AleoKeyProvider`, etc. (or to the
|
|
1243
|
+
* `get`/`post` helpers) when talking to a backend that uses cookie-based
|
|
1244
|
+
* session affinity. Browsers and iOS NSURLSession persist cookies on their own,
|
|
1245
|
+
* so this is targeted at Node and bare React Native consumers.
|
|
1246
|
+
*
|
|
1247
|
+
* Wraps the global `fetch` (avoiding illegal-invocation errors in browsers when
|
|
1248
|
+
* `fetch` is passed around as a bare reference) and layers a per-origin cookie
|
|
1249
|
+
* jar on top. Responses' `Set-Cookie` headers are captured (filtered by
|
|
1250
|
+
* `AFFINITY_COOKIE_NAMES`) and replayed as a `Cookie` header on subsequent
|
|
1251
|
+
* same-origin requests, which is required for backends that use cookie-based
|
|
1252
|
+
* session affinity (see `cookieJar` above).
|
|
1253
|
+
*
|
|
1254
|
+
* A caller-supplied `Cookie` header is never overwritten — `network-client.ts`
|
|
1255
|
+
* forwards the pubkey-response cookie manually onto delegated-prove requests
|
|
1256
|
+
* for Node compatibility, and that path takes precedence over the jar.
|
|
1257
|
+
*/
|
|
1258
|
+
const cookieAffinityTransport = async (input, init) => {
|
|
1259
|
+
const origin = originOf(input);
|
|
1260
|
+
const cookie = cookieHeaderFor(origin);
|
|
1261
|
+
if (cookie) {
|
|
1262
|
+
// Always operate on shallow clones so callers reusing the same
|
|
1263
|
+
// `init` / `Headers` / `Request` across origins don't end up with
|
|
1264
|
+
// origin A's jar cookie persisting into the object and blocking
|
|
1265
|
+
// origin B's correct cookie.
|
|
1266
|
+
if (init?.headers !== undefined && init.headers !== null) {
|
|
1267
|
+
// init.headers, when explicitly set, REPLACES the Request's
|
|
1268
|
+
// headers per the Fetch spec — attach there.
|
|
1269
|
+
init = { ...init, headers: attachCookie(init.headers, cookie) };
|
|
1270
|
+
}
|
|
1271
|
+
else if (isRequestLike(input)) {
|
|
1272
|
+
// Merge the Request's existing headers with the cookie and
|
|
1273
|
+
// pass them via `init.headers` instead of mutating the
|
|
1274
|
+
// Request itself. (Fetch spec: an explicit `init.headers`
|
|
1275
|
+
// replaces Request.headers entirely, so we copy the
|
|
1276
|
+
// originals into the merged set first.)
|
|
1277
|
+
try {
|
|
1278
|
+
const merged = new Headers(input.headers);
|
|
1279
|
+
if (!merged.has("cookie")) {
|
|
1280
|
+
merged.set("cookie", cookie);
|
|
1281
|
+
init = { ...(init ?? {}), headers: merged };
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
catch {
|
|
1285
|
+
// Some runtimes restrict Headers construction from a
|
|
1286
|
+
// Request; skip rather than failing the request.
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
else if (init) {
|
|
1290
|
+
init = { ...init, headers: attachCookie(undefined, cookie) };
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
init = { headers: attachCookie(undefined, cookie) };
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
const response = await fetch(input, init);
|
|
1297
|
+
// A response's `Set-Cookie` belongs to the final response URL's origin,
|
|
1298
|
+
// which can differ from the request input's when fetch follows redirects
|
|
1299
|
+
// (cross-origin or http→https). Prefer `response.url`; fall back to the
|
|
1300
|
+
// request origin for minimal mocked responses that don't expose a `url`.
|
|
1301
|
+
const responseOrigin = responseOriginOf(response) ?? origin;
|
|
1302
|
+
storeSetCookies(responseOrigin, readSetCookies(response));
|
|
1303
|
+
return response;
|
|
1304
|
+
};
|
|
1068
1305
|
function parseJSON(json) {
|
|
1069
1306
|
function revive(key, value, context) {
|
|
1070
1307
|
if (Number.isInteger(value)) {
|
|
@@ -1243,6 +1480,11 @@ const RECORD_DOMAIN = "RecordScannerV0";
|
|
|
1243
1480
|
const ZERO_ADDRESS = "aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc";
|
|
1244
1481
|
const FIVE_MINUTES = 5 * 60 * 1000; // 5 minutes in milliseconds
|
|
1245
1482
|
|
|
1483
|
+
const HEADERS = new Set([
|
|
1484
|
+
"x-aleo-sdk-version",
|
|
1485
|
+
"x-aleo-environment",
|
|
1486
|
+
"x-aleo-method",
|
|
1487
|
+
]);
|
|
1246
1488
|
/**
|
|
1247
1489
|
* Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
|
|
1248
1490
|
* allow users to query public information from the Aleo blockchain and submit transactions to the network.
|
|
@@ -1290,7 +1532,7 @@ class AleoNetworkClient {
|
|
|
1290
1532
|
else {
|
|
1291
1533
|
this.headers = {
|
|
1292
1534
|
// This is replaced by the actual version by a Rollup plugin
|
|
1293
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1535
|
+
"X-Aleo-SDK-Version": "0.11.2",
|
|
1294
1536
|
"X-Aleo-environment": environment(),
|
|
1295
1537
|
};
|
|
1296
1538
|
}
|
|
@@ -1306,7 +1548,7 @@ class AleoNetworkClient {
|
|
|
1306
1548
|
else {
|
|
1307
1549
|
this.headers = {
|
|
1308
1550
|
// This is replaced by the actual version by a Rollup plugin
|
|
1309
|
-
"X-Aleo-SDK-Version": "0.11.
|
|
1551
|
+
"X-Aleo-SDK-Version": "0.11.2",
|
|
1310
1552
|
"X-Aleo-environment": environment(),
|
|
1311
1553
|
};
|
|
1312
1554
|
}
|
|
@@ -1422,6 +1664,21 @@ class AleoNetworkClient {
|
|
|
1422
1664
|
removeHeader(headerName) {
|
|
1423
1665
|
delete this.headers[headerName];
|
|
1424
1666
|
}
|
|
1667
|
+
userHeaders() {
|
|
1668
|
+
const result = {};
|
|
1669
|
+
for (const [key, value] of Object.entries(this.headers)) {
|
|
1670
|
+
if (!HEADERS.has(key.toLowerCase())) {
|
|
1671
|
+
result[key] = value;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return result;
|
|
1675
|
+
}
|
|
1676
|
+
method(method) {
|
|
1677
|
+
if (this.hasCustomTransport) {
|
|
1678
|
+
return this.userHeaders();
|
|
1679
|
+
}
|
|
1680
|
+
return { ...this.headers, "X-ALEO-METHOD": method };
|
|
1681
|
+
}
|
|
1425
1682
|
/**
|
|
1426
1683
|
* Fetches data from the Aleo network and returns it as a JSON object.
|
|
1427
1684
|
*
|
|
@@ -1449,10 +1706,9 @@ class AleoNetworkClient {
|
|
|
1449
1706
|
const ctx = { ...this.ctx };
|
|
1450
1707
|
return await retryWithBackoff(async () => {
|
|
1451
1708
|
const response = await get(this.host + url, {
|
|
1452
|
-
headers:
|
|
1453
|
-
|
|
1454
|
-
...ctx,
|
|
1455
|
-
},
|
|
1709
|
+
headers: this.hasCustomTransport
|
|
1710
|
+
? this.userHeaders()
|
|
1711
|
+
: { ...this.headers, ...ctx },
|
|
1456
1712
|
}, this.transport);
|
|
1457
1713
|
return await response.text();
|
|
1458
1714
|
});
|
|
@@ -2684,7 +2940,7 @@ class AleoNetworkClient {
|
|
|
2684
2940
|
const endpoint = this.verboseErrors ? "transaction/broadcast?check_transaction=true" : "transaction/broadcast";
|
|
2685
2941
|
const response = await retryWithBackoff(() => this._sendPost(`${this.host}/${endpoint}`, {
|
|
2686
2942
|
body: transactionString,
|
|
2687
|
-
headers: Object.assign({},
|
|
2943
|
+
headers: Object.assign({}, this.method("submitTransaction"), {
|
|
2688
2944
|
"Content-Type": "application/json",
|
|
2689
2945
|
}),
|
|
2690
2946
|
}));
|
|
@@ -2710,7 +2966,7 @@ class AleoNetworkClient {
|
|
|
2710
2966
|
try {
|
|
2711
2967
|
const response = await retryWithBackoff(() => post(this.host + "/solution/broadcast", {
|
|
2712
2968
|
body: solution,
|
|
2713
|
-
headers: Object.assign({},
|
|
2969
|
+
headers: Object.assign({}, this.method("submitSolution"), {
|
|
2714
2970
|
"Content-Type": "application/json",
|
|
2715
2971
|
}),
|
|
2716
2972
|
}, this.transport));
|
|
@@ -2739,7 +2995,8 @@ class AleoNetworkClient {
|
|
|
2739
2995
|
}
|
|
2740
2996
|
const response = await post(`${this.baseUrl}/jwts/${consumerId}`, {
|
|
2741
2997
|
headers: {
|
|
2742
|
-
|
|
2998
|
+
...this.method("refreshJwt"),
|
|
2999
|
+
'X-Provable-API-Key': apiKey,
|
|
2743
3000
|
}
|
|
2744
3001
|
}, this.transport);
|
|
2745
3002
|
const authHeader = response.headers.get('authorization');
|
|
@@ -2833,8 +3090,7 @@ class AleoNetworkClient {
|
|
|
2833
3090
|
}
|
|
2834
3091
|
// Create the necessary headers to hit the provable api.
|
|
2835
3092
|
const headers = {
|
|
2836
|
-
...this.
|
|
2837
|
-
"X-ALEO-METHOD": "submitProvingRequest",
|
|
3093
|
+
...this.method("submitProvingRequest"),
|
|
2838
3094
|
"Content-Type": "application/json",
|
|
2839
3095
|
};
|
|
2840
3096
|
if (jwtData?.jwt) {
|
|
@@ -2948,10 +3204,7 @@ class AleoNetworkClient {
|
|
|
2948
3204
|
}
|
|
2949
3205
|
try {
|
|
2950
3206
|
const res = await this.transport(`${this.host}/transaction/confirmed/${transactionId}`, {
|
|
2951
|
-
headers:
|
|
2952
|
-
...this.headers,
|
|
2953
|
-
"X-ALEO-METHOD": "waitForTransactionConfirmation",
|
|
2954
|
-
},
|
|
3207
|
+
headers: this.method("waitForTransactionConfirmation"),
|
|
2955
3208
|
});
|
|
2956
3209
|
if (!res.ok) {
|
|
2957
3210
|
let text = "";
|
|
@@ -5462,6 +5715,19 @@ class SealanceMerkleTree {
|
|
|
5462
5715
|
}
|
|
5463
5716
|
}
|
|
5464
5717
|
|
|
5718
|
+
// This method generates the hook data for the Circle USDCx shielded mint flow.
|
|
5719
|
+
function generateHookData(recipientAddress, secretNonce) {
|
|
5720
|
+
// Leo's BHP256::commit_to_field uses the typed plaintext bits, not raw address bits.
|
|
5721
|
+
const recipientBits = mainnet_js.Plaintext.fromString(recipientAddress).toBitsLe();
|
|
5722
|
+
const secret = mainnet_js.Scalar.fromString(secretNonce);
|
|
5723
|
+
const committedField = new mainnet_js.BHP256().commit(recipientBits, secret);
|
|
5724
|
+
const committedBytes = committedField.toBytesLe();
|
|
5725
|
+
const hookData = new Uint8Array(65);
|
|
5726
|
+
hookData[0] = 2;
|
|
5727
|
+
hookData.set(committedBytes, 1);
|
|
5728
|
+
return hookData;
|
|
5729
|
+
}
|
|
5730
|
+
|
|
5465
5731
|
/**
|
|
5466
5732
|
* The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
|
|
5467
5733
|
*/
|
|
@@ -8199,7 +8465,7 @@ class ProgramManager {
|
|
|
8199
8465
|
* import { AleoKeyProvider, getOrInitConsensusVersionTestHeights, ProgramManager, NetworkRecordProvider } from "@provablehq/sdk/mainnet.js";
|
|
8200
8466
|
*
|
|
8201
8467
|
* // Initialize the development consensus heights in order to work with devnode.
|
|
8202
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
|
|
8468
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
|
|
8203
8469
|
*
|
|
8204
8470
|
* // Create a new NetworkClient and RecordProvider.
|
|
8205
8471
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -8326,7 +8592,7 @@ class ProgramManager {
|
|
|
8326
8592
|
* import { ProgramManager, NetworkRecordProvider, getOrInitConsensusVersionTestHeights } from "@provablehq/sdk/mainnet.js";
|
|
8327
8593
|
*
|
|
8328
8594
|
* // Initialize the development consensus heights in order to work with a local devnode.
|
|
8329
|
-
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13");
|
|
8595
|
+
* getOrInitConsensusVersionTestHeights("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14");
|
|
8330
8596
|
*
|
|
8331
8597
|
* // Create a new NetworkClient, and RecordProvider
|
|
8332
8598
|
* const recordProvider = new NetworkRecordProvider(account, networkClient);
|
|
@@ -9141,10 +9407,13 @@ exports.VALID_TRANSFER_TYPES = VALID_TRANSFER_TYPES;
|
|
|
9141
9407
|
exports.ViewKeyNotStoredError = ViewKeyNotStoredError;
|
|
9142
9408
|
exports.buildExecutionRequestFromExternallySignedData = buildExecutionRequestFromExternallySignedData;
|
|
9143
9409
|
exports.computeExternalSigningInputs = computeExternalSigningInputs;
|
|
9410
|
+
exports.cookieAffinityTransport = cookieAffinityTransport;
|
|
9411
|
+
exports.defaultTransport = defaultTransport;
|
|
9144
9412
|
exports.encryptAuthorization = encryptAuthorization;
|
|
9145
9413
|
exports.encryptProvingRequest = encryptProvingRequest;
|
|
9146
9414
|
exports.encryptRegistrationRequest = encryptRegistrationRequest;
|
|
9147
9415
|
exports.encryptViewKey = encryptViewKey;
|
|
9416
|
+
exports.generateHookData = generateHookData;
|
|
9148
9417
|
exports.getLogLevel = getLogLevel;
|
|
9149
9418
|
exports.initializeWasm = initializeWasm;
|
|
9150
9419
|
exports.inputsToFields = inputsToFields;
|