@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
|
@@ -1,126 +1,246 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Defines platform abstraction interfaces for environment-specific implementations.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module provides the contract for platform-specific operations, allowing
|
|
6
|
+
* the SDK to work seamlessly across Node.js and browser environments. Platform
|
|
7
|
+
* adapters handle all environment-specific dependencies including cryptography,
|
|
8
|
+
* HTTP requests, caching, and PGP operations.
|
|
9
|
+
*
|
|
10
|
+
* The SDK automatically selects the appropriate adapter based on the runtime
|
|
11
|
+
* environment. Custom implementations can be provided for specialized use cases.
|
|
6
12
|
*
|
|
7
13
|
* **Implementation Context:**
|
|
8
|
-
* - Node.js: Uses native crypto modules and full OpenPGP support
|
|
9
|
-
* - Browser: Uses Web Crypto API and browser-compatible libraries
|
|
10
|
-
* - SSR: Automatically selects appropriate implementation based on runtime
|
|
14
|
+
* - Node.js: Uses native crypto modules, in-memory cache, and full OpenPGP support
|
|
15
|
+
* - Browser: Uses Web Crypto API, sessionStorage cache, and browser-compatible libraries
|
|
16
|
+
* - SSR: Automatically selects appropriate implementation based on runtime detection
|
|
11
17
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Custom platform adapter implementation
|
|
21
|
+
* class CustomPlatformAdapter implements VanaPlatformAdapter {
|
|
22
|
+
* crypto = new CustomCryptoAdapter();
|
|
23
|
+
* pgp = new CustomPGPAdapter();
|
|
24
|
+
* http = new CustomHttpAdapter();
|
|
25
|
+
* cache = new CustomCacheAdapter();
|
|
26
|
+
* platform = 'browser' as const;
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* // Use with SDK
|
|
30
|
+
* const client = createClient({
|
|
31
|
+
* platformAdapter: new CustomPlatformAdapter()
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @category Platform
|
|
36
|
+
* @module platform/interface
|
|
15
37
|
*/
|
|
16
38
|
/**
|
|
17
|
-
*
|
|
39
|
+
* Identifies the runtime platform for adapter selection.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Used for debugging, telemetry, and conditional logic based on
|
|
43
|
+
* the execution environment.
|
|
44
|
+
*
|
|
45
|
+
* @category Platform
|
|
18
46
|
*/
|
|
19
47
|
export type PlatformType = "node" | "browser";
|
|
20
48
|
/**
|
|
21
|
-
*
|
|
49
|
+
* Provides platform-specific cryptographic operations.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* Implements ECIES encryption/decryption, key generation, and password-based
|
|
53
|
+
* encryption using platform-appropriate libraries. Node.js uses Buffer-based
|
|
54
|
+
* libraries while browser uses Uint8Array and Web Crypto where possible.
|
|
55
|
+
*
|
|
56
|
+
* @category Platform
|
|
22
57
|
*/
|
|
23
58
|
export interface VanaCryptoAdapter {
|
|
24
59
|
/**
|
|
25
|
-
*
|
|
60
|
+
* Encrypts data with a public key using ECIES.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Uses Elliptic Curve Integrated Encryption Scheme (ECIES) for
|
|
64
|
+
* asymmetric encryption. The implementation varies by platform but
|
|
65
|
+
* maintains compatible output format.
|
|
26
66
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
67
|
+
* @param data - The plaintext data to encrypt.
|
|
68
|
+
* Typically user data or encryption keys.
|
|
69
|
+
* @param publicKey - The recipient's public key in hex format.
|
|
70
|
+
* Can be compressed or uncompressed secp256k1 key.
|
|
71
|
+
* @returns Hex-encoded encrypted data containing IV, ephemeral key, ciphertext, and MAC
|
|
31
72
|
*
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const encrypted = await adapter.crypto.encryptWithPublicKey(
|
|
76
|
+
* 'sensitive data',
|
|
77
|
+
* '04abcd...' // 65-byte uncompressed public key
|
|
78
|
+
* );
|
|
79
|
+
* ```
|
|
35
80
|
*/
|
|
36
81
|
encryptWithPublicKey(data: string, publicKey: string): Promise<string>;
|
|
37
82
|
/**
|
|
38
|
-
*
|
|
83
|
+
* Decrypts ECIES-encrypted data with a private key.
|
|
39
84
|
*
|
|
40
|
-
* @param encryptedData
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
85
|
+
* @param encryptedData - Hex-encoded encrypted data.
|
|
86
|
+
* Must contain IV, ephemeral key, ciphertext, and MAC.
|
|
87
|
+
* @param privateKey - The private key in hex format.
|
|
88
|
+
* Must correspond to the public key used for encryption.
|
|
89
|
+
* @returns The decrypted plaintext string
|
|
90
|
+
*
|
|
91
|
+
* @throws {Error} If decryption or MAC verification fails
|
|
43
92
|
*/
|
|
44
93
|
decryptWithPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
|
|
45
94
|
/**
|
|
46
|
-
*
|
|
95
|
+
* Generates a new secp256k1 key pair.
|
|
96
|
+
*
|
|
97
|
+
* @returns Object with hex-encoded keys
|
|
98
|
+
* @returns returns.publicKey - Compressed public key in hex
|
|
99
|
+
* @returns returns.privateKey - Private key in hex
|
|
47
100
|
*
|
|
48
|
-
* @
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const { publicKey, privateKey } = await adapter.crypto.generateKeyPair();
|
|
104
|
+
* console.log('Public key:', publicKey); // 33 bytes compressed
|
|
105
|
+
* ```
|
|
49
106
|
*/
|
|
50
107
|
generateKeyPair(): Promise<{
|
|
51
108
|
publicKey: string;
|
|
52
109
|
privateKey: string;
|
|
53
110
|
}>;
|
|
54
111
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
112
|
+
* Encrypts data with an Ethereum wallet's public key.
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Specifically designed for wallet-based encryption where the public
|
|
116
|
+
* key comes from an Ethereum wallet. Handles key format conversion
|
|
117
|
+
* and uses ECIES for encryption.
|
|
57
118
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
119
|
+
* @param data - The plaintext data to encrypt.
|
|
120
|
+
* Typically permission grants or metadata.
|
|
121
|
+
* @param publicKey - The wallet's public key.
|
|
122
|
+
* Accepts compressed/uncompressed, with/without 0x prefix.
|
|
123
|
+
* @returns Hex-encoded encrypted data
|
|
62
124
|
*
|
|
63
|
-
* @
|
|
64
|
-
*
|
|
65
|
-
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const encrypted = await adapter.crypto.encryptWithWalletPublicKey(
|
|
128
|
+
* JSON.stringify({ permission: 'read' }),
|
|
129
|
+
* walletPublicKey
|
|
130
|
+
* );
|
|
131
|
+
* ```
|
|
66
132
|
*/
|
|
67
133
|
encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
|
|
68
134
|
/**
|
|
69
|
-
*
|
|
70
|
-
* Uses platform-appropriate ECDH implementation (eccrypto vs eccrypto-js)
|
|
135
|
+
* Decrypts data with an Ethereum wallet's private key.
|
|
71
136
|
*
|
|
72
|
-
* @param encryptedData
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
137
|
+
* @param encryptedData - Hex-encoded encrypted data.
|
|
138
|
+
* Must be encrypted with corresponding wallet public key.
|
|
139
|
+
* @param privateKey - The wallet's private key.
|
|
140
|
+
* Handle with extreme care - never log or store.
|
|
141
|
+
* @returns The decrypted plaintext string
|
|
142
|
+
*
|
|
143
|
+
* @throws {Error} If decryption fails or key is invalid
|
|
75
144
|
*/
|
|
76
145
|
decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
|
|
77
146
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
147
|
+
* Encrypts binary data with password-based encryption.
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* Uses OpenPGP password-based encryption with automatic salt
|
|
151
|
+
* generation. Often used with wallet signatures as passwords for
|
|
152
|
+
* deterministic key derivation.
|
|
153
|
+
*
|
|
154
|
+
* @param data - Binary data to encrypt.
|
|
155
|
+
* Typically file contents or serialized data.
|
|
156
|
+
* @param password - Password for encryption.
|
|
157
|
+
* Often derived from wallet signatures.
|
|
158
|
+
* @returns Encrypted data as Uint8Array
|
|
80
159
|
*
|
|
81
|
-
* @
|
|
82
|
-
*
|
|
83
|
-
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* const fileData = new Uint8Array([1, 2, 3, 4]);
|
|
163
|
+
* const encrypted = await adapter.crypto.encryptWithPassword(
|
|
164
|
+
* fileData,
|
|
165
|
+
* walletSignature
|
|
166
|
+
* );
|
|
167
|
+
* ```
|
|
84
168
|
*/
|
|
85
169
|
encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
|
|
86
170
|
/**
|
|
87
|
-
*
|
|
88
|
-
* Uses platform-appropriate OpenPGP implementation with consistent format
|
|
171
|
+
* Decrypts password-encrypted binary data.
|
|
89
172
|
*
|
|
90
|
-
* @param encryptedData
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
173
|
+
* @param encryptedData - Password-encrypted data.
|
|
174
|
+
* Must be encrypted with the same password.
|
|
175
|
+
* @param password - Password for decryption.
|
|
176
|
+
* Must match the encryption password exactly.
|
|
177
|
+
* @returns Decrypted data as Uint8Array
|
|
178
|
+
*
|
|
179
|
+
* @throws {Error} If decryption fails or password is incorrect
|
|
93
180
|
*/
|
|
94
181
|
decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
|
|
95
182
|
}
|
|
96
183
|
/**
|
|
97
|
-
* PGP operations
|
|
184
|
+
* Provides platform-specific PGP operations.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* Implements PGP encryption, decryption, and key generation using
|
|
188
|
+
* OpenPGP.js with platform-appropriate configuration. Node.js uses
|
|
189
|
+
* optimizations like zlib compression.
|
|
190
|
+
*
|
|
191
|
+
* @category Platform
|
|
98
192
|
*/
|
|
99
193
|
export interface VanaPGPAdapter {
|
|
100
194
|
/**
|
|
101
|
-
*
|
|
195
|
+
* Encrypts data using PGP public key encryption.
|
|
102
196
|
*
|
|
103
|
-
* @param data The data to encrypt
|
|
104
|
-
*
|
|
105
|
-
* @
|
|
197
|
+
* @param data - The plaintext data to encrypt.
|
|
198
|
+
* Typically messages or structured data.
|
|
199
|
+
* @param publicKey - ASCII-armored PGP public key.
|
|
200
|
+
* Obtain from generateKeyPair or key servers.
|
|
201
|
+
* @returns ASCII-armored encrypted message
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const encrypted = await adapter.pgp.encrypt(
|
|
206
|
+
* 'secret message',
|
|
207
|
+
* armoredPublicKey
|
|
208
|
+
* );
|
|
209
|
+
* ```
|
|
106
210
|
*/
|
|
107
211
|
encrypt(data: string, publicKey: string): Promise<string>;
|
|
108
212
|
/**
|
|
109
|
-
*
|
|
213
|
+
* Decrypts PGP-encrypted data.
|
|
214
|
+
*
|
|
215
|
+
* @param encryptedData - ASCII-armored encrypted message.
|
|
216
|
+
* Must be encrypted with corresponding public key.
|
|
217
|
+
* @param privateKey - ASCII-armored PGP private key.
|
|
218
|
+
* May be passphrase-protected.
|
|
219
|
+
* @returns The decrypted plaintext string
|
|
110
220
|
*
|
|
111
|
-
* @
|
|
112
|
-
* @param privateKey The PGP private key
|
|
113
|
-
* @returns Promise resolving to decrypted data
|
|
221
|
+
* @throws {Error} If decryption fails or key is invalid
|
|
114
222
|
*/
|
|
115
223
|
decrypt(encryptedData: string, privateKey: string): Promise<string>;
|
|
116
224
|
/**
|
|
117
|
-
*
|
|
225
|
+
* Generates a new PGP key pair.
|
|
226
|
+
*
|
|
227
|
+
* @param options - Key generation configuration
|
|
228
|
+
* @param options.name - Identity name.
|
|
229
|
+
* Defaults to 'Vana User'.
|
|
230
|
+
* @param options.email - Identity email.
|
|
231
|
+
* Defaults to 'user@vana.com'.
|
|
232
|
+
* @param options.passphrase - Private key passphrase.
|
|
233
|
+
* If omitted, private key is unprotected.
|
|
234
|
+
* @returns ASCII-armored public and private keys
|
|
118
235
|
*
|
|
119
|
-
* @
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const { publicKey, privateKey } = await adapter.pgp.generateKeyPair({
|
|
239
|
+
* name: 'Alice Smith',
|
|
240
|
+
* email: 'alice@example.com',
|
|
241
|
+
* passphrase: 'secure-passphrase'
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
124
244
|
*/
|
|
125
245
|
generateKeyPair(options?: {
|
|
126
246
|
name?: string;
|
|
@@ -132,49 +252,97 @@ export interface VanaPGPAdapter {
|
|
|
132
252
|
}>;
|
|
133
253
|
}
|
|
134
254
|
/**
|
|
135
|
-
* HTTP operations
|
|
255
|
+
* Provides platform-specific HTTP operations.
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* Wraps the fetch API to ensure consistent behavior across
|
|
259
|
+
* Node.js and browser environments.
|
|
260
|
+
*
|
|
261
|
+
* @category Platform
|
|
136
262
|
*/
|
|
137
263
|
export interface VanaHttpAdapter {
|
|
138
264
|
/**
|
|
139
|
-
*
|
|
265
|
+
* Performs an HTTP request.
|
|
266
|
+
*
|
|
267
|
+
* @param url - The URL to request.
|
|
268
|
+
* Must be a valid HTTP/HTTPS URL.
|
|
269
|
+
* @param options - Standard fetch RequestInit options.
|
|
270
|
+
* See MDN documentation for details.
|
|
271
|
+
* @returns Standard fetch Response object
|
|
140
272
|
*
|
|
141
|
-
* @
|
|
142
|
-
*
|
|
143
|
-
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* const response = await adapter.http.fetch(
|
|
276
|
+
* 'https://api.vana.com/data',
|
|
277
|
+
* { method: 'GET', headers: { 'Authorization': 'Bearer token' } }
|
|
278
|
+
* );
|
|
279
|
+
* ```
|
|
144
280
|
*/
|
|
145
281
|
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
146
282
|
}
|
|
147
283
|
/**
|
|
148
|
-
*
|
|
284
|
+
* Provides platform-specific caching operations.
|
|
285
|
+
*
|
|
286
|
+
* @remarks
|
|
287
|
+
* Implements simple key-value caching with platform-appropriate storage.
|
|
288
|
+
* Node.js uses in-memory Map with TTL, browser uses sessionStorage for
|
|
289
|
+
* security (cleared on tab close).
|
|
290
|
+
*
|
|
291
|
+
* @category Platform
|
|
149
292
|
*/
|
|
150
293
|
export interface VanaCacheAdapter {
|
|
151
294
|
/**
|
|
152
|
-
*
|
|
295
|
+
* Retrieves a cached value.
|
|
153
296
|
*
|
|
154
|
-
* @param key The cache key
|
|
297
|
+
* @param key - The cache key.
|
|
298
|
+
* Should be unique per operation.
|
|
155
299
|
* @returns The cached value or null if not found/expired
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const cachedSignature = adapter.cache.get('sig_0x123...');
|
|
304
|
+
* if (cachedSignature) {
|
|
305
|
+
* return cachedSignature;
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
156
308
|
*/
|
|
157
309
|
get(key: string): string | null;
|
|
158
310
|
/**
|
|
159
|
-
*
|
|
311
|
+
* Stores a value in the cache.
|
|
160
312
|
*
|
|
161
|
-
* @param key The cache key
|
|
162
|
-
*
|
|
313
|
+
* @param key - The cache key.
|
|
314
|
+
* Should be unique and descriptive.
|
|
315
|
+
* @param value - The value to cache.
|
|
316
|
+
* Typically signatures or computed results.
|
|
317
|
+
*
|
|
318
|
+
* @remarks
|
|
319
|
+
* Node.js: Cached for 2 hours with TTL
|
|
320
|
+
* Browser: Cached until tab closes (sessionStorage)
|
|
163
321
|
*/
|
|
164
322
|
set(key: string, value: string): void;
|
|
165
323
|
/**
|
|
166
|
-
*
|
|
324
|
+
* Removes a cached value.
|
|
167
325
|
*
|
|
168
|
-
* @param key The cache key
|
|
326
|
+
* @param key - The cache key to remove.
|
|
327
|
+
* Use when cached data becomes invalid.
|
|
169
328
|
*/
|
|
170
329
|
delete(key: string): void;
|
|
171
330
|
/**
|
|
172
|
-
*
|
|
331
|
+
* Clears all cached values.
|
|
332
|
+
*
|
|
333
|
+
* @remarks
|
|
334
|
+
* Use with caution as this removes all performance optimizations.
|
|
335
|
+
* Browser implementation only clears Vana-prefixed keys.
|
|
173
336
|
*/
|
|
174
337
|
clear(): void;
|
|
175
338
|
}
|
|
176
339
|
/**
|
|
177
|
-
*
|
|
340
|
+
* Aggregates all platform-specific adapters into a single interface.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* This is the main interface for platform abstraction. Implementations
|
|
344
|
+
* must provide all required adapters while maintaining consistent behavior
|
|
345
|
+
* and data formats across platforms.
|
|
178
346
|
*
|
|
179
347
|
* **Implementation Guidelines:**
|
|
180
348
|
* 1. All methods must maintain consistent behavior across platforms
|
|
@@ -182,35 +350,60 @@ export interface VanaCacheAdapter {
|
|
|
182
350
|
* 3. Data formats (encoding, serialization) must be identical
|
|
183
351
|
* 4. Performance characteristics can vary but API must be consistent
|
|
184
352
|
*
|
|
185
|
-
*
|
|
353
|
+
* @example
|
|
186
354
|
* ```typescript
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
355
|
+
* // Custom implementation for specialized environment
|
|
356
|
+
* class EdgePlatformAdapter implements VanaPlatformAdapter {
|
|
357
|
+
* crypto = new EdgeCryptoAdapter();
|
|
358
|
+
* pgp = new EdgePGPAdapter();
|
|
359
|
+
* http = new EdgeHttpAdapter();
|
|
360
|
+
* cache = new EdgeCacheAdapter();
|
|
361
|
+
* platform = 'browser' as const; // Edge is browser-like
|
|
192
362
|
* }
|
|
363
|
+
*
|
|
364
|
+
* // Use with SDK
|
|
365
|
+
* const client = createClient({
|
|
366
|
+
* platformAdapter: new EdgePlatformAdapter()
|
|
367
|
+
* });
|
|
193
368
|
* ```
|
|
369
|
+
*
|
|
370
|
+
* @category Platform
|
|
194
371
|
*/
|
|
195
372
|
export interface VanaPlatformAdapter {
|
|
196
373
|
/**
|
|
197
|
-
*
|
|
374
|
+
* Provides cryptographic operations.
|
|
375
|
+
*
|
|
376
|
+
* @remarks
|
|
377
|
+
* Handles ECIES, wallet encryption, and password-based encryption.
|
|
198
378
|
*/
|
|
199
379
|
crypto: VanaCryptoAdapter;
|
|
200
380
|
/**
|
|
201
|
-
* PGP operations
|
|
381
|
+
* Provides PGP operations.
|
|
382
|
+
*
|
|
383
|
+
* @remarks
|
|
384
|
+
* Handles PGP encryption, decryption, and key generation.
|
|
202
385
|
*/
|
|
203
386
|
pgp: VanaPGPAdapter;
|
|
204
387
|
/**
|
|
205
|
-
* HTTP operations
|
|
388
|
+
* Provides HTTP operations.
|
|
389
|
+
*
|
|
390
|
+
* @remarks
|
|
391
|
+
* Wraps fetch API for consistent cross-platform behavior.
|
|
206
392
|
*/
|
|
207
393
|
http: VanaHttpAdapter;
|
|
208
394
|
/**
|
|
209
|
-
*
|
|
395
|
+
* Provides caching operations.
|
|
396
|
+
*
|
|
397
|
+
* @remarks
|
|
398
|
+
* Platform-appropriate storage for temporary data.
|
|
210
399
|
*/
|
|
211
400
|
cache: VanaCacheAdapter;
|
|
212
401
|
/**
|
|
213
|
-
*
|
|
402
|
+
* Identifies the platform type.
|
|
403
|
+
*
|
|
404
|
+
* @remarks
|
|
405
|
+
* Used for debugging, telemetry, and conditional logic.
|
|
406
|
+
* Must be 'node' or 'browser'.
|
|
214
407
|
*/
|
|
215
408
|
readonly platform: PlatformType;
|
|
216
409
|
}
|