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

Initial work of biometric unlock for browser

This commit is contained in:
Hinton
2020-10-09 17:16:15 +02:00
parent 296ccb6829
commit f311101ed9
14 changed files with 133 additions and 28 deletions

View File

@@ -1,5 +1,6 @@
import { BrowserApi } from '../browser/browserApi';
import { SafariApp } from '../browser/safariApp';
import { NativeMessagingBackground } from '../background/nativeMessaging.background';
import { DeviceType } from 'jslib/enums/deviceType';
@@ -18,7 +19,8 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
private analyticsIdCache: string = null;
constructor(private messagingService: MessagingService,
private clipboardWriteCallback: (clipboardValue: string, clearMs: number) => void) { }
private clipboardWriteCallback: (clipboardValue: string, clearMs: number) => void,
private nativeMessagingBackground: NativeMessagingBackground) { }
getDevice(): DeviceType {
if (this.deviceCache) {
@@ -288,13 +290,18 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
}
supportsBiometric() {
return Promise.resolve(false);
return Promise.resolve(true);
}
authenticateBiometric() {
return Promise.resolve(false);
}
async authenticateBiometric() {
const responsePromise = this.nativeMessagingBackground.await();
this.nativeMessagingBackground.send({'command': 'biometricUnlock'});
const response = await responsePromise;
return response.response == 'unlocked';
}
sidebarViewName(): string {
if ((window as any).chrome.sidebarAction && this.isFirefox()) {
return 'sidebar';