@opendatalabs/vana-sdk 3.5.0 → 3.5.1-pr.159.12a6f39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -0
- package/dist/direct/access-request-client.cjs +104 -0
- package/dist/direct/access-request-client.cjs.map +1 -0
- package/dist/direct/access-request-client.d.ts +51 -0
- package/dist/direct/access-request-client.js +79 -0
- package/dist/direct/access-request-client.js.map +1 -0
- package/dist/direct/access-request-client.test.d.ts +1 -0
- package/dist/direct/connect-flow.cjs +152 -0
- package/dist/direct/connect-flow.cjs.map +1 -0
- package/dist/direct/connect-flow.d.ts +85 -0
- package/dist/direct/connect-flow.js +128 -0
- package/dist/direct/connect-flow.js.map +1 -0
- package/dist/direct/connect-flow.test.d.ts +1 -0
- package/dist/direct/controller.cjs +129 -0
- package/dist/direct/controller.cjs.map +1 -0
- package/dist/direct/controller.d.ts +152 -0
- package/dist/direct/controller.js +109 -0
- package/dist/direct/controller.js.map +1 -0
- package/dist/direct/controller.test.d.ts +1 -0
- package/dist/direct/endpoints.cjs +45 -0
- package/dist/direct/endpoints.cjs.map +1 -0
- package/dist/direct/endpoints.d.ts +22 -0
- package/dist/direct/endpoints.js +19 -0
- package/dist/direct/endpoints.js.map +1 -0
- package/dist/direct/errors.cjs +65 -0
- package/dist/direct/errors.cjs.map +1 -0
- package/dist/direct/errors.d.ts +44 -0
- package/dist/direct/errors.js +38 -0
- package/dist/direct/errors.js.map +1 -0
- package/dist/direct/escrow-payment.cjs +96 -0
- package/dist/direct/escrow-payment.cjs.map +1 -0
- package/dist/direct/escrow-payment.d.ts +81 -0
- package/dist/direct/escrow-payment.js +72 -0
- package/dist/direct/escrow-payment.js.map +1 -0
- package/dist/direct/escrow-payment.test.d.ts +1 -0
- package/dist/direct/personal-server-read.cjs +149 -0
- package/dist/direct/personal-server-read.cjs.map +1 -0
- package/dist/direct/personal-server-read.d.ts +103 -0
- package/dist/direct/personal-server-read.js +124 -0
- package/dist/direct/personal-server-read.js.map +1 -0
- package/dist/direct/personal-server-read.test.d.ts +1 -0
- package/dist/direct/types.cjs +35 -0
- package/dist/direct/types.cjs.map +1 -0
- package/dist/direct/types.d.ts +205 -0
- package/dist/direct/types.js +11 -0
- package/dist/direct/types.js.map +1 -0
- package/dist/direct/use-direct-vana-connect.cjs +68 -0
- package/dist/direct/use-direct-vana-connect.cjs.map +1 -0
- package/dist/direct/use-direct-vana-connect.d.ts +45 -0
- package/dist/direct/use-direct-vana-connect.js +46 -0
- package/dist/direct/use-direct-vana-connect.js.map +1 -0
- package/dist/index.browser.d.ts +7 -3
- package/dist/index.browser.js +513 -174
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +536 -179
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +7 -3
- package/dist/index.node.js +513 -174
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/data-point-status.cjs +80 -0
- package/dist/protocol/data-point-status.cjs.map +1 -0
- package/dist/protocol/data-point-status.d.ts +34 -0
- package/dist/protocol/data-point-status.js +51 -0
- package/dist/protocol/data-point-status.js.map +1 -0
- package/dist/protocol/data-point-status.test.d.ts +1 -0
- package/dist/protocol/eip712.cjs +53 -31
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +98 -43
- package/dist/protocol/eip712.js +47 -27
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow-deposit.cjs +89 -0
- package/dist/protocol/escrow-deposit.cjs.map +1 -0
- package/dist/protocol/escrow-deposit.d.ts +47 -0
- package/dist/protocol/escrow-deposit.js +60 -0
- package/dist/protocol/escrow-deposit.js.map +1 -0
- package/dist/protocol/escrow-deposit.test.d.ts +1 -0
- package/dist/protocol/escrow-flow.test.d.ts +21 -0
- package/dist/protocol/fee-registry.cjs +116 -0
- package/dist/protocol/fee-registry.cjs.map +1 -0
- package/dist/protocol/fee-registry.d.ts +151 -0
- package/dist/protocol/fee-registry.js +89 -0
- package/dist/protocol/fee-registry.js.map +1 -0
- package/dist/protocol/fee-registry.test.d.ts +1 -0
- package/dist/protocol/gateway.cjs +107 -37
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +223 -57
- package/dist/protocol/gateway.js +107 -37
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +27 -64
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +6 -13
- package/dist/protocol/grants.js +27 -63
- package/dist/protocol/grants.js.map +1 -1
- package/dist/protocol/personal-server-data.cjs +71 -0
- package/dist/protocol/personal-server-data.cjs.map +1 -0
- package/dist/protocol/personal-server-data.d.ts +16 -0
- package/dist/protocol/personal-server-data.js +47 -0
- package/dist/protocol/personal-server-data.js.map +1 -0
- package/dist/protocol/personal-server-data.test.d.ts +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
- package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
- package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
- package/dist/react.cjs +32 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +33 -0
- package/dist/react.js +11 -0
- package/dist/react.js.map +1 -0
- package/dist/server.cjs +73 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.ts +32 -0
- package/dist/server.js +55 -0
- package/dist/server.js.map +1 -0
- package/dist/storage/providers/vana-storage.cjs +75 -17
- package/dist/storage/providers/vana-storage.cjs.map +1 -1
- package/dist/storage/providers/vana-storage.js +75 -17
- package/dist/storage/providers/vana-storage.js.map +1 -1
- package/package.json +20 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1174,6 +1174,7 @@ 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,
|
|
1177
1178
|
AccountPersonalServerLiteOwnerBindingError: () => AccountPersonalServerLiteOwnerBindingError,
|
|
1178
1179
|
AccountPersonalServerRegistrationError: () => AccountPersonalServerRegistrationError,
|
|
1179
1180
|
BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
|
|
@@ -1183,13 +1184,14 @@ __export(index_node_exports, {
|
|
|
1183
1184
|
CallbackStorage: () => CallbackStorage,
|
|
1184
1185
|
ContractFactory: () => ContractFactory,
|
|
1185
1186
|
ContractNotFoundError: () => ContractNotFoundError,
|
|
1187
|
+
DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
|
|
1186
1188
|
DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
|
|
1189
|
+
DataPointStatus: () => DataPointStatus,
|
|
1187
1190
|
DropboxStorage: () => DropboxStorage,
|
|
1188
1191
|
ECIESError: () => ECIESError,
|
|
1189
|
-
ESCROW_DEPOSIT_ABI: () =>
|
|
1192
|
+
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
|
|
1190
1193
|
ExpiredTokenError: () => ExpiredTokenError,
|
|
1191
|
-
|
|
1192
|
-
FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
|
|
1194
|
+
FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
|
|
1193
1195
|
GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
|
|
1194
1196
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
1195
1197
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
@@ -1202,6 +1204,7 @@ __export(index_node_exports, {
|
|
|
1202
1204
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1203
1205
|
MissingAuthError: () => MissingAuthError,
|
|
1204
1206
|
NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
|
|
1207
|
+
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
1205
1208
|
NetworkError: () => NetworkError,
|
|
1206
1209
|
NodeECIESProvider: () => NodeECIESUint8Provider,
|
|
1207
1210
|
NodePlatformAdapter: () => NodePlatformAdapter,
|
|
@@ -1219,6 +1222,8 @@ __export(index_node_exports, {
|
|
|
1219
1222
|
PersonalServerError: () => PersonalServerError,
|
|
1220
1223
|
PinataStorage: () => PinataStorage,
|
|
1221
1224
|
R2Storage: () => R2Storage,
|
|
1225
|
+
RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
|
|
1226
|
+
REGISTRATION_KIND_FOR_OP: () => REGISTRATION_KIND_FOR_OP,
|
|
1222
1227
|
ReadOnlyError: () => ReadOnlyError,
|
|
1223
1228
|
RelayerError: () => RelayerError,
|
|
1224
1229
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
@@ -1233,10 +1238,15 @@ __export(index_node_exports, {
|
|
|
1233
1238
|
VanaError: () => VanaError,
|
|
1234
1239
|
VanaStorage: () => VanaStorage,
|
|
1235
1240
|
assertValidPkceVerifier: () => assertValidPkceVerifier,
|
|
1241
|
+
buildDepositNativeRequest: () => buildDepositNativeRequest,
|
|
1242
|
+
buildDepositTokenRequest: () => buildDepositTokenRequest,
|
|
1243
|
+
buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
|
|
1244
|
+
buildPersonalServerDataReadRequest: () => buildPersonalServerDataReadRequest,
|
|
1236
1245
|
buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
|
|
1237
1246
|
buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
|
|
1238
1247
|
buildPersonalServerRegistrationSignature: () => buildPersonalServerRegistrationSignature,
|
|
1239
1248
|
buildPersonalServerRegistrationTypedData: () => buildPersonalServerRegistrationTypedData,
|
|
1249
|
+
buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
|
|
1240
1250
|
buildWeb3SignedHeader: () => buildWeb3SignedHeader,
|
|
1241
1251
|
builderRegistrationDomain: () => builderRegistrationDomain,
|
|
1242
1252
|
chains: () => chains,
|
|
@@ -1255,14 +1265,19 @@ __export(index_node_exports, {
|
|
|
1255
1265
|
createVanaStorageProvider: () => createVanaStorageProvider,
|
|
1256
1266
|
createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
|
|
1257
1267
|
createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
|
|
1268
|
+
dataRegistryContractAddress: () => dataRegistryContractAddress,
|
|
1269
|
+
dataRegistryDomain: () => dataRegistryDomain,
|
|
1258
1270
|
decryptWithPassword: () => decryptWithPassword,
|
|
1259
1271
|
deriveMasterKey: () => deriveMasterKey,
|
|
1260
1272
|
deriveScopeKey: () => deriveScopeKey,
|
|
1261
1273
|
deserializeECIES: () => deserializeECIES,
|
|
1262
1274
|
detectPlatform: () => detectPlatform,
|
|
1275
|
+
encodeDepositNativeData: () => encodeDepositNativeData,
|
|
1276
|
+
encodeDepositTokenData: () => encodeDepositTokenData,
|
|
1277
|
+
encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
|
|
1263
1278
|
encryptWithPassword: () => encryptWithPassword,
|
|
1264
|
-
|
|
1265
|
-
|
|
1279
|
+
escrowContractAddress: () => escrowContractAddress,
|
|
1280
|
+
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
1266
1281
|
generatePkceVerifier: () => generatePkceVerifier,
|
|
1267
1282
|
genericPaymentDomain: () => genericPaymentDomain,
|
|
1268
1283
|
getAbi: () => getAbi,
|
|
@@ -1271,6 +1286,8 @@ __export(index_node_exports, {
|
|
|
1271
1286
|
getContractAddress: () => getContractAddress,
|
|
1272
1287
|
getContractController: () => getContractController,
|
|
1273
1288
|
getContractInfo: () => getContractInfo,
|
|
1289
|
+
getFee: () => getFee,
|
|
1290
|
+
getOpFee: () => getOpFee,
|
|
1274
1291
|
getPlatformCapabilities: () => getPlatformCapabilities,
|
|
1275
1292
|
getServiceEndpoints: () => getServiceEndpoints,
|
|
1276
1293
|
grantRegistrationDomain: () => grantRegistrationDomain,
|
|
@@ -1282,11 +1299,12 @@ __export(index_node_exports, {
|
|
|
1282
1299
|
moksha: () => moksha,
|
|
1283
1300
|
mokshaServices: () => mokshaServices,
|
|
1284
1301
|
mokshaTestnet: () => mokshaTestnet2,
|
|
1285
|
-
parseGrantRegistrationPayload: () => parseGrantRegistrationPayload,
|
|
1286
1302
|
parsePSError: () => parsePSError,
|
|
1287
1303
|
parseScope: () => parseScope,
|
|
1288
1304
|
parseWeb3SignedHeader: () => parseWeb3SignedHeader,
|
|
1305
|
+
personalServerDataReadPath: () => personalServerDataReadPath,
|
|
1289
1306
|
personalServerRegistrationDomain: () => personalServerRegistrationDomain,
|
|
1307
|
+
readPersonalServerData: () => readPersonalServerData,
|
|
1290
1308
|
recoverServerOwner: () => recoverServerOwner,
|
|
1291
1309
|
registerPersonalServerSignature: () => registerPersonalServerSignature,
|
|
1292
1310
|
scopeCoveredByGrant: () => scopeCoveredByGrant,
|
|
@@ -29169,6 +29187,8 @@ async function buildWeb3SignedHeader(params) {
|
|
|
29169
29187
|
var DEFAULT_ENDPOINT = "https://storage.vana.org";
|
|
29170
29188
|
var BLOB_PATH_PREFIX = "/v1/blobs";
|
|
29171
29189
|
var DEFAULT_TOKEN_TTL_SECONDS = 300;
|
|
29190
|
+
var MAX_UPLOAD_ATTEMPTS = 4;
|
|
29191
|
+
var MAX_RATE_LIMIT_DELAY_MS = 3e4;
|
|
29172
29192
|
var VanaStorage = class {
|
|
29173
29193
|
endpoint;
|
|
29174
29194
|
signer;
|
|
@@ -29207,27 +29227,46 @@ var VanaStorage = class {
|
|
|
29207
29227
|
const body = new Uint8Array(await file.arrayBuffer());
|
|
29208
29228
|
const contentType = file.type !== "" ? file.type : "application/octet-stream";
|
|
29209
29229
|
const header = await this.signRequest("PUT", path, body);
|
|
29210
|
-
let response;
|
|
29211
|
-
|
|
29212
|
-
|
|
29213
|
-
|
|
29214
|
-
|
|
29215
|
-
|
|
29216
|
-
|
|
29217
|
-
|
|
29218
|
-
|
|
29219
|
-
|
|
29220
|
-
|
|
29230
|
+
let response = null;
|
|
29231
|
+
let responseText = "";
|
|
29232
|
+
for (let attempt = 1; attempt <= MAX_UPLOAD_ATTEMPTS; attempt++) {
|
|
29233
|
+
try {
|
|
29234
|
+
response = await this.fetchImpl(`${this.endpoint}${path}`, {
|
|
29235
|
+
method: "PUT",
|
|
29236
|
+
headers: {
|
|
29237
|
+
authorization: header,
|
|
29238
|
+
"content-type": contentType
|
|
29239
|
+
},
|
|
29240
|
+
body
|
|
29241
|
+
});
|
|
29242
|
+
} catch (cause) {
|
|
29243
|
+
throw new StorageError(
|
|
29244
|
+
`vana-storage upload network error: ${describe(cause)}`,
|
|
29245
|
+
"UPLOAD_ERROR",
|
|
29246
|
+
"vana-storage",
|
|
29247
|
+
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29248
|
+
);
|
|
29249
|
+
}
|
|
29250
|
+
if (response.ok) {
|
|
29251
|
+
break;
|
|
29252
|
+
}
|
|
29253
|
+
responseText = await safeText(response);
|
|
29254
|
+
if (response.status === 429 && attempt < MAX_UPLOAD_ATTEMPTS) {
|
|
29255
|
+
const delayMs = retryDelayMs(response, responseText);
|
|
29256
|
+
if (delayMs > 0) {
|
|
29257
|
+
await sleep(delayMs);
|
|
29258
|
+
}
|
|
29259
|
+
continue;
|
|
29260
|
+
}
|
|
29221
29261
|
throw new StorageError(
|
|
29222
|
-
`vana-storage upload
|
|
29223
|
-
"
|
|
29224
|
-
"vana-storage"
|
|
29225
|
-
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29262
|
+
`vana-storage upload failed: ${response.status} ${response.statusText} - ${responseText}`,
|
|
29263
|
+
"UPLOAD_FAILED",
|
|
29264
|
+
"vana-storage"
|
|
29226
29265
|
);
|
|
29227
29266
|
}
|
|
29228
|
-
if (!response
|
|
29267
|
+
if (!response?.ok) {
|
|
29229
29268
|
throw new StorageError(
|
|
29230
|
-
`vana-storage upload failed
|
|
29269
|
+
`vana-storage upload failed after ${MAX_UPLOAD_ATTEMPTS} attempts - ${responseText}`,
|
|
29231
29270
|
"UPLOAD_FAILED",
|
|
29232
29271
|
"vana-storage"
|
|
29233
29272
|
);
|
|
@@ -29380,6 +29419,43 @@ function describe(value) {
|
|
|
29380
29419
|
if (value instanceof Error) return value.message;
|
|
29381
29420
|
return String(value);
|
|
29382
29421
|
}
|
|
29422
|
+
function retryDelayMs(response, responseText) {
|
|
29423
|
+
const headerDelayMs = parseRetryAfterHeaderMs(
|
|
29424
|
+
response.headers.get("retry-after")
|
|
29425
|
+
);
|
|
29426
|
+
if (headerDelayMs !== null) {
|
|
29427
|
+
return clampRateLimitDelay(headerDelayMs);
|
|
29428
|
+
}
|
|
29429
|
+
return clampRateLimitDelay(parseRetryAfterBodyMs(responseText) ?? 0);
|
|
29430
|
+
}
|
|
29431
|
+
function parseRetryAfterHeaderMs(value) {
|
|
29432
|
+
if (!value) return null;
|
|
29433
|
+
const seconds = Number(value);
|
|
29434
|
+
if (Number.isFinite(seconds)) {
|
|
29435
|
+
return seconds * 1e3;
|
|
29436
|
+
}
|
|
29437
|
+
const dateMs = Date.parse(value);
|
|
29438
|
+
if (Number.isFinite(dateMs)) {
|
|
29439
|
+
return Math.max(0, dateMs - Date.now());
|
|
29440
|
+
}
|
|
29441
|
+
return null;
|
|
29442
|
+
}
|
|
29443
|
+
function parseRetryAfterBodyMs(responseText) {
|
|
29444
|
+
if (!responseText) return null;
|
|
29445
|
+
try {
|
|
29446
|
+
const parsed = JSON.parse(responseText);
|
|
29447
|
+
const seconds = Number(parsed.retryAfter);
|
|
29448
|
+
return Number.isFinite(seconds) ? seconds * 1e3 : null;
|
|
29449
|
+
} catch {
|
|
29450
|
+
return null;
|
|
29451
|
+
}
|
|
29452
|
+
}
|
|
29453
|
+
function clampRateLimitDelay(delayMs) {
|
|
29454
|
+
return Math.min(Math.max(0, delayMs), MAX_RATE_LIMIT_DELAY_MS);
|
|
29455
|
+
}
|
|
29456
|
+
function sleep(ms) {
|
|
29457
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29458
|
+
}
|
|
29383
29459
|
async function safeText(response) {
|
|
29384
29460
|
try {
|
|
29385
29461
|
return await response.text();
|
|
@@ -32654,6 +32730,7 @@ function formatOAuthError(body, status) {
|
|
|
32654
32730
|
// src/protocol/eip712.ts
|
|
32655
32731
|
var DOMAIN_NAME = "Vana Data Portability";
|
|
32656
32732
|
var DOMAIN_VERSION = "1";
|
|
32733
|
+
var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
32657
32734
|
function buildDomain(chainId, verifyingContract) {
|
|
32658
32735
|
return {
|
|
32659
32736
|
name: DOMAIN_NAME,
|
|
@@ -32662,13 +32739,7 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
32662
32739
|
verifyingContract
|
|
32663
32740
|
};
|
|
32664
32741
|
}
|
|
32665
|
-
function
|
|
32666
|
-
return buildDomain(
|
|
32667
|
-
config.chainId,
|
|
32668
|
-
config.contracts.dataRegistry
|
|
32669
|
-
);
|
|
32670
|
-
}
|
|
32671
|
-
function fileDeletionDomain(config) {
|
|
32742
|
+
function dataRegistryDomain(config) {
|
|
32672
32743
|
return buildDomain(
|
|
32673
32744
|
config.chainId,
|
|
32674
32745
|
config.contracts.dataRegistry
|
|
@@ -32698,31 +32769,26 @@ function builderRegistrationDomain(config) {
|
|
|
32698
32769
|
config.contracts.dataPortabilityGrantees
|
|
32699
32770
|
);
|
|
32700
32771
|
}
|
|
32701
|
-
|
|
32702
|
-
|
|
32703
|
-
|
|
32704
|
-
|
|
32705
|
-
|
|
32706
|
-
|
|
32707
|
-
};
|
|
32708
|
-
var FILE_DELETION_TYPES = {
|
|
32709
|
-
FileDeletion: [
|
|
32710
|
-
{ name: "ownerAddress", type: "address" },
|
|
32711
|
-
{ name: "fileId", type: "bytes32" }
|
|
32712
|
-
]
|
|
32713
|
-
};
|
|
32772
|
+
function escrowPaymentDomain(config) {
|
|
32773
|
+
return buildDomain(
|
|
32774
|
+
config.chainId,
|
|
32775
|
+
config.contracts.dataPortabilityEscrow
|
|
32776
|
+
);
|
|
32777
|
+
}
|
|
32714
32778
|
var GRANT_REGISTRATION_TYPES = {
|
|
32715
32779
|
GrantRegistration: [
|
|
32716
32780
|
{ name: "grantorAddress", type: "address" },
|
|
32717
32781
|
{ name: "granteeId", type: "bytes32" },
|
|
32718
|
-
{ name: "
|
|
32719
|
-
{ name: "
|
|
32782
|
+
{ name: "scopes", type: "string[]" },
|
|
32783
|
+
{ name: "grantVersion", type: "uint256" },
|
|
32784
|
+
{ name: "expiresAt", type: "uint256" }
|
|
32720
32785
|
]
|
|
32721
32786
|
};
|
|
32722
32787
|
var GRANT_REVOCATION_TYPES = {
|
|
32723
32788
|
GrantRevocation: [
|
|
32724
32789
|
{ name: "grantorAddress", type: "address" },
|
|
32725
|
-
{ name: "grantId", type: "bytes32" }
|
|
32790
|
+
{ name: "grantId", type: "bytes32" },
|
|
32791
|
+
{ name: "grantVersion", type: "uint256" }
|
|
32726
32792
|
]
|
|
32727
32793
|
};
|
|
32728
32794
|
var SERVER_REGISTRATION_TYPES = {
|
|
@@ -32741,6 +32807,24 @@ var BUILDER_REGISTRATION_TYPES = {
|
|
|
32741
32807
|
{ name: "appUrl", type: "string" }
|
|
32742
32808
|
]
|
|
32743
32809
|
};
|
|
32810
|
+
var ADD_DATA_TYPES = {
|
|
32811
|
+
AddData: [
|
|
32812
|
+
{ name: "ownerAddress", type: "address" },
|
|
32813
|
+
{ name: "scope", type: "string" },
|
|
32814
|
+
{ name: "dataHash", type: "bytes32" },
|
|
32815
|
+
{ name: "metadataHash", type: "bytes32" },
|
|
32816
|
+
{ name: "expectedVersion", type: "uint256" }
|
|
32817
|
+
]
|
|
32818
|
+
};
|
|
32819
|
+
var RECORD_DATA_ACCESS_TYPES = {
|
|
32820
|
+
RecordDataAccess: [
|
|
32821
|
+
{ name: "ownerAddress", type: "address" },
|
|
32822
|
+
{ name: "scope", type: "string" },
|
|
32823
|
+
{ name: "version", type: "uint256" },
|
|
32824
|
+
{ name: "accessor", type: "address" },
|
|
32825
|
+
{ name: "recordId", type: "bytes32" }
|
|
32826
|
+
]
|
|
32827
|
+
};
|
|
32744
32828
|
|
|
32745
32829
|
// src/protocol/personal-server-registration.ts
|
|
32746
32830
|
var import_viem14 = require("viem");
|
|
@@ -33188,67 +33272,34 @@ function isDataPortabilityGatewayConfig(value) {
|
|
|
33188
33272
|
return false;
|
|
33189
33273
|
}
|
|
33190
33274
|
const c = contracts;
|
|
33191
|
-
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
|
|
33192
|
-
}
|
|
33193
|
-
function parseGrantRegistrationPayload(grant) {
|
|
33194
|
-
let parsed;
|
|
33195
|
-
try {
|
|
33196
|
-
parsed = JSON.parse(grant);
|
|
33197
|
-
} catch {
|
|
33198
|
-
return null;
|
|
33199
|
-
}
|
|
33200
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33201
|
-
return null;
|
|
33202
|
-
}
|
|
33203
|
-
const value = parsed;
|
|
33204
|
-
if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
|
|
33205
|
-
return null;
|
|
33206
|
-
}
|
|
33207
|
-
if (!value["scopes"].every((scope) => typeof scope === "string")) {
|
|
33208
|
-
return null;
|
|
33209
|
-
}
|
|
33210
|
-
if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
|
|
33211
|
-
return null;
|
|
33212
|
-
}
|
|
33213
|
-
if (value["user"] !== void 0 && !isHexString(value["user"])) {
|
|
33214
|
-
return null;
|
|
33215
|
-
}
|
|
33216
|
-
if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
|
|
33217
|
-
return null;
|
|
33218
|
-
}
|
|
33219
|
-
if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
|
|
33220
|
-
return null;
|
|
33221
|
-
}
|
|
33222
|
-
return {
|
|
33223
|
-
user: value["user"],
|
|
33224
|
-
builder: value["builder"],
|
|
33225
|
-
scopes: value["scopes"],
|
|
33226
|
-
expiresAt: value["expiresAt"],
|
|
33227
|
-
nonce: value["nonce"]
|
|
33228
|
-
};
|
|
33275
|
+
return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
|
|
33229
33276
|
}
|
|
33230
|
-
function
|
|
33277
|
+
function toUint256(value) {
|
|
33231
33278
|
try {
|
|
33232
|
-
|
|
33233
|
-
|
|
33234
|
-
|
|
33235
|
-
|
|
33236
|
-
|
|
33279
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
33280
|
+
return null;
|
|
33281
|
+
}
|
|
33282
|
+
const big = typeof value === "bigint" ? value : BigInt(value);
|
|
33283
|
+
if (big < 0n) return null;
|
|
33284
|
+
return big;
|
|
33237
33285
|
} catch {
|
|
33238
33286
|
return null;
|
|
33239
33287
|
}
|
|
33240
33288
|
}
|
|
33241
33289
|
async function verifyGrantRegistration(input) {
|
|
33242
|
-
|
|
33243
|
-
|
|
33244
|
-
|
|
33245
|
-
|
|
33246
|
-
|
|
33247
|
-
};
|
|
33290
|
+
if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
|
|
33291
|
+
return { valid: false, error: "scopes must be a non-empty array" };
|
|
33292
|
+
}
|
|
33293
|
+
if (!input.scopes.every((scope) => typeof scope === "string")) {
|
|
33294
|
+
return { valid: false, error: "scopes must contain only strings" };
|
|
33248
33295
|
}
|
|
33249
|
-
const
|
|
33250
|
-
if (
|
|
33251
|
-
return { valid: false, error: "
|
|
33296
|
+
const grantVersion = toUint256(input.grantVersion);
|
|
33297
|
+
if (grantVersion === null || grantVersion < 1n) {
|
|
33298
|
+
return { valid: false, error: "grantVersion must be a uint256 >= 1" };
|
|
33299
|
+
}
|
|
33300
|
+
const expiresAt = toUint256(input.expiresAt);
|
|
33301
|
+
if (expiresAt === null) {
|
|
33302
|
+
return { valid: false, error: "expiresAt must be a non-negative uint256" };
|
|
33252
33303
|
}
|
|
33253
33304
|
let valid;
|
|
33254
33305
|
try {
|
|
@@ -33260,8 +33311,9 @@ async function verifyGrantRegistration(input) {
|
|
|
33260
33311
|
message: {
|
|
33261
33312
|
grantorAddress: input.grantorAddress,
|
|
33262
33313
|
granteeId: input.granteeId,
|
|
33263
|
-
|
|
33264
|
-
|
|
33314
|
+
scopes: input.scopes,
|
|
33315
|
+
grantVersion,
|
|
33316
|
+
expiresAt
|
|
33265
33317
|
},
|
|
33266
33318
|
signature: input.signature
|
|
33267
33319
|
});
|
|
@@ -33272,26 +33324,269 @@ async function verifyGrantRegistration(input) {
|
|
|
33272
33324
|
return { valid: false, error: "Grant signature does not match grantor" };
|
|
33273
33325
|
}
|
|
33274
33326
|
const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
33275
|
-
if (
|
|
33327
|
+
if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
|
|
33276
33328
|
return { valid: false, error: "Grant has expired" };
|
|
33277
33329
|
}
|
|
33278
|
-
if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
|
|
33279
|
-
return { valid: false, error: "Grant user does not match grantorAddress" };
|
|
33280
|
-
}
|
|
33281
33330
|
return {
|
|
33282
33331
|
valid: true,
|
|
33283
33332
|
grantorAddress: input.grantorAddress,
|
|
33284
33333
|
granteeId: input.granteeId,
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
|
|
33334
|
+
scopes: input.scopes,
|
|
33335
|
+
grantVersion: grantVersion.toString(),
|
|
33336
|
+
expiresAt: expiresAt.toString()
|
|
33288
33337
|
};
|
|
33289
33338
|
}
|
|
33290
33339
|
|
|
33291
|
-
// src/protocol/
|
|
33340
|
+
// src/protocol/fee-registry.ts
|
|
33341
|
+
var import_viem18 = require("viem");
|
|
33342
|
+
var FEE_REGISTRY_ABI = (0, import_viem18.parseAbi)([
|
|
33343
|
+
"struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
|
|
33344
|
+
"function fees(bytes32 operation) view returns (Fee)",
|
|
33345
|
+
"function operationKey(string name) pure returns (bytes32)"
|
|
33346
|
+
]);
|
|
33347
|
+
var REGISTRATION_KIND_FOR_OP = {
|
|
33348
|
+
grant: "grant_registration",
|
|
33349
|
+
data: "data_registration",
|
|
33350
|
+
server: "server_registration",
|
|
33351
|
+
builder: "builder_registration"
|
|
33352
|
+
};
|
|
33353
|
+
function operationNameFor(kind, opts) {
|
|
33354
|
+
switch (kind) {
|
|
33355
|
+
case "grant_registration":
|
|
33356
|
+
return opts?.grantRegistrationOpName ?? "grant_registration";
|
|
33357
|
+
case "data_access":
|
|
33358
|
+
return opts?.dataAccessOpName ?? "data_access";
|
|
33359
|
+
case "data_registration":
|
|
33360
|
+
return opts?.dataRegistrationOpName ?? "data_registration";
|
|
33361
|
+
case "server_registration":
|
|
33362
|
+
return opts?.serverRegistrationOpName ?? "server_registration";
|
|
33363
|
+
case "builder_registration":
|
|
33364
|
+
return opts?.builderRegistrationOpName ?? "builder_registration";
|
|
33365
|
+
}
|
|
33366
|
+
}
|
|
33367
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
33368
|
+
async function getFee(client, config, kind, opts) {
|
|
33369
|
+
const address = config.contracts.feeRegistry;
|
|
33370
|
+
const opName = operationNameFor(kind, opts);
|
|
33371
|
+
const opKey = await client.readContract({
|
|
33372
|
+
address,
|
|
33373
|
+
abi: FEE_REGISTRY_ABI,
|
|
33374
|
+
functionName: "operationKey",
|
|
33375
|
+
args: [opName]
|
|
33376
|
+
});
|
|
33377
|
+
const fee = await client.readContract({
|
|
33378
|
+
address,
|
|
33379
|
+
abi: FEE_REGISTRY_ABI,
|
|
33380
|
+
functionName: "fees",
|
|
33381
|
+
args: [opKey]
|
|
33382
|
+
});
|
|
33383
|
+
if (fee.enabled && fee.payee === ZERO_ADDRESS) {
|
|
33384
|
+
throw new Error(
|
|
33385
|
+
`FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
|
|
33386
|
+
);
|
|
33387
|
+
}
|
|
33388
|
+
return fee;
|
|
33389
|
+
}
|
|
33390
|
+
async function getOpFee(client, config, opType, opts) {
|
|
33391
|
+
const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
|
|
33392
|
+
if (!registrationKind) {
|
|
33393
|
+
throw new Error(
|
|
33394
|
+
`getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
|
|
33395
|
+
);
|
|
33396
|
+
}
|
|
33397
|
+
const includeDataAccess = opType === "grant";
|
|
33398
|
+
const [registration, dataAccess] = await Promise.all([
|
|
33399
|
+
getFee(client, config, registrationKind, opts),
|
|
33400
|
+
includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
|
|
33401
|
+
amount: 0n,
|
|
33402
|
+
asset: ZERO_ADDRESS,
|
|
33403
|
+
payee: ZERO_ADDRESS,
|
|
33404
|
+
enabled: false
|
|
33405
|
+
})
|
|
33406
|
+
]);
|
|
33407
|
+
if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
|
|
33408
|
+
throw new Error(
|
|
33409
|
+
`FeeRegistry asset mismatch for "${opType}": registration=${registration.asset} vs data_access=${dataAccess.asset}. The gateway requires both kinds to settle in the same asset when both are enabled.`
|
|
33410
|
+
);
|
|
33411
|
+
}
|
|
33412
|
+
const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
|
|
33413
|
+
return {
|
|
33414
|
+
asset,
|
|
33415
|
+
registrationFee: registration.enabled ? registration.amount : 0n,
|
|
33416
|
+
dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
|
|
33417
|
+
registrationEnabled: registration.enabled,
|
|
33418
|
+
dataAccessEnabled: dataAccess.enabled,
|
|
33419
|
+
registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
|
|
33420
|
+
dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
|
|
33421
|
+
};
|
|
33422
|
+
}
|
|
33423
|
+
|
|
33424
|
+
// src/protocol/escrow-deposit.ts
|
|
33425
|
+
var import_viem19 = require("viem");
|
|
33426
|
+
var ESCROW_DEPOSIT_ABI = [
|
|
33427
|
+
{
|
|
33428
|
+
type: "function",
|
|
33429
|
+
name: "depositNative",
|
|
33430
|
+
stateMutability: "payable",
|
|
33431
|
+
inputs: [{ name: "account", type: "address" }],
|
|
33432
|
+
outputs: []
|
|
33433
|
+
},
|
|
33434
|
+
{
|
|
33435
|
+
type: "function",
|
|
33436
|
+
name: "depositToken",
|
|
33437
|
+
stateMutability: "nonpayable",
|
|
33438
|
+
inputs: [
|
|
33439
|
+
{ name: "account", type: "address" },
|
|
33440
|
+
{ name: "token", type: "address" },
|
|
33441
|
+
{ name: "amount", type: "uint256" }
|
|
33442
|
+
],
|
|
33443
|
+
outputs: []
|
|
33444
|
+
}
|
|
33445
|
+
];
|
|
33446
|
+
function escrowContractAddress(config) {
|
|
33447
|
+
return config.contracts.dataPortabilityEscrow;
|
|
33448
|
+
}
|
|
33449
|
+
function encodeDepositNativeData(input) {
|
|
33450
|
+
return (0, import_viem19.encodeFunctionData)({
|
|
33451
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33452
|
+
functionName: "depositNative",
|
|
33453
|
+
args: [input.account]
|
|
33454
|
+
});
|
|
33455
|
+
}
|
|
33456
|
+
function encodeDepositTokenData(input) {
|
|
33457
|
+
return (0, import_viem19.encodeFunctionData)({
|
|
33458
|
+
abi: ESCROW_DEPOSIT_ABI,
|
|
33459
|
+
functionName: "depositToken",
|
|
33460
|
+
args: [input.account, input.token, input.amount]
|
|
33461
|
+
});
|
|
33462
|
+
}
|
|
33463
|
+
function buildDepositNativeRequest(config, input) {
|
|
33464
|
+
return {
|
|
33465
|
+
to: escrowContractAddress(config),
|
|
33466
|
+
data: encodeDepositNativeData({ account: input.account }),
|
|
33467
|
+
value: input.amount
|
|
33468
|
+
};
|
|
33469
|
+
}
|
|
33470
|
+
function buildDepositTokenRequest(config, input) {
|
|
33471
|
+
return {
|
|
33472
|
+
to: escrowContractAddress(config),
|
|
33473
|
+
data: encodeDepositTokenData(input)
|
|
33474
|
+
};
|
|
33475
|
+
}
|
|
33476
|
+
|
|
33477
|
+
// src/protocol/data-point-status.ts
|
|
33478
|
+
var import_viem20 = require("viem");
|
|
33479
|
+
var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
|
|
33480
|
+
DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
|
|
33481
|
+
DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
|
|
33482
|
+
DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
|
|
33483
|
+
DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
|
|
33484
|
+
return DataPointStatus2;
|
|
33485
|
+
})(DataPointStatus || {});
|
|
33486
|
+
var DATA_REGISTRY_STATUS_ABI = [
|
|
33487
|
+
{
|
|
33488
|
+
type: "function",
|
|
33489
|
+
name: "setStatus",
|
|
33490
|
+
stateMutability: "nonpayable",
|
|
33491
|
+
inputs: [
|
|
33492
|
+
{ name: "scope", type: "string" },
|
|
33493
|
+
{ name: "newStatus", type: "uint8" }
|
|
33494
|
+
],
|
|
33495
|
+
outputs: []
|
|
33496
|
+
}
|
|
33497
|
+
];
|
|
33498
|
+
function dataRegistryContractAddress(config) {
|
|
33499
|
+
return config.contracts.dataRegistry;
|
|
33500
|
+
}
|
|
33501
|
+
function encodeSetDataPointStatusData(input) {
|
|
33502
|
+
return (0, import_viem20.encodeFunctionData)({
|
|
33503
|
+
abi: DATA_REGISTRY_STATUS_ABI,
|
|
33504
|
+
functionName: "setStatus",
|
|
33505
|
+
args: [input.scope, input.status]
|
|
33506
|
+
});
|
|
33507
|
+
}
|
|
33508
|
+
function buildSetDataPointStatusRequest(config, input) {
|
|
33509
|
+
return {
|
|
33510
|
+
to: dataRegistryContractAddress(config),
|
|
33511
|
+
data: encodeSetDataPointStatusData(input)
|
|
33512
|
+
};
|
|
33513
|
+
}
|
|
33514
|
+
function buildMarkDataPointUnavailableRequest(config, input) {
|
|
33515
|
+
return buildSetDataPointStatusRequest(config, {
|
|
33516
|
+
scope: input.scope,
|
|
33517
|
+
status: 3 /* Unavailable */
|
|
33518
|
+
});
|
|
33519
|
+
}
|
|
33520
|
+
|
|
33521
|
+
// src/protocol/data-file.ts
|
|
33292
33522
|
var import_zod = require("zod");
|
|
33523
|
+
var DataFileEnvelopeSchema = import_zod.z.object({
|
|
33524
|
+
$schema: import_zod.z.string().url().optional(),
|
|
33525
|
+
version: import_zod.z.literal("1.0"),
|
|
33526
|
+
scope: import_zod.z.string(),
|
|
33527
|
+
schemaId: import_zod.z.string().optional(),
|
|
33528
|
+
collectedAt: import_zod.z.string().datetime(),
|
|
33529
|
+
data: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())
|
|
33530
|
+
});
|
|
33531
|
+
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33532
|
+
return {
|
|
33533
|
+
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
33534
|
+
...schemaId !== void 0 && { schemaId },
|
|
33535
|
+
version: "1.0",
|
|
33536
|
+
scope,
|
|
33537
|
+
collectedAt,
|
|
33538
|
+
data
|
|
33539
|
+
};
|
|
33540
|
+
}
|
|
33541
|
+
var IngestResponseSchema = import_zod.z.object({
|
|
33542
|
+
scope: import_zod.z.string(),
|
|
33543
|
+
collectedAt: import_zod.z.string().datetime(),
|
|
33544
|
+
status: import_zod.z.enum(["stored", "syncing"])
|
|
33545
|
+
});
|
|
33546
|
+
|
|
33547
|
+
// src/protocol/personal-server-data.ts
|
|
33548
|
+
function personalServerDataReadPath(scope) {
|
|
33549
|
+
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
33550
|
+
}
|
|
33551
|
+
async function buildPersonalServerDataReadRequest(params) {
|
|
33552
|
+
const path = personalServerDataReadPath(params.scope);
|
|
33553
|
+
const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
|
|
33554
|
+
const audience = params.audience ?? baseUrl;
|
|
33555
|
+
const headers = new Headers(params.headers);
|
|
33556
|
+
headers.set(
|
|
33557
|
+
"Authorization",
|
|
33558
|
+
await buildWeb3SignedHeader({
|
|
33559
|
+
aud: audience,
|
|
33560
|
+
grantId: params.grantId,
|
|
33561
|
+
method: "GET",
|
|
33562
|
+
signMessage: params.signMessage,
|
|
33563
|
+
uri: path
|
|
33564
|
+
})
|
|
33565
|
+
);
|
|
33566
|
+
return new Request(`${baseUrl}${path}`, {
|
|
33567
|
+
headers,
|
|
33568
|
+
method: "GET"
|
|
33569
|
+
});
|
|
33570
|
+
}
|
|
33571
|
+
async function readPersonalServerData(params) {
|
|
33572
|
+
const fetchFn = params.fetch ?? globalThis.fetch;
|
|
33573
|
+
if (fetchFn === void 0) {
|
|
33574
|
+
throw new Error("No fetch implementation available");
|
|
33575
|
+
}
|
|
33576
|
+
const request = await buildPersonalServerDataReadRequest(params);
|
|
33577
|
+
const response = await fetchFn(request);
|
|
33578
|
+
if (!response.ok) {
|
|
33579
|
+
throw new Error(
|
|
33580
|
+
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
33581
|
+
);
|
|
33582
|
+
}
|
|
33583
|
+
return DataFileEnvelopeSchema.parse(await response.json());
|
|
33584
|
+
}
|
|
33585
|
+
|
|
33586
|
+
// src/protocol/scopes.ts
|
|
33587
|
+
var import_zod2 = require("zod");
|
|
33293
33588
|
var SEGMENT_RE = /^[a-z0-9][a-z0-9_]*$/;
|
|
33294
|
-
var ScopeSchema =
|
|
33589
|
+
var ScopeSchema = import_zod2.z.string().refine(
|
|
33295
33590
|
(scope) => {
|
|
33296
33591
|
const parts = scope.split(".");
|
|
33297
33592
|
return parts.length >= 2 && parts.length <= 3 && parts.every((part) => SEGMENT_RE.test(part));
|
|
@@ -33332,32 +33627,6 @@ function scopeCoveredByGrant(requestedScope, grantedScopes) {
|
|
|
33332
33627
|
);
|
|
33333
33628
|
}
|
|
33334
33629
|
|
|
33335
|
-
// src/protocol/data-file.ts
|
|
33336
|
-
var import_zod2 = require("zod");
|
|
33337
|
-
var DataFileEnvelopeSchema = import_zod2.z.object({
|
|
33338
|
-
$schema: import_zod2.z.string().url().optional(),
|
|
33339
|
-
version: import_zod2.z.literal("1.0"),
|
|
33340
|
-
scope: import_zod2.z.string(),
|
|
33341
|
-
schemaId: import_zod2.z.string().optional(),
|
|
33342
|
-
collectedAt: import_zod2.z.string().datetime(),
|
|
33343
|
-
data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown())
|
|
33344
|
-
});
|
|
33345
|
-
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33346
|
-
return {
|
|
33347
|
-
...schemaUrl !== void 0 && { $schema: schemaUrl },
|
|
33348
|
-
...schemaId !== void 0 && { schemaId },
|
|
33349
|
-
version: "1.0",
|
|
33350
|
-
scope,
|
|
33351
|
-
collectedAt,
|
|
33352
|
-
data
|
|
33353
|
-
};
|
|
33354
|
-
}
|
|
33355
|
-
var IngestResponseSchema = import_zod2.z.object({
|
|
33356
|
-
scope: import_zod2.z.string(),
|
|
33357
|
-
collectedAt: import_zod2.z.string().datetime(),
|
|
33358
|
-
status: import_zod2.z.enum(["stored", "syncing"])
|
|
33359
|
-
});
|
|
33360
|
-
|
|
33361
33630
|
// src/protocol/gateway.ts
|
|
33362
33631
|
function createGatewayClient(baseUrl) {
|
|
33363
33632
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -33365,16 +33634,6 @@ function createGatewayClient(baseUrl) {
|
|
|
33365
33634
|
const envelope = await res.json();
|
|
33366
33635
|
return envelope.data;
|
|
33367
33636
|
}
|
|
33368
|
-
function normalizeFileRecord(record) {
|
|
33369
|
-
return {
|
|
33370
|
-
fileId: record.fileId ?? record.id ?? "",
|
|
33371
|
-
owner: record.owner ?? record.ownerAddress ?? "",
|
|
33372
|
-
url: record.url,
|
|
33373
|
-
schemaId: record.schemaId,
|
|
33374
|
-
createdAt: record.createdAt ?? record.addedAt ?? "",
|
|
33375
|
-
deletedAt: record.deletedAt ?? null
|
|
33376
|
-
};
|
|
33377
|
-
}
|
|
33378
33637
|
function getMutationId(body, key) {
|
|
33379
33638
|
const value = body[key] ?? body["id"];
|
|
33380
33639
|
return typeof value === "string" ? value : void 0;
|
|
@@ -33424,31 +33683,33 @@ function createGatewayClient(baseUrl) {
|
|
|
33424
33683
|
}
|
|
33425
33684
|
return unwrapEnvelope(res);
|
|
33426
33685
|
},
|
|
33427
|
-
async
|
|
33428
|
-
const res = await fetch(`${base}/v1/
|
|
33686
|
+
async getDataPoint(dataPointId) {
|
|
33687
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}`);
|
|
33429
33688
|
if (res.status === 404) return null;
|
|
33430
33689
|
if (!res.ok) {
|
|
33431
33690
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33432
33691
|
}
|
|
33433
|
-
return
|
|
33692
|
+
return unwrapEnvelope(res);
|
|
33434
33693
|
},
|
|
33435
|
-
async
|
|
33694
|
+
async listDataPointsByOwner(owner, cursor, options) {
|
|
33436
33695
|
const params = new URLSearchParams({ user: owner });
|
|
33437
33696
|
if (cursor !== null) {
|
|
33438
33697
|
params.set("cursor", cursor);
|
|
33439
33698
|
}
|
|
33440
|
-
if (options?.
|
|
33441
|
-
params.set("
|
|
33699
|
+
if (options?.since) {
|
|
33700
|
+
params.set("since", options.since);
|
|
33701
|
+
}
|
|
33702
|
+
if (options?.limit !== void 0) {
|
|
33703
|
+
params.set("limit", String(options.limit));
|
|
33442
33704
|
}
|
|
33443
|
-
const res = await fetch(`${base}/v1/
|
|
33705
|
+
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
33444
33706
|
if (!res.ok) {
|
|
33445
33707
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33446
33708
|
}
|
|
33447
33709
|
const envelope = await res.json();
|
|
33448
|
-
const
|
|
33449
|
-
const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
|
|
33710
|
+
const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
|
|
33450
33711
|
return {
|
|
33451
|
-
|
|
33712
|
+
dataPoints: envelope.data.dataPoints,
|
|
33452
33713
|
cursor: nextCursor
|
|
33453
33714
|
};
|
|
33454
33715
|
},
|
|
@@ -33490,8 +33751,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33490
33751
|
alreadyRegistered: false
|
|
33491
33752
|
};
|
|
33492
33753
|
},
|
|
33493
|
-
async
|
|
33494
|
-
const res = await fetch(`${base}/v1/
|
|
33754
|
+
async registerBuilder(params) {
|
|
33755
|
+
const res = await fetch(`${base}/v1/builders`, {
|
|
33495
33756
|
method: "POST",
|
|
33496
33757
|
headers: {
|
|
33497
33758
|
"Content-Type": "application/json",
|
|
@@ -33499,22 +33760,57 @@ function createGatewayClient(baseUrl) {
|
|
|
33499
33760
|
},
|
|
33500
33761
|
body: JSON.stringify({
|
|
33501
33762
|
ownerAddress: params.ownerAddress,
|
|
33502
|
-
|
|
33503
|
-
|
|
33763
|
+
granteeAddress: params.granteeAddress,
|
|
33764
|
+
publicKey: params.publicKey,
|
|
33765
|
+
appUrl: params.appUrl
|
|
33504
33766
|
})
|
|
33505
33767
|
});
|
|
33506
33768
|
if (res.status === 409) {
|
|
33507
33769
|
const body2 = await res.json().catch(() => ({}));
|
|
33508
33770
|
return {
|
|
33509
|
-
|
|
33771
|
+
builderId: getMutationId(
|
|
33772
|
+
body2,
|
|
33773
|
+
"builderId"
|
|
33774
|
+
),
|
|
33775
|
+
alreadyRegistered: true
|
|
33510
33776
|
};
|
|
33511
33777
|
}
|
|
33512
33778
|
if (!res.ok) {
|
|
33513
33779
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33514
33780
|
}
|
|
33515
|
-
const body = await res.json();
|
|
33781
|
+
const body = await res.json().catch(() => ({}));
|
|
33516
33782
|
return {
|
|
33517
|
-
|
|
33783
|
+
builderId: getMutationId(body, "builderId"),
|
|
33784
|
+
alreadyRegistered: false
|
|
33785
|
+
};
|
|
33786
|
+
},
|
|
33787
|
+
async registerDataPoint(params) {
|
|
33788
|
+
const res = await fetch(`${base}/v1/data`, {
|
|
33789
|
+
method: "POST",
|
|
33790
|
+
headers: {
|
|
33791
|
+
"Content-Type": "application/json",
|
|
33792
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
33793
|
+
},
|
|
33794
|
+
body: JSON.stringify({
|
|
33795
|
+
ownerAddress: params.ownerAddress,
|
|
33796
|
+
scope: params.scope,
|
|
33797
|
+
dataHash: params.dataHash,
|
|
33798
|
+
metadataHash: params.metadataHash,
|
|
33799
|
+
expectedVersion: params.expectedVersion
|
|
33800
|
+
})
|
|
33801
|
+
});
|
|
33802
|
+
if (!res.ok) {
|
|
33803
|
+
const body2 = await res.json().catch(() => ({}));
|
|
33804
|
+
const detail = body2.error ?? res.statusText;
|
|
33805
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
33806
|
+
}
|
|
33807
|
+
const body = await res.json().catch(() => ({}));
|
|
33808
|
+
return {
|
|
33809
|
+
dataPointId: getMutationId(
|
|
33810
|
+
body,
|
|
33811
|
+
"dataPointId"
|
|
33812
|
+
),
|
|
33813
|
+
expectedVersion: body.expectedVersion
|
|
33518
33814
|
};
|
|
33519
33815
|
},
|
|
33520
33816
|
async createGrant(params) {
|
|
@@ -33527,8 +33823,9 @@ function createGatewayClient(baseUrl) {
|
|
|
33527
33823
|
body: JSON.stringify({
|
|
33528
33824
|
grantorAddress: params.grantorAddress,
|
|
33529
33825
|
granteeId: params.granteeId,
|
|
33530
|
-
|
|
33531
|
-
|
|
33826
|
+
scopes: params.scopes,
|
|
33827
|
+
grantVersion: params.grantVersion,
|
|
33828
|
+
expiresAt: params.expiresAt
|
|
33532
33829
|
})
|
|
33533
33830
|
});
|
|
33534
33831
|
if (res.status === 409) {
|
|
@@ -33553,7 +33850,8 @@ function createGatewayClient(baseUrl) {
|
|
|
33553
33850
|
Authorization: `Web3Signed ${params.signature}`
|
|
33554
33851
|
},
|
|
33555
33852
|
body: JSON.stringify({
|
|
33556
|
-
grantorAddress: params.grantorAddress
|
|
33853
|
+
grantorAddress: params.grantorAddress,
|
|
33854
|
+
grantVersion: params.grantVersion
|
|
33557
33855
|
})
|
|
33558
33856
|
});
|
|
33559
33857
|
if (res.status === 409) return;
|
|
@@ -33561,21 +33859,62 @@ function createGatewayClient(baseUrl) {
|
|
|
33561
33859
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33562
33860
|
}
|
|
33563
33861
|
},
|
|
33564
|
-
async
|
|
33565
|
-
const res = await fetch(`${base}/v1/
|
|
33566
|
-
|
|
33862
|
+
async getEscrowBalance(account) {
|
|
33863
|
+
const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
|
|
33864
|
+
if (!res.ok) {
|
|
33865
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33866
|
+
}
|
|
33867
|
+
return await res.json();
|
|
33868
|
+
},
|
|
33869
|
+
async submitEscrowDeposit(params) {
|
|
33870
|
+
const res = await fetch(`${base}/v1/escrow/deposit`, {
|
|
33871
|
+
method: "POST",
|
|
33872
|
+
headers: { "Content-Type": "application/json" },
|
|
33873
|
+
body: JSON.stringify({ txHash: params.txHash })
|
|
33874
|
+
});
|
|
33875
|
+
if (res.status !== 200 && res.status !== 202) {
|
|
33876
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33877
|
+
}
|
|
33878
|
+
return await res.json();
|
|
33879
|
+
},
|
|
33880
|
+
async payForOperation(params) {
|
|
33881
|
+
const body = {
|
|
33882
|
+
payerAddress: params.payerAddress,
|
|
33883
|
+
opType: params.opType,
|
|
33884
|
+
opId: params.opId,
|
|
33885
|
+
asset: params.asset,
|
|
33886
|
+
amount: params.amount,
|
|
33887
|
+
paymentNonce: params.paymentNonce
|
|
33888
|
+
};
|
|
33889
|
+
if (params.accessRecord) {
|
|
33890
|
+
body["accessRecord"] = params.accessRecord;
|
|
33891
|
+
}
|
|
33892
|
+
const res = await fetch(`${base}/v1/escrow/pay`, {
|
|
33893
|
+
method: "POST",
|
|
33567
33894
|
headers: {
|
|
33568
33895
|
"Content-Type": "application/json",
|
|
33569
33896
|
Authorization: `Web3Signed ${params.signature}`
|
|
33570
33897
|
},
|
|
33571
|
-
body: JSON.stringify(
|
|
33572
|
-
ownerAddress: params.ownerAddress
|
|
33573
|
-
})
|
|
33898
|
+
body: JSON.stringify(body)
|
|
33574
33899
|
});
|
|
33575
|
-
if (res.status === 409) return;
|
|
33576
33900
|
if (!res.ok) {
|
|
33577
33901
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33578
33902
|
}
|
|
33903
|
+
return await res.json();
|
|
33904
|
+
},
|
|
33905
|
+
async settle(params) {
|
|
33906
|
+
const res = await fetch(`${base}/v1/settle`, {
|
|
33907
|
+
method: "POST",
|
|
33908
|
+
headers: { "Content-Type": "application/json" },
|
|
33909
|
+
// The gateway accepts an empty body; only `limit` is recognised.
|
|
33910
|
+
// Always send a JSON body so the gateway's req.body shape parse
|
|
33911
|
+
// doesn't have to deal with an undefined.
|
|
33912
|
+
body: JSON.stringify(params ?? {})
|
|
33913
|
+
});
|
|
33914
|
+
if (!res.ok) {
|
|
33915
|
+
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33916
|
+
}
|
|
33917
|
+
return await res.json();
|
|
33579
33918
|
}
|
|
33580
33919
|
};
|
|
33581
33920
|
}
|
|
@@ -33599,7 +33938,7 @@ function genericPaymentDomain(chainId, escrowContract) {
|
|
|
33599
33938
|
verifyingContract: escrowContract
|
|
33600
33939
|
};
|
|
33601
33940
|
}
|
|
33602
|
-
var
|
|
33941
|
+
var ESCROW_DEPOSIT_ABI2 = [
|
|
33603
33942
|
{
|
|
33604
33943
|
type: "function",
|
|
33605
33944
|
name: "depositNative",
|
|
@@ -33757,6 +34096,7 @@ async function parsePSError(response) {
|
|
|
33757
34096
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33758
34097
|
0 && (module.exports = {
|
|
33759
34098
|
ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
|
|
34099
|
+
ADD_DATA_TYPES,
|
|
33760
34100
|
AccountPersonalServerLiteOwnerBindingError,
|
|
33761
34101
|
AccountPersonalServerRegistrationError,
|
|
33762
34102
|
BUILDER_REGISTRATION_TYPES,
|
|
@@ -33766,13 +34106,14 @@ async function parsePSError(response) {
|
|
|
33766
34106
|
CallbackStorage,
|
|
33767
34107
|
ContractFactory,
|
|
33768
34108
|
ContractNotFoundError,
|
|
34109
|
+
DATA_REGISTRY_STATUS_ABI,
|
|
33769
34110
|
DataFileEnvelopeSchema,
|
|
34111
|
+
DataPointStatus,
|
|
33770
34112
|
DropboxStorage,
|
|
33771
34113
|
ECIESError,
|
|
33772
34114
|
ESCROW_DEPOSIT_ABI,
|
|
33773
34115
|
ExpiredTokenError,
|
|
33774
|
-
|
|
33775
|
-
FILE_REGISTRATION_TYPES,
|
|
34116
|
+
FEE_REGISTRY_ABI,
|
|
33776
34117
|
GENERIC_PAYMENT_TYPES,
|
|
33777
34118
|
GRANT_REGISTRATION_TYPES,
|
|
33778
34119
|
GRANT_REVOCATION_TYPES,
|
|
@@ -33785,6 +34126,7 @@ async function parsePSError(response) {
|
|
|
33785
34126
|
MASTER_KEY_MESSAGE,
|
|
33786
34127
|
MissingAuthError,
|
|
33787
34128
|
NATIVE_ASSET_ADDRESS,
|
|
34129
|
+
NATIVE_VANA_ASSET,
|
|
33788
34130
|
NetworkError,
|
|
33789
34131
|
NodeECIESProvider,
|
|
33790
34132
|
NodePlatformAdapter,
|
|
@@ -33802,6 +34144,8 @@ async function parsePSError(response) {
|
|
|
33802
34144
|
PersonalServerError,
|
|
33803
34145
|
PinataStorage,
|
|
33804
34146
|
R2Storage,
|
|
34147
|
+
RECORD_DATA_ACCESS_TYPES,
|
|
34148
|
+
REGISTRATION_KIND_FOR_OP,
|
|
33805
34149
|
ReadOnlyError,
|
|
33806
34150
|
RelayerError,
|
|
33807
34151
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -33816,10 +34160,15 @@ async function parsePSError(response) {
|
|
|
33816
34160
|
VanaError,
|
|
33817
34161
|
VanaStorage,
|
|
33818
34162
|
assertValidPkceVerifier,
|
|
34163
|
+
buildDepositNativeRequest,
|
|
34164
|
+
buildDepositTokenRequest,
|
|
34165
|
+
buildMarkDataPointUnavailableRequest,
|
|
34166
|
+
buildPersonalServerDataReadRequest,
|
|
33819
34167
|
buildPersonalServerLiteOwnerBindingMessage,
|
|
33820
34168
|
buildPersonalServerLiteOwnerBindingSignature,
|
|
33821
34169
|
buildPersonalServerRegistrationSignature,
|
|
33822
34170
|
buildPersonalServerRegistrationTypedData,
|
|
34171
|
+
buildSetDataPointStatusRequest,
|
|
33823
34172
|
buildWeb3SignedHeader,
|
|
33824
34173
|
builderRegistrationDomain,
|
|
33825
34174
|
chains,
|
|
@@ -33838,14 +34187,19 @@ async function parsePSError(response) {
|
|
|
33838
34187
|
createVanaStorageProvider,
|
|
33839
34188
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
33840
34189
|
createViemPersonalServerRegistrationSigner,
|
|
34190
|
+
dataRegistryContractAddress,
|
|
34191
|
+
dataRegistryDomain,
|
|
33841
34192
|
decryptWithPassword,
|
|
33842
34193
|
deriveMasterKey,
|
|
33843
34194
|
deriveScopeKey,
|
|
33844
34195
|
deserializeECIES,
|
|
33845
34196
|
detectPlatform,
|
|
34197
|
+
encodeDepositNativeData,
|
|
34198
|
+
encodeDepositTokenData,
|
|
34199
|
+
encodeSetDataPointStatusData,
|
|
33846
34200
|
encryptWithPassword,
|
|
33847
|
-
|
|
33848
|
-
|
|
34201
|
+
escrowContractAddress,
|
|
34202
|
+
escrowPaymentDomain,
|
|
33849
34203
|
generatePkceVerifier,
|
|
33850
34204
|
genericPaymentDomain,
|
|
33851
34205
|
getAbi,
|
|
@@ -33854,6 +34208,8 @@ async function parsePSError(response) {
|
|
|
33854
34208
|
getContractAddress,
|
|
33855
34209
|
getContractController,
|
|
33856
34210
|
getContractInfo,
|
|
34211
|
+
getFee,
|
|
34212
|
+
getOpFee,
|
|
33857
34213
|
getPlatformCapabilities,
|
|
33858
34214
|
getServiceEndpoints,
|
|
33859
34215
|
grantRegistrationDomain,
|
|
@@ -33865,11 +34221,12 @@ async function parsePSError(response) {
|
|
|
33865
34221
|
moksha,
|
|
33866
34222
|
mokshaServices,
|
|
33867
34223
|
mokshaTestnet,
|
|
33868
|
-
parseGrantRegistrationPayload,
|
|
33869
34224
|
parsePSError,
|
|
33870
34225
|
parseScope,
|
|
33871
34226
|
parseWeb3SignedHeader,
|
|
34227
|
+
personalServerDataReadPath,
|
|
33872
34228
|
personalServerRegistrationDomain,
|
|
34229
|
+
readPersonalServerData,
|
|
33873
34230
|
recoverServerOwner,
|
|
33874
34231
|
registerPersonalServerSignature,
|
|
33875
34232
|
scopeCoveredByGrant,
|