diff --git a/apps/browser/src/background/runtime.background.ts b/apps/browser/src/background/runtime.background.ts index 38bb2ec50c9..cab505f256d 100644 --- a/apps/browser/src/background/runtime.background.ts +++ b/apps/browser/src/background/runtime.background.ts @@ -195,7 +195,8 @@ export default class RuntimeBackground { return await this.main.biometricsService.getBiometricsStatus(); } case BiometricsCommands.UnlockWithBiometricsForUser: { - return await this.main.biometricsService.unlockWithBiometricsForUser(msg.userId); + const userKey = await this.main.biometricsService.unlockWithBiometricsForUser(msg.userId); + return userKey.keyB64; } case BiometricsCommands.GetBiometricsStatusForUser: { return await this.main.biometricsService.getBiometricsStatusForUser(msg.userId); diff --git a/apps/browser/src/key-management/biometrics/background-browser-biometrics.service.ts b/apps/browser/src/key-management/biometrics/background-browser-biometrics.service.ts index 012dda6a291..a0f54c58a64 100644 --- a/apps/browser/src/key-management/biometrics/background-browser-biometrics.service.ts +++ b/apps/browser/src/key-management/biometrics/background-browser-biometrics.service.ts @@ -80,7 +80,7 @@ export class BackgroundBrowserBiometricsService extends BiometricsService { } } - async unlockWithBiometricsForUser(userId: UserId): Promise { + async unlockWithBiometricsForUser(userId: UserId): Promise { try { await this.ensureConnected(); @@ -96,7 +96,7 @@ export class BackgroundBrowserBiometricsService extends BiometricsService { await this.biometricStateService.setBiometricUnlockEnabled(true); await this.biometricStateService.setFingerprintValidated(true); this.keyService.setUserKey(userKey, userId); - return response.userKeyB64; + return userKey; } } else { return null; @@ -107,13 +107,14 @@ export class BackgroundBrowserBiometricsService extends BiometricsService { userId: userId, }); if (response.response) { + // In case the requesting foreground context dies (popup), the userkey should still be set, so the user is unlocked / the setting should be enabled const decodedUserkey = Utils.fromB64ToArray(response.userKeyB64); const userKey = new SymmetricCryptoKey(decodedUserkey) as UserKey; if (await this.keyService.validateUserKey(userKey, userId)) { await this.biometricStateService.setBiometricUnlockEnabled(true); await this.biometricStateService.setFingerprintValidated(true); this.keyService.setUserKey(userKey, userId); - return response.userKeyB64; + return userKey; } } else { return null; @@ -123,6 +124,8 @@ export class BackgroundBrowserBiometricsService extends BiometricsService { this.logService.info("Biometric unlock for user failed", e); throw new Error("Biometric unlock failed"); } + + return null; } async getBiometricsStatusForUser(id: UserId): Promise {