Documentation
¶
Overview ¶
Package rwagent provides a Go client for the RootWallet agent daemon.
The agent is a persistent daemon that holds vault keys in memory and serves operations to authorized apps over a Unix socket HTTP API. This SDK replaces all subprocess `rw` calls with direct HTTP communication.
Index ¶
- Constants
- Variables
- func IsApprovalDenied(err error) bool
- func IsLocked(err error) bool
- func IsNotFound(err error) bool
- func IsNotRunning(err error) bool
- type AgentError
- type AppPermission
- type Client
- func (c *Client) CreateSSHEntry(ctx context.Context, host, username string) (*VaultSSHData, error)
- func (c *Client) GetAddress(ctx context.Context, chain string) (*WalletAddressData, error)
- func (c *Client) GetPassword(ctx context.Context, domain, username string) (*VaultPasswordData, error)
- func (c *Client) GetSSHKey(ctx context.Context, host, username, format string) (*VaultSSHData, error)
- func (c *Client) IsRunning(ctx context.Context) bool
- func (c *Client) Lock(ctx context.Context) error
- func (c *Client) Status(ctx context.Context) (*StatusResponse, error)
- func (c *Client) Unlock(ctx context.Context, password string, ttlMinutes int) error
- type PermittedCapability
- type StatusResponse
- type VaultPasswordData
- type VaultSSHData
- type WalletAddressData
Constants ¶
const ( // DefaultSocketName is the socket file relative to ~/.rootwallet/. DefaultSocketName = "agent.sock" // DefaultTimeout for HTTP requests to the agent. // Set high enough to allow pending approval flow (2 min approval timeout). DefaultTimeout = 150 * time.Second )
Variables ¶
var ErrAgentNotRunning = fmt.Errorf("rootwallet agent is not running — start with: rw agent start && rw agent unlock")
ErrAgentNotRunning is returned when the agent socket is not reachable.
Functions ¶
func IsApprovalDenied ¶
IsApprovalDenied returns true if the user denied the app's access request.
func IsNotFound ¶
IsNotFound returns true if the vault entry was not found.
func IsNotRunning ¶
IsNotRunning returns true if the error indicates the agent is not reachable.
Types ¶
type AgentError ¶
type AgentError struct {
Code string // e.g., "AGENT_LOCKED", "NOT_FOUND"
Message string
StatusCode int
}
AgentError represents an error returned by the rootwallet agent API.
func (*AgentError) Error ¶
func (e *AgentError) Error() string
type AppPermission ¶
type AppPermission struct {
BinaryHash string `json:"binaryHash"`
BinaryPath string `json:"binaryPath"`
Name string `json:"name"`
FirstSeen string `json:"firstSeen"`
LastUsed string `json:"lastUsed"`
Capabilities []PermittedCapability `json:"capabilities"`
}
AppPermission represents an approved app in the permission database.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the rootwallet agent daemon over a Unix socket.
func New ¶
New creates a client that connects to the agent's Unix socket. If socketPath is empty, defaults to ~/.rootwallet/agent.sock.
func (*Client) CreateSSHEntry ¶
CreateSSHEntry creates a new SSH key entry in the vault.
func (*Client) GetAddress ¶
GetAddress returns the active wallet address.
func (*Client) GetPassword ¶
func (c *Client) GetPassword(ctx context.Context, domain, username string) (*VaultPasswordData, error)
GetPassword retrieves a stored password from the vault.
func (*Client) GetSSHKey ¶
func (c *Client) GetSSHKey(ctx context.Context, host, username, format string) (*VaultSSHData, error)
GetSSHKey retrieves an SSH key from the vault. format: "priv", "pub", or "both".
type PermittedCapability ¶
type PermittedCapability struct {
Capability string `json:"capability"`
GrantedAt string `json:"grantedAt"`
}
PermittedCapability is a specific capability granted to an app.
type StatusResponse ¶
type StatusResponse struct {
Version string `json:"version"`
Locked bool `json:"locked"`
Uptime int `json:"uptime"`
PID int `json:"pid"`
ConnectedApps int `json:"connectedApps"`
}
StatusResponse from GET /v1/status.
type VaultPasswordData ¶
type VaultPasswordData struct {
Password string `json:"password"`
}
VaultPasswordData from GET /v1/vault/password/:domain/:user.
type VaultSSHData ¶
type VaultSSHData struct {
PrivateKey string `json:"privateKey,omitempty"`
PublicKey string `json:"publicKey,omitempty"`
}
VaultSSHData from GET /v1/vault/ssh/:host/:user.
type WalletAddressData ¶
WalletAddressData from GET /v1/wallet/address.