emailengine-app 2.80.0 → 2.80.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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +24 -0
- package/README.md +6 -0
- package/data/google-crawlers.json +1 -1
- package/lib/api-routes/account-routes.js +81 -1
- package/lib/api-routes/blocklist-routes.js +24 -0
- package/lib/api-routes/delivery-test-routes.js +6 -0
- package/lib/api-routes/gateway-routes.js +30 -0
- package/lib/api-routes/license-routes.js +10 -0
- package/lib/api-routes/mcp-oauth-routes.js +3 -3
- package/lib/api-routes/mcp-routes.js +39 -21
- package/lib/api-routes/oauth2-app-routes.js +38 -1
- package/lib/api-routes/outbox-routes.js +6 -0
- package/lib/api-routes/permission-map.js +208 -43
- package/lib/api-routes/pubsub-routes.js +8 -0
- package/lib/api-routes/route-helpers.js +58 -11
- package/lib/api-routes/settings-routes.js +50 -4
- package/lib/api-routes/stats-routes.js +6 -0
- package/lib/api-routes/template-routes.js +21 -0
- package/lib/api-routes/token-routes.js +34 -2
- package/lib/api-routes/webhook-route-routes.js +13 -0
- package/lib/email-client/base-client.js +6 -3
- package/lib/email-client/credential-errors.js +4 -0
- package/lib/email-client/imap/login-failure.js +52 -0
- package/lib/email-client/imap/subconnection.js +2 -1
- package/lib/email-client/imap-client.js +3 -6
- package/lib/enum-descriptions.js +12 -2
- package/lib/imapproxy/imap-server.js +1 -1
- package/lib/mcp/oauth.js +46 -8
- package/lib/mcp/protocol.js +78 -35
- package/lib/mcp/tools.js +53 -17
- package/lib/privileged-settings.js +147 -0
- package/lib/schemas.js +60 -16
- package/lib/settings.js +13 -0
- package/lib/tls/catalog.js +428 -0
- package/lib/tls/context.js +87 -161
- package/lib/tls/listeners.js +62 -0
- package/lib/tls/status.js +128 -79
- package/lib/tls/store.js +3 -2
- package/lib/token-permission-view.js +252 -102
- package/lib/token-permissions.js +176 -26
- package/lib/tokens.js +7 -6
- package/lib/tools.js +4 -3
- package/lib/ui-routes/admin-config-routes.js +41 -21
- package/lib/ui-routes/admin-entities-routes.js +23 -13
- package/lib/ui-routes/mcp-consent-routes.js +72 -31
- package/lib/ui-routes/tls-config-routes.js +121 -74
- package/package.json +12 -12
- package/sbom.json +1 -1
- package/server.js +7 -1
- package/static/css/flyonui.css +1 -1
- package/static/js/ui.js +89 -36
- package/static/licenses.html +46 -28
- package/translations/messages.pot +74 -68
- package/views/account/login-redirect.hbs +1 -1
- package/views/account/passkeys.hbs +2 -2
- package/views/accounts/account.hbs +2 -2
- package/views/accounts/browse.hbs +1 -1
- package/views/accounts/edit.hbs +1 -1
- package/views/accounts/register/imap-server.hbs +1 -1
- package/views/config/ai.hbs +1 -1
- package/views/config/branding.hbs +2 -2
- package/views/config/document-store/chat.hbs +1 -1
- package/views/config/document-store/index.hbs +1 -1
- package/views/config/imap-proxy.hbs +1 -1
- package/views/config/license.hbs +1 -1
- package/views/config/mcp.hbs +88 -52
- package/views/config/network.hbs +1 -1
- package/views/config/oauth/app.hbs +2 -2
- package/views/config/service.hbs +1 -1
- package/views/config/smtp.hbs +1 -1
- package/views/config/tls.hbs +266 -165
- package/views/config/webhooks.hbs +2 -2
- package/views/internals/index.hbs +1 -1
- package/views/layout/app.hbs +6 -6
- package/views/layout/login.hbs +5 -5
- package/views/layout/main.hbs +2 -2
- package/views/layout/prompt.hbs +3 -3
- package/views/layout/public.hbs +1 -1
- package/views/mcp/authorize.hbs +47 -45
- package/views/partials/ace_assets.hbs +1 -1
- package/views/partials/add_account_modal.hbs +1 -1
- package/views/partials/filter_editor_js.hbs +2 -2
- package/views/partials/gateway_js.hbs +1 -1
- package/views/partials/mcp_access_levels.hbs +16 -9
- package/views/partials/mcp_tool_count.hbs +15 -14
- package/views/partials/oauth_form.hbs +1 -1
- package/views/partials/public_theme_init.hbs +1 -1
- package/views/partials/template_form.hbs +1 -1
- package/views/partials/theme_init.hbs +1 -1
- package/views/partials/webhooks_editor_functions.hbs +1 -1
- package/views/reference/index.hbs +1 -1
- package/views/reference/redirect.hbs +1 -1
- package/views/reference/tag.hbs +1 -1
- package/views/reference/token.hbs +1 -1
- package/views/templates/template.hbs +1 -1
- package/views/tokens/new.hbs +175 -74
- package/views/unsubscribe.hbs +1 -1
- package/views/webhooks/webhook.hbs +1 -1
- package/workers/api.js +9 -8
- package/workers/smtp.js +1 -1
package/lib/tls/status.js
CHANGED
|
@@ -11,19 +11,23 @@
|
|
|
11
11
|
|
|
12
12
|
const settings = require('../settings');
|
|
13
13
|
const { ACME_DIRECTORY_URL, ACME_ENVIRONMENT } = require('../consts');
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
extraHostnamesFrom,
|
|
17
|
-
acmeEligibleHostnames,
|
|
18
|
-
peekManualCertificate,
|
|
19
|
-
peekSelfSignedCertificate,
|
|
20
|
-
parseCertificate,
|
|
21
|
-
coversHostname,
|
|
22
|
-
normalizeHostname
|
|
23
|
-
} = require('./store');
|
|
24
|
-
const { resolveHostname, sourcesFor } = require('./context');
|
|
14
|
+
const { hostnamesFrom, extraHostnamesFrom, acmeEligibleHostnames, coversHostname, LISTENER_TLS_SETTINGS, listenerTlsFrom } = require('./store');
|
|
15
|
+
const { apiTlsConfig } = require('./context');
|
|
25
16
|
const { getProvisioningStatus } = require('./provision');
|
|
26
17
|
const { worstBy } = require('../utils/severity');
|
|
18
|
+
const { LISTENERS, TLS_CERTIFICATE_SETTINGS, AUTO } = require('./listeners');
|
|
19
|
+
const {
|
|
20
|
+
sourcesFor,
|
|
21
|
+
certificateId,
|
|
22
|
+
parseCertificateId,
|
|
23
|
+
describeEntry,
|
|
24
|
+
isSelectable,
|
|
25
|
+
listCertificates,
|
|
26
|
+
admittedFor,
|
|
27
|
+
resolveDefaultCertificate,
|
|
28
|
+
entryForName,
|
|
29
|
+
listenerView
|
|
30
|
+
} = require('./catalog');
|
|
27
31
|
|
|
28
32
|
// Below this many days left, a certificate is worth pointing at even though it still works.
|
|
29
33
|
const EXPIRY_WARNING_DAYS = 14;
|
|
@@ -52,14 +56,6 @@ const SOURCE_LABELS = {
|
|
|
52
56
|
'self-signed': 'Self-signed'
|
|
53
57
|
};
|
|
54
58
|
|
|
55
|
-
// The same sources inside a sentence: "serving mail.example.com from ..."
|
|
56
|
-
const SOURCE_PHRASES = {
|
|
57
|
-
env: 'the TLS environment variables',
|
|
58
|
-
manual: 'the uploaded certificate',
|
|
59
|
-
acme: "Let's Encrypt",
|
|
60
|
-
'self-signed': 'the self-signed fallback'
|
|
61
|
-
};
|
|
62
|
-
|
|
63
59
|
function daysUntil(date) {
|
|
64
60
|
if (!date) {
|
|
65
61
|
return null;
|
|
@@ -81,30 +77,6 @@ function rehydrateReport(report) {
|
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
/**
|
|
85
|
-
* The certificate a listener is serving for a hostname out of environment or config-file material.
|
|
86
|
-
*
|
|
87
|
-
* That material is per listener and per process, so this module cannot read it, and a hostname
|
|
88
|
-
* served only through EENGINE_SMTP_TLS_CERT used to be described as having no certificate at all
|
|
89
|
-
* while every listener served it perfectly well. The listeners report which configured names they
|
|
90
|
-
* resolved to that material, so the answer is a lookup in that list rather than a second, weaker
|
|
91
|
-
* reimplementation of name matching against the report's own name list.
|
|
92
|
-
*
|
|
93
|
-
* @param {Object[]} reports Certificate descriptions from the listener state payloads
|
|
94
|
-
* @param {string} hostname Name to describe
|
|
95
|
-
* @returns {Object|false} The certificate, or false when no listener reports one for that name
|
|
96
|
-
*/
|
|
97
|
-
function reportedEnvCertificate(reports, hostname) {
|
|
98
|
-
const name = normalizeHostname(hostname);
|
|
99
|
-
if (!name) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const report = reports.find(entry => entry.source === 'env' && [].concat(entry.envHostnames || []).includes(name));
|
|
104
|
-
|
|
105
|
-
return report ? rehydrateReport(report) : false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
80
|
/**
|
|
109
81
|
* The countdown text for a certificate inside its warning window. Only reachable for a
|
|
110
82
|
* certificate that has not expired, so the smallest value is today.
|
|
@@ -212,19 +184,22 @@ function publicView(certificate) {
|
|
|
212
184
|
return false;
|
|
213
185
|
}
|
|
214
186
|
|
|
187
|
+
const words = describeEntry(certificate);
|
|
188
|
+
|
|
215
189
|
return {
|
|
190
|
+
// The id the listeners' settings refer to it by, and the words the page lists it under
|
|
191
|
+
id: certificateId(certificate),
|
|
192
|
+
label: words.label,
|
|
193
|
+
detail: words.detail,
|
|
216
194
|
source: certificate.source,
|
|
195
|
+
// The one-word source, for a sentence that says what kind of certificate a name has
|
|
217
196
|
sourceLabel: SOURCE_LABELS[certificate.source] || certificate.source,
|
|
218
|
-
sourcePhrase: SOURCE_PHRASES[certificate.source] || certificate.source,
|
|
219
197
|
subject: certificate.subject,
|
|
220
198
|
issuer: certificate.issuer,
|
|
221
199
|
serialNumber: certificate.serialNumber,
|
|
222
200
|
fingerprint: certificate.fingerprint,
|
|
223
201
|
fingerprint256: certificate.fingerprint256,
|
|
224
202
|
altNames: certificate.altNames || [],
|
|
225
|
-
// Which configured names a listener resolved to this material, which only the listener
|
|
226
|
-
// knows for environment material - see reportedEnvCertificate()
|
|
227
|
-
envHostnames: certificate.envHostnames || [],
|
|
228
203
|
validFrom: certificate.validFrom,
|
|
229
204
|
validTo: certificate.validTo,
|
|
230
205
|
// ISO strings as well as the dates: handlebars has no date formatter, and the page
|
|
@@ -303,64 +278,77 @@ function wantsCertificate(entry) {
|
|
|
303
278
|
}
|
|
304
279
|
|
|
305
280
|
/**
|
|
306
|
-
* Builds the whole certificate model: what is configured, what
|
|
307
|
-
*
|
|
281
|
+
* Builds the whole certificate model: what is configured, what answers each name, every
|
|
282
|
+
* certificate the instance holds, which of them each listener presents by default, and what the
|
|
283
|
+
* last provisioning attempt did.
|
|
308
284
|
*
|
|
309
285
|
* @param {Object} opts
|
|
310
286
|
* @param {Object} opts.certs @postalsys/certs handler
|
|
311
|
-
* @param {
|
|
312
|
-
*
|
|
313
|
-
*
|
|
287
|
+
* @param {boolean|Promise<boolean>} [opts.served] Whether some listener with TLS on is presenting
|
|
288
|
+
* certificates to clients at all. A promise is
|
|
289
|
+
* accepted, so a page reading the listeners can do
|
|
290
|
+
* it alongside this
|
|
314
291
|
* @returns {Promise<Object>} The model
|
|
315
292
|
*/
|
|
316
293
|
async function buildCertificateStatus(opts) {
|
|
317
294
|
const { certs } = opts || {};
|
|
318
295
|
|
|
319
|
-
// Everything the model needs, in one round of reads
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
settings.getMulti('serviceUrl', 'tlsProvisioning', 'tlsHostnames'),
|
|
325
|
-
peekManualCertificate(),
|
|
326
|
-
peekSelfSignedCertificate(),
|
|
296
|
+
// Everything the model needs, in one round of reads. The hostname list is derived from
|
|
297
|
+
// settings this already has, so it costs no second lookup; the catalog is peeked, not
|
|
298
|
+
// loaded, since nothing here serves it.
|
|
299
|
+
const [values, provisioning, served] = await Promise.all([
|
|
300
|
+
settings.getMulti('serviceUrl', 'tlsProvisioning', 'tlsHostnames', ...TLS_CERTIFICATE_SETTINGS, ...LISTENER_TLS_SETTINGS),
|
|
327
301
|
getProvisioningStatus(),
|
|
328
|
-
(opts && opts.
|
|
302
|
+
(opts && opts.served) || false
|
|
329
303
|
]);
|
|
330
304
|
|
|
331
|
-
const reported = [].concat(listenerReports || []).filter(entry => entry);
|
|
332
|
-
|
|
333
305
|
const mode = values.tlsProvisioning || 'acme';
|
|
334
306
|
const hostnames = hostnamesFrom(values);
|
|
335
307
|
const eligible = acmeEligibleHostnames(hostnames);
|
|
336
|
-
|
|
337
308
|
const sources = sourcesFor(mode);
|
|
338
|
-
const manualX509 = manual ? parseCertificate(manual.cert) : null;
|
|
339
|
-
const selfSignedX509 = selfSigned ? parseCertificate(selfSigned.cert) : null;
|
|
340
309
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
//
|
|
345
|
-
|
|
310
|
+
const catalog = await listCertificates({ certs, hostnames });
|
|
311
|
+
const selfSigned = catalog.find(entry => entry.source === 'self-signed');
|
|
312
|
+
|
|
313
|
+
// What a name has before any listener's own material or default is applied: the stored
|
|
314
|
+
// sources, then the self-signed fallback for a name nothing else covers. That is the row; a
|
|
315
|
+
// listener that answers differently for the name says so under it.
|
|
316
|
+
const shared = admittedFor(catalog, { listener: null, sources });
|
|
317
|
+
const rowEntry = hostname =>
|
|
318
|
+
shared.find(entry => coversHostname(entry.x509, hostname)) || (selfSigned && coversHostname(selfSigned.x509, hostname) ? selfSigned : null);
|
|
346
319
|
|
|
347
|
-
//
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
320
|
+
// Each listener, decided the way the listener decides it
|
|
321
|
+
const switches = listenerTlsFrom(values);
|
|
322
|
+
const apiServesTls = !!apiTlsConfig();
|
|
323
|
+
|
|
324
|
+
const views = LISTENERS.map(listener => {
|
|
325
|
+
const view = listenerView({ catalog, hostnames, sources, listener: listener.key, requested: values[listener.settingKey] });
|
|
326
|
+
const settingsFor = listener.key === 'api' ? { enabled: true, tlsEnabled: apiServesTls } : switches[listener.key];
|
|
327
|
+
return Object.assign({ listener, tlsOn: !!(settingsFor.enabled && settingsFor.tlsEnabled), settingsFor }, view);
|
|
328
|
+
});
|
|
351
329
|
|
|
352
330
|
// The names this page adds and removes. Whatever is configured and not among them is the
|
|
353
331
|
// Service URL's own name, which is set on the General page.
|
|
354
332
|
const extraHostnames = extraHostnamesFrom(values);
|
|
355
333
|
|
|
356
|
-
const certificates = hostnames.map(
|
|
357
|
-
const
|
|
334
|
+
const certificates = hostnames.map(hostname => {
|
|
335
|
+
const entry = rowEntry(hostname);
|
|
336
|
+
const certificate = entry ? entry.material : false;
|
|
358
337
|
const status = provisioning[hostname] || null;
|
|
359
338
|
const acmeEligible = eligible.includes(hostname);
|
|
360
339
|
// Whether asking for a certificate now would do anything at all
|
|
361
340
|
const canRequest = mode === 'acme' && acmeEligible;
|
|
362
341
|
const label = certificateLabel(certificate, status, { served, canRequest });
|
|
363
342
|
|
|
343
|
+
// The listeners with TLS on that answer this name with something other than the row's
|
|
344
|
+
// certificate: their own environment material, or a chosen default that covers the name.
|
|
345
|
+
// Said here, on the row, rather than left for the operator to derive from three tables.
|
|
346
|
+
const servedBy = views
|
|
347
|
+
.filter(view => view.tlsOn)
|
|
348
|
+
.map(view => ({ view, answer: entryForName(hostname, view) }))
|
|
349
|
+
.filter(({ answer }) => answer && answer !== entry)
|
|
350
|
+
.map(({ view, answer }) => ({ key: view.listener.key, name: view.listener.name, label: answer.label }));
|
|
351
|
+
|
|
364
352
|
return {
|
|
365
353
|
hostname,
|
|
366
354
|
isServiceHostname: !extraHostnames.includes(hostname),
|
|
@@ -370,6 +358,7 @@ async function buildCertificateStatus(opts) {
|
|
|
370
358
|
certificate: publicView(certificate),
|
|
371
359
|
label,
|
|
372
360
|
status,
|
|
361
|
+
servedBy,
|
|
373
362
|
// The one line the page shows under the name: why the last order failed, why a request
|
|
374
363
|
// was declined, or that one is under way. The page script paints the same states from
|
|
375
364
|
// the change feed, so its table (views/config/tls.hbs) mirrors STATUS_VARIANTS.
|
|
@@ -380,6 +369,63 @@ async function buildCertificateStatus(opts) {
|
|
|
380
369
|
};
|
|
381
370
|
});
|
|
382
371
|
|
|
372
|
+
// Every certificate the instance holds, with the listeners that present it by default. The
|
|
373
|
+
// self-signed entry is listed generated or not: it is a choice a listener can be given.
|
|
374
|
+
const catalogView = catalog.map(entry => {
|
|
375
|
+
const usedBy = views
|
|
376
|
+
.filter(view => view.fallback === entry)
|
|
377
|
+
.map(view => ({
|
|
378
|
+
key: view.listener.key,
|
|
379
|
+
// A chosen default is the listener's name; an automatic one says so
|
|
380
|
+
label: view.selection === 'selected' ? view.listener.name : `${view.listener.name} (automatic)`
|
|
381
|
+
}));
|
|
382
|
+
|
|
383
|
+
return {
|
|
384
|
+
id: entry.id,
|
|
385
|
+
source: entry.source,
|
|
386
|
+
hostname: entry.hostname || null,
|
|
387
|
+
label: entry.label,
|
|
388
|
+
detail: entry.detail,
|
|
389
|
+
certificate: publicView(entry.material),
|
|
390
|
+
// The badge follows the certificate itself; a certificate no listener presents is
|
|
391
|
+
// not "served", whatever the listeners report
|
|
392
|
+
status: certificateLabel(entry.material, null, { served: served && usedBy.length > 0, canRequest: false }),
|
|
393
|
+
usedBy
|
|
394
|
+
};
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// One entry per listener: what it presents, how that came to be, and the dropdown to change
|
|
398
|
+
// it - the automatic choice named for what it currently amounts to, then every certificate
|
|
399
|
+
// that exists. The dropdown reads "Automatic" for a stored choice that no longer exists, so
|
|
400
|
+
// saving the page as it stands writes the automatic choice the listener already fell back to.
|
|
401
|
+
const listeners = views.map(view => {
|
|
402
|
+
const { listener, settingsFor } = view;
|
|
403
|
+
const auto =
|
|
404
|
+
view.selection === 'selected'
|
|
405
|
+
? resolveDefaultCertificate({ catalog, entries: view.entries, primary: hostnames[0], listener: listener.key, requested: AUTO }).entry
|
|
406
|
+
: view.fallback;
|
|
407
|
+
const missing = view.selection === 'missing';
|
|
408
|
+
const requestedWords = missing ? describeEntry(parseCertificateId(view.requested) || { source: view.requested }) : null;
|
|
409
|
+
|
|
410
|
+
const options = [{ id: AUTO, label: `Automatic: ${auto ? auto.label : 'Self-signed fallback'}`, selected: view.requested === AUTO || missing }].concat(
|
|
411
|
+
catalog.filter(isSelectable).map(entry => ({
|
|
412
|
+
id: entry.id,
|
|
413
|
+
label: entry.label,
|
|
414
|
+
covers: entry.material ? (entry.material.altNames || []).join(', ') : 'generated on first use',
|
|
415
|
+
selected: view.requested === entry.id
|
|
416
|
+
}))
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
return Object.assign({}, listener, settingsFor, {
|
|
420
|
+
requested: view.requested,
|
|
421
|
+
selection: view.selection,
|
|
422
|
+
// The words for a chosen certificate that is gone, for the warning under the dropdown
|
|
423
|
+
missingLabel: requestedWords ? requestedWords.label : null,
|
|
424
|
+
defaultId: view.fallback ? view.fallback.id : null,
|
|
425
|
+
options
|
|
426
|
+
});
|
|
427
|
+
});
|
|
428
|
+
|
|
383
429
|
return {
|
|
384
430
|
mode,
|
|
385
431
|
serviceUrl: values.serviceUrl || '',
|
|
@@ -388,8 +434,11 @@ async function buildCertificateStatus(opts) {
|
|
|
388
434
|
served,
|
|
389
435
|
// Whether the page-level "Request certificates" action has anything to do
|
|
390
436
|
anyWanted: certificates.some(entry => entry.wanted),
|
|
391
|
-
|
|
392
|
-
|
|
437
|
+
// Whether the two stored certificates exist, for the upload link and the regenerate dialog
|
|
438
|
+
manual: catalog.some(entry => entry.source === 'manual'),
|
|
439
|
+
selfSigned: publicView(selfSigned ? selfSigned.material : false),
|
|
440
|
+
catalog: catalogView,
|
|
441
|
+
listeners,
|
|
393
442
|
acme: {
|
|
394
443
|
directoryUrl: ACME_DIRECTORY_URL,
|
|
395
444
|
environment: ACME_ENVIRONMENT,
|
package/lib/tls/store.js
CHANGED
|
@@ -200,8 +200,8 @@ async function readRecord(field, opts) {
|
|
|
200
200
|
* Answering it as one gave the page a "Valid" badge with no dates behind it while the listener,
|
|
201
201
|
* unable to build a context from it, quietly served the self-signed fallback for the name.
|
|
202
202
|
*
|
|
203
|
-
* @param {string} source `manual`, `acme` or `self-signed`
|
|
204
|
-
* @param {Object|false} record The stored record
|
|
203
|
+
* @param {string} source `env`, `manual`, `acme` or `self-signed`
|
|
204
|
+
* @param {Object|false} record The stored record, or environment material in the same shape
|
|
205
205
|
* @returns {Object|false} `{ source, subject, altNames, validTo, ..., cert, ca, privateKey? }`
|
|
206
206
|
*/
|
|
207
207
|
function materialFrom(source, record) {
|
|
@@ -647,6 +647,7 @@ module.exports = {
|
|
|
647
647
|
coversHostname,
|
|
648
648
|
describeCertificate,
|
|
649
649
|
describeX509,
|
|
650
|
+
materialFrom,
|
|
650
651
|
getCertificateHostnames,
|
|
651
652
|
normalizeHostname,
|
|
652
653
|
hostnamesFrom,
|