@walkeros/web-source-cmp-cookiefirst 1.1.0-next-1771252576264
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 +107 -0
- package/dist/dev.d.mts +149 -0
- package/dist/dev.d.ts +149 -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 +125 -0
- package/dist/examples/index.d.ts +125 -0
- package/dist/examples/index.js +161 -0
- package/dist/examples/index.mjs +119 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.d.mts +234 -0
- package/dist/index.d.ts +234 -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 +66 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { WalkerOS, Elb, Logger, Source } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CookieFirst consent object structure
|
|
5
|
+
*/
|
|
6
|
+
interface CookieFirstConsent {
|
|
7
|
+
necessary?: boolean;
|
|
8
|
+
functional?: boolean;
|
|
9
|
+
performance?: boolean;
|
|
10
|
+
advertising?: boolean;
|
|
11
|
+
[category: string]: boolean | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CookieFirst global API interface
|
|
15
|
+
*/
|
|
16
|
+
interface CookieFirstAPI {
|
|
17
|
+
consent: CookieFirstConsent | null;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
CookieFirst?: CookieFirstAPI;
|
|
22
|
+
[key: string]: CookieFirstAPI | unknown;
|
|
23
|
+
}
|
|
24
|
+
interface WindowEventMap {
|
|
25
|
+
cf_init: Event;
|
|
26
|
+
cf_consent: CustomEvent<CookieFirstConsent>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Example CookieFirst consent inputs.
|
|
32
|
+
*
|
|
33
|
+
* These represent real consent states from CookieFirst CMP.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* Full consent - user accepted all categories
|
|
37
|
+
*/
|
|
38
|
+
declare const fullConsent: CookieFirstConsent;
|
|
39
|
+
/**
|
|
40
|
+
* Partial consent - user accepted only necessary and functional
|
|
41
|
+
*/
|
|
42
|
+
declare const partialConsent: CookieFirstConsent;
|
|
43
|
+
/**
|
|
44
|
+
* Minimal consent - user accepted only necessary (required)
|
|
45
|
+
*/
|
|
46
|
+
declare const minimalConsent: CookieFirstConsent;
|
|
47
|
+
/**
|
|
48
|
+
* No consent - user hasn't made a choice yet
|
|
49
|
+
* CookieFirst returns null when no explicit choice has been made
|
|
50
|
+
*/
|
|
51
|
+
declare const noConsent: CookieFirstConsent | null;
|
|
52
|
+
/**
|
|
53
|
+
* Analytics only - user accepted performance tracking
|
|
54
|
+
*/
|
|
55
|
+
declare const analyticsOnlyConsent: CookieFirstConsent;
|
|
56
|
+
/**
|
|
57
|
+
* Marketing only - user accepted advertising
|
|
58
|
+
*/
|
|
59
|
+
declare const marketingOnlyConsent: CookieFirstConsent;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Expected walkerOS consent outputs.
|
|
63
|
+
*
|
|
64
|
+
* These represent the consent state after mapping CookieFirst categories
|
|
65
|
+
* to walkerOS consent groups using the default category map.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Full consent mapped to walkerOS groups
|
|
69
|
+
* (necessary + functional → functional, performance → analytics, advertising → marketing)
|
|
70
|
+
*/
|
|
71
|
+
declare const fullConsentMapped: WalkerOS.Consent;
|
|
72
|
+
/**
|
|
73
|
+
* Partial consent mapped to walkerOS groups
|
|
74
|
+
*/
|
|
75
|
+
declare const partialConsentMapped: WalkerOS.Consent;
|
|
76
|
+
/**
|
|
77
|
+
* Minimal consent mapped to walkerOS groups
|
|
78
|
+
*/
|
|
79
|
+
declare const minimalConsentMapped: WalkerOS.Consent;
|
|
80
|
+
/**
|
|
81
|
+
* Analytics only consent mapped to walkerOS groups
|
|
82
|
+
* Note: functional is true because necessary=true maps to functional
|
|
83
|
+
* (OR logic: if ANY source category is true, target group is true)
|
|
84
|
+
*/
|
|
85
|
+
declare const analyticsOnlyMapped: WalkerOS.Consent;
|
|
86
|
+
/**
|
|
87
|
+
* Marketing only consent mapped to walkerOS groups
|
|
88
|
+
* Note: functional is true because necessary=true maps to functional
|
|
89
|
+
* (OR logic: if ANY source category is true, target group is true)
|
|
90
|
+
*/
|
|
91
|
+
declare const marketingOnlyMapped: WalkerOS.Consent;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create a properly typed elb/push function mock that returns a promise with PushResult
|
|
95
|
+
*/
|
|
96
|
+
declare const createMockElbFn: () => Elb.Fn;
|
|
97
|
+
/**
|
|
98
|
+
* Simple no-op logger for demo purposes
|
|
99
|
+
*/
|
|
100
|
+
declare const noopLogger: Logger.Instance;
|
|
101
|
+
/**
|
|
102
|
+
* Environment interface for CookieFirst source
|
|
103
|
+
*/
|
|
104
|
+
interface CookieFirstEnv extends Source.BaseEnv {
|
|
105
|
+
window?: typeof window;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create a mock CookieFirst API object
|
|
109
|
+
*/
|
|
110
|
+
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent | null) => CookieFirstAPI;
|
|
111
|
+
/**
|
|
112
|
+
* Create a mock window object with CookieFirst
|
|
113
|
+
*/
|
|
114
|
+
declare const createMockWindow: (consent?: CookieFirstConsent | null) => Partial<Window> & {
|
|
115
|
+
CookieFirst: CookieFirstAPI;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Standard mock environment for testing CookieFirst source
|
|
119
|
+
*
|
|
120
|
+
* Use this for testing consent handling without requiring
|
|
121
|
+
* a real browser environment.
|
|
122
|
+
*/
|
|
123
|
+
declare const mockEnv: CookieFirstEnv;
|
|
124
|
+
|
|
125
|
+
export { analyticsOnlyConsent, analyticsOnlyMapped, createMockCookieFirstAPI, createMockElbFn, createMockWindow, fullConsent, fullConsentMapped, marketingOnlyConsent, marketingOnlyMapped, minimalConsent, minimalConsentMapped, mockEnv, noConsent, noopLogger, partialConsent, partialConsentMapped };
|
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
createMockCookieFirstAPI: () => createMockCookieFirstAPI,
|
|
26
|
+
createMockElbFn: () => createMockElbFn,
|
|
27
|
+
createMockWindow: () => createMockWindow,
|
|
28
|
+
fullConsent: () => fullConsent,
|
|
29
|
+
fullConsentMapped: () => fullConsentMapped,
|
|
30
|
+
marketingOnlyConsent: () => marketingOnlyConsent,
|
|
31
|
+
marketingOnlyMapped: () => marketingOnlyMapped,
|
|
32
|
+
minimalConsent: () => minimalConsent,
|
|
33
|
+
minimalConsentMapped: () => minimalConsentMapped,
|
|
34
|
+
mockEnv: () => mockEnv,
|
|
35
|
+
noConsent: () => noConsent,
|
|
36
|
+
noopLogger: () => noopLogger,
|
|
37
|
+
partialConsent: () => partialConsent,
|
|
38
|
+
partialConsentMapped: () => partialConsentMapped
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(examples_exports);
|
|
41
|
+
|
|
42
|
+
// src/examples/inputs.ts
|
|
43
|
+
var fullConsent = {
|
|
44
|
+
necessary: true,
|
|
45
|
+
functional: true,
|
|
46
|
+
performance: true,
|
|
47
|
+
advertising: true
|
|
48
|
+
};
|
|
49
|
+
var partialConsent = {
|
|
50
|
+
necessary: true,
|
|
51
|
+
functional: true,
|
|
52
|
+
performance: false,
|
|
53
|
+
advertising: false
|
|
54
|
+
};
|
|
55
|
+
var minimalConsent = {
|
|
56
|
+
necessary: true,
|
|
57
|
+
functional: false,
|
|
58
|
+
performance: false,
|
|
59
|
+
advertising: false
|
|
60
|
+
};
|
|
61
|
+
var noConsent = null;
|
|
62
|
+
var analyticsOnlyConsent = {
|
|
63
|
+
necessary: true,
|
|
64
|
+
functional: false,
|
|
65
|
+
performance: true,
|
|
66
|
+
advertising: false
|
|
67
|
+
};
|
|
68
|
+
var marketingOnlyConsent = {
|
|
69
|
+
necessary: true,
|
|
70
|
+
functional: false,
|
|
71
|
+
performance: false,
|
|
72
|
+
advertising: true
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// src/examples/outputs.ts
|
|
76
|
+
var fullConsentMapped = {
|
|
77
|
+
functional: true,
|
|
78
|
+
analytics: true,
|
|
79
|
+
marketing: true
|
|
80
|
+
};
|
|
81
|
+
var partialConsentMapped = {
|
|
82
|
+
functional: true,
|
|
83
|
+
analytics: false,
|
|
84
|
+
marketing: false
|
|
85
|
+
};
|
|
86
|
+
var minimalConsentMapped = {
|
|
87
|
+
functional: true,
|
|
88
|
+
analytics: false,
|
|
89
|
+
marketing: false
|
|
90
|
+
};
|
|
91
|
+
var analyticsOnlyMapped = {
|
|
92
|
+
functional: true,
|
|
93
|
+
analytics: true,
|
|
94
|
+
marketing: false
|
|
95
|
+
};
|
|
96
|
+
var marketingOnlyMapped = {
|
|
97
|
+
functional: true,
|
|
98
|
+
analytics: false,
|
|
99
|
+
marketing: true
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/examples/env.ts
|
|
103
|
+
var noop = () => {
|
|
104
|
+
};
|
|
105
|
+
var createMockElbFn = () => {
|
|
106
|
+
const fn = (() => Promise.resolve({
|
|
107
|
+
ok: true
|
|
108
|
+
}));
|
|
109
|
+
return fn;
|
|
110
|
+
};
|
|
111
|
+
var noopLogger = {
|
|
112
|
+
error: noop,
|
|
113
|
+
info: noop,
|
|
114
|
+
debug: noop,
|
|
115
|
+
throw: (message) => {
|
|
116
|
+
throw typeof message === "string" ? new Error(message) : message;
|
|
117
|
+
},
|
|
118
|
+
scope: () => noopLogger
|
|
119
|
+
};
|
|
120
|
+
var createMockCookieFirstAPI = (consent = null) => ({
|
|
121
|
+
consent
|
|
122
|
+
});
|
|
123
|
+
var createMockWindow = (consent = null) => ({
|
|
124
|
+
CookieFirst: createMockCookieFirstAPI(consent),
|
|
125
|
+
addEventListener: noop,
|
|
126
|
+
removeEventListener: noop
|
|
127
|
+
});
|
|
128
|
+
var mockEnv = {
|
|
129
|
+
get push() {
|
|
130
|
+
return createMockElbFn();
|
|
131
|
+
},
|
|
132
|
+
get command() {
|
|
133
|
+
return createMockElbFn();
|
|
134
|
+
},
|
|
135
|
+
get elb() {
|
|
136
|
+
return createMockElbFn();
|
|
137
|
+
},
|
|
138
|
+
get window() {
|
|
139
|
+
return createMockWindow();
|
|
140
|
+
},
|
|
141
|
+
logger: noopLogger
|
|
142
|
+
};
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
analyticsOnlyConsent,
|
|
146
|
+
analyticsOnlyMapped,
|
|
147
|
+
createMockCookieFirstAPI,
|
|
148
|
+
createMockElbFn,
|
|
149
|
+
createMockWindow,
|
|
150
|
+
fullConsent,
|
|
151
|
+
fullConsentMapped,
|
|
152
|
+
marketingOnlyConsent,
|
|
153
|
+
marketingOnlyMapped,
|
|
154
|
+
minimalConsent,
|
|
155
|
+
minimalConsentMapped,
|
|
156
|
+
mockEnv,
|
|
157
|
+
noConsent,
|
|
158
|
+
noopLogger,
|
|
159
|
+
partialConsent,
|
|
160
|
+
partialConsentMapped
|
|
161
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/examples/inputs.ts
|
|
2
|
+
var fullConsent = {
|
|
3
|
+
necessary: true,
|
|
4
|
+
functional: true,
|
|
5
|
+
performance: true,
|
|
6
|
+
advertising: true
|
|
7
|
+
};
|
|
8
|
+
var partialConsent = {
|
|
9
|
+
necessary: true,
|
|
10
|
+
functional: true,
|
|
11
|
+
performance: false,
|
|
12
|
+
advertising: false
|
|
13
|
+
};
|
|
14
|
+
var minimalConsent = {
|
|
15
|
+
necessary: true,
|
|
16
|
+
functional: false,
|
|
17
|
+
performance: false,
|
|
18
|
+
advertising: false
|
|
19
|
+
};
|
|
20
|
+
var noConsent = null;
|
|
21
|
+
var analyticsOnlyConsent = {
|
|
22
|
+
necessary: true,
|
|
23
|
+
functional: false,
|
|
24
|
+
performance: true,
|
|
25
|
+
advertising: false
|
|
26
|
+
};
|
|
27
|
+
var marketingOnlyConsent = {
|
|
28
|
+
necessary: true,
|
|
29
|
+
functional: false,
|
|
30
|
+
performance: false,
|
|
31
|
+
advertising: true
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/examples/outputs.ts
|
|
35
|
+
var fullConsentMapped = {
|
|
36
|
+
functional: true,
|
|
37
|
+
analytics: true,
|
|
38
|
+
marketing: true
|
|
39
|
+
};
|
|
40
|
+
var partialConsentMapped = {
|
|
41
|
+
functional: true,
|
|
42
|
+
analytics: false,
|
|
43
|
+
marketing: false
|
|
44
|
+
};
|
|
45
|
+
var minimalConsentMapped = {
|
|
46
|
+
functional: true,
|
|
47
|
+
analytics: false,
|
|
48
|
+
marketing: false
|
|
49
|
+
};
|
|
50
|
+
var analyticsOnlyMapped = {
|
|
51
|
+
functional: true,
|
|
52
|
+
analytics: true,
|
|
53
|
+
marketing: false
|
|
54
|
+
};
|
|
55
|
+
var marketingOnlyMapped = {
|
|
56
|
+
functional: true,
|
|
57
|
+
analytics: false,
|
|
58
|
+
marketing: true
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/examples/env.ts
|
|
62
|
+
var noop = () => {
|
|
63
|
+
};
|
|
64
|
+
var createMockElbFn = () => {
|
|
65
|
+
const fn = (() => Promise.resolve({
|
|
66
|
+
ok: true
|
|
67
|
+
}));
|
|
68
|
+
return fn;
|
|
69
|
+
};
|
|
70
|
+
var noopLogger = {
|
|
71
|
+
error: noop,
|
|
72
|
+
info: noop,
|
|
73
|
+
debug: noop,
|
|
74
|
+
throw: (message) => {
|
|
75
|
+
throw typeof message === "string" ? new Error(message) : message;
|
|
76
|
+
},
|
|
77
|
+
scope: () => noopLogger
|
|
78
|
+
};
|
|
79
|
+
var createMockCookieFirstAPI = (consent = null) => ({
|
|
80
|
+
consent
|
|
81
|
+
});
|
|
82
|
+
var createMockWindow = (consent = null) => ({
|
|
83
|
+
CookieFirst: createMockCookieFirstAPI(consent),
|
|
84
|
+
addEventListener: noop,
|
|
85
|
+
removeEventListener: noop
|
|
86
|
+
});
|
|
87
|
+
var mockEnv = {
|
|
88
|
+
get push() {
|
|
89
|
+
return createMockElbFn();
|
|
90
|
+
},
|
|
91
|
+
get command() {
|
|
92
|
+
return createMockElbFn();
|
|
93
|
+
},
|
|
94
|
+
get elb() {
|
|
95
|
+
return createMockElbFn();
|
|
96
|
+
},
|
|
97
|
+
get window() {
|
|
98
|
+
return createMockWindow();
|
|
99
|
+
},
|
|
100
|
+
logger: noopLogger
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
analyticsOnlyConsent,
|
|
104
|
+
analyticsOnlyMapped,
|
|
105
|
+
createMockCookieFirstAPI,
|
|
106
|
+
createMockElbFn,
|
|
107
|
+
createMockWindow,
|
|
108
|
+
fullConsent,
|
|
109
|
+
fullConsentMapped,
|
|
110
|
+
marketingOnlyConsent,
|
|
111
|
+
marketingOnlyMapped,
|
|
112
|
+
minimalConsent,
|
|
113
|
+
minimalConsentMapped,
|
|
114
|
+
mockEnv,
|
|
115
|
+
noConsent,
|
|
116
|
+
noopLogger,
|
|
117
|
+
partialConsent,
|
|
118
|
+
partialConsentMapped
|
|
119
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var SourceCookieFirst=(()=>{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:()=>E,SourceCookieFirst:()=>a,analyticsOnlyConsent:()=>f,analyticsOnlyMapped:()=>v,createMockCookieFirstAPI:()=>O,createMockElbFn:()=>b,createMockWindow:()=>w,default:()=>F,fullConsent:()=>l,fullConsentMapped:()=>d,marketingOnlyConsent:()=>g,marketingOnlyMapped:()=>m,minimalConsent:()=>c,minimalConsentMapped:()=>y,mockEnv:()=>M,noConsent:()=>u,noopLogger:()=>C,partialConsent:()=>s,partialConsentMapped:()=>p,sourceCookieFirst:()=>h});var i,a={},l={necessary:!0,functional:!0,performance:!0,advertising:!0},s={necessary:!0,functional:!0,performance:!1,advertising:!1},c={necessary:!0,functional:!1,performance:!1,advertising:!1},u=null,f={necessary:!0,functional:!1,performance:!0,advertising:!1},g={necessary:!0,functional:!1,performance:!1,advertising:!0},d={functional:!0,analytics:!0,marketing:!0},p={functional:!0,analytics:!1,marketing:!1},y={functional:!0,analytics:!1,marketing:!1},v={functional:!0,analytics:!0,marketing:!1},m={functional:!0,analytics:!1,marketing:!0},k=()=>{},b=()=>()=>Promise.resolve({ok:!0}),C={error:k,info:k,debug:k,throw:e=>{throw"string"==typeof e?new Error(e):e},scope:()=>C},O=(e=null)=>({consent:e}),w=(e=null)=>({CookieFirst:O(e),addEventListener:k,removeEventListener:k}),M={get push(){return b()},get command(){return b()},get elb(){return b()},get window(){return w()},logger:C},E={necessary:"functional",functional:"functional",performance:"analytics",advertising:"marketing"},h=async e=>{var n,t,o,r,i,a,l;const{config:s,env:c}=e,{elb:u}=c,f=null!=(n=c.window)?n:void 0!==globalThis.window?globalThis.window:void 0,g={categoryMap:{...E,...null==(t=null==s?void 0:s.settings)?void 0:t.categoryMap},explicitOnly:null==(r=null==(o=null==s?void 0:s.settings)?void 0:o.explicitOnly)||r,globalName:null!=(a=null==(i=null==s?void 0:s.settings)?void 0:i.globalName)?a:"CookieFirst"},d={settings:g};let p,y;if(f){const e=e=>{if(g.explicitOnly&&!e)return;if(!e)return;const n={};Object.entries(e).forEach(([e,t])=>{var o,r;if("boolean"!=typeof t)return;const i=null!=(r=null==(o=g.categoryMap)?void 0:o[e])?r:e;n[i]=n[i]||t}),Object.keys(n).length>0&&u("walker consent",n)},n=null!=(l=g.globalName)?l:"CookieFirst",t=f[n];(null==t?void 0:t.consent)&&e(t.consent),p=()=>{var t;const o=f[n];e(null!=(t=null==o?void 0:o.consent)?t:null)},f.addEventListener("cf_init",p),y=n=>{e(n.detail)},f.addEventListener("cf_consent",y)}return{type:"cookiefirst",config:d,push:u,destroy:async()=>{f&&p&&f.removeEventListener("cf_init",p),f&&y&&f.removeEventListener("cf_consent",y)}}},F=h;return i=r,((r,i,a,l)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let s of t(i))o.call(r,s)||s===a||e(r,s,{get:()=>i[s],enumerable:!(l=n(i,s))||l.enumerable});return r})(e({},"__esModule",{value:!0}),i)})();
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { Source, Elb, WalkerOS, Logger } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CookieFirst consent object structure
|
|
5
|
+
*/
|
|
6
|
+
interface CookieFirstConsent {
|
|
7
|
+
necessary?: boolean;
|
|
8
|
+
functional?: boolean;
|
|
9
|
+
performance?: boolean;
|
|
10
|
+
advertising?: boolean;
|
|
11
|
+
[category: string]: boolean | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CookieFirst global API interface
|
|
15
|
+
*/
|
|
16
|
+
interface CookieFirstAPI {
|
|
17
|
+
consent: CookieFirstConsent | null;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface Window {
|
|
21
|
+
CookieFirst?: CookieFirstAPI;
|
|
22
|
+
[key: string]: CookieFirstAPI | unknown;
|
|
23
|
+
}
|
|
24
|
+
interface WindowEventMap {
|
|
25
|
+
cf_init: Event;
|
|
26
|
+
cf_consent: CustomEvent<CookieFirstConsent>;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Settings for CookieFirst source
|
|
31
|
+
*/
|
|
32
|
+
interface Settings {
|
|
33
|
+
/**
|
|
34
|
+
* Map CookieFirst categories to walkerOS consent groups.
|
|
35
|
+
* Keys: CookieFirst category names
|
|
36
|
+
* Values: walkerOS consent group names
|
|
37
|
+
*
|
|
38
|
+
* Default maps to standard walkerOS groups:
|
|
39
|
+
* - necessary → functional
|
|
40
|
+
* - functional → functional
|
|
41
|
+
* - performance → analytics
|
|
42
|
+
* - advertising → marketing
|
|
43
|
+
*/
|
|
44
|
+
categoryMap?: Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Only process explicit consent (user made a choice).
|
|
47
|
+
* When true: Ignores consent if CookieFirst.consent is null
|
|
48
|
+
* When false: Processes any consent state including defaults
|
|
49
|
+
*
|
|
50
|
+
* Default: true
|
|
51
|
+
*/
|
|
52
|
+
explicitOnly?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Custom name for window.CookieFirst object.
|
|
55
|
+
* Some implementations use a different global name.
|
|
56
|
+
*
|
|
57
|
+
* Default: 'CookieFirst'
|
|
58
|
+
*/
|
|
59
|
+
globalName?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* User input settings (all optional)
|
|
63
|
+
*/
|
|
64
|
+
type InitSettings = Partial<Settings>;
|
|
65
|
+
/**
|
|
66
|
+
* No mapping configuration for this source
|
|
67
|
+
*/
|
|
68
|
+
interface Mapping {
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Push function type - uses elb for consent commands
|
|
72
|
+
*/
|
|
73
|
+
type Push = Elb.Fn;
|
|
74
|
+
/**
|
|
75
|
+
* Environment interface for CookieFirst source
|
|
76
|
+
*/
|
|
77
|
+
interface Env extends Source.BaseEnv {
|
|
78
|
+
window?: Window & typeof globalThis;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Types bundle for CookieFirst source
|
|
82
|
+
*/
|
|
83
|
+
type Types = Source.Types<Settings, Mapping, Push, Env, InitSettings>;
|
|
84
|
+
/**
|
|
85
|
+
* Config type alias
|
|
86
|
+
*/
|
|
87
|
+
type Config = Source.Config<Types>;
|
|
88
|
+
|
|
89
|
+
type index_Config = Config;
|
|
90
|
+
type index_CookieFirstAPI = CookieFirstAPI;
|
|
91
|
+
type index_CookieFirstConsent = CookieFirstConsent;
|
|
92
|
+
type index_Env = Env;
|
|
93
|
+
type index_InitSettings = InitSettings;
|
|
94
|
+
type index_Mapping = Mapping;
|
|
95
|
+
type index_Push = Push;
|
|
96
|
+
type index_Settings = Settings;
|
|
97
|
+
type index_Types = Types;
|
|
98
|
+
declare namespace index {
|
|
99
|
+
export type { index_Config as Config, index_CookieFirstAPI as CookieFirstAPI, index_CookieFirstConsent as CookieFirstConsent, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_Push as Push, index_Settings as Settings, index_Types as Types };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Example CookieFirst consent inputs.
|
|
104
|
+
*
|
|
105
|
+
* These represent real consent states from CookieFirst CMP.
|
|
106
|
+
*/
|
|
107
|
+
/**
|
|
108
|
+
* Full consent - user accepted all categories
|
|
109
|
+
*/
|
|
110
|
+
declare const fullConsent: CookieFirstConsent;
|
|
111
|
+
/**
|
|
112
|
+
* Partial consent - user accepted only necessary and functional
|
|
113
|
+
*/
|
|
114
|
+
declare const partialConsent: CookieFirstConsent;
|
|
115
|
+
/**
|
|
116
|
+
* Minimal consent - user accepted only necessary (required)
|
|
117
|
+
*/
|
|
118
|
+
declare const minimalConsent: CookieFirstConsent;
|
|
119
|
+
/**
|
|
120
|
+
* No consent - user hasn't made a choice yet
|
|
121
|
+
* CookieFirst returns null when no explicit choice has been made
|
|
122
|
+
*/
|
|
123
|
+
declare const noConsent: CookieFirstConsent | null;
|
|
124
|
+
/**
|
|
125
|
+
* Analytics only - user accepted performance tracking
|
|
126
|
+
*/
|
|
127
|
+
declare const analyticsOnlyConsent: CookieFirstConsent;
|
|
128
|
+
/**
|
|
129
|
+
* Marketing only - user accepted advertising
|
|
130
|
+
*/
|
|
131
|
+
declare const marketingOnlyConsent: CookieFirstConsent;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Expected walkerOS consent outputs.
|
|
135
|
+
*
|
|
136
|
+
* These represent the consent state after mapping CookieFirst categories
|
|
137
|
+
* to walkerOS consent groups using the default category map.
|
|
138
|
+
*/
|
|
139
|
+
/**
|
|
140
|
+
* Full consent mapped to walkerOS groups
|
|
141
|
+
* (necessary + functional → functional, performance → analytics, advertising → marketing)
|
|
142
|
+
*/
|
|
143
|
+
declare const fullConsentMapped: WalkerOS.Consent;
|
|
144
|
+
/**
|
|
145
|
+
* Partial consent mapped to walkerOS groups
|
|
146
|
+
*/
|
|
147
|
+
declare const partialConsentMapped: WalkerOS.Consent;
|
|
148
|
+
/**
|
|
149
|
+
* Minimal consent mapped to walkerOS groups
|
|
150
|
+
*/
|
|
151
|
+
declare const minimalConsentMapped: WalkerOS.Consent;
|
|
152
|
+
/**
|
|
153
|
+
* Analytics only consent mapped to walkerOS groups
|
|
154
|
+
* Note: functional is true because necessary=true maps to functional
|
|
155
|
+
* (OR logic: if ANY source category is true, target group is true)
|
|
156
|
+
*/
|
|
157
|
+
declare const analyticsOnlyMapped: WalkerOS.Consent;
|
|
158
|
+
/**
|
|
159
|
+
* Marketing only consent mapped to walkerOS groups
|
|
160
|
+
* Note: functional is true because necessary=true maps to functional
|
|
161
|
+
* (OR logic: if ANY source category is true, target group is true)
|
|
162
|
+
*/
|
|
163
|
+
declare const marketingOnlyMapped: WalkerOS.Consent;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Create a properly typed elb/push function mock that returns a promise with PushResult
|
|
167
|
+
*/
|
|
168
|
+
declare const createMockElbFn: () => Elb.Fn;
|
|
169
|
+
/**
|
|
170
|
+
* Simple no-op logger for demo purposes
|
|
171
|
+
*/
|
|
172
|
+
declare const noopLogger: Logger.Instance;
|
|
173
|
+
/**
|
|
174
|
+
* Environment interface for CookieFirst source
|
|
175
|
+
*/
|
|
176
|
+
interface CookieFirstEnv extends Source.BaseEnv {
|
|
177
|
+
window?: typeof window;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Create a mock CookieFirst API object
|
|
181
|
+
*/
|
|
182
|
+
declare const createMockCookieFirstAPI: (consent?: CookieFirstConsent | null) => CookieFirstAPI;
|
|
183
|
+
/**
|
|
184
|
+
* Create a mock window object with CookieFirst
|
|
185
|
+
*/
|
|
186
|
+
declare const createMockWindow: (consent?: CookieFirstConsent | null) => Partial<Window> & {
|
|
187
|
+
CookieFirst: CookieFirstAPI;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Standard mock environment for testing CookieFirst source
|
|
191
|
+
*
|
|
192
|
+
* Use this for testing consent handling without requiring
|
|
193
|
+
* a real browser environment.
|
|
194
|
+
*/
|
|
195
|
+
declare const mockEnv: CookieFirstEnv;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Default category mapping from CookieFirst to walkerOS consent groups.
|
|
199
|
+
*
|
|
200
|
+
* Maps CookieFirst's standard categories to walkerOS convention:
|
|
201
|
+
* - necessary/functional → functional (essential)
|
|
202
|
+
* - performance → analytics (measurement)
|
|
203
|
+
* - advertising → marketing (ads)
|
|
204
|
+
*/
|
|
205
|
+
declare const DEFAULT_CATEGORY_MAP: Record<string, string>;
|
|
206
|
+
/**
|
|
207
|
+
* CookieFirst consent management source for walkerOS.
|
|
208
|
+
*
|
|
209
|
+
* This source listens to CookieFirst CMP events and translates
|
|
210
|
+
* consent states to walkerOS consent commands.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* import { sourceCookieFirst } from '@walkeros/web-source-cmp-cookiefirst';
|
|
215
|
+
*
|
|
216
|
+
* await startFlow({
|
|
217
|
+
* sources: {
|
|
218
|
+
* consent: {
|
|
219
|
+
* code: sourceCookieFirst,
|
|
220
|
+
* config: {
|
|
221
|
+
* settings: {
|
|
222
|
+
* categoryMap: {
|
|
223
|
+
* performance: 'statistics', // Custom mapping
|
|
224
|
+
* },
|
|
225
|
+
* },
|
|
226
|
+
* },
|
|
227
|
+
* },
|
|
228
|
+
* },
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
declare const sourceCookieFirst: Source.Init<Types>;
|
|
233
|
+
|
|
234
|
+
export { DEFAULT_CATEGORY_MAP, index as SourceCookieFirst, analyticsOnlyConsent, analyticsOnlyMapped, createMockCookieFirstAPI, createMockElbFn, createMockWindow, sourceCookieFirst as default, fullConsent, fullConsentMapped, marketingOnlyConsent, marketingOnlyMapped, minimalConsent, minimalConsentMapped, mockEnv, noConsent, noopLogger, partialConsent, partialConsentMapped, sourceCookieFirst };
|