cloud

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIURL = "https://api.getssher.com"
	DefaultAppURL = "https://cloud.getssher.com"
)

Variables

View Source
var ErrNotLoggedIn = errors.New("not signed in to SSHer Cloud; run 'ssher cloud login'")

Functions

func LoadOrCreateDeviceKey

func LoadOrCreateDeviceKey() (*ecdh.PrivateKey, error)

func RemoveConfig

func RemoveConfig() error

func SaveConfig

func SaveConfig(cfg *Config) error

func ServerHash

func ServerHash(server store.Server) string

func UnwrapWorkspaceKey

func UnwrapWorkspaceKey(envelope Envelope, privateKey *ecdh.PrivateKey) ([]byte, error)

Types

type APIError

type APIError struct {
	Status        int
	Code, Message string
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	BaseURL, Token string
	HTTP           *http.Client
}

func NewClient

func NewClient(baseURL, token string) *Client

func (*Client) CreateDeviceCode

func (c *Client) CreateDeviceCode(ctx context.Context, name, platform string, publicKey []byte) (DeviceCode, error)

func (*Client) CreateServer

func (c *Client) CreateServer(ctx context.Context, orgID string, in EncryptedServer) (EncryptedServer, error)

func (*Client) ExchangeDeviceCode

func (c *Client) ExchangeDeviceCode(ctx context.Context, code string) (DeviceToken, bool, error)

func (*Client) OrganizationDevices added in v0.3.3

func (c *Client) OrganizationDevices(ctx context.Context, orgID string) ([]OrganizationDevice, error)

func (*Client) Organizations

func (c *Client) Organizations(ctx context.Context) ([]Organization, error)

func (*Client) PutWorkspaceEnvelope added in v0.3.3

func (c *Client) PutWorkspaceEnvelope(ctx context.Context, orgID, deviceID string, envelope Envelope) error

func (*Client) Servers

func (c *Client) Servers(ctx context.Context, orgID string) ([]EncryptedServer, error)

func (*Client) UpdateServer

func (c *Client) UpdateServer(ctx context.Context, orgID string, in EncryptedServer, expected int64) (EncryptedServer, error)

func (*Client) WorkspaceEnvelope

func (c *Client) WorkspaceEnvelope(ctx context.Context, orgID, deviceID string) (Envelope, error)

type Config

type Config struct {
	APIURL           string `json:"api_url"`
	AppURL           string `json:"app_url"`
	SessionToken     string `json:"session_token"`
	ExpiresAt        string `json:"expires_at"`
	UserID           string `json:"user_id"`
	UserEmail        string `json:"user_email"`
	DeviceID         string `json:"device_id"`
	OrganizationID   string `json:"organization_id,omitempty"`
	OrganizationName string `json:"organization_name,omitempty"`
}

func LoadConfig

func LoadConfig() (*Config, error)

type Device

type Device struct {
	ID        string `json:"id"`
	UserID    string `json:"user_id"`
	Name      string `json:"name"`
	Platform  string `json:"platform"`
	PublicKey []byte `json:"public_key"`
}

type DeviceCode

type DeviceCode struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri"`
	ExpiresAt       string `json:"expires_at"`
	Interval        int    `json:"interval"`
}

type DeviceToken

type DeviceToken struct {
	Status  string `json:"status"`
	User    User   `json:"user"`
	Device  Device `json:"device"`
	Session struct {
		Token     string `json:"token"`
		ExpiresAt string `json:"expires_at"`
	} `json:"session"`
}

type EncryptedServer

type EncryptedServer struct {
	ID             string     `json:"id"`
	OrganizationID string     `json:"organization_id"`
	Ciphertext     []byte     `json:"ciphertext"`
	Nonce          []byte     `json:"nonce"`
	Revision       int64      `json:"revision"`
	TeamIDs        []string   `json:"team_ids"`
	DeletedAt      *time.Time `json:"deleted_at,omitempty"`
}

func EncryptServer

func EncryptServer(payload ServerPayload, key []byte, orgID, serverID string, revision int64) (EncryptedServer, error)

type Envelope

type Envelope struct {
	OrganizationID     string `json:"organization_id"`
	DeviceID           string `json:"device_id"`
	Generation         int    `json:"generation"`
	EphemeralPublicKey []byte `json:"ephemeral_public_key"`
	Nonce              []byte `json:"nonce"`
	Ciphertext         []byte `json:"ciphertext"`
}

func WrapWorkspaceKey added in v0.3.3

func WrapWorkspaceKey(workspaceKey, recipientPublicKey []byte, orgID, deviceID string) (Envelope, error)

WrapWorkspaceKey encrypts a workspace key for one authorized device. The server stores only this envelope and never receives the plaintext key.

type Organization

type Organization struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
	Role string `json:"role"`
}

type OrganizationDevice added in v0.3.3

type OrganizationDevice struct {
	ID          string     `json:"id"`
	UserID      string     `json:"user_id"`
	Name        string     `json:"name"`
	Platform    string     `json:"platform"`
	PublicKey   []byte     `json:"public_key"`
	HasEnvelope bool       `json:"has_envelope"`
	RevokedAt   *time.Time `json:"revoked_at,omitempty"`
}

type ServerPayload

type ServerPayload struct {
	store.Server
	PrivateKey string `json:"private_key,omitempty"`
}

func DecryptServer

func DecryptServer(record EncryptedServer, key []byte) (ServerPayload, error)

func PayloadForServer

func PayloadForServer(server store.Server) ServerPayload

type User

type User struct {
	ID    string `json:"id"`
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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