imapflow 1.0.187 → 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.
@@ -0,0 +1,786 @@
1
+ import { EventEmitter } from 'events';
2
+ import { TlsOptions } from 'tls';
3
+ import { Readable } from 'stream';
4
+
5
+ export interface ImapFlowOptions {
6
+ /** Hostname of the IMAP server */
7
+ host: string;
8
+ /** Port number for the IMAP server */
9
+ port: number;
10
+ /** If true, the connection will use TLS. If false, then TLS is used only if the server supports STARTTLS extension */
11
+ secure?: boolean;
12
+ /** Servername for SNI (or when host is set to an IP address) */
13
+ servername?: string;
14
+ /** If true, do not use COMPRESS=DEFLATE extension even if server supports it */
15
+ disableCompression?: boolean;
16
+ /** Authentication options */
17
+ auth?: {
18
+ /** Username */
19
+ user: string;
20
+ /** Password for regular authentication (if using OAuth2 then use `accessToken` instead) */
21
+ pass?: string;
22
+ /** OAuth2 access token, if using OAuth2 authentication */
23
+ accessToken?: string;
24
+ /** Optional login method override. Set to 'LOGIN', 'AUTH=LOGIN' or 'AUTH=PLAIN' to use specific method */
25
+ loginMethod?: string;
26
+ };
27
+ /** Client identification info sent to the server if server supports ID extension */
28
+ clientInfo?: IdInfoObject;
29
+ /** If true, then do not start IDLE when connection is established */
30
+ disableAutoIdle?: boolean;
31
+ /** Additional TLS options (see Node.js TLS documentation) */
32
+ tls?: TlsOptions;
33
+ /** Custom logger instance. Set to false to disable logging */
34
+ logger?: Logger | false;
35
+ /** If true, log data read and written to socket encoded in base64 */
36
+ logRaw?: boolean;
37
+ /** If true, emit 'log' events */
38
+ emitLogs?: boolean;
39
+ /** If true, then logs out automatically after successful authentication */
40
+ verifyOnly?: boolean;
41
+ /** If true and verifyOnly is set, lists mailboxes */
42
+ includeMailboxes?: boolean;
43
+ /** Proxy URL. Supports HTTP CONNECT (http:, https:) and SOCKS (socks:, socks4:, socks5:) proxies */
44
+ proxy?: string;
45
+ /** If true, then use QRESYNC instead of CONDSTORE. EXPUNGE notifications will include UID instead of sequence number */
46
+ qresync?: boolean;
47
+ /** If set, then breaks and restarts IDLE every maxIdleTime ms */
48
+ maxIdleTime?: number;
49
+ /** What command to run if IDLE is not supported. Defaults to 'NOOP' */
50
+ missingIdleCommand?: 'NOOP' | 'SELECT' | 'STATUS';
51
+ /** If true, ignores BINARY extension when making FETCH and APPEND calls */
52
+ disableBinary?: boolean;
53
+ /** If true, do not enable supported extensions */
54
+ disableAutoEnable?: boolean;
55
+ /** How long to wait for the connection to be established. Defaults to 90 seconds */
56
+ connectionTimeout?: number;
57
+ /** How long to wait for the greeting. Defaults to 16 seconds */
58
+ greetingTimeout?: number;
59
+ /** How long to wait for socket inactivity before timing out the connection. Defaults to 5 minutes */
60
+ socketTimeout?: number;
61
+ /** If true, uses TLS. If false, uses cleartext. If not set, upgrades to TLS if available */
62
+ doSTARTTLS?: boolean;
63
+ /** Custom instance ID string for logs */
64
+ id?: string;
65
+ /** Optional expunge event handler function */
66
+ expungeHandler?: (event: ExpungeEvent) => Promise<void> | void;
67
+ }
68
+
69
+ export interface Logger {
70
+ debug(obj: any): void;
71
+ info(obj: any): void;
72
+ warn(obj: any): void;
73
+ error(obj: any): void;
74
+ }
75
+
76
+ export interface MailboxObject {
77
+ /** Mailbox path */
78
+ path: string;
79
+ /** Mailbox path delimiter, usually "." or "/" */
80
+ delimiter: string;
81
+ /** List of flags for this mailbox */
82
+ flags: Set<string>;
83
+ /** One of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set */
84
+ specialUse?: string;
85
+ /** True if mailbox was found from the output of LIST command */
86
+ listed?: boolean;
87
+ /** True if mailbox was found from the output of LSUB command */
88
+ subscribed?: boolean;
89
+ /** 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 */
90
+ permanentFlags?: Set<string>;
91
+ /** Unique mailbox ID if server has OBJECTID extension enabled */
92
+ mailboxId?: string;
93
+ /** Latest known modseq value if server has CONDSTORE or XYMHIGHESTMODSEQ enabled */
94
+ highestModseq?: bigint;
95
+ /** If true then the server doesn't support the persistent storage of mod-sequences for the mailbox */
96
+ noModseq?: boolean;
97
+ /** Mailbox UIDVALIDITY value */
98
+ uidValidity: bigint;
99
+ /** Next predicted UID */
100
+ uidNext: number;
101
+ /** Messages in this folder */
102
+ exists: number;
103
+ /** Read-only state */
104
+ readOnly?: boolean;
105
+ }
106
+
107
+ export interface MailboxLockObject {
108
+ /** Mailbox path */
109
+ path: string;
110
+ /** Release current lock */
111
+ release(): void;
112
+ }
113
+
114
+ export interface IdInfoObject {
115
+ /** Name of the program */
116
+ name?: string;
117
+ /** Version number of the program */
118
+ version?: string;
119
+ /** Name of the operating system */
120
+ os?: string;
121
+ /** Vendor of the client/server */
122
+ vendor?: string;
123
+ /** URL to contact for support */
124
+ 'support-url'?: string;
125
+ /** Date program was released */
126
+ date?: Date;
127
+ [key: string]: any;
128
+ }
129
+
130
+ export interface QuotaResponse {
131
+ /** Mailbox path this quota applies to */
132
+ path: string;
133
+ /** Storage quota if provided by server */
134
+ storage?: {
135
+ /** Used storage in bytes */
136
+ used: number;
137
+ /** Total storage available */
138
+ limit: number;
139
+ };
140
+ /** Message count quota if provided by server */
141
+ messages?: {
142
+ /** Stored messages */
143
+ used: number;
144
+ /** Maximum messages allowed */
145
+ limit: number;
146
+ };
147
+ }
148
+
149
+ export interface ListResponse {
150
+ /** Mailbox path (unicode string) */
151
+ path: string;
152
+ /** Mailbox path as listed in the LIST/LSUB response */
153
+ pathAsListed: string;
154
+ /** Mailbox name (last part of path after delimiter) */
155
+ name: string;
156
+ /** Mailbox path delimiter, usually "." or "/" */
157
+ delimiter: string;
158
+ /** An array of parent folder names. All names are in unicode */
159
+ parent: string[];
160
+ /** Same as parent, but as a complete string path (unicode string) */
161
+ parentPath: string;
162
+ /** A set of flags for this mailbox */
163
+ flags: Set<string>;
164
+ /** One of special-use flags (if applicable) */
165
+ specialUse?: string;
166
+ /** True if mailbox was found from the output of LIST command */
167
+ listed: boolean;
168
+ /** True if mailbox was found from the output of LSUB command */
169
+ subscribed: boolean;
170
+ /** If statusQuery was used, then this value includes the status response */
171
+ status?: StatusObject;
172
+ }
173
+
174
+ export interface ListOptions {
175
+ /** Request status items for every listed entry */
176
+ statusQuery?: {
177
+ /** If true request count of messages */
178
+ messages?: boolean;
179
+ /** If true request count of messages with \Recent tag */
180
+ recent?: boolean;
181
+ /** If true request predicted next UID */
182
+ uidNext?: boolean;
183
+ /** If true request mailbox UIDVALIDITY value */
184
+ uidValidity?: boolean;
185
+ /** If true request count of unseen messages */
186
+ unseen?: boolean;
187
+ /** If true request last known modseq value */
188
+ highestModseq?: boolean;
189
+ };
190
+ /** Set specific paths as special use folders */
191
+ specialUseHints?: {
192
+ /** Path to "Sent Mail" folder */
193
+ sent?: string;
194
+ /** Path to "Trash" folder */
195
+ trash?: string;
196
+ /** Path to "Junk Mail" folder */
197
+ junk?: string;
198
+ /** Path to "Drafts" folder */
199
+ drafts?: string;
200
+ };
201
+ }
202
+
203
+ export interface ListTreeResponse {
204
+ /** If true then this is root node without any additional properties besides folders */
205
+ root?: boolean;
206
+ /** Mailbox path */
207
+ path?: string;
208
+ /** Mailbox name (last part of path after delimiter) */
209
+ name?: string;
210
+ /** Mailbox path delimiter, usually "." or "/" */
211
+ delimiter?: string;
212
+ /** List of flags for this mailbox */
213
+ flags?: Set<string>;
214
+ /** One of special-use flags (if applicable) */
215
+ specialUse?: string;
216
+ /** True if mailbox was found from the output of LIST command */
217
+ listed?: boolean;
218
+ /** True if mailbox was found from the output of LSUB command */
219
+ subscribed?: boolean;
220
+ /** If true then this mailbox can not be selected in the UI */
221
+ disabled?: boolean;
222
+ /** An array of subfolders */
223
+ folders?: ListTreeResponse[];
224
+ /** Status response */
225
+ status?: StatusObject;
226
+ }
227
+
228
+ export interface MailboxCreateResponse {
229
+ /** Full mailbox path */
230
+ path: string;
231
+ /** Unique mailbox ID if server supports OBJECTID extension */
232
+ mailboxId?: string;
233
+ /** If true then mailbox was created otherwise it already existed */
234
+ created: boolean;
235
+ }
236
+
237
+ export interface MailboxRenameResponse {
238
+ /** Full mailbox path that was renamed */
239
+ path: string;
240
+ /** New full mailbox path */
241
+ newPath: string;
242
+ }
243
+
244
+ export interface MailboxDeleteResponse {
245
+ /** Full mailbox path that was deleted */
246
+ path: string;
247
+ }
248
+
249
+ export interface StatusObject {
250
+ /** Full mailbox path that was checked */
251
+ path: string;
252
+ /** Count of messages */
253
+ messages?: number;
254
+ /** Count of messages with \Recent tag */
255
+ recent?: number;
256
+ /** Predicted next UID */
257
+ uidNext?: number;
258
+ /** Mailbox UIDVALIDITY value */
259
+ uidValidity?: bigint;
260
+ /** Count of unseen messages */
261
+ unseen?: number;
262
+ /** Last known modseq value (if CONDSTORE extension is enabled) */
263
+ highestModseq?: bigint;
264
+ }
265
+
266
+ export type SequenceString = string | number | bigint;
267
+
268
+ export interface SearchObject {
269
+ /** Message ordering sequence range */
270
+ seq?: SequenceString;
271
+ /** Messages with (value is true) or without (value is false) \Answered flag */
272
+ answered?: boolean;
273
+ /** Messages with (value is true) or without (value is false) \Deleted flag */
274
+ deleted?: boolean;
275
+ /** Messages with (value is true) or without (value is false) \Draft flag */
276
+ draft?: boolean;
277
+ /** Messages with (value is true) or without (value is false) \Flagged flag */
278
+ flagged?: boolean;
279
+ /** Messages with (value is true) or without (value is false) \Seen flag */
280
+ seen?: boolean;
281
+ /** If true matches all messages */
282
+ all?: boolean;
283
+ /** If true matches messages that have the \Recent flag set but not the \Seen flag */
284
+ new?: boolean;
285
+ /** If true matches messages that do not have the \Recent flag set */
286
+ old?: boolean;
287
+ /** If true matches messages that have the \Recent flag set */
288
+ recent?: boolean;
289
+ /** Matches From: address field */
290
+ from?: string;
291
+ /** Matches To: address field */
292
+ to?: string;
293
+ /** Matches Cc: address field */
294
+ cc?: string;
295
+ /** Matches Bcc: address field */
296
+ bcc?: string;
297
+ /** Matches message body */
298
+ body?: string;
299
+ /** Matches message subject */
300
+ subject?: string;
301
+ /** Matches messages larger than value */
302
+ larger?: number;
303
+ /** Matches messages smaller than value */
304
+ smaller?: number;
305
+ /** UID sequence range */
306
+ uid?: SequenceString;
307
+ /** Matches messages with modseq higher than value */
308
+ modseq?: bigint;
309
+ /** Unique email ID. Only used if server supports OBJECTID or X-GM-EXT-1 extensions */
310
+ emailId?: string;
311
+ /** Unique thread ID. Only used if server supports OBJECTID or X-GM-EXT-1 extensions */
312
+ threadId?: string;
313
+ /** Matches messages received before date */
314
+ before?: Date | string;
315
+ /** Matches messages received on date (ignores time) */
316
+ on?: Date | string;
317
+ /** Matches messages received after date */
318
+ since?: Date | string;
319
+ /** Matches messages sent before date */
320
+ sentBefore?: Date | string;
321
+ /** Matches messages sent on date (ignores time) */
322
+ sentOn?: Date | string;
323
+ /** Matches messages sent after date */
324
+ sentSince?: Date | string;
325
+ /** Matches messages that have the custom flag set */
326
+ keyword?: string;
327
+ /** Matches messages that do not have the custom flag set */
328
+ unKeyword?: string;
329
+ /** Matches messages with header key set if value is true or messages where header partially matches a string value */
330
+ header?: { [key: string]: boolean | string };
331
+ /** A SearchObject object. It must not match */
332
+ not?: SearchObject;
333
+ /** An array of 2 or more SearchObject objects. At least one of these must match */
334
+ or?: SearchObject[];
335
+ /** Gmail raw search query (only for Gmail) */
336
+ gmraw?: string;
337
+ /** Gmail raw search query (alias for gmraw) */
338
+ gmailraw?: string;
339
+ }
340
+
341
+ export interface FetchQueryObject {
342
+ /** If true then include UID in the response */
343
+ uid?: boolean;
344
+ /** If true then include flags Set in the response */
345
+ flags?: boolean;
346
+ /** If true then include parsed BODYSTRUCTURE object in the response */
347
+ bodyStructure?: boolean;
348
+ /** If true then include parsed ENVELOPE object in the response */
349
+ envelope?: boolean;
350
+ /** If true then include internal date value in the response */
351
+ internalDate?: boolean;
352
+ /** If true then include message size in the response */
353
+ size?: boolean;
354
+ /** If true then include full message in the response */
355
+ source?: boolean | {
356
+ /** Include full message in the response starting from start byte */
357
+ start?: number;
358
+ /** Include full message in the response, up to maxLength bytes */
359
+ maxLength?: number;
360
+ };
361
+ /** If true then include thread ID in the response (only if server supports either OBJECTID or X-GM-EXT-1 extensions) */
362
+ threadId?: boolean;
363
+ /** If true then include GMail labels in the response (only if server supports X-GM-EXT-1 extension) */
364
+ labels?: boolean;
365
+ /** 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 */
366
+ headers?: boolean | string[];
367
+ /** An array of BODYPART identifiers to include in the response */
368
+ bodyParts?: Array<string | { key: string; start?: number; maxLength?: number }>;
369
+ /** Fast macro equivalent to flags, internalDate, size */
370
+ fast?: boolean;
371
+ /** All macro equivalent to flags, internalDate, size, envelope */
372
+ all?: boolean;
373
+ /** Full macro equivalent to flags, internalDate, size, envelope, bodyStructure */
374
+ full?: boolean;
375
+ }
376
+
377
+ export interface MessageAddressObject {
378
+ /** Name of the address object (unicode) */
379
+ name?: string;
380
+ /** Email address */
381
+ address?: string;
382
+ }
383
+
384
+ export interface MessageEnvelopeObject {
385
+ /** Header date */
386
+ date?: Date;
387
+ /** Message subject (unicode) */
388
+ subject?: string;
389
+ /** Message ID of the message */
390
+ messageId?: string;
391
+ /** Message ID from In-Reply-To header */
392
+ inReplyTo?: string;
393
+ /** Array of addresses from the From: header */
394
+ from?: MessageAddressObject[];
395
+ /** Array of addresses from the Sender: header */
396
+ sender?: MessageAddressObject[];
397
+ /** Array of addresses from the Reply-To: header */
398
+ replyTo?: MessageAddressObject[];
399
+ /** Array of addresses from the To: header */
400
+ to?: MessageAddressObject[];
401
+ /** Array of addresses from the Cc: header */
402
+ cc?: MessageAddressObject[];
403
+ /** Array of addresses from the Bcc: header */
404
+ bcc?: MessageAddressObject[];
405
+ }
406
+
407
+ export interface MessageStructureObject {
408
+ /** Body part number. This value can be used to later fetch the contents of this part of the message */
409
+ part?: string;
410
+ /** Content-Type of this node */
411
+ type: string;
412
+ /** Additional parameters for Content-Type, eg "charset" */
413
+ parameters?: { [key: string]: string };
414
+ /** Content-ID */
415
+ id?: string;
416
+ /** Transfer encoding */
417
+ encoding?: string;
418
+ /** Expected size of the node */
419
+ size?: number;
420
+ /** Message envelope of embedded RFC822 message */
421
+ envelope?: MessageEnvelopeObject;
422
+ /** Content disposition */
423
+ disposition?: string;
424
+ /** Additional parameters for Content-Disposition */
425
+ dispositionParameters?: { [key: string]: string };
426
+ /** An array of child nodes if this is a multipart node */
427
+ childNodes?: MessageStructureObject[];
428
+ /** MD5 hash */
429
+ md5?: string;
430
+ /** Language */
431
+ language?: string[];
432
+ /** Location */
433
+ location?: string;
434
+ /** Description */
435
+ description?: string;
436
+ /** Line count */
437
+ lineCount?: number;
438
+ }
439
+
440
+ export interface FetchMessageObject {
441
+ /** Message sequence number. Always included in the response */
442
+ seq: number;
443
+ /** Message UID number. Always included in the response */
444
+ uid: number;
445
+ /** Message source for the requested byte range */
446
+ source?: Buffer;
447
+ /** Message Modseq number. Always included if the server supports CONDSTORE extension */
448
+ modseq?: bigint;
449
+ /** Unique email ID. Always included if server supports OBJECTID or X-GM-EXT-1 extensions */
450
+ emailId?: string;
451
+ /** Unique thread ID. Only present if server supports OBJECTID or X-GM-EXT-1 extension */
452
+ threadId?: string;
453
+ /** A Set of labels. Only present if server supports X-GM-EXT-1 extension */
454
+ labels?: Set<string>;
455
+ /** Message size */
456
+ size?: number;
457
+ /** A set of message flags */
458
+ flags?: Set<string>;
459
+ /** Flag color like "red", or "yellow". This value is derived from the flags Set */
460
+ flagColor?: string;
461
+ /** Message envelope */
462
+ envelope?: MessageEnvelopeObject;
463
+ /** Message body structure */
464
+ bodyStructure?: MessageStructureObject;
465
+ /** Message internal date */
466
+ internalDate?: Date | string;
467
+ /** A Map of message body parts where key is requested part identifier and value is a Buffer */
468
+ bodyParts?: Map<string, Buffer>;
469
+ /** Requested header lines as Buffer */
470
+ headers?: Buffer;
471
+ /** Account unique ID for this email */
472
+ id?: string;
473
+ }
474
+
475
+ export interface DownloadObject {
476
+ /** Content metadata */
477
+ meta: {
478
+ /** The fetch response size */
479
+ expectedSize: number;
480
+ /** Content-Type of the streamed file */
481
+ contentType: string;
482
+ /** Charset of the body part */
483
+ charset?: string;
484
+ /** Content-Disposition of the streamed file */
485
+ disposition?: string;
486
+ /** Filename of the streamed body part */
487
+ filename?: string;
488
+ /** Transfer encoding */
489
+ encoding?: string;
490
+ /** If content uses flowed formatting */
491
+ flowed?: boolean;
492
+ /** If flowed text uses delSp */
493
+ delSp?: boolean;
494
+ };
495
+ /** Streamed content */
496
+ content: Readable;
497
+ }
498
+
499
+ export interface AppendResponseObject {
500
+ /** Full mailbox path where the message was uploaded to */
501
+ destination: string;
502
+ /** Mailbox UIDVALIDITY if server has UIDPLUS extension enabled */
503
+ uidValidity?: bigint;
504
+ /** UID of the uploaded message if server has UIDPLUS extension enabled */
505
+ uid?: number;
506
+ /** Sequence number of the uploaded message if path is currently selected mailbox */
507
+ seq?: number;
508
+ }
509
+
510
+ export interface CopyResponseObject {
511
+ /** Path of source mailbox */
512
+ path: string;
513
+ /** Path of destination mailbox */
514
+ destination: string;
515
+ /** Destination mailbox UIDVALIDITY if server has UIDPLUS extension enabled */
516
+ uidValidity?: bigint;
517
+ /** Map of UID values where key is UID in source mailbox and value is the UID for the same message in destination mailbox */
518
+ uidMap?: Map<number, number>;
519
+ }
520
+
521
+ export interface FetchOptions {
522
+ /** If true then uses UID numbers instead of sequence numbers */
523
+ uid?: boolean;
524
+ /** If set then only messages with a higher modseq value are returned */
525
+ changedSince?: bigint;
526
+ /** If true then requests a binary response if the server supports this */
527
+ binary?: boolean;
528
+ }
529
+
530
+ export interface StoreOptions {
531
+ /** If true then uses UID numbers instead of sequence numbers */
532
+ uid?: boolean;
533
+ /** If set then only messages with a lower or equal modseq value are updated */
534
+ unchangedSince?: bigint;
535
+ /** If true then update Gmail labels instead of message flags */
536
+ useLabels?: boolean;
537
+ /** If true then does not emit 'flags' event */
538
+ silent?: boolean;
539
+ }
540
+
541
+ export interface MailboxOpenOptions {
542
+ /** If true then opens mailbox in read-only mode */
543
+ readOnly?: boolean;
544
+ /** Optional description for mailbox lock tracking */
545
+ description?: string;
546
+ }
547
+
548
+ export interface ExpungeEvent {
549
+ /** Mailbox path */
550
+ path: string;
551
+ /** Sequence number (if vanished is false) */
552
+ seq?: number;
553
+ /** UID number (if vanished is true or QRESYNC is enabled) */
554
+ uid?: number;
555
+ /** True if message was expunged using VANISHED response */
556
+ vanished: boolean;
557
+ /** True if VANISHED EARLIER response */
558
+ earlier?: boolean;
559
+ }
560
+
561
+ export interface ExistsEvent {
562
+ /** Mailbox path */
563
+ path: string;
564
+ /** Updated count of messages */
565
+ count: number;
566
+ /** Message count before this update */
567
+ prevCount: number;
568
+ }
569
+
570
+ export interface FlagsEvent {
571
+ /** Mailbox path */
572
+ path: string;
573
+ /** Sequence number of updated message */
574
+ seq: number;
575
+ /** UID number of updated message (if server provided this value) */
576
+ uid?: number;
577
+ /** Updated modseq number for the mailbox */
578
+ modseq?: bigint;
579
+ /** A set of all flags for the updated message */
580
+ flags: Set<string>;
581
+ /** Flag color if message is flagged */
582
+ flagColor?: string;
583
+ }
584
+
585
+ export interface LogEvent {
586
+ /** Log level */
587
+ level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
588
+ /** Timestamp */
589
+ t: number;
590
+ /** Connection ID */
591
+ cid: string;
592
+ /** Log order number */
593
+ lo: number;
594
+ /** Additional log data */
595
+ [key: string]: any;
596
+ }
597
+
598
+ export interface ResponseEvent {
599
+ /** Response type */
600
+ response: string;
601
+ /** Response code */
602
+ code?: string;
603
+ }
604
+
605
+ export class AuthenticationFailure extends Error {
606
+ authenticationFailed: true;
607
+ serverResponseCode?: string;
608
+ response?: string;
609
+ oauthError?: any;
610
+ }
611
+
612
+ export class ImapFlow extends EventEmitter {
613
+ /** Current module version */
614
+ static version: string;
615
+
616
+ /** Instance ID for logs */
617
+ id: string;
618
+
619
+ /** Server identification info */
620
+ serverInfo: IdInfoObject | null;
621
+
622
+ /** Is the connection currently encrypted or not */
623
+ secureConnection: boolean;
624
+
625
+ /** Active IMAP capabilities */
626
+ capabilities: Map<string, boolean | number>;
627
+
628
+ /** Enabled capabilities */
629
+ enabled: Set<string>;
630
+
631
+ /** Is the connection currently usable or not */
632
+ usable: boolean;
633
+
634
+ /** Currently authenticated user */
635
+ authenticated: string | boolean;
636
+
637
+ /** Currently selected mailbox */
638
+ mailbox: MailboxObject | false;
639
+
640
+ /** Is current mailbox idling */
641
+ idling: boolean;
642
+
643
+ constructor(options: ImapFlowOptions);
644
+
645
+ /** Initiates a connection against IMAP server */
646
+ connect(): Promise<void>;
647
+
648
+ /** Graceful connection close by sending logout command to server */
649
+ logout(): Promise<void>;
650
+
651
+ /** Closes TCP connection without notifying the server */
652
+ close(): void;
653
+
654
+ /** Returns current quota */
655
+ getQuota(path?: string): Promise<QuotaResponse | false>;
656
+
657
+ /** Lists available mailboxes as an Array */
658
+ list(options?: ListOptions): Promise<ListResponse[]>;
659
+
660
+ /** Lists available mailboxes as a tree structured object */
661
+ listTree(options?: ListOptions): Promise<ListTreeResponse>;
662
+
663
+ /** Performs a no-op call against server */
664
+ noop(): Promise<void>;
665
+
666
+ /** Creates a new mailbox folder */
667
+ mailboxCreate(path: string | string[]): Promise<MailboxCreateResponse>;
668
+
669
+ /** Renames a mailbox */
670
+ mailboxRename(path: string | string[], newPath: string | string[]): Promise<MailboxRenameResponse>;
671
+
672
+ /** Deletes a mailbox */
673
+ mailboxDelete(path: string | string[]): Promise<MailboxDeleteResponse>;
674
+
675
+ /** Subscribes to a mailbox */
676
+ mailboxSubscribe(path: string | string[]): Promise<boolean>;
677
+
678
+ /** Unsubscribes from a mailbox */
679
+ mailboxUnsubscribe(path: string | string[]): Promise<boolean>;
680
+
681
+ /** Opens a mailbox to access messages */
682
+ mailboxOpen(path: string | string[], options?: MailboxOpenOptions): Promise<MailboxObject>;
683
+
684
+ /** Closes a previously opened mailbox */
685
+ mailboxClose(): Promise<boolean>;
686
+
687
+ /** Requests the status of the indicated mailbox */
688
+ status(path: string, query: {
689
+ messages?: boolean;
690
+ recent?: boolean;
691
+ uidNext?: boolean;
692
+ uidValidity?: boolean;
693
+ unseen?: boolean;
694
+ highestModseq?: boolean;
695
+ }): Promise<StatusObject>;
696
+
697
+ /** Starts listening for new or deleted messages from the currently opened mailbox */
698
+ idle(): Promise<boolean>;
699
+
700
+ /** Sets flags for a message or message range */
701
+ messageFlagsSet(range: SequenceString | number[] | SearchObject, flags: string[], options?: StoreOptions): Promise<boolean>;
702
+
703
+ /** Adds flags for a message or message range */
704
+ messageFlagsAdd(range: SequenceString | number[] | SearchObject, flags: string[], options?: StoreOptions): Promise<boolean>;
705
+
706
+ /** Remove specific flags from a message or message range */
707
+ messageFlagsRemove(range: SequenceString | number[] | SearchObject, flags: string[], options?: StoreOptions): Promise<boolean>;
708
+
709
+ /** Sets a colored flag for an email */
710
+ setFlagColor(range: SequenceString | number[] | SearchObject, color: string, options?: StoreOptions): Promise<boolean>;
711
+
712
+ /** Delete messages from the currently opened mailbox */
713
+ messageDelete(range: SequenceString | number[] | SearchObject, options?: { uid?: boolean }): Promise<boolean>;
714
+
715
+ /** Appends a new message to a mailbox */
716
+ append(path: string, content: string | Buffer, flags?: string[], idate?: Date | string): Promise<AppendResponseObject | false>;
717
+
718
+ /** Copies messages from current mailbox to destination mailbox */
719
+ messageCopy(range: SequenceString | number[] | SearchObject, destination: string, options?: { uid?: boolean }): Promise<CopyResponseObject | false>;
720
+
721
+ /** Moves messages from current mailbox to destination mailbox */
722
+ messageMove(range: SequenceString | number[] | SearchObject, destination: string, options?: { uid?: boolean }): Promise<CopyResponseObject | false>;
723
+
724
+ /** Search messages from the currently opened mailbox */
725
+ search(query: SearchObject, options?: { uid?: boolean }): Promise<number[] | false>;
726
+
727
+ /** Fetch messages from the currently opened mailbox */
728
+ fetch(range: SequenceString | number[] | SearchObject, query: FetchQueryObject, options?: FetchOptions): AsyncIterableIterator<FetchMessageObject>;
729
+
730
+ /** Fetch all messages from the currently opened mailbox */
731
+ fetchAll(range: SequenceString | number[] | SearchObject, query: FetchQueryObject, options?: FetchOptions): Promise<FetchMessageObject[]>;
732
+
733
+ /** Fetch a single message from the currently opened mailbox */
734
+ fetchOne(seq: SequenceString, query: FetchQueryObject, options?: FetchOptions): Promise<FetchMessageObject | false>;
735
+
736
+ /** Download either full rfc822 formatted message or a specific bodystructure part as a Stream */
737
+ download(range: SequenceString, part?: string, options?: {
738
+ uid?: boolean;
739
+ maxBytes?: number;
740
+ chunkSize?: number;
741
+ }): Promise<DownloadObject>;
742
+
743
+ /** Fetch multiple attachments as Buffer values */
744
+ downloadMany(range: SequenceString, parts: string[], options?: { uid?: boolean }): Promise<{
745
+ [part: string]: {
746
+ meta: {
747
+ contentType?: string;
748
+ charset?: string;
749
+ disposition?: string;
750
+ filename?: string;
751
+ encoding?: string;
752
+ };
753
+ content: Buffer | null;
754
+ }
755
+ }>;
756
+
757
+ /** Opens a mailbox if not already open and returns a lock */
758
+ getMailboxLock(path: string | string[], options?: MailboxOpenOptions): Promise<MailboxLockObject>;
759
+
760
+ /** Connection close event */
761
+ on(event: 'close', listener: () => void): this;
762
+
763
+ /** Error event */
764
+ on(event: 'error', listener: (error: Error) => void): this;
765
+
766
+ /** Message count in currently opened mailbox changed */
767
+ on(event: 'exists', listener: (data: ExistsEvent) => void): this;
768
+
769
+ /** Deleted message sequence number in currently opened mailbox */
770
+ on(event: 'expunge', listener: (data: ExpungeEvent) => void): this;
771
+
772
+ /** Flags were updated for a message */
773
+ on(event: 'flags', listener: (data: FlagsEvent) => void): this;
774
+
775
+ /** Mailbox was opened */
776
+ on(event: 'mailboxOpen', listener: (mailbox: MailboxObject) => void): this;
777
+
778
+ /** Mailbox was closed */
779
+ on(event: 'mailboxClose', listener: (mailbox: MailboxObject) => void): this;
780
+
781
+ /** Log event if emitLogs=true */
782
+ on(event: 'log', listener: (entry: LogEvent) => void): this;
783
+
784
+ /** Response event */
785
+ on(event: 'response', listener: (response: ResponseEvent) => void): this;
786
+ }