Skip to content

Commit b26dc92

Browse files
Fix wildcard cookie domain for multi-label public suffixes (2.4.1)
The previous slice(-2) heuristic in detectWildcardAndRoot truncated domains with multi-label public suffixes (e.g. .org.uk, .co.uk, .com.au) to the suffix itself, which browsers reject - leaving the cookie host-only. Use the full domain captured after the wildcard so the integrator's wildcard placement defines the cookie scope. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 07c75da commit b26dc92

12 files changed

Lines changed: 47 additions & 43 deletions

dist/crowdhandler.cjs.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.esm.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.umd.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.umd.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gatekeeper/gatekeeper.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,15 @@ var Gatekeeper = /** @class */ (function () {
774774
(0, logger_1.logger)(this.options.debug, "info", "Domain has trailing wildcard, cannot use root domain cookie");
775775
return { isWildcard: false };
776776
}
777-
// Extract root domain (last two parts for cookie domain)
778-
var parts = domainPart.split('.');
779-
var rootDomain = parts.length >= 2
780-
? ".".concat(parts.slice(-2).join('.'))
781-
: ".".concat(domainPart);
777+
// Use the full domain captured after the wildcard. The integrator's
778+
// wildcard placement defines the cookie scope: e.g. *.barbican.org.uk
779+
// → .barbican.org.uk, *.example.com → .example.com. Avoid heuristics
780+
// like "last two labels", which mis-handle multi-label public suffixes
781+
// (.co.uk, .org.uk, .com.au) and would scope the cookie to a public
782+
// suffix the browser then rejects.
782783
return {
783784
isWildcard: true,
784-
rootDomain: rootDomain
785+
rootDomain: ".".concat(domainPart)
785786
};
786787
};
787788
/**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)