Documentation
¶
Index ¶
- Constants
- func AuthFilePath() (string, error)
- func IsLegacySchemaError(err error) bool
- func IsMissingRefreshTokenError(err error) bool
- func SaveAuthStore(path string, store AuthStore) error
- func SetAuthFilePathForTest(authPath string) func()
- func SetReadAuthStoreFileForTest(path string, read func(string) ([]byte, error)) func()
- func SetWriteAuthStoreFileForTest(path string, write func(string, []byte) error) func()
- func WritePrivateFile(path string, body []byte) error
- type Account
- type AuthStore
- type LegacySchemaError
- type SaveCommitOutcome
Constants ¶
View Source
const DefaultAuthFileMode = constants.PrivateFileMode
Variables ¶
This section is empty.
Functions ¶
func AuthFilePath ¶
func IsLegacySchemaError ¶
func IsMissingRefreshTokenError ¶ added in v0.4.0
IsMissingRefreshTokenError 只暴露安全分类,不携带 token 或文件内容。
func SaveAuthStore ¶
func SetAuthFilePathForTest ¶
func SetAuthFilePathForTest(authPath string) func()
func SetReadAuthStoreFileForTest ¶ added in v0.4.0
SetReadAuthStoreFileForTest 仅为跨平台本地状态错误测试拦截指定 auth path。 其他路径始终使用 os.ReadFile。hook 生命周期由互斥锁串行化,同一路径测试不得 并行;调用方必须用 t.Cleanup 执行返回的恢复函数。
func SetWriteAuthStoreFileForTest ¶ added in v0.4.0
SetWriteAuthStoreFileForTest 仅为本地状态原子失败测试拦截指定 auth path。 hook 在编码与完整 store 校验之后、真实原子写入之前执行;调用方必须用 t.Cleanup 执行返回的恢复函数,且不得并行使用同一路径。
func WritePrivateFile ¶
Types ¶
type Account ¶
type Account struct {
RefreshToken string `json:"refresh_token"`
UserID int64 `json:"user_id,omitempty"`
Username string `json:"username,omitempty"`
// PremiumStatus 仅缓存由 App profile 验证过的会员状态;nil 代表从未验证。
PremiumStatus *bool `json:"premium_status,omitempty"`
PremiumStatusCheckedAt *time.Time `json:"premium_status_checked_at,omitempty"`
}
type AuthStore ¶
type AuthStore struct {
DefaultUserID int64 `json:"default_user_id,omitempty"`
Accounts []Account `json:"accounts,omitempty"`
}
func LoadAuthStore ¶
type LegacySchemaError ¶
type LegacySchemaError struct {
Field string
}
func (LegacySchemaError) Error ¶
func (e LegacySchemaError) Error() string
type SaveCommitOutcome ¶ added in v0.4.0
type SaveCommitOutcome string
SaveCommitOutcome 标识 auth store 的目标文件 replacement 是否已提交。
const ( SaveCommitOutcomeUnknown SaveCommitOutcome = "unknown" SaveCommitOutcomeNotCommitted SaveCommitOutcome = "not_committed" SaveCommitOutcomeCommitted SaveCommitOutcome = "committed" )
func SaveAuthStoreWithOutcome ¶ added in v0.4.0
func SaveAuthStoreWithOutcome(path string, store AuthStore) (SaveCommitOutcome, error)
SaveAuthStoreWithOutcome 保存 auth store,并在失败时返回稳定的 commit outcome。 not_committed 表示新内容未替换目标;committed 表示 replacement 已完成,但后续 cleanup 或 durability 步骤失败,调用方必须重新加载目标确认当前状态。
Click to show internal directories.
Click to hide internal directories.