Merge branch 'pass-lifetime-fixes' into 'main'
[ProtonMail-WebClient.git] / applications / pass-desktop / src / lib / biometrics / index.ts
blob16070b7acef7712499d1ecab7303708fed7121c0
1 import { ipcMain } from 'electron';
2 import { platform } from 'os';
4 import type { BiometricsFactory, BiometricsPlatformHandler } from './types';
6 const factory: BiometricsFactory = (getWindow) => {
7     const platformImplementation: BiometricsPlatformHandler = (() => {
8         switch (platform()) {
9             case 'win32':
10                 return (require('./biometrics.windows').default as BiometricsFactory)(getWindow);
11             case 'darwin':
12                 return (require('./biometrics.macos').default as BiometricsFactory)(getWindow);
13             default:
14                 return {
15                     canCheckPresence: () => Promise.resolve(false),
16                     checkPresence: () => Promise.reject('Not implemented'),
17                     getDecryptionKey: () => Promise.reject('Not implemented'),
18                     getSecret: () => Promise.reject('Not implemented'),
19                     deleteSecret: () => Promise.reject('Not implemented'),
20                     setSecret: () => Promise.reject('Not implemented'),
21                 };
22         }
23     })();
25     ipcMain.handle('biometrics:canCheckPresence', platformImplementation.canCheckPresence);
26     ipcMain.handle('biometrics:checkPresence', platformImplementation.checkPresence);
27     ipcMain.handle('biometrics:getDecryptionKey', platformImplementation.getDecryptionKey);
28     ipcMain.handle('biometrics:getSecret', platformImplementation.getSecret);
29     ipcMain.handle('biometrics:setSecret', platformImplementation.setSecret);
30     ipcMain.handle('biometrics:deleteSecret', platformImplementation.deleteSecret);
32     return platformImplementation;
35 export default factory;