Documentation
¶
Overview ¶
Package keychain keeps keys in the OS keychain, as Keys in contract.md defines. Each entry uses the service nicely and the account named after the key's service, and each call has a time limit. Only internal/cli reaches it: a key reaches an extension only through grants.
Index ¶
Constants ¶
const Service = "nicely"
Service is the keychain service of every entry that Nicely stores.
Variables ¶
var ( InteractiveLimit = 60 * time.Second Limit = 10 * time.Second )
The time limit of each call: InteractiveLimit in interactive mode, where a human can answer an unlock prompt, and Limit otherwise. The test binary shortens both, so a scenario proves a limit without waiting.
var ErrNotFound = keyring.ErrNotFound
ErrNotFound is the error of a Backend whose entry does not exist.
ErrUnavailable means that the keychain did not answer a read in time, or refused it, so the command counts it unavailable for every later key.
var ErrWriteUnknown = errors.New("the keychain did not confirm the write")
ErrWriteUnknown means that a write failed or got no answer within its limit. Its effect is unknown, because the keychain may still store or remove the key after ncly answers.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
Get(service, account string) (string, error)
Set(service, account, key string) error
Delete(service, account string) error
}
Backend stores the entries: the OS keychain in ncly, and a test keychain in the test binary alone. Get returns ErrNotFound for a missing entry.
type Keychain ¶
type Keychain struct {
// contains filtered or unexported fields
}
Keychain asks a backend for one command. Once a call finds the keychain unavailable, it asks nothing more, so a command that reads several keys waits for one limit at most.
func (*Keychain) Available ¶
Available asks the keychain once whether it answers, and reports whether it still counts as available. It returns the error of ctx when ctx ends before the keychain answers or its limit passes.
func (*Keychain) Read ¶
Read returns the key of an account and whether the keychain holds one. It returns ErrUnavailable without asking once the keychain is unavailable, and the error of ctx when ctx ends first.