emailengine-app 2.90.0 → 2.91.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 +29 -0
- package/Dockerfile +2 -2
- package/ENVIRONMENT.md +24 -23
- package/README.md +1 -1
- package/data/google-crawlers.json +1 -1
- package/lib/account-assignment.js +26 -9
- package/lib/account.js +38 -9
- package/lib/api-routes/account-routes.js +7 -0
- package/lib/autodetect-imap-settings.js +401 -64
- package/lib/consts.js +4 -0
- package/lib/email-client/imap-client.js +5 -5
- package/lib/email-client/message-builder.js +4 -5
- package/lib/imapproxy/imap-server.js +5 -5
- package/lib/logger-consts.js +37 -1
- package/lib/mail-probe.js +157 -0
- package/lib/oauth/mail-ru.js +9 -2
- package/lib/read-env-value.js +30 -6
- package/lib/redis-backend-warnings.js +70 -0
- package/lib/tools.js +17 -28
- package/lib/ui-routes/account-routes.js +34 -31
- package/lib/ui-routes/account-setup.js +1 -1
- package/lib/ui-routes/provider-signin.js +187 -0
- package/lib/ui-routes/route-helpers.js +1 -1
- package/lib/ui-routes/unsubscribe-routes.js +2 -2
- package/package.json +13 -13
- package/sbom.json +231 -260
- package/server.js +80 -1
- package/static/css/public.css +55 -1
- package/static/licenses.html +126 -148
- package/translations/de.mo +0 -0
- package/translations/de.po +429 -390
- package/translations/en.mo +0 -0
- package/translations/en.po +342 -257
- package/translations/es.mo +0 -0
- package/translations/es.po +440 -395
- package/translations/et.mo +0 -0
- package/translations/et.po +425 -375
- package/translations/fr.mo +0 -0
- package/translations/fr.po +425 -383
- package/translations/it.mo +0 -0
- package/translations/it.po +441 -394
- package/translations/ja.mo +0 -0
- package/translations/ja.po +408 -335
- package/translations/messages.pot +136 -89
- package/translations/nl.mo +0 -0
- package/translations/nl.po +419 -382
- package/translations/pl.mo +0 -0
- package/translations/pl.po +425 -379
- package/translations/sv.mo +0 -0
- package/translations/sv.po +440 -388
- package/translations/tr.mo +0 -0
- package/translations/tr.po +441 -387
- package/views/account-identity-error.hbs +1 -1
- package/views/account-workspace-error.hbs +2 -2
- package/views/accounts/register/imap-server.hbs +22 -7
- package/views/accounts/register/imap.hbs +3 -0
- package/views/accounts/register/index.hbs +1 -27
- package/views/accounts/register/provider-signin.hbs +58 -0
- package/views/oauth-scope-error.hbs +1 -1
- package/views/partials/provider_signin_button.hbs +30 -0
- package/views/queues/index.hbs +1 -1
- package/views/redirect.hbs +1 -1
- package/views/unsubscribe.hbs +6 -6
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// The hosted setup form's answer to autodiscovery recognizing a Gmail or Microsoft mailbox on the
|
|
4
|
+
// IMAP path: which OAuth2 applications can sign that mailbox in instead of a password, and the page
|
|
5
|
+
// that offers them.
|
|
6
|
+
|
|
7
|
+
const { oauth2Apps, oauth2ProviderData } = require('../oauth2-apps');
|
|
8
|
+
const { autodetectImapSettings, isConsumerMailbox } = require('../autodetect-imap-settings');
|
|
9
|
+
|
|
10
|
+
// Outlook application authorities that can sign in a personal (Outlook.com) account. A tenant id
|
|
11
|
+
// or `organizations` signs in work accounts only, `consumers` personal ones only.
|
|
12
|
+
const CONSUMER_AUTHORITIES = new Set(['common', 'consumers']);
|
|
13
|
+
|
|
14
|
+
// What autodiscovery found for an address, kept while the sign-in page is open so that choosing
|
|
15
|
+
// "Continue with IMAP" there does not run the whole lookup again. Keyed by the setup link's nonce
|
|
16
|
+
// and the address, so one link's answer never reaches another link. Bounded and short-lived: a
|
|
17
|
+
// cosmetic shortcut, and a miss simply runs the lookup.
|
|
18
|
+
const DISCOVERY_CACHE = new Map();
|
|
19
|
+
const DISCOVERY_CACHE_TTL = 10 * 60 * 1000;
|
|
20
|
+
const DISCOVERY_CACHE_MAX_ENTRIES = 1000;
|
|
21
|
+
|
|
22
|
+
const discoveryKey = (nonce, email) => (nonce ? `${nonce}:${String(email).trim().toLowerCase()}` : null);
|
|
23
|
+
|
|
24
|
+
function rememberDiscovery(key, serverSettings) {
|
|
25
|
+
if (!key) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
DISCOVERY_CACHE.delete(key);
|
|
29
|
+
if (DISCOVERY_CACHE.size >= DISCOVERY_CACHE_MAX_ENTRIES) {
|
|
30
|
+
DISCOVERY_CACHE.delete(DISCOVERY_CACHE.keys().next().value);
|
|
31
|
+
}
|
|
32
|
+
DISCOVERY_CACHE.set(key, { serverSettings, expires: Date.now() + DISCOVERY_CACHE_TTL });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function recallDiscovery(key) {
|
|
36
|
+
const entry = key && DISCOVERY_CACHE.get(key);
|
|
37
|
+
if (!entry) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
DISCOVERY_CACHE.delete(key);
|
|
41
|
+
return entry.expires > Date.now() ? entry.serverSettings : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Discovers the server settings for the address the visitor typed. A visitor coming back from the
|
|
46
|
+
* sign-in page reuses what was found a moment ago for the same link instead of a second lookup.
|
|
47
|
+
*
|
|
48
|
+
* The password is passed along because hosted Exchange refuses to answer autodiscovery
|
|
49
|
+
* anonymously; it only ever reaches the autodiscovery host named by the address domain's own DNS,
|
|
50
|
+
* and only after that host has asked for it.
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} request - The POST /accounts/new/imap request
|
|
53
|
+
* @param {Object} data - Its parsed signed blob
|
|
54
|
+
* @returns {Promise<Object|undefined>} The autodiscovery result, undefined when nothing was found
|
|
55
|
+
*/
|
|
56
|
+
async function discoverServerSettings(request, data) {
|
|
57
|
+
const { email, password, skipSignIn } = request.payload;
|
|
58
|
+
const cached = skipSignIn ? recallDiscovery(discoveryKey(data.n, email)) : null;
|
|
59
|
+
if (cached) {
|
|
60
|
+
return cached;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return await autodetectImapSettings(email, request.app.gt, { user: email, pass: password });
|
|
64
|
+
} catch (err) {
|
|
65
|
+
request.logger.debug({ msg: 'Failed to resolve email server settings', email, err });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Whether an Outlook application can sign in the mailbox. A personal address needs an application
|
|
71
|
+
* open to personal accounts; an organization's address needs one that is not limited to them. An
|
|
72
|
+
* application pinned to one tenant stays in for any organization, since DNS does not say which
|
|
73
|
+
* tenant a domain belongs to.
|
|
74
|
+
*/
|
|
75
|
+
function outlookAuthorityFits(app, consumer) {
|
|
76
|
+
const authority = String(app.authority || 'common').toLowerCase();
|
|
77
|
+
return consumer ? CONSUMER_AUTHORITIES.has(authority) : authority !== 'consumers';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The OAuth2 applications the hosted setup form may show at all, as the provider picker lists them:
|
|
82
|
+
* listed (which is enabled), each with the button data its sign-in button renders from. The sign-in
|
|
83
|
+
* page on the IMAP path narrows this same list, so the two pages cannot disagree about what is
|
|
84
|
+
* offered.
|
|
85
|
+
*
|
|
86
|
+
* @returns {Promise<Object[]>}
|
|
87
|
+
*/
|
|
88
|
+
async function listListedApps() {
|
|
89
|
+
return (await oauth2Apps.list(0, 100)).apps
|
|
90
|
+
.filter(app => app.includeInListing)
|
|
91
|
+
.map(app => Object.assign({}, app, { providerData: oauth2ProviderData(app.provider, app.cloud) }));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The applications to offer for a mailbox autodiscovery identified as `provider`, out of the
|
|
96
|
+
* listed ones (see listListedApps()), in the picker's order: interactive (no Pub/Sub), and for
|
|
97
|
+
* Outlook able to sign in this kind of account.
|
|
98
|
+
*
|
|
99
|
+
* When more than one is offered, each needs a name the visitor can tell apart, so an application
|
|
100
|
+
* without a display title shows its name instead. A single one keeps the picker's look: no title.
|
|
101
|
+
*
|
|
102
|
+
* @param {Object[]} apps - Applications as listListedApps() returns them
|
|
103
|
+
* @param {string} provider - `gmail` or `outlook`, from the autodiscovery result
|
|
104
|
+
* @param {string} email - The address being set up
|
|
105
|
+
* @returns {Object[]} The applications to offer, each with `providerData` and `displayTitle`
|
|
106
|
+
*/
|
|
107
|
+
function pickSignInApps(apps, provider, email) {
|
|
108
|
+
const consumer = isConsumerMailbox(email);
|
|
109
|
+
const picked = (apps || []).filter(
|
|
110
|
+
app => app && app.provider === provider && app.baseScopes !== 'pubsub' && (provider !== 'outlook' || outlookAuthorityFits(app, consumer))
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return picked.map(app => Object.assign({}, app, { displayTitle: app.title || (picked.length > 1 ? app.name : null) }));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Lists the applications to offer, see pickSignInApps().
|
|
118
|
+
*
|
|
119
|
+
* @returns {Promise<Object[]>}
|
|
120
|
+
*/
|
|
121
|
+
async function listSignInApps(provider, email) {
|
|
122
|
+
if (!provider) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
return pickSignInApps(await listListedApps(), provider, email);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Shown on the IMAP path when autodiscovery recognized a Gmail or Microsoft mailbox and an OAuth2
|
|
130
|
+
* application can sign it in: the visitor picked "Standard IMAP" for a mailbox that signs in better
|
|
131
|
+
* (for Microsoft, only) through the provider.
|
|
132
|
+
*
|
|
133
|
+
* @param {Object} request - The POST /accounts/new/imap request
|
|
134
|
+
* @param {Object} h - Response toolkit
|
|
135
|
+
* @param {Object} [serverSettings] - Autodiscovery result
|
|
136
|
+
* @param {Object} values - The page's form values (name, email, password, data, sig)
|
|
137
|
+
* @param {string} [nonce] - The setup link's nonce, to remember the discovery under
|
|
138
|
+
* @returns {Promise<Object>} `{ response }` to render the page, or `{ apps }` (the applications
|
|
139
|
+
* looked at, possibly none) to go on with the IMAP flow: the visitor chose IMAP already (or the
|
|
140
|
+
* link was minted for it), or no application fits
|
|
141
|
+
*/
|
|
142
|
+
async function renderProviderSignIn(request, h, serverSettings, values, nonce) {
|
|
143
|
+
const provider = serverSettings && serverSettings.provider;
|
|
144
|
+
if (!provider || request.payload.skipSignIn) {
|
|
145
|
+
return { apps: null };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const apps = await listSignInApps(provider, values.email);
|
|
149
|
+
if (!apps.length) {
|
|
150
|
+
// The operator is the one who can fix this, and nothing else tells them it happens
|
|
151
|
+
request.logger.info({ msg: 'No OAuth2 application can sign in this mailbox, continuing with IMAP', provider, domain: values.email.split('@').pop() });
|
|
152
|
+
return { apps };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
rememberDiscovery(discoveryKey(nonce, values.email), serverSettings);
|
|
156
|
+
|
|
157
|
+
const response = h.view(
|
|
158
|
+
'accounts/register/provider-signin',
|
|
159
|
+
{
|
|
160
|
+
pageTitleFull: request.app.gt.gettext('Email Account Setup'),
|
|
161
|
+
isMicrosoft: provider === 'outlook',
|
|
162
|
+
apps,
|
|
163
|
+
values: { name: values.name, email: values.email, password: values.password, data: values.data, sig: values.sig }
|
|
164
|
+
},
|
|
165
|
+
{ layout: 'public' }
|
|
166
|
+
);
|
|
167
|
+
return { response };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The notice the server settings form opens with for a Microsoft mailbox, which will not accept the
|
|
172
|
+
* password over IMAP. Read off the app-password hint the form already carries for such a mailbox
|
|
173
|
+
* (server-derived, see applyAppPasswordHint), so every render of the form agrees.
|
|
174
|
+
*
|
|
175
|
+
* @param {Object} values - Settings form values
|
|
176
|
+
* @param {Object[]} [knownApps] - Outlook applications already looked up for this request
|
|
177
|
+
* @returns {Promise<Object|null>} `{ noApp }`, or null when the mailbox is not a Microsoft one
|
|
178
|
+
*/
|
|
179
|
+
async function microsoftSignInNotice(values, knownApps) {
|
|
180
|
+
if (!values || values.appPassword_provider !== 'Microsoft' || !values.email) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const apps = knownApps || (await listSignInApps('outlook', values.email).catch(() => []));
|
|
184
|
+
return { noApp: !apps.length };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
module.exports = { listListedApps, pickSignInApps, listSignInApps, renderProviderSignIn, microsoftSignInNotice, discoverServerSettings };
|
|
@@ -123,7 +123,7 @@ function accountStateLabel(state, opts, gt) {
|
|
|
123
123
|
if (lastErrorState) {
|
|
124
124
|
switch (lastErrorState.serverResponseCode) {
|
|
125
125
|
case 'ETIMEDOUT':
|
|
126
|
-
errorMessage = gt.gettext('Connection timed out.
|
|
126
|
+
errorMessage = gt.gettext('Connection timed out. A firewall may be blocking the connection, or the port may be incorrect.');
|
|
127
127
|
break;
|
|
128
128
|
case 'ClosedAfterConnectTLS':
|
|
129
129
|
case 'ClosedAfterConnectText':
|
|
@@ -186,7 +186,7 @@ function init(args) {
|
|
|
186
186
|
}
|
|
187
187
|
);
|
|
188
188
|
} catch (err) {
|
|
189
|
-
await request.flash({ type: 'danger', message: request.app.gt.gettext("Couldn't process request. Try again.") });
|
|
189
|
+
await request.flash({ type: 'danger', message: request.app.gt.gettext("Couldn't process your request. Try again.") });
|
|
190
190
|
// Boom 4xx (bad signature, unknown account) is client-caused traffic on a public
|
|
191
191
|
// endpoint, not a server failure
|
|
192
192
|
request.logger[isClientError(err) ? 'debug' : 'error']({ msg: 'Failed to process subscription request', err });
|
|
@@ -235,7 +235,7 @@ function init(args) {
|
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
await request.flash({ type: 'danger', message: request.app.gt.gettext("Couldn't process request. Try again.") });
|
|
238
|
+
await request.flash({ type: 'danger', message: request.app.gt.gettext("Couldn't process your request. Try again.") });
|
|
239
239
|
request.logger.debug({ msg: 'Failed to process subscription request', err });
|
|
240
240
|
|
|
241
241
|
return h
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailengine-app",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.91.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"productTitle": "EmailEngine",
|
|
6
6
|
"description": "Email Sync Engine",
|
|
@@ -60,24 +60,24 @@
|
|
|
60
60
|
"@hapi/boom": "10.0.1",
|
|
61
61
|
"@hapi/cookie": "12.0.1",
|
|
62
62
|
"@hapi/crumb": "9.0.1",
|
|
63
|
-
"@hapi/hapi": "21.4.
|
|
63
|
+
"@hapi/hapi": "21.4.14",
|
|
64
64
|
"@hapi/inert": "7.1.3",
|
|
65
65
|
"@hapi/vision": "7.0.3",
|
|
66
66
|
"@msgpack/msgpack": "3.1.3",
|
|
67
67
|
"@postalsys/bounce-classifier": "3.1.0",
|
|
68
|
-
"@postalsys/certs": "3.0.
|
|
69
|
-
"@postalsys/email-ai-tools": "3.0.
|
|
70
|
-
"@postalsys/email-content": "0.1.
|
|
71
|
-
"@postalsys/email-text-tools": "3.1.
|
|
68
|
+
"@postalsys/certs": "3.0.2",
|
|
69
|
+
"@postalsys/email-ai-tools": "3.0.4",
|
|
70
|
+
"@postalsys/email-content": "0.1.23",
|
|
71
|
+
"@postalsys/email-text-tools": "3.1.2",
|
|
72
72
|
"@postalsys/gettext": "4.3.2",
|
|
73
73
|
"@postalsys/joi-messages": "1.4.1",
|
|
74
74
|
"@postalsys/templates": "3.0.0",
|
|
75
75
|
"@prometheus-io/client": "0.16.1",
|
|
76
|
-
"@sentry/core": "11.
|
|
76
|
+
"@sentry/core": "11.18.0",
|
|
77
77
|
"@simplewebauthn/server": "14.1.0",
|
|
78
78
|
"@zone-eu/mailsplit": "5.4.31",
|
|
79
79
|
"@zone-eu/wild-config": "1.7.10",
|
|
80
|
-
"bullmq": "6.7.
|
|
80
|
+
"bullmq": "6.7.10",
|
|
81
81
|
"fast-xml-parser": "5.12.1",
|
|
82
82
|
"handlebars": "4.7.10",
|
|
83
83
|
"he": "1.2.0",
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"ical.js": "2.2.1",
|
|
86
86
|
"iconv-lite": "0.7.3",
|
|
87
87
|
"imapflow": "2.12.2",
|
|
88
|
-
"ioredfour": "2.2.
|
|
89
|
-
"ioredis": "6.
|
|
88
|
+
"ioredfour": "2.2.1",
|
|
89
|
+
"ioredis": "6.1.0",
|
|
90
90
|
"ipaddr.js": "2.5.0",
|
|
91
91
|
"joi": "18.3.2",
|
|
92
92
|
"libbase64": "1.4.1",
|
|
@@ -102,8 +102,8 @@
|
|
|
102
102
|
"qrcode-generator": "2.0.4",
|
|
103
103
|
"smtp-server": "3.21.7",
|
|
104
104
|
"socks": "2.8.11",
|
|
105
|
-
"tldts": "7.
|
|
106
|
-
"undici": "8.13.
|
|
105
|
+
"tldts": "7.6.0",
|
|
106
|
+
"undici": "8.13.1"
|
|
107
107
|
},
|
|
108
108
|
"overrides": {
|
|
109
109
|
"@hapi/bell": {
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@eslint/js": "10.0.1",
|
|
115
|
-
"@iconify-json/tabler": "1.2.
|
|
115
|
+
"@iconify-json/tabler": "1.2.47",
|
|
116
116
|
"@iconify/tailwind4": "1.2.3",
|
|
117
117
|
"@playwright/test": "1.63.0",
|
|
118
118
|
"@postalsys/ee-client": "2.0.1",
|