@opendatalabs/vana-sdk 3.23.0 → 4.1.0
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/README.md +57 -0
- package/dist/auth/errors.cjs +1 -1
- package/dist/auth/web3-signed.cjs +1 -1
- package/dist/crypto/envelope/job-stream.test.d.ts +1 -0
- package/dist/crypto/envelope/job.cjs +593 -38
- package/dist/crypto/envelope/job.cjs.map +1 -1
- package/dist/crypto/envelope/job.d.ts +44 -27
- package/dist/crypto/envelope/job.js +589 -37
- package/dist/crypto/envelope/job.js.map +1 -1
- package/dist/direct/access-request-client.cjs +1 -1
- package/dist/direct/connect-flow.cjs +43 -1
- package/dist/direct/connect-flow.cjs.map +1 -1
- package/dist/direct/connect-flow.d.ts +12 -0
- package/dist/direct/connect-flow.js +43 -1
- package/dist/direct/connect-flow.js.map +1 -1
- package/dist/direct/controller.cjs +1 -1
- package/dist/direct/errors.cjs +1 -1
- package/dist/direct/escrow-payment.cjs.map +1 -1
- package/dist/direct/escrow-payment.d.ts +2 -2
- package/dist/direct/escrow-payment.js.map +1 -1
- package/dist/direct/personal-server-read.cjs +2 -2
- package/dist/direct/use-direct-vana-connect.cjs +2 -1
- package/dist/direct/use-direct-vana-connect.cjs.map +1 -1
- package/dist/direct/use-direct-vana-connect.d.ts +3 -1
- package/dist/direct/use-direct-vana-connect.js +2 -1
- package/dist/direct/use-direct-vana-connect.js.map +1 -1
- package/dist/error-entry-points.test.d.ts +1 -0
- package/dist/errors.cjs +7 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.browser.d.ts +4 -4
- package/dist/index.browser.js +889 -526
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +1042 -713
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +4 -4
- package/dist/index.node.js +996 -575
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/data-point-deletion.cjs +1 -1
- package/dist/protocol/derivative-questions.cjs +1 -1
- package/dist/protocol/derivative-status.cjs +1 -1
- package/dist/protocol/eip712.cjs +28 -2
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +70 -0
- package/dist/protocol/eip712.js +24 -1
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow.cjs +154 -2
- package/dist/protocol/escrow.cjs.map +1 -1
- package/dist/protocol/escrow.d.ts +145 -2
- package/dist/protocol/escrow.js +152 -1
- package/dist/protocol/escrow.js.map +1 -1
- package/dist/protocol/fixtures/moksha-identity.json +20 -0
- package/dist/protocol/gateway.cjs +1 -1
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +8 -38
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/identity.cjs +14 -10
- package/dist/protocol/identity.cjs.map +1 -1
- package/dist/protocol/identity.js +14 -10
- package/dist/protocol/identity.js.map +1 -1
- package/dist/protocol/jobs-client.cjs +73 -21
- package/dist/protocol/jobs-client.cjs.map +1 -1
- package/dist/protocol/jobs-client.d.ts +7 -5
- package/dist/protocol/jobs-client.js +74 -21
- package/dist/protocol/jobs-client.js.map +1 -1
- package/dist/protocol/jobs.cjs +0 -3
- package/dist/protocol/jobs.cjs.map +1 -1
- package/dist/protocol/jobs.d.ts +21 -13
- package/dist/protocol/jobs.js +0 -2
- package/dist/protocol/jobs.js.map +1 -1
- package/dist/protocol/lineage.cjs +1 -1
- package/dist/protocol/personal-server-data.cjs +1 -1
- package/dist/protocol/personal-server-write.cjs +1 -1
- package/dist/protocol/write-request.cjs +1 -1
- package/dist/protocol/write-signer.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/dist/session-relay/client.cjs +1 -1
- package/dist/session-relay/errors.cjs +1 -1
- package/dist/session-relay/index.cjs +1 -1
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -1138,346 +1138,8 @@ var init_browser2 = __esm({
|
|
|
1138
1138
|
}
|
|
1139
1139
|
});
|
|
1140
1140
|
|
|
1141
|
-
// src/
|
|
1142
|
-
|
|
1143
|
-
constructor(message, code) {
|
|
1144
|
-
super(message);
|
|
1145
|
-
this.code = code;
|
|
1146
|
-
this.name = this.constructor.name;
|
|
1147
|
-
if (Error.captureStackTrace) {
|
|
1148
|
-
Error.captureStackTrace(this, this.constructor);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
code;
|
|
1152
|
-
};
|
|
1153
|
-
var RelayerError = class extends VanaError {
|
|
1154
|
-
constructor(message, statusCode, response) {
|
|
1155
|
-
super(message, "RELAYER_ERROR");
|
|
1156
|
-
this.statusCode = statusCode;
|
|
1157
|
-
this.response = response;
|
|
1158
|
-
}
|
|
1159
|
-
statusCode;
|
|
1160
|
-
response;
|
|
1161
|
-
};
|
|
1162
|
-
var UserRejectedRequestError = class extends VanaError {
|
|
1163
|
-
constructor(message = "User rejected the signature request") {
|
|
1164
|
-
super(message, "USER_REJECTED_REQUEST");
|
|
1165
|
-
}
|
|
1166
|
-
};
|
|
1167
|
-
var InvalidConfigurationError = class extends VanaError {
|
|
1168
|
-
constructor(message) {
|
|
1169
|
-
super(message, "INVALID_CONFIGURATION");
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
var ContractNotFoundError = class extends VanaError {
|
|
1173
|
-
constructor(contractName, chainId) {
|
|
1174
|
-
super(
|
|
1175
|
-
`Contract ${contractName} not found on chain ${chainId}`,
|
|
1176
|
-
"CONTRACT_NOT_FOUND"
|
|
1177
|
-
);
|
|
1178
|
-
}
|
|
1179
|
-
};
|
|
1180
|
-
var BlockchainError = class extends VanaError {
|
|
1181
|
-
constructor(message, originalError) {
|
|
1182
|
-
super(message, "BLOCKCHAIN_ERROR");
|
|
1183
|
-
this.originalError = originalError;
|
|
1184
|
-
}
|
|
1185
|
-
originalError;
|
|
1186
|
-
};
|
|
1187
|
-
var SerializationError = class extends VanaError {
|
|
1188
|
-
constructor(message) {
|
|
1189
|
-
super(message, "SERIALIZATION_ERROR");
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
var SignatureError = class extends VanaError {
|
|
1193
|
-
constructor(message, originalError) {
|
|
1194
|
-
super(message, "SIGNATURE_ERROR");
|
|
1195
|
-
this.originalError = originalError;
|
|
1196
|
-
}
|
|
1197
|
-
originalError;
|
|
1198
|
-
};
|
|
1199
|
-
var NetworkError = class extends VanaError {
|
|
1200
|
-
constructor(message, originalError) {
|
|
1201
|
-
super(message, "NETWORK_ERROR");
|
|
1202
|
-
this.originalError = originalError;
|
|
1203
|
-
}
|
|
1204
|
-
originalError;
|
|
1205
|
-
};
|
|
1206
|
-
var NonceError = class extends VanaError {
|
|
1207
|
-
constructor(message) {
|
|
1208
|
-
super(message, "NONCE_ERROR");
|
|
1209
|
-
}
|
|
1210
|
-
};
|
|
1211
|
-
var PersonalServerError = class extends VanaError {
|
|
1212
|
-
constructor(message, originalError) {
|
|
1213
|
-
super(message, "PERSONAL_SERVER_ERROR");
|
|
1214
|
-
this.originalError = originalError;
|
|
1215
|
-
}
|
|
1216
|
-
originalError;
|
|
1217
|
-
};
|
|
1218
|
-
var ServerUrlMismatchError = class extends VanaError {
|
|
1219
|
-
constructor(existingUrl, providedUrl, serverId) {
|
|
1220
|
-
super(
|
|
1221
|
-
`Server ${serverId} is already registered with URL "${existingUrl}". Cannot change to "${providedUrl}".`,
|
|
1222
|
-
"SERVER_URL_MISMATCH"
|
|
1223
|
-
);
|
|
1224
|
-
this.existingUrl = existingUrl;
|
|
1225
|
-
this.providedUrl = providedUrl;
|
|
1226
|
-
this.serverId = serverId;
|
|
1227
|
-
}
|
|
1228
|
-
existingUrl;
|
|
1229
|
-
providedUrl;
|
|
1230
|
-
serverId;
|
|
1231
|
-
};
|
|
1232
|
-
var PermissionError = class extends VanaError {
|
|
1233
|
-
constructor(message, originalError) {
|
|
1234
|
-
super(message, "PERMISSION_ERROR");
|
|
1235
|
-
this.originalError = originalError;
|
|
1236
|
-
}
|
|
1237
|
-
originalError;
|
|
1238
|
-
};
|
|
1239
|
-
var ReadOnlyError = class extends VanaError {
|
|
1240
|
-
constructor(operation, suggestion = "Initialize the SDK with a walletClient to perform this operation") {
|
|
1241
|
-
super(
|
|
1242
|
-
`Operation '${operation}' requires a wallet client. ${suggestion}`,
|
|
1243
|
-
"READ_ONLY_ERROR"
|
|
1244
|
-
);
|
|
1245
|
-
this.operation = operation;
|
|
1246
|
-
this.suggestion = suggestion;
|
|
1247
|
-
}
|
|
1248
|
-
/** The operation that was attempted */
|
|
1249
|
-
operation;
|
|
1250
|
-
/** Suggested solution for fixing the error */
|
|
1251
|
-
suggestion;
|
|
1252
|
-
};
|
|
1253
|
-
var TransactionPendingError = class extends VanaError {
|
|
1254
|
-
constructor(operationId, message, lastKnownStatus) {
|
|
1255
|
-
super(
|
|
1256
|
-
`Transaction operation pending: ${message} (operationId: ${operationId})`,
|
|
1257
|
-
"TRANSACTION_PENDING"
|
|
1258
|
-
);
|
|
1259
|
-
this.operationId = operationId;
|
|
1260
|
-
this.lastKnownStatus = lastKnownStatus;
|
|
1261
|
-
}
|
|
1262
|
-
operationId;
|
|
1263
|
-
lastKnownStatus;
|
|
1264
|
-
/**
|
|
1265
|
-
* Converts the error to a JSON-serializable format.
|
|
1266
|
-
*
|
|
1267
|
-
* @remarks
|
|
1268
|
-
* Useful for logging, storage, or transmission of error details.
|
|
1269
|
-
*
|
|
1270
|
-
* @returns JSON representation of the error
|
|
1271
|
-
*/
|
|
1272
|
-
toJSON() {
|
|
1273
|
-
return {
|
|
1274
|
-
name: this.name,
|
|
1275
|
-
code: this.code,
|
|
1276
|
-
message: this.message,
|
|
1277
|
-
operationId: this.operationId,
|
|
1278
|
-
lastKnownStatus: this.lastKnownStatus
|
|
1279
|
-
};
|
|
1280
|
-
}
|
|
1281
|
-
};
|
|
1282
|
-
var PersonalServerWriteError = class extends VanaError {
|
|
1283
|
-
constructor(message, code, status, errorCode = null, details) {
|
|
1284
|
-
super(message, code);
|
|
1285
|
-
this.status = status;
|
|
1286
|
-
this.errorCode = errorCode;
|
|
1287
|
-
this.details = details;
|
|
1288
|
-
}
|
|
1289
|
-
status;
|
|
1290
|
-
errorCode;
|
|
1291
|
-
details;
|
|
1292
|
-
};
|
|
1293
|
-
var WriteRequestError = class extends PersonalServerWriteError {
|
|
1294
|
-
constructor(message, details) {
|
|
1295
|
-
super(message, "WRITE_INVALID_REQUEST", void 0, null, details);
|
|
1296
|
-
}
|
|
1297
|
-
};
|
|
1298
|
-
var WriteTransportError = class extends PersonalServerWriteError {
|
|
1299
|
-
constructor(message, attempts, cause) {
|
|
1300
|
-
super(message, "WRITE_TRANSPORT_ERROR", void 0, null, { attempts });
|
|
1301
|
-
this.attempts = attempts;
|
|
1302
|
-
this.cause = cause;
|
|
1303
|
-
}
|
|
1304
|
-
attempts;
|
|
1305
|
-
};
|
|
1306
|
-
var WriteSessionError = class extends PersonalServerWriteError {
|
|
1307
|
-
constructor(message, status, errorCode = null, details) {
|
|
1308
|
-
super(message, "WRITE_SESSION_REJECTED", status, errorCode, details);
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
var WriteSessionExpiredError = class extends PersonalServerWriteError {
|
|
1312
|
-
constructor(message, details) {
|
|
1313
|
-
super(message, "WRITE_SESSION_EXPIRED", void 0, null, details);
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1316
|
-
var WriteUnauthorizedError = class extends PersonalServerWriteError {
|
|
1317
|
-
constructor(message, errorCode = null, details) {
|
|
1318
|
-
super(message, "WRITE_UNAUTHORIZED", 401, errorCode, details);
|
|
1319
|
-
}
|
|
1320
|
-
};
|
|
1321
|
-
var WriteForbiddenError = class extends PersonalServerWriteError {
|
|
1322
|
-
constructor(message, errorCode = null, details) {
|
|
1323
|
-
super(message, "WRITE_FORBIDDEN", 403, errorCode, details);
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
var WriteConflictError = class extends PersonalServerWriteError {
|
|
1327
|
-
constructor(message, errorCode = null, details) {
|
|
1328
|
-
super(message, "WRITE_CONFLICT", 409, errorCode, details);
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
var WriteLineageError = class extends PersonalServerWriteError {
|
|
1332
|
-
constructor(message, status = 422, errorCode = null, details) {
|
|
1333
|
-
super(message, "WRITE_LINEAGE_REJECTED", status, errorCode, details);
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
var WriteRejectedError = class extends PersonalServerWriteError {
|
|
1337
|
-
constructor(message, status, errorCode = null, details) {
|
|
1338
|
-
super(message, "WRITE_REJECTED", status, errorCode, details);
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
var JobsClientError = class extends VanaError {
|
|
1342
|
-
constructor(message, code, status, errorCode = null, details) {
|
|
1343
|
-
super(message, code);
|
|
1344
|
-
this.status = status;
|
|
1345
|
-
this.errorCode = errorCode;
|
|
1346
|
-
this.details = details;
|
|
1347
|
-
}
|
|
1348
|
-
status;
|
|
1349
|
-
errorCode;
|
|
1350
|
-
details;
|
|
1351
|
-
};
|
|
1352
|
-
var BuilderUnknownError = class extends JobsClientError {
|
|
1353
|
-
constructor(message, details) {
|
|
1354
|
-
super(message, "JOB_BUILDER_UNKNOWN", 403, "BUILDER_UNKNOWN", details);
|
|
1355
|
-
}
|
|
1356
|
-
};
|
|
1357
|
-
var GrantInvalidError = class extends JobsClientError {
|
|
1358
|
-
constructor(message, details) {
|
|
1359
|
-
super(message, "JOB_GRANT_INVALID", 403, "GRANT_INVALID", details);
|
|
1360
|
-
}
|
|
1361
|
-
};
|
|
1362
|
-
var OwnerNotReadyError = class extends JobsClientError {
|
|
1363
|
-
constructor(message, details) {
|
|
1364
|
-
super(message, "JOB_OWNER_NOT_READY", 403, "OWNER_NOT_READY", details);
|
|
1365
|
-
}
|
|
1366
|
-
};
|
|
1367
|
-
var JobIdTakenError = class extends JobsClientError {
|
|
1368
|
-
constructor(message, details) {
|
|
1369
|
-
super(message, "JOB_ID_TAKEN", 409, "JOB_ID_TAKEN", details);
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
var JobNotFoundError = class extends JobsClientError {
|
|
1373
|
-
constructor(message, details) {
|
|
1374
|
-
super(message, "JOB_NOT_FOUND", 404, "JOB_NOT_FOUND", details);
|
|
1375
|
-
}
|
|
1376
|
-
};
|
|
1377
|
-
var JobRequestTooLargeError = class extends JobsClientError {
|
|
1378
|
-
constructor(message, errorCode = "BODY_TOO_LARGE", details) {
|
|
1379
|
-
super(message, "JOB_REQUEST_TOO_LARGE", 413, errorCode, details);
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
var JobTimeoutError = class extends JobsClientError {
|
|
1383
|
-
constructor(message, details) {
|
|
1384
|
-
super(message, "JOB_TIMEOUT", void 0, null, details);
|
|
1385
|
-
}
|
|
1386
|
-
};
|
|
1387
|
-
var JobRejectedError = class extends JobsClientError {
|
|
1388
|
-
constructor(message, status, errorCode = null, details) {
|
|
1389
|
-
super(message, "JOB_REJECTED", status, errorCode, details);
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
|
-
var JobTransportError = class extends JobsClientError {
|
|
1393
|
-
constructor(message, cause) {
|
|
1394
|
-
super(message, "JOB_TRANSPORT_ERROR");
|
|
1395
|
-
this.cause = cause;
|
|
1396
|
-
}
|
|
1397
|
-
};
|
|
1398
|
-
var LineageReadError = class extends VanaError {
|
|
1399
|
-
constructor(message, status, errorCode = null, details) {
|
|
1400
|
-
super(message, "LINEAGE_READ_ERROR");
|
|
1401
|
-
this.status = status;
|
|
1402
|
-
this.errorCode = errorCode;
|
|
1403
|
-
this.details = details;
|
|
1404
|
-
}
|
|
1405
|
-
status;
|
|
1406
|
-
errorCode;
|
|
1407
|
-
details;
|
|
1408
|
-
};
|
|
1409
|
-
var DerivativeQuestionRejectedError = class extends PersonalServerWriteError {
|
|
1410
|
-
constructor(message, status, errorCode = null, details) {
|
|
1411
|
-
super(message, "DERIVATIVE_QUESTION_REJECTED", status, errorCode, details);
|
|
1412
|
-
}
|
|
1413
|
-
};
|
|
1414
|
-
var DerivativeQuestionInvalidError = class extends PersonalServerWriteError {
|
|
1415
|
-
constructor(message, status = 400, errorCode = null, details) {
|
|
1416
|
-
super(message, "DERIVATIVE_QUESTION_INVALID", status, errorCode, details);
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
var DerivativeQuestionNotFoundError = class extends PersonalServerWriteError {
|
|
1420
|
-
constructor(message, errorCode = null, details) {
|
|
1421
|
-
super(message, "DERIVATIVE_QUESTION_NOT_FOUND", 404, errorCode, details);
|
|
1422
|
-
}
|
|
1423
|
-
};
|
|
1424
|
-
var DerivativeDerivedScopeRequiredError = class extends PersonalServerWriteError {
|
|
1425
|
-
constructor(message, errorCode = null, details) {
|
|
1426
|
-
super(
|
|
1427
|
-
message,
|
|
1428
|
-
"DERIVATIVE_DERIVED_SCOPE_REQUIRED",
|
|
1429
|
-
400,
|
|
1430
|
-
errorCode,
|
|
1431
|
-
details
|
|
1432
|
-
);
|
|
1433
|
-
}
|
|
1434
|
-
};
|
|
1435
|
-
var DerivativeSourceNotGrantedError = class extends PersonalServerWriteError {
|
|
1436
|
-
constructor(message, errorCode = null, details) {
|
|
1437
|
-
super(message, "DERIVATIVE_SOURCE_NOT_GRANTED", 403, errorCode, details);
|
|
1438
|
-
}
|
|
1439
|
-
};
|
|
1440
|
-
var DerivativeCycleError = class extends PersonalServerWriteError {
|
|
1441
|
-
constructor(message, errorCode = null, details) {
|
|
1442
|
-
super(message, "DERIVATIVE_CYCLE", 409, errorCode, details);
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
|
-
var DerivativeComputeUnavailableError = class extends PersonalServerWriteError {
|
|
1446
|
-
constructor(message, errorCode = null, details) {
|
|
1447
|
-
super(message, "DERIVATIVE_COMPUTE_UNAVAILABLE", 503, errorCode, details);
|
|
1448
|
-
}
|
|
1449
|
-
};
|
|
1450
|
-
var DerivativeQuestionTimeoutError = class extends PersonalServerWriteError {
|
|
1451
|
-
constructor(message, details) {
|
|
1452
|
-
super(message, "DERIVATIVE_QUESTION_TIMEOUT", void 0, null, details);
|
|
1453
|
-
}
|
|
1454
|
-
};
|
|
1455
|
-
var DerivativeQuestionFailedError = class extends PersonalServerWriteError {
|
|
1456
|
-
constructor(message, details) {
|
|
1457
|
-
super(message, "DERIVATIVE_QUESTION_FAILED", void 0, null, details);
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
var DataPointDeletedError = class extends VanaError {
|
|
1461
|
-
constructor(message, details = {}) {
|
|
1462
|
-
super(message, "DATA_POINT_DELETED");
|
|
1463
|
-
this.details = details;
|
|
1464
|
-
}
|
|
1465
|
-
details;
|
|
1466
|
-
};
|
|
1467
|
-
var DataPointNotFoundError = class extends VanaError {
|
|
1468
|
-
constructor(message, details = {}) {
|
|
1469
|
-
super(message, "DATA_POINT_NOT_FOUND");
|
|
1470
|
-
this.details = details;
|
|
1471
|
-
}
|
|
1472
|
-
details;
|
|
1473
|
-
};
|
|
1474
|
-
var DataPointVersionConflictError = class extends VanaError {
|
|
1475
|
-
constructor(message, details = {}) {
|
|
1476
|
-
super(message, "DATA_POINT_VERSION_CONFLICT");
|
|
1477
|
-
this.details = details;
|
|
1478
|
-
}
|
|
1479
|
-
details;
|
|
1480
|
-
};
|
|
1141
|
+
// src/index.browser.ts
|
|
1142
|
+
export * from "./errors.js";
|
|
1481
1143
|
|
|
1482
1144
|
// src/contracts/contractController.ts
|
|
1483
1145
|
import {
|
|
@@ -31552,31 +31214,11 @@ async function decryptWithPassword(encrypted, password) {
|
|
|
31552
31214
|
|
|
31553
31215
|
// src/auth/web3-signed.ts
|
|
31554
31216
|
import { recoverMessageAddress as recoverMessageAddress2 } from "viem";
|
|
31555
|
-
|
|
31556
|
-
|
|
31557
|
-
|
|
31558
|
-
|
|
31559
|
-
|
|
31560
|
-
this.details = details;
|
|
31561
|
-
}
|
|
31562
|
-
details;
|
|
31563
|
-
};
|
|
31564
|
-
var InvalidSignatureError = class extends VanaError {
|
|
31565
|
-
constructor(details, message = "Invalid signature") {
|
|
31566
|
-
super(message, "INVALID_SIGNATURE");
|
|
31567
|
-
this.details = details;
|
|
31568
|
-
}
|
|
31569
|
-
details;
|
|
31570
|
-
};
|
|
31571
|
-
var ExpiredTokenError = class extends VanaError {
|
|
31572
|
-
constructor(details, message = "Token has expired") {
|
|
31573
|
-
super(message, "EXPIRED_TOKEN");
|
|
31574
|
-
this.details = details;
|
|
31575
|
-
}
|
|
31576
|
-
details;
|
|
31577
|
-
};
|
|
31578
|
-
|
|
31579
|
-
// src/auth/web3-signed.ts
|
|
31217
|
+
import {
|
|
31218
|
+
MissingAuthError,
|
|
31219
|
+
InvalidSignatureError,
|
|
31220
|
+
ExpiredTokenError
|
|
31221
|
+
} from "./auth/errors.js";
|
|
31580
31222
|
var WEB3_SIGNED_PREFIX = "Web3Signed ";
|
|
31581
31223
|
var CLOCK_SKEW_SECONDS = 60;
|
|
31582
31224
|
function base64urlDecode(input) {
|
|
@@ -31694,6 +31336,13 @@ async function verifyWeb3Signed(params) {
|
|
|
31694
31336
|
return { signer, payload };
|
|
31695
31337
|
}
|
|
31696
31338
|
|
|
31339
|
+
// src/index.browser.ts
|
|
31340
|
+
import {
|
|
31341
|
+
MissingAuthError as MissingAuthError2,
|
|
31342
|
+
InvalidSignatureError as InvalidSignatureError2,
|
|
31343
|
+
ExpiredTokenError as ExpiredTokenError2
|
|
31344
|
+
} from "./auth/errors.js";
|
|
31345
|
+
|
|
31697
31346
|
// src/protocol/eip712.ts
|
|
31698
31347
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
31699
31348
|
var DOMAIN_VERSION = "1";
|
|
@@ -31742,6 +31391,9 @@ function escrowPaymentDomain(config) {
|
|
|
31742
31391
|
config.contracts.dataPortabilityEscrow
|
|
31743
31392
|
);
|
|
31744
31393
|
}
|
|
31394
|
+
function withdrawAuthorizationDomain(config) {
|
|
31395
|
+
return escrowPaymentDomain(config);
|
|
31396
|
+
}
|
|
31745
31397
|
var GRANT_REGISTRATION_TYPES = {
|
|
31746
31398
|
GrantRegistration: [
|
|
31747
31399
|
{ name: "grantorAddress", type: "address" },
|
|
@@ -31774,6 +31426,15 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
31774
31426
|
{ name: "appUrl", type: "string" }
|
|
31775
31427
|
]
|
|
31776
31428
|
};
|
|
31429
|
+
var WITHDRAW_AUTHORIZATION_TYPES = {
|
|
31430
|
+
WithdrawAuthorization: [
|
|
31431
|
+
{ name: "account", type: "address" },
|
|
31432
|
+
{ name: "asset", type: "address" },
|
|
31433
|
+
{ name: "amount", type: "uint256" },
|
|
31434
|
+
{ name: "withdrawNonce", type: "uint256" },
|
|
31435
|
+
{ name: "deadline", type: "uint256" }
|
|
31436
|
+
]
|
|
31437
|
+
};
|
|
31777
31438
|
var ADD_DATA_TYPES = {
|
|
31778
31439
|
AddData: [
|
|
31779
31440
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -31792,6 +31453,14 @@ var RECORD_DATA_ACCESS_TYPES = {
|
|
|
31792
31453
|
{ name: "recordId", type: "bytes32" }
|
|
31793
31454
|
]
|
|
31794
31455
|
};
|
|
31456
|
+
function buildWithdrawAuthorizationTypedData(config, message) {
|
|
31457
|
+
return {
|
|
31458
|
+
domain: withdrawAuthorizationDomain(config),
|
|
31459
|
+
types: WITHDRAW_AUTHORIZATION_TYPES,
|
|
31460
|
+
primaryType: "WithdrawAuthorization",
|
|
31461
|
+
message
|
|
31462
|
+
};
|
|
31463
|
+
}
|
|
31795
31464
|
|
|
31796
31465
|
// src/protocol/identity.ts
|
|
31797
31466
|
init_interface();
|
|
@@ -31821,17 +31490,21 @@ var PREIMAGE_SEPARATOR = ":";
|
|
|
31821
31490
|
var UNCOMPRESSED_PUBLIC_KEY_BYTES = 65;
|
|
31822
31491
|
var UNCOMPRESSED_PUBLIC_KEY_PREFIX = "04";
|
|
31823
31492
|
var EMPTY_HEX = "0x";
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31829
|
-
}
|
|
31493
|
+
var MAINNET_ANCHOR = Object.freeze({
|
|
31494
|
+
kmsRootPubkey: "0x0434c76e0c3f52ec64cbf9bbf5c910c272330166fd656c0a86bb330963e46910e1a0e6fa51bec74be2f9129342707636060d85856d102cee8290185409ecf7422f",
|
|
31495
|
+
appIds: Object.freeze([
|
|
31496
|
+
"0x01bb1b6dcaf1ea170f1480c5e53b093f384d939a"
|
|
31497
|
+
])
|
|
31498
|
+
});
|
|
31830
31499
|
var ENCLAVE_TRUST_ANCHORS = Object.freeze({
|
|
31831
|
-
|
|
31832
|
-
|
|
31833
|
-
|
|
31834
|
-
|
|
31500
|
+
[VANA_MAINNET_CHAIN_ID]: MAINNET_ANCHOR,
|
|
31501
|
+
// Moksha workers share this dstack app and KMS root; the controller does not derive owner keys.
|
|
31502
|
+
[MOKSHA_CHAIN_ID]: Object.freeze({
|
|
31503
|
+
kmsRootPubkey: "0x0434c76e0c3f52ec64cbf9bbf5c910c272330166fd656c0a86bb330963e46910e1a0e6fa51bec74be2f9129342707636060d85856d102cee8290185409ecf7422f",
|
|
31504
|
+
appIds: Object.freeze([
|
|
31505
|
+
"0xec9a39de98c760e1ded9f1e97016dc5f0e357cf2"
|
|
31506
|
+
])
|
|
31507
|
+
})
|
|
31835
31508
|
});
|
|
31836
31509
|
function userPsId(chainId, ownerAddress) {
|
|
31837
31510
|
const packed = encodePacked(
|
|
@@ -31978,16 +31651,30 @@ var MAX_LEASE_SECONDS = 300;
|
|
|
31978
31651
|
var MAX_ATTEMPTS = 3;
|
|
31979
31652
|
var MAX_WAIT_SECONDS = 25;
|
|
31980
31653
|
var CLAIM_POLL_FLOOR_MS = 1e3;
|
|
31981
|
-
var MAX_INLINE_RESULT_BYTES = 1048576;
|
|
31982
31654
|
var DEFAULT_JOB_DEADLINE_SECONDS = 600;
|
|
31983
31655
|
var MAX_JOB_DEADLINE_SECONDS = 3600;
|
|
31984
31656
|
|
|
31985
31657
|
// src/crypto/envelope/job.ts
|
|
31658
|
+
init_constants();
|
|
31986
31659
|
init_interface();
|
|
31987
31660
|
import { sha256 as sha2565 } from "@noble/hashes/sha2";
|
|
31988
31661
|
import { bytesToHex as bytesToHex2, fromHex as fromHex6, isAddress, isHex, toHex as toHex7 } from "viem";
|
|
31989
31662
|
var textDecoder = new TextDecoder();
|
|
31990
31663
|
var textEncoder = new TextEncoder();
|
|
31664
|
+
var MAX_JOB_RESULT_HEADER_BYTES = 4096;
|
|
31665
|
+
var WRAPPED_KEY_LENGTH_BYTES = 4;
|
|
31666
|
+
var FRAME_LENGTH_BYTES = 4;
|
|
31667
|
+
var FRAME_FLAGS_BYTES = 1;
|
|
31668
|
+
var AES_KEY_BYTES = 32;
|
|
31669
|
+
var AES_GCM_NONCE_BYTES = 12;
|
|
31670
|
+
var AES_GCM_TAG_BYTES = 16;
|
|
31671
|
+
var WRAPPED_METADATA_LENGTH_BYTES = 4;
|
|
31672
|
+
var WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES = AES_KEY_BYTES + AES_GCM_NONCE_BYTES + WRAPPED_METADATA_LENGTH_BYTES;
|
|
31673
|
+
var MAX_WRAPPED_KEY_BYTES = 8192;
|
|
31674
|
+
var FINAL_FRAME_FLAG = 1;
|
|
31675
|
+
var MAX_CHUNK_INDEX = 4294967295;
|
|
31676
|
+
var JOB_RESULT_FORMAT_VERSION = 2;
|
|
31677
|
+
var JOB_RESULT_CHUNK_BYTES = 1024 * 1024;
|
|
31991
31678
|
var JobEnvelopeError = class extends Error {
|
|
31992
31679
|
constructor(message) {
|
|
31993
31680
|
super(message);
|
|
@@ -32019,21 +31706,68 @@ function requestPlaintext(envelope) {
|
|
|
32019
31706
|
validateRequestEnvelope(envelope);
|
|
32020
31707
|
return canonicalJsonBytes(envelope);
|
|
32021
31708
|
}
|
|
32022
|
-
function
|
|
32023
|
-
return
|
|
32024
|
-
|
|
32025
|
-
|
|
32026
|
-
|
|
32027
|
-
|
|
32028
|
-
|
|
32029
|
-
|
|
32030
|
-
body: result.body
|
|
32031
|
-
})
|
|
32032
|
-
);
|
|
31709
|
+
function resultMetadata(result) {
|
|
31710
|
+
return {
|
|
31711
|
+
v: result.v,
|
|
31712
|
+
jobId: result.jobId,
|
|
31713
|
+
scope: result.scope,
|
|
31714
|
+
version: result.version,
|
|
31715
|
+
contentType: result.contentType
|
|
31716
|
+
};
|
|
32033
31717
|
}
|
|
32034
31718
|
function encryptedBytesToBase64(encrypted) {
|
|
32035
31719
|
return toBase64(fromHex6(`0x${serializeECIES(encrypted)}`, "bytes"));
|
|
32036
31720
|
}
|
|
31721
|
+
function encryptedToBytes(encrypted) {
|
|
31722
|
+
const bytes = new Uint8Array(
|
|
31723
|
+
encrypted.iv.length + encrypted.ephemPublicKey.length + encrypted.ciphertext.length + encrypted.mac.length
|
|
31724
|
+
);
|
|
31725
|
+
let offset = 0;
|
|
31726
|
+
bytes.set(encrypted.iv, offset);
|
|
31727
|
+
offset += encrypted.iv.length;
|
|
31728
|
+
bytes.set(encrypted.ephemPublicKey, offset);
|
|
31729
|
+
offset += encrypted.ephemPublicKey.length;
|
|
31730
|
+
bytes.set(encrypted.ciphertext, offset);
|
|
31731
|
+
offset += encrypted.ciphertext.length;
|
|
31732
|
+
bytes.set(encrypted.mac, offset);
|
|
31733
|
+
return bytes;
|
|
31734
|
+
}
|
|
31735
|
+
function bytesToEncrypted(bytes) {
|
|
31736
|
+
const absoluteMinLength = FORMAT.IV_LENGTH + 1 + MAC.LENGTH + 1;
|
|
31737
|
+
if (bytes.length < absoluteMinLength) {
|
|
31738
|
+
throw new ECIESError(
|
|
31739
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${absoluteMinLength} bytes required)`,
|
|
31740
|
+
"DECRYPTION_FAILED"
|
|
31741
|
+
);
|
|
31742
|
+
}
|
|
31743
|
+
const prefix = bytes[FORMAT.EPHEMERAL_KEY_OFFSET];
|
|
31744
|
+
if (prefix !== CURVE.PREFIX.UNCOMPRESSED) {
|
|
31745
|
+
throw new ECIESError(
|
|
31746
|
+
`Invalid ephemeral public key: must be uncompressed format (0x04 prefix), got 0x${prefix.toString(16).padStart(2, "0")}`,
|
|
31747
|
+
"DECRYPTION_FAILED"
|
|
31748
|
+
);
|
|
31749
|
+
}
|
|
31750
|
+
const ephemKeySize = CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH;
|
|
31751
|
+
const minLength = FORMAT.IV_LENGTH + ephemKeySize + MAC.LENGTH + 1;
|
|
31752
|
+
if (bytes.length < minLength) {
|
|
31753
|
+
throw new ECIESError(
|
|
31754
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${minLength} bytes required)`,
|
|
31755
|
+
"DECRYPTION_FAILED"
|
|
31756
|
+
);
|
|
31757
|
+
}
|
|
31758
|
+
return {
|
|
31759
|
+
iv: bytes.subarray(FORMAT.IV_OFFSET, FORMAT.IV_OFFSET + FORMAT.IV_LENGTH),
|
|
31760
|
+
ephemPublicKey: bytes.subarray(
|
|
31761
|
+
FORMAT.EPHEMERAL_KEY_OFFSET,
|
|
31762
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize
|
|
31763
|
+
),
|
|
31764
|
+
ciphertext: bytes.subarray(
|
|
31765
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,
|
|
31766
|
+
bytes.length - MAC.LENGTH
|
|
31767
|
+
),
|
|
31768
|
+
mac: bytes.subarray(bytes.length - MAC.LENGTH)
|
|
31769
|
+
};
|
|
31770
|
+
}
|
|
32037
31771
|
function base64ToEncrypted(ciphertext) {
|
|
32038
31772
|
return deserializeECIES(toHex7(fromBase64(ciphertext)));
|
|
32039
31773
|
}
|
|
@@ -32134,11 +31868,11 @@ function validateRequestEnvelope(value) {
|
|
|
32134
31868
|
requireString(value.auth, "auth", "job request envelope");
|
|
32135
31869
|
return value;
|
|
32136
31870
|
}
|
|
32137
|
-
function
|
|
32138
|
-
requirePlainObject(value, "
|
|
31871
|
+
function validateResultMetadata(value) {
|
|
31872
|
+
requirePlainObject(value, "metadata", "job result");
|
|
32139
31873
|
requireExactKeys(
|
|
32140
31874
|
value,
|
|
32141
|
-
["v", "jobId", "scope", "version", "contentType"
|
|
31875
|
+
["v", "jobId", "scope", "version", "contentType"],
|
|
32142
31876
|
"job result"
|
|
32143
31877
|
);
|
|
32144
31878
|
if (value.v !== JOB_PROTOCOL_VERSION) {
|
|
@@ -32149,14 +31883,222 @@ function validateResult(value) {
|
|
|
32149
31883
|
for (const field of ["jobId", "scope", "contentType"]) {
|
|
32150
31884
|
requireString(value[field], field, "job result");
|
|
32151
31885
|
}
|
|
32152
|
-
if (typeof value.body !== "string") {
|
|
32153
|
-
throw new JobEnvelopeError("Invalid job result: missing body");
|
|
32154
|
-
}
|
|
32155
31886
|
if (value.version !== null && typeof value.version !== "string") {
|
|
32156
31887
|
throw new JobEnvelopeError("Invalid job result: missing version");
|
|
32157
31888
|
}
|
|
32158
31889
|
return value;
|
|
32159
31890
|
}
|
|
31891
|
+
function validateResult(value) {
|
|
31892
|
+
requirePlainObject(value, "result", "job result");
|
|
31893
|
+
requireExactKeys(
|
|
31894
|
+
value,
|
|
31895
|
+
["v", "jobId", "scope", "version", "contentType", "body"],
|
|
31896
|
+
"job result"
|
|
31897
|
+
);
|
|
31898
|
+
validateResultMetadata(resultMetadata(value));
|
|
31899
|
+
if (!(value.body instanceof Uint8Array)) {
|
|
31900
|
+
throw new JobEnvelopeError("Invalid job result: missing body");
|
|
31901
|
+
}
|
|
31902
|
+
return value;
|
|
31903
|
+
}
|
|
31904
|
+
function webCrypto() {
|
|
31905
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.getRandomValues !== "function" || !globalThis.crypto.subtle) {
|
|
31906
|
+
throw new JobEnvelopeError(
|
|
31907
|
+
"Job result streaming requires the Web Crypto API"
|
|
31908
|
+
);
|
|
31909
|
+
}
|
|
31910
|
+
return globalThis.crypto;
|
|
31911
|
+
}
|
|
31912
|
+
function uint32(value) {
|
|
31913
|
+
const bytes = new Uint8Array(4);
|
|
31914
|
+
new DataView(bytes.buffer).setUint32(0, value);
|
|
31915
|
+
return bytes;
|
|
31916
|
+
}
|
|
31917
|
+
function readUint32(bytes, offset = 0) {
|
|
31918
|
+
return new DataView(bytes.buffer, bytes.byteOffset + offset, 4).getUint32(0);
|
|
31919
|
+
}
|
|
31920
|
+
function wrappedKeyPlaintext(contentKey, noncePrefix, metadataBytes) {
|
|
31921
|
+
const plaintext = new Uint8Array(
|
|
31922
|
+
WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES + metadataBytes.length
|
|
31923
|
+
);
|
|
31924
|
+
plaintext.set(contentKey, 0);
|
|
31925
|
+
plaintext.set(noncePrefix, AES_KEY_BYTES);
|
|
31926
|
+
new DataView(plaintext.buffer).setUint32(
|
|
31927
|
+
AES_KEY_BYTES + AES_GCM_NONCE_BYTES,
|
|
31928
|
+
metadataBytes.length
|
|
31929
|
+
);
|
|
31930
|
+
plaintext.set(metadataBytes, WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES);
|
|
31931
|
+
return plaintext;
|
|
31932
|
+
}
|
|
31933
|
+
function parseWrappedKeyPlaintext(plaintext) {
|
|
31934
|
+
if (plaintext.length < WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES) {
|
|
31935
|
+
throw new JobEnvelopeError("Invalid job result: wrapped key is truncated");
|
|
31936
|
+
}
|
|
31937
|
+
const metadataLength = readUint32(
|
|
31938
|
+
plaintext,
|
|
31939
|
+
AES_KEY_BYTES + AES_GCM_NONCE_BYTES
|
|
31940
|
+
);
|
|
31941
|
+
if (metadataLength > MAX_JOB_RESULT_HEADER_BYTES) {
|
|
31942
|
+
throw new JobEnvelopeError(
|
|
31943
|
+
`Invalid job result: header exceeds ${MAX_JOB_RESULT_HEADER_BYTES} bytes`
|
|
31944
|
+
);
|
|
31945
|
+
}
|
|
31946
|
+
if (plaintext.length !== WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES + metadataLength) {
|
|
31947
|
+
throw new JobEnvelopeError(
|
|
31948
|
+
"Invalid job result: header length exceeds payload"
|
|
31949
|
+
);
|
|
31950
|
+
}
|
|
31951
|
+
const metadataBytes = plaintext.slice(WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES);
|
|
31952
|
+
const metadata = validateResultMetadata(
|
|
31953
|
+
parseObject(metadataBytes, "job result header")
|
|
31954
|
+
);
|
|
31955
|
+
return {
|
|
31956
|
+
contentKey: plaintext.slice(0, AES_KEY_BYTES),
|
|
31957
|
+
noncePrefix: plaintext.slice(
|
|
31958
|
+
AES_KEY_BYTES,
|
|
31959
|
+
AES_KEY_BYTES + AES_GCM_NONCE_BYTES
|
|
31960
|
+
),
|
|
31961
|
+
metadataBytes,
|
|
31962
|
+
metadata
|
|
31963
|
+
};
|
|
31964
|
+
}
|
|
31965
|
+
async function importAesKey(contentKey, usage) {
|
|
31966
|
+
return webCrypto().subtle.importKey(
|
|
31967
|
+
"raw",
|
|
31968
|
+
contentKey,
|
|
31969
|
+
{ name: "AES-GCM" },
|
|
31970
|
+
false,
|
|
31971
|
+
[usage]
|
|
31972
|
+
);
|
|
31973
|
+
}
|
|
31974
|
+
function chunkNonce(noncePrefix, chunkIndex) {
|
|
31975
|
+
if (chunkIndex > MAX_CHUNK_INDEX) {
|
|
31976
|
+
throw new JobEnvelopeError("Invalid job result: too many chunks");
|
|
31977
|
+
}
|
|
31978
|
+
const nonce = noncePrefix.slice();
|
|
31979
|
+
const view = new DataView(nonce.buffer, nonce.byteOffset, nonce.byteLength);
|
|
31980
|
+
view.setUint32(8, view.getUint32(8) ^ chunkIndex);
|
|
31981
|
+
return nonce;
|
|
31982
|
+
}
|
|
31983
|
+
function chunkAad(metadataBytes, chunkIndex, final, plaintextLength) {
|
|
31984
|
+
const aad = new Uint8Array(14 + metadataBytes.length);
|
|
31985
|
+
aad[0] = JOB_RESULT_FORMAT_VERSION;
|
|
31986
|
+
aad.set(uint32(metadataBytes.length), 1);
|
|
31987
|
+
aad.set(metadataBytes, 5);
|
|
31988
|
+
aad.set(uint32(chunkIndex), 5 + metadataBytes.length);
|
|
31989
|
+
aad[9 + metadataBytes.length] = final ? FINAL_FRAME_FLAG : 0;
|
|
31990
|
+
aad.set(uint32(plaintextLength), 10 + metadataBytes.length);
|
|
31991
|
+
return aad;
|
|
31992
|
+
}
|
|
31993
|
+
async function encryptResultChunk(key, noncePrefix, metadataBytes, plaintext, chunkIndex, final) {
|
|
31994
|
+
const encrypted = new Uint8Array(
|
|
31995
|
+
await webCrypto().subtle.encrypt(
|
|
31996
|
+
{
|
|
31997
|
+
name: "AES-GCM",
|
|
31998
|
+
iv: chunkNonce(noncePrefix, chunkIndex),
|
|
31999
|
+
additionalData: chunkAad(
|
|
32000
|
+
metadataBytes,
|
|
32001
|
+
chunkIndex,
|
|
32002
|
+
final,
|
|
32003
|
+
plaintext.length
|
|
32004
|
+
),
|
|
32005
|
+
tagLength: AES_GCM_TAG_BYTES * 8
|
|
32006
|
+
},
|
|
32007
|
+
key,
|
|
32008
|
+
plaintext
|
|
32009
|
+
)
|
|
32010
|
+
);
|
|
32011
|
+
const frame = new Uint8Array(
|
|
32012
|
+
FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES + encrypted.length
|
|
32013
|
+
);
|
|
32014
|
+
new DataView(frame.buffer).setUint32(0, encrypted.length);
|
|
32015
|
+
frame[FRAME_LENGTH_BYTES] = final ? FINAL_FRAME_FLAG : 0;
|
|
32016
|
+
frame.set(encrypted, FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES);
|
|
32017
|
+
return frame;
|
|
32018
|
+
}
|
|
32019
|
+
function verifyResultBindings(metadata, expect) {
|
|
32020
|
+
if (metadata.jobId !== expect.jobId) {
|
|
32021
|
+
throw new JobEnvelopeError(
|
|
32022
|
+
`Job result ID ${metadata.jobId} does not match expected job ID ${expect.jobId}`
|
|
32023
|
+
);
|
|
32024
|
+
}
|
|
32025
|
+
if (expect.scope !== void 0 && metadata.scope !== expect.scope) {
|
|
32026
|
+
throw new JobEnvelopeError(
|
|
32027
|
+
`Job result scope ${metadata.scope} does not match expected scope ${expect.scope}`
|
|
32028
|
+
);
|
|
32029
|
+
}
|
|
32030
|
+
if (expect.version !== void 0 && metadata.version !== expect.version) {
|
|
32031
|
+
throw new JobEnvelopeError(
|
|
32032
|
+
`Job result version ${String(metadata.version)} does not match expected version ${String(expect.version)}`
|
|
32033
|
+
);
|
|
32034
|
+
}
|
|
32035
|
+
}
|
|
32036
|
+
var ByteStreamReader = class {
|
|
32037
|
+
reader;
|
|
32038
|
+
current;
|
|
32039
|
+
offset = 0;
|
|
32040
|
+
ended = false;
|
|
32041
|
+
constructor(stream) {
|
|
32042
|
+
this.reader = stream.getReader();
|
|
32043
|
+
}
|
|
32044
|
+
async ensureBytes() {
|
|
32045
|
+
while (!this.current || this.offset === this.current.length) {
|
|
32046
|
+
if (this.ended) return false;
|
|
32047
|
+
const next = await this.reader.read();
|
|
32048
|
+
if (next.done) {
|
|
32049
|
+
this.ended = true;
|
|
32050
|
+
this.current = void 0;
|
|
32051
|
+
return false;
|
|
32052
|
+
}
|
|
32053
|
+
if (!(next.value instanceof Uint8Array)) {
|
|
32054
|
+
throw new JobEnvelopeError(
|
|
32055
|
+
"Invalid job result: stream yielded non-byte data"
|
|
32056
|
+
);
|
|
32057
|
+
}
|
|
32058
|
+
this.current = next.value;
|
|
32059
|
+
this.offset = 0;
|
|
32060
|
+
}
|
|
32061
|
+
return true;
|
|
32062
|
+
}
|
|
32063
|
+
async readExactOrNull(length) {
|
|
32064
|
+
if (!await this.ensureBytes()) return null;
|
|
32065
|
+
const bytes = new Uint8Array(length);
|
|
32066
|
+
let written = 0;
|
|
32067
|
+
while (written < length) {
|
|
32068
|
+
if (!await this.ensureBytes()) {
|
|
32069
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32070
|
+
}
|
|
32071
|
+
const available = this.current.length - this.offset;
|
|
32072
|
+
const count = Math.min(available, length - written);
|
|
32073
|
+
bytes.set(
|
|
32074
|
+
this.current.subarray(this.offset, this.offset + count),
|
|
32075
|
+
written
|
|
32076
|
+
);
|
|
32077
|
+
this.offset += count;
|
|
32078
|
+
written += count;
|
|
32079
|
+
}
|
|
32080
|
+
return bytes;
|
|
32081
|
+
}
|
|
32082
|
+
async readExact(length) {
|
|
32083
|
+
const bytes = await this.readExactOrNull(length);
|
|
32084
|
+
if (!bytes) {
|
|
32085
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32086
|
+
}
|
|
32087
|
+
return bytes;
|
|
32088
|
+
}
|
|
32089
|
+
async hasRemaining() {
|
|
32090
|
+
return this.ensureBytes();
|
|
32091
|
+
}
|
|
32092
|
+
async cancel(reason) {
|
|
32093
|
+
await this.reader.cancel(reason);
|
|
32094
|
+
}
|
|
32095
|
+
};
|
|
32096
|
+
function normalizeChunkError(error) {
|
|
32097
|
+
if (error instanceof JobEnvelopeError) return error;
|
|
32098
|
+
return new JobEnvelopeError(
|
|
32099
|
+
`Invalid job result: chunk authentication failed${error instanceof Error ? `: ${error.message}` : ""}`
|
|
32100
|
+
);
|
|
32101
|
+
}
|
|
32160
32102
|
async function sealJobRequest(envelope, enclavePublicKey, ecies) {
|
|
32161
32103
|
const encrypted = await ecies.encrypt(
|
|
32162
32104
|
fromHex6(enclavePublicKey, "bytes"),
|
|
@@ -32173,38 +32115,315 @@ async function openJobRequest(ciphertext, privateKey, ecies) {
|
|
|
32173
32115
|
parseObject(plaintext, "job request envelope")
|
|
32174
32116
|
);
|
|
32175
32117
|
}
|
|
32176
|
-
async function
|
|
32177
|
-
|
|
32178
|
-
const
|
|
32118
|
+
async function sealJobResultStream(metadataValue, builderPublicKey, ecies) {
|
|
32119
|
+
const metadata = validateResultMetadata(metadataValue);
|
|
32120
|
+
const metadataBytes = canonicalJsonBytes(metadata);
|
|
32121
|
+
if (metadataBytes.length > MAX_JOB_RESULT_HEADER_BYTES) {
|
|
32122
|
+
throw new JobEnvelopeError(
|
|
32123
|
+
`Invalid job result: header exceeds ${MAX_JOB_RESULT_HEADER_BYTES} bytes`
|
|
32124
|
+
);
|
|
32125
|
+
}
|
|
32126
|
+
const crypto2 = webCrypto();
|
|
32127
|
+
const contentKey = crypto2.getRandomValues(new Uint8Array(AES_KEY_BYTES));
|
|
32128
|
+
const noncePrefix = crypto2.getRandomValues(
|
|
32129
|
+
new Uint8Array(AES_GCM_NONCE_BYTES)
|
|
32130
|
+
);
|
|
32131
|
+
const key = await importAesKey(contentKey, "encrypt");
|
|
32132
|
+
const keyPlaintext = wrappedKeyPlaintext(
|
|
32133
|
+
contentKey,
|
|
32134
|
+
noncePrefix,
|
|
32135
|
+
metadataBytes
|
|
32136
|
+
);
|
|
32137
|
+
const encryptedKey = await ecies.encrypt(
|
|
32179
32138
|
fromHex6(builderPublicKey, "bytes"),
|
|
32180
|
-
|
|
32139
|
+
keyPlaintext
|
|
32140
|
+
);
|
|
32141
|
+
contentKey.fill(0);
|
|
32142
|
+
keyPlaintext.fill(0);
|
|
32143
|
+
const wrappedKey = encryptedToBytes(encryptedKey);
|
|
32144
|
+
if (wrappedKey.length > MAX_WRAPPED_KEY_BYTES) {
|
|
32145
|
+
throw new JobEnvelopeError("Invalid job result: wrapped key is too large");
|
|
32146
|
+
}
|
|
32147
|
+
const header = new Uint8Array(
|
|
32148
|
+
1 + WRAPPED_KEY_LENGTH_BYTES + wrappedKey.length
|
|
32181
32149
|
);
|
|
32182
|
-
|
|
32183
|
-
|
|
32184
|
-
|
|
32150
|
+
header[0] = JOB_RESULT_FORMAT_VERSION;
|
|
32151
|
+
new DataView(header.buffer).setUint32(1, wrappedKey.length);
|
|
32152
|
+
header.set(wrappedKey, 1 + WRAPPED_KEY_LENGTH_BYTES);
|
|
32153
|
+
let pending = new Uint8Array(JOB_RESULT_CHUNK_BYTES);
|
|
32154
|
+
let pendingLength = 0;
|
|
32155
|
+
let chunkIndex = 0;
|
|
32156
|
+
const transform = new TransformStream({
|
|
32157
|
+
async transform(chunk, controller) {
|
|
32158
|
+
if (!(chunk instanceof Uint8Array)) {
|
|
32159
|
+
throw new JobEnvelopeError(
|
|
32160
|
+
"Invalid job result: stream yielded non-byte data"
|
|
32161
|
+
);
|
|
32162
|
+
}
|
|
32163
|
+
let offset = 0;
|
|
32164
|
+
while (offset < chunk.length) {
|
|
32165
|
+
if (pendingLength === JOB_RESULT_CHUNK_BYTES) {
|
|
32166
|
+
controller.enqueue(
|
|
32167
|
+
await encryptResultChunk(
|
|
32168
|
+
key,
|
|
32169
|
+
noncePrefix,
|
|
32170
|
+
metadataBytes,
|
|
32171
|
+
pending,
|
|
32172
|
+
chunkIndex,
|
|
32173
|
+
false
|
|
32174
|
+
)
|
|
32175
|
+
);
|
|
32176
|
+
chunkIndex += 1;
|
|
32177
|
+
pending = new Uint8Array(JOB_RESULT_CHUNK_BYTES);
|
|
32178
|
+
pendingLength = 0;
|
|
32179
|
+
}
|
|
32180
|
+
const count = Math.min(
|
|
32181
|
+
chunk.length - offset,
|
|
32182
|
+
JOB_RESULT_CHUNK_BYTES - pendingLength
|
|
32183
|
+
);
|
|
32184
|
+
pending.set(chunk.subarray(offset, offset + count), pendingLength);
|
|
32185
|
+
pendingLength += count;
|
|
32186
|
+
offset += count;
|
|
32187
|
+
}
|
|
32188
|
+
},
|
|
32189
|
+
async flush(controller) {
|
|
32190
|
+
controller.enqueue(
|
|
32191
|
+
await encryptResultChunk(
|
|
32192
|
+
key,
|
|
32193
|
+
noncePrefix,
|
|
32194
|
+
metadataBytes,
|
|
32195
|
+
pending.subarray(0, pendingLength),
|
|
32196
|
+
chunkIndex,
|
|
32197
|
+
true
|
|
32198
|
+
)
|
|
32199
|
+
);
|
|
32200
|
+
}
|
|
32201
|
+
});
|
|
32202
|
+
return { header, transform };
|
|
32185
32203
|
}
|
|
32186
|
-
async function
|
|
32187
|
-
|
|
32188
|
-
|
|
32189
|
-
|
|
32204
|
+
async function sealJobResult(result, builderPublicKey, ecies) {
|
|
32205
|
+
validateResult(result);
|
|
32206
|
+
const sealed = await sealJobResultStream(
|
|
32207
|
+
resultMetadata(result),
|
|
32208
|
+
builderPublicKey,
|
|
32209
|
+
ecies
|
|
32210
|
+
);
|
|
32211
|
+
const frameCount = Math.max(
|
|
32212
|
+
1,
|
|
32213
|
+
Math.ceil(result.body.length / JOB_RESULT_CHUNK_BYTES)
|
|
32190
32214
|
);
|
|
32191
|
-
const
|
|
32192
|
-
|
|
32215
|
+
const size = sealed.header.length + result.body.length + frameCount * (FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES + AES_GCM_TAG_BYTES);
|
|
32216
|
+
const bytes = new Uint8Array(size);
|
|
32217
|
+
bytes.set(sealed.header, 0);
|
|
32218
|
+
let outputOffset = sealed.header.length;
|
|
32219
|
+
const reader = sealed.transform.readable.getReader();
|
|
32220
|
+
const drain = (async () => {
|
|
32221
|
+
for (; ; ) {
|
|
32222
|
+
const next = await reader.read();
|
|
32223
|
+
if (next.done) break;
|
|
32224
|
+
bytes.set(next.value, outputOffset);
|
|
32225
|
+
outputOffset += next.value.length;
|
|
32226
|
+
}
|
|
32227
|
+
})();
|
|
32228
|
+
const writer = sealed.transform.writable.getWriter();
|
|
32229
|
+
const fill = (async () => {
|
|
32230
|
+
for (let offset = 0; offset < result.body.length; offset += JOB_RESULT_CHUNK_BYTES) {
|
|
32231
|
+
await writer.write(
|
|
32232
|
+
result.body.subarray(offset, offset + JOB_RESULT_CHUNK_BYTES)
|
|
32233
|
+
);
|
|
32234
|
+
}
|
|
32235
|
+
await writer.close();
|
|
32236
|
+
})();
|
|
32237
|
+
await Promise.all([drain, fill]);
|
|
32238
|
+
if (outputOffset !== bytes.length) {
|
|
32239
|
+
throw new JobEnvelopeError("Invalid job result: sealed size mismatch");
|
|
32240
|
+
}
|
|
32241
|
+
return { bytes, hash: bytesToHex2(sha2565(bytes)), size };
|
|
32242
|
+
}
|
|
32243
|
+
async function openJobResultStream(bytesStream, builderPrivateKey, ecies, expect) {
|
|
32244
|
+
const reader = new ByteStreamReader(bytesStream);
|
|
32245
|
+
const headerPrefix = await reader.readExact(1 + WRAPPED_KEY_LENGTH_BYTES);
|
|
32246
|
+
const formatVersion = headerPrefix[0];
|
|
32247
|
+
if (formatVersion !== JOB_RESULT_FORMAT_VERSION) {
|
|
32193
32248
|
throw new JobEnvelopeError(
|
|
32194
|
-
`
|
|
32249
|
+
`Unsupported job result format: ${String(formatVersion)}`
|
|
32195
32250
|
);
|
|
32196
32251
|
}
|
|
32197
|
-
|
|
32252
|
+
const wrappedKeyLength = readUint32(headerPrefix, 1);
|
|
32253
|
+
if (wrappedKeyLength === 0 || wrappedKeyLength > MAX_WRAPPED_KEY_BYTES) {
|
|
32198
32254
|
throw new JobEnvelopeError(
|
|
32199
|
-
|
|
32255
|
+
"Invalid job result: invalid wrapped key length"
|
|
32200
32256
|
);
|
|
32201
32257
|
}
|
|
32202
|
-
|
|
32258
|
+
const wrappedKey = await reader.readExact(wrappedKeyLength);
|
|
32259
|
+
const keyPlaintext = await ecies.decrypt(
|
|
32260
|
+
fromHex6(builderPrivateKey, "bytes"),
|
|
32261
|
+
bytesToEncrypted(wrappedKey)
|
|
32262
|
+
);
|
|
32263
|
+
const parsed = parseWrappedKeyPlaintext(keyPlaintext);
|
|
32264
|
+
verifyResultBindings(parsed.metadata, expect);
|
|
32265
|
+
const key = await importAesKey(parsed.contentKey, "decrypt");
|
|
32266
|
+
parsed.contentKey.fill(0);
|
|
32267
|
+
keyPlaintext.fill(0);
|
|
32268
|
+
let chunkIndex = 0;
|
|
32269
|
+
let finished = false;
|
|
32270
|
+
const body = new ReadableStream({
|
|
32271
|
+
async pull(controller) {
|
|
32272
|
+
if (finished) {
|
|
32273
|
+
controller.close();
|
|
32274
|
+
return;
|
|
32275
|
+
}
|
|
32276
|
+
try {
|
|
32277
|
+
const frameHeader = await reader.readExactOrNull(
|
|
32278
|
+
FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES
|
|
32279
|
+
);
|
|
32280
|
+
if (!frameHeader) {
|
|
32281
|
+
throw new JobEnvelopeError("Invalid job result: missing final chunk");
|
|
32282
|
+
}
|
|
32283
|
+
const encryptedLength = readUint32(frameHeader);
|
|
32284
|
+
if (encryptedLength < AES_GCM_TAG_BYTES || encryptedLength > JOB_RESULT_CHUNK_BYTES + AES_GCM_TAG_BYTES) {
|
|
32285
|
+
throw new JobEnvelopeError(
|
|
32286
|
+
"Invalid job result: invalid chunk length"
|
|
32287
|
+
);
|
|
32288
|
+
}
|
|
32289
|
+
const flags = frameHeader[FRAME_LENGTH_BYTES];
|
|
32290
|
+
if (flags !== 0 && flags !== FINAL_FRAME_FLAG) {
|
|
32291
|
+
throw new JobEnvelopeError("Invalid job result: invalid chunk flags");
|
|
32292
|
+
}
|
|
32293
|
+
const final = flags === FINAL_FRAME_FLAG;
|
|
32294
|
+
const plaintextLength = encryptedLength - AES_GCM_TAG_BYTES;
|
|
32295
|
+
if (!final && plaintextLength !== JOB_RESULT_CHUNK_BYTES) {
|
|
32296
|
+
throw new JobEnvelopeError(
|
|
32297
|
+
"Invalid job result: short non-final chunk"
|
|
32298
|
+
);
|
|
32299
|
+
}
|
|
32300
|
+
const encrypted = await reader.readExact(encryptedLength);
|
|
32301
|
+
const plaintext = new Uint8Array(
|
|
32302
|
+
await webCrypto().subtle.decrypt(
|
|
32303
|
+
{
|
|
32304
|
+
name: "AES-GCM",
|
|
32305
|
+
iv: chunkNonce(parsed.noncePrefix, chunkIndex),
|
|
32306
|
+
additionalData: chunkAad(
|
|
32307
|
+
parsed.metadataBytes,
|
|
32308
|
+
chunkIndex,
|
|
32309
|
+
final,
|
|
32310
|
+
plaintextLength
|
|
32311
|
+
),
|
|
32312
|
+
tagLength: AES_GCM_TAG_BYTES * 8
|
|
32313
|
+
},
|
|
32314
|
+
key,
|
|
32315
|
+
encrypted
|
|
32316
|
+
)
|
|
32317
|
+
);
|
|
32318
|
+
if (plaintext.length !== plaintextLength) {
|
|
32319
|
+
throw new JobEnvelopeError(
|
|
32320
|
+
"Invalid job result: decrypted chunk length mismatch"
|
|
32321
|
+
);
|
|
32322
|
+
}
|
|
32323
|
+
chunkIndex += 1;
|
|
32324
|
+
if (final) {
|
|
32325
|
+
if (await reader.hasRemaining()) {
|
|
32326
|
+
throw new JobEnvelopeError(
|
|
32327
|
+
"Invalid job result: bytes follow final chunk"
|
|
32328
|
+
);
|
|
32329
|
+
}
|
|
32330
|
+
finished = true;
|
|
32331
|
+
}
|
|
32332
|
+
controller.enqueue(plaintext);
|
|
32333
|
+
if (finished) controller.close();
|
|
32334
|
+
} catch (error) {
|
|
32335
|
+
controller.error(normalizeChunkError(error));
|
|
32336
|
+
void reader.cancel(error).catch(() => void 0);
|
|
32337
|
+
}
|
|
32338
|
+
},
|
|
32339
|
+
cancel(reason) {
|
|
32340
|
+
return reader.cancel(reason);
|
|
32341
|
+
}
|
|
32342
|
+
});
|
|
32343
|
+
return { metadata: parsed.metadata, body };
|
|
32344
|
+
}
|
|
32345
|
+
function bufferedResultBodySize(sealedBytes) {
|
|
32346
|
+
if (sealedBytes.length < 1 + WRAPPED_KEY_LENGTH_BYTES) {
|
|
32347
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32348
|
+
}
|
|
32349
|
+
if (sealedBytes[0] !== JOB_RESULT_FORMAT_VERSION) {
|
|
32350
|
+
throw new JobEnvelopeError(
|
|
32351
|
+
`Unsupported job result format: ${String(sealedBytes[0])}`
|
|
32352
|
+
);
|
|
32353
|
+
}
|
|
32354
|
+
const wrappedKeyLength = readUint32(sealedBytes, 1);
|
|
32355
|
+
if (wrappedKeyLength === 0 || wrappedKeyLength > MAX_WRAPPED_KEY_BYTES) {
|
|
32203
32356
|
throw new JobEnvelopeError(
|
|
32204
|
-
|
|
32357
|
+
"Invalid job result: invalid wrapped key length"
|
|
32205
32358
|
);
|
|
32206
32359
|
}
|
|
32207
|
-
|
|
32360
|
+
let offset = 1 + WRAPPED_KEY_LENGTH_BYTES + wrappedKeyLength;
|
|
32361
|
+
if (offset > sealedBytes.length) {
|
|
32362
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32363
|
+
}
|
|
32364
|
+
let bodySize = 0;
|
|
32365
|
+
let sawFinal = false;
|
|
32366
|
+
while (offset < sealedBytes.length) {
|
|
32367
|
+
if (sealedBytes.length - offset < FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES) {
|
|
32368
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32369
|
+
}
|
|
32370
|
+
const encryptedLength = readUint32(sealedBytes, offset);
|
|
32371
|
+
const flags = sealedBytes[offset + FRAME_LENGTH_BYTES];
|
|
32372
|
+
if (encryptedLength < AES_GCM_TAG_BYTES || encryptedLength > JOB_RESULT_CHUNK_BYTES + AES_GCM_TAG_BYTES || flags !== 0 && flags !== FINAL_FRAME_FLAG) {
|
|
32373
|
+
throw new JobEnvelopeError("Invalid job result: invalid chunk framing");
|
|
32374
|
+
}
|
|
32375
|
+
const plaintextLength = encryptedLength - AES_GCM_TAG_BYTES;
|
|
32376
|
+
if (flags === 0 && plaintextLength !== JOB_RESULT_CHUNK_BYTES) {
|
|
32377
|
+
throw new JobEnvelopeError("Invalid job result: short non-final chunk");
|
|
32378
|
+
}
|
|
32379
|
+
offset += FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES;
|
|
32380
|
+
if (encryptedLength > sealedBytes.length - offset) {
|
|
32381
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32382
|
+
}
|
|
32383
|
+
offset += encryptedLength;
|
|
32384
|
+
bodySize += plaintextLength;
|
|
32385
|
+
if (flags === FINAL_FRAME_FLAG) {
|
|
32386
|
+
sawFinal = true;
|
|
32387
|
+
if (offset !== sealedBytes.length) {
|
|
32388
|
+
throw new JobEnvelopeError(
|
|
32389
|
+
"Invalid job result: bytes follow final chunk"
|
|
32390
|
+
);
|
|
32391
|
+
}
|
|
32392
|
+
}
|
|
32393
|
+
}
|
|
32394
|
+
if (!sawFinal) {
|
|
32395
|
+
throw new JobEnvelopeError("Invalid job result: missing final chunk");
|
|
32396
|
+
}
|
|
32397
|
+
return bodySize;
|
|
32398
|
+
}
|
|
32399
|
+
async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
|
|
32400
|
+
const bodySize = bufferedResultBodySize(sealedBytes);
|
|
32401
|
+
const stream = new ReadableStream({
|
|
32402
|
+
start(controller) {
|
|
32403
|
+
controller.enqueue(sealedBytes);
|
|
32404
|
+
controller.close();
|
|
32405
|
+
}
|
|
32406
|
+
});
|
|
32407
|
+
const opened = await openJobResultStream(
|
|
32408
|
+
stream,
|
|
32409
|
+
builderPrivateKey,
|
|
32410
|
+
ecies,
|
|
32411
|
+
expect
|
|
32412
|
+
);
|
|
32413
|
+
const body = new Uint8Array(bodySize);
|
|
32414
|
+
let offset = 0;
|
|
32415
|
+
await opened.body.pipeTo(
|
|
32416
|
+
new WritableStream({
|
|
32417
|
+
write(chunk) {
|
|
32418
|
+
body.set(chunk, offset);
|
|
32419
|
+
offset += chunk.length;
|
|
32420
|
+
}
|
|
32421
|
+
})
|
|
32422
|
+
);
|
|
32423
|
+
if (offset !== body.length) {
|
|
32424
|
+
throw new JobEnvelopeError("Invalid job result: opened size mismatch");
|
|
32425
|
+
}
|
|
32426
|
+
return { ...opened.metadata, body };
|
|
32208
32427
|
}
|
|
32209
32428
|
|
|
32210
32429
|
// src/protocol/personal-server-registration.ts
|
|
@@ -32910,6 +33129,7 @@ import {
|
|
|
32910
33129
|
maxUint256,
|
|
32911
33130
|
stringToBytes as stringToBytes3
|
|
32912
33131
|
} from "viem";
|
|
33132
|
+
import { DataPointDeletedError, DataPointNotFoundError } from "./errors.js";
|
|
32913
33133
|
|
|
32914
33134
|
// src/protocol/lineage.ts
|
|
32915
33135
|
import {
|
|
@@ -32918,6 +33138,7 @@ import {
|
|
|
32918
33138
|
keccak256 as keccak2562
|
|
32919
33139
|
} from "viem";
|
|
32920
33140
|
import { z } from "zod";
|
|
33141
|
+
import { LineageReadError, WriteRequestError as WriteRequestError2 } from "./errors.js";
|
|
32921
33142
|
|
|
32922
33143
|
// src/protocol/personal-server-error-body.ts
|
|
32923
33144
|
function isRecord2(value) {
|
|
@@ -32949,6 +33170,7 @@ async function readPersonalServerErrorBody(response) {
|
|
|
32949
33170
|
}
|
|
32950
33171
|
|
|
32951
33172
|
// src/protocol/write-signer.ts
|
|
33173
|
+
import { WriteRequestError } from "./errors.js";
|
|
32952
33174
|
function isRecord3(value) {
|
|
32953
33175
|
return value !== null && typeof value === "object";
|
|
32954
33176
|
}
|
|
@@ -33029,7 +33251,7 @@ function derivedScopeViolatesNaming(derivedScope, sourceScope) {
|
|
|
33029
33251
|
function assertDerivedScopeNaming(derivedScope, sourceScopes) {
|
|
33030
33252
|
for (const sourceScope of sourceScopes) {
|
|
33031
33253
|
if (derivedScopeViolatesNaming(derivedScope, sourceScope)) {
|
|
33032
|
-
throw new
|
|
33254
|
+
throw new WriteRequestError2(
|
|
33033
33255
|
`Derived scope ${derivedScope} must not share its first segment with source scope ${sourceScope}; put derivatives in the app's own namespace`,
|
|
33034
33256
|
{ scope: derivedScope, sourceScope }
|
|
33035
33257
|
);
|
|
@@ -33387,6 +33609,9 @@ async function deleteDataPoint(input) {
|
|
|
33387
33609
|
}
|
|
33388
33610
|
}
|
|
33389
33611
|
|
|
33612
|
+
// src/protocol/personal-server-data.ts
|
|
33613
|
+
import { DataPointDeletedError as DataPointDeletedError2 } from "./errors.js";
|
|
33614
|
+
|
|
33390
33615
|
// src/protocol/data-file.ts
|
|
33391
33616
|
import { z as z2 } from "zod";
|
|
33392
33617
|
var DataFileEnvelopeSchema = z2.object({
|
|
@@ -33445,7 +33670,7 @@ async function readPersonalServerData(params) {
|
|
|
33445
33670
|
const request = await buildPersonalServerDataReadRequest(params);
|
|
33446
33671
|
const response = await fetchFn(request);
|
|
33447
33672
|
if (response.status === 410) {
|
|
33448
|
-
throw new
|
|
33673
|
+
throw new DataPointDeletedError2(
|
|
33449
33674
|
`Personal Server scope '${params.scope}' has been deleted`,
|
|
33450
33675
|
{
|
|
33451
33676
|
scope: params.scope,
|
|
@@ -33460,7 +33685,7 @@ async function readPersonalServerData(params) {
|
|
|
33460
33685
|
}
|
|
33461
33686
|
const body = await response.json();
|
|
33462
33687
|
if (isDataPointTombstone(body)) {
|
|
33463
|
-
throw new
|
|
33688
|
+
throw new DataPointDeletedError2(
|
|
33464
33689
|
`Personal Server scope '${params.scope}' has been deleted`,
|
|
33465
33690
|
{ scope: params.scope, deletedAt: tombstoneDeletedAt(body) }
|
|
33466
33691
|
);
|
|
@@ -33663,17 +33888,28 @@ function tryGrantPermissions(scopes) {
|
|
|
33663
33888
|
import { sha256 as sha2567 } from "@noble/hashes/sha2";
|
|
33664
33889
|
import { bytesToHex as bytesToHex4, isAddress as isAddress7 } from "viem";
|
|
33665
33890
|
import { z as z4 } from "zod";
|
|
33891
|
+
import {
|
|
33892
|
+
WriteConflictError,
|
|
33893
|
+
WriteForbiddenError,
|
|
33894
|
+
WriteLineageError,
|
|
33895
|
+
WriteRejectedError,
|
|
33896
|
+
WriteRequestError as WriteRequestError4,
|
|
33897
|
+
WriteSessionError,
|
|
33898
|
+
WriteSessionExpiredError,
|
|
33899
|
+
WriteUnauthorizedError
|
|
33900
|
+
} from "./errors.js";
|
|
33666
33901
|
|
|
33667
33902
|
// src/protocol/write-request.ts
|
|
33668
33903
|
import { sha256 as sha2566 } from "@noble/hashes/sha2";
|
|
33669
33904
|
import { bytesToHex as bytesToHex3 } from "viem";
|
|
33905
|
+
import { WriteRequestError as WriteRequestError3, WriteTransportError } from "./errors.js";
|
|
33670
33906
|
function normalizeBaseUrl2(url) {
|
|
33671
33907
|
return url.replace(/\/+$/, "");
|
|
33672
33908
|
}
|
|
33673
33909
|
function resolveFetch2(fetchFn) {
|
|
33674
33910
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
33675
33911
|
if (resolved === void 0) {
|
|
33676
|
-
throw new
|
|
33912
|
+
throw new WriteRequestError3("No fetch implementation available");
|
|
33677
33913
|
}
|
|
33678
33914
|
return resolved;
|
|
33679
33915
|
}
|
|
@@ -33728,14 +33964,14 @@ function nextProofIat(proofKey) {
|
|
|
33728
33964
|
return sleep2(waitSec * 1e3).then(() => iat);
|
|
33729
33965
|
}
|
|
33730
33966
|
function freshProofNonce() {
|
|
33731
|
-
const
|
|
33732
|
-
if (typeof
|
|
33733
|
-
return
|
|
33967
|
+
const webCrypto2 = globalThis.crypto;
|
|
33968
|
+
if (typeof webCrypto2?.randomUUID === "function") {
|
|
33969
|
+
return webCrypto2.randomUUID();
|
|
33734
33970
|
}
|
|
33735
|
-
if (typeof
|
|
33736
|
-
return bytesToHex3(
|
|
33971
|
+
if (typeof webCrypto2?.getRandomValues === "function") {
|
|
33972
|
+
return bytesToHex3(webCrypto2.getRandomValues(new Uint8Array(16)));
|
|
33737
33973
|
}
|
|
33738
|
-
throw new
|
|
33974
|
+
throw new WriteRequestError3(
|
|
33739
33975
|
"No secure random source available to build a proof nonce; provide a crypto global"
|
|
33740
33976
|
);
|
|
33741
33977
|
}
|
|
@@ -33891,7 +34127,7 @@ function isWriteSession(value) {
|
|
|
33891
34127
|
}
|
|
33892
34128
|
function sessionCoversScope(session, scope) {
|
|
33893
34129
|
if (!isRecord2(session) || !Array.isArray(session.writeScopes) || !session.writeScopes.every((pattern) => typeof pattern === "string")) {
|
|
33894
|
-
throw new
|
|
34130
|
+
throw new WriteRequestError4("session must come from openWriteSession");
|
|
33895
34131
|
}
|
|
33896
34132
|
return session.writeScopes.some(
|
|
33897
34133
|
(pattern) => scopeMatchesPattern(scope, pattern)
|
|
@@ -33916,12 +34152,12 @@ function encodeWriteMetadataHeader(metadata) {
|
|
|
33916
34152
|
try {
|
|
33917
34153
|
json = JSON.stringify(metadata);
|
|
33918
34154
|
} catch (err) {
|
|
33919
|
-
throw new
|
|
34155
|
+
throw new WriteRequestError4(
|
|
33920
34156
|
`metadata is not JSON-serialisable: ${errorMessage(err)}`
|
|
33921
34157
|
);
|
|
33922
34158
|
}
|
|
33923
34159
|
if (typeof json !== "string") {
|
|
33924
|
-
throw new
|
|
34160
|
+
throw new WriteRequestError4("metadata must serialise to JSON");
|
|
33925
34161
|
}
|
|
33926
34162
|
return json.replace(
|
|
33927
34163
|
/[\u007f-\uffff]/g,
|
|
@@ -33956,7 +34192,7 @@ function setFilenameHeader(headers, filename) {
|
|
|
33956
34192
|
function assertNoReservedKeys(value, where) {
|
|
33957
34193
|
for (const key of RESERVED_WRITE_KEYS) {
|
|
33958
34194
|
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
33959
|
-
throw new
|
|
34195
|
+
throw new WriteRequestError4(
|
|
33960
34196
|
`${where} must not contain the reserved ${key} key; the Personal Server stamps it`,
|
|
33961
34197
|
{ key }
|
|
33962
34198
|
);
|
|
@@ -33968,10 +34204,10 @@ function isLineagePair(value) {
|
|
|
33968
34204
|
}
|
|
33969
34205
|
function normalizeLineage(lineage, derivedScope) {
|
|
33970
34206
|
if (!Array.isArray(lineage)) {
|
|
33971
|
-
throw new
|
|
34207
|
+
throw new WriteRequestError4("lineage must be an array of data point ids");
|
|
33972
34208
|
}
|
|
33973
34209
|
if (lineage.length > MAX_LINEAGE_SOURCES) {
|
|
33974
|
-
throw new
|
|
34210
|
+
throw new WriteRequestError4(
|
|
33975
34211
|
`lineage lists ${lineage.length} sources; the maximum is ${MAX_LINEAGE_SOURCES}`,
|
|
33976
34212
|
{ max: MAX_LINEAGE_SOURCES, count: lineage.length }
|
|
33977
34213
|
);
|
|
@@ -33984,13 +34220,13 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
33984
34220
|
let id;
|
|
33985
34221
|
if (isLineagePair(entry)) {
|
|
33986
34222
|
if (!isAddress7(entry.ownerAddress, { strict: false })) {
|
|
33987
|
-
throw new
|
|
34223
|
+
throw new WriteRequestError4(
|
|
33988
34224
|
"lineage source ownerAddress must be an EVM address",
|
|
33989
34225
|
{ ownerAddress: entry.ownerAddress }
|
|
33990
34226
|
);
|
|
33991
34227
|
}
|
|
33992
34228
|
if (entry.scope.length === 0) {
|
|
33993
|
-
throw new
|
|
34229
|
+
throw new WriteRequestError4("lineage source scope is required");
|
|
33994
34230
|
}
|
|
33995
34231
|
id = deriveDataPointId(entry.ownerAddress, entry.scope);
|
|
33996
34232
|
sourceScopes.push(entry.scope);
|
|
@@ -33998,14 +34234,14 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
33998
34234
|
} else if (isDataPointId(entry)) {
|
|
33999
34235
|
id = entry;
|
|
34000
34236
|
} else {
|
|
34001
|
-
throw new
|
|
34237
|
+
throw new WriteRequestError4(
|
|
34002
34238
|
"lineage entries must be 32-byte hex data point ids or { ownerAddress, scope } pairs",
|
|
34003
34239
|
{ entry }
|
|
34004
34240
|
);
|
|
34005
34241
|
}
|
|
34006
34242
|
const normalized = id.toLowerCase();
|
|
34007
34243
|
if (seen.has(normalized)) {
|
|
34008
|
-
throw new
|
|
34244
|
+
throw new WriteRequestError4("lineage must not repeat a data point id", {
|
|
34009
34245
|
dataPointId: normalized
|
|
34010
34246
|
});
|
|
34011
34247
|
}
|
|
@@ -34014,7 +34250,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
34014
34250
|
}
|
|
34015
34251
|
for (const own of ownIds) {
|
|
34016
34252
|
if (seen.has(own)) {
|
|
34017
|
-
throw new
|
|
34253
|
+
throw new WriteRequestError4(
|
|
34018
34254
|
"lineage must not cite the record's own data point",
|
|
34019
34255
|
{ dataPointId: own, scope: derivedScope }
|
|
34020
34256
|
);
|
|
@@ -34025,7 +34261,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
34025
34261
|
}
|
|
34026
34262
|
function assertNoLineageField(value, where) {
|
|
34027
34263
|
if (Object.prototype.hasOwnProperty.call(value, LINEAGE_FIELD)) {
|
|
34028
|
-
throw new
|
|
34264
|
+
throw new WriteRequestError4(
|
|
34029
34265
|
`${where}.${LINEAGE_FIELD} is reserved; pass sources through the lineage option`
|
|
34030
34266
|
);
|
|
34031
34267
|
}
|
|
@@ -34033,7 +34269,7 @@ function assertNoLineageField(value, where) {
|
|
|
34033
34269
|
function buildMetadataHeader(metadata, sources) {
|
|
34034
34270
|
if (metadata !== void 0) {
|
|
34035
34271
|
if (!isRecord2(metadata)) {
|
|
34036
|
-
throw new
|
|
34272
|
+
throw new WriteRequestError4("metadata must be a plain object");
|
|
34037
34273
|
}
|
|
34038
34274
|
assertNoReservedKeys(metadata, "metadata");
|
|
34039
34275
|
assertNoLineageField(metadata, "metadata");
|
|
@@ -34046,24 +34282,24 @@ function buildMetadataHeader(metadata, sources) {
|
|
|
34046
34282
|
}
|
|
34047
34283
|
function prepareWrite(params) {
|
|
34048
34284
|
if (params.binary !== void 0 && params.data !== void 0) {
|
|
34049
|
-
throw new
|
|
34285
|
+
throw new WriteRequestError4("Pass either data or binary, not both");
|
|
34050
34286
|
}
|
|
34051
34287
|
const rawLineage = params.lineage;
|
|
34052
34288
|
const sources = rawLineage === void 0 || rawLineage === null ? void 0 : normalizeLineage(rawLineage, params.scope);
|
|
34053
34289
|
if (params.binary !== void 0) {
|
|
34054
34290
|
const { bytes, contentType, filename } = params.binary;
|
|
34055
34291
|
if (!(bytes instanceof Uint8Array)) {
|
|
34056
|
-
throw new
|
|
34292
|
+
throw new WriteRequestError4("binary.bytes must be a Uint8Array");
|
|
34057
34293
|
}
|
|
34058
34294
|
if (typeof contentType !== "string" || contentType.trim() === "") {
|
|
34059
|
-
throw new
|
|
34295
|
+
throw new WriteRequestError4("binary.contentType is required");
|
|
34060
34296
|
}
|
|
34061
34297
|
if (filename !== void 0) {
|
|
34062
34298
|
if (typeof filename !== "string") {
|
|
34063
|
-
throw new
|
|
34299
|
+
throw new WriteRequestError4("binary.filename must be a string");
|
|
34064
34300
|
}
|
|
34065
34301
|
if (filename !== filename.trim()) {
|
|
34066
|
-
throw new
|
|
34302
|
+
throw new WriteRequestError4(
|
|
34067
34303
|
"binary.filename must not have leading or trailing whitespace"
|
|
34068
34304
|
);
|
|
34069
34305
|
}
|
|
@@ -34083,13 +34319,13 @@ function prepareWrite(params) {
|
|
|
34083
34319
|
};
|
|
34084
34320
|
}
|
|
34085
34321
|
if (params.data === void 0) {
|
|
34086
|
-
throw new
|
|
34322
|
+
throw new WriteRequestError4("Pass data (a JSON object) or binary");
|
|
34087
34323
|
}
|
|
34088
34324
|
if (!isRecord2(params.data)) {
|
|
34089
|
-
throw new
|
|
34325
|
+
throw new WriteRequestError4("data must be a plain JSON object");
|
|
34090
34326
|
}
|
|
34091
34327
|
if (params.metadata !== void 0) {
|
|
34092
|
-
throw new
|
|
34328
|
+
throw new WriteRequestError4(
|
|
34093
34329
|
"metadata applies to binary writes; put fields to store inside data"
|
|
34094
34330
|
);
|
|
34095
34331
|
}
|
|
@@ -34100,12 +34336,12 @@ function prepareWrite(params) {
|
|
|
34100
34336
|
try {
|
|
34101
34337
|
text = JSON.stringify(record);
|
|
34102
34338
|
} catch (err) {
|
|
34103
|
-
throw new
|
|
34339
|
+
throw new WriteRequestError4(
|
|
34104
34340
|
`data is not JSON-serialisable: ${errorMessage(err)}`
|
|
34105
34341
|
);
|
|
34106
34342
|
}
|
|
34107
34343
|
if (typeof text !== "string" || !text.startsWith("{")) {
|
|
34108
|
-
throw new
|
|
34344
|
+
throw new WriteRequestError4("data must serialise to a JSON object");
|
|
34109
34345
|
}
|
|
34110
34346
|
const body = new TextEncoder().encode(text);
|
|
34111
34347
|
return {
|
|
@@ -34134,11 +34370,11 @@ async function writeErrorFromResponse(response) {
|
|
|
34134
34370
|
async function writeData(params) {
|
|
34135
34371
|
const { session } = params;
|
|
34136
34372
|
if (!isWriteSession(session)) {
|
|
34137
|
-
throw new
|
|
34373
|
+
throw new WriteRequestError4("session must come from openWriteSession");
|
|
34138
34374
|
}
|
|
34139
34375
|
const fetchFn = resolveFetch2(params.fetch);
|
|
34140
34376
|
if (typeof params.scope !== "string" || params.scope.length === 0) {
|
|
34141
|
-
throw new
|
|
34377
|
+
throw new WriteRequestError4("scope is required");
|
|
34142
34378
|
}
|
|
34143
34379
|
const prepared = prepareWrite(params);
|
|
34144
34380
|
if (Date.now() >= session.expiresAt) {
|
|
@@ -34234,6 +34470,21 @@ async function writePersonalServerData(params) {
|
|
|
34234
34470
|
|
|
34235
34471
|
// src/protocol/derivative-questions.ts
|
|
34236
34472
|
import { z as z5 } from "zod";
|
|
34473
|
+
import {
|
|
34474
|
+
DerivativeComputeUnavailableError,
|
|
34475
|
+
DerivativeCycleError,
|
|
34476
|
+
DerivativeDerivedScopeRequiredError,
|
|
34477
|
+
DerivativeQuestionFailedError,
|
|
34478
|
+
DerivativeQuestionInvalidError,
|
|
34479
|
+
DerivativeQuestionNotFoundError,
|
|
34480
|
+
DerivativeQuestionRejectedError,
|
|
34481
|
+
DerivativeQuestionTimeoutError,
|
|
34482
|
+
DerivativeSourceNotGrantedError,
|
|
34483
|
+
WriteConflictError as WriteConflictError2,
|
|
34484
|
+
WriteForbiddenError as WriteForbiddenError2,
|
|
34485
|
+
WriteRequestError as WriteRequestError5,
|
|
34486
|
+
WriteUnauthorizedError as WriteUnauthorizedError2
|
|
34487
|
+
} from "./errors.js";
|
|
34237
34488
|
var DERIVATIVE_QUESTIONS_PATH = "/v1/derivatives/questions";
|
|
34238
34489
|
var MAX_QUESTION_SOURCE_SCOPES = 16;
|
|
34239
34490
|
var MAX_QUESTION_CHARS = 8e3;
|
|
@@ -34316,15 +34567,15 @@ function fetchIdOf(fetchFn) {
|
|
|
34316
34567
|
}
|
|
34317
34568
|
function resolveRequest(params) {
|
|
34318
34569
|
if (typeof params.personalServerUrl !== "string" || params.personalServerUrl.length === 0) {
|
|
34319
|
-
throw new
|
|
34570
|
+
throw new WriteRequestError5("personalServerUrl is required");
|
|
34320
34571
|
}
|
|
34321
34572
|
if (typeof params.grantId !== "string" || params.grantId.length === 0) {
|
|
34322
|
-
throw new
|
|
34573
|
+
throw new WriteRequestError5(
|
|
34323
34574
|
"grantId is required; a question call runs under the grant carrying write:<derivedScope>"
|
|
34324
34575
|
);
|
|
34325
34576
|
}
|
|
34326
34577
|
if (params.signer === null || typeof params.signer !== "object") {
|
|
34327
|
-
throw new
|
|
34578
|
+
throw new WriteRequestError5(
|
|
34328
34579
|
"signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
|
|
34329
34580
|
);
|
|
34330
34581
|
}
|
|
@@ -34400,13 +34651,13 @@ async function questionErrorFromResponse(response, body) {
|
|
|
34400
34651
|
}
|
|
34401
34652
|
switch (response.status) {
|
|
34402
34653
|
case 401:
|
|
34403
|
-
return new
|
|
34654
|
+
return new WriteUnauthorizedError2(text, errorCode, details);
|
|
34404
34655
|
case 403:
|
|
34405
|
-
return new
|
|
34656
|
+
return new WriteForbiddenError2(text, errorCode, details);
|
|
34406
34657
|
case 404:
|
|
34407
34658
|
return new DerivativeQuestionNotFoundError(text, errorCode, details);
|
|
34408
34659
|
case 409:
|
|
34409
|
-
return new
|
|
34660
|
+
return new WriteConflictError2(text, errorCode, details);
|
|
34410
34661
|
default:
|
|
34411
34662
|
return new DerivativeQuestionRejectedError(
|
|
34412
34663
|
text,
|
|
@@ -34508,22 +34759,22 @@ async function sendQuestionRequest(params, spec, schema) {
|
|
|
34508
34759
|
}
|
|
34509
34760
|
function assertQuestionId(questionId) {
|
|
34510
34761
|
if (typeof questionId !== "string" || questionId.length === 0) {
|
|
34511
|
-
throw new
|
|
34762
|
+
throw new WriteRequestError5("questionId is required");
|
|
34512
34763
|
}
|
|
34513
34764
|
return `${DERIVATIVE_QUESTIONS_PATH}/${encodeURIComponent(questionId)}`;
|
|
34514
34765
|
}
|
|
34515
34766
|
function registrationBody(params) {
|
|
34516
34767
|
const { derivedScope, question } = params;
|
|
34517
34768
|
if (typeof derivedScope !== "string" || derivedScope.length === 0) {
|
|
34518
|
-
throw new
|
|
34769
|
+
throw new WriteRequestError5("derivedScope is required");
|
|
34519
34770
|
}
|
|
34520
34771
|
if (!Array.isArray(params.sourceScopes) || params.sourceScopes.length === 0) {
|
|
34521
|
-
throw new
|
|
34772
|
+
throw new WriteRequestError5(
|
|
34522
34773
|
"sourceScopes must be a non-empty array of scopes"
|
|
34523
34774
|
);
|
|
34524
34775
|
}
|
|
34525
34776
|
if (params.sourceScopes.length > MAX_QUESTION_SOURCE_SCOPES) {
|
|
34526
|
-
throw new
|
|
34777
|
+
throw new WriteRequestError5(
|
|
34527
34778
|
`sourceScopes lists ${params.sourceScopes.length} scopes; the maximum is ${MAX_QUESTION_SOURCE_SCOPES}`,
|
|
34528
34779
|
{ max: MAX_QUESTION_SOURCE_SCOPES, count: params.sourceScopes.length }
|
|
34529
34780
|
);
|
|
@@ -34531,15 +34782,15 @@ function registrationBody(params) {
|
|
|
34531
34782
|
const sourceScopes = [];
|
|
34532
34783
|
for (const scope of params.sourceScopes) {
|
|
34533
34784
|
if (typeof scope !== "string" || scope.length === 0) {
|
|
34534
|
-
throw new
|
|
34785
|
+
throw new WriteRequestError5("sourceScopes entries must be scope strings");
|
|
34535
34786
|
}
|
|
34536
34787
|
if (sourceScopes.includes(scope)) {
|
|
34537
|
-
throw new
|
|
34788
|
+
throw new WriteRequestError5("sourceScopes must not repeat a scope", {
|
|
34538
34789
|
duplicate: scope
|
|
34539
34790
|
});
|
|
34540
34791
|
}
|
|
34541
34792
|
if (scope === derivedScope) {
|
|
34542
|
-
throw new
|
|
34793
|
+
throw new WriteRequestError5(
|
|
34543
34794
|
"derivedScope cannot be one of its own sources",
|
|
34544
34795
|
{ scope }
|
|
34545
34796
|
);
|
|
@@ -34547,17 +34798,17 @@ function registrationBody(params) {
|
|
|
34547
34798
|
sourceScopes.push(scope);
|
|
34548
34799
|
}
|
|
34549
34800
|
if (typeof question !== "string" || question.trim() === "") {
|
|
34550
|
-
throw new
|
|
34801
|
+
throw new WriteRequestError5("question must be a non-empty string");
|
|
34551
34802
|
}
|
|
34552
34803
|
if (question.length > MAX_QUESTION_CHARS) {
|
|
34553
|
-
throw new
|
|
34804
|
+
throw new WriteRequestError5(
|
|
34554
34805
|
`question is ${question.length} characters; the maximum is ${MAX_QUESTION_CHARS}`,
|
|
34555
34806
|
{ max: MAX_QUESTION_CHARS, length: question.length }
|
|
34556
34807
|
);
|
|
34557
34808
|
}
|
|
34558
34809
|
if (params.model !== void 0) {
|
|
34559
34810
|
if (typeof params.model !== "string" || params.model.length > MAX_QUESTION_MODEL_CHARS || !MODEL_ID_PATTERN.test(params.model)) {
|
|
34560
|
-
throw new
|
|
34811
|
+
throw new WriteRequestError5("model must be a provider model id", {
|
|
34561
34812
|
model: params.model
|
|
34562
34813
|
});
|
|
34563
34814
|
}
|
|
@@ -34593,7 +34844,7 @@ async function getQuestion(params) {
|
|
|
34593
34844
|
}
|
|
34594
34845
|
async function listQuestions(params) {
|
|
34595
34846
|
if (typeof params.derivedScope !== "string" || params.derivedScope.length === 0) {
|
|
34596
|
-
throw new
|
|
34847
|
+
throw new WriteRequestError5(
|
|
34597
34848
|
"derivedScope is required; a builder may only list its own questions on a scope it may write"
|
|
34598
34849
|
);
|
|
34599
34850
|
}
|
|
@@ -34698,6 +34949,12 @@ async function askPersonalServer(params) {
|
|
|
34698
34949
|
|
|
34699
34950
|
// src/protocol/derivative-status.ts
|
|
34700
34951
|
import { z as z6 } from "zod";
|
|
34952
|
+
import {
|
|
34953
|
+
DerivativeQuestionRejectedError as DerivativeQuestionRejectedError2,
|
|
34954
|
+
DerivativeQuestionTimeoutError as DerivativeQuestionTimeoutError2,
|
|
34955
|
+
WriteRequestError as WriteRequestError6,
|
|
34956
|
+
WriteTransportError as WriteTransportError2
|
|
34957
|
+
} from "./errors.js";
|
|
34701
34958
|
var DERIVATIVE_STATUS_PATH = "/v1/derivatives/status";
|
|
34702
34959
|
var DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS = 12e4;
|
|
34703
34960
|
var DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS = 2e3;
|
|
@@ -34728,13 +34985,13 @@ function normalizeBaseUrl3(url) {
|
|
|
34728
34985
|
function resolveFetch3(fetchFn) {
|
|
34729
34986
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
34730
34987
|
if (resolved === void 0) {
|
|
34731
|
-
throw new
|
|
34988
|
+
throw new WriteRequestError6("No fetch implementation available");
|
|
34732
34989
|
}
|
|
34733
34990
|
return resolved;
|
|
34734
34991
|
}
|
|
34735
34992
|
function requireDerivedScope(derivedScope) {
|
|
34736
34993
|
if (typeof derivedScope !== "string" || derivedScope.length === 0) {
|
|
34737
|
-
throw new
|
|
34994
|
+
throw new WriteRequestError6("derivedScope is required");
|
|
34738
34995
|
}
|
|
34739
34996
|
return derivedScope;
|
|
34740
34997
|
}
|
|
@@ -34753,7 +35010,7 @@ function sleep3(ms, signal) {
|
|
|
34753
35010
|
});
|
|
34754
35011
|
}
|
|
34755
35012
|
function timeoutError(latest, timeoutMs) {
|
|
34756
|
-
return new
|
|
35013
|
+
return new DerivativeQuestionTimeoutError2(
|
|
34757
35014
|
`Derived scope ${latest.derivedScope} was still ${latest.status} after ${timeoutMs}ms`,
|
|
34758
35015
|
{
|
|
34759
35016
|
derivedScope: latest.derivedScope,
|
|
@@ -34766,7 +35023,7 @@ function timeoutError(latest, timeoutMs) {
|
|
|
34766
35023
|
}
|
|
34767
35024
|
function abortError2(signal) {
|
|
34768
35025
|
const reason = signal?.reason;
|
|
34769
|
-
return reason instanceof Error ? reason : new
|
|
35026
|
+
return reason instanceof Error ? reason : new WriteRequestError6("Derivative status wait was aborted");
|
|
34770
35027
|
}
|
|
34771
35028
|
function isDerivativeStatusSettled(status) {
|
|
34772
35029
|
if (status.status === "ready") return true;
|
|
@@ -34799,7 +35056,7 @@ async function getDerivativeStatus(params) {
|
|
|
34799
35056
|
}
|
|
34800
35057
|
);
|
|
34801
35058
|
} catch (err) {
|
|
34802
|
-
throw new
|
|
35059
|
+
throw new WriteTransportError2(
|
|
34803
35060
|
`Derivative status read failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
34804
35061
|
1,
|
|
34805
35062
|
err
|
|
@@ -34814,7 +35071,7 @@ async function getDerivativeStatus(params) {
|
|
|
34814
35071
|
try {
|
|
34815
35072
|
body = await response.json();
|
|
34816
35073
|
} catch (err) {
|
|
34817
|
-
throw new
|
|
35074
|
+
throw new DerivativeQuestionRejectedError2(
|
|
34818
35075
|
"Derivative status response is not JSON",
|
|
34819
35076
|
response.status,
|
|
34820
35077
|
null,
|
|
@@ -34823,7 +35080,7 @@ async function getDerivativeStatus(params) {
|
|
|
34823
35080
|
}
|
|
34824
35081
|
const parsed = DerivativeStatusSchema.safeParse(body);
|
|
34825
35082
|
if (!parsed.success) {
|
|
34826
|
-
throw new
|
|
35083
|
+
throw new DerivativeQuestionRejectedError2(
|
|
34827
35084
|
"Derivative status response is not a status view",
|
|
34828
35085
|
response.status,
|
|
34829
35086
|
null,
|
|
@@ -34857,6 +35114,11 @@ async function waitForDerivativeStatus(params) {
|
|
|
34857
35114
|
}
|
|
34858
35115
|
|
|
34859
35116
|
// src/protocol/gateway.ts
|
|
35117
|
+
import {
|
|
35118
|
+
DataPointDeletedError as DataPointDeletedError3,
|
|
35119
|
+
DataPointNotFoundError as DataPointNotFoundError2,
|
|
35120
|
+
DataPointVersionConflictError
|
|
35121
|
+
} from "./errors.js";
|
|
34860
35122
|
function withGrantPermissions(grant) {
|
|
34861
35123
|
const stripped = { ...grant };
|
|
34862
35124
|
delete stripped.permissions;
|
|
@@ -34902,7 +35164,7 @@ function createGatewayClient(baseUrl) {
|
|
|
34902
35164
|
}
|
|
34903
35165
|
async function deletedError(res, details) {
|
|
34904
35166
|
const body = await readBody(res);
|
|
34905
|
-
return new
|
|
35167
|
+
return new DataPointDeletedError3(
|
|
34906
35168
|
`Data point ${details.dataPointId ?? details.scope ?? ""} has been deleted`,
|
|
34907
35169
|
{ ...details, deletedAt: tombstoneDeletedAt(body) }
|
|
34908
35170
|
);
|
|
@@ -34975,7 +35237,7 @@ function createGatewayClient(baseUrl) {
|
|
|
34975
35237
|
}
|
|
34976
35238
|
const record = await unwrapEnvelope(res);
|
|
34977
35239
|
if (!options?.includeDeleted && isDataPointTombstone(record)) {
|
|
34978
|
-
throw new
|
|
35240
|
+
throw new DataPointDeletedError3(
|
|
34979
35241
|
`Data point ${dataPointId} has been deleted`,
|
|
34980
35242
|
{
|
|
34981
35243
|
dataPointId,
|
|
@@ -35137,7 +35399,7 @@ function createGatewayClient(baseUrl) {
|
|
|
35137
35399
|
})
|
|
35138
35400
|
});
|
|
35139
35401
|
if (res.status === 404) {
|
|
35140
|
-
throw new
|
|
35402
|
+
throw new DataPointNotFoundError2(
|
|
35141
35403
|
`Data point ${dataPointId} (scope '${params.scope}') is not registered`,
|
|
35142
35404
|
details
|
|
35143
35405
|
);
|
|
@@ -35279,6 +35541,7 @@ function createGatewayClient(baseUrl) {
|
|
|
35279
35541
|
}
|
|
35280
35542
|
|
|
35281
35543
|
// src/protocol/escrow.ts
|
|
35544
|
+
import { isHex as isHex2 } from "viem";
|
|
35282
35545
|
var GENERIC_PAYMENT_TYPES = {
|
|
35283
35546
|
GenericPayment: [
|
|
35284
35547
|
{ name: "payerAddress", type: "address" },
|
|
@@ -35318,6 +35581,26 @@ var ESCROW_DEPOSIT_ABI2 = [
|
|
|
35318
35581
|
}
|
|
35319
35582
|
];
|
|
35320
35583
|
var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
35584
|
+
var EscrowWithdrawalLifecycleError = class extends Error {
|
|
35585
|
+
constructor(httpStatus, result) {
|
|
35586
|
+
super(result.error);
|
|
35587
|
+
this.httpStatus = httpStatus;
|
|
35588
|
+
this.result = result;
|
|
35589
|
+
}
|
|
35590
|
+
httpStatus;
|
|
35591
|
+
result;
|
|
35592
|
+
name = "EscrowWithdrawalLifecycleError";
|
|
35593
|
+
};
|
|
35594
|
+
var EscrowWithdrawalRejectionError = class extends Error {
|
|
35595
|
+
constructor(httpStatus, result) {
|
|
35596
|
+
super(result.error);
|
|
35597
|
+
this.httpStatus = httpStatus;
|
|
35598
|
+
this.result = result;
|
|
35599
|
+
}
|
|
35600
|
+
httpStatus;
|
|
35601
|
+
result;
|
|
35602
|
+
name = "EscrowWithdrawalRejectionError";
|
|
35603
|
+
};
|
|
35321
35604
|
function createEscrowGatewayClient(baseUrl) {
|
|
35322
35605
|
const base = baseUrl.replace(/\/+$/, "");
|
|
35323
35606
|
async function throwOnError(res, context) {
|
|
@@ -35333,6 +35616,27 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
35333
35616
|
);
|
|
35334
35617
|
}
|
|
35335
35618
|
}
|
|
35619
|
+
async function throwOnWithdrawError(res) {
|
|
35620
|
+
if (res.ok) return;
|
|
35621
|
+
let body;
|
|
35622
|
+
try {
|
|
35623
|
+
body = await res.json();
|
|
35624
|
+
} catch {
|
|
35625
|
+
throw new Error(
|
|
35626
|
+
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
|
|
35627
|
+
);
|
|
35628
|
+
}
|
|
35629
|
+
if (isEscrowWithdrawalFailureResult(body)) {
|
|
35630
|
+
throw new EscrowWithdrawalLifecycleError(res.status, body);
|
|
35631
|
+
}
|
|
35632
|
+
if (isEscrowWithdrawalRejectedResult(body)) {
|
|
35633
|
+
throw new EscrowWithdrawalRejectionError(res.status, body);
|
|
35634
|
+
}
|
|
35635
|
+
const error = getGatewayErrorMessage(body);
|
|
35636
|
+
throw new Error(
|
|
35637
|
+
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
|
|
35638
|
+
);
|
|
35639
|
+
}
|
|
35336
35640
|
return {
|
|
35337
35641
|
async submitDeposit({ txHash }) {
|
|
35338
35642
|
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
@@ -35388,9 +35692,108 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
35388
35692
|
});
|
|
35389
35693
|
await throwOnError(res, "POST /v1/escrow/pay");
|
|
35390
35694
|
return res.json();
|
|
35695
|
+
},
|
|
35696
|
+
async withdraw({
|
|
35697
|
+
account,
|
|
35698
|
+
asset,
|
|
35699
|
+
amount,
|
|
35700
|
+
withdrawNonce,
|
|
35701
|
+
deadline,
|
|
35702
|
+
signature
|
|
35703
|
+
}) {
|
|
35704
|
+
const res = await fetch(`${base}/v1/escrow/withdraw`, {
|
|
35705
|
+
method: "POST",
|
|
35706
|
+
headers: {
|
|
35707
|
+
"Content-Type": "application/json",
|
|
35708
|
+
Authorization: `Web3Signed ${signature}`
|
|
35709
|
+
},
|
|
35710
|
+
body: JSON.stringify({
|
|
35711
|
+
account,
|
|
35712
|
+
asset,
|
|
35713
|
+
amount,
|
|
35714
|
+
withdrawNonce,
|
|
35715
|
+
deadline
|
|
35716
|
+
})
|
|
35717
|
+
});
|
|
35718
|
+
await throwOnWithdrawError(res);
|
|
35719
|
+
return res.json();
|
|
35720
|
+
},
|
|
35721
|
+
async getWithdrawNonce(account) {
|
|
35722
|
+
const res = await fetch(
|
|
35723
|
+
`${base}/v1/escrow/withdraw/nonce?account=${encodeURIComponent(account)}`,
|
|
35724
|
+
{ cache: "no-store" }
|
|
35725
|
+
);
|
|
35726
|
+
await throwOnError(res, "GET /v1/escrow/withdraw/nonce");
|
|
35727
|
+
const body = await res.json();
|
|
35728
|
+
if (!isWithdrawNonceResponse(body, account)) {
|
|
35729
|
+
throw new Error(
|
|
35730
|
+
"GET /v1/escrow/withdraw/nonce: invalid response structure"
|
|
35731
|
+
);
|
|
35732
|
+
}
|
|
35733
|
+
return body;
|
|
35391
35734
|
}
|
|
35392
35735
|
};
|
|
35393
35736
|
}
|
|
35737
|
+
function getGatewayErrorMessage(body) {
|
|
35738
|
+
if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
|
|
35739
|
+
return body.error;
|
|
35740
|
+
}
|
|
35741
|
+
return void 0;
|
|
35742
|
+
}
|
|
35743
|
+
function isEscrowWithdrawalFailureResult(body) {
|
|
35744
|
+
if (typeof body !== "object" || body === null) return false;
|
|
35745
|
+
const value = body;
|
|
35746
|
+
return value.success === false && (value.status === "retryable" || value.status === "reorged" || value.status === "failed") && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && (isHash(value.txHash) || value.txHash === null) && (!("blockNumber" in value) || isBlockNumber(value.blockNumber));
|
|
35747
|
+
}
|
|
35748
|
+
function isEscrowWithdrawalRejectedResult(body) {
|
|
35749
|
+
if (typeof body !== "object" || body === null) return false;
|
|
35750
|
+
const value = body;
|
|
35751
|
+
return value.success === false && value.status === "rejected" && isWithdrawalRejectionCode(value.code) && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && optionalUint256Decimal(value.balance) && optionalUint256Decimal(value.authorizedAmount) && optionalUint256Decimal(value.withdrawingAmount) && optionalUint256Decimal(value.availableAmount) && optionalUint256Decimal(value.requestedAmount) && optionalUint256Decimal(value.minimumAmount);
|
|
35752
|
+
}
|
|
35753
|
+
function isWithdrawalRejectionCode(value) {
|
|
35754
|
+
return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
|
|
35755
|
+
}
|
|
35756
|
+
function optionalUint256Decimal(value) {
|
|
35757
|
+
return value === void 0 || isUint256Decimal(value);
|
|
35758
|
+
}
|
|
35759
|
+
function isAddressHex(value) {
|
|
35760
|
+
return typeof value === "string" && isHex2(value, { strict: true }) && value.length === 42;
|
|
35761
|
+
}
|
|
35762
|
+
function isHash(value) {
|
|
35763
|
+
return typeof value === "string" && isHex2(value, { strict: true }) && value.length === 66;
|
|
35764
|
+
}
|
|
35765
|
+
function isUint256Decimal(value) {
|
|
35766
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 78) {
|
|
35767
|
+
return false;
|
|
35768
|
+
}
|
|
35769
|
+
if (!/^(0|[1-9]\d*)$/.test(value)) return false;
|
|
35770
|
+
return BigInt(value) <= 2n ** 256n - 1n;
|
|
35771
|
+
}
|
|
35772
|
+
function isBlockNumber(value) {
|
|
35773
|
+
return value === null || isUint256Decimal(value);
|
|
35774
|
+
}
|
|
35775
|
+
function isWithdrawNonceResponse(body, requestedAccount) {
|
|
35776
|
+
if (typeof body !== "object" || body === null) return false;
|
|
35777
|
+
const value = body;
|
|
35778
|
+
if (value.success !== true) return false;
|
|
35779
|
+
if (!isAddressHex(value.account)) return false;
|
|
35780
|
+
if (value.account.toLowerCase() !== requestedAccount.toLowerCase())
|
|
35781
|
+
return false;
|
|
35782
|
+
if (typeof value.chainId !== "string") return false;
|
|
35783
|
+
if (!/^(0|[1-9]\d*)$/.test(value.chainId)) return false;
|
|
35784
|
+
const isLastNull = value.lastWithdrawNonce === null;
|
|
35785
|
+
const lastNonceValid = isLastNull || isUint256Decimal(value.lastWithdrawNonce);
|
|
35786
|
+
if (!lastNonceValid) return false;
|
|
35787
|
+
if (!isUint256Decimal(value.nextWithdrawNonce)) return false;
|
|
35788
|
+
if (isLastNull) {
|
|
35789
|
+
return value.nextWithdrawNonce === "1";
|
|
35790
|
+
}
|
|
35791
|
+
const lastNonce = BigInt(value.lastWithdrawNonce);
|
|
35792
|
+
const nextNonce = BigInt(value.nextWithdrawNonce);
|
|
35793
|
+
const expectedNextNonce = lastNonce + 1n;
|
|
35794
|
+
if (expectedNextNonce > 2n ** 256n - 1n) return false;
|
|
35795
|
+
return nextNonce === expectedNextNonce;
|
|
35796
|
+
}
|
|
35394
35797
|
|
|
35395
35798
|
// src/types/ps-errors.ts
|
|
35396
35799
|
var PSError = class extends Error {
|
|
@@ -35460,15 +35863,12 @@ export {
|
|
|
35460
35863
|
AccountPersonalServerLiteOwnerBindingError,
|
|
35461
35864
|
AccountPersonalServerRegistrationError,
|
|
35462
35865
|
BUILDER_REGISTRATION_TYPES,
|
|
35463
|
-
BlockchainError,
|
|
35464
35866
|
BrowserECIESUint8Provider as BrowserECIESProvider,
|
|
35465
35867
|
BrowserPlatformAdapter,
|
|
35466
|
-
BuilderUnknownError,
|
|
35467
35868
|
CLAIM_POLL_FLOOR_MS,
|
|
35468
35869
|
CONTRACTS,
|
|
35469
35870
|
CallbackStorage,
|
|
35470
35871
|
ContractFactory,
|
|
35471
|
-
ContractNotFoundError,
|
|
35472
35872
|
DATA_REGISTRY_STATUS_ABI,
|
|
35473
35873
|
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
35474
35874
|
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
@@ -35480,21 +35880,9 @@ export {
|
|
|
35480
35880
|
DERIVATIVE_QUESTIONS_PATH,
|
|
35481
35881
|
DERIVATIVE_STATUS_PATH,
|
|
35482
35882
|
DataFileEnvelopeSchema,
|
|
35483
|
-
DataPointDeletedError,
|
|
35484
|
-
DataPointNotFoundError,
|
|
35485
35883
|
DataPointStatus,
|
|
35486
|
-
DataPointVersionConflictError,
|
|
35487
|
-
DerivativeComputeUnavailableError,
|
|
35488
|
-
DerivativeCycleError,
|
|
35489
|
-
DerivativeDerivedScopeRequiredError,
|
|
35490
35884
|
DerivativeErrorCodeSchema,
|
|
35491
|
-
DerivativeQuestionFailedError,
|
|
35492
|
-
DerivativeQuestionInvalidError,
|
|
35493
|
-
DerivativeQuestionNotFoundError,
|
|
35494
|
-
DerivativeQuestionRejectedError,
|
|
35495
35885
|
DerivativeQuestionSchema,
|
|
35496
|
-
DerivativeQuestionTimeoutError,
|
|
35497
|
-
DerivativeSourceNotGrantedError,
|
|
35498
35886
|
DerivativeStatusSchema,
|
|
35499
35887
|
DropboxStorage,
|
|
35500
35888
|
ECIESError,
|
|
@@ -35502,41 +35890,34 @@ export {
|
|
|
35502
35890
|
ENCLAVE_TRUST_ANCHORS,
|
|
35503
35891
|
ENCLAVE_WALLET_PURPOSE,
|
|
35504
35892
|
ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
|
|
35505
|
-
|
|
35893
|
+
EscrowWithdrawalLifecycleError,
|
|
35894
|
+
EscrowWithdrawalRejectionError,
|
|
35895
|
+
ExpiredTokenError2 as ExpiredTokenError,
|
|
35506
35896
|
FEE_REGISTRY_ABI,
|
|
35507
35897
|
GENERIC_PAYMENT_TYPES,
|
|
35508
35898
|
GRANT_REGISTRATION_TYPES,
|
|
35509
35899
|
GRANT_REVOCATION_TYPES,
|
|
35510
35900
|
GoogleDriveStorage,
|
|
35511
|
-
GrantInvalidError,
|
|
35512
35901
|
InMemoryTokenStore,
|
|
35513
35902
|
IngestResponseSchema,
|
|
35514
|
-
InvalidConfigurationError,
|
|
35515
35903
|
InvalidScopeEntryError,
|
|
35516
|
-
InvalidSignatureError,
|
|
35904
|
+
InvalidSignatureError2 as InvalidSignatureError,
|
|
35517
35905
|
IpfsStorage,
|
|
35518
35906
|
JOB_OPERATIONS,
|
|
35519
35907
|
JOB_PROTOCOL_VERSION,
|
|
35908
|
+
JOB_RESULT_CHUNK_BYTES,
|
|
35909
|
+
JOB_RESULT_FORMAT_VERSION,
|
|
35520
35910
|
JOB_STATES,
|
|
35521
35911
|
JobEnvelopeError,
|
|
35522
|
-
JobIdTakenError,
|
|
35523
|
-
JobNotFoundError,
|
|
35524
|
-
JobRejectedError,
|
|
35525
|
-
JobRequestTooLargeError,
|
|
35526
|
-
JobTimeoutError,
|
|
35527
|
-
JobTransportError,
|
|
35528
|
-
JobsClientError,
|
|
35529
35912
|
LINEAGE_FIELD,
|
|
35530
35913
|
LINEAGE_KEY,
|
|
35531
35914
|
LineageEntrySchema,
|
|
35532
35915
|
LineageGraphSchema,
|
|
35533
35916
|
LineageNodeSchema,
|
|
35534
|
-
LineageReadError,
|
|
35535
35917
|
MASTER_KEY_MESSAGE,
|
|
35536
35918
|
MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
|
|
35537
35919
|
MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
35538
35920
|
MAX_ATTEMPTS,
|
|
35539
|
-
MAX_INLINE_RESULT_BYTES,
|
|
35540
35921
|
MAX_JOB_DEADLINE_SECONDS,
|
|
35541
35922
|
MAX_LEASE_SECONDS,
|
|
35542
35923
|
MAX_LINEAGE_SOURCES,
|
|
@@ -35544,13 +35925,10 @@ export {
|
|
|
35544
35925
|
MAX_QUESTION_MODEL_CHARS,
|
|
35545
35926
|
MAX_QUESTION_SOURCE_SCOPES,
|
|
35546
35927
|
MAX_WAIT_SECONDS,
|
|
35547
|
-
MissingAuthError,
|
|
35928
|
+
MissingAuthError2 as MissingAuthError,
|
|
35548
35929
|
NATIVE_ASSET_ADDRESS,
|
|
35549
35930
|
NATIVE_VANA_ASSET,
|
|
35550
|
-
NetworkError,
|
|
35551
|
-
NonceError,
|
|
35552
35931
|
OAuthClient,
|
|
35553
|
-
OwnerNotReadyError,
|
|
35554
35932
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
35555
35933
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
35556
35934
|
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
@@ -35559,9 +35937,6 @@ export {
|
|
|
35559
35937
|
PKCE_CHALLENGE_PATTERN,
|
|
35560
35938
|
PKCE_VERIFIER_PATTERN,
|
|
35561
35939
|
PSError,
|
|
35562
|
-
PermissionError,
|
|
35563
|
-
PersonalServerError,
|
|
35564
|
-
PersonalServerWriteError,
|
|
35565
35940
|
PinataStorage,
|
|
35566
35941
|
QUESTION_STATUSES,
|
|
35567
35942
|
QuestionDeleteResultSchema,
|
|
@@ -35572,42 +35947,26 @@ export {
|
|
|
35572
35947
|
RECORD_DATA_ACCESS_TYPES,
|
|
35573
35948
|
REGISTRATION_KIND_FOR_OP,
|
|
35574
35949
|
RESERVED_WRITE_KEYS,
|
|
35575
|
-
ReadOnlyError,
|
|
35576
35950
|
RedactedLineageNodeSchema,
|
|
35577
|
-
RelayerError,
|
|
35578
35951
|
SCOPE_ACTIONS,
|
|
35579
35952
|
SEALED_ENVELOPE_VERSION,
|
|
35580
35953
|
SERVER_REGISTRATION_TYPES,
|
|
35581
35954
|
ScopeSchema,
|
|
35582
|
-
SerializationError,
|
|
35583
|
-
ServerUrlMismatchError,
|
|
35584
|
-
SignatureError,
|
|
35585
35955
|
StorageError,
|
|
35586
35956
|
StorageManager,
|
|
35587
35957
|
TOMBSTONE_DATA_HASH,
|
|
35588
35958
|
TOMBSTONE_DATA_HASH_PREIMAGE,
|
|
35589
35959
|
TOMBSTONE_METADATA_HASH,
|
|
35590
35960
|
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
35591
|
-
TransactionPendingError,
|
|
35592
35961
|
USER_PS_ID_DOMAIN,
|
|
35593
|
-
UserRejectedRequestError,
|
|
35594
|
-
VanaError,
|
|
35595
35962
|
VanaStorage,
|
|
35963
|
+
WITHDRAW_AUTHORIZATION_TYPES,
|
|
35596
35964
|
WRITER_ATTRIBUTION_KEY,
|
|
35597
35965
|
WRITE_CONTENT_DISPOSITION_HEADER,
|
|
35598
35966
|
WRITE_FILENAME_HEADER,
|
|
35599
35967
|
WRITE_METADATA_HEADER,
|
|
35600
35968
|
WRITE_SESSION_PATH,
|
|
35601
35969
|
WRITE_SIGNATURE_HEADER,
|
|
35602
|
-
WriteConflictError,
|
|
35603
|
-
WriteForbiddenError,
|
|
35604
|
-
WriteLineageError,
|
|
35605
|
-
WriteRejectedError,
|
|
35606
|
-
WriteRequestError,
|
|
35607
|
-
WriteSessionError,
|
|
35608
|
-
WriteSessionExpiredError,
|
|
35609
|
-
WriteTransportError,
|
|
35610
|
-
WriteUnauthorizedError,
|
|
35611
35970
|
appRootPreimage,
|
|
35612
35971
|
askPersonalServer,
|
|
35613
35972
|
assertDerivedScopeNaming,
|
|
@@ -35626,6 +35985,7 @@ export {
|
|
|
35626
35985
|
buildPersonalServerRegistrationTypedData,
|
|
35627
35986
|
buildSetDataPointStatusRequest,
|
|
35628
35987
|
buildWeb3SignedHeader,
|
|
35988
|
+
buildWithdrawAuthorizationTypedData,
|
|
35629
35989
|
builderRegistrationDomain,
|
|
35630
35990
|
canonicalJobRequestBytes,
|
|
35631
35991
|
chains,
|
|
@@ -35703,6 +36063,7 @@ export {
|
|
|
35703
36063
|
normalizeBinaryMimeType,
|
|
35704
36064
|
openJobRequest,
|
|
35705
36065
|
openJobResult,
|
|
36066
|
+
openJobResultStream,
|
|
35706
36067
|
openWriteSession,
|
|
35707
36068
|
parsePSError,
|
|
35708
36069
|
parseScope,
|
|
@@ -35725,6 +36086,7 @@ export {
|
|
|
35725
36086
|
scopeToPathSegments,
|
|
35726
36087
|
sealJobRequest,
|
|
35727
36088
|
sealJobResult,
|
|
36089
|
+
sealJobResultStream,
|
|
35728
36090
|
serializeECIES,
|
|
35729
36091
|
serverRegistrationDomain,
|
|
35730
36092
|
sessionCoversScope,
|
|
@@ -35741,6 +36103,7 @@ export {
|
|
|
35741
36103
|
verifyWeb3Signed,
|
|
35742
36104
|
waitForDerivativeStatus,
|
|
35743
36105
|
waitForQuestion,
|
|
36106
|
+
withdrawAuthorizationDomain,
|
|
35744
36107
|
writeData,
|
|
35745
36108
|
writePersonalServerData
|
|
35746
36109
|
};
|