70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
|
|
/**
|
||
|
|
* SMTP Validation Utilities
|
||
|
|
* Provides validation functions for SMTP server
|
||
|
|
*/
|
||
|
|
import { SmtpState } from '../interfaces.js';
|
||
|
|
/**
|
||
|
|
* Detects header injection attempts in input strings
|
||
|
|
* @param input - The input string to check
|
||
|
|
* @param context - The context where this input is being used ('smtp-command' or 'email-header')
|
||
|
|
* @returns true if header injection is detected, false otherwise
|
||
|
|
*/
|
||
|
|
export declare function detectHeaderInjection(input: string, context?: 'smtp-command' | 'email-header'): boolean;
|
||
|
|
/**
|
||
|
|
* Sanitizes input by removing or escaping potentially dangerous characters
|
||
|
|
* @param input - The input string to sanitize
|
||
|
|
* @returns Sanitized string
|
||
|
|
*/
|
||
|
|
export declare function sanitizeInput(input: string): string;
|
||
|
|
/**
|
||
|
|
* Validates an email address
|
||
|
|
* @param email - Email address to validate
|
||
|
|
* @returns Whether the email address is valid
|
||
|
|
*/
|
||
|
|
export declare function isValidEmail(email: string): boolean;
|
||
|
|
/**
|
||
|
|
* Validates the MAIL FROM command syntax
|
||
|
|
* @param args - Arguments string from the MAIL FROM command
|
||
|
|
* @returns Object with validation result and extracted data
|
||
|
|
*/
|
||
|
|
export declare function validateMailFrom(args: string): {
|
||
|
|
isValid: boolean;
|
||
|
|
address?: string;
|
||
|
|
params?: Record<string, string>;
|
||
|
|
errorMessage?: string;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* Validates the RCPT TO command syntax
|
||
|
|
* @param args - Arguments string from the RCPT TO command
|
||
|
|
* @returns Object with validation result and extracted data
|
||
|
|
*/
|
||
|
|
export declare function validateRcptTo(args: string): {
|
||
|
|
isValid: boolean;
|
||
|
|
address?: string;
|
||
|
|
params?: Record<string, string>;
|
||
|
|
errorMessage?: string;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* Validates the EHLO command syntax
|
||
|
|
* @param args - Arguments string from the EHLO command
|
||
|
|
* @returns Object with validation result and extracted data
|
||
|
|
*/
|
||
|
|
export declare function validateEhlo(args: string): {
|
||
|
|
isValid: boolean;
|
||
|
|
hostname?: string;
|
||
|
|
errorMessage?: string;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* Validates command in the current SMTP state
|
||
|
|
* @param command - SMTP command
|
||
|
|
* @param currentState - Current SMTP state
|
||
|
|
* @returns Whether the command is valid in the current state
|
||
|
|
*/
|
||
|
|
export declare function isValidCommandSequence(command: string, currentState: SmtpState): boolean;
|
||
|
|
/**
|
||
|
|
* Validates if a hostname is valid according to RFC 5321
|
||
|
|
* @param hostname - Hostname to validate
|
||
|
|
* @returns Whether the hostname is valid
|
||
|
|
*/
|
||
|
|
export declare function isValidHostname(hostname: string): boolean;
|