@sentientui/core 0.35.0 → 0.36.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 +51 -12
- package/dist/chunk-735EJYJX.mjs +2 -0
- package/dist/chunk-735EJYJX.mjs.map +1 -0
- package/dist/chunk-DU3AXQHR.mjs +2 -0
- package/dist/chunk-DU3AXQHR.mjs.map +1 -0
- package/dist/chunk-GVKKOUWE.mjs +2 -0
- package/dist/chunk-GVKKOUWE.mjs.map +1 -0
- package/dist/chunk-J5EL7HKC.mjs +2 -0
- package/dist/chunk-J5EL7HKC.mjs.map +1 -0
- package/dist/{index-Dg2gkw_l.d.cts → index-BYOMZ3t-.d.cts} +37 -2
- package/dist/{index-DjbSOAEF.d.ts → index-DEwRTvxc.d.ts} +37 -2
- package/dist/index-consent.d.cts +74 -13
- package/dist/index-consent.d.ts +74 -13
- package/dist/index-consent.js +1 -1
- package/dist/index-consent.js.map +1 -1
- package/dist/index-consent.mjs +1 -1
- package/dist/index-consent.mjs.map +1 -1
- package/dist/index-engagement.js +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-engagement.mjs.map +1 -1
- package/dist/index-graph.d.cts +2 -2
- package/dist/index-graph.d.ts +2 -2
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-graph.mjs.map +1 -1
- package/dist/index-local.d.cts +1 -1
- package/dist/index-local.d.ts +1 -1
- package/dist/index-server.d.cts +10 -0
- package/dist/index-server.d.ts +10 -0
- package/dist/index-server.js +1 -1
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +1 -1
- package/dist/index-server.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/llms.txt +2 -2
- package/package.json +5 -2
- package/dist/chunk-2NVSFI4V.mjs +0 -2
- package/dist/chunk-2NVSFI4V.mjs.map +0 -1
- package/dist/chunk-EUD4PUKP.mjs +0 -2
- package/dist/chunk-EUD4PUKP.mjs.map +0 -1
|
@@ -61,7 +61,12 @@ type QueueConfig = {
|
|
|
61
61
|
type EventQueue = {
|
|
62
62
|
push(event: SentientEvent): void;
|
|
63
63
|
flush(): void;
|
|
64
|
-
|
|
64
|
+
/** Stop the queue with a final flush. `forget`: the visitor asked to be
|
|
65
|
+
* forgotten — a failed final delivery must NOT be persisted for retry
|
|
66
|
+
* (it re-created the retry bucket after forget-me removed it). */
|
|
67
|
+
destroy(opts?: {
|
|
68
|
+
forget?: boolean;
|
|
69
|
+
}): void;
|
|
65
70
|
};
|
|
66
71
|
|
|
67
72
|
/** Synchronous variant assignment cache (memory + localStorage). */
|
|
@@ -144,6 +149,8 @@ declare const LEGACY_SESSION_COOKIE_NAME = "_snt_uid";
|
|
|
144
149
|
* drift impossible, and index.test.ts pins the reader against the writer.
|
|
145
150
|
*/
|
|
146
151
|
declare function sessionCookieName(apiKey?: string): string;
|
|
152
|
+
/** Bumped by every forget-me for this project in this page. */
|
|
153
|
+
declare function forgetGeneration(apiKey: string): number;
|
|
147
154
|
|
|
148
155
|
/**
|
|
149
156
|
* Where a registry component is EXPECTED to exist — `CompoundLocator.page`.
|
|
@@ -217,6 +224,11 @@ type RevealOptions = {
|
|
|
217
224
|
*/
|
|
218
225
|
declare function reveal(el: Element, opts?: RevealOptions): boolean;
|
|
219
226
|
|
|
227
|
+
declare function setCspNonce(nonce: string | undefined): void;
|
|
228
|
+
declare function cspNonce(doc?: Document): string | undefined;
|
|
229
|
+
/** Stamp `el` with the page's nonce when there is one. */
|
|
230
|
+
declare function applyNonce<T extends HTMLElement>(el: T, doc?: Document): T;
|
|
231
|
+
|
|
220
232
|
type MicroSignalEmitter = (signalType: 'rage_click' | 'text_copy' | 'scroll_hesitation' | 'tab_loss', extra?: Record<string, unknown>) => void;
|
|
221
233
|
type MicroSignalType = Parameters<MicroSignalEmitter>[0];
|
|
222
234
|
/**
|
|
@@ -363,6 +375,12 @@ type SentientConfig = {
|
|
|
363
375
|
name: string;
|
|
364
376
|
version: string;
|
|
365
377
|
};
|
|
378
|
+
/**
|
|
379
|
+
* CSP nonce for the <style> elements the SDK injects (the adaptation
|
|
380
|
+
* reveal). Without one the page's CSP needs `style-src 'unsafe-inline'`.
|
|
381
|
+
* Defaults to the nonce of a script already on the page.
|
|
382
|
+
*/
|
|
383
|
+
nonce?: string;
|
|
366
384
|
};
|
|
367
385
|
type AssignResult = {
|
|
368
386
|
variantId: string;
|
|
@@ -598,6 +616,16 @@ type SentientClient = {
|
|
|
598
616
|
destroy(): void;
|
|
599
617
|
/** True when this client is the keyless local-mode client (dev only). */
|
|
600
618
|
readonly isLocal?: boolean;
|
|
619
|
+
/** True while this is a consent-gated client not yet upgraded in place:
|
|
620
|
+
* goals and events are held until then, and a decide is held (or dropped
|
|
621
|
+
* if the page changed). A released one still reads true but can't be
|
|
622
|
+
* upgraded — check `released`. Absent on a tracking client. */
|
|
623
|
+
readonly gated?: boolean;
|
|
624
|
+
/** @internal True once a gated client was disposed/destroyed before any
|
|
625
|
+
* upgrade: its decides resolve null without being sent. */
|
|
626
|
+
readonly released?: boolean;
|
|
627
|
+
/** @internal The gated client's held goal() calls, removed from it. */
|
|
628
|
+
takeHeld?(): Array<(c: SentientClient) => void>;
|
|
601
629
|
};
|
|
602
630
|
|
|
603
631
|
/**
|
|
@@ -616,9 +644,16 @@ declare function isDoNotTrackEnabled(): boolean;
|
|
|
616
644
|
* Pass `apiKey` to target a specific project; omit to upgrade the most-recently-initialized client.
|
|
617
645
|
*/
|
|
618
646
|
declare function grantConsent(apiKey?: string): void;
|
|
647
|
+
/**
|
|
648
|
+
* The page a decision belongs to: the pathname plus a route-shaped fragment.
|
|
649
|
+
* Hash routers (`#/pricing`) navigate without changing the pathname; an
|
|
650
|
+
* in-page anchor (`#faq`) is not a route. Shared by the held-decide drop rule
|
|
651
|
+
* and the snippet's re-decide check, which must agree (grader NEW-2).
|
|
652
|
+
*/
|
|
653
|
+
declare function routeKey(): string;
|
|
619
654
|
/**
|
|
620
655
|
* Initializes the Sentient client. Returns a no-op client during SSR.
|
|
621
656
|
*/
|
|
622
657
|
declare function init(config: SentientConfig): SentientClient;
|
|
623
658
|
|
|
624
|
-
export { type AssignResult as A,
|
|
659
|
+
export { type AssignResult as A, init as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, isDoNotTrackEnabled as F, type GoalDefinition as G, pageScopeMatches as H, resetRevealStyles as I, reveal as J, routeKey as K, LEGACY_SESSION_COOKIE_NAME as L, type MicroSignalEmitter as M, sanitizePageUrl as N, sessionCookieName as O, PAGE_SCOPE_RE as P, type QueueConfig as Q, REVEAL_MS as R, type SectionMapEntry as S, setCspNonce as T, type WeightEntry as W, _registerConsentUpgradeInit as _, type Assignment as a, type AssignmentCache as b, type AuthoredArmReport as c, type ComponentWeightEntry as d, type DecideOutcome as e, type EventType as f, type GoalOptions as g, type GraphClient as h, type GraphConfig as i, type GraphSnapshot as j, LOCAL_MODE_BANNER as k, type MicroSignalType as l, PROD_KEYLESS_ERROR as m, type PageNode as n, type RevealOptions as o, type SentientClient as p, type SentientConfig as q, type SentientEvent as r, type SessionConfig as s, type SessionManager as t, type SkeletonReport as u, applyNonce as v, attachMicroSignalDetectors as w, cspNonce as x, forgetGeneration as y, grantConsent as z };
|
|
@@ -61,7 +61,12 @@ type QueueConfig = {
|
|
|
61
61
|
type EventQueue = {
|
|
62
62
|
push(event: SentientEvent): void;
|
|
63
63
|
flush(): void;
|
|
64
|
-
|
|
64
|
+
/** Stop the queue with a final flush. `forget`: the visitor asked to be
|
|
65
|
+
* forgotten — a failed final delivery must NOT be persisted for retry
|
|
66
|
+
* (it re-created the retry bucket after forget-me removed it). */
|
|
67
|
+
destroy(opts?: {
|
|
68
|
+
forget?: boolean;
|
|
69
|
+
}): void;
|
|
65
70
|
};
|
|
66
71
|
|
|
67
72
|
/** Synchronous variant assignment cache (memory + localStorage). */
|
|
@@ -144,6 +149,8 @@ declare const LEGACY_SESSION_COOKIE_NAME = "_snt_uid";
|
|
|
144
149
|
* drift impossible, and index.test.ts pins the reader against the writer.
|
|
145
150
|
*/
|
|
146
151
|
declare function sessionCookieName(apiKey?: string): string;
|
|
152
|
+
/** Bumped by every forget-me for this project in this page. */
|
|
153
|
+
declare function forgetGeneration(apiKey: string): number;
|
|
147
154
|
|
|
148
155
|
/**
|
|
149
156
|
* Where a registry component is EXPECTED to exist — `CompoundLocator.page`.
|
|
@@ -217,6 +224,11 @@ type RevealOptions = {
|
|
|
217
224
|
*/
|
|
218
225
|
declare function reveal(el: Element, opts?: RevealOptions): boolean;
|
|
219
226
|
|
|
227
|
+
declare function setCspNonce(nonce: string | undefined): void;
|
|
228
|
+
declare function cspNonce(doc?: Document): string | undefined;
|
|
229
|
+
/** Stamp `el` with the page's nonce when there is one. */
|
|
230
|
+
declare function applyNonce<T extends HTMLElement>(el: T, doc?: Document): T;
|
|
231
|
+
|
|
220
232
|
type MicroSignalEmitter = (signalType: 'rage_click' | 'text_copy' | 'scroll_hesitation' | 'tab_loss', extra?: Record<string, unknown>) => void;
|
|
221
233
|
type MicroSignalType = Parameters<MicroSignalEmitter>[0];
|
|
222
234
|
/**
|
|
@@ -363,6 +375,12 @@ type SentientConfig = {
|
|
|
363
375
|
name: string;
|
|
364
376
|
version: string;
|
|
365
377
|
};
|
|
378
|
+
/**
|
|
379
|
+
* CSP nonce for the <style> elements the SDK injects (the adaptation
|
|
380
|
+
* reveal). Without one the page's CSP needs `style-src 'unsafe-inline'`.
|
|
381
|
+
* Defaults to the nonce of a script already on the page.
|
|
382
|
+
*/
|
|
383
|
+
nonce?: string;
|
|
366
384
|
};
|
|
367
385
|
type AssignResult = {
|
|
368
386
|
variantId: string;
|
|
@@ -598,6 +616,16 @@ type SentientClient = {
|
|
|
598
616
|
destroy(): void;
|
|
599
617
|
/** True when this client is the keyless local-mode client (dev only). */
|
|
600
618
|
readonly isLocal?: boolean;
|
|
619
|
+
/** True while this is a consent-gated client not yet upgraded in place:
|
|
620
|
+
* goals and events are held until then, and a decide is held (or dropped
|
|
621
|
+
* if the page changed). A released one still reads true but can't be
|
|
622
|
+
* upgraded — check `released`. Absent on a tracking client. */
|
|
623
|
+
readonly gated?: boolean;
|
|
624
|
+
/** @internal True once a gated client was disposed/destroyed before any
|
|
625
|
+
* upgrade: its decides resolve null without being sent. */
|
|
626
|
+
readonly released?: boolean;
|
|
627
|
+
/** @internal The gated client's held goal() calls, removed from it. */
|
|
628
|
+
takeHeld?(): Array<(c: SentientClient) => void>;
|
|
601
629
|
};
|
|
602
630
|
|
|
603
631
|
/**
|
|
@@ -616,9 +644,16 @@ declare function isDoNotTrackEnabled(): boolean;
|
|
|
616
644
|
* Pass `apiKey` to target a specific project; omit to upgrade the most-recently-initialized client.
|
|
617
645
|
*/
|
|
618
646
|
declare function grantConsent(apiKey?: string): void;
|
|
647
|
+
/**
|
|
648
|
+
* The page a decision belongs to: the pathname plus a route-shaped fragment.
|
|
649
|
+
* Hash routers (`#/pricing`) navigate without changing the pathname; an
|
|
650
|
+
* in-page anchor (`#faq`) is not a route. Shared by the held-decide drop rule
|
|
651
|
+
* and the snippet's re-decide check, which must agree (grader NEW-2).
|
|
652
|
+
*/
|
|
653
|
+
declare function routeKey(): string;
|
|
619
654
|
/**
|
|
620
655
|
* Initializes the Sentient client. Returns a no-op client during SSR.
|
|
621
656
|
*/
|
|
622
657
|
declare function init(config: SentientConfig): SentientClient;
|
|
623
658
|
|
|
624
|
-
export { type AssignResult as A,
|
|
659
|
+
export { type AssignResult as A, init as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, isDoNotTrackEnabled as F, type GoalDefinition as G, pageScopeMatches as H, resetRevealStyles as I, reveal as J, routeKey as K, LEGACY_SESSION_COOKIE_NAME as L, type MicroSignalEmitter as M, sanitizePageUrl as N, sessionCookieName as O, PAGE_SCOPE_RE as P, type QueueConfig as Q, REVEAL_MS as R, type SectionMapEntry as S, setCspNonce as T, type WeightEntry as W, _registerConsentUpgradeInit as _, type Assignment as a, type AssignmentCache as b, type AuthoredArmReport as c, type ComponentWeightEntry as d, type DecideOutcome as e, type EventType as f, type GoalOptions as g, type GraphClient as h, type GraphConfig as i, type GraphSnapshot as j, LOCAL_MODE_BANNER as k, type MicroSignalType as l, PROD_KEYLESS_ERROR as m, type PageNode as n, type RevealOptions as o, type SentientClient as p, type SentientConfig as q, type SentientEvent as r, type SessionConfig as s, type SessionManager as t, type SkeletonReport as u, applyNonce as v, attachMicroSignalDetectors as w, cspNonce as x, forgetGeneration as y, grantConsent as z };
|
package/dist/index-consent.d.cts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
type ConsentPreset = 'cookiebot' | 'onetrust' | 'cookieyes' | 'tcf' | 'google-consent-mode';
|
|
1
|
+
type ConsentPreset = 'cookiebot' | 'onetrust' | 'cookieyes' | 'tcf' | 'google-consent-mode' | 'shopify';
|
|
2
|
+
/** TCF purposes the SDK's processing needs: 1 store/access on a device,
|
|
3
|
+
* 5 build a personalised-content profile, 6 select personalised content from
|
|
4
|
+
* it, 8 measure content performance. The old default was purpose 1 alone —
|
|
5
|
+
* storage consent, which says nothing about profiling or measurement. */
|
|
6
|
+
declare const TCF_DEFAULT_PURPOSES: readonly number[];
|
|
2
7
|
type ConsentSource = ConsentPreset | {
|
|
3
8
|
cmp: 'cookiebot';
|
|
4
9
|
category?: 'preferences' | 'statistics' | 'marketing';
|
|
@@ -10,11 +15,25 @@ type ConsentSource = ConsentPreset | {
|
|
|
10
15
|
category?: 'functional' | 'analytics' | 'performance' | 'advertisement';
|
|
11
16
|
} | {
|
|
12
17
|
cmp: 'tcf';
|
|
18
|
+
/** Purposes that must be satisfied. @default TCF_DEFAULT_PURPOSES (1, 5, 6, 8) */
|
|
13
19
|
purposes?: number[];
|
|
20
|
+
/** Also require consent for this Global Vendor List id. SentientUI is a
|
|
21
|
+
* processor for your site and has no GVL id of its own; set this only if
|
|
22
|
+
* your CMP lists a vendor entry you map it to. */
|
|
23
|
+
vendorId?: number;
|
|
14
24
|
} | {
|
|
15
25
|
cmp: 'google-consent-mode';
|
|
16
26
|
type?: 'analytics_storage' | 'ad_storage' | 'personalization_storage' | 'functionality_storage';
|
|
17
27
|
dataLayer?: string;
|
|
28
|
+
/** The visitor's region (ISO 3166-1 alpha-2, optionally `-` ISO 3166-2
|
|
29
|
+
* subdivision: 'ES', 'US-CA'), e.g. from your CDN's country header.
|
|
30
|
+
* Resolves region-scoped `consent default` commands exactly. Without it
|
|
31
|
+
* a region-scoped denial can't be ruled out, so it reads as denied. */
|
|
32
|
+
region?: string;
|
|
33
|
+
} | {
|
|
34
|
+
cmp: 'shopify';
|
|
35
|
+
/** Which Customer Privacy purpose to require. @default 'analytics' */
|
|
36
|
+
category?: 'analytics' | 'marketing' | 'preferences';
|
|
18
37
|
} | {
|
|
19
38
|
cmp?: undefined;
|
|
20
39
|
/** Cookie to read. Granted when its value equals `value`. */
|
|
@@ -25,39 +44,81 @@ type ConsentSource = ConsentPreset | {
|
|
|
25
44
|
check?: () => boolean;
|
|
26
45
|
/** Event that signals a decision (listened on window AND document). */
|
|
27
46
|
event?: string;
|
|
47
|
+
/** With `check`: true when the visitor has actually REFUSED (not merely
|
|
48
|
+
* not answered yet). A predicate can't say why it returned false, so
|
|
49
|
+
* without this a `check` source only pauses tracking and never forgets. */
|
|
50
|
+
refused?: () => boolean;
|
|
28
51
|
};
|
|
29
52
|
type ConsentWatcher = {
|
|
30
53
|
/** The decision right now: true/false, or null when the source can't tell
|
|
31
54
|
* yet (CMP not loaded, no decision stored). Callers treat null as "keep
|
|
32
55
|
* whatever you knew" — e.g. the server's read — and never as granted. */
|
|
33
56
|
read(): boolean | null;
|
|
57
|
+
/** True only when the source records an actual refusal — a "no" that
|
|
58
|
+
* justifies deleting what the SDK stored (forget-me), not merely gating.
|
|
59
|
+
* False while the platform is loading, while its banner is up (TCF
|
|
60
|
+
* `cmpuishown`), for a region-conservative Consent Mode read, and for
|
|
61
|
+
* `check()` sources (a predicate can't say why it returned false). */
|
|
62
|
+
refused(): boolean;
|
|
34
63
|
/** Call `onChange` whenever the decision may have changed. */
|
|
35
64
|
subscribe(onChange: () => void): () => void;
|
|
36
65
|
};
|
|
37
66
|
/** Cookiebot `CookieConsent`: true/false for `category`, null when unknown. */
|
|
38
67
|
declare function cookiebotCookieGrants(raw: string | undefined, category?: string): boolean | null;
|
|
39
|
-
/** OneTrust `OptanonConsent`: is `group` active? null when unknown.
|
|
68
|
+
/** OneTrust `OptanonConsent`: is `group` active? null when unknown. Pass the
|
|
69
|
+
* raw cookie value, not a decoded one (see {@link consentFromCookies}). */
|
|
40
70
|
declare function onetrustCookieGrants(raw: string | undefined, group?: string): boolean | null;
|
|
41
71
|
/** CookieYes `cookieyes-consent`: `category:yes|no`, null when unrecognised. */
|
|
42
72
|
declare function cookieyesCookieGrants(raw: string | undefined, category?: string): boolean | null;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
type TcConsents = {
|
|
74
|
+
purposes: Set<number>;
|
|
75
|
+
legitimateInterests: Set<number>;
|
|
76
|
+
/** Vendor ids with consent; null when the vendor section is truncated. */
|
|
77
|
+
vendors: Set<number> | null;
|
|
78
|
+
/** The publisher segment (type 3): the site's own purposes. Empty sets when
|
|
79
|
+
* the string carries none. */
|
|
80
|
+
publisherPurposes: Set<number>;
|
|
81
|
+
publisherLegitimateInterests: Set<number>;
|
|
82
|
+
/** PurposeOneTreatment (bit 200): purpose 1 is not collected. */
|
|
83
|
+
purposeOneTreatment: boolean;
|
|
84
|
+
};
|
|
85
|
+
declare function tcStringConsents(tc: string | undefined): TcConsents | null;
|
|
86
|
+
/** Purpose consents only — kept for callers of the pre-vendor parser. */
|
|
51
87
|
declare function tcStringPurposes(tc: string | undefined): Set<number> | null;
|
|
52
88
|
/**
|
|
53
89
|
* Server-side read from the request's cookies (Next.js `AdaptiveRoot`).
|
|
54
90
|
* true/false when the CMP's cookie decides it, null when it can't be known on
|
|
55
91
|
* the server (no cookie yet, a JS-only source) — the caller then gates the
|
|
56
92
|
* first paint and lets the browser decide.
|
|
93
|
+
*
|
|
94
|
+
* `getCookie` must return the value exactly as sent in the Cookie header,
|
|
95
|
+
* NOT decoded: most server cookie jars (Next's cookies(), Express
|
|
96
|
+
* cookie-parser) decode values, and a decoded OneTrust cookie lets a crafted
|
|
97
|
+
* landing URL inject a `groups=` field that reads as consent.
|
|
57
98
|
*/
|
|
58
99
|
declare function consentFromCookies(src: ConsentSource, getCookie: (name: string) => string | undefined): boolean | null;
|
|
59
|
-
/**
|
|
60
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The Consent Mode state for `type` in `dataLayer`, or null when no command
|
|
102
|
+
* has decided it. `region` (e.g. 'ES', 'US-CA') resolves region-scoped
|
|
103
|
+
* `consent default` commands; without it, any region-scoped denial reads as
|
|
104
|
+
* denied until an `update` settles it.
|
|
105
|
+
*/
|
|
106
|
+
declare function consentModeGranted(dataLayer: unknown, type?: string, region?: string): boolean | null;
|
|
61
107
|
declare function consentWatcher(src: ConsentSource, win?: Window): ConsentWatcher;
|
|
62
108
|
|
|
63
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Forget-me WITHOUT a client: delete everything the SDK stores for `apiKey`'s
|
|
111
|
+
* visitor. `client.destroy()` does this for a live tracking client, which only
|
|
112
|
+
* exists when consent was granted in this page view — so a visitor who said
|
|
113
|
+
* "no" somewhere the SDK wasn't watching (a CMP settings page, checkout)
|
|
114
|
+
* kept the 365-day id, the decision snapshot and the retry buckets for good,
|
|
115
|
+
* and the pre-paint script kept personalizing from that snapshot (audit N2).
|
|
116
|
+
* Callers run this when the consent source reports a refusal at boot.
|
|
117
|
+
*
|
|
118
|
+
* Writes nothing unless something was stored: the legacy tombstone (which
|
|
119
|
+
* stops this project re-adopting the shared bare `_snt_uid`) is only written
|
|
120
|
+
* when there is a bare id to block. Returns whether anything was removed.
|
|
121
|
+
*/
|
|
122
|
+
declare function forgetVisitor(apiKey: string): boolean;
|
|
123
|
+
|
|
124
|
+
export { type ConsentPreset, type ConsentSource, type ConsentWatcher, TCF_DEFAULT_PURPOSES, consentFromCookies, consentModeGranted, consentWatcher, cookiebotCookieGrants, cookieyesCookieGrants, forgetVisitor, onetrustCookieGrants, tcStringConsents, tcStringPurposes };
|
package/dist/index-consent.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
type ConsentPreset = 'cookiebot' | 'onetrust' | 'cookieyes' | 'tcf' | 'google-consent-mode';
|
|
1
|
+
type ConsentPreset = 'cookiebot' | 'onetrust' | 'cookieyes' | 'tcf' | 'google-consent-mode' | 'shopify';
|
|
2
|
+
/** TCF purposes the SDK's processing needs: 1 store/access on a device,
|
|
3
|
+
* 5 build a personalised-content profile, 6 select personalised content from
|
|
4
|
+
* it, 8 measure content performance. The old default was purpose 1 alone —
|
|
5
|
+
* storage consent, which says nothing about profiling or measurement. */
|
|
6
|
+
declare const TCF_DEFAULT_PURPOSES: readonly number[];
|
|
2
7
|
type ConsentSource = ConsentPreset | {
|
|
3
8
|
cmp: 'cookiebot';
|
|
4
9
|
category?: 'preferences' | 'statistics' | 'marketing';
|
|
@@ -10,11 +15,25 @@ type ConsentSource = ConsentPreset | {
|
|
|
10
15
|
category?: 'functional' | 'analytics' | 'performance' | 'advertisement';
|
|
11
16
|
} | {
|
|
12
17
|
cmp: 'tcf';
|
|
18
|
+
/** Purposes that must be satisfied. @default TCF_DEFAULT_PURPOSES (1, 5, 6, 8) */
|
|
13
19
|
purposes?: number[];
|
|
20
|
+
/** Also require consent for this Global Vendor List id. SentientUI is a
|
|
21
|
+
* processor for your site and has no GVL id of its own; set this only if
|
|
22
|
+
* your CMP lists a vendor entry you map it to. */
|
|
23
|
+
vendorId?: number;
|
|
14
24
|
} | {
|
|
15
25
|
cmp: 'google-consent-mode';
|
|
16
26
|
type?: 'analytics_storage' | 'ad_storage' | 'personalization_storage' | 'functionality_storage';
|
|
17
27
|
dataLayer?: string;
|
|
28
|
+
/** The visitor's region (ISO 3166-1 alpha-2, optionally `-` ISO 3166-2
|
|
29
|
+
* subdivision: 'ES', 'US-CA'), e.g. from your CDN's country header.
|
|
30
|
+
* Resolves region-scoped `consent default` commands exactly. Without it
|
|
31
|
+
* a region-scoped denial can't be ruled out, so it reads as denied. */
|
|
32
|
+
region?: string;
|
|
33
|
+
} | {
|
|
34
|
+
cmp: 'shopify';
|
|
35
|
+
/** Which Customer Privacy purpose to require. @default 'analytics' */
|
|
36
|
+
category?: 'analytics' | 'marketing' | 'preferences';
|
|
18
37
|
} | {
|
|
19
38
|
cmp?: undefined;
|
|
20
39
|
/** Cookie to read. Granted when its value equals `value`. */
|
|
@@ -25,39 +44,81 @@ type ConsentSource = ConsentPreset | {
|
|
|
25
44
|
check?: () => boolean;
|
|
26
45
|
/** Event that signals a decision (listened on window AND document). */
|
|
27
46
|
event?: string;
|
|
47
|
+
/** With `check`: true when the visitor has actually REFUSED (not merely
|
|
48
|
+
* not answered yet). A predicate can't say why it returned false, so
|
|
49
|
+
* without this a `check` source only pauses tracking and never forgets. */
|
|
50
|
+
refused?: () => boolean;
|
|
28
51
|
};
|
|
29
52
|
type ConsentWatcher = {
|
|
30
53
|
/** The decision right now: true/false, or null when the source can't tell
|
|
31
54
|
* yet (CMP not loaded, no decision stored). Callers treat null as "keep
|
|
32
55
|
* whatever you knew" — e.g. the server's read — and never as granted. */
|
|
33
56
|
read(): boolean | null;
|
|
57
|
+
/** True only when the source records an actual refusal — a "no" that
|
|
58
|
+
* justifies deleting what the SDK stored (forget-me), not merely gating.
|
|
59
|
+
* False while the platform is loading, while its banner is up (TCF
|
|
60
|
+
* `cmpuishown`), for a region-conservative Consent Mode read, and for
|
|
61
|
+
* `check()` sources (a predicate can't say why it returned false). */
|
|
62
|
+
refused(): boolean;
|
|
34
63
|
/** Call `onChange` whenever the decision may have changed. */
|
|
35
64
|
subscribe(onChange: () => void): () => void;
|
|
36
65
|
};
|
|
37
66
|
/** Cookiebot `CookieConsent`: true/false for `category`, null when unknown. */
|
|
38
67
|
declare function cookiebotCookieGrants(raw: string | undefined, category?: string): boolean | null;
|
|
39
|
-
/** OneTrust `OptanonConsent`: is `group` active? null when unknown.
|
|
68
|
+
/** OneTrust `OptanonConsent`: is `group` active? null when unknown. Pass the
|
|
69
|
+
* raw cookie value, not a decoded one (see {@link consentFromCookies}). */
|
|
40
70
|
declare function onetrustCookieGrants(raw: string | undefined, group?: string): boolean | null;
|
|
41
71
|
/** CookieYes `cookieyes-consent`: `category:yes|no`, null when unrecognised. */
|
|
42
72
|
declare function cookieyesCookieGrants(raw: string | undefined, category?: string): boolean | null;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
73
|
+
type TcConsents = {
|
|
74
|
+
purposes: Set<number>;
|
|
75
|
+
legitimateInterests: Set<number>;
|
|
76
|
+
/** Vendor ids with consent; null when the vendor section is truncated. */
|
|
77
|
+
vendors: Set<number> | null;
|
|
78
|
+
/** The publisher segment (type 3): the site's own purposes. Empty sets when
|
|
79
|
+
* the string carries none. */
|
|
80
|
+
publisherPurposes: Set<number>;
|
|
81
|
+
publisherLegitimateInterests: Set<number>;
|
|
82
|
+
/** PurposeOneTreatment (bit 200): purpose 1 is not collected. */
|
|
83
|
+
purposeOneTreatment: boolean;
|
|
84
|
+
};
|
|
85
|
+
declare function tcStringConsents(tc: string | undefined): TcConsents | null;
|
|
86
|
+
/** Purpose consents only — kept for callers of the pre-vendor parser. */
|
|
51
87
|
declare function tcStringPurposes(tc: string | undefined): Set<number> | null;
|
|
52
88
|
/**
|
|
53
89
|
* Server-side read from the request's cookies (Next.js `AdaptiveRoot`).
|
|
54
90
|
* true/false when the CMP's cookie decides it, null when it can't be known on
|
|
55
91
|
* the server (no cookie yet, a JS-only source) — the caller then gates the
|
|
56
92
|
* first paint and lets the browser decide.
|
|
93
|
+
*
|
|
94
|
+
* `getCookie` must return the value exactly as sent in the Cookie header,
|
|
95
|
+
* NOT decoded: most server cookie jars (Next's cookies(), Express
|
|
96
|
+
* cookie-parser) decode values, and a decoded OneTrust cookie lets a crafted
|
|
97
|
+
* landing URL inject a `groups=` field that reads as consent.
|
|
57
98
|
*/
|
|
58
99
|
declare function consentFromCookies(src: ConsentSource, getCookie: (name: string) => string | undefined): boolean | null;
|
|
59
|
-
/**
|
|
60
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The Consent Mode state for `type` in `dataLayer`, or null when no command
|
|
102
|
+
* has decided it. `region` (e.g. 'ES', 'US-CA') resolves region-scoped
|
|
103
|
+
* `consent default` commands; without it, any region-scoped denial reads as
|
|
104
|
+
* denied until an `update` settles it.
|
|
105
|
+
*/
|
|
106
|
+
declare function consentModeGranted(dataLayer: unknown, type?: string, region?: string): boolean | null;
|
|
61
107
|
declare function consentWatcher(src: ConsentSource, win?: Window): ConsentWatcher;
|
|
62
108
|
|
|
63
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Forget-me WITHOUT a client: delete everything the SDK stores for `apiKey`'s
|
|
111
|
+
* visitor. `client.destroy()` does this for a live tracking client, which only
|
|
112
|
+
* exists when consent was granted in this page view — so a visitor who said
|
|
113
|
+
* "no" somewhere the SDK wasn't watching (a CMP settings page, checkout)
|
|
114
|
+
* kept the 365-day id, the decision snapshot and the retry buckets for good,
|
|
115
|
+
* and the pre-paint script kept personalizing from that snapshot (audit N2).
|
|
116
|
+
* Callers run this when the consent source reports a refusal at boot.
|
|
117
|
+
*
|
|
118
|
+
* Writes nothing unless something was stored: the legacy tombstone (which
|
|
119
|
+
* stops this project re-adopting the shared bare `_snt_uid`) is only written
|
|
120
|
+
* when there is a bare id to block. Returns whether anything was removed.
|
|
121
|
+
*/
|
|
122
|
+
declare function forgetVisitor(apiKey: string): boolean;
|
|
123
|
+
|
|
124
|
+
export { type ConsentPreset, type ConsentSource, type ConsentWatcher, TCF_DEFAULT_PURPOSES, consentFromCookies, consentModeGranted, consentWatcher, cookiebotCookieGrants, cookieyesCookieGrants, forgetVisitor, onetrustCookieGrants, tcStringConsents, tcStringPurposes };
|
package/dist/index-consent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var T=(o,n)=>{for(var e in n)h(o,e,{get:n[e],enumerable:!0})},E=(o,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of W(n))!R.call(o,s)&&s!==e&&h(o,s,{get:()=>n[s],enumerable:!(r=O(n,s))||r.enumerable});return o};var I=o=>E(h({},"__esModule",{value:!0}),o);var D={};T(D,{consentFromCookies:()=>L,consentModeGranted:()=>_,consentWatcher:()=>G,cookiebotCookieGrants:()=>y,cookieyesCookieGrants:()=>k,onetrustCookieGrants:()=>m,tcStringPurposes:()=>x});module.exports=I(D);var g=o=>{try{return decodeURIComponent(o)}catch(n){return o}};function d(o,n){if(o)for(let e of o.cookie.split(";")){let r=e.indexOf("=");if(r>0&&e.slice(0,r).trim()===n)return e.slice(r+1).trim()}}function f(o,n,e){let r=[o,...o.document?[o.document]:[]];for(let s of r)for(let t of n)s.addEventListener(t,e);return()=>{for(let s of r)for(let t of n)s.removeEventListener(t,e)}}function y(o,n="statistics"){if(o==null||o==="")return null;let e=g(o).trim();if(e==="-1")return!0;if(e==="0")return!1;let r=new RegExp(`[{,]\\s*${n}\\s*:\\s*(true|false)`).exec(e);return r?r[1]==="true":null}function m(o,n="C0002"){var r;if(o==null||o==="")return null;let e=(r=/(?:^|&)groups=([^&]*)/.exec(g(o)))==null?void 0:r[1];if(e==null)return null;for(let s of g(e).split(",")){let[t,i]=s.split(":");if(t===n)return i==="1"}return null}function k(o,n="analytics"){if(o==null||o==="")return null;let e=new RegExp(`(?:^|,)${n}:(yes|no)(?:,|$)`).exec(g(o));return e?e[1]==="yes":null}function x(o){if(!o)return null;let n=o.split(".")[0];if(!/^[A-Za-z0-9_-]+$/.test(n))return null;let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",r="";for(let t of n)r+=e.indexOf(t).toString(2).padStart(6,"0");if(r.length<176||parseInt(r.slice(0,6),2)!==2)return null;let s=new Set;for(let t=1;t<=24;t++)r[151+t]==="1"&&s.add(t);return s}function A(o){var e,r,s,t,i,c;let n=typeof o=="string"?{cmp:o}:o;switch(n.cmp){case"cookiebot":return{cmp:"cookiebot",category:(e=n.category)!=null?e:"statistics"};case"onetrust":return{cmp:"onetrust",group:(r=n.group)!=null?r:"C0002"};case"cookieyes":return{cmp:"cookieyes",category:(s=n.category)!=null?s:"analytics"};case"tcf":return{cmp:"tcf",purposes:n.purposes&&n.purposes.length>0?n.purposes:[1]};case"google-consent-mode":return{cmp:"google-consent-mode",type:(t=n.type)!=null?t:"analytics_storage",dataLayer:(i=n.dataLayer)!=null?i:"dataLayer"};default:return{cmp:"custom",cookie:n.cookie,value:(c=n.value)!=null?c:"accepted",check:n.check,event:n.event}}}function L(o,n){let e=A(o);switch(e.cmp){case"cookiebot":return y(n("CookieConsent"),e.category);case"onetrust":return m(n("OptanonConsent"),e.group);case"cookieyes":return k(n("cookieyes-consent"),e.category);case"tcf":{let r=x(n("euconsent-v2"));return r?e.purposes.every(s=>r.has(s)):null}case"google-consent-mode":return null;case"custom":return!e.cookie||e.check?null:n(e.cookie)===e.value}}function _(o,n="analytics_storage"){var r;if(!Array.isArray(o))return null;let e=null;for(let s of o){let t=s&&typeof s=="object"&&"length"in s?Array.prototype.slice.call(s):null;if(!t||t[0]!=="consent"||t[1]!=="default"&&t[1]!=="update")continue;let i=(r=t[2])==null?void 0:r[n];i==="granted"?e=!0:i==="denied"&&(e=!1)}return e}function G(o,n=window){let e=A(o),r=n,s=n.document;switch(e.cmp){case"cookiebot":return{read:()=>{let t=r.Cookiebot;return t!=null&&t.consent&&typeof t.consent[e.category]=="boolean"?t.consent[e.category]===!0:y(d(s,"CookieConsent"),e.category)},subscribe:t=>f(n,["CookiebotOnAccept","CookiebotOnDecline","CookiebotOnConsentReady","CookiebotOnLoad"],t)};case"onetrust":return{read:()=>{let t=r.OnetrustActiveGroups;return typeof t=="string"?`,${t},`.includes(`,${e.group},`):m(d(s,"OptanonConsent"),e.group)},subscribe:t=>f(n,["OneTrustGroupsUpdated"],t)};case"cookieyes":return{read:()=>{var i;let t=r.getCkyConsent;if(typeof t=="function")try{let c=(i=t())==null?void 0:i.categories;if(c&&typeof c[e.category]=="boolean")return c[e.category]===!0}catch(c){}return k(d(s,"cookieyes-consent"),e.category)},subscribe:t=>f(n,["cookieyes_consent_update","cookieyes_banner_load","cookieyes_banner_loaded"],t)};case"tcf":{let t=null;return{read:()=>t,subscribe:i=>{let c,a=!1,p=(u,v)=>{!v||a||(typeof u.listenerId=="number"&&(c=u.listenerId),u.eventStatus==="cmpuishown"?t=!1:t=u.gdprApplies===!1||e.purposes.every(C=>{var w,S;return((S=(w=u.purpose)==null?void 0:w.consents)==null?void 0:S[C])===!0}),i())},b=0,l=()=>{if(a)return;let u=r.__tcfapi;typeof u=="function"?u("addEventListener",2,p):b++<40&&window.setTimeout(l,250)};return l(),()=>{a=!0;let u=r.__tcfapi;typeof u=="function"&&c!==void 0&&u("removeEventListener",2,()=>{},c)}}}}case"google-consent-mode":{let t=()=>r[e.dataLayer];return{read:()=>_(t(),e.type),subscribe:i=>{var l,u;let c=(u=r[l=e.dataLayer])!=null?u:r[l]=[],a=c.push,p=function(...v){let C=a.apply(c,v);return i(),C};c.push=p;let b=window.setInterval(i,1e3);return()=>{window.clearInterval(b),c.push===p&&(c.push=a)}}}}case"custom":return{read:()=>{if(e.check)try{return e.check()===!0}catch(i){return!1}if(!e.cookie)return null;let t=d(s,e.cookie);return t===void 0?null:t===e.value},subscribe:t=>e.event?f(n,[e.event],t):()=>{}}}}0&&(module.exports={consentFromCookies,consentModeGranted,consentWatcher,cookiebotCookieGrants,cookieyesCookieGrants,onetrustCookieGrants,tcStringPurposes});
|
|
1
|
+
"use strict";var T=Object.defineProperty,ie=Object.defineProperties,ae=Object.getOwnPropertyDescriptor,ue=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertyNames,Q=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var z=(n,t,e)=>t in n?T(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,D=(n,t)=>{for(var e in t||(t={}))W.call(t,e)&&z(n,e,t[e]);if(Q)for(var e of Q(t))le.call(t,e)&&z(n,e,t[e]);return n},N=(n,t)=>ie(n,ue(t));var de=(n,t)=>{for(var e in t)T(n,e,{get:t[e],enumerable:!0})},fe=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ce(t))!W.call(n,s)&&s!==e&&T(n,s,{get:()=>t[s],enumerable:!(o=ae(t,s))||o.enumerable});return n};var pe=n=>fe(T({},"__esModule",{value:!0}),n);var he={};de(he,{TCF_DEFAULT_PURPOSES:()=>B,consentFromCookies:()=>H,consentModeGranted:()=>J,consentWatcher:()=>Z,cookiebotCookieGrants:()=>O,cookieyesCookieGrants:()=>M,forgetVisitor:()=>se,onetrustCookieGrants:()=>G,tcStringConsents:()=>L,tcStringPurposes:()=>K});module.exports=pe(he);var B=[1,5,6,8],P=n=>{try{return decodeURIComponent(n)}catch(t){return n}};function k(n,t){if(n)for(let e of n.cookie.split(";")){let o=e.indexOf("=");if(o>0&&e.slice(0,o).trim()===t)return e.slice(o+1).trim()}}function I(n,t,e){let o=[n,...n.document?[n.document]:[]];for(let s of o)for(let r of t)s.addEventListener(r,e);return()=>{for(let s of o)for(let r of t)s.removeEventListener(r,e)}}function O(n,t="statistics"){if(n==null||n==="")return null;let e=P(n).trim();if(e==="-1")return!0;if(e==="0")return!1;let o=new RegExp(`[{,]\\s*${t}\\s*:\\s*(true|false)`).exec(e);return o?o[1]==="true":null}function G(n,t="C0002"){if(n==null||n==="")return null;let e;for(let o of n.split("&"))o.startsWith("groups=")&&(e=P(o.slice(7)));if(e==null)return null;for(let o of e.split(",")){let[s,r]=o.split(":");if(s===t)return r==="1"}return null}function M(n,t="analytics"){if(n==null||n==="")return null;let e=new RegExp(`(?:^|,)${t}:(yes|no)(?:,|$)`).exec(P(n));return e?e[1]==="yes":null}var ge="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",j=n=>{let t="";for(let e of n)t+=ge.indexOf(e).toString(2).padStart(6,"0");return t};function L(n){if(!n)return null;let t=n.split("."),e=t[0];if(!/^[A-Za-z0-9_-]+$/.test(e))return null;let o=j(e);if(o.length<200||parseInt(o.slice(0,6),2)!==2)return null;let s=(d,p)=>d+p<=o.length?parseInt(o.slice(d,d+p),2):null,r=new Set,i=new Set;for(let d=1;d<=24;d++)o[151+d]==="1"&&r.add(d),o[175+d]==="1"&&i.add(d);let a=null,u=s(213,16),l=s(229,1);if(u!==null&&l===0){if(230+u<=o.length){a=new Set;for(let d=1;d<=u;d++)o[229+d]==="1"&&a.add(d)}}else if(u!==null&&l===1){let d=s(230,12),p=242,m=new Set,c=d!==null;for(let g=0;c&&g<(d!=null?d:0);g++){let w=s(p,1),h=s(p+1,16);if(w===null||h===null)c=!1;else if(w===1){let b=s(p+17,16);if(b===null||b<h||b-h>65535)c=!1;else for(let S=h;S<=b;S++)m.add(S);p+=33}else m.add(h),p+=17}c&&(a=m)}let f=new Set,y=new Set;for(let d of t.slice(1)){if(!/^[A-Za-z0-9_-]+$/.test(d))continue;let p=j(d);if(!(p.length<51||parseInt(p.slice(0,3),2)!==3))for(let m=1;m<=24;m++)p[2+m]==="1"&&f.add(m),p[26+m]==="1"&&y.add(m)}return{purposes:r,legitimateInterests:i,vendors:a,publisherPurposes:f,publisherLegitimateInterests:y,purposeOneTreatment:o[200]==="1"}}function K(n){var t,e;return(e=(t=L(n))==null?void 0:t.purposes)!=null?e:null}var ye=new Set([1,3,4,5,6]);function Y(n,t,e,o){return n.purposes.every(r=>t(r)||!ye.has(r)&&e(r))?n.vendorId===void 0?!0:o(n.vendorId):!1}function V(n){var e,o,s,r,i,a,u;let t=typeof n=="string"?{cmp:n}:n;switch(t.cmp){case"cookiebot":return{cmp:"cookiebot",category:(e=t.category)!=null?e:"statistics"};case"onetrust":return{cmp:"onetrust",group:(o=t.group)!=null?o:"C0002"};case"cookieyes":return{cmp:"cookieyes",category:(s=t.category)!=null?s:"analytics"};case"tcf":return{cmp:"tcf",purposes:t.purposes&&t.purposes.length>0?t.purposes:B,vendorId:typeof t.vendorId=="number"&&t.vendorId>0?t.vendorId:void 0};case"google-consent-mode":return{cmp:"google-consent-mode",type:(r=t.type)!=null?r:"analytics_storage",dataLayer:(i=t.dataLayer)!=null?i:"dataLayer",region:typeof t.region=="string"&&t.region.trim()!==""?t.region.trim().toUpperCase():void 0};case"shopify":return{cmp:"shopify",category:(a=t.category)!=null?a:"analytics"};default:return{cmp:"custom",cookie:t.cookie,value:(u=t.value)!=null?u:"accepted",check:t.check,event:t.event,refused:t.refused}}}function H(n,t){let e=V(n);switch(e.cmp){case"cookiebot":return O(t("CookieConsent"),e.category);case"onetrust":return G(t("OptanonConsent"),e.group);case"cookieyes":return M(t("cookieyes-consent"),e.category);case"tcf":{let o=L(t("euconsent-v2"));return o?Y(o.purposeOneTreatment?N(D({},e),{purposes:e.purposes.filter(s=>s!==1)}):e,s=>o.purposes.has(s)||o.publisherPurposes.has(s),s=>o.legitimateInterests.has(s)||o.publisherLegitimateInterests.has(s),s=>o.vendors?o.vendors.has(s):null):null}case"google-consent-mode":return null;case"shopify":return null;case"custom":return!e.cookie||e.check?null:t(e.cookie)===e.value}}var U=()=>({update:null,global:null,regions:new Map});function X(n,t,e){let o=t&&typeof t=="object"&&"length"in t?Array.prototype.slice.call(t):null;if(!o||o[0]!=="consent"||o[1]!=="default"&&o[1]!=="update")return;let s=o[2],r=s==null?void 0:s[e],i=r==="granted"?!0:r==="denied"?!1:null;if(i===null)return;if(o[1]==="update"){n.update=i;return}let a=s==null?void 0:s.region,l=(Array.isArray(a)?a:typeof a=="string"?[a]:[]).filter(f=>typeof f=="string"&&f.trim()!=="").map(f=>f.trim().toUpperCase());if(l.length===0)n.global=i;else for(let f of l)n.regions.set(f,i)}function me(n){return n.update===!1}function q(n,t){if(n.update!==null)return n.update;if(t){let e=n.regions.get(t);if(e!==void 0)return e;let o=t.split("-")[0],s=n.regions.get(o);if(s!==void 0)return s;if(t===o){for(let[r,i]of n.regions)if(i===!1&&r.startsWith(`${o}-`))return!1}return n.global}for(let e of n.regions.values())if(e===!1)return!1;return n.global!==null?n.global:n.regions.size>0?!1:null}function J(n,t="analytics_storage",e){if(!Array.isArray(n))return null;let o=U();for(let s of n)X(o,s,t);return q(o,(e==null?void 0:e.trim().toUpperCase())||void 0)}function Z(n,t=window){let e=V(n),o=t,s=t.document;switch(e.cmp){case"cookiebot":return{read:()=>{let r=o.Cookiebot,i=O(k(s,"CookieConsent"),e.category);return r!=null&&r.consent&&typeof r.consent[e.category]=="boolean"&&(r.hasResponse===!0||i===null)?r.consent[e.category]===!0:i},subscribe:r=>I(t,["CookiebotOnAccept","CookiebotOnDecline","CookiebotOnConsentReady","CookiebotOnLoad"],r),refused(){let r=o.Cookiebot;return((r==null?void 0:r.hasResponse)===!0||k(s,"CookieConsent")!==void 0)&&this.read()===!1}};case"onetrust":return{read:()=>{let r=o.OnetrustActiveGroups;return typeof r=="string"?`,${r},`.includes(`,${e.group},`):G(k(s,"OptanonConsent"),e.group)},subscribe:r=>I(t,["OneTrustGroupsUpdated"],r),refused(){return k(s,"OptanonAlertBoxClosed")!==void 0&&this.read()===!1}};case"cookieyes":return{read:()=>{var i;let r=o.getCkyConsent;if(typeof r=="function")try{let a=(i=r())==null?void 0:i.categories;if(a&&typeof a[e.category]=="boolean")return a[e.category]===!0}catch(a){}return M(k(s,"cookieyes-consent"),e.category)},subscribe:r=>I(t,["cookieyes_consent_update","cookieyes_banner_load","cookieyes_banner_loaded"],r),refused(){var a,u;let r=/(?:^|,)action:yes(?:,|$)/.test(P((a=k(s,"cookieyes-consent"))!=null?a:"")),i=o.getCkyConsent;if(!r&&typeof i=="function")try{r=((u=i())==null?void 0:u.isUserActionCompleted)===!0}catch(l){}return r&&this.read()===!1}};case"tcf":{let r=null,i=!1,a=!1;return{read:()=>r,refused:()=>r===!1&&!i&&a,subscribe:u=>{let l,f=!1,y=!1,d=(c,g)=>{var h,b,S,R;if(!g||f)return;typeof c.listenerId=="number"&&(l=c.listenerId),i=c.eventStatus==="cmpuishown",a=(c.eventStatus==="tcloaded"||c.eventStatus==="useractioncomplete")&&c.purposeOneTreatment!==!0&&c.gdprApplies!==!1&&((b=(h=c.purpose)==null?void 0:h.consents)==null?void 0:b[1])!==!0&&((R=(S=c.publisher)==null?void 0:S.consents)==null?void 0:R[1])!==!0;let w=c.eventStatus==="tcloaded"||c.eventStatus==="useractioncomplete";w&&(y=!0),i?r=!1:!w&&c.gdprApplies!==!1?y||(r=null):r=c.gdprApplies===!1||Y(c.purposeOneTreatment===!0?N(D({},e),{purposes:e.purposes.filter(v=>v!==1)}):e,v=>{var C,_,A,x;return((_=(C=c.purpose)==null?void 0:C.consents)==null?void 0:_[v])===!0||((x=(A=c.publisher)==null?void 0:A.consents)==null?void 0:x[v])===!0},v=>{var C,_,A,x;return((_=(C=c.purpose)==null?void 0:C.legitimateInterests)==null?void 0:_[v])===!0||((x=(A=c.publisher)==null?void 0:A.legitimateInterests)==null?void 0:x[v])===!0},v=>{var C,_;return((_=(C=c.vendor)==null?void 0:C.consents)==null?void 0:_[v])===!0})===!0,u()},p=0,m=()=>{if(f)return;let c=o.__tcfapi;typeof c=="function"?c("addEventListener",2,d):p++<40&&window.setTimeout(m,250)};return m(),()=>{f=!0;let c=o.__tcfapi;typeof c=="function"&&l!==void 0&&c("removeEventListener",2,()=>{},l)}}}}case"google-consent-mode":{let r=null,i=0,a=U(),u=()=>{let l=o[e.dataLayer];if(!Array.isArray(l))return null;for((l!==r||l.length<i)&&(r=l,i=0,a=U());i<l.length;i++)X(a,l[i],e.type);return q(a,e.region)};return{read:u,refused:()=>u()===!1&&me(a),subscribe:l=>{let f=new WeakSet,y=!1,d=[],p=-1,m=()=>{var w,h;let g=(h=o[w=e.dataLayer])!=null?h:o[w]=[];if(!f.has(g)){f.add(g);let b=g.push,S=function(...R){let v=b.apply(g,R);return p=g.length,y||l(),v};g.push=S,d.push(()=>{g.push===S&&(g.push=b)})}g.length!==p&&(p=g.length,l())};m();let c=window.setInterval(m,1e3);return()=>{y=!0,window.clearInterval(c);for(let g of d)g()}}}}case"shopify":{let r=e.category==="marketing"?"marketingAllowed":e.category==="preferences"?"preferencesProcessingAllowed":"analyticsProcessingAllowed";return{read:()=>{var a,u;let i=(u=(a=o.Shopify)==null?void 0:a.customerPrivacy)==null?void 0:u[r];if(typeof i!="function")return null;try{let l=i();return typeof l=="boolean"?l:null}catch(l){return null}},refused(){var a,u;let i=(a=o.Shopify)==null?void 0:a.customerPrivacy;if(typeof(i==null?void 0:i.currentVisitorConsent)!="function")return!1;try{return((u=i.currentVisitorConsent())==null?void 0:u[e.category])==="no"}catch(l){return!1}},subscribe:i=>{let a=I(t,["visitorConsentCollected"],i),u=!1,l=0,f=()=>{if(u)return;let y=o.Shopify;if(y!=null&&y.customerPrivacy){i();return}if(typeof(y==null?void 0:y.loadFeatures)=="function"){try{y.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],d=>{!u&&!d&&i()})}catch(d){}return}l++<40&&window.setTimeout(f,250)};return f(),()=>{u=!0,a()}}}}case"custom":return{read:()=>{if(e.check)try{return e.check()===!0}catch(i){return!1}if(!e.cookie)return null;let r=k(s,e.cookie);return r===void 0?null:r===e.value},refused:()=>{var r;if(e.check)try{return((r=e.refused)==null?void 0:r.call(e))===!0}catch(i){return!1}return!!e.cookie&&k(s,e.cookie)!==void 0&&k(s,e.cookie)!==e.value},subscribe:r=>e.event?I(t,[e.event],r):()=>{}}}}function $(n){return n?`_${n.slice(0,12)}`:""}var E="_snt_uid";function ee(n){return`${E}${$(n)}`}var F="__sntForgetGen";function te(n){var t,e;try{let o=window,s=(t=o[F])!=null?t:o[F]={};s[n]=((e=s[n])!=null?e:0)+1}catch(o){}}var ne="_snt_snap:";var Ce=56*1024;function oe(n){return`_snt_retry_${n.slice(0,12)}`}function re(n){return`_snt_goal_retry_${n.slice(0,12)}`}function se(n){if(typeof window=="undefined"||!n)return!1;te(n);let t=!1,e=ee(n);try{if(new RegExp(`(?:^|; )${e}=`).test(document.cookie)){let i=location.protocol==="https:"?"; Secure":"";document.cookie=`${e}=; max-age=0; SameSite=lax; path=/${i}`,t=!0}}catch(i){}let o=$(n),s=[e,"_snt_graph_edges",ne+n,oe(n),re(n),`_snt_graph_nodes${o}`],r=[`_snt_asgn${o}_`];for(let i of["localStorage","sessionStorage"])try{let a=window[i];for(let u of s)a.getItem(u)!==null&&(a.removeItem(u),t=!0);for(let u=a.length-1;u>=0;u--){let l=a.key(u);l&&r.some(f=>l.startsWith(f))&&(a.removeItem(l),t=!0)}}catch(a){}try{(new RegExp(`(?:^|; )${E}=[^;]`).test(document.cookie)||localStorage.getItem(E)!==null||sessionStorage.getItem(E)!==null)&&localStorage.setItem(`${E}_tomb${o}`,"1")}catch(i){}return t}0&&(module.exports={TCF_DEFAULT_PURPOSES,consentFromCookies,consentModeGranted,consentWatcher,cookiebotCookieGrants,cookieyesCookieGrants,forgetVisitor,onetrustCookieGrants,tcStringConsents,tcStringPurposes});
|
|
2
2
|
//# sourceMappingURL=index-consent.js.map
|