keys

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Rendered for js/wasm

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 {
	// Id is the unique ID for this key.
	ID string `js:"id"`
	// Name is a name allocated to key.
	Name string `js:"name"`
	// Encrypted indicates if the key is encrypted and requires a passphrase
	// to load.
	Encrypted bool `js:"encrypted"`
}

ConfiguredKey is a key configured for use.

type DefaultManager added in v0.0.20

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

DefaultManager is an implementation of Manager.

func NewManager

func NewManager(agt agent.Agent, syncStorage, sessionStorage storage.Area) *DefaultManager

NewManager returns a Manager implementation that can manage keys in the supplied agent, and store configured keys in the supplied storage.

func (*DefaultManager) Add added in v0.0.20

func (m *DefaultManager) Add(ctx jsutil.AsyncContext, name string, pemPrivateKey string) error

Add implements Manager.Add.

func (*DefaultManager) CleanupOldData added in v0.0.24

func (m *DefaultManager) CleanupOldData(ctx jsutil.AsyncContext)

CleanupOldData removes storage data that is no longer required.

func (*DefaultManager) Configured added in v0.0.20

func (m *DefaultManager) Configured(ctx jsutil.AsyncContext) ([]*ConfiguredKey, error)

Configured implements Manager.Configured.

func (*DefaultManager) Load added in v0.0.20

func (m *DefaultManager) Load(ctx jsutil.AsyncContext, id ID, passphrase string) error

Load implements Manager.Load.

func (*DefaultManager) LoadFromSession added in v0.0.20

func (m *DefaultManager) LoadFromSession(ctx jsutil.AsyncContext) error

LoadFromSession loads all keys for the current session into the agent.

func (*DefaultManager) Loaded added in v0.0.20

func (m *DefaultManager) Loaded(_ jsutil.AsyncContext) ([]*LoadedKey, error)

Loaded implements Manager.Loaded.

func (*DefaultManager) Remove added in v0.0.20

func (m *DefaultManager) Remove(ctx jsutil.AsyncContext, id ID) error

Remove implements Manager.Remove.

func (*DefaultManager) Unload added in v0.0.20

func (m *DefaultManager) Unload(ctx jsutil.AsyncContext, id ID) error

Unload implements Manager.Unload.

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 {
	// Type is the type of key loaded in the agent (e.g., 'ssh-rsa').
	Type string `js:"type"`
	// InternalBlob is the public key material for the loaded key. Must
	// be exported to be handled correctly in conversion to/from js.Value.
	InternalBlob string `js:"blob"`
	// Comment is a comment for the loaded key.
	Comment string `js:"comment"`
}

LoadedKey is a key loaded into the agent.

func (*LoadedKey) Blob

func (k *LoadedKey) Blob() []byte

Blob returns the public key material for the loaded key.

func (*LoadedKey) ID

func (k *LoadedKey) ID() ID

ID returns the unique ID corresponding to the key. If the ID cannot be determined, then InvalidID is returned.

The ID for a key loaded into the agent is stored in the Comment field as a string in a particular format.

func (*LoadedKey) SetBlob added in v0.0.8

func (k *LoadedKey) SetBlob(b []byte)

SetBlob sets the given public key material for the loaded key.

type Manager

type Manager interface {
	// Configured returns the full set of keys that are configured.
	Configured(ctx jsutil.AsyncContext) ([]*ConfiguredKey, error)

	// Add configures a new key.  name is a human-readable name describing
	// the key, and pemPrivateKey is the PEM-encoded private key.
	Add(ctx jsutil.AsyncContext, name string, pemPrivateKey string) error

	// Remove removes the key with the specified ID.
	//
	// 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(ctx jsutil.AsyncContext, id ID) error

	// Loaded returns the full set of keys loaded into the agent.
	Loaded(ctx jsutil.AsyncContext) ([]*LoadedKey, error)

	// Load loads a new key into to the agent, using the passphrase to
	// decrypt the private key.
	//
	// NOTE: Unencrypted private keys are not currently supported.
	Load(ctx jsutil.AsyncContext, id ID, passphrase string) error

	// Unload unloads a key from the agent.
	Unload(ctx jsutil.AsyncContext, id ID) error
}

Manager provides an API for managing configured keys and loading them into an SSH agent.

func NewClient

func NewClient(msg message.Sender) Manager

NewClient returns a Manager implementation that forwards calls to a Server.

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) *Server

NewServer returns a new Server that manages keys using the supplied Manager.

func (*Server) OnMessage added in v0.0.20

func (s *Server) OnMessage(ctx jsutil.AsyncContext, headerObj js.Value, _ js.Value) js.Value

OnMessage is the callback invoked when a message is received. It determines the type of request received, invokes the appropriate method on the underlying manager instance, and then returns the response to be sent to the client.

Jump to

Keyboard shortcuts

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