@opendatalabs/vana-sdk 0.1.0-alpha.793d5ba → 0.1.0-alpha.8eb4e46

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.
@@ -158,37 +158,56 @@ declare class StorageError extends Error {
158
158
  }
159
159
 
160
160
  /**
161
- * Represents a granted permission from the DataPermissions contract.
161
+ * Represents on-chain permission grant data without expensive off-chain resolution.
162
162
  *
163
- * This interface describes the structure of permissions that have been granted
164
- * on-chain, including all the metadata and parameters associated with the permission.
165
- * Used when querying user permissions or checking access rights.
163
+ * This interface contains only the fast, on-chain data that can be retrieved
164
+ * efficiently from the subgraph without making individual IPFS or contract calls.
165
+ * Use this for fast permission listing in UIs, then call `retrieveGrantFile()`
166
+ * on specific grants when detailed data is needed.
166
167
  *
167
168
  * @category Permissions
169
+ * @example
170
+ * ```typescript
171
+ * // Fast: Get all on-chain permission data
172
+ * const grants = await vana.permissions.getUserPermissionGrantsOnChain();
173
+ *
174
+ * // Lazy: Resolve detailed data for specific permission when needed
175
+ * const grantFile = await retrieveGrantFile(grants[0].grantUrl);
176
+ * console.log('Operation:', grantFile.operation);
177
+ * ```
168
178
  */
169
- interface GrantedPermission {
179
+ interface OnChainPermissionGrant {
170
180
  /** Unique identifier for the permission */
171
181
  id: bigint;
172
- /** Array of file IDs included in the permission */
173
- files: number[];
174
- /** Type of operation permitted (e.g., "llm_inference") */
175
- operation?: string;
176
- /** The grant URL containing all permission details */
177
- grant: string;
178
- /** The parameters associated with the permission */
179
- parameters?: Record<string, unknown>;
180
- /** Optional nonce used when granting the permission */
181
- nonce?: number;
182
- /** Optional block number when permission was granted */
183
- grantedAt?: number;
182
+ /** The grant URL containing detailed permission parameters (IPFS link) */
183
+ grantUrl: string;
184
+ /** Cryptographic signature that authorized this permission */
185
+ grantSignature: string;
186
+ /** Hash of the grant file content for integrity verification */
187
+ grantHash: string;
188
+ /** Nonce used when granting the permission */
189
+ nonce: bigint;
190
+ /** Block number when permission was granted */
191
+ addedAtBlock: bigint;
192
+ /** Timestamp when permission was added */
193
+ addedAtTimestamp: bigint;
194
+ /** Transaction hash of the grant transaction */
195
+ transactionHash: string;
184
196
  /** Address that granted the permission */
185
197
  grantor: Address;
186
- /** Address that received the permission */
187
- grantee: Address;
188
- /** Whether the permission is still active */
198
+ /** Whether the permission is still active (not revoked) */
189
199
  active: boolean;
190
- /** Expiration timestamp if applicable */
191
- expiresAt?: number;
200
+ }
201
+ /**
202
+ * Options for retrieving user permissions
203
+ *
204
+ * @category Permissions
205
+ */
206
+ interface GetUserPermissionsOptions {
207
+ /** Maximum number of permissions to retrieve */
208
+ limit?: number;
209
+ /** Custom subgraph URL to use for querying */
210
+ subgraphUrl?: string;
192
211
  }
193
212
  /**
194
213
  * Parameters for granting data access permission to an application.
@@ -201,7 +220,7 @@ interface GrantedPermission {
201
220
  * @example
202
221
  * ```typescript
203
222
  * const params: GrantPermissionParams = {
204
- * to: '0x1234...', // Application address
223
+ * grantee: '0x1234...', // Application address
205
224
  * operation: 'llm_inference',
206
225
  * files: [1, 2, 3], // File IDs to grant access to
207
226
  * parameters: {
@@ -214,7 +233,7 @@ interface GrantedPermission {
214
233
  */
215
234
  interface GrantPermissionParams$1 {
216
235
  /** The on-chain identity of the application */
217
- to: Address;
236
+ grantee: Address;
218
237
  /** The class of computation, e.g., "llm_inference" */
219
238
  operation: string;
220
239
  /** Array of file IDs to grant permission for */
@@ -493,6 +512,41 @@ interface QueryPermissionsParams {
493
512
  /** Offset for pagination */
494
513
  offset?: number;
495
514
  }
515
+ /**
516
+ * Granted permission details
517
+ *
518
+ * @category Permissions
519
+ */
520
+ interface GrantedPermission {
521
+ /** Unique identifier for the permission */
522
+ id: bigint;
523
+ /** Array of file IDs that the permission applies to */
524
+ files: number[];
525
+ /** The type of operation being granted permission for */
526
+ operation: string;
527
+ /** Grant file reference (IPFS hash or URL) */
528
+ grant: string;
529
+ /** Address of the application granted permission */
530
+ grantee: Address;
531
+ /** Address of the user who granted permission */
532
+ grantor: Address;
533
+ /** Custom parameters for the operation */
534
+ parameters: Record<string, unknown>;
535
+ /** Whether the permission is still active */
536
+ active: boolean;
537
+ /** Data status for the permission */
538
+ dataStatus?: string;
539
+ /** Nonce used for the permission */
540
+ nonce?: number;
541
+ /** Timestamp when permission was granted */
542
+ grantedAt?: number;
543
+ /** Optional expiration timestamp */
544
+ expiresAt?: number;
545
+ /** Transaction hash of the grant transaction */
546
+ transactionHash?: string;
547
+ /** Block number when permission was granted */
548
+ blockNumber?: bigint;
549
+ }
496
550
  /**
497
551
  * Permission query result
498
552
  *
@@ -715,6 +769,16 @@ interface ServerTrustStatus {
715
769
  trustIndex?: number;
716
770
  }
717
771
 
772
+ /**
773
+ * Marker interface to indicate that a Vana instance has storage configured.
774
+ * Used for compile-time type safety to ensure storage-dependent methods
775
+ * are only called on properly configured instances.
776
+ *
777
+ * @category Configuration
778
+ */
779
+ interface StorageRequiredMarker {
780
+ readonly __storageRequired: true;
781
+ }
718
782
  /**
719
783
  * Configuration for storage providers used by the SDK.
720
784
  *
@@ -804,6 +868,7 @@ interface RelayerCallbacks {
804
868
  /**
805
869
  * Submit a file addition for relay
806
870
  *
871
+ * @deprecated Use submitFileAdditionComplete for full support.
807
872
  * @param url - The file URL to register
808
873
  * @param userAddress - The user's address
809
874
  * @returns Promise resolving to object with fileId and transactionHash
@@ -815,6 +880,7 @@ interface RelayerCallbacks {
815
880
  /**
816
881
  * Submit a file addition with permissions for relay
817
882
  *
883
+ * @deprecated Use submitFileAdditionComplete for full support.
818
884
  * @param url - The file URL to register
819
885
  * @param userAddress - The user's address
820
886
  * @param permissions - Array of encrypted permissions
@@ -827,6 +893,33 @@ interface RelayerCallbacks {
827
893
  fileId: number;
828
894
  transactionHash: Hash;
829
895
  }>;
896
+ /**
897
+ * Submit a comprehensive file addition with optional schema and permissions for relay
898
+ *
899
+ * This is the preferred callback that supports all file addition scenarios.
900
+ * It can handle files with schemas, permissions, or both.
901
+ *
902
+ * @param params - Complete parameters for file addition
903
+ * @param params.url - The file URL to register
904
+ * @param params.userAddress - The user's address (defaults to connected wallet if not specified)
905
+ * @param params.permissions - Array of encrypted permissions (empty array if none)
906
+ * @param params.schemaId - Schema ID for validation (0 if none)
907
+ * @param params.ownerAddress - Optional owner address (defaults to userAddress if not specified)
908
+ * @returns Promise resolving to object with fileId and transactionHash
909
+ */
910
+ submitFileAdditionComplete?: (params: {
911
+ url: string;
912
+ userAddress: Address;
913
+ permissions: Array<{
914
+ account: Address;
915
+ key: string;
916
+ }>;
917
+ schemaId: number;
918
+ ownerAddress?: Address;
919
+ }) => Promise<{
920
+ fileId: number;
921
+ transactionHash: Hash;
922
+ }>;
830
923
  /**
831
924
  * Store a grant file for relay (e.g., upload to IPFS)
832
925
  *
@@ -836,7 +929,122 @@ interface RelayerCallbacks {
836
929
  storeGrantFile?: (grantData: GrantFile) => Promise<string>;
837
930
  }
838
931
  /**
839
- * Base configuration interface
932
+ * Storage callback functions for flexible storage operations.
933
+ *
934
+ * Instead of hardcoding storage behavior (HTTP endpoints, etc.), users can provide
935
+ * custom callback functions to handle storage operations in any way they choose.
936
+ * This pattern matches the relayer callbacks approach, providing maximum flexibility.
937
+ *
938
+ * @category Configuration
939
+ * @example
940
+ * ```typescript
941
+ * const storageCallbacks: StorageCallbacks = {
942
+ * async upload(blob, filename, metadata) {
943
+ * // Custom implementation - could be HTTP, S3, local filesystem, etc.
944
+ * const formData = new FormData();
945
+ * formData.append('file', blob, filename);
946
+ * const response = await fetch('/api/storage/upload', {
947
+ * method: 'POST',
948
+ * body: formData
949
+ * });
950
+ * const data = await response.json();
951
+ * return {
952
+ * url: data.url,
953
+ * size: blob.size,
954
+ * contentType: blob.type,
955
+ * metadata: data.metadata
956
+ * };
957
+ * },
958
+ *
959
+ * async download(identifier) {
960
+ * const response = await fetch(`/api/storage/download/${identifier}`);
961
+ * return response.blob();
962
+ * }
963
+ * };
964
+ * ```
965
+ */
966
+ interface StorageCallbacks {
967
+ /**
968
+ * Upload a blob to storage
969
+ *
970
+ * @param blob - The data to upload
971
+ * @param filename - Optional filename hint
972
+ * @param metadata - Optional metadata for the upload
973
+ * @returns Upload result with identifier and metadata
974
+ */
975
+ upload: (blob: Blob, filename?: string, metadata?: Record<string, unknown>) => Promise<StorageUploadResult>;
976
+ /**
977
+ * Download data from storage
978
+ *
979
+ * @param identifier - The storage identifier (could be URL, hash, path, or any unique ID)
980
+ * @param options - Optional download options
981
+ * @returns The downloaded data as a Blob
982
+ */
983
+ download: (identifier: string, options?: StorageDownloadOptions) => Promise<Blob>;
984
+ /**
985
+ * List stored items (optional)
986
+ *
987
+ * @param prefix - Optional prefix to filter results
988
+ * @param options - Optional listing options
989
+ * @returns Array of storage items with metadata
990
+ */
991
+ list?: (prefix?: string, options?: StorageListOptions) => Promise<StorageListResult>;
992
+ /**
993
+ * Delete a stored item (optional)
994
+ *
995
+ * @param identifier - The storage identifier to delete
996
+ * @returns Promise that resolves to true if deletion succeeded
997
+ */
998
+ delete?: (identifier: string) => Promise<boolean>;
999
+ /**
1000
+ * Extract identifier from a URL or return as-is (optional)
1001
+ * Used for backward compatibility with URL-based systems
1002
+ *
1003
+ * @param url - The URL to extract from
1004
+ * @returns The extracted identifier
1005
+ */
1006
+ extractIdentifier?: (url: string) => string;
1007
+ }
1008
+ /**
1009
+ * Options for storage download operations
1010
+ *
1011
+ * @category Configuration
1012
+ */
1013
+ interface StorageDownloadOptions {
1014
+ /** Optional HTTP headers */
1015
+ headers?: Record<string, string>;
1016
+ /** Optional abort signal for cancellation */
1017
+ signal?: AbortSignal;
1018
+ /** Optional byte range for partial downloads */
1019
+ range?: {
1020
+ start?: number;
1021
+ end?: number;
1022
+ };
1023
+ }
1024
+ /**
1025
+ * Result from storage list operations
1026
+ *
1027
+ * @category Configuration
1028
+ */
1029
+ interface StorageListResult {
1030
+ /** Array of storage items */
1031
+ items: Array<{
1032
+ /** Item identifier */
1033
+ identifier: string;
1034
+ /** Item size in bytes */
1035
+ size?: number;
1036
+ /** Last modified timestamp */
1037
+ lastModified?: Date;
1038
+ /** Item metadata */
1039
+ metadata?: Record<string, unknown>;
1040
+ }>;
1041
+ /** Continuation token for pagination */
1042
+ continuationToken?: string;
1043
+ /** Whether more results are available */
1044
+ hasMore?: boolean;
1045
+ }
1046
+ /**
1047
+ * Base configuration interface without storage requirements
840
1048
  *
841
1049
  * @category Configuration
842
1050
  */
@@ -854,6 +1062,42 @@ interface BaseConfig {
854
1062
  * Can be overridden per method call if needed.
855
1063
  */
856
1064
  subgraphUrl?: string;
1065
+ /**
1066
+ * Optional default IPFS gateways to use for fetching files.
1067
+ * These gateways will be used by default in fetchFromIPFS unless overridden per-call.
1068
+ * If not provided, the SDK will use public gateways.
1069
+ *
1070
+ * @example ['https://gateway.pinata.cloud', 'https://ipfs.io']
1071
+ */
1072
+ ipfsGateways?: string[];
1073
+ }
1074
+ /**
1075
+ * Base configuration interface that requires storage for storage-dependent operations
1076
+ *
1077
+ * @category Configuration
1078
+ */
1079
+ interface BaseConfigWithStorage {
1080
+ /**
1081
+ * Optional relayer callback functions for handling gasless transactions.
1082
+ * Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.
1083
+ */
1084
+ relayerCallbacks?: RelayerCallbacks;
1085
+ /** Required storage providers configuration for file upload/download */
1086
+ storage: StorageConfig;
1087
+ /**
1088
+ * Optional subgraph URL for querying user files and permissions.
1089
+ * If not provided, defaults to the built-in subgraph URL for the current chain.
1090
+ * Can be overridden per method call if needed.
1091
+ */
1092
+ subgraphUrl?: string;
1093
+ /**
1094
+ * Optional default IPFS gateways to use for fetching files.
1095
+ * These gateways will be used by default in fetchFromIPFS unless overridden per-call.
1096
+ * If not provided, the SDK will use public gateways.
1097
+ *
1098
+ * @example ['https://gateway.pinata.cloud', 'https://ipfs.io']
1099
+ */
1100
+ ipfsGateways?: string[];
857
1101
  }
858
1102
  /**
859
1103
  * Configuration with wallet client
@@ -866,6 +1110,17 @@ interface WalletConfig extends BaseConfig {
866
1110
  chain: VanaChain;
867
1111
  };
868
1112
  }
1113
+ /**
1114
+ * Configuration with wallet client that requires storage
1115
+ *
1116
+ * @category Configuration
1117
+ */
1118
+ interface WalletConfigWithStorage extends BaseConfigWithStorage {
1119
+ /** The viem WalletClient instance used for signing transactions */
1120
+ walletClient: WalletClient & {
1121
+ chain: VanaChain;
1122
+ };
1123
+ }
869
1124
  /**
870
1125
  * Configuration with chain and account details
871
1126
  *
@@ -879,6 +1134,19 @@ interface ChainConfig extends BaseConfig {
879
1134
  /** Optional account for signing transactions */
880
1135
  account?: Account;
881
1136
  }
1137
+ /**
1138
+ * Configuration with chain and account details that requires storage
1139
+ *
1140
+ * @category Configuration
1141
+ */
1142
+ interface ChainConfigWithStorage extends BaseConfigWithStorage {
1143
+ /** The chain ID for Vana network */
1144
+ chainId: VanaChainId;
1145
+ /** RPC URL for the chain (optional, will use default for the chain if not provided) */
1146
+ rpcUrl?: string;
1147
+ /** Optional account for signing transactions */
1148
+ account?: Account;
1149
+ }
882
1150
  /**
883
1151
  * Main configuration interface for initializing the Vana SDK.
884
1152
  *
@@ -918,6 +1186,32 @@ interface ChainConfig extends BaseConfig {
918
1186
  * ```
919
1187
  */
920
1188
  type VanaConfig = WalletConfig | ChainConfig;
1189
+ /**
1190
+ * Configuration interface for Vana SDK that requires storage providers.
1191
+ *
1192
+ * Use this type when you need to ensure storage is configured for operations
1193
+ * like file uploads, permission grants without pre-stored URLs, or schema creation.
1194
+ *
1195
+ * @category Configuration
1196
+ * @example
1197
+ * ```typescript
1198
+ * // Configuration that guarantees storage availability
1199
+ * const config: VanaConfigWithStorage = {
1200
+ * walletClient: createWalletClient({
1201
+ * account: privateKeyToAccount('0x...'),
1202
+ * chain: moksha,
1203
+ * transport: http()
1204
+ * }),
1205
+ * storage: {
1206
+ * providers: {
1207
+ * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' })
1208
+ * },
1209
+ * defaultProvider: 'ipfs'
1210
+ * }
1211
+ * };
1212
+ * ```
1213
+ */
1214
+ type VanaConfigWithStorage = WalletConfigWithStorage | ChainConfigWithStorage;
921
1215
  /**
922
1216
  * Runtime configuration information
923
1217
  *
@@ -966,6 +1260,22 @@ declare function isWalletConfig(config: VanaConfig): config is WalletConfig;
966
1260
  * ```
967
1261
  */
968
1262
  declare function isChainConfig(config: VanaConfig): config is ChainConfig;
1263
+ /**
1264
+ * Validates whether a configuration has required storage providers.
1265
+ *
1266
+ * @param config - The configuration object to check
1267
+ * @returns True if the config has storage providers configured
1268
+ * @example
1269
+ * ```typescript
1270
+ * if (hasStorageConfig(config)) {
1271
+ * // Safe to use storage-dependent operations
1272
+ * await vana.data.uploadFile(file);
1273
+ * } else {
1274
+ * console.log('Storage not configured - some operations may fail');
1275
+ * }
1276
+ * ```
1277
+ */
1278
+ declare function hasStorageConfig(config: VanaConfig): config is VanaConfigWithStorage;
969
1279
  /**
970
1280
  * Configuration validation options
971
1281
  *
@@ -1117,6 +1427,10 @@ interface FileMetadata {
1117
1427
  * @remarks
1118
1428
  * This is the primary interface for uploading user data through the simplified `vana.data.upload()` method.
1119
1429
  * It handles the complete workflow including encryption, storage, and blockchain registration.
1430
+ *
1431
+ * When using permissions with encryption enabled (default), you must provide the public key
1432
+ * for each permission recipient.
1433
+ *
1120
1434
  * @example
1121
1435
  * ```typescript
1122
1436
  * // Basic file upload
@@ -1132,14 +1446,27 @@ interface FileMetadata {
1132
1446
  * schemaId: 1
1133
1447
  * });
1134
1448
  *
1135
- * // Upload with permissions for an app
1449
+ * // Upload with permissions for an app (encrypted - requires publicKey)
1136
1450
  * const result = await vana.data.upload({
1137
1451
  * content: "Data for AI analysis",
1138
1452
  * filename: "analysis.txt",
1139
1453
  * permissions: [{
1140
- * to: "0x1234...",
1454
+ * grantee: "0x1234...",
1141
1455
  * operation: "llm_inference",
1142
- * parameters: { model: "gpt-4" }
1456
+ * parameters: { model: "gpt-4" },
1457
+ * publicKey: "0x04..." // Required when encrypt is true (default)
1458
+ * }]
1459
+ * });
1460
+ *
1461
+ * // Upload without encryption (publicKey optional)
1462
+ * const result = await vana.data.upload({
1463
+ * content: "Public data",
1464
+ * filename: "public.txt",
1465
+ * encrypt: false,
1466
+ * permissions: [{
1467
+ * grantee: "0x1234...",
1468
+ * operation: "read",
1469
+ * parameters: {}
1143
1470
  * }]
1144
1471
  * });
1145
1472
  * ```
@@ -1158,6 +1485,32 @@ interface UploadParams {
1158
1485
  encrypt?: boolean;
1159
1486
  /** Optional storage provider name. */
1160
1487
  providerName?: string;
1488
+ /** Optional owner address (defaults to current wallet address). */
1489
+ owner?: Address;
1490
+ }
1491
+ /**
1492
+ * Upload parameters with encryption enabled (requires EncryptedPermissionParams).
1493
+ *
1494
+ * @remarks
1495
+ * This interface ensures type safety when using encrypted uploads with permissions.
1496
+ * @category Data Management
1497
+ */
1498
+ interface EncryptedUploadParams extends Omit<UploadParams, "permissions" | "encrypt"> {
1499
+ /** Permissions with required public keys for encrypted data sharing. */
1500
+ permissions?: EncryptedPermissionParams[];
1501
+ /** Encryption is enabled. */
1502
+ encrypt: true;
1503
+ }
1504
+ /**
1505
+ * Upload parameters with encryption disabled.
1506
+ *
1507
+ * @remarks
1508
+ * This interface is used when uploading unencrypted data.
1509
+ * @category Data Management
1510
+ */
1511
+ interface UnencryptedUploadParams extends Omit<UploadParams, "encrypt"> {
1512
+ /** Encryption is disabled. */
1513
+ encrypt: false;
1161
1514
  }
1162
1515
  /**
1163
1516
  * Permission parameters for granting access during file upload.
@@ -1168,7 +1521,7 @@ interface UploadParams {
1168
1521
  */
1169
1522
  interface PermissionParams {
1170
1523
  /** The address of the application to grant permission to. */
1171
- to: Address;
1524
+ grantee: Address;
1172
1525
  /** The operation type (e.g., "llm_inference"). */
1173
1526
  operation: string;
1174
1527
  /** Additional parameters for the permission. */
@@ -1177,6 +1530,20 @@ interface PermissionParams {
1177
1530
  nonce?: bigint;
1178
1531
  /** Optional expiration timestamp. */
1179
1532
  expiresAt?: number;
1533
+ /** Public key of the recipient to encrypt the data key for (required for upload with permissions). */
1534
+ publicKey?: string;
1535
+ }
1536
+ /**
1537
+ * Permission parameters with required public key for encrypted uploads.
1538
+ *
1539
+ * @remarks
1540
+ * This type extends PermissionParams and makes publicKey required, ensuring
1541
+ * compile-time safety when permissions are used with encryption.
1542
+ * @category Data Management
1543
+ */
1544
+ interface EncryptedPermissionParams extends PermissionParams {
1545
+ /** Public key of the recipient to encrypt the data key for. */
1546
+ publicKey: string;
1180
1547
  }
1181
1548
  /**
1182
1549
  * Result of the high-level upload operation.
@@ -2073,88 +2440,96 @@ declare class PinataStorage implements StorageProvider {
2073
2440
  private isValidCID;
2074
2441
  }
2075
2442
 
2076
- interface ServerProxyConfig {
2077
- /** Server endpoint for file uploads */
2078
- uploadUrl: string;
2079
- /** Server endpoint for file downloads */
2080
- downloadUrl: string;
2081
- }
2082
2443
  /**
2083
- * Delegates storage operations to your server endpoints
2444
+ * Storage provider that delegates all operations to user-provided callbacks.
2084
2445
  *
2085
- * @remarks
2086
- * This provider is completely agnostic about the actual storage backend used by
2087
- * your server. It simply proxies upload and download requests to your configured
2088
- * endpoints, allowing you to implement any storage strategy (IPFS, S3, local filesystem, etc.)
2089
- * on the server side while maintaining a consistent client interface.
2446
+ * This provider follows the same flexible pattern as relayer callbacks,
2447
+ * allowing users to implement storage operations in any way they choose
2448
+ * (HTTP, WebSocket, direct cloud APIs, local filesystem, etc.).
2090
2449
  *
2091
2450
  * @category Storage
2092
- *
2093
2451
  * @example
2094
2452
  * ```typescript
2095
- * const serverStorage = new ServerProxyStorage({
2096
- * uploadUrl: "/api/files/upload",
2097
- * downloadUrl: "/api/files/download"
2098
- * });
2099
- *
2100
- * // Upload file through your server
2101
- * const identifier = await serverStorage.upload(fileBlob, { name: "document.pdf" });
2453
+ * // HTTP-based implementation
2454
+ * const httpCallbacks: StorageCallbacks = {
2455
+ * async upload(blob, filename) {
2456
+ * const formData = new FormData();
2457
+ * formData.append('file', blob, filename);
2458
+ * const response = await fetch('/api/storage/upload', {
2459
+ * method: 'POST',
2460
+ * body: formData
2461
+ * });
2462
+ * const data = await response.json();
2463
+ * return {
2464
+ * url: data.url,
2465
+ * size: blob.size,
2466
+ * contentType: blob.type
2467
+ * };
2468
+ * },
2469
+ * async download(identifier) {
2470
+ * const response = await fetch(`/api/storage/download/${identifier}`);
2471
+ * return response.blob();
2472
+ * }
2473
+ * };
2102
2474
  *
2103
- * // Download file through your server
2104
- * const file = await serverStorage.download(identifier);
2475
+ * const storage = new CallbackStorage(httpCallbacks);
2476
+ *
2477
+ * // Direct S3 implementation
2478
+ * const s3Callbacks: StorageCallbacks = {
2479
+ * async upload(blob, filename) {
2480
+ * const url = await getPresignedUploadUrl(filename);
2481
+ * await fetch(url, { method: 'PUT', body: blob });
2482
+ * return {
2483
+ * url: `s3://my-bucket/${filename}`,
2484
+ * size: blob.size,
2485
+ * contentType: blob.type
2486
+ * };
2487
+ * },
2488
+ * async download(identifier) {
2489
+ * const url = await getPresignedDownloadUrl(identifier);
2490
+ * const response = await fetch(url);
2491
+ * return response.blob();
2492
+ * }
2493
+ * };
2105
2494
  * ```
2106
2495
  */
2107
- declare class ServerProxyStorage implements StorageProvider {
2108
- private config;
2109
- constructor(config: ServerProxyConfig);
2496
+ declare class CallbackStorage implements StorageProvider {
2497
+ private readonly callbacks;
2498
+ constructor(callbacks: StorageCallbacks);
2110
2499
  /**
2111
- * Uploads a file through your server endpoint
2112
- *
2113
- * @remarks
2114
- * This method sends the file to your configured upload endpoint via FormData.
2115
- * Your server is responsible for handling the actual storage implementation
2116
- * and must return a JSON response with `success: true` and an `identifier` field.
2500
+ * Upload a file using the provided callback
2117
2501
  *
2118
- * @param file - The file to upload
2119
- * @param filename - Optional custom filename
2120
- * @returns Promise that resolves to the server-provided identifier
2121
- * @throws {StorageError} When the upload fails or server returns an error
2122
- *
2123
- * @example
2124
- * ```typescript
2125
- * const identifier = await serverStorage.upload(fileBlob, { name: "report.pdf" });
2126
- * console.log("File uploaded with identifier:", identifier);
2127
- * ```
2502
+ * @param file - The blob to upload
2503
+ * @param filename - Optional filename for the upload
2504
+ * @returns The upload result with URL and metadata
2128
2505
  */
2129
2506
  upload(file: Blob, filename?: string): Promise<StorageUploadResult>;
2130
2507
  /**
2131
- * Downloads a file through your server endpoint
2508
+ * Download a file using the provided callback
2132
2509
  *
2133
- * @remarks
2134
- * This method sends the identifier to your configured download endpoint via POST request.
2135
- * Your server is responsible for retrieving the file from your storage backend
2136
- * and returning the file content as a blob response.
2510
+ * @param url - The URL or identifier to download
2511
+ * @returns The downloaded blob
2512
+ */
2513
+ download(url: string): Promise<Blob>;
2514
+ /**
2515
+ * List files using the provided callback (if available)
2137
2516
  *
2138
- * @param url - The server-provided URL or identifier from upload
2139
- * @returns Promise that resolves to the downloaded file content
2140
- * @throws {StorageError} When the download fails or file is not found
2517
+ * @param options - Optional list options including filters and pagination
2518
+ * @returns Array of storage files
2519
+ */
2520
+ list(options?: StorageListOptions): Promise<StorageFile[]>;
2521
+ /**
2522
+ * Delete a file using the provided callback (if available)
2141
2523
  *
2142
- * @example
2143
- * ```typescript
2144
- * const fileBlob = await serverStorage.download("file-123");
2145
- * const url = URL.createObjectURL(fileBlob);
2146
- * ```
2524
+ * @param url - The URL or identifier to delete
2525
+ * @returns True if deletion succeeded
2147
2526
  */
2148
- download(url: string): Promise<Blob>;
2149
- list(_options?: StorageListOptions): Promise<StorageFile[]>;
2150
- delete(_url: string): Promise<boolean>;
2527
+ delete(url: string): Promise<boolean>;
2151
2528
  /**
2152
- * Extract identifier from URL or return as-is
2529
+ * Get provider configuration
2153
2530
  *
2154
- * @param url - URL or identifier string
2155
- * @returns identifier string
2531
+ * @returns Provider configuration metadata
2156
2532
  */
2157
- private extractIdentifierFromUrl;
2158
2533
  getConfig(): StorageProviderConfig;
2159
2534
  }
2160
2535
 
@@ -2480,6 +2855,12 @@ interface ControllerContext$1 {
2480
2855
  subgraphUrl?: string;
2481
2856
  /** Adapts SDK functionality to the current runtime environment. */
2482
2857
  platform: VanaPlatformAdapter;
2858
+ /** Validates that storage is available for storage-dependent operations. */
2859
+ validateStorageRequired?: () => void;
2860
+ /** Checks whether storage is configured without throwing an error. */
2861
+ hasStorage?: () => boolean;
2862
+ /** Default IPFS gateways to use for fetching files. */
2863
+ ipfsGateways?: string[];
2483
2864
  }
2484
2865
  /**
2485
2866
  * Manages gasless data access permissions and trusted server registry operations.
@@ -2498,7 +2879,7 @@ interface ControllerContext$1 {
2498
2879
  * ```typescript
2499
2880
  * // Grant permission for an app to access your data
2500
2881
  * const txHash = await vana.permissions.grant({
2501
- * to: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2882
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2502
2883
  * operation: "llm_inference",
2503
2884
  * parameters: { model: "gpt-4", maxTokens: 1000 },
2504
2885
  * });
@@ -2536,7 +2917,7 @@ declare class PermissionsController {
2536
2917
  * @example
2537
2918
  * ```typescript
2538
2919
  * const txHash = await vana.permissions.grant({
2539
- * to: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2920
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2540
2921
  * operation: "llm_inference",
2541
2922
  * parameters: {
2542
2923
  * model: "gpt-4",
@@ -2562,7 +2943,7 @@ declare class PermissionsController {
2562
2943
  * @example
2563
2944
  * ```typescript
2564
2945
  * const { preview, confirm } = await vana.permissions.prepareGrant({
2565
- * to: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2946
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2566
2947
  * operation: "llm_inference",
2567
2948
  * files: [1, 2, 3],
2568
2949
  * parameters: { model: "gpt-4", prompt: "Analyze my social media data" }
@@ -2605,7 +2986,7 @@ declare class PermissionsController {
2605
2986
  * @example
2606
2987
  * ```typescript
2607
2988
  * const { typedData, signature } = await vana.permissions.createAndSign({
2608
- * to: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2989
+ * grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
2609
2990
  * operation: "data_analysis",
2610
2991
  * parameters: { analysisType: "sentiment" },
2611
2992
  * });
@@ -2710,7 +3091,7 @@ declare class PermissionsController {
2710
3091
  * Composes the EIP-712 typed data for PermissionGrant (new simplified format).
2711
3092
  *
2712
3093
  * @param params - The parameters for composing the permission grant message
2713
- * @param params.to - The recipient address for the permission grant
3094
+ * @param params.grantee - The recipient address for the permission grant
2714
3095
  * @param params.operation - The type of operation being granted permission for
2715
3096
  * @param params.files - Array of file IDs that the permission applies to
2716
3097
  * @param params.grantUrl - URL where the grant details are stored
@@ -2739,36 +3120,41 @@ declare class PermissionsController {
2739
3120
  */
2740
3121
  private getUserAddress;
2741
3122
  /**
2742
- * Retrieves all permissions granted by the current user using subgraph queries.
3123
+ * Gets on-chain permission grant data without expensive off-chain resolution.
2743
3124
  *
2744
3125
  * @remarks
2745
- * This method queries the Vana subgraph to find permissions directly granted by the user
2746
- * using the Permission entity. It efficiently handles millions of permissions by leveraging
2747
- * indexed subgraph data instead of scanning contract logs. The method fetches complete
2748
- * grant files from IPFS to provide detailed permission information including operation
2749
- * parameters and grantee details.
2750
- * @param params - Optional query parameters
2751
- * @param params.limit - Maximum number of permissions to return (default: 50)
2752
- * @param params.subgraphUrl - Optional subgraph URL to override the default endpoint
2753
- * @returns A Promise that resolves to an array of `GrantedPermission` objects
2754
- * @throws {BlockchainError} When subgraph is unavailable or returns invalid data
3126
+ * This method provides a fast, performance-focused way to retrieve permission grants
3127
+ * by querying only the subgraph without making expensive IPFS or individual contract calls.
3128
+ * It eliminates the N+1 query problem of the legacy `getUserPermissions()` method.
3129
+ *
3130
+ * The returned data contains all on-chain information but does NOT include resolved
3131
+ * operation details, parameters, or file IDs. Use `retrieveGrantFile()` separately
3132
+ * for specific grants when detailed data is needed.
3133
+ *
3134
+ * **Performance**: Completes in ~100-500ms regardless of permission count.
3135
+ * **Reliability**: Single point of failure (subgraph) with clear RPC fallback path.
3136
+ *
3137
+ * @param options - Options for retrieving permissions (limit, subgraph URL)
3138
+ * @returns A Promise that resolves to an array of `OnChainPermissionGrant` objects
3139
+ * @throws {BlockchainError} When subgraph query fails
3140
+ * @throws {NetworkError} When network requests fail
2755
3141
  * @example
2756
3142
  * ```typescript
2757
- * // Get all permissions granted by current user
2758
- * const permissions = await vana.permissions.getUserPermissions();
3143
+ * // Fast: Get all on-chain permission data
3144
+ * const grants = await vana.permissions.getUserPermissionGrantsOnChain({ limit: 20 });
2759
3145
  *
2760
- * permissions.forEach(permission => {
2761
- * console.log(`Granted ${permission.operation} to ${permission.grantee}`);
3146
+ * // Display in UI immediately
3147
+ * grants.forEach(grant => {
3148
+ * console.log(`Permission ${grant.id}: ${grant.grantUrl}`);
2762
3149
  * });
2763
3150
  *
2764
- * // Limit results
2765
- * const recent = await vana.permissions.getUserPermissions({ limit: 10 });
3151
+ * // Lazy load detailed data for specific permission when user clicks
3152
+ * const grantFile = await retrieveGrantFile(grants[0].grantUrl);
3153
+ * console.log(`Operation: ${grantFile.operation}`);
3154
+ * console.log(`Parameters:`, grantFile.parameters);
2766
3155
  * ```
2767
3156
  */
2768
- getUserPermissions(params?: {
2769
- limit?: number;
2770
- subgraphUrl?: string;
2771
- }): Promise<GrantedPermission[]>;
3157
+ getUserPermissionGrantsOnChain(options?: GetUserPermissionsOptions): Promise<OnChainPermissionGrant[]>;
2772
3158
  /**
2773
3159
  * Gets all permission IDs for a specific file.
2774
3160
  *
@@ -3287,14 +3673,21 @@ interface InitPersonalServerParams {
3287
3673
  /** The user's wallet address */
3288
3674
  userAddress: string;
3289
3675
  }
3676
+ /**
3677
+ * Extended personal server identity information including connection details.
3678
+ * This combines the base PersonalServerModel with additional metadata
3679
+ * needed for client connections.
3680
+ */
3290
3681
  interface PersonalServerIdentity {
3291
- /** Derived address for the personal server */
3682
+ /** Resource type identifier */
3683
+ kind: string;
3684
+ /** The server's Ethereum address */
3292
3685
  address: string;
3293
- /** Public key for encryption */
3686
+ /** The server's public key for encryption */
3294
3687
  public_key: string;
3295
- /** Base URL for the personal server */
3688
+ /** The base URL for connecting to this server */
3296
3689
  base_url: string;
3297
- /** Name of the personal server */
3690
+ /** Human-readable name for this server */
3298
3691
  name: string;
3299
3692
  }
3300
3693
 
@@ -3809,9 +4202,22 @@ interface components {
3809
4202
  type $defs = Record<string, never>;
3810
4203
  type operations = Record<string, never>;
3811
4204
 
4205
+ type CreateOperationRequest = components["schemas"]["CreateOperationRequest"];
3812
4206
  type CreateOperationResponse = components["schemas"]["CreateOperationResponse"];
3813
4207
  type GetOperationResponse = components["schemas"]["GetOperationResponse"];
3814
- type OperationCreatedResponse = CreateOperationResponse;
4208
+ type IdentityResponseModel = components["schemas"]["IdentityResponseModel"];
4209
+ type PersonalServerModel = components["schemas"]["PersonalServerModel"];
4210
+ type ErrorResponse = components["schemas"]["ErrorResponse"];
4211
+ type ValidationErrorResponse = components["schemas"]["ValidationErrorResponse"];
4212
+ type AuthenticationErrorResponse = components["schemas"]["AuthenticationErrorResponse"];
4213
+ type NotFoundErrorResponse = components["schemas"]["NotFoundErrorResponse"];
4214
+ type BlockchainErrorResponse = components["schemas"]["BlockchainErrorResponse"];
4215
+ type FileAccessErrorResponse = components["schemas"]["FileAccessErrorResponse"];
4216
+ type ComputeErrorResponse = components["schemas"]["ComputeErrorResponse"];
4217
+ type DecryptionErrorResponse = components["schemas"]["DecryptionErrorResponse"];
4218
+ type GrantValidationErrorResponse = components["schemas"]["GrantValidationErrorResponse"];
4219
+ type OperationErrorResponse = components["schemas"]["OperationErrorResponse"];
4220
+ type InternalServerErrorResponse = components["schemas"]["InternalServerErrorResponse"];
3815
4221
 
3816
4222
  /**
3817
4223
  * Types for external API responses used by the Vana SDK
@@ -3864,43 +4270,6 @@ interface ReplicateAPIResponse {
3864
4270
  total_time?: number;
3865
4271
  };
3866
4272
  }
3867
- /**
3868
- * Identity Server Output Types
3869
- * These define the expected structure of output from Vana's identity server
3870
- */
3871
- /** Output from the identity server model */
3872
- interface IdentityServerOutput {
3873
- /** User's EVM address */
3874
- user_address: string;
3875
- /** Personal server information */
3876
- personal_server: {
3877
- /** Derived address for the personal server */
3878
- address: string;
3879
- /** Public key for encryption */
3880
- public_key: string;
3881
- };
3882
- }
3883
- /** Identity server response with typed output */
3884
- interface IdentityServerResponse extends Omit<ReplicateAPIResponse, "output"> {
3885
- /** Parsed identity server output */
3886
- output?: IdentityServerOutput | string;
3887
- }
3888
- /**
3889
- * Personal Server Output Types
3890
- * These define the expected structure of output from Vana's personal server
3891
- */
3892
- /** Output from the personal server model */
3893
- interface PersonalServerOutput {
3894
- /** User's EVM address */
3895
- user_address: string;
3896
- /** Identity information */
3897
- identity: {
3898
- /** Additional metadata */
3899
- metadata?: Record<string, unknown>;
3900
- /** Derived address (alternative location) */
3901
- derivedAddress?: string;
3902
- };
3903
- }
3904
4273
  /**
3905
4274
  * Storage Provider API Types
3906
4275
  */
@@ -3973,38 +4342,6 @@ interface APIResponse<T = unknown> {
3973
4342
  * ```
3974
4343
  */
3975
4344
  declare function isReplicateAPIResponse(value: unknown): value is ReplicateAPIResponse;
3976
- /**
3977
- * Validates whether a value is a valid IdentityServerOutput.
3978
- *
3979
- * @param value - The value to check
3980
- * @returns True if the value matches the IdentityServerOutput structure
3981
- * @example
3982
- * ```typescript
3983
- * const output = response.output;
3984
- *
3985
- * if (isIdentityServerOutput(output)) {
3986
- * console.log('User address:', output.user_address);
3987
- * console.log('Server address:', output.personal_server.address);
3988
- * }
3989
- * ```
3990
- */
3991
- declare function isIdentityServerOutput(value: unknown): value is IdentityServerOutput;
3992
- /**
3993
- * Validates whether a value is a valid PersonalServerOutput.
3994
- *
3995
- * @param value - The value to check
3996
- * @returns True if the value matches the PersonalServerOutput structure
3997
- * @example
3998
- * ```typescript
3999
- * const output = response.output;
4000
- *
4001
- * if (isPersonalServerOutput(output)) {
4002
- * console.log('User address:', output.user_address);
4003
- * console.log('Identity metadata:', output.identity.metadata);
4004
- * }
4005
- * ```
4006
- */
4007
- declare function isPersonalServerOutput(value: unknown): value is PersonalServerOutput;
4008
4345
  /**
4009
4346
  * Validates whether a value is a valid APIResponse.
4010
4347
  *
@@ -4037,7 +4374,7 @@ declare function isAPIResponse<T>(value: unknown): value is APIResponse<T>;
4037
4374
  * @example
4038
4375
  * ```typescript
4039
4376
  * const jsonStr = '{"user_address": "0x123...", "identity": {}}';
4040
- * const result = safeParseJSON(jsonStr, isPersonalServerOutput);
4377
+ * const result = safeParseJSON(jsonStr, isAPIResponse);
4041
4378
  *
4042
4379
  * if (result) {
4043
4380
  * console.log('Parsed server output:', result.user_address);
@@ -4056,7 +4393,7 @@ declare function safeParseJSON<T>(jsonString: string, typeGuard: (value: unknown
4056
4393
  * @example
4057
4394
  * ```typescript
4058
4395
  * const response = await replicateClient.get(predictionId);
4059
- * const output = parseReplicateOutput(response, isIdentityServerOutput);
4396
+ * const output = parseReplicateOutput(response, isReplicateAPIResponse);
4060
4397
  *
4061
4398
  * if (output) {
4062
4399
  * console.log('Identity server result:', output.user_address);
@@ -5066,7 +5403,7 @@ interface UserFile {
5066
5403
  */
5067
5404
  interface GrantPermissionParams {
5068
5405
  /** The on-chain identity of the application */
5069
- to: Address;
5406
+ grantee: Address;
5070
5407
  /** The class of computation, e.g., "llm_inference" */
5071
5408
  operation: string;
5072
5409
  /** Array of file IDs to grant permission for */
@@ -5129,6 +5466,9 @@ declare class DataController {
5129
5466
  * - Grants permissions to specified applications
5130
5467
  * - Registers the file on the blockchain
5131
5468
  *
5469
+ * When using permissions with encryption enabled (default), you must provide the public key
5470
+ * for each permission recipient.
5471
+ *
5132
5472
  * @param params - Upload parameters including content, filename, schema, and permissions
5133
5473
  * @returns Promise resolving to upload results with file ID and transaction hash
5134
5474
  * @throws {Error} When wallet is not connected or storage is not configured
@@ -5149,19 +5489,98 @@ declare class DataController {
5149
5489
  * schemaId: 1
5150
5490
  * });
5151
5491
  *
5152
- * // Upload with permissions
5492
+ * // Upload with permissions (encrypted - requires publicKey)
5153
5493
  * const result = await vana.data.upload({
5154
5494
  * content: "Data for AI analysis",
5155
5495
  * filename: "analysis.txt",
5156
5496
  * permissions: [{
5157
- * to: "0x1234...",
5497
+ * grantee: "0x1234...",
5158
5498
  * operation: "llm_inference",
5159
- * parameters: { model: "gpt-4" }
5499
+ * parameters: { model: "gpt-4" },
5500
+ * publicKey: "0x04..." // Required when encrypt is true (default)
5501
+ * }]
5502
+ * });
5503
+ *
5504
+ * // Upload without encryption
5505
+ * const result = await vana.data.upload({
5506
+ * content: "Public data",
5507
+ * filename: "public.txt",
5508
+ * encrypt: false,
5509
+ * permissions: [{
5510
+ * grantee: "0x1234...",
5511
+ * operation: "read",
5512
+ * parameters: {}
5513
+ * }]
5514
+ * });
5515
+ *
5516
+ * // Upload on behalf of another user (delegation)
5517
+ * const result = await vana.data.upload({
5518
+ * content: "User's data",
5519
+ * filename: "delegated.txt",
5520
+ * owner: "0x5678...", // Different from connected wallet
5521
+ * permissions: [{
5522
+ * grantee: "0x1234...",
5523
+ * operation: "process",
5524
+ * parameters: { type: "analysis" },
5525
+ * publicKey: "0x04..."
5160
5526
  * }]
5161
5527
  * });
5162
5528
  * ```
5163
5529
  */
5530
+ upload(params: EncryptedUploadParams): Promise<UploadResult>;
5531
+ upload(params: UnencryptedUploadParams): Promise<UploadResult>;
5164
5532
  upload(params: UploadParams): Promise<UploadResult>;
5533
+ /**
5534
+ * Decrypts a file owned by the user using their wallet signature.
5535
+ *
5536
+ * @remarks
5537
+ * This is the high-level convenience method for decrypting user files, serving as the
5538
+ * symmetrical counterpart to the `upload` method. It handles the complete decryption
5539
+ * workflow including key generation, URL protocol detection, content fetching, and
5540
+ * decryption.
5541
+ *
5542
+ * The method automatically:
5543
+ * - Generates the decryption key from the user's wallet signature
5544
+ * - Determines the appropriate fetch method based on the file URL protocol
5545
+ * - Fetches the encrypted content from IPFS or standard HTTP URLs
5546
+ * - Decrypts the content using the generated key
5547
+ *
5548
+ * For IPFS URLs, the method uses gateway fallback for improved reliability. For
5549
+ * standard HTTP URLs, it uses a simple fetch. If you need custom authentication
5550
+ * headers or specific gateway configurations, use the low-level primitives directly.
5551
+ *
5552
+ * @param file - The user file to decrypt (typically from getUserFiles)
5553
+ * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
5554
+ * @returns Promise resolving to the decrypted file content as a Blob
5555
+ * @throws {Error} When the wallet is not connected
5556
+ * @throws {Error} When fetching the encrypted content fails
5557
+ * @throws {Error} When decryption fails (wrong key or corrupted data)
5558
+ * @example
5559
+ * ```typescript
5560
+ * // Basic file decryption
5561
+ * const files = await vana.data.getUserFiles({ owner: userAddress });
5562
+ * const decryptedBlob = await vana.data.decryptFile(files[0]);
5563
+ *
5564
+ * // Convert to text
5565
+ * const text = await decryptedBlob.text();
5566
+ * console.log('Decrypted content:', text);
5567
+ *
5568
+ * // Convert to JSON
5569
+ * const json = JSON.parse(await decryptedBlob.text());
5570
+ * console.log('Decrypted data:', json);
5571
+ *
5572
+ * // With custom encryption seed
5573
+ * const decryptedBlob = await vana.data.decryptFile(
5574
+ * files[0],
5575
+ * "My custom encryption seed"
5576
+ * );
5577
+ *
5578
+ * // Save to file (in Node.js)
5579
+ * const buffer = await decryptedBlob.arrayBuffer();
5580
+ * fs.writeFileSync('decrypted-file.txt', Buffer.from(buffer));
5581
+ * ```
5582
+ */
5583
+ decryptFile(file: UserFile$1, encryptionSeed?: string): Promise<Blob>;
5165
5584
  /**
5166
5585
  * Retrieves all data files owned by a specific user address.
5167
5586
  *
@@ -5348,19 +5767,6 @@ declare class DataController {
5348
5767
  * 3. Returning the assigned file ID and storage URL
5349
5768
  */
5350
5769
  uploadEncryptedFileWithSchema(encryptedFile: Blob, schemaId: number, filename?: string, providerName?: string): Promise<UploadEncryptedFileResult>;
5351
- /**
5352
- * Decrypts a file that was encrypted using the Vana protocol.
5353
- *
5354
- * @param file - The UserFile object containing the file URL and metadata
5355
- * @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
5356
- * @returns Promise resolving to the decrypted file as a Blob
5357
- *
5358
- * This method handles the complete flow of:
5359
- * 1. Generating the encryption key from the user's wallet signature
5360
- * 2. Fetching the encrypted file from the stored URL
5361
- * 3. Decrypting the file using the canonical Vana decryption method
5362
- */
5363
- decryptFile(file: UserFile$1, encryptionSeed?: string): Promise<Blob>;
5364
5770
  /**
5365
5771
  * Registers a file URL directly on the blockchain with a schema ID.
5366
5772
  *
@@ -5375,13 +5781,6 @@ declare class DataController {
5375
5781
  fileId: number;
5376
5782
  transactionHash: Address;
5377
5783
  }>;
5378
- /**
5379
- * Converts IPFS and Google Drive URLs to direct download URLs for fetching.
5380
- *
5381
- * @param url - The URL to convert to a direct download URL
5382
- * @returns The converted direct download URL or the original URL if not a special URL
5383
- */
5384
- private convertToDownloadUrl;
5385
5784
  /**
5386
5785
  * Gets the user's address from the wallet client.
5387
5786
  *
@@ -5407,6 +5806,23 @@ declare class DataController {
5407
5806
  fileId: number;
5408
5807
  transactionHash: string;
5409
5808
  }>;
5809
+ /**
5810
+ * Adds a file to the registry with permissions and schema.
5811
+ * This combines the functionality of addFileWithPermissions and schema validation.
5812
+ *
5813
+ * @param url - The URL of the file to register
5814
+ * @param ownerAddress - The address of the file owner
5815
+ * @param permissions - Array of permissions to grant (account and encrypted key)
5816
+ * @param schemaId - The schema ID to associate with the file (0 for no schema)
5817
+ * @returns Promise resolving to object with fileId and transactionHash
5818
+ */
5819
+ addFileWithPermissionsAndSchema(url: string, ownerAddress: Address, permissions?: Array<{
5820
+ account: Address;
5821
+ key: string;
5822
+ }>, schemaId?: number): Promise<{
5823
+ fileId: number;
5824
+ transactionHash: string;
5825
+ }>;
5410
5826
  /**
5411
5827
  * Adds a new schema to the DataRefinerRegistry.
5412
5828
  *
@@ -5519,6 +5935,73 @@ declare class DataController {
5519
5935
  * @returns Promise resolving to the decrypted file data
5520
5936
  */
5521
5937
  decryptFileWithPermission(file: UserFile$1, privateKey: string, account?: Address): Promise<Blob>;
5938
+ /**
5939
+ * Simple network-agnostic fetch utility for retrieving file content.
5940
+ *
5941
+ * @remarks
5942
+ * This is a thin wrapper around the global fetch API that returns the response as a Blob.
5943
+ * It provides a consistent interface for fetching encrypted content before decryption.
5944
+ * For IPFS URLs, consider using fetchFromIPFS for better reliability.
5945
+ *
5946
+ * @param url - The URL to fetch content from
5947
+ * @returns Promise resolving to the fetched content as a Blob
5948
+ * @throws {Error} When the fetch fails or returns a non-ok response
5949
+ *
5950
+ * @example
5951
+ * ```typescript
5952
+ * // Fetch and decrypt a file
5953
+ * const encryptionKey = await generateEncryptionKey(walletClient);
5954
+ * const encryptedBlob = await vana.data.fetch(file.url);
5955
+ * const decryptedBlob = await decryptBlob(encryptedBlob, encryptionKey, platform);
5956
+ *
5957
+ * // With custom headers for authentication
5958
+ * const response = await fetch(file.url, {
5959
+ * headers: { 'Authorization': 'Bearer token' }
5960
+ * });
5961
+ * const encryptedBlob = await response.blob();
5962
+ * ```
5963
+ */
5964
+ fetch(url: string): Promise<Blob>;
5965
+ /**
5966
+ * Specialized IPFS fetcher with gateway fallback mechanism.
5967
+ *
5968
+ * @remarks
5969
+ * This method provides robust IPFS content fetching by trying multiple gateways
5970
+ * in sequence until one succeeds. It supports both ipfs:// URLs and raw CIDs.
5971
+ *
5972
+ * The default gateway list includes public gateways, but you should provide
5973
+ * your own gateways for production use to ensure reliability and privacy.
5974
+ *
5975
+ * @param url - The IPFS URL (ipfs://...) or CID to fetch
5976
+ * @param options - Optional configuration
5977
+ * @param options.gateways - Array of IPFS gateway URLs to try (must end with /)
5978
+ * @returns Promise resolving to the fetched content as a Blob
5979
+ * @throws {Error} When all gateways fail to fetch the content
5980
+ *
5981
+ * @example
5982
+ * ```typescript
5983
+ * // Fetch from IPFS with custom gateways
5984
+ * const encryptedBlob = await vana.data.fetchFromIPFS(file.url, {
5985
+ * gateways: [
5986
+ * 'https://my-private-gateway.com/ipfs/',
5987
+ * 'https://dweb.link/ipfs/',
5988
+ * 'https://ipfs.io/ipfs/'
5989
+ * ]
5990
+ * });
5991
+ *
5992
+ * // Decrypt the fetched content
5993
+ * const encryptionKey = await generateEncryptionKey(walletClient);
5994
+ * const decryptedBlob = await decryptBlob(encryptedBlob, encryptionKey, platform);
5995
+ *
5996
+ * // With raw CID
5997
+ * const blob = await vana.data.fetchFromIPFS('QmXxx...', {
5998
+ * gateways: ['https://ipfs.io/ipfs/']
5999
+ * });
6000
+ * ```
6001
+ */
6002
+ fetchFromIPFS(url: string, options?: {
6003
+ gateways?: string[];
6004
+ }): Promise<Blob>;
5522
6005
  /**
5523
6006
  * Validates a data schema against the Vana meta-schema.
5524
6007
  *
@@ -9839,6 +10322,11 @@ declare const contractAbis: {
9839
10322
  readonly internalType: "uint256";
9840
10323
  readonly name: "schemaId";
9841
10324
  readonly type: "uint256";
10325
+ }, {
10326
+ readonly indexed: false;
10327
+ readonly internalType: "string";
10328
+ readonly name: "schemaDefinitionUrl";
10329
+ readonly type: "string";
9842
10330
  }, {
9843
10331
  readonly indexed: false;
9844
10332
  readonly internalType: "string";
@@ -9922,7 +10410,7 @@ declare const contractAbis: {
9922
10410
  }, {
9923
10411
  readonly indexed: false;
9924
10412
  readonly internalType: "string";
9925
- readonly name: "typ";
10413
+ readonly name: "dialect";
9926
10414
  readonly type: "string";
9927
10415
  }, {
9928
10416
  readonly indexed: false;
@@ -9996,6 +10484,32 @@ declare const contractAbis: {
9996
10484
  readonly outputs: readonly [];
9997
10485
  readonly stateMutability: "nonpayable";
9998
10486
  readonly type: "function";
10487
+ }, {
10488
+ readonly inputs: readonly [{
10489
+ readonly internalType: "uint256";
10490
+ readonly name: "dlpId";
10491
+ readonly type: "uint256";
10492
+ }, {
10493
+ readonly internalType: "string";
10494
+ readonly name: "name";
10495
+ readonly type: "string";
10496
+ }, {
10497
+ readonly internalType: "string";
10498
+ readonly name: "schemaDefinitionUrl";
10499
+ readonly type: "string";
10500
+ }, {
10501
+ readonly internalType: "string";
10502
+ readonly name: "refinementInstructionUrl";
10503
+ readonly type: "string";
10504
+ }];
10505
+ readonly name: "addRefiner";
10506
+ readonly outputs: readonly [{
10507
+ readonly internalType: "uint256";
10508
+ readonly name: "";
10509
+ readonly type: "uint256";
10510
+ }];
10511
+ readonly stateMutability: "nonpayable";
10512
+ readonly type: "function";
9999
10513
  }, {
10000
10514
  readonly inputs: readonly [{
10001
10515
  readonly internalType: "uint256";
@@ -10014,7 +10528,7 @@ declare const contractAbis: {
10014
10528
  readonly name: "refinementInstructionUrl";
10015
10529
  readonly type: "string";
10016
10530
  }];
10017
- readonly name: "addRefiner";
10531
+ readonly name: "addRefinerWithSchemaId";
10018
10532
  readonly outputs: readonly [{
10019
10533
  readonly internalType: "uint256";
10020
10534
  readonly name: "";
@@ -10029,7 +10543,7 @@ declare const contractAbis: {
10029
10543
  readonly type: "string";
10030
10544
  }, {
10031
10545
  readonly internalType: "string";
10032
- readonly name: "typ";
10546
+ readonly name: "dialect";
10033
10547
  readonly type: "string";
10034
10548
  }, {
10035
10549
  readonly internalType: "string";
@@ -10305,7 +10819,7 @@ declare const contractAbis: {
10305
10819
  readonly type: "string";
10306
10820
  }, {
10307
10821
  readonly internalType: "string";
10308
- readonly name: "typ";
10822
+ readonly name: "dialect";
10309
10823
  readonly type: "string";
10310
10824
  }, {
10311
10825
  readonly internalType: "string";
@@ -30676,6 +31190,45 @@ declare class ProtocolController {
30676
31190
  getChainName(): string;
30677
31191
  }
30678
31192
 
31193
+ /**
31194
+ * Factory functions for creating VanaCore instances with proper type safety
31195
+ */
31196
+ declare class VanaCoreFactory {
31197
+ /**
31198
+ * Creates a VanaCore instance that enforces storage requirements at compile time.
31199
+ * Use this factory when you know you'll need storage-dependent operations.
31200
+ *
31201
+ * @param platform - The platform adapter for environment-specific operations
31202
+ * @param config - Configuration that includes required storage providers
31203
+ * @returns VanaCore instance with storage validation
31204
+ * @example
31205
+ * ```typescript
31206
+ * const vanaCore = VanaCoreFactory.createWithStorage(platformAdapter, {
31207
+ * walletClient: myWalletClient,
31208
+ * storage: {
31209
+ * providers: { ipfs: new IPFSStorage() },
31210
+ * defaultProvider: 'ipfs'
31211
+ * }
31212
+ * });
31213
+ * ```
31214
+ */
31215
+ static createWithStorage(platform: VanaPlatformAdapter, config: VanaConfigWithStorage): VanaCore & StorageRequiredMarker;
31216
+ /**
31217
+ * Creates a VanaCore instance without storage requirements.
31218
+ * Storage-dependent operations will fail at runtime if not configured.
31219
+ *
31220
+ * @param platform - The platform adapter for environment-specific operations
31221
+ * @param config - Basic configuration without required storage
31222
+ * @returns VanaCore instance
31223
+ * @example
31224
+ * ```typescript
31225
+ * const vanaCore = VanaCoreFactory.create(platformAdapter, {
31226
+ * walletClient: myWalletClient
31227
+ * });
31228
+ * ```
31229
+ */
31230
+ static create(platform: VanaPlatformAdapter, config: VanaConfig): VanaCore;
31231
+ }
30679
31232
  /**
30680
31233
  * Provides the core SDK functionality for interacting with the Vana network.
30681
31234
  *
@@ -30684,8 +31237,11 @@ declare class ProtocolController {
30684
31237
  * adapter to handle environment-specific operations. It initializes all controllers
30685
31238
  * and manages shared context between them.
30686
31239
  *
31240
+ * The class uses TypeScript overloading to enforce storage requirements at compile time.
31241
+ * When storage is required for certain operations, the constructor will fail fast at runtime.
31242
+ *
30687
31243
  * For public usage, use the platform-specific Vana classes that extend this core:
30688
- * - Use `new Vana(config)` from the main package import
31244
+ * - Use `Vana({config)` from the main package import
30689
31245
  * @example
30690
31246
  * ```typescript
30691
31247
  * // Direct instantiation (typically used internally)
@@ -30710,12 +31266,18 @@ declare class VanaCore {
30710
31266
  protected platform: VanaPlatformAdapter;
30711
31267
  private readonly relayerCallbacks?;
30712
31268
  private readonly storageManager?;
31269
+ private readonly hasRequiredStorage;
31270
+ private readonly ipfsGateways?;
30713
31271
  /**
30714
31272
  * Initializes a new VanaCore client instance with the provided configuration.
30715
31273
  *
30716
31274
  * @remarks
30717
31275
  * The constructor validates the configuration, initializes storage providers if configured,
30718
31276
  * creates wallet and public clients, and sets up all SDK controllers with shared context.
31277
+ *
31278
+ * IMPORTANT: This constructor will validate storage requirements at runtime to fail fast.
31279
+ * Methods that require storage will throw runtime errors if storage is not configured.
31280
+ *
30719
31281
  * @param platform - The platform adapter for environment-specific operations
30720
31282
  * @param config - The configuration object specifying wallet or chain settings
30721
31283
  * @throws {InvalidConfigurationError} When the configuration is invalid or incomplete
@@ -30728,6 +31290,48 @@ declare class VanaCore {
30728
31290
  * ```
30729
31291
  */
30730
31292
  constructor(platform: VanaPlatformAdapter, config: VanaConfig);
31293
+ /**
31294
+ * Validates that storage is available for storage-dependent operations.
31295
+ * This method enforces the fail-fast principle by checking storage availability
31296
+ * at method call time rather than during expensive operations.
31297
+ *
31298
+ * @throws {InvalidConfigurationError} When storage is required but not configured
31299
+ * @example
31300
+ * ```typescript
31301
+ * // This will throw if storage is not configured
31302
+ * vana.validateStorageRequired();
31303
+ * await vana.data.uploadFile(file); // Safe to proceed
31304
+ * ```
31305
+ */
31306
+ validateStorageRequired(): void;
31307
+ /**
31308
+ * Checks whether storage is configured without throwing an error.
31309
+ *
31310
+ * @returns True if storage is properly configured
31311
+ * @example
31312
+ * ```typescript
31313
+ * if (vana.hasStorage()) {
31314
+ * await vana.data.uploadFile(file);
31315
+ * } else {
31316
+ * console.warn('Storage not configured - using pre-stored URLs only');
31317
+ * }
31318
+ * ```
31319
+ */
31320
+ hasStorage(): boolean;
31321
+ /**
31322
+ * Type guard to check if this instance has storage enabled at compile time.
31323
+ * Use this when you need TypeScript to understand that storage is available.
31324
+ *
31325
+ * @returns True if storage is configured, with type narrowing
31326
+ * @example
31327
+ * ```typescript
31328
+ * if (vana.isStorageEnabled()) {
31329
+ * // TypeScript knows storage is available here
31330
+ * await vana.data.uploadFile(file);
31331
+ * }
31332
+ * ```
31333
+ */
31334
+ isStorageEnabled(): this is VanaCore & StorageRequiredMarker;
30731
31335
  /**
30732
31336
  * Validates the provided configuration object against all requirements.
30733
31337
  *
@@ -30815,21 +31419,21 @@ declare class VanaCore {
30815
31419
  */
30816
31420
  getPlatformAdapter(): VanaPlatformAdapter;
30817
31421
  /**
30818
- * Encrypts user data using the Vana protocol standard encryption.
31422
+ * Encrypts data using the Vana protocol standard encryption.
30819
31423
  * This method automatically uses the correct platform adapter for the current environment.
30820
31424
  *
30821
31425
  * @param data The data to encrypt (string or Blob)
30822
- * @param walletSignature The wallet signature to use as encryption key
31426
+ * @param key The key to use as encryption key
30823
31427
  * @returns The encrypted data as Blob
30824
31428
  * @example
30825
31429
  * ```typescript
30826
31430
  * const encryptionKey = await generateEncryptionKey(walletClient);
30827
- * const encrypted = await vana.encryptUserData("sensitive data", encryptionKey);
31431
+ * const encrypted = await vana.encryptBlob("sensitive data", encryptionKey);
30828
31432
  * ```
30829
31433
  */
30830
- encryptUserData(data: string | Blob, walletSignature: string): Promise<Blob>;
31434
+ encryptBlob(data: string | Blob, key: string): Promise<Blob>;
30831
31435
  /**
30832
- * Decrypts user data using the Vana protocol standard decryption.
31436
+ * Decrypts data that was encrypted using the Vana protocol.
30833
31437
  * This method automatically uses the correct platform adapter for the current environment.
30834
31438
  *
30835
31439
  * @param encryptedData The encrypted data (string or Blob)
@@ -30838,11 +31442,11 @@ declare class VanaCore {
30838
31442
  * @example
30839
31443
  * ```typescript
30840
31444
  * const encryptionKey = await generateEncryptionKey(walletClient);
30841
- * const decrypted = await vana.decryptUserData(encryptedData, encryptionKey);
31445
+ * const decrypted = await vana.decryptBlob(encryptedData, encryptionKey);
30842
31446
  * const text = await decrypted.text();
30843
31447
  * ```
30844
31448
  */
30845
- decryptUserData(encryptedData: string | Blob, walletSignature: string): Promise<Blob>;
31449
+ decryptBlob(encryptedData: string | Blob, walletSignature: string): Promise<Blob>;
30846
31450
  }
30847
31451
 
30848
31452
  /**
@@ -31043,23 +31647,44 @@ declare function getEncryptionParameters(platformAdapter: VanaPlatformAdapter):
31043
31647
  */
31044
31648
  declare function decryptWithPrivateKey(encryptedData: string, privateKey: string, platformAdapter: VanaPlatformAdapter): Promise<string>;
31045
31649
  /**
31046
- * Encrypt user data using PGP with platform-appropriate configuration
31650
+ * Encrypts data using a signed key generated from the user's wallet signature.
31651
+ *
31652
+ * @remarks
31653
+ * This is a pure cryptographic primitive that encrypts data using the Vana protocol's
31654
+ * standard encryption method. The key parameter must be a signature generated by the
31655
+ * `generateEncryptionKey` utility - this ensures deterministic key generation from the
31656
+ * user's wallet, enabling the same key to be regenerated for decryption.
31657
+ *
31658
+ * This function uses password-based encryption with the signature as the password,
31659
+ * providing symmetric encryption that can be decrypted with the same signature.
31047
31660
  *
31048
31661
  * @param data The data to encrypt (string or Blob)
31049
- * @param walletSignature The wallet signature to use as password
31050
- * @param platformAdapter - The platform adapter for crypto operations
31662
+ * @param key The signed key from `generateEncryptionKey` - MUST be a wallet signature
31663
+ * @param platformAdapter The platform adapter for crypto operations
31051
31664
  * @returns The encrypted data as Blob
31052
- */
31053
- declare function encryptUserData(data: string | Blob, walletSignature: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
31054
- /**
31055
- * Decrypt user data using PGP with platform-appropriate configuration
31665
+ * @throws {Error} When encryption fails
31056
31666
  *
31057
- * @param encryptedData The encrypted data (string or Blob)
31058
- * @param walletSignature The wallet signature to use as password
31059
- * @param platformAdapter - The platform adapter for crypto operations
31060
- * @returns The decrypted data as Blob
31667
+ * @example
31668
+ * ```typescript
31669
+ * // Generate the encryption key from wallet signature
31670
+ * const encryptionKey = await generateEncryptionKey(walletClient);
31671
+ *
31672
+ * // Encrypt data with the signed key
31673
+ * const encryptedBlob = await encryptBlobWithSignedKey(
31674
+ * "My sensitive data",
31675
+ * encryptionKey,
31676
+ * platformAdapter
31677
+ * );
31678
+ *
31679
+ * // Later, decrypt with the same key
31680
+ * const decryptedBlob = await decryptBlobWithSignedKey(
31681
+ * encryptedBlob,
31682
+ * encryptionKey,
31683
+ * platformAdapter
31684
+ * );
31685
+ * ```
31061
31686
  */
31062
- declare function decryptUserData(encryptedData: string | Blob, walletSignature: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
31687
+ declare function encryptBlobWithSignedKey(data: string | Blob, key: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
31063
31688
  /**
31064
31689
  * Generate a new key pair for asymmetric encryption
31065
31690
  *
@@ -31088,6 +31713,55 @@ declare function generatePGPKeyPair(platformAdapter: VanaPlatformAdapter, option
31088
31713
  publicKey: string;
31089
31714
  privateKey: string;
31090
31715
  }>;
31716
+ /**
31717
+ * Decrypts data using a signed key generated from the user's wallet signature.
31718
+ *
31719
+ * @remarks
31720
+ * This is a pure cryptographic primitive for decrypting data that was encrypted using
31721
+ * `encryptBlobWithSignedKey`. It is network-agnostic and only handles decryption - it does
31722
+ * not fetch data from any URL or make network requests. To decrypt a file from a URL, you
31723
+ * must first fetch the encrypted blob using one of the fetch utilities, then pass it to
31724
+ * this function.
31725
+ *
31726
+ * The key parameter must be the same signature that was used for encryption, typically
31727
+ * generated by the `generateEncryptionKey` utility. This ensures that only the user who
31728
+ * encrypted the data (or someone with the same wallet signature) can decrypt it.
31729
+ *
31730
+ * @param encryptedData The encrypted data to decrypt (string or Blob)
31731
+ * @param key The signed key from `generateEncryptionKey` - MUST be the same wallet signature used for encryption
31732
+ * @param platformAdapter The platform adapter for crypto operations
31733
+ * @returns Promise resolving to the decrypted blob
31734
+ * @throws {Error} When decryption fails due to wrong key or corrupted data
31735
+ *
31736
+ * @example
31737
+ * ```typescript
31738
+ * // Generate the same encryption key used for encryption
31739
+ * const encryptionKey = await generateEncryptionKey(walletClient);
31740
+ *
31741
+ * // Fetch and decrypt using the high-level API
31742
+ * const file = await vana.data.getUserFiles({ owner: "0x..." })[0];
31743
+ * const decryptedBlob = await vana.data.decryptFile(file);
31744
+ *
31745
+ * // Or use the low-level primitives directly
31746
+ * const encryptedBlob = await vana.data.fetch(file.url);
31747
+ * const decryptedBlob = await decryptBlobWithSignedKey(
31748
+ * encryptedBlob,
31749
+ * encryptionKey,
31750
+ * platformAdapter
31751
+ * );
31752
+ *
31753
+ * // With IPFS gateway fallback
31754
+ * const encryptedBlob = await vana.data.fetchFromIPFS(file.url, {
31755
+ * gateways: ['https://my-gateway.com/ipfs/', 'https://ipfs.io/ipfs/']
31756
+ * });
31757
+ * const decryptedBlob = await decryptBlobWithSignedKey(
31758
+ * encryptedBlob,
31759
+ * encryptionKey,
31760
+ * platformAdapter
31761
+ * );
31762
+ * ```
31763
+ */
31764
+ declare function decryptBlobWithSignedKey(encryptedData: string | Blob, key: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
31091
31765
 
31092
31766
  /**
31093
31767
  * Format a bigint or BigNumber to a regular number
@@ -31137,11 +31811,42 @@ declare function createGrantFile(params: GrantPermissionParams$1): GrantFile;
31137
31811
  */
31138
31812
  declare function storeGrantFile(grantFile: GrantFile, relayerUrl: string): Promise<string>;
31139
31813
  /**
31140
- * Retrieves a grant file from any URL.
31814
+ * Retrieves detailed grant file data from IPFS or HTTP storage.
31141
31815
  *
31142
- * @param grantUrl - The grant file URL (supports HTTP/HTTPS, ipfs:// protocol, or IPFS gateway URLs)
31143
- * @param _relayerUrl - URL of the relayer service (optional)
31144
- * @returns Promise resolving to the grant file
31816
+ * @remarks
31817
+ * **This is Step 2 of the performant two-step permission API.**
31818
+ *
31819
+ * Use this method to resolve detailed permission data (operation, parameters, etc.)
31820
+ * for specific grants after first getting the fast on-chain data using
31821
+ * `getUserPermissionGrantsOnChain()`. This design eliminates N+1 query problems
31822
+ * by allowing selective lazy-loading of expensive off-chain data.
31823
+ *
31824
+ * **Performance**: Single network request per grant file (typically 100-500ms).
31825
+ * **Reliability**: Tries multiple IPFS gateways as fallbacks if primary URL fails.
31826
+ *
31827
+ * @param grantUrl - The grant file URL from OnChainPermissionGrant.grantUrl
31828
+ * @param _relayerUrl - URL of the relayer service (optional, unused)
31829
+ * @returns Promise resolving to the complete grant file with operation details
31830
+ * @throws {NetworkError} When all retrieval attempts fail
31831
+ * @throws {SerializationError} When grant file format is invalid
31832
+ * @example
31833
+ * ```typescript
31834
+ * // Step 1: Fast on-chain data (no N+1 queries)
31835
+ * const grants = await vana.permissions.getUserPermissionGrantsOnChain();
31836
+ *
31837
+ * // Step 2: Lazy-load details for specific grant when needed
31838
+ * const grantFile = await retrieveGrantFile(grants[0].grantUrl);
31839
+ *
31840
+ * console.log(`Operation: ${grantFile.operation}`);
31841
+ * console.log(`Grantee: ${grantFile.grantee}`);
31842
+ * console.log(`Parameters:`, grantFile.parameters);
31843
+ *
31844
+ * // Only fetch details for grants user actually wants to see
31845
+ * for (const grant of selectedGrants) {
31846
+ * const details = await retrieveGrantFile(grant.grantUrl);
31847
+ * displayGrantDetails(details);
31848
+ * }
31849
+ * ```
31145
31850
  */
31146
31851
  declare function retrieveGrantFile(grantUrl: string, _relayerUrl?: string): Promise<GrantFile>;
31147
31852
  /**
@@ -31868,39 +32573,48 @@ declare class ApiClient {
31868
32573
  }
31869
32574
 
31870
32575
  /**
31871
- * The Vana SDK class pre-configured for browser environments.
31872
- * Automatically uses the browser platform adapter for crypto operations and file systems.
32576
+ * Internal implementation class for browser environments.
32577
+ * This class is not exported directly - use the Vana factory function instead.
32578
+ */
32579
+ declare class VanaBrowserImpl extends VanaCore {
32580
+ constructor(config: VanaConfig);
32581
+ }
32582
+ /**
32583
+ * Creates a new Vana SDK instance configured for browser environments.
32584
+ *
32585
+ * This function automatically provides the correct TypeScript types based on your configuration:
32586
+ * - With storage config: All methods including storage-dependent ones are available
32587
+ * - Without storage: Storage-dependent methods are not available at compile time
31873
32588
  *
32589
+ * @param config - The configuration object containing wallet client and optional storage settings
32590
+ * @returns A Vana SDK instance configured for browser use
31874
32591
  * @example
31875
32592
  * ```typescript
31876
- * const vana = new Vana({ walletClient });
32593
+ * // With storage - all methods available
32594
+ * const vana = Vana({
32595
+ * walletClient,
32596
+ * storage: { providers: { ipfs: new IPFSStorage() }, defaultProvider: 'ipfs' }
32597
+ * });
32598
+ * await vana.data.uploadFile(file); // ✅ Works - TypeScript knows storage is available
31877
32599
  *
31878
- * // Upload and encrypt user data
31879
- * const file = await vana.data.uploadAndStoreFile(dataBlob, schema);
32600
+ * // Without storage - storage methods unavailable at compile time
32601
+ * const vanaNoStorage = Vana({ walletClient });
32602
+ * // await vanaNoStorage.data.uploadFile(file); // ❌ TypeScript error
31880
32603
  *
31881
- * // Grant permissions to DLPs
31882
- * await vana.permissions.grantPermission({
31883
- * account: dlpAddress,
31884
- * fileId: file.id,
31885
- * permissions: ['read']
31886
- * });
32604
+ * // Runtime check still available
32605
+ * if (vanaNoStorage.isStorageEnabled()) {
32606
+ * // TypeScript now knows storage methods are safe to use
32607
+ * await vanaNoStorage.data.uploadFile(file); // ✅ Works
32608
+ * }
31887
32609
  * ```
31888
32610
  */
31889
- declare class VanaBrowser extends VanaCore {
31890
- /**
31891
- * Creates a Vana SDK instance configured for browser environments.
31892
- *
31893
- * @param config - SDK configuration object (wallet client or chain config)
31894
- * @example
31895
- * ```typescript
31896
- * // With wallet client
31897
- * const vana = new Vana({ walletClient });
31898
- *
31899
- * // With chain configuration
31900
- * const vana = new Vana({ chainId: 14800, account });
31901
- * ```
31902
- */
31903
- constructor(config: VanaConfig);
31904
- }
32611
+ declare function Vana(config: VanaConfigWithStorage): VanaBrowserImpl & StorageRequiredMarker;
32612
+ declare function Vana(config: VanaConfig): VanaBrowserImpl;
32613
+ /**
32614
+ * The type of a Vana SDK instance in browser environments.
32615
+ *
32616
+ * @see {@link Vana}
32617
+ */
32618
+ type VanaInstance = VanaBrowserImpl;
31905
32619
 
31906
- export { type $defs, type APIResponse, type AddRefinerParams, type AddRefinerResult, type AddSchemaParams, type AddSchemaResult, type AllKeys, ApiClient, type ApiClientConfig, type ApiResponse, AsyncQueue, type AsyncResult, type Awaited, type BaseConfig, BaseController, type BatchServerInfoResult, type BatchUploadParams, type BatchUploadResult, type BlockRange, BlockchainError, type Brand, BrowserPlatformAdapter, type Cache, type CacheConfig, type ChainConfig, type CheckPermissionParams, CircuitBreaker, type ConditionalOptional, type ConfigValidationOptions, type ConfigValidationResult, type ContractAddresses, type ContractCall, type ContractDeployment, ContractFactory, type ContractInfo, type ContractMethodParams, type ContractMethodReturnType, ContractNotFoundError, type Controller, type ControllerContext, type CreateOperationParams, type CreateOperationResponse, type CreateSchemaParams, type CreateSchemaResult, DEFAULT_ENCRYPTION_SEED, DEFAULT_IPFS_GATEWAY, DataController, type DataSchema, type DeepPartial, type DeepReadonly, type DeleteFileParams, type DeleteFileResult, type DownloadFileParams, type DownloadFileResult, type EncryptionInfo, EventEmitter, type EventFilter, type EventLog, type Factory, type FileAccessPermissions, type FileMetadata, type FileSharingConfig, type GasEstimate, type GenericRequest, type GenericResponse, type GenericTypedData, type GetFileParams, type GetOperationResponse, type GetUserFilesParams, type GetUserTrustedServersParams, type GetUserTrustedServersResult, GoogleDriveStorage, GrantExpiredError, type GrantFile, type GrantPermissionParams, GrantSchemaError, GrantValidationError, type GrantValidationOptions, type GrantValidationResult, type GrantedPermission, GranteeMismatchError, type HttpMethod, IPFS_GATEWAYS, type IdentityServerOutput, type IdentityServerResponse, type InitPersonalServerParams, InvalidConfigurationError, IpfsStorage, type MaybeArray, type MaybePromise, MemoryCache, type Middleware, MiddlewarePipeline, NetworkError, type NetworkInfo, type Nominal, type NonNullable, NonceError, type Observable, type Observer, type OmitByType, type OperationCreatedResponse, OperationNotAllowedError, type OptionalKeys, type PaginatedTrustedServers, type PaginationParams, type PaginationResult, type PartialExcept, type PermissionAnalytics, type PermissionCheckResult, PermissionError, type PermissionEvent, type PermissionGrantDomain, type PermissionGrantMessage, type PermissionGrantTypedData, type PermissionInfo, type PermissionInputMessage, type PermissionOperation, type PermissionParams, type PermissionQueryResult, type PermissionStatus, PermissionsController, PersonalServerError, type PersonalServerIdentity, type PersonalServerOutput, type PickByType, type PinataListResponse, type PinataPin, PinataStorage, type PinataUploadResponse, type Plugin, type PostRequestParams, type PromiseResult, ProtocolController, type QueryPermissionsParams, type RateLimitInfo, RateLimiter, type RateLimiterConfig, type Refiner, type RelayerCallbacks, type RelayerConfig, RelayerError, type RelayerErrorResponse, type RelayerMetrics, type RelayerQueueInfo, type RelayerRequestOptions, type RelayerStatus, type RelayerStorageResponse, type RelayerStoreParams, type RelayerSubmitParams, type RelayerTransactionResponse, type RelayerTransactionStatus, type RelayerWebhookConfig, type RelayerWebhookPayload, type ReplicateAPIResponse, type ReplicateStatus, type Repository, type RequestOptions, type RequireKeys, type RequiredExcept, type RetryConfig, RetryUtility, type RevokePermissionInput, type RevokePermissionParams, type RuntimeConfig, type Schema, SchemaValidationError, SchemaValidator, SerializationError, type Server, type components as ServerComponents, ServerController, type $defs as ServerDefs, type operations as ServerOperations, type paths as ServerPaths, ServerProxyStorage, type ServerTrustStatus, ServerUrlMismatchError, type webhooks as ServerWebhooks, type Service, SignatureError, type SimplifiedPermissionMessage, type StateMachine, type StatusInfo, type StorageConfig, StorageError, type StorageFile, type StorageListOptions, StorageManager, type StorageProvider, type StorageProviderConfig, type StorageUploadResult, type TimeRange, type TransactionOptions, type TransactionReceipt, type Transformer, type TrustServerInput, type TrustServerParams, type TrustServerTypedData, type TrustedServer, type TrustedServerInfo, type TrustedServerQueryMode, type TrustedServerQueryOptions, type UntrustServerInput, type UntrustServerParams, type UntrustServerTypedData, type UpdateSchemaIdParams, type UpdateSchemaIdResult, type UploadEncryptedFileResult, type UploadFileParams, type UploadFileResult, type UploadParams, type UploadProgress, type UploadResult, type UserFile, UserRejectedRequestError, type ValidationResult, type Validator, VanaBrowser as Vana, VanaBrowser, type VanaChain, type VanaChainConfig, type VanaChainId, type VanaConfig, type VanaContract, type VanaContract as VanaContractAbi, type VanaContractInstance, type VanaContractName, VanaError, type VanaPlatformAdapter, type WalletConfig, __contractCache, chains, checkGrantAccess, clearContractCache, type components, convertIpfsUrl, convertIpfsUrlWithFallbacks, createAndStoreGrant, createBrowserPlatformAdapter, createGrantFile, createPlatformAdapterSafe, createValidatedGrant, decryptUserData, decryptWithPrivateKey, decryptWithWalletPrivateKey, VanaBrowser as default, detectPlatform, encryptFileKey, encryptUserData, encryptWithWalletPublicKey, extractIpfsHash, fetchAndValidateSchema, fetchWithFallbacks, formatEth, formatNumber, formatToken, generateEncryptionKey, generateEncryptionKeyPair, generatePGPKeyPair, getAbi, getAllChains, getChainConfig, getContractAddress, getContractController, getContractInfo, getEncryptionParameters, getGatewayUrls, getGrantFileHash, getGrantTimeRemaining, getPlatformCapabilities, isAPIResponse, isChainConfig, isGrantExpired, isIdentityServerOutput, isIpfsUrl, isPersonalServerOutput, isPlatformSupported, isReplicateAPIResponse, isVanaChain, isVanaChainId, isWalletConfig, moksha, mokshaTestnet, type operations, parseReplicateOutput, type paths, retrieveAndValidateGrant, retrieveGrantFile, safeParseJSON, schemaValidator, shortenAddress, storeGrantFile, summarizeGrant, validateDataAgainstSchema, validateDataSchema, validateGrant, validateGrantExpiry, validateGrantFile, validateGranteeAccess, validateOperationAccess, vanaMainnet, type webhooks };
32620
+ export { type $defs, type APIResponse, type AddRefinerParams, type AddRefinerResult, type AddSchemaParams, type AddSchemaResult, type AllKeys, ApiClient, type ApiClientConfig, type ApiResponse, AsyncQueue, type AsyncResult, type AuthenticationErrorResponse, type Awaited, type BaseConfig, type BaseConfigWithStorage, BaseController, type BatchServerInfoResult, type BatchUploadParams, type BatchUploadResult, type BlockRange, BlockchainError, type BlockchainErrorResponse, type Brand, BrowserPlatformAdapter, type Cache, type CacheConfig, CallbackStorage, type ChainConfig, type ChainConfigWithStorage, type CheckPermissionParams, CircuitBreaker, type ComputeErrorResponse, type ConditionalOptional, type ConfigValidationOptions, type ConfigValidationResult, type ContractAddresses, type ContractCall, type ContractDeployment, ContractFactory, type ContractInfo, type ContractMethodParams, type ContractMethodReturnType, ContractNotFoundError, type Controller, type ControllerContext, type CreateOperationParams, type CreateOperationRequest, type CreateOperationResponse, type CreateSchemaParams, type CreateSchemaResult, DEFAULT_ENCRYPTION_SEED, DEFAULT_IPFS_GATEWAY, DataController, type DataSchema, type DecryptionErrorResponse, type DeepPartial, type DeepReadonly, type DeleteFileParams, type DeleteFileResult, type DownloadFileParams, type DownloadFileResult, type EncryptedPermissionParams, type EncryptedUploadParams, type EncryptionInfo, type ErrorResponse, EventEmitter, type EventFilter, type EventLog, type Factory, type FileAccessErrorResponse, type FileAccessPermissions, type FileMetadata, type FileSharingConfig, type GasEstimate, type GenericRequest, type GenericResponse, type GenericTypedData, type GetFileParams, type GetOperationResponse, type GetUserFilesParams, type GetUserPermissionsOptions, type GetUserTrustedServersParams, type GetUserTrustedServersResult, GoogleDriveStorage, GrantExpiredError, type GrantFile, type GrantPermissionParams, GrantSchemaError, GrantValidationError, type GrantValidationErrorResponse, type GrantValidationOptions, type GrantValidationResult, type GrantedPermission, GranteeMismatchError, type HttpMethod, IPFS_GATEWAYS, type IdentityResponseModel, type InitPersonalServerParams, type InternalServerErrorResponse, InvalidConfigurationError, IpfsStorage, type MaybeArray, type MaybePromise, MemoryCache, type Middleware, MiddlewarePipeline, NetworkError, type NetworkInfo, type Nominal, type NonNullable, NonceError, type NotFoundErrorResponse, type Observable, type Observer, type OmitByType, type OnChainPermissionGrant, type OperationErrorResponse, OperationNotAllowedError, type OptionalKeys, type PaginatedTrustedServers, type PaginationParams, type PaginationResult, type PartialExcept, type PermissionAnalytics, type PermissionCheckResult, PermissionError, type PermissionEvent, type PermissionGrantDomain, type PermissionGrantMessage, type PermissionGrantTypedData, type PermissionInfo, type PermissionInputMessage, type PermissionOperation, type PermissionParams, type PermissionQueryResult, type PermissionStatus, PermissionsController, PersonalServerError, type PersonalServerIdentity, type PersonalServerModel, type PickByType, type PinataListResponse, type PinataPin, PinataStorage, type PinataUploadResponse, type Plugin, type PostRequestParams, type PromiseResult, ProtocolController, type QueryPermissionsParams, type RateLimitInfo, RateLimiter, type RateLimiterConfig, type Refiner, type RelayerCallbacks, type RelayerConfig, RelayerError, type RelayerErrorResponse, type RelayerMetrics, type RelayerQueueInfo, type RelayerRequestOptions, type RelayerStatus, type RelayerStorageResponse, type RelayerStoreParams, type RelayerSubmitParams, type RelayerTransactionResponse, type RelayerTransactionStatus, type RelayerWebhookConfig, type RelayerWebhookPayload, type ReplicateAPIResponse, type ReplicateStatus, type Repository, type RequestOptions, type RequireKeys, type RequiredExcept, type RetryConfig, RetryUtility, type RevokePermissionInput, type RevokePermissionParams, type RuntimeConfig, type Schema, SchemaValidationError, SchemaValidator, SerializationError, type Server, type components as ServerComponents, ServerController, type $defs as ServerDefs, type operations as ServerOperations, type paths as ServerPaths, type ServerTrustStatus, ServerUrlMismatchError, type webhooks as ServerWebhooks, type Service, SignatureError, type SimplifiedPermissionMessage, type StateMachine, type StatusInfo, type StorageCallbacks, type StorageConfig, type StorageDownloadOptions, StorageError, type StorageFile, type StorageListOptions, type StorageListResult, StorageManager, type StorageProvider, type StorageProviderConfig, type StorageRequiredMarker, type StorageUploadResult, type TimeRange, type TransactionOptions, type TransactionReceipt, type Transformer, type TrustServerInput, type TrustServerParams, type TrustServerTypedData, type TrustedServer, type TrustedServerInfo, type TrustedServerQueryMode, type TrustedServerQueryOptions, type UnencryptedUploadParams, type UntrustServerInput, type UntrustServerParams, type UntrustServerTypedData, type UpdateSchemaIdParams, type UpdateSchemaIdResult, type UploadEncryptedFileResult, type UploadFileParams, type UploadFileResult, type UploadParams, type UploadProgress, type UploadResult, type UserFile, UserRejectedRequestError, type ValidationErrorResponse, type ValidationResult, type Validator, Vana, VanaBrowserImpl, type VanaChain, type VanaChainConfig, type VanaChainId, type VanaConfig, type VanaConfigWithStorage, type VanaContract, type VanaContract as VanaContractAbi, type VanaContractInstance, type VanaContractName, VanaCore, VanaCoreFactory, VanaError, type VanaInstance, type VanaPlatformAdapter, type WalletConfig, type WalletConfigWithStorage, __contractCache, chains, checkGrantAccess, clearContractCache, type components, convertIpfsUrl, convertIpfsUrlWithFallbacks, createAndStoreGrant, createBrowserPlatformAdapter, createGrantFile, createPlatformAdapterSafe, createValidatedGrant, decryptBlobWithSignedKey, decryptWithPrivateKey, decryptWithWalletPrivateKey, Vana as default, detectPlatform, encryptBlobWithSignedKey, encryptFileKey, encryptWithWalletPublicKey, extractIpfsHash, fetchAndValidateSchema, fetchWithFallbacks, formatEth, formatNumber, formatToken, generateEncryptionKey, generateEncryptionKeyPair, generatePGPKeyPair, getAbi, getAllChains, getChainConfig, getContractAddress, getContractController, getContractInfo, getEncryptionParameters, getGatewayUrls, getGrantFileHash, getGrantTimeRemaining, getPlatformCapabilities, hasStorageConfig, isAPIResponse, isChainConfig, isGrantExpired, isIpfsUrl, isPlatformSupported, isReplicateAPIResponse, isVanaChain, isVanaChainId, isWalletConfig, moksha, mokshaTestnet, type operations, parseReplicateOutput, type paths, retrieveAndValidateGrant, retrieveGrantFile, safeParseJSON, schemaValidator, shortenAddress, storeGrantFile, summarizeGrant, validateDataAgainstSchema, validateDataSchema, validateGrant, validateGrantExpiry, validateGrantFile, validateGranteeAccess, validateOperationAccess, vanaMainnet, type webhooks };