import { cookies } from "next/headers" import { z } from "zod" import { SAS_REQUEST_OTP_STATE_STORAGE_COOKIE_NAME } from "./constants" const otpStateSchema = z.object({ referenceId: z.string().uuid(), databaseUUID: z.string().uuid(), }) export type OtpState = z.infer export function getOTPState() { const otpState = cookies().get(SAS_REQUEST_OTP_STATE_STORAGE_COOKIE_NAME) return otpStateSchema.parse(JSON.parse(otpState?.value ?? "{}")) }