ProofedMesh/services/admin-api/internal/attest/ratechange.go
CTO Agent 65514559dc
Some checks failed
validate / Rego (opa fmt + opa test) (push) Successful in 12s
validate / JSON Schema (ajv) (push) Has been cancelled
services: add admin-api Go service (per-diem rates CRUD, in-memory + Postgres stub store, HTML templates, 13/13 go tests pass, go vet clean)
2026-10-25 17:28:14 +00:00

49 lines
1.4 KiB
Go

// Package attest hands off a rate-change event to the Signing Service and
// returns the SHA-256 of the signed attestation envelope. Current state:
// Stub — PERSUB will be wired in Phase-2.
package attest
import (
"context"
"errors"
"basicstack.de/proofedmesh/services/admin-api/internal/model"
)
type ChangeKind string
const (
ChangeCreate ChangeKind = "create"
ChangeRetire ChangeKind = "retire"
)
// RateChangeEvent is what we hand to the Signing Service.
type RateChangeEvent struct {
Kind ChangeKind
Rate model.Rate
PerformedBy PerformedBy
PerformedAtRFC3339 string
}
type PerformedBy struct {
Issuer string
Subject string
SessionID string
}
// Signer issues a signed rate_change attestation and returns the content hash
// (sha256:...) under which it is stored in the Transparency Log.
type Signer interface {
SignRateChange(ctx context.Context, ev RateChangeEvent) (attestationRef string, err error)
}
// NopSigner is a placeholder that lets the admin-api start without a real
// Signing Service. It must not be used in production — the HTTP layer gates
// its usage behind a startup flag.
type NopSigner struct{}
var errNopNotForProd = errors.New("attest.NopSigner is a stub and must not be used in production")
func (NopSigner) SignRateChange(ctx context.Context, ev RateChangeEvent) (string, error) {
return "", errNopNotForProd
}