emailengine-app 2.85.0 → 2.87.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/.ncurc.js +24 -6
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +97 -0
- package/DOCKER_DEPLOYMENT.md +2 -1
- package/Dockerfile +16 -3
- package/ENVIRONMENT.md +139 -0
- package/README.md +5 -1
- package/config/default.toml +2 -0
- package/copy-static-files.sh +4 -2
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +4 -3
- package/lib/account-assignment.js +19 -0
- package/lib/account.js +285 -195
- package/lib/api-error-codes.js +49 -0
- package/lib/api-reference/model.js +6 -1
- package/lib/api-routes/account-routes.js +91 -32
- package/lib/api-routes/blocklist-routes.js +68 -2
- package/lib/api-routes/delivery-test-routes.js +1 -1
- package/lib/api-routes/gateway-routes.js +82 -10
- package/lib/api-routes/index.js +4 -0
- package/lib/api-routes/license-routes.js +2 -2
- package/lib/api-routes/mailbox-routes.js +3 -3
- package/lib/api-routes/message-routes.js +15 -7
- package/lib/api-routes/oauth2-app-routes.js +15 -8
- package/lib/api-routes/outbox-routes.js +77 -66
- package/lib/api-routes/permission-map.js +55 -6
- package/lib/api-routes/scoped-routes.js +74 -0
- package/lib/api-routes/settings-routes.js +11 -4
- package/lib/api-routes/stats-routes.js +5 -1
- package/lib/api-routes/submit-routes.js +25 -5
- package/lib/api-routes/template-routes.js +7 -6
- package/lib/api-routes/token-routes.js +11 -5
- package/lib/api-routes/webhook-delivery-routes.js +262 -0
- package/lib/api-routes/webhook-route-routes.js +119 -4
- package/lib/calendar-event.js +81 -1
- package/lib/consts.js +38 -46
- package/lib/db.js +14 -6
- package/lib/delivery-error.js +6 -0
- package/lib/deprecations.js +270 -0
- package/lib/email-client/base-client.js +134 -158
- package/lib/email-client/fallback-poll.js +62 -0
- package/lib/email-client/gmail-client.js +59 -11
- package/lib/email-client/imap/adaptive-idle-store.js +73 -0
- package/lib/email-client/imap/adaptive-idle.js +278 -0
- package/lib/email-client/imap/connection-errors.js +14 -1
- package/lib/email-client/imap/idle-settings.js +31 -5
- package/lib/email-client/imap/listing-diff.js +37 -0
- package/lib/email-client/imap/mailbox.js +380 -227
- package/lib/email-client/imap/subconnection.js +7 -29
- package/lib/email-client/imap/sync-operations.js +220 -127
- package/lib/email-client/imap-client.js +227 -163
- package/lib/email-client/message-builder.js +14 -79
- package/lib/email-client/outlook-client.js +378 -338
- package/lib/email-client/smtp-pool-manager.js +16 -13
- package/lib/email-client/sync-state-fields.js +19 -0
- package/lib/encrypt.js +157 -41
- package/lib/enum-descriptions.js +3 -1
- package/lib/env-setting-overrides.js +288 -0
- package/lib/export-worker.js +751 -0
- package/lib/export.js +64 -15
- package/lib/field-usage.js +1 -1
- package/lib/gateway.js +17 -1
- package/lib/get-raw-email.js +35 -108
- package/lib/health.js +75 -0
- package/lib/lock-run.js +119 -0
- package/lib/logger-consts.js +48 -0
- package/lib/logger.js +1 -1
- package/lib/lua/z-head-scores.lua +28 -0
- package/lib/network-errors.js +1 -1
- package/lib/node-version.js +24 -0
- package/lib/notify-attachments.js +20 -1
- package/lib/oauth/gmail.js +54 -29
- package/lib/oauth2-apps.js +630 -655
- package/lib/otp.js +66 -0
- package/lib/outbox.js +184 -54
- package/lib/parse-message.js +3 -3
- package/lib/privileged-settings.js +2 -2
- package/lib/queue-browser/definitions.js +11 -0
- package/lib/queue-browser/index.js +68 -19
- package/lib/queue-job-actions.js +18 -1
- package/lib/queue-retention.js +48 -12
- package/lib/queue-stats.js +11 -2
- package/lib/read-env-value.js +3 -0
- package/lib/redis-memory-warnings.js +99 -0
- package/lib/redis-reconnect.js +29 -0
- package/lib/request-timing.js +23 -0
- package/lib/respawn-backoff.js +35 -0
- package/lib/rewrite-text-nodes.js +19 -59
- package/lib/schemas.js +225 -41
- package/lib/settings.js +6 -2
- package/lib/smtp-auth.js +19 -1
- package/lib/swagger-options.js +2 -2
- package/lib/thread-diagnostics.js +18 -1
- package/lib/tls/provision.js +6 -3
- package/lib/token-audit-log.js +19 -20
- package/lib/token-permission-view.js +4 -3
- package/lib/tools.js +8 -41
- package/lib/ui-routes/admin-config-routes.js +64 -90
- package/lib/ui-routes/admin-entities-routes.js +2 -14
- package/lib/ui-routes/imap-idle-field.js +1 -1
- package/lib/ui-routes/outlook-subscription-view.js +1 -1
- package/lib/ui-routes/overridable-fields.js +84 -0
- package/lib/ui-routes/queue-routes.js +8 -5
- package/lib/ui-routes/settings-page.js +6 -0
- package/lib/utils/decode-headers.js +3 -12
- package/lib/utils/filter-empty.js +20 -0
- package/lib/utils/int-setting.js +48 -0
- package/lib/utils/tracking-settings.js +35 -0
- package/lib/web-safe-html.js +18 -105
- package/lib/webhook-delivery.js +461 -0
- package/lib/webhook-failures.js +132 -0
- package/lib/webhook-request.js +29 -1
- package/lib/webhook-routing.js +30 -1
- package/lib/webhook-test.js +88 -0
- package/lib/webhooks.js +59 -41
- package/lib/worker-rpc-error.js +2 -1
- package/package.json +28 -26
- package/sbom.json +600 -678
- package/server.js +149 -76
- package/static/css/flyonui.css +1 -1
- package/static/js/ace/ace.js +1 -1
- package/static/js/ee-client.js +650 -196
- package/static/licenses.html +49 -59
- package/translations/messages.pot +26 -26
- package/views/config/security.hbs +22 -0
- package/views/config/service.hbs +44 -0
- package/views/config/webhooks.hbs +36 -0
- package/views/layout/app.hbs +9 -6
- package/views/legal.hbs +8 -0
- package/views/partials/queue_retention_note.hbs +12 -8
- package/views/partials/ui/env-managed-alert.hbs +16 -7
- package/workers/api.js +112 -37
- package/workers/export.js +16 -631
- package/workers/imap.js +13 -0
- package/workers/smtp.js +9 -11
- package/workers/webhooks.js +18 -432
- package/lib/email-client/outlook-fallback-poll.js +0 -30
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { mapConcurrent } = require('./utils/map-concurrent');
|
|
4
|
+
|
|
5
|
+
// Attachment downloads a Gmail API or Graph client runs at once for one message
|
|
6
|
+
const API_ATTACHMENT_CONCURRENCY = 4;
|
|
7
|
+
|
|
3
8
|
// Whether an attachment's content belongs in a messageNew payload under the notifyAttachmentSize
|
|
4
9
|
// setting. Both processNew() implementations ask it before downloading an attachment and
|
|
5
10
|
// formatPayload() asks it again for content loaded on other paths, such as inline images the
|
|
@@ -14,4 +19,18 @@ function withinNotifyAttachmentSize(attachment, notifyAttachmentSize) {
|
|
|
14
19
|
return size <= notifyAttachmentSize;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Loads the content of every attachment the messageNew webhook carries (`notifyAttachments`), the
|
|
24
|
+
* ones over `notifyAttachmentSize` excepted. Shared by the IMAP mailbox and the API clients
|
|
25
|
+
* @param {Object[]} attachments - The message's attachments
|
|
26
|
+
* @param {number} sizeLimit - The notifyAttachmentSize setting
|
|
27
|
+
* @param {Function} load - async (attachment) => void, sets attachment.content (base64) when it can
|
|
28
|
+
* @param {number} [concurrency=1] - Downloads at a time: one for IMAP, where they share the
|
|
29
|
+
* connection, a few for the API clients, where each is an HTTP request of its own
|
|
30
|
+
*/
|
|
31
|
+
async function loadNotifyAttachments(attachments, sizeLimit, load, concurrency = 1) {
|
|
32
|
+
const pending = (attachments || []).filter(attachment => withinNotifyAttachmentSize(attachment, sizeLimit) && !attachment.content);
|
|
33
|
+
await mapConcurrent(pending, concurrency, load);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { withinNotifyAttachmentSize, loadNotifyAttachments, API_ATTACHMENT_CONCURRENCY };
|
package/lib/oauth/gmail.js
CHANGED
|
@@ -877,6 +877,14 @@ class GmailOauth {
|
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
879
|
|
|
880
|
+
/**
|
|
881
|
+
* Asks Google to revoke a grant. Never throws: the outcome is returned for the caller to act on.
|
|
882
|
+
*
|
|
883
|
+
* @param {string} token Refresh or access token of the grant
|
|
884
|
+
* @returns {Promise<{revoked: boolean, status?: number, reason?: string, error?: string}>}
|
|
885
|
+
* `reason` is TokenInvalid when Google no longer knows the token (already revoked or expired),
|
|
886
|
+
* ProviderRefused for any other refusal and RequestFailed when no answer arrived
|
|
887
|
+
*/
|
|
880
888
|
async revokeToken(token) {
|
|
881
889
|
const fetchOpts = {
|
|
882
890
|
method: 'post',
|
|
@@ -887,41 +895,58 @@ class GmailOauth {
|
|
|
887
895
|
body: new URLSearchParams({ token }).toString()
|
|
888
896
|
};
|
|
889
897
|
|
|
898
|
+
let res;
|
|
890
899
|
try {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
let responseText;
|
|
894
|
-
try {
|
|
895
|
-
responseText = await res.text();
|
|
896
|
-
} catch (err) {
|
|
897
|
-
// ignore
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
if (this.logger) {
|
|
901
|
-
this.logger.info({
|
|
902
|
-
msg: 'OAuth2 token revocation request',
|
|
903
|
-
action: 'oauth2Fetch',
|
|
904
|
-
fn: 'revokeToken',
|
|
905
|
-
url: this.revokeUrl,
|
|
906
|
-
success: !!res.ok,
|
|
907
|
-
status: res.status
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
if (!res.ok) {
|
|
912
|
-
if (this.logger) {
|
|
913
|
-
this.logger.warn({
|
|
914
|
-
msg: 'OAuth2 token revocation failed',
|
|
915
|
-
status: res.status,
|
|
916
|
-
response: responseText
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
}
|
|
900
|
+
res = await fetchCmd(this.revokeUrl, Object.assign(fetchOpts, { dispatcher: httpAgent.forRoute(this.route).retry }));
|
|
920
901
|
} catch (err) {
|
|
921
902
|
if (this.logger) {
|
|
922
903
|
this.logger.warn({ msg: 'OAuth2 token revocation error', err });
|
|
923
904
|
}
|
|
905
|
+
// The low-level code (ECONNREFUSED, UND_ERR_CONNECT_TIMEOUT) says more than fetch's own "fetch failed"
|
|
906
|
+
return { revoked: false, reason: 'RequestFailed', error: err.cause?.code || err.code || err.message };
|
|
924
907
|
}
|
|
908
|
+
|
|
909
|
+
let responseText;
|
|
910
|
+
try {
|
|
911
|
+
responseText = await res.text();
|
|
912
|
+
} catch (err) {
|
|
913
|
+
// ignore
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
if (this.logger) {
|
|
917
|
+
this.logger.info({
|
|
918
|
+
msg: 'OAuth2 token revocation request',
|
|
919
|
+
action: 'oauth2Fetch',
|
|
920
|
+
fn: 'revokeToken',
|
|
921
|
+
url: this.revokeUrl,
|
|
922
|
+
success: !!res.ok,
|
|
923
|
+
status: res.status
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
if (res.ok) {
|
|
928
|
+
return { revoked: true, status: res.status };
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
if (this.logger) {
|
|
932
|
+
this.logger.warn({
|
|
933
|
+
msg: 'OAuth2 token revocation failed',
|
|
934
|
+
status: res.status,
|
|
935
|
+
response: responseText
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// Only the OAuth2 error code, never the response body: it is the part a caller can act on
|
|
940
|
+
let error;
|
|
941
|
+
try {
|
|
942
|
+
error = JSON.parse(responseText).error;
|
|
943
|
+
} catch (err) {
|
|
944
|
+
// not a JSON error response
|
|
945
|
+
}
|
|
946
|
+
return Object.assign(
|
|
947
|
+
{ revoked: false, status: res.status, reason: error === 'invalid_token' ? 'TokenInvalid' : 'ProviderRefused' },
|
|
948
|
+
typeof error === 'string' ? { error } : {}
|
|
949
|
+
);
|
|
925
950
|
}
|
|
926
951
|
}
|
|
927
952
|
|