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.
- package/CHANGELOG.md +20 -0
- package/README.md +8 -2
- package/dist/cjs/charsets.d.ts +1 -0
- package/dist/cjs/charsets.js +294 -0
- package/dist/cjs/commands/append.d.ts +22 -0
- package/dist/cjs/commands/append.js +151 -0
- package/dist/cjs/commands/authenticate.d.ts +24 -0
- package/dist/cjs/commands/authenticate.js +223 -0
- package/dist/cjs/commands/capability.d.ts +8 -0
- package/dist/cjs/commands/capability.js +32 -0
- package/dist/cjs/commands/close.d.ts +8 -0
- package/dist/cjs/commands/close.js +39 -0
- package/dist/cjs/commands/compress.d.ts +8 -0
- package/dist/cjs/commands/compress.js +56 -0
- package/dist/cjs/commands/copy.d.ts +13 -0
- package/dist/cjs/commands/copy.js +44 -0
- package/dist/cjs/commands/copyuid-parser.d.ts +11 -0
- package/dist/cjs/commands/copyuid-parser.js +32 -0
- package/dist/cjs/commands/create.d.ts +11 -0
- package/dist/cjs/commands/create.js +80 -0
- package/dist/cjs/commands/delete.d.ts +11 -0
- package/dist/cjs/commands/delete.js +40 -0
- package/dist/cjs/commands/enable.d.ts +9 -0
- package/dist/cjs/commands/enable.js +61 -0
- package/dist/cjs/commands/esearch-parser.d.ts +17 -0
- package/dist/cjs/commands/esearch-parser.js +91 -0
- package/dist/cjs/commands/expunge.d.ts +12 -0
- package/dist/cjs/commands/expunge.js +60 -0
- package/dist/cjs/commands/fetch.d.ts +30 -0
- package/dist/cjs/commands/fetch.js +241 -0
- package/dist/cjs/commands/id.d.ts +10 -0
- package/dist/cjs/commands/id.js +80 -0
- package/dist/cjs/commands/idle.d.ts +9 -0
- package/dist/cjs/commands/idle.js +347 -0
- package/dist/cjs/commands/list.d.ts +16 -0
- package/dist/cjs/commands/list.js +518 -0
- package/dist/cjs/commands/login.d.ts +11 -0
- package/dist/cjs/commands/login.js +42 -0
- package/dist/cjs/commands/logout.d.ts +8 -0
- package/dist/cjs/commands/logout.js +47 -0
- package/dist/cjs/commands/move.d.ts +13 -0
- package/dist/cjs/commands/move.js +57 -0
- package/dist/cjs/commands/namespace.d.ts +25 -0
- package/dist/cjs/commands/namespace.js +139 -0
- package/dist/cjs/commands/noop.d.ts +8 -0
- package/dist/cjs/commands/noop.js +22 -0
- package/dist/cjs/commands/quota.d.ts +10 -0
- package/dist/cjs/commands/quota.js +119 -0
- package/dist/cjs/commands/rename.d.ts +12 -0
- package/dist/cjs/commands/rename.js +48 -0
- package/dist/cjs/commands/search.d.ts +15 -0
- package/dist/cjs/commands/search.js +228 -0
- package/dist/cjs/commands/select.d.ts +25 -0
- package/dist/cjs/commands/select.js +250 -0
- package/dist/cjs/commands/starttls.d.ts +8 -0
- package/dist/cjs/commands/starttls.js +30 -0
- package/dist/cjs/commands/status-fields.d.ts +14 -0
- package/dist/cjs/commands/status-fields.js +61 -0
- package/dist/cjs/commands/status.d.ts +12 -0
- package/dist/cjs/commands/status.js +108 -0
- package/dist/cjs/commands/store.d.ts +19 -0
- package/dist/cjs/commands/store.js +93 -0
- package/dist/cjs/commands/subscribe.d.ts +9 -0
- package/dist/cjs/commands/subscribe.js +31 -0
- package/dist/cjs/commands/unsubscribe.d.ts +9 -0
- package/dist/cjs/commands/unsubscribe.js +31 -0
- package/dist/cjs/connection-deadline.d.ts +49 -0
- package/dist/cjs/connection-deadline.js +91 -0
- package/dist/cjs/errors.d.ts +83 -0
- package/dist/cjs/errors.js +13 -0
- package/dist/cjs/handler/imap-compiler.d.ts +24 -0
- package/dist/cjs/handler/imap-compiler.js +285 -0
- package/dist/cjs/handler/imap-formal-syntax.d.ts +28 -0
- package/dist/cjs/handler/imap-formal-syntax.js +121 -0
- package/dist/cjs/handler/imap-handler.d.ts +9 -0
- package/dist/cjs/handler/imap-handler.js +10 -0
- package/dist/cjs/handler/imap-parser.d.ts +16 -0
- package/dist/cjs/handler/imap-parser.js +90 -0
- package/dist/cjs/handler/imap-stream.d.ts +181 -0
- package/dist/cjs/handler/imap-stream.js +446 -0
- package/dist/cjs/handler/limits.d.ts +25 -0
- package/dist/cjs/handler/limits.js +51 -0
- package/dist/cjs/handler/parser-instance.d.ts +68 -0
- package/dist/cjs/handler/parser-instance.js +223 -0
- package/dist/cjs/handler/token-parser.d.ts +91 -0
- package/dist/cjs/handler/token-parser.js +673 -0
- package/dist/cjs/handler/types.d.ts +91 -0
- package/dist/cjs/handler/types.js +4 -0
- package/dist/cjs/imap-commands.d.ts +16 -0
- package/dist/cjs/imap-commands.js +74 -0
- package/dist/cjs/imap-flow.d.ts +676 -0
- package/dist/cjs/imap-flow.js +3949 -0
- package/dist/cjs/jp-decoder.d.ts +12 -0
- package/dist/cjs/jp-decoder.js +79 -0
- package/dist/cjs/limited-passthrough.d.ts +25 -0
- package/dist/cjs/limited-passthrough.js +54 -0
- package/dist/cjs/logger.d.ts +3 -0
- package/dist/cjs/logger.js +11 -0
- package/dist/cjs/package-info.d.ts +3 -0
- package/dist/cjs/package-info.js +7 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/proxy-connection.d.ts +33 -0
- package/dist/cjs/proxy-connection.js +392 -0
- package/dist/cjs/search-compiler.d.ts +34 -0
- package/dist/cjs/search-compiler.js +476 -0
- package/dist/cjs/special-use.d.ts +22 -0
- package/dist/cjs/special-use.js +911 -0
- package/dist/cjs/tools.d.ts +427 -0
- package/dist/cjs/tools.js +1496 -0
- package/{lib/imap-flow.d.ts → dist/cjs/types.d.ts} +386 -516
- package/dist/cjs/types.js +5 -0
- package/dist/esm/charsets.d.ts +1 -0
- package/{lib → dist/esm}/charsets.js +1 -6
- package/dist/esm/commands/append.d.ts +22 -0
- package/{lib → dist/esm}/commands/append.js +22 -52
- package/dist/esm/commands/authenticate.d.ts +24 -0
- package/{lib → dist/esm}/commands/authenticate.js +62 -87
- package/dist/esm/commands/capability.d.ts +8 -0
- package/{lib → dist/esm}/commands/capability.js +6 -9
- package/dist/esm/commands/close.d.ts +8 -0
- package/{lib → dist/esm}/commands/close.js +6 -10
- package/dist/esm/commands/compress.d.ts +8 -0
- package/{lib → dist/esm}/commands/compress.js +7 -11
- package/dist/esm/commands/copy.d.ts +13 -0
- package/{lib → dist/esm}/commands/copy.js +12 -20
- package/dist/esm/commands/copyuid-parser.d.ts +11 -0
- package/{lib → dist/esm}/commands/copyuid-parser.js +9 -15
- package/dist/esm/commands/create.d.ts +11 -0
- package/{lib → dist/esm}/commands/create.js +13 -27
- package/dist/esm/commands/delete.d.ts +11 -0
- package/{lib → dist/esm}/commands/delete.js +9 -14
- package/dist/esm/commands/enable.d.ts +9 -0
- package/{lib → dist/esm}/commands/enable.js +23 -30
- package/dist/esm/commands/esearch-parser.d.ts +17 -0
- package/dist/esm/commands/esearch-parser.js +88 -0
- package/dist/esm/commands/expunge.d.ts +12 -0
- package/{lib → dist/esm}/commands/expunge.js +17 -22
- package/dist/esm/commands/fetch.d.ts +30 -0
- package/{lib → dist/esm}/commands/fetch.js +32 -64
- package/dist/esm/commands/id.d.ts +10 -0
- package/{lib → dist/esm}/commands/id.js +17 -23
- package/dist/esm/commands/idle.d.ts +9 -0
- package/{lib → dist/esm}/commands/idle.js +47 -81
- package/dist/esm/commands/list.d.ts +16 -0
- package/{lib → dist/esm}/commands/list.js +56 -121
- package/dist/esm/commands/login.d.ts +11 -0
- package/{lib → dist/esm}/commands/login.js +10 -15
- package/dist/esm/commands/logout.d.ts +8 -0
- package/{lib → dist/esm}/commands/logout.js +9 -11
- package/dist/esm/commands/move.d.ts +13 -0
- package/{lib → dist/esm}/commands/move.js +13 -21
- package/dist/esm/commands/namespace.d.ts +25 -0
- package/{lib → dist/esm}/commands/namespace.js +34 -44
- package/dist/esm/commands/noop.d.ts +8 -0
- package/{lib → dist/esm}/commands/noop.js +6 -7
- package/dist/esm/commands/quota.d.ts +10 -0
- package/{lib → dist/esm}/commands/quota.js +18 -36
- package/dist/esm/commands/rename.d.ts +12 -0
- package/{lib → dist/esm}/commands/rename.js +10 -15
- package/dist/esm/commands/search.d.ts +15 -0
- package/{lib → dist/esm}/commands/search.js +36 -135
- package/dist/esm/commands/select.d.ts +25 -0
- package/{lib → dist/esm}/commands/select.js +33 -64
- package/dist/esm/commands/starttls.d.ts +8 -0
- package/{lib → dist/esm}/commands/starttls.js +6 -8
- package/dist/esm/commands/status-fields.d.ts +14 -0
- package/{lib → dist/esm}/commands/status-fields.js +5 -16
- package/dist/esm/commands/status.d.ts +12 -0
- package/{lib → dist/esm}/commands/status.js +18 -29
- package/dist/esm/commands/store.d.ts +19 -0
- package/{lib → dist/esm}/commands/store.js +24 -37
- package/dist/esm/commands/subscribe.d.ts +9 -0
- package/{lib → dist/esm}/commands/subscribe.js +8 -12
- package/dist/esm/commands/unsubscribe.d.ts +9 -0
- package/{lib → dist/esm}/commands/unsubscribe.js +8 -12
- package/dist/esm/connection-deadline.d.ts +49 -0
- package/{lib → dist/esm}/connection-deadline.js +14 -25
- package/dist/esm/errors.d.ts +83 -0
- package/dist/esm/errors.js +9 -0
- package/dist/esm/handler/imap-compiler.d.ts +24 -0
- package/{lib → dist/esm}/handler/imap-compiler.js +22 -80
- package/dist/esm/handler/imap-formal-syntax.d.ts +28 -0
- package/dist/esm/handler/imap-formal-syntax.js +117 -0
- package/dist/esm/handler/imap-handler.d.ts +9 -0
- package/dist/esm/handler/imap-handler.js +9 -0
- package/dist/esm/handler/imap-parser.d.ts +16 -0
- package/{lib → dist/esm}/handler/imap-parser.js +31 -44
- package/dist/esm/handler/imap-stream.d.ts +181 -0
- package/{lib → dist/esm}/handler/imap-stream.js +29 -121
- package/dist/esm/handler/limits.d.ts +25 -0
- package/{lib → dist/esm}/handler/limits.js +13 -22
- package/dist/esm/handler/parser-instance.d.ts +68 -0
- package/{lib → dist/esm}/handler/parser-instance.js +19 -47
- package/dist/esm/handler/token-parser.d.ts +91 -0
- package/{lib → dist/esm}/handler/token-parser.js +71 -155
- package/dist/esm/handler/types.d.ts +91 -0
- package/dist/esm/handler/types.js +3 -0
- package/dist/esm/imap-commands.d.ts +16 -0
- package/dist/esm/imap-commands.js +67 -0
- package/dist/esm/imap-flow.d.ts +676 -0
- package/{lib → dist/esm}/imap-flow.js +761 -1789
- package/dist/esm/jp-decoder.d.ts +12 -0
- package/{lib → dist/esm}/jp-decoder.js +6 -21
- package/dist/esm/limited-passthrough.d.ts +25 -0
- package/{lib → dist/esm}/limited-passthrough.js +7 -20
- package/dist/esm/logger.d.ts +3 -0
- package/dist/esm/logger.js +4 -0
- package/dist/esm/package-info.d.ts +3 -0
- package/dist/esm/package-info.js +4 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/proxy-connection.d.ts +33 -0
- package/{lib → dist/esm}/proxy-connection.js +56 -127
- package/dist/esm/search-compiler.d.ts +34 -0
- package/{lib → dist/esm}/search-compiler.js +54 -110
- package/dist/esm/special-use.d.ts +22 -0
- package/dist/esm/special-use.js +907 -0
- package/dist/esm/tools.d.ts +427 -0
- package/dist/esm/tools.js +1446 -0
- package/dist/esm/types.d.ts +828 -0
- package/dist/esm/types.js +4 -0
- package/package.json +60 -20
- package/.gitattributes +0 -1
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/FUNDING.yml +0 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
- package/.github/contributing.md +0 -17
- package/.github/workflows/release.yaml +0 -36
- package/.github/workflows/stale.yml +0 -29
- package/.github/workflows/test.yml +0 -51
- package/.ncurc.js +0 -4
- package/.prettierignore +0 -4
- package/.prettierrc.js +0 -8
- package/.release-please-manifest.json +0 -3
- package/CLAUDE.md +0 -104
- package/Gruntfile.js +0 -23
- package/eslint.config.js +0 -45
- package/lib/handler/imap-formal-syntax.js +0 -189
- package/lib/handler/imap-handler.js +0 -17
- package/lib/imap-commands.js +0 -45
- package/lib/logger.js +0 -5
- package/lib/special-use.js +0 -923
- package/lib/tools.js +0 -1612
- package/release-please-config.json +0 -10
- package/test/authentication-test.js +0 -101
- package/test/auto-idle-test.js +0 -470
- package/test/bodystructure-test.js +0 -899
- package/test/charsets-test.js +0 -161
- package/test/commands-branches-test.js +0 -1095
- package/test/commands-integration-test.js +0 -11124
- package/test/commands-test.js +0 -73
- package/test/connection-edge-cases-test.js +0 -1828
- package/test/connection-test.js +0 -162
- package/test/copyuid-parser-test.js +0 -173
- package/test/fetch-generator-test.js +0 -218
- package/test/fixtures/fake-timers.js +0 -115
- package/test/fixtures/serialized-mimetorture.js +0 -2738
- package/test/fixtures/test-client.js +0 -101
- package/test/fixtures/test-tls.js +0 -8
- package/test/handler-branches-test.js +0 -310
- package/test/idle-polling-test.js +0 -518
- package/test/imap-compiler-test.js +0 -809
- package/test/imap-flow-compress-test.js +0 -166
- package/test/imap-flow-coverage-test.js +0 -612
- package/test/imap-flow-fetch-download-test.js +0 -909
- package/test/imap-flow-internals-test.js +0 -725
- package/test/imap-flow-methods-test.js +0 -889
- package/test/imap-flow-proxy-paths-test.js +0 -366
- package/test/imap-flow-secure-test.js +0 -573
- package/test/imap-flow-server-test.js +0 -1474
- package/test/imap-formal-syntax-test.js +0 -293
- package/test/imap-parser-test.js +0 -1474
- package/test/imap-stream-edge-cases-test.js +0 -666
- package/test/imap-stream-test.js +0 -177
- package/test/imapflow-test.js +0 -258
- package/test/integration/README.md +0 -52
- package/test/integration/dovecot-test.conf +0 -27
- package/test/integration/rev2-live-test.js +0 -431
- package/test/integration/run-rev2-tests.sh +0 -75
- package/test/integration-test.js +0 -83
- package/test/jp-decoder-test.js +0 -304
- package/test/limited-passthrough-test.js +0 -299
- package/test/memory-cleanup-test.js +0 -144
- package/test/memory-leak-test.js +0 -667
- package/test/parser-limits-test.js +0 -292
- package/test/proxy-connection-test.js +0 -738
- package/test/reliability-improvements-test.js +0 -548
- package/test/search-compiler-test.js +0 -1300
- package/test/search-test.js +0 -329
- package/test/special-use-test.js +0 -418
- package/test/starttls-injection-test.js +0 -181
- package/test/tag-correlation-test.js +0 -333
- package/test/timer-policy-test.js +0 -227
- package/test/token-parser-test.js +0 -456
- package/test/tools-test.js +0 -2013
- package/test/unhandled-rejection-test.js +0 -661
|
@@ -1,35 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ConnectionOptions, CipherNameAndProtocol } from 'node:tls';
|
|
2
|
+
import type { Readable } from 'node:stream';
|
|
3
|
+
/**
|
|
4
|
+
* Logger interface. Any object with `debug`, `info`, `warn` and `error` methods can be used,
|
|
5
|
+
* for example a pino or bunyan instance. `trace` and `fatal` are used when present.
|
|
6
|
+
*/
|
|
7
|
+
export interface Logger {
|
|
8
|
+
trace?: ((obj: any) => void) | undefined;
|
|
9
|
+
debug(obj: any): void;
|
|
10
|
+
info(obj: any): void;
|
|
11
|
+
warn(obj: any): void;
|
|
12
|
+
error(obj: any): void;
|
|
13
|
+
fatal?: ((obj: any) => void) | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Authentication options
|
|
17
|
+
*/
|
|
18
|
+
export interface AuthOptions {
|
|
19
|
+
/** Username */
|
|
20
|
+
user: string;
|
|
21
|
+
/** Password for regular authentication (if using OAuth2 then use `accessToken` instead) */
|
|
22
|
+
pass?: string | undefined;
|
|
23
|
+
/** OAuth2 access token, if using OAuth2 authentication */
|
|
24
|
+
accessToken?: string | undefined;
|
|
25
|
+
/** Optional login method override. Set to 'LOGIN', 'AUTH=LOGIN' or 'AUTH=PLAIN' to use specific method */
|
|
26
|
+
loginMethod?: string | undefined;
|
|
27
|
+
/** Authorization identity for SASL PLAIN (used for admin impersonation/delegation). When set, authenticates as `user` but authorizes as `authzid` */
|
|
28
|
+
authzid?: string | undefined;
|
|
29
|
+
}
|
|
5
30
|
export interface ImapFlowOptions {
|
|
6
31
|
/** Hostname of the IMAP server */
|
|
7
|
-
host
|
|
32
|
+
host?: string | undefined;
|
|
8
33
|
/** Port number for the IMAP server */
|
|
9
|
-
port
|
|
34
|
+
port?: number | undefined;
|
|
10
35
|
/** If true, the connection will use TLS. If false, then TLS is used only if the server supports STARTTLS extension */
|
|
11
|
-
secure?: boolean;
|
|
36
|
+
secure?: boolean | undefined;
|
|
12
37
|
/** Servername for SNI (or when host is set to an IP address) */
|
|
13
|
-
servername?: string;
|
|
38
|
+
servername?: string | undefined;
|
|
14
39
|
/** If true, do not use COMPRESS=DEFLATE extension even if server supports it */
|
|
15
|
-
disableCompression?: boolean;
|
|
40
|
+
disableCompression?: boolean | undefined;
|
|
16
41
|
/** 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
|
-
/** Authorization identity for SASL PLAIN (used for admin impersonation/delegation). When set, authenticates as `user` but authorizes as `authzid` */
|
|
27
|
-
authzid?: string;
|
|
28
|
-
};
|
|
42
|
+
auth?: AuthOptions | undefined;
|
|
29
43
|
/** Client identification info sent to the server if server supports ID extension */
|
|
30
|
-
clientInfo?: IdInfoObject;
|
|
44
|
+
clientInfo?: IdInfoObject | undefined;
|
|
31
45
|
/** If true, then do not start IDLE when connection is established */
|
|
32
|
-
disableAutoIdle?: boolean;
|
|
46
|
+
disableAutoIdle?: boolean | undefined;
|
|
33
47
|
/**
|
|
34
48
|
* How long (in ms) the connection has to be inactive before IDLE is started automatically.
|
|
35
49
|
* Keep it above the pause your own code usually leaves between two commands, otherwise every
|
|
@@ -40,22 +54,22 @@ export interface ImapFlowOptions {
|
|
|
40
54
|
* the polling fallback starts, not how often it polls - the poll interval is `maxIdleTime`,
|
|
41
55
|
* capped at 2 minutes. Default: 15000 ms.
|
|
42
56
|
*/
|
|
43
|
-
autoIdleDelay?: number;
|
|
57
|
+
autoIdleDelay?: number | string | undefined;
|
|
44
58
|
/** Additional TLS options (see Node.js TLS documentation) */
|
|
45
|
-
tls?: ConnectionOptions;
|
|
59
|
+
tls?: ConnectionOptions | undefined;
|
|
46
60
|
/** Custom logger instance. Set to false to disable logging */
|
|
47
|
-
logger?: Logger | false;
|
|
61
|
+
logger?: Logger | false | undefined;
|
|
48
62
|
/**
|
|
49
63
|
* If true, log data read and written to socket encoded in base64. Client frames that carry
|
|
50
64
|
* credentials are replaced with a fixed placeholder and marked with `hidden: true`.
|
|
51
65
|
*/
|
|
52
|
-
logRaw?: boolean;
|
|
66
|
+
logRaw?: boolean | undefined;
|
|
53
67
|
/** If true, emit 'log' events */
|
|
54
|
-
emitLogs?: boolean;
|
|
68
|
+
emitLogs?: boolean | undefined;
|
|
55
69
|
/** If true, then logs out automatically after successful authentication */
|
|
56
|
-
verifyOnly?: boolean;
|
|
70
|
+
verifyOnly?: boolean | undefined;
|
|
57
71
|
/** If true and verifyOnly is set, lists mailboxes */
|
|
58
|
-
includeMailboxes?: boolean;
|
|
72
|
+
includeMailboxes?: boolean | undefined;
|
|
59
73
|
/**
|
|
60
74
|
* Proxy URL. Supports HTTP CONNECT (http:, https:) and SOCKS (socks:, socks4:, socks4a:,
|
|
61
75
|
* socks5:) proxies. IPv6 proxy endpoints are given in URL form, e.g. `socks5://[2001:db8::1]:1080`.
|
|
@@ -72,29 +86,29 @@ export interface ImapFlowOptions {
|
|
|
72
86
|
* The proxy endpoint itself is never resolved by ImapFlow; a hostname endpoint is handed to
|
|
73
87
|
* Node as-is. Proxy DNS and negotiation run inside `connectionTimeout`.
|
|
74
88
|
*/
|
|
75
|
-
proxy?: string;
|
|
89
|
+
proxy?: string | undefined;
|
|
76
90
|
/** If true, then use QRESYNC instead of CONDSTORE. EXPUNGE notifications will include UID instead of sequence number */
|
|
77
|
-
qresync?: boolean;
|
|
91
|
+
qresync?: boolean | undefined;
|
|
78
92
|
/** If set, then breaks and restarts IDLE every maxIdleTime ms */
|
|
79
|
-
maxIdleTime?: number;
|
|
93
|
+
maxIdleTime?: number | undefined;
|
|
80
94
|
/** What command to run if IDLE is not supported. Defaults to 'NOOP' */
|
|
81
|
-
missingIdleCommand?: 'NOOP' | 'SELECT' | 'STATUS';
|
|
95
|
+
missingIdleCommand?: 'NOOP' | 'SELECT' | 'STATUS' | undefined;
|
|
82
96
|
/** If true, ignores BINARY extension when making FETCH and APPEND calls */
|
|
83
|
-
disableBinary?: boolean;
|
|
97
|
+
disableBinary?: boolean | undefined;
|
|
84
98
|
/** If true, do not enable supported extensions */
|
|
85
|
-
disableAutoEnable?: boolean;
|
|
99
|
+
disableAutoEnable?: boolean | undefined;
|
|
86
100
|
/** If true, do not enable IMAP4rev2 mode even if the server supports it */
|
|
87
|
-
disableIMAP4rev2?: boolean;
|
|
101
|
+
disableIMAP4rev2?: boolean | undefined;
|
|
88
102
|
/**
|
|
89
103
|
* How long to wait for a usable transport, covering DNS resolution, proxy negotiation and the
|
|
90
104
|
* TCP/TLS handshake as a single budget. Defaults to 90 seconds. An expiry in any of those
|
|
91
105
|
* phases rejects with error code `CONNECT_TIMEOUT`.
|
|
92
106
|
*/
|
|
93
|
-
connectionTimeout?: number;
|
|
107
|
+
connectionTimeout?: number | undefined;
|
|
94
108
|
/** How long to wait for the greeting. Defaults to 16 seconds */
|
|
95
|
-
greetingTimeout?: number;
|
|
109
|
+
greetingTimeout?: number | undefined;
|
|
96
110
|
/** How long to wait for socket inactivity before timing out the connection. Defaults to 5 minutes */
|
|
97
|
-
socketTimeout?: number;
|
|
111
|
+
socketTimeout?: number | undefined;
|
|
98
112
|
/**
|
|
99
113
|
* Maximum allowed length in bytes of a single response line (a response without a literal).
|
|
100
114
|
* Guards against a malicious or broken server that never sends a line terminator. Defaults to
|
|
@@ -104,7 +118,7 @@ export interface ImapFlowOptions {
|
|
|
104
118
|
* Exceeding it is terminal: the connection fails with error code `LineTooLarge` and
|
|
105
119
|
* no further input is parsed.
|
|
106
120
|
*/
|
|
107
|
-
maxLineLength?: number;
|
|
121
|
+
maxLineLength?: number | undefined;
|
|
108
122
|
/**
|
|
109
123
|
* Maximum allowed size in bytes of a single IMAP literal block. Bounds peak memory allocation
|
|
110
124
|
* against a malicious or broken server announcing an oversized literal. Defaults to 1GB. A
|
|
@@ -113,7 +127,7 @@ export interface ImapFlowOptions {
|
|
|
113
127
|
* with error code `LiteralTooLarge`, and neither the marker line nor any byte of the rejected
|
|
114
128
|
* literal is interpreted as protocol.
|
|
115
129
|
*/
|
|
116
|
-
maxLiteralSize?: number;
|
|
130
|
+
maxLiteralSize?: number | undefined;
|
|
117
131
|
/**
|
|
118
132
|
* Maximum allowed total size in bytes of a single assembled IMAP response (every line
|
|
119
133
|
* segment and literal of one response combined). Bounds peak memory allocation against
|
|
@@ -126,28 +140,20 @@ export interface ImapFlowOptions {
|
|
|
126
140
|
* Exceeding it is terminal: the connection fails with error code `ResponseTooLarge` and
|
|
127
141
|
* no further input is parsed.
|
|
128
142
|
*/
|
|
129
|
-
maxResponseSize?: number;
|
|
143
|
+
maxResponseSize?: number | undefined;
|
|
130
144
|
/**
|
|
131
145
|
* Threshold in milliseconds for warning that a mailbox lock has been held
|
|
132
146
|
* for a long time (diagnostic for forgotten release() calls). Defaults to
|
|
133
147
|
* 30 minutes. Set to 0 or false to disable.
|
|
134
148
|
*/
|
|
135
|
-
maxLockHoldTime?: number | false;
|
|
149
|
+
maxLockHoldTime?: number | false | undefined;
|
|
136
150
|
/** If true, uses TLS. If false, uses cleartext. If not set, upgrades to TLS if available */
|
|
137
|
-
doSTARTTLS?: boolean;
|
|
151
|
+
doSTARTTLS?: boolean | undefined;
|
|
138
152
|
/** Custom instance ID string for logs */
|
|
139
|
-
id?: string;
|
|
153
|
+
id?: string | undefined;
|
|
140
154
|
/** Optional expunge event handler function */
|
|
141
|
-
expungeHandler?: (event: ExpungeEvent) => Promise<void> | void;
|
|
155
|
+
expungeHandler?: ((event: ExpungeEvent) => Promise<void> | void) | undefined;
|
|
142
156
|
}
|
|
143
|
-
|
|
144
|
-
export interface Logger {
|
|
145
|
-
debug(obj: any): void;
|
|
146
|
-
info(obj: any): void;
|
|
147
|
-
warn(obj: any): void;
|
|
148
|
-
error(obj: any): void;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
157
|
export interface MailboxObject {
|
|
152
158
|
/** Mailbox path */
|
|
153
159
|
path: string;
|
|
@@ -156,19 +162,19 @@ export interface MailboxObject {
|
|
|
156
162
|
/** List of flags for this mailbox */
|
|
157
163
|
flags: Set<string>;
|
|
158
164
|
/** One of special-use flags (if applicable): "\All", "\Archive", "\Drafts", "\Flagged", "\Junk", "\Sent", "\Trash". Additionally INBOX has non-standard "\Inbox" flag set */
|
|
159
|
-
specialUse?: string;
|
|
165
|
+
specialUse?: string | undefined;
|
|
160
166
|
/** True if mailbox was found from the output of LIST command */
|
|
161
|
-
listed?: boolean;
|
|
167
|
+
listed?: boolean | undefined;
|
|
162
168
|
/** True if the mailbox is subscribed - reported by LSUB or by LIST RETURN (SUBSCRIBED) on LIST-EXTENDED/IMAP4rev2 servers. Servers that answer neither report no subscription state at all, and every mailbox is then assumed to be subscribed */
|
|
163
|
-
subscribed?: boolean;
|
|
169
|
+
subscribed?: boolean | undefined;
|
|
164
170
|
/** 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 */
|
|
165
|
-
permanentFlags?: Set<string
|
|
171
|
+
permanentFlags?: Set<string> | undefined;
|
|
166
172
|
/** Unique mailbox ID if server has OBJECTID extension enabled */
|
|
167
|
-
mailboxId?: string;
|
|
173
|
+
mailboxId?: string | undefined;
|
|
168
174
|
/** Latest known modseq value if server has CONDSTORE or XYMHIGHESTMODSEQ enabled */
|
|
169
|
-
highestModseq?: bigint;
|
|
175
|
+
highestModseq?: bigint | undefined;
|
|
170
176
|
/** If true then the server doesn't support the persistent storage of mod-sequences for the mailbox */
|
|
171
|
-
noModseq?: boolean;
|
|
177
|
+
noModseq?: boolean | undefined;
|
|
172
178
|
/** Mailbox UIDVALIDITY value */
|
|
173
179
|
uidValidity: bigint;
|
|
174
180
|
/** Next predicted UID */
|
|
@@ -176,36 +182,33 @@ export interface MailboxObject {
|
|
|
176
182
|
/** Messages in this folder */
|
|
177
183
|
exists: number;
|
|
178
184
|
/** Sequence number of the first unseen message, if the server reported [UNSEEN] on SELECT. Not a count of unseen messages - use mailboxStatus() with {unseen: true} for that */
|
|
179
|
-
unseen?: number;
|
|
185
|
+
unseen?: number | undefined;
|
|
180
186
|
/** Largest message size in octets the server accepts for APPEND into this mailbox, if it reported [APPENDLIMIT] (RFC 7889) */
|
|
181
|
-
appendlimit?: number;
|
|
187
|
+
appendlimit?: number | undefined;
|
|
182
188
|
/** Read-only state */
|
|
183
|
-
readOnly?: boolean;
|
|
189
|
+
readOnly?: boolean | undefined;
|
|
184
190
|
}
|
|
185
|
-
|
|
186
191
|
export interface MailboxLockObject {
|
|
187
192
|
/** Mailbox path */
|
|
188
193
|
path: string;
|
|
189
194
|
/** Release current lock */
|
|
190
195
|
release(): void;
|
|
191
196
|
}
|
|
192
|
-
|
|
193
197
|
export interface IdInfoObject {
|
|
194
198
|
/** Name of the program */
|
|
195
|
-
name?: string;
|
|
199
|
+
name?: string | false | undefined;
|
|
196
200
|
/** Version number of the program */
|
|
197
|
-
version?: string;
|
|
201
|
+
version?: string | false | undefined;
|
|
198
202
|
/** Name of the operating system */
|
|
199
|
-
os?: string;
|
|
203
|
+
os?: string | false | undefined;
|
|
200
204
|
/** Vendor of the client/server */
|
|
201
|
-
vendor?: string;
|
|
205
|
+
vendor?: string | false | undefined;
|
|
202
206
|
/** URL to contact for support */
|
|
203
|
-
'support-url'?: string;
|
|
207
|
+
'support-url'?: string | false | undefined;
|
|
204
208
|
/** Date program was released */
|
|
205
|
-
date?: Date;
|
|
209
|
+
date?: Date | string | false | undefined;
|
|
206
210
|
[key: string]: any;
|
|
207
211
|
}
|
|
208
|
-
|
|
209
212
|
export interface QuotaResponse {
|
|
210
213
|
/** Mailbox path this quota applies to */
|
|
211
214
|
path: string;
|
|
@@ -215,16 +218,52 @@ export interface QuotaResponse {
|
|
|
215
218
|
used: number;
|
|
216
219
|
/** Total storage available */
|
|
217
220
|
limit: number;
|
|
218
|
-
};
|
|
221
|
+
} | undefined;
|
|
219
222
|
/** Message count quota if provided by server */
|
|
220
223
|
messages?: {
|
|
221
224
|
/** Stored messages */
|
|
222
225
|
used: number;
|
|
223
226
|
/** Maximum messages allowed */
|
|
224
227
|
limit: number;
|
|
225
|
-
};
|
|
228
|
+
} | undefined;
|
|
229
|
+
[resource: string]: any;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Status data items to request with `status()` or the `statusQuery` listing option
|
|
233
|
+
*/
|
|
234
|
+
export interface StatusQuery {
|
|
235
|
+
/** If true request count of messages */
|
|
236
|
+
messages?: boolean | undefined;
|
|
237
|
+
/** If true request count of messages with \Recent tag */
|
|
238
|
+
recent?: boolean | undefined;
|
|
239
|
+
/** If true request predicted next UID */
|
|
240
|
+
uidNext?: boolean | undefined;
|
|
241
|
+
/** If true request mailbox UIDVALIDITY value */
|
|
242
|
+
uidValidity?: boolean | undefined;
|
|
243
|
+
/** If true request count of unseen messages */
|
|
244
|
+
unseen?: boolean | undefined;
|
|
245
|
+
/** If true request last known modseq value */
|
|
246
|
+
highestModseq?: boolean | undefined;
|
|
247
|
+
/** If true request total mailbox size in octets (requires STATUS=SIZE or IMAP4rev2) */
|
|
248
|
+
size?: boolean | undefined;
|
|
249
|
+
/** If true request count of messages with \Deleted flag (requires IMAP4rev2) */
|
|
250
|
+
deleted?: boolean | undefined;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Explicit special-use folder paths, overriding what the server reports
|
|
254
|
+
*/
|
|
255
|
+
export interface SpecialUseHints {
|
|
256
|
+
/** Path to "Sent Mail" folder */
|
|
257
|
+
sent?: string | undefined;
|
|
258
|
+
/** Path to "Trash" folder */
|
|
259
|
+
trash?: string | undefined;
|
|
260
|
+
/** Path to "Junk Mail" folder */
|
|
261
|
+
junk?: string | undefined;
|
|
262
|
+
/** Path to "Drafts" folder */
|
|
263
|
+
drafts?: string | undefined;
|
|
264
|
+
/** Path to "Archive" folder */
|
|
265
|
+
archive?: string | undefined;
|
|
226
266
|
}
|
|
227
|
-
|
|
228
267
|
export interface ListResponse {
|
|
229
268
|
/** Mailbox path (unicode string) */
|
|
230
269
|
path: string;
|
|
@@ -241,437 +280,444 @@ export interface ListResponse {
|
|
|
241
280
|
/** A set of flags for this mailbox */
|
|
242
281
|
flags: Set<string>;
|
|
243
282
|
/** One of special-use flags (if applicable) */
|
|
244
|
-
specialUse?: string;
|
|
283
|
+
specialUse?: string | undefined;
|
|
245
284
|
/** How specialUse was determined: "user" (from specialUseHints), "extension" (SPECIAL-USE or XLIST flag reported by the server) or "name" (matched against known localized folder names) */
|
|
246
|
-
specialUseSource?: 'user' | 'extension' | 'name';
|
|
285
|
+
specialUseSource?: 'user' | 'extension' | 'name' | undefined;
|
|
247
286
|
/** True if mailbox was found from the output of LIST command */
|
|
248
287
|
listed: boolean;
|
|
249
288
|
/** True if the mailbox is subscribed - reported by LSUB or by LIST RETURN (SUBSCRIBED) on LIST-EXTENDED/IMAP4rev2 servers. Servers that answer neither report no subscription state at all, and every mailbox is then assumed to be subscribed */
|
|
250
289
|
subscribed: boolean;
|
|
251
290
|
/** If statusQuery was used, then this value includes the status response */
|
|
252
|
-
status?: StatusObject;
|
|
291
|
+
status?: StatusObject | undefined;
|
|
253
292
|
}
|
|
254
|
-
|
|
255
293
|
export interface ListOptions {
|
|
256
294
|
/** Request status items for every listed entry */
|
|
257
|
-
statusQuery?:
|
|
258
|
-
/** If true request count of messages */
|
|
259
|
-
messages?: boolean;
|
|
260
|
-
/** If true request count of messages with \Recent tag */
|
|
261
|
-
recent?: boolean;
|
|
262
|
-
/** If true request predicted next UID */
|
|
263
|
-
uidNext?: boolean;
|
|
264
|
-
/** If true request mailbox UIDVALIDITY value */
|
|
265
|
-
uidValidity?: boolean;
|
|
266
|
-
/** If true request count of unseen messages */
|
|
267
|
-
unseen?: boolean;
|
|
268
|
-
/** If true request last known modseq value */
|
|
269
|
-
highestModseq?: boolean;
|
|
270
|
-
/** If true request total mailbox size in octets (requires STATUS=SIZE or IMAP4rev2) */
|
|
271
|
-
size?: boolean;
|
|
272
|
-
/** If true request count of messages with \Deleted flag (requires IMAP4rev2) */
|
|
273
|
-
deleted?: boolean;
|
|
274
|
-
};
|
|
295
|
+
statusQuery?: StatusQuery | undefined;
|
|
275
296
|
/** Set specific paths as special use folders */
|
|
276
|
-
specialUseHints?:
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
trash?: string;
|
|
281
|
-
/** Path to "Junk Mail" folder */
|
|
282
|
-
junk?: string;
|
|
283
|
-
/** Path to "Drafts" folder */
|
|
284
|
-
drafts?: string;
|
|
285
|
-
/** Path to "Archive" folder */
|
|
286
|
-
archive?: string;
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
297
|
+
specialUseHints?: SpecialUseHints | undefined;
|
|
298
|
+
/** If true then only runs LIST, without LSUB or subscription lookups */
|
|
299
|
+
listOnly?: boolean | undefined;
|
|
300
|
+
}
|
|
290
301
|
export interface ListTreeResponse {
|
|
291
302
|
/** If true then this is root node without any additional properties besides folders */
|
|
292
|
-
root?: boolean;
|
|
303
|
+
root?: boolean | undefined;
|
|
293
304
|
/** Mailbox path */
|
|
294
|
-
path?: string;
|
|
305
|
+
path?: string | undefined;
|
|
295
306
|
/** Mailbox name (last part of path after delimiter) */
|
|
296
|
-
name?: string;
|
|
307
|
+
name?: string | undefined;
|
|
297
308
|
/** Mailbox path delimiter, usually "." or "/" */
|
|
298
|
-
delimiter?: string;
|
|
309
|
+
delimiter?: string | undefined;
|
|
299
310
|
/** List of flags for this mailbox */
|
|
300
|
-
flags?: Set<string
|
|
311
|
+
flags?: Set<string> | undefined;
|
|
301
312
|
/** One of special-use flags (if applicable) */
|
|
302
|
-
specialUse?: string;
|
|
313
|
+
specialUse?: string | undefined;
|
|
303
314
|
/** True if mailbox was found from the output of LIST command */
|
|
304
|
-
listed?: boolean;
|
|
315
|
+
listed?: boolean | undefined;
|
|
305
316
|
/** True if the mailbox is subscribed - reported by LSUB or by LIST RETURN (SUBSCRIBED) on LIST-EXTENDED/IMAP4rev2 servers. Servers that answer neither report no subscription state at all, and every mailbox is then assumed to be subscribed */
|
|
306
|
-
subscribed?: boolean;
|
|
317
|
+
subscribed?: boolean | undefined;
|
|
307
318
|
/** If true then this mailbox can not be selected in the UI */
|
|
308
|
-
disabled?: boolean;
|
|
319
|
+
disabled?: boolean | undefined;
|
|
309
320
|
/** An array of subfolders */
|
|
310
|
-
folders?: ListTreeResponse[];
|
|
321
|
+
folders?: ListTreeResponse[] | undefined;
|
|
311
322
|
/** Status response */
|
|
312
|
-
status?: StatusObject;
|
|
323
|
+
status?: StatusObject | undefined;
|
|
313
324
|
}
|
|
314
|
-
|
|
315
325
|
export interface MailboxCreateResponse {
|
|
316
326
|
/** Full mailbox path */
|
|
317
327
|
path: string;
|
|
318
328
|
/** Unique mailbox ID if server supports OBJECTID extension */
|
|
319
|
-
mailboxId?: string;
|
|
329
|
+
mailboxId?: string | undefined;
|
|
320
330
|
/** If true then mailbox was created otherwise it already existed */
|
|
321
331
|
created: boolean;
|
|
322
332
|
}
|
|
323
|
-
|
|
324
333
|
export interface MailboxRenameResponse {
|
|
325
334
|
/** Full mailbox path that was renamed */
|
|
326
335
|
path: string;
|
|
327
336
|
/** New full mailbox path */
|
|
328
337
|
newPath: string;
|
|
329
338
|
}
|
|
330
|
-
|
|
331
339
|
export interface MailboxDeleteResponse {
|
|
332
340
|
/** Full mailbox path that was deleted */
|
|
333
341
|
path: string;
|
|
334
342
|
}
|
|
335
|
-
|
|
336
343
|
export interface StatusObject {
|
|
337
344
|
/** Full mailbox path that was checked */
|
|
338
345
|
path: string;
|
|
339
346
|
/** Count of messages */
|
|
340
|
-
messages?: number;
|
|
347
|
+
messages?: number | undefined;
|
|
341
348
|
/** Count of messages with \Recent tag */
|
|
342
|
-
recent?: number;
|
|
349
|
+
recent?: number | undefined;
|
|
343
350
|
/** Predicted next UID */
|
|
344
|
-
uidNext?: number;
|
|
351
|
+
uidNext?: number | undefined;
|
|
345
352
|
/** Mailbox UIDVALIDITY value */
|
|
346
|
-
uidValidity?: bigint;
|
|
353
|
+
uidValidity?: bigint | undefined;
|
|
347
354
|
/** Count of unseen messages */
|
|
348
|
-
unseen?: number;
|
|
355
|
+
unseen?: number | undefined;
|
|
349
356
|
/** Last known modseq value (if CONDSTORE extension is enabled) */
|
|
350
|
-
highestModseq?: bigint;
|
|
357
|
+
highestModseq?: bigint | undefined;
|
|
351
358
|
/** Total size of the mailbox in octets (only if requested and the server supports STATUS=SIZE or IMAP4rev2) */
|
|
352
|
-
size?: number;
|
|
359
|
+
size?: number | undefined;
|
|
353
360
|
/** Count of messages with \Deleted flag (only if requested and IMAP4rev2 is active) */
|
|
354
|
-
deleted?: number;
|
|
361
|
+
deleted?: number | undefined;
|
|
355
362
|
}
|
|
356
|
-
|
|
363
|
+
/**
|
|
364
|
+
* Sequence range string. Separate different values with commas, number ranges with colons and use "*" as the placeholder for the newest message in mailbox
|
|
365
|
+
*/
|
|
357
366
|
export type SequenceString = string | number | bigint;
|
|
358
|
-
|
|
359
367
|
export interface SearchObject {
|
|
360
368
|
/** Message ordering sequence range */
|
|
361
|
-
seq?: SequenceString;
|
|
369
|
+
seq?: SequenceString | undefined;
|
|
362
370
|
/** Messages with (value is true) or without (value is false) \Answered flag */
|
|
363
|
-
answered?: boolean;
|
|
371
|
+
answered?: boolean | undefined;
|
|
364
372
|
/** Messages with (value is true) or without (value is false) \Deleted flag */
|
|
365
|
-
deleted?: boolean;
|
|
373
|
+
deleted?: boolean | undefined;
|
|
366
374
|
/** Messages with (value is true) or without (value is false) \Draft flag */
|
|
367
|
-
draft?: boolean;
|
|
375
|
+
draft?: boolean | undefined;
|
|
368
376
|
/** Messages with (value is true) or without (value is false) \Flagged flag */
|
|
369
|
-
flagged?: boolean;
|
|
377
|
+
flagged?: boolean | undefined;
|
|
370
378
|
/** Messages with (value is true) or without (value is false) \Seen flag */
|
|
371
|
-
seen?: boolean;
|
|
379
|
+
seen?: boolean | undefined;
|
|
372
380
|
/** If true matches all messages */
|
|
373
|
-
all?: boolean;
|
|
381
|
+
all?: boolean | undefined;
|
|
374
382
|
/** If true matches messages that have the \Recent flag set but not the \Seen flag */
|
|
375
|
-
new?: boolean;
|
|
383
|
+
new?: boolean | undefined;
|
|
376
384
|
/** If true matches messages that do not have the \Recent flag set */
|
|
377
|
-
old?: boolean;
|
|
385
|
+
old?: boolean | undefined;
|
|
378
386
|
/** If true matches messages that have the \Recent flag set */
|
|
379
|
-
recent?: boolean;
|
|
387
|
+
recent?: boolean | undefined;
|
|
380
388
|
/** Matches From: address field */
|
|
381
|
-
from?: string;
|
|
389
|
+
from?: string | undefined;
|
|
382
390
|
/** Matches To: address field */
|
|
383
|
-
to?: string;
|
|
391
|
+
to?: string | undefined;
|
|
384
392
|
/** Matches Cc: address field */
|
|
385
|
-
cc?: string;
|
|
393
|
+
cc?: string | undefined;
|
|
386
394
|
/** Matches Bcc: address field */
|
|
387
|
-
bcc?: string;
|
|
395
|
+
bcc?: string | undefined;
|
|
388
396
|
/** Matches message body */
|
|
389
|
-
body?: string;
|
|
397
|
+
body?: string | undefined;
|
|
390
398
|
/** Matches message subject */
|
|
391
|
-
subject?: string;
|
|
399
|
+
subject?: string | undefined;
|
|
392
400
|
/** Matches any text in headers and body */
|
|
393
|
-
text?: string;
|
|
401
|
+
text?: string | undefined;
|
|
394
402
|
/** Matches messages larger than value */
|
|
395
|
-
larger?: number;
|
|
403
|
+
larger?: number | undefined;
|
|
396
404
|
/** Matches messages smaller than value */
|
|
397
|
-
smaller?: number;
|
|
405
|
+
smaller?: number | undefined;
|
|
398
406
|
/** UID sequence range */
|
|
399
|
-
uid?: SequenceString;
|
|
407
|
+
uid?: SequenceString | undefined;
|
|
400
408
|
/** Matches messages with modseq higher than value */
|
|
401
|
-
modseq?: bigint;
|
|
409
|
+
modseq?: bigint | number | undefined;
|
|
402
410
|
/** Unique email ID. Only used if server supports OBJECTID or X-GM-EXT-1 extensions */
|
|
403
|
-
emailId?: string;
|
|
411
|
+
emailId?: string | undefined;
|
|
404
412
|
/** Unique thread ID. Only used if server supports OBJECTID or X-GM-EXT-1 extensions */
|
|
405
|
-
threadId?: string;
|
|
413
|
+
threadId?: string | undefined;
|
|
406
414
|
/** Matches messages received before date */
|
|
407
|
-
before?: Date | string;
|
|
415
|
+
before?: Date | string | undefined;
|
|
408
416
|
/** Matches messages received on date (ignores time) */
|
|
409
|
-
on?: Date | string;
|
|
417
|
+
on?: Date | string | undefined;
|
|
410
418
|
/** Matches messages received after date */
|
|
411
|
-
since?: Date | string;
|
|
419
|
+
since?: Date | string | undefined;
|
|
412
420
|
/** Matches messages sent before date */
|
|
413
|
-
sentBefore?: Date | string;
|
|
421
|
+
sentBefore?: Date | string | undefined;
|
|
414
422
|
/** Matches messages sent on date (ignores time) */
|
|
415
|
-
sentOn?: Date | string;
|
|
423
|
+
sentOn?: Date | string | undefined;
|
|
416
424
|
/** Matches messages sent after date */
|
|
417
|
-
sentSince?: Date | string;
|
|
425
|
+
sentSince?: Date | string | undefined;
|
|
418
426
|
/** Matches messages that have the custom flag set */
|
|
419
|
-
keyword?: string;
|
|
427
|
+
keyword?: string | undefined;
|
|
420
428
|
/** Matches messages that do not have the custom flag set */
|
|
421
|
-
unKeyword?: string;
|
|
429
|
+
unKeyword?: string | undefined;
|
|
422
430
|
/** Matches messages with header key set if value is true or messages where header partially matches a string value */
|
|
423
|
-
header?: {
|
|
431
|
+
header?: {
|
|
432
|
+
[key: string]: boolean | string;
|
|
433
|
+
} | undefined;
|
|
424
434
|
/** A SearchObject object. It must not match */
|
|
425
|
-
not?: SearchObject;
|
|
435
|
+
not?: SearchObject | undefined;
|
|
426
436
|
/** An array of 2 or more SearchObject objects. At least one of these must match */
|
|
427
|
-
or?: SearchObject[];
|
|
437
|
+
or?: SearchObject[] | undefined;
|
|
428
438
|
/** Gmail raw search query (only for Gmail) */
|
|
429
|
-
gmraw?: string;
|
|
439
|
+
gmraw?: string | undefined;
|
|
430
440
|
/** Gmail raw search query (alias for gmraw) */
|
|
431
|
-
gmailraw?: string;
|
|
441
|
+
gmailraw?: string | undefined;
|
|
432
442
|
/** Gmail label filter (only for Gmail). Compiles to an X-GM-RAW "label:"/"-label:" query. "has" matches messages carrying all listed labels, "not" excludes messages carrying any listed label */
|
|
433
|
-
labels?: {
|
|
443
|
+
labels?: {
|
|
444
|
+
has?: string[] | undefined;
|
|
445
|
+
not?: string[] | undefined;
|
|
446
|
+
} | undefined;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* A message range: a sequence string, a list of sequence numbers or a search query
|
|
450
|
+
*/
|
|
451
|
+
export type MessageRange = SequenceString | number[] | SearchObject;
|
|
452
|
+
export interface FetchBodyPartQuery {
|
|
453
|
+
/** Body part identifier, for example "1.2" or "HEADER" */
|
|
454
|
+
key: string;
|
|
455
|
+
/** Start offset in bytes */
|
|
456
|
+
start?: number | undefined;
|
|
457
|
+
/** Maximum number of bytes to fetch */
|
|
458
|
+
maxLength?: number | undefined;
|
|
434
459
|
}
|
|
435
|
-
|
|
436
460
|
export interface FetchQueryObject {
|
|
437
461
|
/** If true then include UID in the response */
|
|
438
|
-
uid?: boolean;
|
|
462
|
+
uid?: boolean | undefined;
|
|
439
463
|
/** If true then include flags Set in the response */
|
|
440
|
-
flags?: boolean;
|
|
464
|
+
flags?: boolean | undefined;
|
|
441
465
|
/** If true then include parsed BODYSTRUCTURE object in the response */
|
|
442
|
-
bodyStructure?: boolean;
|
|
466
|
+
bodyStructure?: boolean | undefined;
|
|
443
467
|
/** If true then include parsed ENVELOPE object in the response */
|
|
444
|
-
envelope?: boolean;
|
|
468
|
+
envelope?: boolean | undefined;
|
|
445
469
|
/** If true then include internal date value in the response */
|
|
446
|
-
internalDate?: boolean;
|
|
470
|
+
internalDate?: boolean | undefined;
|
|
447
471
|
/** If true then include message size in the response */
|
|
448
|
-
size?: boolean;
|
|
472
|
+
size?: boolean | undefined;
|
|
449
473
|
/** If true then include full message in the response */
|
|
450
|
-
source?:
|
|
451
|
-
|
|
452
|
-
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
maxLength?: number;
|
|
457
|
-
};
|
|
474
|
+
source?: boolean | {
|
|
475
|
+
/** Include full message in the response starting from start byte */
|
|
476
|
+
start?: number | undefined;
|
|
477
|
+
/** Include full message in the response, up to maxLength bytes */
|
|
478
|
+
maxLength?: number | undefined;
|
|
479
|
+
} | undefined;
|
|
458
480
|
/** If true then include thread ID in the response (only if server supports either OBJECTID or X-GM-EXT-1 extensions) */
|
|
459
|
-
threadId?: boolean;
|
|
481
|
+
threadId?: boolean | undefined;
|
|
460
482
|
/** If true then include GMail labels in the response (only if server supports X-GM-EXT-1 extension) */
|
|
461
|
-
labels?: boolean;
|
|
483
|
+
labels?: boolean | undefined;
|
|
462
484
|
/** 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 */
|
|
463
|
-
headers?: boolean | string[];
|
|
485
|
+
headers?: boolean | string[] | undefined;
|
|
464
486
|
/** An array of BODYPART identifiers to include in the response */
|
|
465
|
-
bodyParts?: Array<string |
|
|
487
|
+
bodyParts?: Array<string | FetchBodyPartQuery> | undefined;
|
|
466
488
|
/** Fast macro equivalent to flags, internalDate, size */
|
|
467
|
-
fast?: boolean;
|
|
489
|
+
fast?: boolean | undefined;
|
|
468
490
|
/** All macro equivalent to flags, internalDate, size, envelope */
|
|
469
|
-
all?: boolean;
|
|
491
|
+
all?: boolean | undefined;
|
|
470
492
|
/** Full macro equivalent to flags, internalDate, size, envelope, bodyStructure */
|
|
471
|
-
full?: boolean;
|
|
493
|
+
full?: boolean | undefined;
|
|
472
494
|
}
|
|
473
|
-
|
|
474
495
|
export interface MessageAddressObject {
|
|
475
496
|
/** Name of the address object (unicode) */
|
|
476
|
-
name?: string;
|
|
497
|
+
name?: string | undefined;
|
|
477
498
|
/** Email address */
|
|
478
|
-
address?: string;
|
|
499
|
+
address?: string | undefined;
|
|
479
500
|
}
|
|
480
|
-
|
|
481
501
|
export interface MessageEnvelopeObject {
|
|
482
502
|
/** Header date */
|
|
483
|
-
date?: Date;
|
|
503
|
+
date?: Date | string | undefined;
|
|
484
504
|
/** Message subject (unicode) */
|
|
485
|
-
subject?: string;
|
|
505
|
+
subject?: string | undefined;
|
|
486
506
|
/** Message ID of the message */
|
|
487
|
-
messageId?: string;
|
|
507
|
+
messageId?: string | undefined;
|
|
488
508
|
/** Message ID from In-Reply-To header */
|
|
489
|
-
inReplyTo?: string;
|
|
509
|
+
inReplyTo?: string | undefined;
|
|
490
510
|
/** Array of addresses from the From: header */
|
|
491
|
-
from?: MessageAddressObject[];
|
|
511
|
+
from?: MessageAddressObject[] | undefined;
|
|
492
512
|
/** Array of addresses from the Sender: header */
|
|
493
|
-
sender?: MessageAddressObject[];
|
|
513
|
+
sender?: MessageAddressObject[] | undefined;
|
|
494
514
|
/** Array of addresses from the Reply-To: header */
|
|
495
|
-
replyTo?: MessageAddressObject[];
|
|
515
|
+
replyTo?: MessageAddressObject[] | undefined;
|
|
496
516
|
/** Array of addresses from the To: header */
|
|
497
|
-
to?: MessageAddressObject[];
|
|
517
|
+
to?: MessageAddressObject[] | undefined;
|
|
498
518
|
/** Array of addresses from the Cc: header */
|
|
499
|
-
cc?: MessageAddressObject[];
|
|
519
|
+
cc?: MessageAddressObject[] | undefined;
|
|
500
520
|
/** Array of addresses from the Bcc: header */
|
|
501
|
-
bcc?: MessageAddressObject[];
|
|
521
|
+
bcc?: MessageAddressObject[] | undefined;
|
|
502
522
|
}
|
|
503
|
-
|
|
504
523
|
export interface MessageStructureObject {
|
|
505
524
|
/** Body part number. This value can be used to later fetch the contents of this part of the message */
|
|
506
|
-
part?: string;
|
|
525
|
+
part?: string | undefined;
|
|
507
526
|
/** Content-Type of this node */
|
|
508
527
|
type: string;
|
|
509
528
|
/** Additional parameters for Content-Type, eg "charset" */
|
|
510
|
-
parameters?: {
|
|
529
|
+
parameters?: {
|
|
530
|
+
[key: string]: string;
|
|
531
|
+
} | undefined;
|
|
511
532
|
/** Content-ID */
|
|
512
|
-
id?: string;
|
|
533
|
+
id?: string | undefined;
|
|
513
534
|
/** Transfer encoding */
|
|
514
|
-
encoding?: string;
|
|
535
|
+
encoding?: string | undefined;
|
|
515
536
|
/** Expected size of the node */
|
|
516
|
-
size?: number;
|
|
537
|
+
size?: number | undefined;
|
|
517
538
|
/** Message envelope of embedded RFC822 message */
|
|
518
|
-
envelope?: MessageEnvelopeObject;
|
|
539
|
+
envelope?: MessageEnvelopeObject | undefined;
|
|
519
540
|
/** Content disposition */
|
|
520
|
-
disposition?: string;
|
|
541
|
+
disposition?: string | undefined;
|
|
521
542
|
/** Additional parameters for Content-Disposition */
|
|
522
|
-
dispositionParameters?: {
|
|
543
|
+
dispositionParameters?: {
|
|
544
|
+
[key: string]: string;
|
|
545
|
+
} | undefined;
|
|
523
546
|
/** An array of child nodes if this is a multipart node */
|
|
524
|
-
childNodes?: MessageStructureObject[];
|
|
547
|
+
childNodes?: MessageStructureObject[] | undefined;
|
|
525
548
|
/** MD5 hash */
|
|
526
|
-
md5?: string;
|
|
549
|
+
md5?: string | undefined;
|
|
527
550
|
/** Language */
|
|
528
|
-
language?: string[];
|
|
551
|
+
language?: string[] | undefined;
|
|
529
552
|
/** Location */
|
|
530
|
-
location?: string;
|
|
553
|
+
location?: string | undefined;
|
|
531
554
|
/** Description */
|
|
532
|
-
description?: string;
|
|
555
|
+
description?: string | undefined;
|
|
533
556
|
/** Line count */
|
|
534
|
-
lineCount?: number;
|
|
557
|
+
lineCount?: number | undefined;
|
|
535
558
|
}
|
|
536
|
-
|
|
537
559
|
export interface FetchMessageObject {
|
|
538
560
|
/** Message sequence number. Always included in the response */
|
|
539
561
|
seq: number;
|
|
540
562
|
/** Message UID number. Always included in the response */
|
|
541
563
|
uid: number;
|
|
542
564
|
/** Message source for the requested byte range */
|
|
543
|
-
source?: Buffer;
|
|
565
|
+
source?: Buffer | undefined;
|
|
544
566
|
/** Message Modseq number. Always included if the server supports CONDSTORE extension */
|
|
545
|
-
modseq?: bigint;
|
|
567
|
+
modseq?: bigint | undefined;
|
|
546
568
|
/** Unique email ID. Always included if server supports OBJECTID or X-GM-EXT-1 extensions */
|
|
547
|
-
emailId?: string;
|
|
569
|
+
emailId?: string | undefined;
|
|
548
570
|
/** Unique thread ID. Only present if server supports OBJECTID or X-GM-EXT-1 extension */
|
|
549
|
-
threadId?: string;
|
|
571
|
+
threadId?: string | undefined;
|
|
550
572
|
/** A Set of labels. Only present if server supports X-GM-EXT-1 extension */
|
|
551
|
-
labels?: Set<string
|
|
573
|
+
labels?: Set<string> | undefined;
|
|
552
574
|
/** Message size */
|
|
553
|
-
size?: number;
|
|
575
|
+
size?: number | undefined;
|
|
554
576
|
/** A set of message flags */
|
|
555
|
-
flags?: Set<string
|
|
577
|
+
flags?: Set<string> | undefined;
|
|
556
578
|
/** Flag color like "red", or "yellow". This value is derived from the flags Set */
|
|
557
|
-
flagColor?: string;
|
|
579
|
+
flagColor?: string | undefined;
|
|
558
580
|
/** Message envelope */
|
|
559
|
-
envelope?: MessageEnvelopeObject;
|
|
581
|
+
envelope?: MessageEnvelopeObject | undefined;
|
|
560
582
|
/** Message body structure */
|
|
561
|
-
bodyStructure?: MessageStructureObject;
|
|
583
|
+
bodyStructure?: MessageStructureObject | undefined;
|
|
562
584
|
/** Message internal date */
|
|
563
|
-
internalDate?: Date | string;
|
|
585
|
+
internalDate?: Date | string | undefined;
|
|
564
586
|
/** A Map of message body parts where key is requested part identifier and value is a Buffer */
|
|
565
|
-
bodyParts?: Map<string, Buffer
|
|
587
|
+
bodyParts?: Map<string, Buffer> | undefined;
|
|
566
588
|
/** Part identifiers from bodyParts that arrived via FETCH BINARY, i.e. with the content-transfer-encoding already decoded by the server */
|
|
567
|
-
binaryParts?: Set<string
|
|
589
|
+
binaryParts?: Set<string> | undefined;
|
|
568
590
|
/** Requested header lines as Buffer */
|
|
569
|
-
headers?: Buffer;
|
|
591
|
+
headers?: Buffer | undefined;
|
|
570
592
|
/** Account unique ID for this email */
|
|
571
|
-
id?: string;
|
|
593
|
+
id?: string | undefined;
|
|
594
|
+
}
|
|
595
|
+
export interface DownloadMeta {
|
|
596
|
+
/** The fetch response size */
|
|
597
|
+
expectedSize?: number | undefined;
|
|
598
|
+
/** Content-Type of the streamed file */
|
|
599
|
+
contentType?: string | undefined;
|
|
600
|
+
/** Charset of the body part */
|
|
601
|
+
charset?: string | undefined;
|
|
602
|
+
/** Content-Disposition of the streamed file */
|
|
603
|
+
disposition?: string | false | undefined;
|
|
604
|
+
/** Filename of the streamed body part */
|
|
605
|
+
filename?: string | undefined;
|
|
606
|
+
/** Transfer encoding */
|
|
607
|
+
encoding?: string | undefined;
|
|
608
|
+
/** If content uses flowed formatting */
|
|
609
|
+
flowed?: boolean | undefined;
|
|
610
|
+
/** If flowed text uses delSp */
|
|
611
|
+
delSp?: boolean | undefined;
|
|
572
612
|
}
|
|
573
|
-
|
|
574
613
|
export interface DownloadObject {
|
|
575
614
|
/** Content metadata */
|
|
576
|
-
meta:
|
|
577
|
-
/** The fetch response size */
|
|
578
|
-
expectedSize: number;
|
|
579
|
-
/** Content-Type of the streamed file */
|
|
580
|
-
contentType: string;
|
|
581
|
-
/** Charset of the body part */
|
|
582
|
-
charset?: string;
|
|
583
|
-
/** Content-Disposition of the streamed file */
|
|
584
|
-
disposition?: string;
|
|
585
|
-
/** Filename of the streamed body part */
|
|
586
|
-
filename?: string;
|
|
587
|
-
/** Transfer encoding */
|
|
588
|
-
encoding?: string;
|
|
589
|
-
/** If content uses flowed formatting */
|
|
590
|
-
flowed?: boolean;
|
|
591
|
-
/** If flowed text uses delSp */
|
|
592
|
-
delSp?: boolean;
|
|
593
|
-
};
|
|
615
|
+
meta: DownloadMeta;
|
|
594
616
|
/** Streamed content */
|
|
595
617
|
content: Readable;
|
|
596
618
|
}
|
|
597
|
-
|
|
619
|
+
export interface DownloadOptions {
|
|
620
|
+
/** If true then uses UID number instead of sequence number for `range` */
|
|
621
|
+
uid?: boolean | undefined;
|
|
622
|
+
/** If set then limits download size to specified bytes */
|
|
623
|
+
maxBytes?: number | undefined;
|
|
624
|
+
/** How large content parts to ask from the server. Defaults to 65536 */
|
|
625
|
+
chunkSize?: number | undefined;
|
|
626
|
+
}
|
|
627
|
+
/** Options for downloadMany(), the same shape as the download() options */
|
|
628
|
+
export type DownloadManyOptions = DownloadOptions;
|
|
629
|
+
export interface DownloadManyPart {
|
|
630
|
+
meta: DownloadMeta;
|
|
631
|
+
content?: Buffer | null | undefined;
|
|
632
|
+
}
|
|
633
|
+
export type DownloadManyResult = {
|
|
634
|
+
[part: string]: DownloadManyPart;
|
|
635
|
+
};
|
|
598
636
|
export interface AppendResponseObject {
|
|
599
637
|
/** Full mailbox path where the message was uploaded to */
|
|
600
638
|
destination: string;
|
|
601
639
|
/** Mailbox UIDVALIDITY if server has UIDPLUS extension enabled */
|
|
602
|
-
uidValidity?: bigint;
|
|
640
|
+
uidValidity?: bigint | undefined;
|
|
603
641
|
/** UID of the uploaded message if server has UIDPLUS extension enabled */
|
|
604
|
-
uid?: number;
|
|
642
|
+
uid?: number | undefined;
|
|
605
643
|
/** Sequence number of the uploaded message if path is currently selected mailbox */
|
|
606
|
-
seq?: number;
|
|
644
|
+
seq?: number | undefined;
|
|
607
645
|
}
|
|
608
|
-
|
|
609
646
|
export interface CopyResponseObject {
|
|
610
647
|
/** Path of source mailbox */
|
|
611
648
|
path: string;
|
|
612
649
|
/** Path of destination mailbox */
|
|
613
650
|
destination: string;
|
|
614
651
|
/** Destination mailbox UIDVALIDITY if server has UIDPLUS extension enabled */
|
|
615
|
-
uidValidity?: bigint;
|
|
652
|
+
uidValidity?: bigint | undefined;
|
|
616
653
|
/** Map of UID values where key is UID in source mailbox and value is the UID for the same message in destination mailbox */
|
|
617
|
-
uidMap?: Map<number, number
|
|
654
|
+
uidMap?: Map<number, number> | undefined;
|
|
618
655
|
}
|
|
619
|
-
|
|
620
656
|
export interface FetchOptions {
|
|
621
657
|
/** If true then uses UID numbers instead of sequence numbers */
|
|
622
|
-
uid?: boolean;
|
|
658
|
+
uid?: boolean | undefined;
|
|
623
659
|
/** If set then only messages with a higher modseq value are returned */
|
|
624
|
-
changedSince?: bigint;
|
|
660
|
+
changedSince?: bigint | number | undefined;
|
|
625
661
|
/** If true then requests a binary response if the server supports this */
|
|
626
|
-
binary?: boolean;
|
|
662
|
+
binary?: boolean | undefined;
|
|
627
663
|
}
|
|
628
|
-
|
|
629
664
|
export interface StoreOptions {
|
|
630
665
|
/** If true then uses UID numbers instead of sequence numbers */
|
|
631
|
-
uid?: boolean;
|
|
666
|
+
uid?: boolean | undefined;
|
|
632
667
|
/** If set then only messages with a lower or equal modseq value are updated */
|
|
633
|
-
unchangedSince?: bigint;
|
|
668
|
+
unchangedSince?: bigint | number | undefined;
|
|
634
669
|
/** If true then update Gmail labels instead of message flags */
|
|
635
|
-
useLabels?: boolean;
|
|
670
|
+
useLabels?: boolean | undefined;
|
|
636
671
|
/** If true then does not emit 'flags' event */
|
|
637
|
-
silent?: boolean;
|
|
672
|
+
silent?: boolean | undefined;
|
|
638
673
|
}
|
|
639
|
-
|
|
640
674
|
export interface MailboxOpenOptions {
|
|
641
675
|
/** If true then opens mailbox in read-only mode */
|
|
642
|
-
readOnly?: boolean;
|
|
676
|
+
readOnly?: boolean | undefined;
|
|
643
677
|
/** Optional description for mailbox lock tracking */
|
|
644
|
-
description?: string;
|
|
678
|
+
description?: string | undefined;
|
|
645
679
|
}
|
|
646
|
-
|
|
647
680
|
export interface MailboxLockOptions extends MailboxOpenOptions {
|
|
648
681
|
/**
|
|
649
682
|
* Optional timeout in milliseconds to wait for the lock to be granted.
|
|
650
683
|
* If the lock cannot be acquired within this time, the promise rejects
|
|
651
684
|
* with an error whose `code` is `'LockTimeout'`. Defaults to no timeout.
|
|
652
685
|
*/
|
|
653
|
-
acquireTimeout?: number;
|
|
686
|
+
acquireTimeout?: number | undefined;
|
|
654
687
|
/**
|
|
655
688
|
* Per-call override for the threshold after which a held lock triggers
|
|
656
689
|
* a warning log entry. Overrides the ImapFlow constructor option of the
|
|
657
690
|
* same name. Set to 0 or false to disable for this lock only.
|
|
658
691
|
*/
|
|
659
|
-
maxLockHoldTime?: number | false;
|
|
692
|
+
maxLockHoldTime?: number | false | undefined;
|
|
693
|
+
}
|
|
694
|
+
/** Options for messageCopy(), messageMove() and messageDelete() */
|
|
695
|
+
export interface MessageRangeOptions {
|
|
696
|
+
/** If true then uses UID numbers instead of sequence numbers */
|
|
697
|
+
uid?: boolean | undefined;
|
|
698
|
+
}
|
|
699
|
+
/** A RETURN option for ESEARCH (RFC 4731) and PARTIAL (RFC 9394) searches */
|
|
700
|
+
export type SearchReturnOption = 'MIN' | 'MAX' | 'COUNT' | 'ALL' | 'min' | 'max' | 'count' | 'all' | {
|
|
701
|
+
partial: string;
|
|
702
|
+
};
|
|
703
|
+
export interface SearchOptions {
|
|
704
|
+
/** If true then returns UID numbers instead of sequence numbers */
|
|
705
|
+
uid?: boolean | undefined;
|
|
706
|
+
/** ESEARCH RETURN options. When set, the result is an ESearchResult object */
|
|
707
|
+
returnOptions?: SearchReturnOption[] | undefined;
|
|
660
708
|
}
|
|
661
|
-
|
|
662
709
|
export interface ExpungeEvent {
|
|
663
710
|
/** Mailbox path */
|
|
664
711
|
path: string;
|
|
665
712
|
/** Sequence number (if vanished is false) */
|
|
666
|
-
seq?: number;
|
|
713
|
+
seq?: number | undefined;
|
|
667
714
|
/** UID number (if vanished is true or QRESYNC is enabled) */
|
|
668
|
-
uid?: number;
|
|
715
|
+
uid?: number | undefined;
|
|
669
716
|
/** True if message was expunged using VANISHED response */
|
|
670
717
|
vanished: boolean;
|
|
671
718
|
/** True if VANISHED EARLIER response */
|
|
672
|
-
earlier?: boolean;
|
|
719
|
+
earlier?: boolean | undefined;
|
|
673
720
|
}
|
|
674
|
-
|
|
675
721
|
export interface ExistsEvent {
|
|
676
722
|
/** Mailbox path */
|
|
677
723
|
path: string;
|
|
@@ -680,25 +726,31 @@ export interface ExistsEvent {
|
|
|
680
726
|
/** Message count before this update */
|
|
681
727
|
prevCount: number;
|
|
682
728
|
}
|
|
683
|
-
|
|
684
729
|
export interface FlagsEvent {
|
|
685
730
|
/** Mailbox path */
|
|
686
731
|
path: string;
|
|
687
732
|
/** Sequence number of updated message */
|
|
688
733
|
seq: number;
|
|
689
734
|
/** UID number of updated message (if server provided this value) */
|
|
690
|
-
uid?: number;
|
|
735
|
+
uid?: number | undefined;
|
|
691
736
|
/** Updated modseq number for the mailbox */
|
|
692
|
-
modseq?: bigint;
|
|
737
|
+
modseq?: bigint | undefined;
|
|
693
738
|
/** A set of all flags for the updated message */
|
|
694
739
|
flags: Set<string>;
|
|
695
740
|
/** Flag color if message is flagged */
|
|
696
|
-
flagColor?: string;
|
|
697
|
-
}
|
|
698
|
-
|
|
741
|
+
flagColor?: string | undefined;
|
|
742
|
+
}
|
|
743
|
+
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
744
|
+
/**
|
|
745
|
+
* The logger a connection uses internally: every level is always callable, whatever the
|
|
746
|
+
* configured logger supports, and entries are mirrored as 'log' events when `emitLogs` is set
|
|
747
|
+
*/
|
|
748
|
+
export type InternalLogger = {
|
|
749
|
+
[level in LogLevel]: (obj: any) => void;
|
|
750
|
+
};
|
|
699
751
|
export interface LogEvent {
|
|
700
752
|
/** Log level */
|
|
701
|
-
level:
|
|
753
|
+
level: LogLevel;
|
|
702
754
|
/** Timestamp */
|
|
703
755
|
t: number;
|
|
704
756
|
/** Connection ID */
|
|
@@ -708,251 +760,69 @@ export interface LogEvent {
|
|
|
708
760
|
/** Additional log data */
|
|
709
761
|
[key: string]: any;
|
|
710
762
|
}
|
|
711
|
-
|
|
712
763
|
export interface ResponseEvent {
|
|
713
764
|
/** Response type */
|
|
714
765
|
response: string;
|
|
715
766
|
/** Response code */
|
|
716
|
-
code?: string;
|
|
767
|
+
code?: string | undefined;
|
|
717
768
|
}
|
|
718
|
-
|
|
719
769
|
/** Result object returned by ESEARCH (RFC 4731) when returnOptions is specified */
|
|
720
770
|
export interface ESearchResult {
|
|
721
771
|
/** Total number of matching messages */
|
|
722
|
-
count?: number;
|
|
772
|
+
count?: number | undefined;
|
|
723
773
|
/** Lowest matching UID */
|
|
724
|
-
min?: number;
|
|
774
|
+
min?: number | undefined;
|
|
725
775
|
/** Highest matching UID */
|
|
726
|
-
max?: number;
|
|
776
|
+
max?: number | undefined;
|
|
727
777
|
/** All matching UIDs as compact sequence-set string (e.g. "1,5:10,20") */
|
|
728
|
-
all?: string;
|
|
778
|
+
all?: string | undefined;
|
|
729
779
|
/** Paged subset (RFC 9394 PARTIAL) */
|
|
730
780
|
partial?: {
|
|
731
781
|
/** The requested range, e.g. "1:100" */
|
|
732
782
|
range: string;
|
|
733
783
|
/** Matching UIDs in that range as compact sequence-set */
|
|
734
784
|
messages: string;
|
|
735
|
-
};
|
|
785
|
+
} | undefined;
|
|
736
786
|
/** Highest mod-sequence of the matching messages (RFC 7162, present when the search used a modseq criterion on a CONDSTORE session) */
|
|
737
|
-
modseq?: bigint;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
export
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
export
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
/** Active IMAP capabilities */
|
|
761
|
-
capabilities: Map<string, boolean | number>;
|
|
762
|
-
|
|
763
|
-
/** Enabled capabilities */
|
|
764
|
-
enabled: Set<string>;
|
|
765
|
-
|
|
766
|
-
/** Is the connection currently usable or not */
|
|
767
|
-
usable: boolean;
|
|
768
|
-
|
|
769
|
-
/** Currently authenticated user */
|
|
770
|
-
authenticated: string | boolean;
|
|
771
|
-
|
|
772
|
-
/** Currently selected mailbox */
|
|
773
|
-
mailbox: MailboxObject | false;
|
|
774
|
-
|
|
775
|
-
/** Is current mailbox idling */
|
|
776
|
-
idling: boolean;
|
|
777
|
-
|
|
778
|
-
constructor(options: ImapFlowOptions);
|
|
779
|
-
|
|
780
|
-
/** Initiates a connection against IMAP server */
|
|
781
|
-
connect(): Promise<void>;
|
|
782
|
-
|
|
783
|
-
/** Graceful connection close by sending logout command to server */
|
|
784
|
-
logout(): Promise<void>;
|
|
785
|
-
|
|
786
|
-
/** Closes TCP connection without notifying the server */
|
|
787
|
-
close(): void;
|
|
788
|
-
|
|
789
|
-
/** Returns current quota */
|
|
790
|
-
getQuota(path?: string | string[]): Promise<QuotaResponse | false>;
|
|
791
|
-
|
|
792
|
-
/** Lists available mailboxes as an Array */
|
|
793
|
-
list(options?: ListOptions): Promise<ListResponse[]>;
|
|
794
|
-
|
|
795
|
-
/** Lists available mailboxes as a tree structured object */
|
|
796
|
-
listTree(options?: ListOptions): Promise<ListTreeResponse>;
|
|
797
|
-
|
|
798
|
-
/** Performs a no-op call against server */
|
|
799
|
-
noop(): Promise<void>;
|
|
800
|
-
|
|
801
|
-
/** Creates a new mailbox folder */
|
|
802
|
-
mailboxCreate(path: string | string[]): Promise<MailboxCreateResponse>;
|
|
803
|
-
|
|
804
|
-
/** Renames a mailbox */
|
|
805
|
-
mailboxRename(path: string | string[], newPath: string | string[]): Promise<MailboxRenameResponse>;
|
|
806
|
-
|
|
807
|
-
/** Deletes a mailbox */
|
|
808
|
-
mailboxDelete(path: string | string[]): Promise<MailboxDeleteResponse>;
|
|
809
|
-
|
|
810
|
-
/** Subscribes to a mailbox */
|
|
811
|
-
mailboxSubscribe(path: string | string[]): Promise<boolean>;
|
|
812
|
-
|
|
813
|
-
/** Unsubscribes from a mailbox */
|
|
814
|
-
mailboxUnsubscribe(path: string | string[]): Promise<boolean>;
|
|
815
|
-
|
|
816
|
-
/** Opens a mailbox to access messages */
|
|
817
|
-
mailboxOpen(path: string | string[], options?: MailboxOpenOptions): Promise<MailboxObject>;
|
|
818
|
-
|
|
819
|
-
/** Closes a previously opened mailbox */
|
|
820
|
-
mailboxClose(): Promise<boolean>;
|
|
821
|
-
|
|
822
|
-
/** Requests the status of the indicated mailbox */
|
|
823
|
-
status(
|
|
824
|
-
path: string | string[],
|
|
825
|
-
query: {
|
|
826
|
-
messages?: boolean;
|
|
827
|
-
recent?: boolean;
|
|
828
|
-
uidNext?: boolean;
|
|
829
|
-
uidValidity?: boolean;
|
|
830
|
-
unseen?: boolean;
|
|
831
|
-
highestModseq?: boolean;
|
|
832
|
-
/** Requires STATUS=SIZE or IMAP4rev2 */
|
|
833
|
-
size?: boolean;
|
|
834
|
-
/** Requires IMAP4rev2 */
|
|
835
|
-
deleted?: boolean;
|
|
836
|
-
}
|
|
837
|
-
): Promise<StatusObject>;
|
|
838
|
-
|
|
839
|
-
/** Starts listening for new or deleted messages from the currently opened mailbox */
|
|
840
|
-
idle(): Promise<boolean>;
|
|
841
|
-
|
|
842
|
-
/** Sets flags for a message or message range */
|
|
843
|
-
messageFlagsSet(range: SequenceString | number[] | SearchObject, flags: string[], options?: StoreOptions): Promise<boolean>;
|
|
844
|
-
|
|
845
|
-
/** Adds flags for a message or message range */
|
|
846
|
-
messageFlagsAdd(range: SequenceString | number[] | SearchObject, flags: string[], options?: StoreOptions): Promise<boolean>;
|
|
847
|
-
|
|
848
|
-
/** Remove specific flags from a message or message range */
|
|
849
|
-
messageFlagsRemove(range: SequenceString | number[] | SearchObject, flags: string[], options?: StoreOptions): Promise<boolean>;
|
|
850
|
-
|
|
851
|
-
/** Sets a colored flag for an email */
|
|
852
|
-
setFlagColor(range: SequenceString | number[] | SearchObject, color: string, options?: StoreOptions): Promise<boolean>;
|
|
853
|
-
|
|
854
|
-
/** Delete messages from the currently opened mailbox */
|
|
855
|
-
messageDelete(range: SequenceString | number[] | SearchObject, options?: { uid?: boolean }): Promise<boolean>;
|
|
856
|
-
|
|
857
|
-
/** Appends a new message to a mailbox */
|
|
858
|
-
append(path: string | string[], content: string | Buffer, flags?: string[], idate?: Date | string): Promise<AppendResponseObject | false>;
|
|
859
|
-
|
|
860
|
-
/** Copies messages from current mailbox to destination mailbox */
|
|
861
|
-
messageCopy(
|
|
862
|
-
range: SequenceString | number[] | SearchObject,
|
|
863
|
-
destination: string | string[],
|
|
864
|
-
options?: { uid?: boolean }
|
|
865
|
-
): Promise<CopyResponseObject | false>;
|
|
866
|
-
|
|
867
|
-
/** Moves messages from current mailbox to destination mailbox */
|
|
868
|
-
messageMove(
|
|
869
|
-
range: SequenceString | number[] | SearchObject,
|
|
870
|
-
destination: string | string[],
|
|
871
|
-
options?: { uid?: boolean }
|
|
872
|
-
): Promise<CopyResponseObject | false>;
|
|
873
|
-
|
|
874
|
-
/** Search messages from the currently opened mailbox — returns number[] (backward-compatible) */
|
|
875
|
-
search(query: SearchObject, options?: { uid?: boolean }): Promise<number[] | false>;
|
|
876
|
-
/** Search messages with ESEARCH RETURN options — returns ESearchResult */
|
|
877
|
-
search(
|
|
878
|
-
query: SearchObject,
|
|
879
|
-
options: {
|
|
880
|
-
uid?: boolean;
|
|
881
|
-
returnOptions: Array<'MIN' | 'MAX' | 'COUNT' | 'ALL' | { partial: string }>;
|
|
882
|
-
}
|
|
883
|
-
): Promise<ESearchResult | number[] | false>;
|
|
884
|
-
|
|
885
|
-
/** Fetch messages from the currently opened mailbox */
|
|
886
|
-
fetch(range: SequenceString | number[] | SearchObject, query: FetchQueryObject, options?: FetchOptions): AsyncIterableIterator<FetchMessageObject>;
|
|
887
|
-
|
|
888
|
-
/** Fetch all messages from the currently opened mailbox */
|
|
889
|
-
fetchAll(range: SequenceString | number[] | SearchObject, query: FetchQueryObject, options?: FetchOptions): Promise<FetchMessageObject[]>;
|
|
890
|
-
|
|
891
|
-
/** Fetch a single message from the currently opened mailbox */
|
|
892
|
-
fetchOne(seq: SequenceString, query: FetchQueryObject, options?: FetchOptions): Promise<FetchMessageObject | false>;
|
|
893
|
-
|
|
894
|
-
/** Download either full rfc822 formatted message or a specific bodystructure part as a Stream */
|
|
895
|
-
download(
|
|
896
|
-
range: SequenceString,
|
|
897
|
-
part?: string,
|
|
898
|
-
options?: {
|
|
899
|
-
uid?: boolean;
|
|
900
|
-
maxBytes?: number;
|
|
901
|
-
chunkSize?: number;
|
|
902
|
-
}
|
|
903
|
-
): Promise<DownloadObject>;
|
|
904
|
-
|
|
905
|
-
/** Fetch multiple attachments as Buffer values */
|
|
906
|
-
downloadMany(
|
|
907
|
-
range: SequenceString,
|
|
908
|
-
parts: string[],
|
|
909
|
-
options?: { uid?: boolean }
|
|
910
|
-
): Promise<{
|
|
911
|
-
[part: string]: {
|
|
912
|
-
meta: {
|
|
913
|
-
contentType?: string;
|
|
914
|
-
charset?: string;
|
|
915
|
-
disposition?: string;
|
|
916
|
-
filename?: string;
|
|
917
|
-
encoding?: string;
|
|
918
|
-
};
|
|
919
|
-
content: Buffer | null;
|
|
920
|
-
};
|
|
921
|
-
}>;
|
|
922
|
-
|
|
923
|
-
/** Opens a mailbox if not already open and returns a lock */
|
|
924
|
-
getMailboxLock(path: string | string[], options?: MailboxLockOptions): Promise<MailboxLockObject>;
|
|
925
|
-
|
|
926
|
-
/** Returns byte counters for the current connection, optionally resets them */
|
|
927
|
-
stats(reset?: boolean): { sent: number; received: number };
|
|
928
|
-
|
|
929
|
-
/** Detaches sockets from the IMAP pipeline, returns read and write sockets */
|
|
930
|
-
unbind(): { readSocket: any; writeSocket: any };
|
|
931
|
-
|
|
787
|
+
modseq?: bigint | undefined;
|
|
788
|
+
}
|
|
789
|
+
/** A single IMAP namespace entry as reported by the NAMESPACE command */
|
|
790
|
+
export interface NamespaceObject {
|
|
791
|
+
/** Namespace prefix */
|
|
792
|
+
prefix: string;
|
|
793
|
+
/** Hierarchy delimiter. `null` when the server reported NIL (a flat namespace, RFC 2342 section 5), `undefined` when the LIST fallback could not determine it */
|
|
794
|
+
delimiter: string | null | undefined;
|
|
795
|
+
}
|
|
796
|
+
/** Namespaces reported by the server, grouped by type. `other` and `shared` are `false` when the server reported none */
|
|
797
|
+
export interface NamespacesObject {
|
|
798
|
+
personal: NamespaceObject[];
|
|
799
|
+
other: NamespaceObject[] | false;
|
|
800
|
+
shared: NamespaceObject[] | false;
|
|
801
|
+
}
|
|
802
|
+
/** Negotiated TLS session details, from `tls.TLSSocket#getCipher()` plus the authorization state */
|
|
803
|
+
export interface TlsInfo extends CipherNameAndProtocol {
|
|
804
|
+
authorized?: boolean | undefined;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Events emitted by an ImapFlow client
|
|
808
|
+
*/
|
|
809
|
+
export interface ImapFlowEvents {
|
|
932
810
|
/** Connection close event */
|
|
933
|
-
|
|
934
|
-
|
|
811
|
+
close: [];
|
|
935
812
|
/** Error event */
|
|
936
|
-
|
|
937
|
-
|
|
813
|
+
error: [error: Error];
|
|
938
814
|
/** Message count in currently opened mailbox changed */
|
|
939
|
-
|
|
940
|
-
|
|
815
|
+
exists: [data: ExistsEvent];
|
|
941
816
|
/** Deleted message sequence number in currently opened mailbox */
|
|
942
|
-
|
|
943
|
-
|
|
817
|
+
expunge: [data: ExpungeEvent];
|
|
944
818
|
/** Flags were updated for a message */
|
|
945
|
-
|
|
946
|
-
|
|
819
|
+
flags: [data: FlagsEvent];
|
|
947
820
|
/** Mailbox was opened */
|
|
948
|
-
|
|
949
|
-
|
|
821
|
+
mailboxOpen: [mailbox: MailboxObject];
|
|
950
822
|
/** Mailbox was closed, either explicitly or because the connection went away while a mailbox was still selected */
|
|
951
|
-
|
|
952
|
-
|
|
823
|
+
mailboxClose: [mailbox: MailboxObject];
|
|
953
824
|
/** Log event if emitLogs=true */
|
|
954
|
-
|
|
955
|
-
|
|
825
|
+
log: [entry: LogEvent];
|
|
956
826
|
/** Response event */
|
|
957
|
-
|
|
827
|
+
response: [response: ResponseEvent];
|
|
958
828
|
}
|