browser

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrowserSession

type BrowserSession struct {
	SessionID uuid.UUID
	CreatedAt time.Time
	LastUsed  time.Time
	PageCount int
}

BrowserSession tracks browser state for a session

type ExtractOpts

type ExtractOpts struct {
	Selector string // CSS selector (empty = entire page)
	Extract  string // "text", "html", "attributes"
}

ExtractOpts configures content extraction

type Manager

type Manager interface {
	// Navigate to a URL
	Navigate(ctx context.Context, sessionID uuid.UUID, url string, opts NavigateOpts) error

	// Take a screenshot
	Screenshot(ctx context.Context, sessionID uuid.UUID, opts ScreenshotOpts) (*ScreenshotResult, error)

	// Click an element
	Click(ctx context.Context, sessionID uuid.UUID, selector string) error

	// Fill an input field
	Fill(ctx context.Context, sessionID uuid.UUID, selector, value string) error

	// Extract content from the page
	Extract(ctx context.Context, sessionID uuid.UUID, opts ExtractOpts) (string, error)

	// Evaluate JavaScript
	Evaluate(ctx context.Context, sessionID uuid.UUID, script string) (interface{}, error)

	// Wait for an element or condition
	Wait(ctx context.Context, sessionID uuid.UUID, opts WaitOpts) error

	// Generate a PDF
	PDF(ctx context.Context, sessionID uuid.UUID, opts PDFOpts) (*PDFResult, error)

	// Close browser resources for a session
	Close(ctx context.Context, sessionID uuid.UUID) error
}

Manager provides browser automation capabilities for VaultRun sessions

func New

func New(docker *dockerpkg.Client, db *sqlx.DB, storage artifacts.Store) Manager

New creates a new browser manager

type NavigateOpts struct {
	WaitUntil string // "load", "domcontentloaded", "networkidle"
	Timeout   int    // milliseconds
}

NavigateOpts configures navigation behavior

type NetworkPolicy

type NetworkPolicy struct {
	AllowedHosts    []string
	BlockPrivateIPs bool
	BlockLocalhost  bool
	BlockMetadata   bool // Block cloud metadata endpoints (169.254.169.254, etc.)
}

NetworkPolicy defines allowed/blocked URLs for browser navigation

func DefaultNetworkPolicy

func DefaultNetworkPolicy() *NetworkPolicy

DefaultNetworkPolicy returns a secure default policy

type PDFOpts

type PDFOpts struct {
	Format string // "A4", "Letter"
	Path   string // Output path (optional)
}

PDFOpts configures PDF generation

type PDFResult

type PDFResult struct {
	ArtifactID uuid.UUID
	Path       string
	SizeBytes  int64
}

PDFResult contains PDF artifact info

type PlaywrightManager

type PlaywrightManager struct {
	// contains filtered or unexported fields
}

PlaywrightManager implements Manager using Playwright via Docker exec

func (*PlaywrightManager) Click

func (m *PlaywrightManager) Click(ctx context.Context, sessionID uuid.UUID, selector string) error

Click clicks an element

func (*PlaywrightManager) Close

func (m *PlaywrightManager) Close(ctx context.Context, sessionID uuid.UUID) error

Close closes browser resources

func (*PlaywrightManager) Evaluate

func (m *PlaywrightManager) Evaluate(ctx context.Context, sessionID uuid.UUID, jsScript string) (interface{}, error)

Evaluate runs JavaScript in the browser

func (*PlaywrightManager) Extract

func (m *PlaywrightManager) Extract(ctx context.Context, sessionID uuid.UUID, opts ExtractOpts) (string, error)

Extract extracts content from the page

func (*PlaywrightManager) Fill

func (m *PlaywrightManager) Fill(ctx context.Context, sessionID uuid.UUID, selector, value string) error

Fill fills an input field

func (*PlaywrightManager) Navigate

func (m *PlaywrightManager) Navigate(ctx context.Context, sessionID uuid.UUID, targetURL string, opts NavigateOpts) error

Navigate navigates to a URL

func (*PlaywrightManager) PDF

func (m *PlaywrightManager) PDF(ctx context.Context, sessionID uuid.UUID, opts PDFOpts) (*PDFResult, error)

PDF generates a PDF of the current page

func (*PlaywrightManager) Screenshot

func (m *PlaywrightManager) Screenshot(ctx context.Context, sessionID uuid.UUID, opts ScreenshotOpts) (*ScreenshotResult, error)

Screenshot captures a screenshot

func (*PlaywrightManager) Wait

func (m *PlaywrightManager) Wait(ctx context.Context, sessionID uuid.UUID, opts WaitOpts) error

Wait waits for an element or timeout

type ScreenshotOpts

type ScreenshotOpts struct {
	FullPage bool   // Capture entire page (not just viewport)
	Selector string // Screenshot specific element only
	Format   string // "png" or "jpeg"
}

ScreenshotOpts configures screenshot capture

type ScreenshotResult

type ScreenshotResult struct {
	ArtifactID uuid.UUID
	Path       string
	SizeBytes  int64
	Format     string
}

ScreenshotResult contains screenshot artifact info

type WaitOpts

type WaitOpts struct {
	Selector string // Wait for element to appear
	Timeout  int    // milliseconds
}

WaitOpts configures wait conditions

Jump to

Keyboard shortcuts

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