@consenti/ui 0.5.0 → 0.6.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 CHANGED
@@ -183,14 +183,17 @@ const widget = new ConsentiSetup({
183
183
 
184
184
  // Client-side geo resolver (used only when api.enabled = false)
185
185
  // 'default' → browser timezone + navigator.language heuristic (built-in, zero deps)
186
- // WidgetCountryResolverFn → custom async function: () => Promise<{ country, region, confidence }>
186
+ // WidgetCountryResolverFn → custom async function: ({ timezone, language, languages, locale }) => Promise<{ country, region, confidence }>
187
187
  geoDataProvider: 'default',
188
188
 
189
189
  // Only meaningful when api.enabled = false (ignored, with a warning, otherwise — the server
190
190
  // resolves the group in that mode). Only overrides country→group mapping; country/region
191
191
  // detection above always uses the embedded geo data.
192
192
  // 'default' → embedded map (default) | a URL string (fetched; the browser's own HTTP cache
193
- // honors whatever Cache-Control/ETag the response sends) | an inline ComplianceMapData object
193
+ // honors whatever Cache-Control/ETag the response sends) | an inline ComplianceMapData object.
194
+ // A country the map doesn't list falls back to the embedded mapping, unless the document sets
195
+ // `override: true` — then it gets the strictest group ('opt-in'). Unlike the server, an omitted
196
+ // `override` is NOT true here: widget maps have always merged over the embedded mapping.
194
197
  complianceMap: 'default',
195
198
 
196
199
  // TCF (IAB Transparency & Consent Framework) client stub (optional) — see "TCF" section below
@@ -64,6 +64,10 @@ type ComplianceType = 'auto' | ComplianceGroupId | (string & {}) | Symbol;
64
64
 
65
65
  interface ComplianceMapData {
66
66
  version: string;
67
+ /** `true` (default): this map replaces the embedded one entirely, so only the countries listed here
68
+ * resolve (server side). `false`: `countries` is merged over the embedded map — a listed country
69
+ * replaces its embedded entry wholesale, every unlisted country keeps its built-in mapping. */
70
+ override?: boolean;
67
71
  countries: Record<string, CountryComplianceEntry>;
68
72
  }
69
73
  interface CountryComplianceEntry {
@@ -83,6 +87,9 @@ interface ConsentDbRecord {
83
87
  tenantId: string;
84
88
  visitorId: string;
85
89
  profileId: string;
90
+ /** The profile's `version` when this consent was last given — with `profileId`, pins the exact
91
+ * on-disk snapshot (the banner text the visitor saw). Absent on records from before it was tracked. */
92
+ profileVersion?: number;
86
93
  locale: string;
87
94
  consentJson: ConsentValue;
88
95
  gpcDetected: boolean;
@@ -281,7 +288,12 @@ interface ResolvedProfile {
281
288
  /** Apply WCAG 2.1 AA accessibility enhancements to the widget. */
282
289
  enhanceAccessibility?: boolean;
283
290
  }
284
- type WidgetCountryResolverFn = () => Promise<{
291
+ type WidgetCountryResolverFn = (hints: {
292
+ timezone: string;
293
+ language: string;
294
+ languages: string[];
295
+ locale: string;
296
+ }) => Promise<{
285
297
  country: string | null;
286
298
  region: string | null;
287
299
  confidence: number;
@@ -340,8 +352,11 @@ interface ComplianceWidgetConfig {
340
352
  * document from (the browser's own HTTP cache honors whatever `Cache-Control`/`ETag` the
341
353
  * response sends — no custom caching here), or an inline operator-supplied `ComplianceMapData`
342
354
  * object. Invalid data from either a URL or an object logs a warning and falls back to
343
- * `'default'`. Only overrides the country→group mapping — country/region detection itself
344
- * always uses the embedded geo data. */
355
+ * `'default'`. Only overrides the country→group mapping — country/region detection itself always
356
+ * uses the embedded geo data. A country the map doesn't list falls back to the embedded mapping
357
+ * unless the document sets `override: true` (then it gets the strictest group, `'opt-in'`).
358
+ * Unlike the server, an omitted `override` is NOT `true` here: widget maps have always merged
359
+ * over the embedded mapping, and that stays the default. */
345
360
  complianceMap?: 'default' | string | ComplianceMapData;
346
361
  tcf?: TcfWidgetConfig;
347
362
  gpp?: GppWidgetConfig;
package/dist/angular.d.ts CHANGED
@@ -64,6 +64,10 @@ type ComplianceType = 'auto' | ComplianceGroupId | (string & {}) | Symbol;
64
64
 
65
65
  interface ComplianceMapData {
66
66
  version: string;
67
+ /** `true` (default): this map replaces the embedded one entirely, so only the countries listed here
68
+ * resolve (server side). `false`: `countries` is merged over the embedded map — a listed country
69
+ * replaces its embedded entry wholesale, every unlisted country keeps its built-in mapping. */
70
+ override?: boolean;
67
71
  countries: Record<string, CountryComplianceEntry>;
68
72
  }
69
73
  interface CountryComplianceEntry {
@@ -83,6 +87,9 @@ interface ConsentDbRecord {
83
87
  tenantId: string;
84
88
  visitorId: string;
85
89
  profileId: string;
90
+ /** The profile's `version` when this consent was last given — with `profileId`, pins the exact
91
+ * on-disk snapshot (the banner text the visitor saw). Absent on records from before it was tracked. */
92
+ profileVersion?: number;
86
93
  locale: string;
87
94
  consentJson: ConsentValue;
88
95
  gpcDetected: boolean;
@@ -281,7 +288,12 @@ interface ResolvedProfile {
281
288
  /** Apply WCAG 2.1 AA accessibility enhancements to the widget. */
282
289
  enhanceAccessibility?: boolean;
283
290
  }
284
- type WidgetCountryResolverFn = () => Promise<{
291
+ type WidgetCountryResolverFn = (hints: {
292
+ timezone: string;
293
+ language: string;
294
+ languages: string[];
295
+ locale: string;
296
+ }) => Promise<{
285
297
  country: string | null;
286
298
  region: string | null;
287
299
  confidence: number;
@@ -340,8 +352,11 @@ interface ComplianceWidgetConfig {
340
352
  * document from (the browser's own HTTP cache honors whatever `Cache-Control`/`ETag` the
341
353
  * response sends — no custom caching here), or an inline operator-supplied `ComplianceMapData`
342
354
  * object. Invalid data from either a URL or an object logs a warning and falls back to
343
- * `'default'`. Only overrides the country→group mapping — country/region detection itself
344
- * always uses the embedded geo data. */
355
+ * `'default'`. Only overrides the country→group mapping — country/region detection itself always
356
+ * uses the embedded geo data. A country the map doesn't list falls back to the embedded mapping
357
+ * unless the document sets `override: true` (then it gets the strictest group, `'opt-in'`).
358
+ * Unlike the server, an omitted `override` is NOT `true` here: widget maps have always merged
359
+ * over the embedded mapping, and that stays the default. */
345
360
  complianceMap?: 'default' | string | ComplianceMapData;
346
361
  tcf?: TcfWidgetConfig;
347
362
  gpp?: GppWidgetConfig;
package/dist/index.d.ts CHANGED
@@ -64,6 +64,10 @@ type ComplianceType = 'auto' | ComplianceGroupId | (string & {}) | Symbol;
64
64
 
65
65
  interface ComplianceMapData {
66
66
  version: string;
67
+ /** `true` (default): this map replaces the embedded one entirely, so only the countries listed here
68
+ * resolve (server side). `false`: `countries` is merged over the embedded map — a listed country
69
+ * replaces its embedded entry wholesale, every unlisted country keeps its built-in mapping. */
70
+ override?: boolean;
67
71
  countries: Record<string, CountryComplianceEntry>;
68
72
  }
69
73
  interface CountryComplianceEntry {
@@ -83,6 +87,9 @@ interface ConsentDbRecord {
83
87
  tenantId: string;
84
88
  visitorId: string;
85
89
  profileId: string;
90
+ /** The profile's `version` when this consent was last given — with `profileId`, pins the exact
91
+ * on-disk snapshot (the banner text the visitor saw). Absent on records from before it was tracked. */
92
+ profileVersion?: number;
86
93
  locale: string;
87
94
  consentJson: ConsentValue;
88
95
  gpcDetected: boolean;
@@ -401,7 +408,12 @@ interface ResolvedProfile {
401
408
  /** Apply WCAG 2.1 AA accessibility enhancements to the widget. */
402
409
  enhanceAccessibility?: boolean;
403
410
  }
404
- type WidgetCountryResolverFn = () => Promise<{
411
+ type WidgetCountryResolverFn = (hints: {
412
+ timezone: string;
413
+ language: string;
414
+ languages: string[];
415
+ locale: string;
416
+ }) => Promise<{
405
417
  country: string | null;
406
418
  region: string | null;
407
419
  confidence: number;
@@ -460,8 +472,11 @@ interface ComplianceWidgetConfig {
460
472
  * document from (the browser's own HTTP cache honors whatever `Cache-Control`/`ETag` the
461
473
  * response sends — no custom caching here), or an inline operator-supplied `ComplianceMapData`
462
474
  * object. Invalid data from either a URL or an object logs a warning and falls back to
463
- * `'default'`. Only overrides the country→group mapping — country/region detection itself
464
- * always uses the embedded geo data. */
475
+ * `'default'`. Only overrides the country→group mapping — country/region detection itself always
476
+ * uses the embedded geo data. A country the map doesn't list falls back to the embedded mapping
477
+ * unless the document sets `override: true` (then it gets the strictest group, `'opt-in'`).
478
+ * Unlike the server, an omitted `override` is NOT `true` here: widget maps have always merged
479
+ * over the embedded mapping, and that stays the default. */
465
480
  complianceMap?: 'default' | string | ComplianceMapData;
466
481
  tcf?: TcfWidgetConfig;
467
482
  gpp?: GppWidgetConfig;