transport

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateNonce

func GenerateNonce() string

GenerateNonce generates a random nonce for replay protection. Returns a 16-byte random value encoded as hex (32 characters).

func ParseErrorResponse

func ParseErrorResponse(resp *http.Response) error

ParseErrorResponse parses an error response from the API.

func ParsePrivateKey

func ParsePrivateKey(raw ed25519.PrivateKey, hexKey, base64Key string) (ed25519.PrivateKey, error)

ParsePrivateKey parses a private key from various formats. Supports: raw ed25519.PrivateKey, hex string, base64 DER.

Types

type APIError

type APIError struct {
	StatusCode int
	Code       string
	Message    string
}

APIError represents an error returned by the remote-signer API. Defined here so transport can construct it; re-exported from the root client package.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

func (*APIError) IsCode

func (e *APIError) IsCode(code string) bool

IsCode checks if the error has the given error code string.

func (*APIError) IsStatusCode

func (e *APIError) IsStatusCode(code int) bool

IsStatusCode checks if the error has the given HTTP status code.

type Auth

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

Auth handles Ed25519 request signing.

func NewAuth

func NewAuth(privateKey ed25519.PrivateKey) *Auth

NewAuth creates a new Auth from a private key.

func (*Auth) SignRequest

func (a *Auth) SignRequest(timestamp int64, nonce, method, path string, body []byte) string

SignRequest creates the Ed25519 signature for a request with nonce. Format: {timestamp}|{nonce}|{method}|{path}|{sha256(body)}

type Config

type Config struct {
	BaseURL    string
	APIKeyID   string
	HTTPClient *http.Client
	TLS        *TLSConfig
}

Config holds configuration for creating a new Transport.

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error"`
	Message string `json:"message"`
}

ErrorResponse represents an error response from the API.

type TLSConfig

type TLSConfig struct {
	CAFile     string
	CertFile   string
	KeyFile    string
	SkipVerify bool
}

TLSConfig holds TLS configuration.

type Transport

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

Transport handles HTTP communication with the remote-signer service.

func NewTransport

func NewTransport(cfg Config, auth *Auth) (*Transport, error)

NewTransport creates a new Transport with the given configuration.

func (*Transport) BaseURL

func (t *Transport) BaseURL() string

BaseURL returns the base URL.

func (*Transport) Request

func (t *Transport) Request(ctx context.Context, method, path string, body interface{}, result interface{}, acceptedStatuses ...int) error

Request performs an authenticated JSON request and decodes the response into result.

func (*Transport) RequestNoAuth

func (t *Transport) RequestNoAuth(ctx context.Context, method, path string) (*http.Response, error)

RequestNoAuth performs an unauthenticated request (for /health, /metrics).

func (*Transport) RequestRaw

func (t *Transport) RequestRaw(ctx context.Context, method, path string, body []byte, acceptedStatuses ...int) ([]byte, error)

RequestRaw performs an authenticated request and returns the raw response body as bytes.

Jump to

Keyboard shortcuts

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