browser

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package browser provides browser automation utilities including URL allowlist enforcement for sandboxed browser plugins.

Index

Constants

This section is empty.

Variables

View Source
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

func NewAllowlist(domains []string) *Allowlist

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

func (a *Allowlist) Allowed(rawURL string) (bool, error)

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.

func (*Allowlist) Domains

func (a *Allowlist) Domains() []string

Domains returns the list of allowed domain patterns.

func (*Allowlist) IsEmpty

func (a *Allowlist) IsEmpty() bool

IsEmpty returns true if the allowlist has no domain restrictions.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL