π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Go the other way for better future composability
Manav Rathi7b3ea329631b
diff --git a/web/apps/auth/src/pages/auth.tsx b/web/apps/auth/src/pages/auth.tsxindex 7984cf946a..7e53837490 100644--- a/web/apps/auth/src/pages/auth.tsx+++ b/web/apps/auth/src/pages/auth.tsx@@ -22,7 +22,7 @@ import {import { useBaseContext } from "ente-base/context";import { isHTTP401Error } from "ente-base/http";import log from "ente-base/log";-import { masterKeyBytesFromSessionIfLoggedIn } from "ente-base/session";+import { masterKeyB64FromSessionIfLoggedIn } from "ente-base/session";import { t } from "i18next";import { useRouter } from "next/router";import React, { useCallback, useEffect, useState } from "react";@@ -41,8 +41,8 @@ const Page: React.FC = () => {useEffect(() => {const fetchCodes = async () => {- const masterKeyBytes = await masterKeyBytesFromSessionIfLoggedIn();- if (!masterKeyBytes) {+ const masterKey = await masterKeyB64FromSessionIfLoggedIn();+ if (!masterKey) {stashRedirect("/auth");void router.push("/");return;@@ -50,7 +50,7 @@ const Page: React.FC = () => {try {const { codes, timeOffset } =- await getAuthCodesAndTimeOffset(masterKeyBytes);+ await getAuthCodesAndTimeOffset(masterKey);setCodes(codes);setTimeOffset(timeOffset ?? 0);} catch (e) {diff --git a/web/apps/auth/src/services/remote.ts b/web/apps/auth/src/services/remote.tsindex a29632cd26..cdb73f62df 100644--- a/web/apps/auth/src/services/remote.ts+++ b/web/apps/auth/src/services/remote.ts@@ -20,8 +20,14 @@ export interface AuthCodesAndTimeOffset {timeOffset?: number;}+/**+ * Fetch the user's auth codes from remote and decrypt them using the user's+ * master key.+ *+ * @param masterKey The user's base64 encoded master key.+ */export const getAuthCodesAndTimeOffset = async (- masterKeyBytes: Uint8Array,+ masterKey: string,): Promise<AuthCodesAndTimeOffset> => {const authenticatorEntityKey = await getAuthenticatorEntityKey();if (!authenticatorEntityKey) {@@ -31,7 +37,7 @@ export const getAuthCodesAndTimeOffset = async (const authenticatorKey = await decryptAuthenticatorKey(authenticatorEntityKey,- masterKeyBytes,+ masterKey,);const { entities, timeOffset } =@@ -263,7 +269,7 @@ export const getAuthenticatorEntityKey = async (): Promise<*/const decryptAuthenticatorKey = async (remote: AuthenticatorEntityKey,- masterKeyBytes: Uint8Array,+ masterKey: string,) =>decryptBox({@@ -271,5 +277,5 @@ const decryptAuthenticatorKey = async (// Remote calls it the header, but it really is the nonce.nonce: remote.header,},- masterKeyBytes,+ masterKey,);