Two problems bundled into the branded error page: 1) "fetch failed" on no network — the tab kept falling through to name-not-registered (and other "we asked and got nothing" verdicts) because a totally offline browser can't reach the beacon to know. Add a first-class `offline` kind that runs before every other verdict: navigator.onLine === false wins; the page says "You appear to be offline" and keeps the address so the user can Retry after reconnecting. 2) Typos on BCNR names (games.x when they meant game.x) — the page only offered Search / Register. Now the page asks main for the top near-matches from the warm sharedIndex (Levenshtein ≤ 2, same TLD) over an origin-gated `error-bns-similar` IPC. Up to three matches render as chip-links; clicking one retries at that host, preserving the original path. Works offline too — the index is local. Origin-gate on the IPC uses the existing isErrorPageSender check, and error-preload.js exposes only the invoke — no arbitrary index access.
12 lines
740 B
JavaScript
12 lines
740 B
JavaScript
const { contextBridge, ipcRenderer } = require("electron");
|
|
// Renderer -> main API for the branded error page. All calls are user-initiated
|
|
// button clicks; main validates the sender before acting so a hostile page
|
|
// can't drive navigation by loading window.errorpage.
|
|
contextBridge.exposeInMainWorld("errorpage", {
|
|
retry: (url) => ipcRenderer.invoke("error-retry", url),
|
|
goHome: () => ipcRenderer.invoke("error-home"),
|
|
searchFor: (text) => ipcRenderer.invoke("error-search", text),
|
|
registerOnSirius: (host) => ipcRenderer.invoke("error-register", host),
|
|
openExternal: (url) => ipcRenderer.invoke("error-open-external", url),
|
|
bnsSimilar: (host) => ipcRenderer.invoke("error-bns-similar", host),
|
|
});
|