import { ByteSource } from './data-stream-reader-lite.js'; export type { ByteSource }; /** Input accepted by the MsgReader constructor. */ export type MsgBuffer = ByteSource; /** Thrown when the input is not a readable .msg (OLE compound document) file. */ export declare class InvalidMsgFileError extends Error { constructor(message?: string); } /** Guards against corrupt files that declare absurd stream sizes. */ export declare const MAX_DOCUMENT_SIZE: number; export interface MsgData { bigBlockSize: number; bigBlockLength: number; xBlockLength: number; batCount: number; propertyStart: number; sbatStart: number; sbatCount: number; xbatStart: number; xbatCount: number; fieldsData?: MessageData; propertyData?: (Property | null)[]; sbatData?: number[]; batData?: number[]; /** Memoized block ids backing the mini stream (root storage chain). */ miniStreamBlocks?: number[] | null; } export declare enum PropertyType { Directory = 1, Document = 2, Root = 5 } export interface Property { index: number; type: PropertyType; name: string; previousProperty: number; nextProperty: number; childProperty: number; startBlock: number; sizeBlock: number; children?: number[]; } /** String-valued message fields (see CONST.MSG.FIELD.NAME_MAPPING). */ export interface MessageTextFields { /** PidTagSubject (0037). */ subject?: string; /** PidTagNormalizedSubject (0E1D). */ normalizedSubject?: string; /** PidTagSubjectPrefix (003D). */ subjectPrefix?: string; /** PidTagMessageClass (001A), e.g. `IPM.Note`. */ messageClass?: string; /** PidTagImportance (0017). */ importance?: number; /** PidTagPriority (0026). */ priority?: number; /** PidTagSensitivity (0036). */ sensitivity?: number; /** PidTagClientSubmitTime (0039). */ clientSubmitTime?: Date; /** PidTagSentRepresentingName (0042). */ sentRepresentingName?: string; /** PidTagSubmitFlags (0047). */ submitFlags?: number; /** PidTagSentRepresentingAddrtype (0064), e.g. `SMTP`. */ sentRepresentingAddressType?: string; /** PidTagSentRepresentingEmailAddress (0065). */ sentRepresentingEmail?: string; /** PidTagConversationTopic (0070). */ conversationTopic?: string; /** PidTagSenderName (0C1A). */ senderName?: string; /** PidTagSenderEmailAddress (0C1F). */ senderEmail?: string; /** PidTagSenderSmtpAddress (0C1E). */ senderSmtpAddress?: string; /** PidTagBody (1000), plain text. */ body?: string; /** PidTagBodyHtml (1013): raw HTML, as bytes (0102) or string (001E). Use getHtmlBody(). */ bodyHtml?: Uint8Array | string; /** PidTagTransportMessageHeaders (007D). */ headers?: string; /** PidTagRtfCompressed (1009). Use getRtfBody() to decompress. */ compressedRtf?: Uint8Array; /** PidTagInternetMessageId (1035). */ internetMessageId?: string; /** PidTagMessageCodepage (3FFD), e.g. 1252. Drives 001E string decoding. */ messageCodepage?: number; /** PidTagDisplayTo (0E04). */ displayTo?: string; /** PidTagDisplayCc (0E03). */ displayCc?: string; /** PidTagDisplayBcc (0E02). */ displayBcc?: string; /** PidTagDeliverTime (0E06). */ deliverTime?: Date; /** PidTagMessageFlags (0E07). */ messageFlags?: number; /** PidTagHasAttachments (0E1B). */ hasAttachments?: boolean; /** PidTagLastModifierName (3FFA). */ lastModifierName?: string; } export interface Attachment { /** Index into the property table of the `__substg1.3701*` stream. */ dataId: number; /** Declared byte length of the attachment content. */ contentLength: number; /** PidTagAttachLongFilename (3707). */ fileName?: string; /** PidTagAttachFilename (3704, 8.3 short name). */ fileNameShort?: string; /** PidTagAttachExtension (3703). */ extension?: string; /** PidTagAttachMimeTag (370E). */ mimeType?: string; /** PidTagAttachContentId (3712). */ pidContentId?: string; /** PidTagAttachContentLocation (3716). */ attachContentLocation?: string; /** PidTagAttachMethod (3705). */ attachMethod?: number; /** * The embedded message for attachments that contain one * (`hasInnerMsg`), parsed recursively. */ embeddedMessage?: MessageData; /** * True when the attachment embeds another message (unsupported content). * @deprecated Use hasInnerMsg instead. */ innerMsgContent?: boolean; /** True when the attachment embeds another message (unsupported content). */ hasInnerMsg?: boolean; /** Decoded values for tags without a friendly name, keyed by 4-hex-digit class. */ extraProperties?: Record; } export interface Recipient { /** PidTagDisplayName (3001). */ name?: string; /** PidTagEmailAddress (3003). */ email?: string; /** PidTagAddressType (3002), e.g. `SMTP`. */ addressType?: string; /** PidTagSmtpAddress (39FE). */ smtpAddress?: string; /** PidTagSearchKey (300B). */ searchKey?: Uint8Array; /** Decoded values for tags without a friendly name, keyed by 4-hex-digit class. */ extraProperties?: Record; } export interface MessageData extends MessageTextFields { attachments: Attachment[]; recipients: Recipient[]; /** Decoded values for tags without a friendly name, keyed by 4-hex-digit class. */ extraProperties: Record; } /** * Backwards-compatible alias for MessageData. * (The legacy `error`/`dataId`/`contentLength`/`innerMsgContent` members are * no longer populated; invalid files now throw InvalidMsgFileError.) */ export type FieldsData = MessageData; /** Fully decoded attachment content, plus the descriptor metadata. */ export interface AttachmentContent { /** Index into the property table of the `__substg1.3701*` stream. */ dataId?: number; fileName?: string; fileNameShort?: string; extension?: string; mimeType?: string; pidContentId?: string; /** PidTagAttachContentLocation (3716). */ attachContentLocation?: string; /** PidTagAttachMethod (3705). */ attachMethod?: number; /** Decoded values for tags without a friendly name, keyed by 4-hex-digit class. */ extraProperties?: Record; contentLength: number; content: Uint8Array; } export default class MsgReader { private ds; private fileData; constructor(input: MsgBuffer); /** Non-throwing check: true when `input` starts with the OLE compound-document magic. */ static isMsgFile(input: MsgBuffer): boolean; private ensureParsed; /** * Returns message metadata, recipients and attachment descriptors. * Attachment *contents* are not loaded; use getAttachment() for those. * The returned object is a defensive copy — mutating it does not affect * the reader — but binary payloads (compressedRtf, bodyHtml) are shared * views and should be treated as read-only. */ getFileData(): MessageData; /** Returns the parsed OLE directory entries (for advanced use). */ getProperties(): (Property | null)[]; /** * Reads an attachment's content. * @param attachment attachment index, or an attachment descriptor from getFileData(). */ getAttachment(attachment: number | Attachment): AttachmentContent; /** Reads an attachment's content by its index in `getFileData().attachments`. */ getAttachmentByIndex(index: number): AttachmentContent; /** Reads an attachment's content from its descriptor. */ getAttachmentData(attachment: Attachment): AttachmentContent; /** * Decompresses the PidTagRtfCompressed body to an RTF string. * Returns null when the message has no compressed RTF body. */ getRtfBody(): string | null; /** * Returns the PidTagBodyHtml body as a string, or null when absent. * Binary payloads are decoded via BOM / `` / strict-UTF-8 * probing, falling back to the message codepage (windows-1252 default). */ getHtmlBody(): string | null; } //# sourceMappingURL=msg-reader.d.ts.map