@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.
@@ -33846,6 +33846,19 @@ init_crypto_utils();
33846
33846
  var SignatureCache = class {
33847
33847
  /**
33848
33848
  * Get a cached signature if it exists and hasn't expired
33849
+ *
33850
+ * @param cache - Platform cache adapter instance
33851
+ * @param walletAddress - Wallet address that created the signature
33852
+ * @param messageHash - Hash of the message that was signed
33853
+ * @returns The cached signature if valid, null if expired or not found
33854
+ * @example
33855
+ * ```typescript
33856
+ * const messageHash = SignatureCache.hashMessage(typedData);
33857
+ * const cached = SignatureCache.get(cache, '0x123...', messageHash);
33858
+ * if (cached) {
33859
+ * console.log('Using cached signature:', cached);
33860
+ * }
33861
+ * ```
33849
33862
  */
33850
33863
  static get(cache, walletAddress, messageHash) {
33851
33864
  const key = this.getCacheKey(walletAddress, messageHash);
@@ -33867,7 +33880,24 @@ var SignatureCache = class {
33867
33880
  }
33868
33881
  }
33869
33882
  /**
33870
- * Store a signature in the cache
33883
+ * Store a signature in the cache with configurable TTL
33884
+ *
33885
+ * @param cache - Platform cache adapter instance
33886
+ * @param walletAddress - Wallet address that created the signature
33887
+ * @param messageHash - Hash of the message that was signed
33888
+ * @param signature - The signature to cache
33889
+ * @param ttlHours - Time to live in hours (default: 2)
33890
+ * @example
33891
+ * ```typescript
33892
+ * const signature = await wallet.signTypedData(typedData);
33893
+ * const messageHash = SignatureCache.hashMessage(typedData);
33894
+ *
33895
+ * // Cache for default 2 hours
33896
+ * SignatureCache.set(cache, walletAddress, messageHash, signature);
33897
+ *
33898
+ * // Cache for 24 hours
33899
+ * SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
33900
+ * ```
33871
33901
  */
33872
33902
  static set(cache, walletAddress, messageHash, signature, ttlHours = this.DEFAULT_TTL_HOURS) {
33873
33903
  const key = this.getCacheKey(walletAddress, messageHash);
@@ -33883,6 +33913,18 @@ var SignatureCache = class {
33883
33913
  }
33884
33914
  /**
33885
33915
  * Clear all cached signatures (useful for testing or explicit cleanup)
33916
+ *
33917
+ * @param cache - Platform cache adapter instance
33918
+ * @example
33919
+ * ```typescript
33920
+ * // Clear all signatures when user logs out
33921
+ * SignatureCache.clear(cache);
33922
+ *
33923
+ * // Clear before running tests
33924
+ * beforeEach(() => {
33925
+ * SignatureCache.clear(cache);
33926
+ * });
33927
+ * ```
33886
33928
  */
33887
33929
  static clear(cache) {
33888
33930
  try {
@@ -33893,6 +33935,27 @@ var SignatureCache = class {
33893
33935
  static getCacheKey(walletAddress, messageHash) {
33894
33936
  return `${this.PREFIX}${walletAddress.toLowerCase()}:${messageHash}`;
33895
33937
  }
33938
+ /**
33939
+ * Generate a deterministic hash of a message object for cache key generation
33940
+ *
33941
+ * @remarks
33942
+ * Creates a consistent hash from complex objects including EIP-712 typed data.
33943
+ * Handles BigInt serialization and produces a 32-character hash that balances
33944
+ * uniqueness with key length constraints.
33945
+ *
33946
+ * @param message - The message object to hash (typically EIP-712 typed data)
33947
+ * @returns A 32-character hash string suitable for cache keys
33948
+ * @example
33949
+ * ```typescript
33950
+ * const typedData = {
33951
+ * domain: { name: 'Vana', version: '1' },
33952
+ * message: { nonce: 123n, grant: '...' }
33953
+ * };
33954
+ *
33955
+ * const hash = SignatureCache.hashMessage(typedData);
33956
+ * // Returns something like: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"
33957
+ * ```
33958
+ */
33896
33959
  static hashMessage(message) {
33897
33960
  const jsonString = JSON.stringify(message, this.bigIntReplacer);
33898
33961
  const base64Hash = toBase64(jsonString);
@@ -33905,8 +33968,12 @@ var SignatureCache = class {
33905
33968
  /**
33906
33969
  * Custom JSON replacer that converts BigInt values to strings for serialization
33907
33970
  * This ensures deterministic cache key generation for EIP-712 typed data
33971
+ *
33972
+ * @param _key - The object key being serialized (unused)
33973
+ * @param value - The value to serialize
33974
+ * @returns The serialized value
33908
33975
  */
33909
- static bigIntReplacer(key, value) {
33976
+ static bigIntReplacer(_key, value) {
33910
33977
  if (typeof value === "bigint") {
33911
33978
  return `__BIGINT__${value.toString()}`;
33912
33979
  }
@@ -33933,7 +34000,7 @@ var PermissionsController = class {
33933
34000
  }
33934
34001
  /**
33935
34002
  * Grants permission for an application to access user data with gasless transactions.
33936
- *
34003
+ *
33937
34004
  * This method provides a complete end-to-end permission grant flow that returns
33938
34005
  * the permission ID and other relevant data immediately after successful submission.
33939
34006
  * For advanced users who need more control over the transaction lifecycle, use
@@ -33960,7 +34027,7 @@ var PermissionsController = class {
33960
34027
  *
33961
34028
  * console.log(`Permission ${result.permissionId} granted to ${result.user}`);
33962
34029
  * console.log(`Transaction: ${result.transactionHash}`);
33963
- *
34030
+ *
33964
34031
  * // Can immediately use the permission ID for other operations
33965
34032
  * await vana.permissions.revoke({ permissionId: result.permissionId });
33966
34033
  * ```
@@ -33971,12 +34038,12 @@ var PermissionsController = class {
33971
34038
  }
33972
34039
  /**
33973
34040
  * Submits a permission grant transaction and returns the transaction hash immediately.
33974
- *
34041
+ *
33975
34042
  * This is the lower-level method that provides maximum control over transaction timing.
33976
34043
  * Use this when you want to handle transaction confirmation and event parsing separately,
33977
34044
  * or when submitting multiple transactions in batch.
33978
34045
  *
33979
- * @param params - The permission grant configuration object
34046
+ * @param params - The permission grant configuration object
33980
34047
  * @returns Promise that resolves to the transaction hash when successfully submitted
33981
34048
  * @throws {RelayerError} When gasless transaction submission fails
33982
34049
  * @throws {SignatureError} When user rejects the signature request
@@ -33987,7 +34054,7 @@ var PermissionsController = class {
33987
34054
  * // Submit transaction and handle confirmation later
33988
34055
  * const txHash = await vana.permissions.submitPermissionGrant(params);
33989
34056
  * console.log(`Transaction submitted: ${txHash}`);
33990
- *
34057
+ *
33991
34058
  * // Later, when you need the permission data:
33992
34059
  * const result = await parseTransactionResult(context, txHash, 'grant');
33993
34060
  * console.log(`Permission ID: ${result.permissionId}`);
@@ -34007,6 +34074,8 @@ var PermissionsController = class {
34007
34074
  * until the returned `confirm()` function is called.
34008
34075
  * @param params - The permission grant parameters
34009
34076
  * @returns A promise resolving to a preview object and confirm function
34077
+ * @throws {SerializationError} When grant parameters are invalid or cannot be serialized
34078
+ * @throws {BlockchainError} When grant validation fails or preparation encounters an error
34010
34079
  * @example
34011
34080
  * ```typescript
34012
34081
  * const { preview, confirm } = await vana.permissions.prepareGrant({
@@ -34410,13 +34479,13 @@ var PermissionsController = class {
34410
34479
  }
34411
34480
  /**
34412
34481
  * Revokes a previously granted permission.
34413
- *
34482
+ *
34414
34483
  * This method provides complete revocation with automatic event parsing to confirm
34415
34484
  * the permission was successfully revoked. For advanced users who need more control,
34416
34485
  * use `submitPermissionRevoke()` instead.
34417
34486
  *
34418
34487
  * @param params - Parameters for revoking the permission
34419
- * @param params.permissionId - Permission identifier as bigint for contract compatibility.
34488
+ * @param params.permissionId - Permission identifier (accepts bigint, number, or string).
34420
34489
  * Obtain from permission grants via `getUserPermissionGrantsOnChain()`.
34421
34490
  * @returns Promise resolving to revocation data from PermissionRevoked event
34422
34491
  * @throws {BlockchainError} When revocation fails or event parsing fails
@@ -34438,7 +34507,7 @@ var PermissionsController = class {
34438
34507
  }
34439
34508
  /**
34440
34509
  * Submits a permission revocation transaction and returns the transaction hash immediately.
34441
- *
34510
+ *
34442
34511
  * This is the lower-level method that provides maximum control over transaction timing.
34443
34512
  * Use this when you want to handle transaction confirmation and event parsing separately.
34444
34513
  *
@@ -34493,6 +34562,11 @@ var PermissionsController = class {
34493
34562
  *
34494
34563
  * @param params - Parameters for revoking the permission
34495
34564
  * @returns Promise resolving to transaction hash
34565
+ * @throws {BlockchainError} When chain ID is not available
34566
+ * @throws {NonceError} When retrieving user nonce fails
34567
+ * @throws {SignatureError} When user rejects the signature request
34568
+ * @throws {RelayerError} When gasless submission fails
34569
+ * @throws {PermissionError} When revocation fails for any other reason
34496
34570
  */
34497
34571
  async revokeWithSignature(params) {
34498
34572
  try {
@@ -34535,6 +34609,9 @@ var PermissionsController = class {
34535
34609
  * Retrieves the user's current nonce from the DataPermissions contract.
34536
34610
  *
34537
34611
  * @returns Promise resolving to the user's current nonce value
34612
+ * @throws {Error} When wallet account is not available
34613
+ * @throws {Error} When chain ID is not available
34614
+ * @throws {NonceError} When reading nonce from contract fails
34538
34615
  */
34539
34616
  async getUserNonce() {
34540
34617
  try {
@@ -34781,6 +34858,7 @@ var PermissionsController = class {
34781
34858
  *
34782
34859
  * @param fileId - The file ID to query permissions for
34783
34860
  * @returns Promise resolving to array of permission IDs
34861
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
34784
34862
  */
34785
34863
  async getFilePermissionIds(fileId) {
34786
34864
  try {
@@ -34809,6 +34887,7 @@ var PermissionsController = class {
34809
34887
  *
34810
34888
  * @param permissionId - The permission ID to query files for
34811
34889
  * @returns Promise resolving to array of file IDs
34890
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
34812
34891
  */
34813
34892
  async getPermissionFileIds(permissionId) {
34814
34893
  try {
@@ -34837,6 +34916,7 @@ var PermissionsController = class {
34837
34916
  *
34838
34917
  * @param permissionId - The permission ID to check
34839
34918
  * @returns Promise resolving to boolean indicating if permission is active
34919
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
34840
34920
  */
34841
34921
  async isActivePermission(permissionId) {
34842
34922
  try {
@@ -34865,6 +34945,7 @@ var PermissionsController = class {
34865
34945
  *
34866
34946
  * @param permissionId - The permission ID to query
34867
34947
  * @returns Promise resolving to permission info
34948
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
34868
34949
  */
34869
34950
  async getPermissionInfo(permissionId) {
34870
34951
  try {
@@ -34912,7 +34993,12 @@ var PermissionsController = class {
34912
34993
  * Trusts a server for data processing.
34913
34994
  *
34914
34995
  * @param params - Parameters for trusting the server
34996
+ * @param params.serverId - The server's Ethereum address
34997
+ * @param params.serverUrl - The server's URL endpoint
34915
34998
  * @returns Promise resolving to transaction hash
34999
+ * @throws {UserRejectedRequestError} When user rejects the transaction
35000
+ * @throws {BlockchainError} When chain ID is unavailable or transaction fails
35001
+ * @throws {Error} When wallet account is not available
34916
35002
  * @example
34917
35003
  * ```typescript
34918
35004
  * // Trust a server by providing its ID and URL
@@ -34959,6 +35045,12 @@ var PermissionsController = class {
34959
35045
  *
34960
35046
  * @param params - Parameters for trusting the server
34961
35047
  * @returns Promise resolving to transaction hash
35048
+ * @throws {BlockchainError} When chain ID is not available
35049
+ * @throws {NonceError} When retrieving user nonce fails
35050
+ * @throws {SignatureError} When user rejects the signature request
35051
+ * @throws {RelayerError} When gasless submission fails
35052
+ * @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
35053
+ * @throws {BlockchainError} When trust operation fails for any other reason
34962
35054
  */
34963
35055
  async trustServerWithSignature(params) {
34964
35056
  try {
@@ -35033,7 +35125,12 @@ var PermissionsController = class {
35033
35125
  * Untrusts a server.
35034
35126
  *
35035
35127
  * @param params - Parameters for untrusting the server
35128
+ * @param params.serverId - The server's Ethereum address to untrust
35036
35129
  * @returns Promise resolving to transaction hash
35130
+ * @throws {Error} When wallet account is not available
35131
+ * @throws {NonceError} When retrieving user nonce fails
35132
+ * @throws {UserRejectedRequestError} When user rejects the transaction
35133
+ * @throws {BlockchainError} When untrust transaction fails
35037
35134
  */
35038
35135
  async untrustServer(params) {
35039
35136
  const nonce = await this.getUserNonce();
@@ -35047,7 +35144,13 @@ var PermissionsController = class {
35047
35144
  * Untrusts a server using a signature (gasless transaction).
35048
35145
  *
35049
35146
  * @param params - Parameters for untrusting the server
35147
+ * @param params.serverId - The server's Ethereum address to untrust
35050
35148
  * @returns Promise resolving to transaction hash
35149
+ * @throws {Error} When wallet account is not available
35150
+ * @throws {NonceError} When retrieving user nonce fails
35151
+ * @throws {SignatureError} When user rejects the signature request
35152
+ * @throws {RelayerError} When gasless submission fails
35153
+ * @throws {BlockchainError} When untrust transaction fails
35051
35154
  */
35052
35155
  async untrustServerWithSignature(params) {
35053
35156
  try {
@@ -35089,6 +35192,7 @@ var PermissionsController = class {
35089
35192
  *
35090
35193
  * @param userAddress - Optional user address (defaults to current user)
35091
35194
  * @returns Promise resolving to array of trusted server addresses
35195
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
35092
35196
  */
35093
35197
  async getTrustedServers(userAddress) {
35094
35198
  try {
@@ -35118,6 +35222,7 @@ var PermissionsController = class {
35118
35222
  *
35119
35223
  * @param serverId - Server address
35120
35224
  * @returns Promise resolving to server information
35225
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
35121
35226
  */
35122
35227
  async getServerInfo(serverId) {
35123
35228
  try {
@@ -35146,6 +35251,7 @@ var PermissionsController = class {
35146
35251
  *
35147
35252
  * @param userAddress - Optional user address (defaults to current user)
35148
35253
  * @returns Promise resolving to the number of trusted servers
35254
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
35149
35255
  */
35150
35256
  async getTrustedServersCount(userAddress) {
35151
35257
  try {
@@ -35175,6 +35281,7 @@ var PermissionsController = class {
35175
35281
  *
35176
35282
  * @param options - Query options including pagination parameters
35177
35283
  * @returns Promise resolving to paginated trusted servers
35284
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
35178
35285
  */
35179
35286
  async getTrustedServersPaginated(options = {}) {
35180
35287
  try {
@@ -35234,6 +35341,7 @@ var PermissionsController = class {
35234
35341
  *
35235
35342
  * @param options - Query options
35236
35343
  * @returns Promise resolving to array of trusted server info
35344
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
35237
35345
  */
35238
35346
  async getTrustedServersWithInfo(options = {}) {
35239
35347
  try {
@@ -35271,6 +35379,7 @@ var PermissionsController = class {
35271
35379
  *
35272
35380
  * @param serverIds - Array of server IDs to query
35273
35381
  * @returns Promise resolving to batch result with successes and failures
35382
+ * @throws {BlockchainError} When reading from contract fails or chain is unavailable
35274
35383
  */
35275
35384
  async getServerInfoBatch(serverIds) {
35276
35385
  if (serverIds.length === 0) {
@@ -35764,9 +35873,14 @@ var DataController = class {
35764
35873
  * @param file - The user file to decrypt (typically from getUserFiles)
35765
35874
  * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
35766
35875
  * @returns Promise resolving to the decrypted file content as a Blob
35767
- * @throws {Error} When the wallet is not connected
35768
- * @throws {Error} When fetching the encrypted content fails
35769
- * @throws {Error} When decryption fails (wrong key or corrupted data)
35876
+ * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
35877
+ * @throws {Error} "Network error: Cannot access the file URL" - When file URL is inaccessible (CORS, server down)
35878
+ * @throws {Error} "File not found: The encrypted file is no longer available" - When file returns 404
35879
+ * @throws {Error} "Access denied" - When file returns 403 (no permission)
35880
+ * @throws {Error} "File is empty or could not be retrieved" - When file has no content
35881
+ * @throws {Error} "Invalid file format: This file doesn't appear to be encrypted with the Vana protocol" - When file is not properly encrypted
35882
+ * @throws {Error} "Wrong encryption key" - When decryption fails due to incorrect key/seed
35883
+ * @throws {Error} "Failed to decrypt file: {error}" - General decryption failures
35770
35884
  * @example
35771
35885
  * ```typescript
35772
35886
  * // Basic file decryption
@@ -35886,11 +36000,20 @@ var DataController = class {
35886
36000
  * This method queries the Vana subgraph to find files directly owned by the user.
35887
36001
  * It efficiently handles large datasets by using the File entity's owner field
35888
36002
  * and returns complete file metadata without additional contract calls.
36003
+ *
36004
+ * **Deduplication Behavior:**
36005
+ * The method automatically deduplicates files by ID, keeping only the latest version
36006
+ * (highest timestamp) when duplicate file IDs are found. This handles cases where
36007
+ * the subgraph may contain multiple entries for the same file due to re-indexing
36008
+ * or blockchain reorganizations.
35889
36009
  * @param params - The query parameters object
35890
36010
  * @param params.owner - The wallet address of the file owner to query
35891
36011
  * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
35892
- * @returns A Promise that resolves to an array of UserFile objects with metadata
35893
- * @throws {Error} When the subgraph is unavailable or returns invalid data
36012
+ * @returns A Promise that resolves to an array of UserFile objects with metadata, sorted by latest timestamp first
36013
+ * @throws {Error} When subgraphUrl is not provided and not configured - "subgraphUrl is required"
36014
+ * @throws {Error} When subgraph request fails - "Subgraph request failed: {status} {statusText}"
36015
+ * @throws {Error} When subgraph returns errors - "Subgraph errors: {error messages}"
36016
+ * @throws {Error} When JSON parsing fails - "Failed to fetch user files from subgraph: {error}"
35894
36017
  * @example
35895
36018
  * ```typescript
35896
36019
  * // Query files for a specific user
@@ -36393,6 +36516,9 @@ var DataController = class {
36393
36516
  *
36394
36517
  * @param fileId - The file ID to look up
36395
36518
  * @returns Promise resolving to UserFile object
36519
+ * @throws {Error} "Chain ID not available" - When wallet chain is not configured
36520
+ * @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
36521
+ * @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
36396
36522
  * @example
36397
36523
  * ```typescript
36398
36524
  * try {
@@ -36462,7 +36588,21 @@ var DataController = class {
36462
36588
  /**
36463
36589
  * Uploads an encrypted file to storage and registers it on the blockchain.
36464
36590
  *
36465
- * @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption
36591
+ * @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption
36592
+ *
36593
+ * Migration guide:
36594
+ * ```typescript
36595
+ * // Old way (deprecated):
36596
+ * const encrypted = await encryptBlob(data, key);
36597
+ * const result = await vana.data.uploadEncryptedFile(encrypted, filename);
36598
+ *
36599
+ * // New way:
36600
+ * const result = await vana.data.upload({
36601
+ * content: data,
36602
+ * filename: filename,
36603
+ * encrypt: true // Handles encryption automatically
36604
+ * });
36605
+ * ```
36466
36606
  * @param encryptedFile - The encrypted file blob to upload
36467
36607
  * @param filename - Optional filename for the upload
36468
36608
  * @param providerName - Optional storage provider to use
@@ -36550,7 +36690,22 @@ var DataController = class {
36550
36690
  /**
36551
36691
  * Uploads an encrypted file to storage and registers it on the blockchain with a schema.
36552
36692
  *
36553
- * @deprecated Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
36693
+ * @deprecated Since v2.0.0 - Use vana.data.upload() instead for the high-level API with automatic encryption and schema validation
36694
+ *
36695
+ * Migration guide:
36696
+ * ```typescript
36697
+ * // Old way (deprecated):
36698
+ * const encrypted = await encryptBlob(data, key);
36699
+ * const result = await vana.data.uploadEncryptedFileWithSchema(encrypted, schemaId, filename);
36700
+ *
36701
+ * // New way:
36702
+ * const result = await vana.data.upload({
36703
+ * content: data,
36704
+ * filename: filename,
36705
+ * schemaId: schemaId, // Automatic validation
36706
+ * encrypt: true
36707
+ * });
36708
+ * ```
36554
36709
  * @param encryptedFile - The encrypted file blob to upload
36555
36710
  * @param schemaId - The schema ID to associate with the file
36556
36711
  * @param filename - Optional filename for the upload
@@ -36826,7 +36981,24 @@ var DataController = class {
36826
36981
  /**
36827
36982
  * Adds a new schema to the DataRefinerRegistry.
36828
36983
  *
36829
- * @deprecated Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
36984
+ * @deprecated Since v2.0.0 - Use vana.schemas.create() instead for the high-level API with automatic IPFS upload
36985
+ *
36986
+ * Migration guide:
36987
+ * ```typescript
36988
+ * // Old way (deprecated):
36989
+ * const result = await vana.data.addSchema({
36990
+ * name: "UserProfile",
36991
+ * type: "JSON",
36992
+ * definitionUrl: "ipfs://..."
36993
+ * });
36994
+ *
36995
+ * // New way:
36996
+ * const result = await vana.schemas.create({
36997
+ * name: "UserProfile",
36998
+ * type: "JSON",
36999
+ * definition: schemaObject // Automatically uploads to IPFS
37000
+ * });
37001
+ * ```
36830
37002
  * @param params - Schema parameters including name, type, and definition URL
36831
37003
  * @returns Promise resolving to the new schema ID and transaction hash
36832
37004
  */
@@ -36885,7 +37057,16 @@ var DataController = class {
36885
37057
  /**
36886
37058
  * Retrieves a schema by its ID.
36887
37059
  *
36888
- * @deprecated Use vana.schemas.get() instead
37060
+ * @deprecated Since v2.0.0 - Use vana.schemas.get() instead
37061
+ *
37062
+ * Migration guide:
37063
+ * ```typescript
37064
+ * // Old way (deprecated):
37065
+ * const schema = await vana.data.getSchema(schemaId);
37066
+ *
37067
+ * // New way:
37068
+ * const schema = await vana.schemas.get(schemaId);
37069
+ * ```
36889
37070
  * @param schemaId - The schema ID to retrieve
36890
37071
  * @returns Promise resolving to the schema information
36891
37072
  */
@@ -36931,7 +37112,16 @@ var DataController = class {
36931
37112
  /**
36932
37113
  * Gets the total number of schemas in the registry.
36933
37114
  *
36934
- * @deprecated Use vana.schemas.count() instead
37115
+ * @deprecated Since v2.0.0 - Use vana.schemas.count() instead
37116
+ *
37117
+ * Migration guide:
37118
+ * ```typescript
37119
+ * // Old way (deprecated):
37120
+ * const count = await vana.data.getSchemasCount();
37121
+ *
37122
+ * // New way:
37123
+ * const count = await vana.schemas.count();
37124
+ * ```
36935
37125
  * @returns Promise resolving to the total schema count
36936
37126
  */
36937
37127
  async getSchemasCount() {
@@ -37253,8 +37443,11 @@ var DataController = class {
37253
37443
  *
37254
37444
  * @param fileId - The ID of the file to add permissions for
37255
37445
  * @param account - The address of the account to grant permission to
37256
- * @param publicKey - The public key to encrypt the user's encryption key with
37446
+ * @param publicKey - The public key to encrypt the user's encryption key with (hex string with 0x prefix)
37257
37447
  * @returns Promise resolving to permission data from PermissionGranted event
37448
+ * @throws {Error} "No addresses available in wallet client" - When wallet is not connected
37449
+ * @throws {Error} "Chain ID not available" - When wallet chain is not configured
37450
+ * @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
37258
37451
  * @example
37259
37452
  * ```typescript
37260
37453
  * const result = await vana.data.addPermissionToFile(fileId, account, publicKey);
@@ -37407,7 +37600,9 @@ var DataController = class {
37407
37600
  *
37408
37601
  * @param url - The URL to fetch content from
37409
37602
  * @returns Promise resolving to the fetched content as a Blob
37410
- * @throws {Error} When the fetch fails or returns a non-ok response
37603
+ * @throws {Error} "HTTP error! status: {status} {statusText}" - When server returns error status
37604
+ * @throws {Error} "Empty response" - When server returns no content
37605
+ * @throws {Error} "Network error: Failed to fetch from {url}" - When network request fails
37411
37606
  *
37412
37607
  * @example
37413
37608
  * ```typescript
@@ -37459,7 +37654,10 @@ var DataController = class {
37459
37654
  * @param options - Optional configuration
37460
37655
  * @param options.gateways - Array of IPFS gateway URLs to try (must end with /)
37461
37656
  * @returns Promise resolving to the fetched content as a Blob
37462
- * @throws {Error} When all gateways fail to fetch the content
37657
+ * @throws {Error} "Invalid IPFS URL format" - When URL is not ipfs:// or valid CID
37658
+ * @throws {Error} "Empty response" - When gateway returns no content
37659
+ * @throws {Error} "HTTP error! status: {status}" - When gateway returns error status
37660
+ * @throws {Error} "Failed to fetch IPFS content {cid} from all gateways" - When all gateways fail
37463
37661
  *
37464
37662
  * @example
37465
37663
  * ```typescript
@@ -38021,11 +38219,11 @@ var ServerController = class {
38021
38219
  * const identity = await vana.server.getIdentity({
38022
38220
  * userAddress: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
38023
38221
  * });
38024
- *
38222
+ *
38025
38223
  * console.log(`Server: ${identity.name}`);
38026
38224
  * console.log(`Address: ${identity.address}`);
38027
38225
  * console.log(`Public Key: ${identity.public_key}`);
38028
- *
38226
+ *
38029
38227
  * // Use the public key for encrypting data to share with this server
38030
38228
  * const encryptedData = await encryptWithWalletPublicKey(
38031
38229
  * userData,
@@ -38189,7 +38387,7 @@ var ServerController = class {
38189
38387
  * @remarks
38190
38388
  * This method attempts to cancel an operation that is currently processing
38191
38389
  * on the personal server. The operation must be in a cancellable state
38192
- * (typically `starting` or `processing`). Not all operations support
38390
+ * (typically `starting` or `processing`). Not all operations support
38193
38391
  * cancellation, and cancellation may not be immediate. The server will
38194
38392
  * attempt to stop the operation and update its status to `canceled`.
38195
38393
  *
@@ -38216,7 +38414,7 @@ var ServerController = class {
38216
38414
  * try {
38217
38415
  * await vana.server.cancelOperation(operation.id);
38218
38416
  * console.log("Cancellation requested");
38219
- *
38417
+ *
38220
38418
  * // Verify cancellation
38221
38419
  * const status = await vana.server.getOperation(operation.id);
38222
38420
  * if (status.status === "canceled") {
@@ -38640,6 +38838,7 @@ var ProtocolController = class {
38640
38838
  * Gets the current chain ID from the wallet client.
38641
38839
  *
38642
38840
  * @returns The chain ID
38841
+ * @throws {Error} When chain ID is not available from wallet client
38643
38842
  */
38644
38843
  getChainId() {
38645
38844
  const chainId = this.context.walletClient.chain?.id;
@@ -38652,6 +38851,7 @@ var ProtocolController = class {
38652
38851
  * Gets the current chain name from the wallet client.
38653
38852
  *
38654
38853
  * @returns The chain name
38854
+ * @throws {Error} When chain name is not available from wallet client
38655
38855
  */
38656
38856
  getChainName() {
38657
38857
  const chainName = this.context.walletClient.chain?.name;