Skip to content

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

Browser extension simplify and improve create-item autofill flow UX

Leendert de Borst132ff46c2462
diff --git a/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts
index 62ffc4afe..8a60dfb06 100644
--- a/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/PopupMessageHandler.ts
@@ -48,6 +48,7 @@ export function handleOpenPopupCreateCredential(message: any, sender?: any) : Pr
const itemTitle = message.itemTitle || '';
const currentUrl = message.currentUrl || '';
const sourceTabId = sender?.tab?.id;
+ const sourceFrameId = sender?.frameId;
const elementIdentifier = message.elementIdentifier;
// Derive the service URL (origin only) from the page URL passed by the content script.
@@ -72,6 +73,9 @@ export function handleOpenPopupCreateCredential(message: any, sender?: any) : Pr
if (sourceTabId !== undefined && sourceTabId !== null) {
hashParams.set('sourceTabId', String(sourceTabId));
}
+ if (typeof sourceFrameId === 'number') {
+ hashParams.set('sourceFrameId', String(sourceFrameId));
+ }
if (elementIdentifier) {
hashParams.set('elementIdentifier', String(elementIdentifier));
}
diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.ts
index e97527f94..ca2bd9165 100644
--- a/apps/browser-extension/src/entrypoints/content.ts
+++ b/apps/browser-extension/src/entrypoints/content.ts
@@ -6,7 +6,7 @@ import '@/entrypoints/contentScript/style.css';
import { setPlatform } from '@aliasvault/client/platform';
import { CONDITIONAL_PASSKEYS_UPDATED_EVENT, hasPendingConditionalRequest, refreshConditionalPasskeyOptions } from '@/entrypoints/contentScript/ConditionalPasskey';
-import { fillCreatedItem, injectIcon, popupDebounceTimeHasPassed, validateInputField } from '@/entrypoints/contentScript/Form';
+import { fillItem, injectIcon, popupDebounceTimeHasPassed, validateInputField } from '@/entrypoints/contentScript/Form';
import { consumeUnlockResume, getLastAutofillInput, openAutofillPopup, openTotpPopup, removeExistingPopup, createUpgradeRequiredPopup } from '@/entrypoints/contentScript/Popup';
import { showSavePrompt, showAddUrlPrompt, isSavePromptVisible, updateSavePromptLogin, getPersistedSavePromptState, restoreSavePromptFromState, restoreAddUrlPromptFromState } from '@/entrypoints/contentScript/SavePrompt';
import { initializeWebAuthnInterceptor } from '@/entrypoints/contentScript/WebAuthnInterceptor';
@@ -25,7 +25,6 @@ import { t } from '@/i18n/StandaloneI18n';
import { extensionPlatform } from '@/platform/ExtensionPlatform';
import type { ItemRef } from '@aliasvault/client/database/ItemRef';
-import type { Item } from '@aliasvault/models/vault';
import { defineContentScript, createShadowRootUi } from '#imports';
@@ -665,13 +664,14 @@ export default defineContentScript({
});
/*
- * A credential was created in the full popup window (opened from this page's "create new
- * item" flow). Autofill it back into the page form, mirroring the inline quick-create UX.
+ * A credential was created in the full popup window (opened from this frame's "create new
+ * item" flow). Autofill it back into the page form, mirroring the inline quick-create UX. Only
+ * the item's reference arrives; the fill data is fetched like for any pick, with this frame as sender.
*/
onMessage('AUTOFILL_CREATED_ITEM', async ({ data }) => {
const { item, elementIdentifier } = data;
- if (!item) {
+ if (!item?.Id || !item.ManifestId) {
return { success: false, error: 'No item provided' };
}
@@ -698,7 +698,8 @@ export default defineContentScript({
// Close any open inline popup before filling.
removeExistingPopup(container);
- await fillCreatedItem(item as Item, resolvedInput);
+ // Not awaited, so the popup window can close while the fill (with its typing delay) runs in the page.
+ fillItem({ Id: item.Id, ManifestId: item.ManifestId }, resolvedInput).catch((error) => logFailure('[AliasVault] Error autofilling created item', error));
return { success: true };
});
diff --git a/apps/browser-extension/src/entrypoints/contentScript/Form.ts b/apps/browser-extension/src/entrypoints/contentScript/Form.ts
index ccb1b6ae1..df964bc1c 100644
--- a/apps/browser-extension/src/entrypoints/contentScript/Form.ts
+++ b/apps/browser-extension/src/entrypoints/contentScript/Form.ts
@@ -1,5 +1,3 @@
-import { itemToCredential } from '@aliasvault/models/vault';
-
import { openAutofillPopup, openTotpPopup, removeExistingPopup } from '@/entrypoints/contentScript/Popup';
import { LOGO_MARK_SVG } from '@/utils/constants/logo';
@@ -13,7 +11,7 @@ import { ClickValidator } from '@/utils/security/ClickValidator';
import { copyTotpToClipboardIfEnabled } from '@/utils/TotpClipboard';
import type { ItemRef } from '@aliasvault/client/database/ItemRef';
-import type { Credential, Item } from '@aliasvault/models/vault';
+import type { Credential } from '@aliasvault/models/vault';
/**
* Global timestamp to track popup debounce time.
@@ -112,17 +110,6 @@ export async function fillItem(item: ItemRef, input: HTMLInputElement): Promise<
await copyTotpToClipboardIfEnabled(item);
}
-/**
- * Fill an item the extension popup just created (and sent to this page) into the form of `input`.
- *
- * @param item - The created item.
- * @param input - The input element the create flow started from.
- */
-export async function fillCreatedItem(item: Item, input: HTMLInputElement): Promise<void> {
- await fillForm(input, () => Promise.resolve(itemToCredential(item)));
- await copyTotpToClipboardIfEnabled(item);
-}
-
/**
* Fill the form of `input` with the credential `getCredential` resolves, which is only asked for once a form is found.
*/
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx
index 2b0336000..1b7a26263 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/items/ItemAddEdit.tsx
@@ -96,6 +96,7 @@ const ItemAddEdit: React.FC = () => {
const folderIdParam = folderManifestIdParam ? searchParams.get('folderId') : null;
const sourceTabIdParam = searchParams.get('sourceTabId');
+ const sourceFrameIdParam = searchParams.get('sourceFrameId');
const fillBackElementIdentifier = searchParams.get('elementIdentifier');
const { executeVaultMutationAsync } = useVaultMutate();
@@ -673,26 +674,26 @@ const ItemAddEdit: React.FC = () => {
/**
* After creating a credential from a page's "create new item" flow, autofill the freshly
- * created item back into the originating tab and close this popup window. Returns true when the
+ * created item back into the originating frame and close this popup window. Returns true when the
* fill-back path handled the post-save behaviour (so the caller should skip normal navigation).
*/
const fillBackAndCloseWindow = useCallback(async (savedItem: Item): Promise<boolean> => {
- if (isEditMode || !sourceTabIdParam) {
+ if (isEditMode || !sourceTabIdParam || !sourceFrameIdParam) {
return false;
}
const tabId = Number(sourceTabIdParam);
- if (!Number.isInteger(tabId)) {
+ const frameId = Number(sourceFrameIdParam);
+ if (!Number.isInteger(tabId) || !Number.isInteger(frameId)) {
return false;
}
try {
- // Strip the binary logo before sending as its not used by autofill and prevents message serialization errors.
- const fillPayload = JSON.parse(JSON.stringify({ ...savedItem, Logo: undefined }));
+ // Send only the item reference, to the frame the flow started in.
await sendMessage('AUTOFILL_CREATED_ITEM', {
- item: fillPayload,
+ item: { Id: savedItem.Id, ManifestId: savedItem.ManifestId },
elementIdentifier: fillBackElementIdentifier ?? undefined
- }, tabId);
+ }, { tabId, frameId });
} catch (err) {
logFailure('Error autofilling created item into page', err);
}
@@ -720,7 +721,7 @@ const ItemAddEdit: React.FC = () => {
}
return true;
- }, [isEditMode, sourceTabIdParam, fillBackElementIdentifier]);
+ }, [isEditMode, sourceTabIdParam, sourceFrameIdParam, fillBackElementIdentifier]);
/**
* Handle form submission.
diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
index d57f6e17b..74ff18531 100644
--- a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
@@ -60,7 +60,7 @@ export interface IExtensionMessageProtocol {
AUTH_UNLOCK_PASSWORD(data: { password: string }): BackgroundAuthResult;
AUTH_UNLOCK_PIN(data: { pin: string }): BackgroundAuthResult;
ADD_URL_TO_CREDENTIAL(data: { itemId: string; manifestId: string; url: string }): { success: boolean; error?: string };
- AUTOFILL_CREATED_ITEM(data: { item: any; elementIdentifier?: string }): BoolResponse;
+ AUTOFILL_CREATED_ITEM(data: { item: ItemRef; elementIdentifier?: string }): BoolResponse;
BLOCK_LOGIN_SAVE_FOR_DOMAIN(data: { domain: string }): void;
CHECK_AUTH_STATUS(): { isLoggedIn: boolean; isVaultLocked: boolean; requiresLegacySqliteBlobMigration: boolean; requiresManifestMigration: boolean; error?: string };
CHECK_LOGIN_DUPLICATE(data: { domain: string; username: string }): DuplicateCheckResponse;
diff --git a/docs/docs/security-whitepaper.mdx b/docs/docs/security-whitepaper.mdx
index c10298666..8c6837131 100644
--- a/docs/docs/security-whitepaper.mdx
+++ b/docs/docs/security-whitepaper.mdx
@@ -69,7 +69,7 @@ The last column names the mechanism and the section that describes it.
|---|---|---|---|
| **Malicious or compromised server** (operator, insider, intruder, leaked database or backups) | Reads and modifies everything the server stores; controls every API response; serves any public key, setting or version it likes | Read vault or stored email contents; learn the master password or any key; forge or alter vault contents undetected; move data between vaults, fields or users; make a client derive a key below the client-enforced minimum | Client-held key hierarchy ([4](#4-key-derivation-and-key-hierarchy)); AES-256-GCM bound to its slot ([4.1](#41-key-hierarchy), [6](#6-vault-operations)); signed public keys and grants ([10](#10-vault-sharing)); client-side Argon2id minimum ([4](#4-key-derivation-and-key-hierarchy)); residual: key substitution at invitation ([13.2](#limitation-server-provided-keys)), rollback ([13.3](#limitation-rollback)) and email on arrival ([13.4](#limitation-email-at-rest)) |
| **Network attacker** (on-path, rogue access point, mis-issued certificate) | Reads and modifies traffic between client and server | Learn the password or any key; read vault contents; impersonate the server to a client during login | SRP with mutual proof ([5](#5-authentication-process)); vault data encrypted before transmission ([6](#6-vault-operations)); TLS |
-| **Malicious website** visited while the extension is installed | Runs scripts in its own page, sends messages to the content script, calls the WebAuthn API | Obtain credentials or passkey signatures for another site; trigger autofill for another origin; read extension storage | Autofill matched on the registrable domain; WebAuthn origin and relying-party checks ([8](#8-passkey-authentication)); content-script isolation, one item released per user pick |
+| **Malicious website** visited while the extension is installed | Runs scripts in its own page, sends messages to the content script, calls the WebAuthn API | Obtain credentials or passkey signatures for another site; trigger autofill for another origin; read extension storage | Autofill suggestions matched on the registrable domain; one item released per user pick, only to the frame it was picked in; content-script isolation; WebAuthn origin and relying-party checks ([8](#8-passkey-authentication)) |
| **Another AliasVault user**, including current and former shared-vault members | Holds their own account, grants they were given, and copies of data they synced | Open a vault they were not invited to; read another user's personal vault; keep receiving a shared vault's mail after removal | One VEK per vault, grants only to invited accounts, per-vault authorization on the server, delivery keypair replaced on removal ([10](#10-vault-sharing)); residual: the VEK is not rotated ([13.1](#limitation-shared-member-removal)) |
| **Holder of a stolen session token** | Calls the API as the user until the token expires or is revoked | Decrypt anything | Tokens never decrypt; access tokens live 10 minutes; refresh tokens are stored hashed and rotated on use; sessions can be revoked ([5.3](#53-session-tokens)) |
| **Holder of a copy of the encrypted data** (server database, device storage, backup, export file) | Unlimited offline computation | Decrypt without the master password or export password | Argon2id with a client-enforced minimum ([4](#4-key-derivation-and-key-hierarchy), [12](#12-vault-exports)); residual: a PIN-protected copy on the device is only as strong as the PIN ([13.7](#limitation-pin-unlock)) |