@luwiostack/cookie-consent 0.1.0 → 0.3.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":"vendors.mjs","names":[],"sources":["../src/vendors/define-vendor.ts","../src/vendors/time.ts","../src/vendors/google-ads.ts","../src/vendors/google-analytics.ts","../src/vendors/google-maps.ts","../src/vendors/google-recaptcha.ts","../src/vendors/hotjar.ts","../src/vendors/linkedin-insight.ts","../src/vendors/meta-pixel.ts","../src/vendors/tiktok-pixel.ts","../src/vendors/vimeo.ts","../src/vendors/youtube.ts","../src/vendors/presets.ts","../src/vendors/from-data.ts"],"sourcesContent":["import { ConsentError } from '../errors'\nimport type { ConsentCookie, ConsentVendor } from '../types'\n\nexport interface VendorPresetOptions<Name extends string = string> {\n /**\n * Only these of the preset's cookies — for when your integration doesn't set them all (e.g. no\n * Google Signals). Default: every cookie in the preset. An unknown name is a type error and throws.\n */\n cookies?: readonly Name[]\n /** Your own cookies on top, for anything this vendor sets in your setup that the preset lacks. */\n extra?: readonly ConsentCookie[]\n}\n\n/** A ready-made vendor: call it (optionally narrowing or extending its cookies) to get a `ConsentVendor`. */\nexport interface VendorPreset<Name extends string = string> {\n (options?: VendorPresetOptions<Name>): ConsentVendor\n /** The vendor id — also the translation key of its name. */\n readonly id: string\n /** Every cookie the preset declares. */\n readonly cookies: readonly ConsentCookie[]\n}\n\nexport interface VendorDefinition<C extends readonly ConsentCookie[]> {\n /** Stable key — also the translation key for the vendor's name, and the prefix of its cookies' keys. */\n id: string\n privacy_policy_url?: string\n cookies: C\n}\n\n/**\n * Define a reusable vendor preset — how every preset in `@luwiostack/cookie-consent/vendors` is built, and\n * the way to package your own (an in-house widget you use across apps). Cookie names are inferred as\n * literals, so the preset's `cookies` option only accepts names it declares.\n *\n * Translation keys follow the package catalogs: `t(vendor.id)` is the vendor's name and\n * `t(\\`${vendor.id}.${cookie.name}\\`)` a cookie's purpose.\n */\nexport function defineVendor<const C extends readonly ConsentCookie[]>(\n definition: VendorDefinition<C>,\n): VendorPreset<C[number]['name']> {\n const { id, privacy_policy_url, cookies } = definition\n const preset = (options: VendorPresetOptions<C[number]['name']> = {}): ConsentVendor => {\n let picked: readonly ConsentCookie[] = cookies\n if (options.cookies) {\n const known = new Set(cookies.map((c) => c.name))\n for (const name of options.cookies) {\n if (!known.has(name)) {\n throw new ConsentError(\n `Vendor \"${id}\" has no cookie \"${name}\" — use \\`extra\\` to add one.`,\n )\n }\n }\n const wanted = new Set<string>(options.cookies)\n picked = cookies.filter((c) => wanted.has(c.name))\n }\n return {\n id,\n ...(privacy_policy_url ? { privacy_policy_url } : {}),\n cookies: [...picked, ...(options.extra ?? [])],\n }\n }\n return Object.assign(preset, { id, cookies })\n}\n","// Lifetimes in the presets are milliseconds, like every duration in @luwiostack/cookie-consent.\nexport const MINUTE = 60 * 1000\nexport const HOUR = 60 * MINUTE\nexport const DAY = 24 * HOUR\n","import { defineVendor } from './define-vendor'\nimport { DAY, MINUTE } from './time'\n\n// Google Ads — the cookies a standard integration sets for visitors.\n// Sources:\n// https://business.safety.google/adscookies/\n// https://policies.google.com/technologies/cookies\n// Note: IDE is 13 months in the EEA, Switzerland and UK (24 months elsewhere). _gac_* is only set when Google\n// Analytics is linked to Google Ads.\nexport const googleAds = /* @__PURE__ */ defineVendor({\n id: 'google_ads',\n privacy_policy_url: 'https://policies.google.com/privacy',\n cookies: [\n { name: '_gcl_au', category: 'marketing', max_age: 90 * DAY },\n { name: '_gcl_aw', category: 'marketing', max_age: 90 * DAY },\n { name: '_gcl_dc', category: 'marketing', max_age: 90 * DAY },\n { name: '_gac_*', category: 'marketing', max_age: 90 * DAY },\n { name: 'IDE', category: 'marketing', max_age: 390 * DAY },\n { name: 'test_cookie', category: 'marketing', max_age: 15 * MINUTE },\n { name: 'ar_debug', category: 'marketing', max_age: 90 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// Google Analytics — the cookies a standard integration sets for visitors.\n// Sources:\n// https://support.google.com/analytics/answer/11397207\n// https://business.safety.google/adscookies/\n// https://policies.google.com/technologies/cookies\nexport const googleAnalytics = /* @__PURE__ */ defineVendor({\n id: 'google_analytics',\n privacy_policy_url: 'https://policies.google.com/privacy',\n cookies: [\n { name: '_ga', category: 'statistics', max_age: 730 * DAY },\n { name: '_ga_*', category: 'statistics', max_age: 730 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// Google Maps — the cookies a standard integration sets for visitors.\n// Sources:\n// https://policies.google.com/technologies/cookies\n// https://policies.google.com/technologies/cookies/embedded?hl=en\n// Note: Google publishes no list for Maps embeds; these are the general google.com cookies from \"How Google\n// uses cookies\". What's set depends on the visitor's existing Google cookies, sign-in and region.\nexport const googleMaps = /* @__PURE__ */ defineVendor({\n id: 'google_maps',\n privacy_policy_url: 'https://policies.google.com/privacy',\n cookies: [\n { name: 'NID', category: 'marketing', max_age: 180 * DAY },\n { name: 'AEC', category: 'necessary', max_age: 180 * DAY },\n { name: 'SOCS', category: 'necessary', max_age: 390 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// Google reCAPTCHA — the cookies a standard integration sets for visitors.\n// Sources:\n// https://developers.google.com/recaptcha/docs/faq\n// https://cookiedatabase.org/cookie/google-recaptcha/_grecaptcha/\n// Note: Google documents _GRECAPTCHA's name and purpose, not its lifetime — 6 months is from Cookiedatabase.org.\nexport const googleRecaptcha = /* @__PURE__ */ defineVendor({\n id: 'google_recaptcha',\n privacy_policy_url: 'https://policies.google.com/privacy',\n cookies: [{ name: '_GRECAPTCHA', category: 'necessary', max_age: 180 * DAY }],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY, MINUTE } from './time'\n\n// Hotjar — the cookies a standard integration sets for visitors.\n// Sources:\n// https://help.hotjar.com/hc/en-us/articles/36819973371409-Cookies-Set-by-the-Hotjar-Tracking-Code\n// Note: Short-lived test cookies and two survey cookies are left out.\nexport const hotjar = /* @__PURE__ */ defineVendor({\n id: 'hotjar',\n privacy_policy_url: 'https://www.hotjar.com/legal/policies/privacy/',\n cookies: [\n { name: '_hjSessionUser_*', category: 'statistics', max_age: 365 * DAY },\n { name: '_hjSession_*', category: 'statistics', max_age: 30 * MINUTE },\n { name: '_hjHasCachedUserAttributes', category: 'statistics', max_age: 'session' },\n { name: '_hjUserAttributesHash', category: 'statistics', max_age: 2 * MINUTE },\n {\n name: '_hjUserAttributes',\n category: 'statistics',\n type: 'local_storage',\n max_age: 'persistent',\n },\n { name: 'hjViewportId', category: 'statistics', type: 'session_storage', max_age: 'session' },\n {\n name: 'hjActiveViewportIds',\n category: 'statistics',\n type: 'local_storage',\n max_age: 'session',\n },\n { name: '_hjDonePolls', category: 'statistics', max_age: 365 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// LinkedIn Insight Tag — the cookies a standard integration sets for visitors.\n// Sources:\n// https://www.linkedin.com/legal/l/cookie-table\n// Note: The logged-in-only bscookie and _guid (LinkedIn's own Google Ads) are left out.\nexport const linkedinInsight = /* @__PURE__ */ defineVendor({\n id: 'linkedin_insight',\n privacy_policy_url: 'https://www.linkedin.com/legal/privacy-policy',\n cookies: [\n { name: 'li_fat_id', category: 'marketing', max_age: 30 * DAY },\n { name: 'ln_or', category: 'marketing', max_age: DAY },\n { name: 'bcookie', category: 'marketing', max_age: 365 * DAY },\n { name: 'lidc', category: 'marketing', max_age: DAY },\n { name: 'li_sugr', category: 'marketing', max_age: 90 * DAY },\n { name: 'UserMatchHistory', category: 'marketing', max_age: 30 * DAY },\n { name: 'AnalyticsSyncHistory', category: 'marketing', max_age: 30 * DAY },\n { name: 'li_gc', category: 'necessary', max_age: 180 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// Meta Pixel — the cookies a standard integration sets for visitors.\n// Sources:\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc/\n// https://www.facebook.com/policies/cookies/\n// https://web.archive.org/web/20220522135037/https://www.facebook.com/policies/cookies\n// Note: Meta's current cookie policy names no cookies; the 90-day lifetimes of _fbp / fr come from earlier\n// versions of Meta's own policy, and _fbc's from Meta's Conversions API docs.\nexport const metaPixel = /* @__PURE__ */ defineVendor({\n id: 'meta_pixel',\n privacy_policy_url: 'https://www.facebook.com/privacy/policy/',\n cookies: [\n { name: '_fbp', category: 'marketing', max_age: 90 * DAY },\n { name: '_fbc', category: 'marketing', max_age: 90 * DAY },\n { name: 'fr', category: 'marketing', max_age: 90 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// TikTok Pixel — the cookies a standard integration sets for visitors.\n// Sources:\n// https://ads.tiktok.com/help/article/using-cookies-with-tiktok-pixel\n// Note: TikTok's lifetimes are 13 months from last use (rolling). ttcsid* covers ttcsid and ttcsid_<pixel code>.\nexport const tiktokPixel = /* @__PURE__ */ defineVendor({\n id: 'tiktok_pixel',\n privacy_policy_url: 'https://www.tiktok.com/legal/page/eea/privacy-policy/en',\n cookies: [\n { name: '_ttp', category: 'marketing', max_age: 390 * DAY },\n { name: 'ttcsid*', category: 'marketing', max_age: 390 * DAY },\n { name: 'ttclid', category: 'marketing', max_age: 390 * DAY },\n { name: '_pangle', category: 'marketing', max_age: 390 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY, MINUTE } from './time'\n\n// Vimeo — the cookies a standard integration sets for visitors.\n// Sources:\n// https://help.vimeo.com/hc/en-us/articles/26080940921361-Vimeo-Player-Cookies\n// https://vimeo.com/cookie_policy\n// Note: Feature-specific cookies (passwords, webinars, live chat) are left out; Cloudflare's __cf_bm / _cfuvid /\n// cf_clearance come from Vimeo's own player-cookie article.\nexport const vimeo = /* @__PURE__ */ defineVendor({\n id: 'vimeo',\n privacy_policy_url: 'https://vimeo.com/privacy',\n cookies: [\n { name: 'vuid', category: 'statistics', max_age: 730 * DAY },\n { name: 'player', category: 'preferences', max_age: 365 * DAY },\n { name: 'player_clearance', category: 'necessary', max_age: 7 * DAY },\n { name: '__cf_bm', category: 'necessary', max_age: 30 * MINUTE },\n { name: '_cfuvid', category: 'necessary', max_age: 'session' },\n { name: 'cf_clearance', category: 'necessary', max_age: 365 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// YouTube — the cookies a standard integration sets for visitors.\n// Sources:\n// https://policies.google.com/technologies/cookies\n// https://business.safety.google/adscookies/\n// https://support.google.com/youtube/answer/171780\n// https://cookiedatabase.org/\n// Note: Google is moving VISITOR_INFO1_LIVE to __Secure-YNID, so both are listed. youtube-nocookie.com still\n// uses storage, so treat it as needing consent too.\nexport const youtube = /* @__PURE__ */ defineVendor({\n id: 'youtube',\n privacy_policy_url: 'https://policies.google.com/privacy',\n cookies: [\n { name: 'YSC', category: 'marketing', max_age: 'session' },\n { name: '__Secure-YNID', category: 'marketing', max_age: 180 * DAY },\n { name: 'VISITOR_INFO1_LIVE', category: 'marketing', max_age: 180 * DAY },\n { name: '__Secure-YENID', category: 'marketing', max_age: 390 * DAY },\n { name: '__Secure-ROLLOUT_TOKEN', category: 'marketing', max_age: 180 * DAY },\n { name: 'PREF', category: 'preferences', max_age: 240 * DAY },\n ],\n})\n","import { googleAds } from './google-ads'\nimport { googleAnalytics } from './google-analytics'\nimport { googleMaps } from './google-maps'\nimport { googleRecaptcha } from './google-recaptcha'\nimport { hotjar } from './hotjar'\nimport { linkedinInsight } from './linkedin-insight'\nimport { metaPixel } from './meta-pixel'\nimport { tiktokPixel } from './tiktok-pixel'\nimport { vimeo } from './vimeo'\nimport { youtube } from './youtube'\n\n/**\n * Every preset by its id — for when the set of vendors is decided at runtime (a backend that turns\n * integrations on and off sends `\"google_analytics\"`, not code). Importing this map bundles every\n * preset; import the named presets instead when your vendors are fixed in code.\n */\nexport const vendorPresets = {\n google_analytics: googleAnalytics,\n hotjar,\n google_ads: googleAds,\n meta_pixel: metaPixel,\n linkedin_insight: linkedinInsight,\n tiktok_pixel: tiktokPixel,\n youtube,\n vimeo,\n google_maps: googleMaps,\n google_recaptcha: googleRecaptcha,\n} as const\n\n/** The id of a shipped preset — `'google_analytics'`, `'meta_pixel'`, … */\nexport type VendorPresetId = keyof typeof vendorPresets\n","import { type ConsentCategoryId, isConsentCategoryId, REQUIRED_CATEGORY } from '../categories'\nimport { ConsentError } from '../errors'\nimport type { ConsentCategoriesConfig, ConsentCookie, ConsentVendor } from '../types'\nimport { type VendorPresetId, vendorPresets } from './presets'\n\n/**\n * The serializable consent config — what a backend sends when it decides which integrations are on\n * (a back office where an admin enables Google Analytics, or the YouTube embed without tracking).\n * JSON only: per category, the vendors used in it — a preset id, a preset reference narrowed or\n * extended, or a full declaration when there's no preset. A vendor brings only its cookies of the\n * category it's listed under (plus its necessary ones). snake_case, like every dataset.\n *\n * ```json\n * {\n * \"policy_version\": 7,\n * \"categories\": {\n * \"statistics\": [\"google_analytics\"],\n * \"preferences\": [\"youtube\"],\n * \"marketing\": [\n * { \"preset\": \"google_ads\", \"cookies\": [\"_gcl_au\", \"IDE\"] },\n * { \"id\": \"acme_chat\", \"cookies\": [{ \"name\": \"acme_id\", \"category\": \"marketing\", \"max_age\": 31536000000 }] }\n * ]\n * }\n * }\n * ```\n */\nexport interface ConsentConfigData {\n /** Bump it whenever the set of vendors changes, so every visitor is asked again. Default `1`. */\n policy_version?: string | number\n /** How long a decision stays valid, in milliseconds. Default: 365 days. */\n max_age?: number\n /** Per category, the vendors used in it. */\n categories: Partial<Record<ConsentCategoryId, readonly ConsentVendorData[]>>\n}\n\n/** A vendor in the data: a preset id, a preset reference, or a full declaration of your own. */\nexport type ConsentVendorData = VendorPresetId | ConsentPresetVendorData | ConsentVendor\n\n/** A shipped preset by id, optionally narrowed (`cookies`) or extended (`extra`). */\nexport interface ConsentPresetVendorData {\n preset: VendorPresetId\n cookies?: readonly string[]\n extra?: readonly ConsentCookie[]\n}\n\n/** The part of `createConsent`'s config that data describes. */\nexport interface ConsentConfigFromData {\n categories: ConsentCategoriesConfig\n policyVersion?: string | number\n maxAge?: number\n}\n\n/** What only the app knows, merged into the data's config. */\nexport interface ConsentConfigFromDataOptions {\n /**\n * The app's own strictly necessary vendors (its session cookie, CSRF token, the consent record),\n * declared in code. Put under `necessary`, ahead of the data's categories. Once the app declares\n * them, the data may not list `necessary` itself: strictly necessary cookies are the app's to\n * declare, never the backend's.\n */\n necessary?: readonly ConsentVendor[]\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nfunction presetFor(id: unknown, where: string) {\n if (typeof id === 'string' && Object.hasOwn(vendorPresets, id)) {\n return vendorPresets[id as VendorPresetId] as (\n options?: Record<string, unknown>,\n ) => ConsentVendor\n }\n throw new ConsentError(`${where}: unknown vendor preset \"${String(id)}\".`)\n}\n\nfunction vendorFromData(raw: unknown, where: string): ConsentVendor {\n if (typeof raw === 'string') return presetFor(raw, where)()\n if (!isObject(raw)) throw new ConsentError(`${where}: must be a preset id or an object.`)\n if ('preset' in raw) {\n const preset = presetFor(raw.preset, where)\n if (raw.cookies !== undefined && !Array.isArray(raw.cookies)) {\n throw new ConsentError(`${where} (\"${raw.preset}\"): cookies must be an array of names.`)\n }\n if (raw.extra !== undefined && !Array.isArray(raw.extra)) {\n throw new ConsentError(`${where} (\"${raw.preset}\"): extra must be an array of cookies.`)\n }\n // The preset itself rejects a cookie name it doesn't declare.\n return preset({ cookies: raw.cookies, extra: raw.extra })\n }\n // A full declaration — createConsent validates its id, cookies, categories and lifetimes.\n return raw as unknown as ConsentVendor\n}\n\n/**\n * Turn backend data into `createConsent` options: per category, preset ids and references become\n * full vendor declarations (from `vendorPresets`); full declarations pass through. Pass the app's\n * own strictly necessary vendors as `necessary`, then spread the result and add what else only the\n * app knows:\n *\n * ```ts\n * const consent = createConsent({\n * ...consentConfigFromData(config.consent, { necessary: [mySite] }),\n * onChange,\n * })\n * ```\n *\n * Checks the shape as it goes — the data comes over the wire — and `createConsent` then validates\n * the rest (a vendor without cookies of its category, cookie names, lifetimes).\n *\n * @throws {ConsentError} for a malformed shape, an unknown category or preset, a cookie a preset\n * doesn't declare, or — when the app passes `necessary` — a `necessary` category in the data.\n */\nexport function consentConfigFromData(\n data: ConsentConfigData,\n options: ConsentConfigFromDataOptions = {},\n): ConsentConfigFromData {\n if (!isObject(data)) throw new ConsentError('Consent config data must be an object.')\n if (!isObject(data.categories)) {\n throw new ConsentError('Consent config data needs a \"categories\" object.')\n }\n const categories: Record<string, readonly ConsentVendor[]> = {}\n if (options.necessary !== undefined) {\n if (Object.hasOwn(data.categories, REQUIRED_CATEGORY)) {\n throw new ConsentError(\n `Consent config data may not list \"${REQUIRED_CATEGORY}\": the app declares its strictly necessary vendors itself.`,\n )\n }\n if (!Array.isArray(options.necessary)) {\n throw new ConsentError(`The app's \"${REQUIRED_CATEGORY}\" vendors must be an array.`)\n }\n categories[REQUIRED_CATEGORY] = options.necessary\n }\n for (const [id, list] of Object.entries(data.categories)) {\n if (!isConsentCategoryId(id)) throw new ConsentError(`Unknown consent category \"${id}\".`)\n if (!Array.isArray(list)) throw new ConsentError(`Category \"${id}\": vendors must be an array.`)\n categories[id] = list.map((raw: unknown, index) =>\n vendorFromData(raw, `Category \"${id}\", vendor #${index + 1}`),\n )\n }\n return {\n categories,\n ...(data.policy_version !== undefined ? { policyVersion: data.policy_version } : {}),\n ...(data.max_age !== undefined ? { maxAge: data.max_age } : {}),\n }\n}\n"],"mappings":";;;;;;;;;;AAqCA,SAAgB,aACd,YACiC;CACjC,MAAM,EAAE,IAAI,oBAAoB,YAAY;CAC5C,MAAM,UAAU,UAAkD,CAAC,MAAqB;EACtF,IAAI,SAAmC;EACvC,IAAI,QAAQ,SAAS;GACnB,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAAK,MAAM,EAAE,IAAI,CAAC;GAChD,KAAK,MAAM,QAAQ,QAAQ,SACzB,IAAI,CAAC,MAAM,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qBA,SAAgB,sBACd,MACA,UAAwC,CAAC,GAClB;CACvB,IAAI,CAAC,SAAS,IAAI,GAAG,MAAM,IAAI,aAAa,wCAAwC;CACpF,IAAI,CAAC,SAAS,KAAK,UAAU,GAC3B,MAAM,IAAI,aAAa,oDAAkD;CAE3E,MAAM,aAAuD,CAAC;CAC9D,IAAI,QAAQ,cAAc,KAAA,GAAW;EACnC,IAAI,OAAO,OAAO,KAAK,YAAA,WAA6B,GAClD,MAAM,IAAI,aACR,qCAAqC,kBAAkB,2DACzD;EAEF,IAAI,CAAC,MAAM,QAAQ,QAAQ,SAAS,GAClC,MAAM,IAAI,aAAa,cAAc,kBAAkB,4BAA4B;EAErF,WAAW,qBAAqB,QAAQ;CAC1C;CACA,KAAK,MAAM,CAAC,IAAI,SAAS,OAAO,QAAQ,KAAK,UAAU,GAAG;EACxD,IAAI,CAAC,oBAAoB,EAAE,GAAG,MAAM,IAAI,aAAa,6BAA6B,GAAG,GAAG;EACxF,IAAI,CAAC,MAAM,QAAQ,IAAI,GAAG,MAAM,IAAI,aAAa,aAAa,GAAG,6BAA6B;EAC9F,WAAW,MAAM,KAAK,KAAK,KAAc,UACvC,eAAe,KAAK,aAAa,GAAG,aAAa,QAAQ,GAAG,CAC9D;CACF;CACA,OAAO;EACL;EACA,GAAI,KAAK,mBAAmB,KAAA,IAAY,EAAE,eAAe,KAAK,eAAe,IAAI,CAAC;EAClF,GAAI,KAAK,YAAY,KAAA,IAAY,EAAE,QAAQ,KAAK,QAAQ,IAAI,CAAC;CAC/D;AACF"}
1
+ {"version":3,"file":"vendors.mjs","names":[],"sources":["../src/vendors/define-vendor.ts","../src/vendors/google-transfers.ts","../src/vendors/time.ts","../src/vendors/google-ads.ts","../src/vendors/google-analytics.ts","../src/vendors/google-maps.ts","../src/vendors/google-recaptcha.ts","../src/vendors/hotjar.ts","../src/vendors/linkedin-insight.ts","../src/vendors/meta-pixel.ts","../src/vendors/tiktok-pixel.ts","../src/vendors/vimeo.ts","../src/vendors/youtube.ts","../src/vendors/presets.ts","../src/vendors/from-data.ts"],"sourcesContent":["import { ConsentError } from '../errors'\nimport { toConsentVendor } from '../machine-names'\nimport type {\n ConsentCookie,\n ConsentCookieDeclaration,\n ConsentTransfer,\n ConsentTransferDeclaration,\n ConsentVendor,\n} from '../types'\n\nexport interface VendorPresetOptions<Name extends string = string> {\n /**\n * Only these of the preset's cookies — for when your integration doesn't set them all (e.g. no\n * Google Signals). Default: every cookie in the preset. An unknown name is a type error and throws.\n */\n cookies?: readonly Name[]\n /** Your own cookies on top, for anything this vendor sets in your setup that the preset lacks. */\n extra?: readonly ConsentCookieDeclaration[]\n}\n\n/** A ready-made vendor: call it (optionally narrowing or extending its cookies) to get a `ConsentVendor`. */\nexport interface VendorPreset<Name extends string = string> {\n (options?: VendorPresetOptions<Name>): ConsentVendor\n /** The vendor id. */\n readonly id: string\n /** The translation key of its name — its id as a machine name. */\n readonly machine_name: string\n /** Every cookie the preset declares, each with its translation keys. */\n readonly cookies: readonly ConsentCookie[]\n /** Its countries outside the EEA, with their translation keys. */\n readonly transfers?: readonly ConsentTransfer[]\n}\n\nexport interface VendorDefinition<C extends readonly ConsentCookieDeclaration[]> {\n /** Stable id; its machine name (the translation key of its name, and its cookies' prefix) derives from it. */\n id: string\n privacy_policy_url?: string\n /** Its countries outside the EEA; `[]` when the data stays in the EEA. */\n transfers?: readonly ConsentTransferDeclaration[]\n cookies: C\n}\n\n/**\n * Define a reusable vendor preset — how every preset in `@luwiostack/cookie-consent/vendors` is built, and\n * the way to package your own (an in-house widget you use across apps). Cookie names are inferred as\n * literals, so the preset's `cookies` option only accepts names it declares.\n *\n * Translation keys follow the package catalogs: `t(vendor.machine_name)` is the vendor's name and\n * `t(cookie.machine_name)` a cookie's purpose (the vendor's machine name plus the cookie name).\n *\n * @throws {ConsentError} when two cookie names come out as the same machine name.\n */\nexport function defineVendor<const C extends readonly ConsentCookieDeclaration[]>(\n definition: VendorDefinition<C>,\n): VendorPreset<C[number]['name']> {\n const { id, privacy_policy_url, transfers } = definition\n // Resolved once: the machine names, and a clash between two cookie names fails here.\n const { machine_name, cookies, transfers: presented } = toConsentVendor(definition)\n const preset = (options: VendorPresetOptions<C[number]['name']> = {}): ConsentVendor => {\n let picked: readonly ConsentCookie[] = cookies\n if (options.cookies) {\n const known = new Set(cookies.map((c) => c.name))\n for (const name of options.cookies) {\n if (!known.has(name)) {\n throw new ConsentError(\n `Vendor \"${id}\" has no cookie \"${name}\" — use \\`extra\\` to add one.`,\n )\n }\n }\n const wanted = new Set<string>(options.cookies)\n picked = cookies.filter((c) => wanted.has(c.name))\n }\n for (const cookie of (options.extra ?? []) as unknown[]) {\n const name = (cookie as { name?: unknown } | null)?.name\n if (\n typeof cookie !== 'object' ||\n cookie === null ||\n typeof name !== 'string' ||\n name === ''\n ) {\n throw new ConsentError(`Vendor \"${id}\": every extra cookie needs a non-empty name.`)\n }\n }\n return toConsentVendor({\n id,\n ...(privacy_policy_url ? { privacy_policy_url } : {}),\n ...(transfers !== undefined ? { transfers } : {}),\n cookies: [...picked, ...(options.extra ?? [])],\n })\n }\n return Object.assign(preset, {\n id,\n machine_name,\n cookies,\n ...(presented !== undefined ? { transfers: presented } : {}),\n })\n}\n","import type { ConsentTransferDeclaration } from '../types'\n\n// Google's transfers outside the EEA, shared by every Google preset: its data-center countries,\n// the US under Google LLC's DPF certification, the others under adequacy decisions or SCCs.\n// Sources:\n// https://policies.google.com/privacy/frameworks\n// https://datacenters.google/locations/\n// https://www.dataprivacyframework.gov/list (Google LLC: active)\n// https://business.safety.google/controllerterms/\nexport const GOOGLE_TRANSFERS: readonly ConsentTransferDeclaration[] = [\n { country: 'CL', safeguards: ['scc'] },\n { country: 'GB', safeguards: ['adequacy'] },\n { country: 'JP', safeguards: ['adequacy'] },\n { country: 'MY', safeguards: ['scc'] },\n { country: 'SG', safeguards: ['scc'] },\n { country: 'TW', safeguards: ['scc'] },\n { country: 'US', safeguards: ['dpf', 'scc'] },\n { country: 'UY', safeguards: ['adequacy'] },\n]\n","// Lifetimes in the presets are milliseconds, like every duration in @luwiostack/cookie-consent.\nexport const MINUTE = 60 * 1000\nexport const HOUR = 60 * MINUTE\nexport const DAY = 24 * HOUR\n","import { defineVendor } from './define-vendor'\nimport { GOOGLE_TRANSFERS } from './google-transfers'\nimport { DAY, MINUTE } from './time'\n\n// Google Ads — the cookies a standard integration sets for visitors.\n// Sources:\n// https://business.safety.google/adscookies/\n// https://policies.google.com/technologies/cookies\n// Note: IDE is 13 months in the EEA, Switzerland and UK (24 months elsewhere). _gac_* is only set when Google\n// Analytics is linked to Google Ads. Domains from adscookies: _gcl_* / _gac_* on the partner (site's) domain,\n// IDE / test_cookie on doubleclick.net; ar_debug is also set on googleadservices.com and google-analytics.com.\nexport const googleAds = /* @__PURE__ */ defineVendor({\n id: 'google_ads',\n privacy_policy_url: 'https://policies.google.com/privacy',\n transfers: GOOGLE_TRANSFERS,\n cookies: [\n { name: '_gcl_au', category: 'marketing', max_age: 90 * DAY },\n { name: '_gcl_aw', category: 'marketing', max_age: 90 * DAY },\n { name: '_gcl_dc', category: 'marketing', max_age: 90 * DAY },\n { name: '_gac_*', category: 'marketing', max_age: 90 * DAY },\n { name: 'IDE', category: 'marketing', max_age: 390 * DAY, domain: '.doubleclick.net' },\n {\n name: 'test_cookie',\n category: 'marketing',\n max_age: 15 * MINUTE,\n domain: '.doubleclick.net',\n },\n { name: 'ar_debug', category: 'marketing', max_age: 90 * DAY, domain: '.doubleclick.net' },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { GOOGLE_TRANSFERS } from './google-transfers'\nimport { DAY } from './time'\n\n// Google Analytics — the cookies a standard integration sets for visitors.\n// Sources:\n// https://support.google.com/analytics/answer/11397207\n// https://business.safety.google/adscookies/\n// https://policies.google.com/technologies/cookies\n// Note: both cookies are first-party.\nexport const googleAnalytics = /* @__PURE__ */ defineVendor({\n id: 'google_analytics',\n privacy_policy_url: 'https://policies.google.com/privacy',\n transfers: GOOGLE_TRANSFERS,\n cookies: [\n { name: '_ga', category: 'statistics', max_age: 730 * DAY },\n { name: '_ga_*', category: 'statistics', max_age: 730 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { GOOGLE_TRANSFERS } from './google-transfers'\nimport { DAY } from './time'\n\n// Google Maps — the cookies a standard integration sets for visitors.\n// Sources:\n// https://policies.google.com/technologies/cookies\n// https://policies.google.com/technologies/cookies/embedded?hl=en\n// https://business.safety.google/adscookies/ (NID on google.com)\n// Note: Google publishes no list for Maps embeds; these are the general google.com cookies from \"How Google\n// uses cookies\". What's set depends on the visitor's existing Google cookies, sign-in and region. AEC's\n// .google.com is observed in www.google.com's Set-Cookie; SOCS's is undocumented, taken as the same.\nexport const googleMaps = /* @__PURE__ */ defineVendor({\n id: 'google_maps',\n privacy_policy_url: 'https://policies.google.com/privacy',\n transfers: GOOGLE_TRANSFERS,\n cookies: [\n { name: 'NID', category: 'marketing', max_age: 180 * DAY, domain: '.google.com' },\n { name: 'AEC', category: 'necessary', max_age: 180 * DAY, domain: '.google.com' },\n { name: 'SOCS', category: 'necessary', max_age: 390 * DAY, domain: '.google.com' },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { GOOGLE_TRANSFERS } from './google-transfers'\nimport { DAY } from './time'\n\n// Google reCAPTCHA — the cookies a standard integration sets for visitors.\n// Sources:\n// https://developers.google.com/recaptcha/docs/faq\n// https://cookiedatabase.org/cookie/google-recaptcha/_grecaptcha/\n// Note: Google documents _GRECAPTCHA's name, purpose and www.google.com domain, not its lifetime; 6 months is\n// from Cookiedatabase.org and matches www.google.com/recaptcha's Set-Cookie.\nexport const googleRecaptcha = /* @__PURE__ */ defineVendor({\n id: 'google_recaptcha',\n privacy_policy_url: 'https://policies.google.com/privacy',\n transfers: GOOGLE_TRANSFERS,\n cookies: [\n { name: '_GRECAPTCHA', category: 'necessary', max_age: 180 * DAY, domain: 'www.google.com' },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY, MINUTE } from './time'\n\n// Hotjar — the cookies a standard integration sets for visitors.\n// Sources:\n// https://help.hotjar.com/hc/en-us/articles/36819973371409-Cookies-Set-by-the-Hotjar-Tracking-Code\n// https://help.hotjar.com/hc/en-us/articles/36820023091089 (hosted in AWS eu-west-1, Ireland)\n// https://contentsquare.com/privacy-center/subprocessors/\n// Note: Short-lived test cookies and two survey cookies are left out. All cookies are first-party. Tracking\n// data stays in the EEA; the UK support affiliate works under intercompany SCCs (US subprocessors serve only\n// User Tests and Interviews, not the tracking code).\nexport const hotjar = /* @__PURE__ */ defineVendor({\n id: 'hotjar',\n privacy_policy_url: 'https://www.hotjar.com/legal/policies/privacy/',\n transfers: [{ country: 'GB', safeguards: ['scc'] }],\n cookies: [\n { name: '_hjSessionUser_*', category: 'statistics', max_age: 365 * DAY },\n { name: '_hjSession_*', category: 'statistics', max_age: 30 * MINUTE },\n { name: '_hjHasCachedUserAttributes', category: 'statistics', max_age: 'session' },\n { name: '_hjUserAttributesHash', category: 'statistics', max_age: 2 * MINUTE },\n {\n name: '_hjUserAttributes',\n category: 'statistics',\n type: 'local_storage',\n max_age: 'persistent',\n },\n { name: 'hjViewportId', category: 'statistics', type: 'session_storage', max_age: 'session' },\n {\n name: 'hjActiveViewportIds',\n category: 'statistics',\n type: 'local_storage',\n max_age: 'session',\n },\n { name: '_hjDonePolls', category: 'statistics', max_age: 365 * DAY },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// LinkedIn Insight Tag — the cookies a standard integration sets for visitors.\n// Sources:\n// https://www.linkedin.com/legal/l/cookie-table\n// https://www.linkedin.com/legal/privacy-policy\n// https://www.dataprivacyframework.gov/list (LinkedIn Corporation: active)\n// Note: The logged-in-only bscookie and _guid (LinkedIn's own Google Ads) are left out. The cookie table lists\n// ln_or both on the first-party domain and on .linkedin.com; it's taken as first-party, like li_fat_id.\nexport const linkedinInsight = /* @__PURE__ */ defineVendor({\n id: 'linkedin_insight',\n privacy_policy_url: 'https://www.linkedin.com/legal/privacy-policy',\n transfers: [{ country: 'US', safeguards: ['dpf', 'scc'] }],\n cookies: [\n { name: 'li_fat_id', category: 'marketing', max_age: 30 * DAY },\n { name: 'ln_or', category: 'marketing', max_age: DAY },\n { name: 'bcookie', category: 'marketing', max_age: 365 * DAY, domain: '.linkedin.com' },\n { name: 'lidc', category: 'marketing', max_age: DAY, domain: '.linkedin.com' },\n { name: 'li_sugr', category: 'marketing', max_age: 90 * DAY, domain: '.linkedin.com' },\n {\n name: 'UserMatchHistory',\n category: 'marketing',\n max_age: 30 * DAY,\n domain: '.linkedin.com',\n },\n {\n name: 'AnalyticsSyncHistory',\n category: 'marketing',\n max_age: 30 * DAY,\n domain: '.linkedin.com',\n },\n { name: 'li_gc', category: 'necessary', max_age: 180 * DAY, domain: '.linkedin.com' },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// Meta Pixel — the cookies a standard integration sets for visitors.\n// Sources:\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc/\n// https://www.facebook.com/policies/cookies/\n// https://web.archive.org/web/20220522135037/https://www.facebook.com/policies/cookies\n// https://privacycenter.instagram.com/policy/?subpage=9.subpage.3-HowDoWeSafeguard\n// https://www.dataprivacyframework.gov/list (Meta Platforms, Inc.: active)\n// Note: Meta's current cookie policy names no cookies; the 90-day lifetimes of _fbp / fr come from earlier\n// versions of Meta's own policy, and _fbc's from Meta's Conversions API docs. _fbp and _fbc are first-party\n// (fbevents.js writes them on the site's domain); fr's .facebook.com is undocumented, taken from the pixel\n// requests going to facebook.com. Transfers: the US under DPF, the adequacy countries Meta names; other\n// countries under SCCs are not named.\nexport const metaPixel = /* @__PURE__ */ defineVendor({\n id: 'meta_pixel',\n privacy_policy_url: 'https://www.facebook.com/privacy/policy/',\n transfers: [\n { country: 'AR', safeguards: ['adequacy'] },\n { country: 'CA', safeguards: ['adequacy'] },\n { country: 'CH', safeguards: ['adequacy'] },\n { country: 'GB', safeguards: ['adequacy'] },\n { country: 'IL', safeguards: ['adequacy'] },\n { country: 'NZ', safeguards: ['adequacy'] },\n { country: 'US', safeguards: ['dpf'] },\n ],\n cookies: [\n { name: '_fbp', category: 'marketing', max_age: 90 * DAY },\n { name: '_fbc', category: 'marketing', max_age: 90 * DAY },\n { name: 'fr', category: 'marketing', max_age: 90 * DAY, domain: '.facebook.com' },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY } from './time'\n\n// TikTok Pixel — the cookies a standard integration sets for visitors.\n// Sources:\n// https://ads.tiktok.com/help/article/using-cookies-with-tiktok-pixel\n// https://www.tiktok.com/legal/page/eea/transferee-countries/en\n// Note: TikTok's lifetimes are 13 months from last use (rolling). ttcsid* covers ttcsid and ttcsid_<pixel code>.\n// _ttp also has a third-party variant on .tiktok.com; the first-party one is declared. _pangle is read, not\n// set, by the pixel. Transfers: storage and group remote access, per TikTok's EEA transferee list; no TikTok\n// entity is DPF-certified.\nexport const tiktokPixel = /* @__PURE__ */ defineVendor({\n id: 'tiktok_pixel',\n privacy_policy_url: 'https://www.tiktok.com/legal/page/eea/privacy-policy/en',\n transfers: [\n { country: 'AU', safeguards: ['scc'] },\n { country: 'BR', safeguards: ['scc'] },\n { country: 'CA', safeguards: ['adequacy'] },\n { country: 'CN', safeguards: ['scc'] },\n { country: 'GB', safeguards: ['adequacy'] },\n { country: 'IL', safeguards: ['adequacy'] },\n { country: 'JP', safeguards: ['adequacy'] },\n { country: 'KR', safeguards: ['adequacy'] },\n { country: 'MY', safeguards: ['scc'] },\n { country: 'PH', safeguards: ['scc'] },\n { country: 'SG', safeguards: ['scc'] },\n { country: 'US', safeguards: ['scc'] },\n ],\n cookies: [\n { name: '_ttp', category: 'marketing', max_age: 390 * DAY },\n { name: 'ttcsid*', category: 'marketing', max_age: 390 * DAY },\n { name: 'ttclid', category: 'marketing', max_age: 390 * DAY },\n {\n name: '_pangle',\n category: 'marketing',\n max_age: 390 * DAY,\n domain: 'analytics.pangle-ads.com',\n },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { DAY, MINUTE } from './time'\n\n// Vimeo — the cookies a standard integration sets for visitors.\n// Sources:\n// https://help.vimeo.com/hc/en-us/articles/26080940921361-Vimeo-Player-Cookies\n// https://vimeo.com/cookie_policy\n// https://vimeo.com/legal/privacy/policy.md\n// https://www.dataprivacyframework.gov/list (Vimeo.com, Inc.: active)\n// Note: Feature-specific cookies (passwords, webinars, live chat) are left out; Cloudflare's __cf_bm / _cfuvid /\n// cf_clearance come from Vimeo's own player-cookie article. Vimeo documents no domains: the player's config\n// sets .vimeo.com (vuid, player) and __cf_bm is observed on vimeo.com; the rest are taken as .vimeo.com.\nexport const vimeo = /* @__PURE__ */ defineVendor({\n id: 'vimeo',\n privacy_policy_url: 'https://vimeo.com/privacy',\n transfers: [{ country: 'US', safeguards: ['dpf', 'scc'] }],\n cookies: [\n { name: 'vuid', category: 'statistics', max_age: 730 * DAY, domain: '.vimeo.com' },\n { name: 'player', category: 'preferences', max_age: 365 * DAY, domain: '.vimeo.com' },\n { name: 'player_clearance', category: 'necessary', max_age: 7 * DAY, domain: '.vimeo.com' },\n { name: '__cf_bm', category: 'necessary', max_age: 30 * MINUTE, domain: '.vimeo.com' },\n { name: '_cfuvid', category: 'necessary', max_age: 'session', domain: '.vimeo.com' },\n { name: 'cf_clearance', category: 'necessary', max_age: 365 * DAY, domain: '.vimeo.com' },\n ],\n})\n","import { defineVendor } from './define-vendor'\nimport { GOOGLE_TRANSFERS } from './google-transfers'\nimport { DAY } from './time'\n\n// YouTube — the cookies a standard integration sets for visitors.\n// Sources:\n// https://policies.google.com/technologies/cookies\n// https://business.safety.google/adscookies/\n// https://support.google.com/youtube/answer/171780\n// https://cookiedatabase.org/\n// Note: Google is moving VISITOR_INFO1_LIVE to __Secure-YNID, so both are listed. youtube-nocookie.com still\n// uses storage, so treat it as needing consent too. Domains: YSC / VISITOR_INFO1_LIVE from adscookies, the\n// rest observed in the embed's Set-Cookie or, for __Secure-YENID and PREF (undocumented), taken as the\n// embed's .youtube.com.\nexport const youtube = /* @__PURE__ */ defineVendor({\n id: 'youtube',\n privacy_policy_url: 'https://policies.google.com/privacy',\n transfers: GOOGLE_TRANSFERS,\n cookies: [\n { name: 'YSC', category: 'marketing', max_age: 'session', domain: '.youtube.com' },\n { name: '__Secure-YNID', category: 'marketing', max_age: 180 * DAY, domain: '.youtube.com' },\n {\n name: 'VISITOR_INFO1_LIVE',\n category: 'marketing',\n max_age: 180 * DAY,\n domain: '.youtube.com',\n },\n { name: '__Secure-YENID', category: 'marketing', max_age: 390 * DAY, domain: '.youtube.com' },\n {\n name: '__Secure-ROLLOUT_TOKEN',\n category: 'marketing',\n max_age: 180 * DAY,\n domain: '.youtube.com',\n },\n { name: 'PREF', category: 'preferences', max_age: 240 * DAY, domain: '.youtube.com' },\n ],\n})\n","import { googleAds } from './google-ads'\nimport { googleAnalytics } from './google-analytics'\nimport { googleMaps } from './google-maps'\nimport { googleRecaptcha } from './google-recaptcha'\nimport { hotjar } from './hotjar'\nimport { linkedinInsight } from './linkedin-insight'\nimport { metaPixel } from './meta-pixel'\nimport { tiktokPixel } from './tiktok-pixel'\nimport { vimeo } from './vimeo'\nimport { youtube } from './youtube'\n\n/**\n * Every preset by its id — for when the set of vendors is decided at runtime (a backend that turns\n * integrations on and off sends `\"google_analytics\"`, not code). Importing this map bundles every\n * preset; import the named presets instead when your vendors are fixed in code.\n */\nexport const vendorPresets = {\n google_analytics: googleAnalytics,\n hotjar,\n google_ads: googleAds,\n meta_pixel: metaPixel,\n linkedin_insight: linkedinInsight,\n tiktok_pixel: tiktokPixel,\n youtube,\n vimeo,\n google_maps: googleMaps,\n google_recaptcha: googleRecaptcha,\n} as const\n\n/** The id of a shipped preset — `'google_analytics'`, `'meta_pixel'`, … */\nexport type VendorPresetId = keyof typeof vendorPresets\n","import { type ConsentCategoryId, isConsentCategoryId, REQUIRED_CATEGORY } from '../categories'\nimport { ConsentError } from '../errors'\nimport type {\n ConsentCategoriesConfig,\n ConsentCookieDeclaration,\n ConsentVendorDeclaration,\n} from '../types'\nimport { type VendorPresetId, vendorPresets } from './presets'\n\n/**\n * The serializable consent config — what a backend sends when it decides which integrations are on\n * (a back office where an admin enables Google Analytics, or the YouTube embed without tracking).\n * JSON only: per category, the vendors used in it — a preset id, a preset reference narrowed or\n * extended, or a full declaration when there's no preset. A vendor brings only its cookies of the\n * category it's listed under (plus its necessary ones). snake_case, like every dataset.\n *\n * ```json\n * {\n * \"policy_version\": 7,\n * \"categories\": {\n * \"statistics\": [\"google_analytics\"],\n * \"preferences\": [\"youtube\"],\n * \"marketing\": [\n * { \"preset\": \"google_ads\", \"cookies\": [\"_gcl_au\", \"IDE\"] },\n * { \"id\": \"acme_chat\", \"cookies\": [{ \"name\": \"acme_id\", \"category\": \"marketing\", \"max_age\": 31536000000 }] }\n * ]\n * }\n * }\n * ```\n */\nexport interface ConsentConfigData {\n /** Bump it whenever the set of vendors changes, so every visitor is asked again. Default `1`. */\n policy_version?: string | number\n /** How long a decision stays valid, in milliseconds. Default: 365 days. */\n max_age?: number\n /** Per category, the vendors used in it. */\n categories: Partial<Record<ConsentCategoryId, readonly ConsentVendorData[]>>\n}\n\n/** A vendor in the data: a preset id, a preset reference, or a full declaration of your own. */\nexport type ConsentVendorData = VendorPresetId | ConsentPresetVendorData | ConsentVendorDeclaration\n\n/** A shipped preset by id, optionally narrowed (`cookies`) or extended (`extra`). */\nexport interface ConsentPresetVendorData {\n preset: VendorPresetId\n cookies?: readonly string[]\n extra?: readonly ConsentCookieDeclaration[]\n}\n\n/** The part of `createConsent`'s config that data describes. */\nexport interface ConsentConfigFromData {\n categories: ConsentCategoriesConfig\n policyVersion?: string | number\n maxAge?: number\n}\n\n/** What only the app knows, merged into the data's config. */\nexport interface ConsentConfigFromDataOptions {\n /**\n * The app's own strictly necessary vendors (its session cookie, CSRF token, the consent record),\n * declared in code. Put under `necessary`, ahead of the data's categories. Once the app declares\n * them, the data may not list `necessary` itself: strictly necessary cookies are the app's to\n * declare, never the backend's.\n */\n necessary?: readonly ConsentVendorDeclaration[]\n}\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nfunction presetFor(id: unknown, where: string) {\n if (typeof id === 'string' && Object.hasOwn(vendorPresets, id)) {\n return vendorPresets[id as VendorPresetId] as (\n options?: Record<string, unknown>,\n ) => ConsentVendorDeclaration\n }\n throw new ConsentError(`${where}: unknown vendor preset \"${String(id)}\".`)\n}\n\nfunction vendorFromData(raw: unknown, where: string): ConsentVendorDeclaration {\n if (typeof raw === 'string') return presetFor(raw, where)()\n if (!isObject(raw)) throw new ConsentError(`${where}: must be a preset id or an object.`)\n if ('preset' in raw) {\n const preset = presetFor(raw.preset, where)\n if (raw.cookies !== undefined && !Array.isArray(raw.cookies)) {\n throw new ConsentError(`${where} (\"${raw.preset}\"): cookies must be an array of names.`)\n }\n if (raw.extra !== undefined && !Array.isArray(raw.extra)) {\n throw new ConsentError(`${where} (\"${raw.preset}\"): extra must be an array of cookies.`)\n }\n // The preset itself rejects a cookie name it doesn't declare.\n return preset({ cookies: raw.cookies, extra: raw.extra })\n }\n // A full declaration — createConsent validates its id, cookies, categories and lifetimes.\n return raw as unknown as ConsentVendorDeclaration\n}\n\n/**\n * Turn backend data into `createConsent` options: per category, preset ids and references become\n * full vendor declarations (from `vendorPresets`); full declarations pass through. Pass the app's\n * own strictly necessary vendors as `necessary`, then spread the result and add what else only the\n * app knows:\n *\n * ```ts\n * const consent = createConsent({\n * ...consentConfigFromData(config.consent, { necessary: [mySite] }),\n * onChange,\n * })\n * ```\n *\n * Checks the shape as it goes — the data comes over the wire — and `createConsent` then validates\n * the rest (a vendor without cookies of its category, cookie names, lifetimes).\n *\n * @throws {ConsentError} for a malformed shape, an unknown category or preset, a cookie a preset\n * doesn't declare, or — when the app passes `necessary` — a `necessary` category in the data.\n */\nexport function consentConfigFromData(\n data: ConsentConfigData,\n options: ConsentConfigFromDataOptions = {},\n): ConsentConfigFromData {\n if (!isObject(data)) throw new ConsentError('Consent config data must be an object.')\n if (!isObject(data.categories)) {\n throw new ConsentError('Consent config data needs a \"categories\" object.')\n }\n const categories: Record<string, readonly ConsentVendorDeclaration[]> = {}\n if (options.necessary !== undefined) {\n if (Object.hasOwn(data.categories, REQUIRED_CATEGORY)) {\n throw new ConsentError(\n `Consent config data may not list \"${REQUIRED_CATEGORY}\": the app declares its strictly necessary vendors itself.`,\n )\n }\n if (!Array.isArray(options.necessary)) {\n throw new ConsentError(`The app's \"${REQUIRED_CATEGORY}\" vendors must be an array.`)\n }\n categories[REQUIRED_CATEGORY] = options.necessary\n }\n for (const [id, list] of Object.entries(data.categories)) {\n if (!isConsentCategoryId(id)) throw new ConsentError(`Unknown consent category \"${id}\".`)\n if (!Array.isArray(list)) throw new ConsentError(`Category \"${id}\": vendors must be an array.`)\n categories[id] = list.map((raw: unknown, index) =>\n vendorFromData(raw, `Category \"${id}\", vendor #${index + 1}`),\n )\n }\n return {\n categories,\n ...(data.policy_version !== undefined ? { policyVersion: data.policy_version } : {}),\n ...(data.max_age !== undefined ? { maxAge: data.max_age } : {}),\n }\n}\n"],"mappings":";;;;;;;;;;;;AAoDA,SAAgB,aACd,YACiC;CACjC,MAAM,EAAE,IAAI,oBAAoB,cAAc;CAE9C,MAAM,EAAE,cAAc,SAAS,WAAW,cAAc,gBAAgB,UAAU;CAClF,MAAM,UAAU,UAAkD,CAAC,MAAqB;EACtF,IAAI,SAAmC;EACvC,IAAI,QAAQ,SAAS;GACnB,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAAK,MAAM,EAAE,IAAI,CAAC;GAChD,KAAK,MAAM,QAAQ,QAAQ,SACzB,IAAI,CAAC,MAAM,IAAI,IAAI,GACjB,MAAM,IAAI,aACR,WAAW,GAAG,mBAAmB,KAAK,8BACxC;GAGJ,MAAM,SAAS,IAAI,IAAY,QAAQ,OAAO;GAC9C,SAAS,QAAQ,QAAQ,MAAM,OAAO,IAAI,EAAE,IAAI,CAAC;EACnD;EACA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AAQ,SAAS,GAClC,MAAM,IAAI,aAAa,cAAc,kBAAkB,4BAA4B;EAErF,WAAW,qBAAqB,QAAQ;CAC1C;CACA,KAAK,MAAM,CAAC,IAAI,SAAS,OAAO,QAAQ,KAAK,UAAU,GAAG;EACxD,IAAI,CAAC,oBAAoB,EAAE,GAAG,MAAM,IAAI,aAAa,6BAA6B,GAAG,GAAG;EACxF,IAAI,CAAC,MAAM,QAAQ,IAAI,GAAG,MAAM,IAAI,aAAa,aAAa,GAAG,6BAA6B;EAC9F,WAAW,MAAM,KAAK,KAAK,KAAc,UACvC,eAAe,KAAK,aAAa,GAAG,aAAa,QAAQ,GAAG,CAC9D;CACF;CACA,OAAO;EACL;EACA,GAAI,KAAK,mBAAmB,KAAA,IAAY,EAAE,eAAe,KAAK,eAAe,IAAI,CAAC;EAClF,GAAI,KAAK,YAAY,KAAA,IAAY,EAAE,QAAQ,KAAK,QAAQ,IAAI,CAAC;CAC/D;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@luwiostack/cookie-consent",
3
- "version": "0.1.0",
4
- "description": "Cookie consent — typed, app-defined categories with vendor cookie declarations (plus ready-made presets), persisted to localStorage with policy-version and expiry re-consent, Google Consent Mode v2, script unblocking and removal of a withdrawn category's cookies. React-free core plus a provider, useConsent and a gating component; no UI — apps build their own banner.",
3
+ "version": "0.3.0",
4
+ "description": "Cookie consent — typed, app-defined categories with vendor cookie declarations (plus ready-made presets), persisted to localStorage with policy-version and expiry re-consent, script unblocking and removal of a withdrawn category's cookies. React-free core plus a provider, useConsent and a gating component; no UI — apps build their own banner.",
5
5
  "keywords": [
6
6
  "consent",
7
7
  "cookie-consent",
@@ -10,7 +10,6 @@
10
10
  "eprivacy",
11
11
  "cookie-banner",
12
12
  "cookie-removal",
13
- "google-consent-mode",
14
13
  "react",
15
14
  "luwio"
16
15
  ],
@@ -65,7 +64,7 @@
65
64
  "provenance": true
66
65
  },
67
66
  "dependencies": {
68
- "@luwiostack/storage": "0.1.0"
67
+ "@luwiostack/storage": "0.1.1"
69
68
  },
70
69
  "peerDependencies": {
71
70
  "react": ">=18"
@@ -1,55 +0,0 @@
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. Each id is also the translation key of
5
- * the category's name (`category.<id>`) and description (`category.<id>.description`) in the
6
- * 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
- Object.defineProperty(exports, "CONSENT_CATEGORIES", {
31
- enumerable: true,
32
- get: function() {
33
- return CONSENT_CATEGORIES;
34
- }
35
- });
36
- Object.defineProperty(exports, "ConsentError", {
37
- enumerable: true,
38
- get: function() {
39
- return ConsentError;
40
- }
41
- });
42
- Object.defineProperty(exports, "REQUIRED_CATEGORY", {
43
- enumerable: true,
44
- get: function() {
45
- return REQUIRED_CATEGORY;
46
- }
47
- });
48
- Object.defineProperty(exports, "isConsentCategoryId", {
49
- enumerable: true,
50
- get: function() {
51
- return isConsentCategoryId;
52
- }
53
- });
54
-
55
- //# sourceMappingURL=errors-BqpghFQf.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-BqpghFQf.cjs","names":[],"sources":["../src/categories.ts","../src/errors.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. Each id is also the translation key of\n * the category's name (`category.<id>`) and description (`category.<id>.description`) in the\n * 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"],"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"}
@@ -1,32 +0,0 @@
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. Each id is also the translation key of
5
- * the category's name (`category.<id>`) and description (`category.<id>.description`) in the
6
- * 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
- export { isConsentCategoryId as i, CONSENT_CATEGORIES as n, REQUIRED_CATEGORY as r, ConsentError as t };
31
-
32
- //# sourceMappingURL=errors-D2ZIcEYK.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-D2ZIcEYK.mjs","names":[],"sources":["../src/categories.ts","../src/errors.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. Each id is also the translation key of\n * the category's name (`category.<id>`) and description (`category.<id>.description`) in the\n * 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"],"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-BrxRJL4I.d.cts","names":[],"sources":["../src/categories.ts","../src/domain/consent-decision.ts","../src/types.ts"],"mappings":";;;;;;;;cAMa;;KAGD,4BAA4B;;cAG3B;;iBAGG,oBAAoB,iBAAiB,SAAS;;;UC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