keyring

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package keyring stores the CLI credential. Default is a 0600 file (headless/CI-safe, never world-readable); the OS keychain (go-keyring) is opt-in via HEXREAD_KEYRING=system.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("keyring: no stored credential")

Functions

This section is empty.

Types

type File

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

File is a 0600 credential file.

func DefaultFile

func DefaultFile() *File

DefaultFile resolves <config-dir>/hexread/credential. With no config dir and no home the path would be relative, putting the API key in the working directory; it is left empty instead and Get/Set fail with errNoConfigDir.

func NewFile

func NewFile(path string) *File

func (*File) Delete

func (f *File) Delete() error

func (*File) Get

func (f *File) Get() (string, error)

func (*File) Set

func (f *File) Set(s string) error

Set writes the credential atomically (temp file + rename) so a crash can't leave a truncated credential. The new file is always mode 0600: rename replaces the inode, so an existing file's mode is not preserved.

type Keyring

type Keyring interface {
	Set(secret string) error
	Get() (string, error)
	Delete() error
}

func Default

func Default() Keyring

Default selects the backend from HEXREAD_KEYRING: "file" (or unset) → the 0600 credential file, "system" → the OS keychain. An unknown value returns an erroring stub rather than silently storing the secret somewhere the user didn't choose.

type System

type System struct{}

System uses the OS keychain (macOS Keychain / Windows Credential Manager / Linux Secret Service).

func (System) Delete

func (System) Delete() error

func (System) Get

func (System) Get() (string, error)

func (System) Set

func (System) Set(s string) error

Jump to

Keyboard shortcuts

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