Documentation
¶
Index ¶
Constants ¶
View Source
const ( // KeyPrefix is the expected prefix for all Saber API keys. KeyPrefix = "sk_live_" // KeyLength is the total length of a valid API key (prefix + 43 chars). KeyLength = 51 )
Variables ¶
This section is empty.
Functions ¶
func APIKey ¶
APIKey returns the active API key using the lookup order: 1. SABER_API_KEY env var 2. ~/.saber/credentials.json Returns ("", nil) if no key is configured.
func DeleteCredentials ¶
func DeleteCredentials() error
DeleteCredentials removes ~/.saber/credentials.json. Idempotent.
func RequireAPIKey ¶
RequireAPIKey returns the API key or exits with code 2 if not configured.
func SaveCredentials ¶
SaveCredentials writes credentials to ~/.saber/credentials.json (mode 0600).
func ValidateKeyFormat ¶
ValidateKeyFormat checks the format of an API key without hitting the network.
Types ¶
type Credentials ¶
Credentials is persisted to ~/.saber/credentials.json.
func LoadCredentials ¶
func LoadCredentials() (*Credentials, error)
LoadCredentials reads ~/.saber/credentials.json.
type ErrNotAuthenticated ¶
type ErrNotAuthenticated struct{}
ErrNotAuthenticated is returned when no API key is found.
func (*ErrNotAuthenticated) Error ¶
func (e *ErrNotAuthenticated) Error() string
Click to show internal directories.
Click to hide internal directories.