auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 7 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

This section is empty.

Functions

This section is empty.

Types

type File

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

File 管理一个可原子写回的认证状态文件

func Load

func Load(path string) (*File, error)

Load 读取一个认证状态文件

func New

func New(path string, state StorageState) (*File, error)

New 创建一个待写入的认证状态文件

func (*File) Account

func (f *File) Account(globalProxy string) LoadedAccount

Account 返回协议客户端使用的账号来源

func (*File) SaveCookies

func (f *File) SaveCookies(cookies []gemini.Cookie) error

SaveCookies 更新 Cookie 并原子写回认证状态

func (*File) Write

func (f *File) Write() error

Write 将当前状态原子写入磁盘

type ImportSource

type ImportSource struct {
	Browser string `json:"browser,omitempty"`
	Profile string `json:"profile,omitempty"`
}

ImportSource 记录认证状态的浏览器来源

type LoadedAccount

type LoadedAccount struct {
	ID       string
	ProxyURL string
	Source   gemini.AccountSource
	OAuth    *OAuthMaterial
}

LoadedAccount 是服务启动使用的账号配置

func LoadFiles

func LoadFiles(paths []string, globalProxy string) ([]LoadedAccount, error)

LoadFiles 加载全部认证状态文件

type Metadata

type Metadata struct {
	ID          string             `json:"id"`
	Proxy       string             `json:"proxy,omitempty"`
	Source      ImportSource       `json:"source,omitempty"`
	Fingerprint gemini.Fingerprint `json:"fingerprint"`
	OAuth       *OAuthMaterial     `json:"oauth,omitempty"`
}

Metadata 保存账号固定身份

type OAuthMaterial

type OAuthMaterial struct {
	GaiaID            string `json:"gaiaId"`
	RefreshToken      string `json:"refreshToken"`
	WrappedBindingKey []byte `json:"wrappedBindingKey"`
}

OAuthMaterial 保存无需再次读取浏览器的续签材料

type StateCookie

type StateCookie 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"`
}

StateCookie 表示 Playwright storage-state 中的 Cookie

type StorageState

type StorageState struct {
	Cookies  []StateCookie     `json:"cookies"`
	Origins  []json.RawMessage `json:"origins"`
	Metadata Metadata          `json:"geminiWeb2api"`
}

StorageState 是兼容 Playwright 的认证状态文件

Jump to

Keyboard shortcuts

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