UNPKG

@auth0/nextjs-auth0

Version:
37 lines (36 loc) 2.03 kB
import { NextResponse } from "next/server.js"; import type { Authenticator, ChallengeResponse, EnrollmentResponse, EnrollOobOptions, EnrollOtpOptions } from "../types/index.js"; import { VerifyMfaOptions, type AuthenticatorApiResponse, type ChallengeApiResponse, type EnrollmentApiResponse } from "../types/mfa.js"; /** * Transforms Auth0 API authenticator response (snake_case) to SDK format (camelCase). * * @param auth - Raw authenticator from Auth0 API * @returns Transformed authenticator */ export declare function camelizeAuthenticator(auth: AuthenticatorApiResponse): Authenticator; /** * Transforms Auth0 API challenge response (snake_case) to SDK format (camelCase). * * @param result - Raw challenge result from Auth0 API * @returns Transformed challenge response */ export declare function camelizeChallengeResponse(result: ChallengeApiResponse): ChallengeResponse; /** * Transforms Auth0 API enrollment response (snake_case) to SDK format (camelCase). * Builds discriminated union based on authenticator type. * * @param result - Raw enrollment result from Auth0 API * @returns Transformed enrollment response */ export declare function buildEnrollmentResponse(result: EnrollmentApiResponse): EnrollmentResponse; /** * Builds type-safe enrollment options from request body. * Validates type-specific required fields. * * @param body - Request body * @param authenticatorType - Type of authenticator to enroll * @returns Tuple of [options, null] or [null, errorResponse] */ export declare function buildEnrollOptions(body: unknown, authenticatorType: string): [Omit<EnrollOobOptions, "mfaToken">, null] | [Omit<EnrollOtpOptions, "mfaToken">, null] | [null, NextResponse]; export declare const buildVerifyParams: (options: VerifyMfaOptions, mfaToken: string) => URLSearchParams; export declare const getVerifyGrantType: (params: URLSearchParams) => "http://auth0.com/oauth/grant-type/mfa-otp" | "http://auth0.com/oauth/grant-type/mfa-oob" | "http://auth0.com/oauth/grant-type/mfa-recovery-code";