@opendatalabs/vana-sdk 3.1.0 → 3.2.0-canary.88d802d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/account/personal-server-lite-owner-binding.cjs +81 -0
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/account/personal-server-lite-owner-binding.d.ts +30 -0
- package/dist/account/personal-server-lite-owner-binding.js +59 -0
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/account/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/account/personal-server-registration.cjs +263 -0
- package/dist/account/personal-server-registration.cjs.map +1 -0
- package/dist/account/personal-server-registration.d.ts +66 -0
- package/dist/account/personal-server-registration.js +240 -0
- package/dist/account/personal-server-registration.js.map +1 -0
- package/dist/account/personal-server-registration.test.d.ts +1 -0
- package/dist/auth/errors.js +1 -1
- package/dist/auth/oauth-client.js +2 -2
- package/dist/auth/web3-signed-builder.js +1 -1
- package/dist/auth/web3-signed.js +3 -3
- package/dist/browser.js +1 -1
- package/dist/chains/definitions.js +1 -1
- package/dist/chains/index.js +1 -1
- package/dist/chains.browser.js +1 -1
- package/dist/chains.js +1 -1
- package/dist/chains.node.js +1 -1
- package/dist/contracts/contractController.js +4 -4
- package/dist/core/client.js +1 -1
- package/dist/crypto/ecies/base.js +3 -3
- package/dist/crypto/ecies/browser.js +1 -1
- package/dist/crypto/ecies/index.js +1 -1
- package/dist/crypto/ecies/interface.js +1 -1
- package/dist/crypto/ecies/node.js +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.js +1 -1
- package/dist/generated/abi/index.js +26 -26
- package/dist/index.browser.d.ts +8 -3
- package/dist/index.browser.js +706 -72
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +733 -73
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +8 -3
- package/dist/index.node.js +706 -72
- package/dist/index.node.js.map +4 -4
- package/dist/node.js +1 -1
- package/dist/platform/browser-only.js +1 -1
- package/dist/platform/browser-safe.js +1 -1
- package/dist/platform/browser.js +6 -6
- package/dist/platform/index.js +4 -4
- package/dist/platform/node.js +8 -8
- package/dist/platform/utils.js +2 -2
- package/dist/platform.browser.js +3 -3
- package/dist/platform.js +4 -4
- package/dist/platform.node.js +4 -4
- package/dist/protocol/eip712.cjs +58 -3
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +98 -7
- package/dist/protocol/eip712.js +52 -3
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow-deposit.cjs +89 -0
- package/dist/protocol/escrow-deposit.cjs.map +1 -0
- package/dist/protocol/escrow-deposit.d.ts +47 -0
- package/dist/protocol/escrow-deposit.js +60 -0
- package/dist/protocol/escrow-deposit.js.map +1 -0
- package/dist/protocol/escrow-deposit.test.d.ts +1 -0
- package/dist/protocol/escrow-flow.test.d.ts +21 -0
- package/dist/protocol/gateway.cjs +124 -3
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +196 -16
- package/dist/protocol/gateway.js +124 -3
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +24 -64
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +6 -13
- package/dist/protocol/grants.js +25 -64
- package/dist/protocol/grants.js.map +1 -1
- package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
- package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
- package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/protocol/personal-server-registration.cjs +122 -0
- package/dist/protocol/personal-server-registration.cjs.map +1 -0
- package/dist/protocol/personal-server-registration.d.ts +62 -0
- package/dist/protocol/personal-server-registration.js +97 -0
- package/dist/protocol/personal-server-registration.js.map +1 -0
- package/dist/protocol/personal-server-registration.test.d.ts +1 -0
- package/dist/storage/default.js +1 -1
- package/dist/storage/index.js +10 -10
- package/dist/storage/manager.js +1 -1
- package/dist/storage/providers/callback-storage.js +1 -1
- package/dist/storage/providers/dropbox.js +1 -1
- package/dist/storage/providers/google-drive.js +1 -1
- package/dist/storage/providers/ipfs.js +2 -2
- package/dist/storage/providers/pinata.js +1 -1
- package/dist/storage/providers/r2.js +1 -1
- package/dist/storage/providers/vana-storage.js +2 -2
- package/dist/types/index.js +2 -2
- package/dist/types.js +1 -1
- package/package.json +6 -3
package/dist/index.node.js
CHANGED
|
@@ -32509,6 +32509,7 @@ function formatOAuthError(body, status) {
|
|
|
32509
32509
|
// src/protocol/eip712.ts
|
|
32510
32510
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
32511
32511
|
var DOMAIN_VERSION = "1";
|
|
32512
|
+
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
32512
32513
|
function buildDomain(chainId, verifyingContract) {
|
|
32513
32514
|
return {
|
|
32514
32515
|
name: DOMAIN_NAME,
|
|
@@ -32523,6 +32524,12 @@ function fileRegistrationDomain(config) {
|
|
|
32523
32524
|
config.contracts.dataRegistry
|
|
32524
32525
|
);
|
|
32525
32526
|
}
|
|
32527
|
+
function dataRegistryDomain(config) {
|
|
32528
|
+
return buildDomain(
|
|
32529
|
+
config.chainId,
|
|
32530
|
+
config.contracts.dataRegistry
|
|
32531
|
+
);
|
|
32532
|
+
}
|
|
32526
32533
|
function grantRegistrationDomain(config) {
|
|
32527
32534
|
return buildDomain(
|
|
32528
32535
|
config.chainId,
|
|
@@ -32547,6 +32554,12 @@ function builderRegistrationDomain(config) {
|
|
|
32547
32554
|
config.contracts.dataPortabilityGrantees
|
|
32548
32555
|
);
|
|
32549
32556
|
}
|
|
32557
|
+
function escrowPaymentDomain(config) {
|
|
32558
|
+
return buildDomain(
|
|
32559
|
+
config.chainId,
|
|
32560
|
+
config.contracts.dataPortabilityEscrow
|
|
32561
|
+
);
|
|
32562
|
+
}
|
|
32550
32563
|
var FILE_REGISTRATION_TYPES = {
|
|
32551
32564
|
FileRegistration: [
|
|
32552
32565
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -32558,14 +32571,16 @@ var GRANT_REGISTRATION_TYPES = {
|
|
|
32558
32571
|
GrantRegistration: [
|
|
32559
32572
|
{ name: "grantorAddress", type: "address" },
|
|
32560
32573
|
{ name: "granteeId", type: "bytes32" },
|
|
32561
|
-
{ name: "
|
|
32562
|
-
{ name: "
|
|
32574
|
+
{ name: "scopes", type: "string[]" },
|
|
32575
|
+
{ name: "grantVersion", type: "uint256" },
|
|
32576
|
+
{ name: "expiresAt", type: "uint256" }
|
|
32563
32577
|
]
|
|
32564
32578
|
};
|
|
32565
32579
|
var GRANT_REVOCATION_TYPES = {
|
|
32566
32580
|
GrantRevocation: [
|
|
32567
32581
|
{ name: "grantorAddress", type: "address" },
|
|
32568
|
-
{ name: "grantId", type: "bytes32" }
|
|
32582
|
+
{ name: "grantId", type: "bytes32" },
|
|
32583
|
+
{ name: "grantVersion", type: "uint256" }
|
|
32569
32584
|
]
|
|
32570
32585
|
};
|
|
32571
32586
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32584,83 +32599,500 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32584
32599
|
{ name: "appUrl", type: "string" }
|
|
32585
32600
|
]
|
|
32586
32601
|
};
|
|
32602
|
+
var GENERIC_PAYMENT_TYPES = {
|
|
32603
|
+
GenericPayment: [
|
|
32604
|
+
{ name: "payerAddress", type: "address" },
|
|
32605
|
+
{ name: "opType", type: "string" },
|
|
32606
|
+
{ name: "opId", type: "bytes32" },
|
|
32607
|
+
{ name: "asset", type: "address" },
|
|
32608
|
+
{ name: "amount", type: "uint256" },
|
|
32609
|
+
{ name: "paymentNonce", type: "uint256" }
|
|
32610
|
+
]
|
|
32611
|
+
};
|
|
32612
|
+
var ADD_DATA_TYPES = {
|
|
32613
|
+
AddData: [
|
|
32614
|
+
{ name: "ownerAddress", type: "address" },
|
|
32615
|
+
{ name: "scope", type: "string" },
|
|
32616
|
+
{ name: "dataHash", type: "bytes32" },
|
|
32617
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
32618
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
32619
|
+
]
|
|
32620
|
+
};
|
|
32621
|
+
var RECORD_DATA_ACCESS_TYPES = {
|
|
32622
|
+
RecordDataAccess: [
|
|
32623
|
+
{ name: "ownerAddress", type: "address" },
|
|
32624
|
+
{ name: "scope", type: "string" },
|
|
32625
|
+
{ name: "version", type: "uint256" },
|
|
32626
|
+
{ name: "accessor", type: "address" },
|
|
32627
|
+
{ name: "recordId", type: "bytes32" }
|
|
32628
|
+
]
|
|
32629
|
+
};
|
|
32587
32630
|
|
|
32588
|
-
// src/protocol/
|
|
32589
|
-
import {
|
|
32590
|
-
|
|
32591
|
-
|
|
32631
|
+
// src/protocol/personal-server-registration.ts
|
|
32632
|
+
import {
|
|
32633
|
+
isAddress
|
|
32634
|
+
} from "viem";
|
|
32635
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
|
|
32636
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
|
|
32637
|
+
function assertAddress(value, name) {
|
|
32638
|
+
if (!isAddress(value)) {
|
|
32639
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
32640
|
+
}
|
|
32592
32641
|
}
|
|
32593
|
-
function
|
|
32594
|
-
if (
|
|
32595
|
-
return
|
|
32642
|
+
function getAccountAddress(account) {
|
|
32643
|
+
if (!account) {
|
|
32644
|
+
return void 0;
|
|
32596
32645
|
}
|
|
32597
|
-
|
|
32598
|
-
|
|
32599
|
-
|
|
32600
|
-
|
|
32646
|
+
return typeof account === "string" ? account : account.address;
|
|
32647
|
+
}
|
|
32648
|
+
function isPersonalServerRegistrationSigner(source) {
|
|
32649
|
+
return "address" in source && typeof source.signTypedData === "function";
|
|
32650
|
+
}
|
|
32651
|
+
function createViemPersonalServerRegistrationSigner(source, options = {}) {
|
|
32652
|
+
if (isPersonalServerRegistrationSigner(source)) {
|
|
32653
|
+
return source;
|
|
32601
32654
|
}
|
|
32602
|
-
const
|
|
32603
|
-
|
|
32655
|
+
const accountAddress = getAccountAddress(options.account) ?? getAccountAddress(source.account);
|
|
32656
|
+
if (accountAddress) {
|
|
32657
|
+
return {
|
|
32658
|
+
address: accountAddress,
|
|
32659
|
+
signTypedData: (typedData) => source.signTypedData({
|
|
32660
|
+
...typedData,
|
|
32661
|
+
account: options.account ?? source.account ?? accountAddress
|
|
32662
|
+
})
|
|
32663
|
+
};
|
|
32664
|
+
}
|
|
32665
|
+
throw new Error(
|
|
32666
|
+
"Viem wallet client requires an account option or account property"
|
|
32667
|
+
);
|
|
32604
32668
|
}
|
|
32605
|
-
function
|
|
32606
|
-
|
|
32607
|
-
|
|
32608
|
-
parsed = JSON.parse(grant);
|
|
32609
|
-
} catch {
|
|
32610
|
-
return null;
|
|
32669
|
+
function personalServerRegistrationDomain(input = {}) {
|
|
32670
|
+
if (input.config) {
|
|
32671
|
+
return serverRegistrationDomain(input.config);
|
|
32611
32672
|
}
|
|
32612
|
-
|
|
32613
|
-
|
|
32673
|
+
const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
|
|
32674
|
+
assertAddress(verifyingContract, "verifyingContract");
|
|
32675
|
+
return {
|
|
32676
|
+
name: "Vana Data Portability",
|
|
32677
|
+
version: "1",
|
|
32678
|
+
chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32679
|
+
verifyingContract
|
|
32680
|
+
};
|
|
32681
|
+
}
|
|
32682
|
+
function buildPersonalServerRegistrationTypedData(input) {
|
|
32683
|
+
assertAddress(input.ownerAddress, "ownerAddress");
|
|
32684
|
+
assertAddress(input.serverAddress, "serverAddress");
|
|
32685
|
+
return {
|
|
32686
|
+
domain: personalServerRegistrationDomain(input),
|
|
32687
|
+
types: SERVER_REGISTRATION_TYPES,
|
|
32688
|
+
primaryType: "ServerRegistration",
|
|
32689
|
+
message: {
|
|
32690
|
+
ownerAddress: input.ownerAddress,
|
|
32691
|
+
serverAddress: input.serverAddress,
|
|
32692
|
+
publicKey: input.serverPublicKey,
|
|
32693
|
+
serverUrl: input.serverUrl
|
|
32694
|
+
}
|
|
32695
|
+
};
|
|
32696
|
+
}
|
|
32697
|
+
async function buildPersonalServerRegistrationSignature(input) {
|
|
32698
|
+
const typedData = buildPersonalServerRegistrationTypedData({
|
|
32699
|
+
ownerAddress: input.signer.address,
|
|
32700
|
+
serverAddress: input.serverAddress,
|
|
32701
|
+
serverPublicKey: input.serverPublicKey,
|
|
32702
|
+
serverUrl: input.serverUrl,
|
|
32703
|
+
config: input.config,
|
|
32704
|
+
chainId: input.chainId,
|
|
32705
|
+
verifyingContract: input.verifyingContract
|
|
32706
|
+
});
|
|
32707
|
+
const signature = await input.signer.signTypedData(typedData);
|
|
32708
|
+
return {
|
|
32709
|
+
signature,
|
|
32710
|
+
signerAddress: input.signer.address,
|
|
32711
|
+
typedData
|
|
32712
|
+
};
|
|
32713
|
+
}
|
|
32714
|
+
var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
32715
|
+
|
|
32716
|
+
// src/protocol/personal-server-lite-owner-binding.ts
|
|
32717
|
+
import {
|
|
32718
|
+
isAddress as isAddress2
|
|
32719
|
+
} from "viem";
|
|
32720
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
|
|
32721
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
32722
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
32723
|
+
function assertAddress2(value, name) {
|
|
32724
|
+
if (!isAddress2(value)) {
|
|
32725
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
32614
32726
|
}
|
|
32615
|
-
|
|
32616
|
-
|
|
32617
|
-
|
|
32727
|
+
}
|
|
32728
|
+
function getAccountAddress2(account) {
|
|
32729
|
+
if (!account) {
|
|
32730
|
+
return void 0;
|
|
32618
32731
|
}
|
|
32619
|
-
|
|
32620
|
-
|
|
32732
|
+
return typeof account === "string" ? account : account.address;
|
|
32733
|
+
}
|
|
32734
|
+
function isPersonalServerLiteOwnerBindingSigner(source) {
|
|
32735
|
+
return "address" in source && typeof source.signMessage === "function";
|
|
32736
|
+
}
|
|
32737
|
+
function buildPersonalServerLiteOwnerBindingMessage(ownerAddress) {
|
|
32738
|
+
assertAddress2(ownerAddress, "ownerAddress");
|
|
32739
|
+
return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}`;
|
|
32740
|
+
}
|
|
32741
|
+
function createViemPersonalServerLiteOwnerBindingSigner(source, options = {}) {
|
|
32742
|
+
if (isPersonalServerLiteOwnerBindingSigner(source)) {
|
|
32743
|
+
return source;
|
|
32621
32744
|
}
|
|
32622
|
-
|
|
32623
|
-
|
|
32745
|
+
const accountAddress = getAccountAddress2(options.account) ?? getAccountAddress2(source.account);
|
|
32746
|
+
if (accountAddress) {
|
|
32747
|
+
return {
|
|
32748
|
+
address: accountAddress,
|
|
32749
|
+
signMessage: ({ message }) => source.signMessage({
|
|
32750
|
+
account: options.account ?? source.account ?? accountAddress,
|
|
32751
|
+
message
|
|
32752
|
+
})
|
|
32753
|
+
};
|
|
32624
32754
|
}
|
|
32625
|
-
|
|
32626
|
-
|
|
32755
|
+
throw new Error(
|
|
32756
|
+
"Viem wallet client requires an account option or account property"
|
|
32757
|
+
);
|
|
32758
|
+
}
|
|
32759
|
+
async function buildPersonalServerLiteOwnerBindingSignature(input) {
|
|
32760
|
+
const message = buildPersonalServerLiteOwnerBindingMessage(
|
|
32761
|
+
input.signer.address
|
|
32762
|
+
);
|
|
32763
|
+
const signature = await input.signer.signMessage({ message });
|
|
32764
|
+
return {
|
|
32765
|
+
signature,
|
|
32766
|
+
signerAddress: input.signer.address,
|
|
32767
|
+
message,
|
|
32768
|
+
purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
|
|
32769
|
+
};
|
|
32770
|
+
}
|
|
32771
|
+
var signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSignature;
|
|
32772
|
+
|
|
32773
|
+
// src/account/personal-server-registration.ts
|
|
32774
|
+
import { isAddress as isAddress3 } from "viem";
|
|
32775
|
+
var ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT = "personal_server.server_registration.v1";
|
|
32776
|
+
var AccountPersonalServerRegistrationError = class extends Error {
|
|
32777
|
+
status;
|
|
32778
|
+
code;
|
|
32779
|
+
details;
|
|
32780
|
+
constructor(input) {
|
|
32781
|
+
super(input.message);
|
|
32782
|
+
this.name = "AccountPersonalServerRegistrationError";
|
|
32783
|
+
this.status = input.status;
|
|
32784
|
+
this.code = input.code;
|
|
32785
|
+
this.details = input.details;
|
|
32627
32786
|
}
|
|
32628
|
-
|
|
32629
|
-
|
|
32787
|
+
};
|
|
32788
|
+
var DEFAULT_ACCOUNT_PS_REGISTRATION_PATH = "/api/v1/intents/personal-server-registration/sign";
|
|
32789
|
+
function trimTrailingSlash(value) {
|
|
32790
|
+
return value.replace(/\/+$/, "");
|
|
32791
|
+
}
|
|
32792
|
+
function assertAddress3(value, name) {
|
|
32793
|
+
if (!isAddress3(value)) {
|
|
32794
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
32630
32795
|
}
|
|
32631
|
-
|
|
32632
|
-
|
|
32796
|
+
}
|
|
32797
|
+
async function parseAccountResponse(response) {
|
|
32798
|
+
const body = await response.json().catch(() => void 0);
|
|
32799
|
+
if (!response.ok) {
|
|
32800
|
+
throw new AccountPersonalServerRegistrationError({
|
|
32801
|
+
status: response.status,
|
|
32802
|
+
code: accountErrorCode(body),
|
|
32803
|
+
message: accountErrorMessage(response.status, body),
|
|
32804
|
+
details: body
|
|
32805
|
+
});
|
|
32806
|
+
}
|
|
32807
|
+
return body;
|
|
32808
|
+
}
|
|
32809
|
+
function accountErrorMessage(status, body) {
|
|
32810
|
+
const nestedMessage = nestedAccountErrorField(body, "message");
|
|
32811
|
+
if (nestedMessage) {
|
|
32812
|
+
return nestedMessage;
|
|
32813
|
+
}
|
|
32814
|
+
if (isRecord(body) && typeof body.message === "string") {
|
|
32815
|
+
return body.message;
|
|
32816
|
+
}
|
|
32817
|
+
const code = accountErrorCode(body);
|
|
32818
|
+
if (code) {
|
|
32819
|
+
return `Account PS registration signing failed: ${code}`;
|
|
32820
|
+
}
|
|
32821
|
+
return `Account PS registration signing failed: ${status}`;
|
|
32822
|
+
}
|
|
32823
|
+
function accountErrorCode(body) {
|
|
32824
|
+
const nestedCode = nestedAccountErrorField(body, "code");
|
|
32825
|
+
if (nestedCode) {
|
|
32826
|
+
return nestedCode;
|
|
32827
|
+
}
|
|
32828
|
+
if (isRecord(body)) {
|
|
32829
|
+
if (typeof body.code === "string") {
|
|
32830
|
+
return body.code;
|
|
32831
|
+
}
|
|
32832
|
+
if (typeof body.error === "string") {
|
|
32833
|
+
return body.error;
|
|
32834
|
+
}
|
|
32633
32835
|
}
|
|
32836
|
+
return void 0;
|
|
32837
|
+
}
|
|
32838
|
+
function nestedAccountErrorField(body, field) {
|
|
32839
|
+
if (!isRecord(body) || !isRecord(body.error)) {
|
|
32840
|
+
return void 0;
|
|
32841
|
+
}
|
|
32842
|
+
const value = body.error[field];
|
|
32843
|
+
return typeof value === "string" ? value : void 0;
|
|
32844
|
+
}
|
|
32845
|
+
function isRecord(value) {
|
|
32846
|
+
return typeof value === "object" && value !== null;
|
|
32847
|
+
}
|
|
32848
|
+
function normalizeAccountResponse(response) {
|
|
32634
32849
|
return {
|
|
32635
|
-
|
|
32636
|
-
|
|
32637
|
-
|
|
32638
|
-
|
|
32639
|
-
nonce: value["nonce"]
|
|
32850
|
+
...response,
|
|
32851
|
+
status: response.status === "fallback_required" ? "confirmation_required" : response.status,
|
|
32852
|
+
signerAddress: response.signerAddress ?? response.signer?.address,
|
|
32853
|
+
typedData: response.typedData ?? response.typed_data
|
|
32640
32854
|
};
|
|
32641
32855
|
}
|
|
32642
|
-
function
|
|
32643
|
-
|
|
32644
|
-
|
|
32856
|
+
function buildSignedResult(response, request) {
|
|
32857
|
+
assertAddress3(response.signerAddress, "signerAddress");
|
|
32858
|
+
if (response.typedData) {
|
|
32859
|
+
assertTypedDataMatchesRequest(
|
|
32860
|
+
response.typedData,
|
|
32861
|
+
request,
|
|
32862
|
+
response.signerAddress
|
|
32863
|
+
);
|
|
32864
|
+
}
|
|
32865
|
+
return {
|
|
32866
|
+
signature: response.signature,
|
|
32867
|
+
signerAddress: response.signerAddress,
|
|
32868
|
+
typedData: response.typedData ?? buildPersonalServerRegistrationTypedData({
|
|
32869
|
+
ownerAddress: response.signerAddress,
|
|
32870
|
+
...request
|
|
32871
|
+
}),
|
|
32872
|
+
intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT
|
|
32873
|
+
};
|
|
32874
|
+
}
|
|
32875
|
+
function assertTypedDataMatchesRequest(typedData, request, expectedSignerAddress) {
|
|
32876
|
+
assertAddress3(
|
|
32877
|
+
typedData.message.ownerAddress,
|
|
32878
|
+
"typedData.message.ownerAddress"
|
|
32879
|
+
);
|
|
32880
|
+
assertAddress3(
|
|
32881
|
+
typedData.message.serverAddress,
|
|
32882
|
+
"typedData.message.serverAddress"
|
|
32883
|
+
);
|
|
32884
|
+
if (expectedSignerAddress && !sameAddress(typedData.message.ownerAddress, expectedSignerAddress)) {
|
|
32885
|
+
throw new Error(
|
|
32886
|
+
"Account typedData ownerAddress must match the expected signer address"
|
|
32887
|
+
);
|
|
32888
|
+
}
|
|
32889
|
+
if (!sameAddress(typedData.message.serverAddress, request.serverAddress)) {
|
|
32890
|
+
throw new Error(
|
|
32891
|
+
"Account typedData serverAddress must match the requested serverAddress"
|
|
32892
|
+
);
|
|
32893
|
+
}
|
|
32894
|
+
if (typedData.message.publicKey !== request.serverPublicKey) {
|
|
32895
|
+
throw new Error(
|
|
32896
|
+
"Account typedData publicKey must match the requested serverPublicKey"
|
|
32897
|
+
);
|
|
32898
|
+
}
|
|
32899
|
+
if (typedData.message.serverUrl !== request.serverUrl) {
|
|
32900
|
+
throw new Error(
|
|
32901
|
+
"Account typedData serverUrl must match the requested serverUrl"
|
|
32902
|
+
);
|
|
32903
|
+
}
|
|
32904
|
+
if (typedData.primaryType !== "ServerRegistration") {
|
|
32905
|
+
throw new Error("Account typedData primaryType must be ServerRegistration");
|
|
32906
|
+
}
|
|
32907
|
+
if (JSON.stringify(typedData.types) !== JSON.stringify(SERVER_REGISTRATION_TYPES)) {
|
|
32908
|
+
throw new Error("Account typedData types must be ServerRegistration types");
|
|
32909
|
+
}
|
|
32910
|
+
const expectedDomain = personalServerRegistrationDomain({
|
|
32911
|
+
config: request.config,
|
|
32912
|
+
chainId: request.chainId,
|
|
32913
|
+
verifyingContract: request.verifyingContract
|
|
32914
|
+
});
|
|
32915
|
+
if (!domainsEqual(typedData.domain, expectedDomain)) {
|
|
32916
|
+
throw new Error("Account typedData domain must match the requested domain");
|
|
32917
|
+
}
|
|
32918
|
+
}
|
|
32919
|
+
function sameAddress(a, b) {
|
|
32920
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
32921
|
+
}
|
|
32922
|
+
function domainsEqual(a, b) {
|
|
32923
|
+
if (!a || !b) {
|
|
32924
|
+
return false;
|
|
32925
|
+
}
|
|
32926
|
+
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;
|
|
32927
|
+
}
|
|
32928
|
+
async function signPersonalServerRegistrationWithAccount(config, request) {
|
|
32929
|
+
assertAddress3(request.serverAddress, "serverAddress");
|
|
32930
|
+
const fetchImpl = config.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
32931
|
+
const endpoint = new URL(
|
|
32932
|
+
config.endpointPath ?? DEFAULT_ACCOUNT_PS_REGISTRATION_PATH,
|
|
32933
|
+
`${trimTrailingSlash(config.accountOrigin)}/`
|
|
32934
|
+
);
|
|
32935
|
+
const response = await fetchImpl(endpoint, {
|
|
32936
|
+
method: "POST",
|
|
32937
|
+
headers: { "content-type": "application/json" },
|
|
32938
|
+
credentials: "include",
|
|
32939
|
+
body: JSON.stringify({
|
|
32940
|
+
intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
32941
|
+
serverAddress: request.serverAddress,
|
|
32942
|
+
serverPublicKey: request.serverPublicKey,
|
|
32943
|
+
serverUrl: request.serverUrl,
|
|
32944
|
+
config: request.config,
|
|
32945
|
+
chainId: request.chainId,
|
|
32946
|
+
verifyingContract: request.verifyingContract
|
|
32947
|
+
})
|
|
32948
|
+
});
|
|
32949
|
+
const body = normalizeAccountResponse(await parseAccountResponse(response));
|
|
32950
|
+
if (body.status === "signed") {
|
|
32951
|
+
if (!body.signature || !body.signerAddress) {
|
|
32952
|
+
throw new Error(
|
|
32953
|
+
"Account signed response must include signature and signerAddress"
|
|
32954
|
+
);
|
|
32955
|
+
}
|
|
32645
32956
|
return {
|
|
32646
|
-
|
|
32647
|
-
|
|
32957
|
+
status: "signed",
|
|
32958
|
+
result: buildSignedResult(
|
|
32959
|
+
{
|
|
32960
|
+
signature: body.signature,
|
|
32961
|
+
signerAddress: body.signerAddress,
|
|
32962
|
+
typedData: body.typedData
|
|
32963
|
+
},
|
|
32964
|
+
request
|
|
32965
|
+
)
|
|
32648
32966
|
};
|
|
32967
|
+
}
|
|
32968
|
+
if (body.status === "confirmation_required") {
|
|
32969
|
+
if (!body.typedData) {
|
|
32970
|
+
throw new Error(
|
|
32971
|
+
"Account confirmation_required response must include typedData"
|
|
32972
|
+
);
|
|
32973
|
+
}
|
|
32974
|
+
assertTypedDataMatchesRequest(body.typedData, request, body.signerAddress);
|
|
32975
|
+
if (!config.fallbackSigner) {
|
|
32976
|
+
return {
|
|
32977
|
+
status: "confirmation_required",
|
|
32978
|
+
typedData: body.typedData,
|
|
32979
|
+
signerAddress: body.signerAddress
|
|
32980
|
+
};
|
|
32981
|
+
}
|
|
32982
|
+
assertTypedDataMatchesRequest(
|
|
32983
|
+
body.typedData,
|
|
32984
|
+
request,
|
|
32985
|
+
config.fallbackSigner.address
|
|
32986
|
+
);
|
|
32987
|
+
const signature = await config.fallbackSigner.signTypedData(body.typedData);
|
|
32988
|
+
return {
|
|
32989
|
+
status: "fallback_signed",
|
|
32990
|
+
accountStatus: "confirmation_required",
|
|
32991
|
+
result: {
|
|
32992
|
+
signature,
|
|
32993
|
+
signerAddress: config.fallbackSigner.address,
|
|
32994
|
+
typedData: body.typedData,
|
|
32995
|
+
intent: ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT
|
|
32996
|
+
}
|
|
32997
|
+
};
|
|
32998
|
+
}
|
|
32999
|
+
throw new Error(
|
|
33000
|
+
`Unsupported Account PS registration signing status: ${String(body.status)}`
|
|
33001
|
+
);
|
|
33002
|
+
}
|
|
33003
|
+
|
|
33004
|
+
// src/account/personal-server-lite-owner-binding.ts
|
|
33005
|
+
var AccountPersonalServerLiteOwnerBindingError = class extends Error {
|
|
33006
|
+
code;
|
|
33007
|
+
details;
|
|
33008
|
+
constructor(input) {
|
|
33009
|
+
super(input.message);
|
|
33010
|
+
this.name = "AccountPersonalServerLiteOwnerBindingError";
|
|
33011
|
+
this.code = input.code;
|
|
33012
|
+
this.details = input.details;
|
|
33013
|
+
}
|
|
33014
|
+
};
|
|
33015
|
+
async function signPersonalServerLiteOwnerBindingWithAccountClient(config) {
|
|
33016
|
+
let address;
|
|
33017
|
+
try {
|
|
33018
|
+
address = await config.client.getAddress();
|
|
33019
|
+
} catch (error) {
|
|
33020
|
+
throw accountOwnerBindingError(error);
|
|
33021
|
+
}
|
|
33022
|
+
if (!address) {
|
|
33023
|
+
throw new AccountPersonalServerLiteOwnerBindingError({
|
|
33024
|
+
message: "Account did not return a wallet address",
|
|
33025
|
+
code: "account_address_required"
|
|
33026
|
+
});
|
|
33027
|
+
}
|
|
33028
|
+
const message = buildPersonalServerLiteOwnerBindingMessage(address);
|
|
33029
|
+
let signature;
|
|
33030
|
+
try {
|
|
33031
|
+
signature = await config.client.signMessage({ message });
|
|
33032
|
+
} catch (error) {
|
|
33033
|
+
throw accountOwnerBindingError(error);
|
|
33034
|
+
}
|
|
33035
|
+
return {
|
|
33036
|
+
signature,
|
|
33037
|
+
signerAddress: address,
|
|
33038
|
+
message,
|
|
33039
|
+
purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE
|
|
33040
|
+
};
|
|
33041
|
+
}
|
|
33042
|
+
function accountOwnerBindingError(error) {
|
|
33043
|
+
if (error instanceof AccountPersonalServerLiteOwnerBindingError) {
|
|
33044
|
+
return error;
|
|
33045
|
+
}
|
|
33046
|
+
const rpcError = error;
|
|
33047
|
+
const code = rpcError?.code;
|
|
33048
|
+
const message = typeof rpcError?.message === "string" && rpcError.message.length > 0 ? rpcError.message : "Account PS Lite owner-binding signature failed";
|
|
33049
|
+
return new AccountPersonalServerLiteOwnerBindingError({
|
|
33050
|
+
message,
|
|
33051
|
+
code,
|
|
33052
|
+
details: error
|
|
33053
|
+
});
|
|
33054
|
+
}
|
|
33055
|
+
|
|
33056
|
+
// src/protocol/grants.ts
|
|
33057
|
+
import { verifyTypedData } from "viem";
|
|
33058
|
+
function isHexString(value) {
|
|
33059
|
+
return typeof value === "string" && value.startsWith("0x");
|
|
33060
|
+
}
|
|
33061
|
+
function isDataPortabilityGatewayConfig(value) {
|
|
33062
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
33063
|
+
return false;
|
|
33064
|
+
}
|
|
33065
|
+
const config = value;
|
|
33066
|
+
const contracts = config["contracts"];
|
|
33067
|
+
if (typeof config["chainId"] !== "number" || !Number.isInteger(config["chainId"]) || config["chainId"] <= 0 || contracts === null || typeof contracts !== "object" || Array.isArray(contracts)) {
|
|
33068
|
+
return false;
|
|
33069
|
+
}
|
|
33070
|
+
const c = contracts;
|
|
33071
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]);
|
|
33072
|
+
}
|
|
33073
|
+
function toUint256(value) {
|
|
33074
|
+
try {
|
|
33075
|
+
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
33076
|
+
if (big < 0n) return null;
|
|
33077
|
+
return big;
|
|
32649
33078
|
} catch {
|
|
32650
33079
|
return null;
|
|
32651
33080
|
}
|
|
32652
33081
|
}
|
|
32653
33082
|
async function verifyGrantRegistration(input) {
|
|
32654
|
-
|
|
32655
|
-
|
|
32656
|
-
|
|
32657
|
-
|
|
32658
|
-
|
|
32659
|
-
};
|
|
33083
|
+
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
33084
|
+
return { valid: false, error: "scopes must be a non-empty array" };
|
|
33085
|
+
}
|
|
33086
|
+
if (!input.scopes.every((scope) => typeof scope === "string")) {
|
|
33087
|
+
return { valid: false, error: "scopes must contain only strings" };
|
|
32660
33088
|
}
|
|
32661
|
-
const
|
|
32662
|
-
if (
|
|
32663
|
-
return { valid: false, error: "
|
|
33089
|
+
const grantVersion = toUint256(input.grantVersion);
|
|
33090
|
+
if (grantVersion === null || grantVersion < 1n) {
|
|
33091
|
+
return { valid: false, error: "grantVersion must be a uint256 >= 1" };
|
|
33092
|
+
}
|
|
33093
|
+
const expiresAt = toUint256(input.expiresAt);
|
|
33094
|
+
if (expiresAt === null) {
|
|
33095
|
+
return { valid: false, error: "expiresAt must be a non-negative uint256" };
|
|
32664
33096
|
}
|
|
32665
33097
|
let valid;
|
|
32666
33098
|
try {
|
|
@@ -32672,8 +33104,9 @@ async function verifyGrantRegistration(input) {
|
|
|
32672
33104
|
message: {
|
|
32673
33105
|
grantorAddress: input.grantorAddress,
|
|
32674
33106
|
granteeId: input.granteeId,
|
|
32675
|
-
|
|
32676
|
-
|
|
33107
|
+
scopes: input.scopes,
|
|
33108
|
+
grantVersion,
|
|
33109
|
+
expiresAt
|
|
32677
33110
|
},
|
|
32678
33111
|
signature: input.signature
|
|
32679
33112
|
});
|
|
@@ -32684,19 +33117,69 @@ async function verifyGrantRegistration(input) {
|
|
|
32684
33117
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
32685
33118
|
}
|
|
32686
33119
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
32687
|
-
if (
|
|
33120
|
+
if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
|
|
32688
33121
|
return { valid: false, error: "Grant has expired" };
|
|
32689
33122
|
}
|
|
32690
|
-
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
32691
|
-
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
32692
|
-
}
|
|
32693
33123
|
return {
|
|
32694
33124
|
valid: true,
|
|
32695
33125
|
grantorAddress: input.grantorAddress,
|
|
32696
33126
|
granteeId: input.granteeId,
|
|
32697
|
-
|
|
32698
|
-
|
|
32699
|
-
|
|
33127
|
+
scopes: input.scopes,
|
|
33128
|
+
grantVersion: grantVersion.toString(),
|
|
33129
|
+
expiresAt: expiresAt.toString()
|
|
33130
|
+
};
|
|
33131
|
+
}
|
|
33132
|
+
|
|
33133
|
+
// src/protocol/escrow-deposit.ts
|
|
33134
|
+
import { encodeFunctionData } from "viem";
|
|
33135
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
33136
|
+
{
|
|
33137
|
+
type: "function",
|
|
33138
|
+
name: "depositNative",
|
|
33139
|
+
stateMutability: "payable",
|
|
33140
|
+
inputs: [{ name: "account", type: "address" }],
|
|
33141
|
+
outputs: []
|
|
33142
|
+
},
|
|
33143
|
+
{
|
|
33144
|
+
type: "function",
|
|
33145
|
+
name: "depositToken",
|
|
33146
|
+
stateMutability: "nonpayable",
|
|
33147
|
+
inputs: [
|
|
33148
|
+
{ name: "account", type: "address" },
|
|
33149
|
+
{ name: "token", type: "address" },
|
|
33150
|
+
{ name: "amount", type: "uint256" }
|
|
33151
|
+
],
|
|
33152
|
+
outputs: []
|
|
33153
|
+
}
|
|
33154
|
+
];
|
|
33155
|
+
function escrowContractAddress(config) {
|
|
33156
|
+
return config.contracts.dataPortabilityEscrow;
|
|
33157
|
+
}
|
|
33158
|
+
function encodeDepositNativeData(input) {
|
|
33159
|
+
return encodeFunctionData({
|
|
33160
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33161
|
+
functionName: "depositNative",
|
|
33162
|
+
args: [input.account]
|
|
33163
|
+
});
|
|
33164
|
+
}
|
|
33165
|
+
function encodeDepositTokenData(input) {
|
|
33166
|
+
return encodeFunctionData({
|
|
33167
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33168
|
+
functionName: "depositToken",
|
|
33169
|
+
args: [input.account, input.token, input.amount]
|
|
33170
|
+
});
|
|
33171
|
+
}
|
|
33172
|
+
function buildDepositNativeRequest(config, input) {
|
|
33173
|
+
return {
|
|
33174
|
+
to: escrowContractAddress(config),
|
|
33175
|
+
data: encodeDepositNativeData({ account: input.account }),
|
|
33176
|
+
value: input.amount
|
|
33177
|
+
};
|
|
33178
|
+
}
|
|
33179
|
+
function buildDepositTokenRequest(config, input) {
|
|
33180
|
+
return {
|
|
33181
|
+
to: escrowContractAddress(config),
|
|
33182
|
+
data: encodeDepositTokenData(input)
|
|
32700
33183
|
};
|
|
32701
33184
|
}
|
|
32702
33185
|
|
|
@@ -32896,6 +33379,68 @@ function createGatewayClient(baseUrl) {
|
|
|
32896
33379
|
alreadyRegistered: false
|
|
32897
33380
|
};
|
|
32898
33381
|
},
|
|
33382
|
+
async registerBuilder(params) {
|
|
33383
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
33384
|
+
method: "POST",
|
|
33385
|
+
headers: {
|
|
33386
|
+
"Content-Type": "application/json",
|
|
33387
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33388
|
+
},
|
|
33389
|
+
body: JSON.stringify({
|
|
33390
|
+
ownerAddress: params.ownerAddress,
|
|
33391
|
+
granteeAddress: params.granteeAddress,
|
|
33392
|
+
publicKey: params.publicKey,
|
|
33393
|
+
appUrl: params.appUrl
|
|
33394
|
+
})
|
|
33395
|
+
});
|
|
33396
|
+
if (res.status === 409) {
|
|
33397
|
+
const body2 = await res.json().catch(() => ({}));
|
|
33398
|
+
return {
|
|
33399
|
+
builderId: getMutationId(
|
|
33400
|
+
body2,
|
|
33401
|
+
"builderId"
|
|
33402
|
+
),
|
|
33403
|
+
alreadyRegistered: true
|
|
33404
|
+
};
|
|
33405
|
+
}
|
|
33406
|
+
if (!res.ok) {
|
|
33407
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33408
|
+
}
|
|
33409
|
+
const body = await res.json().catch(() => ({}));
|
|
33410
|
+
return {
|
|
33411
|
+
builderId: getMutationId(body, "builderId"),
|
|
33412
|
+
alreadyRegistered: false
|
|
33413
|
+
};
|
|
33414
|
+
},
|
|
33415
|
+
async registerDataPoint(params) {
|
|
33416
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
33417
|
+
method: "POST",
|
|
33418
|
+
headers: {
|
|
33419
|
+
"Content-Type": "application/json",
|
|
33420
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33421
|
+
},
|
|
33422
|
+
body: JSON.stringify({
|
|
33423
|
+
ownerAddress: params.ownerAddress,
|
|
33424
|
+
scope: params.scope,
|
|
33425
|
+
dataHash: params.dataHash,
|
|
33426
|
+
metadataHash: params.metadataHash,
|
|
33427
|
+
expectedVersion: params.expectedVersion
|
|
33428
|
+
})
|
|
33429
|
+
});
|
|
33430
|
+
if (!res.ok) {
|
|
33431
|
+
const body2 = await res.json().catch(() => ({}));
|
|
33432
|
+
const detail = body2.error ?? res.statusText;
|
|
33433
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33434
|
+
}
|
|
33435
|
+
const body = await res.json().catch(() => ({}));
|
|
33436
|
+
return {
|
|
33437
|
+
dataPointId: getMutationId(
|
|
33438
|
+
body,
|
|
33439
|
+
"dataPointId"
|
|
33440
|
+
),
|
|
33441
|
+
expectedVersion: body.expectedVersion
|
|
33442
|
+
};
|
|
33443
|
+
},
|
|
32899
33444
|
async registerFile(params) {
|
|
32900
33445
|
const res = await fetch(`${base}/v1/files`, {
|
|
32901
33446
|
method: "POST",
|
|
@@ -32933,8 +33478,9 @@ function createGatewayClient(baseUrl) {
|
|
|
32933
33478
|
body: JSON.stringify({
|
|
32934
33479
|
grantorAddress: params.grantorAddress,
|
|
32935
33480
|
granteeId: params.granteeId,
|
|
32936
|
-
|
|
32937
|
-
|
|
33481
|
+
scopes: params.scopes,
|
|
33482
|
+
grantVersion: params.grantVersion,
|
|
33483
|
+
expiresAt: params.expiresAt
|
|
32938
33484
|
})
|
|
32939
33485
|
});
|
|
32940
33486
|
if (res.status === 409) {
|
|
@@ -32959,13 +33505,71 @@ function createGatewayClient(baseUrl) {
|
|
|
32959
33505
|
Authorization: `Web3Signed ${params.signature}`
|
|
32960
33506
|
},
|
|
32961
33507
|
body: JSON.stringify({
|
|
32962
|
-
grantorAddress: params.grantorAddress
|
|
33508
|
+
grantorAddress: params.grantorAddress,
|
|
33509
|
+
grantVersion: params.grantVersion
|
|
32963
33510
|
})
|
|
32964
33511
|
});
|
|
32965
33512
|
if (res.status === 409) return;
|
|
32966
33513
|
if (!res.ok) {
|
|
32967
33514
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32968
33515
|
}
|
|
33516
|
+
},
|
|
33517
|
+
async getEscrowBalance(account) {
|
|
33518
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
33519
|
+
if (!res.ok) {
|
|
33520
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33521
|
+
}
|
|
33522
|
+
return await res.json();
|
|
33523
|
+
},
|
|
33524
|
+
async submitEscrowDeposit(params) {
|
|
33525
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33526
|
+
method: "POST",
|
|
33527
|
+
headers: { "Content-Type": "application/json" },
|
|
33528
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
33529
|
+
});
|
|
33530
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
33531
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33532
|
+
}
|
|
33533
|
+
return await res.json();
|
|
33534
|
+
},
|
|
33535
|
+
async payForOperation(params) {
|
|
33536
|
+
const body = {
|
|
33537
|
+
payerAddress: params.payerAddress,
|
|
33538
|
+
opType: params.opType,
|
|
33539
|
+
opId: params.opId,
|
|
33540
|
+
asset: params.asset,
|
|
33541
|
+
amount: params.amount,
|
|
33542
|
+
paymentNonce: params.paymentNonce
|
|
33543
|
+
};
|
|
33544
|
+
if (params.accessRecord) {
|
|
33545
|
+
body["accessRecord"] = params.accessRecord;
|
|
33546
|
+
}
|
|
33547
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33548
|
+
method: "POST",
|
|
33549
|
+
headers: {
|
|
33550
|
+
"Content-Type": "application/json",
|
|
33551
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33552
|
+
},
|
|
33553
|
+
body: JSON.stringify(body)
|
|
33554
|
+
});
|
|
33555
|
+
if (!res.ok) {
|
|
33556
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33557
|
+
}
|
|
33558
|
+
return await res.json();
|
|
33559
|
+
},
|
|
33560
|
+
async settle(params) {
|
|
33561
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
33562
|
+
method: "POST",
|
|
33563
|
+
headers: { "Content-Type": "application/json" },
|
|
33564
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33565
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
33566
|
+
// doesn't have to deal with an undefined.
|
|
33567
|
+
body: JSON.stringify(params ?? {})
|
|
33568
|
+
});
|
|
33569
|
+
if (!res.ok) {
|
|
33570
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33571
|
+
}
|
|
33572
|
+
return await res.json();
|
|
32969
33573
|
}
|
|
32970
33574
|
};
|
|
32971
33575
|
}
|
|
@@ -32995,7 +33599,7 @@ var KNOWN_CODES = /* @__PURE__ */ new Set([
|
|
|
32995
33599
|
"server_not_configured",
|
|
32996
33600
|
"content_too_large"
|
|
32997
33601
|
]);
|
|
32998
|
-
function
|
|
33602
|
+
function isRecord2(value) {
|
|
32999
33603
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
33000
33604
|
}
|
|
33001
33605
|
function normalizeCode(value) {
|
|
@@ -33006,10 +33610,10 @@ function normalizeCode(value) {
|
|
|
33006
33610
|
return KNOWN_CODES.has(code) ? code : null;
|
|
33007
33611
|
}
|
|
33008
33612
|
function extractPSErrorBody(body) {
|
|
33009
|
-
if (!
|
|
33613
|
+
if (!isRecord2(body)) {
|
|
33010
33614
|
return null;
|
|
33011
33615
|
}
|
|
33012
|
-
const nested =
|
|
33616
|
+
const nested = isRecord2(body.error) ? body.error : null;
|
|
33013
33617
|
const code = normalizeCode(
|
|
33014
33618
|
nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
|
|
33015
33619
|
);
|
|
@@ -33033,6 +33637,10 @@ async function parsePSError(response) {
|
|
|
33033
33637
|
return errorBody ? new PSError(errorBody.code, errorBody.message) : null;
|
|
33034
33638
|
}
|
|
33035
33639
|
export {
|
|
33640
|
+
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33641
|
+
ADD_DATA_TYPES,
|
|
33642
|
+
AccountPersonalServerLiteOwnerBindingError,
|
|
33643
|
+
AccountPersonalServerRegistrationError,
|
|
33036
33644
|
BUILDER_REGISTRATION_TYPES,
|
|
33037
33645
|
BlockchainError,
|
|
33038
33646
|
BrowserPlatformAdapter,
|
|
@@ -33043,8 +33651,10 @@ export {
|
|
|
33043
33651
|
DataFileEnvelopeSchema,
|
|
33044
33652
|
DropboxStorage,
|
|
33045
33653
|
ECIESError,
|
|
33654
|
+
ESCROW_DEPOSIT_ABI,
|
|
33046
33655
|
ExpiredTokenError,
|
|
33047
33656
|
FILE_REGISTRATION_TYPES,
|
|
33657
|
+
GENERIC_PAYMENT_TYPES,
|
|
33048
33658
|
GRANT_REGISTRATION_TYPES,
|
|
33049
33659
|
GRANT_REVOCATION_TYPES,
|
|
33050
33660
|
GoogleDriveStorage,
|
|
@@ -33055,11 +33665,17 @@ export {
|
|
|
33055
33665
|
IpfsStorage,
|
|
33056
33666
|
MASTER_KEY_MESSAGE,
|
|
33057
33667
|
MissingAuthError,
|
|
33668
|
+
NATIVE_VANA_ASSET,
|
|
33058
33669
|
NetworkError,
|
|
33059
33670
|
NodeECIESUint8Provider as NodeECIESProvider,
|
|
33060
33671
|
NodePlatformAdapter,
|
|
33061
33672
|
NonceError,
|
|
33062
33673
|
OAuthClient,
|
|
33674
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
33675
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
33676
|
+
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
33677
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
33678
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT,
|
|
33063
33679
|
PKCE_CHALLENGE_PATTERN,
|
|
33064
33680
|
PKCE_VERIFIER_PATTERN,
|
|
33065
33681
|
PSError,
|
|
@@ -33067,6 +33683,7 @@ export {
|
|
|
33067
33683
|
PersonalServerError,
|
|
33068
33684
|
PinataStorage,
|
|
33069
33685
|
R2Storage,
|
|
33686
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
33070
33687
|
ReadOnlyError,
|
|
33071
33688
|
RelayerError,
|
|
33072
33689
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33081,6 +33698,12 @@ export {
|
|
|
33081
33698
|
VanaError,
|
|
33082
33699
|
VanaStorage,
|
|
33083
33700
|
assertValidPkceVerifier,
|
|
33701
|
+
buildDepositNativeRequest,
|
|
33702
|
+
buildDepositTokenRequest,
|
|
33703
|
+
buildPersonalServerLiteOwnerBindingMessage,
|
|
33704
|
+
buildPersonalServerLiteOwnerBindingSignature,
|
|
33705
|
+
buildPersonalServerRegistrationSignature,
|
|
33706
|
+
buildPersonalServerRegistrationTypedData,
|
|
33084
33707
|
buildWeb3SignedHeader,
|
|
33085
33708
|
builderRegistrationDomain,
|
|
33086
33709
|
chains,
|
|
@@ -33096,12 +33719,19 @@ export {
|
|
|
33096
33719
|
createPlatformAdapterFor,
|
|
33097
33720
|
createPlatformAdapterSafe,
|
|
33098
33721
|
createVanaStorageProvider,
|
|
33722
|
+
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33723
|
+
createViemPersonalServerRegistrationSigner,
|
|
33724
|
+
dataRegistryDomain,
|
|
33099
33725
|
decryptWithPassword,
|
|
33100
33726
|
deriveMasterKey,
|
|
33101
33727
|
deriveScopeKey,
|
|
33102
33728
|
deserializeECIES,
|
|
33103
33729
|
detectPlatform,
|
|
33730
|
+
encodeDepositNativeData,
|
|
33731
|
+
encodeDepositTokenData,
|
|
33104
33732
|
encryptWithPassword,
|
|
33733
|
+
escrowContractAddress,
|
|
33734
|
+
escrowPaymentDomain,
|
|
33105
33735
|
fileRegistrationDomain,
|
|
33106
33736
|
generatePkceVerifier,
|
|
33107
33737
|
getAbi,
|
|
@@ -33121,16 +33751,20 @@ export {
|
|
|
33121
33751
|
moksha,
|
|
33122
33752
|
mokshaServices,
|
|
33123
33753
|
mokshaTestnet2 as mokshaTestnet,
|
|
33124
|
-
parseGrantRegistrationPayload,
|
|
33125
33754
|
parsePSError,
|
|
33126
33755
|
parseScope,
|
|
33127
33756
|
parseWeb3SignedHeader,
|
|
33757
|
+
personalServerRegistrationDomain,
|
|
33128
33758
|
recoverServerOwner,
|
|
33759
|
+
registerPersonalServerSignature,
|
|
33129
33760
|
scopeCoveredByGrant,
|
|
33130
33761
|
scopeMatchesPattern,
|
|
33131
33762
|
scopeToPathSegments,
|
|
33132
33763
|
serializeECIES,
|
|
33133
33764
|
serverRegistrationDomain,
|
|
33765
|
+
signPersonalServerLiteOwnerBinding,
|
|
33766
|
+
signPersonalServerLiteOwnerBindingWithAccountClient,
|
|
33767
|
+
signPersonalServerRegistrationWithAccount,
|
|
33134
33768
|
vanaMainnet2 as vanaMainnet,
|
|
33135
33769
|
verifyGrantRegistration,
|
|
33136
33770
|
verifyPkceChallenge,
|