Dependency advisories: nodemailer 10, overrides for Payload's pinned deps

- nodemailer ^8.0.1 -> ^10.2.1 (advisories up to 10.1.3); drop @types/nodemailer,
  nodemailer 10 ships its own types. Node engines >=20.9.0 (nodemailer 10 needs 20+).
- pnpm.overrides (repo only, not passed to projects) for packages in payload 3.90.2's
  tree: undici and dompurify are exact-pinned upstream; fast-uri, js-yaml,
  browserslist, source-map-js, fast-copy, baseline-browser-mapping raised to fixed
  minimums. pnpm audit --prod: 19 high / 35 moderate / 11 low -> 0.
- Tests: SMTP over a local SMTP socket with real nodemailer (panelSmtpAdapter,
  sendEmail, unreachable server status), Microsoft Graph and Graph->SMTP fallback
  via mailAdapter; real payloadTotp through ipalKit, plus a check that payload-2fa
  resolves the project's payload.
- Docs: email.md, AGENT.md §4 item 12, ipal-setup, ipal-upgrade, README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-27 16:42:05 +01:00
co-authored by Claude Opus 5.5
parent 54fb57b7a9
commit 007a0a3ae6
9 changed files with 372 additions and 74 deletions
+5 -1
View File
@@ -67,6 +67,7 @@ plugin development.
`nodemailer`, `lucide-react`, `slugify` and `server-only` are regular
`dependencies` of the plugin — they install with it; don't add them yourself.
The plugin's `nodemailer` 10 needs **Node.js 20 or later**.
What you provide are the **peer dependencies** — packages the plugin shares with
your project — in a version matching your Payload:
@@ -86,7 +87,10 @@ pnpm add @payloadcms/[email protected] # only with R2 media
```
Keep every `@payloadcms/*` at exactly the same version as `payload`
(`pnpm.overrides` — see PROGRAMISTA.md §1). Upload optimization and image
(`pnpm.overrides` — see PROGRAMISTA.md §1). Then run `pnpm audit --prod`: with
`payload` 3.90.x, Payload's own tree pins a vulnerable `undici` and `dompurify` —
add the two overrides from [AGENT.md §4 item 12](./docs/agent/AGENT.md) (recommended, not
required by the plugin). Upload optimization and image
placeholders also use the `sharp` you pass to `buildConfig({ sharp })`
(standard in a `create-payload-app` project).
+14
View File
@@ -416,6 +416,20 @@ No abbreviations (`HeroSection`, not `HeroSec`). Do not create `lib/pages.ts`,
15.x line. Pin `next` and `eslint-config-next` to the same 16.4.x (≥ 16.4.1) and make sure `sharp` resolves to
0.35.5 or later (`pnpm why sharp`). The plugin's peer range stays open (`next >=15`) — the minimum is yours to keep.
**Check:** `pnpm ls next sharp` → next ≥ 16.4.1, sharp ≥ 0.35.5; `pnpm dev` prints no security-upgrade warning.
12. **No open production advisories.** Node.js 20 or later (the plugin's `nodemailer` 10 requires it). Run
`pnpm audit --prod`. The plugin's own dependencies are clean; what remains comes from Payload's tree, which only
the project's lockfile can fix. With `payload` 3.90.x two packages are pinned exactly and need `pnpm.overrides`
next to the `@payloadcms/*` ones:
```json
"dompurify@<3.4.17": "^3.4.17",
"undici@>=7 <7.30.1": "^7.30.1"
```
`undici` comes from `payload` (3.92.1 and later already ship 7.30.1), `dompurify` from the admin code editor
(`@payloadcms/ui` → `monaco-editor`, which pins 3.2.7). Everything else in the report (`fast-uri`, `js-yaml`,
`browserslist`, `source-map-js`, `fast-copy`, `baseline-browser-mapping`) is a range: `pnpm update` or a fresh
lockfile picks up the fix; add an override like the ones above only if it does not. These are recommendations —
the plugin forces none of them. Never add a project dependency on `nodemailer` or `@types/nodemailer`.
**Check:** `pnpm audit --prod` → no high or critical; `pnpm why undici dompurify` → only the fixed versions.
---
+2
View File
@@ -41,6 +41,8 @@ pnpm add @intecion/ipal-kit @payloadcms/plugin-seo @payloadcms/plugin-form-build
```
**Next.js 16.4.1 or later** (minimum safe version: 16.0.0–16.4.0 have critical advisories, AGENT.md §4 item 11):
`pnpm add next@^16.4.1 eslint-config-next@^16.4.1 sharp@^0.35.5` when create-payload-app gave you an older one.
**Node.js 20 or later** (the plugin's `nodemailer` 10 requires it). After the install, `pnpm audit --prod` → no high or
critical; with `payload` 3.90.x add the `dompurify` and `undici` overrides from AGENT.md §4 item 12.
`nodemailer`, `lucide-react`, `slugify`, `server-only` come with the plugin — do not add them (your own
`lucide-react` only `~0.400.0`). In `package.json`: pin every `@payloadcms/*` (ui, next, db-*, richtext-lexical,
plugin-seo, plugin-form-builder, storage-s3) in `pnpm.overrides` **to the exact `payload` version**, then
+9
View File
@@ -86,12 +86,21 @@ the banner → `<CookieBanner settings="detailed">` and remove the copy. With `d
`pnpm add next@^16.4.1 eslint-config-next@^16.4.1 sharp@^0.35.5`, `rm -rf .next`, build, redeploy on Coolify
(a new image ships the fixed next and sharp). **Check:** `pnpm dev` prints no security-upgrade warning.
**Every upgrade — dependency advisories** (AGENT.md §4 item 12): `pnpm audit --prod`; with `payload` 3.90.x add the
`dompurify` and `undici` overrides, `pnpm install`, audit again. **Check:** no high or critical.
**→ after 1.13.0 (admin follow-ups):** `pnpm payload generate:importmap` — new panel component
`@intecion/ipal-kit/admin#FaviconCheck` (hint under Site settings → Site icon). **Check:** pick a 32×32 PNG as the
site icon → a warning appears under the field; saving still works. Nothing else to change: the statistics tab title,
the cookie scanner's integration names and the maintenance notice's close button now follow the language by themselves
(`<ConstructionNotice mode={await getConstructionMode(locale)} />` already passes it).
**→ after 1.13.0 (dependency advisories):** the plugin now brings `nodemailer` 10 (was 8), which needs **Node.js 20 or
later** — check the Coolify build image and `.nvmrc` / `engines`. Remove `nodemailer` and `@types/nodemailer` from the
project's own `package.json` if someone added them (the plugin's copy is the one `mailAdapter` uses). Then the audit step
above. **Check:** Site integrations → E-mail sending → send a test e-mail over SMTP (and over Microsoft Graph when the
project uses it); `pnpm audit --prod` → no high or critical.
## 2. Inventory (no code changes)
For **every** item in the PROGRAMISTA §6 table show evidence (grep / file) of whether
it applies to the project. Run the **ipal-audit** skill (`--quick`) and attach the result.
+9 -2
View File
@@ -10,8 +10,15 @@ and the editor picks the transport in the panel. A separate `sendEmail` helper (
## Dependency
`nodemailer` (`^8`) is already in the plugin's `dependencies` — the project does not need to
install it. Graph is plain `fetch`, no extra packages.
`nodemailer` (`^10.2.1`) is already in the plugin's `dependencies` — the project does not need to
install it (nodemailer 10 ships its own types, so `@types/nodemailer` is not needed either). Graph is plain
`fetch`, no extra packages.
- **Node.js 20 or later** — nodemailer 10 requires it (the Coolify images run Node 22).
- **Why `^10.2.1`:** every nodemailer up to 10.1.3 has open advisories (address parser ReDoS, recipient-domain
bypass, `raw`/`resolveContent` file access). Do not pin an older nodemailer in the project.
- **Since nodemailer 9**, attachments given as an `href`/`path` URL are fetched with TLS certificate validation.
A mail with an attachment from a host with a self-signed certificate now fails instead of sending.
## Config
+13 -4
View File
@@ -90,7 +90,7 @@
},
"dependencies": {
"lucide-react": "^0.400.0",
"nodemailer": "^8.0.1",
"nodemailer": "^10.2.1",
"server-only": "^0.0.1",
"slugify": "^1.6.6"
},
@@ -120,7 +120,6 @@
"@swc-node/register": "1.10.9",
"@swc/cli": "0.6.0",
"@types/node": "22.20.5",
"@types/nodemailer": "^8.0.1",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"copyfiles": "2.4.1",
@@ -143,7 +142,7 @@
"vitest": "5.0.4"
},
"engines": {
"node": "^18.20.2 || >=20.9.0",
"node": ">=20.9.0",
"pnpm": "^9 || ^10 || ^11"
},
"publishConfig": {
@@ -154,7 +153,17 @@
"sharp",
"esbuild",
"unrs-resolver"
]
],
"overrides": {
"baseline-browser-mapping@<2.11.0": "^2.11.0",
"browserslist@<4.28.7": "^4.28.7",
"dompurify@<3.4.17": "^3.4.17",
"fast-copy@<3.1.0": "^3.1.0",
"fast-uri@<3.1.9": "^3.1.9",
"js-yaml@>=4 <4.3.2": "^4.3.2",
"source-map-js@<1.2.2": "^1.2.2",
"undici@>=7 <7.30.1": "^7.30.1"
}
},
"peerDependenciesMeta": {
"@clocklimited/payload-2fa": {
+72 -67
View File
@@ -4,6 +4,16 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
overrides:
baseline-browser-mapping@<2.11.0: ^2.11.0
browserslist@<4.28.7: ^4.28.7
dompurify@<3.4.17: ^3.4.17
fast-copy@<3.1.0: ^3.1.0
fast-uri@<3.1.9: ^3.1.9
js-yaml@>=4 <4.3.2: ^4.3.2
source-map-js@<1.2.2: ^1.2.2
undici@>=7 <7.30.1: ^7.30.1
importers:
.:
@@ -18,8 +28,8 @@ importers:
specifier: ^0.400.0
version: 0.400.0([email protected])
nodemailer:
specifier: ^8.0.1
version: 8.0.11
specifier: ^10.2.1
version: 10.2.1
server-only:
specifier: ^0.0.1
version: 0.0.1
@@ -66,9 +76,6 @@ importers:
'@types/node':
specifier: 22.20.5
version: 22.20.5
'@types/nodemailer':
specifier: ^8.0.1
version: 8.0.1
'@types/react':
specifier: ^19.2.14
version: 19.2.14
@@ -2119,9 +2126,6 @@ packages:
'@types/[email protected]':
resolution: {integrity: sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==}
'@types/[email protected]':
resolution: {integrity: sha512-PxpaInm8V1JQDd4j0ds5HfvWQk8JupS1C0Picb96QJsrrRDjBH+DlK7L4ZdNSqNULhiZRQHc40nLVShaGxXAMw==}
'@types/[email protected]':
resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==}
@@ -2587,8 +2591,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
[email protected]0.42:
resolution: {integrity: sha512-c/jurFrDLyui7o1J86yLkRu4LMsTYcBohveus7/I2Hzdn9KIP2bdJPTue/lR1KH46enoPbD77GKeSYNdyPoD3Q==}
[email protected]1.33:
resolution: {integrity: sha512-yiVKDX+qCMRKBE084lXvq9EcwFUhKZ2nU8TK1EQQuOgPNR/lmbGxXOeDdlGUqC2Zz11Cs9rk1d/8NfgBmlkt0w==}
engines: {node: '>=6.0.0'}
hasBin: true
@@ -2627,8 +2631,8 @@ packages:
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
engines: {node: '>=8'}
[email protected]8.5:
resolution: {integrity: sha512-Cu2E6QejHWzuDMTkuwgpABFgDfZrXLQq5V13YOACZx4mFAG4IwGTbTfHPMr4WtxlHoXSM8FIuRwYYCz5XiabaQ==}
[email protected]9.5:
resolution: {integrity: sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==}
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
@@ -2690,6 +2694,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-g/uHREV2ZpK9qMalCsWaxmA6ol+DX8GYhuf3T40RKoP+oL7vhRJh8LNt73PCjpnR6l14FzfPrB5Yux4PKm2meg==}
[email protected]:
resolution: {integrity: sha512-LFUqIIAwpzsIuevnKnsR9qnStBcgzPShTX61lBwN9uFkkf8o8zLiebEjbW8AYtZiF+1YKDWfdt/pWDtMuG8Xwg==}
[email protected]:
resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}
@@ -2952,8 +2959,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==}
dompurify@3.2.7:
resolution: {integrity: sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==}
dompurify@3.4.17:
resolution: {integrity: sha512-B/pSlYVHQ58kqISD/yDjuJ1yfzI34m1gF4lAod2bwSRhiN4K5Cl3H8Af7hqB2PmTL911tdEudnnXn5FnhRoz0w==}
[email protected]:
resolution: {integrity: sha512-hOzRGSdyKIU4FcTSFYGKdXEjFsncVwHZ43gY3WU5Bz9j5Iadp6Rh6hxLSQ1IWXpKLBKt/d5y1cpSPcV+FcoQ1A==}
@@ -3058,8 +3065,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
[email protected].389:
resolution: {integrity: sha512-cEto7aeOqBfU1D+c5py5pE+ooscKE75JifxLBdFUZsqAxRS6y7kebtxAZvICszSl05gPjYHDTjY+lXpyGvpJbg==}
[email protected].465:
resolution: {integrity: sha512-zg4iUpbeGw7YNZsswc2xKr2uiBex2d8dELAXo92Icw3but1ULbrvK8USe6wVLaWjgJnKBARv0pchx9Owktx6wQ==}
[email protected]:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
@@ -3446,8 +3453,8 @@ packages:
resolution: {integrity: sha512-yblEwXAbGv1VQDmow7s38W77hzAgJAO50ztBLMcUyUBfxv1HC+LGwtiEN+Co6LtlqT/5uwVOxsD4TNIilWhwdQ==}
engines: {node: '>=4'}
fast-copy@3.0.2:
resolution: {integrity: sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ==}
fast-copy@3.1.0:
resolution: {integrity: sha512-IuCOCDFM1F/s4LtG7Bjr3yUUwPHybyhqN74xk2cMYoP51vVeErMy8+6HGFchi/+45lW8uzhs6lBeEqks2GWt6A==}
[email protected]:
resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}
@@ -3472,8 +3479,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==}
[email protected].3:
resolution: {integrity: sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==}
[email protected].9:
resolution: {integrity: sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==}
[email protected]:
resolution: {integrity: sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw==}
@@ -3998,8 +4005,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
[email protected].0:
resolution: {integrity: sha512-1td788aAnnZ5qs7V2QIRl1owjtYpbKt749Y3xauqQgwIIGF/xXWz1wMTEBx5O3LK3lXLVuqXPdPxj2BoFHaW9Q==}
[email protected].2:
resolution: {integrity: sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==}
hasBin: true
[email protected]:
@@ -4365,13 +4372,13 @@ packages:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
[email protected].50:
resolution: {integrity: sha512-J6l92tKHX6w8Jy5nO1Vuc01NoIiRGi/d6qBKVxh+IQ8Cr3b6HbVNfKiF8ZpFKufTwpwxMmce2W3iQZ861ZRyTg==}
[email protected].60:
resolution: {integrity: sha512-OmO8+GM1JUZqXET720VrJCwkjUCXmCMQm0Z3UDDRbfNLHS4NEAvY60j5jiFv0tkKw2PNNlqOLhahVmwJIOLDIQ==}
engines: {node: '>=18'}
nodemailer@8.0.11:
resolution: {integrity: sha512-nrO/pDAUKl+wXX+lx16tDLbnm0fW6sK/x8mgohaCpg+CdCEl482bD4tCuAZk2DyliruiNTIZxRCoWkDqJEnAiA==}
engines: {node: '>=6.0.0'}
nodemailer@10.2.1:
resolution: {integrity: sha512-ZrDNsPFoDMwefNs7sJwrYiEJ/CG4ClJWDZv05iNJsEBWa8GRDry1QJHTJxsuTAY9eDDKjX4k+q3SxslXJOao7w==}
engines: {node: '>=20.0.0'}
[email protected]:
resolution: {integrity: sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow==}
@@ -4992,8 +4999,8 @@ packages:
resolution: {integrity: sha512-9x9+o8krTT2saA9liI4BljNjwAbvUnWf11Wq+i/iZt8nl2UGYnf3TH5uBydE7VALmP7AGwlfszuEeL8BDyb0YA==}
hasBin: true
[email protected].1:
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
[email protected].2:
resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==}
engines: {node: '>=0.10.0'}
[email protected]:
@@ -5285,8 +5292,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
undici@7.29.0:
resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==}
undici@7.30.1:
resolution: {integrity: sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==}
engines: {node: '>=20.18.1'}
[email protected]:
@@ -5311,11 +5318,11 @@ packages:
resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==}
engines: {node: '>=8'}
update-browserslist-db@1.2.3:
resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==}
update-browserslist-db@1.3.4:
resolution: {integrity: sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==}
hasBin: true
peerDependencies:
browserslist: '>= 4.21.0'
browserslist: ^4.28.7
[email protected]:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
@@ -5575,7 +5582,7 @@ snapshots:
dependencies:
'@jsdevtools/ono': 7.1.3
'@types/json-schema': 7.0.15
js-yaml: 4.3.0
js-yaml: 4.3.2
'@aws-sdk/[email protected]':
dependencies:
@@ -5801,7 +5808,7 @@ snapshots:
dependencies:
'@babel/compat-data': 7.29.7
'@babel/helper-validator-option': 7.29.7
browserslist: 4.28.5
browserslist: 4.29.5
lru-cache: 5.1.1
semver: 6.3.1
@@ -6386,7 +6393,7 @@ snapshots:
globals: 14.0.0
ignore: 5.3.2
import-fresh: 3.3.1
js-yaml: 4.3.0
js-yaml: 4.3.2
minimatch: 3.1.5
strip-json-comments: 3.1.1
transitivePeerDependencies:
@@ -7761,10 +7768,6 @@ snapshots:
dependencies:
undici-types: 6.21.0
'@types/[email protected]':
dependencies:
'@types/node': 22.20.5
'@types/[email protected]': {}
'@types/[email protected]':
@@ -8216,7 +8219,7 @@ snapshots:
[email protected]:
dependencies:
fast-deep-equal: 3.1.3
fast-uri: 3.1.3
fast-uri: 3.1.9
json-schema-traverse: 1.0.0
require-from-string: 2.0.2
@@ -8363,7 +8366,7 @@ snapshots:
[email protected]: {}
[email protected]0.42: {}
[email protected]1.33: {}
[email protected]:
dependencies:
@@ -8401,13 +8404,13 @@ snapshots:
dependencies:
fill-range: 7.1.1
[email protected]8.5:
[email protected]9.5:
dependencies:
baseline-browser-mapping: 2.10.42
caniuse-lite: 1.0.30001803
electron-to-chromium: 1.5.389
node-releases: 2.0.50
update-browserslist-db: 1.2.3([email protected]8.5)
baseline-browser-mapping: 2.11.33
caniuse-lite: 1.0.30001819
electron-to-chromium: 1.5.465
node-releases: 2.0.60
update-browserslist-db: 1.3.4([email protected]9.5)
[email protected]: {}
@@ -8472,6 +8475,8 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]: {}
@@ -8701,7 +8706,7 @@ snapshots:
'@babel/runtime': 7.29.7
csstype: 3.2.3
dompurify@3.2.7:
dompurify@3.4.17:
optionalDependencies:
'@types/trusted-types': 2.0.7
@@ -8730,7 +8735,7 @@ snapshots:
dependencies:
safe-buffer: 5.2.1
[email protected].389: {}
[email protected].465: {}
[email protected]: {}
@@ -9477,7 +9482,7 @@ snapshots:
ext-list: 2.2.2
sort-keys-length: 1.0.1
fast-copy@3.0.2: {}
fast-copy@3.1.0: {}
[email protected]: {}
@@ -9505,7 +9510,7 @@ snapshots:
[email protected]: {}
[email protected].3: {}
[email protected].9: {}
[email protected]:
dependencies:
@@ -10033,7 +10038,7 @@ snapshots:
[email protected]: {}
[email protected].0:
[email protected].2:
dependencies:
argparse: 2.0.1
@@ -10051,7 +10056,7 @@ snapshots:
'@types/json-schema': 7.0.15
'@types/lodash': 4.17.24
is-glob: 4.0.3
js-yaml: 4.3.0
js-yaml: 4.3.2
lodash: 4.18.1
minimist: 1.2.8
prettier: 3.9.4
@@ -10465,7 +10470,7 @@ snapshots:
[email protected]:
dependencies:
dompurify: 3.2.7
dompurify: 3.4.17
marked: 14.0.0
[email protected]: {}
@@ -10482,7 +10487,7 @@ snapshots:
dependencies:
'@next/env': 16.4.3
'@swc/helpers': 0.5.23
baseline-browser-mapping: 2.10.42
baseline-browser-mapping: 2.11.33
caniuse-lite: 1.0.30001803
postcss: 8.5.23
react: 19.3.0
@@ -10520,9 +10525,9 @@ snapshots:
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
[email protected].50: {}
[email protected].60: {}
nodemailer@8.0.11: {}
nodemailer@10.2.1: {}
[email protected]:
dependencies:
@@ -10720,7 +10725,7 @@ snapshots:
sax: 1.6.1
ts-essentials: 10.0.3([email protected])
tsx: 4.22.4
undici: 7.29.0
undici: 7.30.1
uuid: 13.0.2
ws: 8.21.0
transitivePeerDependencies:
@@ -10782,7 +10787,7 @@ snapshots:
dependencies:
colorette: 2.0.20
dateformat: 4.6.3
fast-copy: 3.0.2
fast-copy: 3.1.0
fast-safe-stringify: 2.1.1
help-me: 5.0.0
joycon: 3.1.1
@@ -10832,7 +10837,7 @@ snapshots:
dependencies:
nanoid: 3.3.20
picocolors: 1.1.1
source-map-js: 1.2.1
source-map-js: 1.2.2
[email protected]: {}
@@ -11113,7 +11118,7 @@ snapshots:
dependencies:
chokidar: 3.6.0
immutable: 4.3.9
source-map-js: 1.2.1
source-map-js: 1.2.2
[email protected]: {}
@@ -11276,7 +11281,7 @@ snapshots:
sort-object-keys: 1.1.3
tinyglobby: 0.2.17
[email protected].1: {}
[email protected].2: {}
[email protected]:
dependencies:
@@ -11609,7 +11614,7 @@ snapshots:
[email protected]: {}
undici@7.29.0: {}
undici@7.30.1: {}
[email protected]:
dependencies:
@@ -11663,9 +11668,9 @@ snapshots:
[email protected]: {}
update-browserslist-db@1.2.3([email protected]8.5):
update-browserslist-db@1.3.4([email protected]9.5):
dependencies:
browserslist: 4.28.5
browserslist: 4.29.5
escalade: 3.2.0
picocolors: 1.1.1
+203
View File
@@ -0,0 +1,203 @@
import type { BasePayload, PayloadEmailAdapter } from 'payload'
import { createServer, type Server } from 'node:net'
import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from 'vitest'
import { mailAdapter } from '../src/modules/email/mailAdapter.js'
import { panelSmtpAdapter } from '../src/modules/email/panelSmtpAdapter.js'
import { sendEmail } from '../src/modules/email/sendEmail.js'
import { fakePayload } from './helpers.js'
vi.mock('server-only', () => ({}))
type Received = { auth: string[]; data: string; from: string; to: string[] }
/**
* Minimal plain-text SMTP server: just enough of RFC 5321 for nodemailer to
* authenticate and deliver one message per connection. No STARTTLS is
* advertised, so the real nodemailer client talks to it in the clear.
*/
function startSmtpServer(received: Received[]): Promise<{ port: number; server: Server }> {
const server = createServer((socket) => {
const mail: Received = { auth: [], data: '', from: '', to: [] }
let inData = false
let buffer = ''
const reply = (line: string) => socket.write(`${line}\r\n`)
reply('220 localhost ESMTP test')
socket.on('data', (chunk) => {
buffer += chunk.toString('utf8')
let index: number
while ((index = buffer.indexOf('\r\n')) >= 0) {
const line = buffer.slice(0, index)
buffer = buffer.slice(index + 2)
if (inData) {
if (line === '.') {
inData = false
received.push(mail)
reply('250 2.0.0 Ok: queued as TEST1')
} else {
mail.data += `${line.startsWith('..') ? line.slice(1) : line}\n`
}
continue
}
const command = line.toUpperCase()
if (command.startsWith('EHLO')) {
socket.write('250-localhost\r\n250-AUTH PLAIN LOGIN\r\n250 8BITMIME\r\n')
} else if (command.startsWith('AUTH PLAIN')) {
mail.auth.push(Buffer.from(line.slice(11), 'base64').toString('utf8'))
reply('235 2.7.0 Authentication successful')
} else if (command.startsWith('MAIL FROM:')) {
mail.from = line.slice(10).trim()
reply('250 2.1.0 Ok')
} else if (command.startsWith('RCPT TO:')) {
mail.to.push(line.slice(8).trim())
reply('250 2.1.5 Ok')
} else if (command === 'DATA') {
inData = true
reply('354 End data with <CR><LF>.<CR><LF>')
} else if (command === 'QUIT') {
reply('221 2.0.0 Bye')
socket.end()
} else {
reply('502 5.5.2 Command not recognized')
}
}
})
})
return new Promise((resolve) => {
server.listen(0, '127.0.0.1', () => {
const address = server.address()
resolve({ port: typeof address === 'object' && address ? address.port : 0, server })
})
})
}
const buildAdapter = (adapter: PayloadEmailAdapter, payload: BasePayload) =>
adapter({ payload } as Parameters<PayloadEmailAdapter>[0])
describe('e-mail transports (nodemailer 10)', () => {
const received: Received[] = []
let port = 0
let server: Server
beforeAll(async () => {
;({ port, server } = await startSmtpServer(received))
})
afterAll(async () => {
await new Promise((resolve) => server.close(resolve))
})
afterEach(() => {
received.length = 0
vi.unstubAllEnvs()
vi.unstubAllGlobals()
})
const smtpSettings = () => ({
smtpFromAddress: '[email protected]',
smtpFromName: 'Example Office',
smtpHost: '127.0.0.1',
smtpPassword: 'test-password',
smtpPort: port,
smtpUser: 'mailer',
})
test('panelSmtpAdapter delivers over SMTP with the panel sender and a single-line subject', async () => {
const { payload } = fakePayload({ integrations: smtpSettings() })
const adapter = buildAdapter(panelSmtpAdapter(), payload)
const result = await adapter.sendEmail({
html: '<p>Hello</p>',
subject: 'New lead\r\nBcc: [email protected]',
to: '[email protected]',
})
expect(result).toMatchObject({ sent: true })
expect((result as { messageId: string }).messageId).toMatch(/^<[^@>]+@[^@>]+>$/)
expect(received).toHaveLength(1)
const [mail] = received
expect(mail.auth).toEqual(['\0mailer\0test-password'])
expect(mail.from).toBe('<[email protected]>')
expect(mail.to).toEqual(['<[email protected]>'])
expect(mail.data).toContain('From: Example Office <[email protected]>')
expect(mail.data).toContain('Subject: New lead Bcc: [email protected]')
expect(mail.data).not.toMatch(/^Bcc:/m)
expect(mail.data).toContain('<p>Hello</p>')
})
test('sendEmail helper delivers over SMTP and returns the message id', async () => {
const { payload } = fakePayload({ integrations: smtpSettings() })
const result = await sendEmail({
html: '<p>Hi</p>',
payload,
replyTo: '[email protected]',
subject: 'Contact',
text: 'Hi',
to: ['[email protected]', '[email protected]'],
})
expect(result).toMatchObject({ sent: true })
expect(received[0].to).toEqual(['<[email protected]>', '<[email protected]>'])
expect(received[0].data).toContain('Reply-To: [email protected]')
})
test('an unreachable SMTP server is reported, not thrown, and the status is recorded', async () => {
const { payload } = fakePayload({ integrations: { ...smtpSettings(), smtpPort: 1 } })
const adapter = buildAdapter(mailAdapter(), payload)
const result = await adapter.sendEmail({ html: '<p>x</p>', subject: 'x', to: '[email protected]' })
expect(result).toMatchObject({ error: 'The e-mail was not sent.', sent: false })
expect(payload.updateGlobal).toHaveBeenCalledWith(
expect.objectContaining({
data: expect.objectContaining({
emailStatus: expect.objectContaining({ code: 'smtp-error', state: 'degraded' }),
}),
}),
)
})
test('mailAdapter sends over Microsoft Graph when selected and configured', async () => {
vi.stubEnv('GRAPH_TENANT_ID', 'tenant')
vi.stubEnv('GRAPH_CLIENT_ID', 'client')
vi.stubEnv('GRAPH_CLIENT_SECRET', 'secret')
vi.stubEnv('GRAPH_SENDER', '[email protected]')
const fetchMock = vi.fn(async (url: string) =>
url.includes('login.microsoftonline.com')
? new Response(JSON.stringify({ access_token: 'token-1' }), { status: 200 })
: new Response(null, { status: 202 }),
)
vi.stubGlobal('fetch', fetchMock)
const { payload } = fakePayload({ integrations: { ...smtpSettings(), emailTransport: 'graph' } })
const adapter = buildAdapter(mailAdapter(), payload)
const result = await adapter.sendEmail({ html: '<p>Graph</p>', subject: 'Via Graph', to: '[email protected]' })
expect(result).toEqual({ sent: true })
expect(received).toHaveLength(0)
expect(fetchMock).toHaveBeenCalledTimes(2)
const [url, init] = fetchMock.mock.calls[1] as unknown as [string, RequestInit]
expect(url).toBe('https://graph.microsoft.com/v1.0/users/forms%40example.com/sendMail')
expect((init.headers as Record<string, string>).Authorization).toBe('Bearer token-1')
const body = JSON.parse(init.body as string) as { message: Record<string, unknown> }
expect(body.message).toMatchObject({
from: { emailAddress: { name: 'Example Office', address: '[email protected]' } },
replyTo: [{ emailAddress: { address: '[email protected]' } }],
subject: 'Via Graph',
toRecipients: [{ emailAddress: { address: '[email protected]' } }],
})
})
test('mailAdapter falls back to SMTP when Graph is selected but not configured', async () => {
const { payload } = fakePayload({ integrations: { ...smtpSettings(), emailTransport: 'graph' } })
const adapter = buildAdapter(mailAdapter(), payload)
const result = await adapter.sendEmail({ html: '<p>x</p>', subject: 'Fallback', to: '[email protected]' })
expect(result).toMatchObject({ sent: true })
expect(received).toHaveLength(1)
expect(payload.logger.warn).toHaveBeenCalled()
})
})
+45
View File
@@ -0,0 +1,45 @@
import type { Config, TextField } from 'payload'
import { payloadTotp } from '@clocklimited/payload-2fa'
import { realpathSync } from 'node:fs'
import { createRequire } from 'node:module'
import { describe, expect, test } from 'vitest'
import type { I18nConfig } from '../src/modules/i18n/types.js'
import { ipalKit } from '../src/plugin.js'
const i18n: I18nConfig = { defaultLocale: 'en', locales: [{ code: 'en', label: 'English' }] }
const require = createRequire(import.meta.url)
/** Real path of the `payload` entry that `fromFile` would load. */
const payloadSeenFrom = (fromFile: string) => realpathSync(createRequire(fromFile).resolve('payload'))
describe('@clocklimited/payload-2fa with the real plugin', () => {
test('uses the same payload as the project (peer dependency, no second copy)', () => {
const twoFactorEntry = realpathSync(require.resolve('@clocklimited/payload-2fa'))
expect(payloadSeenFrom(twoFactorEntry)).toBe(payloadSeenFrom(import.meta.url))
})
test('ipalKit wraps the auth collection with TOTP: secret field, strategy and setup view', async () => {
const config = await ipalKit({
access: { authCollection: 'users' },
i18n,
twoFactor: { issuer: 'Example', plugin: payloadTotp },
})({ collections: [], secret: 'x' } as unknown as Config)
const users = config.collections?.find((c) => c.slug === 'users')
const secret = users?.fields.find(
(f): f is TextField => 'name' in f && f.name === 'totpSecret' && f.type === 'text',
)
expect(secret).toBeDefined()
expect(secret?.admin?.hidden).toBe(true)
// The TOTP secret is never readable over the API.
expect((secret?.access?.read as () => boolean)()).toBe(false)
const auth = users?.auth
expect(typeof auth === 'object' && auth.strategies?.length).toBeGreaterThan(0)
expect(config.admin?.components?.views?.SetupTOTP).toBeDefined()
expect(config.admin?.components?.views?.VerifyTOTP).toBeDefined()
})
})