-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathpostal-mime.d.ts
More file actions
93 lines (82 loc) · 2.32 KB
/
Copy pathpostal-mime.d.ts
File metadata and controls
93 lines (82 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
export type RawEmail = string | ArrayBuffer | Uint8Array | Blob | Buffer | ReadableStream;
export type Header = {
/** Lowercase header name */
key: string;
/** Original header name preserving case */
originalKey: string;
/** Header value */
value: string;
};
export type HeaderLine = {
/** Lowercase header name */
key: string;
/** Complete raw header line including key and value (with folded lines merged) */
line: string;
};
export type Mailbox = {
name: string;
address: string;
group?: undefined;
};
export type Address =
| Mailbox
| {
name: string;
address?: undefined;
group: Mailbox[];
};
export type Attachment = {
filename: string | null;
mimeType: string;
disposition: 'attachment' | 'inline' | null;
related?: boolean;
description?: string;
contentId?: string;
method?: string;
/**
* Set when a `message/rfc822` part hit `maxRfc822NestingDepth` and was emitted as an
* attachment instead of being parsed. Its own parts are not reflected in `text`,
* `html` or `attachments`.
*/
rfc822DepthExceeded?: boolean;
content: ArrayBuffer | Uint8Array | string;
encoding?: 'base64' | 'utf8';
};
export type Email = {
headers: Header[];
headerLines: HeaderLine[];
from?: Address;
sender?: Address;
replyTo?: Address[];
deliveredTo?: string;
returnPath?: string;
to?: Address[];
cc?: Address[];
bcc?: Address[];
subject?: string;
messageId?: string;
inReplyTo?: string;
references?: string;
date?: string;
html?: string;
text?: string;
attachments: Attachment[];
};
export type AddressParserOptions = {
flatten?: boolean;
};
export function addressParser(str: string, options?: AddressParserOptions): Address[];
export function decodeWords(str: string): string;
export type PostalMimeOptions = {
rfc822Attachments?: boolean;
forceRfc822Attachments?: boolean;
attachmentEncoding?: 'base64' | 'utf8' | 'arraybuffer';
maxNestingDepth?: number;
maxHeadersSize?: number;
maxRfc822NestingDepth?: number;
};
export default class PostalMime {
constructor(options?: PostalMimeOptions);
static parse(email: RawEmail, options?: PostalMimeOptions): Promise<Email>;
parse(email: RawEmail): Promise<Email>;
}