Mail relay: the built-in client for the Intecion Notifications Webservice

Transport, enrolment with the confirm route, token and state in payload-kv, rotation,
the panel's state block, doctor rules, the fake service and the copied contract 1.5.0.
Tests against the contract's runner and the fake. Docs and HTTP tests follow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 20:29:46 +01:00
co-authored by Claude Fable 5.2
parent 9efd86a06f
commit ea9703f8e3
97 changed files with 7720 additions and 48 deletions
+23
View File
@@ -31,6 +31,10 @@ import { mergeCookieScanLabels } from './modules/consent/scanner/labels.js'
import { buildConstructionFields } from './modules/construction/fields.js'
import { buildArchiveFields } from './modules/content/index.js'
import { buildDoctorEndpoint } from './modules/doctor/status.js'
import { GRAPH_DEPRECATION_NOTICE, graphAvailable } from './modules/email/mailAdapter.js'
import { withAccountMailMark } from './modules/email/relay/accountMail.js'
import { relayConfirmEndpoint } from './modules/email/relay/confirm.js'
import { relayPanelEndpoints } from './modules/email/relay/panel.js'
import { testEmailEndpoint } from './modules/email/test/testEmailEndpoint.js'
import { emailSettingsFields } from './modules/forms/emailLayout.js'
import { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'
@@ -705,6 +709,7 @@ export const iapl = (options: IaplOptions): Plugin => {
}),
buildSiteIntegrations({
additionalFields: options.integrationsFields,
mailRelay: options.mail?.relay !== false,
reenterSecretOnChange: options.secrets?.reenterOnChange !== false,
writeOnlySecrets: options.secrets?.writeOnly !== false,
}),
@@ -743,6 +748,22 @@ export const iapl = (options: IaplOptions): Plugin => {
config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]
// --- e-mail: the Intecion Notifications Webservice (docs/email.md; off with mail: { relay: false }) ---
// What mailAdapter() reads at send time; born under the new name (`custom.iapl`).
const relay = options.mail?.relay
const iaplCustom = (config.custom?.iapl ?? {}) as object
config.custom = {
...config.custom,
iapl: { ...iaplCustom, mail: { ...(options.mail?.graphDeprecationWarning === false ? { graphDeprecationWarning: false } : {}), relay: relay === false ? false : (relay ?? {}) } },
}
if (relay !== false) {
// The public route the service calls a site back at (404 unless this site just started an
// enrolment), and the admin-only routes of the state block on the e-mail tab.
config.endpoints = [...config.endpoints, relayConfirmEndpoint(relay ?? {}), ...relayPanelEndpoints()]
// "Forgot password" and "verify your e-mail" are Payload's own mail: say what they are.
config.collections = (config.collections ?? []).map((c) => (c.auth ? withAccountMailMark(c) : c))
}
// --- iapl-doctor status (404 until IAPL_DOCTOR_TOKEN is set; docs/doctor.md) ---
if (options.doctor !== false) {
config.endpoints = [...(config.endpoints ?? []), buildDoctorEndpoint(options.doctor ?? {})]
@@ -918,6 +939,8 @@ export const iapl = (options: IaplOptions): Plugin => {
)
}
adoptConfig(payload)
// Microsoft Graph is deprecated (removed in 2.0): one warning per start while its variables are set.
if (graphAvailable() && options.mail?.graphDeprecationWarning !== false) {payload.logger.warn(GRAPH_DEPRECATION_NOTICE)}
// Payload's dev reload swaps `payload.config` and runs no onInit: adopt the new config at once.
watchPayloadConfig(payload, adoptConfig)
if (staleImportMap) {