@opendatalabs/vana-sdk 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +47 -0
  2. package/dist/direct/access-request-client.cjs +3 -0
  3. package/dist/direct/access-request-client.cjs.map +1 -1
  4. package/dist/direct/access-request-client.js +3 -0
  5. package/dist/direct/access-request-client.js.map +1 -1
  6. package/dist/direct/controller.cjs +43 -2
  7. package/dist/direct/controller.cjs.map +1 -1
  8. package/dist/direct/controller.d.ts +33 -0
  9. package/dist/direct/controller.js +46 -2
  10. package/dist/direct/controller.js.map +1 -1
  11. package/dist/direct/grant-union.cjs +129 -0
  12. package/dist/direct/grant-union.cjs.map +1 -0
  13. package/dist/direct/grant-union.d.ts +138 -0
  14. package/dist/direct/grant-union.js +102 -0
  15. package/dist/direct/grant-union.js.map +1 -0
  16. package/dist/direct/grant-union.test.d.ts +1 -0
  17. package/dist/direct/types.cjs.map +1 -1
  18. package/dist/direct/types.d.ts +43 -0
  19. package/dist/direct/types.js.map +1 -1
  20. package/dist/errors.cjs +2 -2
  21. package/dist/errors.cjs.map +1 -1
  22. package/dist/errors.d.ts +7 -1
  23. package/dist/errors.js +2 -2
  24. package/dist/errors.js.map +1 -1
  25. package/dist/index.browser.d.ts +2 -1
  26. package/dist/index.browser.js +99 -0
  27. package/dist/index.browser.js.map +3 -3
  28. package/dist/index.node.cjs +945 -418
  29. package/dist/index.node.cjs.map +4 -4
  30. package/dist/index.node.d.ts +2 -1
  31. package/dist/index.node.js +801 -276
  32. package/dist/index.node.js.map +4 -4
  33. package/dist/protocol/jobs-client.cjs +196 -25
  34. package/dist/protocol/jobs-client.cjs.map +1 -1
  35. package/dist/protocol/jobs-client.d.ts +39 -1
  36. package/dist/protocol/jobs-client.js +199 -26
  37. package/dist/protocol/jobs-client.js.map +1 -1
  38. package/dist/protocol/jobs.cjs.map +1 -1
  39. package/dist/protocol/jobs.d.ts +71 -1
  40. package/dist/protocol/jobs.js.map +1 -1
  41. package/dist/server.cjs +9 -0
  42. package/dist/server.cjs.map +1 -1
  43. package/dist/server.d.ts +2 -1
  44. package/dist/server.js +10 -0
  45. package/dist/server.js.map +1 -1
  46. package/package.json +1 -1
@@ -1205,10 +1205,10 @@ __export(index_node_exports, {
1205
1205
  ENCLAVE_IDENTITY_EVIDENCE_VERSION: () => ENCLAVE_IDENTITY_EVIDENCE_VERSION,
1206
1206
  ENCLAVE_TRUST_ANCHORS: () => ENCLAVE_TRUST_ANCHORS,
1207
1207
  ENCLAVE_WALLET_PURPOSE: () => ENCLAVE_WALLET_PURPOSE,
1208
- ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
1208
+ ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI,
1209
1209
  EscrowWithdrawalLifecycleError: () => EscrowWithdrawalLifecycleError,
1210
1210
  EscrowWithdrawalRejectionError: () => EscrowWithdrawalRejectionError,
1211
- ExpiredTokenError: () => import_errors14.ExpiredTokenError,
1211
+ ExpiredTokenError: () => import_errors16.ExpiredTokenError,
1212
1212
  FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
1213
1213
  GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
1214
1214
  GRANT_OP_TYPE: () => GRANT_OP_TYPE,
@@ -1218,7 +1218,7 @@ __export(index_node_exports, {
1218
1218
  InMemoryTokenStore: () => InMemoryTokenStore,
1219
1219
  IngestResponseSchema: () => IngestResponseSchema,
1220
1220
  InvalidScopeEntryError: () => InvalidScopeEntryError,
1221
- InvalidSignatureError: () => import_errors14.InvalidSignatureError,
1221
+ InvalidSignatureError: () => import_errors16.InvalidSignatureError,
1222
1222
  IpfsStorage: () => IpfsStorage,
1223
1223
  JOB_OPERATIONS: () => JOB_OPERATIONS,
1224
1224
  JOB_PROTOCOL_VERSION: () => JOB_PROTOCOL_VERSION,
@@ -1242,7 +1242,7 @@ __export(index_node_exports, {
1242
1242
  MAX_QUESTION_MODEL_CHARS: () => MAX_QUESTION_MODEL_CHARS,
1243
1243
  MAX_QUESTION_SOURCE_SCOPES: () => MAX_QUESTION_SOURCE_SCOPES,
1244
1244
  MAX_WAIT_SECONDS: () => MAX_WAIT_SECONDS,
1245
- MissingAuthError: () => import_errors14.MissingAuthError,
1245
+ MissingAuthError: () => import_errors16.MissingAuthError,
1246
1246
  NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
1247
1247
  NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
1248
1248
  NodeECIESProvider: () => NodeECIESUint8Provider,
@@ -1351,6 +1351,7 @@ __export(index_node_exports, {
1351
1351
  encryptWithPassword: () => encryptWithPassword,
1352
1352
  escrowContractAddress: () => escrowContractAddress,
1353
1353
  escrowPaymentDomain: () => escrowPaymentDomain,
1354
+ findLiveGrant: () => findLiveGrant,
1354
1355
  formatScopeEntry: () => formatScopeEntry,
1355
1356
  gatewayLineagePath: () => gatewayLineagePath,
1356
1357
  generatePkceVerifier: () => generatePkceVerifier,
@@ -1384,7 +1385,9 @@ __export(index_node_exports, {
1384
1385
  isTombstoneHashes: () => isTombstoneHashes,
1385
1386
  kmsIssuedPreimage: () => kmsIssuedPreimage,
1386
1387
  listQuestions: () => listQuestions,
1388
+ liveGrantScopes: () => liveGrantScopes,
1387
1389
  mainnetServices: () => mainnetServices,
1390
+ mergeWithLiveGrant: () => mergeWithLiveGrant,
1388
1391
  moksha: () => moksha,
1389
1392
  mokshaServices: () => mokshaServices,
1390
1393
  mokshaTestnet: () => mokshaTestnet2,
@@ -1428,6 +1431,7 @@ __export(index_node_exports, {
1428
1431
  toDirectPaymentReceipt: () => toDirectPaymentReceipt,
1429
1432
  tombstoneDeletedAt: () => tombstoneDeletedAt,
1430
1433
  tryGrantPermissions: () => tryGrantPermissions,
1434
+ unionGrantScopes: () => unionGrantScopes,
1431
1435
  userPsId: () => userPsId,
1432
1436
  vanaMainnet: () => vanaMainnet2,
1433
1437
  verifyEnclaveIdentityEvidence: () => verifyEnclaveIdentityEvidence,
@@ -31922,7 +31926,7 @@ async function verifyWeb3Signed(params) {
31922
31926
  }
31923
31927
 
31924
31928
  // src/index.node.ts
31925
- var import_errors14 = require("./auth/errors.cjs");
31929
+ var import_errors16 = require("./auth/errors.cjs");
31926
31930
 
31927
31931
  // src/auth/pkce.ts
31928
31932
  var PKCE_VERIFIER_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
@@ -32547,7 +32551,7 @@ var MAX_JOB_DEADLINE_SECONDS = 3600;
32547
32551
  // src/protocol/jobs-client.ts
32548
32552
  var import_node_crypto = require("node:crypto");
32549
32553
  var import_sha26 = require("@noble/hashes/sha2");
32550
- var import_viem16 = require("viem");
32554
+ var import_viem17 = require("viem");
32551
32555
  var import_accounts2 = require("viem/accounts");
32552
32556
 
32553
32557
  // src/crypto/envelope/job.ts
@@ -33324,6 +33328,517 @@ async function openJobResult(sealedBytes, builderPrivateKey, ecies, expect) {
33324
33328
 
33325
33329
  // src/protocol/jobs-client.ts
33326
33330
  var import_errors3 = require("./errors.cjs");
33331
+ var import_errors4 = require("./direct/errors.cjs");
33332
+
33333
+ // src/config/contracts.config.ts
33334
+ var CONTRACTS2 = {
33335
+ // ========================================
33336
+ // DATA PORTABILITY CONTRACTS
33337
+ // ========================================
33338
+ DataPortabilityEscrow: {
33339
+ addresses: {
33340
+ 14800: "0x07d7769081adc3a3DBe91f5E4B98E9A5a6B292e3",
33341
+ 1480: "0x07d7769081adc3a3DBe91f5E4B98E9A5a6B292e3"
33342
+ }
33343
+ },
33344
+ FeeRegistry: {
33345
+ addresses: {
33346
+ 14800: "0xb4FA18443E0FA6cdC0280D20b8cCDB2377D13Bf2",
33347
+ 1480: "0xb4FA18443E0FA6cdC0280D20b8cCDB2377D13Bf2"
33348
+ }
33349
+ },
33350
+ // V2 deployment (DataPortabilityPermissionsV2Proxy). The gateway is the source
33351
+ // of truth for which deployment is live; verify with
33352
+ // `cast call <address> "eip712Domain()(bytes1,string,string,uint256,address,bytes32,uint256[])"`
33353
+ // which must return the domain name "Vana Data Portability".
33354
+ DataPortabilityPermissions: {
33355
+ addresses: {
33356
+ 14800: "0x4d3FA76064D88e0454cFc4CaD7e5FeC3e3124011",
33357
+ 1480: "0x4d3FA76064D88e0454cFc4CaD7e5FeC3e3124011"
33358
+ }
33359
+ },
33360
+ // V2 deployment (DataPortabilityServersV2Proxy) on both chains.
33361
+ DataPortabilityServers: {
33362
+ addresses: {
33363
+ 14800: "0xCae2CE0e9caa6643ed28186cF57bd40Bd9E17Eab",
33364
+ 1480: "0xCae2CE0e9caa6643ed28186cF57bd40Bd9E17Eab"
33365
+ }
33366
+ },
33367
+ DataPortabilityGrantees: {
33368
+ addresses: {
33369
+ 14800: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234",
33370
+ 1480: "0x8325C0A0948483EdA023A1A2Fd895e62C5131234"
33371
+ }
33372
+ },
33373
+ DataRegistry: {
33374
+ addresses: {
33375
+ 14800: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C",
33376
+ 1480: "0x8C8788f98385F6ba1adD4234e551ABba0f82Cb7C"
33377
+ }
33378
+ },
33379
+ // ========================================
33380
+ // COMPUTING INFRASTRUCTURE
33381
+ // ========================================
33382
+ ComputeEngine: {
33383
+ addresses: {
33384
+ 14800: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd",
33385
+ 1480: "0xb2BFe33FA420c45F1Cf1287542ad81ae935447bd"
33386
+ }
33387
+ },
33388
+ ComputeEngineTreasury: {
33389
+ addresses: {
33390
+ 14800: "0xceB33C501B624D984bD1Ed3298f6D1d8F7CE03d1",
33391
+ 1480: "0xceB33C501B624D984bD1Ed3298f6D1d8F7CE03d1"
33392
+ },
33393
+ discovery: {
33394
+ parent: "ComputeEngine",
33395
+ getter: "computeEngineTreasury"
33396
+ }
33397
+ },
33398
+ QueryEngine: {
33399
+ addresses: {
33400
+ 14800: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490",
33401
+ 1480: "0xd25Eb66EA2452cf3238A2eC6C1FD1B7F5B320490"
33402
+ }
33403
+ },
33404
+ VanaTreasury: {
33405
+ addresses: {
33406
+ 14800: "0x8B32Ef32f22e72cc25D53f6E858f57cAe7E198f9",
33407
+ 1480: "0x8B32Ef32f22e72cc25D53f6E858f57cAe7E198f9"
33408
+ },
33409
+ discovery: {
33410
+ parent: "QueryEngine",
33411
+ getter: "queryEngineTreasury"
33412
+ }
33413
+ },
33414
+ DataRefinerRegistry: {
33415
+ addresses: {
33416
+ 14800: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c",
33417
+ 1480: "0x93c3EF89369fDcf08Be159D9DeF0F18AB6Be008c"
33418
+ }
33419
+ },
33420
+ ComputeInstructionRegistry: {
33421
+ addresses: {
33422
+ 14800: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5",
33423
+ 1480: "0x5786B12b4c6Ba2bFAF0e77Ed30Bf6d32805563A5"
33424
+ }
33425
+ },
33426
+ // ========================================
33427
+ // TEE POOLS (Canonical Deployments)
33428
+ // ========================================
33429
+ TeePoolPhala: {
33430
+ addresses: {
33431
+ 14800: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A",
33432
+ 1480: "0xE8EC6BD73b23Ad40E6B9a6f4bD343FAc411bD99A"
33433
+ }
33434
+ },
33435
+ TeePoolEphemeralStandard: {
33436
+ addresses: {
33437
+ 14800: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A",
33438
+ 1480: "0xe124bae846D5ec157f75Bd9e68ca87C4d2AB835A"
33439
+ }
33440
+ },
33441
+ TeePoolPersistentStandard: {
33442
+ addresses: {
33443
+ 14800: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76",
33444
+ 1480: "0xe8bB8d0629651Cf33e0845d743976Dc1f0971d76"
33445
+ }
33446
+ },
33447
+ TeePoolPersistentGpu: {
33448
+ addresses: {
33449
+ 14800: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9",
33450
+ 1480: "0x1c346Cd74f8551f8fa13f3F4b6b8dAE22338E6a9"
33451
+ }
33452
+ },
33453
+ TeePoolDedicatedStandard: {
33454
+ addresses: {
33455
+ 14800: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d",
33456
+ 1480: "0xf024b7ac5E8417416f53B41ecfa58C8e9396687d"
33457
+ }
33458
+ },
33459
+ TeePoolDedicatedGpu: {
33460
+ addresses: {
33461
+ 14800: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E",
33462
+ 1480: "0xB1686FA9620bBf851714d1cB47b8a4Bf4664644E"
33463
+ }
33464
+ },
33465
+ // ========================================
33466
+ // VANA EPOCH / DLP REGISTRY
33467
+ // ========================================
33468
+ // Note: DLP rewards-specific contracts (DLPPerformance, DLPRewardDeployer,
33469
+ // DLPRewardDeployerTreasury, DLPRewardSwap, SwapHelper) were removed in the
33470
+ // protocol unification cleanup. VanaEpoch, DLPRegistry, and DLPRegistryTreasury
33471
+ // are kept because they may be referenced beyond the rewards system.
33472
+ VanaEpoch: {
33473
+ addresses: {
33474
+ 14800: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0",
33475
+ 1480: "0x2063cFF0609D59bCCc196E20Eb58A8696a6b15A0"
33476
+ }
33477
+ },
33478
+ DLPRegistry: {
33479
+ addresses: {
33480
+ 14800: "0x4D59880a924526d1dD33260552Ff4328b1E18a43",
33481
+ 1480: "0x4D59880a924526d1dD33260552Ff4328b1E18a43"
33482
+ }
33483
+ },
33484
+ DLPRegistryTreasury: {
33485
+ addresses: {
33486
+ 14800: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a",
33487
+ 1480: "0xb12ce1d27bEeFe39b6F0110b1AB77C21Aa0c9F9a"
33488
+ },
33489
+ discovery: {
33490
+ parent: "DLPRegistry",
33491
+ getter: "treasury"
33492
+ }
33493
+ },
33494
+ // ========================================
33495
+ // VANA POOL (STAKING)
33496
+ // ========================================
33497
+ VanaPoolStaking: {
33498
+ addresses: {
33499
+ 14800: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e",
33500
+ 1480: "0x641C18E2F286c86f96CE95C8ec1EB9fC0415Ca0e"
33501
+ }
33502
+ },
33503
+ VanaPoolTreasury: {
33504
+ addresses: {
33505
+ 14800: "0x143BE72CF2541604A7691933CAccd6D9cC17c003",
33506
+ 1480: "0x143BE72CF2541604A7691933CAccd6D9cC17c003"
33507
+ },
33508
+ discovery: {
33509
+ parent: "VanaPoolStaking",
33510
+ getter: "vanaPoolTreasury"
33511
+ }
33512
+ },
33513
+ VanaPoolEntity: {
33514
+ addresses: {
33515
+ 14800: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30",
33516
+ 1480: "0x44f20490A82e1f1F1cC25Dd3BA8647034eDdce30"
33517
+ },
33518
+ discovery: {
33519
+ parent: "VanaPoolStaking",
33520
+ getter: "vanaPoolEntity"
33521
+ }
33522
+ },
33523
+ // ========================================
33524
+ // DLP DEPLOYMENT & TOKEN SYSTEM
33525
+ // ========================================
33526
+ DATFactory: {
33527
+ addresses: {
33528
+ 14800: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644",
33529
+ 1480: "0x40f8bccF35a75ecef63BC3B1B3E06ffEB9220644"
33530
+ }
33531
+ },
33532
+ DAT: {
33533
+ addresses: {
33534
+ 14800: "0xA706b93ccED89f13340673889e29F0a5cd84212d",
33535
+ 1480: "0xA706b93ccED89f13340673889e29F0a5cd84212d"
33536
+ }
33537
+ },
33538
+ DATPausable: {
33539
+ addresses: {
33540
+ 14800: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e",
33541
+ 1480: "0xe69FE86f0B95cC2f8416Fe22815c85DC8887e76e"
33542
+ }
33543
+ },
33544
+ DATVotes: {
33545
+ addresses: {
33546
+ 14800: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831",
33547
+ 1480: "0xaE04c8A77E9B27869eb563720524A9aE0baf1831"
33548
+ }
33549
+ },
33550
+ // ========================================
33551
+ // EXTERNAL DEPENDENCIES (DeFi)
33552
+ // ========================================
33553
+ WVANA: {
33554
+ addresses: {
33555
+ 14800: "0xbccc4b4c6530F82FE309c5E845E50b5E9C89f2AD",
33556
+ 1480: "0x00EDdD9621Fb08436d0331c149D1690909a5906d"
33557
+ }
33558
+ },
33559
+ UniswapV3NonfungiblePositionManager: {
33560
+ addresses: {
33561
+ 14800: "0x48Bd633f4B9128a38Ebb4a48b6975EB3Eaf1931b",
33562
+ 1480: "0x45a2992e1bFdCF9b9AcE0a84A238f2E56F481816"
33563
+ }
33564
+ },
33565
+ UniswapV3QuoterV2: {
33566
+ addresses: {
33567
+ 14800: "0x3152246f3CD4dD465292Dd4Ffd792E2Cf602e332",
33568
+ 1480: "0x1b13728ea3C90863990aC0e05987CfeC1888908c"
33569
+ }
33570
+ },
33571
+ // ========================================
33572
+ // UTILITY CONTRACTS
33573
+ // ========================================
33574
+ Multicall3: {
33575
+ addresses: {
33576
+ 14800: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",
33577
+ 1480: "0xD8d2dFca27E8797fd779F8547166A2d3B29d360E"
33578
+ }
33579
+ },
33580
+ Multisend: {
33581
+ addresses: {
33582
+ 14800: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d",
33583
+ 1480: "0x8807e8BCDFbaA8c2761760f3FBA37F6f7F2C5b2d"
33584
+ }
33585
+ }
33586
+ };
33587
+
33588
+ // src/protocol/escrow.ts
33589
+ var import_viem16 = require("viem");
33590
+ var GENERIC_PAYMENT_TYPES = {
33591
+ GenericPayment: [
33592
+ { name: "payerAddress", type: "address" },
33593
+ { name: "opType", type: "string" },
33594
+ { name: "opId", type: "bytes32" },
33595
+ { name: "asset", type: "address" },
33596
+ { name: "amount", type: "uint256" },
33597
+ { name: "paymentNonce", type: "uint256" }
33598
+ ]
33599
+ };
33600
+ function genericPaymentDomain(chainId, escrowContract) {
33601
+ return {
33602
+ name: "Vana Data Portability",
33603
+ version: "1",
33604
+ chainId,
33605
+ verifyingContract: escrowContract
33606
+ };
33607
+ }
33608
+ var ESCROW_DEPOSIT_ABI = [
33609
+ {
33610
+ type: "function",
33611
+ name: "depositNative",
33612
+ stateMutability: "payable",
33613
+ inputs: [{ name: "account", type: "address" }],
33614
+ outputs: []
33615
+ },
33616
+ {
33617
+ type: "function",
33618
+ name: "depositToken",
33619
+ stateMutability: "nonpayable",
33620
+ inputs: [
33621
+ { name: "account", type: "address" },
33622
+ { name: "token", type: "address" },
33623
+ { name: "amount", type: "uint256" }
33624
+ ],
33625
+ outputs: []
33626
+ }
33627
+ ];
33628
+ var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
33629
+ var EscrowWithdrawalLifecycleError = class extends Error {
33630
+ constructor(httpStatus, result) {
33631
+ super(result.error);
33632
+ this.httpStatus = httpStatus;
33633
+ this.result = result;
33634
+ }
33635
+ httpStatus;
33636
+ result;
33637
+ name = "EscrowWithdrawalLifecycleError";
33638
+ };
33639
+ var EscrowWithdrawalRejectionError = class extends Error {
33640
+ constructor(httpStatus, result) {
33641
+ super(result.error);
33642
+ this.httpStatus = httpStatus;
33643
+ this.result = result;
33644
+ }
33645
+ httpStatus;
33646
+ result;
33647
+ name = "EscrowWithdrawalRejectionError";
33648
+ };
33649
+ function createEscrowGatewayClient(baseUrl) {
33650
+ const base = baseUrl.replace(/\/+$/, "");
33651
+ async function throwOnError(res, context) {
33652
+ if (!res.ok) {
33653
+ let detail = "";
33654
+ try {
33655
+ const body = await res.json();
33656
+ if (body.error) detail = `: ${body.error}`;
33657
+ } catch {
33658
+ }
33659
+ throw new Error(
33660
+ `Escrow gateway error (${context}): ${res.status} ${res.statusText}${detail}`
33661
+ );
33662
+ }
33663
+ }
33664
+ async function throwOnWithdrawError(res) {
33665
+ if (res.ok) return;
33666
+ let body;
33667
+ try {
33668
+ body = await res.json();
33669
+ } catch {
33670
+ throw new Error(
33671
+ `Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
33672
+ );
33673
+ }
33674
+ if (isEscrowWithdrawalFailureResult(body)) {
33675
+ throw new EscrowWithdrawalLifecycleError(res.status, body);
33676
+ }
33677
+ if (isEscrowWithdrawalRejectedResult(body)) {
33678
+ throw new EscrowWithdrawalRejectionError(res.status, body);
33679
+ }
33680
+ const error = getGatewayErrorMessage(body);
33681
+ throw new Error(
33682
+ `Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
33683
+ );
33684
+ }
33685
+ return {
33686
+ async submitDeposit({ txHash }) {
33687
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
33688
+ method: "POST",
33689
+ headers: { "Content-Type": "application/json" },
33690
+ body: JSON.stringify({ txHash })
33691
+ });
33692
+ if (res.status !== 200 && res.status !== 202) {
33693
+ await throwOnError(res, "POST /v1/escrow/deposit");
33694
+ }
33695
+ return res.json();
33696
+ },
33697
+ async getEscrowBalance(account) {
33698
+ const res = await fetch(
33699
+ `${base}/v1/escrow/balance?account=${encodeURIComponent(account)}`
33700
+ );
33701
+ await throwOnError(res, "GET /v1/escrow/balance");
33702
+ return res.json();
33703
+ },
33704
+ async syncEscrowBalance(account) {
33705
+ const res = await fetch(
33706
+ `${base}/v1/escrow/balance/sync?account=${encodeURIComponent(account)}`,
33707
+ { method: "POST" }
33708
+ );
33709
+ await throwOnError(res, "POST /v1/escrow/balance/sync");
33710
+ return res.json();
33711
+ },
33712
+ async payForOp({
33713
+ payerAddress,
33714
+ opType,
33715
+ opId,
33716
+ asset,
33717
+ amount,
33718
+ paymentNonce,
33719
+ signature,
33720
+ accessRecord
33721
+ }) {
33722
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33723
+ method: "POST",
33724
+ headers: {
33725
+ "Content-Type": "application/json",
33726
+ Authorization: `Web3Signed ${signature}`
33727
+ },
33728
+ body: JSON.stringify({
33729
+ payerAddress,
33730
+ opType,
33731
+ opId,
33732
+ asset,
33733
+ amount,
33734
+ paymentNonce,
33735
+ ...accessRecord ? { accessRecord } : {}
33736
+ })
33737
+ });
33738
+ await throwOnError(res, "POST /v1/escrow/pay");
33739
+ return res.json();
33740
+ },
33741
+ async withdraw({
33742
+ account,
33743
+ asset,
33744
+ amount,
33745
+ withdrawNonce,
33746
+ deadline,
33747
+ signature
33748
+ }) {
33749
+ const res = await fetch(`${base}/v1/escrow/withdraw`, {
33750
+ method: "POST",
33751
+ headers: {
33752
+ "Content-Type": "application/json",
33753
+ Authorization: `Web3Signed ${signature}`
33754
+ },
33755
+ body: JSON.stringify({
33756
+ account,
33757
+ asset,
33758
+ amount,
33759
+ withdrawNonce,
33760
+ deadline
33761
+ })
33762
+ });
33763
+ await throwOnWithdrawError(res);
33764
+ return res.json();
33765
+ },
33766
+ async getWithdrawNonce(account) {
33767
+ const res = await fetch(
33768
+ `${base}/v1/escrow/withdraw/nonce?account=${encodeURIComponent(account)}`,
33769
+ { cache: "no-store" }
33770
+ );
33771
+ await throwOnError(res, "GET /v1/escrow/withdraw/nonce");
33772
+ const body = await res.json();
33773
+ if (!isWithdrawNonceResponse(body, account)) {
33774
+ throw new Error(
33775
+ "GET /v1/escrow/withdraw/nonce: invalid response structure"
33776
+ );
33777
+ }
33778
+ return body;
33779
+ }
33780
+ };
33781
+ }
33782
+ function getGatewayErrorMessage(body) {
33783
+ if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
33784
+ return body.error;
33785
+ }
33786
+ return void 0;
33787
+ }
33788
+ function isEscrowWithdrawalFailureResult(body) {
33789
+ if (typeof body !== "object" || body === null) return false;
33790
+ const value = body;
33791
+ return value.success === false && (value.status === "retryable" || value.status === "reorged" || value.status === "failed") && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && (isHash(value.txHash) || value.txHash === null) && (!("blockNumber" in value) || isBlockNumber(value.blockNumber));
33792
+ }
33793
+ function isEscrowWithdrawalRejectedResult(body) {
33794
+ if (typeof body !== "object" || body === null) return false;
33795
+ const value = body;
33796
+ return value.success === false && value.status === "rejected" && isWithdrawalRejectionCode(value.code) && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && optionalUint256Decimal(value.balance) && optionalUint256Decimal(value.authorizedAmount) && optionalUint256Decimal(value.withdrawingAmount) && optionalUint256Decimal(value.availableAmount) && optionalUint256Decimal(value.requestedAmount) && optionalUint256Decimal(value.minimumAmount);
33797
+ }
33798
+ function isWithdrawalRejectionCode(value) {
33799
+ return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
33800
+ }
33801
+ function optionalUint256Decimal(value) {
33802
+ return value === void 0 || isUint256Decimal(value);
33803
+ }
33804
+ function isAddressHex(value) {
33805
+ return typeof value === "string" && (0, import_viem16.isHex)(value, { strict: true }) && value.length === 42;
33806
+ }
33807
+ function isHash(value) {
33808
+ return typeof value === "string" && (0, import_viem16.isHex)(value, { strict: true }) && value.length === 66;
33809
+ }
33810
+ function isUint256Decimal(value) {
33811
+ if (typeof value !== "string" || value.length === 0 || value.length > 78) {
33812
+ return false;
33813
+ }
33814
+ if (!/^(0|[1-9]\d*)$/.test(value)) return false;
33815
+ return BigInt(value) <= 2n ** 256n - 1n;
33816
+ }
33817
+ function isBlockNumber(value) {
33818
+ return value === null || isUint256Decimal(value);
33819
+ }
33820
+ function isWithdrawNonceResponse(body, requestedAccount) {
33821
+ if (typeof body !== "object" || body === null) return false;
33822
+ const value = body;
33823
+ if (value.success !== true) return false;
33824
+ if (!isAddressHex(value.account)) return false;
33825
+ if (value.account.toLowerCase() !== requestedAccount.toLowerCase())
33826
+ return false;
33827
+ if (typeof value.chainId !== "string") return false;
33828
+ if (!/^(0|[1-9]\d*)$/.test(value.chainId)) return false;
33829
+ const isLastNull = value.lastWithdrawNonce === null;
33830
+ const lastNonceValid = isLastNull || isUint256Decimal(value.lastWithdrawNonce);
33831
+ if (!lastNonceValid) return false;
33832
+ if (!isUint256Decimal(value.nextWithdrawNonce)) return false;
33833
+ if (isLastNull) {
33834
+ return value.nextWithdrawNonce === "1";
33835
+ }
33836
+ const lastNonce = BigInt(value.lastWithdrawNonce);
33837
+ const nextNonce = BigInt(value.nextWithdrawNonce);
33838
+ const expectedNextNonce = lastNonce + 1n;
33839
+ if (expectedNextNonce > 2n ** 256n - 1n) return false;
33840
+ return nextNonce === expectedNextNonce;
33841
+ }
33327
33842
 
33328
33843
  // src/protocol/write-signer.ts
33329
33844
  var import_errors2 = require("./errors.cjs");
@@ -33369,7 +33884,9 @@ function resolveWriteSigner(source, options = {}) {
33369
33884
  // src/protocol/jobs-client.ts
33370
33885
  var IDENTITY_PATH = "/v1/identity";
33371
33886
  var JOBS_PATH = "/v1/jobs";
33887
+ var JOB_QUOTE_PATH = "/v1/jobs/quote";
33372
33888
  var JOB_EXECUTE_PATH = "/v1/jobs/execute";
33889
+ var JOB_ACCESS_OP_TYPE = "job_access";
33373
33890
  var AUTHORIZATION_HEADER = "Authorization";
33374
33891
  var CONTENT_TYPE_HEADER = "Content-Type";
33375
33892
  var JSON_CONTENT_TYPE = "application/json";
@@ -33383,7 +33900,11 @@ var HTTP_UNAUTHORIZED = 401;
33383
33900
  var HTTP_FORBIDDEN = 403;
33384
33901
  var HTTP_NOT_FOUND = 404;
33385
33902
  var HTTP_CONFLICT = 409;
33903
+ var HTTP_PAYMENT_REQUIRED = 402;
33386
33904
  var HTTP_PAYLOAD_TOO_LARGE = 413;
33905
+ var NONCE_TIMESTAMP_SHIFT = 32n;
33906
+ var UINT256_DECIMAL = /^(0|[1-9]\d*)$/;
33907
+ var POSITIVE_UINT256_DECIMAL = /^[1-9]\d*$/;
33387
33908
  var MILLISECONDS_PER_SECOND = 1e3;
33388
33909
  var DEFAULT_JOB_TIMEOUT_MS = 12e4;
33389
33910
  var DEFAULT_JOB_POLL_MS = CLAIM_POLL_FLOOR_MS;
@@ -33466,11 +33987,17 @@ function resolveBuilder(options) {
33466
33987
  "Builder signer must expose both address and publicKey"
33467
33988
  );
33468
33989
  }
33990
+ const typedDataSigner = source.signTypedData;
33469
33991
  return {
33470
33992
  builder: {
33471
33993
  address: signer.address,
33472
33994
  publicKey,
33473
- signMessage: signer.signMessage
33995
+ signMessage: signer.signMessage,
33996
+ ...typedDataSigner ? {
33997
+ signTypedData: typedDataSigner.bind(
33998
+ source
33999
+ )
34000
+ } : {}
33474
34001
  },
33475
34002
  ...options.builderPrivateKey ? { privateKey: options.builderPrivateKey } : {}
33476
34003
  };
@@ -33554,7 +34081,7 @@ function isResultHandle(value) {
33554
34081
  function hasMatchingIdentityKey(value) {
33555
34082
  const address = value["address"];
33556
34083
  const publicKey = value["publicKey"];
33557
- if (typeof address !== "string" || !(0, import_viem16.isAddress)(address) || typeof publicKey !== "string" || !(0, import_viem16.isHex)(publicKey)) {
34084
+ if (typeof address !== "string" || !(0, import_viem17.isAddress)(address) || typeof publicKey !== "string" || !(0, import_viem17.isHex)(publicKey)) {
33558
34085
  return false;
33559
34086
  }
33560
34087
  try {
@@ -33567,14 +34094,59 @@ function hasExpectedIdentity(value, owner, chainId) {
33567
34094
  const identityOwner = value["ownerAddress"];
33568
34095
  const identityChainId = value["chainId"];
33569
34096
  const identityUserPsId = value["userPsId"];
33570
- if (!hasMatchingIdentityKey(value) || typeof identityOwner !== "string" || !(0, import_viem16.isAddress)(identityOwner) || typeof identityChainId !== "number" || typeof identityUserPsId !== "string" || !(0, import_viem16.isHex)(identityUserPsId)) {
34097
+ if (!hasMatchingIdentityKey(value) || typeof identityOwner !== "string" || !(0, import_viem17.isAddress)(identityOwner) || typeof identityChainId !== "number" || typeof identityUserPsId !== "string" || !(0, import_viem17.isHex)(identityUserPsId)) {
33571
34098
  return false;
33572
34099
  }
33573
- return (0, import_viem16.isAddressEqual)(identityOwner, owner) && identityChainId === chainId && identityUserPsId.toLowerCase() === userPsId(chainId, owner).toLowerCase();
34100
+ return (0, import_viem17.isAddressEqual)(identityOwner, owner) && identityChainId === chainId && identityUserPsId.toLowerCase() === userPsId(chainId, owner).toLowerCase();
33574
34101
  }
33575
34102
  function sleep2(ms) {
33576
34103
  return new Promise((resolve) => setTimeout(resolve, ms));
33577
34104
  }
34105
+ function resolveEscrowContract(options) {
34106
+ if (options.escrowContract) return options.escrowContract;
34107
+ const addresses = CONTRACTS2["DataPortabilityEscrow"]?.addresses;
34108
+ const address = addresses?.[options.chainId];
34109
+ if (!address || !(0, import_viem17.isAddress)(address)) {
34110
+ throw new import_errors3.JobRejectedError(
34111
+ `No DataPortabilityEscrow address for chain ${options.chainId}; pass escrowContract`
34112
+ );
34113
+ }
34114
+ return address;
34115
+ }
34116
+ function nextPaymentNonce() {
34117
+ const random = new Uint32Array(1);
34118
+ globalThis.crypto.getRandomValues(random);
34119
+ return (BigInt(Date.now()) << NONCE_TIMESTAMP_SHIFT) + BigInt(random[0] ?? 0);
34120
+ }
34121
+ function parseJobQuote(body) {
34122
+ if (!isRecord2(body)) return null;
34123
+ const { chainId, price, asset, payable, enforced } = body;
34124
+ if (typeof chainId !== "number" || !Number.isSafeInteger(chainId))
34125
+ return null;
34126
+ if (typeof price !== "string" || !UINT256_DECIMAL.test(price)) return null;
34127
+ if (typeof asset !== "string" || !(0, import_viem17.isAddress)(asset)) return null;
34128
+ if (typeof payable !== "boolean" || typeof enforced !== "boolean")
34129
+ return null;
34130
+ return { chainId, price, asset, payable, enforced };
34131
+ }
34132
+ async function paymentQuote(response) {
34133
+ const body = await responseBody(response);
34134
+ const asset = isRecord2(body) ? body["asset"] : void 0;
34135
+ const amount = isRecord2(body) ? body["amount"] : void 0;
34136
+ if (typeof asset !== "string" || !(0, import_viem17.isAddress)(asset) || typeof amount !== "string" || !POSITIVE_UINT256_DECIMAL.test(amount)) {
34137
+ throw new import_errors3.JobRejectedError(
34138
+ "Gateway asked for payment without a usable quote",
34139
+ response.status
34140
+ );
34141
+ }
34142
+ return { asset, amount };
34143
+ }
34144
+ async function paymentRefusal(response) {
34145
+ const body = await responseBody(response);
34146
+ const parsed = isRecord2(body) ? body : {};
34147
+ const message = typeof parsed["error"] === "string" ? parsed["error"] : "This read requires payment the builder escrow cannot back";
34148
+ return { message, details: parsed };
34149
+ }
33578
34150
  function requireFiniteDuration(value, field) {
33579
34151
  if (!Number.isFinite(value)) {
33580
34152
  throw new import_errors3.JobRejectedError(`${field} must be a finite number`);
@@ -33587,6 +34159,73 @@ function createJobsClient(options) {
33587
34159
  const { builder, privateKey } = resolveBuilder(options);
33588
34160
  const ecies = options.ecies ?? new NodeECIESUint8Provider();
33589
34161
  const now = options.now ?? (() => /* @__PURE__ */ new Date());
34162
+ async function signQuote(jobId, quote) {
34163
+ if (!builder.signTypedData) {
34164
+ throw new import_errors3.JobRejectedError(
34165
+ "This read is charged, but the builder signer cannot sign typed data"
34166
+ );
34167
+ }
34168
+ const paymentNonce = nextPaymentNonce();
34169
+ const signature = await builder.signTypedData({
34170
+ domain: genericPaymentDomain(
34171
+ options.chainId,
34172
+ resolveEscrowContract(options)
34173
+ ),
34174
+ types: GENERIC_PAYMENT_TYPES,
34175
+ primaryType: "GenericPayment",
34176
+ message: {
34177
+ payerAddress: builder.address,
34178
+ opType: JOB_ACCESS_OP_TYPE,
34179
+ opId: (0, import_viem17.keccak256)((0, import_viem17.toHex)(jobId.toLowerCase())),
34180
+ asset: quote.asset,
34181
+ amount: BigInt(quote.amount),
34182
+ paymentNonce
34183
+ }
34184
+ });
34185
+ return {
34186
+ signature,
34187
+ amount: quote.amount,
34188
+ asset: quote.asset,
34189
+ paymentNonce: paymentNonce.toString()
34190
+ };
34191
+ }
34192
+ async function postSubmission(submission, wait) {
34193
+ const identifiers = {
34194
+ jobId: submission.jobId,
34195
+ idempotencyKey: submission.idempotencyKey
34196
+ };
34197
+ const bodyBytes = new TextEncoder().encode(JSON.stringify(submission));
34198
+ const authorization = await buildWeb3SignedHeader({
34199
+ signMessage: builder.signMessage,
34200
+ aud: audience,
34201
+ method: POST_METHOD,
34202
+ uri: JOBS_PATH,
34203
+ body: bodyBytes,
34204
+ nonce: (0, import_node_crypto.randomUUID)()
34205
+ });
34206
+ try {
34207
+ return await request(
34208
+ `${baseUrl}${JOBS_PATH}?wait=${wait}`,
34209
+ {
34210
+ method: POST_METHOD,
34211
+ headers: {
34212
+ [AUTHORIZATION_HEADER]: authorization,
34213
+ [CONTENT_TYPE_HEADER]: JSON_CONTENT_TYPE
34214
+ },
34215
+ body: bodyBytes
34216
+ },
34217
+ "Job submission"
34218
+ );
34219
+ } catch (error) {
34220
+ if (error instanceof import_errors3.JobTransportError) {
34221
+ throw new import_errors3.JobTransportError(error.message, error.cause, {
34222
+ ...error.details,
34223
+ ...identifiers
34224
+ });
34225
+ }
34226
+ throw error;
34227
+ }
34228
+ }
33590
34229
  async function request(url, init, description) {
33591
34230
  try {
33592
34231
  return await fetchFn(url, init);
@@ -33642,7 +34281,8 @@ function createJobsClient(options) {
33642
34281
  "deadlineSeconds"
33643
34282
  );
33644
34283
  const wait = clampInteger(params.wait, 0, 0, MAX_WAIT_SECONDS, "wait");
33645
- const jobId = (0, import_node_crypto.randomUUID)();
34284
+ const jobId = params.jobId ?? (0, import_node_crypto.randomUUID)();
34285
+ const idempotencyKey = params.idempotencyKey ?? (0, import_node_crypto.randomUUID)();
33646
34286
  const nowMs = now().getTime();
33647
34287
  if (!Number.isFinite(nowMs)) {
33648
34288
  throw new import_errors3.JobRejectedError("now must return a valid Date");
@@ -33680,32 +34320,41 @@ function createJobsClient(options) {
33680
34320
  grantId: requestBody.grantId,
33681
34321
  scope: requestBody.scope,
33682
34322
  operation: requestBody.operation,
33683
- idempotencyKey: (0, import_node_crypto.randomUUID)(),
34323
+ idempotencyKey,
33684
34324
  jobId,
33685
34325
  deadline,
33686
- requestCiphertext
34326
+ requestCiphertext,
34327
+ ...params.maxPrice === void 0 ? {} : { maxPrice: params.maxPrice }
33687
34328
  };
33688
- const bodyBytes = new TextEncoder().encode(JSON.stringify(submission));
33689
- const authorization = await buildWeb3SignedHeader({
33690
- signMessage: builder.signMessage,
33691
- aud: audience,
33692
- method: POST_METHOD,
33693
- uri: JOBS_PATH,
33694
- body: bodyBytes,
33695
- nonce: (0, import_node_crypto.randomUUID)()
33696
- });
33697
- const response = await request(
33698
- `${baseUrl}${JOBS_PATH}?wait=${wait}`,
33699
- {
33700
- method: POST_METHOD,
33701
- headers: {
33702
- [AUTHORIZATION_HEADER]: authorization,
33703
- [CONTENT_TYPE_HEADER]: JSON_CONTENT_TYPE
33704
- },
33705
- body: bodyBytes
33706
- },
33707
- "Job submission"
33708
- );
34329
+ let response = await postSubmission(submission, wait);
34330
+ if (response.status === HTTP_PAYMENT_REQUIRED) {
34331
+ const quote = await paymentQuote(response);
34332
+ if (params.maxPrice !== void 0 && BigInt(quote.amount) > BigInt(params.maxPrice)) {
34333
+ throw new import_errors4.PaymentRequiredError(
34334
+ "The quoted price is above the maxPrice you set for this read",
34335
+ {
34336
+ jobId,
34337
+ scope: params.scope,
34338
+ grantId: params.grantId,
34339
+ asset: quote.asset,
34340
+ amount: quote.amount,
34341
+ maxPrice: params.maxPrice
34342
+ }
34343
+ );
34344
+ }
34345
+ submission.payment = await signQuote(jobId, quote);
34346
+ submission.priceAsset = quote.asset;
34347
+ response = await postSubmission(submission, wait);
34348
+ if (response.status === HTTP_PAYMENT_REQUIRED) {
34349
+ const refusal = await paymentRefusal(response);
34350
+ throw new import_errors4.PaymentRequiredError(refusal.message, {
34351
+ jobId,
34352
+ scope: params.scope,
34353
+ grantId: params.grantId,
34354
+ ...refusal.details
34355
+ });
34356
+ }
34357
+ }
33709
34358
  if (!response.ok) {
33710
34359
  throw await rejectedResponse(response, "Job submission rejected");
33711
34360
  }
@@ -33728,6 +34377,40 @@ function createJobsClient(options) {
33728
34377
  response.status
33729
34378
  );
33730
34379
  },
34380
+ async quoteJob() {
34381
+ const authorization = await buildWeb3SignedHeader({
34382
+ signMessage: builder.signMessage,
34383
+ aud: audience,
34384
+ method: GET_METHOD,
34385
+ uri: JOB_QUOTE_PATH,
34386
+ nonce: (0, import_node_crypto.randomUUID)()
34387
+ });
34388
+ const response = await request(
34389
+ `${baseUrl}${JOB_QUOTE_PATH}`,
34390
+ {
34391
+ method: GET_METHOD,
34392
+ headers: { [AUTHORIZATION_HEADER]: authorization }
34393
+ },
34394
+ "Job quote"
34395
+ );
34396
+ if (!response.ok) {
34397
+ throw await rejectedResponse(response, "Job quote rejected");
34398
+ }
34399
+ const quote = parseJobQuote(await responseBody(response));
34400
+ if (!quote) {
34401
+ throw new import_errors3.JobRejectedError(
34402
+ "Gateway returned an undocumented job quote",
34403
+ response.status
34404
+ );
34405
+ }
34406
+ if (quote.chainId !== options.chainId) {
34407
+ throw new import_errors3.JobRejectedError(
34408
+ `Gateway quoted chain ${quote.chainId}, not the configured ${options.chainId}`,
34409
+ response.status
34410
+ );
34411
+ }
34412
+ return quote;
34413
+ },
33731
34414
  async getJob(jobId) {
33732
34415
  const path = `${JOBS_PATH}/${encodeURIComponent(jobId)}`;
33733
34416
  const authorization = await buildWeb3SignedHeader({
@@ -33819,7 +34502,7 @@ function createJobsClient(options) {
33819
34502
  error
33820
34503
  );
33821
34504
  }
33822
- const actualHash = (0, import_viem16.bytesToHex)((0, import_sha26.sha256)(bytes));
34505
+ const actualHash = (0, import_viem17.bytesToHex)((0, import_sha26.sha256)(bytes));
33823
34506
  if (actualHash.toLowerCase() !== handle.hash.toLowerCase()) {
33824
34507
  throw new import_errors3.JobResultIntegrityError(
33825
34508
  "Fetched job result hash does not match its handle",
@@ -33881,14 +34564,14 @@ function createJobsClient(options) {
33881
34564
  }
33882
34565
 
33883
34566
  // src/protocol/personal-server-registration.ts
33884
- var import_viem17 = require("viem");
34567
+ var import_viem18 = require("viem");
33885
34568
  var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
33886
34569
  var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
33887
34570
  PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
33888
34571
  "DataPortabilityServers"
33889
34572
  );
33890
34573
  function assertAddress(value, name) {
33891
- if (!(0, import_viem17.isAddress)(value)) {
34574
+ if (!(0, import_viem18.isAddress)(value)) {
33892
34575
  throw new Error(`${name} must be a valid EVM address`);
33893
34576
  }
33894
34577
  }
@@ -33974,12 +34657,12 @@ async function buildPersonalServerRegistrationSignature(input) {
33974
34657
  var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
33975
34658
 
33976
34659
  // src/personal-server-lite/owner-binding.ts
33977
- var import_viem18 = require("viem");
34660
+ var import_viem19 = require("viem");
33978
34661
  var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
33979
34662
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
33980
34663
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
33981
34664
  function assertAddress2(value, name) {
33982
- if (!(0, import_viem18.isAddress)(value)) {
34665
+ if (!(0, import_viem19.isAddress)(value)) {
33983
34666
  throw new Error(`${name} must be a valid EVM address`);
33984
34667
  }
33985
34668
  }
@@ -34029,7 +34712,7 @@ async function buildPersonalServerLiteOwnerBindingSignature(input) {
34029
34712
  var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
34030
34713
 
34031
34714
  // src/account/personal-server-registration.ts
34032
- var import_viem19 = require("viem");
34715
+ var import_viem20 = require("viem");
34033
34716
  var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
34034
34717
  var AccountPersonalServerRegistrationError = class extends Error {
34035
34718
  status;
@@ -34048,7 +34731,7 @@ function trimTrailingSlash(value) {
34048
34731
  return value.replace(/\/+$/, "");
34049
34732
  }
34050
34733
  function assertAddress3(value, name) {
34051
- if (!(0, import_viem19.isAddress)(value)) {
34734
+ if (!(0, import_viem20.isAddress)(value)) {
34052
34735
  throw new Error(`${name} must be a valid EVM address`);
34053
34736
  }
34054
34737
  }
@@ -34312,7 +34995,7 @@ function accountOwnerBindingError(error) {
34312
34995
  }
34313
34996
 
34314
34997
  // src/protocol/grants.ts
34315
- var import_viem20 = require("viem");
34998
+ var import_viem21 = require("viem");
34316
34999
  function isHexString(value) {
34317
35000
  return typeof value === "string" && value.startsWith("0x");
34318
35001
  }
@@ -34357,7 +35040,7 @@ async function verifyGrantRegistration(input) {
34357
35040
  }
34358
35041
  let valid;
34359
35042
  try {
34360
- valid = await (0, import_viem20.verifyTypedData)({
35043
+ valid = await (0, import_viem21.verifyTypedData)({
34361
35044
  address: input.grantorAddress,
34362
35045
  domain: grantRegistrationDomain(input.gatewayConfig),
34363
35046
  types: GRANT_REGISTRATION_TYPES,
@@ -34392,8 +35075,8 @@ async function verifyGrantRegistration(input) {
34392
35075
  }
34393
35076
 
34394
35077
  // src/protocol/fee-registry.ts
34395
- var import_viem21 = require("viem");
34396
- var FEE_REGISTRY_ABI = (0, import_viem21.parseAbi)([
35078
+ var import_viem22 = require("viem");
35079
+ var FEE_REGISTRY_ABI = (0, import_viem22.parseAbi)([
34397
35080
  "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
34398
35081
  "function fees(bytes32 operation) view returns (Fee)",
34399
35082
  "function operationKey(string name) pure returns (bytes32)"
@@ -34476,8 +35159,8 @@ async function getOpFee(client, config, opType, opts) {
34476
35159
  }
34477
35160
 
34478
35161
  // src/protocol/escrow-deposit.ts
34479
- var import_viem22 = require("viem");
34480
- var ESCROW_DEPOSIT_ABI = [
35162
+ var import_viem23 = require("viem");
35163
+ var ESCROW_DEPOSIT_ABI2 = [
34481
35164
  {
34482
35165
  type: "function",
34483
35166
  name: "depositNative",
@@ -34501,15 +35184,15 @@ function escrowContractAddress(config) {
34501
35184
  return config.contracts.dataPortabilityEscrow;
34502
35185
  }
34503
35186
  function encodeDepositNativeData(input) {
34504
- return (0, import_viem22.encodeFunctionData)({
34505
- abi: ESCROW_DEPOSIT_ABI,
35187
+ return (0, import_viem23.encodeFunctionData)({
35188
+ abi: ESCROW_DEPOSIT_ABI2,
34506
35189
  functionName: "depositNative",
34507
35190
  args: [input.account]
34508
35191
  });
34509
35192
  }
34510
35193
  function encodeDepositTokenData(input) {
34511
- return (0, import_viem22.encodeFunctionData)({
34512
- abi: ESCROW_DEPOSIT_ABI,
35194
+ return (0, import_viem23.encodeFunctionData)({
35195
+ abi: ESCROW_DEPOSIT_ABI2,
34513
35196
  functionName: "depositToken",
34514
35197
  args: [input.account, input.token, input.amount]
34515
35198
  });
@@ -34529,7 +35212,7 @@ function buildDepositTokenRequest(config, input) {
34529
35212
  }
34530
35213
 
34531
35214
  // src/protocol/data-point-status.ts
34532
- var import_viem23 = require("viem");
35215
+ var import_viem24 = require("viem");
34533
35216
  var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
34534
35217
  DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
34535
35218
  DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
@@ -34553,7 +35236,7 @@ function dataRegistryContractAddress(config) {
34553
35236
  return config.contracts.dataRegistry;
34554
35237
  }
34555
35238
  function encodeSetDataPointStatusData(input) {
34556
- return (0, import_viem23.encodeFunctionData)({
35239
+ return (0, import_viem24.encodeFunctionData)({
34557
35240
  abi: DATA_REGISTRY_STATUS_ABI,
34558
35241
  functionName: "setStatus",
34559
35242
  args: [input.scope, input.status]
@@ -34573,13 +35256,13 @@ function buildMarkDataPointUnavailableRequest(config, input) {
34573
35256
  }
34574
35257
 
34575
35258
  // src/protocol/data-point-deletion.ts
34576
- var import_viem25 = require("viem");
34577
- var import_errors5 = require("./errors.cjs");
35259
+ var import_viem26 = require("viem");
35260
+ var import_errors6 = require("./errors.cjs");
34578
35261
 
34579
35262
  // src/protocol/lineage.ts
34580
- var import_viem24 = require("viem");
35263
+ var import_viem25 = require("viem");
34581
35264
  var import_zod = require("zod");
34582
- var import_errors4 = require("./errors.cjs");
35265
+ var import_errors5 = require("./errors.cjs");
34583
35266
 
34584
35267
  // src/protocol/personal-server-error-body.ts
34585
35268
  function isRecord4(value) {
@@ -34616,13 +35299,13 @@ function isDataPointId(value) {
34616
35299
  return typeof value === "string" && DATA_POINT_ID_PATTERN.test(value);
34617
35300
  }
34618
35301
  function deriveDataPointId(ownerAddress, scope) {
34619
- if (!(0, import_viem24.isAddress)(ownerAddress, { strict: false })) {
35302
+ if (!(0, import_viem25.isAddress)(ownerAddress, { strict: false })) {
34620
35303
  throw new Error(
34621
35304
  `ownerAddress is not an EVM address: ${String(ownerAddress)}`
34622
35305
  );
34623
35306
  }
34624
- return (0, import_viem24.keccak256)(
34625
- (0, import_viem24.encodeAbiParameters)(
35307
+ return (0, import_viem25.keccak256)(
35308
+ (0, import_viem25.encodeAbiParameters)(
34626
35309
  [
34627
35310
  { name: "ownerAddress", type: "address" },
34628
35311
  { name: "scope", type: "string" }
@@ -34651,7 +35334,7 @@ function derivedScopeViolatesNaming(derivedScope, sourceScope) {
34651
35334
  function assertDerivedScopeNaming(derivedScope, sourceScopes) {
34652
35335
  for (const sourceScope of sourceScopes) {
34653
35336
  if (derivedScopeViolatesNaming(derivedScope, sourceScope)) {
34654
- throw new import_errors4.WriteRequestError(
35337
+ throw new import_errors5.WriteRequestError(
34655
35338
  `Derived scope ${derivedScope} must not share its first segment with source scope ${sourceScope}; put derivatives in the app's own namespace`,
34656
35339
  { scope: derivedScope, sourceScope }
34657
35340
  );
@@ -34714,7 +35397,7 @@ function normalizeBaseUrl(url) {
34714
35397
  function resolveFetch2(fetchFn) {
34715
35398
  const resolved = fetchFn ?? globalThis.fetch;
34716
35399
  if (resolved === void 0) {
34717
- throw new import_errors4.LineageReadError("No fetch implementation available");
35400
+ throw new import_errors5.LineageReadError("No fetch implementation available");
34718
35401
  }
34719
35402
  return resolved;
34720
35403
  }
@@ -34722,7 +35405,7 @@ function normalizeVersion(version) {
34722
35405
  if (version === void 0) return void 0;
34723
35406
  const text = String(version);
34724
35407
  if (!VERSION_PATTERN.test(text)) {
34725
- throw new import_errors4.LineageReadError(
35408
+ throw new import_errors5.LineageReadError(
34726
35409
  "version must be a positive decimal integer",
34727
35410
  void 0,
34728
35411
  "INVALID_VERSION",
@@ -34733,7 +35416,7 @@ function normalizeVersion(version) {
34733
35416
  }
34734
35417
  async function lineageReadFailure(source, response) {
34735
35418
  const { errorCode, message, details } = await readPersonalServerErrorBody(response);
34736
- return new import_errors4.LineageReadError(
35419
+ return new import_errors5.LineageReadError(
34737
35420
  message ?? `${source} lineage read failed: ${response.status} ${response.statusText}`,
34738
35421
  response.status,
34739
35422
  errorCode,
@@ -34745,7 +35428,7 @@ async function parseLineageGraph(source, response) {
34745
35428
  try {
34746
35429
  body = await response.json();
34747
35430
  } catch (err) {
34748
- throw new import_errors4.LineageReadError(
35431
+ throw new import_errors5.LineageReadError(
34749
35432
  `${source} lineage response is not JSON`,
34750
35433
  response.status,
34751
35434
  null,
@@ -34755,7 +35438,7 @@ async function parseLineageGraph(source, response) {
34755
35438
  const envelope = isRecord4(body) && isRecord4(body.data) ? body : void 0;
34756
35439
  const parsed = LineageGraphSchema.safeParse(envelope?.data ?? body);
34757
35440
  if (!parsed.success) {
34758
- throw new import_errors4.LineageReadError(
35441
+ throw new import_errors5.LineageReadError(
34759
35442
  `${source} lineage response is not a lineage view`,
34760
35443
  response.status,
34761
35444
  null,
@@ -34770,7 +35453,7 @@ async function sendLineageRead(source, fetchFn, url, headers) {
34770
35453
  try {
34771
35454
  response = await fetchFn(url, { method: "GET", headers });
34772
35455
  } catch (err) {
34773
- throw new import_errors4.LineageReadError(
35456
+ throw new import_errors5.LineageReadError(
34774
35457
  `${source} lineage read failed: ${err instanceof Error ? err.message : String(err)}`,
34775
35458
  void 0,
34776
35459
  null,
@@ -34811,7 +35494,7 @@ async function getPersonalServerLineage(params) {
34811
35494
  }
34812
35495
  async function getGatewayLineage(params) {
34813
35496
  if (!isDataPointId(params.dataPointId)) {
34814
- throw new import_errors4.LineageReadError(
35497
+ throw new import_errors5.LineageReadError(
34815
35498
  "dataPointId must be a 32-byte hex string (see deriveDataPointId)",
34816
35499
  void 0,
34817
35500
  "INVALID_DATA_POINT_ID",
@@ -34848,7 +35531,7 @@ var TOMBSTONE_METADATA_HASH_PREIMAGE = "vana.data-point.tombstone.metadata.v1";
34848
35531
  var TOMBSTONE_DATA_HASH = "0x30c45ee72fe56d1927701316925ab7ceacd3b6f9267061735d59396f075c6222";
34849
35532
  var TOMBSTONE_METADATA_HASH = "0xc5255a141acd6a2ae55971b62c0a85977c2511989dc114ad2abc2b7644f57d90";
34850
35533
  function computeTombstoneHash(preimage) {
34851
- return (0, import_viem25.keccak256)((0, import_viem25.stringToBytes)(preimage));
35534
+ return (0, import_viem26.keccak256)((0, import_viem26.stringToBytes)(preimage));
34852
35535
  }
34853
35536
  function isTombstoneHashes(dataHash, metadataHash) {
34854
35537
  return typeof dataHash === "string" && typeof metadataHash === "string" && dataHash.toLowerCase() === TOMBSTONE_DATA_HASH && metadataHash.toLowerCase() === TOMBSTONE_METADATA_HASH;
@@ -34867,12 +35550,12 @@ function tombstoneDeletedAt(value) {
34867
35550
  return typeof deletedAt === "string" ? deletedAt : null;
34868
35551
  }
34869
35552
  function assertAddress4(value, name) {
34870
- if (!(0, import_viem25.isAddress)(value)) {
35553
+ if (!(0, import_viem26.isAddress)(value)) {
34871
35554
  throw new Error(`${name} must be a valid EVM address`);
34872
35555
  }
34873
35556
  }
34874
35557
  function assertUint256(value, name) {
34875
- if (value < 0n || value > import_viem25.maxUint256) {
35558
+ if (value < 0n || value > import_viem26.maxUint256) {
34876
35559
  throw new Error(`${name} must fit in uint256, got ${value}`);
34877
35560
  }
34878
35561
  }
@@ -34957,13 +35640,13 @@ async function deleteDataPoint(input) {
34957
35640
  if (currentVersion === void 0) {
34958
35641
  const record = await input.gateway.getDataPoint(dataPointId);
34959
35642
  if (record === null) {
34960
- throw new import_errors5.DataPointNotFoundError(
35643
+ throw new import_errors6.DataPointNotFoundError(
34961
35644
  `No data point registered for scope '${input.scope}' owned by ${ownerAddress}`,
34962
35645
  { dataPointId, scope: input.scope, ownerAddress }
34963
35646
  );
34964
35647
  }
34965
35648
  if (isDataPointTombstone(record)) {
34966
- throw new import_errors5.DataPointDeletedError(
35649
+ throw new import_errors6.DataPointDeletedError(
34967
35650
  `Data point ${dataPointId} (scope '${input.scope}') is already deleted`,
34968
35651
  {
34969
35652
  dataPointId,
@@ -34975,7 +35658,7 @@ async function deleteDataPoint(input) {
34975
35658
  }
34976
35659
  currentVersion = parseExpectedVersion(record.expectedVersion);
34977
35660
  }
34978
- if (currentVersion < 0n || currentVersion >= import_viem25.maxUint256) {
35661
+ if (currentVersion < 0n || currentVersion >= import_viem26.maxUint256) {
34979
35662
  throw new Error(
34980
35663
  `currentVersion ${currentVersion} cannot be incremented to a uint256 tombstone version`
34981
35664
  );
@@ -35010,7 +35693,7 @@ async function deleteDataPoint(input) {
35010
35693
  }
35011
35694
 
35012
35695
  // src/protocol/personal-server-data.ts
35013
- var import_errors6 = require("./errors.cjs");
35696
+ var import_errors7 = require("./errors.cjs");
35014
35697
 
35015
35698
  // src/protocol/data-file.ts
35016
35699
  var import_zod2 = require("zod");
@@ -35070,7 +35753,7 @@ async function readPersonalServerData(params) {
35070
35753
  const request = await buildPersonalServerDataReadRequest(params);
35071
35754
  const response = await fetchFn(request);
35072
35755
  if (response.status === 410) {
35073
- throw new import_errors6.DataPointDeletedError(
35756
+ throw new import_errors7.DataPointDeletedError(
35074
35757
  `Personal Server scope '${params.scope}' has been deleted`,
35075
35758
  {
35076
35759
  scope: params.scope,
@@ -35085,7 +35768,7 @@ async function readPersonalServerData(params) {
35085
35768
  }
35086
35769
  const body = await response.json();
35087
35770
  if (isDataPointTombstone(body)) {
35088
- throw new import_errors6.DataPointDeletedError(
35771
+ throw new import_errors7.DataPointDeletedError(
35089
35772
  `Personal Server scope '${params.scope}' has been deleted`,
35090
35773
  { scope: params.scope, deletedAt: tombstoneDeletedAt(body) }
35091
35774
  );
@@ -35286,21 +35969,21 @@ function tryGrantPermissions(scopes) {
35286
35969
 
35287
35970
  // src/protocol/personal-server-write.ts
35288
35971
  var import_sha28 = require("@noble/hashes/sha2");
35289
- var import_viem27 = require("viem");
35972
+ var import_viem28 = require("viem");
35290
35973
  var import_zod4 = require("zod");
35291
- var import_errors8 = require("./errors.cjs");
35974
+ var import_errors9 = require("./errors.cjs");
35292
35975
 
35293
35976
  // src/protocol/write-request.ts
35294
35977
  var import_sha27 = require("@noble/hashes/sha2");
35295
- var import_viem26 = require("viem");
35296
- var import_errors7 = require("./errors.cjs");
35978
+ var import_viem27 = require("viem");
35979
+ var import_errors8 = require("./errors.cjs");
35297
35980
  function normalizeBaseUrl2(url) {
35298
35981
  return url.replace(/\/+$/, "");
35299
35982
  }
35300
35983
  function resolveFetch3(fetchFn) {
35301
35984
  const resolved = fetchFn ?? globalThis.fetch;
35302
35985
  if (resolved === void 0) {
35303
- throw new import_errors7.WriteRequestError("No fetch implementation available");
35986
+ throw new import_errors8.WriteRequestError("No fetch implementation available");
35304
35987
  }
35305
35988
  return resolved;
35306
35989
  }
@@ -35360,14 +36043,14 @@ function freshProofNonce() {
35360
36043
  return webCrypto2.randomUUID();
35361
36044
  }
35362
36045
  if (typeof webCrypto2?.getRandomValues === "function") {
35363
- return (0, import_viem26.bytesToHex)(webCrypto2.getRandomValues(new Uint8Array(16)));
36046
+ return (0, import_viem27.bytesToHex)(webCrypto2.getRandomValues(new Uint8Array(16)));
35364
36047
  }
35365
- throw new import_errors7.WriteRequestError(
36048
+ throw new import_errors8.WriteRequestError(
35366
36049
  "No secure random source available to build a proof nonce; provide a crypto global"
35367
36050
  );
35368
36051
  }
35369
36052
  function proofKeyFor(parts) {
35370
- return (0, import_viem26.bytesToHex)(
36053
+ return (0, import_viem27.bytesToHex)(
35371
36054
  (0, import_sha27.sha256)(
35372
36055
  new TextEncoder().encode(
35373
36056
  JSON.stringify([
@@ -35375,7 +36058,7 @@ function proofKeyFor(parts) {
35375
36058
  parts.method,
35376
36059
  parts.uri,
35377
36060
  parts.grantId,
35378
- parts.signedBytes ? (0, import_viem26.bytesToHex)((0, import_sha27.sha256)(parts.signedBytes)) : ""
36061
+ parts.signedBytes ? (0, import_viem27.bytesToHex)((0, import_sha27.sha256)(parts.signedBytes)) : ""
35379
36062
  ])
35380
36063
  )
35381
36064
  )
@@ -35397,7 +36080,7 @@ async function sendWithFreshProof(label, fetchFn, options, proofKey, build) {
35397
36080
  delayMs *= 2;
35398
36081
  }
35399
36082
  }
35400
- throw new import_errors7.WriteTransportError(
36083
+ throw new import_errors8.WriteTransportError(
35401
36084
  `${label} failed after ${attempts} attempt(s): ${errorMessage(lastError)}`,
35402
36085
  attempts,
35403
36086
  lastError
@@ -35468,7 +36151,7 @@ async function openWriteSession(params) {
35468
36151
  const mintedAt = Date.now();
35469
36152
  if (!response.ok) {
35470
36153
  const { errorCode, message, details } = await readPersonalServerErrorBody(response);
35471
- throw new import_errors8.WriteSessionError(
36154
+ throw new import_errors9.WriteSessionError(
35472
36155
  message ?? `Write session handshake failed: ${response.status} ${response.statusText}`,
35473
36156
  response.status,
35474
36157
  errorCode,
@@ -35479,7 +36162,7 @@ async function openWriteSession(params) {
35479
36162
  try {
35480
36163
  body = await response.json();
35481
36164
  } catch (err) {
35482
- throw new import_errors8.WriteSessionError(
36165
+ throw new import_errors9.WriteSessionError(
35483
36166
  "Write session response is not JSON",
35484
36167
  response.status,
35485
36168
  null,
@@ -35488,7 +36171,7 @@ async function openWriteSession(params) {
35488
36171
  }
35489
36172
  const parsed = WriteSessionResponseSchema.safeParse(body);
35490
36173
  if (!parsed.success) {
35491
- throw new import_errors8.WriteSessionError(
36174
+ throw new import_errors9.WriteSessionError(
35492
36175
  "Write session response is not a session",
35493
36176
  response.status,
35494
36177
  null,
@@ -35496,7 +36179,7 @@ async function openWriteSession(params) {
35496
36179
  );
35497
36180
  }
35498
36181
  if (parsed.data.token_type.toLowerCase() !== "bearer") {
35499
- throw new import_errors8.WriteSessionError(
36182
+ throw new import_errors9.WriteSessionError(
35500
36183
  `Write session token type is not Bearer: ${parsed.data.token_type}`,
35501
36184
  response.status
35502
36185
  );
@@ -35518,7 +36201,7 @@ function isWriteSession(value) {
35518
36201
  }
35519
36202
  function sessionCoversScope(session, scope) {
35520
36203
  if (!isRecord4(session) || !Array.isArray(session.writeScopes) || !session.writeScopes.every((pattern) => typeof pattern === "string")) {
35521
- throw new import_errors8.WriteRequestError("session must come from openWriteSession");
36204
+ throw new import_errors9.WriteRequestError("session must come from openWriteSession");
35522
36205
  }
35523
36206
  return session.writeScopes.some(
35524
36207
  (pattern) => scopeMatchesPattern(scope, pattern)
@@ -35543,12 +36226,12 @@ function encodeWriteMetadataHeader(metadata) {
35543
36226
  try {
35544
36227
  json = JSON.stringify(metadata);
35545
36228
  } catch (err) {
35546
- throw new import_errors8.WriteRequestError(
36229
+ throw new import_errors9.WriteRequestError(
35547
36230
  `metadata is not JSON-serialisable: ${errorMessage(err)}`
35548
36231
  );
35549
36232
  }
35550
36233
  if (typeof json !== "string") {
35551
- throw new import_errors8.WriteRequestError("metadata must serialise to JSON");
36234
+ throw new import_errors9.WriteRequestError("metadata must serialise to JSON");
35552
36235
  }
35553
36236
  return json.replace(
35554
36237
  /[\u007f-\uffff]/g,
@@ -35562,7 +36245,7 @@ function binaryWriteSignedBytes(input) {
35562
36245
  mimeType: normalizeBinaryMimeType(input.contentType),
35563
36246
  ...input.filename ? { filename: input.filename } : {},
35564
36247
  sizeBytes: input.bytes.length,
35565
- contentHash: (0, import_viem27.bytesToHex)((0, import_sha28.sha256)(input.bytes)),
36248
+ contentHash: (0, import_viem28.bytesToHex)((0, import_sha28.sha256)(input.bytes)),
35566
36249
  encoding: "base64",
35567
36250
  content: toBase64(input.bytes),
35568
36251
  ...metadata !== void 0 ? { metadata } : {}
@@ -35583,7 +36266,7 @@ function setFilenameHeader(headers, filename) {
35583
36266
  function assertNoReservedKeys(value, where) {
35584
36267
  for (const key of RESERVED_WRITE_KEYS) {
35585
36268
  if (Object.prototype.hasOwnProperty.call(value, key)) {
35586
- throw new import_errors8.WriteRequestError(
36269
+ throw new import_errors9.WriteRequestError(
35587
36270
  `${where} must not contain the reserved ${key} key; the Personal Server stamps it`,
35588
36271
  { key }
35589
36272
  );
@@ -35595,10 +36278,10 @@ function isLineagePair(value) {
35595
36278
  }
35596
36279
  function normalizeLineage(lineage, derivedScope) {
35597
36280
  if (!Array.isArray(lineage)) {
35598
- throw new import_errors8.WriteRequestError("lineage must be an array of data point ids");
36281
+ throw new import_errors9.WriteRequestError("lineage must be an array of data point ids");
35599
36282
  }
35600
36283
  if (lineage.length > MAX_LINEAGE_SOURCES) {
35601
- throw new import_errors8.WriteRequestError(
36284
+ throw new import_errors9.WriteRequestError(
35602
36285
  `lineage lists ${lineage.length} sources; the maximum is ${MAX_LINEAGE_SOURCES}`,
35603
36286
  { max: MAX_LINEAGE_SOURCES, count: lineage.length }
35604
36287
  );
@@ -35610,14 +36293,14 @@ function normalizeLineage(lineage, derivedScope) {
35610
36293
  for (const entry of lineage) {
35611
36294
  let id;
35612
36295
  if (isLineagePair(entry)) {
35613
- if (!(0, import_viem27.isAddress)(entry.ownerAddress, { strict: false })) {
35614
- throw new import_errors8.WriteRequestError(
36296
+ if (!(0, import_viem28.isAddress)(entry.ownerAddress, { strict: false })) {
36297
+ throw new import_errors9.WriteRequestError(
35615
36298
  "lineage source ownerAddress must be an EVM address",
35616
36299
  { ownerAddress: entry.ownerAddress }
35617
36300
  );
35618
36301
  }
35619
36302
  if (entry.scope.length === 0) {
35620
- throw new import_errors8.WriteRequestError("lineage source scope is required");
36303
+ throw new import_errors9.WriteRequestError("lineage source scope is required");
35621
36304
  }
35622
36305
  id = deriveDataPointId(entry.ownerAddress, entry.scope);
35623
36306
  sourceScopes.push(entry.scope);
@@ -35625,14 +36308,14 @@ function normalizeLineage(lineage, derivedScope) {
35625
36308
  } else if (isDataPointId(entry)) {
35626
36309
  id = entry;
35627
36310
  } else {
35628
- throw new import_errors8.WriteRequestError(
36311
+ throw new import_errors9.WriteRequestError(
35629
36312
  "lineage entries must be 32-byte hex data point ids or { ownerAddress, scope } pairs",
35630
36313
  { entry }
35631
36314
  );
35632
36315
  }
35633
36316
  const normalized = id.toLowerCase();
35634
36317
  if (seen.has(normalized)) {
35635
- throw new import_errors8.WriteRequestError("lineage must not repeat a data point id", {
36318
+ throw new import_errors9.WriteRequestError("lineage must not repeat a data point id", {
35636
36319
  dataPointId: normalized
35637
36320
  });
35638
36321
  }
@@ -35641,7 +36324,7 @@ function normalizeLineage(lineage, derivedScope) {
35641
36324
  }
35642
36325
  for (const own of ownIds) {
35643
36326
  if (seen.has(own)) {
35644
- throw new import_errors8.WriteRequestError(
36327
+ throw new import_errors9.WriteRequestError(
35645
36328
  "lineage must not cite the record's own data point",
35646
36329
  { dataPointId: own, scope: derivedScope }
35647
36330
  );
@@ -35652,7 +36335,7 @@ function normalizeLineage(lineage, derivedScope) {
35652
36335
  }
35653
36336
  function assertNoLineageField(value, where) {
35654
36337
  if (Object.prototype.hasOwnProperty.call(value, LINEAGE_FIELD)) {
35655
- throw new import_errors8.WriteRequestError(
36338
+ throw new import_errors9.WriteRequestError(
35656
36339
  `${where}.${LINEAGE_FIELD} is reserved; pass sources through the lineage option`
35657
36340
  );
35658
36341
  }
@@ -35660,7 +36343,7 @@ function assertNoLineageField(value, where) {
35660
36343
  function buildMetadataHeader(metadata, sources) {
35661
36344
  if (metadata !== void 0) {
35662
36345
  if (!isRecord4(metadata)) {
35663
- throw new import_errors8.WriteRequestError("metadata must be a plain object");
36346
+ throw new import_errors9.WriteRequestError("metadata must be a plain object");
35664
36347
  }
35665
36348
  assertNoReservedKeys(metadata, "metadata");
35666
36349
  assertNoLineageField(metadata, "metadata");
@@ -35673,24 +36356,24 @@ function buildMetadataHeader(metadata, sources) {
35673
36356
  }
35674
36357
  function prepareWrite(params) {
35675
36358
  if (params.binary !== void 0 && params.data !== void 0) {
35676
- throw new import_errors8.WriteRequestError("Pass either data or binary, not both");
36359
+ throw new import_errors9.WriteRequestError("Pass either data or binary, not both");
35677
36360
  }
35678
36361
  const rawLineage = params.lineage;
35679
36362
  const sources = rawLineage === void 0 || rawLineage === null ? void 0 : normalizeLineage(rawLineage, params.scope);
35680
36363
  if (params.binary !== void 0) {
35681
36364
  const { bytes, contentType, filename } = params.binary;
35682
36365
  if (!(bytes instanceof Uint8Array)) {
35683
- throw new import_errors8.WriteRequestError("binary.bytes must be a Uint8Array");
36366
+ throw new import_errors9.WriteRequestError("binary.bytes must be a Uint8Array");
35684
36367
  }
35685
36368
  if (typeof contentType !== "string" || contentType.trim() === "") {
35686
- throw new import_errors8.WriteRequestError("binary.contentType is required");
36369
+ throw new import_errors9.WriteRequestError("binary.contentType is required");
35687
36370
  }
35688
36371
  if (filename !== void 0) {
35689
36372
  if (typeof filename !== "string") {
35690
- throw new import_errors8.WriteRequestError("binary.filename must be a string");
36373
+ throw new import_errors9.WriteRequestError("binary.filename must be a string");
35691
36374
  }
35692
36375
  if (filename !== filename.trim()) {
35693
- throw new import_errors8.WriteRequestError(
36376
+ throw new import_errors9.WriteRequestError(
35694
36377
  "binary.filename must not have leading or trailing whitespace"
35695
36378
  );
35696
36379
  }
@@ -35710,13 +36393,13 @@ function prepareWrite(params) {
35710
36393
  };
35711
36394
  }
35712
36395
  if (params.data === void 0) {
35713
- throw new import_errors8.WriteRequestError("Pass data (a JSON object) or binary");
36396
+ throw new import_errors9.WriteRequestError("Pass data (a JSON object) or binary");
35714
36397
  }
35715
36398
  if (!isRecord4(params.data)) {
35716
- throw new import_errors8.WriteRequestError("data must be a plain JSON object");
36399
+ throw new import_errors9.WriteRequestError("data must be a plain JSON object");
35717
36400
  }
35718
36401
  if (params.metadata !== void 0) {
35719
- throw new import_errors8.WriteRequestError(
36402
+ throw new import_errors9.WriteRequestError(
35720
36403
  "metadata applies to binary writes; put fields to store inside data"
35721
36404
  );
35722
36405
  }
@@ -35727,12 +36410,12 @@ function prepareWrite(params) {
35727
36410
  try {
35728
36411
  text = JSON.stringify(record);
35729
36412
  } catch (err) {
35730
- throw new import_errors8.WriteRequestError(
36413
+ throw new import_errors9.WriteRequestError(
35731
36414
  `data is not JSON-serialisable: ${errorMessage(err)}`
35732
36415
  );
35733
36416
  }
35734
36417
  if (typeof text !== "string" || !text.startsWith("{")) {
35735
- throw new import_errors8.WriteRequestError("data must serialise to a JSON object");
36418
+ throw new import_errors9.WriteRequestError("data must serialise to a JSON object");
35736
36419
  }
35737
36420
  const body = new TextEncoder().encode(text);
35738
36421
  return {
@@ -35745,31 +36428,31 @@ async function writeErrorFromResponse(response) {
35745
36428
  const { errorCode, message, details } = await readPersonalServerErrorBody(response);
35746
36429
  const text = message ?? `Personal Server write failed: ${response.status} ${response.statusText}`;
35747
36430
  if (response.status === 422 || errorCode?.startsWith("LINEAGE_")) {
35748
- return new import_errors8.WriteLineageError(text, response.status, errorCode, details);
36431
+ return new import_errors9.WriteLineageError(text, response.status, errorCode, details);
35749
36432
  }
35750
36433
  switch (response.status) {
35751
36434
  case 401:
35752
- return new import_errors8.WriteUnauthorizedError(text, errorCode, details);
36435
+ return new import_errors9.WriteUnauthorizedError(text, errorCode, details);
35753
36436
  case 403:
35754
- return new import_errors8.WriteForbiddenError(text, errorCode, details);
36437
+ return new import_errors9.WriteForbiddenError(text, errorCode, details);
35755
36438
  case 409:
35756
- return new import_errors8.WriteConflictError(text, errorCode, details);
36439
+ return new import_errors9.WriteConflictError(text, errorCode, details);
35757
36440
  default:
35758
- return new import_errors8.WriteRejectedError(text, response.status, errorCode, details);
36441
+ return new import_errors9.WriteRejectedError(text, response.status, errorCode, details);
35759
36442
  }
35760
36443
  }
35761
36444
  async function writeData(params) {
35762
36445
  const { session } = params;
35763
36446
  if (!isWriteSession(session)) {
35764
- throw new import_errors8.WriteRequestError("session must come from openWriteSession");
36447
+ throw new import_errors9.WriteRequestError("session must come from openWriteSession");
35765
36448
  }
35766
36449
  const fetchFn = resolveFetch3(params.fetch);
35767
36450
  if (typeof params.scope !== "string" || params.scope.length === 0) {
35768
- throw new import_errors8.WriteRequestError("scope is required");
36451
+ throw new import_errors9.WriteRequestError("scope is required");
35769
36452
  }
35770
36453
  const prepared = prepareWrite(params);
35771
36454
  if (Date.now() >= session.expiresAt) {
35772
- throw new import_errors8.WriteSessionExpiredError(
36455
+ throw new import_errors9.WriteSessionExpiredError(
35773
36456
  "Write session has expired; open a new session",
35774
36457
  { grantId: session.grantId, expiresAt: session.expiresAt }
35775
36458
  );
@@ -35825,7 +36508,7 @@ async function writeData(params) {
35825
36508
  try {
35826
36509
  body = await response.json();
35827
36510
  } catch (err) {
35828
- throw new import_errors8.WriteRejectedError(
36511
+ throw new import_errors9.WriteRejectedError(
35829
36512
  "Personal Server write response is not JSON",
35830
36513
  response.status,
35831
36514
  null,
@@ -35834,7 +36517,7 @@ async function writeData(params) {
35834
36517
  }
35835
36518
  const parsed = WriteDataResultSchema.safeParse(body);
35836
36519
  if (!parsed.success) {
35837
- throw new import_errors8.WriteRejectedError(
36520
+ throw new import_errors9.WriteRejectedError(
35838
36521
  "Personal Server write response is not an ingest result",
35839
36522
  response.status,
35840
36523
  null,
@@ -35861,7 +36544,7 @@ async function writePersonalServerData(params) {
35861
36544
 
35862
36545
  // src/protocol/derivative-questions.ts
35863
36546
  var import_zod5 = require("zod");
35864
- var import_errors9 = require("./errors.cjs");
36547
+ var import_errors10 = require("./errors.cjs");
35865
36548
  var DERIVATIVE_QUESTIONS_PATH = "/v1/derivatives/questions";
35866
36549
  var MAX_QUESTION_SOURCE_SCOPES = 16;
35867
36550
  var MAX_QUESTION_CHARS = 8e3;
@@ -35944,15 +36627,15 @@ function fetchIdOf(fetchFn) {
35944
36627
  }
35945
36628
  function resolveRequest(params) {
35946
36629
  if (typeof params.personalServerUrl !== "string" || params.personalServerUrl.length === 0) {
35947
- throw new import_errors9.WriteRequestError("personalServerUrl is required");
36630
+ throw new import_errors10.WriteRequestError("personalServerUrl is required");
35948
36631
  }
35949
36632
  if (typeof params.grantId !== "string" || params.grantId.length === 0) {
35950
- throw new import_errors9.WriteRequestError(
36633
+ throw new import_errors10.WriteRequestError(
35951
36634
  "grantId is required; a question call runs under the grant carrying write:<derivedScope>"
35952
36635
  );
35953
36636
  }
35954
36637
  if (params.signer === null || typeof params.signer !== "object") {
35955
- throw new import_errors9.WriteRequestError(
36638
+ throw new import_errors10.WriteRequestError(
35956
36639
  "signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
35957
36640
  );
35958
36641
  }
@@ -36006,37 +36689,37 @@ async function questionErrorFromResponse(response, body) {
36006
36689
  const text = message ?? `Derivative question request failed: ${response.status} ${response.statusText}`;
36007
36690
  switch (errorCode) {
36008
36691
  case "DERIVATIVE_SOURCE_NOT_GRANTED":
36009
- return new import_errors9.DerivativeSourceNotGrantedError(text, errorCode, details);
36692
+ return new import_errors10.DerivativeSourceNotGrantedError(text, errorCode, details);
36010
36693
  case "DERIVATIVE_CYCLE":
36011
- return new import_errors9.DerivativeCycleError(text, errorCode, details);
36694
+ return new import_errors10.DerivativeCycleError(text, errorCode, details);
36012
36695
  case "DERIVATIVE_COMPUTE_UNAVAILABLE":
36013
- return new import_errors9.DerivativeComputeUnavailableError(text, errorCode, details);
36696
+ return new import_errors10.DerivativeComputeUnavailableError(text, errorCode, details);
36014
36697
  case "DERIVATIVE_QUESTION_INVALID":
36015
36698
  case "LINEAGE_SCOPE_UNDER_SOURCE_PREFIX":
36016
- return new import_errors9.DerivativeQuestionInvalidError(
36699
+ return new import_errors10.DerivativeQuestionInvalidError(
36017
36700
  text,
36018
36701
  response.status,
36019
36702
  errorCode,
36020
36703
  details
36021
36704
  );
36022
36705
  case "DERIVATIVE_QUESTION_NOT_FOUND":
36023
- return new import_errors9.DerivativeQuestionNotFoundError(text, errorCode, details);
36706
+ return new import_errors10.DerivativeQuestionNotFoundError(text, errorCode, details);
36024
36707
  case "DERIVATIVE_DERIVED_SCOPE_REQUIRED":
36025
- return new import_errors9.DerivativeDerivedScopeRequiredError(text, errorCode, details);
36708
+ return new import_errors10.DerivativeDerivedScopeRequiredError(text, errorCode, details);
36026
36709
  default:
36027
36710
  break;
36028
36711
  }
36029
36712
  switch (response.status) {
36030
36713
  case 401:
36031
- return new import_errors9.WriteUnauthorizedError(text, errorCode, details);
36714
+ return new import_errors10.WriteUnauthorizedError(text, errorCode, details);
36032
36715
  case 403:
36033
- return new import_errors9.WriteForbiddenError(text, errorCode, details);
36716
+ return new import_errors10.WriteForbiddenError(text, errorCode, details);
36034
36717
  case 404:
36035
- return new import_errors9.DerivativeQuestionNotFoundError(text, errorCode, details);
36718
+ return new import_errors10.DerivativeQuestionNotFoundError(text, errorCode, details);
36036
36719
  case 409:
36037
- return new import_errors9.WriteConflictError(text, errorCode, details);
36720
+ return new import_errors10.WriteConflictError(text, errorCode, details);
36038
36721
  default:
36039
- return new import_errors9.DerivativeQuestionRejectedError(
36722
+ return new import_errors10.DerivativeQuestionRejectedError(
36040
36723
  text,
36041
36724
  response.status,
36042
36725
  errorCode,
@@ -36116,7 +36799,7 @@ async function sendQuestionRequest(params, spec, schema) {
36116
36799
  try {
36117
36800
  body = await response.json();
36118
36801
  } catch (err) {
36119
- throw new import_errors9.DerivativeQuestionRejectedError(
36802
+ throw new import_errors10.DerivativeQuestionRejectedError(
36120
36803
  `${spec.label} response is not JSON`,
36121
36804
  response.status,
36122
36805
  null,
@@ -36125,7 +36808,7 @@ async function sendQuestionRequest(params, spec, schema) {
36125
36808
  }
36126
36809
  const parsed = schema.safeParse(body);
36127
36810
  if (!parsed.success) {
36128
- throw new import_errors9.DerivativeQuestionRejectedError(
36811
+ throw new import_errors10.DerivativeQuestionRejectedError(
36129
36812
  `${spec.label} response is not a derivative question answer`,
36130
36813
  response.status,
36131
36814
  null,
@@ -36136,22 +36819,22 @@ async function sendQuestionRequest(params, spec, schema) {
36136
36819
  }
36137
36820
  function assertQuestionId(questionId) {
36138
36821
  if (typeof questionId !== "string" || questionId.length === 0) {
36139
- throw new import_errors9.WriteRequestError("questionId is required");
36822
+ throw new import_errors10.WriteRequestError("questionId is required");
36140
36823
  }
36141
36824
  return `${DERIVATIVE_QUESTIONS_PATH}/${encodeURIComponent(questionId)}`;
36142
36825
  }
36143
36826
  function registrationBody(params) {
36144
36827
  const { derivedScope, question } = params;
36145
36828
  if (typeof derivedScope !== "string" || derivedScope.length === 0) {
36146
- throw new import_errors9.WriteRequestError("derivedScope is required");
36829
+ throw new import_errors10.WriteRequestError("derivedScope is required");
36147
36830
  }
36148
36831
  if (!Array.isArray(params.sourceScopes) || params.sourceScopes.length === 0) {
36149
- throw new import_errors9.WriteRequestError(
36832
+ throw new import_errors10.WriteRequestError(
36150
36833
  "sourceScopes must be a non-empty array of scopes"
36151
36834
  );
36152
36835
  }
36153
36836
  if (params.sourceScopes.length > MAX_QUESTION_SOURCE_SCOPES) {
36154
- throw new import_errors9.WriteRequestError(
36837
+ throw new import_errors10.WriteRequestError(
36155
36838
  `sourceScopes lists ${params.sourceScopes.length} scopes; the maximum is ${MAX_QUESTION_SOURCE_SCOPES}`,
36156
36839
  { max: MAX_QUESTION_SOURCE_SCOPES, count: params.sourceScopes.length }
36157
36840
  );
@@ -36159,15 +36842,15 @@ function registrationBody(params) {
36159
36842
  const sourceScopes = [];
36160
36843
  for (const scope of params.sourceScopes) {
36161
36844
  if (typeof scope !== "string" || scope.length === 0) {
36162
- throw new import_errors9.WriteRequestError("sourceScopes entries must be scope strings");
36845
+ throw new import_errors10.WriteRequestError("sourceScopes entries must be scope strings");
36163
36846
  }
36164
36847
  if (sourceScopes.includes(scope)) {
36165
- throw new import_errors9.WriteRequestError("sourceScopes must not repeat a scope", {
36848
+ throw new import_errors10.WriteRequestError("sourceScopes must not repeat a scope", {
36166
36849
  duplicate: scope
36167
36850
  });
36168
36851
  }
36169
36852
  if (scope === derivedScope) {
36170
- throw new import_errors9.WriteRequestError(
36853
+ throw new import_errors10.WriteRequestError(
36171
36854
  "derivedScope cannot be one of its own sources",
36172
36855
  { scope }
36173
36856
  );
@@ -36175,17 +36858,17 @@ function registrationBody(params) {
36175
36858
  sourceScopes.push(scope);
36176
36859
  }
36177
36860
  if (typeof question !== "string" || question.trim() === "") {
36178
- throw new import_errors9.WriteRequestError("question must be a non-empty string");
36861
+ throw new import_errors10.WriteRequestError("question must be a non-empty string");
36179
36862
  }
36180
36863
  if (question.length > MAX_QUESTION_CHARS) {
36181
- throw new import_errors9.WriteRequestError(
36864
+ throw new import_errors10.WriteRequestError(
36182
36865
  `question is ${question.length} characters; the maximum is ${MAX_QUESTION_CHARS}`,
36183
36866
  { max: MAX_QUESTION_CHARS, length: question.length }
36184
36867
  );
36185
36868
  }
36186
36869
  if (params.model !== void 0) {
36187
36870
  if (typeof params.model !== "string" || params.model.length > MAX_QUESTION_MODEL_CHARS || !MODEL_ID_PATTERN.test(params.model)) {
36188
- throw new import_errors9.WriteRequestError("model must be a provider model id", {
36871
+ throw new import_errors10.WriteRequestError("model must be a provider model id", {
36189
36872
  model: params.model
36190
36873
  });
36191
36874
  }
@@ -36221,7 +36904,7 @@ async function getQuestion(params) {
36221
36904
  }
36222
36905
  async function listQuestions(params) {
36223
36906
  if (typeof params.derivedScope !== "string" || params.derivedScope.length === 0) {
36224
- throw new import_errors9.WriteRequestError(
36907
+ throw new import_errors10.WriteRequestError(
36225
36908
  "derivedScope is required; a builder may only list its own questions on a scope it may write"
36226
36909
  );
36227
36910
  }
@@ -36279,7 +36962,7 @@ async function waitForQuestion(params) {
36279
36962
  if (isSettled(latest.status)) return latest;
36280
36963
  const remaining = deadline - Date.now();
36281
36964
  if (remaining <= 0) {
36282
- throw new import_errors9.DerivativeQuestionTimeoutError(
36965
+ throw new import_errors10.DerivativeQuestionTimeoutError(
36283
36966
  `Derivative question ${latest.questionId} was still ${latest.status} after ${timeoutMs}ms`,
36284
36967
  {
36285
36968
  questionId: latest.questionId,
@@ -36299,7 +36982,7 @@ async function askPersonalServer(params) {
36299
36982
  questionId: registered.questionId
36300
36983
  });
36301
36984
  if (registration.status !== "ready") {
36302
- throw new import_errors9.DerivativeQuestionFailedError(
36985
+ throw new import_errors10.DerivativeQuestionFailedError(
36303
36986
  `Derivative question ${registration.questionId} failed: ${registration.error ?? "no reason given"}`,
36304
36987
  {
36305
36988
  questionId: registration.questionId,
@@ -36326,7 +37009,7 @@ async function askPersonalServer(params) {
36326
37009
 
36327
37010
  // src/protocol/derivative-status.ts
36328
37011
  var import_zod6 = require("zod");
36329
- var import_errors10 = require("./errors.cjs");
37012
+ var import_errors11 = require("./errors.cjs");
36330
37013
  var DERIVATIVE_STATUS_PATH = "/v1/derivatives/status";
36331
37014
  var DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS = 12e4;
36332
37015
  var DEFAULT_DERIVATIVE_STATUS_POLL_INTERVAL_MS = 2e3;
@@ -36357,13 +37040,13 @@ function normalizeBaseUrl3(url) {
36357
37040
  function resolveFetch4(fetchFn) {
36358
37041
  const resolved = fetchFn ?? globalThis.fetch;
36359
37042
  if (resolved === void 0) {
36360
- throw new import_errors10.WriteRequestError("No fetch implementation available");
37043
+ throw new import_errors11.WriteRequestError("No fetch implementation available");
36361
37044
  }
36362
37045
  return resolved;
36363
37046
  }
36364
37047
  function requireDerivedScope(derivedScope) {
36365
37048
  if (typeof derivedScope !== "string" || derivedScope.length === 0) {
36366
- throw new import_errors10.WriteRequestError("derivedScope is required");
37049
+ throw new import_errors11.WriteRequestError("derivedScope is required");
36367
37050
  }
36368
37051
  return derivedScope;
36369
37052
  }
@@ -36382,7 +37065,7 @@ function sleep4(ms, signal) {
36382
37065
  });
36383
37066
  }
36384
37067
  function timeoutError(latest, timeoutMs) {
36385
- return new import_errors10.DerivativeQuestionTimeoutError(
37068
+ return new import_errors11.DerivativeQuestionTimeoutError(
36386
37069
  `Derived scope ${latest.derivedScope} was still ${latest.status} after ${timeoutMs}ms`,
36387
37070
  {
36388
37071
  derivedScope: latest.derivedScope,
@@ -36395,7 +37078,7 @@ function timeoutError(latest, timeoutMs) {
36395
37078
  }
36396
37079
  function abortError2(signal) {
36397
37080
  const reason = signal?.reason;
36398
- return reason instanceof Error ? reason : new import_errors10.WriteRequestError("Derivative status wait was aborted");
37081
+ return reason instanceof Error ? reason : new import_errors11.WriteRequestError("Derivative status wait was aborted");
36399
37082
  }
36400
37083
  function isDerivativeStatusSettled(status) {
36401
37084
  if (status.status === "ready") return true;
@@ -36428,7 +37111,7 @@ async function getDerivativeStatus(params) {
36428
37111
  }
36429
37112
  );
36430
37113
  } catch (err) {
36431
- throw new import_errors10.WriteTransportError(
37114
+ throw new import_errors11.WriteTransportError(
36432
37115
  `Derivative status read failed: ${err instanceof Error ? err.message : String(err)}`,
36433
37116
  1,
36434
37117
  err
@@ -36443,7 +37126,7 @@ async function getDerivativeStatus(params) {
36443
37126
  try {
36444
37127
  body = await response.json();
36445
37128
  } catch (err) {
36446
- throw new import_errors10.DerivativeQuestionRejectedError(
37129
+ throw new import_errors11.DerivativeQuestionRejectedError(
36447
37130
  "Derivative status response is not JSON",
36448
37131
  response.status,
36449
37132
  null,
@@ -36452,7 +37135,7 @@ async function getDerivativeStatus(params) {
36452
37135
  }
36453
37136
  const parsed = DerivativeStatusSchema.safeParse(body);
36454
37137
  if (!parsed.success) {
36455
- throw new import_errors10.DerivativeQuestionRejectedError(
37138
+ throw new import_errors11.DerivativeQuestionRejectedError(
36456
37139
  "Derivative status response is not a status view",
36457
37140
  response.status,
36458
37141
  null,
@@ -36486,7 +37169,7 @@ async function waitForDerivativeStatus(params) {
36486
37169
  }
36487
37170
 
36488
37171
  // src/protocol/gateway.ts
36489
- var import_errors11 = require("./errors.cjs");
37172
+ var import_errors12 = require("./errors.cjs");
36490
37173
  function withGrantPermissions(grant) {
36491
37174
  const stripped = { ...grant };
36492
37175
  delete stripped.permissions;
@@ -36532,7 +37215,7 @@ function createGatewayClient(baseUrl) {
36532
37215
  }
36533
37216
  async function deletedError(res, details) {
36534
37217
  const body = await readBody(res);
36535
- return new import_errors11.DataPointDeletedError(
37218
+ return new import_errors12.DataPointDeletedError(
36536
37219
  `Data point ${details.dataPointId ?? details.scope ?? ""} has been deleted`,
36537
37220
  { ...details, deletedAt: tombstoneDeletedAt(body) }
36538
37221
  );
@@ -36605,7 +37288,7 @@ function createGatewayClient(baseUrl) {
36605
37288
  }
36606
37289
  const record = await unwrapEnvelope(res);
36607
37290
  if (!options?.includeDeleted && isDataPointTombstone(record)) {
36608
- throw new import_errors11.DataPointDeletedError(
37291
+ throw new import_errors12.DataPointDeletedError(
36609
37292
  `Data point ${dataPointId} has been deleted`,
36610
37293
  {
36611
37294
  dataPointId,
@@ -36767,7 +37450,7 @@ function createGatewayClient(baseUrl) {
36767
37450
  })
36768
37451
  });
36769
37452
  if (res.status === 404) {
36770
- throw new import_errors11.DataPointNotFoundError(
37453
+ throw new import_errors12.DataPointNotFoundError(
36771
37454
  `Data point ${dataPointId} (scope '${params.scope}') is not registered`,
36772
37455
  details
36773
37456
  );
@@ -36778,7 +37461,7 @@ function createGatewayClient(baseUrl) {
36778
37461
  body2["currentExpectedVersion"]
36779
37462
  );
36780
37463
  const detail = stringOrUndefined(body2["error"]) ?? res.statusText;
36781
- throw new import_errors11.DataPointVersionConflictError(
37464
+ throw new import_errors12.DataPointVersionConflictError(
36782
37465
  `Gateway error: 409 ${detail}`,
36783
37466
  {
36784
37467
  ...details,
@@ -36908,259 +37591,99 @@ function createGatewayClient(baseUrl) {
36908
37591
  };
36909
37592
  }
36910
37593
 
36911
- // src/protocol/escrow.ts
36912
- var import_viem28 = require("viem");
36913
- var GENERIC_PAYMENT_TYPES = {
36914
- GenericPayment: [
36915
- { name: "payerAddress", type: "address" },
36916
- { name: "opType", type: "string" },
36917
- { name: "opId", type: "bytes32" },
36918
- { name: "asset", type: "address" },
36919
- { name: "amount", type: "uint256" },
36920
- { name: "paymentNonce", type: "uint256" }
36921
- ]
36922
- };
36923
- function genericPaymentDomain(chainId, escrowContract) {
36924
- return {
36925
- name: "Vana Data Portability",
36926
- version: "1",
36927
- chainId,
36928
- verifyingContract: escrowContract
36929
- };
37594
+ // src/direct/grant-union.ts
37595
+ var import_errors13 = require("./direct/errors.cjs");
37596
+ function dedupe(entries) {
37597
+ return [...new Set(entries)];
36930
37598
  }
36931
- var ESCROW_DEPOSIT_ABI2 = [
36932
- {
36933
- type: "function",
36934
- name: "depositNative",
36935
- stateMutability: "payable",
36936
- inputs: [{ name: "account", type: "address" }],
36937
- outputs: []
36938
- },
36939
- {
36940
- type: "function",
36941
- name: "depositToken",
36942
- stateMutability: "nonpayable",
36943
- inputs: [
36944
- { name: "account", type: "address" },
36945
- { name: "token", type: "address" },
36946
- { name: "amount", type: "uint256" }
36947
- ],
36948
- outputs: []
36949
- }
36950
- ];
36951
- var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
36952
- var EscrowWithdrawalLifecycleError = class extends Error {
36953
- constructor(httpStatus, result) {
36954
- super(result.error);
36955
- this.httpStatus = httpStatus;
36956
- this.result = result;
36957
- }
36958
- httpStatus;
36959
- result;
36960
- name = "EscrowWithdrawalLifecycleError";
36961
- };
36962
- var EscrowWithdrawalRejectionError = class extends Error {
36963
- constructor(httpStatus, result) {
36964
- super(result.error);
36965
- this.httpStatus = httpStatus;
36966
- this.result = result;
36967
- }
36968
- httpStatus;
36969
- result;
36970
- name = "EscrowWithdrawalRejectionError";
36971
- };
36972
- function createEscrowGatewayClient(baseUrl) {
36973
- const base = baseUrl.replace(/\/+$/, "");
36974
- async function throwOnError(res, context) {
36975
- if (!res.ok) {
36976
- let detail = "";
36977
- try {
36978
- const body = await res.json();
36979
- if (body.error) detail = `: ${body.error}`;
36980
- } catch {
36981
- }
36982
- throw new Error(
36983
- `Escrow gateway error (${context}): ${res.status} ${res.statusText}${detail}`
36984
- );
36985
- }
37599
+ function isCarryable(entry) {
37600
+ try {
37601
+ parseScope(parseScopeEntry(entry).scope);
37602
+ return true;
37603
+ } catch {
37604
+ return false;
36986
37605
  }
36987
- async function throwOnWithdrawError(res) {
36988
- if (res.ok) return;
36989
- let body;
36990
- try {
36991
- body = await res.json();
36992
- } catch {
36993
- throw new Error(
36994
- `Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
36995
- );
36996
- }
36997
- if (isEscrowWithdrawalFailureResult(body)) {
36998
- throw new EscrowWithdrawalLifecycleError(res.status, body);
36999
- }
37000
- if (isEscrowWithdrawalRejectedResult(body)) {
37001
- throw new EscrowWithdrawalRejectionError(res.status, body);
37002
- }
37003
- const error = getGatewayErrorMessage(body);
37004
- throw new Error(
37005
- `Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
37606
+ }
37607
+ function unionGrantScopes(liveScopes, scopes, removeScopes = []) {
37608
+ const remove = new Set(removeScopes);
37609
+ const conflicting = scopes.filter((entry) => remove.has(entry));
37610
+ if (conflicting.length > 0) {
37611
+ throw new import_errors13.DirectConfigError(
37612
+ `${conflicting.join(", ")} cannot be both requested and removed. Drop it from scopes or from removeScopes.`,
37613
+ { conflicting }
37006
37614
  );
37007
37615
  }
37616
+ const live = dedupe(liveScopes);
37617
+ const requested = dedupe(scopes);
37618
+ const liveSet = new Set(live);
37619
+ const removed = live.filter((entry) => remove.has(entry));
37620
+ const remaining = live.filter((entry) => !remove.has(entry));
37621
+ const notCarried = remaining.filter((entry) => !isCarryable(entry));
37622
+ const keptAll = remaining.filter(isCarryable);
37623
+ const added = requested.filter((entry) => !liveSet.has(entry));
37008
37624
  return {
37009
- async submitDeposit({ txHash }) {
37010
- const res = await fetch(`${base}/v1/escrow/deposit`, {
37011
- method: "POST",
37012
- headers: { "Content-Type": "application/json" },
37013
- body: JSON.stringify({ txHash })
37014
- });
37015
- if (res.status !== 200 && res.status !== 202) {
37016
- await throwOnError(res, "POST /v1/escrow/deposit");
37017
- }
37018
- return res.json();
37019
- },
37020
- async getEscrowBalance(account) {
37021
- const res = await fetch(
37022
- `${base}/v1/escrow/balance?account=${encodeURIComponent(account)}`
37023
- );
37024
- await throwOnError(res, "GET /v1/escrow/balance");
37025
- return res.json();
37026
- },
37027
- async syncEscrowBalance(account) {
37028
- const res = await fetch(
37029
- `${base}/v1/escrow/balance/sync?account=${encodeURIComponent(account)}`,
37030
- { method: "POST" }
37031
- );
37032
- await throwOnError(res, "POST /v1/escrow/balance/sync");
37033
- return res.json();
37034
- },
37035
- async payForOp({
37036
- payerAddress,
37037
- opType,
37038
- opId,
37039
- asset,
37040
- amount,
37041
- paymentNonce,
37042
- signature,
37043
- accessRecord
37044
- }) {
37045
- const res = await fetch(`${base}/v1/escrow/pay`, {
37046
- method: "POST",
37047
- headers: {
37048
- "Content-Type": "application/json",
37049
- Authorization: `Web3Signed ${signature}`
37050
- },
37051
- body: JSON.stringify({
37052
- payerAddress,
37053
- opType,
37054
- opId,
37055
- asset,
37056
- amount,
37057
- paymentNonce,
37058
- ...accessRecord ? { accessRecord } : {}
37059
- })
37060
- });
37061
- await throwOnError(res, "POST /v1/escrow/pay");
37062
- return res.json();
37063
- },
37064
- async withdraw({
37065
- account,
37066
- asset,
37067
- amount,
37068
- withdrawNonce,
37069
- deadline,
37070
- signature
37071
- }) {
37072
- const res = await fetch(`${base}/v1/escrow/withdraw`, {
37073
- method: "POST",
37074
- headers: {
37075
- "Content-Type": "application/json",
37076
- Authorization: `Web3Signed ${signature}`
37077
- },
37078
- body: JSON.stringify({
37079
- account,
37080
- asset,
37081
- amount,
37082
- withdrawNonce,
37083
- deadline
37084
- })
37085
- });
37086
- await throwOnWithdrawError(res);
37087
- return res.json();
37088
- },
37089
- async getWithdrawNonce(account) {
37090
- const res = await fetch(
37091
- `${base}/v1/escrow/withdraw/nonce?account=${encodeURIComponent(account)}`,
37092
- { cache: "no-store" }
37093
- );
37094
- await throwOnError(res, "GET /v1/escrow/withdraw/nonce");
37095
- const body = await res.json();
37096
- if (!isWithdrawNonceResponse(body, account)) {
37097
- throw new Error(
37098
- "GET /v1/escrow/withdraw/nonce: invalid response structure"
37099
- );
37100
- }
37101
- return body;
37102
- }
37625
+ scopes: dedupe([...keptAll, ...added]),
37626
+ kept: keptAll,
37627
+ added,
37628
+ removed,
37629
+ notCarried,
37630
+ liveScopes: live
37103
37631
  };
37104
37632
  }
37105
- function getGatewayErrorMessage(body) {
37106
- if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
37107
- return body.error;
37108
- }
37109
- return void 0;
37110
- }
37111
- function isEscrowWithdrawalFailureResult(body) {
37112
- if (typeof body !== "object" || body === null) return false;
37113
- const value = body;
37114
- return value.success === false && (value.status === "retryable" || value.status === "reorged" || value.status === "failed") && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && (isHash(value.txHash) || value.txHash === null) && (!("blockNumber" in value) || isBlockNumber(value.blockNumber));
37115
- }
37116
- function isEscrowWithdrawalRejectedResult(body) {
37117
- if (typeof body !== "object" || body === null) return false;
37118
- const value = body;
37119
- return value.success === false && value.status === "rejected" && isWithdrawalRejectionCode(value.code) && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && optionalUint256Decimal(value.balance) && optionalUint256Decimal(value.authorizedAmount) && optionalUint256Decimal(value.withdrawingAmount) && optionalUint256Decimal(value.availableAmount) && optionalUint256Decimal(value.requestedAmount) && optionalUint256Decimal(value.minimumAmount);
37120
- }
37121
- function isWithdrawalRejectionCode(value) {
37122
- return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
37633
+ function isActiveGrant(grant) {
37634
+ return !grant.revokedAt && !grant.expired;
37123
37635
  }
37124
- function optionalUint256Decimal(value) {
37125
- return value === void 0 || isUint256Decimal(value);
37636
+ function sameHex(a, b) {
37637
+ return a.toLowerCase() === b.toLowerCase();
37126
37638
  }
37127
- function isAddressHex(value) {
37128
- return typeof value === "string" && (0, import_viem28.isHex)(value, { strict: true }) && value.length === 42;
37639
+ async function findLiveGrant(gateway, owner, granteeId) {
37640
+ const grants = await gateway.listGrantsByUser(owner);
37641
+ const matching = grants.filter(
37642
+ (grant) => sameHex(grant.granteeId, granteeId) && isActiveGrant(grant)
37643
+ ).sort((a, b) => {
37644
+ const av = BigInt(a.grantVersion || "0");
37645
+ const bv = BigInt(b.grantVersion || "0");
37646
+ return av === bv ? 0 : av > bv ? -1 : 1;
37647
+ });
37648
+ return matching[0] ?? null;
37129
37649
  }
37130
- function isHash(value) {
37131
- return typeof value === "string" && (0, import_viem28.isHex)(value, { strict: true }) && value.length === 66;
37650
+ async function liveGrantScopes(gateway, owner, granteeId) {
37651
+ const grant = await findLiveGrant(gateway, owner, granteeId);
37652
+ return grant ? [...grant.scopes] : [];
37132
37653
  }
37133
- function isUint256Decimal(value) {
37134
- if (typeof value !== "string" || value.length === 0 || value.length > 78) {
37135
- return false;
37654
+ async function resolveGranteeId(input) {
37655
+ if (input.granteeId) {
37656
+ return input.granteeId;
37136
37657
  }
37137
- if (!/^(0|[1-9]\d*)$/.test(value)) return false;
37138
- return BigInt(value) <= 2n ** 256n - 1n;
37139
- }
37140
- function isBlockNumber(value) {
37141
- return value === null || isUint256Decimal(value);
37658
+ if (!input.appAddress) {
37659
+ throw new import_errors13.DirectConfigError(
37660
+ "mergeWithLiveGrant needs granteeId or appAddress to find the app's grant."
37661
+ );
37662
+ }
37663
+ if (!input.gateway.getBuilder) {
37664
+ throw new import_errors13.DirectConfigError(
37665
+ "mergeWithLiveGrant needs gateway.getBuilder to resolve appAddress to a granteeId. Pass granteeId instead."
37666
+ );
37667
+ }
37668
+ const builder = await input.gateway.getBuilder(input.appAddress);
37669
+ return builder?.id ?? null;
37142
37670
  }
37143
- function isWithdrawNonceResponse(body, requestedAccount) {
37144
- if (typeof body !== "object" || body === null) return false;
37145
- const value = body;
37146
- if (value.success !== true) return false;
37147
- if (!isAddressHex(value.account)) return false;
37148
- if (value.account.toLowerCase() !== requestedAccount.toLowerCase())
37149
- return false;
37150
- if (typeof value.chainId !== "string") return false;
37151
- if (!/^(0|[1-9]\d*)$/.test(value.chainId)) return false;
37152
- const isLastNull = value.lastWithdrawNonce === null;
37153
- const lastNonceValid = isLastNull || isUint256Decimal(value.lastWithdrawNonce);
37154
- if (!lastNonceValid) return false;
37155
- if (!isUint256Decimal(value.nextWithdrawNonce)) return false;
37156
- if (isLastNull) {
37157
- return value.nextWithdrawNonce === "1";
37671
+ async function mergeWithLiveGrant(input) {
37672
+ const removeScopes = input.removeScopes ?? [];
37673
+ unionGrantScopes([], input.scopes, removeScopes);
37674
+ const granteeId = await resolveGranteeId(input);
37675
+ const grant = granteeId ? await findLiveGrant(input.gateway, input.owner, granteeId) : null;
37676
+ if (!grant) {
37677
+ return {
37678
+ status: "no_live_grant",
37679
+ ...unionGrantScopes([], input.scopes, removeScopes)
37680
+ };
37158
37681
  }
37159
- const lastNonce = BigInt(value.lastWithdrawNonce);
37160
- const nextNonce = BigInt(value.nextWithdrawNonce);
37161
- const expectedNextNonce = lastNonce + 1n;
37162
- if (expectedNextNonce > 2n ** 256n - 1n) return false;
37163
- return nextNonce === expectedNextNonce;
37682
+ return {
37683
+ status: "merged",
37684
+ grantId: grant.id,
37685
+ ...unionGrantScopes(grant.scopes, input.scopes, removeScopes)
37686
+ };
37164
37687
  }
37165
37688
 
37166
37689
  // src/direct/escrow-payment.ts
@@ -37399,8 +37922,8 @@ async function authorizeEscrowPayment(params) {
37399
37922
  }
37400
37923
 
37401
37924
  // src/direct/personal-server-read.ts
37402
- var import_errors12 = require("./direct/errors.cjs");
37403
- var import_errors13 = require("./errors.cjs");
37925
+ var import_errors14 = require("./direct/errors.cjs");
37926
+ var import_errors15 = require("./errors.cjs");
37404
37927
  function asRecord2(value) {
37405
37928
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
37406
37929
  }
@@ -37444,7 +37967,7 @@ function parseLegacyGrantOperation(params) {
37444
37967
  const { challengeGrantId, challengeOpId, challengeOpType, grantId } = params;
37445
37968
  const opType = challengeOpType ?? GRANT_OP_TYPE;
37446
37969
  if (opType !== GRANT_OP_TYPE) {
37447
- throw new import_errors12.PersonalServerReadError(
37970
+ throw new import_errors14.PersonalServerReadError(
37448
37971
  "Personal Server payment challenge used an unsupported escrow op type",
37449
37972
  402,
37450
37973
  { opType: challengeOpType }
@@ -37452,14 +37975,14 @@ function parseLegacyGrantOperation(params) {
37452
37975
  }
37453
37976
  const opId = challengeOpId ?? challengeGrantId ?? grantId;
37454
37977
  if (!opId || !isBytes32Hex(opId)) {
37455
- throw new import_errors12.PersonalServerReadError(
37978
+ throw new import_errors14.PersonalServerReadError(
37456
37979
  "Personal Server payment challenge used an invalid escrow op id",
37457
37980
  402,
37458
37981
  { opId }
37459
37982
  );
37460
37983
  }
37461
37984
  if (opId.toLowerCase() !== grantId.toLowerCase()) {
37462
- throw new import_errors12.PersonalServerReadError(
37985
+ throw new import_errors14.PersonalServerReadError(
37463
37986
  "Personal Server payment challenge did not match the requested grant",
37464
37987
  402,
37465
37988
  { opId, grantId }
@@ -37505,7 +38028,7 @@ function parseCanonicalDataAccessAccept(value) {
37505
38028
  function parseCanonicalDataAccessPayment(params) {
37506
38029
  const { body, grantId, raw } = params;
37507
38030
  if (body.x402Version !== 1 || body.error !== "PAYMENT_REQUIRED") {
37508
- throw new import_errors12.PersonalServerReadError(
38031
+ throw new import_errors14.PersonalServerReadError(
37509
38032
  "Personal Server data-access payment response was not a canonical x402 challenge",
37510
38033
  402
37511
38034
  );
@@ -37544,20 +38067,20 @@ async function parsePersonalServerPaymentRequired(res, grantId) {
37544
38067
  "accepts"
37545
38068
  );
37546
38069
  if (hasAcceptsEnvelope && (body.x402Version !== 1 || body.error !== "PAYMENT_REQUIRED")) {
37547
- throw new import_errors12.PersonalServerReadError(
38070
+ throw new import_errors14.PersonalServerReadError(
37548
38071
  "Personal Server grant payment response was not a canonical x402 challenge",
37549
38072
  402
37550
38073
  );
37551
38074
  }
37552
38075
  const accept = preferredLegacyAccept(body);
37553
38076
  if (hasDataAccessMarker(body) && !accept) {
37554
- throw new import_errors12.PersonalServerReadError(
38077
+ throw new import_errors14.PersonalServerReadError(
37555
38078
  "Personal Server data-access payment challenge was untrusted or incomplete",
37556
38079
  402
37557
38080
  );
37558
38081
  }
37559
38082
  if (hasAcceptsEnvelope && !accept) {
37560
- throw new import_errors12.PersonalServerReadError(
38083
+ throw new import_errors14.PersonalServerReadError(
37561
38084
  "Personal Server grant payment challenge had no compatible escrow offer",
37562
38085
  402
37563
38086
  );
@@ -37575,7 +38098,7 @@ async function parsePersonalServerPaymentRequired(res, grantId) {
37575
38098
  const accessRecord2 = parseAccessRecord(accept.accessRecord);
37576
38099
  const hasAccessRecord = accept.accessRecord !== void 0;
37577
38100
  if (!network || !payerAddress || !isAddressHex2(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex2(asset) || !amount || !isUint256Decimal3(amount, true) || !paymentNonce || !isUint256Decimal3(paymentNonce, false) || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount || hasAccessRecord && (!accessRecord2 || !isValidDataAccessRecord(accessRecord2) || accessRecord2.accessor.toLowerCase() !== payerAddress.toLowerCase()) || amount === "0" && !accessRecord2) {
37578
- throw new import_errors12.PersonalServerReadError(
38101
+ throw new import_errors14.PersonalServerReadError(
37579
38102
  "Personal Server grant payment challenge was untrusted or incomplete",
37580
38103
  402
37581
38104
  );
@@ -37863,6 +38386,7 @@ async function parsePSError(response) {
37863
38386
  encryptWithPassword,
37864
38387
  escrowContractAddress,
37865
38388
  escrowPaymentDomain,
38389
+ findLiveGrant,
37866
38390
  formatScopeEntry,
37867
38391
  gatewayLineagePath,
37868
38392
  generatePkceVerifier,
@@ -37896,7 +38420,9 @@ async function parsePSError(response) {
37896
38420
  isTombstoneHashes,
37897
38421
  kmsIssuedPreimage,
37898
38422
  listQuestions,
38423
+ liveGrantScopes,
37899
38424
  mainnetServices,
38425
+ mergeWithLiveGrant,
37900
38426
  moksha,
37901
38427
  mokshaServices,
37902
38428
  mokshaTestnet,
@@ -37940,6 +38466,7 @@ async function parsePSError(response) {
37940
38466
  toDirectPaymentReceipt,
37941
38467
  tombstoneDeletedAt,
37942
38468
  tryGrantPermissions,
38469
+ unionGrantScopes,
37943
38470
  userPsId,
37944
38471
  vanaMainnet,
37945
38472
  verifyEnclaveIdentityEvidence,