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>
30 lines
1010 B
TypeScript
30 lines
1010 B
TypeScript
/**
|
|
* Everything a request handler or job needs, passed in rather than imported, so tests can run the
|
|
* whole app against an in-memory database and messenger (tests/support/).
|
|
*/
|
|
import type { PrismaClient } from './generated/prisma/client.js';
|
|
import type { Config } from './lib/config.js';
|
|
import { Secrets } from './lib/crypto.js';
|
|
import { LiveMessenger, type Messenger } from './lib/messages.js';
|
|
import { Settings } from './lib/settings.js';
|
|
|
|
export type Db = PrismaClient;
|
|
|
|
export type Ctx = {
|
|
config: Config;
|
|
db: Db;
|
|
secrets: Secrets;
|
|
settings: Settings;
|
|
messenger: Messenger;
|
|
now: () => Date;
|
|
};
|
|
|
|
export function createCtx(config: Config, db: Db, opts: { messenger?: Messenger; now?: () => Date } = {}): Ctx {
|
|
const secrets = new Secrets(config.secret);
|
|
const partial = { config, db, secrets } as Ctx;
|
|
partial.settings = new Settings(partial);
|
|
partial.messenger = opts.messenger ?? new LiveMessenger(partial);
|
|
partial.now = opts.now ?? (() => new Date());
|
|
return partial;
|
|
}
|