auth-core-recipes.ts78 lines · main
1/**
2 * briven-engine recipe catalog + status APIs.
3 *
4 * GET /v1/auth-core/recipes — full catalog + loaded names
5 * GET /v1/auth-core/providers — social provider catalog
6 * GET /v1/auth-core/delivery — email/SMS delivery status
7 */
8
9import { Hono } from 'hono';
10
11import {
12 BRIVEN_ENGINE_ID,
13 getAuthCoreRecipeMeta,
14 isAuthCoreInitialized,
15 probeBrivenEngine,
16} from '../services/auth-core/engine.js';
17import {
18 BRIVEN_ENGINE_RECIPE_CATALOG,
19 getRecipePhase,
20} from '../services/auth-core/recipes.js';
21import { BRIVEN_ENGINE_SOCIAL_CATALOG } from '../services/auth-core/providers.js';
22import type { AppEnv } from '../types/app-env.js';
23
24export const authCoreRecipesRouter = new Hono<AppEnv>();
25
26authCoreRecipesRouter.get('/v1/auth-core/recipes', async (c) => {
27 const meta = getAuthCoreRecipeMeta();
28 const phase = getRecipePhase();
29 const core = await probeBrivenEngine();
30
31 const catalog = BRIVEN_ENGINE_RECIPE_CATALOG.map((r) => ({
32 ...r,
33 loaded: meta.names.includes(r.id),
34 availableInPhase: r.phase <= phase,
35 }));
36
37 return c.json({
38 engine: BRIVEN_ENGINE_ID,
39 product: 'Briven Auth',
40 sdkInitialized: isAuthCoreInitialized(),
41 recipePhase: meta.phase ?? phase,
42 loaded: meta.names,
43 smsIncluded: meta.names.includes('passwordless'),
44 catalog,
45 core: {
46 ok: core.ok,
47 message: core.message,
48 hello: core.hello,
49 },
50 deployGate: 'local-build-only-until-complete',
51 });
52});
53
54authCoreRecipesRouter.get('/v1/auth-core/providers', (c) => {
55 return c.json({
56 engine: BRIVEN_ENGINE_ID,
57 product: 'Briven Auth',
58 providers: BRIVEN_ENGINE_SOCIAL_CATALOG,
59 note: 'Secrets are per-project; empty credentials means provider is listed but not live for that project yet.',
60 });
61});
62
63authCoreRecipesRouter.get('/v1/auth-core/delivery', (c) => {
64 return c.json({
65 engine: BRIVEN_ENGINE_ID,
66 email: {
67 enabled: true,
68 modes: ['log', 'platform', 'provider'],
69 status: 'briven-engine delivery hook wired (passwordless + future reset/verify)',
70 },
71 sms: {
72 enabled: true,
73 includedInPlan: true,
74 modes: ['log', 'provider', 'error'],
75 status: 'briven-engine SMS OTP via passwordless EMAIL_OR_PHONE',
76 },
77 });
78});