Documentation
¶
Overview ¶
Package push validates app-owned subscriptions and sends redacted Web Push payloads. It classifies transport outcomes for the app's durable delivery ledgers but does not decide alert eligibility or retain delivery state.
Index ¶
Constants ¶
const Subscriber = "https://osauer.dev"
Subscriber is the VAPID contact claim presented to push services. It must be an "https:" URL (webpush-go passes those through unchanged) or a bare email without the "mailto:" prefix (the library prepends exactly one). Never a "mailto:"-prefixed value — webpush-go v1.4.0 would double it into "mailto:mailto:…" — and never an @localhost address: Apple rejects both with 403 BadJwtToken, surfacing as http_rejected on every delivery.
Variables ¶
This section is empty.
Functions ¶
func GenerateVAPIDKeys ¶
GenerateVAPIDKeys creates a private/public VAPID key pair for app-owned push subscriptions.
func ValidateSubscription ¶
func ValidateSubscription(sub state.PushSubscription) error
ValidateSubscription requires the endpoint and both Web Push key fields; it does not establish that the subscription's paired device is active.
Types ¶
type Payload ¶
type Payload struct {
Title string `json:"title"`
Body string `json:"body"`
Severity string `json:"severity,omitempty"`
Kind string `json:"kind,omitempty"`
Destination string `json:"destination,omitempty"`
DisplayID string `json:"display_id,omitempty"`
URL string `json:"url,omitempty"`
AlertID string `json:"alert_id,omitempty"`
Action string `json:"action,omitempty"`
}
Payload is the allowlisted lock-screen surface. Callers must construct it from redacted presentation data rather than producer evidence or account state.
func GovernancePayload ¶
func GovernancePayload(candidate rpc.NudgeCandidate, displayID string) (Payload, error)
GovernancePayload is the only constructor for governance Web Push copy. Canonicalization replaces every caller-supplied display field with the shared enum template, while the returned struct populates only the explicit lock-screen allowlist.
func SafeDiagnosticPayload ¶
func SafeDiagnosticPayload() Payload
SafeDiagnosticPayload returns a fixed notification test containing no account, position, order, occurrence, or subscription data.
type Sender ¶
type Sender interface {
Send(context.Context, state.PushSubscription, state.VAPIDKeys, Payload) state.PushAttempt
}
Sender transports one caller-selected, redacted payload and returns a classified attempt for the caller to persist. It does not grant eligibility.
type WebPushSender ¶
type WebPushSender struct {
Subscriber string
Client webpush.HTTPClient
}
WebPushSender sends payloads through a Web Push service. A nil Client uses the webpush library's default HTTP client.
func (WebPushSender) Send ¶
func (s WebPushSender) Send(ctx context.Context, sub state.PushSubscription, keys state.VAPIDKeys, payload Payload) state.PushAttempt
Send validates sub, sends payload once, and classifies the response without persisting it. OK means the push service accepted the request, not that a device displayed or a human read the notification.