From 533e6d06e7cee59f70c03144d8bbfd1db62e610d Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 25 May 2024 15:32:56 +0530 Subject: [PATCH] tsc --- web/packages/accounts/pages/recover.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/packages/accounts/pages/recover.tsx b/web/packages/accounts/pages/recover.tsx index b26976cef..2173037d3 100644 --- a/web/packages/accounts/pages/recover.tsx +++ b/web/packages/accounts/pages/recover.tsx @@ -1,4 +1,5 @@ import log from "@/next/log"; +import { ensure } from "@/utils/ensure"; import { sendOtt } from "@ente/accounts/api/user"; import { PAGES } from "@ente/accounts/constants/pages"; import { APP_HOMES } from "@ente/shared/apps/constants"; @@ -29,7 +30,9 @@ const bip39 = require("bip39"); bip39.setDefaultWordlist("english"); export default function Recover({ appContext, appName }: PageProps) { - const [keyAttributes, setKeyAttributes] = useState(); + const [keyAttributes, setKeyAttributes] = useState< + KeyAttributes | undefined + >(); const router = useRouter(); @@ -76,13 +79,14 @@ export default function Recover({ appContext, appName }: PageProps) { recoveryKey = bip39.mnemonicToEntropy(recoveryKey); } const cryptoWorker = await ComlinkCryptoWorker.getInstance(); + const keyAttr = ensure(keyAttributes); const masterKey = await cryptoWorker.decryptB64( - keyAttributes.masterKeyEncryptedWithRecoveryKey, - keyAttributes.masterKeyDecryptionNonce, + keyAttr.masterKeyEncryptedWithRecoveryKey, + keyAttr.masterKeyDecryptionNonce, await cryptoWorker.fromHex(recoveryKey), ); await saveKeyInSessionStore(SESSION_KEYS.ENCRYPTION_KEY, masterKey); - await decryptAndStoreToken(keyAttributes, masterKey); + await decryptAndStoreToken(keyAttr, masterKey); setData(LS_KEYS.SHOW_BACK_BUTTON, { value: false }); router.push(PAGES.CHANGE_PASSWORD);