Accounts 1.0.0 backend: OIDC provider, sign-in steps, account and admin API

oidc-provider 9.13.3 with PKCE, ES256, crosscode.identity/1 claims and
back-channel logout; clients are the linked products (Connect). Sign-in
steps (password, sign-up, email check, 2FA and its setup, privacy notice,
news question, password reset) survive to the product. Account page and
admin API, church profile, export and deletion fan-out, Hub v2 client,
jobs. End-to-end tests with a test product on openid-client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 13:33:49 +02:00
co-authored by Claude Opus 5.5
parent 45c6539bf1
commit 069b66fd30
51 changed files with 4863 additions and 9 deletions
@@ -0,0 +1,50 @@
/**
* Public endpoints: the church's branding for the sign-in pages, the church profile for its
* products (`GET /api/church/v1`, contracts 1.5.0), and Connect (`/api/links/v1/*`, as Events 2.4).
*/
import express, { type Response } from 'express';
import { CHURCH_PATHS, LINK_PATHS, LINK_SCHEMA } from '@crosscode/contracts';
import type { Ctx } from '../context.js';
import { handle, limit } from '../http.js';
import { branding, church } from '../church/profile.js';
import { acceptConnect, acceptDisconnect, LinkError } from '../links/connect.js';
import { setupNeeded } from '../setup/routes.js';
const strip = (p: string) => p.replace(/^\/api/, '');
function linkError(res: Response, e: unknown) {
if (e instanceof LinkError) return res.status(e.status).json({ message: e.message, code: e.code });
console.error('[links]', e);
return res.status(500).json({ message: 'Something went wrong.', code: 'SERVER_ERROR' });
}
export function publicRouter(ctx: Ctx) {
const r = express.Router();
const json = express.json({ limit: '16kb' });
r.get('/v2/branding', handle(async () => ({ ...(await branding(ctx)), setupNeeded: await setupNeeded(ctx) })));
r.get(strip(CHURCH_PATHS.profile), limit(600), handle(async (_req, res) => {
res.set('Cache-Control', 'public, max-age=60');
return church(ctx);
}));
r.post(strip(LINK_PATHS.connect), limit(30), json, async (req, res) => {
try {
res.json(await acceptConnect(ctx, req.body, req));
} catch (e) {
linkError(res, e);
}
});
r.post(strip(LINK_PATHS.disconnect), limit(30), json, async (req, res) => {
try {
await acceptDisconnect(ctx, req.body, req);
res.json({ schema: LINK_SCHEMA, type: 'link.disconnected' });
} catch (e) {
linkError(res, e);
}
});
return r;
}