Documentation
¶
Index ¶
- func GeminiCookies(cookies []StateCookie) []gemini.Cookie
- type BoundSession
- type File
- func (f *File) Account() LoadedAccount
- func (f *File) Metadata() Metadata
- func (f *File) Path() string
- func (f *File) SaveCookies(cookies []gemini.Cookie) error
- func (f *File) SetBoundSession(bound *BoundSession) error
- func (f *File) SetDisabled(disabled bool) error
- func (f *File) SetOAuthAndBound(material OAuthMaterial, bound *BoundSession, profile string) error
- func (f *File) SetPairingRenewal(digest string) error
- func (f *File) SetProxy(proxy string) error
- func (f *File) Write() error
- type ImportSource
- type LoadedAccount
- type Metadata
- type OAuthMaterial
- type StateCookie
- type StorageState
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 (*File) SaveCookies ¶
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
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
SetPairingRenewal 更新远程配对续签凭据摘要并写回
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 是服务启动使用的账号配置
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 保存账号固定身份
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 的认证状态文件