emailengine-app 2.84.2 → 2.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.ncurc.js +29 -9
  2. package/.prettierignore +5 -1
  3. package/.prettierrc.js +2 -0
  4. package/.release-please-manifest.json +1 -1
  5. package/CHANGELOG.md +107 -0
  6. package/Dockerfile +20 -1
  7. package/ENVIRONMENT.md +139 -0
  8. package/README.md +2 -2
  9. package/bin/emailengine.js +434 -408
  10. package/config/default.toml +2 -0
  11. package/copy-static-files.sh +41 -14
  12. package/data/google-crawlers.json +1 -1
  13. package/data/public_suffix_list.dat +16563 -0
  14. package/eslint.config.js +81 -99
  15. package/lib/account-assignment.js +19 -0
  16. package/lib/account.js +230 -170
  17. package/lib/api-error-codes.js +49 -0
  18. package/lib/api-reference/format.js +4 -3
  19. package/lib/api-reference/model.js +6 -1
  20. package/lib/api-routes/account-routes.js +255 -38
  21. package/lib/api-routes/blocklist-routes.js +91 -4
  22. package/lib/api-routes/delivery-test-routes.js +27 -4
  23. package/lib/api-routes/export-routes.js +28 -2
  24. package/lib/api-routes/gateway-routes.js +110 -12
  25. package/lib/api-routes/index.js +4 -0
  26. package/lib/api-routes/license-routes.js +2 -2
  27. package/lib/api-routes/mailbox-routes.js +44 -5
  28. package/lib/api-routes/message-routes.js +112 -10
  29. package/lib/api-routes/oauth2-app-routes.js +63 -23
  30. package/lib/api-routes/outbox-routes.js +97 -52
  31. package/lib/api-routes/permission-map.js +67 -7
  32. package/lib/api-routes/scoped-routes.js +74 -0
  33. package/lib/api-routes/settings-routes.js +34 -6
  34. package/lib/api-routes/stats-routes.js +5 -1
  35. package/lib/api-routes/submit-routes.js +337 -309
  36. package/lib/api-routes/template-routes.js +45 -8
  37. package/lib/api-routes/token-routes.js +152 -100
  38. package/lib/api-routes/webhook-delivery-routes.js +262 -0
  39. package/lib/api-routes/webhook-route-routes.js +132 -6
  40. package/lib/bounce-detect.js +397 -205
  41. package/lib/calendar-event.js +81 -1
  42. package/lib/consts.js +38 -45
  43. package/lib/db.js +14 -6
  44. package/lib/delivery-error.js +6 -0
  45. package/lib/deprecations.js +270 -0
  46. package/lib/email-client/base-client.js +137 -184
  47. package/lib/email-client/fallback-poll.js +62 -0
  48. package/lib/email-client/gmail-client.js +60 -22
  49. package/lib/email-client/imap/adaptive-idle-store.js +73 -0
  50. package/lib/email-client/imap/adaptive-idle.js +278 -0
  51. package/lib/email-client/imap/connection-errors.js +14 -1
  52. package/lib/email-client/imap/idle-settings.js +31 -5
  53. package/lib/email-client/imap/listing-diff.js +37 -0
  54. package/lib/email-client/imap/mailbox.js +372 -242
  55. package/lib/email-client/imap/subconnection.js +8 -30
  56. package/lib/email-client/imap/sync-operations.js +220 -127
  57. package/lib/email-client/imap-client.js +228 -164
  58. package/lib/email-client/message-builder.js +14 -79
  59. package/lib/email-client/notification-handler.js +1 -2
  60. package/lib/email-client/outlook-client.js +372 -338
  61. package/lib/email-client/smtp-pool-manager.js +16 -13
  62. package/lib/email-client/sync-state-fields.js +19 -0
  63. package/lib/encrypt.js +157 -41
  64. package/lib/enum-descriptions.js +3 -1
  65. package/lib/env-setting-overrides.js +288 -0
  66. package/lib/export-worker.js +751 -0
  67. package/lib/export.js +64 -15
  68. package/lib/gateway.js +19 -4
  69. package/lib/get-raw-email.js +25 -107
  70. package/lib/hapi-request-logger.js +107 -0
  71. package/lib/health.js +75 -0
  72. package/lib/imapproxy/imap-core/README.md +6 -5
  73. package/lib/lock-run.js +119 -0
  74. package/lib/logger-consts.js +48 -0
  75. package/lib/logger.js +1 -1
  76. package/lib/lua/z-head-scores.lua +28 -0
  77. package/lib/mcp/tools.js +37 -8
  78. package/lib/network-errors.js +1 -1
  79. package/lib/node-version.js +24 -0
  80. package/lib/notify-attachments.js +36 -0
  81. package/lib/oauth/outlook-mailbox.js +35 -0
  82. package/lib/oauth/state.js +24 -0
  83. package/lib/oauth2-apps.js +631 -656
  84. package/lib/outbox.js +184 -54
  85. package/lib/parse-message.js +3 -3
  86. package/lib/pbkdf2-phc.js +1 -1
  87. package/lib/privileged-settings.js +2 -2
  88. package/lib/queue-browser/definitions.js +11 -0
  89. package/lib/queue-browser/index.js +68 -19
  90. package/lib/queue-job-actions.js +18 -1
  91. package/lib/queue-retention.js +48 -12
  92. package/lib/queue-stats.js +11 -2
  93. package/lib/read-env-value.js +3 -0
  94. package/lib/redis-memory-warnings.js +99 -0
  95. package/lib/redis-reconnect.js +29 -0
  96. package/lib/request-timing.js +23 -0
  97. package/lib/respawn-backoff.js +35 -0
  98. package/lib/rewrite-text-nodes.js +19 -59
  99. package/lib/schemas.js +164 -40
  100. package/lib/settings.js +6 -2
  101. package/lib/smtp-auth.js +19 -1
  102. package/lib/sso.js +1 -1
  103. package/lib/swagger-options.js +1 -1
  104. package/lib/thread-diagnostics.js +63 -0
  105. package/lib/timezones.js +109 -0
  106. package/lib/tls/provision.js +6 -3
  107. package/lib/token-audit-log.js +19 -20
  108. package/lib/token-permission-view.js +7 -6
  109. package/lib/tools.js +48 -51
  110. package/lib/totp.js +2 -5
  111. package/lib/translations.js +1 -2
  112. package/lib/ui-routes/account-routes.js +475 -454
  113. package/lib/ui-routes/account-setup.js +99 -0
  114. package/lib/ui-routes/admin-config-routes.js +152 -100
  115. package/lib/ui-routes/admin-entities-routes.js +93 -21
  116. package/lib/ui-routes/auth-routes.js +90 -38
  117. package/lib/ui-routes/imap-idle-field.js +1 -1
  118. package/lib/ui-routes/internals-routes.js +5 -0
  119. package/lib/ui-routes/oauth-config-routes.js +124 -82
  120. package/lib/ui-routes/outlook-subscription-view.js +1 -1
  121. package/lib/ui-routes/overridable-fields.js +84 -0
  122. package/lib/ui-routes/queue-routes.js +8 -5
  123. package/lib/ui-routes/route-helpers.js +19 -3
  124. package/lib/ui-routes/settings-page.js +6 -0
  125. package/lib/ui-routes/tls-config-routes.js +58 -15
  126. package/lib/utils/back-off.js +82 -0
  127. package/lib/utils/decode-headers.js +3 -12
  128. package/lib/utils/filter-empty.js +20 -0
  129. package/lib/utils/int-setting.js +48 -0
  130. package/lib/utils/murmurhash3.js +66 -0
  131. package/lib/utils/public-suffix.js +122 -0
  132. package/lib/utils/random-id.js +26 -0
  133. package/lib/utils/tracking-settings.js +35 -0
  134. package/lib/utils/version.js +74 -0
  135. package/lib/web-safe-html.js +18 -105
  136. package/lib/webhook-delivery.js +461 -0
  137. package/lib/webhook-failures.js +132 -0
  138. package/lib/webhook-request.js +29 -1
  139. package/lib/webhook-routing.js +56 -0
  140. package/lib/webhook-test.js +88 -0
  141. package/lib/webhooks.js +93 -45
  142. package/lib/worker-rpc-error.js +2 -1
  143. package/package.json +37 -38
  144. package/sbom.json +7902 -1
  145. package/server.js +784 -518
  146. package/static/js/ace/ace.js +1 -1
  147. package/static/licenses.html +225 -1060
  148. package/translations/messages.pot +62 -63
  149. package/views/config/ai.hbs +1 -1
  150. package/views/config/security.hbs +24 -2
  151. package/views/config/service.hbs +47 -0
  152. package/views/config/webhooks.hbs +36 -0
  153. package/views/internals/index.hbs +8 -0
  154. package/views/partials/queue_retention_note.hbs +12 -8
  155. package/views/partials/ui/env-managed-alert.hbs +16 -7
  156. package/views/partials/webhook_form.hbs +1 -1
  157. package/views/suppression-lists/index.hbs +1 -1
  158. package/workers/api.js +840 -611
  159. package/workers/export.js +17 -632
  160. package/workers/imap.js +13 -0
  161. package/workers/smtp.js +9 -11
  162. package/workers/submit.js +1 -1
  163. package/workers/webhooks.js +18 -448
  164. package/lib/email-client/outlook-fallback-poll.js +0 -30
@@ -38,6 +38,8 @@ maxSize = "5M" # maximum size of an attachment when submitting or uploading
38
38
  #keyPath = "/path/to/key.pem"
39
39
 
40
40
  [smtp]
41
+ # enabled, port, host, secret and proxy are deprecated and removed after 2027-01-01. They only seed
42
+ # the SMTP server settings on a first start; configure the SMTP server in the admin UI instead
41
43
  enabled = false
42
44
  port = 2525
43
45
  host = "127.0.0.1"
@@ -51,32 +51,59 @@ cp node_modules/flyonui/flyonui.js static/js/flyonui.js
51
51
  # Rebuild the compiled admin UI stylesheet (Tailwind v4 + FlyonUI)
52
52
  npm run build:css
53
53
 
54
- # Both JSON artifacts below are refreshed from the network and are committed, so a failed fetch
54
+ # The artifacts below are regenerated (mostly from the network) and are committed, so a failed fetch
55
55
  # must not be allowed to damage the copy already in the tree. A plain `> file` redirect truncates
56
56
  # before the command runs, which is how a GitHub 500 once left a zero-byte sbom.json behind - and
57
57
  # under `set -e` it also aborts the rest of this script, silently skipping the licence and gettext
58
58
  # regeneration that npm run update chains after it. Each fetch therefore lands in a sibling temp
59
- # file, is checked for being valid JSON, and only then replaces the committed one. The temp file
60
- # is created next to its target rather than in $TMPDIR so the move is a rename within the same
61
- # filesystem, never a copy that could be interrupted half-written.
62
- fetch_json() {
59
+ # file, is checked for being complete (valid JSON, or a format-specific check), and only then
60
+ # replaces the committed one. The temp file is created next to its target rather than in $TMPDIR
61
+ # so the move is a rename within the same filesystem, never a copy that could be interrupted
62
+ # half-written.
63
+ #
64
+ # fetch_checked TARGET CHECK COMMAND...: CHECK is a node script that throws unless the file named
65
+ # by process.argv[1] is a complete copy of what TARGET (process.argv[2]) should hold. A CHECK that
66
+ # exits with status 3 instead says the new copy changes nothing that matters, and the committed one
67
+ # is kept without a warning.
68
+ fetch_checked() {
63
69
  local target="$1"
64
- shift
65
- local tmp
70
+ local check="$2"
71
+ shift 2
72
+ local tmp status
66
73
  tmp=$(mktemp "${target}.XXXXXX")
67
- if "$@" > "$tmp" && node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$tmp"; then
74
+ if "$@" > "$tmp" && node -e "$check" "$tmp" "$target"; then
75
+ # mktemp creates the file 0600
76
+ chmod 644 "$tmp"
68
77
  mv "$tmp" "$target"
69
78
  else
79
+ status=$?
70
80
  rm -f "$tmp"
71
- echo "WARNING: failed to refresh ${target}, keeping the previous copy" >&2
81
+ if [ "$status" -ne 3 ]; then
82
+ echo "WARNING: failed to refresh ${target}, keeping the previous copy" >&2
83
+ fi
72
84
  fi
73
85
  }
74
86
 
87
+ fetch_json() {
88
+ local target="$1"
89
+ shift
90
+ fetch_checked "$target" 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$@"
91
+ }
92
+
75
93
  fetch_json data/google-crawlers.json wget -q -O - https://developers.google.com/static/crawling/ipranges/special-crawlers.json
76
94
  node -e 'console.log("Google crawlers updated: "+require("./data/google-crawlers.json").creationTime);'
77
95
 
78
- # brew install gh
79
- # gh auth login
80
- # gh ext install advanced-security/gh-sbom
81
- # gh sbom -c -l > sbom.json
82
- fetch_json sbom.json gh sbom
96
+ # The Public Suffix List, read by lib/utils/public-suffix.js. Kept verbatim (it is MPL-2.0 and carries
97
+ # its own licence header), and only accepted when both sections arrived whole: a truncated list would
98
+ # not fail to parse, it would just quietly know fewer suffixes. Nor is a list older than the one
99
+ # already here: the site's CDN has served a copy two days behind the one committed the same morning,
100
+ # and the refresh replaced the newer list with it. Exit code 3 keeps the current copy without a warning
101
+ fetch_checked data/public_suffix_list.dat 'const fs=require("fs");const t=fs.readFileSync(process.argv[1],"utf8");for(const m of ["===BEGIN ICANN DOMAINS===","===END ICANN DOMAINS===","===BEGIN PRIVATE DOMAINS===","===END PRIVATE DOMAINS==="])if(!t.includes(m))throw new Error("missing "+m);const v=x=>((x.match(/^\/\/ VERSION: (\S+)/m)||[])[1]||"");let old="";try{old=v(fs.readFileSync(process.argv[2],"utf8"))}catch(e){}if(old&&v(t)<old){console.error("Public Suffix List: the download ("+(v(t)||"no version")+") is older than the copy here ("+old+"), keeping it");process.exit(3)}' wget -q -O - https://publicsuffix.org/list/public_suffix_list.dat
102
+ grep -m1 '^// VERSION:' data/public_suffix_list.dat || true
103
+
104
+ # The SBOM shipped in the binary and served at /sbom.json, generated from the installed tree by npm
105
+ # (SPDX 2.3). Runtime dependencies only: dev tooling never reaches an instance. It used to come
106
+ # from GitHub's dependency graph (gh sbom), which only knows a lockfile once it has been pushed, so
107
+ # every dependency bump needed a second update after the push to catch up. npm stamps each run with
108
+ # a new creation time and document namespace, so a copy that differs in nothing else is not taken.
109
+ fetch_checked sbom.json 'const fs=require("fs");const strip=f=>{const d=JSON.parse(fs.readFileSync(f,"utf8"));delete d.documentNamespace;delete d.creationInfo.created;return JSON.stringify(d)};const next=strip(process.argv[1]);let prev=null;try{prev=strip(process.argv[2])}catch{}if(next===prev)process.exit(3)' npm sbom --sbom-format spdx --omit dev
@@ -1,5 +1,5 @@
1
1
  {
2
- "creationTime": "2026-10-16T14:46:08.000000",
2
+ "creationTime": "2026-10-22T14:46:14.000000",
3
3
  "prefixes": [
4
4
  {
5
5
  "ipv6Prefix": "2001:4860:4801:2008::/64"