Skip to main content

ChallengeResponse

Package: @nauth-toolkit/client Type: Request (Discriminated Union)

Discriminated union type for responding to authentication challenges. Type depends on the challenge being completed.

import { ChallengeResponse } from '@nauth-toolkit/client';

Types

VerifyEmailResponse

Email verification challenge response.

{
session: string;
type: 'VERIFY_EMAIL';
code: string; // 6-digit verification code
}

VerifyPhoneCollectResponse

Phone number collection (first step of phone verification).

{
session: string;
type: 'VERIFY_PHONE';
phone: string; // E.164 format (e.g., '+14155551234')
}

VerifyPhoneCodeResponse

Phone verification code (second step of phone verification).

{
session: string;
type: 'VERIFY_PHONE';
code: string; // 6-digit verification code
}

MFACodeResponse

MFA code verification.

{
session: string;
type: 'MFA_REQUIRED';
method: 'sms' | 'email' | 'totp' | 'backup';
code: string; // MFA code
}

MFAPasskeyResponse

Passkey MFA verification.

{
session: string;
type: 'MFA_REQUIRED';
method: 'passkey';
credential: Record<string, unknown>; // WebAuthn credential
}

MFASetupResponse

MFA device setup completion.

{
session: string;
type: 'MFA_SETUP_REQUIRED';
method: 'sms' | 'email' | 'totp' | 'passkey';
setupData: Record<string, unknown>; // Method-specific setup data
}

Setup Data Structure by Method:

  • TOTP: { secret: string, code: string } - Both secret (from getSetupData) and code (from user) are required
  • SMS: { code: string } or { deviceId: number } (if auto-completed)
  • Email: { code: string } or { deviceId: number } (if auto-completed)
  • Passkey: { credential: Record<string, unknown> } - WebAuthn credential from registration

ForceChangePasswordResponse

Force password change.

{
session: string;
type: 'FORCE_CHANGE_PASSWORD';
newPassword: string; // New password meeting requirements
}

Example

Email Verification

{
"session": "challenge_session_token_xyz",
"type": "VERIFY_EMAIL",
"code": "123456"
}

MFA Code

{
"session": "challenge_session_token_xyz",
"type": "MFA_REQUIRED",
"method": "totp",
"code": "654321"
}

Used By