@scalemule/news-publication 0.0.13 → 0.0.14
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/dist/{chunk-5MHPE77S.js → chunk-5YQYJ2L2.js} +1 -1
- package/dist/chunk-QWK6G2UF.js +117 -0
- package/dist/{chunk-FUUL2PSF.js → chunk-WZ3NQRQO.js} +1 -1
- package/dist/compliance.cjs +19 -0
- package/dist/compliance.d.cts +2 -0
- package/dist/compliance.d.ts +2 -0
- package/dist/compliance.js +2 -0
- package/dist/cookie-consent-banner.cjs +25 -369
- package/dist/cookie-consent-banner.js +2 -2
- package/dist/cookie-settings-view.cjs +21 -193
- package/dist/cookie-settings-view.js +2 -2
- package/dist/index.cjs +128 -448
- package/dist/index.d.cts +14 -113
- package/dist/index.d.ts +14 -113
- package/dist/index.js +3 -3
- package/dist/{marketplace-CpGWPbFk.d.ts → marketplace-29i5w4LS.d.cts} +1 -1
- package/dist/{marketplace-CpGWPbFk.d.cts → marketplace-29i5w4LS.d.ts} +1 -1
- package/dist/marketplace-view.d.cts +1 -1
- package/dist/marketplace-view.d.ts +1 -1
- package/dist/{meet-5Ym5bxfh.d.cts → meet-RWmfj3I3.d.cts} +1 -1
- package/dist/{meet-5Ym5bxfh.d.ts → meet-RWmfj3I3.d.ts} +1 -1
- package/dist/meet-forms.d.cts +1 -1
- package/dist/meet-forms.d.ts +1 -1
- package/dist/meet-view.d.cts +1 -1
- package/dist/meet-view.d.ts +1 -1
- package/dist/snapshot-file.d.cts +1 -1
- package/dist/snapshot-file.d.ts +1 -1
- package/dist/{snapshot-BS4hn1dk.d.ts → snapshot-sHgQHuAF.d.cts} +1 -1
- package/dist/{snapshot-BS4hn1dk.d.cts → snapshot-sHgQHuAF.d.ts} +1 -1
- package/package.json +12 -2
- package/dist/chunk-L5OE6DND.js +0 -506
package/dist/chunk-L5OE6DND.js
DELETED
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
// src/cookies.ts
|
|
2
|
-
var COOKIE_CONSENT_KEY = "sm_cookie_consent_v1";
|
|
3
|
-
var COOKIE_CONSENT_BACKUP_KEY = "napsite_cookie_consent_v1";
|
|
4
|
-
var COOKIE_CONSENT_EVENT = "scalemule-cookie-consent-change";
|
|
5
|
-
var COOKIE_CONSENT_MAX_AGE_SECONDS = 365 * 24 * 60 * 60;
|
|
6
|
-
var DEFAULT_CONSENT_HUB_URL = "https://bayareachronicle.com/consent-bridge.html";
|
|
7
|
-
var NETWORK_CONSENT_STORAGE_KEY = "sm_network_consent_status";
|
|
8
|
-
var DEFAULT_PREFERENCES_REJECTED = {
|
|
9
|
-
essential: true,
|
|
10
|
-
performance: false,
|
|
11
|
-
functional: false,
|
|
12
|
-
advertising: false
|
|
13
|
-
};
|
|
14
|
-
var DEFAULT_PREFERENCES_ACCEPTED = {
|
|
15
|
-
essential: true,
|
|
16
|
-
performance: true,
|
|
17
|
-
functional: true,
|
|
18
|
-
advertising: true
|
|
19
|
-
};
|
|
20
|
-
var COOKIE_CATEGORIES = [
|
|
21
|
-
{
|
|
22
|
-
id: "essential",
|
|
23
|
-
title: "Strictly Necessary Cookies",
|
|
24
|
-
shortDescription: "Essential for site security, navigation, and privacy preference management.",
|
|
25
|
-
fullDescription: "These cookies are necessary for the website to function properly and securely. They enable core features such as load balancing, CSRF protection, secure session tokens, and remembering your cookie consent choice. Because the site cannot function without them, they cannot be turned off.",
|
|
26
|
-
required: true,
|
|
27
|
-
cookies: [
|
|
28
|
-
{
|
|
29
|
-
name: "sm_cookie_consent_v1",
|
|
30
|
-
provider: "First-Party (ScaleMule)",
|
|
31
|
-
purpose: "Stores your verified cookie privacy and category consent choices.",
|
|
32
|
-
duration: "1 year",
|
|
33
|
-
type: "HTTP Cookie"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: "napsite_session_v1",
|
|
37
|
-
provider: "First-Party",
|
|
38
|
-
purpose: "Maintains session continuity, security tokens, and server routing.",
|
|
39
|
-
duration: "30 minutes (idle)",
|
|
40
|
-
type: "Session Storage"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "napsite_preview",
|
|
44
|
-
provider: "First-Party",
|
|
45
|
-
purpose: "Verifies preview access permissions when viewing unpublished newsroom editions.",
|
|
46
|
-
duration: "14 days",
|
|
47
|
-
type: "HTTP Cookie"
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: "performance",
|
|
53
|
-
title: "Performance & Analytics Cookies",
|
|
54
|
-
shortDescription: "Help us measure reader engagement, story completion, and site reliability.",
|
|
55
|
-
fullDescription: "These cookies collect anonymous information about how visitors navigate our news publication. They allow us to count article reads, understand scroll depth and reading completion, and identify broken links or slow-loading assets so we can keep our community reporting responsive and fast. All metrics are aggregated and never contain personal information.",
|
|
56
|
-
required: false,
|
|
57
|
-
cookies: [
|
|
58
|
-
{
|
|
59
|
-
name: "napsite_visitor_v1",
|
|
60
|
-
provider: "First-Party",
|
|
61
|
-
purpose: "A randomized anonymous UUIDv7 to count distinct readers without tracking personal identity.",
|
|
62
|
-
duration: "1 year",
|
|
63
|
-
type: "Local Storage"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "napsite_analytics_v1",
|
|
67
|
-
provider: "First-Party",
|
|
68
|
-
purpose: "Connects reading completion and web vitals to the anonymous session.",
|
|
69
|
-
duration: "30 minutes",
|
|
70
|
-
type: "HTTP Cookie"
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
id: "functional",
|
|
76
|
-
title: "Functional & Personalization Cookies",
|
|
77
|
-
shortDescription: "Remember your reading preferences, text size, and narration audio settings.",
|
|
78
|
-
fullDescription: "These cookies enable enhanced convenience features designed for readers. They remember your custom text sizing, keep your preferred audio narration playback speed (e.g., 1.0x vs 1.25x), and preserve your local town filters across the front page so you always see news closest to your neighborhood.",
|
|
79
|
-
required: false,
|
|
80
|
-
cookies: [
|
|
81
|
-
{
|
|
82
|
-
name: "reader_text_size",
|
|
83
|
-
provider: "First-Party",
|
|
84
|
-
purpose: "Remembers your preferred reading font size across articles.",
|
|
85
|
-
duration: "1 year",
|
|
86
|
-
type: "Local Storage"
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "news_publication_theme",
|
|
90
|
-
provider: "First-Party",
|
|
91
|
-
purpose: "Remembers your reading theme preference (light, dark, or system).",
|
|
92
|
-
duration: "1 year",
|
|
93
|
-
type: "HTTP Cookie"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: "audio_narration_speed",
|
|
97
|
-
provider: "First-Party",
|
|
98
|
-
purpose: "Stores your preferred audio player playback rate (e.g. 1.0x, 1.25x).",
|
|
99
|
-
duration: "1 year",
|
|
100
|
-
type: "Local Storage"
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
id: "advertising",
|
|
106
|
-
title: "Advertising & Local Sponsorship Cookies",
|
|
107
|
-
shortDescription: "Support local business sponsors by capping repetition and measuring notices.",
|
|
108
|
-
fullDescription: "Our journalism is supported by local business sponsors and community partners. These cookies ensure you do not see the same sponsor banner repeatedly (frequency capping) and help local merchants measure whether their announcement reached their community. They never track your activity across unrelated third-party websites or build external advertising profiles.",
|
|
109
|
-
required: false,
|
|
110
|
-
cookies: [
|
|
111
|
-
{
|
|
112
|
-
name: "napsite_sponsor_cap",
|
|
113
|
-
provider: "First-Party",
|
|
114
|
-
purpose: "Prevents repetitive display of identical local business announcements.",
|
|
115
|
-
duration: "7 days",
|
|
116
|
-
type: "Local Storage"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: "local_sponsor_ref",
|
|
120
|
-
provider: "First-Party",
|
|
121
|
-
purpose: "Attributes community inquiries directly to the sponsoring local merchant.",
|
|
122
|
-
duration: "30 days",
|
|
123
|
-
type: "Local Storage"
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
];
|
|
128
|
-
var memoryConsent = null;
|
|
129
|
-
function readCookie(name) {
|
|
130
|
-
if (typeof document === "undefined") return null;
|
|
131
|
-
const match = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([.$?*|{}()[\]\\/+^])/g, "\\$1") + "=([^;]*)"));
|
|
132
|
-
return match ? decodeURIComponent(match[1]) : null;
|
|
133
|
-
}
|
|
134
|
-
function writeCookie(name, value, maxAgeSeconds) {
|
|
135
|
-
if (typeof document === "undefined") return;
|
|
136
|
-
const secure = typeof location !== "undefined" && location.protocol === "https:" ? "; Secure" : "";
|
|
137
|
-
document.cookie = `${name}=${encodeURIComponent(value)}; Path=/; Max-Age=${maxAgeSeconds}; SameSite=Lax${secure}`;
|
|
138
|
-
}
|
|
139
|
-
function getCookieConsent() {
|
|
140
|
-
if (typeof window === "undefined") return memoryConsent;
|
|
141
|
-
try {
|
|
142
|
-
const raw = readCookie(COOKIE_CONSENT_KEY) || readCookie(COOKIE_CONSENT_BACKUP_KEY);
|
|
143
|
-
if (raw) {
|
|
144
|
-
const parsed = JSON.parse(raw);
|
|
145
|
-
if (parsed && parsed.version === 1 && parsed.preferences) {
|
|
146
|
-
memoryConsent = parsed;
|
|
147
|
-
return parsed;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
const stored = window.localStorage?.getItem(COOKIE_CONSENT_KEY);
|
|
151
|
-
if (stored) {
|
|
152
|
-
const parsed = JSON.parse(stored);
|
|
153
|
-
if (parsed && parsed.version === 1 && parsed.preferences) {
|
|
154
|
-
memoryConsent = parsed;
|
|
155
|
-
return parsed;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
} catch {
|
|
159
|
-
}
|
|
160
|
-
return memoryConsent;
|
|
161
|
-
}
|
|
162
|
-
var EU_EEA_UK_COUNTRIES = /* @__PURE__ */ new Set([
|
|
163
|
-
"AT",
|
|
164
|
-
"BE",
|
|
165
|
-
"BG",
|
|
166
|
-
"HR",
|
|
167
|
-
"CY",
|
|
168
|
-
"CZ",
|
|
169
|
-
"DK",
|
|
170
|
-
"EE",
|
|
171
|
-
"FI",
|
|
172
|
-
"FR",
|
|
173
|
-
"DE",
|
|
174
|
-
"GR",
|
|
175
|
-
"HU",
|
|
176
|
-
"IE",
|
|
177
|
-
"IT",
|
|
178
|
-
"LV",
|
|
179
|
-
"LT",
|
|
180
|
-
"LU",
|
|
181
|
-
"MT",
|
|
182
|
-
"NL",
|
|
183
|
-
"PL",
|
|
184
|
-
"PT",
|
|
185
|
-
"RO",
|
|
186
|
-
"SK",
|
|
187
|
-
"SI",
|
|
188
|
-
"ES",
|
|
189
|
-
"SE",
|
|
190
|
-
"IS",
|
|
191
|
-
"LI",
|
|
192
|
-
"NO",
|
|
193
|
-
"GB",
|
|
194
|
-
"CH"
|
|
195
|
-
]);
|
|
196
|
-
function isGeoConsentRequired(countryCode) {
|
|
197
|
-
if (countryCode && typeof countryCode === "string") {
|
|
198
|
-
const code = countryCode.trim().toUpperCase();
|
|
199
|
-
if (code.length === 2) {
|
|
200
|
-
return EU_EEA_UK_COUNTRIES.has(code);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (typeof window !== "undefined") {
|
|
204
|
-
try {
|
|
205
|
-
const cached = readCookie("sm_geo_country") || window.localStorage?.getItem("sm_geo_country");
|
|
206
|
-
if (cached && typeof cached === "string" && cached.length === 2) {
|
|
207
|
-
return EU_EEA_UK_COUNTRIES.has(cached.toUpperCase());
|
|
208
|
-
}
|
|
209
|
-
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
210
|
-
if (tz) {
|
|
211
|
-
if (/^(America|US|Canada|Pacific)\//i.test(tz)) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
if (/^(Europe|Atlantic\/Reykjavik|Atlantic\/Canary|Atlantic\/Faeroe|Atlantic\/Madeira|Atlantic\/Azores|WET|CET|EET|GMT)/i.test(tz)) {
|
|
215
|
-
return true;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
} catch {
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
function checkUrlConsentBridge() {
|
|
224
|
-
if (typeof window === "undefined") return false;
|
|
225
|
-
try {
|
|
226
|
-
const url = new URL(window.location.href);
|
|
227
|
-
const param = url.searchParams.get("sm_consent");
|
|
228
|
-
if (!param) return false;
|
|
229
|
-
if (param === "accepted" || param === "1" || param === "all") {
|
|
230
|
-
acceptAllCookies();
|
|
231
|
-
} else if (param === "rejected" || param === "0" || param === "essential") {
|
|
232
|
-
rejectOptionalCookies();
|
|
233
|
-
} else {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
url.searchParams.delete("sm_consent");
|
|
237
|
-
const newSearch = url.searchParams.toString() ? `?${url.searchParams.toString()}` : "";
|
|
238
|
-
window.history.replaceState(null, "", `${url.pathname}${newSearch}${url.hash}`);
|
|
239
|
-
return true;
|
|
240
|
-
} catch {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function decorateNetworkUrl(targetUrl) {
|
|
245
|
-
const consent = getCookieConsent();
|
|
246
|
-
if (!consent) return targetUrl;
|
|
247
|
-
try {
|
|
248
|
-
const base = typeof window !== "undefined" ? window.location.origin : "https://localhost";
|
|
249
|
-
const url = new URL(targetUrl, base);
|
|
250
|
-
const value = consent.preferences.performance || consent.preferences.advertising ? "1" : "0";
|
|
251
|
-
url.searchParams.set("sm_consent", value);
|
|
252
|
-
return url.toString();
|
|
253
|
-
} catch {
|
|
254
|
-
return targetUrl;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function queryNetworkConsentHub(hubUrl = DEFAULT_CONSENT_HUB_URL, timeoutMs = 1e3) {
|
|
258
|
-
if (typeof window === "undefined") return Promise.resolve(null);
|
|
259
|
-
try {
|
|
260
|
-
const hubOrigin = new URL(hubUrl).origin;
|
|
261
|
-
if (window.location.origin === hubOrigin) {
|
|
262
|
-
try {
|
|
263
|
-
const direct = window.localStorage?.getItem(NETWORK_CONSENT_STORAGE_KEY);
|
|
264
|
-
if (direct === "accepted" || direct === "rejected") {
|
|
265
|
-
return Promise.resolve(direct);
|
|
266
|
-
}
|
|
267
|
-
} catch {
|
|
268
|
-
}
|
|
269
|
-
return Promise.resolve(null);
|
|
270
|
-
}
|
|
271
|
-
return new Promise((resolve) => {
|
|
272
|
-
let settled = false;
|
|
273
|
-
let iframe = null;
|
|
274
|
-
let timer = null;
|
|
275
|
-
const finish = (result) => {
|
|
276
|
-
if (settled) return;
|
|
277
|
-
settled = true;
|
|
278
|
-
if (timer !== null) window.clearTimeout(timer);
|
|
279
|
-
window.removeEventListener("message", onMessage);
|
|
280
|
-
if (iframe && iframe.parentNode) {
|
|
281
|
-
try {
|
|
282
|
-
iframe.parentNode.removeChild(iframe);
|
|
283
|
-
} catch {
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
resolve(result);
|
|
287
|
-
};
|
|
288
|
-
const sendGet = () => {
|
|
289
|
-
try {
|
|
290
|
-
iframe?.contentWindow?.postMessage({ type: "SM_CONSENT_GET" }, hubOrigin);
|
|
291
|
-
} catch {
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
const onMessage = (event) => {
|
|
295
|
-
if (event.origin !== hubOrigin) return;
|
|
296
|
-
const data = event.data;
|
|
297
|
-
if (!data || typeof data !== "object") return;
|
|
298
|
-
if (data.type === "SM_CONSENT_STATUS") {
|
|
299
|
-
const status = data.status === "accepted" || data.status === "rejected" ? data.status : null;
|
|
300
|
-
finish(status);
|
|
301
|
-
} else if (data.type === "SM_CONSENT_BRIDGE_READY") {
|
|
302
|
-
sendGet();
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
window.addEventListener("message", onMessage);
|
|
306
|
-
timer = window.setTimeout(() => {
|
|
307
|
-
finish(null);
|
|
308
|
-
}, timeoutMs);
|
|
309
|
-
try {
|
|
310
|
-
iframe = document.createElement("iframe");
|
|
311
|
-
iframe.src = hubUrl;
|
|
312
|
-
iframe.style.position = "absolute";
|
|
313
|
-
iframe.style.width = "0";
|
|
314
|
-
iframe.style.height = "0";
|
|
315
|
-
iframe.style.border = "0";
|
|
316
|
-
iframe.style.display = "none";
|
|
317
|
-
iframe.style.visibility = "hidden";
|
|
318
|
-
iframe.setAttribute("aria-hidden", "true");
|
|
319
|
-
iframe.setAttribute("tabindex", "-1");
|
|
320
|
-
iframe.onload = () => {
|
|
321
|
-
sendGet();
|
|
322
|
-
};
|
|
323
|
-
iframe.onerror = () => {
|
|
324
|
-
finish(null);
|
|
325
|
-
};
|
|
326
|
-
const target = document.body || document.documentElement;
|
|
327
|
-
target.appendChild(iframe);
|
|
328
|
-
} catch {
|
|
329
|
-
finish(null);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
} catch {
|
|
333
|
-
return Promise.resolve(null);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function setNetworkConsentHub(status, hubUrl = DEFAULT_CONSENT_HUB_URL) {
|
|
337
|
-
if (typeof window === "undefined") return;
|
|
338
|
-
try {
|
|
339
|
-
const hubOrigin = new URL(hubUrl).origin;
|
|
340
|
-
if (window.location.origin === hubOrigin) {
|
|
341
|
-
try {
|
|
342
|
-
if (status) {
|
|
343
|
-
window.localStorage?.setItem(NETWORK_CONSENT_STORAGE_KEY, status);
|
|
344
|
-
} else {
|
|
345
|
-
window.localStorage?.removeItem(NETWORK_CONSENT_STORAGE_KEY);
|
|
346
|
-
}
|
|
347
|
-
} catch {
|
|
348
|
-
}
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
let iframe = null;
|
|
352
|
-
let timer = null;
|
|
353
|
-
const cleanup = () => {
|
|
354
|
-
if (timer !== null) window.clearTimeout(timer);
|
|
355
|
-
window.removeEventListener("message", onMessage);
|
|
356
|
-
if (iframe && iframe.parentNode) {
|
|
357
|
-
try {
|
|
358
|
-
iframe.parentNode.removeChild(iframe);
|
|
359
|
-
} catch {
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
const sendSet = () => {
|
|
364
|
-
try {
|
|
365
|
-
iframe?.contentWindow?.postMessage({ type: "SM_CONSENT_SET", status }, hubOrigin);
|
|
366
|
-
} catch {
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
const onMessage = (event) => {
|
|
370
|
-
if (event.origin !== hubOrigin) return;
|
|
371
|
-
const data = event.data;
|
|
372
|
-
if (!data || typeof data !== "object") return;
|
|
373
|
-
if (data.type === "SM_CONSENT_SAVED") {
|
|
374
|
-
cleanup();
|
|
375
|
-
} else if (data.type === "SM_CONSENT_BRIDGE_READY") {
|
|
376
|
-
sendSet();
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
window.addEventListener("message", onMessage);
|
|
380
|
-
timer = window.setTimeout(cleanup, 2500);
|
|
381
|
-
try {
|
|
382
|
-
iframe = document.createElement("iframe");
|
|
383
|
-
iframe.src = hubUrl;
|
|
384
|
-
iframe.style.position = "absolute";
|
|
385
|
-
iframe.style.width = "0";
|
|
386
|
-
iframe.style.height = "0";
|
|
387
|
-
iframe.style.border = "0";
|
|
388
|
-
iframe.style.display = "none";
|
|
389
|
-
iframe.style.visibility = "hidden";
|
|
390
|
-
iframe.setAttribute("aria-hidden", "true");
|
|
391
|
-
iframe.setAttribute("tabindex", "-1");
|
|
392
|
-
iframe.onload = () => {
|
|
393
|
-
sendSet();
|
|
394
|
-
};
|
|
395
|
-
iframe.onerror = cleanup;
|
|
396
|
-
const target = document.body || document.documentElement;
|
|
397
|
-
target.appendChild(iframe);
|
|
398
|
-
} catch {
|
|
399
|
-
cleanup();
|
|
400
|
-
}
|
|
401
|
-
} catch {
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
function hasConsented() {
|
|
405
|
-
return getCookieConsent() !== null;
|
|
406
|
-
}
|
|
407
|
-
function isCategoryAllowed(category) {
|
|
408
|
-
if (category === "essential") return true;
|
|
409
|
-
const consent = getCookieConsent();
|
|
410
|
-
if (!consent) {
|
|
411
|
-
if (typeof navigator !== "undefined") {
|
|
412
|
-
const nav = navigator;
|
|
413
|
-
if (nav.globalPrivacyControl || nav.doNotTrack === "1") {
|
|
414
|
-
return false;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
return Boolean(consent.preferences[category]);
|
|
420
|
-
}
|
|
421
|
-
function setCookieConsent(preferences, source = "settings_save") {
|
|
422
|
-
const mergedPreferences = {
|
|
423
|
-
essential: true,
|
|
424
|
-
performance: Boolean(preferences.performance),
|
|
425
|
-
functional: Boolean(preferences.functional),
|
|
426
|
-
advertising: Boolean(preferences.advertising)
|
|
427
|
-
};
|
|
428
|
-
let anonymous_id;
|
|
429
|
-
if (typeof window !== "undefined") {
|
|
430
|
-
try {
|
|
431
|
-
anonymous_id = window.localStorage?.getItem("napsite_visitor_v1") || void 0;
|
|
432
|
-
} catch {
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
const record = {
|
|
436
|
-
version: 1,
|
|
437
|
-
preferences: mergedPreferences,
|
|
438
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
439
|
-
anonymous_id,
|
|
440
|
-
source
|
|
441
|
-
};
|
|
442
|
-
memoryConsent = record;
|
|
443
|
-
const serialized = JSON.stringify(record);
|
|
444
|
-
writeCookie(COOKIE_CONSENT_KEY, serialized, COOKIE_CONSENT_MAX_AGE_SECONDS);
|
|
445
|
-
writeCookie(COOKIE_CONSENT_BACKUP_KEY, serialized, COOKIE_CONSENT_MAX_AGE_SECONDS);
|
|
446
|
-
if (typeof window !== "undefined") {
|
|
447
|
-
try {
|
|
448
|
-
window.localStorage?.setItem(COOKIE_CONSENT_KEY, serialized);
|
|
449
|
-
} catch {
|
|
450
|
-
}
|
|
451
|
-
const networkStatus = mergedPreferences.performance || mergedPreferences.advertising ? "accepted" : "rejected";
|
|
452
|
-
setNetworkConsentHub(networkStatus);
|
|
453
|
-
window.dispatchEvent(new CustomEvent(COOKIE_CONSENT_EVENT, { detail: record }));
|
|
454
|
-
}
|
|
455
|
-
return record;
|
|
456
|
-
}
|
|
457
|
-
function acceptAllCookies() {
|
|
458
|
-
return setCookieConsent(DEFAULT_PREFERENCES_ACCEPTED, "banner_accept");
|
|
459
|
-
}
|
|
460
|
-
function rejectOptionalCookies() {
|
|
461
|
-
return setCookieConsent(DEFAULT_PREFERENCES_REJECTED, "banner_reject");
|
|
462
|
-
}
|
|
463
|
-
function clearCookieConsent() {
|
|
464
|
-
memoryConsent = null;
|
|
465
|
-
if (typeof document !== "undefined") {
|
|
466
|
-
document.cookie = `${COOKIE_CONSENT_KEY}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
467
|
-
document.cookie = `${COOKIE_CONSENT_BACKUP_KEY}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
468
|
-
}
|
|
469
|
-
if (typeof window !== "undefined") {
|
|
470
|
-
try {
|
|
471
|
-
window.localStorage?.removeItem(COOKIE_CONSENT_KEY);
|
|
472
|
-
} catch {
|
|
473
|
-
}
|
|
474
|
-
setNetworkConsentHub(null);
|
|
475
|
-
window.dispatchEvent(new CustomEvent(COOKIE_CONSENT_EVENT, { detail: null }));
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
async function recordConsentToCompliance(record, options) {
|
|
479
|
-
if (typeof window === "undefined") return;
|
|
480
|
-
const endpoint = options?.endpoint || "/api/compliance/consent";
|
|
481
|
-
try {
|
|
482
|
-
const payload = {
|
|
483
|
-
consent_type: "cookie_policy",
|
|
484
|
-
granted: record.preferences.performance || record.preferences.advertising,
|
|
485
|
-
preferences: record.preferences,
|
|
486
|
-
source: record.source,
|
|
487
|
-
anonymous_id: record.anonymous_id,
|
|
488
|
-
timestamp: record.timestamp,
|
|
489
|
-
url: window.location.href,
|
|
490
|
-
user_agent: window.navigator.userAgent
|
|
491
|
-
};
|
|
492
|
-
if (typeof navigator.sendBeacon === "function") {
|
|
493
|
-
navigator.sendBeacon(endpoint, new Blob([JSON.stringify(payload)], { type: "application/json" }));
|
|
494
|
-
} else {
|
|
495
|
-
await fetch(endpoint, {
|
|
496
|
-
method: "POST",
|
|
497
|
-
headers: { "content-type": "application/json" },
|
|
498
|
-
body: JSON.stringify(payload),
|
|
499
|
-
keepalive: true
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
} catch {
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
export { COOKIE_CATEGORIES, COOKIE_CONSENT_BACKUP_KEY, COOKIE_CONSENT_EVENT, COOKIE_CONSENT_KEY, COOKIE_CONSENT_MAX_AGE_SECONDS, DEFAULT_CONSENT_HUB_URL, DEFAULT_PREFERENCES_ACCEPTED, DEFAULT_PREFERENCES_REJECTED, EU_EEA_UK_COUNTRIES, NETWORK_CONSENT_STORAGE_KEY, acceptAllCookies, checkUrlConsentBridge, clearCookieConsent, decorateNetworkUrl, getCookieConsent, hasConsented, isCategoryAllowed, isGeoConsentRequired, queryNetworkConsentHub, recordConsentToCompliance, rejectOptionalCookies, setCookieConsent, setNetworkConsentHub };
|