auth

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 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) Path added in v0.1.3

func (f *File) Path() string

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

func (*File) Proxy added in v0.1.3

func (f *File) Proxy() string

Proxy 返回账号固定代理

func (*File) SaveCookies

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

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

func (*File) SetDisabled added in v0.1.3

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

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

func (*File) SetProxy added in v0.1.3

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

SetProxy 修改账号固定代理并写回,空值表示使用全局代理

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

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"`
	Language string         `json:"language,omitempty"`
	AuthUser int            `json:"authUser,omitempty"`
	OAuth    *OAuthMaterial `json:"oauth,omitempty"`
	Disabled bool           `json:"disabled,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