Merge main (security-perf + SEO) into docs; finish English docs and agent guide

- Resolve conflicts in analytics, consent, content, i18n, mcp and stats,
  keeping the docs fixes and the new code behaviour, verified against src
- Translate the remaining 14 module pages, ipal-seo-check skill and script
- Integrate the security-perf and SEO agent-guide text: getRobots,
  isPathVisible, Search & AI (DNS verification first, meta fields optional),
  sitemap index/cache/503, consentMode basic/advanced, policyVersion,
  globalOverrides, revalidatePath / buildGlobalRevalidateHook, authAccess,
  firstUserAdmin, allowCollectionMismatch, unknown-IP rate limit; stale
  claims fixed across AGENT.md, skills, frontend, developer guide, vibe
- docsConsistency: pending list removed (all docs English); relative links
  now also check #anchors

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 17:59:52 +02:00
co-authored by Claude Opus 5.5
107 changed files with 5476 additions and 2541 deletions
+222 -212
View File
@@ -1,55 +1,58 @@
# consent
Banner zgody na cookies (GDPR): 4 kategorie (necessary / functional /
analytics / marketing), zapis w cookie z wersjonowaniem, Google Consent Mode,
treść z globala CookieSettings. Okno ustawień w trzech trybach do wyboru
(`settings`: w pasku, małe okno, duże okno ze szczegółami ciasteczek). Domyślny
wygląd w czystym Tailwind, nadpisywalny.
Cookie consent banner (GDPR): 4 categories (necessary / functional /
analytics / marketing), stored in a versioned cookie, Google Consent Mode,
content from the CookieSettings global. A settings window in three modes to pick
from (`settings`: in the bar, small window, large window with cookie details).
Default look in plain Tailwind, overridable.
## Zależność
## Dependency
Banner używa ikony z `lucide-react` — to zwykła zależność `dependencies` pakietu
(`^0.400.0`), instaluje się razem z ipal-kit; w projekcie nic nie dodajesz.
The banner uses an icon from `lucide-react` — a regular `dependencies` entry of
the package (`^0.400.0`), installed together with ipal-kit; you add nothing in the
project.
## Config
Global **CookieSettings** (slug `cookie-settings`, grupa *Settings*) jest zawsze
budowany. Odczyt publiczny (`read: () => true` — baner czyta go dla anonimowych
gości); `update` bez własnej reguły, więc obowiązuje domyślne Payload: każdy
zalogowany użytkownik panelu (także rola `user`). Jedyna opcja pluginu w tym
module to `consentLog` (niżej). Edytor zarządza
treścią bannera (message, przyciski, kategorie, settingsTitle) w panelu,
localized. Link do polityki prywatności bierze się z system pages
(`privacyPolicy`), nie z osobnego pola.
The **CookieSettings** global (slug `cookie-settings`, group *Settings*) is always
built. Public read (`read: () => true` — the banner reads it for anonymous
visitors); `update` is limited to the `admin` and `editor` roles (`adminOrEditor` —
consent texts are legal copy, not for plain `user` accounts). To change it:
`ipalKit({ globalOverrides: { 'cookie-settings': { access: { update } } } })`.
The only plugin option in this module is `consentLog` (below). The editor manages
the banner content (message, buttons, categories, settingsTitle) in the panel,
localized. The privacy policy link comes from system pages (`privacyPolicy`), not
from a separate field.
**Link do polityki prywatności w banerze (od 1.7.12)** — zero kodu:
**Privacy policy link in the banner (since 1.7.12)** — zero code:
| Co | Skąd |
| What | Where from |
|---|---|
| Dokąd prowadzi | Site Settings → System Pages → Privacy Policy |
| Tekst linku | Cookie Settings → `privacyLinkLabel` (per język) |
| Gdy tekst pusty | tytuł strony polityki w danym języku |
| Where it leads | Site Settings → System Pages → Privacy Policy |
| Link text | Cookie Settings → `privacyLinkLabel` (per language) |
| When the text is empty | title of the policy page in that language |
Opcje `privacyPolicy` w `getConsentTexts`: pomiń (automat), `false` (bez
linku), `{ page }` (własna strona, odczytana z `locale: 'all'`). Parametr
`label` jest **przestarzały** — tekst wpisany w kodzie łamie A0 przy kilku
językach; działa tylko, gdy pole w panelu jest puste. Usuń go z projektów przy
okazji aktualizacji.
`privacyPolicy` options in `getConsentTexts`: omit (automatic), `false` (no
link), `{ page }` (your own page, read with `locale: 'all'`). The `label`
parameter is **deprecated** — text hard-coded in code breaks A0 with several
languages; it works only when the panel field is empty. Remove it from projects
when you update them.
## Front — Provider + banner
Zwykle jedną linią w layoutcie (PROGRAMISTA §2.8) — `SiteProviders` (`/rsc`) wpina provider,
baner, przycisk i `Analytics` w dobrej kolejności, z tekstami z `getSiteShell(locale).consent`:
Usually one line in the layout (PROGRAMISTA §2.8) — `SiteProviders` (`/rsc`) wires the provider,
banner, button and `Analytics` in the right order, with texts from `getSiteShell(locale).consent`:
```tsx
<SiteProviders shell={await getSiteShell(locale)} logEndpoint="/api/ipal/consent"
banner={<CookieBanner equalChoice classNames={…} />}>{children}</SiteProviders>
```
`SiteProviders` przyjmuje też `cookieMap`, `banner={false}`, `cookieButton={false}`
(lub własny element) i `analytics={false | { defer, deferTimeoutMs }}`.
`SiteProviders` also takes `cookieMap`, `banner={false}`, `cookieButton={false}`
(or your own element) and `analytics={false | { consentMode, defer, deferTimeoutMs }}`
(`consentMode: 'basic'` = no Google request before consent — see [analytics.md](./analytics.md)).
Ręcznie (własny układ) — to samo z pojedynczych części:
By hand (your own layout) — the same from the individual parts:
Provider owija aplikację, banner i button renderują się same. Import z
The provider wraps the app; the banner and the button render themselves. Import from
`@intecion/ipal-kit/client`:
```tsx
@@ -61,8 +64,8 @@ export default async function Layout({ children, params }) {
const { locale } = await params
const payload = await getPayload({ config })
// teksty z Cookie Settings; link do polityki automatycznie:
// cel = System Pages → Privacy Policy, tekst = Cookie Settings → privacyLinkLabel
// texts from Cookie Settings; the policy link is automatic:
// target = System Pages → Privacy Policy, text = Cookie Settings → privacyLinkLabel
const texts = await getConsentTexts({ payload, config: i18nConfig, locale })
return (
@@ -75,61 +78,61 @@ export default async function Layout({ children, params }) {
}
```
`ConsentProvider` — propsy: `texts` (wymagane, `ConsentTexts` z `getConsentTexts`),
`cookieMap` (dodatkowe ciasteczka do kasowania przy wycofaniu), `logEndpoint`
(rejestr zgód). `CookieBanner` nie renderuje się po decyzji, `CookieButton` —
odwrotnie (pokazuje się dopiero po decyzji i ponownie otwiera baner); oba
renderują się dopiero po zamontowaniu na kliencie.
`ConsentProvider` — props: `texts` (required, `ConsentTexts` from `getConsentTexts`),
`cookieMap` (extra cookies to delete on withdrawal), `logEndpoint`
(consent log). `CookieBanner` does not render after a decision, `CookieButton` —
the opposite (it shows only after a decision and reopens the banner); both
render only after mounting on the client.
`getConsentTexts({ payload, config, locale, privacyPolicy?, settingsSlug? })` —
`settingsSlug` to slug SiteSettings dla automatycznego linku (domyślnie
`'site-settings'`). Puste pola w panelu → angielski fallback.
`settingsSlug` is the SiteSettings slug for the automatic link (default
`'site-settings'`). Empty fields in the panel → English fallback.
| Prop `CookieBanner` | Domyślnie | Opis |
| `CookieBanner` prop | Default | Description |
|---|---|---|
| `classNames` | — | sloty (tabela niżej) — podany zastępuje domyślny |
| `equalChoice` | `false` | „Odrzuć” w stylu przycisku głównego |
| `icon` | `true` | ikona ciasteczka |
| `order` | `['settings', 'reject', 'accept']` | przyciski banera |
| `classNames` | — | slots (table below) — a given one replaces the default |
| `equalChoice` | `false` | "Reject" styled as the primary button |
| `icon` | `true` | cookie icon |
| `order` | `['settings', 'reject', 'accept']` | banner buttons |
| `settings` | `'inline'` | `'inline' \| 'modal' \| 'detailed'` |
| `controls` | `'checkbox'` | `'checkbox' \| 'switch'` |
| `settingsActions` | `['back', 'save']` | przyciski pod kategoriami (`'accept' \| 'back' \| 'reject' \| 'save'`) |
| `settingsActions` | `['back', 'save']` | buttons under the categories (`'accept' \| 'back' \| 'reject' \| 'save'`) |
`CookieButton` przyjmuje tylko `className` (zastępuje domyślny).
`CookieButton` takes only `className` (replaces the default).
## Nadpisywanie wyglądu (Poziom 2)
## Overriding the look (Level 2)
Domyślne klasy Tailwind można nadpisać przez `classNames`:
The default Tailwind classes can be overridden with `classNames`:
```tsx
<CookieBanner classNames={{
root: 'fixed inset-x-0 bottom-0 ...', // Twój layout
primaryButton: 'btn btn-primary', // np. DaisyUI
root: 'fixed inset-x-0 bottom-0 ...', // your layout
primaryButton: 'btn btn-primary', // e.g. DaisyUI
secondaryButton: 'btn btn-ghost',
}} />
```
## Gating skryptów wg zgody
## Gating scripts by consent
```ts
import { updateConsent, setDefaultConsent } from '@intecion/ipal-kit'
// wysyła sygnały do Google Consent Mode (gtag) na podstawie stanu zgody
// sends signals to Google Consent Mode (gtag) based on the consent state
```
Logika (kategorie, storage, parsowanie) też jest dostępna server-safe z
The logic (categories, storage, parsing) is also available server-safe from
`@intecion/ipal-kit`:
```ts
import { parseConsent, CONSENT_COOKIE, CONSENT_CATEGORIES } from '@intecion/ipal-kit'
// np. gating skryptów server-side na podstawie cookie zgody
// e.g. server-side script gating based on the consent cookie
```
### ConsentScript — ładuj skrypt dopiero po zgodzie
### ConsentScript — load a script only after consent
Dla third-party BEZ własnego Consent Mode (Meta Pixel, LinkedIn Insight, czaty,
własna analityka) użyj `ConsentScript` — ładuje skrypt tylko po zgodzie dla jego
kategorii, reaguje na żywo (akceptacja w banerze → skrypt pojawia się bez
przeładowania). Renderuj wewnątrz `<ConsentProvider>`:
For third parties WITHOUT their own Consent Mode (Meta Pixel, LinkedIn Insight, chats,
your own analytics) use `ConsentScript` — it loads the script only after consent for
its category and reacts live (accept in the banner → the script appears without a
reload). Render it inside `<ConsentProvider>`:
```tsx
import { ConsentScript } from '@intecion/ipal-kit/client'
@@ -141,20 +144,20 @@ import { ConsentScript } from '@intecion/ipal-kit/client'
attributes={{ 'data-domain': 'example.com' }} />
```
GA/GTM lepiej przez Consent Mode (`updateConsent` wyżej) — `ConsentScript` jest
dla wendorów, których tak nie ugatujesz. Uwaga: skrypt raz załadowany działa do
końca strony (tag `<script>` nie da się „odładować") — wycofanie zgody blokuje
KOLEJNE ładowanie; dla running tagów polegaj na Consent Mode.
GA/GTM are better handled by Consent Mode (`updateConsent` above) — `ConsentScript` is
for vendors you cannot gate that way. Note: a script once loaded runs until the page
ends (a `<script>` tag cannot be "unloaded") — withdrawing consent blocks the NEXT
load; for running tags rely on Consent Mode.
## Wygląd — nadpisywanie stylów
## Look — overriding styles
Banner i przycisk mają domyślny, neutralny wygląd (light + dark) i działają bez
żadnej konfiguracji. Kolory i zaokrąglenia idą przez CSS custom properties z
fallbackami — żeby przestylować pod klienta, zadeklaruj zmienne w swoim CSS.
Bez importów, bez propsów, bez walki ze specificity:
The banner and the button have a default, neutral look (light + dark) and work
without any configuration. Colours and radii go through CSS custom properties with
fallbacks — to restyle for a client, declare the variables in your CSS.
No imports, no props, no fighting specificity:
```css
/* global.css — wszystko opcjonalne, nadpisz tylko to, co chcesz */
/* global.css — everything optional, override only what you want */
:root {
--ipal-primary: #16a34a;
--ipal-primary-hover: #15803d;
@@ -162,213 +165,220 @@ Bez importów, bez propsów, bez walki ze specificity:
}
```
Dostępne tokeny (każdy ma odpowiednik `-dark` używany pod `dark:`):
Available tokens (each has a `-dark` counterpart used under `dark:`):
| Token | Domyślnie | Co koloruje |
| Token | Default | What it colours |
|---|---|---|
| `--ipal-surface` | `#fff` | tło bannera i przycisku |
| `--ipal-border` | `#e5e5e5` | obramowania |
| `--ipal-text` | `#404040` | tekst treści |
| `--ipal-text-strong` | `#171717` | nagłówki, nazwy kategorii |
| `--ipal-text-muted` | `#737373` | opisy kategorii |
| `--ipal-primary` | `#2563eb` | przycisk główny, ikona, link, checkbox |
| `--ipal-primary-hover` | `#1d4ed8` | hover przycisku głównego |
| `--ipal-primary-text` | `#fff` | tekst na przycisku głównym |
| `--ipal-hover` | `#f5f5f5` | hover przycisków drugorzędnych |
| `--ipal-radius` | `0.375rem` | zaokrąglenie przycisków |
| `--ipal-surface` | `#fff` | banner and button background |
| `--ipal-border` | `#e5e5e5` | borders |
| `--ipal-text` | `#404040` | body text |
| `--ipal-text-strong` | `#171717` | headings, category names |
| `--ipal-text-muted` | `#737373` | category descriptions |
| `--ipal-primary` | `#2563eb` | primary button, icon, link, checkbox |
| `--ipal-primary-hover` | `#1d4ed8` | primary button hover |
| `--ipal-primary-text` | `#fff` | text on the primary button |
| `--ipal-hover` | `#f5f5f5` | secondary buttons hover |
| `--ipal-radius` | `0.375rem` | button radius |
Wymaga `@source` skanującego pakiet (patrz PROGRAMISTA.md §2.5) — inaczej Tailwind
nie wygeneruje tych klas.
Requires an `@source` that scans the package (see PROGRAMISTA.md §2.5) — otherwise
Tailwind will not generate these classes.
### Gdy tokeny nie wystarczą
### When tokens are not enough
Układ (odstępy, pozycja, breakpointy) nie jest tokenizowany — to nie jest coś,
co zmienia się per brand, a wystawienie go oznaczałoby wymyślanie CSS od nowa,
zmienna po zmiennej. Na większe zmiany są `classNames`:
Layout (spacing, position, breakpoints) is not tokenized — it is not something
that changes per brand, and exposing it would mean reinventing CSS, variable by
variable. For bigger changes there is `classNames`:
```tsx
<CookieBanner classNames={{
root: 'fixed inset-0 z-50 grid place-items-center bg-black/50', // modal zamiast paska
primaryButton: 'btn btn-primary', // np. DaisyUI
root: 'fixed inset-0 z-50 grid place-items-center bg-black/50', // modal instead of a bar
primaryButton: 'btn btn-primary', // e.g. DaisyUI
secondaryButton: 'btn btn-ghost',
}} />
<CookieButton className="fixed bottom-6 right-6 ..." />
```
Podany className zastępuje domyślny (nie dokleja się). Każdy element ma swój slot (1.10.0):
A given className replaces the default (it is not appended). Every element has its own slot (1.10.0):
| Slot | Element |
|---|---|
| `root`, `body`, `content` | pasek, wewnętrzna szerokość, rząd tekst + przyciski |
| `text`, `icon`, `eyebrow`, `title`, `message`, `link` | blok tekstu banera |
| `actions` | rząd przycisków banera |
| `primaryButton`, `secondaryButton` | dwa style przycisków (domyślne dla wszystkich) |
| `acceptButton`, `rejectButton`, `settingsButton`, `saveButton`, `backButton` | pojedyncze przyciski — puste → `primaryButton` / `secondaryButton` |
| `overlay`, `dialog`, `closeButton` | modal ustawień (`settings="modal"` / `"detailed"`) |
| `categoryCard`, `cookies`, `cookiesToggle`, `cookieList`, `cookie`, `cookieName`, `cookieMeta` | duże okno (`settings="detailed"`): karta kategorii, rozwijana lista ciasteczek, jedno ciasteczko, nazwa, siatka dostawca / cel / czas |
| `settingsTitle`, `settingsDescription`, `categories`, `category`, `categoryTitle`, `categoryDescription` | widok ustawień |
| `control`, `controlThumb`, `badge` | checkbox / przełącznik, kciuk przełącznika, znacznik „Zawsze aktywne” |
| `settingsActions` | rząd przycisków pod kategoriami |
| `root`, `body`, `content` | bar, inner width, text + buttons row |
| `text`, `icon`, `eyebrow`, `title`, `message`, `link` | banner text block |
| `actions` | banner buttons row |
| `primaryButton`, `secondaryButton` | two button styles (defaults for all) |
| `acceptButton`, `rejectButton`, `settingsButton`, `saveButton`, `backButton` | single buttons — empty → `primaryButton` / `secondaryButton` |
| `overlay`, `dialog`, `closeButton` | settings modal (`settings="modal"` / `"detailed"`) |
| `categoryCard`, `cookies`, `cookiesToggle`, `cookieList`, `cookie`, `cookieName`, `cookieMeta` | large window (`settings="detailed"`): category card, expandable cookie list, one cookie, name, provider / purpose / duration grid |
| `settingsTitle`, `settingsDescription`, `categories`, `category`, `categoryTitle`, `categoryDescription` | settings view |
| `control`, `controlThumb`, `badge` | checkbox / switch, switch thumb, "Always active" badge |
| `settingsActions` | buttons row under the categories |
### Układ: kolejność przycisków, modal, przełączniki (1.10.0)
### Layout: button order, modal, switches (1.10.0)
```tsx
<CookieBanner
equalChoice
icon={false} // bez ikony ciasteczka
order={['accept', 'reject', 'settings']} // przyciski banera w tej kolejności
settings="modal" // ustawienia w oknie na środku (✕, Escape, klik w tło)
controls="switch" // przełączniki role="switch" zamiast checkboxów
settingsActions={['save', 'reject', 'accept']} // przyciski pod kategoriami
icon={false} // no cookie icon
order={['accept', 'reject', 'settings']} // banner buttons in this order
settings="modal" // settings in a centred window (✕, Escape, click on backdrop)
controls="switch" // role="switch" toggles instead of checkboxes
settingsActions={['save', 'reject', 'accept']} // buttons under the categories
classNames={{ … }}
/>
```
Domyślnie (bez tych propsów) baner wygląda i działa jak przed 1.10.0.
By default (without these props) the banner looks and works as before 1.10.0.
### Duże okno ze szczegółami (`settings="detailed"`, 1.12.3)
### Large window with details (`settings="detailed"`, 1.12.3)
Trzy tryby ustawień do wyboru w projekcie — jeden prop:
Three settings modes to pick in the project — one prop:
| `settings` | Co widzi użytkownik po „Ustawienia” |
| `settings` | What the user sees after "Settings" |
|---|---|
| `'inline'` (domyślnie) | kategorie w samym pasku banera |
| `'modal'` | małe okno na środku: kategoria + krótki opis + przełącznik |
| `'detailed'` | duże okno: każda kategoria to karta z przełącznikiem, opisem i rozwijaną listą jej ciasteczek (nazwa, dostawca, cel, czas przechowywania) |
| `'inline'` (default) | categories inside the banner bar |
| `'modal'` | small centred window: category + short description + switch |
| `'detailed'` | large window: each category is a card with a switch, a description and an expandable list of its cookies (name, provider, purpose, retention) |
```tsx
<CookieBanner equalChoice controls="switch" settings="detailed" />
```
Lista ciasteczek bierze się z **Cookie Settings → Cookies** (to samo źródło co `<CookieTable>` na stronie
polityki), filtrowana po kategorii — kategoria bez wpisów nie ma rozwijanej listy. Podpisy listy: **Cookie
Settings → Detail labels** (`cookies` — np. „Używane ciasteczka”, licznik dopisuje się sam; `provider`, `purpose`,
`duration`), per język; puste → angielskie. `getConsentTexts` przekazuje to w `texts.cookies` / `texts.details`
— nic nie trzeba podawać w kodzie. Zamykanie jak w `'modal'` (✕, Escape, klik w tło). Domyślna szerokość okna
`max-w-4xl` — zmiana przez `classNames.dialog`.
The cookie list comes from **Cookie Settings → Cookies** (the same source as `<CookieTable>` on the policy
page), filtered by category — a category without entries has no expandable list. List labels: **Cookie
Settings → Detail labels** (`cookies` — e.g. "Cookies used", the counter is added automatically; `provider`,
`purpose`, `duration`), per language; empty → English. `getConsentTexts` passes this in `texts.cookies` /
`texts.details` — nothing to pass in code. Closing as in `'modal'` (✕, Escape, click on backdrop). Default
window width `max-w-4xl` — change it with `classNames.dialog`.
Który tryb wybrać: decyduje design projektu. Brief milczy → `'detailed'` (użytkownik widzi przy zgodzie, jakie
ciasteczka i od kogo — pełna informacja w miejscu decyzji), pod warunkiem że lista Cookies jest wypełniona ze skanu
(`ipal-consent-check` → cookie-scan); pusta lista = okno bez rozwijanych list, wtedy wystarczy `'modal'`. Decyzję
zapisz w `AGENTS.md` → „Ustalenia projektu”.
Which mode to choose: the project design decides. If the brief is silent → `'detailed'` (at the moment of
consent the user sees which cookies are set and by whom — full information where the decision is made),
provided the Cookies list is filled from a scan (`ipal-consent-check` → cookie-scan); an empty list = a
window without expandable lists, then `'modal'` is enough. Record the decision in `AGENTS.md` →
"Project decisions".
Zalecenie (AGENT.md §7): najpierw tokeny i `classNames` — wtedy poprawki z aktualizacji pluginu trafiają
do projektu. Gdy potrzebujesz całkiem innego układu, możesz zbudować własne okno; dane są w kontekście: `useConsentContext()` → `texts.cookies`,
`texts.details`, `state`, `savePreferences`.
Recommendation (AGENT.md §7): tokens and `classNames` first — then fixes from plugin updates reach the
project. When you need a completely different layout, you can build your own window; the data is in the
context: `useConsentContext()` → `texts.cookies`, `texts.details`, `state`, `savePreferences`.
Teksty z panelu (**Cookie Settings**, per język) — puste pole = element się nie pokazuje:
Texts from the panel (**Cookie Settings**, per language) — empty field = the element is not shown:
| Pole | Gdzie |
| Field | Where |
|---|---|
| `eyebrow` | mały napis nad tytułem banera („Prywatność i cookies”) |
| `title` | tytuł banera („Szanujemy Twoją prywatność”) |
| `settingsDescription` | opis pod tytułem ustawień |
| `alwaysActiveLabel` | znacznik przy „Niezbędne” zamiast wyłączonego przełącznika |
| `detailLabels.cookies` / `.provider` / `.purpose` / `.duration` | podpisy listy ciasteczek w oknie `settings="detailed"` (puste → angielskie) |
| `cookies` (lista) | ciasteczka per kategoria — okno `detailed` i `<CookieTable>`; `purpose`, `duration` per język |
| `buttons.close` | etykieta przycisku ✕ dla czytników ekranu (puste → „Close”) |
| `buttons.savePreferences` | „Zapisz” w ustawieniach (do 1.11.0 pole `save` — nazwa zarezerwowana w Mongoose; w kodzie dalej `texts.buttons.save`). MongoDB: od 1.12.2 plugin przy starcie kopiuje stare `save` (wszystkie języki), gdy `savePreferences` brak |
| `eyebrow` | small label above the banner title ("Privacy and cookies") |
| `title` | banner title ("We respect your privacy") |
| `settingsDescription` | description under the settings title |
| `alwaysActiveLabel` | badge next to "Necessary" instead of a disabled switch |
| `detailLabels.cookies` / `.provider` / `.purpose` / `.duration` | cookie list labels in the `settings="detailed"` window (empty → English) |
| `cookies` (list) | cookies per category — the `detailed` window and `<CookieTable>`; `purpose`, `duration` per language |
| `buttons.close` | screen-reader label of the ✕ button (empty → "Close") |
| `buttons.savePreferences` | "Save" in the settings (up to 1.11.0 the field was `save` — a name reserved in Mongoose; in code still `texts.buttons.save`). MongoDB: since 1.12.2 the plugin copies the old `save` (all languages) on startup when `savePreferences` is missing |
Nowe pola w globalu = migracja w projektach na Postgres/SQLite (`payload migrate:create`); MongoDB bez zmian.
New fields in the global = a migration in projects on Postgres/SQLite (`payload migrate:create`); MongoDB unchanged.
Elementy mają też stabilne uchwyty `data-ipal` do CSS i testów e2e (używa ich
`ipal-consent-check`): `banner`, `cookie-button` oraz przyciski `settings`, `reject`,
`accept`, `back`, `save`; w trybie modal także `consent-overlay`, `consent-dialog`, `close`; w trybie detailed
dodatkowo `category-<kategoria>` (karta) i `cookies` (rozwijana lista).
The elements also have stable `data-ipal` handles for CSS and e2e tests (used by
`ipal-consent-check`): `banner`, `cookie-button` and the buttons `settings`, `reject`,
`accept`, `back`, `save`; in modal mode also `consent-overlay`, `consent-dialog`, `close`; in detailed mode
additionally `category-<category>` (card) and `cookies` (expandable list).
Dostępność: dialog banera i `CookieButton` mają `aria-label` z **Cookie Settings →
title** albo **settingsTitle** (per język) — bez tekstów na sztywno w komponentach. Modal ma
`aria-modal`, fokus na ✕ po otwarciu i zamyka się Escape; przełączniki mają `role="switch"` i `aria-checked`.
Accessibility: the banner dialog and `CookieButton` have an `aria-label` from **Cookie Settings →
title** or **settingsTitle** (per language) — no hard-coded texts in the components. The modal has
`aria-modal`, focus on ✕ after opening and closes on Escape; switches have `role="switch"` and `aria-checked`.
## Locale jako cookie functional (wbudowane)
## Locale as a functional cookie (built in)
Plugin sam zarządza jedną cookie functional: **`NEXT_LOCALE`** (wybór języka).
Nie musisz nic konfigurować — działa out of the box:
The plugin itself manages one functional cookie: **`NEXT_LOCALE`** (language choice).
You do not need to configure anything — it works out of the box:
- **Zapis za zgodą.** Middleware zapisuje `NEXT_LOCALE` tylko, gdy użytkownik
zaakceptował kategorię **functional**. Bez zgody język działa (negocjacja per
żądanie), ale nie jest utrwalany w cookie. Opcja middleware/proxy
`consentCategory: 'necessary'` zapisuje zawsze.
**Uwaga:** middleware czyta zgodę bez wersji polityki (zakłada wersję `1`) —
po podniesieniu *Policy version* w panelu `NEXT_LOCALE` przestaje być zapisywane.
- **Sprzątanie po cofnięciu.** Gdy użytkownik cofnie zgodę na functional, hook
consent usuwa `NEXT_LOCALE` automatycznie. Odpowiada za to `DEFAULT_COOKIE_MAP`:
- **Stored only with consent.** The middleware writes `NEXT_LOCALE` only when the user
has accepted the **functional** category. Without consent the language still works
(negotiated per request), but it is not persisted in a cookie. The middleware/proxy
option `consentCategory: 'necessary'` always writes it.
By default the middleware accepts a stored consent under the policy version it was
saved with (the proxy cannot read the panel). To require the current *Policy version*,
pass `policyVersion` to the middleware/proxy (`createLocaleMiddleware` / `createProxy`).
- **Cleanup after withdrawal.** When the user withdraws functional consent, the consent
hook deletes `NEXT_LOCALE` automatically. `DEFAULT_COOKIE_MAP` is responsible for that:
```ts
const DEFAULT_COOKIE_MAP = {
analytics: ['_ga', '_ga_*', '_gid', '_gat*', '_clck', '_clsk', 'CLID', '_hj*', 'ipal_vid'], // ipal_vid — stats.md
functional: [LOCALE_COOKIE_NAME], // 'NEXT_LOCALE' — plugin zna własną cookie
functional: [LOCALE_COOKIE_NAME], // 'NEXT_LOCALE' — the plugin knows its own cookie
marketing: ['_fbp', '_fbc', '_gcl_*', '_ttp', 'li_fat_id', '_uetsid', '_uetvid'],
}
```
### Twoje własne cookie functional/analytics
### Your own functional/analytics cookies
Jeśli ustawiasz własne cookie podlegające zgodzie, dopisz je przez `cookieMap` —
po cofnięciu zgody zostaną skasowane razem z domyślnymi:
If you set your own cookie that is subject to consent, add it through `cookieMap` —
after consent is withdrawn it is deleted together with the defaults:
```tsx
<ConsentProvider texts={texts} cookieMap={{ functional: ['moje-ustawienie'], analytics: ['_my*'] }}>
<ConsentProvider texts={texts} cookieMap={{ functional: ['my-setting'], analytics: ['_my*'] }}>
```
Mapa jest **dopisywana** do `DEFAULT_COOKIE_MAP` (nie zastępuje jej), `*` na końcu
= prefiks. To samo przyjmuje `SiteProviders cookieMap` i `useConsent({ cookieMap })`
(hook niskopoziomowy — w aplikacji używaj providera, inaczej powstaje drugi,
niezależny stan zgody).
The map is **added** to `DEFAULT_COOKIE_MAP` (it does not replace it), `*` at the end
= prefix. `SiteProviders cookieMap` and `useConsent({ cookieMap })` take the same
(low-level hook — in the app use the provider, otherwise you get a second,
independent consent state).
> Mechanizm zgody dla locale jest opisany też od strony i18n:
> [i18n.md](./i18n.md#cookie-locale-a-zgoda-rodo).
> The consent mechanism for the locale is also described from the i18n side:
> [i18n.md](./i18n.md#locale-cookie-and-consent-gdpr).
## Wersja polityki, wycofanie zgody, rejestr zgód, tabela ciasteczek (1.9.1)
## Policy version, withdrawing consent, consent log, cookie table (1.9.1)
- **Ponowna zgoda po zmianie polityki:** Cookie Settings → *Policy version* (sidebar). Podnieś o 1
po dodaniu narzędzia albo zmianie polityki — każdy odwiedzający zobaczy baner ponownie.
`getConsentTexts` przekazuje wersję do `<ConsentProvider texts>` automatycznie.
- **Wycofanie zgody kasuje ciasteczka narzędzi** (`_ga`, `_ga_*`, `_gid`, `_fbp`, `_gcl_*`, Clarity,
LinkedIn, TikTok, Hotjar…) — także na domenie nadrzędnej (`.klient.pl`), gdzie zapisuje je GA.
Własne ciasteczka projektu: `<ConsentProvider cookieMap={{ marketing: ['_my*'] }}>` (dopisywane do
listy domyślnej, `*` = prefiks).
- **Równy wybór:** `<CookieBanner equalChoice />` — „Odrzuć” wygląda jak „Akceptuj wszystko”
(wymóg UODO/EDPB: odmowa równie łatwa jak zgoda). Domyślnie wyłączone, żeby nie zmieniać wyglądu
istniejących stron; **w nowych projektach włączaj**.
- **Rejestr zgód (dowód zgody, art. 7 ust. 1 RODO):** `ipalKit({ consentLog: true })` albo
- **New consent after a policy change:** Cookie Settings → *Policy version* (sidebar). Raise it by 1
after adding a tool or changing the policy — every visitor will see the banner again.
`getConsentTexts` passes the version to `<ConsentProvider texts>` automatically.
- **Withdrawing consent deletes the tools' cookies** (`_ga`, `_ga_*`, `_gid`, `_fbp`, `_gcl_*`, Clarity,
LinkedIn, TikTok, Hotjar…) — also on the parent domain (`.client.com`), where GA stores them.
The project's own cookies: `<ConsentProvider cookieMap={{ marketing: ['_my*'] }}>` (added to the
default list, `*` = prefix).
- **Equal choice:** `<CookieBanner equalChoice />` — "Reject" looks like "Accept all"
(UODO/EDPB requirement: refusing must be as easy as consenting). Off by default so the look of
existing sites does not change; **turn it on in new projects**.
- **Consent log (proof of consent, GDPR Art. 7(1)):** `ipalKit({ consentLog: true })` or
`ipalKit({ consentLog: { retentionDays: 730 } })` + `<ConsentProvider logEndpoint="/api/ipal/consent">`
(lub `SiteProviders logEndpoint`). Zapisuje losowy identyfikator (ten sam co w ciasteczku), wybory,
wersję polityki i czas — **bez IP i user-agenta**. Szczegóły niżej. Postgres: `migrate:create`.
- **Tabela ciasteczek** dla strony polityki: Cookie Settings → *Cookies* (wypełniana skanem,
skill `ipal-consent-check` → cookie-scan) + `getCookieTable` + `<CookieTable>` z `/rsc`.
- Ciasteczko zgody: `cookie-consent` (`CONSENT_COOKIE`), JSON `{ id, state, timestamp, version }`,
`max-age` 180 dni (`CONSENT_MAX_AGE`), `samesite=lax`, `Secure` na HTTPS. Zgoda z inną wersją
polityki jest traktowana jak brak decyzji.
- Global Privacy Control nie jest potrzebny: w UE wszystko poza niezbędnymi i tak jest domyślnie
wyłączone do czasu zgody.
(or `SiteProviders logEndpoint`). It stores a random identifier (the same as in the cookie), the
choices, the policy version and the time — **no IP and no user agent**. *Consent records* collection
(admin only), automatic cleanup after `retentionDays` (default 1095). Details below. Postgres:
`migrate:create`.
- **Cookie table** for the policy page: Cookie Settings → *Cookies* (filled by a scan,
skill `ipal-consent-check` → cookie-scan) + `getCookieTable` + `<CookieTable>` from `/rsc`.
- Consent cookie: `cookie-consent` (`CONSENT_COOKIE`), JSON `{ id, state, timestamp, version }`,
`max-age` 180 days (`CONSENT_MAX_AGE`), `samesite=lax`, `Secure` on HTTPS. Consent with another
policy version is treated as no decision.
- Global Privacy Control is not needed: in the EU everything except necessary is off by default
anyway until consent.
## Rejestr zgód — szczegóły (`consentLog`)
## Consent log — details (`consentLog`)
| Element | Wartość |
| Item | Value |
|---|---|
| Opcja | `consentLog?: boolean \| { retentionDays?: number }` (typ `ConsentLogOptions`) |
| `retentionDays` | domyślnie `1095` (3 lata) |
| Kolekcja | `consent-records` (`CONSENT_LOG_SLUG`), grupa *Settings*; pola `consentId` (index), `version`, `choices.{necessary,functional,analytics,marketing}`, `createdAt` |
| Dostęp do kolekcji | `read` / `delete` — admin; `create` / `update` — nikt przez API (zapis tylko endpointem, `overrideAccess`) |
| Endpoint | `POST /api/ipal/consent`, publiczny (bez logowania) |
| Option | `consentLog?: boolean \| { retentionDays?: number }` (type `ConsentLogOptions`) |
| `retentionDays` | default `1095` (3 years) |
| Collection | `consent-records` (`CONSENT_LOG_SLUG`), group *Settings*; fields `consentId` (index), `version`, `choices.{necessary,functional,analytics,marketing}`, `createdAt` |
| Collection access | `read` / `delete` — admin; `create` / `update` — nobody through the API (written only by the endpoint, `overrideAccess`) |
| Endpoint | `POST /api/ipal/consent`, public (no login) |
| Body | `{ id: string (hex 16–64), version: int ≥ 1, state: { necessary, functional, analytics, marketing: boolean } }` |
| Odpowiedzi | `201 { ok: true }`, `400` (zły JSON/walidacja), `429` (limit 20 żądań/min na IP, scope `consent`), `500` |
| Czyszczenie | przy zapisie, najwyżej raz na 24 h na proces: usuwa rekordy starsze niż `retentionDays` |
| Responses | `201 { ok: true }`, `400` (bad JSON/validation), `429` (limit 20 requests/min per IP, scope `consent`), `500` |
| Cleanup | on a write, at most once per 24 h per process: one `db.deleteMany` for records older than `retentionDays`, **in the background** (the consent write does not wait; an error is logged and the cleanup is retried on the next write) |
Provider wysyła rekord po każdej decyzji (`fetch` z `keepalive`, błędy ignorowane —
baner nigdy nie czeka). Ręcznie: `buildConsentLogCollection()` / `buildConsentLogEndpoint(opts)`
z `@intecion/ipal-kit`.
The provider sends a record after every decision (`fetch` with `keepalive`, errors ignored —
the banner never waits). By hand: `buildConsentLogCollection()` / `buildConsentLogEndpoint(opts)`
from `@intecion/ipal-kit`.
## Wyłączenie, nadpisanie, rozszerzenie
## Turn off, override, extend
- **Wyłączenie:** nie montuj `CookieBanner` / `CookieButton` (albo `SiteProviders banner={false}
cookieButton={false}`). Global `cookie-settings` jest obecnie zawsze dodawany (brak opcji);
rejestr zgód tylko przy `consentLog`.
- **Nadpisanie:** teksty i lista ciasteczek w panelu; wygląd tokenami `--ipal-*` i `classNames`;
układ propsami `order`, `settings`, `controls`, `settingsActions`, `equalChoice`, `icon`;
`retentionDays` rejestru; `privacyPolicy` / `settingsSlug` w `getConsentTexts`.
- **Rozszerzenie:** `cookieMap` (własne ciasteczka do kasowania), `ConsentScript` (skrypty bez Consent
Mode), `useConsentContext()` (własny UI: `state`, `acceptAll`, `rejectAll`, `savePreferences`,
`reopen`, `texts`), helpery server-safe (`parseConsent`, `readConsentRecord`, `CONSENT_COOKIE`,
`getCookieTable`) i budowniczowie `buildConsentLogCollection` / `buildConsentLogEndpoint`.
- **Turn off:** do not mount `CookieBanner` / `CookieButton` (or `SiteProviders banner={false}
cookieButton={false}`). The `cookie-settings` global is currently always added (no option to drop
it); the consent log only with `consentLog`.
- **Override:** texts and the cookie list in the panel; the look with `--ipal-*` tokens and `classNames`;
the layout with the props `order`, `settings`, `controls`, `settingsActions`, `equalChoice`, `icon`;
the log's `retentionDays`; `privacyPolicy` / `settingsSlug` in `getConsentTexts`. The `cookie-settings`
global (write access is `admin` + `editor` by default, hooks, admin options):
`ipalKit({ globalOverrides: { 'cookie-settings': { access: { update } } } })` — your access rules win,
your hooks run after the plugin's; a function gets the plugin's global and returns the one to use.
- **Extend:** `cookieMap` (your own cookies to delete), `ConsentScript` (scripts without Consent
Mode), `useConsentContext()` (your own UI: `state`, `acceptAll`, `rejectAll`, `savePreferences`,
`reopen`, `texts`), server-safe helpers (`parseConsent`, `readConsentRecord`, `CONSENT_COOKIE`,
`getCookieTable`) and the builders `buildConsentLogCollection` / `buildConsentLogEndpoint`.