Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher sends Web Push notifications to every stored subscription.
func NewDispatcher ¶
func NewDispatcher(store *Store, vapid VAPID, subscriber string) *Dispatcher
NewDispatcher builds a dispatcher over the given store and VAPID keys.
func (*Dispatcher) Notify ¶
func (d *Dispatcher) Notify(n Notification)
Notify fans n out to all subscriptions, pruning any the push service reports as gone (404/410). Best-effort: per-subscription failures are logged, not returned.
func (*Dispatcher) VAPIDPublicKey ¶
func (d *Dispatcher) VAPIDPublicKey() string
VAPIDPublicKey returns the public key browsers need to subscribe.
type Notification ¶
type Notification struct {
Title string `json:"title"`
Body string `json:"body,omitempty"`
SessionID string `json:"session_id,omitempty"`
Tag string `json:"tag,omitempty"` // coalesces same-session notifications on the device
}
Notification is the payload delivered (encrypted) to the service worker, which turns it into a system notification. Keep it minimal: it ends up on the lock screen, so no prompts, tool args, paths, diffs or final text — just a type and the session title.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a thread-safe, disk-backed set of Web Push subscriptions keyed by endpoint. Single-user personal use over the tailnet — no per-user identity; a subscription is one browser/device that opted in.
func (*Store) Add ¶
func (s *Store) Add(sub webpush.Subscription) error
Add stores (or replaces) a subscription by endpoint and persists. Idempotent.
func (*Store) All ¶
func (s *Store) All() []webpush.Subscription
All returns a snapshot slice of the current subscriptions.
type VAPID ¶
VAPID is the server's VAPID key pair (RFC 8292). The public key is shared with browsers (application server key); the private key signs the VAPID JWT and must stay secret (persisted 0600).
func LoadOrGenerateVAPID ¶
LoadOrGenerateVAPID reads the VAPID key pair from path, generating and persisting a new pair (0600) on first use. The pair is stable across restarts so existing browser subscriptions keep working.