Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add credential create popout icon in inline credential create as fallback (#1247)
Leendert de Borst08517e346933
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.tsindex ee090643a..d6912301e 100644--- a/apps/browser-extension/src/entrypoints/background.ts+++ b/apps/browser-extension/src/entrypoints/background.ts@@ -3,7 +3,7 @@ import { onMessage, sendMessage } from "webext-bridge/background";import { handleResetAutoLockTimer, handlePopupHeartbeat, handleSetAutoLockTimeout } from '@/entrypoints/background/AutolockTimeoutHandler';import { handleClipboardCopied, handleCancelClipboardClear, handleGetClipboardClearTimeout, handleSetClipboardClearTimeout, handleGetClipboardCountdownState } from '@/entrypoints/background/ClipboardClearHandler';import { setupContextMenus } from '@/entrypoints/background/ContextMenu';-import { handleOpenPopup, handlePopupWithCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';+import { handleOpenPopup, handlePopupWithCredential, handleOpenPopupCreateCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearVault, handleCreateIdentity, handleGetCredentials, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGetPersistedFormValues, handleGetVault, handlePersistFormValues, handleStoreEncryptionKey, handleStoreEncryptionKeyDerivationParams, handleStoreVault, handleSyncVault, handleUploadVault } from '@/entrypoints/background/VaultMessageHandler';import { GLOBAL_CONTEXT_MENU_ENABLED_KEY } from '@/utils/Constants';@@ -40,6 +40,7 @@ export default defineBackground({onMessage('OPEN_POPUP', () => handleOpenPopup());onMessage('OPEN_POPUP_WITH_CREDENTIAL', ({ data }) => handlePopupWithCredential(data));+ onMessage('OPEN_POPUP_CREATE_CREDENTIAL', ({ data }) => handleOpenPopupCreateCredential(data));onMessage('TOGGLE_CONTEXT_MENU', ({ data }) => handleToggleContextMenu(data));onMessage('PERSIST_FORM_VALUES', ({ data }) => handlePersistFormValues(data));diff --git a/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.tsindex 2314c9340..654c7c612 100644--- a/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts@@ -1,6 +1,7 @@/* eslint-disable @typescript-eslint/no-explicit-any */import { setupContextMenus } from '@/entrypoints/background/ContextMenu';+import { SKIP_FORM_RESTORE_KEY } from '@/utils/Constants';import { BoolResponse } from '@/utils/types/messaging/BoolResponse';import { browser } from '#imports';@@ -37,6 +38,50 @@ export function handlePopupWithCredential(message: any) : Promise<BoolResponse>})();}+/**+ * Handle opening the popup on create credential page with prefilled service name.+ */+export function handleOpenPopupCreateCredential(message: any) : Promise<BoolResponse> {+ return (async () : Promise<BoolResponse> => {+ const serviceName = encodeURIComponent(message.serviceName || '');++ // Use the URL passed from the content script (current page URL)+ let serviceUrl = '';+ if (message.currentUrl) {+ try {+ const url = new URL(message.currentUrl);+ // Only include http/https URLs+ if (url.protocol === 'http:' || url.protocol === 'https:') {+ serviceUrl = encodeURIComponent(url.origin + url.pathname);+ }+ } catch (error) {+ console.error('Error parsing current URL:', error);+ }+ }++ // Set a localStorage flag to skip restoring previously persisted form values as we want to start fresh with this explicit create credential request.+ await browser.storage.local.set({ [SKIP_FORM_RESTORE_KEY]: true });++ const urlParams = new URLSearchParams();+ urlParams.set('expanded', 'true');+ if (serviceName) {+ urlParams.set('serviceName', serviceName);+ }+ if (serviceUrl) {+ urlParams.set('serviceUrl', serviceUrl);+ }++ browser.windows.create({+ url: browser.runtime.getURL(`/popup.html?${urlParams.toString()}#/credentials/add`),+ type: 'popup',+ width: 400,+ height: 600,+ focused: true+ });+ return { success: true };+ })();+}+/*** Handle toggling the context menu.*/diff --git a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts b/apps/browser-extension/src/entrypoints/contentScript/Popup.tsindex b2ba444b1..2faf045c3 100644--- a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts@@ -829,11 +829,20 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootCon${randomIdentityIcon}<h3 class="av-create-popup-title">${randomIdentityTitle}</h3></div>- <button class="av-create-popup-mode-dropdown">- <svg class="av-icon" viewBox="0 0 24 24">- <path d="M6 9l6 6 6-6"/>- </svg>- </button>+ <div class="av-create-popup-header-buttons">+ <button class="av-create-popup-mode-dropdown">+ <svg class="av-icon" viewBox="0 0 24 24">+ <path d="M6 9l6 6 6-6"/>+ </svg>+ </button>+ <button class="av-create-popup-popout" title="Open in main popup">+ <svg class="av-icon" viewBox="0 0 24 24">+ <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>+ <polyline points="15 3 21 3 21 9"></polyline>+ <line x1="10" y1="14" x2="21" y2="3"></line>+ </svg>+ </button>+ </div></div></div>@@ -960,6 +969,7 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConconst customMode = popup.querySelector('.av-create-popup-custom-mode') as HTMLElement;const dropdownMenu = popup.querySelector('.av-create-popup-mode-dropdown-menu') as HTMLElement;const titleContainer = popup.querySelector('.av-create-popup-title-container') as HTMLElement;+ const popoutBtn = popup.querySelector('.av-create-popup-popout') as HTMLButtonElement;const cancelBtn = popup.querySelector('#cancel-btn') as HTMLButtonElement;const customCancelBtn = popup.querySelector('#custom-cancel-btn') as HTMLButtonElement;const saveBtn = popup.querySelector('#save-btn') as HTMLButtonElement;@@ -1042,6 +1052,16 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConawait updateSuggestions(customEmail, emailSuggestions, emailHistory);await updateSuggestions(customUsername, usernameSuggestions, usernameHistory);+ // Handle popout button click+ popoutBtn.addEventListener('click', (e) => {+ e.preventDefault();+ e.stopPropagation();+ const serviceName = inputServiceName.value.trim();+ const currentUrl = window.location.href;+ sendMessage('OPEN_POPUP_CREATE_CREDENTIAL', { serviceName, currentUrl }, 'background');+ closePopup(null);+ });+// Handle email inputcustomEmail.addEventListener('input', async () => {await updateSuggestions(customEmail, emailSuggestions, emailHistory);diff --git a/apps/browser-extension/src/entrypoints/contentScript/style.css b/apps/browser-extension/src/entrypoints/contentScript/style.cssindex 5fa946e06..2b23e36ec 100644--- a/apps/browser-extension/src/entrypoints/contentScript/style.css+++ b/apps/browser-extension/src/entrypoints/contentScript/style.css@@ -784,28 +784,41 @@ body {.av-create-popup-title-container {display: flex;align-items: center;- gap: 8px;flex: 1;- justify-content: center;cursor: pointer;padding: 4px 8px;border-radius: 4px;transition: background-color 0.2s;+ position: relative;}.av-create-popup-title-wrapper {+ position: absolute;+ left: 0;+ right: 0;display: flex;align-items: center;+ justify-content: center;gap: 8px;color: #d68338;+ pointer-events: none;+}++.av-create-popup-header-buttons {+ display: flex;+ align-items: center;+ gap: 4px;+ margin-left: auto;}+.av-create-popup-title-wrapper .av-icon {width: 20px;height: 20px;stroke-width: 1.5;stroke-linecap: round;stroke-linejoin: round;+ pointer-events: auto;}.av-create-popup-title-wrapper .av-create-popup-title {@@ -813,6 +826,7 @@ body {font-size: 18px;font-weight: 600;color: #f8f9fa;+ pointer-events: auto;}.av-create-popup-title-container:hover {@@ -841,6 +855,34 @@ body {height: 16px;}+.av-create-popup-popout {+ background: none;+ border: none;+ padding: 4px;+ cursor: pointer;+ color: #9ca3af;+ display: flex;+ align-items: center;+ justify-content: center;+ border-radius: 4px;+ transition: background-color 0.2s, color 0.2s;+}++.av-create-popup-popout:hover {+ background-color: #4b5563;+ color: #d68338;+}++.av-create-popup-popout .av-icon {+ width: 16px;+ height: 16px;+ stroke: currentColor;+ fill: none;+ stroke-width: 2;+ stroke-linecap: round;+ stroke-linejoin: round;+}+.av-create-popup-mode-dropdown-menu {position: absolute;left: 50%;diff --git a/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsxindex ded576dfb..a60569d71 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialAddEdit.tsx@@ -23,10 +23,13 @@ import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';import { useVaultMutate } from '@/entrypoints/popup/hooks/useVaultMutate';+import { SKIP_FORM_RESTORE_KEY } from '@/utils/Constants';import { IdentityHelperUtils, CreateIdentityGenerator, CreateUsernameEmailGenerator, Identity, Gender } from '@/utils/dist/shared/identity-generator';import type { Attachment, Credential } from '@/utils/dist/shared/models/vault';import { CreatePasswordGenerator } from '@/utils/dist/shared/password-generator';+import { browser } from '#imports';+type CredentialMode = 'random' | 'manual';// Persisted form data type used for JSON serialization.@@ -230,14 +233,36 @@ const CredentialAddEdit: React.FC = () => {}if (!id) {- // On create mode, focus the service name field after a short delay to ensure the component is mounted.+ // On create mode, check for URL parameters and prefill if present+ const urlParams = new URLSearchParams(window.location.search);+ const serviceName = urlParams.get('serviceName');+ const serviceUrl = urlParams.get('serviceUrl');++ if (serviceName) {+ setValue('ServiceName', decodeURIComponent(serviceName));+ }+ if (serviceUrl) {+ setValue('ServiceUrl', decodeURIComponent(serviceUrl));+ }++ // Focus the service name field after a short delay to ensure the component is mounted.setTimeout(() => {serviceNameRef.current?.focus();}, 100);setIsInitialLoading(false);- // Load persisted form values if they exist.- loadPersistedValues();+ // Check if we should skip form restoration (e.g., when opened from popout button)+ browser.storage.local.get([SKIP_FORM_RESTORE_KEY]).then((result) => {+ if (result[SKIP_FORM_RESTORE_KEY]) {+ // Clear the flag after using it+ browser.storage.local.remove([SKIP_FORM_RESTORE_KEY]);+ // Don't load persisted values, but set local loading to false+ setLocalLoading(false);+ } else {+ // Load persisted form values normally+ loadPersistedValues();+ }+ });return;}@@ -270,7 +295,7 @@ const CredentialAddEdit: React.FC = () => {console.error('Error loading credential:', err);setIsInitialLoading(false);}- }, [dbContext.sqliteClient, id, navigate, setIsInitialLoading, setValue, loadPersistedValues]);+ }, [dbContext.sqliteClient, id, navigate, setIsInitialLoading, setValue, loadPersistedValues, clearPersistedValues]);/*** Handle the delete button click.diff --git a/apps/browser-extension/src/utils/Constants.ts b/apps/browser-extension/src/utils/Constants.tsindex 6ea4e113e..2b24651b5 100644--- a/apps/browser-extension/src/utils/Constants.ts+++ b/apps/browser-extension/src/utils/Constants.ts@@ -1,4 +1,3 @@-// TODO: store generic setting constants somewhere else.export const DISABLED_SITES_KEY = 'local:aliasvault_disabled_sites';export const GLOBAL_AUTOFILL_POPUP_ENABLED_KEY = 'local:aliasvault_global_autofill_popup_enabled';export const GLOBAL_CONTEXT_MENU_ENABLED_KEY = 'local:aliasvault_global_context_menu_enabled';@@ -11,3 +10,4 @@ export const AUTOFILL_MATCHING_MODE_KEY = 'local:aliasvault_autofill_matching_mo// TODO: store these settings in the actual vault when updating the datamodel for roadmap v1.0.export const CUSTOM_EMAIL_HISTORY_KEY = 'local:aliasvault_custom_email_history';export const CUSTOM_USERNAME_HISTORY_KEY = 'local:aliasvault_custom_username_history';+export const SKIP_FORM_RESTORE_KEY = 'local:aliasvault_skip_form_restore';