Repository navigation
feat: 单文件——每个房间文件都能离线生成新房间,同时是网站和中继服务器 - #7
Merged
Merged
Conversation
Room files gain a 更换中继 panel that re-emits the same room (master or wrapped key untouched, no password needed) with a new relay list and exact CSP connect-src. The hosted maker converts existing files, and the CLI gains a retarget command. All three paths produce byte-identical output that passes verify-room-file. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
1. Relay-agnostic transport (version 3 rooms)
- Relay entries bc+wss://, nostr+wss://, mqtt+wss:// select version 3;
classic wss:// rooms stay version 2, unchanged. Retarget converts
between them with the same key, password and roomId.
- html-room/mesh.js: members admit (AES-GCM frames under a master-derived
key), number (announce, claim, earliest claim wins), list and attribute
each other; relays only forward. Every frame goes to every relay and is
de-duplicated by IV, so one surviving relay keeps the room together.
- Node server and Cloudflare Worker serve /bc/<topic> plain broadcast.
2. Easier relays
- relay/go: dependency-free Go broadcast relay, one ~6 MB binary for
Windows, macOS, Linux, BSD, Android and OpenWrt routers; -tunnel prints
a public bc+wss:// address via a Cloudflare quick tunnel (no domain,
open port or root).
- scripts/relay-quickstart.sh downloads it (SHA-256 enforced) and
cloudflared; Relay binaries workflow publishes 13 platform builds.
3. External protocols
- Nostr: ephemeral kind 20111 events tagged with the topic, signed with
a per-session BIP-340 key (@noble/curves).
- MQTT 3.1.1 over WebSocket, QoS 0, topic htmlroom/<topic>.
Tests: unit (parsing, sealing, packets, membership clashes), real relays
(Node, Go, signature-checking Nostr relay, aedes MQTT, Worker /bc/ under
wrangler dev), browser end-to-end over four relays with relay loss.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Rewrites every user-facing string in the room creator and the generated index.html in everyday words, moves relay settings into a collapsed section, highlights the main buttons, and links the repository (https://github.com/Freecode100Year/htmlroom.git) from both pages. Tests updated for the new wording. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Files carry an optional custom: true (on by default in the creation page and CLI room; untick or --strict for exact relays only). Such files allow connect-src wss: plus loopback ws, and show a relay box on the entry screen; typed relays apply to that visit only and pick classic or decentralized mode, with the same key, password and roomId. Web links never show the box. Converter and CLI retarget keep or change the setting. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
- Room files fold a creator: a new room with a new key and optional new
password, built offline from the page's own script and style bytes
(htmlFor), byte-identical to a release build.
- A blank file ({} or {relays}) is the creator: the offline generator and
the hosted site. It also opens #hr1= links (CSP wss: + loopback ws) and
converts old files; hosted, it offers itself as an offline download.
- The separate web entry (web.js, hr.js, hr.css) is gone: hr.html and the
Pages index.html are the creator file; _headers is generated with the
same script and style hashes.
Tests: offline chain blank -> A -> B (new password) -> C with no network
requests and release-identical output, chat in B, site self-download;
existing suites updated for links on the site reaching any relay.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Every file carries html-room/serve.js in an HTML comment before the doctype; to Node the page is a block comment, so `node index.html` runs a zero-dependency relay (/hr/ with the shared rules, /bc/, /healthz, --tunnel, --tls-cert). A blank creator also serves itself, making one file a complete site; a room file never serves itself (its key). New files created in the browser carry the server part from document.firstChild. Tests: the shared /hr/ and /bc/ relay probes run against node index.html; browser test serves the site from the file, chats through it, and runs the downloaded room file as a relay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Owner
Author
|
已随 #8 并入 main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
index.html。改动
htmlFor),不联网,与render(config)逐字节一致,可用verify-room-file.mjs核验。{}或{"relays":[…]}的文件打开即是创建页面,负责创建房间、转换旧文件;托管在网站上时还可「下载离线版」。dist/hr.html和 Pages 的index.html都是这个创建器文件,也负责打开#hr1=房间链接。html-room/web.js、hr.js和hr.css。dist/_headers由构建生成,HTTP CSP 固定与文件相同的脚本和样式哈希。wss: ws://localhost:* ws://127.0.0.1:*,网站可以打开任意中继的房间链接,不再限于站点白名单。安全上的取舍已写进security-model.md。测试
build:check通过;Worker 探针在wrangler dev下 10 项通过。browser-tests/generations.mjs:追加:房间文件同时是服务端(
node index.html)<!doctype html>前的 HTML 注释里内嵌中继(html-room/serve.js,只用 Node 标准库)。浏览器跳过它;Node 把页面部分当作块注释,所以node index.html直接运行中继,提供/hr/(与 Node 中继共用规则)、/bc/、/healthz,支持--tunnel和--tls-cert。/hr/、/bc/探针在node index.html上全部通过。https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Generated by Claude Code