Documentation
¶
Overview ¶
Package keyring provides multi-keyring management for akt.
It wraps the Cosmos SDK's crypto/keyring package, adding support for multiple named keyrings that can be shared across contexts.
Each named keyring maps to a Cosmos SDK keyring.Keyring instance backed by a specific backend (os, file, test, kwallet, pass) and directory.
Index ¶
- func ApplyOverrides(keyrings []aktctx.Keyring, backend, dir string) []aktctx.Keyring
- func Backends() []string
- func DefaultAlgo() sdkkeyring.SignatureAlgo
- func EffectiveBackend(root string, kr aktctx.Keyring) (string, bool)
- func NewDeferred(backend string, loader DeferredLoader) sdkkeyring.Keyring
- func NewInMemory(cdc codec.Codec) sdkkeyring.Keyring
- func SystemBackendNames() []string
- func SystemKeyringAvailable() bool
- func ValidateBackend(backend string) error
- type DeferredLoader
- type Manager
- func (m *Manager) Deferred(name string) sdkkeyring.Keyring
- func (m *Manager) EffectiveBackend(name string) (string, bool)
- func (m *Manager) Get(name string) (sdkkeyring.Keyring, error)
- func (m *Manager) Names() []string
- func (m *Manager) Reload(keyrings []aktctx.Keyring)
- func (m *Manager) SetInput(r io.Reader)
- type UnavailableBackendError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyOverrides ¶ added in v0.0.4
ApplyOverrides returns keyring configurations with the per-invocation --keyring-backend / --keyring-dir overrides (SPEC §3.1) applied. Empty overrides leave the persisted configuration untouched, so an unset flag can never shadow a context's stored backend.
func Backends ¶ added in v0.0.4
func Backends() []string
Backends returns every keyring backend akt accepts, in the order they are offered to users (SPEC §1.5).
func DefaultAlgo ¶
func DefaultAlgo() sdkkeyring.SignatureAlgo
DefaultAlgo returns the default signing algorithm (secp256k1).
func EffectiveBackend ¶ added in v0.0.4
EffectiveBackend reports the concrete credential store that serves kr's configured backend on this host, and whether the host can provide it at all.
Only "os" is an alias: every other backend is pinned by the SDK to exactly one store, so it is its own effective backend. Resolution is inspection only — it never reads a key, unlocks a store, or prompts.
func NewDeferred ¶ added in v0.0.4
func NewDeferred(backend string, loader DeferredLoader) sdkkeyring.Keyring
NewDeferred returns a keyring proxy that invokes loader on its first key operation. It is used by public reads that may need a named default account later but must not prompt merely because the context has one configured.
func NewInMemory ¶
func NewInMemory(cdc codec.Codec) sdkkeyring.Keyring
NewInMemory creates an in-memory keyring for dry-run / testing use. It is not associated with any named keyring in the config.
func SystemBackendNames ¶ added in v0.0.4
func SystemBackendNames() []string
SystemBackendNames names the credential stores that can serve the "os" backend on this platform, whether or not they are present.
func SystemKeyringAvailable ¶ added in v0.0.4
func SystemKeyringAvailable() bool
SystemKeyringAvailable reports whether this host provides a credential store that can serve the "os" backend (SPEC §1.5). Offering "os" where this is false hands the user a backend that silently becomes something else.
func ValidateBackend ¶ added in v0.0.4
ValidateBackend reports whether backend names a keyring akt can open. An empty value means "unset" and is accepted: callers treat it as "inherit the configured backend".
Types ¶
type DeferredLoader ¶ added in v0.0.4
type DeferredLoader func() (sdkkeyring.Keyring, error)
DeferredLoader opens the configured keyring when an operation first needs key material. The returned keyring or error is cached for the process.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple named keyrings. It lazily opens keyrings on first access and caches them for the lifetime of the process. Manager is safe for concurrent use.
func NewManager ¶
NewManager creates a keyring manager from the config root and keyring definitions. The codec is required by the Cosmos SDK keyring for protobuf key serialization.
func (*Manager) Deferred ¶ added in v0.0.4
func (m *Manager) Deferred(name string) sdkkeyring.Keyring
Deferred returns a proxy that opens the named keyring on its first key operation. Inspecting Backend does not open the configured store.
func (*Manager) EffectiveBackend ¶ added in v0.0.4
EffectiveBackend reports the concrete credential store that serves the named keyring on this host (SPEC §1.5), and whether the host can provide it.
func (*Manager) Get ¶
func (m *Manager) Get(name string) (sdkkeyring.Keyring, error)
Get returns the Cosmos SDK keyring for the given named keyring. The keyring is lazily opened on first access and cached.
type UnavailableBackendError ¶ added in v0.0.4
UnavailableBackendError reports a configured keyring backend that this host cannot provide. It is deliberately fatal rather than a fallback: substituting a different credential store would move the user's keys without telling them (SPEC §1.5).
func (*UnavailableBackendError) Error ¶ added in v0.0.4
func (e *UnavailableBackendError) Error() string