/** * @module * Cloudflare Workers socket adapter for SMTP via cloudflare:sockets. * * @example * ```ts * import { CloudflareAdapter } from "sently/adapters/cf"; * import { createSMTPMailer } from "sently/smtp"; * * const mailer = await createSMTPMailer({ * host: "smtp.example.com", * adapter: new CloudflareAdapter(), * auth: { user: "relay@example.com", pass: "secret" }, * }); * ``` */ import type { SocketAdapter, TLSOptions } from "../core/types.js"; /** Configuration options for {@link CloudflareAdapter}. */ export interface CloudflareAdapterOptions { /** Use implicit TLS on connect (secureTransport: "on"). Default: false. */ secure?: boolean; /** Enable STARTTLS upgrade after plain connect. Default: true when not secure. */ starttls?: boolean; /** Reserved for future TLS tuning (Workers sockets API). */ tls?: TLSOptions; } /** * Cloudflare Workers socket adapter via cloudflare:sockets. * * Limitations: * - No connection pooling (isolate lifecycle) * - No file system access for attachment.path * - No DNS MX lookup — explicit SMTP relay host required */ export declare class CloudflareAdapter implements SocketAdapter { /** Underlying Cloudflare Workers socket. */ private socket; /** Writable stream writer for outbound bytes. */ private writer; /** Whether the connection is currently encrypted. */ private _secure; /** Whether the socket is connected. */ private _connected; /** Whether implicit TLS is used on connect (port 465 style). */ private readonly directTls; /** Whether STARTTLS upgrade is enabled after plain connect. */ private readonly starttls; /** Creates a Cloudflare Workers socket adapter. */ constructor(options?: CloudflareAdapterOptions); /** Whether the connection uses TLS. */ get secure(): boolean; /** Whether the socket is currently connected. */ get connected(): boolean; /** Opens a TCP or TLS connection to the given host and port. */ connect(host: string, port: number): Promise; /** Upgrades a plain connection to TLS via STARTTLS. */ startTLS(_options?: TLSOptions): Promise; /** Writes raw bytes to the socket. */ write(data: Uint8Array): Promise; /** Reads incoming socket data as an async iterable of byte chunks. */ read(): AsyncGenerator; /** Closes the socket connection. */ close(): Promise; }