/** * Electron sudo backend. * * When node-server runs *inside* an Electron main process (`process.versions * .electron` is set), the native gesture is `dialog.showMessageBox` with three * buttons (Deny / Allow Once / Always). On "Always" an editable pattern is * captured via {@link ElectronBackendDeps.promptInput}; the default * implementation runs `window.prompt` inside a transient offscreen * `BrowserWindow`. Both seams are injectable so tests never touch Electron. * * Fail closed: a thrown dialog call, a cancelled prompt, or an unknown button * resolves to `deny` / falls back to the suggested pattern. */ import type { SudoBackend } from './types.js'; /** Result shape of `dialog.showMessageBox`. */ interface MessageBoxResult { response: number; } /** Injection seams. */ export interface ElectronBackendDeps { /** Raise a modal message box; resolves the clicked button index. */ showMessageBox?: (options: { type: string; buttons: string[]; defaultId: number; cancelId: number; title: string; message: string; detail: string; }) => Promise; /** Capture an editable pattern; resolves null on cancel. */ promptInput?: (message: string, defaultValue: string) => Promise; } /** Create the Electron backend. */ export declare function createElectronBackend(deps?: ElectronBackendDeps): SudoBackend; export {};