@opendatalabs/vana-sdk 3.1.0 → 3.2.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 (79) hide show
  1. package/README.md +2 -1
  2. package/dist/account/personal-server-lite-owner-binding.cjs +81 -0
  3. package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -0
  4. package/dist/account/personal-server-lite-owner-binding.d.ts +30 -0
  5. package/dist/account/personal-server-lite-owner-binding.js +59 -0
  6. package/dist/account/personal-server-lite-owner-binding.js.map +1 -0
  7. package/dist/account/personal-server-lite-owner-binding.test.d.ts +1 -0
  8. package/dist/account/personal-server-registration.cjs +263 -0
  9. package/dist/account/personal-server-registration.cjs.map +1 -0
  10. package/dist/account/personal-server-registration.d.ts +66 -0
  11. package/dist/account/personal-server-registration.js +240 -0
  12. package/dist/account/personal-server-registration.js.map +1 -0
  13. package/dist/account/personal-server-registration.test.d.ts +1 -0
  14. package/dist/auth/errors.js +1 -1
  15. package/dist/auth/oauth-client.js +2 -2
  16. package/dist/auth/web3-signed-builder.js +1 -1
  17. package/dist/auth/web3-signed.js +3 -3
  18. package/dist/browser.js +1 -1
  19. package/dist/chains/definitions.js +1 -1
  20. package/dist/chains/index.js +1 -1
  21. package/dist/chains.browser.js +1 -1
  22. package/dist/chains.js +1 -1
  23. package/dist/chains.node.js +1 -1
  24. package/dist/contracts/contractController.js +4 -4
  25. package/dist/core/client.js +1 -1
  26. package/dist/crypto/ecies/base.js +3 -3
  27. package/dist/crypto/ecies/browser.js +1 -1
  28. package/dist/crypto/ecies/index.js +1 -1
  29. package/dist/crypto/ecies/interface.js +1 -1
  30. package/dist/crypto/ecies/node.js +1 -1
  31. package/dist/crypto/services/WalletKeyEncryptionService.js +1 -1
  32. package/dist/generated/abi/index.js +26 -26
  33. package/dist/index.browser.d.ts +4 -0
  34. package/dist/index.browser.js +447 -3
  35. package/dist/index.browser.js.map +4 -4
  36. package/dist/index.node.cjs +464 -5
  37. package/dist/index.node.cjs.map +4 -4
  38. package/dist/index.node.d.ts +4 -0
  39. package/dist/index.node.js +447 -3
  40. package/dist/index.node.js.map +4 -4
  41. package/dist/node.js +1 -1
  42. package/dist/platform/browser-only.js +1 -1
  43. package/dist/platform/browser-safe.js +1 -1
  44. package/dist/platform/browser.js +6 -6
  45. package/dist/platform/index.js +4 -4
  46. package/dist/platform/node.js +8 -8
  47. package/dist/platform/utils.js +2 -2
  48. package/dist/platform.browser.js +3 -3
  49. package/dist/platform.js +4 -4
  50. package/dist/platform.node.js +4 -4
  51. package/dist/protocol/eip712.cjs.map +1 -1
  52. package/dist/protocol/eip712.d.ts +1 -1
  53. package/dist/protocol/eip712.js.map +1 -1
  54. package/dist/protocol/grants.js +1 -1
  55. package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
  56. package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
  57. package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
  58. package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
  59. package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
  60. package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
  61. package/dist/protocol/personal-server-registration.cjs +122 -0
  62. package/dist/protocol/personal-server-registration.cjs.map +1 -0
  63. package/dist/protocol/personal-server-registration.d.ts +62 -0
  64. package/dist/protocol/personal-server-registration.js +97 -0
  65. package/dist/protocol/personal-server-registration.js.map +1 -0
  66. package/dist/protocol/personal-server-registration.test.d.ts +1 -0
  67. package/dist/storage/default.js +1 -1
  68. package/dist/storage/index.js +10 -10
  69. package/dist/storage/manager.js +1 -1
  70. package/dist/storage/providers/callback-storage.js +1 -1
  71. package/dist/storage/providers/dropbox.js +1 -1
  72. package/dist/storage/providers/google-drive.js +1 -1
  73. package/dist/storage/providers/ipfs.js +2 -2
  74. package/dist/storage/providers/pinata.js +1 -1
  75. package/dist/storage/providers/r2.js +1 -1
  76. package/dist/storage/providers/vana-storage.js +2 -2
  77. package/dist/types/index.js +2 -2
  78. package/dist/types.js +1 -1
  79. package/package.json +4 -2
@@ -36,6 +36,10 @@ export { generatePkceVerifier, computePkceChallenge, verifyPkceChallenge, assert
36
36
  export { InMemoryTokenStore, type TokenStore, type TokenRecord, } from "./auth/token-store";
37
37
  export { OAuthClient, type OAuthClientConfig, type AuthorizationUrlResult, } from "./auth/oauth-client";
38
38
  export { fileRegistrationDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain, FILE_REGISTRATION_TYPES, GRANT_REGISTRATION_TYPES, GRANT_REVOCATION_TYPES, SERVER_REGISTRATION_TYPES, BUILDER_REGISTRATION_TYPES, type DataPortabilityContracts, type DataPortabilityGatewayConfig, type FileRegistrationMessage, type GrantRegistrationMessage, type GrantRevocationMessage, type ServerRegistrationMessage, type BuilderRegistrationMessage, } from "./protocol/eip712";
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";
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
+ export { AccountPersonalServerLiteOwnerBindingError, signPersonalServerLiteOwnerBindingWithAccountClient, type AccountPersonalServerLiteOwnerBindingClient, type SignPersonalServerLiteOwnerBindingWithAccountClientConfig, } from "./account/personal-server-lite-owner-binding";
39
43
  export { isDataPortabilityGatewayConfig, parseGrantRegistrationPayload, verifyGrantRegistration, type DataPortabilityGrantPayload, type VerifyGrantRegistrationInput, type VerifyGrantRegistrationResult, } from "./protocol/grants";
40
44
  export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes";
41
45
  export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file";
@@ -32585,6 +32585,431 @@ var BUILDER_REGISTRATION_TYPES = {
32585
32585
  ]
32586
32586
  };
32587
32587
 
32588
+ // src/protocol/personal-server-registration.ts
32589
+ import {
32590
+ isAddress
32591
+ } from "viem";
32592
+ var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
32593
+ var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
32594
+ function assertAddress(value, name) {
32595
+ if (!isAddress(value)) {
32596
+ throw new Error(`${name} must be a valid EVM address`);
32597
+ }
32598
+ }
32599
+ function getAccountAddress(account) {
32600
+ if (!account) {
32601
+ return void 0;
32602
+ }
32603
+ return typeof account === "string" ? account : account.address;
32604
+ }
32605
+ function isPersonalServerRegistrationSigner(source) {
32606
+ return "address" in source && typeof source.signTypedData === "function";
32607
+ }
32608
+ function createViemPersonalServerRegistrationSigner(source, options = {}) {
32609
+ if (isPersonalServerRegistrationSigner(source)) {
32610
+ return source;
32611
+ }
32612
+ const accountAddress = getAccountAddress(options.account) ?? getAccountAddress(source.account);
32613
+ if (accountAddress) {
32614
+ return {
32615
+ address: accountAddress,
32616
+ signTypedData: (typedData) => source.signTypedData({
32617
+ ...typedData,
32618
+ account: options.account ?? source.account ?? accountAddress
32619
+ })
32620
+ };
32621
+ }
32622
+ throw new Error(
32623
+ "Viem wallet client requires an account option or account property"
32624
+ );
32625
+ }
32626
+ function personalServerRegistrationDomain(input = {}) {
32627
+ if (input.config) {
32628
+ return serverRegistrationDomain(input.config);
32629
+ }
32630
+ const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
32631
+ assertAddress(verifyingContract, "verifyingContract");
32632
+ return {
32633
+ name: "Vana Data Portability",
32634
+ version: "1",
32635
+ chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
32636
+ verifyingContract
32637
+ };
32638
+ }
32639
+ function buildPersonalServerRegistrationTypedData(input) {
32640
+ assertAddress(input.ownerAddress, "ownerAddress");
32641
+ assertAddress(input.serverAddress, "serverAddress");
32642
+ return {
32643
+ domain: personalServerRegistrationDomain(input),
32644
+ types: SERVER_REGISTRATION_TYPES,
32645
+ primaryType: "ServerRegistration",
32646
+ message: {
32647
+ ownerAddress: input.ownerAddress,
32648
+ serverAddress: input.serverAddress,
32649
+ publicKey: input.serverPublicKey,
32650
+ serverUrl: input.serverUrl
32651
+ }
32652
+ };
32653
+ }
32654
+ async function buildPersonalServerRegistrationSignature(input) {
32655
+ const typedData = buildPersonalServerRegistrationTypedData({
32656
+ ownerAddress: input.signer.address,
32657
+ serverAddress: input.serverAddress,
32658
+ serverPublicKey: input.serverPublicKey,
32659
+ serverUrl: input.serverUrl,
32660
+ config: input.config,
32661
+ chainId: input.chainId,
32662
+ verifyingContract: input.verifyingContract
32663
+ });
32664
+ const signature = await input.signer.signTypedData(typedData);
32665
+ return {
32666
+ signature,
32667
+ signerAddress: input.signer.address,
32668
+ typedData
32669
+ };
32670
+ }
32671
+ var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
32672
+
32673
+ // src/protocol/personal-server-lite-owner-binding.ts
32674
+ import {
32675
+ isAddress as isAddress2
32676
+ } from "viem";
32677
+ var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
32678
+ var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
32679
+ var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
32680
+ function assertAddress2(value, name) {
32681
+ if (!isAddress2(value)) {
32682
+ throw new Error(`${name} must be a valid EVM address`);
32683
+ }
32684
+ }
32685
+ function getAccountAddress2(account) {
32686
+ if (!account) {
32687
+ return void 0;
32688
+ }
32689
+ return typeof account === "string" ? account : account.address;
32690
+ }
32691
+ function isPersonalServerLiteOwnerBindingSigner(source) {
32692
+ return "address" in source && typeof source.signMessage === "function";
32693
+ }
32694
+ function buildPersonalServerLiteOwnerBindingMessage(ownerAddress) {
32695
+ assertAddress2(ownerAddress, "ownerAddress");
32696
+ return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}`;
32697
+ }
32698
+ function createViemPersonalServerLiteOwnerBindingSigner(source, options = {}) {
32699
+ if (isPersonalServerLiteOwnerBindingSigner(source)) {
32700
+ return source;
32701
+ }
32702
+ const accountAddress = getAccountAddress2(options.account) ?? getAccountAddress2(source.account);
32703
+ if (accountAddress) {
32704
+ return {
32705
+ address: accountAddress,
32706
+ signMessage: ({ message }) => source.signMessage({
32707
+ account: options.account ?? source.account ?? accountAddress,
32708
+ message
32709
+ })
32710
+ };
32711
+ }
32712
+ throw new Error(
32713
+ "Viem wallet client requires an account option or account property"
32714
+ );
32715
+ }
32716
+ async function buildPersonalServerLiteOwnerBindingSignature(input) {
32717
+ const message = buildPersonalServerLiteOwnerBindingMessage(
32718
+ input.signer.address
32719
+ );
32720
+ const signature = await input.signer.signMessage({ message });
32721
+ return {
32722
+ signature,
32723
+ signerAddress: input.signer.address,
32724
+ message,
32725
+ purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
32726
+ };
32727
+ }
32728
+ var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
32729
+
32730
+ // src/account/personal-server-registration.ts
32731
+ import { isAddress as isAddress3 } from "viem";
32732
+ var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
32733
+ var AccountPersonalServerRegistrationError = class extends Error {
32734
+ status;
32735
+ code;
32736
+ details;
32737
+ constructor(input) {
32738
+ super(input.message);
32739
+ this.name = "AccountPersonalServerRegistrationError";
32740
+ this.status = input.status;
32741
+ this.code = input.code;
32742
+ this.details = input.details;
32743
+ }
32744
+ };
32745
+ var DEFAULT_ACCOUNT_PS_REGISTRATION_PATH = "/api/v1/intents/personal-server-registration/sign";
32746
+ function trimTrailingSlash(value) {
32747
+ return value.replace(/\/+$/, "");
32748
+ }
32749
+ function assertAddress3(value, name) {
32750
+ if (!isAddress3(value)) {
32751
+ throw new Error(`${name} must be a valid EVM address`);
32752
+ }
32753
+ }
32754
+ async function parseAccountResponse(response) {
32755
+ const body = await response.json().catch(() => void 0);
32756
+ if (!response.ok) {
32757
+ throw new AccountPersonalServerRegistrationError({
32758
+ status: response.status,
32759
+ code: accountErrorCode(body),
32760
+ message: accountErrorMessage(response.status, body),
32761
+ details: body
32762
+ });
32763
+ }
32764
+ return body;
32765
+ }
32766
+ function accountErrorMessage(status, body) {
32767
+ const nestedMessage = nestedAccountErrorField(body, "message");
32768
+ if (nestedMessage) {
32769
+ return nestedMessage;
32770
+ }
32771
+ if (isRecord(body) && typeof body.message === "string") {
32772
+ return body.message;
32773
+ }
32774
+ const code = accountErrorCode(body);
32775
+ if (code) {
32776
+ return `Account PS registration signing failed: ${code}`;
32777
+ }
32778
+ return `Account PS registration signing failed: ${status}`;
32779
+ }
32780
+ function accountErrorCode(body) {
32781
+ const nestedCode = nestedAccountErrorField(body, "code");
32782
+ if (nestedCode) {
32783
+ return nestedCode;
32784
+ }
32785
+ if (isRecord(body)) {
32786
+ if (typeof body.code === "string") {
32787
+ return body.code;
32788
+ }
32789
+ if (typeof body.error === "string") {
32790
+ return body.error;
32791
+ }
32792
+ }
32793
+ return void 0;
32794
+ }
32795
+ function nestedAccountErrorField(body, field) {
32796
+ if (!isRecord(body) || !isRecord(body.error)) {
32797
+ return void 0;
32798
+ }
32799
+ const value = body.error[field];
32800
+ return typeof value === "string" ? value : void 0;
32801
+ }
32802
+ function isRecord(value) {
32803
+ return typeof value === "object" && value !== null;
32804
+ }
32805
+ function normalizeAccountResponse(response) {
32806
+ return {
32807
+ ...response,
32808
+ status: response.status === "fallback_required" ? "confirmation_required" : response.status,
32809
+ signerAddress: response.signerAddress ?? response.signer?.address,
32810
+ typedData: response.typedData ?? response.typed_data
32811
+ };
32812
+ }
32813
+ function buildSignedResult(response, request) {
32814
+ assertAddress3(response.signerAddress, "signerAddress");
32815
+ if (response.typedData) {
32816
+ assertTypedDataMatchesRequest(
32817
+ response.typedData,
32818
+ request,
32819
+ response.signerAddress
32820
+ );
32821
+ }
32822
+ return {
32823
+ signature: response.signature,
32824
+ signerAddress: response.signerAddress,
32825
+ typedData: response.typedData ?? buildPersonalServerRegistrationTypedData({
32826
+ ownerAddress: response.signerAddress,
32827
+ ...request
32828
+ }),
32829
+ intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT
32830
+ };
32831
+ }
32832
+ function assertTypedDataMatchesRequest(typedData, request, expectedSignerAddress) {
32833
+ assertAddress3(
32834
+ typedData.message.ownerAddress,
32835
+ "typedData.message.ownerAddress"
32836
+ );
32837
+ assertAddress3(
32838
+ typedData.message.serverAddress,
32839
+ "typedData.message.serverAddress"
32840
+ );
32841
+ if (expectedSignerAddress && !sameAddress(typedData.message.ownerAddress, expectedSignerAddress)) {
32842
+ throw new Error(
32843
+ "Account typedData ownerAddress must match the expected signer address"
32844
+ );
32845
+ }
32846
+ if (!sameAddress(typedData.message.serverAddress, request.serverAddress)) {
32847
+ throw new Error(
32848
+ "Account typedData serverAddress must match the requested serverAddress"
32849
+ );
32850
+ }
32851
+ if (typedData.message.publicKey !== request.serverPublicKey) {
32852
+ throw new Error(
32853
+ "Account typedData publicKey must match the requested serverPublicKey"
32854
+ );
32855
+ }
32856
+ if (typedData.message.serverUrl !== request.serverUrl) {
32857
+ throw new Error(
32858
+ "Account typedData serverUrl must match the requested serverUrl"
32859
+ );
32860
+ }
32861
+ if (typedData.primaryType !== "ServerRegistration") {
32862
+ throw new Error("Account typedData primaryType must be ServerRegistration");
32863
+ }
32864
+ if (JSON.stringify(typedData.types) !== JSON.stringify(SERVER_REGISTRATION_TYPES)) {
32865
+ throw new Error("Account typedData types must be ServerRegistration types");
32866
+ }
32867
+ const expectedDomain = personalServerRegistrationDomain({
32868
+ config: request.config,
32869
+ chainId: request.chainId,
32870
+ verifyingContract: request.verifyingContract
32871
+ });
32872
+ if (!domainsEqual(typedData.domain, expectedDomain)) {
32873
+ throw new Error("Account typedData domain must match the requested domain");
32874
+ }
32875
+ }
32876
+ function sameAddress(a, b) {
32877
+ return a.toLowerCase() === b.toLowerCase();
32878
+ }
32879
+ function domainsEqual(a, b) {
32880
+ if (!a || !b) {
32881
+ return false;
32882
+ }
32883
+ return a.name === b.name && a.version === b.version && Number(a.chainId) === Number(b.chainId) && String(a.verifyingContract ?? "").toLowerCase() === String(b.verifyingContract ?? "").toLowerCase() && a.salt === b.salt;
32884
+ }
32885
+ async function signPersonalServerRegistrationWithAccount(config, request) {
32886
+ assertAddress3(request.serverAddress, "serverAddress");
32887
+ const fetchImpl = config.fetchImpl ?? globalThis.fetch.bind(globalThis);
32888
+ const endpoint = new URL(
32889
+ config.endpointPath ?? DEFAULT_ACCOUNT_PS_REGISTRATION_PATH,
32890
+ `${trimTrailingSlash(config.accountOrigin)}/`
32891
+ );
32892
+ const response = await fetchImpl(endpoint, {
32893
+ method: "POST",
32894
+ headers: { "content-type": "application/json" },
32895
+ credentials: "include",
32896
+ body: JSON.stringify({
32897
+ intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
32898
+ serverAddress: request.serverAddress,
32899
+ serverPublicKey: request.serverPublicKey,
32900
+ serverUrl: request.serverUrl,
32901
+ config: request.config,
32902
+ chainId: request.chainId,
32903
+ verifyingContract: request.verifyingContract
32904
+ })
32905
+ });
32906
+ const body = normalizeAccountResponse(await parseAccountResponse(response));
32907
+ if (body.status === "signed") {
32908
+ if (!body.signature || !body.signerAddress) {
32909
+ throw new Error(
32910
+ "Account signed response must include signature and signerAddress"
32911
+ );
32912
+ }
32913
+ return {
32914
+ status: "signed",
32915
+ result: buildSignedResult(
32916
+ {
32917
+ signature: body.signature,
32918
+ signerAddress: body.signerAddress,
32919
+ typedData: body.typedData
32920
+ },
32921
+ request
32922
+ )
32923
+ };
32924
+ }
32925
+ if (body.status === "confirmation_required") {
32926
+ if (!body.typedData) {
32927
+ throw new Error(
32928
+ "Account confirmation_required response must include typedData"
32929
+ );
32930
+ }
32931
+ assertTypedDataMatchesRequest(body.typedData, request, body.signerAddress);
32932
+ if (!config.fallbackSigner) {
32933
+ return {
32934
+ status: "confirmation_required",
32935
+ typedData: body.typedData,
32936
+ signerAddress: body.signerAddress
32937
+ };
32938
+ }
32939
+ assertTypedDataMatchesRequest(
32940
+ body.typedData,
32941
+ request,
32942
+ config.fallbackSigner.address
32943
+ );
32944
+ const signature = await config.fallbackSigner.signTypedData(body.typedData);
32945
+ return {
32946
+ status: "fallback_signed",
32947
+ accountStatus: "confirmation_required",
32948
+ result: {
32949
+ signature,
32950
+ signerAddress: config.fallbackSigner.address,
32951
+ typedData: body.typedData,
32952
+ intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT
32953
+ }
32954
+ };
32955
+ }
32956
+ throw new Error(
32957
+ `Unsupported Account PS registration signing status: ${String(body.status)}`
32958
+ );
32959
+ }
32960
+
32961
+ // src/account/personal-server-lite-owner-binding.ts
32962
+ var AccountPersonalServerLiteOwnerBindingError = class extends Error {
32963
+ code;
32964
+ details;
32965
+ constructor(input) {
32966
+ super(input.message);
32967
+ this.name = "AccountPersonalServerLiteOwnerBindingError";
32968
+ this.code = input.code;
32969
+ this.details = input.details;
32970
+ }
32971
+ };
32972
+ async function signPersonalServerLiteOwnerBindingWithAccountClient(config) {
32973
+ let address;
32974
+ try {
32975
+ address = await config.client.getAddress();
32976
+ } catch (error) {
32977
+ throw accountOwnerBindingError(error);
32978
+ }
32979
+ if (!address) {
32980
+ throw new AccountPersonalServerLiteOwnerBindingError({
32981
+ message: "Account did not return a wallet address",
32982
+ code: "account_address_required"
32983
+ });
32984
+ }
32985
+ const message = buildPersonalServerLiteOwnerBindingMessage(address);
32986
+ let signature;
32987
+ try {
32988
+ signature = await config.client.signMessage({ message });
32989
+ } catch (error) {
32990
+ throw accountOwnerBindingError(error);
32991
+ }
32992
+ return {
32993
+ signature,
32994
+ signerAddress: address,
32995
+ message,
32996
+ purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
32997
+ };
32998
+ }
32999
+ function accountOwnerBindingError(error) {
33000
+ if (error instanceof AccountPersonalServerLiteOwnerBindingError) {
33001
+ return error;
33002
+ }
33003
+ const rpcError = error;
33004
+ const code = rpcError?.code;
33005
+ const message = typeof rpcError?.message === "string" && rpcError.message.length > 0 ? rpcError.message : "Account PS Lite owner-binding signature failed";
33006
+ return new AccountPersonalServerLiteOwnerBindingError({
33007
+ message,
33008
+ code,
33009
+ details: error
33010
+ });
33011
+ }
33012
+
32588
33013
  // src/protocol/grants.ts
32589
33014
  import { verifyTypedData } from "viem";
32590
33015
  function isHexString(value) {
@@ -32995,7 +33420,7 @@ var KNOWN_CODES = /* @__PURE__ */ new Set([
32995
33420
  "server_not_configured",
32996
33421
  "content_too_large"
32997
33422
  ]);
32998
- function isRecord(value) {
33423
+ function isRecord2(value) {
32999
33424
  return value !== null && typeof value === "object" && !Array.isArray(value);
33000
33425
  }
33001
33426
  function normalizeCode(value) {
@@ -33006,10 +33431,10 @@ function normalizeCode(value) {
33006
33431
  return KNOWN_CODES.has(code) ? code : null;
33007
33432
  }
33008
33433
  function extractPSErrorBody(body) {
33009
- if (!isRecord(body)) {
33434
+ if (!isRecord2(body)) {
33010
33435
  return null;
33011
33436
  }
33012
- const nested = isRecord(body.error) ? body.error : null;
33437
+ const nested = isRecord2(body.error) ? body.error : null;
33013
33438
  const code = normalizeCode(
33014
33439
  nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
33015
33440
  );
@@ -33033,6 +33458,9 @@ async function parsePSError(response) {
33033
33458
  return errorBody ? new PSError(errorBody.code, errorBody.message) : null;
33034
33459
  }
33035
33460
  export {
33461
+ ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33462
+ AccountPersonalServerLiteOwnerBindingError,
33463
+ AccountPersonalServerRegistrationError,
33036
33464
  BUILDER_REGISTRATION_TYPES,
33037
33465
  BlockchainError,
33038
33466
  BrowserPlatformAdapter,
@@ -33060,6 +33488,11 @@ export {
33060
33488
  NodePlatformAdapter,
33061
33489
  NonceError,
33062
33490
  OAuthClient,
33491
+ PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
33492
+ PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
33493
+ PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
33494
+ PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
33495
+ PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT,
33063
33496
  PKCE_CHALLENGE_PATTERN,
33064
33497
  PKCE_VERIFIER_PATTERN,
33065
33498
  PSError,
@@ -33081,6 +33514,10 @@ export {
33081
33514
  VanaError,
33082
33515
  VanaStorage,
33083
33516
  assertValidPkceVerifier,
33517
+ buildPersonalServerLiteOwnerBindingMessage,
33518
+ buildPersonalServerLiteOwnerBindingSignature,
33519
+ buildPersonalServerRegistrationSignature,
33520
+ buildPersonalServerRegistrationTypedData,
33084
33521
  buildWeb3SignedHeader,
33085
33522
  builderRegistrationDomain,
33086
33523
  chains,
@@ -33096,6 +33533,8 @@ export {
33096
33533
  createPlatformAdapterFor,
33097
33534
  createPlatformAdapterSafe,
33098
33535
  createVanaStorageProvider,
33536
+ createViemPersonalServerLiteOwnerBindingSigner,
33537
+ createViemPersonalServerRegistrationSigner,
33099
33538
  decryptWithPassword,
33100
33539
  deriveMasterKey,
33101
33540
  deriveScopeKey,
@@ -33125,12 +33564,17 @@ export {
33125
33564
  parsePSError,
33126
33565
  parseScope,
33127
33566
  parseWeb3SignedHeader,
33567
+ personalServerRegistrationDomain,
33128
33568
  recoverServerOwner,
33569
+ registerPersonalServerSignature,
33129
33570
  scopeCoveredByGrant,
33130
33571
  scopeMatchesPattern,
33131
33572
  scopeToPathSegments,
33132
33573
  serializeECIES,
33133
33574
  serverRegistrationDomain,
33575
+ signPersonalServerLiteOwnerBinding,
33576
+ signPersonalServerLiteOwnerBindingWithAccountClient,
33577
+ signPersonalServerRegistrationWithAccount,
33134
33578
  vanaMainnet2 as vanaMainnet,
33135
33579
  verifyGrantRegistration,
33136
33580
  verifyPkceChallenge,