@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,34 +1,184 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Provides browser-specific implementations of platform abstraction interfaces.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module implements all platform-specific operations for browser environments,
|
|
6
|
+
* using native Web APIs and browser-compatible libraries. It avoids Node.js-specific
|
|
7
|
+
* dependencies like Buffer, using Uint8Array and viem utilities instead. Supports
|
|
8
|
+
* both standard eccrypto and custom ECIES implementations based on feature flags.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Use the browser platform adapter
|
|
13
|
+
* import { BrowserPlatformAdapter } from '@vana-sdk/platform/browser';
|
|
14
|
+
*
|
|
15
|
+
* const adapter = new BrowserPlatformAdapter();
|
|
16
|
+
*
|
|
17
|
+
* // Encrypt data with public key
|
|
18
|
+
* const encrypted = await adapter.crypto.encryptWithPublicKey(
|
|
19
|
+
* 'sensitive data',
|
|
20
|
+
* '0x04...' // Public key hex
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* // Use sessionStorage-backed cache
|
|
24
|
+
* adapter.cache.set('temp_key', 'cached_value');
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @category Platform
|
|
28
|
+
* @module platform/browser
|
|
6
29
|
*/
|
|
7
30
|
import type { VanaPlatformAdapter, VanaCryptoAdapter, VanaPGPAdapter, VanaHttpAdapter, VanaCacheAdapter } from "./interface";
|
|
8
31
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
32
|
+
* Implements cryptographic operations for browser environments.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Provides ECIES encryption/decryption, key generation, and password-based
|
|
36
|
+
* encryption using either eccrypto-js or a custom ECIES implementation.
|
|
37
|
+
* Uses Uint8Array and viem utilities for browser compatibility.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
11
40
|
*/
|
|
12
41
|
declare class BrowserCryptoAdapter implements VanaCryptoAdapter {
|
|
13
42
|
private customEciesProvider;
|
|
14
43
|
private customWalletService;
|
|
44
|
+
/**
|
|
45
|
+
* Encrypts data using ECIES with a public key.
|
|
46
|
+
*
|
|
47
|
+
* @param data - The plaintext string to encrypt.
|
|
48
|
+
* Typically user data or sensitive information.
|
|
49
|
+
* @param publicKeyHex - The recipient's public key in hex format.
|
|
50
|
+
* Can include or omit the '0x' prefix.
|
|
51
|
+
* @returns Encrypted data as a hex string without '0x' prefix
|
|
52
|
+
*
|
|
53
|
+
* @throws {Error} If encryption fails or public key is invalid
|
|
54
|
+
*/
|
|
15
55
|
encryptWithPublicKey(data: string, publicKeyHex: string): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Decrypts ECIES-encrypted data using a private key.
|
|
58
|
+
*
|
|
59
|
+
* @param encryptedData - Hex string containing encrypted data.
|
|
60
|
+
* Can include or omit the '0x' prefix.
|
|
61
|
+
* @param privateKeyHex - The private key in hex format.
|
|
62
|
+
* Must correspond to the public key used for encryption.
|
|
63
|
+
* @returns The decrypted plaintext string
|
|
64
|
+
*
|
|
65
|
+
* @throws {Error} If decryption fails or MAC verification fails
|
|
66
|
+
*/
|
|
16
67
|
decryptWithPrivateKey(encryptedData: string, privateKeyHex: string): Promise<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Encrypts data using a wallet's public key.
|
|
70
|
+
*
|
|
71
|
+
* @param data - The plaintext string to encrypt.
|
|
72
|
+
* Typically permission data or DLP metadata.
|
|
73
|
+
* @param publicKey - The wallet's public key.
|
|
74
|
+
* Automatically handles compressed/uncompressed formats.
|
|
75
|
+
* @returns Encrypted data as a hex string
|
|
76
|
+
*
|
|
77
|
+
* @throws {Error} If encryption fails or key processing fails
|
|
78
|
+
*/
|
|
17
79
|
encryptWithWalletPublicKey(data: string, publicKey: string): Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* Decrypts data using a wallet's private key.
|
|
82
|
+
*
|
|
83
|
+
* @param encryptedData - Hex string containing encrypted data.
|
|
84
|
+
* Must be encrypted with corresponding wallet public key.
|
|
85
|
+
* @param privateKey - The wallet's private key.
|
|
86
|
+
* Obtain from wallet connection (handle with care).
|
|
87
|
+
* @returns The decrypted plaintext string
|
|
88
|
+
*
|
|
89
|
+
* @throws {Error} If decryption fails or key is invalid
|
|
90
|
+
*/
|
|
18
91
|
decryptWithWalletPrivateKey(encryptedData: string, privateKey: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Generates a new secp256k1 key pair for ECIES operations.
|
|
94
|
+
*
|
|
95
|
+
* @returns Object containing hex-encoded public and private keys
|
|
96
|
+
* @returns returns.privateKey - Private key in hex format without '0x'
|
|
97
|
+
* @returns returns.publicKey - Compressed public key in hex format without '0x'
|
|
98
|
+
*
|
|
99
|
+
* @throws {Error} If key generation fails
|
|
100
|
+
*/
|
|
19
101
|
generateKeyPair(): Promise<{
|
|
20
102
|
privateKey: string;
|
|
21
103
|
publicKey: string;
|
|
22
104
|
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Encrypts binary data using password-based encryption.
|
|
107
|
+
*
|
|
108
|
+
* @param data - Binary data to encrypt.
|
|
109
|
+
* Typically file contents or serialized objects.
|
|
110
|
+
* @param password - Password for encryption.
|
|
111
|
+
* Often derived from wallet signatures.
|
|
112
|
+
* @returns Encrypted data as Uint8Array
|
|
113
|
+
*
|
|
114
|
+
* @remarks
|
|
115
|
+
* Uses OpenPGP for password-based encryption with automatic
|
|
116
|
+
* salt generation for security.
|
|
117
|
+
*
|
|
118
|
+
* @throws {Error} If encryption fails
|
|
119
|
+
*/
|
|
23
120
|
encryptWithPassword(data: Uint8Array, password: string): Promise<Uint8Array>;
|
|
121
|
+
/**
|
|
122
|
+
* Decrypts password-encrypted binary data.
|
|
123
|
+
*
|
|
124
|
+
* @param encryptedData - Password-encrypted data as Uint8Array.
|
|
125
|
+
* Must be encrypted with the same password.
|
|
126
|
+
* @param password - Password for decryption.
|
|
127
|
+
* Must match the encryption password.
|
|
128
|
+
* @returns Decrypted data as Uint8Array
|
|
129
|
+
*
|
|
130
|
+
* @throws {Error} If decryption fails or password is incorrect
|
|
131
|
+
*/
|
|
24
132
|
decryptWithPassword(encryptedData: Uint8Array, password: string): Promise<Uint8Array>;
|
|
25
133
|
}
|
|
26
134
|
/**
|
|
27
|
-
*
|
|
135
|
+
* Implements PGP operations for browser environments.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Provides PGP encryption, decryption, and key generation using the OpenPGP.js
|
|
139
|
+
* library with browser-optimized configuration.
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
28
142
|
*/
|
|
29
143
|
declare class BrowserPGPAdapter implements VanaPGPAdapter {
|
|
144
|
+
/**
|
|
145
|
+
* Encrypts data using PGP public key encryption.
|
|
146
|
+
*
|
|
147
|
+
* @param data - The plaintext string to encrypt.
|
|
148
|
+
* Typically messages or structured data.
|
|
149
|
+
* @param publicKeyArmored - ASCII-armored PGP public key.
|
|
150
|
+
* Obtain from PGP key generation or key servers.
|
|
151
|
+
* @returns ASCII-armored encrypted message
|
|
152
|
+
*
|
|
153
|
+
* @throws {Error} If encryption fails or public key is invalid
|
|
154
|
+
*/
|
|
30
155
|
encrypt(data: string, publicKeyArmored: string): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Decrypts PGP-encrypted data using a private key.
|
|
158
|
+
*
|
|
159
|
+
* @param encryptedData - ASCII-armored encrypted message.
|
|
160
|
+
* Must be encrypted with corresponding public key.
|
|
161
|
+
* @param privateKeyArmored - ASCII-armored PGP private key.
|
|
162
|
+
* Must correspond to the public key used for encryption.
|
|
163
|
+
* @returns The decrypted plaintext string
|
|
164
|
+
*
|
|
165
|
+
* @throws {Error} If decryption fails or private key is invalid
|
|
166
|
+
*/
|
|
31
167
|
decrypt(encryptedData: string, privateKeyArmored: string): Promise<string>;
|
|
168
|
+
/**
|
|
169
|
+
* Generates a new PGP key pair.
|
|
170
|
+
*
|
|
171
|
+
* @param options - Key generation options
|
|
172
|
+
* @param options.name - Name for the key identity.
|
|
173
|
+
* Defaults to 'Vana User'.
|
|
174
|
+
* @param options.email - Email for the key identity.
|
|
175
|
+
* Defaults to 'user@vana.com'.
|
|
176
|
+
* @param options.passphrase - Passphrase to protect the private key.
|
|
177
|
+
* If not provided, key is unprotected.
|
|
178
|
+
* @returns ASCII-armored public and private keys
|
|
179
|
+
*
|
|
180
|
+
* @throws {Error} If key generation fails
|
|
181
|
+
*/
|
|
32
182
|
generateKeyPair(options?: {
|
|
33
183
|
name?: string;
|
|
34
184
|
email?: string;
|
|
@@ -39,27 +189,97 @@ declare class BrowserPGPAdapter implements VanaPGPAdapter {
|
|
|
39
189
|
}>;
|
|
40
190
|
}
|
|
41
191
|
/**
|
|
42
|
-
*
|
|
192
|
+
* Implements HTTP operations for browser environments.
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* Uses the native Fetch API available in all modern browsers.
|
|
196
|
+
*
|
|
197
|
+
* @internal
|
|
43
198
|
*/
|
|
44
199
|
declare class BrowserHttpAdapter implements VanaHttpAdapter {
|
|
200
|
+
/**
|
|
201
|
+
* Performs an HTTP request using the Fetch API.
|
|
202
|
+
*
|
|
203
|
+
* @param url - The URL to fetch.
|
|
204
|
+
* Must be a valid HTTP/HTTPS URL.
|
|
205
|
+
* @param options - Standard fetch options.
|
|
206
|
+
* See MDN fetch documentation for details.
|
|
207
|
+
* @returns Standard fetch Response object
|
|
208
|
+
*/
|
|
45
209
|
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
46
210
|
}
|
|
47
211
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
212
|
+
* Implements secure caching for browser environments.
|
|
213
|
+
*
|
|
214
|
+
* @remarks
|
|
215
|
+
* Uses sessionStorage for temporary caching that's automatically cleared
|
|
216
|
+
* when the browser tab closes. This provides better security for sensitive
|
|
217
|
+
* data like signatures compared to localStorage. All keys are prefixed to
|
|
218
|
+
* avoid conflicts with other applications.
|
|
219
|
+
*
|
|
220
|
+
* @internal
|
|
50
221
|
*/
|
|
51
222
|
declare class BrowserCacheAdapter implements VanaCacheAdapter {
|
|
52
223
|
private readonly prefix;
|
|
224
|
+
/**
|
|
225
|
+
* Retrieves a cached value by key.
|
|
226
|
+
*
|
|
227
|
+
* @param key - The cache key to look up.
|
|
228
|
+
* Automatically prefixed to avoid conflicts.
|
|
229
|
+
* @returns The cached value or null if not found
|
|
230
|
+
*/
|
|
53
231
|
get(key: string): string | null;
|
|
232
|
+
/**
|
|
233
|
+
* Stores a value in sessionStorage.
|
|
234
|
+
*
|
|
235
|
+
* @param key - The cache key.
|
|
236
|
+
* Automatically prefixed with 'vana_cache_'.
|
|
237
|
+
* @param value - The value to cache.
|
|
238
|
+
* Will be cleared when tab closes.
|
|
239
|
+
*/
|
|
54
240
|
set(key: string, value: string): void;
|
|
241
|
+
/**
|
|
242
|
+
* Removes a specific key from the cache.
|
|
243
|
+
*
|
|
244
|
+
* @param key - The cache key to remove.
|
|
245
|
+
* Only removes the prefixed key.
|
|
246
|
+
*/
|
|
55
247
|
delete(key: string): void;
|
|
248
|
+
/**
|
|
249
|
+
* Clears all Vana-prefixed cache entries.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* Only removes entries with the 'vana_cache_' prefix,
|
|
253
|
+
* preserving other sessionStorage data.
|
|
254
|
+
*/
|
|
56
255
|
clear(): void;
|
|
57
256
|
}
|
|
58
257
|
/**
|
|
59
|
-
*
|
|
258
|
+
* Provides complete platform abstraction for browser environments.
|
|
259
|
+
*
|
|
260
|
+
* @remarks
|
|
261
|
+
* This adapter aggregates all browser-specific implementations of platform
|
|
262
|
+
* operations. It uses native Web APIs where possible and browser-compatible
|
|
263
|
+
* libraries for crypto and PGP operations. The adapter automatically selects
|
|
264
|
+
* appropriate cryptographic implementations based on feature flags.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* // Create a browser adapter instance
|
|
269
|
+
* const adapter = new BrowserPlatformAdapter();
|
|
270
|
+
*
|
|
271
|
+
* // All platform operations are available
|
|
272
|
+
* const encrypted = await adapter.crypto.encryptWithPublicKey(
|
|
273
|
+
* 'secret',
|
|
274
|
+
* publicKey
|
|
275
|
+
* );
|
|
276
|
+
*
|
|
277
|
+
* const response = await adapter.http.fetch('/api/data');
|
|
278
|
+
*
|
|
279
|
+
* adapter.cache.set('key', 'value'); // Uses sessionStorage
|
|
280
|
+
* ```
|
|
60
281
|
*
|
|
61
|
-
*
|
|
62
|
-
* without requiring any Node.js polyfills.
|
|
282
|
+
* @category Platform
|
|
63
283
|
*/
|
|
64
284
|
export declare class BrowserPlatformAdapter implements VanaPlatformAdapter {
|
|
65
285
|
readonly crypto: BrowserCryptoAdapter;
|
package/dist/platform/browser.js
CHANGED
|
@@ -15,6 +15,17 @@ class BrowserCryptoAdapter {
|
|
|
15
15
|
customWalletService = new WalletKeyEncryptionService({
|
|
16
16
|
eciesProvider: this.customEciesProvider
|
|
17
17
|
});
|
|
18
|
+
/**
|
|
19
|
+
* Encrypts data using ECIES with a public key.
|
|
20
|
+
*
|
|
21
|
+
* @param data - The plaintext string to encrypt.
|
|
22
|
+
* Typically user data or sensitive information.
|
|
23
|
+
* @param publicKeyHex - The recipient's public key in hex format.
|
|
24
|
+
* Can include or omit the '0x' prefix.
|
|
25
|
+
* @returns Encrypted data as a hex string without '0x' prefix
|
|
26
|
+
*
|
|
27
|
+
* @throws {Error} If encryption fails or public key is invalid
|
|
28
|
+
*/
|
|
18
29
|
async encryptWithPublicKey(data, publicKeyHex) {
|
|
19
30
|
try {
|
|
20
31
|
if (features.useCustomECIES) {
|
|
@@ -35,7 +46,10 @@ class BrowserCryptoAdapter {
|
|
|
35
46
|
const eccryptojs = await getEccryptoJS();
|
|
36
47
|
const cleanKey = publicKeyHex.startsWith("0x") ? publicKeyHex.slice(2) : publicKeyHex;
|
|
37
48
|
const publicKeyBytes = Buffer.from(cleanKey, "hex");
|
|
38
|
-
const
|
|
49
|
+
const uncompressed = this.customEciesProvider.normalizeToUncompressed(
|
|
50
|
+
new Uint8Array(publicKeyBytes)
|
|
51
|
+
);
|
|
52
|
+
const publicKeyBuffer = Buffer.from(uncompressed);
|
|
39
53
|
const message = Buffer.from(data, "utf8");
|
|
40
54
|
const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);
|
|
41
55
|
const result = Buffer.concat([
|
|
@@ -50,6 +64,17 @@ class BrowserCryptoAdapter {
|
|
|
50
64
|
throw wrapCryptoError("encryptWithPublicKey", error);
|
|
51
65
|
}
|
|
52
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Decrypts ECIES-encrypted data using a private key.
|
|
69
|
+
*
|
|
70
|
+
* @param encryptedData - Hex string containing encrypted data.
|
|
71
|
+
* Can include or omit the '0x' prefix.
|
|
72
|
+
* @param privateKeyHex - The private key in hex format.
|
|
73
|
+
* Must correspond to the public key used for encryption.
|
|
74
|
+
* @returns The decrypted plaintext string
|
|
75
|
+
*
|
|
76
|
+
* @throws {Error} If decryption fails or MAC verification fails
|
|
77
|
+
*/
|
|
53
78
|
async decryptWithPrivateKey(encryptedData, privateKeyHex) {
|
|
54
79
|
try {
|
|
55
80
|
if (features.useCustomECIES) {
|
|
@@ -80,6 +105,17 @@ class BrowserCryptoAdapter {
|
|
|
80
105
|
throw wrapCryptoError("decryptWithPrivateKey", error);
|
|
81
106
|
}
|
|
82
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Encrypts data using a wallet's public key.
|
|
110
|
+
*
|
|
111
|
+
* @param data - The plaintext string to encrypt.
|
|
112
|
+
* Typically permission data or DLP metadata.
|
|
113
|
+
* @param publicKey - The wallet's public key.
|
|
114
|
+
* Automatically handles compressed/uncompressed formats.
|
|
115
|
+
* @returns Encrypted data as a hex string
|
|
116
|
+
*
|
|
117
|
+
* @throws {Error} If encryption fails or key processing fails
|
|
118
|
+
*/
|
|
83
119
|
async encryptWithWalletPublicKey(data, publicKey) {
|
|
84
120
|
try {
|
|
85
121
|
if (features.useCustomECIES) {
|
|
@@ -91,7 +127,10 @@ class BrowserCryptoAdapter {
|
|
|
91
127
|
const eccryptojs = await getEccryptoJS();
|
|
92
128
|
const cleanKey = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
93
129
|
const publicKeyBytes = Buffer.from(cleanKey, "hex");
|
|
94
|
-
const
|
|
130
|
+
const uncompressed = this.customEciesProvider.normalizeToUncompressed(
|
|
131
|
+
new Uint8Array(publicKeyBytes)
|
|
132
|
+
);
|
|
133
|
+
const publicKeyBuffer = Buffer.from(uncompressed);
|
|
95
134
|
const message = Buffer.from(data, "utf8");
|
|
96
135
|
const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);
|
|
97
136
|
const result = Buffer.concat([
|
|
@@ -106,6 +145,17 @@ class BrowserCryptoAdapter {
|
|
|
106
145
|
throw wrapCryptoError("encryptWithWalletPublicKey", error);
|
|
107
146
|
}
|
|
108
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Decrypts data using a wallet's private key.
|
|
150
|
+
*
|
|
151
|
+
* @param encryptedData - Hex string containing encrypted data.
|
|
152
|
+
* Must be encrypted with corresponding wallet public key.
|
|
153
|
+
* @param privateKey - The wallet's private key.
|
|
154
|
+
* Obtain from wallet connection (handle with care).
|
|
155
|
+
* @returns The decrypted plaintext string
|
|
156
|
+
*
|
|
157
|
+
* @throws {Error} If decryption fails or key is invalid
|
|
158
|
+
*/
|
|
109
159
|
async decryptWithWalletPrivateKey(encryptedData, privateKey) {
|
|
110
160
|
try {
|
|
111
161
|
if (features.useCustomECIES) {
|
|
@@ -130,6 +180,15 @@ class BrowserCryptoAdapter {
|
|
|
130
180
|
throw wrapCryptoError("decryptWithWalletPrivateKey", error);
|
|
131
181
|
}
|
|
132
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Generates a new secp256k1 key pair for ECIES operations.
|
|
185
|
+
*
|
|
186
|
+
* @returns Object containing hex-encoded public and private keys
|
|
187
|
+
* @returns returns.privateKey - Private key in hex format without '0x'
|
|
188
|
+
* @returns returns.publicKey - Compressed public key in hex format without '0x'
|
|
189
|
+
*
|
|
190
|
+
* @throws {Error} If key generation fails
|
|
191
|
+
*/
|
|
133
192
|
async generateKeyPair() {
|
|
134
193
|
try {
|
|
135
194
|
if (features.useCustomECIES) {
|
|
@@ -152,6 +211,21 @@ class BrowserCryptoAdapter {
|
|
|
152
211
|
throw wrapCryptoError("generateKeyPair", error);
|
|
153
212
|
}
|
|
154
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Encrypts binary data using password-based encryption.
|
|
216
|
+
*
|
|
217
|
+
* @param data - Binary data to encrypt.
|
|
218
|
+
* Typically file contents or serialized objects.
|
|
219
|
+
* @param password - Password for encryption.
|
|
220
|
+
* Often derived from wallet signatures.
|
|
221
|
+
* @returns Encrypted data as Uint8Array
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* Uses OpenPGP for password-based encryption with automatic
|
|
225
|
+
* salt generation for security.
|
|
226
|
+
*
|
|
227
|
+
* @throws {Error} If encryption fails
|
|
228
|
+
*/
|
|
155
229
|
async encryptWithPassword(data, password) {
|
|
156
230
|
try {
|
|
157
231
|
const openpgp = await getOpenPGP();
|
|
@@ -166,6 +240,17 @@ class BrowserCryptoAdapter {
|
|
|
166
240
|
throw wrapCryptoError("encryptWithPassword", error);
|
|
167
241
|
}
|
|
168
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Decrypts password-encrypted binary data.
|
|
245
|
+
*
|
|
246
|
+
* @param encryptedData - Password-encrypted data as Uint8Array.
|
|
247
|
+
* Must be encrypted with the same password.
|
|
248
|
+
* @param password - Password for decryption.
|
|
249
|
+
* Must match the encryption password.
|
|
250
|
+
* @returns Decrypted data as Uint8Array
|
|
251
|
+
*
|
|
252
|
+
* @throws {Error} If decryption fails or password is incorrect
|
|
253
|
+
*/
|
|
169
254
|
async decryptWithPassword(encryptedData, password) {
|
|
170
255
|
try {
|
|
171
256
|
const openpgp = await getOpenPGP();
|
|
@@ -184,6 +269,17 @@ class BrowserCryptoAdapter {
|
|
|
184
269
|
}
|
|
185
270
|
}
|
|
186
271
|
class BrowserPGPAdapter {
|
|
272
|
+
/**
|
|
273
|
+
* Encrypts data using PGP public key encryption.
|
|
274
|
+
*
|
|
275
|
+
* @param data - The plaintext string to encrypt.
|
|
276
|
+
* Typically messages or structured data.
|
|
277
|
+
* @param publicKeyArmored - ASCII-armored PGP public key.
|
|
278
|
+
* Obtain from PGP key generation or key servers.
|
|
279
|
+
* @returns ASCII-armored encrypted message
|
|
280
|
+
*
|
|
281
|
+
* @throws {Error} If encryption fails or public key is invalid
|
|
282
|
+
*/
|
|
187
283
|
async encrypt(data, publicKeyArmored) {
|
|
188
284
|
try {
|
|
189
285
|
const openpgp = await getOpenPGP();
|
|
@@ -200,6 +296,17 @@ class BrowserPGPAdapter {
|
|
|
200
296
|
throw new Error(`PGP encryption failed: ${String(error)}`);
|
|
201
297
|
}
|
|
202
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Decrypts PGP-encrypted data using a private key.
|
|
301
|
+
*
|
|
302
|
+
* @param encryptedData - ASCII-armored encrypted message.
|
|
303
|
+
* Must be encrypted with corresponding public key.
|
|
304
|
+
* @param privateKeyArmored - ASCII-armored PGP private key.
|
|
305
|
+
* Must correspond to the public key used for encryption.
|
|
306
|
+
* @returns The decrypted plaintext string
|
|
307
|
+
*
|
|
308
|
+
* @throws {Error} If decryption fails or private key is invalid
|
|
309
|
+
*/
|
|
203
310
|
async decrypt(encryptedData, privateKeyArmored) {
|
|
204
311
|
try {
|
|
205
312
|
const openpgp = await getOpenPGP();
|
|
@@ -218,6 +325,20 @@ class BrowserPGPAdapter {
|
|
|
218
325
|
throw new Error(`PGP decryption failed: ${String(error)}`);
|
|
219
326
|
}
|
|
220
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Generates a new PGP key pair.
|
|
330
|
+
*
|
|
331
|
+
* @param options - Key generation options
|
|
332
|
+
* @param options.name - Name for the key identity.
|
|
333
|
+
* Defaults to 'Vana User'.
|
|
334
|
+
* @param options.email - Email for the key identity.
|
|
335
|
+
* Defaults to 'user@vana.com'.
|
|
336
|
+
* @param options.passphrase - Passphrase to protect the private key.
|
|
337
|
+
* If not provided, key is unprotected.
|
|
338
|
+
* @returns ASCII-armored public and private keys
|
|
339
|
+
*
|
|
340
|
+
* @throws {Error} If key generation fails
|
|
341
|
+
*/
|
|
221
342
|
async generateKeyPair(options) {
|
|
222
343
|
try {
|
|
223
344
|
const openpgp = await getOpenPGP();
|
|
@@ -230,12 +351,28 @@ class BrowserPGPAdapter {
|
|
|
230
351
|
}
|
|
231
352
|
}
|
|
232
353
|
class BrowserHttpAdapter {
|
|
354
|
+
/**
|
|
355
|
+
* Performs an HTTP request using the Fetch API.
|
|
356
|
+
*
|
|
357
|
+
* @param url - The URL to fetch.
|
|
358
|
+
* Must be a valid HTTP/HTTPS URL.
|
|
359
|
+
* @param options - Standard fetch options.
|
|
360
|
+
* See MDN fetch documentation for details.
|
|
361
|
+
* @returns Standard fetch Response object
|
|
362
|
+
*/
|
|
233
363
|
async fetch(url, options) {
|
|
234
364
|
return fetch(url, options);
|
|
235
365
|
}
|
|
236
366
|
}
|
|
237
367
|
class BrowserCacheAdapter {
|
|
238
368
|
prefix = "vana_cache_";
|
|
369
|
+
/**
|
|
370
|
+
* Retrieves a cached value by key.
|
|
371
|
+
*
|
|
372
|
+
* @param key - The cache key to look up.
|
|
373
|
+
* Automatically prefixed to avoid conflicts.
|
|
374
|
+
* @returns The cached value or null if not found
|
|
375
|
+
*/
|
|
239
376
|
get(key) {
|
|
240
377
|
try {
|
|
241
378
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -246,6 +383,14 @@ class BrowserCacheAdapter {
|
|
|
246
383
|
return null;
|
|
247
384
|
}
|
|
248
385
|
}
|
|
386
|
+
/**
|
|
387
|
+
* Stores a value in sessionStorage.
|
|
388
|
+
*
|
|
389
|
+
* @param key - The cache key.
|
|
390
|
+
* Automatically prefixed with 'vana_cache_'.
|
|
391
|
+
* @param value - The value to cache.
|
|
392
|
+
* Will be cleared when tab closes.
|
|
393
|
+
*/
|
|
249
394
|
set(key, value) {
|
|
250
395
|
try {
|
|
251
396
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -255,6 +400,12 @@ class BrowserCacheAdapter {
|
|
|
255
400
|
} catch {
|
|
256
401
|
}
|
|
257
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Removes a specific key from the cache.
|
|
405
|
+
*
|
|
406
|
+
* @param key - The cache key to remove.
|
|
407
|
+
* Only removes the prefixed key.
|
|
408
|
+
*/
|
|
258
409
|
delete(key) {
|
|
259
410
|
try {
|
|
260
411
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -264,6 +415,13 @@ class BrowserCacheAdapter {
|
|
|
264
415
|
} catch {
|
|
265
416
|
}
|
|
266
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* Clears all Vana-prefixed cache entries.
|
|
420
|
+
*
|
|
421
|
+
* @remarks
|
|
422
|
+
* Only removes entries with the 'vana_cache_' prefix,
|
|
423
|
+
* preserving other sessionStorage data.
|
|
424
|
+
*/
|
|
267
425
|
clear() {
|
|
268
426
|
try {
|
|
269
427
|
if (typeof sessionStorage === "undefined") {
|