Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildPayload ¶
BuildPayload produces a canonical JSON representation of the struct fields, excluding any field tagged with `hmac:"-"`.
The canonical form is a JSON object with keys sorted alphabetically, produced by json.Marshal over a map[string]any. This guarantees:
- Deterministic key ordering (Go sorts map keys in json.Marshal)
- Proper escaping of special characters in values
- Empty fields are always included (no omitempty)
- No ambiguity from custom serialization formats
Types ¶
type Signable ¶
Signable is the minimal interface for HMAC-verifiable structs. Any struct embedding Signature satisfies this automatically.
type Signature ¶
type Signature struct {
Timestamp int64 `json:"timestamp"`
Signature string `json:"signature" hmac:"-"`
}
Signature is an embeddable struct that provides HMAC signature support with mandatory timestamp for anti-replay protection. Embed it in any request struct to make it verifiable via Verify.
type RegisterPlanRequest struct {
hmac.Signature
Persistence string `json:"repo"`
PlanOutput string `json:"plan_output"`
}
func (Signature) GetTimestamp ¶
GetTimestamp returns the request timestamp for anti-replay validation.
func (Signature) SignatureBytes ¶
SignatureBytes returns the signature as a byte slice.