mirror of
https://github.com/bitwarden/browser
synced 2026-02-05 11:13:44 +00:00
Add persistent to os biometric service
This commit is contained in:
@@ -33,6 +33,12 @@ export default class OsBiometricsServiceLinux implements OsBiometricService {
|
||||
|
||||
constructor() {}
|
||||
|
||||
async enrollPersistent(userId: UserId, key: SymmetricCryptoKey): Promise<void> {}
|
||||
|
||||
async hasPersistentKey(userId: UserId): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
async setBiometricKey(userId: UserId, key: SymmetricCryptoKey): Promise<void> {
|
||||
await biometrics.provideKey(this.biometricsSystem, userId, Buffer.from(key.toEncoded().buffer));
|
||||
}
|
||||
|
||||
@@ -20,6 +20,14 @@ export default class OsBiometricsServiceMac implements OsBiometricService {
|
||||
private logService: LogService,
|
||||
) {}
|
||||
|
||||
async enrollPersistent(userId: UserId, key: SymmetricCryptoKey): Promise<void> {
|
||||
return await passwords.setPassword(SERVICE, getLookupKeyForUser(userId), key.toBase64());
|
||||
}
|
||||
|
||||
async hasPersistentKey(userId: UserId): Promise<boolean> {
|
||||
return (await passwords.getPassword(SERVICE, getLookupKeyForUser(userId))) != null;
|
||||
}
|
||||
|
||||
async supportsBiometrics(): Promise<boolean> {
|
||||
return systemPreferences.canPromptTouchID();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,18 @@ export default class OsBiometricsServiceWindows implements OsBiometricService {
|
||||
private windowMain: WindowMain,
|
||||
) {}
|
||||
|
||||
async enrollPersistent(userId: UserId, key: SymmetricCryptoKey): Promise<void> {
|
||||
await biometrics.enrollPersistent(
|
||||
this.biometricsSystem,
|
||||
userId,
|
||||
Buffer.from(key.toEncoded().buffer),
|
||||
);
|
||||
}
|
||||
|
||||
async hasPersistentKey(userId: UserId): Promise<boolean> {
|
||||
return await biometrics.hasPersistent(this.biometricsSystem, userId);
|
||||
}
|
||||
|
||||
async supportsBiometrics(): Promise<boolean> {
|
||||
return await biometrics.authenticateAvailable(this.biometricsSystem);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ export interface OsBiometricService {
|
||||
setBiometricKey(userId: UserId, key: SymmetricCryptoKey): Promise<void>;
|
||||
deleteBiometricKey(userId: UserId): Promise<void>;
|
||||
getBiometricsFirstUnlockStatusForUser(userId: UserId): Promise<BiometricsStatus>;
|
||||
enrollPersistent(userId: UserId, key: SymmetricCryptoKey): Promise<void>;
|
||||
hasPersistentKey(userId: UserId): Promise<boolean>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user