1// A NIP-07 stand-in for browser testing without an extension: signs with a2// fixed key over HTTP. Start it, then in the page's devtools console run:3//4// window.nostr = { getPublicKey: async () => (await (await fetch('http://127.0.0.1:9999/pk')).text()),5// signEvent: async (e) => (await fetch('http://127.0.0.1:9999/sign', { method: 'POST', body: JSON.stringify(e) })).json() };6//7// Never use this key for anything real.8import { createServer } from "node:http";9import { finalizeEvent, getPublicKey } from "nostr-tools/pure";10const sk = new Uint8Array(32).fill(7);11createServer(async (req, res) => {12 res.setHeader("access-control-allow-origin", "*");13 res.setHeader("access-control-allow-headers", "content-type");14 if (req.method === "OPTIONS") return res.end();15 if (req.url === "/pk") return res.end(getPublicKey(sk));16 let body = "";17 for await (const c of req) body += c;18 res.setHeader("content-type", "application/json");19 res.end(JSON.stringify(finalizeEvent(JSON.parse(body), sk)));20}).listen(9999, () => console.log("signer on 9999"));