auth

package
v0.2.2 Latest Latest
Warning

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

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

func GeminiCookies added in v0.1.9

func GeminiCookies(cookies []StateCookie) []gemini.Cookie

GeminiCookies 把认证状态中的 Cookie 转为协议客户端使用的 Cookie

Types

type BoundSession added in v0.2.0

type BoundSession struct {
	ID          string   `json:"id"`
	RefreshURL  string   `json:"refreshUrl"`
	Credentials []string `json:"credentials"`
}

BoundSession 保存 OAuthMultilogin 登记的 Google DBSC 会话参数

type File

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

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

func Load

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

Load 读取一个认证状态文件,账号没有版本池中的 Chrome 版本时按各版本占比分配一个并写回

func New

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

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

func (*File) Account

func (f *File) Account() LoadedAccount

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

func (*File) Metadata added in v0.1.9

func (f *File) Metadata() Metadata

Metadata 返回账号固定身份

func (*File) Path added in v0.1.3

func (f *File) Path() string

Path 返回认证状态文件的绝对路径

func (*File) SaveCookies

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

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

func (*File) SetBoundSession added in v0.2.0

func (f *File) SetBoundSession(bound *BoundSession) error

SetBoundSession 更新 DBSC 会话登记并写回

func (*File) SetDisabled added in v0.1.3

func (f *File) SetDisabled(disabled bool) error

SetDisabled 修改账号停用标记并写回

func (*File) SetOAuthAndBound added in v0.2.0

func (f *File) SetOAuthAndBound(material OAuthMaterial, bound *BoundSession, profile string) error

SetOAuthAndBound 更新续签材料、DBSC 会话登记与来源 Profile 并写回

func (*File) SetPairingRenewal added in v0.2.0

func (f *File) SetPairingRenewal(digest string) error

SetPairingRenewal 更新远程配对续签凭据摘要并写回

func (*File) SetProxy added in v0.1.3

func (f *File) SetProxy(proxy string) error

SetProxy 修改账号固定代理并写回,空值表示从代理池分配,direct 表示直连

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
	BoundSession *BoundSession
	// Profile 为 Chrome 导入的 Profile 目录名,Cookie Header 导入时为空
	Profile  string
	Disabled bool
	File     *File
}

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

func LoadFiles

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

LoadFiles 加载全部认证状态文件

type Metadata

type Metadata struct {
	ID       string       `json:"id"`
	Proxy    string       `json:"proxy,omitempty"`
	Source   ImportSource `json:"source,omitempty"`
	Language string       `json:"language,omitempty"`
	AuthUser int          `json:"authUser,omitempty"`
	// Chrome 是账号绑定的 Chrome 主版本,生成、轮换与续签请求都以该版本的身份发出
	Chrome         int            `json:"chrome,omitempty"`
	OAuth          *OAuthMaterial `json:"oauth,omitempty"`
	BoundSession   *BoundSession  `json:"boundSession,omitempty"`
	PairingRenewal string         `json:"pairingRenewal,omitempty"`
	Disabled       bool           `json:"disabled,omitempty"`
}

Metadata 保存账号固定身份

func Inherit added in v0.1.9

func Inherit(path string, metadata Metadata) Metadata

Inherit 让本次导入的 metadata 沿用 path 处已导入账号的停用标记、Chrome 版本、配对续签摘要与未重新填写的固定代理

type OAuthMaterial

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

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

func StateCookies added in v0.1.9

func StateCookies(cookies []gemini.Cookie) []StateCookie

StateCookies 把协议客户端的 Cookie 转为认证状态中的 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