@opendatalabs/vana-sdk 0.1.0-alpha.761813a → 0.1.0-alpha.7e4db82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.js.map +1 -1
- package/dist/index.browser.d.ts +715 -207
- package/dist/index.browser.js +563 -411
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.cjs +566 -416
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +716 -208
- package/dist/index.node.d.ts +716 -208
- package/dist/index.node.js +562 -411
- package/dist/index.node.js.map +1 -1
- package/dist/platform.browser.js +1 -57
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +1 -57
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.js +1 -57
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +1 -57
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.js +1 -57
- package/dist/platform.node.js.map +1 -1
- package/package.json +10 -2
package/dist/index.browser.d.ts
CHANGED
|
@@ -158,37 +158,56 @@ declare class StorageError extends Error {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
* Represents
|
|
161
|
+
* Represents on-chain permission grant data without expensive off-chain resolution.
|
|
162
162
|
*
|
|
163
|
-
* This interface
|
|
164
|
-
*
|
|
165
|
-
*
|
|
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
|
|
179
|
+
interface OnChainPermissionGrant {
|
|
170
180
|
/** Unique identifier for the permission */
|
|
171
181
|
id: bigint;
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
|
|
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
|
-
/**
|
|
187
|
-
grantee: Address;
|
|
188
|
-
/** Whether the permission is still active */
|
|
198
|
+
/** Whether the permission is still active (not revoked) */
|
|
189
199
|
active: boolean;
|
|
190
|
-
|
|
191
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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 */
|
|
@@ -227,6 +246,8 @@ interface GrantPermissionParams$1 {
|
|
|
227
246
|
nonce?: bigint;
|
|
228
247
|
/** Optional expiration time for the permission */
|
|
229
248
|
expiresAt?: number;
|
|
249
|
+
/** Optional grantee ID to use instead of resolving from address */
|
|
250
|
+
granteeId?: number;
|
|
230
251
|
}
|
|
231
252
|
/**
|
|
232
253
|
* Parameters for revoking a previously granted data access permission.
|
|
@@ -340,6 +361,8 @@ interface PermissionInputMessage {
|
|
|
340
361
|
grant: string;
|
|
341
362
|
/** File IDs */
|
|
342
363
|
fileIds: bigint[];
|
|
364
|
+
/** Grantee ID */
|
|
365
|
+
granteeId: bigint;
|
|
343
366
|
}
|
|
344
367
|
/**
|
|
345
368
|
* Contract RevokePermissionInput structure
|
|
@@ -493,6 +516,41 @@ interface QueryPermissionsParams {
|
|
|
493
516
|
/** Offset for pagination */
|
|
494
517
|
offset?: number;
|
|
495
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* Granted permission details
|
|
521
|
+
*
|
|
522
|
+
* @category Permissions
|
|
523
|
+
*/
|
|
524
|
+
interface GrantedPermission {
|
|
525
|
+
/** Unique identifier for the permission */
|
|
526
|
+
id: bigint;
|
|
527
|
+
/** Array of file IDs that the permission applies to */
|
|
528
|
+
files: number[];
|
|
529
|
+
/** The type of operation being granted permission for */
|
|
530
|
+
operation: string;
|
|
531
|
+
/** Grant file reference (IPFS hash or URL) */
|
|
532
|
+
grant: string;
|
|
533
|
+
/** Address of the application granted permission */
|
|
534
|
+
grantee: Address;
|
|
535
|
+
/** Address of the user who granted permission */
|
|
536
|
+
grantor: Address;
|
|
537
|
+
/** Custom parameters for the operation */
|
|
538
|
+
parameters: Record<string, unknown>;
|
|
539
|
+
/** Whether the permission is still active */
|
|
540
|
+
active: boolean;
|
|
541
|
+
/** Data status for the permission */
|
|
542
|
+
dataStatus?: string;
|
|
543
|
+
/** Nonce used for the permission */
|
|
544
|
+
nonce?: number;
|
|
545
|
+
/** Timestamp when permission was granted */
|
|
546
|
+
grantedAt?: number;
|
|
547
|
+
/** Optional expiration timestamp */
|
|
548
|
+
expiresAt?: number;
|
|
549
|
+
/** Transaction hash of the grant transaction */
|
|
550
|
+
transactionHash?: string;
|
|
551
|
+
/** Block number when permission was granted */
|
|
552
|
+
blockNumber?: bigint;
|
|
553
|
+
}
|
|
496
554
|
/**
|
|
497
555
|
* Permission query result
|
|
498
556
|
*
|
|
@@ -715,6 +773,16 @@ interface ServerTrustStatus {
|
|
|
715
773
|
trustIndex?: number;
|
|
716
774
|
}
|
|
717
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Marker interface to indicate that a Vana instance has storage configured.
|
|
778
|
+
* Used for compile-time type safety to ensure storage-dependent methods
|
|
779
|
+
* are only called on properly configured instances.
|
|
780
|
+
*
|
|
781
|
+
* @category Configuration
|
|
782
|
+
*/
|
|
783
|
+
interface StorageRequiredMarker {
|
|
784
|
+
readonly __storageRequired: true;
|
|
785
|
+
}
|
|
718
786
|
/**
|
|
719
787
|
* Configuration for storage providers used by the SDK.
|
|
720
788
|
*
|
|
@@ -863,7 +931,7 @@ interface RelayerCallbacks {
|
|
|
863
931
|
storeGrantFile?: (grantData: GrantFile) => Promise<string>;
|
|
864
932
|
}
|
|
865
933
|
/**
|
|
866
|
-
* Base configuration interface
|
|
934
|
+
* Base configuration interface without storage requirements
|
|
867
935
|
*
|
|
868
936
|
* @category Configuration
|
|
869
937
|
*/
|
|
@@ -881,6 +949,42 @@ interface BaseConfig {
|
|
|
881
949
|
* Can be overridden per method call if needed.
|
|
882
950
|
*/
|
|
883
951
|
subgraphUrl?: string;
|
|
952
|
+
/**
|
|
953
|
+
* Optional default IPFS gateways to use for fetching files.
|
|
954
|
+
* These gateways will be used by default in fetchFromIPFS unless overridden per-call.
|
|
955
|
+
* If not provided, the SDK will use public gateways.
|
|
956
|
+
*
|
|
957
|
+
* @example ['https://gateway.pinata.cloud', 'https://ipfs.io']
|
|
958
|
+
*/
|
|
959
|
+
ipfsGateways?: string[];
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Base configuration interface that requires storage for storage-dependent operations
|
|
963
|
+
*
|
|
964
|
+
* @category Configuration
|
|
965
|
+
*/
|
|
966
|
+
interface BaseConfigWithStorage {
|
|
967
|
+
/**
|
|
968
|
+
* Optional relayer callback functions for handling gasless transactions.
|
|
969
|
+
* Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.
|
|
970
|
+
*/
|
|
971
|
+
relayerCallbacks?: RelayerCallbacks;
|
|
972
|
+
/** Required storage providers configuration for file upload/download */
|
|
973
|
+
storage: StorageConfig;
|
|
974
|
+
/**
|
|
975
|
+
* Optional subgraph URL for querying user files and permissions.
|
|
976
|
+
* If not provided, defaults to the built-in subgraph URL for the current chain.
|
|
977
|
+
* Can be overridden per method call if needed.
|
|
978
|
+
*/
|
|
979
|
+
subgraphUrl?: string;
|
|
980
|
+
/**
|
|
981
|
+
* Optional default IPFS gateways to use for fetching files.
|
|
982
|
+
* These gateways will be used by default in fetchFromIPFS unless overridden per-call.
|
|
983
|
+
* If not provided, the SDK will use public gateways.
|
|
984
|
+
*
|
|
985
|
+
* @example ['https://gateway.pinata.cloud', 'https://ipfs.io']
|
|
986
|
+
*/
|
|
987
|
+
ipfsGateways?: string[];
|
|
884
988
|
}
|
|
885
989
|
/**
|
|
886
990
|
* Configuration with wallet client
|
|
@@ -893,6 +997,17 @@ interface WalletConfig extends BaseConfig {
|
|
|
893
997
|
chain: VanaChain;
|
|
894
998
|
};
|
|
895
999
|
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Configuration with wallet client that requires storage
|
|
1002
|
+
*
|
|
1003
|
+
* @category Configuration
|
|
1004
|
+
*/
|
|
1005
|
+
interface WalletConfigWithStorage extends BaseConfigWithStorage {
|
|
1006
|
+
/** The viem WalletClient instance used for signing transactions */
|
|
1007
|
+
walletClient: WalletClient & {
|
|
1008
|
+
chain: VanaChain;
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
896
1011
|
/**
|
|
897
1012
|
* Configuration with chain and account details
|
|
898
1013
|
*
|
|
@@ -906,6 +1021,19 @@ interface ChainConfig extends BaseConfig {
|
|
|
906
1021
|
/** Optional account for signing transactions */
|
|
907
1022
|
account?: Account;
|
|
908
1023
|
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Configuration with chain and account details that requires storage
|
|
1026
|
+
*
|
|
1027
|
+
* @category Configuration
|
|
1028
|
+
*/
|
|
1029
|
+
interface ChainConfigWithStorage extends BaseConfigWithStorage {
|
|
1030
|
+
/** The chain ID for Vana network */
|
|
1031
|
+
chainId: VanaChainId;
|
|
1032
|
+
/** RPC URL for the chain (optional, will use default for the chain if not provided) */
|
|
1033
|
+
rpcUrl?: string;
|
|
1034
|
+
/** Optional account for signing transactions */
|
|
1035
|
+
account?: Account;
|
|
1036
|
+
}
|
|
909
1037
|
/**
|
|
910
1038
|
* Main configuration interface for initializing the Vana SDK.
|
|
911
1039
|
*
|
|
@@ -945,6 +1073,32 @@ interface ChainConfig extends BaseConfig {
|
|
|
945
1073
|
* ```
|
|
946
1074
|
*/
|
|
947
1075
|
type VanaConfig = WalletConfig | ChainConfig;
|
|
1076
|
+
/**
|
|
1077
|
+
* Configuration interface for Vana SDK that requires storage providers.
|
|
1078
|
+
*
|
|
1079
|
+
* Use this type when you need to ensure storage is configured for operations
|
|
1080
|
+
* like file uploads, permission grants without pre-stored URLs, or schema creation.
|
|
1081
|
+
*
|
|
1082
|
+
* @category Configuration
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```typescript
|
|
1085
|
+
* // Configuration that guarantees storage availability
|
|
1086
|
+
* const config: VanaConfigWithStorage = {
|
|
1087
|
+
* walletClient: createWalletClient({
|
|
1088
|
+
* account: privateKeyToAccount('0x...'),
|
|
1089
|
+
* chain: moksha,
|
|
1090
|
+
* transport: http()
|
|
1091
|
+
* }),
|
|
1092
|
+
* storage: {
|
|
1093
|
+
* providers: {
|
|
1094
|
+
* ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' })
|
|
1095
|
+
* },
|
|
1096
|
+
* defaultProvider: 'ipfs'
|
|
1097
|
+
* }
|
|
1098
|
+
* };
|
|
1099
|
+
* ```
|
|
1100
|
+
*/
|
|
1101
|
+
type VanaConfigWithStorage = WalletConfigWithStorage | ChainConfigWithStorage;
|
|
948
1102
|
/**
|
|
949
1103
|
* Runtime configuration information
|
|
950
1104
|
*
|
|
@@ -993,6 +1147,22 @@ declare function isWalletConfig(config: VanaConfig): config is WalletConfig;
|
|
|
993
1147
|
* ```
|
|
994
1148
|
*/
|
|
995
1149
|
declare function isChainConfig(config: VanaConfig): config is ChainConfig;
|
|
1150
|
+
/**
|
|
1151
|
+
* Validates whether a configuration has required storage providers.
|
|
1152
|
+
*
|
|
1153
|
+
* @param config - The configuration object to check
|
|
1154
|
+
* @returns True if the config has storage providers configured
|
|
1155
|
+
* @example
|
|
1156
|
+
* ```typescript
|
|
1157
|
+
* if (hasStorageConfig(config)) {
|
|
1158
|
+
* // Safe to use storage-dependent operations
|
|
1159
|
+
* await vana.data.uploadFile(file);
|
|
1160
|
+
* } else {
|
|
1161
|
+
* console.log('Storage not configured - some operations may fail');
|
|
1162
|
+
* }
|
|
1163
|
+
* ```
|
|
1164
|
+
*/
|
|
1165
|
+
declare function hasStorageConfig(config: VanaConfig): config is VanaConfigWithStorage;
|
|
996
1166
|
/**
|
|
997
1167
|
* Configuration validation options
|
|
998
1168
|
*
|
|
@@ -1144,6 +1314,10 @@ interface FileMetadata {
|
|
|
1144
1314
|
* @remarks
|
|
1145
1315
|
* This is the primary interface for uploading user data through the simplified `vana.data.upload()` method.
|
|
1146
1316
|
* It handles the complete workflow including encryption, storage, and blockchain registration.
|
|
1317
|
+
*
|
|
1318
|
+
* When using permissions with encryption enabled (default), you must provide the public key
|
|
1319
|
+
* for each permission recipient.
|
|
1320
|
+
*
|
|
1147
1321
|
* @example
|
|
1148
1322
|
* ```typescript
|
|
1149
1323
|
* // Basic file upload
|
|
@@ -1159,14 +1333,27 @@ interface FileMetadata {
|
|
|
1159
1333
|
* schemaId: 1
|
|
1160
1334
|
* });
|
|
1161
1335
|
*
|
|
1162
|
-
* // Upload with permissions for an app
|
|
1336
|
+
* // Upload with permissions for an app (encrypted - requires publicKey)
|
|
1163
1337
|
* const result = await vana.data.upload({
|
|
1164
1338
|
* content: "Data for AI analysis",
|
|
1165
1339
|
* filename: "analysis.txt",
|
|
1166
1340
|
* permissions: [{
|
|
1167
|
-
*
|
|
1341
|
+
* grantee: "0x1234...",
|
|
1168
1342
|
* operation: "llm_inference",
|
|
1169
|
-
* parameters: { model: "gpt-4" }
|
|
1343
|
+
* parameters: { model: "gpt-4" },
|
|
1344
|
+
* publicKey: "0x04..." // Required when encrypt is true (default)
|
|
1345
|
+
* }]
|
|
1346
|
+
* });
|
|
1347
|
+
*
|
|
1348
|
+
* // Upload without encryption (publicKey optional)
|
|
1349
|
+
* const result = await vana.data.upload({
|
|
1350
|
+
* content: "Public data",
|
|
1351
|
+
* filename: "public.txt",
|
|
1352
|
+
* encrypt: false,
|
|
1353
|
+
* permissions: [{
|
|
1354
|
+
* grantee: "0x1234...",
|
|
1355
|
+
* operation: "read",
|
|
1356
|
+
* parameters: {}
|
|
1170
1357
|
* }]
|
|
1171
1358
|
* });
|
|
1172
1359
|
* ```
|
|
@@ -1186,6 +1373,30 @@ interface UploadParams {
|
|
|
1186
1373
|
/** Optional storage provider name. */
|
|
1187
1374
|
providerName?: string;
|
|
1188
1375
|
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Upload parameters with encryption enabled (requires EncryptedPermissionParams).
|
|
1378
|
+
*
|
|
1379
|
+
* @remarks
|
|
1380
|
+
* This interface ensures type safety when using encrypted uploads with permissions.
|
|
1381
|
+
* @category Data Management
|
|
1382
|
+
*/
|
|
1383
|
+
interface EncryptedUploadParams extends Omit<UploadParams, "permissions" | "encrypt"> {
|
|
1384
|
+
/** Permissions with required public keys for encrypted data sharing. */
|
|
1385
|
+
permissions?: EncryptedPermissionParams[];
|
|
1386
|
+
/** Encryption is enabled. */
|
|
1387
|
+
encrypt: true;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Upload parameters with encryption disabled.
|
|
1391
|
+
*
|
|
1392
|
+
* @remarks
|
|
1393
|
+
* This interface is used when uploading unencrypted data.
|
|
1394
|
+
* @category Data Management
|
|
1395
|
+
*/
|
|
1396
|
+
interface UnencryptedUploadParams extends Omit<UploadParams, "encrypt"> {
|
|
1397
|
+
/** Encryption is disabled. */
|
|
1398
|
+
encrypt: false;
|
|
1399
|
+
}
|
|
1189
1400
|
/**
|
|
1190
1401
|
* Permission parameters for granting access during file upload.
|
|
1191
1402
|
*
|
|
@@ -1195,7 +1406,7 @@ interface UploadParams {
|
|
|
1195
1406
|
*/
|
|
1196
1407
|
interface PermissionParams {
|
|
1197
1408
|
/** The address of the application to grant permission to. */
|
|
1198
|
-
|
|
1409
|
+
grantee: Address;
|
|
1199
1410
|
/** The operation type (e.g., "llm_inference"). */
|
|
1200
1411
|
operation: string;
|
|
1201
1412
|
/** Additional parameters for the permission. */
|
|
@@ -1207,6 +1418,18 @@ interface PermissionParams {
|
|
|
1207
1418
|
/** Public key of the recipient to encrypt the data key for (required for upload with permissions). */
|
|
1208
1419
|
publicKey?: string;
|
|
1209
1420
|
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Permission parameters with required public key for encrypted uploads.
|
|
1423
|
+
*
|
|
1424
|
+
* @remarks
|
|
1425
|
+
* This type extends PermissionParams and makes publicKey required, ensuring
|
|
1426
|
+
* compile-time safety when permissions are used with encryption.
|
|
1427
|
+
* @category Data Management
|
|
1428
|
+
*/
|
|
1429
|
+
interface EncryptedPermissionParams extends PermissionParams {
|
|
1430
|
+
/** Public key of the recipient to encrypt the data key for. */
|
|
1431
|
+
publicKey: string;
|
|
1432
|
+
}
|
|
1210
1433
|
/**
|
|
1211
1434
|
* Result of the high-level upload operation.
|
|
1212
1435
|
*
|
|
@@ -2509,6 +2732,12 @@ interface ControllerContext$1 {
|
|
|
2509
2732
|
subgraphUrl?: string;
|
|
2510
2733
|
/** Adapts SDK functionality to the current runtime environment. */
|
|
2511
2734
|
platform: VanaPlatformAdapter;
|
|
2735
|
+
/** Validates that storage is available for storage-dependent operations. */
|
|
2736
|
+
validateStorageRequired?: () => void;
|
|
2737
|
+
/** Checks whether storage is configured without throwing an error. */
|
|
2738
|
+
hasStorage?: () => boolean;
|
|
2739
|
+
/** Default IPFS gateways to use for fetching files. */
|
|
2740
|
+
ipfsGateways?: string[];
|
|
2512
2741
|
}
|
|
2513
2742
|
/**
|
|
2514
2743
|
* Manages gasless data access permissions and trusted server registry operations.
|
|
@@ -2527,7 +2756,7 @@ interface ControllerContext$1 {
|
|
|
2527
2756
|
* ```typescript
|
|
2528
2757
|
* // Grant permission for an app to access your data
|
|
2529
2758
|
* const txHash = await vana.permissions.grant({
|
|
2530
|
-
*
|
|
2759
|
+
* grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
2531
2760
|
* operation: "llm_inference",
|
|
2532
2761
|
* parameters: { model: "gpt-4", maxTokens: 1000 },
|
|
2533
2762
|
* });
|
|
@@ -2565,7 +2794,7 @@ declare class PermissionsController {
|
|
|
2565
2794
|
* @example
|
|
2566
2795
|
* ```typescript
|
|
2567
2796
|
* const txHash = await vana.permissions.grant({
|
|
2568
|
-
*
|
|
2797
|
+
* grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
2569
2798
|
* operation: "llm_inference",
|
|
2570
2799
|
* parameters: {
|
|
2571
2800
|
* model: "gpt-4",
|
|
@@ -2591,7 +2820,7 @@ declare class PermissionsController {
|
|
|
2591
2820
|
* @example
|
|
2592
2821
|
* ```typescript
|
|
2593
2822
|
* const { preview, confirm } = await vana.permissions.prepareGrant({
|
|
2594
|
-
*
|
|
2823
|
+
* grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
2595
2824
|
* operation: "llm_inference",
|
|
2596
2825
|
* files: [1, 2, 3],
|
|
2597
2826
|
* parameters: { model: "gpt-4", prompt: "Analyze my social media data" }
|
|
@@ -2634,7 +2863,7 @@ declare class PermissionsController {
|
|
|
2634
2863
|
* @example
|
|
2635
2864
|
* ```typescript
|
|
2636
2865
|
* const { typedData, signature } = await vana.permissions.createAndSign({
|
|
2637
|
-
*
|
|
2866
|
+
* grantee: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
2638
2867
|
* operation: "data_analysis",
|
|
2639
2868
|
* parameters: { analysisType: "sentiment" },
|
|
2640
2869
|
* });
|
|
@@ -2739,12 +2968,13 @@ declare class PermissionsController {
|
|
|
2739
2968
|
* Composes the EIP-712 typed data for PermissionGrant (new simplified format).
|
|
2740
2969
|
*
|
|
2741
2970
|
* @param params - The parameters for composing the permission grant message
|
|
2742
|
-
* @param params.
|
|
2971
|
+
* @param params.grantee - The recipient address for the permission grant
|
|
2743
2972
|
* @param params.operation - The type of operation being granted permission for
|
|
2744
2973
|
* @param params.files - Array of file IDs that the permission applies to
|
|
2745
2974
|
* @param params.grantUrl - URL where the grant details are stored
|
|
2746
2975
|
* @param params.serializedParameters - Serialized parameters for the operation
|
|
2747
2976
|
* @param params.nonce - Unique number to prevent replay attacks
|
|
2977
|
+
* @param params.granteeId - The ID of the grantee from the registry
|
|
2748
2978
|
* @returns Promise resolving to the typed data structure
|
|
2749
2979
|
*/
|
|
2750
2980
|
private composePermissionGrantMessage;
|
|
@@ -2768,36 +2998,41 @@ declare class PermissionsController {
|
|
|
2768
2998
|
*/
|
|
2769
2999
|
private getUserAddress;
|
|
2770
3000
|
/**
|
|
2771
|
-
*
|
|
3001
|
+
* Gets on-chain permission grant data without expensive off-chain resolution.
|
|
2772
3002
|
*
|
|
2773
3003
|
* @remarks
|
|
2774
|
-
* This method
|
|
2775
|
-
*
|
|
2776
|
-
*
|
|
2777
|
-
*
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
2780
|
-
*
|
|
2781
|
-
*
|
|
2782
|
-
*
|
|
2783
|
-
*
|
|
3004
|
+
* This method provides a fast, performance-focused way to retrieve permission grants
|
|
3005
|
+
* by querying only the subgraph without making expensive IPFS or individual contract calls.
|
|
3006
|
+
* It eliminates the N+1 query problem of the legacy `getUserPermissions()` method.
|
|
3007
|
+
*
|
|
3008
|
+
* The returned data contains all on-chain information but does NOT include resolved
|
|
3009
|
+
* operation details, parameters, or file IDs. Use `retrieveGrantFile()` separately
|
|
3010
|
+
* for specific grants when detailed data is needed.
|
|
3011
|
+
*
|
|
3012
|
+
* **Performance**: Completes in ~100-500ms regardless of permission count.
|
|
3013
|
+
* **Reliability**: Single point of failure (subgraph) with clear RPC fallback path.
|
|
3014
|
+
*
|
|
3015
|
+
* @param options - Options for retrieving permissions (limit, subgraph URL)
|
|
3016
|
+
* @returns A Promise that resolves to an array of `OnChainPermissionGrant` objects
|
|
3017
|
+
* @throws {BlockchainError} When subgraph query fails
|
|
3018
|
+
* @throws {NetworkError} When network requests fail
|
|
2784
3019
|
* @example
|
|
2785
3020
|
* ```typescript
|
|
2786
|
-
* // Get all
|
|
2787
|
-
* const
|
|
3021
|
+
* // Fast: Get all on-chain permission data
|
|
3022
|
+
* const grants = await vana.permissions.getUserPermissionGrantsOnChain({ limit: 20 });
|
|
2788
3023
|
*
|
|
2789
|
-
*
|
|
2790
|
-
*
|
|
3024
|
+
* // Display in UI immediately
|
|
3025
|
+
* grants.forEach(grant => {
|
|
3026
|
+
* console.log(`Permission ${grant.id}: ${grant.grantUrl}`);
|
|
2791
3027
|
* });
|
|
2792
3028
|
*
|
|
2793
|
-
* //
|
|
2794
|
-
* const
|
|
3029
|
+
* // Lazy load detailed data for specific permission when user clicks
|
|
3030
|
+
* const grantFile = await retrieveGrantFile(grants[0].grantUrl);
|
|
3031
|
+
* console.log(`Operation: ${grantFile.operation}`);
|
|
3032
|
+
* console.log(`Parameters:`, grantFile.parameters);
|
|
2795
3033
|
* ```
|
|
2796
3034
|
*/
|
|
2797
|
-
|
|
2798
|
-
limit?: number;
|
|
2799
|
-
subgraphUrl?: string;
|
|
2800
|
-
}): Promise<GrantedPermission[]>;
|
|
3035
|
+
getUserPermissionGrantsOnChain(options?: GetUserPermissionsOptions): Promise<OnChainPermissionGrant[]>;
|
|
2801
3036
|
/**
|
|
2802
3037
|
* Gets all permission IDs for a specific file.
|
|
2803
3038
|
*
|
|
@@ -3316,14 +3551,21 @@ interface InitPersonalServerParams {
|
|
|
3316
3551
|
/** The user's wallet address */
|
|
3317
3552
|
userAddress: string;
|
|
3318
3553
|
}
|
|
3554
|
+
/**
|
|
3555
|
+
* Extended personal server identity information including connection details.
|
|
3556
|
+
* This combines the base PersonalServerModel with additional metadata
|
|
3557
|
+
* needed for client connections.
|
|
3558
|
+
*/
|
|
3319
3559
|
interface PersonalServerIdentity {
|
|
3320
|
-
/**
|
|
3560
|
+
/** Resource type identifier */
|
|
3561
|
+
kind: string;
|
|
3562
|
+
/** The server's Ethereum address */
|
|
3321
3563
|
address: string;
|
|
3322
|
-
/**
|
|
3564
|
+
/** The server's public key for encryption */
|
|
3323
3565
|
public_key: string;
|
|
3324
|
-
/**
|
|
3566
|
+
/** The base URL for connecting to this server */
|
|
3325
3567
|
base_url: string;
|
|
3326
|
-
/**
|
|
3568
|
+
/** Human-readable name for this server */
|
|
3327
3569
|
name: string;
|
|
3328
3570
|
}
|
|
3329
3571
|
|
|
@@ -3838,9 +4080,22 @@ interface components {
|
|
|
3838
4080
|
type $defs = Record<string, never>;
|
|
3839
4081
|
type operations = Record<string, never>;
|
|
3840
4082
|
|
|
4083
|
+
type CreateOperationRequest = components["schemas"]["CreateOperationRequest"];
|
|
3841
4084
|
type CreateOperationResponse = components["schemas"]["CreateOperationResponse"];
|
|
3842
4085
|
type GetOperationResponse = components["schemas"]["GetOperationResponse"];
|
|
3843
|
-
type
|
|
4086
|
+
type IdentityResponseModel = components["schemas"]["IdentityResponseModel"];
|
|
4087
|
+
type PersonalServerModel = components["schemas"]["PersonalServerModel"];
|
|
4088
|
+
type ErrorResponse = components["schemas"]["ErrorResponse"];
|
|
4089
|
+
type ValidationErrorResponse = components["schemas"]["ValidationErrorResponse"];
|
|
4090
|
+
type AuthenticationErrorResponse = components["schemas"]["AuthenticationErrorResponse"];
|
|
4091
|
+
type NotFoundErrorResponse = components["schemas"]["NotFoundErrorResponse"];
|
|
4092
|
+
type BlockchainErrorResponse = components["schemas"]["BlockchainErrorResponse"];
|
|
4093
|
+
type FileAccessErrorResponse = components["schemas"]["FileAccessErrorResponse"];
|
|
4094
|
+
type ComputeErrorResponse = components["schemas"]["ComputeErrorResponse"];
|
|
4095
|
+
type DecryptionErrorResponse = components["schemas"]["DecryptionErrorResponse"];
|
|
4096
|
+
type GrantValidationErrorResponse = components["schemas"]["GrantValidationErrorResponse"];
|
|
4097
|
+
type OperationErrorResponse = components["schemas"]["OperationErrorResponse"];
|
|
4098
|
+
type InternalServerErrorResponse = components["schemas"]["InternalServerErrorResponse"];
|
|
3844
4099
|
|
|
3845
4100
|
/**
|
|
3846
4101
|
* Types for external API responses used by the Vana SDK
|
|
@@ -3893,43 +4148,6 @@ interface ReplicateAPIResponse {
|
|
|
3893
4148
|
total_time?: number;
|
|
3894
4149
|
};
|
|
3895
4150
|
}
|
|
3896
|
-
/**
|
|
3897
|
-
* Identity Server Output Types
|
|
3898
|
-
* These define the expected structure of output from Vana's identity server
|
|
3899
|
-
*/
|
|
3900
|
-
/** Output from the identity server model */
|
|
3901
|
-
interface IdentityServerOutput {
|
|
3902
|
-
/** User's EVM address */
|
|
3903
|
-
user_address: string;
|
|
3904
|
-
/** Personal server information */
|
|
3905
|
-
personal_server: {
|
|
3906
|
-
/** Derived address for the personal server */
|
|
3907
|
-
address: string;
|
|
3908
|
-
/** Public key for encryption */
|
|
3909
|
-
public_key: string;
|
|
3910
|
-
};
|
|
3911
|
-
}
|
|
3912
|
-
/** Identity server response with typed output */
|
|
3913
|
-
interface IdentityServerResponse extends Omit<ReplicateAPIResponse, "output"> {
|
|
3914
|
-
/** Parsed identity server output */
|
|
3915
|
-
output?: IdentityServerOutput | string;
|
|
3916
|
-
}
|
|
3917
|
-
/**
|
|
3918
|
-
* Personal Server Output Types
|
|
3919
|
-
* These define the expected structure of output from Vana's personal server
|
|
3920
|
-
*/
|
|
3921
|
-
/** Output from the personal server model */
|
|
3922
|
-
interface PersonalServerOutput {
|
|
3923
|
-
/** User's EVM address */
|
|
3924
|
-
user_address: string;
|
|
3925
|
-
/** Identity information */
|
|
3926
|
-
identity: {
|
|
3927
|
-
/** Additional metadata */
|
|
3928
|
-
metadata?: Record<string, unknown>;
|
|
3929
|
-
/** Derived address (alternative location) */
|
|
3930
|
-
derivedAddress?: string;
|
|
3931
|
-
};
|
|
3932
|
-
}
|
|
3933
4151
|
/**
|
|
3934
4152
|
* Storage Provider API Types
|
|
3935
4153
|
*/
|
|
@@ -4002,38 +4220,6 @@ interface APIResponse<T = unknown> {
|
|
|
4002
4220
|
* ```
|
|
4003
4221
|
*/
|
|
4004
4222
|
declare function isReplicateAPIResponse(value: unknown): value is ReplicateAPIResponse;
|
|
4005
|
-
/**
|
|
4006
|
-
* Validates whether a value is a valid IdentityServerOutput.
|
|
4007
|
-
*
|
|
4008
|
-
* @param value - The value to check
|
|
4009
|
-
* @returns True if the value matches the IdentityServerOutput structure
|
|
4010
|
-
* @example
|
|
4011
|
-
* ```typescript
|
|
4012
|
-
* const output = response.output;
|
|
4013
|
-
*
|
|
4014
|
-
* if (isIdentityServerOutput(output)) {
|
|
4015
|
-
* console.log('User address:', output.user_address);
|
|
4016
|
-
* console.log('Server address:', output.personal_server.address);
|
|
4017
|
-
* }
|
|
4018
|
-
* ```
|
|
4019
|
-
*/
|
|
4020
|
-
declare function isIdentityServerOutput(value: unknown): value is IdentityServerOutput;
|
|
4021
|
-
/**
|
|
4022
|
-
* Validates whether a value is a valid PersonalServerOutput.
|
|
4023
|
-
*
|
|
4024
|
-
* @param value - The value to check
|
|
4025
|
-
* @returns True if the value matches the PersonalServerOutput structure
|
|
4026
|
-
* @example
|
|
4027
|
-
* ```typescript
|
|
4028
|
-
* const output = response.output;
|
|
4029
|
-
*
|
|
4030
|
-
* if (isPersonalServerOutput(output)) {
|
|
4031
|
-
* console.log('User address:', output.user_address);
|
|
4032
|
-
* console.log('Identity metadata:', output.identity.metadata);
|
|
4033
|
-
* }
|
|
4034
|
-
* ```
|
|
4035
|
-
*/
|
|
4036
|
-
declare function isPersonalServerOutput(value: unknown): value is PersonalServerOutput;
|
|
4037
4223
|
/**
|
|
4038
4224
|
* Validates whether a value is a valid APIResponse.
|
|
4039
4225
|
*
|
|
@@ -4066,7 +4252,7 @@ declare function isAPIResponse<T>(value: unknown): value is APIResponse<T>;
|
|
|
4066
4252
|
* @example
|
|
4067
4253
|
* ```typescript
|
|
4068
4254
|
* const jsonStr = '{"user_address": "0x123...", "identity": {}}';
|
|
4069
|
-
* const result = safeParseJSON(jsonStr,
|
|
4255
|
+
* const result = safeParseJSON(jsonStr, isAPIResponse);
|
|
4070
4256
|
*
|
|
4071
4257
|
* if (result) {
|
|
4072
4258
|
* console.log('Parsed server output:', result.user_address);
|
|
@@ -4085,7 +4271,7 @@ declare function safeParseJSON<T>(jsonString: string, typeGuard: (value: unknown
|
|
|
4085
4271
|
* @example
|
|
4086
4272
|
* ```typescript
|
|
4087
4273
|
* const response = await replicateClient.get(predictionId);
|
|
4088
|
-
* const output = parseReplicateOutput(response,
|
|
4274
|
+
* const output = parseReplicateOutput(response, isReplicateAPIResponse);
|
|
4089
4275
|
*
|
|
4090
4276
|
* if (output) {
|
|
4091
4277
|
* console.log('Identity server result:', output.user_address);
|
|
@@ -5095,7 +5281,7 @@ interface UserFile {
|
|
|
5095
5281
|
*/
|
|
5096
5282
|
interface GrantPermissionParams {
|
|
5097
5283
|
/** The on-chain identity of the application */
|
|
5098
|
-
|
|
5284
|
+
grantee: Address;
|
|
5099
5285
|
/** The class of computation, e.g., "llm_inference" */
|
|
5100
5286
|
operation: string;
|
|
5101
5287
|
/** Array of file IDs to grant permission for */
|
|
@@ -5104,6 +5290,12 @@ interface GrantPermissionParams {
|
|
|
5104
5290
|
parameters: Record<string, unknown>;
|
|
5105
5291
|
/** Optional pre-stored grant URL to avoid duplicate IPFS storage */
|
|
5106
5292
|
grantUrl?: string;
|
|
5293
|
+
/** Optional nonce for the permission */
|
|
5294
|
+
nonce?: bigint;
|
|
5295
|
+
/** Optional expiration time for the permission */
|
|
5296
|
+
expiresAt?: number;
|
|
5297
|
+
/** Optional grantee ID to use instead of resolving from address */
|
|
5298
|
+
granteeId?: number;
|
|
5107
5299
|
}
|
|
5108
5300
|
|
|
5109
5301
|
/**
|
|
@@ -5158,6 +5350,9 @@ declare class DataController {
|
|
|
5158
5350
|
* - Grants permissions to specified applications
|
|
5159
5351
|
* - Registers the file on the blockchain
|
|
5160
5352
|
*
|
|
5353
|
+
* When using permissions with encryption enabled (default), you must provide the public key
|
|
5354
|
+
* for each permission recipient.
|
|
5355
|
+
*
|
|
5161
5356
|
* @param params - Upload parameters including content, filename, schema, and permissions
|
|
5162
5357
|
* @returns Promise resolving to upload results with file ID and transaction hash
|
|
5163
5358
|
* @throws {Error} When wallet is not connected or storage is not configured
|
|
@@ -5178,19 +5373,85 @@ declare class DataController {
|
|
|
5178
5373
|
* schemaId: 1
|
|
5179
5374
|
* });
|
|
5180
5375
|
*
|
|
5181
|
-
* // Upload with permissions
|
|
5376
|
+
* // Upload with permissions (encrypted - requires publicKey)
|
|
5182
5377
|
* const result = await vana.data.upload({
|
|
5183
5378
|
* content: "Data for AI analysis",
|
|
5184
5379
|
* filename: "analysis.txt",
|
|
5185
5380
|
* permissions: [{
|
|
5186
|
-
*
|
|
5381
|
+
* grantee: "0x1234...",
|
|
5187
5382
|
* operation: "llm_inference",
|
|
5188
|
-
* parameters: { model: "gpt-4" }
|
|
5383
|
+
* parameters: { model: "gpt-4" },
|
|
5384
|
+
* publicKey: "0x04..." // Required when encrypt is true (default)
|
|
5385
|
+
* }]
|
|
5386
|
+
* });
|
|
5387
|
+
*
|
|
5388
|
+
* // Upload without encryption
|
|
5389
|
+
* const result = await vana.data.upload({
|
|
5390
|
+
* content: "Public data",
|
|
5391
|
+
* filename: "public.txt",
|
|
5392
|
+
* encrypt: false,
|
|
5393
|
+
* permissions: [{
|
|
5394
|
+
* grantee: "0x1234...",
|
|
5395
|
+
* operation: "read",
|
|
5396
|
+
* parameters: {}
|
|
5189
5397
|
* }]
|
|
5190
5398
|
* });
|
|
5191
5399
|
* ```
|
|
5192
5400
|
*/
|
|
5401
|
+
upload(params: EncryptedUploadParams): Promise<UploadResult>;
|
|
5402
|
+
upload(params: UnencryptedUploadParams): Promise<UploadResult>;
|
|
5193
5403
|
upload(params: UploadParams): Promise<UploadResult>;
|
|
5404
|
+
/**
|
|
5405
|
+
* Decrypts a file owned by the user using their wallet signature.
|
|
5406
|
+
*
|
|
5407
|
+
* @remarks
|
|
5408
|
+
* This is the high-level convenience method for decrypting user files, serving as the
|
|
5409
|
+
* symmetrical counterpart to the `upload` method. It handles the complete decryption
|
|
5410
|
+
* workflow including key generation, URL protocol detection, content fetching, and
|
|
5411
|
+
* decryption.
|
|
5412
|
+
*
|
|
5413
|
+
* The method automatically:
|
|
5414
|
+
* - Generates the decryption key from the user's wallet signature
|
|
5415
|
+
* - Determines the appropriate fetch method based on the file URL protocol
|
|
5416
|
+
* - Fetches the encrypted content from IPFS or standard HTTP URLs
|
|
5417
|
+
* - Decrypts the content using the generated key
|
|
5418
|
+
*
|
|
5419
|
+
* For IPFS URLs, the method uses gateway fallback for improved reliability. For
|
|
5420
|
+
* standard HTTP URLs, it uses a simple fetch. If you need custom authentication
|
|
5421
|
+
* headers or specific gateway configurations, use the low-level primitives directly.
|
|
5422
|
+
*
|
|
5423
|
+
* @param file - The user file to decrypt (typically from getUserFiles)
|
|
5424
|
+
* @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
|
|
5425
|
+
* @returns Promise resolving to the decrypted file content as a Blob
|
|
5426
|
+
* @throws {Error} When the wallet is not connected
|
|
5427
|
+
* @throws {Error} When fetching the encrypted content fails
|
|
5428
|
+
* @throws {Error} When decryption fails (wrong key or corrupted data)
|
|
5429
|
+
* @example
|
|
5430
|
+
* ```typescript
|
|
5431
|
+
* // Basic file decryption
|
|
5432
|
+
* const files = await vana.data.getUserFiles({ owner: userAddress });
|
|
5433
|
+
* const decryptedBlob = await vana.data.decryptFile(files[0]);
|
|
5434
|
+
*
|
|
5435
|
+
* // Convert to text
|
|
5436
|
+
* const text = await decryptedBlob.text();
|
|
5437
|
+
* console.log('Decrypted content:', text);
|
|
5438
|
+
*
|
|
5439
|
+
* // Convert to JSON
|
|
5440
|
+
* const json = JSON.parse(await decryptedBlob.text());
|
|
5441
|
+
* console.log('Decrypted data:', json);
|
|
5442
|
+
*
|
|
5443
|
+
* // With custom encryption seed
|
|
5444
|
+
* const decryptedBlob = await vana.data.decryptFile(
|
|
5445
|
+
* files[0],
|
|
5446
|
+
* "My custom encryption seed"
|
|
5447
|
+
* );
|
|
5448
|
+
*
|
|
5449
|
+
* // Save to file (in Node.js)
|
|
5450
|
+
* const buffer = await decryptedBlob.arrayBuffer();
|
|
5451
|
+
* fs.writeFileSync('decrypted-file.txt', Buffer.from(buffer));
|
|
5452
|
+
* ```
|
|
5453
|
+
*/
|
|
5454
|
+
decryptFile(file: UserFile$1, encryptionSeed?: string): Promise<Blob>;
|
|
5194
5455
|
/**
|
|
5195
5456
|
* Retrieves all data files owned by a specific user address.
|
|
5196
5457
|
*
|
|
@@ -5377,19 +5638,6 @@ declare class DataController {
|
|
|
5377
5638
|
* 3. Returning the assigned file ID and storage URL
|
|
5378
5639
|
*/
|
|
5379
5640
|
uploadEncryptedFileWithSchema(encryptedFile: Blob, schemaId: number, filename?: string, providerName?: string): Promise<UploadEncryptedFileResult>;
|
|
5380
|
-
/**
|
|
5381
|
-
* Decrypts a file that was encrypted using the Vana protocol.
|
|
5382
|
-
*
|
|
5383
|
-
* @param file - The UserFile object containing the file URL and metadata
|
|
5384
|
-
* @param encryptionSeed - Optional custom encryption seed (defaults to Vana standard)
|
|
5385
|
-
* @returns Promise resolving to the decrypted file as a Blob
|
|
5386
|
-
*
|
|
5387
|
-
* This method handles the complete flow of:
|
|
5388
|
-
* 1. Generating the encryption key from the user's wallet signature
|
|
5389
|
-
* 2. Fetching the encrypted file from the stored URL
|
|
5390
|
-
* 3. Decrypting the file using the canonical Vana decryption method
|
|
5391
|
-
*/
|
|
5392
|
-
decryptFile(file: UserFile$1, encryptionSeed?: string): Promise<Blob>;
|
|
5393
5641
|
/**
|
|
5394
5642
|
* Registers a file URL directly on the blockchain with a schema ID.
|
|
5395
5643
|
*
|
|
@@ -5404,13 +5652,6 @@ declare class DataController {
|
|
|
5404
5652
|
fileId: number;
|
|
5405
5653
|
transactionHash: Address;
|
|
5406
5654
|
}>;
|
|
5407
|
-
/**
|
|
5408
|
-
* Converts IPFS and Google Drive URLs to direct download URLs for fetching.
|
|
5409
|
-
*
|
|
5410
|
-
* @param url - The URL to convert to a direct download URL
|
|
5411
|
-
* @returns The converted direct download URL or the original URL if not a special URL
|
|
5412
|
-
*/
|
|
5413
|
-
private convertToDownloadUrl;
|
|
5414
5655
|
/**
|
|
5415
5656
|
* Gets the user's address from the wallet client.
|
|
5416
5657
|
*
|
|
@@ -5565,6 +5806,73 @@ declare class DataController {
|
|
|
5565
5806
|
* @returns Promise resolving to the decrypted file data
|
|
5566
5807
|
*/
|
|
5567
5808
|
decryptFileWithPermission(file: UserFile$1, privateKey: string, account?: Address): Promise<Blob>;
|
|
5809
|
+
/**
|
|
5810
|
+
* Simple network-agnostic fetch utility for retrieving file content.
|
|
5811
|
+
*
|
|
5812
|
+
* @remarks
|
|
5813
|
+
* This is a thin wrapper around the global fetch API that returns the response as a Blob.
|
|
5814
|
+
* It provides a consistent interface for fetching encrypted content before decryption.
|
|
5815
|
+
* For IPFS URLs, consider using fetchFromIPFS for better reliability.
|
|
5816
|
+
*
|
|
5817
|
+
* @param url - The URL to fetch content from
|
|
5818
|
+
* @returns Promise resolving to the fetched content as a Blob
|
|
5819
|
+
* @throws {Error} When the fetch fails or returns a non-ok response
|
|
5820
|
+
*
|
|
5821
|
+
* @example
|
|
5822
|
+
* ```typescript
|
|
5823
|
+
* // Fetch and decrypt a file
|
|
5824
|
+
* const encryptionKey = await generateEncryptionKey(walletClient);
|
|
5825
|
+
* const encryptedBlob = await vana.data.fetch(file.url);
|
|
5826
|
+
* const decryptedBlob = await decryptBlob(encryptedBlob, encryptionKey, platform);
|
|
5827
|
+
*
|
|
5828
|
+
* // With custom headers for authentication
|
|
5829
|
+
* const response = await fetch(file.url, {
|
|
5830
|
+
* headers: { 'Authorization': 'Bearer token' }
|
|
5831
|
+
* });
|
|
5832
|
+
* const encryptedBlob = await response.blob();
|
|
5833
|
+
* ```
|
|
5834
|
+
*/
|
|
5835
|
+
fetch(url: string): Promise<Blob>;
|
|
5836
|
+
/**
|
|
5837
|
+
* Specialized IPFS fetcher with gateway fallback mechanism.
|
|
5838
|
+
*
|
|
5839
|
+
* @remarks
|
|
5840
|
+
* This method provides robust IPFS content fetching by trying multiple gateways
|
|
5841
|
+
* in sequence until one succeeds. It supports both ipfs:// URLs and raw CIDs.
|
|
5842
|
+
*
|
|
5843
|
+
* The default gateway list includes public gateways, but you should provide
|
|
5844
|
+
* your own gateways for production use to ensure reliability and privacy.
|
|
5845
|
+
*
|
|
5846
|
+
* @param url - The IPFS URL (ipfs://...) or CID to fetch
|
|
5847
|
+
* @param options - Optional configuration
|
|
5848
|
+
* @param options.gateways - Array of IPFS gateway URLs to try (must end with /)
|
|
5849
|
+
* @returns Promise resolving to the fetched content as a Blob
|
|
5850
|
+
* @throws {Error} When all gateways fail to fetch the content
|
|
5851
|
+
*
|
|
5852
|
+
* @example
|
|
5853
|
+
* ```typescript
|
|
5854
|
+
* // Fetch from IPFS with custom gateways
|
|
5855
|
+
* const encryptedBlob = await vana.data.fetchFromIPFS(file.url, {
|
|
5856
|
+
* gateways: [
|
|
5857
|
+
* 'https://my-private-gateway.com/ipfs/',
|
|
5858
|
+
* 'https://dweb.link/ipfs/',
|
|
5859
|
+
* 'https://ipfs.io/ipfs/'
|
|
5860
|
+
* ]
|
|
5861
|
+
* });
|
|
5862
|
+
*
|
|
5863
|
+
* // Decrypt the fetched content
|
|
5864
|
+
* const encryptionKey = await generateEncryptionKey(walletClient);
|
|
5865
|
+
* const decryptedBlob = await decryptBlob(encryptedBlob, encryptionKey, platform);
|
|
5866
|
+
*
|
|
5867
|
+
* // With raw CID
|
|
5868
|
+
* const blob = await vana.data.fetchFromIPFS('QmXxx...', {
|
|
5869
|
+
* gateways: ['https://ipfs.io/ipfs/']
|
|
5870
|
+
* });
|
|
5871
|
+
* ```
|
|
5872
|
+
*/
|
|
5873
|
+
fetchFromIPFS(url: string, options?: {
|
|
5874
|
+
gateways?: string[];
|
|
5875
|
+
}): Promise<Blob>;
|
|
5568
5876
|
/**
|
|
5569
5877
|
* Validates a data schema against the Vana meta-schema.
|
|
5570
5878
|
*
|
|
@@ -30753,6 +31061,45 @@ declare class ProtocolController {
|
|
|
30753
31061
|
getChainName(): string;
|
|
30754
31062
|
}
|
|
30755
31063
|
|
|
31064
|
+
/**
|
|
31065
|
+
* Factory functions for creating VanaCore instances with proper type safety
|
|
31066
|
+
*/
|
|
31067
|
+
declare class VanaCoreFactory {
|
|
31068
|
+
/**
|
|
31069
|
+
* Creates a VanaCore instance that enforces storage requirements at compile time.
|
|
31070
|
+
* Use this factory when you know you'll need storage-dependent operations.
|
|
31071
|
+
*
|
|
31072
|
+
* @param platform - The platform adapter for environment-specific operations
|
|
31073
|
+
* @param config - Configuration that includes required storage providers
|
|
31074
|
+
* @returns VanaCore instance with storage validation
|
|
31075
|
+
* @example
|
|
31076
|
+
* ```typescript
|
|
31077
|
+
* const vanaCore = VanaCoreFactory.createWithStorage(platformAdapter, {
|
|
31078
|
+
* walletClient: myWalletClient,
|
|
31079
|
+
* storage: {
|
|
31080
|
+
* providers: { ipfs: new IPFSStorage() },
|
|
31081
|
+
* defaultProvider: 'ipfs'
|
|
31082
|
+
* }
|
|
31083
|
+
* });
|
|
31084
|
+
* ```
|
|
31085
|
+
*/
|
|
31086
|
+
static createWithStorage(platform: VanaPlatformAdapter, config: VanaConfigWithStorage): VanaCore & StorageRequiredMarker;
|
|
31087
|
+
/**
|
|
31088
|
+
* Creates a VanaCore instance without storage requirements.
|
|
31089
|
+
* Storage-dependent operations will fail at runtime if not configured.
|
|
31090
|
+
*
|
|
31091
|
+
* @param platform - The platform adapter for environment-specific operations
|
|
31092
|
+
* @param config - Basic configuration without required storage
|
|
31093
|
+
* @returns VanaCore instance
|
|
31094
|
+
* @example
|
|
31095
|
+
* ```typescript
|
|
31096
|
+
* const vanaCore = VanaCoreFactory.create(platformAdapter, {
|
|
31097
|
+
* walletClient: myWalletClient
|
|
31098
|
+
* });
|
|
31099
|
+
* ```
|
|
31100
|
+
*/
|
|
31101
|
+
static create(platform: VanaPlatformAdapter, config: VanaConfig): VanaCore;
|
|
31102
|
+
}
|
|
30756
31103
|
/**
|
|
30757
31104
|
* Provides the core SDK functionality for interacting with the Vana network.
|
|
30758
31105
|
*
|
|
@@ -30761,8 +31108,11 @@ declare class ProtocolController {
|
|
|
30761
31108
|
* adapter to handle environment-specific operations. It initializes all controllers
|
|
30762
31109
|
* and manages shared context between them.
|
|
30763
31110
|
*
|
|
31111
|
+
* The class uses TypeScript overloading to enforce storage requirements at compile time.
|
|
31112
|
+
* When storage is required for certain operations, the constructor will fail fast at runtime.
|
|
31113
|
+
*
|
|
30764
31114
|
* For public usage, use the platform-specific Vana classes that extend this core:
|
|
30765
|
-
* - Use `
|
|
31115
|
+
* - Use `Vana({config)` from the main package import
|
|
30766
31116
|
* @example
|
|
30767
31117
|
* ```typescript
|
|
30768
31118
|
* // Direct instantiation (typically used internally)
|
|
@@ -30787,12 +31137,18 @@ declare class VanaCore {
|
|
|
30787
31137
|
protected platform: VanaPlatformAdapter;
|
|
30788
31138
|
private readonly relayerCallbacks?;
|
|
30789
31139
|
private readonly storageManager?;
|
|
31140
|
+
private readonly hasRequiredStorage;
|
|
31141
|
+
private readonly ipfsGateways?;
|
|
30790
31142
|
/**
|
|
30791
31143
|
* Initializes a new VanaCore client instance with the provided configuration.
|
|
30792
31144
|
*
|
|
30793
31145
|
* @remarks
|
|
30794
31146
|
* The constructor validates the configuration, initializes storage providers if configured,
|
|
30795
31147
|
* creates wallet and public clients, and sets up all SDK controllers with shared context.
|
|
31148
|
+
*
|
|
31149
|
+
* IMPORTANT: This constructor will validate storage requirements at runtime to fail fast.
|
|
31150
|
+
* Methods that require storage will throw runtime errors if storage is not configured.
|
|
31151
|
+
*
|
|
30796
31152
|
* @param platform - The platform adapter for environment-specific operations
|
|
30797
31153
|
* @param config - The configuration object specifying wallet or chain settings
|
|
30798
31154
|
* @throws {InvalidConfigurationError} When the configuration is invalid or incomplete
|
|
@@ -30805,6 +31161,48 @@ declare class VanaCore {
|
|
|
30805
31161
|
* ```
|
|
30806
31162
|
*/
|
|
30807
31163
|
constructor(platform: VanaPlatformAdapter, config: VanaConfig);
|
|
31164
|
+
/**
|
|
31165
|
+
* Validates that storage is available for storage-dependent operations.
|
|
31166
|
+
* This method enforces the fail-fast principle by checking storage availability
|
|
31167
|
+
* at method call time rather than during expensive operations.
|
|
31168
|
+
*
|
|
31169
|
+
* @throws {InvalidConfigurationError} When storage is required but not configured
|
|
31170
|
+
* @example
|
|
31171
|
+
* ```typescript
|
|
31172
|
+
* // This will throw if storage is not configured
|
|
31173
|
+
* vana.validateStorageRequired();
|
|
31174
|
+
* await vana.data.uploadFile(file); // Safe to proceed
|
|
31175
|
+
* ```
|
|
31176
|
+
*/
|
|
31177
|
+
validateStorageRequired(): void;
|
|
31178
|
+
/**
|
|
31179
|
+
* Checks whether storage is configured without throwing an error.
|
|
31180
|
+
*
|
|
31181
|
+
* @returns True if storage is properly configured
|
|
31182
|
+
* @example
|
|
31183
|
+
* ```typescript
|
|
31184
|
+
* if (vana.hasStorage()) {
|
|
31185
|
+
* await vana.data.uploadFile(file);
|
|
31186
|
+
* } else {
|
|
31187
|
+
* console.warn('Storage not configured - using pre-stored URLs only');
|
|
31188
|
+
* }
|
|
31189
|
+
* ```
|
|
31190
|
+
*/
|
|
31191
|
+
hasStorage(): boolean;
|
|
31192
|
+
/**
|
|
31193
|
+
* Type guard to check if this instance has storage enabled at compile time.
|
|
31194
|
+
* Use this when you need TypeScript to understand that storage is available.
|
|
31195
|
+
*
|
|
31196
|
+
* @returns True if storage is configured, with type narrowing
|
|
31197
|
+
* @example
|
|
31198
|
+
* ```typescript
|
|
31199
|
+
* if (vana.isStorageEnabled()) {
|
|
31200
|
+
* // TypeScript knows storage is available here
|
|
31201
|
+
* await vana.data.uploadFile(file);
|
|
31202
|
+
* }
|
|
31203
|
+
* ```
|
|
31204
|
+
*/
|
|
31205
|
+
isStorageEnabled(): this is VanaCore & StorageRequiredMarker;
|
|
30808
31206
|
/**
|
|
30809
31207
|
* Validates the provided configuration object against all requirements.
|
|
30810
31208
|
*
|
|
@@ -30892,21 +31290,21 @@ declare class VanaCore {
|
|
|
30892
31290
|
*/
|
|
30893
31291
|
getPlatformAdapter(): VanaPlatformAdapter;
|
|
30894
31292
|
/**
|
|
30895
|
-
* Encrypts
|
|
31293
|
+
* Encrypts data using the Vana protocol standard encryption.
|
|
30896
31294
|
* This method automatically uses the correct platform adapter for the current environment.
|
|
30897
31295
|
*
|
|
30898
31296
|
* @param data The data to encrypt (string or Blob)
|
|
30899
|
-
* @param
|
|
31297
|
+
* @param key The key to use as encryption key
|
|
30900
31298
|
* @returns The encrypted data as Blob
|
|
30901
31299
|
* @example
|
|
30902
31300
|
* ```typescript
|
|
30903
31301
|
* const encryptionKey = await generateEncryptionKey(walletClient);
|
|
30904
|
-
* const encrypted = await vana.
|
|
31302
|
+
* const encrypted = await vana.encryptBlob("sensitive data", encryptionKey);
|
|
30905
31303
|
* ```
|
|
30906
31304
|
*/
|
|
30907
|
-
|
|
31305
|
+
encryptBlob(data: string | Blob, key: string): Promise<Blob>;
|
|
30908
31306
|
/**
|
|
30909
|
-
* Decrypts
|
|
31307
|
+
* Decrypts data that was encrypted using the Vana protocol.
|
|
30910
31308
|
* This method automatically uses the correct platform adapter for the current environment.
|
|
30911
31309
|
*
|
|
30912
31310
|
* @param encryptedData The encrypted data (string or Blob)
|
|
@@ -30915,11 +31313,11 @@ declare class VanaCore {
|
|
|
30915
31313
|
* @example
|
|
30916
31314
|
* ```typescript
|
|
30917
31315
|
* const encryptionKey = await generateEncryptionKey(walletClient);
|
|
30918
|
-
* const decrypted = await vana.
|
|
31316
|
+
* const decrypted = await vana.decryptBlob(encryptedData, encryptionKey);
|
|
30919
31317
|
* const text = await decrypted.text();
|
|
30920
31318
|
* ```
|
|
30921
31319
|
*/
|
|
30922
|
-
|
|
31320
|
+
decryptBlob(encryptedData: string | Blob, walletSignature: string): Promise<Blob>;
|
|
30923
31321
|
}
|
|
30924
31322
|
|
|
30925
31323
|
/**
|
|
@@ -31120,23 +31518,44 @@ declare function getEncryptionParameters(platformAdapter: VanaPlatformAdapter):
|
|
|
31120
31518
|
*/
|
|
31121
31519
|
declare function decryptWithPrivateKey(encryptedData: string, privateKey: string, platformAdapter: VanaPlatformAdapter): Promise<string>;
|
|
31122
31520
|
/**
|
|
31123
|
-
*
|
|
31521
|
+
* Encrypts data using a signed key generated from the user's wallet signature.
|
|
31522
|
+
*
|
|
31523
|
+
* @remarks
|
|
31524
|
+
* This is a pure cryptographic primitive that encrypts data using the Vana protocol's
|
|
31525
|
+
* standard encryption method. The key parameter must be a signature generated by the
|
|
31526
|
+
* `generateEncryptionKey` utility - this ensures deterministic key generation from the
|
|
31527
|
+
* user's wallet, enabling the same key to be regenerated for decryption.
|
|
31528
|
+
*
|
|
31529
|
+
* This function uses password-based encryption with the signature as the password,
|
|
31530
|
+
* providing symmetric encryption that can be decrypted with the same signature.
|
|
31124
31531
|
*
|
|
31125
31532
|
* @param data The data to encrypt (string or Blob)
|
|
31126
|
-
* @param
|
|
31127
|
-
* @param platformAdapter
|
|
31533
|
+
* @param key The signed key from `generateEncryptionKey` - MUST be a wallet signature
|
|
31534
|
+
* @param platformAdapter The platform adapter for crypto operations
|
|
31128
31535
|
* @returns The encrypted data as Blob
|
|
31129
|
-
|
|
31130
|
-
declare function encryptUserData(data: string | Blob, walletSignature: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
|
|
31131
|
-
/**
|
|
31132
|
-
* Decrypt user data using PGP with platform-appropriate configuration
|
|
31536
|
+
* @throws {Error} When encryption fails
|
|
31133
31537
|
*
|
|
31134
|
-
* @
|
|
31135
|
-
*
|
|
31136
|
-
*
|
|
31137
|
-
*
|
|
31538
|
+
* @example
|
|
31539
|
+
* ```typescript
|
|
31540
|
+
* // Generate the encryption key from wallet signature
|
|
31541
|
+
* const encryptionKey = await generateEncryptionKey(walletClient);
|
|
31542
|
+
*
|
|
31543
|
+
* // Encrypt data with the signed key
|
|
31544
|
+
* const encryptedBlob = await encryptBlobWithSignedKey(
|
|
31545
|
+
* "My sensitive data",
|
|
31546
|
+
* encryptionKey,
|
|
31547
|
+
* platformAdapter
|
|
31548
|
+
* );
|
|
31549
|
+
*
|
|
31550
|
+
* // Later, decrypt with the same key
|
|
31551
|
+
* const decryptedBlob = await decryptBlobWithSignedKey(
|
|
31552
|
+
* encryptedBlob,
|
|
31553
|
+
* encryptionKey,
|
|
31554
|
+
* platformAdapter
|
|
31555
|
+
* );
|
|
31556
|
+
* ```
|
|
31138
31557
|
*/
|
|
31139
|
-
declare function
|
|
31558
|
+
declare function encryptBlobWithSignedKey(data: string | Blob, key: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
|
|
31140
31559
|
/**
|
|
31141
31560
|
* Generate a new key pair for asymmetric encryption
|
|
31142
31561
|
*
|
|
@@ -31165,6 +31584,55 @@ declare function generatePGPKeyPair(platformAdapter: VanaPlatformAdapter, option
|
|
|
31165
31584
|
publicKey: string;
|
|
31166
31585
|
privateKey: string;
|
|
31167
31586
|
}>;
|
|
31587
|
+
/**
|
|
31588
|
+
* Decrypts data using a signed key generated from the user's wallet signature.
|
|
31589
|
+
*
|
|
31590
|
+
* @remarks
|
|
31591
|
+
* This is a pure cryptographic primitive for decrypting data that was encrypted using
|
|
31592
|
+
* `encryptBlobWithSignedKey`. It is network-agnostic and only handles decryption - it does
|
|
31593
|
+
* not fetch data from any URL or make network requests. To decrypt a file from a URL, you
|
|
31594
|
+
* must first fetch the encrypted blob using one of the fetch utilities, then pass it to
|
|
31595
|
+
* this function.
|
|
31596
|
+
*
|
|
31597
|
+
* The key parameter must be the same signature that was used for encryption, typically
|
|
31598
|
+
* generated by the `generateEncryptionKey` utility. This ensures that only the user who
|
|
31599
|
+
* encrypted the data (or someone with the same wallet signature) can decrypt it.
|
|
31600
|
+
*
|
|
31601
|
+
* @param encryptedData The encrypted data to decrypt (string or Blob)
|
|
31602
|
+
* @param key The signed key from `generateEncryptionKey` - MUST be the same wallet signature used for encryption
|
|
31603
|
+
* @param platformAdapter The platform adapter for crypto operations
|
|
31604
|
+
* @returns Promise resolving to the decrypted blob
|
|
31605
|
+
* @throws {Error} When decryption fails due to wrong key or corrupted data
|
|
31606
|
+
*
|
|
31607
|
+
* @example
|
|
31608
|
+
* ```typescript
|
|
31609
|
+
* // Generate the same encryption key used for encryption
|
|
31610
|
+
* const encryptionKey = await generateEncryptionKey(walletClient);
|
|
31611
|
+
*
|
|
31612
|
+
* // Fetch and decrypt using the high-level API
|
|
31613
|
+
* const file = await vana.data.getUserFiles({ owner: "0x..." })[0];
|
|
31614
|
+
* const decryptedBlob = await vana.data.decryptFile(file);
|
|
31615
|
+
*
|
|
31616
|
+
* // Or use the low-level primitives directly
|
|
31617
|
+
* const encryptedBlob = await vana.data.fetch(file.url);
|
|
31618
|
+
* const decryptedBlob = await decryptBlobWithSignedKey(
|
|
31619
|
+
* encryptedBlob,
|
|
31620
|
+
* encryptionKey,
|
|
31621
|
+
* platformAdapter
|
|
31622
|
+
* );
|
|
31623
|
+
*
|
|
31624
|
+
* // With IPFS gateway fallback
|
|
31625
|
+
* const encryptedBlob = await vana.data.fetchFromIPFS(file.url, {
|
|
31626
|
+
* gateways: ['https://my-gateway.com/ipfs/', 'https://ipfs.io/ipfs/']
|
|
31627
|
+
* });
|
|
31628
|
+
* const decryptedBlob = await decryptBlobWithSignedKey(
|
|
31629
|
+
* encryptedBlob,
|
|
31630
|
+
* encryptionKey,
|
|
31631
|
+
* platformAdapter
|
|
31632
|
+
* );
|
|
31633
|
+
* ```
|
|
31634
|
+
*/
|
|
31635
|
+
declare function decryptBlobWithSignedKey(encryptedData: string | Blob, key: string, platformAdapter: VanaPlatformAdapter): Promise<Blob>;
|
|
31168
31636
|
|
|
31169
31637
|
/**
|
|
31170
31638
|
* Format a bigint or BigNumber to a regular number
|
|
@@ -31214,11 +31682,42 @@ declare function createGrantFile(params: GrantPermissionParams$1): GrantFile;
|
|
|
31214
31682
|
*/
|
|
31215
31683
|
declare function storeGrantFile(grantFile: GrantFile, relayerUrl: string): Promise<string>;
|
|
31216
31684
|
/**
|
|
31217
|
-
* Retrieves
|
|
31685
|
+
* Retrieves detailed grant file data from IPFS or HTTP storage.
|
|
31686
|
+
*
|
|
31687
|
+
* @remarks
|
|
31688
|
+
* **This is Step 2 of the performant two-step permission API.**
|
|
31689
|
+
*
|
|
31690
|
+
* Use this method to resolve detailed permission data (operation, parameters, etc.)
|
|
31691
|
+
* for specific grants after first getting the fast on-chain data using
|
|
31692
|
+
* `getUserPermissionGrantsOnChain()`. This design eliminates N+1 query problems
|
|
31693
|
+
* by allowing selective lazy-loading of expensive off-chain data.
|
|
31694
|
+
*
|
|
31695
|
+
* **Performance**: Single network request per grant file (typically 100-500ms).
|
|
31696
|
+
* **Reliability**: Tries multiple IPFS gateways as fallbacks if primary URL fails.
|
|
31697
|
+
*
|
|
31698
|
+
* @param grantUrl - The grant file URL from OnChainPermissionGrant.grantUrl
|
|
31699
|
+
* @param _relayerUrl - URL of the relayer service (optional, unused)
|
|
31700
|
+
* @returns Promise resolving to the complete grant file with operation details
|
|
31701
|
+
* @throws {NetworkError} When all retrieval attempts fail
|
|
31702
|
+
* @throws {SerializationError} When grant file format is invalid
|
|
31703
|
+
* @example
|
|
31704
|
+
* ```typescript
|
|
31705
|
+
* // Step 1: Fast on-chain data (no N+1 queries)
|
|
31706
|
+
* const grants = await vana.permissions.getUserPermissionGrantsOnChain();
|
|
31707
|
+
*
|
|
31708
|
+
* // Step 2: Lazy-load details for specific grant when needed
|
|
31709
|
+
* const grantFile = await retrieveGrantFile(grants[0].grantUrl);
|
|
31710
|
+
*
|
|
31711
|
+
* console.log(`Operation: ${grantFile.operation}`);
|
|
31712
|
+
* console.log(`Grantee: ${grantFile.grantee}`);
|
|
31713
|
+
* console.log(`Parameters:`, grantFile.parameters);
|
|
31218
31714
|
*
|
|
31219
|
-
*
|
|
31220
|
-
*
|
|
31221
|
-
*
|
|
31715
|
+
* // Only fetch details for grants user actually wants to see
|
|
31716
|
+
* for (const grant of selectedGrants) {
|
|
31717
|
+
* const details = await retrieveGrantFile(grant.grantUrl);
|
|
31718
|
+
* displayGrantDetails(details);
|
|
31719
|
+
* }
|
|
31720
|
+
* ```
|
|
31222
31721
|
*/
|
|
31223
31722
|
declare function retrieveGrantFile(grantUrl: string, _relayerUrl?: string): Promise<GrantFile>;
|
|
31224
31723
|
/**
|
|
@@ -31945,39 +32444,48 @@ declare class ApiClient {
|
|
|
31945
32444
|
}
|
|
31946
32445
|
|
|
31947
32446
|
/**
|
|
31948
|
-
*
|
|
31949
|
-
*
|
|
32447
|
+
* Internal implementation class for browser environments.
|
|
32448
|
+
* This class is not exported directly - use the Vana factory function instead.
|
|
32449
|
+
*/
|
|
32450
|
+
declare class VanaBrowserImpl extends VanaCore {
|
|
32451
|
+
constructor(config: VanaConfig);
|
|
32452
|
+
}
|
|
32453
|
+
/**
|
|
32454
|
+
* Creates a new Vana SDK instance configured for browser environments.
|
|
31950
32455
|
*
|
|
32456
|
+
* This function automatically provides the correct TypeScript types based on your configuration:
|
|
32457
|
+
* - With storage config: All methods including storage-dependent ones are available
|
|
32458
|
+
* - Without storage: Storage-dependent methods are not available at compile time
|
|
32459
|
+
*
|
|
32460
|
+
* @param config - The configuration object containing wallet client and optional storage settings
|
|
32461
|
+
* @returns A Vana SDK instance configured for browser use
|
|
31951
32462
|
* @example
|
|
31952
32463
|
* ```typescript
|
|
31953
|
-
*
|
|
32464
|
+
* // With storage - all methods available
|
|
32465
|
+
* const vana = Vana({
|
|
32466
|
+
* walletClient,
|
|
32467
|
+
* storage: { providers: { ipfs: new IPFSStorage() }, defaultProvider: 'ipfs' }
|
|
32468
|
+
* });
|
|
32469
|
+
* await vana.data.uploadFile(file); // ✅ Works - TypeScript knows storage is available
|
|
31954
32470
|
*
|
|
31955
|
-
* //
|
|
31956
|
-
* const
|
|
32471
|
+
* // Without storage - storage methods unavailable at compile time
|
|
32472
|
+
* const vanaNoStorage = Vana({ walletClient });
|
|
32473
|
+
* // await vanaNoStorage.data.uploadFile(file); // ❌ TypeScript error
|
|
31957
32474
|
*
|
|
31958
|
-
* //
|
|
31959
|
-
*
|
|
31960
|
-
*
|
|
31961
|
-
*
|
|
31962
|
-
*
|
|
31963
|
-
* });
|
|
32475
|
+
* // Runtime check still available
|
|
32476
|
+
* if (vanaNoStorage.isStorageEnabled()) {
|
|
32477
|
+
* // TypeScript now knows storage methods are safe to use
|
|
32478
|
+
* await vanaNoStorage.data.uploadFile(file); // ✅ Works
|
|
32479
|
+
* }
|
|
31964
32480
|
* ```
|
|
31965
32481
|
*/
|
|
31966
|
-
declare
|
|
31967
|
-
|
|
31968
|
-
|
|
31969
|
-
|
|
31970
|
-
|
|
31971
|
-
|
|
31972
|
-
|
|
31973
|
-
|
|
31974
|
-
* const vana = new Vana({ walletClient });
|
|
31975
|
-
*
|
|
31976
|
-
* // With chain configuration
|
|
31977
|
-
* const vana = new Vana({ chainId: 14800, account });
|
|
31978
|
-
* ```
|
|
31979
|
-
*/
|
|
31980
|
-
constructor(config: VanaConfig);
|
|
31981
|
-
}
|
|
32482
|
+
declare function Vana(config: VanaConfigWithStorage): VanaBrowserImpl & StorageRequiredMarker;
|
|
32483
|
+
declare function Vana(config: VanaConfig): VanaBrowserImpl;
|
|
32484
|
+
/**
|
|
32485
|
+
* The type of a Vana SDK instance in browser environments.
|
|
32486
|
+
*
|
|
32487
|
+
* @see {@link Vana}
|
|
32488
|
+
*/
|
|
32489
|
+
type VanaInstance = VanaBrowserImpl;
|
|
31982
32490
|
|
|
31983
|
-
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
|
|
32491
|
+
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, 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, 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 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 };
|