Documentation
¶
Index ¶
Constants ¶
const DefaultTarget = "127.0.0.1:9222"
DefaultTarget is Chrome's conventional remote-debugging address.
Variables ¶
ErrCDPUnavailable means the Chrome DevTools endpoint could not be reached.
Functions ¶
func ResolveTarget ¶
ResolveTarget normalizes a CDP target string into an HTTP endpoint or a websocket debugger URL. Empty target defaults to 127.0.0.1:9222.
Accepted forms:
- port: "9224"
- host:port: "127.0.0.1:9224"
- http(s) CDP endpoint: "http://127.0.0.1:9224"
- websocket debugger URL: "ws://127.0.0.1:9224/devtools/browser/..."
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal Chrome DevTools Protocol client for Storage.setCookies.
func Connect ¶
Connect dials a CDP target: an HTTP endpoint, whose browser websocket is looked up, or a websocket debugger URL.
func (*Client) Endpoint ¶
Endpoint returns the resolved CDP HTTP endpoint or websocket URL used to connect.
func (*Client) SetCookies ¶
SetCookies injects cookies via Storage.setCookies, falling back to one-by-one when the batch call fails. Returns how many cookies were set successfully. Cookie values are never logged.
type CookieConversion ¶
type CookieConversion struct {
Cookies []CookieParam
Skipped int
}
CookieConversion holds CookieParams ready for CDP and how many were skipped.
func CookiesToParams ¶
func CookiesToParams(stored []auth.StoredCookie) CookieConversion
CookiesToParams converts stored session cookies into CDP CookieParams. Cookies with empty Name or Value are skipped. Cookie values are never logged.
type CookieParam ¶
type CookieParam struct {
Name string `json:"name"`
Value string `json:"value"`
URL string `json:"url,omitempty"`
Domain string `json:"domain,omitempty"`
Path string `json:"path,omitempty"`
Secure bool `json:"secure,omitempty"`
HTTPOnly bool `json:"httpOnly,omitempty"`
Expires *float64 `json:"expires,omitempty"`
SameSite string `json:"sameSite,omitempty"`
}
CookieParam is the CDP Network.CookieParam subset used by Storage.setCookies. Value is included for CDP only and must never be logged or printed.
type SyncResult ¶
type SyncResult struct {
CDP string `json:"cdp"`
Attempted int `json:"attempted"`
Set int `json:"set"`
Skipped int `json:"skipped"`
}
SyncResult is the JSON-safe outcome of syncing cookies into a browser.
func SyncCookies ¶
func SyncCookies(ctx context.Context, sessionFile, target string) (*SyncResult, error)
SyncCookies loads the saved session and injects cookies into Chrome over CDP.