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 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.
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 ¶
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).