@solvenza/cookies-compliance 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -0
- package/bin/audit-cli.js +25 -0
- package/bin/init-cli.js +126 -0
- package/dist/chunk-DDAAVRWG.js +25 -0
- package/dist/chunk-DDAAVRWG.js.map +1 -0
- package/dist/chunk-LIWFUVWY.js +1858 -0
- package/dist/chunk-LIWFUVWY.js.map +1 -0
- package/dist/consent-engine-BvsH_wqV.d.cts +191 -0
- package/dist/consent-engine-BvsH_wqV.d.ts +191 -0
- package/dist/consent.esm.cjs +2051 -0
- package/dist/consent.esm.cjs.map +1 -0
- package/dist/consent.esm.d.cts +146 -0
- package/dist/consent.esm.d.ts +146 -0
- package/dist/consent.esm.js +184 -0
- package/dist/consent.esm.js.map +1 -0
- package/dist/consent.min.js +589 -0
- package/dist/consent.min.js.map +1 -0
- package/dist/wrappers/angular.cjs +1867 -0
- package/dist/wrappers/angular.cjs.map +1 -0
- package/dist/wrappers/angular.d.cts +20 -0
- package/dist/wrappers/angular.d.ts +20 -0
- package/dist/wrappers/angular.js +42 -0
- package/dist/wrappers/angular.js.map +1 -0
- package/dist/wrappers/next.cjs +1840 -0
- package/dist/wrappers/next.cjs.map +1 -0
- package/dist/wrappers/next.d.cts +3 -0
- package/dist/wrappers/next.d.ts +3 -0
- package/dist/wrappers/next.js +15 -0
- package/dist/wrappers/next.js.map +1 -0
- package/dist/wrappers/react.cjs +1882 -0
- package/dist/wrappers/react.cjs.map +1 -0
- package/dist/wrappers/react.d.cts +4 -0
- package/dist/wrappers/react.d.ts +4 -0
- package/dist/wrappers/react.js +56 -0
- package/dist/wrappers/react.js.map +1 -0
- package/dist/wrappers/wordpress.cjs +64 -0
- package/dist/wrappers/wordpress.cjs.map +1 -0
- package/dist/wrappers/wordpress.d.cts +10 -0
- package/dist/wrappers/wordpress.d.ts +10 -0
- package/dist/wrappers/wordpress.js +41 -0
- package/dist/wrappers/wordpress.js.map +1 -0
- package/package.json +85 -0
- package/schema.json +165 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigValidationError,
|
|
3
|
+
Consent,
|
|
4
|
+
ConsentEngine,
|
|
5
|
+
CookieStorageProvider,
|
|
6
|
+
CookieStore,
|
|
7
|
+
GoogleConsentAdapter,
|
|
8
|
+
IframeGate,
|
|
9
|
+
IframeResourceBlocker,
|
|
10
|
+
ImageResourceBlocker,
|
|
11
|
+
MemoryStorageProvider,
|
|
12
|
+
MemoryStore,
|
|
13
|
+
PolicyGenerator,
|
|
14
|
+
ResourceGate,
|
|
15
|
+
ResourceScanner,
|
|
16
|
+
ScriptGate,
|
|
17
|
+
ScriptResourceBlocker,
|
|
18
|
+
computeReceiptSignature,
|
|
19
|
+
createReceipt,
|
|
20
|
+
isReceiptExpired,
|
|
21
|
+
parseReceipt,
|
|
22
|
+
sanitizeHtml,
|
|
23
|
+
validateConfig,
|
|
24
|
+
verifyReceiptIntegrity
|
|
25
|
+
} from "./chunk-LIWFUVWY.js";
|
|
26
|
+
import {
|
|
27
|
+
__spreadProps,
|
|
28
|
+
__spreadValues
|
|
29
|
+
} from "./chunk-DDAAVRWG.js";
|
|
30
|
+
|
|
31
|
+
// src/core/builder/config-builder.ts
|
|
32
|
+
var ConsentConfigBuilder = class {
|
|
33
|
+
constructor(policyVersion) {
|
|
34
|
+
this.config = {
|
|
35
|
+
schemaVersion: 1,
|
|
36
|
+
policyVersion: "1.0.0",
|
|
37
|
+
categories: {},
|
|
38
|
+
services: {}
|
|
39
|
+
};
|
|
40
|
+
if (policyVersion) {
|
|
41
|
+
this.config.policyVersion = policyVersion;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
setSchemaVersion(version) {
|
|
45
|
+
this.config.schemaVersion = version;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
setPolicyVersion(version) {
|
|
49
|
+
this.config.policyVersion = version;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
setPolicyUrls(privacyUrl, cookiesUrl) {
|
|
53
|
+
this.config.policy = { privacyUrl, cookiesUrl };
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
setLocale(defaultLocale, autoDetect = true) {
|
|
57
|
+
this.config.locale = {
|
|
58
|
+
default: defaultLocale,
|
|
59
|
+
autoDetect
|
|
60
|
+
};
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
addCategory(id, category) {
|
|
64
|
+
if (!this.config.categories) {
|
|
65
|
+
this.config.categories = {};
|
|
66
|
+
}
|
|
67
|
+
this.config.categories[id] = category;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
addService(id, service) {
|
|
71
|
+
if (!this.config.services) {
|
|
72
|
+
this.config.services = {};
|
|
73
|
+
}
|
|
74
|
+
this.config.services[id] = service;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
build() {
|
|
78
|
+
var _a;
|
|
79
|
+
if (!((_a = this.config.categories) == null ? void 0 : _a.necessary)) {
|
|
80
|
+
this.config.categories = __spreadProps(__spreadValues({}, this.config.categories), {
|
|
81
|
+
necessary: {
|
|
82
|
+
required: true,
|
|
83
|
+
default: true,
|
|
84
|
+
label: "Necesarias",
|
|
85
|
+
description: "Cookies y almacenamiento imprescindible para el funcionamiento del sitio."
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const finalConfig = this.config;
|
|
90
|
+
validateConfig(finalConfig);
|
|
91
|
+
return finalConfig;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/storage/storage-factory.ts
|
|
96
|
+
var StorageFactory = class {
|
|
97
|
+
static create(type) {
|
|
98
|
+
switch (type) {
|
|
99
|
+
case "cookie":
|
|
100
|
+
return new CookieStorageProvider();
|
|
101
|
+
case "memory":
|
|
102
|
+
return new MemoryStorageProvider();
|
|
103
|
+
default:
|
|
104
|
+
return new CookieStorageProvider();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/i18n/engine.ts
|
|
110
|
+
var I18nEngine = class {
|
|
111
|
+
constructor() {
|
|
112
|
+
this.locale = "es";
|
|
113
|
+
}
|
|
114
|
+
setLocale(locale) {
|
|
115
|
+
this.locale = locale;
|
|
116
|
+
}
|
|
117
|
+
getLocale() {
|
|
118
|
+
return this.locale;
|
|
119
|
+
}
|
|
120
|
+
detectBrowserLocale() {
|
|
121
|
+
if (typeof navigator !== "undefined" && navigator.language) {
|
|
122
|
+
return navigator.language.split("-")[0].toLowerCase();
|
|
123
|
+
}
|
|
124
|
+
return "es";
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/index.ts
|
|
129
|
+
if (typeof window !== "undefined") {
|
|
130
|
+
window.Consent = Consent;
|
|
131
|
+
window.ConsentSDK = {
|
|
132
|
+
Consent,
|
|
133
|
+
ConsentEngine,
|
|
134
|
+
ConsentConfigBuilder,
|
|
135
|
+
validateConfig,
|
|
136
|
+
PolicyGenerator,
|
|
137
|
+
ResourceScanner
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (typeof document !== "undefined") {
|
|
141
|
+
const currentScript = document.currentScript;
|
|
142
|
+
const configUrl = currentScript == null ? void 0 : currentScript.getAttribute("data-config");
|
|
143
|
+
if (configUrl) {
|
|
144
|
+
const autoInit = () => {
|
|
145
|
+
void Consent.init(configUrl).catch((err) => {
|
|
146
|
+
console.warn("[ConsentSDK AutoInit Warning]", err);
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
if (document.readyState === "loading") {
|
|
150
|
+
document.addEventListener("DOMContentLoaded", autoInit);
|
|
151
|
+
} else {
|
|
152
|
+
autoInit();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
ConfigValidationError,
|
|
158
|
+
Consent,
|
|
159
|
+
ConsentConfigBuilder,
|
|
160
|
+
ConsentEngine,
|
|
161
|
+
CookieStorageProvider,
|
|
162
|
+
CookieStore,
|
|
163
|
+
GoogleConsentAdapter,
|
|
164
|
+
I18nEngine,
|
|
165
|
+
IframeGate,
|
|
166
|
+
IframeResourceBlocker,
|
|
167
|
+
ImageResourceBlocker,
|
|
168
|
+
MemoryStorageProvider,
|
|
169
|
+
MemoryStore,
|
|
170
|
+
PolicyGenerator,
|
|
171
|
+
ResourceGate,
|
|
172
|
+
ResourceScanner,
|
|
173
|
+
ScriptGate,
|
|
174
|
+
ScriptResourceBlocker,
|
|
175
|
+
StorageFactory,
|
|
176
|
+
computeReceiptSignature,
|
|
177
|
+
createReceipt,
|
|
178
|
+
isReceiptExpired,
|
|
179
|
+
parseReceipt,
|
|
180
|
+
sanitizeHtml,
|
|
181
|
+
validateConfig,
|
|
182
|
+
verifyReceiptIntegrity
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=consent.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/builder/config-builder.ts","../src/storage/storage-factory.ts","../src/i18n/engine.ts","../src/index.ts"],"sourcesContent":["import type { CategoryConfig, ConsentConfig, ServiceConfig } from \"../types.js\";\nimport { validateConfig } from \"../config-validator.js\";\n\nexport class ConsentConfigBuilder {\n private config: Partial<ConsentConfig> = {\n schemaVersion: 1,\n policyVersion: \"1.0.0\",\n categories: {},\n services: {},\n };\n\n constructor(policyVersion?: string) {\n if (policyVersion) {\n this.config.policyVersion = policyVersion;\n }\n }\n\n setSchemaVersion(version: number): this {\n this.config.schemaVersion = version;\n return this;\n }\n\n setPolicyVersion(version: string): this {\n this.config.policyVersion = version;\n return this;\n }\n\n setPolicyUrls(privacyUrl: string, cookiesUrl: string): this {\n this.config.policy = { privacyUrl, cookiesUrl };\n return this;\n }\n\n setLocale(defaultLocale: string, autoDetect = true): this {\n this.config.locale = {\n default: defaultLocale,\n autoDetect,\n };\n return this;\n }\n\n addCategory(id: string, category: CategoryConfig): this {\n if (!this.config.categories) {\n this.config.categories = {};\n }\n this.config.categories[id] = category;\n return this;\n }\n\n addService(id: string, service: ServiceConfig): this {\n if (!this.config.services) {\n this.config.services = {};\n }\n this.config.services[id] = service;\n return this;\n }\n\n build(): ConsentConfig {\n if (!this.config.categories?.necessary) {\n this.config.categories = {\n ...this.config.categories,\n necessary: {\n required: true,\n default: true,\n label: \"Necesarias\",\n description: \"Cookies y almacenamiento imprescindible para el funcionamiento del sitio.\",\n },\n };\n }\n\n const finalConfig = this.config as ConsentConfig;\n validateConfig(finalConfig);\n return finalConfig;\n }\n}\n","import type { IStorageProvider, StorageType } from \"../core/contracts/storage.interface.js\";\nimport { CookieStorageProvider } from \"./cookie-store.js\";\nimport { MemoryStorageProvider } from \"./memory-store.js\";\n\nexport class StorageFactory {\n static create(type: StorageType): IStorageProvider {\n switch (type) {\n case \"cookie\":\n return new CookieStorageProvider();\n case \"memory\":\n return new MemoryStorageProvider();\n default:\n return new CookieStorageProvider();\n }\n }\n}\n","export class I18nEngine {\n private locale = \"es\";\n\n setLocale(locale: string): void {\n this.locale = locale;\n }\n\n getLocale(): string {\n return this.locale;\n }\n\n detectBrowserLocale(): string {\n if (typeof navigator !== \"undefined\" && navigator.language) {\n return navigator.language.split(\"-\")[0].toLowerCase();\n }\n return \"es\";\n }\n}\n","import { Consent, ConsentEngine } from \"./core/consent-engine.js\";\nimport { ConsentConfigBuilder } from \"./core/builder/config-builder.js\";\nimport { validateConfig, ConfigValidationError } from \"./core/config-validator.js\";\nimport { createReceipt, parseReceipt, isReceiptExpired } from \"./core/receipt.js\";\nimport { StorageFactory } from \"./storage/storage-factory.js\";\nimport { CookieStorageProvider, CookieStore } from \"./storage/cookie-store.js\";\nimport { MemoryStorageProvider, MemoryStore } from \"./storage/memory-store.js\";\nimport { GoogleConsentAdapter } from \"./services/google.js\";\nimport { ScriptResourceBlocker, ScriptGate } from \"./blocker/script-gate.js\";\nimport { IframeResourceBlocker, IframeGate } from \"./blocker/iframe-gate.js\";\nimport { ImageResourceBlocker, ResourceGate } from \"./blocker/resource-gate.js\";\nimport { ResourceScanner } from \"./diagnostics/resource-scanner.js\";\nimport { computeReceiptSignature, verifyReceiptIntegrity, sanitizeHtml } from \"./core/security.js\";\nimport { I18nEngine } from \"./i18n/engine.js\";\nimport { PolicyGenerator } from \"./ui/policy-generator.js\";\n\nexport {\n Consent,\n ConsentEngine,\n ConsentConfigBuilder,\n validateConfig,\n ConfigValidationError,\n createReceipt,\n parseReceipt,\n isReceiptExpired,\n StorageFactory,\n CookieStorageProvider,\n CookieStore,\n MemoryStorageProvider,\n MemoryStore,\n GoogleConsentAdapter,\n ScriptResourceBlocker,\n ScriptGate,\n IframeResourceBlocker,\n IframeGate,\n ImageResourceBlocker,\n ResourceGate,\n ResourceScanner,\n computeReceiptSignature,\n verifyReceiptIntegrity,\n sanitizeHtml,\n I18nEngine,\n PolicyGenerator,\n};\n\nexport type * from \"./core/types.js\";\n\nif (typeof window !== \"undefined\") {\n (window as any).Consent = Consent;\n (window as any).ConsentSDK = {\n Consent,\n ConsentEngine,\n ConsentConfigBuilder,\n validateConfig,\n PolicyGenerator,\n ResourceScanner,\n };\n}\n\nif (typeof document !== \"undefined\") {\n const currentScript = document.currentScript as HTMLScriptElement | null;\n const configUrl = currentScript?.getAttribute(\"data-config\");\n if (configUrl) {\n const autoInit = () => {\n void Consent.init(configUrl).catch((err: unknown) => {\n console.warn(\"[ConsentSDK AutoInit Warning]\", err);\n });\n };\n\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", autoInit);\n } else {\n autoInit();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,uBAAN,MAA2B;AAAA,EAQhC,YAAY,eAAwB;AAPpC,SAAQ,SAAiC;AAAA,MACvC,eAAe;AAAA,MACf,eAAe;AAAA,MACf,YAAY,CAAC;AAAA,MACb,UAAU,CAAC;AAAA,IACb;AAGE,QAAI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