@walkeros/web-source-cmp-usercentrics 3.4.1 → 3.4.2

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/dist/index.d.mts CHANGED
@@ -21,6 +21,93 @@ interface UsercentricsEventDetail {
21
21
  declare global {
22
22
  interface WindowEventMap {
23
23
  ucEvent: CustomEvent<UsercentricsEventDetail>;
24
+ UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
25
+ }
26
+ }
27
+ /**
28
+ * Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
29
+ * Only the fields we use are typed — minimal surface, not a full V2 API mirror.
30
+ */
31
+ interface UsercentricsV2Service {
32
+ /** Category slug: 'essential' | 'functional' | 'marketing' | custom */
33
+ categorySlug: string;
34
+ /** Consent state for this service */
35
+ consent: {
36
+ status: boolean;
37
+ };
38
+ }
39
+ /**
40
+ * Usercentrics V2 window API (`window.UC_UI`).
41
+ *
42
+ * Methods are synchronous (unlike V3). All methods are optional because
43
+ * Usercentrics does not guarantee every deployment exposes every method.
44
+ */
45
+ interface UsercentricsV2Api {
46
+ isInitialized?: () => boolean;
47
+ getServicesBaseInfo?: () => UsercentricsV2Service[];
48
+ areAllConsentsAccepted?: () => boolean;
49
+ }
50
+ /**
51
+ * Usercentrics V3 category state. The SDK may add future states; we handle
52
+ * unknowns conservatively as non-accepting.
53
+ */
54
+ type UsercentricsV3CategoryState = 'ALL_ACCEPTED' | 'ALL_DENIED' | 'SOME_ACCEPTED' | 'NO_STATE' | string;
55
+ /**
56
+ * Minimal V3 CategoryData — only fields the adapter reads.
57
+ */
58
+ interface UsercentricsV3CategoryData {
59
+ state: UsercentricsV3CategoryState;
60
+ name: string;
61
+ }
62
+ /**
63
+ * Minimal V3 ConsentData — only the `type` field is used to distinguish
64
+ * explicit vs implicit consent. Other fields (status, version, etc.) exist on
65
+ * the real SDK but are not read by this adapter.
66
+ */
67
+ interface UsercentricsV3ConsentData {
68
+ type: 'EXPLICIT' | 'IMPLICIT' | string;
69
+ }
70
+ /**
71
+ * Minimal V3 ConsentDetails — only the fields the adapter reads.
72
+ * The real SDK also exposes `services`, but the adapter currently operates
73
+ * at category level only.
74
+ */
75
+ interface UsercentricsV3ConsentDetails {
76
+ consent: UsercentricsV3ConsentData;
77
+ categories: Record<string, UsercentricsV3CategoryData>;
78
+ }
79
+ /**
80
+ * Usercentrics V3 window API (`window.__ucCmp`).
81
+ *
82
+ * Only the methods this adapter calls are typed — the real SDK surface is
83
+ * much wider but we intentionally keep this narrow.
84
+ */
85
+ interface UsercentricsV3Api {
86
+ isInitialized: () => Promise<boolean>;
87
+ getConsentDetails: () => Promise<UsercentricsV3ConsentDetails>;
88
+ }
89
+ /**
90
+ * V3 CMP event detail. Fired on `UC_UI_CMP_EVENT` (or custom name).
91
+ * `source: 'CMP'` + a decision `type` tells us a user action has been taken.
92
+ */
93
+ interface UsercentricsV3CmpEventDetail {
94
+ source?: string;
95
+ type?: string;
96
+ }
97
+ declare global {
98
+ interface Window {
99
+ /**
100
+ * Usercentrics V2 CMP API. Attached once the V2 Browser SDK is
101
+ * initialized. Optional because the SDK loads asynchronously — guard
102
+ * with a truthiness check before access.
103
+ */
104
+ UC_UI?: UsercentricsV2Api;
105
+ /**
106
+ * Usercentrics V3 CMP API. Attached once the V3 Browser SDK is
107
+ * initialized. Optional because the SDK loads asynchronously — guard
108
+ * with a truthiness check before access.
109
+ */
110
+ __ucCmp?: UsercentricsV3Api;
24
111
  }
25
112
  }
26
113
  /**
@@ -41,8 +128,9 @@ interface Settings {
41
128
  * Values: walkerOS consent group names
42
129
  *
43
130
  * Applied in both group-level and service-level consent modes.
44
- * When multiple source categories map to the same group, OR logic applies:
45
- * if ANY source category is true, the target group is true.
131
+ * When multiple source categories map to the same group, strict AND logic
132
+ * applies: ALL contributing source categories must be true for the target
133
+ * group to be true. Any single false denies consent.
46
134
  *
47
135
  * Default: {} (pass through category names as-is)
48
136
  */
@@ -55,6 +143,28 @@ interface Settings {
55
143
  * Default: true
56
144
  */
57
145
  explicitOnly?: boolean;
146
+ /**
147
+ * Which Usercentrics API to target.
148
+ * - 'auto' (default): detect at init. If `window.__ucCmp` is present, use V3.
149
+ * If only `window.UC_UI` is present, use V2. If neither is present yet,
150
+ * register listeners for both so late-loading CMPs are still caught.
151
+ * - 'v2': force legacy `window.UC_UI` path.
152
+ * - 'v3': force current `window.__ucCmp` path.
153
+ */
154
+ apiVersion?: 'auto' | 'v2' | 'v3';
155
+ /**
156
+ * V3 window event name to listen for consent changes.
157
+ *
158
+ * Usercentrics V3 hardcodes its built-in event names (`UC_UI_CMP_EVENT`,
159
+ * `UC_UI_INITIALIZED`, `UC_UI_VIEW_CHANGED`, `UC_CONSENT`) — they cannot be
160
+ * renamed. However, the Usercentrics admin dashboard (Implementation >
161
+ * Data Layer & Events) lets admins configure an ADDITIONAL custom window
162
+ * event. Use this setting to point at that custom event name if
163
+ * configured; otherwise leave as default.
164
+ *
165
+ * Default: 'UC_UI_CMP_EVENT'
166
+ */
167
+ v3EventName?: string;
58
168
  }
59
169
  /**
60
170
  * User input settings (all optional)
@@ -92,8 +202,16 @@ type index_Push = Push;
92
202
  type index_Settings = Settings;
93
203
  type index_Types = Types;
94
204
  type index_UsercentricsEventDetail = UsercentricsEventDetail;
205
+ type index_UsercentricsV2Api = UsercentricsV2Api;
206
+ type index_UsercentricsV2Service = UsercentricsV2Service;
207
+ type index_UsercentricsV3Api = UsercentricsV3Api;
208
+ type index_UsercentricsV3CategoryData = UsercentricsV3CategoryData;
209
+ type index_UsercentricsV3CategoryState = UsercentricsV3CategoryState;
210
+ type index_UsercentricsV3CmpEventDetail = UsercentricsV3CmpEventDetail;
211
+ type index_UsercentricsV3ConsentData = UsercentricsV3ConsentData;
212
+ type index_UsercentricsV3ConsentDetails = UsercentricsV3ConsentDetails;
95
213
  declare namespace index {
96
- export type { index_Config as Config, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Push as Push, index_Settings as Settings, index_Types as Types, index_UsercentricsEventDetail as UsercentricsEventDetail };
214
+ export type { index_Config as Config, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Push as Push, index_Settings as Settings, index_Types as Types, index_UsercentricsEventDetail as UsercentricsEventDetail, index_UsercentricsV2Api as UsercentricsV2Api, index_UsercentricsV2Service as UsercentricsV2Service, index_UsercentricsV3Api as UsercentricsV3Api, index_UsercentricsV3CategoryData as UsercentricsV3CategoryData, index_UsercentricsV3CategoryState as UsercentricsV3CategoryState, index_UsercentricsV3CmpEventDetail as UsercentricsV3CmpEventDetail, index_UsercentricsV3ConsentData as UsercentricsV3ConsentData, index_UsercentricsV3ConsentDetails as UsercentricsV3ConsentDetails };
97
215
  }
98
216
 
99
217
  /**
@@ -199,8 +317,10 @@ declare const trigger: (input: unknown, env: Record<string, unknown>) => void |
199
317
  /**
200
318
  * Usercentrics consent management source for walkerOS.
201
319
  *
202
- * This source listens to Usercentrics CMP events and translates
203
- * consent states to walkerOS consent commands.
320
+ * Listens to Usercentrics CMP events and translates consent states to
321
+ * walkerOS consent commands. Supports both the legacy V2 API
322
+ * (`window.UC_UI` + `ucEvent`) and the current V3 API
323
+ * (`window.__ucCmp` + `UC_UI_CMP_EVENT`).
204
324
  *
205
325
  * @example
206
326
  * ```typescript
package/dist/index.d.ts CHANGED
@@ -21,6 +21,93 @@ interface UsercentricsEventDetail {
21
21
  declare global {
22
22
  interface WindowEventMap {
23
23
  ucEvent: CustomEvent<UsercentricsEventDetail>;
24
+ UC_UI_CMP_EVENT: CustomEvent<UsercentricsV3CmpEventDetail>;
25
+ }
26
+ }
27
+ /**
28
+ * Usercentrics V2 service info shape returned by `UC_UI.getServicesBaseInfo()`.
29
+ * Only the fields we use are typed — minimal surface, not a full V2 API mirror.
30
+ */
31
+ interface UsercentricsV2Service {
32
+ /** Category slug: 'essential' | 'functional' | 'marketing' | custom */
33
+ categorySlug: string;
34
+ /** Consent state for this service */
35
+ consent: {
36
+ status: boolean;
37
+ };
38
+ }
39
+ /**
40
+ * Usercentrics V2 window API (`window.UC_UI`).
41
+ *
42
+ * Methods are synchronous (unlike V3). All methods are optional because
43
+ * Usercentrics does not guarantee every deployment exposes every method.
44
+ */
45
+ interface UsercentricsV2Api {
46
+ isInitialized?: () => boolean;
47
+ getServicesBaseInfo?: () => UsercentricsV2Service[];
48
+ areAllConsentsAccepted?: () => boolean;
49
+ }
50
+ /**
51
+ * Usercentrics V3 category state. The SDK may add future states; we handle
52
+ * unknowns conservatively as non-accepting.
53
+ */
54
+ type UsercentricsV3CategoryState = 'ALL_ACCEPTED' | 'ALL_DENIED' | 'SOME_ACCEPTED' | 'NO_STATE' | string;
55
+ /**
56
+ * Minimal V3 CategoryData — only fields the adapter reads.
57
+ */
58
+ interface UsercentricsV3CategoryData {
59
+ state: UsercentricsV3CategoryState;
60
+ name: string;
61
+ }
62
+ /**
63
+ * Minimal V3 ConsentData — only the `type` field is used to distinguish
64
+ * explicit vs implicit consent. Other fields (status, version, etc.) exist on
65
+ * the real SDK but are not read by this adapter.
66
+ */
67
+ interface UsercentricsV3ConsentData {
68
+ type: 'EXPLICIT' | 'IMPLICIT' | string;
69
+ }
70
+ /**
71
+ * Minimal V3 ConsentDetails — only the fields the adapter reads.
72
+ * The real SDK also exposes `services`, but the adapter currently operates
73
+ * at category level only.
74
+ */
75
+ interface UsercentricsV3ConsentDetails {
76
+ consent: UsercentricsV3ConsentData;
77
+ categories: Record<string, UsercentricsV3CategoryData>;
78
+ }
79
+ /**
80
+ * Usercentrics V3 window API (`window.__ucCmp`).
81
+ *
82
+ * Only the methods this adapter calls are typed — the real SDK surface is
83
+ * much wider but we intentionally keep this narrow.
84
+ */
85
+ interface UsercentricsV3Api {
86
+ isInitialized: () => Promise<boolean>;
87
+ getConsentDetails: () => Promise<UsercentricsV3ConsentDetails>;
88
+ }
89
+ /**
90
+ * V3 CMP event detail. Fired on `UC_UI_CMP_EVENT` (or custom name).
91
+ * `source: 'CMP'` + a decision `type` tells us a user action has been taken.
92
+ */
93
+ interface UsercentricsV3CmpEventDetail {
94
+ source?: string;
95
+ type?: string;
96
+ }
97
+ declare global {
98
+ interface Window {
99
+ /**
100
+ * Usercentrics V2 CMP API. Attached once the V2 Browser SDK is
101
+ * initialized. Optional because the SDK loads asynchronously — guard
102
+ * with a truthiness check before access.
103
+ */
104
+ UC_UI?: UsercentricsV2Api;
105
+ /**
106
+ * Usercentrics V3 CMP API. Attached once the V3 Browser SDK is
107
+ * initialized. Optional because the SDK loads asynchronously — guard
108
+ * with a truthiness check before access.
109
+ */
110
+ __ucCmp?: UsercentricsV3Api;
24
111
  }
25
112
  }
26
113
  /**
@@ -41,8 +128,9 @@ interface Settings {
41
128
  * Values: walkerOS consent group names
42
129
  *
43
130
  * Applied in both group-level and service-level consent modes.
44
- * When multiple source categories map to the same group, OR logic applies:
45
- * if ANY source category is true, the target group is true.
131
+ * When multiple source categories map to the same group, strict AND logic
132
+ * applies: ALL contributing source categories must be true for the target
133
+ * group to be true. Any single false denies consent.
46
134
  *
47
135
  * Default: {} (pass through category names as-is)
48
136
  */
@@ -55,6 +143,28 @@ interface Settings {
55
143
  * Default: true
56
144
  */
57
145
  explicitOnly?: boolean;
146
+ /**
147
+ * Which Usercentrics API to target.
148
+ * - 'auto' (default): detect at init. If `window.__ucCmp` is present, use V3.
149
+ * If only `window.UC_UI` is present, use V2. If neither is present yet,
150
+ * register listeners for both so late-loading CMPs are still caught.
151
+ * - 'v2': force legacy `window.UC_UI` path.
152
+ * - 'v3': force current `window.__ucCmp` path.
153
+ */
154
+ apiVersion?: 'auto' | 'v2' | 'v3';
155
+ /**
156
+ * V3 window event name to listen for consent changes.
157
+ *
158
+ * Usercentrics V3 hardcodes its built-in event names (`UC_UI_CMP_EVENT`,
159
+ * `UC_UI_INITIALIZED`, `UC_UI_VIEW_CHANGED`, `UC_CONSENT`) — they cannot be
160
+ * renamed. However, the Usercentrics admin dashboard (Implementation >
161
+ * Data Layer & Events) lets admins configure an ADDITIONAL custom window
162
+ * event. Use this setting to point at that custom event name if
163
+ * configured; otherwise leave as default.
164
+ *
165
+ * Default: 'UC_UI_CMP_EVENT'
166
+ */
167
+ v3EventName?: string;
58
168
  }
59
169
  /**
60
170
  * User input settings (all optional)
@@ -92,8 +202,16 @@ type index_Push = Push;
92
202
  type index_Settings = Settings;
93
203
  type index_Types = Types;
94
204
  type index_UsercentricsEventDetail = UsercentricsEventDetail;
205
+ type index_UsercentricsV2Api = UsercentricsV2Api;
206
+ type index_UsercentricsV2Service = UsercentricsV2Service;
207
+ type index_UsercentricsV3Api = UsercentricsV3Api;
208
+ type index_UsercentricsV3CategoryData = UsercentricsV3CategoryData;
209
+ type index_UsercentricsV3CategoryState = UsercentricsV3CategoryState;
210
+ type index_UsercentricsV3CmpEventDetail = UsercentricsV3CmpEventDetail;
211
+ type index_UsercentricsV3ConsentData = UsercentricsV3ConsentData;
212
+ type index_UsercentricsV3ConsentDetails = UsercentricsV3ConsentDetails;
95
213
  declare namespace index {
96
- export type { index_Config as Config, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Push as Push, index_Settings as Settings, index_Types as Types, index_UsercentricsEventDetail as UsercentricsEventDetail };
214
+ export type { index_Config as Config, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Push as Push, index_Settings as Settings, index_Types as Types, index_UsercentricsEventDetail as UsercentricsEventDetail, index_UsercentricsV2Api as UsercentricsV2Api, index_UsercentricsV2Service as UsercentricsV2Service, index_UsercentricsV3Api as UsercentricsV3Api, index_UsercentricsV3CategoryData as UsercentricsV3CategoryData, index_UsercentricsV3CategoryState as UsercentricsV3CategoryState, index_UsercentricsV3CmpEventDetail as UsercentricsV3CmpEventDetail, index_UsercentricsV3ConsentData as UsercentricsV3ConsentData, index_UsercentricsV3ConsentDetails as UsercentricsV3ConsentDetails };
97
215
  }
98
216
 
99
217
  /**
@@ -199,8 +317,10 @@ declare const trigger: (input: unknown, env: Record<string, unknown>) => void |
199
317
  /**
200
318
  * Usercentrics consent management source for walkerOS.
201
319
  *
202
- * This source listens to Usercentrics CMP events and translates
203
- * consent states to walkerOS consent commands.
320
+ * Listens to Usercentrics CMP events and translates consent states to
321
+ * walkerOS consent commands. Supports both the legacy V2 API
322
+ * (`window.UC_UI` + `ucEvent`) and the current V3 API
323
+ * (`window.__ucCmp` + `UC_UI_CMP_EVENT`).
204
324
  *
205
325
  * @example
206
326
  * ```typescript