auth

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package auth 提供 pixiv auth 命令组:账号列表、选择、导入导出、检查与刷新,以及浏览器 OAuth 登录。

包的组成:New 组装命令树,Support 携带账号服务、登录服务与配置读取端口。 AccountService 适配账号领域访问。 桌面回调与远程登录在 github.com/FlanChanXwO/pixiv-cli/internal/urlscheme。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountJSON

func AccountJSON(account account.AccountSummary) any

AccountJSON 返回与 `pixiv auth list --json` 单账号项相同的公开摘要;不含凭据。

func New

func New(env environment.Env, support Support) *cobra.Command

New 构造完整 Pixiv auth 命令组;账号、登录、bundle 和交互都保留在该 owner。

Types

type AccountService

type AccountService struct {
	Pixiv       accountPort
	LoadRuntime func() (settings.RuntimeConfig, error)
}

AccountService 把账号领域服务接到 auth 命令上。 账号领域服务不读取 CLI 配置;代理和运行时开关只在这里转换为 SDK options。

type Support

type Support struct {
	// Account 延迟打开账号服务;只在执行账号子命令时调用。
	Account func() (*account.Service, error)
	// Login 延迟打开登录服务,避免构造命令树时打开数据库。
	Login func() (account.LoginService, error)
	// LoadRuntime 每次调用读取最新的运行时配置。
	LoadRuntime func() (settings.RuntimeConfig, error)
	// WriteBundle 写出含凭据的 bundle;force 为 false 时不得覆盖已有文件。
	WriteBundle func(string, []byte, bool) error
}

Support 携带各 auth 叶子命令共用的账号、登录和 bundle 写入端口;输入输出与交互式提问 由 environment.Env 提供。

func SupportFor

func SupportFor(accounts func() (*account.Service, account.LoginService, error), loadRuntime func() (settings.RuntimeConfig, error), writeBundle func(string, []byte, bool) error) Support

SupportFor 构造生产 Support:账号与登录服务延迟打开,配置按调用读取,bundle 写入 复用 secretfile 的私有文件语义。

Jump to

Keyboard shortcuts

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