Documentation
¶
Overview ¶
Package sweetcookie loads cookies from local browser profiles (Chrome-family including Arc, Firefox, Safari).
This is intended for local tooling (CLI helpers, dev scripts, test harnesses). It reads local browser state, may trigger keychain/keyring prompts, and should not be used in server contexts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoOrigin = errors.New("sweetcookie: URL or Origins required (or AllowAllHosts)")
ErrNoOrigin is returned when neither URL nor Origins is set and AllowAllHosts is false.
Functions ¶
This section is empty.
Types ¶
type Browser ¶
type Browser string
Browser identifies a cookie source.
const ( // BrowserInline is the inline cookie payload source. BrowserInline Browser = "inline" // BrowserChrome is Google Chrome. BrowserChrome Browser = "chrome" // BrowserChromium is Chromium. BrowserChromium Browser = "chromium" // BrowserEdge is Microsoft Edge. BrowserEdge Browser = "edge" // BrowserBrave is Brave Browser. BrowserBrave Browser = "brave" // BrowserVivaldi is Vivaldi. BrowserVivaldi Browser = "vivaldi" // BrowserOpera is Opera. BrowserOpera Browser = "opera" // BrowserArc is Arc Browser. BrowserArc Browser = "arc" // BrowserFirefox is Mozilla Firefox. BrowserFirefox Browser = "firefox" // BrowserSafari is Apple Safari (macOS only). BrowserSafari Browser = "safari" )
func DefaultBrowsers ¶
func DefaultBrowsers() []Browser
DefaultBrowsers returns a default source preference order.
type Cookie ¶
type Cookie struct {
Name string
Value string
Domain string
Path string
Secure bool
HTTPOnly bool
SameSite SameSite
Expires *time.Time
Source Source
}
Cookie is a browser cookie record.
type InlineCookies ¶
type InlineCookies struct {
// Exactly one of these is expected to be set. If multiple are set, JSON wins over Base64 over File.
JSON []byte
Base64 string
File string
}
InlineCookies is an optional cookie payload source (JSON/base64/file).
type Options ¶
type Options struct {
// URL is used to filter cookies by (scheme, host, path).
// If empty, Origins must be set, or AllowAllHosts must be true.
URL string
// Origins are additional origins to consider (e.g. OAuth redirects).
// If set, they are used for filtering alongside URL.
Origins []string
// Names is an allowlist of cookie names (empty means "all names").
Names []string
// Browsers is a source priority list. If empty, DefaultBrowsers() is used.
Browsers []Browser
// Mode controls how multiple sources are combined.
Mode Mode
// Profile overrides per-browser selection.
// For Chromium-family: profile name (e.g. "Default"), profile dir, or explicit Cookies DB path.
// For Firefox: profile name/dir, or explicit cookies.sqlite path.
// For Safari: explicit Cookies.binarycookies path (macOS only).
Profiles map[Browser]string
// Inline is an optional source that is always tried before browser reads.
Inline InlineCookies
IncludeExpired bool
AllowAllHosts bool
// Timeout for OS helper calls (keychain/keyring).
Timeout time.Duration
Debug bool
}
Options configures cookie loading and filtering.
Click to show internal directories.
Click to hide internal directories.