feat(federation): add peering handshake and admin peer management endpoints

Add federation routes module with four endpoints:
- POST /api/federation/peer/initiate — admin-only, starts peering handshake
  with a remote instance (validates origin, generates HMAC secret, sends
  server-to-server accept request with 10s timeout)
- POST /api/federation/peer/accept — server-to-server first contact,
  rate-limited to 10 req/min per IP, creates/activates peer record
- GET /api/federation/peers — admin-only, lists all peers (hmacSecret excluded)
- DELETE /api/federation/peers/:id — admin-only, revokes peer and cleans outbox
This commit is contained in:
Jannis Braun
2026-03-25 21:19:47 +01:00
parent 32a0c2e618
commit fbdec82172
2 changed files with 373 additions and 0 deletions
+2
View File
@@ -25,6 +25,7 @@ import { exploreRoutes } from './routes/explore.js';
import { searchRoutes } from './routes/search.js';
import { adminRoutes } from './routes/admin.js';
import { gifRoutes } from './routes/gif.js';
import { federationRoutes } from './routes/federation.js';
import { registerWebSocket } from './ws/handler.js';
import path from 'path';
@@ -95,6 +96,7 @@ async function main(): Promise<void> {
await app.register(searchRoutes);
await app.register(adminRoutes);
await app.register(gifRoutes);
await app.register(federationRoutes);
await app.register(registerWebSocket);
app.get('/api/health', async () => {