Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Remove unlock-success page and directly continue with primary flow (e.g. autofill) instead (#2374)
Leendert de Borstc1c8c031467c
diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.tsindex 4b14bf1d3..cc4e151a3 100644--- a/apps/browser-extension/src/entrypoints/content.ts+++ b/apps/browser-extension/src/entrypoints/content.ts@@ -7,7 +7,7 @@ import { setPlatform } from '@aliasvault/client/platform';import { CONDITIONAL_PASSKEYS_UPDATED_EVENT, hasPendingConditionalRequest, refreshConditionalPasskeyOptions } from '@/entrypoints/contentScript/ConditionalPasskey';import { fillItem, injectIcon, popupDebounceTimeHasPassed, validateInputField } from '@/entrypoints/contentScript/Form';-import { getLastAutofillInput, openAutofillPopup, openTotpPopup, removeExistingPopup, createUpgradeRequiredPopup } from '@/entrypoints/contentScript/Popup';+import { consumeUnlockResume, getLastAutofillInput, openAutofillPopup, openTotpPopup, removeExistingPopup, createUpgradeRequiredPopup } from '@/entrypoints/contentScript/Popup';import { showSavePrompt, showAddUrlPrompt, isSavePromptVisible, updateSavePromptLogin, getPersistedSavePromptState, restoreSavePromptFromState, restoreAddUrlPromptFromState } from '@/entrypoints/contentScript/SavePrompt';import { initializeWebAuthnInterceptor } from '@/entrypoints/contentScript/WebAuthnInterceptor';@@ -708,12 +708,23 @@ export default defineContentScript({return { success: true };});- // When the vault is unlocked, re-query any pending conditional passkey requests+ /*+ * When the vault is unlocked, reopen the autofill popup the user unlocked from, and re-query any pending+ * conditional passkey requests.+ */onMessage('VAULT_UNLOCKED', async () => {- if (ctx.isInvalid || !hasPendingConditionalRequest()) {+ if (ctx.isInvalid) {return;}- await refreshConditionalPasskeyOptions();++ const resume = consumeUnlockResume();+ if (resume) {+ await showPopupWithAuthCheck(resume.input, container, resume.popupType, true);+ }++ if (hasPendingConditionalRequest()) {+ await refreshConditionalPasskeyOptions();+ }});/**@@ -832,7 +843,7 @@ export default defineContentScript({// Vault is locked, show vault locked popupconst { createVaultLockedPopup } = await import('@/entrypoints/contentScript/Popup');- createVaultLockedPopup(inputElement, container);+ createVaultLockedPopup(inputElement, container, popupType);return;}diff --git a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts b/apps/browser-extension/src/entrypoints/contentScript/Popup.tsindex 98a0ebfe7..32d4d19a5 100644--- a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts@@ -6,6 +6,7 @@ import { FieldKey, getFieldValue, normalizeTotpPeriod } from '@aliasvault/modelsimport { fillItem, fillTotpCode } from '@/entrypoints/contentScript/Form';+import { DEFAULT_POPUP_TYPE, type PopupType } from '@/utils/autofill/PopupTypes';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';import { sendMessage, type TotpSecret } from '@/utils/messaging/ExtensionMessaging';import { ClickValidator } from '@/utils/security/ClickValidator';@@ -32,6 +33,28 @@ export function getLastAutofillInput(): HTMLInputElement | null {return lastAutofillInput;}+/**+ * How long after the user clicked a "vault locked" popup an unlock still reopens the autofill popup.+ */+const UNLOCK_RESUME_WINDOW_MS = 5 * 60 * 1000;++/**+ * The field whose "vault locked" popup the user clicked, to reopen its autofill popup once the vault is unlocked.+ */+let pendingUnlockResume: { input: HTMLInputElement; popupType: PopupType; expiresAt: number } | null = null;++/**+ * Take the field to reopen the autofill popup for after an unlock, or null when there is none (or it is gone).+ */+export function consumeUnlockResume(): { input: HTMLInputElement; popupType: PopupType } | null {+ const resume = pendingUnlockResume;+ pendingUnlockResume = null;+ if (!resume || Date.now() > resume.expiresAt || isAnchorGone(resume.input)) {+ return null;+ }+ return resume;+}+/** Dimensions of the create-credential popup window (must match browser.windows.create in the* background's handleOpenPopupCreateCredential), used to keep it fully on-screen when positioning.@@ -246,7 +269,7 @@ export function openTotpPopup(input: HTMLInputElement, container: HTMLElement, f}}- await createVaultLockedPopup(input, container);+ await createVaultLockedPopup(input, container, 'totp');}})();}@@ -1124,11 +1147,12 @@ export async function createAutofillPopup(input: HTMLInputElement, items: Item[]/*** Create vault locked popup.*/-export async function createVaultLockedPopup(input: HTMLInputElement, rootContainer: HTMLElement): Promise<void> {+export async function createVaultLockedPopup(input: HTMLInputElement, rootContainer: HTMLElement, popupType: PopupType = DEFAULT_POPUP_TYPE): Promise<void> {/**- * Handle unlock click.+ * Handle unlock click: open the unlock window, and reopen this field's autofill popup once the vault is unlocked.*/const handleUnlockClick = () : void => {+ pendingUnlockResume = { input, popupType, expiresAt: Date.now() + UNLOCK_RESUME_WINDOW_MS };sendMessage('OPEN_POPUP');removeExistingPopup(rootContainer);}diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsxindex 2254a5287..57b11875f 100644--- a/apps/browser-extension/src/entrypoints/popup/App.tsx+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx@@ -15,7 +15,6 @@ import { NavigationProvider } from '@/entrypoints/popup/context/NavigationConteximport AuthSettings from '@/entrypoints/popup/pages/auth/AuthSettings';import Login from '@/entrypoints/popup/pages/auth/Login';import Unlock from '@/entrypoints/popup/pages/auth/Unlock';-import UnlockSuccess from '@/entrypoints/popup/pages/auth/UnlockSuccess';import Upgrade from '@/entrypoints/popup/pages/auth/Upgrade';import EmailDetails from '@/entrypoints/popup/pages/emails/EmailDetails';import EmailsList from '@/entrypoints/popup/pages/emails/EmailsList';@@ -192,7 +191,6 @@ const App: React.FC = () => {{ path: '/reinitialize', element: <Reinitialize />, showBackButton: false },{ path: '/login', element: <Login />, showBackButton: false, layout: LayoutType.AUTH },{ path: '/unlock', element: <Unlock />, showBackButton: false, layout: LayoutType.AUTH },- { path: '/unlock-success', element: <UnlockSuccess />, showBackButton: false },{ path: '/upgrade', element: <Upgrade />, showBackButton: false },{ path: '/auth-settings', element: <AuthSettings />, showBackButton: true, title: t('common.settings') },{ path: '/items', element: <ItemsList />, showBackButton: false },diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsxindex 11366042c..e59a3ed33 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/BottomNav.tsx@@ -40,7 +40,7 @@ const BottomNav: React.FC = () => {};// Auth pages that don't show bottom navigation but still show header- const authPages = ['/', '/login', '/auth-settings', '/unlock', '/unlock-success', '/upgrade'];+ const authPages = ['/', '/login', '/auth-settings', '/unlock', '/upgrade'];const isAuthPage = authPages.includes(location.pathname);if (isAuthPage) {diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsxindex 52407c821..89127074d 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx@@ -374,61 +374,66 @@ const Login: React.FC = () => {if (twoFactorRequired) {return (- <div>- <form onSubmit={handleTwoFactorSubmit} className="bg-white dark:bg-gray-700 w-full shadow-md rounded px-8 pt-6 pb-8 mb-4">- {error && (- <div className="mb-4 text-red-500 dark:text-red-400 text-sm">- {error}+ <div className="flex flex-col items-center justify-center p-4">+ <div className="w-full max-w-md">+ <form onSubmit={handleTwoFactorSubmit} className="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6">+ <div className="text-center mb-6">+ <h2 className="text-xl font-bold text-gray-900 dark:text-white">{t('common.twoFactorAuthentication')}</h2>+ <p className="text-sm text-gray-600 dark:text-gray-400 mt-2">{t('auth.twoFactorTitle')}</p></div>- )}- {vaultError && <VaultErrorReport error={vaultError} />}- <div className="mb-6">- <p className="text-gray-700 dark:text-gray-200 mb-4">- {t('auth.twoFactorTitle')}++ {error && (+ <div className="mb-4 text-red-500 dark:text-red-400 text-sm">+ {error}+ </div>+ )}+ {vaultError && <VaultErrorReport error={vaultError} />}++ <div className="mb-6">+ <label className="block text-gray-700 dark:text-gray-200 font-medium mb-2" htmlFor="twoFactorCode">+ {t('auth.authCode')}+ </label>+ <input+ className="shadow appearance-none border rounded-lg w-full py-2 px-3 text-gray-700 dark:text-gray-200 dark:bg-gray-700 dark:border-gray-600 leading-tight focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"+ id="twoFactorCode"+ type="text"+ inputMode="numeric"+ autoComplete="one-time-code"+ autoFocus+ value={twoFactorCode}+ onChange={(e) => setTwoFactorCode(e.target.value)}+ placeholder={t('auth.enterAuthCode')}+ required+ />+ </div>+ <div className="flex flex-col w-full space-y-2">+ <Button type="submit">+ {t('auth.verify')}+ </Button>+ <Button+ type="button"+ onClick={async () => {+ // Clear persisted 2FA state+ await sendMessage('CLEAR_TWO_FACTOR_STATE');+ // Reset the form+ setCredentials({+ username: '',+ password: ''+ });+ setTwoFactorRequired(false);+ setTwoFactorCode('');+ setError(null);+ }}+ variant="secondary"+ >+ {t('common.cancel')}+ </Button>+ </div>+ <p className="text-sm text-gray-500 dark:text-gray-400 mt-6 text-center">+ {t('auth.authCodeNote')}</p>- <label className="block text-gray-700 dark:text-gray-200 text-sm font-bold mb-2" htmlFor="twoFactorCode">- {t('auth.authCode')}- </label>- <input- className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 dark:text-gray-200 dark:bg-gray-800 dark:border-gray-600 leading-tight focus:outline-none focus:shadow-outline"- id="twoFactorCode"- type="text"- value={twoFactorCode}- onChange={(e) => setTwoFactorCode(e.target.value)}- placeholder={t('auth.enterAuthCode')}- required- />- </div>- <div className="flex flex-col w-full space-y-2">- <Button type="submit">- {t('auth.verify')}- </Button>- <Button- type="button"- onClick={async () => {- // Clear persisted 2FA state- await sendMessage('CLEAR_TWO_FACTOR_STATE');- // Reset the form- setCredentials({- username: '',- password: ''- });- setTwoFactorRequired(false);- setTwoFactorCode('');- setPasswordHashString(null);- setPasswordHashBase64(null);- setLoginResponse(null);- setError(null);- }}- variant="secondary"- >- {t('common.cancel')}- </Button>- </div>- <p className="text-xs text-gray-500 dark:text-gray-400 mt-4 text-center">- {t('auth.authCodeNote')}- </p>- </form>+ </form>+ </div></div>);}diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/UnlockSuccess.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/UnlockSuccess.tsxdeleted file mode 100644index 4d7df51df..000000000--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/UnlockSuccess.tsx+++ /dev/null@@ -1,180 +0,0 @@-import React, { useEffect, useState, useRef, useCallback } from 'react';-import { useTranslation } from 'react-i18next';-import { useNavigate } from 'react-router-dom';--import { CountdownBar, type ICountdownBarHandle } from '@/entrypoints/popup/components/CountdownBar';--import { LocalPreferencesService } from '@/utils/LocalPreferencesService';--const AUTO_CLOSE_COUNTDOWN_SECONDS = 2.5;--/**- * Unlock success component shown when the vault is successfully unlocked in a separate popup- * asking the user if they want to close the popup.- */-const UnlockSuccess: React.FC = () => {- const navigate = useNavigate();- const { t } = useTranslation();- const [autoCloseEnabled, setAutoCloseEnabled] = useState<boolean>(false);- const [countdown, setCountdown] = useState<number | null>(null);- const [isLoading, setIsLoading] = useState<boolean>(true);- const countdownTimerRef = useRef<ReturnType<typeof setInterval> | null>(null);- const countdownBarRef = useRef<ICountdownBarHandle>(null);-- /**- * Clear the countdown timer- */- const clearCountdownTimer = useCallback((): void => {- if (countdownTimerRef.current) {- clearInterval(countdownTimerRef.current);- countdownTimerRef.current = null;- }- }, []);-- /**- * Start the auto-close countdown- */- const startCountdown = useCallback((): void => {- clearCountdownTimer();- setCountdown(AUTO_CLOSE_COUNTDOWN_SECONDS);-- // Start the animation bar- countdownBarRef.current?.startAnimation(AUTO_CLOSE_COUNTDOWN_SECONDS);-- countdownTimerRef.current = setInterval(() => {- setCountdown((prev) => {- if (prev === null || prev <= 1) {- clearCountdownTimer();- window.close();- return null;- }- return prev - 1;- });- }, 1000);- }, [clearCountdownTimer]);-- /**- * Stop the auto-close countdown- */- const stopCountdown = useCallback((): void => {- clearCountdownTimer();- setCountdown(null);- countdownBarRef.current?.stopAnimation();- }, [clearCountdownTimer]);-- /**- * Handle checkbox change- */- const handleAutoCloseChange = async (checked: boolean): Promise<void> => {- setAutoCloseEnabled(checked);- await LocalPreferencesService.setAutoCloseUnlockPopup(checked);-- if (checked) {- startCountdown();- } else {- stopCountdown();- }- };-- /**- * Handle browsing vault contents - navigate to items page and reset mode parameter- */- const handleBrowseVaultContents = (): void => {- stopCountdown();-- // Remove mode=inline from URL before navigating- const url = new URL(window.location.href);- url.searchParams.delete('mode');- window.history.replaceState({}, '', url);-- // Navigate to items page- navigate('/items');- };-- /**- * Handle close popup button click- */- const handleClosePopup = (): void => {- stopCountdown();- window.close();- };-- // Load saved preference and start countdown if enabled- useEffect(() => {- /**- * Load the auto-close preference from storage- */- const loadPreference = async (): Promise<void> => {- const enabled = await LocalPreferencesService.getAutoCloseUnlockPopup();- setAutoCloseEnabled(enabled);- setIsLoading(false);-- if (enabled) {- // Use setTimeout to ensure the CountdownBar component has mounted- setTimeout(() => {- startCountdown();- }, 0);- }- };-- loadPreference();-- return (): void => {- clearCountdownTimer();- };- }, [clearCountdownTimer, startCountdown]);-- return (- <div className="flex flex-col items-center justify-center p-6 text-center">- {/* Countdown bar at the top */}- <CountdownBar- ref={countdownBarRef}- isVisible={countdown !== null}- colorClass="bg-primary-500"- />-- <div className="mb-4 text-green-600 dark:text-green-400">- <svg className="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />- </svg>- </div>- <h2 className="text-xl font-semibold mb-4 text-gray-900 dark:text-white">- {t('auth.unlockSuccessTitle')}- </h2>- <p className="mb-6 text-gray-600 dark:text-gray-400">- {t('auth.unlockSuccessDescription')}- </p>-- <div className="space-y-3 w-full">- <button- onClick={handleClosePopup}- className="w-full px-4 py-2 text-white bg-primary-600 rounded hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2"- >- {t('auth.closePopup')}- </button>- <button- onClick={handleBrowseVaultContents}- className="w-full px-4 py-2 text-gray-900 bg-white border border-gray-300 rounded hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600 dark:border-gray-600"- >- {t('auth.browseVault')}- </button>- </div>-- {/* Auto-close checkbox at the bottom with subtle styling */}- <div className="w-full mt-6 pt-4 border-t border-gray-200 dark:border-gray-700">- <label className="flex items-center justify-center gap-2 cursor-pointer text-xs text-gray-400 dark:text-gray-500">- <input- type="checkbox"- checked={autoCloseEnabled}- onChange={(e) => handleAutoCloseChange(e.target.checked)}- disabled={isLoading}- className="w-3.5 h-3.5 rounded border-gray-300 text-gray-400 focus:ring-gray-400 dark:border-gray-600 dark:bg-gray-700"- />- <span>{t('auth.autoCloseUnlockPopup')}</span>- </label>- </div>- </div>- );-};--export default UnlockSuccess;diff --git a/apps/browser-extension/src/entrypoints/popup/utils/routes.ts b/apps/browser-extension/src/entrypoints/popup/utils/routes.tsindex e24b2c69b..4091673e6 100644--- a/apps/browser-extension/src/entrypoints/popup/utils/routes.ts+++ b/apps/browser-extension/src/entrypoints/popup/utils/routes.ts@@ -7,5 +7,4 @@ export const AUTH_FLOW_PATHS: readonly string[] = ['/reinitialize','/login','/unlock',- '/unlock-success',];diff --git a/apps/browser-extension/src/utils/LocalPreferencesService.ts b/apps/browser-extension/src/utils/LocalPreferencesService.tsindex dd6a9b507..001ead8ad 100644--- a/apps/browser-extension/src/utils/LocalPreferencesService.ts+++ b/apps/browser-extension/src/utils/LocalPreferencesService.ts@@ -30,22 +30,6 @@ export const LocalPreferencesService = {await storage.setItem(StorageKeys.SHOW_FOLDERS, showFolders);},- /**- * Get the auto-close unlock popup preference.- * @returns Whether to auto-close the popup after unlocking. Defaults to true.- */- async getAutoCloseUnlockPopup(): Promise<boolean> {- const value = await storage.getItem(StorageKeys.AUTO_CLOSE_UNLOCK_POPUP) as boolean | null;- return value ?? true;- },-- /**- * Set the auto-close unlock popup preference.- */- async setAutoCloseUnlockPopup(enabled: boolean): Promise<void> {- await storage.setItem(StorageKeys.AUTO_CLOSE_UNLOCK_POPUP, enabled);- },-/** ============================================* Unlock screen behaviordiff --git a/apps/browser-extension/src/utils/constants/storageKeys.ts b/apps/browser-extension/src/utils/constants/storageKeys.tsindex 47d70d7a6..a11214ddd 100644--- a/apps/browser-extension/src/utils/constants/storageKeys.ts+++ b/apps/browser-extension/src/utils/constants/storageKeys.ts@@ -79,8 +79,6 @@ export const StorageKeys = {CUSTOM_USERNAME_HISTORY: 'local:aliasvault_custom_username_history',/** Whether the item list is grouped by folder. */SHOW_FOLDERS: 'local:aliasvault_show_folders',- /** Whether the popup closes automatically after unlocking. */- AUTO_CLOSE_UNLOCK_POPUP: 'local:aliasvault_auto_close_unlock_popup',/** Unlock method used last, preselected on the unlock screen. */LAST_USED_UNLOCK_METHOD: 'local:aliasvault_last_used_unlock_method',/** Whether the save-login prompt is enabled. */@@ -157,7 +155,6 @@ export const LOCAL_PREFERENCE_STORAGE_KEYS: readonly StorageKey[] = [StorageKeys.CUSTOM_EMAIL_HISTORY,StorageKeys.CUSTOM_USERNAME_HISTORY,StorageKeys.SHOW_FOLDERS,- StorageKeys.AUTO_CLOSE_UNLOCK_POPUP,StorageKeys.LAST_USED_UNLOCK_METHOD,StorageKeys.LOGIN_SAVE_ENABLED,StorageKeys.LOGIN_SAVE_AUTO_DISMISS_SECONDS,diff --git a/core/i18n/locales/en.json b/core/i18n/locales/en.jsonindex 105aab90b..60b0ac995 100644--- a/core/i18n/locales/en.json+++ b/core/i18n/locales/en.json@@ -80,10 +80,8 @@"auth": {"authCode": "Authentication Code","authCodeNote": "Note: if you don't have access to your authenticator device, you can reset your 2FA with a recovery code by logging in via the website.",- "autoCloseUnlockPopup": "Auto-close on future sign ins","biometricPrompt": "Would you like to use {{biometric}} to unlock your vault?","browseVault": "Browse vault contents",- "closePopup": "Close this popup","confirmLogout": "Are you sure you want to logout? You need to login again with your master password to access your vault.","connectingTo": "Connecting to","createNewVault": "Create new vault",@@ -200,8 +198,6 @@"unlockWithWebAuthn": "Unlock with passkey","webAuthnNotSupportedError": "Your current browser does not support the WebAuthn PRF extension. Please login with your password instead."},- "unlockSuccessDescription": "You can now use autofill in login forms in your browser.",- "unlockSuccessTitle": "Your vault is successfully unlocked","unlockTitle": "Unlock Your Vault","unlockVault": "Unlock Vault","unlockWithBiometric": "Unlock with {{biometric}}",