Detect HTTP-header cookies via CookieStore change event

Progressive enhancement for Chromium browsers: listen on the
CookieStore change event to catch cookies set by Set-Cookie HTTP
response headers, which the document.cookie setter hook cannot see.
Adds a new "http" cookie source through the full stack.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-06 18:54:50 +04:00
parent a4cb61366f
commit c0d0221be1
5 changed files with 81 additions and 2 deletions

View File

@@ -24,12 +24,14 @@ type CookieSource string
const (
CookieSourceScript CookieSource = "SCRIPT"
CookieSourcePreExisting CookieSource = "PRE_EXISTING"
CookieSourceHTTP CookieSource = "HTTP"
)
func CookieSources() []CookieSource {
return []CookieSource{
CookieSourceScript,
CookieSourcePreExisting,
CookieSourceHTTP,
}
}
@@ -53,6 +55,8 @@ func (s *CookieSource) Scan(value any) error {
*s = CookieSourceScript
case CookieSourcePreExisting:
*s = CookieSourcePreExisting
case CookieSourceHTTP:
*s = CookieSourceHTTP
default:
return fmt.Errorf("invalid CookieSource value: %q", v)
}
@@ -62,7 +66,8 @@ func (s *CookieSource) Scan(value any) error {
func (s CookieSource) Value() (driver.Value, error) {
switch s {
case CookieSourceScript,
CookieSourcePreExisting:
CookieSourcePreExisting,
CookieSourceHTTP:
return string(s), nil
default:
return nil, fmt.Errorf("invalid CookieSource: %s", s)