mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
refactor(auth-state-updates): [Auth/PM-18544] Add shouldUpdate() checks to frequently updated state (#15994)
Adds `shouldUpdate()` checks to frequently updated disk state in the Auth domain, specifically: - `account_verifyNewDeviceLogin` - `token_accessToken` - `token_refreshToken` - `masterPassword_masterKeyHash` This ensures that the state only updates if the new value is different from the previous value, thus avoiding unnecessary updates.
This commit is contained in:
@@ -149,14 +149,18 @@ export class MasterPasswordService implements InternalMasterPasswordServiceAbstr
|
||||
if (userId == null) {
|
||||
throw new Error("User ID is required.");
|
||||
}
|
||||
await this.stateProvider.getUser(userId, MASTER_KEY_HASH).update((_) => masterKeyHash);
|
||||
await this.stateProvider.getUser(userId, MASTER_KEY_HASH).update((_) => masterKeyHash, {
|
||||
shouldUpdate: (previousValue) => previousValue !== masterKeyHash,
|
||||
});
|
||||
}
|
||||
|
||||
async clearMasterKeyHash(userId: UserId): Promise<void> {
|
||||
if (userId == null) {
|
||||
throw new Error("User ID is required.");
|
||||
}
|
||||
await this.stateProvider.getUser(userId, MASTER_KEY_HASH).update((_) => null);
|
||||
await this.stateProvider.getUser(userId, MASTER_KEY_HASH).update((_) => null, {
|
||||
shouldUpdate: (previousValue) => previousValue !== null,
|
||||
});
|
||||
}
|
||||
|
||||
async setMasterKeyEncryptedUserKey(encryptedKey: EncString, userId: UserId): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user