cdp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cdp drives an already-running stealth browser over the Chrome DevTools Protocol to extract and inject browser storage state. It connects through the serve multiplexer's ?fingerprint=<seed> routing via chromedp's RemoteAllocator and never launches Chrome itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Inject

func Inject(ctx context.Context, cdpBase, seed string, st *StorageState) error

Inject writes the storage state into the seed's fresh browser: cookies first (browser-global), then per-origin localStorage on a scratch tab navigated to each origin.

Types

type Cookie struct {
	Name     string  `json:"name"`
	Value    string  `json:"value"`
	Domain   string  `json:"domain"`
	Path     string  `json:"path"`
	Expires  float64 `json:"expires"`
	HTTPOnly bool    `json:"httpOnly"`
	Secure   bool    `json:"secure"`
	SameSite string  `json:"sameSite,omitempty"`
}

Cookie mirrors a Playwright storageState cookie. Expires is seconds since the epoch, or -1 for a session cookie.

type LocalStorageItem

type LocalStorageItem struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

LocalStorageItem is a single localStorage key/value pair.

type Origin

type Origin struct {
	Origin       string             `json:"origin"`
	LocalStorage []LocalStorageItem `json:"localStorage"`
}

Origin is one origin's localStorage in the Playwright storageState shape.

type StorageState

type StorageState struct {
	Cookies []Cookie `json:"cookies"`
	Origins []Origin `json:"origins"`
}

StorageState is the subset of the Playwright storageState JSON shape cuttle checks out and back in: global cookies plus per-origin localStorage. It is small (auth state, not full Chrome-profile fidelity) so it round-trips over CDP between the local canonical copy and an ephemeral remote seed.

func Extract

func Extract(ctx context.Context, cdpBase, seed string, origins []string) (*StorageState, []string, error)

Extract connects to the seed's browser and reads its storage state. Cookies are browser-global; localStorage is origin-scoped, so each origin is visited on a scratch tab (localStorage is only readable from a document of that origin). An origin that fails to load contributes no localStorage rather than failing the whole extract; its origin string is returned in failed so the caller can tell a transient load failure apart from a genuinely-empty origin and preserve the last-known localStorage for the former.

func (*StorageState) OriginURLs

func (s *StorageState) OriginURLs() []string

OriginURLs returns the origin strings the state carries, so a checkin knows which origins to re-read localStorage from.

Jump to

Keyboard shortcuts

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