Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update VaultMessageHandler.ts (#2159)
Leendert de Borst3bccd6c98b17
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.tsindex 8c980a273..8fe7f0eb1 100644--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts@@ -1463,16 +1463,21 @@ export async function handleCheckSyncStatus(): Promise<SyncStatusCheckResult> {return { success: false, hasNewerVault: false, hasDirtyChanges: false, isOffline: false, requiresLogout: true, errorKey: 'passwordChanged' };}- // If another device performed the KEK/VEK migration, catch up before any sync work happens.- if (!await adoptRemoteVaultKeyIfNeeded()) {+ const localSharedRevisions = await getLocalSharedManifestRevisions();+ const hasNewerVault = serverManifestsNeedPull(statusResponse.manifestRevisions, syncState.serverRevision, localSharedRevisions);++ /*+ * Only matters when there is server content to materialize: a device that migrated elsewhere necessarily wrote a+ * new root manifest revision, so a remote migration always shows up as a pull. With nothing to pull there is+ * nothing encrypted under a VEK we might be missing, and an unmigrated device can skip the probe entirely.+ */+ if (hasNewerVault && !await adoptRemoteVaultKeyIfNeeded()) {return { success: false, hasNewerVault: false, hasDirtyChanges: false, isOffline: false, requiresLogout: true, errorKey: 'passwordChanged' };}- const localSharedRevisions = await getLocalSharedManifestRevisions();-return {success: true,- hasNewerVault: serverManifestsNeedPull(statusResponse.manifestRevisions, syncState.serverRevision, localSharedRevisions),+ hasNewerVault,hasDirtyChanges: syncState.isDirty,isOffline: false,requiresLogout: false@@ -1596,8 +1601,11 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {return { success: false, hasNewVault: false, wasOffline: false, upgradeRequired: false, requiresLogout: true, errorKey: 'passwordChanged' };}- // If another device performed the KEK/VEK migration, catch up before any sync work happens.- if (!await adoptRemoteVaultKeyIfNeeded()) {+ /*+ * Only needed when we are about to pull: the vault data below is decrypted with the session key, which is stale if+ * another device migrated. An unmigrated device with nothing to pull has nothing to adopt and skips the check.+ */+ if (needsPull && !await adoptRemoteVaultKeyIfNeeded()) {return { success: false, hasNewVault: false, wasOffline: false, upgradeRequired: false, requiresLogout: true, errorKey: 'passwordChanged' };}