@opendatalabs/vana-sdk 3.22.0-pr.208.e9c19e9 → 3.22.0-pr.209.13d545d

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.
@@ -36,7 +36,7 @@ export { MissingAuthError, InvalidSignatureError, ExpiredTokenError, } from "./a
36
36
  export { generatePkceVerifier, computePkceChallenge, verifyPkceChallenge, assertValidPkceVerifier, PKCE_VERIFIER_PATTERN, PKCE_CHALLENGE_PATTERN, } from "./auth/pkce.js";
37
37
  export { InMemoryTokenStore, type TokenStore, type TokenRecord, } from "./auth/token-store.js";
38
38
  export { OAuthClient, type OAuthClientConfig, type AuthorizationUrlResult, } from "./auth/oauth-client.js";
39
- export { NATIVE_VANA_ASSET, dataRegistryDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain, escrowPaymentDomain, withdrawAuthorizationDomain, buildWithdrawAuthorizationTypedData, GRANT_REGISTRATION_TYPES, GRANT_REVOCATION_TYPES, SERVER_REGISTRATION_TYPES, BUILDER_REGISTRATION_TYPES, ADD_DATA_TYPES, RECORD_DATA_ACCESS_TYPES, WITHDRAW_AUTHORIZATION_TYPES, type DataPortabilityContracts, type DataPortabilityGatewayConfig, type GrantRegistrationMessage, type GrantRevocationMessage, type ServerRegistrationMessage, type BuilderRegistrationMessage, type AddDataMessage, type RecordDataAccessMessage, type WithdrawAuthorizationMessage, } from "./protocol/eip712.js";
39
+ export { NATIVE_VANA_ASSET, dataRegistryDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain, escrowPaymentDomain, GRANT_REGISTRATION_TYPES, GRANT_REVOCATION_TYPES, SERVER_REGISTRATION_TYPES, BUILDER_REGISTRATION_TYPES, ADD_DATA_TYPES, RECORD_DATA_ACCESS_TYPES, type DataPortabilityContracts, type DataPortabilityGatewayConfig, type GrantRegistrationMessage, type GrantRevocationMessage, type ServerRegistrationMessage, type BuilderRegistrationMessage, type AddDataMessage, type RecordDataAccessMessage, } from "./protocol/eip712.js";
40
40
  export { ENCLAVE_IDENTITY_EVIDENCE_VERSION, USER_PS_ID_DOMAIN, ENCLAVE_WALLET_PURPOSE, MASTER_SIGNATURE_DELIVERY_VERSION, MASTER_SIGNATURE_DELIVERY_MAX_AGE_SECONDS, SEALED_ENVELOPE_VERSION, ENCLAVE_TRUST_ANCHORS, userPsId, appRootPreimage, kmsIssuedPreimage, verifyEnclaveIdentityEvidence, buildMasterSignatureDelivery, encryptMasterSignatureDelivery, type UserPsId, type EnclaveIdentityEvidence, type ExpectedIdentity, type IdentityRequest, type IdentityState, type IdentityResponse, type IdentityRegistrationRequest, type IdentityRegistrationResponse, type MasterSignatureDelivery, type SealedSecretSubmission, type SealedSecretResponse, type AesGcmBox, type SealedEnvelope, type EnclaveTrustAnchors, } from "./protocol/identity.js";
41
41
  export { JOB_PROTOCOL_VERSION, JOB_OPERATIONS, JOB_STATES, DEFAULT_LEASE_SECONDS, MAX_LEASE_SECONDS, MAX_ATTEMPTS, MAX_WAIT_SECONDS, CLAIM_POLL_FLOOR_MS, MAX_INLINE_RESULT_BYTES, DEFAULT_JOB_DEADLINE_SECONDS, MAX_JOB_DEADLINE_SECONDS, type JobOperation, type JobState, type PaymentState, type JobRequest, type JobRequestEnvelope, type JobSubmission, type JobStatus, type ClaimRequest, type ClaimResponse, type HeartbeatRequest, type CompleteRequest, type FailRequest, type FencedResponse, type JobResult, type TeeNodeState, type TeeNodeRegistration, type TeeNodeHeartbeat, type TeeNode, } from "./protocol/jobs.js";
42
42
  export { JobEnvelopeError, canonicalJobRequestBytes, sealJobRequest, openJobRequest, sealJobResult, openJobResult, } from "./crypto/envelope/job.js";
@@ -59,7 +59,7 @@ export { DERIVATIVE_STATUS_PATH, DEFAULT_DERIVATIVE_STATUS_TIMEOUT_MS, DEFAULT_D
59
59
  export { deriveDataPointId, isDataPointId, scopeNamespace, derivedScopeViolatesNaming, assertDerivedScopeNaming, isRedactedLineageNode, personalServerLineagePath, gatewayLineagePath, getLineage, getPersonalServerLineage, getGatewayLineage, LineageNodeSchema, RedactedLineageNodeSchema, LineageEntrySchema, LineageGraphSchema, type LineageNode, type RedactedLineageNode, type LineageEntry, type LineageGraph, type LineageReadResult, type PersonalServerLineageParams, type GatewayLineageParams, type GetLineageParams, } from "./protocol/lineage.js";
60
60
  export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file.js";
61
61
  export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type OwnerServerRecord, type OwnerServersResult, type GatewayGrantFee, type GatewayGrantStatus, type GatewayGrantResponse, type GrantListItem, type DataPointRecord, type DataPointListResult, type ListDataPointsOptions, type RegisterServerParams, type RegisterServerResult, type RegisterBuilderParams, type RegisterBuilderResult, type RegisterDataPointParams, type RegisterDataPointResult, type GetDataPointOptions, type DeleteDataPointParams, type DeleteDataPointResult, type CreateGrantParams, type RevokeGrantParams, type AccessRecord, type PayForOperationParams, type PayForOperationResult, type SettleOpType, type SettleItem, type SettlePromoteResult, type SettleReconcileItem, type SettleParams, type SettleResult, type GatewayClient, } from "./protocol/gateway.js";
62
- export { createEscrowGatewayClient, genericPaymentDomain, GENERIC_PAYMENT_TYPES, ESCROW_DEPOSIT_ABI, NATIVE_ASSET_ADDRESS, type GenericPaymentMessage, type EscrowBalanceEntry, type EscrowBalanceResult, type EscrowBalanceSyncResult, type DepositSubmissionResult, type PaymentBreakdown, type EscrowPayResult, EscrowWithdrawalLifecycleError, EscrowWithdrawalRejectionError, type EscrowPaymentClient, type EscrowWithdrawalFailureResult, type EscrowWithdrawalRejectedResult, type EscrowWithdrawalRejectionCode, type EscrowWithdrawalSubmittedResult, type EscrowWithdrawalSubmittedWithoutTransaction, type EscrowWithdrawalSubmittedWithTransaction, type EscrowWithdrawalSettledResult, type EscrowWithdrawalResult, type SubmitDepositParams, type PayForOpParams, type WithdrawFromEscrowParams, type WithdrawNonceResponse, type EscrowGatewayClient, type SubmittedDepositEntry, type FinalizedDepositEntry, type FailedDepositEntry, } from "./protocol/escrow.js";
62
+ export { createEscrowGatewayClient, genericPaymentDomain, GENERIC_PAYMENT_TYPES, ESCROW_DEPOSIT_ABI, NATIVE_ASSET_ADDRESS, type GenericPaymentMessage, type EscrowBalanceEntry, type EscrowBalanceResult, type EscrowBalanceSyncResult, type DepositSubmissionResult, type PaymentBreakdown, type EscrowPayResult, type SubmitDepositParams, type PayForOpParams, type EscrowGatewayClient, type SubmittedDepositEntry, type FinalizedDepositEntry, type FailedDepositEntry, } from "./protocol/escrow.js";
63
63
  export { authorizeEscrowPayment, authorizeGrantPayment, buildEscrowPaymentHeader, buildGrantPaymentHeader, createDefaultNonceSource, DATA_ACCESS_OP_TYPE, GRANT_OP_TYPE, paymentReceiptFromHeader, paymentResponseMetadataFromHeader, toDirectFeeBreakdown, toDirectPaymentReceipt, type EscrowPaymentConfig, type EscrowPaymentHeaderConfig, type PaymentNonceSource, type SignTypedDataFn, } from "./direct/escrow-payment.js";
64
64
  export { parsePersonalServerPaymentRequired, type FetchResponseLike, } from "./direct/personal-server-read.js";
65
65
  export type { ForegroundDelivery, DirectPaymentResponseMetadata, PersonalServerDataAccessPaymentOperation, PersonalServerGrantPaymentOperation, PersonalServerPaymentOperation, PersonalServerPaymentRequired, } from "./direct/types.js";
@@ -32312,9 +32312,6 @@ function escrowPaymentDomain(config) {
32312
32312
  config.contracts.dataPortabilityEscrow
32313
32313
  );
32314
32314
  }
32315
- function withdrawAuthorizationDomain(config) {
32316
- return escrowPaymentDomain(config);
32317
- }
32318
32315
  var GRANT_REGISTRATION_TYPES = {
32319
32316
  GrantRegistration: [
32320
32317
  { name: "grantorAddress", type: "address" },
@@ -32347,15 +32344,6 @@ var BUILDER_REGISTRATION_TYPES = {
32347
32344
  { name: "appUrl", type: "string" }
32348
32345
  ]
32349
32346
  };
32350
- var WITHDRAW_AUTHORIZATION_TYPES = {
32351
- WithdrawAuthorization: [
32352
- { name: "account", type: "address" },
32353
- { name: "asset", type: "address" },
32354
- { name: "amount", type: "uint256" },
32355
- { name: "withdrawNonce", type: "uint256" },
32356
- { name: "deadline", type: "uint256" }
32357
- ]
32358
- };
32359
32347
  var ADD_DATA_TYPES = {
32360
32348
  AddData: [
32361
32349
  { name: "ownerAddress", type: "address" },
@@ -32374,14 +32362,6 @@ var RECORD_DATA_ACCESS_TYPES = {
32374
32362
  { name: "recordId", type: "bytes32" }
32375
32363
  ]
32376
32364
  };
32377
- function buildWithdrawAuthorizationTypedData(config, message) {
32378
- return {
32379
- domain: withdrawAuthorizationDomain(config),
32380
- types: WITHDRAW_AUTHORIZATION_TYPES,
32381
- primaryType: "WithdrawAuthorization",
32382
- message
32383
- };
32384
- }
32385
32365
 
32386
32366
  // src/protocol/identity.ts
32387
32367
  init_interface();
@@ -32575,7 +32555,7 @@ var MAX_JOB_DEADLINE_SECONDS = 3600;
32575
32555
  // src/crypto/envelope/job.ts
32576
32556
  init_interface();
32577
32557
  import { sha256 as sha2565 } from "@noble/hashes/sha2";
32578
- import { bytesToHex as bytesToHex2, fromHex as fromHex6, isAddress, isHex, toHex as toHex8 } from "viem";
32558
+ import { bytesToHex as bytesToHex2, fromHex as fromHex6, toHex as toHex8 } from "viem";
32579
32559
  var textDecoder = new TextDecoder();
32580
32560
  var textEncoder = new TextEncoder();
32581
32561
  var JobEnvelopeError = class extends Error {
@@ -32602,11 +32582,9 @@ function canonicalJsonBytes(value) {
32602
32582
  return textEncoder.encode(JSON.stringify(sortJsonKeys(value)));
32603
32583
  }
32604
32584
  function canonicalJobRequestBytes(request) {
32605
- validateJobRequest(request);
32606
32585
  return canonicalJsonBytes(request);
32607
32586
  }
32608
32587
  function requestPlaintext(envelope) {
32609
- validateRequestEnvelope(envelope);
32610
32588
  return canonicalJsonBytes(envelope);
32611
32589
  }
32612
32590
  function resultPlaintext(result) {
@@ -32639,99 +32617,42 @@ function parseObject(plaintext, kind) {
32639
32617
  throw new JobEnvelopeError(`Invalid ${kind}: malformed JSON`);
32640
32618
  }
32641
32619
  }
32642
- function isPlainObject2(value) {
32643
- if (value === null || typeof value !== "object") return false;
32644
- const prototype = Object.getPrototypeOf(value);
32645
- return prototype === Object.prototype || prototype === null;
32646
- }
32647
- function requirePlainObject(value, field, kind) {
32648
- if (!isPlainObject2(value)) {
32649
- throw new JobEnvelopeError(`Invalid ${kind}: invalid ${field}`);
32650
- }
32651
- }
32652
- function requireExactKeys(value, expectedKeys, kind) {
32653
- for (const key of expectedKeys) {
32654
- if (!Object.hasOwn(value, key) || value[key] === void 0) {
32655
- throw new JobEnvelopeError(`Invalid ${kind}: missing ${key}`);
32656
- }
32657
- }
32658
- const expected = new Set(expectedKeys);
32659
- for (const key of Reflect.ownKeys(value)) {
32660
- if (!expected.has(key)) {
32661
- throw new JobEnvelopeError(
32662
- `Invalid ${kind}: unknown field ${String(key)}`
32663
- );
32664
- }
32665
- }
32666
- }
32667
32620
  function requireString(value, field, kind) {
32668
32621
  if (typeof value !== "string" || value.length === 0) {
32669
32622
  throw new JobEnvelopeError(`Invalid ${kind}: missing ${field}`);
32670
32623
  }
32671
32624
  }
32672
- function validateJobRequest(value) {
32673
- requirePlainObject(value, "request", "job request");
32674
- requireExactKeys(
32675
- value,
32676
- [
32677
- "v",
32678
- "jobId",
32679
- "owner",
32680
- "builder",
32681
- "builderPublicKey",
32682
- "grantId",
32683
- "scope",
32684
- "operation",
32685
- "pinnedVersion",
32686
- "deadline"
32687
- ],
32688
- "job request"
32689
- );
32690
- if (value.v !== JOB_PROTOCOL_VERSION) {
32625
+ function validateRequestEnvelope(value) {
32626
+ const request = value.request;
32627
+ if (request === null || typeof request !== "object" || Array.isArray(request)) {
32628
+ throw new JobEnvelopeError("Invalid job request envelope: missing request");
32629
+ }
32630
+ const fields = request;
32631
+ if (fields.v !== 1) {
32691
32632
  throw new JobEnvelopeError(
32692
- `Unsupported job request version: ${String(value.v)}`
32633
+ `Unsupported job request version: ${String(fields.v)}`
32693
32634
  );
32694
32635
  }
32695
- requireString(value.jobId, "jobId", "job request");
32696
- if (typeof value.owner !== "string" || !isAddress(value.owner)) {
32697
- throw new JobEnvelopeError("Invalid job request: invalid owner");
32698
- }
32699
- if (typeof value.builder !== "string" || !isAddress(value.builder)) {
32700
- throw new JobEnvelopeError("Invalid job request: invalid builder");
32701
- }
32702
- if (typeof value.builderPublicKey !== "string" || !isHex(value.builderPublicKey)) {
32703
- throw new JobEnvelopeError("Invalid job request: invalid builderPublicKey");
32704
- }
32705
- if (typeof value.grantId !== "string" || !isHex(value.grantId)) {
32706
- throw new JobEnvelopeError("Invalid job request: invalid grantId");
32707
- }
32708
- requireString(value.scope, "scope", "job request");
32709
- if (!JOB_OPERATIONS.includes(value.operation)) {
32710
- throw new JobEnvelopeError("Invalid job request: invalid operation");
32711
- }
32712
- if (value.pinnedVersion !== null && typeof value.pinnedVersion !== "string") {
32636
+ for (const field of [
32637
+ "jobId",
32638
+ "owner",
32639
+ "builder",
32640
+ "builderPublicKey",
32641
+ "grantId",
32642
+ "scope",
32643
+ "operation",
32644
+ "deadline"
32645
+ ]) {
32646
+ requireString(fields[field], field, "job request");
32647
+ }
32648
+ if (fields.pinnedVersion !== null && typeof fields.pinnedVersion !== "string") {
32713
32649
  throw new JobEnvelopeError("Invalid job request: missing pinnedVersion");
32714
32650
  }
32715
- if (typeof value.deadline !== "string" || !Number.isFinite(Date.parse(value.deadline))) {
32716
- throw new JobEnvelopeError("Invalid job request: invalid deadline");
32717
- }
32718
- return value;
32719
- }
32720
- function validateRequestEnvelope(value) {
32721
- requirePlainObject(value, "envelope", "job request envelope");
32722
- requireExactKeys(value, ["request", "auth"], "job request envelope");
32723
- validateJobRequest(value.request);
32724
32651
  requireString(value.auth, "auth", "job request envelope");
32725
32652
  return value;
32726
32653
  }
32727
32654
  function validateResult(value) {
32728
- requirePlainObject(value, "result", "job result");
32729
- requireExactKeys(
32730
- value,
32731
- ["v", "jobId", "scope", "version", "contentType", "body"],
32732
- "job result"
32733
- );
32734
- if (value.v !== JOB_PROTOCOL_VERSION) {
32655
+ if (value.v !== 1) {
32735
32656
  throw new JobEnvelopeError(
32736
32657
  `Unsupported job result version: ${String(value.v)}`
32737
32658
  );
@@ -32747,10 +32668,10 @@ function validateResult(value) {
32747
32668
  }
32748
32669
  return value;
32749
32670
  }
32750
- async function sealJobRequest(envelope, enclavePublicKey, ecies) {
32671
+ async function sealJobRequest(e, enclavePublicKey, ecies) {
32751
32672
  const encrypted = await ecies.encrypt(
32752
32673
  fromHex6(enclavePublicKey, "bytes"),
32753
- requestPlaintext(envelope)
32674
+ requestPlaintext(e)
32754
32675
  );
32755
32676
  return encryptedBytesToBase64(encrypted);
32756
32677
  }
@@ -32763,11 +32684,10 @@ async function openJobRequest(ciphertext, privateKey, ecies) {
32763
32684
  parseObject(plaintext, "job request envelope")
32764
32685
  );
32765
32686
  }
32766
- async function sealJobResult(result, builderPublicKey, ecies) {
32767
- validateResult(result);
32687
+ async function sealJobResult(r, builderPublicKey, ecies) {
32768
32688
  const encrypted = await ecies.encrypt(
32769
32689
  fromHex6(builderPublicKey, "bytes"),
32770
- resultPlaintext(result)
32690
+ resultPlaintext(r)
32771
32691
  );
32772
32692
  const ciphertext = encryptedBytesToBase64(encrypted);
32773
32693
  const bytes = fromBase64(ciphertext);
@@ -32799,7 +32719,7 @@ async function openJobResult(ciphertext, builderPrivateKey, ecies, expect) {
32799
32719
 
32800
32720
  // src/protocol/personal-server-registration.ts
32801
32721
  import {
32802
- isAddress as isAddress2
32722
+ isAddress
32803
32723
  } from "viem";
32804
32724
  var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
32805
32725
  var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
@@ -32807,7 +32727,7 @@ var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress
32807
32727
  "DataPortabilityServers"
32808
32728
  );
32809
32729
  function assertAddress(value, name) {
32810
- if (!isAddress2(value)) {
32730
+ if (!isAddress(value)) {
32811
32731
  throw new Error(`${name} must be a valid EVM address`);
32812
32732
  }
32813
32733
  }
@@ -32894,13 +32814,13 @@ var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
32894
32814
 
32895
32815
  // src/personal-server-lite/owner-binding.ts
32896
32816
  import {
32897
- isAddress as isAddress3
32817
+ isAddress as isAddress2
32898
32818
  } from "viem";
32899
32819
  var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
32900
32820
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
32901
32821
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
32902
32822
  function assertAddress2(value, name) {
32903
- if (!isAddress3(value)) {
32823
+ if (!isAddress2(value)) {
32904
32824
  throw new Error(`${name} must be a valid EVM address`);
32905
32825
  }
32906
32826
  }
@@ -32950,7 +32870,7 @@ async function buildPersonalServerLiteOwnerBindingSignature(input) {
32950
32870
  var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
32951
32871
 
32952
32872
  // src/account/personal-server-registration.ts
32953
- import { isAddress as isAddress4 } from "viem";
32873
+ import { isAddress as isAddress3 } from "viem";
32954
32874
  var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
32955
32875
  var AccountPersonalServerRegistrationError = class extends Error {
32956
32876
  status;
@@ -32969,7 +32889,7 @@ function trimTrailingSlash(value) {
32969
32889
  return value.replace(/\/+$/, "");
32970
32890
  }
32971
32891
  function assertAddress3(value, name) {
32972
- if (!isAddress4(value)) {
32892
+ if (!isAddress3(value)) {
32973
32893
  throw new Error(`${name} must be a valid EVM address`);
32974
32894
  }
32975
32895
  }
@@ -33495,7 +33415,7 @@ function buildMarkDataPointUnavailableRequest(config, input) {
33495
33415
 
33496
33416
  // src/protocol/data-point-deletion.ts
33497
33417
  import {
33498
- isAddress as isAddress6,
33418
+ isAddress as isAddress5,
33499
33419
  keccak256 as keccak2563,
33500
33420
  maxUint256,
33501
33421
  stringToBytes as stringToBytes3
@@ -33504,7 +33424,7 @@ import {
33504
33424
  // src/protocol/lineage.ts
33505
33425
  import {
33506
33426
  encodeAbiParameters,
33507
- isAddress as isAddress5,
33427
+ isAddress as isAddress4,
33508
33428
  keccak256 as keccak2562
33509
33429
  } from "viem";
33510
33430
  import { z } from "zod";
@@ -33584,7 +33504,7 @@ function isDataPointId(value) {
33584
33504
  return typeof value === "string" && DATA_POINT_ID_PATTERN.test(value);
33585
33505
  }
33586
33506
  function deriveDataPointId(ownerAddress, scope) {
33587
- if (!isAddress5(ownerAddress, { strict: false })) {
33507
+ if (!isAddress4(ownerAddress, { strict: false })) {
33588
33508
  throw new Error(
33589
33509
  `ownerAddress is not an EVM address: ${String(ownerAddress)}`
33590
33510
  );
@@ -33835,7 +33755,7 @@ function tombstoneDeletedAt(value) {
33835
33755
  return typeof deletedAt === "string" ? deletedAt : null;
33836
33756
  }
33837
33757
  function assertAddress4(value, name) {
33838
- if (!isAddress6(value)) {
33758
+ if (!isAddress5(value)) {
33839
33759
  throw new Error(`${name} must be a valid EVM address`);
33840
33760
  }
33841
33761
  }
@@ -34251,7 +34171,7 @@ function tryGrantPermissions(scopes) {
34251
34171
 
34252
34172
  // src/protocol/personal-server-write.ts
34253
34173
  import { sha256 as sha2567 } from "@noble/hashes/sha2";
34254
- import { bytesToHex as bytesToHex4, isAddress as isAddress7 } from "viem";
34174
+ import { bytesToHex as bytesToHex4, isAddress as isAddress6 } from "viem";
34255
34175
  import { z as z4 } from "zod";
34256
34176
 
34257
34177
  // src/protocol/write-request.ts
@@ -34573,7 +34493,7 @@ function normalizeLineage(lineage, derivedScope) {
34573
34493
  for (const entry of lineage) {
34574
34494
  let id;
34575
34495
  if (isLineagePair(entry)) {
34576
- if (!isAddress7(entry.ownerAddress, { strict: false })) {
34496
+ if (!isAddress6(entry.ownerAddress, { strict: false })) {
34577
34497
  throw new WriteRequestError(
34578
34498
  "lineage source ownerAddress must be an EVM address",
34579
34499
  { ownerAddress: entry.ownerAddress }
@@ -35869,7 +35789,6 @@ function createGatewayClient(baseUrl) {
35869
35789
  }
35870
35790
 
35871
35791
  // src/protocol/escrow.ts
35872
- import { isHex as isHex2 } from "viem";
35873
35792
  var GENERIC_PAYMENT_TYPES = {
35874
35793
  GenericPayment: [
35875
35794
  { name: "payerAddress", type: "address" },
@@ -35909,26 +35828,6 @@ var ESCROW_DEPOSIT_ABI2 = [
35909
35828
  }
35910
35829
  ];
35911
35830
  var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
35912
- var EscrowWithdrawalLifecycleError = class extends Error {
35913
- constructor(httpStatus, result) {
35914
- super(result.error);
35915
- this.httpStatus = httpStatus;
35916
- this.result = result;
35917
- }
35918
- httpStatus;
35919
- result;
35920
- name = "EscrowWithdrawalLifecycleError";
35921
- };
35922
- var EscrowWithdrawalRejectionError = class extends Error {
35923
- constructor(httpStatus, result) {
35924
- super(result.error);
35925
- this.httpStatus = httpStatus;
35926
- this.result = result;
35927
- }
35928
- httpStatus;
35929
- result;
35930
- name = "EscrowWithdrawalRejectionError";
35931
- };
35932
35831
  function createEscrowGatewayClient(baseUrl) {
35933
35832
  const base = baseUrl.replace(/\/+$/, "");
35934
35833
  async function throwOnError(res, context) {
@@ -35944,27 +35843,6 @@ function createEscrowGatewayClient(baseUrl) {
35944
35843
  );
35945
35844
  }
35946
35845
  }
35947
- async function throwOnWithdrawError(res) {
35948
- if (res.ok) return;
35949
- let body;
35950
- try {
35951
- body = await res.json();
35952
- } catch {
35953
- throw new Error(
35954
- `Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}`
35955
- );
35956
- }
35957
- if (isEscrowWithdrawalFailureResult(body)) {
35958
- throw new EscrowWithdrawalLifecycleError(res.status, body);
35959
- }
35960
- if (isEscrowWithdrawalRejectedResult(body)) {
35961
- throw new EscrowWithdrawalRejectionError(res.status, body);
35962
- }
35963
- const error = getGatewayErrorMessage(body);
35964
- throw new Error(
35965
- `Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
35966
- );
35967
- }
35968
35846
  return {
35969
35847
  async submitDeposit({ txHash }) {
35970
35848
  const res = await fetch(`${base}/v1/escrow/deposit`, {
@@ -36020,108 +35898,9 @@ function createEscrowGatewayClient(baseUrl) {
36020
35898
  });
36021
35899
  await throwOnError(res, "POST /v1/escrow/pay");
36022
35900
  return res.json();
36023
- },
36024
- async withdraw({
36025
- account,
36026
- asset,
36027
- amount,
36028
- withdrawNonce,
36029
- deadline,
36030
- signature
36031
- }) {
36032
- const res = await fetch(`${base}/v1/escrow/withdraw`, {
36033
- method: "POST",
36034
- headers: {
36035
- "Content-Type": "application/json",
36036
- Authorization: `Web3Signed ${signature}`
36037
- },
36038
- body: JSON.stringify({
36039
- account,
36040
- asset,
36041
- amount,
36042
- withdrawNonce,
36043
- deadline
36044
- })
36045
- });
36046
- await throwOnWithdrawError(res);
36047
- return res.json();
36048
- },
36049
- async getWithdrawNonce(account) {
36050
- const res = await fetch(
36051
- `${base}/v1/escrow/withdraw/nonce?account=${encodeURIComponent(account)}`,
36052
- { cache: "no-store" }
36053
- );
36054
- await throwOnError(res, "GET /v1/escrow/withdraw/nonce");
36055
- const body = await res.json();
36056
- if (!isWithdrawNonceResponse(body, account)) {
36057
- throw new Error(
36058
- "GET /v1/escrow/withdraw/nonce: invalid response structure"
36059
- );
36060
- }
36061
- return body;
36062
35901
  }
36063
35902
  };
36064
35903
  }
36065
- function getGatewayErrorMessage(body) {
36066
- if (typeof body === "object" && body !== null && "error" in body && typeof body.error === "string") {
36067
- return body.error;
36068
- }
36069
- return void 0;
36070
- }
36071
- function isEscrowWithdrawalFailureResult(body) {
36072
- if (typeof body !== "object" || body === null) return false;
36073
- const value = body;
36074
- 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));
36075
- }
36076
- function isEscrowWithdrawalRejectedResult(body) {
36077
- if (typeof body !== "object" || body === null) return false;
36078
- const value = body;
36079
- 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);
36080
- }
36081
- function isWithdrawalRejectionCode(value) {
36082
- return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
36083
- }
36084
- function optionalUint256Decimal(value) {
36085
- return value === void 0 || isUint256Decimal(value);
36086
- }
36087
- function isAddressHex(value) {
36088
- return typeof value === "string" && isHex2(value, { strict: true }) && value.length === 42;
36089
- }
36090
- function isHash(value) {
36091
- return typeof value === "string" && isHex2(value, { strict: true }) && value.length === 66;
36092
- }
36093
- function isUint256Decimal(value) {
36094
- if (typeof value !== "string" || value.length === 0 || value.length > 78) {
36095
- return false;
36096
- }
36097
- if (!/^(0|[1-9]\d*)$/.test(value)) return false;
36098
- return BigInt(value) <= 2n ** 256n - 1n;
36099
- }
36100
- function isBlockNumber(value) {
36101
- return value === null || isUint256Decimal(value);
36102
- }
36103
- function isWithdrawNonceResponse(body, requestedAccount) {
36104
- if (typeof body !== "object" || body === null) return false;
36105
- const value = body;
36106
- if (value.success !== true) return false;
36107
- if (!isAddressHex(value.account)) return false;
36108
- if (value.account.toLowerCase() !== requestedAccount.toLowerCase())
36109
- return false;
36110
- if (typeof value.chainId !== "string") return false;
36111
- if (!/^(0|[1-9]\d*)$/.test(value.chainId)) return false;
36112
- const isLastNull = value.lastWithdrawNonce === null;
36113
- const lastNonceValid = isLastNull || isUint256Decimal(value.lastWithdrawNonce);
36114
- if (!lastNonceValid) return false;
36115
- if (!isUint256Decimal(value.nextWithdrawNonce)) return false;
36116
- if (isLastNull) {
36117
- return value.nextWithdrawNonce === "1";
36118
- }
36119
- const lastNonce = BigInt(value.lastWithdrawNonce);
36120
- const nextNonce = BigInt(value.nextWithdrawNonce);
36121
- const expectedNextNonce = lastNonce + 1n;
36122
- if (expectedNextNonce > 2n ** 256n - 1n) return false;
36123
- return nextNonce === expectedNextNonce;
36124
- }
36125
35904
 
36126
35905
  // src/direct/escrow-payment.ts
36127
35906
  var GRANT_OP_TYPE = "grant";
@@ -36158,12 +35937,12 @@ var UINT256_MAX = (1n << 256n) - 1n;
36158
35937
  var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
36159
35938
  var BYTES32_RE = /^0x[0-9a-fA-F]{64}$/;
36160
35939
  var SIGNATURE_RE = /^0x[0-9a-fA-F]{130}$/;
36161
- function isUint256Decimal2(value, allowZero) {
35940
+ function isUint256Decimal(value, allowZero) {
36162
35941
  const pattern = allowZero ? /^(0|[1-9]\d*)$/ : /^[1-9]\d*$/;
36163
35942
  return value.length <= UINT256_MAX.toString().length && pattern.test(value) && BigInt(value) <= UINT256_MAX;
36164
35943
  }
36165
35944
  function isValidAccessRecord(record) {
36166
- return BYTES32_RE.test(record.dataPointId) && isUint256Decimal2(record.version, false) && ADDRESS_RE.test(record.accessor) && BYTES32_RE.test(record.recordId) && SIGNATURE_RE.test(record.signature);
35945
+ return BYTES32_RE.test(record.dataPointId) && isUint256Decimal(record.version, false) && ADDRESS_RE.test(record.accessor) && BYTES32_RE.test(record.recordId) && SIGNATURE_RE.test(record.signature);
36167
35946
  }
36168
35947
  function validateSigningOperation(payerAddress, required) {
36169
35948
  if (!ADDRESS_RE.test(payerAddress)) {
@@ -36175,10 +35954,10 @@ function validateSigningOperation(payerAddress, required) {
36175
35954
  if (!ADDRESS_RE.test(required.asset || NATIVE_ASSET_ADDRESS)) {
36176
35955
  throw new Error("Payment asset must be a 20-byte EVM address");
36177
35956
  }
36178
- if (!isUint256Decimal2(required.amount, true)) {
35957
+ if (!isUint256Decimal(required.amount, true)) {
36179
35958
  throw new Error("Payment amount must be a canonical uint256 decimal");
36180
35959
  }
36181
- if (required.paymentNonce !== void 0 && !isUint256Decimal2(required.paymentNonce, false)) {
35960
+ if (required.paymentNonce !== void 0 && !isUint256Decimal(required.paymentNonce, false)) {
36182
35961
  throw new Error("Payment nonce must be a positive uint256 decimal");
36183
35962
  }
36184
35963
  const accessRecord = required.accessRecord;
@@ -36309,7 +36088,7 @@ function paymentResponseMetadataFromHeader(header) {
36309
36088
  const registrationFee = stringField(breakdown, "registrationFee");
36310
36089
  const dataAccessFee = stringField(breakdown, "dataAccessFee");
36311
36090
  const paidAt = stringField(result, "paidAt");
36312
- if (result?.success !== true || !opType || !opId || !BYTES32_RE.test(opId) || !payerAddress || !ADDRESS_RE.test(payerAddress) || !asset || !ADDRESS_RE.test(asset) || !amount || !isUint256Decimal2(amount, true) || !paymentNonce || !isUint256Decimal2(paymentNonce, false) || !registrationFee || !isUint256Decimal2(registrationFee, true) || !dataAccessFee || !isUint256Decimal2(dataAccessFee, true) || typeof breakdown?.registrationPaid !== "boolean" || !paidAt || !isCanonicalIsoTimestamp(paidAt)) {
36091
+ if (result?.success !== true || !opType || !opId || !BYTES32_RE.test(opId) || !payerAddress || !ADDRESS_RE.test(payerAddress) || !asset || !ADDRESS_RE.test(asset) || !amount || !isUint256Decimal(amount, true) || !paymentNonce || !isUint256Decimal(paymentNonce, false) || !registrationFee || !isUint256Decimal(registrationFee, true) || !dataAccessFee || !isUint256Decimal(dataAccessFee, true) || typeof breakdown?.registrationPaid !== "boolean" || !paidAt || !isCanonicalIsoTimestamp(paidAt)) {
36313
36092
  return void 0;
36314
36093
  }
36315
36094
  return {
@@ -36399,15 +36178,15 @@ function isBytes32Hex(value) {
36399
36178
  return /^0x[0-9a-fA-F]{64}$/.test(value);
36400
36179
  }
36401
36180
  var UINT256_MAX2 = (1n << 256n) - 1n;
36402
- function isAddressHex2(value) {
36181
+ function isAddressHex(value) {
36403
36182
  return /^0x[0-9a-fA-F]{40}$/.test(value);
36404
36183
  }
36405
- function isUint256Decimal3(value, allowZero) {
36184
+ function isUint256Decimal2(value, allowZero) {
36406
36185
  const pattern = allowZero ? /^(0|[1-9]\d*)$/ : /^[1-9]\d*$/;
36407
36186
  return value.length <= UINT256_MAX2.toString().length && pattern.test(value) && BigInt(value) <= UINT256_MAX2;
36408
36187
  }
36409
36188
  function isValidDataAccessRecord(record) {
36410
- return isBytes32Hex(record.dataPointId) && isUint256Decimal3(record.version, false) && isAddressHex2(record.accessor) && isBytes32Hex(record.recordId) && /^0x[0-9a-fA-F]{130}$/.test(record.signature);
36189
+ return isBytes32Hex(record.dataPointId) && isUint256Decimal2(record.version, false) && isAddressHex(record.accessor) && isBytes32Hex(record.recordId) && /^0x[0-9a-fA-F]{130}$/.test(record.signature);
36411
36190
  }
36412
36191
  function parseLegacyGrantOperation(params) {
36413
36192
  const { challengeGrantId, challengeOpId, challengeOpType, grantId } = params;
@@ -36458,7 +36237,7 @@ function parseCanonicalDataAccessAccept(value) {
36458
36237
  const accessRecord = parseAccessRecord(accept?.accessRecord);
36459
36238
  const acceptAsset = stringField2(accept, "asset");
36460
36239
  const acceptAmount = stringField2(accept, "amount");
36461
- if (!network || !payerAddress || !isAddressHex2(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex2(asset) || !amount || !isUint256Decimal3(amount, true) || !paymentNonce || !isUint256Decimal3(paymentNonce, false) || !accessRecord || !isValidDataAccessRecord(accessRecord) || payerAddress.toLowerCase() !== accessRecord.accessor.toLowerCase() || opId.toLowerCase() !== accessRecord.recordId.toLowerCase() || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount) {
36240
+ if (!network || !payerAddress || !isAddressHex(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex(asset) || !amount || !isUint256Decimal2(amount, true) || !paymentNonce || !isUint256Decimal2(paymentNonce, false) || !accessRecord || !isValidDataAccessRecord(accessRecord) || payerAddress.toLowerCase() !== accessRecord.accessor.toLowerCase() || opId.toLowerCase() !== accessRecord.recordId.toLowerCase() || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount) {
36462
36241
  return null;
36463
36242
  }
36464
36243
  return {
@@ -36543,7 +36322,7 @@ async function parsePersonalServerPaymentRequired(res, grantId) {
36543
36322
  const acceptAmount = stringField2(accept, "amount");
36544
36323
  const accessRecord2 = parseAccessRecord(accept.accessRecord);
36545
36324
  const hasAccessRecord = accept.accessRecord !== void 0;
36546
- 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) {
36325
+ if (!network || !payerAddress || !isAddressHex(payerAddress) || !opId || !isBytes32Hex(opId) || !asset || !isAddressHex(asset) || !amount || !isUint256Decimal2(amount, true) || !paymentNonce || !isUint256Decimal2(paymentNonce, false) || !acceptAsset || acceptAsset.toLowerCase() !== asset.toLowerCase() || acceptAmount !== amount || hasAccessRecord && (!accessRecord2 || !isValidDataAccessRecord(accessRecord2) || accessRecord2.accessor.toLowerCase() !== payerAddress.toLowerCase()) || amount === "0" && !accessRecord2) {
36547
36326
  throw new PersonalServerReadError(
36548
36327
  "Personal Server grant payment challenge was untrusted or incomplete",
36549
36328
  402
@@ -36700,8 +36479,6 @@ export {
36700
36479
  ENCLAVE_TRUST_ANCHORS,
36701
36480
  ENCLAVE_WALLET_PURPOSE,
36702
36481
  ESCROW_DEPOSIT_ABI2 as ESCROW_DEPOSIT_ABI,
36703
- EscrowWithdrawalLifecycleError,
36704
- EscrowWithdrawalRejectionError,
36705
36482
  ExpiredTokenError,
36706
36483
  FEE_REGISTRY_ABI,
36707
36484
  GENERIC_PAYMENT_TYPES,
@@ -36787,7 +36564,6 @@ export {
36787
36564
  UserRejectedRequestError,
36788
36565
  VanaError,
36789
36566
  VanaStorage,
36790
- WITHDRAW_AUTHORIZATION_TYPES,
36791
36567
  WRITER_ATTRIBUTION_KEY,
36792
36568
  WRITE_CONTENT_DISPOSITION_HEADER,
36793
36569
  WRITE_FILENAME_HEADER,
@@ -36825,7 +36601,6 @@ export {
36825
36601
  buildPersonalServerRegistrationTypedData,
36826
36602
  buildSetDataPointStatusRequest,
36827
36603
  buildWeb3SignedHeader,
36828
- buildWithdrawAuthorizationTypedData,
36829
36604
  builderRegistrationDomain,
36830
36605
  canonicalJobRequestBytes,
36831
36606
  chains,
@@ -36950,7 +36725,6 @@ export {
36950
36725
  verifyWeb3Signed,
36951
36726
  waitForDerivativeStatus,
36952
36727
  waitForQuestion,
36953
- withdrawAuthorizationDomain,
36954
36728
  writeData,
36955
36729
  writePersonalServerData
36956
36730
  };