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:
+147
@@ -0,0 +1,147 @@
|
||||
// German first (the launch region is Germany), English as fallback.
|
||||
|
||||
const de = {
|
||||
"app.tagline": "Wohnungen und Häuser, getragen von allen. Kostenlos, ohne Konzern.",
|
||||
"status.line": "{listings} Anzeigen · {peers} verbundene Knoten · Regionen: {regions}",
|
||||
"status.unreachable": "Dieser Knoten ist nicht erreichbar.",
|
||||
"filter.kind": "Angebot",
|
||||
"filter.category": "Art",
|
||||
"filter.region": "Gebiet (Geohash)",
|
||||
"filter.regionHint": "z. B. u1x für den Raum Hamburg, genauer: u1xj",
|
||||
"filter.maxPrice": "Preis bis (€)",
|
||||
"filter.minArea": "Fläche ab (m²)",
|
||||
"filter.minRooms": "Zimmer ab",
|
||||
"filter.any": "Alle",
|
||||
"filter.search": "Suchen",
|
||||
"filter.reset": "Zurücksetzen",
|
||||
"kind.rent": "Miete",
|
||||
"kind.sale": "Kauf",
|
||||
"cat.apartment": "Wohnung",
|
||||
"cat.house": "Haus",
|
||||
"cat.room": "Zimmer",
|
||||
"cat.commercial": "Gewerbe",
|
||||
"results.none": "Keine Anzeigen gefunden.",
|
||||
"results.loading": "Lädt …",
|
||||
"results.more": "Mehr laden",
|
||||
"results.hidden": "{n} Ergebnis(se) ausgeblendet, weil die Signatur nicht geprüft werden konnte.",
|
||||
"results.error": "Die Suche ist fehlgeschlagen.",
|
||||
"card.perMonth": "/ Monat",
|
||||
"card.rooms": "{n} Zimmer",
|
||||
"card.area": "{n} m²",
|
||||
"badge.ok": "Signatur geprüft",
|
||||
"badge.bad": "Nicht verifiziert",
|
||||
"detail.back": "← Zurück zur Suche",
|
||||
"detail.notFound": "Diese Anzeige gibt es nicht (mehr).",
|
||||
"detail.unverified":
|
||||
"Diese Anzeige konnte nicht verifiziert werden und wird deshalb nicht angezeigt. Sie könnte gefälscht oder verändert sein.",
|
||||
"detail.features": "Ausstattung",
|
||||
"detail.facts": "Eckdaten",
|
||||
"detail.kind": "Angebot",
|
||||
"detail.category": "Art",
|
||||
"detail.area": "Fläche",
|
||||
"detail.rooms": "Zimmer",
|
||||
"detail.published": "Veröffentlicht",
|
||||
"detail.expires": "Läuft ab",
|
||||
"detail.version": "Version",
|
||||
"detail.location": "Lage (ungefähr, ca. 1 km)",
|
||||
"detail.map": "Auf OpenStreetMap ansehen (externe Seite)",
|
||||
"detail.contact": "Kontakt",
|
||||
"detail.contactSoon":
|
||||
"Der Kontakt zum Anbieter läuft über dessen eigenen Knoten und ist noch nicht verfügbar. Die genaue Adresse wird nie öffentlich verteilt.",
|
||||
"verify.title": "Prüfung in deinem Browser",
|
||||
"verify.intro":
|
||||
"Diese Prüfung läuft lokal, nicht auf dem Server. Ein Knoten kann Anzeigen also nicht unbemerkt fälschen.",
|
||||
"verify.limit":
|
||||
"Nicht prüfbar: ob der Anbieter sein Gerät inzwischen gesperrt hat. Das weiß nur das Netzwerk; dein Knoten kennt den aktuellen Stand.",
|
||||
"verify.format": "Aufbau der Anzeige",
|
||||
"verify.certificate": "Gerätezertifikat des Anbieters ist gültig",
|
||||
"verify.binding": "Zertifikat gehört zu diesem Anbieter und Gerät",
|
||||
"verify.validity": "Zeiträume (Zertifikat, Anzeige) stimmen",
|
||||
"verify.signature": "Signatur passt zum Inhalt",
|
||||
"verify.pow": "Rechenaufwand gegen Spam (Proof-of-Work)",
|
||||
"verify.owner": "Anbieter (Identität)",
|
||||
"verify.device": "Gerät",
|
||||
"verify.raw": "Rohdaten (so signiert)",
|
||||
"footer.text":
|
||||
"Allmende ist freie Software (AGPL-3.0). Es gibt keinen Betreiber und keine Gebühren.",
|
||||
} as const;
|
||||
|
||||
const en: Record<keyof typeof de, string> = {
|
||||
"app.tagline": "Homes to rent and buy, run by everyone. Free, with no company behind it.",
|
||||
"status.line": "{listings} listings · {peers} connected nodes · regions: {regions}",
|
||||
"status.unreachable": "This node is not reachable.",
|
||||
"filter.kind": "Offer",
|
||||
"filter.category": "Type",
|
||||
"filter.region": "Area (geohash)",
|
||||
"filter.regionHint": "e.g. u1x for the Hamburg area, more precise: u1xj",
|
||||
"filter.maxPrice": "Price up to (€)",
|
||||
"filter.minArea": "Area from (m²)",
|
||||
"filter.minRooms": "Rooms from",
|
||||
"filter.any": "Any",
|
||||
"filter.search": "Search",
|
||||
"filter.reset": "Reset",
|
||||
"kind.rent": "Rent",
|
||||
"kind.sale": "Buy",
|
||||
"cat.apartment": "Apartment",
|
||||
"cat.house": "House",
|
||||
"cat.room": "Room",
|
||||
"cat.commercial": "Commercial",
|
||||
"results.none": "No listings found.",
|
||||
"results.loading": "Loading …",
|
||||
"results.more": "Load more",
|
||||
"results.hidden": "{n} result(s) hidden because their signature could not be verified.",
|
||||
"results.error": "The search failed.",
|
||||
"card.perMonth": "/ month",
|
||||
"card.rooms": "{n} rooms",
|
||||
"card.area": "{n} m²",
|
||||
"badge.ok": "Signature verified",
|
||||
"badge.bad": "Not verified",
|
||||
"detail.back": "← Back to search",
|
||||
"detail.notFound": "This listing does not exist (any more).",
|
||||
"detail.unverified":
|
||||
"This listing could not be verified and is therefore not shown. It may be forged or altered.",
|
||||
"detail.features": "Features",
|
||||
"detail.facts": "Key facts",
|
||||
"detail.kind": "Offer",
|
||||
"detail.category": "Type",
|
||||
"detail.area": "Area",
|
||||
"detail.rooms": "Rooms",
|
||||
"detail.published": "Published",
|
||||
"detail.expires": "Expires",
|
||||
"detail.version": "Version",
|
||||
"detail.location": "Location (approximate, about 1 km)",
|
||||
"detail.map": "View on OpenStreetMap (external site)",
|
||||
"detail.contact": "Contact",
|
||||
"detail.contactSoon":
|
||||
"Contact goes through the owner's own node and is not available yet. The exact address is never distributed publicly.",
|
||||
"verify.title": "Checked in your browser",
|
||||
"verify.intro":
|
||||
"This check runs locally, not on the server, so a node cannot forge listings unnoticed.",
|
||||
"verify.limit":
|
||||
"Cannot be checked: whether the owner has since revoked their device. Only the network knows that; your node has the current state.",
|
||||
"verify.format": "Structure of the listing",
|
||||
"verify.certificate": "Owner's device certificate is valid",
|
||||
"verify.binding": "Certificate belongs to this owner and device",
|
||||
"verify.validity": "Time windows (certificate, listing) are right",
|
||||
"verify.signature": "Signature matches the content",
|
||||
"verify.pow": "Anti-spam work (proof-of-work)",
|
||||
"verify.owner": "Owner (identity)",
|
||||
"verify.device": "Device",
|
||||
"verify.raw": "Raw data (as signed)",
|
||||
"footer.text": "Allmende is free software (AGPL-3.0). There is no operator and there are no fees.",
|
||||
};
|
||||
|
||||
export type Key = keyof typeof de;
|
||||
|
||||
function detect(): "de" | "en" {
|
||||
const q = new URLSearchParams(location.search).get("lang");
|
||||
if (q === "de" || q === "en") return q;
|
||||
return navigator.language?.toLowerCase().startsWith("de") ? "de" : "en";
|
||||
}
|
||||
|
||||
export const lang = detect();
|
||||
const dict: Record<Key, string> = lang === "de" ? de : en;
|
||||
|
||||
export function t(key: Key, vars: Record<string, string | number> = {}): string {
|
||||
return dict[key].replace(/\{(\w+)\}/g, (_, name: string) => String(vars[name] ?? ""));
|
||||
}
|
||||
Reference in New Issue
Block a user