import { SentlyError } from "./errors.js"; export { computeCRAMMD5 } from "./cram-md5.js"; /** SMTP command to send to the server. */ export type SMTPCommand = { type: "EHLO"; domain: string; } | { type: "STARTTLS"; } | { type: "AUTH_LOGIN"; user: string; pass: string; } | { type: "AUTH_PLAIN"; user: string; pass: string; } | { type: "AUTH_CRAM_MD5_INIT"; } | { type: "AUTH_CRAM_MD5_RESPONSE"; response: string; } | { type: "AUTH_XOAUTH2"; xoauth2String: string; } | { type: "MAIL_FROM"; address: string; } | { type: "RCPT_TO"; address: string; } | { type: "DATA"; } | { type: "DATA_BODY"; content: Uint8Array; } | { type: "QUIT"; } | { type: "RSET"; } | { type: "NOOP"; }; /** Parsed SMTP server response. */ export interface SMTPResponse { /** Three-digit SMTP status code. */ code: number; /** Human-readable response text after the status code. */ message: string; /** True when the code is in the 2xx success range. */ isSuccess: boolean; /** True when the code is 354 (ready for message data). */ isReady: boolean; /** True when the code is 4xx or 5xx. */ isError: boolean; } /** SMTP protocol error with server response details. */ export declare class SMTPError extends SentlyError { readonly command: string; readonly response: string; /** Creates an SMTP protocol error. */ constructor(message: string, smtpCode: number, command: string, response: string); } /** * Encode an SMTPCommand into a Uint8Array for sending over the socket. */ export declare function encodeCommand(cmd: SMTPCommand): Uint8Array; /** * Parse raw bytes from the server into an SMTPResponse. */ export declare function parseResponse(data: Uint8Array): SMTPResponse; /** * Accumulate byte chunks until a complete SMTP response is received. */ export declare function accumulateResponse(chunks: Uint8Array[]): Uint8Array | null; /** * Select the best AUTH method from EHLO capability lines. * Priority: XOAUTH2 > CRAM-MD5 > LOGIN > PLAIN. */ export declare function selectAuthMethod(capabilities: string[]): "LOGIN" | "PLAIN" | "CRAM-MD5" | "OAUTH2"; /** * Parse an EHLO multi-line response and extract capability keywords. */ export declare function parseEHLO(response: SMTPResponse): string[]; /** * Assert that an SMTPResponse code is within the expected set. */ export declare function assertResponse(response: SMTPResponse, expectedCodes: number[], command: string): void; /** Encode AUTH LOGIN password step (second base64 chunk). */ export declare function encodeAuthLoginPass(pass: string): Uint8Array; /** Encode AUTH LOGIN user step when sent separately after 334. */ export declare function encodeAuthLoginUser(user: string): Uint8Array; /** Encode CRAM-MD5 response after challenge. */ export declare function encodeAuthCramResponse(response: string): Uint8Array; /** Encode raw SMTP line with CRLF. */ export declare function encodeLine(line: string): Uint8Array;