@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
|
@@ -48,6 +48,17 @@ class BrowserCryptoAdapter {
|
|
|
48
48
|
customWalletService = new import_WalletKeyEncryptionService.WalletKeyEncryptionService({
|
|
49
49
|
eciesProvider: this.customEciesProvider
|
|
50
50
|
});
|
|
51
|
+
/**
|
|
52
|
+
* Encrypts data using ECIES with a public key.
|
|
53
|
+
*
|
|
54
|
+
* @param data - The plaintext string to encrypt.
|
|
55
|
+
* Typically user data or sensitive information.
|
|
56
|
+
* @param publicKeyHex - The recipient's public key in hex format.
|
|
57
|
+
* Can include or omit the '0x' prefix.
|
|
58
|
+
* @returns Encrypted data as a hex string without '0x' prefix
|
|
59
|
+
*
|
|
60
|
+
* @throws {Error} If encryption fails or public key is invalid
|
|
61
|
+
*/
|
|
51
62
|
async encryptWithPublicKey(data, publicKeyHex) {
|
|
52
63
|
try {
|
|
53
64
|
if (import_features.features.useCustomECIES) {
|
|
@@ -68,7 +79,10 @@ class BrowserCryptoAdapter {
|
|
|
68
79
|
const eccryptojs = await getEccryptoJS();
|
|
69
80
|
const cleanKey = publicKeyHex.startsWith("0x") ? publicKeyHex.slice(2) : publicKeyHex;
|
|
70
81
|
const publicKeyBytes = Buffer.from(cleanKey, "hex");
|
|
71
|
-
const
|
|
82
|
+
const uncompressed = this.customEciesProvider.normalizeToUncompressed(
|
|
83
|
+
new Uint8Array(publicKeyBytes)
|
|
84
|
+
);
|
|
85
|
+
const publicKeyBuffer = Buffer.from(uncompressed);
|
|
72
86
|
const message = Buffer.from(data, "utf8");
|
|
73
87
|
const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);
|
|
74
88
|
const result = Buffer.concat([
|
|
@@ -83,6 +97,17 @@ class BrowserCryptoAdapter {
|
|
|
83
97
|
throw (0, import_error_utils.wrapCryptoError)("encryptWithPublicKey", error);
|
|
84
98
|
}
|
|
85
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Decrypts ECIES-encrypted data using a private key.
|
|
102
|
+
*
|
|
103
|
+
* @param encryptedData - Hex string containing encrypted data.
|
|
104
|
+
* Can include or omit the '0x' prefix.
|
|
105
|
+
* @param privateKeyHex - The private key in hex format.
|
|
106
|
+
* Must correspond to the public key used for encryption.
|
|
107
|
+
* @returns The decrypted plaintext string
|
|
108
|
+
*
|
|
109
|
+
* @throws {Error} If decryption fails or MAC verification fails
|
|
110
|
+
*/
|
|
86
111
|
async decryptWithPrivateKey(encryptedData, privateKeyHex) {
|
|
87
112
|
try {
|
|
88
113
|
if (import_features.features.useCustomECIES) {
|
|
@@ -113,6 +138,17 @@ class BrowserCryptoAdapter {
|
|
|
113
138
|
throw (0, import_error_utils.wrapCryptoError)("decryptWithPrivateKey", error);
|
|
114
139
|
}
|
|
115
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Encrypts data using a wallet's public key.
|
|
143
|
+
*
|
|
144
|
+
* @param data - The plaintext string to encrypt.
|
|
145
|
+
* Typically permission data or DLP metadata.
|
|
146
|
+
* @param publicKey - The wallet's public key.
|
|
147
|
+
* Automatically handles compressed/uncompressed formats.
|
|
148
|
+
* @returns Encrypted data as a hex string
|
|
149
|
+
*
|
|
150
|
+
* @throws {Error} If encryption fails or key processing fails
|
|
151
|
+
*/
|
|
116
152
|
async encryptWithWalletPublicKey(data, publicKey) {
|
|
117
153
|
try {
|
|
118
154
|
if (import_features.features.useCustomECIES) {
|
|
@@ -124,7 +160,10 @@ class BrowserCryptoAdapter {
|
|
|
124
160
|
const eccryptojs = await getEccryptoJS();
|
|
125
161
|
const cleanKey = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
126
162
|
const publicKeyBytes = Buffer.from(cleanKey, "hex");
|
|
127
|
-
const
|
|
163
|
+
const uncompressed = this.customEciesProvider.normalizeToUncompressed(
|
|
164
|
+
new Uint8Array(publicKeyBytes)
|
|
165
|
+
);
|
|
166
|
+
const publicKeyBuffer = Buffer.from(uncompressed);
|
|
128
167
|
const message = Buffer.from(data, "utf8");
|
|
129
168
|
const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);
|
|
130
169
|
const result = Buffer.concat([
|
|
@@ -139,6 +178,17 @@ class BrowserCryptoAdapter {
|
|
|
139
178
|
throw (0, import_error_utils.wrapCryptoError)("encryptWithWalletPublicKey", error);
|
|
140
179
|
}
|
|
141
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Decrypts data using a wallet's private key.
|
|
183
|
+
*
|
|
184
|
+
* @param encryptedData - Hex string containing encrypted data.
|
|
185
|
+
* Must be encrypted with corresponding wallet public key.
|
|
186
|
+
* @param privateKey - The wallet's private key.
|
|
187
|
+
* Obtain from wallet connection (handle with care).
|
|
188
|
+
* @returns The decrypted plaintext string
|
|
189
|
+
*
|
|
190
|
+
* @throws {Error} If decryption fails or key is invalid
|
|
191
|
+
*/
|
|
142
192
|
async decryptWithWalletPrivateKey(encryptedData, privateKey) {
|
|
143
193
|
try {
|
|
144
194
|
if (import_features.features.useCustomECIES) {
|
|
@@ -163,6 +213,15 @@ class BrowserCryptoAdapter {
|
|
|
163
213
|
throw (0, import_error_utils.wrapCryptoError)("decryptWithWalletPrivateKey", error);
|
|
164
214
|
}
|
|
165
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Generates a new secp256k1 key pair for ECIES operations.
|
|
218
|
+
*
|
|
219
|
+
* @returns Object containing hex-encoded public and private keys
|
|
220
|
+
* @returns returns.privateKey - Private key in hex format without '0x'
|
|
221
|
+
* @returns returns.publicKey - Compressed public key in hex format without '0x'
|
|
222
|
+
*
|
|
223
|
+
* @throws {Error} If key generation fails
|
|
224
|
+
*/
|
|
166
225
|
async generateKeyPair() {
|
|
167
226
|
try {
|
|
168
227
|
if (import_features.features.useCustomECIES) {
|
|
@@ -185,6 +244,21 @@ class BrowserCryptoAdapter {
|
|
|
185
244
|
throw (0, import_error_utils.wrapCryptoError)("generateKeyPair", error);
|
|
186
245
|
}
|
|
187
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Encrypts binary data using password-based encryption.
|
|
249
|
+
*
|
|
250
|
+
* @param data - Binary data to encrypt.
|
|
251
|
+
* Typically file contents or serialized objects.
|
|
252
|
+
* @param password - Password for encryption.
|
|
253
|
+
* Often derived from wallet signatures.
|
|
254
|
+
* @returns Encrypted data as Uint8Array
|
|
255
|
+
*
|
|
256
|
+
* @remarks
|
|
257
|
+
* Uses OpenPGP for password-based encryption with automatic
|
|
258
|
+
* salt generation for security.
|
|
259
|
+
*
|
|
260
|
+
* @throws {Error} If encryption fails
|
|
261
|
+
*/
|
|
188
262
|
async encryptWithPassword(data, password) {
|
|
189
263
|
try {
|
|
190
264
|
const openpgp = await getOpenPGP();
|
|
@@ -199,6 +273,17 @@ class BrowserCryptoAdapter {
|
|
|
199
273
|
throw (0, import_error_utils.wrapCryptoError)("encryptWithPassword", error);
|
|
200
274
|
}
|
|
201
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Decrypts password-encrypted binary data.
|
|
278
|
+
*
|
|
279
|
+
* @param encryptedData - Password-encrypted data as Uint8Array.
|
|
280
|
+
* Must be encrypted with the same password.
|
|
281
|
+
* @param password - Password for decryption.
|
|
282
|
+
* Must match the encryption password.
|
|
283
|
+
* @returns Decrypted data as Uint8Array
|
|
284
|
+
*
|
|
285
|
+
* @throws {Error} If decryption fails or password is incorrect
|
|
286
|
+
*/
|
|
202
287
|
async decryptWithPassword(encryptedData, password) {
|
|
203
288
|
try {
|
|
204
289
|
const openpgp = await getOpenPGP();
|
|
@@ -217,6 +302,17 @@ class BrowserCryptoAdapter {
|
|
|
217
302
|
}
|
|
218
303
|
}
|
|
219
304
|
class BrowserPGPAdapter {
|
|
305
|
+
/**
|
|
306
|
+
* Encrypts data using PGP public key encryption.
|
|
307
|
+
*
|
|
308
|
+
* @param data - The plaintext string to encrypt.
|
|
309
|
+
* Typically messages or structured data.
|
|
310
|
+
* @param publicKeyArmored - ASCII-armored PGP public key.
|
|
311
|
+
* Obtain from PGP key generation or key servers.
|
|
312
|
+
* @returns ASCII-armored encrypted message
|
|
313
|
+
*
|
|
314
|
+
* @throws {Error} If encryption fails or public key is invalid
|
|
315
|
+
*/
|
|
220
316
|
async encrypt(data, publicKeyArmored) {
|
|
221
317
|
try {
|
|
222
318
|
const openpgp = await getOpenPGP();
|
|
@@ -233,6 +329,17 @@ class BrowserPGPAdapter {
|
|
|
233
329
|
throw new Error(`PGP encryption failed: ${String(error)}`);
|
|
234
330
|
}
|
|
235
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Decrypts PGP-encrypted data using a private key.
|
|
334
|
+
*
|
|
335
|
+
* @param encryptedData - ASCII-armored encrypted message.
|
|
336
|
+
* Must be encrypted with corresponding public key.
|
|
337
|
+
* @param privateKeyArmored - ASCII-armored PGP private key.
|
|
338
|
+
* Must correspond to the public key used for encryption.
|
|
339
|
+
* @returns The decrypted plaintext string
|
|
340
|
+
*
|
|
341
|
+
* @throws {Error} If decryption fails or private key is invalid
|
|
342
|
+
*/
|
|
236
343
|
async decrypt(encryptedData, privateKeyArmored) {
|
|
237
344
|
try {
|
|
238
345
|
const openpgp = await getOpenPGP();
|
|
@@ -251,6 +358,20 @@ class BrowserPGPAdapter {
|
|
|
251
358
|
throw new Error(`PGP decryption failed: ${String(error)}`);
|
|
252
359
|
}
|
|
253
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Generates a new PGP key pair.
|
|
363
|
+
*
|
|
364
|
+
* @param options - Key generation options
|
|
365
|
+
* @param options.name - Name for the key identity.
|
|
366
|
+
* Defaults to 'Vana User'.
|
|
367
|
+
* @param options.email - Email for the key identity.
|
|
368
|
+
* Defaults to 'user@vana.com'.
|
|
369
|
+
* @param options.passphrase - Passphrase to protect the private key.
|
|
370
|
+
* If not provided, key is unprotected.
|
|
371
|
+
* @returns ASCII-armored public and private keys
|
|
372
|
+
*
|
|
373
|
+
* @throws {Error} If key generation fails
|
|
374
|
+
*/
|
|
254
375
|
async generateKeyPair(options) {
|
|
255
376
|
try {
|
|
256
377
|
const openpgp = await getOpenPGP();
|
|
@@ -263,12 +384,28 @@ class BrowserPGPAdapter {
|
|
|
263
384
|
}
|
|
264
385
|
}
|
|
265
386
|
class BrowserHttpAdapter {
|
|
387
|
+
/**
|
|
388
|
+
* Performs an HTTP request using the Fetch API.
|
|
389
|
+
*
|
|
390
|
+
* @param url - The URL to fetch.
|
|
391
|
+
* Must be a valid HTTP/HTTPS URL.
|
|
392
|
+
* @param options - Standard fetch options.
|
|
393
|
+
* See MDN fetch documentation for details.
|
|
394
|
+
* @returns Standard fetch Response object
|
|
395
|
+
*/
|
|
266
396
|
async fetch(url, options) {
|
|
267
397
|
return fetch(url, options);
|
|
268
398
|
}
|
|
269
399
|
}
|
|
270
400
|
class BrowserCacheAdapter {
|
|
271
401
|
prefix = "vana_cache_";
|
|
402
|
+
/**
|
|
403
|
+
* Retrieves a cached value by key.
|
|
404
|
+
*
|
|
405
|
+
* @param key - The cache key to look up.
|
|
406
|
+
* Automatically prefixed to avoid conflicts.
|
|
407
|
+
* @returns The cached value or null if not found
|
|
408
|
+
*/
|
|
272
409
|
get(key) {
|
|
273
410
|
try {
|
|
274
411
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -279,6 +416,14 @@ class BrowserCacheAdapter {
|
|
|
279
416
|
return null;
|
|
280
417
|
}
|
|
281
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Stores a value in sessionStorage.
|
|
421
|
+
*
|
|
422
|
+
* @param key - The cache key.
|
|
423
|
+
* Automatically prefixed with 'vana_cache_'.
|
|
424
|
+
* @param value - The value to cache.
|
|
425
|
+
* Will be cleared when tab closes.
|
|
426
|
+
*/
|
|
282
427
|
set(key, value) {
|
|
283
428
|
try {
|
|
284
429
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -288,6 +433,12 @@ class BrowserCacheAdapter {
|
|
|
288
433
|
} catch {
|
|
289
434
|
}
|
|
290
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Removes a specific key from the cache.
|
|
438
|
+
*
|
|
439
|
+
* @param key - The cache key to remove.
|
|
440
|
+
* Only removes the prefixed key.
|
|
441
|
+
*/
|
|
291
442
|
delete(key) {
|
|
292
443
|
try {
|
|
293
444
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -297,6 +448,13 @@ class BrowserCacheAdapter {
|
|
|
297
448
|
} catch {
|
|
298
449
|
}
|
|
299
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* Clears all Vana-prefixed cache entries.
|
|
453
|
+
*
|
|
454
|
+
* @remarks
|
|
455
|
+
* Only removes entries with the 'vana_cache_' prefix,
|
|
456
|
+
* preserving other sessionStorage data.
|
|
457
|
+
*/
|
|
300
458
|
clear() {
|
|
301
459
|
try {
|
|
302
460
|
if (typeof sessionStorage === "undefined") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/platform/browser.ts"],"sourcesContent":["/**\n * Browser implementation of the Vana Platform Adapter using Uint8Array\n *\n * This implementation uses browser-compatible libraries and native APIs\n * without requiring Buffer or other Node.js polyfills.\n */\n\nimport type {\n VanaPlatformAdapter,\n VanaCryptoAdapter,\n VanaPGPAdapter,\n VanaHttpAdapter,\n VanaCacheAdapter,\n} from \"./interface\";\nimport { getPGPKeyGenParams } from \"./shared/pgp-utils\";\nimport { wrapCryptoError } from \"./shared/error-utils\";\nimport { lazyImport } from \"../utils/lazy-import\";\nimport { WalletKeyEncryptionService } from \"../crypto/services/WalletKeyEncryptionService\";\nimport { parseEncryptedDataBuffer } from \"../utils/crypto-utils\";\nimport { toHex, fromHex, stringToBytes, bytesToString, concat } from \"viem\";\nimport * as secp256k1 from \"@noble/secp256k1\";\nimport { features } from \"../config/features\";\n\n// Import browser ECIES provider\nimport { BrowserECIESUint8Provider } from \"../crypto/ecies/browser\";\n\n// Lazy-loaded dependencies to avoid Turbopack TDZ issues\nconst getOpenPGP = lazyImport(() => import(\"openpgp\"));\nconst getEccryptoJS = lazyImport(() => import(\"eccrypto-js\"));\n\n/**\n * Browser implementation of crypto operations using Uint8Array\n * Supports both eccrypto-js (default) and custom ECIES implementation\n */\nclass BrowserCryptoAdapter implements VanaCryptoAdapter {\n // Initialize both providers - only one will be used based on feature flag\n private customEciesProvider = new BrowserECIESUint8Provider();\n private customWalletService = new WalletKeyEncryptionService({\n eciesProvider: this.customEciesProvider,\n });\n\n async encryptWithPublicKey(\n data: string,\n publicKeyHex: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation\n const prefixedHex = publicKeyHex.startsWith(\"0x\")\n ? publicKeyHex\n : `0x${publicKeyHex}`;\n const publicKeyBytes = fromHex(prefixedHex as `0x${string}`, \"bytes\");\n\n // Encrypt data using ECIES\n const encrypted = await this.customEciesProvider.encrypt(\n publicKeyBytes,\n stringToBytes(data),\n );\n\n // Concatenate all components and return as hex string\n const result = concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return toHex(result).slice(2); // Remove '0x' prefix for backward compatibility\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n\n // Remove 0x prefix if present\n const cleanKey = publicKeyHex.startsWith(\"0x\")\n ? publicKeyHex.slice(2)\n : publicKeyHex;\n const publicKeyBytes = Buffer.from(cleanKey, \"hex\");\n\n // Ensure public key is in uncompressed format (65 bytes with 0x04 prefix)\n // If it's 64 bytes, add the 0x04 prefix; if already 65 bytes, use as-is\n const publicKeyBuffer =\n publicKeyBytes.length === 64\n ? Buffer.concat([Buffer.from([4]), publicKeyBytes])\n : publicKeyBytes;\n\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);\n\n // Concatenate all components and return as hex string\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n }\n } catch (error) {\n throw wrapCryptoError(\"encryptWithPublicKey\", error);\n }\n }\n\n async decryptWithPrivateKey(\n encryptedData: string,\n privateKeyHex: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation\n const encryptedHex = encryptedData.startsWith(\"0x\")\n ? encryptedData\n : `0x${encryptedData}`;\n const privateHex = privateKeyHex.startsWith(\"0x\")\n ? privateKeyHex\n : `0x${privateKeyHex}`;\n const encryptedBytes = fromHex(encryptedHex as `0x${string}`, \"bytes\");\n const privateKeyBytes = fromHex(privateHex as `0x${string}`, \"bytes\");\n\n // Parse the encrypted data into components\n const encrypted = parseEncryptedDataBuffer(encryptedBytes);\n\n // Decrypt using ECIES\n const decrypted = await this.customEciesProvider.decrypt(\n privateKeyBytes,\n encrypted,\n );\n\n return bytesToString(decrypted);\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const privateKey = Buffer.from(privateKeyHex, \"hex\");\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n\n // Parse the encrypted data\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n const decrypted = await eccryptojs.decrypt(privateKey, {\n iv: Buffer.from(iv),\n ephemPublicKey: Buffer.from(ephemPublicKey),\n ciphertext: Buffer.from(ciphertext),\n mac: Buffer.from(mac),\n });\n\n return decrypted.toString(\"utf8\");\n }\n } catch (error) {\n throw wrapCryptoError(\"decryptWithPrivateKey\", error);\n }\n }\n\n async encryptWithWalletPublicKey(\n data: string,\n publicKey: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation via WalletKeyEncryptionService\n return await this.customWalletService.encryptWithWalletPublicKey(\n data,\n publicKey,\n );\n } else {\n // Use eccrypto-js directly for wallet encryption\n const eccryptojs = await getEccryptoJS();\n\n // Remove 0x prefix if present\n const cleanKey = publicKey.startsWith(\"0x\")\n ? publicKey.slice(2)\n : publicKey;\n const publicKeyBytes = Buffer.from(cleanKey, \"hex\");\n\n // Ensure public key is in uncompressed format (65 bytes with 0x04 prefix)\n // If it's 64 bytes, add the 0x04 prefix; if already 65 bytes, use as-is\n const publicKeyBuffer =\n publicKeyBytes.length === 64\n ? Buffer.concat([Buffer.from([4]), publicKeyBytes])\n : publicKeyBytes;\n\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);\n\n // Concatenate all components and return as hex string\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n }\n } catch (error) {\n throw wrapCryptoError(\"encryptWithWalletPublicKey\", error);\n }\n }\n\n async decryptWithWalletPrivateKey(\n encryptedData: string,\n privateKey: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation via WalletKeyEncryptionService\n return await this.customWalletService.decryptWithWalletPrivateKey(\n encryptedData,\n privateKey,\n );\n } else {\n // Use eccrypto-js directly for wallet decryption\n const eccryptojs = await getEccryptoJS();\n const privateKeyBuffer = Buffer.from(privateKey, \"hex\");\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n\n // Parse the encrypted data\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n const decrypted = await eccryptojs.decrypt(privateKeyBuffer, {\n iv: Buffer.from(iv),\n ephemPublicKey: Buffer.from(ephemPublicKey),\n ciphertext: Buffer.from(ciphertext),\n mac: Buffer.from(mac),\n });\n\n return decrypted.toString(\"utf8\");\n }\n } catch (error) {\n throw wrapCryptoError(\"decryptWithWalletPrivateKey\", error);\n }\n }\n\n async generateKeyPair(): Promise<{\n privateKey: string;\n publicKey: string;\n }> {\n try {\n if (features.useCustomECIES) {\n // Use custom implementation with @noble/secp256k1\n // Generate random private key\n const privateKeyBytes = secp256k1.utils.randomPrivateKey();\n\n // Generate public key (compressed for consistency with Node implementation)\n const publicKeyBytes = secp256k1.getPublicKey(privateKeyBytes, true);\n\n return {\n privateKey: toHex(privateKeyBytes).slice(2),\n publicKey: toHex(publicKeyBytes).slice(2),\n };\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const privateKey = eccryptojs.generatePrivate();\n const publicKey = eccryptojs.getPublic(privateKey);\n\n return {\n privateKey: privateKey.toString(\"hex\"),\n publicKey: publicKey.toString(\"hex\"),\n };\n }\n } catch (error) {\n throw wrapCryptoError(\"generateKeyPair\", error);\n }\n }\n\n async encryptWithPassword(\n data: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n\n // Create a message from the data\n const message = await openpgp.createMessage({ binary: data });\n\n // Encrypt with password\n const encrypted = await openpgp.encrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n return new Uint8Array(encrypted as ArrayBuffer);\n } catch (error) {\n throw wrapCryptoError(\"encryptWithPassword\", error);\n }\n }\n\n async decryptWithPassword(\n encryptedData: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n\n // Read the encrypted message\n const message = await openpgp.readMessage({\n binaryMessage: encryptedData,\n });\n\n // Decrypt with password\n const { data } = await openpgp.decrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n return new Uint8Array(data as ArrayBuffer);\n } catch (error) {\n throw wrapCryptoError(\"decryptWithPassword\", error);\n }\n }\n}\n\n/**\n * Browser implementation of PGP operations\n */\nclass BrowserPGPAdapter implements VanaPGPAdapter {\n async encrypt(data: string, publicKeyArmored: string): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });\n\n const encrypted = await openpgp.encrypt({\n message: await openpgp.createMessage({ text: data }),\n encryptionKeys: publicKey,\n config: {\n preferredCompressionAlgorithm: openpgp.enums.compression.zlib,\n },\n });\n\n return encrypted as string;\n } catch (error) {\n throw new Error(`PGP encryption failed: ${String(error)}`);\n }\n }\n\n async decrypt(\n encryptedData: string,\n privateKeyArmored: string,\n ): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const privateKey = await openpgp.readPrivateKey({\n armoredKey: privateKeyArmored,\n });\n const message = await openpgp.readMessage({\n armoredMessage: encryptedData,\n });\n\n const { data: decrypted } = await openpgp.decrypt({\n message,\n decryptionKeys: privateKey,\n });\n\n return decrypted as string;\n } catch (error) {\n throw new Error(`PGP decryption failed: ${String(error)}`);\n }\n }\n\n async generateKeyPair(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n }): Promise<{ publicKey: string; privateKey: string }> {\n try {\n const openpgp = await getOpenPGP();\n // Use shared utility to get standardized parameters\n const keyGenParams = getPGPKeyGenParams(options);\n\n const { privateKey, publicKey } = await openpgp.generateKey(keyGenParams);\n\n return { publicKey, privateKey };\n } catch (error) {\n throw wrapCryptoError(\"PGP key generation\", error);\n }\n }\n}\n\n/**\n * Browser implementation of HTTP operations using Fetch API\n */\nclass BrowserHttpAdapter implements VanaHttpAdapter {\n async fetch(url: string, options?: RequestInit): Promise<Response> {\n return fetch(url, options);\n }\n}\n\n/**\n * Browser implementation of caching using sessionStorage for security\n * SessionStorage is cleared when the tab closes, making it more secure for signature caching\n */\nclass BrowserCacheAdapter implements VanaCacheAdapter {\n private readonly prefix = \"vana_cache_\";\n\n get(key: string): string | null {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return null;\n }\n return sessionStorage.getItem(this.prefix + key);\n } catch {\n return null;\n }\n }\n\n set(key: string, value: string): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n sessionStorage.setItem(this.prefix + key, value);\n } catch {\n // Ignore storage errors (quota exceeded, etc.)\n }\n }\n\n delete(key: string): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n sessionStorage.removeItem(this.prefix + key);\n } catch {\n // Ignore storage errors\n }\n }\n\n clear(): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n // Only clear our prefixed keys to avoid affecting other data\n const keysToRemove: string[] = [];\n for (let i = 0; i < sessionStorage.length; i++) {\n const key = sessionStorage.key(i);\n if (key?.startsWith(this.prefix)) {\n keysToRemove.push(key);\n }\n }\n keysToRemove.forEach((key) => {\n sessionStorage.removeItem(key);\n });\n } catch {\n // Ignore storage errors\n }\n }\n}\n\n/**\n * Browser implementation of the Vana Platform Adapter\n *\n * This adapter provides all platform-specific functionality for browser environments\n * without requiring any Node.js polyfills.\n */\nexport class BrowserPlatformAdapter implements VanaPlatformAdapter {\n public readonly crypto = new BrowserCryptoAdapter();\n public readonly pgp = new BrowserPGPAdapter();\n public readonly http = new BrowserHttpAdapter();\n public readonly cache = new BrowserCacheAdapter();\n public readonly platform = \"browser\" as const;\n}\n"],"mappings":";;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Q,CAAC,QAAQ;AAC5B,uBAAe,WAAW,GAAG;AAAA,MAC/B,CAAC;AAAA,IACH,QAAQ;AAAA,IAER;AAAA,EACF;AACF;AAQO,MAAM,uBAAsD;AAAA,EACjD,SAAS,IAAI,qBAAqB;AAAA,EAClC,MAAM,IAAI,kBAAkB;AAAA,EAC5B,OAAO,IAAI,mBAAmB;AAAA,EAC9B,QAAQ,IAAI,oBAAoB;AAAA,EAChC,WAAW;AAC7B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/platform/browser.ts"],"sourcesContent":["/**\n * Provides browser-specific implementations of platform abstraction interfaces.\n *\n * @remarks\n * This module implements all platform-specific operations for browser environments,\n * using native Web APIs and browser-compatible libraries. It avoids Node.js-specific\n * dependencies like Buffer, using Uint8Array and viem utilities instead. Supports\n * both standard eccrypto and custom ECIES implementations based on feature flags.\n *\n * @example\n * ```typescript\n * // Use the browser platform adapter\n * import { BrowserPlatformAdapter } from '@vana-sdk/platform/browser';\n *\n * const adapter = new BrowserPlatformAdapter();\n *\n * // Encrypt data with public key\n * const encrypted = await adapter.crypto.encryptWithPublicKey(\n * 'sensitive data',\n * '0x04...' // Public key hex\n * );\n *\n * // Use sessionStorage-backed cache\n * adapter.cache.set('temp_key', 'cached_value');\n * ```\n *\n * @category Platform\n * @module platform/browser\n */\n\nimport type {\n VanaPlatformAdapter,\n VanaCryptoAdapter,\n VanaPGPAdapter,\n VanaHttpAdapter,\n VanaCacheAdapter,\n} from \"./interface\";\nimport { getPGPKeyGenParams } from \"./shared/pgp-utils\";\nimport { wrapCryptoError } from \"./shared/error-utils\";\nimport { lazyImport } from \"../utils/lazy-import\";\nimport { WalletKeyEncryptionService } from \"../crypto/services/WalletKeyEncryptionService\";\nimport { parseEncryptedDataBuffer } from \"../utils/crypto-utils\";\nimport { toHex, fromHex, stringToBytes, bytesToString, concat } from \"viem\";\nimport * as secp256k1 from \"@noble/secp256k1\";\nimport { features } from \"../config/features\";\n\n// Import browser ECIES provider\nimport { BrowserECIESUint8Provider } from \"../crypto/ecies/browser\";\n\n// Lazy-loaded dependencies to avoid Turbopack TDZ issues\nconst getOpenPGP = lazyImport(() => import(\"openpgp\"));\nconst getEccryptoJS = lazyImport(() => import(\"eccrypto-js\"));\n\n/**\n * Implements cryptographic operations for browser environments.\n *\n * @remarks\n * Provides ECIES encryption/decryption, key generation, and password-based\n * encryption using either eccrypto-js or a custom ECIES implementation.\n * Uses Uint8Array and viem utilities for browser compatibility.\n *\n * @internal\n */\nclass BrowserCryptoAdapter implements VanaCryptoAdapter {\n // Initialize both providers - only one will be used based on feature flag\n private customEciesProvider = new BrowserECIESUint8Provider();\n private customWalletService = new WalletKeyEncryptionService({\n eciesProvider: this.customEciesProvider,\n });\n\n /**\n * Encrypts data using ECIES with a public key.\n *\n * @param data - The plaintext string to encrypt.\n * Typically user data or sensitive information.\n * @param publicKeyHex - The recipient's public key in hex format.\n * Can include or omit the '0x' prefix.\n * @returns Encrypted data as a hex string without '0x' prefix\n *\n * @throws {Error} If encryption fails or public key is invalid\n */\n async encryptWithPublicKey(\n data: string,\n publicKeyHex: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation\n const prefixedHex = publicKeyHex.startsWith(\"0x\")\n ? publicKeyHex\n : `0x${publicKeyHex}`;\n const publicKeyBytes = fromHex(prefixedHex as `0x${string}`, \"bytes\");\n\n // Encrypt data using ECIES\n const encrypted = await this.customEciesProvider.encrypt(\n publicKeyBytes,\n stringToBytes(data),\n );\n\n // Concatenate all components and return as hex string\n const result = concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return toHex(result).slice(2); // Remove '0x' prefix for backward compatibility\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n\n // Remove 0x prefix if present\n const cleanKey = publicKeyHex.startsWith(\"0x\")\n ? publicKeyHex.slice(2)\n : publicKeyHex;\n const publicKeyBytes = Buffer.from(cleanKey, \"hex\");\n\n // Normalize to uncompressed format using the ECIES provider\n // This handles both compressed (33 bytes) and uncompressed (65 bytes) keys\n const uncompressed = this.customEciesProvider.normalizeToUncompressed(\n new Uint8Array(publicKeyBytes),\n );\n const publicKeyBuffer = Buffer.from(uncompressed);\n\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);\n\n // Concatenate all components and return as hex string\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n }\n } catch (error) {\n throw wrapCryptoError(\"encryptWithPublicKey\", error);\n }\n }\n\n /**\n * Decrypts ECIES-encrypted data using a private key.\n *\n * @param encryptedData - Hex string containing encrypted data.\n * Can include or omit the '0x' prefix.\n * @param privateKeyHex - The private key in hex format.\n * Must correspond to the public key used for encryption.\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or MAC verification fails\n */\n async decryptWithPrivateKey(\n encryptedData: string,\n privateKeyHex: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation\n const encryptedHex = encryptedData.startsWith(\"0x\")\n ? encryptedData\n : `0x${encryptedData}`;\n const privateHex = privateKeyHex.startsWith(\"0x\")\n ? privateKeyHex\n : `0x${privateKeyHex}`;\n const encryptedBytes = fromHex(encryptedHex as `0x${string}`, \"bytes\");\n const privateKeyBytes = fromHex(privateHex as `0x${string}`, \"bytes\");\n\n // Parse the encrypted data into components\n const encrypted = parseEncryptedDataBuffer(encryptedBytes);\n\n // Decrypt using ECIES\n const decrypted = await this.customEciesProvider.decrypt(\n privateKeyBytes,\n encrypted,\n );\n\n return bytesToString(decrypted);\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const privateKey = Buffer.from(privateKeyHex, \"hex\");\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n\n // Parse the encrypted data\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n const decrypted = await eccryptojs.decrypt(privateKey, {\n iv: Buffer.from(iv),\n ephemPublicKey: Buffer.from(ephemPublicKey),\n ciphertext: Buffer.from(ciphertext),\n mac: Buffer.from(mac),\n });\n\n return decrypted.toString(\"utf8\");\n }\n } catch (error) {\n throw wrapCryptoError(\"decryptWithPrivateKey\", error);\n }\n }\n\n /**\n * Encrypts data using a wallet's public key.\n *\n * @param data - The plaintext string to encrypt.\n * Typically permission data or DLP metadata.\n * @param publicKey - The wallet's public key.\n * Automatically handles compressed/uncompressed formats.\n * @returns Encrypted data as a hex string\n *\n * @throws {Error} If encryption fails or key processing fails\n */\n async encryptWithWalletPublicKey(\n data: string,\n publicKey: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation via WalletKeyEncryptionService\n return await this.customWalletService.encryptWithWalletPublicKey(\n data,\n publicKey,\n );\n } else {\n // Use eccrypto-js directly for wallet encryption\n const eccryptojs = await getEccryptoJS();\n\n // Remove 0x prefix if present\n const cleanKey = publicKey.startsWith(\"0x\")\n ? publicKey.slice(2)\n : publicKey;\n const publicKeyBytes = Buffer.from(cleanKey, \"hex\");\n\n // Normalize to uncompressed format using the ECIES provider\n // This handles both compressed (33 bytes) and uncompressed (65 bytes) keys\n const uncompressed = this.customEciesProvider.normalizeToUncompressed(\n new Uint8Array(publicKeyBytes),\n );\n const publicKeyBuffer = Buffer.from(uncompressed);\n\n const message = Buffer.from(data, \"utf8\");\n\n const encrypted = await eccryptojs.encrypt(publicKeyBuffer, message);\n\n // Concatenate all components and return as hex string\n const result = Buffer.concat([\n encrypted.iv,\n encrypted.ephemPublicKey,\n encrypted.ciphertext,\n encrypted.mac,\n ]);\n\n return result.toString(\"hex\");\n }\n } catch (error) {\n throw wrapCryptoError(\"encryptWithWalletPublicKey\", error);\n }\n }\n\n /**\n * Decrypts data using a wallet's private key.\n *\n * @param encryptedData - Hex string containing encrypted data.\n * Must be encrypted with corresponding wallet public key.\n * @param privateKey - The wallet's private key.\n * Obtain from wallet connection (handle with care).\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or key is invalid\n */\n async decryptWithWalletPrivateKey(\n encryptedData: string,\n privateKey: string,\n ): Promise<string> {\n try {\n if (features.useCustomECIES) {\n // Use custom ECIES implementation via WalletKeyEncryptionService\n return await this.customWalletService.decryptWithWalletPrivateKey(\n encryptedData,\n privateKey,\n );\n } else {\n // Use eccrypto-js directly for wallet decryption\n const eccryptojs = await getEccryptoJS();\n const privateKeyBuffer = Buffer.from(privateKey, \"hex\");\n const encryptedBuffer = Buffer.from(encryptedData, \"hex\");\n\n // Parse the encrypted data\n const { iv, ephemPublicKey, ciphertext, mac } =\n parseEncryptedDataBuffer(encryptedBuffer);\n\n const decrypted = await eccryptojs.decrypt(privateKeyBuffer, {\n iv: Buffer.from(iv),\n ephemPublicKey: Buffer.from(ephemPublicKey),\n ciphertext: Buffer.from(ciphertext),\n mac: Buffer.from(mac),\n });\n\n return decrypted.toString(\"utf8\");\n }\n } catch (error) {\n throw wrapCryptoError(\"decryptWithWalletPrivateKey\", error);\n }\n }\n\n /**\n * Generates a new secp256k1 key pair for ECIES operations.\n *\n * @returns Object containing hex-encoded public and private keys\n * @returns returns.privateKey - Private key in hex format without '0x'\n * @returns returns.publicKey - Compressed public key in hex format without '0x'\n *\n * @throws {Error} If key generation fails\n */\n async generateKeyPair(): Promise<{\n privateKey: string;\n publicKey: string;\n }> {\n try {\n if (features.useCustomECIES) {\n // Use custom implementation with @noble/secp256k1\n // Generate random private key\n const privateKeyBytes = secp256k1.utils.randomPrivateKey();\n\n // Generate public key (compressed for consistency with Node implementation)\n const publicKeyBytes = secp256k1.getPublicKey(privateKeyBytes, true);\n\n return {\n privateKey: toHex(privateKeyBytes).slice(2),\n publicKey: toHex(publicKeyBytes).slice(2),\n };\n } else {\n // Use eccrypto-js (default)\n const eccryptojs = await getEccryptoJS();\n const privateKey = eccryptojs.generatePrivate();\n const publicKey = eccryptojs.getPublic(privateKey);\n\n return {\n privateKey: privateKey.toString(\"hex\"),\n publicKey: publicKey.toString(\"hex\"),\n };\n }\n } catch (error) {\n throw wrapCryptoError(\"generateKeyPair\", error);\n }\n }\n\n /**\n * Encrypts binary data using password-based encryption.\n *\n * @param data - Binary data to encrypt.\n * Typically file contents or serialized objects.\n * @param password - Password for encryption.\n * Often derived from wallet signatures.\n * @returns Encrypted data as Uint8Array\n *\n * @remarks\n * Uses OpenPGP for password-based encryption with automatic\n * salt generation for security.\n *\n * @throws {Error} If encryption fails\n */\n async encryptWithPassword(\n data: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n\n // Create a message from the data\n const message = await openpgp.createMessage({ binary: data });\n\n // Encrypt with password\n const encrypted = await openpgp.encrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n return new Uint8Array(encrypted as ArrayBuffer);\n } catch (error) {\n throw wrapCryptoError(\"encryptWithPassword\", error);\n }\n }\n\n /**\n * Decrypts password-encrypted binary data.\n *\n * @param encryptedData - Password-encrypted data as Uint8Array.\n * Must be encrypted with the same password.\n * @param password - Password for decryption.\n * Must match the encryption password.\n * @returns Decrypted data as Uint8Array\n *\n * @throws {Error} If decryption fails or password is incorrect\n */\n async decryptWithPassword(\n encryptedData: Uint8Array,\n password: string,\n ): Promise<Uint8Array> {\n try {\n const openpgp = await getOpenPGP();\n\n // Read the encrypted message\n const message = await openpgp.readMessage({\n binaryMessage: encryptedData,\n });\n\n // Decrypt with password\n const { data } = await openpgp.decrypt({\n message,\n passwords: [password],\n format: \"binary\",\n });\n\n return new Uint8Array(data as ArrayBuffer);\n } catch (error) {\n throw wrapCryptoError(\"decryptWithPassword\", error);\n }\n }\n}\n\n/**\n * Implements PGP operations for browser environments.\n *\n * @remarks\n * Provides PGP encryption, decryption, and key generation using the OpenPGP.js\n * library with browser-optimized configuration.\n *\n * @internal\n */\nclass BrowserPGPAdapter implements VanaPGPAdapter {\n /**\n * Encrypts data using PGP public key encryption.\n *\n * @param data - The plaintext string to encrypt.\n * Typically messages or structured data.\n * @param publicKeyArmored - ASCII-armored PGP public key.\n * Obtain from PGP key generation or key servers.\n * @returns ASCII-armored encrypted message\n *\n * @throws {Error} If encryption fails or public key is invalid\n */\n async encrypt(data: string, publicKeyArmored: string): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });\n\n const encrypted = await openpgp.encrypt({\n message: await openpgp.createMessage({ text: data }),\n encryptionKeys: publicKey,\n config: {\n preferredCompressionAlgorithm: openpgp.enums.compression.zlib,\n },\n });\n\n return encrypted as string;\n } catch (error) {\n throw new Error(`PGP encryption failed: ${String(error)}`);\n }\n }\n\n /**\n * Decrypts PGP-encrypted data using a private key.\n *\n * @param encryptedData - ASCII-armored encrypted message.\n * Must be encrypted with corresponding public key.\n * @param privateKeyArmored - ASCII-armored PGP private key.\n * Must correspond to the public key used for encryption.\n * @returns The decrypted plaintext string\n *\n * @throws {Error} If decryption fails or private key is invalid\n */\n async decrypt(\n encryptedData: string,\n privateKeyArmored: string,\n ): Promise<string> {\n try {\n const openpgp = await getOpenPGP();\n const privateKey = await openpgp.readPrivateKey({\n armoredKey: privateKeyArmored,\n });\n const message = await openpgp.readMessage({\n armoredMessage: encryptedData,\n });\n\n const { data: decrypted } = await openpgp.decrypt({\n message,\n decryptionKeys: privateKey,\n });\n\n return decrypted as string;\n } catch (error) {\n throw new Error(`PGP decryption failed: ${String(error)}`);\n }\n }\n\n /**\n * Generates a new PGP key pair.\n *\n * @param options - Key generation options\n * @param options.name - Name for the key identity.\n * Defaults to 'Vana User'.\n * @param options.email - Email for the key identity.\n * Defaults to 'user@vana.com'.\n * @param options.passphrase - Passphrase to protect the private key.\n * If not provided, key is unprotected.\n * @returns ASCII-armored public and private keys\n *\n * @throws {Error} If key generation fails\n */\n async generateKeyPair(options?: {\n name?: string;\n email?: string;\n passphrase?: string;\n }): Promise<{ publicKey: string; privateKey: string }> {\n try {\n const openpgp = await getOpenPGP();\n // Use shared utility to get standardized parameters\n const keyGenParams = getPGPKeyGenParams(options);\n\n const { privateKey, publicKey } = await openpgp.generateKey(keyGenParams);\n\n return { publicKey, privateKey };\n } catch (error) {\n throw wrapCryptoError(\"PGP key generation\", error);\n }\n }\n}\n\n/**\n * Implements HTTP operations for browser environments.\n *\n * @remarks\n * Uses the native Fetch API available in all modern browsers.\n *\n * @internal\n */\nclass BrowserHttpAdapter implements VanaHttpAdapter {\n /**\n * Performs an HTTP request using the Fetch API.\n *\n * @param url - The URL to fetch.\n * Must be a valid HTTP/HTTPS URL.\n * @param options - Standard fetch options.\n * See MDN fetch documentation for details.\n * @returns Standard fetch Response object\n */\n async fetch(url: string, options?: RequestInit): Promise<Response> {\n return fetch(url, options);\n }\n}\n\n/**\n * Implements secure caching for browser environments.\n *\n * @remarks\n * Uses sessionStorage for temporary caching that's automatically cleared\n * when the browser tab closes. This provides better security for sensitive\n * data like signatures compared to localStorage. All keys are prefixed to\n * avoid conflicts with other applications.\n *\n * @internal\n */\nclass BrowserCacheAdapter implements VanaCacheAdapter {\n private readonly prefix = \"vana_cache_\";\n\n /**\n * Retrieves a cached value by key.\n *\n * @param key - The cache key to look up.\n * Automatically prefixed to avoid conflicts.\n * @returns The cached value or null if not found\n */\n get(key: string): string | null {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return null;\n }\n return sessionStorage.getItem(this.prefix + key);\n } catch {\n return null;\n }\n }\n\n /**\n * Stores a value in sessionStorage.\n *\n * @param key - The cache key.\n * Automatically prefixed with 'vana_cache_'.\n * @param value - The value to cache.\n * Will be cleared when tab closes.\n */\n set(key: string, value: string): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n sessionStorage.setItem(this.prefix + key, value);\n } catch {\n // Ignore storage errors (quota exceeded, etc.)\n }\n }\n\n /**\n * Removes a specific key from the cache.\n *\n * @param key - The cache key to remove.\n * Only removes the prefixed key.\n */\n delete(key: string): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n sessionStorage.removeItem(this.prefix + key);\n } catch {\n // Ignore storage errors\n }\n }\n\n /**\n * Clears all Vana-prefixed cache entries.\n *\n * @remarks\n * Only removes entries with the 'vana_cache_' prefix,\n * preserving other sessionStorage data.\n */\n clear(): void {\n try {\n if (typeof sessionStorage === \"undefined\") {\n return;\n }\n // Only clear our prefixed keys to avoid affecting other data\n const keysToRemove: string[] = [];\n for (let i = 0; i < sessionStorage.length; i++) {\n const key = sessionStorage.key(i);\n if (key?.startsWith(this.prefix)) {\n keysToRemove.push(key);\n }\n }\n keysToRemove.forEach((key) => {\n sessionStorage.removeItem(key);\n });\n } catch {\n // Ignore storage errors\n }\n }\n}\n\n/**\n * Provides complete platform abstraction for browser environments.\n *\n * @remarks\n * This adapter aggregates all browser-specific implementations of platform\n * operations. It uses native Web APIs where possible and browser-compatible\n * libraries for crypto and PGP operations. The adapter automatically selects\n * appropriate cryptographic implementations based on feature flags.\n *\n * @example\n * ```typescript\n * // Create a browser adapter instance\n * const adapter = new BrowserPlatformAdapter();\n *\n * // All platform operations are available\n * const encrypted = await adapter.crypto.encryptWithPublicKey(\n * 'secret',\n * publicKey\n * );\n *\n * const response = await adapter.http.fetch('/api/data');\n *\n * adapter.cache.set('key', 'value'); // Uses sessionStorage\n * ```\n *\n * @category Platform\n */\nexport class BrowserPlatformAdapter implements VanaPlatformAdapter {\n public readonly crypto = new BrowserCryptoAdapter();\n public readonly pgp = new BrowserPGPAdapter();\n public readonly http = new BrowserHttpAdapter();\n public readonly cache = new BrowserCacheAdapter();\n public readonly platform = \"browser\" as const;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqCA,uBAAmC;AACnC,yBAAgC;AAChC,yBAA2B;AAC3B,wCAA2C;AAC3C,0BAAyC;AACzC,kBAAqE;AACrE,gBAA2B;AAC3B,sBAAyB;AAGzB,qBAA0C;A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