@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.node.d.ts
CHANGED
|
@@ -35,14 +35,13 @@ export { MissingAuthError, InvalidSignatureError, ExpiredTokenError, } from "./a
|
|
|
35
35
|
export { generatePkceVerifier, computePkceChallenge, verifyPkceChallenge, assertValidPkceVerifier, PKCE_VERIFIER_PATTERN, PKCE_CHALLENGE_PATTERN, } from "./auth/pkce";
|
|
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
|
-
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.node.js
CHANGED
|
@@ -32509,7 +32509,6 @@ 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";
|
|
32513
32512
|
function buildDomain(chainId, verifyingContract) {
|
|
32514
32513
|
return {
|
|
32515
32514
|
name: DOMAIN_NAME,
|
|
@@ -32524,7 +32523,7 @@ function fileRegistrationDomain(config) {
|
|
|
32524
32523
|
config.contracts.dataRegistry
|
|
32525
32524
|
);
|
|
32526
32525
|
}
|
|
32527
|
-
function
|
|
32526
|
+
function fileDeletionDomain(config) {
|
|
32528
32527
|
return buildDomain(
|
|
32529
32528
|
config.chainId,
|
|
32530
32529
|
config.contracts.dataRegistry
|
|
@@ -32554,12 +32553,6 @@ function builderRegistrationDomain(config) {
|
|
|
32554
32553
|
config.contracts.dataPortabilityGrantees
|
|
32555
32554
|
);
|
|
32556
32555
|
}
|
|
32557
|
-
function escrowPaymentDomain(config) {
|
|
32558
|
-
return buildDomain(
|
|
32559
|
-
config.chainId,
|
|
32560
|
-
config.contracts.dataPortabilityEscrow
|
|
32561
|
-
);
|
|
32562
|
-
}
|
|
32563
32556
|
var FILE_REGISTRATION_TYPES = {
|
|
32564
32557
|
FileRegistration: [
|
|
32565
32558
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -32567,20 +32560,24 @@ var FILE_REGISTRATION_TYPES = {
|
|
|
32567
32560
|
{ name: "schemaId", type: "bytes32" }
|
|
32568
32561
|
]
|
|
32569
32562
|
};
|
|
32563
|
+
var FILE_DELETION_TYPES = {
|
|
32564
|
+
FileDeletion: [
|
|
32565
|
+
{ name: "ownerAddress", type: "address" },
|
|
32566
|
+
{ name: "fileId", type: "bytes32" }
|
|
32567
|
+
]
|
|
32568
|
+
};
|
|
32570
32569
|
var GRANT_REGISTRATION_TYPES = {
|
|
32571
32570
|
GrantRegistration: [
|
|
32572
32571
|
{ name: "grantorAddress", type: "address" },
|
|
32573
32572
|
{ name: "granteeId", type: "bytes32" },
|
|
32574
|
-
{ name: "
|
|
32575
|
-
{ name: "
|
|
32576
|
-
{ name: "expiresAt", type: "uint256" }
|
|
32573
|
+
{ name: "grant", type: "string" },
|
|
32574
|
+
{ name: "fileIds", type: "uint256[]" }
|
|
32577
32575
|
]
|
|
32578
32576
|
};
|
|
32579
32577
|
var GRANT_REVOCATION_TYPES = {
|
|
32580
32578
|
GrantRevocation: [
|
|
32581
32579
|
{ name: "grantorAddress", type: "address" },
|
|
32582
|
-
{ name: "grantId", type: "bytes32" }
|
|
32583
|
-
{ name: "grantVersion", type: "uint256" }
|
|
32580
|
+
{ name: "grantId", type: "bytes32" }
|
|
32584
32581
|
]
|
|
32585
32582
|
};
|
|
32586
32583
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32599,34 +32596,6 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32599
32596
|
{ name: "appUrl", type: "string" }
|
|
32600
32597
|
]
|
|
32601
32598
|
};
|
|
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
|
-
};
|
|
32630
32599
|
|
|
32631
32600
|
// src/protocol/personal-server-registration.ts
|
|
32632
32601
|
import {
|
|
@@ -33068,31 +33037,67 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
33068
33037
|
return false;
|
|
33069
33038
|
}
|
|
33070
33039
|
const c = contracts;
|
|
33071
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"])
|
|
33040
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
33072
33041
|
}
|
|
33073
|
-
function
|
|
33042
|
+
function parseGrantRegistrationPayload(grant) {
|
|
33043
|
+
let parsed;
|
|
33074
33044
|
try {
|
|
33075
|
-
|
|
33076
|
-
if (big < 0n) return null;
|
|
33077
|
-
return big;
|
|
33045
|
+
parsed = JSON.parse(grant);
|
|
33078
33046
|
} catch {
|
|
33079
33047
|
return null;
|
|
33080
33048
|
}
|
|
33081
|
-
|
|
33082
|
-
|
|
33083
|
-
|
|
33084
|
-
|
|
33049
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33050
|
+
return null;
|
|
33051
|
+
}
|
|
33052
|
+
const value = parsed;
|
|
33053
|
+
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
33054
|
+
return null;
|
|
33055
|
+
}
|
|
33056
|
+
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
33057
|
+
return null;
|
|
33058
|
+
}
|
|
33059
|
+
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
33060
|
+
return null;
|
|
33085
33061
|
}
|
|
33086
|
-
if (
|
|
33087
|
-
return
|
|
33062
|
+
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
33063
|
+
return null;
|
|
33064
|
+
}
|
|
33065
|
+
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
33066
|
+
return null;
|
|
33067
|
+
}
|
|
33068
|
+
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
33069
|
+
return null;
|
|
33070
|
+
}
|
|
33071
|
+
return {
|
|
33072
|
+
user: value["user"],
|
|
33073
|
+
builder: value["builder"],
|
|
33074
|
+
scopes: value["scopes"],
|
|
33075
|
+
expiresAt: value["expiresAt"],
|
|
33076
|
+
nonce: value["nonce"]
|
|
33077
|
+
};
|
|
33078
|
+
}
|
|
33079
|
+
function parseFileIds(fileIds) {
|
|
33080
|
+
try {
|
|
33081
|
+
const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
|
|
33082
|
+
return {
|
|
33083
|
+
values,
|
|
33084
|
+
display: values.map((fileId) => fileId.toString())
|
|
33085
|
+
};
|
|
33086
|
+
} catch {
|
|
33087
|
+
return null;
|
|
33088
33088
|
}
|
|
33089
|
-
|
|
33090
|
-
|
|
33091
|
-
|
|
33089
|
+
}
|
|
33090
|
+
async function verifyGrantRegistration(input) {
|
|
33091
|
+
const payload = parseGrantRegistrationPayload(input.grant);
|
|
33092
|
+
if (!payload) {
|
|
33093
|
+
return {
|
|
33094
|
+
valid: false,
|
|
33095
|
+
error: "Grant must be JSON with scopes and expiresAt"
|
|
33096
|
+
};
|
|
33092
33097
|
}
|
|
33093
|
-
const
|
|
33094
|
-
if (
|
|
33095
|
-
return { valid: false, error: "
|
|
33098
|
+
const fileIds = parseFileIds(input.fileIds);
|
|
33099
|
+
if (!fileIds) {
|
|
33100
|
+
return { valid: false, error: "fileIds must contain integer values" };
|
|
33096
33101
|
}
|
|
33097
33102
|
let valid;
|
|
33098
33103
|
try {
|
|
@@ -33104,9 +33109,8 @@ async function verifyGrantRegistration(input) {
|
|
|
33104
33109
|
message: {
|
|
33105
33110
|
grantorAddress: input.grantorAddress,
|
|
33106
33111
|
granteeId: input.granteeId,
|
|
33107
|
-
|
|
33108
|
-
|
|
33109
|
-
expiresAt
|
|
33112
|
+
grant: input.grant,
|
|
33113
|
+
fileIds: fileIds.values
|
|
33110
33114
|
},
|
|
33111
33115
|
signature: input.signature
|
|
33112
33116
|
});
|
|
@@ -33117,69 +33121,19 @@ async function verifyGrantRegistration(input) {
|
|
|
33117
33121
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
33118
33122
|
}
|
|
33119
33123
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
33120
|
-
if (expiresAt >
|
|
33124
|
+
if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
|
|
33121
33125
|
return { valid: false, error: "Grant has expired" };
|
|
33122
33126
|
}
|
|
33127
|
+
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
33128
|
+
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
33129
|
+
}
|
|
33123
33130
|
return {
|
|
33124
33131
|
valid: true,
|
|
33125
33132
|
grantorAddress: input.grantorAddress,
|
|
33126
33133
|
granteeId: input.granteeId,
|
|
33127
|
-
|
|
33128
|
-
|
|
33129
|
-
|
|
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)
|
|
33134
|
+
grant: input.grant,
|
|
33135
|
+
payload,
|
|
33136
|
+
fileIds: fileIds.display
|
|
33183
33137
|
};
|
|
33184
33138
|
}
|
|
33185
33139
|
|
|
@@ -33379,68 +33333,6 @@ function createGatewayClient(baseUrl) {
|
|
|
33379
33333
|
alreadyRegistered: false
|
|
33380
33334
|
};
|
|
33381
33335
|
},
|
|
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
|
-
},
|
|
33444
33336
|
async registerFile(params) {
|
|
33445
33337
|
const res = await fetch(`${base}/v1/files`, {
|
|
33446
33338
|
method: "POST",
|
|
@@ -33478,9 +33370,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33478
33370
|
body: JSON.stringify({
|
|
33479
33371
|
grantorAddress: params.grantorAddress,
|
|
33480
33372
|
granteeId: params.granteeId,
|
|
33481
|
-
|
|
33482
|
-
|
|
33483
|
-
expiresAt: params.expiresAt
|
|
33373
|
+
grant: params.grant,
|
|
33374
|
+
fileIds: params.fileIds
|
|
33484
33375
|
})
|
|
33485
33376
|
});
|
|
33486
33377
|
if (res.status === 409) {
|
|
@@ -33505,8 +33396,7 @@ function createGatewayClient(baseUrl) {
|
|
|
33505
33396
|
Authorization: `Web3Signed ${params.signature}`
|
|
33506
33397
|
},
|
|
33507
33398
|
body: JSON.stringify({
|
|
33508
|
-
grantorAddress: params.grantorAddress
|
|
33509
|
-
grantVersion: params.grantVersion
|
|
33399
|
+
grantorAddress: params.grantorAddress
|
|
33510
33400
|
})
|
|
33511
33401
|
});
|
|
33512
33402
|
if (res.status === 409) return;
|
|
@@ -33514,62 +33404,21 @@ function createGatewayClient(baseUrl) {
|
|
|
33514
33404
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33515
33405
|
}
|
|
33516
33406
|
},
|
|
33517
|
-
async
|
|
33518
|
-
const res = await fetch(`${base}/v1/
|
|
33519
|
-
|
|
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",
|
|
33407
|
+
async deleteFile(params) {
|
|
33408
|
+
const res = await fetch(`${base}/v1/files/${params.fileId}`, {
|
|
33409
|
+
method: "DELETE",
|
|
33549
33410
|
headers: {
|
|
33550
33411
|
"Content-Type": "application/json",
|
|
33551
33412
|
Authorization: `Web3Signed ${params.signature}`
|
|
33552
33413
|
},
|
|
33553
|
-
body: JSON.stringify(
|
|
33554
|
-
|
|
33555
|
-
|
|
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 ?? {})
|
|
33414
|
+
body: JSON.stringify({
|
|
33415
|
+
ownerAddress: params.ownerAddress
|
|
33416
|
+
})
|
|
33568
33417
|
});
|
|
33418
|
+
if (res.status === 409) return;
|
|
33569
33419
|
if (!res.ok) {
|
|
33570
33420
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33571
33421
|
}
|
|
33572
|
-
return await res.json();
|
|
33573
33422
|
}
|
|
33574
33423
|
};
|
|
33575
33424
|
}
|
|
@@ -33638,7 +33487,6 @@ async function parsePSError(response) {
|
|
|
33638
33487
|
}
|
|
33639
33488
|
export {
|
|
33640
33489
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33641
|
-
ADD_DATA_TYPES,
|
|
33642
33490
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33643
33491
|
AccountPersonalServerRegistrationError,
|
|
33644
33492
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33651,10 +33499,9 @@ export {
|
|
|
33651
33499
|
DataFileEnvelopeSchema,
|
|
33652
33500
|
DropboxStorage,
|
|
33653
33501
|
ECIESError,
|
|
33654
|
-
ESCROW_DEPOSIT_ABI,
|
|
33655
33502
|
ExpiredTokenError,
|
|
33503
|
+
FILE_DELETION_TYPES,
|
|
33656
33504
|
FILE_REGISTRATION_TYPES,
|
|
33657
|
-
GENERIC_PAYMENT_TYPES,
|
|
33658
33505
|
GRANT_REGISTRATION_TYPES,
|
|
33659
33506
|
GRANT_REVOCATION_TYPES,
|
|
33660
33507
|
GoogleDriveStorage,
|
|
@@ -33665,7 +33512,6 @@ export {
|
|
|
33665
33512
|
IpfsStorage,
|
|
33666
33513
|
MASTER_KEY_MESSAGE,
|
|
33667
33514
|
MissingAuthError,
|
|
33668
|
-
NATIVE_VANA_ASSET,
|
|
33669
33515
|
NetworkError,
|
|
33670
33516
|
NodeECIESUint8Provider as NodeECIESProvider,
|
|
33671
33517
|
NodePlatformAdapter,
|
|
@@ -33683,7 +33529,6 @@ export {
|
|
|
33683
33529
|
PersonalServerError,
|
|
33684
33530
|
PinataStorage,
|
|
33685
33531
|
R2Storage,
|
|
33686
|
-
RECORD_DATA_ACCESS_TYPES,
|
|
33687
33532
|
ReadOnlyError,
|
|
33688
33533
|
RelayerError,
|
|
33689
33534
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33698,8 +33543,6 @@ export {
|
|
|
33698
33543
|
VanaError,
|
|
33699
33544
|
VanaStorage,
|
|
33700
33545
|
assertValidPkceVerifier,
|
|
33701
|
-
buildDepositNativeRequest,
|
|
33702
|
-
buildDepositTokenRequest,
|
|
33703
33546
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33704
33547
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33705
33548
|
buildPersonalServerRegistrationSignature,
|
|
@@ -33721,17 +33564,13 @@ export {
|
|
|
33721
33564
|
createVanaStorageProvider,
|
|
33722
33565
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33723
33566
|
createViemPersonalServerRegistrationSigner,
|
|
33724
|
-
dataRegistryDomain,
|
|
33725
33567
|
decryptWithPassword,
|
|
33726
33568
|
deriveMasterKey,
|
|
33727
33569
|
deriveScopeKey,
|
|
33728
33570
|
deserializeECIES,
|
|
33729
33571
|
detectPlatform,
|
|
33730
|
-
encodeDepositNativeData,
|
|
33731
|
-
encodeDepositTokenData,
|
|
33732
33572
|
encryptWithPassword,
|
|
33733
|
-
|
|
33734
|
-
escrowPaymentDomain,
|
|
33573
|
+
fileDeletionDomain,
|
|
33735
33574
|
fileRegistrationDomain,
|
|
33736
33575
|
generatePkceVerifier,
|
|
33737
33576
|
getAbi,
|
|
@@ -33751,6 +33590,7 @@ export {
|
|
|
33751
33590
|
moksha,
|
|
33752
33591
|
mokshaServices,
|
|
33753
33592
|
mokshaTestnet2 as mokshaTestnet,
|
|
33593
|
+
parseGrantRegistrationPayload,
|
|
33754
33594
|
parsePSError,
|
|
33755
33595
|
parseScope,
|
|
33756
33596
|
parseWeb3SignedHeader,
|