mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 01:03:35 +00:00
Split jslib into multiple modules (#363)
* Split jslib into multiple modules
This commit is contained in:
35
electron/src/biometric.darwin.main.ts
Normal file
35
electron/src/biometric.darwin.main.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { I18nService, StorageService } from 'jslib-common/abstractions';
|
||||
|
||||
import { ipcMain, systemPreferences } from 'electron';
|
||||
import { BiometricMain } from 'jslib-common/abstractions/biometric.main';
|
||||
import { ConstantsService } from 'jslib-common/services/constants.service';
|
||||
import { ElectronConstants } from './electronConstants';
|
||||
|
||||
export default class BiometricDarwinMain implements BiometricMain {
|
||||
isError: boolean = false;
|
||||
|
||||
constructor(private storageService: StorageService, private i18nservice: I18nService) {}
|
||||
|
||||
async init() {
|
||||
this.storageService.save(ElectronConstants.enableBiometric, await this.supportsBiometric());
|
||||
this.storageService.save(ConstantsService.biometricText, 'unlockWithTouchId');
|
||||
this.storageService.save(ElectronConstants.noAutoPromptBiometricsText, 'noAutoPromptTouchId');
|
||||
|
||||
ipcMain.on('biometric', async (event: any, message: any) => {
|
||||
event.returnValue = await this.requestCreate();
|
||||
});
|
||||
}
|
||||
|
||||
supportsBiometric(): Promise<boolean> {
|
||||
return Promise.resolve(systemPreferences.canPromptTouchID());
|
||||
}
|
||||
|
||||
async requestCreate(): Promise<boolean> {
|
||||
try {
|
||||
await systemPreferences.promptTouchID(this.i18nservice.t('touchIdConsentMessage'));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user