Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Merge branch 'main' into 1404-update-datamodel-to-use-fields-based-approach
Leendert de Borst84434abe3aa0
diff --cc apps/browser-extension/src/entrypoints/background/VaultMessageHandler.tsindex 1cf13628c,47dedd04c..4edec18d3--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts@@@ -160,15 -185,17 +173,19 @@@ export async function handleSyncVault// Retrieve the latest vault from the server.const vaultResponse = await webApi.get<VaultResponse>('Vault');+ // Store in local: storage for persistence (fresh from server, no pending sync)await storage.setItems([- { key: 'session:encryptedVault', value: vaultResponse.vault.blob },- { key: 'session:publicEmailDomains', value: vaultResponse.vault.publicEmailDomainList },- { key: 'session:privateEmailDomains', value: vaultResponse.vault.privateEmailDomainList },- { key: 'session:hiddenPrivateEmailDomains', value: vaultResponse.vault.hiddenPrivateEmailDomainList },- { key: 'session:vaultRevisionNumber', value: vaultResponse.vault.currentRevisionNumber }+ { key: 'local:encryptedVault', value: vaultResponse.vault.blob },+ { key: 'local:publicEmailDomains', value: vaultResponse.vault.publicEmailDomainList },+ { key: 'local:privateEmailDomains', value: vaultResponse.vault.privateEmailDomainList },+ { key: 'local:hiddenPrivateEmailDomains', value: vaultResponse.vault.hiddenPrivateEmailDomainList },+ { key: 'local:vaultRevisionNumber', value: vaultResponse.vault.currentRevisionNumber },+ { key: 'local:hasPendingSync', value: false }]);++ // Clear cached client since we received a new vault blob from server+ cachedSqliteClient = null;+ cachedVaultBlob = null;}return { success: true };@@@ -219,42 -245,26 +236,46 @@@ export async function handleGetVault}/**- * Clear the vault from browser storage.+ * Lock the vault by clearing only session data.+ * This preserves local vault data so user can unlock again without server.*/-export function handleClearVault(-) : messageBoolResponse {+export function handleLockVault(): messageBoolResponse {+ // Clear session-only data (locks the vault)storage.removeItems([- 'session:encryptedVault','session:encryptionKey',- // TODO: the derivedKey clear can be removed some period of time after 0.22.0 is released.- 'session:derivedKey',- 'session:encryptionKeyDerivationParams',- 'session:publicEmailDomains',- 'session:privateEmailDomains',- 'session:hiddenPrivateEmailDomains',- 'session:vaultRevisionNumber'+ 'session:persistedFormValues',+ ]);++ return { success: true };+}++/**+ * Clear the vault completely from browser storage (both local: and session:).+ * This is used for full logout - removes all vault data.+ */+export function handleClearVault(): messageBoolResponse {+ // Clear persistent vault data from local: storage+ storage.removeItems([+ 'local:encryptedVault',+ 'local:publicEmailDomains',+ 'local:privateEmailDomains',+ 'local:hiddenPrivateEmailDomains',+ 'local:vaultRevisionNumber',+ 'local:isOfflineMode',+ 'local:hasPendingSync',+ 'local:encryptionKeyDerivationParams'+ ]);++ // Clear session-only data+ storage.removeItems([+ 'session:encryptionKey',+ 'session:persistedFormValues',]);+ // Clear cached client since vault was cleared+ cachedSqliteClient = null;+ cachedVaultBlob = null;+return { success: true };}@@@ -555,10 -649,10 +670,11 @@@ async function uploadNewVaultToServer(s/*** Create a new sqlite client for the stored vault.+ * Uses a cache to avoid repeated decryption and initialization for read operations.*/async function createVaultSqliteClient() : Promise<SqliteClient> {- const encryptedVault = await storage.getItem('session:encryptedVault') as string;+ // Read from local: storage for persistent vault access+ const encryptedVault = await storage.getItem('local:encryptedVault') as string;const encryptionKey = await handleGetEncryptionKey();if (!encryptedVault || !encryptionKey) {throw new Error(await t('common.errors.unknownError'));@@@ -574,64 -673,9 +695,68 @@@const sqliteClient = new SqliteClient();await sqliteClient.initializeFromBase64(decryptedVault);+ // Cache the client and vault blob+ cachedSqliteClient = sqliteClient;+ cachedVaultBlob = encryptedVault;+return sqliteClient;}++/**+ * Get offline mode status.+ */+export async function handleGetOfflineMode(): Promise<boolean> {+ const isOffline = await storage.getItem('local:isOfflineMode') as boolean;+ return isOffline ?? false;+}++/**+ * Set offline mode status.+ */+export async function handleSetOfflineMode(isOffline: boolean): Promise<void> {+ await storage.setItem('local:isOfflineMode', isOffline);+}++/**+ * Get pending sync status (true if local vault has changes not yet uploaded to server).+ */+export async function handleGetHasPendingSync(): Promise<boolean> {+ const hasPendingSync = await storage.getItem('local:hasPendingSync') as boolean;+ return hasPendingSync ?? false;+}++/**+ * Set pending sync status.+ */+export async function handleSetHasPendingSync(hasPendingSync: boolean): Promise<void> {+ await storage.setItem('local:hasPendingSync', hasPendingSync);+}++/**+ * Get the encrypted vault blob directly (for merge operations).+ */+export async function handleGetEncryptedVault(): Promise<string | null> {+ return await storage.getItem('local:encryptedVault') as string | null;+}++/**+ * Store the encrypted vault blob with pending sync flag.+ * This is an atomic operation that should be used for all local vault mutations.+ *+ * @param request Object with vaultBlob, hasPendingSync flag, and optional vaultRevisionNumber+ */+export async function handleStoreEncryptedVault(request: { vaultBlob: string; hasPendingSync: boolean; vaultRevisionNumber?: number }): Promise<void> {+ if (request.vaultRevisionNumber !== undefined) {+ // Store vault, pending sync flag, and revision number atomically+ await storage.setItems([+ { key: 'local:encryptedVault', value: request.vaultBlob },+ { key: 'local:hasPendingSync', value: request.hasPendingSync },+ { key: 'local:vaultRevisionNumber', value: request.vaultRevisionNumber }+ ]);+ } else {+ await storage.setItems([+ { key: 'local:encryptedVault', value: request.vaultBlob },+ { key: 'local:hasPendingSync', value: request.hasPendingSync }+ ]);+ }+}