@opendatalabs/vana-sdk 3.16.0 → 3.18.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/README.md +107 -0
- package/dist/direct/personal-server-read.cjs +20 -1
- package/dist/direct/personal-server-read.cjs.map +1 -1
- package/dist/direct/personal-server-read.js +23 -1
- package/dist/direct/personal-server-read.js.map +1 -1
- package/dist/errors.cjs +121 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +190 -0
- package/dist/errors.js +106 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.browser.d.ts +5 -1
- package/dist/index.browser.js +1449 -58
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +1501 -59
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +5 -1
- package/dist/index.node.js +1449 -58
- package/dist/index.node.js.map +4 -4
- package/dist/protocol/data-point-deletion.cjs +220 -0
- package/dist/protocol/data-point-deletion.cjs.map +1 -0
- package/dist/protocol/data-point-deletion.d.ts +180 -0
- package/dist/protocol/data-point-deletion.js +193 -0
- package/dist/protocol/data-point-deletion.js.map +1 -0
- package/dist/protocol/data-point-deletion.test.d.ts +1 -0
- package/dist/protocol/gateway.cjs +145 -32
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +42 -3
- package/dist/protocol/gateway.js +156 -32
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/lineage.cjs +287 -0
- package/dist/protocol/lineage.cjs.map +1 -0
- package/dist/protocol/lineage.d.ts +228 -0
- package/dist/protocol/lineage.js +258 -0
- package/dist/protocol/lineage.js.map +1 -0
- package/dist/protocol/lineage.test.d.ts +1 -0
- package/dist/protocol/personal-server-data.cjs +20 -1
- package/dist/protocol/personal-server-data.cjs.map +1 -1
- package/dist/protocol/personal-server-data.js +23 -1
- package/dist/protocol/personal-server-data.js.map +1 -1
- package/dist/protocol/personal-server-error-body.cjs +57 -0
- package/dist/protocol/personal-server-error-body.cjs.map +1 -0
- package/dist/protocol/personal-server-error-body.d.ts +18 -0
- package/dist/protocol/personal-server-error-body.js +32 -0
- package/dist/protocol/personal-server-error-body.js.map +1 -0
- package/dist/protocol/personal-server-write.cjs +623 -0
- package/dist/protocol/personal-server-write.cjs.map +1 -0
- package/dist/protocol/personal-server-write.d.ts +284 -0
- package/dist/protocol/personal-server-write.js +601 -0
- package/dist/protocol/personal-server-write.js.map +1 -0
- package/dist/protocol/personal-server-write.test.d.ts +1 -0
- package/dist/protocol/write-signer.cjs +67 -0
- package/dist/protocol/write-signer.cjs.map +1 -0
- package/dist/protocol/write-signer.d.ts +59 -0
- package/dist/protocol/write-signer.js +43 -0
- package/dist/protocol/write-signer.js.map +1 -0
- package/dist/protocol/write-signer.test.d.ts +1 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/providers/vana-storage.cjs +66 -0
- package/dist/storage/providers/vana-storage.cjs.map +1 -1
- package/dist/storage/providers/vana-storage.d.ts +26 -0
- package/dist/storage/providers/vana-storage.js +66 -0
- package/dist/storage/providers/vana-storage.js.map +1 -1
- package/dist/tests/mock-personal-server.d.ts +127 -0
- package/dist/utils/response-body.cjs +46 -0
- package/dist/utils/response-body.cjs.map +1 -0
- package/dist/utils/response-body.d.ts +26 -0
- package/dist/utils/response-body.js +20 -0
- package/dist/utils/response-body.js.map +1 -0
- package/dist/utils/response-body.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -1187,7 +1187,10 @@ __export(index_node_exports, {
|
|
|
1187
1187
|
DATA_ACCESS_OP_TYPE: () => DATA_ACCESS_OP_TYPE,
|
|
1188
1188
|
DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
|
|
1189
1189
|
DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
|
|
1190
|
+
DataPointDeletedError: () => DataPointDeletedError,
|
|
1191
|
+
DataPointNotFoundError: () => DataPointNotFoundError,
|
|
1190
1192
|
DataPointStatus: () => DataPointStatus,
|
|
1193
|
+
DataPointVersionConflictError: () => DataPointVersionConflictError,
|
|
1191
1194
|
DropboxStorage: () => DropboxStorage,
|
|
1192
1195
|
ECIESError: () => ECIESError,
|
|
1193
1196
|
ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI2,
|
|
@@ -1204,7 +1207,14 @@ __export(index_node_exports, {
|
|
|
1204
1207
|
InvalidScopeEntryError: () => InvalidScopeEntryError,
|
|
1205
1208
|
InvalidSignatureError: () => InvalidSignatureError,
|
|
1206
1209
|
IpfsStorage: () => IpfsStorage,
|
|
1210
|
+
LINEAGE_FIELD: () => LINEAGE_FIELD,
|
|
1211
|
+
LINEAGE_KEY: () => LINEAGE_KEY,
|
|
1212
|
+
LineageEntrySchema: () => LineageEntrySchema,
|
|
1213
|
+
LineageGraphSchema: () => LineageGraphSchema,
|
|
1214
|
+
LineageNodeSchema: () => LineageNodeSchema,
|
|
1215
|
+
LineageReadError: () => LineageReadError,
|
|
1207
1216
|
MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
|
|
1217
|
+
MAX_LINEAGE_SOURCES: () => MAX_LINEAGE_SOURCES,
|
|
1208
1218
|
MissingAuthError: () => MissingAuthError,
|
|
1209
1219
|
NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
|
|
1210
1220
|
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
@@ -1223,11 +1233,14 @@ __export(index_node_exports, {
|
|
|
1223
1233
|
PSError: () => PSError,
|
|
1224
1234
|
PermissionError: () => PermissionError,
|
|
1225
1235
|
PersonalServerError: () => PersonalServerError,
|
|
1236
|
+
PersonalServerWriteError: () => PersonalServerWriteError,
|
|
1226
1237
|
PinataStorage: () => PinataStorage,
|
|
1227
1238
|
R2Storage: () => R2Storage,
|
|
1228
1239
|
RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
|
|
1229
1240
|
REGISTRATION_KIND_FOR_OP: () => REGISTRATION_KIND_FOR_OP,
|
|
1241
|
+
RESERVED_WRITE_KEYS: () => RESERVED_WRITE_KEYS,
|
|
1230
1242
|
ReadOnlyError: () => ReadOnlyError,
|
|
1243
|
+
RedactedLineageNodeSchema: () => RedactedLineageNodeSchema,
|
|
1231
1244
|
RelayerError: () => RelayerError,
|
|
1232
1245
|
SCOPE_ACTIONS: () => SCOPE_ACTIONS,
|
|
1233
1246
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
@@ -1237,13 +1250,36 @@ __export(index_node_exports, {
|
|
|
1237
1250
|
SignatureError: () => SignatureError,
|
|
1238
1251
|
StorageError: () => StorageError,
|
|
1239
1252
|
StorageManager: () => StorageManager,
|
|
1253
|
+
TOMBSTONE_DATA_HASH: () => TOMBSTONE_DATA_HASH,
|
|
1254
|
+
TOMBSTONE_DATA_HASH_PREIMAGE: () => TOMBSTONE_DATA_HASH_PREIMAGE,
|
|
1255
|
+
TOMBSTONE_METADATA_HASH: () => TOMBSTONE_METADATA_HASH,
|
|
1256
|
+
TOMBSTONE_METADATA_HASH_PREIMAGE: () => TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
1240
1257
|
TransactionPendingError: () => TransactionPendingError,
|
|
1241
1258
|
UserRejectedRequestError: () => UserRejectedRequestError,
|
|
1242
1259
|
VanaError: () => VanaError,
|
|
1243
1260
|
VanaStorage: () => VanaStorage,
|
|
1261
|
+
WRITER_ATTRIBUTION_KEY: () => WRITER_ATTRIBUTION_KEY,
|
|
1262
|
+
WRITE_CONTENT_DISPOSITION_HEADER: () => WRITE_CONTENT_DISPOSITION_HEADER,
|
|
1263
|
+
WRITE_FILENAME_HEADER: () => WRITE_FILENAME_HEADER,
|
|
1264
|
+
WRITE_METADATA_HEADER: () => WRITE_METADATA_HEADER,
|
|
1265
|
+
WRITE_SESSION_PATH: () => WRITE_SESSION_PATH,
|
|
1266
|
+
WRITE_SIGNATURE_HEADER: () => WRITE_SIGNATURE_HEADER,
|
|
1267
|
+
WriteConflictError: () => WriteConflictError,
|
|
1268
|
+
WriteForbiddenError: () => WriteForbiddenError,
|
|
1269
|
+
WriteLineageError: () => WriteLineageError,
|
|
1270
|
+
WriteRejectedError: () => WriteRejectedError,
|
|
1271
|
+
WriteRequestError: () => WriteRequestError,
|
|
1272
|
+
WriteSessionError: () => WriteSessionError,
|
|
1273
|
+
WriteSessionExpiredError: () => WriteSessionExpiredError,
|
|
1274
|
+
WriteTransportError: () => WriteTransportError,
|
|
1275
|
+
WriteUnauthorizedError: () => WriteUnauthorizedError,
|
|
1276
|
+
assertDerivedScopeNaming: () => assertDerivedScopeNaming,
|
|
1244
1277
|
assertValidPkceVerifier: () => assertValidPkceVerifier,
|
|
1245
1278
|
authorizeEscrowPayment: () => authorizeEscrowPayment,
|
|
1246
1279
|
authorizeGrantPayment: () => authorizeGrantPayment,
|
|
1280
|
+
binaryWriteSignedBytes: () => binaryWriteSignedBytes,
|
|
1281
|
+
buildDataPointDeletionSignature: () => buildDataPointDeletionSignature,
|
|
1282
|
+
buildDataPointDeletionTypedData: () => buildDataPointDeletionTypedData,
|
|
1247
1283
|
buildDepositNativeRequest: () => buildDepositNativeRequest,
|
|
1248
1284
|
buildDepositTokenRequest: () => buildDepositTokenRequest,
|
|
1249
1285
|
buildEscrowPaymentHeader: () => buildEscrowPaymentHeader,
|
|
@@ -1261,6 +1297,7 @@ __export(index_node_exports, {
|
|
|
1261
1297
|
clearContractCache: () => clearContractCache,
|
|
1262
1298
|
computeBodyHash: () => computeBodyHash,
|
|
1263
1299
|
computePkceChallenge: () => computePkceChallenge,
|
|
1300
|
+
computeTombstoneHash: () => computeTombstoneHash,
|
|
1264
1301
|
contractCacheForTesting: () => contractCacheForTesting,
|
|
1265
1302
|
createBrowserPlatformAdapter: () => createBrowserPlatformAdapter,
|
|
1266
1303
|
createDataFileEnvelope: () => createDataFileEnvelope,
|
|
@@ -1272,22 +1309,28 @@ __export(index_node_exports, {
|
|
|
1272
1309
|
createPlatformAdapterFor: () => createPlatformAdapterFor,
|
|
1273
1310
|
createPlatformAdapterSafe: () => createPlatformAdapterSafe,
|
|
1274
1311
|
createVanaStorageProvider: () => createVanaStorageProvider,
|
|
1312
|
+
createViemDataPointDeletionSigner: () => createViemDataPointDeletionSigner,
|
|
1275
1313
|
createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
|
|
1276
1314
|
createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
|
|
1277
1315
|
dataRegistryContractAddress: () => dataRegistryContractAddress,
|
|
1278
1316
|
dataRegistryDomain: () => dataRegistryDomain,
|
|
1279
1317
|
decryptWithPassword: () => decryptWithPassword,
|
|
1318
|
+
deleteDataPoint: () => deleteDataPoint,
|
|
1319
|
+
deriveDataPointId: () => deriveDataPointId,
|
|
1280
1320
|
deriveMasterKey: () => deriveMasterKey,
|
|
1281
1321
|
deriveScopeKey: () => deriveScopeKey,
|
|
1322
|
+
derivedScopeViolatesNaming: () => derivedScopeViolatesNaming,
|
|
1282
1323
|
deserializeECIES: () => deserializeECIES,
|
|
1283
1324
|
detectPlatform: () => detectPlatform,
|
|
1284
1325
|
encodeDepositNativeData: () => encodeDepositNativeData,
|
|
1285
1326
|
encodeDepositTokenData: () => encodeDepositTokenData,
|
|
1286
1327
|
encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
|
|
1328
|
+
encodeWriteMetadataHeader: () => encodeWriteMetadataHeader,
|
|
1287
1329
|
encryptWithPassword: () => encryptWithPassword,
|
|
1288
1330
|
escrowContractAddress: () => escrowContractAddress,
|
|
1289
1331
|
escrowPaymentDomain: () => escrowPaymentDomain,
|
|
1290
1332
|
formatScopeEntry: () => formatScopeEntry,
|
|
1333
|
+
gatewayLineagePath: () => gatewayLineagePath,
|
|
1291
1334
|
generatePkceVerifier: () => generatePkceVerifier,
|
|
1292
1335
|
genericPaymentDomain: () => genericPaymentDomain,
|
|
1293
1336
|
getAbi: () => getAbi,
|
|
@@ -1297,48 +1340,65 @@ __export(index_node_exports, {
|
|
|
1297
1340
|
getContractController: () => getContractController,
|
|
1298
1341
|
getContractInfo: () => getContractInfo,
|
|
1299
1342
|
getFee: () => getFee,
|
|
1343
|
+
getGatewayLineage: () => getGatewayLineage,
|
|
1344
|
+
getLineage: () => getLineage,
|
|
1300
1345
|
getOpFee: () => getOpFee,
|
|
1346
|
+
getPersonalServerLineage: () => getPersonalServerLineage,
|
|
1301
1347
|
getPlatformCapabilities: () => getPlatformCapabilities,
|
|
1302
1348
|
getServiceEndpoints: () => getServiceEndpoints,
|
|
1303
1349
|
grantPermissions: () => grantPermissions,
|
|
1304
1350
|
grantRegistrationDomain: () => grantRegistrationDomain,
|
|
1305
1351
|
grantRevocationDomain: () => grantRevocationDomain,
|
|
1306
1352
|
hasAction: () => hasAction,
|
|
1353
|
+
isDataPointId: () => isDataPointId,
|
|
1354
|
+
isDataPointTombstone: () => isDataPointTombstone,
|
|
1307
1355
|
isDataPortabilityGatewayConfig: () => isDataPortabilityGatewayConfig,
|
|
1308
1356
|
isECIESEncrypted: () => isECIESEncrypted,
|
|
1309
1357
|
isPlatformSupported: () => isPlatformSupported,
|
|
1358
|
+
isRedactedLineageNode: () => isRedactedLineageNode,
|
|
1359
|
+
isTombstoneHashes: () => isTombstoneHashes,
|
|
1310
1360
|
mainnetServices: () => mainnetServices,
|
|
1311
1361
|
moksha: () => moksha,
|
|
1312
1362
|
mokshaServices: () => mokshaServices,
|
|
1313
1363
|
mokshaTestnet: () => mokshaTestnet2,
|
|
1364
|
+
normalizeBinaryMimeType: () => normalizeBinaryMimeType,
|
|
1365
|
+
openWriteSession: () => openWriteSession,
|
|
1314
1366
|
parsePSError: () => parsePSError,
|
|
1315
1367
|
parsePersonalServerPaymentRequired: () => parsePersonalServerPaymentRequired,
|
|
1316
1368
|
parseScope: () => parseScope,
|
|
1317
1369
|
parseScopeEntry: () => parseScopeEntry,
|
|
1318
1370
|
parseWeb3SignedHeader: () => parseWeb3SignedHeader,
|
|
1371
|
+
parseWriteMetadataHeader: () => parseWriteMetadataHeader,
|
|
1319
1372
|
paymentReceiptFromHeader: () => paymentReceiptFromHeader,
|
|
1320
1373
|
paymentResponseMetadataFromHeader: () => paymentResponseMetadataFromHeader,
|
|
1321
1374
|
permissionsToScopes: () => permissionsToScopes,
|
|
1322
1375
|
personalServerDataReadPath: () => personalServerDataReadPath,
|
|
1376
|
+
personalServerLineagePath: () => personalServerLineagePath,
|
|
1323
1377
|
personalServerRegistrationDomain: () => personalServerRegistrationDomain,
|
|
1324
1378
|
readPersonalServerData: () => readPersonalServerData,
|
|
1325
1379
|
recoverServerOwner: () => recoverServerOwner,
|
|
1326
1380
|
registerPersonalServerSignature: () => registerPersonalServerSignature,
|
|
1381
|
+
resolveWriteSigner: () => resolveWriteSigner,
|
|
1327
1382
|
scopeCoveredByGrant: () => scopeCoveredByGrant,
|
|
1328
1383
|
scopeMatchesPattern: () => scopeMatchesPattern,
|
|
1384
|
+
scopeNamespace: () => scopeNamespace,
|
|
1329
1385
|
scopeToPathSegments: () => scopeToPathSegments,
|
|
1330
1386
|
serializeECIES: () => serializeECIES,
|
|
1331
1387
|
serverRegistrationDomain: () => serverRegistrationDomain,
|
|
1388
|
+
sessionCoversScope: () => sessionCoversScope,
|
|
1332
1389
|
signPersonalServerLiteOwnerBinding: () => signPersonalServerLiteOwnerBinding,
|
|
1333
1390
|
signPersonalServerLiteOwnerBindingWithAccountClient: () => signPersonalServerLiteOwnerBindingWithAccountClient,
|
|
1334
1391
|
signPersonalServerRegistrationWithAccount: () => signPersonalServerRegistrationWithAccount,
|
|
1335
1392
|
toDirectFeeBreakdown: () => toDirectFeeBreakdown,
|
|
1336
1393
|
toDirectPaymentReceipt: () => toDirectPaymentReceipt,
|
|
1394
|
+
tombstoneDeletedAt: () => tombstoneDeletedAt,
|
|
1337
1395
|
tryGrantPermissions: () => tryGrantPermissions,
|
|
1338
1396
|
vanaMainnet: () => vanaMainnet2,
|
|
1339
1397
|
verifyGrantRegistration: () => verifyGrantRegistration,
|
|
1340
1398
|
verifyPkceChallenge: () => verifyPkceChallenge,
|
|
1341
|
-
verifyWeb3Signed: () => verifyWeb3Signed
|
|
1399
|
+
verifyWeb3Signed: () => verifyWeb3Signed,
|
|
1400
|
+
writeData: () => writeData,
|
|
1401
|
+
writePersonalServerData: () => writePersonalServerData
|
|
1342
1402
|
});
|
|
1343
1403
|
module.exports = __toCommonJS(index_node_exports);
|
|
1344
1404
|
|
|
@@ -1483,6 +1543,97 @@ var TransactionPendingError = class extends VanaError {
|
|
|
1483
1543
|
};
|
|
1484
1544
|
}
|
|
1485
1545
|
};
|
|
1546
|
+
var PersonalServerWriteError = class extends VanaError {
|
|
1547
|
+
constructor(message, code, status, errorCode = null, details) {
|
|
1548
|
+
super(message, code);
|
|
1549
|
+
this.status = status;
|
|
1550
|
+
this.errorCode = errorCode;
|
|
1551
|
+
this.details = details;
|
|
1552
|
+
}
|
|
1553
|
+
status;
|
|
1554
|
+
errorCode;
|
|
1555
|
+
details;
|
|
1556
|
+
};
|
|
1557
|
+
var WriteRequestError = class extends PersonalServerWriteError {
|
|
1558
|
+
constructor(message, details) {
|
|
1559
|
+
super(message, "WRITE_INVALID_REQUEST", void 0, null, details);
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
var WriteTransportError = class extends PersonalServerWriteError {
|
|
1563
|
+
constructor(message, attempts, cause) {
|
|
1564
|
+
super(message, "WRITE_TRANSPORT_ERROR", void 0, null, { attempts });
|
|
1565
|
+
this.attempts = attempts;
|
|
1566
|
+
this.cause = cause;
|
|
1567
|
+
}
|
|
1568
|
+
attempts;
|
|
1569
|
+
};
|
|
1570
|
+
var WriteSessionError = class extends PersonalServerWriteError {
|
|
1571
|
+
constructor(message, status, errorCode = null, details) {
|
|
1572
|
+
super(message, "WRITE_SESSION_REJECTED", status, errorCode, details);
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
var WriteSessionExpiredError = class extends PersonalServerWriteError {
|
|
1576
|
+
constructor(message, details) {
|
|
1577
|
+
super(message, "WRITE_SESSION_EXPIRED", void 0, null, details);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
var WriteUnauthorizedError = class extends PersonalServerWriteError {
|
|
1581
|
+
constructor(message, errorCode = null, details) {
|
|
1582
|
+
super(message, "WRITE_UNAUTHORIZED", 401, errorCode, details);
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
var WriteForbiddenError = class extends PersonalServerWriteError {
|
|
1586
|
+
constructor(message, errorCode = null, details) {
|
|
1587
|
+
super(message, "WRITE_FORBIDDEN", 403, errorCode, details);
|
|
1588
|
+
}
|
|
1589
|
+
};
|
|
1590
|
+
var WriteConflictError = class extends PersonalServerWriteError {
|
|
1591
|
+
constructor(message, errorCode = null, details) {
|
|
1592
|
+
super(message, "WRITE_CONFLICT", 409, errorCode, details);
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
var WriteLineageError = class extends PersonalServerWriteError {
|
|
1596
|
+
constructor(message, status = 422, errorCode = null, details) {
|
|
1597
|
+
super(message, "WRITE_LINEAGE_REJECTED", status, errorCode, details);
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
var WriteRejectedError = class extends PersonalServerWriteError {
|
|
1601
|
+
constructor(message, status, errorCode = null, details) {
|
|
1602
|
+
super(message, "WRITE_REJECTED", status, errorCode, details);
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
var LineageReadError = class extends VanaError {
|
|
1606
|
+
constructor(message, status, errorCode = null, details) {
|
|
1607
|
+
super(message, "LINEAGE_READ_ERROR");
|
|
1608
|
+
this.status = status;
|
|
1609
|
+
this.errorCode = errorCode;
|
|
1610
|
+
this.details = details;
|
|
1611
|
+
}
|
|
1612
|
+
status;
|
|
1613
|
+
errorCode;
|
|
1614
|
+
details;
|
|
1615
|
+
};
|
|
1616
|
+
var DataPointDeletedError = class extends VanaError {
|
|
1617
|
+
constructor(message, details = {}) {
|
|
1618
|
+
super(message, "DATA_POINT_DELETED");
|
|
1619
|
+
this.details = details;
|
|
1620
|
+
}
|
|
1621
|
+
details;
|
|
1622
|
+
};
|
|
1623
|
+
var DataPointNotFoundError = class extends VanaError {
|
|
1624
|
+
constructor(message, details = {}) {
|
|
1625
|
+
super(message, "DATA_POINT_NOT_FOUND");
|
|
1626
|
+
this.details = details;
|
|
1627
|
+
}
|
|
1628
|
+
details;
|
|
1629
|
+
};
|
|
1630
|
+
var DataPointVersionConflictError = class extends VanaError {
|
|
1631
|
+
constructor(message, details = {}) {
|
|
1632
|
+
super(message, "DATA_POINT_VERSION_CONFLICT");
|
|
1633
|
+
this.details = details;
|
|
1634
|
+
}
|
|
1635
|
+
details;
|
|
1636
|
+
};
|
|
1486
1637
|
|
|
1487
1638
|
// src/contracts/contractController.ts
|
|
1488
1639
|
var import_viem3 = require("viem");
|
|
@@ -29239,6 +29390,22 @@ function getProtocolNetworkChainId(network) {
|
|
|
29239
29390
|
return PROTOCOL_NETWORK_CHAIN_IDS[network];
|
|
29240
29391
|
}
|
|
29241
29392
|
|
|
29393
|
+
// src/utils/response-body.ts
|
|
29394
|
+
function isPlainObject(value) {
|
|
29395
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29396
|
+
}
|
|
29397
|
+
async function readJsonValue(res) {
|
|
29398
|
+
try {
|
|
29399
|
+
return await res.json();
|
|
29400
|
+
} catch {
|
|
29401
|
+
return null;
|
|
29402
|
+
}
|
|
29403
|
+
}
|
|
29404
|
+
async function readJsonObject(res) {
|
|
29405
|
+
const value = await readJsonValue(res);
|
|
29406
|
+
return isPlainObject(value) ? value : {};
|
|
29407
|
+
}
|
|
29408
|
+
|
|
29242
29409
|
// src/storage/providers/vana-storage.ts
|
|
29243
29410
|
var DEFAULT_ENDPOINT = "https://storage.vana.org";
|
|
29244
29411
|
var LEGACY_BLOB_PATH_PREFIX = "/v1/blobs";
|
|
@@ -29410,6 +29577,65 @@ var VanaStorage = class {
|
|
|
29410
29577
|
}
|
|
29411
29578
|
return true;
|
|
29412
29579
|
}
|
|
29580
|
+
/**
|
|
29581
|
+
* Delete every version's blob under `(owner, scope)` --
|
|
29582
|
+
* `DELETE {prefix}/{owner}/{scope}` on vana-storage, signed with the same
|
|
29583
|
+
* Web3Signed header as uploads (aud = endpoint origin, empty bodyHash).
|
|
29584
|
+
* The worker accepts the owner's own signature or a personal server the
|
|
29585
|
+
* owner registered with the gateway.
|
|
29586
|
+
*
|
|
29587
|
+
* @param ownerAddress - Must equal the provider's configured owner; a
|
|
29588
|
+
* mismatch throws before anything is signed so this wallet can never be
|
|
29589
|
+
* induced to sign a delete for another namespace.
|
|
29590
|
+
* @param scope - The scope segment, e.g. `"instagram.profile"`.
|
|
29591
|
+
*/
|
|
29592
|
+
async deleteScope(ownerAddress, scope) {
|
|
29593
|
+
if (ownerAddress.toLowerCase() !== this.ownerAddress) {
|
|
29594
|
+
throw new StorageError(
|
|
29595
|
+
`deleteScope owner '${ownerAddress}' does not match the configured owner '${this.ownerAddress}'`,
|
|
29596
|
+
"INVALID_OWNER",
|
|
29597
|
+
"vana-storage"
|
|
29598
|
+
);
|
|
29599
|
+
}
|
|
29600
|
+
if (scope.length === 0 || scope.includes("/") || isTraversalSegment(scope)) {
|
|
29601
|
+
throw new StorageError(
|
|
29602
|
+
`scope must be a single non-empty path segment, got '${scope}'`,
|
|
29603
|
+
"INVALID_SCOPE",
|
|
29604
|
+
"vana-storage"
|
|
29605
|
+
);
|
|
29606
|
+
}
|
|
29607
|
+
const path = `${this.blobPathPrefix}/${this.ownerAddress}/${encodeURIComponent(scope)}`;
|
|
29608
|
+
const header = await this.signRequest("DELETE", path);
|
|
29609
|
+
let response;
|
|
29610
|
+
try {
|
|
29611
|
+
response = await this.fetchImpl(`${this.endpoint}${path}`, {
|
|
29612
|
+
method: "DELETE",
|
|
29613
|
+
headers: { authorization: header }
|
|
29614
|
+
});
|
|
29615
|
+
} catch (cause) {
|
|
29616
|
+
throw new StorageError(
|
|
29617
|
+
`vana-storage scope delete network error: ${describe(cause)}`,
|
|
29618
|
+
"DELETE_ERROR",
|
|
29619
|
+
"vana-storage",
|
|
29620
|
+
{ cause: cause instanceof Error ? cause : void 0 }
|
|
29621
|
+
);
|
|
29622
|
+
}
|
|
29623
|
+
if (!response.ok) {
|
|
29624
|
+
const responseText = await safeText(response);
|
|
29625
|
+
throw new StorageError(
|
|
29626
|
+
`vana-storage scope delete failed: ${response.status} ${response.statusText} - ${responseText}`,
|
|
29627
|
+
"DELETE_FAILED",
|
|
29628
|
+
"vana-storage"
|
|
29629
|
+
);
|
|
29630
|
+
}
|
|
29631
|
+
const body = await readJsonObject(response);
|
|
29632
|
+
return {
|
|
29633
|
+
deleted: typeof body["deleted"] === "boolean" ? body["deleted"] : true,
|
|
29634
|
+
scope: typeof body["scope"] === "string" ? body["scope"] : scope,
|
|
29635
|
+
count: nonNegativeInteger(body["count"]) ?? 0,
|
|
29636
|
+
totalBytes: nonNegativeInteger(body["totalBytes"]) ?? 0
|
|
29637
|
+
};
|
|
29638
|
+
}
|
|
29413
29639
|
getConfig() {
|
|
29414
29640
|
return {
|
|
29415
29641
|
name: "vana-storage",
|
|
@@ -29538,6 +29764,12 @@ function encodeRelativePath(filename) {
|
|
|
29538
29764
|
}
|
|
29539
29765
|
return parts.map((p) => encodeURIComponent(p)).join("/");
|
|
29540
29766
|
}
|
|
29767
|
+
function isTraversalSegment(segment) {
|
|
29768
|
+
return segment === "." || segment === "..";
|
|
29769
|
+
}
|
|
29770
|
+
function nonNegativeInteger(value) {
|
|
29771
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
29772
|
+
}
|
|
29541
29773
|
function describe(value) {
|
|
29542
29774
|
if (value instanceof Error) return value.message;
|
|
29543
29775
|
return String(value);
|
|
@@ -32980,13 +33212,13 @@ function createViemPersonalServerRegistrationSigner(source, options = {}) {
|
|
|
32980
33212
|
if (isPersonalServerRegistrationSigner(source)) {
|
|
32981
33213
|
return source;
|
|
32982
33214
|
}
|
|
32983
|
-
const
|
|
32984
|
-
if (
|
|
33215
|
+
const accountAddress2 = getAccountAddress(options.account) ?? getAccountAddress(source.account);
|
|
33216
|
+
if (accountAddress2) {
|
|
32985
33217
|
return {
|
|
32986
|
-
address:
|
|
33218
|
+
address: accountAddress2,
|
|
32987
33219
|
signTypedData: (typedData) => source.signTypedData({
|
|
32988
33220
|
...typedData,
|
|
32989
|
-
account: options.account ?? source.account ??
|
|
33221
|
+
account: options.account ?? source.account ?? accountAddress2
|
|
32990
33222
|
})
|
|
32991
33223
|
};
|
|
32992
33224
|
}
|
|
@@ -33069,12 +33301,12 @@ function createViemPersonalServerLiteOwnerBindingSigner(source, options = {}) {
|
|
|
33069
33301
|
if (isPersonalServerLiteOwnerBindingSigner(source)) {
|
|
33070
33302
|
return source;
|
|
33071
33303
|
}
|
|
33072
|
-
const
|
|
33073
|
-
if (
|
|
33304
|
+
const accountAddress2 = getAccountAddress2(options.account) ?? getAccountAddress2(source.account);
|
|
33305
|
+
if (accountAddress2) {
|
|
33074
33306
|
return {
|
|
33075
|
-
address:
|
|
33307
|
+
address: accountAddress2,
|
|
33076
33308
|
signMessage: ({ message }) => source.signMessage({
|
|
33077
|
-
account: options.account ?? source.account ??
|
|
33309
|
+
account: options.account ?? source.account ?? accountAddress2,
|
|
33078
33310
|
message
|
|
33079
33311
|
})
|
|
33080
33312
|
};
|
|
@@ -33641,15 +33873,485 @@ function buildMarkDataPointUnavailableRequest(config, input) {
|
|
|
33641
33873
|
});
|
|
33642
33874
|
}
|
|
33643
33875
|
|
|
33644
|
-
// src/protocol/data-
|
|
33876
|
+
// src/protocol/data-point-deletion.ts
|
|
33877
|
+
var import_viem22 = require("viem");
|
|
33878
|
+
|
|
33879
|
+
// src/protocol/lineage.ts
|
|
33880
|
+
var import_viem21 = require("viem");
|
|
33645
33881
|
var import_zod = require("zod");
|
|
33646
|
-
|
|
33647
|
-
|
|
33648
|
-
|
|
33882
|
+
|
|
33883
|
+
// src/protocol/personal-server-error-body.ts
|
|
33884
|
+
function isRecord2(value) {
|
|
33885
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
33886
|
+
}
|
|
33887
|
+
async function readPersonalServerErrorBody(response) {
|
|
33888
|
+
let body;
|
|
33889
|
+
try {
|
|
33890
|
+
body = await response.json();
|
|
33891
|
+
} catch {
|
|
33892
|
+
return { errorCode: null, message: null };
|
|
33893
|
+
}
|
|
33894
|
+
if (!isRecord2(body)) return { errorCode: null, message: null };
|
|
33895
|
+
const nested = isRecord2(body.error) ? body.error : null;
|
|
33896
|
+
const gatewayShape = typeof body.error === "string" && typeof body.code === "string";
|
|
33897
|
+
const code = nested?.errorCode ?? nested?.code ?? body.errorCode ?? (gatewayShape ? body.code : void 0) ?? (typeof body.error === "string" ? body.error : void 0) ?? body.code;
|
|
33898
|
+
const message = nested?.message ?? body.message ?? (gatewayShape ? body.error : void 0);
|
|
33899
|
+
const gatewayDetails = {};
|
|
33900
|
+
for (const key of ["unknown", "scope", "sourceScope"]) {
|
|
33901
|
+
if (gatewayShape && body[key] !== void 0)
|
|
33902
|
+
gatewayDetails[key] = body[key];
|
|
33903
|
+
}
|
|
33904
|
+
const details = nested?.details ?? body.details ?? (Object.keys(gatewayDetails).length > 0 ? gatewayDetails : void 0);
|
|
33905
|
+
return {
|
|
33906
|
+
errorCode: typeof code === "string" ? code : null,
|
|
33907
|
+
message: typeof message === "string" ? message : null,
|
|
33908
|
+
...isRecord2(details) ? { details } : {}
|
|
33909
|
+
};
|
|
33910
|
+
}
|
|
33911
|
+
|
|
33912
|
+
// src/protocol/write-signer.ts
|
|
33913
|
+
function isRecord3(value) {
|
|
33914
|
+
return value !== null && typeof value === "object";
|
|
33915
|
+
}
|
|
33916
|
+
function isViemWriteAccount(source) {
|
|
33917
|
+
return isRecord3(source) && source.type === "local" && typeof source.address === "string" && typeof source.signMessage === "function";
|
|
33918
|
+
}
|
|
33919
|
+
function isViemWriteWalletClient(source) {
|
|
33920
|
+
return isRecord3(source) && typeof source.signMessage === "function" && source.type !== "local" && (source.type === "walletClient" || "transport" in source);
|
|
33921
|
+
}
|
|
33922
|
+
function accountAddress(account) {
|
|
33923
|
+
return typeof account === "string" ? account : account.address;
|
|
33924
|
+
}
|
|
33925
|
+
function resolveWriteSigner(source, options = {}) {
|
|
33926
|
+
if (isViemWriteWalletClient(source)) {
|
|
33927
|
+
const account = options.account ?? source.account;
|
|
33928
|
+
if (account === void 0) {
|
|
33929
|
+
throw new WriteRequestError(
|
|
33930
|
+
"Viem wallet client requires an account option or account property"
|
|
33931
|
+
);
|
|
33932
|
+
}
|
|
33933
|
+
return {
|
|
33934
|
+
address: accountAddress(account),
|
|
33935
|
+
signMessage: (message) => source.signMessage({ account, message })
|
|
33936
|
+
};
|
|
33937
|
+
}
|
|
33938
|
+
if (isViemWriteAccount(source)) {
|
|
33939
|
+
return {
|
|
33940
|
+
address: source.address,
|
|
33941
|
+
signMessage: (message) => source.signMessage({ message })
|
|
33942
|
+
};
|
|
33943
|
+
}
|
|
33944
|
+
if (!isRecord3(source) || typeof source.signMessage !== "function") {
|
|
33945
|
+
throw new WriteRequestError(
|
|
33946
|
+
"signer must be a viem LocalAccount, a viem WalletClient, or a { signMessage } object"
|
|
33947
|
+
);
|
|
33948
|
+
}
|
|
33949
|
+
return source;
|
|
33950
|
+
}
|
|
33951
|
+
|
|
33952
|
+
// src/protocol/lineage.ts
|
|
33953
|
+
var DATA_POINT_ID_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
33954
|
+
function isDataPointId(value) {
|
|
33955
|
+
return typeof value === "string" && DATA_POINT_ID_PATTERN.test(value);
|
|
33956
|
+
}
|
|
33957
|
+
function deriveDataPointId(ownerAddress, scope) {
|
|
33958
|
+
if (!(0, import_viem21.isAddress)(ownerAddress, { strict: false })) {
|
|
33959
|
+
throw new Error(
|
|
33960
|
+
`ownerAddress is not an EVM address: ${String(ownerAddress)}`
|
|
33961
|
+
);
|
|
33962
|
+
}
|
|
33963
|
+
return (0, import_viem21.keccak256)(
|
|
33964
|
+
(0, import_viem21.encodeAbiParameters)(
|
|
33965
|
+
[
|
|
33966
|
+
{ name: "ownerAddress", type: "address" },
|
|
33967
|
+
{ name: "scope", type: "string" }
|
|
33968
|
+
],
|
|
33969
|
+
[ownerAddress, scope]
|
|
33970
|
+
)
|
|
33971
|
+
);
|
|
33972
|
+
}
|
|
33973
|
+
var DataPointIdSchema = import_zod.z.string().regex(DATA_POINT_ID_PATTERN).transform((value) => value.toLowerCase());
|
|
33974
|
+
var VERSION_PATTERN = /^[1-9]\d*$/;
|
|
33975
|
+
var NODE_VERSION_PATTERN = /^(0|[1-9]\d*)$/;
|
|
33976
|
+
var VersionSchema = import_zod.z.union([import_zod.z.string(), import_zod.z.number()]).transform(String).refine((value) => NODE_VERSION_PATTERN.test(value), {
|
|
33977
|
+
message: "version must be a decimal integer"
|
|
33978
|
+
});
|
|
33979
|
+
var ViewVersionSchema = VersionSchema.refine(
|
|
33980
|
+
(value) => VERSION_PATTERN.test(value),
|
|
33981
|
+
{ message: "version must be a positive decimal integer" }
|
|
33982
|
+
);
|
|
33983
|
+
function scopeNamespace(scope) {
|
|
33984
|
+
const dot = scope.indexOf(".");
|
|
33985
|
+
return dot === -1 ? scope : scope.slice(0, dot);
|
|
33986
|
+
}
|
|
33987
|
+
function derivedScopeViolatesNaming(derivedScope, sourceScope) {
|
|
33988
|
+
return scopeNamespace(derivedScope) === scopeNamespace(sourceScope);
|
|
33989
|
+
}
|
|
33990
|
+
function assertDerivedScopeNaming(derivedScope, sourceScopes) {
|
|
33991
|
+
for (const sourceScope of sourceScopes) {
|
|
33992
|
+
if (derivedScopeViolatesNaming(derivedScope, sourceScope)) {
|
|
33993
|
+
throw new WriteRequestError(
|
|
33994
|
+
`Derived scope ${derivedScope} must not share its first segment with source scope ${sourceScope}; put derivatives in the app's own namespace`,
|
|
33995
|
+
{ scope: derivedScope, sourceScope }
|
|
33996
|
+
);
|
|
33997
|
+
}
|
|
33998
|
+
}
|
|
33999
|
+
}
|
|
34000
|
+
var LineageNodeSchema = import_zod.z.object({
|
|
34001
|
+
dataPointId: DataPointIdSchema,
|
|
34002
|
+
scope: import_zod.z.string(),
|
|
34003
|
+
/**
|
|
34004
|
+
* The node's current version, decimal string; `"0"` for a source that no
|
|
34005
|
+
* longer resolves to a registered data point.
|
|
34006
|
+
*/
|
|
34007
|
+
version: VersionSchema,
|
|
34008
|
+
/** The node's tombstone time, or `null` when live. */
|
|
34009
|
+
deletedAt: import_zod.z.string().nullable()
|
|
34010
|
+
});
|
|
34011
|
+
var RedactedLineageNodeSchema = import_zod.z.object({
|
|
34012
|
+
dataPointId: DataPointIdSchema,
|
|
34013
|
+
redacted: import_zod.z.literal(true)
|
|
34014
|
+
});
|
|
34015
|
+
var LineageEntrySchema = import_zod.z.union([
|
|
34016
|
+
RedactedLineageNodeSchema,
|
|
34017
|
+
LineageNodeSchema
|
|
34018
|
+
]);
|
|
34019
|
+
var LineageGraphSchema = import_zod.z.object({
|
|
34020
|
+
dataPointId: DataPointIdSchema,
|
|
34021
|
+
/** The data point owner; every node in the view belongs to it. */
|
|
34022
|
+
ownerAddress: import_zod.z.string().optional(),
|
|
33649
34023
|
scope: import_zod.z.string(),
|
|
33650
|
-
|
|
33651
|
-
|
|
33652
|
-
|
|
34024
|
+
/**
|
|
34025
|
+
* The derived record's version whose lineage is shown: the requested one,
|
|
34026
|
+
* else the current one, else (current is a tombstone) the last version
|
|
34027
|
+
* that carried lineage.
|
|
34028
|
+
*/
|
|
34029
|
+
version: ViewVersionSchema,
|
|
34030
|
+
deletedAt: import_zod.z.string().nullable(),
|
|
34031
|
+
sources: import_zod.z.array(LineageEntrySchema),
|
|
34032
|
+
derivatives: import_zod.z.array(LineageEntrySchema),
|
|
34033
|
+
/** `true` when `derivatives` was cut at the server's cap (1000). */
|
|
34034
|
+
derivativesTruncated: import_zod.z.boolean().optional()
|
|
34035
|
+
});
|
|
34036
|
+
function isRedactedLineageNode(entry) {
|
|
34037
|
+
return "redacted" in entry && entry.redacted === true;
|
|
34038
|
+
}
|
|
34039
|
+
function personalServerLineagePath(scope, version) {
|
|
34040
|
+
return `/v1/data/${encodeURIComponent(scope)}/lineage${version === void 0 ? "" : `/${String(version)}`}`;
|
|
34041
|
+
}
|
|
34042
|
+
function gatewayLineagePath(dataPointId, version) {
|
|
34043
|
+
return `/v1/data/${dataPointId.toLowerCase()}/lineage${version === void 0 ? "" : `/${String(version)}`}`;
|
|
34044
|
+
}
|
|
34045
|
+
function normalizeBaseUrl(url) {
|
|
34046
|
+
return url.replace(/\/+$/, "");
|
|
34047
|
+
}
|
|
34048
|
+
function resolveFetch(fetchFn) {
|
|
34049
|
+
const resolved = fetchFn ?? globalThis.fetch;
|
|
34050
|
+
if (resolved === void 0) {
|
|
34051
|
+
throw new LineageReadError("No fetch implementation available");
|
|
34052
|
+
}
|
|
34053
|
+
return resolved;
|
|
34054
|
+
}
|
|
34055
|
+
function normalizeVersion(version) {
|
|
34056
|
+
if (version === void 0) return void 0;
|
|
34057
|
+
const text = String(version);
|
|
34058
|
+
if (!VERSION_PATTERN.test(text)) {
|
|
34059
|
+
throw new LineageReadError(
|
|
34060
|
+
"version must be a positive decimal integer",
|
|
34061
|
+
void 0,
|
|
34062
|
+
"INVALID_VERSION",
|
|
34063
|
+
{ version }
|
|
34064
|
+
);
|
|
34065
|
+
}
|
|
34066
|
+
return text;
|
|
34067
|
+
}
|
|
34068
|
+
async function lineageReadFailure(source, response) {
|
|
34069
|
+
const { errorCode, message, details } = await readPersonalServerErrorBody(response);
|
|
34070
|
+
return new LineageReadError(
|
|
34071
|
+
message ?? `${source} lineage read failed: ${response.status} ${response.statusText}`,
|
|
34072
|
+
response.status,
|
|
34073
|
+
errorCode,
|
|
34074
|
+
details
|
|
34075
|
+
);
|
|
34076
|
+
}
|
|
34077
|
+
async function parseLineageGraph(source, response) {
|
|
34078
|
+
let body;
|
|
34079
|
+
try {
|
|
34080
|
+
body = await response.json();
|
|
34081
|
+
} catch (err) {
|
|
34082
|
+
throw new LineageReadError(
|
|
34083
|
+
`${source} lineage response is not JSON`,
|
|
34084
|
+
response.status,
|
|
34085
|
+
null,
|
|
34086
|
+
{ cause: err instanceof Error ? err.message : String(err) }
|
|
34087
|
+
);
|
|
34088
|
+
}
|
|
34089
|
+
const envelope = isRecord2(body) && isRecord2(body.data) ? body : void 0;
|
|
34090
|
+
const parsed = LineageGraphSchema.safeParse(envelope?.data ?? body);
|
|
34091
|
+
if (!parsed.success) {
|
|
34092
|
+
throw new LineageReadError(
|
|
34093
|
+
`${source} lineage response is not a lineage view`,
|
|
34094
|
+
response.status,
|
|
34095
|
+
null,
|
|
34096
|
+
{ issues: parsed.error.issues }
|
|
34097
|
+
);
|
|
34098
|
+
}
|
|
34099
|
+
const proof = isRecord2(envelope?.proof) ? envelope.proof : void 0;
|
|
34100
|
+
return proof === void 0 ? parsed.data : { ...parsed.data, proof };
|
|
34101
|
+
}
|
|
34102
|
+
async function sendLineageRead(source, fetchFn, url, headers) {
|
|
34103
|
+
let response;
|
|
34104
|
+
try {
|
|
34105
|
+
response = await fetchFn(url, { method: "GET", headers });
|
|
34106
|
+
} catch (err) {
|
|
34107
|
+
throw new LineageReadError(
|
|
34108
|
+
`${source} lineage read failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
34109
|
+
void 0,
|
|
34110
|
+
null,
|
|
34111
|
+
{ cause: err instanceof Error ? err.message : String(err) }
|
|
34112
|
+
);
|
|
34113
|
+
}
|
|
34114
|
+
if (!response.ok) {
|
|
34115
|
+
throw await lineageReadFailure(source, response);
|
|
34116
|
+
}
|
|
34117
|
+
return parseLineageGraph(source, response);
|
|
34118
|
+
}
|
|
34119
|
+
async function getPersonalServerLineage(params) {
|
|
34120
|
+
const fetchFn = resolveFetch(params.fetch);
|
|
34121
|
+
const baseUrl = normalizeBaseUrl(params.personalServerUrl);
|
|
34122
|
+
const audience = params.audience ?? baseUrl;
|
|
34123
|
+
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
34124
|
+
const path = personalServerLineagePath(
|
|
34125
|
+
params.scope,
|
|
34126
|
+
normalizeVersion(params.version)
|
|
34127
|
+
);
|
|
34128
|
+
const headers = new Headers(params.headers);
|
|
34129
|
+
headers.set(
|
|
34130
|
+
"Authorization",
|
|
34131
|
+
await buildWeb3SignedHeader({
|
|
34132
|
+
signMessage: signer.signMessage,
|
|
34133
|
+
aud: audience,
|
|
34134
|
+
method: "GET",
|
|
34135
|
+
uri: path,
|
|
34136
|
+
grantId: params.grantId
|
|
34137
|
+
})
|
|
34138
|
+
);
|
|
34139
|
+
return sendLineageRead(
|
|
34140
|
+
"Personal Server",
|
|
34141
|
+
fetchFn,
|
|
34142
|
+
`${baseUrl}${path}`,
|
|
34143
|
+
headers
|
|
34144
|
+
);
|
|
34145
|
+
}
|
|
34146
|
+
async function getGatewayLineage(params) {
|
|
34147
|
+
if (!isDataPointId(params.dataPointId)) {
|
|
34148
|
+
throw new LineageReadError(
|
|
34149
|
+
"dataPointId must be a 32-byte hex string (see deriveDataPointId)",
|
|
34150
|
+
void 0,
|
|
34151
|
+
"INVALID_DATA_POINT_ID",
|
|
34152
|
+
{ dataPointId: params.dataPointId }
|
|
34153
|
+
);
|
|
34154
|
+
}
|
|
34155
|
+
const fetchFn = resolveFetch(params.fetch);
|
|
34156
|
+
const baseUrl = normalizeBaseUrl(params.gatewayUrl);
|
|
34157
|
+
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
34158
|
+
const uri = gatewayLineagePath(
|
|
34159
|
+
params.dataPointId,
|
|
34160
|
+
normalizeVersion(params.version)
|
|
34161
|
+
);
|
|
34162
|
+
const headers = new Headers(params.headers);
|
|
34163
|
+
headers.set(
|
|
34164
|
+
"Authorization",
|
|
34165
|
+
await buildWeb3SignedHeader({
|
|
34166
|
+
signMessage: signer.signMessage,
|
|
34167
|
+
aud: baseUrl,
|
|
34168
|
+
method: "GET",
|
|
34169
|
+
uri,
|
|
34170
|
+
grantId: params.grantId?.toLowerCase()
|
|
34171
|
+
})
|
|
34172
|
+
);
|
|
34173
|
+
return sendLineageRead("Gateway", fetchFn, `${baseUrl}${uri}`, headers);
|
|
34174
|
+
}
|
|
34175
|
+
function getLineage(params) {
|
|
34176
|
+
return "personalServerUrl" in params ? getPersonalServerLineage(params) : getGatewayLineage(params);
|
|
34177
|
+
}
|
|
34178
|
+
|
|
34179
|
+
// src/protocol/data-point-deletion.ts
|
|
34180
|
+
var TOMBSTONE_DATA_HASH_PREIMAGE = "vana.data-point.tombstone.v1";
|
|
34181
|
+
var TOMBSTONE_METADATA_HASH_PREIMAGE = "vana.data-point.tombstone.metadata.v1";
|
|
34182
|
+
var TOMBSTONE_DATA_HASH = "0x30c45ee72fe56d1927701316925ab7ceacd3b6f9267061735d59396f075c6222";
|
|
34183
|
+
var TOMBSTONE_METADATA_HASH = "0xc5255a141acd6a2ae55971b62c0a85977c2511989dc114ad2abc2b7644f57d90";
|
|
34184
|
+
function computeTombstoneHash(preimage) {
|
|
34185
|
+
return (0, import_viem22.keccak256)((0, import_viem22.stringToBytes)(preimage));
|
|
34186
|
+
}
|
|
34187
|
+
function isTombstoneHashes(dataHash, metadataHash) {
|
|
34188
|
+
return typeof dataHash === "string" && typeof metadataHash === "string" && dataHash.toLowerCase() === TOMBSTONE_DATA_HASH && metadataHash.toLowerCase() === TOMBSTONE_METADATA_HASH;
|
|
34189
|
+
}
|
|
34190
|
+
function isDataPointTombstone(value) {
|
|
34191
|
+
if (!isPlainObject(value)) return false;
|
|
34192
|
+
if (typeof value["deletedAt"] === "string") return true;
|
|
34193
|
+
return isTombstoneHashes(
|
|
34194
|
+
typeof value["dataHash"] === "string" ? value["dataHash"] : void 0,
|
|
34195
|
+
typeof value["metadataHash"] === "string" ? value["metadataHash"] : void 0
|
|
34196
|
+
);
|
|
34197
|
+
}
|
|
34198
|
+
function tombstoneDeletedAt(value) {
|
|
34199
|
+
if (!isPlainObject(value)) return null;
|
|
34200
|
+
const deletedAt = value["deletedAt"];
|
|
34201
|
+
return typeof deletedAt === "string" ? deletedAt : null;
|
|
34202
|
+
}
|
|
34203
|
+
function assertAddress4(value, name) {
|
|
34204
|
+
if (!(0, import_viem22.isAddress)(value)) {
|
|
34205
|
+
throw new Error(`${name} must be a valid EVM address`);
|
|
34206
|
+
}
|
|
34207
|
+
}
|
|
34208
|
+
function assertUint256(value, name) {
|
|
34209
|
+
if (value < 0n || value > import_viem22.maxUint256) {
|
|
34210
|
+
throw new Error(`${name} must fit in uint256, got ${value}`);
|
|
34211
|
+
}
|
|
34212
|
+
}
|
|
34213
|
+
function getAccountAddress3(account) {
|
|
34214
|
+
if (!account) return void 0;
|
|
34215
|
+
return typeof account === "string" ? account : account.address;
|
|
34216
|
+
}
|
|
34217
|
+
function isDataPointDeletionSigner(source) {
|
|
34218
|
+
return "address" in source && typeof source.signTypedData === "function";
|
|
34219
|
+
}
|
|
34220
|
+
function createViemDataPointDeletionSigner(source, options = {}) {
|
|
34221
|
+
if (isDataPointDeletionSigner(source)) {
|
|
34222
|
+
return source;
|
|
34223
|
+
}
|
|
34224
|
+
const accountAddress2 = getAccountAddress3(options.account) ?? getAccountAddress3(source.account);
|
|
34225
|
+
if (accountAddress2) {
|
|
34226
|
+
return {
|
|
34227
|
+
address: accountAddress2,
|
|
34228
|
+
signTypedData: (typedData) => source.signTypedData({
|
|
34229
|
+
...typedData,
|
|
34230
|
+
account: options.account ?? source.account ?? accountAddress2
|
|
34231
|
+
})
|
|
34232
|
+
};
|
|
34233
|
+
}
|
|
34234
|
+
throw new Error(
|
|
34235
|
+
"Viem wallet client requires an account option or account property"
|
|
34236
|
+
);
|
|
34237
|
+
}
|
|
34238
|
+
function buildDataPointDeletionTypedData(input) {
|
|
34239
|
+
assertAddress4(input.ownerAddress, "ownerAddress");
|
|
34240
|
+
if (input.scope.length === 0) {
|
|
34241
|
+
throw new Error("scope must be a non-empty string");
|
|
34242
|
+
}
|
|
34243
|
+
if (input.expectedVersion <= 0n) {
|
|
34244
|
+
throw new Error("expectedVersion must be a positive version number");
|
|
34245
|
+
}
|
|
34246
|
+
assertUint256(input.expectedVersion, "expectedVersion");
|
|
34247
|
+
return {
|
|
34248
|
+
domain: dataRegistryDomain(input.config),
|
|
34249
|
+
types: ADD_DATA_TYPES,
|
|
34250
|
+
primaryType: "AddData",
|
|
34251
|
+
message: {
|
|
34252
|
+
ownerAddress: input.ownerAddress,
|
|
34253
|
+
scope: input.scope,
|
|
34254
|
+
dataHash: TOMBSTONE_DATA_HASH,
|
|
34255
|
+
metadataHash: TOMBSTONE_METADATA_HASH,
|
|
34256
|
+
expectedVersion: input.expectedVersion
|
|
34257
|
+
}
|
|
34258
|
+
};
|
|
34259
|
+
}
|
|
34260
|
+
async function buildDataPointDeletionSignature(input) {
|
|
34261
|
+
const typedData = buildDataPointDeletionTypedData({
|
|
34262
|
+
ownerAddress: input.signer.address,
|
|
34263
|
+
scope: input.scope,
|
|
34264
|
+
expectedVersion: input.expectedVersion,
|
|
34265
|
+
config: input.config
|
|
34266
|
+
});
|
|
34267
|
+
const signature = await input.signer.signTypedData(typedData);
|
|
34268
|
+
return {
|
|
34269
|
+
signature,
|
|
34270
|
+
signerAddress: input.signer.address,
|
|
34271
|
+
typedData
|
|
34272
|
+
};
|
|
34273
|
+
}
|
|
34274
|
+
function toError(value) {
|
|
34275
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
34276
|
+
}
|
|
34277
|
+
function parseExpectedVersion(value) {
|
|
34278
|
+
if (typeof value !== "string" || !/^\d+$/.test(value)) {
|
|
34279
|
+
throw new Error(
|
|
34280
|
+
`Gateway returned a malformed expectedVersion: ${JSON.stringify(value)}`
|
|
34281
|
+
);
|
|
34282
|
+
}
|
|
34283
|
+
const parsed = BigInt(value);
|
|
34284
|
+
assertUint256(parsed, "Gateway expectedVersion");
|
|
34285
|
+
return parsed;
|
|
34286
|
+
}
|
|
34287
|
+
async function deleteDataPoint(input) {
|
|
34288
|
+
const ownerAddress = input.signer.address;
|
|
34289
|
+
const dataPointId = deriveDataPointId(ownerAddress, input.scope);
|
|
34290
|
+
let currentVersion = input.currentVersion;
|
|
34291
|
+
if (currentVersion === void 0) {
|
|
34292
|
+
const record = await input.gateway.getDataPoint(dataPointId);
|
|
34293
|
+
if (record === null) {
|
|
34294
|
+
throw new DataPointNotFoundError(
|
|
34295
|
+
`No data point registered for scope '${input.scope}' owned by ${ownerAddress}`,
|
|
34296
|
+
{ dataPointId, scope: input.scope, ownerAddress }
|
|
34297
|
+
);
|
|
34298
|
+
}
|
|
34299
|
+
if (isDataPointTombstone(record)) {
|
|
34300
|
+
throw new DataPointDeletedError(
|
|
34301
|
+
`Data point ${dataPointId} (scope '${input.scope}') is already deleted`,
|
|
34302
|
+
{
|
|
34303
|
+
dataPointId,
|
|
34304
|
+
scope: input.scope,
|
|
34305
|
+
ownerAddress,
|
|
34306
|
+
deletedAt: tombstoneDeletedAt(record)
|
|
34307
|
+
}
|
|
34308
|
+
);
|
|
34309
|
+
}
|
|
34310
|
+
currentVersion = parseExpectedVersion(record.expectedVersion);
|
|
34311
|
+
}
|
|
34312
|
+
if (currentVersion < 0n || currentVersion >= import_viem22.maxUint256) {
|
|
34313
|
+
throw new Error(
|
|
34314
|
+
`currentVersion ${currentVersion} cannot be incremented to a uint256 tombstone version`
|
|
34315
|
+
);
|
|
34316
|
+
}
|
|
34317
|
+
const tombstoneVersion = currentVersion + 1n;
|
|
34318
|
+
const signed = await buildDataPointDeletionSignature({
|
|
34319
|
+
signer: input.signer,
|
|
34320
|
+
scope: input.scope,
|
|
34321
|
+
expectedVersion: tombstoneVersion,
|
|
34322
|
+
config: input.config
|
|
34323
|
+
});
|
|
34324
|
+
const tombstone = await input.gateway.deleteDataPoint({
|
|
34325
|
+
ownerAddress,
|
|
34326
|
+
scope: input.scope,
|
|
34327
|
+
expectedVersion: tombstoneVersion.toString(),
|
|
34328
|
+
signature: signed.signature
|
|
34329
|
+
});
|
|
34330
|
+
const base = {
|
|
34331
|
+
dataPointId,
|
|
34332
|
+
ownerAddress,
|
|
34333
|
+
scope: input.scope,
|
|
34334
|
+
version: tombstoneVersion.toString(),
|
|
34335
|
+
signature: signed.signature,
|
|
34336
|
+
tombstone
|
|
34337
|
+
};
|
|
34338
|
+
try {
|
|
34339
|
+
const storage = await input.storage.deleteScope(ownerAddress, input.scope);
|
|
34340
|
+
return { ...base, status: "deleted", storage };
|
|
34341
|
+
} catch (cause) {
|
|
34342
|
+
return { ...base, status: "partial", storageError: toError(cause) };
|
|
34343
|
+
}
|
|
34344
|
+
}
|
|
34345
|
+
|
|
34346
|
+
// src/protocol/data-file.ts
|
|
34347
|
+
var import_zod2 = require("zod");
|
|
34348
|
+
var DataFileEnvelopeSchema = import_zod2.z.object({
|
|
34349
|
+
$schema: import_zod2.z.string().url().optional(),
|
|
34350
|
+
version: import_zod2.z.literal("1.0"),
|
|
34351
|
+
scope: import_zod2.z.string(),
|
|
34352
|
+
schemaId: import_zod2.z.string().optional(),
|
|
34353
|
+
collectedAt: import_zod2.z.string().datetime(),
|
|
34354
|
+
data: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown())
|
|
33653
34355
|
});
|
|
33654
34356
|
function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
33655
34357
|
return {
|
|
@@ -33661,10 +34363,10 @@ function createDataFileEnvelope(scope, collectedAt, data, schemaUrl, schemaId) {
|
|
|
33661
34363
|
data
|
|
33662
34364
|
};
|
|
33663
34365
|
}
|
|
33664
|
-
var IngestResponseSchema =
|
|
33665
|
-
scope:
|
|
33666
|
-
collectedAt:
|
|
33667
|
-
status:
|
|
34366
|
+
var IngestResponseSchema = import_zod2.z.object({
|
|
34367
|
+
scope: import_zod2.z.string(),
|
|
34368
|
+
collectedAt: import_zod2.z.string().datetime(),
|
|
34369
|
+
status: import_zod2.z.enum(["stored", "syncing"])
|
|
33668
34370
|
});
|
|
33669
34371
|
|
|
33670
34372
|
// src/protocol/personal-server-data.ts
|
|
@@ -33698,19 +34400,35 @@ async function readPersonalServerData(params) {
|
|
|
33698
34400
|
}
|
|
33699
34401
|
const request = await buildPersonalServerDataReadRequest(params);
|
|
33700
34402
|
const response = await fetchFn(request);
|
|
34403
|
+
if (response.status === 410) {
|
|
34404
|
+
throw new DataPointDeletedError(
|
|
34405
|
+
`Personal Server scope '${params.scope}' has been deleted`,
|
|
34406
|
+
{
|
|
34407
|
+
scope: params.scope,
|
|
34408
|
+
deletedAt: tombstoneDeletedAt(await readJsonValue(response))
|
|
34409
|
+
}
|
|
34410
|
+
);
|
|
34411
|
+
}
|
|
33701
34412
|
if (!response.ok) {
|
|
33702
34413
|
throw new Error(
|
|
33703
34414
|
`Personal Server data read failed: ${response.status} ${response.statusText}`
|
|
33704
34415
|
);
|
|
33705
34416
|
}
|
|
33706
|
-
|
|
34417
|
+
const body = await response.json();
|
|
34418
|
+
if (isDataPointTombstone(body)) {
|
|
34419
|
+
throw new DataPointDeletedError(
|
|
34420
|
+
`Personal Server scope '${params.scope}' has been deleted`,
|
|
34421
|
+
{ scope: params.scope, deletedAt: tombstoneDeletedAt(body) }
|
|
34422
|
+
);
|
|
34423
|
+
}
|
|
34424
|
+
return DataFileEnvelopeSchema.parse(body);
|
|
33707
34425
|
}
|
|
33708
34426
|
|
|
33709
34427
|
// src/protocol/scopes.ts
|
|
33710
|
-
var
|
|
34428
|
+
var import_zod3 = require("zod");
|
|
33711
34429
|
var SOURCE_RE = /^[a-z0-9][a-z0-9_]*$/;
|
|
33712
34430
|
var TAIL_SEGMENT_RE = /^[a-zA-Z0-9][a-zA-Z0-9_]*$/;
|
|
33713
|
-
var ScopeSchema =
|
|
34431
|
+
var ScopeSchema = import_zod3.z.string().refine(
|
|
33714
34432
|
(scope) => {
|
|
33715
34433
|
const parts = scope.split(".");
|
|
33716
34434
|
if (parts.length < 2 || parts.length > 3) return false;
|
|
@@ -33897,6 +34615,561 @@ function tryGrantPermissions(scopes) {
|
|
|
33897
34615
|
}
|
|
33898
34616
|
}
|
|
33899
34617
|
|
|
34618
|
+
// src/protocol/personal-server-write.ts
|
|
34619
|
+
var import_sha25 = require("@noble/hashes/sha2");
|
|
34620
|
+
var import_viem23 = require("viem");
|
|
34621
|
+
var import_zod4 = require("zod");
|
|
34622
|
+
var WRITE_SESSION_PATH = "/v1/write/session";
|
|
34623
|
+
var WRITE_SIGNATURE_HEADER = "X-Vana-Write-Signature";
|
|
34624
|
+
var WRITE_METADATA_HEADER = "X-Vana-Metadata";
|
|
34625
|
+
var LINEAGE_FIELD = "lineage";
|
|
34626
|
+
var MAX_LINEAGE_SOURCES = 256;
|
|
34627
|
+
var WRITE_FILENAME_HEADER = "X-Filename";
|
|
34628
|
+
var WRITE_CONTENT_DISPOSITION_HEADER = "Content-Disposition";
|
|
34629
|
+
var WRITER_ATTRIBUTION_KEY = "$writtenBy";
|
|
34630
|
+
var LINEAGE_KEY = "$lineage";
|
|
34631
|
+
var RESERVED_WRITE_KEYS = [
|
|
34632
|
+
WRITER_ATTRIBUTION_KEY,
|
|
34633
|
+
LINEAGE_KEY
|
|
34634
|
+
];
|
|
34635
|
+
var WriteDataResultSchema = IngestResponseSchema.extend({
|
|
34636
|
+
// Present when the write carried lineage: the validated, lowercased ids.
|
|
34637
|
+
lineage: import_zod4.z.object({ sources: import_zod4.z.array(import_zod4.z.string()) }).optional()
|
|
34638
|
+
});
|
|
34639
|
+
var WriteSessionResponseSchema = import_zod4.z.object({
|
|
34640
|
+
access_token: import_zod4.z.string().min(1),
|
|
34641
|
+
token_type: import_zod4.z.string(),
|
|
34642
|
+
expires_in: import_zod4.z.number().nonnegative(),
|
|
34643
|
+
scope: import_zod4.z.string()
|
|
34644
|
+
});
|
|
34645
|
+
function normalizeBaseUrl2(url) {
|
|
34646
|
+
return url.replace(/\/+$/, "");
|
|
34647
|
+
}
|
|
34648
|
+
function resolveFetch2(fetchFn) {
|
|
34649
|
+
const resolved = fetchFn ?? globalThis.fetch;
|
|
34650
|
+
if (resolved === void 0) {
|
|
34651
|
+
throw new WriteRequestError("No fetch implementation available");
|
|
34652
|
+
}
|
|
34653
|
+
return resolved;
|
|
34654
|
+
}
|
|
34655
|
+
function dataPath(scope) {
|
|
34656
|
+
return `/v1/data/${encodeURIComponent(scope)}`;
|
|
34657
|
+
}
|
|
34658
|
+
function errorMessage(err) {
|
|
34659
|
+
return err instanceof Error ? err.message : String(err);
|
|
34660
|
+
}
|
|
34661
|
+
function finiteOr(value, fallback) {
|
|
34662
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
34663
|
+
}
|
|
34664
|
+
function sleep2(ms) {
|
|
34665
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
34666
|
+
}
|
|
34667
|
+
var issuedProofIats = /* @__PURE__ */ new Map();
|
|
34668
|
+
var issuedProofBuckets = /* @__PURE__ */ new Map();
|
|
34669
|
+
var issuedProofIatsPrunedAtSec = 0;
|
|
34670
|
+
var WEB3_SIGNED_PROOF_LIFETIME_SECONDS = 300;
|
|
34671
|
+
var WEB3_SIGNED_CLOCK_SKEW_SECONDS = 60;
|
|
34672
|
+
var PROOF_IAT_RETENTION_SECONDS = WEB3_SIGNED_PROOF_LIFETIME_SECONDS + WEB3_SIGNED_CLOCK_SKEW_SECONDS;
|
|
34673
|
+
var PROOF_IAT_MAX_AHEAD_SECONDS = 30;
|
|
34674
|
+
function pruneIssuedProofIats(nowSec) {
|
|
34675
|
+
if (issuedProofIatsPrunedAtSec === nowSec) return;
|
|
34676
|
+
issuedProofIatsPrunedAtSec = nowSec;
|
|
34677
|
+
const cutoff = nowSec - PROOF_IAT_RETENTION_SECONDS;
|
|
34678
|
+
for (const [sec, keys] of issuedProofBuckets) {
|
|
34679
|
+
if (sec >= cutoff) continue;
|
|
34680
|
+
for (const key of keys) issuedProofIats.delete(key);
|
|
34681
|
+
issuedProofBuckets.delete(sec);
|
|
34682
|
+
}
|
|
34683
|
+
}
|
|
34684
|
+
function setIssuedProofIat(key, iat, previous) {
|
|
34685
|
+
if (previous !== void 0) {
|
|
34686
|
+
const bucket2 = issuedProofBuckets.get(previous);
|
|
34687
|
+
bucket2?.delete(key);
|
|
34688
|
+
if (bucket2?.size === 0) issuedProofBuckets.delete(previous);
|
|
34689
|
+
}
|
|
34690
|
+
issuedProofIats.set(key, iat);
|
|
34691
|
+
let bucket = issuedProofBuckets.get(iat);
|
|
34692
|
+
if (bucket === void 0) {
|
|
34693
|
+
bucket = /* @__PURE__ */ new Set();
|
|
34694
|
+
issuedProofBuckets.set(iat, bucket);
|
|
34695
|
+
}
|
|
34696
|
+
bucket.add(key);
|
|
34697
|
+
}
|
|
34698
|
+
function nextProofIat(proofKey) {
|
|
34699
|
+
const nowSec = Math.floor(Date.now() / 1e3);
|
|
34700
|
+
pruneIssuedProofIats(nowSec);
|
|
34701
|
+
const last = issuedProofIats.get(proofKey);
|
|
34702
|
+
const iat = last === void 0 ? nowSec : Math.max(nowSec, last + 1);
|
|
34703
|
+
setIssuedProofIat(proofKey, iat, last);
|
|
34704
|
+
const waitSec = iat - nowSec - PROOF_IAT_MAX_AHEAD_SECONDS;
|
|
34705
|
+
if (waitSec <= 0) return Promise.resolve(iat);
|
|
34706
|
+
return sleep2(waitSec * 1e3).then(() => iat);
|
|
34707
|
+
}
|
|
34708
|
+
function proofKeyFor(parts) {
|
|
34709
|
+
return (0, import_viem23.bytesToHex)(
|
|
34710
|
+
(0, import_sha25.sha256)(
|
|
34711
|
+
new TextEncoder().encode(
|
|
34712
|
+
JSON.stringify([
|
|
34713
|
+
parts.aud,
|
|
34714
|
+
parts.method,
|
|
34715
|
+
parts.uri,
|
|
34716
|
+
parts.grantId,
|
|
34717
|
+
parts.signedBytes ? (0, import_viem23.bytesToHex)((0, import_sha25.sha256)(parts.signedBytes)) : ""
|
|
34718
|
+
])
|
|
34719
|
+
)
|
|
34720
|
+
)
|
|
34721
|
+
);
|
|
34722
|
+
}
|
|
34723
|
+
async function sendWithFreshProof(label, fetchFn, options, proofKey, build) {
|
|
34724
|
+
const attempts = Math.max(1, Math.floor(finiteOr(options?.attempts, 3)));
|
|
34725
|
+
let delayMs = Math.max(0, finiteOr(options?.initialDelayMs, 1e3));
|
|
34726
|
+
let lastError;
|
|
34727
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
34728
|
+
const { url, init } = await build(await nextProofIat(proofKey));
|
|
34729
|
+
try {
|
|
34730
|
+
return await fetchFn(url, init);
|
|
34731
|
+
} catch (err) {
|
|
34732
|
+
lastError = err;
|
|
34733
|
+
}
|
|
34734
|
+
if (attempt < attempts - 1) {
|
|
34735
|
+
await sleep2(delayMs);
|
|
34736
|
+
delayMs *= 2;
|
|
34737
|
+
}
|
|
34738
|
+
}
|
|
34739
|
+
throw new WriteTransportError(
|
|
34740
|
+
`${label} failed after ${attempts} attempt(s): ${errorMessage(lastError)}`,
|
|
34741
|
+
attempts,
|
|
34742
|
+
lastError
|
|
34743
|
+
);
|
|
34744
|
+
}
|
|
34745
|
+
async function openWriteSession(params) {
|
|
34746
|
+
const fetchFn = resolveFetch2(params.fetch);
|
|
34747
|
+
const personalServerUrl = normalizeBaseUrl2(params.personalServerUrl);
|
|
34748
|
+
const audience = params.audience ?? personalServerUrl;
|
|
34749
|
+
const signer = resolveWriteSigner(params.signer, { account: params.account });
|
|
34750
|
+
const response = await sendWithFreshProof(
|
|
34751
|
+
"Write session handshake",
|
|
34752
|
+
fetchFn,
|
|
34753
|
+
params.retry,
|
|
34754
|
+
proofKeyFor({
|
|
34755
|
+
aud: audience,
|
|
34756
|
+
method: "POST",
|
|
34757
|
+
uri: WRITE_SESSION_PATH,
|
|
34758
|
+
grantId: params.grantId
|
|
34759
|
+
}),
|
|
34760
|
+
async (iat) => {
|
|
34761
|
+
const headers = new Headers(params.headers);
|
|
34762
|
+
headers.set(
|
|
34763
|
+
"Authorization",
|
|
34764
|
+
await buildWeb3SignedHeader({
|
|
34765
|
+
signMessage: signer.signMessage,
|
|
34766
|
+
aud: audience,
|
|
34767
|
+
method: "POST",
|
|
34768
|
+
uri: WRITE_SESSION_PATH,
|
|
34769
|
+
grantId: params.grantId,
|
|
34770
|
+
iat
|
|
34771
|
+
})
|
|
34772
|
+
);
|
|
34773
|
+
return {
|
|
34774
|
+
url: `${personalServerUrl}${WRITE_SESSION_PATH}`,
|
|
34775
|
+
init: { method: "POST", headers }
|
|
34776
|
+
};
|
|
34777
|
+
}
|
|
34778
|
+
);
|
|
34779
|
+
const mintedAt = Date.now();
|
|
34780
|
+
if (!response.ok) {
|
|
34781
|
+
const { errorCode, message, details } = await readPersonalServerErrorBody(response);
|
|
34782
|
+
throw new WriteSessionError(
|
|
34783
|
+
message ?? `Write session handshake failed: ${response.status} ${response.statusText}`,
|
|
34784
|
+
response.status,
|
|
34785
|
+
errorCode,
|
|
34786
|
+
details
|
|
34787
|
+
);
|
|
34788
|
+
}
|
|
34789
|
+
let body;
|
|
34790
|
+
try {
|
|
34791
|
+
body = await response.json();
|
|
34792
|
+
} catch (err) {
|
|
34793
|
+
throw new WriteSessionError(
|
|
34794
|
+
"Write session response is not JSON",
|
|
34795
|
+
response.status,
|
|
34796
|
+
null,
|
|
34797
|
+
{ cause: errorMessage(err) }
|
|
34798
|
+
);
|
|
34799
|
+
}
|
|
34800
|
+
const parsed = WriteSessionResponseSchema.safeParse(body);
|
|
34801
|
+
if (!parsed.success) {
|
|
34802
|
+
throw new WriteSessionError(
|
|
34803
|
+
"Write session response is not a session",
|
|
34804
|
+
response.status,
|
|
34805
|
+
null,
|
|
34806
|
+
{ issues: parsed.error.issues }
|
|
34807
|
+
);
|
|
34808
|
+
}
|
|
34809
|
+
if (parsed.data.token_type.toLowerCase() !== "bearer") {
|
|
34810
|
+
throw new WriteSessionError(
|
|
34811
|
+
`Write session token type is not Bearer: ${parsed.data.token_type}`,
|
|
34812
|
+
response.status
|
|
34813
|
+
);
|
|
34814
|
+
}
|
|
34815
|
+
return {
|
|
34816
|
+
personalServerUrl,
|
|
34817
|
+
audience,
|
|
34818
|
+
grantId: params.grantId,
|
|
34819
|
+
accessToken: parsed.data.access_token,
|
|
34820
|
+
expiresAt: mintedAt + parsed.data.expires_in * 1e3,
|
|
34821
|
+
writeScopes: parsed.data.scope.split(" ").filter((s) => s.length > 0),
|
|
34822
|
+
signer
|
|
34823
|
+
};
|
|
34824
|
+
}
|
|
34825
|
+
function isWriteSession(value) {
|
|
34826
|
+
if (!isRecord2(value)) return false;
|
|
34827
|
+
const signer = value.signer;
|
|
34828
|
+
return typeof value.personalServerUrl === "string" && typeof value.audience === "string" && typeof value.grantId === "string" && typeof value.accessToken === "string" && value.accessToken.length > 0 && typeof value.expiresAt === "number" && Number.isFinite(value.expiresAt) && Array.isArray(value.writeScopes) && value.writeScopes.every((scope) => typeof scope === "string") && isRecord2(signer) && typeof signer.signMessage === "function";
|
|
34829
|
+
}
|
|
34830
|
+
function sessionCoversScope(session, scope) {
|
|
34831
|
+
if (!isRecord2(session) || !Array.isArray(session.writeScopes) || !session.writeScopes.every((pattern) => typeof pattern === "string")) {
|
|
34832
|
+
throw new WriteRequestError("session must come from openWriteSession");
|
|
34833
|
+
}
|
|
34834
|
+
return session.writeScopes.some(
|
|
34835
|
+
(pattern) => scopeMatchesPattern(scope, pattern)
|
|
34836
|
+
);
|
|
34837
|
+
}
|
|
34838
|
+
function normalizeBinaryMimeType(contentType) {
|
|
34839
|
+
if (!contentType) return "application/octet-stream";
|
|
34840
|
+
return contentType.split(";")[0].trim() || "application/octet-stream";
|
|
34841
|
+
}
|
|
34842
|
+
function parseWriteMetadataHeader(value) {
|
|
34843
|
+
if (value === null) return void 0;
|
|
34844
|
+
const trimmed = value.trim();
|
|
34845
|
+
if (trimmed === "") return void 0;
|
|
34846
|
+
try {
|
|
34847
|
+
return JSON.parse(trimmed);
|
|
34848
|
+
} catch {
|
|
34849
|
+
return value;
|
|
34850
|
+
}
|
|
34851
|
+
}
|
|
34852
|
+
function encodeWriteMetadataHeader(metadata) {
|
|
34853
|
+
let json;
|
|
34854
|
+
try {
|
|
34855
|
+
json = JSON.stringify(metadata);
|
|
34856
|
+
} catch (err) {
|
|
34857
|
+
throw new WriteRequestError(
|
|
34858
|
+
`metadata is not JSON-serialisable: ${errorMessage(err)}`
|
|
34859
|
+
);
|
|
34860
|
+
}
|
|
34861
|
+
if (typeof json !== "string") {
|
|
34862
|
+
throw new WriteRequestError("metadata must serialise to JSON");
|
|
34863
|
+
}
|
|
34864
|
+
return json.replace(
|
|
34865
|
+
/[\u007f-\uffff]/g,
|
|
34866
|
+
(c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`
|
|
34867
|
+
);
|
|
34868
|
+
}
|
|
34869
|
+
function binaryWriteSignedBytes(input) {
|
|
34870
|
+
const metadata = parseWriteMetadataHeader(input.metadataHeader ?? null);
|
|
34871
|
+
const record = {
|
|
34872
|
+
$binary: true,
|
|
34873
|
+
mimeType: normalizeBinaryMimeType(input.contentType),
|
|
34874
|
+
...input.filename ? { filename: input.filename } : {},
|
|
34875
|
+
sizeBytes: input.bytes.length,
|
|
34876
|
+
contentHash: (0, import_viem23.bytesToHex)((0, import_sha25.sha256)(input.bytes)),
|
|
34877
|
+
encoding: "base64",
|
|
34878
|
+
content: toBase64(input.bytes),
|
|
34879
|
+
...metadata !== void 0 ? { metadata } : {}
|
|
34880
|
+
};
|
|
34881
|
+
return new TextEncoder().encode(JSON.stringify(record));
|
|
34882
|
+
}
|
|
34883
|
+
var PRINTABLE_ASCII = /^[\x20-\x7e]*$/;
|
|
34884
|
+
function setFilenameHeader(headers, filename) {
|
|
34885
|
+
if (PRINTABLE_ASCII.test(filename)) {
|
|
34886
|
+
headers.set(WRITE_FILENAME_HEADER, filename);
|
|
34887
|
+
return;
|
|
34888
|
+
}
|
|
34889
|
+
headers.set(
|
|
34890
|
+
WRITE_CONTENT_DISPOSITION_HEADER,
|
|
34891
|
+
`attachment; filename*=UTF-8''${encodeURIComponent(filename)}`
|
|
34892
|
+
);
|
|
34893
|
+
}
|
|
34894
|
+
function assertNoReservedKeys(value, where) {
|
|
34895
|
+
for (const key of RESERVED_WRITE_KEYS) {
|
|
34896
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
|
34897
|
+
throw new WriteRequestError(
|
|
34898
|
+
`${where} must not contain the reserved ${key} key; the Personal Server stamps it`,
|
|
34899
|
+
{ key }
|
|
34900
|
+
);
|
|
34901
|
+
}
|
|
34902
|
+
}
|
|
34903
|
+
}
|
|
34904
|
+
function isLineagePair(value) {
|
|
34905
|
+
return isRecord2(value) && typeof value.ownerAddress === "string" && typeof value.scope === "string";
|
|
34906
|
+
}
|
|
34907
|
+
function normalizeLineage(lineage, derivedScope) {
|
|
34908
|
+
if (!Array.isArray(lineage)) {
|
|
34909
|
+
throw new WriteRequestError("lineage must be an array of data point ids");
|
|
34910
|
+
}
|
|
34911
|
+
if (lineage.length > MAX_LINEAGE_SOURCES) {
|
|
34912
|
+
throw new WriteRequestError(
|
|
34913
|
+
`lineage lists ${lineage.length} sources; the maximum is ${MAX_LINEAGE_SOURCES}`,
|
|
34914
|
+
{ max: MAX_LINEAGE_SOURCES, count: lineage.length }
|
|
34915
|
+
);
|
|
34916
|
+
}
|
|
34917
|
+
const seen = /* @__PURE__ */ new Set();
|
|
34918
|
+
const sources = [];
|
|
34919
|
+
const sourceScopes = [];
|
|
34920
|
+
const ownIds = /* @__PURE__ */ new Set();
|
|
34921
|
+
for (const entry of lineage) {
|
|
34922
|
+
let id;
|
|
34923
|
+
if (isLineagePair(entry)) {
|
|
34924
|
+
if (!(0, import_viem23.isAddress)(entry.ownerAddress, { strict: false })) {
|
|
34925
|
+
throw new WriteRequestError(
|
|
34926
|
+
"lineage source ownerAddress must be an EVM address",
|
|
34927
|
+
{ ownerAddress: entry.ownerAddress }
|
|
34928
|
+
);
|
|
34929
|
+
}
|
|
34930
|
+
if (entry.scope.length === 0) {
|
|
34931
|
+
throw new WriteRequestError("lineage source scope is required");
|
|
34932
|
+
}
|
|
34933
|
+
id = deriveDataPointId(entry.ownerAddress, entry.scope);
|
|
34934
|
+
sourceScopes.push(entry.scope);
|
|
34935
|
+
ownIds.add(deriveDataPointId(entry.ownerAddress, derivedScope));
|
|
34936
|
+
} else if (isDataPointId(entry)) {
|
|
34937
|
+
id = entry;
|
|
34938
|
+
} else {
|
|
34939
|
+
throw new WriteRequestError(
|
|
34940
|
+
"lineage entries must be 32-byte hex data point ids or { ownerAddress, scope } pairs",
|
|
34941
|
+
{ entry }
|
|
34942
|
+
);
|
|
34943
|
+
}
|
|
34944
|
+
const normalized = id.toLowerCase();
|
|
34945
|
+
if (seen.has(normalized)) {
|
|
34946
|
+
throw new WriteRequestError("lineage must not repeat a data point id", {
|
|
34947
|
+
dataPointId: normalized
|
|
34948
|
+
});
|
|
34949
|
+
}
|
|
34950
|
+
seen.add(normalized);
|
|
34951
|
+
sources.push(normalized);
|
|
34952
|
+
}
|
|
34953
|
+
for (const own of ownIds) {
|
|
34954
|
+
if (seen.has(own)) {
|
|
34955
|
+
throw new WriteRequestError(
|
|
34956
|
+
"lineage must not cite the record's own data point",
|
|
34957
|
+
{ dataPointId: own, scope: derivedScope }
|
|
34958
|
+
);
|
|
34959
|
+
}
|
|
34960
|
+
}
|
|
34961
|
+
assertDerivedScopeNaming(derivedScope, sourceScopes);
|
|
34962
|
+
return sources;
|
|
34963
|
+
}
|
|
34964
|
+
function assertNoLineageField(value, where) {
|
|
34965
|
+
if (Object.prototype.hasOwnProperty.call(value, LINEAGE_FIELD)) {
|
|
34966
|
+
throw new WriteRequestError(
|
|
34967
|
+
`${where}.${LINEAGE_FIELD} is reserved; pass sources through the lineage option`
|
|
34968
|
+
);
|
|
34969
|
+
}
|
|
34970
|
+
}
|
|
34971
|
+
function buildMetadataHeader(metadata, sources) {
|
|
34972
|
+
if (metadata !== void 0) {
|
|
34973
|
+
if (!isRecord2(metadata)) {
|
|
34974
|
+
throw new WriteRequestError("metadata must be a plain object");
|
|
34975
|
+
}
|
|
34976
|
+
assertNoReservedKeys(metadata, "metadata");
|
|
34977
|
+
assertNoLineageField(metadata, "metadata");
|
|
34978
|
+
}
|
|
34979
|
+
if (metadata === void 0 && sources === void 0) return void 0;
|
|
34980
|
+
return encodeWriteMetadataHeader({
|
|
34981
|
+
...metadata ?? {},
|
|
34982
|
+
...sources !== void 0 ? { [LINEAGE_FIELD]: sources } : {}
|
|
34983
|
+
});
|
|
34984
|
+
}
|
|
34985
|
+
function prepareWrite(params) {
|
|
34986
|
+
if (params.binary !== void 0 && params.data !== void 0) {
|
|
34987
|
+
throw new WriteRequestError("Pass either data or binary, not both");
|
|
34988
|
+
}
|
|
34989
|
+
const rawLineage = params.lineage;
|
|
34990
|
+
const sources = rawLineage === void 0 || rawLineage === null ? void 0 : normalizeLineage(rawLineage, params.scope);
|
|
34991
|
+
if (params.binary !== void 0) {
|
|
34992
|
+
const { bytes, contentType, filename } = params.binary;
|
|
34993
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
34994
|
+
throw new WriteRequestError("binary.bytes must be a Uint8Array");
|
|
34995
|
+
}
|
|
34996
|
+
if (typeof contentType !== "string" || contentType.trim() === "") {
|
|
34997
|
+
throw new WriteRequestError("binary.contentType is required");
|
|
34998
|
+
}
|
|
34999
|
+
if (filename !== void 0) {
|
|
35000
|
+
if (typeof filename !== "string") {
|
|
35001
|
+
throw new WriteRequestError("binary.filename must be a string");
|
|
35002
|
+
}
|
|
35003
|
+
if (filename !== filename.trim()) {
|
|
35004
|
+
throw new WriteRequestError(
|
|
35005
|
+
"binary.filename must not have leading or trailing whitespace"
|
|
35006
|
+
);
|
|
35007
|
+
}
|
|
35008
|
+
}
|
|
35009
|
+
const metadataHeader = buildMetadataHeader(params.metadata, sources);
|
|
35010
|
+
return {
|
|
35011
|
+
body: bytes,
|
|
35012
|
+
signedBytes: binaryWriteSignedBytes({
|
|
35013
|
+
bytes,
|
|
35014
|
+
contentType,
|
|
35015
|
+
filename,
|
|
35016
|
+
metadataHeader
|
|
35017
|
+
}),
|
|
35018
|
+
contentType,
|
|
35019
|
+
filename,
|
|
35020
|
+
metadataHeader
|
|
35021
|
+
};
|
|
35022
|
+
}
|
|
35023
|
+
if (params.data === void 0) {
|
|
35024
|
+
throw new WriteRequestError("Pass data (a JSON object) or binary");
|
|
35025
|
+
}
|
|
35026
|
+
if (!isRecord2(params.data)) {
|
|
35027
|
+
throw new WriteRequestError("data must be a plain JSON object");
|
|
35028
|
+
}
|
|
35029
|
+
if (params.metadata !== void 0) {
|
|
35030
|
+
throw new WriteRequestError(
|
|
35031
|
+
"metadata applies to binary writes; put fields to store inside data"
|
|
35032
|
+
);
|
|
35033
|
+
}
|
|
35034
|
+
assertNoReservedKeys(params.data, "data");
|
|
35035
|
+
assertNoLineageField(params.data, "data");
|
|
35036
|
+
const record = sources === void 0 ? params.data : { ...params.data, [LINEAGE_FIELD]: sources };
|
|
35037
|
+
let text;
|
|
35038
|
+
try {
|
|
35039
|
+
text = JSON.stringify(record);
|
|
35040
|
+
} catch (err) {
|
|
35041
|
+
throw new WriteRequestError(
|
|
35042
|
+
`data is not JSON-serialisable: ${errorMessage(err)}`
|
|
35043
|
+
);
|
|
35044
|
+
}
|
|
35045
|
+
if (typeof text !== "string" || !text.startsWith("{")) {
|
|
35046
|
+
throw new WriteRequestError("data must serialise to a JSON object");
|
|
35047
|
+
}
|
|
35048
|
+
const body = new TextEncoder().encode(text);
|
|
35049
|
+
return {
|
|
35050
|
+
body,
|
|
35051
|
+
signedBytes: body,
|
|
35052
|
+
contentType: "application/json"
|
|
35053
|
+
};
|
|
35054
|
+
}
|
|
35055
|
+
async function writeErrorFromResponse(response) {
|
|
35056
|
+
const { errorCode, message, details } = await readPersonalServerErrorBody(response);
|
|
35057
|
+
const text = message ?? `Personal Server write failed: ${response.status} ${response.statusText}`;
|
|
35058
|
+
if (response.status === 422 || errorCode?.startsWith("LINEAGE_")) {
|
|
35059
|
+
return new WriteLineageError(text, response.status, errorCode, details);
|
|
35060
|
+
}
|
|
35061
|
+
switch (response.status) {
|
|
35062
|
+
case 401:
|
|
35063
|
+
return new WriteUnauthorizedError(text, errorCode, details);
|
|
35064
|
+
case 403:
|
|
35065
|
+
return new WriteForbiddenError(text, errorCode, details);
|
|
35066
|
+
case 409:
|
|
35067
|
+
return new WriteConflictError(text, errorCode, details);
|
|
35068
|
+
default:
|
|
35069
|
+
return new WriteRejectedError(text, response.status, errorCode, details);
|
|
35070
|
+
}
|
|
35071
|
+
}
|
|
35072
|
+
async function writeData(params) {
|
|
35073
|
+
const { session } = params;
|
|
35074
|
+
if (!isWriteSession(session)) {
|
|
35075
|
+
throw new WriteRequestError("session must come from openWriteSession");
|
|
35076
|
+
}
|
|
35077
|
+
const fetchFn = resolveFetch2(params.fetch);
|
|
35078
|
+
if (typeof params.scope !== "string" || params.scope.length === 0) {
|
|
35079
|
+
throw new WriteRequestError("scope is required");
|
|
35080
|
+
}
|
|
35081
|
+
const prepared = prepareWrite(params);
|
|
35082
|
+
if (Date.now() >= session.expiresAt) {
|
|
35083
|
+
throw new WriteSessionExpiredError(
|
|
35084
|
+
"Write session has expired; open a new session",
|
|
35085
|
+
{ grantId: session.grantId, expiresAt: session.expiresAt }
|
|
35086
|
+
);
|
|
35087
|
+
}
|
|
35088
|
+
const path = dataPath(params.scope);
|
|
35089
|
+
const response = await sendWithFreshProof(
|
|
35090
|
+
`Write to ${params.scope}`,
|
|
35091
|
+
fetchFn,
|
|
35092
|
+
params.retry,
|
|
35093
|
+
proofKeyFor({
|
|
35094
|
+
aud: session.audience,
|
|
35095
|
+
method: "POST",
|
|
35096
|
+
uri: path,
|
|
35097
|
+
grantId: session.grantId,
|
|
35098
|
+
signedBytes: prepared.signedBytes
|
|
35099
|
+
}),
|
|
35100
|
+
async (iat) => {
|
|
35101
|
+
const headers = new Headers(params.headers);
|
|
35102
|
+
headers.set("Content-Type", prepared.contentType);
|
|
35103
|
+
headers.set("Authorization", `Bearer ${session.accessToken}`);
|
|
35104
|
+
if (prepared.filename) {
|
|
35105
|
+
setFilenameHeader(headers, prepared.filename);
|
|
35106
|
+
}
|
|
35107
|
+
if (prepared.metadataHeader !== void 0) {
|
|
35108
|
+
headers.set(WRITE_METADATA_HEADER, prepared.metadataHeader);
|
|
35109
|
+
}
|
|
35110
|
+
headers.set(
|
|
35111
|
+
WRITE_SIGNATURE_HEADER,
|
|
35112
|
+
await buildWeb3SignedHeader({
|
|
35113
|
+
signMessage: session.signer.signMessage,
|
|
35114
|
+
aud: session.audience,
|
|
35115
|
+
method: "POST",
|
|
35116
|
+
uri: path,
|
|
35117
|
+
body: prepared.signedBytes,
|
|
35118
|
+
grantId: session.grantId,
|
|
35119
|
+
iat
|
|
35120
|
+
})
|
|
35121
|
+
);
|
|
35122
|
+
return {
|
|
35123
|
+
url: `${session.personalServerUrl}${path}`,
|
|
35124
|
+
init: {
|
|
35125
|
+
method: "POST",
|
|
35126
|
+
headers,
|
|
35127
|
+
body: prepared.body
|
|
35128
|
+
}
|
|
35129
|
+
};
|
|
35130
|
+
}
|
|
35131
|
+
);
|
|
35132
|
+
if (!response.ok) {
|
|
35133
|
+
throw await writeErrorFromResponse(response);
|
|
35134
|
+
}
|
|
35135
|
+
let body;
|
|
35136
|
+
try {
|
|
35137
|
+
body = await response.json();
|
|
35138
|
+
} catch (err) {
|
|
35139
|
+
throw new WriteRejectedError(
|
|
35140
|
+
"Personal Server write response is not JSON",
|
|
35141
|
+
response.status,
|
|
35142
|
+
null,
|
|
35143
|
+
{ cause: errorMessage(err) }
|
|
35144
|
+
);
|
|
35145
|
+
}
|
|
35146
|
+
const parsed = WriteDataResultSchema.safeParse(body);
|
|
35147
|
+
if (!parsed.success) {
|
|
35148
|
+
throw new WriteRejectedError(
|
|
35149
|
+
"Personal Server write response is not an ingest result",
|
|
35150
|
+
response.status,
|
|
35151
|
+
null,
|
|
35152
|
+
{ issues: parsed.error.issues }
|
|
35153
|
+
);
|
|
35154
|
+
}
|
|
35155
|
+
return parsed.data;
|
|
35156
|
+
}
|
|
35157
|
+
async function writePersonalServerData(params) {
|
|
35158
|
+
const session = await openWriteSession({
|
|
35159
|
+
personalServerUrl: params.personalServerUrl,
|
|
35160
|
+
signer: params.signer,
|
|
35161
|
+
grantId: params.grantId,
|
|
35162
|
+
account: params.account,
|
|
35163
|
+
audience: params.audience,
|
|
35164
|
+
fetch: params.fetch,
|
|
35165
|
+
headers: params.headers,
|
|
35166
|
+
retry: params.retry
|
|
35167
|
+
});
|
|
35168
|
+
const writeParams = { ...params, session };
|
|
35169
|
+
const result = await writeData(writeParams);
|
|
35170
|
+
return { ...result, session };
|
|
35171
|
+
}
|
|
35172
|
+
|
|
33900
35173
|
// src/protocol/gateway.ts
|
|
33901
35174
|
function withGrantPermissions(grant) {
|
|
33902
35175
|
const stripped = { ...grant };
|
|
@@ -33910,14 +35183,44 @@ function withGrantPermissions(grant) {
|
|
|
33910
35183
|
}
|
|
33911
35184
|
function createGatewayClient(baseUrl) {
|
|
33912
35185
|
const base = baseUrl.replace(/\/+$/, "");
|
|
35186
|
+
function malformedBody(res) {
|
|
35187
|
+
return new Error(
|
|
35188
|
+
`Gateway error: ${res.status} malformed response body (expected a JSON envelope)`
|
|
35189
|
+
);
|
|
35190
|
+
}
|
|
35191
|
+
async function readEnvelope(res) {
|
|
35192
|
+
const envelope = await readJsonValue(res);
|
|
35193
|
+
if (!isPlainObject(envelope) || !("data" in envelope)) {
|
|
35194
|
+
throw malformedBody(res);
|
|
35195
|
+
}
|
|
35196
|
+
return envelope;
|
|
35197
|
+
}
|
|
33913
35198
|
async function unwrapEnvelope(res) {
|
|
33914
|
-
|
|
33915
|
-
return envelope.data;
|
|
35199
|
+
return (await readEnvelope(res)).data;
|
|
33916
35200
|
}
|
|
33917
35201
|
function getMutationId(body, key) {
|
|
35202
|
+
if (!isPlainObject(body)) return void 0;
|
|
33918
35203
|
const value = body[key] ?? body["id"];
|
|
33919
35204
|
return typeof value === "string" ? value : void 0;
|
|
33920
35205
|
}
|
|
35206
|
+
async function readBody(res) {
|
|
35207
|
+
const raw = await readJsonObject(res);
|
|
35208
|
+
const data = raw["data"];
|
|
35209
|
+
if (isPlainObject(data) && "proof" in raw) {
|
|
35210
|
+
return data;
|
|
35211
|
+
}
|
|
35212
|
+
return raw;
|
|
35213
|
+
}
|
|
35214
|
+
function stringOrUndefined(value) {
|
|
35215
|
+
return typeof value === "string" ? value : void 0;
|
|
35216
|
+
}
|
|
35217
|
+
async function deletedError(res, details) {
|
|
35218
|
+
const body = await readBody(res);
|
|
35219
|
+
return new DataPointDeletedError(
|
|
35220
|
+
`Data point ${details.dataPointId ?? details.scope ?? ""} has been deleted`,
|
|
35221
|
+
{ ...details, deletedAt: tombstoneDeletedAt(body) }
|
|
35222
|
+
);
|
|
35223
|
+
}
|
|
33921
35224
|
return {
|
|
33922
35225
|
async isRegisteredBuilder(address) {
|
|
33923
35226
|
const builder = await this.getBuilder(address);
|
|
@@ -33974,13 +35277,29 @@ function createGatewayClient(baseUrl) {
|
|
|
33974
35277
|
}
|
|
33975
35278
|
return await res.json();
|
|
33976
35279
|
},
|
|
33977
|
-
async getDataPoint(dataPointId) {
|
|
33978
|
-
const
|
|
35280
|
+
async getDataPoint(dataPointId, options) {
|
|
35281
|
+
const query = options?.includeDeleted ? "?includeDeleted=true" : "";
|
|
35282
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}${query}`);
|
|
33979
35283
|
if (res.status === 404) return null;
|
|
35284
|
+
if (res.status === 410) {
|
|
35285
|
+
throw await deletedError(res, { dataPointId });
|
|
35286
|
+
}
|
|
33980
35287
|
if (!res.ok) {
|
|
33981
35288
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33982
35289
|
}
|
|
33983
|
-
|
|
35290
|
+
const record = await unwrapEnvelope(res);
|
|
35291
|
+
if (!options?.includeDeleted && isDataPointTombstone(record)) {
|
|
35292
|
+
throw new DataPointDeletedError(
|
|
35293
|
+
`Data point ${dataPointId} has been deleted`,
|
|
35294
|
+
{
|
|
35295
|
+
dataPointId,
|
|
35296
|
+
scope: record.scope,
|
|
35297
|
+
ownerAddress: record.ownerAddress,
|
|
35298
|
+
deletedAt: tombstoneDeletedAt(record)
|
|
35299
|
+
}
|
|
35300
|
+
);
|
|
35301
|
+
}
|
|
35302
|
+
return record;
|
|
33984
35303
|
},
|
|
33985
35304
|
async listDataPointsByOwner(owner, cursor, options) {
|
|
33986
35305
|
const params = new URLSearchParams({ user: owner });
|
|
@@ -33993,14 +35312,24 @@ function createGatewayClient(baseUrl) {
|
|
|
33993
35312
|
if (options?.limit !== void 0) {
|
|
33994
35313
|
params.set("limit", String(options.limit));
|
|
33995
35314
|
}
|
|
35315
|
+
if (options?.includeDeleted) {
|
|
35316
|
+
params.set("includeDeleted", "true");
|
|
35317
|
+
}
|
|
33996
35318
|
const res = await fetch(`${base}/v1/data?${params.toString()}`);
|
|
33997
35319
|
if (!res.ok) {
|
|
33998
35320
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
33999
35321
|
}
|
|
34000
|
-
const envelope = await res
|
|
34001
|
-
|
|
35322
|
+
const envelope = await readEnvelope(res);
|
|
35323
|
+
if (!isPlainObject(envelope.data) || !Array.isArray(envelope.data["dataPoints"])) {
|
|
35324
|
+
throw malformedBody(res);
|
|
35325
|
+
}
|
|
35326
|
+
const rows = envelope.data["dataPoints"];
|
|
35327
|
+
const pagination = isPlainObject(envelope["pagination"]) ? envelope["pagination"] : void 0;
|
|
35328
|
+
const rawCursor = pagination?.["nextCursor"];
|
|
35329
|
+
const nextCursor = pagination?.["hasMore"] === false || typeof rawCursor !== "string" ? null : rawCursor;
|
|
35330
|
+
const dataPoints = options?.includeDeleted ? rows : rows.filter((row) => !isDataPointTombstone(row));
|
|
34002
35331
|
return {
|
|
34003
|
-
dataPoints
|
|
35332
|
+
dataPoints,
|
|
34004
35333
|
cursor: nextCursor
|
|
34005
35334
|
};
|
|
34006
35335
|
},
|
|
@@ -34027,7 +35356,7 @@ function createGatewayClient(baseUrl) {
|
|
|
34027
35356
|
})
|
|
34028
35357
|
});
|
|
34029
35358
|
if (res.status === 409) {
|
|
34030
|
-
const body2 = await res
|
|
35359
|
+
const body2 = await readJsonObject(res);
|
|
34031
35360
|
return {
|
|
34032
35361
|
serverId: getMutationId(body2, "serverId"),
|
|
34033
35362
|
alreadyRegistered: true
|
|
@@ -34036,7 +35365,7 @@ function createGatewayClient(baseUrl) {
|
|
|
34036
35365
|
if (!res.ok) {
|
|
34037
35366
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
34038
35367
|
}
|
|
34039
|
-
const body = await res
|
|
35368
|
+
const body = await readJsonObject(res);
|
|
34040
35369
|
return {
|
|
34041
35370
|
serverId: getMutationId(body, "serverId"),
|
|
34042
35371
|
alreadyRegistered: false
|
|
@@ -34057,19 +35386,16 @@ function createGatewayClient(baseUrl) {
|
|
|
34057
35386
|
})
|
|
34058
35387
|
});
|
|
34059
35388
|
if (res.status === 409) {
|
|
34060
|
-
const body2 = await res
|
|
35389
|
+
const body2 = await readJsonObject(res);
|
|
34061
35390
|
return {
|
|
34062
|
-
builderId: getMutationId(
|
|
34063
|
-
body2,
|
|
34064
|
-
"builderId"
|
|
34065
|
-
),
|
|
35391
|
+
builderId: getMutationId(body2, "builderId"),
|
|
34066
35392
|
alreadyRegistered: true
|
|
34067
35393
|
};
|
|
34068
35394
|
}
|
|
34069
35395
|
if (!res.ok) {
|
|
34070
35396
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
34071
35397
|
}
|
|
34072
|
-
const body = await res
|
|
35398
|
+
const body = await readJsonObject(res);
|
|
34073
35399
|
return {
|
|
34074
35400
|
builderId: getMutationId(body, "builderId"),
|
|
34075
35401
|
alreadyRegistered: false
|
|
@@ -34091,17 +35417,77 @@ function createGatewayClient(baseUrl) {
|
|
|
34091
35417
|
})
|
|
34092
35418
|
});
|
|
34093
35419
|
if (!res.ok) {
|
|
34094
|
-
const body2 = await res
|
|
34095
|
-
const detail = body2
|
|
35420
|
+
const body2 = await readJsonObject(res);
|
|
35421
|
+
const detail = stringOrUndefined(body2["error"]) ?? res.statusText;
|
|
35422
|
+
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
35423
|
+
}
|
|
35424
|
+
const body = await readJsonObject(res);
|
|
35425
|
+
return {
|
|
35426
|
+
dataPointId: getMutationId(body, "dataPointId"),
|
|
35427
|
+
expectedVersion: stringOrUndefined(body["expectedVersion"])
|
|
35428
|
+
};
|
|
35429
|
+
},
|
|
35430
|
+
async deleteDataPoint(params) {
|
|
35431
|
+
const dataPointId = deriveDataPointId(
|
|
35432
|
+
params.ownerAddress,
|
|
35433
|
+
params.scope
|
|
35434
|
+
);
|
|
35435
|
+
const details = {
|
|
35436
|
+
dataPointId,
|
|
35437
|
+
scope: params.scope,
|
|
35438
|
+
ownerAddress: params.ownerAddress
|
|
35439
|
+
};
|
|
35440
|
+
const res = await fetch(`${base}/v1/data/${dataPointId}`, {
|
|
35441
|
+
method: "DELETE",
|
|
35442
|
+
headers: {
|
|
35443
|
+
"Content-Type": "application/json",
|
|
35444
|
+
Authorization: `Web3Signed ${params.signature}`
|
|
35445
|
+
},
|
|
35446
|
+
body: JSON.stringify({
|
|
35447
|
+
ownerAddress: params.ownerAddress,
|
|
35448
|
+
scope: params.scope,
|
|
35449
|
+
expectedVersion: params.expectedVersion,
|
|
35450
|
+
signature: params.signature
|
|
35451
|
+
})
|
|
35452
|
+
});
|
|
35453
|
+
if (res.status === 404) {
|
|
35454
|
+
throw new DataPointNotFoundError(
|
|
35455
|
+
`Data point ${dataPointId} (scope '${params.scope}') is not registered`,
|
|
35456
|
+
details
|
|
35457
|
+
);
|
|
35458
|
+
}
|
|
35459
|
+
if (res.status === 409) {
|
|
35460
|
+
const body2 = await readBody(res);
|
|
35461
|
+
const currentExpectedVersion = stringOrUndefined(
|
|
35462
|
+
body2["currentExpectedVersion"]
|
|
35463
|
+
);
|
|
35464
|
+
const detail = stringOrUndefined(body2["error"]) ?? res.statusText;
|
|
35465
|
+
throw new DataPointVersionConflictError(
|
|
35466
|
+
`Gateway error: 409 ${detail}`,
|
|
35467
|
+
{
|
|
35468
|
+
...details,
|
|
35469
|
+
expectedVersion: params.expectedVersion,
|
|
35470
|
+
currentExpectedVersion
|
|
35471
|
+
}
|
|
35472
|
+
);
|
|
35473
|
+
}
|
|
35474
|
+
if (res.status === 410) {
|
|
35475
|
+
throw await deletedError(res, details);
|
|
35476
|
+
}
|
|
35477
|
+
if (!res.ok) {
|
|
35478
|
+
const body2 = await readBody(res);
|
|
35479
|
+
const detail = stringOrUndefined(body2["error"]) ?? res.statusText;
|
|
34096
35480
|
throw new Error(`Gateway error: ${res.status} ${detail}`);
|
|
34097
35481
|
}
|
|
34098
|
-
const body = await res
|
|
35482
|
+
const body = await readBody(res);
|
|
34099
35483
|
return {
|
|
34100
|
-
dataPointId: getMutationId(
|
|
34101
|
-
|
|
34102
|
-
|
|
34103
|
-
),
|
|
34104
|
-
|
|
35484
|
+
dataPointId: getMutationId(body, "dataPointId") ?? dataPointId,
|
|
35485
|
+
ownerAddress: stringOrUndefined(body["ownerAddress"]),
|
|
35486
|
+
scope: stringOrUndefined(body["scope"]),
|
|
35487
|
+
dataHash: stringOrUndefined(body["dataHash"]),
|
|
35488
|
+
metadataHash: stringOrUndefined(body["metadataHash"]),
|
|
35489
|
+
expectedVersion: stringOrUndefined(body["expectedVersion"]),
|
|
35490
|
+
deletedAt: tombstoneDeletedAt(body)
|
|
34105
35491
|
};
|
|
34106
35492
|
},
|
|
34107
35493
|
async createGrant(params) {
|
|
@@ -34120,18 +35506,14 @@ function createGatewayClient(baseUrl) {
|
|
|
34120
35506
|
})
|
|
34121
35507
|
});
|
|
34122
35508
|
if (res.status === 409) {
|
|
34123
|
-
const body2 = await res
|
|
34124
|
-
return {
|
|
34125
|
-
grantId: getMutationId(body2, "grantId")
|
|
34126
|
-
};
|
|
35509
|
+
const body2 = await readJsonObject(res);
|
|
35510
|
+
return { grantId: getMutationId(body2, "grantId") };
|
|
34127
35511
|
}
|
|
34128
35512
|
if (!res.ok) {
|
|
34129
35513
|
throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
|
|
34130
35514
|
}
|
|
34131
|
-
const body = await res
|
|
34132
|
-
return {
|
|
34133
|
-
grantId: getMutationId(body, "grantId")
|
|
34134
|
-
};
|
|
35515
|
+
const body = await readJsonObject(res);
|
|
35516
|
+
return { grantId: getMutationId(body, "grantId") };
|
|
34135
35517
|
},
|
|
34136
35518
|
async revokeGrant(params) {
|
|
34137
35519
|
const res = await fetch(`${base}/v1/grants/${params.grantId}`, {
|
|
@@ -34817,7 +36199,7 @@ var KNOWN_CODES = /* @__PURE__ */ new Set([
|
|
|
34817
36199
|
"server_not_configured",
|
|
34818
36200
|
"content_too_large"
|
|
34819
36201
|
]);
|
|
34820
|
-
function
|
|
36202
|
+
function isRecord4(value) {
|
|
34821
36203
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
34822
36204
|
}
|
|
34823
36205
|
function normalizeCode(value) {
|
|
@@ -34828,10 +36210,10 @@ function normalizeCode(value) {
|
|
|
34828
36210
|
return KNOWN_CODES.has(code) ? code : null;
|
|
34829
36211
|
}
|
|
34830
36212
|
function extractPSErrorBody(body) {
|
|
34831
|
-
if (!
|
|
36213
|
+
if (!isRecord4(body)) {
|
|
34832
36214
|
return null;
|
|
34833
36215
|
}
|
|
34834
|
-
const nested =
|
|
36216
|
+
const nested = isRecord4(body.error) ? body.error : null;
|
|
34835
36217
|
const code = normalizeCode(
|
|
34836
36218
|
nested?.errorCode ?? nested?.code ?? body.errorCode ?? body.code
|
|
34837
36219
|
);
|
|
@@ -34870,7 +36252,10 @@ async function parsePSError(response) {
|
|
|
34870
36252
|
DATA_ACCESS_OP_TYPE,
|
|
34871
36253
|
DATA_REGISTRY_STATUS_ABI,
|
|
34872
36254
|
DataFileEnvelopeSchema,
|
|
36255
|
+
DataPointDeletedError,
|
|
36256
|
+
DataPointNotFoundError,
|
|
34873
36257
|
DataPointStatus,
|
|
36258
|
+
DataPointVersionConflictError,
|
|
34874
36259
|
DropboxStorage,
|
|
34875
36260
|
ECIESError,
|
|
34876
36261
|
ESCROW_DEPOSIT_ABI,
|
|
@@ -34887,7 +36272,14 @@ async function parsePSError(response) {
|
|
|
34887
36272
|
InvalidScopeEntryError,
|
|
34888
36273
|
InvalidSignatureError,
|
|
34889
36274
|
IpfsStorage,
|
|
36275
|
+
LINEAGE_FIELD,
|
|
36276
|
+
LINEAGE_KEY,
|
|
36277
|
+
LineageEntrySchema,
|
|
36278
|
+
LineageGraphSchema,
|
|
36279
|
+
LineageNodeSchema,
|
|
36280
|
+
LineageReadError,
|
|
34890
36281
|
MASTER_KEY_MESSAGE,
|
|
36282
|
+
MAX_LINEAGE_SOURCES,
|
|
34891
36283
|
MissingAuthError,
|
|
34892
36284
|
NATIVE_ASSET_ADDRESS,
|
|
34893
36285
|
NATIVE_VANA_ASSET,
|
|
@@ -34906,11 +36298,14 @@ async function parsePSError(response) {
|
|
|
34906
36298
|
PSError,
|
|
34907
36299
|
PermissionError,
|
|
34908
36300
|
PersonalServerError,
|
|
36301
|
+
PersonalServerWriteError,
|
|
34909
36302
|
PinataStorage,
|
|
34910
36303
|
R2Storage,
|
|
34911
36304
|
RECORD_DATA_ACCESS_TYPES,
|
|
34912
36305
|
REGISTRATION_KIND_FOR_OP,
|
|
36306
|
+
RESERVED_WRITE_KEYS,
|
|
34913
36307
|
ReadOnlyError,
|
|
36308
|
+
RedactedLineageNodeSchema,
|
|
34914
36309
|
RelayerError,
|
|
34915
36310
|
SCOPE_ACTIONS,
|
|
34916
36311
|
SERVER_REGISTRATION_TYPES,
|
|
@@ -34920,13 +36315,36 @@ async function parsePSError(response) {
|
|
|
34920
36315
|
SignatureError,
|
|
34921
36316
|
StorageError,
|
|
34922
36317
|
StorageManager,
|
|
36318
|
+
TOMBSTONE_DATA_HASH,
|
|
36319
|
+
TOMBSTONE_DATA_HASH_PREIMAGE,
|
|
36320
|
+
TOMBSTONE_METADATA_HASH,
|
|
36321
|
+
TOMBSTONE_METADATA_HASH_PREIMAGE,
|
|
34923
36322
|
TransactionPendingError,
|
|
34924
36323
|
UserRejectedRequestError,
|
|
34925
36324
|
VanaError,
|
|
34926
36325
|
VanaStorage,
|
|
36326
|
+
WRITER_ATTRIBUTION_KEY,
|
|
36327
|
+
WRITE_CONTENT_DISPOSITION_HEADER,
|
|
36328
|
+
WRITE_FILENAME_HEADER,
|
|
36329
|
+
WRITE_METADATA_HEADER,
|
|
36330
|
+
WRITE_SESSION_PATH,
|
|
36331
|
+
WRITE_SIGNATURE_HEADER,
|
|
36332
|
+
WriteConflictError,
|
|
36333
|
+
WriteForbiddenError,
|
|
36334
|
+
WriteLineageError,
|
|
36335
|
+
WriteRejectedError,
|
|
36336
|
+
WriteRequestError,
|
|
36337
|
+
WriteSessionError,
|
|
36338
|
+
WriteSessionExpiredError,
|
|
36339
|
+
WriteTransportError,
|
|
36340
|
+
WriteUnauthorizedError,
|
|
36341
|
+
assertDerivedScopeNaming,
|
|
34927
36342
|
assertValidPkceVerifier,
|
|
34928
36343
|
authorizeEscrowPayment,
|
|
34929
36344
|
authorizeGrantPayment,
|
|
36345
|
+
binaryWriteSignedBytes,
|
|
36346
|
+
buildDataPointDeletionSignature,
|
|
36347
|
+
buildDataPointDeletionTypedData,
|
|
34930
36348
|
buildDepositNativeRequest,
|
|
34931
36349
|
buildDepositTokenRequest,
|
|
34932
36350
|
buildEscrowPaymentHeader,
|
|
@@ -34944,6 +36362,7 @@ async function parsePSError(response) {
|
|
|
34944
36362
|
clearContractCache,
|
|
34945
36363
|
computeBodyHash,
|
|
34946
36364
|
computePkceChallenge,
|
|
36365
|
+
computeTombstoneHash,
|
|
34947
36366
|
contractCacheForTesting,
|
|
34948
36367
|
createBrowserPlatformAdapter,
|
|
34949
36368
|
createDataFileEnvelope,
|
|
@@ -34955,22 +36374,28 @@ async function parsePSError(response) {
|
|
|
34955
36374
|
createPlatformAdapterFor,
|
|
34956
36375
|
createPlatformAdapterSafe,
|
|
34957
36376
|
createVanaStorageProvider,
|
|
36377
|
+
createViemDataPointDeletionSigner,
|
|
34958
36378
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
34959
36379
|
createViemPersonalServerRegistrationSigner,
|
|
34960
36380
|
dataRegistryContractAddress,
|
|
34961
36381
|
dataRegistryDomain,
|
|
34962
36382
|
decryptWithPassword,
|
|
36383
|
+
deleteDataPoint,
|
|
36384
|
+
deriveDataPointId,
|
|
34963
36385
|
deriveMasterKey,
|
|
34964
36386
|
deriveScopeKey,
|
|
36387
|
+
derivedScopeViolatesNaming,
|
|
34965
36388
|
deserializeECIES,
|
|
34966
36389
|
detectPlatform,
|
|
34967
36390
|
encodeDepositNativeData,
|
|
34968
36391
|
encodeDepositTokenData,
|
|
34969
36392
|
encodeSetDataPointStatusData,
|
|
36393
|
+
encodeWriteMetadataHeader,
|
|
34970
36394
|
encryptWithPassword,
|
|
34971
36395
|
escrowContractAddress,
|
|
34972
36396
|
escrowPaymentDomain,
|
|
34973
36397
|
formatScopeEntry,
|
|
36398
|
+
gatewayLineagePath,
|
|
34974
36399
|
generatePkceVerifier,
|
|
34975
36400
|
genericPaymentDomain,
|
|
34976
36401
|
getAbi,
|
|
@@ -34980,47 +36405,64 @@ async function parsePSError(response) {
|
|
|
34980
36405
|
getContractController,
|
|
34981
36406
|
getContractInfo,
|
|
34982
36407
|
getFee,
|
|
36408
|
+
getGatewayLineage,
|
|
36409
|
+
getLineage,
|
|
34983
36410
|
getOpFee,
|
|
36411
|
+
getPersonalServerLineage,
|
|
34984
36412
|
getPlatformCapabilities,
|
|
34985
36413
|
getServiceEndpoints,
|
|
34986
36414
|
grantPermissions,
|
|
34987
36415
|
grantRegistrationDomain,
|
|
34988
36416
|
grantRevocationDomain,
|
|
34989
36417
|
hasAction,
|
|
36418
|
+
isDataPointId,
|
|
36419
|
+
isDataPointTombstone,
|
|
34990
36420
|
isDataPortabilityGatewayConfig,
|
|
34991
36421
|
isECIESEncrypted,
|
|
34992
36422
|
isPlatformSupported,
|
|
36423
|
+
isRedactedLineageNode,
|
|
36424
|
+
isTombstoneHashes,
|
|
34993
36425
|
mainnetServices,
|
|
34994
36426
|
moksha,
|
|
34995
36427
|
mokshaServices,
|
|
34996
36428
|
mokshaTestnet,
|
|
36429
|
+
normalizeBinaryMimeType,
|
|
36430
|
+
openWriteSession,
|
|
34997
36431
|
parsePSError,
|
|
34998
36432
|
parsePersonalServerPaymentRequired,
|
|
34999
36433
|
parseScope,
|
|
35000
36434
|
parseScopeEntry,
|
|
35001
36435
|
parseWeb3SignedHeader,
|
|
36436
|
+
parseWriteMetadataHeader,
|
|
35002
36437
|
paymentReceiptFromHeader,
|
|
35003
36438
|
paymentResponseMetadataFromHeader,
|
|
35004
36439
|
permissionsToScopes,
|
|
35005
36440
|
personalServerDataReadPath,
|
|
36441
|
+
personalServerLineagePath,
|
|
35006
36442
|
personalServerRegistrationDomain,
|
|
35007
36443
|
readPersonalServerData,
|
|
35008
36444
|
recoverServerOwner,
|
|
35009
36445
|
registerPersonalServerSignature,
|
|
36446
|
+
resolveWriteSigner,
|
|
35010
36447
|
scopeCoveredByGrant,
|
|
35011
36448
|
scopeMatchesPattern,
|
|
36449
|
+
scopeNamespace,
|
|
35012
36450
|
scopeToPathSegments,
|
|
35013
36451
|
serializeECIES,
|
|
35014
36452
|
serverRegistrationDomain,
|
|
36453
|
+
sessionCoversScope,
|
|
35015
36454
|
signPersonalServerLiteOwnerBinding,
|
|
35016
36455
|
signPersonalServerLiteOwnerBindingWithAccountClient,
|
|
35017
36456
|
signPersonalServerRegistrationWithAccount,
|
|
35018
36457
|
toDirectFeeBreakdown,
|
|
35019
36458
|
toDirectPaymentReceipt,
|
|
36459
|
+
tombstoneDeletedAt,
|
|
35020
36460
|
tryGrantPermissions,
|
|
35021
36461
|
vanaMainnet,
|
|
35022
36462
|
verifyGrantRegistration,
|
|
35023
36463
|
verifyPkceChallenge,
|
|
35024
|
-
verifyWeb3Signed
|
|
36464
|
+
verifyWeb3Signed,
|
|
36465
|
+
writeData,
|
|
36466
|
+
writePersonalServerData
|
|
35025
36467
|
});
|
|
35026
36468
|
//# sourceMappingURL=index.node.cjs.map
|