@opendatalabs/vana-sdk 0.1.0-alpha.8fd7ef5 → 0.1.0-alpha.b390e7f

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.
@@ -926,6 +926,121 @@ interface RelayerCallbacks {
926
926
  */
927
927
  storeGrantFile?: (grantData: GrantFile) => Promise<string>;
928
928
  }
929
+ /**
930
+ * Storage callback functions for flexible storage operations.
931
+ *
932
+ * Instead of hardcoding storage behavior (HTTP endpoints, etc.), users can provide
933
+ * custom callback functions to handle storage operations in any way they choose.
934
+ * This pattern matches the relayer callbacks approach, providing maximum flexibility.
935
+ *
936
+ * @category Configuration
937
+ * @example
938
+ * ```typescript
939
+ * const storageCallbacks: StorageCallbacks = {
940
+ * async upload(blob, filename, metadata) {
941
+ * // Custom implementation - could be HTTP, S3, local filesystem, etc.
942
+ * const formData = new FormData();
943
+ * formData.append('file', blob, filename);
944
+ * const response = await fetch('/api/storage/upload', {
945
+ * method: 'POST',
946
+ * body: formData
947
+ * });
948
+ * const data = await response.json();
949
+ * return {
950
+ * url: data.url,
951
+ * size: blob.size,
952
+ * contentType: blob.type,
953
+ * metadata: data.metadata
954
+ * };
955
+ * },
956
+ *
957
+ * async download(identifier) {
958
+ * const response = await fetch(`/api/storage/download/${identifier}`);
959
+ * return response.blob();
960
+ * }
961
+ * };
962
+ * ```
963
+ */
964
+ interface StorageCallbacks {
965
+ /**
966
+ * Upload a blob to storage
967
+ *
968
+ * @param blob - The data to upload
969
+ * @param filename - Optional filename hint
970
+ * @param metadata - Optional metadata for the upload
971
+ * @returns Upload result with identifier and metadata
972
+ */
973
+ upload: (blob: Blob, filename?: string, metadata?: Record<string, unknown>) => Promise<StorageUploadResult>;
974
+ /**
975
+ * Download data from storage
976
+ *
977
+ * @param identifier - The storage identifier (could be URL, hash, path, or any unique ID)
978
+ * @param options - Optional download options
979
+ * @returns The downloaded data as a Blob
980
+ */
981
+ download: (identifier: string, options?: StorageDownloadOptions) => Promise<Blob>;
982
+ /**
983
+ * List stored items (optional)
984
+ *
985
+ * @param prefix - Optional prefix to filter results
986
+ * @param options - Optional listing options
987
+ * @returns Array of storage items with metadata
988
+ */
989
+ list?: (prefix?: string, options?: StorageListOptions) => Promise<StorageListResult>;
990
+ /**
991
+ * Delete a stored item (optional)
992
+ *
993
+ * @param identifier - The storage identifier to delete
994
+ * @returns Promise that resolves to true if deletion succeeded
995
+ */
996
+ delete?: (identifier: string) => Promise<boolean>;
997
+ /**
998
+ * Extract identifier from a URL or return as-is (optional)
999
+ * Used for backward compatibility with URL-based systems
1000
+ *
1001
+ * @param url - The URL to extract from
1002
+ * @returns The extracted identifier
1003
+ */
1004
+ extractIdentifier?: (url: string) => string;
1005
+ }
1006
+ /**
1007
+ * Options for storage download operations
1008
+ *
1009
+ * @category Configuration
1010
+ */
1011
+ interface StorageDownloadOptions {
1012
+ /** Optional HTTP headers */
1013
+ headers?: Record<string, string>;
1014
+ /** Optional abort signal for cancellation */
1015
+ signal?: AbortSignal;
1016
+ /** Optional byte range for partial downloads */
1017
+ range?: {
1018
+ start?: number;
1019
+ end?: number;
1020
+ };
1021
+ }
1022
+ /**
1023
+ * Result from storage list operations
1024
+ *
1025
+ * @category Configuration
1026
+ */
1027
+ interface StorageListResult {
1028
+ /** Array of storage items */
1029
+ items: Array<{
1030
+ /** Item identifier */
1031
+ identifier: string;
1032
+ /** Item size in bytes */
1033
+ size?: number;
1034
+ /** Last modified timestamp */
1035
+ lastModified?: Date;
1036
+ /** Item metadata */
1037
+ metadata?: Record<string, unknown>;
1038
+ }>;
1039
+ /** Continuation token for pagination */
1040
+ continuationToken?: string;
1041
+ /** Whether more results are available */
1042
+ hasMore?: boolean;
1043
+ }
929
1044
  /**
930
1045
  * Base configuration interface without storage requirements
931
1046
  *
@@ -2321,88 +2436,96 @@ declare class PinataStorage implements StorageProvider {
2321
2436
  private isValidCID;
2322
2437
  }
2323
2438
 
2324
- interface ServerProxyConfig {
2325
- /** Server endpoint for file uploads */
2326
- uploadUrl: string;
2327
- /** Server endpoint for file downloads */
2328
- downloadUrl: string;
2329
- }
2330
2439
  /**
2331
- * Delegates storage operations to your server endpoints
2440
+ * Storage provider that delegates all operations to user-provided callbacks.
2332
2441
  *
2333
- * @remarks
2334
- * This provider is completely agnostic about the actual storage backend used by
2335
- * your server. It simply proxies upload and download requests to your configured
2336
- * endpoints, allowing you to implement any storage strategy (IPFS, S3, local filesystem, etc.)
2337
- * on the server side while maintaining a consistent client interface.
2442
+ * This provider follows the same flexible pattern as relayer callbacks,
2443
+ * allowing users to implement storage operations in any way they choose
2444
+ * (HTTP, WebSocket, direct cloud APIs, local filesystem, etc.).
2338
2445
  *
2339
2446
  * @category Storage
2340
- *
2341
2447
  * @example
2342
2448
  * ```typescript
2343
- * const serverStorage = new ServerProxyStorage({
2344
- * uploadUrl: "/api/files/upload",
2345
- * downloadUrl: "/api/files/download"
2346
- * });
2347
- *
2348
- * // Upload file through your server
2349
- * const identifier = await serverStorage.upload(fileBlob, { name: "document.pdf" });
2449
+ * // HTTP-based implementation
2450
+ * const httpCallbacks: StorageCallbacks = {
2451
+ * async upload(blob, filename) {
2452
+ * const formData = new FormData();
2453
+ * formData.append('file', blob, filename);
2454
+ * const response = await fetch('/api/storage/upload', {
2455
+ * method: 'POST',
2456
+ * body: formData
2457
+ * });
2458
+ * const data = await response.json();
2459
+ * return {
2460
+ * url: data.url,
2461
+ * size: blob.size,
2462
+ * contentType: blob.type
2463
+ * };
2464
+ * },
2465
+ * async download(identifier) {
2466
+ * const response = await fetch(`/api/storage/download/${identifier}`);
2467
+ * return response.blob();
2468
+ * }
2469
+ * };
2350
2470
  *
2351
- * // Download file through your server
2352
- * const file = await serverStorage.download(identifier);
2471
+ * const storage = new CallbackStorage(httpCallbacks);
2472
+ *
2473
+ * // Direct S3 implementation
2474
+ * const s3Callbacks: StorageCallbacks = {
2475
+ * async upload(blob, filename) {
2476
+ * const url = await getPresignedUploadUrl(filename);
2477
+ * await fetch(url, { method: 'PUT', body: blob });
2478
+ * return {
2479
+ * url: `s3://my-bucket/${filename}`,
2480
+ * size: blob.size,
2481
+ * contentType: blob.type
2482
+ * };
2483
+ * },
2484
+ * async download(identifier) {
2485
+ * const url = await getPresignedDownloadUrl(identifier);
2486
+ * const response = await fetch(url);
2487
+ * return response.blob();
2488
+ * }
2489
+ * };
2353
2490
  * ```
2354
2491
  */
2355
- declare class ServerProxyStorage implements StorageProvider {
2356
- private config;
2357
- constructor(config: ServerProxyConfig);
2492
+ declare class CallbackStorage implements StorageProvider {
2493
+ private readonly callbacks;
2494
+ constructor(callbacks: StorageCallbacks);
2358
2495
  /**
2359
- * Uploads a file through your server endpoint
2496
+ * Upload a file using the provided callback
2360
2497
  *
2361
- * @remarks
2362
- * This method sends the file to your configured upload endpoint via FormData.
2363
- * Your server is responsible for handling the actual storage implementation
2364
- * and must return a JSON response with `success: true` and an `identifier` field.
2365
- *
2366
- * @param file - The file to upload
2367
- * @param filename - Optional custom filename
2368
- * @returns Promise that resolves to the server-provided identifier
2369
- * @throws {StorageError} When the upload fails or server returns an error
2370
- *
2371
- * @example
2372
- * ```typescript
2373
- * const identifier = await serverStorage.upload(fileBlob, { name: "report.pdf" });
2374
- * console.log("File uploaded with identifier:", identifier);
2375
- * ```
2498
+ * @param file - The blob to upload
2499
+ * @param filename - Optional filename for the upload
2500
+ * @returns The upload result with URL and metadata
2376
2501
  */
2377
2502
  upload(file: Blob, filename?: string): Promise<StorageUploadResult>;
2378
2503
  /**
2379
- * Downloads a file through your server endpoint
2504
+ * Download a file using the provided callback
2380
2505
  *
2381
- * @remarks
2382
- * This method sends the identifier to your configured download endpoint via POST request.
2383
- * Your server is responsible for retrieving the file from your storage backend
2384
- * and returning the file content as a blob response.
2506
+ * @param url - The URL or identifier to download
2507
+ * @returns The downloaded blob
2508
+ */
2509
+ download(url: string): Promise<Blob>;
2510
+ /**
2511
+ * List files using the provided callback (if available)
2385
2512
  *
2386
- * @param url - The server-provided URL or identifier from upload
2387
- * @returns Promise that resolves to the downloaded file content
2388
- * @throws {StorageError} When the download fails or file is not found
2513
+ * @param options - Optional list options including filters and pagination
2514
+ * @returns Array of storage files
2515
+ */
2516
+ list(options?: StorageListOptions): Promise<StorageFile[]>;
2517
+ /**
2518
+ * Delete a file using the provided callback (if available)
2389
2519
  *
2390
- * @example
2391
- * ```typescript
2392
- * const fileBlob = await serverStorage.download("file-123");
2393
- * const url = URL.createObjectURL(fileBlob);
2394
- * ```
2520
+ * @param url - The URL or identifier to delete
2521
+ * @returns True if deletion succeeded
2395
2522
  */
2396
- download(url: string): Promise<Blob>;
2397
- list(_options?: StorageListOptions): Promise<StorageFile[]>;
2398
- delete(_url: string): Promise<boolean>;
2523
+ delete(url: string): Promise<boolean>;
2399
2524
  /**
2400
- * Extract identifier from URL or return as-is
2525
+ * Get provider configuration
2401
2526
  *
2402
- * @param url - URL or identifier string
2403
- * @returns identifier string
2527
+ * @returns Provider configuration metadata
2404
2528
  */
2405
- private extractIdentifierFromUrl;
2406
2529
  getConfig(): StorageProviderConfig;
2407
2530
  }
2408
2531
 
@@ -32477,4 +32600,4 @@ declare function Vana(config: VanaConfig): VanaBrowserImpl;
32477
32600
  */
32478
32601
  type VanaInstance = VanaBrowserImpl;
32479
32602
 
32480
- 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, 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 };
32603
+ 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 };
@@ -39279,175 +39279,151 @@ var PinataStorage = class {
39279
39279
  }
39280
39280
  };
39281
39281
 
39282
- // src/storage/providers/server-proxy.ts
39283
- var ServerProxyStorage = class {
39284
- constructor(config) {
39285
- this.config = config;
39286
- if (!config.uploadUrl) {
39287
- throw new StorageError(
39288
- "Upload URL is required",
39289
- "MISSING_UPLOAD_URL",
39290
- "server-proxy"
39291
- );
39292
- }
39293
- if (!config.downloadUrl) {
39294
- throw new StorageError(
39295
- "Download URL is required",
39296
- "MISSING_DOWNLOAD_URL",
39297
- "server-proxy"
39282
+ // src/storage/providers/callback-storage.ts
39283
+ var CallbackStorage = class {
39284
+ constructor(callbacks) {
39285
+ this.callbacks = callbacks;
39286
+ if (!callbacks.upload || !callbacks.download) {
39287
+ throw new Error(
39288
+ "CallbackStorage requires both upload and download callbacks"
39298
39289
  );
39299
39290
  }
39300
39291
  }
39301
39292
  /**
39302
- * Uploads a file through your server endpoint
39303
- *
39304
- * @remarks
39305
- * This method sends the file to your configured upload endpoint via FormData.
39306
- * Your server is responsible for handling the actual storage implementation
39307
- * and must return a JSON response with `success: true` and an `identifier` field.
39293
+ * Upload a file using the provided callback
39308
39294
  *
39309
- * @param file - The file to upload
39310
- * @param filename - Optional custom filename
39311
- * @returns Promise that resolves to the server-provided identifier
39312
- * @throws {StorageError} When the upload fails or server returns an error
39313
- *
39314
- * @example
39315
- * ```typescript
39316
- * const identifier = await serverStorage.upload(fileBlob, { name: "report.pdf" });
39317
- * console.log("File uploaded with identifier:", identifier);
39318
- * ```
39295
+ * @param file - The blob to upload
39296
+ * @param filename - Optional filename for the upload
39297
+ * @returns The upload result with URL and metadata
39319
39298
  */
39320
39299
  async upload(file, filename) {
39321
39300
  try {
39322
- const formData = new FormData();
39323
- formData.append("file", file);
39324
- if (filename) {
39325
- formData.append("name", filename);
39326
- }
39327
- const response = await fetch(this.config.uploadUrl, {
39328
- method: "POST",
39329
- body: formData
39330
- });
39331
- if (!response.ok) {
39332
- const _errorText = await response.text();
39333
- throw new StorageError(
39334
- `Server upload failed: ${response.status} ${response.statusText}`,
39335
- "UPLOAD_FAILED",
39336
- "server-proxy"
39337
- );
39338
- }
39339
- const result = await response.json();
39340
- if (!result.success) {
39341
- throw new StorageError(
39342
- `Upload failed: ${result.error || "Unknown server error"}`,
39343
- "UPLOAD_FAILED",
39344
- "server-proxy"
39345
- );
39346
- }
39347
- if (!result.identifier) {
39301
+ const result = await this.callbacks.upload(file, filename);
39302
+ if (!result.url || result.url.trim() === "") {
39348
39303
  throw new StorageError(
39349
- "Server upload succeeded but no identifier returned",
39350
- "NO_IDENTIFIER_RETURNED",
39351
- "server-proxy"
39304
+ "Upload callback returned invalid result: missing or empty url",
39305
+ "INVALID_UPLOAD_RESULT",
39306
+ "callback-storage"
39352
39307
  );
39353
39308
  }
39354
- return {
39355
- url: result.url || result.identifier,
39356
- size: file.size,
39357
- contentType: file.type || "application/octet-stream"
39358
- };
39309
+ return result;
39359
39310
  } catch (error) {
39360
39311
  if (error instanceof StorageError) {
39361
39312
  throw error;
39362
39313
  }
39363
39314
  throw new StorageError(
39364
- `Server proxy upload error: ${error instanceof Error ? error.message : "Unknown error"}`,
39315
+ `Upload failed: ${error instanceof Error ? error.message : String(error)}`,
39365
39316
  "UPLOAD_ERROR",
39366
- "server-proxy"
39317
+ "callback-storage",
39318
+ { cause: error instanceof Error ? error : void 0 }
39367
39319
  );
39368
39320
  }
39369
39321
  }
39370
39322
  /**
39371
- * Downloads a file through your server endpoint
39323
+ * Download a file using the provided callback
39372
39324
  *
39373
- * @remarks
39374
- * This method sends the identifier to your configured download endpoint via POST request.
39375
- * Your server is responsible for retrieving the file from your storage backend
39376
- * and returning the file content as a blob response.
39377
- *
39378
- * @param url - The server-provided URL or identifier from upload
39379
- * @returns Promise that resolves to the downloaded file content
39380
- * @throws {StorageError} When the download fails or file is not found
39381
- *
39382
- * @example
39383
- * ```typescript
39384
- * const fileBlob = await serverStorage.download("file-123");
39385
- * const url = URL.createObjectURL(fileBlob);
39386
- * ```
39325
+ * @param url - The URL or identifier to download
39326
+ * @returns The downloaded blob
39387
39327
  */
39388
39328
  async download(url) {
39389
39329
  try {
39390
- const identifier = this.extractIdentifierFromUrl(url);
39391
- const response = await fetch(this.config.downloadUrl, {
39392
- method: "POST",
39393
- headers: {
39394
- "Content-Type": "application/json"
39395
- },
39396
- body: JSON.stringify({ identifier })
39397
- });
39398
- if (!response.ok) {
39399
- const _errorText = await response.text();
39330
+ const identifier = this.callbacks.extractIdentifier ? this.callbacks.extractIdentifier(url) : url;
39331
+ const blob = await this.callbacks.download(identifier);
39332
+ if (!(blob instanceof Blob)) {
39400
39333
  throw new StorageError(
39401
- `Server download failed: ${response.status} ${response.statusText}`,
39402
- "DOWNLOAD_FAILED",
39403
- "server-proxy"
39334
+ "Download callback returned invalid result: expected Blob",
39335
+ "INVALID_DOWNLOAD_RESULT",
39336
+ "callback-storage"
39404
39337
  );
39405
39338
  }
39406
- return await response.blob();
39339
+ return blob;
39407
39340
  } catch (error) {
39408
39341
  if (error instanceof StorageError) {
39409
39342
  throw error;
39410
39343
  }
39411
39344
  throw new StorageError(
39412
- `Server proxy download error: ${error instanceof Error ? error.message : "Unknown error"}`,
39345
+ `Download failed: ${error instanceof Error ? error.message : String(error)}`,
39413
39346
  "DOWNLOAD_ERROR",
39414
- "server-proxy"
39347
+ "callback-storage",
39348
+ { cause: error instanceof Error ? error : void 0 }
39415
39349
  );
39416
39350
  }
39417
39351
  }
39418
- async list(_options) {
39419
- throw new StorageError(
39420
- "List operation is not supported by server proxy storage",
39421
- "LIST_NOT_SUPPORTED",
39422
- "server-proxy"
39423
- );
39424
- }
39425
- async delete(_url) {
39426
- throw new StorageError(
39427
- "Delete operation is not supported by server proxy storage",
39428
- "DELETE_NOT_SUPPORTED",
39429
- "server-proxy"
39430
- );
39352
+ /**
39353
+ * List files using the provided callback (if available)
39354
+ *
39355
+ * @param options - Optional list options including filters and pagination
39356
+ * @returns Array of storage files
39357
+ */
39358
+ async list(options) {
39359
+ if (!this.callbacks.list) {
39360
+ throw new StorageError(
39361
+ "List operation not supported - no list callback provided",
39362
+ "NOT_SUPPORTED",
39363
+ "callback-storage"
39364
+ );
39365
+ }
39366
+ try {
39367
+ const result = await this.callbacks.list(options?.namePattern, options);
39368
+ return result.items.map((item, index) => ({
39369
+ id: item.identifier,
39370
+ name: item.identifier.split("/").pop() || `file-${index}`,
39371
+ url: item.identifier,
39372
+ size: item.size || 0,
39373
+ contentType: "application/octet-stream",
39374
+ createdAt: item.lastModified || /* @__PURE__ */ new Date(),
39375
+ metadata: item.metadata
39376
+ }));
39377
+ } catch (error) {
39378
+ throw new StorageError(
39379
+ `List failed: ${error instanceof Error ? error.message : String(error)}`,
39380
+ "LIST_ERROR",
39381
+ "callback-storage",
39382
+ { cause: error instanceof Error ? error : void 0 }
39383
+ );
39384
+ }
39431
39385
  }
39432
39386
  /**
39433
- * Extract identifier from URL or return as-is
39387
+ * Delete a file using the provided callback (if available)
39434
39388
  *
39435
- * @param url - URL or identifier string
39436
- * @returns identifier string
39389
+ * @param url - The URL or identifier to delete
39390
+ * @returns True if deletion succeeded
39437
39391
  */
39438
- extractIdentifierFromUrl(url) {
39439
- return url;
39392
+ async delete(url) {
39393
+ if (!this.callbacks.delete) {
39394
+ throw new StorageError(
39395
+ "Delete operation not supported - no delete callback provided",
39396
+ "NOT_SUPPORTED",
39397
+ "callback-storage"
39398
+ );
39399
+ }
39400
+ try {
39401
+ const identifier = this.callbacks.extractIdentifier ? this.callbacks.extractIdentifier(url) : url;
39402
+ return await this.callbacks.delete(identifier);
39403
+ } catch (error) {
39404
+ throw new StorageError(
39405
+ `Delete failed: ${error instanceof Error ? error.message : String(error)}`,
39406
+ "DELETE_ERROR",
39407
+ "callback-storage",
39408
+ { cause: error instanceof Error ? error : void 0 }
39409
+ );
39410
+ }
39440
39411
  }
39412
+ /**
39413
+ * Get provider configuration
39414
+ *
39415
+ * @returns Provider configuration metadata
39416
+ */
39441
39417
  getConfig() {
39442
39418
  return {
39443
- name: "Server Proxy",
39444
- type: "server-proxy",
39419
+ name: "callback-storage",
39420
+ type: "callback",
39445
39421
  requiresAuth: false,
39446
39422
  features: {
39447
39423
  upload: true,
39448
39424
  download: true,
39449
- list: false,
39450
- delete: false
39425
+ list: !!this.callbacks.list,
39426
+ delete: !!this.callbacks.delete
39451
39427
  }
39452
39428
  };
39453
39429
  }
@@ -40907,6 +40883,7 @@ export {
40907
40883
  BaseController,
40908
40884
  BlockchainError,
40909
40885
  BrowserPlatformAdapter,
40886
+ CallbackStorage,
40910
40887
  CircuitBreaker,
40911
40888
  ContractFactory,
40912
40889
  ContractNotFoundError,
@@ -40939,7 +40916,6 @@ export {
40939
40916
  SchemaValidator,
40940
40917
  SerializationError,
40941
40918
  ServerController,
40942
- ServerProxyStorage,
40943
40919
  ServerUrlMismatchError,
40944
40920
  SignatureError,
40945
40921
  StorageError,