reenable local logging

This commit is contained in:
Abhinav 2023-11-02 20:59:50 +05:30
parent 10937c9d55
commit 9cfbc96fc7
4 changed files with 52 additions and 51 deletions

View file

@ -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);

View file

@ -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(

View file

@ -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<UserVerificationResponse> => {
// 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;
}
};
// ====================

View file

@ -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<T extends new () => InstanceType<T>> {
public remote: Promise<Remote<InstanceType<T>>>;
@ -14,7 +14,7 @@ export class ComlinkWorker<T extends new () => InstanceType<T>> {
this.worker.onerror = (errorEvent) => {
console.error('Got error event from worker', errorEvent);
};
// addLocalLog(() => `Initiated ${this.name}`);
addLocalLog(() => `Initiated ${this.name}`);
const comlink = wrap<T>(this.worker);
this.remote = new comlink() as Promise<Remote<InstanceType<T>>>;
// expose(WorkerElectronCacheStorageClient, this.worker);
@ -26,6 +26,6 @@ export class ComlinkWorker<T extends new () => InstanceType<T>> {
public terminate() {
this.worker.terminate();
// addLocalLog(() => `Terminated ${this.name}`);
addLocalLog(() => `Terminated ${this.name}`);
}
}