Documentation
¶
Overview ¶
Package auth manages authentication token storage for axi-forge. Tokens are stored in a single JSON file at $XDG_CACHE_HOME/axi-forge/credentials.json, keyed by host. The file is the single source of truth — no environment variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollapseHome ¶
CollapseHome replaces the user's home directory prefix in path with "~". Returns the original path if the home directory cannot be determined.
func DefaultStorePath ¶
func DefaultStorePath() string
DefaultStorePath returns the default path to the credentials file. Uses $XDG_CACHE_HOME if set, otherwise ~/.cache.
func InferForgeType ¶
InferForgeType returns a forge type identifier (e.g., "github", "gitlab", "forgejo") inferred from the host string.
func ResolveToken ¶
ResolveToken returns the token for the given host from the default store, or a TokenError if not found.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides concurrent-safe read/write access to the credentials file. The zero value is not usable; use NewStore to create one.
func NewStore ¶
NewStore creates a Store backed by the file at the given path. The parent directory must exist; the file is created on first write.
type TokenError ¶
type TokenError struct {
Host string
}
TokenError is a structured error returned when a token is not found for a host. It satisfies forge.StructuredError so main.go can format output uniformly.
func (*TokenError) Error ¶
func (e *TokenError) Error() string
func (*TokenError) Help ¶
func (e *TokenError) Help() string
Help returns the suggested corrective command.
func (*TokenError) Message ¶
func (e *TokenError) Message() string
Message returns the user-facing error message.