theseus/approval-preload.js
Local Dev 40391798e0 feat(theseus/bchwallet): per-site payment allowance for remembered sends
The dapp send approval gains an "Afterwards" dropdown: ask every time, or
allow up to 0.001 / 0.01 / 0.1 BCH more without asking. The allowance is
stored as permissions[origin].sendTx {capSats, usedSats}; sends within the
remainder go through silently and draw it down, a larger request re-prompts
(showing what is left) and the choice made there replaces the allowance.
No unlimited option. Settings > Connected sites shows the remaining budget
and Revoke clears it. Message signing still asks every time.

Host: approvalModal accepts `select` {id, label, options}; a chosen value
comes back as "+<id>=<value>" and is validated against the offered options.
2026-09-06 12:43:17 +02:00

9 lines
569 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, extra) => ipcRenderer.invoke("approval-pick", reqId, action, !!checked, String(extra || "")),
});