emailengine-app 2.81.2 → 2.82.1

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 (226) hide show
  1. package/.ncurc.js +33 -10
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +71 -0
  4. package/DOCKER_DEPLOYMENT.md +13 -12
  5. package/Dockerfile +2 -0
  6. package/bin/emailengine.js +105 -25
  7. package/config/default.toml +0 -5
  8. package/config/test.toml +0 -5
  9. package/data/google-crawlers.json +1 -1
  10. package/encrypt.js +70 -42
  11. package/getswagger.sh +0 -4
  12. package/lib/account/account-state.js +2 -110
  13. package/lib/account/expected-identity.js +1 -1
  14. package/lib/account-assignment.js +138 -1
  15. package/lib/account.js +289 -869
  16. package/lib/api-reference/index.js +2 -3
  17. package/lib/api-reference/schema-tree.js +53 -3
  18. package/lib/api-routes/account-binding.js +58 -0
  19. package/lib/api-routes/account-routes.js +65 -37
  20. package/lib/api-routes/behavior-notes.js +4 -0
  21. package/lib/api-routes/blocklist-routes.js +2 -2
  22. package/lib/api-routes/bull-board-routes.js +1 -6
  23. package/lib/api-routes/export-routes.js +2 -22
  24. package/lib/api-routes/gateway-routes.js +15 -16
  25. package/lib/api-routes/index.js +1 -13
  26. package/lib/api-routes/mailbox-routes.js +2 -7
  27. package/lib/api-routes/mcp-oauth-routes.js +2 -1
  28. package/lib/api-routes/mcp-routes.js +7 -7
  29. package/lib/api-routes/message-routes.js +50 -238
  30. package/lib/api-routes/mint-bounds.js +110 -0
  31. package/lib/api-routes/oauth2-app-routes.js +23 -32
  32. package/lib/api-routes/operation-impact.js +1 -1
  33. package/lib/api-routes/outbox-routes.js +3 -3
  34. package/lib/api-routes/permission-map.js +1 -7
  35. package/lib/api-routes/route-helpers.js +11 -5
  36. package/lib/api-routes/settings-routes.js +20 -21
  37. package/lib/api-routes/stats-routes.js +1 -1
  38. package/lib/api-routes/submit-routes.js +17 -18
  39. package/lib/api-routes/template-routes.js +4 -9
  40. package/lib/api-routes/token-routes.js +28 -6
  41. package/lib/api-token-scheme.js +71 -0
  42. package/lib/arf-detect.js +33 -6
  43. package/lib/auth-token.js +44 -24
  44. package/lib/autodetect-imap-settings.js +305 -123
  45. package/lib/bounce-detect.js +25 -16
  46. package/lib/calendar-event.js +78 -0
  47. package/lib/consts.js +54 -5
  48. package/lib/create-imap-client.js +24 -0
  49. package/lib/db.js +77 -30
  50. package/lib/delivery-error.js +70 -2
  51. package/lib/egress-fetch.js +54 -3
  52. package/lib/egress-filter.js +11 -0
  53. package/lib/email-client/api-retry.js +147 -0
  54. package/lib/email-client/base-client.js +383 -536
  55. package/lib/email-client/credential-errors.js +21 -5
  56. package/lib/email-client/gmail/gmail-api.js +38 -125
  57. package/lib/email-client/gmail/send-request.js +1 -1
  58. package/lib/email-client/gmail-client.js +77 -51
  59. package/lib/email-client/imap/mailbox.js +158 -324
  60. package/lib/email-client/imap/stale-view.js +109 -0
  61. package/lib/email-client/imap/subconnection.js +46 -9
  62. package/lib/email-client/imap/sync-operations.js +5 -37
  63. package/lib/email-client/imap-client.js +190 -65
  64. package/lib/email-client/message-builder.js +50 -25
  65. package/lib/email-client/notification-handler.js +5 -219
  66. package/lib/email-client/outlook/graph-api.js +147 -126
  67. package/lib/email-client/outlook/send-request.js +10 -4
  68. package/lib/email-client/outlook-client.js +389 -463
  69. package/lib/email-client/smtp-pool-manager.js +3 -2
  70. package/lib/encrypt.js +184 -19
  71. package/lib/enum-descriptions.js +6 -3
  72. package/lib/export.js +141 -41
  73. package/lib/gateway.js +25 -6
  74. package/lib/get-raw-email.js +26 -44
  75. package/lib/get-secret.js +1 -21
  76. package/lib/handlebars-helpers.js +31 -10
  77. package/lib/imap-proxy-auth.js +13 -29
  78. package/lib/imapproxy/imap-core/README.md +1 -0
  79. package/lib/imapproxy/imap-core/lib/handler/imap-parser.js +12 -0
  80. package/lib/imapproxy/imap-core/lib/imap-command.js +74 -10
  81. package/lib/imapproxy/imap-core/lib/imap-connection.js +9 -1
  82. package/lib/imapproxy/imap-core/lib/imap-server.js +112 -26
  83. package/lib/imapproxy/imap-core/lib/imap-stream.js +41 -1
  84. package/lib/imapproxy/imap-core/lib/imap-tools.js +10 -2
  85. package/lib/imapproxy/imap-core/lib/indexer/indexer.js +4 -2
  86. package/lib/imapproxy/imap-server.js +17 -177
  87. package/lib/imapproxy/proxy-handoff.js +235 -0
  88. package/lib/imapproxy/response-error.js +33 -0
  89. package/lib/imapproxy/upstream-client.js +2 -2
  90. package/lib/license-beacon.js +3 -9
  91. package/lib/llm-pre-process.js +182 -43
  92. package/lib/logger.js +1 -1
  93. package/lib/lua/ee-export-queue-add.lua +39 -0
  94. package/lib/lua/ee-get-idempotency.lua +15 -3
  95. package/lib/lua/ee-release-attempts.lua +23 -0
  96. package/lib/lua/ee-reserve-attempts.lua +42 -0
  97. package/lib/lua/h-set-bigger.lua +12 -2
  98. package/lib/lua/s-list-accounts.lua +6 -3
  99. package/lib/mcp/index.js +1 -2
  100. package/lib/mcp/listen.js +221 -18
  101. package/lib/mcp/oauth.js +44 -5
  102. package/lib/mcp/resources.js +8 -2
  103. package/lib/mcp/tools.js +108 -36
  104. package/lib/message-port-stream.js +64 -6
  105. package/lib/oauth/external-account-signer.js +16 -13
  106. package/lib/oauth/gmail.js +64 -32
  107. package/lib/oauth/mail-ru.js +24 -17
  108. package/lib/oauth/outlook.js +53 -40
  109. package/lib/oauth/pubsub/google.js +38 -2
  110. package/lib/oauth/scope-checker.js +39 -8
  111. package/lib/oauth/scope-list.js +55 -0
  112. package/lib/oauth/token-fetch.js +47 -0
  113. package/lib/oauth/verify-app.js +2 -2
  114. package/lib/oauth2-apps.js +154 -90
  115. package/lib/openapi/build-document.js +1 -1
  116. package/lib/openapi/joi-schema.js +78 -9
  117. package/lib/outbox.js +2 -7
  118. package/lib/parse-message.js +21 -0
  119. package/lib/payload-examples-webhooks.json +4 -7
  120. package/lib/pbkdf2-phc.js +101 -0
  121. package/lib/privileged-settings.js +0 -14
  122. package/lib/queue-retention.js +4 -2
  123. package/lib/rate-limit.js +54 -15
  124. package/lib/read-env-value.js +33 -2
  125. package/lib/redis-scan-delete.js +56 -29
  126. package/lib/redis-url.js +3 -1
  127. package/lib/respawn-backoff.js +5 -4
  128. package/lib/response-stream.js +25 -4
  129. package/lib/rewrite-text-nodes.js +27 -40
  130. package/lib/routes-ui.js +0 -5
  131. package/lib/schemas.js +180 -253
  132. package/lib/sentry.js +21 -5
  133. package/lib/settings.js +58 -59
  134. package/lib/smtp-auth.js +6 -2
  135. package/lib/smtp-message-processor.js +28 -7
  136. package/lib/sso.js +7 -3
  137. package/lib/stream-encrypt.js +14 -13
  138. package/lib/swagger-options.js +3 -1
  139. package/lib/tls/provision.js +69 -3
  140. package/lib/tls/store.js +14 -1
  141. package/lib/token-audit-log.js +3 -2
  142. package/lib/tools.js +114 -53
  143. package/lib/totp.js +16 -1
  144. package/lib/ui-routes/account-routes.js +67 -70
  145. package/lib/ui-routes/admin-config-routes.js +111 -134
  146. package/lib/ui-routes/admin-entities-routes.js +101 -191
  147. package/lib/ui-routes/ai-options.js +104 -0
  148. package/lib/ui-routes/auth-routes.js +98 -18
  149. package/lib/ui-routes/export-routes.js +3 -23
  150. package/lib/ui-routes/internals-routes.js +12 -9
  151. package/lib/ui-routes/network-config-routes.js +8 -18
  152. package/lib/ui-routes/oauth-config-routes.js +83 -228
  153. package/lib/ui-routes/route-helpers.js +63 -67
  154. package/lib/ui-routes/special-use-paths.js +33 -0
  155. package/lib/ui-routes/unsubscribe-routes.js +2 -2
  156. package/lib/utils/decode-headers.js +32 -5
  157. package/lib/utils/header-map.js +62 -1
  158. package/lib/utils/network.js +11 -17
  159. package/lib/web-safe-html.js +77 -4
  160. package/lib/webhook-request.js +9 -1
  161. package/lib/webhook-routing.js +27 -1
  162. package/lib/webhooks.js +120 -43
  163. package/lib/worker-rpc-error.js +43 -2
  164. package/list-generate.js +13 -2
  165. package/package.json +38 -46
  166. package/sbom.json +1 -1
  167. package/scripts/refresh-test-tokens.js +42 -14
  168. package/server.js +338 -292
  169. package/setup-production.sh +16 -7
  170. package/static/css/flyonui.css +1 -1
  171. package/static/css/src/app.tailwind.css +7 -8
  172. package/static/js/ee-client.js +145 -70
  173. package/static/js/ui.js +350 -154
  174. package/static/licenses.html +349 -1740
  175. package/translations/messages.pot +129 -111
  176. package/views/account-workspace-error.hbs +30 -0
  177. package/views/accounts/account.hbs +9 -4
  178. package/views/accounts/browse.hbs +10 -4
  179. package/views/accounts/edit.hbs +11 -2
  180. package/views/config/ai.hbs +49 -41
  181. package/views/config/oauth/app.hbs +2 -1
  182. package/views/dashboard.hbs +18 -16
  183. package/views/internals/index.hbs +1 -1
  184. package/views/layout/app.hbs +0 -22
  185. package/views/layout/login.hbs +2 -1
  186. package/views/partials/filter_editor_js.hbs +4 -3
  187. package/views/partials/gmail_api_scopes.hbs +16 -0
  188. package/views/partials/oauth_form.hbs +67 -94
  189. package/views/partials/oauth_pubsub_app_select.hbs +43 -0
  190. package/views/partials/scope_info.hbs +14 -23
  191. package/views/partials/side_menu.hbs +0 -4
  192. package/views/partials/ui/account-picker.hbs +6 -32
  193. package/views/partials/ui/model-picker.hbs +31 -0
  194. package/views/partials/ui/pagination.hbs +6 -1
  195. package/views/partials/ui/picker.hbs +47 -0
  196. package/views/unsubscribe.hbs +1 -1
  197. package/workers/api.js +82 -47
  198. package/workers/export.js +55 -60
  199. package/workers/imap.js +132 -49
  200. package/workers/submit.js +5 -6
  201. package/workers/webhooks.js +46 -27
  202. package/.githooks/pre-commit +0 -80
  203. package/.github/CODE_OF_CONDUCT.md +0 -76
  204. package/.github/contributing.md +0 -17
  205. package/.github/dependabot.yml +0 -22
  206. package/.github/docker-smoke-test.sh +0 -61
  207. package/.github/workflows/deploy.yml +0 -215
  208. package/.github/workflows/e2e.yml +0 -55
  209. package/.github/workflows/release.yaml +0 -217
  210. package/.github/workflows/test.yml +0 -307
  211. package/lib/api-routes/chat-routes.js +0 -535
  212. package/lib/document-store.js +0 -75
  213. package/lib/es.js +0 -757
  214. package/lib/generate-text-preview.js +0 -61
  215. package/lib/imapproxy/imap-core/memory-notifier.js +0 -129
  216. package/lib/pre-process.js +0 -196
  217. package/lib/threads.js +0 -155
  218. package/lib/ui-routes/document-store-routes.js +0 -806
  219. package/playwright.config.js +0 -47
  220. package/views/config/document-store/chat.hbs +0 -286
  221. package/views/config/document-store/index.hbs +0 -146
  222. package/views/config/document-store/mappings/index.hbs +0 -108
  223. package/views/config/document-store/mappings/new.hbs +0 -68
  224. package/views/config/document-store/pre-processing/index.hbs +0 -103
  225. package/views/partials/document_store_header.hbs +0 -30
  226. package/workers/documents.js +0 -1128
@@ -11,17 +11,19 @@ const { webhooks: Webhooks } = require('../lib/webhooks');
11
11
  const { GooglePubSub } = require('../lib/oauth/pubsub/google');
12
12
 
13
13
  const { readEnvValue, threadStats, getDuration, httpAgent, getServiceSecret, redactUrlCredentials, splitUrlCredentials } = require('../lib/tools');
14
- const { sendWebhookRequest } = require('../lib/webhook-request');
14
+ const { sendWebhookRequest, isUnrecoverableWebhookError } = require('../lib/webhook-request');
15
15
  const { willBeFinalAttempt, isFinalFailedAttempt } = require('../lib/delivery-error');
16
16
  const { validateWebhookTarget } = require('../lib/webhook-egress');
17
- const { resolveTargetUrl, isDeliverableRoute, eventAllowed } = require('../lib/webhook-routing');
17
+ const { resolveTargetUrl, isDeliverableRoute, eventAllowed, deliveryCustomHeaders, isRouteMappingMissing } = require('../lib/webhook-routing');
18
18
 
19
19
  const { initSentry } = require('../lib/sentry');
20
20
  initSentry('webhooks');
21
21
 
22
- const { redis, queueConf } = require('../lib/db');
22
+ const { redis, queueConf, logBullErrors } = require('../lib/db');
23
23
  const { Worker, UnrecoverableError } = require('bullmq');
24
24
  const settings = require('../lib/settings');
25
+ const { decryptField } = require('../lib/encrypt');
26
+ const getSecret = require('../lib/get-secret');
25
27
 
26
28
  const { REDIS_PREFIX, ACCOUNT_DELETED_NOTIFY, MESSAGE_NEW_NOTIFY } = require('../lib/consts');
27
29
 
@@ -41,11 +43,6 @@ const NOTIFY_QC = (readEnvValue('EENGINE_NOTIFY_QC') && Number(readEnvValue('EEN
41
43
  // DEFAULT_WEBHOOK_REQUEST_TIMEOUT baked into sendWebhookRequest when unset
42
44
  const WEBHOOK_TIMEOUT = getDuration(readEnvValue('EENGINE_WEBHOOK_TIMEOUT')) || false;
43
45
 
44
- // Neither of these changes on a retry: the egress policy rejects the same destination every time,
45
- // and an endpoint configured to redirect keeps redirecting. Such a delivery is final on its first
46
- // failure, which decides both the log level and whether the remaining attempts are spent.
47
- const isUnrecoverableWebhookError = err => !!err && (err.code === 'EEGRESSBLOCKED' || err.code === 'EREDIRECTNOTFOLLOWED');
48
-
49
46
  let callQueue = new Map();
50
47
  let mids = 0;
51
48
 
@@ -90,6 +87,15 @@ function getAccountKey(account) {
90
87
  return `${REDIS_PREFIX}iad:${account}`;
91
88
  }
92
89
 
90
+ // The account `webhooks` and `webhooksCustomHeaders` fields are encrypted at rest (see
91
+ // ENCRYPTED_ACCOUNT_FIELDS in lib/account.js); a value stored before that is cleartext, which
92
+ // decrypt() passes through. One that no longer decrypts reads as unset, as it does for the account.
93
+ async function openAccountField(field, value, account) {
94
+ return decryptField(value, await getSecret(), err =>
95
+ logger.error({ msg: 'Failed to decrypt account webhook setting', action: 'webhook', account, field, err })
96
+ );
97
+ }
98
+
93
99
  async function metrics(logger, key, method, ...args) {
94
100
  try {
95
101
  parentPort.postMessage({
@@ -116,7 +122,10 @@ async function onCommand(command) {
116
122
  case 'close':
117
123
  clearTimeout(startRetryTimer);
118
124
  googlePubSub.stopAll();
119
- await notifyWorker.close(true);
125
+ // Not forced: a forced close abandons the delivery in flight, which BullMQ then
126
+ // re-runs as stalled after the lock expires, so the receiver got the event twice
127
+ // with the same X-EE-Wh-Id. The main thread bounds this wait with its own drain timeout.
128
+ await notifyWorker.close();
120
129
  return true;
121
130
  default:
122
131
  logger.debug({ msg: 'Unhandled command', command });
@@ -205,8 +214,9 @@ const notifyWorker = new Worker(
205
214
  job.__routeId = job.data._route.id;
206
215
  }
207
216
 
208
- // validate if we should even process this webhook
209
- let accountExists = await redis.hexists(accountKey, 'account');
217
+ // One round trip for the existence check and the two account fields a delivery may need
218
+ // (used to be three, one per job). The fields are opened where they are used, below.
219
+ let [accountExists, storedWebhooks, storedCustomHeaders] = await redis.hmget(accountKey, 'account', 'webhooks', 'webhooksCustomHeaders');
210
220
  if (!accountExists && job.name !== ACCOUNT_DELETED_NOTIFY) {
211
221
  logger.debug({
212
222
  msg: 'Account not found',
@@ -239,13 +249,27 @@ const notifyWorker = new Worker(
239
249
  if (job.data._route && job.data._route.id) {
240
250
  customRoute = await Webhooks.getMeta(job.data._route.id);
241
251
  customMapping = job.data._route.mapping;
252
+ let mappingMissing = isRouteMappingMissing(job.data._route);
242
253
  delete job.data._route;
243
254
  if (!isDeliverableRoute(customRoute)) {
244
255
  return;
245
256
  }
257
+ if (mappingMissing) {
258
+ logger.warn({
259
+ msg: 'Custom webhook route has no mapped payload, not sending',
260
+ action: 'webhook',
261
+ queue: job.queue.name,
262
+ code: 'missing_mapping',
263
+ job: job.id,
264
+ event: job.name,
265
+ account: job.data.account,
266
+ route: customRoute.id
267
+ });
268
+ return;
269
+ }
246
270
  }
247
271
 
248
- let accountWebhooks = await redis.hget(accountKey, 'webhooks');
272
+ let accountWebhooks = await openAccountField('webhooks', storedWebhooks, job.data.account);
249
273
 
250
274
  // the global setting is only fetched when neither a custom route nor the account override decides the target
251
275
  let webhooks = resolveTargetUrl(customRoute && customRoute.targetUrl, accountWebhooks, null).url || (await settings.get('webhooks'));
@@ -266,7 +290,10 @@ const notifyWorker = new Worker(
266
290
  }
267
291
 
268
292
  let accountWebhooksCustomHeaders;
269
- let accountWebhooksCustomHeadersJson = await redis.hget(accountKey, 'webhooksCustomHeaders');
293
+ // The account's headers belong to the account's (or the global) target. A custom route is
294
+ // an operator-defined endpoint with headers of its own: the account's secrets must not
295
+ // travel there, nor override the route's own Authorization.
296
+ let accountWebhooksCustomHeadersJson = customRoute ? null : await openAccountField('webhooksCustomHeaders', storedCustomHeaders, job.data.account);
270
297
  if (accountWebhooksCustomHeadersJson) {
271
298
  try {
272
299
  accountWebhooksCustomHeaders = JSON.parse(accountWebhooksCustomHeadersJson);
@@ -395,21 +422,11 @@ const notifyWorker = new Worker(
395
422
 
396
423
  if (customRoute) {
397
424
  headers['X-EE-Wh-Custom-Route'] = customRoute.id;
398
- for (let header of customRoute.customHeaders || []) {
399
- headers[header.key] = header.value;
400
- }
401
- } else {
402
- let webhookCustomHeaders = await settings.get('webhooksCustomHeaders');
403
- for (let header of webhookCustomHeaders || []) {
404
- headers[header.key] = header.value;
405
- }
406
- }
407
-
408
- if (accountWebhooksCustomHeaders) {
409
- for (let header of accountWebhooksCustomHeaders || []) {
410
- headers[header.key] = header.value;
411
- }
412
425
  }
426
+ Object.assign(
427
+ headers,
428
+ deliveryCustomHeaders(customRoute, customRoute ? null : await settings.get('webhooksCustomHeaders'), accountWebhooksCustomHeaders)
429
+ );
413
430
 
414
431
  let start = Date.now();
415
432
  let duration;
@@ -580,6 +597,8 @@ const notifyWorker = new Worker(
580
597
  )
581
598
  );
582
599
 
600
+ logBullErrors(notifyWorker, 'worker:webhooks');
601
+
583
602
  notifyWorker.on('completed', async job => {
584
603
  metrics(logger, 'queuesProcessed', 'inc', {
585
604
  queue: 'notify',
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Pre-commit hook: auto-format staged JavaScript with Prettier.
4
- #
5
- # Mirrors the file set covered by `npm run format` (lib/, workers/, test/, and
6
- # top-level *.js); Prettier additionally applies .prettierignore. Installed via the
7
- # "prepare" npm script, which points core.hooksPath at .githooks on `npm install`.
8
- #
9
- # Behavior:
10
- # - Fully-staged files are formatted in place and re-added to the index, so the
11
- # commit records the formatted result.
12
- # - Files that are staged AND still have unstaged changes are only *checked*,
13
- # never rewritten: formatting and re-adding them would sweep unrelated unstaged
14
- # hunks into the commit. If such a file is unformatted, the commit is aborted.
15
-
16
- set -u
17
-
18
- repo_root=$(git rev-parse --show-toplevel) || exit 0
19
- cd "$repo_root" || exit 0
20
-
21
- prettier="./node_modules/.bin/prettier"
22
- if [ ! -x "$prettier" ]; then
23
- echo "pre-commit: Prettier not found ($prettier) - skipping format (run 'npm install')." >&2
24
- exit 0
25
- fi
26
-
27
- # True for paths inside the format-covered set, matching *.js. Case patterns match
28
- # '/' with '*', so lib/*.js also covers nested files; the */* arm excludes anything
29
- # outside the covered directories, leaving top-level *.js to the last arm.
30
- is_covered() {
31
- case "$1" in
32
- lib/*.js | workers/*.js | test/*.js) return 0 ;;
33
- */*) return 1 ;;
34
- *.js) return 0 ;;
35
- *) return 1 ;;
36
- esac
37
- }
38
-
39
- to_format=()
40
- to_check=()
41
- while IFS= read -r -d '' f; do
42
- is_covered "$f" || continue
43
- # `git diff --quiet` compares the working tree to the index for this path:
44
- # exit 0 => no unstaged changes (safe to format+re-add), non-zero => partial.
45
- if git diff --quiet -- "$f"; then
46
- to_format+=("$f")
47
- else
48
- to_check+=("$f")
49
- fi
50
- done < <(git diff --cached --name-only --diff-filter=ACMR -z -- '*.js')
51
-
52
- if [ ${#to_format[@]} -eq 0 ] && [ ${#to_check[@]} -eq 0 ]; then
53
- exit 0
54
- fi
55
-
56
- status=0
57
-
58
- if [ ${#to_check[@]} -gt 0 ]; then
59
- if ! "$prettier" --check "${to_check[@]}"; then
60
- {
61
- echo ""
62
- echo "pre-commit: the staged file(s) above have additional unstaged changes and are not formatted."
63
- echo "They were left untouched to avoid committing unstaged hunks. Run:"
64
- echo " npm run format"
65
- echo "then re-stage and commit."
66
- } >&2
67
- status=1
68
- fi
69
- fi
70
-
71
- if [ ${#to_format[@]} -gt 0 ]; then
72
- if "$prettier" --write "${to_format[@]}"; then
73
- git add -- "${to_format[@]}"
74
- else
75
- echo "pre-commit: Prettier failed on staged files." >&2
76
- status=1
77
- fi
78
- fi
79
-
80
- exit $status
@@ -1,76 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, sex characteristics, gender identity and expression,
9
- level of experience, education, socio-economic status, nationality, personal
10
- appearance, race, religion, or sexual identity and orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- - Using welcoming and inclusive language
18
- - Being respectful of differing viewpoints and experiences
19
- - Gracefully accepting constructive criticism
20
- - Focusing on what is best for the community
21
- - Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- - The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- - Trolling, insulting/derogatory comments, and personal or political attacks
28
- - Public or private harassment
29
- - Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- - Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at andris@emailengine.app. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
-
73
- [homepage]: https://www.contributor-covenant.org
74
-
75
- For answers to common questions about this code of conduct, see
76
- https://www.contributor-covenant.org/faq
@@ -1,17 +0,0 @@
1
- # Contributing
2
-
3
- ## Legal
4
-
5
- (agreement below borrowed from [Sidekiq Legal](https://github.com/mperham/sidekiq/blob/master/.github/contributing.md))
6
-
7
- By submitting a Pull Request, you disavow any rights or claims to any changes
8
- submitted to the EmailEngine project and assign the copyright of
9
- those changes to Postal Systems OÜ.
10
-
11
- If you cannot or do not want to reassign those rights (your employment
12
- contract for your employer may not allow this), you should not submit a PR.
13
- Open an issue and someone else can do the work.
14
-
15
- This is a legal way of saying "If you submit a PR to us, that code becomes ours".
16
- 99.9% of the time that's what you intend anyways; we hope it doesn't scare you
17
- away from contributing.
@@ -1,22 +0,0 @@
1
- version: 2
2
-
3
- updates:
4
- # The Node base image is the one dependency that goes stale without any diff to review, which is
5
- # how it ended up 19 months behind. This entry exists to keep the digest current, nothing else.
6
- - package-ecosystem: docker
7
- directory: /
8
- schedule:
9
- interval: weekly
10
- commit-message:
11
- # `fix:` rather than `chore:`, so a base image bump reaches users through the release notes
12
- # instead of being filtered out of them
13
- prefix: fix
14
- # Digest updates only. The Node major is a deliberate choice that has to stay in step with the
15
- # CI matrix, the pkg targets and the deploy workflow, and it tracks Active LTS rather than
16
- # Current - left unignored, the first run proposed 24-alpine to 26-alpine, which is exactly the
17
- # drift this entry is meant to prevent. Moving the major is a manual decision.
18
- ignore:
19
- - dependency-name: node
20
- update-types:
21
- - version-update:semver-major
22
- - version-update:semver-minor
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env bash
2
- #
3
- # Smoke test the EmailEngine CLI inside a built image.
4
- #
5
- # The Dockerfile copies an explicit allowlist of root-level files rather than `COPY . .`, so a CLI
6
- # subcommand that dispatches to one (e.g. `scan` -> ../scan.js, `encrypt` -> ../encrypt.js) can be
7
- # missing from the image while the build and the server both stay green - CMD only runs server.js.
8
- # Both `scan` and `encrypt` shipped broken that way. Exercising the commands catches it regardless of
9
- # how the module is referenced, which a source-level check cannot.
10
- #
11
- # Runs against a locally-loaded image (see the workflows) BEFORE the multi-arch push, so a broken
12
- # image is never published - the previous version smoke tested the already-pushed image and could
13
- # only detect the regression, not prevent shipping it.
14
- #
15
- # Usage: docker-smoke-test.sh <image-ref>
16
- set -euo pipefail
17
-
18
- image="${1:?usage: docker-smoke-test.sh <image-ref>}"
19
- status=0
20
-
21
- # Only the subcommands that dispatch to a root-level module can exercise the allowlist; everything
22
- # else resolves out of lib/ or node_modules. This list is a runtime spot-check, not the completeness
23
- # authority - test/dockerfile-cli-modules-test.js derives the full set of root-level requires from
24
- # bin/emailengine.js and fails if any is not COPYed. Add new root-dispatching subcommands here too.
25
- for cmd in scan encrypt; do
26
- # These subcommands need Redis or arguments and are expected to exit non-zero; we only assert the
27
- # module resolved. Capture the exit code explicitly (no `|| true`, which would mask a container
28
- # that never started) so a docker/exec failure - exit >=125 - is treated as a failure, not a pass.
29
- out=$(docker run --rm --entrypoint node "$image" bin/emailengine.js "$cmd" 2>&1) && rc=0 || rc=$?
30
-
31
- if [ "$rc" -ge 125 ]; then
32
- echo "::error::container failed to start for 'emailengine $cmd' (exit $rc)"
33
- printf '%s\n' "$out"
34
- status=1
35
- continue
36
- fi
37
-
38
- if grep -q "Cannot find module" <<<"$out"; then
39
- echo "::error::emailengine $cmd cannot resolve its module inside the image"
40
- printf '%s\n' "$out"
41
- status=1
42
- fi
43
- done
44
-
45
- # The image has to be able to say which commit it was built from. update-info.sh writes an empty
46
- # commit rather than failing when EE_COMMIT_HASH is missing, and the Dockerfile requires the arg
47
- # precisely so that cannot happen - but the Dockerfile's check is a source-level one, and this is the
48
- # only place the built artifact is asked the question directly. Also catches the commit being right in
49
- # the Dockerfile and wrong in the image, e.g. a stale layer replayed from the build cache.
50
- commit=$(docker run --rm --entrypoint node "$image" -p "require('/emailengine/version-info.json').commit" 2>&1) && rc=0 || rc=$?
51
-
52
- if [ "$rc" -ne 0 ]; then
53
- echo "::error::could not read version-info.json from the image"
54
- printf '%s\n' "$commit"
55
- status=1
56
- elif [ -z "${commit//[[:space:]]/}" ] || [ "$commit" = "undefined" ]; then
57
- echo "::error::the image reports no commit hash - it was built without a usable EE_COMMIT_HASH build arg"
58
- status=1
59
- fi
60
-
61
- exit $status
@@ -1,215 +0,0 @@
1
- on:
2
- push:
3
- branches:
4
- - master
5
-
6
- name: Deploy test instance and Docker image
7
-
8
- permissions:
9
- contents: read
10
-
11
- concurrency:
12
- group: ${{ github.workflow }}-${{ github.ref }}
13
- cancel-in-progress: true
14
-
15
- jobs:
16
- deploy:
17
- name: Deploy Demo App
18
- runs-on: ubuntu-24.04
19
- timeout-minutes: 15
20
-
21
- steps:
22
- - name: Checkout
23
- uses: actions/checkout@v6
24
-
25
- - name: Use Node.js 24
26
- uses: actions/setup-node@v6
27
- with:
28
- node-version: 24
29
-
30
- - name: Install SSH key
31
- uses: shimataro/ssh-key-action@v2
32
- with:
33
- key: ${{ secrets.SSH_KEY }}
34
- known_hosts: ${{ secrets.KNOWN_HOSTS }}
35
-
36
- - name: Deploy to server
37
- env:
38
- TARGET_HOST_02: dev.emailengine.app
39
- NODE_ENV: production
40
- SERVICE_NAME: emailengine
41
- id: deploy
42
- run: |
43
- echo $GITHUB_SHA > commit.txt
44
- EE_COMMIT_HASH=$GITHUB_SHA ./update-info.sh
45
- npm install --omit=dev
46
- tar czf /tmp/${SERVICE_NAME}.tar.gz --exclude .git .
47
- scp -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" /tmp/${SERVICE_NAME}.tar.gz deploy@${TARGET_HOST_02}:
48
- ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" deploy@$TARGET_HOST_02 "/opt/deploy.sh ${SERVICE_NAME}"
49
-
50
- - name: Deploy to demo server
51
- env:
52
- TARGET_HOST_02: dev.emailengine.app
53
- NODE_ENV: production
54
- SERVICE_NAME: emailengine-demo
55
- id: deploy-demo
56
- run: |
57
- echo $GITHUB_SHA > commit.txt
58
- EE_COMMIT_HASH=$GITHUB_SHA ./update-info.sh
59
- npm install --omit=dev
60
- tar czf /tmp/${SERVICE_NAME}.tar.gz --exclude .git .
61
- scp -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" /tmp/${SERVICE_NAME}.tar.gz deploy@${TARGET_HOST_02}:
62
- ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" deploy@$TARGET_HOST_02 "/opt/deploy.sh ${SERVICE_NAME}"
63
-
64
- docker:
65
- name: Build Docker Image (${{ matrix.arch }})
66
- # One job per architecture, each on a runner of that architecture. The arm64 leg used to be
67
- # emulated through QEMU on an x86 runner, where `npm ci` hit an illegal instruction and then
68
- # hung until the job timeout - reliably on any commit that touches package-lock.json, since
69
- # that busts the cached layer and forces the install to run in full. A native runner takes
70
- # the emulator out of the picture, and each image now gets smoke tested on the architecture
71
- # it was actually built for rather than only amd64.
72
- runs-on: ${{ matrix.runner }}
73
- timeout-minutes: 30
74
- permissions:
75
- contents: read
76
- packages: write
77
- strategy:
78
- fail-fast: false
79
- matrix:
80
- include:
81
- - arch: amd64
82
- platform: linux/amd64
83
- runner: ubuntu-24.04
84
- - arch: arm64
85
- platform: linux/arm64
86
- runner: ubuntu-24.04-arm
87
-
88
- steps:
89
- - name: Checkout
90
- uses: actions/checkout@v6
91
-
92
- - name: Set up Docker Buildx
93
- uses: docker/setup-buildx-action@v4
94
-
95
- - name: Login to Docker Hub
96
- uses: docker/login-action@v4
97
- with:
98
- username: ${{ secrets.DOCKERHUB_USERNAME }}
99
- password: ${{ secrets.DOCKERHUB_TOKEN }}
100
-
101
- - name: Login to GHCR
102
- uses: docker/login-action@v4
103
- with:
104
- registry: ghcr.io
105
- username: ${{ github.repository_owner }}
106
- password: ${{ secrets.GITHUB_TOKEN }}
107
-
108
- # Build locally and exercise the CLI BEFORE anything is published, so a broken image is
109
- # never pushed. The push below replays from this build's local layer cache, so paying
110
- # for the build twice costs almost nothing.
111
- - name: Build for smoke test (local)
112
- uses: docker/build-push-action@v7
113
- with:
114
- context: .
115
- platforms: ${{ matrix.platform }}
116
- load: true
117
- tags: emailengine:smoke-test
118
- build-args: |
119
- EE_COMMIT_HASH=${{ github.sha }}
120
- # Without a cache backend BuildKit starts cold on every run: setup-buildx-action
121
- # creates a fresh builder on an ephemeral runner. The scope is per-architecture so
122
- # the two legs cannot evict each other's entries.
123
- cache-from: type=gha,scope=${{ matrix.arch }}
124
-
125
- - name: Smoke test the CLI inside the image
126
- run: bash .github/docker-smoke-test.sh emailengine:smoke-test
127
-
128
- # Pushed by digest and left untagged: a tag can only be attached once both architectures
129
- # exist, which is what the manifest job below does. Both registries are written here so
130
- # the blobs are already in place and the manifest job never has to copy them between
131
- # registries.
132
- - name: Build and push by digest
133
- id: build
134
- uses: docker/build-push-action@v7
135
- with:
136
- context: .
137
- platforms: ${{ matrix.platform }}
138
- outputs: type=image,"name=docker.io/${{ github.repository }},ghcr.io/${{ github.repository }}",push-by-digest=true,name-canonical=true,push=true
139
- cache-from: type=gha,scope=${{ matrix.arch }}
140
- cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
141
- build-args: |
142
- EE_COMMIT_HASH=${{ github.sha }}
143
-
144
- - name: Export digest
145
- run: |
146
- mkdir -p /tmp/digests
147
- digest="${{ steps.build.outputs.digest }}"
148
- touch "/tmp/digests/${digest#sha256:}"
149
-
150
- - name: Upload digest
151
- uses: actions/upload-artifact@v4
152
- with:
153
- name: digests-${{ matrix.arch }}
154
- path: /tmp/digests/*
155
- if-no-files-found: error
156
- # Long enough for "Re-run failed jobs" on a later working day to still find the
157
- # digest of the leg that passed; the check below refuses to publish without it
158
- retention-days: 7
159
-
160
- docker-manifest:
161
- name: Publish Docker Manifest
162
- runs-on: ubuntu-24.04
163
- needs: docker
164
- timeout-minutes: 15
165
- permissions:
166
- contents: read
167
- packages: write
168
-
169
- steps:
170
- - name: Download digests
171
- uses: actions/download-artifact@v4
172
- with:
173
- path: /tmp/digests
174
- pattern: digests-*
175
- merge-multiple: true
176
-
177
- # One digest file per platform in the build matrix. With fail-fast off, one leg can
178
- # push its digest while the other fails, and a re-run that finds only the surviving
179
- # artifact (or none, once they expire) would otherwise publish a single-platform
180
- # manifest list under every tag as if it were complete.
181
- - name: Check that every platform produced a digest
182
- working-directory: /tmp/digests
183
- run: |
184
- count=$(ls -1 | wc -l)
185
- if [ "$count" -ne 2 ]; then
186
- echo "Expected 2 digests (linux/amd64, linux/arm64), found $count:"
187
- ls -1
188
- exit 1
189
- fi
190
-
191
- - name: Set up Docker Buildx
192
- uses: docker/setup-buildx-action@v4
193
-
194
- - name: Login to Docker Hub
195
- uses: docker/login-action@v4
196
- with:
197
- username: ${{ secrets.DOCKERHUB_USERNAME }}
198
- password: ${{ secrets.DOCKERHUB_TOKEN }}
199
-
200
- - name: Login to GHCR
201
- uses: docker/login-action@v4
202
- with:
203
- registry: ghcr.io
204
- username: ${{ github.repository_owner }}
205
- password: ${{ secrets.GITHUB_TOKEN }}
206
-
207
- # :latest is owned by the release workflow (release.yaml) and always points at the
208
- # newest release; per-push dev builds from master are published as :edge instead.
209
- - name: Create and push the manifest list
210
- working-directory: /tmp/digests
211
- run: |
212
- for image in "docker.io/${{ github.repository }}" "ghcr.io/${{ github.repository }}"; do
213
- docker buildx imagetools create -t "${image}:edge" \
214
- $(printf "${image}@sha256:%s " *)
215
- done
@@ -1,55 +0,0 @@
1
- name: E2E Tests
2
-
3
- # Browser-driven happy-path end-to-end suite (test/e2e), kept separate from the unit and
4
- # integration tiers so it is easy to re-run on its own and has its own requirements: it drives a
5
- # real browser (Playwright/Chromium) and reaches external services (Ethereal for the test mailbox,
6
- # postalsys.com for the 14-day trial).
7
-
8
- on:
9
- workflow_dispatch:
10
- push:
11
- branches: [master]
12
-
13
- permissions:
14
- contents: read
15
-
16
- concurrency:
17
- group: e2e-${{ github.ref }}
18
- cancel-in-progress: true
19
-
20
- jobs:
21
- e2e:
22
- name: E2E (Playwright)
23
- timeout-minutes: 20
24
- runs-on: ubuntu-24.04
25
- services:
26
- redis:
27
- image: redis
28
- options: >-
29
- --health-cmd "redis-cli ping"
30
- --health-interval 10s
31
- --health-timeout 5s
32
- --health-retries 5
33
- ports:
34
- - 6379:6379
35
- steps:
36
- - uses: actions/checkout@v6
37
- - name: Use Node.js 24
38
- uses: actions/setup-node@v6
39
- with:
40
- node-version: 24
41
- cache: npm
42
- - run: npm install
43
- - name: Install Playwright browser
44
- run: npx playwright install --with-deps chromium
45
- - name: Run e2e tests
46
- run: npm run test:e2e
47
- env:
48
- NODE_ENV: e2e
49
- - name: Upload Playwright report
50
- uses: actions/upload-artifact@v4
51
- if: ${{ !cancelled() }}
52
- with:
53
- name: playwright-report
54
- path: playwright-report/
55
- retention-days: 7