mimeParse.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * MIME Source Parser for Attachment Extraction
  3. *
  4. * Parses raw email MIME source to extract attachment metadata and content.
  5. * Used as a fallback when AppleScript's `mail attachments` returns empty
  6. * (which happens across all account types: iCloud, Google, Exchange).
  7. *
  8. * @module utils/mimeParse
  9. */
  10. export interface MimeAttachmentInfo {
  11. /** Filename from Content-Disposition or Content-Type name parameter */
  12. name: string;
  13. /** MIME type from Content-Type header */
  14. mimeType: string;
  15. /** Size in bytes from Content-Disposition size parameter, or estimated from body */
  16. size: number;
  17. }
  18. export interface MimeAttachmentData extends MimeAttachmentInfo {
  19. /** Decoded binary content */
  20. data: Buffer;
  21. }
  22. /**
  23. * Parse MIME source and return metadata for all file attachments.
  24. * Skips inline dispositions (signature images, etc.). Descends into
  25. * nested multipart/* containers.
  26. *
  27. * @param source - Raw MIME source of the email
  28. * @returns Array of attachment metadata (name, mimeType, size)
  29. */
  30. export declare function parseMimeAttachments(source: string): MimeAttachmentInfo[];
  31. /**
  32. * Extract and decode a specific attachment from MIME source by filename.
  33. * Supports base64, quoted-printable, and 7bit/8bit/binary transfer encodings.
  34. * Descends into nested multipart/* containers.
  35. *
  36. * @param source - Raw MIME source of the email
  37. * @param attachmentName - Filename to extract
  38. * @returns Decoded attachment data, or null if not found
  39. */
  40. export declare function extractMimeAttachment(source: string, attachmentName: string): MimeAttachmentData | null;
  41. //# sourceMappingURL=mimeParse.d.ts.map