Initial commit

This commit is contained in:
2026-08-02 20:55:23 +02:00
parent 411f484b40
commit d558d18d9a
295 changed files with 9 additions and 5880 deletions
-42
View File
@@ -1,42 +0,0 @@
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