UNPKG

cloudflare-email

Version:

Easily handle incoming and outgoing emails on Cloudflare Workers.

50 lines (46 loc) 1.71 kB
import { EnhancedMessage, Middleware, Context } from 'cloudflare-email-kit'; export * from 'cloudflare-email-kit'; import { MIMEMessage, Mailbox } from 'mimetext/browser'; export * from 'mimetext/browser'; export * from 'cloudflare-email-mailchannels'; export * from 'cloudflare-email-router'; /** * Creates a reply message based on the given message. * @param message - The message to reply to. * @returns The created reply message. */ declare function respond(message: EnhancedMessage): MIMEMessage; /** * Creates a mailbox with the specified address. * (tracking: https://github.com/muratgozel/MIMEText/issues/45) * @param address - The email address of the mailbox. * @returns The mailbox. */ declare function mailbox(address: string): Mailbox; /** * Converts an ArrayBuffer to a string. * @param buffer - The ArrayBuffer to convert. * @returns The converted string. */ declare function ab2str(buffer: ArrayBuffer): string; /** * Converts an ArrayBuffer to a base64 string. * @param buffer - The ArrayBuffer to be converted. * @returns The base64 string representation of the ArrayBuffer. */ declare function ab2b64(buffer: ArrayBuffer): string; declare function ab27bit(buffer: ArrayBuffer): string; /** * Middleware that guards against messages exceeding a maximum size. * If the message exceeds the maximum size, it will be rejected. */ declare class SizeGuard implements Middleware { protected max_size: number; name: string; /** * @param max_size The maximum size of a message in bytes. */ constructor(max_size: number); handle(ctx: Context, next: () => Promise<void>): Promise<void>; } export { SizeGuard, ab27bit, ab2b64, ab2str, mailbox, respond };