imapkit 4.0.2 → 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 +34 -75
- 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,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_zlib_1 = __importDefault(require("node:zlib"));
|
|
7
|
+
// Z_SYNC_FLUSH ends with an empty stored block, LEN 0 and NLEN 0xFFFF (RFC 1951 section 3.2.4)
|
|
8
|
+
const SYNC_MARKER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
|
|
9
|
+
// Z_FINISH right after a flush is an empty final block with fixed Huffman codes
|
|
10
|
+
const EMPTY_FINAL_BLOCK = Buffer.from([0x03, 0x00]);
|
|
11
|
+
/**
|
|
12
|
+
* One end of a COMPRESS=DEFLATE layer (RFC 4978): raw DEFLATE (RFC 1951, no zlib header or
|
|
13
|
+
* checksum) in both directions. The server plugin uses it, and so do the clients of the tests and
|
|
14
|
+
* the compare tool.
|
|
15
|
+
*
|
|
16
|
+
* Either direction can be terminated, which UNAUTHENTICATE requires (RFC 8437 section 4.1). Output
|
|
17
|
+
* terminates with a final DEFLATE block, data written after that goes out uncompressed once the
|
|
18
|
+
* compressed data is out. Input terminates where the peer ended its compression: at the end of
|
|
19
|
+
* its DEFLATE stream if it sent a final block, otherwise at the end of the sync flush that
|
|
20
|
+
* carried the last compressed data. The input is split at sync flush markers to find that point.
|
|
21
|
+
*/
|
|
22
|
+
class DeflateLayer {
|
|
23
|
+
/**
|
|
24
|
+
* @param {Object} options
|
|
25
|
+
* @param {Function} options.writeRaw `(buffer)` sends octets to the peer
|
|
26
|
+
* @param {Function} options.onData `(buffer)` gets the input, decompressed while compression is active
|
|
27
|
+
* @param {Function} [options.onError] `(err)` called when the input is not valid DEFLATE data
|
|
28
|
+
*/
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.writeRaw = options.writeRaw;
|
|
31
|
+
this.onData = options.onData;
|
|
32
|
+
this.onError = options.onError || (() => false);
|
|
33
|
+
// outgoing data is compressed
|
|
34
|
+
this.active = true;
|
|
35
|
+
// incoming data is compressed
|
|
36
|
+
this.inputActive = true;
|
|
37
|
+
this._deflate = node_zlib_1.default.createDeflateRaw();
|
|
38
|
+
this._deflate.on('data', (chunk) => this.writeRaw(chunk));
|
|
39
|
+
this._deflate.on('error', (err) => this.onError(err));
|
|
40
|
+
// writes that wait for the final compressed data, null when nothing is waiting
|
|
41
|
+
this._held = null;
|
|
42
|
+
this._endCallbacks = [];
|
|
43
|
+
this._flushScheduled = false;
|
|
44
|
+
this._inflate = node_zlib_1.default.createInflateRaw({ flush: node_zlib_1.default.constants.Z_SYNC_FLUSH });
|
|
45
|
+
this._inflate.on('data', (chunk) => {
|
|
46
|
+
// anything the peer compressed after it ended its compression is dropped
|
|
47
|
+
if (this.inputActive) {
|
|
48
|
+
this.onData(chunk);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
this._inflate.on('error', (err) => {
|
|
52
|
+
this.inputActive = false;
|
|
53
|
+
this._pieces = [];
|
|
54
|
+
this._busy = false;
|
|
55
|
+
this.onError(err);
|
|
56
|
+
this._next();
|
|
57
|
+
});
|
|
58
|
+
// input waiting for the inflater, split at sync flush markers
|
|
59
|
+
this._pieces = [];
|
|
60
|
+
this._busy = false;
|
|
61
|
+
// octets given to the inflater
|
|
62
|
+
this._fed = 0;
|
|
63
|
+
// the peer may still send the empty final block of its DEFLATE stream
|
|
64
|
+
this._expectFinal = false;
|
|
65
|
+
// called once the received data is processed
|
|
66
|
+
this._idleCallbacks = [];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sends data to the peer, compressed while compression is active
|
|
70
|
+
*
|
|
71
|
+
* @param {Buffer} data Data to send
|
|
72
|
+
*/
|
|
73
|
+
write(data) {
|
|
74
|
+
if (this._held) {
|
|
75
|
+
this._held.push(data);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!this.active) {
|
|
79
|
+
this.writeRaw(data);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this._deflate.write(data);
|
|
83
|
+
if (!this._flushScheduled) {
|
|
84
|
+
// everything written in one go, like a burst of responses, is flushed together, so the peer
|
|
85
|
+
// gets it right away instead of when the compressor buffer fills up (RFC 4978 section 4)
|
|
86
|
+
this._flushScheduled = true;
|
|
87
|
+
process.nextTick(() => {
|
|
88
|
+
this._flushScheduled = false;
|
|
89
|
+
if (this.active && !this._deflate.destroyed) {
|
|
90
|
+
this._deflate.flush(node_zlib_1.default.constants.Z_SYNC_FLUSH);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Terminates the outgoing compression with a final DEFLATE block. Later writes are sent
|
|
97
|
+
* uncompressed, after the compressed data.
|
|
98
|
+
*
|
|
99
|
+
* @param {Function} [callback] Called once the compressed data is written out
|
|
100
|
+
*/
|
|
101
|
+
end(callback) {
|
|
102
|
+
if (callback) {
|
|
103
|
+
this._endCallbacks.push(callback);
|
|
104
|
+
}
|
|
105
|
+
if (!this.active) {
|
|
106
|
+
if (!this._held) {
|
|
107
|
+
this._runCallbacks('_endCallbacks');
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.active = false;
|
|
112
|
+
this._held = [];
|
|
113
|
+
this._deflate.once('end', () => {
|
|
114
|
+
const held = this._held || [];
|
|
115
|
+
this._held = null;
|
|
116
|
+
held.forEach(data => this.writeRaw(data));
|
|
117
|
+
this._runCallbacks('_endCallbacks');
|
|
118
|
+
});
|
|
119
|
+
this._deflate.end();
|
|
120
|
+
}
|
|
121
|
+
// calls the callbacks of a list once, callbacks added meanwhile wait for the next run
|
|
122
|
+
_runCallbacks(key) {
|
|
123
|
+
const callbacks = this[key];
|
|
124
|
+
this[key] = [];
|
|
125
|
+
callbacks.forEach(callback => callback());
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Handles octets received from the peer
|
|
129
|
+
*
|
|
130
|
+
* @param {Buffer} chunk Received data
|
|
131
|
+
*/
|
|
132
|
+
receive(chunk) {
|
|
133
|
+
if (!this.inputActive && !this._busy && !this._pieces.length) {
|
|
134
|
+
this._receivePlain(chunk);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let start = 0;
|
|
138
|
+
let pos;
|
|
139
|
+
while ((pos = chunk.indexOf(SYNC_MARKER, start)) >= 0) {
|
|
140
|
+
this._pieces.push(chunk.subarray(start, pos + SYNC_MARKER.length));
|
|
141
|
+
start = pos + SYNC_MARKER.length;
|
|
142
|
+
}
|
|
143
|
+
if (start < chunk.length) {
|
|
144
|
+
this._pieces.push(chunk.subarray(start));
|
|
145
|
+
}
|
|
146
|
+
this._next();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Tells the layer that the peer terminates its compression after the data decompressed so far
|
|
150
|
+
* (RFC 8437 section 4.1). Call it from onData, the rest of the input is then passed on as is.
|
|
151
|
+
*/
|
|
152
|
+
endInput() {
|
|
153
|
+
this.inputActive = false;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Calls back once all received data is passed on
|
|
157
|
+
*
|
|
158
|
+
* @param {Function} callback Function to call
|
|
159
|
+
*/
|
|
160
|
+
whenIdle(callback) {
|
|
161
|
+
this._idleCallbacks.push(callback);
|
|
162
|
+
this._next();
|
|
163
|
+
}
|
|
164
|
+
_next() {
|
|
165
|
+
if (this._busy) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!this._pieces.length) {
|
|
169
|
+
this._runCallbacks('_idleCallbacks');
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!this.inputActive) {
|
|
173
|
+
const rest = Buffer.concat(this._pieces);
|
|
174
|
+
this._pieces = [];
|
|
175
|
+
this._receivePlain(rest);
|
|
176
|
+
this._next();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const piece = this._pieces.shift();
|
|
180
|
+
this._busy = true;
|
|
181
|
+
this._fed += piece.length;
|
|
182
|
+
this._inflate.write(piece, () => {
|
|
183
|
+
this._busy = false;
|
|
184
|
+
// octets the inflater did not use follow the end of the peer's DEFLATE stream
|
|
185
|
+
const unused = this._fed - this._inflate.bytesWritten;
|
|
186
|
+
if (unused > 0 || this._inflate.readableEnded) {
|
|
187
|
+
this.inputActive = false;
|
|
188
|
+
if (unused > 0) {
|
|
189
|
+
this._pieces.unshift(piece.subarray(piece.length - unused));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else if (!this.inputActive) {
|
|
193
|
+
// the input ended at a sync flush, the final block may still follow
|
|
194
|
+
this._expectFinal = true;
|
|
195
|
+
}
|
|
196
|
+
this._next();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
_receivePlain(chunk) {
|
|
200
|
+
if (this._expectFinal) {
|
|
201
|
+
this._expectFinal = false;
|
|
202
|
+
if (chunk.subarray(0, EMPTY_FINAL_BLOCK.length).equals(EMPTY_FINAL_BLOCK)) {
|
|
203
|
+
chunk = chunk.subarray(EMPTY_FINAL_BLOCK.length);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (chunk.length) {
|
|
207
|
+
this.onData(chunk);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Frees the compressor and the decompressor
|
|
212
|
+
*/
|
|
213
|
+
destroy() {
|
|
214
|
+
this.active = this.inputActive = false;
|
|
215
|
+
this._pieces = [];
|
|
216
|
+
this._deflate.destroy();
|
|
217
|
+
this._inflate.destroy();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.default = DeflateLayer;
|
|
221
|
+
{
|
|
222
|
+
const defaultExport = exports.default;
|
|
223
|
+
if (defaultExport && (typeof defaultExport === 'function' || typeof defaultExport === 'object')) {
|
|
224
|
+
for (const key of Object.keys(exports)) {
|
|
225
|
+
if (key !== 'default' && !(key in defaultExport)) {
|
|
226
|
+
defaultExport[key] = exports[key];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
Object.defineProperty(defaultExport, 'default', { value: defaultExport, enumerable: false, writable: true, configurable: true });
|
|
230
|
+
module.exports = defaultExport;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a binary string (one char per octet) as UTF-8, invalid sequences become U+FFFD
|
|
3
|
+
*/
|
|
4
|
+
declare function decodeUtf8(value: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Decodes an RFC 2047 header value to a Unicode string. Text outside encoded words is read as UTF-8
|
|
7
|
+
* (invalid sequences become U+FFFD). Adjacent encoded words in the same charset are decoded together,
|
|
8
|
+
* so a multi-octet character may span them, and the white space between them is dropped (RFC 2047
|
|
9
|
+
* section 6.2). Encoded words in an unknown charset are kept as they are.
|
|
10
|
+
*
|
|
11
|
+
* @param {String} value Header value as a binary string
|
|
12
|
+
* @return {String} Decoded value
|
|
13
|
+
*/
|
|
14
|
+
declare function decodeHeader(input: unknown): string;
|
|
15
|
+
export { decodeHeader, decodeUtf8 };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// RFC 2047 encoded words in header values, decoded for SEARCH, SORT and THREAD
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.decodeHeader = decodeHeader;
|
|
5
|
+
exports.decodeUtf8 = decodeUtf8;
|
|
6
|
+
// RFC 2047 section 2: encoded-word = "=?" charset "?" encoding "?" encoded-text "?=", RFC 2231 section 5
|
|
7
|
+
// adds an optional "*" language suffix to the charset
|
|
8
|
+
const ENCODED_WORD = /=\?([^?\s*]+)(?:\*[^?\s]*)?\?([BbQq])\?([^?\s]*)\?=/g;
|
|
9
|
+
const utf8Decoder = new TextDecoder('utf-8');
|
|
10
|
+
/**
|
|
11
|
+
* Reads a binary string (one char per octet) as UTF-8, invalid sequences become U+FFFD
|
|
12
|
+
*/
|
|
13
|
+
function decodeUtf8(value) {
|
|
14
|
+
return utf8Decoder.decode(Buffer.from(value, 'binary'));
|
|
15
|
+
}
|
|
16
|
+
// decoders by lower case charset name, false for a charset that TextDecoder does not know
|
|
17
|
+
const decoders = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Decodes the octets of an encoded word, or returns false if the charset is unknown
|
|
20
|
+
*/
|
|
21
|
+
function decodeCharset(charset, octets) {
|
|
22
|
+
charset = charset.toLowerCase();
|
|
23
|
+
if (!decoders.has(charset)) {
|
|
24
|
+
let decoder = false;
|
|
25
|
+
try {
|
|
26
|
+
decoder = new TextDecoder(charset);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// unknown charset
|
|
30
|
+
}
|
|
31
|
+
decoders.set(charset, decoder);
|
|
32
|
+
}
|
|
33
|
+
const decoder = decoders.get(charset);
|
|
34
|
+
return decoder ? decoder.decode(octets) : false;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Decodes an RFC 2047 header value to a Unicode string. Text outside encoded words is read as UTF-8
|
|
38
|
+
* (invalid sequences become U+FFFD). Adjacent encoded words in the same charset are decoded together,
|
|
39
|
+
* so a multi-octet character may span them, and the white space between them is dropped (RFC 2047
|
|
40
|
+
* section 6.2). Encoded words in an unknown charset are kept as they are.
|
|
41
|
+
*
|
|
42
|
+
* @param {String} value Header value as a binary string
|
|
43
|
+
* @return {String} Decoded value
|
|
44
|
+
*/
|
|
45
|
+
function decodeHeader(input) {
|
|
46
|
+
const value = String(input || '');
|
|
47
|
+
if (value.indexOf('=?') < 0 && !/[\u0080-\u00ff]/.test(value)) {
|
|
48
|
+
// nothing to decode
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
let result = '';
|
|
52
|
+
let pending = null;
|
|
53
|
+
let lastIndex = 0;
|
|
54
|
+
const flush = () => {
|
|
55
|
+
if (pending) {
|
|
56
|
+
const decoded = decodeCharset(pending.charset, Buffer.concat(pending.octets));
|
|
57
|
+
result += decoded === false ? pending.source : decoded;
|
|
58
|
+
pending = null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
ENCODED_WORD.lastIndex = 0;
|
|
62
|
+
let match;
|
|
63
|
+
while ((match = ENCODED_WORD.exec(value))) {
|
|
64
|
+
const between = value.substring(lastIndex, match.index);
|
|
65
|
+
const adjacent = pending && /^\s*$/.test(between);
|
|
66
|
+
if (!adjacent) {
|
|
67
|
+
flush();
|
|
68
|
+
result += decodeUtf8(between);
|
|
69
|
+
}
|
|
70
|
+
lastIndex = ENCODED_WORD.lastIndex;
|
|
71
|
+
const octets = match[2].toUpperCase() === 'B'
|
|
72
|
+
? Buffer.from(match[3], 'base64')
|
|
73
|
+
: Buffer.from(match[3].replace(/_/g, ' ').replace(/=([0-9a-fA-F]{2})/g, (m, hex) => String.fromCharCode(parseInt(hex, 16))), 'binary');
|
|
74
|
+
if (pending && pending.charset.toLowerCase() !== match[1].toLowerCase()) {
|
|
75
|
+
flush();
|
|
76
|
+
}
|
|
77
|
+
if (!pending) {
|
|
78
|
+
pending = { charset: match[1], octets: [], source: '' };
|
|
79
|
+
}
|
|
80
|
+
pending.octets.push(octets);
|
|
81
|
+
pending.source += (pending.source ? between : '') + match[0];
|
|
82
|
+
}
|
|
83
|
+
flush();
|
|
84
|
+
return result + decodeUtf8(value.substr(lastIndex));
|
|
85
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ParsedAddress } from './addressparser.js';
|
|
2
|
+
import type { ParsedHeader } from './mimeparser.js';
|
|
3
|
+
/** An address of the ENVELOPE (RFC 3501 section 9): name, source route, mailbox and host, all NIL for a group end */
|
|
4
|
+
export type EnvelopeAddress = [name: string | null, adl: null, mailbox: string | null, host: string | null];
|
|
5
|
+
/** The fields of the ENVELOPE (RFC 3501 section 7.4.2), in order */
|
|
6
|
+
export type Envelope = [
|
|
7
|
+
date: string | null,
|
|
8
|
+
subject: string | null,
|
|
9
|
+
from: EnvelopeAddress[] | null,
|
|
10
|
+
sender: EnvelopeAddress[] | null,
|
|
11
|
+
replyTo: EnvelopeAddress[] | null,
|
|
12
|
+
to: EnvelopeAddress[] | null,
|
|
13
|
+
cc: EnvelopeAddress[] | null,
|
|
14
|
+
bcc: EnvelopeAddress[] | null,
|
|
15
|
+
inReplyTo: string | null,
|
|
16
|
+
messageId: string | null
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Convert a message object to an ENVELOPE object
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} header Parsed header of a mime tree node
|
|
22
|
+
* @return {Object} ENVELOPE compatible object
|
|
23
|
+
*/
|
|
24
|
+
export default function envelope(header: ParsedHeader): Envelope;
|
|
25
|
+
/**
|
|
26
|
+
* Converts an address object to a list of arrays
|
|
27
|
+
* [{name: "User Name", addres:"user@example.com"}] -> [["User Name", null, "user", "example.com"]]
|
|
28
|
+
*
|
|
29
|
+
* @param {Array} arr An array of address objects
|
|
30
|
+
* @return {Array} A list of addresses
|
|
31
|
+
*/
|
|
32
|
+
declare function processAddress(arr: ParsedAddress | ParsedAddress[] | undefined, def?: ParsedAddress | ParsedAddress[]): EnvelopeAddress[] | null;
|
|
33
|
+
export { processAddress };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This module converts message structure into an ENVELOPE object
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = envelope;
|
|
5
|
+
exports.processAddress = processAddress;
|
|
6
|
+
/**
|
|
7
|
+
* Convert a message object to an ENVELOPE object
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} header Parsed header of a mime tree node
|
|
10
|
+
* @return {Object} ENVELOPE compatible object
|
|
11
|
+
*/
|
|
12
|
+
function envelope(header) {
|
|
13
|
+
// RFC 3501 9: env-date and env-subject are nstring, NIL when the header is missing
|
|
14
|
+
const subject = header.subject;
|
|
15
|
+
return [
|
|
16
|
+
header.date || null,
|
|
17
|
+
typeof subject === 'string' ? subject : null,
|
|
18
|
+
processAddress(header.from),
|
|
19
|
+
processAddress(header.sender, header.from),
|
|
20
|
+
processAddress(header['reply-to'], header.from),
|
|
21
|
+
processAddress(header.to),
|
|
22
|
+
processAddress(header.cc),
|
|
23
|
+
processAddress(header.bcc),
|
|
24
|
+
// If this is an embedded MESSAGE/RFC822, then Gmail seems to
|
|
25
|
+
// have a bug here, it states '"NIL"' as the value, not 'NIL'
|
|
26
|
+
header['in-reply-to'] || null,
|
|
27
|
+
header['message-id'] || null
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts an address object to a list of arrays
|
|
32
|
+
* [{name: "User Name", addres:"user@example.com"}] -> [["User Name", null, "user", "example.com"]]
|
|
33
|
+
*
|
|
34
|
+
* @param {Array} arr An array of address objects
|
|
35
|
+
* @return {Array} A list of addresses
|
|
36
|
+
*/
|
|
37
|
+
function processAddress(arr, def) {
|
|
38
|
+
let list = [].concat(arr || []);
|
|
39
|
+
if (!list.length) {
|
|
40
|
+
list = [].concat(def || []);
|
|
41
|
+
}
|
|
42
|
+
if (!list.length) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let result = [];
|
|
46
|
+
list.forEach(addr => {
|
|
47
|
+
if (addr.group) {
|
|
48
|
+
// Handle group syntax
|
|
49
|
+
result.push([null, null, addr.name || '', null]);
|
|
50
|
+
result = result.concat(processAddress(addr.group) || []);
|
|
51
|
+
result.push([null, null, null, null]);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
let name = addr.name || null;
|
|
55
|
+
let address = addr.address || '';
|
|
56
|
+
if (!address && name) {
|
|
57
|
+
// a bare word ("To: localuser") is the mailbox, not the name
|
|
58
|
+
address = name;
|
|
59
|
+
name = null;
|
|
60
|
+
}
|
|
61
|
+
if (!address) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const at = address.lastIndexOf('@');
|
|
65
|
+
const user = at >= 0 ? address.substr(0, at) : address;
|
|
66
|
+
// RFC 3501 7.4.2 reserves a NIL host for group markers, so an address without a domain gets
|
|
67
|
+
// the placeholder host that Dovecot uses for the same input
|
|
68
|
+
const domain = (at >= 0 ? address.substr(at + 1) : '') || 'MISSING_DOMAIN';
|
|
69
|
+
result.push([name, null, user || null, domain]);
|
|
70
|
+
});
|
|
71
|
+
// env-from = "(" 1*address ")", there is no SP between the addresses (RFC 3501 section 9)
|
|
72
|
+
Object.defineProperty(result, 'adjacentLists', { value: true });
|
|
73
|
+
return result.length ? result : null;
|
|
74
|
+
}
|
|
75
|
+
{
|
|
76
|
+
const defaultExport = exports.default;
|
|
77
|
+
if (defaultExport && (typeof defaultExport === 'function' || typeof defaultExport === 'object')) {
|
|
78
|
+
for (const key of Object.keys(exports)) {
|
|
79
|
+
if (key !== 'default' && !(key in defaultExport)) {
|
|
80
|
+
defaultExport[key] = exports[key];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
Object.defineProperty(defaultExport, 'default', { value: defaultExport, enumerable: false, writable: true, configurable: true });
|
|
84
|
+
module.exports = defaultExport;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { SearchResult } from './commands/handlers/search.js';
|
|
2
|
+
import type { Attribute, IMAPResponse, IMAPServer, Mailbox, Message } from './types.js';
|
|
3
|
+
/** A parsed PARTIAL range, see parsePartialRange() */
|
|
4
|
+
export interface PartialRange {
|
|
5
|
+
/** the argument as the client sent it */
|
|
6
|
+
range: string;
|
|
7
|
+
from: number;
|
|
8
|
+
to: number;
|
|
9
|
+
/** partial-range-last, counted from the last result */
|
|
10
|
+
fromEnd: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** Upper case result option names to their arguments (`parsed.searchReturn`), PARTIAL has its parsed range */
|
|
13
|
+
export type SearchReturn = Map<string, any>;
|
|
14
|
+
/** The parts of a search result that the ESEARCH response is built from */
|
|
15
|
+
export type EsearchResult = Pick<SearchResult, 'list' | 'numbers'>;
|
|
16
|
+
/**
|
|
17
|
+
* ESEARCH response helpers (RFC 4731, RFC 4466 section 2.6.2). Used by the ESEARCH, SEARCHRES, PARTIAL,
|
|
18
|
+
* CONTEXT=SEARCH and MULTISEARCH plugins, and meant to be reused where SEARCH always answers with ESEARCH (IMAP4rev2, RFC 9051).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Formats a list of numbers as a compact sequence-set, e.g. [1, 2, 3, 5] becomes "1:3,5"
|
|
22
|
+
*
|
|
23
|
+
* @param {Array} numbers List of nz-numbers, in any order
|
|
24
|
+
* @return {String} sequence-set, empty for an empty list
|
|
25
|
+
*/
|
|
26
|
+
declare function toSequenceSet(numbers: Iterable<number>): string;
|
|
27
|
+
/**
|
|
28
|
+
* Formats a list of numbers as a sequence-set that keeps their order, for SORT results (RFC 5267
|
|
29
|
+
* section 3.2): only runs of ascending consecutive numbers become ranges, e.g. [5, 3, 4, 2] becomes "5,3:4,2"
|
|
30
|
+
*
|
|
31
|
+
* @param {Array} numbers List of nz-numbers in the requested order
|
|
32
|
+
* @return {String} sequence-set, empty for an empty list
|
|
33
|
+
*/
|
|
34
|
+
declare function toOrderedSet(numbers: number[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* Parses the argument of the PARTIAL search return option (RFC 5267 section 4.4, RFC 9394 section 4):
|
|
37
|
+
* partial-range-first = nz-number ":" nz-number, partial-range-last = "-" nz-number ":" "-" nz-number.
|
|
38
|
+
* "*" is not allowed, and 500:400 is the same as 400:500
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} item Parsed argument
|
|
41
|
+
* @param {Boolean} allowLast If true, the partial-range-last form of RFC 9394 is accepted
|
|
42
|
+
* @return {Object} `{ range, from, to, fromEnd }`, `range` is the argument as the client sent it
|
|
43
|
+
*/
|
|
44
|
+
declare function parsePartialRange(item: Attribute, allowLast: boolean): PartialRange;
|
|
45
|
+
/**
|
|
46
|
+
* Picks the results that a PARTIAL range refers to. The first result is 1, and -1 is the last one
|
|
47
|
+
* (RFC 9394 section 3.1). Results outside the list are left out
|
|
48
|
+
*
|
|
49
|
+
* @param {Array} list Results in mailbox order
|
|
50
|
+
* @param {Object} partial Parsed range, see parsePartialRange
|
|
51
|
+
* @return {Array} results in the range, in mailbox order
|
|
52
|
+
*/
|
|
53
|
+
declare function selectPartial<T>(list: T[], partial: PartialRange): T[];
|
|
54
|
+
/**
|
|
55
|
+
* Registers the PARTIAL search return option, shared by the PARTIAL and CONTEXT=SEARCH plugins. The
|
|
56
|
+
* partial-range-last form (-1:-100) is only valid with the PARTIAL capability (RFC 9394 section 4)
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} server IMAP server, with the ESEARCH plugin loaded
|
|
59
|
+
*/
|
|
60
|
+
declare function registerPartialOption(server: IMAPServer): void;
|
|
61
|
+
/**
|
|
62
|
+
* Picks the messages that the requested result options return. With COUNT or ALL, or without
|
|
63
|
+
* MIN, MAX and PARTIAL, these are all matching messages, otherwise the lowest and/or the highest
|
|
64
|
+
* matching message and the ones in the PARTIAL range. This is the set that the MODSEQ result
|
|
65
|
+
* option describes (RFC 4731 section 3.2) and that SAVE stores (RFC 5182 section 2.4, RFC 9394
|
|
66
|
+
* section 3.2)
|
|
67
|
+
*
|
|
68
|
+
* @param {Array} list Matching messages, in mailbox order
|
|
69
|
+
* @param {Map} options Upper case result option names to their arguments, an empty map stands for ALL
|
|
70
|
+
* @return {Array} returned messages, in mailbox order
|
|
71
|
+
*/
|
|
72
|
+
declare function selectReturned<T>(list: T[], options: SearchReturn): T[];
|
|
73
|
+
/**
|
|
74
|
+
* Builds the search correlator (RFC 4466 section 2.6.2), with the MAILBOX and UIDVALIDITY
|
|
75
|
+
* correlators of RFC 7377 section 4 if a mailbox is given
|
|
76
|
+
*
|
|
77
|
+
* @param {String} tag Tag of the command
|
|
78
|
+
* @param {Object} [mailbox] Mailbox the response is about
|
|
79
|
+
* @return {Array} correlator list
|
|
80
|
+
*/
|
|
81
|
+
declare function buildCorrelator(tag: string, mailbox?: Mailbox | null): Attribute[];
|
|
82
|
+
/**
|
|
83
|
+
* Builds an ESEARCH response (RFC 4466 section 2.6.2) with the RFC 4731 section 3.1 return data
|
|
84
|
+
* and PARTIAL (RFC 5267 section 4.4, RFC 9394 section 3.1)
|
|
85
|
+
*
|
|
86
|
+
* @param {String} tag Tag of the command, for the search correlator
|
|
87
|
+
* @param {Boolean} isUid If true, the response lists UIDs and has the UID indicator
|
|
88
|
+
* @param {Object} result Search result, `{ list, numbers }` (see src/commands/handlers/search.ts)
|
|
89
|
+
* @param {Map} options Upper case result option names to their arguments, an empty map stands for ALL (RFC 4731 section 3.1)
|
|
90
|
+
* @param {Object} [mailbox] Adds the MAILBOX and UIDVALIDITY correlators of RFC 7377 for this mailbox
|
|
91
|
+
* @param {Array} [sorted] The matching messages in sort order, for an extended SORT (RFC 5267 section 3.1): MIN and MAX are
|
|
92
|
+
* the first and the last sorted message, ALL and PARTIAL list the results in sort order
|
|
93
|
+
* @return {Object} response for connection.send()
|
|
94
|
+
*/
|
|
95
|
+
declare function buildEsearchResponse(tag: string, isUid: boolean, result: EsearchResult, options: SearchReturn, mailbox?: Mailbox | null, sorted?: Message[] | null): IMAPResponse;
|
|
96
|
+
export { toSequenceSet, toOrderedSet, selectReturned, selectPartial, parsePartialRange, registerPartialOption, buildCorrelator, buildEsearchResponse };
|