browserauth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package browserauth borrows a live browser session by extracting specific cookies for a domain from the user's installed browsers. It is the reusable "borrow-the-browser-session" primitive (the same shape slackctl uses for xoxc/xoxd): configure an Extractor with a domain and the set of cookie names you need, and Extract returns them plus the source browser/profile they came from. The browser-reading itself is behind a seam, so callers (and tests) can inject cookies without ever touching a real browser store.

This package is deliberately self-contained and org-agnostic — a future cookie-auth CLI can import it and only change Domain / RequiredCookieNames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extractor

type Extractor struct {
	// Domain is the cookie domain suffix to match, e.g. ".linkedin.com".
	Domain string
	// Browsers optionally restricts extraction to these browser names (case-insensitive:
	// "chrome", "brave", "firefox", "chromium", "edge"). Empty means "any browser".
	Browsers []string
	// RequiredCookieNames are the cookies that MUST all be present from a single source for a
	// successful extraction (e.g. []string{"li_at", "JSESSIONID"}).
	RequiredCookieNames []string
	// contains filtered or unexported fields
}

Extractor pulls a required set of cookies for one domain out of the browser stores.

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context) (map[string]string, string, error)

Extract returns the required cookies as a name→value map plus a human-readable source ("chrome (Default)"). It succeeds only when a SINGLE source (one browser+profile) supplies every RequiredCookieName — mixing cookies from two sessions would produce an invalid pair. An error names exactly what was missing so the user knows to log in / pick another browser.

func (*Extractor) WithFinder

func (e *Extractor) WithFinder(f Finder) *Extractor

WithFinder overrides the cookie source (tests inject a fake so they never read a real browser).

type Finder

type Finder func(ctx context.Context, domain string) ([]RawCookie, error)

Finder discovers cookies for a domain across the browsers on this host. It is the seam that isolates kooky: production uses the kooky-backed finder, tests inject a fake.

type RawCookie

type RawCookie struct {
	Name    string
	Value   string
	Browser string // e.g. "chrome", "brave", "firefox"
	Profile string // browser profile, e.g. "Default"
}

RawCookie is one cookie discovered in a browser store.

Jump to

Keyboard shortcuts

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