From c3cba4d9b3a7dfbf5f366bb83e2805b687bd4f4f Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sun, 17 Dec 2023 14:05:48 +0100 Subject: [PATCH] feat(electronSecurity): make on method more secure --- electron/preload.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/electron/preload.ts b/electron/preload.ts index a39f1270f5..90f9dc3eed 100644 --- a/electron/preload.ts +++ b/electron/preload.ts @@ -12,9 +12,10 @@ const _invoke: (channel: IPCEventValue, ...args: any[]) => Promise = ( ) => ipcRenderer.invoke(channel, ...args); const ea: ElectronAPI = { - on: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void) => - ipcRenderer.on(channel, listener), - + on: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void) => { + // NOTE: there is no proper way to unsubscribe apart from unsusbscribing all + ipcRenderer.on(channel, listener); + }, // INVOKE // ------ getUserDataPath: () => _invoke('GET_PATH', 'userData') as Promise,