added /dist

This commit is contained in:
2026-08-03 12:24:28 +02:00
parent dd97bb67fe
commit 05150e7ece
490 changed files with 6667 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
import { CONSENT_CATEGORIES, DEFAULT_CONSENT } from './categories.js';
/**
* Consent persistence in a cookie. Stored with a version so we can invalidate
* old consents when the policy changes, and a timestamp (GDPR: consent must be
* dated). Readable both client-side (banner) and server-side (script gating).
*/ export const CONSENT_COOKIE = 'cookie-consent';
export const CONSENT_VERSION = 1;
export const CONSENT_MAX_AGE = 60 * 60 * 24 * 180 // 180 days
;
export function serializeConsent(state) {
const payload = {
state,
timestamp: new Date().toISOString(),
version: CONSENT_VERSION
};
return encodeURIComponent(JSON.stringify(payload));
}
export function parseConsent(raw) {
if (!raw) {
return null;
}
try {
const parsed = JSON.parse(decodeURIComponent(raw));
if (parsed.version !== CONSENT_VERSION) {
return null;
}
const state = {
...DEFAULT_CONSENT
};
for (const cat of CONSENT_CATEGORIES){
if (typeof parsed.state?.[cat] === 'boolean') {
state[cat] = parsed.state[cat];
}
}
state.necessary = true;
return state;
} catch {
return null;
}
}
//# sourceMappingURL=storage.js.map