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,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.updateSession = updateSession;
|
|
37
|
+
const node_buffer_1 = require("node:buffer");
|
|
38
|
+
const mailbox_name_js_1 = __importStar(require("./mailbox-name.js"));
|
|
39
|
+
const enable_js_1 = require("./plugins/enable.js");
|
|
40
|
+
/**
|
|
41
|
+
* UTF-8 support of a session, shared by the UTF8=ACCEPT (RFC 9755) and IMAP4rev2 (RFC 9051) plugins. Both
|
|
42
|
+
* turn on UTF-8 mailbox names and quoted strings with ENABLE, and they can be loaded in any order, so the
|
|
43
|
+
* state of a session is always computed from what it has enabled, see updateSession().
|
|
44
|
+
*/
|
|
45
|
+
// RFC 9755 section 3: mailbox names MUST NOT contain control characters, DEL, LINE SEPARATOR or
|
|
46
|
+
// PARAGRAPH SEPARATOR. RFC 5198 section 2 (Net-Unicode) also forbids a leading BOM and unassigned code points
|
|
47
|
+
// eslint-disable-next-line no-control-regex
|
|
48
|
+
const INVALID_NAME_CHARS = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]|^\ufeff|\p{Cn}/u;
|
|
49
|
+
function badError(message) {
|
|
50
|
+
const err = new Error(message);
|
|
51
|
+
err.imapResponse = 'BAD';
|
|
52
|
+
return err;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Throws a BAD error for a mailbox name that is not Net-Unicode (RFC 9755 section 3, RFC 9051 section 5.1).
|
|
56
|
+
* RFC 5198 section 2 also requires Normalization Form C
|
|
57
|
+
*
|
|
58
|
+
* @param {String|Boolean} decoded Mailbox name as a unicode string, false if it could not be decoded
|
|
59
|
+
* @return {String} the decoded name
|
|
60
|
+
*/
|
|
61
|
+
function checkNetUnicode(decoded) {
|
|
62
|
+
if (decoded === false || INVALID_NAME_CHARS.test(decoded)) {
|
|
63
|
+
throw badError('Mailbox name must be valid Net-Unicode without control characters (RFC 9755 section 3)');
|
|
64
|
+
}
|
|
65
|
+
if (decoded.normalize('NFC') !== decoded) {
|
|
66
|
+
throw badError('Mailbox name must be in Unicode Normalization Form C (RFC 5198 section 2, RFC 9051 section 5.1)');
|
|
67
|
+
}
|
|
68
|
+
return decoded;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks a modified UTF-7 mailbox name from a client that did not enable UTF-8. The RFC 9755
|
|
72
|
+
* section 3 rules apply to these names as well, e.g. "&AA0-" encodes CR
|
|
73
|
+
*
|
|
74
|
+
* @param {String} name Mailbox name as a binary string
|
|
75
|
+
* @return {String} Storage name
|
|
76
|
+
* @throws {Error} BAD error if the name is not valid
|
|
77
|
+
*/
|
|
78
|
+
function importMutf7Name(name) {
|
|
79
|
+
const error = (0, mailbox_name_js_1.default)(name);
|
|
80
|
+
if (error) {
|
|
81
|
+
throw badError(error);
|
|
82
|
+
}
|
|
83
|
+
checkNetUnicode((0, mailbox_name_js_1.decode)(name));
|
|
84
|
+
return name;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Converts a UTF-8 mailbox name from the client to the modified UTF-7 storage name
|
|
88
|
+
*
|
|
89
|
+
* @param {String} name Mailbox name as a binary string
|
|
90
|
+
* @return {String} Storage name
|
|
91
|
+
* @throws {Error} BAD error if the name is not valid
|
|
92
|
+
*/
|
|
93
|
+
function importUtf8Name(name) {
|
|
94
|
+
const buf = Buffer.from(name, 'binary');
|
|
95
|
+
return (0, mailbox_name_js_1.encode)(checkNetUnicode((0, node_buffer_1.isUtf8)(buf) && buf.toString('utf-8')));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Converts a modified UTF-7 storage name to UTF-8. A name that is not valid modified UTF-7
|
|
99
|
+
* is sent as it is.
|
|
100
|
+
*
|
|
101
|
+
* @param {String} path Storage name
|
|
102
|
+
* @return {String} Mailbox name as a binary string
|
|
103
|
+
*/
|
|
104
|
+
function exportUtf8Name(path) {
|
|
105
|
+
const decoded = (0, mailbox_name_js_1.decode)(path);
|
|
106
|
+
return decoded === false ? path : Buffer.from(decoded, 'utf-8').toString('binary');
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sets the UTF-8 options of a session from the extensions it has enabled. Run it when the session starts,
|
|
110
|
+
* after ENABLE and after UNAUTHENTICATE (once the ENABLE plugin has cleared `connection.enabled`).
|
|
111
|
+
*
|
|
112
|
+
* - With the UTF8=ACCEPT plugin, quoted strings may hold UTF-8 even before ENABLE (RFC 9755 section 3) and
|
|
113
|
+
* modified UTF-7 names must decode to Net-Unicode. Without it, 8-bit quoted strings are a syntax error until
|
|
114
|
+
* ENABLE IMAP4rev2, like RFC 3501 says
|
|
115
|
+
* - ENABLE UTF8=ACCEPT or IMAP4rev2: mailbox names are UTF-8 in both directions and strings that are valid
|
|
116
|
+
* UTF-8 are sent quoted (RFC 9755 section 3, RFC 9051 sections 4.3 and 5.1)
|
|
117
|
+
* - ENABLE UTF8=ACCEPT: SEARCH strings are UTF-8 and CHARSET is refused (RFC 9755 section 3)
|
|
118
|
+
* - ENABLE IMAP4rev2: SEARCH strings are UTF-8 unless a CHARSET says otherwise (RFC 9051 section 6.4.4)
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} connection IMAP connection
|
|
121
|
+
*/
|
|
122
|
+
function updateSession(connection) {
|
|
123
|
+
const server = connection.server;
|
|
124
|
+
const accept = (0, enable_js_1.isEnabled)(connection, 'UTF8=ACCEPT');
|
|
125
|
+
const rev2 = (0, enable_js_1.isEnabled)(connection, 'IMAP4rev2');
|
|
126
|
+
const utf8Names = accept || rev2;
|
|
127
|
+
// UTF-8 names and quoted strings are on, plugins check this instead of the extension names
|
|
128
|
+
connection.utf8Enabled = utf8Names;
|
|
129
|
+
connection.parserOptions.utf8 = !!server.utf8Accept || rev2;
|
|
130
|
+
connection.compilerOptions.utf8 = utf8Names;
|
|
131
|
+
connection.searchCharset = accept ? 'UTF-8' : false;
|
|
132
|
+
connection.defaultSearchCharset = rev2 ? 'UTF-8' : false;
|
|
133
|
+
if (utf8Names) {
|
|
134
|
+
connection.importMailboxName = importUtf8Name;
|
|
135
|
+
connection.exportMailboxName = exportUtf8Name;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// back to the IMAPConnection methods, the overrides are own properties of the connection
|
|
139
|
+
const overrides = connection;
|
|
140
|
+
delete overrides.exportMailboxName;
|
|
141
|
+
if (server.utf8Accept) {
|
|
142
|
+
connection.importMailboxName = importMutf7Name;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
delete overrides.importMailboxName;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VANISHED responses (RFC 7162 section 3.2.10) in place of EXPUNGE notifications. Used by QRESYNC
|
|
3
|
+
* and by UIDONLY (RFC 9586 section 3.4), which both report expunged messages by UID.
|
|
4
|
+
*/
|
|
5
|
+
import type { IMAPResponse, Notification } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a queued notification is an EXPUNGE response for a removed message
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} notification Queued notification
|
|
10
|
+
* @return {Boolean} true for an EXPUNGE notification
|
|
11
|
+
*/
|
|
12
|
+
declare function isExpungeNotification(notification: Notification): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Replaces the EXPUNGE notifications of a queue with VANISHED responses, consecutive EXPUNGE
|
|
15
|
+
* notifications become one VANISHED response. The queue is not changed
|
|
16
|
+
*
|
|
17
|
+
* @param {Array} queue Queued notifications
|
|
18
|
+
* @return {Array} notifications to send
|
|
19
|
+
*/
|
|
20
|
+
declare function toVanished(queue: Notification[]): IMAPResponse[];
|
|
21
|
+
export { isExpungeNotification, toVanished };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* VANISHED responses (RFC 7162 section 3.2.10) in place of EXPUNGE notifications. Used by QRESYNC
|
|
4
|
+
* and by UIDONLY (RFC 9586 section 3.4), which both report expunged messages by UID.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.isExpungeNotification = isExpungeNotification;
|
|
8
|
+
exports.toVanished = toVanished;
|
|
9
|
+
const esearch_js_1 = require("./esearch.js");
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a queued notification is an EXPUNGE response for a removed message
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} notification Queued notification
|
|
14
|
+
* @return {Boolean} true for an EXPUNGE notification
|
|
15
|
+
*/
|
|
16
|
+
function isExpungeNotification(notification) {
|
|
17
|
+
const name = !!notification.message && !!notification.attributes && notification.attributes[1];
|
|
18
|
+
return !!name && name.type === 'ATOM' && String(name.value).toUpperCase() === 'EXPUNGE';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Replaces the EXPUNGE notifications of a queue with VANISHED responses, consecutive EXPUNGE
|
|
22
|
+
* notifications become one VANISHED response. The queue is not changed
|
|
23
|
+
*
|
|
24
|
+
* @param {Array} queue Queued notifications
|
|
25
|
+
* @return {Array} notifications to send
|
|
26
|
+
*/
|
|
27
|
+
function toVanished(queue) {
|
|
28
|
+
if (!queue.some(isExpungeNotification)) {
|
|
29
|
+
return queue;
|
|
30
|
+
}
|
|
31
|
+
// groups of consecutive expunges, as lists of UIDs, between the other notifications
|
|
32
|
+
const groups = [];
|
|
33
|
+
queue.forEach(notification => {
|
|
34
|
+
if (!isExpungeNotification(notification)) {
|
|
35
|
+
groups.push(notification);
|
|
36
|
+
}
|
|
37
|
+
else if (Array.isArray(groups[groups.length - 1])) {
|
|
38
|
+
// an EXPUNGE notification always carries its message
|
|
39
|
+
groups[groups.length - 1].push(notification.message);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
groups.push([notification.message]);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// the removed messages go with the response for output handlers, like `message` of EXPUNGE
|
|
46
|
+
return groups.map(group => Array.isArray(group)
|
|
47
|
+
? {
|
|
48
|
+
tag: '*',
|
|
49
|
+
command: 'VANISHED',
|
|
50
|
+
attributes: [{ type: 'SEQUENCE', value: (0, esearch_js_1.toSequenceSet)(group.map(message => message.uid)) }],
|
|
51
|
+
notification: true,
|
|
52
|
+
messages: group
|
|
53
|
+
}
|
|
54
|
+
: group);
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** An address, or a group with its member addresses */
|
|
2
|
+
export interface ParsedAddress {
|
|
3
|
+
name: string;
|
|
4
|
+
address?: string;
|
|
5
|
+
group?: ParsedAddress[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parses structured e-mail addresses from an address field
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
*
|
|
12
|
+
* "Name <address@domain>"
|
|
13
|
+
*
|
|
14
|
+
* will be converted to
|
|
15
|
+
*
|
|
16
|
+
* [{name: "Name", address: "address@domain"}]
|
|
17
|
+
*
|
|
18
|
+
* @param {String} str Address field
|
|
19
|
+
* @return {Array} An array of address objects
|
|
20
|
+
*/
|
|
21
|
+
export default function parse(str: string, inGroup?: boolean): ParsedAddress[];
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Parses structured e-mail addresses from an address field
|
|
5
3
|
*
|
|
@@ -14,39 +12,34 @@
|
|
|
14
12
|
* @param {String} str Address field
|
|
15
13
|
* @return {Array} An array of address objects
|
|
16
14
|
*/
|
|
17
|
-
|
|
15
|
+
export default function parse(str, inGroup) {
|
|
18
16
|
const tokenizer = new Tokenizer(str);
|
|
19
17
|
const tokens = tokenizer.tokenize();
|
|
20
|
-
|
|
21
18
|
const addresses = [];
|
|
22
19
|
let address = [];
|
|
23
20
|
let parsedAddresses = [];
|
|
24
|
-
|
|
25
21
|
tokens.forEach(token => {
|
|
26
22
|
if (token.type === 'operator' && (token.value === ',' || token.value === ';')) {
|
|
27
23
|
if (address.length) {
|
|
28
24
|
addresses.push(address);
|
|
29
25
|
}
|
|
30
26
|
address = [];
|
|
31
|
-
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
32
29
|
address.push(token);
|
|
33
30
|
}
|
|
34
31
|
});
|
|
35
|
-
|
|
36
32
|
if (address.length) {
|
|
37
33
|
addresses.push(address);
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
addresses.forEach(address => {
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
parsedAddresses = parsedAddresses.concat(
|
|
36
|
+
const handled = _handleAddress(address, inGroup);
|
|
37
|
+
if (handled.length) {
|
|
38
|
+
parsedAddresses = parsedAddresses.concat(handled);
|
|
44
39
|
}
|
|
45
40
|
});
|
|
46
|
-
|
|
47
41
|
return parsedAddresses;
|
|
48
|
-
}
|
|
49
|
-
|
|
42
|
+
}
|
|
50
43
|
/**
|
|
51
44
|
* Converts tokens for a single address into an address object
|
|
52
45
|
*
|
|
@@ -69,11 +62,9 @@ function _handleAddress(tokens, inGroup) {
|
|
|
69
62
|
};
|
|
70
63
|
let i;
|
|
71
64
|
let len;
|
|
72
|
-
|
|
73
65
|
// Filter out <addresses>, (comments) and regular text
|
|
74
66
|
for (i = 0, len = tokens.length; i < len; i++) {
|
|
75
67
|
token = tokens[i];
|
|
76
|
-
|
|
77
68
|
if (token.type === 'operator') {
|
|
78
69
|
switch (token.value) {
|
|
79
70
|
case '<':
|
|
@@ -93,27 +84,28 @@ function _handleAddress(tokens, inGroup) {
|
|
|
93
84
|
default:
|
|
94
85
|
state = 'text';
|
|
95
86
|
}
|
|
96
|
-
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
97
89
|
if (token.value) {
|
|
98
90
|
data[state].push(token.value);
|
|
99
91
|
}
|
|
100
92
|
}
|
|
101
93
|
}
|
|
102
|
-
|
|
103
94
|
// If there is no text but a comment, replace the two
|
|
104
95
|
if (!data.text.length && data.comment.length) {
|
|
105
96
|
data.text = data.comment;
|
|
106
97
|
data.comment = [];
|
|
107
98
|
}
|
|
108
|
-
|
|
109
99
|
if (isGroup) {
|
|
110
100
|
// http://tools.ietf.org/html/rfc2822#appendix-A.1.3
|
|
111
|
-
|
|
101
|
+
const text = data.text.join(' ');
|
|
112
102
|
addresses.push({
|
|
113
|
-
name
|
|
103
|
+
// address is never set here, so an empty group name throws like the JavaScript original did
|
|
104
|
+
name: text || address.name,
|
|
114
105
|
group: data.group.length ? parse(data.group.join(','), true) : []
|
|
115
106
|
});
|
|
116
|
-
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
117
109
|
// If no address was found, try to detect one from regular text
|
|
118
110
|
if (!data.address.length && data.text.length) {
|
|
119
111
|
for (i = data.text.length - 1; i >= 0; i--) {
|
|
@@ -122,16 +114,15 @@ function _handleAddress(tokens, inGroup) {
|
|
|
122
114
|
break;
|
|
123
115
|
}
|
|
124
116
|
}
|
|
125
|
-
|
|
126
117
|
const _regexHandler = function (address) {
|
|
127
118
|
if (!data.address.length) {
|
|
128
119
|
data.address = [address.trim()];
|
|
129
120
|
return ' ';
|
|
130
|
-
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
131
123
|
return address;
|
|
132
124
|
}
|
|
133
125
|
};
|
|
134
|
-
|
|
135
126
|
// still no address
|
|
136
127
|
if (!data.address.length) {
|
|
137
128
|
for (i = data.text.length - 1; i >= 0; i--) {
|
|
@@ -142,61 +133,123 @@ function _handleAddress(tokens, inGroup) {
|
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
135
|
}
|
|
145
|
-
|
|
146
136
|
// If there's still is no text but a comment exixts, replace the two
|
|
147
137
|
if (!data.text.length && data.comment.length) {
|
|
148
138
|
data.text = data.comment;
|
|
149
139
|
data.comment = [];
|
|
150
140
|
}
|
|
151
|
-
|
|
152
141
|
// Keep only the first address occurence, push others to regular text
|
|
153
142
|
if (data.address.length > 1) {
|
|
154
143
|
data.text = data.text.concat(data.address.splice(1));
|
|
155
144
|
}
|
|
156
|
-
|
|
157
145
|
// Join values with spaces
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (!data.address && isGroup) {
|
|
146
|
+
const text = data.text.join(' ');
|
|
147
|
+
const addressText = data.address.join(' ');
|
|
148
|
+
if (!addressText && isGroup) {
|
|
162
149
|
return [];
|
|
163
|
-
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
164
152
|
address = {
|
|
165
|
-
address:
|
|
166
|
-
name:
|
|
153
|
+
address: addressText || text || '',
|
|
154
|
+
name: text || addressText || ''
|
|
167
155
|
};
|
|
168
|
-
|
|
169
156
|
if (address.address === address.name) {
|
|
170
157
|
if ((address.address || '').match(/@/)) {
|
|
171
158
|
address.name = '';
|
|
172
|
-
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
173
161
|
address.address = '';
|
|
174
162
|
}
|
|
175
163
|
}
|
|
176
|
-
|
|
177
164
|
addresses.push(address);
|
|
178
165
|
}
|
|
179
166
|
}
|
|
180
|
-
|
|
181
167
|
return addresses;
|
|
182
168
|
}
|
|
183
|
-
|
|
184
169
|
/**
|
|
185
170
|
* Creates a Tokenizer object for tokenizing address field strings
|
|
186
171
|
*
|
|
187
172
|
* @constructor
|
|
188
173
|
* @param {String} str Address field string
|
|
189
174
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
175
|
+
class Tokenizer {
|
|
176
|
+
constructor(str) {
|
|
177
|
+
this.str = (str || '').toString();
|
|
178
|
+
this.operatorCurrent = '';
|
|
179
|
+
this.operatorExpecting = '';
|
|
180
|
+
this.node = null;
|
|
181
|
+
this.escaped = false;
|
|
182
|
+
this.list = [];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Tokenizes the original input string
|
|
186
|
+
*
|
|
187
|
+
* @return {Array} An array of operator|text tokens
|
|
188
|
+
*/
|
|
189
|
+
tokenize() {
|
|
190
|
+
let chr;
|
|
191
|
+
const list = [];
|
|
192
|
+
for (let i = 0, len = this.str.length; i < len; i++) {
|
|
193
|
+
chr = this.str.charAt(i);
|
|
194
|
+
this.checkChar(chr);
|
|
195
|
+
}
|
|
196
|
+
this.list.forEach(node => {
|
|
197
|
+
node.value = (node.value || '').toString().trim();
|
|
198
|
+
if (node.value) {
|
|
199
|
+
list.push(node);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return list;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Checks if a character is an operator or text and acts accordingly
|
|
206
|
+
*
|
|
207
|
+
* @param {String} chr Character from the address field
|
|
208
|
+
*/
|
|
209
|
+
checkChar(chr) {
|
|
210
|
+
if ((chr in this.operators || chr === '\\') && this.escaped) {
|
|
211
|
+
this.escaped = false;
|
|
212
|
+
}
|
|
213
|
+
else if (this.operatorExpecting && chr === this.operatorExpecting) {
|
|
214
|
+
this.node = {
|
|
215
|
+
type: 'operator',
|
|
216
|
+
value: chr
|
|
217
|
+
};
|
|
218
|
+
this.list.push(this.node);
|
|
219
|
+
this.node = null;
|
|
220
|
+
this.operatorExpecting = '';
|
|
221
|
+
this.escaped = false;
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
else if (!this.operatorExpecting && chr in this.operators) {
|
|
225
|
+
this.node = {
|
|
226
|
+
type: 'operator',
|
|
227
|
+
value: chr
|
|
228
|
+
};
|
|
229
|
+
this.list.push(this.node);
|
|
230
|
+
this.node = null;
|
|
231
|
+
this.operatorExpecting = this.operators[chr];
|
|
232
|
+
this.escaped = false;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (!this.escaped && chr === '\\') {
|
|
236
|
+
this.escaped = true;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (!this.node) {
|
|
240
|
+
this.node = {
|
|
241
|
+
type: 'text',
|
|
242
|
+
value: ''
|
|
243
|
+
};
|
|
244
|
+
this.list.push(this.node);
|
|
245
|
+
}
|
|
246
|
+
if (this.escaped && chr !== '\\') {
|
|
247
|
+
this.node.value += '\\';
|
|
248
|
+
}
|
|
249
|
+
this.node.value += chr;
|
|
250
|
+
this.escaped = false;
|
|
251
|
+
}
|
|
198
252
|
}
|
|
199
|
-
|
|
200
253
|
/**
|
|
201
254
|
* Operator tokens and which tokens are expected to end the sequence
|
|
202
255
|
*/
|
|
@@ -207,77 +260,3 @@ Tokenizer.prototype.operators = {
|
|
|
207
260
|
',': '',
|
|
208
261
|
':': ';'
|
|
209
262
|
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Tokenizes the original input string
|
|
213
|
-
*
|
|
214
|
-
* @return {Array} An array of operator|text tokens
|
|
215
|
-
*/
|
|
216
|
-
Tokenizer.prototype.tokenize = function () {
|
|
217
|
-
let chr;
|
|
218
|
-
const list = [];
|
|
219
|
-
for (let i = 0, len = this.str.length; i < len; i++) {
|
|
220
|
-
chr = this.str.charAt(i);
|
|
221
|
-
this.checkChar(chr);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
this.list.forEach(node => {
|
|
225
|
-
node.value = (node.value || '').toString().trim();
|
|
226
|
-
if (node.value) {
|
|
227
|
-
list.push(node);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
return list;
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Checks if a character is an operator or text and acts accordingly
|
|
236
|
-
*
|
|
237
|
-
* @param {String} chr Character from the address field
|
|
238
|
-
*/
|
|
239
|
-
Tokenizer.prototype.checkChar = function (chr) {
|
|
240
|
-
if ((chr in this.operators || chr === '\\') && this.escaped) {
|
|
241
|
-
this.escaped = false;
|
|
242
|
-
} else if (this.operatorExpecting && chr === this.operatorExpecting) {
|
|
243
|
-
this.node = {
|
|
244
|
-
type: 'operator',
|
|
245
|
-
value: chr
|
|
246
|
-
};
|
|
247
|
-
this.list.push(this.node);
|
|
248
|
-
this.node = null;
|
|
249
|
-
this.operatorExpecting = '';
|
|
250
|
-
this.escaped = false;
|
|
251
|
-
return;
|
|
252
|
-
} else if (!this.operatorExpecting && chr in this.operators) {
|
|
253
|
-
this.node = {
|
|
254
|
-
type: 'operator',
|
|
255
|
-
value: chr
|
|
256
|
-
};
|
|
257
|
-
this.list.push(this.node);
|
|
258
|
-
this.node = null;
|
|
259
|
-
this.operatorExpecting = this.operators[chr];
|
|
260
|
-
this.escaped = false;
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (!this.escaped && chr === '\\') {
|
|
265
|
-
this.escaped = true;
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
if (!this.node) {
|
|
270
|
-
this.node = {
|
|
271
|
-
type: 'text',
|
|
272
|
-
value: ''
|
|
273
|
-
};
|
|
274
|
-
this.list.push(this.node);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (this.escaped && chr !== '\\') {
|
|
278
|
-
this.node.value += '\\';
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
this.node.value += chr;
|
|
282
|
-
this.escaped = false;
|
|
283
|
-
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Attribute, ParsedCommand } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a parsed argument is an atom, optionally a specific one
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} value Parsed argument
|
|
6
|
+
* @param {String} [name] Upper case atom to match, the value is compared case-insensitively
|
|
7
|
+
* @return {Boolean} true for an atom (with that name)
|
|
8
|
+
*/
|
|
9
|
+
declare function isAtom(value: Attribute, name?: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a parsed argument is an astring (RFC 3501 section 9): an atom, a quoted string or a literal. An
|
|
12
|
+
* atom the parser split into a section or partial range (like BODY[1]<0.5>) is not
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} value Parsed argument
|
|
15
|
+
* @return {Boolean} true for an astring
|
|
16
|
+
*/
|
|
17
|
+
declare function isAstring(value: Attribute): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The parser turns every NIL atom into null, as in an nstring. Where the grammar has an astring (mailbox names, user
|
|
20
|
+
* names, search strings, ...) NIL is an ordinary atom, so these nulls are turned back into atoms with the spelling
|
|
21
|
+
* the client used
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} parsed Parsed command, changed in place
|
|
24
|
+
* @param {String} data Raw command line with its literals
|
|
25
|
+
* @param {Function} select `(path)` returns true for the nulls to restore, `path` lists the indexes from the
|
|
26
|
+
* top-level arguments down, e.g. [2, 0] for the first item of a list in the third argument
|
|
27
|
+
*/
|
|
28
|
+
/** Indexes from the top-level arguments down to a nested value, `'section'` steps into the section of an atom */
|
|
29
|
+
export type ArgumentPath = (number | string)[];
|
|
30
|
+
declare function restoreNilAtoms(parsed: ParsedCommand, data: string, select: (path: ArgumentPath) => boolean): void;
|
|
31
|
+
export { isAtom, isAstring, restoreNilAtoms };
|