mirror of
https://github.com/bitwarden/browser
synced 2025-12-24 04:04:24 +00:00
[PM-6296] Fix biometrics error prompt when biometrics are temporarily unavailable in browser extension (#9851)
* Add availability check to biometrics * Move isbiometricunlockavailable logic to parent component * Fix availability detection on desktop * FIx response parsing on browser * Suppress pending biometric message while checking for availability * Refactor biometrics functions out of platformutilsservice * Remove unused constructor * Remove unused abstract function definitions * Rename abstract services * Add documentation * Rename service abstraction, add comments * Add comments * Refactor browser biometrics into background/foreground and remove callbacks * Remove unused logs * Remove unused logs
This commit is contained in:
@@ -32,6 +32,7 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { BiometricStateService } from "@bitwarden/common/platform/biometrics/biometric-state.service";
|
||||
import { BiometricsService } from "@bitwarden/common/platform/biometrics/biometric.service";
|
||||
import { KeySuffixOptions } from "@bitwarden/common/platform/enums";
|
||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||
import { UserId } from "@bitwarden/common/types/guid";
|
||||
@@ -86,6 +87,7 @@ export class LockComponent implements OnInit, OnDestroy {
|
||||
protected userVerificationService: UserVerificationService,
|
||||
protected pinService: PinServiceAbstraction,
|
||||
protected biometricStateService: BiometricStateService,
|
||||
protected biometricsService: BiometricsService,
|
||||
protected accountService: AccountService,
|
||||
protected authService: AuthService,
|
||||
protected kdfConfigService: KdfConfigService,
|
||||
@@ -145,6 +147,13 @@ export class LockComponent implements OnInit, OnDestroy {
|
||||
return !!userKey;
|
||||
}
|
||||
|
||||
async isBiometricUnlockAvailable(): Promise<boolean> {
|
||||
if (!(await this.biometricsService.supportsBiometric())) {
|
||||
return false;
|
||||
}
|
||||
return this.biometricsService.isBiometricUnlockAvailable();
|
||||
}
|
||||
|
||||
togglePassword() {
|
||||
this.showPassword = !this.showPassword;
|
||||
const input = document.getElementById(this.pinEnabled ? "pin" : "masterPassword");
|
||||
@@ -355,7 +364,7 @@ export class LockComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.masterPasswordEnabled = await this.userVerificationService.hasMasterPassword();
|
||||
|
||||
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
||||
this.supportsBiometric = await this.biometricsService.supportsBiometric();
|
||||
this.biometricLock =
|
||||
(await this.vaultTimeoutSettingsService.isBiometricLockSet()) &&
|
||||
((await this.cryptoService.hasUserKeyStored(KeySuffixOptions.Biometric)) ||
|
||||
|
||||
@@ -43,8 +43,6 @@ export abstract class PlatformUtilsService {
|
||||
abstract isSelfHost(): boolean;
|
||||
abstract copyToClipboard(text: string, options?: ClipboardOptions): void | boolean;
|
||||
abstract readFromClipboard(): Promise<string>;
|
||||
abstract supportsBiometric(): Promise<boolean>;
|
||||
abstract authenticateBiometric(): Promise<boolean>;
|
||||
abstract supportsSecureStorage(): boolean;
|
||||
abstract getAutofillKeyboardShortcut(): Promise<string>;
|
||||
}
|
||||
|
||||
19
libs/common/src/platform/biometrics/biometric.service.ts
Normal file
19
libs/common/src/platform/biometrics/biometric.service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* The biometrics service is used to provide access to the status of and access to biometric functionality on the platforms.
|
||||
*/
|
||||
export abstract class BiometricsService {
|
||||
/**
|
||||
* Check if the platform supports biometric authentication.
|
||||
*/
|
||||
abstract supportsBiometric(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Checks whether biometric unlock is currently available at the moment (e.g. if the laptop lid is shut, biometric unlock may not be available)
|
||||
*/
|
||||
abstract isBiometricUnlockAvailable(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Performs biometric authentication
|
||||
*/
|
||||
abstract authenticateBiometric(): Promise<boolean>;
|
||||
}
|
||||
Reference in New Issue
Block a user