emailengine-app 2.80.0 → 2.81.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.
Files changed (178) hide show
  1. package/.dockerignore +44 -0
  2. package/.github/docker-smoke-test.sh +16 -0
  3. package/.github/workflows/deploy.yml +4 -0
  4. package/.github/workflows/release.yaml +4 -0
  5. package/.github/workflows/test.yml +2 -0
  6. package/.release-please-manifest.json +1 -1
  7. package/CHANGELOG.md +56 -0
  8. package/Dockerfile +17 -9
  9. package/README.md +6 -0
  10. package/data/google-crawlers.json +1 -1
  11. package/docker-compose.yml +7 -1
  12. package/lib/api-routes/account-routes.js +239 -73
  13. package/lib/api-routes/blocklist-routes.js +24 -0
  14. package/lib/api-routes/delivery-test-routes.js +6 -0
  15. package/lib/api-routes/gateway-routes.js +30 -0
  16. package/lib/api-routes/license-routes.js +10 -0
  17. package/lib/api-routes/mcp-oauth-routes.js +3 -3
  18. package/lib/api-routes/mcp-routes.js +39 -21
  19. package/lib/api-routes/oauth2-app-routes.js +38 -1
  20. package/lib/api-routes/outbox-routes.js +6 -0
  21. package/lib/api-routes/permission-map.js +212 -42
  22. package/lib/api-routes/pubsub-routes.js +8 -0
  23. package/lib/api-routes/route-helpers.js +58 -11
  24. package/lib/api-routes/settings-routes.js +50 -4
  25. package/lib/api-routes/stats-routes.js +6 -0
  26. package/lib/api-routes/template-routes.js +21 -0
  27. package/lib/api-routes/token-routes.js +34 -2
  28. package/lib/api-routes/webhook-route-routes.js +13 -0
  29. package/lib/autodetect-imap-settings.js +4 -4
  30. package/lib/email-client/base-client.js +6 -3
  31. package/lib/email-client/credential-errors.js +4 -0
  32. package/lib/email-client/imap/login-failure.js +52 -0
  33. package/lib/email-client/imap/subconnection.js +2 -1
  34. package/lib/email-client/imap-client.js +3 -6
  35. package/lib/enum-descriptions.js +12 -2
  36. package/lib/imapproxy/imap-server.js +1 -1
  37. package/lib/mcp/oauth.js +46 -8
  38. package/lib/mcp/protocol.js +78 -35
  39. package/lib/mcp/tools.js +53 -17
  40. package/lib/privileged-settings.js +147 -0
  41. package/lib/schemas.js +60 -16
  42. package/lib/sentry.js +13 -2
  43. package/lib/settings.js +13 -0
  44. package/lib/tls/catalog.js +428 -0
  45. package/lib/tls/context.js +87 -161
  46. package/lib/tls/listeners.js +62 -0
  47. package/lib/tls/provision.js +1 -1
  48. package/lib/tls/status.js +128 -79
  49. package/lib/tls/store.js +3 -2
  50. package/lib/token-permission-view.js +253 -102
  51. package/lib/token-permissions.js +176 -26
  52. package/lib/tokens.js +7 -6
  53. package/lib/tools.js +5 -3
  54. package/lib/ui-routes/account-routes.js +195 -61
  55. package/lib/ui-routes/admin-config-routes.js +41 -21
  56. package/lib/ui-routes/admin-entities-routes.js +32 -22
  57. package/lib/ui-routes/mcp-consent-routes.js +72 -31
  58. package/lib/ui-routes/tls-config-routes.js +121 -74
  59. package/package.json +16 -16
  60. package/sbom.json +1 -1
  61. package/server.js +7 -1
  62. package/static/css/flyonui.css +1 -1
  63. package/static/css/public.css +41 -0
  64. package/static/css/src/app.tailwind.css +135 -4
  65. package/static/js/public.js +218 -0
  66. package/static/js/ui.js +89 -36
  67. package/static/licenses.html +55 -37
  68. package/translations/README.md +4 -3
  69. package/translations/de.mo +0 -0
  70. package/translations/de.po +296 -185
  71. package/translations/en.po +220 -128
  72. package/translations/es.mo +0 -0
  73. package/translations/es.po +558 -0
  74. package/translations/et.mo +0 -0
  75. package/translations/et.po +288 -181
  76. package/translations/fr.mo +0 -0
  77. package/translations/fr.po +295 -183
  78. package/translations/it.mo +0 -0
  79. package/translations/it.po +558 -0
  80. package/translations/ja.mo +0 -0
  81. package/translations/ja.po +268 -192
  82. package/translations/locales.json +24 -0
  83. package/translations/messages.pot +179 -127
  84. package/translations/nl.mo +0 -0
  85. package/translations/nl.po +288 -175
  86. package/translations/pl.mo +0 -0
  87. package/translations/pl.po +294 -181
  88. package/translations/sv.mo +0 -0
  89. package/translations/sv.po +555 -0
  90. package/translations/tr.mo +0 -0
  91. package/translations/tr.po +555 -0
  92. package/update-info.sh +12 -6
  93. package/views/account/login-redirect.hbs +6 -5
  94. package/views/account/passkeys.hbs +8 -8
  95. package/views/account/security.hbs +2 -2
  96. package/views/accounts/account.hbs +19 -21
  97. package/views/accounts/browse.hbs +1 -1
  98. package/views/accounts/edit.hbs +15 -15
  99. package/views/accounts/index.hbs +3 -3
  100. package/views/accounts/register/imap-server.hbs +27 -173
  101. package/views/accounts/register/validating.hbs +139 -0
  102. package/views/config/ai.hbs +15 -17
  103. package/views/config/branding.hbs +7 -7
  104. package/views/config/document-store/chat.hbs +9 -8
  105. package/views/config/document-store/index.hbs +14 -15
  106. package/views/config/document-store/mappings/index.hbs +5 -6
  107. package/views/config/document-store/mappings/new.hbs +1 -2
  108. package/views/config/document-store/pre-processing/index.hbs +4 -4
  109. package/views/config/email-processing.hbs +6 -6
  110. package/views/config/imap-proxy.hbs +7 -8
  111. package/views/config/license.hbs +9 -9
  112. package/views/config/logging.hbs +5 -7
  113. package/views/config/mcp.hbs +90 -58
  114. package/views/config/network.hbs +4 -4
  115. package/views/config/oauth/app.hbs +12 -12
  116. package/views/config/oauth/index.hbs +6 -6
  117. package/views/config/oauth/subscriptions.hbs +9 -9
  118. package/views/config/security.hbs +5 -7
  119. package/views/config/service.hbs +11 -10
  120. package/views/config/smtp.hbs +9 -12
  121. package/views/config/tls-upload.hbs +3 -3
  122. package/views/config/tls.hbs +281 -182
  123. package/views/config/webhooks.hbs +12 -15
  124. package/views/dashboard.hbs +9 -8
  125. package/views/gateways/edit.hbs +3 -3
  126. package/views/gateways/gateway.hbs +3 -3
  127. package/views/gateways/index.hbs +6 -6
  128. package/views/gateways/new.hbs +3 -3
  129. package/views/internals/index.hbs +15 -13
  130. package/views/layout/app.hbs +6 -6
  131. package/views/layout/login.hbs +32 -19
  132. package/views/layout/main.hbs +2 -2
  133. package/views/layout/prompt.hbs +15 -18
  134. package/views/layout/public.hbs +1 -1
  135. package/views/mcp/authorize.hbs +47 -45
  136. package/views/partials/accounts_table.hbs +5 -5
  137. package/views/partials/ace_assets.hbs +1 -1
  138. package/views/partials/add_account_modal.hbs +4 -4
  139. package/views/partials/address_list.hbs +4 -4
  140. package/views/partials/filter_editor_js.hbs +2 -2
  141. package/views/partials/gateway_form.hbs +5 -5
  142. package/views/partials/gateway_js.hbs +1 -1
  143. package/views/partials/mcp_access_levels.hbs +16 -9
  144. package/views/partials/mcp_account_limit.hbs +2 -2
  145. package/views/partials/mcp_tool_count.hbs +15 -14
  146. package/views/partials/oauth_config_header.hbs +2 -2
  147. package/views/partials/oauth_form.hbs +37 -42
  148. package/views/partials/public_alerts.hbs +1 -1
  149. package/views/partials/public_test_labels.hbs +15 -0
  150. package/views/partials/public_theme_init.hbs +1 -1
  151. package/views/partials/security_header.hbs +2 -2
  152. package/views/partials/template_form.hbs +4 -4
  153. package/views/partials/theme_init.hbs +1 -1
  154. package/views/partials/tls_security_card.hbs +4 -1
  155. package/views/partials/ui/form-field.hbs +6 -1
  156. package/views/partials/ui/setting-ref.hbs +12 -7
  157. package/views/partials/ui/stat-card.hbs +4 -1
  158. package/views/partials/ui/tabs.hbs +3 -7
  159. package/views/partials/webhook_form.hbs +9 -12
  160. package/views/partials/webhooks_editor_functions.hbs +1 -1
  161. package/views/reference/index.hbs +3 -3
  162. package/views/reference/redirect.hbs +1 -1
  163. package/views/reference/tag.hbs +1 -1
  164. package/views/reference/token.hbs +4 -4
  165. package/views/suppression-lists/index.hbs +8 -6
  166. package/views/suppression-lists/list.hbs +13 -8
  167. package/views/templates/edit.hbs +1 -1
  168. package/views/templates/index.hbs +10 -11
  169. package/views/templates/template.hbs +5 -5
  170. package/views/tokens/index.hbs +17 -17
  171. package/views/tokens/new.hbs +190 -93
  172. package/views/unsubscribe.hbs +1 -1
  173. package/views/webhooks/edit.hbs +1 -1
  174. package/views/webhooks/index.hbs +10 -11
  175. package/views/webhooks/new.hbs +1 -1
  176. package/views/webhooks/webhook.hbs +5 -6
  177. package/workers/api.js +9 -8
  178. package/workers/smtp.js +1 -1
@@ -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"}}
@@ -11,68 +11,108 @@ badgeVariant=pageLabel.type class="mb-1"}}
11
11
  </div>
12
12
  {{/ui/page-header}}
13
13
 
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>
14
+ <p class="mb-6">Manage TLS certificates for the SMTP server, IMAP proxy, and HTTPS interface. Use Let's Encrypt, upload a
15
+ certificate, supply one through environment variables, or generate a self-signed certificate.</p>
17
16
 
18
17
  {{#if acme.staging}}
19
18
  {{#> ui/alert-banner variant="warning" icon="icon-[tabler--flask]" title="Staging certificate authority"}}
20
19
  <div>This instance is pointed at the Let's Encrypt staging directory (<code>{{acme.directoryUrl}}</code>). Certificates
21
- it issues are signed by a root nobody trusts, so every client will refuse them. Clear
22
- <code>EENGINE_ACME_DIRECTORY_URL</code> to go back to production.</div>
20
+ it issues are for testing and are not trusted by standard clients. To restore the production defaults, clear
21
+ both <code>EENGINE_ACME_DIRECTORY_URL</code> and <code>EENGINE_ACME_ENVIRONMENT</code>, then restart EmailEngine.</div>
23
22
  {{/ui/alert-banner}}
24
23
  {{/if}}
25
24
 
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}}
25
+ {{!-- Listeners first: what clients actually get is the reason to open this page. One row per
26
+ listener, with the certificate it presents by default as a dropdown. Saved with the button
27
+ rather than on change: every save reloads the listeners, and a wrong default is what a
28
+ client sees on its next handshake. --}}
29
+ <form method="post" action="/admin/config/tls/listeners">
30
+ {{!-- no id: the layout already renders the #crumb element the scripts read --}}
31
+ <input type="hidden" name="crumb" value="{{crumb}}" />
60
32
 
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>
33
+ <div class="card bg-base-100 shadow-md mb-6" id="tls-listeners">
34
+ <div class="card-header">
35
+ <h6 class="card-title text-primary">Listeners</h6>
36
+ </div>
37
+ <div class="px-6 pt-4 text-sm text-base-content/70">The default certificate is presented to a client that names
38
+ no host, and for every name it covers. Other configured names are served their own certificate, from the
39
+ table below.</div>
40
+ <div class="overflow-x-auto">
41
+ <table class="table ee-table-wrap table-fixed md:min-w-[56rem] ee-table-stack">
42
+ <thead>
43
+ <tr>
44
+ <th class="w-52">Listener</th>
45
+ <th>Default certificate</th>
46
+ <th class="w-80">Serving now</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ {{#each listeners}}
51
+ <tr data-listener="{{this.key}}">
52
+ <td class="align-top">
53
+ <div class="font-medium">{{this.name}}</div>
54
+ <div class="mt-1 flex flex-wrap items-center gap-1">
55
+ {{#if this.state}}
56
+ {{> ui/state-badge label=this.state dataType=this.key}}
57
+ {{/if}}
58
+ {{#if this.serving.label}}
59
+ {{> ui/badge label=this.serving.label.text variant=this.serving.label.type title=this.serving.label.title soft=true}}
60
+ {{/if}}
61
+ </div>
62
+ </td>
63
+ <td class="align-top" data-label="Default certificate">
64
+ {{> ui/setting-ref name=this.settingKey class="whitespace-nowrap"}}
65
+ <select id="tlsDefault-{{this.key}}" name="{{this.settingKey}}" class="select max-w-md"
66
+ data-tls-default="{{this.key}}">
67
+ {{#each this.options}}
68
+ <option value="{{this.id}}" {{#if this.selected}}selected{{/if}}>{{this.label}}{{#if this.covers}}
69
+ ({{this.covers}}){{/if}}</option>
70
+ {{/each}}
71
+ </select>
72
+ {{#equals this.selection "missing"}}
73
+ <span class="helper-text text-warning">{{this.missingLabel}} (<code>{{this.requested}}</code>)
74
+ is no longer available. This listener is using the automatic choice. Save changes to keep that selection.</span>
75
+ {{/equals}}
76
+ </td>
77
+ <td class="align-top text-sm" data-label="Serving now">
78
+ {{#if this.serving.certificate}}
79
+ <div>Presenting {{this.serving.certificate.label}}{{#if this.serving.certificate.validToIso}}, valid
80
+ until <span class="local-time"
81
+ data-time="{{this.serving.certificate.validToIso}}">{{this.serving.certificate.validToIso}}</span>{{/if}}.
82
+ </div>
83
+ {{else if this.hint}}
84
+ <div class="text-base-content/70">{{this.hint}}{{#if this.needsSetup}} Turn it on from the <a
85
+ href="{{this.configuredAt}}" class="link link-animated">{{this.name}}</a> page.{{/if}}</div>
86
+ {{else}}
87
+ <div class="text-base-content/70">
88
+ {{#if this.tlsEnabled}}
89
+ Serving HTTPS (<code>EENGINE_API_TLS</code> is set); the listener has not reported a certificate
90
+ yet.
91
+ {{else}}
92
+ Serving plain HTTP, the default. Put a reverse proxy in front for HTTPS, or set
93
+ <code>EENGINE_API_TLS=true</code> to have EmailEngine serve it with the certificates on this
94
+ page.
95
+ {{/if}}
96
+ </div>
97
+ {{/if}}
98
+ </td>
99
+ </tr>
100
+ {{/each}}
101
+ </tbody>
102
+ </table>
103
+ </div>
104
+ <div class="card-footer border-base-content/10 border-t px-6 py-4">
105
+ {{> ui/btn label="Save changes" type="submit" icon="icon-[tabler--settings]" id="tls-listeners-save"}}
106
+ </div>
107
+ </div>
108
+ </form>
69
109
 
70
110
  {{!-- One row per name. The Service URL's own name comes from the General page and cannot be
71
111
  removed here; the others are added from the input in the header and removed from the row menu.
72
112
  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">
113
+ <div class="card bg-base-100 shadow-md mb-6" id="tls-hostnames">
74
114
  <div class="card-header flex flex-wrap items-center justify-between gap-3">
75
- <h6 class="card-title text-primary">Certificates</h6>
115
+ <h6 class="card-title text-primary">Hostnames</h6>
76
116
  <form method="post" action="/admin/config/tls/hostnames" class="flex items-center gap-2 w-full sm:w-auto">
77
117
  <input type="hidden" name="crumb" value="{{crumb}}" />
78
118
  <input type="text" class="input input-sm min-w-0 grow sm:grow-0 sm:w-72" id="tlsAddHostname" name="hostname"
@@ -85,14 +125,15 @@ badgeVariant=pageLabel.type class="mb-1"}}
85
125
 
86
126
  {{#if certificates}}
87
127
  {{!-- Fixed layout, so the line under a row wraps inside the card instead of widening the table;
88
- the minimum width keeps the columns readable on a phone, where the wrapper scrolls. --}}
128
+ the minimum width keeps the columns readable from md up, where this is still a table.
129
+ Below that ee-table-stack turns each row into a block, so the minimum is not applied. --}}
89
130
  <div class="overflow-x-auto">
90
- <table class="table ee-table-wrap table-fixed min-w-[52rem]">
131
+ <table class="table ee-table-wrap table-fixed md:min-w-[52rem] ee-table-stack">
91
132
  <thead>
92
133
  <tr>
93
134
  <th>Hostname</th>
94
135
  <th class="w-36">Status</th>
95
- <th class="w-32">Source</th>
136
+ <th class="w-56">Certificate</th>
96
137
  <th class="w-32">Expires</th>
97
138
  <th class="w-40 text-end"><span class="sr-only">Actions</span></th>
98
139
  </tr>
@@ -106,11 +147,11 @@ badgeVariant=pageLabel.type class="mb-1"}}
106
147
  <div class="text-base-content/60 text-xs">Service URL</div>
107
148
  {{/if}}
108
149
  {{#unless this.acmeEligible}}
109
- <div class="text-base-content/60 text-xs">Not a public name, so Let's Encrypt can not validate
150
+ <div class="text-base-content/60 text-xs">Not a public name, so Let's Encrypt cannot validate
110
151
  it</div>
111
152
  {{/unless}}
112
153
  </td>
113
- <td>
154
+ <td data-label="Status">
114
155
  {{!-- the wrapper keeps the badge on one line: the page script rewrites the
115
156
  badge's own class list on a live update --}}
116
157
  <div class="whitespace-nowrap">
@@ -118,20 +159,29 @@ badgeVariant=pageLabel.type class="mb-1"}}
118
159
  dataName="cert-badge" dataValue=this.hostname}}
119
160
  </div>
120
161
  </td>
121
- <td>
162
+ <td data-label="Certificate">
122
163
  {{#if this.certificate}}
123
- {{this.certificate.sourceLabel}}
164
+ <a href="#tls-certificates" class="link link-animated">{{this.certificate.label}}</a>
124
165
  {{else}}
125
166
  <span class="text-base-content/60">None yet</span>
126
167
  {{/if}}
168
+ {{!-- A listener whose default, or whose own environment material, covers this
169
+ name presents that instead. Said here, on the row, rather than left for
170
+ the operator to derive from three tables. --}}
171
+ {{#each this.servedBy}}
172
+ <div class="text-base-content/60 text-xs" data-served-by="{{this.key}}">{{this.name}} presents
173
+ {{this.label}}</div>
174
+ {{/each}}
127
175
  </td>
128
- <td>
176
+ <td data-label="Expires">
129
177
  {{#if this.certificate.validToIso}}
130
178
  <div><span class="local-time" data-time="{{this.certificate.validToIso}}">{{this.certificate.validToIso}}</span></div>
131
179
  <div class="text-base-content/60 text-xs"><span class="relative-time" data-time="{{this.certificate.validToIso}}"></span></div>
180
+ {{else}}
181
+ <span class="text-base-content/40">-</span>
132
182
  {{/if}}
133
183
  </td>
134
- <td class="text-end">
184
+ <td class="ee-stack-actions text-end">
135
185
  <div class="flex items-center justify-end gap-1 whitespace-nowrap">
136
186
  {{#if this.wanted}}
137
187
  {{> ui/btn label="Request" variant="primary" style="soft" size="sm" icon="icon-[tabler--refresh]"
@@ -182,6 +232,112 @@ 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 md:min-w-[56rem] ee-table-stack">
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 data-label="Covers">
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 data-label="Status">
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 data-label="Expires">
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
+ {{else}}
294
+ <span class="text-base-content/40">-</span>
295
+ {{/if}}
296
+ </td>
297
+ <td data-label="Used by">
298
+ {{#if this.usedBy}}
299
+ <div class="flex flex-wrap gap-1">
300
+ {{#each this.usedBy}}
301
+ {{> ui/badge label=this.label variant="neutral" soft=true dataName="used-by" dataValue=this.key}}
302
+ {{/each}}
303
+ </div>
304
+ {{else}}
305
+ <span class="text-base-content/60 text-sm">No listener presents it by default</span>
306
+ {{/if}}
307
+ </td>
308
+ <td class="ee-stack-actions text-end">
309
+ <div class="flex items-center justify-end gap-1 whitespace-nowrap">
310
+ {{#> ui/row-actions label="Certificate actions"}}
311
+ {{!-- static first item on purpose: a block that opens with a condition can
312
+ lose its whole content to the partial-block pitfall --}}
313
+ <li><button type="button" class="dropdown-item" data-overlay="#catalogDetails{{@index}}">Details</button></li>
314
+ {{#equals this.source "manual"}}
315
+ <li><a class="dropdown-item" href="/admin/config/tls/upload">Replace</a></li>
316
+ <li><button type="button" class="dropdown-item text-error" data-overlay="#removeUploaded"
317
+ id="tls-remove-uploaded">Remove</button></li>
318
+ {{/equals}}
319
+ {{#equals this.source "acme"}}
320
+ <li><button type="button" class="dropdown-item text-error list-delete-btn"
321
+ data-delete-modal="#removeIssued" data-delete-id="{{this.hostname}}"
322
+ data-delete-name="{{this.hostname}}">Remove issued certificate</button></li>
323
+ {{/equals}}
324
+ {{#equals this.source "self-signed"}}
325
+ <li><button type="button" class="dropdown-item" data-overlay="#regenerateSelfSigned"
326
+ id="tls-regenerate-self-signed">{{#if this.certificate}}Regenerate{{else}}Generate now{{/if}}</button></li>
327
+ {{/equals}}
328
+ {{#equals this.source "env"}}
329
+ <li><span class="dropdown-item text-base-content/60">Managed outside EmailEngine</span></li>
330
+ {{/equals}}
331
+ {{/ui/row-actions}}
332
+ </div>
333
+ </td>
334
+ </tr>
335
+ {{/each}}
336
+ </tbody>
337
+ </table>
338
+ </div>
339
+ </div>
340
+
185
341
  {{> ui/env-managed-alert}}
186
342
 
187
343
  <form method="post" action="/admin/config/tls">
@@ -192,152 +348,80 @@ badgeVariant=pageLabel.type class="mb-1"}}
192
348
  <div class="card-header">
193
349
  <h6 class="card-title text-primary">Certificate source</h6>
194
350
  </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. --}}
351
+ {{!-- The setting selects which stored sources a name is resolved from, not which one is
352
+ used, so each option says what gets served: in Let's Encrypt mode an uploaded
353
+ certificate still wins for the names it covers. A default a listener was set to
354
+ present is presented in every mode - it is a choice, like environment material. --}}
198
355
  <div class="card-body space-y-4">
199
356
  <div>
200
357
  {{> ui/setting-ref name="tlsProvisioning"}}
201
358
  {{> ui/radio id="tlsProvisioningAcme" name="tlsProvisioning" value="acme" label="Let's Encrypt (recommended)"
202
- selected=values.tlsProvisioning hint="Ordered and renewed for every public name. An uploaded certificate
203
- still wins for the names it covers."}}
359
+ selected=values.tlsProvisioning hint="Automatically request and renew certificates for public hostnames. Uploaded certificates take priority for the names they cover."}}
204
360
  </div>
205
361
  <div>
206
362
  {{> ui/radio id="tlsProvisioningManual" name="tlsProvisioning" value="manual" label="Uploaded certificate only"
207
- selected=values.tlsProvisioning hint="Nothing is ordered. Names the upload does not cover get the
208
- self-signed fallback."}}
363
+ selected=values.tlsProvisioning hint="Use the uploaded certificate. Hostnames it does not cover use the self-signed fallback."}}
209
364
  </div>
210
365
  <div>
211
366
  {{> ui/radio id="tlsProvisioningSelfSigned" name="tlsProvisioning" value="self-signed" label="Self-signed only"
212
- selected=values.tlsProvisioning hint="For an instance the internet can not reach. Clients must pin the
213
- fingerprint or be told to accept the certificate."}}
367
+ selected=values.tlsProvisioning hint="Use a self-signed certificate. Clients must be configured to trust it, for example by pinning its fingerprint."}}
214
368
  </div>
215
369
  </div>
216
370
  <div class="card-footer border-base-content/10 border-t px-6 py-4">
217
- {{> ui/btn label="Save Changes" type="submit" icon="icon-[tabler--settings]"}}
371
+ {{> ui/btn label="Save changes" type="submit" icon="icon-[tabler--settings]"}}
218
372
  </div>
219
373
  </div>
220
374
  </form>
221
375
 
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"}}
376
+ {{#> ui/details summary="How certificates are chosen" class="card bg-base-100 shadow-md mb-6"}}
377
+ <p class="mb-2">Each listener presents its <strong>default certificate</strong> to a client that names no host, and for
378
+ every name that certificate covers. A client asking for another configured name is answered with the first
379
+ certificate in the table above that covers the name and that the source setting admits; a name nothing covers gets
380
+ the self-signed fallback. With the default left on <em>Automatic</em>, a listener presents the material from its own
381
+ TLS environment variables (<code>EENGINE_SMTP_TLS_CERT</code>, <code>EENGINE_IMAPPROXY_TLS_CERT</code>,
382
+ <code>EENGINE_API_TLS_CERT</code>) when they are set, and otherwise the certificate for the Service URL hostname. A
383
+ default chosen by hand is presented whatever the source setting says.</p>
298
384
  <p class="mb-2">EmailEngine answers the Let's Encrypt <code>http-01</code> challenge itself, at
299
385
  <code>/.well-known/acme-challenge/</code>. For that to work, the hostname has to resolve to this machine and a
300
386
  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>
387
+ EmailEngine renews issued certificates automatically. Use <em>Check reachability</em> in a hostname's menu
388
+ to check DNS and port 80 access before requesting a certificate.</p>
309
389
  <p>Certificate authority: <code>{{acme.directoryUrl}}</code> (account <code>{{acme.environment}}</code>).</p>
310
390
  {{/ui/details}}
311
391
 
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. --}}
392
+ {{!-- One details dialog per row, so the tables stay narrow. Keyed by position: a hostname is not
393
+ a valid id, and the rows are few. --}}
394
+ {{#*inline "certificateDetails"}}
395
+ <dl class="ee-dl">
396
+ <dt>Certificate</dt>
397
+ <dd>{{this.label}}{{#if this.detail}} <span class="text-base-content/60 font-mono text-xs">{{this.detail}}</span>{{/if}}</dd>
398
+ <dt>Subject</dt>
399
+ <dd class="break-all">{{this.subject}}</dd>
400
+ <dt>Issuer</dt>
401
+ <dd class="break-all">{{this.issuer}}</dd>
402
+ <dt>Covers</dt>
403
+ <dd class="font-mono text-sm break-all">{{#each this.altNames}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}</dd>
404
+ <dt>Valid from</dt>
405
+ <dd><span class="local-date-time" data-time="{{this.validFromIso}}">{{this.validFromIso}}</span></dd>
406
+ <dt>Valid until</dt>
407
+ <dd><span class="local-date-time" data-time="{{this.validToIso}}">{{this.validToIso}}</span></dd>
408
+ <dt>SHA-256 fingerprint</dt>
409
+ <dd>
410
+ <div class="flex items-start gap-2">
411
+ <code class="text-xs break-all min-w-0" id="{{fingerprintId}}">{{this.fingerprint256}}</code>
412
+ {{> ui/copy-btn target=fingerprintId small=true btnClass="btn-text"}}
413
+ </div>
414
+ </dd>
415
+ <dt>Chain</dt>
416
+ <dd>{{ngettext '%d certificate' '%d certificates' this.chainLength}}</dd>
417
+ </dl>
418
+ {{/inline}}
419
+
314
420
  {{#each certificates}}
315
421
  {{#> ui/modal id=(concat "certDetails" @index) title=this.hostname}}
316
422
  <div class="modal-body">
317
423
  {{#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>
424
+ {{> certificateDetails this.certificate fingerprintId=(concat "certFingerprint" @index)}}
341
425
  {{else}}
342
426
  <p class="text-base-content/60 mb-0">No certificate is stored for this name yet.</p>
343
427
  {{/if}}
@@ -345,6 +429,19 @@ badgeVariant=pageLabel.type class="mb-1"}}
345
429
  {{/ui/modal}}
346
430
  {{/each}}
347
431
 
432
+ {{#each catalog}}
433
+ {{#> ui/modal id=(concat "catalogDetails" @index) title=this.label}}
434
+ <div class="modal-body">
435
+ {{#if this.certificate}}
436
+ {{> certificateDetails this.certificate fingerprintId=(concat "catalogFingerprint" @index)}}
437
+ {{else}}
438
+ <p class="text-base-content/60 mb-0">Not generated yet. It is generated for every configured name the first time a
439
+ listener needs it, or from its row menu.</p>
440
+ {{/if}}
441
+ </div>
442
+ {{/ui/modal}}
443
+ {{/each}}
444
+
348
445
  {{#> ui/delete-modal id="removeHostname" noun="hostname" action="/admin/config/tls/hostnames/delete" fieldName="hostname"}}
349
446
  Stop serving a certificate for <strong class="delete-target-name"></strong>? An already issued certificate is kept and
350
447
  used again if the name is added back.
@@ -353,12 +450,14 @@ used again if the name is added back.
353
450
  {{#> ui/confirm-modal id="removeIssued" title="Remove issued certificate" action="/admin/config/tls/delete"
354
451
  fieldName="certificate" fieldClass="delete-target-id" submitLabel="Remove certificate"}}
355
452
  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.
453
+ self-signed certificate until a new one is ordered. A listener set to present this certificate presents its automatic
454
+ choice until it is set to another.
357
455
  {{/ui/confirm-modal}}
358
456
 
359
457
  {{#> ui/confirm-modal id="removeUploaded" title="Remove uploaded certificate" action="/admin/config/tls/delete"
360
458
  fieldName="certificate" fieldValue="manual" submitLabel="Remove certificate"}}
361
- Remove the uploaded certificate? Every name it covers falls back to whatever the selected source provides.
459
+ Remove the uploaded certificate? Every name it covers falls back to whatever the selected source provides. A listener
460
+ set to present it presents its automatic choice until it is set to another.
362
461
  {{/ui/confirm-modal}}
363
462
 
364
463
  {{#> ui/confirm-modal id="regenerateSelfSigned" title="Self-signed certificate" action="/admin/config/tls/delete"
@@ -372,7 +471,7 @@ Generate a self-signed certificate for every configured name now, instead of the
372
471
  {{/if}}
373
472
  {{/ui/confirm-modal}}
374
473
 
375
- <script nonce="{{cspNonce}}">
474
+ <script data-cfasync="false" nonce="{{cspNonce}}">
376
475
  document.addEventListener('DOMContentLoaded', () => {
377
476
 
378
477
  // The one line under a hostname row. Every message about a name lands here, so a name