@luwiostack/cookie-consent 0.0.0-stage → 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.
- package/README.md +415 -2
- package/dist/index.cjs +569 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +118 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +118 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +558 -0
- package/dist/index.mjs.map +1 -0
- package/dist/machine-names-DAJioLt5.mjs +102 -0
- package/dist/machine-names-DAJioLt5.mjs.map +1 -0
- package/dist/machine-names-DCujHBVM.cjs +137 -0
- package/dist/machine-names-DCujHBVM.cjs.map +1 -0
- package/dist/react.cjs +124 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +109 -0
- package/dist/react.d.cts.map +1 -0
- package/dist/react.d.mts +109 -0
- package/dist/react.d.mts.map +1 -0
- package/dist/react.mjs +120 -0
- package/dist/react.mjs.map +1 -0
- package/dist/types-ByyibBUg.d.cts +272 -0
- package/dist/types-ByyibBUg.d.cts.map +1 -0
- package/dist/types-ByyibBUg.d.mts +272 -0
- package/dist/types-ByyibBUg.d.mts.map +1 -0
- package/dist/used-vendors-C8uSNIkd.cjs +14 -0
- package/dist/used-vendors-C8uSNIkd.cjs.map +1 -0
- package/dist/used-vendors-Dxk4PZtY.mjs +9 -0
- package/dist/used-vendors-Dxk4PZtY.mjs.map +1 -0
- package/dist/vendors.cjs +619 -0
- package/dist/vendors.cjs.map +1 -0
- package/dist/vendors.d.cts +171 -0
- package/dist/vendors.d.cts.map +1 -0
- package/dist/vendors.d.mts +171 -0
- package/dist/vendors.d.mts.map +1 -0
- package/dist/vendors.mjs +606 -0
- package/dist/vendors.mjs.map +1 -0
- package/package.json +89 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#granted"],"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,IAAI,aAAa,kDAAkD;EAE3E,IAAI,OAAO,MAAM,mBAAmB,YAAY,MAAM,mBAAmB,IACvE,MAAM,IAAI,aAAa,sDAAsD;EAE/E,IAAI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,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"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//#region src/categories.ts
|
|
2
|
+
/**
|
|
3
|
+
* The fixed consent categories, in display order — the same four every consent tool (and Google
|
|
4
|
+
* Consent Mode) works with. `necessary` is always granted. A category's name and description are
|
|
5
|
+
* translated by machine name (`consent_category_<id>`, `consent_category_<id>_description`) from
|
|
6
|
+
* the package catalogs.
|
|
7
|
+
*/
|
|
8
|
+
const CONSENT_CATEGORIES = [
|
|
9
|
+
"necessary",
|
|
10
|
+
"preferences",
|
|
11
|
+
"statistics",
|
|
12
|
+
"marketing"
|
|
13
|
+
];
|
|
14
|
+
/** The category that is always granted and can't be refused. */
|
|
15
|
+
const REQUIRED_CATEGORY = "necessary";
|
|
16
|
+
/** Whether a value is one of the fixed category ids. */
|
|
17
|
+
function isConsentCategoryId(value) {
|
|
18
|
+
return CONSENT_CATEGORIES.includes(value);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/errors.ts
|
|
22
|
+
/** Thrown for an invalid consent configuration or an invalid stored decision. */
|
|
23
|
+
var ConsentError = class extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ConsentError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/utils/to-machine-name.ts
|
|
31
|
+
/**
|
|
32
|
+
* Converts a human-readable name to a stable snake_case machine name.
|
|
33
|
+
*
|
|
34
|
+
* - Normalizes Unicode (NFD) and strips diacritics (é → e, ñ → n, …)
|
|
35
|
+
* - Lowercases
|
|
36
|
+
* - Replaces any run of non-alphanumeric characters with a single underscore
|
|
37
|
+
* - Trims leading/trailing underscores
|
|
38
|
+
*/
|
|
39
|
+
function toMachineName(name) {
|
|
40
|
+
return name.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/machine-names.ts
|
|
44
|
+
/** @internal A category's name key, e.g. `consent_category_statistics`. */
|
|
45
|
+
const categoryMachineName = (id) => `consent_category_${id}`;
|
|
46
|
+
/** @internal A cookie type's key, e.g. `consent_cookie_type_local_storage`. */
|
|
47
|
+
const cookieTypeMachineName = (type) => `consent_cookie_type_${type}`;
|
|
48
|
+
/** @internal A worded lifetime's key: `consent_max_age_session` / `consent_max_age_persistent`. */
|
|
49
|
+
const maxAgeMachineName = (maxAge) => `consent_max_age_${maxAge}`;
|
|
50
|
+
/** @internal A cookie party's key: `consent_cookie_party_first` / `consent_cookie_party_third`. */
|
|
51
|
+
const partyMachineName = (party) => `consent_cookie_party_${party}`;
|
|
52
|
+
/** @internal A transfer safeguard's key, e.g. `consent_transfer_safeguard_dpf`. */
|
|
53
|
+
const safeguardMachineName = (safeguard) => `consent_transfer_safeguard_${safeguard}`;
|
|
54
|
+
/**
|
|
55
|
+
* @internal A cookie's key: its vendor's machine name plus its name, a `*` read as `wildcard` —
|
|
56
|
+
* `google_analytics` + `_ga_*` → `google_analytics_ga_wildcard`.
|
|
57
|
+
*/
|
|
58
|
+
function cookieMachineName(vendor, cookieName) {
|
|
59
|
+
const name = toMachineName(cookieName.replaceAll("*", " wildcard "));
|
|
60
|
+
return name === "" ? "" : `${vendor}_${name}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @internal A vendor declaration with its machine names, cookies included. Throws when its id or a
|
|
64
|
+
* cookie name has no letters or digits, or when two cookie names come out the same.
|
|
65
|
+
*/
|
|
66
|
+
function toConsentVendor(declaration) {
|
|
67
|
+
const where = `Vendor "${declaration.id}"`;
|
|
68
|
+
const machine_name = toMachineName(declaration.id);
|
|
69
|
+
if (machine_name === "") throw new ConsentError(`${where}: the id needs letters or digits for its machine name.`);
|
|
70
|
+
const byMachineName = /* @__PURE__ */ new Map();
|
|
71
|
+
const cookies = declaration.cookies.map((cookie) => {
|
|
72
|
+
const key = cookieMachineName(machine_name, cookie.name);
|
|
73
|
+
if (key === "") throw new ConsentError(`${where}: cookie "${cookie.name}" needs letters or digits.`);
|
|
74
|
+
const clash = byMachineName.get(key);
|
|
75
|
+
if (clash !== void 0 && clash !== cookie.name) throw new ConsentError(`${where}: cookies "${clash}" and "${cookie.name}" have the same machine name "${key}".`);
|
|
76
|
+
byMachineName.set(key, cookie.name);
|
|
77
|
+
const party = cookie.domain === void 0 ? "first" : "third";
|
|
78
|
+
return {
|
|
79
|
+
...cookie,
|
|
80
|
+
machine_name: key,
|
|
81
|
+
type_machine_name: cookieTypeMachineName(cookie.type ?? "http"),
|
|
82
|
+
party,
|
|
83
|
+
party_machine_name: partyMachineName(party),
|
|
84
|
+
...typeof cookie.max_age === "string" ? { max_age_machine_name: maxAgeMachineName(cookie.max_age) } : {}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
const { transfers: declared, ...rest } = declaration;
|
|
88
|
+
const transfers = declared?.map((transfer) => ({
|
|
89
|
+
...transfer,
|
|
90
|
+
safeguard_machine_names: transfer.safeguards.map(safeguardMachineName)
|
|
91
|
+
}));
|
|
92
|
+
return {
|
|
93
|
+
...rest,
|
|
94
|
+
machine_name,
|
|
95
|
+
...transfers !== void 0 ? { transfers } : {},
|
|
96
|
+
cookies
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { REQUIRED_CATEGORY as a, CONSENT_CATEGORIES as i, toConsentVendor as n, isConsentCategoryId as o, ConsentError as r, categoryMachineName as t };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=machine-names-DAJioLt5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine-names-DAJioLt5.mjs","names":[],"sources":["../src/categories.ts","../src/errors.ts","../src/utils/to-machine-name.ts","../src/machine-names.ts"],"sourcesContent":["/**\n * The fixed consent categories, in display order — the same four every consent tool (and Google\n * Consent Mode) works with. `necessary` is always granted. A category's name and description are\n * translated by machine name (`consent_category_<id>`, `consent_category_<id>_description`) from\n * the package catalogs.\n */\nexport const CONSENT_CATEGORIES = ['necessary', 'preferences', 'statistics', 'marketing'] as const\n\n/** `'necessary' | 'preferences' | 'statistics' | 'marketing'` */\nexport type ConsentCategoryId = (typeof CONSENT_CATEGORIES)[number]\n\n/** The category that is always granted and can't be refused. */\nexport const REQUIRED_CATEGORY = 'necessary' satisfies ConsentCategoryId\n\n/** Whether a value is one of the fixed category ids. */\nexport function isConsentCategoryId(value: unknown): value is ConsentCategoryId {\n return (CONSENT_CATEGORIES as readonly unknown[]).includes(value)\n}\n","/** Thrown for an invalid consent configuration or an invalid stored decision. */\nexport class ConsentError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'ConsentError'\n }\n}\n","/**\n * Converts a human-readable name to a stable snake_case machine name.\n *\n * - Normalizes Unicode (NFD) and strips diacritics (é → e, ñ → n, …)\n * - Lowercases\n * - Replaces any run of non-alphanumeric characters with a single underscore\n * - Trims leading/trailing underscores\n */\nexport function toMachineName(name: string): string {\n return name\n .normalize('NFD')\n .replace(/\\p{M}/gu, '') // strip combining marks (diacritics)\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '_') // non-alphanumeric runs → _\n .replace(/^_|_$/g, '') // trim edges\n}\n","import type { ConsentCategoryId } from './categories'\nimport { ConsentError } from './errors'\nimport type {\n ConsentCookie,\n ConsentCookieParty,\n ConsentCookieType,\n ConsentCookieWordedMaxAge,\n ConsentTransferSafeguard,\n ConsentVendor,\n ConsentVendorDeclaration,\n} from './types'\nimport { toMachineName } from './utils/to-machine-name'\n\n// Every text a cookie list needs has one translation key: a snake_case machine name, like a\n// country's. The categories and the generic words carry a `consent_` prefix, so they can't clash\n// with the app's own keys; a vendor's is its id, a cookie's is its vendor's plus its name.\n\n/** @internal A category's name key, e.g. `consent_category_statistics`. */\nexport const categoryMachineName = (id: ConsentCategoryId) => `consent_category_${id}`\n\n/** @internal A cookie type's key, e.g. `consent_cookie_type_local_storage`. */\nexport const cookieTypeMachineName = (type: ConsentCookieType) => `consent_cookie_type_${type}`\n\n/** @internal A worded lifetime's key: `consent_max_age_session` / `consent_max_age_persistent`. */\nexport const maxAgeMachineName = (maxAge: ConsentCookieWordedMaxAge) => `consent_max_age_${maxAge}`\n\n/** @internal A cookie party's key: `consent_cookie_party_first` / `consent_cookie_party_third`. */\nexport const partyMachineName = (party: ConsentCookieParty) => `consent_cookie_party_${party}`\n\n/** @internal A transfer safeguard's key, e.g. `consent_transfer_safeguard_dpf`. */\nexport const safeguardMachineName = (safeguard: ConsentTransferSafeguard) =>\n `consent_transfer_safeguard_${safeguard}`\n\n/**\n * @internal A cookie's key: its vendor's machine name plus its name, a `*` read as `wildcard` —\n * `google_analytics` + `_ga_*` → `google_analytics_ga_wildcard`.\n */\nexport function cookieMachineName(vendor: string, cookieName: string): string {\n const name = toMachineName(cookieName.replaceAll('*', ' wildcard '))\n return name === '' ? '' : `${vendor}_${name}`\n}\n\n/**\n * @internal A vendor declaration with its machine names, cookies included. Throws when its id or a\n * cookie name has no letters or digits, or when two cookie names come out the same.\n */\nexport function toConsentVendor(declaration: ConsentVendorDeclaration): ConsentVendor {\n const where = `Vendor \"${declaration.id}\"`\n const machine_name = toMachineName(declaration.id)\n if (machine_name === '') {\n throw new ConsentError(`${where}: the id needs letters or digits for its machine name.`)\n }\n const byMachineName = new Map<string, string>()\n const cookies: ConsentCookie[] = declaration.cookies.map((cookie) => {\n const key = cookieMachineName(machine_name, cookie.name)\n if (key === '') {\n throw new ConsentError(`${where}: cookie \"${cookie.name}\" needs letters or digits.`)\n }\n const clash = byMachineName.get(key)\n if (clash !== undefined && clash !== cookie.name) {\n throw new ConsentError(\n `${where}: cookies \"${clash}\" and \"${cookie.name}\" have the same machine name \"${key}\".`,\n )\n }\n byMachineName.set(key, cookie.name)\n const party: ConsentCookieParty = cookie.domain === undefined ? 'first' : 'third'\n return {\n ...cookie,\n machine_name: key,\n type_machine_name: cookieTypeMachineName(cookie.type ?? 'http'),\n party,\n party_machine_name: partyMachineName(party),\n ...(typeof cookie.max_age === 'string'\n ? { max_age_machine_name: maxAgeMachineName(cookie.max_age) }\n : {}),\n }\n })\n const { transfers: declared, ...rest } = declaration\n const transfers = declared?.map((transfer) => ({\n ...transfer,\n safeguard_machine_names: transfer.safeguards.map(safeguardMachineName),\n }))\n return {\n ...rest,\n machine_name,\n ...(transfers !== undefined ? { transfers } : {}),\n cookies,\n }\n}\n"],"mappings":";;;;;;;AAMA,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C,MAAM,IAAI,aACR,GAAG,MAAM,aAAa,MAAM,SAAS,OAAO,KAAK,gCAAgC,IAAI,GACvF;EAEF,cAAc,IAAI,KAAK,OAAO,IAAI;EAClC,MAAM,QAA4B,OAAO,WAAW,KAAA,IAAY,UAAU;EAC1E,OAAO;GACL,GAAG;GACH,cAAc;GACd,mBAAmB,sBAAsB,OAAO,QAAQ,MAAM;GAC9D;GACA,oBAAoB,iBAAiB,KAAK;GAC1C,GAAI,OAAO,OAAO,YAAY,WAC1B,EAAE,sBAAsB,kBAAkB,OAAO,OAAO,EAAE,IAC1D,CAAC;EACP;CACF,CAAC;CACD,MAAM,EAAE,WAAW,UAAU,GAAG,SAAS;CACzC,MAAM,YAAY,UAAU,KAAK,cAAc;EAC7C,GAAG;EACH,yBAAyB,SAAS,WAAW,IAAI,oBAAoB;CACvE,EAAE;CACF,OAAO;EACL,GAAG;EACH;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;EAC/C;CACF;AACF"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
//#region src/categories.ts
|
|
2
|
+
/**
|
|
3
|
+
* The fixed consent categories, in display order — the same four every consent tool (and Google
|
|
4
|
+
* Consent Mode) works with. `necessary` is always granted. A category's name and description are
|
|
5
|
+
* translated by machine name (`consent_category_<id>`, `consent_category_<id>_description`) from
|
|
6
|
+
* the package catalogs.
|
|
7
|
+
*/
|
|
8
|
+
const CONSENT_CATEGORIES = [
|
|
9
|
+
"necessary",
|
|
10
|
+
"preferences",
|
|
11
|
+
"statistics",
|
|
12
|
+
"marketing"
|
|
13
|
+
];
|
|
14
|
+
/** The category that is always granted and can't be refused. */
|
|
15
|
+
const REQUIRED_CATEGORY = "necessary";
|
|
16
|
+
/** Whether a value is one of the fixed category ids. */
|
|
17
|
+
function isConsentCategoryId(value) {
|
|
18
|
+
return CONSENT_CATEGORIES.includes(value);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/errors.ts
|
|
22
|
+
/** Thrown for an invalid consent configuration or an invalid stored decision. */
|
|
23
|
+
var ConsentError = class extends Error {
|
|
24
|
+
constructor(message) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ConsentError";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/utils/to-machine-name.ts
|
|
31
|
+
/**
|
|
32
|
+
* Converts a human-readable name to a stable snake_case machine name.
|
|
33
|
+
*
|
|
34
|
+
* - Normalizes Unicode (NFD) and strips diacritics (é → e, ñ → n, …)
|
|
35
|
+
* - Lowercases
|
|
36
|
+
* - Replaces any run of non-alphanumeric characters with a single underscore
|
|
37
|
+
* - Trims leading/trailing underscores
|
|
38
|
+
*/
|
|
39
|
+
function toMachineName(name) {
|
|
40
|
+
return name.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/machine-names.ts
|
|
44
|
+
/** @internal A category's name key, e.g. `consent_category_statistics`. */
|
|
45
|
+
const categoryMachineName = (id) => `consent_category_${id}`;
|
|
46
|
+
/** @internal A cookie type's key, e.g. `consent_cookie_type_local_storage`. */
|
|
47
|
+
const cookieTypeMachineName = (type) => `consent_cookie_type_${type}`;
|
|
48
|
+
/** @internal A worded lifetime's key: `consent_max_age_session` / `consent_max_age_persistent`. */
|
|
49
|
+
const maxAgeMachineName = (maxAge) => `consent_max_age_${maxAge}`;
|
|
50
|
+
/** @internal A cookie party's key: `consent_cookie_party_first` / `consent_cookie_party_third`. */
|
|
51
|
+
const partyMachineName = (party) => `consent_cookie_party_${party}`;
|
|
52
|
+
/** @internal A transfer safeguard's key, e.g. `consent_transfer_safeguard_dpf`. */
|
|
53
|
+
const safeguardMachineName = (safeguard) => `consent_transfer_safeguard_${safeguard}`;
|
|
54
|
+
/**
|
|
55
|
+
* @internal A cookie's key: its vendor's machine name plus its name, a `*` read as `wildcard` —
|
|
56
|
+
* `google_analytics` + `_ga_*` → `google_analytics_ga_wildcard`.
|
|
57
|
+
*/
|
|
58
|
+
function cookieMachineName(vendor, cookieName) {
|
|
59
|
+
const name = toMachineName(cookieName.replaceAll("*", " wildcard "));
|
|
60
|
+
return name === "" ? "" : `${vendor}_${name}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @internal A vendor declaration with its machine names, cookies included. Throws when its id or a
|
|
64
|
+
* cookie name has no letters or digits, or when two cookie names come out the same.
|
|
65
|
+
*/
|
|
66
|
+
function toConsentVendor(declaration) {
|
|
67
|
+
const where = `Vendor "${declaration.id}"`;
|
|
68
|
+
const machine_name = toMachineName(declaration.id);
|
|
69
|
+
if (machine_name === "") throw new ConsentError(`${where}: the id needs letters or digits for its machine name.`);
|
|
70
|
+
const byMachineName = /* @__PURE__ */ new Map();
|
|
71
|
+
const cookies = declaration.cookies.map((cookie) => {
|
|
72
|
+
const key = cookieMachineName(machine_name, cookie.name);
|
|
73
|
+
if (key === "") throw new ConsentError(`${where}: cookie "${cookie.name}" needs letters or digits.`);
|
|
74
|
+
const clash = byMachineName.get(key);
|
|
75
|
+
if (clash !== void 0 && clash !== cookie.name) throw new ConsentError(`${where}: cookies "${clash}" and "${cookie.name}" have the same machine name "${key}".`);
|
|
76
|
+
byMachineName.set(key, cookie.name);
|
|
77
|
+
const party = cookie.domain === void 0 ? "first" : "third";
|
|
78
|
+
return {
|
|
79
|
+
...cookie,
|
|
80
|
+
machine_name: key,
|
|
81
|
+
type_machine_name: cookieTypeMachineName(cookie.type ?? "http"),
|
|
82
|
+
party,
|
|
83
|
+
party_machine_name: partyMachineName(party),
|
|
84
|
+
...typeof cookie.max_age === "string" ? { max_age_machine_name: maxAgeMachineName(cookie.max_age) } : {}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
const { transfers: declared, ...rest } = declaration;
|
|
88
|
+
const transfers = declared?.map((transfer) => ({
|
|
89
|
+
...transfer,
|
|
90
|
+
safeguard_machine_names: transfer.safeguards.map(safeguardMachineName)
|
|
91
|
+
}));
|
|
92
|
+
return {
|
|
93
|
+
...rest,
|
|
94
|
+
machine_name,
|
|
95
|
+
...transfers !== void 0 ? { transfers } : {},
|
|
96
|
+
cookies
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
Object.defineProperty(exports, "CONSENT_CATEGORIES", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function() {
|
|
103
|
+
return CONSENT_CATEGORIES;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
Object.defineProperty(exports, "ConsentError", {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function() {
|
|
109
|
+
return ConsentError;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "REQUIRED_CATEGORY", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function() {
|
|
115
|
+
return REQUIRED_CATEGORY;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(exports, "categoryMachineName", {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function() {
|
|
121
|
+
return categoryMachineName;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, "isConsentCategoryId", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function() {
|
|
127
|
+
return isConsentCategoryId;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
Object.defineProperty(exports, "toConsentVendor", {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function() {
|
|
133
|
+
return toConsentVendor;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=machine-names-DCujHBVM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine-names-DCujHBVM.cjs","names":[],"sources":["../src/categories.ts","../src/errors.ts","../src/utils/to-machine-name.ts","../src/machine-names.ts"],"sourcesContent":["/**\n * The fixed consent categories, in display order — the same four every consent tool (and Google\n * Consent Mode) works with. `necessary` is always granted. A category's name and description are\n * translated by machine name (`consent_category_<id>`, `consent_category_<id>_description`) from\n * the package catalogs.\n */\nexport const CONSENT_CATEGORIES = ['necessary', 'preferences', 'statistics', 'marketing'] as const\n\n/** `'necessary' | 'preferences' | 'statistics' | 'marketing'` */\nexport type ConsentCategoryId = (typeof CONSENT_CATEGORIES)[number]\n\n/** The category that is always granted and can't be refused. */\nexport const REQUIRED_CATEGORY = 'necessary' satisfies ConsentCategoryId\n\n/** Whether a value is one of the fixed category ids. */\nexport function isConsentCategoryId(value: unknown): value is ConsentCategoryId {\n return (CONSENT_CATEGORIES as readonly unknown[]).includes(value)\n}\n","/** Thrown for an invalid consent configuration or an invalid stored decision. */\nexport class ConsentError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'ConsentError'\n }\n}\n","/**\n * Converts a human-readable name to a stable snake_case machine name.\n *\n * - Normalizes Unicode (NFD) and strips diacritics (é → e, ñ → n, …)\n * - Lowercases\n * - Replaces any run of non-alphanumeric characters with a single underscore\n * - Trims leading/trailing underscores\n */\nexport function toMachineName(name: string): string {\n return name\n .normalize('NFD')\n .replace(/\\p{M}/gu, '') // strip combining marks (diacritics)\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '_') // non-alphanumeric runs → _\n .replace(/^_|_$/g, '') // trim edges\n}\n","import type { ConsentCategoryId } from './categories'\nimport { ConsentError } from './errors'\nimport type {\n ConsentCookie,\n ConsentCookieParty,\n ConsentCookieType,\n ConsentCookieWordedMaxAge,\n ConsentTransferSafeguard,\n ConsentVendor,\n ConsentVendorDeclaration,\n} from './types'\nimport { toMachineName } from './utils/to-machine-name'\n\n// Every text a cookie list needs has one translation key: a snake_case machine name, like a\n// country's. The categories and the generic words carry a `consent_` prefix, so they can't clash\n// with the app's own keys; a vendor's is its id, a cookie's is its vendor's plus its name.\n\n/** @internal A category's name key, e.g. `consent_category_statistics`. */\nexport const categoryMachineName = (id: ConsentCategoryId) => `consent_category_${id}`\n\n/** @internal A cookie type's key, e.g. `consent_cookie_type_local_storage`. */\nexport const cookieTypeMachineName = (type: ConsentCookieType) => `consent_cookie_type_${type}`\n\n/** @internal A worded lifetime's key: `consent_max_age_session` / `consent_max_age_persistent`. */\nexport const maxAgeMachineName = (maxAge: ConsentCookieWordedMaxAge) => `consent_max_age_${maxAge}`\n\n/** @internal A cookie party's key: `consent_cookie_party_first` / `consent_cookie_party_third`. */\nexport const partyMachineName = (party: ConsentCookieParty) => `consent_cookie_party_${party}`\n\n/** @internal A transfer safeguard's key, e.g. `consent_transfer_safeguard_dpf`. */\nexport const safeguardMachineName = (safeguard: ConsentTransferSafeguard) =>\n `consent_transfer_safeguard_${safeguard}`\n\n/**\n * @internal A cookie's key: its vendor's machine name plus its name, a `*` read as `wildcard` —\n * `google_analytics` + `_ga_*` → `google_analytics_ga_wildcard`.\n */\nexport function cookieMachineName(vendor: string, cookieName: string): string {\n const name = toMachineName(cookieName.replaceAll('*', ' wildcard '))\n return name === '' ? '' : `${vendor}_${name}`\n}\n\n/**\n * @internal A vendor declaration with its machine names, cookies included. Throws when its id or a\n * cookie name has no letters or digits, or when two cookie names come out the same.\n */\nexport function toConsentVendor(declaration: ConsentVendorDeclaration): ConsentVendor {\n const where = `Vendor \"${declaration.id}\"`\n const machine_name = toMachineName(declaration.id)\n if (machine_name === '') {\n throw new ConsentError(`${where}: the id needs letters or digits for its machine name.`)\n }\n const byMachineName = new Map<string, string>()\n const cookies: ConsentCookie[] = declaration.cookies.map((cookie) => {\n const key = cookieMachineName(machine_name, cookie.name)\n if (key === '') {\n throw new ConsentError(`${where}: cookie \"${cookie.name}\" needs letters or digits.`)\n }\n const clash = byMachineName.get(key)\n if (clash !== undefined && clash !== cookie.name) {\n throw new ConsentError(\n `${where}: cookies \"${clash}\" and \"${cookie.name}\" have the same machine name \"${key}\".`,\n )\n }\n byMachineName.set(key, cookie.name)\n const party: ConsentCookieParty = cookie.domain === undefined ? 'first' : 'third'\n return {\n ...cookie,\n machine_name: key,\n type_machine_name: cookieTypeMachineName(cookie.type ?? 'http'),\n party,\n party_machine_name: partyMachineName(party),\n ...(typeof cookie.max_age === 'string'\n ? { max_age_machine_name: maxAgeMachineName(cookie.max_age) }\n : {}),\n }\n })\n const { transfers: declared, ...rest } = declaration\n const transfers = declared?.map((transfer) => ({\n ...transfer,\n safeguard_machine_names: transfer.safeguards.map(safeguardMachineName),\n }))\n return {\n ...rest,\n machine_name,\n ...(transfers !== undefined ? { transfers } : {}),\n cookies,\n }\n}\n"],"mappings":";;;;;;;AAMA,MAAa,qBAAqB;CAAC;CAAa;CAAe;CAAc;AAAW;;AAMxF,MAAa,oBAAoB;;AAGjC,SAAgB,oBAAoB,OAA4C;CAC9E,OAAQ,mBAA0C,SAAS,KAAK;AAClE;;;;AChBA,IAAa,eAAb,cAAkC,MAAM;CACtC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;;ACEA,SAAgB,cAAc,MAAsB;CAClD,OAAO,KACJ,UAAU,KAAK,CAAC,CAChB,QAAQ,WAAW,EAAE,CAAC,CACtB,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,UAAU,EAAE;AACzB;;;;ACGA,MAAa,uBAAuB,OAA0B,oBAAoB;;AAGlF,MAAa,yBAAyB,SAA4B,uBAAuB;;AAGzF,MAAa,qBAAqB,WAAsC,mBAAmB;;AAG3F,MAAa,oBAAoB,UAA8B,wBAAwB;;AAGvF,MAAa,wBAAwB,cACnC,8BAA8B;;;;;AAMhC,SAAgB,kBAAkB,QAAgB,YAA4B;CAC5E,MAAM,OAAO,cAAc,WAAW,WAAW,KAAK,YAAY,CAAC;CACnE,OAAO,SAAS,KAAK,KAAK,GAAG,OAAO,GAAG;AACzC;;;;;AAMA,SAAgB,gBAAgB,aAAsD;CACpF,MAAM,QAAQ,WAAW,YAAY,GAAG;CACxC,MAAM,eAAe,cAAc,YAAY,EAAE;CACjD,IAAI,iBAAiB,IACnB,MAAM,IAAI,aAAa,GAAG,MAAM,uDAAuD;CAEzF,MAAM,gCAAgB,IAAI,IAAoB;CAC9C,MAAM,UAA2B,YAAY,QAAQ,KAAK,WAAW;EACnE,MAAM,MAAM,kBAAkB,cAAc,OAAO,IAAI;EACvD,IAAI,QAAQ,IACV,MAAM,IAAI,aAAa,GAAG,MAAM,YAAY,OAAO,KAAK,2BAA2B;EAErF,MAAM,QAAQ,cAAc,IAAI,GAAG;EACnC,IAAI,UAAU,KAAA,KAAa,UAAU,OAAO,MAC1C,MAAM,IAAI,aACR,GAAG,MAAM,aAAa,MAAM,SAAS,OAAO,KAAK,gCAAgC,IAAI,GACvF;EAEF,cAAc,IAAI,KAAK,OAAO,IAAI;EAClC,MAAM,QAA4B,OAAO,WAAW,KAAA,IAAY,UAAU;EAC1E,OAAO;GACL,GAAG;GACH,cAAc;GACd,mBAAmB,sBAAsB,OAAO,QAAQ,MAAM;GAC9D;GACA,oBAAoB,iBAAiB,KAAK;GAC1C,GAAI,OAAO,OAAO,YAAY,WAC1B,EAAE,sBAAsB,kBAAkB,OAAO,OAAO,EAAE,IAC1D,CAAC;EACP;CACF,CAAC;CACD,MAAM,EAAE,WAAW,UAAU,GAAG,SAAS;CACzC,MAAM,YAAY,UAAU,KAAK,cAAc;EAC7C,GAAG;EACH,yBAAyB,SAAS,WAAW,IAAI,oBAAoB;CACvE,EAAE;CACF,OAAO;EACL,GAAG;EACH;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;EAC/C;CACF;AACF"}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_used_vendors = require("./used-vendors-C8uSNIkd.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
//#region src/react/consent-context.ts
|
|
6
|
+
const ConsentContext = (0, react.createContext)(null);
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/react/use-consent.ts
|
|
9
|
+
/** @internal Reads the raw context; throws outside `<Consent>`. */
|
|
10
|
+
function useConsentContext() {
|
|
11
|
+
const ctx = (0, react.useContext)(ConsentContext);
|
|
12
|
+
if (!ctx) throw new Error("useConsent must be used within <Consent consent={…}>.");
|
|
13
|
+
return ctx;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The visitor's consent, reactively, plus the actions to change it.
|
|
17
|
+
*
|
|
18
|
+
* @throws {Error} outside `<Consent>`.
|
|
19
|
+
*/
|
|
20
|
+
function useConsent() {
|
|
21
|
+
const { consent, snapshot, isPreferencesOpen, setPreferencesOpen } = useConsentContext();
|
|
22
|
+
return (0, react.useMemo)(() => {
|
|
23
|
+
const m = consent;
|
|
24
|
+
const decision = snapshot.decision;
|
|
25
|
+
const closing = (fn) => (...args) => {
|
|
26
|
+
fn(...args);
|
|
27
|
+
setPreferencesOpen(false);
|
|
28
|
+
};
|
|
29
|
+
const usedIn = require_used_vendors.usedVendors(m.categories);
|
|
30
|
+
const isGranted = (id, vendorId) => (vendorId === void 0 || usedIn[id]?.has(vendorId) === true) && (m.isRequired(id) || (decision?.isGranted(id) ?? false));
|
|
31
|
+
return {
|
|
32
|
+
consent: m,
|
|
33
|
+
status: snapshot.status,
|
|
34
|
+
decision,
|
|
35
|
+
categories: m.categories,
|
|
36
|
+
needsDecision: snapshot.status === "pending",
|
|
37
|
+
isGranted,
|
|
38
|
+
isRequired: (id) => m.isRequired(id),
|
|
39
|
+
acceptAll: closing(() => m.acceptAll()),
|
|
40
|
+
rejectAll: closing(() => m.rejectAll()),
|
|
41
|
+
save: closing((granted) => m.save(granted)),
|
|
42
|
+
grant: (...ids) => void m.grant(...ids),
|
|
43
|
+
revoke: (...ids) => void m.revoke(...ids),
|
|
44
|
+
reset: () => m.reset(),
|
|
45
|
+
isPreferencesOpen,
|
|
46
|
+
openPreferences: () => setPreferencesOpen(true),
|
|
47
|
+
closePreferences: () => setPreferencesOpen(false)
|
|
48
|
+
};
|
|
49
|
+
}, [
|
|
50
|
+
consent,
|
|
51
|
+
snapshot,
|
|
52
|
+
isPreferencesOpen,
|
|
53
|
+
setPreferencesOpen
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/react/consent-gate.tsx
|
|
58
|
+
/**
|
|
59
|
+
* Renders its children only once consent allows them — for embeds and widgets that set cookies or
|
|
60
|
+
* track (a YouTube player, a map, a chat widget). Shows `fallback` otherwise, including on the
|
|
61
|
+
* server and during hydration, so tracking content never renders before consent.
|
|
62
|
+
*
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <ConsentGate
|
|
65
|
+
* category="preferences"
|
|
66
|
+
* vendor="youtube"
|
|
67
|
+
* fallback={(gate) => <button type="button" onClick={gate.grant}>Load video</button>}
|
|
68
|
+
* >
|
|
69
|
+
* <iframe src="https://www.youtube-nocookie.com/embed/…" />
|
|
70
|
+
* </ConsentGate>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function ConsentGate({ category, vendor, fallback = null, children }) {
|
|
74
|
+
const consent = useConsent();
|
|
75
|
+
const required = typeof category === "string" ? [category] : category;
|
|
76
|
+
const usedIn = (id) => consent.categories.find((c) => c.id === id)?.vendors.some((v) => v.id === vendor);
|
|
77
|
+
if (vendor !== void 0 && !required.every(usedIn)) return null;
|
|
78
|
+
const missing = required.filter((id) => !consent.isGranted(id));
|
|
79
|
+
if (missing.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
80
|
+
if (typeof fallback !== "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback });
|
|
81
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: fallback({
|
|
82
|
+
missing,
|
|
83
|
+
grant: () => consent.grant(...missing),
|
|
84
|
+
openPreferences: consent.openPreferences
|
|
85
|
+
}) });
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/react/consent-provider.tsx
|
|
89
|
+
const SERVER_SNAPSHOT = Object.freeze({
|
|
90
|
+
status: "unknown",
|
|
91
|
+
decision: null
|
|
92
|
+
});
|
|
93
|
+
const getServerSnapshot = () => SERVER_SNAPSHOT;
|
|
94
|
+
/**
|
|
95
|
+
* Supplies a consent instance to the tree and keeps it reactive: every `useConsent()` and
|
|
96
|
+
* `<ConsentGate>` below re-renders when the decision changes — in this tab or another. Also owns
|
|
97
|
+
* whether your app's preferences UI is open, so a "Cookie settings" link anywhere (a footer) can
|
|
98
|
+
* reopen it with `openPreferences()`.
|
|
99
|
+
*/
|
|
100
|
+
function Consent({ consent, children }) {
|
|
101
|
+
const snapshot = (0, react.useSyncExternalStore)(consent.subscribe, consent.getSnapshot, getServerSnapshot);
|
|
102
|
+
const [isPreferencesOpen, setPreferencesOpen] = (0, react.useState)(false);
|
|
103
|
+
const value = (0, react.useMemo)(() => ({
|
|
104
|
+
consent,
|
|
105
|
+
snapshot,
|
|
106
|
+
isPreferencesOpen,
|
|
107
|
+
setPreferencesOpen
|
|
108
|
+
}), [
|
|
109
|
+
consent,
|
|
110
|
+
snapshot,
|
|
111
|
+
isPreferencesOpen
|
|
112
|
+
]);
|
|
113
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConsentContext.Provider, {
|
|
114
|
+
value,
|
|
115
|
+
children
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
exports.Consent = Consent;
|
|
120
|
+
exports.ConsentContext = ConsentContext;
|
|
121
|
+
exports.ConsentGate = ConsentGate;
|
|
122
|
+
exports.useConsent = useConsent;
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.cjs","names":["createContext","useContext","useMemo","usedVendors","useSyncExternalStore","useState","useMemo"],"sources":["../src/react/consent-context.ts","../src/react/use-consent.ts","../src/react/consent-gate.tsx","../src/react/consent-provider.tsx"],"sourcesContent":["import { createContext } from 'react'\nimport type { ConsentManager, ConsentSnapshot } from '../types'\n\nexport interface ConsentContextValue {\n consent: ConsentManager\n snapshot: ConsentSnapshot\n isPreferencesOpen: boolean\n setPreferencesOpen: (open: boolean) => void\n}\n\nexport const ConsentContext = createContext<ConsentContextValue | null>(null)\n","import { useContext, useMemo } from 'react'\nimport type { ConsentCategoryId } from '../categories'\nimport type { ConsentDecision } from '../domain/consent-decision'\nimport type { ConsentCategory, ConsentManager, ConsentStatus } from '../types'\nimport { usedVendors } from '../used-vendors'\nimport { ConsentContext, type ConsentContextValue } from './consent-context'\n\nexport interface UseConsentReturn {\n /** The underlying instance. */\n consent: ConsentManager\n /** `unknown` during SSR/hydration, then `pending` or `decided`. */\n status: ConsentStatus\n /** The valid decision, or `null` while `pending` / `unknown`. */\n decision: ConsentDecision | null\n /** The four categories in order, each with its vendors and their cookies. */\n categories: readonly ConsentCategory[]\n /** Whether the visitor should be asked (status `pending`). `false` while `unknown`. */\n needsDecision: boolean\n /**\n * Reactive: necessary always, others only once decided. With a vendor, also whether it's used in\n * that category — `isGranted('preferences', 'youtube')`.\n */\n isGranted: (category: ConsentCategoryId, vendorId?: string) => boolean\n isRequired: (category: ConsentCategoryId) => boolean\n /** Grant everything (closes the preferences). */\n acceptAll: () => void\n /** Grant only the required categories (closes the preferences). */\n rejectAll: () => void\n /** Grant exactly these (closes the preferences). */\n save: (granted: Iterable<ConsentCategoryId>) => void\n /** Grant these on top of the current decision. */\n grant: (...ids: ConsentCategoryId[]) => void\n /** Withdraw these from the current decision. */\n revoke: (...ids: ConsentCategoryId[]) => void\n /** Forget the decision — the banner shows again. */\n reset: () => void\n /** Whether the preferences are open (shared across the tree). */\n isPreferencesOpen: boolean\n openPreferences: () => void\n closePreferences: () => void\n}\n\n/** @internal Reads the raw context; throws outside `<Consent>`. */\nexport function useConsentContext(): ConsentContextValue {\n const ctx = useContext(ConsentContext)\n if (!ctx) throw new Error('useConsent must be used within <Consent consent={…}>.')\n return ctx\n}\n\n/**\n * The visitor's consent, reactively, plus the actions to change it.\n *\n * @throws {Error} outside `<Consent>`.\n */\nexport function useConsent(): UseConsentReturn {\n const { consent, snapshot, isPreferencesOpen, setPreferencesOpen } = useConsentContext()\n return useMemo(() => {\n const m = consent\n const decision = snapshot.decision\n const closing =\n <A extends unknown[]>(fn: (...args: A) => unknown) =>\n (...args: A) => {\n fn(...args)\n setPreferencesOpen(false)\n }\n const usedIn = usedVendors(m.categories)\n const isGranted = (id: ConsentCategoryId, vendorId?: string) =>\n (vendorId === undefined || usedIn[id]?.has(vendorId) === true) &&\n (m.isRequired(id) || (decision?.isGranted(id) ?? false))\n return {\n consent: m,\n status: snapshot.status,\n decision,\n categories: m.categories,\n needsDecision: snapshot.status === 'pending',\n isGranted,\n isRequired: (id) => m.isRequired(id),\n acceptAll: closing(() => m.acceptAll()),\n rejectAll: closing(() => m.rejectAll()),\n save: closing((granted: Iterable<ConsentCategoryId>) => m.save(granted)),\n grant: (...ids) => void m.grant(...ids),\n revoke: (...ids) => void m.revoke(...ids),\n reset: () => m.reset(),\n isPreferencesOpen,\n openPreferences: () => setPreferencesOpen(true),\n closePreferences: () => setPreferencesOpen(false),\n }\n }, [consent, snapshot, isPreferencesOpen, setPreferencesOpen])\n}\n","import type { ReactNode } from 'react'\nimport type { ConsentCategoryId } from '../categories'\nimport { useConsent } from './use-consent'\n\ntype Id = ConsentCategoryId\n\nexport interface ConsentGateApi {\n /** The categories still missing. */\n missing: readonly Id[]\n /** Grant the missing categories right here (\"Load video\" on a placeholder). */\n grant: () => void\n /** Open the preferences instead. */\n openPreferences: () => void\n}\n\nexport interface ConsentGateProps {\n /** The category — or categories, all required — the content needs. */\n category: Id | readonly Id[]\n /**\n * The vendor the content belongs to (`\"youtube\"`). The gate then also needs that vendor to be used\n * in the category — and renders nothing, not even the fallback, when it isn't: that integration\n * is off for this app.\n */\n vendor?: string\n /** Rendered instead while consent is missing. A function gets the gate's api. */\n fallback?: ReactNode | ((api: ConsentGateApi) => ReactNode)\n children?: ReactNode\n}\n\n/**\n * Renders its children only once consent allows them — for embeds and widgets that set cookies or\n * track (a YouTube player, a map, a chat widget). Shows `fallback` otherwise, including on the\n * server and during hydration, so tracking content never renders before consent.\n *\n * ```tsx\n * <ConsentGate\n * category=\"preferences\"\n * vendor=\"youtube\"\n * fallback={(gate) => <button type=\"button\" onClick={gate.grant}>Load video</button>}\n * >\n * <iframe src=\"https://www.youtube-nocookie.com/embed/…\" />\n * </ConsentGate>\n * ```\n */\nexport function ConsentGate({ category, vendor, fallback = null, children }: ConsentGateProps) {\n const consent = useConsent()\n const required = (typeof category === 'string' ? [category] : category) as readonly Id[]\n // A vendor that isn't used in (every one of) these categories: the integration is off.\n const usedIn = (id: Id) =>\n consent.categories.find((c) => c.id === id)?.vendors.some((v) => v.id === vendor)\n if (vendor !== undefined && !required.every(usedIn)) return null\n const missing = required.filter((id) => !consent.isGranted(id))\n\n if (missing.length === 0) return <>{children}</>\n if (typeof fallback !== 'function') return <>{fallback}</>\n return (\n <>\n {fallback({\n missing,\n grant: () => consent.grant(...missing),\n openPreferences: consent.openPreferences,\n })}\n </>\n )\n}\n","import type { ReactNode } from 'react'\nimport { useMemo, useState, useSyncExternalStore } from 'react'\nimport type { ConsentManager, ConsentSnapshot } from '../types'\nimport { ConsentContext, type ConsentContextValue } from './consent-context'\n\n// Storage is out of reach on the server: render as `unknown` (gates closed, no banner) and let the\n// client snapshot take over after hydration — so a visitor who already decided never sees a flash.\nconst SERVER_SNAPSHOT: ConsentSnapshot = Object.freeze({ status: 'unknown', decision: null })\nconst getServerSnapshot = () => SERVER_SNAPSHOT\n\nexport interface ConsentProps {\n /** The instance from `createConsent(config)`. */\n consent: ConsentManager\n children?: ReactNode\n}\n\n/**\n * Supplies a consent instance to the tree and keeps it reactive: every `useConsent()` and\n * `<ConsentGate>` below re-renders when the decision changes — in this tab or another. Also owns\n * whether your app's preferences UI is open, so a \"Cookie settings\" link anywhere (a footer) can\n * reopen it with `openPreferences()`.\n */\nexport function Consent({ consent, children }: ConsentProps) {\n const snapshot = useSyncExternalStore(consent.subscribe, consent.getSnapshot, getServerSnapshot)\n const [isPreferencesOpen, setPreferencesOpen] = useState(false)\n\n const value = useMemo<ConsentContextValue>(\n () => ({ consent, snapshot, isPreferencesOpen, setPreferencesOpen }),\n [consent, snapshot, isPreferencesOpen],\n )\n return <ConsentContext.Provider value={value}>{children}</ConsentContext.Provider>\n}\n"],"mappings":";;;;;AAUA,MAAa,kBAAA,GAAiBA,MAAAA,cAAAA,CAA0C,IAAI;;;;ACiC5E,SAAgB,oBAAyC;CACvD,MAAM,OAAA,GAAMC,MAAAA,WAAAA,CAAW,cAAc;CACrC,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,uDAAuD;CACjF,OAAO;AACT;;;;;;AAOA,SAAgB,aAA+B;CAC7C,MAAM,EAAE,SAAS,UAAU,mBAAmB,uBAAuB,kBAAkB;CACvF,QAAA,GAAOC,MAAAA,QAAAA,OAAc;EACnB,MAAM,IAAI;EACV,MAAM,WAAW,SAAS;EAC1B,MAAM,WACkB,QACrB,GAAG,SAAY;GACd,GAAG,GAAG,IAAI;GACV,mBAAmB,KAAK;EAC1B;EACF,MAAM,SAASC,qBAAAA,YAAY,EAAE,UAAU;EACvC,MAAM,aAAa,IAAuB,cACvC,aAAa,KAAA,KAAa,OAAO,GAAG,EAAE,IAAI,QAAQ,MAAM,UACxD,EAAE,WAAW,EAAE,MAAM,UAAU,UAAU,EAAE,KAAK;EACnD,OAAO;GACL,SAAS;GACT,QAAQ,SAAS;GACjB;GACA,YAAY,EAAE;GACd,eAAe,SAAS,WAAW;GACnC;GACA,aAAa,OAAO,EAAE,WAAW,EAAE;GACnC,WAAW,cAAc,EAA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