Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Use Rust password generator in content script (#776)
Leendert de Borst4bbf505f11e5
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.tsindex a74aeaa1e..881bbe14a 100644--- a/apps/browser-extension/src/entrypoints/background.ts+++ b/apps/browser-extension/src/entrypoints/background.ts@@ -9,7 +9,7 @@ import { handleGetWebAuthnSettings, handleWebAuthnCreate, handleWebAuthnGet, hanimport { handleOpenPopup, handlePopupWithItem, handleOpenPopupCreateCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';import { handleStoreSavePromptState, handleGetSavePromptState, handleClearSavePromptState, handleStoreLastAutofilled, handleGetLastAutofilled, handleClearLastAutofilled } from '@/entrypoints/background/SavePromptStateHandler';import { 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 { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleCreateItem, handleGetFilteredItems, handleGetSearchItems, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGeneratePassword, 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 { LocalPreferencesService } from '@/utils/LocalPreferencesService';import { onMessage, sendMessage } from "@/utils/messaging/ExtensionMessaging";@@ -223,6 +223,7 @@ export default defineBackground({onMessage('GET_DEFAULT_EMAIL_DOMAIN', () => handleGetDefaultEmailDomain());onMessage('GET_DEFAULT_IDENTITY_SETTINGS', () => handleGetDefaultIdentitySettings());onMessage('GET_PASSWORD_SETTINGS', () => handleGetPasswordSettings());+ onMessage('GENERATE_PASSWORD', ({ data }) => handleGeneratePassword(data.settings));onMessage('STORE_VAULT_METADATA', ({ data }) => handleStoreVaultMetadata(data));onMessage('STORE_ENCRYPTION_KEY', async ({ data }) => {diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.tsindex efd4f1f2b..ffe823b44 100644--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts@@ -4,12 +4,12 @@ import { storage } from 'wxt/utils/storage';import { TRASH_RETENTION_DAYS } from '@/utils/constants/vault';import type { EncryptionKeyDerivationParams } from '@/utils/dist/core/models/metadata';-import { FieldKey, ItemTypes, createSystemField, type Item } from '@/utils/dist/core/models/vault';+import { FieldKey, ItemTypes, createSystemField, type Item, type PasswordSettings } from '@/utils/dist/core/models/vault';import type { Vault, VaultResponse, VaultPostResponse } from '@/utils/dist/core/models/webapi';import { EncryptionUtility } from '@/utils/EncryptionUtility';import { LocalPreferencesService } from '@/utils/LocalPreferencesService';import { RecentlySelectedItemService } from '@/utils/RecentlySelectedItemService';-import { filterItems, AutofillMatchingMode, extractRootDomain, isUrlAlreadyLinked } from '@/utils/RustCore';+import { filterItems, AutofillMatchingMode, extractRootDomain, isUrlAlreadyLinked, generatePassword } from '@/utils/RustCore';import { SqliteClient } from '@/utils/SqliteClient';import { getItemWithFallback } from '@/utils/StorageUtility';import { ApiAuthError } from '@/utils/types/errors/ApiAuthError';@@ -636,6 +636,21 @@ export async function handleGetPasswordSettings(}}+/**+ * Generate a password or passphrase from the given settings using the Rust core.+ */+export async function handleGeneratePassword(+ settings: PasswordSettings+): Promise<{ success: boolean; password?: string; error?: string }> {+ try {+ const password = await generatePassword(settings);+ return { success: true, password };+ } catch (error) {+ console.error('Error generating password:', error);+ return { success: false, error: formatErrorWithCode(await t('common.errors.unknownError'), AppErrorCode.UNKNOWN_ERROR) };+ }+}+/*** Get the encryption key for the encrypted vault.*/diff --git a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts b/apps/browser-extension/src/entrypoints/contentScript/Popup.tsindex da85ec9f1..cb224341d 100644--- a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts@@ -4,9 +4,8 @@ import { fillItem, fillTotpCode } from '@/entrypoints/contentScript/Form';import { CreateIdentityGenerator, IdentityHelperUtils } from '@/utils/dist/core/identity-generator';import { ItemTypeIconSvgs } from '@/utils/dist/core/models/icons';-import type { Item, ItemField } from '@/utils/dist/core/models/vault';+import type { Item, ItemField, PasswordSettings } from '@/utils/dist/core/models/vault';import { ItemTypes, FieldKey, createSystemField, getFieldValue } from '@/utils/dist/core/models/vault';-import { 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';@@ -20,6 +19,15 @@ import { t } from '@/i18n/StandaloneI18n';import { getCurrentAutofillFrameUrl } from './AutofillFrameUrl';import { completeConditionalWithPasskey, getConditionalPasskeyOptions, hasPendingConditionalRequest } from './ConditionalPasskey';+/**+ * Generate a password from the given settings via the background (which runs the Rust core).+ * The content script cannot load the WASM core itself, so generation is delegated.+ */+const generatePasswordFromSettings = async (settings: PasswordSettings): Promise<string> => {+ const response = await sendMessage('GENERATE_PASSWORD', { settings });+ return response.password ?? '';+};+/*** WeakMap to store event listeners for popup containers*/@@ -949,16 +957,16 @@ export async function createAutofillPopup(input: HTMLInputElement, items: Item[]// Get password settings from backgroundconst passwordSettingsResponse = await sendMessage('GET_PASSWORD_SETTINGS');- // Initialize password generator with the retrieved settings- const passwordGenerator = CreatePasswordGenerator(passwordSettingsResponse.settings ?? {+ // Generate a password from the retrieved settings via the Rust core (background).+ const passwordSettings = passwordSettingsResponse.settings ?? {Length: 12,UseLowercase: true,UseUppercase: true,UseNumbers: true,UseSpecialChars: true,UseNonAmbiguousChars: true- });- const password = passwordGenerator.generateRandomPassword();+ };+ const password = await generatePasswordFromSettings(passwordSettings);// Extract favicon from page and get the bytesconst faviconBytes = await getFaviconBytes(document);@@ -2015,7 +2023,6 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootCon});// Get password settings from background- let passwordGenerator: PasswordGenerator;let currentPasswordSettings: PasswordSettings = {Length: 12,UseLowercase: true,@@ -2024,10 +2031,12 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConUseSpecialChars: true,UseNonAmbiguousChars: true};+ // Becomes true once settings have loaded, so generation isn't attempted too early.+ let passwordSettingsLoaded = false;sendMessage('GET_PASSWORD_SETTINGS').then((passwordSettingsResponse) => {currentPasswordSettings = passwordSettingsResponse.settings ?? currentPasswordSettings;- passwordGenerator = CreatePasswordGenerator(currentPasswordSettings);+ passwordSettingsLoaded = true;// Update UI with loaded settingsconst lengthSlider = popup.querySelector('#password-length-slider') as HTMLInputElement;@@ -2036,25 +2045,25 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConlengthValue.textContent = currentPasswordSettings.Length.toString();// Generate initial password after settings are loaded- generatePassword();+ void generatePassword();});/*** Generate and set password.*/- const generatePassword = () : void => {- if (!passwordGenerator) {+ const generatePassword = async () : Promise<void> => {+ if (!passwordSettingsLoaded) {return;}- passwordPreview.value = passwordGenerator.generateRandomPassword();+ passwordPreview.value = await generatePasswordFromSettings(currentPasswordSettings);passwordPreview.type = 'text';passwordPreview.dataset.isGenerated = 'true';updateVisibilityIcon(true);};// Handle regenerate button click- regenerateBtn.addEventListener('click', generatePassword);+ regenerateBtn.addEventListener('click', () => void generatePassword());// Handle password length sliderconst lengthSlider = popup.querySelector('#password-length-slider') as HTMLInputElement;@@ -2067,10 +2076,7 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConlengthValue.textContent = newLength.toString();// Regenerate password with new settings- if (passwordGenerator) {- passwordGenerator = CreatePasswordGenerator(currentPasswordSettings);- generatePassword();- }+ void generatePassword();});// Handle advanced configuration button@@ -2194,13 +2200,10 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootCon/*** Update the config preview.*/- const updateConfigPreview = (): void => {- if (passwordGenerator) {- passwordGenerator = CreatePasswordGenerator(currentPasswordSettings);- configPreview.value = passwordGenerator.generateRandomPassword();- }+ const updateConfigPreview = async (): Promise<void> => {+ configPreview.value = await generatePasswordFromSettings(currentPasswordSettings);};- updateConfigPreview();+ void updateConfigPreview();// Handle toggle buttonsdialog.querySelectorAll('.av-password-config-toggle').forEach(toggle => {@@ -2225,7 +2228,7 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootContoggle.classList.toggle('active', currentPasswordSettings.UseSpecialChars);break;}- updateConfigPreview();+ void updateConfigPreview();}});});@@ -2234,12 +2237,12 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConconst avoidAmbiguousCheckbox = dialog.querySelector('#avoid-ambiguous') as HTMLInputElement;avoidAmbiguousCheckbox.addEventListener('change', () => {currentPasswordSettings.UseNonAmbiguousChars = avoidAmbiguousCheckbox.checked;- updateConfigPreview();+ void updateConfigPreview();});// Handle refresh buttonconst refreshBtn = dialog.querySelector('#config-refresh') as HTMLButtonElement;- refreshBtn.addEventListener('click', updateConfigPreview);+ refreshBtn.addEventListener('click', () => void updateConfigPreview());// Handle use buttonconst useBtn = dialog.querySelector('#config-use-btn') as HTMLButtonElement;@@ -2249,9 +2252,6 @@ export async function createAliasCreationPopup(suggestedNames: string[], rootConpasswordPreview.dataset.isGenerated = 'true';updateVisibilityIcon(true);- // Update main password generator- passwordGenerator = CreatePasswordGenerator(currentPasswordSettings);-// Update slider valuelengthSlider.value = lengthToSlider(currentPasswordSettings.Length).toString();lengthValue.textContent = currentPasswordSettings.Length.toString();diff --git a/apps/browser-extension/src/utils/dist/core/password-generator/README.md b/apps/browser-extension/src/utils/dist/core/password-generator/README.mddeleted file mode 100644index ed0527c64..000000000--- a/apps/browser-extension/src/utils/dist/core/password-generator/README.md+++ /dev/null@@ -1,9 +0,0 @@-# ⚠️ Auto-Generated Files--This folder contains the output of the core `password-generator` module from the `/core` directory in the AliasVault project.--**Do not edit any of these files manually.**--To make changes:-1. Update the source files in the `/core/typescript/password-generator/src` directory-2. Run the `build.sh` script in the module directory to regenerate the outputs and copy them here.diff --git a/apps/browser-extension/src/utils/dist/core/password-generator/index.d.ts b/apps/browser-extension/src/utils/dist/core/password-generator/index.d.tsdeleted file mode 100644index ebfe93c7b..000000000--- a/apps/browser-extension/src/utils/dist/core/password-generator/index.d.ts+++ /dev/null@@ -1,134 +0,0 @@-/**- * Settings for password generation stored in SQLite database settings table as string.- */-type PasswordSettings = {- /**- * The length of the password.- */- Length: number;- /**- * Whether to use lowercase letters.- */- UseLowercase: boolean;- /**- * Whether to use uppercase letters.- */- UseUppercase: boolean;- /**- * Whether to use numbers.- */- UseNumbers: boolean;- /**- * Whether to use special characters.- */- UseSpecialChars: boolean;- /**- * Whether to use non-ambiguous characters.- */- UseNonAmbiguousChars: boolean;-};--/**- * Generate a random password.- */-declare class PasswordGenerator {- private readonly lowercaseChars;- private readonly uppercaseChars;- private readonly numberChars;- private readonly specialChars;- /**- * Ambiguous characters that look similar and are easy to confuse when typing:- * - I, l, 1, | (pipe) - all look like vertical lines- * - O, 0, o - all look like circles- * - Z, 2 - similar appearance- * - S, 5 - similar appearance- * - B, 8 - similar appearance- * - G, 6 - similar appearance- * - Brackets, braces, parentheses: [], {}, ()- * - Quotes: ', ", `- * - Punctuation pairs: ;:, .,- * - Dashes: -, _- * - Angle brackets: <>- */- private readonly ambiguousChars;- private length;- private useLowercase;- private useUppercase;- private useNumbers;- private useSpecial;- private useNonAmbiguous;- /**- * Create a new instance of PasswordGenerator.- * @param settings Optional password settings to initialize with.- */- constructor(settings?: PasswordSettings);- /**- * Apply password settings to this generator.- */- applySettings(settings: PasswordSettings): this;- /**- * Set the length of the password.- */- setLength(length: number): this;- /**- * Set if lowercase letters should be used.- */- useLowercaseLetters(use: boolean): this;- /**- * Set if uppercase letters should be used.- */- useUppercaseLetters(use: boolean): this;- /**- * Set if numeric characters should be used.- */- useNumericCharacters(use: boolean): this;- /**- * Set if special characters should be used.- */- useSpecialCharacters(use: boolean): this;- /**- * Set if only non-ambiguous characters should be used.- */- useNonAmbiguousCharacters(use: boolean): this;- /**- * Get a random index from the crypto module.- */- private getUnbiasedRandomIndex;- /**- * Generate a random password.- */- generateRandomPassword(): string;- /**- * Build character set based on selected options.- */- private buildCharacterSet;- /**- * Remove ambiguous characters from a character set.- */- private removeAmbiguousCharacters;- /**- * Generate initial random password.- */- private generateInitialPassword;- /**- * Ensure the generated password meets all specified requirements.- */- private ensureRequirements;- /**- * Get a character set with ambiguous characters removed if needed.- */- private getSafeCharacterSet;- /**- * Add a character from the given set at a random position in the password.- */- private addCharacterFromSet;-}--/**- * Creates a new password generator.- * @param settings - The settings for the password generator.- * @returns A new password generator instance.- */-declare const CreatePasswordGenerator: (settings: PasswordSettings) => PasswordGenerator;--export { CreatePasswordGenerator, PasswordGenerator, type PasswordSettings };diff --git a/apps/browser-extension/src/utils/dist/core/password-generator/index.js b/apps/browser-extension/src/utils/dist/core/password-generator/index.jsdeleted file mode 100644index 757060daa..000000000--- a/apps/browser-extension/src/utils/dist/core/password-generator/index.js+++ /dev/null@@ -1,245 +0,0 @@-// <auto-generated>-// This file was automatically generated. Do not edit manually.--"use strict";-var __defProp = Object.defineProperty;-var __getOwnPropDesc = Object.getOwnPropertyDescriptor;-var __getOwnPropNames = Object.getOwnPropertyNames;-var __hasOwnProp = Object.prototype.hasOwnProperty;-var __export = (target, all) => {- for (var name in all)- __defProp(target, name, { get: all[name], enumerable: true });-};-var __copyProps = (to, from, except, desc) => {- if (from && typeof from === "object" || typeof from === "function") {- for (let key of __getOwnPropNames(from))- if (!__hasOwnProp.call(to, key) && key !== except)- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });- }- return to;-};-var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);--// src/index.ts-var index_exports = {};-__export(index_exports, {- CreatePasswordGenerator: () => CreatePasswordGenerator,- PasswordGenerator: () => PasswordGenerator-});-module.exports = __toCommonJS(index_exports);--// src/utils/PasswordGenerator.ts-var PasswordGenerator = class {- /**- * Create a new instance of PasswordGenerator.- * @param settings Optional password settings to initialize with.- */- constructor(settings) {- this.lowercaseChars = "abcdefghijklmnopqrstuvwxyz";- this.uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";- this.numberChars = "0123456789";- this.specialChars = "!@#$%^&*()_+-=[]{}|;:,.<>?";- /**- * Ambiguous characters that look similar and are easy to confuse when typing:- * - I, l, 1, | (pipe) - all look like vertical lines- * - O, 0, o - all look like circles- * - Z, 2 - similar appearance- * - S, 5 - similar appearance- * - B, 8 - similar appearance- * - G, 6 - similar appearance- * - Brackets, braces, parentheses: [], {}, ()- * - Quotes: ', ", `- * - Punctuation pairs: ;:, .,- * - Dashes: -, _- * - Angle brackets: <>- */- this.ambiguousChars = "Il1O0oZzSsBbGg2568|[]{}()<>;:,.`'\"_-";- this.length = 18;- this.useLowercase = true;- this.useUppercase = true;- this.useNumbers = true;- this.useSpecial = true;- this.useNonAmbiguous = false;- if (settings) {- this.applySettings(settings);- }- }- /**- * Apply password settings to this generator.- */- applySettings(settings) {- this.length = settings.Length;- this.useLowercase = settings.UseLowercase;- this.useUppercase = settings.UseUppercase;- this.useNumbers = settings.UseNumbers;- this.useSpecial = settings.UseSpecialChars;- this.useNonAmbiguous = settings.UseNonAmbiguousChars;- return this;- }- /**- * Set the length of the password.- */- setLength(length) {- this.length = length;- return this;- }- /**- * Set if lowercase letters should be used.- */- useLowercaseLetters(use) {- this.useLowercase = use;- return this;- }- /**- * Set if uppercase letters should be used.- */- useUppercaseLetters(use) {- this.useUppercase = use;- return this;- }- /**- * Set if numeric characters should be used.- */- useNumericCharacters(use) {- this.useNumbers = use;- return this;- }- /**- * Set if special characters should be used.- */- useSpecialCharacters(use) {- this.useSpecial = use;- return this;- }- /**- * Set if only non-ambiguous characters should be used.- */- useNonAmbiguousCharacters(use) {- this.useNonAmbiguous = use;- return this;- }- /**- * Get a random index from the crypto module.- */- getUnbiasedRandomIndex(max) {- const limit = Math.floor(2 ** 32 / max) * max;- while (true) {- const array = new Uint32Array(1);- crypto.getRandomValues(array);- const value = array[0];- if (value < limit) {- return value % max;- }- }- }- /**- * Generate a random password.- */- generateRandomPassword() {- const chars = this.buildCharacterSet();- let password = this.generateInitialPassword(chars);- password = this.ensureRequirements(password);- return password;- }- /**- * Build character set based on selected options.- */- buildCharacterSet() {- let chars = "";- if (this.useLowercase) {- chars += this.lowercaseChars;- }- if (this.useUppercase) {- chars += this.uppercaseChars;- }- if (this.useNumbers) {- chars += this.numberChars;- }- if (this.useSpecial) {- chars += this.specialChars;- }- if (chars.length === 0) {- chars = this.lowercaseChars;- }- if (this.useNonAmbiguous) {- chars = this.removeAmbiguousCharacters(chars);- }- return chars;- }- /**- * Remove ambiguous characters from a character set.- */- removeAmbiguousCharacters(chars) {- for (const ambChar of this.ambiguousChars) {- chars = chars.replace(ambChar, "");- }- return chars;- }- /**- * Generate initial random password.- */- generateInitialPassword(chars) {- let password = "";- for (let i = 0; i < this.length; i++) {- password += chars[this.getUnbiasedRandomIndex(chars.length)];- }- return password;- }- /**- * Ensure the generated password meets all specified requirements.- */- ensureRequirements(password) {- if (this.useLowercase && !/[a-z]/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.lowercaseChars)- );- }- if (this.useUppercase && !/[A-Z]/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.uppercaseChars)- );- }- if (this.useNumbers && !/\d/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.numberChars)- );- }- if (this.useSpecial && !/[!@#$%^&*()_+\-=[\]{}|;:,.<>?]/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.specialChars)- );- }- return password;- }- /**- * Get a character set with ambiguous characters removed if needed.- */- getSafeCharacterSet(charSet) {- if (!this.useNonAmbiguous) {- return charSet;- }- return this.removeAmbiguousCharacters(charSet);- }- /**- * Add a character from the given set at a random position in the password.- */- addCharacterFromSet(password, charSet) {- const pos = this.getUnbiasedRandomIndex(this.length);- const char = charSet[this.getUnbiasedRandomIndex(charSet.length)];- return password.substring(0, pos) + char + password.substring(pos + 1);- }-};--// src/factories/PasswordGeneratorFactory.ts-var CreatePasswordGenerator = (settings) => {- return new PasswordGenerator(settings);-};-// Annotate the CommonJS export names for ESM import in node:-0 && (module.exports = {- CreatePasswordGenerator,- PasswordGenerator-});diff --git a/apps/browser-extension/src/utils/dist/core/password-generator/index.mjs b/apps/browser-extension/src/utils/dist/core/password-generator/index.mjsdeleted file mode 100644index 60016fcf9..000000000--- a/apps/browser-extension/src/utils/dist/core/password-generator/index.mjs+++ /dev/null@@ -1,218 +0,0 @@-// <auto-generated>-// This file was automatically generated. Do not edit manually.---// src/utils/PasswordGenerator.ts-var PasswordGenerator = class {- /**- * Create a new instance of PasswordGenerator.- * @param settings Optional password settings to initialize with.- */- constructor(settings) {- this.lowercaseChars = "abcdefghijklmnopqrstuvwxyz";- this.uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";- this.numberChars = "0123456789";- this.specialChars = "!@#$%^&*()_+-=[]{}|;:,.<>?";- /**- * Ambiguous characters that look similar and are easy to confuse when typing:- * - I, l, 1, | (pipe) - all look like vertical lines- * - O, 0, o - all look like circles- * - Z, 2 - similar appearance- * - S, 5 - similar appearance- * - B, 8 - similar appearance- * - G, 6 - similar appearance- * - Brackets, braces, parentheses: [], {}, ()- * - Quotes: ', ", `- * - Punctuation pairs: ;:, .,- * - Dashes: -, _- * - Angle brackets: <>- */- this.ambiguousChars = "Il1O0oZzSsBbGg2568|[]{}()<>;:,.`'\"_-";- this.length = 18;- this.useLowercase = true;- this.useUppercase = true;- this.useNumbers = true;- this.useSpecial = true;- this.useNonAmbiguous = false;- if (settings) {- this.applySettings(settings);- }- }- /**- * Apply password settings to this generator.- */- applySettings(settings) {- this.length = settings.Length;- this.useLowercase = settings.UseLowercase;- this.useUppercase = settings.UseUppercase;- this.useNumbers = settings.UseNumbers;- this.useSpecial = settings.UseSpecialChars;- this.useNonAmbiguous = settings.UseNonAmbiguousChars;- return this;- }- /**- * Set the length of the password.- */- setLength(length) {- this.length = length;- return this;- }- /**- * Set if lowercase letters should be used.- */- useLowercaseLetters(use) {- this.useLowercase = use;- return this;- }- /**- * Set if uppercase letters should be used.- */- useUppercaseLetters(use) {- this.useUppercase = use;- return this;- }- /**- * Set if numeric characters should be used.- */- useNumericCharacters(use) {- this.useNumbers = use;- return this;- }- /**- * Set if special characters should be used.- */- useSpecialCharacters(use) {- this.useSpecial = use;- return this;- }- /**- * Set if only non-ambiguous characters should be used.- */- useNonAmbiguousCharacters(use) {- this.useNonAmbiguous = use;- return this;- }- /**- * Get a random index from the crypto module.- */- getUnbiasedRandomIndex(max) {- const limit = Math.floor(2 ** 32 / max) * max;- while (true) {- const array = new Uint32Array(1);- crypto.getRandomValues(array);- const value = array[0];- if (value < limit) {- return value % max;- }- }- }- /**- * Generate a random password.- */- generateRandomPassword() {- const chars = this.buildCharacterSet();- let password = this.generateInitialPassword(chars);- password = this.ensureRequirements(password);- return password;- }- /**- * Build character set based on selected options.- */- buildCharacterSet() {- let chars = "";- if (this.useLowercase) {- chars += this.lowercaseChars;- }- if (this.useUppercase) {- chars += this.uppercaseChars;- }- if (this.useNumbers) {- chars += this.numberChars;- }- if (this.useSpecial) {- chars += this.specialChars;- }- if (chars.length === 0) {- chars = this.lowercaseChars;- }- if (this.useNonAmbiguous) {- chars = this.removeAmbiguousCharacters(chars);- }- return chars;- }- /**- * Remove ambiguous characters from a character set.- */- removeAmbiguousCharacters(chars) {- for (const ambChar of this.ambiguousChars) {- chars = chars.replace(ambChar, "");- }- return chars;- }- /**- * Generate initial random password.- */- generateInitialPassword(chars) {- let password = "";- for (let i = 0; i < this.length; i++) {- password += chars[this.getUnbiasedRandomIndex(chars.length)];- }- return password;- }- /**- * Ensure the generated password meets all specified requirements.- */- ensureRequirements(password) {- if (this.useLowercase && !/[a-z]/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.lowercaseChars)- );- }- if (this.useUppercase && !/[A-Z]/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.uppercaseChars)- );- }- if (this.useNumbers && !/\d/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.numberChars)- );- }- if (this.useSpecial && !/[!@#$%^&*()_+\-=[\]{}|;:,.<>?]/.exec(password)) {- password = this.addCharacterFromSet(- password,- this.getSafeCharacterSet(this.specialChars)- );- }- return password;- }- /**- * Get a character set with ambiguous characters removed if needed.- */- getSafeCharacterSet(charSet) {- if (!this.useNonAmbiguous) {- return charSet;- }- return this.removeAmbiguousCharacters(charSet);- }- /**- * Add a character from the given set at a random position in the password.- */- addCharacterFromSet(password, charSet) {- const pos = this.getUnbiasedRandomIndex(this.length);- const char = charSet[this.getUnbiasedRandomIndex(charSet.length)];- return password.substring(0, pos) + char + password.substring(pos + 1);- }-};--// src/factories/PasswordGeneratorFactory.ts-var CreatePasswordGenerator = (settings) => {- return new PasswordGenerator(settings);-};-export {- CreatePasswordGenerator,- PasswordGenerator-};