Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor linting issues (#758)
Leendert de Borst35cc29e75168
diff --git a/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/browser-extension/src/entrypoints/background/VaultMessageHandler.tsindex f027d7d48..769b5be36 100644--- a/browser-extension/src/entrypoints/background/VaultMessageHandler.ts+++ b/browser-extension/src/entrypoints/background/VaultMessageHandler.ts@@ -197,13 +197,13 @@ export async function getEmailAddressesForVault(const privateEmailDomains = await storage.getItem('session:privateEmailDomains') as string[];const emailAddresses = credentials- .filter(cred => cred.Email != null)- .map(cred => cred.Email)+ .filter(cred => cred.Alias?.Email != null)+ .map(cred => cred.Alias.Email ?? '').filter((email, index, self) => self.indexOf(email) === index);return emailAddresses.filter(email => {- const domain = email.split('@')[1];- return privateEmailDomains.includes(domain);+ const domain = email?.split('@')[1];+ return domain && privateEmailDomains.includes(domain);});}diff --git a/browser-extension/src/entrypoints/contentScript/Popup.ts b/browser-extension/src/entrypoints/contentScript/Popup.tsindex b0f14a940..3ad354d50 100644--- a/browser-extension/src/entrypoints/contentScript/Popup.ts+++ b/browser-extension/src/entrypoints/contentScript/Popup.ts@@ -212,25 +212,20 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Credenconst faviconBytes = await getFaviconBytes(document);credential = {Id: '',- ServiceName: result.serviceName || '',+ ServiceName: result.serviceName ?? '',ServiceUrl: getValidServiceUrl(),- Email: result.customEmail || '',- Logo: faviconBytes || undefined,- Username: result.customUsername || '',- Password: result.customPassword || '', // Set the generated password- Notes: '',+ Logo: faviconBytes ?? undefined,+ Username: result.customUsername,+ Password: result.customPassword ?? '', // Set the generated passwordAlias: {- FirstName: '',- LastName: '',- NickName: result.customUsername || '',+ NickName: result.customUsername ?? '',// TODO: once birthdate is made nullable in datamodel refactor, remove this.BirthDate: '0001-01-01 00:00:00',- Gender: undefined,- Email: result.customEmail || ''+ Email: result.customEmail ?? ''}};} else {- // Generate new identity locally+ // Generate new identity locally.const identityGenerator = new IdentityGeneratorEn();const identity = await identityGenerator.generateRandomIdentity();@@ -238,14 +233,7 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Credenconst passwordSettingsResponse = await sendMessage('GET_PASSWORD_SETTINGS', {}, 'background') as PasswordSettingsResponse;// Initialize password generator with the retrieved settings- const passwordGenerator = new PasswordGenerator({- Length: 16,- UseUppercase: true,- UseLowercase: true,- UseNumbers: true,- UseSpecialChars: true,- UseNonAmbiguousChars: false- });+ const passwordGenerator = new PasswordGenerator(passwordSettingsResponse.settings);const password = passwordGenerator.generateRandomPassword();// Extract favicon from page and get the bytes@@ -253,13 +241,11 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Credencredential = {Id: '',- ServiceName: result.serviceName || '',+ ServiceName: result.serviceName ?? '',ServiceUrl: getValidServiceUrl(),- Email: `${identity.emailPrefix}@${domain}`,- Logo: faviconBytes || undefined,+ Logo: faviconBytes ?? undefined,Username: identity.nickName,Password: password,- Notes: '',Alias: {FirstName: identity.firstName,LastName: identity.lastName,@@ -348,8 +334,6 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: CredenactionContainer.appendChild(closeButton);popup.appendChild(actionContainer);- console.log('Autofill actually popup appended:', popup);-/*** Handle clicking outside the popup.*/@@ -496,12 +480,15 @@ function handleSearchInput(searchInput: HTMLInputElement, credentials: Credentia});} else {// Otherwise filter based on search term- filteredCredentials = uniqueCredentials.filter(cred =>- cred.ServiceName?.toLowerCase().includes(searchTerm) ||- cred.Username?.toLowerCase().includes(searchTerm) ||- cred.Email?.toLowerCase().includes(searchTerm) ||- cred.ServiceUrl?.toLowerCase().includes(searchTerm)- ).sort((a, b) => {+ filteredCredentials = uniqueCredentials.filter(cred => {+ const searchableFields = [+ cred.ServiceName?.toLowerCase(),+ cred.Username?.toLowerCase(),+ cred.Alias?.Email?.toLowerCase(),+ cred.ServiceUrl?.toLowerCase()+ ];+ return searchableFields.some(field => field?.includes(searchTerm));+ }).sort((a, b) => {// First compare by service nameconst serviceNameComparison = (a.ServiceName ?? '').localeCompare(b.ServiceName ?? '');if (serviceNameComparison !== 0) {@@ -559,9 +546,8 @@ function createCredentialList(credentials: Credential[], input: HTMLInputElement}if (cred.Username) {details.push(cred.Username);- }- else if (cred.Email) {- details.push(cred.Email);+ } else if (cred.Alias?.Email) {+ details.push(cred.Alias.Email);}detailsContainer.textContent = details.join(' · ');@@ -821,8 +807,10 @@ export async function createEditNamePopup(defaultName: string, rootContainer: HTconst passwordPreview = popup.querySelector('#password-preview') as HTMLInputElement;const regenerateBtn = popup.querySelector('#regenerate-password') as HTMLButtonElement;- // Set up default values with placeholder styling- const setupDefaultValue = (input: HTMLInputElement) => {+ /**+ * Setup default value for input with placeholder styling.+ */+ const setupDefaultValue = (input: HTMLInputElement) : void => {const defaultValue = input.dataset.defaultValue;if (defaultValue) {input.value = defaultValue;@@ -866,8 +854,10 @@ export async function createEditNamePopup(defaultName: string, rootContainer: HTUseNonAmbiguousChars: false});- // Function to generate and set password- const generatePassword = () => {+ /**+ * Generate and set password.+ */+ const generatePassword = () : void => {passwordPreview.value = passwordGenerator.generateRandomPassword();};@@ -877,8 +867,10 @@ export async function createEditNamePopup(defaultName: string, rootContainer: HT// Handle regenerate button clickregenerateBtn.addEventListener('click', generatePassword);- // Handle mode switching via dropdown- const toggleDropdown = () => {+ /**+ * Toggle dropdown visibility.+ */+ const toggleDropdown = () : void => {dropdownMenu.style.display = dropdownMenu.style.display === 'none' ? 'block' : 'none';};@@ -971,14 +963,20 @@ export async function createEditNamePopup(defaultName: string, rootContainer: HTusernameLabel.appendChild(usernameError);}- // Remove error styling when user starts typing- const removeError = () => {+ /**+ * Remove error styling.+ */+ const removeError = () : void => {customEmail.classList.remove('av-create-popup-input-error');customUsername.classList.remove('av-create-popup-input-error');const emailError = emailLabel.querySelector('.av-create-popup-error-text');const usernameError = usernameLabel.querySelector('.av-create-popup-error-text');- if (emailError) emailError.remove();- if (usernameError) usernameError.remove();+ if (emailError) {+ emailError.remove();+ }+ if (usernameError) {+ usernameError.remove();+ }};customEmail.addEventListener('input', removeError, { once: true });@@ -1047,7 +1045,9 @@ export async function createEditNamePopup(defaultName: string, rootContainer: HT}});- // Handle click outside+ /**+ * Handle click outside.+ */const handleClickOutside = (event: MouseEvent): void => {const target = event.target as Node;if (target === overlay) {@@ -1084,7 +1084,6 @@ export function openAutofillPopup(input: HTMLInputElement, container: HTMLElemenconst response = await sendMessage('GET_CREDENTIALS', { }, 'background') as CredentialsResponse;if (response.success) {- console.log('creating autofill popup...');createAutofillPopup(input, response.credentials, container);} else {createVaultLockedPopup(input, container);diff --git a/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsx b/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsxindex a40392810..9f32a1749 100644--- a/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsx+++ b/browser-extension/src/entrypoints/popup/pages/CredentialDetails.tsx@@ -94,7 +94,7 @@ const TotpBlock: React.FC<{ credentialId: string }> = ({ credentialId }) => (* Render the login credentials block.*/const LoginCredentialsBlock: React.FC<{ credential: Credential }> = ({ credential }) => {- const email = credential.Email?.trim();+ const email = credential.Alias?.Email?.trim();const username = credential.Username?.trim();const password = credential.Password?.trim();@@ -305,10 +305,10 @@ const CredentialDetails: React.FC = () => {<div className="space-y-6"><HeaderBlock credential={credential} onOpenNewPopup={openInNewPopup} />- {credential.Email && (+ {credential.Alias?.Email && (<EmailBlock- email={credential.Email}- isSupported={isEmailDomainSupported(credential.Email)}+ email={credential.Alias.Email}+ isSupported={isEmailDomainSupported(credential.Alias.Email)}/>)}diff --git a/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx b/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsxindex ba5acdb99..e36e8e927 100644--- a/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx+++ b/browser-extension/src/entrypoints/popup/pages/CredentialsList.tsx@@ -106,11 +106,12 @@ const CredentialsList: React.FC = () => {// Add this function to filter credentialsconst filteredCredentials = credentials.filter(cred => {const searchLower = searchTerm.toLowerCase();- return (- cred.ServiceName?.toLowerCase().includes(searchLower) ||- cred.Username?.toLowerCase().includes(searchLower) ||- (cred.Email?.toLowerCase().includes(searchLower))- );+ const searchableFields = [+ cred.ServiceName?.toLowerCase(),+ cred.Username?.toLowerCase(),+ cred.Alias?.Email?.toLowerCase()+ ];+ return searchableFields.some(field => field?.includes(searchLower));});if (isLoading) {diff --git a/browser-extension/src/utils/SqliteClient.tsx b/browser-extension/src/utils/SqliteClient.tsxindex 366460a34..ee976978d 100644--- a/browser-extension/src/utils/SqliteClient.tsx+++ b/browser-extension/src/utils/SqliteClient.tsx@@ -169,7 +169,6 @@ class SqliteClient {Id: row.Id,Username: row.Username,Password: row.Password,- Email: row.Email,ServiceName: row.ServiceName,ServiceUrl: row.ServiceUrl,Logo: row.Logo,@@ -220,7 +219,6 @@ class SqliteClient {Id: row.Id,Username: row.Username,Password: row.Password,- Email: row.Email,ServiceName: row.ServiceName,ServiceUrl: row.ServiceUrl,Logo: row.Logo,@@ -385,7 +383,7 @@ class SqliteClient {const credentialId = crypto.randomUUID().toUpperCase();this.executeUpdate(credentialQuery, [credentialId,- credential.Username,+ credential.Username ?? null,credential.Notes ?? null,serviceId,aliasId,diff --git a/browser-extension/src/utils/types/Credential.ts b/browser-extension/src/utils/types/Credential.tsindex c495f8685..4e797e056 100644--- a/browser-extension/src/utils/types/Credential.ts+++ b/browser-extension/src/utils/types/Credential.ts@@ -5,16 +5,15 @@ import { Gender } from "../generators/Identity/types/Gender";*/export type Credential = {Id: string;- Username: string;+ Username?: string;Password: string;- Email: string;ServiceName: string;ServiceUrl?: string;Logo?: Uint8Array | number[];Notes?: string;Alias: {- FirstName: string;- LastName: string;+ FirstName?: string;+ LastName?: string;NickName?: string;BirthDate: string;Gender?: Gender;