@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.js
CHANGED
|
@@ -34108,6 +34108,19 @@ var SignatureCache = class {
|
|
|
34108
34108
|
static DEFAULT_TTL_HOURS = 2;
|
|
34109
34109
|
/**
|
|
34110
34110
|
* Get a cached signature if it exists and hasn't expired
|
|
34111
|
+
*
|
|
34112
|
+
* @param cache - Platform cache adapter instance
|
|
34113
|
+
* @param walletAddress - Wallet address that created the signature
|
|
34114
|
+
* @param messageHash - Hash of the message that was signed
|
|
34115
|
+
* @returns The cached signature if valid, null if expired or not found
|
|
34116
|
+
* @example
|
|
34117
|
+
* ```typescript
|
|
34118
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
34119
|
+
* const cached = SignatureCache.get(cache, '0x123...', messageHash);
|
|
34120
|
+
* if (cached) {
|
|
34121
|
+
* console.log('Using cached signature:', cached);
|
|
34122
|
+
* }
|
|
34123
|
+
* ```
|
|
34111
34124
|
*/
|
|
34112
34125
|
static get(cache, walletAddress, messageHash) {
|
|
34113
34126
|
const key = this.getCacheKey(walletAddress, messageHash);
|
|
@@ -34129,7 +34142,24 @@ var SignatureCache = class {
|
|
|
34129
34142
|
}
|
|
34130
34143
|
}
|
|
34131
34144
|
/**
|
|
34132
|
-
* Store a signature in the cache
|
|
34145
|
+
* Store a signature in the cache with configurable TTL
|
|
34146
|
+
*
|
|
34147
|
+
* @param cache - Platform cache adapter instance
|
|
34148
|
+
* @param walletAddress - Wallet address that created the signature
|
|
34149
|
+
* @param messageHash - Hash of the message that was signed
|
|
34150
|
+
* @param signature - The signature to cache
|
|
34151
|
+
* @param ttlHours - Time to live in hours (default: 2)
|
|
34152
|
+
* @example
|
|
34153
|
+
* ```typescript
|
|
34154
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
34155
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
34156
|
+
*
|
|
34157
|
+
* // Cache for default 2 hours
|
|
34158
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
34159
|
+
*
|
|
34160
|
+
* // Cache for 24 hours
|
|
34161
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
|
|
34162
|
+
* ```
|
|
34133
34163
|
*/
|
|
34134
34164
|
static set(cache, walletAddress, messageHash, signature, ttlHours = this.DEFAULT_TTL_HOURS) {
|
|
34135
34165
|
const key = this.getCacheKey(walletAddress, messageHash);
|
|
@@ -34145,6 +34175,18 @@ var SignatureCache = class {
|
|
|
34145
34175
|
}
|
|
34146
34176
|
/**
|
|
34147
34177
|
* Clear all cached signatures (useful for testing or explicit cleanup)
|
|
34178
|
+
*
|
|
34179
|
+
* @param cache - Platform cache adapter instance
|
|
34180
|
+
* @example
|
|
34181
|
+
* ```typescript
|
|
34182
|
+
* // Clear all signatures when user logs out
|
|
34183
|
+
* SignatureCache.clear(cache);
|
|
34184
|
+
*
|
|
34185
|
+
* // Clear before running tests
|
|
34186
|
+
* beforeEach(() => {
|
|
34187
|
+
* SignatureCache.clear(cache);
|
|
34188
|
+
* });
|
|
34189
|
+
* ```
|
|
34148
34190
|
*/
|
|
34149
34191
|
static clear(cache) {
|
|
34150
34192
|
try {
|
|
@@ -34155,6 +34197,27 @@ var SignatureCache = class {
|
|
|
34155
34197
|
static getCacheKey(walletAddress, messageHash) {
|
|
34156
34198
|
return `${this.PREFIX}${walletAddress.toLowerCase()}:${messageHash}`;
|
|
34157
34199
|
}
|
|
34200
|
+
/**
|
|
34201
|
+
* Generate a deterministic hash of a message object for cache key generation
|
|
34202
|
+
*
|
|
34203
|
+
* @remarks
|
|
34204
|
+
* Creates a consistent hash from complex objects including EIP-712 typed data.
|
|
34205
|
+
* Handles BigInt serialization and produces a 32-character hash that balances
|
|
34206
|
+
* uniqueness with key length constraints.
|
|
34207
|
+
*
|
|
34208
|
+
* @param message - The message object to hash (typically EIP-712 typed data)
|
|
34209
|
+
* @returns A 32-character hash string suitable for cache keys
|
|
34210
|
+
* @example
|
|
34211
|
+
* ```typescript
|
|
34212
|
+
* const typedData = {
|
|
34213
|
+
* domain: { name: 'Vana', version: '1' },
|
|
34214
|
+
* message: { nonce: 123n, grant: '...' }
|
|
34215
|
+
* };
|
|
34216
|
+
*
|
|
34217
|
+
* const hash = SignatureCache.hashMessage(typedData);
|
|
34218
|
+
* // Returns something like: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
|
|
34219
|
+
* ```
|
|
34220
|
+
*/
|
|
34158
34221
|
static hashMessage(message) {
|
|
34159
34222
|
const jsonString = JSON.stringify(message, this.bigIntReplacer);
|
|
34160
34223
|
const base64Hash = toBase64(jsonString);
|
|
@@ -34167,8 +34230,12 @@ var SignatureCache = class {
|
|
|
34167
34230
|
/**
|
|
34168
34231
|
* Custom JSON replacer that converts BigInt values to strings for serialization
|
|
34169
34232
|
* This ensures deterministic cache key generation for EIP-712 typed data
|
|
34233
|
+
*
|
|
34234
|
+
* @param _key - The object key being serialized (unused)
|
|
34235
|
+
* @param value - The value to serialize
|
|
34236
|
+
* @returns The serialized value
|
|
34170
34237
|
*/
|
|
34171
|
-
static bigIntReplacer(
|
|
34238
|
+
static bigIntReplacer(_key, value) {
|
|
34172
34239
|
if (typeof value === "bigint") {
|
|
34173
34240
|
return `__BIGINT__${value.toString()}`;
|
|
34174
34241
|
}
|
|
@@ -34193,7 +34260,7 @@ var PermissionsController = class {
|
|
|
34193
34260
|
}
|
|
34194
34261
|
/**
|
|
34195
34262
|
* Grants permission for an application to access user data with gasless transactions.
|
|
34196
|
-
*
|
|
34263
|
+
*
|
|
34197
34264
|
* This method provides a complete end-to-end permission grant flow that returns
|
|
34198
34265
|
* the permission ID and other relevant data immediately after successful submission.
|
|
34199
34266
|
* For advanced users who need more control over the transaction lifecycle, use
|
|
@@ -34220,7 +34287,7 @@ var PermissionsController = class {
|
|
|
34220
34287
|
*
|
|
34221
34288
|
* console.log(`Permission ${result.permissionId} granted to ${result.user}`);
|
|
34222
34289
|
* console.log(`Transaction: ${result.transactionHash}`);
|
|
34223
|
-
*
|
|
34290
|
+
*
|
|
34224
34291
|
* // Can immediately use the permission ID for other operations
|
|
34225
34292
|
* await vana.permissions.revoke({ permissionId: result.permissionId });
|
|
34226
34293
|
* ```
|
|
@@ -34231,12 +34298,12 @@ var PermissionsController = class {
|
|
|
34231
34298
|
}
|
|
34232
34299
|
/**
|
|
34233
34300
|
* Submits a permission grant transaction and returns the transaction hash immediately.
|
|
34234
|
-
*
|
|
34301
|
+
*
|
|
34235
34302
|
* This is the lower-level method that provides maximum control over transaction timing.
|
|
34236
34303
|
* Use this when you want to handle transaction confirmation and event parsing separately,
|
|
34237
34304
|
* or when submitting multiple transactions in batch.
|
|
34238
34305
|
*
|
|
34239
|
-
* @param params - The permission grant configuration object
|
|
34306
|
+
* @param params - The permission grant configuration object
|
|
34240
34307
|
* @returns Promise that resolves to the transaction hash when successfully submitted
|
|
34241
34308
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
34242
34309
|
* @throws {SignatureError} When user rejects the signature request
|
|
@@ -34247,7 +34314,7 @@ var PermissionsController = class {
|
|
|
34247
34314
|
* // Submit transaction and handle confirmation later
|
|
34248
34315
|
* const txHash = await vana.permissions.submitPermissionGrant(params);
|
|
34249
34316
|
* console.log(`Transaction submitted: ${txHash}`);
|
|
34250
|
-
*
|
|
34317
|
+
*
|
|
34251
34318
|
* // Later, when you need the permission data:
|
|
34252
34319
|
* const result = await parseTransactionResult(context, txHash, 'grant');
|
|
34253
34320
|
* console.log(`Permission ID: ${result.permissionId}`);
|
|
@@ -34267,6 +34334,8 @@ var PermissionsController = class {
|
|
|
34267
34334
|
* until the returned `confirm()` function is called.
|
|
34268
34335
|
* @param params - The permission grant parameters
|
|
34269
34336
|
* @returns A promise resolving to a preview object and confirm function
|
|
34337
|
+
* @throws {SerializationError} When grant parameters are invalid or cannot be serialized
|
|
34338
|
+
* @throws {BlockchainError} When grant validation fails or preparation encounters an error
|
|
34270
34339
|
* @example
|
|
34271
34340
|
* ```typescript
|
|
34272
34341
|
* const { preview, confirm } = await vana.permissions.prepareGrant({
|
|
@@ -34670,13 +34739,13 @@ var PermissionsController = class {
|
|
|
34670
34739
|
}
|
|
34671
34740
|
/**
|
|
34672
34741
|
* Revokes a previously granted permission.
|
|
34673
|
-
*
|
|
34742
|
+
*
|
|
34674
34743
|
* This method provides complete revocation with automatic event parsing to confirm
|
|
34675
34744
|
* the permission was successfully revoked. For advanced users who need more control,
|
|
34676
34745
|
* use `submitPermissionRevoke()` instead.
|
|
34677
34746
|
*
|
|
34678
34747
|
* @param params - Parameters for revoking the permission
|
|
34679
|
-
* @param params.permissionId - Permission identifier
|
|
34748
|
+
* @param params.permissionId - Permission identifier (accepts bigint, number, or string).
|
|
34680
34749
|
* Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
|
|
34681
34750
|
* @returns Promise resolving to revocation data from PermissionRevoked event
|
|
34682
34751
|
* @throws {BlockchainError} When revocation fails or event parsing fails
|
|
@@ -34698,7 +34767,7 @@ var PermissionsController = class {
|
|
|
34698
34767
|
}
|
|
34699
34768
|
/**
|
|
34700
34769
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
34701
|
-
*
|
|
34770
|
+
*
|
|
34702
34771
|
* This is the lower-level method that provides maximum control over transaction timing.
|
|
34703
34772
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
34704
34773
|
*
|
|
@@ -34753,6 +34822,11 @@ var PermissionsController = class {
|
|
|
34753
34822
|
*
|
|
34754
34823
|
* @param params - Parameters for revoking the permission
|
|
34755
34824
|
* @returns Promise resolving to transaction hash
|
|
34825
|
+
* @throws {BlockchainError} When chain ID is not available
|
|
34826
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
34827
|
+
* @throws {SignatureError} When user rejects the signature request
|
|
34828
|
+
* @throws {RelayerError} When gasless submission fails
|
|
34829
|
+
* @throws {PermissionError} When revocation fails for any other reason
|
|
34756
34830
|
*/
|
|
34757
34831
|
async revokeWithSignature(params) {
|
|
34758
34832
|
try {
|
|
@@ -34795,6 +34869,9 @@ var PermissionsController = class {
|
|
|
34795
34869
|
* Retrieves the user's current nonce from the DataPermissions contract.
|
|
34796
34870
|
*
|
|
34797
34871
|
* @returns Promise resolving to the user's current nonce value
|
|
34872
|
+
* @throws {Error} When wallet account is not available
|
|
34873
|
+
* @throws {Error} When chain ID is not available
|
|
34874
|
+
* @throws {NonceError} When reading nonce from contract fails
|
|
34798
34875
|
*/
|
|
34799
34876
|
async getUserNonce() {
|
|
34800
34877
|
try {
|
|
@@ -35041,6 +35118,7 @@ var PermissionsController = class {
|
|
|
35041
35118
|
*
|
|
35042
35119
|
* @param fileId - The file ID to query permissions for
|
|
35043
35120
|
* @returns Promise resolving to array of permission IDs
|
|
35121
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35044
35122
|
*/
|
|
35045
35123
|
async getFilePermissionIds(fileId) {
|
|
35046
35124
|
try {
|
|
@@ -35069,6 +35147,7 @@ var PermissionsController = class {
|
|
|
35069
35147
|
*
|
|
35070
35148
|
* @param permissionId - The permission ID to query files for
|
|
35071
35149
|
* @returns Promise resolving to array of file IDs
|
|
35150
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35072
35151
|
*/
|
|
35073
35152
|
async getPermissionFileIds(permissionId) {
|
|
35074
35153
|
try {
|
|
@@ -35097,6 +35176,7 @@ var PermissionsController = class {
|
|
|
35097
35176
|
*
|
|
35098
35177
|
* @param permissionId - The permission ID to check
|
|
35099
35178
|
* @returns Promise resolving to boolean indicating if permission is active
|
|
35179
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35100
35180
|
*/
|
|
35101
35181
|
async isActivePermission(permissionId) {
|
|
35102
35182
|
try {
|
|
@@ -35125,6 +35205,7 @@ var PermissionsController = class {
|
|
|
35125
35205
|
*
|
|
35126
35206
|
* @param permissionId - The permission ID to query
|
|
35127
35207
|
* @returns Promise resolving to permission info
|
|
35208
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35128
35209
|
*/
|
|
35129
35210
|
async getPermissionInfo(permissionId) {
|
|
35130
35211
|
try {
|
|
@@ -35172,7 +35253,12 @@ var PermissionsController = class {
|
|
|
35172
35253
|
* Trusts a server for data processing.
|
|
35173
35254
|
*
|
|
35174
35255
|
* @param params - Parameters for trusting the server
|
|
35256
|
+
* @param params.serverId - The server's Ethereum address
|
|
35257
|
+
* @param params.serverUrl - The server's URL endpoint
|
|
35175
35258
|
* @returns Promise resolving to transaction hash
|
|
35259
|
+
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
35260
|
+
* @throws {BlockchainError} When chain ID is unavailable or transaction fails
|
|
35261
|
+
* @throws {Error} When wallet account is not available
|
|
35176
35262
|
* @example
|
|
35177
35263
|
* ```typescript
|
|
35178
35264
|
* // Trust a server by providing its ID and URL
|
|
@@ -35219,6 +35305,12 @@ var PermissionsController = class {
|
|
|
35219
35305
|
*
|
|
35220
35306
|
* @param params - Parameters for trusting the server
|
|
35221
35307
|
* @returns Promise resolving to transaction hash
|
|
35308
|
+
* @throws {BlockchainError} When chain ID is not available
|
|
35309
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
35310
|
+
* @throws {SignatureError} When user rejects the signature request
|
|
35311
|
+
* @throws {RelayerError} When gasless submission fails
|
|
35312
|
+
* @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
|
|
35313
|
+
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
35222
35314
|
*/
|
|
35223
35315
|
async trustServerWithSignature(params) {
|
|
35224
35316
|
try {
|
|
@@ -35293,7 +35385,12 @@ var PermissionsController = class {
|
|
|
35293
35385
|
* Untrusts a server.
|
|
35294
35386
|
*
|
|
35295
35387
|
* @param params - Parameters for untrusting the server
|
|
35388
|
+
* @param params.serverId - The server's Ethereum address to untrust
|
|
35296
35389
|
* @returns Promise resolving to transaction hash
|
|
35390
|
+
* @throws {Error} When wallet account is not available
|
|
35391
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
35392
|
+
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
35393
|
+
* @throws {BlockchainError} When untrust transaction fails
|
|
35297
35394
|
*/
|
|
35298
35395
|
async untrustServer(params) {
|
|
35299
35396
|
const nonce = await this.getUserNonce();
|
|
@@ -35307,7 +35404,13 @@ var PermissionsController = class {
|
|
|
35307
35404
|
* Untrusts a server using a signature (gasless transaction).
|
|
35308
35405
|
*
|
|
35309
35406
|
* @param params - Parameters for untrusting the server
|
|
35407
|
+
* @param params.serverId - The server's Ethereum address to untrust
|
|
35310
35408
|
* @returns Promise resolving to transaction hash
|
|
35409
|
+
* @throws {Error} When wallet account is not available
|
|
35410
|
+
* @throws {NonceError} When retrieving user nonce fails
|
|
35411
|
+
* @throws {SignatureError} When user rejects the signature request
|
|
35412
|
+
* @throws {RelayerError} When gasless submission fails
|
|
35413
|
+
* @throws {BlockchainError} When untrust transaction fails
|
|
35311
35414
|
*/
|
|
35312
35415
|
async untrustServerWithSignature(params) {
|
|
35313
35416
|
try {
|
|
@@ -35349,6 +35452,7 @@ var PermissionsController = class {
|
|
|
35349
35452
|
*
|
|
35350
35453
|
* @param userAddress - Optional user address (defaults to current user)
|
|
35351
35454
|
* @returns Promise resolving to array of trusted server addresses
|
|
35455
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35352
35456
|
*/
|
|
35353
35457
|
async getTrustedServers(userAddress) {
|
|
35354
35458
|
try {
|
|
@@ -35378,6 +35482,7 @@ var PermissionsController = class {
|
|
|
35378
35482
|
*
|
|
35379
35483
|
* @param serverId - Server address
|
|
35380
35484
|
* @returns Promise resolving to server information
|
|
35485
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35381
35486
|
*/
|
|
35382
35487
|
async getServerInfo(serverId) {
|
|
35383
35488
|
try {
|
|
@@ -35406,6 +35511,7 @@ var PermissionsController = class {
|
|
|
35406
35511
|
*
|
|
35407
35512
|
* @param userAddress - Optional user address (defaults to current user)
|
|
35408
35513
|
* @returns Promise resolving to the number of trusted servers
|
|
35514
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35409
35515
|
*/
|
|
35410
35516
|
async getTrustedServersCount(userAddress) {
|
|
35411
35517
|
try {
|
|
@@ -35435,6 +35541,7 @@ var PermissionsController = class {
|
|
|
35435
35541
|
*
|
|
35436
35542
|
* @param options - Query options including pagination parameters
|
|
35437
35543
|
* @returns Promise resolving to paginated trusted servers
|
|
35544
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35438
35545
|
*/
|
|
35439
35546
|
async getTrustedServersPaginated(options = {}) {
|
|
35440
35547
|
try {
|
|
@@ -35494,6 +35601,7 @@ var PermissionsController = class {
|
|
|
35494
35601
|
*
|
|
35495
35602
|
* @param options - Query options
|
|
35496
35603
|
* @returns Promise resolving to array of trusted server info
|
|
35604
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35497
35605
|
*/
|
|
35498
35606
|
async getTrustedServersWithInfo(options = {}) {
|
|
35499
35607
|
try {
|
|
@@ -35531,6 +35639,7 @@ var PermissionsController = class {
|
|
|
35531
35639
|
*
|
|
35532
35640
|
* @param serverIds - Array of server IDs to query
|
|
35533
35641
|
* @returns Promise resolving to batch result with successes and failures
|
|
35642
|
+
* @throws {BlockchainError} When reading from contract fails or chain is unavailable
|
|
35534
35643
|
*/
|
|
35535
35644
|
async getServerInfoBatch(serverIds) {
|
|
35536
35645
|
if (serverIds.length === 0) {
|
|
@@ -36024,9 +36133,14 @@ var DataController = class {
|
|
|
36024
36133
|
* @param file - The user file to decrypt (typically from getUserFiles)
|
|
36025
36134
|
* @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
|
|
36026
36135
|
* @returns Promise resolving to the decrypted file content as a Blob
|
|
36027
|
-
* @throws {Error}
|
|
36028
|
-
* @throws {Error}
|
|
36029
|
-
* @throws {Error}
|
|
36136
|
+
* @throws {Error} "No addresses available in wallet client" - When wallet is not connected
|
|
36137
|
+
* @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
|
|
36138
|
+
* @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
|
|
36139
|
+
* @throws {Error} "Access denied" - When file returns 403 (no permission)
|
|
36140
|
+
* @throws {Error} "File is empty or could not be retrieved" - When file has no content
|
|
36141
|
+
* @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
|
|
36142
|
+
* @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
|
|
36143
|
+
* @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
|
|
36030
36144
|
* @example
|
|
36031
36145
|
* ```typescript
|
|
36032
36146
|
* // Basic file decryption
|
|
@@ -36146,11 +36260,20 @@ var DataController = class {
|
|
|
36146
36260
|
* This method queries the Vana subgraph to find files directly owned by the user.
|
|
36147
36261
|
* It efficiently handles large datasets by using the File entity's owner field
|
|
36148
36262
|
* and returns complete file metadata without additional contract calls.
|
|
36263
|
+
*
|
|
36264
|
+
* **Deduplication Behavior:**
|
|
36265
|
+
* The method automatically deduplicates files by ID, keeping only the latest version
|
|
36266
|
+
* (highest timestamp) when duplicate file IDs are found. This handles cases where
|
|
36267
|
+
* the subgraph may contain multiple entries for the same file due to re-indexing
|
|
36268
|
+
* or blockchain reorganizations.
|
|
36149
36269
|
* @param params - The query parameters object
|
|
36150
36270
|
* @param params.owner - The wallet address of the file owner to query
|
|
36151
36271
|
* @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
|
|
36152
|
-
* @returns A Promise that resolves to an array of UserFile objects with metadata
|
|
36153
|
-
* @throws {Error} When
|
|
36272
|
+
* @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
|
|
36273
|
+
* @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
|
|
36274
|
+
* @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
|
|
36275
|
+
* @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
|
|
36276
|
+
* @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
|
|
36154
36277
|
* @example
|
|
36155
36278
|
* ```typescript
|
|
36156
36279
|
* // Query files for a specific user
|
|
@@ -36653,6 +36776,9 @@ var DataController = class {
|
|
|
36653
36776
|
*
|
|
36654
36777
|
* @param fileId - The file ID to look up
|
|
36655
36778
|
* @returns Promise resolving to UserFile object
|
|
36779
|
+
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
36780
|
+
* @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
|
|
36781
|
+
* @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
|
|
36656
36782
|
* @example
|
|
36657
36783
|
* ```typescript
|
|
36658
36784
|
* try {
|
|
@@ -36722,7 +36848,21 @@ var DataController = class {
|
|
|
36722
36848
|
/**
|
|
36723
36849
|
* Uploads an encrypted file to storage and registers it on the blockchain.
|
|
36724
36850
|
*
|
|
36725
|
-
* @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption
|
|
36851
|
+
* @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption
|
|
36852
|
+
*
|
|
36853
|
+
* Migration guide:
|
|
36854
|
+
* ```typescript
|
|
36855
|
+
* // Old way (deprecated):
|
|
36856
|
+
* const encrypted = await encryptBlob(data, key);
|
|
36857
|
+
* const result = await vana.data.uploadEncryptedFile(encrypted, filename);
|
|
36858
|
+
*
|
|
36859
|
+
* // New way:
|
|
36860
|
+
* const result = await vana.data.upload({
|
|
36861
|
+
* content: data,
|
|
36862
|
+
* filename: filename,
|
|
36863
|
+
* encrypt: true // Handles encryption automatically
|
|
36864
|
+
* });
|
|
36865
|
+
* ```
|
|
36726
36866
|
* @param encryptedFile - The encrypted file blob to upload
|
|
36727
36867
|
* @param filename - Optional filename for the upload
|
|
36728
36868
|
* @param providerName - Optional storage provider to use
|
|
@@ -36810,7 +36950,22 @@ var DataController = class {
|
|
|
36810
36950
|
/**
|
|
36811
36951
|
* Uploads an encrypted file to storage and registers it on the blockchain with a schema.
|
|
36812
36952
|
*
|
|
36813
|
-
* @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
|
|
36953
|
+
* @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
|
|
36954
|
+
*
|
|
36955
|
+
* Migration guide:
|
|
36956
|
+
* ```typescript
|
|
36957
|
+
* // Old way (deprecated):
|
|
36958
|
+
* const encrypted = await encryptBlob(data, key);
|
|
36959
|
+
* const result = await vana.data.uploadEncryptedFileWithSchema(encrypted, schemaId, filename);
|
|
36960
|
+
*
|
|
36961
|
+
* // New way:
|
|
36962
|
+
* const result = await vana.data.upload({
|
|
36963
|
+
* content: data,
|
|
36964
|
+
* filename: filename,
|
|
36965
|
+
* schemaId: schemaId, // Automatic validation
|
|
36966
|
+
* encrypt: true
|
|
36967
|
+
* });
|
|
36968
|
+
* ```
|
|
36814
36969
|
* @param encryptedFile - The encrypted file blob to upload
|
|
36815
36970
|
* @param schemaId - The schema ID to associate with the file
|
|
36816
36971
|
* @param filename - Optional filename for the upload
|
|
@@ -37086,7 +37241,24 @@ var DataController = class {
|
|
|
37086
37241
|
/**
|
|
37087
37242
|
* Adds a new schema to the DataRefinerRegistry.
|
|
37088
37243
|
*
|
|
37089
|
-
* @deprecated Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
|
|
37244
|
+
* @deprecated Since v2.0.0 - Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
|
|
37245
|
+
*
|
|
37246
|
+
* Migration guide:
|
|
37247
|
+
* ```typescript
|
|
37248
|
+
* // Old way (deprecated):
|
|
37249
|
+
* const result = await vana.data.addSchema({
|
|
37250
|
+
* name: "UserProfile",
|
|
37251
|
+
* type: "JSON",
|
|
37252
|
+
* definitionUrl: "ipfs://..."
|
|
37253
|
+
* });
|
|
37254
|
+
*
|
|
37255
|
+
* // New way:
|
|
37256
|
+
* const result = await vana.schemas.create({
|
|
37257
|
+
* name: "UserProfile",
|
|
37258
|
+
* type: "JSON",
|
|
37259
|
+
* definition: schemaObject // Automatically uploads to IPFS
|
|
37260
|
+
* });
|
|
37261
|
+
* ```
|
|
37090
37262
|
* @param params - Schema parameters including name, type, and definition URL
|
|
37091
37263
|
* @returns Promise resolving to the new schema ID and transaction hash
|
|
37092
37264
|
*/
|
|
@@ -37145,7 +37317,16 @@ var DataController = class {
|
|
|
37145
37317
|
/**
|
|
37146
37318
|
* Retrieves a schema by its ID.
|
|
37147
37319
|
*
|
|
37148
|
-
* @deprecated Use vana.schemas.get() instead
|
|
37320
|
+
* @deprecated Since v2.0.0 - Use vana.schemas.get() instead
|
|
37321
|
+
*
|
|
37322
|
+
* Migration guide:
|
|
37323
|
+
* ```typescript
|
|
37324
|
+
* // Old way (deprecated):
|
|
37325
|
+
* const schema = await vana.data.getSchema(schemaId);
|
|
37326
|
+
*
|
|
37327
|
+
* // New way:
|
|
37328
|
+
* const schema = await vana.schemas.get(schemaId);
|
|
37329
|
+
* ```
|
|
37149
37330
|
* @param schemaId - The schema ID to retrieve
|
|
37150
37331
|
* @returns Promise resolving to the schema information
|
|
37151
37332
|
*/
|
|
@@ -37191,7 +37372,16 @@ var DataController = class {
|
|
|
37191
37372
|
/**
|
|
37192
37373
|
* Gets the total number of schemas in the registry.
|
|
37193
37374
|
*
|
|
37194
|
-
* @deprecated Use vana.schemas.count() instead
|
|
37375
|
+
* @deprecated Since v2.0.0 - Use vana.schemas.count() instead
|
|
37376
|
+
*
|
|
37377
|
+
* Migration guide:
|
|
37378
|
+
* ```typescript
|
|
37379
|
+
* // Old way (deprecated):
|
|
37380
|
+
* const count = await vana.data.getSchemasCount();
|
|
37381
|
+
*
|
|
37382
|
+
* // New way:
|
|
37383
|
+
* const count = await vana.schemas.count();
|
|
37384
|
+
* ```
|
|
37195
37385
|
* @returns Promise resolving to the total schema count
|
|
37196
37386
|
*/
|
|
37197
37387
|
async getSchemasCount() {
|
|
@@ -37513,8 +37703,11 @@ var DataController = class {
|
|
|
37513
37703
|
*
|
|
37514
37704
|
* @param fileId - The ID of the file to add permissions for
|
|
37515
37705
|
* @param account - The address of the account to grant permission to
|
|
37516
|
-
* @param publicKey - The public key to encrypt the user's encryption key with
|
|
37706
|
+
* @param publicKey - The public key to encrypt the user's encryption key with (hex string with 0x prefix)
|
|
37517
37707
|
* @returns Promise resolving to permission data from PermissionGranted event
|
|
37708
|
+
* @throws {Error} "No addresses available in wallet client" - When wallet is not connected
|
|
37709
|
+
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
37710
|
+
* @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
|
|
37518
37711
|
* @example
|
|
37519
37712
|
* ```typescript
|
|
37520
37713
|
* const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
|
|
@@ -37667,7 +37860,9 @@ var DataController = class {
|
|
|
37667
37860
|
*
|
|
37668
37861
|
* @param url - The URL to fetch content from
|
|
37669
37862
|
* @returns Promise resolving to the fetched content as a Blob
|
|
37670
|
-
* @throws {Error}
|
|
37863
|
+
* @throws {Error} "HTTP error! status: {status} {statusText}" - When server returns error status
|
|
37864
|
+
* @throws {Error} "Empty response" - When server returns no content
|
|
37865
|
+
* @throws {Error} "Network error: Failed to fetch from {url}" - When network request fails
|
|
37671
37866
|
*
|
|
37672
37867
|
* @example
|
|
37673
37868
|
* ```typescript
|
|
@@ -37719,7 +37914,10 @@ var DataController = class {
|
|
|
37719
37914
|
* @param options - Optional configuration
|
|
37720
37915
|
* @param options.gateways - Array of IPFS gateway URLs to try (must end with /)
|
|
37721
37916
|
* @returns Promise resolving to the fetched content as a Blob
|
|
37722
|
-
* @throws {Error} When
|
|
37917
|
+
* @throws {Error} "Invalid IPFS URL format" - When URL is not ipfs:// or valid CID
|
|
37918
|
+
* @throws {Error} "Empty response" - When gateway returns no content
|
|
37919
|
+
* @throws {Error} "HTTP error! status: {status}" - When gateway returns error status
|
|
37920
|
+
* @throws {Error} "Failed to fetch IPFS content {cid} from all gateways" - When all gateways fail
|
|
37723
37921
|
*
|
|
37724
37922
|
* @example
|
|
37725
37923
|
* ```typescript
|
|
@@ -38281,11 +38479,11 @@ var ServerController = class {
|
|
|
38281
38479
|
* const identity = await vana.server.getIdentity({
|
|
38282
38480
|
* userAddress: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
38283
38481
|
* });
|
|
38284
|
-
*
|
|
38482
|
+
*
|
|
38285
38483
|
* console.log(`Server: ${identity.name}`);
|
|
38286
38484
|
* console.log(`Address: ${identity.address}`);
|
|
38287
38485
|
* console.log(`Public Key: ${identity.public_key}`);
|
|
38288
|
-
*
|
|
38486
|
+
*
|
|
38289
38487
|
* // Use the public key for encrypting data to share with this server
|
|
38290
38488
|
* const encryptedData = await encryptWithWalletPublicKey(
|
|
38291
38489
|
* userData,
|
|
@@ -38449,7 +38647,7 @@ var ServerController = class {
|
|
|
38449
38647
|
* @remarks
|
|
38450
38648
|
* This method attempts to cancel an operation that is currently processing
|
|
38451
38649
|
* on the personal server. The operation must be in a cancellable state
|
|
38452
|
-
* (typically `starting` or `processing`). Not all operations support
|
|
38650
|
+
* (typically `starting` or `processing`). Not all operations support
|
|
38453
38651
|
* cancellation, and cancellation may not be immediate. The server will
|
|
38454
38652
|
* attempt to stop the operation and update its status to `canceled`.
|
|
38455
38653
|
*
|
|
@@ -38476,7 +38674,7 @@ var ServerController = class {
|
|
|
38476
38674
|
* try {
|
|
38477
38675
|
* await vana.server.cancelOperation(operation.id);
|
|
38478
38676
|
* console.log("Cancellation requested");
|
|
38479
|
-
*
|
|
38677
|
+
*
|
|
38480
38678
|
* // Verify cancellation
|
|
38481
38679
|
* const status = await vana.server.getOperation(operation.id);
|
|
38482
38680
|
* if (status.status === "canceled") {
|
|
@@ -38900,6 +39098,7 @@ var ProtocolController = class {
|
|
|
38900
39098
|
* Gets the current chain ID from the wallet client.
|
|
38901
39099
|
*
|
|
38902
39100
|
* @returns The chain ID
|
|
39101
|
+
* @throws {Error} When chain ID is not available from wallet client
|
|
38903
39102
|
*/
|
|
38904
39103
|
getChainId() {
|
|
38905
39104
|
const chainId = this.context.walletClient.chain?.id;
|
|
@@ -38912,6 +39111,7 @@ var ProtocolController = class {
|
|
|
38912
39111
|
* Gets the current chain name from the wallet client.
|
|
38913
39112
|
*
|
|
38914
39113
|
* @returns The chain name
|
|
39114
|
+
* @throws {Error} When chain name is not available from wallet client
|
|
38915
39115
|
*/
|
|
38916
39116
|
getChainName() {
|
|
38917
39117
|
const chainName = this.context.walletClient.chain?.name;
|