push

package
v2.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 11 Imported by: 0

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

View Source
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

func GenerateVAPIDKeys() (privateKey, publicKey string, err error)

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

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

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL