Documentation
¶
Index ¶
- type APIError
- type ChallengeResult
- type Client
- func (c *Client) AssignDomain(ctx context.Context, domainID string, deviceIDs []string) ([]DomainAssignment, error)
- func (c *Client) CreateACMEChallenge(ctx context.Context, digest, hostname string) (*ChallengeResult, error)
- func (c *Client) CreateInvite(ctx context.Context) (*InviteResult, error)
- func (c *Client) DeleteACMEChallenge(ctx context.Context, id string) error
- func (c *Client) DeleteDomain(ctx context.Context, domainID string) error
- func (c *Client) DeviceID() string
- func (c *Client) Enroll(ctx context.Context) (*EnrollResult, error)
- func (c *Client) EnrollWithRecovery(ctx context.Context, bundle *RecoveryBundleInput) (*EnrollResult, error)
- func (c *Client) GetDeviceInfo(ctx context.Context) (*DeviceInfo, error)
- func (c *Client) GetVouchers(ctx context.Context) ([]VoucherArtifact, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) JoinAccount(ctx context.Context, inviteCode string) error
- func (c *Client) LeaveAccount(ctx context.Context) error
- func (c *Client) ListAssignments(ctx context.Context, domainID string) ([]DomainAssignment, error)
- func (c *Client) ListDomains(ctx context.Context) ([]DomainInfo, error)
- func (c *Client) Ready(ctx context.Context) error
- func (c *Client) RegisterDomain(ctx context.Context, domain string) (*DomainInfo, error)
- func (c *Client) RequestNexusToken(ctx context.Context, stage int, sessionNonce string) (string, error)
- func (c *Client) SetHostname(ctx context.Context, hostname string) error
- func (c *Client) SignVoucher(ctx context.Context, requestID, quoteB64 string) error
- func (c *Client) UnassignDomain(ctx context.Context, domainID, deviceID string) error
- func (c *Client) VerifyDomain(ctx context.Context, domainID string) (*DomainInfo, error)
- func (c *Client) VerifyToken(ctx context.Context, token string) (*VerifyResult, error)
- type DeviceInfo
- type DomainAssignment
- type DomainInfo
- type EnrollResult
- type InviteResult
- type Option
- func WithDeviceID(id string) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithInsecureSkipVerify() Option
- func WithNoRetry() Option
- func WithRateLimit(requestsPerSecond float64, burst int) Option
- func WithReconnectJitter(maxDelay time.Duration) Option
- func WithRetry(maxAttempts int, baseDelay, maxDelay time.Duration) Option
- type PendingVoucherRequest
- type RecoveryBundleInput
- type VerifyResult
- type VoucherArtifact
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶ added in v0.1.5
type APIError struct {
StatusCode int
Message string
RetryAfter time.Duration // parsed from Retry-After header; zero if absent
}
APIError represents an HTTP error response from the namek server.
func (*APIError) IsRetryable ¶ added in v0.1.5
IsRetryable returns true for status codes that indicate the request can be retried.
type ChallengeResult ¶
ChallengeResult is returned from POST /acme/challenges.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client for the namek server API.
func (*Client) AssignDomain ¶ added in v0.1.2
func (c *Client) AssignDomain(ctx context.Context, domainID string, deviceIDs []string) ([]DomainAssignment, error)
AssignDomain calls POST /api/v1/domains/:id/assignments (authenticated).
func (*Client) CreateACMEChallenge ¶
func (c *Client) CreateACMEChallenge(ctx context.Context, digest, hostname string) (*ChallengeResult, error)
CreateACMEChallenge calls POST /api/v1/acme/challenges (authenticated). hostname is optional: if empty, the challenge targets the device's canonical hostname. To target a custom hostname, pass the full FQDN (e.g. "mydevice.example.com").
func (*Client) CreateInvite ¶ added in v0.1.4
func (c *Client) CreateInvite(ctx context.Context) (*InviteResult, error)
CreateInvite calls POST /api/v1/accounts/invite (authenticated).
func (*Client) DeleteACMEChallenge ¶
DeleteACMEChallenge calls DELETE /api/v1/acme/challenges/:id (authenticated).
func (*Client) DeleteDomain ¶ added in v0.1.2
DeleteDomain calls DELETE /api/v1/domains/:id (authenticated).
func (*Client) Enroll ¶
func (c *Client) Enroll(ctx context.Context) (*EnrollResult, error)
Enroll performs the 2-phase enrollment flow.
func (*Client) EnrollWithRecovery ¶ added in v0.1.4
func (c *Client) EnrollWithRecovery(ctx context.Context, bundle *RecoveryBundleInput) (*EnrollResult, error)
EnrollWithRecovery performs the 2-phase enrollment flow with a recovery bundle.
func (*Client) GetDeviceInfo ¶
func (c *Client) GetDeviceInfo(ctx context.Context) (*DeviceInfo, error)
GetDeviceInfo calls GET /api/v1/devices/me (authenticated).
func (*Client) GetVouchers ¶ added in v0.1.4
func (c *Client) GetVouchers(ctx context.Context) ([]VoucherArtifact, error)
GetVouchers calls GET /api/v1/vouchers (authenticated).
func (*Client) Health ¶
Health calls GET /health. Bypasses jitter and degraded tracking intentionally — health probes should not be delayed, and are typically used as readiness gates.
func (*Client) JoinAccount ¶ added in v0.1.4
JoinAccount calls POST /api/v1/accounts/join (authenticated).
func (*Client) LeaveAccount ¶ added in v0.1.4
LeaveAccount calls DELETE /api/v1/accounts/leave (authenticated).
func (*Client) ListAssignments ¶ added in v0.1.2
ListAssignments calls GET /api/v1/domains/:id/assignments (authenticated).
func (*Client) ListDomains ¶ added in v0.1.2
func (c *Client) ListDomains(ctx context.Context) ([]DomainInfo, error)
ListDomains calls GET /api/v1/domains (authenticated).
func (*Client) Ready ¶
Ready calls GET /ready. Bypasses jitter and degraded tracking (same rationale as Health).
func (*Client) RegisterDomain ¶ added in v0.1.2
RegisterDomain calls POST /api/v1/domains (authenticated).
func (*Client) RequestNexusToken ¶
func (c *Client) RequestNexusToken(ctx context.Context, stage int, sessionNonce string) (string, error)
RequestNexusToken calls POST /api/v1/tokens/nexus (authenticated).
func (*Client) SetHostname ¶
SetHostname calls PATCH /api/v1/devices/me/hostname (authenticated).
func (*Client) SignVoucher ¶ added in v0.1.4
SignVoucher calls POST /api/v1/vouchers/sign (authenticated).
func (*Client) UnassignDomain ¶ added in v0.1.2
UnassignDomain calls DELETE /api/v1/domains/:id/assignments/:device_id (authenticated).
func (*Client) VerifyDomain ¶ added in v0.1.2
VerifyDomain calls POST /api/v1/domains/:id/verify (authenticated).
func (*Client) VerifyToken ¶
VerifyToken calls POST /internal/v1/tokens/verify (Nexus mTLS-authenticated).
type DeviceInfo ¶
type DeviceInfo struct {
DeviceID string `json:"device_id"`
Hostname string `json:"hostname"`
CustomHostname *string `json:"custom_hostname"`
AccountID string `json:"account_id"`
Status string `json:"status"`
IdentityClass string `json:"identity_class"`
TrustLevel string `json:"trust_level"`
IssuerFingerprint *string `json:"issuer_fingerprint,omitempty"`
OSVersion *string `json:"os_version,omitempty"`
RecoveryStatus string `json:"recovery_status"`
NexusEndpoints []string `json:"nexus_endpoints"`
RelayServices map[string][]string `json:"relay_services,omitempty"`
AliasDomains []string `json:"alias_domains,omitempty"`
PendingVoucherRequests []PendingVoucherRequest `json:"pending_voucher_requests,omitempty"`
NewVouchers []VoucherArtifact `json:"new_vouchers,omitempty"`
}
DeviceInfo is returned from GET /devices/me.
type DomainAssignment ¶ added in v0.1.2
type DomainAssignment struct {
DeviceID string `json:"device_id"`
Domain string `json:"domain"`
CreatedAt string `json:"created_at"`
}
DomainAssignment represents a device-to-domain assignment.
type DomainInfo ¶ added in v0.1.2
type DomainInfo struct {
ID string `json:"id"`
AccountID string `json:"account_id"`
Domain string `json:"domain"`
Status string `json:"status"` // "pending" or "verified"
CNAMETarget string `json:"cname_target"`
AssignedDevices []string `json:"assigned_devices,omitempty"`
CreatedAt string `json:"created_at"`
ExpiresAt string `json:"expires_at,omitempty"`
VerifiedAt string `json:"verified_at,omitempty"`
VerifiedByDeviceID string `json:"verified_by_device_id,omitempty"`
}
DomainInfo represents an alias domain registered with the namek server.
type EnrollResult ¶
type EnrollResult struct {
DeviceID string `json:"device_id"`
Hostname string `json:"hostname"`
IdentityClass string `json:"identity_class"`
TrustLevel string `json:"trust_level"`
NexusEndpoints []string `json:"nexus_endpoints"`
RelayServices map[string][]string `json:"relay_services,omitempty"`
Reenrolled bool `json:"reenrolled,omitempty"`
}
EnrollResult is returned after successful enrollment.
type InviteResult ¶ added in v0.1.4
type InviteResult struct {
InviteCode string `json:"invite_code"`
AccountID string `json:"account_id"`
ExpiresAt string `json:"expires_at"`
}
InviteResult is returned from POST /accounts/invite.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithDeviceID ¶
WithDeviceID restores a previously-enrolled device ID, allowing the client to make authenticated requests without re-enrolling.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithInsecureSkipVerify ¶
func WithInsecureSkipVerify() Option
WithInsecureSkipVerify disables TLS certificate verification. Must be applied after WithHTTPClient if both are used.
func WithNoRetry ¶ added in v0.1.5
func WithNoRetry() Option
WithNoRetry disables automatic retry (useful for testing).
func WithRateLimit ¶ added in v0.1.5
WithRateLimit enables client-side rate limiting to prevent overwhelming the server. requestsPerSecond is the sustained rate, burst is the maximum concurrent burst.
func WithReconnectJitter ¶ added in v0.1.5
WithReconnectJitter sets the maximum random delay applied before the first request after a failure. This spreads the thundering herd when many clients recover simultaneously (e.g., after a server outage). Default: disabled.
type PendingVoucherRequest ¶ added in v0.1.4
type PendingVoucherRequest struct {
RequestID string `json:"request_id"`
VoucherData string `json:"voucher_data"`
Nonce string `json:"nonce"`
}
PendingVoucherRequest is a voucher that needs signing.
type RecoveryBundleInput ¶ added in v0.1.4
type RecoveryBundleInput struct {
AccountID string
Vouchers []VoucherArtifact
CustomHostname string
AliasDomains []string
}
RecoveryBundleInput is the recovery bundle included in the attest request.
type VerifyResult ¶
VerifyResult is returned from POST /tokens/verify.