1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 13:53:34 +00:00

Add logging for userkey / device trust rotation (#11682)

* Add logging for userkey rotation

* Fix tests
This commit is contained in:
Bernd Schoolmann
2024-10-24 19:54:39 +02:00
committed by GitHub
parent a9d9130f01
commit 9264e6775c
4 changed files with 28 additions and 0 deletions

View File

@@ -175,6 +175,7 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
newUserKey: UserKey,
masterPasswordHash: string,
): Promise<void> {
this.logService.info("[Device trust rotation] Rotating device trust...");
if (!userId) {
throw new Error("UserId is required. Cannot rotate device's trust.");
}
@@ -183,11 +184,15 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
if (currentDeviceKey == null) {
// If the current device doesn't have a device key available to it, then we can't
// rotate any trust at all, so early return.
this.logService.info("[Device trust rotation] No device key available to rotate trust!");
return;
}
// At this point of rotating their keys, they should still have their old user key in state
const oldUserKey = await firstValueFrom(this.keyService.userKey$(userId));
if (oldUserKey == newUserKey) {
this.logService.info("[Device trust rotation] Old user key is the same as the new user key.");
}
const deviceIdentifier = await this.appIdService.getAppId();
const secretVerificationRequest = new SecretVerificationRequest();
@@ -229,7 +234,12 @@ export class DeviceTrustService implements DeviceTrustServiceAbstraction {
trustRequest.currentDevice = currentDeviceUpdateRequest;
trustRequest.otherDevices = [];
this.logService.info(
"[Device trust rotation] Posting device trust update with current device:",
deviceIdentifier,
);
await this.devicesApiService.updateTrust(trustRequest, deviceIdentifier);
this.logService.info("[Device trust rotation] Device trust update posted successfully.");
}
async getDeviceKey(userId: UserId): Promise<DeviceKey | null> {

View File

@@ -193,6 +193,7 @@ export class NotificationsService implements NotificationsServiceAbstraction {
break;
case NotificationType.LogOut:
if (isAuthenticated) {
this.logService.info("[Notifications Service] Received logout notification");
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.logoutCallback("logoutNotification");