Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat: accounts login, passkeys desc

httpjamesm7553e0e5b106
diff --git a/apps/accounts/public/images/ente.svg b/apps/accounts/public/images/ente.svg
new file mode 100644
index 0000000000..33bd742568
--- /dev/null
+++ b/apps/accounts/public/images/ente.svg
@@ -0,0 +1,3 @@
+<svg width="43" height="13" viewBox="0 0 43 13" fill="#fff" xmlns="http://www.w3.org/2000/svg">
+<path d="M6.102 12.144C4.998 12.144 4.026 11.928 3.186 11.496C2.358 11.064 1.716 10.476 1.26 9.732C0.804 8.976 0.576 8.118 0.576 7.158C0.576 6.186 0.798 5.328 1.242 4.584C1.698 3.828 2.316 3.24 3.096 2.82C3.876 2.388 4.758 2.172 5.742 2.172C6.69 2.172 7.542 2.376 8.298 2.784C9.066 3.18 9.672 3.756 10.116 4.512C10.56 5.256 10.782 6.15 10.782 7.194C10.782 7.302 10.776 7.428 10.764 7.572C10.752 7.704 10.74 7.83 10.728 7.95H2.862V6.312H9.252L8.172 6.798C8.172 6.294 8.07 5.856 7.866 5.484C7.662 5.112 7.38 4.824 7.02 4.62C6.66 4.404 6.24 4.296 5.76 4.296C5.28 4.296 4.854 4.404 4.482 4.62C4.122 4.824 3.84 5.118 3.636 5.502C3.432 5.874 3.33 6.318 3.33 6.834V7.266C3.33 7.794 3.444 8.262 3.672 8.67C3.912 9.066 4.242 9.372 4.662 9.588C5.094 9.792 5.598 9.894 6.174 9.894C6.69 9.894 7.14 9.816 7.524 9.66C7.92 9.504 8.28 9.27 8.604 8.958L10.098 10.578C9.654 11.082 9.096 11.472 8.424 11.748C7.752 12.012 6.978 12.144 6.102 12.144ZM18.5375 2.172C19.3055 2.172 19.9895 2.328 20.5895 2.64C21.2015 2.94 21.6815 3.408 22.0295 4.044C22.3775 4.668 22.5515 5.472 22.5515 6.456V12H19.7435V6.888C19.7435 6.108 19.5695 5.532 19.2215 5.16C18.8855 4.788 18.4055 4.602 17.7815 4.602C17.3375 4.602 16.9355 4.698 16.5755 4.89C16.2275 5.07 15.9515 5.352 15.7475 5.736C15.5555 6.12 15.4595 6.612 15.4595 7.212V12H12.6515V2.316H15.3335V4.998L14.8295 4.188C15.1775 3.54 15.6755 3.042 16.3235 2.694C16.9715 2.346 17.7095 2.172 18.5375 2.172ZM29.0568 12.144C27.9168 12.144 27.0288 11.856 26.3928 11.28C25.7568 10.692 25.4388 9.822 25.4388 8.67V0.174H28.2468V8.634C28.2468 9.042 28.3548 9.36 28.5708 9.588C28.7868 9.804 29.0808 9.912 29.4528 9.912C29.8968 9.912 30.2748 9.792 30.5868 9.552L31.3428 11.532C31.0548 11.736 30.7068 11.892 30.2988 12C29.9028 12.096 29.4888 12.144 29.0568 12.144ZM23.9448 4.692V2.532H30.6588V4.692H23.9448ZM37.4262 12.144C36.3222 12.144 35.3502 11.928 34.5102 11.496C33.6822 11.064 33.0402 10.476 32.5842 9.732C32.1282 8.976 31.9002 8.118 31.9002 7.158C31.9002 6.186 32.1222 5.328 32.5662 4.584C33.0222 3.828 33.6402 3.24 34.4202 2.82C35.2002 2.388 36.0822 2.172 37.0662 2.172C38.0142 2.172 38.8662 2.376 39.6222 2.784C40.3902 3.18 40.9962 3.756 41.4402 4.512C41.8842 5.256 42.1062 6.15 42.1062 7.194C42.1062 7.302 42.1002 7.428 42.0882 7.572C42.0762 7.704 42.0642 7.83 42.0522 7.95H34.1862V6.312H40.5762L39.4962 6.798C39.4962 6.294 39.3942 5.856 39.1902 5.484C38.9862 5.112 38.7042 4.824 38.3442 4.62C37.9842 4.404 37.5642 4.296 37.0842 4.296C36.6042 4.296 36.1782 4.404 35.8062 4.62C35.4462 4.824 35.1642 5.118 34.9602 5.502C34.7562 5.874 34.6542 6.318 34.6542 6.834V7.266C34.6542 7.794 34.7682 8.262 34.9962 8.67C35.2362 9.066 35.5662 9.372 35.9862 9.588C36.4182 9.792 36.9222 9.894 37.4982 9.894C38.0142 9.894 38.4642 9.816 38.8482 9.66C39.2442 9.504 39.6042 9.27 39.9282 8.958L41.4222 10.578C40.9782 11.082 40.4202 11.472 39.7482 11.748C39.0762 12.012 38.3022 12.144 37.4262 12.144Z" />
+</svg>
diff --git a/apps/accounts/public/locales/en/translation.json b/apps/accounts/public/locales/en/translation.json
index 30bedec271..36866d6432 100644
--- a/apps/accounts/public/locales/en/translation.json
+++ b/apps/accounts/public/locales/en/translation.json
@@ -629,5 +629,6 @@
"DELETE_PASSKEY_CONFIRMATION": "Are you sure you want to delete this passkey? This action is irreversible.",
"RENAME_PASSKEY": "Rename passkey",
"ADD_PASSKEY": "Add passkey",
- "ENTER_PASSKEY_NAME": "Enter passkey name"
+ "ENTER_PASSKEY_NAME": "Enter passkey name",
+ "PASSKEYS_DESCRIPTION": "Passkeys are a modern and secure second-factor for your Ente account. They use on-device biometric authentication for convenience and security."
}
diff --git a/apps/accounts/src/pages/_app.tsx b/apps/accounts/src/pages/_app.tsx
index a4e3eb46a3..86bd520326 100644
--- a/apps/accounts/src/pages/_app.tsx
+++ b/apps/accounts/src/pages/_app.tsx
@@ -13,10 +13,18 @@ import 'styles/global.css';
import { setupI18n } from '@ente/shared/i18n';
import { Overlay } from '@ente/shared/components/Container';
import EnteSpinner from '@ente/shared/components/EnteSpinner';
+import AppNavbar from '@ente/shared/components/Navbar/app';
+import {
+ DialogBoxAttributesV2,
+ SetDialogBoxAttributesV2,
+} from '@ente/shared/components/DialogBoxV2/types';
+import DialogBoxV2 from '@ente/shared/components/DialogBoxV2';
export const AppContext = createContext(
{} as {
isMobile: boolean;
+ showNavBar: (show: boolean) => void;
+ setDialogBoxAttributesV2: SetDialogBoxAttributesV2;
}
);
@@ -26,6 +34,19 @@ const clientSideEmotionCache = createEmotionCache();
export default function App(props: EnteAppProps) {
const [isI18nReady, setIsI18nReady] = useState<boolean>(false);
+ const [showNavbar, setShowNavBar] = useState(false);
+
+ const [dialogBoxAttributeV2, setDialogBoxAttributesV2] =
+ useState<DialogBoxAttributesV2>();
+
+ const [dialogBoxV2View, setDialogBoxV2View] = useState(false);
+
+ useEffect(() => {
+ setDialogBoxV2View(true);
+ }, [dialogBoxAttributeV2]);
+
+ const showNavBar = (show: boolean) => setShowNavBar(show);
+
const isMobile = useMediaQuery('(max-width:428px)');
const {
@@ -40,11 +61,21 @@ export default function App(props: EnteAppProps) {
setupI18n().finally(() => setIsI18nReady(true));
}, []);
+ const closeDialogBoxV2 = () => setDialogBoxV2View(false);
+
return (
<CacheProvider value={emotionCache}>
<ThemeProvider theme={getTheme(themeColor, APPS.PHOTOS)}>
<CssBaseline enableColorScheme />
- <AppContext.Provider value={{ isMobile }}>
+ <DialogBoxV2
+ sx={{ zIndex: 1600 }}
+ open={dialogBoxV2View}
+ onClose={closeDialogBoxV2}
+ attributes={dialogBoxAttributeV2}
+ />
+
+ <AppContext.Provider
+ value={{ isMobile, showNavBar, setDialogBoxAttributesV2 }}>
{!isI18nReady && (
<Overlay
sx={(theme) => ({
@@ -57,6 +88,7 @@ export default function App(props: EnteAppProps) {
<EnteSpinner />
</Overlay>
)}
+ {showNavbar && <AppNavbar isMobile={isMobile} />}
<Component {...pageProps} />
</AppContext.Provider>
</ThemeProvider>
diff --git a/apps/accounts/src/pages/credentials/index.tsx b/apps/accounts/src/pages/credentials/index.tsx
new file mode 100644
index 0000000000..963aae624b
--- /dev/null
+++ b/apps/accounts/src/pages/credentials/index.tsx
@@ -0,0 +1,17 @@
+import CredentialPage from '@ente/accounts/pages/credentials';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function Credential() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <CredentialPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/pages/index.tsx b/apps/accounts/src/pages/index.tsx
new file mode 100644
index 0000000000..86fa118264
--- /dev/null
+++ b/apps/accounts/src/pages/index.tsx
@@ -0,0 +1,13 @@
+import { useRouter } from 'next/router';
+import { useEffect } from 'react';
+
+const Index = () => {
+ const router = useRouter();
+
+ useEffect(() => {
+ router.push('/login');
+ }, []);
+ return <></>;
+};
+
+export default Index;
diff --git a/apps/accounts/src/pages/login/index.tsx b/apps/accounts/src/pages/login/index.tsx
new file mode 100644
index 0000000000..67ddabf55e
--- /dev/null
+++ b/apps/accounts/src/pages/login/index.tsx
@@ -0,0 +1,17 @@
+import LoginPage from '@ente/accounts/pages/login';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function Login() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <LoginPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/pages/passkeys/index.tsx b/apps/accounts/src/pages/passkeys/index.tsx
index 3d283b06b9..64137d3a44 100644
--- a/apps/accounts/src/pages/passkeys/index.tsx
+++ b/apps/accounts/src/pages/passkeys/index.tsx
@@ -1,6 +1,6 @@
import { CenteredFlex } from '@ente/shared/components/Container';
import SingleInputForm from '@ente/shared/components/SingleInputForm';
-import { Box } from '@mui/material';
+import { Box, Typography } from '@mui/material';
import {
finishPasskeyRegistration,
getPasskeyRegistrationOptions,
@@ -12,6 +12,7 @@ import {
Dispatch,
SetStateAction,
createContext,
+ useContext,
useEffect,
useState,
} from 'react';
@@ -19,6 +20,8 @@ import { Passkey } from 'types/passkey';
import PasskeysList from './PasskeysList';
import ManagePasskeyDrawer from './ManagePasskeyDrawer';
import { t } from 'i18next';
+import { AppContext } from 'pages/_app';
+import FormPaper from '@ente/shared/components/Form/FormPaper';
export const PasskeysContext = createContext(
{} as {
@@ -30,6 +33,8 @@ export const PasskeysContext = createContext(
);
const Passkeys = () => {
+ const { showNavBar } = useContext(AppContext);
+
const [selectedPasskey, setSelectedPasskey] = useState<Passkey | null>(
null
);
@@ -44,16 +49,27 @@ const Passkeys = () => {
};
useEffect(() => {
+ showNavBar(true);
init();
}, []);
- const handleSubmit = async (inputValue: string) => {
- const response: {
+ const handleSubmit = async (
+ inputValue: string,
+ setFieldError: (errorMessage: string) => void
+ ) => {
+ let response: {
options: {
publicKey: PublicKeyCredentialCreationOptions;
};
sessionID: string;
- } = await getPasskeyRegistrationOptions();
+ };
+
+ try {
+ response = await getPasskeyRegistrationOptions();
+ } catch {
+ setFieldError('Failed to begin registration');
+ return;
+ }
const options = response.options;
@@ -74,14 +90,21 @@ const Passkeys = () => {
try {
newCredential = await navigator.credentials.create(options);
} catch (e) {
- return logError(e, 'Error creating credential');
+ logError(e, 'Error creating credential');
+ setFieldError('Failed to create credential');
+ return;
}
- await finishPasskeyRegistration(
- inputValue,
- newCredential,
- response.sessionID
- );
+ try {
+ await finishPasskeyRegistration(
+ inputValue,
+ newCredential,
+ response.sessionID
+ );
+ } catch {
+ setFieldError('Failed to finish registration');
+ return;
+ }
init();
};
@@ -96,16 +119,28 @@ const Passkeys = () => {
refreshPasskeys: init,
}}>
<CenteredFlex>
- <Box>
- <SingleInputForm
- fieldType="text"
- placeholder={t('ENTER_PASSKEY_NAME')}
- buttonText={t('ADD_PASSKEY')}
- initialValue={''}
- blockButton
- callback={handleSubmit}
- />
- <Box>
+ <Box maxWidth="20rem">
+ <Box marginBottom="1rem">
+ <Typography>{t('PASSKEYS_DESCRIPTION')}</Typography>
+ </Box>
+ <FormPaper
+ style={{
+ padding: '1rem',
+ }}>
+ <SingleInputForm
+ fieldType="text"
+ placeholder={t('ENTER_PASSKEY_NAME')}
+ buttonText={t('ADD_PASSKEY')}
+ initialValue={''}
+ callback={handleSubmit}
+ submitButtonProps={{
+ sx: {
+ marginBottom: 1,
+ },
+ }}
+ />
+ </FormPaper>
+ <Box marginTop="1rem">
<PasskeysList passkeys={passkeys} />
</Box>
</Box>
diff --git a/apps/accounts/src/pages/recover/index.tsx b/apps/accounts/src/pages/recover/index.tsx
new file mode 100644
index 0000000000..976791015e
--- /dev/null
+++ b/apps/accounts/src/pages/recover/index.tsx
@@ -0,0 +1,17 @@
+import RecoverPage from '@ente/accounts/pages/recover';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function Recover() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <RecoverPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/pages/two-factor/recover/index.tsx b/apps/accounts/src/pages/two-factor/recover/index.tsx
new file mode 100644
index 0000000000..39055fe43f
--- /dev/null
+++ b/apps/accounts/src/pages/two-factor/recover/index.tsx
@@ -0,0 +1,17 @@
+import TwoFactorRecoverPage from '@ente/accounts/pages/two-factor/recover';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function TwoFactorRecover() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <TwoFactorRecoverPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/pages/two-factor/setup/index.tsx b/apps/accounts/src/pages/two-factor/setup/index.tsx
new file mode 100644
index 0000000000..849b2f78ba
--- /dev/null
+++ b/apps/accounts/src/pages/two-factor/setup/index.tsx
@@ -0,0 +1,17 @@
+import TwoFactorSetupPage from '@ente/accounts/pages/two-factor/setup';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function TwoFactorSetup() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <TwoFactorSetupPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/pages/two-factor/verify/index.tsx b/apps/accounts/src/pages/two-factor/verify/index.tsx
new file mode 100644
index 0000000000..dbb01bdada
--- /dev/null
+++ b/apps/accounts/src/pages/two-factor/verify/index.tsx
@@ -0,0 +1,17 @@
+import TwoFactorVerifyPage from '@ente/accounts/pages/two-factor/verify';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function TwoFactorVerify() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <TwoFactorVerifyPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/pages/verify/index.tsx b/apps/accounts/src/pages/verify/index.tsx
new file mode 100644
index 0000000000..54f1081d9b
--- /dev/null
+++ b/apps/accounts/src/pages/verify/index.tsx
@@ -0,0 +1,17 @@
+import VerifyPage from '@ente/accounts/pages/verify';
+import { useRouter } from 'next/router';
+import { AppContext } from 'pages/_app';
+import { useContext } from 'react';
+import { APPS } from '@ente/shared/apps/constants';
+
+export default function Verify() {
+ const appContext = useContext(AppContext);
+ const router = useRouter();
+ return (
+ <VerifyPage
+ appContext={appContext}
+ router={router}
+ appName={APPS.ACCOUNTS}
+ />
+ );
+}
diff --git a/apps/accounts/src/styles/global.css b/apps/accounts/src/styles/global.css
index e3095d8de6..2dace242c1 100644
--- a/apps/accounts/src/styles/global.css
+++ b/apps/accounts/src/styles/global.css
@@ -37,8 +37,6 @@ body {
flex: 1;
display: flex;
flex-direction: column;
- padding: 1rem;
- box-sizing: border-box;
}
#__next {
diff --git a/packages/shared/apps/constants.ts b/packages/shared/apps/constants.ts
index 34016bf832..4d54608fd4 100644
--- a/packages/shared/apps/constants.ts
+++ b/packages/shared/apps/constants.ts
@@ -1,9 +1,10 @@
-import { AUTH_PAGES, PHOTOS_PAGES } from '../constants/pages';
+import { ACCOUNTS_PAGES, AUTH_PAGES, PHOTOS_PAGES } from '../constants/pages';
export enum APPS {
PHOTOS = 'PHOTOS',
AUTH = 'AUTH',
ALBUMS = 'ALBUMS',
+ ACCOUNTS = 'ACCOUNTS',
}
export enum APP_ENV {
@@ -16,18 +17,21 @@ export const CLIENT_PACKAGE_NAMES = new Map([
[APPS.ALBUMS, 'io.ente.albums.web'],
[APPS.PHOTOS, 'io.ente.photos.web'],
[APPS.AUTH, 'io.ente.auth.web'],
+ [APPS.ACCOUNTS, 'io.ente.accounts.web'],
]);
export const APP_TITLES = new Map([
[APPS.ALBUMS, 'Ente Albums'],
[APPS.PHOTOS, 'Ente Photos'],
[APPS.AUTH, 'Ente Auth'],
+ [APPS.ACCOUNTS, 'Ente Accounts'],
]);
export const APP_HOMES = new Map([
[APPS.ALBUMS, '/'],
[APPS.PHOTOS, PHOTOS_PAGES.GALLERY],
[APPS.AUTH, AUTH_PAGES.AUTH],
+ [APPS.ACCOUNTS, ACCOUNTS_PAGES.PASSKEYS],
]);
export const OTT_CLIENTS = new Map([
diff --git a/packages/shared/constants/pages.tsx b/packages/shared/constants/pages.tsx
index 72bdcac358..db6e9672d0 100644
--- a/packages/shared/constants/pages.tsx
+++ b/packages/shared/constants/pages.tsx
@@ -33,3 +33,16 @@ export enum AUTH_PAGES {
ROOT = '/',
AUTH = '/auth',
}
+
+export enum ACCOUNTS_PAGES {
+ CREDENTIALS = '/credentials',
+ LOGIN = '/login',
+ RECOVER = '/recover',
+ SIGNUP = '/signup',
+ TWO_FACTOR_SETUP = '/two-factor/setup',
+ TWO_FACTOR_VERIFY = '/two-factor/verify',
+ TWO_FACTOR_RECOVER = '/two-factor/recover',
+ VERIFY = '/verify',
+ ROOT = '/',
+ PASSKEYS = '/passkeys',
+}