diff --git a/package.json b/package.json index adc20e85..23217e37 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "node_modules/@json2csv/plainjs/dist/**/*", "node_modules/@json2csv/formatters/dist/**/*", "node_modules/@json2csv/transforms/dist/**/*", - "node_modules/@streamparser/json/dist/**/*" + "node_modules/@streamparser/json/dist/**/*", + "node_modules/node-mac-auth/build/Release/auth.node" ] }, "scripts": { diff --git a/src/command-handlers/configure.ts b/src/command-handlers/configure.ts index 12a04963..ca97bb55 100644 --- a/src/command-handlers/configure.ts +++ b/src/command-handlers/configure.ts @@ -1,5 +1,4 @@ import winston from 'winston'; -import { canPromptTouchID } from 'node-mac-auth'; import { encryptAesCbcHmac256 } from '../modules/crypto/encrypt'; import { deleteLocalKey, setLocalKey, warnUnreachableKeychainDisabled } from '../modules/crypto/keychainManager'; import { connectAndPrepare } from '../modules/database'; @@ -71,8 +70,13 @@ export const configureUserPresenceVerification = async (options: { const { method } = options; const { db, localConfiguration } = await connectAndPrepare({ autoSync: false }); - if (method === 'biometrics' && !canPromptTouchID()) { - throw new Error('Biometrics are not supported on your device.'); + if (method === 'biometrics') { + if (process.platform === 'darwin') { + const { canPromptTouchID } = await import('node-mac-auth'); + if (!canPromptTouchID()) { + throw new Error('Biometrics are not supported on your device.'); + } + } } db.prepare('UPDATE device SET userPresenceVerification = ? WHERE login = ?') diff --git a/src/modules/auth/userPresenceVerification.ts b/src/modules/auth/userPresenceVerification.ts index 6c7099a3..a2124d2a 100644 --- a/src/modules/auth/userPresenceVerification.ts +++ b/src/modules/auth/userPresenceVerification.ts @@ -1,4 +1,3 @@ -import { promptTouchID, canPromptTouchID } from 'node-mac-auth'; import { DeviceConfiguration } from '../../types'; export const userPresenceVerification = async (params: { deviceConfiguration: DeviceConfiguration | null }) => { @@ -13,15 +12,18 @@ export const userPresenceVerification = async (params: { deviceConfiguration: De } if (deviceConfiguration.userPresenceVerification === 'biometrics') { - if (canPromptTouchID()) { - return promptTouchID({ - reason: 'validate your identity before accessing your vault', - reuseDuration: 60, // 1min - dies when program closes - }).catch((error) => { - throw new Error(`Touch ID verification failed: ${error}`); - }); + if (process.platform === 'darwin') { + const { canPromptTouchID, promptTouchID } = await import('node-mac-auth'); + if (canPromptTouchID()) { + return promptTouchID({ + reason: 'validate your identity before accessing your vault', + reuseDuration: 60, // 1min - dies when program closes + }).catch((error) => { + throw new Error(`Touch ID verification failed: ${error}`); + }); + } } else { - throw new Error('Biometrics are not supported on your device.'); + throw new Error('Biometrics are only supported on macos for now.'); } } };