profile

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 15 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 profile keeps a browser profile's auth state (cookies + per-origin localStorage) canonical on the local machine and checks it in and out of an otherwise-ephemeral remote browser seed over CDP.

A named profile is a cuttle seed. Its storage_state.json lives under $XDG_DATA_HOME/cuttle/profiles/<name>/. On session start the state is injected into the fresh remote seed; during and at the end of the session it is extracted back and written atomically, so a crash loses at most one checkpoint interval of cookie deltas. "Resides locally" is true at rest; a live session necessarily holds the cookies on the remote to act as the user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CandidateOrigins added in v0.7.0

func CandidateOrigins(st *cdp.StorageState) []string

CandidateOrigins is the set of origins a checkin re-reads localStorage from: origins already recorded in the state, plus https origins derived from cookie domains, so a fresh login's localStorage is captured even before its origin is first recorded. localStorage is origin-scoped, so unknown origins cannot be discovered without visiting them. Exported so the serve daemon derives the same origin set when it extracts a seed's state over its own loopback CDP. Nil-safe.

func CarryForward added in v0.7.0

func CarryForward(prior, st *cdp.StorageState, failed []string) *cdp.StorageState

CarryForward re-attaches prior localStorage for origins that failed to load this pass, so an unconditional overwrite never drops persisted state on a transient per-origin blip. It is the in-memory core of carryForwardLocalStorage (which loads prior from disk first); the serve daemon calls it directly with the prior snapshot it already holds. A nil prior carries nothing forward.

func DataDir

func DataDir(name string) string

DataDir is $XDG_DATA_HOME/cuttle/profiles/<name>, falling back to ~/.local/share.

func SaveState added in v0.7.0

func SaveState(name string, st *cdp.StorageState) error

SaveState writes a profile's storage_state.json to its local canonical dir. It is the entry point for the CLI's local-canonical pull (down captures a running seed's state into the local store) and validates the name against the seed grammar (reserved names rejected) so a stray key never lands in the store.

func ValidName

func ValidName(name string) bool

ValidName reports whether name is a legal profile name. A profile name is a cuttle seed, so it shares the seed grammar (fingerprint.ValidSeed).

Types

type Options

type Options struct {
	Name     string        // profile name == seed
	CDPBase  string        // e.g. http://127.0.0.1:9222
	Remote   bool          // storage = "remote": durable remote dir, no checkout/checkin
	Interval time.Duration // checkpoint interval; 0 uses the default
}

Options configures a profile session.

type Session

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

Session is a live checkout of a local-canonical profile into a remote seed. For a remote-persistent profile it is an inert handle (the remote dir is durable, so there is nothing to check out or in).

func Checkout

func Checkout(ctx context.Context, opts Options) (*Session, error)

Checkout starts a session: for a local-canonical profile it takes the single-writer lock, injects the local storage_state into the fresh remote seed, and begins periodic checkpoints. For a remote-persistent profile it returns an inert session. The caller MUST Close the returned session (a deferred Close plus a signal-aware context covers Ctrl-C).

func (*Session) Close

func (s *Session) Close() error

Close checks the session in: it stops the checkpoint loop, performs a final extract+save, and releases the lock. Releasing the lock always happens even if the final save fails, so a crashed browser never wedges the profile. Close is idempotent.

Jump to

Keyboard shortcuts

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