Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update save prompt re-emitter (#1694)

Leendert de Borstd66c489ab666
diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.ts
index 3d141989f..adcc5799c 100644
--- a/apps/browser-extension/src/entrypoints/content.ts
+++ b/apps/browser-extension/src/entrypoints/content.ts
@@ -158,6 +158,21 @@ function initializeLoginDetector(container: HTMLElement): void {
return;
}
+ // Check if vault is locked
+ try {
+ const authStatus = await sendMessage('CHECK_AUTH_STATUS', {}, 'background') as {
+ isLoggedIn: boolean;
+ 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 credentials
if (isSavePromptVisible()) {
console.debug('[AliasVault] Save prompt already visible, updating with new credentials');
diff --git a/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts b/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts
index dd03203aa..c1991b600 100644
--- a/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts
+++ b/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts
@@ -29,6 +29,9 @@ let countdownStartTime = 0;
/** Current auto-dismiss duration */
let currentAutoDismissMs = 0;
+/** Initial auto-dismiss duration (for resetting) */
+let initialAutoDismissMs = 0;
+
/** Callback for when auto-dismiss triggers */
let onAutoDismissCallback: (() => void) | null = null;
@@ -70,6 +73,7 @@ export async function showSavePrompt(container: HTMLElement, options: SavePrompt
// Set up auto-dismiss with countdown bar
if (autoDismissMs > 0) {
// Initialize countdown state
+ initialAutoDismissMs = autoDismissMs;
currentAutoDismissMs = autoDismissMs;
remainingTimeMs = autoDismissMs;
countdownStartTime = Date.now();
@@ -156,6 +160,43 @@ function resumeCountdown(): void {
}, remainingTimeMs);
}
+/**
+ * Reset the countdown timer to the initial duration.
+ * Called when new credentials are detected to give user time to review.
+ */
+function resetCountdown(): void {
+ if (initialAutoDismissMs <= 0) {
+ return;
+ }
+
+ // Clear existing timer
+ if (autoDismissTimer) {
+ clearTimeout(autoDismissTimer);
+ autoDismissTimer = null;
+ }
+
+ // Reset countdown state
+ currentAutoDismissMs = initialAutoDismissMs;
+ remainingTimeMs = initialAutoDismissMs;
+ countdownStartTime = Date.now();
+ isAutoDismissPaused = false;
+
+ // Reset and restart countdown bar animation
+ if (countdownBar) {
+ countdownBar.style.transition = 'none';
+ countdownBar.style.width = '100%';
+ // Force reflow to restart animation
+ void countdownBar.offsetWidth;
+ startCountdownAnimation(initialAutoDismissMs);
+ }
+
+ // Set new timer
+ autoDismissTimer = window.setTimeout(() => {
+ removeSavePrompt();
+ onAutoDismissCallback?.();
+ }, initialAutoDismissMs);
+}
+
/**
* Set up listeners to pause/resume countdown on hover and focus.
*/
@@ -185,6 +226,7 @@ export function removeSavePrompt(): void {
remainingTimeMs = 0;
countdownStartTime = 0;
currentAutoDismissMs = 0;
+ initialAutoDismissMs = 0;
onAutoDismissCallback = null;
// Reset login state
@@ -253,6 +295,9 @@ export function updateSavePromptLogin(login: CapturedLogin): void {
}
}
+ // Reset the auto-dismiss timer to give user time to review new credentials
+ resetCountdown();
+
console.debug('[AliasVault] Updated save prompt with new credentials');
}
diff --git a/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts b/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts
index e8017712f..d69231712 100644
--- a/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts
+++ b/apps/browser-extension/src/utils/loginDetector/LoginDetector.ts
@@ -347,9 +347,14 @@ export class LoginDetector {
* Emit login with debouncing to prevent duplicates.
*/
private emitLoginDebounced(login: CapturedLogin): void {
- // Check if this is the same login we just captured
+ /*
+ * Check if this is the exact same login we just captured (including password).
+ * We include password in the comparison so that retries with different passwords
+ * are still emitted and can update the save prompt with new credentials.
+ */
if (this.lastCapturedLogin &&
this.lastCapturedLogin.username === login.username &&
+ this.lastCapturedLogin.password === login.password &&
this.lastCapturedLogin.domain === login.domain &&
Date.now() - this.lastCapturedLogin.timestamp < 5000) {
// Skip duplicate within 5 seconds