Consent (GDPR)
- Withdrawing consent now deletes GA/Meta/Ads/Clarity/LinkedIn/TikTok/Hotjar
cookies (prefix patterns) on the host AND parent domains — previously only
the locale cookie was removed and _ga & co. stayed. Projects extend the list
via <ConsentProvider cookieMap>, merged with the defaults.
- Cookie Settings → Policy version: raising it asks every visitor again.
- <CookieBanner equalChoice>: Reject styled like Accept (UODO/EDPB), opt-in.
- Opt-in consent log (ipalKit({ consentLog: true }) + logEndpoint): random id,
choices, version, time — no IP/UA; admin-only collection, retention purge.
- Cookie Settings → Cookies + getCookieTable + unstyled <CookieTable> (/rsc).
- Consent cookie gets Secure on HTTPS; consent id stored with the decision.
- ipal-consent-check: cookie-scan.mjs (before/after consent, known-tool
catalog PL/EN, flags non-necessary cookies set before consent) and
import-cookies.ts into the panel (idempotent, keeps editor edits).
Forms
- Server-side type checks per field from the panel definition: email = one
address (blocks "a@x, b@y" recipient injection into {{email}} confirmations
and CR/LF header injection), select/radio only configured options, numbers,
booleans; objects/arrays rejected; control and bidi characters stripped.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
60 lines
2.7 KiB
TypeScript
60 lines
2.7 KiB
TypeScript
/**
|
|
* Imports a cookie-scan result into Cookie Settings → Cookies (panel), so the
|
|
* cookie policy page (<CookieTable>) lists what the site really sets.
|
|
*
|
|
* LOCALE=pl pnpm payload run .agents/skills/ipal-consent-check/scripts/import-cookies.ts cookie-scan/cookies.json
|
|
* # second language: scan again with --lang en, then import with LOCALE=en
|
|
* # (rows are matched by cookie name; only purpose/duration are localized)
|
|
*
|
|
* Merges by cookie name: an editor's own purpose/duration/provider are kept
|
|
* unless OVERWRITE=1. Cookies no longer seen are kept too (remove them in the
|
|
* panel) — a scan of a few pages can miss cookies set elsewhere. `unknown`
|
|
* category rows are skipped: classify them in cookies.json first.
|
|
*/
|
|
import config from '@payload-config'
|
|
import { readFileSync } from 'node:fs'
|
|
import { getPayload } from 'payload'
|
|
|
|
type Scanned = { category: string; duration?: string; name: string; provider?: string; purpose?: string }
|
|
type Row = { category?: string; duration?: null | string; id?: string; name?: string; provider?: null | string; purpose?: null | string }
|
|
|
|
// `payload run` forwards positional args but not --flags — options come from env.
|
|
const file = process.argv.slice(2).find((a) => a.endsWith('.json'))
|
|
const locale = process.env.LOCALE
|
|
const overwrite = process.env.OVERWRITE === '1'
|
|
if (!file || !locale) {
|
|
console.error('Usage: LOCALE=<code> [OVERWRITE=1] pnpm payload run import-cookies.ts <cookies.json>')
|
|
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)
|