emailengine-app 2.83.1 → 2.84.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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +30 -0
- package/README.md +1 -1
- package/SECURITY.md +126 -47
- package/data/google-crawlers.json +1 -1
- package/gettext-extract.js +95 -15
- package/lib/api-routes/outbox-routes.js +132 -9
- package/lib/api-routes/permission-map.js +11 -1
- package/lib/consts.js +3 -5
- package/lib/email-client/base-client.js +44 -20
- package/lib/email-client/credential-errors.js +3 -31
- package/lib/email-client/imap/idle-settings.js +44 -0
- package/lib/email-client/imap/mailbox.js +19 -7
- package/lib/email-client/imap-client.js +3 -21
- package/lib/email-client/smtp-pool-manager.js +25 -6
- package/lib/enum-descriptions.js +7 -0
- package/lib/export.js +46 -42
- package/lib/field-usage.js +4 -0
- package/lib/handlebars-helpers.js +4 -0
- package/lib/imapproxy/imap-core/lib/commands/starttls.js +4 -2
- package/lib/imapproxy/imap-core/lib/imap-server.js +44 -11
- package/lib/imapproxy/proxy-handoff.js +10 -1
- package/lib/logger.js +3 -2
- package/lib/message-port-stream.js +23 -0
- package/lib/network-errors.js +50 -0
- package/lib/oauth/gmail.js +5 -1
- package/lib/oauth/mail-ru.js +5 -1
- package/lib/oauth/outlook.js +5 -1
- package/lib/oauth/pubsub/google.js +3 -2
- package/lib/oauth/token-fetch.js +2 -3
- package/lib/outbox.js +338 -10
- package/lib/queue-browser/definitions.js +132 -0
- package/lib/queue-browser/format.js +387 -0
- package/lib/queue-browser/index.js +568 -0
- package/lib/queue-job-actions.js +75 -0
- package/lib/queue-retention.js +53 -1
- package/lib/routes-ui.js +5 -0
- package/lib/schemas.js +42 -2
- package/lib/security-headers.js +2 -24
- package/lib/sub-script.js +10 -3
- package/lib/token-permission-view.js +1 -1
- package/lib/tools.js +16 -2
- package/lib/ui-routes/account-routes.js +6 -0
- package/lib/ui-routes/imap-idle-field.js +42 -0
- package/lib/ui-routes/queue-routes.js +371 -0
- package/lib/utils/status-error.js +21 -0
- package/package.json +18 -20
- package/prepare-bundle-deps.sh +1 -1
- package/sbom.json +1 -1
- package/server.js +10 -0
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +2 -0
- package/static/js/queues.js +117 -0
- package/static/licenses.html +127 -251
- package/translations/README.md +3 -2
- package/translations/messages.pot +280 -265
- package/views/accounts/account.hbs +31 -0
- package/views/accounts/edit.hbs +2 -0
- package/views/config/service.hbs +1 -2
- package/views/dashboard.hbs +2 -2
- package/views/partials/queue_cell_account.hbs +20 -0
- package/views/partials/queue_cell_failure.hbs +6 -0
- package/views/partials/queue_clean_items.hbs +9 -0
- package/views/partials/queue_clean_modal.hbs +9 -0
- package/views/partials/queue_entry_actions.hbs +41 -0
- package/views/partials/queue_job_actions.hbs +15 -0
- package/views/partials/queue_pause_controls.hbs +18 -0
- package/views/partials/queue_retention_note.hbs +49 -0
- package/views/partials/queue_rows_export.hbs +58 -0
- package/views/partials/queue_rows_notify.hbs +73 -0
- package/views/partials/queue_rows_submit.hbs +70 -0
- package/views/partials/side_menu.hbs +1 -1
- package/views/partials/ui/tooltip.hbs +5 -3
- package/views/queues/index.hbs +104 -0
- package/views/queues/job.hbs +224 -0
- package/views/queues/queue.hbs +93 -0
- package/views/webhooks/webhook.hbs +3 -0
- package/workers/api.js +0 -4
- package/workers/imap.js +10 -3
- package/workers/smtp.js +16 -1
- package/workers/submit.js +19 -5
- package/workers/webhooks.js +13 -0
- package/lib/api-routes/bull-board-routes.js +0 -56
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.84.0](https://github.com/postalsys/emailengine/compare/v2.83.2...v2.84.0) (2026-10-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **admin:** replace bull-board with an in-house queue browser ([4215616](https://github.com/postalsys/emailengine/commit/4215616552c92762212c021ab2c0768884aa487b))
|
|
9
|
+
* per-account IDLE restart interval (imap.maxIdleTime) ([25e5cb7](https://github.com/postalsys/emailengine/commit/25e5cb761d39a33304f9219dccad4f9bc0c336a6))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **admin:** format the queue help panel and keep a leading kebab menu on the page ([ed51305](https://github.com/postalsys/emailengine/commit/ed513050da555d195ba9937a82f216bff053cd9e))
|
|
15
|
+
* **admin:** move a queue entry's actions to the page header and explain what the queues keep ([9ace194](https://github.com/postalsys/emailengine/commit/9ace19484818f6f0951bb53bbfb8ea0826a23f40))
|
|
16
|
+
* **admin:** post queue entry actions as plain forms ([e335331](https://github.com/postalsys/emailengine/commit/e335331a56c994f08c2e051444378d93e1cefa67))
|
|
17
|
+
* **admin:** say which bound decides the failed-entry count on the queue page ([7224cd7](https://github.com/postalsys/emailengine/commit/7224cd742cd3760bca46b4a748eb54bd73020ec8))
|
|
18
|
+
* **deps:** update bullmq to 6.3.15 ([b58b632](https://github.com/postalsys/emailengine/commit/b58b63233aa0aedad57c4816ad3d937089161e56))
|
|
19
|
+
* **deps:** update imapflow to 2.4.3 and dotenv to 18.0.8 ([c28955b](https://github.com/postalsys/emailengine/commit/c28955bbcedc20748745016fcec397e2603e85c3))
|
|
20
|
+
* **deps:** update nodemailer to 10.1.1, imapflow to 2.4.2 and libmime to 5.4.8 ([ff766dd](https://github.com/postalsys/emailengine/commit/ff766dd89ea1de9cdb72673cec14adb7c9bb90ff))
|
|
21
|
+
* skip DSN parsing when the message was expunged before it was downloaded ([44113d5](https://github.com/postalsys/emailengine/commit/44113d55fd2f89902536a3ef3074b9fa27a4838b))
|
|
22
|
+
|
|
23
|
+
## [2.83.2](https://github.com/postalsys/emailengine/compare/v2.83.1...v2.83.2) (2026-10-10)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* close connection and error handling gaps from the TLS/TCP audit ([c858c05](https://github.com/postalsys/emailengine/commit/c858c059eb26be91f485ba0841c306e2fcfae232))
|
|
29
|
+
* **deps:** update nodemailer, imapflow, mailparser and smtp-server ([5e9ef89](https://github.com/postalsys/emailengine/commit/5e9ef89e3a2bb2ff56f8a4b2c355470d2adff171))
|
|
30
|
+
* **deps:** update smtp-server to 3.19.21 ([c53de63](https://github.com/postalsys/emailengine/commit/c53de63f025281ba64e740895a9076097a15c8ae))
|
|
31
|
+
* treat a stalled response body as a transient network failure ([a33a161](https://github.com/postalsys/emailengine/commit/a33a161a71bb795bf8bf8de49d2afd9cac52fe92))
|
|
32
|
+
|
|
3
33
|
## [2.83.1](https://github.com/postalsys/emailengine/compare/v2.83.0...v2.83.1) (2026-10-08)
|
|
4
34
|
|
|
5
35
|
|
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ EmailEngine relies on Redis as its data store. Redis stores everything in RAM, s
|
|
|
142
142
|
|
|
143
143
|
To diagnose problems:
|
|
144
144
|
|
|
145
|
-
1. **Check the job queues:**
|
|
145
|
+
1. **Check the job queues:** Open the queue browser at [http://127.0.0.1:3000/admin/queues](http://127.0.0.1:3000/admin/queues) (requires an admin session) to see what is waiting, running and failed in the webhook, submission and export queues.
|
|
146
146
|
2. **Scan Keyspace:** Run the following to group Redis keys by type and generate a report:
|
|
147
147
|
|
|
148
148
|
```bash
|
package/SECURITY.md
CHANGED
|
@@ -1,80 +1,159 @@
|
|
|
1
1
|
# Security Policy
|
|
2
2
|
|
|
3
|
-
EmailEngine is a self-hosted email integration platform
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
EmailEngine is a self-hosted email integration platform. It stores email account
|
|
4
|
+
credentials, proxies access to IMAP/SMTP, the Gmail API, and the Microsoft Graph
|
|
5
|
+
API, and serves a REST API and an admin web UI. We welcome responsible reports
|
|
6
|
+
of vulnerabilities that present a credible security risk to users. Please
|
|
7
|
+
distinguish security vulnerabilities from ordinary bugs, unusual edge cases, and
|
|
8
|
+
hardening suggestions.
|
|
7
9
|
|
|
8
10
|
## Supported Versions
|
|
9
11
|
|
|
10
|
-
Security fixes are released only against the latest version. We do not
|
|
11
|
-
patches to older
|
|
12
|
-
supported way to receive security updates.
|
|
12
|
+
Security fixes are released only against the latest major version. We do not
|
|
13
|
+
backport patches to older majors, so upgrading to the current release line is
|
|
14
|
+
the supported way to receive security updates.
|
|
13
15
|
|
|
14
16
|
| Version | Supported |
|
|
15
17
|
| ------- | ------------------ |
|
|
16
18
|
| 2.x | :white_check_mark: |
|
|
17
19
|
| < 2.0 | :x: |
|
|
18
20
|
|
|
19
|
-
If you are on an older
|
|
21
|
+
If you are on an older major, please upgrade. See the release notes at
|
|
20
22
|
<https://github.com/postalsys/emailengine/releases> before updating.
|
|
21
23
|
|
|
24
|
+
## What Qualifies as a Security Vulnerability
|
|
25
|
+
|
|
26
|
+
A security report should identify a realistic way for an attacker to cross a
|
|
27
|
+
security boundary in a supported version of EmailEngine. Unexpected behavior, a
|
|
28
|
+
failing test, or a technically correct proof of concept is not sufficient on its
|
|
29
|
+
own to establish security impact.
|
|
30
|
+
|
|
31
|
+
In particular, explain:
|
|
32
|
+
|
|
33
|
+
- **Attacker capabilities:** Who is the attacker, and what inputs, systems, or
|
|
34
|
+
responses can they control _without_ already having the privileges or secrets
|
|
35
|
+
they are trying to gain?
|
|
36
|
+
- **Attack path:** How does attacker-controlled input reach the affected code
|
|
37
|
+
through a supported EmailEngine interface, such as the REST API, the admin web
|
|
38
|
+
UI, the hosted authentication forms, the built-in SMTP server or IMAP proxy,
|
|
39
|
+
webhook delivery, or an email message that EmailEngine processes?
|
|
40
|
+
- **Prerequisites:** What configuration and user actions are required? If the
|
|
41
|
+
attack depends on unusual options or deliberately malformed input, explain why
|
|
42
|
+
those conditions could arise in a real application.
|
|
43
|
+
- **Impact:** What confidentiality, integrity, or availability boundary is
|
|
44
|
+
crossed, and what can the attacker achieve as a result?
|
|
45
|
+
|
|
46
|
+
A vulnerability involving an optional or less common feature can still qualify
|
|
47
|
+
if these conditions are met. Conversely, the existence of a defensive check in
|
|
48
|
+
the code does not, by itself, establish that every bypass of that check has a
|
|
49
|
+
realistic security impact.
|
|
50
|
+
|
|
22
51
|
## Reporting a Vulnerability
|
|
23
52
|
|
|
24
|
-
**
|
|
25
|
-
pull requests, or discussions
|
|
53
|
+
**Do not disclose suspected exploitable vulnerabilities through public GitHub
|
|
54
|
+
issues, pull requests, or discussions before coordinating with the
|
|
55
|
+
maintainers.**
|
|
26
56
|
|
|
27
57
|
Report privately through one of the following channels:
|
|
28
58
|
|
|
29
|
-
1. **GitHub Security Advisories (preferred)
|
|
30
|
-
<https://github.com/postalsys/emailengine/security/advisories/new>.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
1. **GitHub Security Advisories (preferred):**
|
|
60
|
+
<https://github.com/postalsys/emailengine/security/advisories/new>.
|
|
61
|
+
2. **Email:** **andris@postalsys.com**, as listed in
|
|
62
|
+
[`SECURITY.txt`](SECURITY.txt). Encrypt sensitive details if possible.
|
|
63
|
+
|
|
64
|
+
### Required Information
|
|
65
|
+
|
|
66
|
+
Please provide enough information to evaluate both the defect and its security
|
|
67
|
+
impact. Reports should include:
|
|
68
|
+
|
|
69
|
+
1. The affected EmailEngine version or commit, Node.js version, deployment
|
|
70
|
+
method (npm, Docker, or prebuilt binary), and relevant configuration.
|
|
71
|
+
2. A concise description of the issue and the affected component (for example
|
|
72
|
+
the REST API, admin web UI, OAuth2 flows, the built-in SMTP server or IMAP
|
|
73
|
+
proxy, webhook delivery, credential encryption, or the export pipeline).
|
|
74
|
+
3. A minimal, tested reproduction, including steps to run it, expected behavior,
|
|
75
|
+
and observed behavior.
|
|
76
|
+
4. A concrete threat model: attacker control, prerequisites, trust boundary, and
|
|
77
|
+
resulting impact. Clearly distinguish what your reproduction proves from what
|
|
78
|
+
you believe might be possible.
|
|
79
|
+
5. An explanation of why the issue affects real deployments beyond a
|
|
80
|
+
deliberately constructed test setup, where this is not obvious.
|
|
81
|
+
|
|
82
|
+
A suggested fix is welcome but does not replace an explanation of
|
|
83
|
+
exploitability. A complete real-world exploit is not always necessary, but the
|
|
84
|
+
report must make a credible security impact clear.
|
|
85
|
+
|
|
86
|
+
### Reports That May Be Treated as Ordinary Bugs
|
|
87
|
+
|
|
88
|
+
The following generally do **not** qualify for private security handling unless
|
|
89
|
+
you can demonstrate an additional, meaningful security boundary crossing:
|
|
90
|
+
|
|
91
|
+
- Issues that require the attacker to control trusted application code,
|
|
92
|
+
administrator-only configuration, or the secret they supposedly extract.
|
|
93
|
+
- Problems caused solely by application-level misuse, exposed credentials, or
|
|
94
|
+
insecure deployment choices outside EmailEngine's control.
|
|
95
|
+
- Contrived proof-of-concept setups where the tester controls both sides of a
|
|
96
|
+
request, without explaining how a separate attacker could trigger the issue.
|
|
97
|
+
- Parser quirks, unexpected behavior, and bypasses of internal checks with no
|
|
98
|
+
demonstrated security impact.
|
|
99
|
+
- Speculative findings based only on static analysis or an automated tool's
|
|
100
|
+
assessment, without a verified reproduction and credible attack scenario.
|
|
101
|
+
|
|
102
|
+
These may still be valid bugs and may be considered through the normal issue
|
|
103
|
+
tracker. Please coordinate before making any potentially exploitable details
|
|
104
|
+
public. Classification as a bug does not guarantee a fix or a particular
|
|
105
|
+
priority.
|
|
106
|
+
|
|
107
|
+
### Automated and AI-Assisted Reports
|
|
108
|
+
|
|
109
|
+
Automated analysis and AI tools are welcome as research aids, but the person
|
|
110
|
+
submitting a report is responsible for verifying its claims. **Do not submit
|
|
111
|
+
bulk, unverified, or speculative AI-generated findings.** Test each finding
|
|
112
|
+
against a supported release and establish the actual security impact. Reports
|
|
113
|
+
that do not meet the requirements above may be closed without further
|
|
114
|
+
investigation or individual feedback; they can be resubmitted with stronger
|
|
115
|
+
evidence.
|
|
116
|
+
|
|
117
|
+
## Triage and Disclosure
|
|
118
|
+
|
|
119
|
+
EmailEngine is maintained by a small team, and there is **no guaranteed response
|
|
120
|
+
or resolution time**. Reports are prioritized based on demonstrated impact,
|
|
121
|
+
exploitability, affected usage, and available maintenance resources.
|
|
122
|
+
|
|
123
|
+
A private report does not automatically become a security advisory. Confirmed
|
|
124
|
+
vulnerabilities may be fixed and disclosed through GitHub Security Advisories;
|
|
125
|
+
other findings may be closed, deferred, or handled as ordinary bugs. Please do
|
|
126
|
+
not disclose details of an unresolved, potentially exploitable issue publicly
|
|
127
|
+
without coordinating with the maintainers.
|
|
128
|
+
|
|
129
|
+
## CVEs and Credit
|
|
130
|
+
|
|
131
|
+
We do not request or manage CVE identifiers. A report being acknowledged, a bug
|
|
132
|
+
being fixed, or a pull request being merged does **not** mean that EmailEngine
|
|
133
|
+
has confirmed a security vulnerability or endorsed a CVE assignment. We do not
|
|
134
|
+
guarantee advisories, CVE identifiers, or public credit for reports. For
|
|
135
|
+
confirmed vulnerabilities disclosed through an advisory, substantive reporters
|
|
136
|
+
may be credited if they wish.
|
|
58
137
|
|
|
59
138
|
## Scope
|
|
60
139
|
|
|
61
|
-
In scope: the EmailEngine application source in this repository
|
|
140
|
+
In scope: the EmailEngine application source in this repository: the REST API
|
|
62
141
|
and admin web UI (authentication, session and token handling, CSRF protection),
|
|
63
|
-
OAuth2 application handling, credential encryption at rest, the
|
|
64
|
-
IMAP proxy
|
|
142
|
+
OAuth2 application handling, credential encryption at rest, the built-in SMTP
|
|
143
|
+
server and IMAP proxy, webhook delivery (including custom filter and transform
|
|
65
144
|
functions), the export pipeline, and inter-worker communication.
|
|
66
145
|
|
|
67
146
|
Out of scope:
|
|
68
147
|
|
|
69
148
|
- Vulnerabilities in your own application code that integrates with EmailEngine.
|
|
70
|
-
- Misconfiguration of your deployment
|
|
71
|
-
|
|
72
|
-
|
|
149
|
+
- Misconfiguration of your deployment, for example exposing the admin interface
|
|
150
|
+
or REST API to untrusted networks, weak service secrets, an unauthenticated or
|
|
151
|
+
publicly reachable Redis instance, or missing TLS.
|
|
73
152
|
- Issues that require an already-compromised host or pre-existing administrator
|
|
74
153
|
access.
|
|
75
154
|
- Vulnerabilities in third-party email providers and services that EmailEngine
|
|
76
155
|
connects to (Gmail, Microsoft 365, arbitrary IMAP/SMTP servers).
|
|
77
|
-
-
|
|
78
|
-
|
|
156
|
+
- Missing security headers without a demonstrated, concrete impact.
|
|
157
|
+
- Social-engineering reports.
|
|
79
158
|
|
|
80
159
|
Thank you for helping keep EmailEngine and its users safe.
|
package/gettext-extract.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// Extracts translatable strings from JS sources into translations/messages.pot.
|
|
4
|
-
// Run via `npm run gettext` after xgettext-template has
|
|
5
|
-
//
|
|
4
|
+
// Run via `npm run gettext` after xgettext-template has written the strings of the Handlebars
|
|
5
|
+
// views to translations/messages.pot.tmp - this script joins the strings found in JS files into
|
|
6
|
+
// that catalog and writes the result to translations/messages.pot.
|
|
7
|
+
//
|
|
8
|
+
// The output is canonical: an unchanged source tree produces a byte-identical file. That takes
|
|
9
|
+
// two things xgettext-template does not do. It parses the views in the order their reads
|
|
10
|
+
// complete (async.parallel over fs.readFile), so both the entry order and the order of the
|
|
11
|
+
// reference lines of a string used in several views changed from run to run; both are sorted
|
|
12
|
+
// here. And the creation date is only stamped when the catalog content actually changed.
|
|
6
13
|
//
|
|
7
14
|
// Replaces jsxgettext, which bundled acorn 5 and crashed on post-ES2018 syntax
|
|
8
15
|
// (optional chaining, nullish coalescing, etc.). Files are discovered dynamically,
|
|
@@ -16,6 +23,8 @@ const Path = require('path');
|
|
|
16
23
|
|
|
17
24
|
const ROOT_DIR = __dirname;
|
|
18
25
|
const POT_PATH = Path.join(ROOT_DIR, 'translations', 'messages.pot');
|
|
26
|
+
// The catalog of the Handlebars views, as written by xgettext-template
|
|
27
|
+
const TEMPLATES_POT_PATH = `${POT_PATH}.tmp`;
|
|
19
28
|
|
|
20
29
|
// All server-side code that may contain gettext()/ngettext() calls
|
|
21
30
|
const SCAN_DIRS = ['bin', 'lib', 'workers'];
|
|
@@ -114,6 +123,65 @@ function extractFromFile(filePath) {
|
|
|
114
123
|
return entries;
|
|
115
124
|
}
|
|
116
125
|
|
|
126
|
+
// "views/a.hbs:12" -> ['views/a.hbs', 12], so line 9 sorts before line 10
|
|
127
|
+
function parseReference(reference) {
|
|
128
|
+
let separator = reference.lastIndexOf(':');
|
|
129
|
+
return [reference.slice(0, separator), Number(reference.slice(separator + 1))];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function compareReferences(a, b) {
|
|
133
|
+
let [pathA, lineA] = parseReference(a);
|
|
134
|
+
let [pathB, lineB] = parseReference(b);
|
|
135
|
+
if (pathA !== pathB) {
|
|
136
|
+
return pathA < pathB ? -1 : 1;
|
|
137
|
+
}
|
|
138
|
+
return lineA - lineB;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// One reference per line as written here, but several to a line in catalogs from GNU tools
|
|
142
|
+
function getReferences(entry) {
|
|
143
|
+
let reference = entry.comments && entry.comments.reference;
|
|
144
|
+
return reference ? reference.split(/\s+/).filter(value => value) : [];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const compareStrings = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
148
|
+
|
|
149
|
+
// Entries in source order: by their first reference, so a file's strings stay together in the
|
|
150
|
+
// order they appear in it. Context, then msgid, break ties (several strings on one line)
|
|
151
|
+
function compareEntries(a, b) {
|
|
152
|
+
let refA = getReferences(a)[0] || '';
|
|
153
|
+
let refB = getReferences(b)[0] || '';
|
|
154
|
+
if (refA !== refB) {
|
|
155
|
+
return compareReferences(refA, refB);
|
|
156
|
+
}
|
|
157
|
+
return compareStrings(a.msgctxt || '', b.msgctxt || '') || compareStrings(a.msgid, b.msgid);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Compiles a parsed catalog in canonical form: every entry's references sorted, and the entries
|
|
162
|
+
* sorted by their first one. Mutates the reference comments of `pot`
|
|
163
|
+
* @param {Object} pot - Catalog as returned by po.parse()
|
|
164
|
+
* @returns {Buffer} The compiled POT file
|
|
165
|
+
*/
|
|
166
|
+
function compileCanonical(pot) {
|
|
167
|
+
for (let entries of Object.values(pot.translations)) {
|
|
168
|
+
for (let entry of Object.values(entries)) {
|
|
169
|
+
let references = getReferences(entry);
|
|
170
|
+
if (references.length) {
|
|
171
|
+
entry.comments.reference = references.sort(compareReferences).join('\n');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return po.compile(pot, { sort: compareEntries });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function formatCreationDate(date) {
|
|
179
|
+
return date
|
|
180
|
+
.toISOString()
|
|
181
|
+
.replace(/T/, ' ')
|
|
182
|
+
.replace(/:\d+\.\d+Z$/, '+0000');
|
|
183
|
+
}
|
|
184
|
+
|
|
117
185
|
function main() {
|
|
118
186
|
let files = listScanFiles();
|
|
119
187
|
|
|
@@ -122,16 +190,9 @@ function main() {
|
|
|
122
190
|
extracted = extracted.concat(extractFromFile(filePath));
|
|
123
191
|
}
|
|
124
192
|
|
|
125
|
-
let pot = po.parse(fs.readFileSync(
|
|
193
|
+
let pot = po.parse(fs.readFileSync(TEMPLATES_POT_PATH));
|
|
126
194
|
let translations = (pot.translations[''] = pot.translations[''] || {});
|
|
127
195
|
|
|
128
|
-
// xgettext-template does not stamp a creation date, so set it here (jsxgettext used to)
|
|
129
|
-
pot.headers = pot.headers || {};
|
|
130
|
-
pot.headers['POT-Creation-Date'] = new Date()
|
|
131
|
-
.toISOString()
|
|
132
|
-
.replace(/T/, ' ')
|
|
133
|
-
.replace(/:\d+\.\d+Z$/, '+0000');
|
|
134
|
-
|
|
135
196
|
for (let { msgid, msgidPlural, reference } of extracted) {
|
|
136
197
|
let entry = translations[msgid];
|
|
137
198
|
if (!entry) {
|
|
@@ -144,20 +205,39 @@ function main() {
|
|
|
144
205
|
}
|
|
145
206
|
|
|
146
207
|
entry.comments = entry.comments || {};
|
|
147
|
-
let references = entry
|
|
208
|
+
let references = getReferences(entry);
|
|
148
209
|
if (!references.includes(reference)) {
|
|
149
210
|
references.push(reference);
|
|
150
211
|
}
|
|
151
212
|
entry.comments.reference = references.join('\n');
|
|
152
213
|
}
|
|
153
214
|
|
|
154
|
-
|
|
155
|
-
|
|
215
|
+
// xgettext-template does not stamp a creation date (jsxgettext used to). The previous date is
|
|
216
|
+
// kept unless the content changed, so an unchanged tree leaves the file as it was
|
|
217
|
+
let existing = fs.existsSync(POT_PATH) ? fs.readFileSync(POT_PATH) : Buffer.alloc(0);
|
|
218
|
+
pot.headers = pot.headers || {};
|
|
219
|
+
pot.headers['POT-Creation-Date'] = existing.length ? po.parse(existing).headers['POT-Creation-Date'] : '';
|
|
220
|
+
let output = compileCanonical(pot);
|
|
221
|
+
|
|
222
|
+
let changed = !output.equals(existing);
|
|
223
|
+
if (changed) {
|
|
224
|
+
pot.headers['POT-Creation-Date'] = formatCreationDate(new Date());
|
|
225
|
+
fs.writeFileSync(POT_PATH, compileCanonical(pot));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
console.log(
|
|
229
|
+
`Extracted ${extracted.length} gettext strings from ${files.length} JS files into ${Path.relative(ROOT_DIR, POT_PATH)}${changed ? '' : ' (unchanged)'}`
|
|
230
|
+
);
|
|
156
231
|
}
|
|
157
232
|
|
|
158
233
|
if (require.main === module) {
|
|
159
|
-
|
|
234
|
+
try {
|
|
235
|
+
main();
|
|
236
|
+
} finally {
|
|
237
|
+
// Also on failure, so a broken run does not leave the intermediate file behind
|
|
238
|
+
fs.rmSync(TEMPLATES_POT_PATH, { force: true });
|
|
239
|
+
}
|
|
160
240
|
}
|
|
161
241
|
|
|
162
242
|
// Exported for the gettext coverage test, which walks the same scan set with the same helpers
|
|
163
|
-
module.exports = { listScanFiles, parseFile, calleeName, extractFromFile };
|
|
243
|
+
module.exports = { listScanFiles, parseFile, calleeName, extractFromFile, compareReferences, compileCanonical };
|
|
@@ -13,6 +13,15 @@ const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
|
13
13
|
async function init(args) {
|
|
14
14
|
const { server, CORS_CONFIG } = args;
|
|
15
15
|
|
|
16
|
+
// The queue ID of a message, as every per-message outbox route takes it
|
|
17
|
+
const outboxEntryParams = Joi.object({
|
|
18
|
+
queueId: Joi.string().max(100).example('d41f0423195f271f').description('Queue identifier for scheduled email').required()
|
|
19
|
+
}).label('OutboxEntryParams');
|
|
20
|
+
|
|
21
|
+
// What every per-message route answers for an unknown queue ID. The state refusals the
|
|
22
|
+
// outbox module throws (code NotFailed, ContentGone, NotDelayed) carry a 409 of their own
|
|
23
|
+
const notFound = () => Boom.boomify(new Error('Requested queue entry was not found'), { statusCode: 404 });
|
|
24
|
+
|
|
16
25
|
server.route({
|
|
17
26
|
method: 'GET',
|
|
18
27
|
path: '/v1/outbox',
|
|
@@ -98,9 +107,7 @@ async function init(args) {
|
|
|
98
107
|
try {
|
|
99
108
|
let outboxEntry = await outbox.get({ queueId: request.params.queueId, logger });
|
|
100
109
|
if (!outboxEntry) {
|
|
101
|
-
|
|
102
|
-
let error = Boom.boomify(new Error(message), { statusCode: 404 });
|
|
103
|
-
throw error;
|
|
110
|
+
throw notFound();
|
|
104
111
|
}
|
|
105
112
|
return maskSecrets(outboxEntry);
|
|
106
113
|
} catch (err) {
|
|
@@ -133,9 +140,7 @@ async function init(args) {
|
|
|
133
140
|
},
|
|
134
141
|
failAction,
|
|
135
142
|
|
|
136
|
-
params:
|
|
137
|
-
queueId: Joi.string().max(100).example('d41f0423195f271f').description('Queue identifier for scheduled email').required()
|
|
138
|
-
}).label('OutboxEntryParams')
|
|
143
|
+
params: outboxEntryParams
|
|
139
144
|
},
|
|
140
145
|
|
|
141
146
|
response: {
|
|
@@ -145,6 +150,126 @@ async function init(args) {
|
|
|
145
150
|
}
|
|
146
151
|
});
|
|
147
152
|
|
|
153
|
+
server.route({
|
|
154
|
+
method: 'POST',
|
|
155
|
+
path: '/v1/outbox/{queueId}/retry',
|
|
156
|
+
|
|
157
|
+
async handler(request) {
|
|
158
|
+
try {
|
|
159
|
+
let result = await outbox.retry({ queueId: request.params.queueId, logger });
|
|
160
|
+
if (!result) {
|
|
161
|
+
throw notFound();
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
} catch (err) {
|
|
165
|
+
handleError(request, err);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
options: {
|
|
169
|
+
description: 'Retry a failed message',
|
|
170
|
+
notes: 'Puts a message whose delivery failed for good back into the queue with a fresh set of delivery attempts. Only a failed message whose content is still stored can be retried: the content of the most recent failures is kept for this, within the bounds set by EENGINE_QUEUE_KEEP_FAILED_CONTENT and EENGINE_QUEUE_KEEP_FAILED_CONTENT_SIZE. A message that cannot be retried answers 409 with `code` NotFailed (the message is not in the failed state) or ContentGone (its content is no longer stored).',
|
|
171
|
+
tags: ['api', 'Outbox'],
|
|
172
|
+
|
|
173
|
+
plugins: {
|
|
174
|
+
mcp: {
|
|
175
|
+
name: 'retry_queued_message',
|
|
176
|
+
title: 'Retry failed message',
|
|
177
|
+
description:
|
|
178
|
+
'Retry a message whose delivery failed for good, by the queue id from get_outbox. Only a message in the failed state whose content is still stored can be retried; the error says when it cannot. A retried message starts over with a full set of delivery attempts.'
|
|
179
|
+
},
|
|
180
|
+
openapi: {
|
|
181
|
+
responses: apiResponses('Returns a retry marker. The message is waiting for a delivery attempt again.', 400, 401, 403, 404, 409, 429, 500)
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
auth: {
|
|
186
|
+
strategy: 'api-token',
|
|
187
|
+
mode: 'required'
|
|
188
|
+
},
|
|
189
|
+
cors: CORS_CONFIG,
|
|
190
|
+
|
|
191
|
+
validate: {
|
|
192
|
+
options: {
|
|
193
|
+
stripUnknown: false,
|
|
194
|
+
abortEarly: false,
|
|
195
|
+
convert: true
|
|
196
|
+
},
|
|
197
|
+
failAction,
|
|
198
|
+
|
|
199
|
+
params: outboxEntryParams
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
response: {
|
|
203
|
+
schema: Joi.object({
|
|
204
|
+
retried: apiBoolean().default(true).description('Was the message put back into the queue'),
|
|
205
|
+
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier of the message'),
|
|
206
|
+
messageId: Joi.string().allow(null, '').example('<test123@example.com>').description('Message-ID header value')
|
|
207
|
+
}).label('RetryOutboxEntryResponse'),
|
|
208
|
+
failAction: 'log'
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
server.route({
|
|
214
|
+
method: 'POST',
|
|
215
|
+
path: '/v1/outbox/{queueId}/promote',
|
|
216
|
+
|
|
217
|
+
async handler(request) {
|
|
218
|
+
try {
|
|
219
|
+
let result = await outbox.promote({ queueId: request.params.queueId, logger });
|
|
220
|
+
if (!result) {
|
|
221
|
+
throw notFound();
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
} catch (err) {
|
|
225
|
+
handleError(request, err);
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
options: {
|
|
229
|
+
description: 'Send a queued message now',
|
|
230
|
+
notes: 'Moves a message out of the delayed set so it is delivered at the next opportunity instead of at its scheduled time, or instead of after the backoff before its next attempt. Any other state answers 409 with `code` NotDelayed.',
|
|
231
|
+
tags: ['api', 'Outbox'],
|
|
232
|
+
|
|
233
|
+
plugins: {
|
|
234
|
+
mcp: {
|
|
235
|
+
name: 'send_queued_message_now',
|
|
236
|
+
title: 'Send queued message now',
|
|
237
|
+
description:
|
|
238
|
+
'Deliver a queued message at the next opportunity instead of waiting for its scheduled time or for the backoff before its next attempt, by the queue id from get_outbox. Only a message in the delayed state can be promoted.'
|
|
239
|
+
},
|
|
240
|
+
openapi: {
|
|
241
|
+
responses: apiResponses('Returns a promotion marker. The message is waiting for a delivery attempt.', 400, 401, 403, 404, 409, 429, 500)
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
auth: {
|
|
246
|
+
strategy: 'api-token',
|
|
247
|
+
mode: 'required'
|
|
248
|
+
},
|
|
249
|
+
cors: CORS_CONFIG,
|
|
250
|
+
|
|
251
|
+
validate: {
|
|
252
|
+
options: {
|
|
253
|
+
stripUnknown: false,
|
|
254
|
+
abortEarly: false,
|
|
255
|
+
convert: true
|
|
256
|
+
},
|
|
257
|
+
failAction,
|
|
258
|
+
|
|
259
|
+
params: outboxEntryParams
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
response: {
|
|
263
|
+
schema: Joi.object({
|
|
264
|
+
promoted: apiBoolean().default(true).description('Was the message moved out of the delayed set'),
|
|
265
|
+
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier of the message'),
|
|
266
|
+
messageId: Joi.string().allow(null, '').example('<test123@example.com>').description('Message-ID header value')
|
|
267
|
+
}).label('PromoteOutboxEntryResponse'),
|
|
268
|
+
failAction: 'log'
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
148
273
|
server.route({
|
|
149
274
|
method: 'DELETE',
|
|
150
275
|
path: '/v1/outbox/{queueId}',
|
|
@@ -188,9 +313,7 @@ async function init(args) {
|
|
|
188
313
|
},
|
|
189
314
|
failAction,
|
|
190
315
|
|
|
191
|
-
params:
|
|
192
|
-
queueId: Joi.string().max(100).example('d41f0423195f271f').description('Queue identifier for scheduled email').required()
|
|
193
|
-
}).label('OutboxEntryParams')
|
|
316
|
+
params: outboxEntryParams
|
|
194
317
|
},
|
|
195
318
|
|
|
196
319
|
response: {
|
|
@@ -255,6 +255,10 @@ const SURFACE_GRANTS = {
|
|
|
255
255
|
{ action: ACTION.WRITE, group: GROUP.TEMPLATE },
|
|
256
256
|
{ action: ACTION.DESTRUCTIVE, group: GROUP.TEMPLATE },
|
|
257
257
|
{ action: ACTION.READ, group: GROUP.OUTBOX },
|
|
258
|
+
// Retrying a failed message and sending a scheduled one now: operating the queue, which is
|
|
259
|
+
// why they sit here with the cancel and not in the mail table - the mail table is pinned
|
|
260
|
+
// so no issued mail token widens, and a mail agent resubmits instead
|
|
261
|
+
{ action: ACTION.WRITE, group: GROUP.OUTBOX },
|
|
258
262
|
{ action: ACTION.DESTRUCTIVE, group: GROUP.OUTBOX },
|
|
259
263
|
{ action: ACTION.READ, group: GROUP.DIAGNOSTICS },
|
|
260
264
|
{ action: ACTION.READ, group: GROUP.LOGS }
|
|
@@ -459,7 +463,13 @@ const GROUP_ROUTES = {
|
|
|
459
463
|
'POST /v1/delivery-test/account/{account}'
|
|
460
464
|
],
|
|
461
465
|
|
|
462
|
-
[GROUP.OUTBOX]: [
|
|
466
|
+
[GROUP.OUTBOX]: [
|
|
467
|
+
'GET /v1/outbox',
|
|
468
|
+
'GET /v1/outbox/{queueId}',
|
|
469
|
+
'POST /v1/outbox/{queueId}/retry',
|
|
470
|
+
'POST /v1/outbox/{queueId}/promote',
|
|
471
|
+
'DELETE /v1/outbox/{queueId}'
|
|
472
|
+
],
|
|
463
473
|
|
|
464
474
|
[GROUP.EXPORT]: [
|
|
465
475
|
'POST /v1/account/{account}/export',
|
package/lib/consts.js
CHANGED
|
@@ -314,10 +314,6 @@ module.exports = {
|
|
|
314
314
|
|
|
315
315
|
NONCE_BYTES: 16,
|
|
316
316
|
|
|
317
|
-
// Where the bull-board queue browser is mounted (lib/api-routes/bull-board-routes.js); the
|
|
318
|
-
// security headers key their bull-board profile on it
|
|
319
|
-
BULL_BOARD_BASE_PATH: '/admin/bull-board',
|
|
320
|
-
|
|
321
317
|
// Longest account id EmailEngine accepts. Defined here rather than only on `accountIdSchema`
|
|
322
318
|
// because the token audit log truncates to it while writing, before route validation has had a
|
|
323
319
|
// chance to reject a longer one, and the two have to agree: a log that trimmed at a different
|
|
@@ -423,7 +419,9 @@ module.exports = {
|
|
|
423
419
|
'ECONNREFUSED',
|
|
424
420
|
'UND_ERR_SOCKET',
|
|
425
421
|
'UND_ERR_CONNECT_TIMEOUT',
|
|
426
|
-
'UND_ERR_HEADERS_TIMEOUT'
|
|
422
|
+
'UND_ERR_HEADERS_TIMEOUT',
|
|
423
|
+
// a response body that stalled mid-transfer
|
|
424
|
+
'UND_ERR_BODY_TIMEOUT'
|
|
427
425
|
]),
|
|
428
426
|
|
|
429
427
|
// Error codes meaning "the IMAP connection is gone", as opposed to the command itself failing
|