diff --git a/packages/accounts/components/Login.tsx b/packages/accounts/components/Login.tsx index 46dbe489d..d17682614 100644 --- a/packages/accounts/components/Login.tsx +++ b/packages/accounts/components/Login.tsx @@ -7,7 +7,7 @@ import FormPaperTitle from '@ente/shared/components/Form/FormPaper/Title'; import FormPaperFooter from '@ente/shared/components/Form/FormPaper/Footer'; import LinkButton from '@ente/shared/components/LinkButton'; import { t } from 'i18next'; -// import { addLocalLog } from 'utils/logging'; +import { addLocalLog } from '@ente/shared/logging'; import { Input } from '@mui/material'; import SingleInputForm, { SingleInputFormProps, @@ -28,9 +28,9 @@ export default function Login(props: LoginProps) { try { setData(LS_KEYS.USER, { email }); const srpAttributes = await getSRPAttributes(email); - // addLocalLog( - // () => ` srpAttributes: ${JSON.stringify(srpAttributes)}` - // ); + addLocalLog( + () => ` srpAttributes: ${JSON.stringify(srpAttributes)}` + ); if (!srpAttributes || srpAttributes.isEmailMFAEnabled) { await sendOtt(props.appName, email); router.push(PAGES.VERIFY); diff --git a/packages/accounts/pages/credentials.tsx b/packages/accounts/pages/credentials.tsx index c46e3cc60..d687d6e5e 100644 --- a/packages/accounts/pages/credentials.tsx +++ b/packages/accounts/pages/credentials.tsx @@ -45,7 +45,7 @@ import VerifyMasterPasswordForm, { VerifyMasterPasswordFormProps, } from '@ente/shared/components/VerifyMasterPasswordForm'; // import { APPS, getAppName } from '@ente/shared/apps'; -// import { addLocalLog } from 'utils/logging'; +import { addLocalLog } from '@ente/shared/logging'; import ComlinkCryptoWorker from '@ente/shared/crypto'; import { B64EncryptionResult } from '@ente/shared/crypto/types'; import { CustomError } from '@ente/shared/error'; @@ -219,7 +219,7 @@ export default function Credentials({ setData(LS_KEYS.SRP_ATTRIBUTES, srpAttributes); } } - // addLocalLog(() => `userSRPSetupPending ${!srpAttributes}`); + addLocalLog(() => `userSRPSetupPending ${!srpAttributes}`); if (!srpAttributes) { const loginSubKey = await generateLoginSubKey(kek); const srpSetupAttributes = await generateSRPSetupAttributes( diff --git a/packages/accounts/services/srp.ts b/packages/accounts/services/srp.ts index 937e836b4..8da9072bb 100644 --- a/packages/accounts/services/srp.ts +++ b/packages/accounts/services/srp.ts @@ -14,6 +14,8 @@ import { v4 as uuidv4 } from 'uuid'; import ComlinkCryptoWorker from '@ente/shared/crypto'; import { generateLoginSubKey } from '@ente/shared/crypto/helpers'; import { UserVerificationResponse } from '@ente/accounts/types/user'; +import { logError } from '@ente/shared/sentry'; +import { addLocalLog } from '@ente/shared/logging'; const SRP_PARAMS = SRP.params['4096']; @@ -39,7 +41,7 @@ export const configureSRP = async ({ const srpA = convertBufferToBase64(srpClient.computeA()); - // addLocalLog(() => `srp a: ${srpA}`); + addLocalLog(() => `srp a: ${srpA}`); const { setupID, srpB } = await startSRPSetup({ srpA, srpUserID, @@ -57,11 +59,10 @@ export const configureSRP = async ({ }); srpClient.checkM2(convertBase64ToBuffer(srpM2)); + } catch (e) { + logError(e, 'srp configure failed'); + throw e; } finally { - // catch (e) { - // logError(e, 'srp configure failed'); - // throw e; - // } InMemoryStore.set(MS_KEYS.SRP_CONFIGURE_IN_PROGRESS, false); } }; @@ -84,15 +85,15 @@ export const generateSRPSetupAttributes = async ( const srpVerifier = convertBufferToBase64(srpVerifierBuffer); - // addLocalLog( - // () => `SRP setup attributes generated', - // ${JSON.stringify({ - // srpSalt, - // srpUserID, - // srpVerifier, - // loginSubKey, - // })}` - // ); + addLocalLog( + () => `SRP setup attributes generated', + ${JSON.stringify({ + srpSalt, + srpUserID, + srpVerifier, + loginSubKey, + })}` + ); return { srpUserID, @@ -106,37 +107,37 @@ export const loginViaSRP = async ( srpAttributes: SRPAttributes, kek: string ): Promise => { - // try { - const loginSubKey = await generateLoginSubKey(kek); - const srpClient = await generateSRPClient( - srpAttributes.srpSalt, - srpAttributes.srpUserID, - loginSubKey - ); - const srpA = srpClient.computeA(); - const { srpB, sessionID } = await createSRPSession( - srpAttributes.srpUserID, - convertBufferToBase64(srpA) - ); - srpClient.setB(convertBase64ToBuffer(srpB)); + try { + const loginSubKey = await generateLoginSubKey(kek); + const srpClient = await generateSRPClient( + srpAttributes.srpSalt, + srpAttributes.srpUserID, + loginSubKey + ); + const srpA = srpClient.computeA(); + const { srpB, sessionID } = await createSRPSession( + srpAttributes.srpUserID, + convertBufferToBase64(srpA) + ); + srpClient.setB(convertBase64ToBuffer(srpB)); - const m1 = srpClient.computeM1(); - // addLocalLog(() => `srp m1: ${convertBufferToBase64(m1)}`); - const { srpM2, ...rest } = await verifySRPSession( - sessionID, - srpAttributes.srpUserID, - convertBufferToBase64(m1) - ); - // addLocalLog(() => `srp verify session successful,srpM2: ${srpM2}`); + const m1 = srpClient.computeM1(); + addLocalLog(() => `srp m1: ${convertBufferToBase64(m1)}`); + const { srpM2, ...rest } = await verifySRPSession( + sessionID, + srpAttributes.srpUserID, + convertBufferToBase64(m1) + ); + addLocalLog(() => `srp verify session successful,srpM2: ${srpM2}`); - srpClient.checkM2(convertBase64ToBuffer(srpM2)); + srpClient.checkM2(convertBase64ToBuffer(srpM2)); - // addLocalLog(() => `srp server verify successful`); - return rest; - // } catch (e) { - // logError(e, 'srp verify failed'); - // throw e; - // } + addLocalLog(() => `srp server verify successful`); + return rest; + } catch (e) { + logError(e, 'srp verify failed'); + throw e; + } }; // ==================== diff --git a/packages/shared/worker/comlinkWorker.ts b/packages/shared/worker/comlinkWorker.ts index 3e3e8e3b9..a582bd00a 100644 --- a/packages/shared/worker/comlinkWorker.ts +++ b/packages/shared/worker/comlinkWorker.ts @@ -1,6 +1,6 @@ import { Remote, wrap } from 'comlink'; // import { WorkerElectronCacheStorageClient } from 'services/workerElectronCache/client'; -// import { addLocalLog } from 'utils/logging'; +import { addLocalLog } from '@ente/shared/logging'; export class ComlinkWorker InstanceType> { public remote: Promise>>; @@ -14,7 +14,7 @@ export class ComlinkWorker InstanceType> { this.worker.onerror = (errorEvent) => { console.error('Got error event from worker', errorEvent); }; - // addLocalLog(() => `Initiated ${this.name}`); + addLocalLog(() => `Initiated ${this.name}`); const comlink = wrap(this.worker); this.remote = new comlink() as Promise>>; // expose(WorkerElectronCacheStorageClient, this.worker); @@ -26,6 +26,6 @@ export class ComlinkWorker InstanceType> { public terminate() { this.worker.terminate(); - // addLocalLog(() => `Terminated ${this.name}`); + addLocalLog(() => `Terminated ${this.name}`); } }