token

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package token persists the access tokens clover mints (e.g. via the GitHub device flow), keyed by host. It prefers the OS keyring (macOS Keychain, libsecret, Windows Credential Manager) and falls back to a 0600 file under the user config directory when no keyring is available, so headless environments still work. The CLI edge owns this; the pure core never sees a credential.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option configures a Store.

func WithDir

func WithDir(dir string) Option

WithDir overrides the file-fallback directory, for tests.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store reads and writes tokens by host, keyring-first with a file fallback.

func New

func New(opts ...Option) (*Store, error)

New returns a Store whose file fallback lives under the user config directory (e.g. ~/.config/clover/hosts). The directory is created lazily on the first write that needs it.

func (*Store) Delete

func (s *Store) Delete(host string) error

Delete removes any stored token for host from both the keyring and the file fallback. A missing token is not an error.

func (*Store) Get

func (s *Store) Get(host string) (string, bool)

Get returns the token stored for host, trying the keyring then the file fallback. Both values are trimmed, and an empty result is reported as a miss (false) so an empty entry never shadows a later credential source.

func (*Store) Set

func (s *Store) Set(host, token string) error

Set stores token for host in the keyring, falling back to a 0600 file when the keyring is unavailable (commonly headless Linux without a secret service).

Jump to

Keyboard shortcuts

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