credstore

package
v0.0.1-testing Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package credstore stores account secrets in the OS keyring (macOS Keychain, Windows Credential Manager, Secret Service on Linux), with an explicit opt-in plain-file fallback for headless environments.

Index

Constants

View Source
const Service = "reearth-cli"

Service is the keyring service name.

Variables

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

Functions

func CheckKeyring

func CheckKeyring() error

CheckKeyring verifies that the OS keyring is usable by writing and deleting a probe entry.

func DefaultFilePath

func DefaultFilePath(configDir string) string

DefaultFilePath is where the insecure fallback store lives.

Types

type AccessToken

type AccessToken struct {
	Token  string    `json:"token"`
	Expiry time.Time `json:"expiry"`
}

AccessToken is a cached access token for one audience.

type Secret

type Secret struct {
	Kind         string                 `json:"kind"`
	RefreshToken string                 `json:"refresh_token,omitempty"`
	Token        string                 `json:"token,omitempty"`
	AccessTokens map[string]AccessToken `json:"access_tokens,omitempty"`
}

Secret is everything sensitive about an account. Only RefreshToken (oauth) or Token (token accounts) is essential; AccessTokens is a best-effort cache.

type Store

type Store interface {
	Get(account string) (*Secret, error)
	Set(account string, s *Secret) error
	Delete(account string) error
}

func File

func File(path string) Store

File returns a plain JSON-file store (0600). Use only when the user opted in.

func Keyring

func Keyring() Store

Keyring returns the OS keyring store.

func Memory

func Memory() Store

Memory returns an in-memory store for tests.

Jump to

Keyboard shortcuts

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