Some checks are pending
E2E / Playwright e2e (push) Waiting to run
Add authenticator-validate device picker, captcha/frame stages, WebAuthn utils fix, and recovery query parsing for /reset-password links.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
"use client"
|
|
|
|
import type { FlowChallenge } from "@/lib/auth/flow-api"
|
|
|
|
export type StageRendererProps = {
|
|
challenge: FlowChallenge | null
|
|
values: Record<string, string>
|
|
fieldErrors: Record<string, string>
|
|
submitting: boolean
|
|
onChange: (key: string, value: string) => void
|
|
onSubmit: (payload: Record<string, unknown>) => void | Promise<void>
|
|
}
|
|
|
|
export type StageRenderer = React.ComponentType<StageRendererProps>
|
|
|
|
export function readPrimaryAction(challenge: FlowChallenge | null): string {
|
|
const action = challenge?.primary_action
|
|
return typeof action === "string" && action.trim() ? action : "Continuer"
|
|
}
|
|
|
|
export function isKnownFlowComponent(component: string): boolean {
|
|
return component in FLOW_STAGE_REGISTRY || LEGACY_KNOWN_COMPONENTS.has(component)
|
|
}
|
|
|
|
const LEGACY_KNOWN_COMPONENTS = new Set([
|
|
"ak-stage-prompt",
|
|
"ak-stage-identification",
|
|
"ak-stage-email",
|
|
"ak-stage-authenticator-validate",
|
|
"ak-stage-password",
|
|
"ak-stage-user-login",
|
|
"ak-stage-authenticator-webauthn",
|
|
"ak-stage-source",
|
|
"ak-stage-captcha",
|
|
"xak-flow-redirect",
|
|
"xak-flow-frame",
|
|
"ak-stage-access-denied",
|
|
])
|
|
|
|
/** Registry for Phase 3 stages. */
|
|
export const FLOW_STAGE_REGISTRY: Record<string, StageRenderer> = {}
|