From 27bcbf4b41373f8fbd3941c8ea6645414dac4fdd Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Thu, 17 Sep 2020 15:36:11 -0400 Subject: [PATCH] Conditional load of biometrics API on Win10+ (#169) * Conditional load of biometrics API on Win10+ * consolidate if block * Return -1 instead of null --- src/electron/biometric.windows.main.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/electron/biometric.windows.main.ts b/src/electron/biometric.windows.main.ts index 1d9f3df008..316110b5ec 100644 --- a/src/electron/biometric.windows.main.ts +++ b/src/electron/biometric.windows.main.ts @@ -48,7 +48,7 @@ export default class BiometricWindowsMain implements BiometricMain { getWindowsSecurityCredentialsUiModule(): any { try { - if (this.windowsSecurityCredentialsUiModule == null) { + if (this.windowsSecurityCredentialsUiModule == null && this.getWindowsMajorVersion() >= 10) { this.windowsSecurityCredentialsUiModule = require('@nodert-win10-rs4/windows.security.credentials.ui'); } return this.windowsSecurityCredentialsUiModule; @@ -110,4 +110,16 @@ export default class BiometricWindowsMain implements BiometricMain { } catch { /*Ignore error*/ } 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; + } }