@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 +159 -0
- package/dist/dev.d.mts +148 -0
- package/dist/dev.d.ts +148 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +129 -0
- package/dist/examples/index.d.ts +129 -0
- package/dist/examples/index.js +115 -0
- package/dist/examples/index.mjs +74 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.d.mts +251 -0
- package/dist/index.d.ts +251 -0
- package/dist/index.es5.js +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +72 -0
|
@@ -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 };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/examples/index.ts
|
|
21
|
+
var examples_exports = {};
|
|
22
|
+
__export(examples_exports, {
|
|
23
|
+
analyticsOnlyConsent: () => analyticsOnlyConsent,
|
|
24
|
+
analyticsOnlyMapped: () => analyticsOnlyMapped,
|
|
25
|
+
createMockElbFn: () => createMockElbFn,
|
|
26
|
+
createMockOneTrustAPI: () => createMockOneTrustAPI,
|
|
27
|
+
customCategoryConsent: () => customCategoryConsent,
|
|
28
|
+
emptyConsent: () => emptyConsent,
|
|
29
|
+
fullConsent: () => fullConsent,
|
|
30
|
+
fullConsentMapped: () => fullConsentMapped,
|
|
31
|
+
marketingOnlyConsent: () => marketingOnlyConsent,
|
|
32
|
+
marketingOnlyMapped: () => marketingOnlyMapped,
|
|
33
|
+
minimalConsent: () => minimalConsent,
|
|
34
|
+
minimalConsentMapped: () => minimalConsentMapped,
|
|
35
|
+
noopLogger: () => noopLogger,
|
|
36
|
+
partialConsent: () => partialConsent,
|
|
37
|
+
partialConsentMapped: () => partialConsentMapped
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(examples_exports);
|
|
40
|
+
|
|
41
|
+
// src/examples/inputs.ts
|
|
42
|
+
var fullConsent = ",C0001,C0002,C0003,C0004,C0005,";
|
|
43
|
+
var partialConsent = ",C0001,C0003,";
|
|
44
|
+
var minimalConsent = ",C0001,";
|
|
45
|
+
var analyticsOnlyConsent = ",C0001,C0002,";
|
|
46
|
+
var marketingOnlyConsent = ",C0001,C0004,";
|
|
47
|
+
var emptyConsent = "";
|
|
48
|
+
var customCategoryConsent = ",C0001,CUSTOM01,CUSTOM02,";
|
|
49
|
+
|
|
50
|
+
// src/examples/outputs.ts
|
|
51
|
+
var fullConsentMapped = {
|
|
52
|
+
functional: true,
|
|
53
|
+
analytics: true,
|
|
54
|
+
marketing: true
|
|
55
|
+
};
|
|
56
|
+
var partialConsentMapped = {
|
|
57
|
+
functional: true,
|
|
58
|
+
analytics: false,
|
|
59
|
+
marketing: false
|
|
60
|
+
};
|
|
61
|
+
var minimalConsentMapped = {
|
|
62
|
+
functional: true,
|
|
63
|
+
analytics: false,
|
|
64
|
+
marketing: false
|
|
65
|
+
};
|
|
66
|
+
var analyticsOnlyMapped = {
|
|
67
|
+
functional: true,
|
|
68
|
+
analytics: true,
|
|
69
|
+
marketing: false
|
|
70
|
+
};
|
|
71
|
+
var marketingOnlyMapped = {
|
|
72
|
+
functional: true,
|
|
73
|
+
analytics: false,
|
|
74
|
+
marketing: true
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/examples/env.ts
|
|
78
|
+
var noop = () => {
|
|
79
|
+
};
|
|
80
|
+
var createMockElbFn = () => {
|
|
81
|
+
const fn = (() => Promise.resolve({
|
|
82
|
+
ok: true
|
|
83
|
+
}));
|
|
84
|
+
return fn;
|
|
85
|
+
};
|
|
86
|
+
var noopLogger = {
|
|
87
|
+
error: noop,
|
|
88
|
+
info: noop,
|
|
89
|
+
debug: noop,
|
|
90
|
+
throw: (message) => {
|
|
91
|
+
throw typeof message === "string" ? new Error(message) : message;
|
|
92
|
+
},
|
|
93
|
+
scope: () => noopLogger
|
|
94
|
+
};
|
|
95
|
+
var createMockOneTrustAPI = (isAlertBoxClosed = false) => ({
|
|
96
|
+
IsAlertBoxClosed: () => isAlertBoxClosed
|
|
97
|
+
});
|
|
98
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
+
0 && (module.exports = {
|
|
100
|
+
analyticsOnlyConsent,
|
|
101
|
+
analyticsOnlyMapped,
|
|
102
|
+
createMockElbFn,
|
|
103
|
+
createMockOneTrustAPI,
|
|
104
|
+
customCategoryConsent,
|
|
105
|
+
emptyConsent,
|
|
106
|
+
fullConsent,
|
|
107
|
+
fullConsentMapped,
|
|
108
|
+
marketingOnlyConsent,
|
|
109
|
+
marketingOnlyMapped,
|
|
110
|
+
minimalConsent,
|
|
111
|
+
minimalConsentMapped,
|
|
112
|
+
noopLogger,
|
|
113
|
+
partialConsent,
|
|
114
|
+
partialConsentMapped
|
|
115
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// src/examples/inputs.ts
|
|
2
|
+
var fullConsent = ",C0001,C0002,C0003,C0004,C0005,";
|
|
3
|
+
var partialConsent = ",C0001,C0003,";
|
|
4
|
+
var minimalConsent = ",C0001,";
|
|
5
|
+
var analyticsOnlyConsent = ",C0001,C0002,";
|
|
6
|
+
var marketingOnlyConsent = ",C0001,C0004,";
|
|
7
|
+
var emptyConsent = "";
|
|
8
|
+
var customCategoryConsent = ",C0001,CUSTOM01,CUSTOM02,";
|
|
9
|
+
|
|
10
|
+
// src/examples/outputs.ts
|
|
11
|
+
var fullConsentMapped = {
|
|
12
|
+
functional: true,
|
|
13
|
+
analytics: true,
|
|
14
|
+
marketing: true
|
|
15
|
+
};
|
|
16
|
+
var partialConsentMapped = {
|
|
17
|
+
functional: true,
|
|
18
|
+
analytics: false,
|
|
19
|
+
marketing: false
|
|
20
|
+
};
|
|
21
|
+
var minimalConsentMapped = {
|
|
22
|
+
functional: true,
|
|
23
|
+
analytics: false,
|
|
24
|
+
marketing: false
|
|
25
|
+
};
|
|
26
|
+
var analyticsOnlyMapped = {
|
|
27
|
+
functional: true,
|
|
28
|
+
analytics: true,
|
|
29
|
+
marketing: false
|
|
30
|
+
};
|
|
31
|
+
var marketingOnlyMapped = {
|
|
32
|
+
functional: true,
|
|
33
|
+
analytics: false,
|
|
34
|
+
marketing: true
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/examples/env.ts
|
|
38
|
+
var noop = () => {
|
|
39
|
+
};
|
|
40
|
+
var createMockElbFn = () => {
|
|
41
|
+
const fn = (() => Promise.resolve({
|
|
42
|
+
ok: true
|
|
43
|
+
}));
|
|
44
|
+
return fn;
|
|
45
|
+
};
|
|
46
|
+
var noopLogger = {
|
|
47
|
+
error: noop,
|
|
48
|
+
info: noop,
|
|
49
|
+
debug: noop,
|
|
50
|
+
throw: (message) => {
|
|
51
|
+
throw typeof message === "string" ? new Error(message) : message;
|
|
52
|
+
},
|
|
53
|
+
scope: () => noopLogger
|
|
54
|
+
};
|
|
55
|
+
var createMockOneTrustAPI = (isAlertBoxClosed = false) => ({
|
|
56
|
+
IsAlertBoxClosed: () => isAlertBoxClosed
|
|
57
|
+
});
|
|
58
|
+
export {
|
|
59
|
+
analyticsOnlyConsent,
|
|
60
|
+
analyticsOnlyMapped,
|
|
61
|
+
createMockElbFn,
|
|
62
|
+
createMockOneTrustAPI,
|
|
63
|
+
customCategoryConsent,
|
|
64
|
+
emptyConsent,
|
|
65
|
+
fullConsent,
|
|
66
|
+
fullConsentMapped,
|
|
67
|
+
marketingOnlyConsent,
|
|
68
|
+
marketingOnlyMapped,
|
|
69
|
+
minimalConsent,
|
|
70
|
+
minimalConsentMapped,
|
|
71
|
+
noopLogger,
|
|
72
|
+
partialConsent,
|
|
73
|
+
partialConsentMapped
|
|
74
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var SourceCookiePro=(()=>{var e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,t=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r={};((n,t)=>{for(var o in t)e(n,o,{get:t[o],enumerable:!0})})(r,{DEFAULT_CATEGORY_MAP:()=>M,SourceCookiePro:()=>a,analyticsOnlyConsent:()=>p,analyticsOnlyMapped:()=>f,createMockElbFn:()=>b,createMockOneTrustAPI:()=>w,customCategoryConsent:()=>g,default:()=>T,emptyConsent:()=>C,fullConsent:()=>i,fullConsentMapped:()=>d,marketingOnlyConsent:()=>u,marketingOnlyMapped:()=>m,minimalConsent:()=>c,minimalConsentMapped:()=>O,noopLogger:()=>k,partialConsent:()=>s,partialConsentMapped:()=>y,sourceCookiePro:()=>h});var l,a={},i=",C0001,C0002,C0003,C0004,C0005,",s=",C0001,C0003,",c=",C0001,",p=",C0001,C0002,",u=",C0001,C0004,",C="",g=",C0001,CUSTOM01,CUSTOM02,",d={functional:!0,analytics:!0,marketing:!0},y={functional:!0,analytics:!1,marketing:!1},O={functional:!0,analytics:!1,marketing:!1},f={functional:!0,analytics:!0,marketing:!1},m={functional:!0,analytics:!1,marketing:!0},v=()=>{},b=()=>()=>Promise.resolve({ok:!0}),k={error:v,info:v,debug:v,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>k},w=(e=!1)=>({IsAlertBoxClosed:()=>e}),M={C0001:"functional",C0002:"analytics",C0003:"functional",C0004:"marketing",C0005:"marketing"},h=async e=>{var n,t,o,r,l,a,i,s;const{config:c,env:p}=e,{elb:u}=p,C=null!=(n=p.window)?n:void 0!==globalThis.window?globalThis.window:void 0,g={...M,...null!=(o=null==(t=null==c?void 0:c.settings)?void 0:t.categoryMap)?o:{}},d={};Object.entries(g).forEach(([e,n])=>{d[e.toLowerCase()]=n});const y={categoryMap:g,explicitOnly:null==(l=null==(r=null==c?void 0:c.settings)?void 0:r.explicitOnly)||l,globalName:null!=(i=null==(a=null==c?void 0:c.settings)?void 0:a.globalName)?i:"OneTrust"},O={settings:y};let f,m,v=!1;if(C){const e=null!=(s=y.globalName)?s:"OneTrust",n=new Set(Object.values(d)),t=e=>{const t={};return n.forEach(e=>{t[e]=!1}),e.split(",").filter(e=>e.length>0).forEach(e=>{const n=d[e.toLowerCase()];n&&(t[n]=!0)}),t},o=()=>{const n=C.OptanonActiveGroups;if(null==n)return;if(y.explicitOnly){const n=C[e];if((null==n?void 0:n.IsAlertBoxClosed)&&!n.IsAlertBoxClosed())return}const o=t(n);Object.keys(o).length>0&&u("walker consent",o)},r=C[e];r&&void 0!==C.OptanonActiveGroups&&o(),r||(m=C.OptanonWrapper,v=!0,C.OptanonWrapper=()=>{m&&m(),o(),C.OptanonWrapper=m,v=!1}),f=()=>{o()},C.addEventListener("OneTrustGroupsUpdated",f)}return{type:"cookiepro",config:O,push:u,destroy:async()=>{C&&f&&C.removeEventListener("OneTrustGroupsUpdated",f),C&&v&&(C.OptanonWrapper=m)}}},T=h;return l=r,((r,l,a,i)=>{if(l&&"object"==typeof l||"function"==typeof l)for(let s of t(l))o.call(r,s)||s===a||e(r,s,{get:()=>l[s],enumerable:!(i=n(l,s))||i.enumerable});return r})(e({},"__esModule",{value:!0}),l)})();
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { Source, Elb, WalkerOS, Logger } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OneTrust global API interface.
|
|
5
|
+
*
|
|
6
|
+
* Represents the subset of the OneTrust SDK we interact with.
|
|
7
|
+
* The full SDK is much larger, but we only need consent-related methods.
|
|
8
|
+
*/
|
|
9
|
+
interface OneTrustAPI {
|
|
10
|
+
/** Returns true if user has made an explicit consent choice */
|
|
11
|
+
IsAlertBoxClosed: () => boolean;
|
|
12
|
+
/** Register a callback for consent changes (callback receives event with detail: string[]) */
|
|
13
|
+
OnConsentChanged?: (fn: (event: {
|
|
14
|
+
detail: string[];
|
|
15
|
+
}) => void) => void;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
/** OneTrust SDK global object */
|
|
20
|
+
OneTrust?: OneTrustAPI;
|
|
21
|
+
/** Comma-separated string of active consent category IDs (e.g. ",C0001,C0003,") */
|
|
22
|
+
OptanonActiveGroups?: string;
|
|
23
|
+
/** OneTrust callback function, called on SDK load and consent changes */
|
|
24
|
+
OptanonWrapper?: () => void;
|
|
25
|
+
/** CookiePro legacy alias for OneTrust */
|
|
26
|
+
Optanon?: unknown;
|
|
27
|
+
[key: string]: OneTrustAPI | unknown;
|
|
28
|
+
}
|
|
29
|
+
interface WindowEventMap {
|
|
30
|
+
/** event.detail is an array of active group ID strings (e.g. ["C0001", "C0002"]) */
|
|
31
|
+
OneTrustGroupsUpdated: CustomEvent<string[]>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Settings for CookiePro/OneTrust source
|
|
36
|
+
*/
|
|
37
|
+
interface Settings {
|
|
38
|
+
/**
|
|
39
|
+
* Map CookiePro category IDs to walkerOS consent groups.
|
|
40
|
+
* Keys: CookiePro category IDs (e.g. 'C0001', 'C0002')
|
|
41
|
+
* Values: walkerOS consent group names
|
|
42
|
+
*
|
|
43
|
+
* Comparison is case-insensitive (keys are normalized to lowercase during init).
|
|
44
|
+
*
|
|
45
|
+
* Default provides sensible mapping for standard OneTrust categories:
|
|
46
|
+
* - C0001 (Strictly Necessary) -> functional
|
|
47
|
+
* - C0002 (Performance) -> analytics
|
|
48
|
+
* - C0003 (Functional) -> functional
|
|
49
|
+
* - C0004 (Targeting) -> marketing
|
|
50
|
+
* - C0005 (Social Media) -> marketing
|
|
51
|
+
*/
|
|
52
|
+
categoryMap?: Record<string, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Only process explicit consent (user made a choice).
|
|
55
|
+
* When true: Checks OneTrust.IsAlertBoxClosed() -- only processes
|
|
56
|
+
* consent if user has actively interacted with the banner.
|
|
57
|
+
* When false: Processes any consent state including defaults.
|
|
58
|
+
*
|
|
59
|
+
* Default: true
|
|
60
|
+
*/
|
|
61
|
+
explicitOnly?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Custom name for window.OneTrust object.
|
|
64
|
+
* Some implementations use a different global name.
|
|
65
|
+
*
|
|
66
|
+
* Default: 'OneTrust'
|
|
67
|
+
*/
|
|
68
|
+
globalName?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* User input settings (all optional)
|
|
72
|
+
*/
|
|
73
|
+
type InitSettings = Partial<Settings>;
|
|
74
|
+
/**
|
|
75
|
+
* No mapping configuration for this source
|
|
76
|
+
*/
|
|
77
|
+
interface Mapping {
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Push function type - uses elb for consent commands
|
|
81
|
+
*/
|
|
82
|
+
type Push = Elb.Fn;
|
|
83
|
+
/**
|
|
84
|
+
* Environment interface for CookiePro source
|
|
85
|
+
*/
|
|
86
|
+
interface Env extends Source.BaseEnv {
|
|
87
|
+
window?: Window & typeof globalThis;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Types bundle for CookiePro source
|
|
91
|
+
*/
|
|
92
|
+
type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;
|
|
93
|
+
/**
|
|
94
|
+
* Config type alias
|
|
95
|
+
*/
|
|
96
|
+
type Config = Source.Config<Types>;
|
|
97
|
+
|
|
98
|
+
type index_Config = Config;
|
|
99
|
+
type index_Env = Env;
|
|
100
|
+
type index_InitSettings = InitSettings;
|
|
101
|
+
type index_Mapping = Mapping;
|
|
102
|
+
type index_OneTrustAPI = OneTrustAPI;
|
|
103
|
+
type index_Push = Push;
|
|
104
|
+
type index_Settings = Settings;
|
|
105
|
+
type index_Types = Types;
|
|
106
|
+
declare namespace index {
|
|
107
|
+
export type { index_Config as Config, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_OneTrustAPI as OneTrustAPI, index_Push as Push, index_Settings as Settings, index_Types as Types };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Example CookiePro OptanonActiveGroups strings.
|
|
112
|
+
*
|
|
113
|
+
* These represent real consent states from CookiePro/OneTrust CMP.
|
|
114
|
+
* Format: comma-separated active category IDs with leading/trailing commas.
|
|
115
|
+
* Only active groups are listed. Absence means denied.
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* Full consent - user accepted all categories
|
|
119
|
+
*/
|
|
120
|
+
declare const fullConsent = ",C0001,C0002,C0003,C0004,C0005,";
|
|
121
|
+
/**
|
|
122
|
+
* Partial consent - necessary + functional only
|
|
123
|
+
*/
|
|
124
|
+
declare const partialConsent = ",C0001,C0003,";
|
|
125
|
+
/**
|
|
126
|
+
* Minimal consent - only strictly necessary (always active)
|
|
127
|
+
*/
|
|
128
|
+
declare const minimalConsent = ",C0001,";
|
|
129
|
+
/**
|
|
130
|
+
* Analytics only - necessary + performance
|
|
131
|
+
*/
|
|
132
|
+
declare const analyticsOnlyConsent = ",C0001,C0002,";
|
|
133
|
+
/**
|
|
134
|
+
* Marketing only - necessary + targeting
|
|
135
|
+
*/
|
|
136
|
+
declare const marketingOnlyConsent = ",C0001,C0004,";
|
|
137
|
+
/**
|
|
138
|
+
* Empty string - no consent yet or cleared
|
|
139
|
+
*/
|
|
140
|
+
declare const emptyConsent = "";
|
|
141
|
+
/**
|
|
142
|
+
* Custom category IDs - some installations use custom IDs
|
|
143
|
+
*/
|
|
144
|
+
declare const customCategoryConsent = ",C0001,CUSTOM01,CUSTOM02,";
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Expected walkerOS consent outputs.
|
|
148
|
+
*
|
|
149
|
+
* These represent the consent state after parsing OptanonActiveGroups
|
|
150
|
+
* and mapping through the default categoryMap.
|
|
151
|
+
*
|
|
152
|
+
* Default map:
|
|
153
|
+
* - C0001 -> functional
|
|
154
|
+
* - C0002 -> analytics
|
|
155
|
+
* - C0003 -> functional
|
|
156
|
+
* - C0004 -> marketing
|
|
157
|
+
* - C0005 -> marketing
|
|
158
|
+
*
|
|
159
|
+
* All mapped walkerOS groups get explicit true/false values.
|
|
160
|
+
* Active groups -> true, absent groups -> false.
|
|
161
|
+
*/
|
|
162
|
+
/**
|
|
163
|
+
* Full consent mapped to walkerOS groups
|
|
164
|
+
*/
|
|
165
|
+
declare const fullConsentMapped: WalkerOS.Consent;
|
|
166
|
+
/**
|
|
167
|
+
* Partial consent - necessary + functional mapped
|
|
168
|
+
* C0001 -> functional (true), C0003 -> functional (true)
|
|
169
|
+
* analytics and marketing absent -> false
|
|
170
|
+
*/
|
|
171
|
+
declare const partialConsentMapped: WalkerOS.Consent;
|
|
172
|
+
/**
|
|
173
|
+
* Minimal consent - only strictly necessary
|
|
174
|
+
* C0001 -> functional (true)
|
|
175
|
+
* analytics and marketing absent -> false
|
|
176
|
+
*/
|
|
177
|
+
declare const minimalConsentMapped: WalkerOS.Consent;
|
|
178
|
+
/**
|
|
179
|
+
* Analytics only - necessary + performance
|
|
180
|
+
* C0001 -> functional (true), C0002 -> analytics (true)
|
|
181
|
+
* marketing absent -> false
|
|
182
|
+
*/
|
|
183
|
+
declare const analyticsOnlyMapped: WalkerOS.Consent;
|
|
184
|
+
/**
|
|
185
|
+
* Marketing only - necessary + targeting
|
|
186
|
+
* C0001 -> functional (true), C0004 -> marketing (true)
|
|
187
|
+
* analytics absent -> false
|
|
188
|
+
*/
|
|
189
|
+
declare const marketingOnlyMapped: WalkerOS.Consent;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Create a properly typed elb/push function mock
|
|
193
|
+
*/
|
|
194
|
+
declare const createMockElbFn: () => Elb.Fn;
|
|
195
|
+
/**
|
|
196
|
+
* Simple no-op logger for demo purposes
|
|
197
|
+
*/
|
|
198
|
+
declare const noopLogger: Logger.Instance;
|
|
199
|
+
/**
|
|
200
|
+
* Create a mock OneTrust API object
|
|
201
|
+
*/
|
|
202
|
+
declare const createMockOneTrustAPI: (isAlertBoxClosed?: boolean) => OneTrustAPI;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Default category mapping from CookiePro/OneTrust to walkerOS consent groups.
|
|
206
|
+
*
|
|
207
|
+
* Keys use OneTrust's standard uppercase IDs (as shown in CookiePro dashboard).
|
|
208
|
+
* Lookups are case-insensitive (normalized during init).
|
|
209
|
+
*
|
|
210
|
+
* Maps OneTrust's standard category IDs to walkerOS convention:
|
|
211
|
+
* - C0001 (Strictly Necessary) -> functional
|
|
212
|
+
* - C0002 (Performance) -> analytics
|
|
213
|
+
* - C0003 (Functional) -> functional
|
|
214
|
+
* - C0004 (Targeting) -> marketing
|
|
215
|
+
* - C0005 (Social Media) -> marketing
|
|
216
|
+
*/
|
|
217
|
+
declare const DEFAULT_CATEGORY_MAP: Record<string, string>;
|
|
218
|
+
/**
|
|
219
|
+
* CookiePro/OneTrust consent management source for walkerOS.
|
|
220
|
+
*
|
|
221
|
+
* This source listens to CookiePro/OneTrust CMP events and translates
|
|
222
|
+
* consent states to walkerOS consent commands.
|
|
223
|
+
*
|
|
224
|
+
* Three detection paths:
|
|
225
|
+
* 1. Already loaded: window.OneTrust + window.OptanonActiveGroups
|
|
226
|
+
* 2. Init: Wraps OptanonWrapper (preserves existing)
|
|
227
|
+
* 3. Change: OneTrustGroupsUpdated window event
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* import { sourceCookiePro } from '@walkeros/web-source-cmp-cookiepro';
|
|
232
|
+
*
|
|
233
|
+
* await startFlow({
|
|
234
|
+
* sources: {
|
|
235
|
+
* consent: {
|
|
236
|
+
* code: sourceCookiePro,
|
|
237
|
+
* config: {
|
|
238
|
+
* settings: {
|
|
239
|
+
* categoryMap: {
|
|
240
|
+
* C0002: 'statistics', // Custom mapping
|
|
241
|
+
* },
|
|
242
|
+
* },
|
|
243
|
+
* },
|
|
244
|
+
* },
|
|
245
|
+
* },
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
declare const sourceCookiePro: Source.Init<Types>;
|
|
250
|
+
|
|
251
|
+
export { DEFAULT_CATEGORY_MAP, index as SourceCookiePro, analyticsOnlyConsent, analyticsOnlyMapped, createMockElbFn, createMockOneTrustAPI, customCategoryConsent, sourceCookiePro as default, emptyConsent, fullConsent, fullConsentMapped, marketingOnlyConsent, marketingOnlyMapped, minimalConsent, minimalConsentMapped, noopLogger, partialConsent, partialConsentMapped, sourceCookiePro };
|