@nortic/citronkaka-ui 0.0.2-beta.32 → 0.1.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const m = { BASE_URL: "/", DEV: !1, DOMAIN: "
|
|
1
|
+
const m = { BASE_URL: "/", DEV: !1, DOMAIN: ".nortic.io", MODE: "production", NODE_ENV: "production", PROD: !0, SSR: !1 }, { DOMAIN: h } = m, k = {
|
|
2
2
|
domain: h,
|
|
3
3
|
defaultModel: {
|
|
4
4
|
useraction: !1,
|
|
@@ -14,8 +14,8 @@ const m = { BASE_URL: "/", DEV: !1, DOMAIN: "localhost", MODE: "development", NO
|
|
|
14
14
|
};
|
|
15
15
|
class d {
|
|
16
16
|
static createCookieString(e, t, o = {}) {
|
|
17
|
-
const { expires:
|
|
18
|
-
return `${e}=${a}${u}; path=${i}; SameSite=${
|
|
17
|
+
const { expires: n, path: i = "/", sameSite: s = "Strict", domain: c } = o, a = encodeURIComponent(t), u = n ? `; expires=${n.toUTCString()}` : "", p = c ? `; domain=${c}` : "";
|
|
18
|
+
return `${e}=${a}${u}; path=${i}; SameSite=${s}${p}`;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Sets a cookie with the specified options.
|
|
@@ -24,9 +24,9 @@ class d {
|
|
|
24
24
|
* @param days Number of days until the cookie expires.
|
|
25
25
|
* @param domain Optional domain for the cookie.
|
|
26
26
|
*/
|
|
27
|
-
static set(e, t, o,
|
|
28
|
-
const i = typeof t == "string" ? t : JSON.stringify(t),
|
|
29
|
-
document.cookie = this.createCookieString(e, i, { expires:
|
|
27
|
+
static set(e, t, o, n) {
|
|
28
|
+
const i = typeof t == "string" ? t : JSON.stringify(t), s = new Date(Date.now() + o * 24 * 60 * 60 * 1e3);
|
|
29
|
+
document.cookie = this.createCookieString(e, i, { expires: s, domain: n });
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Retrieves the value of a cookie by name.
|
|
@@ -62,14 +62,14 @@ class f {
|
|
|
62
62
|
* @param blacklist An array of RegExp patterns for cookies to delete.
|
|
63
63
|
*/
|
|
64
64
|
static run(e, t = d) {
|
|
65
|
-
function o(
|
|
65
|
+
function o(n) {
|
|
66
66
|
document.cookie.split(";").forEach((i) => {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const s = i.split("=")[0].trim();
|
|
68
|
+
n.test(s) && (t.delete(s), console.warn(`Removed cookie: ${s}`));
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
e.forEach((
|
|
72
|
-
o(
|
|
71
|
+
e.forEach((n) => {
|
|
72
|
+
o(n);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -100,9 +100,9 @@ class y {
|
|
|
100
100
|
* @param cookieString The cookie string to be set.
|
|
101
101
|
*/
|
|
102
102
|
set(o) {
|
|
103
|
-
var
|
|
104
|
-
const i = o.split("=")[0].trim(),
|
|
105
|
-
|
|
103
|
+
var n;
|
|
104
|
+
const i = o.split("=")[0].trim(), s = o.match(/expires=([^;]+)/i);
|
|
105
|
+
s && new Date(s[1]).getTime() < Date.now() || !e.some((c) => c.test(i)) ? (n = t.set) == null || n.call(document, o) : console.warn(`Blocked cookie: ${i}`);
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
}
|
|
@@ -132,18 +132,18 @@ class l {
|
|
|
132
132
|
static interceptScriptCreation(e) {
|
|
133
133
|
const t = document.createElement.bind(document);
|
|
134
134
|
document.createElement = function(o) {
|
|
135
|
-
const
|
|
135
|
+
const n = t(o);
|
|
136
136
|
if (o.toLowerCase() === "script") {
|
|
137
|
-
const i =
|
|
137
|
+
const i = n, s = Object.getOwnPropertyDescriptor(
|
|
138
138
|
HTMLScriptElement.prototype,
|
|
139
139
|
"src"
|
|
140
140
|
);
|
|
141
|
-
|
|
141
|
+
s && Object.defineProperty(i, "src", {
|
|
142
142
|
configurable: !0,
|
|
143
143
|
enumerable: !0,
|
|
144
144
|
get() {
|
|
145
145
|
var c;
|
|
146
|
-
return (c =
|
|
146
|
+
return (c = s.get) == null ? void 0 : c.call(i);
|
|
147
147
|
},
|
|
148
148
|
set(c) {
|
|
149
149
|
var a;
|
|
@@ -151,11 +151,11 @@ class l {
|
|
|
151
151
|
console.warn(`Blocked script: ${c}`), i.type = "javascript/blocked";
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
|
-
(a =
|
|
154
|
+
(a = s.set) == null || a.call(i, c);
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
return
|
|
158
|
+
return n;
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
@@ -166,15 +166,15 @@ class l {
|
|
|
166
166
|
static observeDynamicScripts(e) {
|
|
167
167
|
new MutationObserver((t) => {
|
|
168
168
|
t.forEach(({ addedNodes: o }) => {
|
|
169
|
-
o.forEach((
|
|
170
|
-
if (
|
|
171
|
-
const i =
|
|
169
|
+
o.forEach((n) => {
|
|
170
|
+
if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "SCRIPT") {
|
|
171
|
+
const i = n;
|
|
172
172
|
if (i.src && this.shouldBlockScript(e, i.src)) {
|
|
173
173
|
console.warn(`Blocked dynamically added script: ${i.src}`), i.type = "javascript/blocked";
|
|
174
|
-
const
|
|
175
|
-
i.getAttribute("type") === "javascript/blocked" && (c.preventDefault(), console.warn(`Prevented execution of blocked script: ${i.src}`)), i.removeEventListener("beforescriptexecute",
|
|
174
|
+
const s = (c) => {
|
|
175
|
+
i.getAttribute("type") === "javascript/blocked" && (c.preventDefault(), console.warn(`Prevented execution of blocked script: ${i.src}`)), i.removeEventListener("beforescriptexecute", s);
|
|
176
176
|
};
|
|
177
|
-
i.addEventListener("beforescriptexecute",
|
|
177
|
+
i.addEventListener("beforescriptexecute", s);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
});
|
|
@@ -186,8 +186,8 @@ class l {
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
class g {
|
|
189
|
-
constructor(e = k, t = { update: [] }, o = d,
|
|
190
|
-
this.config = e, this.listeners = t, this.persistentService = o, this.cookieCleaner =
|
|
189
|
+
constructor(e = k, t = { update: [] }, o = d, n = f, i = y, s = l) {
|
|
190
|
+
this.config = e, this.listeners = t, this.persistentService = o, this.cookieCleaner = n, this.cookieInterceptor = i, this.scriptInterceptor = s, n.run(this.blacklist.cookies), i.run(this.blacklist.cookies), s.run(this.blacklist.scripts);
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* Retrieves the current cookie consent model from persistent storage.
|
|
@@ -241,8 +241,8 @@ class g {
|
|
|
241
241
|
get blacklist() {
|
|
242
242
|
return this.config.services.reduce((e, t) => {
|
|
243
243
|
if (this.model.value[t.category] === !1) {
|
|
244
|
-
const { cookies: o, scripts:
|
|
245
|
-
e.cookies = e.cookies.concat(o), e.scripts = e.scripts.concat(
|
|
244
|
+
const { cookies: o, scripts: n } = t;
|
|
245
|
+
e.cookies = e.cookies.concat(o), e.scripts = e.scripts.concat(n);
|
|
246
246
|
}
|
|
247
247
|
return e;
|
|
248
248
|
}, { cookies: [], scripts: [] });
|
|
@@ -272,8 +272,8 @@ class b {
|
|
|
272
272
|
* Initializes the cookie consent dialog if user action has not been recorded.
|
|
273
273
|
*/
|
|
274
274
|
init() {
|
|
275
|
-
this.service.model.useraction || (this.loadUI(), this.service.on("update", (
|
|
276
|
-
|
|
275
|
+
this.service.model.useraction || (this.loadUI(), this.service.on("update", () => {
|
|
276
|
+
this.unloadUI();
|
|
277
277
|
}));
|
|
278
278
|
}
|
|
279
279
|
/**
|
|
@@ -281,7 +281,7 @@ class b {
|
|
|
281
281
|
*/
|
|
282
282
|
async loadUI() {
|
|
283
283
|
try {
|
|
284
|
-
const { NorticCookieConsentDialog: e } = await import("./index-
|
|
284
|
+
const { NorticCookieConsentDialog: e } = await import("./index-DEG5Kd4y.js");
|
|
285
285
|
window.customElements.get("nortic-cookie-consent-dialog") || window.customElements.define("nortic-cookie-consent-dialog", e), this.ui = document.createElement("nortic-cookie-consent-dialog"), this.ui.setAttribute("data-testid", "cookie-consent"), document.body.appendChild(this.ui);
|
|
286
286
|
} catch (e) {
|
|
287
287
|
console.error("Failed to load the cookie consent dialog:", e);
|