Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor (#1694)
Leendert de Borste1429a85eeb4
diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.tsindex eb3e4d6ec..7ef51a228 100644--- a/apps/browser-extension/src/entrypoints/content.ts+++ b/apps/browser-extension/src/entrypoints/content.ts@@ -29,13 +29,6 @@ let loginDetector: LoginDetector | null = null;* @param serviceName - The user-specified service name.*/async function handleSaveLogin(login: CapturedLogin, serviceName: string): Promise<void> {- console.debug('[AliasVault] Save requested:', {- serviceName,- username: login.username,- domain: login.domain,- hasFavicon: !!login.faviconUrl,- });-try {const response = await sendMessage('SAVE_LOGIN_CREDENTIAL', {serviceName,@@ -46,9 +39,7 @@ async function handleSaveLogin(login: CapturedLogin, serviceName: string): PromifaviconUrl: login.faviconUrl,}, 'background') as { success: boolean; itemId?: string; error?: string };- if (response.success) {- console.debug('[AliasVault] Login saved successfully, itemId:', response.itemId);- } else {+ if (!response.success) {console.error('[AliasVault] Failed to save login:', response.error);}} catch (error) {@@ -61,8 +52,6 @@ async function handleSaveLogin(login: CapturedLogin, serviceName: string): Promi* @param domain - The domain to block from future save prompts.*/async function handleNeverSaveForDomain(domain: string): Promise<void> {- console.debug('[AliasVault] Never save for domain:', domain);-// Store the blocked domain in local storagetry {const blockedDomains = await storage.getItem('local:loginSaveBlockedDomains') as string[] ?? [];@@ -79,7 +68,7 @@ async function handleNeverSaveForDomain(domain: string): Promise<void> {* Handle save prompt dismissal.*/function handleSavePromptDismiss(): void {- console.debug('[AliasVault] Save prompt dismissed');+ // No action needed on dismiss}/**@@ -147,8 +136,6 @@ async function checkAndRestoreSavePromptEarly(ctx: Parameters<typeof createShadoreturn;}- console.debug('[AliasVault] Found persisted save prompt state, attempting early restore');-// Wait for body to be available (poll quickly)let attempts = 0;while (!document.body && attempts < 50) {@@ -228,11 +215,8 @@ async function checkAndRestorePersistedSavePrompt(container: HTMLElement): Promireturn;}- console.debug('[AliasVault] Found persisted save prompt state, checking if we should restore');-// Check if the feature is still enabledif (!await isLoginSaveEnabled()) {- console.debug('[AliasVault] Login save feature is disabled, not restoring prompt');return;}@@ -243,17 +227,14 @@ async function checkAndRestorePersistedSavePrompt(container: HTMLElement): PromiisVaultLocked: boolean;};if (!authStatus.isLoggedIn || authStatus.isVaultLocked) {- console.debug('[AliasVault] Vault is locked or not logged in, not restoring prompt');return;}} catch {- console.debug('[AliasVault] Could not check auth status, not restoring prompt');return;}// Check if the domain is now blockedif (await isDomainBlocked(persistedState.domain)) {- console.debug('[AliasVault] Domain is now blocked, not restoring prompt');return;}@@ -284,16 +265,8 @@ function initializeLoginDetector(container: HTMLElement): void {loginDetector.initialize();loginDetector.onLoginCapture(async (login: CapturedLogin) => {- console.debug('[AliasVault] Login detected:', {- username: login.username,- domain: login.domain,- suggestedName: login.suggestedName,- hasPassword: !!login.password,- });-// Check if the feature is enabledif (!await isLoginSaveEnabled()) {- console.debug('[AliasVault] Login save feature is disabled');return;}@@ -304,30 +277,25 @@ function initializeLoginDetector(container: HTMLElement): void {isVaultLocked: boolean;};if (!authStatus.isLoggedIn || authStatus.isVaultLocked) {- console.debug('[AliasVault] Vault is locked or not logged in, skipping save prompt');return;}} catch {- console.debug('[AliasVault] Could not check auth status, skipping save prompt');return;}// Check if a save prompt is already visible - if so, update it with new credentialsif (isSavePromptVisible()) {- console.debug('[AliasVault] Save prompt already visible, updating with new credentials');updateSavePromptLogin(login);return;}// Check if the domain is blockedif (await isDomainBlocked(login.domain)) {- console.debug('[AliasVault] Domain is blocked from save prompts');return;}// Check if the login already exists in the vaultif (await isLoginDuplicate(login.domain, login.username)) {- console.debug('[AliasVault] Login already exists in vault, skipping save prompt');return;}diff --git a/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts b/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.tsindex 224f60cb4..ea478e03f 100644--- a/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts@@ -373,8 +373,6 @@ export async function restoreSavePromptFromState(// Set up periodic persistence for subsequent navigationssetupPeriodicPersistence();-- console.debug('[AliasVault] Restored save prompt from persisted state with', restoredRemainingTime, 'ms remaining');}/**@@ -418,8 +416,6 @@ export function updateSavePromptLogin(login: CapturedLogin): void {// Reset the auto-dismiss timer to give user time to review new credentialsresetCountdown();-- console.debug('[AliasVault] Updated save prompt with new credentials');}/**@@ -616,7 +612,6 @@ export async function getPersistedSavePromptState(): Promise<SavePromptPersistedgetBaseDomain(currentDomain) === getBaseDomain(state.domain);if (!isRelatedDomain) {- console.debug('[AliasVault] Persisted state domain mismatch:', state.domain, 'vs', currentDomain);await clearPersistedSavePromptState();return null;}@@ -624,7 +619,6 @@ export async function getPersistedSavePromptState(): Promise<SavePromptPersisted// The background script already adjusts the remaining time, but check if expiredif (state.remainingTimeMs <= 0) {- console.debug('[AliasVault] Persisted save prompt timer expired');await clearPersistedSavePromptState();return null;}diff --git a/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts b/apps/browser-extension/src/utils/loginDetector/LoginDetector.tsindex eb464ad8b..b43e7a73d 100644--- a/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts+++ b/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts@@ -26,12 +26,9 @@ export class LoginDetector {private captureDebounceTimer: number | null = null;private lastCapturedLogin: CapturedLogin | null = null;- /** Domains to exclude from login detection */+ /** Domains to exclude from login detection (only AliasVault itself) */private static readonly EXCLUDED_DOMAINS = ['aliasvault.net',- 'localhost',- '127.0.0.1',- '0.0.0.0',];/**@@ -114,11 +111,6 @@ export class LoginDetector {}}- // Skip non-HTTPS pages (configurable in future)- if (window.location.protocol !== 'https:') {- return true;- }-return false;}diff --git a/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.excludedDomains.test.ts b/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.excludedDomains.test.tsindex 2a26d4ea1..5534d0cb7 100644--- a/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.excludedDomains.test.ts+++ b/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.excludedDomains.test.ts@@ -17,8 +17,6 @@ describe('LoginDetector excluded domains', () => {const excludedUrls = ['https://aliasvault.net/login','https://subdomain.aliasvault.net/login',- 'https://127.0.0.1/login',- 'https://0.0.0.0/login',];excludedUrls.forEach((url) => {diff --git a/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.lifecycle.test.ts b/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.lifecycle.test.tsindex eeb92a4b7..d181e9216 100644--- a/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.lifecycle.test.ts+++ b/apps/browser-extension/src/utils/loginDetector/__tests__/LoginDetector.lifecycle.test.ts@@ -56,9 +56,12 @@ describe('LoginDetector lifecycle', () => {expect(callback).not.toHaveBeenCalled();});- it('should skip initialization for localhost', () => {+ it('should allow localhost (for self-hosted users)', () => {const { document, window } = createTestEnvironment(- '<html><body><form><input type="password"></form></body></html>',+ `<html><body><form>+ <input type="text" name="user" value="testuser">+ <input type="password" name="pass" value="testpass">+ </form></body></html>`,'https://localhost/login');setGlobalWindow(window);@@ -73,12 +76,15 @@ describe('LoginDetector lifecycle', () => {form?.dispatchEvent(new window.Event('submit', { bubbles: true }));vi.runAllTimers();- expect(callback).not.toHaveBeenCalled();+ expect(callback).toHaveBeenCalled();});- it('should skip initialization for HTTP (non-HTTPS) pages', () => {+ it('should allow HTTP pages (user choice to use insecure sites)', () => {const { document, window } = createTestEnvironment(- '<html><body><form><input type="password"></form></body></html>',+ `<html><body><form>+ <input type="text" name="user" value="testuser">+ <input type="password" name="pass" value="testpass">+ </form></body></html>`,'http://example.com/login');setGlobalWindow(window);@@ -93,7 +99,7 @@ describe('LoginDetector lifecycle', () => {form?.dispatchEvent(new window.Event('submit', { bubbles: true }));vi.runAllTimers();- expect(callback).not.toHaveBeenCalled();+ expect(callback).toHaveBeenCalled();});});