imapkit 4.0.3 → 4.1.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/README.md +32 -19
- package/bin/imapkit.js +12 -16
- package/dist/cjs/addressparser.d.ts +21 -0
- package/dist/cjs/addressparser.js +277 -0
- package/dist/cjs/arguments.d.ts +31 -0
- package/{lib → dist/cjs}/arguments.js +9 -21
- package/dist/cjs/bodystructure.d.ts +25 -0
- package/dist/cjs/bodystructure.js +150 -0
- package/dist/cjs/cert.d.ts +2 -0
- package/dist/cjs/cert.js +7 -0
- package/dist/cjs/command-states.d.ts +36 -0
- package/dist/cjs/command-states.js +102 -0
- package/dist/cjs/commands/append.d.ts +88 -0
- package/dist/cjs/commands/append.js +299 -0
- package/dist/cjs/commands/capability.d.ts +2 -0
- package/dist/cjs/commands/capability.js +44 -0
- package/dist/cjs/commands/check.d.ts +2 -0
- package/dist/cjs/commands/check.js +28 -0
- package/dist/cjs/commands/close.d.ts +2 -0
- package/dist/cjs/commands/close.js +35 -0
- package/dist/cjs/commands/copy.d.ts +30 -0
- package/dist/cjs/commands/copy.js +107 -0
- package/dist/cjs/commands/create.d.ts +2 -0
- package/dist/cjs/commands/create.js +53 -0
- package/dist/cjs/commands/delete.d.ts +2 -0
- package/dist/cjs/commands/delete.js +63 -0
- package/dist/cjs/commands/examine.d.ts +2 -0
- package/dist/cjs/commands/examine.js +19 -0
- package/dist/cjs/commands/expunge.d.ts +2 -0
- package/dist/cjs/commands/expunge.js +32 -0
- package/dist/cjs/commands/fetch.d.ts +23 -0
- package/dist/cjs/commands/fetch.js +208 -0
- package/dist/cjs/commands/handlers/fetch.d.ts +12 -0
- package/dist/cjs/commands/handlers/fetch.js +195 -0
- package/dist/cjs/commands/handlers/flags.d.ts +17 -0
- package/dist/cjs/commands/handlers/flags.js +39 -0
- package/dist/cjs/commands/handlers/search.d.ts +85 -0
- package/dist/cjs/commands/handlers/search.js +504 -0
- package/dist/cjs/commands/handlers/status.d.ts +34 -0
- package/dist/cjs/commands/handlers/status.js +81 -0
- package/dist/cjs/commands/handlers/store.d.ts +3 -0
- package/dist/cjs/commands/handlers/store.js +117 -0
- package/dist/cjs/commands/index.d.ts +2 -0
- package/dist/cjs/commands/index.js +61 -0
- package/dist/cjs/commands/list.d.ts +2 -0
- package/dist/cjs/commands/list.js +86 -0
- package/dist/cjs/commands/login.d.ts +2 -0
- package/dist/cjs/commands/login.js +62 -0
- package/dist/cjs/commands/logout.d.ts +2 -0
- package/dist/cjs/commands/logout.js +40 -0
- package/dist/cjs/commands/lsub.d.ts +2 -0
- package/dist/cjs/commands/lsub.js +79 -0
- package/dist/cjs/commands/noop.d.ts +2 -0
- package/dist/cjs/commands/noop.js +28 -0
- package/dist/cjs/commands/rename.d.ts +2 -0
- package/dist/cjs/commands/rename.js +98 -0
- package/dist/cjs/commands/search.d.ts +10 -0
- package/dist/cjs/commands/search.js +71 -0
- package/dist/cjs/commands/select.d.ts +19 -0
- package/dist/cjs/commands/select.js +230 -0
- package/dist/cjs/commands/status.d.ts +2 -0
- package/dist/cjs/commands/status.js +57 -0
- package/dist/cjs/commands/store.d.ts +10 -0
- package/dist/cjs/commands/store.js +134 -0
- package/dist/cjs/commands/subscribe.d.ts +2 -0
- package/dist/cjs/commands/subscribe.js +51 -0
- package/dist/cjs/commands/uid-copy.d.ts +2 -0
- package/dist/cjs/commands/uid-copy.js +19 -0
- package/dist/cjs/commands/uid-fetch.d.ts +3 -0
- package/dist/cjs/commands/uid-fetch.js +17 -0
- package/dist/cjs/commands/uid-search.d.ts +3 -0
- package/dist/cjs/commands/uid-search.js +17 -0
- package/dist/cjs/commands/uid-store.d.ts +3 -0
- package/dist/cjs/commands/uid-store.js +17 -0
- package/dist/cjs/commands/unsubscribe.d.ts +2 -0
- package/dist/cjs/commands/unsubscribe.js +50 -0
- package/dist/cjs/dates.d.ts +64 -0
- package/dist/cjs/dates.js +124 -0
- package/dist/cjs/deflate-layer.d.ts +83 -0
- package/dist/cjs/deflate-layer.js +232 -0
- package/dist/cjs/encoded-words.d.ts +15 -0
- package/dist/cjs/encoded-words.js +85 -0
- package/dist/cjs/envelope.d.ts +33 -0
- package/dist/cjs/envelope.js +86 -0
- package/dist/cjs/esearch.d.ts +96 -0
- package/dist/cjs/esearch.js +190 -0
- package/dist/cjs/framing.d.ts +66 -0
- package/{lib → dist/cjs}/framing.js +9 -26
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/list-extensions.d.ts +50 -0
- package/dist/cjs/list-extensions.js +35 -0
- package/dist/cjs/load-plugins.d.ts +21 -0
- package/dist/cjs/load-plugins.js +89 -0
- package/dist/cjs/mailbox-name.d.ts +26 -0
- package/dist/cjs/mailbox-name.js +127 -0
- package/dist/cjs/mimeparser.d.ts +137 -0
- package/dist/cjs/mimeparser.js +727 -0
- package/dist/cjs/mock-client.d.ts +39 -0
- package/dist/cjs/mock-client.js +236 -0
- package/dist/cjs/numbers.d.ts +28 -0
- package/dist/cjs/numbers.js +52 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/plugins/acl.d.ts +2 -0
- package/dist/cjs/plugins/acl.js +888 -0
- package/dist/cjs/plugins/appendlimit.d.ts +16 -0
- package/dist/cjs/plugins/appendlimit.js +87 -0
- package/dist/cjs/plugins/auth-plain.d.ts +2 -0
- package/dist/cjs/plugins/auth-plain.js +89 -0
- package/dist/cjs/plugins/binary.d.ts +30 -0
- package/dist/cjs/plugins/binary.js +247 -0
- package/dist/cjs/plugins/catenate.d.ts +14 -0
- package/dist/cjs/plugins/catenate.js +250 -0
- package/dist/cjs/plugins/compress.d.ts +7 -0
- package/dist/cjs/plugins/compress.js +79 -0
- package/dist/cjs/plugins/condstore.d.ts +5 -0
- package/dist/cjs/plugins/condstore.js +492 -0
- package/dist/cjs/plugins/context-search.d.ts +8 -0
- package/dist/cjs/plugins/context-search.js +304 -0
- package/dist/cjs/plugins/context-sort.d.ts +6 -0
- package/dist/cjs/plugins/context-sort.js +32 -0
- package/dist/cjs/plugins/create-special-use.d.ts +7 -0
- package/dist/cjs/plugins/create-special-use.js +101 -0
- package/dist/cjs/plugins/enable.d.ts +23 -0
- package/dist/cjs/plugins/enable.js +127 -0
- package/dist/cjs/plugins/esearch.d.ts +6 -0
- package/dist/cjs/plugins/esearch.js +142 -0
- package/dist/cjs/plugins/esort.d.ts +6 -0
- package/dist/cjs/plugins/esort.js +60 -0
- package/dist/cjs/plugins/id.d.ts +5 -0
- package/dist/cjs/plugins/id.js +123 -0
- package/dist/cjs/plugins/idle.d.ts +5 -0
- package/dist/cjs/plugins/idle.js +85 -0
- package/dist/cjs/plugins/imap4rev2.d.ts +6 -0
- package/dist/cjs/plugins/imap4rev2.js +184 -0
- package/dist/cjs/plugins/index.d.ts +2 -0
- package/dist/cjs/plugins/index.js +119 -0
- package/dist/cjs/plugins/list-extended.d.ts +2 -0
- package/dist/cjs/plugins/list-extended.js +235 -0
- package/dist/cjs/plugins/list-status.d.ts +6 -0
- package/dist/cjs/plugins/list-status.js +42 -0
- package/dist/cjs/plugins/literalminus.d.ts +8 -0
- package/dist/cjs/plugins/literalminus.js +32 -0
- package/dist/cjs/plugins/literalplus.d.ts +6 -0
- package/dist/cjs/plugins/literalplus.js +30 -0
- package/dist/cjs/plugins/logindisabled.d.ts +5 -0
- package/dist/cjs/plugins/logindisabled.js +54 -0
- package/dist/cjs/plugins/messagelimit.d.ts +19 -0
- package/dist/cjs/plugins/messagelimit.js +227 -0
- package/dist/cjs/plugins/metadata-server.d.ts +7 -0
- package/dist/cjs/plugins/metadata-server.js +24 -0
- package/dist/cjs/plugins/metadata.d.ts +11 -0
- package/dist/cjs/plugins/metadata.js +436 -0
- package/dist/cjs/plugins/move.d.ts +11 -0
- package/dist/cjs/plugins/move.js +96 -0
- package/dist/cjs/plugins/multiappend.d.ts +12 -0
- package/dist/cjs/plugins/multiappend.js +38 -0
- package/dist/cjs/plugins/multisearch.d.ts +6 -0
- package/dist/cjs/plugins/multisearch.js +263 -0
- package/dist/cjs/plugins/namespace.d.ts +5 -0
- package/dist/cjs/plugins/namespace.js +57 -0
- package/dist/cjs/plugins/notify.d.ts +2 -0
- package/dist/cjs/plugins/notify.js +628 -0
- package/dist/cjs/plugins/oauthbearer.d.ts +32 -0
- package/dist/cjs/plugins/oauthbearer.js +202 -0
- package/dist/cjs/plugins/objectid.d.ts +23 -0
- package/dist/cjs/plugins/objectid.js +221 -0
- package/dist/cjs/plugins/partial.d.ts +6 -0
- package/dist/cjs/plugins/partial.js +78 -0
- package/dist/cjs/plugins/preview.d.ts +31 -0
- package/dist/cjs/plugins/preview.js +378 -0
- package/dist/cjs/plugins/qresync.d.ts +11 -0
- package/dist/cjs/plugins/qresync.js +473 -0
- package/dist/cjs/plugins/quota.d.ts +18 -0
- package/dist/cjs/plugins/quota.js +254 -0
- package/dist/cjs/plugins/replace.d.ts +14 -0
- package/dist/cjs/plugins/replace.js +130 -0
- package/dist/cjs/plugins/sasl-ir.d.ts +5 -0
- package/dist/cjs/plugins/sasl-ir.js +24 -0
- package/dist/cjs/plugins/savedate.d.ts +17 -0
- package/dist/cjs/plugins/savedate.js +64 -0
- package/dist/cjs/plugins/savelimit.d.ts +10 -0
- package/dist/cjs/plugins/savelimit.js +30 -0
- package/dist/cjs/plugins/searchres.d.ts +6 -0
- package/dist/cjs/plugins/searchres.js +91 -0
- package/dist/cjs/plugins/sort-display.d.ts +11 -0
- package/dist/cjs/plugins/sort-display.js +37 -0
- package/dist/cjs/plugins/sort.d.ts +11 -0
- package/dist/cjs/plugins/sort.js +125 -0
- package/dist/cjs/plugins/special-use.d.ts +10 -0
- package/dist/cjs/plugins/special-use.js +95 -0
- package/dist/cjs/plugins/starttls.d.ts +5 -0
- package/dist/cjs/plugins/starttls.js +55 -0
- package/dist/cjs/plugins/status-size.d.ts +7 -0
- package/dist/cjs/plugins/status-size.js +30 -0
- package/dist/cjs/plugins/thread-orderedsubject.d.ts +11 -0
- package/dist/cjs/plugins/thread-orderedsubject.js +28 -0
- package/dist/cjs/plugins/thread-references.d.ts +11 -0
- package/dist/cjs/plugins/thread-references.js +28 -0
- package/dist/cjs/plugins/uidonly.d.ts +15 -0
- package/dist/cjs/plugins/uidonly.js +126 -0
- package/dist/cjs/plugins/uidplus.d.ts +15 -0
- package/dist/cjs/plugins/uidplus.js +119 -0
- package/dist/cjs/plugins/unauthenticate.d.ts +7 -0
- package/dist/cjs/plugins/unauthenticate.js +32 -0
- package/dist/cjs/plugins/unselect.d.ts +5 -0
- package/dist/cjs/plugins/unselect.js +36 -0
- package/dist/cjs/plugins/utf8-accept.d.ts +6 -0
- package/dist/cjs/plugins/utf8-accept.js +72 -0
- package/dist/cjs/plugins/x-gm-ext-1.d.ts +26 -0
- package/dist/cjs/plugins/x-gm-ext-1.js +422 -0
- package/dist/cjs/plugins/xoauth2.d.ts +2 -0
- package/dist/cjs/plugins/xoauth2.js +155 -0
- package/dist/cjs/plugins/xtoybird.d.ts +2 -0
- package/dist/cjs/plugins/xtoybird.js +236 -0
- package/dist/cjs/server.d.ts +876 -0
- package/dist/cjs/server.js +2597 -0
- package/dist/cjs/smtp-listener.d.ts +13 -0
- package/dist/cjs/smtp-listener.js +47 -0
- package/dist/cjs/sorting.d.ts +77 -0
- package/dist/cjs/sorting.js +290 -0
- package/dist/cjs/threading.d.ts +30 -0
- package/dist/cjs/threading.js +318 -0
- package/dist/cjs/types.d.ts +327 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/utf8-session.d.ts +17 -0
- package/dist/cjs/utf8-session.js +148 -0
- package/dist/cjs/vanished.d.ts +21 -0
- package/dist/cjs/vanished.js +55 -0
- package/dist/esm/addressparser.d.ts +21 -0
- package/{lib → dist/esm}/addressparser.js +102 -123
- package/dist/esm/arguments.d.ts +31 -0
- package/dist/esm/arguments.js +96 -0
- package/dist/esm/bodystructure.d.ts +25 -0
- package/{lib → dist/esm}/bodystructure.js +17 -33
- package/dist/esm/cert.d.ts +2 -0
- package/dist/esm/cert.js +4 -0
- package/dist/esm/command-states.d.ts +36 -0
- package/{lib → dist/esm}/command-states.js +4 -16
- package/dist/esm/commands/append.d.ts +88 -0
- package/{lib → dist/esm}/commands/append.js +47 -85
- package/dist/esm/commands/capability.d.ts +2 -0
- package/dist/esm/commands/capability.js +29 -0
- package/dist/esm/commands/check.d.ts +2 -0
- package/dist/esm/commands/check.js +13 -0
- package/dist/esm/commands/close.d.ts +2 -0
- package/dist/esm/commands/close.js +20 -0
- package/dist/esm/commands/copy.d.ts +30 -0
- package/{lib → dist/esm}/commands/copy.js +31 -55
- package/dist/esm/commands/create.d.ts +2 -0
- package/{lib → dist/esm}/commands/create.js +25 -39
- package/dist/esm/commands/delete.d.ts +2 -0
- package/{lib → dist/esm}/commands/delete.js +25 -41
- package/dist/esm/commands/examine.d.ts +2 -0
- package/dist/esm/commands/examine.js +4 -0
- package/dist/esm/commands/expunge.d.ts +2 -0
- package/dist/esm/commands/expunge.js +17 -0
- package/dist/esm/commands/fetch.d.ts +23 -0
- package/{lib → dist/esm}/commands/fetch.js +33 -74
- package/dist/esm/commands/handlers/fetch.d.ts +12 -0
- package/{lib → dist/esm}/commands/handlers/fetch.js +11 -42
- package/dist/esm/commands/handlers/flags.d.ts +17 -0
- package/{lib → dist/esm}/commands/handlers/flags.js +3 -11
- package/dist/esm/commands/handlers/search.d.ts +85 -0
- package/{lib → dist/esm}/commands/handlers/search.js +33 -71
- package/dist/esm/commands/handlers/status.d.ts +34 -0
- package/{lib → dist/esm}/commands/handlers/status.js +1 -9
- package/dist/esm/commands/handlers/store.d.ts +3 -0
- package/{lib → dist/esm}/commands/handlers/store.js +20 -44
- package/dist/esm/commands/index.d.ts +2 -0
- package/dist/esm/commands/index.js +55 -0
- package/dist/esm/commands/list.d.ts +2 -0
- package/dist/esm/commands/list.js +71 -0
- package/dist/esm/commands/login.d.ts +2 -0
- package/{lib → dist/esm}/commands/login.js +24 -44
- package/dist/esm/commands/logout.d.ts +2 -0
- package/dist/esm/commands/logout.js +25 -0
- package/dist/esm/commands/lsub.d.ts +2 -0
- package/dist/esm/commands/lsub.js +64 -0
- package/dist/esm/commands/noop.d.ts +2 -0
- package/dist/esm/commands/noop.js +13 -0
- package/dist/esm/commands/rename.d.ts +2 -0
- package/{lib → dist/esm}/commands/rename.js +32 -51
- package/dist/esm/commands/search.d.ts +10 -0
- package/dist/esm/commands/search.js +54 -0
- package/dist/esm/commands/select.d.ts +19 -0
- package/dist/esm/commands/select.js +214 -0
- package/dist/esm/commands/status.d.ts +2 -0
- package/{lib → dist/esm}/commands/status.js +18 -39
- package/dist/esm/commands/store.d.ts +10 -0
- package/{lib → dist/esm}/commands/store.js +39 -73
- package/dist/esm/commands/subscribe.d.ts +2 -0
- package/{lib → dist/esm}/commands/subscribe.js +22 -39
- package/dist/esm/commands/uid-copy.d.ts +2 -0
- package/dist/esm/commands/uid-copy.js +4 -0
- package/dist/esm/commands/uid-fetch.d.ts +3 -0
- package/dist/esm/commands/uid-fetch.js +3 -0
- package/dist/esm/commands/uid-search.d.ts +3 -0
- package/dist/esm/commands/uid-search.js +3 -0
- package/dist/esm/commands/uid-store.d.ts +3 -0
- package/dist/esm/commands/uid-store.js +3 -0
- package/dist/esm/commands/unsubscribe.d.ts +2 -0
- package/{lib → dist/esm}/commands/unsubscribe.js +22 -37
- package/dist/esm/dates.d.ts +64 -0
- package/{lib → dist/esm}/dates.js +6 -14
- package/dist/esm/deflate-layer.d.ts +83 -0
- package/{lib → dist/esm}/deflate-layer.js +9 -26
- package/dist/esm/encoded-words.d.ts +15 -0
- package/{lib → dist/esm}/encoded-words.js +9 -25
- package/dist/esm/envelope.d.ts +33 -0
- package/{lib → dist/esm}/envelope.js +8 -19
- package/dist/esm/esearch.d.ts +96 -0
- package/{lib → dist/esm}/esearch.js +12 -39
- package/dist/esm/framing.d.ts +66 -0
- package/dist/esm/framing.js +82 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/list-extensions.d.ts +50 -0
- package/{lib → dist/esm}/list-extensions.js +1 -4
- package/dist/esm/load-plugins.d.ts +21 -0
- package/{lib → dist/esm}/load-plugins.js +9 -43
- package/dist/esm/mailbox-name.d.ts +26 -0
- package/{lib → dist/esm}/mailbox-name.js +5 -26
- package/dist/esm/mimeparser.d.ts +137 -0
- package/{lib → dist/esm}/mimeparser.js +74 -152
- package/dist/esm/mock-client.d.ts +39 -0
- package/{lib → dist/esm}/mock-client.js +26 -40
- package/dist/esm/numbers.d.ts +28 -0
- package/{lib → dist/esm}/numbers.js +1 -8
- package/dist/esm/package.json +3 -0
- package/dist/esm/plugins/acl.d.ts +2 -0
- package/{lib → dist/esm}/plugins/acl.js +146 -240
- package/dist/esm/plugins/appendlimit.d.ts +16 -0
- package/{lib → dist/esm}/plugins/appendlimit.js +5 -16
- package/dist/esm/plugins/auth-plain.d.ts +2 -0
- package/{lib → dist/esm}/plugins/auth-plain.js +11 -31
- package/dist/esm/plugins/binary.d.ts +30 -0
- package/{lib → dist/esm}/plugins/binary.js +17 -43
- package/dist/esm/plugins/catenate.d.ts +14 -0
- package/{lib → dist/esm}/plugins/catenate.js +19 -40
- package/dist/esm/plugins/compress.d.ts +7 -0
- package/dist/esm/plugins/compress.js +61 -0
- package/dist/esm/plugins/condstore.d.ts +5 -0
- package/{lib → dist/esm}/plugins/condstore.js +66 -152
- package/dist/esm/plugins/context-search.d.ts +8 -0
- package/{lib → dist/esm}/plugins/context-search.js +53 -88
- package/dist/esm/plugins/context-sort.d.ts +6 -0
- package/{lib → dist/esm}/plugins/context-sort.js +4 -9
- package/dist/esm/plugins/create-special-use.d.ts +7 -0
- package/{lib → dist/esm}/plugins/create-special-use.js +33 -55
- package/dist/esm/plugins/enable.d.ts +23 -0
- package/dist/esm/plugins/enable.js +111 -0
- package/dist/esm/plugins/esearch.d.ts +6 -0
- package/{lib → dist/esm}/plugins/esearch.js +13 -42
- package/dist/esm/plugins/esort.d.ts +6 -0
- package/{lib → dist/esm}/plugins/esort.js +7 -25
- package/dist/esm/plugins/id.d.ts +5 -0
- package/dist/esm/plugins/id.js +108 -0
- package/dist/esm/plugins/idle.d.ts +5 -0
- package/dist/esm/plugins/idle.js +70 -0
- package/dist/esm/plugins/imap4rev2.d.ts +6 -0
- package/{lib → dist/esm}/plugins/imap4rev2.js +24 -60
- package/dist/esm/plugins/index.d.ts +2 -0
- package/dist/esm/plugins/index.js +113 -0
- package/dist/esm/plugins/list-extended.d.ts +2 -0
- package/{lib → dist/esm}/plugins/list-extended.js +28 -66
- package/dist/esm/plugins/list-status.d.ts +6 -0
- package/{lib → dist/esm}/plugins/list-status.js +5 -12
- package/dist/esm/plugins/literalminus.d.ts +8 -0
- package/{lib → dist/esm}/plugins/literalminus.js +2 -5
- package/dist/esm/plugins/literalplus.d.ts +6 -0
- package/{lib → dist/esm}/plugins/literalplus.js +2 -5
- package/dist/esm/plugins/logindisabled.d.ts +5 -0
- package/dist/esm/plugins/logindisabled.js +39 -0
- package/dist/esm/plugins/messagelimit.d.ts +19 -0
- package/{lib → dist/esm}/plugins/messagelimit.js +18 -41
- package/dist/esm/plugins/metadata-server.d.ts +7 -0
- package/{lib → dist/esm}/plugins/metadata-server.js +3 -7
- package/dist/esm/plugins/metadata.d.ts +11 -0
- package/dist/esm/plugins/metadata.js +421 -0
- package/dist/esm/plugins/move.d.ts +11 -0
- package/{lib → dist/esm}/plugins/move.js +37 -66
- package/dist/esm/plugins/multiappend.d.ts +12 -0
- package/{lib → dist/esm}/plugins/multiappend.js +2 -5
- package/dist/esm/plugins/multisearch.d.ts +6 -0
- package/{lib → dist/esm}/plugins/multisearch.js +24 -48
- package/dist/esm/plugins/namespace.d.ts +5 -0
- package/dist/esm/plugins/namespace.js +42 -0
- package/dist/esm/plugins/notify.d.ts +2 -0
- package/{lib → dist/esm}/plugins/notify.js +90 -134
- package/dist/esm/plugins/oauthbearer.d.ts +32 -0
- package/{lib → dist/esm}/plugins/oauthbearer.js +18 -48
- package/dist/esm/plugins/objectid.d.ts +23 -0
- package/{lib → dist/esm}/plugins/objectid.js +21 -58
- package/dist/esm/plugins/partial.d.ts +6 -0
- package/{lib → dist/esm}/plugins/partial.js +7 -15
- package/dist/esm/plugins/preview.d.ts +31 -0
- package/{lib → dist/esm}/plugins/preview.js +28 -66
- package/dist/esm/plugins/qresync.d.ts +11 -0
- package/{lib → dist/esm}/plugins/qresync.js +64 -134
- package/dist/esm/plugins/quota.d.ts +18 -0
- package/{lib → dist/esm}/plugins/quota.js +89 -135
- package/dist/esm/plugins/replace.d.ts +14 -0
- package/{lib → dist/esm}/plugins/replace.js +21 -51
- package/dist/esm/plugins/sasl-ir.d.ts +5 -0
- package/{lib → dist/esm}/plugins/sasl-ir.js +3 -6
- package/dist/esm/plugins/savedate.d.ts +17 -0
- package/{lib → dist/esm}/plugins/savedate.js +5 -15
- package/dist/esm/plugins/savelimit.d.ts +10 -0
- package/{lib → dist/esm}/plugins/savelimit.js +3 -6
- package/dist/esm/plugins/searchres.d.ts +6 -0
- package/{lib → dist/esm}/plugins/searchres.js +13 -22
- package/dist/esm/plugins/sort-display.d.ts +11 -0
- package/{lib → dist/esm}/plugins/sort-display.js +6 -10
- package/dist/esm/plugins/sort.d.ts +11 -0
- package/{lib → dist/esm}/plugins/sort.js +24 -46
- package/dist/esm/plugins/special-use.d.ts +10 -0
- package/{lib → dist/esm}/plugins/special-use.js +9 -24
- package/dist/esm/plugins/starttls.d.ts +5 -0
- package/{lib → dist/esm}/plugins/starttls.js +20 -37
- package/dist/esm/plugins/status-size.d.ts +7 -0
- package/{lib → dist/esm}/plugins/status-size.js +4 -11
- package/dist/esm/plugins/thread-orderedsubject.d.ts +11 -0
- package/{lib → dist/esm}/plugins/thread-orderedsubject.js +3 -6
- package/dist/esm/plugins/thread-references.d.ts +11 -0
- package/{lib → dist/esm}/plugins/thread-references.js +3 -6
- package/dist/esm/plugins/uidonly.d.ts +15 -0
- package/{lib → dist/esm}/plugins/uidonly.js +11 -35
- package/dist/esm/plugins/uidplus.d.ts +15 -0
- package/{lib → dist/esm}/plugins/uidplus.js +25 -45
- package/dist/esm/plugins/unauthenticate.d.ts +7 -0
- package/dist/esm/plugins/unauthenticate.js +17 -0
- package/dist/esm/plugins/unselect.d.ts +5 -0
- package/dist/esm/plugins/unselect.js +21 -0
- package/dist/esm/plugins/utf8-accept.d.ts +6 -0
- package/{lib → dist/esm}/plugins/utf8-accept.js +10 -21
- package/dist/esm/plugins/x-gm-ext-1.d.ts +26 -0
- package/{lib → dist/esm}/plugins/x-gm-ext-1.js +48 -100
- package/dist/esm/plugins/xoauth2.d.ts +2 -0
- package/dist/esm/plugins/xoauth2.js +140 -0
- package/dist/esm/plugins/xtoybird.d.ts +2 -0
- package/dist/esm/plugins/xtoybird.js +218 -0
- package/dist/esm/server.d.ts +876 -0
- package/dist/esm/server.js +2543 -0
- package/dist/esm/smtp-listener.d.ts +13 -0
- package/{lib → dist/esm}/smtp-listener.js +5 -12
- package/dist/esm/sorting.d.ts +77 -0
- package/{lib → dist/esm}/sorting.js +40 -53
- package/dist/esm/threading.d.ts +30 -0
- package/{lib → dist/esm}/threading.js +29 -70
- package/dist/esm/types.d.ts +327 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/utf8-session.d.ts +17 -0
- package/{lib → dist/esm}/utf8-session.js +15 -25
- package/dist/esm/vanished.d.ts +21 -0
- package/{lib → dist/esm}/vanished.js +16 -21
- package/dist/plugin-help.json +298 -0
- package/package.json +54 -11
- package/lib/commands/capability.js +0 -47
- package/lib/commands/check.js +0 -21
- package/lib/commands/close.js +0 -30
- package/lib/commands/examine.js +0 -7
- package/lib/commands/expunge.js +0 -27
- package/lib/commands/list.js +0 -100
- package/lib/commands/logout.js +0 -41
- package/lib/commands/lsub.js +0 -87
- package/lib/commands/noop.js +0 -21
- package/lib/commands/search.js +0 -76
- package/lib/commands/select.js +0 -289
- package/lib/commands/uid copy.js +0 -7
- package/lib/commands/uid fetch.js +0 -5
- package/lib/commands/uid search.js +0 -5
- package/lib/commands/uid store.js +0 -5
- package/lib/plugins/compress.js +0 -76
- package/lib/plugins/enable.js +0 -155
- package/lib/plugins/id.js +0 -138
- package/lib/plugins/idle.js +0 -105
- package/lib/plugins/logindisabled.js +0 -50
- package/lib/plugins/metadata.js +0 -475
- package/lib/plugins/namespace.js +0 -67
- package/lib/plugins/unauthenticate.js +0 -28
- package/lib/plugins/unselect.js +0 -36
- package/lib/plugins/xoauth2.js +0 -188
- package/lib/plugins/xtoybird.js +0 -282
- package/lib/server.js +0 -2880
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SMTPServer } from 'smtp-server';
|
|
2
|
+
import type { IMAPServer } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Starts an SMTP server that appends every received message to the INBOX
|
|
5
|
+
* of the given ImapKit IMAP server. Any sender, recipient and credentials
|
|
6
|
+
* are accepted.
|
|
7
|
+
*
|
|
8
|
+
* @param {Number} smtpPort - port to listen on for SMTP commands
|
|
9
|
+
* @param {Object} imapServer - the ImapKit IMAP server
|
|
10
|
+
* @param {Function} [callback] - function executed when SMTP server is listening
|
|
11
|
+
* @return {SMTPServer} the SMTP server instance, use `close()` to stop it
|
|
12
|
+
*/
|
|
13
|
+
export declare function startSMTPServer(smtpPort: number, imapServer: IMAPServer, callback?: (() => void) | null): SMTPServer;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startSMTPServer = startSMTPServer;
|
|
4
|
+
const smtp_server_1 = require("smtp-server");
|
|
5
|
+
/**
|
|
6
|
+
* Starts an SMTP server that appends every received message to the INBOX
|
|
7
|
+
* of the given ImapKit IMAP server. Any sender, recipient and credentials
|
|
8
|
+
* are accepted.
|
|
9
|
+
*
|
|
10
|
+
* @param {Number} smtpPort - port to listen on for SMTP commands
|
|
11
|
+
* @param {Object} imapServer - the ImapKit IMAP server
|
|
12
|
+
* @param {Function} [callback] - function executed when SMTP server is listening
|
|
13
|
+
* @return {SMTPServer} the SMTP server instance, use `close()` to stop it
|
|
14
|
+
*/
|
|
15
|
+
function startSMTPServer(smtpPort, imapServer, callback) {
|
|
16
|
+
const credentials = imapServer.getCredentials();
|
|
17
|
+
const server = new smtp_server_1.SMTPServer({
|
|
18
|
+
banner: 'ImapKit',
|
|
19
|
+
key: credentials.key,
|
|
20
|
+
cert: credentials.cert,
|
|
21
|
+
authOptional: true,
|
|
22
|
+
logger: false,
|
|
23
|
+
onAuth(auth, session, done) {
|
|
24
|
+
done(null, { user: auth.username });
|
|
25
|
+
},
|
|
26
|
+
onData(stream, session, done) {
|
|
27
|
+
const chunks = [];
|
|
28
|
+
stream.on('data', (chunk) => chunks.push(chunk));
|
|
29
|
+
stream.on('error', done);
|
|
30
|
+
stream.on('end', () => {
|
|
31
|
+
// smtp-server has already removed the dot-stuffing (RFC 5321 section 4.5.2)
|
|
32
|
+
imapServer.appendMessage('INBOX', [], false, Buffer.concat(chunks).toString('binary'));
|
|
33
|
+
done();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
server.on('error', (err) => {
|
|
38
|
+
if (imapServer.options.debug) {
|
|
39
|
+
console.error('SMTP server error: %s', err.message);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
server.listen(smtpPort, () => {
|
|
43
|
+
console.log('Incoming SMTP server up and running on port %s', server.server.address().port);
|
|
44
|
+
callback?.();
|
|
45
|
+
});
|
|
46
|
+
return server;
|
|
47
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import makeSearch from './commands/handlers/search.js';
|
|
2
|
+
import type { Attribute, IMAPConnection, Message, ParsedCommand } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the i;unicode-casemap form of a string (RFC 5051 section 2): every character is titlecased
|
|
5
|
+
* and then decomposed (NFKD). Comparing the UTF-8 octets of the results is the collation that
|
|
6
|
+
* RFC 5256 section 7 requires for SORT and THREAD (I18NLEVEL=1, RFC 5255 section 4.5)
|
|
7
|
+
*
|
|
8
|
+
* @param {String} str Unicode string
|
|
9
|
+
* @return {Buffer} UTF-8 octets to compare with Buffer.compare
|
|
10
|
+
*/
|
|
11
|
+
declare function collationKey(str: string): Buffer;
|
|
12
|
+
/**
|
|
13
|
+
* Extracts the base subject (RFC 5256 section 2.1) and tells if the subject marks a reply or a
|
|
14
|
+
* forward (RFC 5256 section 3, REFERENCES): the extraction removed a subj-refwd, a "(fwd)" trailer
|
|
15
|
+
* or a subj-fwd-hdr and subj-fwd-trl pair.
|
|
16
|
+
*
|
|
17
|
+
* @param {String} subject Subject header value as a binary string
|
|
18
|
+
* @return {Object} `{ subject, isReply }`, subject is the base subject as a Unicode string
|
|
19
|
+
*/
|
|
20
|
+
declare function baseSubject(subject: string | undefined): {
|
|
21
|
+
subject: string;
|
|
22
|
+
isReply: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Internal date and time of a message in milliseconds (RFC 5256 ARRIVAL)
|
|
26
|
+
*
|
|
27
|
+
* @param {Object} message Message object
|
|
28
|
+
* @return {Number} timestamp, 0 if the internal date can not be parsed
|
|
29
|
+
*/
|
|
30
|
+
declare function arrivalTime(message: Message): number;
|
|
31
|
+
/**
|
|
32
|
+
* Sent date of a message in milliseconds (RFC 5256 section 2.2): the Date header normalized to UTC.
|
|
33
|
+
* An invalid zone is read as UTC and an invalid time as 00:00:00, and if the header is missing or
|
|
34
|
+
* has no valid date, the internal date is used instead.
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} message Message object
|
|
37
|
+
* @return {Number} timestamp
|
|
38
|
+
*/
|
|
39
|
+
declare function sentTime(message: Message): number;
|
|
40
|
+
/**
|
|
41
|
+
* addr-mailbox of the first address in a header (RFC 5256 CC, FROM and TO), empty if there is none
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} message Message object
|
|
44
|
+
* @param {String} header "from", "to" or "cc"
|
|
45
|
+
* @return {String} Unicode string
|
|
46
|
+
*/
|
|
47
|
+
declare function addressMailbox(message: Message, header: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* DISPLAY sort value of the first address in a header (RFC 5957 sections 3 and 4): the decoded
|
|
50
|
+
* addr-name, or addr-mailbox@addr-host, or addr-mailbox, or the empty string
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} message Message object
|
|
53
|
+
* @param {String} header "from" or "to"
|
|
54
|
+
* @return {String} Unicode string
|
|
55
|
+
*/
|
|
56
|
+
declare function displayAddress(message: Message, header: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Lists the Message IDs in a header value, normalized so that quoting does not matter (RFC 5256
|
|
59
|
+
* section 3, REFERENCES): comments and white space are dropped and a quoted id-left is unquoted.
|
|
60
|
+
* Only ids of the form "<" id-left "@" id-right ">" (RFC 5322 section 3.6.4) are valid.
|
|
61
|
+
*
|
|
62
|
+
* @param {String|Array} value Header value
|
|
63
|
+
* @return {Array} Message IDs
|
|
64
|
+
*/
|
|
65
|
+
declare function parseMessageIds(value: string | string[] | undefined): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Runs the search part of SORT and THREAD (RFC 5256 section 3): the charset is mandatory and the
|
|
68
|
+
* criteria follow it, both as in SEARCH. Sends a tagged BAD or NO response if the search fails.
|
|
69
|
+
*
|
|
70
|
+
* @param {Object} connection IMAP connection
|
|
71
|
+
* @param {Object} parsed Parsed command
|
|
72
|
+
* @param {String} data Raw command
|
|
73
|
+
* @param {Array} attributes Command arguments starting with the charset
|
|
74
|
+
* @return {Object|Boolean} `{ list, numbers }` like the SEARCH handler returns, or false after an error
|
|
75
|
+
*/
|
|
76
|
+
declare function searchMessages(connection: IMAPConnection, parsed: ParsedCommand, data: string, attributes: Attribute[]): ReturnType<typeof makeSearch> | false;
|
|
77
|
+
export { collationKey, baseSubject, arrivalTime, sentTime, addressMailbox, displayAddress, parseMessageIds, searchMessages };
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Message values for SORT and THREAD (RFC 5256): string collation, base subject, sent date,
|
|
3
|
+
// addresses and Message IDs, and the search step that both commands start with
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.collationKey = collationKey;
|
|
9
|
+
exports.baseSubject = baseSubject;
|
|
10
|
+
exports.arrivalTime = arrivalTime;
|
|
11
|
+
exports.sentTime = sentTime;
|
|
12
|
+
exports.addressMailbox = addressMailbox;
|
|
13
|
+
exports.displayAddress = displayAddress;
|
|
14
|
+
exports.parseMessageIds = parseMessageIds;
|
|
15
|
+
exports.searchMessages = searchMessages;
|
|
16
|
+
const mimeparser_js_1 = require("./mimeparser.js");
|
|
17
|
+
const envelope_js_1 = require("./envelope.js");
|
|
18
|
+
const dates_js_1 = require("./dates.js");
|
|
19
|
+
const search_js_1 = __importDefault(require("./commands/handlers/search.js"));
|
|
20
|
+
const search_js_2 = require("./commands/handlers/search.js");
|
|
21
|
+
const encoded_words_js_1 = require("./encoded-words.js");
|
|
22
|
+
// UnicodeData.txt titlecase mappings that differ from the single code point uppercase mapping
|
|
23
|
+
// that String#toUpperCase gives: the Latin digraphs and the Greek letters with ypogegrammeni
|
|
24
|
+
const TITLECASE = new Map([
|
|
25
|
+
[0x01c4, 0x01c5],
|
|
26
|
+
[0x01c6, 0x01c5],
|
|
27
|
+
[0x01c7, 0x01c8],
|
|
28
|
+
[0x01c9, 0x01c8],
|
|
29
|
+
[0x01ca, 0x01cb],
|
|
30
|
+
[0x01cc, 0x01cb],
|
|
31
|
+
[0x01f1, 0x01f2],
|
|
32
|
+
[0x01f3, 0x01f2],
|
|
33
|
+
[0x1fb3, 0x1fbc],
|
|
34
|
+
[0x1fc3, 0x1fcc],
|
|
35
|
+
[0x1ff3, 0x1ffc]
|
|
36
|
+
]);
|
|
37
|
+
for (const start of [0x1f80, 0x1f90, 0x1fa0]) {
|
|
38
|
+
for (let i = 0; i < 8; i++) {
|
|
39
|
+
TITLECASE.set(start + i, start + i + 8);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the i;unicode-casemap form of a string (RFC 5051 section 2): every character is titlecased
|
|
44
|
+
* and then decomposed (NFKD). Comparing the UTF-8 octets of the results is the collation that
|
|
45
|
+
* RFC 5256 section 7 requires for SORT and THREAD (I18NLEVEL=1, RFC 5255 section 4.5)
|
|
46
|
+
*
|
|
47
|
+
* @param {String} str Unicode string
|
|
48
|
+
* @return {Buffer} UTF-8 octets to compare with Buffer.compare
|
|
49
|
+
*/
|
|
50
|
+
function collationKey(str) {
|
|
51
|
+
let result = '';
|
|
52
|
+
for (const char of str) {
|
|
53
|
+
const code = char.codePointAt(0);
|
|
54
|
+
if (TITLECASE.has(code)) {
|
|
55
|
+
result += String.fromCodePoint(TITLECASE.get(code));
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
// full case mappings (e.g. "ß" to "SS") are not the simple mapping of UnicodeData.txt
|
|
59
|
+
const upper = char.toUpperCase();
|
|
60
|
+
result += [...upper].length === 1 ? upper : char;
|
|
61
|
+
}
|
|
62
|
+
return Buffer.from(result.normalize('NFKD'), 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
// RFC 5256 section 5: subj-refwd = ("re" / ("fw" ["d"])) *WSP [subj-blob] ":", subj-blob = "[" *BLOBCHAR "]" *WSP
|
|
65
|
+
const SUBJ_BLOB = '\\[[^[\\]]*\\] *';
|
|
66
|
+
const SUBJ_LEADER = new RegExp('^(?:' + SUBJ_BLOB + ')*(?:re|fwd?) *(?:' + SUBJ_BLOB + ')?:', 'i');
|
|
67
|
+
const SUBJ_BLOB_PREFIX = new RegExp('^' + SUBJ_BLOB);
|
|
68
|
+
/**
|
|
69
|
+
* Extracts the base subject (RFC 5256 section 2.1) and tells if the subject marks a reply or a
|
|
70
|
+
* forward (RFC 5256 section 3, REFERENCES): the extraction removed a subj-refwd, a "(fwd)" trailer
|
|
71
|
+
* or a subj-fwd-hdr and subj-fwd-trl pair.
|
|
72
|
+
*
|
|
73
|
+
* @param {String} subject Subject header value as a binary string
|
|
74
|
+
* @return {Object} `{ subject, isReply }`, subject is the base subject as a Unicode string
|
|
75
|
+
*/
|
|
76
|
+
function baseSubject(subject) {
|
|
77
|
+
let isReply = false;
|
|
78
|
+
// (1) decode encoded words, tabs and continuations become a space, runs of spaces one space
|
|
79
|
+
let text = (0, encoded_words_js_1.decodeHeader)(subject)
|
|
80
|
+
.replace(/\r?\n(?=[ \t])/g, '')
|
|
81
|
+
.replace(/[\t\r\n]/g, ' ')
|
|
82
|
+
.replace(/ {2,}/g, ' ');
|
|
83
|
+
for (;;) {
|
|
84
|
+
// (2) remove subj-trailer text until there is none
|
|
85
|
+
let end = text.length;
|
|
86
|
+
for (;;) {
|
|
87
|
+
if (text.charAt(end - 1) === ' ') {
|
|
88
|
+
end--;
|
|
89
|
+
}
|
|
90
|
+
else if (end >= 5 && text.substring(end - 5, end).toLowerCase() === '(fwd)') {
|
|
91
|
+
isReply = true;
|
|
92
|
+
end -= 5;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
text = text.substring(0, end);
|
|
99
|
+
// (3) remove subj-leader text, (4) remove a subj-blob prefix if a subj-base remains, (5) repeat
|
|
100
|
+
for (;;) {
|
|
101
|
+
let match;
|
|
102
|
+
if (text.charAt(0) === ' ') {
|
|
103
|
+
text = text.substr(1);
|
|
104
|
+
}
|
|
105
|
+
else if ((match = text.match(SUBJ_LEADER))) {
|
|
106
|
+
isReply = true;
|
|
107
|
+
text = text.substr(match[0].length);
|
|
108
|
+
}
|
|
109
|
+
else if ((match = text.match(SUBJ_BLOB_PREFIX)) && match[0].length < text.length) {
|
|
110
|
+
text = text.substr(match[0].length);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// (6) unwrap "[fwd: ... ]" and start over from step (2)
|
|
117
|
+
if (/^\[fwd:/i.test(text) && /\]$/.test(text)) {
|
|
118
|
+
isReply = true;
|
|
119
|
+
text = text.slice(5, -1);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
// (7) the remaining text is the base subject
|
|
123
|
+
return { subject: text, isReply };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Internal date and time of a message in milliseconds (RFC 5256 ARRIVAL)
|
|
128
|
+
*
|
|
129
|
+
* @param {Object} message Message object
|
|
130
|
+
* @return {Number} timestamp, 0 if the internal date can not be parsed
|
|
131
|
+
*/
|
|
132
|
+
function arrivalTime(message) {
|
|
133
|
+
const date = (0, dates_js_1.parseDateTime)(message.internaldate);
|
|
134
|
+
return date ? (0, dates_js_1.toTimestamp)(date) : 0;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Sent date of a message in milliseconds (RFC 5256 section 2.2): the Date header normalized to UTC.
|
|
138
|
+
* An invalid zone is read as UTC and an invalid time as 00:00:00, and if the header is missing or
|
|
139
|
+
* has no valid date, the internal date is used instead.
|
|
140
|
+
*
|
|
141
|
+
* @param {Object} message Message object
|
|
142
|
+
* @return {Number} timestamp
|
|
143
|
+
*/
|
|
144
|
+
function sentTime(message) {
|
|
145
|
+
const date = (0, dates_js_1.parseHeaderDate)((0, mimeparser_js_1.getMessageData)(message).tree.parsedHeader.date);
|
|
146
|
+
if (!date) {
|
|
147
|
+
return arrivalTime(message);
|
|
148
|
+
}
|
|
149
|
+
// the parsers set minutes and seconds together with hours
|
|
150
|
+
if (date.hours === undefined || date.hours > 23 || date.minutes > 59 || date.seconds > 60) {
|
|
151
|
+
Object.assign(date, { hours: 0, minutes: 0, seconds: 0 });
|
|
152
|
+
}
|
|
153
|
+
return (0, dates_js_1.toTimestamp)(date);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Returns the first address of an envelope address list, as [name, adl, mailbox, host]
|
|
157
|
+
*/
|
|
158
|
+
function firstAddress(message, header) {
|
|
159
|
+
const list = (0, envelope_js_1.processAddress)((0, mimeparser_js_1.getMessageData)(message).tree.parsedHeader[header]);
|
|
160
|
+
return (list && list[0]) || null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* addr-mailbox of the first address in a header (RFC 5256 CC, FROM and TO), empty if there is none
|
|
164
|
+
*
|
|
165
|
+
* @param {Object} message Message object
|
|
166
|
+
* @param {String} header "from", "to" or "cc"
|
|
167
|
+
* @return {String} Unicode string
|
|
168
|
+
*/
|
|
169
|
+
function addressMailbox(message, header) {
|
|
170
|
+
const address = firstAddress(message, header);
|
|
171
|
+
return address && address[2] ? (0, encoded_words_js_1.decodeHeader)(address[2]) : '';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* DISPLAY sort value of the first address in a header (RFC 5957 sections 3 and 4): the decoded
|
|
175
|
+
* addr-name, or addr-mailbox@addr-host, or addr-mailbox, or the empty string
|
|
176
|
+
*
|
|
177
|
+
* @param {Object} message Message object
|
|
178
|
+
* @param {String} header "from" or "to"
|
|
179
|
+
* @return {String} Unicode string
|
|
180
|
+
*/
|
|
181
|
+
function displayAddress(message, header) {
|
|
182
|
+
const address = firstAddress(message, header);
|
|
183
|
+
const name = address && address[0] ? (0, encoded_words_js_1.decodeHeader)(address[0]) : '';
|
|
184
|
+
if (name || !address || !address[2]) {
|
|
185
|
+
return name;
|
|
186
|
+
}
|
|
187
|
+
return (0, encoded_words_js_1.decodeHeader)(address[3] ? address[2] + '@' + address[3] : address[2]);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Lists the Message IDs in a header value, normalized so that quoting does not matter (RFC 5256
|
|
191
|
+
* section 3, REFERENCES): comments and white space are dropped and a quoted id-left is unquoted.
|
|
192
|
+
* Only ids of the form "<" id-left "@" id-right ">" (RFC 5322 section 3.6.4) are valid.
|
|
193
|
+
*
|
|
194
|
+
* @param {String|Array} value Header value
|
|
195
|
+
* @return {Array} Message IDs
|
|
196
|
+
*/
|
|
197
|
+
function parseMessageIds(value) {
|
|
198
|
+
const str = [].concat(value || []).join(' ');
|
|
199
|
+
const ids = [];
|
|
200
|
+
let depth = 0;
|
|
201
|
+
let quoted = false;
|
|
202
|
+
let current = null;
|
|
203
|
+
for (let i = 0; i < str.length; i++) {
|
|
204
|
+
const char = str.charAt(i);
|
|
205
|
+
if (quoted) {
|
|
206
|
+
if (char === '\\') {
|
|
207
|
+
if (current !== null) {
|
|
208
|
+
current += str.charAt(i + 1);
|
|
209
|
+
}
|
|
210
|
+
i++;
|
|
211
|
+
}
|
|
212
|
+
else if (char === '"') {
|
|
213
|
+
quoted = false;
|
|
214
|
+
}
|
|
215
|
+
else if (current !== null) {
|
|
216
|
+
current += char;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else if (depth) {
|
|
220
|
+
if (char === '\\') {
|
|
221
|
+
i++;
|
|
222
|
+
}
|
|
223
|
+
else if (char === '(') {
|
|
224
|
+
depth++;
|
|
225
|
+
}
|
|
226
|
+
else if (char === ')') {
|
|
227
|
+
depth--;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else if (char === '"') {
|
|
231
|
+
quoted = true;
|
|
232
|
+
}
|
|
233
|
+
else if (char === '(') {
|
|
234
|
+
depth++;
|
|
235
|
+
}
|
|
236
|
+
else if (char === '<') {
|
|
237
|
+
current = '';
|
|
238
|
+
}
|
|
239
|
+
else if (char === '>') {
|
|
240
|
+
if (current !== null) {
|
|
241
|
+
const at = current.lastIndexOf('@');
|
|
242
|
+
if (at > 0 && at < current.length - 1) {
|
|
243
|
+
ids.push(current);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
current = null;
|
|
247
|
+
}
|
|
248
|
+
else if (current !== null && !/\s/.test(char)) {
|
|
249
|
+
current += char;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return ids;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Runs the search part of SORT and THREAD (RFC 5256 section 3): the charset is mandatory and the
|
|
256
|
+
* criteria follow it, both as in SEARCH. Sends a tagged BAD or NO response if the search fails.
|
|
257
|
+
*
|
|
258
|
+
* @param {Object} connection IMAP connection
|
|
259
|
+
* @param {Object} parsed Parsed command
|
|
260
|
+
* @param {String} data Raw command
|
|
261
|
+
* @param {Array} attributes Command arguments starting with the charset
|
|
262
|
+
* @return {Object|Boolean} `{ list, numbers }` like the SEARCH handler returns, or false after an error
|
|
263
|
+
*/
|
|
264
|
+
function searchMessages(connection, parsed, data, attributes) {
|
|
265
|
+
const command = parsed.command.toUpperCase();
|
|
266
|
+
const charset = attributes[0];
|
|
267
|
+
try {
|
|
268
|
+
// RFC 5256 section 5: charset = atom / quoted
|
|
269
|
+
if (attributes.length < 2) {
|
|
270
|
+
throw (0, search_js_2.badError)(command + ' expects a charset and search criteria');
|
|
271
|
+
}
|
|
272
|
+
if (!charset || ['ATOM', 'STRING'].indexOf(charset.type) < 0) {
|
|
273
|
+
throw (0, search_js_2.badError)('Charset must be an atom or a quoted string');
|
|
274
|
+
}
|
|
275
|
+
const criteria = (0, search_js_2.criteriaValues)(attributes.slice(1));
|
|
276
|
+
if (connection.searchCharset) {
|
|
277
|
+
// RFC 9755 section 3: with a fixed session charset (UTF8=ACCEPT) other charsets are BAD
|
|
278
|
+
if (charset.value.toUpperCase() !== connection.searchCharset) {
|
|
279
|
+
throw (0, search_js_2.badError)('Charset must be ' + connection.searchCharset + ' in this session');
|
|
280
|
+
}
|
|
281
|
+
return (0, search_js_1.default)(connection, connection.getSessionMessages(), criteria);
|
|
282
|
+
}
|
|
283
|
+
const params = ['CHARSET', charset.value].concat(criteria);
|
|
284
|
+
return (0, search_js_1.default)(connection, connection.getSessionMessages(), params);
|
|
285
|
+
}
|
|
286
|
+
catch (E) {
|
|
287
|
+
(0, search_js_2.sendSearchError)(connection, parsed, data, E, command + ' FAILED');
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IMAPServer, Message } from './types.js';
|
|
2
|
+
/** A searched message with the values that threading looks at */
|
|
3
|
+
export interface ThreadEntry {
|
|
4
|
+
message: Message;
|
|
5
|
+
seq: number;
|
|
6
|
+
/** sent date, see sentTime() */
|
|
7
|
+
date: number;
|
|
8
|
+
/** the base subject as a binary string of its collation key, and if the subject marks a reply or forward */
|
|
9
|
+
subject: {
|
|
10
|
+
id: string;
|
|
11
|
+
isReply: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** A node of a thread tree, a node without an entry is a dummy */
|
|
15
|
+
export interface ThreadNode {
|
|
16
|
+
entry: ThreadEntry | null;
|
|
17
|
+
parent: ThreadNode | null;
|
|
18
|
+
children: ThreadNode[];
|
|
19
|
+
}
|
|
20
|
+
/** A threading algorithm, returns the top level nodes */
|
|
21
|
+
export type ThreadAlgorithm = (entries: ThreadEntry[]) => ThreadNode[];
|
|
22
|
+
/**
|
|
23
|
+
* Adds the THREAD and UID THREAD commands, unless another algorithm plugin did already, and the
|
|
24
|
+
* THREAD=<algorithm> capability
|
|
25
|
+
*
|
|
26
|
+
* @param {Object} server IMAP server
|
|
27
|
+
* @param {String} algorithm "ORDEREDSUBJECT" or "REFERENCES"
|
|
28
|
+
*/
|
|
29
|
+
declare function addThreadAlgorithm(server: IMAPServer, algorithm: string): void;
|
|
30
|
+
export { addThreadAlgorithm };
|