imapflow 1.7.8 → 2.0.0

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.
Files changed (296) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +8 -2
  3. package/dist/cjs/charsets.d.ts +1 -0
  4. package/dist/cjs/charsets.js +294 -0
  5. package/dist/cjs/commands/append.d.ts +22 -0
  6. package/dist/cjs/commands/append.js +151 -0
  7. package/dist/cjs/commands/authenticate.d.ts +24 -0
  8. package/dist/cjs/commands/authenticate.js +223 -0
  9. package/dist/cjs/commands/capability.d.ts +8 -0
  10. package/dist/cjs/commands/capability.js +32 -0
  11. package/dist/cjs/commands/close.d.ts +8 -0
  12. package/dist/cjs/commands/close.js +39 -0
  13. package/dist/cjs/commands/compress.d.ts +8 -0
  14. package/dist/cjs/commands/compress.js +56 -0
  15. package/dist/cjs/commands/copy.d.ts +13 -0
  16. package/dist/cjs/commands/copy.js +44 -0
  17. package/dist/cjs/commands/copyuid-parser.d.ts +11 -0
  18. package/dist/cjs/commands/copyuid-parser.js +32 -0
  19. package/dist/cjs/commands/create.d.ts +11 -0
  20. package/dist/cjs/commands/create.js +80 -0
  21. package/dist/cjs/commands/delete.d.ts +11 -0
  22. package/dist/cjs/commands/delete.js +40 -0
  23. package/dist/cjs/commands/enable.d.ts +9 -0
  24. package/dist/cjs/commands/enable.js +61 -0
  25. package/dist/cjs/commands/esearch-parser.d.ts +17 -0
  26. package/dist/cjs/commands/esearch-parser.js +91 -0
  27. package/dist/cjs/commands/expunge.d.ts +12 -0
  28. package/dist/cjs/commands/expunge.js +60 -0
  29. package/dist/cjs/commands/fetch.d.ts +30 -0
  30. package/dist/cjs/commands/fetch.js +241 -0
  31. package/dist/cjs/commands/id.d.ts +10 -0
  32. package/dist/cjs/commands/id.js +80 -0
  33. package/dist/cjs/commands/idle.d.ts +9 -0
  34. package/dist/cjs/commands/idle.js +347 -0
  35. package/dist/cjs/commands/list.d.ts +16 -0
  36. package/dist/cjs/commands/list.js +518 -0
  37. package/dist/cjs/commands/login.d.ts +11 -0
  38. package/dist/cjs/commands/login.js +42 -0
  39. package/dist/cjs/commands/logout.d.ts +8 -0
  40. package/dist/cjs/commands/logout.js +47 -0
  41. package/dist/cjs/commands/move.d.ts +13 -0
  42. package/dist/cjs/commands/move.js +57 -0
  43. package/dist/cjs/commands/namespace.d.ts +25 -0
  44. package/dist/cjs/commands/namespace.js +139 -0
  45. package/dist/cjs/commands/noop.d.ts +8 -0
  46. package/dist/cjs/commands/noop.js +22 -0
  47. package/dist/cjs/commands/quota.d.ts +10 -0
  48. package/dist/cjs/commands/quota.js +119 -0
  49. package/dist/cjs/commands/rename.d.ts +12 -0
  50. package/dist/cjs/commands/rename.js +48 -0
  51. package/dist/cjs/commands/search.d.ts +15 -0
  52. package/dist/cjs/commands/search.js +228 -0
  53. package/dist/cjs/commands/select.d.ts +25 -0
  54. package/dist/cjs/commands/select.js +250 -0
  55. package/dist/cjs/commands/starttls.d.ts +8 -0
  56. package/dist/cjs/commands/starttls.js +30 -0
  57. package/dist/cjs/commands/status-fields.d.ts +14 -0
  58. package/dist/cjs/commands/status-fields.js +61 -0
  59. package/dist/cjs/commands/status.d.ts +12 -0
  60. package/dist/cjs/commands/status.js +108 -0
  61. package/dist/cjs/commands/store.d.ts +19 -0
  62. package/dist/cjs/commands/store.js +93 -0
  63. package/dist/cjs/commands/subscribe.d.ts +9 -0
  64. package/dist/cjs/commands/subscribe.js +31 -0
  65. package/dist/cjs/commands/unsubscribe.d.ts +9 -0
  66. package/dist/cjs/commands/unsubscribe.js +31 -0
  67. package/dist/cjs/connection-deadline.d.ts +49 -0
  68. package/dist/cjs/connection-deadline.js +91 -0
  69. package/dist/cjs/errors.d.ts +83 -0
  70. package/dist/cjs/errors.js +13 -0
  71. package/dist/cjs/handler/imap-compiler.d.ts +24 -0
  72. package/dist/cjs/handler/imap-compiler.js +285 -0
  73. package/dist/cjs/handler/imap-formal-syntax.d.ts +28 -0
  74. package/dist/cjs/handler/imap-formal-syntax.js +121 -0
  75. package/dist/cjs/handler/imap-handler.d.ts +9 -0
  76. package/dist/cjs/handler/imap-handler.js +10 -0
  77. package/dist/cjs/handler/imap-parser.d.ts +16 -0
  78. package/dist/cjs/handler/imap-parser.js +90 -0
  79. package/dist/cjs/handler/imap-stream.d.ts +181 -0
  80. package/dist/cjs/handler/imap-stream.js +446 -0
  81. package/dist/cjs/handler/limits.d.ts +25 -0
  82. package/dist/cjs/handler/limits.js +51 -0
  83. package/dist/cjs/handler/parser-instance.d.ts +68 -0
  84. package/dist/cjs/handler/parser-instance.js +223 -0
  85. package/dist/cjs/handler/token-parser.d.ts +91 -0
  86. package/dist/cjs/handler/token-parser.js +673 -0
  87. package/dist/cjs/handler/types.d.ts +91 -0
  88. package/dist/cjs/handler/types.js +4 -0
  89. package/dist/cjs/imap-commands.d.ts +16 -0
  90. package/dist/cjs/imap-commands.js +74 -0
  91. package/dist/cjs/imap-flow.d.ts +676 -0
  92. package/dist/cjs/imap-flow.js +3949 -0
  93. package/dist/cjs/jp-decoder.d.ts +12 -0
  94. package/dist/cjs/jp-decoder.js +79 -0
  95. package/dist/cjs/limited-passthrough.d.ts +25 -0
  96. package/dist/cjs/limited-passthrough.js +54 -0
  97. package/dist/cjs/logger.d.ts +3 -0
  98. package/dist/cjs/logger.js +11 -0
  99. package/dist/cjs/package-info.d.ts +3 -0
  100. package/dist/cjs/package-info.js +7 -0
  101. package/dist/cjs/package.json +3 -0
  102. package/dist/cjs/proxy-connection.d.ts +33 -0
  103. package/dist/cjs/proxy-connection.js +392 -0
  104. package/dist/cjs/search-compiler.d.ts +34 -0
  105. package/dist/cjs/search-compiler.js +476 -0
  106. package/dist/cjs/special-use.d.ts +22 -0
  107. package/dist/cjs/special-use.js +911 -0
  108. package/dist/cjs/tools.d.ts +427 -0
  109. package/dist/cjs/tools.js +1496 -0
  110. package/{lib/imap-flow.d.ts → dist/cjs/types.d.ts} +386 -516
  111. package/dist/cjs/types.js +5 -0
  112. package/dist/esm/charsets.d.ts +1 -0
  113. package/{lib → dist/esm}/charsets.js +1 -6
  114. package/dist/esm/commands/append.d.ts +22 -0
  115. package/{lib → dist/esm}/commands/append.js +22 -52
  116. package/dist/esm/commands/authenticate.d.ts +24 -0
  117. package/{lib → dist/esm}/commands/authenticate.js +62 -87
  118. package/dist/esm/commands/capability.d.ts +8 -0
  119. package/{lib → dist/esm}/commands/capability.js +6 -9
  120. package/dist/esm/commands/close.d.ts +8 -0
  121. package/{lib → dist/esm}/commands/close.js +6 -10
  122. package/dist/esm/commands/compress.d.ts +8 -0
  123. package/{lib → dist/esm}/commands/compress.js +7 -11
  124. package/dist/esm/commands/copy.d.ts +13 -0
  125. package/{lib → dist/esm}/commands/copy.js +12 -20
  126. package/dist/esm/commands/copyuid-parser.d.ts +11 -0
  127. package/{lib → dist/esm}/commands/copyuid-parser.js +9 -15
  128. package/dist/esm/commands/create.d.ts +11 -0
  129. package/{lib → dist/esm}/commands/create.js +13 -27
  130. package/dist/esm/commands/delete.d.ts +11 -0
  131. package/{lib → dist/esm}/commands/delete.js +9 -14
  132. package/dist/esm/commands/enable.d.ts +9 -0
  133. package/{lib → dist/esm}/commands/enable.js +23 -30
  134. package/dist/esm/commands/esearch-parser.d.ts +17 -0
  135. package/dist/esm/commands/esearch-parser.js +88 -0
  136. package/dist/esm/commands/expunge.d.ts +12 -0
  137. package/{lib → dist/esm}/commands/expunge.js +17 -22
  138. package/dist/esm/commands/fetch.d.ts +30 -0
  139. package/{lib → dist/esm}/commands/fetch.js +32 -64
  140. package/dist/esm/commands/id.d.ts +10 -0
  141. package/{lib → dist/esm}/commands/id.js +17 -23
  142. package/dist/esm/commands/idle.d.ts +9 -0
  143. package/{lib → dist/esm}/commands/idle.js +47 -81
  144. package/dist/esm/commands/list.d.ts +16 -0
  145. package/{lib → dist/esm}/commands/list.js +56 -121
  146. package/dist/esm/commands/login.d.ts +11 -0
  147. package/{lib → dist/esm}/commands/login.js +10 -15
  148. package/dist/esm/commands/logout.d.ts +8 -0
  149. package/{lib → dist/esm}/commands/logout.js +9 -11
  150. package/dist/esm/commands/move.d.ts +13 -0
  151. package/{lib → dist/esm}/commands/move.js +13 -21
  152. package/dist/esm/commands/namespace.d.ts +25 -0
  153. package/{lib → dist/esm}/commands/namespace.js +34 -44
  154. package/dist/esm/commands/noop.d.ts +8 -0
  155. package/{lib → dist/esm}/commands/noop.js +6 -7
  156. package/dist/esm/commands/quota.d.ts +10 -0
  157. package/{lib → dist/esm}/commands/quota.js +18 -36
  158. package/dist/esm/commands/rename.d.ts +12 -0
  159. package/{lib → dist/esm}/commands/rename.js +10 -15
  160. package/dist/esm/commands/search.d.ts +15 -0
  161. package/{lib → dist/esm}/commands/search.js +36 -135
  162. package/dist/esm/commands/select.d.ts +25 -0
  163. package/{lib → dist/esm}/commands/select.js +33 -64
  164. package/dist/esm/commands/starttls.d.ts +8 -0
  165. package/{lib → dist/esm}/commands/starttls.js +6 -8
  166. package/dist/esm/commands/status-fields.d.ts +14 -0
  167. package/{lib → dist/esm}/commands/status-fields.js +5 -16
  168. package/dist/esm/commands/status.d.ts +12 -0
  169. package/{lib → dist/esm}/commands/status.js +18 -29
  170. package/dist/esm/commands/store.d.ts +19 -0
  171. package/{lib → dist/esm}/commands/store.js +24 -37
  172. package/dist/esm/commands/subscribe.d.ts +9 -0
  173. package/{lib → dist/esm}/commands/subscribe.js +8 -12
  174. package/dist/esm/commands/unsubscribe.d.ts +9 -0
  175. package/{lib → dist/esm}/commands/unsubscribe.js +8 -12
  176. package/dist/esm/connection-deadline.d.ts +49 -0
  177. package/{lib → dist/esm}/connection-deadline.js +14 -25
  178. package/dist/esm/errors.d.ts +83 -0
  179. package/dist/esm/errors.js +9 -0
  180. package/dist/esm/handler/imap-compiler.d.ts +24 -0
  181. package/{lib → dist/esm}/handler/imap-compiler.js +22 -80
  182. package/dist/esm/handler/imap-formal-syntax.d.ts +28 -0
  183. package/dist/esm/handler/imap-formal-syntax.js +117 -0
  184. package/dist/esm/handler/imap-handler.d.ts +9 -0
  185. package/dist/esm/handler/imap-handler.js +9 -0
  186. package/dist/esm/handler/imap-parser.d.ts +16 -0
  187. package/{lib → dist/esm}/handler/imap-parser.js +31 -44
  188. package/dist/esm/handler/imap-stream.d.ts +181 -0
  189. package/{lib → dist/esm}/handler/imap-stream.js +29 -121
  190. package/dist/esm/handler/limits.d.ts +25 -0
  191. package/{lib → dist/esm}/handler/limits.js +13 -22
  192. package/dist/esm/handler/parser-instance.d.ts +68 -0
  193. package/{lib → dist/esm}/handler/parser-instance.js +19 -47
  194. package/dist/esm/handler/token-parser.d.ts +91 -0
  195. package/{lib → dist/esm}/handler/token-parser.js +71 -155
  196. package/dist/esm/handler/types.d.ts +91 -0
  197. package/dist/esm/handler/types.js +3 -0
  198. package/dist/esm/imap-commands.d.ts +16 -0
  199. package/dist/esm/imap-commands.js +67 -0
  200. package/dist/esm/imap-flow.d.ts +676 -0
  201. package/{lib → dist/esm}/imap-flow.js +761 -1789
  202. package/dist/esm/jp-decoder.d.ts +12 -0
  203. package/{lib → dist/esm}/jp-decoder.js +6 -21
  204. package/dist/esm/limited-passthrough.d.ts +25 -0
  205. package/{lib → dist/esm}/limited-passthrough.js +7 -20
  206. package/dist/esm/logger.d.ts +3 -0
  207. package/dist/esm/logger.js +4 -0
  208. package/dist/esm/package-info.d.ts +3 -0
  209. package/dist/esm/package-info.js +4 -0
  210. package/dist/esm/package.json +3 -0
  211. package/dist/esm/proxy-connection.d.ts +33 -0
  212. package/{lib → dist/esm}/proxy-connection.js +56 -127
  213. package/dist/esm/search-compiler.d.ts +34 -0
  214. package/{lib → dist/esm}/search-compiler.js +54 -110
  215. package/dist/esm/special-use.d.ts +22 -0
  216. package/dist/esm/special-use.js +907 -0
  217. package/dist/esm/tools.d.ts +427 -0
  218. package/dist/esm/tools.js +1446 -0
  219. package/dist/esm/types.d.ts +828 -0
  220. package/dist/esm/types.js +4 -0
  221. package/package.json +60 -20
  222. package/.gitattributes +0 -1
  223. package/.github/CODE_OF_CONDUCT.md +0 -76
  224. package/.github/FUNDING.yml +0 -4
  225. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
  226. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
  227. package/.github/contributing.md +0 -17
  228. package/.github/workflows/release.yaml +0 -36
  229. package/.github/workflows/stale.yml +0 -29
  230. package/.github/workflows/test.yml +0 -51
  231. package/.ncurc.js +0 -4
  232. package/.prettierignore +0 -4
  233. package/.prettierrc.js +0 -8
  234. package/.release-please-manifest.json +0 -3
  235. package/CLAUDE.md +0 -104
  236. package/Gruntfile.js +0 -23
  237. package/eslint.config.js +0 -45
  238. package/lib/handler/imap-formal-syntax.js +0 -189
  239. package/lib/handler/imap-handler.js +0 -17
  240. package/lib/imap-commands.js +0 -45
  241. package/lib/logger.js +0 -5
  242. package/lib/special-use.js +0 -923
  243. package/lib/tools.js +0 -1612
  244. package/release-please-config.json +0 -10
  245. package/test/authentication-test.js +0 -101
  246. package/test/auto-idle-test.js +0 -470
  247. package/test/bodystructure-test.js +0 -899
  248. package/test/charsets-test.js +0 -161
  249. package/test/commands-branches-test.js +0 -1095
  250. package/test/commands-integration-test.js +0 -11124
  251. package/test/commands-test.js +0 -73
  252. package/test/connection-edge-cases-test.js +0 -1828
  253. package/test/connection-test.js +0 -162
  254. package/test/copyuid-parser-test.js +0 -173
  255. package/test/fetch-generator-test.js +0 -218
  256. package/test/fixtures/fake-timers.js +0 -115
  257. package/test/fixtures/serialized-mimetorture.js +0 -2738
  258. package/test/fixtures/test-client.js +0 -101
  259. package/test/fixtures/test-tls.js +0 -8
  260. package/test/handler-branches-test.js +0 -310
  261. package/test/idle-polling-test.js +0 -518
  262. package/test/imap-compiler-test.js +0 -809
  263. package/test/imap-flow-compress-test.js +0 -166
  264. package/test/imap-flow-coverage-test.js +0 -612
  265. package/test/imap-flow-fetch-download-test.js +0 -909
  266. package/test/imap-flow-internals-test.js +0 -725
  267. package/test/imap-flow-methods-test.js +0 -889
  268. package/test/imap-flow-proxy-paths-test.js +0 -366
  269. package/test/imap-flow-secure-test.js +0 -573
  270. package/test/imap-flow-server-test.js +0 -1474
  271. package/test/imap-formal-syntax-test.js +0 -293
  272. package/test/imap-parser-test.js +0 -1474
  273. package/test/imap-stream-edge-cases-test.js +0 -666
  274. package/test/imap-stream-test.js +0 -177
  275. package/test/imapflow-test.js +0 -258
  276. package/test/integration/README.md +0 -52
  277. package/test/integration/dovecot-test.conf +0 -27
  278. package/test/integration/rev2-live-test.js +0 -431
  279. package/test/integration/run-rev2-tests.sh +0 -75
  280. package/test/integration-test.js +0 -83
  281. package/test/jp-decoder-test.js +0 -304
  282. package/test/limited-passthrough-test.js +0 -299
  283. package/test/memory-cleanup-test.js +0 -144
  284. package/test/memory-leak-test.js +0 -667
  285. package/test/parser-limits-test.js +0 -292
  286. package/test/proxy-connection-test.js +0 -738
  287. package/test/reliability-improvements-test.js +0 -548
  288. package/test/search-compiler-test.js +0 -1300
  289. package/test/search-test.js +0 -329
  290. package/test/special-use-test.js +0 -418
  291. package/test/starttls-injection-test.js +0 -181
  292. package/test/tag-correlation-test.js +0 -333
  293. package/test/timer-policy-test.js +0 -227
  294. package/test/token-parser-test.js +0 -456
  295. package/test/tools-test.js +0 -2013
  296. package/test/unhandled-rejection-test.js +0 -661
@@ -0,0 +1,676 @@
1
+ /**
2
+ * @module imapflow
3
+ */
4
+ import tls from 'node:tls';
5
+ import net from 'node:net';
6
+ import { EventEmitter } from 'node:events';
7
+ import { PassThrough, type Readable } from 'node:stream';
8
+ import { AuthenticationFailure } from './errors.js';
9
+ import type { AppendResponseObject, CopyResponseObject, DownloadManyOptions, DownloadManyResult, DownloadObject, DownloadOptions, ESearchResult, FetchMessageObject, FetchOptions, FetchQueryObject, IdInfoObject, ImapFlowEvents, ImapFlowOptions, InternalLogger, ListOptions, ListResponse, ListTreeResponse, MailboxCreateResponse, MailboxDeleteResponse, MailboxLockObject, MailboxLockOptions, MailboxObject, MailboxOpenOptions, MailboxRenameResponse, MessageRange, MessageRangeOptions, NamespaceObject, NamespacesObject, QuotaResponse, SearchObject, SearchOptions, SearchReturnOption, SequenceString, StatusObject, StatusQuery, StoreOptions, TlsInfo } from './types.js';
10
+ export type * from './types.js';
11
+ export type { ImapFlowError } from './errors.js';
12
+ export { AuthenticationFailure } from './errors.js';
13
+ export type { ImapAttribute, ImapAttributeList, ImapAttributeNode, ImapResponse } from './handler/types.js';
14
+ declare const stateValues: {
15
+ readonly NOT_AUTHENTICATED: 1;
16
+ readonly AUTHENTICATED: 2;
17
+ readonly SELECTED: 3;
18
+ readonly LOGOUT: 4;
19
+ };
20
+ /** One of the `ImapFlow#states` values */
21
+ export type ConnectionState = (typeof stateValues)[keyof typeof stateValues];
22
+ /**
23
+ * The connection state constants, see `ImapFlow#states`. Every member is typed as the whole
24
+ * union, so a list of states accepts any state in an `includes()` check
25
+ */
26
+ export type ConnectionStates = {
27
+ readonly [K in keyof typeof stateValues]: ConnectionState;
28
+ };
29
+ /**
30
+ * The socket carrying the IMAP session. A TLS socket exposes `getCipher()` and `authorized`, a
31
+ * cleartext socket does not, and the code checks for them at runtime.
32
+ */
33
+ export type ImapSocket = net.Socket & {
34
+ getCipher?: (() => tls.CipherNameAndProtocol) | undefined;
35
+ authorized?: boolean | undefined;
36
+ };
37
+ /**
38
+ * Where outgoing bytes are written: the socket itself, or the PassThrough that feeds the
39
+ * DEFLATE stream once compression is active
40
+ */
41
+ export type WriteSocket = (ImapSocket | PassThrough) & {
42
+ destroySoon?: (() => void) | undefined;
43
+ };
44
+ /**
45
+ * Typed event overloads of the {@link ImapFlow} class, see {@link ImapFlowEvents}
46
+ */
47
+ export interface ImapFlow {
48
+ on<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
49
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
50
+ once<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
51
+ once(event: string | symbol, listener: (...args: any[]) => void): this;
52
+ off<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
53
+ off(event: string | symbol, listener: (...args: any[]) => void): this;
54
+ addListener<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
55
+ addListener(event: string | symbol, listener: (...args: any[]) => void): this;
56
+ removeListener<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
57
+ removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
58
+ prependListener<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
59
+ prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
60
+ prependOnceListener<K extends keyof ImapFlowEvents>(event: K, listener: (...args: ImapFlowEvents[K]) => void): this;
61
+ prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
62
+ emit<K extends keyof ImapFlowEvents>(event: K, ...args: ImapFlowEvents[K]): boolean;
63
+ emit(event: string | symbol, ...args: any[]): boolean;
64
+ }
65
+ /**
66
+ * IMAP client class for accessing IMAP mailboxes
67
+ */
68
+ export declare class ImapFlow extends EventEmitter {
69
+ /**
70
+ * Current module version as a static class property
71
+ */
72
+ static version: string;
73
+ /** IMAP connection options, see {@link ImapFlowOptions} */
74
+ options: ImapFlowOptions;
75
+ /** Instance ID for logs */
76
+ id: string;
77
+ /** Client identification info sent with the ID command */
78
+ clientInfo: IdInfoObject;
79
+ /**
80
+ * Server identification info. Available after successful `connect()`.
81
+ * If server does not provide identification info then this value is `null`.
82
+ */
83
+ serverInfo: IdInfoObject | null;
84
+ /** Connection logger. Every level is callable, see `getLogger()` */
85
+ log: InternalLogger;
86
+ /** Is the connection currently encrypted or not */
87
+ secureConnection: boolean;
88
+ /** Port number the connection is made to */
89
+ port: number;
90
+ /** Hostname the connection is made to */
91
+ host: string;
92
+ /** Server name for SNI, or false when connecting to an IP literal */
93
+ servername: string | false;
94
+ /** Set once `close()` has run */
95
+ isClosed: boolean;
96
+ /** Connection state constants */
97
+ states: ConnectionStates;
98
+ /** Current connection state, one of `states` */
99
+ state: ConnectionState;
100
+ /**
101
+ * Active IMAP capabilities. Value is either `true` for toggleable capabilities (eg. `UIDPLUS`)
102
+ * or a number for capabilities with a value (eg. `APPENDLIMIT`)
103
+ */
104
+ capabilities: Map<string, boolean | number>;
105
+ /**
106
+ * Enabled capabilities. Usually `CONDSTORE` and `UTF8=ACCEPT` if server supports these.
107
+ */
108
+ enabled: Set<string>;
109
+ /**
110
+ * Is the connection currently usable or not
111
+ */
112
+ usable: boolean;
113
+ /**
114
+ * Currently authenticated user or `false` if mailbox is not open
115
+ * or `true` if connection was authenticated by PREAUTH
116
+ */
117
+ authenticated: string | boolean;
118
+ /**
119
+ * Currently selected mailbox or `false` if mailbox is not open
120
+ */
121
+ mailbox: MailboxObject | false;
122
+ /**
123
+ * Is current mailbox idling (`true`) or not (`false`)
124
+ */
125
+ idling: boolean;
126
+ /** Whether log entries are also emitted as 'log' events, see the `emitLogs` option */
127
+ emitLogs: boolean;
128
+ /** The personal namespace, from the NAMESPACE command */
129
+ namespace: NamespaceObject | undefined;
130
+ /** Every namespace the server reported */
131
+ namespaces: NamespacesObject | undefined;
132
+ /** Human readable text of the server greeting */
133
+ greeting: string | undefined;
134
+ /** Reason text of the server's BYE response, if the server closed the session */
135
+ byeReason: string | undefined;
136
+ /** Negotiated TLS session details, `false` for a cleartext connection */
137
+ tls: TlsInfo | false | undefined;
138
+ constructor(options?: ImapFlowOptions | undefined);
139
+ /**
140
+ * Returns byte counters for the current connection.
141
+ *
142
+ * @param reset If `true` then resets the byte counters after returning the current values
143
+ * @returns Byte counters: bytes sent to and received from the server
144
+ */
145
+ stats(reset?: boolean): {
146
+ sent: number;
147
+ received: number;
148
+ };
149
+ /**
150
+ * Tries to upgrade the connection to TLS using STARTTLS.
151
+ * @throws if STARTTLS is required, but not possible.
152
+ * @returns true, if the connection is now protected by TLS, either direct TLS or STARTTLS.
153
+ */
154
+ upgradeToSTARTTLS(): Promise<boolean>;
155
+ /**
156
+ * 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
157
+ *
158
+ * @throws Will throw an error if connection or authentication fails
159
+ * @example
160
+ * let client = new ImapFlow({...});
161
+ * await client.connect();
162
+ */
163
+ connect(): Promise<void>;
164
+ /**
165
+ * Graceful connection close by sending logout command to server. TCP connection is closed once command is finished.
166
+ *
167
+ * @example
168
+ * let client = new ImapFlow({...});
169
+ * await client.connect();
170
+ * ...
171
+ * await client.logout();
172
+ */
173
+ logout(): Promise<void>;
174
+ /**
175
+ * Close the TCP connection.
176
+ * Unlike `close()`, return immediately from this function, allowing the
177
+ * caller function to proceed, and run `close()` function afterwards.
178
+ */
179
+ closeAfter(): void;
180
+ /**
181
+ * Closes TCP connection without notifying the server.
182
+ *
183
+ * @example
184
+ * let client = new ImapFlow({...});
185
+ * await client.connect();
186
+ * ...
187
+ * client.close();
188
+ */
189
+ close(): void;
190
+ /**
191
+ * Returns current quota
192
+ *
193
+ * @param path Optional mailbox path if you want to check quota for specific folder. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
194
+ * @returns Quota information or `false` if QUOTA extension is not supported or requested path does not exist
195
+ *
196
+ * @example
197
+ * let quota = await client.getQuota();
198
+ * console.log(quota.storage.used, quota.storage.limit)
199
+ */
200
+ getQuota(path?: string | string[] | undefined): Promise<QuotaResponse | false>;
201
+ /**
202
+ * Lists available mailboxes as an Array
203
+ *
204
+ * @param options defines additional listing options
205
+ * @returns An array of ListResponse objects
206
+ *
207
+ * @example
208
+ * let list = await client.list();
209
+ * list.forEach(mailbox=>console.log(mailbox.path));
210
+ */
211
+ list(options?: ListOptions | undefined): Promise<ListResponse[]>;
212
+ /**
213
+ * Lists available mailboxes as a tree structured object
214
+ *
215
+ * @param options defines additional listing options
216
+ * @returns Tree structured object
217
+ *
218
+ * @example
219
+ * let tree = await client.listTree();
220
+ * tree.folders.forEach(mailbox=>console.log(mailbox.path));
221
+ */
222
+ listTree(options?: ListOptions | undefined): Promise<ListTreeResponse>;
223
+ /**
224
+ * Performs a no-op call against server
225
+ */
226
+ noop(): Promise<void>;
227
+ /**
228
+ * Creates a new mailbox folder and sets up subscription for the created mailbox. Throws on error.
229
+ *
230
+ * @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.
231
+ * @returns Mailbox info
232
+ * @throws Will throw an error if mailbox can not be created
233
+ *
234
+ * @example
235
+ * let info = await client.mailboxCreate(['parent', 'child']);
236
+ * console.log(info.path);
237
+ * // "INBOX.parent.child" // assumes "INBOX." as namespace prefix and "." as delimiter
238
+ */
239
+ mailboxCreate(path: string | string[]): Promise<MailboxCreateResponse>;
240
+ /**
241
+ * Renames a mailbox. Throws on error.
242
+ *
243
+ * @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.
244
+ * @param newPath New path for the mailbox
245
+ * @returns Mailbox info
246
+ * @throws Will throw an error if mailbox does not exist or can not be renamed
247
+ *
248
+ * @example
249
+ * let info = await client.mailboxRename('parent.child', 'Important stuff');
250
+ * console.log(info.newPath);
251
+ * // "INBOX.Important stuff" // assumes "INBOX." as namespace prefix
252
+ */
253
+ mailboxRename(path: string | string[], newPath: string | string[]): Promise<MailboxRenameResponse>;
254
+ /**
255
+ * Deletes a mailbox. Throws on error.
256
+ *
257
+ * @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.
258
+ * @returns Mailbox info
259
+ * @throws Will throw an error if mailbox does not exist or can not be deleted
260
+ *
261
+ * @example
262
+ * let info = await client.mailboxDelete('Important stuff');
263
+ * console.log(info.path);
264
+ * // "INBOX.Important stuff" // assumes "INBOX." as namespace prefix
265
+ */
266
+ mailboxDelete(path: string | string[]): Promise<MailboxDeleteResponse>;
267
+ /**
268
+ * Subscribes to a mailbox
269
+ *
270
+ * @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.
271
+ * @returns `true` if subscription operation succeeded, `false` otherwise
272
+ *
273
+ * @example
274
+ * await client.mailboxSubscribe('Important stuff');
275
+ */
276
+ mailboxSubscribe(path: string | string[]): Promise<boolean>;
277
+ /**
278
+ * Unsubscribes from a mailbox
279
+ *
280
+ * @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.
281
+ * @returns `true` if unsubscription operation succeeded, `false` otherwise
282
+ *
283
+ * @example
284
+ * await client.mailboxUnsubscribe('Important stuff');
285
+ */
286
+ mailboxUnsubscribe(path: string | string[]): Promise<boolean>;
287
+ /**
288
+ * Opens a mailbox to access messages. You can perform message operations only against an opened mailbox.
289
+ * Using {@link ImapFlow#getMailboxLock} instead of `mailboxOpen()` is preferred. Both do the same thing
290
+ * but next `getMailboxLock()` call is not executed until previous one is released.
291
+ *
292
+ * @param path **Path for the mailbox** to open
293
+ * @param options optional options
294
+ * @returns Mailbox info
295
+ * @throws Will throw an error if mailbox does not exist or can not be opened
296
+ *
297
+ * @example
298
+ * let mailbox = await client.mailboxOpen('Important stuff');
299
+ * console.log(mailbox.exists);
300
+ * // 125
301
+ */
302
+ mailboxOpen(path: string | string[], options?: MailboxOpenOptions | undefined): Promise<MailboxObject>;
303
+ /**
304
+ * Closes a previously opened mailbox
305
+ *
306
+ * @returns Did the operation succeed or not
307
+ *
308
+ * @example
309
+ * let mailbox = await client.mailboxOpen('INBOX');
310
+ * await client.mailboxClose();
311
+ */
312
+ mailboxClose(): Promise<boolean>;
313
+ /**
314
+ * Requests the status of the indicated mailbox. Only requested status values will be returned.
315
+ *
316
+ * @param path mailbox path to check for (unicode string). If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
317
+ * @param query defines requested status items
318
+ * @returns status of the indicated mailbox
319
+ *
320
+ * @example
321
+ * let status = await client.status('INBOX', {unseen: true});
322
+ * console.log(status.unseen);
323
+ * // 123
324
+ */
325
+ status(path: string | string[], query: StatusQuery): Promise<StatusObject>;
326
+ /**
327
+ * Starts listening for new or deleted messages from the currently opened mailbox. Only required if `disableAutoIdle` is set to `true`
328
+ * otherwise IDLE is started by default on connection inactivity. NB! If `idle()` is called manually then it does not
329
+ * return until IDLE is finished which means you would have to call some other command out of scope.
330
+ *
331
+ * @returns Did the operation succeed or not
332
+ *
333
+ * @example
334
+ * let mailbox = await client.mailboxOpen('INBOX');
335
+ *
336
+ * await client.idle();
337
+ */
338
+ idle(): Promise<boolean | undefined>;
339
+ /**
340
+ * Sets flags for a message or message range
341
+ *
342
+ * @param range Range to filter the messages
343
+ * @param flags Array of flags to set. Only flags that are permitted to set are used, other flags are ignored
344
+ * @param options Store options
345
+ * @returns Did the operation succeed or not
346
+ *
347
+ * @example
348
+ * let mailbox = await client.mailboxOpen('INBOX');
349
+ * // mark all unseen messages as seen (and remove other flags)
350
+ * await client.messageFlagsSet({seen: false}, ['\Seen]);
351
+ */
352
+ messageFlagsSet(range: MessageRange, flags: string[], options?: StoreOptions | undefined): Promise<boolean>;
353
+ /**
354
+ * Adds flags for a message or message range
355
+ *
356
+ * @param range Range to filter the messages
357
+ * @param flags Array of flags to set. Only flags that are permitted to set are used, other flags are ignored
358
+ * @param options Store options
359
+ * @returns Did the operation succeed or not
360
+ *
361
+ * @example
362
+ * let mailbox = await client.mailboxOpen('INBOX');
363
+ * // mark all unseen messages as seen (and keep other flags as is)
364
+ * await client.messageFlagsAdd({seen: false}, ['\Seen]);
365
+ */
366
+ messageFlagsAdd(range: MessageRange, flags: string[], options?: StoreOptions | undefined): Promise<boolean>;
367
+ /**
368
+ * Remove specific flags from a message or message range
369
+ *
370
+ * @param range Range to filter the messages
371
+ * @param flags Array of flags to remove. Only flags that are permitted to set are used, other flags are ignored
372
+ * @param options Store options
373
+ * @returns Did the operation succeed or not
374
+ *
375
+ * @example
376
+ * let mailbox = await client.mailboxOpen('INBOX');
377
+ * // mark all seen messages as unseen by removing \\Seen flag
378
+ * await client.messageFlagsRemove({seen: true}, ['\Seen]);
379
+ */
380
+ messageFlagsRemove(range: MessageRange, flags: string[], options?: StoreOptions | undefined): Promise<boolean>;
381
+ /**
382
+ * Sets a colored flag for an email. Only supported by mail clients like Apple Mail
383
+ *
384
+ * @param range Range to filter the messages
385
+ * @param color The color to set. One of 'red', 'orange', 'yellow', 'green', 'blue', 'purple', and 'grey'
386
+ * @param options Store options
387
+ * @returns Did the operation succeed or not
388
+ *
389
+ * @example
390
+ * let mailbox = await client.mailboxOpen('INBOX');
391
+ * // add a purple flag for all emails
392
+ * await client.setFlagColor('1:*', 'Purple');
393
+ */
394
+ setFlagColor(range: MessageRange, color: string, options?: StoreOptions | undefined): Promise<boolean>;
395
+ /**
396
+ * Delete messages from the currently opened mailbox. Method does not indicate info about deleted messages,
397
+ * instead you should be using the `expunge` event for this
398
+ *
399
+ * @param range Range to filter the messages
400
+ * @param options Range options
401
+ * @returns Did the operation succeed or not
402
+ *
403
+ * @example
404
+ * let mailbox = await client.mailboxOpen('INBOX');
405
+ * // delete all seen messages
406
+ * await client.messageDelete({seen: true});
407
+ */
408
+ messageDelete(range: MessageRange, options?: MessageRangeOptions | undefined): Promise<boolean>;
409
+ /**
410
+ * Appends a new message to a mailbox
411
+ *
412
+ * @param path Mailbox path to upload the message to (unicode string). If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
413
+ * @param content RFC822 formatted email message
414
+ * @param flags an array of flags to be set for the uploaded message
415
+ * @param idate internal date to be set for the message
416
+ * @returns info about uploaded message
417
+ *
418
+ * @example
419
+ * await client.append('INBOX', rawMessageBuffer, ['\\Seen'], new Date(2000, 1, 1));
420
+ */
421
+ append(path: string | string[], content: string | Buffer, flags?: string[] | undefined, idate?: Date | string | undefined): Promise<AppendResponseObject | false>;
422
+ /**
423
+ * Copies messages from current mailbox to destination mailbox
424
+ *
425
+ * @param range Range of messages to copy
426
+ * @param destination Mailbox path to copy the messages to. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
427
+ * @param options Range options
428
+ * @returns info about copies messages
429
+ *
430
+ * @example
431
+ * await client.mailboxOpen('INBOX');
432
+ * // copy all messages to a mailbox called "Backup" (must exist)
433
+ * let result = await client.messageCopy('1:*', 'Backup');
434
+ * console.log('Copied %s messages', result.uidMap.size);
435
+ */
436
+ messageCopy(range: MessageRange, destination: string | string[], options?: MessageRangeOptions | undefined): Promise<CopyResponseObject | false>;
437
+ /**
438
+ * Moves messages from current mailbox to destination mailbox
439
+ *
440
+ * @param range Range of messages to move
441
+ * @param destination Mailbox path to move the messages to. If value is an array then it is joined using current delimiter symbols. Namespace prefix is added automatically if required.
442
+ * @param options Range options
443
+ * @returns info about moved messages
444
+ *
445
+ * @example
446
+ * await client.mailboxOpen('INBOX');
447
+ * // move all messages to a mailbox called "Trash" (must exist)
448
+ * let result = await client.messageMove('1:*', 'Trash');
449
+ * console.log('Moved %s messages', result.uidMap.size);
450
+ */
451
+ messageMove(range: MessageRange, destination: string | string[], options?: MessageRangeOptions | undefined): Promise<CopyResponseObject | false>;
452
+ /**
453
+ * Search messages from the currently opened mailbox
454
+ *
455
+ * @param query Query to filter the messages
456
+ * @param options Search options. With `returnOptions` set the result is an ESEARCH result object
457
+ * @returns An array of sequence or UID numbers, or an ESearchResult when `returnOptions` was used
458
+ *
459
+ * @example
460
+ * let mailbox = await client.mailboxOpen('INBOX');
461
+ * // find all unseen messages
462
+ * let list = await client.search({seen: false});
463
+ * // use OR modifier (array of 2 or more search queries)
464
+ * let list = await client.search({
465
+ * seen: false,
466
+ * or: [
467
+ * {flagged: true},
468
+ * {from: 'andris'},
469
+ * {subject: 'test'}
470
+ * ]});
471
+ */
472
+ search(query: SearchObject, options?: MessageRangeOptions | undefined): Promise<number[] | false | undefined>;
473
+ search(query: SearchObject, options: SearchOptions & {
474
+ returnOptions: SearchReturnOption[];
475
+ }): Promise<ESearchResult | number[] | false | undefined>;
476
+ search(query: SearchObject, options?: SearchOptions | undefined): Promise<ESearchResult | number[] | false | undefined>;
477
+ /**
478
+ * Fetch messages from the currently opened mailbox
479
+ *
480
+ * @param range Range of messages to fetch
481
+ * @param query Fetch query
482
+ * @param options Fetch options
483
+ * @yields Message data object
484
+ *
485
+ * @example
486
+ * let mailbox = await client.mailboxOpen('INBOX');
487
+ * // fetch UID for all messages in a mailbox
488
+ * for await (let msg of client.fetch('1:*', {uid: true})){
489
+ * console.log(msg.uid);
490
+ * // NB! You can not run any IMAP commands in this loop
491
+ * // otherwise you will end up in a deadloop
492
+ * }
493
+ */
494
+ fetch(range: MessageRange, query: FetchQueryObject, options?: FetchOptions | undefined): AsyncGenerator<FetchMessageObject, false | void, undefined>;
495
+ /**
496
+ * Fetch messages from the currently opened mailbox.
497
+ *
498
+ * This method will fetch all messages before resolving the promise, unlike .fetch(), which
499
+ * is an async generator. Do not use large ranges like 1:*, as this might exhaust all available
500
+ * memory if the mailbox contains a large number of emails.
501
+ * @param range Range of messages to fetch
502
+ * @param query Fetch query
503
+ * @param options Fetch options
504
+ * @returns Array of Message data object
505
+ *
506
+ * @example
507
+ * let mailbox = await client.mailboxOpen('INBOX');
508
+ * // fetch UID for all messages in a mailbox
509
+ * const messages = await client.fetchAll('1:*', {uid: true});
510
+ * for (let msg of messages){
511
+ * console.log(msg.uid);
512
+ * }
513
+ */
514
+ fetchAll(range: MessageRange, query: FetchQueryObject, options?: FetchOptions | undefined): Promise<FetchMessageObject[]>;
515
+ /**
516
+ * Fetch a single message from the currently opened mailbox
517
+ *
518
+ * @param seq Single UID or sequence number of the message to fetch for
519
+ * @param query Fetch query
520
+ * @param options Fetch options
521
+ * @returns Message data object
522
+ *
523
+ * @example
524
+ * let mailbox = await client.mailboxOpen('INBOX');
525
+ * // fetch UID for the last email in the selected mailbox
526
+ * let lastMsg = await client.fetchOne('*', {uid: true})
527
+ * console.log(lastMsg.uid);
528
+ */
529
+ fetchOne(seq: SequenceString, query: FetchQueryObject, options?: FetchOptions | undefined): Promise<FetchMessageObject | false | undefined>;
530
+ /**
531
+ * Download either full rfc822 formatted message or a specific bodystructure part as a Stream.
532
+ * Bodystructure parts are decoded so the resulting stream is a binary file. Text content
533
+ * is automatically converted to UTF-8 charset.
534
+ *
535
+ * @param range UID or sequence number for the message to fetch
536
+ * @param part If not set then downloads entire rfc822 formatted message, otherwise downloads specific bodystructure part
537
+ * @param options Download options
538
+ * @returns Download data object. Resolves with an empty object when no mailbox is selected or the message or part was not found
539
+ *
540
+ * @example
541
+ * let mailbox = await client.mailboxOpen('INBOX');
542
+ * // download body part nr '1.2' from latest message
543
+ * let {meta, content} = await client.download('*', '1.2');
544
+ * content.pipe(fs.createWriteStream(meta.filename));
545
+ */
546
+ download(range: SequenceString, part?: string | undefined, options?: DownloadOptions | undefined): Promise<DownloadObject>;
547
+ /**
548
+ * Fetch multiple attachments as Buffer values
549
+ *
550
+ * @param range UID or sequence number for the message to fetch
551
+ * @param parts A list of bodystructure parts
552
+ * @param options Download options
553
+ * @returns Download data object, keyed by part
554
+ *
555
+ * @example
556
+ * let mailbox = await client.mailboxOpen('INBOX');
557
+ * // download body parts '2', and '3' from all messages in the selected mailbox
558
+ * let response = await client.downloadMany('*', ['2', '3']);
559
+ * process.stdout.write(response[2].content)
560
+ * process.stdout.write(response[3].content)
561
+ */
562
+ downloadMany(range: SequenceString, parts: string[], options?: DownloadManyOptions | undefined): Promise<DownloadManyResult>;
563
+ /**
564
+ * Opens a mailbox if not already open and returns a lock. Next call to `getMailboxLock()` is queued
565
+ * until previous lock is released. This is suggested over {@link ImapFlow#mailboxOpen} as
566
+ * `getMailboxLock()` gives you a weak transaction while `mailboxOpen()` has no guarantees whatsoever that another
567
+ * mailbox is opened while you try to call multiple fetch or store commands.
568
+ *
569
+ * @param path **Path for the mailbox** to open
570
+ * @param options optional options
571
+ * @returns Mailbox lock
572
+ * @throws Will throw an error if mailbox does not exist or can not be opened
573
+ *
574
+ * @example
575
+ * let lock = await client.getMailboxLock('INBOX');
576
+ * try {
577
+ * // do something in the mailbox
578
+ * } finally {
579
+ * // use finally{} to make sure lock is released even if exception occurs
580
+ * lock.release();
581
+ * }
582
+ */
583
+ getMailboxLock(path: string | string[], options?: MailboxLockOptions | undefined): Promise<MailboxLockObject>;
584
+ /**
585
+ * Detaches sockets from the IMAP pipeline. Useful for upgrading the connection
586
+ * (e.g., STARTTLS) or transferring socket ownership.
587
+ *
588
+ * @returns Socket objects: `readSocket` is the read socket (inflated socket if compression is enabled, raw socket otherwise),
589
+ * `writeSocket` the write socket and `socket` the raw underlying socket (same as readSocket/writeSocket when compression is disabled)
590
+ */
591
+ unbind(): {
592
+ readSocket: Readable;
593
+ writeSocket: WriteSocket;
594
+ socket: ImapSocket;
595
+ };
596
+ }
597
+ /**
598
+ * Connection close event. **NB!** ImapFlow does not handle reconnects automatically.
599
+ * So whenever a 'close' event occurs you must create a new connection yourself.
600
+ *
601
+ * @event ImapFlow#close
602
+ */
603
+ /**
604
+ * Error event. In most cases getting an error event also means that connection is closed
605
+ * and pending operations should return with a failure.
606
+ *
607
+ * @event ImapFlow#error
608
+ * @example
609
+ * client.on('error', err=>{
610
+ * console.log(`Error occurred: ${err.message}`);
611
+ * });
612
+ */
613
+ /**
614
+ * Message count in currently opened mailbox changed
615
+ *
616
+ * @event ImapFlow#exists
617
+ * @example
618
+ * client.on('exists', data=>{
619
+ * console.log(`Message count in "${data.path}" is ${data.count}`);
620
+ * });
621
+ */
622
+ /**
623
+ * Deleted message sequence number in currently opened mailbox. One event is fired for every deleted email.
624
+ *
625
+ * @event ImapFlow#expunge
626
+ * @example
627
+ * client.on('expunge', data=>{
628
+ * console.log(`Message #${data.seq} was deleted from "${data.path}"`);
629
+ * });
630
+ */
631
+ /**
632
+ * Flags were updated for a message. Not all servers fire this event.
633
+ *
634
+ * @event ImapFlow#flags
635
+ * @example
636
+ * client.on('flags', data=>{
637
+ * console.log(`Flag set for #${data.seq} is now "${Array.from(data.flags).join(', ')}"`);
638
+ * });
639
+ */
640
+ /**
641
+ * Mailbox was opened
642
+ *
643
+ * @event ImapFlow#mailboxOpen
644
+ * @example
645
+ * client.on('mailboxOpen', mailbox => {
646
+ * console.log(`Mailbox ${mailbox.path} was opened`);
647
+ * });
648
+ */
649
+ /**
650
+ * Mailbox was closed
651
+ *
652
+ * Emitted both when a selected mailbox is closed explicitly, by `mailboxClose()` or by
653
+ * selecting a different mailbox, and when the connection itself goes away while a mailbox
654
+ * was still selected, whether through a clean logout or a lost transport. The transition is
655
+ * reported once per selected mailbox, before the `close` event.
656
+ *
657
+ * @event ImapFlow#mailboxClose
658
+ * @example
659
+ * client.on('mailboxClose', mailbox => {
660
+ * console.log(`Mailbox ${mailbox.path} was closed`);
661
+ * });
662
+ */
663
+ /**
664
+ * Log event if `emitLogs=true`
665
+ *
666
+ * @event ImapFlow#log
667
+ * @example
668
+ * client.on('log', entry => {
669
+ * console.log(`${entry.cid} ${entry.msg}`);
670
+ * });
671
+ */
672
+ declare const imapflow: {
673
+ ImapFlow: typeof ImapFlow;
674
+ AuthenticationFailure: typeof AuthenticationFailure;
675
+ };
676
+ export default imapflow;