Three opt-in capabilities for add-ons, plus the plumbing they need:
- vault-derive: api.vault.derive("<id>/<path>") resolves once the password
vault is unlocked with a 32-byte HKDF child of the vault root under
"silentmode/addons/<path>". Path must start with the add-on id.
- page-inject: manifest "page-inject" {preload, origins}; a session-wide
preload asks main (sync, against the committed URL) which add-on bridges
apply and runs them in the isolated world with a scoped `theseus` object.
- approval-modal: api.approvalModal({title, body, origin, rows, actions,
checkbox}) shows a consent overlay over the tab area (approval.html);
resolves to the picked action id, "cancel", or "<id>+<checkbox>".
- api.onMessage/emit + window.silentmode.invoke/on for panel <-> activate()
messaging; page bridges use addon-page-msg, gated by tab + origin match.
- api.require so add-ons can share Theseus's dependency tree.
9 lines
541 B
JavaScript
9 lines
541 B
JavaScript
// 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),
|
|
});
|