Lets users of other gerbeur instances sign in here with their account there, as federation-service.ts describes, and lets admins pick the instances to trust or block. The login and register pages start a sign-in, the /federation/callback page finishes it, /manage edits the peers, and the other instances' servers send their events.

  • POST /api/federation/logins — public. Starts a sign-in with an account on another instance (FederationLoginRequest, with an invite unless it is trusted), and answers its /authorize page to go to. Rate-limited per instance.
  • POST /api/federation/sessions — public. Finishes it (FederationSessionRequest) and answers the user and their tokens, as a sign-in does. Each sign-in started finishes once, so the limit on /logins bounds it.
  • POST /api/federation/events — public, server to server. Applies a home instance's signed event about one of its users ({ event }). Rate-limited per instance; a 4xx tells the sender to give up on the event, a 429 or a 5xx to try again.
  • GET /api/federation/peers — optional sign-in. Answers the trusted instances, or every listed one to federation:manage.
  • PUT /api/federation/peers — permission federation:manage. Trusts or blocks an instance (SetPeerRequest) and answers it; 502 when one to trust doesn't answer as a gerbeur.
  • DELETE /api/federation/peers/:host — permission federation:manage. Takes an instance off the lists.

Variables

v
default: Router

Mounted by api/main.ts behind the error, Open Graph and CORS middleware. An APIException thrown by a handler becomes the JSON error response there.

Usage

import * as mod from "api/routes/federation.ts";