// The step-up broker. `request()` in api.ts lives outside React, so it cannot // render a dialog itself; instead it calls back into whatever prompt the // StepUpModal registered when it mounted inside the (app) layout. type Prompt = (methods: string[]) => Promise; let prompt: Prompt | null = null; // The provider registers the real prompt at mount. Before that, or outside the // app shell, step-up simply fails rather than hanging forever. export function registerStepUpPrompt(fn: Prompt | null) { prompt = fn; } export async function requestStepUp(methods: string[]): Promise { if (!prompt) throw new Error("re-authentication is required"); return prompt(methods); }