Skip to main content

NAuthErrorCode

Package: @nauth-toolkit/client Type: Enum

Enumeration of standardized error codes returned by the SDK. Mirrors backend error codes for consistent error handling.

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

Categories​

Authentication Errors​

CodeDescription
AUTH_INVALID_CREDENTIALSWrong email/password
AUTH_ACCOUNT_LOCKEDAccount locked
AUTH_ACCOUNT_INACTIVEAccount deactivated
AUTH_TOKEN_EXPIREDAccess token expired
AUTH_TOKEN_INVALIDToken invalid/revoked
AUTH_BEARER_NOT_ALLOWEDBearer token not allowed
AUTH_COOKIES_NOT_ALLOWEDCookies not allowed
AUTH_CSRF_TOKEN_INVALIDCSRF token invalid
AUTH_CSRF_TOKEN_MISSINGCSRF token missing
AUTH_TOKEN_REUSE_DETECTEDToken reuse detected
AUTH_SESSION_NOT_FOUNDSession not found
AUTH_SESSION_EXPIREDSession expired

Signup Errors​

CodeDescription
SIGNUP_DISABLEDSignup disabled
SIGNUP_EMAIL_EXISTSEmail already registered
SIGNUP_USERNAME_EXISTSUsername already exists
SIGNUP_PHONE_EXISTSPhone already registered
SIGNUP_WEAK_PASSWORDPassword doesn't meet requirements
SIGNUP_PHONE_REQUIREDPhone required
SIGNUP_NOT_ALLOWEDSignup not allowed

Verification Errors​

CodeDescription
VERIFY_CODE_INVALIDVerification code invalid
VERIFY_CODE_EXPIREDVerification code expired
VERIFY_TOO_MANY_ATTEMPTSToo many attempts
VERIFY_ALREADY_VERIFIEDAlready verified

MFA Errors​

CodeDescription
MFA_SETUP_REQUIREDMFA setup required
MFA_INVALID_CODEMFA code is incorrect
MFA_CODE_EXPIREDMFA code has expired
MFA_DEVICE_NOT_FOUNDMFA device doesn't exist
MFA_SETUP_INVALIDMFA setup verification failed
VERIFICATION_CODE_INVALIDTOTP verification code invalid

Rate Limit Errors​

CodeDescription
RATE_LIMIT_SMSSMS rate limited
RATE_LIMIT_EMAILEmail rate limited
RATE_LIMIT_LOGINLogin rate limited
RATE_LIMIT_RESENDResend rate limited

Social Auth Errors​

CodeDescription
SOCIAL_TOKEN_INVALIDSocial token invalid
SOCIAL_ACCOUNT_LINKEDAccount already linked
SOCIAL_CONFIG_MISSINGSocial config missing
SOCIAL_EMAIL_REQUIREDEmail required
SOCIAL_ACCOUNT_NOT_FOUNDAccount not found
SOCIAL_ACCESS_DENIEDNot permitted to use this app

Challenge Errors​

CodeDescription
CHALLENGE_EXPIREDChallenge expired
CHALLENGE_INVALIDChallenge invalid
CHALLENGE_TYPE_MISMATCHChallenge type mismatch
CHALLENGE_MAX_ATTEMPTSMax attempts reached
CHALLENGE_ALREADY_COMPLETEDChallenge completed

Validation Errors​

CodeDescription
VALIDATION_FAILEDValidation failed
VALIDATION_INVALID_PHONEInvalid phone format
VALIDATION_INVALID_EMAILInvalid email format
VALIDATION_INVALID_PASSWORDInvalid password

Password Errors​

CodeDescription
PASSWORD_INCORRECTPassword incorrect
PASSWORD_REUSEDPassword reused
PASSWORD_CHANGE_NOT_ALLOWEDPassword change not allowed

Adaptive MFA​

CodeDescription
SIGNIN_BLOCKED_HIGH_RISKSign-in blocked (high risk)

General Errors​

CodeDescription
RESOURCE_NOT_FOUNDResource not found
FORBIDDENForbidden
INTERNAL_ERRORInternal error
SERVICE_UNAVAILABLEService unavailable

OpenID Connect Provider Errors​

For an application that is itself an OpenID Connect provider. The first two are what client.oidc rejects with; OIDC_ACCESS_DENIED is available for identity-provider routes you write yourself.

CodeDescription
OIDC_ACCESS_DENIEDThe account may not be issued credentials at all
OIDC_INTERACTION_NOT_FOUNDThe authorization request expired or was already resolved
OIDC_LOGIN_REQUIREDRecoverable — details.uid names the request to resume after login

Example​

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

try {
await client.login('user@example.com', 'password');
} catch (error) {
if (error instanceof NAuthClientError) {
switch (error.code) {
case NAuthErrorCode.AUTH_INVALID_CREDENTIALS:
console.log('Wrong credentials');
break;
case NAuthErrorCode.RATE_LIMIT_LOGIN:
const retryAfter = error.details?.retryAfter as number;
console.log(`Rate limited. Retry in ${retryAfter}s`);
break;
}
}
}

Used By​