camoufoxnative

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 32 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

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthenticationRequired = errors.New("隔离登录态失效")

ErrAuthenticationRequired 表示隔离账户需要恢复登录

Functions

func AccountFingerprint added in v0.2.0

func AccountFingerprint(options Options) (map[string]any, error)

AccountFingerprint 返回账户固定 Camoufox 指纹配置,不存在时按当前版本生成并保存

func FindExecutable

func FindExecutable(ctx context.Context) (string, error)

FindExecutable 定位源码环境或 Release 自带的 Camoufox

func PersistAccountFingerprint

func PersistAccountFingerprint(sourceDirectory string, targetDirectory string) error

PersistAccountFingerprint 将隔离登录指纹保存到账户目录

func RemoveStaleProfiles added in v0.1.7

func RemoveStaleProfiles() (int, error)

RemoveStaleProfiles 删除创建进程已退出的临时 profile 并返回删除数量

Types

type LoginOptions

type LoginOptions struct {
	ExecutablePath string
	Directory      string
	Locale         string
	Timezone       string
	Proxy          string
	ProxyBypass    string
	Timeout        time.Duration
	Log            io.Writer
}

LoginOptions 定义纯 Go 隔离登录环境

type LoginResult

type LoginResult struct {
	StorageStateJSON []byte
	Email            string
	PageURL          string
	VerifiedAt       time.Time
	DriveError       string
}

LoginResult 返回隔离浏览器导出的 Playwright storage state

func Login

func Login(ctx context.Context, options LoginOptions) (result LoginResult, err error)

Login 启动可见隔离 Camoufox 并在 AI Studio 可用后导出认证状态

type LoginVerification

type LoginVerification struct {
	Authenticated bool
	PageURL       string
	VerifiedAt    time.Time
	Reason        string
}

LoginVerification 返回已有登录态的页面验证结果

func Verify

func Verify(ctx context.Context, options LoginOptions, storageStateJSON []byte) (verification LoginVerification, err error)

Verify 使用无头隔离 Camoufox 验证已有 Playwright storage state

type Options

type Options struct {
	ExecutablePath   string
	StorageStatePath string
	Model            string
	BootstrapPrompt  string
	Locale           string
	Timezone         string
	Proxy            string
	ProxyBypass      string
	Headless         bool
	TemporaryChat    bool
	CacheDirectory   string
	ReadyTimeout     time.Duration
	Log              io.Writer
	StartupProgress  func(StartupStage)
}

Options 定义单个 AI Studio 账户的原生 Camoufox runtime

type ProtectedResponse

type ProtectedResponse struct {
	StatusCode int
	Header     http.Header
	Body       io.ReadCloser
}

ProtectedResponse 表示由固定指纹浏览器流式返回的 MakerSuite 响应

type StartupStage

type StartupStage string

StartupStage 表示 Camoufox runtime 的启动阶段

const (
	// StartupPreparingBrowser 表示正在准备浏览器配置
	StartupPreparingBrowser StartupStage = "preparing_browser"
	// StartupLaunchingBrowser 表示正在启动浏览器进程
	StartupLaunchingBrowser StartupStage = "launching_browser"
	// StartupConnectingBiDi 表示正在连接 WebDriver BiDi
	StartupConnectingBiDi StartupStage = "connecting_bidi"
	// StartupLoadingAIStudio 表示正在载入 AI Studio 页面
	StartupLoadingAIStudio StartupStage = "loading_ai_studio"
	// StartupLocatingWAA 表示正在定位 WAA 服务
	StartupLocatingWAA StartupStage = "locating_waa"
	// StartupBootstrappingWAA 表示正在执行 WAA Bootstrap
	StartupBootstrappingWAA StartupStage = "bootstrapping_waa"
)

type State

type State struct {
	PID         int
	PageURL     string
	UserAgent   string
	Platform    string
	Timezone    string
	SnapshotKey string
	Headers     http.Header
}

State 返回原生 runtime 的当前页面与 bootstrap 结果

type Worker

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

Worker 保存单个账户的长驻 Camoufox 与 WAA service

func Start

func Start(ctx context.Context, options Options) (*Worker, error)

Start 启动隔离 Camoufox 并完成一次官网 WAA bootstrap

func (*Worker) Close

func (worker *Worker) Close() error

Close 结束 BiDi session 并清理 Camoufox profile

func (*Worker) Proof

func (worker *Worker) Proof(ctx context.Context, digest string, prompt string) (string, error)

Proof 同步官网 prompt 状态后为 SHA-256 digest 生成 fresh WAA proof

func (*Worker) ProtocolHeaders

func (worker *Worker) ProtocolHeaders(ctx context.Context) (http.Header, error)

ProtocolHeaders 返回官网为 GenerateContent 构造的六个公共头

func (*Worker) SendProtected

func (worker *Worker) SendProtected(ctx context.Context, rawURL string, headers http.Header, body []byte) (*ProtectedResponse, error)

SendProtected 通过固定指纹 Camoufox 页面发送请求,保留原生 TLS、HTTP/2、请求头、Cookie 和页面指纹

func (*Worker) State

func (worker *Worker) State() State

State 返回 runtime 的不可变状态副本

func (*Worker) StorageCookies

func (worker *Worker) StorageCookies(ctx context.Context) ([]byte, error)

StorageCookies 导出当前固定指纹浏览器 Cookie,供账户状态签名和持久化

Jump to

Keyboard shortcuts

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