Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Open popup from locked vault notice (#541)
Leendert de Borstb1ab983333a6
diff --git a/browser-extensions/chrome/src/background.ts b/browser-extensions/chrome/src/background.tsindex 4d86e975b..f54c70657 100644--- a/browser-extensions/chrome/src/background.ts+++ b/browser-extensions/chrome/src/background.ts@@ -118,7 +118,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {* console.log('matchingCredentials:', matchingCredentials);*/- sendResponse({ credentials: credentials });+ sendResponse({ credentials: credentials, status: 'OK' });} catch (error) {console.error('Error getting credentials:', error);sendResponse({ credentials: [], status: 'LOCKED', error: 'Failed to get credentials' });@@ -131,6 +131,18 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {sendResponse(vaultState.derivedKey ? vaultState.derivedKey : null);break;}++ case 'OPEN_POPUP': {+ chrome.windows.create({+ url: chrome.runtime.getURL('index.html'),+ type: 'popup',+ width: 400,+ height: 600,+ focused: true+ });+ sendResponse({ success: true });+ break;+ }}return true;});diff --git a/browser-extensions/chrome/src/contentScript.ts b/browser-extensions/chrome/src/contentScript.tsindex 9b863bb8a..05976d164 100644--- a/browser-extensions/chrome/src/contentScript.ts+++ b/browser-extensions/chrome/src/contentScript.ts@@ -1,13 +1,18 @@import { detectForms } from './utils/FormDetector';import { Credential } from './types/Credential';-interface CredentialResponse {+type CredentialResponse = {status: 'OK' | 'LOCKED';credentials?: Credential[];}const placeholderBase64 = 'UklGRjoEAABXRUJQVlA4IC4EAAAwFwCdASqAAIAAPpFCm0olo6Ihp5IraLASCWUA0eb/0s56RrLtCnYfLPiBshdXWMx8j1Ez65f169iA4xUDBTEV6ylMQeCIj2b7RngGi7gKZ9WjKdSoy9R8JcgOmjCMlDmLG20KhNo/i/Dc/Ah5GAvGfm8kfniV3AkR6fxN6eKwjDc6xrDgSfS48G5uGV6WzQt24YAVlLSK9BMwndzfHnePK1KFchFrL7O3ulB8cGNCeomu4o+l0SrS/JKblJ4WTzj0DAD++lCU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BYSpjMwM193Swt+yJyjvaGYWPnqExxKiNarpB2WSO7soCAZXhS1uEYHryrK47BH6W1dRiruqT0xpLih3MXiwU3VDwAAAA==';+// Add this function at the top of the file+function isDarkMode(): boolean {+ return window.matchMedia('(prefers-color-scheme: dark)').matches;+}+// Listen for input field focusdocument.addEventListener('focusin', (e) => {const target = e.target as HTMLInputElement;@@ -23,8 +28,12 @@ function showCredentialPopup(input: HTMLInputElement) : void {const forms = detectForms();if (!forms.length) return;+ console.log('showCredentialPopup called');+// Request credentials from background scriptchrome.runtime.sendMessage({ type: 'GET_CREDENTIALS_FOR_URL', url: window.location.href }, (response: CredentialResponse) => {+ console.log('showCredentialPopup response:', response);+switch (response.status) {case 'OK':if (response.credentials?.length) {@@ -33,7 +42,7 @@ function showCredentialPopup(input: HTMLInputElement) : void {break;case 'LOCKED':- createStatusPopup(input, 'AliasVault is locked, please login (again).');+ createStatusPopup(input, 'AliasVault is locked.');break;}});@@ -58,12 +67,13 @@ function createPopup(input: HTMLInputElement, credentials: Credential[]) : voidpopup.style.cssText = `position: absolute;z-index: 999999;- background: white;- border: 1px solid #ccc;+ background: ${isDarkMode() ? '#1f2937' : 'white'};+ border: 1px solid ${isDarkMode() ? '#374151' : '#ccc'};border-radius: 4px;- box-shadow: 0 2px 4px rgba(0,0,0,0.2);+ box-shadow: 0 2px 4px ${isDarkMode() ? 'rgba(0,0,0,0.4)' : 'rgba(0,0,0,0.2)'};padding: 8px 0;width: ${popupWidth}px;+ color: ${isDarkMode() ? '#f8f9fa' : '#000000'};`;/**@@ -126,7 +136,7 @@ function createPopup(input: HTMLInputElement, credentials: Credential[]) : void});item.addEventListener('mouseenter', () => {- item.style.backgroundColor = '#f0f0f0';+ item.style.backgroundColor = isDarkMode() ? '#374151' : '#f0f0f0';});item.addEventListener('mouseleave', () => {@@ -158,29 +168,80 @@ function createStatusPopup(input: HTMLInputElement, message: string): void {popup.style.cssText = `position: absolute;z-index: 999999;- background: white;- border: 1px solid #ccc;+ background: ${isDarkMode() ? '#1f2937' : 'white'};+ border: 1px solid ${isDarkMode() ? '#374151' : '#ccc'};border-radius: 4px;- box-shadow: 0 2px 4px rgba(0,0,0,0.2);+ box-shadow: 0 2px 4px ${isDarkMode() ? 'rgba(0,0,0,0.4)' : 'rgba(0,0,0,0.2)'};padding: 12px 16px;width: ${popupWidth}px;+ color: ${isDarkMode() ? '#f8f9fa' : '#000000'};+ `;++ // Create container for message and button+ const container = document.createElement('div');+ container.style.cssText = `+ display: flex;+ align-items: center;+ position: relative;`;// Add messageconst messageElement = document.createElement('div');messageElement.style.cssText = `- color: #666;+ color: ${isDarkMode() ? '#d1d5db' : '#666'};font-size: 14px;+ padding-right: 32px;`;messageElement.textContent = message;- popup.appendChild(messageElement);+ container.appendChild(messageElement);++ // Add unlock button with SVG icon+ const button = document.createElement('button');+ button.title = 'Unlock AliasVault';+ button.style.cssText = `+ position: absolute;+ right: 0;+ background: none;+ border: none;+ cursor: pointer;+ padding: 4px;+ display: flex;+ align-items: center;+ justify-content: center;+ color: #0066cc;+ border-radius: 4px;+ `;+ button.innerHTML = `+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>+ <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>+ </svg>+ `;++ button.addEventListener('mouseenter', () => {+ button.style.backgroundColor = isDarkMode() ? '#374151' : '#f0f0f0';+ });++ button.addEventListener('mouseleave', () => {+ button.style.backgroundColor = 'transparent';+ });++ button.addEventListener('click', () => {+ chrome.runtime.sendMessage({ type: 'OPEN_POPUP' });+ removeExistingPopup();+ });++ container.appendChild(button);+ popup.appendChild(container);// Position popup below inputconst rect = input.getBoundingClientRect();popup.style.top = `${rect.bottom + window.scrollY + 2}px`;popup.style.left = `${rect.left + window.scrollX}px`;- // Add click outside handler+ /**+ * Add event listener to document to close popup when clicking outside.+ */const handleClickOutside = (event: MouseEvent): void => {if (!popup.contains(event.target as Node)) {removeExistingPopup();