import type { ImapFlow } from '../imap-flow.js'; /** * Credentials for the AUTHENTICATE command */ export interface AuthenticateCredentials { /** OAuth2 access token for OAUTHBEARER/XOAUTH2 authentication */ accessToken?: string | undefined; /** Password for PLAIN or LOGIN authentication */ password?: string | undefined; /** Force a specific login method (e.g., 'AUTH=PLAIN', 'AUTH=LOGIN') */ loginMethod?: string | undefined; /** Authorization identity for PLAIN authentication */ authzid?: string | undefined; } /** * Authenticates user using the best available method. * * @param connection - IMAP connection instance * @param username - The username to authenticate with * @param credentials - Authentication credentials * @returns The authenticated username, or undefined if already authenticated * @throws {Error} If no supported authentication mechanism is available or if authentication fails */ export default function authenticate(connection: ImapFlow, username: string, { accessToken, password, loginMethod, authzid }: AuthenticateCredentials): Promise;