@walkeros/web-source-cmp-cookiepro 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.
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # @walkeros/web-source-cmp-cookiepro
2
+
3
+ CookiePro/OneTrust consent management source for walkerOS.
4
+
5
+ This source listens to
6
+ [CookiePro/OneTrust](https://www.onetrust.com/products/cookie-consent/) CMP
7
+ events and translates consent states to walkerOS consent commands.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @walkeros/web-source-cmp-cookiepro
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { startFlow } from '@walkeros/collector';
19
+ import { sourceCookiePro } from '@walkeros/web-source-cmp-cookiepro';
20
+ // import { destinationGtag } from '@walkeros/web-destination-gtag';
21
+
22
+ await startFlow({
23
+ sources: {
24
+ consent: {
25
+ code: sourceCookiePro,
26
+ },
27
+ },
28
+ destinations: {
29
+ gtag: {
30
+ code: destinationGtag,
31
+ config: {
32
+ consent: { analytics: true }, // Requires analytics consent
33
+ },
34
+ },
35
+ },
36
+ });
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ ### Settings
42
+
43
+ | Setting | Type | Default | Description |
44
+ | -------------- | ------------------------ | ------------ | -------------------------------------------------- |
45
+ | `categoryMap` | `Record<string, string>` | See below | Maps CookiePro category IDs to walkerOS groups |
46
+ | `explicitOnly` | `boolean` | `true` | Only process explicit consent (user made a choice) |
47
+ | `globalName` | `string` | `'OneTrust'` | Custom name for `window.OneTrust` object |
48
+
49
+ ### Default category mapping
50
+
51
+ ```typescript
52
+ {
53
+ C0001: 'functional', // Strictly Necessary
54
+ C0002: 'analytics', // Performance
55
+ C0003: 'functional', // Functional
56
+ C0004: 'marketing', // Targeting
57
+ C0005: 'marketing', // Social Media
58
+ }
59
+ ```
60
+
61
+ Category ID comparison is case-insensitive. Unmapped category IDs are ignored
62
+ (not passed through), since CookiePro's opaque IDs are meaningless without a
63
+ mapping. All mapped walkerOS groups receive explicit `true`/`false` values --
64
+ absent groups are set to `false` so destinations know which consent is denied.
65
+
66
+ ### Custom mapping example
67
+
68
+ ```typescript
69
+ import { startFlow } from '@walkeros/collector';
70
+ import { sourceCookiePro } from '@walkeros/web-source-cmp-cookiepro';
71
+
72
+ await startFlow({
73
+ sources: {
74
+ consent: {
75
+ code: sourceCookiePro,
76
+ config: {
77
+ settings: {
78
+ categoryMap: {
79
+ C0002: 'statistics', // Use 'statistics' instead of 'analytics'
80
+ },
81
+ explicitOnly: true,
82
+ },
83
+ },
84
+ },
85
+ },
86
+ });
87
+ ```
88
+
89
+ Custom entries are merged with the default mapping. Specify only the categories
90
+ you want to override -- all other defaults remain active.
91
+
92
+ ## How it works
93
+
94
+ 1. **Already loaded**: When the source initializes, it checks if
95
+ `window.OneTrust` and `window.OptanonActiveGroups` already exist. If so,
96
+ processes consent immediately.
97
+
98
+ 2. **OptanonWrapper**: If the SDK isn't loaded yet, wraps the global
99
+ `OptanonWrapper` callback (preserving any existing wrapper). OneTrust calls
100
+ this function on SDK init. The wrapper self-unwraps after the first call,
101
+ leaving the event listener to handle subsequent changes.
102
+
103
+ 3. **OneTrustGroupsUpdated event**: Listens for the `OneTrustGroupsUpdated`
104
+ window event, which fires on every consent change.
105
+
106
+ 4. **Parsing**: Splits the `OptanonActiveGroups` comma-separated string, maps
107
+ category IDs through `categoryMap`, and calls `elb('walker consent', state)`.
108
+ Sets explicit `false` for all mapped groups that are not in the active list.
109
+
110
+ ### Timing considerations
111
+
112
+ The source handles all timing scenarios:
113
+
114
+ - **SDK loads before source:** The "already loaded" check reads existing consent
115
+ from `OptanonActiveGroups` immediately. The `OneTrustGroupsUpdated` listener
116
+ catches future changes.
117
+ - **Source loads before SDK:** The `OptanonWrapper` wrapping intercepts the
118
+ SDK's init callback. The event listener catches subsequent changes.
119
+ - **`explicitOnly` (default):** Uses `OneTrust.IsAlertBoxClosed()` to determine
120
+ if the user has actively interacted with the consent banner. Implicit/default
121
+ consent is ignored.
122
+
123
+ ### OptanonWrapper wrapping
124
+
125
+ The `OptanonWrapper` function-reassignment pattern is the standard OneTrust
126
+ integration approach. Multiple scripts can wrap it in a chain (each preserving
127
+ the previous). On `destroy()`, the source restores the wrapper it captured at
128
+ init time. If another script wraps `OptanonWrapper` after this source, that
129
+ wrapper will be lost on destroy. This is inherent to the pattern.
130
+
131
+ ## CookiePro API reference
132
+
133
+ - `window.OptanonActiveGroups`: Comma-separated string of active category IDs
134
+ (e.g., `",C0001,C0003,"`)
135
+ - `window.OneTrust.IsAlertBoxClosed()`: Returns `true` if user made explicit
136
+ choice
137
+ - `window.OptanonWrapper()`: Global callback invoked by SDK on load and consent
138
+ changes
139
+ - `OneTrustGroupsUpdated`: Window event fired on consent changes (event.detail
140
+ is an array of active group IDs)
141
+
142
+ ## walkerOS.json
143
+
144
+ ```json
145
+ { "walkerOS": { "type": "source", "platform": "web" } }
146
+ ```
147
+
148
+ ## Type definitions
149
+
150
+ See [src/types/index.ts](./src/types/index.ts) for TypeScript interfaces.
151
+
152
+ ## Related
153
+
154
+ - [Consent management guide](https://www.walkeros.io/docs/guides/consent)
155
+ - [CookiePro documentation](https://www.walkeros.io/docs/sources/web/cmps/cookiepro)
156
+
157
+ ## License
158
+
159
+ MIT
package/dist/dev.d.mts ADDED
@@ -0,0 +1,148 @@
1
+ import { WalkerOS, Elb, Logger } from '@walkeros/core';
2
+
3
+ /**
4
+ * Example CookiePro OptanonActiveGroups strings.
5
+ *
6
+ * These represent real consent states from CookiePro/OneTrust CMP.
7
+ * Format: comma-separated active category IDs with leading/trailing commas.
8
+ * Only active groups are listed. Absence means denied.
9
+ */
10
+ /**
11
+ * Full consent - user accepted all categories
12
+ */
13
+ declare const fullConsent = ",C0001,C0002,C0003,C0004,C0005,";
14
+ /**
15
+ * Partial consent - necessary + functional only
16
+ */
17
+ declare const partialConsent = ",C0001,C0003,";
18
+ /**
19
+ * Minimal consent - only strictly necessary (always active)
20
+ */
21
+ declare const minimalConsent = ",C0001,";
22
+ /**
23
+ * Analytics only - necessary + performance
24
+ */
25
+ declare const analyticsOnlyConsent = ",C0001,C0002,";
26
+ /**
27
+ * Marketing only - necessary + targeting
28
+ */
29
+ declare const marketingOnlyConsent = ",C0001,C0004,";
30
+ /**
31
+ * Empty string - no consent yet or cleared
32
+ */
33
+ declare const emptyConsent = "";
34
+ /**
35
+ * Custom category IDs - some installations use custom IDs
36
+ */
37
+ declare const customCategoryConsent = ",C0001,CUSTOM01,CUSTOM02,";
38
+
39
+ /**
40
+ * Expected walkerOS consent outputs.
41
+ *
42
+ * These represent the consent state after parsing OptanonActiveGroups
43
+ * and mapping through the default categoryMap.
44
+ *
45
+ * Default map:
46
+ * - C0001 -> functional
47
+ * - C0002 -> analytics
48
+ * - C0003 -> functional
49
+ * - C0004 -> marketing
50
+ * - C0005 -> marketing
51
+ *
52
+ * All mapped walkerOS groups get explicit true/false values.
53
+ * Active groups -> true, absent groups -> false.
54
+ */
55
+ /**
56
+ * Full consent mapped to walkerOS groups
57
+ */
58
+ declare const fullConsentMapped: WalkerOS.Consent;
59
+ /**
60
+ * Partial consent - necessary + functional mapped
61
+ * C0001 -> functional (true), C0003 -> functional (true)
62
+ * analytics and marketing absent -> false
63
+ */
64
+ declare const partialConsentMapped: WalkerOS.Consent;
65
+ /**
66
+ * Minimal consent - only strictly necessary
67
+ * C0001 -> functional (true)
68
+ * analytics and marketing absent -> false
69
+ */
70
+ declare const minimalConsentMapped: WalkerOS.Consent;
71
+ /**
72
+ * Analytics only - necessary + performance
73
+ * C0001 -> functional (true), C0002 -> analytics (true)
74
+ * marketing absent -> false
75
+ */
76
+ declare const analyticsOnlyMapped: WalkerOS.Consent;
77
+ /**
78
+ * Marketing only - necessary + targeting
79
+ * C0001 -> functional (true), C0004 -> marketing (true)
80
+ * analytics absent -> false
81
+ */
82
+ declare const marketingOnlyMapped: WalkerOS.Consent;
83
+
84
+ /**
85
+ * OneTrust global API interface.
86
+ *
87
+ * Represents the subset of the OneTrust SDK we interact with.
88
+ * The full SDK is much larger, but we only need consent-related methods.
89
+ */
90
+ interface OneTrustAPI {
91
+ /** Returns true if user has made an explicit consent choice */
92
+ IsAlertBoxClosed: () => boolean;
93
+ /** Register a callback for consent changes (callback receives event with detail: string[]) */
94
+ OnConsentChanged?: (fn: (event: {
95
+ detail: string[];
96
+ }) => void) => void;
97
+ }
98
+ declare global {
99
+ interface Window {
100
+ /** OneTrust SDK global object */
101
+ OneTrust?: OneTrustAPI;
102
+ /** Comma-separated string of active consent category IDs (e.g. ",C0001,C0003,") */
103
+ OptanonActiveGroups?: string;
104
+ /** OneTrust callback function, called on SDK load and consent changes */
105
+ OptanonWrapper?: () => void;
106
+ /** CookiePro legacy alias for OneTrust */
107
+ Optanon?: unknown;
108
+ [key: string]: OneTrustAPI | unknown;
109
+ }
110
+ interface WindowEventMap {
111
+ /** event.detail is an array of active group ID strings (e.g. ["C0001", "C0002"]) */
112
+ OneTrustGroupsUpdated: CustomEvent<string[]>;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Create a properly typed elb/push function mock
118
+ */
119
+ declare const createMockElbFn: () => Elb.Fn;
120
+ /**
121
+ * Simple no-op logger for demo purposes
122
+ */
123
+ declare const noopLogger: Logger.Instance;
124
+ /**
125
+ * Create a mock OneTrust API object
126
+ */
127
+ declare const createMockOneTrustAPI: (isAlertBoxClosed?: boolean) => OneTrustAPI;
128
+
129
+ declare const index_analyticsOnlyConsent: typeof analyticsOnlyConsent;
130
+ declare const index_analyticsOnlyMapped: typeof analyticsOnlyMapped;
131
+ declare const index_createMockElbFn: typeof createMockElbFn;
132
+ declare const index_createMockOneTrustAPI: typeof createMockOneTrustAPI;
133
+ declare const index_customCategoryConsent: typeof customCategoryConsent;
134
+ declare const index_emptyConsent: typeof emptyConsent;
135
+ declare const index_fullConsent: typeof fullConsent;
136
+ declare const index_fullConsentMapped: typeof fullConsentMapped;
137
+ declare const index_marketingOnlyConsent: typeof marketingOnlyConsent;
138
+ declare const index_marketingOnlyMapped: typeof marketingOnlyMapped;
139
+ declare const index_minimalConsent: typeof minimalConsent;
140
+ declare const index_minimalConsentMapped: typeof minimalConsentMapped;
141
+ declare const index_noopLogger: typeof noopLogger;
142
+ declare const index_partialConsent: typeof partialConsent;
143
+ declare const index_partialConsentMapped: typeof partialConsentMapped;
144
+ declare namespace index {
145
+ export { index_analyticsOnlyConsent as analyticsOnlyConsent, index_analyticsOnlyMapped as analyticsOnlyMapped, index_createMockElbFn as createMockElbFn, index_createMockOneTrustAPI as createMockOneTrustAPI, index_customCategoryConsent as customCategoryConsent, index_emptyConsent as emptyConsent, index_fullConsent as fullConsent, index_fullConsentMapped as fullConsentMapped, index_marketingOnlyConsent as marketingOnlyConsent, index_marketingOnlyMapped as marketingOnlyMapped, index_minimalConsent as minimalConsent, index_minimalConsentMapped as minimalConsentMapped, index_noopLogger as noopLogger, index_partialConsent as partialConsent, index_partialConsentMapped as partialConsentMapped };
146
+ }
147
+
148
+ export { index as examples };
package/dist/dev.d.ts ADDED
@@ -0,0 +1,148 @@
1
+ import { WalkerOS, Elb, Logger } from '@walkeros/core';
2
+
3
+ /**
4
+ * Example CookiePro OptanonActiveGroups strings.
5
+ *
6
+ * These represent real consent states from CookiePro/OneTrust CMP.
7
+ * Format: comma-separated active category IDs with leading/trailing commas.
8
+ * Only active groups are listed. Absence means denied.
9
+ */
10
+ /**
11
+ * Full consent - user accepted all categories
12
+ */
13
+ declare const fullConsent = ",C0001,C0002,C0003,C0004,C0005,";
14
+ /**
15
+ * Partial consent - necessary + functional only
16
+ */
17
+ declare const partialConsent = ",C0001,C0003,";
18
+ /**
19
+ * Minimal consent - only strictly necessary (always active)
20
+ */
21
+ declare const minimalConsent = ",C0001,";
22
+ /**
23
+ * Analytics only - necessary + performance
24
+ */
25
+ declare const analyticsOnlyConsent = ",C0001,C0002,";
26
+ /**
27
+ * Marketing only - necessary + targeting
28
+ */
29
+ declare const marketingOnlyConsent = ",C0001,C0004,";
30
+ /**
31
+ * Empty string - no consent yet or cleared
32
+ */
33
+ declare const emptyConsent = "";
34
+ /**
35
+ * Custom category IDs - some installations use custom IDs
36
+ */
37
+ declare const customCategoryConsent = ",C0001,CUSTOM01,CUSTOM02,";
38
+
39
+ /**
40
+ * Expected walkerOS consent outputs.
41
+ *
42
+ * These represent the consent state after parsing OptanonActiveGroups
43
+ * and mapping through the default categoryMap.
44
+ *
45
+ * Default map:
46
+ * - C0001 -> functional
47
+ * - C0002 -> analytics
48
+ * - C0003 -> functional
49
+ * - C0004 -> marketing
50
+ * - C0005 -> marketing
51
+ *
52
+ * All mapped walkerOS groups get explicit true/false values.
53
+ * Active groups -> true, absent groups -> false.
54
+ */
55
+ /**
56
+ * Full consent mapped to walkerOS groups
57
+ */
58
+ declare const fullConsentMapped: WalkerOS.Consent;
59
+ /**
60
+ * Partial consent - necessary + functional mapped
61
+ * C0001 -> functional (true), C0003 -> functional (true)
62
+ * analytics and marketing absent -> false
63
+ */
64
+ declare const partialConsentMapped: WalkerOS.Consent;
65
+ /**
66
+ * Minimal consent - only strictly necessary
67
+ * C0001 -> functional (true)
68
+ * analytics and marketing absent -> false
69
+ */
70
+ declare const minimalConsentMapped: WalkerOS.Consent;
71
+ /**
72
+ * Analytics only - necessary + performance
73
+ * C0001 -> functional (true), C0002 -> analytics (true)
74
+ * marketing absent -> false
75
+ */
76
+ declare const analyticsOnlyMapped: WalkerOS.Consent;
77
+ /**
78
+ * Marketing only - necessary + targeting
79
+ * C0001 -> functional (true), C0004 -> marketing (true)
80
+ * analytics absent -> false
81
+ */
82
+ declare const marketingOnlyMapped: WalkerOS.Consent;
83
+
84
+ /**
85
+ * OneTrust global API interface.
86
+ *
87
+ * Represents the subset of the OneTrust SDK we interact with.
88
+ * The full SDK is much larger, but we only need consent-related methods.
89
+ */
90
+ interface OneTrustAPI {
91
+ /** Returns true if user has made an explicit consent choice */
92
+ IsAlertBoxClosed: () => boolean;
93
+ /** Register a callback for consent changes (callback receives event with detail: string[]) */
94
+ OnConsentChanged?: (fn: (event: {
95
+ detail: string[];
96
+ }) => void) => void;
97
+ }
98
+ declare global {
99
+ interface Window {
100
+ /** OneTrust SDK global object */
101
+ OneTrust?: OneTrustAPI;
102
+ /** Comma-separated string of active consent category IDs (e.g. ",C0001,C0003,") */
103
+ OptanonActiveGroups?: string;
104
+ /** OneTrust callback function, called on SDK load and consent changes */
105
+ OptanonWrapper?: () => void;
106
+ /** CookiePro legacy alias for OneTrust */
107
+ Optanon?: unknown;
108
+ [key: string]: OneTrustAPI | unknown;
109
+ }
110
+ interface WindowEventMap {
111
+ /** event.detail is an array of active group ID strings (e.g. ["C0001", "C0002"]) */
112
+ OneTrustGroupsUpdated: CustomEvent<string[]>;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Create a properly typed elb/push function mock
118
+ */
119
+ declare const createMockElbFn: () => Elb.Fn;
120
+ /**
121
+ * Simple no-op logger for demo purposes
122
+ */
123
+ declare const noopLogger: Logger.Instance;
124
+ /**
125
+ * Create a mock OneTrust API object
126
+ */
127
+ declare const createMockOneTrustAPI: (isAlertBoxClosed?: boolean) => OneTrustAPI;
128
+
129
+ declare const index_analyticsOnlyConsent: typeof analyticsOnlyConsent;
130
+ declare const index_analyticsOnlyMapped: typeof analyticsOnlyMapped;
131
+ declare const index_createMockElbFn: typeof createMockElbFn;
132
+ declare const index_createMockOneTrustAPI: typeof createMockOneTrustAPI;
133
+ declare const index_customCategoryConsent: typeof customCategoryConsent;
134
+ declare const index_emptyConsent: typeof emptyConsent;
135
+ declare const index_fullConsent: typeof fullConsent;
136
+ declare const index_fullConsentMapped: typeof fullConsentMapped;
137
+ declare const index_marketingOnlyConsent: typeof marketingOnlyConsent;
138
+ declare const index_marketingOnlyMapped: typeof marketingOnlyMapped;
139
+ declare const index_minimalConsent: typeof minimalConsent;
140
+ declare const index_minimalConsentMapped: typeof minimalConsentMapped;
141
+ declare const index_noopLogger: typeof noopLogger;
142
+ declare const index_partialConsent: typeof partialConsent;
143
+ declare const index_partialConsentMapped: typeof partialConsentMapped;
144
+ declare namespace index {
145
+ export { index_analyticsOnlyConsent as analyticsOnlyConsent, index_analyticsOnlyMapped as analyticsOnlyMapped, index_createMockElbFn as createMockElbFn, index_createMockOneTrustAPI as createMockOneTrustAPI, index_customCategoryConsent as customCategoryConsent, index_emptyConsent as emptyConsent, index_fullConsent as fullConsent, index_fullConsentMapped as fullConsentMapped, index_marketingOnlyConsent as marketingOnlyConsent, index_marketingOnlyMapped as marketingOnlyMapped, index_minimalConsent as minimalConsent, index_minimalConsentMapped as minimalConsentMapped, index_noopLogger as noopLogger, index_partialConsent as partialConsent, index_partialConsentMapped as partialConsentMapped };
146
+ }
147
+
148
+ export { index as examples };
package/dist/dev.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,n=Object.defineProperty,t=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0})},l={};r(l,{examples:()=>i}),module.exports=(e=l,((e,r,l,i)=>{if(r&&"object"==typeof r||"function"==typeof r)for(let s of a(r))o.call(e,s)||s===l||n(e,s,{get:()=>r[s],enumerable:!(i=t(r,s))||i.enumerable});return e})(n({},"__esModule",{value:!0}),e));var i={};r(i,{analyticsOnlyConsent:()=>C,analyticsOnlyMapped:()=>b,createMockElbFn:()=>M,createMockOneTrustAPI:()=>w,customCategoryConsent:()=>u,emptyConsent:()=>m,fullConsent:()=>s,fullConsentMapped:()=>f,marketingOnlyConsent:()=>y,marketingOnlyMapped:()=>d,minimalConsent:()=>p,minimalConsentMapped:()=>O,noopLogger:()=>v,partialConsent:()=>c,partialConsentMapped:()=>g});var s=",C0001,C0002,C0003,C0004,C0005,",c=",C0001,C0003,",p=",C0001,",C=",C0001,C0002,",y=",C0001,C0004,",m="",u=",C0001,CUSTOM01,CUSTOM02,",f={functional:!0,analytics:!0,marketing:!0},g={functional:!0,analytics:!1,marketing:!1},O={functional:!0,analytics:!1,marketing:!1},b={functional:!0,analytics:!0,marketing:!1},d={functional:!0,analytics:!1,marketing:!0},k=()=>{},M=()=>()=>Promise.resolve({ok:!0}),v={error:k,info:k,debug:k,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>v},w=(e=!1)=>({IsAlertBoxClosed:()=>e});//# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev.ts","../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts"],"sourcesContent":["/**\n * Development exports for testing and tooling.\n */\nexport * as examples from './examples';\n","export * from './inputs';\nexport * from './outputs';\nexport * from './env';\n","/**\n * Example CookiePro OptanonActiveGroups strings.\n *\n * These represent real consent states from CookiePro/OneTrust CMP.\n * Format: comma-separated active category IDs with leading/trailing commas.\n * Only active groups are listed. Absence means denied.\n */\n\n/**\n * Full consent - user accepted all categories\n */\nexport const fullConsent = ',C0001,C0002,C0003,C0004,C0005,';\n\n/**\n * Partial consent - necessary + functional only\n */\nexport const partialConsent = ',C0001,C0003,';\n\n/**\n * Minimal consent - only strictly necessary (always active)\n */\nexport const minimalConsent = ',C0001,';\n\n/**\n * Analytics only - necessary + performance\n */\nexport const analyticsOnlyConsent = ',C0001,C0002,';\n\n/**\n * Marketing only - necessary + targeting\n */\nexport const marketingOnlyConsent = ',C0001,C0004,';\n\n/**\n * Empty string - no consent yet or cleared\n */\nexport const emptyConsent = '';\n\n/**\n * Custom category IDs - some installations use custom IDs\n */\nexport const customCategoryConsent = ',C0001,CUSTOM01,CUSTOM02,';\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing OptanonActiveGroups\n * and mapping through the default categoryMap.\n *\n * Default map:\n * - C0001 -> functional\n * - C0002 -> analytics\n * - C0003 -> functional\n * - C0004 -> marketing\n * - C0005 -> marketing\n *\n * All mapped walkerOS groups get explicit true/false values.\n * Active groups -> true, absent groups -> false.\n */\n\n/**\n * Full consent mapped to walkerOS groups\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n\n/**\n * Partial consent - necessary + functional mapped\n * C0001 -> functional (true), C0003 -> functional (true)\n * analytics and marketing absent -> false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Minimal consent - only strictly necessary\n * C0001 -> functional (true)\n * analytics and marketing absent -> false\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Analytics only - necessary + performance\n * C0001 -> functional (true), C0002 -> analytics (true)\n * marketing absent -> false\n */\nexport const analyticsOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: false,\n};\n\n/**\n * Marketing only - necessary + targeting\n * C0001 -> functional (true), C0004 -> marketing (true)\n * analytics absent -> false\n */\nexport const marketingOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: true,\n};\n","import type { Source, Elb, Logger } from '@walkeros/core';\nimport type { OneTrustAPI } from '../types';\n\n/**\n * Example environment configurations for CookiePro source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n scope: () => noopLogger,\n};\n\n/**\n * Create a mock OneTrust API object\n */\nexport const createMockOneTrustAPI = (\n isAlertBoxClosed = false,\n): OneTrustAPI => ({\n IsAlertBoxClosed: () => isAlertBoxClosed,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAc;AAKpB,IAAM,iBAAiB;AAKvB,IAAM,iBAAiB;AAKvB,IAAM,uBAAuB;AAK7B,IAAM,uBAAuB;AAK7B,IAAM,eAAe;AAKrB,IAAM,wBAAwB;;;ACnB9B,IAAM,oBAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;;;AC/DA,IAAM,OAAO,MAAM;AAAC;AAKb,IAAM,kBAAkB,MAAc;AAC3C,QAAM,MAAM,MACV,QAAQ,QAAQ;AAAA,IACd,IAAI;AAAA,EACN,CAAC;AACH,SAAO;AACT;AAKO,IAAM,aAA8B;AAAA,EACzC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO,CAAC,YAA4B;AAClC,UAAM,OAAO,YAAY,WAAW,IAAI,MAAM,OAAO,IAAI;AAAA,EAC3D;AAAA,EACA,OAAO,MAAM;AACf;AAKO,IAAM,wBAAwB,CACnC,mBAAmB,WACF;AAAA,EACjB,kBAAkB,MAAM;AAC1B;","names":[]}
package/dist/dev.mjs ADDED
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty,e={};((e,a)=>{for(var t in a)n(e,t,{get:a[t],enumerable:!0})})(e,{analyticsOnlyConsent:()=>r,analyticsOnlyMapped:()=>m,createMockElbFn:()=>f,createMockOneTrustAPI:()=>k,customCategoryConsent:()=>s,emptyConsent:()=>l,fullConsent:()=>a,fullConsentMapped:()=>C,marketingOnlyConsent:()=>i,marketingOnlyMapped:()=>y,minimalConsent:()=>o,minimalConsentMapped:()=>p,noopLogger:()=>u,partialConsent:()=>t,partialConsentMapped:()=>c});var a=",C0001,C0002,C0003,C0004,C0005,",t=",C0001,C0003,",o=",C0001,",r=",C0001,C0002,",i=",C0001,C0004,",l="",s=",C0001,CUSTOM01,CUSTOM02,",C={functional:!0,analytics:!0,marketing:!0},c={functional:!0,analytics:!1,marketing:!1},p={functional:!0,analytics:!1,marketing:!1},m={functional:!0,analytics:!0,marketing:!1},y={functional:!0,analytics:!1,marketing:!0},g=()=>{},f=()=>()=>Promise.resolve({ok:!0}),u={error:g,info:g,debug:g,throw:n=>{throw"string"==typeof n?new Error(n):n},scope:()=>u},k=(n=!1)=>({IsAlertBoxClosed:()=>n});export{e as examples};//# sourceMappingURL=dev.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/outputs.ts","../src/examples/env.ts"],"sourcesContent":["export * from './inputs';\nexport * from './outputs';\nexport * from './env';\n","/**\n * Example CookiePro OptanonActiveGroups strings.\n *\n * These represent real consent states from CookiePro/OneTrust CMP.\n * Format: comma-separated active category IDs with leading/trailing commas.\n * Only active groups are listed. Absence means denied.\n */\n\n/**\n * Full consent - user accepted all categories\n */\nexport const fullConsent = ',C0001,C0002,C0003,C0004,C0005,';\n\n/**\n * Partial consent - necessary + functional only\n */\nexport const partialConsent = ',C0001,C0003,';\n\n/**\n * Minimal consent - only strictly necessary (always active)\n */\nexport const minimalConsent = ',C0001,';\n\n/**\n * Analytics only - necessary + performance\n */\nexport const analyticsOnlyConsent = ',C0001,C0002,';\n\n/**\n * Marketing only - necessary + targeting\n */\nexport const marketingOnlyConsent = ',C0001,C0004,';\n\n/**\n * Empty string - no consent yet or cleared\n */\nexport const emptyConsent = '';\n\n/**\n * Custom category IDs - some installations use custom IDs\n */\nexport const customCategoryConsent = ',C0001,CUSTOM01,CUSTOM02,';\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Expected walkerOS consent outputs.\n *\n * These represent the consent state after parsing OptanonActiveGroups\n * and mapping through the default categoryMap.\n *\n * Default map:\n * - C0001 -> functional\n * - C0002 -> analytics\n * - C0003 -> functional\n * - C0004 -> marketing\n * - C0005 -> marketing\n *\n * All mapped walkerOS groups get explicit true/false values.\n * Active groups -> true, absent groups -> false.\n */\n\n/**\n * Full consent mapped to walkerOS groups\n */\nexport const fullConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: true,\n};\n\n/**\n * Partial consent - necessary + functional mapped\n * C0001 -> functional (true), C0003 -> functional (true)\n * analytics and marketing absent -> false\n */\nexport const partialConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Minimal consent - only strictly necessary\n * C0001 -> functional (true)\n * analytics and marketing absent -> false\n */\nexport const minimalConsentMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: false,\n};\n\n/**\n * Analytics only - necessary + performance\n * C0001 -> functional (true), C0002 -> analytics (true)\n * marketing absent -> false\n */\nexport const analyticsOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: true,\n marketing: false,\n};\n\n/**\n * Marketing only - necessary + targeting\n * C0001 -> functional (true), C0004 -> marketing (true)\n * analytics absent -> false\n */\nexport const marketingOnlyMapped: WalkerOS.Consent = {\n functional: true,\n analytics: false,\n marketing: true,\n};\n","import type { Source, Elb, Logger } from '@walkeros/core';\nimport type { OneTrustAPI } from '../types';\n\n/**\n * Example environment configurations for CookiePro source testing.\n */\n\nconst noop = () => {};\n\n/**\n * Create a properly typed elb/push function mock\n */\nexport const createMockElbFn = (): Elb.Fn => {\n const fn = (() =>\n Promise.resolve({\n ok: true,\n })) as Elb.Fn;\n return fn;\n};\n\n/**\n * Simple no-op logger for demo purposes\n */\nexport const noopLogger: Logger.Instance = {\n error: noop,\n info: noop,\n debug: noop,\n throw: (message: string | Error) => {\n throw typeof message === 'string' ? new Error(message) : message;\n },\n scope: () => noopLogger,\n};\n\n/**\n * Create a mock OneTrust API object\n */\nexport const createMockOneTrustAPI = (\n isAlertBoxClosed = false,\n): OneTrustAPI => ({\n IsAlertBoxClosed: () => isAlertBoxClosed,\n});\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWO,IAAM,cAAc;AAKpB,IAAM,iBAAiB;AAKvB,IAAM,iBAAiB;AAKvB,IAAM,uBAAuB;AAK7B,IAAM,uBAAuB;AAK7B,IAAM,eAAe;AAKrB,IAAM,wBAAwB;;;ACnB9B,IAAM,oBAAsC;AAAA,EACjD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,uBAAyC;AAAA,EACpD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;AAOO,IAAM,sBAAwC;AAAA,EACnD,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,WAAW;AACb;;;AC/DA,IAAM,OAAO,MAAM;AAAC;AAKb,IAAM,kBAAkB,MAAc;AAC3C,QAAM,MAAM,MACV,QAAQ,QAAQ;AAAA,IACd,IAAI;AAAA,EACN,CAAC;AACH,SAAO;AACT;AAKO,IAAM,aAA8B;AAAA,EACzC,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO,CAAC,YAA4B;AAClC,UAAM,OAAO,YAAY,WAAW,IAAI,MAAM,OAAO,IAAI;AAAA,EAC3D;AAAA,EACA,OAAO,MAAM;AACf;AAKO,IAAM,wBAAwB,CACnC,mBAAmB,WACF;AAAA,EACjB,kBAAkB,MAAM;AAC1B;","names":[]}
@@ -0,0 +1,129 @@
1
+ import { WalkerOS, Elb, Logger } from '@walkeros/core';
2
+
3
+ /**
4
+ * Example CookiePro OptanonActiveGroups strings.
5
+ *
6
+ * These represent real consent states from CookiePro/OneTrust CMP.
7
+ * Format: comma-separated active category IDs with leading/trailing commas.
8
+ * Only active groups are listed. Absence means denied.
9
+ */
10
+ /**
11
+ * Full consent - user accepted all categories
12
+ */
13
+ declare const fullConsent = ",C0001,C0002,C0003,C0004,C0005,";
14
+ /**
15
+ * Partial consent - necessary + functional only
16
+ */
17
+ declare const partialConsent = ",C0001,C0003,";
18
+ /**
19
+ * Minimal consent - only strictly necessary (always active)
20
+ */
21
+ declare const minimalConsent = ",C0001,";
22
+ /**
23
+ * Analytics only - necessary + performance
24
+ */
25
+ declare const analyticsOnlyConsent = ",C0001,C0002,";
26
+ /**
27
+ * Marketing only - necessary + targeting
28
+ */
29
+ declare const marketingOnlyConsent = ",C0001,C0004,";
30
+ /**
31
+ * Empty string - no consent yet or cleared
32
+ */
33
+ declare const emptyConsent = "";
34
+ /**
35
+ * Custom category IDs - some installations use custom IDs
36
+ */
37
+ declare const customCategoryConsent = ",C0001,CUSTOM01,CUSTOM02,";
38
+
39
+ /**
40
+ * Expected walkerOS consent outputs.
41
+ *
42
+ * These represent the consent state after parsing OptanonActiveGroups
43
+ * and mapping through the default categoryMap.
44
+ *
45
+ * Default map:
46
+ * - C0001 -> functional
47
+ * - C0002 -> analytics
48
+ * - C0003 -> functional
49
+ * - C0004 -> marketing
50
+ * - C0005 -> marketing
51
+ *
52
+ * All mapped walkerOS groups get explicit true/false values.
53
+ * Active groups -> true, absent groups -> false.
54
+ */
55
+ /**
56
+ * Full consent mapped to walkerOS groups
57
+ */
58
+ declare const fullConsentMapped: WalkerOS.Consent;
59
+ /**
60
+ * Partial consent - necessary + functional mapped
61
+ * C0001 -> functional (true), C0003 -> functional (true)
62
+ * analytics and marketing absent -> false
63
+ */
64
+ declare const partialConsentMapped: WalkerOS.Consent;
65
+ /**
66
+ * Minimal consent - only strictly necessary
67
+ * C0001 -> functional (true)
68
+ * analytics and marketing absent -> false
69
+ */
70
+ declare const minimalConsentMapped: WalkerOS.Consent;
71
+ /**
72
+ * Analytics only - necessary + performance
73
+ * C0001 -> functional (true), C0002 -> analytics (true)
74
+ * marketing absent -> false
75
+ */
76
+ declare const analyticsOnlyMapped: WalkerOS.Consent;
77
+ /**
78
+ * Marketing only - necessary + targeting
79
+ * C0001 -> functional (true), C0004 -> marketing (true)
80
+ * analytics absent -> false
81
+ */
82
+ declare const marketingOnlyMapped: WalkerOS.Consent;
83
+
84
+ /**
85
+ * OneTrust global API interface.
86
+ *
87
+ * Represents the subset of the OneTrust SDK we interact with.
88
+ * The full SDK is much larger, but we only need consent-related methods.
89
+ */
90
+ interface OneTrustAPI {
91
+ /** Returns true if user has made an explicit consent choice */
92
+ IsAlertBoxClosed: () => boolean;
93
+ /** Register a callback for consent changes (callback receives event with detail: string[]) */
94
+ OnConsentChanged?: (fn: (event: {
95
+ detail: string[];
96
+ }) => void) => void;
97
+ }
98
+ declare global {
99
+ interface Window {
100
+ /** OneTrust SDK global object */
101
+ OneTrust?: OneTrustAPI;
102
+ /** Comma-separated string of active consent category IDs (e.g. ",C0001,C0003,") */
103
+ OptanonActiveGroups?: string;
104
+ /** OneTrust callback function, called on SDK load and consent changes */
105
+ OptanonWrapper?: () => void;
106
+ /** CookiePro legacy alias for OneTrust */
107
+ Optanon?: unknown;
108
+ [key: string]: OneTrustAPI | unknown;
109
+ }
110
+ interface WindowEventMap {
111
+ /** event.detail is an array of active group ID strings (e.g. ["C0001", "C0002"]) */
112
+ OneTrustGroupsUpdated: CustomEvent<string[]>;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Create a properly typed elb/push function mock
118
+ */
119
+ declare const createMockElbFn: () => Elb.Fn;
120
+ /**
121
+ * Simple no-op logger for demo purposes
122
+ */
123
+ declare const noopLogger: Logger.Instance;
124
+ /**
125
+ * Create a mock OneTrust API object
126
+ */
127
+ declare const createMockOneTrustAPI: (isAlertBoxClosed?: boolean) => OneTrustAPI;
128
+
129
+ export { analyticsOnlyConsent, analyticsOnlyMapped, createMockElbFn, createMockOneTrustAPI, customCategoryConsent, emptyConsent, fullConsent, fullConsentMapped, marketingOnlyConsent, marketingOnlyMapped, minimalConsent, minimalConsentMapped, noopLogger, partialConsent, partialConsentMapped };