// Browser host-shim for the Hermes messenger panel. // // The panel UI (panel.html inside Theseus) talks to the Theseus main process // over an IPC bridge exposed as window.silentmode. This shim re-implements // that bridge in a plain browser tab: NIP-17 wrap/unwrap with nostr-tools, // Nostr pubkey + relay lookup via navigate.st/api/name, inbox + contacts in // localStorage. // // Why this works at all: the panel calls bridge.invoke(name, payload) and // awaits a promise, and subscribes with bridge.on(channel, cb). Every op is // a pure function of the panel's state, the user's secret key, and a WSS // connection — no Node, no filesystem, no Electron. The real Theseus host // adds vault binding, mnemonic persistence and backup; the browser can // never promise any of that, so the shim stubs those paths and surfaces an // honest error when the panel asks. // // Scope v0 (2026-10-21): // - nsec1… paste and BIP-39 12/24-word paste both go in `mnemonicInput` // - one default relay: wss://nos.lol (matches Theseus HERMES_DEFAULT_RELAYS) // - send resolves `alice.x` → np+nr via /api/name // - receive via a single long-lived REQ subscription // - inbox + contacts in localStorage, scoped by `hermes..*` // - no profile fetch (truncated pkHex shows); phone/backup/vault stubbed // // Keep this file plain classic script. The panel's own