@luwiostack/cookie-consent 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["#granted","ConsentError","ConsentError","isConsentCategoryId","CONSENT_CATEGORIES","REQUIRED_CATEGORY","usedVendors","localStore"],"sources":["../src/domain/consent-decision.ts","../src/consent.ts","../src/formatters/consent-cookie-formatter.ts","../src/integrations/clear-revoked-cookies.ts","../src/integrations/google-consent-mode.ts","../src/integrations/unblock-scripts.ts"],"sourcesContent":["import type { ConsentCategoryId } from '../categories'\nimport { ConsentError } from '../errors'\nimport type { StoredConsent } from '../types'\n\nexport interface ConsentDecisionInput {\n consent_id: string\n policy_version: string\n granted: Iterable<ConsentCategoryId>\n decided_at: number\n}\n\n/**\n * One visitor's answer to the consent question: which categories they granted, under which policy\n * version, and when. Immutable and always valid — the factory throws on a malformed input.\n *\n * Validity over time (policy version, expiry) is not the decision's concern: the consent instance\n * decides whether a stored decision still counts.\n */\nexport class ConsentDecision {\n readonly consent_id: string\n readonly policy_version: string\n /** When the decision was made, in epoch milliseconds. */\n readonly decided_at: number\n readonly #granted: ReadonlySet<ConsentCategoryId>\n\n private constructor(input: ConsentDecisionInput) {\n this.consent_id = input.consent_id\n this.policy_version = input.policy_version\n this.decided_at = input.decided_at\n this.#granted = new Set(input.granted)\n }\n\n /** @throws {ConsentError} on an empty `consent_id` / `policy_version` or a non-finite `decided_at`. */\n static new(input: ConsentDecisionInput): ConsentDecision {\n if (typeof input.consent_id !== 'string' || input.consent_id === '') {\n throw new ConsentError('A consent decision needs a non-empty consent_id.')\n }\n if (typeof input.policy_version !== 'string' || input.policy_version === '') {\n throw new ConsentError('A consent decision needs a non-empty policy_version.')\n }\n if (typeof input.decided_at !== 'number' || !Number.isFinite(input.decided_at)) {\n throw new ConsentError('A consent decision needs decided_at as finite epoch milliseconds.')\n }\n return new ConsentDecision(input)\n }\n\n /** Like {@link ConsentDecision.new}, but returns `null` instead of throwing. */\n static tryNew(input: ConsentDecisionInput): ConsentDecision | null {\n try {\n return ConsentDecision.new(input)\n } catch {\n return null\n }\n }\n\n /** Whether this decision grants the category. */\n isGranted(id: ConsentCategoryId): boolean {\n return this.#granted.has(id)\n }\n\n /** Every granted category id. */\n granted(): ConsentCategoryId[] {\n return [...this.#granted]\n }\n\n /** Same id, version, time and granted set. */\n equals(other: ConsentDecision): boolean {\n if (\n this.consent_id !== other.consent_id ||\n this.policy_version !== other.policy_version ||\n this.decided_at !== other.decided_at ||\n this.#granted.size !== other.#granted.size\n ) {\n return false\n }\n for (const id of this.#granted) if (!other.#granted.has(id)) return false\n return true\n }\n\n /** The serialized form kept in the store. */\n toJSON(): StoredConsent {\n return {\n consent_id: this.consent_id,\n policy_version: this.policy_version,\n granted: this.granted(),\n decided_at: this.decided_at,\n }\n }\n}\n","import { localStore } from '@luwiostack/storage'\nimport {\n CONSENT_CATEGORIES,\n type ConsentCategoryId,\n isConsentCategoryId,\n REQUIRED_CATEGORY,\n} from './categories'\nimport { ConsentDecision } from './domain/consent-decision'\nimport { ConsentError } from './errors'\nimport type {\n ConsentCategoriesConfig,\n ConsentCategory,\n ConsentConfig,\n ConsentCookie,\n ConsentCookieType,\n ConsentManager,\n ConsentSnapshot,\n ConsentVendor,\n StoredConsent,\n} from './types'\nimport { usedVendors } from './used-vendors'\n\n/** The key the default `localStorage` store keeps the decision behind. */\nexport const DEFAULT_STORAGE_KEY = 'luwio.consent'\n/** The default decision lifetime: 365 days. */\nexport const DEFAULT_MAX_AGE = 365 * 24 * 60 * 60 * 1000\n\n// A stored decision dated further ahead than this is invalid: it can't have been made yet, and\n// would otherwise never expire. The margin absorbs a clock adjusted slightly back.\nconst FUTURE_TOLERANCE = 5 * 60 * 1000\n\nconst PENDING: ConsentSnapshot = Object.freeze({ status: 'pending', decision: null })\n\nconst COOKIE_TYPES: ReadonlySet<ConsentCookieType> = new Set([\n 'http',\n 'local_storage',\n 'session_storage',\n 'indexed_db',\n 'pixel',\n])\n\n/** Checks one vendor declaration: an id, unique cookie names, valid categories and lifetimes. */\nfunction validateVendor(vendor: ConsentVendor, listedIn: ConsentCategoryId): void {\n if (typeof vendor?.id !== 'string' || vendor.id === '') {\n throw new ConsentError(`Category \"${listedIn}\": a vendor id must be non-empty.`)\n }\n const where = `Vendor \"${vendor.id}\"`\n if (!Array.isArray(vendor.cookies)) throw new ConsentError(`${where}: cookies must be an array.`)\n const names = new Set<string>()\n for (const cookie of vendor.cookies) {\n if (typeof cookie.name !== 'string' || cookie.name === '') {\n throw new ConsentError(`${where}: a cookie name must be non-empty.`)\n }\n if (names.has(cookie.name)) {\n throw new ConsentError(`${where}: duplicate cookie \"${cookie.name}\".`)\n }\n names.add(cookie.name)\n if (!isConsentCategoryId(cookie.category)) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" needs a category (${CONSENT_CATEGORIES.join(', ')}).`,\n )\n }\n if (cookie.type !== undefined && !COOKIE_TYPES.has(cookie.type)) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" has an unknown type \"${cookie.type}\".`,\n )\n }\n const { max_age } = cookie\n const validAge =\n max_age === 'session' ||\n max_age === 'persistent' ||\n (typeof max_age === 'number' && Number.isFinite(max_age) && max_age > 0)\n if (!validAge) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" needs max_age as positive milliseconds, 'session' or 'persistent'.`,\n )\n }\n }\n}\n\n/**\n * Resolves the per-category config into the vendors the app actually uses: a vendor listed under a\n * category brings its cookies of that category, plus its necessary cookies (always allowed, and part\n * of any use of the service). A vendor listed under several categories is merged into one.\n */\nfunction resolveVendors(config: ConsentCategoriesConfig): {\n vendors: ConsentVendor[]\n listed: Record<ConsentCategoryId, string[]>\n} {\n if (typeof config !== 'object' || config === null || Array.isArray(config)) {\n throw new ConsentError('categories must be an object of category id → vendors.')\n }\n for (const key of Object.keys(config)) {\n if (!isConsentCategoryId(key)) {\n throw new ConsentError(\n `Unknown consent category \"${key}\" — use ${CONSENT_CATEGORIES.join(', ')}.`,\n )\n }\n }\n const merged = new Map<string, { vendor: ConsentVendor; cookies: Map<string, ConsentCookie> }>()\n const listed = Object.fromEntries(CONSENT_CATEGORIES.map((id) => [id, [] as string[]])) as Record<\n ConsentCategoryId,\n string[]\n >\n for (const category of CONSENT_CATEGORIES) {\n const inCategory = config[category]\n if (inCategory === undefined) continue\n if (!Array.isArray(inCategory as unknown)) {\n throw new ConsentError(`Category \"${category}\": vendors must be an array.`)\n }\n const seen = new Set<string>()\n for (const vendor of inCategory) {\n validateVendor(vendor, category)\n const where = `Category \"${category}\", vendor \"${vendor.id}\"`\n if (seen.has(vendor.id)) throw new ConsentError(`${where}: duplicate vendor.`)\n seen.add(vendor.id)\n listed[category].push(vendor.id)\n const picked = vendor.cookies.filter((c) => c.category === category)\n if (picked.length === 0) {\n throw new ConsentError(`${where}: the vendor has no ${category} cookies.`)\n }\n const entry = merged.get(vendor.id) ?? { vendor, cookies: new Map() }\n for (const cookie of vendor.cookies) {\n if (cookie.category === category || cookie.category === REQUIRED_CATEGORY) {\n entry.cookies.set(cookie.name, cookie)\n }\n }\n merged.set(vendor.id, entry)\n }\n }\n const vendors = [...merged.values()].map(({ vendor, cookies }) => ({\n ...vendor,\n // Keep the declaration's own cookie order.\n cookies: vendor.cookies.filter((c) => cookies.has(c.name)),\n }))\n return { vendors, listed }\n}\n\n// The id of an expired / old-version record is reused so a consent log stays linked — but only when\n// it's a usable string (the stored value may have been tampered with).\nfunction reusableId(record: StoredConsent | null): string | null {\n const id = record?.consent_id\n return typeof id === 'string' && id !== '' ? id : null\n}\n\nfunction randomId(): string {\n const c = globalThis.crypto\n if (c && typeof c.randomUUID === 'function') return c.randomUUID()\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`\n}\n\n/**\n * Create a consent instance: per category, the vendors the app uses there (a vendor brings only its\n * cookies of that category, plus its necessary ones), where the decision is kept, and when it must\n * be asked again. Create it once (module\n * scope is fine — storage is only touched on access, so it's SSR-safe) and hand it to\n * `<Consent consent={…}>` in React, or use it directly.\n *\n * ```ts\n * import { googleAnalytics, youtube } from '@luwiostack/cookie-consent/vendors'\n *\n * const consent = createConsent({\n * categories: {\n * statistics: [googleAnalytics()],\n * preferences: [youtube()], // the embed only — no YouTube tracking cookies\n * },\n * policyVersion: 2,\n * })\n * consent.isGranted('preferences', 'youtube') // the embed may load\n * consent.isGranted('marketing', 'youtube') // false — not used there\n * ```\n *\n * @throws {ConsentError} for an invalid `maxAge`, an unknown category, or an invalid vendor (listed\n * twice in a category, no cookies of the category it's listed in, duplicate cookie, empty name,\n * missing cookie category, bad `max_age` / `type`).\n */\nexport function createConsent(config: ConsentConfig = {}): ConsentManager {\n const { vendors, listed } = resolveVendors(config.categories ?? {})\n\n // Each category with the vendors that have cookies in it, cookies narrowed to that category: the\n // ones listed there in config order, then (for necessary) the others that bring necessary cookies.\n const byId = new Map(vendors.map((v) => [v.id, v]))\n const categories: readonly ConsentCategory[] = CONSENT_CATEGORIES.map((id) => {\n const ids = [...new Set([...listed[id], ...vendors.map((v) => v.id)])]\n return {\n id,\n required: id === REQUIRED_CATEGORY,\n vendors: ids.flatMap((vendorId) => {\n const vendor = byId.get(vendorId) as ConsentVendor\n const cookies = vendor.cookies.filter((c) => c.category === id)\n return cookies.length > 0 ? [{ ...vendor, cookies }] : []\n }),\n }\n })\n const usedIn = usedVendors(categories)\n\n const maxAge = config.maxAge ?? DEFAULT_MAX_AGE\n if (typeof maxAge !== 'number' || Number.isNaN(maxAge) || maxAge <= 0) {\n throw new ConsentError('maxAge must be a positive number of milliseconds.')\n }\n const policyVersion = String(config.policyVersion ?? 1)\n // Persisting the decision is best-effort: where storage is blocked or full, the default store fails\n // quietly instead of throwing out of acceptAll() & co. A store you pass in keeps its own onError.\n const store =\n config.store ?? localStore<StoredConsent>(DEFAULT_STORAGE_KEY, { onError: 'ignore' })\n const now = config.now ?? Date.now\n\n // A decision the store didn't keep (storage blocked or full, a store with onError 'ignore') is held\n // here for the rest of the page's life — so the banner closes and the visitor's choice applies,\n // instead of being asked again on every click. `undefined`: the store is the source of truth.\n let unsaved: StoredConsent | null | undefined\n const listeners = new Set<() => void>()\n const notify = () => {\n for (const fn of [...listeners]) fn()\n }\n const read = (): StoredConsent | null => (unsaved !== undefined ? unsaved : store.read())\n\n // Snapshot memo: the store's read() is referentially stable between changes, so caching on the raw\n // record (plus whether it has expired since) keeps getSnapshot() stable for useSyncExternalStore.\n let lastRecord: StoredConsent | null | undefined\n let lastExpired = false\n let lastSnapshot: ConsentSnapshot = PENDING\n\n function toDecision(record: StoredConsent): ConsentDecision | null {\n if (record.policy_version !== policyVersion) return null\n if (!Array.isArray(record.granted)) return null\n // Unknown ids (a tampered record) are dropped; necessary is always in.\n const granted = new Set<ConsentCategoryId>([REQUIRED_CATEGORY])\n for (const id of record.granted) if (isConsentCategoryId(id)) granted.add(id)\n return ConsentDecision.tryNew({ ...record, granted })\n }\n\n function getSnapshot(): ConsentSnapshot {\n const record = read()\n const age = record === null ? 0 : now() - record.decided_at\n const expired = record !== null && (age > maxAge || age < -FUTURE_TOLERANCE)\n if (record === lastRecord && expired === lastExpired) return lastSnapshot\n lastRecord = record\n lastExpired = expired\n const decision = record && !expired ? toDecision(record) : null\n lastSnapshot = decision ? Object.freeze({ status: 'decided', decision }) : PENDING\n return lastSnapshot\n }\n\n function current(): ConsentDecision | null {\n return getSnapshot().decision\n }\n\n function commit(granted: Iterable<ConsentCategoryId>): ConsentDecision {\n const previous = current()\n const set = new Set<ConsentCategoryId>([REQUIRED_CATEGORY])\n for (const id of granted) if (isConsentCategoryId(id)) set.add(id)\n const next = ConsentDecision.new({\n // Keep the visitor's consent id across changes, so a consent log can link them.\n consent_id: previous?.consent_id ?? reusableId(read()) ?? randomId(),\n policy_version: policyVersion,\n // Keep the categories' configured order in storage.\n granted: CONSENT_CATEGORIES.filter((id) => set.has(id)),\n decided_at: now(),\n })\n const record = next.toJSON()\n store.write(record)\n // Did it land? A store that fails quietly reads back the old value (or nothing).\n const kept = store.read()\n const landed = kept?.consent_id === record.consent_id && kept?.decided_at === record.decided_at\n unsaved = landed ? undefined : record\n if (!landed) notify() // the store announced nothing\n config.onChange?.(next, previous)\n return next\n }\n\n const isRequired = (id: ConsentCategoryId) => id === REQUIRED_CATEGORY\n const isGranted = (id: ConsentCategoryId, vendorId?: string) =>\n (vendorId === undefined || usedIn[id].has(vendorId)) &&\n (isRequired(id) || (current()?.isGranted(id) ?? false))\n\n return {\n categories,\n vendors,\n policyVersion,\n getSnapshot,\n subscribe: (onChange) => {\n listeners.add(onChange)\n const unsubscribe = store.subscribe(onChange)\n return () => {\n listeners.delete(onChange)\n unsubscribe()\n }\n },\n isGranted,\n isRequired,\n acceptAll: () => commit(CONSENT_CATEGORIES),\n rejectAll: () => commit([]),\n save: (granted) => commit(granted),\n grant: (...grant) => commit([...(current()?.granted() ?? []), ...grant]),\n revoke: (...revoke) => {\n const drop = new Set(revoke)\n return commit((current()?.granted() ?? []).filter((id) => !drop.has(id)))\n },\n reset: () => {\n const previous = current()\n store.clear()\n if (unsaved !== undefined) {\n unsaved = undefined\n notify()\n }\n config.onChange?.(null, previous)\n },\n }\n}\n","import type { ConsentCookie } from '../types'\n\nexport interface ConsentCookieFormatOptions {\n /** How unit names are written: `long` (\"2 years\"), `short` (\"2 yrs\"), `narrow` (\"2y\"). Default `long`. */\n unitDisplay?: 'long' | 'short' | 'narrow'\n}\n\nconst SECOND = 1000\nconst MINUTE = 60 * SECOND\nconst HOUR = 60 * MINUTE\nconst DAY = 24 * HOUR\n\n// Largest first. A month counts as 30 days and a year as 365 — how cookie declarations are written\n// (\"3 months\" for 90 days, \"13 months\" for 390), not calendar arithmetic.\nconst UNITS = [\n ['year', 365 * DAY],\n ['month', 30 * DAY],\n ['day', DAY],\n ['hour', HOUR],\n ['minute', MINUTE],\n ['second', SECOND],\n] as const\n\n/** Renders a cookie declaration's values for people. */\nexport class ConsentCookieFormatter {\n /**\n * A cookie's lifetime in `locale`, in the largest unit that divides it evenly: 2 years, 3 months,\n * 400 days, 30 minutes — falling back to whole days (or the largest unit that fits) when nothing\n * divides evenly. Returns `null` for `'session'` and `'persistent'`: those are words, so render\n * them through your own translations.\n */\n static formatLocale(\n cookie: Pick<ConsentCookie, 'max_age'>,\n locale: Intl.Locale,\n options: ConsentCookieFormatOptions = {},\n ): string | null {\n const { max_age } = cookie\n if (typeof max_age !== 'number') return null\n const unitDisplay = options.unitDisplay ?? 'long'\n const exact = UNITS.find(([, ms]) => max_age >= ms && max_age % ms === 0)\n const [unit, ms] =\n exact ?? (max_age >= DAY ? UNITS[2] : (UNITS.find(([, u]) => max_age >= u) ?? UNITS[5]))\n const value = Math.max(1, Math.round(max_age / ms))\n return new Intl.NumberFormat(locale.toString(), { style: 'unit', unit, unitDisplay }).format(\n value,\n )\n }\n}\n","import { REQUIRED_CATEGORY } from '../categories'\nimport type { ConsentCookie, ConsentManager } from '../types'\n\nexport interface ClearRevokedCookiesOptions {\n /**\n * Called once per item actually removed, with the declaration and the real name (a wildcard\n * `_ga_*` resolves to `_ga_ABC123`) — to log it, or to reload the page so running scripts stop.\n */\n onClear?: (cookie: ConsentCookie, actualName: string) => void\n}\n\n/** A declared name as a matcher: `*` matches any run of characters (`_ga_*`, `ttcsid*`). */\nfunction matcher(name: string): (actual: string) => boolean {\n if (!name.includes('*')) return (actual) => actual === name\n const pattern = name.split('*').map((part) => part.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n const re = new RegExp(`^${pattern.join('.*')}$`)\n return (actual) => re.test(actual)\n}\n\n/**\n * The domains a first-party cookie may have been set for: none (host-only), the host itself, and\n * each parent domain (`www.shop.example.com` → `shop.example.com`, `example.com`). Analytics tags\n * usually set theirs on the registrable domain, so deleting needs the same `Domain` attribute.\n * A bare top-level domain (`com`) is never a valid cookie domain, so it's left out.\n * @internal\n */\nexport function domainCandidates(hostname: string): (string | undefined)[] {\n const parts = hostname.split('.')\n const parents: string[] = []\n for (let i = 0; i < parts.length - 1; i++) parents.push(parts.slice(i).join('.'))\n return [undefined, ...parents]\n}\n\n/** The paths a cookie may have been set for, from this page up to the root: `/a/b` → `/a/b`, `/a`, `/`. @internal */\nexport function pathCandidates(pathname: string): string[] {\n const segments = pathname.split('/').filter(Boolean)\n const paths = ['/']\n for (let i = 1; i <= segments.length; i++) paths.push(`/${segments.slice(0, i).join('/')}`)\n return paths\n}\n\nfunction cookieNames(doc: Document): string[] {\n return doc.cookie\n .split(';')\n .map((pair) => pair.slice(0, pair.indexOf('=') === -1 ? undefined : pair.indexOf('=')).trim())\n .filter(Boolean)\n}\n\nfunction expireCookie(doc: Document, name: string): void {\n const { hostname, pathname } = doc.location\n for (const domain of domainCandidates(hostname)) {\n for (const path of pathCandidates(pathname)) {\n doc.cookie = `${name}=; Path=${path}${domain ? `; Domain=${domain}` : ''}; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT`\n }\n }\n}\n\nfunction storageKeys(storage: Storage): string[] {\n const keys: string[] = []\n for (let i = 0; i < storage.length; i++) {\n const key = storage.key(i)\n if (key !== null) keys.push(key)\n }\n return keys\n}\n\n/**\n * Remove what a withdrawn category left behind. At start and on every change, the declared cookies\n * and storage items of every category that isn't granted are deleted — after \"withdraw statistics\",\n * `_ga` and `_ga_*` are gone, not just unused. `necessary` is never touched, and a name a granted\n * category also declares is kept.\n *\n * Only **first-party** storage can be reached: cookies on your own domain (tried with every parent\n * domain and path, since tags set them broadly), `localStorage` / `sessionStorage` items and\n * IndexedDB databases. A third-party cookie (`IDE` on doubleclick.net) lives on another site and\n * can't be removed from yours; `HttpOnly` cookies only by your server. Scripts already running keep\n * running — reload the page (e.g. from `onClear`) to stop them.\n *\n * Returns a stop function. A no-op on the server.\n */\nexport function clearRevokedCookies(\n consent: ConsentManager,\n options: ClearRevokedCookiesOptions = {},\n): () => void {\n if (typeof document === 'undefined') return () => {}\n\n const clear = () => {\n // What a granted category declares stays — even when a revoked one declares the same name.\n const kept: ((actual: string) => boolean)[] = []\n const revoked: ConsentCookie[] = []\n for (const category of consent.categories) {\n const granted = category.id === REQUIRED_CATEGORY || consent.isGranted(category.id)\n for (const vendor of category.vendors) {\n for (const cookie of vendor.cookies) {\n if (granted) kept.push(matcher(cookie.name))\n else revoked.push(cookie)\n }\n }\n }\n if (revoked.length === 0) return\n const isKept = (actual: string) => kept.some((matches) => matches(actual))\n const cleared = (cookie: ConsentCookie, actual: string) => options.onClear?.(cookie, actual)\n\n for (const cookie of revoked) {\n const matches = matcher(cookie.name)\n const type = cookie.type ?? 'http'\n if (type === 'http') {\n for (const actual of cookieNames(document)) {\n if (!matches(actual) || isKept(actual)) continue\n expireCookie(document, actual)\n // Reported only once it's really gone (no domain/path variant may have matched).\n if (!cookieNames(document).includes(actual)) cleared(cookie, actual)\n }\n } else if (type === 'local_storage' || type === 'session_storage') {\n let storage: Storage | undefined\n try {\n storage = type === 'local_storage' ? window.localStorage : window.sessionStorage\n } catch {\n continue // Storage blocked: there's nothing to remove either.\n }\n for (const actual of storageKeys(storage)) {\n if (!matches(actual) || isKept(actual)) continue\n storage.removeItem(actual)\n cleared(cookie, actual)\n }\n } else if (type === 'indexed_db' && typeof indexedDB !== 'undefined') {\n if (typeof indexedDB.databases === 'function') {\n void indexedDB.databases().then((databases) => {\n for (const { name } of databases) {\n if (!name || !matches(name) || isKept(name)) continue\n indexedDB.deleteDatabase(name)\n cleared(cookie, name)\n }\n })\n } else if (!cookie.name.includes('*') && !isKept(cookie.name)) {\n // No list of databases (older browsers): delete by exact name — deleting a database that\n // doesn't exist is harmless, but it isn't reported, since it may never have been there.\n indexedDB.deleteDatabase(cookie.name)\n }\n }\n // 'pixel': nothing is stored on the visitor's device.\n }\n }\n\n clear()\n return consent.subscribe(clear)\n}\n","import type { ConsentCategoryId } from '../categories'\nimport type { ConsentManager } from '../types'\n\n/** The Google Consent Mode v2 signals. */\nexport type GoogleConsentSignal =\n | 'ad_storage'\n | 'ad_user_data'\n | 'ad_personalization'\n | 'analytics_storage'\n | 'functionality_storage'\n | 'personalization_storage'\n | 'security_storage'\n\nexport type GoogleConsentValue = 'granted' | 'denied'\n\n/** Which category (or categories — all must be granted) drives each signal. Unmapped signals aren't sent. */\nexport type GoogleConsentMapping = Partial<\n Record<GoogleConsentSignal, ConsentCategoryId | readonly ConsentCategoryId[]>\n>\n\n/** The standard mapping of Google's signals onto the fixed categories — the default. */\nexport const DEFAULT_GOOGLE_CONSENT_MAPPING = {\n ad_storage: 'marketing',\n ad_user_data: 'marketing',\n ad_personalization: 'marketing',\n analytics_storage: 'statistics',\n functionality_storage: 'preferences',\n personalization_storage: 'preferences',\n security_storage: 'necessary',\n} as const satisfies Required<GoogleConsentMapping>\n\ntype Gtag = (...args: unknown[]) => void\n\nexport interface GoogleConsentModeOptions {\n /**\n * Which category drives each signal. Default {@link DEFAULT_GOOGLE_CONSENT_MAPPING} (ads →\n * marketing, analytics → statistics, functionality / personalization → preferences, security →\n * necessary). A custom mapping sends only the signals it lists; a signal mapped to several\n * categories is granted only when all are.\n */\n mapping?: GoogleConsentMapping\n /** Milliseconds Google tags wait for an `update` after the `default` command. Default `500`. */\n waitForUpdate?: number\n /** Restrict the `default` command to these ISO 3166-2 regions (e.g. `['BE', 'NL']`). */\n region?: readonly string[]\n /** Send `ads_data_redaction: true` while ad storage is denied. Default `false`. */\n adsDataRedaction?: boolean\n /** Send `url_passthrough: true`. Default `false`. */\n urlPassthrough?: boolean\n /** The `gtag` function. Default `window.gtag`, defined as the standard `dataLayer` stub if absent. */\n gtag?: Gtag\n}\n\ntype GtagWindow = Window & { dataLayer?: unknown[]; gtag?: Gtag }\n\nfunction resolveGtag(): Gtag | undefined {\n if (typeof window === 'undefined') return undefined\n const w = window as GtagWindow\n if (typeof w.gtag === 'function') return w.gtag\n w.dataLayer = w.dataLayer ?? []\n const dataLayer = w.dataLayer\n // Google's own stub: it must push the `arguments` object, not an array — gtag.js tells them apart.\n w.gtag = function gtag() {\n // biome-ignore lint/complexity/noArguments: gtag.js requires the Arguments object\n dataLayer.push(arguments)\n }\n return w.gtag\n}\n\n/**\n * Wire a consent instance to Google Consent Mode v2: sends `gtag('consent', 'default', …)` with every\n * mapped signal denied (signals mapped to required categories granted), then an `update` with the\n * visitor's decision — immediately when one is stored, and again on every change.\n *\n * Call it **before** the Google tag (gtag.js / GTM) loads, so the default is in place for its first\n * hit. Returns an unsubscribe. A no-op on the server.\n */\nexport function googleConsentMode(\n consent: ConsentManager,\n options: GoogleConsentModeOptions = {},\n): () => void {\n const gtag = options.gtag ?? resolveGtag()\n if (!gtag) return () => {}\n\n type Id = ConsentCategoryId\n const entries = Object.entries(options.mapping ?? DEFAULT_GOOGLE_CONSENT_MAPPING) as [\n GoogleConsentSignal,\n Id | readonly Id[],\n ][]\n\n const signals = (isGranted: (id: Id) => boolean) => {\n const out: Partial<Record<GoogleConsentSignal, GoogleConsentValue>> = {}\n for (const [signal, cat] of entries) {\n const list = (typeof cat === 'string' ? [cat] : cat) as readonly Id[]\n out[signal] = list.every(isGranted) ? 'granted' : 'denied'\n }\n return out\n }\n\n if (options.adsDataRedaction) gtag('set', 'ads_data_redaction', true)\n if (options.urlPassthrough) gtag('set', 'url_passthrough', true)\n\n gtag('consent', 'default', {\n ...signals((id) => consent.isRequired(id)),\n wait_for_update: options.waitForUpdate ?? 500,\n ...(options.region ? { region: [...options.region] } : {}),\n })\n\n let last = ''\n const sync = () => {\n if (consent.getSnapshot().status !== 'decided' && last === '') return\n const next = signals((id) => consent.isGranted(id))\n const key = JSON.stringify(next)\n if (key === last) return\n last = key\n gtag('consent', 'update', next)\n }\n sync()\n return consent.subscribe(sync)\n}\n","import type { ConsentCategoryId } from '../categories'\nimport type { ConsentManager } from '../types'\n\nexport interface UnblockScriptsOptions {\n /** Where to look. Default `document`. */\n root?: ParentNode\n /** The attribute naming the required categories (space-separated, all must be granted). Default `data-consent`. */\n attribute?: string\n /**\n * The attribute naming the vendor, which must then be used in those categories — an element whose\n * vendor isn't configured there stays blocked. Default `data-consent-vendor`.\n */\n vendorAttribute?: string\n /** Also activate matching elements added to the page later (a `MutationObserver`). Default `true`. */\n observe?: boolean\n}\n\n/**\n * Hold third-party scripts and embeds back until their category is granted — mark them up blocked and\n * this activates them the moment consent allows (on load, and on every later change):\n *\n * ```html\n * <!-- a script: type=\"text/plain\" so the browser doesn't run it; data-type restores a module type -->\n * <script type=\"text/plain\" data-consent=\"statistics\" src=\"https://example.com/analytics.js\"></script>\n * <script type=\"text/plain\" data-consent=\"marketing\">trackPageView()</script>\n *\n * <!-- with a vendor: also only while that vendor is used in the category -->\n * <script type=\"text/plain\" data-consent=\"marketing\" data-consent-vendor=\"meta_pixel\">fbq(…)</script>\n *\n * <!-- an iframe / img: data-src instead of src -->\n * <iframe data-consent=\"marketing\" data-src=\"https://www.youtube-nocookie.com/embed/…\"></iframe>\n * ```\n *\n * A script is replaced by a fresh `<script>` copy (the only way to make the browser run it), its\n * CSP `nonce` included; an embed gets its `src` from `data-src`. Activation is one-way: a revoked category can't un-run a\n * script — reload the page from `onChange` when something is withdrawn. Returns a stop function.\n */\nexport function unblockScripts(\n consent: ConsentManager,\n options: UnblockScriptsOptions = {},\n): () => void {\n if (typeof document === 'undefined') return () => {}\n const root = options.root ?? document\n const attr = options.attribute ?? 'data-consent'\n const vendorAttr = options.vendorAttribute ?? 'data-consent-vendor'\n\n const allowed = (el: Element) => {\n const ids = (el.getAttribute(attr) ?? '').split(/\\s+/).filter(Boolean) as ConsentCategoryId[]\n const vendor = el.getAttribute(vendorAttr) ?? undefined\n return ids.length > 0 && ids.every((id) => consent.isGranted(id, vendor))\n }\n\n const activate = () => {\n for (const el of Array.from(root.querySelectorAll(`script[type=\"text/plain\"][${attr}]`))) {\n if (!allowed(el)) continue\n const script = document.createElement('script')\n for (const { name, value } of Array.from(el.attributes)) {\n if (name === 'type' || name === 'data-type') continue\n script.setAttribute(name, value)\n }\n const type = el.getAttribute('data-type')\n if (type) script.setAttribute('type', type)\n // Under a Content-Security-Policy header, browsers hide a script's nonce from getAttribute()\n // (\"nonce hiding\") — only the property keeps it. Without this the copy fails the CSP check.\n const { nonce } = el as HTMLScriptElement\n if (nonce) script.nonce = nonce\n if (!el.hasAttribute('src')) script.text = el.textContent ?? ''\n el.replaceWith(script)\n }\n for (const el of Array.from(root.querySelectorAll(`[${attr}][data-src]:not(script)`))) {\n if (!allowed(el)) continue\n const src = el.getAttribute('data-src')\n el.removeAttribute('data-src')\n if (src) el.setAttribute('src', src)\n }\n }\n\n activate()\n const unsubscribe = consent.subscribe(activate)\n\n let observer: MutationObserver | undefined\n if ((options.observe ?? true) && typeof MutationObserver !== 'undefined') {\n observer = new MutationObserver((records) => {\n if (records.some((r) => r.addedNodes.length > 0)) activate()\n })\n const target = root instanceof Document ? root.documentElement : (root as Node)\n observer.observe(target, { childList: true, subtree: true })\n }\n\n return () => {\n unsubscribe()\n observer?.disconnect()\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAa,kBAAb,MAAa,gBAAgB;CAC3B;CACA;;CAEA;CACA;CAEA,YAAoB,OAA6B;EAC/C,KAAK,aAAa,MAAM;EACxB,KAAK,iBAAiB,MAAM;EAC5B,KAAK,aAAa,MAAM;EACxB,KAAKA,WAAW,IAAI,IAAI,MAAM,OAAO;CACvC;;CAGA,OAAO,IAAI,OAA8C;EACvD,IAAI,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,IAC/D,MAAM,IAAIC,eAAAA,aAAa,kDAAkD;EAE3E,IAAI,OAAO,MAAM,mBAAmB,YAAY,MAAM,mBAAmB,IACvE,MAAM,IAAIA,eAAAA,aAAa,sDAAsD;EAE/E,IAAI,OAAO,MAAM,eAAe,YAAY,CAAC,OAAO,SAAS,MAAM,UAAU,GAC3E,MAAM,IAAIA,eAAAA,aAAa,mEAAmE;EAE5F,OAAO,IAAI,gBAAgB,KAAK;CAClC;;CAGA,OAAO,OAAO,OAAqD;EACjE,IAAI;GACF,OAAO,gBAAgB,IAAI,KAAK;EAClC,QAAQ;G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KAAK,GAAG,OAAO,OAAO,GAAG,eAAe;GAC7D,GAAG,YAAY,MAAM;EACvB;EACA,KAAK,MAAM,MAAM,MAAM,KAAK,KAAK,iBAAiB,IAAI,KAAK,wBAAwB,CAAC,GAAG;GACrF,IAAI,CAAC,QAAQ,EAAE,GAAG;GAClB,MAAM,MAAM,GAAG,aAAa,UAAU;GACtC,GAAG,gBAAgB,UAAU;GAC7B,IAAI,KAAK,GAAG,aAAa,OAAO,GAAG;EACrC;CACF;CAEA,SAAS;CACT,MAAM,cAAc,QAAQ,UAAU,QAAQ;CAE9C,IAAI;CACJ,KAAK,QAAQ,WAAW,SAAS,OAAO,qBAAqB,aAAa;EACxE,WAAW,IAAI,kBAAkB,YAAY;GAC3C,IAAI,QAAQ,MAAM,MAAM,EAAE,WAAW,SAAS,CAAC,GAAG,SAAS;EAC7D,CAAC;EACD,MAAM,SAAS,gBAAgB,WAAW,KAAK,kBAAmB;EAClE,SAAS,QAAQ,QAAQ;GAAE,WAAW;GAAM,SAAS;EAAK,CAAC;CAC7D;CAEA,aAAa;EACX,YAAY;EACZ,UAAU,WAAW;CACvB;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["#granted","ConsentError","ConsentError","isConsentCategoryId","CONSENT_CATEGORIES","toConsentVendor","categoryMachineName","REQUIRED_CATEGORY","usedVendors","localStore"],"sources":["../src/domain/consent-decision.ts","../src/consent.ts","../src/formatters/consent-cookie-formatter.ts","../src/integrations/clear-revoked-cookies.ts","../src/integrations/unblock-scripts.ts"],"sourcesContent":["import type { ConsentCategoryId } from '../categories'\nimport { ConsentError } from '../errors'\nimport type { StoredConsent } from '../types'\n\nexport interface ConsentDecisionInput {\n consent_id: string\n policy_version: string\n granted: Iterable<ConsentCategoryId>\n decided_at: number\n}\n\n/**\n * One visitor's answer to the consent question: which categories they granted, under which policy\n * version, and when. Immutable and always valid — the factory throws on a malformed input.\n *\n * Validity over time (policy version, expiry) is not the decision's concern: the consent instance\n * decides whether a stored decision still counts.\n */\nexport class ConsentDecision {\n readonly consent_id: string\n readonly policy_version: string\n /** When the decision was made, in epoch milliseconds. */\n readonly decided_at: number\n readonly #granted: ReadonlySet<ConsentCategoryId>\n\n private constructor(input: ConsentDecisionInput) {\n this.consent_id = input.consent_id\n this.policy_version = input.policy_version\n this.decided_at = input.decided_at\n this.#granted = new Set(input.granted)\n }\n\n /** @throws {ConsentError} on an empty `consent_id` / `policy_version` or a non-finite `decided_at`. */\n static new(input: ConsentDecisionInput): ConsentDecision {\n if (typeof input.consent_id !== 'string' || input.consent_id === '') {\n throw new ConsentError('A consent decision needs a non-empty consent_id.')\n }\n if (typeof input.policy_version !== 'string' || input.policy_version === '') {\n throw new ConsentError('A consent decision needs a non-empty policy_version.')\n }\n if (typeof input.decided_at !== 'number' || !Number.isFinite(input.decided_at)) {\n throw new ConsentError('A consent decision needs decided_at as finite epoch milliseconds.')\n }\n return new ConsentDecision(input)\n }\n\n /** Like {@link ConsentDecision.new}, but returns `null` instead of throwing. */\n static tryNew(input: ConsentDecisionInput): ConsentDecision | null {\n try {\n return ConsentDecision.new(input)\n } catch {\n return null\n }\n }\n\n /** Whether this decision grants the category. */\n isGranted(id: ConsentCategoryId): boolean {\n return this.#granted.has(id)\n }\n\n /** Every granted category id. */\n granted(): ConsentCategoryId[] {\n return [...this.#granted]\n }\n\n /** Same id, version, time and granted set. */\n equals(other: ConsentDecision): boolean {\n if (\n this.consent_id !== other.consent_id ||\n this.policy_version !== other.policy_version ||\n this.decided_at !== other.decided_at ||\n this.#granted.size !== other.#granted.size\n ) {\n return false\n }\n for (const id of this.#granted) if (!other.#granted.has(id)) return false\n return true\n }\n\n /** The serialized form kept in the store. */\n toJSON(): StoredConsent {\n return {\n consent_id: this.consent_id,\n policy_version: this.policy_version,\n granted: this.granted(),\n decided_at: this.decided_at,\n }\n }\n}\n","import { localStore } from '@luwiostack/storage'\nimport {\n CONSENT_CATEGORIES,\n type ConsentCategoryId,\n isConsentCategoryId,\n REQUIRED_CATEGORY,\n} from './categories'\nimport { ConsentDecision } from './domain/consent-decision'\nimport { ConsentError } from './errors'\nimport { categoryMachineName, toConsentVendor } from './machine-names'\nimport type {\n ConsentCategoriesConfig,\n ConsentCategory,\n ConsentConfig,\n ConsentCookie,\n ConsentCookieDeclaration,\n ConsentCookieType,\n ConsentManager,\n ConsentSnapshot,\n ConsentTransferDeclaration,\n ConsentTransferSafeguard,\n ConsentVendor,\n ConsentVendorDeclaration,\n StoredConsent,\n} from './types'\nimport { usedVendors } from './used-vendors'\n\n/** The key the default `localStorage` store keeps the decision behind. */\nexport const DEFAULT_STORAGE_KEY = 'luwio.consent'\n/** The default decision lifetime: 365 days. */\nexport const DEFAULT_MAX_AGE = 365 * 24 * 60 * 60 * 1000\n\n// A stored decision dated further ahead than this is invalid: it can't have been made yet, and\n// would otherwise never expire. The margin absorbs a clock adjusted slightly back.\nconst FUTURE_TOLERANCE = 5 * 60 * 1000\n\nconst PENDING: ConsentSnapshot = Object.freeze({ status: 'pending', decision: null })\n\nconst COOKIE_TYPES: ReadonlySet<ConsentCookieType> = new Set([\n 'http',\n 'local_storage',\n 'session_storage',\n 'indexed_db',\n 'pixel',\n])\n\n/** Checks one vendor declaration: an id, unique cookie names, valid categories and lifetimes. */\nfunction validateVendor(vendor: ConsentVendorDeclaration, listedIn: ConsentCategoryId): void {\n if (typeof vendor?.id !== 'string' || vendor.id === '') {\n throw new ConsentError(`Category \"${listedIn}\": a vendor id must be non-empty.`)\n }\n const where = `Vendor \"${vendor.id}\"`\n if (!Array.isArray(vendor.cookies)) throw new ConsentError(`${where}: cookies must be an array.`)\n validateTransfers(vendor.transfers, where)\n const names = new Set<string>()\n for (const cookie of vendor.cookies as unknown[] as ConsentCookieDeclaration[]) {\n if (typeof cookie !== 'object' || cookie === null) {\n throw new ConsentError(`${where}: every cookie must be an object.`)\n }\n if (typeof cookie.name !== 'string' || cookie.name === '') {\n throw new ConsentError(`${where}: a cookie name must be non-empty.`)\n }\n if (names.has(cookie.name)) {\n throw new ConsentError(`${where}: duplicate cookie \"${cookie.name}\".`)\n }\n names.add(cookie.name)\n if (!isConsentCategoryId(cookie.category)) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" needs a category (${CONSENT_CATEGORIES.join(', ')}).`,\n )\n }\n if (cookie.type !== undefined && !COOKIE_TYPES.has(cookie.type)) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" has an unknown type \"${cookie.type}\".`,\n )\n }\n const { max_age } = cookie\n const validAge =\n max_age === 'session' ||\n max_age === 'persistent' ||\n (typeof max_age === 'number' && Number.isFinite(max_age) && max_age > 0)\n if (!validAge) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" needs max_age as positive milliseconds, 'session' or 'persistent'.`,\n )\n }\n if (\n cookie.domain !== undefined &&\n (typeof cookie.domain !== 'string' || !DOMAIN.test(cookie.domain))\n ) {\n throw new ConsentError(\n `${where}: cookie \"${cookie.name}\" needs domain as a host name like \".youtube.com\", or none for the site's own domain.`,\n )\n }\n }\n}\n\n/** A cookie domain: a host name, optionally with a leading dot, no scheme, port or path. */\nconst DOMAIN = /^\\.?[a-z0-9-]+(\\.[a-z0-9-]+)+$/i\n\nconst SAFEGUARDS: ReadonlySet<ConsentTransferSafeguard> = new Set(['adequacy', 'dpf', 'scc', 'bcr'])\n\n/** Transfers: absent, or per unique ISO alpha-2 country at least one known safeguard. */\nfunction validateTransfers(transfers: unknown, where: string): void {\n if (transfers === undefined) return\n if (!Array.isArray(transfers)) throw new ConsentError(`${where}: transfers must be an array.`)\n const countries = new Set<string>()\n for (const transfer of transfers as ConsentTransferDeclaration[]) {\n const country = transfer?.country\n if (typeof country !== 'string' || !/^[A-Z]{2}$/.test(country)) {\n throw new ConsentError(`${where}: a transfer needs country as ISO alpha-2, e.g. \"US\".`)\n }\n if (countries.has(country)) throw new ConsentError(`${where}: duplicate transfer \"${country}\".`)\n countries.add(country)\n const { safeguards } = transfer\n if (\n !Array.isArray(safeguards) ||\n safeguards.length === 0 ||\n !safeguards.every((s) => SAFEGUARDS.has(s))\n ) {\n throw new ConsentError(\n `${where}: transfer \"${country}\" needs safeguards from ${[...SAFEGUARDS].join(', ')}.`,\n )\n }\n }\n}\n\n/**\n * Resolves the per-category config into the vendors the app actually uses: a vendor listed under a\n * category brings its cookies of that category, plus its necessary cookies (always allowed, and part\n * of any use of the service). A vendor listed under several categories is merged into one.\n */\nfunction resolveVendors(config: ConsentCategoriesConfig): {\n vendors: ConsentVendor[]\n listed: Record<ConsentCategoryId, string[]>\n} {\n if (typeof config !== 'object' || config === null || Array.isArray(config)) {\n throw new ConsentError('categories must be an object of category id → vendors.')\n }\n for (const key of Object.keys(config)) {\n if (!isConsentCategoryId(key)) {\n throw new ConsentError(\n `Unknown consent category \"${key}\" — use ${CONSENT_CATEGORIES.join(', ')}.`,\n )\n }\n }\n const merged = new Map<string, { vendor: ConsentVendor; cookies: Map<string, ConsentCookie> }>()\n // Two ids may not share a machine name: their translation keys would collide.\n const idByMachineName = new Map<string, string>()\n const listed = Object.fromEntries(CONSENT_CATEGORIES.map((id) => [id, [] as string[]])) as Record<\n ConsentCategoryId,\n string[]\n >\n for (const category of CONSENT_CATEGORIES) {\n const inCategory = config[category]\n if (inCategory === undefined) continue\n if (!Array.isArray(inCategory as unknown)) {\n throw new ConsentError(`Category \"${category}\": vendors must be an array.`)\n }\n const seen = new Set<string>()\n for (const declaration of inCategory) {\n validateVendor(declaration, category)\n const vendor = toConsentVendor(declaration)\n const other = idByMachineName.get(vendor.machine_name)\n if (other !== undefined && other !== vendor.id) {\n throw new ConsentError(\n `Vendors \"${other}\" and \"${vendor.id}\" have the same machine name \"${vendor.machine_name}\".`,\n )\n }\n idByMachineName.set(vendor.machine_name, vendor.id)\n const where = `Category \"${category}\", vendor \"${vendor.id}\"`\n if (seen.has(vendor.id)) throw new ConsentError(`${where}: duplicate vendor.`)\n seen.add(vendor.id)\n listed[category].push(vendor.id)\n const picked = vendor.cookies.filter((c) => c.category === category)\n if (picked.length === 0) {\n throw new ConsentError(`${where}: the vendor has no ${category} cookies.`)\n }\n const entry = merged.get(vendor.id) ?? { vendor, cookies: new Map() }\n if (entry.vendor !== vendor && !sameVendorInfo(entry.vendor, vendor)) {\n throw new ConsentError(\n `Vendor \"${vendor.id}\" is declared differently in two categories (privacy_policy_url or transfers).`,\n )\n }\n // Each listing may declare its own cookies (a preset narrowed per category): the vendor gets\n // the union. The same cookie declared twice must be declared the same way.\n for (const cookie of vendor.cookies) {\n if (cookie.category !== category && cookie.category !== REQUIRED_CATEGORY) continue\n const known = entry.cookies.get(cookie.name)\n if (known !== undefined && !sameCookie(known, cookie)) {\n throw new ConsentError(\n `Vendor \"${vendor.id}\": cookie \"${cookie.name}\" is declared differently in two categories.`,\n )\n }\n // Two names from different listings may not share a translation key (one declaration is\n // already checked by toConsentVendor).\n const clash = [...entry.cookies.values()].find(\n (c) => c.name !== cookie.name && c.machine_name === cookie.machine_name,\n )\n if (clash) {\n throw new ConsentError(\n `Vendor \"${vendor.id}\": cookies \"${clash.name}\" and \"${cookie.name}\" have the same machine name \"${cookie.machine_name}\".`,\n )\n }\n entry.cookies.set(cookie.name, cookie)\n }\n merged.set(vendor.id, entry)\n }\n }\n const vendors = [...merged.values()].map(({ vendor, cookies }) => {\n // The first declaration's cookie order, then what later listings added — always the\n // declaration that brought the cookie in (the first one may declare it for another category).\n const order = vendor.cookies.map((c) => c.name).filter((name) => cookies.has(name))\n const ordered = new Set(order)\n for (const name of cookies.keys()) if (!ordered.has(name)) order.push(name)\n return {\n ...vendor,\n cookies: order.flatMap((name) => cookies.get(name) ?? []),\n }\n })\n return { vendors, listed }\n}\n\nfunction sameVendorInfo(a: ConsentVendorDeclaration, b: ConsentVendorDeclaration): boolean {\n return (\n a.privacy_policy_url === b.privacy_policy_url &&\n transfersKey(a.transfers) === transfersKey(b.transfers)\n )\n}\n\n/** Transfers in a canonical form: the same countries and safeguards in any order compare equal. */\nfunction transfersKey(transfers: readonly ConsentTransferDeclaration[] | undefined): string {\n if (transfers === undefined) return 'none'\n return transfers\n .map((t) => `${t.country}:${[...t.safeguards].sort().join(',')}`)\n .sort()\n .join(';')\n}\n\nfunction sameCookie(a: ConsentCookieDeclaration, b: ConsentCookieDeclaration): boolean {\n return (\n a.category === b.category &&\n (a.type ?? 'http') === (b.type ?? 'http') &&\n a.max_age === b.max_age &&\n a.domain === b.domain\n )\n}\n\n// The id of an expired / old-version record is reused so a consent log stays linked — but only when\n// it's a usable string (the stored value may have been tampered with).\nfunction reusableId(record: StoredConsent | null): string | null {\n const id = record?.consent_id\n return typeof id === 'string' && id !== '' ? id : null\n}\n\nfunction randomId(): string {\n const c = globalThis.crypto\n if (c && typeof c.randomUUID === 'function') return c.randomUUID()\n return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`\n}\n\n/**\n * Create a consent instance: per category, the vendors the app uses there (a vendor brings only its\n * cookies of that category, plus its necessary ones), where the decision is kept, and when it must\n * be asked again. Create it once (module\n * scope is fine — storage is only touched on access, so it's SSR-safe) and hand it to\n * `<Consent consent={…}>` in React, or use it directly.\n *\n * ```ts\n * import { googleAnalytics, youtube } from '@luwiostack/cookie-consent/vendors'\n *\n * const consent = createConsent({\n * categories: {\n * statistics: [googleAnalytics()],\n * preferences: [youtube()], // the embed only — no YouTube tracking cookies\n * },\n * policyVersion: 2,\n * })\n * consent.isGranted('preferences', 'youtube') // the embed may load\n * consent.isGranted('marketing', 'youtube') // false — not used there\n * ```\n *\n * @throws {ConsentError} for an invalid `maxAge`, an unknown category, or an invalid vendor (listed\n * twice in a category, no cookies of the category it's listed in, duplicate cookie, empty name,\n * missing cookie category, bad `max_age` / `type`).\n */\nexport function createConsent(config: ConsentConfig = {}): ConsentManager {\n const { vendors, listed } = resolveVendors(config.categories ?? {})\n\n // Each category with the vendors that have cookies in it, cookies narrowed to that category: the\n // ones listed there in config order, then (for necessary) the others that bring necessary cookies.\n const byId = new Map(vendors.map((v) => [v.id, v]))\n const categories: readonly ConsentCategory[] = CONSENT_CATEGORIES.map((id) => {\n const ids = [...new Set([...listed[id], ...vendors.map((v) => v.id)])]\n return {\n id,\n machine_name: categoryMachineName(id),\n description_machine_name: `${categoryMachineName(id)}_description`,\n required: id === REQUIRED_CATEGORY,\n vendors: ids.flatMap((vendorId) => {\n const vendor = byId.get(vendorId) as ConsentVendor\n const cookies = vendor.cookies.filter((c) => c.category === id)\n return cookies.length > 0 ? [{ ...vendor, cookies }] : []\n }),\n }\n })\n const usedIn = usedVendors(categories)\n\n const maxAge = config.maxAge ?? DEFAULT_MAX_AGE\n if (typeof maxAge !== 'number' || Number.isNaN(maxAge) || maxAge <= 0) {\n throw new ConsentError('maxAge must be a positive number of milliseconds.')\n }\n const rawVersion: unknown = config.policyVersion ?? 1\n const validVersion =\n (typeof rawVersion === 'string' && rawVersion !== '') ||\n (typeof rawVersion === 'number' && Number.isFinite(rawVersion))\n if (!validVersion) {\n throw new ConsentError('policyVersion must be a non-empty string or a finite number.')\n }\n const policyVersion = String(rawVersion)\n // Persisting the decision is best-effort: where storage is blocked or full, the default store fails\n // quietly instead of throwing out of acceptAll() & co. A store you pass in keeps its own onError.\n const store =\n config.store ?? localStore<StoredConsent>(DEFAULT_STORAGE_KEY, { onError: 'ignore' })\n const now = config.now ?? Date.now\n\n // A decision the store didn't keep (storage blocked or full, a store with onError 'ignore') is held\n // here for the rest of the page's life — so the banner closes and the visitor's choice applies,\n // instead of being asked again on every click. `undefined`: the store is the source of truth.\n let unsaved: StoredConsent | null | undefined\n const listeners = new Set<() => void>()\n const notify = () => {\n for (const fn of [...listeners]) fn()\n }\n const read = (): StoredConsent | null => (unsaved !== undefined ? unsaved : store.read())\n\n // Snapshot memo: the store's read() is referentially stable between changes, so caching on the raw\n // record (plus whether it has expired since) keeps getSnapshot() stable for useSyncExternalStore.\n let lastRecord: StoredConsent | null | undefined\n let lastExpired = false\n let lastSnapshot: ConsentSnapshot = PENDING\n\n function toDecision(record: StoredConsent): ConsentDecision | null {\n if (record.policy_version !== policyVersion) return null\n if (!Array.isArray(record.granted)) return null\n // Unknown ids (a tampered record) are dropped; necessary is always in.\n const granted = new Set<ConsentCategoryId>([REQUIRED_CATEGORY])\n for (const id of record.granted) if (isConsentCategoryId(id)) granted.add(id)\n return ConsentDecision.tryNew({ ...record, granted })\n }\n\n function getSnapshot(): ConsentSnapshot {\n const record = read()\n const age = record === null ? 0 : now() - record.decided_at\n const expired = record !== null && (age > maxAge || age < -FUTURE_TOLERANCE)\n if (record === lastRecord && expired === lastExpired) return lastSnapshot\n lastRecord = record\n lastExpired = expired\n const decision = record && !expired ? toDecision(record) : null\n lastSnapshot = decision ? Object.freeze({ status: 'decided', decision }) : PENDING\n return lastSnapshot\n }\n\n function current(): ConsentDecision | null {\n return getSnapshot().decision\n }\n\n function commit(granted: Iterable<ConsentCategoryId>): ConsentDecision {\n const previous = current()\n const set = new Set<ConsentCategoryId>([REQUIRED_CATEGORY])\n for (const id of granted) if (isConsentCategoryId(id)) set.add(id)\n const next = ConsentDecision.new({\n // Keep the visitor's consent id across changes, so a consent log can link them.\n consent_id: previous?.consent_id ?? reusableId(read()) ?? randomId(),\n policy_version: policyVersion,\n // Keep the categories' configured order in storage.\n granted: CONSENT_CATEGORIES.filter((id) => set.has(id)),\n decided_at: now(),\n })\n const record = next.toJSON()\n store.write(record)\n // Did it land? A store that fails quietly reads back the old value (or nothing).\n const kept = store.read()\n const landed = kept?.consent_id === record.consent_id && kept?.decided_at === record.decided_at\n unsaved = landed ? undefined : record\n if (!landed) notify() // the store announced nothing\n config.onChange?.(next, previous)\n return next\n }\n\n const isRequired = (id: ConsentCategoryId) => id === REQUIRED_CATEGORY\n const isGranted = (id: ConsentCategoryId, vendorId?: string) =>\n // An unknown category (untyped input: a data-consent attribute) is never granted.\n (vendorId === undefined || usedIn[id]?.has(vendorId) === true) &&\n (isRequired(id) || (current()?.isGranted(id) ?? false))\n\n return {\n categories,\n vendors,\n policyVersion,\n getSnapshot,\n subscribe: (onChange) => {\n listeners.add(onChange)\n const unsubscribe = store.subscribe(onChange)\n return () => {\n listeners.delete(onChange)\n unsubscribe()\n }\n },\n isGranted,\n isRequired,\n acceptAll: () => commit(CONSENT_CATEGORIES),\n rejectAll: () => commit([]),\n save: (granted) => commit(granted),\n grant: (...grant) => commit([...(current()?.granted() ?? []), ...grant]),\n revoke: (...revoke) => {\n const drop = new Set(revoke)\n return commit((current()?.granted() ?? []).filter((id) => !drop.has(id)))\n },\n reset: () => {\n const previous = current()\n store.clear()\n if (unsaved !== undefined) {\n unsaved = undefined\n notify()\n }\n config.onChange?.(null, previous)\n },\n }\n}\n","import type { ConsentCookie } from '../types'\n\nexport interface ConsentCookieFormatOptions {\n /** How unit names are written: `long` (\"2 years\"), `short` (\"2 yrs\"), `narrow` (\"2y\"). Default `long`. */\n unitDisplay?: 'long' | 'short' | 'narrow'\n}\n\nconst SECOND = 1000\nconst MINUTE = 60 * SECOND\nconst HOUR = 60 * MINUTE\nconst DAY = 24 * HOUR\n\n// Largest first. A month counts as 30 days and a year as 365 — how cookie declarations are written\n// (\"3 months\" for 90 days, \"13 months\" for 390), not calendar arithmetic.\nconst UNITS = [\n ['year', 365 * DAY],\n ['month', 30 * DAY],\n ['day', DAY],\n ['hour', HOUR],\n ['minute', MINUTE],\n ['second', SECOND],\n] as const\n\n/** Renders a cookie declaration's values for people. */\nexport class ConsentCookieFormatter {\n /**\n * A cookie's lifetime in `locale`, in the largest unit that divides it evenly: 2 years, 3 months,\n * 400 days, 30 minutes — falling back to whole days (or the largest unit that fits) when nothing\n * divides evenly. Returns `null` for `'session'` and `'persistent'`: those are words, so translate\n * them — `formatLocale(cookie, locale) ?? t(cookie.max_age_machine_name)`.\n */\n static formatLocale(\n cookie: Pick<ConsentCookie, 'max_age'>,\n locale: Intl.Locale,\n options: ConsentCookieFormatOptions = {},\n ): string | null {\n const { max_age } = cookie\n if (typeof max_age !== 'number') return null\n const unitDisplay = options.unitDisplay ?? 'long'\n const exact = UNITS.find(([, ms]) => max_age >= ms && max_age % ms === 0)\n const [unit, ms] =\n exact ?? (max_age >= DAY ? UNITS[2] : (UNITS.find(([, u]) => max_age >= u) ?? UNITS[5]))\n const value = Math.max(1, Math.round(max_age / ms))\n return new Intl.NumberFormat(locale.toString(), { style: 'unit', unit, unitDisplay }).format(\n value,\n )\n }\n}\n","import { REQUIRED_CATEGORY } from '../categories'\nimport type { ConsentCookie, ConsentManager } from '../types'\n\nexport interface ClearRevokedCookiesOptions {\n /**\n * Called once per item actually removed, with the declaration and the real name (a wildcard\n * `_ga_*` resolves to `_ga_ABC123`) — to log it, or to reload the page so running scripts stop.\n */\n onClear?: (cookie: ConsentCookie, actualName: string) => void\n}\n\n/** A declared name as a matcher: `*` matches any run of characters (`_ga_*`, `ttcsid*`). */\nfunction matcher(name: string): (actual: string) => boolean {\n if (!name.includes('*')) return (actual) => actual === name\n const pattern = name.split('*').map((part) => part.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n const re = new RegExp(`^${pattern.join('.*')}$`)\n return (actual) => re.test(actual)\n}\n\n/**\n * The domains a first-party cookie may have been set for: none (host-only), the host itself, and\n * each parent domain (`www.shop.example.com` → `shop.example.com`, `example.com`). Analytics tags\n * usually set theirs on the registrable domain, so deleting needs the same `Domain` attribute.\n * A bare top-level domain (`com`) is never a valid cookie domain, so it's left out.\n * @internal\n */\nexport function domainCandidates(hostname: string): (string | undefined)[] {\n const parts = hostname.split('.')\n const parents: string[] = []\n for (let i = 0; i < parts.length - 1; i++) parents.push(parts.slice(i).join('.'))\n return [undefined, ...parents]\n}\n\n/** The paths a cookie may have been set for, from this page up to the root: `/a/b` → `/a/b`, `/a`, `/`. @internal */\nexport function pathCandidates(pathname: string): string[] {\n const segments = pathname.split('/').filter(Boolean)\n const paths = ['/']\n for (let i = 1; i <= segments.length; i++) paths.push(`/${segments.slice(0, i).join('/')}`)\n return paths\n}\n\nfunction cookieNames(doc: Document): string[] {\n return doc.cookie\n .split(';')\n .map((pair) => pair.slice(0, pair.indexOf('=') === -1 ? undefined : pair.indexOf('=')).trim())\n .filter(Boolean)\n}\n\nfunction expireCookie(doc: Document, name: string): void {\n const { hostname, pathname } = doc.location\n for (const domain of domainCandidates(hostname)) {\n for (const path of pathCandidates(pathname)) {\n doc.cookie = `${name}=; Path=${path}${domain ? `; Domain=${domain}` : ''}; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT`\n }\n }\n}\n\nfunction storageKeys(storage: Storage): string[] {\n const keys: string[] = []\n for (let i = 0; i < storage.length; i++) {\n const key = storage.key(i)\n if (key !== null) keys.push(key)\n }\n return keys\n}\n\n/**\n * Remove what a withdrawn category left behind. At start and on every change, the declared cookies\n * and storage items of every category that isn't granted are deleted — after \"withdraw statistics\",\n * `_ga` and `_ga_*` are gone, not just unused. `necessary` is never touched, and a name a granted\n * category also declares is kept.\n *\n * Only **first-party** storage can be reached: cookies on your own domain (tried with every parent\n * domain and path, since tags set them broadly), `localStorage` / `sessionStorage` items and\n * IndexedDB databases. A third-party cookie (declared with a `domain`, like `IDE` on\n * doubleclick.net) lives on another site: it's skipped, so a first-party item that shares its name\n * is never removed. `HttpOnly` cookies can only be removed by your server. Scripts already running keep\n * running — reload the page (e.g. from `onClear`) to stop them.\n *\n * Returns a stop function. A no-op on the server.\n */\nexport function clearRevokedCookies(\n consent: ConsentManager,\n options: ClearRevokedCookiesOptions = {},\n): () => void {\n if (typeof document === 'undefined') return () => {}\n\n const clear = () => {\n // What a granted category declares stays — even when a revoked one declares the same name.\n const kept: ((actual: string) => boolean)[] = []\n const revoked: ConsentCookie[] = []\n for (const category of consent.categories) {\n const granted = category.id === REQUIRED_CATEGORY || consent.isGranted(category.id)\n for (const vendor of category.vendors) {\n for (const cookie of vendor.cookies) {\n if (granted) kept.push(matcher(cookie.name))\n // A third-party cookie (one with a domain) lives on the vendor's domain: out of reach, and\n // a first-party item that happens to share its name is not ours to remove.\n else if (cookie.domain === undefined) revoked.push(cookie)\n }\n }\n }\n if (revoked.length === 0) return\n const isKept = (actual: string) => kept.some((matches) => matches(actual))\n const cleared = (cookie: ConsentCookie, actual: string) => options.onClear?.(cookie, actual)\n\n for (const cookie of revoked) {\n const matches = matcher(cookie.name)\n const type = cookie.type ?? 'http'\n if (type === 'http') {\n for (const actual of cookieNames(document)) {\n if (!matches(actual) || isKept(actual)) continue\n expireCookie(document, actual)\n // Reported only once it's really gone (no domain/path variant may have matched).\n if (!cookieNames(document).includes(actual)) cleared(cookie, actual)\n }\n } else if (type === 'local_storage' || type === 'session_storage') {\n let storage: Storage | undefined\n try {\n storage = type === 'local_storage' ? window.localStorage : window.sessionStorage\n } catch {\n continue // Storage blocked: there's nothing to remove either.\n }\n for (const actual of storageKeys(storage)) {\n if (!matches(actual) || isKept(actual)) continue\n storage.removeItem(actual)\n cleared(cookie, actual)\n }\n } else if (type === 'indexed_db' && typeof indexedDB !== 'undefined') {\n if (typeof indexedDB.databases === 'function') {\n void indexedDB\n .databases()\n .then((databases) => {\n for (const { name } of databases) {\n if (!name || !matches(name) || isKept(name)) continue\n indexedDB.deleteDatabase(name)\n cleared(cookie, name)\n }\n })\n .catch(() => {}) // Listing refused (a privacy mode): nothing to remove.\n } else if (!cookie.name.includes('*') && !isKept(cookie.name)) {\n // No list of databases (older browsers): delete by exact name — deleting a database that\n // doesn't exist is harmless, but it isn't reported, since it may never have been there.\n indexedDB.deleteDatabase(cookie.name)\n }\n }\n // 'pixel': nothing is stored on the visitor's device.\n }\n }\n\n clear()\n return consent.subscribe(clear)\n}\n","import type { ConsentCategoryId } from '../categories'\nimport type { ConsentManager } from '../types'\n\nexport interface UnblockScriptsOptions {\n /** Where to look. Default `document`. */\n root?: ParentNode\n /** The attribute naming the required categories (space-separated, all must be granted). Default `data-consent`. */\n attribute?: string\n /**\n * The attribute naming the vendor, which must then be used in those categories — an element whose\n * vendor isn't configured there stays blocked. Default `data-consent-vendor`.\n */\n vendorAttribute?: string\n /** Also activate matching elements added to the page later (a `MutationObserver`). Default `true`. */\n observe?: boolean\n}\n\n/**\n * Hold third-party scripts and embeds back until their category is granted — mark them up blocked and\n * this activates them the moment consent allows (on load, and on every later change):\n *\n * ```html\n * <!-- a script: type=\"text/plain\" so the browser doesn't run it; data-type restores a module type -->\n * <script type=\"text/plain\" data-consent=\"statistics\" src=\"https://example.com/analytics.js\"></script>\n * <script type=\"text/plain\" data-consent=\"marketing\">trackPageView()</script>\n *\n * <!-- with a vendor: also only while that vendor is used in the category -->\n * <script type=\"text/plain\" data-consent=\"marketing\" data-consent-vendor=\"meta_pixel\">fbq(…)</script>\n *\n * <!-- an iframe / img: data-src instead of src -->\n * <iframe data-consent=\"marketing\" data-src=\"https://www.youtube-nocookie.com/embed/…\"></iframe>\n * ```\n *\n * A script is replaced by a fresh `<script>` copy (the only way to make the browser run it), its\n * CSP `nonce` included; an embed gets its `src` from `data-src`. Activation is one-way: a revoked category can't un-run a\n * script — reload the page from `onChange` when something is withdrawn. Returns a stop function.\n */\nexport function unblockScripts(\n consent: ConsentManager,\n options: UnblockScriptsOptions = {},\n): () => void {\n if (typeof document === 'undefined') return () => {}\n const root = options.root ?? document\n const attr = options.attribute ?? 'data-consent'\n const vendorAttr = options.vendorAttribute ?? 'data-consent-vendor'\n\n const allowed = (el: Element) => {\n const ids = (el.getAttribute(attr) ?? '').split(/\\s+/).filter(Boolean) as ConsentCategoryId[]\n const vendor = el.getAttribute(vendorAttr) ?? undefined\n return ids.length > 0 && ids.every((id) => consent.isGranted(id, vendor))\n }\n\n const activate = () => {\n for (const el of Array.from(root.querySelectorAll(`script[type=\"text/plain\"][${attr}]`))) {\n if (!allowed(el)) continue\n const script = document.createElement('script')\n for (const { name, value } of Array.from(el.attributes)) {\n if (name === 'type' || name === 'data-type') continue\n script.setAttribute(name, value)\n }\n const type = el.getAttribute('data-type')\n if (type) script.setAttribute('type', type)\n // Under a Content-Security-Policy header, browsers hide a script's nonce from getAttribute()\n // (\"nonce hiding\") — only the property keeps it. Without this the copy fails the CSP check.\n const { nonce } = el as HTMLScriptElement\n if (nonce) script.nonce = nonce\n if (!el.hasAttribute('src')) script.text = el.textContent ?? ''\n el.replaceWith(script)\n }\n for (const el of Array.from(root.querySelectorAll(`[${attr}][data-src]:not(script)`))) {\n if (!allowed(el)) continue\n const src = el.getAttribute('data-src')\n el.removeAttribute('data-src')\n if (src) el.setAttribute('src', src)\n }\n }\n\n activate()\n const unsubscribe = consent.subscribe(activate)\n\n let observer: MutationObserver | undefined\n if ((options.observe ?? true) && typeof MutationObserver !== 'undefined') {\n observer = new MutationObserver((records) => {\n if (records.some((r) => r.addedNodes.length > 0)) activate()\n })\n const target = root instanceof Document ? root.documentElement : (root as Node)\n observer.observe(target, { childList: true, subtree: true })\n }\n\n return () => {\n unsubscribe()\n observer?.disconnect()\n }\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAa,kBAAb,MAAa,gBAAgB;CAC3B;CACA;;CAEA;CACA;CAEA,YAAoB,OAA6B;EAC/C,KAAK,aAAa,MAAM;EACxB,KAAK,iBAAiB,MAAM;EAC5B,KAAK,aAAa,MAAM;EACxB,KAAKA,WAAW,IAAI,IAAI,MAAM,OAAO;CACvC;;CAGA,OAAO,IAAI,OAA8C;EACvD,IAAI,OAAO,MAAM,eAAe,YAAY,MAAM,eAAe,IAC/D,MAAM,IAAIC,sBAAAA,aAAa,kDAAkD;EAE3E,IAAI,OAAO,MAAM,mBAAmB,YAAY,MAAM,mBAAmB,IACvE,MAAM,IAAIA,sBAAAA,aAAa,sDAAsD;EAE/E,IAAI,OAAO,MAAM,eAAe,YAAY,CAAC,OAAO,SAAS,MAAM,UAAU,GAC3E,MAAM,IAAIA,sBAAAA,aAAa,mEAAmE;EAE5F,OAAO,IAAI,gBAAgB,KAAK;CAClC;;CAGA,OAAO,OAAO,OAAqD;EACjE,IAAI;GACF,OAAO,gBAAgB,IAAI,KAAK;EAClC,QAAQ;GACN,OAAO;EACT;CACF;;CAGA,UAAU,IAAgC;EACxC,OAAO,KAAKD,SAAS,IAAI,EAAE;CAC7B;;CAGA,UAA+B;EAC7B,OAAO,CAA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E,GAAG;GAClB,MAAM,SAAS,SAAS,cAAc,QAAQ;GAC9C,KAAK,MAAM,EAAE,MAAM,WAAW,MAAM,KAAK,GAAG,UAAU,GAAG;IACvD,IAAI,SAAS,UAAU,SAAS,aAAa;IAC7C,OAAO,aAAa,MAAM,KAAK;GACjC;GACA,MAAM,OAAO,GAAG,aAAa,WAAW;GACxC,IAAI,MAAM,OAAO,aAAa,QAAQ,IAAI;GAG1C,MAAM,EAAE,UAAU;GAClB,IAAI,OAAO,OAAO,QAAQ;GAC1B,IAAI,CAAC,GAAG,aAAa,KAAK,GAAG,OAAO,OAAO,GAAG,eAAe;GAC7D,GAAG,YAAY,MAAM;EACvB;EACA,KAAK,MAAM,MAAM,MAAM,KAAK,KAAK,iBAAiB,IAAI,KAAK,wBAAwB,CAAC,GAAG;GACrF,IAAI,CAAC,QAAQ,EAAE,GAAG;GAClB,MAAM,MAAM,GAAG,aAAa,UAAU;GACtC,GAAG,gBAAgB,UAAU;GAC7B,IAAI,KAAK,GAAG,aAAa,OAAO,GAAG;EACrC;CACF;CAEA,SAAS;CACT,MAAM,cAAc,QAAQ,UAAU,QAAQ;CAE9C,IAAI;CACJ,KAAK,QAAQ,WAAW,SAAS,OAAO,qBAAqB,aAAa;EACxE,WAAW,IAAI,kBAAkB,YAAY;GAC3C,IAAI,QAAQ,MAAM,MAAM,EAAE,WAAW,SAAS,CAAC,GAAG,SAAS;EAC7D,CAAC;EACD,MAAM,SAAS,gBAAgB,WAAW,KAAK,kBAAmB;EAClE,SAAS,QAAQ,QAAQ;GAAE,WAAW;GAAM,SAAS;EAAK,CAAC;CAC7D;CAEA,aAAa;EACX,YAAY;EACZ,UAAU,WAAW;CACvB;AACF"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as isConsentCategoryId, a as ConsentCookieMaxAge, c as ConsentSnapshot, d as StoredConsent, f as ConsentDecision, g as REQUIRED_CATEGORY, h as ConsentCategoryId, i as ConsentCookie, l as ConsentStatus, m as CONSENT_CATEGORIES, n as ConsentCategory, o as ConsentCookieType, p as ConsentDecisionInput, r as ConsentConfig, s as ConsentManager, t as ConsentCategoriesConfig, u as ConsentVendor } from "./types-BrxRJL4I.cjs";
1
+ import { C as REQUIRED_CATEGORY, S as ConsentCategoryId, _ as ConsentVendorDeclaration, a as ConsentCookieDeclaration, b as ConsentDecisionInput, c as ConsentCookieType, d as ConsentSnapshot, f as ConsentStatus, g as ConsentVendor, h as ConsentTransferSafeguard, i as ConsentCookie, l as ConsentCookieWordedMaxAge, m as ConsentTransferDeclaration, n as ConsentCategory, o as ConsentCookieMaxAge, p as ConsentTransfer, r as ConsentConfig, s as ConsentCookieParty, t as ConsentCategoriesConfig, u as ConsentManager, v as StoredConsent, w as isConsentCategoryId, x as CONSENT_CATEGORIES, y as ConsentDecision } from "./types-ByyibBUg.cjs";
2
2
  //#region src/consent.d.ts
3
3
  /** The key the default `localStorage` store keeps the decision behind. */
4
4
  declare const DEFAULT_STORAGE_KEY = "luwio.consent";
@@ -47,8 +47,8 @@ declare class ConsentCookieFormatter {
47
47
  /**
48
48
  * A cookie's lifetime in `locale`, in the largest unit that divides it evenly: 2 years, 3 months,
49
49
  * 400 days, 30 minutes — falling back to whole days (or the largest unit that fits) when nothing
50
- * divides evenly. Returns `null` for `'session'` and `'persistent'`: those are words, so render
51
- * them through your own translations.
50
+ * divides evenly. Returns `null` for `'session'` and `'persistent'`: those are words, so translate
51
+ * them — `formatLocale(cookie, locale) ?? t(cookie.max_age_machine_name)`.
52
52
  */
53
53
  static formatLocale(cookie: Pick<ConsentCookie, 'max_age'>, locale: Intl.Locale, options?: ConsentCookieFormatOptions): string | null;
54
54
  }
@@ -69,60 +69,15 @@ interface ClearRevokedCookiesOptions {
69
69
  *
70
70
  * Only **first-party** storage can be reached: cookies on your own domain (tried with every parent
71
71
  * domain and path, since tags set them broadly), `localStorage` / `sessionStorage` items and
72
- * IndexedDB databases. A third-party cookie (`IDE` on doubleclick.net) lives on another site and
73
- * can't be removed from yours; `HttpOnly` cookies only by your server. Scripts already running keep
72
+ * IndexedDB databases. A third-party cookie (declared with a `domain`, like `IDE` on
73
+ * doubleclick.net) lives on another site: it's skipped, so a first-party item that shares its name
74
+ * is never removed. `HttpOnly` cookies can only be removed by your server. Scripts already running keep
74
75
  * running — reload the page (e.g. from `onClear`) to stop them.
75
76
  *
76
77
  * Returns a stop function. A no-op on the server.
77
78
  */
78
79
  declare function clearRevokedCookies(consent: ConsentManager, options?: ClearRevokedCookiesOptions): () => void;
79
80
  //#endregion
80
- //#region src/integrations/google-consent-mode.d.ts
81
- /** The Google Consent Mode v2 signals. */
82
- type GoogleConsentSignal = 'ad_storage' | 'ad_user_data' | 'ad_personalization' | 'analytics_storage' | 'functionality_storage' | 'personalization_storage' | 'security_storage';
83
- type GoogleConsentValue = 'granted' | 'denied';
84
- /** Which category (or categories — all must be granted) drives each signal. Unmapped signals aren't sent. */
85
- type GoogleConsentMapping = Partial<Record<GoogleConsentSignal, ConsentCategoryId | readonly ConsentCategoryId[]>>;
86
- /** The standard mapping of Google's signals onto the fixed categories — the default. */
87
- declare const DEFAULT_GOOGLE_CONSENT_MAPPING: {
88
- readonly ad_storage: 'marketing';
89
- readonly ad_user_data: 'marketing';
90
- readonly ad_personalization: 'marketing';
91
- readonly analytics_storage: 'statistics';
92
- readonly functionality_storage: 'preferences';
93
- readonly personalization_storage: 'preferences';
94
- readonly security_storage: 'necessary';
95
- };
96
- type Gtag = (...args: unknown[]) => void;
97
- interface GoogleConsentModeOptions {
98
- /**
99
- * Which category drives each signal. Default {@link DEFAULT_GOOGLE_CONSENT_MAPPING} (ads →
100
- * marketing, analytics → statistics, functionality / personalization → preferences, security →
101
- * necessary). A custom mapping sends only the signals it lists; a signal mapped to several
102
- * categories is granted only when all are.
103
- */
104
- mapping?: GoogleConsentMapping;
105
- /** Milliseconds Google tags wait for an `update` after the `default` command. Default `500`. */
106
- waitForUpdate?: number;
107
- /** Restrict the `default` command to these ISO 3166-2 regions (e.g. `['BE', 'NL']`). */
108
- region?: readonly string[];
109
- /** Send `ads_data_redaction: true` while ad storage is denied. Default `false`. */
110
- adsDataRedaction?: boolean;
111
- /** Send `url_passthrough: true`. Default `false`. */
112
- urlPassthrough?: boolean;
113
- /** The `gtag` function. Default `window.gtag`, defined as the standard `dataLayer` stub if absent. */
114
- gtag?: Gtag;
115
- }
116
- /**
117
- * Wire a consent instance to Google Consent Mode v2: sends `gtag('consent', 'default', …)` with every
118
- * mapped signal denied (signals mapped to required categories granted), then an `update` with the
119
- * visitor's decision — immediately when one is stored, and again on every change.
120
- *
121
- * Call it **before** the Google tag (gtag.js / GTM) loads, so the default is in place for its first
122
- * hit. Returns an unsubscribe. A no-op on the server.
123
- */
124
- declare function googleConsentMode(consent: ConsentManager, options?: GoogleConsentModeOptions): () => void;
125
- //#endregion
126
81
  //#region src/integrations/unblock-scripts.d.ts
127
82
  interface UnblockScriptsOptions {
128
83
  /** Where to look. Default `document`. */
@@ -159,5 +114,5 @@ interface UnblockScriptsOptions {
159
114
  */
160
115
  declare function unblockScripts(consent: ConsentManager, options?: UnblockScriptsOptions): () => void;
161
116
  //#endregion
162
- export { CONSENT_CATEGORIES, type ClearRevokedCookiesOptions, type ConsentCategoriesConfig, type ConsentCategory, type ConsentCategoryId, type ConsentConfig, type ConsentCookie, type ConsentCookieFormatOptions, ConsentCookieFormatter, type ConsentCookieMaxAge, type ConsentCookieType, ConsentDecision, type ConsentDecisionInput, ConsentError, type ConsentManager, type ConsentSnapshot, type ConsentStatus, type ConsentVendor, DEFAULT_GOOGLE_CONSENT_MAPPING, DEFAULT_MAX_AGE, DEFAULT_STORAGE_KEY, type GoogleConsentMapping, type GoogleConsentModeOptions, type GoogleConsentSignal, type GoogleConsentValue, REQUIRED_CATEGORY, type StoredConsent, type UnblockScriptsOptions, clearRevokedCookies, createConsent, googleConsentMode, isConsentCategoryId, unblockScripts };
117
+ export { CONSENT_CATEGORIES, type ClearRevokedCookiesOptions, type ConsentCategoriesConfig, type ConsentCategory, type ConsentCategoryId, type ConsentConfig, type ConsentCookie, type ConsentCookieDeclaration, type ConsentCookieFormatOptions, ConsentCookieFormatter, type ConsentCookieMaxAge, type ConsentCookieParty, type ConsentCookieType, type ConsentCookieWordedMaxAge, ConsentDecision, type ConsentDecisionInput, ConsentError, type ConsentManager, type ConsentSnapshot, type ConsentStatus, type ConsentTransfer, type ConsentTransferDeclaration, type ConsentTransferSafeguard, type ConsentVendor, type ConsentVendorDeclaration, DEFAULT_MAX_AGE, DEFAULT_STORAGE_KEY, REQUIRED_CATEGORY, type StoredConsent, type UnblockScriptsOptions, clearRevokedCookies, createConsent, isConsentCategoryId, unblockScripts };
163
118
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/consent.ts","../src/errors.ts","../src/formatters/consent-cookie-formatter.ts","../src/integrations/clear-revoked-cookies.ts","../src/integrations/google-consent-mode.ts","../src/integrations/unblock-scripts.ts"],"mappings":";;;cAuBa;;cAEA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuJG,cAAc,SAAQ,gBAAqB;;;;cC/K9C,qBAAqB;EAChC,YAAY;;;;UCAG;;EAEf;;;cAoBW;;;;;;;SAOJ,aACL,QAAQ,KAAK,2BACb,QAAQ,KAAK,QACb,UAAS;;;;UC/BI;;;;;EAKf,WAAW,QAAQ,eAAe;;;;;;;;;;;;;;;;iBAwEpB,oBACd,SAAS,gBACT,UAAS;;;;KC9EC;KASA;;KAGA,uBAAuB,QACjC,OAAO,qBAAqB,6BAA6B;;cAI9C;WACC;WACE;WACM;WACD;WACI;WACE;WACP;;KAGf,WAAW;UAEC;;;;;;;EAOf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA,OAAO;;;;;;;;;;iBA2BO,kBACd,SAAS,gBACT,UAAS;;;UC5EM;;EAEf,OAAO;;EAEP;;;;;EAKA;;EAEA;;;;;;;;;;;;;;;;;;;;;;iBAuBc,eACd,SAAS,gBACT,UAAS"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/consent.ts","../src/errors.ts","../src/formatters/consent-cookie-formatter.ts","../src/integrations/clear-revoked-cookies.ts","../src/integrations/unblock-scripts.ts"],"mappings":";;;cA4Ba;;cAEA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgQG,cAAc,SAAQ,gBAAqB;;;;cC7R9C,qBAAqB;EAChC,YAAY;;;;UCAG;;EAEf;;;cAoBW;;;;;;;SAOJ,aACL,QAAQ,KAAK,2BACb,QAAQ,KAAK,QACb,UAAS;;;;UC/BI;;;;;EAKf,WAAW,QAAQ,eAAe;;;;;;;;;;;;;;;;;iBAyEpB,oBACd,SAAS,gBACT,UAAS;;;UChFM;;EAEf,OAAO;;EAEP;;;;;EAKA;;EAEA;;;;;;;;;;;;;;;;;;;;;;iBAuBc,eACd,SAAS,gBACT,UAAS"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as isConsentCategoryId, a as ConsentCookieMaxAge, c as ConsentSnapshot, d as StoredConsent, f as ConsentDecision, g as REQUIRED_CATEGORY, h as ConsentCategoryId, i as ConsentCookie, l as ConsentStatus, m as CONSENT_CATEGORIES, n as ConsentCategory, o as ConsentCookieType, p as ConsentDecisionInput, r as ConsentConfig, s as ConsentManager, t as ConsentCategoriesConfig, u as ConsentVendor } from "./types-BrxRJL4I.mjs";
1
+ import { C as REQUIRED_CATEGORY, S as ConsentCategoryId, _ as ConsentVendorDeclaration, a as ConsentCookieDeclaration, b as ConsentDecisionInput, c as ConsentCookieType, d as ConsentSnapshot, f as ConsentStatus, g as ConsentVendor, h as ConsentTransferSafeguard, i as ConsentCookie, l as ConsentCookieWordedMaxAge, m as ConsentTransferDeclaration, n as ConsentCategory, o as ConsentCookieMaxAge, p as ConsentTransfer, r as ConsentConfig, s as ConsentCookieParty, t as ConsentCategoriesConfig, u as ConsentManager, v as StoredConsent, w as isConsentCategoryId, x as CONSENT_CATEGORIES, y as ConsentDecision } from "./types-ByyibBUg.mjs";
2
2
  //#region src/consent.d.ts
3
3
  /** The key the default `localStorage` store keeps the decision behind. */
4
4
  declare const DEFAULT_STORAGE_KEY = "luwio.consent";
@@ -47,8 +47,8 @@ declare class ConsentCookieFormatter {
47
47
  /**
48
48
  * A cookie's lifetime in `locale`, in the largest unit that divides it evenly: 2 years, 3 months,
49
49
  * 400 days, 30 minutes — falling back to whole days (or the largest unit that fits) when nothing
50
- * divides evenly. Returns `null` for `'session'` and `'persistent'`: those are words, so render
51
- * them through your own translations.
50
+ * divides evenly. Returns `null` for `'session'` and `'persistent'`: those are words, so translate
51
+ * them — `formatLocale(cookie, locale) ?? t(cookie.max_age_machine_name)`.
52
52
  */
53
53
  static formatLocale(cookie: Pick<ConsentCookie, 'max_age'>, locale: Intl.Locale, options?: ConsentCookieFormatOptions): string | null;
54
54
  }
@@ -69,60 +69,15 @@ interface ClearRevokedCookiesOptions {
69
69
  *
70
70
  * Only **first-party** storage can be reached: cookies on your own domain (tried with every parent
71
71
  * domain and path, since tags set them broadly), `localStorage` / `sessionStorage` items and
72
- * IndexedDB databases. A third-party cookie (`IDE` on doubleclick.net) lives on another site and
73
- * can't be removed from yours; `HttpOnly` cookies only by your server. Scripts already running keep
72
+ * IndexedDB databases. A third-party cookie (declared with a `domain`, like `IDE` on
73
+ * doubleclick.net) lives on another site: it's skipped, so a first-party item that shares its name
74
+ * is never removed. `HttpOnly` cookies can only be removed by your server. Scripts already running keep
74
75
  * running — reload the page (e.g. from `onClear`) to stop them.
75
76
  *
76
77
  * Returns a stop function. A no-op on the server.
77
78
  */
78
79
  declare function clearRevokedCookies(consent: ConsentManager, options?: ClearRevokedCookiesOptions): () => void;
79
80
  //#endregion
80
- //#region src/integrations/google-consent-mode.d.ts
81
- /** The Google Consent Mode v2 signals. */
82
- type GoogleConsentSignal = 'ad_storage' | 'ad_user_data' | 'ad_personalization' | 'analytics_storage' | 'functionality_storage' | 'personalization_storage' | 'security_storage';
83
- type GoogleConsentValue = 'granted' | 'denied';
84
- /** Which category (or categories — all must be granted) drives each signal. Unmapped signals aren't sent. */
85
- type GoogleConsentMapping = Partial<Record<GoogleConsentSignal, ConsentCategoryId | readonly ConsentCategoryId[]>>;
86
- /** The standard mapping of Google's signals onto the fixed categories — the default. */
87
- declare const DEFAULT_GOOGLE_CONSENT_MAPPING: {
88
- readonly ad_storage: 'marketing';
89
- readonly ad_user_data: 'marketing';
90
- readonly ad_personalization: 'marketing';
91
- readonly analytics_storage: 'statistics';
92
- readonly functionality_storage: 'preferences';
93
- readonly personalization_storage: 'preferences';
94
- readonly security_storage: 'necessary';
95
- };
96
- type Gtag = (...args: unknown[]) => void;
97
- interface GoogleConsentModeOptions {
98
- /**
99
- * Which category drives each signal. Default {@link DEFAULT_GOOGLE_CONSENT_MAPPING} (ads →
100
- * marketing, analytics → statistics, functionality / personalization → preferences, security →
101
- * necessary). A custom mapping sends only the signals it lists; a signal mapped to several
102
- * categories is granted only when all are.
103
- */
104
- mapping?: GoogleConsentMapping;
105
- /** Milliseconds Google tags wait for an `update` after the `default` command. Default `500`. */
106
- waitForUpdate?: number;
107
- /** Restrict the `default` command to these ISO 3166-2 regions (e.g. `['BE', 'NL']`). */
108
- region?: readonly string[];
109
- /** Send `ads_data_redaction: true` while ad storage is denied. Default `false`. */
110
- adsDataRedaction?: boolean;
111
- /** Send `url_passthrough: true`. Default `false`. */
112
- urlPassthrough?: boolean;
113
- /** The `gtag` function. Default `window.gtag`, defined as the standard `dataLayer` stub if absent. */
114
- gtag?: Gtag;
115
- }
116
- /**
117
- * Wire a consent instance to Google Consent Mode v2: sends `gtag('consent', 'default', …)` with every
118
- * mapped signal denied (signals mapped to required categories granted), then an `update` with the
119
- * visitor's decision — immediately when one is stored, and again on every change.
120
- *
121
- * Call it **before** the Google tag (gtag.js / GTM) loads, so the default is in place for its first
122
- * hit. Returns an unsubscribe. A no-op on the server.
123
- */
124
- declare function googleConsentMode(consent: ConsentManager, options?: GoogleConsentModeOptions): () => void;
125
- //#endregion
126
81
  //#region src/integrations/unblock-scripts.d.ts
127
82
  interface UnblockScriptsOptions {
128
83
  /** Where to look. Default `document`. */
@@ -159,5 +114,5 @@ interface UnblockScriptsOptions {
159
114
  */
160
115
  declare function unblockScripts(consent: ConsentManager, options?: UnblockScriptsOptions): () => void;
161
116
  //#endregion
162
- export { CONSENT_CATEGORIES, type ClearRevokedCookiesOptions, type ConsentCategoriesConfig, type ConsentCategory, type ConsentCategoryId, type ConsentConfig, type ConsentCookie, type ConsentCookieFormatOptions, ConsentCookieFormatter, type ConsentCookieMaxAge, type ConsentCookieType, ConsentDecision, type ConsentDecisionInput, ConsentError, type ConsentManager, type ConsentSnapshot, type ConsentStatus, type ConsentVendor, DEFAULT_GOOGLE_CONSENT_MAPPING, DEFAULT_MAX_AGE, DEFAULT_STORAGE_KEY, type GoogleConsentMapping, type GoogleConsentModeOptions, type GoogleConsentSignal, type GoogleConsentValue, REQUIRED_CATEGORY, type StoredConsent, type UnblockScriptsOptions, clearRevokedCookies, createConsent, googleConsentMode, isConsentCategoryId, unblockScripts };
117
+ export { CONSENT_CATEGORIES, type ClearRevokedCookiesOptions, type ConsentCategoriesConfig, type ConsentCategory, type ConsentCategoryId, type ConsentConfig, type ConsentCookie, type ConsentCookieDeclaration, type ConsentCookieFormatOptions, ConsentCookieFormatter, type ConsentCookieMaxAge, type ConsentCookieParty, type ConsentCookieType, type ConsentCookieWordedMaxAge, ConsentDecision, type ConsentDecisionInput, ConsentError, type ConsentManager, type ConsentSnapshot, type ConsentStatus, type ConsentTransfer, type ConsentTransferDeclaration, type ConsentTransferSafeguard, type ConsentVendor, type ConsentVendorDeclaration, DEFAULT_MAX_AGE, DEFAULT_STORAGE_KEY, REQUIRED_CATEGORY, type StoredConsent, type UnblockScriptsOptions, clearRevokedCookies, createConsent, isConsentCategoryId, unblockScripts };
163
118
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/consent.ts","../src/errors.ts","../src/formatters/consent-cookie-formatter.ts","../src/integrations/clear-revoked-cookies.ts","../src/integrations/google-consent-mode.ts","../src/integrations/unblock-scripts.ts"],"mappings":";;;cAuBa;;cAEA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuJG,cAAc,SAAQ,gBAAqB;;;;cC/K9C,qBAAqB;EAChC,YAAY;;;;UCAG;;EAEf;;;cAoBW;;;;;;;SAOJ,aACL,QAAQ,KAAK,2BACb,QAAQ,KAAK,QACb,UAAS;;;;UC/BI;;;;;EAKf,WAAW,QAAQ,eAAe;;;;;;;;;;;;;;;;iBAwEpB,oBACd,SAAS,gBACT,UAAS;;;;KC9EC;KASA;;KAGA,uBAAuB,QACjC,OAAO,qBAAqB,6BAA6B;;cAI9C;WACC;WACE;WACM;WACD;WACI;WACE;WACP;;KAGf,WAAW;UAEC;;;;;;;EAOf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA,OAAO;;;;;;;;;;iBA2BO,kBACd,SAAS,gBACT,UAAS;;;UC5EM;;EAEf,OAAO;;EAEP;;;;;EAKA;;EAEA;;;;;;;;;;;;;;;;;;;;;;iBAuBc,eACd,SAAS,gBACT,UAAS"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/consent.ts","../src/errors.ts","../src/formatters/consent-cookie-formatter.ts","../src/integrations/clear-revoked-cookies.ts","../src/integrations/unblock-scripts.ts"],"mappings":";;;cA4Ba;;cAEA;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgQG,cAAc,SAAQ,gBAAqB;;;;cC7R9C,qBAAqB;EAChC,YAAY;;;;UCAG;;EAEf;;;cAoBW;;;;;;;SAOJ,aACL,QAAQ,KAAK,2BACb,QAAQ,KAAK,QACb,UAAS;;;;UC/BI;;;;;EAKf,WAAW,QAAQ,eAAe;;;;;;;;;;;;;;;;;iBAyEpB,oBACd,SAAS,gBACT,UAAS;;;UChFM;;EAEf,OAAO;;EAEP;;;;;EAKA;;EAEA;;;;;;;;;;;;;;;;;;;;;;iBAuBc,eACd,SAAS,gBACT,UAAS"}