util

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWriteFile

func AtomicWriteFile(path string, data []byte, perm os.FileMode) error

AtomicWriteFile writes data to a file atomically using temp file + rename

func ClientTLSConfig

func ClientTLSConfig() (*tls.Config, error)

ClientTLSConfig returns TLS config for client connections

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the XDG-compliant config directory for op-authd

func Contains

func Contains[T comparable](slice []T, item T) bool

Contains checks if a slice contains a specific element

func DataDir

func DataDir() (string, error)

DataDir returns the XDG-compliant data directory for op-authd

func EnsureSecureToken

func EnsureSecureToken() (string, error)

EnsureSecureToken ensures a token exists using secure storage

func EnsureToken

func EnsureToken(path string) (string, error)

func Filter

func Filter[T any](slice []T, predicate func(T) bool) []T

Filter returns a new slice containing only elements that match the predicate

func FindFirst

func FindFirst[T any](slice []T, predicate func(T) bool) (T, bool)

FindFirst returns the first element matching the predicate, or zero value if none found

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration with appropriate units

func GroupBy

func GroupBy[T any, K comparable](slice []T, keyFn func(T) K) map[K][]T

GroupBy groups slice elements by the result of the key function

func HomeDir

func HomeDir() string

func Map

func Map[T any, R any](slice []T, fn func(T) R) []R

Map transforms a slice using the provided function

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string with support for days, weeks, months, years Supports: 1h, 30m, 45s, 2d, 1w, 3M, 1y, or combinations like "1d12h30m"

func RuntimeDir

func RuntimeDir() (string, error)

RuntimeDir returns the XDG-compliant runtime directory for op-authd

func SocketPath

func SocketPath() (string, error)

func StateDir

func StateDir() (string, error)

StateDir maintains backward compatibility (now an alias for DataDir)

func TLSConfig

func TLSConfig() (*tls.Config, error)

TLSConfig generates or loads TLS configuration for Unix socket encryption

func TokenPath

func TokenPath() (string, error)

func ValidateDuration

func ValidateDuration(s string) error

ValidateDuration checks if a duration string is valid

Types

type SecureTokenManager

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

SecureTokenManager handles token storage using OS keyring with file fallback

func NewSecureTokenManager

func NewSecureTokenManager() (*SecureTokenManager, error)

NewSecureTokenManager creates a new secure token manager

func (*SecureTokenManager) DeleteToken

func (stm *SecureTokenManager) DeleteToken() error

DeleteToken removes the token from both keyring and file

func (*SecureTokenManager) GetStorageLocation

func (stm *SecureTokenManager) GetStorageLocation() string

GetStorageLocation returns information about where the token is stored

func (*SecureTokenManager) IsKeyringsSupported

func (stm *SecureTokenManager) IsKeyringsSupported() bool

IsKeyringsSupported checks if OS keyring is available

func (*SecureTokenManager) RetrieveToken

func (stm *SecureTokenManager) RetrieveToken() (string, error)

RetrieveToken retrieves the token from OS keyring with file fallback

func (*SecureTokenManager) StoreToken

func (stm *SecureTokenManager) StoreToken(token string) error

StoreToken stores the token in OS keyring with file fallback

Jump to

Keyboard shortcuts

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