@opendatalabs/vana-sdk 3.23.0 → 4.0.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 +882 -518
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +1035 -705
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +4 -4
- package/dist/index.node.js +989 -567
- 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 +7 -2
- package/dist/protocol/identity.cjs.map +1 -1
- package/dist/protocol/identity.js +7 -2
- 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();
|
|
@@ -31830,8 +31499,13 @@ function emptyAnchor() {
|
|
|
31830
31499
|
var ENCLAVE_TRUST_ANCHORS = Object.freeze({
|
|
31831
31500
|
// filled at fleet provisioning; verify fails closed while empty
|
|
31832
31501
|
[VANA_MAINNET_CHAIN_ID]: emptyAnchor(),
|
|
31833
|
-
//
|
|
31834
|
-
[MOKSHA_CHAIN_ID]:
|
|
31502
|
+
// Moksha workers share this dstack app and KMS root; the controller does not derive owner keys.
|
|
31503
|
+
[MOKSHA_CHAIN_ID]: Object.freeze({
|
|
31504
|
+
kmsRootPubkey: "0x0434c76e0c3f52ec64cbf9bbf5c910c272330166fd656c0a86bb330963e46910e1a0e6fa51bec74be2f9129342707636060d85856d102cee8290185409ecf7422f",
|
|
31505
|
+
appIds: Object.freeze([
|
|
31506
|
+
"0xec9a39de98c760e1ded9f1e97016dc5f0e357cf2"
|
|
31507
|
+
])
|
|
31508
|
+
})
|
|
31835
31509
|
});
|
|
31836
31510
|
function userPsId(chainId, ownerAddress) {
|
|
31837
31511
|
const packed = encodePacked(
|
|
@@ -31978,16 +31652,30 @@ var MAX_LEASE_SECONDS = 300;
|
|
|
31978
31652
|
var MAX_ATTEMPTS = 3;
|
|
31979
31653
|
var MAX_WAIT_SECONDS = 25;
|
|
31980
31654
|
var CLAIM_POLL_FLOOR_MS = 1e3;
|
|
31981
|
-
var MAX_INLINE_RESULT_BYTES = 1048576;
|
|
31982
31655
|
var DEFAULT_JOB_DEADLINE_SECONDS = 600;
|
|
31983
31656
|
var MAX_JOB_DEADLINE_SECONDS = 3600;
|
|
31984
31657
|
|
|
31985
31658
|
// src/crypto/envelope/job.ts
|
|
31659
|
+
init_constants();
|
|
31986
31660
|
init_interface();
|
|
31987
31661
|
import { sha256 as sha2565 } from "@noble/hashes/sha2";
|
|
31988
31662
|
import { bytesToHex as bytesToHex2, fromHex as fromHex6, isAddress, isHex, toHex as toHex7 } from "viem";
|
|
31989
31663
|
var textDecoder = new TextDecoder();
|
|
31990
31664
|
var textEncoder = new TextEncoder();
|
|
31665
|
+
var MAX_JOB_RESULT_HEADER_BYTES = 4096;
|
|
31666
|
+
var WRAPPED_KEY_LENGTH_BYTES = 4;
|
|
31667
|
+
var FRAME_LENGTH_BYTES = 4;
|
|
31668
|
+
var FRAME_FLAGS_BYTES = 1;
|
|
31669
|
+
var AES_KEY_BYTES = 32;
|
|
31670
|
+
var AES_GCM_NONCE_BYTES = 12;
|
|
31671
|
+
var AES_GCM_TAG_BYTES = 16;
|
|
31672
|
+
var WRAPPED_METADATA_LENGTH_BYTES = 4;
|
|
31673
|
+
var WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES = AES_KEY_BYTES + AES_GCM_NONCE_BYTES + WRAPPED_METADATA_LENGTH_BYTES;
|
|
31674
|
+
var MAX_WRAPPED_KEY_BYTES = 8192;
|
|
31675
|
+
var FINAL_FRAME_FLAG = 1;
|
|
31676
|
+
var MAX_CHUNK_INDEX = 4294967295;
|
|
31677
|
+
var JOB_RESULT_FORMAT_VERSION = 2;
|
|
31678
|
+
var JOB_RESULT_CHUNK_BYTES = 1024 * 1024;
|
|
31991
31679
|
var JobEnvelopeError = class extends Error {
|
|
31992
31680
|
constructor(message) {
|
|
31993
31681
|
super(message);
|
|
@@ -32019,21 +31707,68 @@ function requestPlaintext(envelope) {
|
|
|
32019
31707
|
validateRequestEnvelope(envelope);
|
|
32020
31708
|
return canonicalJsonBytes(envelope);
|
|
32021
31709
|
}
|
|
32022
|
-
function
|
|
32023
|
-
return
|
|
32024
|
-
|
|
32025
|
-
|
|
32026
|
-
|
|
32027
|
-
|
|
32028
|
-
|
|
32029
|
-
|
|
32030
|
-
body: result.body
|
|
32031
|
-
})
|
|
32032
|
-
);
|
|
31710
|
+
function resultMetadata(result) {
|
|
31711
|
+
return {
|
|
31712
|
+
v: result.v,
|
|
31713
|
+
jobId: result.jobId,
|
|
31714
|
+
scope: result.scope,
|
|
31715
|
+
version: result.version,
|
|
31716
|
+
contentType: result.contentType
|
|
31717
|
+
};
|
|
32033
31718
|
}
|
|
32034
31719
|
function encryptedBytesToBase64(encrypted) {
|
|
32035
31720
|
return toBase64(fromHex6(`0x${serializeECIES(encrypted)}`, "bytes"));
|
|
32036
31721
|
}
|
|
31722
|
+
function encryptedToBytes(encrypted) {
|
|
31723
|
+
const bytes = new Uint8Array(
|
|
31724
|
+
encrypted.iv.length + encrypted.ephemPublicKey.length + encrypted.ciphertext.length + encrypted.mac.length
|
|
31725
|
+
);
|
|
31726
|
+
let offset = 0;
|
|
31727
|
+
bytes.set(encrypted.iv, offset);
|
|
31728
|
+
offset += encrypted.iv.length;
|
|
31729
|
+
bytes.set(encrypted.ephemPublicKey, offset);
|
|
31730
|
+
offset += encrypted.ephemPublicKey.length;
|
|
31731
|
+
bytes.set(encrypted.ciphertext, offset);
|
|
31732
|
+
offset += encrypted.ciphertext.length;
|
|
31733
|
+
bytes.set(encrypted.mac, offset);
|
|
31734
|
+
return bytes;
|
|
31735
|
+
}
|
|
31736
|
+
function bytesToEncrypted(bytes) {
|
|
31737
|
+
const absoluteMinLength = FORMAT.IV_LENGTH + 1 + MAC.LENGTH + 1;
|
|
31738
|
+
if (bytes.length < absoluteMinLength) {
|
|
31739
|
+
throw new ECIESError(
|
|
31740
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${absoluteMinLength} bytes required)`,
|
|
31741
|
+
"DECRYPTION_FAILED"
|
|
31742
|
+
);
|
|
31743
|
+
}
|
|
31744
|
+
const prefix = bytes[FORMAT.EPHEMERAL_KEY_OFFSET];
|
|
31745
|
+
if (prefix !== CURVE.PREFIX.UNCOMPRESSED) {
|
|
31746
|
+
throw new ECIESError(
|
|
31747
|
+
`Invalid ephemeral public key: must be uncompressed format (0x04 prefix), got 0x${prefix.toString(16).padStart(2, "0")}`,
|
|
31748
|
+
"DECRYPTION_FAILED"
|
|
31749
|
+
);
|
|
31750
|
+
}
|
|
31751
|
+
const ephemKeySize = CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH;
|
|
31752
|
+
const minLength = FORMAT.IV_LENGTH + ephemKeySize + MAC.LENGTH + 1;
|
|
31753
|
+
if (bytes.length < minLength) {
|
|
31754
|
+
throw new ECIESError(
|
|
31755
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${minLength} bytes required)`,
|
|
31756
|
+
"DECRYPTION_FAILED"
|
|
31757
|
+
);
|
|
31758
|
+
}
|
|
31759
|
+
return {
|
|
31760
|
+
iv: bytes.subarray(FORMAT.IV_OFFSET, FORMAT.IV_OFFSET + FORMAT.IV_LENGTH),
|
|
31761
|
+
ephemPublicKey: bytes.subarray(
|
|
31762
|
+
FORMAT.EPHEMERAL_KEY_OFFSET,
|
|
31763
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize
|
|
31764
|
+
),
|
|
31765
|
+
ciphertext: bytes.subarray(
|
|
31766
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,
|
|
31767
|
+
bytes.length - MAC.LENGTH
|
|
31768
|
+
),
|
|
31769
|
+
mac: bytes.subarray(bytes.length - MAC.LENGTH)
|
|
31770
|
+
};
|
|
31771
|
+
}
|
|
32037
31772
|
function base64ToEncrypted(ciphertext) {
|
|
32038
31773
|
return deserializeECIES(toHex7(fromBase64(ciphertext)));
|
|
32039
31774
|
}
|
|
@@ -32134,11 +31869,11 @@ function validateRequestEnvelope(value) {
|
|
|
32134
31869
|
requireString(value.auth, "auth", "job request envelope");
|
|
32135
31870
|
return value;
|
|
32136
31871
|
}
|
|
32137
|
-
function
|
|
32138
|
-
requirePlainObject(value, "
|
|
31872
|
+
function validateResultMetadata(value) {
|
|
31873
|
+
requirePlainObject(value, "metadata", "job result");
|
|
32139
31874
|
requireExactKeys(
|
|
32140
31875
|
value,
|
|
32141
|
-
["v", "jobId", "scope", "version", "contentType"
|
|
31876
|
+
["v", "jobId", "scope", "version", "contentType"],
|
|
32142
31877
|
"job result"
|
|
32143
31878
|
);
|
|
32144
31879
|
if (value.v !== JOB_PROTOCOL_VERSION) {
|
|
@@ -32149,14 +31884,222 @@ function validateResult(value) {
|
|
|
32149
31884
|
for (const field of ["jobId", "scope", "contentType"]) {
|
|
32150
31885
|
requireString(value[field], field, "job result");
|
|
32151
31886
|
}
|
|
32152
|
-
if (typeof value.body !== "string") {
|
|
32153
|
-
throw new JobEnvelopeError("Invalid job result: missing body");
|
|
32154
|
-
}
|
|
32155
31887
|
if (value.version !== null && typeof value.version !== "string") {
|
|
32156
31888
|
throw new JobEnvelopeError("Invalid job result: missing version");
|
|
32157
31889
|
}
|
|
32158
31890
|
return value;
|
|
32159
31891
|
}
|
|
31892
|
+
function validateResult(value) {
|
|
31893
|
+
requirePlainObject(value, "result", "job result");
|
|
31894
|
+
requireExactKeys(
|
|
31895
|
+
value,
|
|
31896
|
+
["v", "jobId", "scope", "version", "contentType", "body"],
|
|
31897
|
+
"job result"
|
|
31898
|
+
);
|
|
31899
|
+
validateResultMetadata(resultMetadata(value));
|
|
31900
|
+
if (!(value.body instanceof Uint8Array)) {
|
|
31901
|
+
throw new JobEnvelopeError("Invalid job result: missing body");
|
|
31902
|
+
}
|
|
31903
|
+
return value;
|
|
31904
|
+
}
|
|
31905
|
+
function webCrypto() {
|
|
31906
|
+
if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.getRandomValues !== "function" || !globalThis.crypto.subtle) {
|
|
31907
|
+
throw new JobEnvelopeError(
|
|
31908
|
+
"Job result streaming requires the Web Crypto API"
|
|
31909
|
+
);
|
|
31910
|
+
}
|
|
31911
|
+
return globalThis.crypto;
|
|
31912
|
+
}
|
|
31913
|
+
function uint32(value) {
|
|
31914
|
+
const bytes = new Uint8Array(4);
|
|
31915
|
+
new DataView(bytes.buffer).setUint32(0, value);
|
|
31916
|
+
return bytes;
|
|
31917
|
+
}
|
|
31918
|
+
function readUint32(bytes, offset = 0) {
|
|
31919
|
+
return new DataView(bytes.buffer, bytes.byteOffset + offset, 4).getUint32(0);
|
|
31920
|
+
}
|
|
31921
|
+
function wrappedKeyPlaintext(contentKey, noncePrefix, metadataBytes) {
|
|
31922
|
+
const plaintext = new Uint8Array(
|
|
31923
|
+
WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES + metadataBytes.length
|
|
31924
|
+
);
|
|
31925
|
+
plaintext.set(contentKey, 0);
|
|
31926
|
+
plaintext.set(noncePrefix, AES_KEY_BYTES);
|
|
31927
|
+
new DataView(plaintext.buffer).setUint32(
|
|
31928
|
+
AES_KEY_BYTES + AES_GCM_NONCE_BYTES,
|
|
31929
|
+
metadataBytes.length
|
|
31930
|
+
);
|
|
31931
|
+
plaintext.set(metadataBytes, WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES);
|
|
31932
|
+
return plaintext;
|
|
31933
|
+
}
|
|
31934
|
+
function parseWrappedKeyPlaintext(plaintext) {
|
|
31935
|
+
if (plaintext.length < WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES) {
|
|
31936
|
+
throw new JobEnvelopeError("Invalid job result: wrapped key is truncated");
|
|
31937
|
+
}
|
|
31938
|
+
const metadataLength = readUint32(
|
|
31939
|
+
plaintext,
|
|
31940
|
+
AES_KEY_BYTES + AES_GCM_NONCE_BYTES
|
|
31941
|
+
);
|
|
31942
|
+
if (metadataLength > MAX_JOB_RESULT_HEADER_BYTES) {
|
|
31943
|
+
throw new JobEnvelopeError(
|
|
31944
|
+
`Invalid job result: header exceeds ${MAX_JOB_RESULT_HEADER_BYTES} bytes`
|
|
31945
|
+
);
|
|
31946
|
+
}
|
|
31947
|
+
if (plaintext.length !== WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES + metadataLength) {
|
|
31948
|
+
throw new JobEnvelopeError(
|
|
31949
|
+
"Invalid job result: header length exceeds payload"
|
|
31950
|
+
);
|
|
31951
|
+
}
|
|
31952
|
+
const metadataBytes = plaintext.slice(WRAPPED_KEY_PLAINTEXT_PREFIX_BYTES);
|
|
31953
|
+
const metadata = validateResultMetadata(
|
|
31954
|
+
parseObject(metadataBytes, "job result header")
|
|
31955
|
+
);
|
|
31956
|
+
return {
|
|
31957
|
+
contentKey: plaintext.slice(0, AES_KEY_BYTES),
|
|
31958
|
+
noncePrefix: plaintext.slice(
|
|
31959
|
+
AES_KEY_BYTES,
|
|
31960
|
+
AES_KEY_BYTES + AES_GCM_NONCE_BYTES
|
|
31961
|
+
),
|
|
31962
|
+
metadataBytes,
|
|
31963
|
+
metadata
|
|
31964
|
+
};
|
|
31965
|
+
}
|
|
31966
|
+
async function importAesKey(contentKey, usage) {
|
|
31967
|
+
return webCrypto().subtle.importKey(
|
|
31968
|
+
"raw",
|
|
31969
|
+
contentKey,
|
|
31970
|
+
{ name: "AES-GCM" },
|
|
31971
|
+
false,
|
|
31972
|
+
[usage]
|
|
31973
|
+
);
|
|
31974
|
+
}
|
|
31975
|
+
function chunkNonce(noncePrefix, chunkIndex) {
|
|
31976
|
+
if (chunkIndex > MAX_CHUNK_INDEX) {
|
|
31977
|
+
throw new JobEnvelopeError("Invalid job result: too many chunks");
|
|
31978
|
+
}
|
|
31979
|
+
const nonce = noncePrefix.slice();
|
|
31980
|
+
const view = new DataView(nonce.buffer, nonce.byteOffset, nonce.byteLength);
|
|
31981
|
+
view.setUint32(8, view.getUint32(8) ^ chunkIndex);
|
|
31982
|
+
return nonce;
|
|
31983
|
+
}
|
|
31984
|
+
function chunkAad(metadataBytes, chunkIndex, final, plaintextLength) {
|
|
31985
|
+
const aad = new Uint8Array(14 + metadataBytes.length);
|
|
31986
|
+
aad[0] = JOB_RESULT_FORMAT_VERSION;
|
|
31987
|
+
aad.set(uint32(metadataBytes.length), 1);
|
|
31988
|
+
aad.set(metadataBytes, 5);
|
|
31989
|
+
aad.set(uint32(chunkIndex), 5 + metadataBytes.length);
|
|
31990
|
+
aad[9 + metadataBytes.length] = final ? FINAL_FRAME_FLAG : 0;
|
|
31991
|
+
aad.set(uint32(plaintextLength), 10 + metadataBytes.length);
|
|
31992
|
+
return aad;
|
|
31993
|
+
}
|
|
31994
|
+
async function encryptResultChunk(key, noncePrefix, metadataBytes, plaintext, chunkIndex, final) {
|
|
31995
|
+
const encrypted = new Uint8Array(
|
|
31996
|
+
await webCrypto().subtle.encrypt(
|
|
31997
|
+
{
|
|
31998
|
+
name: "AES-GCM",
|
|
31999
|
+
iv: chunkNonce(noncePrefix, chunkIndex),
|
|
32000
|
+
additionalData: chunkAad(
|
|
32001
|
+
metadataBytes,
|
|
32002
|
+
chunkIndex,
|
|
32003
|
+
final,
|
|
32004
|
+
plaintext.length
|
|
32005
|
+
),
|
|
32006
|
+
tagLength: AES_GCM_TAG_BYTES * 8
|
|
32007
|
+
},
|
|
32008
|
+
key,
|
|
32009
|
+
plaintext
|
|
32010
|
+
)
|
|
32011
|
+
);
|
|
32012
|
+
const frame = new Uint8Array(
|
|
32013
|
+
FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES + encrypted.length
|
|
32014
|
+
);
|
|
32015
|
+
new DataView(frame.buffer).setUint32(0, encrypted.length);
|
|
32016
|
+
frame[FRAME_LENGTH_BYTES] = final ? FINAL_FRAME_FLAG : 0;
|
|
32017
|
+
frame.set(encrypted, FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES);
|
|
32018
|
+
return frame;
|
|
32019
|
+
}
|
|
32020
|
+
function verifyResultBindings(metadata, expect) {
|
|
32021
|
+
if (metadata.jobId !== expect.jobId) {
|
|
32022
|
+
throw new JobEnvelopeError(
|
|
32023
|
+
`Job result ID ${metadata.jobId} does not match expected job ID ${expect.jobId}`
|
|
32024
|
+
);
|
|
32025
|
+
}
|
|
32026
|
+
if (expect.scope !== void 0 && metadata.scope !== expect.scope) {
|
|
32027
|
+
throw new JobEnvelopeError(
|
|
32028
|
+
`Job result scope ${metadata.scope} does not match expected scope ${expect.scope}`
|
|
32029
|
+
);
|
|
32030
|
+
}
|
|
32031
|
+
if (expect.version !== void 0 && metadata.version !== expect.version) {
|
|
32032
|
+
throw new JobEnvelopeError(
|
|
32033
|
+
`Job result version ${String(metadata.version)} does not match expected version ${String(expect.version)}`
|
|
32034
|
+
);
|
|
32035
|
+
}
|
|
32036
|
+
}
|
|
32037
|
+
var ByteStreamReader = class {
|
|
32038
|
+
reader;
|
|
32039
|
+
current;
|
|
32040
|
+
offset = 0;
|
|
32041
|
+
ended = false;
|
|
32042
|
+
constructor(stream) {
|
|
32043
|
+
this.reader = stream.getReader();
|
|
32044
|
+
}
|
|
32045
|
+
async ensureBytes() {
|
|
32046
|
+
while (!this.current || this.offset === this.current.length) {
|
|
32047
|
+
if (this.ended) return false;
|
|
32048
|
+
const next = await this.reader.read();
|
|
32049
|
+
if (next.done) {
|
|
32050
|
+
this.ended = true;
|
|
32051
|
+
this.current = void 0;
|
|
32052
|
+
return false;
|
|
32053
|
+
}
|
|
32054
|
+
if (!(next.value instanceof Uint8Array)) {
|
|
32055
|
+
throw new JobEnvelopeError(
|
|
32056
|
+
"Invalid job result: stream yielded non-byte data"
|
|
32057
|
+
);
|
|
32058
|
+
}
|
|
32059
|
+
this.current = next.value;
|
|
32060
|
+
this.offset = 0;
|
|
32061
|
+
}
|
|
32062
|
+
return true;
|
|
32063
|
+
}
|
|
32064
|
+
async readExactOrNull(length) {
|
|
32065
|
+
if (!await this.ensureBytes()) return null;
|
|
32066
|
+
const bytes = new Uint8Array(length);
|
|
32067
|
+
let written = 0;
|
|
32068
|
+
while (written < length) {
|
|
32069
|
+
if (!await this.ensureBytes()) {
|
|
32070
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32071
|
+
}
|
|
32072
|
+
const available = this.current.length - this.offset;
|
|
32073
|
+
const count = Math.min(available, length - written);
|
|
32074
|
+
bytes.set(
|
|
32075
|
+
this.current.subarray(this.offset, this.offset + count),
|
|
32076
|
+
written
|
|
32077
|
+
);
|
|
32078
|
+
this.offset += count;
|
|
32079
|
+
written += count;
|
|
32080
|
+
}
|
|
32081
|
+
return bytes;
|
|
32082
|
+
}
|
|
32083
|
+
async readExact(length) {
|
|
32084
|
+
const bytes = await this.readExactOrNull(length);
|
|
32085
|
+
if (!bytes) {
|
|
32086
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32087
|
+
}
|
|
32088
|
+
return bytes;
|
|
32089
|
+
}
|
|
32090
|
+
async hasRemaining() {
|
|
32091
|
+
return this.ensureBytes();
|
|
32092
|
+
}
|
|
32093
|
+
async cancel(reason) {
|
|
32094
|
+
await this.reader.cancel(reason);
|
|
32095
|
+
}
|
|
32096
|
+
};
|
|
32097
|
+
function normalizeChunkError(error) {
|
|
32098
|
+
if (error instanceof JobEnvelopeError) return error;
|
|
32099
|
+
return new JobEnvelopeError(
|
|
32100
|
+
`Invalid job result: chunk authentication failed${error instanceof Error ? `: ${error.message}` : ""}`
|
|
32101
|
+
);
|
|
32102
|
+
}
|
|
32160
32103
|
async function sealJobRequest(envelope, enclavePublicKey, ecies) {
|
|
32161
32104
|
const encrypted = await ecies.encrypt(
|
|
32162
32105
|
fromHex6(enclavePublicKey, "bytes"),
|
|
@@ -32173,38 +32116,315 @@ async function openJobRequest(ciphertext, privateKey, ecies) {
|
|
|
32173
32116
|
parseObject(plaintext, "job request envelope")
|
|
32174
32117
|
);
|
|
32175
32118
|
}
|
|
32176
|
-
async function
|
|
32177
|
-
|
|
32178
|
-
const
|
|
32119
|
+
async function sealJobResultStream(metadataValue, builderPublicKey, ecies) {
|
|
32120
|
+
const metadata = validateResultMetadata(metadataValue);
|
|
32121
|
+
const metadataBytes = canonicalJsonBytes(metadata);
|
|
32122
|
+
if (metadataBytes.length > MAX_JOB_RESULT_HEADER_BYTES) {
|
|
32123
|
+
throw new JobEnvelopeError(
|
|
32124
|
+
`Invalid job result: header exceeds ${MAX_JOB_RESULT_HEADER_BYTES} bytes`
|
|
32125
|
+
);
|
|
32126
|
+
}
|
|
32127
|
+
const crypto2 = webCrypto();
|
|
32128
|
+
const contentKey = crypto2.getRandomValues(new Uint8Array(AES_KEY_BYTES));
|
|
32129
|
+
const noncePrefix = crypto2.getRandomValues(
|
|
32130
|
+
new Uint8Array(AES_GCM_NONCE_BYTES)
|
|
32131
|
+
);
|
|
32132
|
+
const key = await importAesKey(contentKey, "encrypt");
|
|
32133
|
+
const keyPlaintext = wrappedKeyPlaintext(
|
|
32134
|
+
contentKey,
|
|
32135
|
+
noncePrefix,
|
|
32136
|
+
metadataBytes
|
|
32137
|
+
);
|
|
32138
|
+
const encryptedKey = await ecies.encrypt(
|
|
32179
32139
|
fromHex6(builderPublicKey, "bytes"),
|
|
32180
|
-
|
|
32140
|
+
keyPlaintext
|
|
32141
|
+
);
|
|
32142
|
+
contentKey.fill(0);
|
|
32143
|
+
keyPlaintext.fill(0);
|
|
32144
|
+
const wrappedKey = encryptedToBytes(encryptedKey);
|
|
32145
|
+
if (wrappedKey.length > MAX_WRAPPED_KEY_BYTES) {
|
|
32146
|
+
throw new JobEnvelopeError("Invalid job result: wrapped key is too large");
|
|
32147
|
+
}
|
|
32148
|
+
const header = new Uint8Array(
|
|
32149
|
+
1 + WRAPPED_KEY_LENGTH_BYTES + wrappedKey.length
|
|
32181
32150
|
);
|
|
32182
|
-
|
|
32183
|
-
|
|
32184
|
-
|
|
32151
|
+
header[0] = JOB_RESULT_FORMAT_VERSION;
|
|
32152
|
+
new DataView(header.buffer).setUint32(1, wrappedKey.length);
|
|
32153
|
+
header.set(wrappedKey, 1 + WRAPPED_KEY_LENGTH_BYTES);
|
|
32154
|
+
let pending = new Uint8Array(JOB_RESULT_CHUNK_BYTES);
|
|
32155
|
+
let pendingLength = 0;
|
|
32156
|
+
let chunkIndex = 0;
|
|
32157
|
+
const transform = new TransformStream({
|
|
32158
|
+
async transform(chunk, controller) {
|
|
32159
|
+
if (!(chunk instanceof Uint8Array)) {
|
|
32160
|
+
throw new JobEnvelopeError(
|
|
32161
|
+
"Invalid job result: stream yielded non-byte data"
|
|
32162
|
+
);
|
|
32163
|
+
}
|
|
32164
|
+
let offset = 0;
|
|
32165
|
+
while (offset < chunk.length) {
|
|
32166
|
+
if (pendingLength === JOB_RESULT_CHUNK_BYTES) {
|
|
32167
|
+
controller.enqueue(
|
|
32168
|
+
await encryptResultChunk(
|
|
32169
|
+
key,
|
|
32170
|
+
noncePrefix,
|
|
32171
|
+
metadataBytes,
|
|
32172
|
+
pending,
|
|
32173
|
+
chunkIndex,
|
|
32174
|
+
false
|
|
32175
|
+
)
|
|
32176
|
+
);
|
|
32177
|
+
chunkIndex += 1;
|
|
32178
|
+
pending = new Uint8Array(JOB_RESULT_CHUNK_BYTES);
|
|
32179
|
+
pendingLength = 0;
|
|
32180
|
+
}
|
|
32181
|
+
const count = Math.min(
|
|
32182
|
+
chunk.length - offset,
|
|
32183
|
+
JOB_RESULT_CHUNK_BYTES - pendingLength
|
|
32184
|
+
);
|
|
32185
|
+
pending.set(chunk.subarray(offset, offset + count), pendingLength);
|
|
32186
|
+
pendingLength += count;
|
|
32187
|
+
offset += count;
|
|
32188
|
+
}
|
|
32189
|
+
},
|
|
32190
|
+
async flush(controller) {
|
|
32191
|
+
controller.enqueue(
|
|
32192
|
+
await encryptResultChunk(
|
|
32193
|
+
key,
|
|
32194
|
+
noncePrefix,
|
|
32195
|
+
metadataBytes,
|
|
32196
|
+
pending.subarray(0, pendingLength),
|
|
32197
|
+
chunkIndex,
|
|
32198
|
+
true
|
|
32199
|
+
)
|
|
32200
|
+
);
|
|
32201
|
+
}
|
|
32202
|
+
});
|
|
32203
|
+
return { header, transform };
|
|
32185
32204
|
}
|
|
32186
|
-
async function
|
|
32187
|
-
|
|
32188
|
-
|
|
32189
|
-
|
|
32205
|
+
async function sealJobResult(result, builderPublicKey, ecies) {
|
|
32206
|
+
validateResult(result);
|
|
32207
|
+
const sealed = await sealJobResultStream(
|
|
32208
|
+
resultMetadata(result),
|
|
32209
|
+
builderPublicKey,
|
|
32210
|
+
ecies
|
|
32211
|
+
);
|
|
32212
|
+
const frameCount = Math.max(
|
|
32213
|
+
1,
|
|
32214
|
+
Math.ceil(result.body.length / JOB_RESULT_CHUNK_BYTES)
|
|
32190
32215
|
);
|
|
32191
|
-
const
|
|
32192
|
-
|
|
32216
|
+
const size = sealed.header.length + result.body.length + frameCount * (FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES + AES_GCM_TAG_BYTES);
|
|
32217
|
+
const bytes = new Uint8Array(size);
|
|
32218
|
+
bytes.set(sealed.header, 0);
|
|
32219
|
+
let outputOffset = sealed.header.length;
|
|
32220
|
+
const reader = sealed.transform.readable.getReader();
|
|
32221
|
+
const drain = (async () => {
|
|
32222
|
+
for (; ; ) {
|
|
32223
|
+
const next = await reader.read();
|
|
32224
|
+
if (next.done) break;
|
|
32225
|
+
bytes.set(next.value, outputOffset);
|
|
32226
|
+
outputOffset += next.value.length;
|
|
32227
|
+
}
|
|
32228
|
+
})();
|
|
32229
|
+
const writer = sealed.transform.writable.getWriter();
|
|
32230
|
+
const fill = (async () => {
|
|
32231
|
+
for (let offset = 0; offset < result.body.length; offset += JOB_RESULT_CHUNK_BYTES) {
|
|
32232
|
+
await writer.write(
|
|
32233
|
+
result.body.subarray(offset, offset + JOB_RESULT_CHUNK_BYTES)
|
|
32234
|
+
);
|
|
32235
|
+
}
|
|
32236
|
+
await writer.close();
|
|
32237
|
+
})();
|
|
32238
|
+
await Promise.all([drain, fill]);
|
|
32239
|
+
if (outputOffset !== bytes.length) {
|
|
32240
|
+
throw new JobEnvelopeError("Invalid job result: sealed size mismatch");
|
|
32241
|
+
}
|
|
32242
|
+
return { bytes, hash: bytesToHex2(sha2565(bytes)), size };
|
|
32243
|
+
}
|
|
32244
|
+
async function openJobResultStream(bytesStream, builderPrivateKey, ecies, expect) {
|
|
32245
|
+
const reader = new ByteStreamReader(bytesStream);
|
|
32246
|
+
const headerPrefix = await reader.readExact(1 + WRAPPED_KEY_LENGTH_BYTES);
|
|
32247
|
+
const formatVersion = headerPrefix[0];
|
|
32248
|
+
if (formatVersion !== JOB_RESULT_FORMAT_VERSION) {
|
|
32193
32249
|
throw new JobEnvelopeError(
|
|
32194
|
-
`
|
|
32250
|
+
`Unsupported job result format: ${String(formatVersion)}`
|
|
32195
32251
|
);
|
|
32196
32252
|
}
|
|
32197
|
-
|
|
32253
|
+
const wrappedKeyLength = readUint32(headerPrefix, 1);
|
|
32254
|
+
if (wrappedKeyLength === 0 || wrappedKeyLength > MAX_WRAPPED_KEY_BYTES) {
|
|
32198
32255
|
throw new JobEnvelopeError(
|
|
32199
|
-
|
|
32256
|
+
"Invalid job result: invalid wrapped key length"
|
|
32200
32257
|
);
|
|
32201
32258
|
}
|
|
32202
|
-
|
|
32259
|
+
const wrappedKey = await reader.readExact(wrappedKeyLength);
|
|
32260
|
+
const keyPlaintext = await ecies.decrypt(
|
|
32261
|
+
fromHex6(builderPrivateKey, "bytes"),
|
|
32262
|
+
bytesToEncrypted(wrappedKey)
|
|
32263
|
+
);
|
|
32264
|
+
const parsed = parseWrappedKeyPlaintext(keyPlaintext);
|
|
32265
|
+
verifyResultBindings(parsed.metadata, expect);
|
|
32266
|
+
const key = await importAesKey(parsed.contentKey, "decrypt");
|
|
32267
|
+
parsed.contentKey.fill(0);
|
|
32268
|
+
keyPlaintext.fill(0);
|
|
32269
|
+
let chunkIndex = 0;
|
|
32270
|
+
let finished = false;
|
|
32271
|
+
const body = new ReadableStream({
|
|
32272
|
+
async pull(controller) {
|
|
32273
|
+
if (finished) {
|
|
32274
|
+
controller.close();
|
|
32275
|
+
return;
|
|
32276
|
+
}
|
|
32277
|
+
try {
|
|
32278
|
+
const frameHeader = await reader.readExactOrNull(
|
|
32279
|
+
FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES
|
|
32280
|
+
);
|
|
32281
|
+
if (!frameHeader) {
|
|
32282
|
+
throw new JobEnvelopeError("Invalid job result: missing final chunk");
|
|
32283
|
+
}
|
|
32284
|
+
const encryptedLength = readUint32(frameHeader);
|
|
32285
|
+
if (encryptedLength < AES_GCM_TAG_BYTES || encryptedLength > JOB_RESULT_CHUNK_BYTES + AES_GCM_TAG_BYTES) {
|
|
32286
|
+
throw new JobEnvelopeError(
|
|
32287
|
+
"Invalid job result: invalid chunk length"
|
|
32288
|
+
);
|
|
32289
|
+
}
|
|
32290
|
+
const flags = frameHeader[FRAME_LENGTH_BYTES];
|
|
32291
|
+
if (flags !== 0 && flags !== FINAL_FRAME_FLAG) {
|
|
32292
|
+
throw new JobEnvelopeError("Invalid job result: invalid chunk flags");
|
|
32293
|
+
}
|
|
32294
|
+
const final = flags === FINAL_FRAME_FLAG;
|
|
32295
|
+
const plaintextLength = encryptedLength - AES_GCM_TAG_BYTES;
|
|
32296
|
+
if (!final && plaintextLength !== JOB_RESULT_CHUNK_BYTES) {
|
|
32297
|
+
throw new JobEnvelopeError(
|
|
32298
|
+
"Invalid job result: short non-final chunk"
|
|
32299
|
+
);
|
|
32300
|
+
}
|
|
32301
|
+
const encrypted = await reader.readExact(encryptedLength);
|
|
32302
|
+
const plaintext = new Uint8Array(
|
|
32303
|
+
await webCrypto().subtle.decrypt(
|
|
32304
|
+
{
|
|
32305
|
+
name: "AES-GCM",
|
|
32306
|
+
iv: chunkNonce(parsed.noncePrefix, chunkIndex),
|
|
32307
|
+
additionalData: chunkAad(
|
|
32308
|
+
parsed.metadataBytes,
|
|
32309
|
+
chunkIndex,
|
|
32310
|
+
final,
|
|
32311
|
+
plaintextLength
|
|
32312
|
+
),
|
|
32313
|
+
tagLength: AES_GCM_TAG_BYTES * 8
|
|
32314
|
+
},
|
|
32315
|
+
key,
|
|
32316
|
+
encrypted
|
|
32317
|
+
)
|
|
32318
|
+
);
|
|
32319
|
+
if (plaintext.length !== plaintextLength) {
|
|
32320
|
+
throw new JobEnvelopeError(
|
|
32321
|
+
"Invalid job result: decrypted chunk length mismatch"
|
|
32322
|
+
);
|
|
32323
|
+
}
|
|
32324
|
+
chunkIndex += 1;
|
|
32325
|
+
if (final) {
|
|
32326
|
+
if (await reader.hasRemaining()) {
|
|
32327
|
+
throw new JobEnvelopeError(
|
|
32328
|
+
"Invalid job result: bytes follow final chunk"
|
|
32329
|
+
);
|
|
32330
|
+
}
|
|
32331
|
+
finished = true;
|
|
32332
|
+
}
|
|
32333
|
+
controller.enqueue(plaintext);
|
|
32334
|
+
if (finished) controller.close();
|
|
32335
|
+
} catch (error) {
|
|
32336
|
+
controller.error(normalizeChunkError(error));
|
|
32337
|
+
void reader.cancel(error).catch(() => void 0);
|
|
32338
|
+
}
|
|
32339
|
+
},
|
|
32340
|
+
cancel(reason) {
|
|
32341
|
+
return reader.cancel(reason);
|
|
32342
|
+
}
|
|
32343
|
+
});
|
|
32344
|
+
return { metadata: parsed.metadata, body };
|
|
32345
|
+
}
|
|
32346
|
+
function bufferedResultBodySize(sealedBytes) {
|
|
32347
|
+
if (sealedBytes.length < 1 + WRAPPED_KEY_LENGTH_BYTES) {
|
|
32348
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32349
|
+
}
|
|
32350
|
+
if (sealedBytes[0] !== JOB_RESULT_FORMAT_VERSION) {
|
|
32351
|
+
throw new JobEnvelopeError(
|
|
32352
|
+
`Unsupported job result format: ${String(sealedBytes[0])}`
|
|
32353
|
+
);
|
|
32354
|
+
}
|
|
32355
|
+
const wrappedKeyLength = readUint32(sealedBytes, 1);
|
|
32356
|
+
if (wrappedKeyLength === 0 || wrappedKeyLength > MAX_WRAPPED_KEY_BYTES) {
|
|
32203
32357
|
throw new JobEnvelopeError(
|
|
32204
|
-
|
|
32358
|
+
"Invalid job result: invalid wrapped key length"
|
|
32205
32359
|
);
|
|
32206
32360
|
}
|
|
32207
|
-
|
|
32361
|
+
let offset = 1 + WRAPPED_KEY_LENGTH_BYTES + wrappedKeyLength;
|
|
32362
|
+
if (offset > sealedBytes.length) {
|
|
32363
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32364
|
+
}
|
|
32365
|
+
let bodySize = 0;
|
|
32366
|
+
let sawFinal = false;
|
|
32367
|
+
while (offset < sealedBytes.length) {
|
|
32368
|
+
if (sealedBytes.length - offset < FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES) {
|
|
32369
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32370
|
+
}
|
|
32371
|
+
const encryptedLength = readUint32(sealedBytes, offset);
|
|
32372
|
+
const flags = sealedBytes[offset + FRAME_LENGTH_BYTES];
|
|
32373
|
+
if (encryptedLength < AES_GCM_TAG_BYTES || encryptedLength > JOB_RESULT_CHUNK_BYTES + AES_GCM_TAG_BYTES || flags !== 0 && flags !== FINAL_FRAME_FLAG) {
|
|
32374
|
+
throw new JobEnvelopeError("Invalid job result: invalid chunk framing");
|
|
32375
|
+
}
|
|
32376
|
+
const plaintextLength = encryptedLength - AES_GCM_TAG_BYTES;
|
|
32377
|
+
if (flags === 0 && plaintextLength !== JOB_RESULT_CHUNK_BYTES) {
|
|
32378
|
+
throw new JobEnvelopeError("Invalid job result: short non-final chunk");
|
|
32379
|
+
}
|
|
32380
|
+
offset += FRAME_LENGTH_BYTES + FRAME_FLAGS_BYTES;
|
|
32381
|
+
if (encryptedLength > sealedBytes.length - offset) {
|
|
32382
|
+
throw new JobEnvelopeError("Invalid job result: truncated payload");
|
|
32383
|
+
}
|
|
32384
|
+
offset += encryptedLength;
|
|
32385
|
+
bodySize += plaintextLength;
|
|
32386
|
+
if (flags === FINAL_FRAME_FLAG) {
|
|
32387
|
+
sawFinal = true;
|
|
32388
|
+
if (offset !== sealedBytes.length) {
|
|
32389
|
+
throw new JobEnvelopeError(
|
|
32390
|
+
"Invalid job result: bytes follow final chunk"
|
|
32391
|
+
);
|
|
32392
|
+
}
|
|
32393
|
+
}
|
|
32394
|
+
}
|
|
32395
|
+
if (!sawFinal) {
|
|
32396
|
+
throw new JobEnvelopeError("Invalid job result: missing final chunk");
|
|
32397
|
+
}
|
|
32398
|
+
return bodySize;
|
|
32399
|
+
}
|
|
32400
|
+
async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
|
|
32401
|
+
const bodySize = bufferedResultBodySize(sealedBytes);
|
|
32402
|
+
const stream = new ReadableStream({
|
|
32403
|
+
start(controller) {
|
|
32404
|
+
controller.enqueue(sealedBytes);
|
|
32405
|
+
controller.close();
|
|
32406
|
+
}
|
|
32407
|
+
});
|
|
32408
|
+
const opened = await openJobResultStream(
|
|
32409
|
+
stream,
|
|
32410
|
+
builderPrivateKey,
|
|
32411
|
+
ecies,
|
|
32412
|
+
expect
|
|
32413
|
+
);
|
|
32414
|
+
const body = new Uint8Array(bodySize);
|
|
32415
|
+
let offset = 0;
|
|
32416
|
+
await opened.body.pipeTo(
|
|
32417
|
+
new WritableStream({
|
|
32418
|
+
write(chunk) {
|
|
32419
|
+
body.set(chunk, offset);
|
|
32420
|
+
offset += chunk.length;
|
|
32421
|
+
}
|
|
32422
|
+
})
|
|
32423
|
+
);
|
|
32424
|
+
if (offset !== body.length) {
|
|
32425
|
+
throw new JobEnvelopeError("Invalid job result: opened size mismatch");
|
|
32426
|
+
}
|
|
32427
|
+
return { ...opened.metadata, body };
|
|
32208
32428
|
}
|
|
32209
32429
|
|
|
32210
32430
|
// src/protocol/personal-server-registration.ts
|
|
@@ -32910,6 +33130,7 @@ import {
|
|
|
32910
33130
|
maxUint256,
|
|
32911
33131
|
stringToBytes as stringToBytes3
|
|
32912
33132
|
} from "viem";
|
|
33133
|
+
import { DataPointDeletedError, DataPointNotFoundError } from "./errors.js";
|
|
32913
33134
|
|
|
32914
33135
|
// src/protocol/lineage.ts
|
|
32915
33136
|
import {
|
|
@@ -32918,6 +33139,7 @@ import {
|
|
|
32918
33139
|
keccak256 as keccak2562
|
|
32919
33140
|
} from "viem";
|
|
32920
33141
|
import { z } from "zod";
|
|
33142
|
+
import { LineageReadError, WriteRequestError as WriteRequestError2 } from "./errors.js";
|
|
32921
33143
|
|
|
32922
33144
|
// src/protocol/personal-server-error-body.ts
|
|
32923
33145
|
function isRecord2(value) {
|
|
@@ -32949,6 +33171,7 @@ async function readPersonalServerErrorBody(response) {
|
|
|
32949
33171
|
}
|
|
32950
33172
|
|
|
32951
33173
|
// src/protocol/write-signer.ts
|
|
33174
|
+
import { WriteRequestError } from "./errors.js";
|
|
32952
33175
|
function isRecord3(value) {
|
|
32953
33176
|
return value !== null && typeof value === "object";
|
|
32954
33177
|
}
|
|
@@ -33029,7 +33252,7 @@ function derivedScopeViolatesNaming(derivedScope, sourceScope) {
|
|
|
33029
33252
|
function assertDerivedScopeNaming(derivedScope, sourceScopes) {
|
|
33030
33253
|
for (const sourceScope of sourceScopes) {
|
|
33031
33254
|
if (derivedScopeViolatesNaming(derivedScope, sourceScope)) {
|
|
33032
|
-
throw new
|
|
33255
|
+
throw new WriteRequestError2(
|
|
33033
33256
|
`Derived scope ${derivedScope} must not share its first segment with source scope ${sourceScope}; put derivatives in the app's own namespace`,
|
|
33034
33257
|
{ scope: derivedScope, sourceScope }
|
|
33035
33258
|
);
|
|
@@ -33387,6 +33610,9 @@ async function deleteDataPoint(input) {
|
|
|
33387
33610
|
}
|
|
33388
33611
|
}
|
|
33389
33612
|
|
|
33613
|
+
// src/protocol/personal-server-data.ts
|
|
33614
|
+
import { DataPointDeletedError as DataPointDeletedError2 } from "./errors.js";
|
|
33615
|
+
|
|
33390
33616
|
// src/protocol/data-file.ts
|
|
33391
33617
|
import { z as z2 } from "zod";
|
|
33392
33618
|
var DataFileEnvelopeSchema = z2.object({
|
|
@@ -33445,7 +33671,7 @@ async function readPersonalServerData(params) {
|
|
|
33445
33671
|
const request = await buildPersonalServerDataReadRequest(params);
|
|
33446
33672
|
const response = await fetchFn(request);
|
|
33447
33673
|
if (response.status === 410) {
|
|
33448
|
-
throw new
|
|
33674
|
+
throw new DataPointDeletedError2(
|
|
33449
33675
|
`Personal Server scope '${params.scope}' has been deleted`,
|
|
33450
33676
|
{
|
|
33451
33677
|
scope: params.scope,
|
|
@@ -33460,7 +33686,7 @@ async function readPersonalServerData(params) {
|
|
|
33460
33686
|
}
|
|
33461
33687
|
const body = await response.json();
|
|
33462
33688
|
if (isDataPointTombstone(body)) {
|
|
33463
|
-
throw new
|
|
33689
|
+
throw new DataPointDeletedError2(
|
|
33464
33690
|
`Personal Server scope '${params.scope}' has been deleted`,
|
|
33465
33691
|
{ scope: params.scope, deletedAt: tombstoneDeletedAt(body) }
|
|
33466
33692
|
);
|
|
@@ -33663,17 +33889,28 @@ function tryGrantPermissions(scopes) {
|
|
|
33663
33889
|
import { sha256 as sha2567 } from "@noble/hashes/sha2";
|
|
33664
33890
|
import { bytesToHex as bytesToHex4, isAddress as isAddress7 } from "viem";
|
|
33665
33891
|
import { z as z4 } from "zod";
|
|
33892
|
+
import {
|
|
33893
|
+
WriteConflictError,
|
|
33894
|
+
WriteForbiddenError,
|
|
33895
|
+
WriteLineageError,
|
|
33896
|
+
WriteRejectedError,
|
|
33897
|
+
WriteRequestError as WriteRequestError4,
|
|
33898
|
+
WriteSessionError,
|
|
33899
|
+
WriteSessionExpiredError,
|
|
33900
|
+
WriteUnauthorizedError
|
|
33901
|
+
} from "./errors.js";
|
|
33666
33902
|
|
|
33667
33903
|
// src/protocol/write-request.ts
|
|
33668
33904
|
import { sha256 as sha2566 } from "@noble/hashes/sha2";
|
|
33669
33905
|
import { bytesToHex as bytesToHex3 } from "viem";
|
|
33906
|
+
import { WriteRequestError as WriteRequestError3, WriteTransportError } from "./errors.js";
|
|
33670
33907
|
function normalizeBaseUrl2(url) {
|
|
33671
33908
|
return url.replace(/\/+$/, "");
|
|
33672
33909
|
}
|
|
33673
33910
|
function resolveFetch2(fetchFn) {
|
|
33674
33911
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
33675
33912
|
if (resolved === void 0) {
|
|
33676
|
-
throw new
|
|
33913
|
+
throw new WriteRequestError3("No fetch implementation available");
|
|
33677
33914
|
}
|
|
33678
33915
|
return resolved;
|
|
33679
33916
|
}
|
|
@@ -33728,14 +33965,14 @@ function nextProofIat(proofKey) {
|
|
|
33728
33965
|
return sleep2(waitSec * 1e3).then(() => iat);
|
|
33729
33966
|
}
|
|
33730
33967
|
function freshProofNonce() {
|
|
33731
|
-
const
|
|
33732
|
-
if (typeof
|
|
33733
|
-
return
|
|
33968
|
+
const webCrypto2 = globalThis.crypto;
|
|
33969
|
+
if (typeof webCrypto2?.randomUUID === "function") {
|
|
33970
|
+
return webCrypto2.randomUUID();
|
|
33734
33971
|
}
|
|
33735
|
-
if (typeof
|
|
33736
|
-
return bytesToHex3(
|
|
33972
|
+
if (typeof webCrypto2?.getRandomValues === "function") {
|
|
33973
|
+
return bytesToHex3(webCrypto2.getRandomValues(new Uint8Array(16)));
|
|
33737
33974
|
}
|
|
33738
|
-
throw new
|
|
33975
|
+
throw new WriteRequestError3(
|
|
33739
33976
|
"No secure random source available to build a proof nonce; provide a crypto global"
|
|
33740
33977
|
);
|
|
33741
33978
|
}
|
|
@@ -33891,7 +34128,7 @@ function isWriteSession(value) {
|
|
|
33891
34128
|
}
|
|
33892
34129
|
function sessionCoversScope(session, scope) {
|
|
33893
34130
|
if (!isRecord2(session) || !Array.isArray(session.writeScopes) || !session.writeScopes.every((pattern) => typeof pattern === "string")) {
|
|
33894
|
-
throw new
|
|
34131
|
+
throw new WriteRequestError4("session must come from openWriteSession");
|
|
33895
34132
|
}
|
|
33896
34133
|
return session.writeScopes.some(
|
|
33897
34134
|
(pattern) => scopeMatchesPattern(scope, pattern)
|
|
@@ -33916,12 +34153,12 @@ function encodeWriteMetadataHeader(metadata) {
|
|
|
33916
34153
|
try {
|
|
33917
34154
|
json = JSON.stringify(metadata);
|
|
33918
34155
|
} catch (err) {
|
|
33919
|
-
throw new
|
|
34156
|
+
throw new WriteRequestError4(
|
|
33920
34157
|
`metadata is not JSON-serialisable: ${errorMessage(err)}`
|
|
33921
34158
|
);
|
|
33922
34159
|
}
|
|
33923
34160
|
if (typeof json !== "string") {
|
|
33924
|
-
throw new
|
|
34161
|
+
throw new WriteRequestError4("metadata must serialise to JSON");
|
|
33925
34162
|
}
|
|
33926
34163
|
return json.replace(
|
|
33927
34164
|
/[\u007f-\uffff]/g,
|
|
@@ -33956,7 +34193,7 @@ function setFilenameHeader(headers, filename) {
|
|
|
33956
34193
|
function assertNoReservedKeys(value, where) {
|
|
33957
34194
|
for (const key of RESERVED_WRITE_KEYS) {
|
|
33958
34195
|
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
33959
|
-
throw new
|
|
34196
|
+
throw new WriteRequestError4(
|
|
33960
34197
|
`${where} must not contain the reserved ${key} key; the Personal Server stamps it`,
|
|
33961
34198
|
{ key }
|
|
33962
34199
|
);
|
|
@@ -33968,10 +34205,10 @@ function isLineagePair(value) {
|
|
|
33968
34205
|
}
|
|
33969
34206
|
function normalizeLineage(lineage, derivedScope) {
|
|
33970
34207
|
if (!Array.isArray(lineage)) {
|
|
33971
|
-
throw new
|
|
34208
|
+
throw new WriteRequestError4("lineage must be an array of data point ids");
|
|
33972
34209
|
}
|
|
33973
34210
|
if (lineage.length > MAX_LINEAGE_SOURCES) {
|
|
33974
|
-
throw new
|
|
34211
|
+
throw new WriteRequestError4(
|
|
33975
34212
|
`lineage lists ${lineage.length} sources; the maximum is ${MAX_LINEAGE_SOURCES}`,
|
|
33976
34213
|
{ max: MAX_LINEAGE_SOURCES, count: lineage.length }
|
|
33977
34214
|
);
|
|
@@ -33984,13 +34221,13 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
33984
34221
|
let id;
|
|
33985
34222
|
if (isLineagePair(entry)) {
|
|
33986
34223
|
if (!isAddress7(entry.ownerAddress, { strict: false })) {
|
|
33987
|
-
throw new
|
|
34224
|
+
throw new WriteRequestError4(
|
|
33988
34225
|
"lineage source ownerAddress must be an EVM address",
|
|
33989
34226
|
{ ownerAddress: entry.ownerAddress }
|
|
33990
34227
|
);
|
|
33991
34228
|
}
|
|
33992
34229
|
if (entry.scope.length === 0) {
|
|
33993
|
-
throw new
|
|
34230
|
+
throw new WriteRequestError4("lineage source scope is required");
|
|
33994
34231
|
}
|
|
33995
34232
|
id = deriveDataPointId(entry.ownerAddress, entry.scope);
|
|
33996
34233
|
sourceScopes.push(entry.scope);
|
|
@@ -33998,14 +34235,14 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
33998
34235
|
} else if (isDataPointId(entry)) {
|
|
33999
34236
|
id = entry;
|
|
34000
34237
|
} else {
|
|
34001
|
-
throw new
|
|
34238
|
+
throw new WriteRequestError4(
|
|
34002
34239
|
"lineage entries must be 32-byte hex data point ids or { ownerAddress, scope } pairs",
|
|
34003
34240
|
{ entry }
|
|
34004
34241
|
);
|
|
34005
34242
|
}
|
|
34006
34243
|
const normalized = id.toLowerCase();
|
|
34007
34244
|
if (seen.has(normalized)) {
|
|
34008
|
-
throw new
|
|
34245
|
+
throw new WriteRequestError4("lineage must not repeat a data point id", {
|
|
34009
34246
|
dataPointId: normalized
|
|
34010
34247
|
});
|
|
34011
34248
|
}
|
|
@@ -34014,7 +34251,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
34014
34251
|
}
|
|
34015
34252
|
for (const own of ownIds) {
|
|
34016
34253
|
if (seen.has(own)) {
|
|
34017
|
-
throw new
|
|
34254
|
+
throw new WriteRequestError4(
|
|
34018
34255
|
"lineage must not cite the record's own data point",
|
|
34019
34256
|
{ dataPointId: own, scope: derivedScope }
|
|
34020
34257
|
);
|
|
@@ -34025,7 +34262,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
34025
34262
|
}
|
|
34026
34263
|
function assertNoLineageField(value, where) {
|
|
34027
34264
|
if (Object.prototype.hasOwnProperty.call(value, LINEAGE_FIELD)) {
|
|
34028
|
-
throw new
|
|
34265
|
+
throw new WriteRequestError4(
|
|
34029
34266
|
`${where}.${LINEAGE_FIELD} is reserved; pass sources through the lineage option`
|
|
34030
34267
|
);
|
|
34031
34268
|
}
|
|
@@ -34033,7 +34270,7 @@ function assertNoLineageField(value, where) {
|
|
|
34033
34270
|
function buildMetadataHeader(metadata, sources) {
|
|
34034
34271
|
if (metadata !== void 0) {
|
|
34035
34272
|
if (!isRecord2(metadata)) {
|
|
34036
|
-
throw new
|
|
34273
|
+
throw new WriteRequestError4("metadata must be a plain object");
|
|
34037
34274
|
}
|
|
34038
34275
|
assertNoReservedKeys(metadata, "metadata");
|
|
34039
34276
|
assertNoLineageField(metadata, "metadata");
|
|
@@ -34046,24 +34283,24 @@ function buildMetadataHeader(metadata, sources) {
|
|
|
34046
34283
|
}
|
|
34047
34284
|
function prepareWrite(params) {
|
|
34048
34285
|
if (params.binary !== void 0 && params.data !== void 0) {
|
|
34049
|
-
throw new
|
|
34286
|
+
throw new WriteRequestError4("Pass either data or binary, not both");
|
|
34050
34287
|
}
|
|
34051
34288
|
const rawLineage = params.lineage;
|
|
34052
34289
|
const sources = rawLineage === void 0 || rawLineage === null ? void 0 : normalizeLineage(rawLineage, params.scope);
|
|
34053
34290
|
if (params.binary !== void 0) {
|
|
34054
34291
|
const { bytes, contentType, filename } = params.binary;
|
|
34055
34292
|
if (!(bytes instanceof Uint8Array)) {
|
|
34056
|
-
throw new
|
|
34293
|
+
throw new WriteRequestError4("binary.bytes must be a Uint8Array");
|
|
34057
34294
|
}
|
|
34058
34295
|
if (typeof contentType !== "string" || contentType.trim() === "") {
|
|
34059
|
-
throw new
|
|
34296
|
+
throw new WriteRequestError4("binary.contentType is required");
|
|
34060
34297
|
}
|
|
34061
34298
|
if (filename !== void 0) {
|
|
34062
34299
|
if (typeof filename !== "string") {
|
|
34063
|
-
throw new
|
|
34300
|
+
throw new WriteRequestError4("binary.filename must be a string");
|
|
34064
34301
|
}
|
|
34065
34302
|
if (filename !== filename.trim()) {
|
|
34066
|
-
throw new
|
|
34303
|
+
throw new WriteRequestError4(
|
|
34067
34304
|
"binary.filename must not have leading or trailing whitespace"
|
|
34068
34305
|
);
|
|
34069
34306
|
}
|
|
@@ -34083,13 +34320,13 @@ function prepareWrite(params) {
|
|
|
34083
34320
|
};
|
|
34084
34321
|
}
|
|
34085
34322
|
if (params.data === void 0) {
|
|
34086
|
-
throw new
|
|
34323
|
+
throw new WriteRequestError4("Pass data (a JSON object) or binary");
|
|
34087
34324
|
}
|
|
34088
34325
|
if (!isRecord2(params.data)) {
|
|
34089
|
-
throw new
|
|
34326
|
+
throw new WriteRequestError4("data must be a plain JSON object");
|
|
34090
34327
|
}
|
|
34091
34328
|
if (params.metadata !== void 0) {
|
|
34092
|
-
throw new
|
|
34329
|
+
throw new WriteRequestError4(
|
|
34093
34330
|
"metadata applies to binary writes; put fields to store inside data"
|
|
34094
34331
|
);
|
|
34095
34332
|
}
|
|
@@ -34100,12 +34337,12 @@ function prepareWrite(params) {
|
|
|
34100
34337
|
try {
|
|
34101
34338
|
text = JSON.stringify(record);
|
|
34102
34339
|
} catch (err) {
|
|
34103
|
-
throw new
|
|
34340
|
+
throw new WriteRequestError4(
|
|
34104
34341
|
`data is not JSON-serialisable: ${errorMessage(err)}`
|
|
34105
34342
|
);
|
|
34106
34343
|
}
|
|
34107
34344
|
if (typeof text !== "string" || !text.startsWith("{")) {
|
|
34108
|
-
throw new
|
|
34345
|
+
throw new WriteRequestError4("data must serialise to a JSON object");
|
|
34109
34346
|
}
|
|
34110
34347
|
const body = new TextEncoder().encode(text);
|
|
34111
34348
|
return {
|
|
@@ -34134,11 +34371,11 @@ async function writeErrorFromResponse(response) {
|
|
|
34134
34371
|
async function writeData(params) {
|
|
34135
34372
|
const { session } = params;
|
|
34136
34373
|
if (!isWriteSession(session)) {
|
|
34137
|
-
throw new
|
|
34374
|
+
throw new WriteRequestError4("session must come from openWriteSession");
|
|
34138
34375
|
}
|
|
34139
34376
|
const fetchFn = resolveFetch2(params.fetch);
|
|
34140
34377
|
if (typeof params.scope !== "string" || params.scope.length === 0) {
|
|
34141
|
-
throw new
|
|
34378
|
+
throw new WriteRequestError4("scope is required");
|
|
34142
34379
|
}
|
|
34143
34380
|
const prepared = prepareWrite(params);
|
|
34144
34381
|
if (Date.now() >= session.expiresAt) {
|
|
@@ -34234,6 +34471,21 @@ async function writePersonalServerData(params) {
|
|
|
34234
34471
|
|
|
34235
34472
|
// src/protocol/derivative-questions.ts
|
|
34236
34473
|
import { z as z5 } from "zod";
|
|
34474
|
+
import {
|
|
34475
|
+
DerivativeComputeUnavailableError,
|
|
34476
|
+
DerivativeCycleError,
|
|
34477
|
+
DerivativeDerivedScopeRequiredError,
|
|
34478
|
+
DerivativeQuestionFailedError,
|
|
34479
|
+
DerivativeQuestionInvalidError,
|
|
34480
|
+
DerivativeQuestionNotFoundError,
|
|
34481
|
+
DerivativeQuestionRejectedError,
|
|
34482
|
+
DerivativeQuestionTimeoutError,
|
|
34483
|
+
DerivativeSourceNotGrantedError,
|
|
34484
|
+
WriteConflictError as WriteConflictError2,
|
|
34485
|
+
WriteForbiddenError as WriteForbiddenError2,
|
|
34486
|
+
WriteRequestError as WriteRequestError5,
|
|
34487
|
+
WriteUnauthorizedError as WriteUnauthorizedError2
|
|
34488
|
+
} from "./errors.js";
|
|
34237
34489
|
var DERIVATIVE_QUESTIONS_PATH = "/v1/derivatives/questions";
|
|
34238
34490
|
var MAX_QUESTION_SOURCE_SCOPES = 16;
|
|
34239
34491
|
var MAX_QUESTION_CHARS = 8e3;
|
|
@@ -34316,15 +34568,15 @@ function fetchIdOf(fetchFn) {
|
|
|
34316
34568
|
}
|
|
34317
34569
|
function resolveRequest(params) {
|
|
34318
34570
|
if (typeof params.personalServerUrl !== "string" || params.personalServerUrl.length === 0) {
|
|
34319
|
-
throw new
|
|
34571
|
+
throw new WriteRequestError5("personalServerUrl is required");
|
|
34320
34572
|
}
|
|
34321
34573
|
if (typeof params.grantId !== "string" || params.grantId.length === 0) {
|
|
34322
|
-
throw new
|
|
34574
|
+
throw new WriteRequestError5(
|
|
34323
34575
|
"grantId is required; a question call runs under the grant carrying write:<derivedScope>"
|
|
34324
34576
|
);
|
|
34325
34577
|
}
|
|
34326
34578
|
if (params.signer === null || typeof params.signer !== "object") {
|
|
34327
|
-
throw new
|
|
34579
|
+
throw new WriteRequestError5(
|
|
34328
34580
|
"signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
|
|
34329
34581
|
);
|
|
34330
34582
|
}
|
|
@@ -34400,13 +34652,13 @@ async function questionErrorFromResponse(response, body) {
|
|
|
34400
34652
|
}
|
|
34401
34653
|
switch (response.status) {
|
|
34402
34654
|
case 401:
|
|
34403
|
-
return new
|
|
34655
|
+
return new WriteUnauthorizedError2(text, errorCode, details);
|
|
34404
34656
|
case 403:
|
|
34405
|
-
return new
|
|
34657
|
+
return new WriteForbiddenError2(text, errorCode, details);
|
|
34406
34658
|
case 404:
|
|
34407
34659
|
return new DerivativeQuestionNotFoundError(text, errorCode, details);
|
|
34408
34660
|
case 409:
|
|
34409
|
-
return new
|
|
34661
|
+
return new WriteConflictError2(text, errorCode, details);
|
|
34410
34662
|
default:
|
|
34411
34663
|
return new DerivativeQuestionRejectedError(
|
|
34412
34664
|
text,
|
|
@@ -34508,22 +34760,22 @@ async function sendQuestionRequest(params, spec, schema) {
|
|
|
34508
34760
|
}
|
|
34509
34761
|
function assertQuestionId(questionId) {
|
|
34510
34762
|
if (typeof questionId !== "string" || questionId.length === 0) {
|
|
34511
|
-
throw new
|
|
34763
|
+
throw new WriteRequestError5("questionId is required");
|
|
34512
34764
|
}
|
|
34513
34765
|
return `${DERIVATIVE_QUESTIONS_PATH}/${encodeURIComponent(questionId)}`;
|
|
34514
34766
|
}
|
|
34515
34767
|
function registrationBody(params) {
|
|
34516
34768
|
const { derivedScope, question } = params;
|
|
34517
34769
|
if (typeof derivedScope !== "string" || derivedScope.length === 0) {
|
|
34518
|
-
throw new
|
|
34770
|
+
throw new WriteRequestError5("derivedScope is required");
|
|
34519
34771
|
}
|
|
34520
34772
|
if (!Array.isArray(params.sourceScopes) || params.sourceScopes.length === 0) {
|
|
34521
|
-
throw new
|
|
34773
|
+
throw new WriteRequestError5(
|
|
34522
34774
|
"sourceScopes must be a non-empty array of scopes"
|
|
34523
34775
|
);
|
|
34524
34776
|
}
|
|
34525
34777
|
if (params.sourceScopes.length > MAX_QUESTION_SOURCE_SCOPES) {
|
|
34526
|
-
throw new
|
|
34778
|
+
throw new WriteRequestError5(
|
|
34527
34779
|
`sourceScopes lists ${params.sourceScopes.length} scopes; the maximum is ${MAX_QUESTION_SOURCE_SCOPES}`,
|
|
34528
34780
|
{ max: MAX_QUESTION_SOURCE_SCOPES, count: params.sourceScopes.length }
|
|
34529
34781
|
);
|
|
@@ -34531,15 +34783,15 @@ function registrationBody(params) {
|
|
|
34531
34783
|
const sourceScopes = [];
|
|
34532
34784
|
for (const scope of params.sourceScopes) {
|
|
34533
34785
|
if (typeof scope !== "string" || scope.length === 0) {
|
|
34534
|
-
throw new
|
|
34786
|
+
throw new WriteRequestError5("sourceScopes entries must be scope strings");
|
|
34535
34787
|
}
|
|
34536
34788
|
if (sourceScopes.includes(scope)) {
|
|
34537
|
-
throw new
|
|
34789
|
+
throw new WriteRequestError5("sourceScopes must not repeat a scope", {
|
|
34538
34790
|
duplicate: scope
|
|
34539
34791
|
});
|
|
34540
34792
|
}
|
|
34541
34793
|
if (scope === derivedScope) {
|
|
34542
|
-
throw new
|
|
34794
|
+
throw new WriteRequestError5(
|
|
34543
34795
|
"derivedScope cannot be one of its own sources",
|
|
34544
34796
|
{ scope }
|
|
34545
34797
|
);
|
|
@@ -34547,17 +34799,17 @@ function registrationBody(params) {
|
|
|
34547
34799
|
sourceScopes.push(scope);
|
|
34548
34800
|
}
|
|
34549
34801
|
if (typeof question !== "string" || question.trim() === "") {
|
|
34550
|
-
throw new
|
|
34802
|
+
throw new WriteRequestError5("question must be a non-empty string");
|
|
34551
34803
|
}
|
|
34552
34804
|
if (question.length > MAX_QUESTION_CHARS) {
|
|
34553
|
-
throw new
|
|
34805
|
+
throw new WriteRequestError5(
|
|
34554
34806
|
`question is ${question.length} characters; the maximum is ${MAX_QUESTION_CHARS}`,
|
|
34555
34807
|
{ max: MAX_QUESTION_CHARS, length: question.length }
|
|
34556
34808
|
);
|
|
34557
34809
|
}
|
|
34558
34810
|
if (params.model !== void 0) {
|
|
34559
34811
|
if (typeof params.model !== "string" || params.model.length > MAX_QUESTION_MODEL_CHARS || !MODEL_ID_PATTERN.test(params.model)) {
|
|
34560
|
-
throw new
|
|
34812
|
+
throw new WriteRequestError5("model must be a provider model id", {
|
|
34561
34813
|
model: params.model
|
|
34562
34814
|
});
|
|
34563
34815
|
}
|
|
@@ -34593,7 +34845,7 @@ async function getQuestion(params) {
|
|
|
34593
34845
|
}
|
|
34594
34846
|
async function listQuestions(params) {
|
|
34595
34847
|
if (typeof params.derivedScope !== "string" || params.derivedScope.length === 0) {
|
|
34596
|
-
throw new
|
|
34848
|
+
throw new WriteRequestError5(
|
|
34597
34849
|
"derivedScope is required; a builder may only list its own questions on a scope it may write"
|
|
34598
34850
|
);
|
|
34599
34851
|
}
|
|
@@ -34698,6 +34950,12 @@ async function askPersonalServer(params) {
|
|
|
34698
34950
|
|
|
34699
34951
|
// src/protocol/derivative-status.ts
|
|
34700
34952
|
import { z as z6 } from "zod";
|
|
34953
|
+
import {
|
|
34954
|
+
DerivativeQuestionRejectedError as DerivativeQuestionRejectedError2,
|
|
34955
|
+
DerivativeQuestionTimeoutError as DerivativeQuestionTimeoutError2,
|
|
34956
|
+
WriteRequestError as WriteRequestError6,
|
|
34957
|
+
WriteTransportError as WriteTransportError2
|
|
34958
|
+
} from "./errors.js";
|
|
34701
34959
|
var DERIVATIVE_STATUS_PATH = "/v1/derivatives/status";
|
|
34702
34960
|
var DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS = 12e4;
|
|
34703
34961
|
var DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS = 2e3;
|
|
@@ -34728,13 +34986,13 @@ function normalizeBaseUrl3(url) {
|
|
|
34728
34986
|
function resolveFetch3(fetchFn) {
|
|
34729
34987
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
34730
34988
|
if (resolved === void 0) {
|
|
34731
|
-
throw new
|
|
34989
|
+
throw new WriteRequestError6("No fetch implementation available");
|
|
34732
34990
|
}
|
|
34733
34991
|
return resolved;
|
|
34734
34992
|
}
|
|
34735
34993
|
function requireDerivedScope(derivedScope) {
|
|
34736
34994
|
if (typeof derivedScope !== "string" || derivedScope.length === 0) {
|
|
34737
|
-
throw new
|
|
34995
|
+
throw new WriteRequestError6("derivedScope is required");
|
|
34738
34996
|
}
|
|
34739
34997
|
return derivedScope;
|
|
34740
34998
|
}
|
|
@@ -34753,7 +35011,7 @@ function sleep3(ms, signal) {
|
|
|
34753
35011
|
});
|
|
34754
35012
|
}
|
|
34755
35013
|
function timeoutError(latest, timeoutMs) {
|
|
34756
|
-
return new
|
|
35014
|
+
return new DerivativeQuestionTimeoutError2(
|
|
34757
35015
|
`Derived scope ${latest.derivedScope} was still ${latest.status} after ${timeoutMs}ms`,
|
|
34758
35016
|
{
|
|
34759
35017
|
derivedScope: latest.derivedScope,
|
|
@@ -34766,7 +35024,7 @@ function timeoutError(latest, timeoutMs) {
|
|
|
34766
35024
|
}
|
|
34767
35025
|
function abortError2(signal) {
|
|
34768
35026
|
const reason = signal?.reason;
|
|
34769
|
-
return reason instanceof Error ? reason : new
|
|
35027
|
+
return reason instanceof Error ? reason : new WriteRequestError6("Derivative status wait was aborted");
|
|
34770
35028
|
}
|
|
34771
35029
|
function isDerivativeStatusSettled(status) {
|
|
34772
35030
|
if (status.status === "ready") return true;
|
|
@@ -34799,7 +35057,7 @@ async function getDerivativeStatus(params) {
|
|
|
34799
35057
|
}
|
|
34800
35058
|
);
|
|
34801
35059
|
} catch (err) {
|
|
34802
|
-
throw new
|
|
35060
|
+
throw new WriteTransportError2(
|
|
34803
35061
|
`Derivative status read failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
34804
35062
|
1,
|
|
34805
35063
|
err
|
|
@@ -34814,7 +35072,7 @@ async function getDerivativeStatus(params) {
|
|
|
34814
35072
|
try {
|
|
34815
35073
|
body = await response.json();
|
|
34816
35074
|
} catch (err) {
|
|
34817
|
-
throw new
|
|
35075
|
+
throw new DerivativeQuestionRejectedError2(
|
|
34818
35076
|
"Derivative status response is not JSON",
|
|
34819
35077
|
response.status,
|
|
34820
35078
|
null,
|
|
@@ -34823,7 +35081,7 @@ async function getDerivativeStatus(params) {
|
|
|
34823
35081
|
}
|
|
34824
35082
|
const parsed = DerivativeStatusSchema.safeParse(body);
|
|
34825
35083
|
if (!parsed.success) {
|
|
34826
|
-
throw new
|
|
35084
|
+
throw new DerivativeQuestionRejectedError2(
|
|
34827
35085
|
"Derivative status response is not a status view",
|
|
34828
35086
|
response.status,
|
|
34829
35087
|
null,
|
|
@@ -34857,6 +35115,11 @@ async function waitForDerivativeStatus(params) {
|
|
|
34857
35115
|
}
|
|
34858
35116
|
|
|
34859
35117
|
// src/protocol/gateway.ts
|
|
35118
|
+
import {
|
|
35119
|
+
DataPointDeletedError as DataPointDeletedError3,
|
|
35120
|
+
DataPointNotFoundError as DataPointNotFoundError2,
|
|
35121
|
+
DataPointVersionConflictError
|
|
35122
|
+
} from "./errors.js";
|
|
34860
35123
|
function withGrantPermissions(grant) {
|
|
34861
35124
|
const stripped = { ...grant };
|
|
34862
35125
|
delete stripped.permissions;
|
|
@@ -34902,7 +35165,7 @@ function createGatewayClient(baseUrl) {
|
|
|
34902
35165
|
}
|
|
34903
35166
|
async function deletedError(res, details) {
|
|
34904
35167
|
const body = await readBody(res);
|
|
34905
|
-
return new
|
|
35168
|
+
return new DataPointDeletedError3(
|
|
34906
35169
|
`Data point ${details.dataPointId ?? details.scope ?? ""} has been deleted`,
|
|
34907
35170
|
{ ...details, deletedAt: tombstoneDeletedAt(body) }
|
|
34908
35171
|
);
|
|
@@ -34975,7 +35238,7 @@ function createGatewayClient(baseUrl) {
|
|
|
34975
35238
|
}
|
|
34976
35239
|
const record = await unwrapEnvelope(res);
|
|
34977
35240
|
if (!options?.includeDeleted && isDataPointTombstone(record)) {
|
|
34978
|
-
throw new
|
|
35241
|
+
throw new DataPointDeletedError3(
|
|
34979
35242
|
`Data point ${dataPointId} has been deleted`,
|
|
34980
35243
|
{
|
|
34981
35244
|
dataPointId,
|
|
@@ -35137,7 +35400,7 @@ function createGatewayClient(baseUrl) {
|
|
|
35137
35400
|
})
|
|
35138
35401
|
});
|
|
35139
35402
|
if (res.status === 404) {
|
|
35140
|
-
throw new
|
|
35403
|
+
throw new DataPointNotFoundError2(
|
|
35141
35404
|
`Data point ${dataPointId} (scope '${params.scope}') is not registered`,
|
|
35142
35405
|
details
|
|
35143
35406
|
);
|
|
@@ -35279,6 +35542,7 @@ function createGatewayClient(baseUrl) {
|
|
|
35279
35542
|
}
|
|
35280
35543
|
|
|
35281
35544
|
// src/protocol/escrow.ts
|
|
35545
|
+
import { isHex as isHex2 } from "viem";
|
|
35282
35546
|
var GENERIC_PAYMENT_TYPES = {
|
|
35283
35547
|
GenericPayment: [
|
|
35284
35548
|
{ name: "payerAddress", type: "address" },
|
|
@@ -35318,6 +35582,26 @@ var ESCROW_DEPOSIT_ABI2 = [
|
|
|
35318
35582
|
}
|
|
35319
35583
|
];
|
|
35320
35584
|
var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
35585
|
+
var EscrowWithdrawalLifecycleError = class extends Error {
|
|
35586
|
+
constructor(httpStatus, result) {
|
|
35587
|
+
super(result.error);
|
|
35588
|
+
this.httpStatus = httpStatus;
|
|
35589
|
+
this.result = result;
|
|
35590
|
+
}
|
|
35591
|
+
httpStatus;
|
|
35592
|
+
result;
|
|
35593
|
+
name = "EscrowWithdrawalLifecycleError";
|
|
35594
|
+
};
|
|
35595
|
+
var EscrowWithdrawalRejectionError = class extends Error {
|
|
35596
|
+
constructor(httpStatus, result) {
|
|
35597
|
+
super(result.error);
|
|
35598
|
+
this.httpStatus = httpStatus;
|
|
35599
|
+
this.result = result;
|
|
35600
|
+
}
|
|
35601
|
+
httpStatus;
|
|
35602
|
+
result;
|
|
35603
|
+
name = "EscrowWithdrawalRejectionError";
|
|
35604
|
+
};
|
|
35321
35605
|
function createEscrowGatewayClient(baseUrl) {
|
|
35322
35606
|
const base = baseUrl.replace(/\/+$/, "");
|
|
35323
35607
|
async function throwOnError(res, context) {
|
|
@@ -35333,6 +35617,27 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
35333
35617
|
);
|
|
35334
35618
|
}
|
|
35335
35619
|
}
|
|
35620
|
+
async function throwOnWithdrawError(res) {
|
|
35621
|
+
if (res.ok) return;
|
|
35622
|
+
let body;
|
|
35623
|
+
try {
|
|
35624
|
+
body = await res.json();
|
|
35625
|
+
} catch {
|
|
35626
|
+
throw new Error(
|
|
35627
|
+
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
|
|
35628
|
+
);
|
|
35629
|
+
}
|
|
35630
|
+
if (isEscrowWithdrawalFailureResult(body)) {
|
|
35631
|
+
throw new EscrowWithdrawalLifecycleError(res.status, body);
|
|
35632
|
+
}
|
|
35633
|
+
if (isEscrowWithdrawalRejectedResult(body)) {
|
|
35634
|
+
throw new EscrowWithdrawalRejectionError(res.status, body);
|
|
35635
|
+
}
|
|
35636
|
+
const error = getGatewayErrorMessage(body);
|
|
35637
|
+
throw new Error(
|
|
35638
|
+
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
|
|
35639
|
+
);
|
|
35640
|
+
}
|
|
35336
35641
|
return {
|
|
35337
35642
|
async submitDeposit({ txHash }) {
|
|
35338
35643
|
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
@@ -35388,9 +35693,108 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
35388
35693
|
});
|
|
35389
35694
|
await throwOnError(res, "POST /v1/escrow/pay");
|
|
35390
35695
|
return res.json();
|
|
35696
|
+
},
|
|
35697
|
+
async withdraw({
|
|
35698
|
+
account,
|
|
35699
|
+
asset,
|
|
35700
|
+
amount,
|
|
35701
|
+
withdrawNonce,
|
|
35702
|
+
deadline,
|
|
35703
|
+
signature
|
|
35704
|
+
}) {
|
|
35705
|
+
const res = await fetch(`${base}/v1/escrow/withdraw`, {
|
|
35706
|
+
method: "POST",
|
|
35707
|
+
headers: {
|
|
35708
|
+
"Content-Type": "application/json",
|
|
35709
|
+
Authorization: `Web3Signed ${signature}`
|
|
35710
|
+
},
|
|
35711
|
+
body: JSON.stringify({
|
|
35712
|
+
account,
|
|
35713
|
+
asset,
|
|
35714
|
+
amount,
|
|
35715
|
+
withdrawNonce,
|
|
35716
|
+
deadline
|
|
35717
|
+
})
|
|
35718
|
+
});
|
|
35719
|
+
await throwOnWithdrawError(res);
|
|
35720
|
+
return res.json();
|
|
35721
|
+
},
|
|
35722
|
+
async getWithdrawNonce(account) {
|
|
35723
|
+
const res = await fetch(
|
|
35724
|
+
`${base}/v1/escrow/withdraw/nonce?account=${encodeURIComponent(account)}`,
|
|
35725
|
+
{ cache: "no-store" }
|
|
35726
|
+
);
|
|
35727
|
+
await throwOnError(res, "GET /v1/escrow/withdraw/nonce");
|
|
35728
|
+
const body = await res.json();
|
|
35729
|
+
if (!isWithdrawNonceResponse(body, account)) {
|
|
35730
|
+
throw new Error(
|
|
35731
|
+
"GET /v1/escrow/withdraw/nonce: invalid response structure"
|
|
35732
|
+
);
|
|
35733
|
+
}
|
|
35734
|
+
return body;
|
|
35391
35735
|
}
|
|
35392
35736
|
};
|
|
35393
35737
|
}
|
|
35738
|
+
function getGatewayErrorMessage(body) {
|
|
35739
|
+
if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
|
|
35740
|
+
return body.error;
|
|
35741
|
+
}
|
|
35742
|
+
return void 0;
|
|
35743
|
+
}
|
|
35744
|
+
function isEscrowWithdrawalFailureResult(body) {
|
|
35745
|
+
if (typeof body !== "object" || body === null) return false;
|
|
35746
|
+
const value = body;
|
|
35747
|
+
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));
|
|
35748
|
+
}
|
|
35749
|
+
function isEscrowWithdrawalRejectedResult(body) {
|
|
35750
|
+
if (typeof body !== "object" || body === null) return false;
|
|
35751
|
+
const value = body;
|
|
35752
|
+
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);
|
|
35753
|
+
}
|
|
35754
|
+
function isWithdrawalRejectionCode(value) {
|
|
35755
|
+
return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
|
|
35756
|
+
}
|
|
35757
|
+
function optionalUint256Decimal(value) {
|
|
35758
|
+
return value === void 0 || isUint256Decimal(value);
|
|
35759
|
+
}
|
|
35760
|
+
function isAddressHex(value) {
|
|
35761
|
+
return typeof value === "string" && isHex2(value, { strict: true }) && value.length === 42;
|
|
35762
|
+
}
|
|
35763
|
+
function isHash(value) {
|
|
35764
|
+
return typeof value === "string" && isHex2(value, { strict: true }) && value.length === 66;
|
|
35765
|
+
}
|
|
35766
|
+
function isUint256Decimal(value) {
|
|
35767
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 78) {
|
|
35768
|
+
return false;
|
|
35769
|
+
}
|
|
35770
|
+
if (!/^(0|[1-9]\d*)$/.test(value)) return false;
|
|
35771
|
+
return BigInt(value) <= 2n ** 256n - 1n;
|
|
35772
|
+
}
|
|
35773
|
+
function isBlockNumber(value) {
|
|
35774
|
+
return value === null || isUint256Decimal(value);
|
|
35775
|
+
}
|
|
35776
|
+
function isWithdrawNonceResponse(body, requestedAccount) {
|
|
35777
|
+
if (typeof body !== "object" || body === null) return false;
|
|
35778
|
+
const value = body;
|
|
35779
|
+
if (value.success !== true) return false;
|
|
35780
|
+
if (!isAddressHex(value.account)) return false;
|
|
35781
|
+
if (value.account.toLowerCase() !== requestedAccount.toLowerCase())
|
|
35782
|
+
return false;
|
|
35783
|
+
if (typeof value.chainId !== "string") return false;
|
|
35784
|
+
if (!/^(0|[1-9]\d*)$/.test(value.chainId)) return false;
|
|
35785
|
+
const isLastNull = value.lastWithdrawNonce === null;
|
|
35786
|
+
const lastNonceValid = isLastNull || isUint256Decimal(value.lastWithdrawNonce);
|
|
35787
|
+
if (!lastNonceValid) return false;
|
|
35788
|
+
if (!isUint256Decimal(value.nextWithdrawNonce)) return false;
|
|
35789
|
+
if (isLastNull) {
|
|
35790
|
+
return value.nextWithdrawNonce === "1";
|
|
35791
|
+
}
|
|
35792
|
+
const lastNonce = BigInt(value.lastWithdrawNonce);
|
|
35793
|
+
const nextNonce = BigInt(value.nextWithdrawNonce);
|
|
35794
|
+
const expectedNextNonce = lastNonce + 1n;
|
|
35795
|
+
if (expectedNextNonce > 2n ** 256n - 1n) return false;
|
|
35796
|
+
return nextNonce === expectedNextNonce;
|
|
35797
|
+
}
|
|
35394
35798
|
|
|
35395
35799
|
// src/types/ps-errors.ts
|
|
35396
35800
|
var PSError = class extends Error {
|
|
@@ -35460,15 +35864,12 @@ export {
|
|
|
35460
35864
|
AccountPersonalServerLiteOwnerBindingError,
|
|
35461
35865
|
AccountPersonalServerRegistrationError,
|
|
35462
35866
|
BUILDER_REGISTRATION_TYPES,
|
|
35463
|
-
BlockchainError,
|
|
35464
35867
|
BrowserECIESUint8Provider as BrowserECIESProvider,
|
|
35465
35868
|
BrowserPlatformAdapter,
|
|
35466
|
-
BuilderUnknownError,
|
|
35467
35869
|
CLAIM_POLL_FLOOR_MS,
|
|
35468
35870
|
CONTRACTS,
|
|
35469
35871
|
CallbackStorage,
|
|
35470
35872
|
ContractFactory,
|
|
35471
|
-
ContractNotFoundError,
|
|
35472
35873
|
DATA_REGISTRY_STATUS_ABI,
|
|
35473
35874
|
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
35474
35875
|
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
@@ -35480,21 +35881,9 @@ export {
|
|
|
35480
35881
|
DERIVATIVE_QUESTIONS_PATH,
|
|
35481
35882
|
DERIVATIVE_STATUS_PATH,
|
|
35482
35883
|
DataFileEnvelopeSchema,
|
|
35483
|
-
DataPointDeletedError,
|
|
35484
|
-
DataPointNotFoundError,
|
|
35485
35884
|
DataPointStatus,
|
|
35486
|
-
DataPointVersionConflictError,
|
|
35487
|
-
DerivativeComputeUnavailableError,
|
|
35488
|
-
DerivativeCycleError,
|
|
35489
|
-
DerivativeDerivedScopeRequiredError,
|
|
35490
35885
|
DerivativeErrorCodeSchema,
|
|
35491
|
-
DerivativeQuestionFailedError,
|
|
35492
|
-
DerivativeQuestionInvalidError,
|
|
35493
|
-
DerivativeQuestionNotFoundError,
|
|
35494
|
-
DerivativeQuestionRejectedError,
|
|
35495
35886
|
DerivativeQuestionSchema,
|
|
35496
|
-
DerivativeQuestionTimeoutError,
|
|
35497
|
-
DerivativeSourceNotGrantedError,
|
|
35498
35887
|
DerivativeStatusSchema,
|
|
35499
35888
|
DropboxStorage,
|
|
35500
35889
|
ECIESError,
|
|
@@ -35502,41 +35891,34 @@ export {
|
|
|
35502
35891
|
ENCLAVE_TRUST_ANCHORS,
|
|
35503
35892
|
ENCLAVE_WALLET_PURPOSE,
|
|
35504
35893
|
ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
|
|
35505
|
-
|
|
35894
|
+
EscrowWithdrawalLifecycleError,
|
|
35895
|
+
EscrowWithdrawalRejectionError,
|
|
35896
|
+
ExpiredTokenError2 as ExpiredTokenError,
|
|
35506
35897
|
FEE_REGISTRY_ABI,
|
|
35507
35898
|
GENERIC_PAYMENT_TYPES,
|
|
35508
35899
|
GRANT_REGISTRATION_TYPES,
|
|
35509
35900
|
GRANT_REVOCATION_TYPES,
|
|
35510
35901
|
GoogleDriveStorage,
|
|
35511
|
-
GrantInvalidError,
|
|
35512
35902
|
InMemoryTokenStore,
|
|
35513
35903
|
IngestResponseSchema,
|
|
35514
|
-
InvalidConfigurationError,
|
|
35515
35904
|
InvalidScopeEntryError,
|
|
35516
|
-
InvalidSignatureError,
|
|
35905
|
+
InvalidSignatureError2 as InvalidSignatureError,
|
|
35517
35906
|
IpfsStorage,
|
|
35518
35907
|
JOB_OPERATIONS,
|
|
35519
35908
|
JOB_PROTOCOL_VERSION,
|
|
35909
|
+
JOB_RESULT_CHUNK_BYTES,
|
|
35910
|
+
JOB_RESULT_FORMAT_VERSION,
|
|
35520
35911
|
JOB_STATES,
|
|
35521
35912
|
JobEnvelopeError,
|
|
35522
|
-
JobIdTakenError,
|
|
35523
|
-
JobNotFoundError,
|
|
35524
|
-
JobRejectedError,
|
|
35525
|
-
JobRequestTooLargeError,
|
|
35526
|
-
JobTimeoutError,
|
|
35527
|
-
JobTransportError,
|
|
35528
|
-
JobsClientError,
|
|
35529
35913
|
LINEAGE_FIELD,
|
|
35530
35914
|
LINEAGE_KEY,
|
|
35531
35915
|
LineageEntrySchema,
|
|
35532
35916
|
LineageGraphSchema,
|
|
35533
35917
|
LineageNodeSchema,
|
|
35534
|
-
LineageReadError,
|
|
35535
35918
|
MASTER_KEY_MESSAGE,
|
|
35536
35919
|
MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
|
|
35537
35920
|
MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
35538
35921
|
MAX_ATTEMPTS,
|
|
35539
|
-
MAX_INLINE_RESULT_BYTES,
|
|
35540
35922
|
MAX_JOB_DEADLINE_SECONDS,
|
|
35541
35923
|
MAX_LEASE_SECONDS,
|
|
35542
35924
|
MAX_LINEAGE_SOURCES,
|
|
@@ -35544,13 +35926,10 @@ export {
|
|
|
35544
35926
|
MAX_QUESTION_MODEL_CHARS,
|
|
35545
35927
|
MAX_QUESTION_SOURCE_SCOPES,
|
|
35546
35928
|
MAX_WAIT_SECONDS,
|
|
35547
|
-
MissingAuthError,
|
|
35929
|
+
MissingAuthError2 as MissingAuthError,
|
|
35548
35930
|
NATIVE_ASSET_ADDRESS,
|
|
35549
35931
|
NATIVE_VANA_ASSET,
|
|
35550
|
-
NetworkError,
|
|
35551
|
-
NonceError,
|
|
35552
35932
|
OAuthClient,
|
|
35553
|
-
OwnerNotReadyError,
|
|
35554
35933
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
35555
35934
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
35556
35935
|
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
@@ -35559,9 +35938,6 @@ export {
|
|
|
35559
35938
|
PKCE_CHALLENGE_PATTERN,
|
|
35560
35939
|
PKCE_VERIFIER_PATTERN,
|
|
35561
35940
|
PSError,
|
|
35562
|
-
PermissionError,
|
|
35563
|
-
PersonalServerError,
|
|
35564
|
-
PersonalServerWriteError,
|
|
35565
35941
|
PinataStorage,
|
|
35566
35942
|
QUESTION_STATUSES,
|
|
35567
35943
|
QuestionDeleteResultSchema,
|
|
@@ -35572,42 +35948,26 @@ export {
|
|
|
35572
35948
|
RECORD_DATA_ACCESS_TYPES,
|
|
35573
35949
|
REGISTRATION_KIND_FOR_OP,
|
|
35574
35950
|
RESERVED_WRITE_KEYS,
|
|
35575
|
-
ReadOnlyError,
|
|
35576
35951
|
RedactedLineageNodeSchema,
|
|
35577
|
-
RelayerError,
|
|
35578
35952
|
SCOPE_ACTIONS,
|
|
35579
35953
|
SEALED_ENVELOPE_VERSION,
|
|
35580
35954
|
SERVER_REGISTRATION_TYPES,
|
|
35581
35955
|
ScopeSchema,
|
|
35582
|
-
SerializationError,
|
|
35583
|
-
ServerUrlMismatchError,
|
|
35584
|
-
SignatureError,
|
|
35585
35956
|
StorageError,
|
|
35586
35957
|
StorageManager,
|
|
35587
35958
|
TOMBSTONE_DATA_HASH,
|
|
35588
35959
|
TOMBSTONE_DATA_HASH_PREIMAGE,
|
|
35589
35960
|
TOMBSTONE_METADATA_HASH,
|
|
35590
35961
|
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
35591
|
-
TransactionPendingError,
|
|
35592
35962
|
USER_PS_ID_DOMAIN,
|
|
35593
|
-
UserRejectedRequestError,
|
|
35594
|
-
VanaError,
|
|
35595
35963
|
VanaStorage,
|
|
35964
|
+
WITHDRAW_AUTHORIZATION_TYPES,
|
|
35596
35965
|
WRITER_ATTRIBUTION_KEY,
|
|
35597
35966
|
WRITE_CONTENT_DISPOSITION_HEADER,
|
|
35598
35967
|
WRITE_FILENAME_HEADER,
|
|
35599
35968
|
WRITE_METADATA_HEADER,
|
|
35600
35969
|
WRITE_SESSION_PATH,
|
|
35601
35970
|
WRITE_SIGNATURE_HEADER,
|
|
35602
|
-
WriteConflictError,
|
|
35603
|
-
WriteForbiddenError,
|
|
35604
|
-
WriteLineageError,
|
|
35605
|
-
WriteRejectedError,
|
|
35606
|
-
WriteRequestError,
|
|
35607
|
-
WriteSessionError,
|
|
35608
|
-
WriteSessionExpiredError,
|
|
35609
|
-
WriteTransportError,
|
|
35610
|
-
WriteUnauthorizedError,
|
|
35611
35971
|
appRootPreimage,
|
|
35612
35972
|
askPersonalServer,
|
|
35613
35973
|
assertDerivedScopeNaming,
|
|
@@ -35626,6 +35986,7 @@ export {
|
|
|
35626
35986
|
buildPersonalServerRegistrationTypedData,
|
|
35627
35987
|
buildSetDataPointStatusRequest,
|
|
35628
35988
|
buildWeb3SignedHeader,
|
|
35989
|
+
buildWithdrawAuthorizationTypedData,
|
|
35629
35990
|
builderRegistrationDomain,
|
|
35630
35991
|
canonicalJobRequestBytes,
|
|
35631
35992
|
chains,
|
|
@@ -35703,6 +36064,7 @@ export {
|
|
|
35703
36064
|
normalizeBinaryMimeType,
|
|
35704
36065
|
openJobRequest,
|
|
35705
36066
|
openJobResult,
|
|
36067
|
+
openJobResultStream,
|
|
35706
36068
|
openWriteSession,
|
|
35707
36069
|
parsePSError,
|
|
35708
36070
|
parseScope,
|
|
@@ -35725,6 +36087,7 @@ export {
|
|
|
35725
36087
|
scopeToPathSegments,
|
|
35726
36088
|
sealJobRequest,
|
|
35727
36089
|
sealJobResult,
|
|
36090
|
+
sealJobResultStream,
|
|
35728
36091
|
serializeECIES,
|
|
35729
36092
|
serverRegistrationDomain,
|
|
35730
36093
|
sessionCoversScope,
|
|
@@ -35741,6 +36104,7 @@ export {
|
|
|
35741
36104
|
verifyWeb3Signed,
|
|
35742
36105
|
waitForDerivativeStatus,
|
|
35743
36106
|
waitForQuestion,
|
|
36107
|
+
withdrawAuthorizationDomain,
|
|
35744
36108
|
writeData,
|
|
35745
36109
|
writePersonalServerData
|
|
35746
36110
|
};
|