emailengine-app 2.82.0 → 2.82.2
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 +23 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +51 -0
- package/DOCKER_DEPLOYMENT.md +13 -12
- package/bin/emailengine.js +77 -7
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +35 -10
- package/lib/api-routes/account-binding.js +58 -0
- package/lib/api-routes/account-routes.js +48 -9
- package/lib/api-routes/behavior-notes.js +4 -0
- package/lib/api-routes/gateway-routes.js +10 -2
- package/lib/api-routes/message-routes.js +10 -3
- package/lib/api-routes/outbox-routes.js +1 -1
- package/lib/api-routes/settings-routes.js +1 -2
- package/lib/api-routes/token-routes.js +1 -1
- package/lib/autodetect-imap-settings.js +146 -4
- package/lib/consts.js +12 -0
- package/lib/db.js +1 -19
- package/lib/delivery-error.js +68 -1
- package/lib/email-client/base-client.js +6 -13
- package/lib/email-client/credential-errors.js +21 -5
- package/lib/email-client/gmail-client.js +2 -2
- package/lib/email-client/imap-client.js +2 -1
- package/lib/email-client/message-builder.js +41 -11
- package/lib/email-client/outlook-client.js +263 -84
- package/lib/email-client/outlook-fallback-poll.js +30 -0
- package/lib/enum-descriptions.js +5 -1
- package/lib/export.js +8 -2
- package/lib/gateway.js +5 -0
- package/lib/get-secret.js +1 -21
- package/lib/mcp/tools.js +95 -36
- package/lib/oauth/gmail.js +42 -12
- package/lib/oauth/mail-ru.js +24 -17
- package/lib/oauth/outlook.js +34 -24
- package/lib/oauth/scope-checker.js +35 -1
- package/lib/oauth/scope-list.js +55 -0
- package/lib/oauth/token-fetch.js +47 -0
- package/lib/oauth2-apps.js +16 -47
- package/lib/outbox.js +2 -7
- package/lib/queue-retention.js +4 -2
- package/lib/read-env-value.js +33 -2
- package/lib/schemas.js +62 -15
- package/lib/token-audit-log.js +3 -2
- package/lib/tools.js +1 -1
- package/lib/ui-routes/account-routes.js +40 -7
- package/lib/ui-routes/oauth-config-routes.js +3 -14
- package/lib/ui-routes/outlook-subscription-view.js +36 -0
- package/lib/ui-routes/route-helpers.js +25 -37
- package/lib/ui-routes/special-use-paths.js +33 -0
- package/lib/utils/network.js +9 -17
- package/package.json +18 -18
- package/sbom.json +1 -1
- package/server.js +21 -3
- package/setup-production.sh +16 -7
- package/static/licenses.html +30 -20
- package/translations/messages.pot +74 -56
- package/views/account-workspace-error.hbs +30 -0
- package/views/accounts/account.hbs +14 -6
- package/views/accounts/edit.hbs +11 -2
- package/views/internals/index.hbs +1 -1
- package/views/partials/gmail_api_scopes.hbs +16 -0
- package/views/partials/oauth_form.hbs +67 -94
- package/views/partials/oauth_pubsub_app_select.hbs +43 -0
- package/views/partials/scope_info.hbs +14 -23
- package/workers/api.js +62 -27
- package/workers/imap.js +6 -3
- package/workers/submit.js +2 -5
|
@@ -20,6 +20,7 @@ const { redis } = require('../db');
|
|
|
20
20
|
const { toolGrants } = require('../mcp/tools');
|
|
21
21
|
const { Account, accountsExist, accountSummary, isAuthFailureDisabled, isAccessTokenInvalidated } = require('../account');
|
|
22
22
|
const { REDIS_PREFIX, DEFAULT_PAGE_SIZE } = require('../consts');
|
|
23
|
+
const { formatOutlookSubscription } = require('./outlook-subscription-view');
|
|
23
24
|
const { oauth2ProviderData } = require('../oauth2-apps');
|
|
24
25
|
const exampleDocumentsPayloads = require('../payload-examples-documents.json');
|
|
25
26
|
|
|
@@ -224,20 +225,7 @@ function formatAccountData(account, gt) {
|
|
|
224
225
|
account.oauth2.accessTokenInvalidated = isAccessTokenInvalidated(account.oauth2);
|
|
225
226
|
|
|
226
227
|
if (account.outlookSubscription) {
|
|
227
|
-
account.outlookSubscription
|
|
228
|
-
? account.outlookSubscription.expirationDateTime.toISOString()
|
|
229
|
-
: false;
|
|
230
|
-
|
|
231
|
-
let state = account.outlookSubscription.state || {};
|
|
232
|
-
|
|
233
|
-
account.outlookSubscription.isValid =
|
|
234
|
-
state.state !== 'error' && account.outlookSubscription.expirationDateTime && account.outlookSubscription.expirationDateTime > new Date();
|
|
235
|
-
|
|
236
|
-
account.outlookSubscription.stateLabel = (state.state || '').replace(/^./, c => c.toUpperCase());
|
|
237
|
-
|
|
238
|
-
if ((state.state === 'created' && !account.outlookSubscription.expirationDateTime) || account.outlookSubscription.expirationDateTime < new Date()) {
|
|
239
|
-
account.outlookSubscription.stateLabel = 'Expired';
|
|
240
|
-
}
|
|
228
|
+
formatOutlookSubscription(account.outlookSubscription, account.state);
|
|
241
229
|
}
|
|
242
230
|
}
|
|
243
231
|
|
|
@@ -350,33 +338,32 @@ function jsonErrorPayload(err) {
|
|
|
350
338
|
return { success: false, error: err.code || 'Error', message: err.message };
|
|
351
339
|
}
|
|
352
340
|
|
|
353
|
-
// The
|
|
354
|
-
//
|
|
355
|
-
//
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
|
|
361
|
-
// form navigations, so the browser still renders the page.
|
|
362
|
-
function identityErrorView(request, h, { expectedEmail, actualEmail, retryUrl }) {
|
|
341
|
+
// The refusal pages of the hosted setup flow, where the mailbox owner made a correctable choice and is
|
|
342
|
+
// given a way back (`retryUrl`) rather than being bounced to the calling application. Rendered from both
|
|
343
|
+
// arms of the form - the OAuth2 callback in workers/api.js and the IMAP arm in ./account-routes.js, in
|
|
344
|
+
// different workers - so the view name, the layout and the refusal status are decided here. 403 rather
|
|
345
|
+
// than the 200 that the sibling views/oauth-scope-error.hbs returns: these are refused requests, the
|
|
346
|
+
// surrounding refusals in the same flow already answer 403, and every call site is a plain form
|
|
347
|
+
// navigation, so the browser still renders the page.
|
|
348
|
+
function setupRefusalView(request, h, view, context) {
|
|
363
349
|
return h
|
|
364
|
-
.view(
|
|
365
|
-
'
|
|
366
|
-
|
|
367
|
-
pageTitleFull: request.app.gt.gettext('Email Account Setup'),
|
|
368
|
-
templateLocale: request.app.locale,
|
|
369
|
-
expectedEmail,
|
|
370
|
-
actualEmail,
|
|
371
|
-
retryUrl
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
layout: 'public'
|
|
375
|
-
}
|
|
376
|
-
)
|
|
350
|
+
.view(view, Object.assign({ pageTitleFull: request.app.gt.gettext('Email Account Setup'), templateLocale: request.app.locale }, context), {
|
|
351
|
+
layout: 'public'
|
|
352
|
+
})
|
|
377
353
|
.code(403);
|
|
378
354
|
}
|
|
379
355
|
|
|
356
|
+
// "Wrong account": a setup link pinned to one address was completed as another. Only `retryUrl` is
|
|
357
|
+
// arm-specific - the OAuth arm sends the user back to the provider, the IMAP arm back to the form.
|
|
358
|
+
function identityErrorView(request, h, { expectedEmail, actualEmail, retryUrl }) {
|
|
359
|
+
return setupRefusalView(request, h, 'account-identity-error', { expectedEmail, actualEmail, retryUrl });
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// "Work account required": the application takes only Workspace accounts and a personal one signed in.
|
|
363
|
+
function workspaceErrorView(request, h, { actualEmail, retryUrl }) {
|
|
364
|
+
return setupRefusalView(request, h, 'account-workspace-error', { actualEmail, retryUrl });
|
|
365
|
+
}
|
|
366
|
+
|
|
380
367
|
// View-model for the ui/pagination partial: prev/next URLs plus the numbered page links.
|
|
381
368
|
// basePath is the URL path without a query string (leading slash optional, matching the
|
|
382
369
|
// `new URL(path, base)` convention the route modules already use); data is a listing
|
|
@@ -605,6 +592,7 @@ module.exports = {
|
|
|
605
592
|
accountPickerEntry,
|
|
606
593
|
accountPickerSelection,
|
|
607
594
|
identityErrorView,
|
|
595
|
+
workspaceErrorView,
|
|
608
596
|
compiledFragments,
|
|
609
597
|
closedAfterConnectMessage,
|
|
610
598
|
accountStateLabel,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { SPECIAL_USE_PATH_TYPES } = require('../consts');
|
|
4
|
+
|
|
5
|
+
// The words the admin UI shows for each special-use folder override. The TYPES are not re-listed
|
|
6
|
+
// here: SPECIAL_USE_PATH_TYPES in lib/consts.js is the contract the IMAP client reads (it turns the
|
|
7
|
+
// list into the specialUseHints it passes to LIST) and the account schemas declare a field per entry,
|
|
8
|
+
// so a type added there reaches the form with it rather than needing a second edit.
|
|
9
|
+
//
|
|
10
|
+
// Split out of ./account-routes.js, which is at its size budget, and because this is page copy rather
|
|
11
|
+
// than routing: the same shape as ./ai-options.js next to it.
|
|
12
|
+
const SPECIAL_USE_PATH_LABELS = {
|
|
13
|
+
sent: { label: 'Sent Mail', description: 'Store copies of sent emails in this folder.' },
|
|
14
|
+
drafts: { label: 'Drafts', description: 'Treat this folder as the Drafts folder.' },
|
|
15
|
+
junk: { label: 'Junk', description: 'Treat this folder as the Junk folder.' },
|
|
16
|
+
trash: { label: 'Trash', description: 'Treat this folder as the Trash folder, where deleted messages are moved.' },
|
|
17
|
+
archive: { label: 'Archive', description: 'Treat this folder as the Archive folder.' }
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The override fields as the edit form and the account page consume them: the account field name, the
|
|
22
|
+
* form input id and the words to show, in the order the two templates render them.
|
|
23
|
+
*
|
|
24
|
+
* `{ type, key, inputId, label, description }` per entry. The form renders one input per entry from
|
|
25
|
+
* `inputId`, its joi schema is generated per entry, and the update loop writes `key` onto the account
|
|
26
|
+
* - so the four of them cannot drift. Only `sentMailPath` was ever offered on the form, which is how
|
|
27
|
+
* the other four came to be settable over PUT /v1/account/{account} alone.
|
|
28
|
+
*/
|
|
29
|
+
const SPECIAL_USE_PATH_FIELDS = SPECIAL_USE_PATH_TYPES.map(type =>
|
|
30
|
+
Object.assign({ type, key: `${type}MailPath`, inputId: `imap_${type}MailPath` }, SPECIAL_USE_PATH_LABELS[type])
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
module.exports = { SPECIAL_USE_PATH_FIELDS, SPECIAL_USE_PATH_LABELS };
|
package/lib/utils/network.js
CHANGED
|
@@ -177,6 +177,11 @@ function resolveClientIp({ remoteAddress, forwardedFor, enableApiProxy, trustedP
|
|
|
177
177
|
return remoteAddress;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
// Reverse-DNS suffixes of the scanners whose fetches must not count as a real open or click. No `g`
|
|
181
|
+
// flag: RegExp#test() advances lastIndex on a global regex, so a hoisted one would skip every other
|
|
182
|
+
// call - which is exactly how a shared instance of this would start letting scanner traffic through.
|
|
183
|
+
const SCANNER_HOSTNAME_PATTERN = /\bbarracuda\.com$|\bspfbl\.net$/i;
|
|
184
|
+
|
|
180
185
|
/**
|
|
181
186
|
* Detects if a request is from an automated scanner (Google, Barracuda, etc.)
|
|
182
187
|
* @param {string} ip - IP address to check
|
|
@@ -213,23 +218,10 @@ async function detectAutomatedRequest(ip) {
|
|
|
213
218
|
});
|
|
214
219
|
}
|
|
215
220
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const hostname = []
|
|
221
|
-
.concat(hostnames || [])
|
|
222
|
-
.shift()
|
|
223
|
-
.toString()
|
|
224
|
-
.trim()
|
|
225
|
-
.toLowerCase();
|
|
226
|
-
|
|
227
|
-
// Barracuda, spfbl
|
|
228
|
-
if (/\bbarracuda\.com$|\bspfbl\.net$/gi.test(hostname)) {
|
|
229
|
-
return true;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return false;
|
|
221
|
+
// Every PTR record, not just the first. An address is under no obligation to list the scanner's
|
|
222
|
+
// own name first, and this filter is the only thing keeping scanner fetches out of trackOpen and
|
|
223
|
+
// trackClick - reading one record of several reported them as real opens and clicks.
|
|
224
|
+
return [].concat(hostnames || []).some(entry => SCANNER_HOSTNAME_PATTERN.test(String(entry).trim().toLowerCase()));
|
|
233
225
|
}
|
|
234
226
|
|
|
235
227
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailengine-app",
|
|
3
|
-
"version": "2.82.
|
|
3
|
+
"version": "2.82.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"productTitle": "EmailEngine",
|
|
6
6
|
"description": "Email Sync Engine",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build-dist": "pkg --compress Brotli package.json && npm install && node winconf.js",
|
|
27
27
|
"build-dist-fast": "pkg --debug package.json && npm install && node winconf.js",
|
|
28
28
|
"licenses": "node list-generate.js",
|
|
29
|
-
"gettext": "find ./views -name \"*.hbs\" -print0 | xargs -0 xgettext-template -L Handlebars -o translations/messages.pot
|
|
29
|
+
"gettext": "find ./views -name \"*.hbs\" -print0 | xargs -0 xgettext-template -L Handlebars --force-po -o - > translations/messages.pot.tmp && mv translations/messages.pot.tmp translations/messages.pot && node gettext-extract.js",
|
|
30
30
|
"update": "rm -rf node_modules package-lock.json && ncu -u && npm install && ./copy-static-files.sh && npm run licenses && npm run gettext",
|
|
31
31
|
"test-gmail-api": "node lib/email-client/gmail-client.js --dbs.redis=redis://127.0.0.1/11",
|
|
32
32
|
"format": "prettier --write 'lib/**/*.js' 'workers/**/*.js' 'test/**/*.js' '*.js'",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://emailengine.app/",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@bull-board/api": "9.10.
|
|
55
|
-
"@bull-board/hapi": "9.10.
|
|
54
|
+
"@bull-board/api": "9.10.4",
|
|
55
|
+
"@bull-board/hapi": "9.10.4",
|
|
56
56
|
"@hapi/accept": "6.0.3",
|
|
57
57
|
"@hapi/bell": "13.2.0",
|
|
58
58
|
"@hapi/boom": "10.0.1",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"@msgpack/msgpack": "3.1.3",
|
|
65
65
|
"@postalsys/bounce-classifier": "3.0.1",
|
|
66
66
|
"@postalsys/certs": "1.4.4",
|
|
67
|
-
"@postalsys/email-ai-tools": "2.2.
|
|
68
|
-
"@postalsys/email-content": "0.1.
|
|
67
|
+
"@postalsys/email-ai-tools": "2.2.1",
|
|
68
|
+
"@postalsys/email-content": "0.1.11",
|
|
69
69
|
"@postalsys/email-text-tools": "2.4.18",
|
|
70
70
|
"@postalsys/gettext": "4.1.1",
|
|
71
71
|
"@postalsys/joi-messages": "1.3.1",
|
|
72
72
|
"@postalsys/templates": "2.0.3",
|
|
73
|
-
"@sentry/node-core": "10.
|
|
73
|
+
"@sentry/node-core": "10.76.0",
|
|
74
74
|
"@simplewebauthn/server": "14.0.3",
|
|
75
|
-
"@zone-eu/mailsplit": "5.4.
|
|
75
|
+
"@zone-eu/mailsplit": "5.4.20",
|
|
76
76
|
"@zone-eu/wild-config": "1.7.7",
|
|
77
77
|
"bullmq": "6.3.11",
|
|
78
78
|
"compare-versions": "6.1.1",
|
|
@@ -87,27 +87,27 @@
|
|
|
87
87
|
"html-to-text": "10.0.1",
|
|
88
88
|
"ical.js": "2.2.1",
|
|
89
89
|
"iconv-lite": "0.7.3",
|
|
90
|
-
"imapflow": "2.2.
|
|
90
|
+
"imapflow": "2.2.5",
|
|
91
91
|
"ioredfour": "1.4.4",
|
|
92
92
|
"ioredis": "6.0.0",
|
|
93
93
|
"ipaddr.js": "2.5.0",
|
|
94
94
|
"joi": "18.2.9",
|
|
95
|
-
"libbase64": "1.3.
|
|
96
|
-
"libmime": "5.4.
|
|
95
|
+
"libbase64": "1.3.2",
|
|
96
|
+
"libmime": "5.4.7",
|
|
97
97
|
"libqp": "2.1.2",
|
|
98
|
-
"mailparser": "3.9.
|
|
98
|
+
"mailparser": "3.9.36",
|
|
99
99
|
"marked": "15.0.12",
|
|
100
100
|
"minimist": "1.2.8",
|
|
101
101
|
"murmurhash": "2.0.1",
|
|
102
|
-
"nanoid": "3.3.
|
|
103
|
-
"nodemailer": "10.0.
|
|
102
|
+
"nanoid": "3.3.20",
|
|
103
|
+
"nodemailer": "10.0.15",
|
|
104
104
|
"pino": "10.3.1",
|
|
105
105
|
"prom-client": "15.1.3",
|
|
106
106
|
"psl": "1.15.0",
|
|
107
107
|
"pubface": "1.1.18",
|
|
108
108
|
"punycode.js": "2.3.1",
|
|
109
109
|
"qrcode-generator": "2.0.4",
|
|
110
|
-
"smtp-server": "3.19.
|
|
110
|
+
"smtp-server": "3.19.17",
|
|
111
111
|
"socks": "2.8.10",
|
|
112
112
|
"timezones-list": "3.1.0",
|
|
113
113
|
"undici": "7.30.0"
|
|
@@ -125,13 +125,13 @@
|
|
|
125
125
|
"acorn-walk": "8.3.5",
|
|
126
126
|
"chai": "4.5.0",
|
|
127
127
|
"eerawlog": "1.5.5",
|
|
128
|
-
"eslint": "10.
|
|
128
|
+
"eslint": "10.12.0",
|
|
129
129
|
"flyonui": "2.4.1",
|
|
130
|
-
"pino-pretty": "13.
|
|
130
|
+
"pino-pretty": "13.2.0",
|
|
131
131
|
"prettier": "3.9.9",
|
|
132
132
|
"resedit": "3.1.0",
|
|
133
133
|
"spdx-satisfies": "6.0.0",
|
|
134
|
-
"supertest": "7.3.
|
|
134
|
+
"supertest": "7.3.1",
|
|
135
135
|
"tailwindcss": "4.3.3",
|
|
136
136
|
"xgettext-template": "5.0.0"
|
|
137
137
|
},
|