namekclient

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChallengeResult

type ChallengeResult struct {
	ID   string `json:"id"`
	FQDN string `json:"fqdn"`
}

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 New

func New(baseURL string, tpm tpmdevice.Device, opts ...Option) *Client

New creates a namekclient that uses the given TPM device for attestation.

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 string) (*ChallengeResult, error)

CreateACMEChallenge calls POST /api/v1/acme/challenges (authenticated).

func (*Client) DeleteACMEChallenge

func (c *Client) DeleteACMEChallenge(ctx context.Context, id string) error

DeleteACMEChallenge calls DELETE /api/v1/acme/challenges/:id (authenticated).

func (*Client) DeleteDomain added in v0.1.2

func (c *Client) DeleteDomain(ctx context.Context, domainID string) error

DeleteDomain calls DELETE /api/v1/domains/:id (authenticated).

func (*Client) DeviceID

func (c *Client) DeviceID() string

DeviceID returns the current device ID, or empty if not yet enrolled.

func (*Client) Enroll

func (c *Client) Enroll(ctx context.Context) (*EnrollResult, error)

Enroll performs the 2-phase enrollment flow.

func (*Client) GetDeviceInfo

func (c *Client) GetDeviceInfo(ctx context.Context) (*DeviceInfo, error)

GetDeviceInfo calls GET /api/v1/devices/me (authenticated).

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health calls GET /health.

func (*Client) ListAssignments added in v0.1.2

func (c *Client) ListAssignments(ctx context.Context, domainID string) ([]DomainAssignment, error)

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

func (c *Client) Ready(ctx context.Context) error

Ready calls GET /ready.

func (*Client) RegisterDomain added in v0.1.2

func (c *Client) RegisterDomain(ctx context.Context, domain string) (*DomainInfo, error)

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

func (c *Client) SetHostname(ctx context.Context, hostname string) error

SetHostname calls PATCH /api/v1/devices/me/hostname (authenticated).

func (*Client) UnassignDomain added in v0.1.2

func (c *Client) UnassignDomain(ctx context.Context, domainID, deviceID string) error

UnassignDomain calls DELETE /api/v1/domains/:id/assignments/:device_id (authenticated).

func (*Client) VerifyDomain added in v0.1.2

func (c *Client) VerifyDomain(ctx context.Context, domainID string) (*DomainInfo, error)

VerifyDomain calls POST /api/v1/domains/:id/verify (authenticated).

func (*Client) VerifyToken

func (c *Client) VerifyToken(ctx context.Context, token string) (*VerifyResult, error)

VerifyToken calls POST /api/v1/tokens/verify (no auth).

type DeviceInfo

type DeviceInfo struct {
	DeviceID       string   `json:"device_id"`
	Hostname       string   `json:"hostname"`
	CustomHostname *string  `json:"custom_hostname"`
	Status         string   `json:"status"`
	IdentityClass  string   `json:"identity_class"`
	NexusEndpoints []string `json:"nexus_endpoints"`
	AliasDomains   []string `json:"alias_domains,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"`
	NexusEndpoints []string `json:"nexus_endpoints"`
	Reenrolled     bool     `json:"reenrolled,omitempty"`
}

EnrollResult is returned after successful enrollment.

type Option

type Option func(*Client)

Option configures a Client.

func WithDeviceID

func WithDeviceID(id string) Option

WithDeviceID restores a previously-enrolled device ID, allowing the client to make authenticated requests without re-enrolling.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

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.

type VerifyResult

type VerifyResult struct {
	Valid bool   `json:"valid"`
	Error string `json:"error,omitempty"`
}

VerifyResult is returned from POST /tokens/verify.

Jump to

Keyboard shortcuts

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