Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Replace webext-bridge with webext-core/messaging (#2062)
Leendert de Borst0947bb576d24
diff --git a/apps/browser-extension/package-lock.json b/apps/browser-extension/package-lock.jsonindex 8e1484d13..13fcf759f 100644--- a/apps/browser-extension/package-lock.json+++ b/apps/browser-extension/package-lock.json@@ -1,12 +1,12 @@{"name": "aliasvault-browser-extension",- "version": "0.29.0",+ "version": "0.30.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "aliasvault-browser-extension",- "version": "0.29.0",+ "version": "0.30.0","hasInstallScript": true,"dependencies": {"@dnd-kit/core": "^6.3.1",@@ -14,6 +14,7 @@"@dnd-kit/utilities": "^3.2.2","@hookform/resolvers": "^5.1.1","@types/dompurify": "^3.0.5",+ "@webext-core/messaging": "^3.0.1","argon2-browser": "^1.18.0","buffer": "^6.0.3","dompurify": "^3.4.0",@@ -29,7 +30,6 @@"secure-remote-password": "github:LinusU/secure-remote-password#73e5f732b6ca0cdbdc19da1a0c5f48cdbad2cbf0","sql.js": "^1.12.0","vitest": "^3.0.8",- "webext-bridge": "^6.0.1","yup": "^1.6.1"},"devDependencies": {@@ -159,6 +159,12 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/@aklinker1/zero-serialize-error": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/@aklinker1/zero-serialize-error/-/zero-serialize-error-1.0.2.tgz",+ "integrity": "sha512-hGVkgFqb8Zs80JJ7MOSCGQXH2SyWfwnJwOl8Qpp1lUdkp5T7GTf8QrAMib42Hnzx6HtnNYdmNaSSg4MQy+MDRQ==",+ "license": "MIT"+ },"node_modules/@alloc/quick-lru": {"version": "5.2.0","resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",@@ -2328,12 +2334,6 @@"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==","license": "MIT"},- "node_modules/@types/webextension-polyfill": {- "version": "0.8.3",- "resolved": "https://registry.npmjs.org/@types/webextension-polyfill/-/webextension-polyfill-0.8.3.tgz",- "integrity": "sha512-GN+Hjzy9mXjWoXKmaicTegv3FJ0WFZ3aYz77Wk8TMp1IY3vEzvzj1vnsa0ggV7vMI1i+PUxe4qqnIJKCzf9aTg==",- "license": "MIT"- },"node_modules/@types/yup": {"version": "0.29.14","resolved": "https://registry.npmjs.org/@types/yup/-/yup-0.29.14.tgz",@@ -2961,6 +2961,22 @@"dev": true,"license": "MIT"},+ "node_modules/@webext-core/messaging": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/@webext-core/messaging/-/messaging-3.0.1.tgz",+ "integrity": "sha512-xZ1DTIm/ZHBqKUf1+DczTywbF9MKeJ9ib3iUQIilh9o/2ETYprDDL+Gk5p28GEF82YW5+M2G7LVGpySfcvNpkg==",+ "license": "MIT",+ "dependencies": {+ "@aklinker1/zero-serialize-error": "^1.0.2",+ "webextension-polyfill": "^0.10.0"+ }+ },+ "node_modules/@webext-core/messaging/node_modules/webextension-polyfill": {+ "version": "0.10.0",+ "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",+ "integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g==",+ "license": "MPL-2.0"+ },"node_modules/@wxt-dev/browser": {"version": "0.1.4","resolved": "https://registry.npmjs.org/@wxt-dev/browser/-/browser-0.1.4.tgz",@@ -8583,15 +8599,6 @@"url": "https://github.com/sindresorhus/nano-spawn?sponsor=1"}},- "node_modules/nanoevents": {- "version": "6.0.2",- "resolved": "https://registry.npmjs.org/nanoevents/-/nanoevents-6.0.2.tgz",- "integrity": "sha512-FRS2otuFcPPYDPYViNWQ42+1iZqbXydinkRHTHFxrF4a1CpBfmydR9zkI44WSXAXCyPrkcGtPk5CnpW6Y3lFKQ==",- "license": "MIT",- "engines": {- "node": "^12.0.0 || ^14.0.0 || >=16.0.0"- }- },"node_modules/nanoid": {"version": "3.3.11","resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",@@ -10734,21 +10741,6 @@"node": ">=10"}},- "node_modules/serialize-error": {- "version": "9.1.1",- "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-9.1.1.tgz",- "integrity": "sha512-6uZQLGyUkNA4N+Zii9fYukmNu9PEA1F5rqcwXzN/3LtBjwl2dFBbVZ1Zyn08/CGkB4H440PIemdOQBt1Wvjbrg==",- "license": "MIT",- "dependencies": {- "type-fest": "^2.5.3"- },- "engines": {- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"- },- "funding": {- "url": "https://github.com/sponsors/sindresorhus"- }- },"node_modules/set-blocking": {"version": "2.0.0","resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",@@ -11694,12 +11686,6 @@"integrity": "sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==","license": "MIT"},- "node_modules/tiny-uid": {- "version": "1.1.2",- "resolved": "https://registry.npmjs.org/tiny-uid/-/tiny-uid-1.1.2.tgz",- "integrity": "sha512-0beRFXR+fv4C40ND2PqgNjq6iyB1dKXciKJjslLw0kPYCcR82aNd2b+Tt2yy06LimIlvtoehgvrm/fUZCutSfg==",- "license": "MIT"- },"node_modules/tinybench": {"version": "2.9.0","resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",@@ -12613,25 +12599,6 @@"url": "https://github.com/sponsors/sindresorhus"}},- "node_modules/webext-bridge": {- "version": "6.0.1",- "resolved": "https://registry.npmjs.org/webext-bridge/-/webext-bridge-6.0.1.tgz",- "integrity": "sha512-GruIrN+vNwbxVCi8UW4Dqk5YkcGA9V0ZfJ57jXP9JXHbrsDs5k2N6NNYQR5e+wSCnQpGYOGAGihwUpKlhg8QIw==",- "license": "MIT",- "dependencies": {- "@types/webextension-polyfill": "^0.8.3",- "nanoevents": "^6.0.2",- "serialize-error": "^9.0.0",- "tiny-uid": "^1.1.1",- "webextension-polyfill": "^0.9.0"- }- },- "node_modules/webextension-polyfill": {- "version": "0.9.0",- "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.9.0.tgz",- "integrity": "sha512-LTtHb0yR49xa9irkstDxba4GATDAcDw3ncnFH9RImoFwDlW47U95ME5sn5IiQX2ghfaECaf6xyXM8yvClIBkkw==",- "license": "MPL-2.0"- },"node_modules/webidl-conversions": {"version": "7.0.0","resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",diff --git a/apps/browser-extension/package.json b/apps/browser-extension/package.jsonindex ddfeaccf6..b7a21f205 100644--- a/apps/browser-extension/package.json+++ b/apps/browser-extension/package.json@@ -34,6 +34,7 @@"@dnd-kit/utilities": "^3.2.2","@hookform/resolvers": "^5.1.1","@types/dompurify": "^3.0.5",+ "@webext-core/messaging": "^3.0.1","argon2-browser": "^1.18.0","buffer": "^6.0.3","dompurify": "^3.4.0",@@ -49,7 +50,6 @@"secure-remote-password": "github:LinusU/secure-remote-password#73e5f732b6ca0cdbdc19da1a0c5f48cdbad2cbf0","sql.js": "^1.12.0","vitest": "^3.0.8",- "webext-bridge": "^6.0.1","yup": "^1.6.1"},"devDependencies": {diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.tsindex 04a87a039..c5dfc24dd 100644--- a/apps/browser-extension/src/entrypoints/background.ts+++ b/apps/browser-extension/src/entrypoints/background.ts@@ -2,8 +2,6 @@* Background script entry point - handles messages from the content script*/-import { onMessage, sendMessage } from "webext-bridge/background";-import { handleResetAutoLockTimer, handlePopupHeartbeat, handleSetAutoLockTimeout, initializeAutoLockAlarm, handleAutoLockAlarm } from '@/entrypoints/background/AutolockTimeoutHandler';import { handleClipboardCopied, handleCancelClipboardClear, handleGetClipboardClearTimeout, handleSetClipboardClearTimeout, handleGetClipboardCountdownState } from '@/entrypoints/background/ClipboardClearHandler';import { setupContextMenus } from '@/entrypoints/background/ContextMenu';@@ -13,10 +11,8 @@ import { handleStoreSavePromptState, handleGetSavePromptState, handleClearSavePrimport { handleStoreTwoFactorState, handleGetTwoFactorState, handleClearTwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleCreateItem, handleGetFilteredItems, handleGetSearchItems, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGetPersistedFormValues, handleGetVault, handlePersistFormValues, handleStoreEncryptionKey, handleStoreEncryptionKeyDerivationParams, handleStoreVaultMetadata, handleSyncVault, handleUploadVault, handleGetEncryptedVault, handleStoreEncryptedVault, handleGetSyncState, handleMarkVaultClean, handleGetServerRevision, handleCheckSyncStatus, handleFullVaultSync, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleSetLoginSaveEnabled, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpSecrets, handleGenerateTotpCode, handleSetRecentlySelected, handleGetRecentlySelected } from '@/entrypoints/background/VaultMessageHandler';-import { EncryptionKeyDerivationParams } from "@/utils/dist/core/models/metadata";-import type { LoginResponse } from "@/utils/dist/core/models/webapi";import { LocalPreferencesService } from '@/utils/LocalPreferencesService';-import type { SavePromptPersistedState, LastAutofilledCredential } from "@/utils/loginDetector";+import { onMessage, sendMessage } from "@/utils/messaging/ExtensionMessaging";import { defineBackground, browser } from '#imports';@@ -60,34 +56,34 @@ export default defineBackground({});const elementIdentifier = results[0]?.result;if (elementIdentifier) {- sendMessage('OPEN_AUTOFILL_POPUP', { elementIdentifier }, `content-script@${tab.id}`);+ sendMessage('OPEN_AUTOFILL_POPUP', { elementIdentifier }, tab.id);}} catch (error) {console.error('Error handling show-autofill-popup command:', error);}});- // Listen for messages using webext-bridge+ // Listen for messages via @webext-core/messagingonMessage('CHECK_AUTH_STATUS', () => handleCheckAuthStatus());onMessage('GET_ENCRYPTION_KEY', () => handleGetEncryptionKey());onMessage('GET_ENCRYPTION_KEY_DERIVATION_PARAMS', () => handleGetEncryptionKeyDerivationParams());onMessage('GET_VAULT', () => handleGetVault());- onMessage('GET_FILTERED_ITEMS', ({ data }) => handleGetFilteredItems(data as { currentUrl: string, pageTitle: string, matchingMode?: string, includeRecentlySelected?: boolean }));- onMessage('GET_SEARCH_ITEMS', ({ data }) => handleGetSearchItems(data as { searchTerm: string }));+ onMessage('GET_FILTERED_ITEMS', ({ data }) => handleGetFilteredItems(data));+ onMessage('GET_SEARCH_ITEMS', ({ data }) => handleGetSearchItems(data));onMessage('GET_DEFAULT_EMAIL_DOMAIN', () => handleGetDefaultEmailDomain());onMessage('GET_DEFAULT_IDENTITY_SETTINGS', () => handleGetDefaultIdentitySettings());onMessage('GET_PASSWORD_SETTINGS', () => handleGetPasswordSettings());- onMessage('STORE_VAULT_METADATA', ({ data }) => handleStoreVaultMetadata(data as { publicEmailDomainList?: string[]; privateEmailDomainList?: string[]; hiddenPrivateEmailDomainList?: string[] }));- onMessage('STORE_ENCRYPTION_KEY', ({ data }) => handleStoreEncryptionKey(data as string));- onMessage('STORE_ENCRYPTION_KEY_DERIVATION_PARAMS', ({ data }) => handleStoreEncryptionKeyDerivationParams(data as EncryptionKeyDerivationParams));+ onMessage('STORE_VAULT_METADATA', ({ data }) => handleStoreVaultMetadata(data));+ onMessage('STORE_ENCRYPTION_KEY', ({ data }) => handleStoreEncryptionKey(data));+ onMessage('STORE_ENCRYPTION_KEY_DERIVATION_PARAMS', ({ data }) => handleStoreEncryptionKeyDerivationParams(data));onMessage('GET_ENCRYPTED_VAULT', () => handleGetEncryptedVault());- onMessage('STORE_ENCRYPTED_VAULT', ({ data }) => handleStoreEncryptedVault(data as { vaultBlob: string; markDirty?: boolean; serverRevision?: number; expectedMutationSeq?: number }));+ onMessage('STORE_ENCRYPTED_VAULT', ({ data }) => handleStoreEncryptedVault(data));onMessage('GET_SYNC_STATE', () => handleGetSyncState());- onMessage('MARK_VAULT_CLEAN', ({ data }) => handleMarkVaultClean(data as { mutationSeqAtStart: number; newServerRevision: number }));+ onMessage('MARK_VAULT_CLEAN', ({ data }) => handleMarkVaultClean(data));onMessage('GET_SERVER_REVISION', () => handleGetServerRevision());onMessage('CREATE_ITEM', ({ data }) => handleCreateItem(data));@@ -109,35 +105,35 @@ export default defineBackground({onMessage('CLEAR_PERSISTED_FORM_VALUES', () => handleClearPersistedFormValues());// Remember login save messages- onMessage('CHECK_LOGIN_DUPLICATE', ({ data }) => handleCheckLoginDuplicate(data as { domain: string; username: string }));- onMessage('SAVE_LOGIN_CREDENTIAL', ({ data }) => handleSaveLoginCredential(data as { serviceName: string; username: string; password: string; url: string; domain: string; logoBase64?: string }));- onMessage('ADD_URL_TO_CREDENTIAL', ({ data }) => handleAddUrlToCredential(data as { itemId: string; url: string }));- onMessage('IS_URL_LINKED_TO_CREDENTIAL', ({ data }) => handleIsUrlLinkedToCredential(data as { itemId: string; url: string }));+ onMessage('CHECK_LOGIN_DUPLICATE', ({ data }) => handleCheckLoginDuplicate(data));+ onMessage('SAVE_LOGIN_CREDENTIAL', ({ data }) => handleSaveLoginCredential(data));+ onMessage('ADD_URL_TO_CREDENTIAL', ({ data }) => handleAddUrlToCredential(data));+ onMessage('IS_URL_LINKED_TO_CREDENTIAL', ({ data }) => handleIsUrlLinkedToCredential(data));onMessage('GET_LOGIN_SAVE_SETTINGS', () => handleGetLoginSaveSettings());- onMessage('SET_LOGIN_SAVE_ENABLED', ({ data }) => handleSetLoginSaveEnabled(data as boolean));+ onMessage('SET_LOGIN_SAVE_ENABLED', ({ data }) => handleSetLoginSaveEnabled(data));// TOTP autofill messages- onMessage('GET_ITEMS_WITH_TOTP', ({ data }) => handleGetItemsWithTotp(data as { currentUrl: string, pageTitle: string, matchingMode?: string }));- onMessage('SEARCH_ITEMS_WITH_TOTP', ({ data }) => handleSearchItemsWithTotp(data as { searchTerm: string }));- onMessage('GET_TOTP_SECRETS', ({ data }) => handleGetTotpSecrets(data as { itemIds: string[] }));- onMessage('GENERATE_TOTP_CODE', ({ data }) => handleGenerateTotpCode(data as { itemId: string }));+ onMessage('GET_ITEMS_WITH_TOTP', ({ data }) => handleGetItemsWithTotp(data));+ onMessage('SEARCH_ITEMS_WITH_TOTP', ({ data }) => handleSearchItemsWithTotp(data));+ onMessage('GET_TOTP_SECRETS', ({ data }) => handleGetTotpSecrets(data));+ onMessage('GENERATE_TOTP_CODE', ({ data }) => handleGenerateTotpCode(data));// Track recently selected items for autofill prioritization- onMessage('SET_RECENTLY_SELECTED', ({ data }) => handleSetRecentlySelected(data as { itemId: string; domain: string }));- onMessage('GET_RECENTLY_SELECTED', ({ data }) => handleGetRecentlySelected(data as { domain: string }));+ onMessage('SET_RECENTLY_SELECTED', ({ data }) => handleSetRecentlySelected(data));+ onMessage('GET_RECENTLY_SELECTED', ({ data }) => handleGetRecentlySelected(data));// Remember login save state (for surviving page navigation)- onMessage('STORE_SAVE_PROMPT_STATE', ({ data, sender }) => handleStoreSavePromptState({ tabId: sender.tabId!, state: data as SavePromptPersistedState }));- onMessage('GET_SAVE_PROMPT_STATE', ({ sender }) => handleGetSavePromptState({ tabId: sender.tabId! }));- onMessage('CLEAR_SAVE_PROMPT_STATE', ({ sender }) => handleClearSavePromptState({ tabId: sender.tabId! }));+ onMessage('STORE_SAVE_PROMPT_STATE', ({ data, sender }) => handleStoreSavePromptState({ tabId: sender.tab!.id!, state: data }));+ onMessage('GET_SAVE_PROMPT_STATE', ({ sender }) => handleGetSavePromptState({ tabId: sender.tab!.id! }));+ onMessage('CLEAR_SAVE_PROMPT_STATE', ({ sender }) => handleClearSavePromptState({ tabId: sender.tab!.id! }));// Track last autofilled credential (for "Add URL to existing credential" prompt)- onMessage('STORE_LAST_AUTOFILLED', ({ data, sender }) => handleStoreLastAutofilled({ tabId: sender.tabId!, credential: data as LastAutofilledCredential }));- onMessage('GET_LAST_AUTOFILLED', ({ data, sender }) => handleGetLastAutofilled({ tabId: sender.tabId!, ...(data as { domain?: string; username?: string }) }));- onMessage('CLEAR_LAST_AUTOFILLED', ({ sender }) => handleClearLastAutofilled({ tabId: sender.tabId! }));+ onMessage('STORE_LAST_AUTOFILLED', ({ data, sender }) => handleStoreLastAutofilled({ tabId: sender.tab!.id!, credential: data }));+ onMessage('GET_LAST_AUTOFILLED', ({ data, sender }) => handleGetLastAutofilled({ tabId: sender.tab!.id!, ...data }));+ onMessage('CLEAR_LAST_AUTOFILLED', ({ sender }) => handleClearLastAutofilled({ tabId: sender.tab!.id! }));// Two-factor authentication state persistence- onMessage('STORE_TWO_FACTOR_STATE', ({ data }) => handleStoreTwoFactorState(data as { username: string; loginResponse: LoginResponse; passwordHashString: string; passwordHashBase64: string; rememberMe: boolean }));+ onMessage('STORE_TWO_FACTOR_STATE', ({ data }) => handleStoreTwoFactorState(data));onMessage('GET_TWO_FACTOR_STATE', () => handleGetTwoFactorState());onMessage('CLEAR_TWO_FACTOR_STATE', () => handleClearTwoFactorState());@@ -145,12 +141,12 @@ export default defineBackground({onMessage('CLIPBOARD_COPIED', () => handleClipboardCopied());onMessage('CANCEL_CLIPBOARD_CLEAR', () => handleCancelClipboardClear());onMessage('GET_CLIPBOARD_CLEAR_TIMEOUT', () => handleGetClipboardClearTimeout());- onMessage('SET_CLIPBOARD_CLEAR_TIMEOUT', ({ data }) => handleSetClipboardClearTimeout(data as number));+ onMessage('SET_CLIPBOARD_CLEAR_TIMEOUT', ({ data }) => handleSetClipboardClearTimeout(data));onMessage('GET_CLIPBOARD_COUNTDOWN_STATE', () => handleGetClipboardCountdownState());// Auto-lock management messagesonMessage('RESET_AUTO_LOCK_TIMER', () => handleResetAutoLockTimer());- onMessage('SET_AUTO_LOCK_TIMEOUT', ({ data }) => handleSetAutoLockTimeout(data as number));+ onMessage('SET_AUTO_LOCK_TIMEOUT', ({ data }) => handleSetAutoLockTimeout(data));onMessage('POPUP_HEARTBEAT', () => handlePopupHeartbeat());// Handle clipboard copied from context menudiff --git a/apps/browser-extension/src/entrypoints/background/ClipboardClearHandler.ts b/apps/browser-extension/src/entrypoints/background/ClipboardClearHandler.tsindex 879d78e5b..6cc3c6dc4 100644--- a/apps/browser-extension/src/entrypoints/background/ClipboardClearHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/ClipboardClearHandler.ts@@ -1,6 +1,5 @@-import { sendMessage } from 'webext-bridge/background';-import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';let clipboardClearTimer: NodeJS.Timeout | null = null;let countdownInterval: NodeJS.Timeout | null = null;@@ -107,7 +106,7 @@ export async function handleClipboardCopied() : Promise<void> {remainingTime = timeout;// Send initial countdown immediately with ID- sendMessage('CLIPBOARD_COUNTDOWN', { remaining: remainingTime, total: timeout, id: thisCountdownId }, 'popup').catch(() => {});+ sendMessage('CLIPBOARD_COUNTDOWN', { remaining: remainingTime, total: timeout, id: thisCountdownId }).catch(() => {});// Send countdown updates to popup every 100ms for smooth animationlet elapsed = 0;@@ -122,7 +121,7 @@ export async function handleClipboardCopied() : Promise<void> {elapsed += 0.1;remainingTime = Math.max(0, timeout - elapsed);- sendMessage('CLIPBOARD_COUNTDOWN', { remaining: remainingTime, total: timeout, id: thisCountdownId }, 'popup').catch(() => {});+ sendMessage('CLIPBOARD_COUNTDOWN', { remaining: remainingTime, total: timeout, id: thisCountdownId }).catch(() => {});if (elapsed >= timeout && countdownInterval) {clearInterval(countdownInterval);@@ -148,7 +147,7 @@ export async function handleClipboardCopied() : Promise<void> {countdownStartTime = 0;totalCountdownTime = 0;- sendMessage('CLIPBOARD_CLEARED', {}, 'popup').catch(() => {});+ sendMessage('CLIPBOARD_CLEARED', {}).catch(() => {});} catch (error) {console.error('[CLIPBOARD] Error during clipboard clear:', error);@@ -161,7 +160,7 @@ export async function handleClipboardCopied() : Promise<void> {currentCountdownId = 0;countdownStartTime = 0;totalCountdownTime = 0;- sendMessage('CLIPBOARD_CLEARED', {}, 'popup').catch(() => {});+ sendMessage('CLIPBOARD_CLEARED', {}).catch(() => {});}}, timeout * 1000);}@@ -178,7 +177,7 @@ export function handleCancelClipboardClear(): void {clearInterval(countdownInterval);countdownInterval = null;}- sendMessage('CLIPBOARD_COUNTDOWN_CANCELLED', {}, 'popup').catch(() => {});+ sendMessage('CLIPBOARD_COUNTDOWN_CANCELLED', {}).catch(() => {});}/**diff --git a/apps/browser-extension/src/entrypoints/background/ContextMenu.ts b/apps/browser-extension/src/entrypoints/background/ContextMenu.tsindex ab93f02ab..8b3255a1e 100644--- a/apps/browser-extension/src/entrypoints/background/ContextMenu.ts+++ b/apps/browser-extension/src/entrypoints/background/ContextMenu.ts@@ -1,8 +1,8 @@import { type Browser } from '@wxt-dev/browser';-import { sendMessage } from 'webext-bridge/background';import { POPUP_TYPES, type PopupType, isPopupType } from '@/utils/autofill/PopupTypes';import { PasswordGenerator } from '@/utils/dist/core/password-generator';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { t } from '@/i18n/StandaloneI18n';@@ -138,7 +138,7 @@ export function handleContextMenuClick(info: Browser.contextMenus.OnClickData, tconst elementIdentifier = results[0]?.result;if (elementIdentifier) {// Send message to content script with proper tab targeting- sendMessage('OPEN_AUTOFILL_POPUP', { elementIdentifier, popupType }, `content-script@${tab.id}`);+ sendMessage('OPEN_AUTOFILL_POPUP', { elementIdentifier, popupType }, tab.id);}});}diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.tsindex d7c516189..64b506596 100644--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts@@ -266,11 +266,6 @@ export async function handleGetVault(* This preserves local vault data so user can unlock again without server.*/export async function handleLockVault(): Promise<messageBoolResponse> {- /*- * Clear session-only data (locks the vault). Must be awaited so callers can- * safely navigate away — otherwise the popup can race past the removal while- * `session:encryptionKey` is still set, leaving stale state in storage watchers.- */await storage.removeItems(['session:encryptionKey','session:persistedFormValues',diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.tsindex 2ae248de6..0bff91897 100644--- a/apps/browser-extension/src/entrypoints/content.ts+++ b/apps/browser-extension/src/entrypoints/content.ts@@ -3,8 +3,6 @@*/import '@/entrypoints/contentScript/style.css';-import { onMessage, sendMessage } from "webext-bridge/content-script";-import { injectIcon, popupDebounceTimeHasPassed, validateInputField } from '@/entrypoints/contentScript/Form';import { openAutofillPopup, openTotpPopup, removeExistingPopup, createUpgradeRequiredPopup } from '@/entrypoints/contentScript/Popup';import { showSavePrompt, showAddUrlPrompt, isSavePromptVisible, updateSavePromptLogin, getPersistedSavePromptState, restoreSavePromptFromState, restoreAddUrlPromptFromState } from '@/entrypoints/contentScript/SavePrompt';@@ -14,8 +12,8 @@ import { DEFAULT_POPUP_TYPE, isPopupType, popupTypeForFieldType, POPUP_TYPES, tyimport { FormDetector } from '@/utils/formDetector/FormDetector';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';import { LoginDetector } from '@/utils/loginDetector';-import type { CapturedLogin, LastAutofilledCredential } from '@/utils/loginDetector';-import { BoolResponse as messageBoolResponse } from '@/utils/types/messaging/BoolResponse';+import type { CapturedLogin } from '@/utils/loginDetector';+import { onMessage, sendMessage } from '@/utils/messaging/ExtensionMessaging';import { t } from '@/i18n/StandaloneI18n';@@ -62,14 +60,14 @@ async function handleSaveLogin(login: CapturedLogin, serviceName: string): Promiurl: login.url,domain: login.domain,faviconUrl: login.faviconUrl,- }, 'background') as { success: boolean; itemId?: string; error?: string };+ });if (!response.success) {console.error('[AliasVault] Failed to save login:', response.error);}// Clear the last autofilled state after save- await sendMessage('CLEAR_LAST_AUTOFILLED', {}, 'background');+ await sendMessage('CLEAR_LAST_AUTOFILLED');} catch (error) {console.error('[AliasVault] Error saving login:', error);}@@ -97,7 +95,7 @@ async function handleNeverSaveForDomain(domain: string): Promise<void> {*/async function handleSavePromptDismiss(): Promise<void> {// Clear the last autofilled state on dismiss- await sendMessage('CLEAR_LAST_AUTOFILLED', {}, 'background');+ await sendMessage('CLEAR_LAST_AUTOFILLED');}/**@@ -110,14 +108,14 @@ async function handleAddUrlToCredential(itemId: string, url: string): Promise<voconst response = await sendMessage('ADD_URL_TO_CREDENTIAL', {itemId,url,- }, 'background') as { success: boolean; error?: string };+ });if (!response.success) {console.error('[AliasVault] Failed to add URL to credential:', response.error);}// Clear the last autofilled state after successful add- await sendMessage('CLEAR_LAST_AUTOFILLED', {}, 'background');+ await sendMessage('CLEAR_LAST_AUTOFILLED');} catch (error) {console.error('[AliasVault] Error adding URL to credential:', error);}@@ -129,11 +127,7 @@ async function handleAddUrlToCredential(itemId: string, url: string): Promise<vo*/async function isLoginSaveEnabled(): Promise<boolean> {try {- const response = await sendMessage('GET_LOGIN_SAVE_SETTINGS', {}, 'background') as {- success: boolean;- enabled: boolean;- autoDismissSeconds: number;- };+ const response = await sendMessage('GET_LOGIN_SAVE_SETTINGS');return response.success && response.enabled;} catch {return false;@@ -165,7 +159,7 @@ async function isLoginDuplicate(domain: string, username: string): Promise<booleconst response = await sendMessage('CHECK_LOGIN_DUPLICATE', {domain,username,- }, 'background') as { success: boolean; isDuplicate: boolean };+ });return response.success && response.isDuplicate;} catch {return false;@@ -206,10 +200,7 @@ async function checkAndRestoreSavePromptEarly(ctx: Parameters<typeof createShado// Check if vault is still unlockedtry {- const authStatus = await sendMessage('CHECK_AUTH_STATUS', {}, 'background') as {- isLoggedIn: boolean;- isVaultLocked: boolean;- };+ const authStatus = await sendMessage('CHECK_AUTH_STATUS');if (!authStatus.isLoggedIn || authStatus.isVaultLocked) {return;}@@ -299,10 +290,7 @@ async function checkAndRestorePersistedSavePrompt(container: HTMLElement): Promi// Check if vault is still unlockedtry {- const authStatus = await sendMessage('CHECK_AUTH_STATUS', {}, 'background') as {- isLoggedIn: boolean;- isVaultLocked: boolean;- };+ const authStatus = await sendMessage('CHECK_AUTH_STATUS');if (!authStatus.isLoggedIn || authStatus.isVaultLocked) {return;}@@ -359,10 +347,7 @@ function initializeLoginDetector(container: HTMLElement): void {// Check if vault is lockedtry {- const authStatus = await sendMessage('CHECK_AUTH_STATUS', {}, 'background') as {- isLoggedIn: boolean;- isVaultLocked: boolean;- };+ const authStatus = await sendMessage('CHECK_AUTH_STATUS');if (!authStatus.isLoggedIn || authStatus.isVaultLocked) {return;}@@ -389,10 +374,7 @@ function initializeLoginDetector(container: HTMLElement): void {// Get auto-dismiss settingslet autoDismissMs = 15000;try {- const settings = await sendMessage('GET_LOGIN_SAVE_SETTINGS', {}, 'background') as {- success: boolean;- autoDismissSeconds: number;- };+ const settings = await sendMessage('GET_LOGIN_SAVE_SETTINGS');if (settings.success) {autoDismissMs = settings.autoDismissSeconds * 1000;}@@ -408,7 +390,7 @@ function initializeLoginDetector(container: HTMLElement): void {const lastAutofilledResponse = await sendMessage('GET_LAST_AUTOFILLED', {domain: login.domain,username: login.username,- }, 'background') as { success: boolean; credential: LastAutofilledCredential | null };+ });if (lastAutofilledResponse.success && lastAutofilledResponse.credential) {/*@@ -417,7 +399,7 @@ function initializeLoginDetector(container: HTMLElement): void {const linkCheck = await sendMessage('IS_URL_LINKED_TO_CREDENTIAL', {itemId: lastAutofilledResponse.credential.itemId,url: login.url,- }, 'background') as { linked: boolean };+ });if (!linkCheck.linked) {// Current URL is not linked to the existing credential, show the prompt.@@ -585,8 +567,7 @@ export default defineContentScript({void checkAndRestorePersistedSavePrompt(container);// Listen for messages from the background script- onMessage('OPEN_AUTOFILL_POPUP', async (message: { data: { elementIdentifier: string; popupType?: string } }) : Promise<messageBoolResponse> => {- const { data } = message;+ onMessage('OPEN_AUTOFILL_POPUP', async ({ data }) => {const { elementIdentifier, popupType } = data;if (!elementIdentifier) {@@ -676,13 +657,7 @@ export default defineContentScript({async function showPopupWithAuthCheck(inputElement: HTMLInputElement, container: HTMLElement, popupType: PopupType = DEFAULT_POPUP_TYPE, forceShow: boolean = false) : Promise<void> {try {// Check auth status and pending migrations in a single call- const { sendMessage } = await import('webext-bridge/content-script');- const authStatus = await sendMessage('CHECK_AUTH_STATUS', {}, 'background') as {- isLoggedIn: boolean,- isVaultLocked: boolean,- hasPendingMigrations: boolean,- error?: string- };+ const authStatus = await sendMessage('CHECK_AUTH_STATUS');if (authStatus.isVaultLocked) {// Check if the user has dismissed the vault locked popupdiff --git a/apps/browser-extension/src/entrypoints/contentScript/Form.ts b/apps/browser-extension/src/entrypoints/contentScript/Form.tsindex 89d5cf0cf..1e1d302bf 100644--- a/apps/browser-extension/src/entrypoints/contentScript/Form.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/Form.ts@@ -1,5 +1,3 @@-import { sendMessage } from 'webext-bridge/content-script';-import { openAutofillPopup, openTotpPopup, removeExistingPopup } from '@/entrypoints/contentScript/Popup';import { LOGO_MARK_SVG } from '@/utils/constants/logo';@@ -10,6 +8,7 @@ import { FormFiller } from '@/utils/formDetector/FormFiller';import { DetectedFieldType } from '@/utils/formDetector/types/FormFields';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';import type { LastAutofilledCredential } from '@/utils/loginDetector';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { ClickValidator } from '@/utils/security/ClickValidator';import { SqliteClient } from '@/utils/SqliteClient';@@ -102,7 +101,7 @@ export async function fillItem(item: Item, input: HTMLInputElement): Promise<voihidePopupFor(300);// Reset auto-lock timer when autofilling- sendMessage('RESET_AUTO_LOCK_TIMER', {}, 'background').catch(() => {+ sendMessage('RESET_AUTO_LOCK_TIMER').catch(() => {// Ignore errors as background script might not be ready});@@ -137,12 +136,12 @@ export async function fillItem(item: Item, input: HTMLInputElement): Promise<voifaviconUrl: faviconUrl ?? undefined,};- sendMessage('STORE_LAST_AUTOFILLED', lastAutofilled, 'background').catch(() => {+ sendMessage('STORE_LAST_AUTOFILLED', lastAutofilled).catch(() => {// Ignore errors as background script might not be ready});// Store recently selected item for smart autofill prioritization- sendMessage('SET_RECENTLY_SELECTED', { itemId: item.Id, domain: window.location.hostname }, 'background').catch(() => {+ sendMessage('SET_RECENTLY_SELECTED', { itemId: item.Id, domain: window.location.hostname }).catch(() => {// Ignore errors as background script might not be ready});@@ -151,18 +150,14 @@ export async function fillItem(item: Item, input: HTMLInputElement): Promise<voiif (autoCopyTotpEnabled) {try {// Generate TOTP code via background- const response = await sendMessage('GENERATE_TOTP_CODE', { itemId: item.Id }, 'background') as {- success: boolean;- code?: string;- error?: string;- };+ const response = await sendMessage('GENERATE_TOTP_CODE', { itemId: item.Id });if (response.success && response.code) {// Copy TOTP code to clipboardawait navigator.clipboard.writeText(response.code);// Notify background script that clipboard was copied to start countdown- sendMessage('CLIPBOARD_COPIED', { value: response.code }, 'background').catch(() => {+ sendMessage('CLIPBOARD_COPIED').catch(() => {// Ignore errors as background script might not be ready});}@@ -436,16 +431,12 @@ export async function fillTotpCode(itemId: string, input: HTMLInputElement): ProhidePopupFor(300);// Reset auto-lock timer when autofilling- sendMessage('RESET_AUTO_LOCK_TIMER', {}, 'background').catch(() => {+ sendMessage('RESET_AUTO_LOCK_TIMER').catch(() => {// Ignore errors as background script might not be ready});// Generate TOTP code via background- const response = await sendMessage('GENERATE_TOTP_CODE', { itemId }, 'background') as {- success: boolean;- code?: string;- error?: string;- };+ const response = await sendMessage('GENERATE_TOTP_CODE', { itemId });if (!response.success || !response.code) {console.error('Failed to generate TOTP code:', response.error);@@ -459,7 +450,7 @@ export async function fillTotpCode(itemId: string, input: HTMLInputElement): ProtriggerInputEvents(input);// Store recently selected item for smart autofill prioritization- sendMessage('SET_RECENTLY_SELECTED', { itemId, domain: window.location.hostname }, 'background').catch(() => {+ sendMessage('SET_RECENTLY_SELECTED', { itemId, domain: window.location.hostname }).catch(() => {// Ignore errors as background script might not be ready});}diff --git a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts b/apps/browser-extension/src/entrypoints/contentScript/Popup.tsindex 57660013c..7d19b3f99 100644--- a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts@@ -1,5 +1,4 @@import * as OTPAuth from 'otpauth';-import { sendMessage } from 'webext-bridge/content-script';import { fillItem, fillTotpCode } from '@/entrypoints/contentScript/Form';@@ -10,14 +9,11 @@ import { ItemTypes, FieldKey, createSystemField } from '@/utils/dist/core/modelsimport { CreatePasswordGenerator, PasswordGenerator, PasswordSettings } from '@/utils/dist/core/password-generator';import { getAllFaviconLinks } from '@/utils/favicon';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { sliderToLength, lengthToSlider, SLIDER_MIN, SLIDER_MAX } from '@/utils/passwordLengthSlider';import { ClickValidator } from '@/utils/security/ClickValidator';import { ServiceDetectionUtility } from '@/utils/serviceDetection/ServiceDetectionUtility';import { SqliteClient } from '@/utils/SqliteClient';-import { IdentitySettingsResponse } from '@/utils/types/messaging/IdentitySettingsResponse';-import { ItemsResponse } from '@/utils/types/messaging/ItemsResponse';-import { PasswordSettingsResponse } from '@/utils/types/messaging/PasswordSettingsResponse';-import { StringResponse } from '@/utils/types/messaging/StringResponse';import { t } from '@/i18n/StandaloneI18n';@@ -138,7 +134,7 @@ export function openAutofillPopup(input: HTMLInputElement, container: HTMLElemenpageTitle: document.title,matchingMode: matchingMode,includeRecentlySelected: true // Enable for multi-step login autofill- }, 'background') as ItemsResponse;+ });if (response.success) {await createAutofillPopup(input, response.items, container, response.recentlySelectedId);@@ -187,7 +183,7 @@ export function openTotpPopup(input: HTMLInputElement, container: HTMLElement, fcurrentUrl: window.location.href,pageTitle: document.title,matchingMode: matchingMode- }, 'background') as ItemsResponse;+ });if (response.success) {await createTotpPopup(input, response.items, container, response.recentlySelectedId);@@ -265,7 +261,7 @@ async function createTotpPopup(input: HTMLInputElement, items: Item[] | undefine// Search in TOTP items onlyconst response = await sendMessage('SEARCH_ITEMS_WITH_TOTP', {searchTerm: searchTerm- }, 'background') as ItemsResponse;+ });if (response.success && response.items) {// Search results don't carry prioritization, so don't highlight any item@@ -425,11 +421,7 @@ function updateTotpPopupContent(items: Item[], itemList: HTMLElement | null, inp// Fetch TOTP secrets and create items with live codes(async (): Promise<void> => {const itemIds = items.map(item => item.Id);- const secretsResponse = await sendMessage('GET_TOTP_SECRETS', { itemIds }, 'background') as {- success: boolean;- secrets?: Record<string, string>;- error?: string;- };+ const secretsResponse = await sendMessage('GET_TOTP_SECRETS', { itemIds });const secrets = secretsResponse.success && secretsResponse.secrets ? secretsResponse.secrets : {};const hasSecrets = Object.keys(secrets).length > 0;@@ -611,7 +603,7 @@ function createTotpItem(addReliableClickHandler(popoutIcon, (e) => {e.stopPropagation();- sendMessage('OPEN_POPUP_WITH_ITEM', { itemId: item.Id }, 'background');+ sendMessage('OPEN_POPUP_WITH_ITEM', { itemId: item.Id });removeExistingPopup(rootContainer);});@@ -843,10 +835,10 @@ export async function createAutofillPopup(input: HTMLInputElement, items: Item[]try {// Sync with api to ensure we have the latest vault.- await sendMessage('SYNC_VAULT', {}, 'background');+ await sendMessage('SYNC_VAULT');// Retrieve default email domain from background- const response = await sendMessage('GET_DEFAULT_EMAIL_DOMAIN', {}, 'background') as StringResponse;+ const response = await sendMessage('GET_DEFAULT_EMAIL_DOMAIN');const domain = response.value;let newItem: Item;@@ -883,12 +875,12 @@ export async function createAutofillPopup(input: HTMLInputElement, items: Item[]};} else {// Generate new random identity using identity generator.- const identitySettings = await sendMessage('GET_DEFAULT_IDENTITY_SETTINGS', {}, 'background') as IdentitySettingsResponse;+ const identitySettings = await sendMessage('GET_DEFAULT_IDENTITY_SETTINGS');const identityGenerator = CreateIdentityGenerator(identitySettings.settings?.language ?? 'en');const identity = identityGenerator.generateRandomIdentity(identitySettings.settings?.gender);// Get password settings from background- const passwordSettingsResponse = await sendMessage('GET_PASSWORD_SETTINGS', {}, 'background') as PasswordSettingsResponse;+ const passwordSettingsResponse = await sendMessage('GET_PASSWORD_SETTINGS');// Initialize password generator with the retrieved settingsconst passwordGenerator = CreatePasswordGenerator(passwordSettingsResponse.settings ?? {@@ -931,7 +923,7 @@ export async function createAutofillPopup(input: HTMLInputElement, items: Item[]// Create item in background.const createResponse = await sendMessage('CREATE_ITEM', {item: JSON.parse(JSON.stringify(newItem))- }, 'background') as { success: boolean; error?: string };+ });// Check if item creation succeededif (!createResponse.success) {@@ -1096,7 +1088,7 @@ export async function createVaultLockedPopup(input: HTMLInputElement, rootContai* Handle unlock click.*/const handleUnlockClick = () : void => {- sendMessage('OPEN_POPUP', {}, 'background');+ sendMessage('OPEN_POPUP');removeExistingPopup(rootContainer);}@@ -1209,7 +1201,7 @@ async function handleSearchInput(searchInput: HTMLInputElement, initialItems: It// Search in full vault with search termconst response = await sendMessage('GET_SEARCH_ITEMS', {searchTerm: searchTerm- }, 'background') as ItemsResponse;+ });if (response.success && response.items) {// Search results don't carry prioritization, so don't highlight any item@@ -1340,7 +1332,7 @@ function createItemList(items: Item[], input: HTMLInputElement, rootContainer: H// Handle popout click with security validationaddReliableClickHandler(popoutIcon, (e) => {e.stopPropagation(); // Prevent item fill- sendMessage('OPEN_POPUP_WITH_ITEM', { itemId: item.Id }, 'background');+ sendMessage('OPEN_POPUP_WITH_ITEM', { itemId: item.Id });removeExistingPopup(rootContainer);});@@ -1709,7 +1701,7 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConsendMessage('OPEN_POPUP_CREATE_CREDENTIAL', {serviceName: serviceName || encodedServiceInfo.serviceName,currentUrl: encodedServiceInfo.currentUrl- }, 'background');+ });closePopup(null);});@@ -1790,8 +1782,7 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConUseNonAmbiguousChars: true};- sendMessage('GET_PASSWORD_SETTINGS', {}, 'background').then((response) => {- const passwordSettingsResponse = response as PasswordSettingsResponse;+ sendMessage('GET_PASSWORD_SETTINGS').then((passwordSettingsResponse) => {currentPasswordSettings = passwordSettingsResponse.settings ?? currentPasswordSettings;passwordGenerator = CreatePasswordGenerator(currentPasswordSettings);@@ -2427,7 +2418,7 @@ async function resizeImage(imageData: Uint8Array, contentType: string, targetWid*/export async function dismissVaultLockedPopup(): Promise<void> {// First check if user is logged in or not.- const authStatus = await sendMessage('CHECK_AUTH_STATUS', {}, 'background') as { isLoggedIn: boolean, isVaultLocked: boolean };+ const authStatus = await sendMessage('CHECK_AUTH_STATUS');if (authStatus.isLoggedIn) {// User is logged in - dismiss for 4 hours@@ -2527,7 +2518,7 @@ export async function createUpgradeRequiredPopup(input: HTMLInputElement, rootCo* Handle upgrade click.*/const handleUpgradeClick = () : void => {- sendMessage('OPEN_POPUP', {}, 'background');+ sendMessage('OPEN_POPUP');removeExistingPopup(rootContainer);}diff --git a/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts b/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.tsindex ba1b9249b..57d88b5f3 100644--- a/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/SavePrompt.ts@@ -3,10 +3,9 @@* Displays a non-intrusive banner at the top of the page when credentials are detected.*/-import { sendMessage } from 'webext-bridge/content-script';-import { getLogoMarkSvg } from '@/utils/constants/logo';import type { CapturedLogin, SavePromptOptions, SavePromptPersistedState, AddUrlPromptOptions, LastAutofilledCredential } from '@/utils/loginDetector';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { t } from '@/i18n/StandaloneI18n';@@ -735,7 +734,7 @@ async function persistSavePromptState(): Promise<void> {};try {- await sendMessage('STORE_SAVE_PROMPT_STATE', state, 'background');+ await sendMessage('STORE_SAVE_PROMPT_STATE', state);} catch (error) {console.error('[AliasVault] Error persisting save prompt state:', error);}@@ -756,10 +755,7 @@ function handleBeforeUnload(): void {*/export async function getPersistedSavePromptState(): Promise<SavePromptPersistedState | null> {try {- const response = await sendMessage('GET_SAVE_PROMPT_STATE', {}, 'background') as {- success: boolean;- state: SavePromptPersistedState | null;- };+ const response = await sendMessage('GET_SAVE_PROMPT_STATE');if (!response.success || !response.state) {return null;@@ -802,7 +798,7 @@ export async function getPersistedSavePromptState(): Promise<SavePromptPersisted*/export async function clearPersistedSavePromptState(): Promise<void> {try {- await sendMessage('CLEAR_SAVE_PROMPT_STATE', {}, 'background');+ await sendMessage('CLEAR_SAVE_PROMPT_STATE');} catch (error) {console.error('[AliasVault] Error clearing persisted save prompt state:', error);}diff --git a/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.ts b/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.tsindex 1cce582ae..cec74d854 100644--- a/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/WebAuthnInterceptor.ts@@ -4,9 +4,7 @@/* eslint-disable @typescript-eslint/no-explicit-any */-import { sendMessage } from 'webext-bridge/content-script';--import type { WebAuthnSettingsResponse } from '@/utils/passkey/types';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { browser } from '#imports';@@ -126,7 +124,7 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {const result = await sendMessage('WEBAUTHN_CREATE', {publicKey,origin- }, 'background');+ });// Track if user cancelled to enable cooldownif (result && typeof result === 'object' && (result as any).cancelled) {@@ -215,7 +213,7 @@ export async function initializeWebAuthnInterceptor(_ctx: any): Promise<void> {publicKey,origin,isAutomaticRequest- }, 'background');+ });// Track if user cancelled to enable cooldownif (result && typeof result === 'object' && (result as any).cancelled) {@@ -263,7 +261,7 @@ export async function isWebAuthnInterceptionEnabled(): Promise<boolean> {try {const response = await sendMessage('GET_WEBAUTHN_SETTINGS', {url: window.location.href- }, 'background') as unknown as WebAuthnSettingsResponse;+ });return response.enabled ?? false;} catch {return false;diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsxindex 80708853b..3c0a2053e 100644--- a/apps/browser-extension/src/entrypoints/popup/App.tsx+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx@@ -1,7 +1,6 @@import React, { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';import { HashRouter as Router, Routes, Route, useLocation } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';import DefaultLayout from '@/entrypoints/popup/components/Layout/DefaultLayout';import Header from '@/entrypoints/popup/components/Layout/Header';@@ -37,6 +36,8 @@ import PasskeySettings from '@/entrypoints/popup/pages/settings/PasskeySettings'import Settings from '@/entrypoints/popup/pages/settings/Settings';import VaultUnlockSettings from '@/entrypoints/popup/pages/settings/VaultUnlockSettings';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';+import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';import '@/entrypoints/popup/style.css';@@ -219,13 +220,13 @@ const App: React.FC = () => {*/useEffect(() => {// Send initial heartbeat- sendMessage('POPUP_HEARTBEAT', {}, 'background').catch(() => {+ sendMessage('POPUP_HEARTBEAT').catch(() => {// Ignore errors as background script might not be ready});// Set up heartbeat intervalconst heartbeatInterval = setInterval(() => {- sendMessage('POPUP_HEARTBEAT', {}, 'background').catch(() => {+ sendMessage('POPUP_HEARTBEAT').catch(() => {// Ignore errors as background script might not be ready});}, 5000); // Send heartbeat every 5 secondsdiff --git a/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx b/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsxindex ce75fc67d..d730ce8e3 100644--- a/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx@@ -1,5 +1,6 @@import React, { useEffect, useState, useRef } from 'react';-import { onMessage, sendMessage } from 'webext-bridge/popup';++import { onMessage, sendMessage } from '@/utils/messaging/ExtensionMessaging';import { CountdownBar, ICountdownBarHandle } from './CountdownBar';@@ -31,8 +32,7 @@ export const ClipboardCountdownBar: React.FC = () => {useEffect(() => {// Request current countdown state on mount- sendMessage('GET_CLIPBOARD_COUNTDOWN_STATE', {}, 'background').then((state) => {- const countdownState = state as { remaining: number; total: number; id: number } | null;+ sendMessage('GET_CLIPBOARD_COUNTDOWN_STATE').then((countdownState) => {if (countdownState && countdownState.remaining > 0) {currentCountdownIdRef.current = countdownState.id;setIsVisible(true);@@ -47,7 +47,7 @@ export const ClipboardCountdownBar: React.FC = () => {// Listen for countdown updates from background scriptconst unsubscribe = onMessage('CLIPBOARD_COUNTDOWN', ({ data }) => {- const { remaining, total, id } = data as { remaining: number; total: number; id: number };+ const { remaining, total, id } = data;setIsVisible(remaining > 0);// Check if this is a new countdown (different ID)diff --git a/apps/browser-extension/src/entrypoints/popup/components/Dialogs/LogoutConfirmModal.tsx b/apps/browser-extension/src/entrypoints/popup/components/Dialogs/LogoutConfirmModal.tsxindex b2ba705d0..6695943a4 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Dialogs/LogoutConfirmModal.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Dialogs/LogoutConfirmModal.tsx@@ -1,9 +1,10 @@-import React, { useState, useEffect, useCallback } from 'react';+import React, { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';import ModalWrapper from '@/entrypoints/popup/components/Dialogs/ModalWrapper';+import { storage } from '#imports';+interface ILogoutConfirmModalProps {isOpen: boolean;onClose: () => void;@@ -23,33 +24,40 @@ const LogoutConfirmModal: React.FC<ILogoutConfirmModalProps> = ({const [isDirty, setIsDirty] = useState<boolean | null>(null);/**- * Check if the vault has unsynced changes when the modal opens.- */- const checkSyncState = useCallback(async (): Promise<void> => {- try {- const syncState = await sendMessage('GET_SYNC_STATE', {}, 'background') as {- isDirty: boolean;- mutationSequence: number;- serverRevision: number;- };- setIsDirty(syncState.isDirty);- } catch (error) {- console.error('Failed to check sync state:', error);- // Default to showing the simple logout confirmation on error- setIsDirty(false);- }- }, []);-- /**- * Check sync state when modal opens.+ * Check sync state every time the modal opens. The dirty flag lives in+ * local storage, so a direct read is equivalent to (and faster than) a+ * round-trip through the background script. The cancellation flag prevents+ * a stale response from overwriting state if the modal is closed and+ * reopened before this read resolves.*/useEffect(() => {- if (isOpen) {- // Reset state when modal opens+ if (!isOpen) {setIsDirty(null);- checkSyncState();+ return;}- }, [isOpen, checkSyncState]);++ let cancelled = false;+ setIsDirty(null);++ (async () : Promise<void> => {+ try {+ const dirty = await storage.getItem('local:isDirty') as boolean | null;+ if (!cancelled) {+ setIsDirty(dirty ?? false);+ }+ } catch (error) {+ console.error('Failed to check sync state:', error);+ if (!cancelled) {+ // Default to showing the simple logout confirmation on error+ setIsDirty(false);+ }+ }+ })();++ return () : void => {+ cancelled = true;+ };+ }, [isOpen]);// Don't render anything if not open or still loadingif (!isOpen || isDirty === null) {diff --git a/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx b/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsxindex 455a43812..2d8adc149 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx@@ -1,9 +1,10 @@import React, { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';import { ClipboardCopyService } from '@/entrypoints/popup/utils/ClipboardCopyService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';+/*** Form input copy to clipboard props.*/@@ -86,7 +87,7 @@ export const FormInputCopyToClipboard: React.FC<FormInputCopyToClipboardProps> =clipboardService.setCopied(id);// Notify background script that clipboard was copied- await sendMessage('CLIPBOARD_COPIED', { value }, 'background');+ await sendMessage('CLIPBOARD_COPIED');// Reset copied state after 2 secondssetTimeout(() => {diff --git a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsxindex 8b1f08d09..252f9cf15 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Items/Details/TotpBlock.tsx@@ -1,11 +1,11 @@import * as OTPAuth from 'otpauth';import React, { useState, useEffect } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';import { useDb } from '@/entrypoints/popup/context/DbContext';import type { TotpCode } from '@/utils/dist/core/models/vault';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';/*** Formats a TOTP code as "XXX XXX" with a space in the middle for better readability.@@ -84,7 +84,7 @@ const TotpBlock: React.FC<TotpBlockProps> = ({ itemId }) => {setCopiedId(id);// Notify background script that clipboard was copied- await sendMessage('CLIPBOARD_COPIED', { value: code }, 'background');+ await sendMessage('CLIPBOARD_COPIED');// Reset copied state after 2 secondssetTimeout(() => {diff --git a/apps/browser-extension/src/entrypoints/popup/components/Layout/ServerSyncIndicator.tsx b/apps/browser-extension/src/entrypoints/popup/components/Layout/ServerSyncIndicator.tsxindex 15a43ede7..e8d9f7d0f 100644--- a/apps/browser-extension/src/entrypoints/popup/components/Layout/ServerSyncIndicator.tsx+++ b/apps/browser-extension/src/entrypoints/popup/components/Layout/ServerSyncIndicator.tsx@@ -1,11 +1,11 @@import React, { useState, useEffect, useRef, useCallback } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';-import type { FullVaultSyncResult } from '@/entrypoints/background/VaultMessageHandler';import { useApp } from '@/entrypoints/popup/context/AppContext';import { useDb } from '@/entrypoints/popup/context/DbContext';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';+/*** Minimum time (ms) to show the syncing indicator.* Ensures user sees confirmation that a new vault was downloaded.@@ -82,7 +82,7 @@ const ServerSyncIndicator: React.FC = () => {}try {- const result = await sendMessage('FULL_VAULT_SYNC', {}, 'background') as FullVaultSyncResult;+ const result = await sendMessage('FULL_VAULT_SYNC');// Handle logout requirementif (result.requiresLogout) {diff --git a/apps/browser-extension/src/entrypoints/popup/context/AuthContext.tsx b/apps/browser-extension/src/entrypoints/popup/context/AuthContext.tsxindex cdc2b3157..9210dd105 100644--- a/apps/browser-extension/src/entrypoints/popup/context/AuthContext.tsx+++ b/apps/browser-extension/src/entrypoints/popup/context/AuthContext.tsx@@ -1,9 +1,9 @@import React, { createContext, useContext, useState, useMemo, useCallback } from 'react';-import { sendMessage } from 'webext-bridge/popup';import { useDb } from '@/entrypoints/popup/context/DbContext';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { removeAndDisablePin } from '@/utils/PinUnlockService';import { storage } from '#imports';@@ -77,7 +77,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children*/const clearAuthForced = useCallback(async (errorMessage?: string) : Promise<void> => {// Clear session data (tokens + ephemeral data) - vault data is preserved for recovery- await sendMessage('CLEAR_SESSION', {}, 'background');+ await sendMessage('CLEAR_SESSION');// Clear in-memory database referencedbContext?.clearDatabase();@@ -109,7 +109,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ childrenawait clearAuthForced(errorMessage);// Additionally clear vault data and username (forced logout preserves these for recovery)- await sendMessage('CLEAR_VAULT_DATA', {}, 'background');+ await sendMessage('CLEAR_VAULT_DATA');setUsername(null);}, [clearAuthForced]);diff --git a/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx b/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsxindex 3697021d8..562a7803f 100644--- a/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx+++ b/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx@@ -1,7 +1,7 @@import React, { createContext, useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';-import { sendMessage } from 'webext-bridge/popup';import type { EncryptionKeyDerivationParams } from '@/utils/dist/core/models/metadata';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import SqliteClient from '@/utils/SqliteClient';import { getItemWithFallback } from '@/utils/StorageUtility';import { AppErrorCode, formatErrorWithCode } from '@/utils/types/errors/AppErrorCodes';@@ -254,7 +254,7 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }let response: messageVaultResponse;try {response = await Promise.race([- sendMessage('GET_VAULT', {}, 'background') as Promise<messageVaultResponse>,+ sendMessage('GET_VAULT'),timeoutPromise,]);} finally {@@ -365,14 +365,14 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }* ignores the storage event triggered by this same flow.*/markOwnEncryptionKey(encryptionKey);- await sendMessage('STORE_ENCRYPTION_KEY', encryptionKey, 'background');+ await sendMessage('STORE_ENCRYPTION_KEY', encryptionKey);}, []);/*** Store encryption key derivation params in background worker.*/const storeEncryptionKeyDerivationParams = useCallback(async (params: EncryptionKeyDerivationParams) : Promise<void> => {- await sendMessage('STORE_ENCRYPTION_KEY_DERIVATION_PARAMS', params, 'background');+ await sendMessage('STORE_ENCRYPTION_KEY_DERIVATION_PARAMS', params);}, []);/**diff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useCurrentTabMatching.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useCurrentTabMatching.tsindex ef9002ea7..1870142dd 100644--- a/apps/browser-extension/src/entrypoints/popup/hooks/useCurrentTabMatching.ts+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useCurrentTabMatching.ts@@ -1,9 +1,8 @@import { useCallback } from 'react';-import { sendMessage } from 'webext-bridge/popup';import type { Item } from '@/utils/dist/core/models/vault';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';-import type { ItemsResponse } from '@/utils/types/messaging/ItemsResponse';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { browser } from '#imports';@@ -62,7 +61,7 @@ const useCurrentTabMatching = (): {pageTitle: activeTab.title || '',matchingMode: matchingMode// includeRecentlySelected defaults to false (recently selected is for autofill only)- }, 'background') as ItemsResponse;+ });if (!response.success || !response.items) {return null;diff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useFormPersistence.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useFormPersistence.tsindex 002c7d77e..211e84fdb 100644--- a/apps/browser-extension/src/entrypoints/popup/hooks/useFormPersistence.ts+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useFormPersistence.ts@@ -1,5 +1,6 @@import { useCallback, useEffect, useRef } from 'react';-import { sendMessage } from 'webext-bridge/popup';++import { sendMessage } from '@/utils/messaging/ExtensionMessaging';/*** Generic form persistence hook for saving and restoring form state.@@ -110,7 +111,7 @@ const useFormPersistence = <T>({data: formData,};- await sendMessage('PERSIST_FORM_VALUES', JSON.stringify(persistedData), 'background');+ await sendMessage('PERSIST_FORM_VALUES', JSON.stringify(persistedData));}, [formId, formData, isLoading]);/**@@ -126,7 +127,7 @@ const useFormPersistence = <T>({return false;}- const persistedData = await sendMessage('GET_PERSISTED_FORM_VALUES', null, 'background') as string | null;+ const persistedData = await sendMessage('GET_PERSISTED_FORM_VALUES') as string | null;try {if (!persistedData) {@@ -160,7 +161,7 @@ const useFormPersistence = <T>({* Clear persisted form values from storage.*/const clearPersistedValues = useCallback(async (): Promise<void> => {- await sendMessage('CLEAR_PERSISTED_FORM_VALUES', null, 'background');+ await sendMessage('CLEAR_PERSISTED_FORM_VALUES');}, []);/**diff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultMutate.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultMutate.tsindex 104b1a2f5..ec0421f25 100644--- a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultMutate.ts+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultMutate.ts@@ -1,10 +1,9 @@import { useCallback, useRef } from 'react';-import { sendMessage } from 'webext-bridge/popup';-import type { FullVaultSyncResult } from '@/entrypoints/background/VaultMessageHandler';import { useDb } from '@/entrypoints/popup/context/DbContext';import { EncryptionUtility } from '@/utils/EncryptionUtility';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';/*** Hook to execute a vault mutation.@@ -38,7 +37,7 @@ export function useVaultMutate(): {// Export and encrypt the updated vaultconst base64Vault = dbContext.sqliteClient!.exportToBase64();- const encryptionKey = await sendMessage('GET_ENCRYPTION_KEY', {}, 'background') as string;+ const encryptionKey = await sendMessage('GET_ENCRYPTION_KEY') as string;const encryptedVaultBlob = await EncryptionUtility.symmetricEncrypt(base64Vault,encryptionKey@@ -48,7 +47,7 @@ export function useVaultMutate(): {await sendMessage('STORE_ENCRYPTED_VAULT', {vaultBlob: encryptedVaultBlob,markDirty: true- }, 'background');+ });// Refresh the sync state in Reactawait dbContext.refreshSyncState();@@ -73,12 +72,7 @@ export function useVaultMutate(): {* Get sync state from background - includes both isDirty flag* and isSyncInProgress status from the background script*/- const syncState = await sendMessage('GET_SYNC_STATE', {}, 'background') as {- isDirty: boolean;- isSyncInProgress: boolean;- mutationSequence: number;- serverRevision: number;- };+ const syncState = await sendMessage('GET_SYNC_STATE');/** Only clear uploading indicator when:@@ -125,8 +119,7 @@ export function useVaultMutate(): {** After sending message, we start polling to detect completion.*/- void sendMessage('FULL_VAULT_SYNC', {}, 'background').then(async (result) => {- const syncResult = result as FullVaultSyncResult;+ void sendMessage('FULL_VAULT_SYNC').then(async (syncResult) => {if (!syncResult.success && (syncResult.error || syncResult.errorKey)) {/** Permanent failure (e.g. HTTP 413 vault too large). Stop polling and clear the uploaddiff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.tsindex 381970364..2435b23fe 100644--- a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts@@ -1,11 +1,11 @@import { useCallback } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';-import type { FullVaultSyncResult, SyncStatusCheckResult } from '@/entrypoints/background/VaultMessageHandler';import { useApp } from '@/entrypoints/popup/context/AppContext';import { useDb } from '@/entrypoints/popup/context/DbContext';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';+type VaultSyncOptions = {onSuccess?: (hasNewVault: boolean) => void;onError?: (error: string) => void;@@ -52,7 +52,7 @@ export const useVaultSync = (): { syncVault: (options?: VaultSyncOptions) => Pro* Quick check if sync is needed, this tells us if server has newer vault* or if we have local changes to upload, so we can show the appropriate indicator in UI.*/- const statusCheck = await sendMessage('CHECK_SYNC_STATUS', {}, 'background') as SyncStatusCheckResult;+ const statusCheck = await sendMessage('CHECK_SYNC_STATUS');// Handle logout requirement from status checkif (statusCheck.requiresLogout) {@@ -69,7 +69,7 @@ export const useVaultSync = (): { syncVault: (options?: VaultSyncOptions) => Pro}// Delegate to background script for full sync orchestration- const result = await sendMessage('FULL_VAULT_SYNC', {}, 'background') as FullVaultSyncResult;+ const result = await sendMessage('FULL_VAULT_SYNC');// Handle logout requirementif (result.requiresLogout) {diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsxindex 192eb4a2e..023bef5a5 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx@@ -1,6 +1,5 @@import React, { useCallback, useEffect, useRef } from 'react';import { useNavigate } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';import { useApp } from '@/entrypoints/popup/context/AppContext';import { useDb } from '@/entrypoints/popup/context/DbContext';@@ -9,6 +8,8 @@ import useCurrentTabMatching from '@/entrypoints/popup/hooks/useCurrentTabMatchiimport { consumePendingRedirectUrl } from '@/entrypoints/popup/hooks/useVaultLockRedirect';import { useVaultSync } from '@/entrypoints/popup/hooks/useVaultSync';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';+import { storage } from '#imports';const LAST_VISITED_PAGE_KEY = 'session:lastVisitedPage';@@ -141,7 +142,7 @@ const Reinitialize: React.FC = () => {storage.removeItem(LAST_VISITED_PAGE_KEY),storage.removeItem(LAST_VISITED_TIME_KEY),storage.removeItem(NAVIGATION_HISTORY_KEY),- sendMessage('CLEAR_PERSISTED_FORM_VALUES', null, 'background'),+ sendMessage('CLEAR_PERSISTED_FORM_VALUES'),]);// Save current tab URL for future tab-switch detectiondiff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsxindex d4e4c14df..433a8d978 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx@@ -1,9 +1,7 @@import React, { useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';-import type { TwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';import Button from '@/entrypoints/popup/components/Button';import MobileUnlockModal from '@/entrypoints/popup/components/Dialogs/MobileUnlockModal';import HeaderButton from '@/entrypoints/popup/components/HeaderButton';@@ -21,6 +19,7 @@ import { AppInfo } from '@/utils/AppInfo';import { SrpAuthService } from '@/utils/auth/SrpAuthService';import type { VaultResponse, LoginResponse } from '@/utils/dist/core/models/webapi';import { EncryptionUtility } from '@/utils/EncryptionUtility';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { ApiAuthError } from '@/utils/types/errors/ApiAuthError';import { hasErrorCode, getErrorMessage } from '@/utils/types/errors/AppErrorCodes';import type { MobileLoginResult } from '@/utils/types/messaging/MobileLoginResult';@@ -103,7 +102,7 @@ const Login: React.FC = () => {publicEmailDomainList: vaultResponse.vault.publicEmailDomainList,privateEmailDomainList: vaultResponse.vault.privateEmailDomainList,hiddenPrivateEmailDomainList: vaultResponse.vault.hiddenPrivateEmailDomainList,- }, 'background');+ });await dbContext.loadDatabase(decryptedExisting);return;@@ -125,13 +124,13 @@ const Login: React.FC = () => {await sendMessage('STORE_ENCRYPTED_VAULT', {vaultBlob: vaultResponse.vault.blob,serverRevision: vaultResponse.vault.currentRevisionNumber,- }, 'background');+ });await sendMessage('STORE_VAULT_METADATA', {publicEmailDomainList: vaultResponse.vault.publicEmailDomainList,privateEmailDomainList: vaultResponse.vault.privateEmailDomainList,hiddenPrivateEmailDomainList: vaultResponse.vault.hiddenPrivateEmailDomainList,- }, 'background');+ });// Decrypt and load the vault into memoryconst decryptedVault = await EncryptionUtility.symmetricDecrypt(vaultToLoad, encryptionKey);@@ -212,7 +211,7 @@ const Login: React.FC = () => {*/if (!twoFactorStateRestoreAttempted) {twoFactorStateRestoreAttempted = true;- const savedState = await sendMessage('GET_TWO_FACTOR_STATE', null, 'background') as TwoFactorState | null;+ const savedState = await sendMessage('GET_TWO_FACTOR_STATE');if (savedState) {// Restore the 2FA statesetCredentials({ username: savedState.username, password: '' });@@ -324,7 +323,7 @@ const Login: React.FC = () => {passwordHashString,passwordHashBase64,rememberMe,- }, 'background');+ });// Show app.hideLoading();@@ -393,7 +392,7 @@ const Login: React.FC = () => {}// Clear any persisted 2FA state since login is successful- await sendMessage('CLEAR_TWO_FACTOR_STATE', null, 'background');+ await sendMessage('CLEAR_TWO_FACTOR_STATE');// Handle successful authenticationawait handleSuccessfulAuth(@@ -517,7 +516,7 @@ const Login: React.FC = () => {type="button"onClick={async () => {// Clear persisted 2FA state- await sendMessage('CLEAR_TWO_FACTOR_STATE', null, 'background');+ await sendMessage('CLEAR_TWO_FACTOR_STATE');// Reset the formsetCredentials({username: '',diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsxindex 98e68f43e..ec80ac176 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx@@ -1,7 +1,6 @@import React, { useEffect, useState, useCallback, useRef } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';import AlertMessage from '@/entrypoints/popup/components/AlertMessage';import Button from '@/entrypoints/popup/components/Button';@@ -20,8 +19,8 @@ import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import SrpUtility from '@/entrypoints/popup/utils/SrpUtility';import { SrpAuthService } from '@/utils/auth/SrpAuthService';-import type { EncryptionKeyDerivationParams } from '@/utils/dist/core/models/metadata';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import {getPinLength,isPinEnabled,@@ -269,7 +268,7 @@ const Unlock: React.FC = () => {});} else {// Offline mode: use stored encryption params to derive key- const storedParams = await sendMessage('GET_ENCRYPTION_KEY_DERIVATION_PARAMS', {}, 'background') as EncryptionKeyDerivationParams | null;+ const storedParams = await sendMessage('GET_ENCRYPTION_KEY_DERIVATION_PARAMS');if (!storedParams) {// No stored params - can't unlock offline without having logged in beforediff --git a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyAuthenticate.tsx b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyAuthenticate.tsxindex 9ff1b23bc..746f44185 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyAuthenticate.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyAuthenticate.tsx@@ -1,7 +1,6 @@import React, { useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useLocation } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';import Button from '@/entrypoints/popup/components/Button';import PasskeyBypassDialog from '@/entrypoints/popup/components/Dialogs/PasskeyBypassDialog';@@ -11,6 +10,7 @@ import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { useVaultLockRedirect } from '@/entrypoints/popup/hooks/useVaultLockRedirect';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { PasskeyAuthenticator } from '@/utils/passkey/PasskeyAuthenticator';import { PasskeyHelper } from '@/utils/passkey/PasskeyHelper';import type { GetRequest, PasskeyGetCredentialResponse, PendingPasskeyGetRequest, StoredPasskeyRecord } from '@/utils/passkey/types';@@ -54,7 +54,7 @@ const PasskeyAuthenticate: React.FC = () => {if (requestId) {try {// Fetch the full request data from background- const data = await sendMessage('GET_REQUEST_DATA', { requestId }, 'background') as unknown as PendingPasskeyGetRequest;+ const data = await sendMessage('GET_REQUEST_DATA', { requestId }) as unknown as PendingPasskeyGetRequest;if (data && data.type === 'get') {setRequest(data);@@ -289,7 +289,7 @@ const PasskeyAuthenticate: React.FC = () => {await sendMessage('PASSKEY_POPUP_RESPONSE', {requestId: request.requestId,credential- }, 'background');+ });} catch (error) {console.error('PasskeyAuthenticate: Error during authentication', error);setLoading(false);@@ -331,7 +331,7 @@ const PasskeyAuthenticate: React.FC = () => {await sendMessage('PASSKEY_POPUP_RESPONSE', {requestId: request.requestId,fallback: true- }, 'background');+ });};/**@@ -349,7 +349,7 @@ const PasskeyAuthenticate: React.FC = () => {await sendMessage('PASSKEY_POPUP_RESPONSE', {requestId: request.requestId,cancelled: true- }, 'background');+ });};if (!request) {diff --git a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsxindex 2c609965f..73c783d89 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/passkeys/PasskeyCreate.tsx@@ -1,7 +1,6 @@import React, { useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useLocation } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';import Alert from '@/entrypoints/popup/components/Alert';import Button from '@/entrypoints/popup/components/Button';@@ -17,6 +16,7 @@ import { useVaultMutate } from '@/entrypoints/popup/hooks/useVaultMutate';import type { Item, Passkey } from '@/utils/dist/core/models/vault';import { FieldKey, ItemTypes, getFieldValue, createSystemField } from '@/utils/dist/core/models/vault';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { PasskeyAuthenticator } from '@/utils/passkey/PasskeyAuthenticator';import { PasskeyHelper } from '@/utils/passkey/PasskeyHelper';import type { CreateRequest, PasskeyCreateCredentialResponse, PendingPasskeyCreateRequest } from '@/utils/passkey/types';@@ -68,7 +68,7 @@ const PasskeyCreate: React.FC = () => {if (requestId) {try {// Fetch the full request data from background- const data = await sendMessage('GET_REQUEST_DATA', { requestId }, 'background') as unknown as PendingPasskeyCreateRequest;+ const data = await sendMessage('GET_REQUEST_DATA', { requestId }) as unknown as PendingPasskeyCreateRequest;if (data && data.type === 'create') {setRequest(data);@@ -465,7 +465,7 @@ const PasskeyCreate: React.FC = () => {await sendMessage('PASSKEY_POPUP_RESPONSE', {requestId: request.requestId,credential: flattenedCredential- }, 'background');+ });setLocalLoading(false);} catch (error) {@@ -508,7 +508,7 @@ const PasskeyCreate: React.FC = () => {await sendMessage('PASSKEY_POPUP_RESPONSE', {requestId: request.requestId,fallback: true- }, 'background');+ });};/**@@ -526,7 +526,7 @@ const PasskeyCreate: React.FC = () => {await sendMessage('PASSKEY_POPUP_RESPONSE', {requestId: request.requestId,cancelled: true- }, 'background');+ });};if (!request) {diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/AutoLockSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/AutoLockSettings.tsxindex a8d9676d6..87c363e46 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/AutoLockSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/AutoLockSettings.tsx@@ -1,12 +1,12 @@import React, { useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';import HelpModal from '@/entrypoints/popup/components/Dialogs/HelpModal';import PageTitle from '@/entrypoints/popup/components/PageTitle';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';/*** Auto-lock settings page component.@@ -36,7 +36,7 @@ const AutoLockSettings: React.FC = () => {const setAutoLockTimeoutSetting = async (timeout: number) : Promise<void> => {setAutoLockTimeout(timeout);await LocalPreferencesService.setAutoLockTimeout(timeout);- await sendMessage('SET_AUTO_LOCK_TIMEOUT', timeout, 'background');+ await sendMessage('SET_AUTO_LOCK_TIMEOUT', timeout);};return (diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/ClipboardSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/ClipboardSettings.tsxindex a208f34e8..9edb2311c 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/ClipboardSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/ClipboardSettings.tsx@@ -1,11 +1,11 @@import React, { useEffect, useState } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';import PageTitle from '@/entrypoints/popup/components/PageTitle';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';/*** Clipboard settings page component.@@ -34,7 +34,7 @@ const ClipboardSettings: React.FC = () => {*/const setClipboardClearTimeout = async (timeout: number) : Promise<void> => {await LocalPreferencesService.setClipboardClearTimeout(timeout);- await sendMessage('SET_CLIPBOARD_CLEAR_TIMEOUT', timeout, 'background');+ await sendMessage('SET_CLIPBOARD_CLEAR_TIMEOUT', timeout);setClipboardTimeout(timeout);};diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/ContextMenuSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/ContextMenuSettings.tsxindex 1684d1366..8708e7ca1 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/ContextMenuSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/ContextMenuSettings.tsx@@ -1,11 +1,11 @@import React, { useEffect, useState, useCallback } from 'react';import { useTranslation } from 'react-i18next';-import { sendMessage } from 'webext-bridge/popup';import PageTitle from '@/entrypoints/popup/components/PageTitle';import { useLoading } from '@/entrypoints/popup/context/LoadingContext';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';/*** Context menu settings page component.@@ -35,7 +35,7 @@ const ContextMenuSettings: React.FC = () => {const newContextMenuEnabled = !isContextMenuEnabled;await LocalPreferencesService.setGlobalContextMenuEnabled(newContextMenuEnabled);- await sendMessage('TOGGLE_CONTEXT_MENU', { enabled: newContextMenuEnabled }, 'background');+ await sendMessage('TOGGLE_CONTEXT_MENU', { enabled: newContextMenuEnabled });setIsContextMenuEnabled(newContextMenuEnabled);};diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsxindex 8a3bd7815..d9f5174dc 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/Settings.tsx@@ -1,7 +1,6 @@import React, { useEffect, useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';-import { sendMessage } from 'webext-bridge/popup';import LogoutConfirmModal from '@/entrypoints/popup/components/Dialogs/LogoutConfirmModal';import HeaderButton from '@/entrypoints/popup/components/HeaderButton';@@ -17,6 +16,7 @@ import { useApiUrl } from '@/entrypoints/popup/utils/ApiUrlUtility';import { PopoutUtility } from '@/entrypoints/popup/utils/PopoutUtility';import { AppInfo } from '@/utils/AppInfo';+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';import { browser, storage } from "#imports";@@ -138,7 +138,7 @@ const Settings: React.FC = () => {* Handle lock vault.*/const handleLock = async () : Promise<void> => {- await sendMessage('LOCK_VAULT', {}, 'background');+ await sendMessage('LOCK_VAULT');// Navigate to unlock pagenavigate('/unlock');diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.tsnew file mode 100644index 000000000..6b0428c02--- /dev/null+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts@@ -0,0 +1,108 @@+/**+ * Shared messaging contract for the extension. Every message that crosses a+ * popup/background/content-script boundary is declared here and dispatched via+ * the `sendMessage` / `onMessage` exported here.+ */++import { defineExtensionMessaging } from '@webext-core/messaging';++import type { TwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';+import type { SyncStatusCheckResult, FullVaultSyncResult } from '@/entrypoints/background/VaultMessageHandler';++import type { EncryptionKeyDerivationParams } from '@/utils/dist/core/models/metadata';+import type { LoginResponse } from '@/utils/dist/core/models/webapi';+import type { SavePromptPersistedState, LastAutofilledCredential } from '@/utils/loginDetector';+import type { PendingPasskeyRequest, WebAuthnSettingsResponse } from '@/utils/passkey/types';+import type { BoolResponse } from '@/utils/types/messaging/BoolResponse';+import type { DuplicateCheckResponse } from '@/utils/types/messaging/DuplicateCheckResponse';+import type { IdentitySettingsResponse } from '@/utils/types/messaging/IdentitySettingsResponse';+import type { ItemsResponse } from '@/utils/types/messaging/ItemsResponse';+import type { PasswordSettingsResponse } from '@/utils/types/messaging/PasswordSettingsResponse';+import type { SaveLoginResponse } from '@/utils/types/messaging/SaveLoginResponse';+import type { StringResponse } from '@/utils/types/messaging/StringResponse';+import type { VaultResponse } from '@/utils/types/messaging/VaultResponse';+import type { VaultUploadResponse } from '@/utils/types/messaging/VaultUploadResponse';++/* eslint-disable @typescript-eslint/no-explicit-any */+/**+ * Protocol map enumerating every message that flows through the extension's+ * runtime messaging system. Each entry maps a message name to a function+ * signature where the argument is the request payload and the return value is+ * the response shape (promises are unwrapped automatically by the library).+ */+export interface IExtensionMessageProtocol {+ ADD_URL_TO_CREDENTIAL(data: { itemId: string; url: string }): { success: boolean; error?: string };+ CANCEL_CLIPBOARD_CLEAR(): void;+ CHECK_AUTH_STATUS(): { isLoggedIn: boolean; isVaultLocked: boolean; hasPendingMigrations: boolean; error?: string };+ CHECK_LOGIN_DUPLICATE(data: { domain: string; username: string }): DuplicateCheckResponse;+ CHECK_SYNC_STATUS(): SyncStatusCheckResult;+ CLEAR_LAST_AUTOFILLED(): { success: boolean };+ CLEAR_PERSISTED_FORM_VALUES(): void;+ CLEAR_SAVE_PROMPT_STATE(): { success: boolean };+ CLEAR_SESSION(): BoolResponse;+ CLEAR_TWO_FACTOR_STATE(): void;+ CLEAR_VAULT_DATA(): BoolResponse;+ CLIPBOARD_CLEARED(data: Record<string, never>): void;+ CLIPBOARD_COPIED(): void;+ CLIPBOARD_COPIED_FROM_CONTEXT(): void;+ CLIPBOARD_COUNTDOWN(data: { remaining: number; total: number; id: number }): void;+ CLIPBOARD_COUNTDOWN_CANCELLED(data: Record<string, never>): void;+ CREATE_ITEM(data: any): BoolResponse;+ FULL_VAULT_SYNC(): FullVaultSyncResult;+ GENERATE_TOTP_CODE(data: { itemId: string }): { success: boolean; code?: string; error?: string };+ GET_CLIPBOARD_CLEAR_TIMEOUT(): number;+ GET_CLIPBOARD_COUNTDOWN_STATE(): { remaining: number; total: number; id: number } | null;+ GET_DEFAULT_EMAIL_DOMAIN(): StringResponse;+ GET_DEFAULT_IDENTITY_SETTINGS(): IdentitySettingsResponse;+ GET_ENCRYPTED_VAULT(): string | null;+ GET_ENCRYPTION_KEY(): string | null;+ GET_ENCRYPTION_KEY_DERIVATION_PARAMS(): EncryptionKeyDerivationParams | null;+ GET_FILTERED_ITEMS(data: { currentUrl: string; pageTitle: string; matchingMode?: string; includeRecentlySelected?: boolean }): ItemsResponse;+ GET_ITEMS_WITH_TOTP(data: { currentUrl: string; pageTitle: string; matchingMode?: string }): ItemsResponse;+ GET_LAST_AUTOFILLED(data: { domain?: string; username?: string }): { success: boolean; credential: LastAutofilledCredential | null };+ GET_LOGIN_SAVE_SETTINGS(): { success: boolean; enabled: boolean; autoDismissSeconds: number; error?: string };+ GET_PASSWORD_SETTINGS(): PasswordSettingsResponse;+ GET_PERSISTED_FORM_VALUES(): any | null;+ GET_RECENTLY_SELECTED(data: { domain: string }): { success: boolean; itemId?: string | null };+ GET_REQUEST_DATA(data: any): PendingPasskeyRequest | null;+ GET_SAVE_PROMPT_STATE(): { success: boolean; state: SavePromptPersistedState | null };+ GET_SEARCH_ITEMS(data: { searchTerm: string }): ItemsResponse;+ GET_SERVER_REVISION(): number;+ GET_SYNC_STATE(): { isDirty: boolean; mutationSequence: number; serverRevision: number; isSyncInProgress: boolean };+ GET_TOTP_SECRETS(data: { itemIds: string[] }): { success: boolean; secrets?: Record<string, string>; error?: string };+ GET_TWO_FACTOR_STATE(): TwoFactorState | null;+ GET_VAULT(): VaultResponse;+ GET_WEBAUTHN_SETTINGS(data: any): WebAuthnSettingsResponse;+ IS_URL_LINKED_TO_CREDENTIAL(data: { itemId: string; url: string }): { linked: boolean };+ LOCK_VAULT(): BoolResponse;+ MARK_VAULT_CLEAN(data: { mutationSeqAtStart: number; newServerRevision: number }): { cleared: boolean; currentMutationSeq: number };+ OPEN_AUTOFILL_POPUP(data: { elementIdentifier: string; popupType?: string }): BoolResponse;+ OPEN_POPUP(): BoolResponse;+ OPEN_POPUP_CREATE_CREDENTIAL(data: any): BoolResponse;+ OPEN_POPUP_WITH_ITEM(data: any): BoolResponse;+ PASSKEY_POPUP_RESPONSE(data: any): { success: boolean };+ PERSIST_FORM_VALUES(data: any): void;+ POPUP_HEARTBEAT(): void;+ RESET_AUTO_LOCK_TIMER(): void;+ SAVE_LOGIN_CREDENTIAL(data: { serviceName: string; username: string; password: string; url: string; domain: string; logoBase64?: string; faviconUrl?: string }): SaveLoginResponse;+ SEARCH_ITEMS_WITH_TOTP(data: { searchTerm: string }): ItemsResponse;+ SET_AUTO_LOCK_TIMEOUT(data: number): boolean;+ SET_CLIPBOARD_CLEAR_TIMEOUT(data: number): boolean;+ SET_LOGIN_SAVE_ENABLED(data: boolean): BoolResponse;+ SET_RECENTLY_SELECTED(data: { itemId: string; domain: string }): { success: boolean };+ STORE_ENCRYPTED_VAULT(data: { vaultBlob: string; markDirty?: boolean; serverRevision?: number; expectedMutationSeq?: number }): { success: boolean; mutationSequence: number };+ STORE_ENCRYPTION_KEY(data: string): BoolResponse;+ STORE_ENCRYPTION_KEY_DERIVATION_PARAMS(data: EncryptionKeyDerivationParams): BoolResponse;+ STORE_LAST_AUTOFILLED(data: LastAutofilledCredential): { success: boolean };+ STORE_SAVE_PROMPT_STATE(data: SavePromptPersistedState): { success: boolean };+ STORE_TWO_FACTOR_STATE(data: { username: string; loginResponse: LoginResponse; passwordHashString: string; passwordHashBase64: string; rememberMe: boolean }): void;+ STORE_VAULT_METADATA(data: { publicEmailDomainList?: string[]; privateEmailDomainList?: string[]; hiddenPrivateEmailDomainList?: string[] }): BoolResponse;+ SYNC_VAULT(): BoolResponse;+ TOGGLE_CONTEXT_MENU(data: any): BoolResponse;+ UPLOAD_VAULT(): VaultUploadResponse;+ WEBAUTHN_CREATE(data: any): any;+ WEBAUTHN_GET(data: any): any;+}+/* eslint-enable @typescript-eslint/no-explicit-any */++export const { sendMessage, onMessage } = defineExtensionMessaging<IExtensionMessageProtocol>();diff --git a/apps/browser-extension/tests/e2e/11-cross-window-state-sync.spec.ts b/apps/browser-extension/tests/e2e/11-cross-window-state-sync.spec.tsindex 2fd0dbdb1..b5531f4b9 100644--- a/apps/browser-extension/tests/e2e/11-cross-window-state-sync.spec.ts+++ b/apps/browser-extension/tests/e2e/11-cross-window-state-sync.spec.ts@@ -43,7 +43,7 @@ test.describe.serial('11. Cross-Window State Sync', () => {test('11.2 logout in popup propagates to expanded popout', async ({ context, extensionId, testUser }) => {// Main popup is on /unlock from 11.1; bring it back to the vault.- await client.popup.reload();+ await client.popup.bringToFront();await client.unlockVault(testUser.password);const popout = await context.newPage();@@ -51,7 +51,7 @@ test.describe.serial('11. Cross-Window State Sync', () => {await waitForVaultReady(popout, Timeouts.LONG);// Logout from the main popup: settings → logout → confirm modal.- await client.popup.reload();+ await client.popup.bringToFront();await client.goToSettings();await client.popup.locator('button#logout-button').click();await client.popup.locator('button#logout-confirm-button').click();@@ -64,7 +64,7 @@ test.describe.serial('11. Cross-Window State Sync', () => {test('11.3 unlock in popup propagates to expanded popout', async ({ context, extensionId, apiUrl, testUser }) => {// After 11.2 the popup is on /login; sign back in and lock so both windows start on /unlock.- await client.popup.reload();+ await client.popup.bringToFront();await client.login(apiUrl, testUser.username, testUser.password);await client.lockVault();@@ -77,7 +77,6 @@ test.describe.serial('11. Cross-Window State Sync', () => {// Unlock from the main popup. The popout should observe the encryption key// appearing in session storage and load the now-decrypted vault.console.log('reload popup');- await client.popup.reload();await client.popup.bringToFront();await client.unlockVault(testUser.password);console.log('unlock vault');@@ -94,7 +93,6 @@ test.describe.serial('11. Cross-Window State Sync', () => {test('11.4 login in popup propagates to expanded popout', async ({ context, extensionId, apiUrl, testUser }) => {// Reach a clean logged-out state in the main popup.- await client.popup.reload();await client.goToSettings();await client.popup.locator('button#logout-button').click();await client.popup.locator('button#logout-confirm-button').click();@@ -106,7 +104,6 @@ test.describe.serial('11. Cross-Window State Sync', () => {// Log in from the main popup. The popout should observe the access token// and encryption key appearing and route itself to the unlocked vault.- await client.popup.reload();await client.popup.bringToFront();await client.login(apiUrl, testUser.username, testUser.password);