1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-25660] UserKeyDefinition.clearOn doesn't clear data in some cases (#16799)

* fix: always try to register clearOn events

`registerEvents` already checks for existing registered events so there is no
need to have a pre-check in `doStorageSave`. It causes issues because the
`newState` and `oldState` parameters come from the custom deserializer which
might never return `null` (e.g. transforming `null` to some default value).
Better to just use the list of registered events as a source of truth.

A performance check shows that most calls would only save a couple of
milliseconds (ranges from 0.8 ms to 18 ms) and the total amount of time
saved from application startup, to unlock, to showing the vault is about 100 ms.
I haven't been able to perceive the change.

* Revert "feat: add folder.clear warning (#16376)"

This reverts commit a2e36c4489.
This commit is contained in:
Andreas Coroiu
2025-10-17 09:25:49 +02:00
committed by GitHub
parent 7cd9832034
commit 5281da8fad
6 changed files with 1 additions and 8 deletions

View File

@@ -1674,7 +1674,6 @@ export default class MainBackground {
await Promise.all([
this.keyService.clearKeys(userBeingLoggedOut),
this.cipherService.clear(userBeingLoggedOut),
// ! DO NOT REMOVE folderService.clear ! For more information see PM-25660
this.folderService.clear(userBeingLoggedOut),
this.vaultTimeoutSettingsService.clear(userBeingLoggedOut),
this.biometricStateService.logout(userBeingLoggedOut),

View File

@@ -949,7 +949,6 @@ export class ServiceContainer {
this.eventUploadService.uploadEvents(userId as UserId),
this.keyService.clearKeys(userId),
this.cipherService.clear(userId),
// ! DO NOT REMOVE folderService.clear ! For more information see PM-25660
this.folderService.clear(userId),
]);

View File

@@ -691,7 +691,6 @@ export class AppComponent implements OnInit, OnDestroy {
await this.eventUploadService.uploadEvents(userBeingLoggedOut);
await this.keyService.clearKeys(userBeingLoggedOut);
await this.cipherService.clear(userBeingLoggedOut);
// ! DO NOT REMOVE folderService.clear ! For more information see PM-25660
await this.folderService.clear(userBeingLoggedOut);
await this.vaultTimeoutSettingsService.clear(userBeingLoggedOut);
await this.biometricStateService.logout(userBeingLoggedOut);

View File

@@ -258,7 +258,6 @@ export class AppComponent implements OnDestroy, OnInit {
await Promise.all([
this.keyService.clearKeys(userId),
this.cipherService.clear(userId),
// ! DO NOT REMOVE folderService.clear ! For more information see PM-25660
this.folderService.clear(userId),
this.biometricStateService.logout(userId),
]);

View File

@@ -144,7 +144,6 @@ export class VaultTimeoutService implements VaultTimeoutServiceAbstraction {
await this.searchService.clearIndex(lockingUserId);
// ! DO NOT REMOVE folderService.clearDecryptedFolderState ! For more information see PM-25660
await this.folderService.clearDecryptedFolderState(lockingUserId);
await this.masterPasswordService.clearMasterKey(lockingUserId);

View File

@@ -31,8 +31,6 @@ export class DefaultSingleUserState<T>
protected override async doStorageSave(newState: T, oldState: T): Promise<void> {
await super.doStorageSave(newState, oldState);
if (newState != null && oldState == null) {
await this.stateEventRegistrarService.registerEvents(this.keyDefinition);
}
await this.stateEventRegistrarService.registerEvents(this.keyDefinition);
}
}