Documentation
¶
Overview ¶
Package browser provides browser automation utilities including URL allowlist enforcement for sandboxed browser plugins.
Index ¶
- Variables
- type Allowlist
- type ProfileInfo
- type ProfileService
- func (ps *ProfileService) BaseDir() string
- func (ps *ProfileService) Clear(_ context.Context, agent string) error
- func (ps *ProfileService) Delete(_ context.Context, agent string) error
- func (ps *ProfileService) Info(_ context.Context, agent string) (*ProfileInfo, error)
- func (ps *ProfileService) List(_ context.Context) ([]ProfileInfo, error)
Constants ¶
This section is empty.
Variables ¶
var ErrProfileNotFound = errors.New("browser: profile not found")
ErrProfileNotFound is returned when a requested agent profile directory does not exist.
Functions ¶
This section is empty.
Types ¶
type Allowlist ¶
type Allowlist struct {
// contains filtered or unexported fields
}
Allowlist enforces domain restrictions on browser navigation. A nil or empty Allowlist permits all domains (except blocked ranges).
func NewAllowlist ¶
NewAllowlist creates an Allowlist from a list of domain patterns. Supports exact matches ("github.com") and wildcard subdomains ("*.example.com"). An empty list means unrestricted (all non-blocked domains are allowed).
func (*Allowlist) Allowed ¶
Allowed checks whether a URL is permitted by the allowlist. Returns false if the URL's host matches a blocked range (link-local, metadata endpoints) regardless of the allowlist. If the allowlist is empty, all non-blocked URLs are allowed.
type ProfileInfo ¶ added in v0.8.0
type ProfileInfo struct {
Agent string `json:"agent"`
SizeBytes int64 `json:"size_bytes"`
DomainCount int `json:"domain_count"`
Domains []string `json:"domains,omitempty"`
LastUsed time.Time `json:"last_used"`
}
ProfileInfo describes a single agent's browser profile on disk.
type ProfileService ¶ added in v0.8.0
type ProfileService struct {
// contains filtered or unexported fields
}
ProfileService provides read and mutation operations on per-agent browser profile directories stored under a shared base directory.
func NewProfileService ¶ added in v0.8.0
func NewProfileService(baseDir string, logger *slog.Logger) *ProfileService
NewProfileService creates a ProfileService rooted at baseDir. baseDir must be an absolute path.
func (*ProfileService) BaseDir ¶ added in v0.8.0
func (ps *ProfileService) BaseDir() string
BaseDir returns the base directory containing all agent profiles.
func (*ProfileService) Clear ¶ added in v0.8.0
func (ps *ProfileService) Clear(_ context.Context, agent string) error
Clear removes all files inside an agent's profile directory but keeps the directory itself so the browser container can immediately reuse it.
func (*ProfileService) Delete ¶ added in v0.8.0
func (ps *ProfileService) Delete(_ context.Context, agent string) error
Delete removes an agent's profile directory entirely.
func (*ProfileService) Info ¶ added in v0.8.0
func (ps *ProfileService) Info(_ context.Context, agent string) (*ProfileInfo, error)
Info returns detailed information about a specific agent's browser profile.
func (*ProfileService) List ¶ added in v0.8.0
func (ps *ProfileService) List(_ context.Context) ([]ProfileInfo, error)
List returns profile info for every agent that has a profile directory.