Web & HTTP2 exports
Raw Markdown/web/push
RFC 8291 Web Push payload encryption and VAPID key generation.
Functions & symbols#
encrypt#
function
Encrypts a Web Push payload and constructs VAPID-signed HTTP headers `{:endpoint :headers :body}` ready to POST.
| Parameter | Type | Optional | Description |
|---|---|---|---|
subscription | Map | required | Browser PushSubscription map {:endpoint :keys {:p256dh :auth}} |
payload | String | required | UTF-8 notification payload (e.g. encoded JSON) |
vapid_private | String | required | URL-safe Base64 VAPID private key |
vapid_public | String | required | URL-safe Base64 VAPID public key |
options | Map | required | Push options {:subject "mailto:..." [:ttl Int :urgency String]} |
Returns:
Any(let req (web-push/encrypt sub body priv pub {:subject "mailto:ops@example.com" :ttl 3600}))generate-keys#
function
Generates a fresh ECDSA P-256 VAPID keypair `{:public-key String :private-key String}` in URL-safe Base64.
Returns:
Any(let keys (web-push/generate-keys))