browser

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 86 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package browser drives a Chromium, Lightpanda, cloud, or attached browser over the Chrome DevTools Protocol

Index

Constants

View Source
const (
	// DefaultBrowserCDPPort is the remote debugging port /browser connect probes and launches on
	DefaultBrowserCDPPort = 9222
	// DefaultBrowserCDPURL is the local CDP endpoint /browser connect uses without an argument
	DefaultBrowserCDPURL = "http://127.0.0.1:9222"
)
View Source
const (
	DialogPolicyMustRespond = "must_respond"
	DialogPolicyAutoDismiss = "auto_dismiss"
	DialogPolicyAutoAccept  = "auto_accept"
)

Dialog policies the supervisor accepts

View Source
const (
	CloseNormal          = 1000
	CloseGoingAway       = 1001
	CloseProtocolError   = 1002
	CloseUnsupportedData = 1003
	CloseMessageTooBig   = 1009
)

Close status codes used by the client

View Source
const InspectionStampAttr = "data-icebath-vault-slot"

Attribute each inspection stamps on every input as nonce and index

View Source
const LightpandaInstallHint = lightpandaInstallHint

Install line the doctor prints when the Lightpanda engine is selected without a binary

View Source
const NativeVisionValueKey = "vision.native"

Env.Values key the agent runtime sets to a bool saying screenshots may ride inside tool results

View Source
const Toolset = "browser"

Toolset every browser tool registers under

View Source
const UnsupportedChannel = "__unsupported_channel__"

Sentinel for a recognized Chromium pre release channel default, distinct from no Chromium default

Variables

View Source
var BrowserPageBackendRegistry = provider.NewProviderRegistry[BrowserPageBackend](provider.ProviderRegistryOptions{
	Label: "Browser page backend", Logger: pkgLog()})

Browser page backends plugins register, consumed by browser_vault before the CDP session

View Source
var BrowserProviderRegistry = provider.NewProviderRegistry[BrowserProvider](provider.ProviderRegistryOptions{Label: "Browser", Logger: pkgLog()})

Cloud browser providers plugins register, consumed by the cloud provider selection

View Source
var ErrCDPClosed = errors.New("CDP connection closed before reply")

ErrCDPClosed reports a command whose connection dropped before its reply

View Source
var HarnessDirKeys = [4]string{"BH_RUNTIME_DIR", "BH_RUNTIME_DIR_SHARED", "BH_TMP_DIR", "BH_TMP_DIR_SHARED"}

Env keys that with BU_NAME identify one harness daemon

Functions

func AtexitCleanup

func AtexitCleanup(ctx context.Context)

Process exit sweep, every session closed and the janitor stopped, which the binary's shutdown path calls

func BeginVaultUnlock

func BeginVaultUnlock(ctx context.Context, backend string) int

Lock generation snapshot taken before spawning the manager CLI, passed to StoreVaultSessionToken

func BrowserCDPSchema

func BrowserCDPSchema() *jsonutil.Object

Static browser_cdp schema

func BrowserCommand

func BrowserCommand(ctx context.Context, env *tools.Env, ns map[string]any, w io.Writer) (int, error)

BrowserCommand runs icebath browser, close-profile ending the browser that holds the real profile

func BrowserDialogSchema

func BrowserDialogSchema() *jsonutil.Object

Static browser_dialog schema

func BrowserExecSchema

func BrowserExecSchema() *jsonutil.Object

Static browser_exec schema, its description tailored per session by the overrides

func BrowserExecSchemaOverrides

func BrowserExecSchemaOverrides(env *tools.Env) *jsonutil.Object

Session tailored description, plus the local parameter only when real profile browsing is consented

func BrowserPageBackendScopedRegistry

func BrowserPageBackendScopedRegistry() plugins.ScopedRegistry

Plugin facing registry that register_browser_page_backend writes into, a plugin host object stored as the backend adapted from it

func BrowserProviderScopedRegistry

func BrowserProviderScopedRegistry() plugins.ScopedRegistry

Plugin facing registry that register_browser_provider writes into, a plugin host object stored as the provider adapted from it

func BrowserVaultSchema

func BrowserVaultSchema() *jsonutil.Object

func BuildFillJS

func BuildFillJS(fills []*jsonutil.Object, expectedOrigin, nonce string) string

Page script that asserts the origin then fills the stamped controls and reports only a count

func BuildInspectionJS

func BuildInspectionJS(nonce string) string

Page script that stamps every input with the nonce and reports the visible controls

func BuildOTPFills

func BuildOTPFills(otpControls []ClassifiedLoginControl, code string) []*jsonutil.Object

One fill per adjacent single character box of one form, else the best field takes the whole code

func CDPOverrideRaw

func CDPOverrideRaw(env *tools.Env) string

Configured CDP override with no network I/O, the live connect then BROWSER_CDP_URL then browser.cdp_url

func CanPromptVaultHere

func CanPromptVaultHere(ctx context.Context, env *tools.Env) bool

False where no human can answer, cron, webhook, api_server and single query sessions

func ChromeDebugDataDir

func ChromeDebugDataDir(ctx context.Context) string

Profile directory of the debug browser under the icebath home

func ChromiumExecutable

func ChromiumExecutable(env *tools.Env, allowOverride bool) string

Chromium binary the launcher would run, the configured override honoured when allowed

func ChromiumMissingHint

func ChromiumMissingHint(env *tools.Env) string

One actionable line for a machine without Chromium that never suggests npm

func ClaimPrivateDir

func ClaimPrivateDir(path string) bool

Creates the dir 0700, or accepts an existing real directory of this uid closed to group and other

func CleanupAllBrowsers

func CleanupAllBrowsers(ctx context.Context, env *tools.Env)

Closes every live browser session so the next tool call picks up the current backend

func CleanupProfileBrowsers

func CleanupProfileBrowsers(ctx context.Context, env *tools.Env, homeKey string) error

Closes one profile home's sessions, supervisors and harness daemons and drops its cached config

func DaemonIdentity

func DaemonIdentity(env map[string]string) [5]string

Harness dir values then BU_NAME of the daemon a call with env drives

func DiscoverLocalCDPURL

func DiscoverLocalCDPURL(ctx context.Context, port int, timeout time.Duration) string

DiscoverLocalCDPURL returns the first loopback URL on the port speaking CDP, empty when none does

func EmergencyCleanupAllSessions

func EmergencyCleanupAllSessions(ctx context.Context)

Closes this process's browser sessions then reaps orphans of crashed processes, once per process

func FindFreeDebugPort

func FindFreeDebugPort(preferred, attempts int) int

First port after preferred bindable on both loopbacks, preferred plus one when none binds

func FindLightpandaBinary

func FindLightpandaBinary(env *tools.Env) string

Lightpanda binary found on PATH or in a known install directory, empty when absent

func FitDefaultSocketDir

func FitDefaultSocketDir(env map[string]string) error

Moves a default runtime dir whose socket for the call's BU_NAME overflows sun_path to a private short dir

func FitsSocketBudget

func FitsSocketBudget(resolvedDir string, budget *int) bool

True when a 64 character session socket under the resolved dir fits the budget, always without one

func GetChromeDebugCandidates

func GetChromeDebugCandidates(system string) []string

Existing debug browser binaries deduplicated by normalized path, first seen kept

func IsBrowserDebugReady

func IsBrowserDebugReady(ctx context.Context, rawURL string, timeout time.Duration) bool

IsBrowserDebugReady reports whether a URL exposes a reachable DevTools endpoint

func IsLoginBackendEnabled

func IsLoginBackendEnabled(ctx context.Context, name string) (bool, error)

An installed manager is a login source unless the profile turned vault.<name>.enabled off

func IsLoginBackendInstalled

func IsLoginBackendInstalled(ctx context.Context, name string) (bool, error)

Whether the manager CLI is reachable, a configured binary_path honoured over PATH

func IsVaultUnlocked

func IsVaultUnlocked(ctx context.Context, backend string) bool

Status probe that leaves the idle timer alone

func LightpandaEngineStatus

func LightpandaEngineStatus(env *tools.Env) (bool, string)

Whether the Lightpanda engine is in effect and the setting shadowing it otherwise

func LiveCDPGeneration

func LiveCDPGeneration(homeKey string) int

LiveCDPGeneration counts the home's live endpoint publishes

func LiveCDPOverride

func LiveCDPOverride(homeKey string) string

LiveCDPOverride is the home's /browser connect endpoint, empty when none is published

func LocalPortInUse

func LocalPortInUse(port int, timeout time.Duration) bool

LocalPortInUse reports whether either loopback accepts TCP on the port

func LockAllVaultProfiles

func LockAllVaultProfiles()

Drops every token of every profile at process shutdown

func LockVault

func LockVault(ctx context.Context, backend *string)

Forgets the current profile's session for one backend, or all of them when backend is nil

func LoginBackendScopedRegistry

func LoginBackendScopedRegistry() plugins.ScopedRegistry

Plugin facing registry that register_login_backend writes into

func ManualChromeDebugCommand

func ManualChromeDebugCommand(ctx context.Context, port int, system string) string

Copy paste command that starts a debug browser, empty when no binary is known

func NamespaceHarnessDirs

func NamespaceHarnessDirs(env map[string]string, tag string) error

Gives a served profile tag its own harness runtime and tmp dirs in the child env, an empty tag changing nothing

func PrivateUserRuntimeDir

func PrivateUserRuntimeDir() string

The user runtime dir when it is an absolute real directory of this uid closed to group and other

func RegisterLoginBackendProvider

func RegisterLoginBackendProvider(ctx context.Context, provider LoginBackend, scope string) error

Registers a plugin backend in a scope, refusing a name another plugin already holds there

func ReleaseVaultSession

func ReleaseVaultSession(sessionID string)

Drops only the tokens the ended gateway session unlocked

func RemoveVaultItem

func RemoveVaultItem(ctx context.Context, handle string) (bool, error)

RemoveVaultItem removes an item of the local vault by handle and reports whether there was one

func ResetLoginBackendRegistryForTests

func ResetLoginBackendRegistryForTests()

Clears every plugin login backend registration, for tests only

func ResolveCDPOverride

func ResolveCDPOverride(ctx context.Context, cdpURL string) string

ResolveCDPOverride normalizes a CDP endpoint into a concrete websocket URL through /json/version discovery

func RunWithSecretEnv

func RunWithSecretEnv(argv []string, env map[string]string, secretEnv, secret string, timeout time.Duration, label string) (provider.CLIResult, error)

Runs a manager CLI that reads the secret from a named variable set on the child environment only

func RunWithStdinSecret

func RunWithStdinSecret(argv []string, env map[string]string, secret string, timeout time.Duration, label string) (provider.CLIResult, error)

Runs a manager CLI feeding the secret on stdin, never argv and never env

func RunningInstance

func RunningInstance(userDataDir string) (int, string, int, bool)

Port, browser path and pid of the live Chromium already serving DevTools on the dir, for other packages

func SelectCheckoutFills

func SelectCheckoutFills(classified []ClassifiedLoginControl, secret map[string]string, fieldTokens *jsonutil.Object) []*jsonutil.Object

Maps a payment or address payload onto the best control per token, a combined expiry replacing month and year

func SelectPasswordFill

func SelectPasswordFill(classified []ClassifiedLoginControl, password string) []*jsonutil.Object

One fill for the best current-password control, empty without a password field or password

func SetLiveCDPOverride

func SetLiveCDPOverride(homeKey, cdpURL string)

SetLiveCDPOverride publishes or with an empty url clears the home's live endpoint and bumps its generation

func SetVaultSource

func SetVaultSource(ctx context.Context, h, name string, on bool) error

SetVaultSource turns a password manager icebath knows on or off for browser logins

func SocketDirBudget

func SocketDirBudget(platform string) *int

Runtime dir byte budget of a sys.platform value where the harness binds AF_UNIX sockets, nil elsewhere

func SocketFitRuntimeDir

func SocketFitRuntimeDir(runtimeDir, base, tag string) (string, error)

The runtime dir as given when its resolved socket path fits, else a private short dir keyed by base and tag

func StaticLoginBackendName

func StaticLoginBackendName(provider any) (string, error)

The backend's name judged before anything else reads it, a ValueError with a fixed message when refused

func StopBrowser

func StopBrowser(ctx context.Context, key string)

Stops the Chromium this process launched or leased under key

func StoreVaultSessionToken

func StoreVaultSessionToken(ctx context.Context, backend, token string, generation *int) bool

Commits an unlock, false and nothing stored when a lock happened since the generation snapshot

func UsingLightpandaEngine

func UsingLightpandaEngine(env *tools.Env) bool

Whether browser.engine selects Lightpanda in the config of env

func VaultCommand

func VaultCommand(ctx context.Context, h string, ns map[string]any, w io.Writer) (code int, err error)

Runs icebath vault, dispatching add, list, rm, sources and key

func VaultSessionToken

func VaultSessionToken(ctx context.Context, backend string) (string, bool)

Token for a real manager call, refreshing the idle timer

Types

type BitwardenLoginBackend

type BitwardenLoginBackend struct {
	LoginBackendDefaults
	// contains filtered or unexported fields
}

Bitwarden Password Manager logins read through the bw CLI

func (*BitwardenLoginBackend) DisplayName

func (*BitwardenLoginBackend) DisplayName() string

func (*BitwardenLoginBackend) GetMeta

func (b *BitwardenLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)

func (*BitwardenLoginBackend) IsUnlocked

func (b *BitwardenLoginBackend) IsUnlocked() bool

func (*BitwardenLoginBackend) ListItems

func (b *BitwardenLoginBackend) ListItems() ([]vault.VaultItemMeta, error)

Login metadata of every type 1 item with a fill target, URIs matched Never left out

func (*BitwardenLoginBackend) Name

func (*BitwardenLoginBackend) Name() string

func (*BitwardenLoginBackend) NeedsUnlock

func (*BitwardenLoginBackend) NeedsUnlock() bool

func (*BitwardenLoginBackend) Prefix

func (*BitwardenLoginBackend) Prefix() string

func (*BitwardenLoginBackend) ResolveOTP

func (b *BitwardenLoginBackend) ResolveOTP(handle string) (string, bool, error)

Current code of the item's TOTP seed, absent when bw reports none

func (*BitwardenLoginBackend) ResolvePassword

func (b *BitwardenLoginBackend) ResolvePassword(handle string) (string, error)

func (*BitwardenLoginBackend) Unlock

func (b *BitwardenLoginBackend) Unlock(masterPassword string) error

Mints a session key through the passwordenv contract, the variable set on the child environment only

type BrowserPageBackend

type BrowserPageBackend interface {
	provider.ProviderBase
	HasPage(taskID string) bool
	Evaluate(taskID, expression string, secret bool) (any, error)
}

A plugin browser owning its pages outside the CDP session whose live page browser_vault evaluates scripts on

type BrowserProvider

type BrowserProvider interface {
	provider.ProviderBase
	IsAvailable(env *tools.Env) bool
	CreateSession(env *tools.Env, taskID string) (map[string]any, error)
	CloseSession(env *tools.Env, sessionID string) bool
	EmergencyCleanup(env *tools.Env, sessionID string)
}

Cloud browser backend selected by browser.cloud_provider, each call reading the profile's secrets through env

type BrowserUseBrowserProvider

type BrowserUseBrowserProvider struct{ CloudBrowserProvider }

Browser Use cloud browser on the user's BROWSER_USE_API_KEY

func (*BrowserUseBrowserProvider) CreateSession

func (p *BrowserUseBrowserProvider) CreateSession(env *tools.Env, taskID string) (map[string]any, error)

Creates a browser, wrapping network errors in the provider's create failure

func (*BrowserUseBrowserProvider) IsAvailable

func (p *BrowserUseBrowserProvider) IsAvailable(env *tools.Env) bool

Availability from the configured BROWSER_USE_API_KEY

type BrowserbaseBrowserProvider

type BrowserbaseBrowserProvider struct{ CloudBrowserProvider }

Browserbase cloud browser with direct BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID only

func (*BrowserbaseBrowserProvider) CreateSession

func (p *BrowserbaseBrowserProvider) CreateSession(env *tools.Env, taskID string) (map[string]any, error)

Creates a session with the configured features, retrying without each paid feature a 402 refuses

type CDPConn

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

CDPConn multiplexes commands and events over one DevTools websocket

func DialCDP

func DialCDP(ctx context.Context, wsURL string, maxMessage int64) (*CDPConn, error)

DialCDP connects to a DevTools websocket URL and starts the reader

func NewCDPConn

func NewCDPConn(ws *WSConn) *CDPConn

NewCDPConn wraps an open websocket and starts dispatching its frames

func (*CDPConn) Alive

func (c *CDPConn) Alive() bool

Alive reports whether the reader still runs

func (*CDPConn) Attach

func (c *CDPConn) Attach(ctx context.Context, targetID string) (string, error)

Attach opens a flattened session on a target and returns its session id

func (*CDPConn) Call

func (c *CDPConn) Call(ctx context.Context, method string, params any, sessionID string) (json.RawMessage, error)

Call sends one command, on the flattened session when given, and waits for its reply

func (*CDPConn) CallInto

func (c *CDPConn) CallInto(ctx context.Context, method string, params any, sessionID string, out any) error

CallInto decodes a command's result into out

func (*CDPConn) CallTimeout

func (c *CDPConn) CallTimeout(method string, params any, sessionID string, timeout time.Duration) (json.RawMessage, error)

CallTimeout runs Call under a fresh deadline

func (*CDPConn) Close

func (c *CDPConn) Close() error

Close ends the connection with a normal close handshake, forcing the socket shut after two seconds

func (*CDPConn) CreateTarget

func (c *CDPConn) CreateTarget(ctx context.Context, url string, background bool) (string, error)

CreateTarget opens a new page target and returns its id

func (*CDPConn) Detach

func (c *CDPConn) Detach(ctx context.Context, sessionID string) error

Detach closes a flattened session

func (*CDPConn) Done

func (c *CDPConn) Done() <-chan struct{}

Done closes once the connection is gone

func (*CDPConn) Err

func (c *CDPConn) Err() error

Err is the reason the connection ended, nil while it runs

func (*CDPConn) OnEvent

func (c *CDPConn) OnEvent(fn func(CDPEvent)) func()

OnEvent registers an event handler and returns its remover

func (*CDPConn) Targets

func (c *CDPConn) Targets(ctx context.Context) ([]TargetInfo, error)

Targets lists the browser's targets

func (*CDPConn) URL

func (c *CDPConn) URL() string

URL returns the websocket endpoint of this connection

type CDPError

type CDPError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

CDPError is a protocol error reply to one command

func (*CDPError) Error

func (e *CDPError) Error() string

type CDPEvent

type CDPEvent struct {
	Method    string
	Params    json.RawMessage
	SessionID string
}

CDPEvent is one protocol event with the flattened session it fired on

type ChromeDebugLaunch

type ChromeDebugLaunch struct {
	Launched bool
	Attempts []*LaunchAttempt
}

ChromeDebugLaunch is whether a debug browser was spawned and the attempts explaining why not

func LaunchChromeDebug

func LaunchChromeDebug(ctx context.Context, port int, system string) ChromeDebugLaunch

Launches a Chromium family browser with remote debugging, trying each candidate until one stays up

func (ChromeDebugLaunch) Hint

func (l ChromeDebugLaunch) Hint() string

Best user facing explanation of a failed or soft launch, empty when none applies

type ClassifiedLoginControl

type ClassifiedLoginControl struct {
	Control LoginControl
	Score   int
	Token   string
}

func ClassifyCheckoutControl

func ClassifyCheckoutControl(control LoginControl) *ClassifiedLoginControl

Classifies one control as a payment or address fill target, password and email inputs never matching by text

func ClassifyLoginControl

func ClassifyLoginControl(control LoginControl) *ClassifiedLoginControl

Classifies one control as a login fill target, nil when it is none

func ClassifyOTPControls

func ClassifyOTPControls(controls []LoginControl) []ClassifiedLoginControl

The controls taking a second factor code in DOM order, autocomplete one-time-code being authoritative

type CloudBrowserProvider

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

Shared REST lifecycle of the bundled cloud browser vendors, one create request and one release request

func (*CloudBrowserProvider) CloseSession

func (p *CloudBrowserProvider) CloseSession(env *tools.Env, sessionID string) bool

Releases a session, false on missing credentials or a failed release, logging each outcome

func (*CloudBrowserProvider) DisplayName

func (p *CloudBrowserProvider) DisplayName() string

func (*CloudBrowserProvider) EmergencyCleanup

func (p *CloudBrowserProvider) EmergencyCleanup(env *tools.Env, sessionID string)

Teardown from exit paths that tolerates missing credentials and network errors

func (*CloudBrowserProvider) GetSetupSchema

func (p *CloudBrowserProvider) GetSetupSchema() map[string]any

Setup picker row, nil hiding the provider from the picker

func (*CloudBrowserProvider) IsAvailable

func (p *CloudBrowserProvider) IsAvailable(env *tools.Env) bool

Available when the vendor config resolves, a raised resolution error propagating as a panic

func (*CloudBrowserProvider) Name

func (p *CloudBrowserProvider) Name() string

type DialogRecord

type DialogRecord struct {
	ID, Type, Message  string
	OpenedAt, ClosedAt float64
	ClosedBy           string
	FrameID            any
}

One dialog that opened and was then handled

type ErrWSClosed

type ErrWSClosed struct {
	Code   int
	Reason string
}

ErrWSClosed reports the peer closed the websocket with its status code and reason

func (*ErrWSClosed) Error

func (e *ErrWSClosed) Error() string

type FirecrawlBrowserProvider

type FirecrawlBrowserProvider struct{ CloudBrowserProvider }

Firecrawl cloud browser on /v2/browser, explicit selection only

func (*FirecrawlBrowserProvider) CreateSession

func (p *FirecrawlBrowserProvider) CreateSession(env *tools.Env, taskID string) (map[string]any, error)

Creates a browser that lives for browser.firecrawl.ttl seconds

type FrameInfo

type FrameInfo struct {
	FrameID, URL, Origin string
	ParentFrameID        string
	IsOOPIF              bool
	CDPSessionID         string
	Name                 string
}

One frame of the page's frame tree, out of process frames carrying their own session

type LaunchAttempt

type LaunchAttempt struct {
	Binary, State string
	ReturnCode    *int
	StderrTail    string
}

LaunchAttempt is the outcome of one candidate binary launch

type LaunchOptions

type LaunchOptions struct {
	Executable    string
	UserDataDir   string
	Ephemeral     bool
	Headed        *bool
	ExtraArgs     []string
	ProcEnv       map[string]string
	Timeout       *time.Duration
	SandboxBypass bool
	Prepare       func() string
	// The copy of the user's own browser profile, which keeps its browser sign in
	UserProfile bool
}

What a launch starts or attaches, a zero Executable resolving the packaged Chromium

type LaunchedBrowser

type LaunchedBrowser struct {
	Key         string
	PID         *int64
	StartTime   *int64
	CDPURL      string
	HTTPURL     string
	UserDataDir string
	Owned       bool
	Ephemeral   bool
	HomeKey     string
	// Launch record file name its leases are keyed by when this process did not name it
	RecordName string
	// Held from another PID namespace so the pid is never signalled and liveness is its DevTools endpoint
	Foreign bool
}

A Chromium this process launched or attached to on a shared profile

func LaunchChromium

func LaunchChromium(ctx context.Context, env *tools.Env, key string, opts LaunchOptions) (*LaunchedBrowser, string)

Launches or attaches the Chromium for key, returning it or the launch error text

type LightpandaServer

type LightpandaServer struct {
	SessionName string
	Port        int

	LogPath   string
	StartTime *int64
	// contains filtered or unexported fields
}

One lightpanda serve per browser session, its CDP discovery URL on a loopback port

func (*LightpandaServer) CDPURL

func (s *LightpandaServer) CDPURL() string

HTTP discovery URL, the harness resolves json/version itself

func (*LightpandaServer) IsAlive

func (s *LightpandaServer) IsAlive() bool

type LocalLoginBackend

type LocalLoginBackend struct {
	LoginBackendDefaults
	// contains filtered or unexported fields
}

The always on local Fernet vault as a login backend

func NewLocalLoginBackend

func NewLocalLoginBackend(ctx context.Context) *LocalLoginBackend

Local backend reading the vault store of the ctx home

func (*LocalLoginBackend) DisplayName

func (*LocalLoginBackend) DisplayName() string

func (*LocalLoginBackend) GetMeta

func (b *LocalLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)

func (*LocalLoginBackend) ListItems

func (b *LocalLoginBackend) ListItems() ([]vault.VaultItemMeta, error)

func (*LocalLoginBackend) Name

func (*LocalLoginBackend) Name() string

func (*LocalLoginBackend) Prefix

func (*LocalLoginBackend) Prefix() string

func (*LocalLoginBackend) ResolveOTP

func (b *LocalLoginBackend) ResolveOTP(handle string) (string, bool, error)

Current code of a login storing a TOTP seed, absent without a seed

func (*LocalLoginBackend) ResolvePassword

func (b *LocalLoginBackend) ResolvePassword(handle string) (string, error)

func (*LocalLoginBackend) ResolveSecret

func (b *LocalLoginBackend) ResolveSecret(handle string) (map[string]string, error)

Every field of the item payload as text

type LoginBackend

type LoginBackend interface {
	Name() string
	DisplayName() string
	Prefix() string
	NeedsUnlock() bool
	Owns(handle string) bool
	IsUnlocked() bool
	// Profile exclusive section entered after the origin pre check, the returned function leaving it
	FillContext() (func() error, error)
	ListItems() ([]vault.VaultItemMeta, error)
	GetMeta(handle string) (*vault.VaultItemMeta, error)
	ResolvePassword(handle string) (string, error)
	ResolveOTP(handle string) (string, bool, error)
	ResolveSecret(handle string) (map[string]string, error)
}

Login source of the browser credential vault, listing metadata and resolving one secret at fill time

func EnabledLoginBackends

func EnabledLoginBackends(ctx context.Context) ([]LoginBackend, error)

Local first, then every detected external manager the user has not turned off, then the enabled plugin backends

func EnabledPluginLoginBackends

func EnabledPluginLoginBackends(ctx context.Context) []LoginBackend

Registered backends the profile turned on with vault.<name>.enabled true, wrapped for the vault tool

func LoginBackendForHandle

func LoginBackendForHandle(ctx context.Context, handle string) (LoginBackend, error)

The enabled backend whose namespace a handle carries, nil when none owns it

func LoginBackendProvider

func LoginBackendProvider(ctx context.Context, name, scope string) LoginBackend

Backend registered under the name in the scope, nil when none is

func NewBitwardenLoginBackend

func NewBitwardenLoginBackend(ctx context.Context, cfg ManagerConfig) LoginBackend

Bitwarden backend of its settings

func NewOnePasswordLoginBackend

func NewOnePasswordLoginBackend(ctx context.Context, cfg ManagerConfig) LoginBackend

1Password backend of its settings, a configured service account token skipping the prompt

type LoginBackendDefaults

type LoginBackendDefaults struct{ Self LoginBackend }

Contract defaults a concrete backend embeds with Self bound to itself

func (LoginBackendDefaults) FillContext

func (LoginBackendDefaults) FillContext() (func() error, error)

No profile exclusive section around a fill, reported as a nil release

func (LoginBackendDefaults) IsUnlocked

func (LoginBackendDefaults) IsUnlocked() bool

Always unlocked unless overridden

func (LoginBackendDefaults) NeedsUnlock

func (LoginBackendDefaults) NeedsUnlock() bool

No master password prompt unless overridden

func (LoginBackendDefaults) Owns

func (d LoginBackendDefaults) Owns(handle string) bool

A handle belongs to the backend whose prefix it carries

func (LoginBackendDefaults) ResolveOTP

func (LoginBackendDefaults) ResolveOTP(string) (string, bool, error)

No one time code, the user is asked

func (LoginBackendDefaults) ResolveSecret

func (d LoginBackendDefaults) ResolveSecret(handle string) (map[string]string, error)

Password only payload, the shape external managers resolve

type LoginControl

type LoginControl struct {
	Autocomplete string
	FormIndex    *int
	Index        int
	Label        string
	Name         string
	Type         string
	MaxLength    *int
}

Descriptor of a visible input control as inspected in the page

func LoginControlFromDict

func LoginControlFromDict(raw *jsonutil.Object) (LoginControl, error)

Control built from the inspection script's record, either key spelling accepted

type ManagerConfig

type ManagerConfig struct {
	// Full path of the manager's command-line tool, empty finding it on the search path
	BinaryPath string
	// 1Password account, empty for the default one
	Account string
	// Environment variable holding the 1Password service account token
	ServiceAccountTokenEnv string
}

Settings of one external password manager, read from its vault.<name> settings

type OnePasswordLoginBackend

type OnePasswordLoginBackend struct {
	LoginBackendDefaults
	// contains filtered or unexported fields
}

1Password Login items read through the op CLI

func (*OnePasswordLoginBackend) DisplayName

func (*OnePasswordLoginBackend) DisplayName() string

func (*OnePasswordLoginBackend) GetMeta

func (b *OnePasswordLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)

func (*OnePasswordLoginBackend) IsUnlocked

func (b *OnePasswordLoginBackend) IsUnlocked() bool

func (*OnePasswordLoginBackend) ListItems

func (b *OnePasswordLoginBackend) ListItems() ([]vault.VaultItemMeta, error)

Login metadata of every item with a usable origin, remembering each item's vault for later reads

func (*OnePasswordLoginBackend) Name

func (*OnePasswordLoginBackend) NeedsUnlock

func (*OnePasswordLoginBackend) NeedsUnlock() bool

func (*OnePasswordLoginBackend) Prefix

func (*OnePasswordLoginBackend) Prefix() string

func (*OnePasswordLoginBackend) ResolveOTP

func (b *OnePasswordLoginBackend) ResolveOTP(handle string) (string, bool, error)

Current code of the item's one time password field, absent when op reports none

func (*OnePasswordLoginBackend) ResolvePassword

func (b *OnePasswordLoginBackend) ResolvePassword(handle string) (string, error)

func (*OnePasswordLoginBackend) Unlock

func (b *OnePasswordLoginBackend) Unlock(masterPassword string) error

Mints a session token from the master password consumed on stdin

type PendingDialog

type PendingDialog struct {
	ID, Type, Message, DefaultPrompt string
	OpenedAt                         float64
	CDPSessionID                     string
	FrameID                          any
	BridgeRequestID                  string
}

One JS dialog currently open on some frame's session

type PluginBackendError

type PluginBackendError struct{ Msg string }

A plugin login backend failed or broke its contract, the fixed text never carrying the plugin's own message

func (*PluginBackendError) Error

func (e *PluginBackendError) Error() string

type PluginLoginBackend

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

Core owned wrapper around a plugin registered login backend, the only form the vault tool ever sees

func NewPluginLoginBackend

func NewPluginLoginBackend(name string, plugin LoginBackend) *PluginLoginBackend

Wrapper whose namespace is the registry key, never an attribute the plugin can change later

func (*PluginLoginBackend) DisplayName

func (b *PluginLoginBackend) DisplayName() string

func (*PluginLoginBackend) FillContext

func (b *PluginLoginBackend) FillContext() (func() error, error)

The plugin's own section around one of its fills, its exit guarded like every other plugin call

func (*PluginLoginBackend) GetMeta

func (b *PluginLoginBackend) GetMeta(handle string) (*vault.VaultItemMeta, error)

Validated copy of one item, nil outside the namespace or when the plugin reports another id

func (*PluginLoginBackend) IsUnlocked

func (b *PluginLoginBackend) IsUnlocked() bool

func (*PluginLoginBackend) ListItems

func (b *PluginLoginBackend) ListItems() ([]vault.VaultItemMeta, error)

Validated copies of the plugin's items restricted to its own namespace

func (*PluginLoginBackend) Name

func (b *PluginLoginBackend) Name() string

func (*PluginLoginBackend) NeedsUnlock

func (b *PluginLoginBackend) NeedsUnlock() bool

func (*PluginLoginBackend) Owns

func (b *PluginLoginBackend) Owns(handle string) bool

Ownership decided here, so the plugin's own Owns is never consulted

func (*PluginLoginBackend) Prefix

func (b *PluginLoginBackend) Prefix() string

func (*PluginLoginBackend) ResolveOTP

func (b *PluginLoginBackend) ResolveOTP(handle string) (string, bool, error)

func (*PluginLoginBackend) ResolvePassword

func (b *PluginLoginBackend) ResolvePassword(handle string) (string, error)

func (*PluginLoginBackend) ResolveSecret

func (b *PluginLoginBackend) ResolveSecret(handle string) (map[string]string, error)

Copied payload of the plugin, a nil mapping reading as an invalid value

type SupervisorSnapshot

type SupervisorSnapshot struct {
	PendingDialogs []PendingDialog
	RecentDialogs  []DialogRecord
	FrameTree      *jsonutil.Object
	Active         bool
	CDPURL, TaskID string
	// contains filtered or unexported fields
}

Read only view of supervisor state for tool handlers

func (SupervisorSnapshot) ToDict

func (s SupervisorSnapshot) ToDict() *jsonutil.Object

Serialized snapshot for tool output, recent dialogs only when any exist

type TargetInfo

type TargetInfo struct {
	TargetID string `json:"targetId"`
	Type     string `json:"type"`
	Title    string `json:"title"`
	URL      string `json:"url"`
	Attached bool   `json:"attached"`
	OpenerID string `json:"openerId,omitempty"`
}

TargetInfo is one entry of Target.getTargets

type UnlockRequired

type UnlockRequired struct{ Backend LoginBackend }

The backend is locked for this session, so the surface must prompt for the master password

func (*UnlockRequired) Error

func (e *UnlockRequired) Error() string

type VaultFieldView

type VaultFieldView struct {
	Key              string
	Required, Secret bool
	// Only values the field takes, empty for free text
	Choices []string
}

VaultFieldView is one field of an item of a kind besides its label and site

func VaultKindFields

func VaultKindFields(kind string) []VaultFieldView

VaultKindFields is the fields of an item of a kind in the order they are asked, nil for an unknown kind

type VaultItemView

type VaultItemView struct {
	Handle, Source, Kind, Label, Identifier, Origin string
	// Kept in the vault of this profile, so it can be removed here
	Local bool
}

VaultItemView is one item the agent may fill in, never its secret

func AddVaultItem

func AddVaultItem(ctx context.Context, kind, label, origin string, values map[string]string) (VaultItemView, error)

AddVaultItem stores a login, card or address in the local vault from its values by field

func VaultItems

func VaultItems(ctx context.Context) ([]VaultItemView, []string, error)

VaultItems is every item the agent may fill in and the password managers that are locked

type VaultKeyView

type VaultKeyView struct {
	// file, keychain, or none while no item was saved yet
	Storage                string
	Path, Service, Account string
	// Where the key of a new vault goes, file or keychain
	Configured string
	// Keychain of this computer
	Keychain string
	// Keychain copy that a move back to the file could not remove yet
	KeychainLeft string
}

VaultKeyView is where the key of the local vault lives

func MoveVaultKey

func MoveVaultKey(ctx context.Context, h, target string) (VaultKeyView, error)

MoveVaultKey moves the vault key to the keychain or back to its file

func VaultKey

func VaultKey(ctx context.Context, h string) (VaultKeyView, error)

VaultKey is where the key of the local vault lives

type VaultSourceView

type VaultSourceView struct{ Name, DisplayName, State string }

VaultSourceView is one password manager and whether the agent uses it: on, off or missing

func VaultSources

func VaultSources(ctx context.Context) ([]VaultSourceView, error)

VaultSources is every password manager icebath knows and whether the agent uses it

type WSConn

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

WSConn is one RFC 6455 client connection with reassembly, ping replies, and close handshake

func DialWS

func DialWS(ctx context.Context, rawURL string, opts WSOptions) (*WSConn, error)

DialWS performs the opening handshake against a ws or wss URL, tunnelling through an environment proxy for non loopback hosts

func (*WSConn) Close

func (c *WSConn) Close(code int, reason string) error

Close sends a close frame, waits briefly for the peer's close, and shuts the socket

func (*WSConn) ForceClose

func (c *WSConn) ForceClose()

ForceClose drops the socket without a close handshake

func (*WSConn) Ping

func (c *WSConn) Ping(ctx context.Context, payload []byte) error

Ping sends a ping control frame with an optional payload

func (*WSConn) ReadMessage

func (c *WSConn) ReadMessage(ctx context.Context) (byte, []byte, error)

ReadMessage returns the next complete text or binary message, answering pings and completing a close handshake meanwhile

func (*WSConn) SendClose

func (c *WSConn) SendClose(code int, reason string) error

SendClose writes a close frame and leaves the peer's reply to whoever reads the connection

func (*WSConn) URL

func (c *WSConn) URL() string

URL returns the endpoint this connection was dialed with

func (*WSConn) WriteBinary

func (c *WSConn) WriteBinary(ctx context.Context, payload []byte) error

WriteBinary sends one unfragmented masked binary frame

func (*WSConn) WriteText

func (c *WSConn) WriteText(ctx context.Context, payload []byte) error

WriteText sends one unfragmented masked text frame

type WSOptions

type WSOptions struct {
	// Zero means no limit on an assembled message
	MaxMessageSize int64
	// Zero means a 10 second handshake deadline
	HandshakeTimeout time.Duration
	Header           http.Header
	TLS              *tls.Config
}

WSOptions tunes a websocket dial

Directories

Path Synopsis
Package quiet keeps the Chromium icebath starts for the agent from calling Google services on its own
Package quiet keeps the Chromium icebath starts for the agent from calling Google services on its own

Jump to

Keyboard shortcuts

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