@owlmeans/consent 0.1.18-rc.5 → 0.1.18-rc.7
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/build/consts.d.ts +10 -0
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +10 -0
- package/build/consts.js.map +1 -1
- package/build/gtm.d.ts +33 -0
- package/build/gtm.d.ts.map +1 -1
- package/build/gtm.js +69 -1
- package/build/gtm.js.map +1 -1
- package/build/i18n/be.json +3 -1
- package/build/i18n/de.json +3 -1
- package/build/i18n/en.json +3 -1
- package/build/i18n/es.json +3 -1
- package/build/i18n/fr.json +3 -1
- package/build/i18n/pl.json +3 -1
- package/build/i18n/ru.json +3 -1
- package/build/i18n/uk.json +3 -1
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/linker.d.ts +57 -0
- package/build/linker.d.ts.map +1 -0
- package/build/linker.js +252 -0
- package/build/linker.js.map +1 -0
- package/build/plugins.d.ts +55 -0
- package/build/plugins.d.ts.map +1 -0
- package/build/plugins.js +58 -0
- package/build/plugins.js.map +1 -0
- package/build/store.d.ts.map +1 -1
- package/build/store.js +24 -1
- package/build/store.js.map +1 -1
- package/build/types.d.ts +18 -0
- package/build/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +11 -0
- package/src/gtm.ts +80 -1
- package/src/i18n/be.json +3 -1
- package/src/i18n/de.json +3 -1
- package/src/i18n/en.json +3 -1
- package/src/i18n/es.json +3 -1
- package/src/i18n/fr.json +3 -1
- package/src/i18n/pl.json +3 -1
- package/src/i18n/ru.json +3 -1
- package/src/i18n/uk.json +3 -1
- package/src/index.ts +10 -0
- package/src/linker.ts +289 -0
- package/src/plugins.ts +104 -0
- package/src/store.ts +26 -1
- package/src/types.ts +19 -0
- package/tests/consent.spec.ts +33 -3
- package/tests/linker.spec.ts +352 -0
- package/tests/tracking.spec.ts +191 -0
package/build/consts.d.ts
CHANGED
|
@@ -17,6 +17,16 @@ export declare const CONSENT_COOKIE_DAYS = 365;
|
|
|
17
17
|
export declare const CONSENT_SCHEMA_VERSION = 2;
|
|
18
18
|
/** Idempotence flag for the Consent Mode defaults. Fixed: a page may carry two bundles. */
|
|
19
19
|
export declare const CONSENT_SETUP_FLAG = "cookieConsentSetup";
|
|
20
|
+
/**
|
|
21
|
+
* The DOM event `applyConsent` dispatches on `window` after it finishes writing globals and
|
|
22
|
+
* pushing the Consent Mode update.
|
|
23
|
+
*
|
|
24
|
+
* A loader that already ran (a gate script that decided, on first paint, not to load yet) has no
|
|
25
|
+
* other way to hear a LATER grant — Consent Mode itself speaks only on `window.dataLayer`, which a
|
|
26
|
+
* tag that has not loaded is not listening to. `event.detail.record` carries the record that was
|
|
27
|
+
* just applied.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CONSENT_EVENT = "owlmeans:consent";
|
|
20
30
|
export declare const CONSENT_ESSENTIAL = "essential";
|
|
21
31
|
export declare const CONSENT_ANALYTICS = "analytics";
|
|
22
32
|
export declare const CONSENT_MARKETING = "marketing";
|
package/build/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,WAAW,wBAAwB,CAAA;AAEhD,eAAO,MAAM,mBAAmB,MAAM,CAAA;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,2FAA2F;AAC3F,eAAO,MAAM,kBAAkB,uBAAuB,CAAA;AAEtD,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAC5C,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAE5C,eAAO,MAAM,eAAe,YAAI,IAAI,EA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AAQ,CAQxE,CAAA"}
|
package/build/consts.js
CHANGED
|
@@ -16,6 +16,16 @@ export const CONSENT_COOKIE_DAYS = 365;
|
|
|
16
16
|
export const CONSENT_SCHEMA_VERSION = 2;
|
|
17
17
|
/** Idempotence flag for the Consent Mode defaults. Fixed: a page may carry two bundles. */
|
|
18
18
|
export const CONSENT_SETUP_FLAG = 'cookieConsentSetup';
|
|
19
|
+
/**
|
|
20
|
+
* The DOM event `applyConsent` dispatches on `window` after it finishes writing globals and
|
|
21
|
+
* pushing the Consent Mode update.
|
|
22
|
+
*
|
|
23
|
+
* A loader that already ran (a gate script that decided, on first paint, not to load yet) has no
|
|
24
|
+
* other way to hear a LATER grant — Consent Mode itself speaks only on `window.dataLayer`, which a
|
|
25
|
+
* tag that has not loaded is not listening to. `event.detail.record` carries the record that was
|
|
26
|
+
* just applied.
|
|
27
|
+
*/
|
|
28
|
+
export const CONSENT_EVENT = 'owlmeans:consent';
|
|
19
29
|
export const CONSENT_ESSENTIAL = 'essential';
|
|
20
30
|
export const CONSENT_ANALYTICS = 'analytics';
|
|
21
31
|
export const CONSENT_MARKETING = 'marketing';
|
package/build/consts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAA;AAEhD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEvC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAA;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAE5C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AQ;IAC/B,uBAAuB,EAAE,QAAQ;IACjC,gBAAgB,EAAE,SAAS;CAC5B,CAAA"}
|
package/build/gtm.d.ts
CHANGED
|
@@ -26,6 +26,16 @@ export declare const pushConsentDefaults: (opts?: ConsentOptions) => void;
|
|
|
26
26
|
* turn, so writing them afterwards would let the first firing see the previous answer.
|
|
27
27
|
*/
|
|
28
28
|
export declare const applyConsent: (record: ConsentRecord, opts?: ConsentOptions) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Whether a stored decision grants tracking at all — a signal-bearing category, not merely the
|
|
31
|
+
* required essential one.
|
|
32
|
+
*
|
|
33
|
+
* "Signal-bearing" is what a required category can never be: it exists to gate whether a LOADER
|
|
34
|
+
* runs, and a required category is disclosure, not a question — everyone gets it. Only a category
|
|
35
|
+
* that both is optional and drives at least one Consent Mode signal counts, which is exactly what
|
|
36
|
+
* `googleTagHeadScript`'s `'basic'` mode gates a Google tag behind.
|
|
37
|
+
*/
|
|
38
|
+
export declare const trackingGranted: (record: ConsentRecord | null, categories?: ConsentCategory[]) => boolean;
|
|
29
39
|
/**
|
|
30
40
|
* The inline script a document stamps ABOVE its tag-manager snippet.
|
|
31
41
|
*
|
|
@@ -36,4 +46,27 @@ export declare const applyConsent: (record: ConsentRecord, opts?: ConsentOptions
|
|
|
36
46
|
* denied for the first paint of every page.
|
|
37
47
|
*/
|
|
38
48
|
export declare const consentBootstrapScript: (opts?: ConsentOptions) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Withhold a loader until a stored or later decision grants tracking.
|
|
51
|
+
*
|
|
52
|
+
* The counterpart to `consentBootstrapScript` for the `'basic'` gated loading mode
|
|
53
|
+
* (`@owlmeans/web-gtm`'s `GOOGLE_TAG_DEFAULT_MODE`): where the bootstrap always declares Consent
|
|
54
|
+
* Mode's defaults so a tag may load cookieless, this withholds the tag itself — the loader string
|
|
55
|
+
* is only ever reached once `trackingGranted` is true, either because a returning visitor's stored
|
|
56
|
+
* record already says so, or because `applyConsent` later dispatches {@link CONSENT_EVENT} with
|
|
57
|
+
* one that does. The listener removes itself on the first passing event, so the loader — which
|
|
58
|
+
* marks its own element and refuses to run twice — is asked to run at most once from here.
|
|
59
|
+
*
|
|
60
|
+
* `loaderExpr` is a complete statement or expression that runs the loader when reached — the
|
|
61
|
+
* self-invoking IIFE string `googleTagHeadScript`'s `gtagScript`/`gtmContainerScript` already
|
|
62
|
+
* produce, embedded here verbatim rather than called. It is placed inline exactly as
|
|
63
|
+
* `consentBootstrapScript`'s own output is: dynamic values (the storage key, the category shape,
|
|
64
|
+
* the event name) are JSON-encoded so nothing configured can break out of a string literal, and
|
|
65
|
+
* escaping the RESULT for HTML (`</script`, `<!--`) is left to whoever composes the final inline
|
|
66
|
+
* script — the same discipline `consentBootstrapScript` follows, and `googleTagHeadScript` already
|
|
67
|
+
* applies to the whole script it stamps.
|
|
68
|
+
*/
|
|
69
|
+
export declare const consentGateScript: (loaderExpr: string, opts?: ConsentOptions & {
|
|
70
|
+
categories?: ConsentCategory[];
|
|
71
|
+
}) => string;
|
|
39
72
|
//# sourceMappingURL=gtm.d.ts.map
|
package/build/gtm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtm.d.ts","sourceRoot":"","sources":["../src/gtm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gtm.d.ts","sourceRoot":"","sources":["../src/gtm.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAUhF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAUrD;AAKD,8EAA8E;AAC9E,eAAO,MAAM,eAAe,gBACb,eAAe,EAAE,KAC7B,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAMrC,CAAA;AAED,sDAAsD;AACtD,eAAO,MAAM,aAAa,WAChB,aAAa,eAAe,eAAe,EAAE,KACpD,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAWrC,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,UAAW,cAAc,KAAG,IAO3D,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,WAAY,aAAa,SAAS,cAAc,KAAG,IA6B3E,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,WAClB,aAAa,GAAG,IAAI,eAAc,eAAe,EAAE,KAC1D,OAEF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,UAAW,cAAc,KAAG,MA+B9D,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,iBAAiB,eAChB,MAAM,SAAS,cAAc,GAAG;IAAE,UAAU,CAAC,EAAE,eAAe,EAAE,CAAA;CAAE,KAC7E,MAuBF,CAAA"}
|
package/build/gtm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CONSENT_KEY, CONSENT_SETUP_FLAG, CONSENT_SIGNAL_DEFAULTS, DEFAULT_CONSENT_CATEGORIES, } from './consts.js';
|
|
1
|
+
import { CONSENT_EVENT, CONSENT_KEY, CONSENT_SETUP_FLAG, CONSENT_SIGNAL_DEFAULTS, DEFAULT_CONSENT_CATEGORIES, } from './consts.js';
|
|
2
|
+
import { consentLinkerScript } from './linker.js';
|
|
2
3
|
const global = () => typeof window !== 'undefined' ? window : null;
|
|
3
4
|
/**
|
|
4
5
|
* Push onto the tag-manager queue in the shape Google's own snippet uses.
|
|
@@ -77,7 +78,24 @@ export const applyConsent = (record, opts) => {
|
|
|
77
78
|
win.dataLayer.push({ event: category.event });
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
// A gate script (`consentGateScript`) that already decided NOT to load, because nothing was
|
|
82
|
+
// granted at the time it ran, has no other way to hear this. Consent Mode itself speaks only on
|
|
83
|
+
// `dataLayer`, which a tag that never loaded is not listening to.
|
|
84
|
+
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function'
|
|
85
|
+
&& typeof CustomEvent === 'function') {
|
|
86
|
+
window.dispatchEvent(new CustomEvent(CONSENT_EVENT, { detail: { record } }));
|
|
87
|
+
}
|
|
80
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Whether a stored decision grants tracking at all — a signal-bearing category, not merely the
|
|
91
|
+
* required essential one.
|
|
92
|
+
*
|
|
93
|
+
* "Signal-bearing" is what a required category can never be: it exists to gate whether a LOADER
|
|
94
|
+
* runs, and a required category is disclosure, not a question — everyone gets it. Only a category
|
|
95
|
+
* that both is optional and drives at least one Consent Mode signal counts, which is exactly what
|
|
96
|
+
* `googleTagHeadScript`'s `'basic'` mode gates a Google tag behind.
|
|
97
|
+
*/
|
|
98
|
+
export const trackingGranted = (record, categories = DEFAULT_CONSENT_CATEGORIES) => record != null && categories.some(category => !category.required && (category.signals?.length ?? 0) > 0 && record[category.key] === true);
|
|
81
99
|
/**
|
|
82
100
|
* The inline script a document stamps ABOVE its tag-manager snippet.
|
|
83
101
|
*
|
|
@@ -97,9 +115,16 @@ export const consentBootstrapScript = (opts) => {
|
|
|
97
115
|
})));
|
|
98
116
|
const storageKey = JSON.stringify(opts?.storageKey ?? CONSENT_KEY);
|
|
99
117
|
const flag = JSON.stringify(CONSENT_SETUP_FLAG);
|
|
118
|
+
// Right after the default is pushed and before EITHER storage read below (this one, and the
|
|
119
|
+
// `consentGateScript` that is concatenated after this whole IIFE) — an adopted decision must
|
|
120
|
+
// already be in storage by the time anything reads it, so `gtm.js`'s own `page_view` never sees
|
|
121
|
+
// the parameter and a granted decision loads the tag on arrival. A page with no `opts.linker`
|
|
122
|
+
// gets an empty string here, unchanged from before this existed.
|
|
123
|
+
const linker = opts?.linker != null ? `${consentLinkerScript(opts)};` : '';
|
|
100
124
|
return `(function(w,d){` +
|
|
101
125
|
`w.dataLayer=w.dataLayer||[];function g(){w.dataLayer.push(arguments)}` +
|
|
102
126
|
`if(w[${flag}])return;g('consent','default',${defaults});w[${flag}]=true;` +
|
|
127
|
+
linker +
|
|
103
128
|
`var raw=null;try{raw=w.localStorage.getItem(${storageKey})}catch(e){}` +
|
|
104
129
|
`if(!raw){var p=('; '+d.cookie).split('; '+${storageKey}+'=');` +
|
|
105
130
|
`if(p.length===2){raw=p.pop().split(';').shift()}}` +
|
|
@@ -111,4 +136,47 @@ export const consentBootstrapScript = (opts) => {
|
|
|
111
136
|
`u[s]=ok&&u[s]!=='denied'?'granted':'denied'}}` +
|
|
112
137
|
`g('consent','update',u)})(window,document)`;
|
|
113
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Withhold a loader until a stored or later decision grants tracking.
|
|
141
|
+
*
|
|
142
|
+
* The counterpart to `consentBootstrapScript` for the `'basic'` gated loading mode
|
|
143
|
+
* (`@owlmeans/web-gtm`'s `GOOGLE_TAG_DEFAULT_MODE`): where the bootstrap always declares Consent
|
|
144
|
+
* Mode's defaults so a tag may load cookieless, this withholds the tag itself — the loader string
|
|
145
|
+
* is only ever reached once `trackingGranted` is true, either because a returning visitor's stored
|
|
146
|
+
* record already says so, or because `applyConsent` later dispatches {@link CONSENT_EVENT} with
|
|
147
|
+
* one that does. The listener removes itself on the first passing event, so the loader — which
|
|
148
|
+
* marks its own element and refuses to run twice — is asked to run at most once from here.
|
|
149
|
+
*
|
|
150
|
+
* `loaderExpr` is a complete statement or expression that runs the loader when reached — the
|
|
151
|
+
* self-invoking IIFE string `googleTagHeadScript`'s `gtagScript`/`gtmContainerScript` already
|
|
152
|
+
* produce, embedded here verbatim rather than called. It is placed inline exactly as
|
|
153
|
+
* `consentBootstrapScript`'s own output is: dynamic values (the storage key, the category shape,
|
|
154
|
+
* the event name) are JSON-encoded so nothing configured can break out of a string literal, and
|
|
155
|
+
* escaping the RESULT for HTML (`</script`, `<!--`) is left to whoever composes the final inline
|
|
156
|
+
* script — the same discipline `consentBootstrapScript` follows, and `googleTagHeadScript` already
|
|
157
|
+
* applies to the whole script it stamps.
|
|
158
|
+
*/
|
|
159
|
+
export const consentGateScript = (loaderExpr, opts) => {
|
|
160
|
+
const gate = JSON.stringify(categoriesOf(opts).map(category => ({
|
|
161
|
+
key: category.key,
|
|
162
|
+
required: category.required === true,
|
|
163
|
+
hasSignal: (category.signals ?? []).length > 0,
|
|
164
|
+
})));
|
|
165
|
+
const storageKey = JSON.stringify(opts?.storageKey ?? CONSENT_KEY);
|
|
166
|
+
const event = JSON.stringify(CONSENT_EVENT);
|
|
167
|
+
return `(function(w,d){` +
|
|
168
|
+
`function ok(r){if(!r)return false;var cs=${gate};` +
|
|
169
|
+
`for(var i=0;i<cs.length;i++){var c=cs[i];` +
|
|
170
|
+
`if(!c.required&&c.hasSignal&&r[c.key]===true)return true}return false}` +
|
|
171
|
+
`function load(){${loaderExpr}}` +
|
|
172
|
+
`var raw=null;try{raw=w.localStorage.getItem(${storageKey})}catch(e){}` +
|
|
173
|
+
`if(!raw){var p=('; '+d.cookie).split('; '+${storageKey}+'=');` +
|
|
174
|
+
`if(p.length===2){raw=p.pop().split(';').shift()}}` +
|
|
175
|
+
`var r=null;if(raw){try{r=JSON.parse(raw)}catch(e){r=null}}` +
|
|
176
|
+
`if(ok(r)){load();return}` +
|
|
177
|
+
`function h(ev){if(ok(ev&&ev.detail&&ev.detail.record)){` +
|
|
178
|
+
`w.removeEventListener(${event},h);load()}}` +
|
|
179
|
+
`w.addEventListener(${event},h)` +
|
|
180
|
+
`})(window,document)`;
|
|
181
|
+
};
|
|
114
182
|
//# sourceMappingURL=gtm.js.map
|
package/build/gtm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gtm.js","sourceRoot":"","sources":["../src/gtm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"gtm.js","sourceRoot":"","sources":["../src/gtm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAAE,W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AU,cAAc;QACvE,6CAA6C,UAAU,QAAQ;QAC/D,mDAAmD;QACnD,6DAA6D;QAC7D,UAAU,UAAU,QAAQ;QAC5B,8EAA8E;QAC9E,oCAAoC;QACpC,yDAAyD;QACzD,+CAA+C;QAC/C,4CAA4C,CAAA;AAChD,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAkB,EAAE,IAA0D,EACtE,EAAE;IACV,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC9D,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,KAAK,IAAI;QACpC,SAAS,EAAE,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;KAC/C,CAAC,CAAC,CAAC,CAAA;IACJ,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,IAAI,WAAW,CAAC,CAAA;IAClE,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;IAE3C,OAAO,iBAAiB;QACtB,4CAA4C,IAAI,GAAG;QACnD,2CAA2C;QAC3C,wEAAwE;QACxE,mBAAmB,UAAU,GAAG;QAChC,+CAA+C,UAAU,cAAc;QACvE,6CAA6C,UAAU,QAAQ;QAC/D,mDAAmD;QACnD,4DAA4D;QAC5D,0BAA0B;QAC1B,yDAAyD;QACzD,yBAAyB,KAAK,cAAc;QAC5C,sBAAsB,KAAK,KAAK;QAChC,qBAAqB,CAAA;AACzB,CAAC,CAAA"}
|
package/build/i18n/be.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Файлы cookie",
|
|
31
31
|
"policyServicePrivacy": "Палітыка прыватнасці: {{provider}}",
|
|
32
32
|
"privacy": "Палітыка прыватнасці",
|
|
33
|
-
"terms": "Умовы карыстання"
|
|
33
|
+
"terms": "Умовы карыстання",
|
|
34
|
+
"domains": "Гэты выбар распаўсюджваецца на {{domains}}.",
|
|
35
|
+
"policyDomains": "Гэты выбар распаўсюджваецца на наступныя дамены:"
|
|
34
36
|
}
|
package/build/i18n/de.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Cookies",
|
|
31
31
|
"policyServicePrivacy": "Datenschutzerklärung von {{provider}}",
|
|
32
32
|
"privacy": "Datenschutzerklärung",
|
|
33
|
-
"terms": "Nutzungsbedingungen"
|
|
33
|
+
"terms": "Nutzungsbedingungen",
|
|
34
|
+
"domains": "Diese Wahl gilt für {{domains}}.",
|
|
35
|
+
"policyDomains": "Diese Wahl gilt für die folgenden Domains:"
|
|
34
36
|
}
|
package/build/i18n/en.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Cookies",
|
|
31
31
|
"policyServicePrivacy": "{{provider}} privacy policy",
|
|
32
32
|
"privacy": "Privacy Policy",
|
|
33
|
-
"terms": "Terms & Conditions"
|
|
33
|
+
"terms": "Terms & Conditions",
|
|
34
|
+
"domains": "This choice applies to {{domains}}.",
|
|
35
|
+
"policyDomains": "This choice applies across these domains:"
|
|
34
36
|
}
|
package/build/i18n/es.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Cookies",
|
|
31
31
|
"policyServicePrivacy": "Política de privacidad de {{provider}}",
|
|
32
32
|
"privacy": "Política de privacidad",
|
|
33
|
-
"terms": "Términos y condiciones"
|
|
33
|
+
"terms": "Términos y condiciones",
|
|
34
|
+
"domains": "Esta elección se aplica a {{domains}}.",
|
|
35
|
+
"policyDomains": "Esta elección se aplica a los siguientes dominios:"
|
|
34
36
|
}
|
package/build/i18n/fr.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Cookies",
|
|
31
31
|
"policyServicePrivacy": "Politique de confidentialité de {{provider}}",
|
|
32
32
|
"privacy": "Politique de confidentialité",
|
|
33
|
-
"terms": "Conditions générales"
|
|
33
|
+
"terms": "Conditions générales",
|
|
34
|
+
"domains": "Ce choix s'applique à {{domains}}.",
|
|
35
|
+
"policyDomains": "Ce choix s'applique aux domaines suivants :"
|
|
34
36
|
}
|
package/build/i18n/pl.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Pliki cookie",
|
|
31
31
|
"policyServicePrivacy": "Polityka prywatności: {{provider}}",
|
|
32
32
|
"privacy": "Polityka prywatności",
|
|
33
|
-
"terms": "Regulamin"
|
|
33
|
+
"terms": "Regulamin",
|
|
34
|
+
"domains": "Ten wybór dotyczy: {{domains}}.",
|
|
35
|
+
"policyDomains": "Ten wybór dotyczy następujących domen:"
|
|
34
36
|
}
|
package/build/i18n/ru.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Файлы cookie",
|
|
31
31
|
"policyServicePrivacy": "Политика конфиденциальности: {{provider}}",
|
|
32
32
|
"privacy": "Политика конфиденциальности",
|
|
33
|
-
"terms": "Условия использования"
|
|
33
|
+
"terms": "Условия использования",
|
|
34
|
+
"domains": "Этот выбор применяется к {{domains}}.",
|
|
35
|
+
"policyDomains": "Этот выбор применяется к следующим доменам:"
|
|
34
36
|
}
|
package/build/i18n/uk.json
CHANGED
|
@@ -30,5 +30,7 @@
|
|
|
30
30
|
"policyCookies": "Файли cookie",
|
|
31
31
|
"policyServicePrivacy": "Політика конфіденційності: {{provider}}",
|
|
32
32
|
"privacy": "Політика конфіденційності",
|
|
33
|
-
"terms": "Умови користування"
|
|
33
|
+
"terms": "Умови користування",
|
|
34
|
+
"domains": "Цей вибір застосовується до {{domains}}.",
|
|
35
|
+
"policyDomains": "Цей вибір застосовується до таких доменів:"
|
|
34
36
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -4,4 +4,8 @@ export * from './storage.js';
|
|
|
4
4
|
export * from './gtm.js';
|
|
5
5
|
export * from './store.js';
|
|
6
6
|
export * from './i18n.js';
|
|
7
|
+
export type { ConsentPlugin } from './plugins.js';
|
|
8
|
+
export { registerConsentPlugin, consentPlugins, decorateConsentUrl, consentDomains, adoptConsent, startConsentPlugins, } from './plugins.js';
|
|
9
|
+
export type { ConsentLinkPayload } from './linker.js';
|
|
10
|
+
export { consentLinker, encodeConsentLink, decodeConsentLink, stripConsentLinkParam, consentLinkerScript, CONSENT_LINK_PARAM, CONSENT_LINK_MAX_AGE, CONSENT_LINK_SKEW, } from './linker.js';
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EACL,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EACvF,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EACL,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAC/F,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,GAC5D,MAAM,aAAa,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -3,4 +3,6 @@ export * from './storage.js';
|
|
|
3
3
|
export * from './gtm.js';
|
|
4
4
|
export * from './store.js';
|
|
5
5
|
export * from './i18n.js';
|
|
6
|
+
export { registerConsentPlugin, consentPlugins, decorateConsentUrl, consentDomains, adoptConsent, startConsentPlugins, } from './plugins.js';
|
|
7
|
+
export { consentLinker, encodeConsentLink, decodeConsentLink, stripConsentLinkParam, consentLinkerScript, CONSENT_LINK_PARAM, CONSENT_LINK_MAX_AGE, CONSENT_LINK_SKEW, } from './linker.js';
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AAEzB,OAAO,EACL,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EACvF,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,aAAa,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAC/F,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,GAC5D,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ConsentPlugin } from './plugins.js';
|
|
2
|
+
import type { ConsentOptions, ConsentRecord } from './types.js';
|
|
3
|
+
/** The URL parameter a decorated link carries the decision in, absent an override. */
|
|
4
|
+
export declare const CONSENT_LINK_PARAM = "owlcc";
|
|
5
|
+
/** How old a decorated link's timestamp may be and still be trusted, in seconds, absent an override. */
|
|
6
|
+
export declare const CONSENT_LINK_MAX_AGE = 300;
|
|
7
|
+
/** Clock skew allowed the OTHER way — a timestamp up to this far in the future is still trusted. */
|
|
8
|
+
export declare const CONSENT_LINK_SKEW = 60;
|
|
9
|
+
declare const CONSENT_LINK_VERSION = 2;
|
|
10
|
+
/** The decoded, not-yet-validated payload a decorated link's parameter carries. */
|
|
11
|
+
export interface ConsentLinkPayload {
|
|
12
|
+
v: typeof CONSENT_LINK_VERSION;
|
|
13
|
+
/** One entry per OPTIONAL category this site knows, `1` granted / `0` denied. */
|
|
14
|
+
c: Record<string, 0 | 1>;
|
|
15
|
+
/** Unix seconds the link was decorated at. */
|
|
16
|
+
t: number;
|
|
17
|
+
}
|
|
18
|
+
/** The current document's decision, as the link parameter's `c`: one `0`/`1` per optional category. */
|
|
19
|
+
export declare const encodeConsentLink: (record: ConsentRecord, opts?: ConsentOptions) => string;
|
|
20
|
+
/** Parse-only — no trust decision here, that is `consentLinker(opts).adopt`'s job. Never throws. */
|
|
21
|
+
export declare const decodeConsentLink: (value: string) => ConsentLinkPayload | null;
|
|
22
|
+
/**
|
|
23
|
+
* Cross-domain consent: share this decision, and adopt one, between the domains named in
|
|
24
|
+
* `opts.linker.domains`.
|
|
25
|
+
*
|
|
26
|
+
* `start` decorates outgoing first-party links; `adopt` reads and validates an incoming one;
|
|
27
|
+
* `domains` discloses the list a dialog or policy page names. `decorate` is generic (a bare `URL`,
|
|
28
|
+
* no DOM) so the same trust rule serves a real anchor click and a programmatic navigation
|
|
29
|
+
* (`decorateConsentUrl`) alike — the `rel="noreferrer"` exemption is a DOM-only concept and is
|
|
30
|
+
* therefore checked by `start`'s click handler, never here.
|
|
31
|
+
*/
|
|
32
|
+
export declare const consentLinker: () => ConsentPlugin;
|
|
33
|
+
/**
|
|
34
|
+
* Remove the link parameter from the visible URL, keeping every other parameter and the hash — the
|
|
35
|
+
* real-TS equivalent of what {@link consentLinkerScript}'s embedded fragment already did inline.
|
|
36
|
+
* Idempotent: a page with no head script calls this from `consentStore.init` and it strips once; a
|
|
37
|
+
* page that ALSO carried the head script finds the parameter already gone and does nothing.
|
|
38
|
+
*/
|
|
39
|
+
export declare const stripConsentLinkParam: (opts: ConsentOptions) => void;
|
|
40
|
+
/**
|
|
41
|
+
* The inline `<head>` fragment that adopts a decorated link's decision and strips the parameter —
|
|
42
|
+
* standalone, so a page can stamp it even where nothing else here runs (a legal page with no tag
|
|
43
|
+
* script). `@owlmeans/web-gtm`'s `consentBootstrapScript` embeds this SAME fragment right after
|
|
44
|
+
* pushing Consent Mode's defaults, so a page that has both never runs it twice with different
|
|
45
|
+
* effect — the second attempt finds the parameter already gone and does nothing.
|
|
46
|
+
*
|
|
47
|
+
* Mirrors `consentLinker().adopt` exactly (v2, referrer + freshness/skew + full optional coverage +
|
|
48
|
+
* no existing record), but as hand-rolled JS text rather than a call into this module — the same
|
|
49
|
+
* discipline `consentBootstrapScript`/`consentGateScript` already follow, because this has to run
|
|
50
|
+
* before any bundle (this module included) has loaded. The parameter is ALWAYS stripped via
|
|
51
|
+
* `history.replaceState`, whether or not the trust rule accepts it: a stale or foreign `owlcc` is
|
|
52
|
+
* exactly as much noise as an adopted one, and neither belongs in the visible URL or in what a page
|
|
53
|
+
* reload, a shared link or a browser history entry carries forward.
|
|
54
|
+
*/
|
|
55
|
+
export declare const consentLinkerScript: (opts: ConsentOptions) => string;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=linker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../src/linker.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAGjD,OAAO,KAAK,EAAmB,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhF,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,UAAU,CAAA;AACzC,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,MAAM,CAAA;AACvC,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,KAAK,CAAA;AAEnC,QAAA,MAAM,oBAAoB,IAAI,CAAA;AAE9B,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,OAAO,oBAAoB,CAAA;IAC9B,iFAAiF;IACjF,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IACxB,8CAA8C;IAC9C,CAAC,EAAE,MAAM,CAAA;CACV;AAwBD,uGAAuG;AACvG,eAAO,MAAM,iBAAiB,WAAY,aAAa,SAAS,cAAc,KAAG,MAQhF,CAAA;AAED,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,UAAW,MAAM,KAAG,kBAAkB,GAAG,IAmBtE,CAAA;AAmBD;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,QAAO,aAgGhC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,SAAU,cAAc,KAAG,IAgB5D,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,SAAU,cAAc,KAAG,MA6C1D,CAAA"}
|