Files
nostermd-relay/internal/relayinfo/relayinfo.go
T
rgoodall 294616642f
ci / build (push) Successful in 2m3s
ci / image (push) Successful in 1m4s
initial public relay build repo
2026-07-24 13:11:06 -04:00

43 lines
1.7 KiB
Go

// Package relayinfo implements the Nosterm capability handshake.
//
// A standard NIP-11 relay information document describes supported NIPs. A
// "nostermd" additionally advertises a `features` array so that a Nosterm
// client can enable/disable UI capabilities and gracefully fall back when
// connected to a plain Nostr relay that omits it.
//
// The upstream nip11.RelayInformationDocument has no `features` field and its
// custom JSON marshaller drops unknown keys, so the relay serves NIP-11 itself
// and merges these fields into the JSON object.
package relayinfo
const (
// SoftwareName is advertised as the NIP-11 `software` value.
SoftwareName = "nostermd"
// SoftwareVersion is advertised as the NIP-11 `version` value.
SoftwareVersion = "0.1.0"
)
// baseFeatures advertised by every relay build. Presence/typing/moderation/etc.
// are declared here as they are implemented; the baseline relay supports managed
// NIP-29 channels only. Runtime-dependent features (e.g. federation) are added
// in Extras based on configuration.
var baseFeatures = []string{
"channels", // NIP-29 managed group channels
}
// Extras returns the extra top-level keys merged into the NIP-11 document JSON.
// Keeping this in one place makes the handshake easy to extend. `federated`
// reflects whether this relay has any federation peer configured, so a client
// can surface that a channel here may be mirrored elsewhere.
func Extras(federated bool) map[string]any {
features := append([]string{}, baseFeatures...)
if federated {
features = append(features, "federation") // chat-only relay↔relay mirroring
}
return map[string]any{
"software": SoftwareName,
"version": SoftwareVersion,
"features": features,
}
}