@opendatalabs/vana-sdk 0.1.0-alpha.cb72de2 → 0.1.0-alpha.d44f792
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.d.ts +994 -63
- package/dist/index.browser.js +227 -27
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +227 -27
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +994 -63
- package/dist/index.node.d.ts +994 -63
- package/dist/index.node.js +227 -27
- package/dist/index.node.js.map +1 -1
- package/package.json +1 -1
package/dist/index.node.cjs
CHANGED
|
@@ -34254,6 +34254,19 @@ var SignatureCache = class {
|
|
|
34254
34254
|
static DEFAULT_TTL_HOURS = 2;
|
|
34255
34255
|
/**
|
|
34256
34256
|
* Get a cached signature if it exists and hasn't expired
|
|
34257
|
+
*
|
|
34258
|
+
* @param cache - Platform cache adapter instance
|
|
34259
|
+
* @param walletAddress - Wallet address that created the signature
|
|
34260
|
+
* @param messageHash - Hash of the message that was signed
|
|
34261
|
+
* @returns The cached signature if valid, null if expired or not found
|
|
34262
|
+
* @example
|
|
34263
|
+
* ```typescript
|
|
34264
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
34265
|
+
* const cached = SignatureCache.get(cache, '0x123...', messageHash);
|
|
34266
|
+
* if (cached) {
|
|
34267
|
+
* console.log('Using cached signature:', cached);
|
|
34268
|
+
* }
|
|
34269
|
+
* ```
|
|
34257
34270
|
*/
|
|
34258
34271
|
static get(cache, walletAddress, messageHash) {
|
|
34259
34272
|
const key = this.getCacheKey(walletAddress, messageHash);
|
|
@@ -34275,7 +34288,24 @@ var SignatureCache = class {
|
|
|
34275
34288
|
}
|
|
34276
34289
|
}
|
|
34277
34290
|
/**
|
|
34278
|
-
* Store a signature in the cache
|
|
34291
|
+
* Store a signature in the cache with configurable TTL
|
|
34292
|
+
*
|
|
34293
|
+
* @param cache - Platform cache adapter instance
|
|
34294
|
+
* @param walletAddress - Wallet address that created the signature
|
|
34295
|
+
* @param messageHash - Hash of the message that was signed
|
|
34296
|
+
* @param signature - The signature to cache
|
|
34297
|
+
* @param ttlHours - Time to live in hours (default: 2)
|
|
34298
|
+
* @example
|
|
34299
|
+
* ```typescript
|
|
34300
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
34301
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
34302
|
+
*
|
|
34303
|
+
* // Cache for default 2 hours
|
|
34304
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
34305
|
+
*
|
|
34306
|
+
* // Cache for 24 hours
|
|
34307
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
|
|
34308
|
+
* ```
|
|
34279
34309
|
*/
|
|
34280
34310
|
static set(cache, walletAddress, messageHash, signature, ttlHours = this.DEFAULT_TTL_HOURS) {
|
|
34281
34311
|
const key = this.getCacheKey(walletAddress, messageHash);
|
|
@@ -34291,6 +34321,18 @@ var SignatureCache = class {
|
|
|
34291
34321
|
}
|
|
34292
34322
|
/**
|
|
34293
34323
|
* Clear all cached signatures (useful for testing or explicit cleanup)
|
|
34324
|
+
*
|
|
34325
|
+
* @param cache - Platform cache adapter instance
|
|
34326
|
+
* @example
|
|
34327
|
+
* ```typescript
|
|
34328
|
+
* // Clear all signatures when user logs out
|
|
34329
|
+
* SignatureCache.clear(cache);
|
|
34330
|
+
*
|
|
34331
|
+
* // Clear before running tests
|
|
34332
|
+
* beforeEach(() => {
|
|
34333
|
+
* SignatureCache.clear(cache);
|
|
34334
|
+
* });
|
|
34335
|
+
* ```
|
|
34294
34336
|
*/
|
|
34295
34337
|
static clear(cache) {
|
|
34296
34338
|
try {
|
|
@@ -34301,6 +34343,27 @@ var SignatureCache = class {
|
|
|
34301
34343
|
static getCacheKey(walletAddress, messageHash) {
|
|
34302
34344
|
return `${this.PREFIX}${walletAddress.toLowerCase()}:${messageHash}`;
|
|
34303
34345
|
}
|
|
34346
|
+
/**
|
|
34347
|
+
* Generate a deterministic hash of a message object for cache key generation
|
|
34348
|
+
*
|
|
34349
|
+
* @remarks
|
|
34350
|
+
* Creates a consistent hash from complex objects including EIP-712 typed data.
|
|
34351
|
+
* Handles BigInt serialization and produces a 32-character hash that balances
|
|
34352
|
+
* uniqueness with key length constraints.
|
|
34353
|
+
*
|
|
34354
|
+
* @param message - The message object to hash (typically EIP-712 typed data)
|
|
34355
|
+
* @returns A 32-character hash string suitable for cache keys
|
|
34356
|
+
* @example
|
|
34357
|
+
* ```typescript
|
|
34358
|
+
* const typedData = {
|
|
34359
|
+
* domain: { name: 'Vana', version: '1' },
|
|
34360
|
+
* message: { nonce: 123n, grant: '...' }
|
|
34361
|
+
* };
|
|
34362
|
+
*
|
|
34363
|
+
* const hash = SignatureCache.hashMessage(typedData);
|
|
34364
|
+
* // Returns something like: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
|
|
34365
|
+
* ```
|
|
34366
|
+
*/
|
|
34304
34367
|
static hashMessage(message) {
|
|
34305
34368
|
const jsonString = JSON.stringify(message, this.bigIntReplacer);
|
|
34306
34369
|
const base64Hash = toBase64(jsonString);
|
|
@@ -34313,8 +34376,12 @@ var SignatureCache = class {
|
|
|
34313
34376
|
/**
|
|
34314
34377
|
* Custom JSON replacer that converts BigInt values to strings for serialization
|
|
34315
34378
|
* This ensures deterministic cache key generation for EIP-712 typed data
|
|
34379
|
+
*
|
|
34380
|
+
* @param _key - The object key being serialized (unused)
|
|
34381
|
+
* @param value - The value to serialize
|
|
34382
|
+
* @returns The serialized value
|
|
34316
34383
|
*/
|
|
34317
|
-
static bigIntReplacer(
|
|
34384
|
+
static bigIntReplacer(_key, value) {
|
|
34318
34385
|
if (typeof value === "bigint") {
|
|
34319
34386
|
return `__BIGINT__${value.toString()}`;
|
|
34320
34387
|
}
|
|
@@ -34339,7 +34406,7 @@ var PermissionsController = class {
|
|
|
34339
34406
|
}
|
|
34340
34407
|
/**
|
|
34341
34408
|
* Grants permission for an application to access user data with gasless transactions.
|
|
34342
|
-
*
|
|
34409
|
+
*
|
|
34343
34410
|
* This method provides a complete end-to-end permission grant flow that returns
|
|
34344
34411
|
* the permission ID and other relevant data immediately after successful submission.
|
|
34345
34412
|
* For advanced users who need more control over the transaction lifecycle, use
|
|
@@ -34366,7 +34433,7 @@ var PermissionsController = class {
|
|
|
34366
34433
|
*
|
|
34367
34434
|
* console.log(`Permission ${result.permissionId} granted to ${result.user}`);
|
|
34368
34435
|
* console.log(`Transaction: ${result.transactionHash}`);
|
|
34369
|
-
*
|
|
34436
|
+
*
|
|
34370
34437
|
* // Can immediately use the permission ID for other operations
|
|
34371
34438
|
* await vana.permissions.revoke({ permissionId: result.permissionId });
|
|
34372
34439
|
* ```
|
|
@@ -34377,12 +34444,12 @@ var PermissionsController = class {
|
|
|
34377
34444
|
}
|
|
34378
34445
|
/**
|
|
34379
34446
|
* Submits a permission grant transaction and returns the transaction hash immediately.
|
|
34380
|
-
*
|
|
34447
|
+
*
|
|
34381
34448
|
* This is the lower-level method that provides maximum control over transaction timing.
|
|
34382
34449
|
* Use this when you want to handle transaction confirmation and event parsing separately,
|
|
34383
34450
|
* or when submitting multiple transactions in batch.
|
|
34384
34451
|
*
|
|
34385
|
-
* @param params - The permission grant configuration object
|
|
34452
|
+
* @param params - The permission grant configuration object
|
|
34386
34453
|
* @returns Promise that resolves to the transaction hash when successfully submitted
|
|
34387
34454
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
34388
34455
|
* @throws {SignatureError} When user rejects the signature request
|
|
@@ -34393,7 +34460,7 @@ var PermissionsController = class {
|
|
|
34393
34460
|
* // Submit transaction and handle confirmation later
|
|
34394
34461
|
* const txHash = await vana.permissions.submitPermissionGrant(params);
|
|
34395
34462
|
* console.log(`Transaction submitted: ${txHash}`);
|
|
34396
|
-
*
|
|
34463
|
+
*
|
|
34397
34464
|
* // Later, when you need the permission data:
|
|
34398
34465
|
* const result = await parseTransactionResult(context, txHash, 'grant');
|
|
34399
34466
|
* console.log(`Permission ID: ${result.permissionId}`);
|
|
@@ -34413,6 +34480,8 @@ var PermissionsController = class {
|
|
|
34413
34480
|
* until the returned `confirm()` function is called.
|
|
34414
34481
|
* @param params - The permission grant parameters
|
|
34415
34482
|
* @returns A promise resolving to a preview object and confirm function
|
|
34483
|
+
* @throws {SerializationError} When grant parameters are invalid or cannot be serialized
|
|
34484
|
+
* @throws {BlockchainError} When grant validation fails or preparation encounters an error
|
|
34416
34485
|
* @example
|
|
34417
34486
|
* ```typescript
|
|
34418
34487
|
* const { preview, confirm } = await vana.permissions.prepareGrant({
|
|
@@ -34816,13 +34885,13 @@ var PermissionsController = class {
|
|
|
34816
34885
|
}
|
|
34817
34886
|
/**
|
|
34818
34887
|
* Revokes a previously granted permission.
|
|
34819
|
-
*
|
|
34888
|
+
*
|
|
34820
34889
|
* This method provides complete revocation with automatic event parsing to confirm
|
|
34821
34890
|
* the permission was successfully revoked. For advanced users who need more control,
|
|
34822
34891
|
* use `submitPermissionRevoke()` instead.
|
|
34823
34892
|
*
|
|
34824
34893
|
* @param params - Parameters for revoking the permission
|
|
34825
|
-
* @param params.permissionId - Permission identifier
|
|
34894
|
+
* @param params.permissionId - Permission identifier (accepts bigint, number, or string).
|
|
34826
34895
|
* Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
|
|
34827
34896
|
* @returns Promise resolving to revocation data from PermissionRevoked event
|
|
34828
34897
|
* @throws {BlockchainError} When revocation fails or event parsing fails
|
|
@@ -34844,7 +34913,7 @@ var PermissionsController = class {
|
|
|
34844
34913
|
}
|
|
34845
34914
|
/**
|
|
34846
34915
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
34847
|
-
*
|
|
34916
|
+
*
|
|
34848
34917
|
* This is the lower-level method that provides maximum control over transaction timing.
|
|
34849
34918
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
34850
34919
|
*
|
|
@@ -34899,6 +34968,11 @@ var PermissionsController = class {
|
|
|
34899
34968
|
*
|
|
34900
34969
|
* @param params - Parameters for revoking the permission
|
|
34901
34970
|
* @returns Promise resolving to transaction hash
|
|
34971
|
+
* @throws {BlockchainError} When chain ID is not available
|
|
34972
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
34973
|
+
* @throws {SignatureError} When user rejects the signature request
|
|
34974
|
+
* @throws {RelayerError} When gasless submission fails
|
|
34975
|
+
* @throws {PermissionError} When revocation fails for any other reason
|
|
34902
34976
|
*/
|
|
34903
34977
|
async revokeWithSignature(params) {
|
|
34904
34978
|
try {
|
|
@@ -34941,6 +35015,9 @@ var PermissionsController = class {
|
|
|
34941
35015
|
* Retrieves the user's current nonce from the DataPermissions contract.
|
|
34942
35016
|
*
|
|
34943
35017
|
* @returns Promise resolving to the user's current nonce value
|
|
35018
|
+
* @throws {Error} When wallet account is not available
|
|
35019
|
+
* @throws {Error} When chain ID is not available
|
|
35020
|
+
* @throws {NonceError} When reading nonce from contract fails
|
|
34944
35021
|
*/
|
|
34945
35022
|
async getUserNonce() {
|
|
34946
35023
|
try {
|
|
@@ -35187,6 +35264,7 @@ var PermissionsController = class {
|
|
|
35187
35264
|
*
|
|
35188
35265
|
* @param fileId - The file ID to query permissions for
|
|
35189
35266
|
* @returns Promise resolving to array of permission IDs
|
|
35267
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35190
35268
|
*/
|
|
35191
35269
|
async getFilePermissionIds(fileId) {
|
|
35192
35270
|
try {
|
|
@@ -35215,6 +35293,7 @@ var PermissionsController = class {
|
|
|
35215
35293
|
*
|
|
35216
35294
|
* @param permissionId - The permission ID to query files for
|
|
35217
35295
|
* @returns Promise resolving to array of file IDs
|
|
35296
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35218
35297
|
*/
|
|
35219
35298
|
async getPermissionFileIds(permissionId) {
|
|
35220
35299
|
try {
|
|
@@ -35243,6 +35322,7 @@ var PermissionsController = class {
|
|
|
35243
35322
|
*
|
|
35244
35323
|
* @param permissionId - The permission ID to check
|
|
35245
35324
|
* @returns Promise resolving to boolean indicating if permission is active
|
|
35325
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35246
35326
|
*/
|
|
35247
35327
|
async isActivePermission(permissionId) {
|
|
35248
35328
|
try {
|
|
@@ -35271,6 +35351,7 @@ var PermissionsController = class {
|
|
|
35271
35351
|
*
|
|
35272
35352
|
* @param permissionId - The permission ID to query
|
|
35273
35353
|
* @returns Promise resolving to permission info
|
|
35354
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35274
35355
|
*/
|
|
35275
35356
|
async getPermissionInfo(permissionId) {
|
|
35276
35357
|
try {
|
|
@@ -35318,7 +35399,12 @@ var PermissionsController = class {
|
|
|
35318
35399
|
* Trusts a server for data processing.
|
|
35319
35400
|
*
|
|
35320
35401
|
* @param params - Parameters for trusting the server
|
|
35402
|
+
* @param params.serverId - The server's Ethereum address
|
|
35403
|
+
* @param params.serverUrl - The server's URL endpoint
|
|
35321
35404
|
* @returns Promise resolving to transaction hash
|
|
35405
|
+
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
35406
|
+
* @throws {BlockchainError} When chain ID is unavailable or transaction fails
|
|
35407
|
+
* @throws {Error} When wallet account is not available
|
|
35322
35408
|
* @example
|
|
35323
35409
|
* ```typescript
|
|
35324
35410
|
* // Trust a server by providing its ID and URL
|
|
@@ -35365,6 +35451,12 @@ var PermissionsController = class {
|
|
|
35365
35451
|
*
|
|
35366
35452
|
* @param params - Parameters for trusting the server
|
|
35367
35453
|
* @returns Promise resolving to transaction hash
|
|
35454
|
+
* @throws {BlockchainError} When chain ID is not available
|
|
35455
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
35456
|
+
* @throws {SignatureError} When user rejects the signature request
|
|
35457
|
+
* @throws {RelayerError} When gasless submission fails
|
|
35458
|
+
* @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
|
|
35459
|
+
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
35368
35460
|
*/
|
|
35369
35461
|
async trustServerWithSignature(params) {
|
|
35370
35462
|
try {
|
|
@@ -35439,7 +35531,12 @@ var PermissionsController = class {
|
|
|
35439
35531
|
* Untrusts a server.
|
|
35440
35532
|
*
|
|
35441
35533
|
* @param params - Parameters for untrusting the server
|
|
35534
|
+
* @param params.serverId - The server's Ethereum address to untrust
|
|
35442
35535
|
* @returns Promise resolving to transaction hash
|
|
35536
|
+
* @throws {Error} When wallet account is not available
|
|
35537
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
35538
|
+
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
35539
|
+
* @throws {BlockchainError} When untrust transaction fails
|
|
35443
35540
|
*/
|
|
35444
35541
|
async untrustServer(params) {
|
|
35445
35542
|
const nonce = await this.getUserNonce();
|
|
@@ -35453,7 +35550,13 @@ var PermissionsController = class {
|
|
|
35453
35550
|
* Untrusts a server using a signature (gasless transaction).
|
|
35454
35551
|
*
|
|
35455
35552
|
* @param params - Parameters for untrusting the server
|
|
35553
|
+
* @param params.serverId - The server's Ethereum address to untrust
|
|
35456
35554
|
* @returns Promise resolving to transaction hash
|
|
35555
|
+
* @throws {Error} When wallet account is not available
|
|
35556
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
35557
|
+
* @throws {SignatureError} When user rejects the signature request
|
|
35558
|
+
* @throws {RelayerError} When gasless submission fails
|
|
35559
|
+
* @throws {BlockchainError} When untrust transaction fails
|
|
35457
35560
|
*/
|
|
35458
35561
|
async untrustServerWithSignature(params) {
|
|
35459
35562
|
try {
|
|
@@ -35495,6 +35598,7 @@ var PermissionsController = class {
|
|
|
35495
35598
|
*
|
|
35496
35599
|
* @param userAddress - Optional user address (defaults to current user)
|
|
35497
35600
|
* @returns Promise resolving to array of trusted server addresses
|
|
35601
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35498
35602
|
*/
|
|
35499
35603
|
async getTrustedServers(userAddress) {
|
|
35500
35604
|
try {
|
|
@@ -35524,6 +35628,7 @@ var PermissionsController = class {
|
|
|
35524
35628
|
*
|
|
35525
35629
|
* @param serverId - Server address
|
|
35526
35630
|
* @returns Promise resolving to server information
|
|
35631
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35527
35632
|
*/
|
|
35528
35633
|
async getServerInfo(serverId) {
|
|
35529
35634
|
try {
|
|
@@ -35552,6 +35657,7 @@ var PermissionsController = class {
|
|
|
35552
35657
|
*
|
|
35553
35658
|
* @param userAddress - Optional user address (defaults to current user)
|
|
35554
35659
|
* @returns Promise resolving to the number of trusted servers
|
|
35660
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35555
35661
|
*/
|
|
35556
35662
|
async getTrustedServersCount(userAddress) {
|
|
35557
35663
|
try {
|
|
@@ -35581,6 +35687,7 @@ var PermissionsController = class {
|
|
|
35581
35687
|
*
|
|
35582
35688
|
* @param options - Query options including pagination parameters
|
|
35583
35689
|
* @returns Promise resolving to paginated trusted servers
|
|
35690
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35584
35691
|
*/
|
|
35585
35692
|
async getTrustedServersPaginated(options = {}) {
|
|
35586
35693
|
try {
|
|
@@ -35640,6 +35747,7 @@ var PermissionsController = class {
|
|
|
35640
35747
|
*
|
|
35641
35748
|
* @param options - Query options
|
|
35642
35749
|
* @returns Promise resolving to array of trusted server info
|
|
35750
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35643
35751
|
*/
|
|
35644
35752
|
async getTrustedServersWithInfo(options = {}) {
|
|
35645
35753
|
try {
|
|
@@ -35677,6 +35785,7 @@ var PermissionsController = class {
|
|
|
35677
35785
|
*
|
|
35678
35786
|
* @param serverIds - Array of server IDs to query
|
|
35679
35787
|
* @returns Promise resolving to batch result with successes and failures
|
|
35788
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35680
35789
|
*/
|
|
35681
35790
|
async getServerInfoBatch(serverIds) {
|
|
35682
35791
|
if (serverIds.length === 0) {
|
|
@@ -36170,9 +36279,14 @@ var DataController = class {
|
|
|
36170
36279
|
* @param file - The user file to decrypt (typically from getUserFiles)
|
|
36171
36280
|
* @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
|
|
36172
36281
|
* @returns Promise resolving to the decrypted file content as a Blob
|
|
36173
|
-
* @throws {Error}
|
|
36174
|
-
* @throws {Error}
|
|
36175
|
-
* @throws {Error}
|
|
36282
|
+
* @throws {Error} "No addresses available in wallet client" - When wallet is not connected
|
|
36283
|
+
* @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
|
|
36284
|
+
* @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
|
|
36285
|
+
* @throws {Error} "Access denied" - When file returns 403 (no permission)
|
|
36286
|
+
* @throws {Error} "File is empty or could not be retrieved" - When file has no content
|
|
36287
|
+
* @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
|
|
36288
|
+
* @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
|
|
36289
|
+
* @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
|
|
36176
36290
|
* @example
|
|
36177
36291
|
* ```typescript
|
|
36178
36292
|
* // Basic file decryption
|
|
@@ -36292,11 +36406,20 @@ var DataController = class {
|
|
|
36292
36406
|
* This method queries the Vana subgraph to find files directly owned by the user.
|
|
36293
36407
|
* It efficiently handles large datasets by using the File entity's owner field
|
|
36294
36408
|
* and returns complete file metadata without additional contract calls.
|
|
36409
|
+
*
|
|
36410
|
+
* **Deduplication Behavior:**
|
|
36411
|
+
* The method automatically deduplicates files by ID, keeping only the latest version
|
|
36412
|
+
* (highest timestamp) when duplicate file IDs are found. This handles cases where
|
|
36413
|
+
* the subgraph may contain multiple entries for the same file due to re-indexing
|
|
36414
|
+
* or blockchain reorganizations.
|
|
36295
36415
|
* @param params - The query parameters object
|
|
36296
36416
|
* @param params.owner - The wallet address of the file owner to query
|
|
36297
36417
|
* @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
|
|
36298
|
-
* @returns A Promise that resolves to an array of UserFile objects with metadata
|
|
36299
|
-
* @throws {Error} When
|
|
36418
|
+
* @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
|
|
36419
|
+
* @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
|
|
36420
|
+
* @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
|
|
36421
|
+
* @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
|
|
36422
|
+
* @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
|
|
36300
36423
|
* @example
|
|
36301
36424
|
* ```typescript
|
|
36302
36425
|
* // Query files for a specific user
|
|
@@ -36799,6 +36922,9 @@ var DataController = class {
|
|
|
36799
36922
|
*
|
|
36800
36923
|
* @param fileId - The file ID to look up
|
|
36801
36924
|
* @returns Promise resolving to UserFile object
|
|
36925
|
+
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
36926
|
+
* @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
|
|
36927
|
+
* @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
|
|
36802
36928
|
* @example
|
|
36803
36929
|
* ```typescript
|
|
36804
36930
|
* try {
|
|
@@ -36868,7 +36994,21 @@ var DataController = class {
|
|
|
36868
36994
|
/**
|
|
36869
36995
|
* Uploads an encrypted file to storage and registers it on the blockchain.
|
|
36870
36996
|
*
|
|
36871
|
-
* @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption
|
|
36997
|
+
* @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption
|
|
36998
|
+
*
|
|
36999
|
+
* Migration guide:
|
|
37000
|
+
* ```typescript
|
|
37001
|
+
* // Old way (deprecated):
|
|
37002
|
+
* const encrypted = await encryptBlob(data, key);
|
|
37003
|
+
* const result = await vana.data.uploadEncryptedFile(encrypted, filename);
|
|
37004
|
+
*
|
|
37005
|
+
* // New way:
|
|
37006
|
+
* const result = await vana.data.upload({
|
|
37007
|
+
* content: data,
|
|
37008
|
+
* filename: filename,
|
|
37009
|
+
* encrypt: true // Handles encryption automatically
|
|
37010
|
+
* });
|
|
37011
|
+
* ```
|
|
36872
37012
|
* @param encryptedFile - The encrypted file blob to upload
|
|
36873
37013
|
* @param filename - Optional filename for the upload
|
|
36874
37014
|
* @param providerName - Optional storage provider to use
|
|
@@ -36956,7 +37096,22 @@ var DataController = class {
|
|
|
36956
37096
|
/**
|
|
36957
37097
|
* Uploads an encrypted file to storage and registers it on the blockchain with a schema.
|
|
36958
37098
|
*
|
|
36959
|
-
* @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
|
|
37099
|
+
* @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
|
|
37100
|
+
*
|
|
37101
|
+
* Migration guide:
|
|
37102
|
+
* ```typescript
|
|
37103
|
+
* // Old way (deprecated):
|
|
37104
|
+
* const encrypted = await encryptBlob(data, key);
|
|
37105
|
+
* const result = await vana.data.uploadEncryptedFileWithSchema(encrypted, schemaId, filename);
|
|
37106
|
+
*
|
|
37107
|
+
* // New way:
|
|
37108
|
+
* const result = await vana.data.upload({
|
|
37109
|
+
* content: data,
|
|
37110
|
+
* filename: filename,
|
|
37111
|
+
* schemaId: schemaId, // Automatic validation
|
|
37112
|
+
* encrypt: true
|
|
37113
|
+
* });
|
|
37114
|
+
* ```
|
|
36960
37115
|
* @param encryptedFile - The encrypted file blob to upload
|
|
36961
37116
|
* @param schemaId - The schema ID to associate with the file
|
|
36962
37117
|
* @param filename - Optional filename for the upload
|
|
@@ -37232,7 +37387,24 @@ var DataController = class {
|
|
|
37232
37387
|
/**
|
|
37233
37388
|
* Adds a new schema to the DataRefinerRegistry.
|
|
37234
37389
|
*
|
|
37235
|
-
* @deprecated Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
|
|
37390
|
+
* @deprecated Since v2.0.0 - Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
|
|
37391
|
+
*
|
|
37392
|
+
* Migration guide:
|
|
37393
|
+
* ```typescript
|
|
37394
|
+
* // Old way (deprecated):
|
|
37395
|
+
* const result = await vana.data.addSchema({
|
|
37396
|
+
* name: "UserProfile",
|
|
37397
|
+
* type: "JSON",
|
|
37398
|
+
* definitionUrl: "ipfs://..."
|
|
37399
|
+
* });
|
|
37400
|
+
*
|
|
37401
|
+
* // New way:
|
|
37402
|
+
* const result = await vana.schemas.create({
|
|
37403
|
+
* name: "UserProfile",
|
|
37404
|
+
* type: "JSON",
|
|
37405
|
+
* definition: schemaObject // Automatically uploads to IPFS
|
|
37406
|
+
* });
|
|
37407
|
+
* ```
|
|
37236
37408
|
* @param params - Schema parameters including name, type, and definition URL
|
|
37237
37409
|
* @returns Promise resolving to the new schema ID and transaction hash
|
|
37238
37410
|
*/
|
|
@@ -37291,7 +37463,16 @@ var DataController = class {
|
|
|
37291
37463
|
/**
|
|
37292
37464
|
* Retrieves a schema by its ID.
|
|
37293
37465
|
*
|
|
37294
|
-
* @deprecated Use vana.schemas.get() instead
|
|
37466
|
+
* @deprecated Since v2.0.0 - Use vana.schemas.get() instead
|
|
37467
|
+
*
|
|
37468
|
+
* Migration guide:
|
|
37469
|
+
* ```typescript
|
|
37470
|
+
* // Old way (deprecated):
|
|
37471
|
+
* const schema = await vana.data.getSchema(schemaId);
|
|
37472
|
+
*
|
|
37473
|
+
* // New way:
|
|
37474
|
+
* const schema = await vana.schemas.get(schemaId);
|
|
37475
|
+
* ```
|
|
37295
37476
|
* @param schemaId - The schema ID to retrieve
|
|
37296
37477
|
* @returns Promise resolving to the schema information
|
|
37297
37478
|
*/
|
|
@@ -37337,7 +37518,16 @@ var DataController = class {
|
|
|
37337
37518
|
/**
|
|
37338
37519
|
* Gets the total number of schemas in the registry.
|
|
37339
37520
|
*
|
|
37340
|
-
* @deprecated Use vana.schemas.count() instead
|
|
37521
|
+
* @deprecated Since v2.0.0 - Use vana.schemas.count() instead
|
|
37522
|
+
*
|
|
37523
|
+
* Migration guide:
|
|
37524
|
+
* ```typescript
|
|
37525
|
+
* // Old way (deprecated):
|
|
37526
|
+
* const count = await vana.data.getSchemasCount();
|
|
37527
|
+
*
|
|
37528
|
+
* // New way:
|
|
37529
|
+
* const count = await vana.schemas.count();
|
|
37530
|
+
* ```
|
|
37341
37531
|
* @returns Promise resolving to the total schema count
|
|
37342
37532
|
*/
|
|
37343
37533
|
async getSchemasCount() {
|
|
@@ -37659,8 +37849,11 @@ var DataController = class {
|
|
|
37659
37849
|
*
|
|
37660
37850
|
* @param fileId - The ID of the file to add permissions for
|
|
37661
37851
|
* @param account - The address of the account to grant permission to
|
|
37662
|
-
* @param publicKey - The public key to encrypt the user's encryption key with
|
|
37852
|
+
* @param publicKey - The public key to encrypt the user's encryption key with (hex string with 0x prefix)
|
|
37663
37853
|
* @returns Promise resolving to permission data from PermissionGranted event
|
|
37854
|
+
* @throws {Error} "No addresses available in wallet client" - When wallet is not connected
|
|
37855
|
+
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
37856
|
+
* @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
|
|
37664
37857
|
* @example
|
|
37665
37858
|
* ```typescript
|
|
37666
37859
|
* const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
|
|
@@ -37813,7 +38006,9 @@ var DataController = class {
|
|
|
37813
38006
|
*
|
|
37814
38007
|
* @param url - The URL to fetch content from
|
|
37815
38008
|
* @returns Promise resolving to the fetched content as a Blob
|
|
37816
|
-
* @throws {Error}
|
|
38009
|
+
* @throws {Error} "HTTP error! status: {status} {statusText}" - When server returns error status
|
|
38010
|
+
* @throws {Error} "Empty response" - When server returns no content
|
|
38011
|
+
* @throws {Error} "Network error: Failed to fetch from {url}" - When network request fails
|
|
37817
38012
|
*
|
|
37818
38013
|
* @example
|
|
37819
38014
|
* ```typescript
|
|
@@ -37865,7 +38060,10 @@ var DataController = class {
|
|
|
37865
38060
|
* @param options - Optional configuration
|
|
37866
38061
|
* @param options.gateways - Array of IPFS gateway URLs to try (must end with /)
|
|
37867
38062
|
* @returns Promise resolving to the fetched content as a Blob
|
|
37868
|
-
* @throws {Error} When
|
|
38063
|
+
* @throws {Error} "Invalid IPFS URL format" - When URL is not ipfs:// or valid CID
|
|
38064
|
+
* @throws {Error} "Empty response" - When gateway returns no content
|
|
38065
|
+
* @throws {Error} "HTTP error! status: {status}" - When gateway returns error status
|
|
38066
|
+
* @throws {Error} "Failed to fetch IPFS content {cid} from all gateways" - When all gateways fail
|
|
37869
38067
|
*
|
|
37870
38068
|
* @example
|
|
37871
38069
|
* ```typescript
|
|
@@ -38427,11 +38625,11 @@ var ServerController = class {
|
|
|
38427
38625
|
* const identity = await vana.server.getIdentity({
|
|
38428
38626
|
* userAddress: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
38429
38627
|
* });
|
|
38430
|
-
*
|
|
38628
|
+
*
|
|
38431
38629
|
* console.log(`Server: ${identity.name}`);
|
|
38432
38630
|
* console.log(`Address: ${identity.address}`);
|
|
38433
38631
|
* console.log(`Public Key: ${identity.public_key}`);
|
|
38434
|
-
*
|
|
38632
|
+
*
|
|
38435
38633
|
* // Use the public key for encrypting data to share with this server
|
|
38436
38634
|
* const encryptedData = await encryptWithWalletPublicKey(
|
|
38437
38635
|
* userData,
|
|
@@ -38595,7 +38793,7 @@ var ServerController = class {
|
|
|
38595
38793
|
* @remarks
|
|
38596
38794
|
* This method attempts to cancel an operation that is currently processing
|
|
38597
38795
|
* on the personal server. The operation must be in a cancellable state
|
|
38598
|
-
* (typically `starting` or `processing`). Not all operations support
|
|
38796
|
+
* (typically `starting` or `processing`). Not all operations support
|
|
38599
38797
|
* cancellation, and cancellation may not be immediate. The server will
|
|
38600
38798
|
* attempt to stop the operation and update its status to `canceled`.
|
|
38601
38799
|
*
|
|
@@ -38622,7 +38820,7 @@ var ServerController = class {
|
|
|
38622
38820
|
* try {
|
|
38623
38821
|
* await vana.server.cancelOperation(operation.id);
|
|
38624
38822
|
* console.log("Cancellation requested");
|
|
38625
|
-
*
|
|
38823
|
+
*
|
|
38626
38824
|
* // Verify cancellation
|
|
38627
38825
|
* const status = await vana.server.getOperation(operation.id);
|
|
38628
38826
|
* if (status.status === "canceled") {
|
|
@@ -39040,6 +39238,7 @@ var ProtocolController = class {
|
|
|
39040
39238
|
* Gets the current chain ID from the wallet client.
|
|
39041
39239
|
*
|
|
39042
39240
|
* @returns The chain ID
|
|
39241
|
+
* @throws {Error} When chain ID is not available from wallet client
|
|
39043
39242
|
*/
|
|
39044
39243
|
getChainId() {
|
|
39045
39244
|
const chainId = this.context.walletClient.chain?.id;
|
|
@@ -39052,6 +39251,7 @@ var ProtocolController = class {
|
|
|
39052
39251
|
* Gets the current chain name from the wallet client.
|
|
39053
39252
|
*
|
|
39054
39253
|
* @returns The chain name
|
|
39254
|
+
* @throws {Error} When chain name is not available from wallet client
|
|
39055
39255
|
*/
|
|
39056
39256
|
getChainName() {
|
|
39057
39257
|
const chainName = this.context.walletClient.chain?.name;
|