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.
Files changed (101) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +24 -0
  3. package/README.md +6 -0
  4. package/data/google-crawlers.json +1 -1
  5. package/lib/api-routes/account-routes.js +81 -1
  6. package/lib/api-routes/blocklist-routes.js +24 -0
  7. package/lib/api-routes/delivery-test-routes.js +6 -0
  8. package/lib/api-routes/gateway-routes.js +30 -0
  9. package/lib/api-routes/license-routes.js +10 -0
  10. package/lib/api-routes/mcp-oauth-routes.js +3 -3
  11. package/lib/api-routes/mcp-routes.js +39 -21
  12. package/lib/api-routes/oauth2-app-routes.js +38 -1
  13. package/lib/api-routes/outbox-routes.js +6 -0
  14. package/lib/api-routes/permission-map.js +208 -43
  15. package/lib/api-routes/pubsub-routes.js +8 -0
  16. package/lib/api-routes/route-helpers.js +58 -11
  17. package/lib/api-routes/settings-routes.js +50 -4
  18. package/lib/api-routes/stats-routes.js +6 -0
  19. package/lib/api-routes/template-routes.js +21 -0
  20. package/lib/api-routes/token-routes.js +34 -2
  21. package/lib/api-routes/webhook-route-routes.js +13 -0
  22. package/lib/email-client/base-client.js +6 -3
  23. package/lib/email-client/credential-errors.js +4 -0
  24. package/lib/email-client/imap/login-failure.js +52 -0
  25. package/lib/email-client/imap/subconnection.js +2 -1
  26. package/lib/email-client/imap-client.js +3 -6
  27. package/lib/enum-descriptions.js +12 -2
  28. package/lib/imapproxy/imap-server.js +1 -1
  29. package/lib/mcp/oauth.js +46 -8
  30. package/lib/mcp/protocol.js +78 -35
  31. package/lib/mcp/tools.js +53 -17
  32. package/lib/privileged-settings.js +147 -0
  33. package/lib/schemas.js +60 -16
  34. package/lib/settings.js +13 -0
  35. package/lib/tls/catalog.js +428 -0
  36. package/lib/tls/context.js +87 -161
  37. package/lib/tls/listeners.js +62 -0
  38. package/lib/tls/status.js +128 -79
  39. package/lib/tls/store.js +3 -2
  40. package/lib/token-permission-view.js +252 -102
  41. package/lib/token-permissions.js +176 -26
  42. package/lib/tokens.js +7 -6
  43. package/lib/tools.js +4 -3
  44. package/lib/ui-routes/admin-config-routes.js +41 -21
  45. package/lib/ui-routes/admin-entities-routes.js +23 -13
  46. package/lib/ui-routes/mcp-consent-routes.js +72 -31
  47. package/lib/ui-routes/tls-config-routes.js +121 -74
  48. package/package.json +12 -12
  49. package/sbom.json +1 -1
  50. package/server.js +7 -1
  51. package/static/css/flyonui.css +1 -1
  52. package/static/js/ui.js +89 -36
  53. package/static/licenses.html +46 -28
  54. package/translations/messages.pot +74 -68
  55. package/views/account/login-redirect.hbs +1 -1
  56. package/views/account/passkeys.hbs +2 -2
  57. package/views/accounts/account.hbs +2 -2
  58. package/views/accounts/browse.hbs +1 -1
  59. package/views/accounts/edit.hbs +1 -1
  60. package/views/accounts/register/imap-server.hbs +1 -1
  61. package/views/config/ai.hbs +1 -1
  62. package/views/config/branding.hbs +2 -2
  63. package/views/config/document-store/chat.hbs +1 -1
  64. package/views/config/document-store/index.hbs +1 -1
  65. package/views/config/imap-proxy.hbs +1 -1
  66. package/views/config/license.hbs +1 -1
  67. package/views/config/mcp.hbs +88 -52
  68. package/views/config/network.hbs +1 -1
  69. package/views/config/oauth/app.hbs +2 -2
  70. package/views/config/service.hbs +1 -1
  71. package/views/config/smtp.hbs +1 -1
  72. package/views/config/tls.hbs +266 -165
  73. package/views/config/webhooks.hbs +2 -2
  74. package/views/internals/index.hbs +1 -1
  75. package/views/layout/app.hbs +6 -6
  76. package/views/layout/login.hbs +5 -5
  77. package/views/layout/main.hbs +2 -2
  78. package/views/layout/prompt.hbs +3 -3
  79. package/views/layout/public.hbs +1 -1
  80. package/views/mcp/authorize.hbs +47 -45
  81. package/views/partials/ace_assets.hbs +1 -1
  82. package/views/partials/add_account_modal.hbs +1 -1
  83. package/views/partials/filter_editor_js.hbs +2 -2
  84. package/views/partials/gateway_js.hbs +1 -1
  85. package/views/partials/mcp_access_levels.hbs +16 -9
  86. package/views/partials/mcp_tool_count.hbs +15 -14
  87. package/views/partials/oauth_form.hbs +1 -1
  88. package/views/partials/public_theme_init.hbs +1 -1
  89. package/views/partials/template_form.hbs +1 -1
  90. package/views/partials/theme_init.hbs +1 -1
  91. package/views/partials/webhooks_editor_functions.hbs +1 -1
  92. package/views/reference/index.hbs +1 -1
  93. package/views/reference/redirect.hbs +1 -1
  94. package/views/reference/tag.hbs +1 -1
  95. package/views/reference/token.hbs +1 -1
  96. package/views/templates/template.hbs +1 -1
  97. package/views/tokens/new.hbs +175 -74
  98. package/views/unsubscribe.hbs +1 -1
  99. package/views/webhooks/webhook.hbs +1 -1
  100. package/workers/api.js +9 -8
  101. package/workers/smtp.js +1 -1
@@ -355,7 +355,7 @@ fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tab
355
355
  </form>
356
356
  {{/ui/modal}}
357
357
 
358
- <script nonce="{{cspNonce}}">
358
+ <script data-cfasync="false" nonce="{{cspNonce}}">
359
359
  document.addEventListener('DOMContentLoaded', () => {
360
360
  document.getElementById('addServiceAccountModal').addEventListener('open.overlay', () => {
361
361
  document.getElementById('service-account-name').focus();
@@ -364,7 +364,7 @@ fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tab
364
364
  </script>
365
365
  {{/if}}
366
366
 
367
- <script nonce="{{cspNonce}}">
367
+ <script data-cfasync="false" nonce="{{cspNonce}}">
368
368
  document.addEventListener('DOMContentLoaded', () => {
369
369
  const appId = "{{app.id}}";
370
370
  const stepsElm = document.getElementById('verify-steps');
@@ -123,7 +123,7 @@
123
123
 
124
124
  </form>
125
125
 
126
- <script nonce="{{cspNonce}}">
126
+ <script data-cfasync="false" nonce="{{cspNonce}}">
127
127
  document.addEventListener('DOMContentLoaded', () => {
128
128
 
129
129
  const sendCleanPayload = async () => {
@@ -143,7 +143,7 @@
143
143
 
144
144
  <input type="hidden" id="availableAddresses" value="{{availableAddresses}}">
145
145
 
146
- <script nonce="{{cspNonce}}">
146
+ <script data-cfasync="false" nonce="{{cspNonce}}">
147
147
  document.addEventListener('DOMContentLoaded', () => {
148
148
 
149
149
  let availableAddresses = document.getElementById('availableAddresses').value.split(',').map(e => e.trim()).filter(e => e);
@@ -1,6 +1,6 @@
1
1
  {{!-- The header badge is the worst of what the listeners serve, or "TLS off" when none of them
2
- serves TLS, so the first glance and the tiles below it agree. The request action posts with
3
- fetch (uiPostJson), which is why it sits outside the settings form further down. The static
2
+ serves TLS, so the first glance and the tables below it agree. The request action posts with
3
+ fetch (uiPostJson), which is why it sits outside the settings forms further down. The static
4
4
  wrapper is deliberate: a partial block that opens with a condition can lose its content. --}}
5
5
  {{#> ui/page-header title="TLS Certificates" icon="icon-[tabler--certificate]" badgeLabel=pageLabel.text
6
6
  badgeVariant=pageLabel.type class="mb-1"}}
@@ -12,8 +12,9 @@ badgeVariant=pageLabel.type class="mb-1"}}
12
12
  {{/ui/page-header}}
13
13
 
14
14
  <p class="mb-6">Certificates for the SMTP server, the IMAP proxy, and the admin interface when EmailEngine serves HTTPS
15
- itself. They can be ordered from Let's Encrypt, uploaded, or generated here as a self-signed fallback so a
16
- listener always starts.</p>
15
+ itself. Each listener presents one certificate by default and answers a client that asks for another configured
16
+ name with the certificate for that name. Certificates can be ordered from Let's Encrypt, uploaded, supplied through
17
+ the environment, or generated here as a self-signed fallback so a listener always starts.</p>
17
18
 
18
19
  {{#if acme.staging}}
19
20
  {{#> ui/alert-banner variant="warning" icon="icon-[tabler--flask]" title="Staging certificate authority"}}
@@ -23,56 +24,98 @@ badgeVariant=pageLabel.type class="mb-1"}}
23
24
  {{/ui/alert-banner}}
24
25
  {{/if}}
25
26
 
26
- {{!-- One tile per listener. The icon is a call-site literal so the Tailwind scanner sees it; the
27
- tint follows the certificate the listener serves, muted when it serves none. --}}
28
- {{#*inline "listenerTile"}}
29
- {{#> ui/stat-card variant=(when this.serving.label.type this.serving.label.type "neutral") icon=icon title=this.name}}
30
- <div class="text-sm" data-listener="{{this.key}}">
31
- <div class="mb-1 flex flex-wrap items-center gap-1">
32
- {{#if this.state}}
33
- {{> ui/state-badge label=this.state dataType=this.key}}
34
- {{/if}}
35
- {{#if this.serving.label}}
36
- {{> ui/badge label=this.serving.label.text variant=this.serving.label.type title=this.serving.label.title soft=true}}
37
- {{/if}}
38
- </div>
39
- {{#if this.serving.certificate}}
40
- <div>Serving <span class="font-mono">{{this.serving.hostname}}</span> from
41
- {{this.serving.certificate.sourcePhrase}}{{#if this.serving.certificate.validToIso}}, valid until <span
42
- class="local-time" data-time="{{this.serving.certificate.validToIso}}">{{this.serving.certificate.validToIso}}</span>{{/if}}.
43
- </div>
44
- {{else if this.hint}}
45
- <div class="text-base-content/70">{{this.hint}}{{#if this.needsSetup}} Turn it on from the <a
46
- href="{{this.configuredAt}}" class="link link-animated">{{this.name}}</a> page.{{/if}}</div>
47
- {{else}}
48
- <div class="text-base-content/70">
49
- {{#if this.tlsEnabled}}
50
- Serving HTTPS (<code>EENGINE_API_TLS</code> is set); the listener has not reported a certificate yet.
51
- {{else}}
52
- Serving plain HTTP, the default. Put a reverse proxy in front for HTTPS, or set
53
- <code>EENGINE_API_TLS=true</code> to have EmailEngine serve it with the certificates on this page.
54
- {{/if}}
55
- </div>
56
- {{/if}}
57
- </div>
58
- {{/ui/stat-card}}
59
- {{/inline}}
27
+ {{!-- Listeners first: what clients actually get is the reason to open this page. One row per
28
+ listener, with the certificate it presents by default as a dropdown. Saved with the button
29
+ rather than on change: every save reloads the listeners, and a wrong default is what a
30
+ client sees on its next handshake. --}}
31
+ <form method="post" action="/admin/config/tls/listeners">
32
+ {{!-- no id: the layout already renders the #crumb element the scripts read --}}
33
+ <input type="hidden" name="crumb" value="{{crumb}}" />
60
34
 
61
- {{!-- Listeners first: what clients actually get is the reason to open this page. --}}
62
- <div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6" id="tls-listeners">
63
- {{#each listeners}}
64
- {{#equals this.key "api"}}{{> listenerTile icon="icon-[tabler--world]"}}{{/equals}}
65
- {{#equals this.key "smtp"}}{{> listenerTile icon="icon-[tabler--server]"}}{{/equals}}
66
- {{#equals this.key "imapProxy"}}{{> listenerTile icon="icon-[tabler--inbox]"}}{{/equals}}
67
- {{/each}}
68
- </div>
35
+ <div class="card bg-base-100 shadow-md mb-6" id="tls-listeners">
36
+ <div class="card-header">
37
+ <h6 class="card-title text-primary">Listeners</h6>
38
+ </div>
39
+ <div class="px-6 pt-4 text-sm text-base-content/70">The default certificate is presented to a client that names
40
+ no host, and for every name it covers. Other configured names are served their own certificate, from the
41
+ table below.</div>
42
+ <div class="overflow-x-auto">
43
+ <table class="table ee-table-wrap table-fixed min-w-[56rem]">
44
+ <thead>
45
+ <tr>
46
+ <th class="w-52">Listener</th>
47
+ <th>Default certificate</th>
48
+ <th class="w-80">Serving now</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ {{#each listeners}}
53
+ <tr data-listener="{{this.key}}">
54
+ <td class="align-top">
55
+ <div class="font-medium">{{this.name}}</div>
56
+ <div class="mt-1 flex flex-wrap items-center gap-1">
57
+ {{#if this.state}}
58
+ {{> ui/state-badge label=this.state dataType=this.key}}
59
+ {{/if}}
60
+ {{#if this.serving.label}}
61
+ {{> ui/badge label=this.serving.label.text variant=this.serving.label.type title=this.serving.label.title soft=true}}
62
+ {{/if}}
63
+ </div>
64
+ </td>
65
+ <td class="align-top">
66
+ {{> ui/setting-ref name=this.settingKey class="whitespace-nowrap"}}
67
+ <select id="tlsDefault-{{this.key}}" name="{{this.settingKey}}" class="select max-w-md"
68
+ data-tls-default="{{this.key}}">
69
+ {{#each this.options}}
70
+ <option value="{{this.id}}" {{#if this.selected}}selected{{/if}}>{{this.label}}{{#if this.covers}}
71
+ ({{this.covers}}){{/if}}</option>
72
+ {{/each}}
73
+ </select>
74
+ {{#equals this.selection "missing"}}
75
+ <span class="helper-text text-warning">{{this.missingLabel}} (<code>{{this.requested}}</code>)
76
+ no longer exists, so this listener presents the automatic choice. Save to make that the
77
+ setting.</span>
78
+ {{/equals}}
79
+ </td>
80
+ <td class="align-top text-sm">
81
+ {{#if this.serving.certificate}}
82
+ <div>Presenting {{this.serving.certificate.label}}{{#if this.serving.certificate.validToIso}}, valid
83
+ until <span class="local-time"
84
+ data-time="{{this.serving.certificate.validToIso}}">{{this.serving.certificate.validToIso}}</span>{{/if}}.
85
+ </div>
86
+ {{else if this.hint}}
87
+ <div class="text-base-content/70">{{this.hint}}{{#if this.needsSetup}} Turn it on from the <a
88
+ href="{{this.configuredAt}}" class="link link-animated">{{this.name}}</a> page.{{/if}}</div>
89
+ {{else}}
90
+ <div class="text-base-content/70">
91
+ {{#if this.tlsEnabled}}
92
+ Serving HTTPS (<code>EENGINE_API_TLS</code> is set); the listener has not reported a certificate
93
+ yet.
94
+ {{else}}
95
+ Serving plain HTTP, the default. Put a reverse proxy in front for HTTPS, or set
96
+ <code>EENGINE_API_TLS=true</code> to have EmailEngine serve it with the certificates on this
97
+ page.
98
+ {{/if}}
99
+ </div>
100
+ {{/if}}
101
+ </td>
102
+ </tr>
103
+ {{/each}}
104
+ </tbody>
105
+ </table>
106
+ </div>
107
+ <div class="card-footer border-base-content/10 border-t px-6 py-4">
108
+ {{> ui/btn label="Save Changes" type="submit" icon="icon-[tabler--settings]" id="tls-listeners-save"}}
109
+ </div>
110
+ </div>
111
+ </form>
69
112
 
70
113
  {{!-- One row per name. The Service URL's own name comes from the General page and cannot be
71
114
  removed here; the others are added from the input in the header and removed from the row menu.
72
115
  Both post immediately, the way every other list on the admin surface is edited. --}}
73
- <div class="card bg-base-100 shadow-md mb-6" id="tls-certificates">
116
+ <div class="card bg-base-100 shadow-md mb-6" id="tls-hostnames">
74
117
  <div class="card-header flex flex-wrap items-center justify-between gap-3">
75
- <h6 class="card-title text-primary">Certificates</h6>
118
+ <h6 class="card-title text-primary">Hostnames</h6>
76
119
  <form method="post" action="/admin/config/tls/hostnames" class="flex items-center gap-2 w-full sm:w-auto">
77
120
  <input type="hidden" name="crumb" value="{{crumb}}" />
78
121
  <input type="text" class="input input-sm min-w-0 grow sm:grow-0 sm:w-72" id="tlsAddHostname" name="hostname"
@@ -92,7 +135,7 @@ badgeVariant=pageLabel.type class="mb-1"}}
92
135
  <tr>
93
136
  <th>Hostname</th>
94
137
  <th class="w-36">Status</th>
95
- <th class="w-32">Source</th>
138
+ <th class="w-56">Certificate</th>
96
139
  <th class="w-32">Expires</th>
97
140
  <th class="w-40 text-end"><span class="sr-only">Actions</span></th>
98
141
  </tr>
@@ -120,10 +163,17 @@ badgeVariant=pageLabel.type class="mb-1"}}
120
163
  </td>
121
164
  <td>
122
165
  {{#if this.certificate}}
123
- {{this.certificate.sourceLabel}}
166
+ <a href="#tls-certificates" class="link link-animated">{{this.certificate.label}}</a>
124
167
  {{else}}
125
168
  <span class="text-base-content/60">None yet</span>
126
169
  {{/if}}
170
+ {{!-- A listener whose default, or whose own environment material, covers this
171
+ name presents that instead. Said here, on the row, rather than left for
172
+ the operator to derive from three tables. --}}
173
+ {{#each this.servedBy}}
174
+ <div class="text-base-content/60 text-xs" data-served-by="{{this.key}}">{{this.name}} presents
175
+ {{this.label}}</div>
176
+ {{/each}}
127
177
  </td>
128
178
  <td>
129
179
  {{#if this.certificate.validToIso}}
@@ -182,6 +232,110 @@ badgeVariant=pageLabel.type class="mb-1"}}
182
232
  {{/if}}
183
233
  </div>
184
234
 
235
+ {{!-- Every certificate the instance holds, one row each, whatever it came from: the material a
236
+ listener's environment variables supply, the uploaded certificate, each issued one, and the
237
+ self-signed fallback. "Used by" is which listeners present it by default. --}}
238
+ <div class="card bg-base-100 shadow-md mb-6" id="tls-certificates">
239
+ <div class="card-header flex flex-wrap items-center justify-between gap-3">
240
+ <h6 class="card-title text-primary">Certificates</h6>
241
+ {{> ui/btn label=(when manual "Replace uploaded certificate" "Upload a certificate") variant="primary" style="soft"
242
+ size="sm" href="/admin/config/tls/upload" icon="icon-[tabler--upload]" id="tls-upload-link"}}
243
+ </div>
244
+ <div class="overflow-x-auto">
245
+ <table class="table ee-table-wrap table-fixed min-w-[56rem]">
246
+ <thead>
247
+ <tr>
248
+ <th>Certificate</th>
249
+ <th class="w-52">Covers</th>
250
+ <th class="w-32">Status</th>
251
+ <th class="w-32">Expires</th>
252
+ <th class="w-44">Used by</th>
253
+ <th class="w-28 text-end"><span class="sr-only">Actions</span></th>
254
+ </tr>
255
+ </thead>
256
+ <tbody>
257
+ {{#each catalog}}
258
+ <tr data-certificate-row="{{this.id}}">
259
+ <td>
260
+ <div class="font-medium">{{this.label}}</div>
261
+ {{#if this.detail}}
262
+ <div class="text-base-content/60 text-xs font-mono break-all">{{this.detail}}</div>
263
+ {{else if this.certificate}}
264
+ <div class="text-base-content/60 text-xs font-mono break-all">{{this.certificate.subject}}</div>
265
+ {{/if}}
266
+ {{#equals this.source "self-signed"}}
267
+ {{#if this.certificate}}
268
+ <div class="flex items-start gap-2 mt-1">
269
+ <span class="text-base-content/60 text-xs shrink-0">SHA-256</span>
270
+ <code class="text-xs break-all min-w-0" id="selfSignedFingerprint">{{this.certificate.fingerprint256}}</code>
271
+ {{> ui/copy-btn target="selfSignedFingerprint" small=true btnClass="btn-text"}}
272
+ </div>
273
+ {{/if}}
274
+ {{/equals}}
275
+ </td>
276
+ <td>
277
+ {{#if this.certificate}}
278
+ <div class="font-mono text-sm break-words">{{#each this.certificate.altNames}}{{this}}{{#unless @last}},
279
+ {{/unless}}{{/each}}</div>
280
+ {{else}}
281
+ <span class="text-base-content/60">Every configured name, generated on first use</span>
282
+ {{/if}}
283
+ </td>
284
+ <td>
285
+ <div class="whitespace-nowrap">
286
+ {{> ui/badge label=this.status.text variant=this.status.type title=this.status.title}}
287
+ </div>
288
+ </td>
289
+ <td>
290
+ {{#if this.certificate.validToIso}}
291
+ <div><span class="local-time" data-time="{{this.certificate.validToIso}}">{{this.certificate.validToIso}}</span></div>
292
+ <div class="text-base-content/60 text-xs"><span class="relative-time" data-time="{{this.certificate.validToIso}}"></span></div>
293
+ {{/if}}
294
+ </td>
295
+ <td>
296
+ {{#if this.usedBy}}
297
+ <div class="flex flex-wrap gap-1">
298
+ {{#each this.usedBy}}
299
+ {{> ui/badge label=this.label variant="neutral" soft=true dataName="used-by" dataValue=this.key}}
300
+ {{/each}}
301
+ </div>
302
+ {{else}}
303
+ <span class="text-base-content/60 text-sm">No listener presents it by default</span>
304
+ {{/if}}
305
+ </td>
306
+ <td class="text-end">
307
+ <div class="flex items-center justify-end gap-1 whitespace-nowrap">
308
+ {{#> ui/row-actions label="Certificate actions"}}
309
+ {{!-- static first item on purpose: a block that opens with a condition can
310
+ lose its whole content to the partial-block pitfall --}}
311
+ <li><button type="button" class="dropdown-item" data-overlay="#catalogDetails{{@index}}">Details</button></li>
312
+ {{#equals this.source "manual"}}
313
+ <li><a class="dropdown-item" href="/admin/config/tls/upload">Replace</a></li>
314
+ <li><button type="button" class="dropdown-item text-error" data-overlay="#removeUploaded"
315
+ id="tls-remove-uploaded">Remove</button></li>
316
+ {{/equals}}
317
+ {{#equals this.source "acme"}}
318
+ <li><button type="button" class="dropdown-item text-error list-delete-btn"
319
+ data-delete-modal="#removeIssued" data-delete-id="{{this.hostname}}"
320
+ data-delete-name="{{this.hostname}}">Remove issued certificate</button></li>
321
+ {{/equals}}
322
+ {{#equals this.source "self-signed"}}
323
+ <li><button type="button" class="dropdown-item" data-overlay="#regenerateSelfSigned"
324
+ id="tls-regenerate-self-signed">{{#if this.certificate}}Regenerate{{else}}Generate now{{/if}}</button></li>
325
+ {{/equals}}
326
+ {{#equals this.source "env"}}
327
+ <li><span class="dropdown-item text-base-content/60">Managed outside EmailEngine</span></li>
328
+ {{/equals}}
329
+ {{/ui/row-actions}}
330
+ </div>
331
+ </td>
332
+ </tr>
333
+ {{/each}}
334
+ </tbody>
335
+ </table>
336
+ </div>
337
+ </div>
338
+
185
339
  {{> ui/env-managed-alert}}
186
340
 
187
341
  <form method="post" action="/admin/config/tls">
@@ -192,9 +346,10 @@ badgeVariant=pageLabel.type class="mb-1"}}
192
346
  <div class="card-header">
193
347
  <h6 class="card-title text-primary">Certificate source</h6>
194
348
  </div>
195
- {{!-- The setting selects which stored sources are admitted, not which one is used, so each
196
- option says what gets served: in Let's Encrypt mode an uploaded certificate still wins
197
- for the names it covers. --}}
349
+ {{!-- The setting selects which stored sources a name is resolved from, not which one is
350
+ used, so each option says what gets served: in Let's Encrypt mode an uploaded
351
+ certificate still wins for the names it covers. A default a listener was set to
352
+ present is presented in every mode - it is a choice, like environment material. --}}
198
353
  <div class="card-body space-y-4">
199
354
  <div>
200
355
  {{> ui/setting-ref name="tlsProvisioning"}}
@@ -219,125 +374,56 @@ badgeVariant=pageLabel.type class="mb-1"}}
219
374
  </div>
220
375
  </form>
221
376
 
222
- {{!-- Material that is not tied to one hostname: the uploaded certificate and the self-signed
223
- fallback each have exactly one place, and the table above only names them as a source. --}}
224
- <div class="card bg-base-100 shadow-md mb-6" id="tls-stored">
225
- <div class="card-header">
226
- <h6 class="card-title text-primary">Stored certificates</h6>
227
- </div>
228
- <div class="overflow-x-auto">
229
- <table class="table ee-table-wrap min-w-[40rem]">
230
- <tbody>
231
- <tr>
232
- <td class="w-1/3 align-top">
233
- <div class="font-medium">Uploaded certificate</div>
234
- <div class="text-base-content/60 text-xs">Served for every name it covers, ahead of anything
235
- EmailEngine obtains itself. Never renewed automatically.</div>
236
- </td>
237
- <td class="align-top">
238
- {{#if manual}}
239
- <div class="font-mono text-sm break-all">{{manual.subject}}</div>
240
- <div class="text-sm break-words">Covers <span class="font-mono">{{#each manual.altNames}}{{this}}{{#unless
241
- @last}}, {{/unless}}{{/each}}</span></div>
242
- <div class="text-base-content/60 text-sm">Valid until <span class="local-time"
243
- data-time="{{manual.validToIso}}">{{manual.validToIso}}</span> (<span class="relative-time"
244
- data-time="{{manual.validToIso}}"></span>)</div>
245
- {{else}}
246
- <span class="text-base-content/60">None uploaded yet.</span>
247
- {{/if}}
248
- </td>
249
- <td class="text-end align-top">
250
- <div class="flex items-center justify-end gap-1 whitespace-nowrap">
251
- {{#if manual}}
252
- {{> ui/btn label="Replace" variant="neutral" style="soft" size="sm" href="/admin/config/tls/upload"
253
- icon="icon-[tabler--upload]"}}
254
- {{> ui/btn label="Remove" variant="error" style="text" size="sm" icon="icon-[tabler--trash]"
255
- overlay="#removeUploaded" id="tls-remove-uploaded"}}
256
- {{else}}
257
- {{> ui/btn label="Upload a certificate" variant="primary" style="soft" size="sm"
258
- href="/admin/config/tls/upload" icon="icon-[tabler--upload]"}}
259
- {{/if}}
260
- </div>
261
- </td>
262
- </tr>
263
- <tr>
264
- <td class="align-top">
265
- <div class="font-medium">Self-signed fallback</div>
266
- <div class="text-base-content/60 text-xs">Generated on this instance the first time a listener
267
- needs one. Clients can not verify it, so pin the fingerprint or configure them to accept it.</div>
268
- </td>
269
- <td class="align-top">
270
- {{#if selfSigned}}
271
- <div class="text-sm break-words">Covers <span class="font-mono">{{#each selfSigned.altNames}}{{this}}{{#unless
272
- @last}}, {{/unless}}{{/each}}</span></div>
273
- <div class="text-base-content/60 text-sm">Valid until <span class="local-time"
274
- data-time="{{selfSigned.validToIso}}">{{selfSigned.validToIso}}</span> (<span class="relative-time"
275
- data-time="{{selfSigned.validToIso}}"></span>)</div>
276
- <div class="flex items-start gap-2 mt-1">
277
- <span class="text-base-content/60 text-xs shrink-0">SHA-256</span>
278
- <code class="text-xs break-all min-w-0" id="selfSignedFingerprint">{{selfSigned.fingerprint256}}</code>
279
- {{> ui/copy-btn target="selfSignedFingerprint" small=true btnClass="btn-text"}}
280
- </div>
281
- {{else}}
282
- <span class="text-base-content/60">Not generated yet.</span>
283
- {{/if}}
284
- </td>
285
- <td class="text-end align-top">
286
- <div class="whitespace-nowrap">
287
- {{> ui/btn label=(when selfSigned "Regenerate" "Generate") variant="neutral" style="soft" size="sm"
288
- icon="icon-[tabler--refresh]" overlay="#regenerateSelfSigned" id="tls-regenerate-self-signed"}}
289
- </div>
290
- </td>
291
- </tr>
292
- </tbody>
293
- </table>
294
- </div>
295
- </div>
296
-
297
- {{#> ui/details summary="How automatic certificates work" class="card bg-base-100 shadow-md mb-6"}}
377
+ {{#> ui/details summary="How certificates are chosen" class="card bg-base-100 shadow-md mb-6"}}
378
+ <p class="mb-2">Each listener presents its <strong>default certificate</strong> to a client that names no host, and for
379
+ every name that certificate covers. A client asking for another configured name is answered with the first
380
+ certificate in the table above that covers the name and that the source setting admits; a name nothing covers gets
381
+ the self-signed fallback. With the default left on <em>Automatic</em>, a listener presents the material from its own
382
+ TLS environment variables (<code>EENGINE_SMTP_TLS_CERT</code>, <code>EENGINE_IMAPPROXY_TLS_CERT</code>,
383
+ <code>EENGINE_API_TLS_CERT</code>) when they are set, and otherwise the certificate for the Service URL hostname. A
384
+ default chosen by hand is presented whatever the source setting says.</p>
298
385
  <p class="mb-2">EmailEngine answers the Let's Encrypt <code>http-01</code> challenge itself, at
299
386
  <code>/.well-known/acme-challenge/</code>. For that to work, the hostname has to resolve to this machine and a
300
387
  request to <strong>port 80</strong> for that name has to reach EmailEngine, directly or through a reverse proxy.
301
- Nothing else is needed; the certificate is renewed on its own well before it expires.</p>
302
- <p class="mb-2"><em>Check reachability</em> in a hostname's menu makes exactly that request against this instance's own
303
- public name, so a missing DNS record or a port 80 that goes somewhere else is reported right away instead of as an
304
- opaque ACME error minutes later.</p>
305
- <p class="mb-2">Each name gets its own certificate, served by hostname (SNI). A certificate supplied through the TLS
306
- environment variables (<code>EENGINE_SMTP_TLS_CERT</code>, <code>EENGINE_IMAPPROXY_TLS_CERT</code>,
307
- <code>EENGINE_API_TLS_CERT</code>) is served whichever source is selected above: it is an explicit instruction from
308
- whoever runs this instance, and EmailEngine does not overrule it.</p>
388
+ Nothing else is needed; the certificate is renewed on its own well before it expires. <em>Check reachability</em>
389
+ in a hostname's menu makes exactly that request against this instance's own public name, so a missing DNS record
390
+ or a port 80 that goes somewhere else is reported right away instead of as an opaque ACME error minutes later.</p>
309
391
  <p>Certificate authority: <code>{{acme.directoryUrl}}</code> (account <code>{{acme.environment}}</code>).</p>
310
392
  {{/ui/details}}
311
393
 
312
- {{!-- One details dialog per row, so the table stays five columns wide. Keyed by position: a
313
- hostname is not a valid id, and the rows are few. --}}
394
+ {{!-- One details dialog per row, so the tables stay narrow. Keyed by position: a hostname is not
395
+ a valid id, and the rows are few. --}}
396
+ {{#*inline "certificateDetails"}}
397
+ <dl class="ee-dl">
398
+ <dt>Certificate</dt>
399
+ <dd>{{this.label}}{{#if this.detail}} <span class="text-base-content/60 font-mono text-xs">{{this.detail}}</span>{{/if}}</dd>
400
+ <dt>Subject</dt>
401
+ <dd class="break-all">{{this.subject}}</dd>
402
+ <dt>Issuer</dt>
403
+ <dd class="break-all">{{this.issuer}}</dd>
404
+ <dt>Covers</dt>
405
+ <dd class="font-mono text-sm break-all">{{#each this.altNames}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}</dd>
406
+ <dt>Valid from</dt>
407
+ <dd><span class="local-date-time" data-time="{{this.validFromIso}}">{{this.validFromIso}}</span></dd>
408
+ <dt>Valid until</dt>
409
+ <dd><span class="local-date-time" data-time="{{this.validToIso}}">{{this.validToIso}}</span></dd>
410
+ <dt>SHA-256 fingerprint</dt>
411
+ <dd>
412
+ <div class="flex items-start gap-2">
413
+ <code class="text-xs break-all min-w-0" id="{{fingerprintId}}">{{this.fingerprint256}}</code>
414
+ {{> ui/copy-btn target=fingerprintId small=true btnClass="btn-text"}}
415
+ </div>
416
+ </dd>
417
+ <dt>Chain</dt>
418
+ <dd>{{ngettext '%d certificate' '%d certificates' this.chainLength}}</dd>
419
+ </dl>
420
+ {{/inline}}
421
+
314
422
  {{#each certificates}}
315
423
  {{#> ui/modal id=(concat "certDetails" @index) title=this.hostname}}
316
424
  <div class="modal-body">
317
425
  {{#if this.certificate}}
318
- <dl class="ee-dl">
319
- <dt>Source</dt>
320
- <dd>{{this.certificate.sourceLabel}}</dd>
321
- <dt>Subject</dt>
322
- <dd class="break-all">{{this.certificate.subject}}</dd>
323
- <dt>Issuer</dt>
324
- <dd class="break-all">{{this.certificate.issuer}}</dd>
325
- <dt>Covers</dt>
326
- <dd class="font-mono text-sm break-all">{{#each this.certificate.altNames}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}</dd>
327
- <dt>Valid from</dt>
328
- <dd><span class="local-date-time" data-time="{{this.certificate.validFromIso}}">{{this.certificate.validFromIso}}</span></dd>
329
- <dt>Valid until</dt>
330
- <dd><span class="local-date-time" data-time="{{this.certificate.validToIso}}">{{this.certificate.validToIso}}</span></dd>
331
- <dt>SHA-256 fingerprint</dt>
332
- <dd>
333
- <div class="flex items-start gap-2">
334
- <code class="text-xs break-all min-w-0" id="certFingerprint{{@index}}">{{this.certificate.fingerprint256}}</code>
335
- {{> ui/copy-btn target=(concat "certFingerprint" @index) small=true btnClass="btn-text"}}
336
- </div>
337
- </dd>
338
- <dt>Chain</dt>
339
- <dd>{{ngettext '%d certificate' '%d certificates' this.certificate.chainLength}}</dd>
340
- </dl>
426
+ {{> certificateDetails this.certificate fingerprintId=(concat "certFingerprint" @index)}}
341
427
  {{else}}
342
428
  <p class="text-base-content/60 mb-0">No certificate is stored for this name yet.</p>
343
429
  {{/if}}
@@ -345,6 +431,19 @@ badgeVariant=pageLabel.type class="mb-1"}}
345
431
  {{/ui/modal}}
346
432
  {{/each}}
347
433
 
434
+ {{#each catalog}}
435
+ {{#> ui/modal id=(concat "catalogDetails" @index) title=this.label}}
436
+ <div class="modal-body">
437
+ {{#if this.certificate}}
438
+ {{> certificateDetails this.certificate fingerprintId=(concat "catalogFingerprint" @index)}}
439
+ {{else}}
440
+ <p class="text-base-content/60 mb-0">Not generated yet. It is generated for every configured name the first time a
441
+ listener needs it, or from its row menu.</p>
442
+ {{/if}}
443
+ </div>
444
+ {{/ui/modal}}
445
+ {{/each}}
446
+
348
447
  {{#> ui/delete-modal id="removeHostname" noun="hostname" action="/admin/config/tls/hostnames/delete" fieldName="hostname"}}
349
448
  Stop serving a certificate for <strong class="delete-target-name"></strong>? An already issued certificate is kept and
350
449
  used again if the name is added back.
@@ -353,12 +452,14 @@ used again if the name is added back.
353
452
  {{#> ui/confirm-modal id="removeIssued" title="Remove issued certificate" action="/admin/config/tls/delete"
354
453
  fieldName="certificate" fieldClass="delete-target-id" submitLabel="Remove certificate"}}
355
454
  Remove the Let's Encrypt certificate stored for <strong class="delete-target-name"></strong>? The name falls back to the
356
- self-signed certificate until a new one is ordered.
455
+ self-signed certificate until a new one is ordered. A listener set to present this certificate presents its automatic
456
+ choice until it is set to another.
357
457
  {{/ui/confirm-modal}}
358
458
 
359
459
  {{#> ui/confirm-modal id="removeUploaded" title="Remove uploaded certificate" action="/admin/config/tls/delete"
360
460
  fieldName="certificate" fieldValue="manual" submitLabel="Remove certificate"}}
361
- Remove the uploaded certificate? Every name it covers falls back to whatever the selected source provides.
461
+ Remove the uploaded certificate? Every name it covers falls back to whatever the selected source provides. A listener
462
+ set to present it presents its automatic choice until it is set to another.
362
463
  {{/ui/confirm-modal}}
363
464
 
364
465
  {{#> ui/confirm-modal id="regenerateSelfSigned" title="Self-signed certificate" action="/admin/config/tls/delete"
@@ -372,7 +473,7 @@ Generate a self-signed certificate for every configured name now, instead of the
372
473
  {{/if}}
373
474
  {{/ui/confirm-modal}}
374
475
 
375
- <script nonce="{{cspNonce}}">
476
+ <script data-cfasync="false" nonce="{{cspNonce}}">
376
477
  document.addEventListener('DOMContentLoaded', () => {
377
478
 
378
479
  // The one line under a hostname row. Every message about a name lands here, so a name
@@ -267,9 +267,9 @@ class="mb-1"}}
267
267
  </form>
268
268
 
269
269
  {{> ace_assets}}
270
- <script src="/static/js/ace/ext-language_tools.js"></script>
270
+ <script data-cfasync="false" src="/static/js/ace/ext-language_tools.js"></script>
271
271
 
272
- <script nonce="{{cspNonce}}">
272
+ <script data-cfasync="false" nonce="{{cspNonce}}">
273
273
  document.addEventListener('DOMContentLoaded', () => {
274
274
 
275
275
  const sendTestPayload = async () => {
@@ -163,7 +163,7 @@ submitLabel="Download Snapshot" submitVariant="info"}}
163
163
  Generate a memory snapshot for debugging? This may briefly affect thread performance.
164
164
  {{/ui/confirm-modal}}
165
165
 
166
- <script nonce="{{cspNonce}}">
166
+ <script data-cfasync="false" nonce="{{cspNonce}}">
167
167
  document.addEventListener('DOMContentLoaded', () => {
168
168
  for (let elm of document.querySelectorAll('.kill-thread-btn')) {
169
169
  elm.addEventListener('click', e => {
@@ -334,12 +334,12 @@
334
334
  </div>
335
335
  <!-- End of content column -->
336
336
 
337
- <script src="/static/js/flyonui.js"></script>
338
- <script src="/static/js/ui.js"></script>
337
+ <script data-cfasync="false" src="/static/js/flyonui.js"></script>
338
+ <script data-cfasync="false" src="/static/js/ui.js"></script>
339
339
 
340
- <script src="/static/js/highlight.min.js"></script>
340
+ <script data-cfasync="false" src="/static/js/highlight.min.js"></script>
341
341
 
342
- <script src="/static/js/app.js"></script>
342
+ <script data-cfasync="false" src="/static/js/app.js"></script>
343
343
 
344
344
  {{!-- global #crumb element for page scripts that post with fetch();
345
345
  must render unconditionally - converted pages rely on it instead of
@@ -352,7 +352,7 @@
352
352
  Provisioning a trial license, please wait <span class="loading loading-spinner loading-sm align-middle"></span>
353
353
  </div>
354
354
  {{/ui/modal}}
355
- <script nonce="{{cspNonce}}">
355
+ <script data-cfasync="false" nonce="{{cspNonce}}">
356
356
  document.addEventListener('DOMContentLoaded', () => {
357
357
  let trialBtn = document.getElementById('start-trial-btn');
358
358
  if (!trialBtn) {
@@ -392,7 +392,7 @@
392
392
 
393
393
  {{#if updateBrowserInfo}}
394
394
  <input type="hidden" id="browser-info-crumb" value="{{crumb}}" />
395
- <script nonce="{{cspNonce}}">
395
+ <script data-cfasync="false" nonce="{{cspNonce}}">
396
396
  document.addEventListener('DOMContentLoaded', () => {
397
397
  let sendBrowserInfo = async () => {
398
398
  let timezone = false;