Compare commits

...
126 Commits
Author SHA1 Message Date
Radosław SmolińskiandClaude Opus 5.5 d97d571de7 1.17.0 release notes: consent
The box says "a doctor warning" for consent-log-migration (decided after the review); the reference copies of the
iapl-upgrade and iapl-reference skills re-synced from docs/agent/skills.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 14:19:50 +01:00
Radosław SmolińskiandClaude Opus 5.5 9fa886ce62 Merge claude/consent-compliance-build: Global Privacy Control honoured, equal choice by default, withdrawal that stops running tools, consent log on by default
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 14:19:35 +01:00
Radosław SmolińskiandClaude Opus 5.5 963464d6cb Consent log endpoint: body capped at 4 KiB (413), version bounded by the policy version; consent-log-migration a warning
Review C-1: the endpoint, on on every site, parsed a 20 MB body. It now refuses a content-length over
CONSENT_LOG_MAX_BYTES (4096) before reading and reads the stream only up to the cap (readCappedBody), so a missing or
false length cannot make it hold more. A version above Cookie settings' policy version is 400 (the cached version is
read again once, for an editor's fresh raise); versions from 1 up are accepted (pages rendered before a raise).
Review C-2: consent-log-migration is a warning, like every consent check of 1.17.0 (the owner's decision).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 14:10:44 +01:00
Radosław SmolińskiandClaude Opus 5.5 9a448ba5df Consent log upgrade test: key order (lint)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 14:00:35 +01:00
Radosław SmolińskiandClaude Opus 5.5 c6a276823c Consent log: missing-table line once per Payload instance; SQL upgrade proof on Postgres and SQLite
test/consentLogUpgrade.test.ts: a site without the log (migrations applied) upgraded to 1.17.0 — without a migration
the site works and a consent write answers 503 with one log line; migrate:create adds only consent_records (and the
lock-relation column) and writes succeed. SQLite always; Postgres with IAPL_TEST_PG_URL. Docs say exactly what the
migration creates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 13:51:52 +01:00
Radosław SmolińskiandClaude Opus 5.5 f5c53e4523 Consent compliance: docs, agent guide, skills, changelog, shared behaviour spec, browser check, reference e2e
- docs/consent.md: compliance defaults, Global Privacy Control, withdrawal, consent log on by default and the SQL
  migration; no more "UODO requirement" or "GPC not needed". docs/analytics.md: what Consent Mode advanced sends.
- docs/consent-behaviour-spec.md: the behaviour IAPL and IAWL share, with the 13-item test list.
- CHANGELOG 1.17.0: the SQL migration first, a before → after table for an existing site.
- AGENT.md, iapl-setup / iapl-upgrade / iapl-reference / iapl-consent-check, PROGRAMISTA item 78; reference skills copy.
- iapl-consent-check: Global Privacy Control, equal prominence and withdrawal runs; Google asset warnings.
- Reference site uses the new defaults; e2e for GPC, a stale grant, equal prominence, withdrawal; e2e:built runs every
  consent test in both bundlers. YouTubeEmbed warns in development without a poster.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 13:48:19 +01:00
Radosław SmolińskiandClaude Opus 5.5 99036eb70c Consent compliance: Global Privacy Control honoured, equal choice by default, withdrawal that stops running tools, consent log on by default
- GPC (gpc.ts): read in the browser before the first paint (consentBannerScript) and in the consent store; pages stay
  static. 'honour' (default): no banner, analytics and marketing off, no request to Google or a pixel; an explicit
  choice on the site wins; a grant made without the signal gives way when it appears. 'ask' and false as opt-outs.
- equalChoice defaults to true; a development warning when the banner has no 'reject'.
- Withdrawal: Meta / TikTok / Clarity told at once, listed localStorage / sessionStorage keys removed.
- Clarity gets consentv2 when it loads; ads_data_redaction with the Consent Mode default.
- consentLog on by default (consentLog: false turns it off); SiteProviders posts to it by itself; a missing SQL table
  answers 503 with one log line.
- Default banner text: one sentence on changing the choice and browser settings; the GPC line (PL / EN).
- Doctor: consent-log-migration, consent-banner rules.
- Stats: Sec-GPC over a choice made without it keeps the visitor id out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 13:38:39 +01:00
Radosław SmolińskiandClaude Fable 5.2 41771fd51a Consent compliance proposal: the banner against the rules, Global Privacy Control, defaults the plugin enforces, the spec shared with IAWL
Design only, no code. First cut for 1.17.0 needs no schema change; eight yes-or-no decisions for the owner.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 13:25:34 +01:00
Radosław SmolińskiandClaude Opus 5.5 9520e61b15 1.17.0 release notes: the speed of public pages
The "Read before upgrading" box names the two changes merged after 2f6a81a: the cookie banner painted with the
page (nothing to do) and Payload's colour-scheme client hints for the admin only (one line in next.config.ts).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 12:56:42 +01:00
Radosław SmolińskiandClaude Opus 5.5 80e202111c Merge claude/consent-banner-first-paint-154f9f: the cookie banner is part of the first render
Conflicts in the docs only, both sides kept: changelog lines, AGENT.md checklist rows 12 (banner) and 13 (wrapper order),
the two iapl-upgrade blocks, PROGRAMISTA rows 76 (client hints) and 77 (banner, renumbered from 76).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 12:56:20 +01:00
Radosław SmolińskiandClaude Opus 5.5 6dd552f721 Merge claude/admin-only-theme-headers-f19f9f: Payload's colour-scheme client hints go to the admin only
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 12:45:22 +01:00
Radosław SmolińskiandClaude Fable 5.2 177620da57 Cookie banner is part of the first render: in the server HTML, decided before the first paint; pages stay static
Until now CookieBanner rendered nothing until the page had hydrated and an effect had read the cookie, so on a first
visit it appeared late and became the LCP element on text pages (request from a client project, 2026-11-26).

- The banner is rendered on the server with `hidden`, followed by one inline script (consentBannerScript) that,
  before the browser paints, shows it (no current decision) or keeps it hidden (current decision). It decides as
  readConsentRecord does. A click on a banner button before hydration is kept and carried out once the page is live.
- The decision is read through a store (useSyncExternalStore): no hydration mismatch, the browser's value before
  the next paint. One decision per document.
- Optional server read (ConsentProvider cookieValue, SiteProviders consentCookie): exact HTML, dynamic pages.
- CookieBanner firstPaint={false} keeps the old behaviour; nonce from SiteProviders / ConsentProvider / the prop.
- Nothing about consent changes: no tag earlier, Consent Mode default first, cookie, consent log, withdrawal.

Tests: test/consentFirstPaint.test.ts (server render, script against readConsentRecord, hydration with no warning,
decisions, tags), reference e2e (static HTML, painted before hydration, returning visitor, early click).
Docs: consent.md "First paint", frontend.md, security.md, AGENT.md, skills, changelog draft under 1.17.0.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 12:08:59 +01:00
Radosław SmolińskiandClaude Fable 5.2 9143c132a3 Payload's colour-scheme client hints go to the admin only: withSecurityConfig outside withPayload
withPayload adds Accept-CH, Critical-CH and Vary: Sec-CH-Prefers-Color-Scheme for /:path*; Critical-CH makes
Chrome repeat the first document request of a visit to a public page. As the outer wrapper, withSecurityConfig
moves the three headers to /admin/:path* (adminClientHints: { route, sources } | false). Inside withPayload
nothing changes, so an unedited site behaves as before. Exports scopeColorSchemeClientHints,
adminClientHintSources, COLOR_SCHEME_CLIENT_HINT; doctor rule client-hints (info); reference site and starter
use the new order; e2e:built and the starter gate check it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 11:55:26 +01:00
Radosław SmolińskiandClaude Opus 5.5 2f6a81acbf 1.17.0 upgrade notes
Changelog: one 1.17.0 entry, the security follow-ups prepared as 1.16.8 first, then e-mail, the name, Postgres;
the mail service is live with enrolment "pending". PROGRAMISTA §6 rows 71 (renamed), 74 and 75; iapl-upgrade
"→ 1.17.0, security"; iapl-setup, iapl-debug, email.md, deployment.md: a new site waits for approval while the
service runs with "pending". Reference skills, AGENTS.md and the reference index on 1.17.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 11:09:53 +01:00
Radosław SmolińskiandClaude Opus 5.5 3bfe377f1b 1.17.0
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 11:09:00 +01:00
Radosław SmolińskiandClaude Opus 5.5 536e219f57 Merge claude/mail-relay-dev-hosts: development hosts by pattern with no env, built in *.dev.netscale.pl
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 11:08:15 +01:00
Radosław SmolińskiandClaude Fable 5.2 6c4e244094 Development hosts, review V-1 to V-3: a malformed list stops the start, a trailing dot and Unicode patterns match, every send reads the store
- V-1: assertDevelopmentHosts - iapl({ developmentHosts }), mail.relay.developmentHosts and
  mailAdapter({ relay }) refuse anything but an array of non-empty host patterns, and a pattern of `*` alone
  (it would make the public site a development address). Nothing is ignored silently any more.
- V-2: one trailing dot of the host is stripped before matching; patterns are punycoded, so one written in
  Unicode matches; a `*` inside a non-ASCII label is refused.
- V-3: the 30-second memory of other hosts is gone. A dump restored into a running development site stops
  its very next e-mail.
- docs, AGENT.md, changelog draft, skills

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 10:57:32 +01:00
Radosław SmolińskiandClaude Fable 5.2 99c73ed0ff Development hosts are about mail only: one sentence on robots; the reference index after the fixture
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 10:40:33 +01:00
Radosław Smoliński 5df5358768 Revert "A development host is kept out of search engines without IAPL_NOINDEX (developmentNoindex, default on)"
This reverts commit bc3aac249f.
2026-11-26 10:38:29 +01:00
Radosław SmolińskiandClaude Fable 5.2 463b966365 Reference site: a test fixture for development hosts (E2E_DEVELOPMENT_HOSTS), for the built-site run of the launch cases
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 10:36:59 +01:00
Radosław SmolińskiandClaude Fable 5.2 bc3aac249f A development host is kept out of search engines without IAPL_NOINDEX (developmentNoindex, default on)
Separate from the mail rule so that it can be taken or left. A site whose address matches
iapl({ developmentHosts }) - built in: *.dev.netscale.pl - is noindex with no env: robots.txt disallows
everything, pages carry noindex, IndexNow sends nothing, buildSecurityHeaders() adds X-Robots-Tag. Nothing
kept a development copy out of search engines until now unless somebody set the variable.

- iapl({ developmentNoindex: false }) switches it off for the project, IAPL_NOINDEX=0 for one environment
- buildSecurityHeaders({ developmentHosts, serverUrl }): next.config runs before the plugin
- the mail rule keeps its own two signals: the development pattern, and the variable itself
- changelog "what changes on upgrade", deployment.md, security.md, AGENT.md, skills

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 10:31:03 +01:00
Radosław SmolińskiandClaude Fable 5.2 14abf369da Mail relay: development hosts are known by pattern, with no env - built in: *.dev.netscale.pl
The launch rule called a site non-public only when IAPL_NOINDEX was set (or the project named its hosts).
The owner's development sites set nothing, so production's database copied onto a development address
counted as a launch and would have mailed real people.

- iapl({ developmentHosts }): host patterns of development addresses. Default DEFAULT_DEVELOPMENT_HOSTS =
  ['*.dev.netscale.pl'], Intecion's own development domain; a project replaces the list or empties it.
  mail.relay.developmentHosts overrides it for the mail service.
- a site whose host matches is non-public exactly as with IAPL_NOINDEX=1; either signal is enough
- siteNonPublicSignal, matchDevelopmentHost, isDevelopmentHost, pluginDevelopmentHosts exported
- panel state: nonPublicBy, nonPublicPattern; doctor: mail-non-public (info) names the signal
- every case of the launch table runs with no env on the built-in pattern
- docs, AGENT.md, skills, changelog draft

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 10:26:12 +01:00
Radosław SmolińskiandClaude Opus 5.5 634908eb57 Merge claude/postgres-mail-deadlock: Postgres keeps connections free of transactions; form and account mail go out after the commit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 01:38:31 +01:00
Radosław SmolińskiandClaude Opus 5.5 074353bf5f Merge claude/mail-relay-launch: launch and a domain move need no click; a non-public copy neither enrols nor sends by itself
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 01:38:26 +01:00
Radosław SmolińskiandClaude Opus 5.5 919953e65e Account mail after commit: matched by its token, not by the address (P-4)
holdAccountMailFor bound the next message to an address to whichever
request held it: two resets for one account at once could lose the first
one's mail on the second's rollback, and a form's mail to that address was
deferred to the reset's transaction.

Payload calls generateEmailSubject({ req, token, user }) right before it
sends the reset or verify mail, and the mail carries that token. The plugin
now wraps that function on every auth collection (a project's own one is
kept, Payload's subject otherwise) and holds the token for the request's
transaction; mailAdapter defers only a message to that account alone whose
body contains a held token. An AsyncLocalStorage mark set in a
beforeOperation hook was not used: Payload awaits the hook, and a mark set
inside it does not reach the send (relay/kinds.ts says the same).

Building blocks renamed with it: holdAccountMail(token, address, req),
releaseAccountMail(token). Both review rows are tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 01:36:17 +01:00
Radosław SmolińskiandClaude Opus 5.5 4efadb21d5 Postgres pool, review round 1: nested transactions, account mail after commit
P-1: a transaction begun inside another one (a hook calling the Local API
without req) no longer queues behind its caller. An AsyncLocalStorage mark set
when a transaction begins lets the inner one through at once, without a
place, but never into the last connection (a second level may take that
one). If the mark is lost, a queue that has not moved for a second admits
its newest waiter. connectionReserve: false now admits everything, as
before. Measured on Postgres 17: 9, 12 and 30 such submissions finish
(before: stuck from 9).

P-2: Payload's "forgot password" and "verify your e-mail" through
mailAdapter() go out right after their transaction commits
(mail.accountMailAfterCommit, default on). With the relay hanging,
30 resets + 30 submissions finish in about 11 s instead of 43.5 s.

P-3: Postgres tests for the "not confirmed" file result after commit, a
caller's outer transaction rolled back or committed, the relay hanging,
and the nested rows; deployment.md has the measured table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 01:19:27 +01:00
Radosław SmolińskiandClaude Fable 5.2 49927205bb Mail relay: launch and a domain move need no click; a non-public copy neither enrols nor sends by itself
The copy rule now goes by direction. A public site that finds another host's connection in its database
(its development address after launch, its old domain after a move) enrols by itself. A site that says it
is not public - IAPL_NOINDEX=1, or a host in the new mail.relay.developmentHosts - and holds another host's
connection is a copy of that site's data: it neither enrols nor sends until "Connect again", also when it
has a token of its own (production's database copied back onto the development address). The consent is
stored with the copy (acceptedHosts), so the next fresh copy waits again.

- mail.relay.otherHosts: 'auto' (default) | 'wait' | 'enrol' | list of the site's own hosts
- mail.relay.developmentHosts, siteIsNonPublic() exported
- the copy refusal ends when its reason does (no cool-down; the panel recomputes it on every read)
- doctor: info for a public site whose database knows another host (the launched site, or a copy that
  forgot IAPL_NOINDEX)
- contract copy 1.7.1 (wording only)
- docs, AGENT.md, skills, changelog draft

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-26 00:46:16 +01:00
Radosław SmolińskiandClaude Opus 5.5 32bb542e8e Postgres: many requests at once no longer stop the site
Each Payload transaction holds a pool connection; code inside it that runs
without its req needs a second one (Payload's own forgotPassword, the mail
adapter's settings read and status write, payload.kv). With the default pool
of 10, ten form submissions or ten "forgot password" requests at once held
every connection and waited for good.

- connectionReserve (default on): at most pool size − reserve transactions
  open at once; a waiter older than a second may use all but the last
  connection. Building blocks in modules/database/transactions.ts.
- Form e-mails go out right after the submission's transaction commits, in
  the same request (forms.emailsInTransaction: true = the old way).
- recordIntegrationStatus merges identical writes and does not hold its
  caller while the pool is busy.
- SMTP time-outs: 10 s connect, 30 s greeting, 60 s silence (smtp.timeouts).

Tests on Postgres 17: 30 submissions, 30 forgot-password, and both against
an SMTP server that never answers, finish while a page answers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-26 00:33:07 +01:00
Radosław SmolińskiandClaude Opus 5.5 acfcf72c03 Merge claude/mail-relay-adapter: mail through IWSN by default, SMTP on request, Graph deprecated
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 23:59:55 +01:00
Radosław SmolińskiandClaude Fable 5.2 85ed92bb89 Mail relay: review round 2 — the store is keyed by host, a copied database does not enrol by itself
- Q-1 one entry per host (iapl:mail-relay:site:<host>); a read never deletes or writes; another host's
  entry is neither used nor touched (a developer's process on the live database, www and apex, a copy)
- a database that holds another host's connection and none of this site's does not enrol by itself:
  "Connect again" does, once; mail.relay.otherHosts ('wait' | 'enrol' | the site's own other hosts);
  panel text and doctor finding; a site with an empty store enrols by itself as before
- Q-2 the file limit answers from what is stored and never asks the service
- Q-3 a file whose mail was not confirmed is not reported as a wrong file, and no notice mail follows
- Q-4 its own text when the access-key field is off
- D-1 docs for open enrolment; staging, copies and several hosts

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 23:14:11 +01:00
Radosław SmolińskiandClaude Fable 5.2 edee3a321f Mail relay: the access-key field is off by default (mail.relay.accessKeyField)
A token issued by hand is set by a developer: setRelayToken() from a script, or mail.relay.token.
The panel field and its route take a token only when the project switches the field on. Docs and
AGENT.md say when such a token is needed and how to set it; a token of another host is refused on
every way in.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 22:25:34 +01:00
Radosław SmolińskiandClaude Fable 5.2 1a11cefffa Mail relay: the 1.7.0 test allows the status read that follows a new enrolment
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 22:14:09 +01:00
Radosław SmolińskiandClaude Fable 5.2 fef2c51bae Mail relay: contract 1.7.0 — X-Intecion-Site on every request with a token, host-mismatch
contracts/mail-relay refreshed from IWDL 6cd99f7 (64 files). A token the service knows as another
site's is forgotten without revoking and the site enrols as itself; a hand-issued one is refused.
The fake requires the header and answers host-mismatch.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 22:13:58 +01:00
Radosław SmolińskiandClaude Fable 5.2 a2b07b1dc1 Mail relay: review of 7d766b6 — R-1 to R-12, four mutations, two sentences
- R-1 a delivered token becomes the one in use only on 200 or a refusal given after authentication
- R-2 a token of another site is refused by what /v1/status says (access-key field, scripts); docs for staging
- R-3 the confirm route looks the nonce up first and counts only refused calls
- R-4 one budget of time per message (10 s, 30 s with files), enrolment and retries included
- R-5 'Disconnect' without the service's answer is not confirmed and keeps the token to try again
- R-6 no enrolment without the confirm route in the config
- R-7 half an SMTP set-up: one log line and a hint in the panel
- R-8 to R-10, R-12 docs; R-11 the last failure stays in the state block
- tests for redirect: manual, the candidate's nonce, the expectation taken back, one recipient only

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 22:07:10 +01:00
Radosław SmolińskiandClaude Fable 5.2 0ee74ab2a4 Mail relay: contract 1.6.0, the token tied to its host, IWSN in the panel
- contracts/mail-relay refreshed from IWDL 83af8c6 (1.6.0)
- an answer that is not the service's JSON is 'not confirmed' unless its status is 400 to 499
- a site with a token issued by hand does not enrol to heal: it stops and says what to ask Intecion for
- a store made on another host (a database copied to staging) is not used: the copy enrols as itself, nothing is revoked
- the panel calls the service IWSN (RELAY_SHORT_NAME); docs, logs and the doctor keep the full name

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 21:51:47 +01:00
Radosław SmolińskiandClaude Fable 5.2 7d766b6d58 Mail relay: the reference site's generated types without the e2e fixture's collections; doctor command in the guide
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 21:24:24 +01:00
Radosław SmolińskiandClaude Fable 5.2 ebfedb03d9 Mail relay: tests count the account rules' own hooks, reference index, doctor fixture
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 21:18:09 +01:00
Radosław SmolińskiandClaude Fable 5.2 2cceceffd0 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 <[email protected]>
2026-11-25 21:14:47 +01:00
Radosław SmolińskiandClaude Fable 5.2 dd3792cbc7 Mail relay: docs, agent guide, skills, changelog draft; test against the real service code; starter offers the mail service
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 20:53:38 +01:00
Radosław SmolińskiandClaude Fable 5.2 533f571d4d Mail relay: HTTP tests on a running Payload, account mail marked by recipient, panel wording, doctor rules tested
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 20:40:17 +01:00
Radosław SmolińskiandClaude Fable 5.2 ea9703f8e3 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]>
2026-11-25 20:29:46 +01:00
Radosław SmolińskiandClaude Opus 5.5 9efd86a06f Merge claude/iapl-rename-1170: the plugin is called IAPL, every name from before keeps working
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 19:26:36 +01:00
Radosław SmolińskiandClaude Fable 5.2 38b903fcfa IAPL rename, review fixes I-1 to I-11
I-1  ipalEnvRules() keeps the IPAL_ rule names (IAPL_ as aliases); iaplEnvRules() the other way round; the IAPL_ value
     is the one checked when both are set
I-2  COOKIE_SCAN_URL_ENV / COOKIE_SCAN_TOKEN_ENV (and the internal SITE_NOINDEX_ENV) keep their old values;
     IAPL_COOKIE_SCAN_URL_ENV / IAPL_COOKIE_SCAN_TOKEN_ENV added
I-3  bin/ipal-*.mjs: five files that run the new ones (1.16's audit skill and CI call them by path); legacy:site checks it
I-4  storage-names sees <SiteProviders … stats> when a JSX prop comes first (the reference layout's shape)
I-5  AGENT.md: a text naming an ipal-<name> skill means iapl-<name> (the vendored ext-* skills)
I-6  leftover text in the skills-current message
I-7  iapl-skills removes the old pointer block when both are in AGENTS.md
I-8, I-11  changelog: the doctor's summary line, IAPL_DOCTOR_STATUS, --strict in CI until the skills are refreshed
I-9  env.md: an empty IAPL_ variable does not switch the IPAL_ one off
I-10 verifyLimit.keyPrefix undefined or empty is 'not given'

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 18:45:36 +01:00
Radosław SmolińskiandClaude Fable 5.2 03452376f9 IAPL rename: three places where the brand rule had replaced a path segment or a test's needle
scripts/starter-gate.mjs (node_modules/@intecion/ipal-kit), dev/tsconfig.json (the 'ipal-kit' path alias),
test/starter.test.ts (the lockfile must not contain 'ipal-kit'); two JSDoc import lines.
Found by pnpm starter:gate.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 18:04:26 +01:00
Radosław SmolińskiandClaude Fable 5.2 5a0ea924ff Reference e2e setup clears the 2FA counter under the site's own key prefix (iapl)
The reference site has storageNames: 'iapl'; the setup cleared only ipal:2fa-verify:*, so attempts of one
e2e run counted against the next (found by the Turbopack run after the webpack run).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:59:00 +01:00
Radosław SmolińskiandClaude Fable 5.2 e0f7fa1add legacyNameForms: the MCP server name and a pattern fragment in the list
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:53:52 +01:00
Radosław SmolińskiandClaude Fable 5.2 0e54789abd Rename plan: what was carried out and where it differs
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:48:00 +01:00
Radosław SmolińskiandClaude Fable 5.2 630b736344 IAPL rename: instructions say 'pnpm exec iapl-skills', which works whatever the project's script is called
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:47:39 +01:00
Radosław SmolińskiandClaude Fable 5.2 3d5106bc4a IAPL rename: readEnv exported, the MCP server name left as it was, legacy:site needs a database
- readEnv / legacyEnvName exported from the root and /env (a project's own code reads IAPL_* with the IPAL_* fallback);
  the name constants hold the IAPL_ spelling — changelog and env.md say so
- createMcpRoute: the default serverName stays 'ipal-site' (clients see it); the scripted step had changed it
- legacy:site: the builds read the database; the script and PROGRAMISTA say which

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:47:11 +01:00
Radosław SmolińskiandClaude Fable 5.2 926ba4a67e IAPL rename: gate checks, and two breaks they found on an unedited 1.16.7 site
- pnpm legacy:site (scripts/legacy-site-check.mjs): the reference site of v1.16.7, unedited, installed against
  this build — old commands, doctor without errors, import map unchanged, tsc, builds with webpack and Turbopack
- test/legacyNameForms.test.ts: the remaining spellings with 'ipal' as a closed list; a new one fails
- found by legacy:site and fixed: 'ipal-tokens --check' called a tokens.css written before 1.17.0 out of date
  (its header names the command); the doctor's env-example rule did not accept IPAL_* in .env.example
- the doctor's seed rules catch IPAL_SEED_ALLOW_FULL=1 as before
- PROGRAMISTA: the new release check

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:41:26 +01:00
Radosław SmolińskiandClaude Fable 5.2 b91984fbcd IAPL rename: docs, agent guide, skills, reference site and starter on the new names; changelog draft
- docs, AGENT.md, the 16 skills, PROGRAMISTA and README use the preferred names (scripted, same list of forms);
  past CHANGELOG entries and the proposals in docs/dev are not rewritten
- AGENT.md: 'Names: IAPL and ipal-kit' — old name, new name, state in 1.x; what is not renamed; storageNames
- iapl-upgrade '→ 1.17.0', PROGRAMISTA §6 item 72, CHANGELOG 1.17.0 (draft): nothing required
- env.md, doctor.md (legacy-names, storage-names), stats.md, security.md, project-starter.md, iapl-reference, iapl-setup
- skill scripts read ipal-audit-skip and IPAL_IP_HEADER too; audit rule ids stay what they were
- reference site: iapl(), iapl-doctor.json, iapl-* skills, storageNames: 'iapl'; INDEX.md regenerated

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:36:09 +01:00
Radosław SmolińskiandClaude Fable 5.2 425fac14fb IAPL rename: the old names keep working, and a second cookie name and counter key for new sites
- exports: ipalKit, IpalOptions, ipalEnvRules, IpalEnvFeatures, ipalT, ipalVar, IPAL_TOKENS,
  IPAL_BREAKPOINTS, IpalTokenName, IpalGlobalSlug are aliases of the iapl names
- env: IAPL_* is read first, IPAL_* as fallback (readEnv; EnvRule.aliases for assertEnv);
  the crawler service reads IPAL_CRAWLER_SITES too
- doctor: reads ipal-doctor.json when it is the only one, the old pointer block, ipal-audit-skip
  and old skill folders; new rule legacy-names (info) and storage-names (warning)
- iapl-skills: installs iapl-*, removes the 16 old folders by exact name, rewrites the old
  pointer block in place; a project's own ipal-* skill stays
- storageNames: 'ipal' (default) | 'iapl': the cookie the scanner declares and the 2FA counter's
  kv prefix; <PageStats visitorCookie>, IAPL_VISITOR_COOKIE, verifyLimit.keyPrefix
- test/legacyNames.test.ts: 24 tests for all of the above

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:31:13 +01:00
Radosław SmolińskiandClaude Fable 5.2 0a4f001797 IAPL rename, scripted: preferred names in src, bin, scripts, services, tests; bin files and skill folders moved
Replaced by an explicit list of forms only (ten exported names, runtime env names, project file
names and marks, commands, skill names, the log prefix, the brand in prose). Package name, import
paths, routes, CSS tokens, data attributes, custom keys, context flags, the cookie and kv keys are
not touched. package.json keeps the five old bin names beside the five new ones.
The old names stop working in this commit and come back as aliases in the next; docs follow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:24:21 +01:00
Radosław SmolińskiandClaude Fable 5.2 414a4702df Rename plan: the owner's answers, and the second cookie name and kv prefix for new sites
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 17:21:53 +01:00
Radosław SmolińskiandClaude Fable 5.2 b785a27b7d Plan: rename ipal-kit to IAPL in 1.17.0 (inventory, sorting, shape, order, questions)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 13:09:57 +01:00
Radosław SmolińskiandClaude Opus 5.5 619a4e06ca 1.16.8 upgrade notes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 10:26:51 +01:00
Radosław SmolińskiandClaude Opus 5.5 dfec3fca46 1.16.8
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 10:26:33 +01:00
Radosław SmolińskiandClaude Opus 5.5 e29ceeffb0 Merge claude/security-copy-rules: copied staff collections, a rule that cannot widen
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 10:26:04 +01:00
Radosław SmolińskiandClaude Opus 5.5 1316509565 Merge claude/security-1168: account rules where an account can hold editor or admin, no package.json among public files, pnpm e2e:built
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 10:26:04 +01:00
Radosław SmolińskiandClaude Fable 5.2 a19fa0d17b L-1 and one changelog entry for the release: what gets narrower on a copy, the collection that becomes staff later
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 10:03:31 +01:00
Radosław SmolińskiandClaude Fable 5.2 20809ba933 L-2: a config collection that becomes staff later keeps the rules it had at config time
A collection of the config that is not named as staff and that a plugin listed after
ipalKit makes the panel's (admin.user) was adopted as a late collection: the plugin's
rule went in front of every rule, also the ones the project wrote. The marker now
holds the operations that had a rule at config time (own); those are left as written
when the collection is handled again, and an operation without one gets the plugin's.
The start log tells this case from a collection a later plugin added.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 10:03:31 +01:00
Radosław SmolińskiandClaude Fable 5.2 a743479276 Copied staff collections: the unit fixture's roles field holds a list (after the rebase on K-1)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 03:52:56 +01:00
Radosław SmolińskiandClaude Fable 5.2 c9540d291a Copied staff collections: access guide, API table, changelog, reference index
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 03:48:21 +01:00
Radosław SmolińskiandClaude Fable 5.2 8dcc123b99 Copied staff collections: the plugin's rule goes in front, nothing is replaced (a rule that cannot widen)
A plugin listed after ipalKit that copies a staff collection under a new slug, or reuses its access object, brings
rules the plugin wrote for the ORIGINAL. On 1.16.7 the copy also carried the boolean 'seen' marker and was left
alone: 'the account itself' then meant an account of the original — with numeric ids the original's account with
the same id changed the copy's account (17 of 40 measured shapes).
Design: the plugin never replaces and never rewrites a rule on such a collection. It puts its rule for the copy's
own slug in front, and both must allow: on a copy named as staff in front of every rule; on a copy that is not
staff or keeps its own rules (custom.ipal.accountRules: false) in front of the rules marked as the plugin's for
another collection. The roles field of every copy is guarded. The mark on the plugin's functions says only
{ slug, self }; custom.ipalAccounts says { slug, staff } (a collection named as staff during next dev is handled
on the reload). The plugin's rules are marked before its 2FA guard, which carries the mark.
Accepted cost: a copy's own account cannot edit itself through a copied rule (as on 1.16.7); the copy writes
access.update — one documented line.
Proof: test/accountCopyTableSuite.ts — 40 shapes x accounts x operations, each row not wider than the measurement
taken on 1.16.7 (test/fixtures/copyRulesBaseline.json) and not wider than the plugin's rule; 2FA off and on.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 03:48:09 +01:00
Radosław SmolińskiandClaude Fable 5.2 4c7b722aed K-3: docs — fields that hold a list, a relationship counts, a rule of your own replaces the protection, known limitations
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 03:44:25 +01:00
Radosław SmolińskiandClaude Fable 5.2 c3d95988e1 K-1, K-2: only a roles field that holds a LIST counts; the start-up check asks each collection its own way
K-1 the plugin counts roles only from an array (getRoles). A single-valued roles field — a select, text or
    relationship without hasMany, a radio — never makes a plugin admin, yet canHoldStaffRole said true: on a
    project's own login collection with a single role select nobody could create, change, delete or unlock accounts,
    the account holding admin included. rolesAreAList(collection) is now a precondition of the admin rules. The same
    for hasPluginRoles: a single select whose values are all the plugin's had the admin rules already in 1.16.7 and
    gets 'an account of this collection' now — its accounts manage each other again; the value still grants nothing.
    A relationship with hasMany counts (ids that are text).
K-2 staffCollectionsNobodyManages returns { stuck, unchecked } and checks collection by collection: no query where
    the field cannot hold admin; a count for a select with hasMany; for text / json / relationship the accounts are
    read and the plugin's own test is applied. Where it cannot check it says so and claims nothing.
Tests: the reviewer's shapes over HTTP and the warning's table against a running Payload, 2FA off and on.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 03:44:25 +01:00
Radosław SmolińskiandClaude Fable 5.2 ccc6f85924 Security follow-ups to 1.16.7: changelog, access guide, skills, API table, release gate, reference index
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 02:59:44 +01:00
Radosław SmolińskiandClaude Fable 5.2 be2e6d52d9 A staff collection whose accounts can hold editor or admin gets the admin rules (H-2, J-3)
In the released 1.16.7. The plugin's checks go by the value on the account, but a project's own staff collection
without rules got the admin rules only when ALL its role values were the plugin's; otherwise 'an account of this
collection' could create, change and delete accounts. Measured on bc0fa65 (SQLite; the first shape also on Postgres
and MongoDB, 2FA off and on): with roles user/editor/admin/boss, with a text and with a json roles field, config-time
and added by a later plugin, an account with the role user creates an admin (201) who reads Site integrations, changes
another staff collection's roles and lists the panel's accounts (200 / 200 / 200), takes the admin over and deletes it;
with viewer/editor a viewer creates an editor who gets past the access rule of Site settings.
canHoldStaffRole(collection): a roles select with editor or admin among its values, or a roles field whose values
cannot be listed. Then: create / delete / unlock an admin, update an admin or the account itself, roles only by an
admin. A project's own rules win. A warning at start when no staff account is an admin and such a collection exists.
The built-site fixture gets a config-time and a late collection of that kind; nothing here touches copied collections.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 02:59:44 +01:00
Radosław SmolińskiandClaude Fable 5.2 01219b69d3 F-3: pnpm e2e:built puts the reference site's generated files back, also on failure
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 02:53:41 +01:00
Radosław SmolińskiandClaude Fable 5.2 e77c607bca R4-3: pnpm e2e:built (webpack and Turbopack); Playwright runs reset the test admins first
The command builds the reference site with both bundlers, checks the public files for a package manifest and runs
the late-staff spec and the published-files check against each built site. A global setup resets the test admins
and their stored 2FA attempt counts before every run, so a spec no longer depends on what ran before it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 02:53:41 +01:00
Radosław SmolińskiandClaude Fable 5.2 9a648b0498 The plugin's version is a constant: no package.json among a site's public assets
pluginVersion() named package.json relative to its own module. A bundler takes such a file for an asset:
a Turbopack build of a site copied the plugin's whole package.json (dependency lists, scripts, the registry
and repository addresses; no secret) to /_next/static/media/package.<hash>.json, served to anyone. Webpack kept
it on the server side. The version now comes from src/version.ts (scripts/write-version.mjs, run by the
`version` script; a test fails when it differs from package.json). A smoke test of the built site: nothing
under .next/static is a package manifest.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 02:53:41 +01:00
Radosław SmolińskiandClaude Opus 5.5 bc0fa65fd7 1.16.7 upgrade notes
CI / check (push) Failing after 5m54s
CI / reference (push) Skipped
CI / reference-full (push) Skipped
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:40:20 +01:00
Radosław SmolińskiandClaude Opus 5.5 14c44d082d 1.16.7
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:40:07 +01:00
Radosław SmolińskiandClaude Opus 5.5 7b2a2759ab Merge claude/security-m1-hardening (rebased): write-only secrets, account rules, password rule, 2FA attempts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:39:30 +01:00
Radosław SmolińskiandClaude Fable 5.2 8a01c72c2a M1 review round 3: a built-site e2e for a late staff collection (both bundlers); docs follow
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:24 +01:00
Radosław SmolińskiandClaude Fable 5.2 6e0ad26b2c M1 review round 3: late staff collections without guessing Payload's default; rules survive a dev reload
R3-1 nothing is decided by a function's name any more (a production build renames it): on a collection that
     arrives after ipalKit the plugin's rule is put in FRONT of the rule that is there and both must allow
     (bothAllow). unlock follows the same table. The log says exactly what was put.
R3-2 the adoption walks the live config (payload.config), which Payload swaps first on a dev reload.
R3-3 readVersions gets the read rule on staff collections.
R3-5 a secret that is not text is refused.
Also: the async check of requireSetup.exempt compares the constructor, not its name.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:24 +01:00
Radosław SmolińskiandClaude Fable 5.2 3e44863c98 M1 review round 2: docs, agent guide, skills, changelog; the reference types without the removed field
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:24 +01:00
Radosław SmolińskiandClaude Fable 5.2 7002ebbfa6 M1 review round 2: the transport is no way round, nobody raises its own role, late staff collections
R2-1 the SMTP password is bound to server, port and user whatever the transport says; the transport alone is not bound.
R2-2 where the plugin's update rule is in force the roles field is closed for the account itself
     (the plugin's roles: only an admin; roles of the project's own: never one's own).
R2-3 auth collections a later plugin adds get the account rules, the password rule and the first-user endpoint when
     the config goes live; a staff slug that is not an auth collection stops the start.
R2-4 smtpRequireTls is taken out: the branch adds no field, column or collection.
Also: read (a staff account) and unlock (an admin) defaults on staff collections (accounts.staffOnlyRead);
doctor staff-own-roles and read / unlock in staff-accounts-open; r1 NULL against the default, also inside a row;
r2 bound values compared exactly.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:24 +01:00
Radosław SmolińskiandClaude Fable 5.2 a32329fbb4 M1 review: reference site types and an e2e check of the bound SMTP password
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:23 +01:00
Radosław SmolińskiandClaude Fable 5.2 fd203de326 M1 review: docs, agent guide, skills and changelog follow the fixes
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:23 +01:00
Radosław SmolińskiandClaude Fable 5.2 1141c749de M1 review: account rules before 2FA, the SMTP password stays with its server, the rest of the findings
M1-1 the first-user route is the plugin's own endpoint in front of Payload's; nothing is read from the path.
M1-2 the account rules are put on the collections before the 2FA package wraps them.
M1-6 the admin rule only where the roles are the plugin's; other staff collections: an account of that collection.
     update / delete get the matching defaults (accounts.adminOnlyWrite); doctor rule staff-accounts-open.
M1-5 access.firstUserAdmin: false with a role below the panel role: the default panel role steps aside, an explicit one is refused.
M1-3 a save that changes the SMTP server, port, user or encryption must send the password again (secrets.reenterOnChange);
     new panel field smtpRequireTls.
M1-4 a restore of a version masks the secrets (maskSecretsOnRestore).
M1-7 a refused origin is logged once with the ways to allow it; default ports are normalised.
Minors: m1 day boundary, m3 e-mail check on reset and bulk update, m4 text of 'all', m5 the mask is never kept.
The account suite runs with 2FA off and on.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:23 +01:00
Radosław SmolińskiandClaude Fable 5.2 81cee02e78 M1: the reference e2e suite follows the stored 2FA verify count
The verify count now survives a restart of the site, so the specs can no longer
share one test admin across server runs: create-test-admin.ts makes two test
admins and clears their stored counts; the setup spec signs in as the second.
The whole suite passes in one run (20 passed, 1 skipped).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:23 +01:00
Radosław SmolińskiandClaude Fable 5.2 83356ab4ed M1: docs, agent guide, skills and changelog for the hardening items
security.md (stored secrets, own-origin 2FA attempts, stored verify count,
dashboard alerts by role), access.md (account rules: panel role, no
self-registration, passwords), turnstile.md (the deprecated env secret,
forms.turnstileOnConfigError), doctor.md (five new rules, the deep status),
AGENT.md, ipal-setup, ipal-upgrade, ipal-debug, ipal-reference (+ api.md),
ipal-doctor and their mirrors, PROGRAMISTA row 69, CHANGELOG under an unreleased
heading with "Requires project changes".

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:23 +01:00
Radosław SmolińskiandClaude Opus 5.5 cff355a541 Merge claude/docs-isadmin-client-import: role checks importable in client components
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 f7296edc71 M1 (8): 2FA attempts only from the own origin; the verify count is stored
R3-2. (b) POST /api/verify-totp and /api/setup-totp refuse a request that a
browser marks as coming from another origin (Origin, Sec-Fetch-Site) — before it
is counted, so another page (a sibling subdomain included) cannot burn an
account's attempts and lock its owner out. Own origins: the request's host,
serverURL, Payload's csrf / cors lists, twoFactor.sameOrigin.origins; requests
without those headers pass. twoFactor.sameOrigin: false turns it off.
(a) The verify count is kept in memory (exact for parallel bursts) and in
Payload's key-value store (payload.kv, no new collection), so a restart or a
second instance does not reset it; the higher count decides, and a failing store
never opens the gate. verifyLimit.store: 'memory' = this instance only.
Doctor: csrf-empty (static, warning) when neither serverURL nor csrf is set.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 0b4c4e8295 M1 (9): dashboard alerts by role
IntegrationAlerts reads the admin-only Site integrations global with access
control off and showed its error texts to everyone who opened the dashboard.
Now: an admin sees what is failing and the link, an editor a neutral "an
integration needs attention — ask an administrator", anyone else nothing.
CookieCrawlAlert is shown to editors and above (the role that may read the crawl
result). Both use userMeetsRole, so a session that still owes its second factor
sees neither. dashboardAlerts: { integrations: 'admin' | 'editor' | 'all',
cookies: 'editor' | 'all' } loosens it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 5d35b2c3f4 M1 (7): a password rule for staff accounts (accounts.password)
When a password is set on a staff collection — a new account, the first-user
screen, a change, a reset by e-mail; panel, API and Local API alike — it must
have at least 12 characters and not be the account's own e-mail address.
Existing passwords are never checked: a shorter one keeps logging in and meets
the rule when it is next changed. accounts.password: { minLength } | false.
No breached-password lookup; checkPassword and the hook are exported.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 c6fc0d21fe M1 (6): nobody creates an account for themselves
accounts.adminOnlyCreate (on): a staff collection without a create rule gets
"an admin, fully signed in" instead of Payload's "any logged-in user" — also the
project's own collection; a rule the project wrote stays.
accounts.firstUserRoute ('panel'): Payload's first-user route answers only for
the collection the panel logs in with. For any other empty auth collection it is
refused, unless that collection's own create rule lets an anonymous request in.
Checked and closed: an empty second staff collection, whose first visitor became
a staff admin (test/accountRulesOff.test.ts records the old behaviour, which
accounts: false / firstUserRoute: 'all' still give).
Doctor: open-signup (deep, info) names auth collections with open sign-up.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 cd60b73685 M1 (5): the lowest role stays out of the admin panel (accounts.panelRole)
The panel opens for editor and above by default: Payload's access.admin on the
collection that carries the roles. An account that holds only `user` sees
"Unauthorized" there; the API is not touched. The rule looks at the role, not
at the second factor, so the 2FA screens stay reachable. accounts.panelRole:
'user' | false (everyone, as before) | 'admin'; accounts: false turns the account
rules off; the project's own access.admin wins. At start the log says how many
accounts the rule keeps out, and is an error when it keeps everyone out.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 463fd5d664 M1 (4): forms.turnstileOnConfigError — a form with files is refused while Turnstile cannot check
While Turnstile is degraded (wrong or missing secret, Cloudflare down) a text
form is still accepted, as before; a submission to the file endpoint is refused
by default. forms.turnstileOnConfigError sets it for every form or per kind
('allow' | 'reject' | { text, files }); a value at a call site still wins.
Nothing changes when Turnstile is off. The gates and the resolver are exported
from the server entry.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 42fdad8c2d M1 (2, 3): the Turnstile env secret is deprecated; doctor rules access-missing, turnstile-degraded, turnstile-env-key
(2) Stage one of the deprecation: TURNSTILE_SECRET_KEY from the environment still
works when the panel field is empty, logs once that it is deprecated, and the
doctor's deep status reports it (rule turnstile-env-key, warning). Nothing is
removed.
(3) access-missing (static, warning): ipalKit without `access` means every panel
account is an admin. turnstile-degraded (deep): Turnstile is not checking forms —
warning, error after a day. The deep status carries the recorded state and where
the secret comes from, never a key.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Fable 5.2 8fa71238ce M1 (1): stored secrets are write-only
smtpPassword and turnstileSecretKey in the Site integrations global are returned
as '********' to every read that goes through access control (REST, GraphQL, the
panel's form state); the Local API with access control off still gets the value.
A save that sends nothing, an empty value or the mask keeps the stored one;
'[[clear]]' removes it. MaskedField says that a value is set and offers to
remove it. Off: secrets: { writeOnly: false }. writeOnlySecret(s) and the hooks
are exported for a project's own fields.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-25 00:39:12 +01:00
Radosław SmolińskiandClaude Opus 5.5 de414a81a8 Role checks in client components: export them from /client, fix the docs
access.md and the 1.16.4 upgrade notes led projects to import isAdmin from
'@intecion/ipal-kit' in a client component; with `next build --webpack` that
fails ('server-only' cannot be imported from a Client Component module).
No existing entry had a client-safe one, so '@intecion/ipal-kit/client' now
exports hasMinimumRole, isAdmin, isEditor and the type Role; the main entry
keeps them for server code.

Docs: access.md (snippet with imports, server vs client, useConfig() carries
admin.user only), AGENT.md, ipal-debug, ipal-reference, ipal-upgrade, the
1.16.4 note, an Unreleased changelog entry. Tests: /client reaches no
server-only module, the predicates' answers with a client config, no
client-component example in the docs imports the main entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 22:00:27 +01:00
Radosław SmolińskiandClaude Opus 5.5 1270ebc3d1 1.16.6 upgrade notes
CI / check (push) Failing after 5m28s
CI / reference (push) Skipped
CI / reference-full (push) Skipped
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:38:42 +01:00
Radosław SmolińskiandClaude Opus 5.5 0356a329ca 1.16.6
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:38:42 +01:00
Radosław SmolińskiandClaude Opus 5.5 b3a5ea1323 Merge claude/2fa-setup-required: an account without 2FA can only set it up (twoFactor.requireSetup)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 20:38:00 +01:00
Radosław SmolińskiandClaude Fable 5.2 b52193ae47 2FA setup required: the missing-column log reads the error's cause chain
R3-1: the SQL adapters throw "Failed query: …" and put the database's own words
("column … does not exist", "no such column") in the error's cause, so the loud
start-up line never appeared on a real Postgres or SQLite. The reason is now
built from the whole cause chain; other failures (ECONNREFUSED, a locked
database) still only warn. Tested with wrapped errors and against the real
adapter with the column dropped.

Docs and the doctor's fix text name how the migration is applied
(deployment.md 4.3) wherever they said only "before the site serves".

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 20:31:44 +01:00
Radosław SmolińskiandClaude Fable 5.2 01e3813723 2FA setup required: review round 2 — no SVG from the icon endpoint, migrations at container start
R2-1: /api/ipal/admin-icon answers with bytes only for a bitmap recognised by its
first bytes (PNG, JPEG, GIF, WebP, ICO, AVIF). An SVG favicon keeps the redirect
to the media file: a site-wide CSP rule overrides a route's own sandbox header,
so the header alone protected nothing in a built site. buildUploadSecurityHeaders
also returns a rule for the icon path, as a second layer.
R2-2: the SQL migration runs when the new container starts (prodMigrations, or
the start command), never in Coolify's pre-deployment command; docs and the log
line say so and point to deployment.md 4.3.
R2-3: requireSetup: null is the default. R2-4: the missing-column log line only
for a column error. R2-5, R2-6: the resetAccess example keeps the code check;
with guard: false the reset endpoint does not exist.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 20:18:47 +01:00
Radosław SmolińskiandClaude Fable 5.2 75a6f5209e 2FA setup required: review fixes (SR-1 to SR-9)
SR-1: /api/ipal/admin-icon sends the upload security headers (sandbox policy,
nosniff) with the bytes: an SVG is shown, never run. fetchPublicImage stops
reading at the size limit.
SR-2: requireSetup.exempt exempts only on exactly true; an async function, and a
windowHours that is not a number or false, stop the start.
SR-3: on Postgres / SQLite the missing column makes every login fail: the log
says so, the docs call the migration a required step of the same deploy, and
ipal-doctor reports a SQL project without it.
SR-4: an admin's reset also ends the account's sessions.
SR-5: the reset needs a session that entered its own TOTP code by default.
SR-6: the doctor's import-map rule covers TwoFactorStatusField and TwoFactorAlert.
SR-7: building blocks exported; dashboard notice, status field, setup notice and
the server-side image fetch can be switched off one by one.
SR-8: totpSetupFrom is on the 2FA collection whenever 2FA is on.
SR-9: both ways out of "every administrator is blocked" in security.md.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 19:32:34 +01:00
Radosław SmolińskiandClaude Fable 5.2 9d2ab43438 2FA setup required: the window of existing accounts starts once, at the first start after the upgrade
Owner's decision: for accounts that exist before the upgrade the 72 hours
count from the first start after it. The code already stamped them then; this
adds the tests that the moment is written once per account (a restart, two
instances starting at once, edits and logins do not move it; 71 h after it setup
is open, 73 h after it the account is blocked) and says so in the docs.

After the rebase on 1.16.5: tests that the setup-required notice and the stale
import-map notice both stand above the screen and never replace the code form,
and that requireSetup, safeBack and guard switch independently.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 18:56:07 +01:00
Radosław SmolińskiandClaude Fable 5.2 5d44ac3135 2FA screens: the brand image loads for a session that still owes its code; browser spec checks it
The tab icon endpoint answers with the image itself instead of a redirect
to the media file, and the logo components hand a session that owes its
2FA code (or has not set 2FA up) the picture fetched without credentials,
as an anonymous visitor gets it. Who can read media is unchanged; when the
file is not public or is larger than 512 KB the site name is used.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 18:46:32 +01:00
Radosław SmolińskiandClaude Fable 5.2 2aaaaa115a 2FA setup required: an account without TOTP reaches only setup, within a 72 h window
twoFactor.requireSetup (on by default with 2FA): an account of the 2FA
collection that has not set TOTP up is refused by ipal-kit's second-factor
check on every collection, global and plugin endpoint; the setup screen and
/api/setup-totp are all it reaches. It has 72 hours from its creation or
from an admin's reset (field totpSetupFrom, stamped by a hook); after that
setup is refused too until an admin reopens it.

Accounts that existed before get their window at the first start after the
upgrade (backfill in onInit), so nobody is blocked when a site upgrades.

Admin side: status and reset / 'Reopen setup' button on the account page
(TwoFactorStatusField), POST /api/ipal/two-factor/reset, a dashboard notice
(TwoFactorAlert), a notice on the setup screen; texts in English and Polish.
ipal-doctor reports blocked accounts and a switched-off mode.

Overridable: requireSetup false, windowHours (false / 0 = none), exempt for
a service account, resetAccess; the per-entity second-factor opt-out applies.
API keys, seeds, bearer-token routes and sites with twoFactor false are not
affected.

HTTP tests (REST, GraphQL, first admin on an empty database) run on SQLite,
Postgres and MongoDB; a browser test on the reference site covers the first
admin, a new editor and the admin's reset. Docs, guide, skills, changelog.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 18:46:32 +01:00
Radosław SmolińskiandClaude Opus 5.5 45d52c4690 1.16.5 upgrade notes
CI / check (push) Failing after 5m27s
CI / reference (push) Skipped
CI / reference-full (push) Skipped
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 17:50:25 +01:00
Radosław SmolińskiandClaude Opus 5.5 bef3a682b8 1.16.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 17:50:25 +01:00
Radosław SmolińskiandClaude Opus 5.5 f96b5c15d0 Merge claude/2fa-safe-back: the back link of the 2FA screens is checked on the server (twoFactor.safeBack)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 17:49:47 +01:00
Radosław SmolińskiandClaude Fable 5.2 3eee841dd0 ipal-doctor: the raw 2FA view warning only for a view component
R3-1: the warning fired on any mention of the 2FA package's setup / verify view
in the config, so it stayed after the fix its own text suggests (SafeTotpView
with the path as ipalTotpView, plus the path in admin.dependencies). It now
warns only when the path is a view's Component.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 17:49:06 +01:00
Radosław SmolińskiandClaude Fable 5.2 b2c1dca5da 2FA back link: the stale import-map notice never replaces the screen
R2-1: the notice was rendered instead of the 2FA screen, and its flag is a text
search of the importMap.js on disk — not the map in the build. A false alarm
(map generated in the build with the repository's file in the running image, a
re-exporting map) hid a working code form and locked everyone out. The notice
is now rendered above the screen, the log line says "may be", and the flag goes
to ipal-kit's own provider only.

R2-2: views are compared against copies, so a factory that reuses its view
objects is guarded too; copyViews, changedViewKeys, SAFE_TOTP_VIEW,
totpViewImportKey, findImportMapFile and missingImportMapEntries are exported;
ipal-doctor warns when the config registers the 2FA package's own view; docs
wording and a misplaced comment fixed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 16:35:16 +01:00
Radosław SmolińskiandClaude Fable 5.2 ad51456eaa 2FA back link: review fixes — views guarded by object, client views, a loud stale import map
SB-1: the 2FA package replaces a view that already stands under its keys, so a
key that existed before the factory ran was wrongly treated as the project's own
and left unguarded (also with a double registration, or ipalKit over its own
output). Views are now compared by object, right after the factory.

SB-2: SafeTotpView renders through Payload's RenderServerComponent: a client
component set as a 2FA view gets only client props plus the checked back.

SB-3: a production build with the previous import map shows an empty 2FA screen.
twoFactor.importMapCheck (on, production only) reads the committed map at start:
an error in the log and a message on the 2FA screens. Docs name the real symptom.

SB-4: enabled: false restores admin.dependencies; wrapTotpViews keeps exportName.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 16:16:39 +01:00
Radosław SmolińskiandClaude Fable 5.2 93e75426ab 2FA screens: the back link is checked on the server (twoFactor.safeBack)
@clocklimited/payload-2fa sends the browser to the `back` query value after a
valid code without checking it (GHSA-rffw-fq79-g3ch upstream, not fixed in the
fork): a prepared link ran script in the panel or left the site.

SafeTotpView now stands in front of the package's setup and verify views and
passes on a checked value: a path on the site's origin inside the admin route,
else the admin root. The package's views stay in the import map through
admin.dependencies, so ipal-kit still never imports the package.

twoFactor.safeBack: false turns it off, a function replaces the rule;
safeAdminBack, wrapTotpViews and SafeTotpView are exported. Projects with 2FA
must regenerate the admin import map.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 15:29:06 +01:00
Radosław SmolińskiandClaude Opus 5.5 39309c5c1c CHANGELOG 1.16.4: the verify limit counts every try; lockout from a sibling subdomain
CI / check (push) Failing after 5m29s
CI / reference (push) Skipped
CI / reference-full (push) Skipped
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 09:36:54 +01:00
Radosław SmolińskiandClaude Opus 5.5 d722157e20 1.16.4 upgrade notes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 09:35:08 +01:00
Radosław SmolińskiandClaude Opus 5.5 03443fd7ee 1.16.4
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 09:35:08 +01:00
Radosław SmolińskiandClaude Opus 5.5 f0f26393a3 Merge claude/security-fix-staff-check-2fa: staff checks only for staff collections; 2FA covers everything
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 02:26:56 +01:00
Radosław SmolińskiandClaude Fable 5.2 dc5326ea1c Review round 3: job-queue rules keep Payload's own defaults; a failed 2FA lookup fails closed
Job queue (R3-1): only a rule that exists is wrapped. At config time that
is what the project wrote; Payload fills in the rest when it builds the
config (3.94.1: run, queue and cancel are all defaultAccess, a logged-in
user) and the sweep of the running config wraps those. No default is
invented, so a request without a user gets what Payload itself answers.

hasTotp false while the account's record carries a TOTP secret (the 2FA
package's own lookup failed, R3-4): the account owes its code, not
'not set up yet'.

Docs: the two-configs-in-one-process case for calls without a source, and
that a half-logged-in editor's browser is refused media files.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 02:22:04 +01:00
Radosław SmolińskiandClaude Fable 5.2 c56f0d41b8 Security review round 2: no exception by name, staff list fails closed, verify limit
R2-1: the sweep skipped every collection whose slug starts with payload-,
so a plugin's payload-... collection added after ipalKit was never guarded.
There is no exception by name or prefix now: every collection and global
is guarded, Payload's own included, and the job queue's run / queue /
cancel rules too.

R2-2: role predicates called without a source fail closed where the staff
collections are not known (browser bundle, middleware, edge): nobody is
staff. They accept req.payload, a config (also the client config) or
{ staffCollections } as the source.

R2-3: the staff list is filed per config / Payload instance; a call without
a source gets only what every config in the process calls staff.

R2-4: payload.config is watched on the instance, so a config swapped in by
a dev reload is guarded before any request or Local API call.

R2-5: verify attempts are limited per account (default 5 in 10 minutes,
twoFactor.verifyLimit), counted in memory, never skipped.

R2-6: a user object without collection owes the second factor; endpoints
the 2FA package may add on collections or globals are guarded too; a
warning names staff collections that 2FA does not cover; docs state what
is not covered, fix the one-argument examples and the doctor example.

HTTP tests for each on payload-2fa beta.7, run on SQLite, Postgres and
MongoDB (test adapter added).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 01:46:25 +01:00
Radosław SmolińskiandClaude Fable 5.2 32faaa5e30 Security review fixes: staff collection first everywhere, 2FA package endpoints guarded, per-entity opt-out, hot reload
F1: roles count only for accounts of a staff collection, in every exported
predicate and access builder (isAdmin, isEditor, hasMinimumRole, adminOnly,
adminOrEditor, requireRole, adminOrSelf, adminOrSelfIn, the Field variants,
the roles field) and first in userMeetsRole. An account of another auth
collection with its own roles: ['admin'] gets nothing. Staff collections:
admin.user, access.authCollection, access.staffCollections. Predicates take
req.payload as an optional last argument and otherwise use the staff
collections of the config ipalKit built in this process.

F2: every endpoint @clocklimited/payload-2fa registers answers accounts of
the 2FA collection only (setup-totp wrote the secret into the 2FA collection
under the caller's id, whatever collection the caller came from); remove and
the admin reset/remove endpoints also need the second factor.

F3: per-entity opt-out honoured, operation by operation: the package's
custom.totp.disableAccessWrapper and ipal-kit's custom.ipal.secondFactor
(passed on to the package); the package's global disableAccessWrapper too.

F4: a no-user auth strategy on the 2FA collection guards the live config at
the start of each request, so entities from plugins listed after ipalKit
stay guarded after a dev hot reload and with disableOnInit.

Tests through HTTP for all four; the 2FA tests now run on payload-2fa
3.0.0-beta.7 (what client sites use), a second file on beta.1 (alias), and
the HTTP files can run against Postgres (IPAL_TEST_POSTGRES_URI). Docs,
agent guide, skills and changelog updated; the not-yet-enrolled limitation
is stated plainly.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 01:02:34 +01:00
Radosław SmolińskiandClaude Fable 5.2 97ee1289aa Reference smoke test: send the site origin so the login cookie counts; test typing
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 00:38:01 +01:00
Radosław SmolińskiandClaude Fable 5.2 0c61ac231b Security: staff checks only for staff collections; 2FA covers what the plugin adds
Staff check (userMeetsRole): the 'no roles field = every account passes'
rule applied to the account's own collection, so an account of a second
auth collection (customers) passed every staff check. It now applies only
to staff collections: the panel's login collection plus the new
access.staffCollections. The injected auth collection uses the new
adminOrSelfIn(slug), so an account of another collection with the same
numeric id is not 'self'.

2FA: @clocklimited/payload-2fa wraps the collections and globals present
when it runs; ipalKit's own globals and collections were added later and
stayed unwrapped, so a password without the TOTP code opened them over
REST and GraphQL. ipal-kit now has its own second-factor check
(secondFactorPassed / requireSecondFactor): applied to every collection
and global at the end of ipalKit, again in onInit for entities added by
plugins listed after it, and inside userMeetsRole and the endpoints that
take a project access function. It fails closed: an unrecognised user
shape is refused, and startup stops when the injected 2FA plugin lacks
the parts the check reads (twoFactor.guard: false opts out).

Tests through real HTTP requests (REST and GraphQL) against Payload's
route handlers, plus the reference smoke test. Docs, agent guide, skills
and the reference skills copy updated; changelog entry without a version.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-24 00:31:55 +01:00
Radosław SmolińskiandClaude Opus 5.5 bc1045a5b7 Merge claude/drift-decisions-1163: PAYLOAD_SECRET minimum in production, doctor seen in CI, create --external
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:09:26 +01:00
Radosław SmolińskiandClaude Opus 5.5 71fea221f1 Merge claude/docs-drift-1163: docs brought in line with the 1.16.3 code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:09:26 +01:00
Radosław SmolińskiandClaude Opus 5.5 0d8d906653 Comments: tab name Search engines, credit text, generateStaticParams scope
Comments and the ipal-kit usage line only (adds ipal-doctor); no behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:01:19 +01:00
Radosław SmolińskiandClaude Opus 5.5 b5df59691c ipal-kit create: a bare --external installs every external skill
Matches the help text and docs/project-starter.md; a list stays as given,
no flag leaves it to the answers. resolveExternal() + test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:01:19 +01:00
Radosław SmolińskiandClaude Opus 5.5 5cd0224ebd ipal-doctor: never write first-seen dates when CI is set
The CLI ignored CI (writeSeen was only !sites && !json); docs and comments
already said "not in CI". shouldWriteSeen() + test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:01:18 +01:00
Radosław SmolińskiandClaude Opus 5.5 36f8f69f82 ipalEnvRules: PAYLOAD_SECRET at least 32 characters in production
New option secretMinLength (default 32, 0 turns it off); checked only with
NODE_ENV=production. Docs: env table, deployment (what changing the secret
does, checked in Payload 3.94.1 and payload-2fa), AGENT.md, ipal-reference,
ipal-setup. Tests: short secret fails in production, passes in dev, 0 and a
custom minimum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:01:18 +01:00
Radosław SmolińskiandClaude Opus 5.5 40fed78da2 Docs: forms reject text over 5000 characters; Site settings update is editor+
(a) The code rejects an over-long value (kind 'too_long', validation text at
the field, answers kept); the limit is fixed. (c) Site settings update needs
the editor role; overridable with globalOverrides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 00:01:18 +01:00
Radosław SmolińskiandClaude Opus 5.5 37592764b5 Docs: fix doc/code drift found against 1.16.3 (docs only)
Verified the IAWL summary's "Doc/code" notes against the code and swept
CLI flags, option names/defaults and env vars. Fixed in the docs:
admin groups (consent-records, cookie-review → Privacy; Form messages
global → Forms), tab labels (More, Spam protection, E-mail sending,
Search engines; Sending method), construction field labels, {field} =
label, globalOverrides instead of "a plugin after ipalKit", enabled:false
keeps globals, pages role labels en+pl, switchLocalePath prefix,
accessibility cookie (necessary), seeding summary() shape, prepublishOnly
chain, doctor --strict --offline in the starter, package files list,
ipal-skills --external in PROGRAMISTA, DATABASE_URI (not _URL),
uploadsCollection exists, SiteProviders nonce, buildLinksField labels,
MCP list_pages limit wording, IPAL_DOCTOR_TOKEN in the env table; shipped
seo-check message "Search engines". Reference skills copy refreshed.

Open questions (not changed): forms over-long text, PAYLOAD_SECRET
length, Site settings update access, doctor seen in CI, bare
`ipal-kit create --external`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-23 23:47:35 +01:00
590 changed files with 38250 additions and 4536 deletions
+9 -9
View File
@@ -47,12 +47,12 @@ jobs:
- run: pnpm build
# file:.. + injected: the site gets a copy of the built plugin with its peers from the site (README.md)
- run: pnpm --dir reference install --frozen-lockfile --ignore-workspace
- run: pnpm --dir reference exec ipal-tokens --check
- run: pnpm --dir reference exec iapl-tokens --check
- run: pnpm --dir reference generate:importmap && git diff --exit-code reference/src/app
- run: pnpm --dir reference generate:types && git diff --exit-code reference/src/payload-types.ts
- run: pnpm --dir reference typecheck
# ipal-doctor (static, docs/doctor.md): the reference site is the zero-findings example — any unsilenced finding fails
- run: node bin/ipal-doctor.mjs reference --strict --offline
# iapl-doctor (static, docs/doctor.md): the reference site is the zero-findings example — any unsilenced finding fails
- run: node bin/iapl-doctor.mjs reference --strict --offline
# Full run on main (and before a release): MongoDB, seed, production build, smoke tests.
reference-full:
@@ -68,10 +68,10 @@ jobs:
DATABASE_URI: mongodb://127.0.0.1:27017/example-studiopl_dev
PAYLOAD_SECRET: ci-reference-secret-0123456789abcdef
NEXT_PUBLIC_SERVER_URL: http://localhost:3100
IPAL_IP_HEADER: x-forwarded-for
# cookieScanner.crawl → ipalEnvRules({ cookieCrawl }) requires both in production; CI never starts a crawl
IPAL_COOKIE_SCAN_URL: http://127.0.0.1:9/crawl
IPAL_COOKIE_SCAN_TOKEN: ci-cookie-scan-token-0123456789
IAPL_IP_HEADER: x-forwarded-for
# cookieScanner.crawl → iaplEnvRules({ cookieCrawl }) requires both in production; CI never starts a crawl
IAPL_COOKIE_SCAN_URL: http://127.0.0.1:9/crawl
IAPL_COOKIE_SCAN_TOKEN: ci-cookie-scan-token-0123456789
NEXT_PUBLIC_TURNSTILE_SITE_KEY: 1x00000000000000000000AA
TURNSTILE_SECRET_KEY: 1x0000000000000000000000000000000AA
ALLOW_LOCAL_MEDIA: '1'
@@ -98,8 +98,8 @@ jobs:
- run: pnpm --dir reference build
- run: pnpm --dir reference exec playwright install --with-deps chromium
- run: pnpm --dir reference test:e2e
# ipal-doctor (deep + HTTP): read-only database counts, the import map, the env rules, and the running site
# iapl-doctor (deep + HTTP): read-only database counts, the import map, the env rules, and the running site
- run: |
PORT=3100 pnpm --dir reference start &
for i in $(seq 1 60); do curl -sf http://localhost:3100/api/health >/dev/null && break; sleep 2; done
node bin/ipal-doctor.mjs reference --strict --offline --deep --url http://localhost:3100
node bin/iapl-doctor.mjs reference --strict --offline --deep --url http://localhost:3100
+2
View File
@@ -56,3 +56,5 @@ next-env.d.ts
# pnpm starter:gate work folder
.starter-gate/
.legacy-site-*/
.tmp-consent-upgrade-*
+16 -14
View File
@@ -1,13 +1,15 @@
# @intecion/ipal-kit
# IAPL (`@intecion/ipal-kit`)
Intecion Payload Advanced Library — a plugin for Payload CMS 3.
IAPL, the Intecion Advanced Payload Library — a plugin for Payload CMS 3. It was called ipal-kit before 1.17.0;
the package name, `@intecion/ipal-kit`, is unchanged, and every older name keeps working
([names table](./docs/agent/AGENT.md#names-iapl-and-ipal-kit)).
Provides internationalization (per-locale routing, hreflang, language switcher),
SEO (metadata, canonical, sitemap, robots), forms (Turnstile, rate limiting,
validation), consent management (consent mode), analytics (GA4/GTM), and a
blog/archive system (collections under an archive page, listing, pagination).
**Principle:** ipal-kit helps projects, never limits them — every module can be
**Principle:** IAPL helps projects, never limits them — every module can be
turned off on its own, every default (access, fields, hooks, labels, routes,
collections, globals) can be overridden and the project's config wins, and the
building blocks are exported, not only the finished features. Where the code
@@ -50,7 +52,7 @@ You *can* install straight from the repo
quick throwaway test it works. But prefer the registry for real projects:
- **Client components resolve correctly.** A git install unpacks into a
commit-hashed path (`.pnpm/@intecion+ipal-kit@git+https…#hash/…`) that breaks
commit-hashed path (`.pnpm/@intecion+IAPL@git+https…#hash/…`) that breaks
Next.js's React Client Manifest — the consent banner, analytics, and Turnstile
components fail at runtime with "Could not find the module … in the React
Client Manifest". The registry unpacks to a clean `node_modules/@intecion/…`
@@ -89,7 +91,7 @@ your project — in a version matching your Payload. The plugin accepts Payload
| `payload`, `@payloadcms/next`, `@payloadcms/ui`, `@payloadcms/richtext-lexical` | `^3.90.2` | already in a `create-payload-app` project |
| `next`, `react` | `>=15`, `^19.0.0` | already in a `create-payload-app` project |
| `@payloadcms/plugin-seo`, `@payloadcms/plugin-form-builder` | `^3.90.2` | **add these** |
| `@clocklimited/payload-2fa` | `^3.0.0-0` | optional peer, but **needed by default**: 2FA is enforced and `ipalKit()` throws at startup unless you pass `twoFactor: { issuer, plugin: payloadTotp }` (or opt out with `twoFactor: false`) |
| `@clocklimited/payload-2fa` | `^3.0.0-0` | optional peer, but **needed by default**: 2FA is enforced and `iapl()` throws at startup unless you pass `twoFactor: { issuer, plugin: payloadTotp }` (or opt out with `twoFactor: false`) |
| `@payloadcms/storage-s3` | `^3.90.2` | optional — only when media go to Cloudflare R2 ([docs/storage.md](./docs/storage.md)) |
```bash
@@ -115,19 +117,19 @@ placeholders also use the `sharp` you pass to `buildConfig({ sharp })`
**Working with an AI agent?** Run this right after installing (and after every upgrade):
```bash
pnpm exec ipal-skills
pnpm exec iapl-skills
```
It copies the `ipal-*` agent skills into `.agents/skills/` and adds a marked
`<!-- ipal-kit:start -->` block to `AGENTS.md` (plus a `CLAUDE.md` that imports it, if you
have none) pointing the agent at the full guide: `AGENT.md`, the `ipal-reference` skill
(every option, env var, route and export) and the `ipal-setup` skill. Only the text between
It copies the `iapl-*` agent skills into `.agents/skills/` and adds a marked
`<!-- iapl:start -->` block to `AGENTS.md` (plus a `CLAUDE.md` that imports it, if you
have none) pointing the agent at the full guide: `AGENT.md`, the `iapl-reference` skill
(every option, env var, route and export) and the `iapl-setup` skill. Only the text between
the markers is ever rewritten. `--no-pointer` skips that step. There is no `postinstall` script.
`pnpm exec ipal-skills --external` also adds a few well-known third-party skills as `ext-*` folders — Vercel's
`pnpm exec iapl-skills --external` also adds a few well-known third-party skills as `ext-*` folders — Vercel's
React best practices and composition patterns, Addy Osmani's accessibility skill, Anthropic's frontend-design
skill and the official Payload 3 skill. They are vendored into the package at pinned commits (text only, each
with its licence and source), so nothing is downloaded, and each starts with a note that ipal-kit's rules win.
with its licence and source), so nothing is downloaded, and each starts with a note that IAPL's rules win.
Pick some with `--external ext-accessibility,ext-payload`.
*Updating the pins (plugin maintainers):* change the commit in `scripts/vendor-external-skills.mjs`, run
@@ -164,7 +166,7 @@ clean working tree):
```bash
npm version patch # 1.0.0 → 1.0.1 (commit + tag)
npm publish # prepublishOnly runs: pnpm clean && pnpm build && pnpm test:int
npm publish # prepublishOnly runs: pnpm clean && pnpm build && pnpm build:starter && pnpm test:int && pnpm starter:gate
git push && git push --tags
```
@@ -194,7 +196,7 @@ Everything lives in the **[docs/](./docs)** directory. To get started:
| `404` on `pnpm add @intecion/...` | the `@intecion:registry` line is missing from `.npmrc` — the install went to public npm instead of Gitea |
| `Could not find the module … in the React Client Manifest` | installed from git, not the registry — reinstall from the registry (clean path) |
| two versions of `lucide-react` | your project uses a `lucide-react` outside the plugin's `^0.400.0` (= `0.400.x`) — align them |
| `[ipal] 2FA is enforced but no 2FA plugin was injected` | install `@clocklimited/payload-2fa` and pass `twoFactor: { issuer, plugin: payloadTotp }` |
| `[iapl] 2FA is enforced but no 2FA plugin was injected` | install `@clocklimited/payload-2fa` and pass `twoFactor: { issuer, plugin: payloadTotp }` |
| `missing secret key … to secure Payload` | `PAYLOAD_SECRET` isn't set in the runtime environment (not a plugin issue) |
If you get stuck, see **[docs/dev/PROGRAMISTA.md](./docs/dev/PROGRAMISTA.md)** or message the
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/env node
// iapl-blocks — the block library's command line.
// pnpm exec iapl-blocks list → the library blocks
// pnpm exec iapl-blocks eject faq → src/blocks/Faq/{config.ts,Component.tsx}
// pnpm exec iapl-blocks eject faq --dest src/blocks --dry-run
// Eject copies one block's source into the project, with its imports pointing at the
// package entries, so the project owns it: same slug and data shape, no migration.
// Then: use the ejected builder in Pages.layout instead of the library one, pass the ejected
// component as createBlockRegistry({ components: { faq: FaqBlock } }), record it in AGENTS.md.
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const args = process.argv.slice(2)
const [command, slug] = args
const dryRun = args.includes('--dry-run')
const destArg = args.indexOf('--dest')
const dest = resolve(process.cwd(), destArg >= 0 ? args[destArg + 1] : 'src/blocks')
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const libRoot = join(pkgRoot, 'src/modules/block-library')
const blocksRoot = join(libRoot, 'blocks')
if (!command || command === '--help' || command === '-h') {
console.log('Usage: iapl-blocks list | iapl-blocks eject <block> [--dest src/blocks] [--dry-run]')
process.exit(0)
}
const slugs = existsSync(blocksRoot) ? readdirSync(blocksRoot).sort() : []
if (command === 'list') {
console.log(slugs.join('\n'))
process.exit(0)
}
if (command !== 'eject' || !slug) {
console.error('Usage: iapl-blocks eject <block>')
process.exit(1)
}
if (!slugs.includes(slug)) {
console.error(`Unknown block "${slug}". Blocks: ${slugs.join(', ')}`)
process.exit(1)
}
/**
* Where an import inside the library goes in a project, by the file it points at.
* Config files (no React) take the Payload-side entries; components take /rsc and /client.
*/
const ROOT = '@intecion/ipal-kit'
const BLOCKS = '@intecion/ipal-kit/blocks'
const RSC = '@intecion/ipal-kit/blocks/rsc'
function target(file, isComponent) {
const rel = relative(join(pkgRoot, 'src/modules'), file).replace(/\\/g, '/').replace(/\.js$/, '')
if (rel.startsWith('block-library/')) {
const inner = rel.slice('block-library/'.length)
if (/^(define|fields|options|shared|types|faq|library|manifest|thumbnails)$/.test(inner)) {return BLOCKS}
return RSC // context, data, texts, ui/*
}
if (rel === 'lightbox/LightboxProvider' || rel === 'richtext/TableOfContents') {return '@intecion/ipal-kit/client'}
if (rel === 'forms/RenderForm' || rel === 'richtext/RenderRichText') {return '@intecion/ipal-kit/rsc'}
if (rel === 'richtext/headings') {return isComponent ? '@intecion/ipal-kit/rsc' : ROOT}
return ROOT
}
/** Rewrites relative imports to package entries and merges imports of the same entry. */
function rewrite(source, file) {
const isComponent = file.endsWith('.tsx')
const merged = new Map()
const body = source.replace(/^import (type )?\{([^}]*)\} from '(\.[^']+)'\n/gm, (_, type, names, spec) => {
const entry = target(resolve(dirname(file), spec), isComponent)
const key = `${type ? 'type ' : ''}${entry}`
const set = merged.get(key) ?? new Set()
for (const n of names.split(',').map((s) => s.trim()).filter(Boolean)) {set.add(n)}
merged.set(key, set)
return ''
})
const lines = [...merged].map(([key, set]) => {
const [type, entry] = key.startsWith('type ') ? ['type ', key.slice(5)] : ['', key]
return `import ${type}{ ${[...set].sort().join(', ')} } from '${entry}'`
})
return body.replace(/^((?:import [^\n]*\n)*)/, (head) => `${head}${lines.join('\n')}\n`).replace(/\n{3,}/g, '\n\n')
}
const folder = slug[0].toUpperCase() + slug.slice(1)
const outDir = join(dest, folder)
const files = readdirSync(join(blocksRoot, slug)).filter((f) => /\.(ts|tsx)$/.test(f))
for (const name of files) {
const from = join(blocksRoot, slug, name)
const to = join(outDir, name)
if (existsSync(to)) {
console.error(`skip ${relative(process.cwd(), to)} (exists — delete it first to eject again)`)
continue
}
const out = `// Ejected from @intecion/ipal-kit (block library: ${slug}). The project owns this file now.\n${rewrite(readFileSync(from, 'utf8'), from)}`
console.log(`${dryRun ? 'would write' : 'write'} ${relative(process.cwd(), to)}`)
if (!dryRun) {
mkdirSync(outDir, { recursive: true })
writeFileSync(to, out)
}
}
console.log(`\nNext: Pages.layout → the ejected build${folder}Block; registry → components: { ${slug}: ${folder}Block }; AGENTS.md → "Project decisions".`)
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env node
// iapl-doctor — checks a site against the IAPL team rules and lists every gap with a fix hint
// (docs/doctor.md). Static by default: reads files, writes nothing (except a first-seen date in
// iapl-doctor.json outside CI).
// pnpm exec iapl-doctor → this project, human-readable
// pnpm exec iapl-doctor --strict --offline → CI on a new site: any finding fails
// pnpm exec iapl-doctor --deep --url http://localhost:3000
// pnpm exec iapl-doctor --json > doctor.json
// pnpm dlx --package=@intecion/ipal-kit@latest iapl-doctor → the newest rules
// Exit: 0 ok · 1 findings · 2 could not run · 3 a rule crashed.
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
const { runDoctorCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'doctor', 'cli.js')).href)
process.exit(await runDoctorCli(process.argv.slice(2), { packageRoot: pkgRoot }))
+197
View File
@@ -0,0 +1,197 @@
#!/usr/bin/env node
// iapl-skills — copies the IAPL agent skills into the project.
// pnpm exec iapl-skills → ./.agents/skills/iapl-*
// pnpm exec iapl-skills --dry-run → show what would change
// pnpm exec iapl-skills --dest .claude/skills
// pnpm exec iapl-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone
// pnpm exec iapl-skills --external → also the vendored third-party skills (ext-*, pinned, text only)
// pnpm exec iapl-skills --external ext-accessibility,ext-payload → only those
// Only folders named iapl-* are touched; the project's own skills stay as they are.
// iapl-* folders that no longer exist in the package are removed (renamed/retired skills).
// Before 1.17.0 the skills were named ipal-*: the 16 folders of that set are removed by their
// exact names (LEGACY_SKILLS) — any other ipal-<something> folder is the project's own and stays.
// `ipal-skills` is the same command under its old name.
// ext-* folders are touched only with --external, and only those carrying IAPL's SOURCE.md.
// AGENTS.md (and CLAUDE.md) get a marked IAPL block pointing at the guide — only the
// text between the markers is ever rewritten; the project's own content stays as it is.
import { createHash } from 'node:crypto'
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const args = process.argv.slice(2)
if (args.includes('--help') || args.includes('-h')) {
console.log('Usage: iapl-skills [--dest <dir>] [--dry-run] [--no-pointer] [--external [ext-a,ext-b]]\nDefault dest: .agents/skills')
process.exit(0)
}
const dryRun = args.includes('--dry-run')
const pointer = !args.includes('--no-pointer')
const externalArg = args.indexOf('--external')
const externalPick = externalArg >= 0 && args[externalArg + 1] && !args[externalArg + 1].startsWith('-')
? args[externalArg + 1].split(',').map((n) => n.trim()).filter(Boolean)
: null
const destArg = args.indexOf('--dest')
const destValue = destArg >= 0 ? args[destArg + 1] : '.agents/skills'
// A missing value would resolve to cwd and remove every iapl-* folder there.
if (!destValue || destValue.startsWith('-')) {
console.error('iapl-skills: --dest needs a directory, e.g. --dest .claude/skills')
process.exit(1)
}
const dest = resolve(process.cwd(), destValue)
if (dest === resolve(process.cwd())) {
console.error('iapl-skills: --dest must be a subdirectory, not the project root')
process.exit(1)
}
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const src = join(pkgRoot, 'docs', 'agent', 'skills')
if (!existsSync(src)) {
console.error(`iapl-skills: no skills found in ${src} — is @intecion/ipal-kit installed with docs?`)
process.exit(1)
}
// Validate --external before anything is copied.
const extSrc = join(pkgRoot, 'docs', 'agent', 'external')
const manifest = externalArg >= 0 ? JSON.parse(readFileSync(join(extSrc, 'manifest.json'), 'utf8')) : { skills: [] }
const known = manifest.skills.map((skill) => skill.name)
const unknown = (externalPick ?? []).filter((name) => !known.includes(name))
if (unknown.length) {
console.error(`iapl-skills: unknown external skill(s): ${unknown.join(', ')} — available: ${known.join(', ')}`)
process.exit(1)
}
// The same list as LEGACY_SKILL_NAMES in src/modules/doctor/rules/legacy.ts (test/legacyNames.test.ts compares them).
const LEGACY_SKILLS = [
'audit', 'block', 'collection', 'consent-check', 'debug', 'doctor', 'form', 'locale-add',
'migrate-fields', 'nav', 'plugin-gap', 'reference', 'seo-check', 'setup', 'site', 'upgrade',
].map((name) => `ipal-${name}`)
const isDir = (base, name) => statSync(join(base, name)).isDirectory()
const isSkillDir = (base, name) => name.startsWith('iapl-') && isDir(base, name)
const shipped = readdirSync(src).filter((n) => isSkillDir(src, n))
const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : []
const retired = [
...existing.filter((n) => !shipped.includes(n)),
...(existsSync(dest) ? readdirSync(dest).filter((n) => LEGACY_SKILLS.includes(n) && isDir(dest, n)) : []),
]
if (!dryRun) mkdirSync(dest, { recursive: true })
for (const name of shipped) {
const action = existing.includes(name) ? 'update' : 'add '
console.log(`${action} ${name}`)
if (!dryRun) {
rmSync(join(dest, name), { recursive: true, force: true }) // drop files removed upstream
cpSync(join(src, name), join(dest, name), { recursive: true })
}
}
for (const name of retired) {
console.log(`remove ${name} (${LEGACY_SKILLS.includes(name) ? `now ${name.replace('ipal-', 'iapl-')}` : 'no longer in IAPL'})`)
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
}
console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`)
// Third-party skills, vendored into the package at pinned commits (docs/agent/external,
// scripts/vendor-external-skills.mjs). Nothing is downloaded here: every file is checked
// against manifest.json before it is copied.
if (externalArg >= 0) {
const MARK = 'Vendored by @intecion/ipal-kit'
const ours = (name) => existsSync(join(dest, name, 'SOURCE.md')) && readFileSync(join(dest, name, 'SOURCE.md'), 'utf8').includes(MARK)
const filesOf = (dir) => readdirSync(dir).flatMap((n) => (statSync(join(dir, n)).isDirectory() ? filesOf(join(dir, n)).map((f) => `${n}/${f}`) : [n]))
for (const skill of manifest.skills.filter((s) => !externalPick || externalPick.includes(s.name))) {
const from = join(extSrc, skill.name)
const files = filesOf(from).sort()
const tampered = files.filter((f) => skill.files[f] !== createHash('sha256').update(readFileSync(join(from, f))).digest('hex'))
if (tampered.length || files.length !== Object.keys(skill.files).length) {
console.error(`iapl-skills: ${skill.name} does not match manifest.json (${tampered.join(', ') || 'file list'}) — skipped`)
process.exitCode = 1
continue
}
if (existsSync(join(dest, skill.name)) && !ours(skill.name)) {
console.warn(`skip ${skill.name} (a folder of that name exists and is not from IAPL)`)
continue
}
console.log(`${existsSync(join(dest, skill.name)) ? 'update' : 'add '} ${skill.name} (${skill.publisher}, ${skill.license}, ${skill.commit.slice(0, 12)})`)
if (!dryRun) {
rmSync(join(dest, skill.name), { recursive: true, force: true })
cpSync(from, join(dest, skill.name), { recursive: true })
}
}
const retiredExt = existsSync(dest)
? readdirSync(dest).filter((n) => n.startsWith('ext-') && !known.includes(n) && ours(n))
: []
for (const name of retiredExt) {
console.log(`remove ${name} (no longer in IAPL)`)
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
}
}
// Pointer block: an agent opening the project must find the guide without being told.
// AGENTS.md is read by Codex/Cursor/Antigravity, CLAUDE.md by Claude Code (which also
// follows `@AGENTS.md` imports, so a CLAUDE.md that imports AGENTS.md needs no copy).
if (pointer) {
const START = '<!-- iapl:start -->'
const END = '<!-- iapl:end -->'
const OLD_START = '<!-- ipal-kit:start -->'
const OLD_END = '<!-- ipal-kit:end -->'
const version = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')).version
const skillsDir = relative(process.cwd(), dest).split('\\').join('/')
const block = [
START,
`## IAPL ${version} — agent guide`,
'',
'<!-- Managed by `pnpm exec iapl-skills` — edits between the markers are overwritten. -->',
'This project is built on `@intecion/ipal-kit` (a Payload CMS 3 plugin). Before you write code:',
'',
'1. Rules: `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md`.',
`2. Everything the plugin provides (options, env vars, routes, layout, hooks, collections, globals, every export): the \`iapl-reference\` skill — \`${skillsDir}/iapl-reference/SKILL.md\`.`,
`3. New project or missing foundation: the \`iapl-setup\` skill; a whole site: \`iapl-site\`. All skills: \`${skillsDir}/\`.`,
'4. Module details: `node_modules/@intecion/ipal-kit/docs/<module>.md`.',
'5. IAPL first: if the plugin has it, use it. Broken or not enough → report it with the `iapl-plugin-gap` skill and wait for the owner — no hand-built replacement, never patch `node_modules`.',
'6. Before you set up a site: ask the owner the architecture questions (AGENT.md "Ask before you build") and wait for the answers; record them under "Project decisions".',
'7. IAPL docs, this guide and the skills are in English; write rules, AGENTS.md entries and gap reports in English.',
END,
].join('\n')
const upsert = (file, { create }) => {
const path = join(process.cwd(), file)
const text = existsSync(path) ? readFileSync(path, 'utf8') : null
let next
if (text === null) {
if (!create) return
next = create === 'import' ? '@AGENTS.md\n' : `# ${file.replace('.md', '')}\n\n${block}\n`
} else if (text.includes(START) && text.includes(END)) {
next = text.slice(0, text.indexOf(START)) + block + text.slice(text.indexOf(END) + END.length)
// both blocks (an upgrade, a rollback whose installer added the old block again, an upgrade): the old one goes
if (next.includes(OLD_START) && next.includes(OLD_END)) {
next = (next.slice(0, next.indexOf(OLD_START)).replace(/\s*$/, '') + '\n\n' + next.slice(next.indexOf(OLD_END) + OLD_END.length).replace(/^\s*/, '')).replace(/\s*$/, '\n')
}
} else if (text.includes(OLD_START) && text.includes(OLD_END)) {
// the block written before 1.17.0: replaced where it stands, markers included
next = text.slice(0, text.indexOf(OLD_START)) + block + text.slice(text.indexOf(OLD_END) + OLD_END.length)
} else {
next = `${text.replace(/\s*$/, '')}\n\n${block}\n`
}
if (next === text) return console.log(`ok ${file}`)
console.log(`${text === null ? 'create' : 'update'} ${file}`)
if (!dryRun) writeFileSync(path, next)
}
upsert('AGENTS.md', { create: 'block' })
const claude = join(process.cwd(), 'CLAUDE.md')
const importsAgents = existsSync(claude) && /^@AGENTS\.md\s*$/m.test(readFileSync(claude, 'utf8'))
// CLAUDE.md that imports AGENTS.md already sees the block — don't duplicate it.
if (!importsAgents) upsert('CLAUDE.md', { create: 'import' })
}
// Skills ship .ts/.tsx templates and scripts. A Next tsconfig ("include": ["**/*.tsx"]) would
// type-check them as project code and break `tsc` / `next build` → they must be excluded.
const tsconfig = join(process.cwd(), 'tsconfig.json')
const top = relative(process.cwd(), dest).split(/[\\/]/)[0]
if (existsSync(tsconfig) && top && !top.startsWith('..')) {
const text = readFileSync(tsconfig, 'utf8')
const exclude = text.match(/"exclude"\s*:\s*\[([^\]]*)\]/)?.[1] ?? ''
const entries = [...exclude.matchAll(/"([^"]*)"/g)].map((m) => m[1].replace(/^\.\//, '').replace(/\/(\*\*)?$/, ''))
if (!entries.includes(top)) {
console.warn(`\n⚠ tsconfig.json does not exclude "${top}" — skill templates would be type-checked and break the build.`)
console.warn(` Add it: "exclude": ["node_modules", "${top}"]`)
process.exitCode = 1
}
}
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env node
// iapl-tokens — the brand's design tokens: src/design/tokens.ts → src/design/tokens.css,
// plus a WCAG contrast check (docs/design-tokens.md).
// pnpm exec iapl-tokens → write src/design/tokens.css, print the contrast report
// pnpm exec iapl-tokens --check → fail when the CSS is out of date (CI, iapl-doctor)
// pnpm exec iapl-tokens --in x.ts --out y.css --warn-only
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
const { runTokensCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'tokens', 'cli.js')).href)
process.exit(await runTokensCli(process.argv.slice(2)))
Executable
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env node
// iapl — the IAPL command line (also installed as `ipal-kit`, its name before 1.17.0, which `pnpm dlx @intecion/ipal-kit` runs).
// pnpm dlx @intecion/ipal-kit@<version> create intecion.com → a new client site (docs/project-starter.md)
// pnpm exec iapl create intecion.com --dir ../intecioncom-web --answers answers.json
// `pnpm dlx <package>` runs the bin named after the package, so every subcommand lives here.
// The other tools keep their own bins: iapl-skills, iapl-blocks, iapl-tokens, iapl-doctor.
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const USAGE = `Usage: iapl <command> [options]
create <domain> a new client site from the reference site (iapl create --help)
Other tools: iapl-skills, iapl-blocks, iapl-tokens, iapl-doctor`
const [command, ...args] = process.argv.slice(2)
if (command !== 'create') {
console.log(USAGE)
process.exit(command === undefined || command === '--help' || command === '-h' ? 0 : 1)
}
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
const { runCreateCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'starter', 'cli.js')).href)
process.exit(await runCreateCli(args))
+2 -101
View File
@@ -1,102 +1,3 @@
#!/usr/bin/env node
// ipal-blocks — the block library's command line.
// pnpm exec ipal-blocks list → the library blocks
// pnpm exec ipal-blocks eject faq → src/blocks/Faq/{config.ts,Component.tsx}
// pnpm exec ipal-blocks eject faq --dest src/blocks --dry-run
// Eject copies one block's source into the project, with its imports pointing at the
// package entries, so the project owns it: same slug and data shape, no migration.
// Then: use the ejected builder in Pages.layout instead of the library one, pass the ejected
// component as createBlockRegistry({ components: { faq: FaqBlock } }), record it in AGENTS.md.
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const args = process.argv.slice(2)
const [command, slug] = args
const dryRun = args.includes('--dry-run')
const destArg = args.indexOf('--dest')
const dest = resolve(process.cwd(), destArg >= 0 ? args[destArg + 1] : 'src/blocks')
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const libRoot = join(pkgRoot, 'src/modules/block-library')
const blocksRoot = join(libRoot, 'blocks')
if (!command || command === '--help' || command === '-h') {
console.log('Usage: ipal-blocks list | ipal-blocks eject <block> [--dest src/blocks] [--dry-run]')
process.exit(0)
}
const slugs = existsSync(blocksRoot) ? readdirSync(blocksRoot).sort() : []
if (command === 'list') {
console.log(slugs.join('\n'))
process.exit(0)
}
if (command !== 'eject' || !slug) {
console.error('Usage: ipal-blocks eject <block>')
process.exit(1)
}
if (!slugs.includes(slug)) {
console.error(`Unknown block "${slug}". Blocks: ${slugs.join(', ')}`)
process.exit(1)
}
/**
* Where an import inside the library goes in a project, by the file it points at.
* Config files (no React) take the Payload-side entries; components take /rsc and /client.
*/
const ROOT = '@intecion/ipal-kit'
const BLOCKS = '@intecion/ipal-kit/blocks'
const RSC = '@intecion/ipal-kit/blocks/rsc'
function target(file, isComponent) {
const rel = relative(join(pkgRoot, 'src/modules'), file).replace(/\\/g, '/').replace(/\.js$/, '')
if (rel.startsWith('block-library/')) {
const inner = rel.slice('block-library/'.length)
if (/^(define|fields|options|shared|types|faq|library|manifest|thumbnails)$/.test(inner)) {return BLOCKS}
return RSC // context, data, texts, ui/*
}
if (rel === 'lightbox/LightboxProvider' || rel === 'richtext/TableOfContents') {return '@intecion/ipal-kit/client'}
if (rel === 'forms/RenderForm' || rel === 'richtext/RenderRichText') {return '@intecion/ipal-kit/rsc'}
if (rel === 'richtext/headings') {return isComponent ? '@intecion/ipal-kit/rsc' : ROOT}
return ROOT
}
/** Rewrites relative imports to package entries and merges imports of the same entry. */
function rewrite(source, file) {
const isComponent = file.endsWith('.tsx')
const merged = new Map()
const body = source.replace(/^import (type )?\{([^}]*)\} from '(\.[^']+)'\n/gm, (_, type, names, spec) => {
const entry = target(resolve(dirname(file), spec), isComponent)
const key = `${type ? 'type ' : ''}${entry}`
const set = merged.get(key) ?? new Set()
for (const n of names.split(',').map((s) => s.trim()).filter(Boolean)) {set.add(n)}
merged.set(key, set)
return ''
})
const lines = [...merged].map(([key, set]) => {
const [type, entry] = key.startsWith('type ') ? ['type ', key.slice(5)] : ['', key]
return `import ${type}{ ${[...set].sort().join(', ')} } from '${entry}'`
})
return body.replace(/^((?:import [^\n]*\n)*)/, (head) => `${head}${lines.join('\n')}\n`).replace(/\n{3,}/g, '\n\n')
}
const folder = slug[0].toUpperCase() + slug.slice(1)
const outDir = join(dest, folder)
const files = readdirSync(join(blocksRoot, slug)).filter((f) => /\.(ts|tsx)$/.test(f))
for (const name of files) {
const from = join(blocksRoot, slug, name)
const to = join(outDir, name)
if (existsSync(to)) {
console.error(`skip ${relative(process.cwd(), to)} (exists — delete it first to eject again)`)
continue
}
const out = `// Ejected from @intecion/ipal-kit (block library: ${slug}). The project owns this file now.\n${rewrite(readFileSync(from, 'utf8'), from)}`
console.log(`${dryRun ? 'would write' : 'write'} ${relative(process.cwd(), to)}`)
if (!dryRun) {
mkdirSync(outDir, { recursive: true })
writeFileSync(to, out)
}
}
console.log(`\nNext: Pages.layout → the ejected build${folder}Block; registry → components: { ${slug}: ${folder}Block }; AGENTS.md → "Project decisions".`)
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-blocks.mjs'
+2 -16
View File
@@ -1,17 +1,3 @@
#!/usr/bin/env node
// ipal-doctor — checks a site against the ipal-kit team rules and lists every gap with a fix hint
// (docs/doctor.md). Static by default: reads files, writes nothing (except a first-seen date in
// ipal-doctor.json outside CI).
// pnpm exec ipal-doctor → this project, human-readable
// pnpm exec ipal-doctor --strict --offline → CI on a new site: any finding fails
// pnpm exec ipal-doctor --deep --url http://localhost:3000
// pnpm exec ipal-doctor --json > doctor.json
// pnpm dlx --package=@intecion/ipal-kit@latest ipal-doctor → the newest rules
// Exit: 0 ok · 1 findings · 2 could not run · 3 a rule crashed.
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
const { runDoctorCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'doctor', 'cli.js')).href)
process.exit(await runDoctorCli(process.argv.slice(2), { packageRoot: pkgRoot }))
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-doctor.mjs'
+2 -22
View File
@@ -1,23 +1,3 @@
#!/usr/bin/env node
// ipal-kit — the plugin's command line.
// pnpm dlx @intecion/ipal-kit@<version> create intecion.com → a new client site (docs/project-starter.md)
// pnpm exec ipal-kit create intecion.com --dir ../intecioncom-web --answers answers.json
// `pnpm dlx <package>` runs the bin named after the package, so every subcommand lives here.
// The other tools keep their own bins: ipal-skills, ipal-blocks, ipal-tokens.
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const USAGE = `Usage: ipal-kit <command> [options]
create <domain> a new client site from the reference site (ipal-kit create --help)
Other tools: ipal-skills, ipal-blocks, ipal-tokens`
const [command, ...args] = process.argv.slice(2)
if (command !== 'create') {
console.log(USAGE)
process.exit(command === undefined || command === '--help' || command === '-h' ? 0 : 1)
}
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
const { runCreateCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'starter', 'cli.js')).href)
process.exit(await runCreateCli(args))
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl.mjs'
+2 -175
View File
@@ -1,176 +1,3 @@
#!/usr/bin/env node
// ipal-skills — copies the ipal-kit agent skills into the project.
// pnpm ipal-skills → ./.agents/skills/ipal-*
// pnpm ipal-skills --dry-run → show what would change
// pnpm ipal-skills --dest .claude/skills
// pnpm ipal-skills --no-pointer → skills only, leave AGENTS.md / CLAUDE.md alone
// pnpm ipal-skills --external → also the vendored third-party skills (ext-*, pinned, text only)
// pnpm ipal-skills --external ext-accessibility,ext-payload → only those
// Only folders named ipal-* are touched; the project's own skills stay as they are.
// ipal-* folders that no longer exist in the package are removed (renamed/retired skills).
// ext-* folders are touched only with --external, and only those carrying ipal-kit's SOURCE.md.
// AGENTS.md (and CLAUDE.md) get a marked ipal-kit block pointing at the guide — only the
// text between the markers is ever rewritten; the project's own content stays as it is.
import { createHash } from 'node:crypto'
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const args = process.argv.slice(2)
if (args.includes('--help') || args.includes('-h')) {
console.log('Usage: ipal-skills [--dest <dir>] [--dry-run] [--no-pointer] [--external [ext-a,ext-b]]\nDefault dest: .agents/skills')
process.exit(0)
}
const dryRun = args.includes('--dry-run')
const pointer = !args.includes('--no-pointer')
const externalArg = args.indexOf('--external')
const externalPick = externalArg >= 0 && args[externalArg + 1] && !args[externalArg + 1].startsWith('-')
? args[externalArg + 1].split(',').map((n) => n.trim()).filter(Boolean)
: null
const destArg = args.indexOf('--dest')
const destValue = destArg >= 0 ? args[destArg + 1] : '.agents/skills'
// A missing value would resolve to cwd and remove every ipal-* folder there.
if (!destValue || destValue.startsWith('-')) {
console.error('ipal-skills: --dest needs a directory, e.g. --dest .claude/skills')
process.exit(1)
}
const dest = resolve(process.cwd(), destValue)
if (dest === resolve(process.cwd())) {
console.error('ipal-skills: --dest must be a subdirectory, not the project root')
process.exit(1)
}
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const src = join(pkgRoot, 'docs', 'agent', 'skills')
if (!existsSync(src)) {
console.error(`ipal-skills: no skills found in ${src} — is @intecion/ipal-kit installed with docs?`)
process.exit(1)
}
// Validate --external before anything is copied.
const extSrc = join(pkgRoot, 'docs', 'agent', 'external')
const manifest = externalArg >= 0 ? JSON.parse(readFileSync(join(extSrc, 'manifest.json'), 'utf8')) : { skills: [] }
const known = manifest.skills.map((skill) => skill.name)
const unknown = (externalPick ?? []).filter((name) => !known.includes(name))
if (unknown.length) {
console.error(`ipal-skills: unknown external skill(s): ${unknown.join(', ')} — available: ${known.join(', ')}`)
process.exit(1)
}
const isSkillDir = (base, name) => name.startsWith('ipal-') && statSync(join(base, name)).isDirectory()
const shipped = readdirSync(src).filter((n) => isSkillDir(src, n))
const existing = existsSync(dest) ? readdirSync(dest).filter((n) => isSkillDir(dest, n)) : []
const retired = existing.filter((n) => !shipped.includes(n))
if (!dryRun) mkdirSync(dest, { recursive: true })
for (const name of shipped) {
const action = existing.includes(name) ? 'update' : 'add '
console.log(`${action} ${name}`)
if (!dryRun) {
rmSync(join(dest, name), { recursive: true, force: true }) // drop files removed upstream
cpSync(join(src, name), join(dest, name), { recursive: true })
}
}
for (const name of retired) {
console.log(`remove ${name} (no longer in ipal-kit)`)
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
}
console.log(`${dryRun ? '[dry-run] ' : ''}${shipped.length} skill(s) → ${dest}`)
// Third-party skills, vendored into the package at pinned commits (docs/agent/external,
// scripts/vendor-external-skills.mjs). Nothing is downloaded here: every file is checked
// against manifest.json before it is copied.
if (externalArg >= 0) {
const MARK = 'Vendored by @intecion/ipal-kit'
const ours = (name) => existsSync(join(dest, name, 'SOURCE.md')) && readFileSync(join(dest, name, 'SOURCE.md'), 'utf8').includes(MARK)
const filesOf = (dir) => readdirSync(dir).flatMap((n) => (statSync(join(dir, n)).isDirectory() ? filesOf(join(dir, n)).map((f) => `${n}/${f}`) : [n]))
for (const skill of manifest.skills.filter((s) => !externalPick || externalPick.includes(s.name))) {
const from = join(extSrc, skill.name)
const files = filesOf(from).sort()
const tampered = files.filter((f) => skill.files[f] !== createHash('sha256').update(readFileSync(join(from, f))).digest('hex'))
if (tampered.length || files.length !== Object.keys(skill.files).length) {
console.error(`ipal-skills: ${skill.name} does not match manifest.json (${tampered.join(', ') || 'file list'}) — skipped`)
process.exitCode = 1
continue
}
if (existsSync(join(dest, skill.name)) && !ours(skill.name)) {
console.warn(`skip ${skill.name} (a folder of that name exists and is not from ipal-kit)`)
continue
}
console.log(`${existsSync(join(dest, skill.name)) ? 'update' : 'add '} ${skill.name} (${skill.publisher}, ${skill.license}, ${skill.commit.slice(0, 12)})`)
if (!dryRun) {
rmSync(join(dest, skill.name), { recursive: true, force: true })
cpSync(from, join(dest, skill.name), { recursive: true })
}
}
const retiredExt = existsSync(dest)
? readdirSync(dest).filter((n) => n.startsWith('ext-') && !known.includes(n) && ours(n))
: []
for (const name of retiredExt) {
console.log(`remove ${name} (no longer in ipal-kit)`)
if (!dryRun) rmSync(join(dest, name), { recursive: true, force: true })
}
}
// Pointer block: an agent opening the project must find the guide without being told.
// AGENTS.md is read by Codex/Cursor/Antigravity, CLAUDE.md by Claude Code (which also
// follows `@AGENTS.md` imports, so a CLAUDE.md that imports AGENTS.md needs no copy).
if (pointer) {
const START = '<!-- ipal-kit:start -->'
const END = '<!-- ipal-kit:end -->'
const version = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')).version
const skillsDir = relative(process.cwd(), dest).split('\\').join('/')
const block = [
START,
`## ipal-kit ${version} — agent guide`,
'',
'<!-- Managed by `pnpm exec ipal-skills` — edits between the markers are overwritten. -->',
'This project is built on `@intecion/ipal-kit` (a Payload CMS 3 plugin). Before you write code:',
'',
'1. Rules: `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md`.',
`2. Everything the plugin provides (options, env vars, routes, layout, hooks, collections, globals, every export): the \`ipal-reference\` skill — \`${skillsDir}/ipal-reference/SKILL.md\`.`,
`3. New project or missing foundation: the \`ipal-setup\` skill; a whole site: \`ipal-site\`. All skills: \`${skillsDir}/\`.`,
'4. Module details: `node_modules/@intecion/ipal-kit/docs/<module>.md`.',
'5. ipal-kit first: if the plugin has it, use it. Broken or not enough → report it with the `ipal-plugin-gap` skill and wait for the owner — no hand-built replacement, never patch `node_modules`.',
'6. Before you set up a site: ask the owner the architecture questions (AGENT.md "Ask before you build") and wait for the answers; record them under "Project decisions".',
'7. ipal-kit docs, this guide and the skills are in English; write rules, AGENTS.md entries and gap reports in English.',
END,
].join('\n')
const upsert = (file, { create }) => {
const path = join(process.cwd(), file)
const text = existsSync(path) ? readFileSync(path, 'utf8') : null
let next
if (text === null) {
if (!create) return
next = create === 'import' ? '@AGENTS.md\n' : `# ${file.replace('.md', '')}\n\n${block}\n`
} else if (text.includes(START) && text.includes(END)) {
next = text.slice(0, text.indexOf(START)) + block + text.slice(text.indexOf(END) + END.length)
} else {
next = `${text.replace(/\s*$/, '')}\n\n${block}\n`
}
if (next === text) return console.log(`ok ${file}`)
console.log(`${text === null ? 'create' : 'update'} ${file}`)
if (!dryRun) writeFileSync(path, next)
}
upsert('AGENTS.md', { create: 'block' })
const claude = join(process.cwd(), 'CLAUDE.md')
const importsAgents = existsSync(claude) && /^@AGENTS\.md\s*$/m.test(readFileSync(claude, 'utf8'))
// CLAUDE.md that imports AGENTS.md already sees the block — don't duplicate it.
if (!importsAgents) upsert('CLAUDE.md', { create: 'import' })
}
// Skills ship .ts/.tsx templates and scripts. A Next tsconfig ("include": ["**/*.tsx"]) would
// type-check them as project code and break `tsc` / `next build` → they must be excluded.
const tsconfig = join(process.cwd(), 'tsconfig.json')
const top = relative(process.cwd(), dest).split(/[\\/]/)[0]
if (existsSync(tsconfig) && top && !top.startsWith('..')) {
const text = readFileSync(tsconfig, 'utf8')
const exclude = text.match(/"exclude"\s*:\s*\[([^\]]*)\]/)?.[1] ?? ''
const entries = [...exclude.matchAll(/"([^"]*)"/g)].map((m) => m[1].replace(/^\.\//, '').replace(/\/(\*\*)?$/, ''))
if (!entries.includes(top)) {
console.warn(`\n⚠ tsconfig.json does not exclude "${top}" — skill templates would be type-checked and break the build.`)
console.warn(` Add it: "exclude": ["node_modules", "${top}"]`)
process.exitCode = 1
}
}
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-skills.mjs'
+2 -12
View File
@@ -1,13 +1,3 @@
#!/usr/bin/env node
// ipal-tokens — the brand's design tokens: src/design/tokens.ts → src/design/tokens.css,
// plus a WCAG contrast check (docs/design-tokens.md).
// pnpm exec ipal-tokens → write src/design/tokens.css, print the contrast report
// pnpm exec ipal-tokens --check → fail when the CSS is out of date (CI, ipal-doctor)
// pnpm exec ipal-tokens --in x.ts --out y.css --warn-only
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..')
const { runTokensCli } = await import(pathToFileURL(join(pkgRoot, 'dist', 'modules', 'tokens', 'cli.js')).href)
process.exit(await runTokensCli(process.argv.slice(2)))
// The path this command had before 1.17.0 (scripts and skills of older projects call it by path). Removed in 2.0.
import './iapl-tokens.mjs'
+112
View File
@@ -0,0 +1,112 @@
# Changelog of the wire contract
## 1.7.1 — 2026-11-25 (not released; no tag yet)
Wording only; nothing for a client to change, and a copy of 1.7.0 need not be refreshed for it.
- **1.7.0 is required, not optional.** A client of 1.6 or older gets `400 invalid-request` on every request
that carries a token, because it does not send `X-Intecion-Site`. By the rule for development versions (§9)
it was numbered as a minor; read it as a breaking step. No client of 1.6 or older was released.
## 1.7.0 — 2026-11-25 (never released)
From the independent review of the first client. What a client built against 1.6.0 has to change is marked.
- **New, required: the header `X-Intecion-Site: <own host>` on every request that carries a token.** Missing:
`400 invalid-request`. Not the token's host: the new code **`403 host-mismatch`** (forget the token, enrol as
yourself). **Client: send the header; handle the code.** All examples with a token carry it; two new
examples (`send-host-mismatch`, `status-no-site-header`).
- **A client stores the host with the token and compares it with its own before use**, and compares the `host`
of `/v1/status` (§8, checklist 3). **Client: add the check.**
- **The confirm endpoint's limiter counts only refused calls**, after the nonce was looked up; never by the
caller's address first (§2). **Client: check the order.**
## 1.6.0 — 2026-11-25 (never released)
From the first client built against the contract (IAPL's). **The service did not change**; these are the
contract's words. What a client built against 1.5.0 has to change is marked.
- **An answer that is not the service's JSON** is no longer "like `503 unavailable`" for the report: with a
status from 400 to 499 it is *not sent*, with any other status (200 included) *not confirmed*.
**Client: change the report for that case.** Retrying it is as before.
- **A client that cannot keep key and bytes** (§1): no retry by itself after the report; a repeat by a person
is a new message; keys derived from the message's record are described, and for such a key
`idempotency-conflict` means "already handled". **Client: nothing must change; derived keys are an option.**
- **A site with a hand-issued token** does not enrol on `reverify` / `invalid-token`; it reports
`relay-refused` and what to ask Intecion for. **Client: nothing, if it already does this.**
- **`Origin` / `Sec-Fetch-Site`:** a client sends neither; said in §1. **Client: nothing for Node.**
- A stand-in need not reproduce the service's lists; said in §10.
## 1.5.0 — 2026-11-25 (never released)
After the third review.
- `new-recipients`: `account` mail is outside it; a form's confirmations may use four fifths of it.
- Failed sends: those in flight are counted in.
- Wording: `backend-failed`, `internal` and unknown codes mean "probably not sent"; the checklist asks a client
to limit "forgot password" itself.
## 1.4.0 — 2026-11-25 (never released)
After the second review.
- **Limits by kind:** `security-alert` has a budget of its own (`limit: "alerts"`, `limits.securityAlertsPerDay`)
outside hour and day; `account` mail may use the whole hour and day, every other kind four fifths. The
`quota` of a send answer is for that kind. `recipient` counts `form-confirmation` messages only.
- **The idempotency promise is now what the service does:** a key whose message was handed to the mail back end
is never sent again within 24 hours; when the result was not recorded it answers `in-progress` until then.
- **Failed sends** have a limit of their own: `429 rate-limited` after 60 in an hour.
- **Retrying:** three attempts, 30 seconds each, ten seconds of waiting in all; an enrolment on the way does
not count.
- **Subject:** U+200D, U+200C and U+00AD are allowed; everything else as before, with the rule a client strips by.
- Any mail of a site to Intecion's own address gets `[host]` in front of its subject.
- The confirm address: no redirect is followed — the usual causes and what to do; `given.quota` gains
`hour-share-used`.
## 1.3.0 — 2026-11-25 (never released)
- **The confirm path is fixed per product** (owner, 2026-11-25): `iapl` → `/api/iapl/mail-relay/confirm`,
`iawl` → `/?rest_route=/iawl/v1/mail-relay/confirm`. **`callbackPath` is gone from the enrolment request**
(a request that carries it is refused). A site that serves its API elsewhere has its path set by Intecion.
- Suppression is account-wide and stays so (owner, 2026-11-25): said in the code table.
## 1.2.0 — 2026-11-25 (never released)
After the first independent review. The wire format is the same; the text now has one reading where it had two.
- **Retrying:** at most three attempts in ten seconds, and the ten seconds win over `retryAfter`; "no answer"
and `in-progress` are reported as *not confirmed*, never as *not sent*.
- **Idempotency:** "the same body" is the same bytes; a client encodes a message once.
- **The confirm endpoint:** exactly `200` and the JSON object, at most 1024 bytes, within 8 seconds; the site
keeps its earlier token until `/v1/enrol` answers 200.
- **An answer that is not JSON** is `unavailable`, retryable.
- `Authorization: Bearer` in any case.
- **Schema:** `code` and `warnings` are open strings (new ones are minor changes); `to` is required unless the
kind is `security-alert`; recipients' `maxItems` is the service's bound, the site's limit is in `/v1/status`;
base64 is padded to a multiple of four (said in words: a pattern for it overflows on large files); lengths are
in code points.
- **Changed behaviour:** the per-recipient limit refuses `form-confirmation` only; a subject may not start with
the service's name in brackets; a `security-alert` gets the site's host in front of its subject;
`attachment-refused` names the file in `field` (suggested status `relay-attachment-refused`);
invisible characters (all of Unicode category Cf) are refused in subject and file names.
- Added: `limits.serverAddresses` in `/v1/status`; what happens beyond it.
- Before the first release tag, versions are development versions (§9).
## 1.1.0 — 2026-11-25 (never released)
- **The base address is `https://webservices.intecion.net/mail`**: one host for Intecion's web services, this
one under the path `/mail`. Paths in the contract are relative to the base address, as before; a client that
kept the base address as one constant changes that constant and nothing else.
- Added: `service.name` in the answer of `/v1/status` ("Intecion Notifications Webservice").
- The service sends from `[email protected]` (owner, 2026-11-25).
Minor, by the contract's own rule (§9): an answer field was added. No copy of 1.0.0 was released; a client that
copied it during development copies the folder again.
## 1.0.0 — 2026-11-25 (never released)
First version: `/v1/enrol` with the call-back and its confirmation, `/v1/send`, `/v1/status`, `/v1/rotate`,
`/v1/revoke`, `/health`; the error codes; the examples and the runner.
Differs from the design proposal (draft 4) in one visible point: the site's confirm endpoint answers `200` with
a `confirmation` (SHA-256 of nonce and token), not a bare `204`. Reason: `services/mail-relay/DECISIONS.md`, D1.
+64
View File
@@ -0,0 +1,64 @@
3d5c4b7ed53fe6fe2c7c28826c0cf666f9c1d0b79f861b404503e7029728a61f README.md
53da77d5dfff9948d68fca26b828563e21f83418245053d78b03a5aecac6c1d1 CHANGELOG.md
249182a01164b81a5f7af87e5c5cdbd3344a80a7a66dfca624cecfb1501b2420 VERSION
2ff0ad5b6a245365c0fa8733fa17b7bbd3ab91d4825981709d0fd02b762b939f schema.json
9d8381d2e3465e97dc801a61f598fcf822e27e73a2c0729877744ec307097910 runner.mjs
7c46860adee597e570832c72bcdb418752a20b9f7d1b2d7a656ed065f9632b2a checksums.mjs
df6015faf02a7cf7e9b5816b9e22b2e82968678ddd72a61c1f9665a8c0897ddf examples/callback-confirm-wordpress.json
f5018ca4fb7d25794ee92168d715aaf47feeba3d907c0550651b16c10a691ceb examples/callback-confirm.json
27bd95712cc36a71519cddc52c03d857b1009c2c384940dbc052022d86bc4231 examples/callback-unknown-nonce.json
de693b060c10c3d0f88fb8edfcd38c491cf141628d747328beee1b50c700c19b examples/enrol-address-literal.json
7c4cf75eb9ab156a3031336ab2688e7c9dcd4cd266b7b7e5e4592285dcbd25ba examples/enrol-callback-no-content.json
64466afc5bf0fecfa36f986d973cd987bbe1f64867e01cdf35e0de40838eb0d1 examples/enrol-callback-not-found.json
0000bcb2b3b676e4fda6c30b8de6e062c88f98c1fa2cc9f75bcd350d65dc0db4 examples/enrol-callback-path-given.json
8b522f16bc9b9980a5c849e94cea35fb268b0ba664dcd5a2e8e0fedd67c2c034 examples/enrol-callback-redirect.json
1e6483ebd85e3851848357266d8e16628a70420428b30d3ddb15253cdc2d9a0d examples/enrol-callback-wrong-confirmation.json
f64e4c75ced60e70b0f2f8e16adbde151be888fe5ac75813cdbe7eb5ecf8a00b examples/enrol-from-browser.json
218f463c95fd79868916390d4616c796d66154398a9864615f9ad0768f801aff examples/enrol-listed-active.json
b628eb5b30e693767e6830de58e0fd172497336f67b76a49a5fb06bfa626c481 examples/enrol-localhost.json
93304590382de5153a47fa88ee98356d0a5ba8039e195959291acd3c33e4a406 examples/enrol-short-nonce.json
e86e6ab23088c1c985ba18f287f66b49c50f51a584a7ca679b8b768597130efd examples/enrol-suspended.json
fe38f1fd1394a7fd42b1a1b0b74aa604578f17ab52590bf95a462a0c0f7d6087 examples/enrol-unlisted-pending.json
b9f71fe993dc39bdbc07e775e925a37175e18e1682fd8bffcc72b3581919be17 examples/health.json
5dff4194764f6f61b01a3f7f504907e578306a486d214e22d1a70b1a207e5ca3 examples/not-found.json
94943f85503cd891f1fb6f0258ab97b2eb48ec10e5f7ea233d349d4da97b8a1b examples/revoke-ok.json
1b467eac1040d56369276e5b8c12540a84942c8b7e3c2e458fc8da5b4f027c86 examples/rotate-ok.json
348f96a160c168797ab27ff0739b17df1762cc2ffdd72cb0a2b3ec2c695093bc examples/rotate-previous-token.json
39774a2ce0434dc791d79f9efb4b14f23203b7e8d58138acc7654265a875609b examples/send-attachments-too-large.json
75ec4de22780b36b41f198f065e38937beb4a50879fd204e080bdb935c2b5e8f examples/send-backend-failed.json
e3331a33604c2239c91c889d3dd338e473fd9b5d80fccb84a39491810bcceac0 examples/send-bearer-any-case.json
26f4f8a2929d132598bcb87e813616cef7b6277249c657cc618f4ede4cb4d906 examples/send-day-quota.json
660dbe2a747686077788f46fe45f269c3eb57e4579225979f91841e9f00fae7b examples/send-display-name-recipient.json
1c6bd0ed454f51acf545f0213fe6108f3639af975fb0751ef8d23bd92da9d4c7 examples/send-executable-attachment.json
ed6869754e418cc5e2a809e52a0242680d79f1bbc2eedd391de04375f29f7b9a examples/send-from-browser.json
e39d197f857b56103726b0f165c67a3476a06207961a59c6f6a1cf333bc3e7e9 examples/send-from-field.json
5c826cd0c297c773510ce37b66a0f6a6425e6282abc1ad30094fd5b545ae9193 examples/send-headers-field.json
3918635b33b32783db96ae17ebbd4296d2deca05d092b55573c574be172601ec examples/send-host-mismatch.json
a6809a8d475106f8e31ba432e56b46e9bf8683a0eca9d62378b1392cd6c44305 examples/send-hour-quota-account.json
c46852c9d9fc7eb83ac6bc3ca2a7c5b79100d2cae93a5cee6720b702b4c22490 examples/send-hour-quota.json
dc0f9c1c946d256aded0de70588c1d1f95740d333b234127f9bce8a4ed8beefb examples/send-key-reused.json
69edbf23c9723337f6327484e587b8cb7603c23e4b4954ebd275a0a794171325 examples/send-no-sender-name.json
bcbf5adcd0c224edb81c3b4188f261252835f715f541030db10432fa7ebd71a4 examples/send-no-token.json
32125ac9ff5460991633cce55febcb310247ca518eae7c650ef634e3f86376e0 examples/send-ok.json
7d8b14d372730f013ee7192021dda68859f779337b8d535bc564ac955a00e325 examples/send-pending.json
e3bbb041217d0a4f378285c06584a093d5e808d223d564e735c559f461fae8b8 examples/send-previous-token.json
53132e3e2177937dc2a35f7fe87f2f383f45ab001fc0306490941b44bb466e3c examples/send-recipient-quota-other-kinds.json
aff454882faab57d4a697be7250fdbac0272bcc2e0c099a6a27c50e0a980ac70 examples/send-recipient-quota.json
d514bc65a75f522389c90f1239d9afa43d96c7c2e7bd31fe0e85dd4c9d543ebd examples/send-recipient-suppressed.json
eb68d83a8d582a3722bf99330246d3d641e49a53e08bbe48e04e09a970cbb866 examples/send-replay.json
189dbdb3df1f0da0b6a1e8fdd0e90babf9dbfe9cfcaeb423ba24e2d59802b663 examples/send-security-alert.json
f299bc4f5193de0619d78551653a0b133a4ae5774dba93b23812b689a074a87d examples/send-sender-name-replaced.json
39a09b2bd01fc12d0e8cb2f93b71b24f31a4f2d0f639fe93b6bf37a7357be0ae examples/send-subject-direction-mark.json
ce4cbea2306f73bd5905249c10ab451a2599cb779e2386828971f40c97b8c591 examples/send-subject-imitates-service.json
247619f5575e898bd558ff7f7674f241c39f3a1e0ae51f589eb6a6dc2fe21e2b examples/send-subject-line-break.json
59175981e46a6f782ce3b4ed9c885699d7766823d660e5a524e89a4f2c6c459a examples/send-subject-visitor-text.json
987a2b4433161b4f2a6502d0487bf18f512f7a630a930ac66b1038cd6e000dc3 examples/send-suspended.json
91cd894526eef28e4dfb2456e476ba0be381e6d621ea833761cc9c63fe247e03 examples/send-text-plain.json
9c6278fcb13d7e06e0dd38ef34eba1abfbcb9c75100994b93c1c5a5444c35f85 examples/send-to-intecion-marked.json
1a1faf5a451220a35f2f0d66bb906e0d9944ed0a71c8209e07da419734a82567 examples/send-too-many-recipients.json
43d04c99549a4fe3c64af6f68b598299e92486af5a52432a2c93c3f9564f7959 examples/send-unknown-address.json
28e05f3c53cab6433b6af4d425511fa6655d0673df2e840af1fed9d25294a123 examples/send-unknown-token.json
f105c38ab11ab5fc508ba0ed3f23f69108c318765c2670029b230b5b9a83912a examples/status-active.json
89009ee9ab8f38e9ec290fb5412f206e1be28ad10fce6a7071d4406ac52dd4f0 examples/status-no-site-header.json
c9f49fa0dae1f0beacaacfe01660b467d06f990228c35a653307c8793f3c97a5 examples/status-pending.json
afdb07ba8279479b6bbfdc4289efda657d4e5a9eccd94b8de165ec728b4a2386 examples/status-unknown-address.json
+540
View File
@@ -0,0 +1,540 @@
# Intecion Notifications Webservice — wire contract
Version: see [`VERSION`](VERSION) (this text describes **1.7.1**). Path prefix of this major version: `/v1`.
This is the whole agreement between the Intecion Notifications Webservice ("the service" below) and a client (the mail transport built into a
site's plugin). It names no product: nothing here says Payload, WordPress, IAPL or IAWL except the values of
the `product` field. A client written from this document, in any language, works with the service.
| File | What |
|---|---|
| `README.md` | This document. Where it and the schema disagree, the schema wins and that is a bug to report |
| `schema.json` | JSON Schema (2020-12) of every body, under `$defs` |
| `examples/*.json` | One request and its answer per file, with the state it needs. They are the contract tests |
| `runner.mjs` | Runs the examples against anything that speaks the contract. No dependency; works in Node and in the Workers runtime |
| `checksums.mjs`, `CHECKSUMS` | SHA-256 of every file above, to detect a hand-edited copy |
| `VERSION`, `CHANGELOG.md` | Semantic version of the contract and what changed |
## 1. Basics
- **Base address: `https://webservices.intecion.net/mail`** — a client keeps it as one constant, host and path
together. Every path in this document and in the examples is relative to it: `POST /v1/send` is
`POST https://webservices.intecion.net/mail/v1/send`, `GET /health` is `…/mail/health`. A client joins the
base address and the path as text; it never resolves a path against the host alone.
- HTTPS only. Bodies are JSON in UTF-8. A request with a body carries `Content-Type: application/json`.
- **The service is for servers, not browsers.** It sends no CORS header, and it refuses any request that
carries an `Origin` header or a `Sec-Fetch-Site` header other than `none` (`403 browser-not-allowed`).
A client must send neither. A server runtime's `fetch` that adds them by itself has to be told not to, or the
header removed, or the service will take the site for a browser. (`Sec-Fetch-Mode` and `Sec-Fetch-Dest` are
not looked at: Node's `fetch` sends `sec-fetch-mode: cors` and passes.)
- **Requests are closed:** an unknown field is refused with `400 invalid-request` and the field's name. A
client cannot set `From`, `Sender`, `Return-Path` or any free header — there are no such fields.
- **Answers are open:** a client ignores fields it does not know.
- A client identifies itself with `User-Agent: <product>/<version>` (not checked, used for the log).
- **An answer that is not the service's JSON** — an error page of the network in front of the service, an empty
body, a cut-off answer — is no answer of the service. The client may retry it (as if `retryable` were true),
and what it means for a message depends on the status alone:
- status **400 to 499**: the request was turned away before the service handled it — **not sent**;
- **any other status, `200` included**: the service may have handled the request and only its answer was
lost — **not confirmed**, exactly like no answer at all (§1, "Retrying").
### Answers
Success is status `200` and a body with `"ok": true`.
Every refusal has the same body ([`Error`](schema.json)) — with one exception: `/health` answers only
`{ "ok": false }`.
```json
{ "ok": false, "code": "quota-exceeded", "message": "…", "retryable": false, "limit": "hour", "retryAfter": 1260 }
```
- `code` is what a client acts on. `message` is English text for a log or an administrator; never show it to a visitor.
- **`retryable` decides whether to try again, not the status.** `429 quota-exceeded` is not retryable;
`429 rate-limited` is.
- `retryAfter` (seconds) is also sent as the `Retry-After` header.
- The list of codes grows with minor versions. A client that meets a code it does not know acts on `retryable`
and shows the `message` to an administrator.
### All codes
| Status | `code` | Meaning | Retry | What a client does | Suggested site status |
|---|---|---|---|---|---|
| 400 | `invalid-request` | Body, header or field is wrong; `field` names it | no | Report a bug | — |
| 401 | `invalid-token` | No token, or one the service does not know (unknown, expired, revoked) | no | Enrol again, then send once more (§2, "Which token") | — |
| 401 | `reverify` | The token is good but comes from a server address the service has not seen for this site | no | Enrol again (the same call-back), then send once more | — |
| 403 | `site-pending` | Enrolled, waiting for approval by Intecion | no | Keep the token; show "waiting for approval" | `relay-pending` |
| 403 | `site-suspended` | Stopped by Intecion | no | Keep the token; show it; do not enrol again | `relay-suspended` |
| 403 | `host-not-allowed` | Enrolment: the host is not a public DNS name | no | Show it (a local or private site cannot use the service) | `relay-refused` |
| 403 | `enrolment-closed` | Enrolment is closed for this product, or altogether | no | Show it | `relay-refused` |
| 403 | `host-mismatch` | The token is good and comes from a known address, but the request's `X-Intecion-Site` names another site than the token's | no | Forget the token (it is another site's — a copied database, a token pasted into the wrong site), enrol as your own host, then send once more | — |
| 403 | `browser-not-allowed` | The request came from a browser | no | — | — |
| 404 | `not-found` | No such route | no | Report a bug | — |
| 405 | `method-not-allowed` | Wrong method | no | Report a bug | — |
| 409 | `enrolment-in-progress` | Another enrolment for this host is running right now | **yes** | Wait `retryAfter`, read your own store again (another process may have the token by now), enrol only if still without one | — |
| 409 | `in-progress` | A send with this `Idempotency-Key` is running right now — or was handed to the mail back end and its result was never recorded (then `retryAfter` is long, and the message may be out) | **yes** | Retry with the same key within the ten seconds; then report "not confirmed" | — |
| 409 | `idempotency-conflict` | This `Idempotency-Key` was used for a different message | no | Report a bug | — |
| 409 | `already-rotated` | `/v1/rotate` with a token that is no longer the current one | no | Read your own store again; if it has no newer token, enrol again | — |
| 413 | `too-large` | `limit` says what: `request`, `body` or `attachments` | no | Show it | `relay-too-large` |
| 415 | `unsupported-media-type` | Not `application/json` | no | Report a bug | — |
| 422 | `callback-failed` | Enrolment: the site's confirm endpoint did not confirm; `reason` is `unreachable`, `timeout`, `redirect`, `status` or `confirmation` | no | Show it, with the reason: firewall or wrong public host (`unreachable`, `timeout`); the site answers the confirm address with a redirect (`redirect`, §2); the endpoint is missing, blocked, or served at another path than its product's (`status`); something prints around the JSON (`confirmation`) | `relay-refused` |
| 422 | `too-many-recipients` | More than the allowed number in To, CC and BCC together | no | Show it | `relay-quota` |
| 422 | `attachment-refused` | A file type the service never carries, or a bad file name; `field` says which file (`attachments[0]`) | no | Show it; the message can be sent without that file | `relay-attachment-refused` |
| 422 | `recipient-suppressed` | The back end refuses one of the recipients (it bounced or complained before — for any site: **the suppression list is one for the whole service, and there is none per site**; an address that bounced for one client's site is refused for every other site too, until Intecion removes it). **Nothing was sent, to anybody.** The service is not told which address it is | no | Show it. With several recipients a client may send to each alone, each with a new key, to find the one | `relay-recipient-suppressed` |
| 429 | `rate-limited` | Too many requests from this address — or too many of this site's sends were refused or failed at the mail back end within the hour (60; a send that fails costs no quota, so it has a limit of its own; account mail and alerts are counted apart from the rest) | **yes** | Wait `retryAfter`; when that is longer than the ten seconds, report | `relay-unreachable` if it persists |
| 429 | `quota-exceeded` | A limit of the site (`limit`: `hour`, `day`, `recipient`, `new-recipients`, `alerts`) or of the whole service (`service`) | no | Show it; the message is not sent | `relay-quota` |
| 502 | `backend-failed` | The mail back end failed, or refused this message | **as `retryable` says** | Retry with the same key when `retryable` is true | `relay-unreachable` if it persists |
| 503 | `unavailable` | The service cannot work right now | **as `retryable` says** | Retry when `retryable` is true | `relay-unreachable` if it persists |
| 500 | `internal` | A fault in the service | **yes** | Retry | `relay-unreachable` if it persists |
A network error or a time-out is treated like `503`. The "suggested site status" column is advice, in the words
the IAPL design uses; a product may name its own. The warning `sender-name-replaced` (below) maps to
`relay-name-replaced`.
**Retrying — the one rule.** A client makes at most **three attempts** for one message, the same
`Idempotency-Key` and the same bytes each time, and only after an answer with `retryable: true` (or no usable
answer at all). Between the attempts it waits **at most ten seconds in all**. **The ten seconds win over
`retryAfter`:** when `retryAfter` is longer than what is left of them, the client stops at once and reports.
- **One attempt** has a time-out of **30 seconds** from sending the request to the end of the answer (a 10 MB
attachment has to fit). An attempt that times out counts as "no answer".
- **An enrolment made on the way** — because the client had no token, or got `invalid-token` or `reverify` — is
not one of the three attempts and its time (up to 10 seconds: the call-back has 8) is not part of the ten
seconds. A client enrols at most once per message.
What the client reports:
| The last thing that happened | The message | Report |
|---|---|---|
| `200` | was accepted | sent |
| A refusal with `retryable: false` | was not sent | the status of that code |
| `rate-limited`, `unavailable`, `enrolment-in-progress` (as the service's own JSON), or an answer that is not the service's JSON with a status from 400 to 499 | was not sent | `relay-unreachable` |
| `backend-failed`, `internal`, or a code the client does not know | **probably** not sent — the mail back end failed in a way it does not explain, and it does not say whether such a message can still go out | `relay-unreachable`, worded as "probably not sent". Like the next row: the same key and bytes if it is tried again |
| **No answer** (time-out, connection lost), an answer that is not the service's JSON with any status outside 400–499, or `409 in-progress` | **may have been sent** — the service cannot say yet, or will never be able to | `relay-unreachable`, worded as "not confirmed", never as "not sent". If the client tries this message again later it uses the **same key and bytes**: within 24 hours of the first attempt that cannot produce a second mail — once the service has handed a message to the mail back end, its key either answers with the result or goes on answering `in-progress`; it is never sent again. A client never sends the message under a new key by itself |
**"The same key and bytes" — and a client that cannot keep them.** The promise that a message is not sent
twice holds for as long as the client still has the message's key and its encoded bytes. What a client does
depends on what it can keep:
- **Within one attempt to deliver a message** (the three tries above) every client keeps both in memory.
- **A client with storage for unsent mail** keeps key and bytes with the message and may try again later.
- **A client without such storage** does not try again by itself once it has reported. "Not confirmed" is then
final for that message: the report says that the mail may or may not have gone out. If a person causes the
mail again — submits the form again, presses "send again" — that is a **new message with a new key**, and
when the first one did go out, the recipient gets it twice. The service cannot prevent that and a client
need not; it should say "not confirmed" in a way that does not invite an immediate repeat.
- **A key derived from the message's own record** narrows this without storing the mail: when the mail belongs
to something the site stores anyway (a form submission, a password-reset request), the client may build the
key from that record's id and the mail's role in it (for example the SHA-256 of both, in the key's
alphabet). A second attempt for the same record — after a restart, from another process — then arrives under
the same key, and the service answers it with the first result (`replayed`), with `in-progress`, or, when the
bytes differ because the mail was built again, with `409 idempotency-conflict`. For a derived key the client
treats **`idempotency-conflict` as "this record's mail was already handled"**, not as a bug: no second mail
either way. A deliberate "send again" by a person uses a new key (the record's id and a counter).
## 2. Enrolment — `POST /v1/enrol`
A site gets its token by proving that it is served at its host. No authentication, nothing to type.
1. The site makes a random **nonce** (32 to 128 characters of `A–Z a–z 0–9 _ -`; at least 128 bits of
randomness), keeps it for 5 minutes, and sends:
```json
{ "host": "example.com", "nonce": "…", "product": "iapl", "productVersion": "1.17.0" }
```
- `host`: the site's public DNS name, lowercase, punycode. No scheme, port, path, address literal, single
label, or private suffix (`.local`, `.internal`, `.test`, `localhost` …).
- There is **no call-back address in the request.** Where a site is called back is fixed per product
(below); a request that names a path is refused (`400`, field `callbackPath`).
2. Before it answers, the service calls the site: `POST https://<host><confirm path of the product>`, port 443,
no redirect followed, **8 seconds** for the whole exchange, body ([`CallbackRequest`](schema.json)):
```json
{ "nonce": "…", "token": "ims_…", "state": "active" }
```
3. **The site's confirm endpoint** accepts the call only if it holds exactly this nonce (compare in constant
time; single use; not expired). Then it stores the token and answers `200` with
```json
{ "confirmation": "<lowercase hex SHA-256 of nonce + \".\" + token>" }
```
In every other case it answers `404` and changes nothing.
**It is a public route: limit it — but only the calls it refuses.** Look the nonce up **first**. A call that
carries the nonce the site holds is the service's and is always answered; only calls that do **not** match
a held nonce count towards a limit. Do not limit by the caller's address before that look-up: the service's
calls come from addresses that every Worker on Cloudflare shares, so a stranger who sends a few requests
from a Worker of their own would use up "the service's" allowance and block the site's enrolment. (When the
site holds no nonce at all — it started no enrolment in the last five minutes — every call is a refused one
and can be answered `404` without any work.)
**Exactly this answer and nothing else.** Status `200` (not 201, not 204). The body is the JSON object alone,
UTF-8, at most 1024 bytes, the hex in lower case. Anything printed before or after it — a PHP notice, a
debug toolbar, a wrapper of the framework — makes the enrolment fail with `callback-failed`, reason
`confirmation`. The service reads no more than 1024 bytes and waits no longer than the 8 seconds.
**Which token.** The call-back arrives *before* `/v1/enrol` has answered. The site stores the new token
**beside** the one it has, and makes it the token it uses when `/v1/enrol` answers `200`. If that answer
never arrives, the site tries the new token on its next request and goes back to the earlier one on
`401 invalid-token` (the service may have failed after the call-back; the earlier token is then still good).
A site never throws a working token away for one it has not seen accepted.
4. The service checks the confirmation. Only then does the token become valid, the calling server's address
become one of the site's known addresses, and `/v1/enrol` answer `200`:
```json
{ "ok": true, "state": "active" }
```
`state` is `active` (the site may send) or `pending` (waiting for approval; sends answer `403 site-pending`
until Intecion approves, then the same token works). **The answer never carries the token.**
Why the confirmation, and not a bare `204`: plenty of ordinary endpoints answer "no content" to any POST (a
report collector, for one). Only an endpoint that knows the nonce *and* has read the token can compute the
confirmation, so nothing else on the host can be mistaken for the confirm endpoint.
Rules a client must know:
- **Enrolling again is the same call** and is how a site heals: after `401 invalid-token`, after `401 reverify`,
after a lost token. The earlier token stays valid for 24 hours (so other processes of the same site are not
cut off), the state is kept — a suspended site stays suspended (`403 site-suspended`, no call-back is made).
- A failed enrolment changes nothing on the service: tokens and addresses stay as they were.
- `409 enrolment-in-progress`: an enrolment for this host from this server is already running (or the
registry changed while the site was being called). It is retryable and is not counted against the site.
- **The confirm path is fixed per product**; a site cannot choose it:
| `product` | The service calls | Notes |
|---|---|---|
| `iapl` | `POST https://<host>/api/iapl/mail-relay/confirm` | Under Payload's default API route (`/api`) |
| `iawl` | `POST https://<host>/?rest_route=/iawl/v1/mail-relay/confirm` | WordPress's REST API addressed by query: the same address works with and without pretty permalinks. The route is `mail-relay/confirm` in the namespace `iawl/v1` |
The service calls **exactly that address and follows no redirect.** A site that redirects it fails with
reason `redirect` — the usual causes: the site adds or removes a trailing slash (Next.js `trailingSlash`),
sends `example.com` to `www.example.com` (enrol the host the site really answers on), or redirects `/` by
language. On WordPress, a security plugin or a setting that blocks or redirects `?rest_route=` gives
`status`. In each case either the site is changed to answer at the address, or Intecion sets the address it
does answer at (a path ending in `/confirm/`, for a site with trailing slashes).
**A project that serves its API somewhere else** — Payload with another `routes.api`, WordPress installed in a
sub-folder, a path prefix in front of the site — cannot say so in the request. Its path is set for its host
**by Intecion** (`ims callback-path <host> <path>`), before the site enrols; until then the enrolment fails
with `callback-failed`, reason `status`. A client shows that as "ask Intecion to set this site's confirm
address", with the address it serves. When an enrolled host confirms at another path than before, Intecion
is told.
- **Server addresses.** A site may send from a limited number of server addresses at a time
(`limits.serverAddresses` in `/v1/status`, 8 unless Intecion set another number). Each new address enrols by
itself after `401 reverify`; beyond the limit the address used longest ago is dropped and gets `reverify`
again. A site whose requests leave from many changing addresses (serverless hosting, a pool of egress
addresses) must have the limit raised by Intecion, or it will enrol in a loop.
- **A site with a token issued by hand cannot heal by itself.** It holds such a token because it cannot be
called back, so "enrol again" is not open to it. Its client does **not** enrol on `401 reverify` or
`401 invalid-token`; it stops and reports `relay-refused`, with what the administrator has to ask Intecion
for: after `reverify` (the site sends from a server address Intecion does not know yet — after a move, or
from a second server) that the new address be added; after `invalid-token` a new token. A client knows that
its token was issued by hand because it was pasted into it; the service's answer does not say so.
- A site on `localhost` or behind a firewall cannot be called back. Intecion can issue a token by hand; the
site stores it the same way.
- Use the token only from the site's server. Never print it, never send it to a browser.
## 3. Sending — `POST /v1/send`
Headers (`Bearer` in any case; one space; then the token exactly):
```
Authorization: Bearer ims_…
X-Intecion-Site: example.com
Idempotency-Key: <16 to 128 characters of A–Z a–z 0–9 _ ->
Content-Type: application/json
```
Body ([`SendRequest`](schema.json)):
```json
{
"product": "iapl", "productVersion": "1.17.0",
"kind": "form-notification",
"to": ["[email protected]"],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "…", "html": "…",
"attachments": [{ "filename": "cv.pdf", "contentType": "application/pdf", "content": "<base64>" }]
}
```
- **`kind`** (required): `form-notification`, `form-confirmation`, `account`, `security-alert`, `system`, `test`.
Mail whose purpose the client does not know is `system`. **The kind decides which limits apply (§3.3), so a
client must set it truthfully for its own mail:** `account` only for mail to an account holder (password
reset, invitation), `form-confirmation` for mail to an address a visitor typed.
- **`to`, `cc`, `bcc`**: bare addresses (`name@domain`), ASCII, no display names. At least one `to` (for every
kind but `security-alert`). The total over the three lists is limited per site
(`limits.recipientsPerMessage` in `/v1/status`; the schema's 50 is only the service's upper bound).
- **`security-alert` is addressed by the service.** `to`, `cc` and `bcc` may be left out and are ignored;
whoever controls a site cannot redirect its alerts. The service puts the site's host in front of the
subject: `[example.com] …` — as it does for **any** mail of a site that has Intecion's own address among its
recipients.
- **`replyTo`**: one bare address. The sender address has no mailbox, so send one whenever a reply makes sense.
- **`senderName`**: the display name. Optional; without it the mail leaves under the site's host. See §3.1.
- **`subject`**: 1 to 300 characters, **no line breaks, no control characters, no characters that hide or
reorder text** — Unicode categories Cc, Zl, Zp, Co, lone surrogates, and Cf (zero-width space, direction
marks and overrides, word joiner, byte-order mark, tag characters) **except three that are ordinary text**:
the zero-width joiner U+200D (inside emoji), the zero-width non-joiner U+200C (Persian and other scripts) and
the soft hyphen U+00AD. A subject is often a visitor's own words: **the client strips what is not allowed
before sending** (a regular expression for it: `/[\p{Cc}\p{Zl}\p{Zp}\p{Co}\p{Cs}]|(?![\u200C\u200D\u00AD])\p{Cf}/gu`);
the service refuses, it does not repair, and a refused message is a lost one. A subject must not start with the
service's name in brackets (`[Intecion Notifications Webservice] …`): that is how the service's own notices
begin.
- **`text` and/or `html`**: at least one. Together at most `limits.maxBodyBytes` (UTF-8).
- **`senderName`**, **`subject`**: lengths are counted in characters (Unicode code points), not bytes.
- **`attachments`**: `content` is base64 (standard alphabet, padded to a multiple of four, no line breaks).
Decoded, all files together are at most `limits.maxAttachmentBytes`. File names: no path, no quotes, no
control or invisible characters. Programs and scripts are refused by extension
(`422 attachment-refused`, with `field` naming the file).
- The sender address is fixed by the service. It adds `X-Intecion-Site: <host>` and `X-Intecion-Product: <product>`
to the mail.
Answer ([`SendResponse`](schema.json)):
```json
{ "ok": true, "id": "…", "messageId": "…", "replayed": false,
"senderName": "Kancelaria Example", "warnings": [],
"quota": { "hour": { "limit": 30, "remaining": 29 }, "day": { "limit": 200, "remaining": 199 } } }
```
`200` means the back end accepted the message for delivery, not that it arrived.
### 3.1 The sender name
The service cleans the name and may replace it. A name that is not accepted is **not** a failed send: the mail
leaves under the site's host instead, and the answer carries `"warnings": ["sender-name-replaced"]` and the
name used in `senderName`.
Accepted: at most 64 characters; letters, digits, spaces and `. , & ' - ( ) /`; letters of one script only.
The guard errs on the careful side and will now and then replace an honest name (one that contains a word
from the list, or reads like a web address: "Dom.Pl"). **A client shows the warning in its panel, with the name
that was used,** so that the site's owner can choose another.
Not accepted: `@ < > " \`, anything that looks like an e-mail or web address (the site's own host is allowed),
and names on the service's list of names that are never a client's (mailbox providers, banks, "support",
"security", "administrator", "no-reply" …). The list is the service's and can change without a new contract
version.
### 3.2 `Idempotency-Key`
- One key per message; the same key on every retry of that message.
- **"The same body" means the same bytes.** A client encodes a message to JSON **once**, keeps those bytes with
the key, and sends exactly them on every retry. Encoding the same message again is not safe: another order of
the fields, `\/` instead of `/`, or other spacing is another body.
- The same key with the same bytes within 24 hours: no second mail; the first answer comes back with
`"replayed": true`.
- The same key with other bytes: `409 idempotency-conflict`.
- A send that was refused or failed does not use up its key.
### 3.3 Limits
A message that would pass a limit is refused whole with `429 quota-exceeded` and `limit`:
| `limit` | Counted | Applies to |
|---|---|---|
| `hour` | messages in the last 60 minutes | every kind but `security-alert`. **`account` mail may use all of it; every other kind only four fifths** (24 of 30), so that a busy or abused form cannot use up the room for a password reset |
| `day` | messages this UTC day | the same: four fifths (160 of 200) for everything but `account` |
| `alerts` | `security-alert` messages this UTC day | `security-alert` only: a budget of its own (`limits.securityAlertsPerDay`, 20), outside `hour` and `day` in both directions — alerts use up nothing else, and nothing else can use up the alerts |
| `recipient` | `form-confirmation` messages to one address this UTC day | `form-confirmation` only: it is for addresses a visitor typed into a form. Other mail to one address (a form's notification to the client's office) is never refused by it |
| `new-recipients` | addresses this site has not mailed in the last 30 days, this UTC day | every kind but `account` and `security-alert`. **A form's confirmations may use four fifths of it** (40 of 50); the rest is kept for the site's other mail, so that addresses a stranger invents in a form cannot keep a notification from an office the site has not written to for a month. `account` mail is outside it altogether: a password reset goes to whoever asked |
| `service` | all sites together this UTC day | every kind |
The numbers are the service's, per site, and are reported by `/v1/status` (`limits`; its `quota` is the whole
hour and day). The `quota` in the answer to a send is what is left **for a message of that kind**. A refused or
failed send costs no quota (failed ones are limited by themselves: 60 an hour per site, the sends that are
with the mail back end at that moment counted in, then `rate-limited`, §1). With a limit below
five nothing is set apart.
## 4. Status — `GET /v1/status`
`Authorization: Bearer ims_…`. Answers for a pending and a suspended site too, so a panel can say why mail does
not go out ([`StatusResponse`](schema.json)):
```json
{ "ok": true, "state": "active", "host": "example.com", "product": "iapl",
"service": { "name": "Intecion Notifications Webservice", "version": "1.0.0", "contract": "1.7.1" },
"sender": { "address": "[email protected]" },
"limits": { "messagesPerHour": 30, "messagesPerDay": 200, "recipientsPerMessage": 10,
"perRecipientPerDay": 10, "newRecipientsPerDay": 50,
"maxBodyBytes": 512000, "maxAttachmentBytes": 10485760, "maxAttachments": 20 },
"quota": { "hour": { "limit": 30, "remaining": 30 }, "day": { "limit": 200, "remaining": 200 } },
"kinds": ["form-notification", "form-confirmation", "account", "security-alert", "system", "test"],
"token": { "issuedAt": "2026-11-25T10:00:00.000Z", "rotateAfter": "2027-02-23T10:00:00.000Z" } }
```
A client takes its attachment limit from `limits.maxAttachmentBytes`, never from a constant of its own.
## 5. Rotation — `POST /v1/rotate`
`Authorization: Bearer ims_…`, no body. When `token.rotateAfter` has passed (90 days after issue), the client
asks for a new token. The answer carries it ([`RotateResponse`](schema.json)):
```json
{ "ok": true, "token": "ims_…", "previousValidUntil": "2027-02-24T10:00:00.000Z" }
```
- Store the new token at once. The previous one stays valid for 24 hours.
- Only the **current** token can rotate. With several processes on one site, exactly one rotation wins; the
others get `409 already-rotated` and read the shared store again.
- If the answer is lost, the new token is lost: the old one works for 24 hours, then `401 invalid-token` leads
to a new enrolment. A client that gets `already-rotated` and finds no newer token in its store enrols again
at once instead of waiting for that.
## 6. Giving up the token — `POST /v1/revoke`
`Authorization: Bearer ims_…`, no body. Every token of the site stops working at once; `{ "ok": true }`. The
site's state is kept. To send again the site enrols again.
## 7. `GET /health`
No authentication. `200 { "ok": true }` or `503 { "ok": false }`, nothing else. For an uptime check, not for a client.
## 8. Authentication, in one place
- The token is `ims_` and 43 characters. It is opaque; the service keeps only its SHA-256.
- Every route except `/v1/enrol` and `/health` needs it, **and** needs the request to come from a server
address the site enrolled from (IPv6: the same `/64`). A good token from another address gets `401 reverify`
and nothing else — not even the site's state.
- **A token belongs to one host and cannot act for another — and both sides hold it to that.**
- **Every request with a token carries `X-Intecion-Site: <the site's own public host>`** (the host it
enrolled as, lower case). Without the header: `400 invalid-request`. With a host that is not the token's:
`403 host-mismatch` — nothing is sent, read, rotated or revoked.
- **A client stores the host together with the token** (at the confirm endpoint: the host it is enrolling
as) and, before it uses a token, compares that stored host with its own public host of this moment. When
they differ the token is not its own — the database was copied from another site (staging from
production, a restored backup of another project), or somebody pasted a foreign token: the client does not
use it, forgets it, and enrols as itself.
- A client that reads `/v1/status` compares the `host` in the answer with its own the same way.
This is a guard against an honest mistake, not against a thief — whoever steals a token can name its host;
the address binding is what stops them. Without the guard, a copy of a site running on the same server as
the original would send mail as the original, on the original's limits.
## 9. Versions
- `VERSION` is `major.minor.patch`. The major is the path prefix (`/v1`).
- **Minor:** something was added that an older client need not know — a new optional request field, a new
answer field, a new `kind`, a new error `code` (treat an unknown code by its `retryable`), a new warning.
For that reason `code` and `warnings` are open strings in the schema, not closed lists.
- **Before the first release** (the first `mail-relay-contract/v…` tag) these are development versions: any
change of behaviour bumps the minor, and nobody is promised that an older copy still works. From the first
tag on the rules above hold strictly.
- **Patch:** wording, examples.
- **Major:** anything else. The service keeps answering the previous major for as long as any released client
speaks it.
- `/v1/status` reports the contract version the service speaks. A client carries the `VERSION` of its copy.
## 10. The examples and the runner
Each file in `examples/` is one case:
```json
{
"id": "send-hour-quota",
"title": "…",
"given": { "site": "active", "quota": "hour-exhausted" },
"request": { "method": "POST", "path": "/v1/send",
"headers": { "authorization": "Bearer {{token}}", "idempotency-key": "{{idempotencyKey}}", "content-type": "application/json" },
"schema": "SendRequest", "body": { } },
"response": { "status": 429, "schema": "Error", "body": { "ok": false, "code": "quota-exceeded", "limit": "hour" } },
"then": { "mails": 0 },
"client": { "retry": false, "reEnrol": false, "status": "relay-quota" }
}
```
- **`given`** names the state the case needs; whoever runs the examples arranges it (table below).
- **`request`** is sent as written, after `{{name}}` is replaced. `schema` names the `$defs` entry the body
must match (left out when the body is wrong on purpose). `{ "$base64Bytes": n }` stands for the base64 of
`n` bytes.
- **`response.body`** is a subset: every field written must be there with that value; more may be there.
- **`then`** says what must be true afterwards: `mails` (how many messages reached the back end in this case)
and `mail` (fields of the one message).
- **`client`** says what a client does with this answer: `retry`, `reEnrol`, and the suggested site status.
Use it to test a client against a canned answer.
- `"direction": "service-to-site"` marks a case that describes the call-back: the request is what the
service sends, the response what the site's confirm endpoint answers.
### `given`
| Key | Values | Meaning |
|---|---|---|
| `site` | `none`, `pending`, `active`, `suspended` | State of `{{host}}` in the registry. Anything but `none` implies a token in `{{token}}` |
| `listed` | `true`, `false` | Enrolment: whether `{{host}}` is on Intecion's list |
| `callback` | `ok`, `not-found`, `wrong-confirmation`, `redirect`, `no-content` | Enrolment: how the site's confirm endpoint behaves. `no-content` answers a bare `204` |
| `token` | `current`, `unknown`, `previous`, `none` | Which token `{{token}}` is. `previous` is a token replaced less than 24 hours ago. `none`: the header is left out |
| `address` | `known`, `unknown` | Whether the request comes from an address the site enrolled from |
| `quota` | `fresh`, `hour-exhausted`, `day-exhausted`, `recipient-exhausted`, `hour-share-used` | The site's counters. `recipient-exhausted`: `{{recipient}}` got the day's maximum of form confirmations. `hour-share-used`: mail other than `account` has used its four fifths of the hour |
| `idempotency` | `fresh`, `sent-same`, `sent-other` | Whether `{{idempotencyKey}}` was already used: for this very body, or for another |
| `backend` | `ok`, `recipient-suppressed`, `failure` | How the mail back end answers |
Variables: `{{host}}`, `{{token}}`, `{{nonce}}`, `{{idempotencyKey}}`, `{{recipient}}`, and — read from the
service — `{{senderAddress}}`, `{{alertRecipient}}`.
### Running them
```js
import { runExample } from './runner.mjs'
const driver = {
// Arrange `given`; return the variables for {{…}}.
async arrange(given, example) { return { host, token, nonce, idempotencyKey, recipient, senderAddress, alertRecipient } },
// Send one request to the thing under test.
async request({ method, path, headers, body }) { return { status, headers, body } },
// Optional: validate `value` against schema.json#/$defs/<name>; return a list of problems.
validate(name, value) { return [] },
// Optional: the messages that reached the back end since arrange().
async mails() { return [{ from, fromName, to, cc, bcc, replyTo, subject, headers }] },
}
for (const example of examples) await runExample(example, driver) // throws on the first mismatch
```
The service runs every example against the Worker under the local Workers runtime
(`services/mail-relay/test/contract.test.ts`). A client's local stand-in for the service runs the same files.
**A stand-in is not the service.** The examples are chosen so that the rules stated in this document decide
them (a sender name with an address in it; a file called `.exe`). The service's own lists — names that are
never a client's, file types it does not carry — are not part of the contract, can change without a new
version, and need not be reproduced: a stand-in approximates them, and a client must not rely on a name or a
file type passing because its stand-in let it pass.
## 11. Using the contract in a client
Until a client lives in this repository it **copies** this folder (all of it, `CHECKSUMS` included) from a
`mail-relay-contract/v…` tag, and has one test that runs `node checksums.mjs --check` on the copy, so a
hand-edited copy fails. The copy's `VERSION` says which contract the client speaks.
Checklist for a client:
1. Constants: the base address, the contract version. No secret.
2. A confirm endpoint (public; `404` unless it holds the nonce; the nonce looked up before any limiter, and
only refused calls counted by it; constant-time compare, single use, answers the confirmation as the only output, keeps the earlier token until the new one is accepted).
3. A token store that is never readable from outside and never printed — holding the token **and the host it
was issued to**. Before every use: is that host still this site's own public host? If not, do not use the
token; enrol as this site. Send `X-Intecion-Site` with every request that carries a token; on
`403 host-mismatch` forget the token and enrol.
4. Enrol on the first send without a token, after `invalid-token` and after `reverify` — unless the token was
issued by hand: then stop and report (§2). Guard against two processes enrolling at once
(`enrolment-in-progress`).
5. One `Idempotency-Key` per message and one encoding of it, both kept across retries; at most three attempts,
30 seconds each, ten seconds of waiting in all, only when `retryable`; an enrolment on the way does not
count; "no answer", `in-progress` and an answer that is not the service's JSON (unless its status is 400 to
499) are reported as not confirmed, never as not sent. No `Origin` or `Sec-Fetch-Site` header. Without
storage for unsent mail: no retry after the report; consider keys derived from the record (§1).
6. **Limit what a visitor can make the site send as `account` mail.** "Forgot password" for an address somebody
types is a visitor's lever like a form: the service lets `account` mail use the whole hour and day and no
limit per address, so thirty requests use up the site's hour. The client's own limiter (per address and per
visitor) is what decides; the service cannot tell a wanted reset from an unwanted one.
7. Strip from the subject what §3 does not allow (line breaks, control characters, direction marks and other
invisible characters — not only line breaks); bare addresses only; the right `kind` for each mail.
8. Read limits from `/v1/status`; rotate after `token.rotateAfter`.
9. Run the examples: the `client` block of each against canned answers, and the whole set against your local
stand-in.
+1
View File
@@ -0,0 +1 @@
1.7.1
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env node
// SHA-256 of every contract file, so a hand-edited copy is noticed.
// node checksums.mjs --check compare the files with CHECKSUMS (exit 1 on any difference)
// node checksums.mjs --write rewrite CHECKSUMS (only in the IWDL repository, when the contract changes)
// Node only, no dependency. Works on a copy of this folder anywhere.
import { createHash } from 'node:crypto'
import { readFileSync, readdirSync, writeFileSync, existsSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const here = dirname(fileURLToPath(import.meta.url))
const FIXED = ['README.md', 'CHANGELOG.md', 'VERSION', 'schema.json', 'runner.mjs', 'checksums.mjs']
function files() {
const examples = readdirSync(join(here, 'examples'))
.filter((f) => f.endsWith('.json'))
.sort()
.map((f) => `examples/${f}`)
return [...FIXED, ...examples]
}
function sums() {
return files()
.map((f) => `${createHash('sha256').update(readFileSync(join(here, f))).digest('hex')} ${f}`)
.join('\n') + '\n'
}
const mode = process.argv[2]
if (mode === '--write') {
writeFileSync(join(here, 'CHECKSUMS'), sums())
console.log(`CHECKSUMS written (${files().length} files)`)
} else if (mode === '--check') {
if (!existsSync(join(here, 'CHECKSUMS'))) {
console.error('CHECKSUMS is missing')
process.exit(1)
}
const want = new Map(
readFileSync(join(here, 'CHECKSUMS'), 'utf8').split('\n').filter(Boolean).map((l) => {
const [sum, name] = l.split(' ')
return [name, sum]
}),
)
const have = new Map(sums().split('\n').filter(Boolean).map((l) => {
const [sum, name] = l.split(' ')
return [name, sum]
}))
const problems = []
for (const [name, sum] of have) {
if (!want.has(name)) problems.push(`not in CHECKSUMS: ${name}`)
else if (want.get(name) !== sum) problems.push(`changed: ${name}`)
}
for (const name of want.keys()) if (!have.has(name)) problems.push(`missing: ${name}`)
if (problems.length) {
console.error(problems.join('\n'))
console.error('\nThe contract files do not match CHECKSUMS. Copy them again from IWDL; do not edit a copy.')
process.exit(1)
}
console.log(`contract ${readFileSync(join(here, 'VERSION'), 'utf8').trim()}: ${have.size} files match CHECKSUMS`)
} else {
console.error('usage: node checksums.mjs --check | --write')
process.exit(2)
}
@@ -0,0 +1,25 @@
{
"id": "callback-confirm-wordpress",
"direction": "service-to-site",
"title": "IAWL (WordPress) sites: the same call at the REST route addressed by query, which works with and without pretty permalinks",
"request": {
"method": "POST",
"path": "/?rest_route=/iawl/v1/mail-relay/confirm",
"headers": {
"content-type": "application/json"
},
"schema": "CallbackRequest",
"body": {
"nonce": "EXAMPLEnonceEXAMPLEnonceEXAMPLEnonce00000000",
"token": "ims_EXAMPLEtokenEXAMPLEtokenEXAMPLEtoken0000000",
"state": "active"
}
},
"response": {
"status": 200,
"schema": "CallbackResponse",
"body": {
"confirmation": "1d5818782053c1f5aae3f9abd898a530cf974c59526d240902c9e19619e0462b"
}
}
}
@@ -0,0 +1,25 @@
{
"id": "callback-confirm",
"direction": "service-to-site",
"title": "IAPL (Payload) sites: the call the service makes, and the only answer that enrols. confirmation = hex SHA-256 of nonce + \".\" + token",
"request": {
"method": "POST",
"path": "/api/iapl/mail-relay/confirm",
"headers": {
"content-type": "application/json"
},
"schema": "CallbackRequest",
"body": {
"nonce": "EXAMPLEnonceEXAMPLEnonceEXAMPLEnonce00000000",
"token": "ims_EXAMPLEtokenEXAMPLEtokenEXAMPLEtoken0000000",
"state": "active"
}
},
"response": {
"status": 200,
"schema": "CallbackResponse",
"body": {
"confirmation": "1d5818782053c1f5aae3f9abd898a530cf974c59526d240902c9e19619e0462b"
}
}
}
@@ -0,0 +1,21 @@
{
"id": "callback-unknown-nonce",
"direction": "service-to-site",
"title": "A call with a nonce the site does not hold: 404, nothing stored",
"request": {
"method": "POST",
"path": "/api/iapl/mail-relay/confirm",
"headers": {
"content-type": "application/json"
},
"schema": "CallbackRequest",
"body": {
"nonce": "UNKNOWNnonceUNKNOWNnonceUNKNOWNnonce00000000",
"token": "ims_EXAMPLEtokenEXAMPLEtokenEXAMPLEtoken0000000",
"state": "active"
}
},
"response": {
"status": 404
}
}
@@ -0,0 +1,33 @@
{
"id": "enrol-address-literal",
"title": "An address literal is not a host",
"given": {
"site": "none"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"body": {
"host": "192.0.2.10",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "host-not-allowed"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-refused"
}
}
@@ -0,0 +1,37 @@
{
"id": "enrol-callback-no-content",
"title": "An endpoint that answers 204 to anything is not a confirm endpoint",
"given": {
"site": "none",
"listed": true,
"callback": "no-content"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "callback-failed",
"reason": "status"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-refused"
}
}
@@ -0,0 +1,38 @@
{
"id": "enrol-callback-not-found",
"title": "Enrolment for a host whose confirm endpoint does not hold the nonce (a host the caller does not control) yields nothing",
"given": {
"site": "none",
"listed": true,
"callback": "not-found"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "callback-failed",
"reason": "status",
"retryable": false
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-refused"
}
}
@@ -0,0 +1,37 @@
{
"id": "enrol-callback-path-given",
"title": "A site cannot say where it is to be called back: the path is fixed per product",
"given": {
"site": "none",
"listed": true,
"callback": "ok"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"body": {
"host": "{{host}}",
"callbackPath": "/api/iapl/mail-relay/confirm",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "callbackPath"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,37 @@
{
"id": "enrol-callback-redirect",
"title": "A redirect is never followed",
"given": {
"site": "none",
"listed": true,
"callback": "redirect"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "callback-failed",
"reason": "redirect"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-refused"
}
}
@@ -0,0 +1,37 @@
{
"id": "enrol-callback-wrong-confirmation",
"title": "A 200 answer without the right confirmation does not enrol",
"given": {
"site": "none",
"listed": true,
"callback": "wrong-confirmation"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "callback-failed",
"reason": "confirmation"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-refused"
}
}
@@ -0,0 +1,37 @@
{
"id": "enrol-from-browser",
"title": "A cross-site POST from a browser is refused",
"given": {
"site": "none",
"listed": true,
"callback": "ok"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json",
"origin": "https://evil.example.net"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "browser-not-allowed"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,36 @@
{
"id": "enrol-listed-active",
"title": "A host on Intecion's list enrols and is active at once; the answer has no token",
"given": {
"site": "none",
"listed": true,
"callback": "ok"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 200,
"schema": "EnrolResponse",
"body": {
"ok": true,
"state": "active"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,33 @@
{
"id": "enrol-localhost",
"title": "A local name cannot be enrolled",
"given": {
"site": "none"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"body": {
"host": "shop.localhost",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "host-not-allowed"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-refused"
}
}
@@ -0,0 +1,36 @@
{
"id": "enrol-short-nonce",
"title": "A short nonce is refused",
"given": {
"site": "none",
"listed": true,
"callback": "ok"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"body": {
"host": "{{host}}",
"nonce": "short",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "nonce"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,35 @@
{
"id": "enrol-suspended",
"title": "A suspended site cannot enrol its way back",
"given": {
"site": "suspended",
"callback": "ok"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "site-suspended"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-suspended"
}
}
@@ -0,0 +1,36 @@
{
"id": "enrol-unlisted-pending",
"title": "A host that is not on the list enrols and waits for approval",
"given": {
"site": "none",
"listed": false,
"callback": "ok"
},
"request": {
"method": "POST",
"path": "/v1/enrol",
"headers": {
"content-type": "application/json"
},
"schema": "EnrolRequest",
"body": {
"host": "{{host}}",
"nonce": "{{nonce}}",
"product": "iapl",
"productVersion": "1.17.0"
}
},
"response": {
"status": 200,
"schema": "EnrolResponse",
"body": {
"ok": true,
"state": "pending"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-pending"
}
}
+17
View File
@@ -0,0 +1,17 @@
{
"id": "health",
"title": "Health says yes or no and nothing else",
"given": {},
"request": {
"method": "GET",
"path": "/health",
"headers": {}
},
"response": {
"status": 200,
"schema": "HealthResponse",
"body": {
"ok": true
}
}
}
@@ -0,0 +1,18 @@
{
"id": "not-found",
"title": "An unknown route",
"given": {},
"request": {
"method": "GET",
"path": "/v2/send",
"headers": {}
},
"response": {
"status": 404,
"schema": "Error",
"body": {
"ok": false,
"code": "not-found"
}
}
}
@@ -0,0 +1,27 @@
{
"id": "revoke-ok",
"title": "The site gives up its token",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/revoke",
"headers": {
"authorization": "Bearer {{token}}",
"x-intecion-site": "{{host}}"
}
},
"response": {
"status": 200,
"schema": "RevokeResponse",
"body": {
"ok": true
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,27 @@
{
"id": "rotate-ok",
"title": "The current token rotates; the answer carries the new one",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/rotate",
"headers": {
"authorization": "Bearer {{token}}",
"x-intecion-site": "{{host}}"
}
},
"response": {
"status": 200,
"schema": "RotateResponse",
"body": {
"ok": true
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,29 @@
{
"id": "rotate-previous-token",
"title": "A token that was already replaced cannot rotate",
"given": {
"site": "active",
"token": "previous"
},
"request": {
"method": "POST",
"path": "/v1/rotate",
"headers": {
"authorization": "Bearer {{token}}",
"x-intecion-site": "{{host}}"
}
},
"response": {
"status": 409,
"schema": "Error",
"body": {
"ok": false,
"code": "already-rotated"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,56 @@
{
"id": "send-attachments-too-large",
"title": "Attachments over the limit",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello.",
"attachments": [
{
"filename": "big.pdf",
"contentType": "application/pdf",
"content": {
"$base64Bytes": 10485761
}
}
]
}
},
"response": {
"status": 413,
"schema": "Error",
"body": {
"ok": false,
"code": "too-large",
"limit": "attachments"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-too-large"
}
}
@@ -0,0 +1,48 @@
{
"id": "send-backend-failed",
"title": "The back end fails; the client may retry with the same key",
"given": {
"site": "active",
"backend": "failure"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 502,
"schema": "Error",
"body": {
"ok": false,
"code": "backend-failed",
"retryable": true
}
},
"then": {
"mails": 0
},
"client": {
"retry": true,
"reEnrol": false,
"status": "relay-unreachable"
}
}
@@ -0,0 +1,48 @@
{
"id": "send-bearer-any-case",
"title": "The word \"Bearer\" in any case",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true,
"replayed": false,
"senderName": "Kancelaria Example",
"warnings": []
}
},
"then": {
"mails": 1
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,49 @@
{
"id": "send-day-quota",
"title": "The daily limit refuses the message",
"given": {
"site": "active",
"quota": "day-exhausted"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 429,
"schema": "Error",
"body": {
"ok": false,
"code": "quota-exceeded",
"limit": "day",
"retryable": false
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-quota"
}
}
@@ -0,0 +1,46 @@
{
"id": "send-display-name-recipient",
"title": "Recipients are bare addresses",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"Jan <[email protected]>"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "to"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,54 @@
{
"id": "send-executable-attachment",
"title": "A program is never carried",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello.",
"attachments": [
{
"filename": "invoice.pdf.exe",
"contentType": "application/pdf",
"content": "TVqQAAMAAAA="
}
]
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "attachment-refused",
"field": "attachments[0]"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-attachment-refused"
}
}
@@ -0,0 +1,47 @@
{
"id": "send-from-browser",
"title": "A request with an Origin header is refused whatever the token",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"origin": "https://evil.example.net",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "browser-not-allowed"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,47 @@
{
"id": "send-from-field",
"title": "The sender address cannot be set",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello.",
"from": "[email protected]"
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "from"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,49 @@
{
"id": "send-headers-field",
"title": "Free headers cannot be set",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello.",
"headers": {
"Return-Path": "[email protected]"
}
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "headers"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,47 @@
{
"id": "send-host-mismatch",
"title": "A token used by a site that names another host (a copy of the site's database, a token pasted into the wrong site) is refused",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "copy-of-{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "host-mismatch",
"retryable": false
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": true,
"status": null
}
}
@@ -0,0 +1,46 @@
{
"id": "send-hour-quota-account",
"title": "When other mail has used its share of the hour, account mail (a password reset) still goes out",
"given": {
"site": "active",
"quota": "hour-share-used"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "account",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true
}
},
"then": {
"mails": 1
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,49 @@
{
"id": "send-hour-quota",
"title": "The hourly limit refuses the message and says so",
"given": {
"site": "active",
"quota": "hour-exhausted"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 429,
"schema": "Error",
"body": {
"ok": false,
"code": "quota-exceeded",
"limit": "hour",
"retryable": false
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-quota"
}
}
@@ -0,0 +1,47 @@
{
"id": "send-key-reused",
"title": "The same Idempotency-Key for another message",
"given": {
"site": "active",
"idempotency": "sent-other"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 409,
"schema": "Error",
"body": {
"ok": false,
"code": "idempotency-conflict"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,49 @@
{
"id": "send-no-sender-name",
"title": "Without a sender name the mail leaves under the host, with no warning",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true,
"senderName": "{{host}}",
"warnings": []
}
},
"then": {
"mails": 1,
"mail": {
"fromName": "{{host}}"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,47 @@
{
"id": "send-no-token",
"title": "No Authorization header",
"given": {
"site": "active",
"token": "none"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 401,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-token"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": true,
"status": null
}
}
@@ -0,0 +1,61 @@
{
"id": "send-ok",
"title": "An active site sends one message",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true,
"replayed": false,
"senderName": "Kancelaria Example",
"warnings": []
}
},
"then": {
"mails": 1,
"mail": {
"from": "{{senderAddress}}",
"fromName": "Kancelaria Example",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"subject": "New enquiry",
"headers": {
"X-Intecion-Site": "{{host}}",
"X-Intecion-Product": "iapl"
}
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,46 @@
{
"id": "send-pending",
"title": "A site waiting for approval sends nothing",
"given": {
"site": "pending"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "site-pending"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-pending"
}
}
@@ -0,0 +1,46 @@
{
"id": "send-previous-token",
"title": "A token replaced less than 24 hours ago still sends",
"given": {
"site": "active",
"token": "previous"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true
}
},
"then": {
"mails": 1
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,46 @@
{
"id": "send-recipient-quota-other-kinds",
"title": "Other mail to the same address is not refused by that limit (a form's notification to the client's office)",
"given": {
"site": "active",
"quota": "recipient-exhausted"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true
}
},
"then": {
"mails": 1
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,48 @@
{
"id": "send-recipient-quota",
"title": "A form's confirmation: one address gets only so many a day",
"given": {
"site": "active",
"quota": "recipient-exhausted"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-confirmation",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 429,
"schema": "Error",
"body": {
"ok": false,
"code": "quota-exceeded",
"limit": "recipient"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-quota"
}
}
@@ -0,0 +1,48 @@
{
"id": "send-recipient-suppressed",
"title": "The back end refuses a suppressed recipient",
"given": {
"site": "active",
"backend": "recipient-suppressed"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "recipient-suppressed",
"retryable": false
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-recipient-suppressed"
}
}
@@ -0,0 +1,47 @@
{
"id": "send-replay",
"title": "The same Idempotency-Key and body again: no second mail",
"given": {
"site": "active",
"idempotency": "sent-same"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true,
"replayed": true
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,53 @@
{
"id": "send-security-alert",
"title": "A security alert is addressed by the service and marked with the site's host; the recipients in the request are ignored",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "security-alert",
"to": [
"[email protected]"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true
}
},
"then": {
"mails": 1,
"mail": {
"to": [
"{{alertRecipient}}"
],
"cc": [],
"bcc": [],
"subject": "[{{host}}] New enquiry"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,52 @@
{
"id": "send-sender-name-replaced",
"title": "A sender name that looks like an address is replaced by the host; the mail still goes out",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "PayPal <[email protected]>",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true,
"senderName": "{{host}}",
"warnings": [
"sender-name-replaced"
]
}
},
"then": {
"mails": 1,
"mail": {
"fromName": "{{host}}"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-name-replaced"
}
}
@@ -0,0 +1,47 @@
{
"id": "send-subject-direction-mark",
"title": "A direction override in the subject is refused: the client strips such characters first",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "Invoice ‮fdp.exe",
"text": "Hello."
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "subject"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,47 @@
{
"id": "send-subject-imitates-service",
"title": "A subject that starts like one of the service's own notices is refused",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "[Intecion Notifications Webservice] example.com waits for approval",
"text": "Hello."
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "subject"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,47 @@
{
"id": "send-subject-line-break",
"title": "A line break in the subject (header injection) is refused, not repaired",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "Hello\r\nBcc: [email protected]",
"text": "Hello."
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "subject"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,51 @@
{
"id": "send-subject-visitor-text",
"title": "A subject with what visitors write — an emoji made of several, a soft hyphen — is carried as it is",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "👩‍💻 Straßen­bahn",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true,
"replayed": false,
"senderName": "Kancelaria Example",
"warnings": []
}
},
"then": {
"mails": 1,
"mail": {
"subject": "👩‍💻 Straßen­bahn"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,46 @@
{
"id": "send-suspended",
"title": "A suspended site sends nothing",
"given": {
"site": "suspended"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 403,
"schema": "Error",
"body": {
"ok": false,
"code": "site-suspended"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-suspended"
}
}
@@ -0,0 +1,46 @@
{
"id": "send-text-plain",
"title": "A form post (text/plain) is refused",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "text/plain",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 415,
"schema": "Error",
"body": {
"ok": false,
"code": "unsupported-media-type"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,51 @@
{
"id": "send-to-intecion-marked",
"title": "Any mail of a site that reaches Intecion's own address gets the site's host in front of its subject",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "system",
"to": [
"{{alertRecipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 200,
"schema": "SendResponse",
"body": {
"ok": true
}
},
"then": {
"mails": 1,
"mail": {
"to": [
"{{alertRecipient}}"
],
"subject": "[{{host}}] New enquiry"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,60 @@
{
"id": "send-too-many-recipients",
"title": "More than ten recipients over To, CC and BCC",
"given": {
"site": "active"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello.",
"cc": [
"[email protected]",
"[email protected]",
"[email protected]"
],
"bcc": [
"[email protected]",
"[email protected]"
]
}
},
"response": {
"status": 422,
"schema": "Error",
"body": {
"ok": false,
"code": "too-many-recipients"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-quota"
}
}
@@ -0,0 +1,48 @@
{
"id": "send-unknown-address",
"title": "A good token from a server address the site never enrolled from (a stolen token)",
"given": {
"site": "active",
"address": "unknown"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 401,
"schema": "Error",
"body": {
"ok": false,
"code": "reverify",
"retryable": false
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": true,
"status": null
}
}
@@ -0,0 +1,47 @@
{
"id": "send-unknown-token",
"title": "A token the service does not know",
"given": {
"site": "active",
"token": "unknown"
},
"request": {
"method": "POST",
"path": "/v1/send",
"headers": {
"authorization": "Bearer {{token}}",
"idempotency-key": "{{idempotencyKey}}",
"content-type": "application/json",
"x-intecion-site": "{{host}}"
},
"schema": "SendRequest",
"body": {
"product": "iapl",
"productVersion": "1.17.0",
"kind": "form-notification",
"to": [
"{{recipient}}"
],
"replyTo": "[email protected]",
"senderName": "Kancelaria Example",
"subject": "New enquiry",
"text": "Hello."
}
},
"response": {
"status": 401,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-token"
}
},
"then": {
"mails": 0
},
"client": {
"retry": false,
"reEnrol": true,
"status": null
}
}
@@ -0,0 +1,36 @@
{
"id": "status-active",
"title": "Status of an active site",
"given": {
"site": "active"
},
"request": {
"method": "GET",
"path": "/v1/status",
"headers": {
"authorization": "Bearer {{token}}",
"x-intecion-site": "{{host}}"
}
},
"response": {
"status": 200,
"schema": "StatusResponse",
"body": {
"ok": true,
"state": "active",
"host": "{{host}}",
"product": "iapl",
"service": {
"name": "Intecion Notifications Webservice"
},
"sender": {
"address": "{{senderAddress}}"
}
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,28 @@
{
"id": "status-no-site-header",
"title": "Every request with a token names its site",
"given": {
"site": "active"
},
"request": {
"method": "GET",
"path": "/v1/status",
"headers": {
"authorization": "Bearer {{token}}"
}
},
"response": {
"status": 400,
"schema": "Error",
"body": {
"ok": false,
"code": "invalid-request",
"field": "X-Intecion-Site"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": null
}
}
@@ -0,0 +1,28 @@
{
"id": "status-pending",
"title": "Status answers for a pending site too",
"given": {
"site": "pending"
},
"request": {
"method": "GET",
"path": "/v1/status",
"headers": {
"authorization": "Bearer {{token}}",
"x-intecion-site": "{{host}}"
}
},
"response": {
"status": 200,
"schema": "StatusResponse",
"body": {
"ok": true,
"state": "pending"
}
},
"client": {
"retry": false,
"reEnrol": false,
"status": "relay-pending"
}
}
@@ -0,0 +1,29 @@
{
"id": "status-unknown-address",
"title": "Status gives nothing to a token from an unknown address",
"given": {
"site": "active",
"address": "unknown"
},
"request": {
"method": "GET",
"path": "/v1/status",
"headers": {
"authorization": "Bearer {{token}}",
"x-intecion-site": "{{host}}"
}
},
"response": {
"status": 401,
"schema": "Error",
"body": {
"ok": false,
"code": "reverify"
}
},
"client": {
"retry": false,
"reEnrol": true,
"status": null
}
}
+160
View File
@@ -0,0 +1,160 @@
// Contract test runner for the Intecion Notifications Webservice.
// No dependency. Works in Node 20+ and in the Workers runtime (uses only WebCrypto, btoa and TextEncoder).
// How to use it: README.md, "The examples and the runner".
export const CONTRACT_VERSION = '1.7.1'
export class ContractError extends Error {
constructor(exampleId, message) {
super(`[${exampleId}] ${message}`)
this.name = 'ContractError'
this.exampleId = exampleId
}
}
/** The confirmation a site's confirm endpoint answers with: lowercase hex SHA-256 of nonce + "." + token. */
export async function confirmationFor(nonce, token) {
const bytes = new TextEncoder().encode(`${nonce}.${token}`)
const digest = await crypto.subtle.digest('SHA-256', bytes)
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, '0')).join('')
}
/** Base64 of `n` zero bytes, built without holding the bytes. */
export function base64OfBytes(n) {
const full = Math.floor(n / 3)
const rest = n % 3
return 'AAAA'.repeat(full) + (rest === 1 ? 'AA==' : rest === 2 ? 'AAA=' : '')
}
/** Replace {{name}} and { "$base64Bytes": n } everywhere in a value. Unknown names are an error. */
export function expand(value, vars, exampleId = '?') {
if (typeof value === 'string') {
return value.replace(/\{\{([A-Za-z]+)\}\}/g, (_, name) => {
if (vars[name] === undefined || vars[name] === null) {
throw new ContractError(exampleId, `the driver's arrange() gave no value for {{${name}}}`)
}
return String(vars[name])
})
}
if (Array.isArray(value)) return value.map((v) => expand(v, vars, exampleId))
if (value && typeof value === 'object') {
if (typeof value.$base64Bytes === 'number') return base64OfBytes(value.$base64Bytes)
const out = {}
for (const [k, v] of Object.entries(value)) out[k] = expand(v, vars, exampleId)
return out
}
return value
}
/** Every field of `expected` must be in `actual` with that value; `actual` may have more. Arrays must be equal. */
export function subsetMismatch(actual, expected, path = '') {
if (expected === null || typeof expected !== 'object') {
return Object.is(actual, expected) ? null : `${path || 'value'}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`
}
if (Array.isArray(expected)) {
if (!Array.isArray(actual) || actual.length !== expected.length) {
return `${path || 'value'}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`
}
for (let i = 0; i < expected.length; i++) {
const m = subsetMismatch(actual[i], expected[i], `${path}[${i}]`)
if (m) return m
}
return null
}
if (actual === null || typeof actual !== 'object') {
return `${path || 'value'}: expected an object, got ${JSON.stringify(actual)}`
}
for (const [k, v] of Object.entries(expected)) {
const m = subsetMismatch(actual[k], v, path ? `${path}.${k}` : k)
if (m) return m
}
return null
}
function headerLookup(headers) {
const out = {}
for (const [k, v] of Object.entries(headers ?? {})) out[k.toLowerCase()] = v
return out
}
/**
* Run one example (direction site-to-service) against a driver. Throws ContractError on the first mismatch.
* Returns { request, response, vars } for further checks by the caller.
*/
export async function runExample(example, driver) {
const id = example.id
if (example.direction === 'service-to-site') {
throw new ContractError(id, 'this example describes the call-back; use runCallbackExample()')
}
const given = example.given ?? {}
const vars = (await driver.arrange(given, example)) ?? {}
const headers = expand(example.request.headers ?? {}, given.token === 'none' ? { ...vars, token: '' } : vars, id)
if (given.token === 'none') delete headers.authorization
const body = example.request.body === undefined ? undefined : expand(example.request.body, vars, id)
if (example.request.schema && driver.validate) {
const problems = driver.validate(example.request.schema, body)
if (problems.length) throw new ContractError(id, `the example's request does not match ${example.request.schema}: ${problems.join('; ')}`)
}
const request = { method: example.request.method, path: example.request.path, headers, body }
const response = await driver.request(request)
if (response.status !== example.response.status) {
throw new ContractError(id, `status: expected ${example.response.status}, got ${response.status} ${JSON.stringify(response.body)}`)
}
if (example.response.schema && driver.validate) {
const problems = driver.validate(example.response.schema, response.body)
if (problems.length) throw new ContractError(id, `the answer does not match ${example.response.schema}: ${problems.join('; ')}`)
}
if (example.response.body !== undefined) {
const m = subsetMismatch(response.body, expand(example.response.body, vars, id))
if (m) throw new ContractError(id, `body: ${m}`)
}
if (response.body && response.body.ok === false) {
const got = headerLookup(response.headers)
if (typeof response.body.retryAfter === 'number' && got['retry-after'] !== undefined && String(got['retry-after']) !== String(response.body.retryAfter)) {
throw new ContractError(id, `Retry-After header (${got['retry-after']}) differs from retryAfter (${response.body.retryAfter})`)
}
if (example.client && typeof example.client.retry === 'boolean' && response.body.retryable !== example.client.retry) {
throw new ContractError(id, `retryable: expected ${example.client.retry}, got ${response.body.retryable}`)
}
}
const cors = headerLookup(response.headers)['access-control-allow-origin']
if (cors !== undefined) throw new ContractError(id, 'the service must not send CORS headers')
if (example.then && driver.mails) {
const mails = await driver.mails()
if (typeof example.then.mails === 'number' && mails.length !== example.then.mails) {
throw new ContractError(id, `mails handed to the back end: expected ${example.then.mails}, got ${mails.length}`)
}
if (example.then.mail) {
const m = subsetMismatch(mails[0], expand(example.then.mail, vars, id), 'mail')
if (m) throw new ContractError(id, m)
}
}
return { request, response, vars }
}
/**
* Run a call-back example against a site's confirm endpoint.
* `site.prepare(body)` makes the site hold (or not hold) the nonce; `site.confirm(request)` calls the endpoint.
*/
export async function runCallbackExample(example, site) {
const id = example.id
if (example.direction !== 'service-to-site') throw new ContractError(id, 'not a call-back example')
const holds = example.response.status === 200
await site.prepare({ ...example.request.body, held: holds })
const response = await site.confirm({ ...example.request })
if (response.status !== example.response.status) {
throw new ContractError(id, `status: expected ${example.response.status}, got ${response.status}`)
}
if (holds) {
const expected = await confirmationFor(example.request.body.nonce, example.request.body.token)
if (!response.body || response.body.confirmation !== expected) {
throw new ContractError(id, 'the confirmation is not hex SHA-256 of nonce + "." + token')
}
}
return response
}
+624
View File
@@ -0,0 +1,624 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://webservices.intecion.net/mail/contract/v1/schema.json",
"title": "Intecion Notifications Webservice — wire contract v1",
"description": "Bodies of every request and answer. Requests are closed (an unknown field is refused); answers are open (a client ignores fields it does not know).",
"$defs": {
"Host": {
"description": "A public DNS name, lowercase, punycode for international names. No scheme, port, path or address literal.",
"type": "string",
"minLength": 4,
"maxLength": 253,
"pattern": "^(?=.{4,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]([a-z0-9-]{0,61}[a-z0-9])$"
},
"Product": {
"description": "The client product. The list is the service's.",
"type": "string",
"enum": [
"iapl",
"iawl"
]
},
"ProductVersion": {
"type": "string",
"minLength": 1,
"maxLength": 32,
"pattern": "^[0-9A-Za-z][0-9A-Za-z.+_-]*$"
},
"Kind": {
"type": "string",
"enum": [
"form-notification",
"form-confirmation",
"account",
"security-alert",
"system",
"test"
]
},
"SiteState": {
"type": "string",
"enum": [
"pending",
"active",
"suspended"
]
},
"Address": {
"description": "A bare e-mail address. No display name, no angle brackets, no comment.",
"type": "string",
"minLength": 6,
"maxLength": 254,
"pattern": "^[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(\\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z]([A-Za-z0-9-]{0,61}[A-Za-z0-9])$"
},
"Nonce": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{32,128}$"
},
"Token": {
"description": "Opaque. Never logged, never shown.",
"type": "string",
"pattern": "^ims_[A-Za-z0-9_-]{43}$"
},
"Window": {
"type": "object",
"required": [
"limit",
"remaining"
],
"properties": {
"limit": {
"type": "integer",
"minimum": 0
},
"remaining": {
"type": "integer",
"minimum": 0
}
}
},
"Quota": {
"type": "object",
"required": [
"hour",
"day"
],
"properties": {
"hour": {
"$ref": "#/$defs/Window"
},
"day": {
"$ref": "#/$defs/Window"
}
}
},
"EnrolRequest": {
"type": "object",
"additionalProperties": false,
"required": [
"host",
"nonce",
"product",
"productVersion"
],
"properties": {
"host": {
"$ref": "#/$defs/Host"
},
"nonce": {
"$ref": "#/$defs/Nonce"
},
"product": {
"$ref": "#/$defs/Product"
},
"productVersion": {
"$ref": "#/$defs/ProductVersion"
}
},
"description": "No call-back path: the service calls the path fixed for the product (README §2)."
},
"EnrolResponse": {
"description": "Never carries the token: it went to the site's confirm endpoint.",
"type": "object",
"required": [
"ok",
"state"
],
"properties": {
"ok": {
"const": true
},
"state": {
"$ref": "#/$defs/SiteState"
}
},
"not": {
"required": [
"token"
]
}
},
"CallbackRequest": {
"description": "Sent BY the service TO the site's confirm endpoint: POST https://<host><the product's confirm path>.",
"type": "object",
"additionalProperties": false,
"required": [
"nonce",
"token",
"state"
],
"properties": {
"nonce": {
"$ref": "#/$defs/Nonce"
},
"token": {
"$ref": "#/$defs/Token"
},
"state": {
"$ref": "#/$defs/SiteState"
}
}
},
"CallbackResponse": {
"description": "The site's answer: status 200, a body of at most 1024 bytes that is this JSON object and nothing else, within 8 seconds. confirmation = lowercase hex SHA-256 of the UTF-8 text nonce + \".\" + token.",
"type": "object",
"required": [
"confirmation"
],
"properties": {
"confirmation": {
"type": "string",
"pattern": "^[0-9a-f]{64}$"
}
}
},
"Attachment": {
"type": "object",
"additionalProperties": false,
"required": [
"filename",
"contentType",
"content"
],
"properties": {
"filename": {
"type": "string",
"minLength": 1,
"maxLength": 255
},
"contentType": {
"type": "string",
"maxLength": 127,
"pattern": "^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*/[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]*$"
},
"content": {
"description": "Base64, standard alphabet, no line breaks, padded: the length is a multiple of four. The pattern states the alphabet only — a pattern that also stated the length would overflow regular-expression engines on a 10 MB file; the service checks the length.",
"type": "string",
"minLength": 4,
"pattern": "^[A-Za-z0-9+/]+={0,2}$"
}
}
},
"SendRequest": {
"type": "object",
"additionalProperties": false,
"required": [
"product",
"productVersion",
"kind",
"subject"
],
"properties": {
"product": {
"$ref": "#/$defs/Product"
},
"productVersion": {
"$ref": "#/$defs/ProductVersion"
},
"kind": {
"$ref": "#/$defs/Kind"
},
"to": {
"description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).",
"type": "array",
"items": {
"$ref": "#/$defs/Address"
},
"maxItems": 50
},
"cc": {
"description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).",
"type": "array",
"items": {
"$ref": "#/$defs/Address"
},
"maxItems": 50
},
"bcc": {
"description": "Bare addresses. The number over to, cc and bcc together is limited per site: limits.recipientsPerMessage in /v1/status (the schema only states the service's upper bound).",
"type": "array",
"items": {
"$ref": "#/$defs/Address"
},
"maxItems": 50
},
"replyTo": {
"$ref": "#/$defs/Address"
},
"senderName": {
"description": "At most 256 characters (Unicode code points).",
"type": "string",
"maxLength": 256
},
"subject": {
"description": "1 to 300 characters (code points). No line breaks, control characters or characters that hide or reorder text (README §3 has the exact rule and the three exceptions); must not start with the service's name in brackets.",
"type": "string",
"minLength": 1,
"maxLength": 300
},
"text": {
"type": "string",
"minLength": 1
},
"html": {
"type": "string",
"minLength": 1
},
"attachments": {
"type": "array",
"items": {
"$ref": "#/$defs/Attachment"
},
"maxItems": 20
}
},
"anyOf": [
{
"required": [
"text"
]
},
{
"required": [
"html"
]
}
],
"allOf": [
{
"if": {
"properties": {
"kind": {
"const": "security-alert"
}
},
"required": [
"kind"
]
},
"else": {
"required": [
"to"
],
"properties": {
"to": {
"minItems": 1
}
}
}
}
]
},
"SendResponse": {
"type": "object",
"required": [
"ok",
"id",
"replayed",
"senderName",
"warnings",
"quota"
],
"properties": {
"ok": {
"const": true
},
"id": {
"description": "The service's id of this message in its log.",
"type": "string",
"minLength": 1
},
"messageId": {
"description": "The back end's id, when it gave one.",
"type": "string"
},
"replayed": {
"description": "true when this Idempotency-Key was already sent and no second mail went out.",
"type": "boolean"
},
"senderName": {
"description": "The name the mail left under.",
"type": "string"
},
"warnings": {
"description": "Known today: sender-name-replaced. A client ignores a warning it does not know.",
"type": "array",
"items": {
"type": "string"
}
},
"quota": {
"description": "What is left for a message of the kind just sent.",
"$ref": "#/$defs/Quota"
}
}
},
"StatusResponse": {
"type": "object",
"required": [
"ok",
"state",
"host",
"product",
"service",
"sender",
"limits",
"quota",
"kinds",
"token"
],
"properties": {
"ok": {
"const": true
},
"state": {
"$ref": "#/$defs/SiteState"
},
"host": {
"$ref": "#/$defs/Host"
},
"product": {
"$ref": "#/$defs/Product"
},
"service": {
"type": "object",
"required": [
"version",
"contract"
],
"properties": {
"name": {
"description": "The service's name, for a panel to show.",
"type": "string"
},
"version": {
"type": "string"
},
"contract": {
"type": "string",
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
}
}
},
"sender": {
"type": "object",
"required": [
"address"
],
"properties": {
"address": {
"$ref": "#/$defs/Address"
}
}
},
"limits": {
"type": "object",
"required": [
"messagesPerHour",
"messagesPerDay",
"recipientsPerMessage",
"perRecipientPerDay",
"newRecipientsPerDay",
"maxBodyBytes",
"maxAttachmentBytes",
"maxAttachments"
],
"properties": {
"messagesPerHour": {
"type": "integer",
"minimum": 0
},
"messagesPerDay": {
"type": "integer",
"minimum": 0
},
"recipientsPerMessage": {
"type": "integer",
"minimum": 1
},
"perRecipientPerDay": {
"type": "integer",
"minimum": 0
},
"newRecipientsPerDay": {
"type": "integer",
"minimum": 0
},
"maxBodyBytes": {
"type": "integer",
"minimum": 0
},
"maxAttachmentBytes": {
"type": "integer",
"minimum": 0
},
"maxAttachments": {
"type": "integer",
"minimum": 0
},
"serverAddresses": {
"description": "Server addresses the site may send from at a time.",
"type": "integer",
"minimum": 1
},
"securityAlertsPerDay": {
"description": "Security alerts a day: a budget of their own, outside the hour and day limits.",
"type": "integer",
"minimum": 0
}
}
},
"quota": {
"$ref": "#/$defs/Quota"
},
"kinds": {
"type": "array",
"items": {
"type": "string"
}
},
"token": {
"type": "object",
"required": [
"issuedAt",
"rotateAfter"
],
"properties": {
"issuedAt": {
"type": "string",
"format": "date-time"
},
"rotateAfter": {
"type": "string",
"format": "date-time"
}
}
},
"senderName": {
"description": "The name the last mail left under, when there was one.",
"type": "string"
}
}
},
"RotateResponse": {
"type": "object",
"required": [
"ok",
"token",
"previousValidUntil"
],
"properties": {
"ok": {
"const": true
},
"token": {
"$ref": "#/$defs/Token"
},
"previousValidUntil": {
"type": "string",
"format": "date-time"
}
}
},
"RevokeResponse": {
"type": "object",
"required": [
"ok"
],
"properties": {
"ok": {
"const": true
}
}
},
"HealthResponse": {
"description": "No detail on purpose — also when it says no: the one answer that is not an Error.",
"type": "object",
"additionalProperties": false,
"required": [
"ok"
],
"properties": {
"ok": {
"type": "boolean"
}
}
},
"ErrorCode": {
"type": "string",
"enum": [
"invalid-request",
"invalid-token",
"reverify",
"site-pending",
"site-suspended",
"host-not-allowed",
"enrolment-closed",
"enrolment-in-progress",
"callback-failed",
"host-mismatch",
"browser-not-allowed",
"not-found",
"method-not-allowed",
"unsupported-media-type",
"idempotency-conflict",
"in-progress",
"already-rotated",
"too-large",
"too-many-recipients",
"attachment-refused",
"recipient-suppressed",
"rate-limited",
"quota-exceeded",
"backend-failed",
"unavailable",
"internal"
],
"description": "The codes the service answers with today. The list grows with minor versions; that is why Error.code is an open string."
},
"Error": {
"type": "object",
"required": [
"ok",
"code",
"message",
"retryable"
],
"properties": {
"ok": {
"const": false
},
"code": {
"description": "One of ErrorCode today. A client that meets a code it does not know acts on `retryable`.",
"type": "string",
"minLength": 1
},
"message": {
"description": "For a log or an administrator. English. Never shown to a visitor.",
"type": "string"
},
"retryable": {
"description": "true: the same request, with the same Idempotency-Key, may be sent again after a short wait.",
"type": "boolean"
},
"retryAfter": {
"description": "Seconds.",
"type": "integer",
"minimum": 0
},
"field": {
"description": "With invalid-request: the field at fault. With attachment-refused: which file, as attachments[n] (n from 0).",
"type": "string"
},
"limit": {
"description": "With quota-exceeded: hour, day, alerts, recipient, new-recipients or service. With too-large: request, body or attachments.",
"type": "string"
},
"reason": {
"description": "With callback-failed: unreachable, timeout, redirect, status or confirmation.",
"type": "string"
}
}
}
}
}
+1 -1
View File
@@ -1420,7 +1420,7 @@ export interface CookieSetting {
}[]
| null;
/**
* Cookies the site uses — shown on the cookie policy page (<CookieTable>). Fill it from a scan: ipal-consent-check → cookie-scan.
* Cookies the site uses — shown on the cookie policy page (<CookieTable>). Fill it from a scan: iapl-consent-check → cookie-scan.
*/
cookies?:
| {
+4 -4
View File
@@ -1,7 +1,7 @@
import { payloadTotp } from '@clocklimited/payload-2fa'
import { sqliteAdapter } from '@payloadcms/db-sqlite'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import { ipalKit } from '../src/index.js'
import { iapl } from '../src/index.js'
import path from 'path'
import { buildConfig } from 'payload'
import sharp from 'sharp'
@@ -64,18 +64,18 @@ export default buildConfig({
await seed(payload)
},
plugins: [
ipalKit({
iapl({
access: { authCollection: 'users' },
i18n: i18nConfig,
consentLog: true,
// Cookie review + "Crawl site" (needs IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN and a running services/cookie-crawler).
// Cookie review + "Crawl site" (needs IAPL_COOKIE_SCAN_URL / IAPL_COOKIE_SCAN_TOKEN and a running services/cookie-crawler).
cookieScanner: { crawl: true },
forms: {},
seo: { collections: ['posts', 'pages'] },
stats: true,
// 2FA is enforced by default; the dev sandbox opts out so it boots without an authenticator.
// IPAL_DEV_2FA=1 turns it on (first-login setup and verify screens).
twoFactor: process.env.IPAL_DEV_2FA ? { issuer: 'ipal-kit dev', plugin: payloadTotp } : false,
twoFactor: process.env.IPAL_DEV_2FA ? { issuer: 'IAPL dev', plugin: payloadTotp } : false,
// Panel logo/icon from Site settings and the technology support credit.
whiteLabel: true,
}),
+947 -2
View File
@@ -1,13 +1,958 @@
# Changelog
Changes that matter for projects built on ipal-kit. How to move to a new version: the
**ipal-upgrade** skill and [PROGRAMISTA.md §6](./dev/PROGRAMISTA.md).
Changes that matter for projects built on IAPL (called ipal-kit before 1.17.0; entries below that version keep the
names their release had: `ipalKit`, `ipal-doctor`, `IPAL_*` and the `ipal-*` skills are the `iapl` names of today).
How to move to a new version: the **iapl-upgrade** skill and [PROGRAMISTA.md §6](./dev/PROGRAMISTA.md).
We keep at least the **20 most recent versions** here. When you upgrade a project by several
versions at once, go through every "Requires project changes" section in order, starting from the
version you have. A new release = a new section at the top; we remove the oldest ones only
once there are more than 20.
## 1.17.0 — the plugin is called IAPL; mail works with no setup
> **Read before upgrading.** In this order: the security follow-ups prepared as 1.16.8 (never released on their
> own), e-mail, the new name, the speed of public pages (one line in `next.config.ts`), consent, then Postgres
> (nothing to do). **One schema change, on Postgres / SQLite only:** the consent log is now on by default — a project
> that never had `consentLog` on creates and applies a migration in the same deploy, or sets `consentLog: false`
> (below, "Consent"). MongoDB: no migration.
>
> **Security first — prepared as 1.16.8, released here.** No option, schema, migration or import-map change. Three points:
> **A site built with Turbopack** (`next build` without `--webpack`) published the plugin's `package.json` (registry
> and repository addresses, no secret): update, rebuild, check that `find .next/static -name 'package*.json'` prints
> nothing, and purge a CDN or cache that may still hold the file. A webpack build (the starter's script): nothing.
> **What can stop people:** on a project's own staff collection **without access rules of its own** whose
> accounts can hold `editor` or `admin` although its roles are not just the plugin's — a `roles` select such as
> `user, editor, admin, boss` or `viewer, editor`, or a `roles` field that is text, json or a relationship (all
> with `hasMany`, i.e. holding a list; a single-valued field is not affected) — an account that is
> not an admin can no longer create, delete or unlock accounts there, change another account, or change
> anybody's roles. If **no** staff account holds `admin`, nobody can (the start log says so; the way out is
> below). And the other way round: in a staff collection whose `roles` is a **single** select with only
> `user` / `editor` / `admin`, accounts manage each other again (see Changed).
> **Only where a plugin listed after ipalKit copies a staff collection, or makes a collection of your config the
> panel's** (`admin.user`): some answers get narrower there — see "Requires project changes". No known site does
> either.
>
> **E-mail — read which of three cases the site is.** A site with **no SMTP server in Site integrations and no
> `GRAPH_*` variables** (its mail failed with "not configured" until now) starts sending through the **Intecion
> Notifications Webservice** after the upgrade: on its next e-mail it contacts `webservices.intecion.net` with its
> host and the plugin version, receives its own token through a new public route, and sends from
> `[email protected]` 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).
> **The service is live** at `https://webservices.intecion.net/mail`. It starts with enrolment **"pending"**: a site
> that enrols waits until Intecion approves it (the panel says "waiting for approval"; nothing is sent until then).
> Switching the service to open enrolment, where a site is active as soon as it enrols, is a later, separate step.
>
> **The name.** 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. No schema, migration or import-map change.
>
> **Speed of public pages** — two changes. **The cookie banner is painted with the page** (it appeared after hydration
> and could be the page's LCP element): nothing to do; remove a project wrapper that delays it (a "mounted" guard,
> `dynamic(…, { ssr: false })`), and with a nonce CSP pass `nonce` to `<SiteProviders>`. Old behaviour:
> `<CookieBanner firstPaint={false} />`. **Payload's colour-scheme client hints go to the admin only** (Chrome no longer
> requests the first page of a visit twice): **one line** in `next.config.ts` —
> `withPayload(withSecurityConfig(nextConfig))` becomes `withSecurityConfig(withPayload(nextConfig))`; a panel not at
> `/admin` adds `{ adminClientHints: { route } }`. Without that line the site works exactly as before.
>
> **Consent** — what a visitor of an existing site sees change: **"Reject" looks like "Accept all"** (it was a plain
> text button); one more sentence in the **default** banner text (only where the panel's message is empty); a browser
> that sends **Global Privacy Control** gets no banner, no tracker request (also not Google's in Consent Mode
> `advanced`) and can opt in from the cookie button. **Every choice is recorded** in *Privacy → Consent records* (the
> consent log is on by default; no IP, no user agent). Withdrawing now stops Meta, TikTok and Clarity at once.
> Consent Mode stays `advanced`. Each change has an opt-out (table under "Requires project changes"). **Postgres /
> SQLite:** `pnpm payload migrate:create consent-log` in the same deploy, or `iapl({ consentLog: false })` — without
> either the site works but no choice is recorded (one log line, a doctor warning).
>
> **Postgres** (nothing to do): many form submissions or "forgot password" requests at the same moment no longer stop
> the site; form and account mail go out right after the commit. Details under "Fixed — Postgres".
### Security — prepared as 1.16.8, released in 1.17.0
#### Security
- **A Turbopack build of a site published the plugin's `package.json`.** The plugin read its own version from
that file by a path relative to its module, and a bundler takes such a file for an asset: Turbopack copied it
to `/_next/static/media/package.<hash>.json`, where anyone could fetch it. It is the **plugin's** manifest, not
the project's: the plugin's name and version, its dependency lists with version ranges (also the development
ones), its script names, and the addresses of the package registry and the git repository it comes from. **No
secret, token or password**, and nothing of the project. The file name is a content hash and no page links to
it. A webpack build (`next build --webpack`, what the starter and the reference site use) kept the file on the
server side: not served. The version is now a constant in the code (`src/version.ts`); nothing is read from
disk at run time.
- **A staff collection whose accounts can hold `editor` or `admin` gets the admin rules.** The plugin's checks go
by the value on the account: `admin` on an account of a staff collection makes a plugin admin, `editor` an
editor — whatever else the collection's `roles` field offers. But a project's own staff collection without
rules got the admin rules only when ALL its role values were the plugin's; otherwise "an account of this
collection" could create, change and delete accounts. So with roles `user, editor, admin, boss` an account
with the role `user` created an `admin` there (or set the admin's password) and then read Site integrations,
changed other staff collections' roles and listed the panel's accounts; with `viewer, editor` a `viewer` made
an `editor` who saves Site settings; the same with a `roles` field that is text or a relationship with
`hasMany`, or json (a relationship to documents with text ids holds those ids). In 1.16.7 and, wider,
before it. Now such a collection — in the config or added by a later plugin — gets: create, delete, unlock —
an admin; update — an admin or the account itself; roles — only an admin. Not affected: `access.authCollection`,
collections with rules of their own, a `roles` select whose values hold neither `editor` nor `admin`. No known
site has such a collection ([access.md](./access.md) "Account rules").
- **A copy of a staff collection kept rules written for the original.** A plugin listed after ipalKit that
spreads a staff collection into another slug (`{ ...staff, slug: 'copy' }`) carried the "already handled" marker
and the plugin's rules along. "An admin, or the account itself" then meant the ORIGINAL's accounts: with
numeric ids (Postgres, SQLite) an account of the original could change the password of the account with the
same id in the copy. Now the plugin puts its rule for the copy's own slug **in front of** every rule it wrote
for the original, and both must allow; on a copy named as staff, in front of every rule. Nothing is replaced
or rewritten, so a copy is never opened wider than it was and never wider than the plugin's rule — whatever
role values it has and however it uses or wraps the copied rules. Its `roles` field is guarded on every copy.
The marker `custom.ipalAccounts` names the slug and the staff status (`{ slug, staff, own? }`).
- **A collection of the config that a later plugin makes the panel's had no account rules.** A collection that is
in your config, is not named as staff, and becomes the login collection because a plugin listed after ipalKit
sets `admin.user` to it counted as "already handled": where it had no rules of its own, Payload's defaults
stood — an account of any auth collection (a customer) could create, change and delete panel accounts there.
Now it gets the plugin's rules when the config goes live, for every operation that had **no** rule in your
config; an operation you wrote a rule for keeps it exactly as written (`AccountsMarker.own`).
#### Changed
- **A single-valued `roles` field no longer brings the admin rules.** The plugin counts roles only from an array,
so an account whose `roles` is one value (`'admin'` in a select without `hasMany`, a radio) was never a plugin
admin. Yet in 1.16.7 a project's own staff collection whose single select offered only `user` / `editor` /
`admin` got the admin rules — and then nobody in it could create, delete or unlock accounts, unless a plugin
admin existed in another staff collection. Such a collection now gets "an account of this collection", like any
collection whose roles are not the plugin's: its accounts manage each other again. Nothing of the plugin's opens:
the value still grants
nothing of the plugin's. But inside such a second staff collection this is wider than 1.16.7: an account with the
value `user` can create, change or delete the account with the value `admin`. **If your own code gives rights by
this value, write the collection's own rules** (`ipal-doctor --url` → `staff-own-roles` names it).
#### Fixed
- `next dev`: a collection that becomes a staff collection in an edit (named in `access.staffCollections` for
the first time) gets its rules on the reload; it needed a restart when its config object outlived the reload.
- A plain 2FA config guards nothing twice at start (the plugin's rules are marked before its 2FA guard).
#### Added
- A start-log warning when staff collections run on the admin rules and no staff account holds `admin`
(checked collection by collection; "could not check" where it cannot tell).
- `pnpm e2e:built` (plugin repository): builds the reference site with webpack and with Turbopack and checks,
on each, the account rules on a built site (copied staff collections included) and that no package manifest is
among the public files. Part of the release gate (PROGRAMISTA §8.1). The reference site's Playwright runs
reset the test admins first (`e2e/global-setup.ts`), so a spec no longer fails because of what ran before it.
- Exports: `canHoldStaffRole`, `rolesAreAList`, `staffCollectionsNobodyManages`, `staffRuleOf`,
`isPasswordRuleHook`; types `StaffRuleMark`, `AccountsMarker`. `markSeenAuthCollections(config, staffSlugs)`
takes the staff slugs; `LateAdoption` has `kept` and `known`.
- The start log tells a collection that became staff after ipalKit ran from one a later plugin added, and names
the rules of its own that were kept.
#### Requires project changes (what projects must update)
- **A staff collection of your own, without access rules, whose accounts can hold `editor` or `admin`** (a
`roles` select with `hasMany` and one of them next to values of your own, or a `roles` field that is text or a
relationship with `hasMany`, or json): only an admin
creates, deletes and unlocks accounts there and changes roles; another account is changed by an admin or by
itself. If accounts with a role of your own (`boss`, `viewer`) managed accounts there, write that as the
collection's own rules (`access.create` / `update` / `delete`, field access on `roles`) — the plugin gives
your values no rights. In a collection where nobody can be an `admin` (`viewer, editor`), accounts are
managed by an admin of another staff collection (the panel's).
- **Read the start log after the upgrade.** `[ipal] No staff account holds the role "admin", so NOBODY can
create, delete or unlock accounts in "…"`: no account of any staff collection is an admin. Give one account
the role with a script (`payload.update({ collection, id, data: { roles: ['admin'] } })`, `pnpm payload run`),
or write the collection's own rules. To switch the default off for every staff collection: `accounts: {
adminOnlyCreate: false, adminOnlyWrite: false }` (that also takes the protection off).
- **A site built with Turbopack:** update and rebuild — the new build has no `package.<hash>.json` under
`/_next/static/media/`. Check: `find .next/static -name 'package*.json'` prints nothing. Purge a CDN or cache in
front of the site. Nothing to do for a webpack build.
- **A staff collection of your own whose `roles` is one value** (a select without `hasMany`) with only `user` /
`editor` / `admin`, and no access rules: its accounts manage each other again (see Changed). If your own code
gives rights by that value, write the collection's rules.
- **Only if a plugin of yours copies a staff collection** (`{ ...staff, slug: 'copy' }`, or a new collection that
reuses a staff collection's `access` object) — three answers get narrower:
- **The copy's own accounts and "the account itself".** In the copy, the copied rule "an admin, or the account
itself" lets only an admin through (it still speaks of the original's accounts). If the copy's own accounts
should edit themselves, give the copy its own rule — one line:
`access: { ...staff.access, update: adminOrSelfIn('copy') }` ([access.md](./access.md) "Account rules").
Before this change those accounts could not edit themselves either.
- **A copy named as staff whose own rules were wider than the plugin's** — a public `read`, an open `create`,
a rule that returns a query, Payload's defaults where it dropped a rule: in 1.16.7 a copy counted as handled
and kept them; now the plugin's rule goes in front, so a customer or an anonymous request no longer passes.
To keep the copy's rules exactly as they are: `custom: { ipal: { accountRules: false } }` on the copy.
- **Where the original has roles of its own** (`lead, member`): its accounts could manage the copy's accounts
(create, change, delete) through the copied rule "an account of the original". They no longer can: only a
plugin admin manages the copy's accounts (the copy's own accounts could not before and cannot now), until
the copy writes rules of its own (`access.create` / `update` / `delete`).
- **Only if a plugin listed after ipalKit sets `admin.user` to a collection of your config that you did not name
as staff:** the operations that collection has no rule for get the plugin's (an admin; update — an admin or
the account itself; read — staff). Rules you wrote on it stay. Better: name it in `access.staffCollections`
(or list that plugin before ipalKit) — then it is handled at config time like any staff collection.
- `pnpm ipal:skills`.
#### Known limitations
- A staff collection **without a `roles` field** is unchanged: every account of it is an admin to the plugin.
- A `roles` select of your own whose values hold neither `editor` nor `admin` is unchanged: inside it every
account may create, change and delete accounts (`ipal-doctor --url` → `staff-own-roles`).
- The plugin judges a collection by its declared `roles` field. A value that a hook of the project's own puts
into `roles` is not seen, and a rule of the project's own (`access.create`, field access on `roles`) replaces
the protection for that operation.
- A relationship `roles` field makes a plugin admin only where the related documents' ids are the role names; over
REST such an account's roles arrive as documents and do not count, over GraphQL and the Local API at depth 0
they do. The admin rules apply to the collection either way.
- The start-log check reads up to 1000 accounts of a collection whose `roles` field the database cannot be asked
about; with more it says "could not check" for that collection.
- `next dev`: a collection that STOPS being a staff collection in an edit keeps the rules until a restart; after
a reload the adoption still runs with the options the site started with.
- A marker or a function mark written by hand in the project's own config is taken at its word ("handled" for a
marker of the collection's own slug); a hand-made function mark only ever adds the plugin's rule in front.
- **Not run for this release:** a built site on Postgres or SQLite (the account rules ran over HTTP on SQLite, Postgres
and MongoDB; the built site, webpack and Turbopack, on MongoDB); a real plugin that copies a staff collection; a
real tracing library around access rules.
### Requires project changes
- **Postgres / SQLite, consent log (first, before the deploy):** the consent log (`consent-records`) is now on by
default. A project that did not set `consentLog` before gets a **new table** (`consent_records`, plus a
`consent_records_id` column on Payload's `payload_locked_documents_rels`; nothing dropped): run `pnpm payload migrate:create
consent-log`, commit the migration and have it applied when the new container starts (`prodMigrations`, or the start
command `pnpm payload migrate && pnpm start`) — **in the same deploy**. Or set `iapl({ consentLog: false })`. Without
either nothing breaks: the page and the banner work, `POST /api/ipal/consent` answers `503`, the server logs once
"the consent-records table does not exist…", and `iapl-doctor` reports `consent-log-migration` (warning). A project
that already had `consentLog: true`: nothing. **MongoDB** (the eight client sites): nothing — the collection
appears by itself.
- **Generated types:** where the consent log was off, `payload generate:types` adds the `consent-records` collection
(`ConsentRecord`, its select type); run it and commit. The import map does not change (the log has no admin
component).
- **What changes for an existing site on upgrade — consent** (an unedited 1.16.7 site, `SiteProviders` layout):
| | Before | After | Opt-out |
|---|---|---|---|
| "Reject" on the banner | plain text button next to a filled "Accept all" | the same filled button as "Accept all" | `<CookieBanner equalChoice={false} />` |
| Default banner text (panel message empty) | "…or choose which to allow." | + "You can change your choice at any time with the cookie button, and set cookie rules in your browser too." (Polish: the same sentence in Polish) | write the message in Cookies → *Banner* |
| A visitor whose browser sends Global Privacy Control, no choice yet | the banner; in Consent Mode `advanced` the Google tag loaded and pinged before a choice | no banner (decided before the first paint), the cookie button; nothing sent to Google or a pixel; nothing stored. Analytics no longer counts these visitors unless they opt in from the cookie button (share unknown; Brave, DuckDuckGo, Firefox private windows today) | `<SiteProviders gpc="ask">` (banner, still nothing sent before a choice) or `gpc={false}` (ignored) |
| Such a visitor who had clicked "Accept all" **after** 1.17.0 without the signal, and turns it on later | — | analytics and marketing switched off on the next page, their cookies deleted, the record rewritten and logged | `gpc={false}` |
| Such a visitor whose choice dates from before 1.17.0 | — | the choice stands until it expires (180 days) or they change it | — |
| Consent log | none unless `consentLog: true` | every choice stored in *Privacy → Consent records* (admin only): random id, choices, policy version, time; purged after 3 years | `iapl({ consentLog: false })`; one layout: `logEndpoint={false}` |
| Withdrawing (cookie button → "Reject") | cookies deleted; Meta, Clarity, LinkedIn, TikTok kept running until the next page | the same, plus Meta, TikTok and Clarity told at once, listed local / session storage keys removed | — |
| Clarity on a site without GA4 / GTM | never got a consent signal: ran without cookies for EEA visits (every page view a new visitor) | `consentv2` sent when it loads: sessions hold together after consent | — |
| Google tag | Consent Mode default | the same, plus `ads_data_redaction` (no ad-click ids in Ads requests while marketing is denied) | — |
| Consent Mode | `advanced` | `advanced` (unchanged) | `consentMode: 'basic'` |
| Schema | — | MongoDB: a new collection, created by itself. Postgres / SQLite: a new table (migration above) | `consentLog: false` |
- **A CI that compares generated types:** `payload generate:types` gives a diff on upgrade — four field descriptions
of Site integrations changed (no type did). Run it and commit `payload-types.ts`. The import map does not change.
- **Nothing else 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 |
|---|---|---|
| SMTP filled in (server, user name, password) | Nothing. No call to Intecion | — |
| `GRAPH_*` set and "Microsoft Graph" chosen | Mail as before. One deprecation warning in the start log, one doctor warning (`mail-graph-deprecated`) | `mail: { graphDeprecationWarning: false }` (the log line) |
| `GRAPH_*` set, "Sending method" on SMTP, no SMTP server (mail failed until now) | Mail goes through Graph | fill in SMTP, or remove the variables |
| Neither (mail failed until now with "not configured") | **An outbound call:** on the next e-mail the site enrols with the service — `POST https://webservices.intecion.net/mail/v1/enrol` with its host and the plugin version — and then sends through it, from `notification@webservices.intecion.net`. At the start the service holds every new site for Intecion's approval (enrolment "pending"; the panel says so); once the service switches to open enrolment, a site is active as soon as it enrols | `iapl({ mail: { relay: false } })` |
| Any site with the mail service enabled (the default) | **A new public route:** `POST /api/iapl/mail-relay/confirm` — answers `404` and changes nothing unless the site itself started an enrolment in the last 5 minutes; rate-limited. Three admin-only routes beside it (`…/status`, `…/connect`, `…/disconnect`) | `mail: { relay: false }` removes all four |
| **A copy** of a site's database on a non-public site — a host that matches `developmentHosts` (built in: `*.dev.netscale.pl`, Intecion's development domain; no env needed) or one with `IAPL_NOINDEX=1` (staging made from production; production's data copied back onto the development address), with no SMTP there | It does **not** enrol or send by itself — its data is production's, and it would mail real people: sends report `relay-refused`, the panel and the doctor say why. "Connect again" lets it send; `mail: { relay: false }` or SMTP to a catcher keeps it silent for good. **A copy on another host without the variable sends** (it looks like launch day); a production site that kept `IAPL_NOINDEX=1` sends nothing | `mail: { relay: { otherHosts: 'enrol' } }` |
| A site launched on its real domain after it was built on a development address; a moved domain | Nothing to do: it enrols by itself on its first e-mail | `mail: { relay: { otherHosts: 'wait' } }` makes it wait for "Connect again" |
| SMTP **half** filled in — a server or a user name, but not server, user name and password (until now: refused, "Fill in the server, user name and password") | Sent through the mail service; one line in the server log and a hint in the state block say that the SMTP settings are incomplete | complete or empty the SMTP fields; `mail: { relay: false }` |
| "Microsoft Graph" chosen in the panel but `GRAPH_*` missing (until now: SMTP with a warning) | SMTP if filled in, otherwise the mail service | as above |
| A site on `localhost` or without `serverURL` | Refused by the plugin itself; nothing leaves the machine. Development: SMTP (a local catcher) as before | — |
For a site that will send through the service: `serverURL` must be the public address the site answers on **without
a redirect**; "Sender address" should be filled in (replies go there — the service's address has no mailbox);
`trailingSlash: true` or a `routes.api` other than `/api` needs Intecion to set the site's confirm address first;
the client's processing agreement should name the service (recipients and message bodies pass through it).
Steps and checks: `iapl-upgrade` "→ 1.17.0, e-mail", [email.md](./email.md).
- **Microsoft Graph is deprecated and will be removed in 2.0** (with Payload 4). It works unchanged through 1.x.
To move a site: [email.md](./email.md) "Moving off Microsoft Graph" — when the owner says so, not in passing.
- **Recommended, one line — public pages load with one request instead of two:** in `next.config.ts` change
`withPayload(withSecurityConfig(nextConfig))` to `withSecurityConfig(withPayload(nextConfig))`. Payload's
`withPayload` sends `Accept-CH`, `Critical-CH` and `Vary: Sec-CH-Prefers-Color-Scheme` for every path, and
`Critical-CH` makes Chrome repeat the first document request of every visit; as the outer wrapper,
`withSecurityConfig` keeps the three headers on `/admin/:path*` only. **A site that is not edited behaves exactly
as before** (the inner wrapper cannot see Payload's rule). Another panel address:
`{ adminClientHints: { route: '/its' } }`; the old behaviour on purpose: `{ adminClientHints: false }`.
Check: `curl -sI <site>/pl | grep -i critical-ch` prints nothing, `<site>/admin/login` still prints it.
`iapl-upgrade` "→ 1.17.0, the public pages' first request", [security.md](./security.md) "Client hints".
- **Otherwise nothing.** Recommended after the update: `pnpm exec iapl-skills` (or the project's `ipal:skills` script) and commit —
the skills are named `iapl-*` now; the 16 old `ipal-*` folders are removed by name, a project's own `ipal-…` skill
stays, and the pointer block in `AGENTS.md` is rewritten in place.
- **A log filter or alert on `[ipal]`, or a script that reads the doctor's output:** the log prefix is `[iapl]`; the
doctor's summary line starts `iapl-doctor:` (was `ipal-doctor:`), and its internal status line is
`IAPL_DOCTOR_STATUS`. The rate-limit scope of `GET /api/ipal/doctor` was renamed with it (one fresh minute).
- **CI that runs the doctor with `--strict`:** until the skills are refreshed it exits 1 with two warnings
(`agents-md`, `skills-current`: the skills and the pointer block are older than the plugin) — as after every
upgrade. Run `pnpm exec iapl-skills` and commit in the same change as the version bump.
### Changed
- **Consent: "Reject" is as prominent as "Accept all" by default** (`equalChoice` defaults to `true`). The EDPB
Cookie Banner Taskforce (2023) found a missing or weaker reject option an infringement for most authorities; a UODO
article repeats it. `equalChoice={false}` restores the secondary look; `iapl-doctor` (`consent-banner`) warns, and a
development console warning names a banner `order` without `'reject'`.
- **Consent log on by default** (`consentLog` — `false` turns it off). The endpoint reads at most 4 KiB of body
(`413` beyond, before anything is parsed) and refuses a `version` above the site's policy version (`400`). `<SiteProviders>` posts every decision to it by
itself: `getSiteShell` gives `consentLogEndpoint` (`'/api/ipal/consent'` with the config's API route, `null` when
the log is off); `logEndpoint={false}` stops one layout. A write without its SQL table answers `503` and logs one line
per process. The posted body gains `gpc`; the record's fields are unchanged.
- **Consent: withdrawal stops the tools already running** — `fbq('consent', 'revoke')`, `ttq.revokeConsent()`,
`clarity('consent', false)` (and `grant` / `consentv2` on a new grant), and the panel's listed local / session
storage keys of the category are removed with its cookies (also the panel's listed cookie names). Clarity gets
`consentv2` when it loads. `ads_data_redaction: true` is set with the Consent Mode default.
- **Default banner text** (English and Polish, used only when the panel's message is empty): one more sentence on
changing the choice with the cookie button and setting cookie rules in the browser (PKE art. 399 asks for the latter).
- **Docs:** `docs/consent.md` no longer calls equal choice a "UODO requirement" (it is the EDPB authorities' position,
repeated by UODO; no UODO or UKE banner decision was found) and no longer says Global Privacy Control is not needed.
`docs/analytics.md` says what Consent Mode `advanced` sends before consent.
- **The cookie banner is part of the first render** ([consent.md → First paint](./consent.md#first-paint-the-banner-is-part-of-the-first-render-1170)).
Until now `<CookieBanner>` rendered nothing until the page had hydrated, so on a first visit its text appeared late
and on a text page became the LCP element (reference site, mobile profile, 4x CPU, slow 4G: page painted at 1.0 s,
banner and LCP at 2.7 s; now banner and LCP at 1.0 s; CLS unchanged). The banner is now in the server HTML with
`hidden`, followed by one small inline script that, before the browser paints, shows it (no decision, an older
Policy version, an unreadable cookie) or keeps it hidden (current decision). **An existing site gets this by
updating, with no edit; public pages stay static / ISR.** Nothing about consent changes: no tag loads earlier, the
Consent Mode default is still pushed first, the cookie, the consent log and withdrawal are as before. A click on a
banner button before hydration is carried out once the page is live.
**What an existing site may notice:** the page's HTML is about 3 kB larger, 1.2 kB gzipped (the banner's markup and the script; the detailed cookie
list is not in it); `[data-ipal="banner"]` exists in the DOM (hidden) for a returning visitor until hydration — a
project e2e test that counts the element right after load should assert `toBeHidden()`; with a **nonce CSP** the
script needs the nonce — `<SiteProviders nonce>` passes it (without it the banner appears after hydration, as
before); with **Tailwind 3** and a `classNames.root` that sets `display`, add
`[data-ipal="banner"][hidden] { display: none !important }`. Old behaviour: `<CookieBanner firstPaint={false} />`.
`CookieButton` and `useConsent` read the decision through a store (`useSyncExternalStore`) instead of an effect.
- **New names beside the old ones** (the old ones are deprecated and go in 2.0):
`iapl()` for `ipalKit()`, `IaplOptions`, `iaplEnvRules`, `IaplEnvFeatures`, `iaplT`, `iaplVar`, `IAPL_TOKENS`,
`IAPL_BREAKPOINTS`, `IaplTokenName`, `IaplGlobalSlug`; commands `iapl`, `iapl-doctor`, `iapl-skills`, `iapl-tokens`,
`iapl-blocks` (the `ipal-*` commands are the same programs); env `IAPL_<NAME>`, with `IPAL_<NAME>` read when the new
one is missing or empty; `iapl-doctor.json` (an existing `ipal-doctor.json` is read and written as before);
`iapl-audit-skip:`; the pointer block `<!-- iapl:start -->`.
- **Not renamed:** the package and its import paths, import-map paths, routes `/api/ipal/*`, CSS tokens `--ipal-*`,
`data-ipal` hooks, `config.custom.ipal`, `req.context` flags, the `ipal` translation namespace, the header
`X-Ipal-Cookie-Crawler`. They change, with a migration path, in 2.0.
- `ipalEnvRules()` still returns its rules under the `IPAL_` names (the `IAPL_` ones as aliases), and the constants
`COOKIE_SCAN_URL_ENV` / `COOKIE_SCAN_TOKEN_ENV` keep their values, so code that adapts the rules by name or reads
`process.env[COOKIE_SCAN_URL_ENV]` works as before. New: `iaplEnvRules()` (names `IAPL_…`, old ones as aliases),
`IAPL_COOKIE_SCAN_URL_ENV`, `IAPL_COOKIE_SCAN_TOKEN_ENV`, and `readEnv` / `legacyEnvName` (from `/env` or the root)
for code of your own.
- The files `bin/ipal-*.mjs` are still in the package and run the new commands (older skills and CI call them by path).
- Docs, the agent guide and the skills use the new names; `AGENT.md` has one table of old and new names
("Names: IAPL and ipal-kit").
- Audit findings whose titles named a command (`iapl-tokens --check`, "forms in iapl", `IAPL_IP_HEADER in .env.example`)
keep their doctor rule ids, so settings in a project's doctor file still match.
### Added
- **Global Privacy Control honoured** ([consent.md → Global Privacy Control](./consent.md#global-privacy-control-1170)):
a browser that sends `Sec-GPC: 1` / `navigator.globalPrivacyControl` gets no banner, analytics and marketing stay off
and nothing is sent to Google (also in Consent Mode `advanced`) or a pixel; the visitor can still opt in from the
cookie button, and that choice wins (stored with `gpc: true`). A grant made without the signal gives way when the
signal appears. Decided in the browser before the first paint — pages stay static, no `Vary`. Options:
`gpc: 'honour' | 'ask' | false` on `SiteProviders` / `ConsentProvider` / `consentBannerScript`. Building blocks:
`resolveConsent`, `gpcFromNavigator`, `gpcFromHeaders`, `GPC_CATEGORIES`, `GPC_HEADER`, `gpcWellKnown`
(`/.well-known/gpc.json`), types `GpcMode`, `ResolvedConsent`; `/client`: `readEffectiveConsent`, `signalVendors`,
`clarityConsent`. The consent record gains `gpc`; the statistics endpoint keeps a visitor id out while the signal
overrides a choice made without it. Text: `texts.gpcNotice` (PL / EN), class slot `gpcNotice`.
- **`maxAgeDays`** on `SiteProviders` / `ConsentProvider` / `useConsent`: the re-ask period (default 180 days).
- **`CONSENT_LOG_PATH`** (`'/ipal/consent'`).
- **Doctor rules** `consent-log-migration` (Postgres / SQLite with the log on and no migration creating
`consent_records`: warning — every consent check of 1.17.0 is a warning) and `consent-banner` (`equalChoice={false}`, an `order` without `'reject'`, `gpc={false}`,
`cookieButton={false}` with no `reopen`, a hand-wired `ConsentProvider` without `logEndpoint`: warnings; `gpc="ask"`:
info; the crawl judging another Consent Mode than the layout: warning).
- **`iapl-consent-check`**: five runs — adds Global Privacy Control, equal prominence (computed size and look of
"Reject" against "Accept all") and withdrawal; warns about YouTube thumbnails, Google Fonts and the Maps API loaded
before a choice. `<YouTubeEmbed>` warns in development when it has no `poster`.
- **[consent-behaviour-spec.md](./consent-behaviour-spec.md)** — the behaviour IAPL and IAWL share: categories, the
record and cookie, Consent Mode mapping, Global Privacy Control, equal prominence in testable terms, the shared test
list. **[dev/consent-compliance-proposal.md](./dev/consent-compliance-proposal.md)** — where the banner stands
against the rules, with sources.
- **Payload's colour-scheme client hints go to the admin only** ([security.md](./security.md) "Client hints").
`withSecurityConfig(withPayload(nextConfig))` — the wrapper **outside** `withPayload` — moves `Accept-CH`,
`Critical-CH` and `Vary: Sec-CH-Prefers-Color-Scheme` from `/:path*` to `/admin/:path*`. Before, every public
page, route handler and static file carried them, and Chrome requested the first page of a visit twice (measured
on the built reference site, both bundlers: 2 document requests → 1; one network round trip less before the
first byte). The panel keeps its light / dark first paint. Option `adminClientHints`: `{ route }` for a changed
`routes.admin`, `{ sources }` for more paths, `false` for the old behaviour. Exports:
`scopeColorSchemeClientHints`, `adminClientHintSources`, `COLOR_SCHEME_CLIENT_HINT`, type
`AdminClientHintsOptions`. Doctor rule `client-hints` (info): the wrapper is inside `withPayload`, or (with
`--url`) the home page still sends `Critical-CH`. The starter and the reference site use the new order; an
existing site changes one line ("Requires project changes").
- Consent, first paint: `CookieBanner` props `firstPaint` (default `true`) and `nonce`; `ConsentProvider` props `nonce`
and `cookieValue`, `SiteProviders` prop `consentCookie` (optional server read of the consent cookie: no banner in the
HTML of a visitor who decided, at the price of dynamic pages); `consentBannerScript({ version, cookieName })` from the
root for a project's own banner; `useConsent` / `useConsentContext` also return `hydrated` and `serverRead`.
- **The Intecion Notifications Webservice (IWSN) as the default e-mail transport** ([email.md](./email.md), AGENT.md §7.2).
The admin panel calls it **IWSN**; docs, logs and the doctor use the full name.
`mailAdapter()` now picks per send: Graph when the panel says so and `GRAPH_*` is set → SMTP when the panel has a
server → Graph when `GRAPH_*` is set → the mail service → not configured (`resolveMailTransport`). The site holds no
mail key: it enrols by a call-back to its own domain and keeps its token in `payload-kv` (one entry per host, `iapl:mail-relay:site:<host>` —
no field, no column; not readable over REST or GraphQL, an admin included; proven by a test). The token is bound to
the site's server addresses and to the host it was issued for (a database copied to another host enrols as itself),
rotated every 90 days, healed by re-enrolment. One message = one `Idempotency-Key` and
one encoding across at most three attempts; a send with no answer is reported as **not confirmed** (it may be out)
and, while the same process runs, goes out under the same key when sent again (after a restart or from another
instance a repeat is a new message). One message has one budget of time — 10 seconds, 30 with files
(`mail.relay.totalTimeoutMs`) — so a service that hangs does not hold a form's visitor for the sum of the attempts. Every message says what it is (form notification, form confirmation, account,
test, system): form mail and Payload's "forgot password" are marked by the plugin; `withMailKind` /
`runWithMailKind` for a project's own. Account mail is limited by the site itself (5 an hour to one address, 10 by
one visitor; `mail.relay.accountMail`). Limits and the file size come from the service (30 an hour, 200 a day, 10 MB
unless Intecion set others); `mailAttachmentLimit` reports the latter.
- **Plugin option `mail`**: `mail: { relay: false | { url, host, enrol, token, senderName, kind, accountMail,
confirmRateLimit, accessKeyField, otherHosts, developmentHosts, totalTimeoutMs, timeoutMs, retryBackoffMs, fetchImpl }, graphDeprecationWarning }`; `mailAdapter({ relay })`.
- **Plugin option `developmentHosts`** (default `DEFAULT_DEVELOPMENT_HOSTS` = `['*.dev.netscale.pl']`): host patterns
of development, preview and staging addresses. A site whose own host matches is non-public **with no environment
variable**: holding a copy of another site's data, it does not mail real people by itself (the table above).
`*.dev.netscale.pl` is Intecion's own development domain, where the team's sites are built before launch; a
project replaces the list with its own patterns or empties it (`[]`). Building blocks: `matchDevelopmentHost`,
`isDevelopmentHost`, `assertDevelopmentHosts`, `pluginDevelopmentHosts`, `siteIsNonPublic`, `siteNonPublicSignal` (`NonPublicSignal`).
A malformed list (not an array of non-empty host patterns, or a lone `*`) stops the start instead of being
ignored; patterns are punycoded, a trailing dot and the port are ignored.
Doctor: `mail-non-public` (info, deep) names the signal that makes a site non-public. The list is about mail only: it does not make a development host noindex. Keeping development addresses out of search engines stays the hosting's business (Coolify) or `IAPL_NOINDEX=1`. Nothing changes in what a site serves to robots on upgrade.
- **Panel:** the state block on the e-mail tab (transport in effect, the site's state with the service, sender and
reply address, what is left of the limits, a replaced sender name; "Check now", "Connect again", "Disconnect";
"Enter an access key" for a token issued by hand only with `mail.relay.accessKeyField: true`); "Sending method" reads "Automatic" / "Microsoft Graph (deprecated)"; the server field reads
"Own SMTP server"; the test e-mail names the transport it used. New status codes `relay-*` with texts in English
and Polish. With `relay: false` the tab is worded as in 1.16.
- **Doctor:** `mail-transport`, `mail-relay-state`, `mail-reply-address`, `mail-graph-deprecated`, `mail-relay-route`;
the status endpoint reports `mail` (states and codes only).
- **Building blocks (root entry):** `relayAdapter`, `enrolRelay`, `getRelayStatus`, `rotateRelayToken`,
`disconnectRelay`, `setRelayToken`, `sendThroughRelay`, `relayRequest`, `buildRelayMessage`, `bareAddress`,
`bareAddresses`, `cleanSubject`, `relayConfirmEndpoint`, `relayPanelEndpoints`, `mailPanelState`,
`resolveRelayOptions`, `relayHost`, `isPublicHost`, `relaySenderName`, `relayAttachmentLimit`, `relayStatusFor`,
`withMailKind`, `runWithMailKind`, `mailKindOf`, `expectMailTo`, `buildFormMailKindHook`, `createFakeRelay` (the
service in memory, for tests), the constants `RELAY_*`, `MAIL_KINDS`, `MAIL_KIND`, `GRAPH_DEPRECATION_NOTICE`, and
their types; `MailRelayStatus` from `/admin`.
- The wire contract of the service (version 1.7.1) is copied in the repository (`contracts/mail-relay/`) with a
checksum test; every example of it runs against the plugin's fake service and against the plugin's client.
- **`iapl-doctor` rule `legacy-names`** (info): lists the old names a project still uses, each with the new one.
Information, not a defect. A warning only for `iapl-doctor.json` and `ipal-doctor.json` side by side, or one variable
set as `IAPL_…` and `IPAL_…` with different values (the `IAPL_` one is read).
- **`storageNames: 'ipal' | 'iapl'`** (default `'ipal'`) for the two names the plugin stores: the statistics visitor
cookie the cookie scanner declares (`ipal_vid` / `iapl_vid`) and the 2FA attempt counter's key in `payload-kv`
(`ipal:2fa-verify:…` / `iapl:2fa-verify:…`). **Sites made with `iapl create` from this version on get `'iapl'`;
existing sites change nothing** — same cookie, same cookie list, same counters. With it: `<PageStats visitorCookie>`,
`IAPL_VISITOR_COOKIE`, `visitorCookieFor`, `twoFactor.verifyLimit.keyPrefix`, and the doctor rule `storage-names`
(the cookie the layout sets is the one the scanner declares). Withdrawing consent deletes the cookie under either name.
Not a switch for a live site: it would start visitors' histories and the running 2FA counts again.
- `EnvRule.aliases` for `assertEnv`: older names of a variable, read when the main one is missing.
### Fixed — Postgres: many requests at once no longer stop the site
- **Ten or more form submissions at the same moment, or ten "forgot password" requests, stopped the whole site on
Postgres** — every request, also pages that only read, waited for good (older than 1.17.0; MongoDB sites were not
affected). Each transaction holds a pool connection, and code inside it that runs without its `req` (Payload's own
"forgot password", the e-mail adapter reading Site integrations and writing the send status, `payload.kv`) needs a
second one; the default pool has 10. Measured on Postgres 17: 12 submissions or 12 resets at once never finished;
now 30 of each, also against an SMTP server that never answers, finish while an ordinary request answers at once.
- **`connectionReserve`** (new plugin option, default on): a fifth of the pool, at least 2, stays free of
transactions; at most `pool size − reserve` transactions are open at once and the next one waits. A transaction
begun inside another one (a project hook that calls the Local API without `req`) takes no place and goes at once,
but never takes the last connection — 9, 12 and 30 such submissions at once finish (before: 12 stopped the site).
`false` = as before. Building blocks `reserveConnections`, `watchTransactions`, `afterCommit`,
`inWatchedTransaction`, `transactionsBusy`, `transactionWatchState`, `poolSize`, `defaultConnectionReserve`,
`RESERVE_ESCAPE_MS` ([deployment.md](./deployment.md) §4.3a, with the measured table).
- **Payload's "forgot password" and "verify your e-mail" go out after their transaction commits** when sent through
`mailAdapter()` (`mail.accountMailAfterCommit`, default on; same request, nothing sent on a rollback). The message is
matched to its request by its token (Payload's `generateEmailSubject` is wrapped; a project's own one is kept). With the mail
service hanging, 30 resets and 30 submissions at once finish in about one send budget (11 s) instead of 43.5 s.
Building blocks `withAccountMailAfterCommit`, `sendAccountMailAfterCommit`, `holdAccountMail`,
`releaseAccountMail`.
- **Form e-mails go out after the submission's transaction commits** — same request, same answer to the visitor
(a file that could not be sent is still reported). A submission rolled back by a later hook now sends nothing; a
send that fails after the commit leaves the submission stored (as a failed e-mail always did). Sites without
transactions (MongoDB without a replica set, SQLite) send at once, as before. The old way:
`forms: { emailsInTransaction: true }`. Building blocks `sendAfterCommit`, `sendFormEmails`
([forms.md](./forms.md) "When e-mails go out").
- **The panel's send status** (`recordIntegrationStatus`): many sends failing at once write it once; while the pool
is busy the write is not waited for.
- **SMTP time-outs**: 10 s to connect (was nodemailer's 2 min), 30 s for the greeting, 60 s of silence (was 10 min);
`mailAdapter({ smtp: { timeouts } })` / `panelSmtpAdapter({ timeouts })`, `SMTP_TIMEOUT_DEFAULTS`, `SmtpTimeouts`.
- Not covered: an e-mail adapter of your own (not `mailAdapter()`) still gets Payload's account mail inside the
transaction unless it calls `sendAccountMailAfterCommit` first.
### Deprecated
- **Microsoft Graph as an e-mail transport** — `graphAdapter`, `GraphAdapterArgs`, `mailAdapter({ graph })`,
`iaplEnvRules({ emailGraph })` and the four `GRAPH_*` variables. Nothing new is built on it; it gets fixes only and
is removed in 2.0. A site on it prints one warning per start (silence: `mail: { graphDeprecationWarning: false }`);
the starter and `iapl-setup` no longer offer it.
## 1.16.7 — hardening
> **Read before upgrading.** Several defaults get stricter. Most sites change nothing, but check
> "Requires project changes". What can stop people: an account with only the role `user` can no longer open the
> panel; a form with files is refused while Turnstile is misconfigured; a script that creates staff accounts
> with a password under 12 characters fails; behind a proxy that hides the site's address and without
> `serverURL` nobody can enter a 2FA code; a project's own staff collection without access rules gets rules;
> changing the SMTP server in the panel asks for the password again; a slug in `access.staffCollections` that
> is not an auth collection keeps Payload from starting (with a health check the old container keeps serving).
> Not a routine patch: agree the deploy with the owner and read the first start's log. No import-map change,
> **no schema change and no migration** on any database.
### Security
- **A secret that is not text is refused** (`false`, `0`, a list, an object used to be stored as typed).
- **Stored secrets are write-only.** `smtpPassword` and `turnstileSecretKey` (Site integrations) were returned
by REST and GraphQL, and sent to the browser by the panel, for everyone who could read that global; the
"masked" field only drew dots. Now every read through access control gets `'********'` when a value is stored;
only server code (the Local API with access control off) reads the value. A save that sends nothing, an empty
value or the mask keeps the stored value; `'[[clear]]'` removes it. The panel is the source of these secrets
([security.md](./security.md) "Stored secrets").
- **The SMTP password stays with the server it was saved for.** Hiding the value was not enough: an admin
session could point the SMTP server at a machine of its own and have a test e-mail deliver the password. A
save in the panel or over the API that changes the server, the port or the user name while a password is
stored must now send the password again, or remove it (`secrets.reenterOnChange`) — whatever the transport
says (the mail adapter falls back to SMTP when Microsoft Graph is not configured). Server code with the Local
API is not asked.
- **Restoring a version of Site integrations** (only where a project turned versions on for that global)
answered with the stored secrets; they are masked there too (`maskSecretsOnRestore`).
- **Nobody creates an account for themselves, or takes one over.** (1) Payload's first-user route
(`POST /api/<slug>/first-register`) answers for every empty auth collection. On an empty **second staff
collection** (`access.staffCollections`) the first visitor became a staff account — an admin to the plugin.
It now answers only for the collection the panel logs in with, in any spelling of the URL (the plugin's own
endpoint sits in front of Payload's). (2) A project's **own** staff collection without `create`, `update` or
`delete` rules had Payload's default, "any logged-in user" — an account of any auth collection: a visitor
account could create a staff account, or change a staff account's password and roles. Such a collection now
gets rules for the operations it has none for: with the plugin's roles — an admin (update: or the account
itself); with role values of its own, or none — an account of that same collection, or a plugin admin.
`unlock` gets the admin rule and `read` "a staff account" (a visitor account could list the staff accounts
and lift their login lock). An account never changes its **own** roles: the collection's `roles` field, when
it has no field access of its own, is closed for that. `readVersions` gets the `read` rule (versions hold
what the accounts hold). The rules hold with 2FA on and off, in a production build, and for a staff
collection that a plugin listed after ipalKit adds — there they are put in front of whatever rules that
collection has (in a sanitized config Payload's default cannot be told from a rule somebody wrote). Anonymous sign-up into the staff collection was already refused; the
plugin's injected collection already had these rules. No known site has a second staff collection
([access.md](./access.md) "Account rules").
- **2FA verify and setup attempts only from the site's own origin.** A page on another origin that the browser
still sends the login cookie to (a sibling subdomain, when neither `serverURL` nor `csrf` is set) could burn an
account's five verify attempts and lock its owner out, without the password. Such requests are refused before
they are counted. A refusal is logged once per origin with the ways to allow it. **The verify count is also
stored in the database**, so a restart or a second instance no longer resets it.
- **Dashboard alerts no longer show integration error texts to every panel role**: details for admins, a neutral
line for editors, nothing for others or for a session that still owes its second factor (`'all'` restores the
old behaviour and checks neither).
### Changed
- **The admin panel opens for `editor` and above** (`accounts.panelRole`). An account that holds only `user`
sees "Unauthorized" in the panel; the API is not touched. With `access.firstUserAdmin: false` and a default
role below the panel role the first account of a fresh site could not get in: the default panel role is then
not applied (a warning at start), and an explicit `accounts.panelRole` is refused at start with the fix.
- **A password set on a staff account has at least 12 characters** and is not the account's e-mail address
(`accounts.password`) — also in a reset by e-mail and a bulk update. Existing passwords are never checked.
- **A form with files is refused while Turnstile cannot check** (wrong or missing secret, Cloudflare down); a
text form is accepted as before (`forms.turnstileOnConfigError`).
- **`TURNSTILE_SECRET_KEY` from the environment is deprecated.** It still works when the panel field is empty
and logs a notice once per start. It will be removed in a later release, named here in advance.
### Fixes
- **Role checks in a client component: import `isAdmin`, `isEditor` and `hasMinimumRole` (and the type `Role`) from
`@intecion/ipal-kit/client`.** The advice since 1.16.4 led to importing them from `@intecion/ipal-kit`, which reaches
`server-only` modules: `next build --webpack` fails with `'server-only' cannot be imported from a Client Component
module`. The main entry keeps exporting them for server code; its Turbopack behaviour is unchanged. access.md also
says now what `useConfig()` carries: `admin.user` only, so accounts of `access.staffCollections` need
`{ staffCollections: [...] }`.
### Added
- Options: `accounts` (`panelRole`, `adminOnlyCreate`, `adminOnlyWrite`, `staffOnlyRead`, `firstUserRoute`,
`password`), `secrets.writeOnly`, `secrets.reenterOnChange`, `forms.turnstileOnConfigError`,
`twoFactor.sameOrigin`, `twoFactor.verifyLimit.store`, `dashboardAlerts`.
- ipal-doctor rules: `access-missing` (no `access` option: every panel account is an admin), `csrf-empty`
(neither `serverURL` nor `csrf`), and with `--url`: `open-signup` (info), `staff-accounts-open` (error; warning
for `read` and `readVersions`: a staff collection an account of another collection may write to, read or unlock),
`staff-own-roles` (warning: a staff collection with role values of its own and no rules), `turnstile-degraded`
(warning, error after 24 hours), `turnstile-env-key`. The deep status gained `openSignUp`, `staffOnOwnRoles`,
`staffOpenToOthers`, `turnstile`,
`turnstileSecretFromEnv` (states and slugs, never a key).
- Exports: `writeOnlySecret`, `writeOnlySecrets`, `SECRET_MASK`, `SECRET_CLEAR`, `maskSecretAfterRead`,
`keepSecretBeforeValidate`, `buildKeepSecret`, `isSecretMask`, `INTEGRATION_SECRET_FIELDS`,
`SMTP_PASSWORD_BOUND_TO`, `maskSecretsOnRestore`, `maskWriteOnlySecrets`; `panelAccess`, `applyPanelRole`,
`resolvePanelRole`, `countBelowPanelRole`, `DEFAULT_PANEL_ROLE`; `staffCreateAccess`, `staffUpdateAccess`,
`staffReadAccess`, `sameStaffCollectionAccess`, `rolesByAdminOnly`, `rolesNotOwn`, `bothAllow`, `hasPluginRoles`,
`applyStaffAccountAccess`, `adoptLateAuthCollections`, `unknownStaffCollections`, `buildFirstUserEndpoint`,
`applyFirstUserRoute`, `openSignUpCollections`, `staffCollectionsOpenToOthers`, `staffCollectionsOnOwnRoles`; `checkPassword`,
`buildPasswordRuleHook`, `applyPasswordRule`, `resolvePasswordRule`, `DEFAULT_PASSWORD_MIN_LENGTH`;
`requestFromOwnOrigin`, `ownOrigins`, `reportRefusedOrigin`; `buildVerifyLimit`, `verifyLimitKey`, `clearVerifyLimits`;
`turnstileSecretFromEnv`, `TURNSTILE_SECRET_ENV`; from `/server`: `passTurnstile`, `passSubmitGates`,
`resolveTurnstileOnConfigError`, `TURNSTILE_ON_CONFIG_ERROR_DEFAULT`.
- `MaskedField` says "A value is set" for a write-only field and offers "Remove the stored value".
### Requires project changes (what projects must update)
- **No migration.** This release adds no field, column, table or collection of its own on any database. The
stored 2FA attempt count uses Payload's own `payload-kv` collection, which every schema of a Payload version
that has `payload.kv` already contains; where it cannot be reached the count stays in memory and the limit
still holds.
- **A slug in `access.staffCollections` (or `access.authCollection`) that is not an auth collection of the
config: Payload does not start.** The log says `[ipal] access names "…" as a staff collection, but this config
has no auth collection with that slug` and lists the auth collections. The process stays up, but every Payload
call fails: `/api/health` answers 503, `/api/*` and the panel 500 (a page that needs no Payload call may still
answer). With a health check ([deployment.md](./deployment.md) §4.4) Coolify keeps the old container. Check
the slugs before the deploy. (A plugin listed after ipalKit may add the collection.)
- **A staff collection added by a plugin listed after ipalKit**: the plugin's rules are put in front of the
rules that collection has, so both must allow — a rule of its own there can only narrow, not widen. To keep
its rules exactly as they are: `custom: { ipal: { accountRules: false } }` on that collection.
- **Set `serverURL`** if it is not set. Behind a reverse proxy that rewrites `Host` and sends no
`X-Forwarded-Host` (nginx's plain `proxy_pass`; Coolify / Traefik keep `Host`) the server does not know its
own address, and the 2FA code page is refused as "another origin": **nobody can enter a code**. The log says
`[ipal] 2FA: a code from origin "…" was refused` once per origin, with the fix. Other ways out:
`twoFactor: { …, sameOrigin: { origins: ['https://…'] } }`, or make the proxy send `X-Forwarded-Host`.
- **Every site: read the first start's log.** `[ipal] N account(s) of "users" are below the role "editor" and
cannot open the admin panel` — give the people who work in the panel `editor`, or set
`accounts: { panelRole: 'user' }`. `NOBODY can open the admin panel` (an error): no account has the role —
a script with the Local API (`roles: ['admin']`), or `accounts: { panelRole: false }` and redeploy.
- **Own code that read `smtpPassword` / `turnstileSecretKey` over REST or GraphQL**, or with
`overrideAccess: false`: it now gets `'********'`. Read them on the server with
`payload.findGlobal({ slug: 'site-integrations' })`. Nothing to do otherwise: stored values stay, e-mail and
Turnstile keep working.
- **A site whose Turnstile secret is only in `TURNSTILE_SECRET_KEY`:** nothing breaks. With the owner, move the
key into Site integrations → Spam protection, then remove the variable (`ipal-doctor --url` →
`turnstile-env-key`).
- **Forms with a File field:** make sure Turnstile works (`ipal-doctor --url` → no `turnstile-degraded`); while
it does not, those forms are refused. To keep accepting them: `forms: { turnstileOnConfigError: { files: 'allow' } }`.
- **A project's own staff collection without `create` / `update` / `delete` / `unlock` / `read` / `readVersions`
rules** gets
them. With the plugin's roles (`access.authCollection`, or a `roles` select with only `user` / `editor` /
`admin`): only an admin creates, deletes and unlocks accounts and changes roles; an account is changed by an
admin or by itself — if non-admins did that on your site, write the rule you want. With **role values of its
own** (`superadmin`, …) or no roles: accounts of that collection keep working as before, except that an
account no longer changes its **own** roles; accounts of other collections are refused. The plugin does not
know your roles, so write your own rules (`ipal-doctor --url` → `staff-own-roles`). `read`: only staff
accounts read a staff collection — **a front end that shows staff accounts to logged-in visitors** (an author
box read with a customer's session) needs its own `read` rule or `accounts: { staffOnlyRead: false }`. Off:
`accounts: { adminOnlyCreate: false, adminOnlyWrite: false, staffOnlyRead: false }`. `first-register` for other auth collections: `403` unless the collection allows
sign-up, or `accounts: { firstUserRoute: 'all' }`.
- **`access.firstUserAdmin: false`** with `access.defaultRole` below `editor`: the panel role is not applied (a
warning at start); with `accounts.panelRole` set the start fails — set `access.defaultRole: 'editor'` or
`accounts: { panelRole: false }`.
- **A script that changes the SMTP server, port or user name over REST / GraphQL** must send the password with
it (`400` "Enter the password again…" otherwise); a seed with the Local API is not asked. In the panel the
person types the password again. `secrets: { reenterOnChange: false }` turns it off.
- **A rolling update:** a Site integrations page opened under the new version and saved against the old one
stores `********` as the password. After the deploy send a test e-mail.
- **Scripts that create staff accounts with a password under 12 characters** fail with a validation error.
Existing accounts with short passwords keep logging in.
- **A panel or front end on another domain that posts to `/api/verify-totp`:**
`twoFactor: { …, sameOrigin: { origins: ['https://…'] } }`.
- **Only if a `'use client'` file imports `isAdmin`, `isEditor` or `hasMinimumRole` from `@intecion/ipal-kit`:**
change the import to `@intecion/ipal-kit/client` and keep the second argument (`isAdmin(user, config)`).
`grep -rlE "^['\"]use client" src | xargs grep -nE "from '@intecion/ipal-kit'"` lists the files; `import type` may stay.
- `pnpm payload generate:types`, `pnpm ipal:skills`.
### Known limitations
- Write-only protects the API and the panel, not the database: the two secrets are stored in plain text there
and in backups (encryption at rest is not part of this release). A secret equal to `********` or `[[clear]]`
cannot be stored. A session that may send e-mail can still use the mailbox through the site (send, not
read). On a port other than 465 the SMTP connection is encrypted only when the server offers STARTTLS, as
before; an option to require it is not part of this release.
- The account rules for a staff collection with role values of its own do not enforce those roles: an account
cannot change its own roles, but inside the collection every account may still create an account with any
role, and change or delete another account — the plugin cannot rank roles it does not know. Write the
collection's own rules; `staff-own-roles` in the doctor names such a collection.
- An account of a staff collection **without a `roles` field** is an admin to the plugin (unchanged): it may
manage accounts of the other staff collections too. Give every staff collection roles, or its own rules.
- The panel role and the password rule need `access` (roles) resp. a staff collection with password login; a
second staff collection without a `roles` field is not affected by `panelRole`.
- The stored verify count uses Payload's `payload.kv`; on a Payload version without it the count is in memory
only. Two instances can each let a few attempts through before the other's write lands ("max per instance" at
worst, never unlimited).
- The own-origin check trusts `Host` / `X-Forwarded-Host` as the proxy sets them, and passes requests without
`Origin` and `Sec-Fetch-Site` (non-browser clients).
- `access-missing` and `csrf-empty` are text searches of the config file and can miss or misread unusual
spellings; `open-signup` and `staff-accounts-open` call the access rules with a made-up request and count a
rule that throws as closed.
- A plugin listed after ipalKit that **copies** a staff collection of the config under a new slug
(`{ ...staff, slug: 'copy' }`) copies the rules made for the original slug with it: accounts of other
collections are refused, but "the account itself" means an account of the original collection. Give such a
copy its own `access.update`.
- **Not run for this release:** the built site and the panel were checked in Chromium on MongoDB only (the access
rules over HTTP ran on SQLite, Postgres and MongoDB); no real mail server, no second instance, no third-party
plugin that adds an auth collection.
## 1.16.6
> **Read before upgrading — this is not a routine patch.** It turns on a new default for every site with 2FA: an
> account that has not set 2FA up can do nothing but set it up, and is **blocked after 72 hours** until an
> administrator reopens it. On Postgres / SQLite it also needs a **migration in the same deploy, or nobody can log
> in**. Work through the list below, and agree the deploy day with the owner.
### Requires project changes (what projects must update)
**Every site with 2FA on. Do all of it in ONE deploy.**
- **Before upgrading a live site:** `pnpm exec ipal-doctor --url <site>` → accounts without 2FA. Each sets 2FA up
now, or is removed. At least one administrator (better two) must have 2FA set up, or nobody can reopen setup
from the panel.
- **Agree the day with the owner:** the 72 hours of every existing account without 2FA start at the deploy,
once. Deploy when those people can act within three days (not before a holiday), or have them set 2FA up first.
- **In the same deploy:** the update, `pnpm payload generate:types`, `pnpm payload generate:importmap` (commit
`importMap.js`; new: `TwoFactorStatusField`, `TwoFactorAlert`), `rm -rf .next`, redeploy. Run
`pnpm exec ipal-doctor` before deploying: it reports a map without the new entries (then the panel has no "Reopen
setup"). Coming from before 1.16.5, the map must also have `SafeTotpView`, or the 2FA screens have no code form.
- **Postgres / SQLite — required, in the same deploy: `pnpm payload migrate:create`, commit, and the migration
applied when the new container starts** (`prodMigrations`, or `pnpm payload migrate && pnpm start` —
[deployment.md §4.3](./deployment.md#43-database-migrations-postgres); not Coolify's Pre-deployment command,
which runs in the old container). The 2FA collection gets the column `totp_setup_from`.
**Without it every login answers 500 — administrators with 2FA included — and nobody can sign in to the
panel.** The log says so at start (`NOBODY CAN LOG IN`), and `ipal-doctor` reports a SQL project whose
migrations do not mention the column. Every project with 2FA on needs it, also with `requireSetup: false`.
MongoDB: nothing.
- **An integration that logs in with a password and has no TOTP** stops working: give it an API key (passes as
before) or exempt it on purpose: `twoFactor.requireSetup: { exempt: ({ user }) => user.email === '…' }`.
- **Own code** calling `payload.find({ …, user, overrideAccess: false })` with a user fetched by id: refused for
every account of the 2FA collection now (before: only accounts with TOTP set up). Use `payload.auth({ headers })`.
- **A reset by an administrator logs that account out everywhere** and needs the administrator's own TOTP code. A
script on an API key needs `twoFactor.resetAccess`. After a suspected compromise change the password too.
- **Options:** `windowHours` is a number (0 or more) or `false`; `exempt` is a plain function returning exactly
`true`, never `async`. A wrong value stops the build and the start with a clear error.
- **After deploy:** read the log line `[ipal] 2FA: N existing account(s) without two-step verification…` and tell
the owner; after 72 hours such an account needs "Reopen setup" from an administrator. Tell the staff: a new account has
72 hours to set 2FA up. `pnpm ipal:skills`.
- **An SVG favicon** has no tab icon on the 2FA screens (use a PNG if that matters).
- **Every administrator is blocked:** security.md "Every administrator is blocked" (a script, or
`{ windowHours: false }` and a redeploy).
- **Not wanted on a site:** `twoFactor.requireSetup: false` (the previous behaviour), or
`{ windowHours: false }` to keep the lock without the time limit. Sites with `twoFactor: false` are not affected.
### Changed
- **An account without two-step verification can only set it up** (`twoFactor.requireSetup`, on by default with
2FA). Until now the panel redirected such an account to the setup screen, but over the API (REST, GraphQL) its
password alone opened everything its role allowed. Now every collection, global and plugin endpoint refuses it
until TOTP is set up; the setup screen and `POST /api/setup-totp` are all it reaches.
- **A setup window of 72 hours**, counted from the account's creation or from a reset by an administrator. After
it the account is blocked — setup is refused too — until an administrator reopens it. This limits how long an
account that never set 2FA up can be taken over by someone who learned its password.
- **Accounts that already exist** get their 72 hours from the **first start after the upgrade** (not from their
creation date), so nobody is blocked at the moment of the upgrade. The server log names how many there are.
That moment is written on each account once: later restarts, redeploys and further instances do not move it,
nor does editing the account.
- **A reset by an administrator ends the account's sessions**, and by default needs a session that entered its
own TOTP code (not an API key, not an exempt account).
- **`/api/ipal/admin-icon` answers with the favicon itself when it is a bitmap** (PNG, JPEG, GIF, WebP, ICO,
AVIF — recognised by its bytes) instead of a redirect, so the tab icon also loads on the 2FA screens. An SVG
favicon is never answered from there (an SVG can carry script): it keeps the redirect to the media file.
`adminMeta.serveIcon: false` = always the redirect. `buildUploadSecurityHeaders()` now also returns a rule for
the icon path (`adminIcon: false` leaves it out).
### Added
- On every account in the panel: **Two-step verification** (sidebar) — set up / open until a date / blocked — and
for administrators "Reset two-step verification" (a lost phone) and "Reopen setup" (a blocked account).
`POST /api/ipal/two-factor/reset` `{ userId }` does the same.
- A dashboard notice for administrators: accounts without two-step verification, and how many are blocked.
- A notice on the setup screen: until when setup has to be done, or that the time has passed. All texts in
English and Polish.
- Options: `twoFactor.requireSetup: false | { windowHours, exempt, dashboardNotice, statusField, setupNotice }`,
`twoFactor.resetAccess`, `whiteLabel.inlineImages`, `adminMeta.serveIcon`. Exports: `twoFactorSetupState`,
`twoFactorSetupDeadline`, `buildSetupFields`, `stampSetupFrom`, `backfillSetupFrom`,
`buildTwoFactorResetEndpoint`, `countAccountsWithoutTotp`, `resolveRequireSetup`, `strictExempt`,
`SETUP_FROM_FIELD`, `TWO_FACTOR_RESET_PATH`, `DEFAULT_SETUP_WINDOW_HOURS`, `fetchPublicImage`,
`publicImageDataUri`, `rasterImageType`, `siteOrigin`, `PUBLIC_IMAGE_MAX_BYTES`, `UPLOAD_SECURITY_HEADERS`; admin components
`TwoFactorStatusField`, `TwoFactorResetButton`, `TwoFactorAlert`.
- `requireSetup.exempt` is strict: only an answer of exactly `true` exempts. An `async` function, and a
`windowHours` that is not a number or `false`, stop the site at start with a clear error.
- The date field `totpSetupFrom` is on the 2FA collection whenever 2FA is on, so switching `requireSetup` or
`guard` never changes the schema (and never restarts anyone's window).
- The panel's tab icon and logo load on the verify and setup screens: `GET /api/ipal/admin-icon` answers with the
image itself when it is a bitmap (no redirect to the media file), and the logo components give a session that still owes its code
the picture as an anonymous visitor would get it. No change to who can read `media`.
- ipal-doctor: a SQL project without a migration for `totp_setup_from` (error), an import map without the two
new admin components (error).
- ipal-doctor: the `2fa` rule says how many accounts without 2FA are blocked (`usersSetupClosed` in the deep
status), warns when `requireSetup` is switched off and notes a missing setup window.
### Known limitations
- **Inside the window** someone who knows the password of an account without 2FA can still set it up with their own
authenticator; the owner is then refused ("already set") and has to ask an administrator. Set 2FA up at once.
- A session without 2FA keeps what Payload gives any session about itself: `/api/access`, token refresh, logout, its own
panel preferences.
- **An exempt account** works on its password alone, with everything its role allows: give it the lowest role.
- A second staff collection (`access.staffCollections`) is outside 2FA and outside this mode, as before. With
`twoFactor.guard: false` the mode is off and the reset endpoint does not exist.
- With `auth.useSessions: false` a reset has no sessions to end: tokens live until they expire. The 2FA package's own
remove / reset endpoints do not end sessions.
- The `ipal-doctor` migration check is a text search in `src/migrations` and `migrations`.
- A site that does not use `buildUploadSecurityHeaders()` still serves a scripted SVG from its media URL as before.
- **Not run for this release:** a generated migration, `prodMigrations` and a real Coolify deploy (the missing and the
added column were tested on Postgres 17 and SQLite); an upgrade of a real site; two containers; media on R2 / S3;
`useSessions: false`; the reset by an API-key admin over HTTP; payload-2fa beta.1 and the Polish notices in a
browser; Firefox / WebKit; a Docker image; a Next `basePath`; Payload below 3.94.1.
## 1.16.5
### Security
- **The 2FA setup and verify screens no longer follow an unchecked `back` link.** `@clocklimited/payload-2fa`
(beta.1 to beta.7) sends the browser to the `back` query value once the code is accepted, without checking it.
A panel user who had typed the password, opened a prepared link to `/admin/verify-totp` or `/admin/setup-totp`
and then entered the code could be sent to another site, or have script run in the panel under their freshly
verified session. The panel's CSP does not stop this. **Affects every site with 2FA on, in every earlier
version.** It needs the user to open such a link between the password and the code; a logged-out or a fully
logged-in user is not affected. The original package fixed it in `payload-totp` 3.0.5 (GHSA-rffw-fq79-g3ch);
the fork has not.
Now ipal-kit checks `back` on the server before the package's screen gets it: only a path on the site's own
origin, inside the admin route, is kept; anything else leads to the admin root
([security.md](./security.md) "The `back` link of the 2FA screens"). The 2FA package itself is unchanged.
### Added
- **`twoFactor.safeBack`** — on by default; `false` turns the check off, a function
`(back, { adminRoute, origin }) => string` replaces the rule.
- **`safeAdminBack`**, **`wrapTotpViews`** (`@intecion/ipal-kit`) and **`SafeTotpView`**
(`@intecion/ipal-kit/admin`) are exported for projects that register the 2FA views themselves.
- **ipal-doctor**: the import-map rule also expects `@intecion/ipal-kit/admin#SafeTotpView` when the installed
plugin has it and the config does not set `safeBack: false`.
- **A stale import map is reported** (`twoFactor.importMapCheck`, on by default, `false` turns it off): in
production the plugin searches the `importMap.js` on disk at start; when the entry above is not found it logs
an error and puts a notice above the 2FA screens. The notice never replaces the screen: the file on disk is
not always the map the build used (a Dockerfile with a separate runner stage, a re-exporting map file), and
then the notice is wrong and sign-in still works — turn the check off for such a project.
- **More building blocks exported** for a project that wraps the 2FA views itself: `copyViews`,
`changedViewKeys`, `SAFE_TOTP_VIEW`, `totpViewImportKey`, `findImportMapFile`, `missingImportMapEntries`.
- **ipal-doctor** warns when the config uses the 2FA package's own setup / verify view as a view's `Component`
(such a view is outside the check).
- **A project's own 2FA screen set through the wrapped factory** (a server or a client component) is rendered
behind the check and gets the checked `back`.
### Requires project changes
- **Every site with 2FA: upgrade, `pnpm payload generate:importmap`, commit `importMap.js`, `rm -rf .next`,
redeploy — all in ONE deploy. Run `pnpm exec ipal-doctor` before deploying.** The plugin's view now stands in front of the package's two screens and
needs its import-map entry (`@intecion/ipal-kit/admin#SafeTotpView`). **If you skip this, the build still
passes and the site starts, but the 2FA setup and verify screens have no code form (HTTP 200), so nobody can
sign in to the panel.** There is no error page. What tells you: `pnpm exec ipal-doctor` before the deploy
(`import map lacks …SafeTotpView`); the line `[ipal] The admin import map may be out of date` in the log at
every start; and, where the form should be, the notice "Two-step verification may not be available". No
option, env, schema or migration. `pnpm ipal:skills` afterwards.
- **A project with its own 2FA screens or view registrations:** security.md "Your own 2FA screen".
- **Check after deploy:** log in with the password only, open
`/admin/verify-totp?back=https%3A%2F%2Fexample.com%2F`, enter the code → you land on `/admin`. A normal login
still returns to the page you came from.
### Known limitations
- After the code, the screen always goes somewhere inside the panel. A `back` that pointed at a page of the
public site (not used by the plugin or the package) now leads to the admin root; pass your own rule if a
project relied on that.
- An absolute `back` on the site's own origin is kept only when the Payload config has `serverURL`; without it
only relative values are (the plugin and the package only ever produce relative ones).
- A missing `back` used to mean "go back in browser history"; it now means the admin root.
- `back=/admin/logout` is inside the panel and is followed: the user is logged out after the code.
- A client-side 2FA screen of your own that reads `useSearchParams()` gets the raw value; use the `back` prop.
- The stale import map check is a text search of the file on disk: it can warn although everything works, and
its notice text changes only with an own `twoFactor.provider`. The `ipal-doctor` warning about a raw view is a
text search too and misses unusual spellings.
- **Not run for this release:** the browser checks on Postgres, in Firefox or WebKit, with a Next `basePath` or in a
real Docker image with a runner stage; payload-2fa beta.2 to beta.6; Payload 3.90 to 3.93. They ran in Chromium on
MongoDB with beta.7 (production build) and, on an earlier commit of the same change, beta.1 (`next dev`).
## 1.16.4
### Security
- **2FA now covers what the plugin adds.** The 2FA package wraps the collections and globals that exist when it
runs; the plugin's own globals and collections were added afterwards and were not wrapped. With 2FA on, an
account that had typed its **password but not the code** could read and change them over the API (REST and
GraphQL): Site settings, Site integrations (including the SMTP password and the Turnstile secret), Cookie banner,
Notifications, forms, form submissions, consent records, cookie review, stats, and the plugin's staff endpoints.
The project's own collections and the user accounts were protected. **Affects every site with 2FA on, in every
earlier version.** It needed a valid staff password. Now ipal-kit runs its own second-factor check on every
collection and global — whichever plugin added it and in whatever order — and on its endpoints
([security.md](./security.md) "What the second factor covers").
- **Accounts of a second auth collection are no longer staff.** Roles, and the rule "no `roles` field = every
account passes", counted for an account of any auth collection. In a project with a visitor account collection
(`customers`, a client zone) such an account passed the plugin's staff checks, with the same reach as above —
every check when its collection had no `roles` field, and `isAdmin` / `adminOnly` / `requireRole` and the others
when it had a `roles` field of its own. With open sign-up, anyone could make one. In the injected auth
collection, "only my own record" also matched an account of another collection with the same numeric id
(Postgres, SQLite). **Affects only projects with more than one auth collection.** Now the staff-collection check
comes first in every predicate and access function: only accounts of the panel's login collection,
`access.authCollection` and `access.staffCollections` count, and the injected collection uses `adminOrSelfIn`
([access.md](./access.md#who-is-staff)).
- **The 2FA package's endpoints accept accounts of the 2FA collection only.** `@clocklimited/payload-2fa` (checked
in 3.0.0-beta.1 and beta.7) takes the logged-in account from any auth collection and writes the TOTP secret into
the 2FA collection under that account's id. With numeric ids (Postgres, SQLite) an account of another auth
collection could set the secret of the staff account with the same id; whoever knew that staff password then
passed 2FA, and the owner's authenticator stopped working. **Affects only projects with more than one auth
collection on Postgres or SQLite** (MongoDB ids do not repeat across collections). ipalKit now guards every
endpoint the package registers; reset and remove also need the second factor
([security.md](./security.md) "The 2FA package's endpoints").
- **Guessing the 2FA code is now limited.** The package never counted verify attempts. Now at most 5 tries
per account in 10 minutes, right or wrong (`twoFactor.verifyLimit`); further tries get `429`. The counter lives in each server
instance's memory and resets when the app restarts or redeploys.
- **Every collection and global is covered, whatever its name** — Payload's own (`payload-preferences`,
`payload-jobs`, …), a plugin's `payload-…` collection, the job queue's `run / queue / cancel` rules.
- **Not changed, and important:** an account that has **not set TOTP up yet** is an ordinary logged-in account —
its password alone opens everything its role allows. Set 2FA up right after an account is created;
`ipal-doctor --url` reports accounts without it.
- **Who was affected, in short.** Every site with 2FA on: a staff password without the code opened the plugin's
settings, integrations (SMTP password, Turnstile secret), forms, submissions and consent records. Sites with a
second auth collection: also visitor accounts. Neither leaves a trace in the data.
### Changed
- **`ipalEnvRules()` checks the `PAYLOAD_SECRET` length in production.** A new option, `secretMinLength`, defaults
to 32; `0` turns the check off. It is checked only with `NODE_ENV=production`, and it uses the `secretVar` you
set. The error gives the length only, never the value.
- **ipal-doctor** never writes first-seen dates (`seen` in `ipal-doctor.json`) when `CI` is set. A normal local run
still writes them, and `until` silences do not depend on them.
- **`ipal-kit create <domain> --external`** with no list installs every vendored `ext-*` skill. A list is used as
given; without the flag the answers decide.
- **Docs brought in line with the code** (38 files): forms reject text over 5000 characters instead of cutting it;
Site settings `update` needs editor or higher; tab and group names (Search engines, More, Privacy, Image viewer,
Form messages); `prepublishOnly`, CLI usage, seeding `summary()`, `switchLocalePath`. Source comments and the
`ipal-kit` usage line name the current labels.
- **Visible with 2FA on:**
- A session that typed the password but not the code gets `403` from the API on everything, including public
globals, pages and media files. Anonymous visitors are unaffected. An editor who leaves the panel at the code
screen and opens the public site in the same browser may see missing images until they enter the code or
log out.
- Accounts of other auth collections get `403` from the 2FA endpoints (`/api/setup-totp`, `/api/verify-totp`, …).
### Added
- `access.staffCollections`: name further auth collections whose accounts are staff.
- `adminOrSelfIn(slug)`, `staffCollectionSlugs(payload)`, `secondFactorPassed(req)`, `requireSecondFactor(access)`
for the project's own access functions and endpoints. `isAdmin`, `isEditor` and `hasMinimumRole` take an optional
last argument that says which collections are staff: `req.payload`, a config, or `{ staffCollections: [...] }`.
- `twoFactor.verifyLimit: false | { max, windowMinutes }`.
- Per-entity opt-out from the second factor: `custom.ipal.secondFactor: false | { read: false }` on a collection
or global; the package's `custom.totp.disableAccessWrapper` is honoured as before.
- `twoFactor.guard: false`: ipal-kit's second-factor check off everywhere, the package's wrapper only (not recommended).
### Requires project changes
- **Every site: upgrade and redeploy.** No config change for a site with one auth collection and
`@clocklimited/payload-2fa` 3.0.0-beta.7 (tested: beta.1 and beta.7). `pnpm ipal:skills` afterwards.
- **`PAYLOAD_SECRET` at least 32 characters in production.**
- **Check before you deploy 1.16.4:** Coolify app → Terminal →
`node -e 'console.log(process.env.PAYLOAD_SECRET.length)'`. 32 or more: nothing to do.
- **Shorter:** either set a random value of 32+ characters (`openssl rand -base64 48`) in Coolify → Environment
Variables and redeploy, or for now add `secretMinLength: 0` (or a lower number) to `ipalEnvRules({ … })` in
`src/instrumentation.ts`.
- **Changing the secret on a live site** (Payload derives its signing key from it): everyone is logged out;
every user enters the 2FA code again (authenticator apps keep working); stored API keys (`useAPIKey`) stop
working; uploads in progress fail. Do it with the owner's OK at a quiet time. If you rotate it as part of the
security steps below, do both in one deploy ([deployment.md](./deployment.md) "`PAYLOAD_SECRET` — length and
changing it").
- **Every site: no account without 2FA.** `pnpm exec ipal-doctor --url <site>` → accounts without 2FA must be 0;
have each such account set TOTP up now, or remove it.
- **Because the earlier behaviour left no trace** (there is no audit log), decide per site with the owner:
- change the **SMTP password** and the **Turnstile secret** stored in Site integrations when a staff password
may have been known to someone else (a reused or shared password, a former employee, a phishing report) — or
simply do it once, it is cheap;
- look through **Site settings and Site integrations** for values nobody on the team set (analytics and tag
manager IDs, sender address, construction mode), and through each **form's Emails tab** for unknown
recipients or BCC addresses;
- form submissions and consent records could have been read; whether that needs a data-protection assessment
is the client's decision.
- **A site with a second auth collection:** treat the points above as required, not optional. Set
`admin: { user: '<staff collection>' }` in `buildConfig`, use `adminOrSelfIn('<slug>')` in your own auth
collections, and if the second collection really is staff, name it in `access.staffCollections`. Roles no
longer count for accounts of other collections: a rule that used `isAdmin` / `adminOnly` for them needs its own
check of `req.user.collection`. On Postgres or SQLite also ask every staff member to confirm their
authenticator still works; if it does not, reset that account's 2FA and set it up again.
- **`isAdmin` / `isEditor` / `hasMinimumRole` in a client component or in `proxy.ts` / middleware** return `false`
unless they are told which collections are staff: `isAdmin(user, config)` with the config from `useConfig()`, or
`isAdmin(user, { staffCollections: ['users'] })`. A client component imports them from `@intecion/ipal-kit/client`
(corrected later: the main entry, which this note implied, does not build there with webpack; `/client` has them
since 1.16.7). On the server (`isAdmin(req.user)` in hooks, endpoints, access functions) nothing
changes; `isAdmin(req.user, req.payload)` is the explicit form.
- **A second staff collection (`access.staffCollections`) is not covered by 2FA** — the log says so at start.
- **Own code that reads a plugin collection or global with `overrideAccess: false`** must pass a `user` from
`payload.auth({ headers })`; a user fetched by id and passed by hand is refused when it has TOTP set up, and its
role does not count without `collection`. Own
endpoints: add `secondFactorPassed(req)` or `userMeetsRole(req, role)`.
- **Startup stops with `[ipal] twoFactor: the injected 2FA plugin did not add …`:** the installed 2FA package is
not one the check recognises. Install a supported version; `twoFactor.guard: false` only as a stop-gap.
- **Check after deploy:** security.md → "What the second factor covers" → Check (three `403`), then log in fully
and open Site integrations and a form submission in the panel.
### Known limitations
- **An account that has not set up 2FA yet** is an ordinary logged-in account: its password alone opens what its
role allows, SMTP credentials included. A later release addresses this. Until then: set 2FA up right after
creating an account, and check the `ipal-doctor --url` count.
- **The verify limit** is per server instance and in memory. A restart or redeploy resets it. Whoever already holds
a staff password can keep trying slowly (about 720 tries a day), or lock the owner out of entering the code for
10 minutes at a time. A hostile page on a sibling subdomain of the site can cause that lockout without the
password, while the owner is logged in to the panel.
- **Accounts of an extra staff collection** (`access.staffCollections`) are not covered by 2FA. The log warns at
start.
- **Dashboard alert widgets** (Integration alerts, Cookie crawl alert) show integration error text to every panel
role. This is older than this release.
## 1.16.3
### Changed
+10 -9
View File
@@ -1,8 +1,8 @@
# @intecion/ipal-kit documentation
All ipal-kit docs, the agent guide and the agent skills are written in English.
All IAPL docs, the agent guide and the agent skills are written in English.
**Main rule — the plugin helps, never limits:** ipal-kit is a plugin — it helps projects and never
**Main rule — the plugin helps, never limits:** IAPL is a plugin — it helps projects and never
limits them. Every module can be turned off on its own, every default can be overridden (the project
config wins), safe defaults have an option to relax them, and the plugin exports building blocks
(helpers, builders, hooks), not only finished features. Every module page has a "Turn off, override,
@@ -11,9 +11,9 @@ extend" section that describes the current code.
| Who you are | Read |
|---|---|
| **AI agent** working in a project | [AGENT.md](./agent/AGENT.md) — rules, structure, building sections, checks before "done" |
| **AI agent — skills** | [agent/skills/](./agent/skills) — 15 `ipal-*` skills for Antigravity/Claude Code, including `ipal-reference` (full map of the plugin and every export), `ipal-setup` (complete installation), `ipal-site` (a site from brief to report) and the check scripts (copied into the project: `pnpm exec ipal-skills`, AGENT.md §14) |
| **AI agent — skills** | [agent/skills/](./agent/skills) — 15 `iapl-*` skills for Antigravity/Claude Code, including `iapl-reference` (full map of the plugin and every export), `iapl-setup` (complete installation), `iapl-site` (a site from brief to report) and the check scripts (copied into the project: `pnpm exec iapl-skills`, AGENT.md §14) |
| **Developer** | [PROGRAMISTA.md](./dev/PROGRAMISTA.md) — installation, new project, env, deployment, upgrades, releasing the plugin, Gitea; deployment and health check: [deployment.md](./deployment.md) |
| **Person driving an AI agent** | [vibe.md](./dev/vibe.md) — autonomous mode (`/ipal-site`) and ready-made step-by-step prompts |
| **Person driving an AI agent** | [vibe.md](./dev/vibe.md) — autonomous mode (`/iapl-site`) and ready-made step-by-step prompts |
API details — one file per module:
@@ -24,15 +24,16 @@ API details — one file per module:
| GA4, GTM, Meta Pixel, Clarity, LinkedIn, TikTok, `defer` | [analytics.md](./analytics.md) |
| Blocks, RenderBlocks, enhanceProps | [blocks.md](./blocks.md) |
| Block library: ready sections, page templates | [block-library.md](./block-library.md) |
| Cookie consent, banner, settings window (in the bar / modal / large with cookie details) | [consent.md](./consent.md) |
| Cookie consent, banner, settings window (in the bar / modal / large with cookie details), Global Privacy Control | [consent.md](./consent.md) |
| The consent behaviour IAPL and IAWL share (record, categories, GPC, equal prominence, tests) | [consent-behaviour-spec.md](./consent-behaviour-spec.md) |
| Cookie scanner: review list of drafts, "Scan cookies", Open Cookie Database lookup (optional) | [cookie-scanner.md](./cookie-scanner.md) |
| Under construction — locks subpages behind a popup (developer tool) | [construction.md](./construction.md) |
| Routing, archives, redirects, Markdown, search | [content.md](./content.md) |
| Site frontend: `createContentHelpers` (`@/lib/content`), `createPageRoute`, `SiteProviders` | [frontend.md](./frontend.md) |
| New site in one command (`ipal-kit create`, `@intecion/ipal-kit/starter`) | [project-starter.md](./project-starter.md) |
| New site in one command (`iapl create`, `@intecion/ipal-kit/starter`) | [project-starter.md](./project-starter.md) |
| Deployment, production variables, health check | [deployment.md](./deployment.md) |
| Seeds: create-only, dry run, backup, production update guard | [seeding.md](./seeding.md) |
| Email SMTP / Graph | [email.md](./email.md) |
| E-mail: the mail service (default), SMTP, Graph (deprecated) | [email.md](./email.md) |
| Env validation | [env.md](./env.md) |
| Forms, useForm, honeypot | [forms.md](./forms.md) |
| GA4 + Meta Pixel through GTM (form events) | [gtm-meta-pixel.md](./gtm-meta-pixel.md) |
@@ -52,10 +53,10 @@ API details — one file per module:
| Stats in the admin panel (no cookies; visitor history with consent) | [stats.md](./stats.md) |
| Auto-slug | [slug.md](./slug.md) |
| Light / dark theme, switcher | [theme.md](./theme.md) |
| Design tokens (`--ipal-*`, `tokens.css`, `tailwind.css`, `ipal-tokens`, DESIGN.md) | [design-tokens.md](./design-tokens.md) |
| Design tokens (`--ipal-*`, `tokens.css`, `tailwind.css`, `iapl-tokens`, DESIGN.md) | [design-tokens.md](./design-tokens.md) |
| R2, `buildImagesConfig`, `MediaPreconnect`, `YouTubeEmbed` | [storage.md](./storage.md) |
| Turnstile | [turnstile.md](./turnstile.md) |
| ipal-doctor (the site against the team standard, `ipal-doctor.json`) | [doctor.md](./doctor.md) |
| iapl-doctor (the site against the team standard, `iapl-doctor.json`) | [doctor.md](./doctor.md) |
| Admin panel white-label | [white-label.md](./white-label.md) |
Maintenance rule: a module's API changes → update its file in the same commit. New working rules →
+352 -23
View File
@@ -7,12 +7,13 @@ predicates and ready access functions (collection-level and field-level).
## Config (payload.config.ts)
```ts
ipalKit({
iapl({
access: {
authCollection: 'users', // slug of your auth collection (required)
// defaultRole: 'user', // role of new accounts
// firstUserAdmin: true, // the account from "Create first user" → admin
// authAccess: { … }, // access of the injected auth collection (your keys win)
// staffCollections: ['partners'], // more auth collections whose accounts are staff
},
// globalOverrides: { … }, // access / admin / hooks / fields of the plugin's globals
})
@@ -22,8 +23,9 @@ ipalKit({
|---|---|---|
| `access.authCollection` | — (required) | the auth collection that gets the `roles` field |
| `access.defaultRole` | `'user'` | role of a new account when an admin did not set one |
| `access.firstUserAdmin` | `true` | the account from the "Create first user" screen (`…/first-register` on an empty collection) gets `['admin']`, even when the form picked `user`; `false` = it gets what was submitted |
| `access.firstUserAdmin` | `true` | the account from the "Create first user" screen (`…/first-register` on an empty collection) gets `['admin']`, even when the form picked `user`; `false` = it gets what was submitted — then mind the panel role, [Account rules](#account-rules-accounts) |
| `access.authAccess` | see the table below | `access` of the **injected** auth collection, merged over the default (your keys win) |
| `access.staffCollections` | `[]` | more auth collections whose accounts count as **staff**, besides the one the panel logs in with (`admin.user`); see "Who is staff" |
| `globalOverrides` | — | changes to the plugin's globals: an object merges `access` / `admin` key by key (your keys win) and appends `hooks` (yours run after the plugin's), other keys (label, fields, …) replace; a function `(global) => global` takes over the whole global |
The `roles` field (select hasMany, required, `saveToJWT`): readable without limits; only an admin
@@ -40,7 +42,7 @@ only checks that someone is logged in.
| Resource | Read | Write | How to change |
|---|---|---|---|
| auth collection **injected** by the plugin, with roles | admin: everyone; others: only themselves | `create` / `delete` / `unlock`: admin; `update`: admin or self | `access.authAccess`, or your own collection |
| auth collection **injected** by the plugin, with roles | admin: everyone; other accounts **of that collection**: only themselves (`adminOrSelfIn`) | `create` / `delete` / `unlock`: admin; `update`: admin or self | `access.authAccess`, or your own collection |
| Site settings, Cookie banner, Notifications | public | `editor+` | `globalOverrides` |
| Site integrations | admin | admin | `globalOverrides` |
| Forms | public (Emails tab only `editor+`) | `editor+` | `forms.formOverrides.access`, the Emails field in `formOverrides.fields` |
@@ -48,7 +50,7 @@ only checks that someone is logged in.
```ts
import { authenticated } from '@intecion/ipal-kit'
ipalKit({
iapl({
access: { authCollection: 'users', authAccess: { read: authenticated } }, // editors see the account list
globalOverrides: {
notifications: { access: { update: authenticated } }, // any logged-in account edits the texts
@@ -58,37 +60,116 @@ ipalKit({
```
The project's own auth collection keeps its own `access` — the plugin only adds the
`roles` field. Give it at least `update: adminOrSelf`, `delete: adminOnly`, `create: adminOnly`,
`roles` field. Give it at least `update: adminOrSelfIn('users')`, `delete: adminOnly`, `create: adminOnly`,
`unlock: adminOnly`: Payload's default lets any logged-in account change the email and password
of another account and unlock any account. A collection injected **without** `access` (no roles)
keeps Payload's default rules — without roles all accounts are equal.
> **Without `access` there is no `roles` field**, so `isAdmin` always returns `false`. The plugin's own
> staff features therefore check with `userMeetsRole(req, minimum)`: when the user's auth collection has no
> `roles` field, every logged-in account passes (as in Payload's default — without roles all accounts are
> equal). That keeps Site integrations, the settings globals, `/api/ipal/test-email`, stats, consent records
> and form submissions reachable. To narrow them without roles: `globalOverrides` for the globals,
> `forms.formSubmissionOverrides` for submissions, or add `access` to get roles.
## Who is staff
**Staff collections** are the auth collections whose accounts work in the panel:
- the one the admin panel logs in with (`admin.user`; Payload's default is the **first** auth collection in the
list — set `admin: { user: 'users' }` yourself as soon as the project has two);
- the one that carries the plugin's roles (`access.authCollection`);
- the ones named in `access.staffCollections`.
An account of **any other auth collection** — `customers`, `members`, a client zone — is a visitor to the
plugin. **Nothing in the plugin counts a role for it**, also when its own collection has a `roles` field with
the value `admin`: not `userMeetsRole`, not `isAdmin` / `isEditor` / `hasMinimumRole`, not `adminOnly`,
`adminOrEditor`, `requireRole`, `adminOrSelf`, `adminOrSelfIn` or the `…Field` variants, not the `roles` field
itself. The staff-collection check always comes first.
The plugin's own staff features — Site integrations, the settings globals, form submissions, consent records,
stats, the cookie scanner, `/api/ipal/test-email` — check with `userMeetsRole(req, minimum)`, in this order:
1. the account belongs to a staff collection;
2. with 2FA on: the account has set TOTP up and has entered the code in this session
([security.md](./security.md) → "What the second factor covers", "Setup required");
3. it holds at least the role `minimum` — **or** its collection has no `roles` field at all. Then every account
of that staff collection passes, as in Payload's default (without roles all accounts are equal).
What follows:
- **Without `access`** there is no `roles` field, so `isAdmin` always returns `false` and rule 3 keeps the
staff features reachable: every account of the panel collection is admin to the plugin. To narrow that
without roles: `globalOverrides` for the globals, `forms.formSubmissionOverrides` for submissions, or add
`access` to get roles.
- **A second staff collection** (e.g. `partners` who edit content): name it in
`access.staffCollections`. That is the one switch that makes its roles count. Without a `roles` field every
partner passes every staff check, admin ones included; to tell them apart add the field:
`fields: [buildRolesField('editor')]` in that collection. **2FA covers one collection** (`twoFactor.collectionSlug`,
by default the panel's): accounts of a further staff collection are staff with a password alone. iapl says
so in the log at start (`[iapl] 2FA covers "users" only…`); name such a collection only when that is acceptable.
- **Payload's own default** for a collection or global without `access` is "any logged-in account" — an account
of a visitor collection included. In a project with a second auth collection give every collection and global
explicit `access` (`adminOrEditor`, `requireRole(…)`, …).
- **A visitor collection that should reach one thing** (e.g. customers read their own form submissions):
do not make it staff. Write that one rule yourself — `forms.formSubmissionOverrides.access.read`,
`globalOverrides`, `collectionOverrides` of the module — and check `req.user.collection` in it.
- **A user object you build yourself** (Local API with `overrideAccess: false`, a custom auth strategy) must
carry `collection`: `{ ...doc, collection: 'users' }`. Payload's own strategies and `payload.auth()` set it. An
account without it is not staff.
> **Changed in 1.16.4.** Before, a role or the "no roles field" rule counted for an account
> of any auth collection: an account of a second auth collection passed staff checks — every one when its
> collection had no `roles` field, and the matching ones when it had its own `roles` field. A project with one
> auth collection sees no difference. A project that relied on a second collection being staff sets
> `access.staffCollections`.
## Predicates (front end / hooks / access)
```ts
import { isAdmin, isEditor, hasMinimumRole, userMeetsRole } from '@intecion/ipal-kit'
import { isAdmin, isEditor, hasMinimumRole, staffCollectionSlugs, userMeetsRole } from '@intecion/ipal-kit'
isAdmin(user) // admin?
isEditor(user) // editor or admin (hierarchy)
hasMinimumRole(user, 'editor') // at least editor
userMeetsRole(req, 'admin') // admin — or any logged-in user when the auth collection has no roles field
isAdmin(req.user, req.payload) // a staff account with the admin role
isEditor(req.user, req.payload) // editor or admin (hierarchy)
hasMinimumRole(req.user, 'editor', req.payload) // at least editor
userMeetsRole(req, 'admin') // the plugin's staff check: staff collection, second factor, role ("Who is staff")
staffCollectionSlugs(req.payload) // ['users', …]
```
They take a loosely typed user (like `req.user`) and read `roles` defensively.
They take a loosely typed user (like `req.user`) and read `roles` defensively. The last argument tells them
which collections are staff:
| Where you call it | Pass | Without it |
|---|---|---|
| access functions, hooks, endpoints (server, the config is loaded) | `req.payload` | works: the staff collections of the config `iapl` built in this process. With two different configs in one process, only collections that are staff in **both** count — pass `req.payload` to get that config's own answer |
| client components — import from **`@intecion/ipal-kit/client`** | the config from `useConfig()` (it has `admin.user`, the panel's login collection), or `{ staffCollections: ['users', …] }` | **always `false`** — the browser bundle has no config |
| Next middleware / `proxy.ts`, the edge runtime | `{ staffCollections: ['users'] }` | **always `false`** — the config is not loaded there |
```tsx
'use client'
import { isAdmin } from '@intecion/ipal-kit/client' // not '@intecion/ipal-kit'
import { useAuth, useConfig } from '@payloadcms/ui'
export function AdminOnlyHint() {
const { config } = useConfig()
const { user } = useAuth()
// a hint only — the server decides
return isAdmin(user, config) ? <p>…</p> : null
}
```
- **The import in a client component is `/client`** (`hasMinimumRole`, `isAdmin`, `isEditor`, the type `Role`). The main
entry reaches `server-only` modules: with `next build --webpack` it fails with `'server-only' cannot be imported from
a Client Component module` (Turbopack builds it, but the import does not belong there either).
In 1.16.4–1.16.6 `/client` does not have them — upgrade.
- **On the server** (config, hooks, access functions, endpoints, server components, `proxy.ts`) import from
`@intecion/ipal-kit`: `/client` is a `'use client'` entry, a server component that calls a function from it fails.
- `useConfig()` carries `admin.user` only (Payload strips `config.custom` from the client config). Accounts of
`access.staffCollections` need the list: `isAdmin(user, { staffCollections: ['users', 'partners'] })`.
They fail closed: where the staff collections are not known, nobody is staff, and an account without
`collection` is nobody. `isAdmin` and the others do **not** check the second factor; `userMeetsRole` and every
`access` function in the config do.
## Ready access functions
### Collection-level (return boolean | Where)
```ts
import { adminOnly, adminOrEditor, adminOrSelf, requireRole, authenticated } from '@intecion/ipal-kit'
import { adminOnly, adminOrEditor, adminOrSelf, adminOrSelfIn, requireRole, authenticated } from '@intecion/ipal-kit'
export const Articles = {
slug: 'articles',
@@ -101,8 +182,12 @@ export const Articles = {
// ...
}
// Users: everyone sees themselves, an admin sees everyone
access: { read: adminOrSelf }
// Users: everyone sees themselves, an admin sees everyone.
// adminOrSelfIn(slug): "self" = an account of THAT collection. Use it for an auth collection whenever
// the project has more than one: adminOrSelf only compares ids, and with numeric ids (Postgres, SQLite)
// customer no. 5 would match staff account no. 5.
access: { read: adminOrSelfIn('users') }
access: { read: adminOrSelf } // fine with a single auth collection
// any minimum threshold
access: { update: requireRole('editor') }
@@ -137,16 +222,260 @@ injectRoles(config, { authCollection: 'members' }) // add the field to a
applyGlobalOverrides(globals, { notifications: { … } }) // the same logic as the globalOverrides option
```
Types: `AccessOption`, `Role`, `GlobalOverride`, `GlobalOverrides`, `IpalGlobalSlug`.
Types: `AccessOption`, `Role`, `GlobalOverride`, `GlobalOverrides`, `IaplGlobalSlug`.
## Account rules (`accounts`)
Rules for the accounts of the staff collection. All on by default; each has its own switch, and
`iapl({ accounts: false })` turns them all off.
```ts
iapl({
access: { authCollection: 'users' },
// accounts: { panelRole: 'user' }, // every account may open the panel (as before)
// accounts: { adminOnlyCreate: false }, // Payload's default `create` on your own staff collection
// accounts: { adminOnlyWrite: false }, // Payload's default `update` / `delete` / `unlock` there, roles field left alone
// accounts: { staffOnlyRead: false }, // Payload's default `read` there
// accounts: { firstUserRoute: 'all' }, // Payload's first-user route for every empty auth collection
// accounts: { firstUserRoute: ['users', 'partners'] },
// accounts: { password: { minLength: 16 } }, // or password: false
// accounts: false, // none of the rules
})
```
### Who may open the panel (`accounts.panelRole`, default `'editor'`)
The lowest role, `user`, is what a new account gets (`access.defaultRole`) and has no business in the panel. The
panel opens for `editor` and above: it is Payload's `access.admin` on the collection that carries the roles. An
account that holds only `user` (or no role) logs in and sees Payload's "Unauthorized" screen. **The API is not
touched** — such an account still gets over REST / GraphQL what its role allows. The rule looks at the role, not
at the second factor, so the 2FA screens stay reachable.
- **What an existing site sees on the first start:** the log line `[iapl] N account(s) of "users" are below the
role "editor" and cannot open the admin panel` — give those people `editor`, or set `panelRole: 'user'`. When
**no** account has the role it is an error (`NOBODY can open the admin panel`): give one account the role with
a script (`payload.update`, Local API) or set `accounts: { panelRole: false }` and redeploy.
- `'admin'` = admins only; `'user'` or `false` = everyone, as before. Needs `access` (the roles). Your own
`access.admin` on the collection, or `access.authAccess.admin`, wins. Building blocks: `panelAccess(role)`,
`applyPanelRole`, `resolvePanelRole`, `countBelowPanelRole`, `DEFAULT_PANEL_ROLE`.
- **Check:** log in to `/admin` as an account with the role `user` → "Unauthorized"; `GET /api/access` for it →
`canAccessAdmin: false`; `GET /api/users/me` still answers.
### Nobody creates an account for themselves, or takes one over (`accounts.adminOnlyCreate`, `accounts.adminOnlyWrite`, `accounts.staffOnlyRead`, `accounts.firstUserRoute`)
By default only the first account of a site can be registered by a visitor, and it becomes admin
(`access.firstUserAdmin`); every other account is made by an admin, and an account is changed by an admin or by
its owner.
Payload's default for a collection without access rules is "any logged-in user" for `create`, `read`, `update`,
`delete` and `unlock` — an account of **any** auth collection. On a project's own staff collection a visitor
account (`customers`) could therefore create a staff account, `PATCH` a staff account's password and roles,
list the staff accounts, and lift the lock after failed logins.
| | Before | Now (default) |
|---|---|---|
| Anonymous `POST /api/users`, GraphQL `createUser` | refused | refused |
| The first account: `POST /api/users/first-register` on an empty collection | 200, role `admin` | the same |
| A signed-in editor or plain user creates an account in the plugin's injected collection | refused | refused |
| …in **the project's own** staff collection that has no `create` rule | **allowed** (Payload's default) | refused — an admin, fully signed in |
| A visitor account (`customers`) changes or deletes an account of the project's own staff collection that has no `update` / `delete` rule | **allowed** (Payload's default) | refused |
| A visitor account lists the accounts of such a collection, or unlocks one | **allowed** (Payload's default) | refused |
| An account of such a collection changes its **own** `roles` (the field has no access of its own) | **allowed** | refused — with the plugin's roles only an admin changes roles |
| `POST /api/<slug>/first-register` on another empty auth collection (`members`) | **200** | 403 |
| …on an empty **second staff collection** (`access.staffCollections`) | **200, and that account was staff** | 403 — an admin of the panel's collection creates its first account |
| A collection that allows sign-up (`customers` with `create: () => true`) | allowed | allowed, its first-user route too |
**Which rule a staff collection gets** (the panel's login collection, `access.authCollection`,
`access.staffCollections`) — only for an operation it has **no** rule for; a rule you wrote always stays:
| The collection | `create`, `delete`, `unlock` | `update` | the `roles` field (when it has no `access.update`) | `read`, `readVersions` |
|---|---|---|---|---|
| carries **the plugin's roles**: it is `access.authCollection`, or has a `roles` select **with `hasMany`** whose values are all `user` / `editor` / `admin` (`hasPluginRoles`), **or one whose accounts can hold `editor` or `admin`**, whatever else its `roles` field offers (`canHoldStaffRole`, below) | an admin (`staffCreateAccess`) | an admin, or the account itself (`staffUpdateAccess(slug)`) | only an admin changes it (`rolesByAdminOnly`) | a staff account (`staffReadAccess`) |
| has **roles of its own that hold neither `editor` nor `admin`** (`superadmin`, `writer`, …) or no `roles` field — the plugin cannot tell who its admins are | an account of that same collection, or a plugin admin of another staff collection (`sameStaffCollectionAccess(slug)`) | the same | an account never changes its **own** (`rolesNotOwn(slug)`) | a staff account |
Always "fully signed in": a session that still owes its second factor passes none of them.
**A `roles` field that can hold `editor` or `admin`.** The plugin's checks go by the **value on the account**
(`isAdmin`, `isEditor`): an account of a staff collection whose `roles` — an **array** — holds `admin` is a plugin
admin, one that holds `editor` edits the site's settings, whatever else the field offers. So wherever an account
of the collection **can** hold one of the two, the collection gets the admin rules (`canHoldStaffRole`):
| The collection's `roles` field | Rules |
|---|---|
| a select **with `hasMany`** and `editor` or `admin` among its values — `user, editor, admin, boss`; `viewer, editor` | the admin rules (first row above) |
| a field that holds a list whose values cannot be listed — text with `hasMany`, json, a relationship with `hasMany` (to documents whose ids are text, the ids are the roles), a select without options, a type the plugin does not know: anything can be written there | the admin rules |
| a select with `hasMany` whose values are all your own and hold neither — `lead, member` | "an account of that same collection" (second row) |
| a field that holds **one** value — a select, text or relationship without `hasMany`, a radio, a number (`rolesAreAList` is false) | second row. The plugin counts roles only from an array: an account whose `roles` is the single value `admin` is **not** a plugin admin, so there is nothing of the plugin's to protect and the collection's accounts keep managing each other. If your own code gives rights by that value, write the collection's own rules |
| no `roles` field | second row; every account of it is an admin to the plugin (below) |
Otherwise any account of such a collection could hand the value out: create an `admin` and be in Site
integrations and every other staff collection, or create an `editor` and change the site's settings. (Until this
change these collections got the second row, and an account with the lowest role could do exactly that.)
**What it means for your accounts:** a role the plugin does not know (`boss`, `viewer`) carries no rights of the
plugin's — such an account no longer creates, deletes or unlocks accounts there, changes another account or
anybody's roles. Give it what it needs with rules of your own (`access.create` / `update` / `delete`, field
access on `roles`), which win as always. In a collection where nobody can be an `admin` (`viewer, editor`) the
accounts are managed by an admin of another staff collection — the panel's.
**A rule of your own replaces the protection for that operation.** The plugin fills only what you left open: with
your own `create: ({ req }) => Boolean(req.user)` any account still creates an `admin` there; with your own
`access.update: () => true` on the `roles` field an account still raises itself. And the plugin sees the field's
declared values, not your code: a value that a hook of yours puts into `roles` (an `afterRead` that returns
`['admin']` from a checkbox, a virtual field) is not seen — such a collection is judged by its declared field.
**If no staff account holds `admin` at all**, nobody can create, delete or unlock accounts in such a collection.
The start log says so: `[iapl] No staff account holds the role "admin", so NOBODY can create, delete or unlock
accounts in "…"`. Way out: give one account the role with a script (`payload.update`, Local API), or write the
collection's own rules. The check asks each staff collection in the way its field allows (a count for a select,
reading the accounts for text / json / relationship fields, up to 1000 of them); where it cannot check a
collection it says `[iapl] Could not check whether an account of "…" holds the role "admin"` instead and claims
nothing.
**Roles of your own — what the plugin does and does not hold.** It cannot rank `superadmin` against `writer`,
so inside such a collection it enforces one thing only: an account does not change its own roles. Everything
else that was allowed inside the collection stays allowed — **every account of it may still create an account
with any role, and change or delete another account**. That is a hole only you can close: write the
collection's `create` / `update` / `delete` rules and the field access of its `roles` field from your roles.
`iapl-doctor --url` names such a collection (`staff-own-roles`, warning). What the plugin closes for you is the
door for accounts of **other** collections.
**A staff collection without a `roles` field:** every account of it is an admin to the plugin (unchanged), so
it may also manage the accounts of the other staff collections. Give it the plugin's roles
(`buildRolesField`), or write its rules.
**A staff collection that a plugin listed after iapl adds** gets the same rules, the password rule and the
first-user endpoint when the config goes live — at start and on every dev reload. The log says exactly what was
put: `[iapl] "late-staff" was added after iapl: put on it — access rules for create, update, delete, unlock,
read, readVersions, roles; the password rule; the first-user endpoint.` One difference from a collection of your
own config: by then Payload has sanitized the collection and filled every missing rule with its default, and
that default cannot be told from a rule somebody wrote (a production build renames every function). So the
plugin does not guess: **its rule is put in front of whatever rule is there, and both must allow**
(`bothAllow`). With Payload's default behind it the result is the plugin's rule; a rule of the collection's own
is kept and can only narrow it. To keep a late collection's rules exactly as they are — an open `create`, a
wider `read` — say so on the collection: `custom: { ipal: { accountRules: false } }` (the password rule and the
first-user endpoint still apply), or list that plugin before iapl.
**A collection of your own config that becomes staff later** — it is in the config, you did not name it as staff,
and a plugin listed after iapl sets `admin.user` to it — is handled at the same moment, with one difference:
the plugin saw it at config time and wrote down which operations had a rule of yours (the marker's `own`). **Those
rules stay exactly as written; an operation that had no rule gets the plugin's** — the same result as for a
collection named in `access.staffCollections`, and its `roles` field is guarded where the plugin's `update` rule
is the one in force. The log: `[iapl] "people" became a staff collection after iapl ran: put on it — access
rules for update, delete, unlock, read, readVersions, roles; the password rule. Its own rules for create are kept
as written.` Without rules of its own such a collection ran on Payload's defaults before (any signed-in account,
a customer included, created and changed panel accounts). Simpler and clearer: name the collection in
`access.staffCollections`, or list that plugin before iapl. Verify: sign in as an account of a non-staff
collection and `POST /api/<slug>` — 403 unless your own `create` rule lets it through.
**A copy of a staff collection** — a later plugin that spreads one into a new slug (`{ ...staff, slug: 'copy' }`),
or a new collection that reuses a staff collection's `access` object — brings along rules the plugin wrote for
the ORIGINAL: "an account of `staff`", "the account itself" = one of the original's. The plugin sees them by a
mark it puts on its own functions (`staffRuleOf(rule)` → `{ slug, self }`; the mark counts only on the very
function it was made for, so a wrapper of yours around a plugin rule is your rule). What it does is one thing,
in every case:
> **The plugin's rule for THIS collection goes in front of the rule that is there, and both must allow.**
> Nothing is replaced and nothing is rewritten.
| The copy | Where the plugin's rule goes in front |
|---|---|
| named in `access.staffCollections` | of every rule — as on any late staff collection |
| not named as staff, or with `custom: { ipal: { accountRules: false } }` | only of the rules the plugin wrote for the original; your own rules there stay as they are |
| its `roles` field | guarded on every copy (the plugin's roles: only an admin changes them; others: never one's own) unless the field has an `access.update` of its own — then the guard goes in front only of a rule the plugin wrote for the original |
So a copy is never opened wider than its rules were before, and never wider than the plugin's rule — whatever
role values it has, whichever operation it uses a copied rule for, however it wraps it. The original's account
with the same id is not "the account itself" in the copy.
**The cost, and the one line that pays it:** a copied rule that says "an admin, or the account itself" still
means the ORIGINAL's accounts, so in the copy only an admin passes it — the copy's own accounts cannot edit
themselves until the copy says who may:
```ts
import { adminOrSelfIn } from '@intecion/ipal-kit'
// in the plugin that makes the copy:
{ ...staff, slug: 'copy', access: { ...staff.access, update: adminOrSelfIn('copy') } }
```
A rule you write there is not marked, so on a staff copy it is combined with the plugin's rule for `copy`
("an admin, or the account itself" of the copy) and works. The password rule is on a copy once
(`isPasswordRuleHook`). The marker `custom.ipalAccounts` (`{ slug, staff, own? }`, type `AccountsMarker`) records which
collection the plugin has handled, whether as staff, and — for a collection that was not staff at config time —
which operations had a rule of the project's then (`own`): a copy carries the original's marker and is handled under
its own slug; in `next dev` a collection named as staff in an edit is handled on the reload. A marker for the
collection's own slug means "handled" — only your own config can write one, like `accountRules: false`.
**A slug in `access.staffCollections` or `access.authCollection` that is not an auth collection of the config:**
Payload does not start. The log names the slug and the auth collections it knows. The process stays up, but
every Payload call fails — `/api/health` answers 503, `/api/*` and the panel 500; a page that needs no Payload
call may still answer. With a health check ([deployment.md](./deployment.md) §4.4) Coolify keeps the old
container serving, so a wrong slug never goes live (`unknownStaffCollections`).
- `adminOnlyCreate: false` = Payload's default `create`; `adminOnlyWrite: false` = Payload's default `update`,
`delete` and `unlock`, and the `roles` field is left alone; `staffOnlyRead: false` = Payload's default `read`.
The rules are put on the collections **before** the 2FA package wraps them, so they hold with 2FA on and off.
- `read` = "a fully signed-in account of a staff collection": staff sees staff (the panel needs it for
relationship fields and the account list), a visitor account sees nothing. The injected collection keeps its
stricter "admin or self". **A front end that shows staff accounts to logged-in visitors** needs its own `read`
rule on that collection (a rule you wrote wins), or `staffOnlyRead: false`.
- `firstUserRoute`: `'panel'` (default) = the collection the panel logs in with; a list of slugs = those;
`'all'` = Payload's behaviour. A collection whose own `create` rule lets an anonymous request through keeps
its route. The plugin puts its own `POST /first-register` endpoint in front of Payload's on every auth
collection (`buildFirstUserEndpoint`): it refuses, or hands the request to Payload's handler. It does not read
the request path, so the spelling of the URL (`/First-Register`) changes nothing. A collection with
`endpoints: false` is left alone.
- **A fresh site:** whoever opens the panel first becomes the admin — create the first account right after the
first deploy.
- **`access.firstUserAdmin: false`** gives the first account the default role. If that role is below the panel
role, nobody could open the panel on a fresh site: with the default panel role the plugin then does **not**
apply it and says so at start; with `accounts.panelRole` set by you the config is refused at start. Set
`access.defaultRole: 'editor'`, or `accounts: { panelRole: false }`.
- **What an existing site sees:** nothing, unless its own staff collection relied on Payload's defaults
(non-admins creating accounts in a collection with the plugin's roles; accounts of another collection writing
to it) — then write the rule you want, or set `adminOnlyCreate: false` / `adminOnlyWrite: false`.
- `iapl-doctor --url`: `open-signup` (info) lists auth collections with open sign-up; `staff-own-roles` (warning)
a staff collection with role values of its own on the default rules; `staff-accounts-open`
(error) names a staff collection an account of another collection may create in, read (a warning), update, delete from or unlock
(the rules are off, or your own rule is wider).
- Building blocks: `staffCreateAccess`, `staffUpdateAccess`, `staffReadAccess`, `sameStaffCollectionAccess`,
`rolesByAdminOnly`, `rolesNotOwn`, `bothAllow`, `hasPluginRoles`, `applyStaffAccountAccess`, `adoptLateAuthCollections`,
`unknownStaffCollections`, `buildFirstUserEndpoint`, `applyFirstUserRoute`, `openSignUpCollections`,
`staffCollectionsOpenToOthers`, `staffCollectionsOnOwnRoles`.
- **Check:** `curl -X POST <site>/api/members/first-register -H 'content-type: application/json' -d
'{"email":"x@example.com","password":"a-long-password-1"}'` → `403`, also as `/First-Register`; the same for
`/api/users` → `403`. Logged in as a visitor account: `PATCH /api/users/<id>` and `GET /api/users` → `403`. As a
non-admin of a staff collection: `PATCH` your own account with `roles` → the roles do not change.
### Passwords (`accounts.password`, default 12 characters)
When a password is **set** on a staff collection — a new account, the first-user screen, a change, a reset by
e-mail; in the panel, over the API and through the Local API — it must have at least 12 characters and must not
be the account's own e-mail address (Payload's own rule is 3 characters). **Existing passwords are never
checked:** an account with a shorter one keeps logging in, and meets the rule the next time its password is
changed. The message is in the panel's language, English or Polish ("The password must have at least 12
characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.<lang>.ipal`).
- `password: { minLength: 16 }`; `password: false` = Payload's rule. Visitor collections are not touched.
- Checked against the account's address also where the request carries none: a change by id, a reset by e-mail
(the account is found by its token), a bulk update (every account it matches). A password that is not text
(a number, a list) is refused with the same message.
- No breached-password lookup (it would send part of a hash of every new password to an outside service);
build one on `checkPassword` / `buildPasswordRuleHook` if a project needs it.
- A script or seed that creates a staff account with a shorter password now fails with a validation error.
- Building blocks: `checkPassword`, `buildPasswordRuleHook`, `applyPasswordRule`, `resolvePasswordRule`,
`DEFAULT_PASSWORD_MIN_LENGTH`.
- **Check:** create an account with an 11-character password → "The password must have at least 12 characters.".
## Turn off, override, extend
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
`staffOnlyRead`, `firstUserRoute`, `password` (above).
- **Turn off:** leave out `access` — no `roles` field, the auth collection keeps Payload's rules
(or yours). `access.firstUserAdmin: false` stops giving admin to the first account.
- **Override:** `access.authAccess` (injected collection), your own auth collection (wins whole),
- **Override:** `access.staffCollections` (who is staff), `access.authAccess` (injected collection), your own auth collection (wins whole),
`globalOverrides` (globals), `forms.formOverrides` / `formSubmissionOverrides` (forms),
`defaultRole`. The role hierarchy (`ROLE_HIERARCHY`) is fixed.
- **Extend:** `requireRole` / `requireRoleField`, predicates, `buildRolesField`, `injectRoles`,
- **Extend:** `requireRole` / `requireRoleField`, `adminOrSelfIn`, predicates (`userMeetsRole`, `staffCollectionSlugs`), `buildRolesField`, `injectRoles`,
`applyGlobalOverrides` in your own collections and globals.
- **Check:** log in with a `user` account → `PATCH /api/globals/site-settings` = 403,
`DELETE /api/users/<admin id>` = 403; the account from "Create first user" has the `admin` role.
+4 -1
View File
@@ -172,6 +172,9 @@ The provider re-applies and syncs on the client anyway. This only removes the fl
### State and attributes (`A11yState`)
Cookie `a11y-prefs` (`A11Y_COOKIE`, JSON, `path=/`, `max-age` 1 year, `samesite=lax`).
It is written only when the visitor changes a setting, with no consent check: a preference the visitor
chose, no tracking (the same reasoning as the theme choice, theme.md). List it as **necessary** in the
cookie list — the scanner does not declare it, add it with `declarations` (cookie-scanner.md).
Widget texts: `texts` prop wins, otherwise `A11Y_DEFAULT_TEXTS[locale]` (`en`, `pl`; prop `locale`,
incl. `texts.on` / `texts.off` for the switches).
The helpers `A11Y_COOKIE`, `A11Y_DEFAULT`, `parseA11y`, `serializeA11y`, `a11yAttributes`
@@ -222,7 +225,7 @@ sell the client "we have a widget = we are WCAG compliant". See [dev/PROGRAMISTA
## Turn off, override, extend
- **Turn off:** the module is opt-in — without `AccessibilityProvider` / `AccessibilityWidget` nothing happens
(no option in `ipalKit`, no fields in the panel).
(no option in `iapl`, no fields in the panel).
- **Override:** the widget's `classNames` and `texts`; the whole look of the effects is project CSS.
- **Extend:** your own UI on `useAccessibility()` (`state`, `set`, `reset`); SSR helpers
`parseA11y` / `a11yAttributes` / `serializeA11y` / `A11Y_DEFAULT`. The option set (`A11yState`) currently
+410 -174
View File
File diff suppressed because it is too large Load Diff
+100 -52
View File
@@ -2,12 +2,12 @@
<!-- Generated by scripts/reference-index.mjs from reference/ — do not edit by hand (pnpm reference:index). -->
The reference site is one complete client site on ipal-kit 1.16.3 ("Example Studio", made up) that uses
The reference site is one complete client site on IAPL 1.17.0 ("Example Studio", made up) that uses
every convention in AGENT.md. It lives in the plugin repo (`reference/`, not in the npm package). Copy the
PATTERN of the file you need; change only the project's content. Files up to
40 lines are below in full; open the rest in the repo at the tag of your plugin version:
`https://git.intecion.net/IntecionSoftware/ipal-kit/src/tag/v<version>/reference/<path>`.
If this index and AGENT.md disagree, report it with ipal-plugin-gap — it is a plugin bug.
If this index and AGENT.md disagree, report it with iapl-plugin-gap — it is a plugin bug.
## Project files
@@ -24,12 +24,12 @@ Rules: AGENT.md §13, §0a.
| `DESIGN.md` | the human source of the look, matching src/design/tokens.ts |
| `README.md` | how to run the reference site and what is where |
| `docs/DEPLOY.md` | the Coolify runbook: local check, app settings, MongoDB resource, env, targeted seeds, DNS, rollback |
| `ipal-doctor.json` | the production domain and launch state for ipal-doctor (below) |
| `iapl-doctor.json` | the production domain and launch state for iapl-doctor (below) |
| `next.config.ts` | security headers, enforced CSP, admin CSP, upload headers, images, no X-Powered-By |
| `package.json` | scripts (build, start, seed, tokens, generate), pinned Payload versions and overrides |
| `playwright.config.ts` | smoke tests against the built, seeded site (below) |
| `postcss.config.mjs` | Tailwind 4 through PostCSS (below) |
| `starter.manifest.json` | what `ipal-kit create` keeps, drops and turns into placeholders |
| `starter.manifest.json` | what `iapl create` keeps, drops and turns into placeholders |
| `tsconfig.json` | paths @/ and @payload-config, .agents excluded (below) |
### `.gitignore`
@@ -58,7 +58,7 @@ legacy-peer-deps=true
22
```
### `ipal-doctor.json`
### `iapl-doctor.json`
```json
{
@@ -93,7 +93,10 @@ try {
}
/**
* Smoke tests against a built, seeded site: pnpm build && pnpm seed && pnpm payload run e2e/create-test-admin.ts.
* Smoke tests against a built, seeded site: pnpm seed && pnpm build.
* The 2FA verify limit (5 attempts per account in 10 minutes) is stored in the database; the global setup resets the
* test admins and clears their counts before every run (e2e/global-setup.ts; E2E_SKIP_ADMIN_SETUP=1 for a run that
* needs an EMPTY database, the fresh-site spec).
* E2E_BASE_URL picks the port (default 3100). Playwright starts its own server there and fails when the port is
* taken, so another project's dev server is never tested by mistake; E2E_REUSE_SERVER=1 uses a server you started.
*/
@@ -101,6 +104,8 @@ const baseURL = process.env.E2E_BASE_URL ?? 'http://localhost:3100'
export default defineConfig({
forbidOnly: !!process.env.CI,
// makes every run independent of the one before: test admins reset, stored 2FA attempt counts cleared
globalSetup: './e2e/global-setup.ts',
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
reporter: process.env.CI ? 'line' : 'list',
retries: process.env.CI ? 1 : 0,
@@ -108,7 +113,9 @@ export default defineConfig({
use: { baseURL, trace: 'retain-on-failure' },
webServer: {
command: 'pnpm start',
env: { PORT: new URL(baseURL).port || '3000' },
// E2E_MAIL_RELAY_URL: the mail service's stand-in that e2e/mail-relay.spec.ts starts (nothing listens there otherwise,
// and the other specs send through the SMTP sink, so the site never calls it)
env: { E2E_MAIL_RELAY_URL: `http://127.0.0.1:${process.env.E2E_RELAY_PORT ?? 2527}/mail`, PORT: new URL(baseURL).port || '3000' },
reuseExistingServer: process.env.E2E_REUSE_SERVER === '1',
url: `${baseURL}/api/health`,
},
@@ -153,7 +160,7 @@ export default { plugins: { '@tailwindcss/postcss': {} } }
## Configuration
Rules: AGENT.md §3, ipal-setup stage 3.
Rules: AGENT.md §3, iapl-setup stage 3.
| File | What it shows |
|---|---|
@@ -161,7 +168,7 @@ Rules: AGENT.md §3, ipal-setup stage 3.
| `src/db.ts` | the database adapter, alone in one file (MongoDB) (below) |
| `src/i18n.config.ts` | the ONLY source of languages (below) |
| `src/instrumentation.ts` | env validation at startup (assertEnv, database name rule) (below) |
| `src/payload.config.ts` | ipalKit with every module the site uses, R2, mail, 2FA, white-label |
| `src/payload.config.ts` | iapl with every module the site uses, R2, mail, 2FA, white-label |
| `src/proxy.ts` | the locale proxy with Markdown negotiation (not middleware.ts) (below) |
### `src/content.config.ts`
@@ -215,21 +222,21 @@ export type Locale = (typeof i18nConfig.locales)[number]['code']
### `src/instrumentation.ts`
```ts
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'
import { assertEnv, iaplEnvRules } from '@intecion/ipal-kit/env'
export function register() {
if (process.env.NEXT_RUNTIME !== 'nodejs') {return}
// storage: R2 is required in production. ALLOW_LOCAL_MEDIA=1 lets a production build run on local disk for
// local checks and CI only — never set it in Coolify.
// @starter:if crawl
// cookieCrawl: IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN in production (cookieScanner.crawl, the shared service).
// cookieCrawl: IAPL_COOKIE_SCAN_URL / IAPL_COOKIE_SCAN_TOKEN in production (cookieScanner.crawl, the shared service).
// @starter:endif
// databaseName: DATABASE_URI must name example-studiopl_dev / example-studiopl_prod (databaseNamesFor).
// R2_PUBLIC_URL optional: media are served through the app by default (storage.md, env.md).
assertEnv(
ipalEnvRules({
iaplEnvRules({
// @starter:if crawl
cookieCrawl: true, // IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN in production — the shared cookie-crawler service
cookieCrawl: true, // IAPL_COOKIE_SCAN_URL / IAPL_COOKIE_SCAN_TOKEN in production — the shared cookie-crawler service
// @starter:endif
databaseName: { domain: 'example-studio.pl' },
// @starter:if graph
@@ -263,7 +270,7 @@ export const config = { matcher: ['/((?!api|admin|_next|.*\\..*).*)'] }
## Collections and globals
Rules: AGENT.md §5, ipal-nav, ipal-collection.
Rules: AGENT.md §5, iapl-nav, iapl-collection.
| File | What it shows |
|---|---|
@@ -290,7 +297,7 @@ import { entryFields } from './entryFields'
const revalidate = buildRevalidateHook({ config: i18nConfig, revalidatePath })
/** The project's own archive collection (skill ipal-collection) — the library has no case-study type. */
/** The project's own archive collection (skill iapl-collection) — the library has no case-study type. */
export const CaseStudies: CollectionConfig = {
slug: 'caseStudies',
admin: { defaultColumns: ['title', 'publishedAt', 'updatedAt'], useAsTitle: 'title' },
@@ -477,7 +484,7 @@ import type { GlobalConfig } from 'payload'
import { buildGlobalRevalidateHook, buildLinkField, rowLabel } from '@intecion/ipal-kit'
import { revalidatePath } from 'next/cache'
/** ipal-nav: link columns and a note. Legal links come from System pages (getSystemLinks), not from here. */
/** iapl-nav: link columns and a note. Legal links come from System pages (getSystemLinks), not from here. */
export const Footer: GlobalConfig = {
slug: 'footer',
access: { read: () => true },
@@ -513,7 +520,7 @@ import type { GlobalConfig } from 'payload'
import { buildGlobalRevalidateHook, buildLinkField, buildLinksField, rowLabel } from '@intecion/ipal-kit'
import { revalidatePath } from 'next/cache'
/** ipal-nav: menu with one submenu level, a CTA button, the mobile menu label. Logo comes from Site settings. */
/** iapl-nav: menu with one submenu level, a CTA button, the mobile menu label. Logo comes from Site settings. */
export const Header: GlobalConfig = {
slug: 'header',
access: { read: () => true },
@@ -636,7 +643,7 @@ Rules: docs/design-tokens.md.
| File | What it shows |
|---|---|
| `src/app/(frontend)/[locale]/design/page.tsx` | the design-token styleguide page (noindex) (below) |
| `src/components/design/TokenPanel.tsx` | one styleguide panel built from IPAL_TOKENS |
| `src/components/design/TokenPanel.tsx` | one styleguide panel built from IAPL_TOKENS |
| `src/design/tokens.css` | GENERATED by `pnpm tokens` from tokens.ts — never edited by hand (below) |
| `src/design/tokens.ts` | the brand: the ONLY file edited to rebrand the site (below) |
@@ -658,7 +665,7 @@ export default function DesignPage() {
return (
<Container className="grid gap-10 py-section">
<header className="grid gap-stack">
<p className="text-sm uppercase tracking-heading text-fg-muted">ipal-kit</p>
<p className="text-sm uppercase tracking-heading text-fg-muted">IAPL</p>
<h1 className="font-heading text-h1 leading-heading text-fg-strong">Design tokens</h1>
<p className="max-w-measure text-lead text-fg-muted">
src/design/tokens.ts → pnpm tokens → src/design/tokens.css. The panels set data-theme=&quot;light&quot; and data-theme=&quot;dark&quot;
@@ -681,8 +688,8 @@ export const generateStaticParams = () => i18nConfig.locales.map(({ code }) => (
```css
/*
* GENERATED by `ipal-tokens` from src/design/tokens.ts — do not edit; change src/design/tokens.ts and run
* `pnpm exec ipal-tokens`. Import it in styles.css after @intecion/ipal-kit/tokens.css (and tailwind.css).
* GENERATED by `iapl-tokens` from src/design/tokens.ts — do not edit; change src/design/tokens.ts and run
* `pnpm exec iapl-tokens`. Import it in styles.css after @intecion/ipal-kit/tokens.css (and tailwind.css).
*/
:root {
@@ -770,7 +777,7 @@ import type { Locale } from '@/i18n.config'
import { getCachedPayload } from './content'
/** Cached getters for the project's own globals — the layout passes them down as props (ipal-nav). */
/** Cached getters for the project's own globals — the layout passes them down as props (iapl-nav). */
export const getHeader = cache(async (locale: string) => (await getCachedPayload()).findGlobal({ slug: 'header', depth: 1, locale: locale as Locale }))
export const getFooter = cache(async (locale: string) => (await getCachedPayload()).findGlobal({ slug: 'footer', depth: 1, locale: locale as Locale }))
export const getCompany = cache(async (locale: string) => (await getCachedPayload()).findGlobal({ slug: 'company', locale: locale as Locale }))
@@ -778,7 +785,7 @@ export const getCompany = cache(async (locale: string) => (await getCachedPayloa
## Layout and components
Rules: AGENT.md §6.8, ipal-nav, ipal-form.
Rules: AGENT.md §6.8, iapl-nav, iapl-form.
| File | What it shows |
|---|---|
@@ -840,7 +847,7 @@ export const generateStaticParams = route.generateStaticParams
```ts
'use server'
// ONE server action for every builder form: honeypot → client IP (IPAL_IP_HEADER) → submitForm
// ONE server action for every builder form: honeypot → client IP (IAPL_IP_HEADER) → submitForm
// (rate limit, Turnstile, validation, consent, save) → the message from Notifications.
import { createSubmitAction } from '@intecion/ipal-kit/server'
import { headers } from 'next/headers'
@@ -898,7 +905,7 @@ import { buttonClass } from '@intecion/ipal-kit/blocks/rsc'
const control =
'w-full rounded-control border border-border bg-surface px-3 py-2 text-fg placeholder:text-fg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus'
/** The ONLY place panel forms are styled (ipal-form). Token utilities only — no hex, no dark:. */
/** The ONLY place panel forms are styled (iapl-form). Token utilities only — no hex, no dark:. */
export const formClasses: BuilderFormClassNames = {
actions: 'flex flex-wrap gap-3',
back: buttonClass('secondary'),
@@ -966,7 +973,7 @@ import type { NavItem } from '@intecion/ipal-kit'
import Link from 'next/link'
import { useEffect, useState } from 'react'
/** Mobile menu: open state only, data via props (ipal-nav). Esc closes it. */
/** Mobile menu: open state only, data via props (iapl-nav). Esc closes it. */
export function MobileNav({ items, menuLabel }: { items: NavItem[]; menuLabel: string }) {
const [open, setOpen] = useState(false)
useEffect(() => {
@@ -1004,7 +1011,7 @@ export function MobileNav({ items, menuLabel }: { items: NavItem[]; menuLabel: s
## SEO, GEO and ops routes
Rules: AGENT.md §0b, ipal-setup stages 7–8.
Rules: AGENT.md §0b, iapl-setup stages 7–8.
| File | What it shows |
|---|---|
@@ -1157,50 +1164,88 @@ Rules: AGENT.md §8a.
| File | What it shows |
|---|---|
| `e2e/create-test-admin.ts` | a test admin with a known TOTP secret, and e-mail sending pointed at the tests' mail sink (local / CI database only) (below) |
| `e2e/create-test-admin.ts` | two test admins with a known TOTP secret (the specs share out the five 2FA verify attempts per account), their stored verify counts cleared, and e-mail sending pointed at the tests' mail sink (local / CI database only) |
| `e2e/global-setup.ts` | Playwright global setup: resets the test admins and clears their stored 2FA attempt counts before every run, so specs do not depend on run order (below) |
| `e2e/late-staff-fixture.ts` | test fixture, on only with E2E_LATE_STAFF=1: one plugin before iapl (staff collections of the config: roles with one more value, the plugin's roles, roles of the project's own) and one after it (a staff collection without rules, one whose roles field is text, copies of staff collections under new slugs — plain, with rules of their own, one rule used for another operation, other role values, the opt-out, not staff — and a visitor collection with open sign-up) |
| `e2e/late-staff.spec.ts` | the account rules on a BUILT site (run by `pnpm e2e:built` after a webpack and a Turbopack build): a staff collection a later plugin adds, staff collections whose accounts can hold `admin`, and copies of staff collections — a visitor account gets nothing, nobody raises its own role or makes an admin, a copy is never wider than the plugin's rule |
| `e2e/mail-relay-fixture.ts` | test fixture, on only with E2E_MAIL_RELAY_URL: points the mail service's client at the stand-in the spec starts; never in a real site (a real site names no address) (below) |
| `e2e/mail-relay-setup.ts` | for the mail-service spec: empties the SMTP fields and the stored token, so the next e-mail enrols and goes through the mail service (local database only) (below) |
| `e2e/mail-relay.spec.ts` | the mail service on a built site: the state block in the panel, the first e-mail through the public confirm route, no token in anything the browser receives |
| `e2e/smoke.spec.ts` | the smoke tests every release must pass: pages, showcase, forms (also a file sent by e-mail), sitemap, SEO/GEO, headers, consent, 2FA |
| `e2e/smtp-sink.ts` | a local mail sink for the smoke tests: reads what the site really sent (recipients, attachments) |
| `e2e/totp.ts` | RFC 6238 code generator for the 2FA sign-in in the smoke test (below) |
| `e2e/totp.ts` | RFC 6238 code generator for the 2FA sign-in in the smoke test, and the address of the second test admin (below) |
| `e2e/two-factor-back.spec.ts` | browser test of the 2FA screens' `back` link (twoFactor.safeBack): a prepared link — script or another host — ends on the admin root, an ordinary one is followed |
| `e2e/two-factor-setup.spec.ts` | browser check of "2FA setup required": the first admin of a fresh site, a new editor, the administrator's reset on the account page |
### `e2e/create-test-admin.ts`
### `e2e/global-setup.ts`
```ts
import { execFileSync } from 'node:child_process'
/**
* Before every Playwright run: the test admins are made (or reset) and their stored 2FA attempt counts cleared
* (e2e/create-test-admin.ts). The count is kept in the database — 5 verify attempts per account in 10 minutes —
* so without this a second run within ten minutes, or one spec run after the whole suite, would find the test
* admin locked out: the result would depend on what ran before. Skipped when the test admin is not configured
* (the specs that need it skip themselves) or with E2E_SKIP_ADMIN_SETUP=1.
*/
export default function globalSetup(): void {
const { E2E_ADMIN_EMAIL, E2E_ADMIN_PASSWORD, E2E_SKIP_ADMIN_SETUP, E2E_TOTP_SECRET } = process.env
if (E2E_SKIP_ADMIN_SETUP === '1' || !E2E_ADMIN_EMAIL || !E2E_ADMIN_PASSWORD || !E2E_TOTP_SECRET) {return}
execFileSync('pnpm', ['payload', 'run', 'e2e/create-test-admin.ts'], { env: { ...process.env, NODE_ENV: 'development' }, stdio: 'inherit' })
}
```
### `e2e/mail-relay-fixture.ts`
```ts
/**
* Creates (or resets) the smoke-test admin with a known TOTP secret, so e2e/smoke.spec.ts signs in through
* the real 2FA screen instead of skipping it. LOCAL / CI database only:
* pnpm payload run e2e/create-test-admin.ts
* Values come from E2E_ADMIN_EMAIL / E2E_ADMIN_PASSWORD / E2E_TOTP_SECRET (.env.example). Not a seed: seeds
* never create users (docs/seeding.md). It also points e-mail sending at the tests' local mail sink
* (E2E_SMTP_PORT, default 2526).
* Test fixture, on only with E2E_MAIL_RELAY_URL (e2e/mail-relay.spec.ts): points the mail service's client at
* a stand-in the spec starts on this machine, so the spec can watch a built site enrol through its own confirm
* route and send — without the real service. Never part of a real site: the starter drops `e2e/` and the lines
* that use this file; a real site names no address (the plugin's own is used).
*/
export const E2E_MAIL_RELAY_URL = process.env.E2E_MAIL_RELAY_URL || undefined
/** `iapl({ mail })` for the test, `undefined` (the plugin's defaults) otherwise. */
export const e2eMail = E2E_MAIL_RELAY_URL ? { relay: { retryBackoffMs: 50, url: E2E_MAIL_RELAY_URL } } : undefined
/**
* `iapl({ developmentHosts })` for a test that plays a development address on this machine (the built-in
* pattern, `*.dev.netscale.pl`, cannot be served from localhost): E2E_DEVELOPMENT_HOSTS, comma-separated
* patterns. `undefined` (the plugin's built-in list) otherwise.
*/
export const e2eDevelopmentHosts = process.env.E2E_DEVELOPMENT_HOSTS ? process.env.E2E_DEVELOPMENT_HOSTS.split(',').map((p) => p.trim()).filter(Boolean) : undefined
```
### `e2e/mail-relay-setup.ts`
```ts
/**
* For e2e/mail-relay.spec.ts — LOCAL / CI database only:
* pnpm payload run e2e/mail-relay-setup.ts the site has no SMTP server and no token: its next e-mail
* goes to the mail service, enrolling first
* Afterwards the spec runs e2e/create-test-admin.ts again, which points e-mail back at the tests' SMTP sink.
*/
import config from '@payload-config'
import { RELAY_KV_KEY } from '@intecion/ipal-kit'
import { isLocalDatabase } from '@intecion/ipal-kit/seed'
import { getPayload } from 'payload'
const { E2E_ADMIN_EMAIL: email, E2E_ADMIN_PASSWORD: password, E2E_TOTP_SECRET: totpSecret } = process.env
if (!email || !password || !totpSecret) {throw new Error('Set E2E_ADMIN_EMAIL, E2E_ADMIN_PASSWORD and E2E_TOTP_SECRET (.env.example).')}
if (process.env.NODE_ENV === 'production' && !process.env.CI) {throw new Error('Refusing: NODE_ENV=production outside CI.')}
if (!isLocalDatabase(process.env.DATABASE_URI ?? '')) {throw new Error('Refusing: DATABASE_URI is not a local database.')}
const payload = await getPayload({ config })
const data = { email, hasTotp: true, password, roles: ['admin'], totpSecret }
const found = await payload.find({ collection: 'users', limit: 1, overrideAccess: true, where: { email: { equals: email } } })
if (found.docs[0]) {
await payload.update({ id: found.docs[0].id, collection: 'users', data: data as never, overrideAccess: true })
} else {
await payload.create({ collection: 'users', data: data as never, overrideAccess: true })
}
console.log(`[e2e] test admin ready: ${email}`)
// E-mail for the smoke tests goes to a local sink the test itself starts (e2e/smtp-sink.ts), so the test can
// read what the site sent — the form file as an attachment. Without the sink running, sends simply fail.
const smtpPort = Number(process.env.E2E_SMTP_PORT ?? 2526)
await payload.updateGlobal({
slug: 'site-integrations',
data: { emailTransport: 'smtp', smtpFromAddress: 'site@example-studio.test', smtpHost: '127.0.0.1', smtpPassword: 'e2e-sink', smtpPort, smtpUser: 'e2e' } as never,
context: { ipalIntegrationStatus: true },
data: { emailStatus: { checkedAt: null, code: null, message: null, since: null, state: null }, emailTransport: 'smtp', smtpFromAddress: 'site@example-studio.test', smtpFromName: 'Example Studio', smtpHost: null, smtpPassword: null, smtpUser: null } as never,
overrideAccess: true,
})
console.log(`[e2e] e-mail sending points at the local sink 127.0.0.1:${smtpPort}`)
for (const key of await payload.kv.keys()) {
if (key === RELAY_KV_KEY || key.startsWith(`${RELAY_KV_KEY}:`)) {await payload.kv.delete(key)}
}
console.log('[e2e] no SMTP server and no mail-service token: the next e-mail enrols and goes through the mail service')
process.exit(0)
```
@@ -1222,4 +1267,7 @@ export function totp(secret: string, now = Date.now()): string {
const code = (hmac.readUInt32BE(offset) & 0x7fffffff) % 1_000_000
return code.toString().padStart(6, '0')
}
/** The second smoke-test admin (create-test-admin.ts makes both): `e2e-admin@…` → `e2e-admin-2@…`. */
export const secondTestAdmin = (email: string): string => email.replace('@', '-2@')
```
@@ -1,9 +1,9 @@
---
name: ipal-audit
description: Audits an ipal-kit (Payload 3 + Next 16) project against AGENT.md rules with a deterministic script — the mandatory feature set (SEO, JSON-LD, llms.txt, Markdown, MCP, R2, Turnstile, panel forms, consent, 2FA, health, env, security headers, X-Powered-By, CSP), forbidden replacements (own forms, nodemailer, reCAPTCHA, hand-written JSON-LD), hardcoded texts/links, forbidden field names, monolithic sections, middleware.ts, missing ISR/generateStaticParams, hex colors, server imports in client components, extra collections, then tsc and build. Use before saying a task is done, after any block/collection/layout change, after an Impeccable pass, and when asked to review or audit the project.
name: iapl-audit
description: Audits an IAPL (Payload 3 + Next 16) project against AGENT.md rules with a deterministic script — the mandatory feature set (SEO, JSON-LD, llms.txt, Markdown, MCP, R2, Turnstile, panel forms, consent, 2FA, health, env, security headers, X-Powered-By, CSP), forbidden replacements (own forms, nodemailer, reCAPTCHA, hand-written JSON-LD), hardcoded texts/links, forbidden field names, monolithic sections, middleware.ts, missing ISR/generateStaticParams, hex colors, server imports in client components, extra collections, then tsc and build. Use before saying a task is done, after any block/collection/layout change, after an Impeccable pass, and when asked to review or audit the project.
---
# ipal-audit
# iapl-audit
The checks from AGENT.md §11 as a script — always the same, no interpretation.
@@ -11,8 +11,8 @@ The checks from AGENT.md §11 as a script — always the same, no interpretation
1. From the project root, run:
```bash
bash .agents/skills/ipal-audit/scripts/audit.sh --quick # while working
bash .agents/skills/ipal-audit/scripts/audit.sh # before "done" (+ tsc + build)
bash .agents/skills/iapl-audit/scripts/audit.sh --quick # while working
bash .agents/skills/iapl-audit/scripts/audit.sh # before "done" (+ tsc + build)
```
Options: `--help`. Do not read the script source — the output is enough.
2. Show the user the **full output** (summary + list of violations).
@@ -27,7 +27,7 @@ The checks from AGENT.md §11 as a script — always the same, no interpretation
## "missing: …" — the mandatory set (AGENT.md §0b)
Every `[ERROR] missing: X` is an item of the set that the code lacks. Wire it
following the hint (PROGRAMISTA §2) — do not ask whether it is needed. The only exception:
a client decision recorded in `AGENTS.md` as `ipal-audit-skip: <keys> — <reason>` (keys
a client decision recorded in `AGENTS.md` as `iapl-audit-skip: <keys> — <reason>` (keys
in AGENT.md §0b). Never add that line yourself just to make the audit pass.
## Polish text and panel labels (AGENT.md §2, §6.5a)
@@ -40,14 +40,14 @@ in AGENT.md §0b). Never add that line yourself just to make the audit pass.
The script checks: hex in classes and inline styles (error), `dark:` on colour utilities and `var(--color-…)` in
classes (warnings), `styles.css` without `@intecion/ipal-kit/tokens.css` (warning — a site not yet migrated),
next/font in `--font-body` with the preset (warning), and with `src/design/tokens.ts`: no `DESIGN.md` (warning) and
`ipal-tokens --check` — a stale `src/design/tokens.css` or a WCAG AA contrast failure is an error.
`iapl-tokens --check` — a stale `src/design/tokens.css` or a WCAG AA contrast failure is an error.
## ipal-audit and ipal-doctor
`ipal-audit` checks the **code** inside the edit loop (and tsc + build). `pnpm exec ipal-doctor` checks the **site**
## iapl-audit and iapl-doctor
`iapl-audit` checks the **code** inside the edit loop (and tsc + build). `pnpm exec iapl-doctor` checks the **site**
against the team standard: it runs this script (`--quick`) from the installed package, reports its findings under its
own rule ids (`i18n-literals`, `blocks-tokens`, `audit:<title>`, one per file), and adds versions, Node, layout, database
names, env, admin, AGENTS.md, skills, seeds and — with `--url` / `--deep` — the running site and the database
(the `ipal-doctor` skill, docs/doctor.md). An approved exception for the doctor goes into `ipal-doctor.json` with a reason.
(the `iapl-doctor` skill, docs/doctor.md). An approved exception for the doctor goes into `iapl-doctor.json` with a reason.
## What the script does not check (do it by hand)
@@ -60,9 +60,11 @@ names, env, admin, AGENTS.md, skills, seeds and — with `--url` / `--deep` —
- **Response headers** (on a running build — `pnpm build && pnpm start`, or the deployed domain):
```bash
U=http://localhost:3000
for p in /pl /admin /api/health; do echo "== $p"; curl -sI "$U$p" | grep -iE 'x-powered-by|content-security-policy'; done
for p in /pl /admin /api/health; do echo "== $p"; curl -sI "$U$p" | grep -iE 'x-powered-by|content-security-policy|critical-ch'; done
```
`x-powered-by` anywhere → ERROR (`withSecurityConfig`, security.md → "X-Powered-By"). No
`x-powered-by` anywhere → ERROR (`withSecurityConfig`, security.md → "X-Powered-By"). `critical-ch` on `/pl` or
`/api/health` → INFO: Chrome repeats the first request of every visit; make `withSecurityConfig` the outer wrapper,
`withSecurityConfig(withPayload(nextConfig))` (security.md → "Client hints"); on `/admin` it belongs. No
`content-security-policy` / `content-security-policy-report-only` on `/pl` and `/admin` → WARNING (CSP not
rolled out). Report-only for more than a few weeks with clean reports → WARNING (switch to `mode: 'enforce'`).
Then open `/pl` and `/admin` in the browser: CSP lines in the console = missing sources (flags / `extra`).
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
# ipal-audit — deterministic checks of an ipal-kit project against AGENT.md.
# iapl-audit — deterministic checks of an IAPL project against AGENT.md.
# Run from the project root:
# bash .agents/skills/ipal-audit/scripts/audit.sh # all checks + tsc + build
# bash .agents/skills/ipal-audit/scripts/audit.sh --quick # static checks only
# bash .agents/skills/ipal-audit/scripts/audit.sh --help
# bash .agents/skills/iapl-audit/scripts/audit.sh # all checks + tsc + build
# bash .agents/skills/iapl-audit/scripts/audit.sh --quick # static checks only
# bash .agents/skills/iapl-audit/scripts/audit.sh --help
# Exit code: 0 = no errors (warnings allowed), 1 = at least one error.
set -u
@@ -22,7 +22,7 @@ for arg in "$@"; do
done
if [ ! -d src ]; then
echo "ipal-audit: run from the project root (no ./src found)." >&2
echo "iapl-audit: run from the project root (no ./src found)." >&2
exit 2
fi
@@ -52,7 +52,7 @@ dirs() { for d in "$@"; do [ -d "$d" ] && printf '%s ' "$d"; done; }
BLOCKS=$(dirs src/blocks)
UI=$(dirs src/blocks src/components)
echo "ipal-audit — $(pwd)"
echo "iapl-audit — $(pwd)"
# --- Skill templates must not be compiled as project code ---
if [ -d .agents ] && [ -f tsconfig.json ]; then
@@ -162,7 +162,7 @@ if [ -n "$UI" ]; then
report WARNING "old colour variables in classes" "§6.11 use the preset utilities (bg-primary, text-fg) — not var(--color-…)" \
"$(g '\[var\(--color-' $UI --include=*.tsx)"
report ERROR "hex colors in inline styles" "§6.11 use design tokens — IPAL_TOKENS / ipalVar() for a dynamic style" \
report ERROR "hex colors in inline styles" "§6.11 use design tokens — IAPL_TOKENS / iaplVar() for a dynamic style" \
"$(g "style=\{\{[^}]*['\"]#[0-9a-fA-F]{3,8}['\"]" $UI --include=*.tsx)"
report ERROR "barrel index.ts" "§6.12 import files directly" \
@@ -184,14 +184,14 @@ if [ -n "$STYLES" ]; then
"$(grep -q 'ipal-kit/tailwind.css' "$STYLES" && g "variable: ['\"]--font-(body|heading|mono)['\"]" src/app --include=*.ts --include=*.tsx)"
fi
if [ -f src/design/tokens.ts ]; then
[ -f DESIGN.md ] || report WARNING "no DESIGN.md" "§6.11 the brand is described in DESIGN.md (template: ipal-setup/resources/DESIGN.md)" "DESIGN.md missing"
TOKENS_BIN=node_modules/@intecion/ipal-kit/bin/ipal-tokens.mjs
[ -f DESIGN.md ] || report WARNING "no DESIGN.md" "§6.11 the brand is described in DESIGN.md (template: iapl-setup/resources/DESIGN.md)" "DESIGN.md missing"
TOKENS_BIN=node_modules/@intecion/ipal-kit/bin/iapl-tokens.mjs
if [ -f "$TOKENS_BIN" ]; then
TOKENS_OUT=$(node "$TOKENS_BIN" --check 2>&1)
[ $? -ne 0 ] && report ERROR "ipal-tokens --check" "§6.11 run pnpm exec ipal-tokens: the CSS is stale or a contrast pair fails WCAG AA" \
"$(printf '%s\n' "$TOKENS_OUT" | grep -E '✗|out of date|ipal-tokens:' || echo 'ipal-tokens --check failed')"
[ $? -ne 0 ] && report ERROR "iapl-tokens --check" "§6.11 run pnpm exec iapl-tokens: the CSS is stale or a contrast pair fails WCAG AA" \
"$(printf '%s\n' "$TOKENS_OUT" | grep -E '✗|out of date|iapl-tokens:' || echo 'iapl-tokens --check failed')"
else
report WARNING "ipal-tokens not installed" "§6.11 @intecion/ipal-kit 1.15+ ships the ipal-tokens bin" "$TOKENS_BIN missing"
report WARNING "iapl-tokens not installed" "§6.11 @intecion/ipal-kit 1.15+ ships the iapl-tokens bin" "$TOKENS_BIN missing"
fi
fi
@@ -199,7 +199,7 @@ fi
if [ -d src/collections ]; then
report ERROR "forbidden collection" "§5.3 settings/nav/footer are globals; FAQ/hero are blocks" \
"$(ls src/collections | grep -iE '^(settings|navigation|nav|footer|header|faq|hero|company|danefirmy)\.ts$')"
report WARNING "own users collection" "§5.3 ipalKit injects the auth collection — keep your own only to add fields (roles + 2FA still attach)" \
report WARNING "own users collection" "§5.3 IAPL injects the auth collection — keep your own only to add fields (roles + 2FA still attach)" \
"$(ls src/collections | grep -iE '^(users|user)\.ts$')"
report WARNING "collections present — confirm each passed the §5.3 test" "minimum: Pages, Media" \
"$(ls src/collections | grep -viE '^(pages|media|users|user|settings|navigation|nav|footer|header|faq|hero|company|danefirmy)\.ts$')"
@@ -261,8 +261,8 @@ done <<< "$(printf '%s\n' "$HTML" | cut -d'|' -f1-2 | sort -u)"
# --- Mandatory feature set (AGENT.md §0b) ---
# Every site wires all of these through the plugin. A missing one is an ERROR
# unless AGENTS.md records the client's decision: `ipal-audit-skip: mcp, llms-full — reason`.
SKIP=$(grep -hiE '^[-* ]*ipal-audit-skip:' AGENTS.md 2>/dev/null | sed 's/^[^:]*://; s/—.*//; s/ - .*//' | tr ',' ' ')
# unless AGENTS.md records the client's decision: `iapl-audit-skip: mcp, llms-full — reason`.
SKIP=$(grep -hiE '^[-* ]*(iapl|ipal)-audit-skip:' AGENTS.md 2>/dev/null | sed 's/^[^:]*://; s/—.*//; s/ - .*//' | tr ',' ' ')
skipped() { for k in $SKIP; do [ "$k" = "$1" ] && return 0; done; return 1; }
# has <regex> <paths…> — true when any file under the paths matches
has() { local re="$1"; shift; grep -rqE "$re" "$@" 2>/dev/null; }
@@ -294,9 +294,9 @@ if [ -n "$APP" ]; then
need WARNING '' "AI summary field" "buildSummaryField() in Pages + createContentHelpers({ summaryField: 'aiSummary' })" 'buildSummaryField' src
# Ops
need ERROR '' "health route" "src/app/api/health/route.ts → export { healthRoute as GET } from '@/lib/content'" 'healthRoute|createHealthRoute' src/app
need ERROR '' "env validation" "src/instrumentation.ts → assertEnv(ipalEnvRules({...})) from @intecion/ipal-kit/env" 'assertEnv' src/instrumentation.ts instrumentation.ts
need ERROR '' "env validation" "src/instrumentation.ts → assertEnv(iaplEnvRules({...})) from @intecion/ipal-kit/env" 'assertEnv' src/instrumentation.ts instrumentation.ts
need ERROR '' "security headers" "next.config.ts → buildSecurityHeaders" 'buildSecurityHeaders' next.config.ts next.config.mjs next.config.js
need WARNING '' "X-Powered-By hidden" "next.config.ts → export default withPayload(withSecurityConfig(nextConfig)) — Next and withPayload send X-Powered-By: Next.js, Payload (security.md)" 'withSecurityConfig|poweredByHeader: *false' next.config.ts next.config.mjs next.config.js
need WARNING '' "X-Powered-By hidden" "next.config.ts → export default withSecurityConfig(withPayload(nextConfig)) — Next and withPayload send X-Powered-By: Next.js, Payload (security.md)" 'withSecurityConfig|poweredByHeader: *false' next.config.ts next.config.mjs next.config.js
need WARNING csp "Content-Security-Policy" "next.config.ts → buildSecurityHeaders({ csp: { mode: 'report-only', reportUri: '/api/csp-report', … } }) + buildAdminCspHeaders on /admin/:path*, then 'enforce' (security.md → ROLL OUT CSP)" "csp: *\\{|csp,|buildCsp|Content-Security-Policy" next.config.ts next.config.mjs next.config.js src/proxy.ts proxy.ts
# Consent, analytics, Turnstile (layout)
need ERROR '' "cookie consent" "<SiteProviders> (or ConsentProvider + CookieBanner + CookieButton) in [locale]/layout.tsx" 'SiteProviders|CookieBanner' src/app
@@ -305,21 +305,21 @@ if [ -n "$APP" ]; then
need WARNING turnstile "Turnstile site key" "getSiteShell(locale) (or getTurnstileConfig(payload)) — off unless BOTH keys are set" 'getSiteShell|getTurnstileConfig' src
need WARNING '' "MediaPreconnect" "<SiteProviders> (adds it) or <MediaPreconnect/> in the layout" 'SiteProviders|MediaPreconnect' src/app
# Forms
need ERROR '' "form submission via the plugin" "actions.ts → export const sendForm = createSubmitAction({ getCachedPayload, headers }) (ipal-form)" 'createSubmitAction|submitForm' src
need ERROR '' "form submission via the plugin" "actions.ts → export const sendForm = createSubmitAction({ getCachedPayload, headers }) (iapl-form)" 'createSubmitAction|submitForm' src
need WARNING '' "upload sandbox headers" "next.config.ts → ...buildUploadSecurityHeaders() (uploaded SVG can't run script)" 'buildUploadSecurityHeaders' next.config.ts next.config.mjs next.config.js
need WARNING '' "images preset" "next.config.ts → images: { ...buildImagesConfig() } (AVIF/WebP, R2 domain)" 'buildImagesConfig' next.config.ts next.config.mjs next.config.js
fi
if [ -n "$CFG" ]; then
need ERROR '' "forms in ipalKit" "$CFG → ipalKit({ forms: {…} }) — forms are built in the panel" 'forms *:' "$CFG"
need ERROR '' "forms in iapl" "$CFG → iapl({ forms: {…} }) — forms are built in the panel" 'forms *:' "$CFG"
need ERROR '' "mailAdapter" "$CFG → email: mailAdapter() — form e-mails go through the panel transport" 'mailAdapter\(' "$CFG"
need ERROR r2 "R2 storage" "$CFG → buildR2Storage(['media'], { s3Storage }) — always wired, local disk only without R2_* env" 'buildR2Storage' "$CFG"
# pnpm dev / generate:importmap with ipal-kit < 1.12.2 and no R2_* env dropped the storage-s3
# pnpm dev / generate:importmap with IAPL < 1.12.2 and no R2_* env dropped the storage-s3
# client handler → blank admin in production (where R2 is on)
if grep -q 'buildR2Storage' "$CFG" 2>/dev/null; then
for IM in src/app/\(payload\)/*/importMap.js; do
[ -f "$IM" ] || continue
report ERROR "import map without the R2 upload handler" "storage.md — pnpm payload generate:importmap (ipal-kit ≥ 1.12.2 writes it with or without R2_* env); without it the production admin renders blank" \
report ERROR "import map without the R2 upload handler" "storage.md — pnpm payload generate:importmap (IAPL ≥ 1.12.2 writes it with or without R2_* env); without it the production admin renders blank" \
"$(grep -q 'S3ClientUploadHandler' "$IM" || echo "$IM")"
done
fi
@@ -331,10 +331,10 @@ fi
# A form seed: scripts/seed-form-*.ts, or a seed file (src/seed, scripts) that seeds the forms collection.
FORM_SEED=$(ls scripts/seed-form* 2>/dev/null; grep -rlE "collection: *['\"]forms['\"]|upsertBy\( *['\"]forms['\"]|seed\.form\(|\.forms?\(" $(dirs src/seed scripts) 2>/dev/null)
if [ -n "$CFG" ] && grep -qE 'forms *:' "$CFG" 2>/dev/null && [ -z "$FORM_SEED" ] && ! skipped forms-seed; then
report WARNING "no form seed" "ipal-form §5 — every form from a seed (scripts/seed-form-*.ts or src/seed/forms.ts: notification + sender confirmation, all languages)" "scripts/seed-form-*.ts"
report WARNING "no form seed" "iapl-form §5 — every form from a seed (scripts/seed-form-*.ts or src/seed/forms.ts: notification + sender confirmation, all languages)" "scripts/seed-form-*.ts"
fi
need WARNING r2 "R2 env in .env.example" ".env.example lists R2_BUCKET, R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_PUBLIC_URL" 'R2_BUCKET' .env.example
need WARNING '' "IPAL_IP_HEADER in .env.example" "header the rate limit trusts, e.g. cf-connecting-ip (forms.md)" 'IPAL_IP_HEADER' .env.example
need WARNING '' "IAPL_IP_HEADER in .env.example" "header the rate limit trusts, e.g. cf-connecting-ip (forms.md)" '(IAPL|IPAL)_IP_HEADER' .env.example
# Plugin replacements (§0b "Forbidden substitutes")
report ERROR "own form / mail / captcha stack" "§0b — forms come from the panel builder, mail from mailAdapter, bot check from Turnstile" \
@@ -349,7 +349,7 @@ report WARNING "<form> outside the form renderer" "§0b — panel forms render v
"$(g '<form[ >]' src --include=*.tsx | grep -v 'components/forms/')"
# Project copies of what the plugin now ships (import instead of code)
report WARNING "own form engine" "ipal-form §3 — <RenderForm> / useBuilderForm (steps, choices, Turnstile, honeypot; Emails tab never reaches the browser)" \
report WARNING "own form engine" "iapl-form §3 — <RenderForm> / useBuilderForm (steps, choices, Turnstile, honeypot; Emails tab never reaches the browser)" \
"$(g 'buildValidator|useForm\(' src --include=*.tsx | grep -v 'useBuilderForm')"
report WARNING "own image lightbox" "lightbox.md — <LightboxTrigger> + lightboxImage, one <SiteProviders lightbox>; labels from Notifications → Lightbox" \
"$(g "['\"](glightbox|photoswipe|yet-another-react-lightbox|react-medium-image-zoom|fslightbox-react)['\"]" src --include=*.ts --include=*.tsx)"
@@ -383,5 +383,5 @@ if [ "$QUICK" -eq 0 ]; then
fi
echo
echo "ipal-audit: $ERRORS error(s), $WARNINGS warning(s)$( [ "$QUICK" -eq 1 ] && echo ' (quick: no tsc/build)')"
echo "iapl-audit: $ERRORS error(s), $WARNINGS warning(s)$( [ "$QUICK" -eq 1 ] && echo ' (quick: no tsc/build)')"
[ "$ERRORS" -eq 0 ]
@@ -4,7 +4,7 @@
// Reads the syntax tree (the project's TypeScript), so comments never count and multi-line forms work.
// Not reported: the panel's own labels (AGENT.md §6.5a), only in a schema file — a .ts file under
// collections/, globals/, fields/ or blocks/, or one importing Payload's schema types; never a .tsx file:
// - adminText('Title', 'Tytuł') from @intecion/ipal-kit
// - adminText('Title', 'Tytuł') from @intecion/ipal-kit/blocks
// - { en: 'Title', pl: 'Tytuł' } as the value of label, singular, plural, description, placeholder or group
// - rowLabel('title', { en: 'Item', pl: 'Pozycja' }) from @intecion/ipal-kit
// - const TITLE: AdminText = { en: 'Title', pl: 'Tytuł' }
@@ -28,7 +28,7 @@ const POLISH = /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/
const SCHEMA_KEYS = new Set(['label', 'singular', 'plural', 'description', 'placeholder', 'group'])
const SCHEMA_DIR = /(?:^|\/)(?:collections|globals|fields|blocks)\//
const SCHEMA_TYPES = /import\s+type\s*\{[^}]*\b(?:Block|CollectionConfig|Field|GlobalConfig|Tab)\b[^}]*\}\s*from\s*['"]payload['"]/
const IPAL = /^@intecion\/ipal-kit(?:\/|$)/
const IAPL = /^@intecion\/ipal-kit(?:\/|$)/
const files = []
const walk = (p) => {
@@ -50,7 +50,7 @@ for (const file of files) {
// Local names of the plugin's helpers (`import { adminText as t } …`); a lookalike of your own does not count.
const helpers = new Map()
for (const st of source.statements) {
if (!ts.isImportDeclaration(st) || !IPAL.test(st.moduleSpecifier.text)) continue
if (!ts.isImportDeclaration(st) || !IAPL.test(st.moduleSpecifier.text)) continue
const named = st.importClause?.namedBindings
if (!named || !ts.isNamedImports(named)) continue
for (const el of named.elements) {
@@ -1,12 +1,12 @@
---
name: ipal-block
description: Builds or refactors one page section (Payload block + React component) in an ipal-kit project the correct way — first a block of the plugin's block library (libraryBlocks / createBlockRegistry, 15 ready sections) or its variant or options, and only when none fits an own block with a clean editor panel (repeatable things as "+ Add …" arrays with rowLabel, never cta1/cta2 slots, short `{ en, pl }` labels per docs/dev/admin-ux.md, no empty spare fields), shared fields from the plugin (buildSectionHeaderField, buildLinksField, buildLinkField, buildSectionSettingsField), UI primitives (Section, SectionHeader, Media, CMSLink), fixed field vocabulary, max ~80 lines of JSX, subcomponents for repeated items, registry wiring. Use when creating a new section/block (hero, features, CTA, FAQ, gallery, pricing, testimonials…), changing a block's fields, or fixing a block with ctaLabel/buttonUrl/pdfUrl fields or a monolithic component.
name: iapl-block
description: Builds or refactors one page section (Payload block + React component) in an IAPL project the correct way — first a block of the plugin's block library (libraryBlocks / createBlockRegistry, 15 ready sections) or its variant or options, and only when none fits an own block with a clean editor panel (repeatable things as "+ Add …" arrays with rowLabel, never cta1/cta2 slots, short `{ en, pl }` labels per docs/dev/admin-ux.md, no empty spare fields), shared fields from the plugin (buildSectionHeaderField, buildLinksField, buildLinkField, buildSectionSettingsField), UI primitives (Section, SectionHeader, Media, CMSLink), fixed field vocabulary, max ~80 lines of JSX, subcomponents for repeated items, registry wiring. Use when creating a new section/block (hero, features, CTA, FAQ, gallery, pricing, testimonials…), changing a block's fields, or fixing a block with ctaLabel/buttonUrl/pdfUrl fields or a monolithic component.
---
# ipal-block
# iapl-block
**ipal-kit first (hard rule, AGENT.md "ipal-kit first"):** anything the plugin covers is built with the
plugin's feature. It does not work or is not enough → report it with **ipal-plugin-gap** and wait for the owner's
**IAPL first (hard rule, AGENT.md "IAPL first"):** anything the plugin covers is built with the
plugin's feature. It does not work or is not enough → report it with **iapl-plugin-gap** and wait for the owner's
decision on that part; no hand-built replacement, no silent workaround. **Code rules:** AGENT.md "Code rules"
(one job per file/component/function, no duplicates, typed, texts from the panel, a check for new behaviour).
@@ -24,12 +24,12 @@ The plugin ships 15 blocks: `hero`, `textMedia`, `featureGrid`, `cta`, `richText
(own `{ label: { en, pl }, value }` + `components` / `classNames` in the registry), `settings: { backgrounds }`,
`links`, `maxItems`. Another look of one part → `createBlockRegistry(content, { classNames: { faq: { item: '…' } } })`;
another primitive everywhere → `ui: { Media }`.
3. The project must own it completely → `pnpm exec ipal-blocks eject <block>` (same slug and data, no migration),
3. The project must own it completely → `pnpm exec iapl-blocks eject <block>` (same slug and data, no migration),
then the ejected builder in `pageBlocks` and `components: { <slug>: <Name>Block }` in the registry.
4. Nothing fits → an own block (below), with the library's builders (`buildItemsField`, `buildMediaField`,
`buildVariantField`, `buildContentField`, `defineLibraryBlock`) and primitives (`Section`, `SectionHeader`, `Media`,
`CMSLink`, `Card` from `@intecion/ipal-kit/blocks/rsc`), added to `extra` in `createBlockRegistry`.
Record the reason in AGENTS.md → "Project decisions" (`ipal-doctor` warns about own blocks that copy a library block).
Record the reason in AGENTS.md → "Project decisions" (`iapl-doctor` warns about own blocks that copy a library block).
**Check (library block):** `pnpm generate:types` → `pnpm payload generate:importmap` → Postgres/SQLite
`pnpm payload migrate:create`; add the block to a page in the panel (en and pl labels, ≤ 6 fields), the page shows
@@ -83,6 +83,6 @@ File patterns (Hero, FeatureGrid + FeatureCard): `resources/section-code.md`.
readable in English and Polish (switch the admin language in Account),
"+ Add Button / Add Feature", collapsed rows showing their content, every field shows something.
First `rowLabel` in the project → `pnpm payload generate:importmap`.
- Run the **ipal-audit** skill (`--quick`), fix every `[ERROR]`.
- Run the **iapl-audit** skill (`--quick`), fix every `[ERROR]`.
- Refactoring an existing block with renamed fields: **migrate the data first**
(old field → new), and only then remove the old fields (AGENT.md §6.7).
@@ -1,6 +1,6 @@
# Section code — ready files for the project
> Resources of the **ipal-block** skill. The rules (why, and what not to do) are in
> Resources of the **iapl-block** skill. The rules (why, and what not to do) are in
> `node_modules/@intecion/ipal-kit/docs/agent/AGENT.md` §6 — this file is only the code
> to create in the project **1:1**. Links (`buildLinkField`, `buildLinksField`,
> `resolveLink`), section fields (`buildSectionHeaderField`, `buildSectionSettingsField`) and the menu
@@ -325,7 +325,7 @@ The design-token standard (`node_modules/@intecion/ipal-kit/docs/design-tokens.m
`text-fg-strong`, `text-fg-muted`, `text-on-primary`, `border-border`, `text-link`, `outline-focus`, `text-h1`…,
`py-section`, `px-gutter`, `gap-gap`, `rounded-control`, `rounded-card`, `shadow-sm`, `max-w-container`.
**Never** hex, `bg-[#ff6600]`, `var(--color-…)`, or `dark:` for colours (the roles switch with the theme).
- The brand is `src/design/tokens.ts` → `pnpm exec ipal-tokens` → `src/design/tokens.css`; `DESIGN.md` describes it.
- The brand is `src/design/tokens.ts` → `pnpm exec iapl-tokens` → `src/design/tokens.css`; `DESIGN.md` describes it.
- Fonts via `next/font` with `variable: '--font-family-body'` / `'--font-family-heading'` on `<html>`.
- No CSS Modules and no `style={{…}}` — exception: a dynamic value from data.
- Visual variants → `Record<Variant, string>` (§6.3), not ternary chains.
@@ -336,7 +336,7 @@ The design-token standard (`node_modules/@intecion/ipal-kit/docs/design-tokens.m
@import "@intecion/ipal-kit/fluid-wide.css";
@import "@intecion/ipal-kit/tokens.css";
@import "@intecion/ipal-kit/tailwind.css";
@import "../../design/tokens.css"; /* generated by ipal-tokens from src/design/tokens.ts */
@import "../../design/tokens.css"; /* generated by iapl-tokens from src/design/tokens.ts */
@source "../../../node_modules/@intecion/ipal-kit/dist/**/*.js";
```
@@ -1,12 +1,12 @@
---
name: ipal-collection
description: Decides whether something should be a Payload collection, a global, or a block, and builds a content collection the ipal-kit way (title, buildSlugField, SEO tab, buildNoindexField, trackSlugHistoryHook, revalidate hook, archive page from System pages, sitemap and routing via content option). Use when the user asks for a blog, news, products, portfolio, testimonials, authors, categories, or any new collection — and whenever you are about to create a file in src/collections.
name: iapl-collection
description: Decides whether something should be a Payload collection, a global, or a block, and builds a content collection the IAPL way (title, buildSlugField, SEO tab, buildNoindexField, trackSlugHistoryHook, revalidate hook, archive page from System pages, sitemap and routing via content option). Use when the user asks for a blog, news, products, portfolio, testimonials, authors, categories, or any new collection — and whenever you are about to create a file in src/collections.
---
# ipal-collection
# iapl-collection
**ipal-kit first (hard rule, AGENT.md "ipal-kit first"):** anything the plugin covers is built with the
plugin's feature. It does not work or is not enough → report it with **ipal-plugin-gap** and wait for the owner's
**IAPL first (hard rule, AGENT.md "IAPL first"):** anything the plugin covers is built with the
plugin's feature. It does not work or is not enough → report it with **iapl-plugin-gap** and wait for the owner's
decision on that part; no hand-built replacement, no silent workaround. **Code rules:** AGENT.md "Code rules"
(one job per file/component/function, no duplicates, typed, texts from the panel, a check for new behaviour).
@@ -22,7 +22,7 @@ Answer these 4 questions for the user — all must be YES:
Any NO → it is not a collection:
- one set of data (company, menu, footer, settings) → **global**,
- part of a page (FAQ, hero, testimonials in a section) → **block** (ipal-block skill),
- part of a page (FAQ, hero, testimonials in a section) → **block** (iapl-block skill),
- `users` → the plugin injects it when the project has none; create your own collection with that slug
only to add fields (it wins over the injected one; roles and 2FA attach to it).
@@ -48,9 +48,14 @@ Ask only when the brief leaves a business question open (e.g. "do posts have aut
generateStaticParams, hreflang.
3. Entry list = a block (EntriesList) with `getEntries`; the entry page uses
`resolveRoute` (type `entry`); JSON-LD per seo.md (e.g. Article).
4. `pnpm generate:types`, `pnpm payload generate:importmap`.
5. Postgres with migrations → `pnpm payload migrate:create`.
4. **An auth collection for visitors** (`auth: true`: customers, members) only when the client requires it
(AGENT.md §5 "A second auth collection"): `admin: { user: 'users' }` in `buildConfig`, `access` with
`adminOrSelfIn('<slug>')` for read / update and an explicit `create`, never in `access.staffCollections`.
Its accounts pass none of the plugin's staff checks, and 2FA (setup required included) does not apply to them. Check: its token → `403` from
`/api/globals/site-integrations` and `/api/form-submissions`.
5. `pnpm generate:types`, `pnpm payload generate:importmap`.
6. Postgres with migrations → `pnpm payload migrate:create`.
## 4. Check
The **ipal-audit** skill. By hand: an entry in the panel → visible at `/<locale>/<archive>/<slug>`,
The **iapl-audit** skill. By hand: an entry in the panel → visible at `/<locale>/<archive>/<slug>`,
in the sitemap; changing the slug → 308 from the old address.
@@ -1,9 +1,9 @@
---
name: ipal-consent-check
description: Proves in a real browser (Playwright) that an ipal-kit site respects cookie consent — no Meta/Clarity/LinkedIn/TikTok/Ads requests and no tracking cookies before a decision or after "reject", Google only with Consent Mode "denied" signals, tags starting after "accept". Use after adding analytics, pixels, embeds (YouTube, maps, chat) or third-party scripts, before handing a site over, and whenever GDPR/RODO or cookie banner behaviour is in question.
name: iapl-consent-check
description: Proves in a real browser (Playwright) that an IAPL site respects cookie consent — no Meta/Clarity/LinkedIn/TikTok/Ads requests and no tracking cookies before a decision or after "reject", Google only with Consent Mode "denied" signals, tags starting after "accept", Global Privacy Control honoured, "Reject" as prominent as "Accept all", withdrawal deleting the cookies. Use after adding analytics, pixels, embeds (YouTube, maps, chat) or third-party scripts, before handing a site over, and whenever GDPR/RODO or cookie banner behaviour is in question.
---
# ipal-consent-check
# iapl-consent-check
GDPR: non-Google tags load **only after consent**; Google (GA4/GTM) may
load earlier only with the Consent Mode "denied" signal and without cookies.
@@ -19,11 +19,12 @@ before analytics or marketing consent — check the project's choice in "Project
2. Start the app (`pnpm build && pnpm start`) and check **a page with tags**
(ideally the homepage and a page with a form/video):
```bash
node .agents/skills/ipal-consent-check/scripts/consent-check.mjs http://localhost:3000/pl
node .agents/skills/iapl-consent-check/scripts/consent-check.mjs http://localhost:3000/pl
```
`--wait 6000` when tags start slowly (`defer` mode in Analytics).
3. Output: three runs in clean profiles — no decision, "Accept",
"Reject" + reload. Every `[ERROR]` is a violation — fix it:
3. Output: five runs in clean profiles — no decision, "Accept", "Reject" + reload, **Global Privacy Control**
(`Sec-GPC: 1` and `navigator.globalPrivacyControl`), "Accept" then withdraw (cookie button → "Reject").
Every `[ERROR]` is a violation — fix it:
| Violation | Cause → fix |
|---|---|
@@ -31,19 +32,36 @@ before analytics or marketing consent — check the project's choice in "Project
| tracking cookie set without consent | same; or GTM fires a tag without an `ad_storage` condition (analytics.md → GTM) |
| GA hit with consent GRANTED | `setDefaultConsent` not before the tag — `<Analytics>` must be inside `<ConsentProvider>` (`SiteProviders` does this itself) |
| YouTube / Maps before consent (warning) | `ConsentScript` (consent.md), `youtube-nocookie.com` or "click to load" |
| "Reject" is not as prominent as "Accept all" / no "Reject" on the first layer | `equalChoice={false}`, a `rejectButton` class or an `order` without `'reject'` in the layout → remove it (the default is equal; consent.md → "Compliance defaults") |
| Global Privacy Control: the Google tag loaded | IAPL before 1.17.0, a hand-made tag loader, or GTM started by hand → update; `<Analytics>` from the plugin |
| Global Privacy Control: banner shown (warning) | `gpc="ask"` / `gpc={false}` in the layout — fine only if it is a recorded project decision |
| withdraw: tracking cookie still set | the cookie is not in `DEFAULT_COOKIE_MAP`, `cookieMap` or the panel's cookie list → add it to the list (scan → approve) or `<ConsentProvider cookieMap>` |
| YouTube thumbnail / Google Fonts / Maps API before a choice (warning) | `<YouTubeEmbed poster>` with an uploaded poster; fonts through `next/font`; maps behind `ConsentScript` or click-to-load |
4. The "after accept" section shows what starts after consent — compare it with the IDs in Site
Integrations (e.g. is Meta Pixel there, if the client has one). Nothing starts
but IDs are filled in → report it as a problem to diagnose (**ipal-debug**).
but IDs are filled in → report it as a problem to diagnose (**iapl-debug**).
5. Banner not found (`data-ipal="banner"`) → `<CookieBanner/>` is not
rendered, or an older ipal-kit version without `data-ipal` attributes on the buttons → **ipal-upgrade**.
rendered, or an older IAPL version without `data-ipal` attributes on the buttons → **iapl-upgrade**.
6. Banner at first paint (1.17.0, consent.md → "First paint"): the banner is in the server HTML and an inline
script shows or hides it before the browser paints; pages stay static.
```bash
curl -s http://localhost:3000/pl | grep -c 'data-ipal="banner-script"' # 1
curl -sI http://localhost:3000/pl | grep -i cache-control # still s-maxage=… (static / ISR)
```
`0` → `firstPaint={false}`, a custom banner, or a wrapper that renders the banner only after mount
(remove it). Under a nonce CSP the browser console must not report the inline script as refused: pass
`nonce` to `<SiteProviders>`. A visitor who decided must never see the banner on reload; one whose
decision is from an older Policy version must see it at once. A click on a button before hydration
counts (the checks above click as soon as the button is visible).
The script needs buttons with `data-ipal="accept"` / `"reject"` — the plugin's
`CookieBanner` has them in every `settings` mode (`inline`, `modal`, `detailed`). A custom banner in the project violates AGENT.md §7.
## Cookie list from the panel (`cookieScanner`)
When the project has `ipalKit({ cookieScanner: true })` (cookie-scanner.md), the editor fills the
When the project has `iapl({ cookieScanner: true })` (cookie-scanner.md), the editor fills the
list in the panel and you check it:
1. Not on yet → turn it on, `pnpm generate:importmap`, `pnpm payload migrate:create cookie-scanner`
@@ -51,7 +69,7 @@ list in the panel and you check it:
chat): add them as `cookieScanner.declarations` (or an `integrations` entry with `isEnabled`) —
never a hand-typed list in code.
2. *Privacy → Cookies → Review and approve* → **Scan cookies** (with `adminLayout: 'separate'`: *Privacy → Cookie review*). "Integrations in use" must match the IDs in Site
Integrations; a filled ID that is missing → **ipal-debug**.
Integrations; a filled ID that is missing → **iapl-debug**.
3. Run the browser scan below and paste every cookie it reports as unknown into **More cookie
names**, scan again. Cookies marked **Needs description** need provider, category and
purpose: ask the client, do not guess (Edit on the approval page opens the entry).
@@ -73,9 +91,9 @@ list in the panel and you check it:
When the project has `cookieScanner: { crawl: true }` (cookie-scanner.md → Browser crawl):
1. Not on yet and the client wants it → turn it on; env `IPAL_COOKIE_SCAN_URL` +
`IPAL_COOKIE_SCAN_TOKEN` (`openssl rand -hex 32`) in Coolify; ask the team to add
`<host>=<token>` to the scanner service's `IPAL_CRAWLER_SITES`; `generate:importmap`,
1. Not on yet and the client wants it → turn it on; env `IAPL_COOKIE_SCAN_URL` +
`IAPL_COOKIE_SCAN_TOKEN` (`openssl rand -hex 32`) in Coolify; ask the team to add
`<host>=<token>` to the scanner service's `IAPL_CRAWLER_SITES`; `generate:importmap`,
`migrate:create cookie-crawl`. Never add Playwright or Chromium to the site.
2. *Cookie review* → **Check site**. "Check site" disabled → the box names the missing variable.
Failed → *Privacy → Cookie check → Error* ("Could not reach the scanner service" = URL / DNS /
@@ -88,7 +106,7 @@ When the project has `cookieScanner: { crawl: true }` (cookie-scanner.md → Bro
before handover. A crawl never adds anything to the cookie banner by itself.
5. Optional: recipients in *Cookie check → Warning e-mails to* (the e-mail also says when cookies
wait for approval and links to the approval page), and a weekly Coolify scheduled task
`curl -X POST -H "Authorization: Bearer $IPAL_COOKIE_SCAN_TOKEN" $NEXT_PUBLIC_SERVER_URL/api/ipal/cookie-crawl`.
`curl -X POST -H "Authorization: Bearer $IAPL_COOKIE_SCAN_TOKEN" $NEXT_PUBLIC_SERVER_URL/api/ipal/cookie-crawl`.
Record both in `AGENTS.md` → "Project decisions".
## Cookie list for the cookie policy (cookie-scan)
@@ -99,7 +117,7 @@ unknown names to the panel scan above instead of step 2):
1. Scan the running site (without consent and after "Accept all", homepage + up to 10 pages from the sitemap):
```bash
node .agents/skills/ipal-consent-check/scripts/cookie-scan.mjs http://localhost:3000 --lang pl
node .agents/skills/iapl-consent-check/scripts/cookie-scan.mjs http://localhost:3000 --lang pl
```
Output: `cookie-scan/cookies.json` and `cookie-scan/cookies.md` (table). `[ERROR]` = a
**non-necessary cookie set before consent** — fix it as in the table above. `[WARNING] unknown` —
@@ -107,7 +125,7 @@ unknown names to the panel scan above instead of step 2):
in `cookies.json`. Do not guess — ask if you do not know.
2. Import into the panel (Cookies → Cookie list), each language separately (scan with `--lang en` for English):
```bash
LOCALE=pl pnpm payload run .agents/skills/ipal-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
LOCALE=pl pnpm payload run .agents/skills/iapl-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
```
It merges by name and does not overwrite editor changes (`OVERWRITE=1` forces it). It does not delete cookies
the scan did not see — the editor does that in the panel. The same list feeds the
@@ -0,0 +1,214 @@
#!/usr/bin/env node
// iapl-consent-check — proves in a real browser that tracking waits for consent (GDPR).
// node consent-check.mjs <pageUrl> [--wait 4000]
// Five runs, each in a fresh browser profile:
// 1. no decision → no third-party pixels, no tracking cookies, Google only with "denied" signals;
// "Reject" as prominent as "Accept all" (same size, same look or no weaker contrast)
// 2. accept all → configured tags start (reported, so you can confirm they're the right ones)
// 3. reject all → same as 1, also after a reload
// 4. Global Privacy Control (Sec-GPC: 1 + navigator.globalPrivacyControl) → no banner (IAPL 1.17.0 default),
// no tracker request at all, Google included
// 5. accept, then withdraw (cookie button → reject) → the tracking cookies are gone
// Needs Playwright: pnpm add -D playwright && pnpm exec playwright install chromium
// Exit code: 0 = compliant, 1 = violations, 2 = setup problem.
const args = process.argv.slice(2)
if (!args[0] || args.includes('--help') || args.includes('-h')) {
console.log('Usage: consent-check.mjs <pageUrl> [--wait ms]')
process.exit(args[0] ? 0 : 2)
}
const url = args[0]
const waitIdx = args.indexOf('--wait')
const WAIT = waitIdx >= 0 ? Number(args[waitIdx + 1]) || 4000 : 4000
let pw
for (const mod of ['playwright', 'playwright-core', '@playwright/test']) {
try { pw = await import(mod); break } catch { /* next */ }
}
if (!pw) {
console.error('iapl-consent-check: Playwright not found. Install: pnpm add -D playwright && pnpm exec playwright install chromium')
process.exit(2)
}
const { chromium } = pw.default ?? pw
// Non-Google vendors have no Consent Mode → ANY request before consent is a violation.
const PIXELS = [
['Meta Pixel', /connect\.facebook\.net|facebook\.com\/tr/],
['Microsoft Clarity', /clarity\.ms/],
['LinkedIn Insight', /snap\.licdn\.com|px\.ads\.linkedin\.com/],
['TikTok Pixel', /analytics\.tiktok\.com/],
['DoubleClick / Google Ads', /doubleclick\.net|googleadservices\.com/],
['Hotjar', /hotjar\.com/],
]
// Embeds that set cookies — should wait for consent or use a privacy mode.
const EMBEDS = [
['YouTube (cookie mode)', /youtube\.com\/embed/],
['Google Maps embed', /google\.com\/maps\/embed/],
]
// Requests to Google before any choice that are not tracking tags: a warning (the visitor's IP reaches Google).
const THIRD_PARTY_ASSETS = [
['YouTube thumbnail (i.ytimg.com) — upload a poster', /i\.ytimg\.com/],
['Google Fonts — self-host (next/font)', /fonts\.googleapis\.com|fonts\.gstatic\.com/],
['Google Maps API', /maps\.googleapis\.com/],
]
const GOOGLE_COLLECT = /google-analytics\.com\/(g\/)?collect|analytics\.google\.com\/g\/collect/
const GOOGLE_TAG = /googletagmanager\.com\/(gtm|gtag)/
const TRACKING_COOKIES = /^(_ga|_gid|_gat|_gcl_|_fbp|_fbc|_clck|_clsk|_ttp|li_|lidc|bcookie|_hj)/
// gcs=G1{ad}{analytics}: '1' = granted. Before consent both must not be '1'.
const consentGranted = (u) => {
const gcs = new URL(u).searchParams.get('gcs')
return gcs ? /^G1.?1|^G11/.test(gcs) : null
}
const browser = await chromium.launch()
/** Computed look of the banner's accept / reject buttons and the banner surface (run 1). */
const buttonLook = (page) => page.evaluate(() => {
const props = ['fontSize', 'fontWeight', 'paddingTop', 'paddingLeft', 'borderTopLeftRadius', 'height', 'backgroundColor', 'color', 'borderTopColor', 'borderTopWidth']
const pick = (el) => {
if (!el) return null
const cs = getComputedStyle(el)
const out = { tag: el.tagName }
for (const p of props) out[p] = p === 'height' ? String(Math.round(el.getBoundingClientRect().height)) : cs[p]
return out
}
const banner = document.querySelector('[data-ipal="banner"]')
return { accept: pick(document.querySelector('[data-ipal="banner"] [data-ipal="accept"]')), reject: pick(document.querySelector('[data-ipal="banner"] [data-ipal="reject"]')), surface: banner ? getComputedStyle(banner).backgroundColor : null }
})
const run = async (label, action, { gpc = false, withdraw = false } = {}) => {
const ctx = await browser.newContext(gpc ? { extraHTTPHeaders: { 'Sec-GPC': '1' } } : {})
if (gpc) await ctx.addInitScript(() => Object.defineProperty(Navigator.prototype, 'globalPrivacyControl', { configurable: true, get: () => true }))
const page = await ctx.newPage()
const requests = []
page.on('request', (r) => requests.push(r.url()))
try {
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 })
} catch (e) {
console.error(`iapl-consent-check: cannot open ${url} (${e.message.split('\n')[0]})`)
const gpcRun = await run('4. Global Privacy Control')
if (gpcRun.bannerVisible) warnings.push('4. Global Privacy Control: the banner is shown (gpc="ask", gpc={false} or IAPL before 1.17.0) — the default honours the signal without a banner')
inspect(gpcRun, true)
if (gpcRun.requests.some((u) => GOOGLE_TAG.test(u) || GOOGLE_COLLECT.test(u))) violations.push('4. Global Privacy Control: the Google tag loaded although the browser asks not to share data and nothing was granted')
const withdrawn = await run('5. accept, then withdraw', 'accept', { withdraw: true })
if (withdrawn.withdrawn?.missing) warnings.push('5. withdraw: no [data-ipal="cookie-button"] to reopen the settings — is <CookieButton/> rendered?')
else if (withdrawn.withdrawn) {
const left = withdrawn.withdrawn.after.filter((c) => TRACKING_COOKIES.test(c))
for (const c of left) violations.push(`5. withdraw: tracking cookie "${c}" still set after "Reject" (add it to <ConsentProvider cookieMap> or the panel's cookie list)`)
}
await browser.close()
process.exit(2)
}
await page.waitForTimeout(WAIT)
await page.mouse.wheel(0, 2000) // some tags wait for interaction (Analytics defer)
await page.waitForTimeout(500)
const banner = (await page.locator('[data-ipal="banner"]').count()) > 0
const bannerVisible = banner && (await page.locator('[data-ipal="banner"]').first().isVisible())
const look = action ? null : await buttonLook(page)
let clicked = null
if (action) {
const btn = page.locator(`[data-ipal="${action}"]`)
if ((await btn.count()) > 0) {
const before = requests.length
await btn.first().click()
await page.waitForTimeout(WAIT)
clicked = before
if (action === 'reject') {
await page.reload({ waitUntil: 'domcontentloaded' })
await page.waitForTimeout(WAIT)
}
} else clicked = -1
}
let withdrawn = null
if (withdraw && clicked !== -1) {
const before = (await ctx.cookies()).map((c) => c.name)
const reopen = page.locator('[data-ipal="cookie-button"]')
if ((await reopen.count()) > 0) {
await reopen.first().click()
await page.locator('[data-ipal="banner"] [data-ipal="reject"]').first().click()
await page.waitForTimeout(1000)
withdrawn = { after: (await ctx.cookies()).map((c) => c.name), before }
} else withdrawn = { missing: true }
}
const cookies = (await ctx.cookies()).map((c) => c.name)
await ctx.close()
return { label, requests, cookies, banner, bannerVisible, clicked, look, withdrawn }
}
/** WCAG contrast of two computed colours (rgb/rgba strings); null when one is transparent. */
const rgb = (c) => { const m = /rgba?\(([^)]+)\)/.exec(c ?? ''); if (!m) return null; const p = m[1].split(',').map(Number); return p.length > 3 && p[3] === 0 ? null : p.slice(0, 3) }
const lum = ([r, g, b]) => { const f = (v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4 }; return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b) }
const contrast = (a, b) => { const x = rgb(a), y = rgb(b); if (!x || !y) return null; const [l1, l2] = [lum(x), lum(y)].sort((m, n) => n - m); return (l1 + 0.05) / (l2 + 0.05) }
const violations = []
const warnings = []
const info = []
const inspect = (r, mustBeQuiet) => {
const pixelHits = PIXELS.filter(([, re]) => r.requests.some((u) => re.test(u))).map(([n]) => n)
const embedHits = EMBEDS.filter(([, re]) => r.requests.some((u) => re.test(u))).map(([n]) => n)
const trackingCookies = r.cookies.filter((c) => TRACKING_COOKIES.test(c))
const collects = r.requests.filter((u) => GOOGLE_COLLECT.test(u))
const grantedCollects = collects.filter((u) => consentGranted(u) === true)
if (mustBeQuiet) {
for (const p of pixelHits) violations.push(`${r.label}: ${p} loaded without consent`)
for (const c of trackingCookies) violations.push(`${r.label}: tracking cookie "${c}" set without consent`)
if (grantedCollects.length) violations.push(`${r.label}: Google Analytics hit with consent GRANTED (gcs) before a decision`)
const noSignal = collects.filter((u) => consentGranted(u) === null)
if (noSignal.length) warnings.push(`${r.label}: Google Analytics hit without Consent Mode signal (gcs) — setDefaultConsent must run before the tag`)
for (const e of embedHits) warnings.push(`${r.label}: ${e} loaded before consent — gate it (ConsentScript) or use youtube-nocookie / click-to-load`)
for (const [n, re] of THIRD_PARTY_ASSETS) if (r.requests.some((u) => re.test(u))) warnings.push(`${r.label}: ${n} — a request to Google before any choice`)
}
return { pixelHits, trackingCookies, google: r.requests.some((u) => GOOGLE_TAG.test(u) || GOOGLE_COLLECT.test(u)) }
}
const first = await run('1. no decision')
if (!first.banner) warnings.push('1. no decision: cookie banner [data-ipal="banner"] not found — is <CookieBanner/> rendered? Older IAPL versions lack data-ipal attributes on buttons.')
const s1 = inspect(first, true)
// Equal prominence (docs/consent-behaviour-spec.md §5): same element and size; same look, or "Reject" no weaker.
if (first.look?.accept && !first.look.reject) violations.push('1. no decision: no "Reject" button on the first layer')
else if (first.look?.accept && first.look.reject) {
const { accept: a, reject: j, surface } = first.look
const size = ['tag', 'fontSize', 'fontWeight', 'paddingTop', 'paddingLeft', 'borderTopLeftRadius', 'height'].filter((p) => a[p] !== j[p])
if (size.length) violations.push(`1. no decision: "Reject" is not as prominent as "Accept all" (differs in ${size.join(', ')})`)
const colours = ['backgroundColor', 'color', 'borderTopColor', 'borderTopWidth'].filter((p) => a[p] !== j[p])
if (colours.length) {
const textJ = contrast(j.color, rgb(j.backgroundColor) ? j.backgroundColor : surface)
const edge = (b) => contrast(rgb(b.backgroundColor) ? b.backgroundColor : b.borderTopColor, surface) ?? 1
if ((textJ !== null && textJ < 4.5) || edge(j) < edge(a)) violations.push(`1. no decision: "Reject" looks weaker than "Accept all" (${colours.join(', ')} differ and its contrast is lower)`)
}
}
const accepted = await run('2. accept all', 'accept')
if (accepted.clicked === -1) warnings.push('2. accept: button [data-ipal="accept"] not found — skipped')
const afterAccept = { ...accepted, requests: accepted.clicked > 0 ? accepted.requests.slice(accepted.clicked) : accepted.requests }
const s2 = inspect(afterAccept, false)
if (!accepted.cookies.includes('cookie-consent') && accepted.clicked >= 0) warnings.push('2. accept: consent cookie "cookie-consent" not stored')
const rejected = await run('3. reject all (+ reload)', 'reject')
if (rejected.clicked === -1) warnings.push('3. reject: button [data-ipal="reject"] not found — skipped')
else inspect({ ...rejected, requests: rejected.requests.slice(rejected.clicked ?? 0) }, true)
const gpcRun = await run('4. Global Privacy Control')
if (gpcRun.bannerVisible) warnings.push('4. Global Privacy Control: the banner is shown (gpc="ask", gpc={false} or IAPL before 1.17.0) — the default honours the signal without a banner')
inspect(gpcRun, true)
if (gpcRun.requests.some((u) => GOOGLE_TAG.test(u) || GOOGLE_COLLECT.test(u))) violations.push('4. Global Privacy Control: the Google tag loaded although the browser asks not to share data and nothing was granted')
const withdrawn = await run('5. accept, then withdraw', 'accept', { withdraw: true })
if (withdrawn.withdrawn?.missing) warnings.push('5. withdraw: no [data-ipal="cookie-button"] to reopen the settings — is <CookieButton/> rendered?')
else if (withdrawn.withdrawn) {
const left = withdrawn.withdrawn.after.filter((c) => TRACKING_COOKIES.test(c))
for (const c of left) violations.push(`5. withdraw: tracking cookie "${c}" still set after "Reject" (add it to <ConsentProvider cookieMap> or the panel's cookie list)`)
}
await browser.close()
info.push(`before consent: Google tag ${s1.google ? 'loaded (Consent Mode, OK if gcs denied)' : 'not loaded'}`)
info.push(`after accept: ${s2.pixelHits.length ? s2.pixelHits.join(', ') : 'no third-party pixels'}${s2.google ? ' + Google' : ''}; cookies: ${accepted.cookies.filter((c) => TRACKING_COOKIES.test(c)).join(', ') || 'none'}`)
console.log(`iapl-consent-check — ${url}`)
for (const v of violations) console.log(`[ERROR] ${v}`)
for (const w of warnings) console.log(`[WARNING] ${w}`)
for (const i of info) console.log(` · ${i}`)
console.log(`iapl-consent-check: ${violations.length} violation(s), ${warnings.length} warning(s)`)
process.exit(violations.length ? 1 : 0)
@@ -1,5 +1,5 @@
#!/usr/bin/env node
// ipal cookie-scan — lists every cookie (and localStorage key) a running site sets, for the cookie policy.
// IAPL cookie-scan — lists every cookie (and localStorage key) a running site sets, for the cookie policy.
// node cookie-scan.mjs <baseUrl> [--pages 10] [--lang pl|en] [--out cookie-scan] [--wait 3000]
// Two fresh browser profiles: before any decision, and after "Accept all" (data-ipal="accept").
// Pages: the base URL + up to --pages URLs from /sitemap.xml.
@@ -174,5 +174,5 @@ if (unknown.length) {
}
if (after.storage.length) {console.log(`\nlocalStorage keys (mention in the policy if they hold personal data): ${after.storage.join(', ')}`)}
console.log(`\n${cookies.length} cookie(s) → ${path.join(OUT, 'cookies.json')}, ${path.join(OUT, 'cookies.md')}`)
console.log(`Import into the panel: LOCALE=${LANG} pnpm payload run .agents/skills/ipal-consent-check/scripts/import-cookies.ts ${path.join(OUT, 'cookies.json')}`)
console.log(`Import into the panel: LOCALE=${LANG} pnpm payload run .agents/skills/iapl-consent-check/scripts/import-cookies.ts ${path.join(OUT, 'cookies.json')}`)
process.exit(errors ? 1 : 0)
@@ -3,7 +3,7 @@
* cookie policy page (<CookieTable>) and the detailed consent window
* (<CookieBanner settings="detailed">) list what the site really sets.
*
* LOCALE=pl pnpm payload run .agents/skills/ipal-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
* LOCALE=pl pnpm payload run .agents/skills/iapl-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
* # second language: scan again with --lang en, then import with LOCALE=en
* # (rows are matched by cookie name; only purpose/duration are localized)
*

Some files were not shown because too many files have changed in this diff Show More