π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Format
Manav Rathi023d8ab8b3c2
diff --git a/web/apps/auth/src/pages/auth.tsx b/web/apps/auth/src/pages/auth.tsxindex 55f8ccd4c1..9c954ab564 100644--- a/web/apps/auth/src/pages/auth.tsx+++ b/web/apps/auth/src/pages/auth.tsx@@ -28,6 +28,7 @@ import { useRouter } from "next/router";import React, { useCallback, useEffect, useState } from "react";import { generateOTPs, type Code } from "services/code";import { getAuthCodesAndTimeOffset } from "services/remote";+import { prettyFormatCode } from "utils/format";const Page: React.FC = () => {const { logout, showMiniDialog } = useBaseContext();@@ -221,7 +222,11 @@ const CodeDisplay: React.FC<CodeDisplayProps> = ({ code, timeOffset }) => {<UnparseableCode {...{ code, errorMessage }} />) : (<ButtonBase component="div" onClick={copyCode}>- <OTPDisplay {...{ code, timeOffset, otp, nextOTP }} />+ <OTPDisplay+ {...{ code, timeOffset }}+ otp={prettyFormatCode(otp)}+ nextOTP={prettyFormatCode(nextOTP)}+ /><Snackbaropen={openCopied}message={t("copied")}diff --git a/web/apps/auth/src/pages/share.tsx b/web/apps/auth/src/pages/share.tsxindex a86d9411d2..40145531e5 100644--- a/web/apps/auth/src/pages/share.tsx+++ b/web/apps/auth/src/pages/share.tsx@@ -2,6 +2,7 @@ import { Box, Button, Stack, Typography, useTheme } from "@mui/material";import { EnteLogo } from "ente-base/components/EnteLogo";import { decryptMetadataJSON_New } from "ente-base/crypto";import React, { useEffect, useMemo, useState } from "react";+import { prettyFormatCode } from "utils/format";interface SharedCode {startTime: number;@@ -249,14 +250,12 @@ const parseCodeDisplay = (const progress = ((elapsedTime % stepDuration) / stepDuration) * 100;return {- currentCode: formatCode(codes[index] ?? ""),- nextCode: formatCode(codes[index + 1] ?? ""),+ currentCode: prettyFormatCode(codes[index] ?? ""),+ nextCode: prettyFormatCode(codes[index + 1] ?? ""),progress,};};-const formatCode = (code: string) => code.replace(/(.{3})/g, "$1 ").trim();-const Message: React.FC<React.PropsWithChildren> = ({ children }) => (<Typography variant="h4" style={{ textAlign: "center" }}>{children}diff --git a/web/apps/auth/src/utils/format.ts b/web/apps/auth/src/utils/format.tsnew file mode 100644index 0000000000..169698c9fb--- /dev/null+++ b/web/apps/auth/src/utils/format.ts@@ -0,0 +1,6 @@+/**+ * Format a generated OTP code to improve readability by breaking it into chunks+ * of length 3.+ */+export const prettyFormatCode = (code: string) =>+ code.replace(/(.{3})/g, "$1 ").trim();