Documentation
¶
Overview ¶
Package cred manages the per-context credential store (~/.vibexp/credentials.json, 0600). It is deliberately separate from the config store so credentials never mingle with non-secret settings. The on-disk schema already accommodates OAuth token entries (issue #5).
Index ¶
Constants ¶
const ( TypeAPIKey = "api_key" TypeOAuth = "oauth" )
Credential entry types.
const EnvAPIKey = "VIBEXP_API_KEY"
EnvAPIKey is the environment variable that overrides stored credentials.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
DefaultPath returns ~/.vibexp/credentials.json.
func Fingerprint ¶
Fingerprint returns a non-secret display form of a key: the first 4 and last 4 characters (e.g. "vxk_…1234"). Short keys collapse to a fixed mask.
Types ¶
type Entry ¶
type Entry struct {
Type string `json:"type"`
APIKey string `json:"api_key,omitempty"`
ClientID string `json:"client_id,omitempty"`
AccessToken string `json:"access_token,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
// Scopes are the scopes the last successful authorization request for
// ClientID actually carried — normally the ones declared at RFC 7591
// registration, but empty when the authorization server refused them and
// the login only succeeded on the no-scope retry (issue #37). Browser login
// reuses a stored client only when its scopes cover the scopes it needs to
// request, so an entry recording a refusal deliberately forces a fresh
// registration next time rather than replaying a request the server is
// known to reject. Older entries have none and re-register for the same
// reason.
Scopes []string `json:"scopes,omitempty"`
}
Entry is one context's stored credential. API-key entries set Type=api_key and APIKey; OAuth entries (issue #5) set Type=oauth and the token fields.
type Resolved ¶
type Resolved struct {
Bearer string
Source Source
// Type is the stored entry type when Source is "stored" ("api_key" or
// "oauth"); empty for env.
Type string
}
Resolved is the effective credential for a context.
type Store ¶
type Store struct {
Path string
}
Store reads and writes the credential file at Path.
func DefaultStore ¶
DefaultStore returns a Store rooted at the default credentials path.