secrets

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "zoh"

ServiceName is the service identifier for keyring storage

Variables

View Source
var ErrNotFound = errors.New("key not found")

ErrNotFound is returned when a key is not found in the store

Functions

func IsHeadless

func IsHeadless() bool

IsHeadless returns true if running in a headless environment (no display server). Only applicable on Linux; macOS and Windows are assumed to have GUI.

func IsWSL

func IsWSL() bool

IsWSL returns true if running under Windows Subsystem for Linux.

Types

type FileStore

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

FileStore implements the Store interface using an AES-256-GCM encrypted file. This is a fallback for environments where OS keyring is unavailable (WSL, headless, Docker).

func NewFileStore

func NewFileStore(password string) (*FileStore, error)

NewFileStore creates a new file-backed credential store. If password is empty, uses a machine-specific default (less secure, prints warning). Future improvement: use scrypt or argon2 for key derivation instead of sha256.

func (*FileStore) Delete

func (s *FileStore) Delete(key string) error

Delete removes a credential from the encrypted file.

func (*FileStore) Get

func (s *FileStore) Get(key string) (string, error)

Get retrieves a credential by key from the encrypted file.

func (*FileStore) List

func (s *FileStore) List() ([]string, error)

List returns all credential keys from the encrypted file.

func (*FileStore) Set

func (s *FileStore) Set(key, value string) error

Set stores a credential in the encrypted file.

type KeyringStore

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

KeyringStore implements the Store interface using the OS keyring.

func NewKeyringStore

func NewKeyringStore() (*KeyringStore, error)

NewKeyringStore creates a new keyring-backed credential store. Returns an error if the keyring is unavailable on this platform.

func (*KeyringStore) Delete

func (s *KeyringStore) Delete(key string) error

Delete removes a credential from the keyring.

func (*KeyringStore) Get

func (s *KeyringStore) Get(key string) (string, error)

Get retrieves a credential by key from the keyring.

func (*KeyringStore) List

func (s *KeyringStore) List() ([]string, error)

List returns all credential keys stored in the keyring.

func (*KeyringStore) Set

func (s *KeyringStore) Set(key, value string) error

Set stores a credential in the keyring.

type Store

type Store interface {
	Get(key string) (string, error)
	Set(key, value string) error
	Delete(key string) error
	List() ([]string, error)
}

Store is the interface for credential storage Implementations will be added in Plan 02 (keyring and file)

func NewStore

func NewStore() (Store, error)

NewStore creates a Store instance using platform-appropriate backend. Tries OS keyring first, falls back to encrypted file if unavailable. Automatically detects WSL and headless environments that need file fallback.

Jump to

Keyboard shortcuts

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