source: Klonkt/FEDERATION.md@ 5143ccf

main
Last change on this file since 5143ccf was 5143ccf, checked in by Robin <roboburr@…>, 7 weeks ago

Docs: the Shaer to Klonkt C2S API

Documents the contract the Shaer apps use to drive a Klonkt account:
discovery (WebFinger -> actor -> endpoints), OAuth (register, PKCE
authorize, token, bearer), the owner reads (actor, outbox, inbox,
enriched followers/following with name + avatar), the outbox writes
(Create/Like/Announce/Follow/Undo, the to/cc visibility mapping,
direct notes, attachments, shaer:helpRequest, the not_public
hardening), uploadMedia, the shaer: vocabulary (FEP-633c) and an error
reference. Linked from FEDERATION.md.

Changed files:
docs/shaer-c2s-api.md

  • the full C2S reference

New file:
docs/shaer-c2s-api.md

FEDERATION.md

  • link to the client API doc under Additional documentation

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

  • Property mode set to 100644
File size: 8.2 KB
Line 
1# Federation
2
3Klonkt is a small single-tenant fediverse site engine. Each site is one
4ActivityPub actor (a `Person`) that federates its posts, replies, boosts,
5likes, follows and polls, and that native or web apps can drive over
6ActivityPub Client-to-Server. This document describes what Klonkt speaks on the
7wire, following [FEP-67ff](https://codeberg.org/fediverse/fep/src/branch/main/fep/67ff/fep-67ff.md).
8
9## Supported federation protocols and standards
10
11- [ActivityPub](https://www.w3.org/TR/activitypub/) Server-to-Server (S2S)
12- [ActivityPub](https://www.w3.org/TR/activitypub/) Client-to-Server (C2S), over OAuth 2.0
13- [WebFinger](https://webfinger.net/) ([RFC 7033](https://www.rfc-editor.org/rfc/rfc7033))
14- [HTTP Signatures](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures) (draft-cavage), `rsa-sha256`
15- [NodeInfo](https://nodeinfo.diaspora.software/) 2.1
16- [OAuth 2.0](https://www.rfc-editor.org/rfc/rfc6749) public clients with PKCE ([RFC 7636](https://www.rfc-editor.org/rfc/rfc7636), S256 only)
17- [OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414) ([RFC 8414](https://www.rfc-editor.org/rfc/rfc8414))
18- [OAuth 2.0 Dynamic Client Registration](https://www.rfc-editor.org/rfc/rfc7591) ([RFC 7591](https://www.rfc-editor.org/rfc/rfc7591))
19
20## Supported FEPs
21
22- [FEP-67ff: FEDERATION.md](https://codeberg.org/fediverse/fep/src/branch/main/fep/67ff/fep-67ff.md) (FINAL): this file.
23- [FEP-f1d5: NodeInfo in Fediverse Software](https://codeberg.org/fediverse/fep/src/branch/main/fep/f1d5/fep-f1d5.md) (FINAL): `/.well-known/nodeinfo` links to a NodeInfo 2.1 document advertising software, version and the `activitypub` protocol.
24
25Beyond these, Klonkt aims for de-facto Mastodon compatibility (the
26`http://joinmastodon.org/ns#` extension terms below). See "Under consideration"
27for FEPs we track but do not yet implement.
28
29## ActivityPub
30
31### Actor
32
33Each site exposes a `Person` actor at `/ap/users/:slug` with `inbox`, `outbox`,
34`followers`, `following` and `featured` collections, and an RSA-2048 public key
35under the legacy `publicKey` / `publicKeyPem` field
36([w3id security/v1](https://w3id.org/security/v1)). The actor advertises
37`discoverable`, `manuallyApprovesFollowers` (currently always `false`),
38`featured`, and profile metadata as `schema:PropertyValue` links (including
39`rel="me"` verification links). Actor and object requests are
40content-negotiated: `application/activity+json` returns the AP document, other
41`Accept` values redirect to the human profile page.
42
43### Activities sent
44
45`Create`, `Update`, `Delete` (as `Tombstone`), `Follow`, `Accept`, `Like`,
46`Announce`, `Undo` (of `Follow` / `Like` / `Announce`), `Add` / `Remove`
47(featured-pin sync), and `Flag` (moderation reports). Posts, replies, boosts,
48likes and follows are delivered to remote inboxes with a signed HTTP request and
49a retrying delivery queue.
50
51### Activities received
52
53`Create`, `Update`, `Delete`, `Follow`, `Accept`, `Reject`, `Like`, `Announce`,
54`Undo` and `Flag`. Inbound follows are answered with `Accept` and backfilled with
55recent posts. Every inbound activity must carry a valid HTTP signature; unsigned
56or unverifiable requests are rejected.
57
58### Object types
59
60- `Note`: posts and replies, including rich replies with formatting and media.
61- `Question`: polls, single (`oneOf`) or multiple (`anyOf`) choice, with
62 `endTime`, `closed`, and Mastodon's `toot:votersCount`. Votes are received as a
63 `Note` with a `name` matching an option and `inReplyTo` the question. Tallies
64 are pushed to followers as `Update(Question)`.
65- `Image`, `Audio`, `Video`: media attachments with `mediaType`, `url` and `name`
66 (alt text). Audio attachments may carry cover art in `icon`.
67- `Tombstone`: in `Delete` activities.
68
69### Extensions and compatibility terms
70
71Every emitted object carries the full `@context`. Beyond AS2 core and
72security/v1, Klonkt declares and uses:
73
74- `as:sensitive` and `summary` for content warnings (blurred media, hidden text).
75- `as:Hashtag` tag objects (`#Tag`, linked to `/tag/:slug`).
76- `Mention` tag objects (`@user@host`, linked to the actor), resolved outbound
77 via WebFinger.
78- `contentMap`: BCP-47 language maps on posts and replies (Mastodon language
79 filter and translate).
80- `toot:discoverable`, `toot:featured`, `toot:votersCount`.
81- `schema:PropertyValue` / `schema:value` for profile metadata, and
82 `schema:embedUrl` for player-card embeds.
83
84### Collections
85
86- `followers` and `following` are count-only for the public. An authenticated
87 request from the site owner (a C2S bearer token scoped to that site) returns the
88 full list of actor URIs, so a connected app can build a contacts list.
89- `featured` lists pinned posts. Pin and unpin federate immediately as
90 `Add` / `Remove`, serialized per site to keep Mastodon's pin order.
91- A note's `replies` collection is served, and inbound threads are crawled one
92 level at a time (stale-while-revalidate, SSRF-guarded, budget-limited).
93
94## Client-to-Server (C2S)
95
96Native and web apps drive an account over ActivityPub C2S. This is not the
97Mastodon client API: Mastodon apps (Ivory and the like) are not supported here.
98
99- Discovery: the actor advertises its OAuth endpoints, and
100 `/.well-known/oauth-authorization-server` (RFC 8414) returns the authorization,
101 token and registration endpoints, `response_types=["code"]`,
102 `grant_types=["authorization_code"]`, `code_challenge_methods=["S256"]`,
103 `token_endpoint_auth_methods=["none"]` and `scopes_supported=["c2s"]`.
104- Registration: `POST /oauth/register` (RFC 7591), public clients only.
105- Authorization: PKCE authorization-code flow with a consent screen where the
106 user picks which site the app may act for. Tokens are hashed at rest and bound
107 to a single user and site.
108- Outbox: `POST /ap/users/:slug/outbox` with a bearer token accepts `Create`
109 (a bare `Note` is wrapped in a `Create` per spec), `Like`, `Announce`,
110 `Follow` and their `Undo`. Content is sanitized; a token cannot post for a
111 different site. `Delete` and `Update` over C2S are not yet implemented.
112
113## Authentication
114
115- S2S: HTTP Signatures (draft-cavage), `rsa-sha256`, over
116 `(request-target) host date digest`, with a configurable clock-skew tolerance
117 and reverse-proxy-aware host matching. Object Integrity Proofs
118 (FEP-8b32) are not used.
119- C2S: OAuth 2.0 bearer tokens, public clients with PKCE (S256), scope `c2s`.
120
121## Moderation and safety
122
123- Inbound `Flag` reports are stored for the site owner; the owner can send an
124 outbound `Flag` to a remote actor's server.
125- The owner can remove an inbound reply from a thread; a tombstone prevents the
126 thread crawler from re-fetching it.
127- Actor and domain blocks silently drop matching activities (no error
128 disclosure) and purge existing content.
129- All outbound fetches are SSRF-guarded (private-range IP blocking on every
130 redirect hop, per-request timeout).
131
132## Under consideration (not yet implemented)
133
134Klonkt tracks the following proposals but does not implement them yet. Draft
135specs are marked; per project policy, drafts are only adopted deliberately and
136with a note in the changelog.
137
138- Reply control. FEP-5624 (per-object reply control) is WITHDRAWN as of
139 2025-06-24; its Mastodon terms `canReply` / `ApproveReply` / `RejectReply`
140 remain in production use. The live successor discussion is in drafts FEP-171b
141 (conversation containers), FEP-7458 (replies collection) and FEP-11dd (context
142 ownership). Klonkt currently accepts all replies to its posts.
143- Search-indexing consent: FEP-5feb (DRAFT). No `indexable` flag is emitted yet.
144- Actor public keys as Multikey: FEP-521a (FINAL). Klonkt still uses the legacy
145 `publicKey` representation.
146- Object Integrity Proofs: FEP-8b32 (DRAFT). Not used.
147- Followers collection synchronization: FEP-8fcf (FINAL). Not implemented.
148- Quote posts: FEP-044f (DRAFT). Quotes appear as replies with an inline link.
149
150A guardian-gated actor model (guardianship for wards, gated follows and replies)
151is being drafted separately as a candidate FEP.
152
153## Additional documentation
154
155- Client-to-Server API for apps (the Shaer contract): `docs/shaer-c2s-api.md`.
156- Source code: `src/services/ActivityPubService.js` (core AP logic),
157 `src/routes/activitypub.js` (S2S, WebFinger, NodeInfo),
158 `src/routes/oauth.js` (C2S / OAuth).
159- Changelog: `CHANGELOG.md` (and `CHANGELOG.nl.md`, `CHANGELOG.de.md`).
Note: See TracBrowser for help on using the repository browser.