~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

A group's site shows the group to whoever signs in on it

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:sites/live-data

A group's site can now show the group to each visitor as they're allowed to see it: a site that names reads is served in a page of the host's that signs the visitor in with the console's own dialog, and its pages ask the host as them through os from /_os/kit.js. Sites that name no reads are served exactly as before.

Claude Opus 5.5

What changes

The record. fyi.opensocial.site and putSite take reads, up to 20 of getGroup, listMembers, listSpaceRecords, getSpaceBlob, getActor and getViewer (sites::READS). Any other method is InvalidSite, from putSite and from a putRecord of the record alike.

Serving. For a site with reads, every page at the address is the host's page: the site's page in a sandboxed frame filling the window, its files under /_site/, and files that are not pages still at their own paths. The host's page has the site page's <title> and preview <meta> tags (written afresh and escaped by the new site_head, so nothing of the site's markup reaches it) and the status the page would have, 404 included. It also serves /client-metadata.json (a public OAuth client asking atproto and an rpc: scope per read and getViewer), /_os/kit.js and /_os/shell.js. /xrpc/ now passes through on every group address, so the dialog's typeahead reaches searchActors.

The page around a site (web/shell, built by npm run build/npm run shell to web/build-shell, read from SITE_SHELL_DIR) holds the visitor's session and draws the console's own SignInDialog, typeahead and "Create one" included. It loads the frame at once, keeps the frame's page in the address bar and the tab title, and answers the kit's asks, refusing a method the site didn't declare and saying locked with sign in or not for you. SignInDialog takes onhandle/oncreate/failed/assets so the shell can drive it; the console behaves as before.

The kit: os.group(), os.me(), os.call(), os.signIn({hint}), os.signOut(), os.onChange(), and <os-sign-in>, a button the page's own CSS styles.

Publishing. The console's Publish dialog is the folder alone, with the rest under a closed "Advanced": "Send every address to one page, for single-page apps" (fallback) and "Let pages show the group's data" (reads, without getViewer, which a page needs only for os.me() and always has), with a line saying pages must be written to ask. Both are filled as the site has them, and Advanced opens when either is set. A 404.html at the folder's top is taken as notFound, in place of the "if you like" field. opensocial site publish --reads getGroup,listMembers; and site_publish takes reads.

Deploying. The image builds the shell and sets SITE_SHELL_DIR=/app/build-shell. SITE_HANDLE_RESOLVER (default https://bsky.social) is where the page resolves a typed handle. The client's origin is the request's X-Forwarded-Host when a proxy sends one, as Caddy does, else Host.

Starting a group. A name typed before the page's script has run now makes the address once it does, as one typed after always did. Before, the address stayed empty, which made e2e's "starting a group" fail under load.

Why

A site in the sandbox has no session, so it could only show what it was published with, while most of what a group wants on its site (rules, members, posts) is for its members only. The sites issue at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzlk7gxpmi3j left this as option B. The session lives in the host's own code at the address, never in what any group.configure holder can publish; the site's pages stay sandboxed and only ask. A page can suggest a handle but can't send anyone anywhere: the visitor confirms in the host's dialog and types their password only at their own PDS. Reads go through the visitor's PDS like any app's call, so the host answers them as it would anywhere else.

How it was checked

  • tests/sites.rs: a site with reads served in the host's page (its policy, the preview tags, the frame's source, the 404 status, the config the script reads), its files under /_site/ and folders redirected there, the kit and shell scripts, the client document and its scopes (and named for X-Forwarded-Host), /xrpc/ passing through, and publishing without reads going back to plain files. Also a method outside READS refused, no shell built answering 404, and site_head::preview against hostile and odd markup (quotes either way, unquoted values, tags after the head, a value that tries to close the tag, a page longer than what's read).
  • tests/commands.rs: --reads by name and by NSID; the MCP protocol test with the new description.
  • e2e: a new flow publishes Riders' site from the console with a read ticked under Advanced, sees the dialog keep it, opens the site signed out ("Members only."), signs in through the dialog at alice's PDS, sees the members, follows a link and sees the address bar and title follow, reloads still signed in, and signs out in place. Riders' site has a front at riders.group-host.internal because the PDS refuses an OAuth client under .test. The folder flow now has a 404.html and checks it becomes notFound. All flows pass locally.
  • just look of the Publish dialog closed and with Advanced open, on desktop and phone (pictures attached); new fieldset.choices and details.more rules for sentence-long choices and a folded part of a form.
  • Built the image's console stage and saw /web/build-shell/shell.js in it.

Shortcomings

  • The shell is about 115 kB gzipped (Svelte, the OAuth client and the console's styles), loaded once on sites that declare reads.
  • @atproto/oauth-client-browser and @atproto/oauth-client are pinned to the Nov 5 spaces alpha, as the newest alpha ships an empty @atproto/oauth-resolver.
  • A page that doesn't load the kit doesn't report where it is, so the address bar stays where the frame started.
  • Safari and Firefox are not checked; e2e is Chromium.
  • Visitors signed in on a site's address will sign in again once sites can be served on a group's own domain (at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3n25k5ew55umt).

Review

The trust line: sites.rs live and shell (what the host's page is and allows), site_head.rs (nothing of the site's markup copied), and web/shell/shell.ts follow and the message handler (what a framed page can make the host's page do).

closed-alice-desktop-light.png

advanced-alice-desktop-light.png

advanced-alice-phone-dark.png

Approved

This adds reads to the site record. A site that names reads is served inside a host-owned page that holds the visitor's OAuth session, and the site's own page stays in a sandboxed frame that can only ask.

I read sites.rs, site_head.rs, site_kit.js and shell.ts in full, which is the trust line you named. I did not read the other 35 files (docs, harness, lexicons, lockfile, CLI, console components); I relied on the passing checks for them. The checks that have finished (web, check, lexicons, docs) pass. test and e2e were still running when I looked.

The trust line holds up:

  • The host page's CSP is script-src 'self' with frame-ancestors 'none'.
  • The frame has no allow-same-origin or top-navigation, and /_site/ answers also carry the sandbox CSP.
  • The < in the config JSON is escaped.
  • site_head rebuilds only escaped title and og:/twitter:/description/theme-color tags.
  • The shell ignores messages whose source isn't the frame and refuses any method not in the site's reads.
  • signIn only opens the dialog, so the visitor still confirms the handle.
  • follow only accepts paths under /_site/. A hostile path like /_site//x makes replaceState throw a SecurityError, which is harmless.

One thing to know. A framed page that links with an absolute path such as /about navigates the frame to the host's shell page. frame-ancestors 'none' then blocks it, so the link looks broken. Relative links, or links the page routes itself, work. Please say in docs/design/sites.md that pages of a live site should use relative links. Rewriting /x to /_site/x in the shell would be a later improvement.

Minor: the client-metadata response sets no Cache-Control and builds client_id from a client-supplied X-Forwarded-Host. That is fine behind Caddy, but a shared cache in front would need Vary: X-Forwarded-Host.

Approved

I read the changes since the approved commit. They touch the console only: the Publish dialog now folds fallback and reads under "Advanced", getViewer is no longer a checkbox, a top-level 404.html becomes notFound, and the name-before-script fix in NewGroupForm is in. None of it touches sites.rs, site_head.rs, site_kit.js or shell.ts, so the trust line I reviewed still stands.

  • Form handling: the server action in settings.ts merges notFound and fallback correctly. Site now carries fallback, so the dialog refills it and opens Advanced when reads or fallback is set.
  • getViewer: the dialog no longer offers it, and the pull says the shell always allows it. That matches the earlier design.
  • Still open from my first review: I asked for docs/design/sites.md to say that pages of a live site should use relative links, because an absolute /about link navigates the frame to the host's page, which frame-ancestors 'none' blocks. The diff doesn't add that, and a search of docs for "relative" finds nothing. I'm not blocking on it, but please add the sentence.
Merged as 47dece5