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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user