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

A site's pages read a group's spaces whole, with an SDK

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:site/spaces
.claude/skills/docs/context.md+1−1
@@ -55,7 +55,7 @@ for more.
Design: `README.md` (overview), `spaces.md`, `groups.md`,
`membership.md`, `signing-in.md`, `moderation.md`, `mcp.md`,
`recovery.md`, `moving.md`. Reference: `../reference/api.md`, `mcp.md`,
`site-kit.md`, `cli.md`, `config.md`. `../development.md`. Link to them rather than
`site-kit.md`, `sdk.md`, `cli.md`, `config.md`. `../development.md`. Link to them rather than
restating them.
A method is named in code, never linked by hand: the docs site links it
.knotless/workflows/e2e.yml+8−4
@@ -18,20 +18,24 @@ image: rust:1.98
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
runners: [runner.knotless.dev]
# Every push to main, and pulls into it or a feature/ branch that change
# the console, the host it asks, the lexicons, the harness it runs over, or
# this file. A pull changing none passes at once, noted as skipped.
# the console, the SDK its site shell builds on, the host it asks, the
# lexicons, the harness it runs over, or this file. A pull changing none
# passes at once, noted as skipped.
on:
push: {refs: [refs/heads/main]}
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [web/**, lexicons/**, crates/**, Cargo.toml, Cargo.lock, harness/e2e/**, docs/guides/**, harness/look/**, harness/shots.mjs, harness/world.mjs, harness/pds.mjs, harness/alpha.sh, harness/tls-proxy.mjs, harness/package.json, harness/package-lock.json, .knotless/workflows/e2e.yml, .knotless/uses.lock]
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, /opt/atproto, /opt/browsers, /opt/chromium-debs, web/node_modules, harness/node_modules]
paths: [web/**, packages/**, lexicons/**, crates/**, Cargo.toml, Cargo.lock, harness/e2e/**, docs/guides/**, harness/look/**, harness/shots.mjs, harness/world.mjs, harness/pds.mjs, harness/alpha.sh, harness/tls-proxy.mjs, harness/package.json, harness/package-lock.json, .knotless/workflows/e2e.yml, .knotless/uses.lock]
cache: [target, /usr/local/cargo/registry, /usr/local/rustup, /opt/node, /opt/atproto, /opt/browsers, /opt/chromium-debs, packages/sdk/node_modules, web/node_modules, harness/node_modules]
env:
PLAYWRIGHT_BROWSERS_PATH: /opt/browsers
GROUP_HOST_DEV_ENV: /opt/atproto/packages/dev-env
steps:
- uses: chadtmiller.com/steps/node@1
with: {version: 24.22.1}
- uses: chadtmiller.com/steps/npm-ci@1
name: sdk
with: {dir: packages/sdk}
- uses: chadtmiller.com/steps/npm-ci@1
name: web
with: {dir: web}
.knotless/workflows/web.yml+22−12
@@ -1,31 +1,41 @@
# The console's checks, as `just lint` runs them: that it, the harness and
# the docs site are formatted as `just fmt` leaves them (oxfmt), that each
# component uses only its own layer and those below (harness/layers.mjs),
# that every dialog's title is its own fixed words (harness/dialogs.mjs),
# and svelte-check, which fails on any warning. The packages are kept
# between runs and installed again only when the lockfile changes.
# The console's checks, as `just lint` runs them: that it, the SDK, the
# harness and the docs site are formatted as `just fmt` leaves them
# (oxfmt), that each component uses only its own layer and those below
# (harness/layers.mjs), that every dialog's title is its own fixed words
# (harness/dialogs.mjs), the SDK's types and tests (packages/sdk, which the
# site shell builds on), and svelte-check, which fails on any warning. The
# packages are kept between runs and installed again only when a lockfile
# changes.
image: node:24.22.1
# The shared runner host; ci.knotless.dev, also this repository's, runs only deploy.yml.
runners: [runner.knotless.dev]
# Pushes to main, and pulls that change the pages, the lexicons their types
# are made from, the harness, the docs site, the format's settings or this
# file. A pull changing none passes at once, noted as skipped.
# Pushes to main, and pulls that change the pages, the packages they build
# on, the lexicons their types are made from, the harness, the docs site,
# the format's settings or this file. A pull changing none passes at once,
# noted as skipped.
on:
push: {refs: [refs/heads/main]}
pull:
base: [refs/heads/main, refs/heads/feature/*]
paths: [web/**, lexicons/**, harness/**, docs-site/**, .oxfmtrc.json, .knotless/workflows/web.yml, .knotless/uses.lock]
cache: [web/node_modules]
paths: [web/**, packages/**, lexicons/**, harness/**, docs-site/**, .oxfmtrc.json, .knotless/workflows/web.yml, .knotless/uses.lock]
cache: [web/node_modules, packages/sdk/node_modules]
steps:
- uses: chadtmiller.com/steps/npm-ci@1
name: sdk packages
with: {dir: packages/sdk}
- uses: chadtmiller.com/steps/npm-ci@1
name: packages
with: {dir: web}
- name: format
run: web/node_modules/.bin/oxfmt --check web harness docs-site
run: web/node_modules/.bin/oxfmt --check web packages/sdk harness docs-site
- name: layers
run: node harness/layers.mjs
- name: dialogs
run: node harness/dialogs.mjs
- name: sdk check
run: cd packages/sdk && npm run check
- name: sdk test
run: cd packages/sdk && npm test
- name: svelte-check
run: cd web && npm run check
- name: build
crates/group-host/src/lib.rs+39−30
@@ -192,44 +192,14 @@ pub(crate) fn routes(host: Arc<Host>) -> Router {
"/xrpc/com.atproto.identity.resolveHandle",
get(api::resolve_handle),
)
.route(
"/xrpc/com.atproto.space.getRecord",
get(space_api::get_record),
)
.route(
"/xrpc/com.atproto.space.listRecords",
get(space_api::list_records),
)
.route("/xrpc/com.atproto.space.getRepo", get(space_api::get_repo))
.route(
"/xrpc/com.atproto.space.getLatestCommit",
get(space_api::get_latest_commit),
)
.route(
"/xrpc/com.atproto.space.listRepoOps",
get(space_api::list_repo_ops),
)
.route("/xrpc/com.atproto.space.getBlob", get(space_api::get_blob))
.route(
"/xrpc/com.atproto.space.listBlobs",
get(space_api::list_blobs),
)
.route(
"/xrpc/com.atproto.space.notifyCredentialsRevoked",
post(space_api::notify_credentials_revoked),
)
.route(
"/xrpc/com.atproto.space.authorizeSpaceSync",
post(authority_api::authorize_space_sync),
)
.route(
"/xrpc/com.atproto.space.notifyRepoUpdate",
post(authority_api::notify_repo_update),
)
.route(
"/xrpc/com.atproto.space.listWriters",
get(authority_api::list_writers),
)
.route(
"/xrpc/fyi.opensocial.createGroup",
post(group_api::create_group),
@@ -460,6 +430,7 @@ pub(crate) fn routes(host: Arc<Host>) -> Router {
.route("/console/logout", post(console_login::logout))
.merge(token_routes())
.merge(oauth_routes())
.merge(space_routes())
.route(
"/xrpc/fyi.opensocial.putSite",
post(sites::put_site).layer(axum::extract::DefaultBodyLimit::max(site_limit)),
@@ -525,6 +496,44 @@ fn oauth_routes() -> Router<Arc<Host>> {
.layer(axum::middleware::from_fn(oauth::cors))
}
/// What a space's member reads it by, from its authority and from each
/// writer's repo here: open to any origin, as lex-space reads a space in
/// a browser (the page around a group's site).
fn space_routes() -> Router<Arc<Host>> {
Router::new()
.route(
"/xrpc/com.atproto.space.getRecord",
get(space_api::get_record),
)
.route(
"/xrpc/com.atproto.space.listRecords",
get(space_api::list_records),
)
.route("/xrpc/com.atproto.space.getRepo", get(space_api::get_repo))
.route(
"/xrpc/com.atproto.space.getLatestCommit",
get(space_api::get_latest_commit),
)
.route(
"/xrpc/com.atproto.space.listRepoOps",
get(space_api::list_repo_ops),
)
.route("/xrpc/com.atproto.space.getBlob", get(space_api::get_blob))
.route(
"/xrpc/com.atproto.space.listBlobs",
get(space_api::list_blobs),
)
.route(
"/xrpc/com.atproto.space.authorizeSpaceSync",
post(authority_api::authorize_space_sync),
)
.route(
"/xrpc/com.atproto.space.listWriters",
get(authority_api::list_writers),
)
.layer(axum::middleware::from_fn(space_api::cors))
}
/// The methods an app calls with a token, as the group: open to any
/// origin, as the OAuth endpoints are.
fn token_routes() -> Router<Arc<Host>> {
crates/group-host/src/site_kit.jsdeleted+0−126
@@ -1,126 +0,0 @@
// `os`: what a page of a group's site asks the page the host serves
// around it, which holds the visitor's session. Each ask is a message to
// it, answered by one naming the same id; a read or a write nobody may
// make now is refused with `locked` and a reason, "sign in" or "not for
// you".
//
// <os-sign-in> is a button for signing in and out, in the page's own
// markup, so the page's own CSS styles it: "Sign in" while nobody is,
// then the visitor's handle and "Sign out".
(() => {
let seq = 0;
const pending = new Map();
const watching = new Set();
addEventListener('message', (e) => {
const m = e.data;
if (e.source !== parent || !m || m.os !== 1) return;
if (m.type === 'changed') return watching.forEach((fn) => fn(m.me));
if (m.type !== 'reply') return;
const waiting = pending.get(m.id);
if (!waiting) return;
pending.delete(m.id);
if (!('error' in m)) return waiting.resolve(m.value);
const error = new Error(m.error);
error.locked = !!m.locked;
error.reason = m.reason;
waiting.reject(error);
});
const ask = (type, body = {}) =>
new Promise((resolve, reject) => {
const id = ++seq;
pending.set(id, { resolve, reject });
parent.postMessage({ os: 1, type, id, ...body }, '*');
});
const tell = (type, body = {}) => parent.postMessage({ os: 1, type, ...body }, '*');
const os = {
/**
* The group whose site this is: `{did, handle, console}`, `console`
* the address of the host's console, where its members manage it.
*/
group: () => ask('group'),
/** Who is looking: `{signedIn, did, handle}`. */
me: () => ask('me'),
/**
* One of the host's methods the site reads, as whoever is looking: its
* JSON, or a `Blob` for one that answers a file (`getSpaceBlob`), to
* show with `URL.createObjectURL`.
*/
call: (method, params = {}) => ask('call', { method, params }),
/**
* One of the host's procedures the site acts by, as whoever is looking:
* `input` its JSON, answered with what the method answers. Such as
* `fyi.opensocial.createReport`, reporting what they see.
*/
act: (method, input = {}) => ask('act', { method, input }),
/**
* Uploads `file`, a picture (a `File` or `Blob` of an `image/` type), to
* the visitor's own PDS, for a record the site writes to point to.
* Answers its reference, `{$type: 'blob', ref, mimeType, size}`, which
* the record holds; a site that declares no writes may not upload.
*/
upload: (file) => ask('upload', { file }),
/**
* Writes `record` in the visitor's own repo, in `space` (one of the
* group's, `at://<group>/space/<type>/<skey>`), as the site declared it
* may: in `collection`, at `rkey` if given. Answers its `uri` and `cid`.
*/
create: (space, collection, record, { rkey } = {}) =>
ask('create', { space, collection, record, ...(rkey ? { rkey } : {}) }),
/** Writes `record` at `rkey`, in place of what is there, as `create` does. */
put: (space, collection, rkey, record) => ask('put', { space, collection, rkey, record }),
/** Deletes the visitor's own record at `rkey`, as `create` writes it. */
delete: (space, collection, rkey) => ask('delete', { space, collection, rkey }),
/**
* Opens the host's sign-in dialog, its handle filled in with `hint` if
* given, for the visitor to confirm. Signed in, the page loads again.
*/
signIn: ({ hint } = {}) => tell('signIn', hint ? { hint: String(hint) } : {}),
/** Signs the visitor out; `onChange` hears of it. */
signOut: () => tell('signOut'),
/** Calls `fn` with who is looking, whenever that changes in place. */
onChange: (fn) => {
watching.add(fn);
return () => watching.delete(fn);
}
};
window.os = os;
// Where this page is and what it is called, for the page around it to
// show in the address bar and the tab: as it loads, and as a page that
// routes in the browser moves.
const at = () =>
tell('at', { path: location.pathname + location.search + location.hash, title: document.title });
for (const name of ['pushState', 'replaceState']) {
const was = history[name].bind(history);
history[name] = (...args) => (was(...args), at());
}
addEventListener('popstate', at);
addEventListener('hashchange', at);
at();
class SignIn extends HTMLElement {
connectedCallback() {
this.stop = os.onChange((me) => this.draw(me));
os.me().then((me) => this.draw(me));
}
disconnectedCallback() {
this.stop?.();
}
draw(me) {
const button = document.createElement('button');
button.type = 'button';
if (!me.signedIn) {
button.textContent = 'Sign in';
button.onclick = () => os.signIn({ hint: this.getAttribute('hint') ?? undefined });
return this.replaceChildren(button);
}
const who = document.createElement('span');
who.className = 'handle';
who.textContent = `@${me.handle ?? me.did}`;
button.textContent = 'Sign out';
button.onclick = () => os.signOut();
this.replaceChildren(who, ' ', button);
}
}
customElements.define('os-sign-in', SignIn);
})();
crates/group-host/src/sites.rs+46−10
@@ -71,8 +71,8 @@ fn blob_of(file: &Value) -> Option<atproto::Cid> {
}
/// Refuses a site the host would not serve: one whose paths [`paths`]
/// refuses, a file naming no blob, or a read or an act that is none of
/// [`READS`] or [`ACTS`].
/// refuses, a file naming no blob, a read or an act that is none of
/// [`READS`] or [`ACTS`], or `spaces` [`spaces`] refuses.
pub fn check(site: &Value) -> Result<(), XrpcError> {
paths(site)?;
for file in site["files"].as_array().into_iter().flatten() {
@@ -81,7 +81,8 @@ pub fn check(site: &Value) -> Result<(), XrpcError> {
return Err(refused(format!("{path} names no blob")));
}
}
methods(site)
methods(site)?;
spaces(site)
}
/// The host's methods a site's pages may ask, as whoever is looking and
@@ -124,9 +125,37 @@ fn writes_of(site: &Value) -> Vec<(&str, &str)> {
.collect()
}
/// Whether a site asks for its visitor's session: to read, act or write.
/// The space types a site's `spaces` name: those its pages read whole,
/// as the visitor.
fn spaces_of(site: &Value) -> Vec<&str> {
let all = site["spaces"].as_array().into_iter().flatten();
all.map(|s| s["space"].as_str().unwrap_or_default())
.collect()
}
/// Whether a site asks for its visitor's session: to read, act, read
/// spaces or write.
fn is_live(site: &Value) -> bool {
!reads_of(site).is_empty() || !acts_of(site).is_empty() || !writes_of(site).is_empty()
!reads_of(site).is_empty()
|| !acts_of(site).is_empty()
|| !spaces_of(site).is_empty()
|| !writes_of(site).is_empty()
}
/// Refuses a site whose `spaces` name no type, or one type twice.
fn spaces(site: &Value) -> Result<(), XrpcError> {
let mut seen = BTreeSet::new();
for kind in spaces_of(site) {
if kind.is_empty() {
return Err(refused("a site's space names no type".to_string()));
}
if !seen.insert(kind) {
return Err(refused(format!(
"{kind} is named twice in the site's spaces"
)));
}
}
Ok(())
}
/// Refuses a site whose `reads` or `acts` name a method that is none of
@@ -507,8 +536,9 @@ pub async fn serve(State(host): State<Arc<Host>>, req: Request, next: Next) -> R
}
}
/// The script a site's page runs to ask the page around it, `os`.
const KIT: &str = include_str!("site_kit.js");
/// The script a site's page runs to ask the page around it, `os`: kept
/// beside that page's own (`web/shell`), with the messages between them.
const KIT: &str = include_str!("../../../web/shell/kit.js");
/// What the page around a site's pages allows itself: its own script, and
/// calls to any PDS its visitor signs in at.
@@ -559,7 +589,8 @@ fn script(bytes: Vec<u8>) -> Response {
/// The site's OAuth client document, at its address `origin`: `atproto`;
/// leave to ask each of its `reads` and `acts`, and `getViewer`, of the
/// host; and to make each of its `writes` in the visitor's own repo, in the group
/// host; to read each of its `spaces` whole, in the group `did`'s spaces
/// of that type; and to make each of its `writes` in the visitor's own repo, in the group
/// `did`'s spaces of that type alone, with pictures they upload for those
/// records to point to.
fn client_metadata(host: &Host, did: &str, handle: &str, origin: &str, site: &Value) -> Response {
@@ -575,6 +606,9 @@ fn client_metadata(host: &Host, did: &str, handle: &str, origin: &str, site: &Va
for method in asked.chain([viewer]).collect::<BTreeSet<_>>() {
scope.push(format!("rpc:{method}?{aud}"));
}
for kind in spaces_of(site).into_iter().collect::<BTreeSet<_>>() {
scope.push(format!("space:{kind}?authority={did}&action=read"));
}
let writes = "action=create&action=update&action=delete";
let written = writes_of(site).into_iter().collect::<BTreeSet<_>>();
for (kind, collection) in &written {
@@ -607,7 +641,7 @@ fn client_metadata(host: &Host, did: &str, handle: &str, origin: &str, site: &Va
/// The page around a site's pages at `path`: the group's page there in a
/// sandboxed frame, and what the host's script needs to sign its visitor
/// in, ask `reads` and `acts`, and make `writes` as them.
/// in, ask `reads` and `acts`, read `spaces` and make `writes` as them.
fn shell(host: &Host, did: &str, handle: &str, site: &Value, path: &str) -> Response {
let (reads, acts) = (reads_of(site), acts_of(site));
let (status, html) = host.page_at(did, site, path);
@@ -621,6 +655,7 @@ fn shell(host: &Host, did: &str, handle: &str, site: &Value, path: &str) -> Resp
"handle": handle,
"reads": reads,
"acts": acts,
"spaces": spaces_of(site),
"writes": writes,
"aud": format!("{}#opensocial", host.config.service_did),
"handleResolver": host.config.site_handle_resolver,
@@ -708,12 +743,13 @@ pub async fn put_site(
let group = configuring(&host, &headers, &body, "putSite").await?;
host.active(&group)?;
let mut site = json!({"$type": SITE, "files": [], "createdAt": iso(now_millis())});
for key in ["fallback", "notFound", "reads", "acts", "writes"] {
for key in ["fallback", "notFound", "reads", "acts", "spaces", "writes"] {
if let Some(given) = body.get(key) {
site[key] = given.clone();
}
}
methods(&site)?;
spaces(&site)?;
let given = body["files"].as_array().expect("its lexicon requires it");
let names: Vec<Value> = given.iter().map(|f| json!({"path": f["path"]})).collect();
paths(&json!({"files": names, "fallback": site["fallback"], "notFound": site["notFound"]}))?;
crates/group-host/src/space_api.rs+28−2
@@ -17,8 +17,9 @@ use atproto::space::{
use atproto::space_auth::{self, CLOCK_SKEW, CREDENTIAL_MAX_AGE, Expect, Kind, TokenError};
use atproto::{Cid, drisl};
use axum::Json;
use axum::extract::{Query, State};
use axum::http::{HeaderMap, HeaderName, StatusCode, header};
use axum::extract::{Query, Request, State};
use axum::http::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, header};
use axum::middleware::Next;
use axum::response::{IntoResponse, Response};
use serde_json::{Value, json};
use std::sync::Arc;
@@ -153,6 +154,31 @@ fn mac(headers: &HeaderMap, account: &Account, profile: &'static str) -> Result<
})
}
/// Lets a page anywhere read a space as its member, as lex-space does in a
/// browser: a request carries a space credential and its signature, and no
/// cookies, so any origin may. Each answer with a MAC exposes its headers
/// itself ([`private`]).
pub async fn cors(req: Request, next: Next) -> Response {
let mut res = if req.method() == Method::OPTIONS {
StatusCode::NO_CONTENT.into_response()
} else {
next.run(req).await
};
let headers = res.headers_mut();
for (k, v) in [
(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*"),
(header::ACCESS_CONTROL_ALLOW_METHODS, "GET, POST, OPTIONS"),
(
header::ACCESS_CONTROL_ALLOW_HEADERS,
"content-type, authorization, atproto-space-audience, signature-input, signature, accept-signature",
),
(header::ACCESS_CONTROL_MAX_AGE, "600"),
] {
headers.insert(k, HeaderValue::from_static(v));
}
res
}
/// An answer for one reader: not kept by a shared cache, and varying with
/// the credential and the MAC asked for; with a MAC, `vouched` the covered
/// header's value, and the MAC's headers exposed to a browser app.
crates/group-host/tests/sites.rs+80−0
@@ -349,6 +349,23 @@ async fn an_app_writes_the_site_as_the_group_only_if_its_member_configures_it()
.await;
assert_eq!(said.error(), (400, "InvalidSite"));
}
// Its spaces each a type, named once.
for spaces in [
json!([{"space": "a.b.c"}, {"space": "a.b.c"}]),
json!([{"space": ""}]),
] {
let mut record = site("index.html");
record["spaces"] = spaces;
let said = app
.call(
&h,
"com.atproto.repo.putRecord",
token,
Some(&put("self", record)),
)
.await;
assert_eq!(said.error(), (400, "InvalidSite"));
}
assert_eq!(page(&h, "/").await.body, "hi");
let gone = json!({"repo": did, "collection": SITE, "rkey": "self"});
let said = app
@@ -702,6 +719,69 @@ async fn a_site_acts_as_its_visitor_only_as_the_host_lets_a_page() {
assert_eq!(site["acts"], acts);
}
#[tokio::test]
async fn a_site_reads_the_groups_spaces_whole_as_its_visitor() {
let h = start(&[], false).await;
let (did, [alice, ..]) = group(&h).await;
let files = json!([{"path": "index.html", "text": "<p>the board</p>"}]);
// A type named twice is refused; one naming none is no NSID, refused
// by the lexicon before the host looks.
let board = json!({"space": "com.example.board"});
let refused = [
(json!([board, board]), "InvalidSite"),
(json!([{"space": ""}]), "InvalidRequest"),
];
for (spaces, wanted) in refused {
let said = call(
&h,
&alice,
"putSite",
json!({"group": did, "files": files, "spaces": spaces}),
)
.await;
assert_eq!(error(&said), (400, wanted), "{spaces}");
}
// Reading spaces alone, its pages are served in the page that holds a
// session, which is told which spaces they read.
let members = format!("{NS}.members");
let spaces = json!([board, {"space": members}]);
let said = call(
&h,
&alice,
"putSite",
json!({"group": did, "files": files, "spaces": spaces}),
)
.await;
assert_eq!(said.0, 200, "{}", said.1);
let shell = page(&h, "/").await;
assert!(
shell.body.contains("data-src=\"/_site/\""),
"{}",
shell.body
);
let (_, config) = shell_of(&shell);
assert_eq!(config["spaces"], json!(["com.example.board", members]));
// Its OAuth client asks to read each, with the group as authority.
let client = page(&h, "/client-metadata.json").await;
let doc: Json = serde_json::from_str(&client.body).unwrap();
let scope: Vec<&str> = doc["scope"].as_str().unwrap().split(' ').collect();
let wanted = [
"atproto".to_string(),
format!("rpc:{NS}.getViewer?aud=did%3Aweb%3Ahost.test%23opensocial"),
format!("space:com.example.board?authority={did}&action=read"),
format!("space:{members}?authority={did}&action=read"),
];
assert_eq!(scope, wanted);
// The record says so, for any app that reads it.
let kept = h.host.store.record(&did, SITE, "self").unwrap().unwrap();
let site = atproto::drisl::decode(&kept.value).unwrap().to_json();
assert_eq!(site["spaces"], spaces);
}
#[tokio::test]
async fn a_site_that_writes_asks_its_visitor_for_those_writes_alone() {
let h = start(&[], false).await;
crates/group-host/tests/spaces.rs+35−0
@@ -224,6 +224,40 @@ async fn a_write_waits_on_its_authority_no_longer_than_the_timeout() {
assert!(waited < group_host::OUTGOING_TIMEOUT * 2, "{waited:?}");
}
#[tokio::test]
async fn lets_a_page_anywhere_read_a_space() {
let h = start(&[], false).await;
for nsid in [
"com.atproto.space.authorizeSpaceSync",
"com.atproto.space.listWriters",
"com.atproto.space.getRepo",
"com.atproto.space.listRepoOps",
] {
let res = h
.http
.request(reqwest::Method::OPTIONS, format!("{}/xrpc/{nsid}", h.url))
.header("origin", "https://hall.groups.test")
.header("access-control-request-method", "GET")
.send()
.await
.unwrap();
assert_eq!(res.status(), 204, "{nsid}");
assert_eq!(res.headers()["access-control-allow-origin"], "*");
let allowed = res.headers()["access-control-allow-headers"]
.to_str()
.unwrap();
for name in [
"authorization",
"atproto-space-audience",
"signature-input",
"signature",
"accept-signature",
] {
assert!(allowed.split(", ").any(|a| a == name), "{allowed}");
}
}
}
#[tokio::test]
async fn serves_a_repo_to_a_syncer_vouched_for() {
let f = fixture().await;
@@ -272,6 +306,7 @@ async fn serves_a_repo_to_a_syncer_vouched_for() {
repo.headers["access-control-expose-headers"],
"atproto-space-commit, signature-input, signature"
);
assert_eq!(repo.headers["access-control-allow-origin"], "*");
// Checked under another secret, the MAC does not hold.
let (_, other) = signed(&f.syncer, &f.group, &f.kem, COMMIT_MAC);
assert!(other.commit(&repo).is_err());
crates/group-host-mcp/src/lib.rs+6−5
@@ -397,11 +397,12 @@ const TOOLS: &[(&str, &[&str], &str, Made)] = &[
already is used again. Its pages run sandboxed, each in an origin of its own, with no \
cookies or storage. A site that names `reads`, methods of the host's such as \
fyi.opensocial.listMembers, `acts`, procedures of the host's such as \
fyi.opensocial.createReport, or `writes`, records of a collection in a type of the \
group's spaces, is served in a page of the host's that signs its visitor in: its pages \
ask those reads as whoever is looking, with `os.call` from `/_os/kit.js`, those acts \
with `os.act`, and make those writes in that person's own repo, with `os.create`, \
`os.put` and `os.delete`.",
fyi.opensocial.createReport, `spaces`, types of the group's spaces, or `writes`, \
records of a collection in a type of the group's spaces, is served in a page of the \
host's that signs its visitor in: its pages ask those reads as whoever is looking, \
with `os.call` from `/_os/kit.js`, those acts with `os.act`, and open those spaces \
with `os.space`, to sync and read them whole and make those writes in that person's \
own repo.",
Made::Method("putSite", None),
),
(
crates/opensocial/src/lib.rs+11−3
crates/opensocial/tests/commands.rs+15−0
docs/design/README.md+2−1
docs/design/sites.md+42−18
docs/reference/api.md+12−9
docs/reference/cli.md+1−1
docs/reference/mcp.md+1−1
docs/reference/sdk.mdnew+134−0
docs/reference/site-kit.md+41−21
docs-site/astro.config.mjs+1−0
harness/e2e/flows.spec.mjs+3−3
lexicons/fyi/opensocial/putSite.json+8−2
lexicons/fyi/opensocial/site.json+19−1
packages/sdk/src/group-client.test.tsnew+147−0
packages/sdk/src/group-client.tsnew+184−0
packages/sdk/src/group-space.test.tsnew+478−0
478 lines changed: not loaded until asked for.
packages/sdk/src/group-space.tsnew+453−0
453 lines changed: not loaded until asked for.
packages/sdk/src/index.tsnew+2−0
packages/sdk/package-lock.jsonnew+2178−0
A large diff, not shown.
packages/sdk/package.jsonnew+24−0
packages/sdk/README.mdnew+108−0
packages/sdk/tsconfig.jsonnew+15−0
web/shell/kit.jsnew+268−0
web/shell/protocol.tsnew+59−0
web/shell/shell.ts+227−56
web/shell/tsconfig.json+4−2
web/shell/vite.config.ts+4−0
web/src/lib/organisms/GroupSite.svelte+42−1
web/src/lib/server/settings.ts+12−6
web/src/lib/server/site.ts+6−1
web/package-lock.json+85−11
web/package.json+5−3
.dockerignore+2−0
.gitignore+2−0
AGENTS.md+4−0
Dockerfile+9−2
Justfile+9−5