Add browser UI with in-browser signature verification

Every node now serves a search and listing-detail UI at GET /. It is
vanilla TypeScript, bundled unminified into web/dist (committed) and
embedded with go:embed, so `go build` is enough to run a node.

The browser verifies each listing itself (certificate, binding, validity,
signature, proof-of-work) with pure-JS ed25519, so a gateway can withhold
listings but not forge them. Unverifiable results are hidden and their
content is never shown. Listing text is only inserted via textContent and
the UI is served with a strict CSP.

Canonical JSON is reimplemented in TypeScript and tested against a golden
fixture signed by the Go code. /api/v1/status now reports difficulty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 18:29:40 +01:00
co-authored by Claude Sonnet 5.5
parent 918e16ed37
commit 3fd40241bc
30 changed files with 6418 additions and 5 deletions
+35
View File
@@ -0,0 +1,35 @@
// Geohash decoding, only to show where a listing roughly is.
const ALPHABET = "0123456789bcdefghjkmnpqrstuvwxyz";
export interface Area {
lat: number;
lon: number;
/** Half the height and width of the cell, in degrees. */
latErr: number;
lonErr: number;
}
export function decodeGeohash(hash: string): Area | null {
let lat: [number, number] = [-90, 90];
let lon: [number, number] = [-180, 180];
let evenBit = true;
for (const ch of hash) {
const idx = ALPHABET.indexOf(ch);
if (idx < 0) return null;
for (let bit = 4; bit >= 0; bit--) {
const on = (idx >> bit) & 1;
const range = evenBit ? lon : lat;
const mid = (range[0] + range[1]) / 2;
if (on) range[0] = mid;
else range[1] = mid;
evenBit = !evenBit;
}
}
return {
lat: (lat[0] + lat[1]) / 2,
lon: (lon[0] + lon[1]) / 2,
latErr: (lat[1] - lat[0]) / 2,
lonErr: (lon[1] - lon[0]) / 2,
};
}