theseus/approval-preload.js

10 lines
541 B
JavaScript
Raw Normal View History

// Preload for the add-on approval overlay (approval.html). Main pushes one
// request at a time via `approval-show`; the page answers with the chosen
// action id through `approval-pick`. Nothing else is exposed — the overlay
// is a pure consent surface.
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("approval", {
onShow: (cb) => ipcRenderer.on("approval-show", (_e, req) => cb(req)),
pick: (reqId, action, checked) => ipcRenderer.invoke("approval-pick", reqId, action, !!checked),
});