Documentation
¶
Overview ¶
Package enroll is the station's side of a rig joining it: one-time codes that carry the station key's fingerprint, the /v1/station profile the rig checks that fingerprint against, the /v1/enroll endpoint, and mDNS so a rig on the LAN finds the station without a URL.
Index ¶
- Constants
- func Advertise(name string, port int) (func(), error)
- func Discover(ctx context.Context, timeout time.Duration) (string, error)
- func Fingerprint(pk nostr.PubKey) string
- func NewCode(pk nostr.PubKey) string
- func ParseCode(code string) (normalized, fingerprint string, err error)
- type Codes
- type Handler
- type Offer
- type Profile
- type Response
Constants ¶
const ( // Service is the mDNS service a station advertises. Service = "_vibium-station._tcp" // CodeLifetime is how long an enrollment code stays usable. CodeLifetime = 15 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func Advertise ¶
Advertise announces the station on the LAN over mDNS. The returned function stops it.
func Fingerprint ¶
Fingerprint is the start of the station's key, the last group of every enrollment code: the rig refuses a station whose key does not match it.
Types ¶
type Handler ¶
type Handler struct {
Key nostr.SecretKey
Name string
TunnelURL string
Devices station.DeviceStore
Events station.EventStore
Codes Codes
Audit station.AuditSink // optional
Logf func(format string, args ...any)
}
Handler serves the profile and enrollment endpoints.
func (*Handler) ServeEnroll ¶
func (h *Handler) ServeEnroll(w http.ResponseWriter, r *http.Request)
ServeEnroll is POST /v1/enroll: a kind 7702 event signed by the rig, naming this station, with a live code and the rig's devices.
func (*Handler) ServeProfile ¶
func (h *Handler) ServeProfile(w http.ResponseWriter, r *http.Request)
ServeProfile is GET /v1/station.
type Offer ¶
type Offer struct {
Name string `json:"name"`
Kind string `json:"kind"`
Caps []string `json:"caps"`
Key string `json:"key,omitempty"`
Shortcuts []station.Shortcut `json:"shortcuts,omitempty"`
Input string `json:"input,omitempty"` // "touch" or "mouse"
Extras string `json:"extras,omitempty"` // the rig's viewer extras script path
Label string `json:"label,omitempty"` // the device's name for people
Platform string `json:"platform,omitempty"` // "ios", "android", ...
Model string `json:"model,omitempty"` // "iPhone 15 Pro Max"
OSVersion string `json:"os_version,omitempty"` // "26.6"
}
Offer is a device as a rig describes it before it has an id: the name the station will put after its rig id.
type Profile ¶
type Profile struct {
Name string `json:"name"`
PubKey string `json:"pubkey"`
TunnelURL string `json:"tunnel_url"`
Event nostr.Event `json:"event"`
}
Profile is what GET /v1/station returns: the station's name, key and tunnel URL, signed as its kind 0 event so the rig can check the key.