mirror of
https://github.com/hanzoai/kms.git
synced 2026-10-17 11:18:16 +00:00
Go 1.27.1, and the code it can say more simply
Both modules declare go 1.27.1 and the build images follow. go fix applied the modernizers: promoted-field keys in struct literals, SplitSeq, strings.Cut, new(expr), slices.Contains and any. The ptr helper had no callers left once new(expr) could say it. omitzero is not applied; it changes what the JSON says, so it is a per-field decision. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
# Hanzo KMS: a thin wrapper over luxfi/kms, built in pure Go. The console in
|
||||
# frontend/ is a static site published on its own and is not part of this image.
|
||||
|
||||
FROM golang:1.26-bookworm AS build
|
||||
FROM golang:1.27.1-bookworm AS build
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
# volumeMounts:
|
||||
# - { name: secrets, mountPath: /secrets }
|
||||
|
||||
FROM golang:1.26-bookworm AS build
|
||||
FROM golang:1.27.1-bookworm AS build
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ func checkAudience(mc jwt.MapClaims, expected string) error {
|
||||
// Expand comma-separated expected list into a set. Empty entries and
|
||||
// surrounding whitespace are ignored.
|
||||
want := make(map[string]struct{})
|
||||
for _, e := range strings.Split(expected, ",") {
|
||||
for e := range strings.SplitSeq(expected, ",") {
|
||||
if s := strings.TrimSpace(e); s != "" {
|
||||
want[s] = struct{}{}
|
||||
}
|
||||
@@ -286,7 +286,7 @@ func checkAudience(mc jwt.MapClaims, expected string) error {
|
||||
// Trailing slashes are normalized on both sides. Mirrors checkAudience.
|
||||
func checkIssuer(got, expected string) error {
|
||||
got = strings.TrimRight(got, "/")
|
||||
for _, e := range strings.Split(expected, ",") {
|
||||
for e := range strings.SplitSeq(expected, ",") {
|
||||
if s := strings.TrimRight(strings.TrimSpace(e), "/"); s != "" && s == got {
|
||||
return nil
|
||||
}
|
||||
@@ -374,8 +374,8 @@ func authFailReason(err error) string {
|
||||
// Honours X-Forwarded-For when present (gateway is trusted upstream).
|
||||
func peerIP(r *http.Request) string {
|
||||
if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
|
||||
if i := strings.IndexByte(xff, ','); i >= 0 {
|
||||
return strings.TrimSpace(xff[:i])
|
||||
if before, _, ok := strings.Cut(xff, ","); ok {
|
||||
return strings.TrimSpace(before)
|
||||
}
|
||||
return strings.TrimSpace(xff)
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ func (z *kmsclientFetcher) Close() error {
|
||||
// kmsclient.Get(path, name) and zapclient.GetAt(path, name, env).
|
||||
func parseSpecs(raw string) ([]spec, error) {
|
||||
var out []spec
|
||||
for _, item := range strings.Split(raw, ",") {
|
||||
for item := range strings.SplitSeq(raw, ",") {
|
||||
item = strings.TrimSpace(item)
|
||||
if item == "" {
|
||||
continue
|
||||
|
||||
@@ -58,10 +58,8 @@ func initTelemetry(_ context.Context, serviceName string) func(context.Context)
|
||||
}
|
||||
|
||||
tracer, err := trace.New(trace.Config{
|
||||
ExporterConfig: trace.ExporterConfig{
|
||||
Type: trace.ZAP,
|
||||
Endpoint: endpoint,
|
||||
},
|
||||
TraceSampleRate: 1,
|
||||
AppName: serviceName,
|
||||
})
|
||||
|
||||
+2
-4
@@ -214,8 +214,6 @@ func zero(b []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func ptr(a node.Address) *node.Address { return &a }
|
||||
|
||||
// Enroll mints a node identity for subject in org, or returns the one it
|
||||
// already has.
|
||||
//
|
||||
@@ -597,7 +595,7 @@ func (s *Store) Rotate(org string, address node.Address, subject string, ev node
|
||||
}
|
||||
defer returnKey(successor)
|
||||
|
||||
nextRec, sealed, err := s.mint(org, subject, successor, prev.Measurement, prev.TEE, prev.Attested, ptr(prev.Address))
|
||||
nextRec, sealed, err := s.mint(org, subject, successor, prev.Measurement, prev.TEE, prev.Attested, new(prev.Address))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -612,7 +610,7 @@ func (s *Store) Rotate(org string, address node.Address, subject string, ev node
|
||||
handover := &node.Handover{Succession: statement, Digest: digest, Signature: sig}
|
||||
|
||||
prev.Status = node.Superseded
|
||||
prev.Next = ptr(nextRec.Address)
|
||||
prev.Next = new(nextRec.Address)
|
||||
prev.Succession = handover
|
||||
prev.Epoch = epoch
|
||||
prev.UpdatedAt = time.Now().UTC()
|
||||
|
||||
@@ -675,15 +675,15 @@ func normalizeS3Endpoint(raw string) (host string, useSSL bool) {
|
||||
|
||||
type zapdbLogger struct{}
|
||||
|
||||
func (zapdbLogger) Errorf(format string, args ...interface{}) {
|
||||
func (zapdbLogger) Errorf(format string, args ...any) {
|
||||
log.Error(fmt.Sprintf(format, args...))
|
||||
}
|
||||
func (zapdbLogger) Warningf(format string, args ...interface{}) {
|
||||
func (zapdbLogger) Warningf(format string, args ...any) {
|
||||
log.Warn(fmt.Sprintf(format, args...))
|
||||
}
|
||||
func (zapdbLogger) Infof(format string, args ...interface{}) {
|
||||
func (zapdbLogger) Infof(format string, args ...any) {
|
||||
log.Info(fmt.Sprintf(format, args...))
|
||||
}
|
||||
func (zapdbLogger) Debugf(format string, args ...interface{}) {
|
||||
func (zapdbLogger) Debugf(format string, args ...any) {
|
||||
log.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ module github.com/hanzoai/kms
|
||||
// Wire-compatible with luxfi clients on both HTTP (/v1/kms/*) and ZAP
|
||||
// (opcodes 0x0040..0x0043).
|
||||
|
||||
go 1.26.8
|
||||
go 1.27.1
|
||||
|
||||
// luxfi/keys + luxfi/kms drive the consensus-native ZAP secret surface.
|
||||
// Threshold signing is delegated over ZAP to an external luxfi/mpc daemon
|
||||
@@ -18,28 +18,15 @@ go 1.26.8
|
||||
// require block below (single source of truth).
|
||||
require (
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/luxfi/keys v1.4.2 // indirect
|
||||
github.com/hanzoai/kms/sdk/go v1.1.6
|
||||
github.com/luxfi/crypto v1.20.5
|
||||
github.com/luxfi/ids v1.3.2
|
||||
github.com/luxfi/kms v1.12.26
|
||||
github.com/luxfi/log v1.4.3
|
||||
github.com/luxfi/trace v1.3.0
|
||||
github.com/luxfi/zap v1.2.7
|
||||
github.com/luxfi/zapdb v1.10.6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/hanzoai/kms/sdk/go v1.1.6
|
||||
github.com/luxfi/ids v1.3.2
|
||||
github.com/luxfi/trace v1.3.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/hanzos3/crc64nvme v1.1.2 // indirect
|
||||
github.com/hanzos3/go v1.0.2 // indirect
|
||||
github.com/hanzos3/md5-simd v1.1.3 // indirect
|
||||
github.com/zap-proto/fiber/v3 v3.2.1 // indirect
|
||||
github.com/zap-proto/go v1.8.3 // indirect
|
||||
github.com/zap-proto/http v0.3.9 // indirect
|
||||
github.com/zap-proto/mcp v1.0.5 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
|
||||
github.com/zap-proto/zip v1.36.48
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -61,6 +48,9 @@ require (
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/rpc v1.2.1 // indirect
|
||||
github.com/grandcat/zeroconf v1.0.0 // indirect
|
||||
github.com/hanzos3/crc64nvme v1.1.2 // indirect
|
||||
github.com/hanzos3/go v1.0.2 // indirect
|
||||
github.com/hanzos3/md5-simd v1.1.3 // indirect
|
||||
github.com/holiman/uint256 v1.3.2 // indirect
|
||||
github.com/klauspost/compress v1.18.6 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
@@ -71,10 +61,10 @@ require (
|
||||
github.com/luxfi/cache v1.3.1 // indirect
|
||||
github.com/luxfi/constants v1.6.2 // indirect
|
||||
github.com/luxfi/container v0.2.2 // indirect
|
||||
github.com/luxfi/crypto v1.20.5
|
||||
github.com/luxfi/geth v1.20.2 // indirect
|
||||
github.com/luxfi/go-bip32 v1.1.0 // indirect
|
||||
github.com/luxfi/go-bip39 v1.2.0 // indirect
|
||||
github.com/luxfi/keys v1.4.2 // indirect
|
||||
github.com/luxfi/math v1.5.1 // indirect
|
||||
github.com/luxfi/math/big v0.1.0 // indirect
|
||||
github.com/luxfi/mdns v0.1.1 // indirect
|
||||
@@ -92,10 +82,14 @@ require (
|
||||
github.com/tinylib/msgp v1.6.4 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.70.0 // indirect
|
||||
github.com/zap-proto/zip v1.36.48
|
||||
github.com/zap-proto/fiber/v3 v3.2.1 // indirect
|
||||
github.com/zap-proto/go v1.8.3 // indirect
|
||||
github.com/zap-proto/http v0.3.9 // indirect
|
||||
github.com/zap-proto/mcp v1.0.5 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/otel v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.44.0 // indirect
|
||||
go.uber.org/mock v0.6.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
module github.com/hanzoai/kms/sdk/go
|
||||
|
||||
go 1.26.8
|
||||
go 1.27.1
|
||||
|
||||
require (
|
||||
github.com/luxfi/crypto v1.20.5
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"slices"
|
||||
|
||||
"github.com/hanzoai/kms/sdk/go/node"
|
||||
)
|
||||
@@ -110,12 +111,7 @@ func (c *Client) ask(ctx context.Context, method, suffix string, body, out any,
|
||||
}
|
||||
|
||||
func accepted(status int, want []int) bool {
|
||||
for _, w := range want {
|
||||
if status == w {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(want, status)
|
||||
}
|
||||
|
||||
// message pulls the KMS's explanation out of a refusal body, falling back to the
|
||||
|
||||
Reference in New Issue
Block a user