@opendatalabs/vana-sdk 0.1.0-alpha.fd33fc9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +33 -1
- package/dist/browser.js.map +1 -1
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.d.ts +30 -1
- package/dist/chains/index.js.map +1 -1
- package/dist/client/__tests__/enhancedResponse.test.d.ts +1 -0
- package/dist/client/enhancedResponse.cjs +164 -0
- package/dist/client/enhancedResponse.cjs.map +1 -0
- package/dist/client/enhancedResponse.d.ts +120 -0
- package/dist/client/enhancedResponse.js +138 -0
- package/dist/client/enhancedResponse.js.map +1 -0
- package/dist/config/chains.cjs.map +1 -1
- package/dist/config/chains.d.ts +99 -0
- package/dist/config/chains.js.map +1 -1
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +66 -10
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
- package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
- package/dist/controllers/base.cjs +33 -0
- package/dist/controllers/base.cjs.map +1 -1
- package/dist/controllers/base.d.ts +10 -0
- package/dist/controllers/base.js +33 -0
- package/dist/controllers/base.js.map +1 -1
- package/dist/controllers/data.cjs +417 -276
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +246 -193
- package/dist/controllers/data.js +430 -279
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/operations.cjs +430 -0
- package/dist/controllers/operations.cjs.map +1 -0
- package/dist/controllers/operations.d.ts +229 -0
- package/dist/controllers/operations.js +406 -0
- package/dist/controllers/operations.js.map +1 -0
- package/dist/controllers/permissions.cjs +690 -209
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +196 -68
- package/dist/controllers/permissions.js +690 -209
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +27 -28
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +104 -25
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +88 -40
- package/dist/controllers/schemas.js +104 -25
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server.cjs +269 -58
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +157 -52
- package/dist/controllers/server.js +269 -58
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/__tests__/health.test.d.ts +1 -0
- package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
- package/dist/core/apiClient.cjs +53 -3
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +132 -7
- package/dist/core/apiClient.js +53 -3
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/generics.cjs +30 -3
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +95 -6
- package/dist/core/generics.js +30 -3
- package/dist/core/generics.js.map +1 -1
- package/dist/core/health.cjs +289 -0
- package/dist/core/health.cjs.map +1 -0
- package/dist/core/health.d.ts +143 -0
- package/dist/core/health.js +265 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/inMemoryNonceManager.cjs +138 -0
- package/dist/core/inMemoryNonceManager.cjs.map +1 -0
- package/dist/core/inMemoryNonceManager.d.ts +69 -0
- package/dist/core/inMemoryNonceManager.js +114 -0
- package/dist/core/inMemoryNonceManager.js.map +1 -0
- package/dist/core/nonceManager.cjs +304 -0
- package/dist/core/nonceManager.cjs.map +1 -0
- package/dist/core/nonceManager.d.ts +116 -0
- package/dist/core/nonceManager.js +280 -0
- package/dist/core/nonceManager.js.map +1 -0
- package/dist/core/pollingManager.cjs +292 -0
- package/dist/core/pollingManager.cjs.map +1 -0
- package/dist/core/pollingManager.d.ts +120 -0
- package/dist/core/pollingManager.js +268 -0
- package/dist/core/pollingManager.js.map +1 -0
- package/dist/core.cjs +55 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +54 -3
- package/dist/core.js +55 -1
- package/dist/core.js.map +1 -1
- package/dist/crypto/ecies/base.cjs +16 -3
- package/dist/crypto/ecies/base.cjs.map +1 -1
- package/dist/crypto/ecies/base.js +16 -3
- package/dist/crypto/ecies/base.js.map +1 -1
- package/dist/errors.cjs +29 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +64 -0
- package/dist/errors.js +28 -0
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +42 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +32 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js +42 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -1
- package/dist/generated/abi/DLPRegistryImplementation.cjs +5 -5
- package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +4 -4
- package/dist/generated/abi/DLPRegistryImplementation.js +5 -5
- package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +166 -2
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +129 -2
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +166 -2
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +167 -19
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +127 -14
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js +167 -19
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +0 -19
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +0 -14
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +0 -19
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs +0 -19
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +0 -14
- package/dist/generated/abi/DataPortabilityServersImplementation.js +0 -19
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
- package/dist/generated/abi/DataRegistryImplementation.cjs +0 -13
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataRegistryImplementation.d.ts +0 -10
- package/dist/generated/abi/DataRegistryImplementation.js +0 -13
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/SwapHelperImplementation.cjs +0 -43
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -1
- package/dist/generated/abi/SwapHelperImplementation.d.ts +0 -35
- package/dist/generated/abi/SwapHelperImplementation.js +0 -43
- package/dist/generated/abi/SwapHelperImplementation.js.map +1 -1
- package/dist/generated/abi/VanaEpochImplementation.cjs +195 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaEpochImplementation.d.ts +151 -0
- package/dist/generated/abi/VanaEpochImplementation.js +195 -0
- package/dist/generated/abi/VanaEpochImplementation.js.map +1 -1
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +22 -65
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +17 -51
- package/dist/generated/abi/VanaPoolEntityImplementation.js +22 -65
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +113 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +85 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.js +113 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
- package/dist/generated/abi/index.d.ts +546 -146
- package/dist/generated/event-types.cjs.map +1 -1
- package/dist/generated/event-types.d.ts +14 -8
- package/dist/generated/eventRegistry.cjs +42 -18
- package/dist/generated/eventRegistry.cjs.map +1 -1
- package/dist/generated/eventRegistry.js +42 -18
- package/dist/generated/eventRegistry.js.map +1 -1
- package/dist/generated/server/server-exports.cjs +22 -0
- package/dist/generated/server/server-exports.cjs.map +1 -1
- package/dist/generated/server/server-exports.d.ts +27 -10
- package/dist/generated/server/server-exports.js +17 -0
- package/dist/generated/server/server-exports.js.map +1 -1
- package/dist/generated/server/server.cjs.map +1 -1
- package/dist/generated/server/server.d.ts +771 -402
- package/dist/generated/subgraph.cjs +797 -32
- package/dist/generated/subgraph.cjs.map +1 -1
- package/dist/generated/subgraph.d.ts +135 -0
- package/dist/generated/subgraph.js +792 -32
- package/dist/generated/subgraph.js.map +1 -1
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.browser.js +10 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +26 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +49 -5
- package/dist/index.node.js +25 -1
- package/dist/index.node.js.map +1 -1
- package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
- package/dist/lib/redisAtomicStore.cjs +201 -0
- package/dist/lib/redisAtomicStore.cjs.map +1 -0
- package/dist/lib/redisAtomicStore.d.ts +120 -0
- package/dist/lib/redisAtomicStore.js +177 -0
- package/dist/lib/redisAtomicStore.js.map +1 -0
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +39 -1
- package/dist/node.js.map +1 -1
- package/dist/platform/browser.cjs +160 -2
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +232 -12
- package/dist/platform/browser.js +160 -2
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/interface.cjs.map +1 -1
- package/dist/platform/interface.d.ts +283 -90
- package/dist/platform/node.cjs +163 -2
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +69 -6
- package/dist/platform/node.js +163 -2
- package/dist/platform/node.js.map +1 -1
- package/dist/server/relayerHandler.cjs +315 -81
- package/dist/server/relayerHandler.cjs.map +1 -1
- package/dist/server/relayerHandler.d.ts +35 -2
- package/dist/server/relayerHandler.js +315 -81
- package/dist/server/relayerHandler.js.map +1 -1
- package/dist/storage/index.cjs +3 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/manager.cjs +108 -25
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +119 -25
- package/dist/storage/manager.js +108 -25
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +86 -15
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +109 -20
- package/dist/storage/providers/callback-storage.js +86 -15
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/dropbox.cjs +237 -0
- package/dist/storage/providers/dropbox.cjs.map +1 -0
- package/dist/storage/providers/dropbox.d.ts +39 -0
- package/dist/storage/providers/dropbox.js +215 -0
- package/dist/storage/providers/dropbox.js.map +1 -0
- package/dist/storage/providers/dropbox.test.d.ts +1 -0
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +12 -14
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
- package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
- package/dist/types/atomicStore.cjs +31 -0
- package/dist/types/atomicStore.cjs.map +1 -0
- package/dist/types/atomicStore.d.ts +236 -0
- package/dist/types/atomicStore.js +7 -0
- package/dist/types/atomicStore.js.map +1 -0
- package/dist/types/blockchain.cjs.map +1 -1
- package/dist/types/blockchain.d.ts +39 -11
- package/dist/types/chains.cjs.map +1 -1
- package/dist/types/chains.d.ts +74 -7
- package/dist/types/chains.js.map +1 -1
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +38 -4
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +71 -7
- package/dist/types/controller-context.cjs.map +1 -1
- package/dist/types/controller-context.d.ts +4 -1
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +11 -10
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +81 -10
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +31 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/operationStore.cjs +17 -0
- package/dist/types/operationStore.cjs.map +1 -0
- package/dist/types/operationStore.d.ts +171 -0
- package/dist/types/operationStore.js +1 -0
- package/dist/types/operationStore.js.map +1 -0
- package/dist/types/operations.cjs +3 -15
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +131 -39
- package/dist/types/operations.js +2 -13
- package/dist/types/operations.js.map +1 -1
- package/dist/types/options.cjs +17 -0
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.d.ts +308 -0
- package/dist/types/options.js +1 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/permissions.cjs.map +1 -1
- package/dist/types/permissions.d.ts +19 -20
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +150 -14
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +145 -24
- package/dist/types/storage.cjs.map +1 -1
- package/dist/types/storage.d.ts +9 -21
- package/dist/types/storage.js.map +1 -1
- package/dist/types/utils.cjs.map +1 -1
- package/dist/types/utils.d.ts +0 -45
- package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
- package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
- package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
- package/dist/utils/chainQuery.cjs +107 -0
- package/dist/utils/chainQuery.cjs.map +1 -0
- package/dist/utils/chainQuery.d.ts +31 -0
- package/dist/utils/chainQuery.js +82 -0
- package/dist/utils/chainQuery.js.map +1 -0
- package/dist/utils/grantFiles.cjs +4 -1
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +10 -20
- package/dist/utils/grantFiles.js +4 -1
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +95 -16
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +93 -12
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/ipfs.cjs +2 -4
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.d.ts +1 -1
- package/dist/utils/ipfs.js +2 -4
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +32 -7
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/signatureCache.cjs +8 -2
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +49 -8
- package/dist/utils/signatureCache.js +8 -2
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/subgraphConsistency.cjs +184 -0
- package/dist/utils/subgraphConsistency.cjs.map +1 -0
- package/dist/utils/subgraphConsistency.d.ts +65 -0
- package/dist/utils/subgraphConsistency.js +155 -0
- package/dist/utils/subgraphConsistency.js.map +1 -0
- package/dist/utils/subgraphMetaCache.cjs +101 -0
- package/dist/utils/subgraphMetaCache.cjs.map +1 -0
- package/dist/utils/subgraphMetaCache.d.ts +56 -0
- package/dist/utils/subgraphMetaCache.js +76 -0
- package/dist/utils/subgraphMetaCache.js.map +1 -0
- package/dist/utils/subgraphPagination.cjs +104 -0
- package/dist/utils/subgraphPagination.cjs.map +1 -0
- package/dist/utils/subgraphPagination.d.ts +78 -0
- package/dist/utils/subgraphPagination.js +78 -0
- package/dist/utils/subgraphPagination.js.map +1 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -1
- package/dist/utils/transactionHelpers.d.ts +12 -12
- package/dist/utils/transactionHelpers.js.map +1 -1
- package/dist/utils/typedDataConverter.cjs.map +1 -1
- package/dist/utils/typedDataConverter.d.ts +39 -3
- package/dist/utils/typedDataConverter.js.map +1 -1
- package/dist/utils/urlResolver.cjs +7 -0
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +22 -4
- package/dist/utils/urlResolver.js +7 -0
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs.map +1 -1
- package/dist/utils/wallet.d.ts +78 -16
- package/dist/utils/wallet.js.map +1 -1
- package/package.json +3 -1
package/dist/types/personal.d.ts
CHANGED
|
@@ -1,38 +1,174 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Defines parameters for posting data requests to personal servers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Used to initiate data access requests that require user permission.
|
|
6
|
+
* The permission ID references a previously granted permission that
|
|
7
|
+
* authorizes the requester to access specific user data.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const params: PostRequestParams = {
|
|
12
|
+
* permissionId: 123
|
|
13
|
+
* };
|
|
14
|
+
*
|
|
15
|
+
* const response = await vana.personal.postRequest(params);
|
|
16
|
+
* console.log('Request posted:', response.requestId);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @category Personal Server
|
|
3
20
|
*/
|
|
4
21
|
export interface PostRequestParams {
|
|
5
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* References a granted permission authorizing data access.
|
|
24
|
+
* Obtain via permission granting flow or query existing permissions.
|
|
25
|
+
* @throws {PermissionNotFoundError} If permission ID is invalid.
|
|
26
|
+
*/
|
|
6
27
|
permissionId: number;
|
|
7
28
|
}
|
|
8
29
|
/**
|
|
9
|
-
*
|
|
30
|
+
* Defines parameters for creating server-side operations.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Initiates asynchronous operations on the personal server that
|
|
34
|
+
* process user data according to granted permissions. Operations
|
|
35
|
+
* run in the background and can be monitored via their operation ID.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const params: CreateOperationParams = {
|
|
40
|
+
* permissionId: 456
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* const operation = await vana.server.createOperation(params);
|
|
44
|
+
* // Monitor operation status
|
|
45
|
+
* const status = await vana.server.getOperationStatus(operation.id);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @category Personal Server
|
|
10
49
|
*/
|
|
11
50
|
export interface CreateOperationParams {
|
|
12
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* References the permission scope for this operation.
|
|
53
|
+
* Determines what data and actions are allowed.
|
|
54
|
+
* @throws {InsufficientPermissionsError} If permission scope is inadequate.
|
|
55
|
+
*/
|
|
13
56
|
permissionId: number;
|
|
14
57
|
}
|
|
15
58
|
/**
|
|
16
|
-
* Parameters for
|
|
59
|
+
* Parameters for downloading an artifact from a server operation.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Artifacts are files generated during operations like Gemini agent analysis.
|
|
63
|
+
* The download requires authentication using the application's signature.
|
|
64
|
+
*
|
|
65
|
+
* @category Personal Server
|
|
66
|
+
*/
|
|
67
|
+
export interface DownloadArtifactParams {
|
|
68
|
+
/**
|
|
69
|
+
* The operation ID that generated the artifact.
|
|
70
|
+
*/
|
|
71
|
+
operationId: string;
|
|
72
|
+
/**
|
|
73
|
+
* The path to the artifact file to download.
|
|
74
|
+
*/
|
|
75
|
+
artifactPath: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Defines parameters for initializing personal server connections.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* Establishes secure communication channels with a user's personal
|
|
82
|
+
* data server. The server manages encrypted user data and enforces
|
|
83
|
+
* permission-based access control. Initialization includes key exchange
|
|
84
|
+
* and session establishment.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const params: InitPersonalServerParams = {
|
|
89
|
+
* userAddress: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
|
|
90
|
+
* };
|
|
91
|
+
*
|
|
92
|
+
* const server = await vana.personal.initServer(params);
|
|
93
|
+
* console.log('Connected to server:', server.baseUrl);
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @category Personal Server
|
|
17
97
|
*/
|
|
18
98
|
export interface InitPersonalServerParams {
|
|
19
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Identifies the user whose personal server to connect to.
|
|
101
|
+
* Must be a valid Ethereum address in hex format.
|
|
102
|
+
* @example '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
|
|
103
|
+
*/
|
|
20
104
|
userAddress: string;
|
|
21
105
|
}
|
|
22
106
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
107
|
+
* Represents comprehensive personal server identity and connection information.
|
|
108
|
+
*
|
|
109
|
+
* @remarks
|
|
110
|
+
* Combines core server identity with connection metadata required for
|
|
111
|
+
* establishing secure communication. Personal servers are user-controlled
|
|
112
|
+
* nodes that store and serve encrypted personal data according to
|
|
113
|
+
* user-defined permissions. This interface provides all necessary
|
|
114
|
+
* information to connect to and interact with a personal server.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const identity: PersonalServerIdentity = {
|
|
119
|
+
* kind: 'PersonalServer',
|
|
120
|
+
* address: '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36',
|
|
121
|
+
* publicKey: '0x04...', // 65-byte uncompressed public key
|
|
122
|
+
* baseUrl: 'https://ps.user.vana.com',
|
|
123
|
+
* name: 'User Personal Server #1'
|
|
124
|
+
* };
|
|
125
|
+
*
|
|
126
|
+
* // Use identity to establish encrypted connection
|
|
127
|
+
* const encrypted = await crypto.encrypt(data, identity.publicKey);
|
|
128
|
+
* const response = await fetch(`${identity.baseUrl}/api/data`, {
|
|
129
|
+
* method: 'POST',
|
|
130
|
+
* body: encrypted
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @category Personal Server
|
|
26
135
|
*/
|
|
27
136
|
export interface PersonalServerIdentity {
|
|
28
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Identifies the resource type for API disambiguation.
|
|
139
|
+
* Always 'PersonalServer' for personal server instances.
|
|
140
|
+
*/
|
|
29
141
|
kind: string;
|
|
30
|
-
/**
|
|
142
|
+
/**
|
|
143
|
+
* Uniquely identifies the server on the blockchain.
|
|
144
|
+
* Used for permission verification and identity proofs.
|
|
145
|
+
* @example '0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36'
|
|
146
|
+
*/
|
|
31
147
|
address: string;
|
|
32
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Enables end-to-end encryption for data transmission.
|
|
150
|
+
* Must be in uncompressed format (65 bytes with 0x04 prefix).
|
|
151
|
+
* @example '0x04...' (130 hex characters)
|
|
152
|
+
*/
|
|
33
153
|
publicKey: string;
|
|
34
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Provides the HTTPS endpoint for server API requests.
|
|
156
|
+
* Should not include trailing slashes or API paths.
|
|
157
|
+
* @example 'https://ps.user.vana.com'
|
|
158
|
+
*/
|
|
35
159
|
baseUrl: string;
|
|
36
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* Displays a user-friendly identifier for the server.
|
|
162
|
+
* Used in UI components and logging for clarity.
|
|
163
|
+
* @example 'Primary Data Server'
|
|
164
|
+
*/
|
|
37
165
|
name: string;
|
|
38
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* @remarks
|
|
169
|
+
* Additional server response types are auto-generated from the OpenAPI
|
|
170
|
+
* specification and available in the server-exports module. Import those
|
|
171
|
+
* types directly when working with server API responses.
|
|
172
|
+
*
|
|
173
|
+
* @see {@link ../types/server-exports | Server Export Types}
|
|
174
|
+
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/relayer.ts"],"sourcesContent":["import type { Hash, Address } from \"viem\";\nimport type {\n GrantFile,\n PermissionGrantTypedData,\n GenericTypedData,\n} from \"./permissions\";\n\n/**\n * Response from the relayer service for grant file storage\n *\n * @category Advanced\n */\nexport interface RelayerStorageResponse {\n /** The IPFS URL where the grant file is stored */\n grantUrl: string;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Storage metadata */\n metadata?: {\n /** IPFS hash */\n ipfsHash: string;\n /** File size in bytes */\n size: number;\n /** Upload timestamp */\n timestamp: number;\n };\n}\n\n/**\n * Response from the relayer service for transaction submission\n *\n * @category Advanced\n */\nexport interface RelayerTransactionResponse {\n /** The transaction hash of the submitted transaction */\n transactionHash: Hash;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Transaction metadata */\n metadata?: {\n /** Gas used */\n gasUsed?: bigint;\n /** Gas price */\n gasPrice?: bigint;\n /** Block number */\n blockNumber?: bigint;\n /** Transaction status */\n status?: \"pending\" | \"confirmed\" | \"failed\";\n };\n}\n\n/**\n * Parameters for storing a grant file via relayer\n *\n * @category Advanced\n */\nexport interface RelayerStoreParams {\n /** The grant file to store */\n grantFile: GrantFile;\n /** Optional storage options */\n options?: {\n /** IPFS pin duration in seconds */\n pinDuration?: number;\n /** Whether to use encryption */\n encrypt?: boolean;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n };\n}\n\n/**\n * Parameters for submitting a transaction via relayer\n *\n * @category Advanced\n */\nexport interface RelayerSubmitParams {\n /** The signed typed data */\n typedData: PermissionGrantTypedData;\n /** The signature */\n signature: string;\n /** Optional transaction options */\n options?: {\n /** Gas limit */\n gasLimit?: bigint;\n /** Priority level */\n priority?: \"low\" | \"medium\" | \"high\";\n /** Whether to wait for confirmation */\n waitForConfirmation?: boolean;\n };\n}\n\n/**\n * Relayer service status\n *\n * @category Advanced\n */\nexport interface RelayerStatus {\n /** Whether the relayer is online */\n online: boolean;\n /** Service version */\n version: string;\n /** Supported chains */\n supportedChains: number[];\n /** Current chain status */\n chainStatus: Record<\n number,\n {\n /** Whether the chain is supported */\n supported: boolean;\n /** Current block number */\n currentBlock: bigint;\n /** Gas price estimation */\n gasPrice: bigint;\n /** Queue size */\n queueSize: number;\n }\n >;\n /** Rate limit information */\n rateLimits: {\n /** Requests per minute */\n requestsPerMinute: number;\n /** Storage requests per hour */\n storageRequestsPerHour: number;\n /** Transaction requests per hour */\n transactionRequestsPerHour: number;\n };\n}\n\n/**\n * Relayer request options\n *\n * @category Advanced\n */\nexport interface RelayerRequestOptions {\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Whether to retry on failure */\n retry?: boolean;\n /** Custom headers */\n headers?: Record<string, string>;\n /** Request priority */\n priority?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * Relayer error response\n *\n * @category Advanced\n */\nexport interface RelayerErrorResponse {\n /** Error code */\n code: string;\n /** Error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n /** Request ID for debugging */\n requestId?: string;\n /** Timestamp of error */\n timestamp: number;\n}\n\n/**\n * Relayer queue information\n *\n * @category Advanced\n */\nexport interface RelayerQueueInfo {\n /** Current queue size */\n size: number;\n /** Estimated processing time in seconds */\n estimatedProcessingTime: number;\n /** Queue position for a specific request */\n position?: number;\n /** Processing statistics */\n stats: {\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Requests processed in last hour */\n requestsProcessedHour: number;\n /** Success rate percentage */\n successRate: number;\n };\n}\n\n/**\n * Relayer transaction status\n *\n * @category Advanced\n */\nexport interface RelayerTransactionStatus {\n /** Transaction hash */\n transactionHash: Hash;\n /** Current status */\n status: \"pending\" | \"confirmed\" | \"failed\";\n /** Block number if confirmed */\n blockNumber?: bigint;\n /** Gas used */\n gasUsed?: bigint;\n /** Error message if failed */\n error?: string;\n /** Status checks performed */\n checks: Array<{\n /** Check timestamp */\n timestamp: number;\n /** Status at time of check */\n status: string;\n /** Block number at time of check */\n blockNumber: bigint;\n }>;\n}\n\n/**\n * Relayer metrics\n *\n * @category Advanced\n */\nexport interface RelayerMetrics {\n /** Total transactions processed */\n totalTransactions: number;\n /** Successful transactions */\n successfulTransactions: number;\n /** Failed transactions */\n failedTransactions: number;\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Current queue size */\n queueSize: number;\n /** Uptime percentage */\n uptime: number;\n /** Last 24 hour statistics */\n last24Hours: {\n /** Transactions processed */\n transactions: number;\n /** Success rate */\n successRate: number;\n /** Average response time */\n averageResponseTime: number;\n };\n}\n\n/**\n * Relayer webhook configuration\n *\n * @category Advanced\n */\nexport interface RelayerWebhookConfig {\n /** Webhook URL */\n url: string;\n /** Events to subscribe to */\n events: Array<\n \"transaction_confirmed\" | \"transaction_failed\" | \"storage_complete\"\n >;\n /** Webhook secret for signature verification */\n secret?: string;\n /** Whether webhook is active */\n active: boolean;\n}\n\n/**\n * Relayer webhook payload\n *\n * @category Advanced\n */\nexport interface RelayerWebhookPayload {\n /** Event type */\n event: string;\n /** Event data */\n data: Record<string, unknown>;\n /** Timestamp */\n timestamp: number;\n /** Webhook ID */\n webhookId: string;\n /** Signature for verification */\n signature: string;\n}\n\n// ===== NEW SIMPLIFIED RELAYER TYPES (v2) =====\n\n/**\n * Handles both EIP-712 signed operations and direct server operations through a single interface.\n *\n * @remarks\n * This discriminated union provides type safety through TypeScript's narrowing.\n * The `type` field determines which operation variant is being used.\n * Signed operations require blockchain transactions, while direct operations\n * handle auxiliary tasks like file storage.\n *\n * @category Relayer\n * @see {@link https://docs.vana.org/docs/gasless-transactions | Gasless Transactions Guide}\n */\nexport type UnifiedRelayerRequest = SignedRelayerRequest | DirectRelayerRequest;\n\n/**\n * Represents an EIP-712 signed operation for gasless transaction submission.\n *\n * @remarks\n * Signed requests contain typed data and signatures that are verified\n * on-chain by smart contracts. The relayer pays gas fees on behalf of users.\n *\n * @category Relayer\n */\nexport interface SignedRelayerRequest {\n /** Discriminator field identifying this as a signed operation */\n type: \"signed\";\n /** Operation identifier for routing (e.g., 'submitAddPermission') */\n operation: SignedOperationType;\n /** EIP-712 typed data structure for the operation */\n typedData: GenericTypedData;\n /** User's signature of the typed data */\n signature: Hash;\n /** Optional address for additional signer verification */\n expectedUserAddress?: Address;\n}\n\n/**\n * Supported signed operation types.\n * @category Relayer\n */\nexport type SignedOperationType =\n | \"submitAddPermission\"\n | \"submitPermissionRevoke\"\n | \"submitTrustServer\"\n | \"submitAddAndTrustServer\"\n | \"submitUntrustServer\"\n | \"submitAddServerFilesAndPermissions\"\n | \"submitRegisterGrantee\";\n\n/**\n * Represents direct server operations that don't require blockchain signatures.\n *\n * @remarks\n * Direct requests handle auxiliary operations like file uploads and grant storage.\n * These operations may still result in blockchain transactions but don't require\n * user signatures for gasless submission.\n *\n * @category Relayer\n */\nexport type DirectRelayerRequest =\n | {\n type: \"direct\";\n operation: \"submitFileAddition\";\n params: {\n url: string;\n userAddress: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionWithPermissions\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionComplete\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n schemaId: number;\n ownerAddress?: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"storeGrantFile\";\n params: GrantFile;\n };\n\n/**\n * Provides type-safe responses for all relayer operations.\n *\n * @remarks\n * The discriminated union ensures proper error handling and result typing.\n * Check the `type` field to determine success or failure before accessing results.\n *\n * @category Relayer\n */\nexport type UnifiedRelayerResponse =\n | {\n type: \"signed\";\n hash: Hash;\n }\n | {\n type: \"direct\";\n result: { fileId: number; transactionHash: Hash } | { url: string } | any;\n }\n | {\n type: \"error\";\n error: string;\n };\n\n/**\n * Simplified relayer configuration.\n * Can be a URL string for convenience, or a callback for full control.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Option 1: Simple URL (SDK handles the transport)\n * const vana = Vana({\n * walletClient,\n * relayer: '/api/relay'\n * });\n *\n * // Option 2: Full control with callback\n * const vana = Vana({\n * walletClient,\n * relayer: async (request) => {\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * });\n * ```\n */\nexport type RelayerConfig =\n | string\n | ((request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>);\n\n/**\n * Simplified relayer callbacks interface (v2).\n * A single callback handles all relayer operations.\n *\n * @category Configuration\n * @example\n * ```typescript\n * const relayerCallbacks: RelayerCallbacksV2 = {\n * submit: async (request) => {\n * // Send to your server endpoint\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * };\n * ```\n */\nexport interface RelayerCallbacksV2 {\n /**\n * Submit any relayer operation.\n *\n * This single callback handles all operations:\n * - EIP-712 signed operations (permissions, server trust, etc.)\n * - Direct operations (file additions, grant storage)\n *\n * On your server, pass the entire request object to the SDK's\n * `handleRelayerOperation` helper function.\n *\n * @param request - The unified request object\n * @returns Promise resolving to operation-specific response\n */\n submit: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/relayer.ts"],"sourcesContent":["/**\n * Defines types for gasless transaction relayers and server operations.\n *\n * @remarks\n * This module provides comprehensive type definitions for interacting with\n * relayer services that enable gasless transactions and auxiliary operations.\n * It includes both legacy v1 types and the simplified v2 unified interface.\n *\n * @category Types\n * @module types/relayer\n */\n\nimport type { Hash, Address, TransactionReceipt } from \"viem\";\nimport type {\n GrantFile,\n PermissionGrantTypedData,\n GenericTypedData,\n} from \"./permissions\";\nimport type { Contract, Fn } from \"../generated/event-types\";\n\n/**\n * Represents the response from storing grant files via relayer.\n *\n * @remarks\n * Contains storage location, metadata, and error information for\n * grant file upload operations.\n *\n * @category Advanced\n */\nexport interface RelayerStorageResponse {\n /** The IPFS URL where the grant file is stored */\n grantUrl: string;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Storage metadata */\n metadata?: {\n /** IPFS hash */\n ipfsHash: string;\n /** File size in bytes */\n size: number;\n /** Upload timestamp */\n timestamp: number;\n };\n}\n\n/**\n * Represents the response from submitting transactions via relayer.\n *\n * @remarks\n * Contains transaction hash, status, and metadata for gasless\n * transaction submissions.\n *\n * @category Advanced\n */\nexport interface RelayerTransactionResponse {\n /** The transaction hash of the submitted transaction */\n transactionHash: Hash;\n /** Success status */\n success: boolean;\n /** Optional error message */\n error?: string;\n /** Transaction metadata */\n metadata?: {\n /** Gas used */\n gasUsed?: bigint;\n /** Gas price */\n gasPrice?: bigint;\n /** Block number */\n blockNumber?: bigint;\n /** Transaction status */\n status?: \"pending\" | \"confirmed\" | \"failed\";\n };\n}\n\n/**\n * Specifies parameters for storing grant files via relayer.\n *\n * @remarks\n * Includes the grant file and optional storage configuration\n * such as encryption and pinning duration.\n *\n * @category Advanced\n */\nexport interface RelayerStoreParams {\n /** The grant file to store */\n grantFile: GrantFile;\n /** Optional storage options */\n options?: {\n /** IPFS pin duration in seconds */\n pinDuration?: number;\n /** Whether to use encryption */\n encrypt?: boolean;\n /** Custom metadata */\n metadata?: Record<string, unknown>;\n };\n}\n\n/**\n * Specifies parameters for submitting gasless transactions.\n *\n * @remarks\n * Contains signed typed data and transaction configuration options\n * for relayer submission.\n *\n * @category Advanced\n */\nexport interface RelayerSubmitParams {\n /** The signed typed data */\n typedData: PermissionGrantTypedData;\n /** The signature */\n signature: string;\n /** Optional transaction options */\n options?: {\n /** Gas limit */\n gasLimit?: bigint;\n /** Priority level */\n priority?: \"low\" | \"medium\" | \"high\";\n /** Whether to wait for confirmation */\n waitForConfirmation?: boolean;\n };\n}\n\n/**\n * Represents the current status and capabilities of a relayer service.\n *\n * @remarks\n * Provides information about supported chains, rate limits, and\n * current operational status for monitoring and decision-making.\n *\n * @category Advanced\n */\nexport interface RelayerStatus {\n /** Whether the relayer is online */\n online: boolean;\n /** Service version */\n version: string;\n /** Supported chains */\n supportedChains: number[];\n /** Current chain status */\n chainStatus: Record<\n number,\n {\n /** Whether the chain is supported */\n supported: boolean;\n /** Current block number */\n currentBlock: bigint;\n /** Gas price estimation */\n gasPrice: bigint;\n /** Queue size */\n queueSize: number;\n }\n >;\n /** Rate limit information */\n rateLimits: {\n /** Requests per minute */\n requestsPerMinute: number;\n /** Storage requests per hour */\n storageRequestsPerHour: number;\n /** Transaction requests per hour */\n transactionRequestsPerHour: number;\n };\n}\n\n/**\n * Configures behavior for relayer requests.\n *\n * @remarks\n * Controls timeout, retry logic, headers, and priority for\n * relayer operation requests.\n *\n * @category Advanced\n */\nexport interface RelayerRequestOptions {\n /** Request timeout in milliseconds */\n timeout?: number;\n /** Whether to retry on failure */\n retry?: boolean;\n /** Custom headers */\n headers?: Record<string, string>;\n /** Request priority */\n priority?: \"low\" | \"medium\" | \"high\";\n}\n\n/**\n * Represents an error response from the relayer service.\n *\n * @remarks\n * Provides structured error information including codes, messages,\n * and debugging details for error handling and recovery.\n *\n * @category Advanced\n */\nexport interface RelayerErrorResponse {\n /** Error code */\n code: string;\n /** Error message */\n message: string;\n /** Additional error details */\n details?: Record<string, unknown>;\n /** Request ID for debugging */\n requestId?: string;\n /** Timestamp of error */\n timestamp: number;\n}\n\n/**\n * Provides information about the relayer's processing queue.\n *\n * @remarks\n * Includes queue size, position, estimated processing time, and\n * performance statistics for queue monitoring.\n *\n * @category Advanced\n */\nexport interface RelayerQueueInfo {\n /** Current queue size */\n size: number;\n /** Estimated processing time in seconds */\n estimatedProcessingTime: number;\n /** Queue position for a specific request */\n position?: number;\n /** Processing statistics */\n stats: {\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Requests processed in last hour */\n requestsProcessedHour: number;\n /** Success rate percentage */\n successRate: number;\n };\n}\n\n/**\n * Tracks the status of a transaction submitted via relayer.\n *\n * @remarks\n * Provides detailed tracking information including confirmation status,\n * gas usage, and historical status checks.\n *\n * @category Advanced\n */\nexport interface RelayerTransactionStatus {\n /** Transaction hash */\n transactionHash: Hash;\n /** Current status */\n status: \"pending\" | \"confirmed\" | \"failed\";\n /** Block number if confirmed */\n blockNumber?: bigint;\n /** Gas used */\n gasUsed?: bigint;\n /** Error message if failed */\n error?: string;\n /** Status checks performed */\n checks: Array<{\n /** Check timestamp */\n timestamp: number;\n /** Status at time of check */\n status: string;\n /** Block number at time of check */\n blockNumber: bigint;\n }>;\n}\n\n/**\n * Provides performance metrics for the relayer service.\n *\n * @remarks\n * Includes transaction statistics, success rates, processing times,\n * and uptime information for monitoring and optimization.\n *\n * @category Advanced\n */\nexport interface RelayerMetrics {\n /** Total transactions processed */\n totalTransactions: number;\n /** Successful transactions */\n successfulTransactions: number;\n /** Failed transactions */\n failedTransactions: number;\n /** Average processing time in seconds */\n averageProcessingTime: number;\n /** Current queue size */\n queueSize: number;\n /** Uptime percentage */\n uptime: number;\n /** Last 24 hour statistics */\n last24Hours: {\n /** Transactions processed */\n transactions: number;\n /** Success rate */\n successRate: number;\n /** Average response time */\n averageResponseTime: number;\n };\n}\n\n/**\n * Configures webhook notifications for relayer events.\n *\n * @remarks\n * Enables asynchronous notifications for transaction confirmations,\n * failures, and storage completions.\n *\n * @category Advanced\n */\nexport interface RelayerWebhookConfig {\n /** Webhook URL */\n url: string;\n /** Events to subscribe to */\n events: Array<\n \"transaction_confirmed\" | \"transaction_failed\" | \"storage_complete\"\n >;\n /** Webhook secret for signature verification */\n secret?: string;\n /** Whether webhook is active */\n active: boolean;\n}\n\n/**\n * Represents a webhook event payload from the relayer.\n *\n * @remarks\n * Contains event data, timestamp, and signature for verification\n * of webhook authenticity.\n *\n * @category Advanced\n */\nexport interface RelayerWebhookPayload {\n /** Event type */\n event: string;\n /** Event data */\n data: Record<string, unknown>;\n /** Timestamp */\n timestamp: number;\n /** Webhook ID */\n webhookId: string;\n /** Signature for verification */\n signature: string;\n}\n\n// ===== NEW SIMPLIFIED RELAYER TYPES (v2) =====\n\n/**\n * Handles both EIP-712 signed operations and direct server operations through a single interface.\n *\n * @remarks\n * This discriminated union provides type safety through TypeScript's narrowing.\n * The `type` field determines which operation variant is being used.\n * Signed operations require blockchain transactions, while direct operations\n * handle auxiliary tasks like file storage.\n *\n * @category Relayer\n * @see {@link https://docs.vana.org/docs/gasless-transactions | Gasless Transactions Guide}\n */\nexport type UnifiedRelayerRequest =\n | SignedRelayerRequest\n | DirectRelayerRequest\n | {\n type: \"status_check\";\n operationId: string;\n };\n\n/**\n * Represents an EIP-712 signed operation for gasless transaction submission.\n *\n * @remarks\n * Signed requests contain typed data and signatures that are verified\n * on-chain by smart contracts. The relayer pays gas fees on behalf of users.\n *\n * @category Relayer\n */\nexport interface SignedRelayerRequest {\n /** Discriminator field identifying this as a signed operation */\n type: \"signed\";\n /** Operation identifier for routing (e.g., 'submitAddPermission') */\n operation: SignedOperationType;\n /** EIP-712 typed data structure for the operation */\n typedData: GenericTypedData;\n /** User's signature of the typed data */\n signature: Hash;\n /** Optional address for additional signer verification */\n expectedUserAddress?: Address;\n}\n\n/**\n * Enumerates supported EIP-712 signed operation types.\n *\n * @remarks\n * Each operation type corresponds to a specific smart contract\n * function that accepts gasless transactions.\n *\n * @category Relayer\n */\nexport type SignedOperationType =\n | \"submitAddPermission\"\n | \"submitPermissionRevoke\"\n | \"submitTrustServer\"\n | \"submitAddAndTrustServer\"\n | \"submitUntrustServer\"\n | \"submitAddServerFilesAndPermissions\";\n// | \"submitRegisterGrantee\"; // TODO: Add when contract supports registerGranteeWithSignature\n\n/**\n * Represents direct server operations that don't require blockchain signatures.\n *\n * @remarks\n * Direct requests handle auxiliary operations like file uploads and grant storage.\n * These operations may still result in blockchain transactions but don't require\n * user signatures for gasless submission.\n *\n * @category Relayer\n */\nexport type DirectRelayerRequest =\n | {\n type: \"direct\";\n operation: \"submitFileAddition\";\n params: {\n url: string;\n userAddress: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionWithPermissions\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n };\n }\n | {\n type: \"direct\";\n operation: \"submitFileAdditionComplete\";\n params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n schemaId: number;\n ownerAddress?: Address;\n };\n }\n | {\n type: \"direct\";\n operation: \"storeGrantFile\";\n params: GrantFile;\n }\n | {\n type: \"direct\";\n operation: \"submitRegisterGrantee\";\n params: {\n owner: Address;\n granteeAddress: Address;\n publicKey: string;\n };\n };\n\n/**\n * Context for transaction operations to enable proper event parsing.\n *\n * @remarks\n * This context is preserved in relayer responses to enable client-side\n * event parsing without requiring manual reconstruction of transaction details.\n *\n * @category Relayer\n */\nexport interface TransactionContext {\n /** The contract that was called */\n contract: Contract;\n /** The function that was called on the contract */\n fn: Fn<Contract>;\n /** The address that initiated the transaction */\n from: Address;\n}\n\n/**\n * Provides type-safe responses for all relayer operations.\n *\n * @remarks\n * The discriminated union ensures proper error handling and result typing.\n * Check the `type` field to determine success or failure before accessing results.\n * The new async pattern returns pending operations with operationIds for polling.\n *\n * Transaction responses include optional context to enable client-side event parsing\n * through the enhanced response pattern.\n *\n * @category Relayer\n */\nexport type UnifiedRelayerResponse =\n | {\n type: \"pending\";\n operationId: string;\n }\n | {\n type: \"submitted\";\n hash: Hash;\n /** Optional context for client-side event parsing and enhanced responses */\n context?: TransactionContext;\n }\n | {\n type: \"confirmed\";\n hash: Hash;\n // Receipt is optional; a performance hint for the client SDK's polling logic.\n receipt?: TransactionReceipt;\n }\n | {\n type: \"signed\";\n hash: Hash;\n /** Optional context for client-side event parsing and enhanced responses */\n context?: TransactionContext;\n }\n | {\n /** Non-transactional operations that complete immediately (e.g., IPFS uploads, file info) */\n type: \"direct\";\n /** The result data from the operation, structure depends on the specific operation */\n result: unknown;\n }\n | {\n type: \"error\";\n error: string;\n };\n\n/**\n * Simplified relayer configuration.\n * Can be a URL string for convenience, or a callback for full control.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Option 1: Simple URL (SDK handles the transport)\n * const vana = Vana({\n * walletClient,\n * relayer: '/api/relay'\n * });\n *\n * // Option 2: Full control with callback\n * const vana = Vana({\n * walletClient,\n * relayer: async (request) => {\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * });\n * ```\n */\nexport type RelayerConfig =\n | string\n | ((request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>);\n\n/**\n * Simplified relayer callbacks interface (v2).\n * A single callback handles all relayer operations.\n *\n * @category Configuration\n * @example\n * ```typescript\n * const relayerCallbacks: RelayerCallbacksV2 = {\n * submit: async (request) => {\n * // Send to your server endpoint\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * };\n * ```\n */\nexport interface RelayerCallbacksV2 {\n /**\n * Submits any relayer operation to the server.\n *\n * @remarks\n * This single callback handles all operations:\n * - EIP-712 signed operations (permissions, server trust, etc.)\n * - Direct operations (file additions, grant storage)\n *\n * On your server, pass the entire request object to the SDK's\n * `handleRelayerOperation` helper function.\n *\n * @param request - The unified request object.\n * Check `type` field to determine operation variant.\n * @returns Promise resolving to operation-specific response\n *\n * @example\n * ```typescript\n * async submit(request) {\n * const response = await fetch('/api/relay', {\n * method: 'POST',\n * body: JSON.stringify(request)\n * });\n * return response.json();\n * }\n * ```\n */\n submit: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types/relayer.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Defines types for gasless transaction relayers and server operations.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides comprehensive type definitions for interacting with
|
|
6
|
+
* relayer services that enable gasless transactions and auxiliary operations.
|
|
7
|
+
* It includes both legacy v1 types and the simplified v2 unified interface.
|
|
8
|
+
*
|
|
9
|
+
* @category Types
|
|
10
|
+
* @module types/relayer
|
|
11
|
+
*/
|
|
12
|
+
import type { Hash, Address, TransactionReceipt } from "viem";
|
|
2
13
|
import type { GrantFile, PermissionGrantTypedData, GenericTypedData } from "./permissions";
|
|
14
|
+
import type { Contract, Fn } from "../generated/event-types";
|
|
3
15
|
/**
|
|
4
|
-
*
|
|
16
|
+
* Represents the response from storing grant files via relayer.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* Contains storage location, metadata, and error information for
|
|
20
|
+
* grant file upload operations.
|
|
5
21
|
*
|
|
6
22
|
* @category Advanced
|
|
7
23
|
*/
|
|
@@ -23,7 +39,11 @@ export interface RelayerStorageResponse {
|
|
|
23
39
|
};
|
|
24
40
|
}
|
|
25
41
|
/**
|
|
26
|
-
*
|
|
42
|
+
* Represents the response from submitting transactions via relayer.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Contains transaction hash, status, and metadata for gasless
|
|
46
|
+
* transaction submissions.
|
|
27
47
|
*
|
|
28
48
|
* @category Advanced
|
|
29
49
|
*/
|
|
@@ -47,7 +67,11 @@ export interface RelayerTransactionResponse {
|
|
|
47
67
|
};
|
|
48
68
|
}
|
|
49
69
|
/**
|
|
50
|
-
*
|
|
70
|
+
* Specifies parameters for storing grant files via relayer.
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* Includes the grant file and optional storage configuration
|
|
74
|
+
* such as encryption and pinning duration.
|
|
51
75
|
*
|
|
52
76
|
* @category Advanced
|
|
53
77
|
*/
|
|
@@ -65,7 +89,11 @@ export interface RelayerStoreParams {
|
|
|
65
89
|
};
|
|
66
90
|
}
|
|
67
91
|
/**
|
|
68
|
-
*
|
|
92
|
+
* Specifies parameters for submitting gasless transactions.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* Contains signed typed data and transaction configuration options
|
|
96
|
+
* for relayer submission.
|
|
69
97
|
*
|
|
70
98
|
* @category Advanced
|
|
71
99
|
*/
|
|
@@ -85,7 +113,11 @@ export interface RelayerSubmitParams {
|
|
|
85
113
|
};
|
|
86
114
|
}
|
|
87
115
|
/**
|
|
88
|
-
*
|
|
116
|
+
* Represents the current status and capabilities of a relayer service.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* Provides information about supported chains, rate limits, and
|
|
120
|
+
* current operational status for monitoring and decision-making.
|
|
89
121
|
*
|
|
90
122
|
* @category Advanced
|
|
91
123
|
*/
|
|
@@ -118,7 +150,11 @@ export interface RelayerStatus {
|
|
|
118
150
|
};
|
|
119
151
|
}
|
|
120
152
|
/**
|
|
121
|
-
*
|
|
153
|
+
* Configures behavior for relayer requests.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* Controls timeout, retry logic, headers, and priority for
|
|
157
|
+
* relayer operation requests.
|
|
122
158
|
*
|
|
123
159
|
* @category Advanced
|
|
124
160
|
*/
|
|
@@ -133,7 +169,11 @@ export interface RelayerRequestOptions {
|
|
|
133
169
|
priority?: "low" | "medium" | "high";
|
|
134
170
|
}
|
|
135
171
|
/**
|
|
136
|
-
*
|
|
172
|
+
* Represents an error response from the relayer service.
|
|
173
|
+
*
|
|
174
|
+
* @remarks
|
|
175
|
+
* Provides structured error information including codes, messages,
|
|
176
|
+
* and debugging details for error handling and recovery.
|
|
137
177
|
*
|
|
138
178
|
* @category Advanced
|
|
139
179
|
*/
|
|
@@ -150,7 +190,11 @@ export interface RelayerErrorResponse {
|
|
|
150
190
|
timestamp: number;
|
|
151
191
|
}
|
|
152
192
|
/**
|
|
153
|
-
*
|
|
193
|
+
* Provides information about the relayer's processing queue.
|
|
194
|
+
*
|
|
195
|
+
* @remarks
|
|
196
|
+
* Includes queue size, position, estimated processing time, and
|
|
197
|
+
* performance statistics for queue monitoring.
|
|
154
198
|
*
|
|
155
199
|
* @category Advanced
|
|
156
200
|
*/
|
|
@@ -172,7 +216,11 @@ export interface RelayerQueueInfo {
|
|
|
172
216
|
};
|
|
173
217
|
}
|
|
174
218
|
/**
|
|
175
|
-
*
|
|
219
|
+
* Tracks the status of a transaction submitted via relayer.
|
|
220
|
+
*
|
|
221
|
+
* @remarks
|
|
222
|
+
* Provides detailed tracking information including confirmation status,
|
|
223
|
+
* gas usage, and historical status checks.
|
|
176
224
|
*
|
|
177
225
|
* @category Advanced
|
|
178
226
|
*/
|
|
@@ -198,7 +246,11 @@ export interface RelayerTransactionStatus {
|
|
|
198
246
|
}>;
|
|
199
247
|
}
|
|
200
248
|
/**
|
|
201
|
-
*
|
|
249
|
+
* Provides performance metrics for the relayer service.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* Includes transaction statistics, success rates, processing times,
|
|
253
|
+
* and uptime information for monitoring and optimization.
|
|
202
254
|
*
|
|
203
255
|
* @category Advanced
|
|
204
256
|
*/
|
|
@@ -226,7 +278,11 @@ export interface RelayerMetrics {
|
|
|
226
278
|
};
|
|
227
279
|
}
|
|
228
280
|
/**
|
|
229
|
-
*
|
|
281
|
+
* Configures webhook notifications for relayer events.
|
|
282
|
+
*
|
|
283
|
+
* @remarks
|
|
284
|
+
* Enables asynchronous notifications for transaction confirmations,
|
|
285
|
+
* failures, and storage completions.
|
|
230
286
|
*
|
|
231
287
|
* @category Advanced
|
|
232
288
|
*/
|
|
@@ -241,7 +297,11 @@ export interface RelayerWebhookConfig {
|
|
|
241
297
|
active: boolean;
|
|
242
298
|
}
|
|
243
299
|
/**
|
|
244
|
-
*
|
|
300
|
+
* Represents a webhook event payload from the relayer.
|
|
301
|
+
*
|
|
302
|
+
* @remarks
|
|
303
|
+
* Contains event data, timestamp, and signature for verification
|
|
304
|
+
* of webhook authenticity.
|
|
245
305
|
*
|
|
246
306
|
* @category Advanced
|
|
247
307
|
*/
|
|
@@ -269,7 +329,10 @@ export interface RelayerWebhookPayload {
|
|
|
269
329
|
* @category Relayer
|
|
270
330
|
* @see {@link https://docs.vana.org/docs/gasless-transactions | Gasless Transactions Guide}
|
|
271
331
|
*/
|
|
272
|
-
export type UnifiedRelayerRequest = SignedRelayerRequest | DirectRelayerRequest
|
|
332
|
+
export type UnifiedRelayerRequest = SignedRelayerRequest | DirectRelayerRequest | {
|
|
333
|
+
type: "status_check";
|
|
334
|
+
operationId: string;
|
|
335
|
+
};
|
|
273
336
|
/**
|
|
274
337
|
* Represents an EIP-712 signed operation for gasless transaction submission.
|
|
275
338
|
*
|
|
@@ -292,10 +355,15 @@ export interface SignedRelayerRequest {
|
|
|
292
355
|
expectedUserAddress?: Address;
|
|
293
356
|
}
|
|
294
357
|
/**
|
|
295
|
-
*
|
|
358
|
+
* Enumerates supported EIP-712 signed operation types.
|
|
359
|
+
*
|
|
360
|
+
* @remarks
|
|
361
|
+
* Each operation type corresponds to a specific smart contract
|
|
362
|
+
* function that accepts gasless transactions.
|
|
363
|
+
*
|
|
296
364
|
* @category Relayer
|
|
297
365
|
*/
|
|
298
|
-
export type SignedOperationType = "submitAddPermission" | "submitPermissionRevoke" | "submitTrustServer" | "submitAddAndTrustServer" | "submitUntrustServer" | "submitAddServerFilesAndPermissions"
|
|
366
|
+
export type SignedOperationType = "submitAddPermission" | "submitPermissionRevoke" | "submitTrustServer" | "submitAddAndTrustServer" | "submitUntrustServer" | "submitAddServerFilesAndPermissions";
|
|
299
367
|
/**
|
|
300
368
|
* Represents direct server operations that don't require blockchain signatures.
|
|
301
369
|
*
|
|
@@ -341,27 +409,67 @@ export type DirectRelayerRequest = {
|
|
|
341
409
|
type: "direct";
|
|
342
410
|
operation: "storeGrantFile";
|
|
343
411
|
params: GrantFile;
|
|
412
|
+
} | {
|
|
413
|
+
type: "direct";
|
|
414
|
+
operation: "submitRegisterGrantee";
|
|
415
|
+
params: {
|
|
416
|
+
owner: Address;
|
|
417
|
+
granteeAddress: Address;
|
|
418
|
+
publicKey: string;
|
|
419
|
+
};
|
|
344
420
|
};
|
|
421
|
+
/**
|
|
422
|
+
* Context for transaction operations to enable proper event parsing.
|
|
423
|
+
*
|
|
424
|
+
* @remarks
|
|
425
|
+
* This context is preserved in relayer responses to enable client-side
|
|
426
|
+
* event parsing without requiring manual reconstruction of transaction details.
|
|
427
|
+
*
|
|
428
|
+
* @category Relayer
|
|
429
|
+
*/
|
|
430
|
+
export interface TransactionContext {
|
|
431
|
+
/** The contract that was called */
|
|
432
|
+
contract: Contract;
|
|
433
|
+
/** The function that was called on the contract */
|
|
434
|
+
fn: Fn<Contract>;
|
|
435
|
+
/** The address that initiated the transaction */
|
|
436
|
+
from: Address;
|
|
437
|
+
}
|
|
345
438
|
/**
|
|
346
439
|
* Provides type-safe responses for all relayer operations.
|
|
347
440
|
*
|
|
348
441
|
* @remarks
|
|
349
442
|
* The discriminated union ensures proper error handling and result typing.
|
|
350
443
|
* Check the `type` field to determine success or failure before accessing results.
|
|
444
|
+
* The new async pattern returns pending operations with operationIds for polling.
|
|
445
|
+
*
|
|
446
|
+
* Transaction responses include optional context to enable client-side event parsing
|
|
447
|
+
* through the enhanced response pattern.
|
|
351
448
|
*
|
|
352
449
|
* @category Relayer
|
|
353
450
|
*/
|
|
354
451
|
export type UnifiedRelayerResponse = {
|
|
452
|
+
type: "pending";
|
|
453
|
+
operationId: string;
|
|
454
|
+
} | {
|
|
455
|
+
type: "submitted";
|
|
456
|
+
hash: Hash;
|
|
457
|
+
/** Optional context for client-side event parsing and enhanced responses */
|
|
458
|
+
context?: TransactionContext;
|
|
459
|
+
} | {
|
|
460
|
+
type: "confirmed";
|
|
461
|
+
hash: Hash;
|
|
462
|
+
receipt?: TransactionReceipt;
|
|
463
|
+
} | {
|
|
355
464
|
type: "signed";
|
|
356
465
|
hash: Hash;
|
|
466
|
+
/** Optional context for client-side event parsing and enhanced responses */
|
|
467
|
+
context?: TransactionContext;
|
|
357
468
|
} | {
|
|
469
|
+
/** Non-transactional operations that complete immediately (e.g., IPFS uploads, file info) */
|
|
358
470
|
type: "direct";
|
|
359
|
-
result
|
|
360
|
-
|
|
361
|
-
transactionHash: Hash;
|
|
362
|
-
} | {
|
|
363
|
-
url: string;
|
|
364
|
-
} | any;
|
|
471
|
+
/** The result data from the operation, structure depends on the specific operation */
|
|
472
|
+
result: unknown;
|
|
365
473
|
} | {
|
|
366
474
|
type: "error";
|
|
367
475
|
error: string;
|
|
@@ -415,8 +523,9 @@ export type RelayerConfig = string | ((request: UnifiedRelayerRequest) => Promis
|
|
|
415
523
|
*/
|
|
416
524
|
export interface RelayerCallbacksV2 {
|
|
417
525
|
/**
|
|
418
|
-
*
|
|
526
|
+
* Submits any relayer operation to the server.
|
|
419
527
|
*
|
|
528
|
+
* @remarks
|
|
420
529
|
* This single callback handles all operations:
|
|
421
530
|
* - EIP-712 signed operations (permissions, server trust, etc.)
|
|
422
531
|
* - Direct operations (file additions, grant storage)
|
|
@@ -424,8 +533,20 @@ export interface RelayerCallbacksV2 {
|
|
|
424
533
|
* On your server, pass the entire request object to the SDK's
|
|
425
534
|
* `handleRelayerOperation` helper function.
|
|
426
535
|
*
|
|
427
|
-
* @param request - The unified request object
|
|
536
|
+
* @param request - The unified request object.
|
|
537
|
+
* Check `type` field to determine operation variant.
|
|
428
538
|
* @returns Promise resolving to operation-specific response
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* async submit(request) {
|
|
543
|
+
* const response = await fetch('/api/relay', {
|
|
544
|
+
* method: 'POST',
|
|
545
|
+
* body: JSON.stringify(request)
|
|
546
|
+
* });
|
|
547
|
+
* return response.json();
|
|
548
|
+
* }
|
|
549
|
+
* ```
|
|
429
550
|
*/
|
|
430
551
|
submit: (request: UnifiedRelayerRequest) => Promise<UnifiedRelayerResponse>;
|
|
431
552
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n * Defines interface for storage provider implementations.\n *\n * @remarks\n * Abstracts storage backends (IPFS, Google Drive, Pinata) behind\n * common interface for encrypted file operations.\n *\n * @category Storage\n * @example\n * ```typescript\n * class MyStorage implements StorageProvider {\n * async upload(file: Blob): Promise<StorageUploadResult> {\n * const url = await uploadToService(file);\n * return { url, size: file.size, contentType: file.type };\n * }\n *\n * async download(url: string): Promise<Blob> {\n * return fetch(url).then(r => r.blob());\n * }\n * }\n * ```\n */\nexport interface StorageProvider {\n /**\n * Upload a file to the storage provider\n *\n * @param file - The file to upload\n * @param filename - Optional custom filename\n * @returns Promise with storage URL and metadata\n */\n upload(file: Blob, filename?: string): Promise<StorageUploadResult>;\n\n /**\n * Download a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with file blob\n */\n download(url: string): Promise<Blob>;\n\n /**\n * List files from the storage provider\n *\n * @param options - Optional filtering and pagination\n * @returns Promise with file list\n */\n list(options?: StorageListOptions): Promise<StorageFile[]>;\n\n /**\n * Delete a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with success status\n */\n delete(url: string): Promise<boolean>;\n\n /**\n * Get provider-specific configuration\n *\n * @returns Provider configuration object\n */\n getConfig(): StorageProviderConfig;\n}\n\nexport interface StorageUploadResult {\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageFile {\n /** File identifier */\n id: string;\n /** File name */\n name: string;\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Upload timestamp */\n createdAt: Date;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageListOptions {\n /** Maximum number of files to return */\n limit?: number;\n /** Pagination cursor/offset */\n offset?: string | number;\n /** Filter by file name pattern */\n namePattern?: string;\n /** Filter by content type */\n contentType?: string;\n}\n\nexport interface StorageProviderConfig {\n /** Provider name */\n name: string;\n /** Provider type */\n type: string;\n /** Whether authentication is required */\n requiresAuth: boolean;\n /** Supported features */\n features: {\n upload: boolean;\n download: boolean;\n list: boolean;\n delete: boolean;\n };\n}\n\nexport class StorageError extends Error {\n public readonly code: string;\n public readonly provider: string;\n // The 'cause' property is now inherited from the base Error class\n\n constructor(\n message: string,\n code: string,\n provider: string,\n options?: { cause?: Error },\n ) {\n // Pass the options object with 'cause' to the super constructor\n super(message, options);\n this.name = \"StorageError\";\n this.code = code;\n this.provider = provider;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuHO,MAAM,qBAAqB,MAAM;AAAA,EACtB;AAAA,EACA;AAAA;AAAA,EAGhB,YACE,SACA,MACA,UACA,SACA;AAEA,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;","names":[]}
|
package/dist/types/storage.d.ts
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Defines interface for storage provider implementations.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Abstracts storage backends (IPFS, Google Drive, Pinata) behind
|
|
6
|
+
* common interface for encrypted file operations.
|
|
7
7
|
*
|
|
8
8
|
* @category Storage
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* return { url: 'https://my-storage.com/file.dat', size: file.size };
|
|
11
|
+
* class MyStorage implements StorageProvider {
|
|
12
|
+
* async upload(file: Blob): Promise<StorageUploadResult> {
|
|
13
|
+
* const url = await uploadToService(file);
|
|
14
|
+
* return { url, size: file.size, contentType: file.type };
|
|
16
15
|
* }
|
|
17
16
|
*
|
|
18
17
|
* async download(url: string): Promise<Blob> {
|
|
19
|
-
*
|
|
20
|
-
* const response = await fetch(url);
|
|
21
|
-
* return response.blob();
|
|
22
|
-
* }
|
|
23
|
-
*
|
|
24
|
-
* async list(options?: StorageListOptions): Promise<StorageFile[]> {
|
|
25
|
-
* // Return list of files
|
|
26
|
-
* return [];
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* async delete(url: string): Promise<void> {
|
|
30
|
-
* // Delete file implementation
|
|
18
|
+
* return fetch(url).then(r => r.blob());
|
|
31
19
|
* }
|
|
32
20
|
* }
|
|
33
21
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/types/storage.ts"],"sourcesContent":["/**\n * Defines interface for storage provider implementations.\n *\n * @remarks\n * Abstracts storage backends (IPFS, Google Drive, Pinata) behind\n * common interface for encrypted file operations.\n *\n * @category Storage\n * @example\n * ```typescript\n * class MyStorage implements StorageProvider {\n * async upload(file: Blob): Promise<StorageUploadResult> {\n * const url = await uploadToService(file);\n * return { url, size: file.size, contentType: file.type };\n * }\n *\n * async download(url: string): Promise<Blob> {\n * return fetch(url).then(r => r.blob());\n * }\n * }\n * ```\n */\nexport interface StorageProvider {\n /**\n * Upload a file to the storage provider\n *\n * @param file - The file to upload\n * @param filename - Optional custom filename\n * @returns Promise with storage URL and metadata\n */\n upload(file: Blob, filename?: string): Promise<StorageUploadResult>;\n\n /**\n * Download a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with file blob\n */\n download(url: string): Promise<Blob>;\n\n /**\n * List files from the storage provider\n *\n * @param options - Optional filtering and pagination\n * @returns Promise with file list\n */\n list(options?: StorageListOptions): Promise<StorageFile[]>;\n\n /**\n * Delete a file from the storage provider\n *\n * @param url - The storage URL\n * @returns Promise with success status\n */\n delete(url: string): Promise<boolean>;\n\n /**\n * Get provider-specific configuration\n *\n * @returns Provider configuration object\n */\n getConfig(): StorageProviderConfig;\n}\n\nexport interface StorageUploadResult {\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageFile {\n /** File identifier */\n id: string;\n /** File name */\n name: string;\n /** Public URL to access the file */\n url: string;\n /** File size in bytes */\n size: number;\n /** Content type/MIME type */\n contentType: string;\n /** Upload timestamp */\n createdAt: Date;\n /** Provider-specific metadata */\n metadata?: Record<string, unknown>;\n}\n\nexport interface StorageListOptions {\n /** Maximum number of files to return */\n limit?: number;\n /** Pagination cursor/offset */\n offset?: string | number;\n /** Filter by file name pattern */\n namePattern?: string;\n /** Filter by content type */\n contentType?: string;\n}\n\nexport interface StorageProviderConfig {\n /** Provider name */\n name: string;\n /** Provider type */\n type: string;\n /** Whether authentication is required */\n requiresAuth: boolean;\n /** Supported features */\n features: {\n upload: boolean;\n download: boolean;\n list: boolean;\n delete: boolean;\n };\n}\n\nexport class StorageError extends Error {\n public readonly code: string;\n public readonly provider: string;\n // The 'cause' property is now inherited from the base Error class\n\n constructor(\n message: string,\n code: string,\n provider: string,\n options?: { cause?: Error },\n ) {\n // Pass the options object with 'cause' to the super constructor\n super(message, options);\n this.name = \"StorageError\";\n this.code = code;\n this.provider = provider;\n }\n}\n"],"mappings":"AAuHO,MAAM,qBAAqB,MAAM;AAAA,EACtB;AAAA,EACA;AAAA;AAAA,EAGhB,YACE,SACA,MACA,UACA,SACA;AAEA,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW;AAAA,EAClB;AACF;","names":[]}
|