Documentation
¶
Overview ¶
Package keys provides APIs to manage configured keys and load them into an SSH agent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfiguredKey ¶
type ConfiguredKey struct {
*js.Object
// Id is the unique ID for this key.
ID ID `js:"id"`
// Name is a name allocated to key.
Name string `js:"name"`
}
ConfiguredKey is a key configured for use.
type ID ¶
type ID string
ID is a unique identifier for a configured key.
const ( // InvalidID is a special ID that will not be assigned to any key. InvalidID ID = "" )
type LoadedKey ¶
type LoadedKey struct {
*js.Object
// Type is the type of key loaded in the agent (e.g., 'ssh-rsa').
Type string `js:"type"`
// Blob is the public key material for the loaded key.
Blob string `js:"blob"`
// Comment is a comment for the loaded key.
Comment string `js:"comment"`
}
LoadedKey is a key loaded into the agent.
type Manager ¶
type Manager interface {
// Configured returns the full set of keys that are configured. The
// callback is invoked with the result.
Configured(callback func(keys []*ConfiguredKey, err error))
// Add configures a new key. name is a human-readable name describing
// the key, and pemPrivateKey is the PEM-encoded private key. callback
// is invoked when complete.
Add(name string, pemPrivateKey string, callback func(err error))
// Remove removes the key with the specified ID. callback is invoked
// when complete.
//
// Note that it might be nice to return an error here, but
// the underlying Chrome APIs don't make it trivial to determine
// if the requested key was removed, or ignored because it didn't
// exist. This could be improved, but it doesn't seem worth it at
// the moment.
Remove(id ID, callback func(err error))
// Loaded returns the full set of keys loaded into the agent. The
// callback is invoked with the result.
Loaded(callback func(keys []*LoadedKey, err error))
// Load loads a new key into to the agent, using the passphrase to
// decrypt the private key. callback is invoked when complete.
//
// NOTE: Unencrypted private keys are not currently supported.
Load(id ID, passphrase string, callback func(err error))
}
Manager provides an API for managing configured keys and loading them into an SSH agent.
func NewClient ¶
func NewClient(msg MessageSender) Manager
NewClient returns a Manager implementation that forwards calls to a Server.
func NewManager ¶
func NewManager(agt agent.Agent, storage PersistentStore) Manager
NewManager returns a Manager implementation that can manage keys in the supplied agent, and store configured keys in the supplied storage.
type MessageReceiver ¶
type MessageReceiver interface {
OnMessage(callback func(header *js.Object, sender *js.Object, sendResponse func(interface{})) bool)
}
MessageReceiver defines methods sufficient to receive messages and send responses.
type MessageSender ¶
type MessageSender interface {
SendMessage(msg interface{}, callback func(rsp *js.Object))
Error() error
}
MessageSender defines methods sufficient to send messages.
type PersistentStore ¶
type PersistentStore interface {
// Set stores new data. See chrome.Storage.Set() for details.
Set(data map[string]interface{}, callback func(err error))
// Get gets data from storage. See chrome.Storage.Get() for details.
Get(callback func(data map[string]interface{}, err error))
// Delete deletes data from storage. See chrome.Storage.Delete() for
// details.
Delete(keys []string, callback func(err error))
}
PersistentStore provides access to underlying storage. See chrome.Storage for details on the methods; using this interface allows for alternate implementations during testing.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server exposes a Manager instance via a messaging API so that a shared instance can be invoked from a different page.
func NewServer ¶
func NewServer(mgr Manager, msg MessageReceiver) *Server
NewServer returns a new Server that manages keys using the supplied Manager.