@opendatalabs/vana-sdk 3.22.0 → 3.23.0-pr.211.1da7c1b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crypto/envelope/job.cjs +313 -0
- package/dist/crypto/envelope/job.cjs.map +1 -0
- package/dist/crypto/envelope/job.d.ts +122 -0
- package/dist/crypto/envelope/job.js +291 -0
- package/dist/crypto/envelope/job.js.map +1 -0
- package/dist/direct/access-request-client.cjs +4 -0
- package/dist/direct/access-request-client.cjs.map +1 -1
- package/dist/direct/access-request-client.js +4 -0
- package/dist/direct/access-request-client.js.map +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/types.cjs.map +1 -1
- package/dist/direct/types.d.ts +7 -0
- package/dist/direct/types.js.map +1 -1
- 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/errors.cjs +84 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +133 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.js +589 -24
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +1217 -111
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +4 -0
- package/dist/index.node.js +1181 -101
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/identity.cjs +219 -0
- package/dist/protocol/identity.cjs.map +1 -0
- package/dist/protocol/identity.d.ts +193 -0
- package/dist/protocol/identity.js +183 -0
- package/dist/protocol/identity.js.map +1 -0
- package/dist/protocol/identity.test.d.ts +1 -0
- package/dist/protocol/identity.vector.test.d.ts +1 -0
- package/dist/protocol/jobs-client.cjs +540 -0
- package/dist/protocol/jobs-client.cjs.map +1 -0
- package/dist/protocol/jobs-client.d.ts +169 -0
- package/dist/protocol/jobs-client.js +547 -0
- package/dist/protocol/jobs-client.js.map +1 -0
- package/dist/protocol/jobs-client.test.d.ts +1 -0
- package/dist/protocol/jobs.cjs +64 -0
- package/dist/protocol/jobs.cjs.map +1 -0
- package/dist/protocol/jobs.d.ts +192 -0
- package/dist/protocol/jobs.js +31 -0
- package/dist/protocol/jobs.js.map +1 -0
- package/dist/protocol/jobs.test.d.ts +1 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +7 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1180,6 +1180,8 @@ __export(index_node_exports, {
|
|
|
1180
1180
|
BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
|
|
1181
1181
|
BlockchainError: () => BlockchainError,
|
|
1182
1182
|
BrowserPlatformAdapter: () => BrowserPlatformAdapter,
|
|
1183
|
+
BuilderUnknownError: () => BuilderUnknownError,
|
|
1184
|
+
CLAIM_POLL_FLOOR_MS: () => CLAIM_POLL_FLOOR_MS,
|
|
1183
1185
|
CONTRACTS: () => CONTRACTS,
|
|
1184
1186
|
CallbackStorage: () => CallbackStorage,
|
|
1185
1187
|
ContractFactory: () => ContractFactory,
|
|
@@ -1188,6 +1190,8 @@ __export(index_node_exports, {
|
|
|
1188
1190
|
DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
|
|
1189
1191
|
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS: () => DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
1190
1192
|
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS: () => DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
1193
|
+
DEFAULT_JOB_DEADLINE_SECONDS: () => DEFAULT_JOB_DEADLINE_SECONDS,
|
|
1194
|
+
DEFAULT_LEASE_SECONDS: () => DEFAULT_LEASE_SECONDS,
|
|
1191
1195
|
DEFAULT_QUESTION_POLL_INTERVAL_MS: () => DEFAULT_QUESTION_POLL_INTERVAL_MS,
|
|
1192
1196
|
DEFAULT_QUESTION_TIMEOUT_MS: () => DEFAULT_QUESTION_TIMEOUT_MS,
|
|
1193
1197
|
DERIVATIVE_ERROR_CODES: () => DERIVATIVE_ERROR_CODES,
|
|
@@ -1212,6 +1216,9 @@ __export(index_node_exports, {
|
|
|
1212
1216
|
DerivativeStatusSchema: () => DerivativeStatusSchema,
|
|
1213
1217
|
DropboxStorage: () => DropboxStorage,
|
|
1214
1218
|
ECIESError: () => ECIESError,
|
|
1219
|
+
ENCLAVE_IDENTITY_EVIDENCE_VERSION: () => ENCLAVE_IDENTITY_EVIDENCE_VERSION,
|
|
1220
|
+
ENCLAVE_TRUST_ANCHORS: () => ENCLAVE_TRUST_ANCHORS,
|
|
1221
|
+
ENCLAVE_WALLET_PURPOSE: () => ENCLAVE_WALLET_PURPOSE,
|
|
1215
1222
|
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
|
|
1216
1223
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
1217
1224
|
FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
|
|
@@ -1220,12 +1227,25 @@ __export(index_node_exports, {
|
|
|
1220
1227
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
1221
1228
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
1222
1229
|
GoogleDriveStorage: () => GoogleDriveStorage,
|
|
1230
|
+
GrantInvalidError: () => GrantInvalidError,
|
|
1223
1231
|
InMemoryTokenStore: () => InMemoryTokenStore,
|
|
1224
1232
|
IngestResponseSchema: () => IngestResponseSchema,
|
|
1225
1233
|
InvalidConfigurationError: () => InvalidConfigurationError,
|
|
1226
1234
|
InvalidScopeEntryError: () => InvalidScopeEntryError,
|
|
1227
1235
|
InvalidSignatureError: () => InvalidSignatureError,
|
|
1228
1236
|
IpfsStorage: () => IpfsStorage,
|
|
1237
|
+
JOB_OPERATIONS: () => JOB_OPERATIONS,
|
|
1238
|
+
JOB_PROTOCOL_VERSION: () => JOB_PROTOCOL_VERSION,
|
|
1239
|
+
JOB_STATES: () => JOB_STATES,
|
|
1240
|
+
JobEnvelopeError: () => JobEnvelopeError,
|
|
1241
|
+
JobIdTakenError: () => JobIdTakenError,
|
|
1242
|
+
JobNotFoundError: () => JobNotFoundError,
|
|
1243
|
+
JobRejectedError: () => JobRejectedError,
|
|
1244
|
+
JobRequestTooLargeError: () => JobRequestTooLargeError,
|
|
1245
|
+
JobResultIntegrityError: () => JobResultIntegrityError,
|
|
1246
|
+
JobTimeoutError: () => JobTimeoutError,
|
|
1247
|
+
JobTransportError: () => JobTransportError,
|
|
1248
|
+
JobsClientError: () => JobsClientError,
|
|
1229
1249
|
LINEAGE_FIELD: () => LINEAGE_FIELD,
|
|
1230
1250
|
LINEAGE_KEY: () => LINEAGE_KEY,
|
|
1231
1251
|
LineageEntrySchema: () => LineageEntrySchema,
|
|
@@ -1233,10 +1253,16 @@ __export(index_node_exports, {
|
|
|
1233
1253
|
LineageNodeSchema: () => LineageNodeSchema,
|
|
1234
1254
|
LineageReadError: () => LineageReadError,
|
|
1235
1255
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1256
|
+
MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS: () => MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
|
|
1257
|
+
MASTER_SIGNATURE_DELIVERY_VERSION: () => MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
1258
|
+
MAX_ATTEMPTS: () => MAX_ATTEMPTS,
|
|
1259
|
+
MAX_JOB_DEADLINE_SECONDS: () => MAX_JOB_DEADLINE_SECONDS,
|
|
1260
|
+
MAX_LEASE_SECONDS: () => MAX_LEASE_SECONDS,
|
|
1236
1261
|
MAX_LINEAGE_SOURCES: () => MAX_LINEAGE_SOURCES,
|
|
1237
1262
|
MAX_QUESTION_CHARS: () => MAX_QUESTION_CHARS,
|
|
1238
1263
|
MAX_QUESTION_MODEL_CHARS: () => MAX_QUESTION_MODEL_CHARS,
|
|
1239
1264
|
MAX_QUESTION_SOURCE_SCOPES: () => MAX_QUESTION_SOURCE_SCOPES,
|
|
1265
|
+
MAX_WAIT_SECONDS: () => MAX_WAIT_SECONDS,
|
|
1240
1266
|
MissingAuthError: () => MissingAuthError,
|
|
1241
1267
|
NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
|
|
1242
1268
|
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
@@ -1245,6 +1271,7 @@ __export(index_node_exports, {
|
|
|
1245
1271
|
NodePlatformAdapter: () => NodePlatformAdapter,
|
|
1246
1272
|
NonceError: () => NonceError,
|
|
1247
1273
|
OAuthClient: () => OAuthClient,
|
|
1274
|
+
OwnerNotReadyError: () => OwnerNotReadyError,
|
|
1248
1275
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX: () => PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
1249
1276
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE: () => PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
1250
1277
|
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION: () => PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
@@ -1270,6 +1297,7 @@ __export(index_node_exports, {
|
|
|
1270
1297
|
RedactedLineageNodeSchema: () => RedactedLineageNodeSchema,
|
|
1271
1298
|
RelayerError: () => RelayerError,
|
|
1272
1299
|
SCOPE_ACTIONS: () => SCOPE_ACTIONS,
|
|
1300
|
+
SEALED_ENVELOPE_VERSION: () => SEALED_ENVELOPE_VERSION,
|
|
1273
1301
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
1274
1302
|
ScopeSchema: () => ScopeSchema,
|
|
1275
1303
|
SerializationError: () => SerializationError,
|
|
@@ -1282,6 +1310,7 @@ __export(index_node_exports, {
|
|
|
1282
1310
|
TOMBSTONE_METADATA_HASH: () => TOMBSTONE_METADATA_HASH,
|
|
1283
1311
|
TOMBSTONE_METADATA_HASH_PREIMAGE: () => TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
1284
1312
|
TransactionPendingError: () => TransactionPendingError,
|
|
1313
|
+
USER_PS_ID_DOMAIN: () => USER_PS_ID_DOMAIN,
|
|
1285
1314
|
UserRejectedRequestError: () => UserRejectedRequestError,
|
|
1286
1315
|
VanaError: () => VanaError,
|
|
1287
1316
|
VanaStorage: () => VanaStorage,
|
|
@@ -1300,6 +1329,7 @@ __export(index_node_exports, {
|
|
|
1300
1329
|
WriteSessionExpiredError: () => WriteSessionExpiredError,
|
|
1301
1330
|
WriteTransportError: () => WriteTransportError,
|
|
1302
1331
|
WriteUnauthorizedError: () => WriteUnauthorizedError,
|
|
1332
|
+
appRootPreimage: () => appRootPreimage,
|
|
1303
1333
|
askPersonalServer: () => askPersonalServer,
|
|
1304
1334
|
assertDerivedScopeNaming: () => assertDerivedScopeNaming,
|
|
1305
1335
|
assertValidPkceVerifier: () => assertValidPkceVerifier,
|
|
@@ -1313,6 +1343,7 @@ __export(index_node_exports, {
|
|
|
1313
1343
|
buildEscrowPaymentHeader: () => buildEscrowPaymentHeader,
|
|
1314
1344
|
buildGrantPaymentHeader: () => buildGrantPaymentHeader,
|
|
1315
1345
|
buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
|
|
1346
|
+
buildMasterSignatureDelivery: () => buildMasterSignatureDelivery,
|
|
1316
1347
|
buildPersonalServerDataReadRequest: () => buildPersonalServerDataReadRequest,
|
|
1317
1348
|
buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
|
|
1318
1349
|
buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
|
|
@@ -1321,6 +1352,7 @@ __export(index_node_exports, {
|
|
|
1321
1352
|
buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
|
|
1322
1353
|
buildWeb3SignedHeader: () => buildWeb3SignedHeader,
|
|
1323
1354
|
builderRegistrationDomain: () => builderRegistrationDomain,
|
|
1355
|
+
canonicalJobRequestBytes: () => canonicalJobRequestBytes,
|
|
1324
1356
|
chains: () => chains,
|
|
1325
1357
|
clearContractCache: () => clearContractCache,
|
|
1326
1358
|
computeBodyHash: () => computeBodyHash,
|
|
@@ -1332,6 +1364,7 @@ __export(index_node_exports, {
|
|
|
1332
1364
|
createDefaultNonceSource: () => createDefaultNonceSource,
|
|
1333
1365
|
createEscrowGatewayClient: () => createEscrowGatewayClient,
|
|
1334
1366
|
createGatewayClient: () => createGatewayClient,
|
|
1367
|
+
createJobsClient: () => createJobsClient,
|
|
1335
1368
|
createNodePlatformAdapter: () => createNodePlatformAdapter,
|
|
1336
1369
|
createPlatformAdapter: () => createPlatformAdapter,
|
|
1337
1370
|
createPlatformAdapterFor: () => createPlatformAdapterFor,
|
|
@@ -1356,6 +1389,7 @@ __export(index_node_exports, {
|
|
|
1356
1389
|
encodeDepositTokenData: () => encodeDepositTokenData,
|
|
1357
1390
|
encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
|
|
1358
1391
|
encodeWriteMetadataHeader: () => encodeWriteMetadataHeader,
|
|
1392
|
+
encryptMasterSignatureDelivery: () => encryptMasterSignatureDelivery,
|
|
1359
1393
|
encryptWithPassword: () => encryptWithPassword,
|
|
1360
1394
|
escrowContractAddress: () => escrowContractAddress,
|
|
1361
1395
|
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
@@ -1390,12 +1424,15 @@ __export(index_node_exports, {
|
|
|
1390
1424
|
isPlatformSupported: () => isPlatformSupported,
|
|
1391
1425
|
isRedactedLineageNode: () => isRedactedLineageNode,
|
|
1392
1426
|
isTombstoneHashes: () => isTombstoneHashes,
|
|
1427
|
+
kmsIssuedPreimage: () => kmsIssuedPreimage,
|
|
1393
1428
|
listQuestions: () => listQuestions,
|
|
1394
1429
|
mainnetServices: () => mainnetServices,
|
|
1395
1430
|
moksha: () => moksha,
|
|
1396
1431
|
mokshaServices: () => mokshaServices,
|
|
1397
1432
|
mokshaTestnet: () => mokshaTestnet2,
|
|
1398
1433
|
normalizeBinaryMimeType: () => normalizeBinaryMimeType,
|
|
1434
|
+
openJobRequest: () => openJobRequest,
|
|
1435
|
+
openJobResult: () => openJobResult,
|
|
1399
1436
|
openWriteSession: () => openWriteSession,
|
|
1400
1437
|
parsePSError: () => parsePSError,
|
|
1401
1438
|
parsePersonalServerPaymentRequired: () => parsePersonalServerPaymentRequired,
|
|
@@ -1419,6 +1456,8 @@ __export(index_node_exports, {
|
|
|
1419
1456
|
scopeMatchesPattern: () => scopeMatchesPattern,
|
|
1420
1457
|
scopeNamespace: () => scopeNamespace,
|
|
1421
1458
|
scopeToPathSegments: () => scopeToPathSegments,
|
|
1459
|
+
sealJobRequest: () => sealJobRequest,
|
|
1460
|
+
sealJobResult: () => sealJobResult,
|
|
1422
1461
|
serializeECIES: () => serializeECIES,
|
|
1423
1462
|
serverRegistrationDomain: () => serverRegistrationDomain,
|
|
1424
1463
|
sessionCoversScope: () => sessionCoversScope,
|
|
@@ -1429,7 +1468,9 @@ __export(index_node_exports, {
|
|
|
1429
1468
|
toDirectPaymentReceipt: () => toDirectPaymentReceipt,
|
|
1430
1469
|
tombstoneDeletedAt: () => tombstoneDeletedAt,
|
|
1431
1470
|
tryGrantPermissions: () => tryGrantPermissions,
|
|
1471
|
+
userPsId: () => userPsId,
|
|
1432
1472
|
vanaMainnet: () => vanaMainnet2,
|
|
1473
|
+
verifyEnclaveIdentityEvidence: () => verifyEnclaveIdentityEvidence,
|
|
1433
1474
|
verifyGrantRegistration: () => verifyGrantRegistration,
|
|
1434
1475
|
verifyPkceChallenge: () => verifyPkceChallenge,
|
|
1435
1476
|
verifyWeb3Signed: () => verifyWeb3Signed,
|
|
@@ -1640,6 +1681,68 @@ var WriteRejectedError = class extends PersonalServerWriteError {
|
|
|
1640
1681
|
super(message, "WRITE_REJECTED", status, errorCode, details);
|
|
1641
1682
|
}
|
|
1642
1683
|
};
|
|
1684
|
+
var JobsClientError = class extends VanaError {
|
|
1685
|
+
constructor(message, code, status, errorCode = null, details) {
|
|
1686
|
+
super(message, code);
|
|
1687
|
+
this.status = status;
|
|
1688
|
+
this.errorCode = errorCode;
|
|
1689
|
+
this.details = details;
|
|
1690
|
+
}
|
|
1691
|
+
status;
|
|
1692
|
+
errorCode;
|
|
1693
|
+
details;
|
|
1694
|
+
};
|
|
1695
|
+
var BuilderUnknownError = class extends JobsClientError {
|
|
1696
|
+
constructor(message, details) {
|
|
1697
|
+
super(message, "JOB_BUILDER_UNKNOWN", 403, "BUILDER_UNKNOWN", details);
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
var GrantInvalidError = class extends JobsClientError {
|
|
1701
|
+
constructor(message, details) {
|
|
1702
|
+
super(message, "JOB_GRANT_INVALID", 403, "GRANT_INVALID", details);
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
var OwnerNotReadyError = class extends JobsClientError {
|
|
1706
|
+
constructor(message, details) {
|
|
1707
|
+
super(message, "JOB_OWNER_NOT_READY", 403, "OWNER_NOT_READY", details);
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
var JobIdTakenError = class extends JobsClientError {
|
|
1711
|
+
constructor(message, details) {
|
|
1712
|
+
super(message, "JOB_ID_TAKEN", 409, "JOB_ID_TAKEN", details);
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
var JobNotFoundError = class extends JobsClientError {
|
|
1716
|
+
constructor(message, details) {
|
|
1717
|
+
super(message, "JOB_NOT_FOUND", 404, "JOB_NOT_FOUND", details);
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
var JobRequestTooLargeError = class extends JobsClientError {
|
|
1721
|
+
constructor(message, errorCode = "BODY_TOO_LARGE", details) {
|
|
1722
|
+
super(message, "JOB_REQUEST_TOO_LARGE", 413, errorCode, details);
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
var JobTimeoutError = class extends JobsClientError {
|
|
1726
|
+
constructor(message, details) {
|
|
1727
|
+
super(message, "JOB_TIMEOUT", void 0, null, details);
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
var JobResultIntegrityError = class extends JobsClientError {
|
|
1731
|
+
constructor(message, details) {
|
|
1732
|
+
super(message, "JOB_RESULT_INTEGRITY", void 0, null, details);
|
|
1733
|
+
}
|
|
1734
|
+
};
|
|
1735
|
+
var JobRejectedError = class extends JobsClientError {
|
|
1736
|
+
constructor(message, status, errorCode = null, details) {
|
|
1737
|
+
super(message, "JOB_REJECTED", status, errorCode, details);
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
var JobTransportError = class extends JobsClientError {
|
|
1741
|
+
constructor(message, cause) {
|
|
1742
|
+
super(message, "JOB_TRANSPORT_ERROR");
|
|
1743
|
+
this.cause = cause;
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1643
1746
|
var LineageReadError = class extends VanaError {
|
|
1644
1747
|
constructor(message, status, errorCode = null, details) {
|
|
1645
1748
|
super(message, "LINEAGE_READ_ERROR");
|
|
@@ -31628,13 +31731,13 @@ var NodeCryptoAdapter = class {
|
|
|
31628
31731
|
*/
|
|
31629
31732
|
async generateKeyPair() {
|
|
31630
31733
|
try {
|
|
31631
|
-
const
|
|
31734
|
+
const secp256k15 = import_secp256k12.default;
|
|
31632
31735
|
let privateKey;
|
|
31633
31736
|
do {
|
|
31634
31737
|
privateKey = (0, import_crypto2.randomBytes)(32);
|
|
31635
|
-
} while (!
|
|
31738
|
+
} while (!secp256k15.privateKeyVerify(privateKey));
|
|
31636
31739
|
const publicKey = Buffer.from(
|
|
31637
|
-
|
|
31740
|
+
secp256k15.publicKeyCreate(privateKey, true)
|
|
31638
31741
|
);
|
|
31639
31742
|
return {
|
|
31640
31743
|
privateKey: privateKey.toString("hex"),
|
|
@@ -32644,15 +32747,1017 @@ var RECORD_DATA_ACCESS_TYPES = {
|
|
|
32644
32747
|
]
|
|
32645
32748
|
};
|
|
32646
32749
|
|
|
32647
|
-
// src/protocol/
|
|
32750
|
+
// src/protocol/identity.ts
|
|
32751
|
+
var secp256k14 = __toESM(require("@noble/secp256k1"), 1);
|
|
32648
32752
|
var import_viem14 = require("viem");
|
|
32753
|
+
var import_accounts = require("viem/accounts");
|
|
32754
|
+
init_interface();
|
|
32755
|
+
var ENCLAVE_IDENTITY_EVIDENCE_VERSION = 1;
|
|
32756
|
+
var USER_PS_ID_DOMAIN = "vana.ps-enclave.v1";
|
|
32757
|
+
var ENCLAVE_WALLET_PURPOSE = "vana.ps-enclave.wallet.v1";
|
|
32758
|
+
var MASTER_SIGNATURE_DELIVERY_VERSION = "vana.ps-enclave.delivery.v1";
|
|
32759
|
+
var MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS = 600;
|
|
32760
|
+
var SEALED_ENVELOPE_VERSION = 1;
|
|
32761
|
+
var VANA_MAINNET_CHAIN_ID = 1480;
|
|
32762
|
+
var MOKSHA_CHAIN_ID = 14800;
|
|
32763
|
+
var KMS_ISSUED_PREFIX = "dstack-kms-issued";
|
|
32764
|
+
var PREIMAGE_SEPARATOR = ":";
|
|
32765
|
+
var UNCOMPRESSED_PUBLIC_KEY_BYTES = 65;
|
|
32766
|
+
var UNCOMPRESSED_PUBLIC_KEY_PREFIX = "04";
|
|
32767
|
+
var EMPTY_HEX = "0x";
|
|
32768
|
+
function emptyAnchor() {
|
|
32769
|
+
return Object.freeze({
|
|
32770
|
+
kmsRootPubkey: EMPTY_HEX,
|
|
32771
|
+
appIds: Object.freeze([])
|
|
32772
|
+
});
|
|
32773
|
+
}
|
|
32774
|
+
var ENCLAVE_TRUST_ANCHORS = Object.freeze({
|
|
32775
|
+
// filled at fleet provisioning; verify fails closed while empty
|
|
32776
|
+
[VANA_MAINNET_CHAIN_ID]: emptyAnchor(),
|
|
32777
|
+
// filled at fleet provisioning; verify fails closed while empty
|
|
32778
|
+
[MOKSHA_CHAIN_ID]: emptyAnchor()
|
|
32779
|
+
});
|
|
32780
|
+
function userPsId(chainId, ownerAddress) {
|
|
32781
|
+
const packed = (0, import_viem14.encodePacked)(
|
|
32782
|
+
["string", "uint256", "address"],
|
|
32783
|
+
[USER_PS_ID_DOMAIN, BigInt(chainId), (0, import_viem14.getAddress)(ownerAddress)]
|
|
32784
|
+
);
|
|
32785
|
+
return (0, import_viem14.keccak256)(packed);
|
|
32786
|
+
}
|
|
32787
|
+
function compressPublicKey(publicKey) {
|
|
32788
|
+
return secp256k14.ProjectivePoint.fromHex(
|
|
32789
|
+
(0, import_viem14.fromHex)(publicKey, "bytes")
|
|
32790
|
+
).toRawBytes(true);
|
|
32791
|
+
}
|
|
32792
|
+
function sameKey(a, b) {
|
|
32793
|
+
return (0, import_viem14.toHex)(compressPublicKey(a)) === (0, import_viem14.toHex)(compressPublicKey(b));
|
|
32794
|
+
}
|
|
32795
|
+
function assertUncompressedKey(publicKey) {
|
|
32796
|
+
const hex = publicKey.slice(2);
|
|
32797
|
+
if (hex.length !== UNCOMPRESSED_PUBLIC_KEY_BYTES * 2 || !hex.startsWith(UNCOMPRESSED_PUBLIC_KEY_PREFIX) || !/^[0-9a-fA-F]+$/.test(hex)) {
|
|
32798
|
+
throw new Error("Public key must be a 65-byte uncompressed secp256k1 key");
|
|
32799
|
+
}
|
|
32800
|
+
}
|
|
32801
|
+
function appRootPreimage(purpose, publicKey) {
|
|
32802
|
+
const keyHex = (0, import_viem14.toHex)(compressPublicKey(publicKey)).slice(2);
|
|
32803
|
+
return (0, import_viem14.keccak256)((0, import_viem14.toBytes)(`${purpose}${PREIMAGE_SEPARATOR}${keyHex}`));
|
|
32804
|
+
}
|
|
32805
|
+
function kmsIssuedPreimage(appId, appRootPublicKey) {
|
|
32806
|
+
const prefix = (0, import_viem14.concat)([
|
|
32807
|
+
(0, import_viem14.toBytes)(`${KMS_ISSUED_PREFIX}${PREIMAGE_SEPARATOR}`),
|
|
32808
|
+
(0, import_viem14.fromHex)(appId, "bytes")
|
|
32809
|
+
]);
|
|
32810
|
+
const compressed = compressPublicKey(appRootPublicKey);
|
|
32811
|
+
return (0, import_viem14.keccak256)((0, import_viem14.concat)([prefix, compressed]));
|
|
32812
|
+
}
|
|
32813
|
+
async function recoverChainKey(hash, signature, link) {
|
|
32814
|
+
try {
|
|
32815
|
+
return (await (0, import_viem14.recoverPublicKey)({ hash, signature })).toLowerCase();
|
|
32816
|
+
} catch {
|
|
32817
|
+
throw new Error(`Invalid enclave signature chain link ${link}`);
|
|
32818
|
+
}
|
|
32819
|
+
}
|
|
32820
|
+
async function verifyEnclaveIdentityEvidence(evidence, anchors, expected) {
|
|
32821
|
+
if (evidence.v !== ENCLAVE_IDENTITY_EVIDENCE_VERSION) {
|
|
32822
|
+
throw new Error("Unsupported enclave identity evidence version");
|
|
32823
|
+
}
|
|
32824
|
+
if (!Number.isInteger(evidence.epoch) || evidence.epoch < 1) {
|
|
32825
|
+
throw new Error("Invalid enclave identity epoch");
|
|
32826
|
+
}
|
|
32827
|
+
if (evidence.chainId !== expected.chainId) {
|
|
32828
|
+
throw new Error(
|
|
32829
|
+
"Enclave identity chain ID does not match expected chain ID"
|
|
32830
|
+
);
|
|
32831
|
+
}
|
|
32832
|
+
if (!(0, import_viem14.isAddressEqual)(evidence.ownerAddress, expected.ownerAddress)) {
|
|
32833
|
+
throw new Error("Enclave identity owner does not match expected owner");
|
|
32834
|
+
}
|
|
32835
|
+
if (evidence.epoch !== expected.epoch) {
|
|
32836
|
+
throw new Error("Enclave identity epoch does not match expected epoch");
|
|
32837
|
+
}
|
|
32838
|
+
const expectedUserPsId = userPsId(expected.chainId, expected.ownerAddress);
|
|
32839
|
+
if (evidence.userPsId.toLowerCase() !== expectedUserPsId.toLowerCase()) {
|
|
32840
|
+
throw new Error("Enclave userPsId does not match expected identity");
|
|
32841
|
+
}
|
|
32842
|
+
if (evidence.purpose !== ENCLAVE_WALLET_PURPOSE) {
|
|
32843
|
+
throw new Error("Unexpected enclave wallet purpose");
|
|
32844
|
+
}
|
|
32845
|
+
if (anchors.kmsRootPubkey === EMPTY_HEX) {
|
|
32846
|
+
throw new Error("KMS root trust anchor is not provisioned");
|
|
32847
|
+
}
|
|
32848
|
+
assertUncompressedKey(evidence.publicKey);
|
|
32849
|
+
const derivedAddress = (0, import_accounts.publicKeyToAddress)(evidence.publicKey);
|
|
32850
|
+
if ((0, import_viem14.getAddress)(derivedAddress) !== (0, import_viem14.getAddress)(evidence.address)) {
|
|
32851
|
+
throw new Error("Enclave public key does not match its address");
|
|
32852
|
+
}
|
|
32853
|
+
const appRootPublicKey = await recoverChainKey(
|
|
32854
|
+
appRootPreimage(evidence.purpose, evidence.publicKey),
|
|
32855
|
+
evidence.signatureChain[0],
|
|
32856
|
+
0
|
|
32857
|
+
);
|
|
32858
|
+
const kmsRootPublicKey = await recoverChainKey(
|
|
32859
|
+
kmsIssuedPreimage(evidence.appId, appRootPublicKey),
|
|
32860
|
+
evidence.signatureChain[1],
|
|
32861
|
+
1
|
|
32862
|
+
);
|
|
32863
|
+
let matchesAnchor;
|
|
32864
|
+
try {
|
|
32865
|
+
matchesAnchor = sameKey(kmsRootPublicKey, anchors.kmsRootPubkey);
|
|
32866
|
+
} catch {
|
|
32867
|
+
throw new Error("KMS root trust anchor is malformed");
|
|
32868
|
+
}
|
|
32869
|
+
if (!matchesAnchor) {
|
|
32870
|
+
throw new Error("KMS root public key does not match the trust anchor");
|
|
32871
|
+
}
|
|
32872
|
+
if ((0, import_viem14.keccak256)(kmsRootPublicKey) !== evidence.kmsRootFingerprint.toLowerCase()) {
|
|
32873
|
+
throw new Error("KMS root fingerprint does not match the evidence");
|
|
32874
|
+
}
|
|
32875
|
+
const appId = evidence.appId.toLowerCase();
|
|
32876
|
+
if (!anchors.appIds.some((allowedAppId) => allowedAppId.toLowerCase() === appId)) {
|
|
32877
|
+
throw new Error("Enclave app ID is not trusted");
|
|
32878
|
+
}
|
|
32879
|
+
}
|
|
32880
|
+
async function buildMasterSignatureDelivery(evidence, masterSignature, now = Math.floor(Date.now() / 1e3)) {
|
|
32881
|
+
deriveMasterKey(masterSignature);
|
|
32882
|
+
const signerAddress = await recoverServerOwner(masterSignature);
|
|
32883
|
+
if (!(0, import_viem14.isAddressEqual)(signerAddress, evidence.ownerAddress)) {
|
|
32884
|
+
throw new Error("Master signature signer does not match evidence owner");
|
|
32885
|
+
}
|
|
32886
|
+
return {
|
|
32887
|
+
v: MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
32888
|
+
userPsId: evidence.userPsId,
|
|
32889
|
+
epoch: evidence.epoch,
|
|
32890
|
+
enclaveAddress: evidence.address,
|
|
32891
|
+
ownerAddress: evidence.ownerAddress,
|
|
32892
|
+
masterSignature,
|
|
32893
|
+
issuedAt: now
|
|
32894
|
+
};
|
|
32895
|
+
}
|
|
32896
|
+
async function encryptMasterSignatureDelivery(delivery, publicKey, ecies) {
|
|
32897
|
+
assertUncompressedKey(publicKey);
|
|
32898
|
+
if (!(0, import_viem14.isAddressEqual)((0, import_accounts.publicKeyToAddress)(publicKey), delivery.enclaveAddress)) {
|
|
32899
|
+
throw new Error(
|
|
32900
|
+
"Public key does not belong to the delivery's enclave address"
|
|
32901
|
+
);
|
|
32902
|
+
}
|
|
32903
|
+
const plaintext = (0, import_viem14.toBytes)(JSON.stringify(delivery));
|
|
32904
|
+
const encrypted = await ecies.encrypt((0, import_viem14.fromHex)(publicKey, "bytes"), plaintext);
|
|
32905
|
+
return `0x${serializeECIES(encrypted)}`;
|
|
32906
|
+
}
|
|
32907
|
+
|
|
32908
|
+
// src/protocol/jobs.ts
|
|
32909
|
+
var JOB_PROTOCOL_VERSION = 1;
|
|
32910
|
+
var JOB_OPERATIONS = ["raw_read", "inference"];
|
|
32911
|
+
var JOB_STATES = [
|
|
32912
|
+
"queued",
|
|
32913
|
+
"claimed",
|
|
32914
|
+
"running",
|
|
32915
|
+
"completed",
|
|
32916
|
+
"failed",
|
|
32917
|
+
"expired",
|
|
32918
|
+
"cancelled"
|
|
32919
|
+
];
|
|
32920
|
+
var DEFAULT_LEASE_SECONDS = 30;
|
|
32921
|
+
var MAX_LEASE_SECONDS = 300;
|
|
32922
|
+
var MAX_ATTEMPTS = 3;
|
|
32923
|
+
var MAX_WAIT_SECONDS = 25;
|
|
32924
|
+
var CLAIM_POLL_FLOOR_MS = 1e3;
|
|
32925
|
+
var DEFAULT_JOB_DEADLINE_SECONDS = 600;
|
|
32926
|
+
var MAX_JOB_DEADLINE_SECONDS = 3600;
|
|
32927
|
+
|
|
32928
|
+
// src/protocol/jobs-client.ts
|
|
32929
|
+
var import_node_crypto = require("node:crypto");
|
|
32930
|
+
var import_sha26 = require("@noble/hashes/sha2");
|
|
32931
|
+
var import_viem16 = require("viem");
|
|
32932
|
+
var import_accounts2 = require("viem/accounts");
|
|
32933
|
+
|
|
32934
|
+
// src/crypto/envelope/job.ts
|
|
32935
|
+
var import_sha25 = require("@noble/hashes/sha2");
|
|
32936
|
+
var import_viem15 = require("viem");
|
|
32937
|
+
init_constants();
|
|
32938
|
+
init_interface();
|
|
32939
|
+
var textDecoder = new TextDecoder();
|
|
32940
|
+
var textEncoder = new TextEncoder();
|
|
32941
|
+
var JobEnvelopeError = class extends Error {
|
|
32942
|
+
constructor(message) {
|
|
32943
|
+
super(message);
|
|
32944
|
+
this.name = "JobEnvelopeError";
|
|
32945
|
+
}
|
|
32946
|
+
};
|
|
32947
|
+
function sortJsonKeys(value) {
|
|
32948
|
+
if (Array.isArray(value)) {
|
|
32949
|
+
return value.map(sortJsonKeys);
|
|
32950
|
+
}
|
|
32951
|
+
if (value !== null && typeof value === "object") {
|
|
32952
|
+
return Object.fromEntries(
|
|
32953
|
+
Object.keys(value).sort().map((key) => [
|
|
32954
|
+
key,
|
|
32955
|
+
sortJsonKeys(value[key])
|
|
32956
|
+
])
|
|
32957
|
+
);
|
|
32958
|
+
}
|
|
32959
|
+
return value;
|
|
32960
|
+
}
|
|
32961
|
+
function canonicalJsonBytes(value) {
|
|
32962
|
+
return textEncoder.encode(JSON.stringify(sortJsonKeys(value)));
|
|
32963
|
+
}
|
|
32964
|
+
function canonicalJobRequestBytes(request) {
|
|
32965
|
+
validateJobRequest(request);
|
|
32966
|
+
return canonicalJsonBytes(request);
|
|
32967
|
+
}
|
|
32968
|
+
function requestPlaintext(envelope) {
|
|
32969
|
+
validateRequestEnvelope(envelope);
|
|
32970
|
+
return canonicalJsonBytes(envelope);
|
|
32971
|
+
}
|
|
32972
|
+
function resultPlaintext(result) {
|
|
32973
|
+
return textEncoder.encode(
|
|
32974
|
+
JSON.stringify({
|
|
32975
|
+
v: result.v,
|
|
32976
|
+
jobId: result.jobId,
|
|
32977
|
+
scope: result.scope,
|
|
32978
|
+
version: result.version,
|
|
32979
|
+
contentType: result.contentType,
|
|
32980
|
+
body: result.body
|
|
32981
|
+
})
|
|
32982
|
+
);
|
|
32983
|
+
}
|
|
32984
|
+
function encryptedBytesToBase64(encrypted) {
|
|
32985
|
+
return toBase64((0, import_viem15.fromHex)(`0x${serializeECIES(encrypted)}`, "bytes"));
|
|
32986
|
+
}
|
|
32987
|
+
function encryptedToBytes(encrypted) {
|
|
32988
|
+
const bytes = new Uint8Array(
|
|
32989
|
+
encrypted.iv.length + encrypted.ephemPublicKey.length + encrypted.ciphertext.length + encrypted.mac.length
|
|
32990
|
+
);
|
|
32991
|
+
let offset = 0;
|
|
32992
|
+
bytes.set(encrypted.iv, offset);
|
|
32993
|
+
offset += encrypted.iv.length;
|
|
32994
|
+
bytes.set(encrypted.ephemPublicKey, offset);
|
|
32995
|
+
offset += encrypted.ephemPublicKey.length;
|
|
32996
|
+
bytes.set(encrypted.ciphertext, offset);
|
|
32997
|
+
offset += encrypted.ciphertext.length;
|
|
32998
|
+
bytes.set(encrypted.mac, offset);
|
|
32999
|
+
return bytes;
|
|
33000
|
+
}
|
|
33001
|
+
function bytesToEncrypted(bytes) {
|
|
33002
|
+
const absoluteMinLength = FORMAT.IV_LENGTH + 1 + MAC.LENGTH + 1;
|
|
33003
|
+
if (bytes.length < absoluteMinLength) {
|
|
33004
|
+
throw new ECIESError(
|
|
33005
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${absoluteMinLength} bytes required)`,
|
|
33006
|
+
"DECRYPTION_FAILED"
|
|
33007
|
+
);
|
|
33008
|
+
}
|
|
33009
|
+
const prefix = bytes[FORMAT.EPHEMERAL_KEY_OFFSET];
|
|
33010
|
+
if (prefix !== CURVE.PREFIX.UNCOMPRESSED) {
|
|
33011
|
+
throw new ECIESError(
|
|
33012
|
+
`Invalid ephemeral public key: must be uncompressed format (0x04 prefix), got 0x${prefix.toString(16).padStart(2, "0")}`,
|
|
33013
|
+
"DECRYPTION_FAILED"
|
|
33014
|
+
);
|
|
33015
|
+
}
|
|
33016
|
+
const ephemKeySize = CURVE.UNCOMPRESSED_PUBLIC_KEY_LENGTH;
|
|
33017
|
+
const minLength = FORMAT.IV_LENGTH + ephemKeySize + MAC.LENGTH + 1;
|
|
33018
|
+
if (bytes.length < minLength) {
|
|
33019
|
+
throw new ECIESError(
|
|
33020
|
+
`Invalid ECIES data: too short (${bytes.length} bytes, minimum ${minLength} bytes required)`,
|
|
33021
|
+
"DECRYPTION_FAILED"
|
|
33022
|
+
);
|
|
33023
|
+
}
|
|
33024
|
+
return {
|
|
33025
|
+
iv: bytes.subarray(FORMAT.IV_OFFSET, FORMAT.IV_OFFSET + FORMAT.IV_LENGTH),
|
|
33026
|
+
ephemPublicKey: bytes.subarray(
|
|
33027
|
+
FORMAT.EPHEMERAL_KEY_OFFSET,
|
|
33028
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize
|
|
33029
|
+
),
|
|
33030
|
+
ciphertext: bytes.subarray(
|
|
33031
|
+
FORMAT.EPHEMERAL_KEY_OFFSET + ephemKeySize,
|
|
33032
|
+
bytes.length - MAC.LENGTH
|
|
33033
|
+
),
|
|
33034
|
+
mac: bytes.subarray(bytes.length - MAC.LENGTH)
|
|
33035
|
+
};
|
|
33036
|
+
}
|
|
33037
|
+
function base64ToEncrypted(ciphertext) {
|
|
33038
|
+
return deserializeECIES((0, import_viem15.toHex)(fromBase64(ciphertext)));
|
|
33039
|
+
}
|
|
33040
|
+
function parseObject(plaintext, kind) {
|
|
33041
|
+
try {
|
|
33042
|
+
const value = JSON.parse(textDecoder.decode(plaintext));
|
|
33043
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
33044
|
+
throw new JobEnvelopeError(`Invalid ${kind}: expected an object`);
|
|
33045
|
+
}
|
|
33046
|
+
return value;
|
|
33047
|
+
} catch (error) {
|
|
33048
|
+
if (error instanceof JobEnvelopeError) throw error;
|
|
33049
|
+
throw new JobEnvelopeError(`Invalid ${kind}: malformed JSON`);
|
|
33050
|
+
}
|
|
33051
|
+
}
|
|
33052
|
+
function isPlainObject2(value) {
|
|
33053
|
+
if (value === null || typeof value !== "object") return false;
|
|
33054
|
+
const prototype = Object.getPrototypeOf(value);
|
|
33055
|
+
return prototype === Object.prototype || prototype === null;
|
|
33056
|
+
}
|
|
33057
|
+
function requirePlainObject(value, field, kind) {
|
|
33058
|
+
if (!isPlainObject2(value)) {
|
|
33059
|
+
throw new JobEnvelopeError(`Invalid ${kind}: invalid ${field}`);
|
|
33060
|
+
}
|
|
33061
|
+
}
|
|
33062
|
+
function requireExactKeys(value, expectedKeys, kind) {
|
|
33063
|
+
for (const key of expectedKeys) {
|
|
33064
|
+
if (!Object.hasOwn(value, key) || value[key] === void 0) {
|
|
33065
|
+
throw new JobEnvelopeError(`Invalid ${kind}: missing ${key}`);
|
|
33066
|
+
}
|
|
33067
|
+
}
|
|
33068
|
+
const expected = new Set(expectedKeys);
|
|
33069
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
33070
|
+
if (!expected.has(key)) {
|
|
33071
|
+
throw new JobEnvelopeError(
|
|
33072
|
+
`Invalid ${kind}: unknown field ${String(key)}`
|
|
33073
|
+
);
|
|
33074
|
+
}
|
|
33075
|
+
}
|
|
33076
|
+
}
|
|
33077
|
+
function requireString(value, field, kind) {
|
|
33078
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
33079
|
+
throw new JobEnvelopeError(`Invalid ${kind}: missing ${field}`);
|
|
33080
|
+
}
|
|
33081
|
+
}
|
|
33082
|
+
function validateJobRequest(value) {
|
|
33083
|
+
requirePlainObject(value, "request", "job request");
|
|
33084
|
+
requireExactKeys(
|
|
33085
|
+
value,
|
|
33086
|
+
[
|
|
33087
|
+
"v",
|
|
33088
|
+
"jobId",
|
|
33089
|
+
"owner",
|
|
33090
|
+
"builder",
|
|
33091
|
+
"builderPublicKey",
|
|
33092
|
+
"grantId",
|
|
33093
|
+
"scope",
|
|
33094
|
+
"operation",
|
|
33095
|
+
"pinnedVersion",
|
|
33096
|
+
"deadline"
|
|
33097
|
+
],
|
|
33098
|
+
"job request"
|
|
33099
|
+
);
|
|
33100
|
+
if (value.v !== JOB_PROTOCOL_VERSION) {
|
|
33101
|
+
throw new JobEnvelopeError(
|
|
33102
|
+
`Unsupported job request version: ${String(value.v)}`
|
|
33103
|
+
);
|
|
33104
|
+
}
|
|
33105
|
+
requireString(value.jobId, "jobId", "job request");
|
|
33106
|
+
if (typeof value.owner !== "string" || !(0, import_viem15.isAddress)(value.owner)) {
|
|
33107
|
+
throw new JobEnvelopeError("Invalid job request: invalid owner");
|
|
33108
|
+
}
|
|
33109
|
+
if (typeof value.builder !== "string" || !(0, import_viem15.isAddress)(value.builder)) {
|
|
33110
|
+
throw new JobEnvelopeError("Invalid job request: invalid builder");
|
|
33111
|
+
}
|
|
33112
|
+
if (typeof value.builderPublicKey !== "string" || !(0, import_viem15.isHex)(value.builderPublicKey)) {
|
|
33113
|
+
throw new JobEnvelopeError("Invalid job request: invalid builderPublicKey");
|
|
33114
|
+
}
|
|
33115
|
+
if (typeof value.grantId !== "string" || !(0, import_viem15.isHex)(value.grantId)) {
|
|
33116
|
+
throw new JobEnvelopeError("Invalid job request: invalid grantId");
|
|
33117
|
+
}
|
|
33118
|
+
requireString(value.scope, "scope", "job request");
|
|
33119
|
+
if (!JOB_OPERATIONS.includes(value.operation)) {
|
|
33120
|
+
throw new JobEnvelopeError("Invalid job request: invalid operation");
|
|
33121
|
+
}
|
|
33122
|
+
if (value.pinnedVersion !== null && typeof value.pinnedVersion !== "string") {
|
|
33123
|
+
throw new JobEnvelopeError("Invalid job request: missing pinnedVersion");
|
|
33124
|
+
}
|
|
33125
|
+
if (typeof value.deadline !== "string" || !Number.isFinite(Date.parse(value.deadline))) {
|
|
33126
|
+
throw new JobEnvelopeError("Invalid job request: invalid deadline");
|
|
33127
|
+
}
|
|
33128
|
+
return value;
|
|
33129
|
+
}
|
|
33130
|
+
function validateRequestEnvelope(value) {
|
|
33131
|
+
requirePlainObject(value, "envelope", "job request envelope");
|
|
33132
|
+
requireExactKeys(value, ["request", "auth"], "job request envelope");
|
|
33133
|
+
validateJobRequest(value.request);
|
|
33134
|
+
requireString(value.auth, "auth", "job request envelope");
|
|
33135
|
+
return value;
|
|
33136
|
+
}
|
|
33137
|
+
function validateResult(value) {
|
|
33138
|
+
requirePlainObject(value, "result", "job result");
|
|
33139
|
+
requireExactKeys(
|
|
33140
|
+
value,
|
|
33141
|
+
["v", "jobId", "scope", "version", "contentType", "body"],
|
|
33142
|
+
"job result"
|
|
33143
|
+
);
|
|
33144
|
+
if (value.v !== JOB_PROTOCOL_VERSION) {
|
|
33145
|
+
throw new JobEnvelopeError(
|
|
33146
|
+
`Unsupported job result version: ${String(value.v)}`
|
|
33147
|
+
);
|
|
33148
|
+
}
|
|
33149
|
+
for (const field of ["jobId", "scope", "contentType"]) {
|
|
33150
|
+
requireString(value[field], field, "job result");
|
|
33151
|
+
}
|
|
33152
|
+
if (typeof value.body !== "string") {
|
|
33153
|
+
throw new JobEnvelopeError("Invalid job result: missing body");
|
|
33154
|
+
}
|
|
33155
|
+
if (value.version !== null && typeof value.version !== "string") {
|
|
33156
|
+
throw new JobEnvelopeError("Invalid job result: missing version");
|
|
33157
|
+
}
|
|
33158
|
+
return value;
|
|
33159
|
+
}
|
|
33160
|
+
async function sealJobRequest(envelope, enclavePublicKey, ecies) {
|
|
33161
|
+
const encrypted = await ecies.encrypt(
|
|
33162
|
+
(0, import_viem15.fromHex)(enclavePublicKey, "bytes"),
|
|
33163
|
+
requestPlaintext(envelope)
|
|
33164
|
+
);
|
|
33165
|
+
return encryptedBytesToBase64(encrypted);
|
|
33166
|
+
}
|
|
33167
|
+
async function openJobRequest(ciphertext, privateKey, ecies) {
|
|
33168
|
+
const plaintext = await ecies.decrypt(
|
|
33169
|
+
privateKey,
|
|
33170
|
+
base64ToEncrypted(ciphertext)
|
|
33171
|
+
);
|
|
33172
|
+
return validateRequestEnvelope(
|
|
33173
|
+
parseObject(plaintext, "job request envelope")
|
|
33174
|
+
);
|
|
33175
|
+
}
|
|
33176
|
+
async function sealJobResult(result, builderPublicKey, ecies) {
|
|
33177
|
+
validateResult(result);
|
|
33178
|
+
const encrypted = await ecies.encrypt(
|
|
33179
|
+
(0, import_viem15.fromHex)(builderPublicKey, "bytes"),
|
|
33180
|
+
resultPlaintext(result)
|
|
33181
|
+
);
|
|
33182
|
+
const bytes = encryptedToBytes(encrypted);
|
|
33183
|
+
return { bytes, hash: (0, import_viem15.bytesToHex)((0, import_sha25.sha256)(bytes)), size: bytes.length };
|
|
33184
|
+
}
|
|
33185
|
+
async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
|
|
33186
|
+
const plaintext = await ecies.decrypt(
|
|
33187
|
+
(0, import_viem15.fromHex)(builderPrivateKey, "bytes"),
|
|
33188
|
+
bytesToEncrypted(sealedBytes)
|
|
33189
|
+
);
|
|
33190
|
+
const result = validateResult(parseObject(plaintext, "job result"));
|
|
33191
|
+
if (result.jobId !== expect.jobId) {
|
|
33192
|
+
throw new JobEnvelopeError(
|
|
33193
|
+
`Job result ID ${result.jobId} does not match expected job ID ${expect.jobId}`
|
|
33194
|
+
);
|
|
33195
|
+
}
|
|
33196
|
+
if (expect.scope !== void 0 && result.scope !== expect.scope) {
|
|
33197
|
+
throw new JobEnvelopeError(
|
|
33198
|
+
`Job result scope ${result.scope} does not match expected scope ${expect.scope}`
|
|
33199
|
+
);
|
|
33200
|
+
}
|
|
33201
|
+
if (expect.version !== void 0 && result.version !== expect.version) {
|
|
33202
|
+
throw new JobEnvelopeError(
|
|
33203
|
+
`Job result version ${String(result.version)} does not match expected version ${String(expect.version)}`
|
|
33204
|
+
);
|
|
33205
|
+
}
|
|
33206
|
+
return result;
|
|
33207
|
+
}
|
|
33208
|
+
|
|
33209
|
+
// src/protocol/write-signer.ts
|
|
33210
|
+
function isRecord(value) {
|
|
33211
|
+
return value !== null && typeof value === "object";
|
|
33212
|
+
}
|
|
33213
|
+
function isViemWriteAccount(source) {
|
|
33214
|
+
return isRecord(source) && source.type === "local" && typeof source.address === "string" && typeof source.signMessage === "function";
|
|
33215
|
+
}
|
|
33216
|
+
function isViemWriteWalletClient(source) {
|
|
33217
|
+
return isRecord(source) && typeof source.signMessage === "function" && source.type !== "local" && (source.type === "walletClient" || "transport" in source);
|
|
33218
|
+
}
|
|
33219
|
+
function accountAddress(account) {
|
|
33220
|
+
return typeof account === "string" ? account : account.address;
|
|
33221
|
+
}
|
|
33222
|
+
function resolveWriteSigner(source, options = {}) {
|
|
33223
|
+
if (isViemWriteWalletClient(source)) {
|
|
33224
|
+
const account = options.account ?? source.account;
|
|
33225
|
+
if (account === void 0) {
|
|
33226
|
+
throw new WriteRequestError(
|
|
33227
|
+
"Viem wallet client requires an account option or account property"
|
|
33228
|
+
);
|
|
33229
|
+
}
|
|
33230
|
+
return {
|
|
33231
|
+
address: accountAddress(account),
|
|
33232
|
+
signMessage: (message) => source.signMessage({ account, message })
|
|
33233
|
+
};
|
|
33234
|
+
}
|
|
33235
|
+
if (isViemWriteAccount(source)) {
|
|
33236
|
+
return {
|
|
33237
|
+
address: source.address,
|
|
33238
|
+
signMessage: (message) => source.signMessage({ message })
|
|
33239
|
+
};
|
|
33240
|
+
}
|
|
33241
|
+
if (!isRecord(source) || typeof source.signMessage !== "function") {
|
|
33242
|
+
throw new WriteRequestError(
|
|
33243
|
+
"signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
|
|
33244
|
+
);
|
|
33245
|
+
}
|
|
33246
|
+
return source;
|
|
33247
|
+
}
|
|
33248
|
+
|
|
33249
|
+
// src/protocol/jobs-client.ts
|
|
33250
|
+
var IDENTITY_PATH = "/v1/identity";
|
|
33251
|
+
var JOBS_PATH = "/v1/jobs";
|
|
33252
|
+
var JOB_EXECUTE_PATH = "/v1/jobs/execute";
|
|
33253
|
+
var AUTHORIZATION_HEADER = "Authorization";
|
|
33254
|
+
var CONTENT_TYPE_HEADER = "Content-Type";
|
|
33255
|
+
var JSON_CONTENT_TYPE = "application/json";
|
|
33256
|
+
var GET_METHOD = "GET";
|
|
33257
|
+
var POST_METHOD = "POST";
|
|
33258
|
+
var RAW_READ_OPERATION = "raw_read";
|
|
33259
|
+
var SEALED_IDENTITY_STATE = "sealed";
|
|
33260
|
+
var HTTP_OK = 200;
|
|
33261
|
+
var HTTP_ACCEPTED = 202;
|
|
33262
|
+
var HTTP_UNAUTHORIZED = 401;
|
|
33263
|
+
var HTTP_FORBIDDEN = 403;
|
|
33264
|
+
var HTTP_NOT_FOUND = 404;
|
|
33265
|
+
var HTTP_CONFLICT = 409;
|
|
33266
|
+
var HTTP_PAYLOAD_TOO_LARGE = 413;
|
|
33267
|
+
var MILLISECONDS_PER_SECOND = 1e3;
|
|
33268
|
+
var DEFAULT_JOB_TIMEOUT_MS = 12e4;
|
|
33269
|
+
var DEFAULT_JOB_POLL_MS = CLAIM_POLL_FLOOR_MS;
|
|
33270
|
+
var TERMINAL_JOB_STATES = /* @__PURE__ */ new Set([
|
|
33271
|
+
"completed",
|
|
33272
|
+
"failed",
|
|
33273
|
+
"expired",
|
|
33274
|
+
"cancelled"
|
|
33275
|
+
]);
|
|
33276
|
+
function isRecord2(value) {
|
|
33277
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
33278
|
+
}
|
|
33279
|
+
function normalizeGateway(gatewayUrl) {
|
|
33280
|
+
try {
|
|
33281
|
+
const url = new URL(gatewayUrl);
|
|
33282
|
+
if (url.pathname !== "/" || url.search !== "" || url.hash !== "") {
|
|
33283
|
+
throw new JobRejectedError(
|
|
33284
|
+
"gatewayUrl must be an origin without a path, query, or fragment"
|
|
33285
|
+
);
|
|
33286
|
+
}
|
|
33287
|
+
return {
|
|
33288
|
+
baseUrl: url.origin,
|
|
33289
|
+
audience: url.origin
|
|
33290
|
+
};
|
|
33291
|
+
} catch (error) {
|
|
33292
|
+
if (error instanceof JobRejectedError) throw error;
|
|
33293
|
+
throw new JobRejectedError(
|
|
33294
|
+
"gatewayUrl must be an absolute URL",
|
|
33295
|
+
void 0,
|
|
33296
|
+
null,
|
|
33297
|
+
{
|
|
33298
|
+
cause: error instanceof Error ? error.message : String(error)
|
|
33299
|
+
}
|
|
33300
|
+
);
|
|
33301
|
+
}
|
|
33302
|
+
}
|
|
33303
|
+
function resolveFetch(fetchFn) {
|
|
33304
|
+
const resolved = fetchFn ?? globalThis.fetch;
|
|
33305
|
+
if (resolved === void 0) {
|
|
33306
|
+
throw new JobRejectedError("No fetch implementation available");
|
|
33307
|
+
}
|
|
33308
|
+
return resolved;
|
|
33309
|
+
}
|
|
33310
|
+
function sourcePublicKey(source) {
|
|
33311
|
+
if (isRecord2(source) && typeof source["publicKey"] === "string") {
|
|
33312
|
+
return source["publicKey"];
|
|
33313
|
+
}
|
|
33314
|
+
return void 0;
|
|
33315
|
+
}
|
|
33316
|
+
function resolveBuilder(options) {
|
|
33317
|
+
if (options.builderPrivateKey && options.builderAccount) {
|
|
33318
|
+
throw new JobRejectedError(
|
|
33319
|
+
"Provide builderPrivateKey or builderAccount, not both"
|
|
33320
|
+
);
|
|
33321
|
+
}
|
|
33322
|
+
let source;
|
|
33323
|
+
try {
|
|
33324
|
+
source = options.builderPrivateKey ? (0, import_accounts2.privateKeyToAccount)(options.builderPrivateKey) : options.builderAccount;
|
|
33325
|
+
} catch (error) {
|
|
33326
|
+
throw new JobRejectedError("Invalid builder private key", void 0, null, {
|
|
33327
|
+
cause: error instanceof Error ? error.message : String(error)
|
|
33328
|
+
});
|
|
33329
|
+
}
|
|
33330
|
+
if (!source) {
|
|
33331
|
+
throw new JobRejectedError(
|
|
33332
|
+
"builderPrivateKey or builderAccount is required"
|
|
33333
|
+
);
|
|
33334
|
+
}
|
|
33335
|
+
let signer;
|
|
33336
|
+
try {
|
|
33337
|
+
signer = resolveWriteSigner(source);
|
|
33338
|
+
} catch (error) {
|
|
33339
|
+
throw new JobRejectedError("Invalid builder signer", void 0, null, {
|
|
33340
|
+
cause: error instanceof Error ? error.message : String(error)
|
|
33341
|
+
});
|
|
33342
|
+
}
|
|
33343
|
+
const publicKey = sourcePublicKey(source);
|
|
33344
|
+
if (!signer.address || !publicKey) {
|
|
33345
|
+
throw new JobRejectedError(
|
|
33346
|
+
"Builder signer must expose both address and publicKey"
|
|
33347
|
+
);
|
|
33348
|
+
}
|
|
33349
|
+
return {
|
|
33350
|
+
builder: {
|
|
33351
|
+
address: signer.address,
|
|
33352
|
+
publicKey,
|
|
33353
|
+
signMessage: signer.signMessage
|
|
33354
|
+
},
|
|
33355
|
+
...options.builderPrivateKey ? { privateKey: options.builderPrivateKey } : {}
|
|
33356
|
+
};
|
|
33357
|
+
}
|
|
33358
|
+
function clampInteger(value, fallback, minimum, maximum, field) {
|
|
33359
|
+
const resolved = value ?? fallback;
|
|
33360
|
+
if (!Number.isFinite(resolved)) {
|
|
33361
|
+
throw new JobRejectedError(`${field} must be a finite number`);
|
|
33362
|
+
}
|
|
33363
|
+
return Math.min(maximum, Math.max(minimum, Math.trunc(resolved)));
|
|
33364
|
+
}
|
|
33365
|
+
async function responseBody(response) {
|
|
33366
|
+
try {
|
|
33367
|
+
return await response.json();
|
|
33368
|
+
} catch {
|
|
33369
|
+
return null;
|
|
33370
|
+
}
|
|
33371
|
+
}
|
|
33372
|
+
function gatewayErrorBody(body, fallback) {
|
|
33373
|
+
if (!isRecord2(body)) return { code: null, message: fallback };
|
|
33374
|
+
const code = typeof body["code"] === "string" ? body["code"] : null;
|
|
33375
|
+
const message = typeof body["error"] === "string" ? body["error"] : typeof body["message"] === "string" ? body["message"] : fallback;
|
|
33376
|
+
const reason = typeof body["reason"] === "string" ? body["reason"] : void 0;
|
|
33377
|
+
const details = isRecord2(body["details"]) ? body["details"] : void 0;
|
|
33378
|
+
return {
|
|
33379
|
+
code,
|
|
33380
|
+
message,
|
|
33381
|
+
...reason ? { reason } : {},
|
|
33382
|
+
...details ? { details } : {}
|
|
33383
|
+
};
|
|
33384
|
+
}
|
|
33385
|
+
async function rejectedResponse(response, fallback) {
|
|
33386
|
+
const parsed = gatewayErrorBody(await responseBody(response), fallback);
|
|
33387
|
+
const details = response.status === HTTP_UNAUTHORIZED && parsed.reason ? { ...parsed.details, reason: parsed.reason } : parsed.details;
|
|
33388
|
+
const message = response.status === HTTP_UNAUTHORIZED && parsed.reason ? `${parsed.message}: ${parsed.reason}` : parsed.message;
|
|
33389
|
+
if (response.status === HTTP_FORBIDDEN) {
|
|
33390
|
+
if (parsed.code === "BUILDER_UNKNOWN") {
|
|
33391
|
+
return new BuilderUnknownError(parsed.message, details);
|
|
33392
|
+
}
|
|
33393
|
+
if (parsed.code === "GRANT_INVALID") {
|
|
33394
|
+
return new GrantInvalidError(parsed.message, details);
|
|
33395
|
+
}
|
|
33396
|
+
if (parsed.code === "OWNER_NOT_READY") {
|
|
33397
|
+
return new OwnerNotReadyError(parsed.message, details);
|
|
33398
|
+
}
|
|
33399
|
+
}
|
|
33400
|
+
if (response.status === HTTP_NOT_FOUND) {
|
|
33401
|
+
return new JobNotFoundError(parsed.message, details);
|
|
33402
|
+
}
|
|
33403
|
+
if (response.status === HTTP_CONFLICT && parsed.code === "JOB_ID_TAKEN") {
|
|
33404
|
+
return new JobIdTakenError(parsed.message, details);
|
|
33405
|
+
}
|
|
33406
|
+
if (response.status === HTTP_PAYLOAD_TOO_LARGE) {
|
|
33407
|
+
return new JobRequestTooLargeError(parsed.message, parsed.code, details);
|
|
33408
|
+
}
|
|
33409
|
+
return new JobRejectedError(message, response.status, parsed.code, details);
|
|
33410
|
+
}
|
|
33411
|
+
function requireStatus(value, status) {
|
|
33412
|
+
if (!isRecord2(value) || !isNonEmptyString(value["jobId"]) || typeof value["state"] !== "string" || !JOB_STATES.includes(value["state"]) || !isNonEmptyString(value["owner"]) || !isNonEmptyString(value["grantId"]) || !isNonEmptyString(value["scope"]) || !isNonEmptyString(value["operation"]) || !JOB_OPERATIONS.includes(value["operation"])) {
|
|
33413
|
+
throw new JobRejectedError(
|
|
33414
|
+
"Gateway response did not contain a job status",
|
|
33415
|
+
status
|
|
33416
|
+
);
|
|
33417
|
+
}
|
|
33418
|
+
return value;
|
|
33419
|
+
}
|
|
33420
|
+
function isNonEmptyString(value) {
|
|
33421
|
+
return typeof value === "string" && value.length > 0;
|
|
33422
|
+
}
|
|
33423
|
+
function hasMatchingIdentityKey(value) {
|
|
33424
|
+
const address = value["address"];
|
|
33425
|
+
const publicKey = value["publicKey"];
|
|
33426
|
+
if (typeof address !== "string" || !(0, import_viem16.isAddress)(address) || typeof publicKey !== "string" || !(0, import_viem16.isHex)(publicKey)) {
|
|
33427
|
+
return false;
|
|
33428
|
+
}
|
|
33429
|
+
try {
|
|
33430
|
+
return (0, import_accounts2.publicKeyToAddress)(publicKey).toLowerCase() === address.toLowerCase();
|
|
33431
|
+
} catch {
|
|
33432
|
+
return false;
|
|
33433
|
+
}
|
|
33434
|
+
}
|
|
33435
|
+
function hasExpectedIdentity(value, owner, chainId) {
|
|
33436
|
+
const identityOwner = value["ownerAddress"];
|
|
33437
|
+
const identityChainId = value["chainId"];
|
|
33438
|
+
const identityUserPsId = value["userPsId"];
|
|
33439
|
+
if (!hasMatchingIdentityKey(value) || typeof identityOwner !== "string" || !(0, import_viem16.isAddress)(identityOwner) || typeof identityChainId !== "number" || typeof identityUserPsId !== "string" || !(0, import_viem16.isHex)(identityUserPsId)) {
|
|
33440
|
+
return false;
|
|
33441
|
+
}
|
|
33442
|
+
return (0, import_viem16.isAddressEqual)(identityOwner, owner) && identityChainId === chainId && identityUserPsId.toLowerCase() === userPsId(chainId, owner).toLowerCase();
|
|
33443
|
+
}
|
|
33444
|
+
function sleep2(ms) {
|
|
33445
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
33446
|
+
}
|
|
33447
|
+
function requireFiniteDuration(value, field) {
|
|
33448
|
+
if (!Number.isFinite(value)) {
|
|
33449
|
+
throw new JobRejectedError(`${field} must be a finite number`);
|
|
33450
|
+
}
|
|
33451
|
+
return Math.max(0, value);
|
|
33452
|
+
}
|
|
33453
|
+
function createJobsClient(options) {
|
|
33454
|
+
const { baseUrl, audience } = normalizeGateway(options.gatewayUrl);
|
|
33455
|
+
const fetchFn = resolveFetch(options.fetch);
|
|
33456
|
+
const { builder, privateKey } = resolveBuilder(options);
|
|
33457
|
+
const ecies = options.ecies ?? new NodeECIESUint8Provider();
|
|
33458
|
+
const now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
33459
|
+
async function request(url, init, description) {
|
|
33460
|
+
try {
|
|
33461
|
+
return await fetchFn(url, init);
|
|
33462
|
+
} catch (error) {
|
|
33463
|
+
throw new JobTransportError(
|
|
33464
|
+
`${description} failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
33465
|
+
error
|
|
33466
|
+
);
|
|
33467
|
+
}
|
|
33468
|
+
}
|
|
33469
|
+
async function getIdentity(owner) {
|
|
33470
|
+
const query = new URLSearchParams({
|
|
33471
|
+
owner,
|
|
33472
|
+
chainId: String(options.chainId)
|
|
33473
|
+
});
|
|
33474
|
+
const response = await request(
|
|
33475
|
+
`${baseUrl}${IDENTITY_PATH}?${query.toString()}`,
|
|
33476
|
+
{ method: GET_METHOD },
|
|
33477
|
+
"Owner identity lookup"
|
|
33478
|
+
);
|
|
33479
|
+
if (response.status === HTTP_NOT_FOUND) {
|
|
33480
|
+
const parsed = gatewayErrorBody(
|
|
33481
|
+
await responseBody(response),
|
|
33482
|
+
"Owner identity not found"
|
|
33483
|
+
);
|
|
33484
|
+
throw new OwnerNotReadyError(parsed.message, parsed.details);
|
|
33485
|
+
}
|
|
33486
|
+
if (!response.ok) {
|
|
33487
|
+
throw await rejectedResponse(response, "Owner identity lookup rejected");
|
|
33488
|
+
}
|
|
33489
|
+
const body = await responseBody(response);
|
|
33490
|
+
if (!isRecord2(body) || body["state"] !== SEALED_IDENTITY_STATE || !isRecord2(body["identity"])) {
|
|
33491
|
+
throw new OwnerNotReadyError("Owner identity is not sealed", {
|
|
33492
|
+
state: isRecord2(body) ? body["state"] : void 0
|
|
33493
|
+
});
|
|
33494
|
+
}
|
|
33495
|
+
if (!hasExpectedIdentity(body["identity"], owner, options.chainId)) {
|
|
33496
|
+
throw new JobRejectedError(
|
|
33497
|
+
"Gateway returned a malformed or mismatched owner identity",
|
|
33498
|
+
response.status
|
|
33499
|
+
);
|
|
33500
|
+
}
|
|
33501
|
+
return body["identity"];
|
|
33502
|
+
}
|
|
33503
|
+
const client = {
|
|
33504
|
+
async submitRawRead(params) {
|
|
33505
|
+
const identity = await getIdentity(params.owner);
|
|
33506
|
+
const deadlineSeconds = clampInteger(
|
|
33507
|
+
params.deadlineSeconds,
|
|
33508
|
+
DEFAULT_JOB_DEADLINE_SECONDS,
|
|
33509
|
+
1,
|
|
33510
|
+
MAX_JOB_DEADLINE_SECONDS,
|
|
33511
|
+
"deadlineSeconds"
|
|
33512
|
+
);
|
|
33513
|
+
const wait = clampInteger(params.wait, 0, 0, MAX_WAIT_SECONDS, "wait");
|
|
33514
|
+
const jobId = (0, import_node_crypto.randomUUID)();
|
|
33515
|
+
const nowMs = now().getTime();
|
|
33516
|
+
if (!Number.isFinite(nowMs)) {
|
|
33517
|
+
throw new JobRejectedError("now must return a valid Date");
|
|
33518
|
+
}
|
|
33519
|
+
const deadline = new Date(
|
|
33520
|
+
nowMs + deadlineSeconds * MILLISECONDS_PER_SECOND
|
|
33521
|
+
).toISOString();
|
|
33522
|
+
const requestBody = {
|
|
33523
|
+
v: JOB_PROTOCOL_VERSION,
|
|
33524
|
+
jobId,
|
|
33525
|
+
owner: params.owner,
|
|
33526
|
+
builder: builder.address,
|
|
33527
|
+
builderPublicKey: builder.publicKey,
|
|
33528
|
+
grantId: params.grantId,
|
|
33529
|
+
scope: params.scope,
|
|
33530
|
+
operation: RAW_READ_OPERATION,
|
|
33531
|
+
pinnedVersion: params.pinnedVersion ?? null,
|
|
33532
|
+
deadline
|
|
33533
|
+
};
|
|
33534
|
+
const auth = await buildWeb3SignedHeader({
|
|
33535
|
+
signMessage: builder.signMessage,
|
|
33536
|
+
aud: audience,
|
|
33537
|
+
method: POST_METHOD,
|
|
33538
|
+
uri: JOB_EXECUTE_PATH,
|
|
33539
|
+
bodyHash: computeBodyHash(canonicalJobRequestBytes(requestBody)),
|
|
33540
|
+
nonce: (0, import_node_crypto.randomUUID)()
|
|
33541
|
+
});
|
|
33542
|
+
const requestCiphertext = await sealJobRequest(
|
|
33543
|
+
{ request: requestBody, auth },
|
|
33544
|
+
identity.publicKey,
|
|
33545
|
+
ecies
|
|
33546
|
+
);
|
|
33547
|
+
const submission = {
|
|
33548
|
+
owner: requestBody.owner,
|
|
33549
|
+
grantId: requestBody.grantId,
|
|
33550
|
+
scope: requestBody.scope,
|
|
33551
|
+
operation: requestBody.operation,
|
|
33552
|
+
idempotencyKey: (0, import_node_crypto.randomUUID)(),
|
|
33553
|
+
jobId,
|
|
33554
|
+
deadline,
|
|
33555
|
+
requestCiphertext
|
|
33556
|
+
};
|
|
33557
|
+
const bodyBytes = new TextEncoder().encode(JSON.stringify(submission));
|
|
33558
|
+
const authorization = await buildWeb3SignedHeader({
|
|
33559
|
+
signMessage: builder.signMessage,
|
|
33560
|
+
aud: audience,
|
|
33561
|
+
method: POST_METHOD,
|
|
33562
|
+
uri: JOBS_PATH,
|
|
33563
|
+
body: bodyBytes,
|
|
33564
|
+
nonce: (0, import_node_crypto.randomUUID)()
|
|
33565
|
+
});
|
|
33566
|
+
const response = await request(
|
|
33567
|
+
`${baseUrl}${JOBS_PATH}?wait=${wait}`,
|
|
33568
|
+
{
|
|
33569
|
+
method: POST_METHOD,
|
|
33570
|
+
headers: {
|
|
33571
|
+
[AUTHORIZATION_HEADER]: authorization,
|
|
33572
|
+
[CONTENT_TYPE_HEADER]: JSON_CONTENT_TYPE
|
|
33573
|
+
},
|
|
33574
|
+
body: bodyBytes
|
|
33575
|
+
},
|
|
33576
|
+
"Job submission"
|
|
33577
|
+
);
|
|
33578
|
+
if (!response.ok) {
|
|
33579
|
+
throw await rejectedResponse(response, "Job submission rejected");
|
|
33580
|
+
}
|
|
33581
|
+
const body = await responseBody(response);
|
|
33582
|
+
if (response.status === HTTP_OK && isRecord2(body)) {
|
|
33583
|
+
const job = requireStatus(body["job"], response.status);
|
|
33584
|
+
if (job.jobId !== jobId) {
|
|
33585
|
+
throw new JobRejectedError(
|
|
33586
|
+
"Gateway returned a job id that does not match the submission",
|
|
33587
|
+
response.status
|
|
33588
|
+
);
|
|
33589
|
+
}
|
|
33590
|
+
return { jobId, state: job.state, job };
|
|
33591
|
+
}
|
|
33592
|
+
if (response.status === HTTP_ACCEPTED && isRecord2(body) && body["jobId"] === jobId && typeof body["state"] === "string" && JOB_STATES.includes(body["state"])) {
|
|
33593
|
+
return { jobId, state: body["state"] };
|
|
33594
|
+
}
|
|
33595
|
+
throw new JobRejectedError(
|
|
33596
|
+
"Gateway returned an undocumented job submission response",
|
|
33597
|
+
response.status
|
|
33598
|
+
);
|
|
33599
|
+
},
|
|
33600
|
+
async getJob(jobId) {
|
|
33601
|
+
const path = `${JOBS_PATH}/${encodeURIComponent(jobId)}`;
|
|
33602
|
+
const authorization = await buildWeb3SignedHeader({
|
|
33603
|
+
signMessage: builder.signMessage,
|
|
33604
|
+
aud: audience,
|
|
33605
|
+
method: GET_METHOD,
|
|
33606
|
+
uri: path,
|
|
33607
|
+
nonce: (0, import_node_crypto.randomUUID)()
|
|
33608
|
+
});
|
|
33609
|
+
const response = await request(
|
|
33610
|
+
`${baseUrl}${path}`,
|
|
33611
|
+
{
|
|
33612
|
+
method: GET_METHOD,
|
|
33613
|
+
headers: { [AUTHORIZATION_HEADER]: authorization }
|
|
33614
|
+
},
|
|
33615
|
+
"Job status read"
|
|
33616
|
+
);
|
|
33617
|
+
if (!response.ok) {
|
|
33618
|
+
throw await rejectedResponse(response, "Job status read rejected");
|
|
33619
|
+
}
|
|
33620
|
+
const body = await responseBody(response);
|
|
33621
|
+
return requireStatus(
|
|
33622
|
+
isRecord2(body) ? body["job"] : void 0,
|
|
33623
|
+
response.status
|
|
33624
|
+
);
|
|
33625
|
+
},
|
|
33626
|
+
async waitForJob(jobId, waitOptions = {}) {
|
|
33627
|
+
const timeoutMs = requireFiniteDuration(
|
|
33628
|
+
waitOptions.timeoutMs ?? DEFAULT_JOB_TIMEOUT_MS,
|
|
33629
|
+
"timeoutMs"
|
|
33630
|
+
);
|
|
33631
|
+
const pollMs = Math.max(
|
|
33632
|
+
CLAIM_POLL_FLOOR_MS,
|
|
33633
|
+
requireFiniteDuration(
|
|
33634
|
+
waitOptions.pollMs ?? DEFAULT_JOB_POLL_MS,
|
|
33635
|
+
"pollMs"
|
|
33636
|
+
)
|
|
33637
|
+
);
|
|
33638
|
+
const startedAt = Date.now();
|
|
33639
|
+
const callerDeadline = startedAt + timeoutMs;
|
|
33640
|
+
let latest;
|
|
33641
|
+
for (; ; ) {
|
|
33642
|
+
if (Date.now() >= callerDeadline) {
|
|
33643
|
+
throw new JobTimeoutError(
|
|
33644
|
+
`Timed out waiting for terminal job ${jobId}`,
|
|
33645
|
+
{
|
|
33646
|
+
jobId,
|
|
33647
|
+
timeoutMs,
|
|
33648
|
+
state: latest?.state
|
|
33649
|
+
}
|
|
33650
|
+
);
|
|
33651
|
+
}
|
|
33652
|
+
latest = await client.getJob(jobId);
|
|
33653
|
+
if (TERMINAL_JOB_STATES.has(latest.state)) return latest;
|
|
33654
|
+
const remaining = callerDeadline - Date.now();
|
|
33655
|
+
if (remaining <= 0) {
|
|
33656
|
+
throw new JobTimeoutError(
|
|
33657
|
+
`Timed out waiting for terminal job ${jobId}`,
|
|
33658
|
+
{
|
|
33659
|
+
jobId,
|
|
33660
|
+
timeoutMs,
|
|
33661
|
+
state: latest.state
|
|
33662
|
+
}
|
|
33663
|
+
);
|
|
33664
|
+
}
|
|
33665
|
+
await sleep2(Math.min(pollMs, remaining));
|
|
33666
|
+
}
|
|
33667
|
+
},
|
|
33668
|
+
async openResult(handle, openOptions) {
|
|
33669
|
+
if (!privateKey) {
|
|
33670
|
+
throw new JobRejectedError(
|
|
33671
|
+
"openResult requires createJobsClient({ builderPrivateKey })"
|
|
33672
|
+
);
|
|
33673
|
+
}
|
|
33674
|
+
const response = await request(
|
|
33675
|
+
handle.url,
|
|
33676
|
+
{ method: GET_METHOD },
|
|
33677
|
+
"Job result fetch"
|
|
33678
|
+
);
|
|
33679
|
+
if (!response.ok) {
|
|
33680
|
+
throw await rejectedResponse(response, "Job result fetch rejected");
|
|
33681
|
+
}
|
|
33682
|
+
let bytes;
|
|
33683
|
+
try {
|
|
33684
|
+
bytes = new Uint8Array(await response.arrayBuffer());
|
|
33685
|
+
} catch (error) {
|
|
33686
|
+
throw new JobTransportError(
|
|
33687
|
+
`Job result fetch failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
33688
|
+
error
|
|
33689
|
+
);
|
|
33690
|
+
}
|
|
33691
|
+
const actualHash = (0, import_viem16.bytesToHex)((0, import_sha26.sha256)(bytes));
|
|
33692
|
+
if (actualHash.toLowerCase() !== handle.hash.toLowerCase()) {
|
|
33693
|
+
throw new JobResultIntegrityError(
|
|
33694
|
+
"Fetched job result hash does not match its handle",
|
|
33695
|
+
{
|
|
33696
|
+
objectKey: handle.objectKey,
|
|
33697
|
+
expectedHash: handle.hash,
|
|
33698
|
+
actualHash
|
|
33699
|
+
}
|
|
33700
|
+
);
|
|
33701
|
+
}
|
|
33702
|
+
if (bytes.length !== handle.size) {
|
|
33703
|
+
throw new JobResultIntegrityError(
|
|
33704
|
+
"Fetched job result size does not match its handle",
|
|
33705
|
+
{
|
|
33706
|
+
objectKey: handle.objectKey,
|
|
33707
|
+
expectedSize: handle.size,
|
|
33708
|
+
actualSize: bytes.length
|
|
33709
|
+
}
|
|
33710
|
+
);
|
|
33711
|
+
}
|
|
33712
|
+
return openJobResult(bytes, privateKey, ecies, openOptions.expect);
|
|
33713
|
+
},
|
|
33714
|
+
async readRaw(params) {
|
|
33715
|
+
const submitted = await client.submitRawRead(params);
|
|
33716
|
+
const job = submitted.job && TERMINAL_JOB_STATES.has(submitted.job.state) ? submitted.job : await client.waitForJob(submitted.jobId, {
|
|
33717
|
+
timeoutMs: params.timeoutMs,
|
|
33718
|
+
pollMs: params.pollMs
|
|
33719
|
+
});
|
|
33720
|
+
if (job.state !== "completed") {
|
|
33721
|
+
throw new JobRejectedError(
|
|
33722
|
+
`Job ${job.jobId} ended in state ${job.state}${job.failureReason ? `: ${job.failureReason}` : ""}`,
|
|
33723
|
+
void 0,
|
|
33724
|
+
null,
|
|
33725
|
+
{
|
|
33726
|
+
jobId: job.jobId,
|
|
33727
|
+
state: job.state,
|
|
33728
|
+
...job.failureReason ? { failureReason: job.failureReason } : {}
|
|
33729
|
+
}
|
|
33730
|
+
);
|
|
33731
|
+
}
|
|
33732
|
+
if (!job.result) {
|
|
33733
|
+
throw new JobRejectedError(
|
|
33734
|
+
"Completed job status does not include a result handle",
|
|
33735
|
+
void 0,
|
|
33736
|
+
null,
|
|
33737
|
+
{ jobId: job.jobId, state: job.state }
|
|
33738
|
+
);
|
|
33739
|
+
}
|
|
33740
|
+
return client.openResult(job.result, {
|
|
33741
|
+
expect: {
|
|
33742
|
+
jobId: submitted.jobId,
|
|
33743
|
+
scope: params.scope,
|
|
33744
|
+
...params.pinnedVersion !== void 0 && params.pinnedVersion !== null ? { version: params.pinnedVersion } : {}
|
|
33745
|
+
}
|
|
33746
|
+
});
|
|
33747
|
+
}
|
|
33748
|
+
};
|
|
33749
|
+
return client;
|
|
33750
|
+
}
|
|
33751
|
+
|
|
33752
|
+
// src/protocol/personal-server-registration.ts
|
|
33753
|
+
var import_viem17 = require("viem");
|
|
32649
33754
|
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
|
|
32650
33755
|
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
|
|
32651
33756
|
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32652
33757
|
"DataPortabilityServers"
|
|
32653
33758
|
);
|
|
32654
33759
|
function assertAddress(value, name) {
|
|
32655
|
-
if (!(0,
|
|
33760
|
+
if (!(0, import_viem17.isAddress)(value)) {
|
|
32656
33761
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32657
33762
|
}
|
|
32658
33763
|
}
|
|
@@ -32738,12 +33843,12 @@ async function buildPersonalServerRegistrationSignature(input) {
|
|
|
32738
33843
|
var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
32739
33844
|
|
|
32740
33845
|
// src/personal-server-lite/owner-binding.ts
|
|
32741
|
-
var
|
|
33846
|
+
var import_viem18 = require("viem");
|
|
32742
33847
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
32743
33848
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
32744
33849
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
32745
33850
|
function assertAddress2(value, name) {
|
|
32746
|
-
if (!(0,
|
|
33851
|
+
if (!(0, import_viem18.isAddress)(value)) {
|
|
32747
33852
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32748
33853
|
}
|
|
32749
33854
|
}
|
|
@@ -32793,7 +33898,7 @@ async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
|
32793
33898
|
var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
32794
33899
|
|
|
32795
33900
|
// src/account/personal-server-registration.ts
|
|
32796
|
-
var
|
|
33901
|
+
var import_viem19 = require("viem");
|
|
32797
33902
|
var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
|
|
32798
33903
|
var AccountPersonalServerRegistrationError = class extends Error {
|
|
32799
33904
|
status;
|
|
@@ -32812,7 +33917,7 @@ function trimTrailingSlash(value) {
|
|
|
32812
33917
|
return value.replace(/\/+$/, "");
|
|
32813
33918
|
}
|
|
32814
33919
|
function assertAddress3(value, name) {
|
|
32815
|
-
if (!(0,
|
|
33920
|
+
if (!(0, import_viem19.isAddress)(value)) {
|
|
32816
33921
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32817
33922
|
}
|
|
32818
33923
|
}
|
|
@@ -32833,7 +33938,7 @@ function accountErrorMessage(status, body) {
|
|
|
32833
33938
|
if (nestedMessage) {
|
|
32834
33939
|
return nestedMessage;
|
|
32835
33940
|
}
|
|
32836
|
-
if (
|
|
33941
|
+
if (isRecord3(body) && typeof body.message === "string") {
|
|
32837
33942
|
return body.message;
|
|
32838
33943
|
}
|
|
32839
33944
|
const code = accountErrorCode(body);
|
|
@@ -32847,7 +33952,7 @@ function accountErrorCode(body) {
|
|
|
32847
33952
|
if (nestedCode) {
|
|
32848
33953
|
return nestedCode;
|
|
32849
33954
|
}
|
|
32850
|
-
if (
|
|
33955
|
+
if (isRecord3(body)) {
|
|
32851
33956
|
if (typeof body.code === "string") {
|
|
32852
33957
|
return body.code;
|
|
32853
33958
|
}
|
|
@@ -32858,13 +33963,13 @@ function accountErrorCode(body) {
|
|
|
32858
33963
|
return void 0;
|
|
32859
33964
|
}
|
|
32860
33965
|
function nestedAccountErrorField(body, field) {
|
|
32861
|
-
if (!
|
|
33966
|
+
if (!isRecord3(body) || !isRecord3(body.error)) {
|
|
32862
33967
|
return void 0;
|
|
32863
33968
|
}
|
|
32864
33969
|
const value = body.error[field];
|
|
32865
33970
|
return typeof value === "string" ? value : void 0;
|
|
32866
33971
|
}
|
|
32867
|
-
function
|
|
33972
|
+
function isRecord3(value) {
|
|
32868
33973
|
return typeof value === "object" && value !== null;
|
|
32869
33974
|
}
|
|
32870
33975
|
function normalizeAccountResponse(response) {
|
|
@@ -33076,7 +34181,7 @@ function accountOwnerBindingError(error) {
|
|
|
33076
34181
|
}
|
|
33077
34182
|
|
|
33078
34183
|
// src/protocol/grants.ts
|
|
33079
|
-
var
|
|
34184
|
+
var import_viem20 = require("viem");
|
|
33080
34185
|
function isHexString(value) {
|
|
33081
34186
|
return typeof value === "string" && value.startsWith("0x");
|
|
33082
34187
|
}
|
|
@@ -33121,7 +34226,7 @@ async function verifyGrantRegistration(input) {
|
|
|
33121
34226
|
}
|
|
33122
34227
|
let valid;
|
|
33123
34228
|
try {
|
|
33124
|
-
valid = await (0,
|
|
34229
|
+
valid = await (0, import_viem20.verifyTypedData)({
|
|
33125
34230
|
address: input.grantorAddress,
|
|
33126
34231
|
domain: grantRegistrationDomain(input.gatewayConfig),
|
|
33127
34232
|
types: GRANT_REGISTRATION_TYPES,
|
|
@@ -33156,8 +34261,8 @@ async function verifyGrantRegistration(input) {
|
|
|
33156
34261
|
}
|
|
33157
34262
|
|
|
33158
34263
|
// src/protocol/fee-registry.ts
|
|
33159
|
-
var
|
|
33160
|
-
var FEE_REGISTRY_ABI = (0,
|
|
34264
|
+
var import_viem21 = require("viem");
|
|
34265
|
+
var FEE_REGISTRY_ABI = (0, import_viem21.parseAbi)([
|
|
33161
34266
|
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
33162
34267
|
"function fees(bytes32 operation) view returns (Fee)",
|
|
33163
34268
|
"function operationKey(string name) pure returns (bytes32)"
|
|
@@ -33240,7 +34345,7 @@ async function getOpFee(client, config, opType, opts) {
|
|
|
33240
34345
|
}
|
|
33241
34346
|
|
|
33242
34347
|
// src/protocol/escrow-deposit.ts
|
|
33243
|
-
var
|
|
34348
|
+
var import_viem22 = require("viem");
|
|
33244
34349
|
var ESCROW_DEPOSIT_ABI = [
|
|
33245
34350
|
{
|
|
33246
34351
|
type: "function",
|
|
@@ -33265,14 +34370,14 @@ function escrowContractAddress(config) {
|
|
|
33265
34370
|
return config.contracts.dataPortabilityEscrow;
|
|
33266
34371
|
}
|
|
33267
34372
|
function encodeDepositNativeData(input) {
|
|
33268
|
-
return (0,
|
|
34373
|
+
return (0, import_viem22.encodeFunctionData)({
|
|
33269
34374
|
abi: ESCROW_DEPOSIT_ABI,
|
|
33270
34375
|
functionName: "depositNative",
|
|
33271
34376
|
args: [input.account]
|
|
33272
34377
|
});
|
|
33273
34378
|
}
|
|
33274
34379
|
function encodeDepositTokenData(input) {
|
|
33275
|
-
return (0,
|
|
34380
|
+
return (0, import_viem22.encodeFunctionData)({
|
|
33276
34381
|
abi: ESCROW_DEPOSIT_ABI,
|
|
33277
34382
|
functionName: "depositToken",
|
|
33278
34383
|
args: [input.account, input.token, input.amount]
|
|
@@ -33293,7 +34398,7 @@ function buildDepositTokenRequest(config, input) {
|
|
|
33293
34398
|
}
|
|
33294
34399
|
|
|
33295
34400
|
// src/protocol/data-point-status.ts
|
|
33296
|
-
var
|
|
34401
|
+
var import_viem23 = require("viem");
|
|
33297
34402
|
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
33298
34403
|
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
33299
34404
|
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
@@ -33317,7 +34422,7 @@ function dataRegistryContractAddress(config) {
|
|
|
33317
34422
|
return config.contracts.dataRegistry;
|
|
33318
34423
|
}
|
|
33319
34424
|
function encodeSetDataPointStatusData(input) {
|
|
33320
|
-
return (0,
|
|
34425
|
+
return (0, import_viem23.encodeFunctionData)({
|
|
33321
34426
|
abi: DATA_REGISTRY_STATUS_ABI,
|
|
33322
34427
|
functionName: "setStatus",
|
|
33323
34428
|
args: [input.scope, input.status]
|
|
@@ -33337,14 +34442,14 @@ function buildMarkDataPointUnavailableRequest(config, input) {
|
|
|
33337
34442
|
}
|
|
33338
34443
|
|
|
33339
34444
|
// src/protocol/data-point-deletion.ts
|
|
33340
|
-
var
|
|
34445
|
+
var import_viem25 = require("viem");
|
|
33341
34446
|
|
|
33342
34447
|
// src/protocol/lineage.ts
|
|
33343
|
-
var
|
|
34448
|
+
var import_viem24 = require("viem");
|
|
33344
34449
|
var import_zod = require("zod");
|
|
33345
34450
|
|
|
33346
34451
|
// src/protocol/personal-server-error-body.ts
|
|
33347
|
-
function
|
|
34452
|
+
function isRecord4(value) {
|
|
33348
34453
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
33349
34454
|
}
|
|
33350
34455
|
async function readPersonalServerErrorBody(response) {
|
|
@@ -33354,8 +34459,8 @@ async function readPersonalServerErrorBody(response) {
|
|
|
33354
34459
|
} catch {
|
|
33355
34460
|
return { errorCode: null, message: null };
|
|
33356
34461
|
}
|
|
33357
|
-
if (!
|
|
33358
|
-
const nested =
|
|
34462
|
+
if (!isRecord4(body)) return { errorCode: null, message: null };
|
|
34463
|
+
const nested = isRecord4(body.error) ? body.error : null;
|
|
33359
34464
|
const gatewayShape = typeof body.error === "string" && typeof body.code === "string";
|
|
33360
34465
|
const code = nested?.errorCode ?? nested?.code ?? body.errorCode ?? (gatewayShape ? body.code : void 0) ?? (typeof body.error === "string" ? body.error : void 0) ?? body.code;
|
|
33361
34466
|
const message = nested?.message ?? body.message ?? (gatewayShape ? body.error : void 0);
|
|
@@ -33368,63 +34473,23 @@ async function readPersonalServerErrorBody(response) {
|
|
|
33368
34473
|
return {
|
|
33369
34474
|
errorCode: typeof code === "string" ? code : null,
|
|
33370
34475
|
message: typeof message === "string" ? message : null,
|
|
33371
|
-
...
|
|
34476
|
+
...isRecord4(details) ? { details } : {}
|
|
33372
34477
|
};
|
|
33373
34478
|
}
|
|
33374
34479
|
|
|
33375
|
-
// src/protocol/write-signer.ts
|
|
33376
|
-
function isRecord3(value) {
|
|
33377
|
-
return value !== null && typeof value === "object";
|
|
33378
|
-
}
|
|
33379
|
-
function isViemWriteAccount(source) {
|
|
33380
|
-
return isRecord3(source) && source.type === "local" && typeof source.address === "string" && typeof source.signMessage === "function";
|
|
33381
|
-
}
|
|
33382
|
-
function isViemWriteWalletClient(source) {
|
|
33383
|
-
return isRecord3(source) && typeof source.signMessage === "function" && source.type !== "local" && (source.type === "walletClient" || "transport" in source);
|
|
33384
|
-
}
|
|
33385
|
-
function accountAddress(account) {
|
|
33386
|
-
return typeof account === "string" ? account : account.address;
|
|
33387
|
-
}
|
|
33388
|
-
function resolveWriteSigner(source, options = {}) {
|
|
33389
|
-
if (isViemWriteWalletClient(source)) {
|
|
33390
|
-
const account = options.account ?? source.account;
|
|
33391
|
-
if (account === void 0) {
|
|
33392
|
-
throw new WriteRequestError(
|
|
33393
|
-
"Viem wallet client requires an account option or account property"
|
|
33394
|
-
);
|
|
33395
|
-
}
|
|
33396
|
-
return {
|
|
33397
|
-
address: accountAddress(account),
|
|
33398
|
-
signMessage: (message) => source.signMessage({ account, message })
|
|
33399
|
-
};
|
|
33400
|
-
}
|
|
33401
|
-
if (isViemWriteAccount(source)) {
|
|
33402
|
-
return {
|
|
33403
|
-
address: source.address,
|
|
33404
|
-
signMessage: (message) => source.signMessage({ message })
|
|
33405
|
-
};
|
|
33406
|
-
}
|
|
33407
|
-
if (!isRecord3(source) || typeof source.signMessage !== "function") {
|
|
33408
|
-
throw new WriteRequestError(
|
|
33409
|
-
"signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
|
|
33410
|
-
);
|
|
33411
|
-
}
|
|
33412
|
-
return source;
|
|
33413
|
-
}
|
|
33414
|
-
|
|
33415
34480
|
// src/protocol/lineage.ts
|
|
33416
34481
|
var DATA_POINT_ID_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
33417
34482
|
function isDataPointId(value) {
|
|
33418
34483
|
return typeof value === "string" && DATA_POINT_ID_PATTERN.test(value);
|
|
33419
34484
|
}
|
|
33420
34485
|
function deriveDataPointId(ownerAddress, scope) {
|
|
33421
|
-
if (!(0,
|
|
34486
|
+
if (!(0, import_viem24.isAddress)(ownerAddress, { strict: false })) {
|
|
33422
34487
|
throw new Error(
|
|
33423
34488
|
`ownerAddress is not an EVM address: ${String(ownerAddress)}`
|
|
33424
34489
|
);
|
|
33425
34490
|
}
|
|
33426
|
-
return (0,
|
|
33427
|
-
(0,
|
|
34491
|
+
return (0, import_viem24.keccak256)(
|
|
34492
|
+
(0, import_viem24.encodeAbiParameters)(
|
|
33428
34493
|
[
|
|
33429
34494
|
{ name: "ownerAddress", type: "address" },
|
|
33430
34495
|
{ name: "scope", type: "string" }
|
|
@@ -33513,7 +34578,7 @@ function gatewayLineagePath(dataPointId, version) {
|
|
|
33513
34578
|
function normalizeBaseUrl(url) {
|
|
33514
34579
|
return url.replace(/\/+$/, "");
|
|
33515
34580
|
}
|
|
33516
|
-
function
|
|
34581
|
+
function resolveFetch2(fetchFn) {
|
|
33517
34582
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
33518
34583
|
if (resolved === void 0) {
|
|
33519
34584
|
throw new LineageReadError("No fetch implementation available");
|
|
@@ -33554,7 +34619,7 @@ async function parseLineageGraph(source, response) {
|
|
|
33554
34619
|
{ cause: err instanceof Error ? err.message : String(err) }
|
|
33555
34620
|
);
|
|
33556
34621
|
}
|
|
33557
|
-
const envelope =
|
|
34622
|
+
const envelope = isRecord4(body) && isRecord4(body.data) ? body : void 0;
|
|
33558
34623
|
const parsed = LineageGraphSchema.safeParse(envelope?.data ?? body);
|
|
33559
34624
|
if (!parsed.success) {
|
|
33560
34625
|
throw new LineageReadError(
|
|
@@ -33564,7 +34629,7 @@ async function parseLineageGraph(source, response) {
|
|
|
33564
34629
|
{ issues: parsed.error.issues }
|
|
33565
34630
|
);
|
|
33566
34631
|
}
|
|
33567
|
-
const proof =
|
|
34632
|
+
const proof = isRecord4(envelope?.proof) ? envelope.proof : void 0;
|
|
33568
34633
|
return proof === void 0 ? parsed.data : { ...parsed.data, proof };
|
|
33569
34634
|
}
|
|
33570
34635
|
async function sendLineageRead(source, fetchFn, url, headers) {
|
|
@@ -33585,7 +34650,7 @@ async function sendLineageRead(source, fetchFn, url, headers) {
|
|
|
33585
34650
|
return parseLineageGraph(source, response);
|
|
33586
34651
|
}
|
|
33587
34652
|
async function getPersonalServerLineage(params) {
|
|
33588
|
-
const fetchFn =
|
|
34653
|
+
const fetchFn = resolveFetch2(params.fetch);
|
|
33589
34654
|
const baseUrl = normalizeBaseUrl(params.personalServerUrl);
|
|
33590
34655
|
const audience = params.audience ?? baseUrl;
|
|
33591
34656
|
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
@@ -33620,7 +34685,7 @@ async function getGatewayLineage(params) {
|
|
|
33620
34685
|
{ dataPointId: params.dataPointId }
|
|
33621
34686
|
);
|
|
33622
34687
|
}
|
|
33623
|
-
const fetchFn =
|
|
34688
|
+
const fetchFn = resolveFetch2(params.fetch);
|
|
33624
34689
|
const baseUrl = normalizeBaseUrl(params.gatewayUrl);
|
|
33625
34690
|
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
33626
34691
|
const uri = gatewayLineagePath(
|
|
@@ -33650,7 +34715,7 @@ var TOMBSTONE_METADATA_HASH_PREIMAGE = "vana.data-point.tombstone.metadata.v1";
|
|
|
33650
34715
|
var TOMBSTONE_DATA_HASH = "0x30c45ee72fe56d1927701316925ab7ceacd3b6f9267061735d59396f075c6222";
|
|
33651
34716
|
var TOMBSTONE_METADATA_HASH = "0xc5255a141acd6a2ae55971b62c0a85977c2511989dc114ad2abc2b7644f57d90";
|
|
33652
34717
|
function computeTombstoneHash(preimage) {
|
|
33653
|
-
return (0,
|
|
34718
|
+
return (0, import_viem25.keccak256)((0, import_viem25.stringToBytes)(preimage));
|
|
33654
34719
|
}
|
|
33655
34720
|
function isTombstoneHashes(dataHash, metadataHash) {
|
|
33656
34721
|
return typeof dataHash === "string" && typeof metadataHash === "string" && dataHash.toLowerCase() === TOMBSTONE_DATA_HASH && metadataHash.toLowerCase() === TOMBSTONE_METADATA_HASH;
|
|
@@ -33669,12 +34734,12 @@ function tombstoneDeletedAt(value) {
|
|
|
33669
34734
|
return typeof deletedAt === "string" ? deletedAt : null;
|
|
33670
34735
|
}
|
|
33671
34736
|
function assertAddress4(value, name) {
|
|
33672
|
-
if (!(0,
|
|
34737
|
+
if (!(0, import_viem25.isAddress)(value)) {
|
|
33673
34738
|
throw new Error(`${name} must be a valid EVM address`);
|
|
33674
34739
|
}
|
|
33675
34740
|
}
|
|
33676
34741
|
function assertUint256(value, name) {
|
|
33677
|
-
if (value < 0n || value >
|
|
34742
|
+
if (value < 0n || value > import_viem25.maxUint256) {
|
|
33678
34743
|
throw new Error(`${name} must fit in uint256, got ${value}`);
|
|
33679
34744
|
}
|
|
33680
34745
|
}
|
|
@@ -33777,7 +34842,7 @@ async function deleteDataPoint(input) {
|
|
|
33777
34842
|
}
|
|
33778
34843
|
currentVersion = parseExpectedVersion(record.expectedVersion);
|
|
33779
34844
|
}
|
|
33780
|
-
if (currentVersion < 0n || currentVersion >=
|
|
34845
|
+
if (currentVersion < 0n || currentVersion >= import_viem25.maxUint256) {
|
|
33781
34846
|
throw new Error(
|
|
33782
34847
|
`currentVersion ${currentVersion} cannot be incremented to a uint256 tombstone version`
|
|
33783
34848
|
);
|
|
@@ -34084,17 +35149,17 @@ function tryGrantPermissions(scopes) {
|
|
|
34084
35149
|
}
|
|
34085
35150
|
|
|
34086
35151
|
// src/protocol/personal-server-write.ts
|
|
34087
|
-
var
|
|
34088
|
-
var
|
|
35152
|
+
var import_sha28 = require("@noble/hashes/sha2");
|
|
35153
|
+
var import_viem27 = require("viem");
|
|
34089
35154
|
var import_zod4 = require("zod");
|
|
34090
35155
|
|
|
34091
35156
|
// src/protocol/write-request.ts
|
|
34092
|
-
var
|
|
34093
|
-
var
|
|
35157
|
+
var import_sha27 = require("@noble/hashes/sha2");
|
|
35158
|
+
var import_viem26 = require("viem");
|
|
34094
35159
|
function normalizeBaseUrl2(url) {
|
|
34095
35160
|
return url.replace(/\/+$/, "");
|
|
34096
35161
|
}
|
|
34097
|
-
function
|
|
35162
|
+
function resolveFetch3(fetchFn) {
|
|
34098
35163
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
34099
35164
|
if (resolved === void 0) {
|
|
34100
35165
|
throw new WriteRequestError("No fetch implementation available");
|
|
@@ -34107,7 +35172,7 @@ function errorMessage(err) {
|
|
|
34107
35172
|
function finiteOr(value, fallback) {
|
|
34108
35173
|
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
34109
35174
|
}
|
|
34110
|
-
function
|
|
35175
|
+
function sleep3(ms) {
|
|
34111
35176
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
34112
35177
|
}
|
|
34113
35178
|
var issuedProofIats = /* @__PURE__ */ new Map();
|
|
@@ -34149,7 +35214,7 @@ function nextProofIat(proofKey) {
|
|
|
34149
35214
|
setIssuedProofIat(proofKey, iat, last);
|
|
34150
35215
|
const waitSec = iat - nowSec - PROOF_IAT_MAX_AHEAD_SECONDS;
|
|
34151
35216
|
if (waitSec <= 0) return Promise.resolve(iat);
|
|
34152
|
-
return
|
|
35217
|
+
return sleep3(waitSec * 1e3).then(() => iat);
|
|
34153
35218
|
}
|
|
34154
35219
|
function freshProofNonce() {
|
|
34155
35220
|
const webCrypto = globalThis.crypto;
|
|
@@ -34157,22 +35222,22 @@ function freshProofNonce() {
|
|
|
34157
35222
|
return webCrypto.randomUUID();
|
|
34158
35223
|
}
|
|
34159
35224
|
if (typeof webCrypto?.getRandomValues === "function") {
|
|
34160
|
-
return (0,
|
|
35225
|
+
return (0, import_viem26.bytesToHex)(webCrypto.getRandomValues(new Uint8Array(16)));
|
|
34161
35226
|
}
|
|
34162
35227
|
throw new WriteRequestError(
|
|
34163
35228
|
"No secure random source available to build a proof nonce; provide a crypto global"
|
|
34164
35229
|
);
|
|
34165
35230
|
}
|
|
34166
35231
|
function proofKeyFor(parts) {
|
|
34167
|
-
return (0,
|
|
34168
|
-
(0,
|
|
35232
|
+
return (0, import_viem26.bytesToHex)(
|
|
35233
|
+
(0, import_sha27.sha256)(
|
|
34169
35234
|
new TextEncoder().encode(
|
|
34170
35235
|
JSON.stringify([
|
|
34171
35236
|
parts.aud,
|
|
34172
35237
|
parts.method,
|
|
34173
35238
|
parts.uri,
|
|
34174
35239
|
parts.grantId,
|
|
34175
|
-
parts.signedBytes ? (0,
|
|
35240
|
+
parts.signedBytes ? (0, import_viem26.bytesToHex)((0, import_sha27.sha256)(parts.signedBytes)) : ""
|
|
34176
35241
|
])
|
|
34177
35242
|
)
|
|
34178
35243
|
)
|
|
@@ -34190,7 +35255,7 @@ async function sendWithFreshProof(label, fetchFn, options, proofKey, build) {
|
|
|
34190
35255
|
lastError = err;
|
|
34191
35256
|
}
|
|
34192
35257
|
if (attempt < attempts - 1) {
|
|
34193
|
-
await
|
|
35258
|
+
await sleep3(delayMs);
|
|
34194
35259
|
delayMs *= 2;
|
|
34195
35260
|
}
|
|
34196
35261
|
}
|
|
@@ -34229,7 +35294,7 @@ function dataPath(scope) {
|
|
|
34229
35294
|
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
34230
35295
|
}
|
|
34231
35296
|
async function openWriteSession(params) {
|
|
34232
|
-
const fetchFn =
|
|
35297
|
+
const fetchFn = resolveFetch3(params.fetch);
|
|
34233
35298
|
const personalServerUrl = normalizeBaseUrl2(params.personalServerUrl);
|
|
34234
35299
|
const audience = params.audience ?? personalServerUrl;
|
|
34235
35300
|
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
@@ -34309,12 +35374,12 @@ async function openWriteSession(params) {
|
|
|
34309
35374
|
};
|
|
34310
35375
|
}
|
|
34311
35376
|
function isWriteSession(value) {
|
|
34312
|
-
if (!
|
|
35377
|
+
if (!isRecord4(value)) return false;
|
|
34313
35378
|
const signer = value.signer;
|
|
34314
|
-
return typeof value.personalServerUrl === "string" && typeof value.audience === "string" && typeof value.grantId === "string" && typeof value.accessToken === "string" && value.accessToken.length > 0 && typeof value.expiresAt === "number" && Number.isFinite(value.expiresAt) && Array.isArray(value.writeScopes) && value.writeScopes.every((scope) => typeof scope === "string") &&
|
|
35379
|
+
return typeof value.personalServerUrl === "string" && typeof value.audience === "string" && typeof value.grantId === "string" && typeof value.accessToken === "string" && value.accessToken.length > 0 && typeof value.expiresAt === "number" && Number.isFinite(value.expiresAt) && Array.isArray(value.writeScopes) && value.writeScopes.every((scope) => typeof scope === "string") && isRecord4(signer) && typeof signer.signMessage === "function";
|
|
34315
35380
|
}
|
|
34316
35381
|
function sessionCoversScope(session, scope) {
|
|
34317
|
-
if (!
|
|
35382
|
+
if (!isRecord4(session) || !Array.isArray(session.writeScopes) || !session.writeScopes.every((pattern) => typeof pattern === "string")) {
|
|
34318
35383
|
throw new WriteRequestError("session must come from openWriteSession");
|
|
34319
35384
|
}
|
|
34320
35385
|
return session.writeScopes.some(
|
|
@@ -34359,7 +35424,7 @@ function binaryWriteSignedBytes(input) {
|
|
|
34359
35424
|
mimeType: normalizeBinaryMimeType(input.contentType),
|
|
34360
35425
|
...input.filename ? { filename: input.filename } : {},
|
|
34361
35426
|
sizeBytes: input.bytes.length,
|
|
34362
|
-
contentHash: (0,
|
|
35427
|
+
contentHash: (0, import_viem27.bytesToHex)((0, import_sha28.sha256)(input.bytes)),
|
|
34363
35428
|
encoding: "base64",
|
|
34364
35429
|
content: toBase64(input.bytes),
|
|
34365
35430
|
...metadata !== void 0 ? { metadata } : {}
|
|
@@ -34388,7 +35453,7 @@ function assertNoReservedKeys(value, where) {
|
|
|
34388
35453
|
}
|
|
34389
35454
|
}
|
|
34390
35455
|
function isLineagePair(value) {
|
|
34391
|
-
return
|
|
35456
|
+
return isRecord4(value) && typeof value.ownerAddress === "string" && typeof value.scope === "string";
|
|
34392
35457
|
}
|
|
34393
35458
|
function normalizeLineage(lineage, derivedScope) {
|
|
34394
35459
|
if (!Array.isArray(lineage)) {
|
|
@@ -34407,7 +35472,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
34407
35472
|
for (const entry of lineage) {
|
|
34408
35473
|
let id;
|
|
34409
35474
|
if (isLineagePair(entry)) {
|
|
34410
|
-
if (!(0,
|
|
35475
|
+
if (!(0, import_viem27.isAddress)(entry.ownerAddress, { strict: false })) {
|
|
34411
35476
|
throw new WriteRequestError(
|
|
34412
35477
|
"lineage source ownerAddress must be an EVM address",
|
|
34413
35478
|
{ ownerAddress: entry.ownerAddress }
|
|
@@ -34456,7 +35521,7 @@ function assertNoLineageField(value, where) {
|
|
|
34456
35521
|
}
|
|
34457
35522
|
function buildMetadataHeader(metadata, sources) {
|
|
34458
35523
|
if (metadata !== void 0) {
|
|
34459
|
-
if (!
|
|
35524
|
+
if (!isRecord4(metadata)) {
|
|
34460
35525
|
throw new WriteRequestError("metadata must be a plain object");
|
|
34461
35526
|
}
|
|
34462
35527
|
assertNoReservedKeys(metadata, "metadata");
|
|
@@ -34509,7 +35574,7 @@ function prepareWrite(params) {
|
|
|
34509
35574
|
if (params.data === void 0) {
|
|
34510
35575
|
throw new WriteRequestError("Pass data (a JSON object) or binary");
|
|
34511
35576
|
}
|
|
34512
|
-
if (!
|
|
35577
|
+
if (!isRecord4(params.data)) {
|
|
34513
35578
|
throw new WriteRequestError("data must be a plain JSON object");
|
|
34514
35579
|
}
|
|
34515
35580
|
if (params.metadata !== void 0) {
|
|
@@ -34560,7 +35625,7 @@ async function writeData(params) {
|
|
|
34560
35625
|
if (!isWriteSession(session)) {
|
|
34561
35626
|
throw new WriteRequestError("session must come from openWriteSession");
|
|
34562
35627
|
}
|
|
34563
|
-
const fetchFn =
|
|
35628
|
+
const fetchFn = resolveFetch3(params.fetch);
|
|
34564
35629
|
if (typeof params.scope !== "string" || params.scope.length === 0) {
|
|
34565
35630
|
throw new WriteRequestError("scope is required");
|
|
34566
35631
|
}
|
|
@@ -34752,7 +35817,7 @@ function resolveRequest(params) {
|
|
|
34752
35817
|
"signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
|
|
34753
35818
|
);
|
|
34754
35819
|
}
|
|
34755
|
-
const fetchFn =
|
|
35820
|
+
const fetchFn = resolveFetch3(params.fetch);
|
|
34756
35821
|
const baseUrl = normalizeBaseUrl2(params.personalServerUrl);
|
|
34757
35822
|
const audience = params.audience ?? baseUrl;
|
|
34758
35823
|
return {
|
|
@@ -35085,7 +36150,7 @@ async function waitForQuestion(params) {
|
|
|
35085
36150
|
}
|
|
35086
36151
|
);
|
|
35087
36152
|
}
|
|
35088
|
-
await
|
|
36153
|
+
await sleep3(Math.min(pollIntervalMs, remaining));
|
|
35089
36154
|
}
|
|
35090
36155
|
}
|
|
35091
36156
|
async function askPersonalServer(params) {
|
|
@@ -35149,7 +36214,7 @@ function derivativeStatusTarget(derivedScope) {
|
|
|
35149
36214
|
function normalizeBaseUrl3(url) {
|
|
35150
36215
|
return url.replace(/\/+$/, "");
|
|
35151
36216
|
}
|
|
35152
|
-
function
|
|
36217
|
+
function resolveFetch4(fetchFn) {
|
|
35153
36218
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
35154
36219
|
if (resolved === void 0) {
|
|
35155
36220
|
throw new WriteRequestError("No fetch implementation available");
|
|
@@ -35162,7 +36227,7 @@ function requireDerivedScope(derivedScope) {
|
|
|
35162
36227
|
}
|
|
35163
36228
|
return derivedScope;
|
|
35164
36229
|
}
|
|
35165
|
-
function
|
|
36230
|
+
function sleep4(ms, signal) {
|
|
35166
36231
|
if (ms <= 0) return Promise.resolve();
|
|
35167
36232
|
return new Promise((resolve, reject) => {
|
|
35168
36233
|
const timer = setTimeout(() => {
|
|
@@ -35198,7 +36263,7 @@ function isDerivativeStatusSettled(status) {
|
|
|
35198
36263
|
}
|
|
35199
36264
|
async function getDerivativeStatus(params) {
|
|
35200
36265
|
const derivedScope = requireDerivedScope(params.derivedScope);
|
|
35201
|
-
const fetchFn =
|
|
36266
|
+
const fetchFn = resolveFetch4(params.fetch);
|
|
35202
36267
|
const baseUrl = normalizeBaseUrl3(params.personalServerUrl);
|
|
35203
36268
|
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
35204
36269
|
const headers = new Headers(params.headers);
|
|
@@ -35276,7 +36341,7 @@ async function waitForDerivativeStatus(params) {
|
|
|
35276
36341
|
if (waitMs > remaining) {
|
|
35277
36342
|
throw timeoutError(latest, timeoutMs);
|
|
35278
36343
|
}
|
|
35279
|
-
await
|
|
36344
|
+
await sleep4(waitMs, params.signal);
|
|
35280
36345
|
}
|
|
35281
36346
|
}
|
|
35282
36347
|
|
|
@@ -36309,7 +37374,7 @@ var KNOWN_CODES = /* @__PURE__ */ new Set([
|
|
|
36309
37374
|
"server_not_configured",
|
|
36310
37375
|
"content_too_large"
|
|
36311
37376
|
]);
|
|
36312
|
-
function
|
|
37377
|
+
function isRecord5(value) {
|
|
36313
37378
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
36314
37379
|
}
|
|
36315
37380
|
function normalizeCode(value) {
|
|
@@ -36320,10 +37385,10 @@ function normalizeCode(value) {
|
|
|
36320
37385
|
return KNOWN_CODES.has(code) ? code : null;
|
|
36321
37386
|
}
|
|
36322
37387
|
function extractPSErrorBody(body) {
|
|
36323
|
-
if (!
|
|
37388
|
+
if (!isRecord5(body)) {
|
|
36324
37389
|
return null;
|
|
36325
37390
|
}
|
|
36326
|
-
const nested =
|
|
37391
|
+
const nested = isRecord5(body.error) ? body.error : null;
|
|
36327
37392
|
const code = normalizeCode(
|
|
36328
37393
|
nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
|
|
36329
37394
|
);
|
|
@@ -36355,6 +37420,8 @@ async function parsePSError(response) {
|
|
|
36355
37420
|
BUILDER_REGISTRATION_TYPES,
|
|
36356
37421
|
BlockchainError,
|
|
36357
37422
|
BrowserPlatformAdapter,
|
|
37423
|
+
BuilderUnknownError,
|
|
37424
|
+
CLAIM_POLL_FLOOR_MS,
|
|
36358
37425
|
CONTRACTS,
|
|
36359
37426
|
CallbackStorage,
|
|
36360
37427
|
ContractFactory,
|
|
@@ -36363,6 +37430,8 @@ async function parsePSError(response) {
|
|
|
36363
37430
|
DATA_REGISTRY_STATUS_ABI,
|
|
36364
37431
|
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
36365
37432
|
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
37433
|
+
DEFAULT_JOB_DEADLINE_SECONDS,
|
|
37434
|
+
DEFAULT_LEASE_SECONDS,
|
|
36366
37435
|
DEFAULT_QUESTION_POLL_INTERVAL_MS,
|
|
36367
37436
|
DEFAULT_QUESTION_TIMEOUT_MS,
|
|
36368
37437
|
DERIVATIVE_ERROR_CODES,
|
|
@@ -36387,6 +37456,9 @@ async function parsePSError(response) {
|
|
|
36387
37456
|
DerivativeStatusSchema,
|
|
36388
37457
|
DropboxStorage,
|
|
36389
37458
|
ECIESError,
|
|
37459
|
+
ENCLAVE_IDENTITY_EVIDENCE_VERSION,
|
|
37460
|
+
ENCLAVE_TRUST_ANCHORS,
|
|
37461
|
+
ENCLAVE_WALLET_PURPOSE,
|
|
36390
37462
|
ESCROW_DEPOSIT_ABI,
|
|
36391
37463
|
ExpiredTokenError,
|
|
36392
37464
|
FEE_REGISTRY_ABI,
|
|
@@ -36395,12 +37467,25 @@ async function parsePSError(response) {
|
|
|
36395
37467
|
GRANT_REGISTRATION_TYPES,
|
|
36396
37468
|
GRANT_REVOCATION_TYPES,
|
|
36397
37469
|
GoogleDriveStorage,
|
|
37470
|
+
GrantInvalidError,
|
|
36398
37471
|
InMemoryTokenStore,
|
|
36399
37472
|
IngestResponseSchema,
|
|
36400
37473
|
InvalidConfigurationError,
|
|
36401
37474
|
InvalidScopeEntryError,
|
|
36402
37475
|
InvalidSignatureError,
|
|
36403
37476
|
IpfsStorage,
|
|
37477
|
+
JOB_OPERATIONS,
|
|
37478
|
+
JOB_PROTOCOL_VERSION,
|
|
37479
|
+
JOB_STATES,
|
|
37480
|
+
JobEnvelopeError,
|
|
37481
|
+
JobIdTakenError,
|
|
37482
|
+
JobNotFoundError,
|
|
37483
|
+
JobRejectedError,
|
|
37484
|
+
JobRequestTooLargeError,
|
|
37485
|
+
JobResultIntegrityError,
|
|
37486
|
+
JobTimeoutError,
|
|
37487
|
+
JobTransportError,
|
|
37488
|
+
JobsClientError,
|
|
36404
37489
|
LINEAGE_FIELD,
|
|
36405
37490
|
LINEAGE_KEY,
|
|
36406
37491
|
LineageEntrySchema,
|
|
@@ -36408,10 +37493,16 @@ async function parsePSError(response) {
|
|
|
36408
37493
|
LineageNodeSchema,
|
|
36409
37494
|
LineageReadError,
|
|
36410
37495
|
MASTER_KEY_MESSAGE,
|
|
37496
|
+
MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS,
|
|
37497
|
+
MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
37498
|
+
MAX_ATTEMPTS,
|
|
37499
|
+
MAX_JOB_DEADLINE_SECONDS,
|
|
37500
|
+
MAX_LEASE_SECONDS,
|
|
36411
37501
|
MAX_LINEAGE_SOURCES,
|
|
36412
37502
|
MAX_QUESTION_CHARS,
|
|
36413
37503
|
MAX_QUESTION_MODEL_CHARS,
|
|
36414
37504
|
MAX_QUESTION_SOURCE_SCOPES,
|
|
37505
|
+
MAX_WAIT_SECONDS,
|
|
36415
37506
|
MissingAuthError,
|
|
36416
37507
|
NATIVE_ASSET_ADDRESS,
|
|
36417
37508
|
NATIVE_VANA_ASSET,
|
|
@@ -36420,6 +37511,7 @@ async function parsePSError(response) {
|
|
|
36420
37511
|
NodePlatformAdapter,
|
|
36421
37512
|
NonceError,
|
|
36422
37513
|
OAuthClient,
|
|
37514
|
+
OwnerNotReadyError,
|
|
36423
37515
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
36424
37516
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
36425
37517
|
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
@@ -36445,6 +37537,7 @@ async function parsePSError(response) {
|
|
|
36445
37537
|
RedactedLineageNodeSchema,
|
|
36446
37538
|
RelayerError,
|
|
36447
37539
|
SCOPE_ACTIONS,
|
|
37540
|
+
SEALED_ENVELOPE_VERSION,
|
|
36448
37541
|
SERVER_REGISTRATION_TYPES,
|
|
36449
37542
|
ScopeSchema,
|
|
36450
37543
|
SerializationError,
|
|
@@ -36457,6 +37550,7 @@ async function parsePSError(response) {
|
|
|
36457
37550
|
TOMBSTONE_METADATA_HASH,
|
|
36458
37551
|
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
36459
37552
|
TransactionPendingError,
|
|
37553
|
+
USER_PS_ID_DOMAIN,
|
|
36460
37554
|
UserRejectedRequestError,
|
|
36461
37555
|
VanaError,
|
|
36462
37556
|
VanaStorage,
|
|
@@ -36475,6 +37569,7 @@ async function parsePSError(response) {
|
|
|
36475
37569
|
WriteSessionExpiredError,
|
|
36476
37570
|
WriteTransportError,
|
|
36477
37571
|
WriteUnauthorizedError,
|
|
37572
|
+
appRootPreimage,
|
|
36478
37573
|
askPersonalServer,
|
|
36479
37574
|
assertDerivedScopeNaming,
|
|
36480
37575
|
assertValidPkceVerifier,
|
|
@@ -36488,6 +37583,7 @@ async function parsePSError(response) {
|
|
|
36488
37583
|
buildEscrowPaymentHeader,
|
|
36489
37584
|
buildGrantPaymentHeader,
|
|
36490
37585
|
buildMarkDataPointUnavailableRequest,
|
|
37586
|
+
buildMasterSignatureDelivery,
|
|
36491
37587
|
buildPersonalServerDataReadRequest,
|
|
36492
37588
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
36493
37589
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
@@ -36496,6 +37592,7 @@ async function parsePSError(response) {
|
|
|
36496
37592
|
buildSetDataPointStatusRequest,
|
|
36497
37593
|
buildWeb3SignedHeader,
|
|
36498
37594
|
builderRegistrationDomain,
|
|
37595
|
+
canonicalJobRequestBytes,
|
|
36499
37596
|
chains,
|
|
36500
37597
|
clearContractCache,
|
|
36501
37598
|
computeBodyHash,
|
|
@@ -36507,6 +37604,7 @@ async function parsePSError(response) {
|
|
|
36507
37604
|
createDefaultNonceSource,
|
|
36508
37605
|
createEscrowGatewayClient,
|
|
36509
37606
|
createGatewayClient,
|
|
37607
|
+
createJobsClient,
|
|
36510
37608
|
createNodePlatformAdapter,
|
|
36511
37609
|
createPlatformAdapter,
|
|
36512
37610
|
createPlatformAdapterFor,
|
|
@@ -36531,6 +37629,7 @@ async function parsePSError(response) {
|
|
|
36531
37629
|
encodeDepositTokenData,
|
|
36532
37630
|
encodeSetDataPointStatusData,
|
|
36533
37631
|
encodeWriteMetadataHeader,
|
|
37632
|
+
encryptMasterSignatureDelivery,
|
|
36534
37633
|
encryptWithPassword,
|
|
36535
37634
|
escrowContractAddress,
|
|
36536
37635
|
escrowPaymentDomain,
|
|
@@ -36565,12 +37664,15 @@ async function parsePSError(response) {
|
|
|
36565
37664
|
isPlatformSupported,
|
|
36566
37665
|
isRedactedLineageNode,
|
|
36567
37666
|
isTombstoneHashes,
|
|
37667
|
+
kmsIssuedPreimage,
|
|
36568
37668
|
listQuestions,
|
|
36569
37669
|
mainnetServices,
|
|
36570
37670
|
moksha,
|
|
36571
37671
|
mokshaServices,
|
|
36572
37672
|
mokshaTestnet,
|
|
36573
37673
|
normalizeBinaryMimeType,
|
|
37674
|
+
openJobRequest,
|
|
37675
|
+
openJobResult,
|
|
36574
37676
|
openWriteSession,
|
|
36575
37677
|
parsePSError,
|
|
36576
37678
|
parsePersonalServerPaymentRequired,
|
|
@@ -36594,6 +37696,8 @@ async function parsePSError(response) {
|
|
|
36594
37696
|
scopeMatchesPattern,
|
|
36595
37697
|
scopeNamespace,
|
|
36596
37698
|
scopeToPathSegments,
|
|
37699
|
+
sealJobRequest,
|
|
37700
|
+
sealJobResult,
|
|
36597
37701
|
serializeECIES,
|
|
36598
37702
|
serverRegistrationDomain,
|
|
36599
37703
|
sessionCoversScope,
|
|
@@ -36604,7 +37708,9 @@ async function parsePSError(response) {
|
|
|
36604
37708
|
toDirectPaymentReceipt,
|
|
36605
37709
|
tombstoneDeletedAt,
|
|
36606
37710
|
tryGrantPermissions,
|
|
37711
|
+
userPsId,
|
|
36607
37712
|
vanaMainnet,
|
|
37713
|
+
verifyEnclaveIdentityEvidence,
|
|
36608
37714
|
verifyGrantRegistration,
|
|
36609
37715
|
verifyPkceChallenge,
|
|
36610
37716
|
verifyWeb3Signed,
|