theseus/unlock-preload.js

11 lines
657 B
JavaScript
Raw Normal View History

// Preload for the vault unlock overlay (unlock.html). Main pushes one request
// via `unlock-show`; the page sends a PIN or the master password back with
// `unlock-submit` and main checks it. The secret goes straight to main — it
// is never handed to the add-on that asked for the unlock.
const { contextBridge, ipcRenderer } = require("electron");
contextBridge.exposeInMainWorld("unlock", {
onShow: (cb) => ipcRenderer.on("unlock-show", (_e, req) => cb(req)),
submit: (reqId, mode, value) => ipcRenderer.invoke("unlock-submit", reqId, String(mode || ""), String(value || "")),
cancel: (reqId) => ipcRenderer.invoke("unlock-cancel", reqId),
});