Documentation
¶
Overview ¶
Package beacons is a thin client for the Truestamp Beacons JSON:API surface (GET /api/json/beacons, /beacons/latest, /beacons/:id, /beacons/by-hash/:hash). A Beacon is a compact "proof of life" projection of a finalized block: {id, hash, timestamp, previous_hash}. The server side is documented in truestamp-v2/docs/BEACONS_API_IMPLEMENTERS_GUIDE.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("beacon not found") ErrBadRequest = errors.New("bad request") ErrRateLimited = errors.New("rate limited") ErrServer = errors.New("server error") )
Errors surfaced by the client. CLI layers may errors.Is these to pick an exit code and user-facing message.
Functions ¶
func ValidateHash ¶
ValidateHash returns nil iff s is exactly 64 lowercase hex characters. Exported so cobra commands can run this client-side before the network.
func ValidateUUIDv7 ¶
ValidateUUIDv7 returns nil iff s parses as a UUID whose version nibble is 7.
Types ¶
type APIError ¶
type APIError struct {
Status int
Detail string // preferred; falls back to Title
RetryAfter string // verbatim Retry-After header on 429
// contains filtered or unexported fields
}
APIError carries HTTP status + preserved `errors[].detail` from the JSON:API envelope for display to the user. Wraps one of the sentinel errors above so callers can errors.Is() the class while still showing the detail text.
type Beacon ¶
type Beacon struct {
ID string `json:"id"` // UUIDv7
Hash string `json:"hash"` // 64 lowercase hex
Timestamp string `json:"timestamp"` // ISO 8601 UTC
PreviousHash string `json:"previous_hash"` // 64 lowercase hex
}
Beacon is the JSON shape returned by every beacon endpoint. All four fields are always present on success; a missing field is treated as a parse error rather than recovered from.
type Config ¶
type Config struct {
APIURL string // e.g. https://www.truestamp.com/api/json
APIKey string // Bearer token (never logged)
Team string // optional tenant id
}
Config carries the subset of runtime configuration needed for a request. Kept small to avoid importing the top-level config package.