/**
 * Zod schema for OTPVerifyResponse
 *
 * This schema provides runtime validation and type inference.
 *  * OTP verification response.

When 2FA is required:
- requires_2fa: True
- session_id: UUID of 2FA verification session
- refresh/access/user: null

When 2FA is not required:
- requires_2fa: False
- session_id: null
- refresh/access/user: populated
 *  */
import { z } from 'zod'
import { UserSchema } from './User.schema'

/**
 * OTP verification response.

When 2FA is required:
- requires_2fa: True
- session_id: UUID of 2FA verification session
- refresh/access/user: null

When 2FA is not required:
- requires_2fa: False
- session_id: null
- refresh/access/user: populated
 */
export const OTPVerifyResponseSchema = z.object({
  requires_2fa: z.boolean().optional(),
  session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
  refresh: z.string().nullable().optional(),
  access: z.string().nullable().optional(),
  user: UserSchema.nullable().optional(),
  should_prompt_2fa: z.boolean().optional(),
})

/**
 * Infer TypeScript type from Zod schema
 */
export type OTPVerifyResponse = z.infer<typeof OTPVerifyResponseSchema>