fix(core): consent expiry, onRevoke callback, domain cookie clearing - #97
Open
DaSchTour wants to merge 3 commits into
Open
fix(core): consent expiry, onRevoke callback, domain cookie clearing#97DaSchTour wants to merge 3 commits into
DaSchTour wants to merge 3 commits into
Conversation
restore() previously restored choices and set _hasConsented whenever the stored revision matched, ignoring isConsentExpired. That meant the banner re-showed after the CNIL-guided re-prompt window, but isAccepted() still returned true — letting ScriptBlocker activate tracking scripts before the user re-consented, defeating the re-prompt. Expired consent now leaves choices empty and hasConsented false, while the pseudonymous subjectId is still carried forward for audit continuity across re-consent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
KeksmeisterConfig.onRevoke was declared but never called, so integrations couldn't react to a category being withdrawn (e.g. to tear down a script/service). Now fired once per category that transitions from accepted to declined via applyChoices() (custom save, accept/reject-all updates), and once per previously-accepted, non-required category in revokeAll(). Not fired on first consent grant or when a category stays accepted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
clearCookies() only deleted cookies with no domain attribute (plus the configured cookieDomain). Third-party scripts commonly scope cookies to a domain attribute (e.g. GA4's `_ga` on `.example.com`), which a bare deletion from `www.example.com` cannot remove. Now also retries deletion across the current hostname and its parent domains down to the 2-label registrable domain. setCookie() gained an optional domain override so this reuses the existing cookie-string logic instead of duplicating it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Bundle ReportChanges will increase total bundle size by 1.09kB (1.49%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: keksmeister-Keksmeister-umdAssets Changed:
Files in
view changes for bundle: keksmeister-Keksmeister-esmAssets Changed:
Files in
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three compliance-related bugfixes in the core consent engine:
1. Expired consent now behaves like no consent (critical).
restore()restoredchoicesand sethasConsented = truewhenever the stored revision matched, ignoringisConsentExpired. Once consent aged past the re-prompt window (consentMaxAgeDays, default 180 days per CNIL guidance), the banner re-showed butisAccepted()still returnedtrue— soScriptBlockerkept tracking scripts unblocked before the user re-consented, defeating the legal purpose of the re-prompt. Expired consent now leaveschoicesempty andhasConsentedfalse; the pseudonymoussubjectIdis still carried forward so re-consent stays linked to the same audit subject.2.
config.onRevokeis now invoked. It was declared inKeksmeisterConfigbut never called anywhere. It now fires once per category that transitions from accepted to declined, both throughapplyChoices()(custom save, accept/reject-all) andrevokeAll()(for every previously accepted, non-required category). It does not fire on first consent grant or when a category stays accepted.3. Auto-clear can now delete domain-scoped cookies.
clearCookies()only attempted deletion without a domain attribute (plus the configuredcookieDomain), which fails for cookies like GA4's_gathat are scoped todomain=.example.com. It now also retries across the current hostname and its parent domains down to the 2-label registrable domain.setCookie()gained an optional domain override parameter so this reuses the existing cookie-string building instead of duplicating it.Test plan
bun run test— 126 tests pass (new tests cover all three fixes)bun run typecheck— cleanbun run build— succeeds🤖 Generated with Claude Code