@solvenza/cookies-compliance 1.1.0 → 1.2.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/LICENSE +21 -0
- package/dist/{chunk-CNAXWXBL.js → chunk-FBRP4MSA.js} +42 -1
- package/dist/chunk-FBRP4MSA.js.map +1 -0
- package/dist/{consent-engine-D3ApY7o3.d.cts → consent-engine-DOMyEKfk.d.cts} +1 -0
- package/dist/{consent-engine-D3ApY7o3.d.ts → consent-engine-DOMyEKfk.d.ts} +1 -0
- package/dist/consent.esm.cjs +41 -0
- package/dist/consent.esm.cjs.map +1 -1
- package/dist/consent.esm.d.cts +3 -2
- package/dist/consent.esm.d.ts +3 -2
- package/dist/consent.esm.js +1 -1
- package/dist/consent.min.js +19 -19
- package/dist/consent.min.js.map +1 -1
- package/dist/wrappers/angular.cjs +41 -0
- package/dist/wrappers/angular.cjs.map +1 -1
- package/dist/wrappers/angular.d.cts +1 -1
- package/dist/wrappers/angular.d.ts +1 -1
- package/dist/wrappers/angular.js +1 -1
- package/dist/wrappers/next.cjs +41 -0
- package/dist/wrappers/next.cjs.map +1 -1
- package/dist/wrappers/next.js +1 -1
- package/dist/wrappers/react.cjs +41 -0
- package/dist/wrappers/react.cjs.map +1 -1
- package/dist/wrappers/react.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-CNAXWXBL.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Solvenza IA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -307,6 +307,19 @@ var CookieStore = class {
|
|
|
307
307
|
}
|
|
308
308
|
document.cookie = cookieStr;
|
|
309
309
|
}
|
|
310
|
+
static clearServiceCookies(config, revokedCategory) {
|
|
311
|
+
var _a, _b;
|
|
312
|
+
if (typeof document === "undefined" || !config.services) return;
|
|
313
|
+
const path = ((_a = config.storage) == null ? void 0 : _a.path) || "/";
|
|
314
|
+
const domain = (_b = config.storage) == null ? void 0 : _b.domain;
|
|
315
|
+
for (const service of Object.values(config.services)) {
|
|
316
|
+
if (service.category === revokedCategory && service.cookies) {
|
|
317
|
+
for (const cookieItem of service.cookies) {
|
|
318
|
+
this.remove(cookieItem.name, path, domain || cookieItem.domain);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
310
323
|
};
|
|
311
324
|
|
|
312
325
|
// src/storage/memory-store.ts
|
|
@@ -1635,6 +1648,7 @@ var ConsentEngine = class {
|
|
|
1635
1648
|
GoogleConsentAdapter.initDefault();
|
|
1636
1649
|
if (evalResult.isValid) {
|
|
1637
1650
|
GoogleConsentAdapter.update(evalResult.choices);
|
|
1651
|
+
this.dispatchDomEvent("solvenza:restored", { state: this.getConsent() });
|
|
1638
1652
|
}
|
|
1639
1653
|
this.blockerRegistry.init(
|
|
1640
1654
|
(cat) => this.has(cat),
|
|
@@ -1731,9 +1745,15 @@ var ConsentEngine = class {
|
|
|
1731
1745
|
} else {
|
|
1732
1746
|
CookieStore.remove(cookieName, ((_c = config.storage) == null ? void 0 : _c.path) || "/", (_d = config.storage) == null ? void 0 : _d.domain);
|
|
1733
1747
|
}
|
|
1748
|
+
for (const catId of Object.keys(config.categories)) {
|
|
1749
|
+
if (catId !== "necessary") {
|
|
1750
|
+
CookieStore.clearServiceCookies(config, catId);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1734
1753
|
this.stateManager.clearChoices();
|
|
1735
1754
|
GoogleConsentAdapter.update(this.stateManager.getChoices());
|
|
1736
1755
|
this.eventBus.emit("consent:withdrawn", { previousChoices });
|
|
1756
|
+
this.dispatchDomEvent("solvenza:updated", { choices: this.stateManager.getChoices() });
|
|
1737
1757
|
this.showBanner();
|
|
1738
1758
|
}
|
|
1739
1759
|
when(categoryOrService, callback) {
|
|
@@ -1779,6 +1799,11 @@ var ConsentEngine = class {
|
|
|
1779
1799
|
(_a = config.security) == null ? void 0 : _a.secretKey
|
|
1780
1800
|
);
|
|
1781
1801
|
this.stateManager.updateChoices(receipt);
|
|
1802
|
+
for (const [catId, isAllowed] of Object.entries(choices)) {
|
|
1803
|
+
if (!isAllowed) {
|
|
1804
|
+
CookieStore.clearServiceCookies(config, catId);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1782
1807
|
const cookieName = ((_b = config.storage) == null ? void 0 : _b.name) || "site_consent";
|
|
1783
1808
|
const receiptJson = JSON.stringify(receipt);
|
|
1784
1809
|
if (((_c = config.storage) == null ? void 0 : _c.type) === "memory") {
|
|
@@ -1810,6 +1835,7 @@ var ConsentEngine = class {
|
|
|
1810
1835
|
}
|
|
1811
1836
|
this.banner.remove();
|
|
1812
1837
|
this.eventBus.emit("consent:changed", { choices, receipt });
|
|
1838
|
+
this.dispatchDomEvent("solvenza:updated", { choices, receipt });
|
|
1813
1839
|
}
|
|
1814
1840
|
showBanner() {
|
|
1815
1841
|
const config = this.stateManager.getConfig();
|
|
@@ -1820,6 +1846,7 @@ var ConsentEngine = class {
|
|
|
1820
1846
|
onConfigure: () => this.openPreferences()
|
|
1821
1847
|
});
|
|
1822
1848
|
this.eventBus.emit("banner:shown", void 0);
|
|
1849
|
+
this.dispatchDomEvent("solvenza:show", void 0);
|
|
1823
1850
|
}
|
|
1824
1851
|
setupGlobalRevocationTrigger() {
|
|
1825
1852
|
if (typeof document === "undefined") return;
|
|
@@ -1830,6 +1857,20 @@ var ConsentEngine = class {
|
|
|
1830
1857
|
this.openPreferences();
|
|
1831
1858
|
}
|
|
1832
1859
|
});
|
|
1860
|
+
document.addEventListener("solvenza:show", () => {
|
|
1861
|
+
this.showBanner();
|
|
1862
|
+
});
|
|
1863
|
+
document.addEventListener("solvenza:preferences", () => {
|
|
1864
|
+
this.openPreferences();
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
dispatchDomEvent(name, detail) {
|
|
1868
|
+
if (typeof document === "undefined") return;
|
|
1869
|
+
try {
|
|
1870
|
+
const customEvent = new CustomEvent(name, { detail, bubbles: true });
|
|
1871
|
+
document.dispatchEvent(customEvent);
|
|
1872
|
+
} catch (e) {
|
|
1873
|
+
}
|
|
1833
1874
|
}
|
|
1834
1875
|
};
|
|
1835
1876
|
var globalScope = typeof window !== "undefined" ? window : globalThis;
|
|
@@ -1863,4 +1904,4 @@ export {
|
|
|
1863
1904
|
ConsentEngine,
|
|
1864
1905
|
Consent
|
|
1865
1906
|
};
|
|
1866
|
-
//# sourceMappingURL=chunk-
|
|
1907
|
+
//# sourceMappingURL=chunk-FBRP4MSA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/config-validator.ts","../src/core/security.ts","../src/core/receipt.ts","../src/storage/cookie-store.ts","../src/storage/memory-store.ts","../src/blocker/script-gate.ts","../src/blocker/iframe-gate.ts","../src/blocker/resource-gate.ts","../src/services/google.ts","../src/diagnostics/resource-scanner.ts","../src/ui/policy-generator.ts","../src/core/state.ts","../src/core/events.ts","../src/core/policy-engine.ts","../src/blocker/registry.ts","../src/services/custom.ts","../src/ui/styles.ts","../src/ui/banner.ts","../src/ui/preferences.ts","../src/core/consent-engine.ts"],"sourcesContent":["import type { ConsentConfig } from \"./types.js\";\n\nexport class ConfigValidationError extends Error {\n constructor(message: string) {\n super(`[ConsentSDK Config Error] ${message}`);\n this.name = \"ConfigValidationError\";\n }\n}\n\nexport function validateConfig(config: ConsentConfig): void {\n if (!config) {\n throw new ConfigValidationError(\"Configuration object is null or undefined.\");\n }\n\n if (typeof config.schemaVersion !== \"number\" || config.schemaVersion < 1) {\n throw new ConfigValidationError(\"Invalid or missing 'schemaVersion'. Expected integer >= 1.\");\n }\n\n if (!config.policyVersion || typeof config.policyVersion !== \"string\") {\n throw new ConfigValidationError(\"Invalid or missing 'policyVersion'. String required.\");\n }\n\n if (!config.categories || typeof config.categories !== \"object\") {\n throw new ConfigValidationError(\"Missing 'categories' map in configuration.\");\n }\n\n const categoryKeys = Object.keys(config.categories);\n if (categoryKeys.length === 0) {\n throw new ConfigValidationError(\"At least one category must be defined in 'categories'.\");\n }\n\n // Ensure necessary category exists and is required\n const necessaryCategory = config.categories[\"necessary\"];\n if (!necessaryCategory) {\n throw new ConfigValidationError(\"Category 'necessary' must be defined.\");\n }\n if (necessaryCategory.required !== true) {\n throw new ConfigValidationError(\"Category 'necessary' must have 'required: true'.\");\n }\n\n // Legal guardrail (AEPD): Optional categories MUST NOT be pre-selected (default = true)\n for (const [catId, catConfig] of Object.entries(config.categories)) {\n if (catId !== \"necessary\" && !catConfig.required) {\n if (catConfig.default === true) {\n throw new ConfigValidationError(\n `Legal violation (AEPD): Optional category '${catId}' cannot have default: true. All optional categories must be opt-in (default: false).`\n );\n }\n }\n }\n\n // Validate services if present\n if (config.services && typeof config.services === \"object\") {\n for (const [serviceId, serviceConfig] of Object.entries(config.services)) {\n if (!serviceConfig.category) {\n throw new ConfigValidationError(\n `Service '${serviceId}' missing 'category' reference.`\n );\n }\n if (!config.categories[serviceConfig.category]) {\n throw new ConfigValidationError(\n `Service '${serviceId}' references non-existent category '${serviceConfig.category}'.`\n );\n }\n }\n }\n}\n","/**\n * Security & Anti-Tampering Utilities\n * Solvenza Cookies Compliance\n */\n\n// Pure JS SHA-256 implementation (Zero-dependency, works in Node, Browser, Web Workers)\nfunction sha256Sync(ascii: string): string {\n let i, j;\n let result = \"\";\n\n const asciiLength = ascii.length * 8;\n let hash = [\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,\n 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n ];\n\n const k = [\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n ];\n\n const blocks: number[] = [];\n for (i = 0; i < ascii.length; i++) {\n blocks[i >> 2] |= ascii.charCodeAt(i) << (24 - (i % 4) * 8);\n }\n blocks[asciiLength >> 5] |= 0x80 << (24 - (asciiLength % 32));\n blocks[(((asciiLength + 64) >> 9) << 4) + 15] = asciiLength;\n\n for (i = 0; i < blocks.length; i += 16) {\n const w = blocks.slice(i, i + 16);\n const oldHash = [...hash];\n\n for (j = 0; j < 64; j++) {\n const w15 = w[j - 15], w2 = w[j - 2];\n\n const s0 = ((w15 >>> 7) | (w15 << 25)) ^ ((w15 >>> 18) | (w15 << 14)) ^ (w15 >>> 3);\n const s1 = ((w2 >>> 17) | (w2 << 15)) ^ ((w2 >>> 19) | (w2 << 13)) ^ (w2 >>> 10);\n\n w[j] = j < 16 ? (w[j] || 0) : (w[j - 16] + s0 + w[j - 7] + s1) | 0;\n\n const ch = (hash[4] & hash[5]) ^ (~hash[4] & hash[6]);\n const maj = (hash[0] & hash[1]) ^ (hash[0] & hash[2]) ^ (hash[1] & hash[2]);\n\n const sig0 = ((hash[0] >>> 2) | (hash[0] << 30)) ^ ((hash[0] >>> 13) | (hash[0] << 19)) ^ ((hash[0] >>> 22) | (hash[0] << 10));\n const sig1 = ((hash[4] >>> 6) | (hash[4] << 26)) ^ ((hash[4] >>> 11) | (hash[4] << 21)) ^ ((hash[4] >>> 25) | (hash[4] << 7));\n\n const t1 = hash[7] + sig1 + ch + k[j] + (w[j] | 0);\n const t2 = sig0 + maj;\n\n hash[7] = hash[6];\n hash[6] = hash[5];\n hash[5] = hash[4];\n hash[4] = (hash[3] + t1) | 0;\n hash[3] = hash[2];\n hash[2] = hash[1];\n hash[1] = hash[0];\n hash[0] = (t1 + t2) | 0;\n }\n\n for (j = 0; j < 8; j++) {\n hash[j] = (hash[j] + oldHash[j]) | 0;\n }\n }\n\n for (i = 0; i < 8; i++) {\n for (j = 3; j >= 0; j--) {\n const b = (hash[i] >> (j * 8)) & 255;\n result += (b < 16 ? \"0\" : \"\") + b.toString(16);\n }\n }\n\n return result;\n}\n\nexport function computeReceiptSignature(payload: string, secretKey?: string): string {\n if (secretKey) {\n return sha256Sync(`${secretKey}:${payload}:${secretKey}`);\n }\n // Fallback FNV-1a hash if no secret key provided\n let hash = 2166136261;\n for (let i = 0; i < payload.length; i++) {\n hash ^= payload.charCodeAt(i);\n hash = Math.imul(hash, 16777619);\n }\n return (hash >>> 0).toString(16);\n}\n\nexport function verifyReceiptIntegrity(payload: string, expectedSignature: string, secretKey?: string): boolean {\n if (!expectedSignature) return false;\n return computeReceiptSignature(payload, secretKey) === expectedSignature;\n}\n\nexport function sanitizeHtml(str: string): string {\n if (!str) return \"\";\n return str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nexport function sanitizeUrl(url: string): string {\n if (!url) return \"#\";\n const trimmed = url.trim().toLowerCase();\n if (trimmed.startsWith(\"javascript:\") || trimmed.startsWith(\"data:\") || trimmed.startsWith(\"vbscript:\")) {\n return \"#\";\n }\n return url;\n}\n","import type { ConsentChoices, ConsentReceipt } from \"./types.js\";\nimport { computeReceiptSignature } from \"./security.js\";\n\nfunction generateUUID(): string {\n if (\n typeof crypto !== \"undefined\" &&\n typeof crypto.randomUUID === \"function\"\n ) {\n return crypto.randomUUID();\n }\n // Fallback for environments lacking crypto.randomUUID\n return \"xxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\nexport function createReceipt(\n policyVersion: string,\n choices: ConsentChoices,\n source: ConsentReceipt[\"source\"],\n existingReceipt?: ConsentReceipt | null,\n secretKey?: string,\n): ConsentReceipt {\n const now = new Date().toISOString();\n const receiptId = existingReceipt?.receiptId || generateUUID();\n const decidedAt = existingReceipt?.decidedAt || now;\n\n const payloadToSign = `${receiptId}:${policyVersion}:${JSON.stringify(choices)}`;\n const signature = computeReceiptSignature(payloadToSign, secretKey);\n\n return {\n schema: 1,\n receiptId,\n policyVersion,\n decidedAt,\n updatedAt: now,\n source,\n choices,\n signature,\n };\n}\n\nexport function parseReceipt(jsonStr: string): ConsentReceipt | null {\n try {\n const data = JSON.parse(jsonStr);\n if (\n typeof data === \"object\" &&\n data !== null &&\n typeof data.receiptId === \"string\" &&\n typeof data.policyVersion === \"string\" &&\n typeof data.choices === \"object\"\n ) {\n return data as ConsentReceipt;\n }\n return null;\n } catch {\n return null;\n }\n}\n\nexport function isReceiptExpired(\n receipt: ConsentReceipt,\n maxAgeDays = 365,\n): boolean {\n if (!receipt.updatedAt) return true;\n const updated = new Date(receipt.updatedAt).getTime();\n const now = Date.now();\n const maxAgeMs = maxAgeDays * 86400 * 1000;\n return now - updated > maxAgeMs;\n}\n","import type { ConsentConfig } from \"../core/types.js\";\nimport type { CookieOptions, IStorageProvider } from \"../core/contracts/storage.interface.js\";\n\nexport type { CookieOptions };\n\nexport class CookieStorageProvider implements IStorageProvider {\n get(key: string): string | null {\n return CookieStore.get(key);\n }\n\n set(key: string, value: string, options?: CookieOptions): void {\n CookieStore.set(key, value, options);\n }\n\n remove(key: string, path = \"/\", domain?: string): void {\n CookieStore.remove(key, path, domain);\n }\n}\n\nexport class CookieStore {\n static get(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n const nameEQ = encodeURIComponent(name) + \"=\";\n const ca = document.cookie.split(\";\");\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) === \" \") c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length));\n }\n }\n return null;\n }\n\n static set(name: string, value: string, options: CookieOptions = {}): void {\n if (typeof document === \"undefined\") return;\n\n const path = options.path || \"/\";\n const maxAgeDays = options.maxAgeDays ?? 365;\n const maxAgeSeconds = Math.floor(maxAgeDays * 86400);\n const sameSite = options.sameSite || \"Lax\";\n\n const isHttps =\n typeof window !== \"undefined\" && window.location.protocol === \"https:\";\n const secure = options.secure ?? isHttps;\n\n let cookieStr = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; Path=${path}; Max-Age=${maxAgeSeconds}; SameSite=${sameSite}`;\n\n if (options.domain) {\n cookieStr += `; Domain=${options.domain}`;\n }\n\n if (secure) {\n cookieStr += \"; Secure\";\n }\n\n document.cookie = cookieStr;\n }\n\n static remove(name: string, path = \"/\", domain?: string): void {\n if (typeof document === \"undefined\") return;\n let cookieStr = `${encodeURIComponent(name)}=; Path=${path}; Max-Age=0; SameSite=Lax`;\n if (domain) {\n cookieStr += `; Domain=${domain}`;\n }\n document.cookie = cookieStr;\n }\n\n static clearServiceCookies(config: ConsentConfig, revokedCategory: string): void {\n if (typeof document === \"undefined\" || !config.services) return;\n\n const path = config.storage?.path || \"/\";\n const domain = config.storage?.domain;\n\n for (const service of Object.values(config.services)) {\n if (service.category === revokedCategory && service.cookies) {\n for (const cookieItem of service.cookies) {\n this.remove(cookieItem.name, path, domain || cookieItem.domain);\n }\n }\n }\n }\n}\n","import type { IStorageProvider } from \"../core/contracts/storage.interface.js\";\n\nexport class MemoryStorageProvider implements IStorageProvider {\n private static store = new Map<string, string>();\n\n get(key: string): string | null {\n return MemoryStorageProvider.store.get(key) ?? null;\n }\n\n set(key: string, value: string): void {\n MemoryStorageProvider.store.set(key, value);\n }\n\n remove(key: string): void {\n MemoryStorageProvider.store.delete(key);\n }\n\n clear(): void {\n MemoryStorageProvider.store.clear();\n }\n}\n\nexport const MemoryStore = {\n get: (name: string) => new MemoryStorageProvider().get(name),\n set: (name: string, val: string) => new MemoryStorageProvider().set(name, val),\n remove: (name: string) => new MemoryStorageProvider().remove(name),\n clear: () => new MemoryStorageProvider().clear(),\n};\n","import type { IResourceBlocker } from \"../core/contracts/blocker.interface.js\";\n\nexport class ScriptResourceBlocker implements IResourceBlocker {\n type: \"script\" = \"script\";\n\n process(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean\n ): void {\n ScriptGate.scanAndActivate(isCategoryAllowed, isServiceAllowed);\n }\n}\n\nexport class ScriptGate {\n private static executedScripts = new Set<Element>();\n\n static scanAndActivate(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean,\n onServiceLoaded?: (serviceId: string, category: string) => void,\n ): void {\n if (typeof document === \"undefined\") return;\n\n const blockedScripts = Array.from(\n document.querySelectorAll<HTMLScriptElement>(\n 'script[type=\"text/plain\"][data-consent], script[type=\"text/plain\"][data-service]',\n ),\n );\n\n for (const oldScript of blockedScripts) {\n if (this.executedScripts.has(oldScript)) continue;\n\n const category = oldScript.getAttribute(\"data-consent\");\n const serviceId = oldScript.getAttribute(\"data-service\");\n\n let isAllowed = false;\n if (serviceId) {\n isAllowed = isServiceAllowed(serviceId);\n } else if (category) {\n isAllowed = isCategoryAllowed(category);\n }\n\n if (!isAllowed) continue;\n\n this.executedScripts.add(oldScript);\n const newScript = document.createElement(\"script\");\n\n for (let i = 0; i < oldScript.attributes.length; i++) {\n const attr = oldScript.attributes[i];\n if (attr.name === \"type\") continue;\n if (attr.name === \"data-src\") {\n newScript.src = attr.value;\n continue;\n }\n newScript.setAttribute(attr.name, attr.value);\n }\n\n newScript.type = \"text/javascript\";\n if (!newScript.src && oldScript.textContent) {\n newScript.textContent = oldScript.textContent;\n }\n\n oldScript.parentNode?.replaceChild(newScript, oldScript);\n\n if (serviceId || category) {\n onServiceLoaded?.(serviceId || category!, category || \"custom\");\n }\n }\n }\n}\n","import type { IResourceBlocker } from \"../core/contracts/blocker.interface.js\";\n\nexport interface IframeGateOptions {\n onAllowClick?: (category: string, serviceId?: string) => void;\n}\n\nexport class IframeResourceBlocker implements IResourceBlocker {\n type: \"iframe\" = \"iframe\";\n\n process(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean\n ): void {\n IframeGate.processIframes(isCategoryAllowed, isServiceAllowed);\n }\n}\n\nexport class IframeGate {\n private static placeholders = new Map<HTMLIFrameElement, HTMLElement>();\n\n static processIframes(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean,\n options: IframeGateOptions = {},\n ): void {\n if (typeof document === \"undefined\") return;\n\n const iframes = Array.from(\n document.querySelectorAll<HTMLIFrameElement>(\n \"iframe[data-consent], iframe[data-service]\",\n ),\n );\n\n for (const iframe of iframes) {\n const category = iframe.getAttribute(\"data-consent\");\n const serviceId = iframe.getAttribute(\"data-service\");\n\n let isAllowed = false;\n if (serviceId) {\n isAllowed = isServiceAllowed(serviceId);\n } else if (category) {\n isAllowed = isCategoryAllowed(category);\n }\n\n const originalSrc =\n iframe.getAttribute(\"data-src\") || iframe.getAttribute(\"src\");\n\n if (!originalSrc) continue;\n\n if (!iframe.getAttribute(\"data-src\")) {\n iframe.setAttribute(\"data-src\", originalSrc);\n }\n\n if (isAllowed) {\n this.unlockIframe(iframe, originalSrc);\n } else {\n this.lockIframe(\n iframe,\n category || \"marketing\",\n serviceId || undefined,\n options,\n );\n }\n }\n }\n\n private static lockIframe(\n iframe: HTMLIFrameElement,\n category: string,\n serviceId: string | undefined,\n options: IframeGateOptions,\n ): void {\n if (iframe.hasAttribute(\"src\")) {\n iframe.removeAttribute(\"src\");\n }\n\n if (this.placeholders.has(iframe)) return;\n\n const container = document.createElement(\"div\");\n container.className = \"consent-iframe-placeholder\";\n container.style.cssText = `\n width: ${iframe.width ? (iframe.width.endsWith(\"%\") || iframe.width.endsWith(\"px\") ? iframe.width : iframe.width + \"px\") : \"100%\"};\n height: ${iframe.height ? (iframe.height.endsWith(\"%\") || iframe.height.endsWith(\"px\") ? iframe.height : iframe.height + \"px\") : \"315px\"};\n min-height: 200px;\n background: #0f172a;\n color: #f8fafc;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n text-align: center;\n padding: 1.5rem;\n border-radius: 8px;\n box-sizing: border-box;\n font-family: system-ui, -apple-system, sans-serif;\n `;\n\n const titleText = serviceId\n ? `Contenido de ${serviceId} bloqueado`\n : \"Contenido externo bloqueado\";\n const bodyText =\n \"Este contenido está bloqueado hasta que autorices esta finalidad de privacidad.\";\n\n container.innerHTML = `\n <div style=\"font-weight: 600; font-size: 1.1rem; margin-bottom: 0.5rem; color: #f8fafc;\">\n ${titleText}\n </div>\n <p style=\"font-size: 0.9rem; color: #94a3b8; margin: 0 0 1rem 0; max-width: 400px;\">\n ${bodyText}\n </p>\n <button type=\"button\" class=\"consent-placeholder-allow-btn\" style=\"\n background: #2563eb;\n color: #ffffff;\n border: none;\n padding: 0.6rem 1.2rem;\n border-radius: 6px;\n font-weight: 500;\n cursor: pointer;\n font-size: 0.9rem;\n transition: background 0.2s ease;\n \">\n Permitir y mostrar contenido\n </button>\n `;\n\n const button = container.querySelector<HTMLButtonElement>(\n \".consent-placeholder-allow-btn\",\n );\n button?.addEventListener(\"click\", () => {\n options.onAllowClick?.(category, serviceId);\n });\n\n iframe.style.display = \"none\";\n iframe.parentNode?.insertBefore(container, iframe);\n this.placeholders.set(iframe, container);\n }\n\n private static unlockIframe(iframe: HTMLIFrameElement, src: string): void {\n if (iframe.getAttribute(\"src\") !== src) {\n iframe.setAttribute(\"src\", src);\n }\n iframe.style.display = \"\";\n\n const placeholder = this.placeholders.get(iframe);\n if (placeholder) {\n placeholder.parentNode?.removeChild(placeholder);\n this.placeholders.delete(iframe);\n }\n }\n}\n","import type { IResourceBlocker } from \"../core/contracts/blocker.interface.js\";\n\nexport class ImageResourceBlocker implements IResourceBlocker {\n type: \"image\" = \"image\";\n\n process(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean\n ): void {\n ResourceGate.processImages(isCategoryAllowed, isServiceAllowed);\n }\n}\n\nexport class ResourceGate {\n static processImages(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean,\n ): void {\n if (typeof document === \"undefined\") return;\n\n const images = Array.from(\n document.querySelectorAll<HTMLImageElement>(\n \"img[data-consent], img[data-service]\",\n ),\n );\n\n for (const img of images) {\n const category = img.getAttribute(\"data-consent\");\n const serviceId = img.getAttribute(\"data-service\");\n\n let isAllowed = false;\n if (serviceId) {\n isAllowed = isServiceAllowed(serviceId);\n } else if (category) {\n isAllowed = isCategoryAllowed(category);\n }\n\n const originalSrc =\n img.getAttribute(\"data-src\") || img.getAttribute(\"src\");\n\n if (!originalSrc) continue;\n\n if (!img.getAttribute(\"data-src\")) {\n img.setAttribute(\"data-src\", originalSrc);\n }\n\n if (isAllowed) {\n if (img.getAttribute(\"src\") !== originalSrc) {\n img.setAttribute(\"src\", originalSrc);\n }\n } else {\n if (img.hasAttribute(\"src\")) {\n img.removeAttribute(\"src\");\n }\n }\n }\n }\n}\n","import type { ConsentChoices } from \"../core/types.js\";\n\ndeclare global {\n interface Window {\n dataLayer?: any[];\n gtag?: (...args: any[]) => void;\n }\n}\n\nexport interface GoogleConsentModeConfig {\n analytics_storage?: string; // category id e.g. \"analytics\"\n ad_storage?: string; // category id e.g. \"marketing\"\n ad_user_data?: string; // category id e.g. \"marketing\"\n ad_personalization?: string; // category id e.g. \"marketing\"\n}\n\nexport class GoogleConsentAdapter {\n private static initialized = false;\n\n static initDefault(_configMap?: GoogleConsentModeConfig): void {\n if (typeof window === \"undefined\") return;\n\n window.dataLayer = window.dataLayer || [];\n if (!window.gtag) {\n window.gtag = function () {\n window.dataLayer?.push(arguments);\n };\n }\n\n if (!this.initialized) {\n window.gtag(\"consent\", \"default\", {\n analytics_storage: \"denied\",\n ad_storage: \"denied\",\n ad_user_data: \"denied\",\n ad_personalization: \"denied\",\n wait_for_update: 500,\n });\n this.initialized = true;\n }\n }\n\n static update(choices: ConsentChoices, configMap?: GoogleConsentModeConfig): void {\n if (typeof window === \"undefined\") return;\n\n this.initDefault(configMap);\n\n const analyticsCategory = configMap?.analytics_storage || \"analytics\";\n const marketingCategory = configMap?.ad_storage || \"marketing\";\n\n const isAnalyticsAllowed = choices[analyticsCategory] === true;\n const isMarketingAllowed = choices[marketingCategory] === true;\n\n window.gtag!(\"consent\", \"update\", {\n analytics_storage: isAnalyticsAllowed ? \"granted\" : \"denied\",\n ad_storage: isMarketingAllowed ? \"granted\" : \"denied\",\n ad_user_data: isMarketingAllowed ? \"granted\" : \"denied\",\n ad_personalization: isMarketingAllowed ? \"granted\" : \"denied\",\n });\n }\n}\n","import type { ConsentConfig, DiagnosticReport } from \"../core/types.js\";\n\nexport class ResourceScanner {\n static runDiagnostic(_config: ConsentConfig, isConsentGiven: boolean): DiagnosticReport {\n const thirdPartyScripts: string[] = [];\n if (typeof document !== \"undefined\") {\n const scripts = document.querySelectorAll(\"script[src]\");\n scripts.forEach((script) => {\n const src = script.getAttribute(\"src\");\n if (src && (src.startsWith(\"http://\") || src.startsWith(\"https://\"))) {\n thirdPartyScripts.push(src);\n }\n });\n }\n\n return {\n timestamp: new Date().toISOString(),\n unblockedThirdPartyScripts: isConsentGiven ? [] : thirdPartyScripts,\n compliant: isConsentGiven || thirdPartyScripts.length === 0,\n };\n }\n\n scanThirdPartyResources(): string[] {\n return ResourceScanner.runDiagnostic({} as any, true).unblockedThirdPartyScripts;\n }\n}\n","import type { ConsentConfig } from \"../core/types.js\";\nimport { sanitizeHtml } from \"../core/security.js\";\n\nexport class PolicyGenerator {\n static renderTable(config: ConsentConfig): string {\n let html = `\n <div class=\"consent-policy-table-wrapper\" style=\"margin: 1.5rem 0; font-family: system-ui, sans-serif;\">\n <table style=\"width: 100%; border-collapse: collapse; text-align: left; border: 1px solid #e2e8f0;\">\n <thead>\n <tr style=\"background: #f8fafc; border-bottom: 2px solid #cbd5e1;\">\n <th style=\"padding: 0.75rem; border: 1px solid #e2e8f0;\">Categoría / Servicio</th>\n <th style=\"padding: 0.75rem; border: 1px solid #e2e8f0;\">Proveedor</th>\n <th style=\"padding: 0.75rem; border: 1px solid #e2e8f0;\">Finalidad</th>\n <th style=\"padding: 0.75rem; border: 1px solid #e2e8f0;\">Requerida</th>\n </tr>\n </thead>\n <tbody>\n `;\n\n for (const [catId, cat] of Object.entries(config.categories)) {\n const isReq = cat.required ? \"Sí (Técnica)\" : \"No (Opcional)\";\n html += `\n <tr style=\"background: #ffffff; font-weight: 600;\">\n <td style=\"padding: 0.75rem; border: 1px solid #e2e8f0;\" colspan=\"3\">${sanitizeHtml(cat.label)}</td>\n <td style=\"padding: 0.75rem; border: 1px solid #e2e8f0;\">${isReq}</td>\n </tr>\n `;\n\n if (config.services) {\n for (const [srvId, srv] of Object.entries(config.services)) {\n if (srv.category === catId) {\n html += `\n <tr style=\"background: #f8fafc; font-size: 0.9rem;\">\n <td style=\"padding: 0.5rem 0.75rem 0.5rem 1.5rem; border: 1px solid #e2e8f0;\">↳ ${sanitizeHtml(srv.label || srvId)}</td>\n <td style=\"padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;\">${sanitizeHtml(srv.provider || \"-\")}</td>\n <td style=\"padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;\">${sanitizeHtml(cat.description || \"-\")}</td>\n <td style=\"padding: 0.5rem 0.75rem; border: 1px solid #e2e8f0;\">${isReq}</td>\n </tr>\n `;\n }\n }\n }\n }\n\n html += `\n </tbody>\n </table>\n </div>\n `;\n\n return html;\n }\n}\n","import type {\n ConsentChoices,\n ConsentConfig,\n ConsentReceipt,\n ConsentState,\n} from \"./types.js\";\n\nexport class StateManager {\n private state: ConsentState = {\n initialized: false,\n policyVersion: \"\",\n locale: \"es\",\n receipt: null,\n choices: {},\n };\n\n private config: ConsentConfig | null = null;\n\n init(\n config: ConsentConfig,\n choices: ConsentChoices,\n receipt: ConsentReceipt | null,\n ): void {\n this.config = config;\n this.state = {\n initialized: true,\n policyVersion: config.policyVersion,\n locale: config.locale?.default || \"es\",\n receipt,\n choices,\n };\n }\n\n getConfig(): ConsentConfig | null {\n return this.config;\n }\n\n getState(): ConsentState {\n return { ...this.state };\n }\n\n getChoices(): ConsentChoices {\n return { ...this.state.choices };\n }\n\n getReceipt(): ConsentReceipt | null {\n return this.state.receipt;\n }\n\n hasCategory(category: string): boolean {\n return this.state.choices[category] === true;\n }\n\n hasService(serviceId: string): boolean {\n if (!this.config || !this.config.services) return false;\n const service = this.config.services[serviceId];\n if (!service) return false;\n\n return this.hasCategory(service.category);\n }\n\n updateChoices(receipt: ConsentReceipt): void {\n this.state.receipt = receipt;\n this.state.choices = { ...receipt.choices };\n }\n\n clearChoices(): void {\n if (!this.config) return;\n const resetChoices: ConsentChoices = {};\n for (const [catId, catConfig] of Object.entries(this.config.categories)) {\n resetChoices[catId] = catConfig.required === true;\n }\n this.state.choices = resetChoices;\n this.state.receipt = null;\n }\n}\n","import type {\n ConsentEvent,\n ConsentEventDetailMap,\n ConsentEventHandler,\n} from \"./types.js\";\n\nexport class EventBus {\n private handlers = new Map<ConsentEvent, Set<ConsentEventHandler<any>>>();\n\n on<E extends ConsentEvent>(\n event: E,\n handler: ConsentEventHandler<E>\n ): () => void {\n if (!this.handlers.has(event)) {\n this.handlers.set(event, new Set());\n }\n const set = this.handlers.get(event)!;\n set.add(handler);\n\n return () => {\n set.delete(handler);\n };\n }\n\n emit<E extends ConsentEvent>(event: E, detail: ConsentEventDetailMap[E]): void {\n const set = this.handlers.get(event);\n if (!set) return;\n\n for (const handler of set) {\n try {\n handler(detail);\n } catch (err) {\n console.error(`[ConsentSDK Event Error] Handler for '${event}' failed:`, err);\n }\n }\n }\n\n clear(): void {\n this.handlers.clear();\n }\n}\n","import type { ConsentChoices, ConsentConfig, ConsentReceipt } from \"./types.js\";\nimport { isReceiptExpired } from \"./receipt.js\";\nimport { computeReceiptSignature } from \"./security.js\";\n\nexport interface PolicyEvaluationResult {\n isValid: boolean;\n reason?: \"missing\" | \"policy_version_changed\" | \"expired\" | \"tampered\" | \"valid\";\n choices: ConsentChoices;\n}\n\nexport function evaluatePolicy(\n config: ConsentConfig,\n receipt: ConsentReceipt | null\n): PolicyEvaluationResult {\n // Build default deny choices (necessary = true, all optionals = false)\n const defaultChoices: ConsentChoices = {};\n for (const [catId, catConfig] of Object.entries(config.categories)) {\n defaultChoices[catId] = catConfig.required === true;\n }\n\n if (!receipt) {\n return {\n isValid: false,\n reason: \"missing\",\n choices: defaultChoices,\n };\n }\n\n if (receipt.policyVersion !== config.policyVersion) {\n return {\n isValid: false,\n reason: \"policy_version_changed\",\n choices: defaultChoices,\n };\n }\n\n const maxAgeDays = config.consent?.maxAgeDays ?? 365;\n if (isReceiptExpired(receipt, maxAgeDays)) {\n return {\n isValid: false,\n reason: \"expired\",\n choices: defaultChoices,\n };\n }\n\n // Anti-tampering signature verification\n if (receipt.signature) {\n const payloadToSign = `${receipt.receiptId}:${receipt.policyVersion}:${JSON.stringify(receipt.choices)}`;\n const expectedSignature = computeReceiptSignature(payloadToSign, config.security?.secretKey);\n if (receipt.signature !== expectedSignature) {\n return {\n isValid: false,\n reason: \"tampered\",\n choices: defaultChoices,\n };\n }\n }\n\n // Merge receipt choices ensuring necessary remains true and any missing category defaults to false\n const activeChoices: ConsentChoices = { ...defaultChoices };\n for (const catId of Object.keys(config.categories)) {\n if (catId === \"necessary\") {\n activeChoices[catId] = true;\n } else if (typeof receipt.choices[catId] === \"boolean\") {\n activeChoices[catId] = receipt.choices[catId];\n }\n }\n\n return {\n isValid: true,\n reason: \"valid\",\n choices: activeChoices,\n };\n}\n","import { ScriptGate } from \"./script-gate.js\";\nimport { IframeGate, type IframeGateOptions } from \"./iframe-gate.js\";\nimport { ResourceGate } from \"./resource-gate.js\";\n\nexport class BlockerRegistry {\n private observer: MutationObserver | null = null;\n\n init(\n isCategoryAllowed: (category: string) => boolean,\n isServiceAllowed: (serviceId: string) => boolean,\n iframeOptions?: IframeGateOptions,\n onServiceLoaded?: (serviceId: string, category: string) => void,\n ): void {\n const runBlockers = () => {\n ScriptGate.scanAndActivate(\n isCategoryAllowed,\n isServiceAllowed,\n onServiceLoaded,\n );\n IframeGate.processIframes(\n isCategoryAllowed,\n isServiceAllowed,\n iframeOptions,\n );\n ResourceGate.processImages(isCategoryAllowed, isServiceAllowed);\n };\n\n // Initial pass\n runBlockers();\n\n // Set up MutationObserver Level B defense for dynamically injected scripts/iframes\n if (\n typeof MutationObserver !== \"undefined\" &&\n typeof document !== \"undefined\"\n ) {\n this.observer = new MutationObserver(() => {\n runBlockers();\n });\n\n this.observer.observe(document.documentElement || document.body, {\n childList: true,\n subtree: true,\n });\n }\n }\n\n destroy(): void {\n if (this.observer) {\n this.observer.disconnect();\n this.observer = null;\n }\n }\n}\n","import type { EventBus } from \"../core/events.js\";\n\nexport class CustomServiceAdapter {\n static createWhen(\n eventBus: EventBus,\n isCategoryAllowed: (cat: string) => boolean,\n isServiceAllowed: (srv: string) => boolean\n ) {\n return function when(\n categoryOrService: string,\n callback: () => void\n ): () => void {\n // Execute immediately if already granted\n if (isCategoryAllowed(categoryOrService) || isServiceAllowed(categoryOrService)) {\n try {\n callback();\n } catch (err) {\n console.error(`[ConsentSDK when()] Callback execution failed:`, err);\n }\n }\n\n // Listen for future consent changes\n return eventBus.on(\"consent:changed\", ({ choices }) => {\n if (choices[categoryOrService] === true || isServiceAllowed(categoryOrService)) {\n try {\n callback();\n } catch (err) {\n console.error(`[ConsentSDK when()] Callback execution failed:`, err);\n }\n }\n });\n };\n }\n}\n","export function injectStyles(nonce?: string): void {\n if (typeof document === \"undefined\") return;\n\n const existing = document.getElementById(\"consent-sdk-styles\");\n if (existing) {\n existing.remove(); // Re-inject updated styles\n }\n\n const styleEl = document.createElement(\"style\");\n styleEl.id = \"consent-sdk-styles\";\n if (nonce) {\n styleEl.setAttribute(\"nonce\", nonce);\n }\n\n styleEl.textContent = `\n :root {\n --consent-bg: #ffffff;\n --consent-fg: #0f172a;\n --consent-muted: #64748b;\n --consent-divider: #f1f5f9;\n --consent-border: #e2e8f0;\n --consent-hover-bg: #f8fafc;\n --consent-primary: #0f172a;\n --consent-primary-hover: #1e293b;\n --consent-primary-fg: #ffffff;\n --consent-secondary: #f8fafc;\n --consent-secondary-hover: #f1f5f9;\n --consent-secondary-fg: #0f172a;\n --consent-accent: #2563eb;\n --consent-focus-ring: rgba(37, 99, 235, 0.3);\n --consent-font: system-ui, -apple-system, BlinkMacSystemFont, \"SF Pro Display\", \"SF Pro Text\", \"Segoe UI\", Roboto, sans-serif;\n --consent-modal-shadow: 0 32px 64px -16px rgba(15, 23, 42, 0.2), 0 0 1px rgba(15, 23, 42, 0.12);\n }\n\n @media (prefers-color-scheme: dark) {\n :root {\n --consent-bg: #0f172a;\n --consent-fg: #f8fafc;\n --consent-muted: #94a3b8;\n --consent-divider: #1e293b;\n --consent-border: #334155;\n --consent-hover-bg: #1e293b;\n --consent-primary: #f8fafc;\n --consent-primary-hover: #ffffff;\n --consent-primary-fg: #0f172a;\n --consent-secondary: #1e293b;\n --consent-secondary-hover: #334155;\n --consent-secondary-fg: #f8fafc;\n --consent-modal-shadow: 0 32px 64px -16px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.12);\n }\n }\n\n @keyframes consentSlideUp {\n from {\n opacity: 0;\n transform: translateY(16px) scale(0.985);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n }\n\n @keyframes consentFadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n\n /* 1st Layer Banner - Clean & Seamless */\n .consent-banner-wrapper {\n position: fixed;\n bottom: 1.25rem;\n left: 1.25rem;\n right: 1.25rem;\n max-width: 1060px;\n margin: 0 auto;\n z-index: 2147483645;\n background: var(--consent-bg);\n color: var(--consent-fg);\n border: 1px solid var(--consent-border);\n border-radius: 20px;\n box-shadow: var(--consent-modal-shadow);\n padding: 1.5rem 1.75rem;\n font-family: var(--consent-font);\n font-size: 0.92rem;\n line-height: 1.5;\n animation: consentSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;\n box-sizing: border-box;\n }\n\n .consent-banner-container {\n display: flex;\n flex-direction: column;\n gap: 1.25rem;\n }\n\n @media (min-width: 860px) {\n .consent-banner-container {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n }\n }\n\n .consent-banner-text {\n flex: 1;\n }\n\n .consent-banner-title {\n font-size: 1.1rem;\n font-weight: 700;\n letter-spacing: -0.015em;\n margin: 0 0 0.35rem 0;\n color: var(--consent-fg);\n display: flex;\n align-items: center;\n gap: 0.5rem;\n }\n\n .consent-banner-title-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 22px;\n height: 22px;\n border-radius: 6px;\n background: rgba(37, 99, 235, 0.1);\n color: var(--consent-accent);\n }\n\n .consent-banner-desc {\n margin: 0;\n color: var(--consent-muted);\n font-size: 0.88rem;\n max-width: 720px;\n }\n\n .consent-banner-links {\n margin-top: 0.4rem;\n }\n\n .consent-banner-links a {\n color: var(--consent-muted);\n font-size: 0.83rem;\n text-decoration: underline;\n text-underline-offset: 3px;\n font-weight: 500;\n margin-right: 1.2rem;\n transition: color 0.15s ease;\n }\n\n .consent-banner-links a:hover {\n color: var(--consent-fg);\n }\n\n /* Equal Visual Prominence CTAs */\n .consent-banner-actions {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n width: 100%;\n }\n\n @media (min-width: 640px) {\n .consent-banner-actions {\n flex-direction: row;\n width: auto;\n align-items: center;\n }\n }\n\n .consent-btn {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 0.6rem 1.2rem;\n font-size: 0.88rem;\n font-weight: 600;\n border-radius: 10px;\n border: 1px solid var(--consent-border);\n cursor: pointer;\n font-family: inherit;\n transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);\n min-height: 42px;\n min-width: 110px;\n box-sizing: border-box;\n user-select: none;\n }\n\n .consent-btn:hover {\n transform: translateY(-1px);\n }\n\n .consent-btn:active {\n transform: translateY(0) scale(0.98);\n }\n\n .consent-btn:focus-visible {\n outline: 3px solid var(--consent-focus-ring);\n outline-offset: 2px;\n }\n\n .consent-btn-reject {\n background: var(--consent-secondary);\n color: var(--consent-secondary-fg);\n border-color: var(--consent-border);\n }\n\n .consent-btn-reject:hover {\n background: var(--consent-secondary-hover);\n }\n\n .consent-btn-configure {\n background: transparent;\n color: var(--consent-muted);\n border-color: transparent;\n }\n\n .consent-btn-configure:hover {\n color: var(--consent-fg);\n background: var(--consent-secondary);\n }\n\n .consent-btn-accept {\n background: var(--consent-primary);\n color: var(--consent-primary-fg);\n border-color: var(--consent-primary);\n }\n\n .consent-btn-accept:hover {\n background: var(--consent-primary-hover);\n }\n\n /* 2nd Layer Preference Modal - Ultra Clean Linear List Style */\n .consent-dialog-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background: rgba(15, 23, 42, 0.45);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n z-index: 2147483646;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 1.25rem;\n box-sizing: border-box;\n animation: consentFadeIn 0.2s ease forwards;\n }\n\n .consent-dialog {\n background: var(--consent-bg);\n color: var(--consent-fg);\n border: 1px solid var(--consent-border);\n border-radius: 20px;\n width: 100%;\n max-width: 600px;\n max-height: 85vh;\n display: flex;\n flex-direction: column;\n box-shadow: var(--consent-modal-shadow);\n font-family: var(--consent-font);\n overflow: hidden;\n animation: consentSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;\n }\n\n .consent-dialog-header {\n padding: 1.5rem 1.75rem 1.25rem 1.75rem;\n border-bottom: 1px solid var(--consent-divider);\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n }\n\n .consent-dialog-title {\n font-size: 1.15rem;\n font-weight: 700;\n letter-spacing: -0.015em;\n margin: 0;\n }\n\n .consent-dialog-close {\n background: transparent;\n border: none;\n color: var(--consent-muted);\n cursor: pointer;\n padding: 0.35rem;\n border-radius: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: background 0.15s ease, color 0.15s ease;\n margin: -0.35rem -0.35rem 0 0;\n }\n\n .consent-dialog-close:hover {\n background: var(--consent-secondary);\n color: var(--consent-fg);\n }\n\n /* Seamless Category List Body (NO individual boxed divs) */\n .consent-dialog-body {\n padding: 0;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n }\n\n .consent-category-row {\n padding: 1.25rem 1.75rem;\n border-bottom: 1px solid var(--consent-divider);\n transition: background 0.15s ease;\n }\n\n .consent-category-row:last-child {\n border-bottom: none;\n }\n\n .consent-category-row:hover {\n background: var(--consent-hover-bg);\n }\n\n .consent-category-header {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 1rem;\n }\n\n .consent-category-name {\n font-weight: 600;\n font-size: 0.95rem;\n color: var(--consent-fg);\n }\n\n .consent-category-desc {\n margin: 0.3rem 0 0 0;\n font-size: 0.85rem;\n color: var(--consent-muted);\n line-height: 1.45;\n }\n\n /* Minimalist Badges */\n .consent-badge {\n display: inline-flex;\n align-items: center;\n padding: 0.15rem 0.5rem;\n border-radius: 6px;\n font-size: 0.7rem;\n font-weight: 600;\n letter-spacing: 0.01em;\n }\n\n .consent-badge-required {\n background: rgba(16, 185, 129, 0.1);\n color: #059669;\n }\n\n .consent-badge-optional {\n background: rgba(100, 116, 139, 0.08);\n color: var(--consent-muted);\n }\n\n /* Inline Service Disclosure Button */\n .consent-toggle-services-btn {\n border: none;\n background: transparent;\n color: var(--consent-accent);\n font-size: 0.78rem;\n font-weight: 600;\n cursor: pointer;\n padding: 0.35rem 0 0 0;\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n font-family: inherit;\n }\n\n .consent-toggle-services-btn:hover {\n opacity: 0.85;\n }\n\n /* Minimalist Toggle Switch */\n .consent-toggle {\n position: relative;\n display: inline-block;\n width: 40px;\n height: 22px;\n flex-shrink: 0;\n margin-top: 0.15rem;\n }\n\n .consent-toggle input {\n opacity: 0;\n width: 0;\n height: 0;\n }\n\n .consent-toggle-slider {\n position: absolute;\n cursor: pointer;\n top: 0; left: 0; right: 0; bottom: 0;\n background-color: #cbd5e1;\n transition: background-color 0.2s ease;\n border-radius: 22px;\n }\n\n .consent-toggle-slider:before {\n position: absolute;\n content: \"\";\n height: 16px;\n width: 16px;\n left: 3px;\n bottom: 3px;\n background-color: white;\n transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);\n border-radius: 50%;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);\n }\n\n .consent-toggle input:checked + .consent-toggle-slider {\n background-color: var(--consent-accent);\n }\n\n .consent-toggle input:checked + .consent-toggle-slider:before {\n transform: translateX(18px);\n }\n\n .consent-toggle input:disabled + .consent-toggle-slider {\n opacity: 0.45;\n cursor: not-allowed;\n }\n\n /* Footer */\n .consent-dialog-footer {\n padding: 1.25rem 1.75rem;\n border-top: 1px solid var(--consent-divider);\n background: var(--consent-bg);\n display: flex;\n flex-direction: column;\n gap: 0.6rem;\n justify-content: space-between;\n align-items: center;\n }\n\n @media (min-width: 520px) {\n .consent-dialog-footer {\n flex-direction: row;\n }\n }\n `;\n document.head.appendChild(styleEl);\n}\n","import type { ConsentConfig } from \"../core/types.js\";\nimport { injectStyles } from \"./styles.js\";\nimport { sanitizeHtml, sanitizeUrl } from \"../core/security.js\";\n\nexport interface BannerHandlers {\n onAcceptAll: () => void;\n onRejectAll: () => void;\n onConfigure: () => void;\n}\n\nexport class ConsentBanner {\n private element: HTMLElement | null = null;\n\n render(config: ConsentConfig, handlers: BannerHandlers): void {\n if (typeof document === \"undefined\") return;\n this.remove();\n injectStyles(config.csp?.nonce);\n\n const bannerConfig = config.ui?.banner || {};\n const titleText = sanitizeHtml(bannerConfig.title || \"Tu privacidad, bajo tu control\");\n const descText = sanitizeHtml(\n bannerConfig.description ||\n \"Usamos tecnologías necesarias para el funcionamiento del sitio. Con tu permiso, también podemos utilizar analítica y marketing.\"\n );\n const acceptText = sanitizeHtml(bannerConfig.accept || \"Aceptar todas\");\n const rejectText = sanitizeHtml(bannerConfig.reject || \"Rechazar todas\");\n const configureText = sanitizeHtml(bannerConfig.configure || \"Configurar\");\n\n const privacyUrl = sanitizeUrl(config.policy?.privacyUrl || \"/politica-privacidad\");\n const cookiesUrl = sanitizeUrl(config.policy?.cookiesUrl || \"/politica-cookies\");\n\n const wrapper = document.createElement(\"div\");\n wrapper.className = \"consent-banner-wrapper\";\n wrapper.setAttribute(\"role\", \"region\");\n wrapper.setAttribute(\n \"aria-label\",\n \"Gestión de consentimiento de privacidad\",\n );\n\n wrapper.innerHTML = `\n <div class=\"consent-banner-container\">\n <div class=\"consent-banner-text\">\n <h2 class=\"consent-banner-title\">\n <span class=\"consent-banner-title-icon\">\n <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\">\n <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"/>\n </svg>\n </span>\n ${titleText}\n </h2>\n <p class=\"consent-banner-desc\">${descText}</p>\n <div class=\"consent-banner-links\">\n <a href=\"${cookiesUrl}\" target=\"_blank\" rel=\"noopener\">Política de cookies</a>\n <a href=\"${privacyUrl}\" target=\"_blank\" rel=\"noopener\">Política de privacidad</a>\n </div>\n </div>\n <div class=\"consent-banner-actions\">\n <button type=\"button\" class=\"consent-btn consent-btn-reject\" id=\"consent-btn-reject\">\n ${rejectText}\n </button>\n <button type=\"button\" class=\"consent-btn consent-btn-configure\" id=\"consent-btn-configure\">\n ${configureText}\n </button>\n <button type=\"button\" class=\"consent-btn consent-btn-accept\" id=\"consent-btn-accept\">\n ${acceptText}\n </button>\n </div>\n </div>\n `;\n\n wrapper\n .querySelector(\"#consent-btn-reject\")\n ?.addEventListener(\"click\", () => {\n handlers.onRejectAll();\n this.remove();\n });\n\n wrapper\n .querySelector(\"#consent-btn-configure\")\n ?.addEventListener(\"click\", () => {\n handlers.onConfigure();\n });\n\n wrapper\n .querySelector(\"#consent-btn-accept\")\n ?.addEventListener(\"click\", () => {\n handlers.onAcceptAll();\n this.remove();\n });\n\n document.body.appendChild(wrapper);\n this.element = wrapper;\n }\n\n remove(): void {\n if (this.element && this.element.parentNode) {\n this.element.parentNode.removeChild(this.element);\n this.element = null;\n }\n }\n}\n","import type { ConsentChoices, ConsentConfig } from \"../core/types.js\";\nimport { injectStyles } from \"./styles.js\";\nimport { sanitizeHtml } from \"../core/security.js\";\n\nexport interface PreferencesHandlers {\n onSave: (choices: ConsentChoices) => void;\n onAcceptAll: () => void;\n onRejectAll: () => void;\n onClose: () => void;\n}\n\nexport class PreferencesModal {\n private backdrop: HTMLElement | null = null;\n private lastFocusedElement: HTMLElement | null = null;\n\n render(\n config: ConsentConfig,\n currentChoices: ConsentChoices,\n handlers: PreferencesHandlers,\n ): void {\n if (typeof document === \"undefined\") return;\n this.close();\n injectStyles(config.csp?.nonce);\n\n this.lastFocusedElement = document.activeElement as HTMLElement;\n\n const prefConfig = config.ui?.preferences || {};\n const modalTitle = sanitizeHtml(prefConfig.title || \"Preferencias de privacidad\");\n const saveText = sanitizeHtml(prefConfig.save || \"Guardar selección\");\n const acceptAllText = sanitizeHtml(prefConfig.acceptAll || \"Permitir todas\");\n const rejectAllText = sanitizeHtml(prefConfig.rejectAll || \"Rechazar opcionales\");\n\n const backdrop = document.createElement(\"div\");\n backdrop.className = \"consent-dialog-backdrop\";\n\n const dialog = document.createElement(\"div\");\n dialog.className = \"consent-dialog\";\n dialog.setAttribute(\"role\", \"dialog\");\n dialog.setAttribute(\"aria-modal\", \"true\");\n dialog.setAttribute(\"aria-labelledby\", \"consent-dialog-title-id\");\n\n // Header\n const header = document.createElement(\"div\");\n header.className = \"consent-dialog-header\";\n header.innerHTML = `\n <div>\n <h2 class=\"consent-dialog-title\" id=\"consent-dialog-title-id\">${modalTitle}</h2>\n <p style=\"margin: 0.2rem 0 0 0; font-size: 0.84rem; color: var(--consent-muted); font-weight: 400;\">\n Gestiona tus permisos de almacenamiento por finalidad (LSSI art. 22.2 & RGPD).\n </p>\n </div>\n <button type=\"button\" class=\"consent-dialog-close\" aria-label=\"Cerrar ventana\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"></line>\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"></line>\n </svg>\n </button>\n `;\n\n // Body (Seamless List Rows)\n const body = document.createElement(\"div\");\n body.className = \"consent-dialog-body\";\n\n const categoryChoices: ConsentChoices = { ...currentChoices };\n\n for (const [catId, catConfig] of Object.entries(config.categories)) {\n const catRow = document.createElement(\"div\");\n catRow.className = \"consent-category-row\";\n\n const isRequired = catConfig.required === true;\n const isChecked = isRequired ? true : (categoryChoices[catId] ?? false);\n\n const associatedServices = config.services\n ? Object.entries(config.services).filter(([_, srv]) => srv.category === catId)\n : [];\n\n let servicesHtml = \"\";\n if (associatedServices.length > 0) {\n servicesHtml = `\n <div class=\"consent-category-services\" id=\"cat-services-${catId}\" style=\"display: none; margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px dashed var(--consent-divider); font-size: 0.82rem;\">\n <div style=\"font-weight: 600; color: var(--consent-muted); margin-bottom: 0.4rem; font-size: 0.75rem; letter-spacing: 0.02em;\">\n Servicios incluidos (${associatedServices.length})\n </div>\n <div style=\"display: flex; flex-direction: column; gap: 0.3rem;\">\n ${associatedServices\n .map(\n ([srvId, srv]) => `\n <div style=\"display: flex; justify-content: space-between; align-items: center; padding: 0.2rem 0;\">\n <span style=\"font-weight: 500;\">${sanitizeHtml(srv.label || srvId)}</span>\n <span style=\"color: var(--consent-muted); font-size: 0.78rem;\">${sanitizeHtml(srv.provider || \"Terceros\")}</span>\n </div>\n `,\n )\n .join(\"\")}\n </div>\n </div>\n `;\n }\n\n catRow.innerHTML = `\n <div class=\"consent-category-header\">\n <div style=\"flex: 1; padding-right: 1rem;\">\n <div style=\"display: flex; align-items: center; gap: 0.4rem;\">\n <span class=\"consent-category-name\">${sanitizeHtml(catConfig.label)}</span>\n ${\n isRequired\n ? '<span class=\"consent-badge consent-badge-required\">Requerida</span>'\n : '<span class=\"consent-badge consent-badge-optional\">Opcional</span>'\n }\n </div>\n <p class=\"consent-category-desc\">${sanitizeHtml(catConfig.description)}</p>\n ${\n associatedServices.length > 0\n ? `<button type=\"button\" class=\"consent-toggle-services-btn\" data-target=\"cat-services-${catId}\">\n Ver servicios (${associatedServices.length}) ▾\n </button>`\n : \"\"\n }\n </div>\n <label class=\"consent-toggle\">\n <input type=\"checkbox\" id=\"cat-toggle-${catId}\" ${isChecked ? \"checked\" : \"\"} ${isRequired ? \"disabled\" : \"\"}>\n <span class=\"consent-toggle-slider\"></span>\n </label>\n </div>\n ${servicesHtml}\n `;\n\n if (!isRequired) {\n const checkbox = catRow.querySelector<HTMLInputElement>(\n `#cat-toggle-${catId}`,\n );\n checkbox?.addEventListener(\"change\", (e) => {\n categoryChoices[catId] = (e.target as HTMLInputElement).checked;\n });\n }\n\n const toggleServicesBtn = catRow.querySelector<HTMLButtonElement>(\n \".consent-toggle-services-btn\",\n );\n if (toggleServicesBtn) {\n toggleServicesBtn.addEventListener(\"click\", () => {\n const targetId = toggleServicesBtn.getAttribute(\"data-target\");\n if (targetId) {\n const targetEl = catRow.querySelector<HTMLElement>(`#${targetId}`);\n if (targetEl) {\n const isHidden = targetEl.style.display === \"none\";\n targetEl.style.display = isHidden ? \"block\" : \"none\";\n toggleServicesBtn.textContent = isHidden\n ? `Ocultar servicios (${associatedServices.length}) ▴`\n : `Ver servicios (${associatedServices.length}) ▾`;\n }\n }\n });\n }\n\n body.appendChild(catRow);\n }\n\n // Footer\n const footer = document.createElement(\"div\");\n footer.className = \"consent-dialog-footer\";\n footer.innerHTML = `\n <button type=\"button\" class=\"consent-btn consent-btn-reject\" id=\"consent-pref-reject\">\n ${rejectAllText}\n </button>\n <div style=\"display: flex; gap: 0.5rem; flex-wrap: wrap;\">\n <button type=\"button\" class=\"consent-btn consent-btn-configure\" id=\"consent-pref-accept\">\n ${acceptAllText}\n </button>\n <button type=\"button\" class=\"consent-btn consent-btn-accept\" id=\"consent-pref-save\">\n ${saveText}\n </button>\n </div>\n `;\n\n dialog.appendChild(header);\n dialog.appendChild(body);\n dialog.appendChild(footer);\n backdrop.appendChild(dialog);\n\n // Event listeners\n header\n .querySelector(\".consent-dialog-close\")\n ?.addEventListener(\"click\", () => {\n handlers.onClose();\n this.close();\n });\n\n footer\n .querySelector(\"#consent-pref-reject\")\n ?.addEventListener(\"click\", () => {\n handlers.onRejectAll();\n this.close();\n });\n\n footer\n .querySelector(\"#consent-pref-accept\")\n ?.addEventListener(\"click\", () => {\n handlers.onAcceptAll();\n this.close();\n });\n\n footer\n .querySelector(\"#consent-pref-save\")\n ?.addEventListener(\"click\", () => {\n handlers.onSave(categoryChoices);\n this.close();\n });\n\n // Keyboard navigation (Escape & Focus Trap)\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n handlers.onClose();\n this.close();\n return;\n }\n\n if (e.key === \"Tab\") {\n const focusableElements = dialog.querySelectorAll<HTMLElement>(\n 'button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])',\n );\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n if (e.shiftKey) {\n if (document.activeElement === firstElement) {\n lastElement?.focus();\n e.preventDefault();\n }\n } else {\n if (document.activeElement === lastElement) {\n firstElement?.focus();\n e.preventDefault();\n }\n }\n }\n };\n\n document.addEventListener(\"keydown\", handleKeyDown);\n (this as any)._keyListener = handleKeyDown;\n\n document.body.appendChild(backdrop);\n this.backdrop = backdrop;\n\n // Focus first element\n const firstFocusable = dialog.querySelector<HTMLElement>(\"button\");\n firstFocusable?.focus();\n }\n\n close(): void {\n if ((this as any)._keyListener) {\n document.removeEventListener(\"keydown\", (this as any)._keyListener);\n delete (this as any)._keyListener;\n }\n\n if (this.backdrop && this.backdrop.parentNode) {\n this.backdrop.parentNode.removeChild(this.backdrop);\n this.backdrop = null;\n }\n\n if (\n this.lastFocusedElement &&\n typeof this.lastFocusedElement.focus === \"function\"\n ) {\n this.lastFocusedElement.focus();\n this.lastFocusedElement = null;\n }\n }\n}\n","import type {\n ConsentChoices,\n ConsentConfig,\n ConsentEvent,\n ConsentEventHandler,\n ConsentReceipt,\n ConsentSDKInterface,\n ConsentState,\n DiagnosticReport,\n} from \"./types.js\";\nimport { validateConfig } from \"./config-validator.js\";\nimport { StateManager } from \"./state.js\";\nimport { EventBus } from \"./events.js\";\nimport { createReceipt, parseReceipt } from \"./receipt.js\";\nimport { evaluatePolicy } from \"./policy-engine.js\";\nimport { CookieStore } from \"../storage/cookie-store.js\";\nimport { MemoryStore } from \"../storage/memory-store.js\";\nimport { BlockerRegistry } from \"../blocker/registry.js\";\nimport { GoogleConsentAdapter } from \"../services/google.js\";\nimport { CustomServiceAdapter } from \"../services/custom.js\";\nimport { ConsentBanner } from \"../ui/banner.js\";\nimport { PreferencesModal } from \"../ui/preferences.js\";\nimport { ResourceScanner } from \"../diagnostics/resource-scanner.js\";\nimport { PolicyGenerator } from \"../ui/policy-generator.js\";\n\nexport class ConsentEngine implements ConsentSDKInterface {\n private stateManager = new StateManager();\n private eventBus = new EventBus();\n private blockerRegistry = new BlockerRegistry();\n private banner = new ConsentBanner();\n private preferencesModal = new PreferencesModal();\n\n private initPromise: Promise<void> | null = null;\n private resolveReady: (() => void) | null = null;\n private readyPromise = new Promise<void>((resolve) => {\n this.resolveReady = resolve;\n });\n\n async init(configInput: ConsentConfig | string): Promise<void> {\n if (this.initPromise) return this.initPromise;\n\n this.initPromise = (async () => {\n let config: ConsentConfig;\n\n if (typeof configInput === \"string\") {\n const response = await fetch(configInput);\n if (!response.ok) {\n throw new Error(\n `[ConsentSDK] Failed to fetch consent configuration from '${configInput}' (HTTP ${response.status})`,\n );\n }\n config = await response.json();\n } else {\n config = configInput;\n }\n\n validateConfig(config);\n\n // Load saved receipt from cookie or memory\n const cookieName = config.storage?.name || \"site_consent\";\n const rawReceipt =\n config.storage?.type === \"memory\"\n ? MemoryStore.get(cookieName)\n : CookieStore.get(cookieName);\n\n const savedReceipt = rawReceipt ? parseReceipt(rawReceipt) : null;\n const evalResult = evaluatePolicy(config, savedReceipt);\n\n const activeReceipt = evalResult.isValid ? savedReceipt : null;\n this.stateManager.init(config, evalResult.choices, activeReceipt);\n\n // Initialize Google Consent Mode defaults\n GoogleConsentAdapter.initDefault();\n if (evalResult.isValid) {\n GoogleConsentAdapter.update(evalResult.choices);\n this.dispatchDomEvent(\"solvenza:restored\", { state: this.getConsent() });\n }\n\n // Initialize Blocker System\n this.blockerRegistry.init(\n (cat) => this.has(cat),\n (srv) => this.hasService(srv),\n {\n onAllowClick: (category) => {\n const current = this.stateManager.getChoices();\n current[category] = true;\n this.setPreferences(current);\n },\n },\n (serviceId, category) => {\n this.eventBus.emit(\"service:loaded\", { serviceId, category });\n },\n );\n\n // Attach global listeners for permanent revocation trigger [data-consent-open] and CustomEvents\n this.setupGlobalRevocationTrigger();\n\n this.resolveReady?.();\n this.eventBus.emit(\"ready\", { state: this.getConsent() });\n\n // If missing receipt or policy version changed, display 1st layer banner\n if (!evalResult.isValid) {\n this.showBanner();\n }\n })();\n\n return this.initPromise;\n }\n\n async ready(): Promise<void> {\n return this.readyPromise;\n }\n\n getConsent(): ConsentState {\n return this.stateManager.getState();\n }\n\n has(category: string): boolean {\n return this.stateManager.hasCategory(category);\n }\n\n hasService(serviceId: string): boolean {\n return this.stateManager.hasService(serviceId);\n }\n\n acceptAll(): void {\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n const choices: ConsentChoices = {};\n for (const catId of Object.keys(config.categories)) {\n choices[catId] = true;\n }\n\n this.saveChoices(choices, \"banner\");\n this.eventBus.emit(\"consent:accepted\", {\n choices,\n receipt: this.getReceipt()!,\n });\n }\n\n rejectAll(): void {\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n const choices: ConsentChoices = {};\n for (const [catId, catConfig] of Object.entries(config.categories)) {\n choices[catId] = catConfig.required === true;\n }\n\n this.saveChoices(choices, \"banner\");\n this.eventBus.emit(\"consent:rejected\", {\n choices,\n receipt: this.getReceipt()!,\n });\n }\n\n setPreferences(choices: ConsentChoices): void {\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n // Enforce necessary = true\n const sanitizedChoices: ConsentChoices = { ...choices };\n sanitizedChoices[\"necessary\"] = true;\n\n this.saveChoices(sanitizedChoices, \"preferences\");\n }\n\n openPreferences(): void {\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n this.preferencesModal.render(config, this.stateManager.getChoices(), {\n onSave: (choices) => this.setPreferences(choices),\n onAcceptAll: () => this.acceptAll(),\n onRejectAll: () => this.rejectAll(),\n onClose: () => {\n this.eventBus.emit(\"preferences:closed\", undefined);\n },\n });\n\n this.eventBus.emit(\"preferences:opened\", undefined);\n }\n\n closePreferences(): void {\n this.preferencesModal.close();\n }\n\n withdraw(): void {\n const previousChoices = this.stateManager.getChoices();\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n const cookieName = config.storage?.name || \"site_consent\";\n if (config.storage?.type === \"memory\") {\n MemoryStore.remove(cookieName);\n } else {\n CookieStore.remove(cookieName, config.storage?.path || \"/\", config.storage?.domain);\n }\n\n // Auto-clear all service cookies for optional categories\n for (const catId of Object.keys(config.categories)) {\n if (catId !== \"necessary\") {\n CookieStore.clearServiceCookies(config, catId);\n }\n }\n\n this.stateManager.clearChoices();\n GoogleConsentAdapter.update(this.stateManager.getChoices());\n this.eventBus.emit(\"consent:withdrawn\", { previousChoices });\n this.dispatchDomEvent(\"solvenza:updated\", { choices: this.stateManager.getChoices() });\n\n this.showBanner();\n }\n\n when(categoryOrService: string, callback: () => void): () => void {\n return CustomServiceAdapter.createWhen(\n this.eventBus,\n (cat) => this.has(cat),\n (srv) => this.hasService(srv),\n )(categoryOrService, callback);\n }\n\n on<E extends ConsentEvent>(\n event: E,\n handler: ConsentEventHandler<E>,\n ): () => void {\n return this.eventBus.on(event, handler);\n }\n\n getReceipt(): ConsentReceipt | null {\n return this.stateManager.getReceipt();\n }\n\n rescan(): DiagnosticReport {\n const config = this.stateManager.getConfig();\n if (!config) {\n throw new Error(\"[ConsentSDK] SDK not initialized.\");\n }\n const isGiven = !!this.getReceipt();\n return ResourceScanner.runDiagnostic(config, isGiven);\n }\n\n mountPolicy(targetContainer: HTMLElement | string): void {\n const config = this.stateManager.getConfig();\n if (!config) {\n throw new Error(\"[ConsentSDK] SDK not initialized.\");\n }\n const container =\n typeof targetContainer === \"string\"\n ? document.querySelector<HTMLElement>(targetContainer)\n : targetContainer;\n if (container) {\n container.innerHTML = PolicyGenerator.renderTable(config);\n }\n }\n\n private saveChoices(\n choices: ConsentChoices,\n source: ConsentReceipt[\"source\"],\n ): void {\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n const receipt = createReceipt(\n config.policyVersion,\n choices,\n source,\n this.stateManager.getReceipt(),\n config.security?.secretKey,\n );\n\n this.stateManager.updateChoices(receipt);\n\n // Auto-clear cookies for revoked categories\n for (const [catId, isAllowed] of Object.entries(choices)) {\n if (!isAllowed) {\n CookieStore.clearServiceCookies(config, catId);\n }\n }\n\n // Persist receipt\n const cookieName = config.storage?.name || \"site_consent\";\n const receiptJson = JSON.stringify(receipt);\n\n if (config.storage?.type === \"memory\") {\n MemoryStore.set(cookieName, receiptJson);\n } else {\n CookieStore.set(cookieName, receiptJson, {\n path: config.storage?.path || \"/\",\n maxAgeDays: config.consent?.maxAgeDays ?? 365,\n sameSite: config.storage?.sameSite || \"Lax\",\n secure: config.storage?.secure,\n domain: config.storage?.domain,\n });\n }\n\n // Update Google Consent Mode\n GoogleConsentAdapter.update(choices);\n\n // Trigger blocker scan for newly permitted resources\n this.blockerRegistry.init(\n (cat) => this.has(cat),\n (srv) => this.hasService(srv),\n );\n\n // Optional receipt log endpoint\n if (config.logging?.enabled && config.logging.endpoint) {\n try {\n fetch(config.logging.endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: receiptJson,\n }).catch(() => {});\n } catch {}\n }\n\n this.banner.remove();\n this.eventBus.emit(\"consent:changed\", { choices, receipt });\n this.dispatchDomEvent(\"solvenza:updated\", { choices, receipt });\n }\n\n private showBanner(): void {\n const config = this.stateManager.getConfig();\n if (!config) return;\n\n this.banner.render(config, {\n onAcceptAll: () => this.acceptAll(),\n onRejectAll: () => this.rejectAll(),\n onConfigure: () => this.openPreferences(),\n });\n this.eventBus.emit(\"banner:shown\", undefined);\n this.dispatchDomEvent(\"solvenza:show\", undefined);\n }\n\n private setupGlobalRevocationTrigger(): void {\n if (typeof document === \"undefined\") return;\n\n document.addEventListener(\"click\", (e) => {\n const target = e.target as HTMLElement | null;\n if (target?.closest(\"[data-consent-open]\")) {\n e.preventDefault();\n this.openPreferences();\n }\n });\n\n // Support zero-code DOM CustomEvents dispatching (e.g. document.dispatchEvent(new Event('solvenza:show')))\n document.addEventListener(\"solvenza:show\", () => {\n this.showBanner();\n });\n\n document.addEventListener(\"solvenza:preferences\", () => {\n this.openPreferences();\n });\n }\n\n private dispatchDomEvent(name: string, detail: unknown): void {\n if (typeof document === \"undefined\") return;\n try {\n const customEvent = new CustomEvent(name, { detail, bubbles: true });\n document.dispatchEvent(customEvent);\n } catch {}\n }\n}\n\n// Ensure global singleton instance across bundler chunks, wrappers, and HMR\nconst globalScope = typeof window !== \"undefined\" ? (window as any) : globalThis;\nif (!globalScope.__ConsentSDK_Instance__) {\n globalScope.__ConsentSDK_Instance__ = new ConsentEngine();\n}\n\nexport const Consent: ConsentEngine = globalScope.__ConsentSDK_Instance__;\n"],"mappings":";;;;;AAEO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAAY,SAAiB;AAC3B,UAAM,6BAA6B,OAAO,EAAE;AAC5C,SAAK,OAAO;AAAA,EACd;AACF;AAEO,SAAS,eAAe,QAA6B;AAC1D,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,sBAAsB,4CAA4C;AAAA,EAC9E;AAEA,MAAI,OAAO,OAAO,kBAAkB,YAAY,OAAO,gBAAgB,GAAG;AACxE,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AAK,UAAU;AAAA,MAClC,aAAa,MAAM,KAAK,gBAAgB;AAAA,IAC1C,CAAC;AACD,SAAK,SAAS,KAAK,gBAAgB,MAAS;AAC5C,SAAK,iBAAiB,iBAAiB,MAAS;AAAA,EAClD;AAAA,EAEQ,+BAAqC;AAC3C,QAAI,OAAO,aAAa,YAAa;AAErC,aAAS,iBAAiB,SAAS,CAAC,MAAM;AACxC,YAAM,SAAS,EAAE;AACjB,UAAI,iCAAQ,QAAQ,wBAAwB;AAC1C,UAAE,eAAe;AACjB,aAAK,gBAAgB;AAAA,MACvB;AAAA,IACF,CAAC;AAGD,aAAS,iBAAiB,iBAAiB,MAAM;AAC/C,WAAK,WAAW;AAAA,IAClB,CAAC;AAED,aAAS,iBAAiB,wBAAwB,MAAM;AACtD,WAAK,gBAAgB;AAAA,IACvB,CAAC;AAAA,EACH;AAAA,EAEQ,iBAAiB,MAAc,QAAuB;AAC5D,QAAI,OAAO,aAAa,YAAa;AACrC,QAAI;AACF,YAAM,cAAc,IAAI,YAAY,MAAM,EAAE,QAAQ,SAAS,KAAK,CAAC;AACnE,eAAS,cAAc,WAAW;AAAA,IACpC,SAAQ;AAAA,IAAC;AAAA,EACX;AACF;AAGA,IAAM,cAAc,OAAO,WAAW,cAAe,SAAiB;AACtE,IAAI,CAAC,YAAY,yBAAyB;AACxC,cAAY,0BAA0B,IAAI,cAAc;AAC1D;AAEO,IAAM,UAAyB,YAAY;","names":["_a"]}
|
package/dist/consent.esm.cjs
CHANGED
|
@@ -516,6 +516,19 @@ var CookieStore = class {
|
|
|
516
516
|
}
|
|
517
517
|
document.cookie = cookieStr;
|
|
518
518
|
}
|
|
519
|
+
static clearServiceCookies(config, revokedCategory) {
|
|
520
|
+
var _a, _b;
|
|
521
|
+
if (typeof document === "undefined" || !config.services) return;
|
|
522
|
+
const path = ((_a = config.storage) == null ? void 0 : _a.path) || "/";
|
|
523
|
+
const domain = (_b = config.storage) == null ? void 0 : _b.domain;
|
|
524
|
+
for (const service of Object.values(config.services)) {
|
|
525
|
+
if (service.category === revokedCategory && service.cookies) {
|
|
526
|
+
for (const cookieItem of service.cookies) {
|
|
527
|
+
this.remove(cookieItem.name, path, domain || cookieItem.domain);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
519
532
|
};
|
|
520
533
|
|
|
521
534
|
// src/storage/memory-store.ts
|
|
@@ -1699,6 +1712,7 @@ var ConsentEngine = class {
|
|
|
1699
1712
|
GoogleConsentAdapter.initDefault();
|
|
1700
1713
|
if (evalResult.isValid) {
|
|
1701
1714
|
GoogleConsentAdapter.update(evalResult.choices);
|
|
1715
|
+
this.dispatchDomEvent("solvenza:restored", { state: this.getConsent() });
|
|
1702
1716
|
}
|
|
1703
1717
|
this.blockerRegistry.init(
|
|
1704
1718
|
(cat) => this.has(cat),
|
|
@@ -1795,9 +1809,15 @@ var ConsentEngine = class {
|
|
|
1795
1809
|
} else {
|
|
1796
1810
|
CookieStore.remove(cookieName, ((_c = config.storage) == null ? void 0 : _c.path) || "/", (_d = config.storage) == null ? void 0 : _d.domain);
|
|
1797
1811
|
}
|
|
1812
|
+
for (const catId of Object.keys(config.categories)) {
|
|
1813
|
+
if (catId !== "necessary") {
|
|
1814
|
+
CookieStore.clearServiceCookies(config, catId);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1798
1817
|
this.stateManager.clearChoices();
|
|
1799
1818
|
GoogleConsentAdapter.update(this.stateManager.getChoices());
|
|
1800
1819
|
this.eventBus.emit("consent:withdrawn", { previousChoices });
|
|
1820
|
+
this.dispatchDomEvent("solvenza:updated", { choices: this.stateManager.getChoices() });
|
|
1801
1821
|
this.showBanner();
|
|
1802
1822
|
}
|
|
1803
1823
|
when(categoryOrService, callback) {
|
|
@@ -1843,6 +1863,11 @@ var ConsentEngine = class {
|
|
|
1843
1863
|
(_a = config.security) == null ? void 0 : _a.secretKey
|
|
1844
1864
|
);
|
|
1845
1865
|
this.stateManager.updateChoices(receipt);
|
|
1866
|
+
for (const [catId, isAllowed] of Object.entries(choices)) {
|
|
1867
|
+
if (!isAllowed) {
|
|
1868
|
+
CookieStore.clearServiceCookies(config, catId);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1846
1871
|
const cookieName = ((_b = config.storage) == null ? void 0 : _b.name) || "site_consent";
|
|
1847
1872
|
const receiptJson = JSON.stringify(receipt);
|
|
1848
1873
|
if (((_c = config.storage) == null ? void 0 : _c.type) === "memory") {
|
|
@@ -1874,6 +1899,7 @@ var ConsentEngine = class {
|
|
|
1874
1899
|
}
|
|
1875
1900
|
this.banner.remove();
|
|
1876
1901
|
this.eventBus.emit("consent:changed", { choices, receipt });
|
|
1902
|
+
this.dispatchDomEvent("solvenza:updated", { choices, receipt });
|
|
1877
1903
|
}
|
|
1878
1904
|
showBanner() {
|
|
1879
1905
|
const config = this.stateManager.getConfig();
|
|
@@ -1884,6 +1910,7 @@ var ConsentEngine = class {
|
|
|
1884
1910
|
onConfigure: () => this.openPreferences()
|
|
1885
1911
|
});
|
|
1886
1912
|
this.eventBus.emit("banner:shown", void 0);
|
|
1913
|
+
this.dispatchDomEvent("solvenza:show", void 0);
|
|
1887
1914
|
}
|
|
1888
1915
|
setupGlobalRevocationTrigger() {
|
|
1889
1916
|
if (typeof document === "undefined") return;
|
|
@@ -1894,6 +1921,20 @@ var ConsentEngine = class {
|
|
|
1894
1921
|
this.openPreferences();
|
|
1895
1922
|
}
|
|
1896
1923
|
});
|
|
1924
|
+
document.addEventListener("solvenza:show", () => {
|
|
1925
|
+
this.showBanner();
|
|
1926
|
+
});
|
|
1927
|
+
document.addEventListener("solvenza:preferences", () => {
|
|
1928
|
+
this.openPreferences();
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
dispatchDomEvent(name, detail) {
|
|
1932
|
+
if (typeof document === "undefined") return;
|
|
1933
|
+
try {
|
|
1934
|
+
const customEvent = new CustomEvent(name, { detail, bubbles: true });
|
|
1935
|
+
document.dispatchEvent(customEvent);
|
|
1936
|
+
} catch (e) {
|
|
1937
|
+
}
|
|
1897
1938
|
}
|
|
1898
1939
|
};
|
|
1899
1940
|
var globalScope = typeof window !== "undefined" ? window : globalThis;
|