From dc743355fb56ec3c6ef44ec56d435d1c748e2cb6 Mon Sep 17 00:00:00 2001 From: neuronull <9162534+neuronull@users.noreply.github.com> Date: Wed, 29 Oct 2025 09:48:45 -0600 Subject: [PATCH] improve IPC message args --- .../autofill/main/main-desktop-autotype.service.ts | 11 ++++++----- .../desktop/src/autofill/models/autotype-configure.ts | 3 +++ apps/desktop/src/autofill/preload.ts | 8 +++++--- .../src/autofill/services/desktop-autotype.service.ts | 7 ++++++- 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 apps/desktop/src/autofill/models/autotype-configure.ts diff --git a/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts b/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts index f19ec12f8a2..1b688672c5b 100644 --- a/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts +++ b/apps/desktop/src/autofill/main/main-desktop-autotype.service.ts @@ -5,6 +5,7 @@ import { LogService } from "@bitwarden/logging"; import { WindowMain } from "../../main/window.main"; import { stringIsNotUndefinedNullAndEmpty } from "../../utils"; +import { AutotypeConfig } from "../models/autotype-configure"; import { AutotypeKeyboardShortcut } from "../models/main-autotype-keyboard-shortcut"; export class MainDesktopAutotypeService { @@ -27,17 +28,17 @@ export class MainDesktopAutotypeService { } init() { - ipcMain.on("autofill.toggleAutotype", (event, data) => { - if (data.enable) { + ipcMain.on("autofill.toggleAutotype", (_event, enable: boolean) => { + if (enable) { this.enableAutotype(); } else { this.disableAutotype(); } }); - ipcMain.on("autofill.configureAutotype", (event, data) => { + ipcMain.on("autofill.configureAutotype", (_event, config: AutotypeConfig) => { const newKeyboardShortcut = new AutotypeKeyboardShortcut(); - const newKeyboardShortcutIsValid = newKeyboardShortcut.set(data.keyboardShortcut); + const newKeyboardShortcutIsValid = newKeyboardShortcut.set(config.keyboardShortcut); if (!newKeyboardShortcutIsValid) { this.logService.error("Configure autotype failed: the keyboard shortcut is invalid."); @@ -47,7 +48,7 @@ export class MainDesktopAutotypeService { this.setKeyboardShortcut(newKeyboardShortcut); }); - ipcMain.on("autofill.completeAutotypeRequest", (event, data) => { + ipcMain.on("autofill.completeAutotypeRequest", (_event, data) => { const { response } = data; if ( diff --git a/apps/desktop/src/autofill/models/autotype-configure.ts b/apps/desktop/src/autofill/models/autotype-configure.ts new file mode 100644 index 00000000000..dda39023c8c --- /dev/null +++ b/apps/desktop/src/autofill/models/autotype-configure.ts @@ -0,0 +1,3 @@ +export interface AutotypeConfig { + keyboardShortcut: string[]; +} diff --git a/apps/desktop/src/autofill/preload.ts b/apps/desktop/src/autofill/preload.ts index 4709b63cc26..7db01b122ce 100644 --- a/apps/desktop/src/autofill/preload.ts +++ b/apps/desktop/src/autofill/preload.ts @@ -5,6 +5,8 @@ import type { autofill } from "@bitwarden/desktop-napi"; import { Command } from "../platform/main/autofill/command"; import { RunCommandParams, RunCommandResult } from "../platform/main/autofill/native-autofill.main"; +import { AutotypeConfig } from "./models/autotype-configure"; + export default { runCommand: (params: RunCommandParams): Promise> => ipcRenderer.invoke("autofill.runCommand", params), @@ -133,11 +135,11 @@ export default { autotypeIsInitialized: () => { return ipcRenderer.invoke("autofill.autotypeIsInitialized"); }, - configureAutotype: (keyboardShortcut: string[]) => { - ipcRenderer.send("autofill.configureAutotype", { keyboardShortcut }); + configureAutotype: (config: AutotypeConfig) => { + ipcRenderer.send("autofill.configureAutotype", config); }, toggleAutotype: (enable: boolean) => { - ipcRenderer.send("autofill.toggleAutotype", { enable }); + ipcRenderer.send("autofill.toggleAutotype", enable); }, listenAutotypeRequest: ( fn: ( diff --git a/apps/desktop/src/autofill/services/desktop-autotype.service.ts b/apps/desktop/src/autofill/services/desktop-autotype.service.ts index 4d3bd9d22d3..a86b3e5070c 100644 --- a/apps/desktop/src/autofill/services/desktop-autotype.service.ts +++ b/apps/desktop/src/autofill/services/desktop-autotype.service.ts @@ -26,6 +26,8 @@ import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.servi import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { UserId } from "@bitwarden/user-core"; +import { AutotypeConfig } from "../models/autotype-configure"; + import { DesktopAutotypeDefaultSettingPolicy } from "./desktop-autotype-policy.service"; export const defaultWindowsAutotypeKeyboardShortcut: string[] = ["Control", "Shift", "B"]; @@ -122,7 +124,10 @@ export class DesktopAutotypeService { this.autotypeKeyboardShortcut$ .pipe( concatMap(async (keyboardShortcut) => { - ipc.autofill.configureAutotype(keyboardShortcut); + const config: AutotypeConfig = { + keyboardShortcut, + }; + ipc.autofill.configureAutotype(config); }), ) .subscribe();