Documentation
¶
Overview ¶
Package push is the web-push (VAPID) notification sink. It degrades to a no-op until keys are configured, so a fresh install never fails on it.
The payload is encrypted with RFC 8291 aes128gcm and authorised with an RFC 8292 VAPID JWT. Implemented directly on crypto/* rather than pulling a dependency: it is ~120 lines and the alternative is another module to audit.
Index ¶
Constants ¶
const ( SettingPrivateKey = "vapid_private" SettingPublicKey = "vapid_public" )
Settings keys the resolved VAPID key pair is persisted under. Deliberately NOT in sinks.Keys: GET/PUT /api/settings never touches them, so there is no API path — not even an admin one — that can read the private key back out, and PUT /api/settings rejects them the same way it rejects any unknown key.
Variables ¶
This section is empty.
Functions ¶
func GenerateKeyPair ¶ added in v2.4.0
GenerateKeyPair mints a fresh P-256 VAPID key pair, in the same base64url raw-scalar (private) / uncompressed-point (public) encoding every other key in this package uses. Used to auto-provision a Sender when no LECTERN_VAPID_PRIVATE/PUBLIC are set — see ResolveKeys.
Types ¶
type Sender ¶
type Sender struct {
PrivateKey string // base64url raw P-256 scalar
PublicKey string // base64url uncompressed P-256 point
Email string
Client *http.Client
Log *slog.Logger
}
Sender holds the VAPID identity.
func ResolveKeys ¶ added in v2.4.0
func ResolveKeys(db *store.DB, envPrivate, envPublic, envEmail string, log *slog.Logger) (*Sender, error)
ResolveKeys builds the Sender lectern runs with, so a phone alert works without the owner ever configuring keys by hand.
LECTERN_VAPID_PRIVATE/PUBLIC win when both are set — an operator's explicit choice, e.g. to share one identity across installs. Otherwise a pair is loaded from the settings table; the very first start generates one and persists it, so every start after that reuses the same identity (a browser subscription is bound to the public key it subscribed with — rotating it silently would orphan every existing subscription).
type Subscription ¶
Subscription is a browser's push endpoint plus its encryption keys.