Documentation
¶
Index ¶
- Constants
- Variables
- type APIError
- type Agent
- type AgentKey
- type Domain
- type EpochTime
- type KeyLoadError
- type Options
- type RevokeAgentKeyRequest
- type RevokeAgentKeyResponse
- type RotateAgentKeyRequest
- type RotateAgentKeyResponse
- type TetherClient
- func (c *TetherClient) CreateAgent(ctx context.Context, agentName string, description string, domainID ...string) (*Agent, error)
- func (c *TetherClient) DeleteAgent(ctx context.Context, agentID string) (bool, error)
- func (c *TetherClient) ListAgentKeys(ctx context.Context, agentID string) ([]AgentKey, error)
- func (c *TetherClient) ListAgents(ctx context.Context) ([]Agent, error)
- func (c *TetherClient) ListDomains(ctx context.Context) ([]Domain, error)
- func (c *TetherClient) RequestChallenge(ctx context.Context) (string, error)
- func (c *TetherClient) RevokeAgentKey(ctx context.Context, agentID, keyID string, reqBody RevokeAgentKeyRequest) (*RevokeAgentKeyResponse, error)
- func (c *TetherClient) RotateAgentKey(ctx context.Context, agentID string, reqBody RotateAgentKeyRequest) (*RotateAgentKeyResponse, error)
- func (c *TetherClient) Sign(challenge string) (string, error)
- func (c *TetherClient) SubmitProof(ctx context.Context, challenge, proof string) (*VerificationResult, error)
- func (c *TetherClient) UpdateAgentDomain(ctx context.Context, agentID string, domainID string) (*UpdateAgentResponse, error)
- func (c *TetherClient) Verify(ctx context.Context) (*VerificationResult, error)
- type UpdateAgentResponse
- type VerificationError
- type VerificationResult
Constants ¶
const ( // DefaultBaseURL is the default Tether API base URL DefaultBaseURL = "https://api.tether.name" // UserAgent for HTTP requests UserAgent = "tether-go/1.0.8" )
Variables ¶
var ErrAPI = errors.New("API error")
ErrAPI indicates an API communication error
var ErrKeyLoad = errors.New("key load error")
ErrKeyLoad indicates a private key loading error
var ErrVerification = errors.New("verification failed")
ErrVerification indicates a verification failure
Functions ¶
This section is empty.
Types ¶
type Agent ¶ added in v1.0.2
type Agent struct {
ID string `json:"id"`
AgentName string `json:"agentName"`
Description string `json:"description"`
DomainID string `json:"domainId,omitempty"`
Domain string `json:"domain,omitempty"`
CreatedAt int64 `json:"createdAt"`
RegistrationToken string `json:"registrationToken,omitempty"`
LastVerifiedAt int64 `json:"lastVerifiedAt,omitempty"`
}
Agent represents a registered agent
type AgentKey ¶ added in v1.0.6
type AgentKey struct {
ID string `json:"id"`
Status string `json:"status"`
CreatedAt int64 `json:"createdAt"`
ActivatedAt int64 `json:"activatedAt"`
GraceUntil int64 `json:"graceUntil"`
RevokedAt int64 `json:"revokedAt"`
RevokedReason string `json:"revokedReason,omitempty"`
}
AgentKey represents a key lifecycle entry for an agent.
type Domain ¶ added in v1.0.5
type Domain struct {
ID string `json:"id"`
Domain string `json:"domain"`
Verified bool `json:"verified"`
VerifiedAt int64 `json:"verifiedAt,omitempty"`
LastCheckedAt int64 `json:"lastCheckedAt,omitempty"`
CreatedAt int64 `json:"createdAt,omitempty"`
}
Domain represents a registered domain under the authenticated account.
type EpochTime ¶ added in v1.0.1
EpochTime wraps time.Time to handle both epoch millisecond integers and ISO 8601 strings when unmarshaling JSON.
func (EpochTime) MarshalJSON ¶ added in v1.0.1
MarshalJSON outputs as epoch milliseconds for round-trip consistency.
func (*EpochTime) UnmarshalJSON ¶ added in v1.0.1
UnmarshalJSON handles epoch ms (number) or ISO 8601 (string).
type KeyLoadError ¶
KeyLoadError represents a private key loading error
func (*KeyLoadError) Error ¶
func (e *KeyLoadError) Error() string
func (*KeyLoadError) Unwrap ¶
func (e *KeyLoadError) Unwrap() error
type Options ¶
type Options struct {
// AgentID is the unique identifier for this agent (required for verify/sign operations)
AgentID string
// PrivateKeyPath is the file path to the RSA private key (PEM or DER format)
PrivateKeyPath string
// PrivateKeyPEM contains the RSA private key in PEM format as bytes
PrivateKeyPEM []byte
// PrivateKeyDER contains the RSA private key in DER format as bytes
PrivateKeyDER []byte
// ApiKey for management operations (alternative to agent auth)
ApiKey string
}
Options configures the TetherClient
type RevokeAgentKeyRequest ¶ added in v1.0.6
type RevokeAgentKeyRequest struct {
Reason string `json:"reason,omitempty"`
StepUpCode string `json:"stepUpCode,omitempty"`
Challenge string `json:"challenge,omitempty"`
Proof string `json:"proof,omitempty"`
}
RevokeAgentKeyRequest defines payload for revoking an agent key.
type RevokeAgentKeyResponse ¶ added in v1.0.6
type RevokeAgentKeyResponse struct {
AgentID string `json:"agentId"`
KeyID string `json:"keyId"`
Revoked bool `json:"revoked"`
PromotedKeyID string `json:"promotedKeyId,omitempty"`
Message string `json:"message"`
}
RevokeAgentKeyResponse is returned from key revoke endpoint.
type RotateAgentKeyRequest ¶ added in v1.0.6
type RotateAgentKeyRequest struct {
PublicKey string `json:"publicKey"`
GracePeriodHours int `json:"gracePeriodHours,omitempty"`
Reason string `json:"reason,omitempty"`
StepUpCode string `json:"stepUpCode,omitempty"`
Challenge string `json:"challenge,omitempty"`
Proof string `json:"proof,omitempty"`
}
RotateAgentKeyRequest defines payload for rotating an agent key.
type RotateAgentKeyResponse ¶ added in v1.0.6
type RotateAgentKeyResponse struct {
AgentID string `json:"agentId"`
PreviousKeyID string `json:"previousKeyId,omitempty"`
NewKeyID string `json:"newKeyId"`
GraceUntil int64 `json:"graceUntil"`
Message string `json:"message"`
}
RotateAgentKeyResponse is returned from key rotation endpoint.
type TetherClient ¶
type TetherClient struct {
// contains filtered or unexported fields
}
TetherClient represents a client for the Tether API
func NewClient ¶
func NewClient(opts Options) (*TetherClient, error)
NewClient creates a new TetherClient with the given options. When ApiKey is provided, agentID and privateKey become optional (only required for verify/sign operations).
func (*TetherClient) CreateAgent ¶ added in v1.0.2
func (c *TetherClient) CreateAgent(ctx context.Context, agentName string, description string, domainID ...string) (*Agent, error)
CreateAgent creates a new agent. Requires an API key to be configured. domainID is optional. When provided, it assigns this agent to that verified domain.
func (*TetherClient) DeleteAgent ¶ added in v1.0.2
DeleteAgent deletes an agent by ID. Requires an API key to be configured.
func (*TetherClient) ListAgentKeys ¶ added in v1.0.6
ListAgentKeys lists key lifecycle entries for an agent.
func (*TetherClient) ListAgents ¶ added in v1.0.2
func (c *TetherClient) ListAgents(ctx context.Context) ([]Agent, error)
ListAgents lists all agents for the authenticated user. Requires an API key to be configured.
func (*TetherClient) ListDomains ¶ added in v1.0.5
func (c *TetherClient) ListDomains(ctx context.Context) ([]Domain, error)
ListDomains lists all registered domains for the authenticated user. Requires an API key to be configured.
func (*TetherClient) RequestChallenge ¶
func (c *TetherClient) RequestChallenge(ctx context.Context) (string, error)
RequestChallenge requests a new challenge from the Tether API
func (*TetherClient) RevokeAgentKey ¶ added in v1.0.6
func (c *TetherClient) RevokeAgentKey(ctx context.Context, agentID, keyID string, reqBody RevokeAgentKeyRequest) (*RevokeAgentKeyResponse, error)
RevokeAgentKey revokes an agent key with optional step-up auth.
func (*TetherClient) RotateAgentKey ¶ added in v1.0.6
func (c *TetherClient) RotateAgentKey(ctx context.Context, agentID string, reqBody RotateAgentKeyRequest) (*RotateAgentKeyResponse, error)
RotateAgentKey rotates an agent key with optional step-up auth.
func (*TetherClient) Sign ¶
func (c *TetherClient) Sign(challenge string) (string, error)
Sign signs a challenge using the client's private key. Requires a private key to be configured.
func (*TetherClient) SubmitProof ¶
func (c *TetherClient) SubmitProof(ctx context.Context, challenge, proof string) (*VerificationResult, error)
SubmitProof submits a signed challenge proof for verification. Requires agentID to be configured.
func (*TetherClient) UpdateAgentDomain ¶ added in v1.0.8
func (c *TetherClient) UpdateAgentDomain(ctx context.Context, agentID string, domainID string) (*UpdateAgentResponse, error)
UpdateAgentDomain updates which identity is shown when an agent is verified. Pass a verified domainID to show that domain, or pass an empty string to show account email.
func (*TetherClient) Verify ¶
func (c *TetherClient) Verify(ctx context.Context) (*VerificationResult, error)
Verify performs a complete verification flow (request challenge + sign + verify)
type UpdateAgentResponse ¶ added in v1.0.8
type UpdateAgentResponse struct {
ID string `json:"id"`
DomainID string `json:"domainId,omitempty"`
Domain string `json:"domain,omitempty"`
Message string `json:"message,omitempty"`
}
UpdateAgentResponse is the response payload for PATCH /agents/{id}
type VerificationError ¶
VerificationError represents a verification failure with details
func (*VerificationError) Error ¶
func (e *VerificationError) Error() string
func (*VerificationError) Unwrap ¶
func (e *VerificationError) Unwrap() error
type VerificationResult ¶
type VerificationResult struct {
// Verified indicates if the agent identity was successfully verified
Verified bool `json:"verified"`
// AgentName is the registered name of the agent
AgentName string `json:"agentName,omitempty"`
// VerifyURL is the public URL to verify this challenge result
VerifyURL string `json:"verifyUrl,omitempty"`
// Email is the email address associated with the agent
Email string `json:"email,omitempty"`
// Domain is the verified domain associated with this agent (if assigned)
Domain string `json:"domain,omitempty"`
// RegisteredSince is when this agent was first registered
RegisteredSince *EpochTime `json:"registeredSince,omitempty"`
// Error contains any error message if verification failed
Error string `json:"error,omitempty"`
// Challenge is the challenge code that was verified
Challenge string `json:"challenge,omitempty"`
}
VerificationResult contains the result of a verification attempt