browserx

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 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 browserx shows a sign-in page in a browser window and reads the address the sign-in ends on. Some logins (a VPN's SAML sign-in) end by opening an address only the vendor's own program understands, such as globalprotectcallback:...; a normal browser drops it. komando starts a Chromium-family browser that is already on the computer, with an empty temporary profile, and watches it over the DevTools pipe (two file descriptors, no network port) until that address shows up.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("the sign-in window was closed before the sign-in finished")

ErrClosed: the person closed the window before the sign-in ended.

Functions

func Find

func Find() string

Find returns a Chromium-family browser on this computer, "" when there is none (Safari and Firefox cannot be watched this way) or when komando cannot watch one here (Windows, see canWatch).

func SignIn

func SignIn(ctx context.Context, exe string, page Page, prefix string, accept func(string) bool) (string, error)

SignIn is one sign-in in a browser of its own: Open, SignIn, Close.

Types

type Browser

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

Browser is a browser window komando opened for sign-ins. One Browser can show several sign-ins in a row: what the first one left (the sign-in service's own session) lets the next one pass without typing.

func Open

func Open(exe string) (*Browser, error)

Open starts the browser exe with a temporary profile, which shares nothing with the person's own browser. Close removes it.

func (*Browser) Close

func (w *Browser) Close()

Close closes the window and removes the profile.

func (*Browser) SignIn

func (w *Browser) SignIn(ctx context.Context, page Page, prefix string, accept func(string) bool) (string, error)

SignIn shows page and returns the first address starting with prefix that the sign-in opens, redirects to or links to, and that accept takes (nil takes any). A sign-in page may name the prefix alone in a script, long before the sign-in ends; accept tells such text from the real answer. When the window is closed and only refused addresses were seen, the longest of them is returned, so the caller can say what was wrong with it. What an earlier SignIn's last page still says is not taken for this one's answer.

type Page

type Page struct{ URL, HTML string }

Page is where the sign-in starts: an address, or a page to show.

type Stopped

type Stopped struct {
	Err error
	At  string
}

Stopped is a sign-in that did not finish: the window was closed (ErrClosed) or the time ran out. At says where it stood: the site and title of the page, which helps the person see what it waited for.

func (*Stopped) Error

func (e *Stopped) Error() string

func (*Stopped) Unwrap

func (e *Stopped) Unwrap() error

Jump to

Keyboard shortcuts

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