[OVERWRITE=1] pnpm payload run import-cookies.ts ')
+ process.exit(2)
+}
+
+const scan = JSON.parse(readFileSync(file, 'utf8')) as { cookies: Scanned[] }
+const payload = await getPayload({ config })
+const current = (await payload.findGlobal({ slug: 'cookie-settings' as never, depth: 0, locale: locale as never })) as { cookies?: Row[] }
+const rows: Row[] = [...(current.cookies ?? [])]
+
+let added = 0
+let updated = 0
+let skipped = 0
+for (const c of scan.cookies) {
+ if (c.category === 'unknown') {
+ skipped++
+ continue
+ }
+ const existing = rows.find((r) => r.name === c.name)
+ if (!existing) {
+ rows.push({ category: c.category, duration: c.duration, name: c.name, provider: c.provider, purpose: c.purpose })
+ added++
+ continue
+ }
+ const pick = (mine: null | string | undefined, theirs?: string) => (overwrite || !mine ? (theirs ?? mine) : mine)
+ existing.provider = pick(existing.provider, c.provider)
+ existing.purpose = pick(existing.purpose, c.purpose)
+ existing.duration = pick(existing.duration, c.duration)
+ if (overwrite) {existing.category = c.category}
+ updated++
+}
+
+await payload.updateGlobal({ slug: 'cookie-settings' as never, data: { cookies: rows } as never, locale: locale as never })
+console.log(`Cookie Settings (${locale}): ${added} added, ${updated} updated, ${skipped} unknown skipped. Review them in the panel.`)
+process.exit(0)
diff --git a/docs/consent.md b/docs/consent.md
index e1b019f..dfba8e1 100644
--- a/docs/consent.md
+++ b/docs/consent.md
@@ -204,3 +204,25 @@ chcesz zachować sprzątanie locale (albo zaimportuj `LOCALE_COOKIE_NAME` i doda
> Mechanizm zgody dla locale jest opisany też od strony i18n:
> [i18n.md](./i18n.md#cookie-locale-a-zgoda-rodo).
+
+## Wersja polityki, wycofanie zgody, rejestr zgód, tabela ciasteczek (1.10)
+
+- **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 `` 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: `` (dopisywane do
+ listy domyślnej, `*` = prefiks).
+- **Równy wybór:** ` ` — „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 })` +
+ ``. Zapisuje losowy identyfikator (ten sam co w
+ ciasteczku), wybory, wersję polityki i czas — **bez IP i user-agenta**. Kolekcja *Consent records*
+ (tylko admin), automatyczne czyszczenie po `retentionDays` (domyślnie 1095). Postgres: `migrate:create`.
+- **Tabela ciasteczek** dla strony polityki: Cookie Settings → *Cookies* (wypełniana skanem,
+ skill `ipal-consent-check` → cookie-scan) + `getCookieTable` + `` z `/rsc`.
+- Ciasteczko zgody ma `Secure` na HTTPS.
+- Global Privacy Control nie jest potrzebny: w UE wszystko poza niezbędnymi i tak jest domyślnie
+ wyłączone do czasu zgody.
diff --git a/src/exports/rsc.ts b/src/exports/rsc.ts
index 9e46c90..6e1cecb 100644
--- a/src/exports/rsc.ts
+++ b/src/exports/rsc.ts
@@ -12,6 +12,8 @@ export type {
EnhanceProps,
RenderBlocksProps,
} from '../modules/blocks/index.js'
+export { CookieTable } from '../modules/consent/CookieTable.js'
+export type { CookieTableLabels } from '../modules/consent/CookieTable.js'
export { RenderRichText } from '../modules/richtext/index.js'
export type { RenderRichTextProps } from '../modules/richtext/index.js'
export { JsonLdGraph } from '../modules/seo/index.js'
diff --git a/src/globals/CookieSettings/fields.ts b/src/globals/CookieSettings/fields.ts
index d554781..8c39e70 100644
--- a/src/globals/CookieSettings/fields.ts
+++ b/src/globals/CookieSettings/fields.ts
@@ -9,6 +9,19 @@ import { CONSENT_CATEGORIES } from '../../modules/consent/categories.js'
* truth. Only the link's visible text lives here (privacyLinkLabel).
*/
export const cookieSettingsFields: Field[] = [
+ {
+ name: 'policyVersion',
+ type: 'number',
+ admin: {
+ description:
+ 'Raise by 1 when you add a tool or change the cookie policy — every visitor is asked for consent again.',
+ position: 'sidebar',
+ step: 1,
+ },
+ defaultValue: 1,
+ min: 1,
+ required: true,
+ },
{
name: 'message',
type: 'textarea',
@@ -65,4 +78,33 @@ export const cookieSettingsFields: Field[] = [
{ name: 'description', type: 'textarea', localized: true },
],
},
+ {
+ name: 'cookies',
+ type: 'array',
+ admin: {
+ description:
+ 'Cookies the site uses — shown on the cookie policy page (). Fill it from a scan: ipal-consent-check → cookie-scan.',
+ initCollapsed: true,
+ },
+ fields: [
+ {
+ type: 'row',
+ fields: [
+ { name: 'name', type: 'text', admin: { width: '40%' }, required: true },
+ { name: 'provider', type: 'text', admin: { description: 'e.g. Google, this site', width: '30%' } },
+ {
+ name: 'category',
+ type: 'select',
+ admin: { width: '30%' },
+ defaultValue: 'necessary',
+ options: CONSENT_CATEGORIES.map((c) => ({ label: c, value: c })),
+ required: true,
+ },
+ ],
+ },
+ { name: 'purpose', type: 'textarea', localized: true },
+ { name: 'duration', type: 'text', admin: { description: 'e.g. "2 years", "session"' }, localized: true },
+ ],
+ labels: { plural: 'Cookies', singular: 'Cookie' },
+ },
]
diff --git a/src/index.ts b/src/index.ts
index 80d591b..97e262e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -21,19 +21,24 @@ export type { AnalyticsConfig } from './modules/analytics/index.js'
export { getAnalyticsConfig } from './modules/analytics/index.js'
export {
ACCEPT_ALL_CONSENT,
+ buildConsentLogCollection,
+ buildConsentLogEndpoint,
CONSENT_CATEGORIES,
CONSENT_COOKIE,
+ CONSENT_LOG_SLUG,
CONSENT_MAX_AGE,
CONSENT_VERSION,
DEFAULT_CONSENT,
getConsentTexts,
+ getCookieTable,
parseConsent,
+ readConsentRecord,
REJECT_ALL_CONSENT,
serializeConsent,
setDefaultConsent,
updateConsent,
} from './modules/consent/index.js'
-export type { ConsentCategory, ConsentState, ConsentTexts } from './modules/consent/index.js'
+export type { ConsentCategory, ConsentLogOptions, ConsentState, ConsentTexts, CookieTableRow } from './modules/consent/index.js'
export type { ContentCollectionOption, ContentOption, ResolvedRoute } from './modules/content/index.js'
export {
archiveFieldName,
diff --git a/src/modules/consent/ConsentContext.tsx b/src/modules/consent/ConsentContext.tsx
index 1cbb62d..c4d180d 100644
--- a/src/modules/consent/ConsentContext.tsx
+++ b/src/modules/consent/ConsentContext.tsx
@@ -2,6 +2,7 @@
import { createContext, type ReactNode, use } from 'react'
import type { ConsentTexts } from './texts.js'
+import type { ConsentCookieMap } from './useConsent.js'
import { useConsent } from './useConsent.js'
@@ -9,8 +10,34 @@ type ConsentContextValue = { texts: ConsentTexts } & ReturnType(null)
-export function ConsentProvider({ children, texts }: { children: ReactNode; texts: ConsentTexts }) {
- const consent = useConsent()
+type ConsentProviderProps = {
+ children: ReactNode
+ /** Extra cookies per category to delete when consent is withdrawn — merged with the built-in list. */
+ cookieMap?: ConsentCookieMap
+ /**
+ * Consent log endpoint (createConsentLogEndpoint, e.g. '/api/ipal/consent'):
+ * every decision is POSTed — random id, choices, policy version, no personal
+ * data — so the site can demonstrate consent (GDPR Art. 7(1)). Off when omitted.
+ */
+ logEndpoint?: string
+ texts: ConsentTexts
+}
+
+export function ConsentProvider({ children, cookieMap, logEndpoint, texts }: ConsentProviderProps) {
+ const consent = useConsent({
+ cookieMap,
+ onDecision: logEndpoint
+ ? (record) => {
+ void fetch(logEndpoint, {
+ body: JSON.stringify(record),
+ headers: { 'content-type': 'application/json' },
+ keepalive: true,
+ method: 'POST',
+ }).catch(() => {})
+ }
+ : undefined,
+ version: texts.version,
+ })
return {children}
}
diff --git a/src/modules/consent/CookieBanner.tsx b/src/modules/consent/CookieBanner.tsx
index 00589af..efec62f 100644
--- a/src/modules/consent/CookieBanner.tsx
+++ b/src/modules/consent/CookieBanner.tsx
@@ -53,7 +53,17 @@ const strongText =
const mutedText =
'text-[var(--ipal-text-muted,#737373)] dark:text-[var(--ipal-text-muted-dark,#a3a3a3)]'
-export function CookieBanner({ classNames }: { classNames?: CookieBannerClassNames } = {}) {
+type CookieBannerProps = {
+ classNames?: CookieBannerClassNames
+ /**
+ * Style "Reject" like "Accept all" (primary). Polish and EU regulators (UODO,
+ * EDPB) expect refusing to be as easy and visible as accepting. Default false
+ * keeps the existing look; recommended true.
+ */
+ equalChoice?: boolean
+}
+
+export function CookieBanner({ classNames, equalChoice = false }: CookieBannerProps = {}) {
const isMounted = useIsMounted()
const { acceptAll, decided, rejectAll, savePreferences, state, texts } = useConsentContext()
const [showSettings, setShowSettings] = useState(false)
@@ -104,7 +114,7 @@ export function CookieBanner({ classNames }: { classNames?: CookieBannerClassNam
-