1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-09 09:51:02 +01:00

Conditional load of biometrics API on Win10+ (#169)

* Conditional load of biometrics API on Win10+

* consolidate if block

* Return -1 instead of null
This commit is contained in:
Chad Scharf 2020-09-17 15:36:11 -04:00 committed by GitHub
parent 5e0a2d1d99
commit 27bcbf4b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,7 @@ export default class BiometricWindowsMain implements BiometricMain {
getWindowsSecurityCredentialsUiModule(): any { getWindowsSecurityCredentialsUiModule(): any {
try { try {
if (this.windowsSecurityCredentialsUiModule == null) { if (this.windowsSecurityCredentialsUiModule == null && this.getWindowsMajorVersion() >= 10) {
this.windowsSecurityCredentialsUiModule = require('@nodert-win10-rs4/windows.security.credentials.ui'); this.windowsSecurityCredentialsUiModule = require('@nodert-win10-rs4/windows.security.credentials.ui');
} }
return this.windowsSecurityCredentialsUiModule; return this.windowsSecurityCredentialsUiModule;
@ -110,4 +110,16 @@ export default class BiometricWindowsMain implements BiometricMain {
} catch { /*Ignore error*/ } } catch { /*Ignore error*/ }
return []; return [];
} }
getWindowsMajorVersion(): number {
if (process.platform !== 'win32') {
return -1;
}
try {
const version = require('os').release();
return Number.parseInt(version.split('.')[0], 10);
}
catch { }
return -1;
}
} }