@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.
- package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
- package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
- package/dist/account/personal-server-lite-owner-binding.js +1 -1
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
- package/dist/index.browser.d.ts +2 -1
- package/dist/index.browser.js +133 -6
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +138 -6
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +2 -1
- package/dist/index.node.js +133 -6
- package/dist/index.node.js.map +4 -4
- package/dist/{protocol/personal-server-lite-owner-binding.cjs → personal-server-lite/owner-binding.cjs} +5 -5
- package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
- package/dist/{protocol/personal-server-lite-owner-binding.d.ts → personal-server-lite/owner-binding.d.ts} +3 -3
- package/dist/{protocol/personal-server-lite-owner-binding.js → personal-server-lite/owner-binding.js} +2 -2
- package/dist/personal-server-lite/owner-binding.js.map +1 -0
- package/dist/protocol/escrow.cjs +146 -0
- package/dist/protocol/escrow.cjs.map +1 -0
- package/dist/protocol/escrow.d.ts +336 -0
- package/dist/protocol/escrow.js +118 -0
- package/dist/protocol/escrow.js.map +1 -0
- package/dist/protocol/escrow.test.d.ts +1 -0
- package/dist/protocol/personal-server-registration.cjs +16 -4
- package/dist/protocol/personal-server-registration.cjs.map +1 -1
- package/dist/protocol/personal-server-registration.d.ts +5 -2
- package/dist/protocol/personal-server-registration.js +16 -4
- package/dist/protocol/personal-server-registration.js.map +1 -1
- package/package.json +1 -1
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.js.map +0 -1
- /package/dist/{protocol/personal-server-lite-owner-binding.test.d.ts → personal-server-lite/owner-binding.test.d.ts} +0 -0
package/dist/index.node.cjs
CHANGED
|
@@ -1186,9 +1186,11 @@ __export(index_node_exports, {
|
|
|
1186
1186
|
DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
|
|
1187
1187
|
DropboxStorage: () => DropboxStorage,
|
|
1188
1188
|
ECIESError: () => ECIESError,
|
|
1189
|
+
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI,
|
|
1189
1190
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
1190
1191
|
FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
|
|
1191
1192
|
FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
|
|
1193
|
+
GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
|
|
1192
1194
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
1193
1195
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
1194
1196
|
GoogleDriveStorage: () => GoogleDriveStorage,
|
|
@@ -1199,6 +1201,7 @@ __export(index_node_exports, {
|
|
|
1199
1201
|
IpfsStorage: () => IpfsStorage,
|
|
1200
1202
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1201
1203
|
MissingAuthError: () => MissingAuthError,
|
|
1204
|
+
NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
|
|
1202
1205
|
NetworkError: () => NetworkError,
|
|
1203
1206
|
NodeECIESProvider: () => NodeECIESUint8Provider,
|
|
1204
1207
|
NodePlatformAdapter: () => NodePlatformAdapter,
|
|
@@ -1243,6 +1246,7 @@ __export(index_node_exports, {
|
|
|
1243
1246
|
contractCacheForTesting: () => contractCacheForTesting,
|
|
1244
1247
|
createBrowserPlatformAdapter: () => createBrowserPlatformAdapter,
|
|
1245
1248
|
createDataFileEnvelope: () => createDataFileEnvelope,
|
|
1249
|
+
createEscrowGatewayClient: () => createEscrowGatewayClient,
|
|
1246
1250
|
createGatewayClient: () => createGatewayClient,
|
|
1247
1251
|
createNodePlatformAdapter: () => createNodePlatformAdapter,
|
|
1248
1252
|
createPlatformAdapter: () => createPlatformAdapter,
|
|
@@ -1260,6 +1264,7 @@ __export(index_node_exports, {
|
|
|
1260
1264
|
fileDeletionDomain: () => fileDeletionDomain,
|
|
1261
1265
|
fileRegistrationDomain: () => fileRegistrationDomain,
|
|
1262
1266
|
generatePkceVerifier: () => generatePkceVerifier,
|
|
1267
|
+
genericPaymentDomain: () => genericPaymentDomain,
|
|
1263
1268
|
getAbi: () => getAbi,
|
|
1264
1269
|
getAllChains: () => getAllChains,
|
|
1265
1270
|
getChainConfig: () => getChainConfig,
|
|
@@ -32739,8 +32744,11 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32739
32744
|
|
|
32740
32745
|
// src/protocol/personal-server-registration.ts
|
|
32741
32746
|
var import_viem14 = require("viem");
|
|
32742
|
-
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID =
|
|
32743
|
-
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =
|
|
32747
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
|
|
32748
|
+
var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
|
|
32749
|
+
PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
|
|
32750
|
+
"DataPortabilityServers"
|
|
32751
|
+
);
|
|
32744
32752
|
function assertAddress(value, name) {
|
|
32745
32753
|
if (!(0, import_viem14.isAddress)(value)) {
|
|
32746
32754
|
throw new Error(`${name} must be a valid EVM address`);
|
|
@@ -32755,6 +32763,12 @@ function getAccountAddress(account) {
|
|
|
32755
32763
|
function isPersonalServerRegistrationSigner(source) {
|
|
32756
32764
|
return "address" in source && typeof source.signTypedData === "function";
|
|
32757
32765
|
}
|
|
32766
|
+
function getDefaultServerRegistrationContract(chainId) {
|
|
32767
|
+
return getContractAddress(
|
|
32768
|
+
chainId,
|
|
32769
|
+
"DataPortabilityServers"
|
|
32770
|
+
);
|
|
32771
|
+
}
|
|
32758
32772
|
function createViemPersonalServerRegistrationSigner(source, options = {}) {
|
|
32759
32773
|
if (isPersonalServerRegistrationSigner(source)) {
|
|
32760
32774
|
return source;
|
|
@@ -32777,12 +32791,13 @@ function personalServerRegistrationDomain(input = {}) {
|
|
|
32777
32791
|
if (input.config) {
|
|
32778
32792
|
return serverRegistrationDomain(input.config);
|
|
32779
32793
|
}
|
|
32780
|
-
const
|
|
32794
|
+
const chainId = input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;
|
|
32795
|
+
const verifyingContract = input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);
|
|
32781
32796
|
assertAddress(verifyingContract, "verifyingContract");
|
|
32782
32797
|
return {
|
|
32783
32798
|
name: "Vana Data Portability",
|
|
32784
32799
|
version: "1",
|
|
32785
|
-
chainId
|
|
32800
|
+
chainId,
|
|
32786
32801
|
verifyingContract
|
|
32787
32802
|
};
|
|
32788
32803
|
}
|
|
@@ -32820,9 +32835,9 @@ async function buildPersonalServerRegistrationSignature(input) {
|
|
|
32820
32835
|
}
|
|
32821
32836
|
var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
|
|
32822
32837
|
|
|
32823
|
-
// src/
|
|
32838
|
+
// src/personal-server-lite/owner-binding.ts
|
|
32824
32839
|
var import_viem15 = require("viem");
|
|
32825
|
-
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.
|
|
32840
|
+
var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
32826
32841
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
32827
32842
|
var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
32828
32843
|
function assertAddress2(value, name) {
|
|
@@ -33565,6 +33580,118 @@ function createGatewayClient(baseUrl) {
|
|
|
33565
33580
|
};
|
|
33566
33581
|
}
|
|
33567
33582
|
|
|
33583
|
+
// src/protocol/escrow.ts
|
|
33584
|
+
var GENERIC_PAYMENT_TYPES = {
|
|
33585
|
+
GenericPayment: [
|
|
33586
|
+
{ name: "payerAddress", type: "address" },
|
|
33587
|
+
{ name: "opType", type: "string" },
|
|
33588
|
+
{ name: "opId", type: "bytes32" },
|
|
33589
|
+
{ name: "asset", type: "address" },
|
|
33590
|
+
{ name: "amount", type: "uint256" },
|
|
33591
|
+
{ name: "paymentNonce", type: "uint256" }
|
|
33592
|
+
]
|
|
33593
|
+
};
|
|
33594
|
+
function genericPaymentDomain(chainId, escrowContract) {
|
|
33595
|
+
return {
|
|
33596
|
+
name: "Vana Data Portability",
|
|
33597
|
+
version: "1",
|
|
33598
|
+
chainId,
|
|
33599
|
+
verifyingContract: escrowContract
|
|
33600
|
+
};
|
|
33601
|
+
}
|
|
33602
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
33603
|
+
{
|
|
33604
|
+
type: "function",
|
|
33605
|
+
name: "depositNative",
|
|
33606
|
+
stateMutability: "payable",
|
|
33607
|
+
inputs: [{ name: "account", type: "address" }],
|
|
33608
|
+
outputs: []
|
|
33609
|
+
},
|
|
33610
|
+
{
|
|
33611
|
+
type: "function",
|
|
33612
|
+
name: "depositToken",
|
|
33613
|
+
stateMutability: "nonpayable",
|
|
33614
|
+
inputs: [
|
|
33615
|
+
{ name: "account", type: "address" },
|
|
33616
|
+
{ name: "token", type: "address" },
|
|
33617
|
+
{ name: "amount", type: "uint256" }
|
|
33618
|
+
],
|
|
33619
|
+
outputs: []
|
|
33620
|
+
}
|
|
33621
|
+
];
|
|
33622
|
+
var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33623
|
+
function createEscrowGatewayClient(baseUrl) {
|
|
33624
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
33625
|
+
async function throwOnError(res, context) {
|
|
33626
|
+
if (!res.ok) {
|
|
33627
|
+
let detail = "";
|
|
33628
|
+
try {
|
|
33629
|
+
const body = await res.json();
|
|
33630
|
+
if (body.error) detail = `: ${body.error}`;
|
|
33631
|
+
} catch {
|
|
33632
|
+
}
|
|
33633
|
+
throw new Error(
|
|
33634
|
+
`Escrow gateway error (${context}): ${res.status} ${res.statusText}${detail}`
|
|
33635
|
+
);
|
|
33636
|
+
}
|
|
33637
|
+
}
|
|
33638
|
+
return {
|
|
33639
|
+
async submitDeposit({ txHash }) {
|
|
33640
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33641
|
+
method: "POST",
|
|
33642
|
+
headers: { "Content-Type": "application/json" },
|
|
33643
|
+
body: JSON.stringify({ txHash })
|
|
33644
|
+
});
|
|
33645
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
33646
|
+
await throwOnError(res, "POST /v1/escrow/deposit");
|
|
33647
|
+
}
|
|
33648
|
+
return res.json();
|
|
33649
|
+
},
|
|
33650
|
+
async getEscrowBalance(account) {
|
|
33651
|
+
const res = await fetch(
|
|
33652
|
+
`${base}/v1/escrow/balance?account=${encodeURIComponent(account)}`
|
|
33653
|
+
);
|
|
33654
|
+
await throwOnError(res, "GET /v1/escrow/balance");
|
|
33655
|
+
return res.json();
|
|
33656
|
+
},
|
|
33657
|
+
async syncEscrowBalance(account) {
|
|
33658
|
+
const res = await fetch(
|
|
33659
|
+
`${base}/v1/escrow/balance/sync?account=${encodeURIComponent(account)}`,
|
|
33660
|
+
{ method: "POST" }
|
|
33661
|
+
);
|
|
33662
|
+
await throwOnError(res, "POST /v1/escrow/balance/sync");
|
|
33663
|
+
return res.json();
|
|
33664
|
+
},
|
|
33665
|
+
async payForOp({
|
|
33666
|
+
payerAddress,
|
|
33667
|
+
opType,
|
|
33668
|
+
opId,
|
|
33669
|
+
asset,
|
|
33670
|
+
amount,
|
|
33671
|
+
paymentNonce,
|
|
33672
|
+
signature
|
|
33673
|
+
}) {
|
|
33674
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33675
|
+
method: "POST",
|
|
33676
|
+
headers: {
|
|
33677
|
+
"Content-Type": "application/json",
|
|
33678
|
+
Authorization: `Web3Signed ${signature}`
|
|
33679
|
+
},
|
|
33680
|
+
body: JSON.stringify({
|
|
33681
|
+
payerAddress,
|
|
33682
|
+
opType,
|
|
33683
|
+
opId,
|
|
33684
|
+
asset,
|
|
33685
|
+
amount,
|
|
33686
|
+
paymentNonce
|
|
33687
|
+
})
|
|
33688
|
+
});
|
|
33689
|
+
await throwOnError(res, "POST /v1/escrow/pay");
|
|
33690
|
+
return res.json();
|
|
33691
|
+
}
|
|
33692
|
+
};
|
|
33693
|
+
}
|
|
33694
|
+
|
|
33568
33695
|
// src/types/ps-errors.ts
|
|
33569
33696
|
var PSError = class extends Error {
|
|
33570
33697
|
constructor(code, message) {
|
|
@@ -33642,9 +33769,11 @@ async function parsePSError(response) {
|
|
|
33642
33769
|
DataFileEnvelopeSchema,
|
|
33643
33770
|
DropboxStorage,
|
|
33644
33771
|
ECIESError,
|
|
33772
|
+
ESCROW_DEPOSIT_ABI,
|
|
33645
33773
|
ExpiredTokenError,
|
|
33646
33774
|
FILE_DELETION_TYPES,
|
|
33647
33775
|
FILE_REGISTRATION_TYPES,
|
|
33776
|
+
GENERIC_PAYMENT_TYPES,
|
|
33648
33777
|
GRANT_REGISTRATION_TYPES,
|
|
33649
33778
|
GRANT_REVOCATION_TYPES,
|
|
33650
33779
|
GoogleDriveStorage,
|
|
@@ -33655,6 +33784,7 @@ async function parsePSError(response) {
|
|
|
33655
33784
|
IpfsStorage,
|
|
33656
33785
|
MASTER_KEY_MESSAGE,
|
|
33657
33786
|
MissingAuthError,
|
|
33787
|
+
NATIVE_ASSET_ADDRESS,
|
|
33658
33788
|
NetworkError,
|
|
33659
33789
|
NodeECIESProvider,
|
|
33660
33790
|
NodePlatformAdapter,
|
|
@@ -33699,6 +33829,7 @@ async function parsePSError(response) {
|
|
|
33699
33829
|
contractCacheForTesting,
|
|
33700
33830
|
createBrowserPlatformAdapter,
|
|
33701
33831
|
createDataFileEnvelope,
|
|
33832
|
+
createEscrowGatewayClient,
|
|
33702
33833
|
createGatewayClient,
|
|
33703
33834
|
createNodePlatformAdapter,
|
|
33704
33835
|
createPlatformAdapter,
|
|
@@ -33716,6 +33847,7 @@ async function parsePSError(response) {
|
|
|
33716
33847
|
fileDeletionDomain,
|
|
33717
33848
|
fileRegistrationDomain,
|
|
33718
33849
|
generatePkceVerifier,
|
|
33850
|
+
genericPaymentDomain,
|
|
33719
33851
|
getAbi,
|
|
33720
33852
|
getAllChains,
|
|
33721
33853
|
getChainConfig,
|