@opendatalabs/vana-sdk 3.2.0-canary.e3ef84a → 3.3.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/index.browser.d.ts +3 -4
- package/dist/index.browser.js +85 -245
- package/dist/index.browser.js.map +3 -3
- package/dist/index.node.cjs +88 -257
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +3 -4
- package/dist/index.node.js +85 -245
- package/dist/index.node.js.map +3 -3
- package/dist/protocol/eip712.cjs +14 -53
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +25 -97
- package/dist/protocol/eip712.js +12 -47
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/gateway.cjs +10 -115
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +29 -196
- package/dist/protocol/gateway.js +10 -115
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +64 -24
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +13 -6
- package/dist/protocol/grants.js +63 -24
- package/dist/protocol/grants.js.map +1 -1
- package/package.json +2 -3
- package/dist/protocol/escrow-deposit.cjs +0 -89
- package/dist/protocol/escrow-deposit.cjs.map +0 -1
- package/dist/protocol/escrow-deposit.d.ts +0 -47
- package/dist/protocol/escrow-deposit.js +0 -60
- package/dist/protocol/escrow-deposit.js.map +0 -1
- package/dist/protocol/escrow-deposit.test.d.ts +0 -1
- package/dist/protocol/escrow-flow.test.d.ts +0 -21
package/dist/index.browser.d.ts
CHANGED
|
@@ -35,14 +35,13 @@ export { encryptWithPassword, decryptWithPassword, } from "./crypto/envelope/ope
|
|
|
35
35
|
export { parseWeb3SignedHeader, verifyWeb3Signed, type Web3SignedPayload, type VerifiedAuth, } from "./auth/web3-signed";
|
|
36
36
|
export { buildWeb3SignedHeader, computeBodyHash, type Web3SignedSignFn, } from "./auth/web3-signed-builder";
|
|
37
37
|
export { MissingAuthError, InvalidSignatureError, ExpiredTokenError, } from "./auth/errors";
|
|
38
|
-
export { fileRegistrationDomain, grantRegistrationDomain, grantRevocationDomain, serverRegistrationDomain, builderRegistrationDomain,
|
|
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
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
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
|
-
export { isDataPortabilityGatewayConfig, verifyGrantRegistration, type VerifyGrantRegistrationInput, type VerifyGrantRegistrationResult, } from "./protocol/grants";
|
|
44
|
-
export { ESCROW_DEPOSIT_ABI, escrowContractAddress, encodeDepositNativeData, encodeDepositTokenData, buildDepositNativeRequest, buildDepositTokenRequest, type DepositNativeInput, type DepositTokenInput, type DepositTransactionRequest, } from "./protocol/escrow-deposit";
|
|
43
|
+
export { isDataPortabilityGatewayConfig, parseGrantRegistrationPayload, verifyGrantRegistration, type DataPortabilityGrantPayload, type VerifyGrantRegistrationInput, type VerifyGrantRegistrationResult, } from "./protocol/grants";
|
|
45
44
|
export { ScopeSchema, parseScope, scopeToPathSegments, scopeMatchesPattern, scopeCoveredByGrant, type Scope, type ParsedScope, } from "./protocol/scopes";
|
|
46
45
|
export { DataFileEnvelopeSchema, createDataFileEnvelope, IngestResponseSchema, type DataFileEnvelope, type IngestResponse, } from "./protocol/data-file";
|
|
47
|
-
export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type GatewayGrantResponse, type
|
|
46
|
+
export { createGatewayClient, type GatewayEnvelope, type GatewayProof, type Builder, type Schema, type ServerInfo, type GatewayGrantResponse, type GrantListItem, type FileRecord, type FileListResult, type RegisterServerParams, type RegisterServerResult, type RegisterFileParams, type CreateGrantParams, type RevokeGrantParams, type DeleteFileParams, type GatewayClient, } from "./protocol/gateway";
|
|
48
47
|
export { PSError, parsePSError, type PSErrorCode } from "./types/ps-errors";
|
package/dist/index.browser.js
CHANGED
|
@@ -31882,7 +31882,6 @@ async function verifyWeb3Signed(params) {
|
|
|
31882
31882
|
// src/protocol/eip712.ts
|
|
31883
31883
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
31884
31884
|
var DOMAIN_VERSION = "1";
|
|
31885
|
-
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
31886
31885
|
function buildDomain(chainId, verifyingContract) {
|
|
31887
31886
|
return {
|
|
31888
31887
|
name: DOMAIN_NAME,
|
|
@@ -31897,7 +31896,7 @@ function fileRegistrationDomain(config) {
|
|
|
31897
31896
|
config.contracts.dataRegistry
|
|
31898
31897
|
);
|
|
31899
31898
|
}
|
|
31900
|
-
function
|
|
31899
|
+
function fileDeletionDomain(config) {
|
|
31901
31900
|
return buildDomain(
|
|
31902
31901
|
config.chainId,
|
|
31903
31902
|
config.contracts.dataRegistry
|
|
@@ -31927,12 +31926,6 @@ function builderRegistrationDomain(config) {
|
|
|
31927
31926
|
config.contracts.dataPortabilityGrantees
|
|
31928
31927
|
);
|
|
31929
31928
|
}
|
|
31930
|
-
function escrowPaymentDomain(config) {
|
|
31931
|
-
return buildDomain(
|
|
31932
|
-
config.chainId,
|
|
31933
|
-
config.contracts.dataPortabilityEscrow
|
|
31934
|
-
);
|
|
31935
|
-
}
|
|
31936
31929
|
var FILE_REGISTRATION_TYPES = {
|
|
31937
31930
|
FileRegistration: [
|
|
31938
31931
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -31940,20 +31933,24 @@ var FILE_REGISTRATION_TYPES = {
|
|
|
31940
31933
|
{ name: "schemaId", type: "bytes32" }
|
|
31941
31934
|
]
|
|
31942
31935
|
};
|
|
31936
|
+
var FILE_DELETION_TYPES = {
|
|
31937
|
+
FileDeletion: [
|
|
31938
|
+
{ name: "ownerAddress", type: "address" },
|
|
31939
|
+
{ name: "fileId", type: "bytes32" }
|
|
31940
|
+
]
|
|
31941
|
+
};
|
|
31943
31942
|
var GRANT_REGISTRATION_TYPES = {
|
|
31944
31943
|
GrantRegistration: [
|
|
31945
31944
|
{ name: "grantorAddress", type: "address" },
|
|
31946
31945
|
{ name: "granteeId", type: "bytes32" },
|
|
31947
|
-
{ name: "
|
|
31948
|
-
{ name: "
|
|
31949
|
-
{ name: "expiresAt", type: "uint256" }
|
|
31946
|
+
{ name: "grant", type: "string" },
|
|
31947
|
+
{ name: "fileIds", type: "uint256[]" }
|
|
31950
31948
|
]
|
|
31951
31949
|
};
|
|
31952
31950
|
var GRANT_REVOCATION_TYPES = {
|
|
31953
31951
|
GrantRevocation: [
|
|
31954
31952
|
{ name: "grantorAddress", type: "address" },
|
|
31955
|
-
{ name: "grantId", type: "bytes32" }
|
|
31956
|
-
{ name: "grantVersion", type: "uint256" }
|
|
31953
|
+
{ name: "grantId", type: "bytes32" }
|
|
31957
31954
|
]
|
|
31958
31955
|
};
|
|
31959
31956
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -31972,34 +31969,6 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
31972
31969
|
{ name: "appUrl", type: "string" }
|
|
31973
31970
|
]
|
|
31974
31971
|
};
|
|
31975
|
-
var GENERIC_PAYMENT_TYPES = {
|
|
31976
|
-
GenericPayment: [
|
|
31977
|
-
{ name: "payerAddress", type: "address" },
|
|
31978
|
-
{ name: "opType", type: "string" },
|
|
31979
|
-
{ name: "opId", type: "bytes32" },
|
|
31980
|
-
{ name: "asset", type: "address" },
|
|
31981
|
-
{ name: "amount", type: "uint256" },
|
|
31982
|
-
{ name: "paymentNonce", type: "uint256" }
|
|
31983
|
-
]
|
|
31984
|
-
};
|
|
31985
|
-
var ADD_DATA_TYPES = {
|
|
31986
|
-
AddData: [
|
|
31987
|
-
{ name: "ownerAddress", type: "address" },
|
|
31988
|
-
{ name: "scope", type: "string" },
|
|
31989
|
-
{ name: "dataHash", type: "bytes32" },
|
|
31990
|
-
{ name: "metadataHash", type: "bytes32" },
|
|
31991
|
-
{ name: "expectedVersion", type: "uint256" }
|
|
31992
|
-
]
|
|
31993
|
-
};
|
|
31994
|
-
var RECORD_DATA_ACCESS_TYPES = {
|
|
31995
|
-
RecordDataAccess: [
|
|
31996
|
-
{ name: "ownerAddress", type: "address" },
|
|
31997
|
-
{ name: "scope", type: "string" },
|
|
31998
|
-
{ name: "version", type: "uint256" },
|
|
31999
|
-
{ name: "accessor", type: "address" },
|
|
32000
|
-
{ name: "recordId", type: "bytes32" }
|
|
32001
|
-
]
|
|
32002
|
-
};
|
|
32003
31972
|
|
|
32004
31973
|
// src/protocol/personal-server-registration.ts
|
|
32005
31974
|
import {
|
|
@@ -32441,31 +32410,67 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
32441
32410
|
return false;
|
|
32442
32411
|
}
|
|
32443
32412
|
const c = contracts;
|
|
32444
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"])
|
|
32413
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
32445
32414
|
}
|
|
32446
|
-
function
|
|
32415
|
+
function parseGrantRegistrationPayload(grant) {
|
|
32416
|
+
let parsed;
|
|
32447
32417
|
try {
|
|
32448
|
-
|
|
32449
|
-
if (big < 0n) return null;
|
|
32450
|
-
return big;
|
|
32418
|
+
parsed = JSON.parse(grant);
|
|
32451
32419
|
} catch {
|
|
32452
32420
|
return null;
|
|
32453
32421
|
}
|
|
32454
|
-
|
|
32455
|
-
|
|
32456
|
-
|
|
32457
|
-
|
|
32422
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
32423
|
+
return null;
|
|
32424
|
+
}
|
|
32425
|
+
const value = parsed;
|
|
32426
|
+
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
32427
|
+
return null;
|
|
32428
|
+
}
|
|
32429
|
+
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
32430
|
+
return null;
|
|
32431
|
+
}
|
|
32432
|
+
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
32433
|
+
return null;
|
|
32458
32434
|
}
|
|
32459
|
-
if (
|
|
32460
|
-
return
|
|
32435
|
+
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
32436
|
+
return null;
|
|
32437
|
+
}
|
|
32438
|
+
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
32439
|
+
return null;
|
|
32440
|
+
}
|
|
32441
|
+
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
32442
|
+
return null;
|
|
32443
|
+
}
|
|
32444
|
+
return {
|
|
32445
|
+
user: value["user"],
|
|
32446
|
+
builder: value["builder"],
|
|
32447
|
+
scopes: value["scopes"],
|
|
32448
|
+
expiresAt: value["expiresAt"],
|
|
32449
|
+
nonce: value["nonce"]
|
|
32450
|
+
};
|
|
32451
|
+
}
|
|
32452
|
+
function parseFileIds(fileIds) {
|
|
32453
|
+
try {
|
|
32454
|
+
const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
|
|
32455
|
+
return {
|
|
32456
|
+
values,
|
|
32457
|
+
display: values.map((fileId) => fileId.toString())
|
|
32458
|
+
};
|
|
32459
|
+
} catch {
|
|
32460
|
+
return null;
|
|
32461
32461
|
}
|
|
32462
|
-
|
|
32463
|
-
|
|
32464
|
-
|
|
32462
|
+
}
|
|
32463
|
+
async function verifyGrantRegistration(input) {
|
|
32464
|
+
const payload = parseGrantRegistrationPayload(input.grant);
|
|
32465
|
+
if (!payload) {
|
|
32466
|
+
return {
|
|
32467
|
+
valid: false,
|
|
32468
|
+
error: "Grant must be JSON with scopes and expiresAt"
|
|
32469
|
+
};
|
|
32465
32470
|
}
|
|
32466
|
-
const
|
|
32467
|
-
if (
|
|
32468
|
-
return { valid: false, error: "
|
|
32471
|
+
const fileIds = parseFileIds(input.fileIds);
|
|
32472
|
+
if (!fileIds) {
|
|
32473
|
+
return { valid: false, error: "fileIds must contain integer values" };
|
|
32469
32474
|
}
|
|
32470
32475
|
let valid;
|
|
32471
32476
|
try {
|
|
@@ -32477,9 +32482,8 @@ async function verifyGrantRegistration(input) {
|
|
|
32477
32482
|
message: {
|
|
32478
32483
|
grantorAddress: input.grantorAddress,
|
|
32479
32484
|
granteeId: input.granteeId,
|
|
32480
|
-
|
|
32481
|
-
|
|
32482
|
-
expiresAt
|
|
32485
|
+
grant: input.grant,
|
|
32486
|
+
fileIds: fileIds.values
|
|
32483
32487
|
},
|
|
32484
32488
|
signature: input.signature
|
|
32485
32489
|
});
|
|
@@ -32490,69 +32494,19 @@ async function verifyGrantRegistration(input) {
|
|
|
32490
32494
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
32491
32495
|
}
|
|
32492
32496
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
32493
|
-
if (expiresAt >
|
|
32497
|
+
if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
|
|
32494
32498
|
return { valid: false, error: "Grant has expired" };
|
|
32495
32499
|
}
|
|
32500
|
+
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
32501
|
+
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
32502
|
+
}
|
|
32496
32503
|
return {
|
|
32497
32504
|
valid: true,
|
|
32498
32505
|
grantorAddress: input.grantorAddress,
|
|
32499
32506
|
granteeId: input.granteeId,
|
|
32500
|
-
|
|
32501
|
-
|
|
32502
|
-
|
|
32503
|
-
};
|
|
32504
|
-
}
|
|
32505
|
-
|
|
32506
|
-
// src/protocol/escrow-deposit.ts
|
|
32507
|
-
import { encodeFunctionData } from "viem";
|
|
32508
|
-
var ESCROW_DEPOSIT_ABI = [
|
|
32509
|
-
{
|
|
32510
|
-
type: "function",
|
|
32511
|
-
name: "depositNative",
|
|
32512
|
-
stateMutability: "payable",
|
|
32513
|
-
inputs: [{ name: "account", type: "address" }],
|
|
32514
|
-
outputs: []
|
|
32515
|
-
},
|
|
32516
|
-
{
|
|
32517
|
-
type: "function",
|
|
32518
|
-
name: "depositToken",
|
|
32519
|
-
stateMutability: "nonpayable",
|
|
32520
|
-
inputs: [
|
|
32521
|
-
{ name: "account", type: "address" },
|
|
32522
|
-
{ name: "token", type: "address" },
|
|
32523
|
-
{ name: "amount", type: "uint256" }
|
|
32524
|
-
],
|
|
32525
|
-
outputs: []
|
|
32526
|
-
}
|
|
32527
|
-
];
|
|
32528
|
-
function escrowContractAddress(config) {
|
|
32529
|
-
return config.contracts.dataPortabilityEscrow;
|
|
32530
|
-
}
|
|
32531
|
-
function encodeDepositNativeData(input) {
|
|
32532
|
-
return encodeFunctionData({
|
|
32533
|
-
abi: ESCROW_DEPOSIT_ABI,
|
|
32534
|
-
functionName: "depositNative",
|
|
32535
|
-
args: [input.account]
|
|
32536
|
-
});
|
|
32537
|
-
}
|
|
32538
|
-
function encodeDepositTokenData(input) {
|
|
32539
|
-
return encodeFunctionData({
|
|
32540
|
-
abi: ESCROW_DEPOSIT_ABI,
|
|
32541
|
-
functionName: "depositToken",
|
|
32542
|
-
args: [input.account, input.token, input.amount]
|
|
32543
|
-
});
|
|
32544
|
-
}
|
|
32545
|
-
function buildDepositNativeRequest(config, input) {
|
|
32546
|
-
return {
|
|
32547
|
-
to: escrowContractAddress(config),
|
|
32548
|
-
data: encodeDepositNativeData({ account: input.account }),
|
|
32549
|
-
value: input.amount
|
|
32550
|
-
};
|
|
32551
|
-
}
|
|
32552
|
-
function buildDepositTokenRequest(config, input) {
|
|
32553
|
-
return {
|
|
32554
|
-
to: escrowContractAddress(config),
|
|
32555
|
-
data: encodeDepositTokenData(input)
|
|
32507
|
+
grant: input.grant,
|
|
32508
|
+
payload,
|
|
32509
|
+
fileIds: fileIds.display
|
|
32556
32510
|
};
|
|
32557
32511
|
}
|
|
32558
32512
|
|
|
@@ -32752,68 +32706,6 @@ function createGatewayClient(baseUrl) {
|
|
|
32752
32706
|
alreadyRegistered: false
|
|
32753
32707
|
};
|
|
32754
32708
|
},
|
|
32755
|
-
async registerBuilder(params) {
|
|
32756
|
-
const res = await fetch(`${base}/v1/builders`, {
|
|
32757
|
-
method: "POST",
|
|
32758
|
-
headers: {
|
|
32759
|
-
"Content-Type": "application/json",
|
|
32760
|
-
Authorization: `Web3Signed ${params.signature}`
|
|
32761
|
-
},
|
|
32762
|
-
body: JSON.stringify({
|
|
32763
|
-
ownerAddress: params.ownerAddress,
|
|
32764
|
-
granteeAddress: params.granteeAddress,
|
|
32765
|
-
publicKey: params.publicKey,
|
|
32766
|
-
appUrl: params.appUrl
|
|
32767
|
-
})
|
|
32768
|
-
});
|
|
32769
|
-
if (res.status === 409) {
|
|
32770
|
-
const body2 = await res.json().catch(() => ({}));
|
|
32771
|
-
return {
|
|
32772
|
-
builderId: getMutationId(
|
|
32773
|
-
body2,
|
|
32774
|
-
"builderId"
|
|
32775
|
-
),
|
|
32776
|
-
alreadyRegistered: true
|
|
32777
|
-
};
|
|
32778
|
-
}
|
|
32779
|
-
if (!res.ok) {
|
|
32780
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32781
|
-
}
|
|
32782
|
-
const body = await res.json().catch(() => ({}));
|
|
32783
|
-
return {
|
|
32784
|
-
builderId: getMutationId(body, "builderId"),
|
|
32785
|
-
alreadyRegistered: false
|
|
32786
|
-
};
|
|
32787
|
-
},
|
|
32788
|
-
async registerDataPoint(params) {
|
|
32789
|
-
const res = await fetch(`${base}/v1/data`, {
|
|
32790
|
-
method: "POST",
|
|
32791
|
-
headers: {
|
|
32792
|
-
"Content-Type": "application/json",
|
|
32793
|
-
Authorization: `Web3Signed ${params.signature}`
|
|
32794
|
-
},
|
|
32795
|
-
body: JSON.stringify({
|
|
32796
|
-
ownerAddress: params.ownerAddress,
|
|
32797
|
-
scope: params.scope,
|
|
32798
|
-
dataHash: params.dataHash,
|
|
32799
|
-
metadataHash: params.metadataHash,
|
|
32800
|
-
expectedVersion: params.expectedVersion
|
|
32801
|
-
})
|
|
32802
|
-
});
|
|
32803
|
-
if (!res.ok) {
|
|
32804
|
-
const body2 = await res.json().catch(() => ({}));
|
|
32805
|
-
const detail = body2.error ?? res.statusText;
|
|
32806
|
-
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
32807
|
-
}
|
|
32808
|
-
const body = await res.json().catch(() => ({}));
|
|
32809
|
-
return {
|
|
32810
|
-
dataPointId: getMutationId(
|
|
32811
|
-
body,
|
|
32812
|
-
"dataPointId"
|
|
32813
|
-
),
|
|
32814
|
-
expectedVersion: body.expectedVersion
|
|
32815
|
-
};
|
|
32816
|
-
},
|
|
32817
32709
|
async registerFile(params) {
|
|
32818
32710
|
const res = await fetch(`${base}/v1/files`, {
|
|
32819
32711
|
method: "POST",
|
|
@@ -32851,9 +32743,8 @@ function createGatewayClient(baseUrl) {
|
|
|
32851
32743
|
body: JSON.stringify({
|
|
32852
32744
|
grantorAddress: params.grantorAddress,
|
|
32853
32745
|
granteeId: params.granteeId,
|
|
32854
|
-
|
|
32855
|
-
|
|
32856
|
-
expiresAt: params.expiresAt
|
|
32746
|
+
grant: params.grant,
|
|
32747
|
+
fileIds: params.fileIds
|
|
32857
32748
|
})
|
|
32858
32749
|
});
|
|
32859
32750
|
if (res.status === 409) {
|
|
@@ -32878,8 +32769,7 @@ function createGatewayClient(baseUrl) {
|
|
|
32878
32769
|
Authorization: `Web3Signed ${params.signature}`
|
|
32879
32770
|
},
|
|
32880
32771
|
body: JSON.stringify({
|
|
32881
|
-
grantorAddress: params.grantorAddress
|
|
32882
|
-
grantVersion: params.grantVersion
|
|
32772
|
+
grantorAddress: params.grantorAddress
|
|
32883
32773
|
})
|
|
32884
32774
|
});
|
|
32885
32775
|
if (res.status === 409) return;
|
|
@@ -32887,62 +32777,21 @@ function createGatewayClient(baseUrl) {
|
|
|
32887
32777
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32888
32778
|
}
|
|
32889
32779
|
},
|
|
32890
|
-
async
|
|
32891
|
-
const res = await fetch(`${base}/v1/
|
|
32892
|
-
|
|
32893
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32894
|
-
}
|
|
32895
|
-
return await res.json();
|
|
32896
|
-
},
|
|
32897
|
-
async submitEscrowDeposit(params) {
|
|
32898
|
-
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
32899
|
-
method: "POST",
|
|
32900
|
-
headers: { "Content-Type": "application/json" },
|
|
32901
|
-
body: JSON.stringify({ txHash: params.txHash })
|
|
32902
|
-
});
|
|
32903
|
-
if (res.status !== 200 && res.status !== 202) {
|
|
32904
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32905
|
-
}
|
|
32906
|
-
return await res.json();
|
|
32907
|
-
},
|
|
32908
|
-
async payForOperation(params) {
|
|
32909
|
-
const body = {
|
|
32910
|
-
payerAddress: params.payerAddress,
|
|
32911
|
-
opType: params.opType,
|
|
32912
|
-
opId: params.opId,
|
|
32913
|
-
asset: params.asset,
|
|
32914
|
-
amount: params.amount,
|
|
32915
|
-
paymentNonce: params.paymentNonce
|
|
32916
|
-
};
|
|
32917
|
-
if (params.accessRecord) {
|
|
32918
|
-
body["accessRecord"] = params.accessRecord;
|
|
32919
|
-
}
|
|
32920
|
-
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
32921
|
-
method: "POST",
|
|
32780
|
+
async deleteFile(params) {
|
|
32781
|
+
const res = await fetch(`${base}/v1/files/${params.fileId}`, {
|
|
32782
|
+
method: "DELETE",
|
|
32922
32783
|
headers: {
|
|
32923
32784
|
"Content-Type": "application/json",
|
|
32924
32785
|
Authorization: `Web3Signed ${params.signature}`
|
|
32925
32786
|
},
|
|
32926
|
-
body: JSON.stringify(
|
|
32927
|
-
|
|
32928
|
-
|
|
32929
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32930
|
-
}
|
|
32931
|
-
return await res.json();
|
|
32932
|
-
},
|
|
32933
|
-
async settle(params) {
|
|
32934
|
-
const res = await fetch(`${base}/v1/settle`, {
|
|
32935
|
-
method: "POST",
|
|
32936
|
-
headers: { "Content-Type": "application/json" },
|
|
32937
|
-
// The gateway accepts an empty body; only `limit` is recognised.
|
|
32938
|
-
// Always send a JSON body so the gateway's req.body shape parse
|
|
32939
|
-
// doesn't have to deal with an undefined.
|
|
32940
|
-
body: JSON.stringify(params ?? {})
|
|
32787
|
+
body: JSON.stringify({
|
|
32788
|
+
ownerAddress: params.ownerAddress
|
|
32789
|
+
})
|
|
32941
32790
|
});
|
|
32791
|
+
if (res.status === 409) return;
|
|
32942
32792
|
if (!res.ok) {
|
|
32943
32793
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
32944
32794
|
}
|
|
32945
|
-
return await res.json();
|
|
32946
32795
|
}
|
|
32947
32796
|
};
|
|
32948
32797
|
}
|
|
@@ -33011,7 +32860,6 @@ async function parsePSError(response) {
|
|
|
33011
32860
|
}
|
|
33012
32861
|
export {
|
|
33013
32862
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33014
|
-
ADD_DATA_TYPES,
|
|
33015
32863
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33016
32864
|
AccountPersonalServerRegistrationError,
|
|
33017
32865
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33025,10 +32873,9 @@ export {
|
|
|
33025
32873
|
DataFileEnvelopeSchema,
|
|
33026
32874
|
DropboxStorage,
|
|
33027
32875
|
ECIESError,
|
|
33028
|
-
ESCROW_DEPOSIT_ABI,
|
|
33029
32876
|
ExpiredTokenError,
|
|
32877
|
+
FILE_DELETION_TYPES,
|
|
33030
32878
|
FILE_REGISTRATION_TYPES,
|
|
33031
|
-
GENERIC_PAYMENT_TYPES,
|
|
33032
32879
|
GRANT_REGISTRATION_TYPES,
|
|
33033
32880
|
GRANT_REVOCATION_TYPES,
|
|
33034
32881
|
GoogleDriveStorage,
|
|
@@ -33039,7 +32886,6 @@ export {
|
|
|
33039
32886
|
IpfsStorage,
|
|
33040
32887
|
MASTER_KEY_MESSAGE,
|
|
33041
32888
|
MissingAuthError,
|
|
33042
|
-
NATIVE_VANA_ASSET,
|
|
33043
32889
|
NetworkError,
|
|
33044
32890
|
NonceError,
|
|
33045
32891
|
OAuthClient,
|
|
@@ -33055,7 +32901,6 @@ export {
|
|
|
33055
32901
|
PersonalServerError,
|
|
33056
32902
|
PinataStorage,
|
|
33057
32903
|
R2Storage,
|
|
33058
|
-
RECORD_DATA_ACCESS_TYPES,
|
|
33059
32904
|
ReadOnlyError,
|
|
33060
32905
|
RelayerError,
|
|
33061
32906
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33070,8 +32915,6 @@ export {
|
|
|
33070
32915
|
VanaError,
|
|
33071
32916
|
VanaStorage,
|
|
33072
32917
|
assertValidPkceVerifier,
|
|
33073
|
-
buildDepositNativeRequest,
|
|
33074
|
-
buildDepositTokenRequest,
|
|
33075
32918
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33076
32919
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33077
32920
|
buildPersonalServerRegistrationSignature,
|
|
@@ -33090,17 +32933,13 @@ export {
|
|
|
33090
32933
|
createVanaStorageProvider,
|
|
33091
32934
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33092
32935
|
createViemPersonalServerRegistrationSigner,
|
|
33093
|
-
dataRegistryDomain,
|
|
33094
32936
|
decryptWithPassword,
|
|
33095
32937
|
deriveMasterKey,
|
|
33096
32938
|
deriveScopeKey,
|
|
33097
32939
|
deserializeECIES,
|
|
33098
32940
|
detectPlatform,
|
|
33099
|
-
encodeDepositNativeData,
|
|
33100
|
-
encodeDepositTokenData,
|
|
33101
32941
|
encryptWithPassword,
|
|
33102
|
-
|
|
33103
|
-
escrowPaymentDomain,
|
|
32942
|
+
fileDeletionDomain,
|
|
33104
32943
|
fileRegistrationDomain,
|
|
33105
32944
|
generatePkceVerifier,
|
|
33106
32945
|
getAbi,
|
|
@@ -33120,6 +32959,7 @@ export {
|
|
|
33120
32959
|
moksha,
|
|
33121
32960
|
mokshaServices,
|
|
33122
32961
|
mokshaTestnet2 as mokshaTestnet,
|
|
32962
|
+
parseGrantRegistrationPayload,
|
|
33123
32963
|
parsePSError,
|
|
33124
32964
|
parseScope,
|
|
33125
32965
|
parseWeb3SignedHeader,
|