@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.cjs
CHANGED
|
@@ -1174,7 +1174,6 @@ var init_browser2 = __esm({
|
|
|
1174
1174
|
var index_node_exports = {};
|
|
1175
1175
|
__export(index_node_exports, {
|
|
1176
1176
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT: () => ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
1177
|
-
ADD_DATA_TYPES: () => ADD_DATA_TYPES,
|
|
1178
1177
|
AccountPersonalServerLiteOwnerBindingError: () => AccountPersonalServerLiteOwnerBindingError,
|
|
1179
1178
|
AccountPersonalServerRegistrationError: () => AccountPersonalServerRegistrationError,
|
|
1180
1179
|
BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
|
|
@@ -1187,10 +1186,9 @@ __export(index_node_exports, {
|
|
|
1187
1186
|
DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
|
|
1188
1187
|
DropboxStorage: () => DropboxStorage,
|
|
1189
1188
|
ECIESError: () => ECIESError,
|
|
1190
|
-
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI,
|
|
1191
1189
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
1190
|
+
FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
|
|
1192
1191
|
FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
|
|
1193
|
-
GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
|
|
1194
1192
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
1195
1193
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
1196
1194
|
GoogleDriveStorage: () => GoogleDriveStorage,
|
|
@@ -1201,7 +1199,6 @@ __export(index_node_exports, {
|
|
|
1201
1199
|
IpfsStorage: () => IpfsStorage,
|
|
1202
1200
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1203
1201
|
MissingAuthError: () => MissingAuthError,
|
|
1204
|
-
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
1205
1202
|
NetworkError: () => NetworkError,
|
|
1206
1203
|
NodeECIESProvider: () => NodeECIESUint8Provider,
|
|
1207
1204
|
NodePlatformAdapter: () => NodePlatformAdapter,
|
|
@@ -1219,7 +1216,6 @@ __export(index_node_exports, {
|
|
|
1219
1216
|
PersonalServerError: () => PersonalServerError,
|
|
1220
1217
|
PinataStorage: () => PinataStorage,
|
|
1221
1218
|
R2Storage: () => R2Storage,
|
|
1222
|
-
RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
|
|
1223
1219
|
ReadOnlyError: () => ReadOnlyError,
|
|
1224
1220
|
RelayerError: () => RelayerError,
|
|
1225
1221
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
@@ -1234,8 +1230,6 @@ __export(index_node_exports, {
|
|
|
1234
1230
|
VanaError: () => VanaError,
|
|
1235
1231
|
VanaStorage: () => VanaStorage,
|
|
1236
1232
|
assertValidPkceVerifier: () => assertValidPkceVerifier,
|
|
1237
|
-
buildDepositNativeRequest: () => buildDepositNativeRequest,
|
|
1238
|
-
buildDepositTokenRequest: () => buildDepositTokenRequest,
|
|
1239
1233
|
buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
|
|
1240
1234
|
buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
|
|
1241
1235
|
buildPersonalServerRegistrationSignature: () => buildPersonalServerRegistrationSignature,
|
|
@@ -1257,17 +1251,13 @@ __export(index_node_exports, {
|
|
|
1257
1251
|
createVanaStorageProvider: () => createVanaStorageProvider,
|
|
1258
1252
|
createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
|
|
1259
1253
|
createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
|
|
1260
|
-
dataRegistryDomain: () => dataRegistryDomain,
|
|
1261
1254
|
decryptWithPassword: () => decryptWithPassword,
|
|
1262
1255
|
deriveMasterKey: () => deriveMasterKey,
|
|
1263
1256
|
deriveScopeKey: () => deriveScopeKey,
|
|
1264
1257
|
deserializeECIES: () => deserializeECIES,
|
|
1265
1258
|
detectPlatform: () => detectPlatform,
|
|
1266
|
-
encodeDepositNativeData: () => encodeDepositNativeData,
|
|
1267
|
-
encodeDepositTokenData: () => encodeDepositTokenData,
|
|
1268
1259
|
encryptWithPassword: () => encryptWithPassword,
|
|
1269
|
-
|
|
1270
|
-
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
1260
|
+
fileDeletionDomain: () => fileDeletionDomain,
|
|
1271
1261
|
fileRegistrationDomain: () => fileRegistrationDomain,
|
|
1272
1262
|
generatePkceVerifier: () => generatePkceVerifier,
|
|
1273
1263
|
getAbi: () => getAbi,
|
|
@@ -1287,6 +1277,7 @@ __export(index_node_exports, {
|
|
|
1287
1277
|
moksha: () => moksha,
|
|
1288
1278
|
mokshaServices: () => mokshaServices,
|
|
1289
1279
|
mokshaTestnet: () => mokshaTestnet2,
|
|
1280
|
+
parseGrantRegistrationPayload: () => parseGrantRegistrationPayload,
|
|
1290
1281
|
parsePSError: () => parsePSError,
|
|
1291
1282
|
parseScope: () => parseScope,
|
|
1292
1283
|
parseWeb3SignedHeader: () => parseWeb3SignedHeader,
|
|
@@ -32658,7 +32649,6 @@ function formatOAuthError(body, status) {
|
|
|
32658
32649
|
// src/protocol/eip712.ts
|
|
32659
32650
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
32660
32651
|
var DOMAIN_VERSION = "1";
|
|
32661
|
-
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
32662
32652
|
function buildDomain(chainId, verifyingContract) {
|
|
32663
32653
|
return {
|
|
32664
32654
|
name: DOMAIN_NAME,
|
|
@@ -32673,7 +32663,7 @@ function fileRegistrationDomain(config) {
|
|
|
32673
32663
|
config.contracts.dataRegistry
|
|
32674
32664
|
);
|
|
32675
32665
|
}
|
|
32676
|
-
function
|
|
32666
|
+
function fileDeletionDomain(config) {
|
|
32677
32667
|
return buildDomain(
|
|
32678
32668
|
config.chainId,
|
|
32679
32669
|
config.contracts.dataRegistry
|
|
@@ -32703,12 +32693,6 @@ function builderRegistrationDomain(config) {
|
|
|
32703
32693
|
config.contracts.dataPortabilityGrantees
|
|
32704
32694
|
);
|
|
32705
32695
|
}
|
|
32706
|
-
function escrowPaymentDomain(config) {
|
|
32707
|
-
return buildDomain(
|
|
32708
|
-
config.chainId,
|
|
32709
|
-
config.contracts.dataPortabilityEscrow
|
|
32710
|
-
);
|
|
32711
|
-
}
|
|
32712
32696
|
var FILE_REGISTRATION_TYPES = {
|
|
32713
32697
|
FileRegistration: [
|
|
32714
32698
|
{ name: "ownerAddress", type: "address" },
|
|
@@ -32716,20 +32700,24 @@ var FILE_REGISTRATION_TYPES = {
|
|
|
32716
32700
|
{ name: "schemaId", type: "bytes32" }
|
|
32717
32701
|
]
|
|
32718
32702
|
};
|
|
32703
|
+
var FILE_DELETION_TYPES = {
|
|
32704
|
+
FileDeletion: [
|
|
32705
|
+
{ name: "ownerAddress", type: "address" },
|
|
32706
|
+
{ name: "fileId", type: "bytes32" }
|
|
32707
|
+
]
|
|
32708
|
+
};
|
|
32719
32709
|
var GRANT_REGISTRATION_TYPES = {
|
|
32720
32710
|
GrantRegistration: [
|
|
32721
32711
|
{ name: "grantorAddress", type: "address" },
|
|
32722
32712
|
{ name: "granteeId", type: "bytes32" },
|
|
32723
|
-
{ name: "
|
|
32724
|
-
{ name: "
|
|
32725
|
-
{ name: "expiresAt", type: "uint256" }
|
|
32713
|
+
{ name: "grant", type: "string" },
|
|
32714
|
+
{ name: "fileIds", type: "uint256[]" }
|
|
32726
32715
|
]
|
|
32727
32716
|
};
|
|
32728
32717
|
var GRANT_REVOCATION_TYPES = {
|
|
32729
32718
|
GrantRevocation: [
|
|
32730
32719
|
{ name: "grantorAddress", type: "address" },
|
|
32731
|
-
{ name: "grantId", type: "bytes32" }
|
|
32732
|
-
{ name: "grantVersion", type: "uint256" }
|
|
32720
|
+
{ name: "grantId", type: "bytes32" }
|
|
32733
32721
|
]
|
|
32734
32722
|
};
|
|
32735
32723
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32748,34 +32736,6 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32748
32736
|
{ name: "appUrl", type: "string" }
|
|
32749
32737
|
]
|
|
32750
32738
|
};
|
|
32751
|
-
var GENERIC_PAYMENT_TYPES = {
|
|
32752
|
-
GenericPayment: [
|
|
32753
|
-
{ name: "payerAddress", type: "address" },
|
|
32754
|
-
{ name: "opType", type: "string" },
|
|
32755
|
-
{ name: "opId", type: "bytes32" },
|
|
32756
|
-
{ name: "asset", type: "address" },
|
|
32757
|
-
{ name: "amount", type: "uint256" },
|
|
32758
|
-
{ name: "paymentNonce", type: "uint256" }
|
|
32759
|
-
]
|
|
32760
|
-
};
|
|
32761
|
-
var ADD_DATA_TYPES = {
|
|
32762
|
-
AddData: [
|
|
32763
|
-
{ name: "ownerAddress", type: "address" },
|
|
32764
|
-
{ name: "scope", type: "string" },
|
|
32765
|
-
{ name: "dataHash", type: "bytes32" },
|
|
32766
|
-
{ name: "metadataHash", type: "bytes32" },
|
|
32767
|
-
{ name: "expectedVersion", type: "uint256" }
|
|
32768
|
-
]
|
|
32769
|
-
};
|
|
32770
|
-
var RECORD_DATA_ACCESS_TYPES = {
|
|
32771
|
-
RecordDataAccess: [
|
|
32772
|
-
{ name: "ownerAddress", type: "address" },
|
|
32773
|
-
{ name: "scope", type: "string" },
|
|
32774
|
-
{ name: "version", type: "uint256" },
|
|
32775
|
-
{ name: "accessor", type: "address" },
|
|
32776
|
-
{ name: "recordId", type: "bytes32" }
|
|
32777
|
-
]
|
|
32778
|
-
};
|
|
32779
32739
|
|
|
32780
32740
|
// src/protocol/personal-server-registration.ts
|
|
32781
32741
|
var import_viem14 = require("viem");
|
|
@@ -33213,31 +33173,67 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
33213
33173
|
return false;
|
|
33214
33174
|
}
|
|
33215
33175
|
const c = contracts;
|
|
33216
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"])
|
|
33176
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
33217
33177
|
}
|
|
33218
|
-
function
|
|
33178
|
+
function parseGrantRegistrationPayload(grant) {
|
|
33179
|
+
let parsed;
|
|
33219
33180
|
try {
|
|
33220
|
-
|
|
33221
|
-
if (big < 0n) return null;
|
|
33222
|
-
return big;
|
|
33181
|
+
parsed = JSON.parse(grant);
|
|
33223
33182
|
} catch {
|
|
33224
33183
|
return null;
|
|
33225
33184
|
}
|
|
33226
|
-
|
|
33227
|
-
|
|
33228
|
-
|
|
33229
|
-
|
|
33185
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33186
|
+
return null;
|
|
33187
|
+
}
|
|
33188
|
+
const value = parsed;
|
|
33189
|
+
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
33190
|
+
return null;
|
|
33191
|
+
}
|
|
33192
|
+
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
33193
|
+
return null;
|
|
33194
|
+
}
|
|
33195
|
+
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
33196
|
+
return null;
|
|
33230
33197
|
}
|
|
33231
|
-
if (
|
|
33232
|
-
return
|
|
33198
|
+
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
33199
|
+
return null;
|
|
33200
|
+
}
|
|
33201
|
+
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
33202
|
+
return null;
|
|
33203
|
+
}
|
|
33204
|
+
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
33205
|
+
return null;
|
|
33206
|
+
}
|
|
33207
|
+
return {
|
|
33208
|
+
user: value["user"],
|
|
33209
|
+
builder: value["builder"],
|
|
33210
|
+
scopes: value["scopes"],
|
|
33211
|
+
expiresAt: value["expiresAt"],
|
|
33212
|
+
nonce: value["nonce"]
|
|
33213
|
+
};
|
|
33214
|
+
}
|
|
33215
|
+
function parseFileIds(fileIds) {
|
|
33216
|
+
try {
|
|
33217
|
+
const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
|
|
33218
|
+
return {
|
|
33219
|
+
values,
|
|
33220
|
+
display: values.map((fileId) => fileId.toString())
|
|
33221
|
+
};
|
|
33222
|
+
} catch {
|
|
33223
|
+
return null;
|
|
33233
33224
|
}
|
|
33234
|
-
|
|
33235
|
-
|
|
33236
|
-
|
|
33225
|
+
}
|
|
33226
|
+
async function verifyGrantRegistration(input) {
|
|
33227
|
+
const payload = parseGrantRegistrationPayload(input.grant);
|
|
33228
|
+
if (!payload) {
|
|
33229
|
+
return {
|
|
33230
|
+
valid: false,
|
|
33231
|
+
error: "Grant must be JSON with scopes and expiresAt"
|
|
33232
|
+
};
|
|
33237
33233
|
}
|
|
33238
|
-
const
|
|
33239
|
-
if (
|
|
33240
|
-
return { valid: false, error: "
|
|
33234
|
+
const fileIds = parseFileIds(input.fileIds);
|
|
33235
|
+
if (!fileIds) {
|
|
33236
|
+
return { valid: false, error: "fileIds must contain integer values" };
|
|
33241
33237
|
}
|
|
33242
33238
|
let valid;
|
|
33243
33239
|
try {
|
|
@@ -33249,9 +33245,8 @@ async function verifyGrantRegistration(input) {
|
|
|
33249
33245
|
message: {
|
|
33250
33246
|
grantorAddress: input.grantorAddress,
|
|
33251
33247
|
granteeId: input.granteeId,
|
|
33252
|
-
|
|
33253
|
-
|
|
33254
|
-
expiresAt
|
|
33248
|
+
grant: input.grant,
|
|
33249
|
+
fileIds: fileIds.values
|
|
33255
33250
|
},
|
|
33256
33251
|
signature: input.signature
|
|
33257
33252
|
});
|
|
@@ -33262,69 +33257,19 @@ async function verifyGrantRegistration(input) {
|
|
|
33262
33257
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
33263
33258
|
}
|
|
33264
33259
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
33265
|
-
if (expiresAt >
|
|
33260
|
+
if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
|
|
33266
33261
|
return { valid: false, error: "Grant has expired" };
|
|
33267
33262
|
}
|
|
33263
|
+
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
33264
|
+
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
33265
|
+
}
|
|
33268
33266
|
return {
|
|
33269
33267
|
valid: true,
|
|
33270
33268
|
grantorAddress: input.grantorAddress,
|
|
33271
33269
|
granteeId: input.granteeId,
|
|
33272
|
-
|
|
33273
|
-
|
|
33274
|
-
|
|
33275
|
-
};
|
|
33276
|
-
}
|
|
33277
|
-
|
|
33278
|
-
// src/protocol/escrow-deposit.ts
|
|
33279
|
-
var import_viem18 = require("viem");
|
|
33280
|
-
var ESCROW_DEPOSIT_ABI = [
|
|
33281
|
-
{
|
|
33282
|
-
type: "function",
|
|
33283
|
-
name: "depositNative",
|
|
33284
|
-
stateMutability: "payable",
|
|
33285
|
-
inputs: [{ name: "account", type: "address" }],
|
|
33286
|
-
outputs: []
|
|
33287
|
-
},
|
|
33288
|
-
{
|
|
33289
|
-
type: "function",
|
|
33290
|
-
name: "depositToken",
|
|
33291
|
-
stateMutability: "nonpayable",
|
|
33292
|
-
inputs: [
|
|
33293
|
-
{ name: "account", type: "address" },
|
|
33294
|
-
{ name: "token", type: "address" },
|
|
33295
|
-
{ name: "amount", type: "uint256" }
|
|
33296
|
-
],
|
|
33297
|
-
outputs: []
|
|
33298
|
-
}
|
|
33299
|
-
];
|
|
33300
|
-
function escrowContractAddress(config) {
|
|
33301
|
-
return config.contracts.dataPortabilityEscrow;
|
|
33302
|
-
}
|
|
33303
|
-
function encodeDepositNativeData(input) {
|
|
33304
|
-
return (0, import_viem18.encodeFunctionData)({
|
|
33305
|
-
abi: ESCROW_DEPOSIT_ABI,
|
|
33306
|
-
functionName: "depositNative",
|
|
33307
|
-
args: [input.account]
|
|
33308
|
-
});
|
|
33309
|
-
}
|
|
33310
|
-
function encodeDepositTokenData(input) {
|
|
33311
|
-
return (0, import_viem18.encodeFunctionData)({
|
|
33312
|
-
abi: ESCROW_DEPOSIT_ABI,
|
|
33313
|
-
functionName: "depositToken",
|
|
33314
|
-
args: [input.account, input.token, input.amount]
|
|
33315
|
-
});
|
|
33316
|
-
}
|
|
33317
|
-
function buildDepositNativeRequest(config, input) {
|
|
33318
|
-
return {
|
|
33319
|
-
to: escrowContractAddress(config),
|
|
33320
|
-
data: encodeDepositNativeData({ account: input.account }),
|
|
33321
|
-
value: input.amount
|
|
33322
|
-
};
|
|
33323
|
-
}
|
|
33324
|
-
function buildDepositTokenRequest(config, input) {
|
|
33325
|
-
return {
|
|
33326
|
-
to: escrowContractAddress(config),
|
|
33327
|
-
data: encodeDepositTokenData(input)
|
|
33270
|
+
grant: input.grant,
|
|
33271
|
+
payload,
|
|
33272
|
+
fileIds: fileIds.display
|
|
33328
33273
|
};
|
|
33329
33274
|
}
|
|
33330
33275
|
|
|
@@ -33524,68 +33469,6 @@ function createGatewayClient(baseUrl) {
|
|
|
33524
33469
|
alreadyRegistered: false
|
|
33525
33470
|
};
|
|
33526
33471
|
},
|
|
33527
|
-
async registerBuilder(params) {
|
|
33528
|
-
const res = await fetch(`${base}/v1/builders`, {
|
|
33529
|
-
method: "POST",
|
|
33530
|
-
headers: {
|
|
33531
|
-
"Content-Type": "application/json",
|
|
33532
|
-
Authorization: `Web3Signed ${params.signature}`
|
|
33533
|
-
},
|
|
33534
|
-
body: JSON.stringify({
|
|
33535
|
-
ownerAddress: params.ownerAddress,
|
|
33536
|
-
granteeAddress: params.granteeAddress,
|
|
33537
|
-
publicKey: params.publicKey,
|
|
33538
|
-
appUrl: params.appUrl
|
|
33539
|
-
})
|
|
33540
|
-
});
|
|
33541
|
-
if (res.status === 409) {
|
|
33542
|
-
const body2 = await res.json().catch(() => ({}));
|
|
33543
|
-
return {
|
|
33544
|
-
builderId: getMutationId(
|
|
33545
|
-
body2,
|
|
33546
|
-
"builderId"
|
|
33547
|
-
),
|
|
33548
|
-
alreadyRegistered: true
|
|
33549
|
-
};
|
|
33550
|
-
}
|
|
33551
|
-
if (!res.ok) {
|
|
33552
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33553
|
-
}
|
|
33554
|
-
const body = await res.json().catch(() => ({}));
|
|
33555
|
-
return {
|
|
33556
|
-
builderId: getMutationId(body, "builderId"),
|
|
33557
|
-
alreadyRegistered: false
|
|
33558
|
-
};
|
|
33559
|
-
},
|
|
33560
|
-
async registerDataPoint(params) {
|
|
33561
|
-
const res = await fetch(`${base}/v1/data`, {
|
|
33562
|
-
method: "POST",
|
|
33563
|
-
headers: {
|
|
33564
|
-
"Content-Type": "application/json",
|
|
33565
|
-
Authorization: `Web3Signed ${params.signature}`
|
|
33566
|
-
},
|
|
33567
|
-
body: JSON.stringify({
|
|
33568
|
-
ownerAddress: params.ownerAddress,
|
|
33569
|
-
scope: params.scope,
|
|
33570
|
-
dataHash: params.dataHash,
|
|
33571
|
-
metadataHash: params.metadataHash,
|
|
33572
|
-
expectedVersion: params.expectedVersion
|
|
33573
|
-
})
|
|
33574
|
-
});
|
|
33575
|
-
if (!res.ok) {
|
|
33576
|
-
const body2 = await res.json().catch(() => ({}));
|
|
33577
|
-
const detail = body2.error ?? res.statusText;
|
|
33578
|
-
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33579
|
-
}
|
|
33580
|
-
const body = await res.json().catch(() => ({}));
|
|
33581
|
-
return {
|
|
33582
|
-
dataPointId: getMutationId(
|
|
33583
|
-
body,
|
|
33584
|
-
"dataPointId"
|
|
33585
|
-
),
|
|
33586
|
-
expectedVersion: body.expectedVersion
|
|
33587
|
-
};
|
|
33588
|
-
},
|
|
33589
33472
|
async registerFile(params) {
|
|
33590
33473
|
const res = await fetch(`${base}/v1/files`, {
|
|
33591
33474
|
method: "POST",
|
|
@@ -33623,9 +33506,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33623
33506
|
body: JSON.stringify({
|
|
33624
33507
|
grantorAddress: params.grantorAddress,
|
|
33625
33508
|
granteeId: params.granteeId,
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
expiresAt: params.expiresAt
|
|
33509
|
+
grant: params.grant,
|
|
33510
|
+
fileIds: params.fileIds
|
|
33629
33511
|
})
|
|
33630
33512
|
});
|
|
33631
33513
|
if (res.status === 409) {
|
|
@@ -33650,8 +33532,7 @@ function createGatewayClient(baseUrl) {
|
|
|
33650
33532
|
Authorization: `Web3Signed ${params.signature}`
|
|
33651
33533
|
},
|
|
33652
33534
|
body: JSON.stringify({
|
|
33653
|
-
grantorAddress: params.grantorAddress
|
|
33654
|
-
grantVersion: params.grantVersion
|
|
33535
|
+
grantorAddress: params.grantorAddress
|
|
33655
33536
|
})
|
|
33656
33537
|
});
|
|
33657
33538
|
if (res.status === 409) return;
|
|
@@ -33659,62 +33540,21 @@ function createGatewayClient(baseUrl) {
|
|
|
33659
33540
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33660
33541
|
}
|
|
33661
33542
|
},
|
|
33662
|
-
async
|
|
33663
|
-
const res = await fetch(`${base}/v1/
|
|
33664
|
-
|
|
33665
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33666
|
-
}
|
|
33667
|
-
return await res.json();
|
|
33668
|
-
},
|
|
33669
|
-
async submitEscrowDeposit(params) {
|
|
33670
|
-
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33671
|
-
method: "POST",
|
|
33672
|
-
headers: { "Content-Type": "application/json" },
|
|
33673
|
-
body: JSON.stringify({ txHash: params.txHash })
|
|
33674
|
-
});
|
|
33675
|
-
if (res.status !== 200 && res.status !== 202) {
|
|
33676
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33677
|
-
}
|
|
33678
|
-
return await res.json();
|
|
33679
|
-
},
|
|
33680
|
-
async payForOperation(params) {
|
|
33681
|
-
const body = {
|
|
33682
|
-
payerAddress: params.payerAddress,
|
|
33683
|
-
opType: params.opType,
|
|
33684
|
-
opId: params.opId,
|
|
33685
|
-
asset: params.asset,
|
|
33686
|
-
amount: params.amount,
|
|
33687
|
-
paymentNonce: params.paymentNonce
|
|
33688
|
-
};
|
|
33689
|
-
if (params.accessRecord) {
|
|
33690
|
-
body["accessRecord"] = params.accessRecord;
|
|
33691
|
-
}
|
|
33692
|
-
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33693
|
-
method: "POST",
|
|
33543
|
+
async deleteFile(params) {
|
|
33544
|
+
const res = await fetch(`${base}/v1/files/${params.fileId}`, {
|
|
33545
|
+
method: "DELETE",
|
|
33694
33546
|
headers: {
|
|
33695
33547
|
"Content-Type": "application/json",
|
|
33696
33548
|
Authorization: `Web3Signed ${params.signature}`
|
|
33697
33549
|
},
|
|
33698
|
-
body: JSON.stringify(
|
|
33699
|
-
|
|
33700
|
-
|
|
33701
|
-
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33702
|
-
}
|
|
33703
|
-
return await res.json();
|
|
33704
|
-
},
|
|
33705
|
-
async settle(params) {
|
|
33706
|
-
const res = await fetch(`${base}/v1/settle`, {
|
|
33707
|
-
method: "POST",
|
|
33708
|
-
headers: { "Content-Type": "application/json" },
|
|
33709
|
-
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33710
|
-
// Always send a JSON body so the gateway's req.body shape parse
|
|
33711
|
-
// doesn't have to deal with an undefined.
|
|
33712
|
-
body: JSON.stringify(params ?? {})
|
|
33550
|
+
body: JSON.stringify({
|
|
33551
|
+
ownerAddress: params.ownerAddress
|
|
33552
|
+
})
|
|
33713
33553
|
});
|
|
33554
|
+
if (res.status === 409) return;
|
|
33714
33555
|
if (!res.ok) {
|
|
33715
33556
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33716
33557
|
}
|
|
33717
|
-
return await res.json();
|
|
33718
33558
|
}
|
|
33719
33559
|
};
|
|
33720
33560
|
}
|
|
@@ -33784,7 +33624,6 @@ async function parsePSError(response) {
|
|
|
33784
33624
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33785
33625
|
0 && (module.exports = {
|
|
33786
33626
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
33787
|
-
ADD_DATA_TYPES,
|
|
33788
33627
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33789
33628
|
AccountPersonalServerRegistrationError,
|
|
33790
33629
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33797,10 +33636,9 @@ async function parsePSError(response) {
|
|
|
33797
33636
|
DataFileEnvelopeSchema,
|
|
33798
33637
|
DropboxStorage,
|
|
33799
33638
|
ECIESError,
|
|
33800
|
-
ESCROW_DEPOSIT_ABI,
|
|
33801
33639
|
ExpiredTokenError,
|
|
33640
|
+
FILE_DELETION_TYPES,
|
|
33802
33641
|
FILE_REGISTRATION_TYPES,
|
|
33803
|
-
GENERIC_PAYMENT_TYPES,
|
|
33804
33642
|
GRANT_REGISTRATION_TYPES,
|
|
33805
33643
|
GRANT_REVOCATION_TYPES,
|
|
33806
33644
|
GoogleDriveStorage,
|
|
@@ -33811,7 +33649,6 @@ async function parsePSError(response) {
|
|
|
33811
33649
|
IpfsStorage,
|
|
33812
33650
|
MASTER_KEY_MESSAGE,
|
|
33813
33651
|
MissingAuthError,
|
|
33814
|
-
NATIVE_VANA_ASSET,
|
|
33815
33652
|
NetworkError,
|
|
33816
33653
|
NodeECIESProvider,
|
|
33817
33654
|
NodePlatformAdapter,
|
|
@@ -33829,7 +33666,6 @@ async function parsePSError(response) {
|
|
|
33829
33666
|
PersonalServerError,
|
|
33830
33667
|
PinataStorage,
|
|
33831
33668
|
R2Storage,
|
|
33832
|
-
RECORD_DATA_ACCESS_TYPES,
|
|
33833
33669
|
ReadOnlyError,
|
|
33834
33670
|
RelayerError,
|
|
33835
33671
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33844,8 +33680,6 @@ async function parsePSError(response) {
|
|
|
33844
33680
|
VanaError,
|
|
33845
33681
|
VanaStorage,
|
|
33846
33682
|
assertValidPkceVerifier,
|
|
33847
|
-
buildDepositNativeRequest,
|
|
33848
|
-
buildDepositTokenRequest,
|
|
33849
33683
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33850
33684
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33851
33685
|
buildPersonalServerRegistrationSignature,
|
|
@@ -33867,17 +33701,13 @@ async function parsePSError(response) {
|
|
|
33867
33701
|
createVanaStorageProvider,
|
|
33868
33702
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33869
33703
|
createViemPersonalServerRegistrationSigner,
|
|
33870
|
-
dataRegistryDomain,
|
|
33871
33704
|
decryptWithPassword,
|
|
33872
33705
|
deriveMasterKey,
|
|
33873
33706
|
deriveScopeKey,
|
|
33874
33707
|
deserializeECIES,
|
|
33875
33708
|
detectPlatform,
|
|
33876
|
-
encodeDepositNativeData,
|
|
33877
|
-
encodeDepositTokenData,
|
|
33878
33709
|
encryptWithPassword,
|
|
33879
|
-
|
|
33880
|
-
escrowPaymentDomain,
|
|
33710
|
+
fileDeletionDomain,
|
|
33881
33711
|
fileRegistrationDomain,
|
|
33882
33712
|
generatePkceVerifier,
|
|
33883
33713
|
getAbi,
|
|
@@ -33897,6 +33727,7 @@ async function parsePSError(response) {
|
|
|
33897
33727
|
moksha,
|
|
33898
33728
|
mokshaServices,
|
|
33899
33729
|
mokshaTestnet,
|
|
33730
|
+
parseGrantRegistrationPayload,
|
|
33900
33731
|
parsePSError,
|
|
33901
33732
|
parseScope,
|
|
33902
33733
|
parseWeb3SignedHeader,
|