Documentation
¶
Overview ¶
Package server is a Postgres-backed ComputeID API implementation. Endpoints match the Integration Guide PDF wire contract so the Go SDK and the Python SDK both work against it unchanged.
Index ¶
- func Migrate(ctx context.Context, db DB) error
- type ActionItem
- type ActionRow
- type AgentPassportResponse
- type AgentRegisterRequest
- type AgentRow
- type CanonicalPayload
- type CapabilityResponse
- type CommandTag
- type Config
- type DB
- type DeviceAuthRequest
- type DeviceAuthResponse
- type DeviceRegisterRequest
- type DeviceResponse
- type DeviceRow
- type ListActionsResponse
- type ListAgentsResponse
- type LogActionRequest
- type RevokeRequest
- type Row
- type Rows
- type Server
- type Signer
- type Tx
- type VerifyResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionItem ¶
type ActionItem struct {
ActionID string `json:"action_id"`
Action string `json:"action"`
Details map[string]any `json:"details,omitempty"`
Outcome string `json:"outcome"`
Timestamp time.Time `json:"timestamp"`
}
ActionItem is a single audit row.
type ActionRow ¶
type ActionRow struct {
ActionID string
Action string
Details map[string]any
Outcome string
OccurredAt time.Time
}
ActionRow is the projected audit-log row.
type AgentPassportResponse ¶
type AgentPassportResponse struct {
PassportID string `json:"passport_id"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Organization string `json:"organization,omitempty"`
Status string `json:"status"`
PublicKey string `json:"public_key,omitempty"`
Signature string `json:"signature"`
SignatureAlgorithm string `json:"signature_algorithm"`
Capabilities []string `json:"capabilities"`
IssuedAt time.Time `json:"issued_at"`
}
AgentPassportResponse matches the 201 body documented in the Integration Guide PDF. Field order and JSON tags are stable.
type AgentRegisterRequest ¶
type AgentRegisterRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Organization string `json:"organization"`
Capabilities []string `json:"capabilities"`
}
AgentRegisterRequest matches POST /v1/agents/register.
type AgentRow ¶
type AgentRow struct {
PassportID string
Name string
Description string
Organization string
Capabilities []string
Status string
PublicKeyPEM string
SignatureB64 string
SignatureAlgorithm string
SignedPayload []byte
IssuedAt time.Time
RevokedAt *time.Time
RevokeReason string
}
AgentRow is the projected row type the handlers and store agree on.
type CanonicalPayload ¶
type CanonicalPayload struct {
PassportID string `json:"passport_id"`
Name string `json:"name"`
Organization string `json:"organization"`
Capabilities []string `json:"capabilities"`
IssuedAt string `json:"issued_at"` // RFC3339Nano
}
CanonicalPayload is the subset of the passport that is signed at issuance. Fixed key order keeps signatures reproducible across runs.
type CapabilityResponse ¶
type CapabilityResponse struct {
Granted bool `json:"granted"`
Capability string `json:"capability,omitempty"`
Scope map[string]any `json:"scope,omitempty"`
BoundAt *time.Time `json:"bound_at,omitempty"`
Reason string `json:"reason,omitempty"`
}
CapabilityResponse matches GET /v1/agents/{id}/capabilities/{name}.
type CommandTag ¶
type CommandTag interface {
RowsAffected() int64
}
CommandTag describes the result of an Exec.
type Config ¶
Config configures New. AdminToken is optional; when non-empty, the dev-only admin endpoints (currently `POST /api/devices/{id}/approve`) require a matching `X-Admin-Token` header. When empty, they are open — appropriate only for local development.
type DB ¶
type DB interface {
Exec(ctx context.Context, sql string, args ...any) (CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) Row
Begin(ctx context.Context) (Tx, error)
Close()
}
DB is the minimal driver surface used by the server (pgx-shaped, but abstracted so tests can substitute a fake later).
type DeviceAuthRequest ¶
type DeviceAuthRequest struct {
DeviceCode string `json:"device_code"`
}
DeviceAuthRequest matches POST /api/devices/authenticate.
type DeviceAuthResponse ¶
type DeviceAuthResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresAt time.Time `json:"expires_at"`
}
DeviceAuthResponse mirrors the production JWT exchange.
type DeviceRegisterRequest ¶
type DeviceRegisterRequest struct {
Name string `json:"name"`
DeviceType string `json:"type"`
IPAddress string `json:"ip_address"`
}
DeviceRegisterRequest matches POST /api/devices/register.
type DeviceResponse ¶
type DeviceResponse struct {
DeviceID string `json:"device_id"`
DeviceCode string `json:"device_code"`
Name string `json:"name"`
DeviceType string `json:"type"`
IPAddress string `json:"ip_address,omitempty"`
Status string `json:"status"`
IssuedAt time.Time `json:"issued_at"`
}
DeviceResponse matches the body returned by register / approve / list.
type DeviceRow ¶
type DeviceRow struct {
DeviceID string
DeviceCode string
Name string
DeviceType string
IPAddress string
Status string
IssuedAt time.Time
ApprovedAt *time.Time
}
DeviceRow is the projected device row.
type ListActionsResponse ¶
type ListActionsResponse struct {
Actions []ActionItem `json:"actions"`
}
ListActionsResponse matches GET /v1/agents/{id}/actions.
type ListAgentsResponse ¶
type ListAgentsResponse struct {
Agents []AgentPassportResponse `json:"agents"`
}
ListAgentsResponse matches GET /v1/agents.
type LogActionRequest ¶
type LogActionRequest struct {
Action string `json:"action"`
Details map[string]any `json:"details"`
Outcome string `json:"outcome"`
}
LogActionRequest matches POST /v1/agents/{id}/actions.
type RevokeRequest ¶
type RevokeRequest struct {
Reason string `json:"reason"`
}
RevokeRequest matches DELETE /v1/agents/{id}/revoke.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP handler bundle.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer issues RSA-2048 / SHA-256 signatures over canonical passport JSON. Matches the signature_algorithm == "RSA-SHA256" string returned by the production ComputeID API.
func LoadOrInitSigner ¶
LoadOrInitSigner reads the singleton RSA key from the signing_keys table, or generates and persists a fresh one if the table is empty.
func (*Signer) PublicKeyPEM ¶
PublicKeyPEM returns the PEM-encoded public key issued passports carry.
func (*Signer) Sign ¶
func (s *Signer) Sign(p CanonicalPayload) (sigB64 string, signedJSON []byte, err error)
Sign returns a base64-encoded RSA-PKCS1v15 signature over a canonical JSON of the payload, plus the JSON bytes that were actually signed (stored in the agents row so Verify can recompute later).
type Tx ¶
type Tx interface {
Exec(ctx context.Context, sql string, args ...any) (CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) Row
Commit(ctx context.Context) error
Rollback(ctx context.Context) error
}
Tx is a database transaction.
type VerifyResponse ¶
type VerifyResponse struct {
PassportID string `json:"passport_id"`
Status string `json:"status"`
SignatureValid bool `json:"signature_valid"`
Capabilities []string `json:"capabilities"`
IssuedAt time.Time `json:"issued_at"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
}
VerifyResponse matches GET /v1/agents/{id}/verify.