@opendatalabs/vana-sdk 3.4.1 → 3.5.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 (33) hide show
  1. package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
  2. package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
  3. package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
  4. package/dist/account/personal-server-lite-owner-binding.js +1 -1
  5. package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
  6. package/dist/index.browser.d.ts +2 -1
  7. package/dist/index.browser.js +133 -6
  8. package/dist/index.browser.js.map +4 -4
  9. package/dist/index.node.cjs +138 -6
  10. package/dist/index.node.cjs.map +4 -4
  11. package/dist/index.node.d.ts +2 -1
  12. package/dist/index.node.js +133 -6
  13. package/dist/index.node.js.map +4 -4
  14. package/dist/{protocol/personal-server-lite-owner-binding.cjs → personal-server-lite/owner-binding.cjs} +5 -5
  15. package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
  16. package/dist/{protocol/personal-server-lite-owner-binding.d.ts → personal-server-lite/owner-binding.d.ts} +3 -3
  17. package/dist/{protocol/personal-server-lite-owner-binding.js → personal-server-lite/owner-binding.js} +2 -2
  18. package/dist/personal-server-lite/owner-binding.js.map +1 -0
  19. package/dist/protocol/escrow.cjs +146 -0
  20. package/dist/protocol/escrow.cjs.map +1 -0
  21. package/dist/protocol/escrow.d.ts +336 -0
  22. package/dist/protocol/escrow.js +118 -0
  23. package/dist/protocol/escrow.js.map +1 -0
  24. package/dist/protocol/escrow.test.d.ts +1 -0
  25. package/dist/protocol/personal-server-registration.cjs +16 -4
  26. package/dist/protocol/personal-server-registration.cjs.map +1 -1
  27. package/dist/protocol/personal-server-registration.d.ts +5 -2
  28. package/dist/protocol/personal-server-registration.js +16 -4
  29. package/dist/protocol/personal-server-registration.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/protocol/personal-server-lite-owner-binding.cjs.map +0 -1
  32. package/dist/protocol/personal-server-lite-owner-binding.js.map +0 -1
  33. /package/dist/{protocol/personal-server-lite-owner-binding.test.d.ts → personal-server-lite/owner-binding.test.d.ts} +0 -0
@@ -37,11 +37,12 @@ export { InMemoryTokenStore, type TokenStore, type TokenRecord, } from "./auth/t
37
37
  export { OAuthClient, type OAuthClientConfig, type AuthorizationUrlResult, } from "./auth/oauth-client";
38
38
  export { fileRegistrationDomain, fileDeletionDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain, FILE_REGISTRATION_TYPES, FILE_DELETION_TYPES, GRANT_REGISTRATION_TYPES, GRANT_REVOCATION_TYPES, SERVER_REGISTRATION_TYPES, BUILDER_REGISTRATION_TYPES, type DataPortabilityContracts, type DataPortabilityGatewayConfig, type FileRegistrationMessage, type FileDeletionMessage, type GrantRegistrationMessage, type GrantRevocationMessage, type ServerRegistrationMessage, type BuilderRegistrationMessage, } from "./protocol/eip712";
39
39
  export { PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID, PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT, personalServerRegistrationDomain, createViemPersonalServerRegistrationSigner, buildPersonalServerRegistrationTypedData, buildPersonalServerRegistrationSignature, registerPersonalServerSignature, type PersonalServerRegistrationTypedData, type PersonalServerRegistrationSigner, type PersonalServerRegistrationDomainInput, type ViemPersonalServerRegistrationWalletClient, type ViemPersonalServerRegistrationSignerSource, type BuildPersonalServerRegistrationTypedDataInput, type BuildPersonalServerRegistrationSignatureInput, type PersonalServerRegistrationSignature, } from "./protocol/personal-server-registration";
40
- export { PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION, PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE, PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX, buildPersonalServerLiteOwnerBindingMessage, createViemPersonalServerLiteOwnerBindingSigner, buildPersonalServerLiteOwnerBindingSignature, signPersonalServerLiteOwnerBinding, type PersonalServerLiteOwnerBindingPurpose, type PersonalServerLiteOwnerBindingMessage, type PersonalServerLiteOwnerBindingSigner, type ViemPersonalServerLiteOwnerBindingWalletClient, type ViemPersonalServerLiteOwnerBindingSignerSource, type BuildPersonalServerLiteOwnerBindingSignatureInput, type PersonalServerLiteOwnerBindingSignature, } from "./protocol/personal-server-lite-owner-binding";
40
+ export { PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION, PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE, PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX, buildPersonalServerLiteOwnerBindingMessage, createViemPersonalServerLiteOwnerBindingSigner, buildPersonalServerLiteOwnerBindingSignature, signPersonalServerLiteOwnerBinding, type PersonalServerLiteOwnerBindingPurpose, type PersonalServerLiteOwnerBindingMessage, type PersonalServerLiteOwnerBindingSigner, type ViemPersonalServerLiteOwnerBindingWalletClient, type ViemPersonalServerLiteOwnerBindingSignerSource, type BuildPersonalServerLiteOwnerBindingSignatureInput, type PersonalServerLiteOwnerBindingSignature, } from "./personal-server-lite/owner-binding";
41
41
  export { ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT, AccountPersonalServerRegistrationError, signPersonalServerRegistrationWithAccount, type AccountPersonalServerRegistrationIntent, type AccountPersonalServerRegistrationSignature, type AccountPersonalServerRegistrationStatus, type AccountPersonalServerRegistrationRequest, type AccountPersonalServerRegistrationConfig, type AccountSignedPersonalServerRegistration, type AccountConfirmationRequiredPersonalServerRegistration, type AccountFallbackSignedPersonalServerRegistration, type AccountPersonalServerRegistrationResult, } from "./account/personal-server-registration";
42
42
  export { AccountPersonalServerLiteOwnerBindingError, signPersonalServerLiteOwnerBindingWithAccountClient, type AccountPersonalServerLiteOwnerBindingClient, type SignPersonalServerLiteOwnerBindingWithAccountClientConfig, } from "./account/personal-server-lite-owner-binding";
43
43
  export { isDataPortabilityGatewayConfig, parseGrantRegistrationPayload, verifyGrantRegistration, type DataPortabilityGrantPayload, type VerifyGrantRegistrationInput, type VerifyGrantRegistrationResult, } from "./protocol/grants";
44
44
  export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes";
45
45
  export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file";
46
46
  export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type GatewayGrantResponse, type GrantListItem, type FileRecord, type FileListResult, type ListFilesOptions, type RegisterServerParams, type RegisterServerResult, type RegisterFileParams, type CreateGrantParams, type RevokeGrantParams, type DeleteFileParams, type GatewayClient, } from "./protocol/gateway";
47
+ 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";
47
48
  export { PSError, parsePSError, type PSErrorCode } from "./types/ps-errors";
@@ -32601,8 +32601,11 @@ var BUILDER_REGISTRATION_TYPES = {
32601
32601
  import {
32602
32602
  isAddress
32603
32603
  } from "viem";
32604
- var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
32605
- var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
32604
+ var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
32605
+ var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
32606
+ PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
32607
+ "DataPortabilityServers"
32608
+ );
32606
32609
  function assertAddress(value, name) {
32607
32610
  if (!isAddress(value)) {
32608
32611
  throw new Error(`${name} must be a valid EVM address`);
@@ -32617,6 +32620,12 @@ function getAccountAddress(account) {
32617
32620
  function isPersonalServerRegistrationSigner(source) {
32618
32621
  return "address" in source && typeof source.signTypedData === "function";
32619
32622
  }
32623
+ function getDefaultServerRegistrationContract(chainId) {
32624
+ return getContractAddress(
32625
+ chainId,
32626
+ "DataPortabilityServers"
32627
+ );
32628
+ }
32620
32629
  function createViemPersonalServerRegistrationSigner(source, options = {}) {
32621
32630
  if (isPersonalServerRegistrationSigner(source)) {
32622
32631
  return source;
@@ -32639,12 +32648,13 @@ function personalServerRegistrationDomain(input = {}) {
32639
32648
  if (input.config) {
32640
32649
  return serverRegistrationDomain(input.config);
32641
32650
  }
32642
- const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
32651
+ const chainId = input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;
32652
+ const verifyingContract = input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);
32643
32653
  assertAddress(verifyingContract, "verifyingContract");
32644
32654
  return {
32645
32655
  name: "Vana Data Portability",
32646
32656
  version: "1",
32647
- chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
32657
+ chainId,
32648
32658
  verifyingContract
32649
32659
  };
32650
32660
  }
@@ -32682,11 +32692,11 @@ async function buildPersonalServerRegistrationSignature(input) {
32682
32692
  }
32683
32693
  var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
32684
32694
 
32685
- // src/protocol/personal-server-lite-owner-binding.ts
32695
+ // src/personal-server-lite/owner-binding.ts
32686
32696
  import {
32687
32697
  isAddress as isAddress2
32688
32698
  } from "viem";
32689
- var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
32699
+ var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
32690
32700
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
32691
32701
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
32692
32702
  function assertAddress2(value, name) {
@@ -33429,6 +33439,118 @@ function createGatewayClient(baseUrl) {
33429
33439
  };
33430
33440
  }
33431
33441
 
33442
+ // src/protocol/escrow.ts
33443
+ var GENERIC_PAYMENT_TYPES = {
33444
+ GenericPayment: [
33445
+ { name: "payerAddress", type: "address" },
33446
+ { name: "opType", type: "string" },
33447
+ { name: "opId", type: "bytes32" },
33448
+ { name: "asset", type: "address" },
33449
+ { name: "amount", type: "uint256" },
33450
+ { name: "paymentNonce", type: "uint256" }
33451
+ ]
33452
+ };
33453
+ function genericPaymentDomain(chainId, escrowContract) {
33454
+ return {
33455
+ name: "Vana Data Portability",
33456
+ version: "1",
33457
+ chainId,
33458
+ verifyingContract: escrowContract
33459
+ };
33460
+ }
33461
+ var ESCROW_DEPOSIT_ABI = [
33462
+ {
33463
+ type: "function",
33464
+ name: "depositNative",
33465
+ stateMutability: "payable",
33466
+ inputs: [{ name: "account", type: "address" }],
33467
+ outputs: []
33468
+ },
33469
+ {
33470
+ type: "function",
33471
+ name: "depositToken",
33472
+ stateMutability: "nonpayable",
33473
+ inputs: [
33474
+ { name: "account", type: "address" },
33475
+ { name: "token", type: "address" },
33476
+ { name: "amount", type: "uint256" }
33477
+ ],
33478
+ outputs: []
33479
+ }
33480
+ ];
33481
+ var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
33482
+ function createEscrowGatewayClient(baseUrl) {
33483
+ const base = baseUrl.replace(/\/+$/, "");
33484
+ async function throwOnError(res, context) {
33485
+ if (!res.ok) {
33486
+ let detail = "";
33487
+ try {
33488
+ const body = await res.json();
33489
+ if (body.error) detail = `: ${body.error}`;
33490
+ } catch {
33491
+ }
33492
+ throw new Error(
33493
+ `Escrow gateway error (${context}): ${res.status} ${res.statusText}${detail}`
33494
+ );
33495
+ }
33496
+ }
33497
+ return {
33498
+ async submitDeposit({ txHash }) {
33499
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
33500
+ method: "POST",
33501
+ headers: { "Content-Type": "application/json" },
33502
+ body: JSON.stringify({ txHash })
33503
+ });
33504
+ if (res.status !== 200 && res.status !== 202) {
33505
+ await throwOnError(res, "POST /v1/escrow/deposit");
33506
+ }
33507
+ return res.json();
33508
+ },
33509
+ async getEscrowBalance(account) {
33510
+ const res = await fetch(
33511
+ `${base}/v1/escrow/balance?account=${encodeURIComponent(account)}`
33512
+ );
33513
+ await throwOnError(res, "GET /v1/escrow/balance");
33514
+ return res.json();
33515
+ },
33516
+ async syncEscrowBalance(account) {
33517
+ const res = await fetch(
33518
+ `${base}/v1/escrow/balance/sync?account=${encodeURIComponent(account)}`,
33519
+ { method: "POST" }
33520
+ );
33521
+ await throwOnError(res, "POST /v1/escrow/balance/sync");
33522
+ return res.json();
33523
+ },
33524
+ async payForOp({
33525
+ payerAddress,
33526
+ opType,
33527
+ opId,
33528
+ asset,
33529
+ amount,
33530
+ paymentNonce,
33531
+ signature
33532
+ }) {
33533
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33534
+ method: "POST",
33535
+ headers: {
33536
+ "Content-Type": "application/json",
33537
+ Authorization: `Web3Signed ${signature}`
33538
+ },
33539
+ body: JSON.stringify({
33540
+ payerAddress,
33541
+ opType,
33542
+ opId,
33543
+ asset,
33544
+ amount,
33545
+ paymentNonce
33546
+ })
33547
+ });
33548
+ await throwOnError(res, "POST /v1/escrow/pay");
33549
+ return res.json();
33550
+ }
33551
+ };
33552
+ }
33553
+
33432
33554
  // src/types/ps-errors.ts
33433
33555
  var PSError = class extends Error {
33434
33556
  constructor(code, message) {
@@ -33505,9 +33627,11 @@ export {
33505
33627
  DataFileEnvelopeSchema,
33506
33628
  DropboxStorage,
33507
33629
  ECIESError,
33630
+ ESCROW_DEPOSIT_ABI,
33508
33631
  ExpiredTokenError,
33509
33632
  FILE_DELETION_TYPES,
33510
33633
  FILE_REGISTRATION_TYPES,
33634
+ GENERIC_PAYMENT_TYPES,
33511
33635
  GRANT_REGISTRATION_TYPES,
33512
33636
  GRANT_REVOCATION_TYPES,
33513
33637
  GoogleDriveStorage,
@@ -33518,6 +33642,7 @@ export {
33518
33642
  IpfsStorage,
33519
33643
  MASTER_KEY_MESSAGE,
33520
33644
  MissingAuthError,
33645
+ NATIVE_ASSET_ADDRESS,
33521
33646
  NetworkError,
33522
33647
  NodeECIESUint8Provider as NodeECIESProvider,
33523
33648
  NodePlatformAdapter,
@@ -33562,6 +33687,7 @@ export {
33562
33687
  contractCacheForTesting,
33563
33688
  createBrowserPlatformAdapter,
33564
33689
  createDataFileEnvelope,
33690
+ createEscrowGatewayClient,
33565
33691
  createGatewayClient,
33566
33692
  createNodePlatformAdapter,
33567
33693
  createPlatformAdapter,
@@ -33579,6 +33705,7 @@ export {
33579
33705
  fileDeletionDomain,
33580
33706
  fileRegistrationDomain,
33581
33707
  generatePkceVerifier,
33708
+ genericPaymentDomain,
33582
33709
  getAbi,
33583
33710
  getAllChains,
33584
33711
  getChainConfig,