import { DomainError } from "./app-error"; import { AuthenticationErrorCode } from "./error-codes"; export abstract class AuthenticationError extends DomainError {} export class NoTokenError extends AuthenticationError { constructor() { super(AuthenticationErrorCode.NO_TOKEN, "No authentication token provided"); } } export class InvalidCredentialsError extends AuthenticationError { constructor() { super(AuthenticationErrorCode.INVALID_CREDENTIALS, "Invalid credentials"); } } export class InvalidTokenError extends AuthenticationError { constructor() { super(AuthenticationErrorCode.INVALID_TOKEN, "Invalid token"); } } export class TokenExpiredError extends AuthenticationError { constructor() { super(AuthenticationErrorCode.TOKEN_EXPIRED, "Token expired"); } } export class InvalidRefreshTokenError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.INVALID_REFRESH_TOKEN, "Invalid or expired refresh token", ); } } export class CurrentPasswordIncorrectError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.CURRENT_PASSWORD_INCORRECT, "Current password is incorrect", ); } } export class PasswordIncorrectError extends AuthenticationError { constructor() { super(AuthenticationErrorCode.PASSWORD_INCORRECT, "Password is incorrect"); } } export class EmailAlreadyVerifiedError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.EMAIL_ALREADY_VERIFIED, "Email is already verified", ); } } export class InvalidVerificationTokenError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.INVALID_VERIFICATION_TOKEN, "Invalid verification token", ); } } export class VerificationTokenExpiredError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.VERIFICATION_TOKEN_EXPIRED, "Verification token has expired", ); } } export class InvalidPasswordResetTokenError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.INVALID_PASSWORD_RESET_TOKEN, "Invalid password reset token", ); } } export class PasswordResetTokenExpiredError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.PASSWORD_RESET_TOKEN_EXPIRED, "Password reset token has expired", ); } } export class EmailNotVerifiedError extends AuthenticationError { constructor() { super( AuthenticationErrorCode.EMAIL_NOT_VERIFIED, "Email address has not been verified. Please check your email and verify your account before logging in.", ); } }