diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a458929..98dbcd9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,8 +12,10 @@ 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`), then Postgres (nothing to do). -> No schema or migration on any database. +> 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 @@ -54,6 +56,15 @@ once there are more than 20. > `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 error). +> > **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". @@ -190,6 +201,33 @@ once there are more than 20. 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**: 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` (error). 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" | `` | + | 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) | `` (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 @@ -237,6 +275,23 @@ once there are more than 20. 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). `` 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 `` 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, @@ -274,6 +329,29 @@ once there are more than 20. 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`: error) 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. `` 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 diff --git a/docs/README.md b/docs/README.md index 71265b6..112467a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -24,7 +24,8 @@ 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) | diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index fb34444..22450ce 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -246,7 +246,7 @@ site), **P** = a test in the panel. Full code: PROGRAMISTA.md §2. | 9 | **Media / R2 / speed** | `Media` with `focalPoint`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` + field; **always** `buildR2Storage(['media'], { s3Storage })` + `@payloadcms/storage-s3`; `R2_*` in `.env.example`; ``; `images: buildImagesConfig()` and `buildUploadSecurityHeaders()` in `next.config.ts`; the project's `` via `mediaImageProps`/`videoProps` (§6.11b) | `buildR2Storage`, `mediaImageProps`, `videoProps`, `buildImagesConfig` | A, S | | 10 | **Forms** | every form from a **seed** (`scripts/seed-form-*.ts`: fields, confirmation, mail to the company **and** confirmation to the customer, every language); a block with `` + `formClasses.ts` (look, once); `actions.ts` = `createSubmitAction({ getCachedPayload, headers })`; `forms: {…}` in `iapl`; `email: mailAdapter()` | `RenderForm` (`/rsc`), `createSubmitAction`, `mailAdapter` | A, P | | 11 | **Turnstile** | `` in `[locale]/layout.tsx` (wires `TurnstileProvider` with the key from the panel); `RenderForm` renders the widget; keys in Site integrations | `SiteProviders`, `getTurnstileConfig`, `TurnstileProvider` | A, P | -| 12 | Consent + analytics | Consent Mode: `'advanced'` (default — the Google tag loads at once with every signal `denied`) or `'basic'` (`` — no request to Google before consent; a client who wants zero requests), the choice goes to "Project decisions"; `iapl({ consentLog: true })` (without it the `/api/ipal/consent` endpoint does not exist) + `}>` (ConsentProvider, banner, CookieButton, Analytics in the right order; the banner is in the server HTML and painted with the page — pages stay static, an inline script decides before the first paint; with a nonce CSP pass `nonce` to `SiteProviders`; never wrap the banner in a "mounted" guard or `dynamic(…, { ssr: false })`, never read the consent cookie in the layout unless the site is dynamic anyway: `consentCookie`, consent.md → "First paint"); settings window mode (`settings`: `inline` / `modal` / `detailed`) per the design, brief is silent → `detailed`, the decision goes to "Project decisions"; tool IDs in the panel; the cookie list from a scan (`cookieScanner: true` → *Cookie review* → **Scan cookies** → *Approve cookies* → **Approve and add**; or cookie-scan → import) — feeds `` on the policy page **and** the lists in the `detailed` window; Cookies → Settings window → Cookie list headings in every language | consent.md, analytics.md | A, `iapl-consent-check` | +| 12 | Consent + analytics | Consent Mode: `'advanced'` (default — the Google tag loads at once with every signal `denied`) or `'basic'` (`` — no request to Google before consent; a client who wants zero requests), the choice goes to "Project decisions"; the consent log is on by default since 1.17.0 (`consentLog: false` turns it off; **Postgres / SQLite: `pnpm payload migrate:create consent-log` and apply it in the same deploy**, doctor `consent-log-migration`) + `}>` (posts every decision to the log by itself; "Reject" is as prominent as "Accept all" by default — `equalChoice`; Global Privacy Control honoured by default — `gpc`, consent.md → "Global Privacy Control"; ConsentProvider, banner, CookieButton, Analytics in the right order; the banner is in the server HTML and painted with the page — pages stay static, an inline script decides before the first paint; with a nonce CSP pass `nonce` to `SiteProviders`; never wrap the banner in a "mounted" guard or `dynamic(…, { ssr: false })`, never read the consent cookie in the layout unless the site is dynamic anyway: `consentCookie`, consent.md → "First paint"); settings window mode (`settings`: `inline` / `modal` / `detailed`) per the design, brief is silent → `detailed`, the decision goes to "Project decisions"; tool IDs in the panel; the cookie list from a scan (`cookieScanner: true` → *Cookie review* → **Scan cookies** → *Approve cookies* → **Approve and add**; or cookie-scan → import) — feeds `` on the policy page **and** the lists in the `detailed` window; Cookies → Settings window → Cookie list headings in every language | consent.md, analytics.md | A, `iapl-consent-check` | | 13 | Security | `buildSecurityHeaders` in `next.config.ts`; `withSecurityConfig(withPayload(nextConfig))` — this order (no `X-Powered-By`; Payload's colour-scheme client hints for `/admin` only, check: `curl -sI localhost:3000/pl \| grep -i critical-ch` → nothing); CSP: `buildSecurityHeaders({ csp: { mode: 'report-only', reportUri: '/api/csp-report', … } })` + `buildAdminCspHeaders` on `/admin/:path*` + `src/app/api/csp-report/route.ts` (`createCspReportRoute`) → read the reports → `mode: 'enforce'`; `twoFactor: { issuer, plugin: payloadTotp }` + `generate:importmap` (`TotpRedirectProvider`, `SafeTotpView`; check: a new admin lands on `/admin/setup-totp?back=%2Fadmin` with the QR, no reloading; a login with the password only gets `403` from `/api/globals/site-integrations` and `/api/form-submissions` — security.md "What the second factor covers"); own endpoints: `secondFactorPassed(req)` / `userMeetsRole(req, role)`; **an account without 2FA can only set it up** (`twoFactor.requireSetup`, default: nothing else answers, 72 h from creation or an admin's reset, then blocked until an admin chooses "Reopen setup" on the account) — so set 2FA up right after creating an account; `iapl-doctor --url` must report 0 accounts without 2FA; Postgres/SQLite: migration for `totpSetupFrom`; `IAPL_IP_HEADER` in production | security.md, forms.md | A | | 14 | Operations | `src/app/api/health/route.ts` (`healthRoute`); `src/instrumentation.ts` with `assertEnv(iaplEnvRules({ storage: true, ipHeader: true }))`; staging with `IAPL_NOINDEX=1`; smoke tests (§8a) | `healthRoute`, `assertEnv`, `iaplEnvRules` | A | | 15 | System pages | Site settings → System pages: homepage, 404, privacy policy, cookies; legal links in the footer by role (`getSystemLinks(locale)`) | `getSystemLinks`, `getSystemPagePath`, `getNotFoundPage` | P | @@ -1149,7 +1149,7 @@ project → **plugin gap**, not a copy. | R2, file names, optimization, preview | `buildR2Storage`, `normalizeFilenameHook`, `buildOptimizeUploadHook`, `buildMediaPlaceholderHook` | storage.md | | Image / video in `` | `mediaImageProps`, `videoProps`, `MEDIA_SIZES` | storage.md | | Enlarge an image (card, gallery, product, rich text) | `` + `` (`/client`), `RenderRichText lightbox`, `useLightbox`; labels: `iapl({ lightbox: true })` → Form messages → Image viewer | lightbox.md | -| YouTube without cookies before a click | `` (`/client`) | storage.md | +| YouTube without cookies before a click | `` (`/client`) — always pass an uploaded poster (without it the thumbnail comes from Google before any choice; a development warning says so) | storage.md | | `next.config` | `buildImagesConfig`, `buildSecurityHeaders` (`csp`), `buildCsp`, `buildCspHeaders`, `buildAdminCsp` / `buildAdminCspHeaders`, `buildUploadSecurityHeaders`, `withSecurityConfig` (the OUTER wrapper: hides `X-Powered-By`, keeps Payload's `Accept-CH` / `Critical-CH` / `Vary` colour-scheme hints on the admin only; `adminClientHints: { route, sources } \| false`), `scopeColorSchemeClientHints`, `adminClientHintSources`, `COLOR_SCHEME_CLIENT_HINT` | storage.md, security.md | | CSP reports, nonces | `createCspReportRoute` (`parseCspReports`, type `CspViolation`), `createProxy({ csp })` + `` (dynamic pages only), `createCspNonce`, `CSP_NONCE_HEADER`, `buildReportingEndpoints`, `cspHeaderKey`, `DEFAULT_CSP_REPORT_GROUP`; types `BuildAdminCspArgs`, `CspDirective`, `CspSources`, `CreateCspReportRouteArgs`, `WithSecurityConfigOptions` | security.md | | Fluid typography and spacing | `fluid.css` / `fluid-wide.css` (`--ipal-*` variables); your own sizes: `fluidClamp`, `FLUID_SCALE`, `FLUID_RANGES` | design-tokens.md | @@ -1160,6 +1160,7 @@ project → **plugin gap**, not a copy. | Need | Use | Doc | |---|---|---| | Banner, settings, cookie button | `}>`, `CookieButton`, `useConsent` | consent.md | +| Compliance defaults (1.17.0): Global Privacy Control honoured (no banner, no tracker request, opt-in from the cookie button wins), "Reject" like "Accept all", consent log on, withdrawal tells Meta / TikTok / Clarity and clears listed storage keys | built in; opt-outs: `SiteProviders gpc="ask"` / `gpc={false}`, `CookieBanner equalChoice={false}`, `iapl({ consentLog: false })` / `logEndpoint={false}`, `maxAgeDays` (re-ask, default 180); building blocks `resolveConsent`, `gpcFromHeaders`, `gpcFromNavigator`, `GPC_CATEGORIES`, `GPC_HEADER`, `CONSENT_LOG_PATH`, `gpcWellKnown` (`/.well-known/gpc.json`), `readEffectiveConsent`, `signalVendors`, `clarityConsent` (`/client`). Check: `iapl-consent-check` (5 runs incl. GPC, equal prominence, withdrawal), `iapl-doctor` (`consent-banner`, `consent-log-migration`) | consent.md → "Compliance defaults", consent-behaviour-spec.md | | Banner at first paint (not after hydration; LCP) | built in: `CookieBanner firstPaint` (default on), `SiteProviders nonce` under a nonce CSP; off: `firstPaint={false}`; server-exact HTML on a dynamic site: `SiteProviders consentCookie` / `ConsentProvider cookieValue`; your own banner: `consentBannerScript`. Check: `curl -s \| grep -c 'data-ipal="banner-script"'` → 1 and the response still has `s-maxage` | consent.md → "First paint" | | Settings window: in the bar / small / large with cookie details | `` — do not build your own window or cookie list | consent.md → "Large window with details" | | A consent-dependent script | `ConsentScript` | consent.md | @@ -1210,7 +1211,10 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both | Text written in one language fills the empty languages (cookie list, cookie review), never over a language's own text | `fillEmptyLocales: false` | `fillEmptyLocales: { 'cookie-settings': [...], 'cookie-review': [...] }`; `buildFillEmptyLocalesGlobalHook` / `…CollectionHook` for your own globals and collections | | Cookie approval: one summary + **Approve and add** (editor+), unknown cookies approved as `marketing` + "Needs description", dashboard reminder while cookies wait; nothing reaches the cookie banner before approval | `cookieScanner.approval: false` (per-entry review) | `approval.unknownCategory`, `approval.dashboard: false`; building blocks `approveCookies`, `loadCookieApproval`, `countPendingCookies`, `flagGoneEntries`, `sameCookie` | | Cookie review: scan + review editor+, delete admin; Open Cookie Database "Functional" → `functional` | omit `cookieScanner` | `cookieScanner.access`, `collectionOverrides`, `databaseCategories`, `integrations`, `declarations`, `labels`, `syncAccepted: false`; building blocks `runCookieScan`, `collectCookieFindings`, `applyCookieFindings` | -| Consent records / stats visits: read and delete admin (stats view and chart follow `stats-visits` read access) | omit `consentLog` / `stats` | `consentLog.collectionOverrides`, `stats.collectionOverrides` (object merges `access`/`admin`/`hooks`, function takes over; `applyCollectionOverride`) | +| Consent log on (since 1.17.0; Postgres / SQLite: a migration in the same deploy) | `consentLog: false`; one layout: `logEndpoint={false}` | `consentLog: { retentionDays, collectionOverrides }`; `buildConsentLogCollection` / `buildConsentLogEndpoint`, `CONSENT_LOG_PATH` | +| Global Privacy Control honoured: no banner, analytics and marketing off, no Google request also in Consent Mode `advanced`; a grant made without the signal is switched off when it appears | `gpc={false}` (doctor warns) | `gpc="ask"`; `resolveConsent`, `gpcFromHeaders`, `consentBannerScript({ gpc })` | +| "Reject" styled like "Accept all" (`equalChoice`) | `equalChoice={false}` (doctor warns) | `classNames.rejectButton` | +| Consent records / stats visits: read and delete admin (stats view and chart follow `stats-visits` read access) | `consentLog: false` / omit `stats` | `consentLog.collectionOverrides`, `stats.collectionOverrides` (object merges `access`/`admin`/`hooks`, function takes over; `applyCollectionOverride`) | | Injected `users`: admin manages everyone, others only themselves | — | `access.authAccess` (your keys win); your own `users` collection wins whole | | First registered account = admin | `access.firstUserAdmin: false` | `buildRolesField(defaultRole, { firstUserAdmin })` | | 2FA on the panel's login collection, mismatch = startup error; redirect to the 2FA screens by `TotpRedirectProvider` | `twoFactor: false` (discouraged) | `twoFactor.collectionSlug`, `allowCollectionMismatch: true`, `twoFactor.provider` (own component, or `false` for the package's) | diff --git a/docs/agent/skills/iapl-consent-check/SKILL.md b/docs/agent/skills/iapl-consent-check/SKILL.md index 9ba0caf..ee351d6 100644 --- a/docs/agent/skills/iapl-consent-check/SKILL.md +++ b/docs/agent/skills/iapl-consent-check/SKILL.md @@ -1,6 +1,6 @@ --- 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". 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. +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. --- # iapl-consent-check @@ -22,8 +22,9 @@ before analytics or marketing consent — check the project's choice in "Project 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,6 +32,11 @@ 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 — `` must be inside `` (`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; `` 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 `` | +| YouTube thumbnail / Google Fonts / Maps API before a choice (warning) | `` 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 diff --git a/docs/agent/skills/iapl-consent-check/scripts/consent-check.mjs b/docs/agent/skills/iapl-consent-check/scripts/consent-check.mjs index c2b5364..f85a9a7 100644 --- a/docs/agent/skills/iapl-consent-check/scripts/consent-check.mjs +++ b/docs/agent/skills/iapl-consent-check/scripts/consent-check.mjs @@ -1,10 +1,14 @@ #!/usr/bin/env node // iapl-consent-check — proves in a real browser that tracking waits for consent (GDPR). // node consent-check.mjs [--wait 4000] -// Three runs, each in a fresh browser profile: -// 1. no decision → no third-party pixels, no tracking cookies, Google only with "denied" signals +// 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. @@ -41,6 +45,12 @@ 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)/ @@ -52,8 +62,22 @@ const consentGranted = (u) => { } const browser = await chromium.launch() -const run = async (label, action) => { - const ctx = await browser.newContext() +/** 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())) @@ -61,13 +85,27 @@ const run = async (label, action) => { await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 }) } catch (e) { console.error(`iapl-consent-check: cannot open ${url} (${e.message.split('\n')[0]})`) - await browser.close() + 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 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 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}"]`) @@ -82,11 +120,27 @@ const run = async (label, action) => { } } 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, clicked } + 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 = [] @@ -103,6 +157,7 @@ const inspect = (r, mustBeQuiet) => { 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)) } } @@ -110,6 +165,19 @@ const inspect = (r, mustBeQuiet) => { const first = await run('1. no decision') if (!first.banner) warnings.push('1. no decision: cookie banner [data-ipal="banner"] not found — is 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') @@ -121,6 +189,18 @@ 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 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 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'}`) diff --git a/docs/agent/skills/iapl-reference/SKILL.md b/docs/agent/skills/iapl-reference/SKILL.md index 11ab28a..6351c4b 100644 --- a/docs/agent/skills/iapl-reference/SKILL.md +++ b/docs/agent/skills/iapl-reference/SKILL.md @@ -91,7 +91,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia | `forms.turnstileOnConfigError` | `{ text: 'allow', files: 'reject' }` | what a form does while Turnstile CANNOT check (wrong / missing secret, Cloudflare down): a text form is accepted, a submission to the file endpoint is refused. Not involved while Turnstile is off | `'allow'` / `'reject'` for every form, or `{ text, files }`; `turnstileOnConfigError` at a call site (`createSubmitAction`, `attachments.submit`) wins | | `forms.attachments` | off | **File** field in the form builder; a file is checked (size, count, type by content, refused extensions), attached to the company e-mail and dropped — **never stored**; adds `POST /api/ipal/forms/submit`, the fields `submissionFiles` / `filesDelivery` / `filesDeliveryNote` / `attemptKey` on `form-submissions`, and the **Files** texts in Form messages | `true` / `FormAttachmentsOption`: `maxSizeMB` (10), `maxTotalMB`, `maxFiles` (3), `fileTypes`, `allowRisky`, `scan` (antivirus hook — none built in), `strictPdf`, `notice`, `maxConcurrent` (2), `path`, `submit` (`maxPerMinute`, `clientIp`, `honeypotField`, `turnstileHostnames`, `turnstileOnConfigError`, `allowedOrigins`, `idleTimeoutMs`, `timeoutMs`); block only: `forms.fields.file: false` or `buildFileBlock(…)`. Postgres: `migrate:create`. Check: submit a PDF → attached to the company e-mail, absent from the customer e-mail, submission shows *File delivery: Handed to the mail server* (forms.md "Files") | | `forms.consentFieldName` | `'consent'` | name of the GDPR consent field `submitForm` requires (read from `config.custom.ipal`) | `createSubmitAction({ consentFieldName })` / `submitForm` argument wins | -| `consentLog` | off | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min) | `true` / `{ retentionDays }` (default 1095) | +| `consentLog` | **on** (since 1.17.0) | `consent-records` collection + `POST /api/ipal/consent` (rate limit 20/min); Postgres / SQLite: a table, migration in the same deploy | `false` / `{ retentionDays }` (default 1095) | | `consentLog.collectionOverrides` | none | changes `consent-records`: an object merges `access` / `admin` / `hooks` key by key (your keys win), a function `(collection) => collection` takes over (keep the slug) | e.g. `{ access: { read: ({ req }) => req.user?.email === 'dpo@acme.pl' } }` — narrows who reads records in a project without roles | | `doctor` | on (404 until `IAPL_DOCTOR_TOKEN` is set) | `GET /api/ipal/doctor` — read-only counts for `iapl-doctor --url` (users without TOTP, cookies waiting for approval, versions); Bearer token ≥ 32 characters, rate-limited, never names or values | `false` = no endpoint; `{ tokenVar, access }` (doctor.md) | | `cookieScanner` | off | `cookie-review` collection, "Scan cookies" box above its list (`CookieScanButton`), `GET`/`POST /api/ipal/cookie-scan`, and (unless `approval: false`) the *Approve cookies* view `/admin/cookie-approval` (`CookieApprovalView`) + `GET`/`POST /api/ipal/cookie-approval` + the dashboard reminder; a scan lists the cookies of the integrations switched on + names looked up in the bundled Open Cookie Database; one **Approve and add** puts the ticked cookies into Cookies → Cookie list (so `` and the detailed window); never deletes, never overwrites edited text, never duplicates, nothing reaches the banner before approval | `true` / object; after switching on: `pnpm generate:importmap` + `migrate:create`. Check: *Privacy → Cookie review* → **Scan cookies** → "Waiting for approval: N" → **Review and approve** → **Approve and add** → the cookies are in Cookies → Cookie list (cookie-scanner.md) | @@ -123,7 +123,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia |---|---|---|---| | auth collection (`users`) | `{ slug, auth: true, useAsTitle: 'email' }`, when the project has none (slug: `access.authCollection` → `twoFactor.collectionSlug` → `admin.user` → `'users'`); with `access`: create/delete/unlock admin only, read/update admin or self | `access.authAccess`; your own collection with that slug | yours wins | | `forms`, `form-submissions` | form-builder + IAPL blocks `step`, `checkboxGroup`, `time` | `forms` | omit `forms` | -| `consent-records` | proof of consent (id, choices, policy version; `consentLog.collectionOverrides`) | `consentLog` | off by default | +| `consent-records` | proof of consent (id, choices, policy version; `consentLog.collectionOverrides`) | `consentLog` | on by default (1.17.0) | | global `cookie-crawl` | latest browser crawl (status, counts, violations, third-party hosts) + e-mail recipients; read editor+, update admin | `cookieScanner.crawl` (`globalOverride`) | off by default | | `cookie-review` | cookie scanner entries (`status` draft / accepted / rejected, `change` new / changed / gone, `needsDescription`; create/read/update editor+, delete admin) | `cookieScanner` | off by default | | view `/admin/cookie-approval` | *Approve cookies*: everything waiting, grouped by category, one **Approve and add** | `cookieScanner.approval` | `approval: false` | @@ -135,7 +135,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia | global revalidation hook | `afterChange` on the four globals → `revalidatePath('/', 'layout')` | `revalidatePath` | omit `revalidatePath` | | `POST /api/ipal/test-email` | SMTP/Graph test (admin only); body `{ to, attachmentMB? }` — `attachmentMB` attaches a dummy file to measure the mail server's size limit | — | **currently always** | | `POST /api/ipal/forms/submit` | a panel form **with files** posts here (multipart, read as a stream; same gates as `sendForm`); same-origin only | `forms.attachments` (`path`, `submit`) | off by default | -| `POST /api/ipal/consent` | saves consent | `consentLog` | off by default | +| `POST /api/ipal/consent` | saves consent (`503` while the SQL table is missing) | `consentLog` | on by default (1.17.0) | | `POST /api/ipal/hit` | page view for stats | `stats` | off by default | | `GET`/`POST /api/ipal/cookie-crawl`, `POST /api/ipal/cookie-crawl/results` | crawl status / start (editor+ or bearer token) / the scanner service's callback (token, running job only) | `cookieScanner.crawl` | off by default | | `GET`/`POST /api/ipal/cookie-approval` | the approval list (`?locale=`) / approve (`{ ids? }`), editor+ | `cookieScanner.approval` (`access`) | `approval: false` | @@ -208,7 +208,8 @@ Mandatory set: AGENT.md §0b, skill **iapl-setup**; checks: **iapl-audit**, **ia | consent | layout + policy page | banner via `SiteProviders`; table `` (`/rsc`) from `getCookieTable` | `iapl-consent-check`; delete the consent cookie → the banner comes back | consent.md | | cookie crawl | config + env + service | `cookieScanner: { crawl: true }`, `IAPL_COOKIE_SCAN_URL` / `IAPL_COOKIE_SCAN_TOKEN`, site in the service's `IAPL_CRAWLER_SITES`; optional Coolify scheduled task `curl -X POST -H "Authorization: Bearer $IAPL_COOKIE_SCAN_TOKEN" $U/api/ipal/cookie-crawl` | **Check site** → "Last crawl …: N pages, N violations"; *Privacy → Cookie check* | cookie-scanner.md → Browser crawl | | cookie list | config | `cookieScanner: true` (+ `declarations` for embeds/chat), `generate:importmap`, `migrate:create` | *Cookie review* → **Scan cookies** → **Review and approve** → **Approve and add** → Cookies → Cookie list; `` and `` list it | cookie-scanner.md | -| proof of consent | config + layout | `consentLog: true` + `logEndpoint="/api/ipal/consent"` | after a click, a document in Consent Records | consent.md | +| proof of consent | nothing (on by default); Postgres / SQLite: `migrate:create consent-log` | `SiteProviders` posts by itself; a hand-wired `ConsentProvider` needs `logEndpoint="/api/ipal/consent"` | after a click, a document in Consent Records | consent.md | +| Global Privacy Control | nothing (on by default) | `gpc="ask"` / `gpc={false}` on `SiteProviders` | a browser with GPC: no banner, cookie button, no tracker request; `iapl-consent-check` run 4 | consent.md → Global Privacy Control | | stats | config + layout | `stats: true` + `` (or `` inside `ConsentProvider`); on a site with `storageNames: 'iapl'` also `visitorCookie: IAPL_VISITOR_COOKIE` (``) — `iapl-doctor` rule `storage-names` | `//stats`; `POST /api/ipal/hit` request in Network | stats.md | | analytics | layout | `SiteProviders` wires `Analytics` (ID from Site integrations → Analytics); Consent Mode: `analytics={{ consentMode: 'basic' }}` = no request to Google before consent, default `'advanced'` = the Google tag loads at once with every signal `denied` | Meta/other pixels only after consent; in `basic` no `gtm.js` / `gtag/js` in Network before consent | analytics.md, gtm-meta-pixel.md | | extra JSON-LD | layout / `lib/content` | `jsonLd={[buildNavigationJsonLd(…)]}`; `siteJsonLd` → `buildLocalBusinessJsonLd` | Rich Results Test | seo.md | diff --git a/docs/agent/skills/iapl-reference/resources/api.md b/docs/agent/skills/iapl-reference/resources/api.md index f5f5429..af0d6f4 100644 --- a/docs/agent/skills/iapl-reference/resources/api.md +++ b/docs/agent/skills/iapl-reference/resources/api.md @@ -161,15 +161,15 @@ Fifteen ready blocks and ten page templates. **Use a library block (or a variant | Export | Import from | What it does / when | |---|---|---| -| `ConsentProvider` | `@intecion/ipal-kit/client` | Consent provider: `{ texts, cookieMap?, logEndpoint?, nonce?, cookieValue? }` (`nonce`: CSP nonce for the banner's first-paint script; `cookieValue`: optional server-read consent cookie → exact HTML, dynamic pages) — consent state, cookie, Consent Mode, deleting cookies after consent is withdrawn, optional POST of the decision to the log (`'/api/ipal/consent'`). Wrap the layout once; required by the banner, `Analytics`, `ConsentScript`. | +| `ConsentProvider` | `@intecion/ipal-kit/client` | Consent provider: `{ texts, cookieMap?, logEndpoint?, nonce?, cookieValue?, gpc?, maxAgeDays? }` (`gpc`: Global Privacy Control `'honour'` default / `'ask'` / `false`; `maxAgeDays`: re-ask period, default 180; withdrawal also removes the panel's listed storage keys and tells Meta / TikTok / Clarity) (`nonce`: CSP nonce for the banner's first-paint script; `cookieValue`: optional server-read consent cookie → exact HTML, dynamic pages) — consent state, cookie, Consent Mode, deleting cookies after consent is withdrawn, optional POST of the decision to the log (`'/api/ipal/consent'`). Wrap the layout once; required by the banner, `Analytics`, `ConsentScript`. | | `CookieBanner` | `@intecion/ipal-kit/client` | Consent banner + category settings: `settings: 'inline' \| 'modal' \| 'detailed'`, `controls`, `equalChoice` (recommended `true`), `order`, `settingsActions`, `icon`, `classNames`, `firstPaint` (default `true`: in the server HTML, decided before the first paint by an inline script; pages stay static), `nonce`; colours from `--ipal-*` CSS vars. Do not write your own banner. | | `CookieButton` | `@intecion/ipal-kit/client` | Floating button that reopens the cookie settings (withdrawing consent); hidden while the banner is visible. Props `className`, `side` (`'left' \| 'right'`), `avoid` (selector it lifts above, default `COOKIE_BUTTON_AVOID` = footer; `false`). Tokens `--ipal-cookie-button-offset`, `--ipal-cookie-button-inset`. Type `CookieButtonProps`. | | `COOKIE_BUTTON_AVOID`, `bottomOverlap(tops, viewportHeight)` | `@intecion/ipal-kit/client` | Default footer selector; pixels the footer covers at the bottom of the screen (how far the button moves up) | | `TOTP_TEXTS`, `TOTP_VIEW_TITLE` | `@intecion/ipal-kit` | en/pl texts of the 2FA screens (`totpPlugin:*`, merged by `twoFactor`) and their tab title | | `ConsentScript` | `@intecion/ipal-kit/client` | Loads an external script (`src` or `code`) only after consent for `category` — for vendors without Consent Mode (chat, Plausible etc.). Inside `ConsentProvider`. | | `CookieTable` | `@intecion/ipal-kit/rsc` | Server Component: cookie table for the cookie policy page — `{ rows, labels?, locale?, categories?, caption?, classNames?, storageColumn?, storageTypes? }`; `rows` from `getCookieTable()`; a **Type** column when a row is local / session storage (`storageColumn: 'auto' \| boolean`). | -| `useConsent(options?)` | `@intecion/ipal-kit/client` | Low-level consent state hook → `{ state, decided, consentId, hydrated, serverRead, acceptAll, rejectAll, savePreferences, reopen }` (options: `cookieMap`, `version`, `onDecision`, `cookieValue`). Usually use `ConsentProvider` + `useConsentContext` (the provider calls it itself). | -| `consentBannerScript({ version?, cookieName? })` | `@intecion/ipal-kit` | The inline script `CookieBanner` puts after its markup: before the first paint it removes `hidden` from the banner (no current decision) or sets `display: none` (current decision), and keeps a click made before hydration. For a project's own banner; reads only the consent cookie. Options type: `ConsentBannerScriptOptions`. consent.md → "First paint". | +| `useConsent(options?)` | `@intecion/ipal-kit/client` | Low-level consent state hook → `{ state, decided, consentId, gpc, gpcMode, hydrated, serverRead, acceptAll, rejectAll, savePreferences, reopen }` (options: `cookieMap`, `storageMap`, `version`, `onDecision` (gets `{ id, state, version, gpc }`), `cookieValue`, `gpc`, `maxAgeDays`). Usually use `ConsentProvider` + `useConsentContext` (the provider calls it itself). | +| `consentBannerScript({ version?, cookieName?, gpc? })` | `@intecion/ipal-kit` | The inline script `CookieBanner` puts after its markup: before the first paint it removes `hidden` from the banner (no current decision) or sets `display: none` (current decision, or Global Privacy Control honoured with `gpc: 'honour'`, the default), and keeps a click made before hydration. For a project's own banner; reads only the consent cookie. Options type: `ConsentBannerScriptOptions`. consent.md → "First paint". | | `useConsentContext()` | `@intecion/ipal-kit/client` | Hook: the `useConsent` value + `texts` from `ConsentProvider` — for your own consent-dependent UI (e.g. `state.marketing`). Throws outside the provider. | | `getConsentTexts({ payload, config, locale?, privacyPolicy?, settingsSlug? })` | `@intecion/ipal-kit` | Server: banner texts from the CookieSettings global (EN fallback per field) + privacy policy link from the system pages → `Promise`; pass to `ConsentProvider texts`. | | `getCookieTable({ payload, locale? })` | `@intecion/ipal-kit` | Server: Cookies → Cookie list rows in one language → `Promise` (does not throw) — for `CookieTable`. | @@ -186,6 +186,13 @@ Fifteen ready blocks and ten page templates. **Use a library block (or a variant | `ACCEPT_ALL_CONSENT` | `@intecion/ipal-kit` | All categories `true`. | | `REJECT_ALL_CONSENT` | `@intecion/ipal-kit` | Only `necessary: true` (a copy of `DEFAULT_CONSENT`). | | `CONSENT_LOG_SLUG` | `@intecion/ipal-kit` | Consent log collection slug: `'consent-records'`. | +| `CONSENT_LOG_PATH` | `@intecion/ipal-kit` | The consent log endpoint's path under the API route: `'/ipal/consent'` (`/api/ipal/consent`). | +| `resolveConsent(record, signal, mode?)` | `@intecion/ipal-kit` | Pure: what is in effect for a stored record (or `null`), the Global Privacy Control signal and the mode (`'honour'` default / `'ask'` / `false`) → `{ decided, gpc, stale, state }` (type `ResolvedConsent`; mode type `GpcMode`). The table in consent.md → "Global Privacy Control". | +| `gpcFromNavigator()` / `gpcFromHeaders(headers)` | `@intecion/ipal-kit` | The signal: `navigator.globalPrivacyControl === true` (false on the server) / `Sec-GPC: 1` exactly. Read the header only where a response is per visitor (endpoints) — never while rendering a static page. | +| `GPC_CATEGORIES`, `GPC_HEADER` | `@intecion/ipal-kit` | `['analytics', 'marketing']` (what the signal refuses) and `'sec-gpc'`. | +| `gpcWellKnown({ lastUpdate })` | `@intecion/ipal-kit` | Route handler for `/.well-known/gpc.json` (`{ gpc: true, lastUpdate }`): `app/.well-known/gpc.json/route.ts` → `export const GET = gpcWellKnown({ lastUpdate: '2026-11-26' })`. Optional. | +| `readEffectiveConsent(version, gpc?)` | `@intecion/ipal-kit/client` | The stored choice under `version` with Global Privacy Control applied, read live from the cookie and `navigator` (not React state) — for your own tag loader's effects. | +| `signalVendors(prev, next)` / `clarityConsent(state)` | `@intecion/ipal-kit/client` | Tells the running Meta Pixel (`fbq('consent', …)`), TikTok (`ttq.revokeConsent` / `grantConsent`) and Clarity (`consentv2` / `consent false`) about a change; `useConsent` calls it on every decision — for your own banner. `clarityConsent` → Clarity's `{ ad_Storage, analytics_Storage }`. | | `buildConsentLogCollection()` | `@intecion/ipal-kit` | Consent log collection (id, choices, version, time — no IP/personal data; proof of consent under GDPR Art. 7(1)). The plugin wires it itself with `consentLog: true` — do not call. | | `buildConsentLogEndpoint({ retentionDays? })` | `@intecion/ipal-kit` | `POST /api/ipal/consent` endpoint that saves decisions and deletes records older than `retentionDays` (default 1095). The plugin wires it itself with `consentLog` — do not call. | diff --git a/docs/agent/skills/iapl-setup/SKILL.md b/docs/agent/skills/iapl-setup/SKILL.md index 958395a..6e48a13 100644 --- a/docs/agent/skills/iapl-setup/SKILL.md +++ b/docs/agent/skills/iapl-setup/SKILL.md @@ -190,7 +190,8 @@ export default buildConfig({ twoFactor: { issuer: '', plugin: payloadTotp }, whiteLabel: true, indexNow: true, - consentLog: true, // without this there is no POST /api/ipal/consent + // consentLog is on by default (1.17.0): consent-records + POST /api/ipal/consent; `consentLog: false` turns it off. + // Postgres / SQLite: pnpm payload migrate:create consent-log, applied in the same deploy. revalidatePath, // saving a plugin global refreshes the whole site (ISR) }), buildR2Storage(['media'], { s3Storage }), // ALWAYS: R2 with the full R2_* set, local disk without it @@ -419,8 +420,8 @@ export default async function LocaleLayout({ children, params }: Props) { return ( - }> + }>
{children}
{/* Header/Footer — stage 10 */}
@@ -591,7 +592,7 @@ after a choice in the banner a new record in Consent records. **Turn off / override.** Turnstile: both keys empty (panel and env) → no widget and no verification; fail-closed `turnstileOnConfigError: 'reject'`; the Turnstile/SMTP fields in Site integrations currently always. Form look: `formClasses`, unusual ones → `useBuilderForm` (no copy of the engine). Banner: `settings`, `controls`, `order`, -`equalChoice`, `classNames`, tokens; no `consentLog` = no register and no endpoint (then remove `logEndpoint`). +`classNames`, tokens (`equalChoice` is the default since 1.17.0 — never pass `equalChoice={false}`); `consentLog: false` = no register and no endpoint (SiteProviders then posts nothing). Global Privacy Control is honoured by default (`gpc`); leave it. **Consent Mode choice** (record it in "Project decisions"): `'advanced'` (default) — the Google tag loads at once with every signal `denied` (pixels and Clarity only after consent); `'basic'` — ``, no request to `googletagmanager.com` before analytics or marketing consent (a client requiring zero requests to Google). diff --git a/docs/agent/skills/iapl-upgrade/SKILL.md b/docs/agent/skills/iapl-upgrade/SKILL.md index 0a913e8..fcd36b3 100644 --- a/docs/agent/skills/iapl-upgrade/SKILL.md +++ b/docs/agent/skills/iapl-upgrade/SKILL.md @@ -581,6 +581,29 @@ element). Pages stay static; consent, tags, the cookie and the consent log are u **Check:** `curl -s | grep -c 'data-ipal="banner-script"'` → 1; the response still carries `s-maxage`; first visit: the banner is there before the page's scripts have loaded; after a decision and a reload: never shown. +**→ 1.17.0, consent compliance (CHANGELOG 1.17.0 "Consent"; PROGRAMISTA §6, item 78; consent.md → "Compliance defaults") — Postgres / SQLite: a migration; MongoDB: nothing required:** +What a visitor of an existing site sees change: "Reject" looks like "Accept all"; one more sentence in the default +banner text (only where the panel's message is empty); a browser with Global Privacy Control gets no banner and no +tracker request. Every decision is now recorded in *Privacy → Consent records*. +1. **Postgres / SQLite and the project never had `consentLog` on:** the consent log is now on by default and is a new + table. In the same deploy: `pnpm payload migrate:create consent-log`, commit it, apply it at container start + (`prodMigrations` or `pnpm payload migrate && pnpm start`). Or `iapl({ consentLog: false })`. Without either the site + works, but every choice answers 503 and is not recorded (one log line; `iapl-doctor` error `consent-log-migration`). + MongoDB: the collection appears by itself. +2. Every site: `pnpm payload generate:types` adds the `consent-records` collection's types (where it was off) — run it and + commit. No import-map change. +3. Layout: remove `logEndpoint="/api/ipal/consent"` from `` (it is the default now; keeping it is + harmless) and `equalChoice` (the default). A hand-wired `` keeps `logEndpoint`. +4. The project's decisions, only where the owner wants the old behaviour — record each in `AGENTS.md` → "Project + decisions": ``, ``, + `iapl({ consentLog: false })`. Consent Mode stays `advanced` unless the project chose `basic`. +5. Project e2e that clicks "Reject" by its old secondary look, or expects the old banner text, update it. +6. A `` without `poster`: add an uploaded poster (the thumbnail otherwise comes from Google before any + choice; the consent check warns). +**Check:** `pnpm exec iapl-doctor` (no `consent-log-migration`, no `consent-banner` warning you did not decide); +`iapl-consent-check` on the built site — 0 violations, run 4 (Global Privacy Control) shows no banner; after a click on +the banner a document in *Privacy → Consent records*. + **→ 1.17.0, e-mail (the Intecion mail service (IWSN in the panel) is the default transport; Microsoft Graph deprecated; CHANGELOG 1.17.0; PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; read which case the site is:** 1. **Every site:** no schema change, no migration, no import-map change. `pnpm payload generate:types` gives a small diff diff --git a/docs/analytics.md b/docs/analytics.md index 1dd0f71..2164a84 100644 --- a/docs/analytics.md +++ b/docs/analytics.md @@ -8,12 +8,15 @@ according to the consent from the consent module: everything `denied`). Then it depends on `consentMode`: - `'advanced'` (default): the `googletagmanager.com` script loads **right away, also before consent**. With `denied`, Google stores no cookies (`_ga`), but it - can send cookieless pings — this is **not** "zero requests before consent". + sends cookieless pings — this is **not** "zero requests before consent" (what they carry: below). + Exception since 1.17.0: a visitor whose browser sends **Global Privacy Control** gets no Google request until + they grant analytics or marketing ([consent.md](./consent.md#global-privacy-control-1170)). - `'basic'`: **zero requests to Google before consent** — the script waits until the visitor grants analytics or marketing (see "How Consent Mode works" below). - **Others (Meta Pixel, Microsoft Clarity, LinkedIn Insight, TikTok Pixel)** — they have no Consent Mode, so they load **only after consent** for their - category. They react live: click "Accept" → the tag starts without a reload. + category. They react live: click "Accept" → the tag starts without a reload; withdraw → Meta, TikTok and Clarity + are told at once (1.17.0). Clarity also gets its own consent signal (`consentv2`) when it loads. ## Config @@ -136,7 +139,19 @@ no conversion modelling for visitors without consent. The default `advanced` loa with `denied` signals. In both modes the Consent Mode default is set first. The mode is the client's decision — record it in `AGENTS.md` → "Project decisions". -The rule itself is `shouldLoadGoogle({ consentMode, ready, state })` — a pure function (no React, no DOM) +**What `advanced` sends before consent** (Google's documentation): the Google tag script is downloaded from +`googletagmanager.com`, and while the signals are `denied` it sends cookieless pings to Google — the timestamp, +user agent and referrer the browser adds to any request, whether the page or a previous one carried an ad-click id, +the consent state, and a random number per page load. Every request carries the visitor's IP address (Google says +Ads truncates it while `ad_storage` is denied and Analytics does not log it). No cookie is read or written. Google +uses the pings for conversion and behaviour modelling — which needs volume: GA4 about 1,000 events a day with +analytics denied for 7 days, Google Ads 700 ad clicks in 7 days per country — so on a small site the pings often buy +nothing. Under the EDPB's guidelines on the technical scope of ePrivacy art. 5(3) (2/2023) a script that makes the +browser send information is in scope whether or not a cookie is involved; no authority has ruled on Consent Mode by +name. `'basic'` sends nothing before consent. `ads_data_redaction` is set with the default (since 1.17.0). + +The rule itself is `shouldLoadGoogle({ consentMode, ready, state, gpc? })` — a pure function (no React, no DOM; +`gpc`: Global Privacy Control applies, then `advanced` waits like `basic`) exported from `@intecion/ipal-kit/client` and `@intecion/ipal-kit`. Use it for your own Google-dependent code (a Maps embed, a YouTube player with Google Ads), so it follows the same consent rule as ``: @@ -154,11 +169,11 @@ const allowed = shouldLoadGoogle({ consentMode: 'basic', ready: true, state: con 3. Click in the banner → `gtag('consent', 'update', …)` → tags react immediately. Withdrawing consent (true → false) deletes the category's cookies (`_ga*`, `_fbp`, -`_clck`, `_ttp`, … — see [consent.md](./consent.md)) and sends an `update` to -Google, but **non-Google scripts that are already loaded (Meta, Clarity, -LinkedIn, TikTok) stay on the page until reload** — the plugin does not unload -them. The same goes for a Google tag already loaded in `basic` mode — from then -on it is governed by the Consent Mode `update`. +`_clck`, `_ttp`, … — see [consent.md](./consent.md)) and its listed storage keys, sends an `update` to +Google, and tells the non-Google tags already on the page (1.17.0): Meta `fbq('consent', 'revoke')`, TikTok +`ttq.revokeConsent()`, Clarity `clarity('consent', false)`. A script cannot be unloaded; LinkedIn Insight has no +consent call and stops with the next page load. A Google tag already loaded in `basic` mode is governed by the +Consent Mode `update` from then on. Mapping of categories to Google signals: diff --git a/docs/consent-behaviour-spec.md b/docs/consent-behaviour-spec.md new file mode 100644 index 0000000..53e67fd --- /dev/null +++ b/docs/consent-behaviour-spec.md @@ -0,0 +1,154 @@ +# Cookie consent: shared behaviour spec + +Version 1, 2026-11-26. Product-neutral: IAPL (`@intecion/ipal-kit`, Payload CMS) implements it in 1.17.0, IAWL +(WordPress) follows it in its consent stage. A visitor's choice must read the same in both products, and both pass +the same tests (§7). Where the products differ is said in §8. Why each rule exists, and which rules are law, +regulator guidance or vendor policy: [dev/consent-compliance-proposal.md](./dev/consent-compliance-proposal.md). + +"MUST" is a requirement of this spec; "SHOULD" a default a product may let a site change. + +## 1. Page delivery + +1. The public page HTML MUST be the same for every visitor: nothing in it depends on the consent cookie or on a + Global Privacy Control signal. Pages stay cacheable (static, ISR, page cache, CDN). +2. The banner is in that HTML, hidden (`hidden` attribute). A small inline script placed right after it decides + **before the first paint**: show it (no current choice) or keep it hidden (a current choice, or GPC honoured). The + script reads only the consent cookie and `navigator.globalPrivacyControl`, stores nothing, loads nothing. +3. A click on a banner button before the rest of the page's script is live MUST NOT be lost: the inline script notes + it and the full script carries it out. +4. No JavaScript, or a script refused by CSP: the banner stays hidden and nothing tracks (every tag is loaded by + script). +5. The server MUST NOT render differently for `Sec-GPC`. An endpoint whose response is per visitor anyway MAY read it. + A product that ever varies a cacheable response by it sends `Vary: Sec-GPC` or marks the response private. + +## 2. Categories and the record + +| Category | Meaning | Switchable | +|---|---|---| +| `necessary` | needed for the site to work (session, security, the consent cookie itself, a theme or language the visitor chose when declared necessary) | no, always on | +| `functional` | remembers the visitor's settings (e.g. language cookie) | yes, off by default | +| `analytics` | measurement (GA4, Clarity, a statistics visitor id) | yes, off by default | +| `marketing` | advertising and remarketing (Google Ads, Meta, LinkedIn, TikTok) | yes, off by default | + +**Cookie:** name `cookie-consent`; value = the record as JSON, URI-encoded; `Path=/`; `SameSite=Lax`; `Secure` on +HTTPS; host-only (no `Domain`); not `HttpOnly` (the browser script reads it); `Max-Age` 15552000 (180 days) for a +grant and a refusal alike (SHOULD; a site may change the period). + +**Record:** + +```json +{ "gpc": false, "id": "a1b2c3d4e5f6a7b8c9d0e1f2", "state": { "necessary": true, "functional": false, "analytics": true, "marketing": false }, "timestamp": "2026-11-26T10:00:00.000Z", "version": 1 } +``` + +- `id`: 24 lowercase hex characters, random, no personal data; kept across changes of the same visitor's choice. +- `version`: the site's policy version (integer ≥ 1). A record with another version counts as **no choice**. +- `timestamp`: ISO 8601 UTC of the choice. +- `gpc`: was the browser sending Global Privacy Control when the choice was made. Absent in records written before + this spec (IAPL before 1.17.0). +- A reader takes the **first** cookie of that name, ignores unknown fields, treats a non-boolean category as off and + `necessary` as on, and treats an unreadable value as no choice. + +**Consent log entry** (server side, SHOULD be on): `consentId` (= `id`), `version`, `choices` (the four booleans), +creation time. **No IP address, no user agent.** Posted after every choice, fire and forget: a failed post never +blocks or breaks the banner. Records are deleted after a retention period (IAPL: 1095 days). + +## 3. Consent Mode and other tools + +| Google signal | From | +|---|---| +| `ad_storage`, `ad_user_data`, `ad_personalization` | `marketing` | +| `analytics_storage` | `analytics` | +| `functionality_storage`, `personalization_storage` | `functional` | +| `security_storage` | always `granted` | + +1. The Consent Mode `default` (the stored choice with GPC applied, else all `denied`; `wait_for_update: 500`) is the + first `dataLayer` entry, before any Google tag command; `ads_data_redaction: true` is set with it. +2. Every choice pushes `gtag('consent', 'update', …)` at once. +3. Consent Mode **advanced** (SHOULD be the default): the Google tag loads before a choice with every signal denied. + **basic** (option): no request to Google before analytics or marketing is granted. Under GPC (§4) advanced behaves + like basic. +4. Other tools load only after their category is granted: Clarity (analytics), Meta Pixel, LinkedIn Insight, TikTok + Pixel (marketing). Clarity gets `clarity('consentv2', { ad_Storage, analytics_Storage })` when it loads. +5. Withdrawal (a category on → off): delete that category's cookies on this host and every parent domain, and its + listed `localStorage` / `sessionStorage` keys; tell the running tools — `fbq('consent', 'revoke')`, + `ttq.revokeConsent()`, `clarity('consent', false)`; a later grant on the same page sends `grant` / `consentv2`. + Write the record and post it to the log. + +## 4. Global Privacy Control + +The signal: `Sec-GPC: 1` (only the exact value `1`) and `navigator.globalPrivacyControl === true`. It is read as a +refusal of **analytics and marketing** that the visitor did not have to click. `functional` and `necessary` are not +its business. + +Modes (SHOULD default to `honour`): `honour`, `ask`, off. + +| Stored choice | Signal | `honour` | `ask` | +|---|---|---|---| +| none | on | no banner (decided before first paint); the reopen button; analytics, marketing off; **no request to any tracker, Google included**; nothing stored | banner shown with the GPC line; nothing sent to any tracker until a choice | +| `gpc: true` (made with the signal) | on | stands, also a grant | stands | +| `gpc: false` (made without it) granting analytics or marketing | on | both switched off at once without asking: cookies and keys deleted, tools and Google told, record rewritten with `gpc: true`, posted to the log | same | +| no `gpc` field (older record) | on | stands until it expires or the visitor changes it | stands | +| any | off | stands — the absence of the signal is never consent | stands | + +- A choice the visitor makes on the site while the signal is on (settings window, or the banner in `ask`) is + specific and wins; it is stored with `gpc: true`. +- The settings window (and the banner in `ask`) shows one line, e.g. "Your browser sends a Global Privacy Control + signal. Analytics and marketing are off. You can turn them on for this site here." +- Off: the signal is ignored entirely. +- A site MAY publish `/.well-known/gpc.json` = `{ "gpc": true, "lastUpdate": "YYYY-MM-DD" }`. +- Do Not Track is not read. + +## 5. Equal prominence, in testable terms + +On the banner's first layer, at 360×640 and at 1280×800: + +1. "Accept all" and "Reject" are both `