@opendatalabs/vana-sdk 3.21.0 → 3.22.0-pr.207.e47cd30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -0
- package/dist/index.browser.d.ts +3 -1
- package/dist/index.browser.js +320 -4
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +364 -34
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +3 -1
- package/dist/index.node.js +323 -7
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/derivative-questions.cjs +22 -0
- package/dist/protocol/derivative-questions.cjs.map +1 -1
- package/dist/protocol/derivative-questions.d.ts +53 -0
- package/dist/protocol/derivative-questions.js +19 -0
- package/dist/protocol/derivative-questions.js.map +1 -1
- package/dist/protocol/derivative-status.cjs +209 -0
- package/dist/protocol/derivative-status.cjs.map +1 -0
- package/dist/protocol/derivative-status.d.ts +196 -0
- package/dist/protocol/derivative-status.js +190 -0
- package/dist/protocol/derivative-status.js.map +1 -0
- package/dist/protocol/derivative-status.test.d.ts +1 -0
- package/dist/protocol/identity.cjs +169 -0
- package/dist/protocol/identity.cjs.map +1 -0
- package/dist/protocol/identity.d.ts +151 -0
- package/dist/protocol/identity.js +132 -0
- package/dist/protocol/identity.js.map +1 -0
- package/dist/protocol/identity.test.d.ts +1 -0
- package/dist/tests/mock-personal-server.d.ts +9 -0
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1186,9 +1186,13 @@ __export(index_node_exports, {
|
|
|
1186
1186
|
ContractNotFoundError: () => ContractNotFoundError,
|
|
1187
1187
|
DATA_ACCESS_OP_TYPE: () => DATA_ACCESS_OP_TYPE,
|
|
1188
1188
|
DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
|
|
1189
|
+
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS: () => DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
1190
|
+
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS: () => DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
1189
1191
|
DEFAULT_QUESTION_POLL_INTERVAL_MS: () => DEFAULT_QUESTION_POLL_INTERVAL_MS,
|
|
1190
1192
|
DEFAULT_QUESTION_TIMEOUT_MS: () => DEFAULT_QUESTION_TIMEOUT_MS,
|
|
1193
|
+
DERIVATIVE_ERROR_CODES: () => DERIVATIVE_ERROR_CODES,
|
|
1191
1194
|
DERIVATIVE_QUESTIONS_PATH: () => DERIVATIVE_QUESTIONS_PATH,
|
|
1195
|
+
DERIVATIVE_STATUS_PATH: () => DERIVATIVE_STATUS_PATH,
|
|
1192
1196
|
DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
|
|
1193
1197
|
DataPointDeletedError: () => DataPointDeletedError,
|
|
1194
1198
|
DataPointNotFoundError: () => DataPointNotFoundError,
|
|
@@ -1197,6 +1201,7 @@ __export(index_node_exports, {
|
|
|
1197
1201
|
DerivativeComputeUnavailableError: () => DerivativeComputeUnavailableError,
|
|
1198
1202
|
DerivativeCycleError: () => DerivativeCycleError,
|
|
1199
1203
|
DerivativeDerivedScopeRequiredError: () => DerivativeDerivedScopeRequiredError,
|
|
1204
|
+
DerivativeErrorCodeSchema: () => DerivativeErrorCodeSchema,
|
|
1200
1205
|
DerivativeQuestionFailedError: () => DerivativeQuestionFailedError,
|
|
1201
1206
|
DerivativeQuestionInvalidError: () => DerivativeQuestionInvalidError,
|
|
1202
1207
|
DerivativeQuestionNotFoundError: () => DerivativeQuestionNotFoundError,
|
|
@@ -1204,8 +1209,12 @@ __export(index_node_exports, {
|
|
|
1204
1209
|
DerivativeQuestionSchema: () => DerivativeQuestionSchema,
|
|
1205
1210
|
DerivativeQuestionTimeoutError: () => DerivativeQuestionTimeoutError,
|
|
1206
1211
|
DerivativeSourceNotGrantedError: () => DerivativeSourceNotGrantedError,
|
|
1212
|
+
DerivativeStatusSchema: () => DerivativeStatusSchema,
|
|
1207
1213
|
DropboxStorage: () => DropboxStorage,
|
|
1208
1214
|
ECIESError: () => ECIESError,
|
|
1215
|
+
ENCLAVE_IDENTITY_EVIDENCE_VERSION: () => ENCLAVE_IDENTITY_EVIDENCE_VERSION,
|
|
1216
|
+
ENCLAVE_TRUST_ANCHORS: () => ENCLAVE_TRUST_ANCHORS,
|
|
1217
|
+
ENCLAVE_WALLET_PURPOSE: () => ENCLAVE_WALLET_PURPOSE,
|
|
1209
1218
|
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
|
|
1210
1219
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
1211
1220
|
FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
|
|
@@ -1227,6 +1236,7 @@ __export(index_node_exports, {
|
|
|
1227
1236
|
LineageNodeSchema: () => LineageNodeSchema,
|
|
1228
1237
|
LineageReadError: () => LineageReadError,
|
|
1229
1238
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1239
|
+
MASTER_SIGNATURE_DELIVERY_VERSION: () => MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
1230
1240
|
MAX_LINEAGE_SOURCES: () => MAX_LINEAGE_SOURCES,
|
|
1231
1241
|
MAX_QUESTION_CHARS: () => MAX_QUESTION_CHARS,
|
|
1232
1242
|
MAX_QUESTION_MODEL_CHARS: () => MAX_QUESTION_MODEL_CHARS,
|
|
@@ -1264,6 +1274,7 @@ __export(index_node_exports, {
|
|
|
1264
1274
|
RedactedLineageNodeSchema: () => RedactedLineageNodeSchema,
|
|
1265
1275
|
RelayerError: () => RelayerError,
|
|
1266
1276
|
SCOPE_ACTIONS: () => SCOPE_ACTIONS,
|
|
1277
|
+
SEALED_ENVELOPE_VERSION: () => SEALED_ENVELOPE_VERSION,
|
|
1267
1278
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
1268
1279
|
ScopeSchema: () => ScopeSchema,
|
|
1269
1280
|
SerializationError: () => SerializationError,
|
|
@@ -1276,6 +1287,7 @@ __export(index_node_exports, {
|
|
|
1276
1287
|
TOMBSTONE_METADATA_HASH: () => TOMBSTONE_METADATA_HASH,
|
|
1277
1288
|
TOMBSTONE_METADATA_HASH_PREIMAGE: () => TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
1278
1289
|
TransactionPendingError: () => TransactionPendingError,
|
|
1290
|
+
USER_PS_ID_DOMAIN: () => USER_PS_ID_DOMAIN,
|
|
1279
1291
|
UserRejectedRequestError: () => UserRejectedRequestError,
|
|
1280
1292
|
VanaError: () => VanaError,
|
|
1281
1293
|
VanaStorage: () => VanaStorage,
|
|
@@ -1294,6 +1306,7 @@ __export(index_node_exports, {
|
|
|
1294
1306
|
WriteSessionExpiredError: () => WriteSessionExpiredError,
|
|
1295
1307
|
WriteTransportError: () => WriteTransportError,
|
|
1296
1308
|
WriteUnauthorizedError: () => WriteUnauthorizedError,
|
|
1309
|
+
appRootPreimage: () => appRootPreimage,
|
|
1297
1310
|
askPersonalServer: () => askPersonalServer,
|
|
1298
1311
|
assertDerivedScopeNaming: () => assertDerivedScopeNaming,
|
|
1299
1312
|
assertValidPkceVerifier: () => assertValidPkceVerifier,
|
|
@@ -1307,6 +1320,7 @@ __export(index_node_exports, {
|
|
|
1307
1320
|
buildEscrowPaymentHeader: () => buildEscrowPaymentHeader,
|
|
1308
1321
|
buildGrantPaymentHeader: () => buildGrantPaymentHeader,
|
|
1309
1322
|
buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
|
|
1323
|
+
buildMasterSignatureDelivery: () => buildMasterSignatureDelivery,
|
|
1310
1324
|
buildPersonalServerDataReadRequest: () => buildPersonalServerDataReadRequest,
|
|
1311
1325
|
buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
|
|
1312
1326
|
buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
|
|
@@ -1339,6 +1353,7 @@ __export(index_node_exports, {
|
|
|
1339
1353
|
decryptWithPassword: () => decryptWithPassword,
|
|
1340
1354
|
deleteDataPoint: () => deleteDataPoint,
|
|
1341
1355
|
deleteQuestion: () => deleteQuestion,
|
|
1356
|
+
derivativeStatusTarget: () => derivativeStatusTarget,
|
|
1342
1357
|
deriveDataPointId: () => deriveDataPointId,
|
|
1343
1358
|
deriveMasterKey: () => deriveMasterKey,
|
|
1344
1359
|
deriveScopeKey: () => deriveScopeKey,
|
|
@@ -1349,6 +1364,7 @@ __export(index_node_exports, {
|
|
|
1349
1364
|
encodeDepositTokenData: () => encodeDepositTokenData,
|
|
1350
1365
|
encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
|
|
1351
1366
|
encodeWriteMetadataHeader: () => encodeWriteMetadataHeader,
|
|
1367
|
+
encryptMasterSignatureDelivery: () => encryptMasterSignatureDelivery,
|
|
1352
1368
|
encryptWithPassword: () => encryptWithPassword,
|
|
1353
1369
|
escrowContractAddress: () => escrowContractAddress,
|
|
1354
1370
|
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
@@ -1362,6 +1378,7 @@ __export(index_node_exports, {
|
|
|
1362
1378
|
getContractAddress: () => getContractAddress,
|
|
1363
1379
|
getContractController: () => getContractController,
|
|
1364
1380
|
getContractInfo: () => getContractInfo,
|
|
1381
|
+
getDerivativeStatus: () => getDerivativeStatus,
|
|
1365
1382
|
getFee: () => getFee,
|
|
1366
1383
|
getGatewayLineage: () => getGatewayLineage,
|
|
1367
1384
|
getLineage: () => getLineage,
|
|
@@ -1377,10 +1394,12 @@ __export(index_node_exports, {
|
|
|
1377
1394
|
isDataPointId: () => isDataPointId,
|
|
1378
1395
|
isDataPointTombstone: () => isDataPointTombstone,
|
|
1379
1396
|
isDataPortabilityGatewayConfig: () => isDataPortabilityGatewayConfig,
|
|
1397
|
+
isDerivativeStatusSettled: () => isDerivativeStatusSettled,
|
|
1380
1398
|
isECIESEncrypted: () => isECIESEncrypted,
|
|
1381
1399
|
isPlatformSupported: () => isPlatformSupported,
|
|
1382
1400
|
isRedactedLineageNode: () => isRedactedLineageNode,
|
|
1383
1401
|
isTombstoneHashes: () => isTombstoneHashes,
|
|
1402
|
+
kmsIssuedPreimage: () => kmsIssuedPreimage,
|
|
1384
1403
|
listQuestions: () => listQuestions,
|
|
1385
1404
|
mainnetServices: () => mainnetServices,
|
|
1386
1405
|
moksha: () => moksha,
|
|
@@ -1420,10 +1439,13 @@ __export(index_node_exports, {
|
|
|
1420
1439
|
toDirectPaymentReceipt: () => toDirectPaymentReceipt,
|
|
1421
1440
|
tombstoneDeletedAt: () => tombstoneDeletedAt,
|
|
1422
1441
|
tryGrantPermissions: () => tryGrantPermissions,
|
|
1442
|
+
userPsId: () => userPsId,
|
|
1423
1443
|
vanaMainnet: () => vanaMainnet2,
|
|
1444
|
+
verifyEnclaveIdentityEvidence: () => verifyEnclaveIdentityEvidence,
|
|
1424
1445
|
verifyGrantRegistration: () => verifyGrantRegistration,
|
|
1425
1446
|
verifyPkceChallenge: () => verifyPkceChallenge,
|
|
1426
1447
|
verifyWeb3Signed: () => verifyWeb3Signed,
|
|
1448
|
+
waitForDerivativeStatus: () => waitForDerivativeStatus,
|
|
1427
1449
|
waitForQuestion: () => waitForQuestion,
|
|
1428
1450
|
writeData: () => writeData,
|
|
1429
1451
|
writePersonalServerData: () => writePersonalServerData
|
|
@@ -31618,13 +31640,13 @@ var NodeCryptoAdapter = class {
|
|
|
31618
31640
|
*/
|
|
31619
31641
|
async generateKeyPair() {
|
|
31620
31642
|
try {
|
|
31621
|
-
const
|
|
31643
|
+
const secp256k15 = import_secp256k12.default;
|
|
31622
31644
|
let privateKey;
|
|
31623
31645
|
do {
|
|
31624
31646
|
privateKey = (0, import_crypto2.randomBytes)(32);
|
|
31625
|
-
} while (!
|
|
31647
|
+
} while (!secp256k15.privateKeyVerify(privateKey));
|
|
31626
31648
|
const publicKey = Buffer.from(
|
|
31627
|
-
|
|
31649
|
+
secp256k15.publicKeyCreate(privateKey, true)
|
|
31628
31650
|
);
|
|
31629
31651
|
return {
|
|
31630
31652
|
privateKey: privateKey.toString("hex"),
|
|
@@ -32634,15 +32656,125 @@ var RECORD_DATA_ACCESS_TYPES = {
|
|
|
32634
32656
|
]
|
|
32635
32657
|
};
|
|
32636
32658
|
|
|
32637
|
-
// src/protocol/
|
|
32659
|
+
// src/protocol/identity.ts
|
|
32660
|
+
var secp256k14 = __toESM(require("@noble/secp256k1"), 1);
|
|
32638
32661
|
var import_viem14 = require("viem");
|
|
32662
|
+
var import_accounts = require("viem/accounts");
|
|
32663
|
+
init_interface();
|
|
32664
|
+
var ENCLAVE_IDENTITY_EVIDENCE_VERSION = 1;
|
|
32665
|
+
var USER_PS_ID_DOMAIN = "vana.ps-enclave.v1";
|
|
32666
|
+
var ENCLAVE_WALLET_PURPOSE = "vana.ps-enclave.wallet.v1";
|
|
32667
|
+
var MASTER_SIGNATURE_DELIVERY_VERSION = "vana.ps-enclave.delivery.v1";
|
|
32668
|
+
var SEALED_ENVELOPE_VERSION = 1;
|
|
32669
|
+
var VANA_MAINNET_CHAIN_ID = 1480;
|
|
32670
|
+
var MOKSHA_CHAIN_ID = 14800;
|
|
32671
|
+
var KMS_ISSUED_PREFIX = "dstack-kms-issued";
|
|
32672
|
+
var PREIMAGE_SEPARATOR = ":";
|
|
32673
|
+
var UNCOMPRESSED_PUBLIC_KEY_BYTES = 65;
|
|
32674
|
+
var UNCOMPRESSED_PUBLIC_KEY_PREFIX = "04";
|
|
32675
|
+
var ENCLAVE_TRUST_ANCHORS = {
|
|
32676
|
+
// filled at fleet provisioning; verify fails closed while empty
|
|
32677
|
+
[VANA_MAINNET_CHAIN_ID]: { kmsRootPubkey: "0x", appIds: [] },
|
|
32678
|
+
// filled at fleet provisioning; verify fails closed while empty
|
|
32679
|
+
[MOKSHA_CHAIN_ID]: { kmsRootPubkey: "0x", appIds: [] }
|
|
32680
|
+
};
|
|
32681
|
+
function userPsId(chainId, ownerAddress) {
|
|
32682
|
+
const packed = (0, import_viem14.encodePacked)(
|
|
32683
|
+
["string", "uint256", "address"],
|
|
32684
|
+
[USER_PS_ID_DOMAIN, BigInt(chainId), (0, import_viem14.getAddress)(ownerAddress)]
|
|
32685
|
+
);
|
|
32686
|
+
return (0, import_viem14.keccak256)(packed);
|
|
32687
|
+
}
|
|
32688
|
+
function appRootPreimage(purpose, publicKey) {
|
|
32689
|
+
const keyHex = publicKey.slice(2).toLowerCase();
|
|
32690
|
+
return (0, import_viem14.keccak256)((0, import_viem14.toBytes)(`${purpose}${PREIMAGE_SEPARATOR}${keyHex}`));
|
|
32691
|
+
}
|
|
32692
|
+
function kmsIssuedPreimage(appId, appRootPublicKey) {
|
|
32693
|
+
const appIdHex = appId.slice(2).toLowerCase();
|
|
32694
|
+
const prefix = (0, import_viem14.toBytes)(
|
|
32695
|
+
`${KMS_ISSUED_PREFIX}${PREIMAGE_SEPARATOR}${appIdHex}`
|
|
32696
|
+
);
|
|
32697
|
+
const compressed = secp256k14.ProjectivePoint.fromHex(
|
|
32698
|
+
(0, import_viem14.fromHex)(appRootPublicKey, "bytes")
|
|
32699
|
+
).toRawBytes(true);
|
|
32700
|
+
return (0, import_viem14.keccak256)((0, import_viem14.concat)([prefix, compressed]));
|
|
32701
|
+
}
|
|
32702
|
+
async function recoverChainKey(hash, signature, link) {
|
|
32703
|
+
try {
|
|
32704
|
+
return (await (0, import_viem14.recoverPublicKey)({ hash, signature })).toLowerCase();
|
|
32705
|
+
} catch {
|
|
32706
|
+
throw new Error(`Invalid enclave signature chain link ${link}`);
|
|
32707
|
+
}
|
|
32708
|
+
}
|
|
32709
|
+
async function verifyEnclaveIdentityEvidence(evidence, anchors) {
|
|
32710
|
+
if (evidence.v !== ENCLAVE_IDENTITY_EVIDENCE_VERSION) {
|
|
32711
|
+
throw new Error("Unsupported enclave identity evidence version");
|
|
32712
|
+
}
|
|
32713
|
+
if (!Number.isInteger(evidence.epoch) || evidence.epoch < 1) {
|
|
32714
|
+
throw new Error("Invalid enclave identity epoch");
|
|
32715
|
+
}
|
|
32716
|
+
const derivedAddress = (0, import_accounts.publicKeyToAddress)(evidence.publicKey);
|
|
32717
|
+
if ((0, import_viem14.getAddress)(derivedAddress) !== (0, import_viem14.getAddress)(evidence.address)) {
|
|
32718
|
+
throw new Error("Enclave public key does not match its address");
|
|
32719
|
+
}
|
|
32720
|
+
const appRootPublicKey = await recoverChainKey(
|
|
32721
|
+
appRootPreimage(evidence.purpose, evidence.publicKey),
|
|
32722
|
+
evidence.signatureChain[0],
|
|
32723
|
+
0
|
|
32724
|
+
);
|
|
32725
|
+
const kmsRootPublicKey = await recoverChainKey(
|
|
32726
|
+
kmsIssuedPreimage(evidence.appId, appRootPublicKey),
|
|
32727
|
+
evidence.signatureChain[1],
|
|
32728
|
+
1
|
|
32729
|
+
);
|
|
32730
|
+
if (anchors.kmsRootPubkey === "0x") {
|
|
32731
|
+
throw new Error("KMS root trust anchor is not provisioned");
|
|
32732
|
+
}
|
|
32733
|
+
if (kmsRootPublicKey !== anchors.kmsRootPubkey.toLowerCase()) {
|
|
32734
|
+
throw new Error("KMS root public key does not match the trust anchor");
|
|
32735
|
+
}
|
|
32736
|
+
if ((0, import_viem14.keccak256)(kmsRootPublicKey) !== evidence.kmsRootFingerprint.toLowerCase()) {
|
|
32737
|
+
throw new Error("KMS root fingerprint does not match the evidence");
|
|
32738
|
+
}
|
|
32739
|
+
const appId = evidence.appId.toLowerCase();
|
|
32740
|
+
if (!anchors.appIds.some((allowedAppId) => allowedAppId.toLowerCase() === appId)) {
|
|
32741
|
+
throw new Error("Enclave app ID is not trusted");
|
|
32742
|
+
}
|
|
32743
|
+
}
|
|
32744
|
+
function buildMasterSignatureDelivery(evidence, masterSignature, now = Math.floor(Date.now() / 1e3)) {
|
|
32745
|
+
deriveMasterKey(masterSignature);
|
|
32746
|
+
return {
|
|
32747
|
+
v: MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
32748
|
+
userPsId: evidence.userPsId,
|
|
32749
|
+
epoch: evidence.epoch,
|
|
32750
|
+
enclaveAddress: evidence.address,
|
|
32751
|
+
ownerAddress: evidence.ownerAddress,
|
|
32752
|
+
masterSignature,
|
|
32753
|
+
issuedAt: now
|
|
32754
|
+
};
|
|
32755
|
+
}
|
|
32756
|
+
function assertUncompressedKey(publicKey) {
|
|
32757
|
+
const hex = publicKey.slice(2);
|
|
32758
|
+
if (hex.length !== UNCOMPRESSED_PUBLIC_KEY_BYTES * 2 || !hex.startsWith(UNCOMPRESSED_PUBLIC_KEY_PREFIX) || !/^[0-9a-fA-F]+$/.test(hex)) {
|
|
32759
|
+
throw new Error("Public key must be a 65-byte uncompressed secp256k1 key");
|
|
32760
|
+
}
|
|
32761
|
+
}
|
|
32762
|
+
async function encryptMasterSignatureDelivery(delivery, publicKey, ecies) {
|
|
32763
|
+
assertUncompressedKey(publicKey);
|
|
32764
|
+
const plaintext = (0, import_viem14.toBytes)(JSON.stringify(delivery));
|
|
32765
|
+
const encrypted = await ecies.encrypt((0, import_viem14.fromHex)(publicKey, "bytes"), plaintext);
|
|
32766
|
+
return `0x${serializeECIES(encrypted)}`;
|
|
32767
|
+
}
|
|
32768
|
+
|
|
32769
|
+
// src/protocol/personal-server-registration.ts
|
|
32770
|
+
var import_viem15 = require("viem");
|
|
32639
32771
|
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
|
|
32640
32772
|
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
|
|
32641
32773
|
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32642
32774
|
"DataPortabilityServers"
|
|
32643
32775
|
);
|
|
32644
32776
|
function assertAddress(value, name) {
|
|
32645
|
-
if (!(0,
|
|
32777
|
+
if (!(0, import_viem15.isAddress)(value)) {
|
|
32646
32778
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32647
32779
|
}
|
|
32648
32780
|
}
|
|
@@ -32728,12 +32860,12 @@ async function buildPersonalServerRegistrationSignature(input) {
|
|
|
32728
32860
|
var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
32729
32861
|
|
|
32730
32862
|
// src/personal-server-lite/owner-binding.ts
|
|
32731
|
-
var
|
|
32863
|
+
var import_viem16 = require("viem");
|
|
32732
32864
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
32733
32865
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
32734
32866
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
32735
32867
|
function assertAddress2(value, name) {
|
|
32736
|
-
if (!(0,
|
|
32868
|
+
if (!(0, import_viem16.isAddress)(value)) {
|
|
32737
32869
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32738
32870
|
}
|
|
32739
32871
|
}
|
|
@@ -32783,7 +32915,7 @@ async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
|
32783
32915
|
var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
32784
32916
|
|
|
32785
32917
|
// src/account/personal-server-registration.ts
|
|
32786
|
-
var
|
|
32918
|
+
var import_viem17 = require("viem");
|
|
32787
32919
|
var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
|
|
32788
32920
|
var AccountPersonalServerRegistrationError = class extends Error {
|
|
32789
32921
|
status;
|
|
@@ -32802,7 +32934,7 @@ function trimTrailingSlash(value) {
|
|
|
32802
32934
|
return value.replace(/\/+$/, "");
|
|
32803
32935
|
}
|
|
32804
32936
|
function assertAddress3(value, name) {
|
|
32805
|
-
if (!(0,
|
|
32937
|
+
if (!(0, import_viem17.isAddress)(value)) {
|
|
32806
32938
|
throw new Error(`${name} must be a valid EVM address`);
|
|
32807
32939
|
}
|
|
32808
32940
|
}
|
|
@@ -33066,7 +33198,7 @@ function accountOwnerBindingError(error) {
|
|
|
33066
33198
|
}
|
|
33067
33199
|
|
|
33068
33200
|
// src/protocol/grants.ts
|
|
33069
|
-
var
|
|
33201
|
+
var import_viem18 = require("viem");
|
|
33070
33202
|
function isHexString(value) {
|
|
33071
33203
|
return typeof value === "string" && value.startsWith("0x");
|
|
33072
33204
|
}
|
|
@@ -33111,7 +33243,7 @@ async function verifyGrantRegistration(input) {
|
|
|
33111
33243
|
}
|
|
33112
33244
|
let valid;
|
|
33113
33245
|
try {
|
|
33114
|
-
valid = await (0,
|
|
33246
|
+
valid = await (0, import_viem18.verifyTypedData)({
|
|
33115
33247
|
address: input.grantorAddress,
|
|
33116
33248
|
domain: grantRegistrationDomain(input.gatewayConfig),
|
|
33117
33249
|
types: GRANT_REGISTRATION_TYPES,
|
|
@@ -33146,8 +33278,8 @@ async function verifyGrantRegistration(input) {
|
|
|
33146
33278
|
}
|
|
33147
33279
|
|
|
33148
33280
|
// src/protocol/fee-registry.ts
|
|
33149
|
-
var
|
|
33150
|
-
var FEE_REGISTRY_ABI = (0,
|
|
33281
|
+
var import_viem19 = require("viem");
|
|
33282
|
+
var FEE_REGISTRY_ABI = (0, import_viem19.parseAbi)([
|
|
33151
33283
|
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
33152
33284
|
"function fees(bytes32 operation) view returns (Fee)",
|
|
33153
33285
|
"function operationKey(string name) pure returns (bytes32)"
|
|
@@ -33230,7 +33362,7 @@ async function getOpFee(client, config, opType, opts) {
|
|
|
33230
33362
|
}
|
|
33231
33363
|
|
|
33232
33364
|
// src/protocol/escrow-deposit.ts
|
|
33233
|
-
var
|
|
33365
|
+
var import_viem20 = require("viem");
|
|
33234
33366
|
var ESCROW_DEPOSIT_ABI = [
|
|
33235
33367
|
{
|
|
33236
33368
|
type: "function",
|
|
@@ -33255,14 +33387,14 @@ function escrowContractAddress(config) {
|
|
|
33255
33387
|
return config.contracts.dataPortabilityEscrow;
|
|
33256
33388
|
}
|
|
33257
33389
|
function encodeDepositNativeData(input) {
|
|
33258
|
-
return (0,
|
|
33390
|
+
return (0, import_viem20.encodeFunctionData)({
|
|
33259
33391
|
abi: ESCROW_DEPOSIT_ABI,
|
|
33260
33392
|
functionName: "depositNative",
|
|
33261
33393
|
args: [input.account]
|
|
33262
33394
|
});
|
|
33263
33395
|
}
|
|
33264
33396
|
function encodeDepositTokenData(input) {
|
|
33265
|
-
return (0,
|
|
33397
|
+
return (0, import_viem20.encodeFunctionData)({
|
|
33266
33398
|
abi: ESCROW_DEPOSIT_ABI,
|
|
33267
33399
|
functionName: "depositToken",
|
|
33268
33400
|
args: [input.account, input.token, input.amount]
|
|
@@ -33283,7 +33415,7 @@ function buildDepositTokenRequest(config, input) {
|
|
|
33283
33415
|
}
|
|
33284
33416
|
|
|
33285
33417
|
// src/protocol/data-point-status.ts
|
|
33286
|
-
var
|
|
33418
|
+
var import_viem21 = require("viem");
|
|
33287
33419
|
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
33288
33420
|
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
33289
33421
|
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
@@ -33307,7 +33439,7 @@ function dataRegistryContractAddress(config) {
|
|
|
33307
33439
|
return config.contracts.dataRegistry;
|
|
33308
33440
|
}
|
|
33309
33441
|
function encodeSetDataPointStatusData(input) {
|
|
33310
|
-
return (0,
|
|
33442
|
+
return (0, import_viem21.encodeFunctionData)({
|
|
33311
33443
|
abi: DATA_REGISTRY_STATUS_ABI,
|
|
33312
33444
|
functionName: "setStatus",
|
|
33313
33445
|
args: [input.scope, input.status]
|
|
@@ -33327,10 +33459,10 @@ function buildMarkDataPointUnavailableRequest(config, input) {
|
|
|
33327
33459
|
}
|
|
33328
33460
|
|
|
33329
33461
|
// src/protocol/data-point-deletion.ts
|
|
33330
|
-
var
|
|
33462
|
+
var import_viem23 = require("viem");
|
|
33331
33463
|
|
|
33332
33464
|
// src/protocol/lineage.ts
|
|
33333
|
-
var
|
|
33465
|
+
var import_viem22 = require("viem");
|
|
33334
33466
|
var import_zod = require("zod");
|
|
33335
33467
|
|
|
33336
33468
|
// src/protocol/personal-server-error-body.ts
|
|
@@ -33408,13 +33540,13 @@ function isDataPointId(value) {
|
|
|
33408
33540
|
return typeof value === "string" && DATA_POINT_ID_PATTERN.test(value);
|
|
33409
33541
|
}
|
|
33410
33542
|
function deriveDataPointId(ownerAddress, scope) {
|
|
33411
|
-
if (!(0,
|
|
33543
|
+
if (!(0, import_viem22.isAddress)(ownerAddress, { strict: false })) {
|
|
33412
33544
|
throw new Error(
|
|
33413
33545
|
`ownerAddress is not an EVM address: ${String(ownerAddress)}`
|
|
33414
33546
|
);
|
|
33415
33547
|
}
|
|
33416
|
-
return (0,
|
|
33417
|
-
(0,
|
|
33548
|
+
return (0, import_viem22.keccak256)(
|
|
33549
|
+
(0, import_viem22.encodeAbiParameters)(
|
|
33418
33550
|
[
|
|
33419
33551
|
{ name: "ownerAddress", type: "address" },
|
|
33420
33552
|
{ name: "scope", type: "string" }
|
|
@@ -33640,7 +33772,7 @@ var TOMBSTONE_METADATA_HASH_PREIMAGE = "vana.data-point.tombstone.metadata.v1";
|
|
|
33640
33772
|
var TOMBSTONE_DATA_HASH = "0x30c45ee72fe56d1927701316925ab7ceacd3b6f9267061735d59396f075c6222";
|
|
33641
33773
|
var TOMBSTONE_METADATA_HASH = "0xc5255a141acd6a2ae55971b62c0a85977c2511989dc114ad2abc2b7644f57d90";
|
|
33642
33774
|
function computeTombstoneHash(preimage) {
|
|
33643
|
-
return (0,
|
|
33775
|
+
return (0, import_viem23.keccak256)((0, import_viem23.stringToBytes)(preimage));
|
|
33644
33776
|
}
|
|
33645
33777
|
function isTombstoneHashes(dataHash, metadataHash) {
|
|
33646
33778
|
return typeof dataHash === "string" && typeof metadataHash === "string" && dataHash.toLowerCase() === TOMBSTONE_DATA_HASH && metadataHash.toLowerCase() === TOMBSTONE_METADATA_HASH;
|
|
@@ -33659,12 +33791,12 @@ function tombstoneDeletedAt(value) {
|
|
|
33659
33791
|
return typeof deletedAt === "string" ? deletedAt : null;
|
|
33660
33792
|
}
|
|
33661
33793
|
function assertAddress4(value, name) {
|
|
33662
|
-
if (!(0,
|
|
33794
|
+
if (!(0, import_viem23.isAddress)(value)) {
|
|
33663
33795
|
throw new Error(`${name} must be a valid EVM address`);
|
|
33664
33796
|
}
|
|
33665
33797
|
}
|
|
33666
33798
|
function assertUint256(value, name) {
|
|
33667
|
-
if (value < 0n || value >
|
|
33799
|
+
if (value < 0n || value > import_viem23.maxUint256) {
|
|
33668
33800
|
throw new Error(`${name} must fit in uint256, got ${value}`);
|
|
33669
33801
|
}
|
|
33670
33802
|
}
|
|
@@ -33767,7 +33899,7 @@ async function deleteDataPoint(input) {
|
|
|
33767
33899
|
}
|
|
33768
33900
|
currentVersion = parseExpectedVersion(record.expectedVersion);
|
|
33769
33901
|
}
|
|
33770
|
-
if (currentVersion < 0n || currentVersion >=
|
|
33902
|
+
if (currentVersion < 0n || currentVersion >= import_viem23.maxUint256) {
|
|
33771
33903
|
throw new Error(
|
|
33772
33904
|
`currentVersion ${currentVersion} cannot be incremented to a uint256 tombstone version`
|
|
33773
33905
|
);
|
|
@@ -34075,12 +34207,12 @@ function tryGrantPermissions(scopes) {
|
|
|
34075
34207
|
|
|
34076
34208
|
// src/protocol/personal-server-write.ts
|
|
34077
34209
|
var import_sha26 = require("@noble/hashes/sha2");
|
|
34078
|
-
var
|
|
34210
|
+
var import_viem25 = require("viem");
|
|
34079
34211
|
var import_zod4 = require("zod");
|
|
34080
34212
|
|
|
34081
34213
|
// src/protocol/write-request.ts
|
|
34082
34214
|
var import_sha25 = require("@noble/hashes/sha2");
|
|
34083
|
-
var
|
|
34215
|
+
var import_viem24 = require("viem");
|
|
34084
34216
|
function normalizeBaseUrl2(url) {
|
|
34085
34217
|
return url.replace(/\/+$/, "");
|
|
34086
34218
|
}
|
|
@@ -34147,14 +34279,14 @@ function freshProofNonce() {
|
|
|
34147
34279
|
return webCrypto.randomUUID();
|
|
34148
34280
|
}
|
|
34149
34281
|
if (typeof webCrypto?.getRandomValues === "function") {
|
|
34150
|
-
return (0,
|
|
34282
|
+
return (0, import_viem24.bytesToHex)(webCrypto.getRandomValues(new Uint8Array(16)));
|
|
34151
34283
|
}
|
|
34152
34284
|
throw new WriteRequestError(
|
|
34153
34285
|
"No secure random source available to build a proof nonce; provide a crypto global"
|
|
34154
34286
|
);
|
|
34155
34287
|
}
|
|
34156
34288
|
function proofKeyFor(parts) {
|
|
34157
|
-
return (0,
|
|
34289
|
+
return (0, import_viem24.bytesToHex)(
|
|
34158
34290
|
(0, import_sha25.sha256)(
|
|
34159
34291
|
new TextEncoder().encode(
|
|
34160
34292
|
JSON.stringify([
|
|
@@ -34162,7 +34294,7 @@ function proofKeyFor(parts) {
|
|
|
34162
34294
|
parts.method,
|
|
34163
34295
|
parts.uri,
|
|
34164
34296
|
parts.grantId,
|
|
34165
|
-
parts.signedBytes ? (0,
|
|
34297
|
+
parts.signedBytes ? (0, import_viem24.bytesToHex)((0, import_sha25.sha256)(parts.signedBytes)) : ""
|
|
34166
34298
|
])
|
|
34167
34299
|
)
|
|
34168
34300
|
)
|
|
@@ -34349,7 +34481,7 @@ function binaryWriteSignedBytes(input) {
|
|
|
34349
34481
|
mimeType: normalizeBinaryMimeType(input.contentType),
|
|
34350
34482
|
...input.filename ? { filename: input.filename } : {},
|
|
34351
34483
|
sizeBytes: input.bytes.length,
|
|
34352
|
-
contentHash: (0,
|
|
34484
|
+
contentHash: (0, import_viem25.bytesToHex)((0, import_sha26.sha256)(input.bytes)),
|
|
34353
34485
|
encoding: "base64",
|
|
34354
34486
|
content: toBase64(input.bytes),
|
|
34355
34487
|
...metadata !== void 0 ? { metadata } : {}
|
|
@@ -34397,7 +34529,7 @@ function normalizeLineage(lineage, derivedScope) {
|
|
|
34397
34529
|
for (const entry of lineage) {
|
|
34398
34530
|
let id;
|
|
34399
34531
|
if (isLineagePair(entry)) {
|
|
34400
|
-
if (!(0,
|
|
34532
|
+
if (!(0, import_viem25.isAddress)(entry.ownerAddress, { strict: false })) {
|
|
34401
34533
|
throw new WriteRequestError(
|
|
34402
34534
|
"lineage source ownerAddress must be an EVM address",
|
|
34403
34535
|
{ ownerAddress: entry.ownerAddress }
|
|
@@ -34662,6 +34794,13 @@ var QUESTION_STATUSES = [
|
|
|
34662
34794
|
"failed",
|
|
34663
34795
|
"stale"
|
|
34664
34796
|
];
|
|
34797
|
+
var DERIVATIVE_ERROR_CODES = [
|
|
34798
|
+
"inference_unavailable",
|
|
34799
|
+
"source_missing",
|
|
34800
|
+
"grant_invalid",
|
|
34801
|
+
"internal"
|
|
34802
|
+
];
|
|
34803
|
+
var DerivativeErrorCodeSchema = import_zod5.z.enum(DERIVATIVE_ERROR_CODES);
|
|
34665
34804
|
var QuestionStatusSchema = import_zod5.z.enum(QUESTION_STATUSES);
|
|
34666
34805
|
var QuestionRegisteredBySchema = import_zod5.z.union([
|
|
34667
34806
|
import_zod5.z.object({ kind: import_zod5.z.literal("owner") }),
|
|
@@ -34683,6 +34822,14 @@ var DerivativeQuestionSchema = import_zod5.z.object({
|
|
|
34683
34822
|
status: QuestionStatusSchema,
|
|
34684
34823
|
/** A short reason, set only while `status` is `failed`. */
|
|
34685
34824
|
error: nullableString,
|
|
34825
|
+
/**
|
|
34826
|
+
* The coarse failure class behind `error`, set only while `status` is
|
|
34827
|
+
* `failed`. `null` from a Personal Server that predates the class
|
|
34828
|
+
* (`personal-server-ts` before the status route).
|
|
34829
|
+
*/
|
|
34830
|
+
errorCode: DerivativeErrorCodeSchema.nullish().transform(
|
|
34831
|
+
(value) => value ?? null
|
|
34832
|
+
),
|
|
34686
34833
|
createdAt: import_zod5.z.string(),
|
|
34687
34834
|
updatedAt: nullableString,
|
|
34688
34835
|
/** When the last compute finished, or `null` while `pending`. */
|
|
@@ -34815,6 +34962,7 @@ async function questionErrorFromResponse(response, body) {
|
|
|
34815
34962
|
);
|
|
34816
34963
|
}
|
|
34817
34964
|
}
|
|
34965
|
+
var personalServerErrorFromQuestionResponse = questionErrorFromResponse;
|
|
34818
34966
|
async function sendOnce(params, resolved, session, spec, bodyBytes) {
|
|
34819
34967
|
return sendWithFreshProof(
|
|
34820
34968
|
spec.label,
|
|
@@ -35094,6 +35242,166 @@ async function askPersonalServer(params) {
|
|
|
35094
35242
|
return { registration, record };
|
|
35095
35243
|
}
|
|
35096
35244
|
|
|
35245
|
+
// src/protocol/derivative-status.ts
|
|
35246
|
+
var import_zod6 = require("zod");
|
|
35247
|
+
var DERIVATIVE_STATUS_PATH = "/v1/derivatives/status";
|
|
35248
|
+
var DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS = 12e4;
|
|
35249
|
+
var DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS = 2e3;
|
|
35250
|
+
var nullable = (schema) => schema.nullish().transform((value) => value ?? null);
|
|
35251
|
+
var DerivativeStatusSchema = import_zod6.z.object({
|
|
35252
|
+
derivedScope: import_zod6.z.string().min(1),
|
|
35253
|
+
status: QuestionStatusSchema,
|
|
35254
|
+
/** When the last compute finished, or `null` if none ever has. */
|
|
35255
|
+
lastComputedAt: nullable(import_zod6.z.string()),
|
|
35256
|
+
/** Local version of the derived record the last compute wrote. */
|
|
35257
|
+
derivedVersion: nullable(import_zod6.z.number()),
|
|
35258
|
+
derivedCollectedAt: nullable(import_zod6.z.string()),
|
|
35259
|
+
/** The failure class; `null` unless `status` is `failed`. */
|
|
35260
|
+
errorCode: nullable(DerivativeErrorCodeSchema),
|
|
35261
|
+
/**
|
|
35262
|
+
* Seconds until the Personal Server's next automatic retry, or `null` when
|
|
35263
|
+
* none is pending or running — the terminal signature. Poll on this cadence
|
|
35264
|
+
* rather than guessing one.
|
|
35265
|
+
*/
|
|
35266
|
+
retryAfterSeconds: nullable(import_zod6.z.number())
|
|
35267
|
+
});
|
|
35268
|
+
function derivativeStatusTarget(derivedScope) {
|
|
35269
|
+
return `${DERIVATIVE_STATUS_PATH}?derivedScope=${encodeURIComponent(derivedScope)}`;
|
|
35270
|
+
}
|
|
35271
|
+
function normalizeBaseUrl3(url) {
|
|
35272
|
+
return url.replace(/\/+$/, "");
|
|
35273
|
+
}
|
|
35274
|
+
function resolveFetch3(fetchFn) {
|
|
35275
|
+
const resolved = fetchFn ?? globalThis.fetch;
|
|
35276
|
+
if (resolved === void 0) {
|
|
35277
|
+
throw new WriteRequestError("No fetch implementation available");
|
|
35278
|
+
}
|
|
35279
|
+
return resolved;
|
|
35280
|
+
}
|
|
35281
|
+
function requireDerivedScope(derivedScope) {
|
|
35282
|
+
if (typeof derivedScope !== "string" || derivedScope.length === 0) {
|
|
35283
|
+
throw new WriteRequestError("derivedScope is required");
|
|
35284
|
+
}
|
|
35285
|
+
return derivedScope;
|
|
35286
|
+
}
|
|
35287
|
+
function sleep3(ms, signal) {
|
|
35288
|
+
if (ms <= 0) return Promise.resolve();
|
|
35289
|
+
return new Promise((resolve, reject) => {
|
|
35290
|
+
const timer = setTimeout(() => {
|
|
35291
|
+
signal?.removeEventListener("abort", onAbort);
|
|
35292
|
+
resolve();
|
|
35293
|
+
}, ms);
|
|
35294
|
+
const onAbort = () => {
|
|
35295
|
+
clearTimeout(timer);
|
|
35296
|
+
reject(abortError2(signal));
|
|
35297
|
+
};
|
|
35298
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
35299
|
+
});
|
|
35300
|
+
}
|
|
35301
|
+
function timeoutError(latest, timeoutMs) {
|
|
35302
|
+
return new DerivativeQuestionTimeoutError(
|
|
35303
|
+
`Derived scope ${latest.derivedScope} was still ${latest.status} after ${timeoutMs}ms`,
|
|
35304
|
+
{
|
|
35305
|
+
derivedScope: latest.derivedScope,
|
|
35306
|
+
status: latest.status,
|
|
35307
|
+
errorCode: latest.errorCode,
|
|
35308
|
+
retryAfterSeconds: latest.retryAfterSeconds,
|
|
35309
|
+
timeoutMs
|
|
35310
|
+
}
|
|
35311
|
+
);
|
|
35312
|
+
}
|
|
35313
|
+
function abortError2(signal) {
|
|
35314
|
+
const reason = signal?.reason;
|
|
35315
|
+
return reason instanceof Error ? reason : new WriteRequestError("Derivative status wait was aborted");
|
|
35316
|
+
}
|
|
35317
|
+
function isDerivativeStatusSettled(status) {
|
|
35318
|
+
if (status.status === "ready") return true;
|
|
35319
|
+
return status.status === "failed" && status.retryAfterSeconds === null;
|
|
35320
|
+
}
|
|
35321
|
+
async function getDerivativeStatus(params) {
|
|
35322
|
+
const derivedScope = requireDerivedScope(params.derivedScope);
|
|
35323
|
+
const fetchFn = resolveFetch3(params.fetch);
|
|
35324
|
+
const baseUrl = normalizeBaseUrl3(params.personalServerUrl);
|
|
35325
|
+
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
35326
|
+
const headers = new Headers(params.headers);
|
|
35327
|
+
headers.set(
|
|
35328
|
+
"Authorization",
|
|
35329
|
+
await buildWeb3SignedHeader({
|
|
35330
|
+
signMessage: signer.signMessage,
|
|
35331
|
+
aud: params.audience ?? baseUrl,
|
|
35332
|
+
method: "GET",
|
|
35333
|
+
uri: DERIVATIVE_STATUS_PATH,
|
|
35334
|
+
grantId: params.grantId
|
|
35335
|
+
})
|
|
35336
|
+
);
|
|
35337
|
+
let response;
|
|
35338
|
+
try {
|
|
35339
|
+
response = await fetchFn(
|
|
35340
|
+
`${baseUrl}${derivativeStatusTarget(derivedScope)}`,
|
|
35341
|
+
{
|
|
35342
|
+
method: "GET",
|
|
35343
|
+
headers,
|
|
35344
|
+
...params.signal ? { signal: params.signal } : {}
|
|
35345
|
+
}
|
|
35346
|
+
);
|
|
35347
|
+
} catch (err) {
|
|
35348
|
+
throw new WriteTransportError(
|
|
35349
|
+
`Derivative status read failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
35350
|
+
1,
|
|
35351
|
+
err
|
|
35352
|
+
);
|
|
35353
|
+
}
|
|
35354
|
+
if (!response.ok) {
|
|
35355
|
+
throw await personalServerErrorFromQuestionResponse(
|
|
35356
|
+
response
|
|
35357
|
+
);
|
|
35358
|
+
}
|
|
35359
|
+
let body;
|
|
35360
|
+
try {
|
|
35361
|
+
body = await response.json();
|
|
35362
|
+
} catch (err) {
|
|
35363
|
+
throw new DerivativeQuestionRejectedError(
|
|
35364
|
+
"Derivative status response is not JSON",
|
|
35365
|
+
response.status,
|
|
35366
|
+
null,
|
|
35367
|
+
{ cause: err instanceof Error ? err.message : String(err) }
|
|
35368
|
+
);
|
|
35369
|
+
}
|
|
35370
|
+
const parsed = DerivativeStatusSchema.safeParse(body);
|
|
35371
|
+
if (!parsed.success) {
|
|
35372
|
+
throw new DerivativeQuestionRejectedError(
|
|
35373
|
+
"Derivative status response is not a status view",
|
|
35374
|
+
response.status,
|
|
35375
|
+
null,
|
|
35376
|
+
{ issues: parsed.error.issues }
|
|
35377
|
+
);
|
|
35378
|
+
}
|
|
35379
|
+
return parsed.data;
|
|
35380
|
+
}
|
|
35381
|
+
async function waitForDerivativeStatus(params) {
|
|
35382
|
+
const timeoutMs = Math.max(
|
|
35383
|
+
0,
|
|
35384
|
+
params.timeoutMs ?? DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS
|
|
35385
|
+
);
|
|
35386
|
+
const pollIntervalMs = Math.max(
|
|
35387
|
+
0,
|
|
35388
|
+
params.pollIntervalMs ?? DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS
|
|
35389
|
+
);
|
|
35390
|
+
const deadline = Date.now() + timeoutMs;
|
|
35391
|
+
for (; ; ) {
|
|
35392
|
+
if (params.signal?.aborted) throw abortError2(params.signal);
|
|
35393
|
+
const latest = await getDerivativeStatus(params);
|
|
35394
|
+
if (isDerivativeStatusSettled(latest)) return latest;
|
|
35395
|
+
const remaining = deadline - Date.now();
|
|
35396
|
+
if (remaining <= 0) throw timeoutError(latest, timeoutMs);
|
|
35397
|
+
const waitMs = latest.retryAfterSeconds === null ? pollIntervalMs : latest.retryAfterSeconds * 1e3;
|
|
35398
|
+
if (waitMs > remaining) {
|
|
35399
|
+
throw timeoutError(latest, timeoutMs);
|
|
35400
|
+
}
|
|
35401
|
+
await sleep3(waitMs, params.signal);
|
|
35402
|
+
}
|
|
35403
|
+
}
|
|
35404
|
+
|
|
35097
35405
|
// src/protocol/gateway.ts
|
|
35098
35406
|
function withGrantPermissions(grant) {
|
|
35099
35407
|
const stripped = { ...grant };
|
|
@@ -36175,9 +36483,13 @@ async function parsePSError(response) {
|
|
|
36175
36483
|
ContractNotFoundError,
|
|
36176
36484
|
DATA_ACCESS_OP_TYPE,
|
|
36177
36485
|
DATA_REGISTRY_STATUS_ABI,
|
|
36486
|
+
DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS,
|
|
36487
|
+
DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS,
|
|
36178
36488
|
DEFAULT_QUESTION_POLL_INTERVAL_MS,
|
|
36179
36489
|
DEFAULT_QUESTION_TIMEOUT_MS,
|
|
36490
|
+
DERIVATIVE_ERROR_CODES,
|
|
36180
36491
|
DERIVATIVE_QUESTIONS_PATH,
|
|
36492
|
+
DERIVATIVE_STATUS_PATH,
|
|
36181
36493
|
DataFileEnvelopeSchema,
|
|
36182
36494
|
DataPointDeletedError,
|
|
36183
36495
|
DataPointNotFoundError,
|
|
@@ -36186,6 +36498,7 @@ async function parsePSError(response) {
|
|
|
36186
36498
|
DerivativeComputeUnavailableError,
|
|
36187
36499
|
DerivativeCycleError,
|
|
36188
36500
|
DerivativeDerivedScopeRequiredError,
|
|
36501
|
+
DerivativeErrorCodeSchema,
|
|
36189
36502
|
DerivativeQuestionFailedError,
|
|
36190
36503
|
DerivativeQuestionInvalidError,
|
|
36191
36504
|
DerivativeQuestionNotFoundError,
|
|
@@ -36193,8 +36506,12 @@ async function parsePSError(response) {
|
|
|
36193
36506
|
DerivativeQuestionSchema,
|
|
36194
36507
|
DerivativeQuestionTimeoutError,
|
|
36195
36508
|
DerivativeSourceNotGrantedError,
|
|
36509
|
+
DerivativeStatusSchema,
|
|
36196
36510
|
DropboxStorage,
|
|
36197
36511
|
ECIESError,
|
|
36512
|
+
ENCLAVE_IDENTITY_EVIDENCE_VERSION,
|
|
36513
|
+
ENCLAVE_TRUST_ANCHORS,
|
|
36514
|
+
ENCLAVE_WALLET_PURPOSE,
|
|
36198
36515
|
ESCROW_DEPOSIT_ABI,
|
|
36199
36516
|
ExpiredTokenError,
|
|
36200
36517
|
FEE_REGISTRY_ABI,
|
|
@@ -36216,6 +36533,7 @@ async function parsePSError(response) {
|
|
|
36216
36533
|
LineageNodeSchema,
|
|
36217
36534
|
LineageReadError,
|
|
36218
36535
|
MASTER_KEY_MESSAGE,
|
|
36536
|
+
MASTER_SIGNATURE_DELIVERY_VERSION,
|
|
36219
36537
|
MAX_LINEAGE_SOURCES,
|
|
36220
36538
|
MAX_QUESTION_CHARS,
|
|
36221
36539
|
MAX_QUESTION_MODEL_CHARS,
|
|
@@ -36253,6 +36571,7 @@ async function parsePSError(response) {
|
|
|
36253
36571
|
RedactedLineageNodeSchema,
|
|
36254
36572
|
RelayerError,
|
|
36255
36573
|
SCOPE_ACTIONS,
|
|
36574
|
+
SEALED_ENVELOPE_VERSION,
|
|
36256
36575
|
SERVER_REGISTRATION_TYPES,
|
|
36257
36576
|
ScopeSchema,
|
|
36258
36577
|
SerializationError,
|
|
@@ -36265,6 +36584,7 @@ async function parsePSError(response) {
|
|
|
36265
36584
|
TOMBSTONE_METADATA_HASH,
|
|
36266
36585
|
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
36267
36586
|
TransactionPendingError,
|
|
36587
|
+
USER_PS_ID_DOMAIN,
|
|
36268
36588
|
UserRejectedRequestError,
|
|
36269
36589
|
VanaError,
|
|
36270
36590
|
VanaStorage,
|
|
@@ -36283,6 +36603,7 @@ async function parsePSError(response) {
|
|
|
36283
36603
|
WriteSessionExpiredError,
|
|
36284
36604
|
WriteTransportError,
|
|
36285
36605
|
WriteUnauthorizedError,
|
|
36606
|
+
appRootPreimage,
|
|
36286
36607
|
askPersonalServer,
|
|
36287
36608
|
assertDerivedScopeNaming,
|
|
36288
36609
|
assertValidPkceVerifier,
|
|
@@ -36296,6 +36617,7 @@ async function parsePSError(response) {
|
|
|
36296
36617
|
buildEscrowPaymentHeader,
|
|
36297
36618
|
buildGrantPaymentHeader,
|
|
36298
36619
|
buildMarkDataPointUnavailableRequest,
|
|
36620
|
+
buildMasterSignatureDelivery,
|
|
36299
36621
|
buildPersonalServerDataReadRequest,
|
|
36300
36622
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
36301
36623
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
@@ -36328,6 +36650,7 @@ async function parsePSError(response) {
|
|
|
36328
36650
|
decryptWithPassword,
|
|
36329
36651
|
deleteDataPoint,
|
|
36330
36652
|
deleteQuestion,
|
|
36653
|
+
derivativeStatusTarget,
|
|
36331
36654
|
deriveDataPointId,
|
|
36332
36655
|
deriveMasterKey,
|
|
36333
36656
|
deriveScopeKey,
|
|
@@ -36338,6 +36661,7 @@ async function parsePSError(response) {
|
|
|
36338
36661
|
encodeDepositTokenData,
|
|
36339
36662
|
encodeSetDataPointStatusData,
|
|
36340
36663
|
encodeWriteMetadataHeader,
|
|
36664
|
+
encryptMasterSignatureDelivery,
|
|
36341
36665
|
encryptWithPassword,
|
|
36342
36666
|
escrowContractAddress,
|
|
36343
36667
|
escrowPaymentDomain,
|
|
@@ -36351,6 +36675,7 @@ async function parsePSError(response) {
|
|
|
36351
36675
|
getContractAddress,
|
|
36352
36676
|
getContractController,
|
|
36353
36677
|
getContractInfo,
|
|
36678
|
+
getDerivativeStatus,
|
|
36354
36679
|
getFee,
|
|
36355
36680
|
getGatewayLineage,
|
|
36356
36681
|
getLineage,
|
|
@@ -36366,10 +36691,12 @@ async function parsePSError(response) {
|
|
|
36366
36691
|
isDataPointId,
|
|
36367
36692
|
isDataPointTombstone,
|
|
36368
36693
|
isDataPortabilityGatewayConfig,
|
|
36694
|
+
isDerivativeStatusSettled,
|
|
36369
36695
|
isECIESEncrypted,
|
|
36370
36696
|
isPlatformSupported,
|
|
36371
36697
|
isRedactedLineageNode,
|
|
36372
36698
|
isTombstoneHashes,
|
|
36699
|
+
kmsIssuedPreimage,
|
|
36373
36700
|
listQuestions,
|
|
36374
36701
|
mainnetServices,
|
|
36375
36702
|
moksha,
|
|
@@ -36409,10 +36736,13 @@ async function parsePSError(response) {
|
|
|
36409
36736
|
toDirectPaymentReceipt,
|
|
36410
36737
|
tombstoneDeletedAt,
|
|
36411
36738
|
tryGrantPermissions,
|
|
36739
|
+
userPsId,
|
|
36412
36740
|
vanaMainnet,
|
|
36741
|
+
verifyEnclaveIdentityEvidence,
|
|
36413
36742
|
verifyGrantRegistration,
|
|
36414
36743
|
verifyPkceChallenge,
|
|
36415
36744
|
verifyWeb3Signed,
|
|
36745
|
+
waitForDerivativeStatus,
|
|
36416
36746
|
waitForQuestion,
|
|
36417
36747
|
writeData,
|
|
36418
36748
|
writePersonalServerData
|