imapflow 1.0.188 → 1.0.189

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/types.d.ts DELETED
@@ -1,1123 +0,0 @@
1
- /// <reference types="node" />
2
-
3
- declare module "imapflow" {
4
- import { EventEmitter } from "events";
5
-
6
- /**
7
- * IMAP connection options
8
- * @property host - Hostname of the IMAP server.
9
- * @property port - Port number for the IMAP server.
10
- * @property [secure = false] - If `true`, establishes the connection directly over TLS (commonly on port 993).
11
- * If `false`, a plain (unencrypted) connection is used first and, if possible, the connection is upgraded to STARTTLS.
12
- * @property [doSTARTTLS] - Determines whether to upgrade the connection to TLS via STARTTLS:
13
- * - **true**: Start unencrypted and upgrade to TLS using STARTTLS before authentication.
14
- * The connection fails if the server does not support STARTTLS or the upgrade fails.
15
- * Note that `secure=true` combined with `doSTARTTLS=true` is invalid.
16
- * - **false**: Never use STARTTLS, even if the server advertises support.
17
- * This is useful if the server has a broken TLS setup.
18
- * Combined with `secure=false`, this results in a fully unencrypted connection.
19
- * Make sure you warn users about the security risks.
20
- * - **undefined** (default): If `secure=false` (default), attempt to upgrade to TLS via STARTTLS before authentication if the server supports it. If not supported, continue unencrypted. This may expose the connection to a downgrade attack.
21
- * @property [servername] - Server name for SNI or when using an IP address as `host`.
22
- * @property [disableCompression = false] - If `true`, the client does not attempt to use the COMPRESS=DEFLATE extension.
23
- * @property auth - Authentication options. Authentication occurs automatically during {@link connect}.
24
- * @property auth.user - Username for authentication.
25
- * @property [auth.pass] - Password for regular authentication.
26
- * @property [auth.accessToken] - OAuth2 access token, if using OAuth2 authentication.
27
- * @property [auth.loginMethod] - Optional login method for password-based authentication (e.g., "LOGIN", "AUTH=LOGIN", or "AUTH=PLAIN").
28
- * If not set, ImapFlow chooses based on available mechanisms.
29
- * @property [clientInfo] - Client identification info sent to the server (via the ID command).
30
- * @property [disableAutoIdle = false] - If `true`, do not start IDLE automatically. Useful when only specific operations are needed.
31
- * @property [tls] - Additional TLS options. For details, see [Node.js TLS connect](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback).
32
- * @property [tls.rejectUnauthorized = true] - If `false`, allows self-signed or expired certificates.
33
- * @property [tls.minVersion = 'TLSv1.2'] - Minimum accepted TLS version (e.g., `'TLSv1.2'`).
34
- * @property [tls.minDHSize = 1024] - Minimum size (in bits) of the DH parameter for TLS connections.
35
- * @property [logger] - Custom logger instance with `debug(obj)`, `info(obj)`, `warn(obj)`, and `error(obj)` methods.
36
- * If `false`, logging is disabled. If not provided, ImapFlow logs to console in [pino format](https://getpino.io/).
37
- * @property [logRaw = false] - If `true`, logs all raw data (read and written) in base64 encoding. You can pipe such logs to [eerawlog](https://github.com/postalsys/eerawlog) command for readable output.
38
- * @property [emitLogs = false] - If `true`, emits `'log'` events with the same data passed to the logger.
39
- * @property [verifyOnly = false] - If `true`, disconnects after successful authentication without performing other actions.
40
- * @property [proxy] - Proxy URL. Supports HTTP CONNECT (`http://`, `https://`) and SOCKS (`socks://`, `socks4://`, `socks5://`).
41
- * @property [qresync = false] - If `true`, enables QRESYNC support so that EXPUNGE notifications include `uid` instead of `seq`.
42
- * @property [maxIdleTime] - If set, breaks and restarts IDLE every `maxIdleTime` milliseconds.
43
- * @property [missingIdleCommand = "NOOP"] - Command to use if the server does not support IDLE.
44
- * @property [disableBinary = false] - If `true`, ignores the BINARY extension for FETCH and APPEND operations.
45
- * @property [disableAutoEnable = false] - If `true`, do not automatically enable supported IMAP extensions.
46
- * @property [connectionTimeout = 90000] - Maximum time (in milliseconds) to wait for the connection to establish. Defaults to 90 seconds.
47
- * @property [greetingTimeout = 16000] - Maximum time (in milliseconds) to wait for the server greeting after a connection is established. Defaults to 16 seconds.
48
- * @property [socketTimeout = 300000] - Maximum period of inactivity (in milliseconds) before terminating the connection. Defaults to 5 minutes.
49
- */
50
- class ImapFlow extends EventEmitter {
51
- /**
52
- * Current module version as a static class property
53
- * @property version - Module version
54
- */
55
- version: {
56
- version: string;
57
- };
58
- /**
59
- * Instance ID for logs
60
- */
61
- id: string;
62
- /**
63
- * Server identification info. Available after successful `connect()`.
64
- * If server does not provide identification info then this value is `null`.
65
- * @example
66
- * await client.connect();
67
- * console.log(client.serverInfo.vendor);
68
- */
69
- serverInfo: IdInfoObject | null;
70
- /**
71
- * Is the connection currently encrypted or not
72
- */
73
- secureConnection: boolean;
74
- /**
75
- * Active IMAP capabilities. Value is either `true` for togglabe capabilities (eg. `UIDPLUS`)
76
- * or a number for capabilities with a value (eg. `APPENDLIMIT`)
77
- */
78
- capabilities: Map<string, boolean | number>;
79
- /**
80
- * Enabled capabilities. Usually `CONDSTORE` and `UTF8=ACCEPT` if server supports these.
81
- */
82
- enabled: Set<string>;
83
- /**
84
- * Is the connection currently usable or not
85
- */
86
- usable: boolean;
87
- /**
88
- * Currently authenticated user or `false` if mailbox is not open
89
- * or `true` if connection was authenticated by PREAUTH
90
- */
91
- authenticated: string | boolean;
92
- /**
93
- * Currently selected mailbox or `false` if mailbox is not open
94
- */
95
- mailbox: MailboxObject | boolean;
96
- /**
97
- * Is current mailbox idling (`true`) or not (`false`)
98
- */
99
- idling: boolean;
100
- /**
101
- * Tries to upgrade the connection to TLS using STARTTLS.
102
- * @returns true, if the connection is now protected by TLS, either direct TLS or STARTTLS.
103
- */
104
- upgradeToSTARTTLS(): boolean;
105
- /**
106
- * Initiates a connection against IMAP server. Throws if anything goes wrong. This is something you have to call before you can run any IMAP commands
107
- * @example
108
- * let client = new ImapFlow({...});
109
- * await client.connect();
110
- */
111
- connect(): Promise<void>;
112
- /**
113
- * Graceful connection close by sending logout command to server. TCP connection is closed once command is finished.
114
- * @example
115
- * let client = new ImapFlow({...});
116
- * await client.connect();
117
- * ...
118
- * await client.logout();
119
- */
120
- logout(): Promise<void>;
121
- /**
122
- * Closes TCP connection without notifying the server.
123
- * @example
124
- * let client = new ImapFlow({...});
125
- * await client.connect();
126
- * ...
127
- * client.close();
128
- */
129
- close(): void;
130
- /**
131
- * Returns current quota
132
- * @example
133
- * let quota = await client.getQuota();
134
- * console.log(quota.storage.used, quota.storage.available)
135
- * @param [path] - Optional mailbox path if you want to check quota for specific folder
136
- * @returns Quota information or `false` if QUTOA extension is not supported or requested path does not exist
137
- */
138
- getQuota(path?: string): Promise<QuotaResponse | Boolean>;
139
- /**
140
- * Lists available mailboxes as an Array
141
- * @example
142
- * let list = await client.list();
143
- * list.forEach(mailbox=>console.log(mailbox.path));
144
- * @param [options] - defines additional listing options
145
- * @returns An array of ListResponse objects
146
- */
147
- list(options?: ListOptions): Promise<ListResponse[]>;
148
- /**
149
- * Lists available mailboxes as a tree structured object
150
- * @example
151
- * let tree = await client.listTree();
152
- * tree.folders.forEach(mailbox=>console.log(mailbox.path));
153
- * @param [options] - defines additional listing options
154
- * @returns Tree structured object
155
- */
156
- listTree(options?: ListOptions): Promise<ListTreeResponse>;
157
- /**
158
- * Performs a no-op call against server
159
- */
160
- noop(): Promise<void>;
161
- /**
162
- * Creates a new mailbox folder and sets up subscription for the created mailbox. Throws on error.
163
- * @example
164
- * let info = await client.mailboxCreate(['parent', 'child']);
165
- * console.log(info.path);
166
- * // "INBOX.parent.child" // assumes "INBOX." as namespace prefix and "." as delimiter
167
- * @param path - Full mailbox path. Unicode is allowed. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
168
- * @returns Mailbox info
169
- */
170
- mailboxCreate(path: string | any[]): Promise<MailboxCreateResponse>;
171
- /**
172
- * Renames a mailbox. Throws on error.
173
- * @example
174
- * let info = await client.mailboxRename('parent.child', 'Important stuff ❗️');
175
- * console.log(info.newPath);
176
- * // "INBOX.Important stuff ❗️" // assumes "INBOX." as namespace prefix
177
- * @param path - Path for the mailbox to rename. Unicode is allowed. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
178
- * @param newPath - New path for the mailbox
179
- * @returns Mailbox info
180
- */
181
- mailboxRename(path: string | any[], newPath: string | any[]): Promise<MailboxRenameResponse>;
182
- /**
183
- * Deletes a mailbox. Throws on error.
184
- * @example
185
- * let info = await client.mailboxDelete('Important stuff ❗️');
186
- * console.log(info.path);
187
- * // "INBOX.Important stuff ❗️" // assumes "INBOX." as namespace prefix
188
- * @param path - Path for the mailbox to delete. Unicode is allowed. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
189
- * @returns Mailbox info
190
- */
191
- mailboxDelete(path: string | any[]): Promise<MailboxDeleteResponse>;
192
- /**
193
- * Subscribes to a mailbox
194
- * @example
195
- * await client.mailboxSubscribe('Important stuff ❗️');
196
- * @param path - Path for the mailbox to subscribe to. Unicode is allowed. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
197
- * @returns `true` if subscription operation succeeded, `false` otherwise
198
- */
199
- mailboxSubscribe(path: string | any[]): Promise<Boolean>;
200
- /**
201
- * Unsubscribes from a mailbox
202
- * @example
203
- * await client.mailboxUnsubscribe('Important stuff ❗️');
204
- * @param path - **Path for the mailbox** to unsubscribe from. Unicode is allowed. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
205
- * @returns `true` if unsubscription operation succeeded, `false` otherwise
206
- */
207
- mailboxUnsubscribe(path: string | any[]): Promise<Boolean>;
208
- /**
209
- * Opens a mailbox to access messages. You can perform message operations only against an opened mailbox.
210
- * Using {@link module:imapflow~ImapFlow#getMailboxLock|getMailboxLock()} instead of `mailboxOpen()` is preferred. Both do the same thing
211
- * but next `getMailboxLock()` call is not executed until previous one is released.
212
- * @example
213
- * let mailbox = await client.mailboxOpen('Important stuff ❗️');
214
- * console.log(mailbox.exists);
215
- * // 125
216
- * @param path - **Path for the mailbox** to open
217
- * @param [options] - optional options
218
- * @param [options.readOnly = false] - If `true` then opens mailbox in read-only mode. You can still try to perform write operations but these would probably fail.
219
- * @returns Mailbox info
220
- */
221
- mailboxOpen(path: string | any[], options?: {
222
- readOnly?: boolean;
223
- }): Promise<MailboxObject>;
224
- /**
225
- * Closes a previously opened mailbox
226
- * @example
227
- * let mailbox = await client.mailboxOpen('INBOX');
228
- * await client.mailboxClose();
229
- * @returns Did the operation succeed or not
230
- */
231
- mailboxClose(): Promise<Boolean>;
232
- /**
233
- * Requests the status of the indicated mailbox. Only requested status values will be returned.
234
- * @example
235
- * let status = await client.status('INBOX', {unseen: true});
236
- * console.log(status.unseen);
237
- * // 123
238
- * @param path - mailbox path to check for (unicode string)
239
- * @param query - defines requested status items
240
- * @param query.messages - if `true` request count of messages
241
- * @param query.recent - if `true` request count of messages with \\Recent tag
242
- * @param query.uidNext - if `true` request predicted next UID
243
- * @param query.uidValidity - if `true` request mailbox `UIDVALIDITY` value
244
- * @param query.unseen - if `true` request count of unseen messages
245
- * @param query.highestModseq - if `true` request last known modseq value
246
- * @returns status of the indicated mailbox
247
- */
248
- status(path: string, query: {
249
- messages: boolean;
250
- recent: boolean;
251
- uidNext: boolean;
252
- uidValidity: boolean;
253
- unseen: boolean;
254
- highestModseq: boolean;
255
- }): Promise<StatusObject>;
256
- /**
257
- * Starts listening for new or deleted messages from the currently opened mailbox. Only required if {@link ImapFlow#disableAutoIdle} is set to `true`
258
- * otherwise IDLE is started by default on connection inactivity. NB! If `idle()` is called manually then it does not
259
- * return until IDLE is finished which means you would have to call some other command out of scope.
260
- * @example
261
- * let mailbox = await client.mailboxOpen('INBOX');
262
- *
263
- * await client.idle();
264
- * @returns Did the operation succeed or not
265
- */
266
- idle(): Promise<Boolean>;
267
- /**
268
- * Sets flags for a message or message range
269
- * @example
270
- * let mailbox = await client.mailboxOpen('INBOX');
271
- * // mark all unseen messages as seen (and remove other flags)
272
- * await client.messageFlagsSet({seen: false}, ['\Seen]);
273
- * @param range - Range to filter the messages
274
- * @param Array - of flags to set. Only flags that are permitted to set are used, other flags are ignored
275
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
276
- * @param [options.unchangedSince] - If set then only messages with a lower or equal `modseq` value are updated. Ignored if server does not support `CONDSTORE` extension.
277
- * @param [options.useLabels = false] - If true then update Gmail labels instead of message flags
278
- * @returns Did the operation succeed or not
279
- */
280
- messageFlagsSet(range: SequenceString | Number[] | SearchObject, Array: string[], options?: {
281
- uid?: boolean;
282
- unchangedSince?: bigint;
283
- useLabels?: boolean;
284
- }): Promise<Boolean>;
285
- /**
286
- * Adds flags for a message or message range
287
- * @example
288
- * let mailbox = await client.mailboxOpen('INBOX');
289
- * // mark all unseen messages as seen (and keep other flags as is)
290
- * await client.messageFlagsAdd({seen: false}, ['\Seen]);
291
- * @param range - Range to filter the messages
292
- * @param Array - of flags to set. Only flags that are permitted to set are used, other flags are ignored
293
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
294
- * @param [options.unchangedSince] - If set then only messages with a lower or equal `modseq` value are updated. Ignored if server does not support `CONDSTORE` extension.
295
- * @param [options.useLabels = false] - If true then update Gmail labels instead of message flags
296
- * @returns Did the operation succeed or not
297
- */
298
- messageFlagsAdd(range: SequenceString | Number[] | SearchObject, Array: string[], options?: {
299
- uid?: boolean;
300
- unchangedSince?: bigint;
301
- useLabels?: boolean;
302
- }): Promise<Boolean>;
303
- /**
304
- * Remove specific flags from a message or message range
305
- * @example
306
- * let mailbox = await client.mailboxOpen('INBOX');
307
- * // mark all seen messages as unseen by removing \\Seen flag
308
- * await client.messageFlagsRemove({seen: true}, ['\Seen]);
309
- * @param range - Range to filter the messages
310
- * @param Array - of flags to remove. Only flags that are permitted to set are used, other flags are ignored
311
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
312
- * @param [options.unchangedSince] - If set then only messages with a lower or equal `modseq` value are updated. Ignored if server does not support `CONDSTORE` extension.
313
- * @param [options.useLabels = false] - If true then update Gmail labels instead of message flags
314
- * @returns Did the operation succeed or not
315
- */
316
- messageFlagsRemove(range: SequenceString | Number[] | SearchObject, Array: string[], options?: {
317
- uid?: boolean;
318
- unchangedSince?: bigint;
319
- useLabels?: boolean;
320
- }): Promise<Boolean>;
321
- /**
322
- * Sets a colored flag for an email. Only supported by mail clients like Apple Mail
323
- * @example
324
- * let mailbox = await client.mailboxOpen('INBOX');
325
- * // add a purple flag for all emails
326
- * await client.setFlagColor('1:*', 'Purple');
327
- * @param range - Range to filter the messages
328
- * @param The - color to set. One of 'red', 'orange', 'yellow', 'green', 'blue', 'purple', and 'grey'
329
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
330
- * @param [options.unchangedSince] - If set then only messages with a lower or equal `modseq` value are updated. Ignored if server does not support `CONDSTORE` extension.
331
- * @returns Did the operation succeed or not
332
- */
333
- setFlagColor(range: SequenceString | Number[] | SearchObject, The: string, options?: {
334
- uid?: boolean;
335
- unchangedSince?: bigint;
336
- }): Promise<Boolean>;
337
- /**
338
- * Delete messages from the currently opened mailbox. Method does not indicate info about deleted messages,
339
- * instead you should be using {@link ImapFlow#expunge} event for this
340
- * @example
341
- * let mailbox = await client.mailboxOpen('INBOX');
342
- * // delete all seen messages
343
- * await client.messageDelete({seen: true});
344
- * @param range - Range to filter the messages
345
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
346
- * @returns Did the operation succeed or not
347
- */
348
- messageDelete(range: SequenceString | Number[] | SearchObject, options?: {
349
- uid?: boolean;
350
- }): Promise<Boolean>;
351
- /**
352
- * Appends a new message to a mailbox
353
- * @example
354
- * await client.append('INBOX', rawMessageBuffer, ['\\Seen'], new Date(2000, 1, 1));
355
- * @param path - Mailbox path to upload the message to (unicode string)
356
- * @param content - RFC822 formatted email message
357
- * @param [flags] - an array of flags to be set for the uploaded message
358
- * @param [idate = now] - internal date to be set for the message
359
- * @returns info about uploaded message
360
- */
361
- append(path: string, content: string | Buffer, flags?: string[], idate?: Date | string): Promise<AppendResponseObject>;
362
- /**
363
- * Copies messages from current mailbox to destination mailbox
364
- * @example
365
- * await client.mailboxOpen('INBOX');
366
- * // copy all messages to a mailbox called "Backup" (must exist)
367
- * let result = await client.messageCopy('1:*', 'Backup');
368
- * console.log('Copied %s messages', result.uidMap.size);
369
- * @param range - Range of messages to copy
370
- * @param destination - Mailbox path to copy the messages to
371
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
372
- * @returns info about copies messages
373
- */
374
- messageCopy(range: SequenceString | Number[] | SearchObject, destination: string, options?: {
375
- uid?: boolean;
376
- }): Promise<CopyResponseObject>;
377
- /**
378
- * Moves messages from current mailbox to destination mailbox
379
- * @example
380
- * await client.mailboxOpen('INBOX');
381
- * // move all messages to a mailbox called "Trash" (must exist)
382
- * let result = await client.messageMove('1:*', 'Trash');
383
- * console.log('Moved %s messages', result.uidMap.size);
384
- * @param range - Range of messages to move
385
- * @param destination - Mailbox path to move the messages to
386
- * @param [options.uid] - If `true` then uses UID {@link SequenceString} instead of sequence numbers
387
- * @returns info about moved messages
388
- */
389
- messageMove(range: SequenceString | Number[] | SearchObject, destination: string, options?: {
390
- uid?: boolean;
391
- }): Promise<CopyResponseObject>;
392
- /**
393
- * Search messages from the currently opened mailbox
394
- * @example
395
- * let mailbox = await client.mailboxOpen('INBOX');
396
- * // find all unseen messages
397
- * let list = await client.search({seen: false});
398
- * // use OR modifier (array of 2 or more search queries)
399
- * let list = await client.search({
400
- * seen: false,
401
- * or: [
402
- * {flagged: true},
403
- * {from: 'andris'},
404
- * {subject: 'test'}
405
- * ]});
406
- * @param query - Query to filter the messages
407
- * @param [options.uid] - If `true` then returns UID numbers instead of sequence numbers
408
- * @returns An array of sequence or UID numbers
409
- */
410
- search(query: SearchObject, options?: {
411
- uid?: boolean;
412
- }): Promise<Number[]>;
413
- /**
414
- * Fetch messages from the currently opened mailbox
415
- * @example
416
- * let mailbox = await client.mailboxOpen('INBOX');
417
- * // fetch UID for all messages in a mailbox
418
- * for await (let msg of client.fetch('1:*', {uid: true})){
419
- * console.log(msg.uid);
420
- * // NB! You can not run any IMAP commands in this loop
421
- * // otherwise you will end up in a deadloop
422
- * }
423
- * @param range - Range of messages to fetch
424
- * @param query - Fetch query
425
- * @param [options.uid] - If `true` then uses UID numbers instead of sequence numbers for `range`
426
- * @param [options.changedSince] - If set then only messages with a higher modseq value are returned. Ignored if server does not support `CONDSTORE` extension.
427
- * @param [options.binary = false] - If `true` then requests a binary response if the server supports this
428
- */
429
- fetch(range: SequenceString | Number[] | SearchObject, query: FetchQueryObject, options?: {
430
- uid?: boolean;
431
- changedSince?: bigint;
432
- binary?: boolean;
433
- }): void;
434
- /**
435
- * Fetch messages from the currently opened mailbox.
436
- *
437
- * This method will fetch all messages before resolving the promise, unlike .fetch(), which
438
- * is an async generator. Do not use large ranges like 1:*, as this might exhaust all available
439
- * memory if the mailbox contains a large number of emails.
440
- * @example
441
- * let mailbox = await client.mailboxOpen('INBOX');
442
- * // fetch UID for all messages in a mailbox
443
- * const messages = await client.fetchAll('1:*', {uid: true});
444
- * for (let msg of messages){
445
- * console.log(msg.uid);
446
- * }
447
- * @param range - Range of messages to fetch
448
- * @param query - Fetch query
449
- * @param [options.uid] - If `true` then uses UID numbers instead of sequence numbers for `range`
450
- * @param [options.changedSince] - If set then only messages with a higher modseq value are returned. Ignored if server does not support `CONDSTORE` extension.
451
- * @param [options.binary = false] - If `true` then requests a binary response if the server supports this
452
- * @returns Array of Message data object
453
- */
454
- fetchAll(range: SequenceString | Number[] | SearchObject, query: FetchQueryObject, options?: {
455
- uid?: boolean;
456
- changedSince?: bigint;
457
- binary?: boolean;
458
- }): Promise<FetchMessageObject[]>;
459
- /**
460
- * Fetch a single message from the currently opened mailbox
461
- * @example
462
- * let mailbox = await client.mailboxOpen('INBOX');
463
- * // fetch UID for the last email in the selected mailbox
464
- * let lastMsg = await client.fetchOne('*', {uid: true})
465
- * console.log(lastMsg.uid);
466
- * @param seq - Single UID or sequence number of the message to fetch for
467
- * @param query - Fetch query
468
- * @param [options.uid] - If `true` then uses UID number instead of sequence number for `seq`
469
- * @param [options.binary = false] - If `true` then requests a binary response if the server supports this
470
- * @returns Message data object
471
- */
472
- fetchOne(seq: SequenceString, query: FetchQueryObject, options?: {
473
- uid?: boolean;
474
- binary?: boolean;
475
- }): Promise<FetchMessageObject>;
476
- /**
477
- * Download either full rfc822 formatted message or a specific bodystructure part as a Stream.
478
- * Bodystructure parts are decoded so the resulting stream is a binary file. Text content
479
- * is automatically converted to UTF-8 charset.
480
- * @example
481
- * let mailbox = await client.mailboxOpen('INBOX');
482
- * // download body part nr '1.2' from latest message
483
- * let {meta, content} = await client.download('*', '1.2');
484
- * content.pipe(fs.createWriteStream(meta.filename));
485
- * @param range - UID or sequence number for the message to fetch
486
- * @param [part] - If not set then downloads entire rfc822 formatted message, otherwise downloads specific bodystructure part
487
- * @param [options.uid] - If `true` then uses UID number instead of sequence number for `range`
488
- * @param [options.maxBytes] - If set then limits download size to specified bytes
489
- * @param [options.chunkSize = 65536] - How large content parts to ask from the server
490
- * @returns Download data object
491
- */
492
- download(range: SequenceString, part?: string, options?: {
493
- uid?: boolean;
494
- maxBytes?: number;
495
- chunkSize?: number;
496
- }): Promise<DownloadObject>;
497
- /**
498
- * Fetch multiple attachments as Buffer values
499
- * @example
500
- * let mailbox = await client.mailboxOpen('INBOX');
501
- * // download body parts '2', and '3' from all messages in the selected mailbox
502
- * let response = await client.downloadMany('*', ['2', '3']);
503
- * process.stdout.write(response[2].content)
504
- * process.stdout.write(response[3].content)
505
- * @param range - UID or sequence number for the message to fetch
506
- * @param parts - A list of bodystructure parts
507
- * @param [options.uid] - If `true` then uses UID number instead of sequence number for `range`
508
- * @returns Download data object
509
- */
510
- downloadMany(range: SequenceString, parts: string, options?: {
511
- uid?: boolean;
512
- }): Promise<object>;
513
- /**
514
- * Opens a mailbox if not already open and returns a lock. Next call to `getMailboxLock()` is queued
515
- * until previous lock is released. This is suggested over {@link module:imapflow~ImapFlow#mailboxOpen|mailboxOpen()} as
516
- * `getMailboxLock()` gives you a weak transaction while `mailboxOpen()` has no guarantees whatsoever that another
517
- * mailbox is opened while you try to call multiple fetch or store commands.
518
- * @example
519
- * let lock = await client.getMailboxLock('INBOX');
520
- * try {
521
- * // do something in the mailbox
522
- * } finally {
523
- * // use finally{} to make sure lock is released even if exception occurs
524
- * lock.release();
525
- * }
526
- * @param path - **Path for the mailbox** to open
527
- * @param [options] - optional options
528
- * @param [options.readOnly = false] - If `true` then opens mailbox in read-only mode. You can still try to perform write operations but these would probably fail.
529
- * @returns Mailbox lock
530
- */
531
- getMailboxLock(path: string | any[], options?: {
532
- readOnly?: boolean;
533
- }): Promise<MailboxLockObject>;
534
- /**
535
- * Hostname of the IMAP server.
536
- */
537
- host: string;
538
- /**
539
- * Port number for the IMAP server.
540
- */
541
- port: number;
542
- /**
543
- * If `true`, establishes the connection directly over TLS (commonly on port 993).
544
- If `false`, a plain (unencrypted) connection is used first and, if possible, the connection is upgraded to STARTTLS.
545
- */
546
- secure?: boolean;
547
- /**
548
- * Determines whether to upgrade the connection to TLS via STARTTLS:
549
- - **true**: Start unencrypted and upgrade to TLS using STARTTLS before authentication.
550
- The connection fails if the server does not support STARTTLS or the upgrade fails.
551
- Note that `secure=true` combined with `doSTARTTLS=true` is invalid.
552
- - **false**: Never use STARTTLS, even if the server advertises support.
553
- This is useful if the server has a broken TLS setup.
554
- Combined with `secure=false`, this results in a fully unencrypted connection.
555
- Make sure you warn users about the security risks.
556
- - **undefined** (default): If `secure=false` (default), attempt to upgrade to TLS via STARTTLS before authentication if the server supports it. If not supported, continue unencrypted. This may expose the connection to a downgrade attack.
557
- */
558
- doSTARTTLS?: boolean;
559
- /**
560
- * Server name for SNI or when using an IP address as `host`.
561
- */
562
- servername?: string;
563
- /**
564
- * If `true`, the client does not attempt to use the COMPRESS=DEFLATE extension.
565
- */
566
- disableCompression?: boolean;
567
- /**
568
- * Authentication options. Authentication occurs automatically during {@link connect}.
569
- */
570
- auth: {
571
- user: string;
572
- pass?: string;
573
- accessToken?: string;
574
- loginMethod?: string;
575
- };
576
- /**
577
- * Client identification info sent to the server (via the ID command).
578
- */
579
- clientInfo?: IdInfoObject;
580
- /**
581
- * If `true`, do not start IDLE automatically. Useful when only specific operations are needed.
582
- */
583
- disableAutoIdle?: boolean;
584
- /**
585
- * Additional TLS options. For details, see [Node.js TLS connect](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback).
586
- */
587
- tls?: {
588
- rejectUnauthorized?: boolean;
589
- minVersion?: string;
590
- minDHSize?: number;
591
- };
592
- /**
593
- * Custom logger instance with `debug(obj)`, `info(obj)`, `warn(obj)`, and `error(obj)` methods.
594
- If `false`, logging is disabled. If not provided, ImapFlow logs to console in [pino format](https://getpino.io/).
595
- */
596
- logger?: any | boolean;
597
- /**
598
- * If `true`, logs all raw data (read and written) in base64 encoding. You can pipe such logs to [eerawlog](https://github.com/postalsys/eerawlog) command for readable output.
599
- */
600
- logRaw?: boolean;
601
- /**
602
- * If `true`, emits `'log'` events with the same data passed to the logger.
603
- */
604
- emitLogs?: boolean;
605
- /**
606
- * If `true`, disconnects after successful authentication without performing other actions.
607
- */
608
- verifyOnly?: boolean;
609
- /**
610
- * Proxy URL. Supports HTTP CONNECT (`http://`, `https://`) and SOCKS (`socks://`, `socks4://`, `socks5://`).
611
- */
612
- proxy?: string;
613
- /**
614
- * If `true`, enables QRESYNC support so that EXPUNGE notifications include `uid` instead of `seq`.
615
- */
616
- qresync?: boolean;
617
- /**
618
- * If set, breaks and restarts IDLE every `maxIdleTime` milliseconds.
619
- */
620
- maxIdleTime?: number;
621
- /**
622
- * Command to use if the server does not support IDLE.
623
- */
624
- missingIdleCommand?: string;
625
- /**
626
- * If `true`, ignores the BINARY extension for FETCH and APPEND operations.
627
- */
628
- disableBinary?: boolean;
629
- /**
630
- * If `true`, do not automatically enable supported IMAP extensions.
631
- */
632
- disableAutoEnable?: boolean;
633
- /**
634
- * Maximum time (in milliseconds) to wait for the connection to establish. Defaults to 90 seconds.
635
- */
636
- connectionTimeout?: number;
637
- /**
638
- * Maximum time (in milliseconds) to wait for the server greeting after a connection is established. Defaults to 16 seconds.
639
- */
640
- greetingTimeout?: number;
641
- /**
642
- * Maximum period of inactivity (in milliseconds) before terminating the connection. Defaults to 5 minutes.
643
- */
644
- socketTimeout?: number;
645
- }
646
- }
647
-
648
- /**
649
- * @property path - mailbox path
650
- * @property delimiter - mailbox path delimiter, usually "." or "/"
651
- * @property flags - list of flags for this mailbox
652
- * @property [specialUse] - one of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set
653
- * @property listed - `true` if mailbox was found from the output of LIST command
654
- * @property subscribed - `true` if mailbox was found from the output of LSUB command
655
- * @property permanentFlags - A Set of flags available to use in this mailbox. If it is not set or includes special flag "\\\*" then any flag can be used.
656
- * @property [mailboxId] - unique mailbox ID if server has `OBJECTID` extension enabled
657
- * @property [highestModseq] - latest known modseq value if server has CONDSTORE or XYMHIGHESTMODSEQ enabled
658
- * @property [noModseq] - if true then the server doesn't support the persistent storage of mod-sequences for the mailbox
659
- * @property uidValidity - Mailbox `UIDVALIDITY` value
660
- * @property uidNext - Next predicted UID
661
- * @property exists - Messages in this folder
662
- */
663
- declare type MailboxObject = {
664
- path: string;
665
- delimiter: string;
666
- flags: Set<string>;
667
- specialUse?: string;
668
- listed: boolean;
669
- subscribed: boolean;
670
- permanentFlags: Set<string>;
671
- mailboxId?: string;
672
- highestModseq?: bigint;
673
- noModseq?: string;
674
- uidValidity: bigint;
675
- uidNext: number;
676
- exists: number;
677
- };
678
-
679
- /**
680
- * @example
681
- * let lock = await client.getMailboxLock('INBOX');
682
- * try {
683
- * // do something in the mailbox
684
- * } finally {
685
- * // use finally{} to make sure lock is released even if exception occurs
686
- * lock.release();
687
- * }
688
- * @property path - mailbox path
689
- * @property release - Release current lock
690
- */
691
- declare type MailboxLockObject = {
692
- path: string;
693
- release: (...params: any[]) => any;
694
- };
695
-
696
- /**
697
- * Client and server identification object, where key is one of RFC2971 defined [data fields](https://tools.ietf.org/html/rfc2971#section-3.3) (but not limited to).
698
- * @property [name] - Name of the program
699
- * @property [version] - Version number of the program
700
- * @property [os] - Name of the operating system
701
- * @property [vendor] - Vendor of the client/server
702
- * @property ['support-url'] - URL to contact for support
703
- * @property [date] - Date program was released
704
- */
705
- declare type IdInfoObject = {
706
- name?: string;
707
- version?: string;
708
- os?: string;
709
- vendor?: string;
710
- 'support-url'?: string;
711
- date?: Date;
712
- };
713
-
714
- /**
715
- * @property path - mailbox path this quota applies to
716
- * @property [storage] - Storage quota if provided by server
717
- * @property [storage.used] - used storage in bytes
718
- * @property [storage.limit] - total storage available
719
- * @property [messages] - Message count quota if provided by server
720
- * @property [messages.used] - stored messages
721
- * @property [messages.limit] - maximum messages allowed
722
- */
723
- declare type QuotaResponse = {
724
- path: string;
725
- storage?: {
726
- used?: number;
727
- limit?: number;
728
- };
729
- messages?: {
730
- used?: number;
731
- limit?: number;
732
- };
733
- };
734
-
735
- /**
736
- * @property path - mailbox path (unicode string)
737
- * @property pathAsListed - mailbox path as listed in the LIST/LSUB response
738
- * @property name - mailbox name (last part of path after delimiter)
739
- * @property delimiter - mailbox path delimiter, usually "." or "/"
740
- * @property parent - An array of parent folder names. All names are in unicode
741
- * @property parentPath - Same as `parent`, but as a complete string path (unicode string)
742
- * @property flags - a set of flags for this mailbox
743
- * @property specialUse - one of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set
744
- * @property listed - `true` if mailbox was found from the output of LIST command
745
- * @property subscribed - `true` if mailbox was found from the output of LSUB command
746
- * @property [status] - If `statusQuery` was used, then this value includes the status response
747
- */
748
- declare type ListResponse = {
749
- path: string;
750
- pathAsListed: string;
751
- name: string;
752
- delimiter: string;
753
- parent: String[];
754
- parentPath: string;
755
- flags: Set<string>;
756
- specialUse: string;
757
- listed: boolean;
758
- subscribed: boolean;
759
- status?: StatusObject;
760
- };
761
-
762
- /**
763
- * @property [statusQuery] - request status items for every listed entry
764
- * @property [statusQuery.messages] - if `true` request count of messages
765
- * @property [statusQuery.recent] - if `true` request count of messages with \\Recent tag
766
- * @property [statusQuery.uidNext] - if `true` request predicted next UID
767
- * @property [statusQuery.uidValidity] - if `true` request mailbox `UIDVALIDITY` value
768
- * @property [statusQuery.unseen] - if `true` request count of unseen messages
769
- * @property [statusQuery.highestModseq] - if `true` request last known modseq value
770
- * @property [specialUseHints] - set specific paths as special use folders, this would override special use flags provided from the server
771
- * @property [specialUseHints.sent] - Path to "Sent Mail" folder
772
- * @property [specialUseHints.trash] - Path to "Trash" folder
773
- * @property [specialUseHints.junk] - Path to "Junk Mail" folder
774
- * @property [specialUseHints.drafts] - Path to "Drafts" folder
775
- */
776
- declare type ListOptions = {
777
- statusQuery?: {
778
- messages?: boolean;
779
- recent?: boolean;
780
- uidNext?: boolean;
781
- uidValidity?: boolean;
782
- unseen?: boolean;
783
- highestModseq?: boolean;
784
- };
785
- specialUseHints?: {
786
- sent?: string;
787
- trash?: string;
788
- junk?: string;
789
- drafts?: string;
790
- };
791
- };
792
-
793
- /**
794
- * @property root - If `true` then this is root node without any additional properties besides *folders*
795
- * @property path - mailbox path
796
- * @property name - mailbox name (last part of path after delimiter)
797
- * @property delimiter - mailbox path delimiter, usually "." or "/"
798
- * @property flags - list of flags for this mailbox
799
- * @property specialUse - one of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set
800
- * @property listed - `true` if mailbox was found from the output of LIST command
801
- * @property subscribed - `true` if mailbox was found from the output of LSUB command
802
- * @property disabled - If `true` then this mailbox can not be selected in the UI
803
- * @property folders - An array of subfolders
804
- */
805
- declare type ListTreeResponse = {
806
- root: boolean;
807
- path: string;
808
- name: string;
809
- delimiter: string;
810
- flags: String[];
811
- specialUse: string;
812
- listed: boolean;
813
- subscribed: boolean;
814
- disabled: boolean;
815
- folders: ListTreeResponse[];
816
- };
817
-
818
- /**
819
- * @property path - full mailbox path
820
- * @property [mailboxId] - unique mailbox ID if server supports `OBJECTID` extension (currently Yahoo and some others)
821
- * @property created - If `true` then mailbox was created otherwise it already existed
822
- */
823
- declare type MailboxCreateResponse = {
824
- path: string;
825
- mailboxId?: string;
826
- created: boolean;
827
- };
828
-
829
- /**
830
- * @property path - full mailbox path that was renamed
831
- * @property newPath - new full mailbox path
832
- */
833
- declare type MailboxRenameResponse = {
834
- path: string;
835
- newPath: string;
836
- };
837
-
838
- /**
839
- * @property path - full mailbox path that was deleted
840
- */
841
- declare type MailboxDeleteResponse = {
842
- path: string;
843
- };
844
-
845
- /**
846
- * @property path - full mailbox path that was checked
847
- * @property [messages] - Count of messages
848
- * @property [recent] - Count of messages with \\Recent tag
849
- * @property [uidNext] - Predicted next UID
850
- * @property [uidValidity] - Mailbox `UIDVALIDITY` value
851
- * @property [unseen] - Count of unseen messages
852
- * @property [highestModseq] - Last known modseq value (if CONDSTORE extension is enabled)
853
- */
854
- declare type StatusObject = {
855
- path: string;
856
- messages?: number;
857
- recent?: number;
858
- uidNext?: number;
859
- uidValidity?: bigint;
860
- unseen?: number;
861
- highestModseq?: bigint;
862
- };
863
-
864
- /**
865
- * Sequence range string. Separate different values with commas, number ranges with colons and use \\* as the placeholder for the newest message in mailbox
866
- * @example
867
- * "1:*" // for all messages
868
- * "1,2,3" // for messages 1, 2 and 3
869
- * "1,2,4:6" // for messages 1,2,4,5,6
870
- * "*" // for the newest message
871
- */
872
- declare type SequenceString = string;
873
-
874
- /**
875
- * IMAP search query options. By default all conditions must match. In case of `or` query term at least one condition must match.
876
- * @property [seq] - message ordering sequence range
877
- * @property [answered] - Messages with (value is `true`) or without (value is `false`) \\Answered flag
878
- * @property [deleted] - Messages with (value is `true`) or without (value is `false`) \\Deleted flag
879
- * @property [draft] - Messages with (value is `true`) or without (value is `false`) \\Draft flag
880
- * @property [flagged] - Messages with (value is `true`) or without (value is `false`) \\Flagged flag
881
- * @property [seen] - Messages with (value is `true`) or without (value is `false`) \\Seen flag
882
- * @property [all] - If `true` matches all messages
883
- * @property [new] - If `true` matches messages that have the \\Recent flag set but not the \\Seen flag
884
- * @property [old] - If `true` matches messages that do not have the \\Recent flag set
885
- * @property [recent] - If `true` matches messages that have the \\Recent flag set
886
- * @property [from] - Matches From: address field
887
- * @property [to] - Matches To: address field
888
- * @property [cc] - Matches Cc: address field
889
- * @property [bcc] - Matches Bcc: address field
890
- * @property [body] - Matches message body
891
- * @property [subject] - Matches message subject
892
- * @property [larger] - Matches messages larger than value
893
- * @property [smaller] - Matches messages smaller than value
894
- * @property [uid] - UID sequence range
895
- * @property [modseq] - Matches messages with modseq higher than value
896
- * @property [emailId] - unique email ID. Only used if server supports `OBJECTID` or `X-GM-EXT-1` extensions
897
- * @property [threadId] - unique thread ID. Only used if server supports `OBJECTID` or `X-GM-EXT-1` extensions
898
- * @property [before] - Matches messages received before date
899
- * @property [on] - Matches messages received on date (ignores time)
900
- * @property [since] - Matches messages received after date
901
- * @property [sentBefore] - Matches messages sent before date
902
- * @property [sentOn] - Matches messages sent on date (ignores time)
903
- * @property [sentSince] - Matches messages sent after date
904
- * @property [keyword] - Matches messages that have the custom flag set
905
- * @property [unKeyword] - Matches messages that do not have the custom flag set
906
- * @property [header] - Matches messages with header key set if value is `true` (**NB!** not supported by all servers) or messages where header partially matches a string value
907
- * @property [not] - A {@link SearchObject} object. It must not match.
908
- * @property [or] - An array of 2 or more {@link SearchObject} objects. At least one of these must match
909
- */
910
- declare type SearchObject = {
911
- seq?: SequenceString;
912
- answered?: boolean;
913
- deleted?: boolean;
914
- draft?: boolean;
915
- flagged?: boolean;
916
- seen?: boolean;
917
- all?: boolean;
918
- new?: boolean;
919
- old?: boolean;
920
- recent?: boolean;
921
- from?: string;
922
- to?: string;
923
- cc?: string;
924
- bcc?: string;
925
- body?: string;
926
- subject?: string;
927
- larger?: number;
928
- smaller?: number;
929
- uid?: SequenceString;
930
- modseq?: bigint;
931
- emailId?: string;
932
- threadId?: string;
933
- before?: Date | string;
934
- on?: Date | string;
935
- since?: Date | string;
936
- sentBefore?: Date | string;
937
- sentOn?: Date | string;
938
- sentSince?: Date | string;
939
- keyword?: string;
940
- unKeyword?: string;
941
- header?: {
942
- [key: string]: Boolean | String;
943
- };
944
- not?: SearchObject;
945
- or?: SearchObject[];
946
- };
947
-
948
- /**
949
- * @property destination - full mailbox path where the message was uploaded to
950
- * @property [uidValidity] - mailbox `UIDVALIDITY` if server has `UIDPLUS` extension enabled
951
- * @property [uid] - UID of the uploaded message if server has `UIDPLUS` extension enabled
952
- * @property [seq] - sequence number of the uploaded message if path is currently selected mailbox
953
- */
954
- declare type AppendResponseObject = {
955
- destination: string;
956
- uidValidity?: bigint;
957
- uid?: number;
958
- seq?: number;
959
- };
960
-
961
- /**
962
- * @property path - path of source mailbox
963
- * @property destination - path of destination mailbox
964
- * @property [uidValidity] - destination mailbox `UIDVALIDITY` if server has `UIDPLUS` extension enabled
965
- * @property [uidMap] - Map of UID values (if server has `UIDPLUS` extension enabled) where key is UID in source mailbox and value is the UID for the same message in destination mailbox
966
- */
967
- declare type CopyResponseObject = {
968
- path: string;
969
- destination: string;
970
- uidValidity?: bigint;
971
- uidMap?: Map<number, number>;
972
- };
973
-
974
- /**
975
- * @property [uid] - if `true` then include UID in the response
976
- * @property [flags] - if `true` then include flags Set in the response. Also adds `flagColor` to the response if the message is flagged.
977
- * @property [bodyStructure] - if `true` then include parsed BODYSTRUCTURE object in the response
978
- * @property [envelope] - if `true` then include parsed ENVELOPE object in the response
979
- * @property [internalDate] - if `true` then include internal date value in the response
980
- * @property [size] - if `true` then include message size in the response
981
- * @property [source] - if `true` then include full message in the response
982
- * @property [source.start] - include full message in the response starting from *start* byte
983
- * @property [source.maxLength] - include full message in the response, up to *maxLength* bytes
984
- * @property [threadId] - if `true` then include thread ID in the response (only if server supports either `OBJECTID` or `X-GM-EXT-1` extensions)
985
- * @property [labels] - if `true` then include GMail labels in the response (only if server supports `X-GM-EXT-1` extension)
986
- * @property [headers] - if `true` then includes full headers of the message in the response. If the value is an array of header keys then includes only headers listed in the array
987
- * @property [bodyParts] - An array of BODYPART identifiers to include in the response
988
- */
989
- declare type FetchQueryObject = {
990
- uid?: boolean;
991
- flags?: boolean;
992
- bodyStructure?: boolean;
993
- envelope?: boolean;
994
- internalDate?: boolean;
995
- size?: boolean;
996
- source?: {
997
- start?: number;
998
- maxLength?: number;
999
- };
1000
- threadId?: string;
1001
- labels?: boolean;
1002
- headers?: boolean | string[];
1003
- bodyParts?: string[];
1004
- };
1005
-
1006
- /**
1007
- * Parsed email address entry
1008
- * @property [name] - name of the address object (unicode)
1009
- * @property [address] - email address
1010
- */
1011
- declare type MessageAddressObject = {
1012
- name?: string;
1013
- address?: string;
1014
- };
1015
-
1016
- /**
1017
- * Parsed IMAP ENVELOPE object
1018
- * @property [date] - header date
1019
- * @property [subject] - message subject (unicode)
1020
- * @property [messageId] - Message ID of the message
1021
- * @property [inReplyTo] - Message ID from In-Reply-To header
1022
- * @property [from] - Array of addresses from the From: header
1023
- * @property [sender] - Array of addresses from the Sender: header
1024
- * @property [replyTo] - Array of addresses from the Reply-To: header
1025
- * @property [to] - Array of addresses from the To: header
1026
- * @property [cc] - Array of addresses from the Cc: header
1027
- * @property [bcc] - Array of addresses from the Bcc: header
1028
- */
1029
- declare type MessageEnvelopeObject = {
1030
- date?: Date;
1031
- subject?: string;
1032
- messageId?: string;
1033
- inReplyTo?: string;
1034
- from?: MessageAddressObject[];
1035
- sender?: MessageAddressObject[];
1036
- replyTo?: MessageAddressObject[];
1037
- to?: MessageAddressObject[];
1038
- cc?: MessageAddressObject[];
1039
- bcc?: MessageAddressObject[];
1040
- };
1041
-
1042
- /**
1043
- * Parsed IMAP BODYSTRUCTURE object
1044
- * @property part - Body part number. This value can be used to later fetch the contents of this part of the message
1045
- * @property type - Content-Type of this node
1046
- * @property [parameters] - Additional parameters for Content-Type, eg "charset"
1047
- * @property [id] - Content-ID
1048
- * @property [encoding] - Transfer encoding
1049
- * @property [size] - Expected size of the node
1050
- * @property [envelope] - message envelope of embedded RFC822 message
1051
- * @property [disposition] - Content disposition
1052
- * @property [dispositionParameters] - Additional parameters for Content-Disposition
1053
- * @property childNodes - An array of child nodes if this is a multipart node. Not present for normal nodes
1054
- */
1055
- declare type MessageStructureObject = {
1056
- part: string;
1057
- type: string;
1058
- parameters?: any;
1059
- id?: string;
1060
- encoding?: string;
1061
- size?: number;
1062
- envelope?: MessageEnvelopeObject;
1063
- disposition?: string;
1064
- dispositionParameters?: any;
1065
- childNodes: MessageStructureObject[];
1066
- };
1067
-
1068
- /**
1069
- * Fetched message data
1070
- * @property seq - message sequence number. Always included in the response
1071
- * @property uid - message UID number. Always included in the response
1072
- * @property [source] - message source for the requested byte range
1073
- * @property [modseq] - message Modseq number. Always included if the server supports CONDSTORE extension
1074
- * @property [emailId] - unique email ID. Always included if server supports `OBJECTID` or `X-GM-EXT-1` extensions
1075
- * @property [threadid] - unique thread ID. Only present if server supports `OBJECTID` or `X-GM-EXT-1` extension
1076
- * @property [labels] - a Set of labels. Only present if server supports `X-GM-EXT-1` extension
1077
- * @property [size] - message size
1078
- * @property [flags] - a set of message flags
1079
- * @property [flagColor] - flag color like "red", or "yellow". This value is derived from the `flags` Set and it uses the same color rules as Apple Mail
1080
- * @property [envelope] - message envelope
1081
- * @property [bodyStructure] - message body structure
1082
- * @property [internalDate] - message internal date
1083
- * @property [bodyParts] - a Map of message body parts where key is requested part identifier and value is a Buffer
1084
- * @property [headers] - Requested header lines as Buffer
1085
- */
1086
- declare type FetchMessageObject = {
1087
- seq: number;
1088
- uid: number;
1089
- source?: Buffer;
1090
- modseq?: bigint;
1091
- emailId?: string;
1092
- threadid?: string;
1093
- labels?: Set<string>;
1094
- size?: number;
1095
- flags?: Set<string>;
1096
- flagColor?: string;
1097
- envelope?: MessageEnvelopeObject;
1098
- bodyStructure?: MessageStructureObject;
1099
- internalDate?: Date;
1100
- bodyParts?: Map<string, Buffer>;
1101
- headers?: Buffer;
1102
- };
1103
-
1104
- /**
1105
- * @property meta - content metadata
1106
- * @property meta.expectedSize - The fetch response size
1107
- * @property meta.contentType - Content-Type of the streamed file. If part was not set then this value is "message/rfc822"
1108
- * @property [meta.charset] - Charset of the body part. Text parts are automatically converted to UTF-8, attachments are kept as is
1109
- * @property [meta.disposition] - Content-Disposition of the streamed file
1110
- * @property [meta.filename] - Filename of the streamed body part
1111
- * @property content - Streamed content
1112
- */
1113
- declare type DownloadObject = {
1114
- meta: {
1115
- expectedSize: number;
1116
- contentType: string;
1117
- charset?: string;
1118
- disposition?: string;
1119
- filename?: string;
1120
- };
1121
- content: ReadableStream;
1122
- };
1123
-