From e06e9ac1f8dd6ad2ee3bd67fbf1f43b5c963f78b Mon Sep 17 00:00:00 2001 From: antelle Date: Sun, 18 Apr 2021 11:50:11 +0200 Subject: [PATCH] moved ipc handlers setup to corresponding files --- .../browser-extension-connector.js | 4 ++++ .../scripts/ipc-handlers/hardware-crypto.js | 11 +++++------ .../ipc-handlers/native-module-host-proxy.js | 3 +++ desktop/scripts/ipc-handlers/spawn-process.js | 5 ++--- desktop/scripts/ipc.js | 18 ++++-------------- 5 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 desktop/scripts/ipc-handlers/browser-extension-connector.js diff --git a/desktop/scripts/ipc-handlers/browser-extension-connector.js b/desktop/scripts/ipc-handlers/browser-extension-connector.js new file mode 100644 index 00000000..b09340e1 --- /dev/null +++ b/desktop/scripts/ipc-handlers/browser-extension-connector.js @@ -0,0 +1,4 @@ +const { ipcMain } = require('electron'); + +ipcMain.handle('browserExtensionConnectorStart', () => {}); +ipcMain.handle('browserExtensionConnectorStop', () => {}); diff --git a/desktop/scripts/ipc-handlers/hardware-crypto.js b/desktop/scripts/ipc-handlers/hardware-crypto.js index bc5a2b59..08293d48 100644 --- a/desktop/scripts/ipc-handlers/hardware-crypto.js +++ b/desktop/scripts/ipc-handlers/hardware-crypto.js @@ -1,17 +1,16 @@ +const { ipcMain } = require('electron'); const { readXoredValue, makeXoredValue } = require('../util/byte-utils'); const { reqNative } = require('../util/req-native'); +ipcMain.handle('hardwareCryptoDeleteKey', hardwareCryptoDeleteKey); +ipcMain.handle('hardwareEncrypt', hardwareEncrypt); +ipcMain.handle('hardwareDecrypt', hardwareDecrypt); + const keyTag = 'net.antelle.keeweb.encryption-key'; let testCipherParams; let keyChecked = false; -module.exports = { - hardwareCryptoDeleteKey, - hardwareEncrypt, - hardwareDecrypt -}; - async function hardwareCryptoDeleteKey() { const secureEnclave = reqNative('secure-enclave'); await secureEnclave.deleteKeyPair({ keyTag }); diff --git a/desktop/scripts/ipc-handlers/native-module-host-proxy.js b/desktop/scripts/ipc-handlers/native-module-host-proxy.js index b2b51bcc..a372dc96 100644 --- a/desktop/scripts/ipc-handlers/native-module-host-proxy.js +++ b/desktop/scripts/ipc-handlers/native-module-host-proxy.js @@ -1,7 +1,10 @@ +const { ipcMain } = require('electron'); const path = require('path'); const { spawn } = require('child_process'); const { EventEmitter } = require('events'); +ipcMain.on('nativeModuleCall', nativeModuleCall); + let callbackWebContents; let nativeModuleHost; diff --git a/desktop/scripts/ipc-handlers/spawn-process.js b/desktop/scripts/ipc-handlers/spawn-process.js index 81d2237c..f8a20e3e 100644 --- a/desktop/scripts/ipc-handlers/spawn-process.js +++ b/desktop/scripts/ipc-handlers/spawn-process.js @@ -1,8 +1,7 @@ +const { ipcMain } = require('electron'); const { spawn } = require('child_process'); -module.exports = { - spawnProcess -}; +ipcMain.handle('spawnProcess', spawnProcess); function spawnProcess(e, config) { return new Promise((resolve) => { diff --git a/desktop/scripts/ipc.js b/desktop/scripts/ipc.js index d0aaad59..01ee2354 100644 --- a/desktop/scripts/ipc.js +++ b/desktop/scripts/ipc.js @@ -1,16 +1,6 @@ -const { ipcMain } = require('electron'); -const { - hardwareCryptoDeleteKey, - hardwareEncrypt, - hardwareDecrypt -} = require('./ipc-handlers/hardware-crypto'); -const { spawnProcess } = require('./ipc-handlers/spawn-process'); -const { nativeModuleCall } = require('./ipc-handlers/native-module-host-proxy'); - module.exports.setupIpcHandlers = () => { - ipcMain.handle('hardwareCryptoDeleteKey', hardwareCryptoDeleteKey); - ipcMain.handle('hardwareEncrypt', hardwareEncrypt); - ipcMain.handle('hardwareDecrypt', hardwareDecrypt); - ipcMain.handle('spawnProcess', spawnProcess); - ipcMain.on('nativeModuleCall', nativeModuleCall); + require('./ipc-handlers/browser-extension-connector'); + require('./ipc-handlers/hardware-crypto'); + require('./ipc-handlers/native-module-host-proxy'); + require('./ipc-handlers/spawn-process'); };