From 3fb5e8bf7fecdf0a84c65303816312a0bc40424d Mon Sep 17 00:00:00 2001 From: brusher_ru Date: Thu, 22 Aug 2024 01:50:11 -0300 Subject: [PATCH] feat: re-encrypt imported AES-GCM wallet with Argon2 --- src/store/useWallet.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/store/useWallet.ts b/src/store/useWallet.ts index 7f4b16b..01a419d 100644 --- a/src/store/useWallet.ts +++ b/src/store/useWallet.ts @@ -35,6 +35,7 @@ import { generateMnemonic, } from '../utils/wallet'; import { isLegacySecrets, migrateSecrets } from '../utils/wallet.legacy'; +import { isGCMEncrypted } from '../utils/aes-gcm'; type WalletData = { meta: WalletMeta; @@ -146,9 +147,10 @@ const useWallet = create( crypto: migratedSecrets, }), }); - const secretsToStore = isLegacySecrets(secrets) - ? await encryptWallet(migratedSecrets, password) - : wallet.crypto; + const secretsToStore = + isLegacySecrets(secrets) || isGCMEncrypted(wallet.crypto) + ? await encryptWallet(migratedSecrets, password) + : wallet.crypto; saveToLocalStorage(WALLET_STORE_KEY, { meta: wallet.meta,