@consenti/ui 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -98
- package/dist/angular.d.cts +326 -43
- package/dist/angular.d.ts +326 -43
- package/dist/angular.js +1 -1
- package/dist/angular.js.map +1 -1
- package/dist/angular.mjs +1 -1
- package/dist/angular.mjs.map +1 -1
- package/dist/chunk-RDE7CM6T.mjs +2 -0
- package/dist/chunk-RDE7CM6T.mjs.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +377 -42
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/profiles-5ZLWWN2L.mjs +2 -0
- package/dist/react.d.cts +326 -43
- package/dist/react.d.ts +326 -43
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/vue.d.cts +326 -43
- package/dist/vue.d.ts +326 -43
- package/dist/vue.js +1 -1
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +1 -1
- package/dist/vue.mjs.map +1 -1
- package/package.json +9 -5
- package/dist/chunk-J4BKXUD6.mjs +0 -2
- package/dist/chunk-J4BKXUD6.mjs.map +0 -1
- package/dist/profiles-OEZAKEWL.mjs +0 -2
- /package/dist/{profiles-OEZAKEWL.mjs.map → profiles-5ZLWWN2L.mjs.map} +0 -0
package/dist/vue.d.cts
CHANGED
|
@@ -13,6 +13,32 @@ type DeepPartial<T> = T extends Function ? T : T extends Array<infer InferredArr
|
|
|
13
13
|
[Key in keyof T]?: DeepPartial<T[Key]> | null;
|
|
14
14
|
} : T;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Single source of truth for all compliance groups, regulations, and country mappings.
|
|
18
|
+
*
|
|
19
|
+
* This is DATA, not types. The `Compliance` and `ComplianceGroupId` literal types
|
|
20
|
+
* derived from the ID arrays below live in @consenti/types (packages/types/src/compliance.ts),
|
|
21
|
+
* via a type-only import — that keeps @consenti/types free of runtime code.
|
|
22
|
+
*
|
|
23
|
+
* ─── HOW TO UPDATE ────────────────────────────────────────────────────────────
|
|
24
|
+
*
|
|
25
|
+
* ADD A NEW REGULATION:
|
|
26
|
+
* 1. Add regulation ID string to `COMPLIANCE_REGULATION_IDS` below
|
|
27
|
+
* (the `Compliance` type in @consenti/types auto-updates from it).
|
|
28
|
+
* 2. Add it to the appropriate group's `compliances` array below.
|
|
29
|
+
* 3. Add / update the country entry in `EMBEDDED_COMPLIANCE_MAP` below.
|
|
30
|
+
* That is all — no other files need touching.
|
|
31
|
+
*
|
|
32
|
+
* ADD A NEW COMPLIANCE GROUP:
|
|
33
|
+
* 1. Add the kebab-case ID to `COMPLIANCE_GROUP_IDS` below.
|
|
34
|
+
* 2. Add a full group entry to `COMPLIANCE_GROUPS` below (label, compliances, flags).
|
|
35
|
+
* 3. Add a validation rule set to `COMPLIANCE_VALIDATION_RULES` below.
|
|
36
|
+
* 4. Map affected countries in `EMBEDDED_COMPLIANCE_MAP` to the new group.
|
|
37
|
+
*
|
|
38
|
+
* ADD OR UPDATE A COUNTRY:
|
|
39
|
+
* Edit the entry in `EMBEDDED_COMPLIANCE_MAP.countries` below. That is the ONLY
|
|
40
|
+
* place that needs changing for country-level jurisdiction updates.
|
|
41
|
+
*/
|
|
16
42
|
declare const COMPLIANCE_GROUP_IDS: readonly ["opt-in", "opt-out", "opt-out-strict", "opt-in-dpdpa", "opt-in-china", "opt-in-brazil", "general-privacy-consent", "notice-only"];
|
|
17
43
|
declare const COOKIE_PURPOSE_IDS: readonly ["necessary", "functional", "preferences", "analytics", "marketing"];
|
|
18
44
|
|
|
@@ -44,11 +70,14 @@ interface ComplianceMapData {
|
|
|
44
70
|
}
|
|
45
71
|
interface CountryComplianceEntry {
|
|
46
72
|
complianceGroup: ComplianceGroupId;
|
|
47
|
-
|
|
48
|
-
|
|
73
|
+
/** Fallback group used when only the country (not the region) is known. Defaults to
|
|
74
|
+
* `complianceGroup` when omitted — only set this explicitly when a region within this
|
|
75
|
+
* country can be stricter than the country-wide baseline (see `overriddenRegions`). */
|
|
76
|
+
default?: ComplianceGroupId;
|
|
77
|
+
description?: string;
|
|
49
78
|
overriddenRegions?: Record<string, {
|
|
50
79
|
complianceGroup: ComplianceGroupId;
|
|
51
|
-
description
|
|
80
|
+
description?: string;
|
|
52
81
|
}>;
|
|
53
82
|
}
|
|
54
83
|
interface ConsentDbRecord {
|
|
@@ -63,9 +92,10 @@ interface ConsentDbRecord {
|
|
|
63
92
|
ageVerified?: boolean;
|
|
64
93
|
parentalConsentToken?: string;
|
|
65
94
|
tcfString?: string;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
95
|
+
gppString?: string;
|
|
96
|
+
/** HMAC-SHA256 signature over the record's core fields, hex-encoded — tamper-evidence for
|
|
97
|
+
* server-stored records via `dataSigningHash` (auto-generated when unset), independent of the
|
|
98
|
+
* widget's own cookie-signing (`core.cookieSigningKey`). */
|
|
69
99
|
signature?: string;
|
|
70
100
|
createdAt: string;
|
|
71
101
|
updatedAt: string;
|
|
@@ -76,15 +106,18 @@ type ConsentAction = 'accept_all' | 'reject_all' | 'custom' | 'update';
|
|
|
76
106
|
type ConsentValue = Record<string, ConsentStatus>;
|
|
77
107
|
/**
|
|
78
108
|
* Output format for getConsent(type).
|
|
79
|
-
* 'default' → raw ConsentValue (existing behaviour)
|
|
109
|
+
* 'default' → raw ConsentValue, keyed by every cookie parameter ID in the profile (existing behaviour)
|
|
80
110
|
* 'google-gtm' → Google Consent Mode v2 keys + ads_data_redaction, url_passthrough
|
|
81
|
-
* '
|
|
111
|
+
* 'purpose' → consent per the fixed CookiePurpose taxonomy (necessary/functional/preferences/analytics/marketing)
|
|
112
|
+
* 'category' → consent per the tenant's own authored preference-modal category, keyed by category ID.
|
|
113
|
+
* 'granted' only when every member parameter is granted; 'denied'/'objected' otherwise
|
|
114
|
+
* (same ConsentStatus values as everything else — see getCategoryConsent for the exact rule)
|
|
82
115
|
* 'adobe' → { analytics, target, manager, optimizer }
|
|
83
116
|
* 'meta' → { pixel, api, plugins, facebookLogin }
|
|
84
117
|
* 'microsoft-clarity' → { session, heatmaps, performance }
|
|
85
118
|
* 'twilio-segment' → { identify, page, track, group, alias }
|
|
86
119
|
*/
|
|
87
|
-
type ConsentType = 'default' | 'google-gtm' | 'category' | 'adobe' | 'meta' | 'microsoft-clarity' | 'twilio-segment';
|
|
120
|
+
type ConsentType = 'default' | 'google-gtm' | 'purpose' | 'category' | 'adobe' | 'meta' | 'microsoft-clarity' | 'twilio-segment';
|
|
88
121
|
type GpcMode = 'ignore' | 'honor' | 'strict';
|
|
89
122
|
type LegalBasis = 'mandatory' | 'consent' | 'legitimate_interest';
|
|
90
123
|
type CookiePurpose = typeof COOKIE_PURPOSE_IDS[number];
|
|
@@ -172,12 +205,46 @@ interface PreferenceModal extends Omit<MainBanner, "position"> {
|
|
|
172
205
|
receiptLabel?: string;
|
|
173
206
|
/** Description shown beneath the consent-receipt checkbox. Falls back to a default when omitted. */
|
|
174
207
|
receiptDescription?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Renders a "Forget me" control in the modal body, below the categories — only shown to
|
|
210
|
+
* visitors who already have a stored consent decision (nothing to erase otherwise). Wired to
|
|
211
|
+
* the same `DELETE /consent/:visitorId` erasure endpoint as `widget.deleteConsent()`, giving
|
|
212
|
+
* visitors self-service access to GDPR Art. 17 / CCPA-CPRA / LGPD Art. 18 / UK GDPR / DPDPA /
|
|
213
|
+
* KVKK / POPIA / PDPA-TH / APPI erasure-equivalent rights without the host wiring a link
|
|
214
|
+
* themselves. See the "Right to erasure" guide for the full compliance mapping.
|
|
215
|
+
*/
|
|
216
|
+
showForgetMe?: boolean;
|
|
217
|
+
/** Label for the "Forget me" button (shown when `showForgetMe` is true). Falls back to a default when omitted. */
|
|
218
|
+
forgetMeLabel?: string;
|
|
175
219
|
}
|
|
176
220
|
interface DpdpaConfig {
|
|
177
221
|
dataFiduciary: string;
|
|
178
222
|
grievanceEmail: string;
|
|
179
223
|
purposeDescription?: string;
|
|
180
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Per-profile age gate — GDPR Art. 8's consent age varies 13–16 by EU member state and DPDPA has
|
|
227
|
+
* its own child-data age rules, so one global age (the old `ConsentiServerConfig.ageGate`) was
|
|
228
|
+
* wrong for a multi-region deployment. Mirrors `dpdpa` exactly: profile-scoped, not global.
|
|
229
|
+
*/
|
|
230
|
+
interface AgeGateConfig {
|
|
231
|
+
enabled: boolean;
|
|
232
|
+
minimumAge: number;
|
|
233
|
+
requireParentalConsent?: boolean;
|
|
234
|
+
}
|
|
235
|
+
/** Per-locale age-gate modal text — translated the same way `mainBanner`/`preferenceModal`
|
|
236
|
+
* content is, unlike the widget's own hardcoded UI chrome (close button, locale switcher). */
|
|
237
|
+
interface AgeGateModalContent {
|
|
238
|
+
heading?: string;
|
|
239
|
+
htmlText: string;
|
|
240
|
+
confirmButtonLabel: string;
|
|
241
|
+
denyButtonLabel: string;
|
|
242
|
+
parentalConsent: {
|
|
243
|
+
heading?: string;
|
|
244
|
+
htmlText: string;
|
|
245
|
+
confirmButtonLabel: string;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
181
248
|
interface ResolvedProfile {
|
|
182
249
|
id: string;
|
|
183
250
|
/** Incremented in place on every save of this profile. Absent for embedded/local profiles that have no server-side version counter. */
|
|
@@ -193,9 +260,21 @@ interface ResolvedProfile {
|
|
|
193
260
|
preferenceModal: PreferenceModal;
|
|
194
261
|
cookieSigningKey?: string;
|
|
195
262
|
dpdpa?: DpdpaConfig;
|
|
263
|
+
ageGate?: AgeGateConfig;
|
|
264
|
+
ageGateModal?: AgeGateModalContent;
|
|
196
265
|
darkMode?: boolean;
|
|
197
266
|
gpcMode?: GpcMode;
|
|
198
|
-
|
|
267
|
+
/** One of the 8 built-in groups, or a custom group id (via `customComplianceGroup` /
|
|
268
|
+
* `ComplianceType`'s string passthrough) — this is the join key `complianceGroupsOverride`
|
|
269
|
+
* looks up by, so it must reflect whichever group this profile actually resolved against,
|
|
270
|
+
* built-in or custom. */
|
|
271
|
+
complianceGroup?: ComplianceGroupId | (string & {});
|
|
272
|
+
/** Set when the geo-resolved region carries a `requiresSensitiveOptIn` carve-out (e.g.
|
|
273
|
+
* Colorado under `opt-out`) — cookies tagged `cpraCategory: 'sensitive'` default to denied
|
|
274
|
+
* even though the rest of `complianceGroup`'s cookies default to granted. Only ever set by
|
|
275
|
+
* server-side geo resolution (`api.enabled: true` + a geoip/maxmind provider); the
|
|
276
|
+
* client-only timezone heuristic never resolves a region, so this is always unset there. */
|
|
277
|
+
requiresSensitiveOptIn?: boolean;
|
|
199
278
|
complianceConfig?: Record<string, string>;
|
|
200
279
|
/** Falls back to `true` (hidden) if neither the widget config nor the profile set it. */
|
|
201
280
|
hidePoweredBy?: boolean;
|
|
@@ -208,26 +287,66 @@ type WidgetCountryResolverFn = () => Promise<{
|
|
|
208
287
|
country: string | null;
|
|
209
288
|
region: string | null;
|
|
210
289
|
confidence: number;
|
|
290
|
+
/** Optional escape hatch: when set, profile resolution uses this compliance group directly
|
|
291
|
+
* instead of computing one from `country`/`region` — mirrors the server-side `GeoResult`'s
|
|
292
|
+
* `complianceGroup` field (`@consenti/types`'s `api.ts`). `country`/`region` are still used for
|
|
293
|
+
* anything that reads them independently of group selection. Optional — omitting it preserves
|
|
294
|
+
* the existing timezone/language-based resolution exactly as before. */
|
|
295
|
+
complianceGroup?: string;
|
|
211
296
|
}>;
|
|
212
|
-
interface AgeGateWidgetConfig {
|
|
213
|
-
enabled: boolean;
|
|
214
|
-
minimumAge: number;
|
|
215
|
-
requireParentalConsent?: boolean;
|
|
216
|
-
}
|
|
217
297
|
/** Mirrors the server-side `TcfConfig` shape (`@consenti/api`) — `cmpId`/`cmpVersion` must match
|
|
218
|
-
* what the backend uses to encode `tcfString`, since both feed the same simplified TC string.
|
|
298
|
+
* what the backend uses to encode `tcfString`, since both feed the same simplified TC string.
|
|
299
|
+
*
|
|
300
|
+
* The client-side `__tcfapi` stub never fetches the Global Vendor List itself (multi-megabyte,
|
|
301
|
+
* and IAB policy requires CMPs to cache their own copy rather than have every visitor's browser
|
|
302
|
+
* fetch it) — `publisherCC`/`vendorListVersion`/`gvlVersion` are therefore operator-supplied
|
|
303
|
+
* config here, not auto-derived. Spec-correct binary TC-string encoding happens server-side in
|
|
304
|
+
* `@consenti/api` (see `compliance.tcf.publisherCC` there); this stub's `tcString` stays the
|
|
305
|
+
* simplified format documented in `@consenti/utils`'s `encodeTcString`. */
|
|
219
306
|
interface TcfWidgetConfig {
|
|
220
307
|
enabled: boolean;
|
|
221
308
|
cmpId: number;
|
|
222
309
|
cmpVersion: number;
|
|
310
|
+
/** ISO 3166-1 alpha-2 publisher country code. No honest default exists — leave unset only if
|
|
311
|
+
* you don't rely on this field downstream; ad-tech vendors that read it will see 'AA'
|
|
312
|
+
* (an explicit "not configured" placeholder, not a real country). */
|
|
313
|
+
publisherCC?: string;
|
|
314
|
+
/** Known Global Vendor List version, if you track it. Defaults to 0 ("unknown"). */
|
|
315
|
+
vendorListVersion?: number;
|
|
316
|
+
/** Known GVL specification version, if you track it. Defaults to 0 ("unknown"). */
|
|
317
|
+
gvlVersion?: number;
|
|
318
|
+
}
|
|
319
|
+
/** Mirrors the server-side `GppConfig` shape (`@consenti/api`) — `cmpId`/`cmpVersion` must match
|
|
320
|
+
* what the backend uses to encode `gppString`. Unlike TCF, the GPP US National section needs no
|
|
321
|
+
* Global Vendor List, so both the widget's `window.__gpp` and the server's `gppString` use the
|
|
322
|
+
* same real, spec-correct encoder (the optional `@iabgpp/cmpapi` peer dependency) — there's no
|
|
323
|
+
* "simplified fallback" format the way TCF has, since a non-spec GPP string has no consumer that
|
|
324
|
+
* would accept it. When `@iabgpp/cmpapi` isn't installed, `window.__gpp` is simply not exposed. */
|
|
325
|
+
interface GppWidgetConfig {
|
|
326
|
+
enabled: boolean;
|
|
327
|
+
cmpId: number;
|
|
328
|
+
cmpVersion: number;
|
|
329
|
+
/** MSPA "covered transaction" — whether this deployment's data transactions fall under MSPA
|
|
330
|
+
* signatory obligations. No honest default, so it's required rather than optional. */
|
|
331
|
+
mspaCoveredTransaction: boolean;
|
|
332
|
+
/** IAB's tri-state encoding for both MSPA fields: 0 = not applicable, 1 = yes, 2 = no. */
|
|
333
|
+
mspaOptOutOptionMode: 0 | 1 | 2;
|
|
334
|
+
mspaServiceProviderMode: 0 | 1 | 2;
|
|
223
335
|
}
|
|
224
336
|
interface ComplianceWidgetConfig {
|
|
225
337
|
type?: ComplianceType;
|
|
226
338
|
geoDataProvider?: 'default' | WidgetCountryResolverFn;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
339
|
+
/** Only meaningful in standalone mode (no `api.enabled`) — ignored (with a warning) when
|
|
340
|
+
* `api.enabled: true`, since the server resolves the compliance group in that mode.
|
|
341
|
+
* `'default'` (embedded map, the default), a URL to fetch a JSON `ComplianceMapData`
|
|
342
|
+
* document from (the browser's own HTTP cache honors whatever `Cache-Control`/`ETag` the
|
|
343
|
+
* response sends — no custom caching here), or an inline operator-supplied `ComplianceMapData`
|
|
344
|
+
* object. Invalid data from either a URL or an object logs a warning and falls back to
|
|
345
|
+
* `'default'`. Only overrides the country→group mapping — country/region detection itself
|
|
346
|
+
* always uses the embedded geo data. */
|
|
347
|
+
complianceMap?: 'default' | string | ComplianceMapData;
|
|
230
348
|
tcf?: TcfWidgetConfig;
|
|
349
|
+
gpp?: GppWidgetConfig;
|
|
231
350
|
}
|
|
232
351
|
interface GtmConfig {
|
|
233
352
|
containerId?: string;
|
|
@@ -248,37 +367,67 @@ interface ApiConfig {
|
|
|
248
367
|
complianceGroup?: ComplianceGroupId;
|
|
249
368
|
trustDomain?: boolean;
|
|
250
369
|
}
|
|
370
|
+
/** Field names mirror their `--consenti-*` CSS variable literally (`--consenti-color-primary`
|
|
371
|
+
* → `colorPrimary`) — see `applyTheme()` in `consenti-setup.ts` for the full mapping. */
|
|
251
372
|
interface ThemeConfig {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
373
|
+
colorBg?: string;
|
|
374
|
+
colorText?: string;
|
|
375
|
+
colorTextMuted?: string;
|
|
376
|
+
colorPrimary?: string;
|
|
377
|
+
colorPrimaryText?: string;
|
|
378
|
+
colorSecondary?: string;
|
|
379
|
+
colorSecondaryText?: string;
|
|
380
|
+
colorBorder?: string;
|
|
381
|
+
colorSecondaryBorder?: string;
|
|
382
|
+
colorOverlay?: string;
|
|
383
|
+
colorAccent?: string;
|
|
384
|
+
colorAccentText?: string;
|
|
259
385
|
fontFamily?: string;
|
|
386
|
+
fontFamilyMono?: string;
|
|
260
387
|
fontSizeBase?: string;
|
|
261
388
|
fontSizeHeading?: string;
|
|
262
389
|
fontSizeMultiplier?: string;
|
|
390
|
+
fontWeightHeading?: string;
|
|
391
|
+
lineHeight?: string;
|
|
392
|
+
spacingXs?: string;
|
|
393
|
+
spacingSm?: string;
|
|
394
|
+
spacingMd?: string;
|
|
395
|
+
spacingLg?: string;
|
|
263
396
|
borderRadius?: string;
|
|
264
|
-
|
|
397
|
+
borderRadiusBtn?: string;
|
|
398
|
+
shadow?: string;
|
|
265
399
|
toggleBgOn?: string;
|
|
400
|
+
toggleBgPartial?: string;
|
|
266
401
|
toggleBgOff?: string;
|
|
267
|
-
|
|
268
|
-
|
|
402
|
+
toggleKnob?: string;
|
|
403
|
+
toggleWidth?: string;
|
|
404
|
+
toggleHeight?: string;
|
|
405
|
+
zBanner?: string;
|
|
406
|
+
zOverlay?: string;
|
|
407
|
+
zModal?: string;
|
|
269
408
|
}
|
|
270
409
|
interface CoreConfig {
|
|
271
410
|
tenantId?: string;
|
|
272
411
|
locale?: string;
|
|
273
|
-
/** Text direction for the banner/modal root. `'auto'` (default) derives it from `locale`
|
|
274
|
-
* (
|
|
412
|
+
/** Text direction for the banner/modal root. `'auto'` (default) derives it from `locale` via
|
|
413
|
+
* `Intl.Locale(...).getTextInfo().direction` (falling back to a hand-maintained RTL-language
|
|
414
|
+
* list on engines without `getTextInfo()` support); set explicitly to override. */
|
|
275
415
|
dir?: 'ltr' | 'rtl' | 'auto';
|
|
276
416
|
disableCssTemplate?: boolean;
|
|
277
417
|
cookieSigningKey?: string;
|
|
278
418
|
allowReceipt?: boolean;
|
|
279
419
|
cookieDomains?: string;
|
|
420
|
+
/** Name of the consent cookie/localStorage key. Default: `'consenti_data'`. Not switched
|
|
421
|
+
* automatically by detected region — set explicitly if you want a different name (e.g.
|
|
422
|
+
* `'euconsent-v2'`, the IAB TCF convention, but only meaningful for operators using the
|
|
423
|
+
* spec-correct binary encoder — `@consenti/api` + the optional `@iabtechlabtcf/core` peer
|
|
424
|
+
* dependency — since the IAB name implies IAB's binary format, not Consenti's own encoding). */
|
|
425
|
+
cookieName?: string;
|
|
280
426
|
storage?: 'cookie' | 'localStorage';
|
|
281
427
|
theme?: ThemeConfig;
|
|
428
|
+
/** Initial logged-in application user ID; empty/anonymous when unset. Prefer `getUserId()`/
|
|
429
|
+
* `setUserId()` (or the `consenti:listener:identify` event) to change it after init — those
|
|
430
|
+
* also handle reconsent when the identity changes on a shared device. */
|
|
282
431
|
userId?: string;
|
|
283
432
|
usePrebuiltProfiles?: 'all' | NonEmptyArray<ComplianceGroupId>;
|
|
284
433
|
cacheResolvedProfiles?: boolean;
|
|
@@ -298,10 +447,25 @@ interface ConsentiConfig {
|
|
|
298
447
|
utils?: UtilsConfig;
|
|
299
448
|
plugins?: ConsentiPlugin[];
|
|
300
449
|
profileOverride?: DeepPartial<ResolvedProfile>;
|
|
450
|
+
/** Per-compliance-group text/button/cookie overrides — applied on top of whichever profile the
|
|
451
|
+
* visitor's resolved group loads, keyed by that group's id (one of the 8 built-in
|
|
452
|
+
* `ComplianceGroupId`s, or any custom group id). Lets you author different copy per country
|
|
453
|
+
* without creating a separate profile (and separate `compliance.type` wiring) for each one —
|
|
454
|
+
* e.g. `{ 'opt-in': { mainBanner: { htmlText: '...' } }, 'my-custom-group': { ... } }`.
|
|
455
|
+
* Applied before `profileOverride`, which still always applies last as the universal catch-all.
|
|
456
|
+
* Works identically in standalone and server (`api.enabled`) mode. */
|
|
457
|
+
complianceGroupsOverride?: Partial<Record<ComplianceGroupId | (string & {}), DeepPartial<ResolvedProfile>>>;
|
|
301
458
|
/** When true, suppresses the "Powered by Consenti" footer link in the banner and modal. */
|
|
302
459
|
hidePoweredBy?: boolean;
|
|
303
460
|
}
|
|
304
|
-
type ConsentiEventName = 'bannerInitialized' | 'consenti:bannerInitialized' | 'bannerVisibility' | 'consenti:bannerVisibility' | 'modalVisibility' | 'consenti:modalVisibility' | 'consentBeingSubmitted' | 'consenti:consentBeingSubmitted' | 'consentSubmitted' | 'consenti:consentSubmitted' | 'parentalConsentRequired' | 'consenti:parentalConsentRequired';
|
|
461
|
+
type ConsentiEventName = 'bannerInitialized' | 'consenti:bannerInitialized' | 'bannerVisibility' | 'consenti:bannerVisibility' | 'modalVisibility' | 'consenti:modalVisibility' | 'consentBeingSubmitted' | 'consenti:consentBeingSubmitted' | 'consentSubmitted' | 'consenti:consentSubmitted' | 'parentalConsentRequired' | 'consenti:parentalConsentRequired' | 'forgetMeRequested' | 'consenti:forgetMeRequested' | 'forgotten' | 'consenti:forgotten';
|
|
462
|
+
/** Snapshot of the current visitor's identity. `visitorId` is `null` until a consent decision
|
|
463
|
+
* has actually happened — it's never minted just to answer this call, see `getVisitor()`. */
|
|
464
|
+
interface VisitorIdentity {
|
|
465
|
+
visitorId: string | null;
|
|
466
|
+
type: 'authenticated' | 'anonymous';
|
|
467
|
+
userId: string | null;
|
|
468
|
+
}
|
|
305
469
|
interface ConsentiWidgetAPI {
|
|
306
470
|
hasConsent(): boolean;
|
|
307
471
|
getConsent(): ConsentValue | null;
|
|
@@ -332,10 +496,25 @@ interface ConsentiWidgetAPI {
|
|
|
332
496
|
submitConsent(consent: Partial<ConsentValue>): Promise<ConsentDbRecord | void>;
|
|
333
497
|
deleteConsent(): Promise<void>;
|
|
334
498
|
reConsent(): Promise<void>;
|
|
499
|
+
/** Erases the stored consent record (same underlying call as `deleteConsent()`) and
|
|
500
|
+
* re-prompts, dispatching `consenti:forgetMeRequested` / `consenti:forgotten` around it so a
|
|
501
|
+
* host app can hook its own identity-verified erasure workflow. Powers the preference modal's
|
|
502
|
+
* "Forget me" button; also callable directly for a custom placement of the same action. */
|
|
503
|
+
forgetMe(resetAgeGate?: boolean): Promise<void>;
|
|
335
504
|
getRootElement(): HTMLElement | null;
|
|
336
505
|
getBannerElement(): HTMLElement | null;
|
|
337
506
|
getModalElement(): HTMLElement | null;
|
|
338
507
|
switchLocale(locale: string): void;
|
|
508
|
+
getUserId(): string | null;
|
|
509
|
+
/** Sets the logged-in application user ID (`null` for anonymous/logout). When the stored
|
|
510
|
+
* consent record's user differs from the new value, reconsents by default — pass
|
|
511
|
+
* `reConsent: false` to just update the identity without prompting again. No-ops (no
|
|
512
|
+
* reconsent, no warning) when there's no prior consent record to compare against. */
|
|
513
|
+
setUserId(userId: string | null, reConsent?: boolean): Promise<void>;
|
|
514
|
+
/** Snapshot of the current visitor's identity: the stable per-browser `visitorId` (`null` if
|
|
515
|
+
* no consent decision has happened yet — this never creates one), whether they're
|
|
516
|
+
* `authenticated` or `anonymous`, and the app `userId` (same as `getUserId()`). */
|
|
517
|
+
getVisitor(): VisitorIdentity;
|
|
339
518
|
setDarkMode(enable?: boolean): void;
|
|
340
519
|
setTheme(theme: Partial<ThemeConfig>): void;
|
|
341
520
|
setConfig(config: DeepPartial<ConsentiConfig>): void;
|
|
@@ -383,17 +562,45 @@ interface ConsentBeingSubmitted {
|
|
|
383
562
|
interface ConsentSubmittedDetail extends ConsentBeingSubmitted {
|
|
384
563
|
apiResponse: ConsentDbRecord;
|
|
385
564
|
}
|
|
386
|
-
/** Dispatched when the age gate is declined and `requireParentalConsent` is set — see
|
|
387
|
-
* `
|
|
565
|
+
/** Dispatched when the age gate is declined and `requireParentalConsent` is set — see the
|
|
566
|
+
* profile's `AgeGateConfig`. A deny-all consent (mandatory cookies only) has already been
|
|
388
567
|
* submitted with `parentalConsentToken` attached; this event is the hook for the site
|
|
389
|
-
* owner to run their own out-of-band parental-consent verification.
|
|
568
|
+
* owner to run their own out-of-band parental-consent verification. `parentalConsentToken` is
|
|
569
|
+
* server-issued (and signed, when `compliance.dataSigningHash` is configured) when `api.enabled`,
|
|
570
|
+
* otherwise a client-generated, unsigned fallback — see `POST /consent/:visitorId/parental-consent-request`. */
|
|
390
571
|
interface ParentalConsentRequiredDetail {
|
|
391
572
|
parentalConsentToken: string;
|
|
392
573
|
profileId: string;
|
|
393
574
|
visitorId: string;
|
|
394
575
|
timestamp: number;
|
|
395
576
|
}
|
|
396
|
-
|
|
577
|
+
/** Dispatched by the standalone `resolveParentalConsent()` util (`apps/ui/src/utils/parental-consent.ts`)
|
|
578
|
+
* after `POST /consent/parental-consent-resolve` succeeds — typically from a fresh page/session
|
|
579
|
+
* with no live `ConsentiSetup` instance (the parent's own device, not the child's). A page that
|
|
580
|
+
* does have a live widget instance can listen for this to react (e.g. re-show the banner/modal for
|
|
581
|
+
* the real consent choice); what "resolved" should actually do to consent state is host-defined. */
|
|
582
|
+
interface ParentalConsentGrantedDetail {
|
|
583
|
+
visitorId: string;
|
|
584
|
+
profileId: string;
|
|
585
|
+
}
|
|
586
|
+
/** Dispatched by `forgetMe()` right before the erasure call goes out — the hook for a host app
|
|
587
|
+
* to kick off its own identity-verified erasure workflow across other systems (CRM, DMP,
|
|
588
|
+
* analytics). The CMP itself only ever erases its own consent record; see the server-side
|
|
589
|
+
* `consent.erased` eventBus event (fired by `DELETE /consent/:visitorId`) for the same hook on
|
|
590
|
+
* the backend. See the "Right to erasure" guide for the full picture. */
|
|
591
|
+
interface ForgetMeRequestedDetail {
|
|
592
|
+
visitorId: string;
|
|
593
|
+
profileId: string;
|
|
594
|
+
timestamp: number;
|
|
595
|
+
}
|
|
596
|
+
/** Dispatched by `forgetMe()` after the consent record has been erased and the banner/age-gate
|
|
597
|
+
* has been re-prompted (see `reConsent()`, which `forgetMe()` wraps). */
|
|
598
|
+
interface ForgottenDetail {
|
|
599
|
+
visitorId: string;
|
|
600
|
+
profileId: string;
|
|
601
|
+
timestamp: number;
|
|
602
|
+
}
|
|
603
|
+
type ConsentEvent = BannerInitializedDetail | BannerVisibilityDetail | ModalVisibilityDetail | ConsentBeingSubmitted | ConsentSubmittedDetail | ParentalConsentRequiredDetail | ParentalConsentGrantedDetail | ForgetMeRequestedDetail | ForgottenDetail;
|
|
397
604
|
|
|
398
605
|
/**
|
|
399
606
|
* Main entry point for the Consenti widget.
|
|
@@ -449,6 +656,8 @@ declare class ConsentiSetup implements ConsentiWidgetAPI {
|
|
|
449
656
|
private _bannerMounted;
|
|
450
657
|
/** Active focus trap keydown listener — removed when modal closes. */
|
|
451
658
|
private _focusTrapListener;
|
|
659
|
+
/** Inbound `consenti:listener:identify` window listener — installed once per init(), removed on destroy(). */
|
|
660
|
+
private _identifyListener;
|
|
452
661
|
/** Maps original handler functions to their DOM-wrapped listeners for on/off bookkeeping. */
|
|
453
662
|
private _eventHandlers;
|
|
454
663
|
/** `core` defaulted to `{}` in the constructor below — every one of its own fields is
|
|
@@ -465,6 +674,21 @@ declare class ConsentiSetup implements ConsentiWidgetAPI {
|
|
|
465
674
|
*/
|
|
466
675
|
constructor(config: ConsentiConfig);
|
|
467
676
|
private profileId;
|
|
677
|
+
/** Patches `base` with `complianceGroupsOverride[base.complianceGroup]`, if both exist — the
|
|
678
|
+
* per-group counterpart to `profileOverride`. Lets an author supply different text/buttons/
|
|
679
|
+
* cookies per compliance group (built-in or custom) without authoring a separate profile for
|
|
680
|
+
* each one. Applied before `profileOverride`, which still always wins as the final catch-all. */
|
|
681
|
+
private applyComplianceGroupOverride;
|
|
682
|
+
/**
|
|
683
|
+
* Whether `window.__tcfapi`/`window.__gpp` should stay uninstalled because the corresponding
|
|
684
|
+
* server-side registration (`compliance.tcf`/`compliance.gpp`) is unconfirmed (cmpId/cmpVersion
|
|
685
|
+
* changed since the dashboard's confirmation checkbox was last checked, or never confirmed).
|
|
686
|
+
* Standalone (no-backend) deployments have no governance layer to check against, so this always
|
|
687
|
+
* resolves `false` there — the client-side config is used as configured, same as before this
|
|
688
|
+
* feature existed. A network failure fails closed (`true`) rather than assuming the
|
|
689
|
+
* unverifiable state is fine.
|
|
690
|
+
*/
|
|
691
|
+
private isRegistrationBlocked;
|
|
468
692
|
/**
|
|
469
693
|
* Starts widget initialisation. Called automatically unless `autoInit: false` is set.
|
|
470
694
|
* Can be called explicitly after construction when `autoInit: false`, or after `destroy()`
|
|
@@ -478,7 +702,7 @@ declare class ConsentiSetup implements ConsentiWidgetAPI {
|
|
|
478
702
|
* `resolveAgeGate()`, then resume here with `hasExisting` fixed at `false`.
|
|
479
703
|
*/
|
|
480
704
|
private continueInit;
|
|
481
|
-
/** Mounts the age-gate prompt (`
|
|
705
|
+
/** Mounts the age-gate prompt (`profile.ageGate`) in place of the normal banner flow. */
|
|
482
706
|
private showAgeGate;
|
|
483
707
|
/**
|
|
484
708
|
* Handles the visitor's age-gate answer.
|
|
@@ -501,13 +725,35 @@ declare class ConsentiSetup implements ConsentiWidgetAPI {
|
|
|
501
725
|
* a resolved profile to read consent from.
|
|
502
726
|
*/
|
|
503
727
|
private finishInit;
|
|
728
|
+
/** Installs the inbound `consenti:listener:identify` window listener — the event-driven
|
|
729
|
+
* counterpart to `setUserId()`. Removes any previously-installed listener first so repeated
|
|
730
|
+
* `init()` calls (e.g. from `switchLocale()`) don't stack up duplicate listeners. */
|
|
731
|
+
private _installIdentifyListener;
|
|
732
|
+
/** Returns the current logged-in application user ID, or `null` for an anonymous visitor. */
|
|
733
|
+
getUserId(): string | null;
|
|
734
|
+
/**
|
|
735
|
+
* Sets the logged-in application user ID (`null` for anonymous/logout). If a stored consent
|
|
736
|
+
* record exists and its user differs from `userId`, this is treated as a different data
|
|
737
|
+
* subject on a shared device: by default it reconsents (deletes the existing record and
|
|
738
|
+
* re-shows the banner) and logs a warning. Pass `reConsent: false` to just update the identity
|
|
739
|
+
* without prompting again (still logs the warning). No-ops entirely — no warning, no
|
|
740
|
+
* reconsent — when there is no prior consent record to compare against (true first-time visitor).
|
|
741
|
+
*/
|
|
742
|
+
setUserId(userId: string | null, reConsent?: boolean): Promise<void>;
|
|
743
|
+
/**
|
|
744
|
+
* Snapshot of the current visitor's identity. `visitorId` is the stable per-browser ID —
|
|
745
|
+
* `null` until a consent decision has actually happened, since this never mints one just to
|
|
746
|
+
* answer the call (see `getOrCreateVisitorId()`). `type` is `'authenticated'` whenever a
|
|
747
|
+
* `userId` is set (via `setUserId()` or `core.userId`), `'anonymous'` otherwise.
|
|
748
|
+
*/
|
|
749
|
+
getVisitor(): VisitorIdentity;
|
|
504
750
|
/** Sets the `dir` attribute on the root element from `core.dir` (default `'auto'`, derived from `core.locale`). */
|
|
505
751
|
private applyDirection;
|
|
506
752
|
/** Applies the `consenti-root--dark` class based on config or profile flag. */
|
|
507
753
|
private applyDarkMode;
|
|
508
754
|
/** Applies `consenti--enhanced-a11y` class when `profile.enhanceAccessibility` is set. */
|
|
509
755
|
private applyAccessibility;
|
|
510
|
-
/** Builds and appends the metadata footer strip to
|
|
756
|
+
/** Builds and appends the metadata footer strip to modal container. */
|
|
511
757
|
private _appendMetaFooter;
|
|
512
758
|
/**
|
|
513
759
|
* Injects a `<style>` element into the root for `stackButtonsOnBreakpoint`.
|
|
@@ -551,8 +797,16 @@ declare class ConsentiSetup implements ConsentiWidgetAPI {
|
|
|
551
797
|
* Pass `type` to get a vendor-ready object instead of the raw Consenti format.
|
|
552
798
|
* Always returns `null` during SSR or when no consent has been saved.
|
|
553
799
|
*
|
|
554
|
-
* @param type -
|
|
555
|
-
*
|
|
800
|
+
* @param type - Output format:
|
|
801
|
+
* - omit / `'default'` → raw ConsentValue, keyed by every cookie parameter ID in the profile
|
|
802
|
+
* - `'purpose'` → consent per the fixed CookiePurpose taxonomy (necessary/functional/preferences/analytics/marketing)
|
|
803
|
+
* - `'category'` → consent per the tenant's own authored preference-modal category, keyed by category ID
|
|
804
|
+
* ('granted' only when every member parameter is granted; 'denied'/'objected' otherwise)
|
|
805
|
+
* - `'google-gtm'` → Google Consent Mode v2 keys + ads_data_redaction, url_passthrough
|
|
806
|
+
* - `'adobe'` → { analytics, target, manager, optimizer }
|
|
807
|
+
* - `'meta'` → { pixel, api, plugins, facebookLogin }
|
|
808
|
+
* - `'microsoft-clarity'` → { session, heatmaps, performance }
|
|
809
|
+
* - `'twilio-segment'` → { identify, page, track, group, alias }
|
|
556
810
|
*/
|
|
557
811
|
getConsent(): ConsentValue | null;
|
|
558
812
|
getConsent(type: ConsentType): Record<string, string> | null;
|
|
@@ -644,8 +898,30 @@ declare class ConsentiSetup implements ConsentiWidgetAPI {
|
|
|
644
898
|
* method so callers do not need to coordinate the async deletion with the banner display.
|
|
645
899
|
*
|
|
646
900
|
* Use this to power "Review my consent" links in footers or privacy dashboards.
|
|
901
|
+
*
|
|
902
|
+
* @param resetAgeGate - When `true` (default) and the profile has `ageGate.enabled`, the
|
|
903
|
+
* age-gate prompt is shown again instead of jumping straight to the
|
|
904
|
+
* banner — mirroring the original first-visit flow. Pass `false` to
|
|
905
|
+
* skip it and go straight to the banner, keeping the visitor's prior
|
|
906
|
+
* age-gate answer.
|
|
647
907
|
*/
|
|
648
|
-
reConsent(): Promise<void>;
|
|
908
|
+
reConsent(resetAgeGate?: boolean): Promise<void>;
|
|
909
|
+
/**
|
|
910
|
+
* Self-service erasure entry point — GDPR Art. 17 / CCPA-CPRA / LGPD Art. 18 and equivalent
|
|
911
|
+
* "right to be forgotten" rights, exercised from the widget itself. Wraps `reConsent()` (same
|
|
912
|
+
* erase-then-reprompt behavior) with `consenti:forgetMeRequested` / `consenti:forgotten`
|
|
913
|
+
* dispatched around it, so a host app can hook its own identity-verified erasure workflow
|
|
914
|
+
* across other systems (CRM, DMP, analytics) — the CMP itself only ever erases its own consent
|
|
915
|
+
* record. See the "Right to erasure" guide for the full picture, including the server-side
|
|
916
|
+
* `consent:erased` eventBus event fired by `DELETE /consent/:visitorId`.
|
|
917
|
+
*
|
|
918
|
+
* Powers the preference modal's "Forget me" button (`preferenceModal.showForgetMe`, only
|
|
919
|
+
* rendered when the visitor already has a stored consent decision). Also callable directly —
|
|
920
|
+
* e.g. `widget.forgetMe()` from a custom footer link or privacy-settings page.
|
|
921
|
+
*
|
|
922
|
+
* @param resetAgeGate - Forwarded to `reConsent()` — see its docs.
|
|
923
|
+
*/
|
|
924
|
+
forgetMe(resetAgeGate?: boolean): Promise<void>;
|
|
649
925
|
/**
|
|
650
926
|
* Returns the fully resolved profile for the current session, or `null` during the
|
|
651
927
|
* async init phase (before the profile has been fetched/resolved).
|
|
@@ -824,14 +1100,21 @@ declare function useConsent(): {
|
|
|
824
1100
|
denyAll: (includingMandatory?: boolean) => Promise<void>;
|
|
825
1101
|
/** Saves the given partial consent map. */
|
|
826
1102
|
submitConsent: (c: Partial<ConsentValue>) => Promise<void | ConsentDbRecord>;
|
|
827
|
-
/** Deletes the current consent record and re-shows the banner.
|
|
828
|
-
|
|
1103
|
+
/** Deletes the current consent record and re-shows the banner. Pass `false` to skip
|
|
1104
|
+
* re-showing the age-gate prompt (if the profile has one) and go straight to the banner. */
|
|
1105
|
+
reConsent: (resetAgeGate?: boolean) => Promise<void>;
|
|
829
1106
|
/** Returns `true` if the given cookie ID is `'granted'`. */
|
|
830
1107
|
isCookieGranted: (id: string) => boolean;
|
|
831
1108
|
/** Returns `true` if every cookie in the given category is `'granted'`. */
|
|
832
1109
|
isCategoryGranted: (id: string) => boolean;
|
|
833
1110
|
/** Switches the active locale and re-renders the banner and modal. */
|
|
834
1111
|
switchLocale: (locale: string) => void | undefined;
|
|
1112
|
+
/** Returns the current logged-in application user ID, or `null` if anonymous. */
|
|
1113
|
+
getUserId: () => string | null;
|
|
1114
|
+
/** Sets the logged-in application user ID; reconsents by default when it changes. */
|
|
1115
|
+
setUserId: (userId: string | null, reConsent?: boolean) => Promise<void>;
|
|
1116
|
+
/** Snapshot of the current visitor's identity (`visitorId`, `type`, `userId`). */
|
|
1117
|
+
getVisitor: () => VisitorIdentity;
|
|
835
1118
|
};
|
|
836
1119
|
|
|
837
1120
|
export { setConsentiWidget, useConsent };
|