From 2cceceffd0a4ad819ee93df5163a76d54b3b8f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Wed, 25 Nov 2026 21:14:47 +0100 Subject: [PATCH] Mail relay: state block without an import-map entry, e2e on the reference site, sharper failure reports - the state block is rendered by IntegrationStatusBanner (no new admin component: generate:importmap gives no diff) - reference site: e2e/mail-relay.spec.ts with a fixture and setup script; e2e:built runs it with both bundlers - a failed enrolment is reported as what it was; the service's own refusal after a fresh enrolment - a message keeps its key after any failure that is not final - a local site is shown as refused in the panel before any e-mail Co-Authored-By: Claude Fable 5.2 --- docs/CHANGELOG.md | 10 +- docs/agent/AGENT.md | 4 +- docs/agent/skills/iapl-debug/SKILL.md | 1 - docs/agent/skills/iapl-upgrade/SKILL.md | 11 +- docs/dev/PROGRAMISTA.md | 2 +- docs/email.md | 4 +- docs/integrations.md | 2 +- reference/.agents/skills/iapl-debug/SKILL.md | 18 +- reference/.agents/skills/iapl-doctor/SKILL.md | 4 + reference/.agents/skills/iapl-form/SKILL.md | 2 + reference/.agents/skills/iapl-setup/SKILL.md | 27 +- .../.agents/skills/iapl-upgrade/SKILL.md | 28 + reference/.env.example | 2 + reference/e2e/mail-relay-fixture.ts | 10 + reference/e2e/mail-relay-setup.ts | 26 + reference/e2e/mail-relay.spec.ts | 92 ++ reference/playwright.config.ts | 4 +- reference/src/payload-types.ts | 1133 ++++++++++++++++- reference/src/payload.config.ts | 5 +- scripts/e2e-built.mjs | 5 +- .../components/MailRelayStatus.tsx | 3 +- src/globals/SiteIntegrations/fields/smtp.ts | 11 +- src/modules/email/relay/panel.ts | 10 +- src/modules/email/relay/send.ts | 16 +- src/modules/email/relay/session.ts | 14 +- .../integrations/IntegrationStatusBanner.tsx | 15 +- src/modules/integrations/status.ts | 7 +- test/mailRelay.test.ts | 54 + test/mailRelayHttp.test.ts | 6 +- 29 files changed, 1461 insertions(+), 65 deletions(-) create mode 100644 reference/e2e/mail-relay-fixture.ts create mode 100644 reference/e2e/mail-relay-setup.ts create mode 100644 reference/e2e/mail-relay.spec.ts diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2e96d2c..86b6edd 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,7 +13,7 @@ once there are more than 20. > **Read before upgrading.** Nothing has to change in a project. The plugin's name is now **IAPL** (Intecion > Advanced Payload Library); it was ipal-kit. **The package is still `@intecion/ipal-kit`**, and every name a -> project uses keeps working. The rename changes no option, schema, migration or import map. This release also carries the +> project uses keeps working. No schema, migration or import-map change. This release also carries the > security follow-ups listed under 1.16.8 below (prepared, not released on their own). > > **E-mail — read which of three cases the site is.** A site with **no SMTP server in Site integrations and no @@ -22,14 +22,14 @@ once there are more than 20. > host and the plugin version, receives its own token through a new public route, and sends from > `notification@webservices.intecion.net` under the panel's "Sender name". **A site with SMTP filled in is not > affected and contacts nothing. A site on Microsoft Graph keeps working and prints one deprecation warning at -> start.** Each new behaviour has its opt-out (table below). No schema change, no migration; one import-map entry. +> start.** Each new behaviour has its opt-out (table below). > **The service must be live for the first case: until Intecion announces it, such a site reports > `relay-unreachable` and sends nothing, as it sent nothing before.** ### Requires project changes -- **Every site: `pnpm payload generate:importmap`, commit.** The e-mail tab of Site integrations has a new block - ("How e-mails are sent", component `@intecion/ipal-kit/admin#MailRelayStatus`); with a stale import map the block is - blank. Nothing else changes in the panel's data: no field was added, "Sending method" keeps its two stored values. +- **Nothing has to be run.** The e-mail tab of Site integrations has a new block ("How e-mails are sent"); it is + rendered by the status banner already in every import map, so `generate:importmap` gives no diff. No field was + added; "Sending method" keeps its two stored values. - **What changes for an existing site on upgrade — e-mail:** | Site today | After the upgrade | Opt-out | diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index 4e1be59..8b0d8bc 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -1262,8 +1262,8 @@ export default buildConfig({ }) ``` -Then `pnpm generate:importmap` (the e-mail tab has a new component, `@intecion/ipal-kit/admin#MailRelayStatus`). -No env variable, no key, no field to fill in. **Do not** add `nodemailer`, `resend`, an `api/send` route or a +No env variable, no key, no field to fill in, no import-map change (the tab's state block rides on the status +banner that is already in every import map). **Do not** add `nodemailer`, `resend`, an `api/send` route or a `GRAPH_*` variable to a project. **How a send is routed** (`resolveMailTransport`, type `MailTransport`): Microsoft Graph when the panel says so and diff --git a/docs/agent/skills/iapl-debug/SKILL.md b/docs/agent/skills/iapl-debug/SKILL.md index 8f906d3..012d10c 100644 --- a/docs/agent/skills/iapl-debug/SKILL.md +++ b/docs/agent/skills/iapl-debug/SKILL.md @@ -114,7 +114,6 @@ through this procedure. Ask only when you are missing something you cannot get y | replies to the site's mail are lost | "Sender address" is empty: the service's own address has no mailbox | fill it in (doctor: `mail-reply-address`) | | the site enrols again and again (`reverify` in the log) | requests leave from many changing addresses (serverless, a pool of egress addresses) | Intecion raises the site's limit of server addresses, or SMTP | | start log: "Microsoft Graph as the e-mail transport is deprecated" | `GRAPH_*` is set | email.md "Moving off Microsoft Graph"; silence only: `mail: { graphDeprecationWarning: false }` | -| the e-mail tab shows a blank where "How e-mails are sent" should be | stale import map | `pnpm payload generate:importmap`, commit, redeploy | | old email sender | mail client cache | check the raw headers | | form: `unknown_fields` | field outside the definition (honeypot not removed) | `iapl-form` → actions.ts | | an account logs in to `/admin` and sees "Unauthorized" (its API calls still work) | `accounts.panelRole`: the panel opens for `editor` and above; the account has only `user`, or no role | give it `editor` (an admin edits the account), or `accounts: { panelRole: 'user' }`; nobody can get in: a script with the Local API sets `roles: ['admin']`, or `accounts: { panelRole: false }` + redeploy | diff --git a/docs/agent/skills/iapl-upgrade/SKILL.md b/docs/agent/skills/iapl-upgrade/SKILL.md index af0ab7e..ff4ff6a 100644 --- a/docs/agent/skills/iapl-upgrade/SKILL.md +++ b/docs/agent/skills/iapl-upgrade/SKILL.md @@ -535,8 +535,8 @@ Every name from before keeps working: `ipalKit()` and the other old exports, the `ipal-doctor.json`, `ipal-audit-skip`, the old pointer block. The package is still `@intecion/ipal-kit`; routes `/api/ipal/*`, `--ipal-*` tokens, `data-ipal` hooks and the cookie `ipal_vid` are unchanged (AGENT.md "Names: IAPL and ipal-kit"). **Do not rename anything in the project unless the owner asks.** -1. Update the package, `pnpm install`. The rename itself changes no option, schema, migration or import map; the mail - service of the same release adds one admin component — see the next block. +1. Update the package, `pnpm install`. No option, schema, migration or import-map change (`pnpm payload generate:importmap` + gives no diff). 2. Refresh the skills: `pnpm exec iapl-skills` (the project's `ipal:skills` script, where it has one, runs the same program). It installs `iapl-*`, removes the 16 old `ipal-*` folders by name (a skill of the project's own named `ipal-…` stays), and rewrites the pointer block in `AGENTS.md` in place. Commit the result. Old skill names written by hand in @@ -553,10 +553,9 @@ ipal-kit"). **Do not rename anything in the project unless the owner asks.** builds; the panel opens; the old commands (`pnpm exec ipal-doctor`) still run. **→ 1.17.0, e-mail (the Intecion mail service is the default transport; Microsoft Graph deprecated; CHANGELOG 1.17.0; -PROGRAMISTA §6, item 73; email.md; AGENT.md §7.2) — one command for every site, then read which case the site is:** -1. **Every site:** `pnpm payload generate:importmap` and commit — the e-mail tab has a new component - (`@intecion/ipal-kit/admin#MailRelayStatus`); with a stale map the block "How e-mails are sent" is blank. No schema - change, no migration. +PROGRAMISTA §6, item 73; email.md; AGENT.md §7.2) — nothing to run; read which case the site is:** +1. **Every site:** no schema change, no migration, no import-map change. The e-mail tab gains the block "How e-mails + are sent" and new wording ("Automatic", "Own SMTP server"). 2. **Which case** — Site integrations → E-mail sending, and the Coolify env: - **SMTP filled in** (server, user name, password): nothing changes, the site contacts nobody. Done. - **`GRAPH_*` set:** mail as before; one deprecation warning per start, doctor warning `mail-graph-deprecated`. diff --git a/docs/dev/PROGRAMISTA.md b/docs/dev/PROGRAMISTA.md index 0e3574c..02b238b 100644 --- a/docs/dev/PROGRAMISTA.md +++ b/docs/dev/PROGRAMISTA.md @@ -680,7 +680,7 @@ Do one item at a time, build, check. Order by importance: | 70 | **1.16.7** — `next build --webpack`: `'server-only' cannot be imported from a Client Component module`, from a `'use client'` file that imports `isAdmin`, `isEditor` or `hasMinimumRole` | Import them from `@intecion/ipal-kit/client` in client components, keep the second argument (`isAdmin(user, config)`); `import type` may stay on the main entry | CHANGELOG 1.16.7, access.md | | 71 | **1.16.8 — security** — a site built with Turbopack (`next build` without `--webpack`) serves `/_next/static/media/package..json`; or the project has a staff collection of its own without access rules; or a plugin listed after iapl copies a staff collection or sets `admin.user`; or the start log says `No staff account holds the role "admin", so NOBODY can …` | Update, `pnpm exec iapl-skills`, `rm -rf .next`, rebuild; no option, schema, migration or import map. Turbopack: `find .next/static -name 'package*.json'` empty, purge a CDN. Own staff collection: a `roles` list that can hold `editor` / `admin` → only an admin manages its accounts (write own rules otherwise; one account must hold `admin`); a single select with only `user` / `editor` / `admin` → its accounts manage each other again (own rules if your code goes by the value). A copy: `access.update: adminOrSelfIn('copy')`, or `custom.ipal.accountRules: false` | CHANGELOG 1.16.8, access.md "Account rules" | | 72 | **1.17.0 — the plugin is called IAPL** — you see `iapl()`, `iapl-doctor`, `IAPL_IP_HEADER`, `iapl-doctor.json`, `[iapl]` in docs and logs and wonder whether the project must change | No. Every old name works through 1.x (`ipalKit`, `ipal-*` commands, `IPAL_*` env, `ipal-doctor.json`, `ipal-audit-skip`, the old pointer block); the package is still `@intecion/ipal-kit`. Run `pnpm exec iapl-skills` (or the project's `ipal:skills` script) and commit; change a log filter on `[ipal]` to `[iapl]`. Rename the rest only when the owner asks (`iapl-upgrade` "→ 1.17.0", AGENT.md "Names: IAPL and ipal-kit"). Never set `storageNames: 'iapl'` on an existing site | -| 73 | **1.17.0 — e-mail: the Intecion mail service is the default transport** — a site with no SMTP server in the panel and no `GRAPH_*` starts sending through the service after the upgrade (an outbound call with its host; a new public route `POST /api/iapl/mail-relay/confirm`; mail from `notification@webservices.intecion.net`); the e-mail tab is blank where "How e-mails are sent" should be; a Graph site warns at start | `pnpm payload generate:importmap` and commit (new component `MailRelayStatus`). SMTP site: nothing else. Graph site: nothing now — deprecated, move when the owner says. Site with neither: agree it with the owner; `serverURL` = the public address, "Sender address" filled in, the host listed by Intecion; or `iapl({ mail: { relay: false } })` to keep the old behaviour | `iapl-upgrade` "→ 1.17.0, e-mail", AGENT.md §7.2, email.md | +| 73 | **1.17.0 — e-mail: the Intecion mail service is the default transport** — a site with no SMTP server in the panel and no `GRAPH_*` starts sending through the service after the upgrade (an outbound call with its host; a new public route `POST /api/iapl/mail-relay/confirm`; mail from `notification@webservices.intecion.net`); a Graph site warns at start | Nothing to run (no schema, migration or import-map change). SMTP site: nothing. Graph site: nothing now — deprecated, move when the owner says. Site with neither: agree it with the owner; `serverURL` = the public address, "Sender address" filled in, the host listed by Intecion; or `iapl({ mail: { relay: false } })` to keep the old behaviour | `iapl-upgrade` "→ 1.17.0, e-mail", AGENT.md §7.2, email.md | After updating the package: `pnpm exec iapl-skills` (new skill versions), `pnpm payload generate:importmap`, `rm -rf .next`, restart dev, grep for the new symbol in `node_modules/@intecion/ipal-kit/dist`. diff --git a/docs/email.md b/docs/email.md index 7f9f708..4f3a5cb 100644 --- a/docs/email.md +++ b/docs/email.md @@ -193,8 +193,8 @@ await runWithMailKind('account', () => sendWelcomeMails(payload, user)) ### The state block in the panel -Site integrations → E-mail sending starts with "How e-mails are sent" (component `MailRelayStatus`, import-map -entry `@intecion/ipal-kit/admin#MailRelayStatus` — **run `payload generate:importmap` after upgrading**): the +Site integrations → E-mail sending starts with "How e-mails are sent" (component `MailRelayStatus` from `/admin`, +rendered by the tab's status banner — **no import-map entry of its own, so nothing to regenerate**): the transport in effect; for the mail service the state (connected, waiting for approval, stopped, not connected and why), the address mail leaves from, where replies go, what is left of the hour and the day, and a sender name the service replaced. Buttons: **Check now**, **Connect again**, **Disconnect**, **Enter an access key**. diff --git a/docs/integrations.md b/docs/integrations.md index 3c7c969..88670cb 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -14,7 +14,7 @@ Currently always added by the plugin. Tabs (unnamed — flat data, e.g. `ga4Meas |---|---| | Analytics | `ga4MeasurementId`, `gtmContainerId`, `metaPixelId`, `clarityProjectId`, `linkedInPartnerId`, `tiktokPixelId` | | Spam protection | `turnstileSiteKey`, `turnstileSecretKey`, hidden `turnstileStatus` + banner | -| E-mail sending | the state block "How e-mails are sent" (`mailRelayStatus`, a `ui` field — nothing stored; absent with `mail: { relay: false }`), `emailTransport` (`smtp` = "Automatic" / `graph` = deprecated), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner | +| E-mail sending | the state block "How e-mails are sent" (part of the tab's status banner — nothing stored; absent with `mail: { relay: false }`), `emailTransport` (`smtp` = "Automatic" / `graph` = deprecated), `smtpHost`, `smtpPort`, `smtpUser`, `smtpPassword`, `smtpFromAddress`, `smtpFromName`, test button, hidden `emailStatus` + banner | | IndexNow | `indexNowKey` (generated on first save) | | More | fields from the `integrationsFields` option — only when given | diff --git a/reference/.agents/skills/iapl-debug/SKILL.md b/reference/.agents/skills/iapl-debug/SKILL.md index 3c97619..012d10c 100644 --- a/reference/.agents/skills/iapl-debug/SKILL.md +++ b/reference/.agents/skills/iapl-debug/SKILL.md @@ -97,7 +97,23 @@ through this procedure. Ask only when you are missing something you cannot get y |---|---|---| | pixel before consent (consent-check) | script wired by hand (`