@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
51 lines • 2.5 kB
TypeScript
/**
* Refuse a header value EmailMessage would refuse (header injection).
*
* Python's check is str.splitlines-based: a value is refused when it
* spans more than one line, so a single trailing terminator passes (and
* serializes inside an encoded word).
*/
export declare function assertHeaderValue(value: string): void;
/**
* Fold one unstructured header (Subject, References, In-Reply-To) the
* way EmailMessage.as_bytes(policy=SMTP) does, continuation lines and
* encoded words included. Returns the header with embedded CRLFs and
* no trailing linesep. An empty value renders as `Name:` with no
* trailing blank, matching python's empty parse tree.
*/
export declare function foldUnstructured(name: string, value: string): string;
/**
* Fold an address header the way python's AddressList folder does:
* the whole rendered list stays on the label's line when it fits,
* moves to one continuation line when it fits a line by itself, and
* otherwise breaks after commas - the comma stays on the prior line
* and the next mailbox starts a continuation line behind one space.
*/
export declare function foldAddressList(name: string, mailboxes: readonly string[]): string;
/**
* The attachment Content-Disposition header with its filename folded
* as python's _fold_mime_parameters does: quoted when ASCII and short,
* RFC 2231 `filename*=utf-8''…` when non-ASCII, and split into
* numbered `filename*N*=` sections when too long for one line.
*
* An ASCII filename holding any line break is refused outright the way
* EmailMessage refuses it (header injection through the quoted-string
* form) - trailing terminators included, unlike the header-value guard.
*/
export declare function foldContentDisposition(filename: string): string;
/** contentmanager._encode_base64: 57 input bytes per 76-char line. */
export declare function encodeBase64Lines(data: Uint8Array): string;
/** A body's transfer encoding and its encoded payload. */
export interface EncodedText {
cte: '7bit' | '8bit' | 'quoted-printable' | 'base64';
/** LF-separated and LF-terminated; the caller normalizes to CRLF. */
payload: string;
}
/**
* email.contentmanager._encode_text with cte unset under the default
* policy (max_line_length 78, cte_type 8bit, linesep LF): short lines
* stay 7bit/8bit, anything longer sniffs the first ten lines to pick
* quoted-printable or base64.
*/
export declare function encodeText(body: string): EncodedText;
//# sourceMappingURL=mime.d.ts.map