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:
+24
-2
@@ -147,7 +147,29 @@ token written to `admin.token` at init, mode 0600).
|
||||
| `DELETE /api/v1/listings/{id}` | token | publish a tombstone |
|
||||
|
||||
Reads send `Access-Control-Allow-Origin: *` (the data is public). Writes are
|
||||
not cross-origin. Images are not supported yet.
|
||||
not cross-origin. Images are not supported yet. `status` also reports the
|
||||
node's PoW `difficulty`, which the browser uses as its minimum.
|
||||
|
||||
## Web UI (`web/`)
|
||||
|
||||
Every node serves a search UI at `GET /`. It is vanilla TypeScript, bundled by
|
||||
esbuild into `web/dist` (unminified, so it can be read) and **committed**, then
|
||||
embedded with `go:embed`: `go build` is enough to run a node, Node.js is only
|
||||
needed to change the UI (`cd web && npm ci && npm run build`).
|
||||
|
||||
- **Verification in the browser.** Every listing is checked locally with
|
||||
pure-JS ed25519/SHA-256 (works over plain http): format, device certificate,
|
||||
certificate/listing binding, validity windows, signature, proof-of-work.
|
||||
Failing results are hidden (with a count) and their content is never shown.
|
||||
A gateway can therefore withhold listings but not forge them. What a browser
|
||||
cannot know is whether a device was revoked since; the UI says so.
|
||||
- **Canonical JSON** is reimplemented in TypeScript and tested against a
|
||||
fixture signed by the Go code (`internal/listing/testdata/fixture.json`,
|
||||
refresh with `UPDATE_FIXTURES=1 go test ./internal/listing -run Golden`).
|
||||
- **Untrusted text.** Listing text is only ever inserted with `textContent`.
|
||||
The CSP is `default-src 'none'; script-src 'self'; style-src 'self'; ...`
|
||||
(no inline script or style), plus `nosniff` and `no-referrer`.
|
||||
- Publishing is not in the UI yet; it stays on the token-protected API.
|
||||
|
||||
## Running a node (`cmd/node`)
|
||||
|
||||
@@ -166,6 +188,6 @@ Proof-of-work per listing and per revocation, plus subscribable blocklists
|
||||
|
||||
Buyer/seller messaging (E2E, store-and-forward), reciprocity rules, anti-
|
||||
discrimination (AGG) content rules, blocklists, peer scoring and rate limits,
|
||||
incremental sync and anti-entropy, DHT discovery, web UI, image hosting,
|
||||
incremental sync and anti-entropy, DHT discovery, UI publishing, image hosting,
|
||||
recovering listings onto a fresh machine with an empty database, a helper to
|
||||
turn a place name into a region.
|
||||
|
||||
Reference in New Issue
Block a user