@referalli/sdk 0.0.0-stage → 0.3.20
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/CHANGELOG.md +128 -0
- package/LICENSE +21 -0
- package/README.md +236 -2
- package/dist/cjs/attribution.d.ts +105 -0
- package/dist/cjs/attribution.js +200 -0
- package/dist/cjs/browser.d.ts +41 -0
- package/dist/cjs/browser.js +88 -0
- package/dist/cjs/client.d.ts +97 -0
- package/dist/cjs/client.js +301 -0
- package/dist/cjs/consent/adapters/cookiebot.d.ts +7 -0
- package/dist/cjs/consent/adapters/cookiebot.js +49 -0
- package/dist/cjs/consent/adapters/cookiemunch.d.ts +8 -0
- package/dist/cjs/consent/adapters/cookiemunch.js +56 -0
- package/dist/cjs/consent/adapters/custom.d.ts +8 -0
- package/dist/cjs/consent/adapters/custom.js +39 -0
- package/dist/cjs/consent/adapters/didomi.d.ts +9 -0
- package/dist/cjs/consent/adapters/didomi.js +67 -0
- package/dist/cjs/consent/adapters/gcm.d.ts +10 -0
- package/dist/cjs/consent/adapters/gcm.js +78 -0
- package/dist/cjs/consent/adapters/gpp.d.ts +9 -0
- package/dist/cjs/consent/adapters/gpp.js +92 -0
- package/dist/cjs/consent/adapters/none.d.ts +3 -0
- package/dist/cjs/consent/adapters/none.js +30 -0
- package/dist/cjs/consent/adapters/onetrust.d.ts +8 -0
- package/dist/cjs/consent/adapters/onetrust.js +71 -0
- package/dist/cjs/consent/adapters/osano.d.ts +9 -0
- package/dist/cjs/consent/adapters/osano.js +71 -0
- package/dist/cjs/consent/adapters/tcf.d.ts +8 -0
- package/dist/cjs/consent/adapters/tcf.js +79 -0
- package/dist/cjs/consent/adapters/termly.d.ts +10 -0
- package/dist/cjs/consent/adapters/termly.js +61 -0
- package/dist/cjs/consent/adapters/usercentrics.d.ts +9 -0
- package/dist/cjs/consent/adapters/usercentrics.js +106 -0
- package/dist/cjs/consent/conformance.d.ts +22 -0
- package/dist/cjs/consent/conformance.js +33 -0
- package/dist/cjs/consent/gate.d.ts +23 -0
- package/dist/cjs/consent/gate.js +220 -0
- package/dist/cjs/consent/port.d.ts +105 -0
- package/dist/cjs/consent/port.js +72 -0
- package/dist/cjs/consent/registry.d.ts +17 -0
- package/dist/cjs/consent/registry.js +61 -0
- package/dist/cjs/consent/served.d.ts +15 -0
- package/dist/cjs/consent/served.js +26 -0
- package/dist/cjs/core.d.ts +77 -0
- package/dist/cjs/core.js +64 -0
- package/dist/cjs/errors.d.ts +42 -0
- package/dist/cjs/errors.generated.d.ts +183 -0
- package/dist/cjs/errors.generated.js +279 -0
- package/dist/cjs/errors.js +47 -0
- package/dist/cjs/generated.d.ts +15146 -0
- package/dist/cjs/generated.js +625 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +93 -0
- package/dist/cjs/mobile.d.ts +66 -0
- package/dist/cjs/mobile.js +69 -0
- package/dist/cjs/node.d.ts +209 -0
- package/dist/cjs/node.js +140 -0
- package/dist/cjs/outbox.d.ts +186 -0
- package/dist/cjs/outbox.js +324 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/resources.generated.d.ts +6002 -0
- package/dist/cjs/resources.generated.js +2090 -0
- package/dist/cjs/served.d.ts +25 -0
- package/dist/cjs/served.js +214 -0
- package/dist/cjs/sha256.d.ts +2 -0
- package/dist/cjs/sha256.js +86 -0
- package/dist/cjs/snippet.d.ts +99 -0
- package/dist/cjs/snippet.js +213 -0
- package/dist/cjs/stripe-events.d.ts +25 -0
- package/dist/cjs/stripe-events.js +117 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/webhooks.d.ts +76 -0
- package/dist/cjs/webhooks.js +159 -0
- package/dist/esm/attribution.d.ts +105 -0
- package/dist/esm/attribution.js +186 -0
- package/dist/esm/browser.d.ts +41 -0
- package/dist/esm/browser.js +68 -0
- package/dist/esm/client.d.ts +97 -0
- package/dist/esm/client.js +297 -0
- package/dist/esm/consent/adapters/cookiebot.d.ts +7 -0
- package/dist/esm/consent/adapters/cookiebot.js +46 -0
- package/dist/esm/consent/adapters/cookiemunch.d.ts +8 -0
- package/dist/esm/consent/adapters/cookiemunch.js +53 -0
- package/dist/esm/consent/adapters/custom.d.ts +8 -0
- package/dist/esm/consent/adapters/custom.js +36 -0
- package/dist/esm/consent/adapters/didomi.d.ts +9 -0
- package/dist/esm/consent/adapters/didomi.js +64 -0
- package/dist/esm/consent/adapters/gcm.d.ts +10 -0
- package/dist/esm/consent/adapters/gcm.js +75 -0
- package/dist/esm/consent/adapters/gpp.d.ts +9 -0
- package/dist/esm/consent/adapters/gpp.js +89 -0
- package/dist/esm/consent/adapters/none.d.ts +3 -0
- package/dist/esm/consent/adapters/none.js +27 -0
- package/dist/esm/consent/adapters/onetrust.d.ts +8 -0
- package/dist/esm/consent/adapters/onetrust.js +68 -0
- package/dist/esm/consent/adapters/osano.d.ts +9 -0
- package/dist/esm/consent/adapters/osano.js +68 -0
- package/dist/esm/consent/adapters/tcf.d.ts +8 -0
- package/dist/esm/consent/adapters/tcf.js +76 -0
- package/dist/esm/consent/adapters/termly.d.ts +10 -0
- package/dist/esm/consent/adapters/termly.js +58 -0
- package/dist/esm/consent/adapters/usercentrics.d.ts +9 -0
- package/dist/esm/consent/adapters/usercentrics.js +103 -0
- package/dist/esm/consent/conformance.d.ts +22 -0
- package/dist/esm/consent/conformance.js +30 -0
- package/dist/esm/consent/gate.d.ts +23 -0
- package/dist/esm/consent/gate.js +217 -0
- package/dist/esm/consent/port.d.ts +105 -0
- package/dist/esm/consent/port.js +67 -0
- package/dist/esm/consent/registry.d.ts +17 -0
- package/dist/esm/consent/registry.js +55 -0
- package/dist/esm/consent/served.d.ts +15 -0
- package/dist/esm/consent/served.js +22 -0
- package/dist/esm/core.d.ts +77 -0
- package/dist/esm/core.js +60 -0
- package/dist/esm/errors.d.ts +42 -0
- package/dist/esm/errors.generated.d.ts +183 -0
- package/dist/esm/errors.generated.js +231 -0
- package/dist/esm/errors.js +40 -0
- package/dist/esm/generated.d.ts +15146 -0
- package/dist/esm/generated.js +622 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/mobile.d.ts +66 -0
- package/dist/esm/mobile.js +64 -0
- package/dist/esm/node.d.ts +209 -0
- package/dist/esm/node.js +135 -0
- package/dist/esm/outbox.d.ts +186 -0
- package/dist/esm/outbox.js +316 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/resources.generated.d.ts +6002 -0
- package/dist/esm/resources.generated.js +2086 -0
- package/dist/esm/served.d.ts +25 -0
- package/dist/esm/served.js +207 -0
- package/dist/esm/sha256.d.ts +2 -0
- package/dist/esm/sha256.js +82 -0
- package/dist/esm/snippet.d.ts +99 -0
- package/dist/esm/snippet.js +210 -0
- package/dist/esm/stripe-events.d.ts +25 -0
- package/dist/esm/stripe-events.js +114 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/webhooks.d.ts +76 -0
- package/dist/esm/webhooks.js +153 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/package.json +105 -4
- package/src/attribution.ts +216 -0
- package/src/browser.ts +107 -0
- package/src/client.ts +351 -0
- package/src/codegen.ts +130 -0
- package/src/consent/adapters/cookiebot.ts +42 -0
- package/src/consent/adapters/cookiemunch.ts +49 -0
- package/src/consent/adapters/custom.ts +37 -0
- package/src/consent/adapters/didomi.ts +59 -0
- package/src/consent/adapters/gcm.ts +68 -0
- package/src/consent/adapters/gpp.ts +81 -0
- package/src/consent/adapters/none.ts +28 -0
- package/src/consent/adapters/onetrust.ts +64 -0
- package/src/consent/adapters/osano.ts +63 -0
- package/src/consent/adapters/tcf.ts +67 -0
- package/src/consent/adapters/termly.ts +54 -0
- package/src/consent/adapters/usercentrics.ts +97 -0
- package/src/consent/conformance.ts +47 -0
- package/src/consent/gate.ts +216 -0
- package/src/consent/port.ts +148 -0
- package/src/consent/registry.ts +60 -0
- package/src/consent/served.ts +24 -0
- package/src/core.ts +127 -0
- package/src/errors.generated.ts +277 -0
- package/src/errors.ts +57 -0
- package/src/generated.ts +14540 -0
- package/src/index.ts +100 -0
- package/src/mobile.ts +96 -0
- package/src/node.ts +291 -0
- package/src/outbox.ts +452 -0
- package/src/resources.generated.ts +2097 -0
- package/src/served.ts +229 -0
- package/src/sha256.ts +82 -0
- package/src/snippet.ts +305 -0
- package/src/stripe-events.ts +130 -0
- package/src/version.ts +2 -0
- package/src/webhooks.ts +207 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* IAB GPP: `__gpp('addEventListener', cb)` and `__gpp('ping', cb)`. Waits for
|
|
4
|
+
* `signalStatus: 'ready'`. The EU TCF section (id 2) follows the `tcf`
|
|
5
|
+
* rules (purpose 1 plus 7 or 9); US state sections are opt-out, so any
|
|
6
|
+
* `SaleOptOut`, `SharingOptOut` or `TargetedAdvertisingOptOut` of 1 (opted
|
|
7
|
+
* out) denies and anything else grants. Evidence: `gppString`.
|
|
8
|
+
*/
|
|
9
|
+
export const gpp = {
|
|
10
|
+
id: 'gpp',
|
|
11
|
+
name: 'IAB GPP',
|
|
12
|
+
defaultCategory: null,
|
|
13
|
+
status: 'beta',
|
|
14
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#gpp',
|
|
15
|
+
vendorDocsUrl: 'https://github.com/InteractiveAdvertisingBureau/Global-Privacy-Platform',
|
|
16
|
+
check: (cfg) => browserCheck(gpp, cfg),
|
|
17
|
+
factory: function gppConsent(w) {
|
|
18
|
+
let ping = null;
|
|
19
|
+
let listening = false;
|
|
20
|
+
const subs = [];
|
|
21
|
+
function set(p) {
|
|
22
|
+
if (!p || typeof p !== 'object')
|
|
23
|
+
return;
|
|
24
|
+
ping = p;
|
|
25
|
+
const list = subs.slice();
|
|
26
|
+
for (let i = 0; i < list.length; i++)
|
|
27
|
+
list[i]();
|
|
28
|
+
}
|
|
29
|
+
function listen() {
|
|
30
|
+
if (listening || typeof w.__gpp !== 'function')
|
|
31
|
+
return;
|
|
32
|
+
listening = true;
|
|
33
|
+
w.__gpp('addEventListener', function (ev, ok) {
|
|
34
|
+
if (ok !== false && ev)
|
|
35
|
+
set(ev.pingData || null);
|
|
36
|
+
});
|
|
37
|
+
w.__gpp('ping', function (p, ok) {
|
|
38
|
+
if (ok !== false)
|
|
39
|
+
set(p);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function seg(s) {
|
|
43
|
+
return Array.isArray(s) ? s[0] : s;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
detect() {
|
|
47
|
+
return typeof w.__gpp === 'function';
|
|
48
|
+
},
|
|
49
|
+
state() {
|
|
50
|
+
listen();
|
|
51
|
+
if (!ping || ping.signalStatus !== 'ready')
|
|
52
|
+
return 'unknown';
|
|
53
|
+
const secs = ping.parsedSections || {};
|
|
54
|
+
const applicable = ping.applicableSections || [];
|
|
55
|
+
const eu = seg(secs.tcfeuv2);
|
|
56
|
+
if (applicable.indexOf(2) >= 0 && eu) {
|
|
57
|
+
const pc = eu.PurposeConsent || [];
|
|
58
|
+
const p = function (n) {
|
|
59
|
+
return !!(pc[n - 1] === true || pc[n - 1] === 1);
|
|
60
|
+
};
|
|
61
|
+
return p(1) && (p(7) || p(9)) ? 'granted' : 'denied';
|
|
62
|
+
}
|
|
63
|
+
for (const k in secs) {
|
|
64
|
+
if (k === 'tcfeuv2' || k === 'tcfcav1')
|
|
65
|
+
continue;
|
|
66
|
+
const s = seg(secs[k]);
|
|
67
|
+
if (s && typeof s === 'object' && (s.SaleOptOut === 1 || s.SharingOptOut === 1 || s.TargetedAdvertisingOptOut === 1)) {
|
|
68
|
+
return 'denied';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return 'granted';
|
|
72
|
+
},
|
|
73
|
+
subscribe(_cfg, cb) {
|
|
74
|
+
subs.push(cb);
|
|
75
|
+
listen();
|
|
76
|
+
return function () {
|
|
77
|
+
const i = subs.indexOf(cb);
|
|
78
|
+
if (i >= 0)
|
|
79
|
+
subs.splice(i, 1);
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
evidence() {
|
|
83
|
+
if (!ping)
|
|
84
|
+
return null;
|
|
85
|
+
return { gppString: typeof ping.gppString === 'string' ? ping.gppString : undefined };
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/** No consent check: always granted (the tracker before consent support). Only for sites that need no opt-in. */
|
|
3
|
+
export const none = {
|
|
4
|
+
id: 'none',
|
|
5
|
+
name: 'None (always store)',
|
|
6
|
+
defaultCategory: null,
|
|
7
|
+
status: 'ga',
|
|
8
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#choose-a-mode',
|
|
9
|
+
vendorDocsUrl: 'https://referalli.com/docs/tracking-consent#choose-a-mode',
|
|
10
|
+
check: (cfg) => browserCheck(none, cfg),
|
|
11
|
+
factory: function noneConsent() {
|
|
12
|
+
return {
|
|
13
|
+
detect() {
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
state() {
|
|
17
|
+
return 'granted';
|
|
18
|
+
},
|
|
19
|
+
subscribe() {
|
|
20
|
+
return function () { };
|
|
21
|
+
},
|
|
22
|
+
evidence() {
|
|
23
|
+
return {};
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ConsentSource } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* OneTrust: `window.OnetrustActiveGroups` (",C0001,C0004,"),
|
|
4
|
+
* `OneTrust.OnConsentChanged` and the `OneTrustGroupsUpdated` window event.
|
|
5
|
+
* Group `C0004` (targeting) by default. An inactive group counts as denied
|
|
6
|
+
* only once the banner was closed (`OneTrust.IsAlertBoxClosed()`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const onetrust: ConsentSource;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* OneTrust: `window.OnetrustActiveGroups` (",C0001,C0004,"),
|
|
4
|
+
* `OneTrust.OnConsentChanged` and the `OneTrustGroupsUpdated` window event.
|
|
5
|
+
* Group `C0004` (targeting) by default. An inactive group counts as denied
|
|
6
|
+
* only once the banner was closed (`OneTrust.IsAlertBoxClosed()`).
|
|
7
|
+
*/
|
|
8
|
+
export const onetrust = {
|
|
9
|
+
id: 'onetrust',
|
|
10
|
+
name: 'OneTrust',
|
|
11
|
+
defaultCategory: 'C0004',
|
|
12
|
+
status: 'ga',
|
|
13
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#onetrust',
|
|
14
|
+
vendorDocsUrl: 'https://developer.onetrust.com/',
|
|
15
|
+
check: (cfg) => browserCheck(onetrust, cfg),
|
|
16
|
+
factory: function onetrustConsent(w) {
|
|
17
|
+
function groups() {
|
|
18
|
+
return typeof w.OnetrustActiveGroups === 'string' ? w.OnetrustActiveGroups : null;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
detect() {
|
|
22
|
+
return !!(w.OneTrust || w.OneTrustStub || groups() !== null);
|
|
23
|
+
},
|
|
24
|
+
state(cfg) {
|
|
25
|
+
const g = groups();
|
|
26
|
+
if (g === null)
|
|
27
|
+
return 'unknown';
|
|
28
|
+
if ((',' + g + ',').indexOf(',' + (cfg.category || 'C0004') + ',') >= 0)
|
|
29
|
+
return 'granted';
|
|
30
|
+
const ot = w.OneTrust;
|
|
31
|
+
const closed = ot && typeof ot.IsAlertBoxClosed === 'function'
|
|
32
|
+
? ot.IsAlertBoxClosed() === true
|
|
33
|
+
: /(?:^|;\s*)OptanonAlertBoxClosed=/.test((w.document && w.document.cookie) || '');
|
|
34
|
+
return closed ? 'denied' : 'unknown';
|
|
35
|
+
},
|
|
36
|
+
subscribe(_cfg, cb) {
|
|
37
|
+
let off = false;
|
|
38
|
+
const fire = function () {
|
|
39
|
+
if (!off)
|
|
40
|
+
cb();
|
|
41
|
+
};
|
|
42
|
+
w.addEventListener('OneTrustGroupsUpdated', fire);
|
|
43
|
+
try {
|
|
44
|
+
if (w.OneTrust && typeof w.OneTrust.OnConsentChanged === 'function')
|
|
45
|
+
w.OneTrust.OnConsentChanged(fire);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
/* the event covers it */
|
|
49
|
+
}
|
|
50
|
+
return function () {
|
|
51
|
+
off = true;
|
|
52
|
+
w.removeEventListener('OneTrustGroupsUpdated', fire);
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
evidence() {
|
|
56
|
+
const g = groups();
|
|
57
|
+
const out = { purposes: g ? g.split(',').filter(Boolean) : [] };
|
|
58
|
+
const ot = w.OneTrust;
|
|
59
|
+
if (ot && typeof ot.getDataSubjectId === 'function') {
|
|
60
|
+
const id = ot.getDataSubjectId();
|
|
61
|
+
if (id)
|
|
62
|
+
out.stamp = String(id);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ConsentSource } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Osano: `Osano.cm.getConsent()` (`MARKETING: 'ACCEPT' | 'DENY'`, …) and the
|
|
4
|
+
* `osano-cm-consent-saved` / `osano-cm-consent-changed` events. Category
|
|
5
|
+
* `MARKETING` by default. `DENY` counts as denied only once a choice was saved
|
|
6
|
+
* (the event, or Osano's `osano_consentmanager` record); before that it is
|
|
7
|
+
* Osano's opt-in default, so no decision.
|
|
8
|
+
*/
|
|
9
|
+
export declare const osano: ConsentSource;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Osano: `Osano.cm.getConsent()` (`MARKETING: 'ACCEPT' | 'DENY'`, …) and the
|
|
4
|
+
* `osano-cm-consent-saved` / `osano-cm-consent-changed` events. Category
|
|
5
|
+
* `MARKETING` by default. `DENY` counts as denied only once a choice was saved
|
|
6
|
+
* (the event, or Osano's `osano_consentmanager` record); before that it is
|
|
7
|
+
* Osano's opt-in default, so no decision.
|
|
8
|
+
*/
|
|
9
|
+
export const osano = {
|
|
10
|
+
id: 'osano',
|
|
11
|
+
name: 'Osano',
|
|
12
|
+
defaultCategory: 'MARKETING',
|
|
13
|
+
status: 'beta',
|
|
14
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#osano',
|
|
15
|
+
vendorDocsUrl: 'https://developers.osano.com/',
|
|
16
|
+
check: (cfg) => browserCheck(osano, cfg),
|
|
17
|
+
factory: function osanoConsent(w) {
|
|
18
|
+
let saved = false;
|
|
19
|
+
function stored() {
|
|
20
|
+
try {
|
|
21
|
+
if (w.localStorage && w.localStorage.getItem('osano_consentmanager'))
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* storage blocked */
|
|
26
|
+
}
|
|
27
|
+
return /(?:^|;\s*)osano_consentmanager=/.test((w.document && w.document.cookie) || '');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
detect() {
|
|
31
|
+
return !!(w.Osano && w.Osano.cm);
|
|
32
|
+
},
|
|
33
|
+
state(cfg) {
|
|
34
|
+
const cm = w.Osano && w.Osano.cm;
|
|
35
|
+
if (!cm || typeof cm.getConsent !== 'function')
|
|
36
|
+
return 'unknown';
|
|
37
|
+
const c = cm.getConsent() || {};
|
|
38
|
+
if (c[cfg.category || 'MARKETING'] === 'ACCEPT')
|
|
39
|
+
return 'granted';
|
|
40
|
+
return saved || stored() ? 'denied' : 'unknown';
|
|
41
|
+
},
|
|
42
|
+
subscribe(_cfg, cb) {
|
|
43
|
+
let off = false;
|
|
44
|
+
const cm = w.Osano && w.Osano.cm;
|
|
45
|
+
const onSave = function () {
|
|
46
|
+
saved = true;
|
|
47
|
+
if (!off)
|
|
48
|
+
cb();
|
|
49
|
+
};
|
|
50
|
+
const onChange = function () {
|
|
51
|
+
if (!off)
|
|
52
|
+
cb();
|
|
53
|
+
};
|
|
54
|
+
if (cm && typeof cm.addEventListener === 'function') {
|
|
55
|
+
cm.addEventListener('osano-cm-consent-saved', onSave);
|
|
56
|
+
cm.addEventListener('osano-cm-consent-changed', onSave);
|
|
57
|
+
cm.addEventListener('osano-cm-initialized', onChange);
|
|
58
|
+
}
|
|
59
|
+
return function () {
|
|
60
|
+
off = true;
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
evidence(cfg) {
|
|
64
|
+
return { purposes: [cfg.category || 'MARKETING'] };
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ConsentSource } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* IAB TCF v2.2: `__tcfapi('addEventListener', 2, cb)`. Granted when purpose 1
|
|
4
|
+
* (store/access) and purpose 7 or 9 are consented (publisher or global
|
|
5
|
+
* purpose consent), or, when `tcfVendorId` is set, purpose 1 plus that
|
|
6
|
+
* vendor's consent. `gdprApplies: false` is granted. Evidence: `tcString`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const tcf: ConsentSource;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* IAB TCF v2.2: `__tcfapi('addEventListener', 2, cb)`. Granted when purpose 1
|
|
4
|
+
* (store/access) and purpose 7 or 9 are consented (publisher or global
|
|
5
|
+
* purpose consent), or, when `tcfVendorId` is set, purpose 1 plus that
|
|
6
|
+
* vendor's consent. `gdprApplies: false` is granted. Evidence: `tcString`.
|
|
7
|
+
*/
|
|
8
|
+
export const tcf = {
|
|
9
|
+
id: 'tcf',
|
|
10
|
+
name: 'IAB TCF v2.2',
|
|
11
|
+
defaultCategory: 'purposes 1 + 7/9',
|
|
12
|
+
status: 'ga',
|
|
13
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#tcf',
|
|
14
|
+
vendorDocsUrl: 'https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework',
|
|
15
|
+
check: (cfg) => browserCheck(tcf, cfg),
|
|
16
|
+
factory: function tcfConsent(w) {
|
|
17
|
+
let data = null;
|
|
18
|
+
let listening = false;
|
|
19
|
+
const subs = [];
|
|
20
|
+
function listen() {
|
|
21
|
+
if (listening || typeof w.__tcfapi !== 'function')
|
|
22
|
+
return;
|
|
23
|
+
listening = true;
|
|
24
|
+
w.__tcfapi('addEventListener', 2, function (tc, ok) {
|
|
25
|
+
if (ok === false || !tc)
|
|
26
|
+
return;
|
|
27
|
+
data = tc;
|
|
28
|
+
const list = subs.slice();
|
|
29
|
+
for (let i = 0; i < list.length; i++)
|
|
30
|
+
list[i]();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function has(n) {
|
|
34
|
+
const pur = (data && data.purpose && data.purpose.consents) || {};
|
|
35
|
+
const pub = (data && data.publisher && data.publisher.consents) || {};
|
|
36
|
+
return !!(pur[n] || pub[n]);
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
detect() {
|
|
40
|
+
return typeof w.__tcfapi === 'function';
|
|
41
|
+
},
|
|
42
|
+
state(cfg) {
|
|
43
|
+
listen();
|
|
44
|
+
if (!data)
|
|
45
|
+
return 'unknown';
|
|
46
|
+
if (data.gdprApplies === false)
|
|
47
|
+
return 'granted';
|
|
48
|
+
if (data.eventStatus !== 'tcloaded' && data.eventStatus !== 'useractioncomplete')
|
|
49
|
+
return 'unknown';
|
|
50
|
+
if (cfg.tcfVendorId) {
|
|
51
|
+
const vc = (data.vendor && data.vendor.consents) || {};
|
|
52
|
+
return has(1) && vc[cfg.tcfVendorId] ? 'granted' : 'denied';
|
|
53
|
+
}
|
|
54
|
+
return has(1) && (has(7) || has(9)) ? 'granted' : 'denied';
|
|
55
|
+
},
|
|
56
|
+
subscribe(_cfg, cb) {
|
|
57
|
+
subs.push(cb);
|
|
58
|
+
listen();
|
|
59
|
+
return function () {
|
|
60
|
+
const i = subs.indexOf(cb);
|
|
61
|
+
if (i >= 0)
|
|
62
|
+
subs.splice(i, 1);
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
evidence() {
|
|
66
|
+
if (!data)
|
|
67
|
+
return null;
|
|
68
|
+
const purposes = [];
|
|
69
|
+
for (let n = 1; n <= 11; n++)
|
|
70
|
+
if (has(n))
|
|
71
|
+
purposes.push(String(n));
|
|
72
|
+
return { tcString: typeof data.tcString === 'string' ? data.tcString : undefined, purposes };
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ConsentSource } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Termly: `Termly.getConsentState()` (`{ advertising: true, … }`) and
|
|
4
|
+
* `Termly.on('consent' | 'initialized', cb)`. Category `advertising` by
|
|
5
|
+
* default. A category that isn't true counts as denied only after a consent
|
|
6
|
+
* event on this page, so a returning visitor who declined stays memory-only
|
|
7
|
+
* (never stored) rather than being read as granted. Shape per Termly's
|
|
8
|
+
* consent API docs; not yet checked against a live Termly site.
|
|
9
|
+
*/
|
|
10
|
+
export declare const termly: ConsentSource;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Termly: `Termly.getConsentState()` (`{ advertising: true, … }`) and
|
|
4
|
+
* `Termly.on('consent' | 'initialized', cb)`. Category `advertising` by
|
|
5
|
+
* default. A category that isn't true counts as denied only after a consent
|
|
6
|
+
* event on this page, so a returning visitor who declined stays memory-only
|
|
7
|
+
* (never stored) rather than being read as granted. Shape per Termly's
|
|
8
|
+
* consent API docs; not yet checked against a live Termly site.
|
|
9
|
+
*/
|
|
10
|
+
export const termly = {
|
|
11
|
+
id: 'termly',
|
|
12
|
+
name: 'Termly',
|
|
13
|
+
defaultCategory: 'advertising',
|
|
14
|
+
status: 'beta',
|
|
15
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#termly',
|
|
16
|
+
vendorDocsUrl: 'https://termly.io/',
|
|
17
|
+
check: (cfg) => browserCheck(termly, cfg),
|
|
18
|
+
factory: function termlyConsent(w) {
|
|
19
|
+
let decided = false;
|
|
20
|
+
return {
|
|
21
|
+
detect() {
|
|
22
|
+
return !!w.Termly;
|
|
23
|
+
},
|
|
24
|
+
state(cfg) {
|
|
25
|
+
const t = w.Termly;
|
|
26
|
+
if (!t || typeof t.getConsentState !== 'function')
|
|
27
|
+
return 'unknown';
|
|
28
|
+
const s = t.getConsentState();
|
|
29
|
+
if (!s || typeof s !== 'object')
|
|
30
|
+
return 'unknown';
|
|
31
|
+
if (s[cfg.category || 'advertising'] === true)
|
|
32
|
+
return 'granted';
|
|
33
|
+
return decided ? 'denied' : 'unknown';
|
|
34
|
+
},
|
|
35
|
+
subscribe(_cfg, cb) {
|
|
36
|
+
let off = false;
|
|
37
|
+
const t = w.Termly;
|
|
38
|
+
if (t && typeof t.on === 'function') {
|
|
39
|
+
t.on('consent', function () {
|
|
40
|
+
decided = true;
|
|
41
|
+
if (!off)
|
|
42
|
+
cb();
|
|
43
|
+
});
|
|
44
|
+
t.on('initialized', function () {
|
|
45
|
+
if (!off)
|
|
46
|
+
cb();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return function () {
|
|
50
|
+
off = true;
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
evidence(cfg) {
|
|
54
|
+
return { purposes: [cfg.category || 'advertising'] };
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ConsentSource } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Usercentrics: v2 `UC_UI.getServicesBaseInfo()` (services with
|
|
4
|
+
* `consent.status` and `categorySlug`) and v3 `__ucCmp.getConsentDetails()`
|
|
5
|
+
* (async; cached and refreshed on each event). `category` matches a service
|
|
6
|
+
* name (add a "Referalli" service and set it) or a category slug; default
|
|
7
|
+
* `marketing`. Events: `UC_UI_CMP_EVENT`, `UC_UI_INITIALIZED`, `UC_CONSENT`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const usercentrics: ConsentSource;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { browserCheck } from '../port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Usercentrics: v2 `UC_UI.getServicesBaseInfo()` (services with
|
|
4
|
+
* `consent.status` and `categorySlug`) and v3 `__ucCmp.getConsentDetails()`
|
|
5
|
+
* (async; cached and refreshed on each event). `category` matches a service
|
|
6
|
+
* name (add a "Referalli" service and set it) or a category slug; default
|
|
7
|
+
* `marketing`. Events: `UC_UI_CMP_EVENT`, `UC_UI_INITIALIZED`, `UC_CONSENT`.
|
|
8
|
+
*/
|
|
9
|
+
export const usercentrics = {
|
|
10
|
+
id: 'usercentrics',
|
|
11
|
+
name: 'Usercentrics',
|
|
12
|
+
defaultCategory: 'marketing',
|
|
13
|
+
status: 'beta',
|
|
14
|
+
docsUrl: 'https://referalli.com/docs/tracking-consent#usercentrics',
|
|
15
|
+
vendorDocsUrl: 'https://docs.usercentrics.com/',
|
|
16
|
+
check: (cfg) => browserCheck(usercentrics, cfg),
|
|
17
|
+
factory: function usercentricsConsent(w) {
|
|
18
|
+
const EVENTS = ['UC_UI_CMP_EVENT', 'UC_UI_INITIALIZED', 'UC_CONSENT', 'UC_UI_VIEW_CHANGED'];
|
|
19
|
+
let v3 = null;
|
|
20
|
+
function refresh(done) {
|
|
21
|
+
const api = w.__ucCmp;
|
|
22
|
+
if (!api || typeof api.getConsentDetails !== 'function') {
|
|
23
|
+
done();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
Promise.resolve(api.getConsentDetails()).then(function (d) {
|
|
28
|
+
v3 = d || null;
|
|
29
|
+
done();
|
|
30
|
+
}, function () {
|
|
31
|
+
done();
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
done();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
detect() {
|
|
40
|
+
if (w.UC_UI || w.__ucCmp)
|
|
41
|
+
return true;
|
|
42
|
+
const d = w.document;
|
|
43
|
+
return !!(d && typeof d.getElementById === 'function' && d.getElementById('usercentrics-cmp'));
|
|
44
|
+
},
|
|
45
|
+
state(cfg) {
|
|
46
|
+
const cat = cfg.category || 'marketing';
|
|
47
|
+
const ui = w.UC_UI;
|
|
48
|
+
if (ui && typeof ui.getServicesBaseInfo === 'function') {
|
|
49
|
+
if (typeof ui.isInitialized === 'function' && !ui.isInitialized())
|
|
50
|
+
return 'unknown';
|
|
51
|
+
const list = ui.getServicesBaseInfo() || [];
|
|
52
|
+
const hit = list.filter(function (s) {
|
|
53
|
+
return s && (s.name === cat || s.categorySlug === cat);
|
|
54
|
+
});
|
|
55
|
+
if (!hit.length)
|
|
56
|
+
return 'unknown';
|
|
57
|
+
if (hit.every(function (s) {
|
|
58
|
+
return s.consent && s.consent.status === true;
|
|
59
|
+
}))
|
|
60
|
+
return 'granted';
|
|
61
|
+
if (typeof ui.isConsentRequired === 'function' && ui.isConsentRequired())
|
|
62
|
+
return 'unknown';
|
|
63
|
+
return 'denied';
|
|
64
|
+
}
|
|
65
|
+
if (!v3)
|
|
66
|
+
return 'unknown';
|
|
67
|
+
const services = v3.services || {};
|
|
68
|
+
for (const k in services) {
|
|
69
|
+
const s = services[k];
|
|
70
|
+
if (s && s.name === cat)
|
|
71
|
+
return s.consent && s.consent.given === true ? 'granted' : v3.consent && v3.consent.required ? 'unknown' : 'denied';
|
|
72
|
+
}
|
|
73
|
+
const c = v3.categories && v3.categories[cat];
|
|
74
|
+
if (c && c.state === 'ALL_ACCEPTED')
|
|
75
|
+
return 'granted';
|
|
76
|
+
if (v3.consent && v3.consent.required)
|
|
77
|
+
return 'unknown';
|
|
78
|
+
return c ? 'denied' : 'unknown';
|
|
79
|
+
},
|
|
80
|
+
subscribe(_cfg, cb) {
|
|
81
|
+
let off = false;
|
|
82
|
+
const fire = function () {
|
|
83
|
+
refresh(function () {
|
|
84
|
+
if (!off)
|
|
85
|
+
cb();
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
for (let i = 0; i < EVENTS.length; i++)
|
|
89
|
+
w.addEventListener(EVENTS[i], fire);
|
|
90
|
+
fire();
|
|
91
|
+
return function () {
|
|
92
|
+
off = true;
|
|
93
|
+
for (let i = 0; i < EVENTS.length; i++)
|
|
94
|
+
w.removeEventListener(EVENTS[i], fire);
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
evidence() {
|
|
98
|
+
const id = v3 && v3.consent && v3.consent.controllerId;
|
|
99
|
+
return id ? { stamp: String(id) } : {};
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ConsentSource } from './port.js';
|
|
2
|
+
/** The vitest functions, passed in so this module never imports a test runner at runtime. */
|
|
3
|
+
export interface TestApi {
|
|
4
|
+
describe: (name: string, fn: () => void) => void;
|
|
5
|
+
it: (name: string, fn: () => unknown) => void;
|
|
6
|
+
expect: (value: unknown) => any;
|
|
7
|
+
}
|
|
8
|
+
/** A fake CMP built from the vendor's documented browser API (test/fixtures/consent/<id>/). */
|
|
9
|
+
export interface ConsentFixture {
|
|
10
|
+
install(w: any): void;
|
|
11
|
+
grant(w: any): void;
|
|
12
|
+
deny(w: any): void;
|
|
13
|
+
broken(w: any): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The runtime-free half of the consent conformance suite (REF-P01,
|
|
17
|
+
* docs/PORTS.md): every adapter declares its docs and status, answers check(),
|
|
18
|
+
* is not detected on a page without its CMP, and never throws out of state()
|
|
19
|
+
* when the CMP's API throws (the gate reads that as `unknown`). The full
|
|
20
|
+
* served-script and module-build cases run in test/consent/conformance.ts.
|
|
21
|
+
*/
|
|
22
|
+
export declare function runConformance(source: ConsentSource, fx: ConsentFixture, newWindow: () => any, t: TestApi): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime-free half of the consent conformance suite (REF-P01,
|
|
3
|
+
* docs/PORTS.md): every adapter declares its docs and status, answers check(),
|
|
4
|
+
* is not detected on a page without its CMP, and never throws out of state()
|
|
5
|
+
* when the CMP's API throws (the gate reads that as `unknown`). The full
|
|
6
|
+
* served-script and module-build cases run in test/consent/conformance.ts.
|
|
7
|
+
*/
|
|
8
|
+
export function runConformance(source, fx, newWindow, t) {
|
|
9
|
+
const { describe, it, expect } = t;
|
|
10
|
+
describe(`consent adapter ${source.id} conformance`, () => {
|
|
11
|
+
it('declares its docs, vendor docs and status', () => {
|
|
12
|
+
expect(source.docsUrl).toMatch(/^https:\/\/referalli\.com\/docs\//);
|
|
13
|
+
expect(source.vendorDocsUrl).toMatch(/^https:\/\//);
|
|
14
|
+
expect(['ga', 'beta']).toContain(source.status);
|
|
15
|
+
});
|
|
16
|
+
it('answers check()', async () => {
|
|
17
|
+
const r = await source.check();
|
|
18
|
+
expect(typeof r.ok).toBe('boolean');
|
|
19
|
+
expect(typeof r.detail).toBe('string');
|
|
20
|
+
});
|
|
21
|
+
it('is not detected on a page without its CMP', () => {
|
|
22
|
+
expect(source.factory(newWindow()).detect()).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
it('is detected once its CMP is on the page', () => {
|
|
25
|
+
const w = newWindow();
|
|
26
|
+
fx.install(w);
|
|
27
|
+
expect(source.factory(w).detect()).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ConsentAdapterFactory, ConsentConfig, ConsentEvidence, ConsentState } from './port.js';
|
|
2
|
+
export interface ConsentGate {
|
|
3
|
+
/** Begin detecting (call once the change handler is ready). */
|
|
4
|
+
start(): void;
|
|
5
|
+
state(): ConsentState;
|
|
6
|
+
/** The adapter in use: an adapter id, `auto` while still looking, `none`, `no-cmp` or `pending`. */
|
|
7
|
+
mode(): string;
|
|
8
|
+
/** The push path: `aff.consent(true|false)`. The latest signal (push or CMP) wins. Idempotent. */
|
|
9
|
+
push(granted: boolean): void;
|
|
10
|
+
evidence(): ConsentEvidence | null;
|
|
11
|
+
stop(): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The one consent state machine, shared by `referalli/browser` (snippet.ts)
|
|
15
|
+
* and the served `aff.js` (served.ts inlines this function's source text, so
|
|
16
|
+
* it must stay self-contained: parameters and browser globals only).
|
|
17
|
+
*
|
|
18
|
+
* `change(state, evidence)` is called on every transition (never for the
|
|
19
|
+
* initial `unknown`). `auto` polls every 100 ms for up to `waitMs` for a CMP
|
|
20
|
+
* to appear; if the page is being left before then with none found, the
|
|
21
|
+
* no-CMP rule applies at once so a quick click-through still keeps its referral.
|
|
22
|
+
*/
|
|
23
|
+
export declare function consentGate(w: any, cfg: ConsentConfig, adapters: Record<string, ConsentAdapterFactory>, order: readonly string[], change: (state: ConsentState, evidence: ConsentEvidence | null) => void): ConsentGate;
|