@luwiostack/cookie-consent 0.0.0-stage → 0.1.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.
@@ -0,0 +1,449 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_errors = require("./errors-BqpghFQf.cjs");
3
+ //#region src/vendors/define-vendor.ts
4
+ /**
5
+ * Define a reusable vendor preset — how every preset in `@luwiostack/cookie-consent/vendors` is built, and
6
+ * the way to package your own (an in-house widget you use across apps). Cookie names are inferred as
7
+ * literals, so the preset's `cookies` option only accepts names it declares.
8
+ *
9
+ * Translation keys follow the package catalogs: `t(vendor.id)` is the vendor's name and
10
+ * `t(\`${vendor.id}.${cookie.name}\`)` a cookie's purpose.
11
+ */
12
+ function defineVendor(definition) {
13
+ const { id, privacy_policy_url, cookies } = definition;
14
+ const preset = (options = {}) => {
15
+ let picked = cookies;
16
+ if (options.cookies) {
17
+ const known = new Set(cookies.map((c) => c.name));
18
+ for (const name of options.cookies) if (!known.has(name)) throw new require_errors.ConsentError(`Vendor "${id}" has no cookie "${name}" — use \`extra\` to add one.`);
19
+ const wanted = new Set(options.cookies);
20
+ picked = cookies.filter((c) => wanted.has(c.name));
21
+ }
22
+ return {
23
+ id,
24
+ ...privacy_policy_url ? { privacy_policy_url } : {},
25
+ cookies: [...picked, ...options.extra ?? []]
26
+ };
27
+ };
28
+ return Object.assign(preset, {
29
+ id,
30
+ cookies
31
+ });
32
+ }
33
+ //#endregion
34
+ //#region src/vendors/time.ts
35
+ const MINUTE = 6e4;
36
+ const DAY = 24 * (60 * MINUTE);
37
+ //#endregion
38
+ //#region src/vendors/google-ads.ts
39
+ const googleAds = /* @__PURE__ */ defineVendor({
40
+ id: "google_ads",
41
+ privacy_policy_url: "https://policies.google.com/privacy",
42
+ cookies: [
43
+ {
44
+ name: "_gcl_au",
45
+ category: "marketing",
46
+ max_age: 90 * DAY
47
+ },
48
+ {
49
+ name: "_gcl_aw",
50
+ category: "marketing",
51
+ max_age: 90 * DAY
52
+ },
53
+ {
54
+ name: "_gcl_dc",
55
+ category: "marketing",
56
+ max_age: 90 * DAY
57
+ },
58
+ {
59
+ name: "_gac_*",
60
+ category: "marketing",
61
+ max_age: 90 * DAY
62
+ },
63
+ {
64
+ name: "IDE",
65
+ category: "marketing",
66
+ max_age: 390 * DAY
67
+ },
68
+ {
69
+ name: "test_cookie",
70
+ category: "marketing",
71
+ max_age: 15 * MINUTE
72
+ },
73
+ {
74
+ name: "ar_debug",
75
+ category: "marketing",
76
+ max_age: 90 * DAY
77
+ }
78
+ ]
79
+ });
80
+ //#endregion
81
+ //#region src/vendors/google-analytics.ts
82
+ const googleAnalytics = /* @__PURE__ */ defineVendor({
83
+ id: "google_analytics",
84
+ privacy_policy_url: "https://policies.google.com/privacy",
85
+ cookies: [{
86
+ name: "_ga",
87
+ category: "statistics",
88
+ max_age: 730 * DAY
89
+ }, {
90
+ name: "_ga_*",
91
+ category: "statistics",
92
+ max_age: 730 * DAY
93
+ }]
94
+ });
95
+ //#endregion
96
+ //#region src/vendors/google-maps.ts
97
+ const googleMaps = /* @__PURE__ */ defineVendor({
98
+ id: "google_maps",
99
+ privacy_policy_url: "https://policies.google.com/privacy",
100
+ cookies: [
101
+ {
102
+ name: "NID",
103
+ category: "marketing",
104
+ max_age: 180 * DAY
105
+ },
106
+ {
107
+ name: "AEC",
108
+ category: "necessary",
109
+ max_age: 180 * DAY
110
+ },
111
+ {
112
+ name: "SOCS",
113
+ category: "necessary",
114
+ max_age: 390 * DAY
115
+ }
116
+ ]
117
+ });
118
+ //#endregion
119
+ //#region src/vendors/google-recaptcha.ts
120
+ const googleRecaptcha = /* @__PURE__ */ defineVendor({
121
+ id: "google_recaptcha",
122
+ privacy_policy_url: "https://policies.google.com/privacy",
123
+ cookies: [{
124
+ name: "_GRECAPTCHA",
125
+ category: "necessary",
126
+ max_age: 180 * DAY
127
+ }]
128
+ });
129
+ //#endregion
130
+ //#region src/vendors/hotjar.ts
131
+ const hotjar = /* @__PURE__ */ defineVendor({
132
+ id: "hotjar",
133
+ privacy_policy_url: "https://www.hotjar.com/legal/policies/privacy/",
134
+ cookies: [
135
+ {
136
+ name: "_hjSessionUser_*",
137
+ category: "statistics",
138
+ max_age: 365 * DAY
139
+ },
140
+ {
141
+ name: "_hjSession_*",
142
+ category: "statistics",
143
+ max_age: 30 * MINUTE
144
+ },
145
+ {
146
+ name: "_hjHasCachedUserAttributes",
147
+ category: "statistics",
148
+ max_age: "session"
149
+ },
150
+ {
151
+ name: "_hjUserAttributesHash",
152
+ category: "statistics",
153
+ max_age: 2 * MINUTE
154
+ },
155
+ {
156
+ name: "_hjUserAttributes",
157
+ category: "statistics",
158
+ type: "local_storage",
159
+ max_age: "persistent"
160
+ },
161
+ {
162
+ name: "hjViewportId",
163
+ category: "statistics",
164
+ type: "session_storage",
165
+ max_age: "session"
166
+ },
167
+ {
168
+ name: "hjActiveViewportIds",
169
+ category: "statistics",
170
+ type: "local_storage",
171
+ max_age: "session"
172
+ },
173
+ {
174
+ name: "_hjDonePolls",
175
+ category: "statistics",
176
+ max_age: 365 * DAY
177
+ }
178
+ ]
179
+ });
180
+ //#endregion
181
+ //#region src/vendors/linkedin-insight.ts
182
+ const linkedinInsight = /* @__PURE__ */ defineVendor({
183
+ id: "linkedin_insight",
184
+ privacy_policy_url: "https://www.linkedin.com/legal/privacy-policy",
185
+ cookies: [
186
+ {
187
+ name: "li_fat_id",
188
+ category: "marketing",
189
+ max_age: 30 * DAY
190
+ },
191
+ {
192
+ name: "ln_or",
193
+ category: "marketing",
194
+ max_age: DAY
195
+ },
196
+ {
197
+ name: "bcookie",
198
+ category: "marketing",
199
+ max_age: 365 * DAY
200
+ },
201
+ {
202
+ name: "lidc",
203
+ category: "marketing",
204
+ max_age: DAY
205
+ },
206
+ {
207
+ name: "li_sugr",
208
+ category: "marketing",
209
+ max_age: 90 * DAY
210
+ },
211
+ {
212
+ name: "UserMatchHistory",
213
+ category: "marketing",
214
+ max_age: 30 * DAY
215
+ },
216
+ {
217
+ name: "AnalyticsSyncHistory",
218
+ category: "marketing",
219
+ max_age: 30 * DAY
220
+ },
221
+ {
222
+ name: "li_gc",
223
+ category: "necessary",
224
+ max_age: 180 * DAY
225
+ }
226
+ ]
227
+ });
228
+ //#endregion
229
+ //#region src/vendors/meta-pixel.ts
230
+ const metaPixel = /* @__PURE__ */ defineVendor({
231
+ id: "meta_pixel",
232
+ privacy_policy_url: "https://www.facebook.com/privacy/policy/",
233
+ cookies: [
234
+ {
235
+ name: "_fbp",
236
+ category: "marketing",
237
+ max_age: 90 * DAY
238
+ },
239
+ {
240
+ name: "_fbc",
241
+ category: "marketing",
242
+ max_age: 90 * DAY
243
+ },
244
+ {
245
+ name: "fr",
246
+ category: "marketing",
247
+ max_age: 90 * DAY
248
+ }
249
+ ]
250
+ });
251
+ //#endregion
252
+ //#region src/vendors/tiktok-pixel.ts
253
+ const tiktokPixel = /* @__PURE__ */ defineVendor({
254
+ id: "tiktok_pixel",
255
+ privacy_policy_url: "https://www.tiktok.com/legal/page/eea/privacy-policy/en",
256
+ cookies: [
257
+ {
258
+ name: "_ttp",
259
+ category: "marketing",
260
+ max_age: 390 * DAY
261
+ },
262
+ {
263
+ name: "ttcsid*",
264
+ category: "marketing",
265
+ max_age: 390 * DAY
266
+ },
267
+ {
268
+ name: "ttclid",
269
+ category: "marketing",
270
+ max_age: 390 * DAY
271
+ },
272
+ {
273
+ name: "_pangle",
274
+ category: "marketing",
275
+ max_age: 390 * DAY
276
+ }
277
+ ]
278
+ });
279
+ //#endregion
280
+ //#region src/vendors/vimeo.ts
281
+ const vimeo = /* @__PURE__ */ defineVendor({
282
+ id: "vimeo",
283
+ privacy_policy_url: "https://vimeo.com/privacy",
284
+ cookies: [
285
+ {
286
+ name: "vuid",
287
+ category: "statistics",
288
+ max_age: 730 * DAY
289
+ },
290
+ {
291
+ name: "player",
292
+ category: "preferences",
293
+ max_age: 365 * DAY
294
+ },
295
+ {
296
+ name: "player_clearance",
297
+ category: "necessary",
298
+ max_age: 7 * DAY
299
+ },
300
+ {
301
+ name: "__cf_bm",
302
+ category: "necessary",
303
+ max_age: 30 * MINUTE
304
+ },
305
+ {
306
+ name: "_cfuvid",
307
+ category: "necessary",
308
+ max_age: "session"
309
+ },
310
+ {
311
+ name: "cf_clearance",
312
+ category: "necessary",
313
+ max_age: 365 * DAY
314
+ }
315
+ ]
316
+ });
317
+ //#endregion
318
+ //#region src/vendors/youtube.ts
319
+ const youtube = /* @__PURE__ */ defineVendor({
320
+ id: "youtube",
321
+ privacy_policy_url: "https://policies.google.com/privacy",
322
+ cookies: [
323
+ {
324
+ name: "YSC",
325
+ category: "marketing",
326
+ max_age: "session"
327
+ },
328
+ {
329
+ name: "__Secure-YNID",
330
+ category: "marketing",
331
+ max_age: 180 * DAY
332
+ },
333
+ {
334
+ name: "VISITOR_INFO1_LIVE",
335
+ category: "marketing",
336
+ max_age: 180 * DAY
337
+ },
338
+ {
339
+ name: "__Secure-YENID",
340
+ category: "marketing",
341
+ max_age: 390 * DAY
342
+ },
343
+ {
344
+ name: "__Secure-ROLLOUT_TOKEN",
345
+ category: "marketing",
346
+ max_age: 180 * DAY
347
+ },
348
+ {
349
+ name: "PREF",
350
+ category: "preferences",
351
+ max_age: 240 * DAY
352
+ }
353
+ ]
354
+ });
355
+ //#endregion
356
+ //#region src/vendors/presets.ts
357
+ /**
358
+ * Every preset by its id — for when the set of vendors is decided at runtime (a backend that turns
359
+ * integrations on and off sends `"google_analytics"`, not code). Importing this map bundles every
360
+ * preset; import the named presets instead when your vendors are fixed in code.
361
+ */
362
+ const vendorPresets = {
363
+ google_analytics: googleAnalytics,
364
+ hotjar,
365
+ google_ads: googleAds,
366
+ meta_pixel: metaPixel,
367
+ linkedin_insight: linkedinInsight,
368
+ tiktok_pixel: tiktokPixel,
369
+ youtube,
370
+ vimeo,
371
+ google_maps: googleMaps,
372
+ google_recaptcha: googleRecaptcha
373
+ };
374
+ //#endregion
375
+ //#region src/vendors/from-data.ts
376
+ const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
377
+ function presetFor(id, where) {
378
+ if (typeof id === "string" && Object.hasOwn(vendorPresets, id)) return vendorPresets[id];
379
+ throw new require_errors.ConsentError(`${where}: unknown vendor preset "${String(id)}".`);
380
+ }
381
+ function vendorFromData(raw, where) {
382
+ if (typeof raw === "string") return presetFor(raw, where)();
383
+ if (!isObject(raw)) throw new require_errors.ConsentError(`${where}: must be a preset id or an object.`);
384
+ if ("preset" in raw) {
385
+ const preset = presetFor(raw.preset, where);
386
+ if (raw.cookies !== void 0 && !Array.isArray(raw.cookies)) throw new require_errors.ConsentError(`${where} ("${raw.preset}"): cookies must be an array of names.`);
387
+ if (raw.extra !== void 0 && !Array.isArray(raw.extra)) throw new require_errors.ConsentError(`${where} ("${raw.preset}"): extra must be an array of cookies.`);
388
+ return preset({
389
+ cookies: raw.cookies,
390
+ extra: raw.extra
391
+ });
392
+ }
393
+ return raw;
394
+ }
395
+ /**
396
+ * Turn backend data into `createConsent` options: per category, preset ids and references become
397
+ * full vendor declarations (from `vendorPresets`); full declarations pass through. Pass the app's
398
+ * own strictly necessary vendors as `necessary`, then spread the result and add what else only the
399
+ * app knows:
400
+ *
401
+ * ```ts
402
+ * const consent = createConsent({
403
+ * ...consentConfigFromData(config.consent, { necessary: [mySite] }),
404
+ * onChange,
405
+ * })
406
+ * ```
407
+ *
408
+ * Checks the shape as it goes — the data comes over the wire — and `createConsent` then validates
409
+ * the rest (a vendor without cookies of its category, cookie names, lifetimes).
410
+ *
411
+ * @throws {ConsentError} for a malformed shape, an unknown category or preset, a cookie a preset
412
+ * doesn't declare, or — when the app passes `necessary` — a `necessary` category in the data.
413
+ */
414
+ function consentConfigFromData(data, options = {}) {
415
+ if (!isObject(data)) throw new require_errors.ConsentError("Consent config data must be an object.");
416
+ if (!isObject(data.categories)) throw new require_errors.ConsentError("Consent config data needs a \"categories\" object.");
417
+ const categories = {};
418
+ if (options.necessary !== void 0) {
419
+ if (Object.hasOwn(data.categories, "necessary")) throw new require_errors.ConsentError(`Consent config data may not list "${require_errors.REQUIRED_CATEGORY}": the app declares its strictly necessary vendors itself.`);
420
+ if (!Array.isArray(options.necessary)) throw new require_errors.ConsentError(`The app's "${require_errors.REQUIRED_CATEGORY}" vendors must be an array.`);
421
+ categories[require_errors.REQUIRED_CATEGORY] = options.necessary;
422
+ }
423
+ for (const [id, list] of Object.entries(data.categories)) {
424
+ if (!require_errors.isConsentCategoryId(id)) throw new require_errors.ConsentError(`Unknown consent category "${id}".`);
425
+ if (!Array.isArray(list)) throw new require_errors.ConsentError(`Category "${id}": vendors must be an array.`);
426
+ categories[id] = list.map((raw, index) => vendorFromData(raw, `Category "${id}", vendor #${index + 1}`));
427
+ }
428
+ return {
429
+ categories,
430
+ ...data.policy_version !== void 0 ? { policyVersion: data.policy_version } : {},
431
+ ...data.max_age !== void 0 ? { maxAge: data.max_age } : {}
432
+ };
433
+ }
434
+ //#endregion
435
+ exports.consentConfigFromData = consentConfigFromData;
436
+ exports.defineVendor = defineVendor;
437
+ exports.googleAds = googleAds;
438
+ exports.googleAnalytics = googleAnalytics;
439
+ exports.googleMaps = googleMaps;
440
+ exports.googleRecaptcha = googleRecaptcha;
441
+ exports.hotjar = hotjar;
442
+ exports.linkedinInsight = linkedinInsight;
443
+ exports.metaPixel = metaPixel;
444
+ exports.tiktokPixel = tiktokPixel;
445
+ exports.vendorPresets = vendorPresets;
446
+ exports.vimeo = vimeo;
447
+ exports.youtube = youtube;
448
+
449
+ //# sourceMappingURL=vendors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendors.cjs","names":["ConsentError","ConsentError","REQUIRED_CATEGORY","isConsentCategoryId"],"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,IAAI,IAAI,GACjB,MAAM,IAAIA,eAAAA,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,OAAO;GACL;GACA,GAAI,qBAAqB,EAAE,mBAAmB,IAAI,CAAC;GACnD,SAAS,CAAC,GAAG,QAAQ,GAAI,QAAQ,SAAS,CAAC,CAAE;EAC/C;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KAAK,YAAA,WAA6B,GAClD,MAAM,IAAIA,eAAAA,aACR,qCAAqCC,eAAAA,kBAAkB,2DACzD;EAEF,IAAI,CAAC,MAAM,QAAQ,QAAQ,SAAS,GAClC,MAAM,IAAID,eAAAA,aAAa,cAAcC,eAAAA,kBAAkB,4BAA4B;EAErF,WAAWA,eAAAA,qBAAqB,QAAQ;CAC1C;CACA,KAAK,MAAM,CAAC,IAAI,SAAS,OAAO,QAAQ,KAAK,UAAU,GAAG;EACxD,IAAI,CAACC,eAAAA,oBAAoB,EAAE,GAAG,MAAM,IAAIF,eAAAA,aAAa,6BAA6B,GAAG,GAAG;EACxF,IAAI,CAAC,MAAM,QAAQ,IAAI,GAAG,MAAM,IAAIA,eAAAA,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"}
@@ -0,0 +1,163 @@
1
+ import { h as ConsentCategoryId, i as ConsentCookie, t as ConsentCategoriesConfig, u as ConsentVendor } from "./types-BrxRJL4I.cjs";
2
+ //#region src/vendors/define-vendor.d.ts
3
+ interface VendorPresetOptions<Name extends string = string> {
4
+ /**
5
+ * Only these of the preset's cookies — for when your integration doesn't set them all (e.g. no
6
+ * Google Signals). Default: every cookie in the preset. An unknown name is a type error and throws.
7
+ */
8
+ cookies?: readonly Name[];
9
+ /** Your own cookies on top, for anything this vendor sets in your setup that the preset lacks. */
10
+ extra?: readonly ConsentCookie[];
11
+ }
12
+ /** A ready-made vendor: call it (optionally narrowing or extending its cookies) to get a `ConsentVendor`. */
13
+ interface VendorPreset<Name extends string = string> {
14
+ (options?: VendorPresetOptions<Name>): ConsentVendor;
15
+ /** The vendor id — also the translation key of its name. */
16
+ readonly id: string;
17
+ /** Every cookie the preset declares. */
18
+ readonly cookies: readonly ConsentCookie[];
19
+ }
20
+ interface VendorDefinition<C extends readonly ConsentCookie[]> {
21
+ /** Stable key — also the translation key for the vendor's name, and the prefix of its cookies' keys. */
22
+ id: string;
23
+ privacy_policy_url?: string;
24
+ cookies: C;
25
+ }
26
+ /**
27
+ * Define a reusable vendor preset — how every preset in `@luwiostack/cookie-consent/vendors` is built, and
28
+ * the way to package your own (an in-house widget you use across apps). Cookie names are inferred as
29
+ * literals, so the preset's `cookies` option only accepts names it declares.
30
+ *
31
+ * Translation keys follow the package catalogs: `t(vendor.id)` is the vendor's name and
32
+ * `t(\`${vendor.id}.${cookie.name}\`)` a cookie's purpose.
33
+ */
34
+ declare function defineVendor<const C extends readonly ConsentCookie[]>(definition: VendorDefinition<C>): VendorPreset<C[number]['name']>;
35
+ //#endregion
36
+ //#region src/vendors/presets.d.ts
37
+ /**
38
+ * Every preset by its id — for when the set of vendors is decided at runtime (a backend that turns
39
+ * integrations on and off sends `"google_analytics"`, not code). Importing this map bundles every
40
+ * preset; import the named presets instead when your vendors are fixed in code.
41
+ */
42
+ declare const vendorPresets: {
43
+ readonly google_analytics: VendorPreset<"_ga" | "_ga_*">;
44
+ readonly hotjar: VendorPreset<"_hjDonePolls" | "_hjHasCachedUserAttributes" | "_hjSessionUser_*" | "_hjSession_*" | "_hjUserAttributes" | "_hjUserAttributesHash" | "hjActiveViewportIds" | "hjViewportId">;
45
+ readonly google_ads: VendorPreset<"IDE" | "_gac_*" | "_gcl_au" | "_gcl_aw" | "_gcl_dc" | "ar_debug" | "test_cookie">;
46
+ readonly meta_pixel: VendorPreset<"_fbc" | "_fbp" | "fr">;
47
+ readonly linkedin_insight: VendorPreset<"AnalyticsSyncHistory" | "UserMatchHistory" | "bcookie" | "li_fat_id" | "li_gc" | "li_sugr" | "lidc" | "ln_or">;
48
+ readonly tiktok_pixel: VendorPreset<"_pangle" | "_ttp" | "ttclid" | "ttcsid*">;
49
+ readonly youtube: VendorPreset<"PREF" | "VISITOR_INFO1_LIVE" | "YSC" | "__Secure-ROLLOUT_TOKEN" | "__Secure-YENID" | "__Secure-YNID">;
50
+ readonly vimeo: VendorPreset<"__cf_bm" | "_cfuvid" | "cf_clearance" | "player" | "player_clearance" | "vuid">;
51
+ readonly google_maps: VendorPreset<"AEC" | "NID" | "SOCS">;
52
+ readonly google_recaptcha: VendorPreset<"_GRECAPTCHA">;
53
+ };
54
+ /** The id of a shipped preset — `'google_analytics'`, `'meta_pixel'`, … */
55
+ type VendorPresetId = keyof typeof vendorPresets;
56
+ //#endregion
57
+ //#region src/vendors/from-data.d.ts
58
+ /**
59
+ * The serializable consent config — what a backend sends when it decides which integrations are on
60
+ * (a back office where an admin enables Google Analytics, or the YouTube embed without tracking).
61
+ * JSON only: per category, the vendors used in it — a preset id, a preset reference narrowed or
62
+ * extended, or a full declaration when there's no preset. A vendor brings only its cookies of the
63
+ * category it's listed under (plus its necessary ones). snake_case, like every dataset.
64
+ *
65
+ * ```json
66
+ * {
67
+ * "policy_version": 7,
68
+ * "categories": {
69
+ * "statistics": ["google_analytics"],
70
+ * "preferences": ["youtube"],
71
+ * "marketing": [
72
+ * { "preset": "google_ads", "cookies": ["_gcl_au", "IDE"] },
73
+ * { "id": "acme_chat", "cookies": [{ "name": "acme_id", "category": "marketing", "max_age": 31536000000 }] }
74
+ * ]
75
+ * }
76
+ * }
77
+ * ```
78
+ */
79
+ interface ConsentConfigData {
80
+ /** Bump it whenever the set of vendors changes, so every visitor is asked again. Default `1`. */
81
+ policy_version?: string | number;
82
+ /** How long a decision stays valid, in milliseconds. Default: 365 days. */
83
+ max_age?: number;
84
+ /** Per category, the vendors used in it. */
85
+ categories: Partial<Record<ConsentCategoryId, readonly ConsentVendorData[]>>;
86
+ }
87
+ /** A vendor in the data: a preset id, a preset reference, or a full declaration of your own. */
88
+ type ConsentVendorData = VendorPresetId | ConsentPresetVendorData | ConsentVendor;
89
+ /** A shipped preset by id, optionally narrowed (`cookies`) or extended (`extra`). */
90
+ interface ConsentPresetVendorData {
91
+ preset: VendorPresetId;
92
+ cookies?: readonly string[];
93
+ extra?: readonly ConsentCookie[];
94
+ }
95
+ /** The part of `createConsent`'s config that data describes. */
96
+ interface ConsentConfigFromData {
97
+ categories: ConsentCategoriesConfig;
98
+ policyVersion?: string | number;
99
+ maxAge?: number;
100
+ }
101
+ /** What only the app knows, merged into the data's config. */
102
+ interface ConsentConfigFromDataOptions {
103
+ /**
104
+ * The app's own strictly necessary vendors (its session cookie, CSRF token, the consent record),
105
+ * declared in code. Put under `necessary`, ahead of the data's categories. Once the app declares
106
+ * them, the data may not list `necessary` itself: strictly necessary cookies are the app's to
107
+ * declare, never the backend's.
108
+ */
109
+ necessary?: readonly ConsentVendor[];
110
+ }
111
+ /**
112
+ * Turn backend data into `createConsent` options: per category, preset ids and references become
113
+ * full vendor declarations (from `vendorPresets`); full declarations pass through. Pass the app's
114
+ * own strictly necessary vendors as `necessary`, then spread the result and add what else only the
115
+ * app knows:
116
+ *
117
+ * ```ts
118
+ * const consent = createConsent({
119
+ * ...consentConfigFromData(config.consent, { necessary: [mySite] }),
120
+ * onChange,
121
+ * })
122
+ * ```
123
+ *
124
+ * Checks the shape as it goes — the data comes over the wire — and `createConsent` then validates
125
+ * the rest (a vendor without cookies of its category, cookie names, lifetimes).
126
+ *
127
+ * @throws {ConsentError} for a malformed shape, an unknown category or preset, a cookie a preset
128
+ * doesn't declare, or — when the app passes `necessary` — a `necessary` category in the data.
129
+ */
130
+ declare function consentConfigFromData(data: ConsentConfigData, options?: ConsentConfigFromDataOptions): ConsentConfigFromData;
131
+ //#endregion
132
+ //#region src/vendors/google-ads.d.ts
133
+ declare const googleAds: VendorPreset<"IDE" | "_gac_*" | "_gcl_au" | "_gcl_aw" | "_gcl_dc" | "ar_debug" | "test_cookie">;
134
+ //#endregion
135
+ //#region src/vendors/google-analytics.d.ts
136
+ declare const googleAnalytics: VendorPreset<"_ga" | "_ga_*">;
137
+ //#endregion
138
+ //#region src/vendors/google-maps.d.ts
139
+ declare const googleMaps: VendorPreset<"AEC" | "NID" | "SOCS">;
140
+ //#endregion
141
+ //#region src/vendors/google-recaptcha.d.ts
142
+ declare const googleRecaptcha: VendorPreset<"_GRECAPTCHA">;
143
+ //#endregion
144
+ //#region src/vendors/hotjar.d.ts
145
+ declare const hotjar: VendorPreset<"_hjDonePolls" | "_hjHasCachedUserAttributes" | "_hjSessionUser_*" | "_hjSession_*" | "_hjUserAttributes" | "_hjUserAttributesHash" | "hjActiveViewportIds" | "hjViewportId">;
146
+ //#endregion
147
+ //#region src/vendors/linkedin-insight.d.ts
148
+ declare const linkedinInsight: VendorPreset<"AnalyticsSyncHistory" | "UserMatchHistory" | "bcookie" | "li_fat_id" | "li_gc" | "li_sugr" | "lidc" | "ln_or">;
149
+ //#endregion
150
+ //#region src/vendors/meta-pixel.d.ts
151
+ declare const metaPixel: VendorPreset<"_fbc" | "_fbp" | "fr">;
152
+ //#endregion
153
+ //#region src/vendors/tiktok-pixel.d.ts
154
+ declare const tiktokPixel: VendorPreset<"_pangle" | "_ttp" | "ttclid" | "ttcsid*">;
155
+ //#endregion
156
+ //#region src/vendors/vimeo.d.ts
157
+ declare const vimeo: VendorPreset<"__cf_bm" | "_cfuvid" | "cf_clearance" | "player" | "player_clearance" | "vuid">;
158
+ //#endregion
159
+ //#region src/vendors/youtube.d.ts
160
+ declare const youtube: VendorPreset<"PREF" | "VISITOR_INFO1_LIVE" | "YSC" | "__Secure-ROLLOUT_TOKEN" | "__Secure-YENID" | "__Secure-YNID">;
161
+ //#endregion
162
+ export { type ConsentConfigData, type ConsentConfigFromData, type ConsentConfigFromDataOptions, type ConsentPresetVendorData, type ConsentVendorData, type VendorDefinition, type VendorPreset, type VendorPresetId, type VendorPresetOptions, consentConfigFromData, defineVendor, googleAds, googleAnalytics, googleMaps, googleRecaptcha, hotjar, linkedinInsight, metaPixel, tiktokPixel, vendorPresets, vimeo, youtube };
163
+ //# sourceMappingURL=vendors.d.cts.map