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
+63 -3
View File
@@ -210,17 +210,77 @@ export type { SearchResult } from './modules/content/index.js'
export { mailAttachmentLimit } from './modules/email/attachmentLimit.js'
export { graphAdapter } from './modules/email/graphAdapter.js'
export type { GraphAdapterArgs } from './modules/email/graphAdapter.js'
export { mailAdapter } from './modules/email/mailAdapter.js'
export type { MailAdapterArgs } from './modules/email/mailAdapter.js'
export { GRAPH_DEPRECATION_NOTICE, mailAdapter, resolveMailTransport } from './modules/email/mailAdapter.js'
export type { MailAdapterArgs, MailTransport } from './modules/email/mailAdapter.js'
// Imported straight from the file, NOT from ./modules/email/index.js — that
// barrel re-exports sendEmail, which imports 'server-only' and would crash when
// Payload loads the config (or runs generate:importmap) as a plain Node script.
export { panelSmtpAdapter } from './modules/email/panelSmtpAdapter.js'
export type { PanelSmtpAdapterArgs } from './modules/email/panelSmtpAdapter.js'
// The Intecion Notifications Webservice (docs/email.md): the transport of a site with no SMTP server.
// Every piece is exported, so a project can use the transport alone, enrol from a script, mark its own
// mail, build its own panel, or test against the fake service.
export { createFakeRelay } from './modules/email/relay/fake.js'
export type { FakeRelay, FakeRelayLimits, FakeRelayMail, FakeRelayOptions } from './modules/email/relay/fake.js'
export {
bareAddress,
bareAddresses,
buildRelayMessage,
cleanSubject,
disconnectRelay,
enrolRelay,
getRelayStatus,
isPublicHost,
MAIL_KIND,
MAIL_KINDS,
mailKindOf,
markNextMail,
RELAY_BASE_URL,
RELAY_CONFIRM_PATH,
RELAY_CONTRACT_VERSION,
RELAY_DEFAULTS,
RELAY_KV_KEY,
RELAY_PRODUCT,
RELAY_SENDER_ADDRESS,
RELAY_SERVICE_NAME,
RELAY_STATUS_CODES,
relayAdapter,
relayAttachmentLimit,
relayConfirmEndpoint,
relayHost,
relayRequest,
relaySenderName,
relayStatusFor,
resolveRelayOptions,
rotateRelayToken,
runWithMailKind,
sendThroughRelay,
setRelayToken,
withMailKind,
} from './modules/email/relay/index.js'
export type {
BuildRelayMessageArgs,
BuiltRelayMessage,
EnrolResult,
MailKind,
RelayAdapterArgs,
RelayAnswer,
RelayCall,
RelayOptions,
RelayRefusal,
RelaySendContext,
RelaySendRequest,
RelaySendResult,
RelayStatus,
RelayStatusCode,
} from './modules/email/relay/index.js'
export { mailPanelState, relayPanelEndpoints } from './modules/email/relay/panel.js'
export type { MailPanelState } from './modules/email/relay/panel.js'
// Boot-time environment validation (fail fast on misconfigured deploys).
export { assertEnv, checkDatabaseName, databaseNameFromUri, databaseNamesFor, iaplEnvRules, ipalEnvRules, legacyEnvName, readEnv } from './modules/env/index.js'
export type { AssertEnvOptions, EnvKind, EnvRule, IaplEnvFeatures, IpalEnvFeatures } from './modules/env/index.js'
export type { FormAttachmentsOption, FormFileScanInput, FormFileScanResult, FormSubmitEndpointOptions } from './modules/forms/attachments/config.js'
export { buildFormMailKindHook } from './modules/forms/attachments/delivery.js'
export { buildFileBlock, fileBlock } from './modules/forms/attachments/fileBlock.js'
export { FORM_FILE_TYPES, formatFileSize, RISKY_FILE_EXTENSIONS } from './modules/forms/attachments/fileTypes.js'
export type { FormFileDetect, FormFileType } from './modules/forms/attachments/fileTypes.js'
@@ -468,4 +528,4 @@ export type { IaplTokenName, IpalTokenName, TokensInput } from './modules/tokens
export { getTurnstileConfig, TURNSTILE_SECRET_ENV, turnstileSecretFromEnv } from './modules/turnstile/config.js'
export type { TurnstileConfig } from './modules/turnstile/config.js'
export { iapl, ipalKit } from './plugin.js'
export type { IaplOptions, IpalOptions, ThemeOptions } from './types.js'
export type { IaplOptions, IpalOptions, MailOptions, ThemeOptions } from './types.js'