# Module /web/push

RFC 8291 Web Push payload encryption and VAPID key generation.

```tangu
(use /web/push)
```

## Functions & symbols

### encrypt

`(encrypt subscription payload vapid-private vapid-public options) -> Map`

Encrypts a Web Push payload and constructs VAPID-signed HTTP headers `{:endpoint :headers :body}` ready to POST.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `subscription` | `Map` | no | Browser PushSubscription map {:endpoint :keys {:p256dh :auth}} |
| `payload` | `String` | no | UTF-8 notification payload (e.g. encoded JSON) |
| `vapid_private` | `String` | no | URL-safe Base64 VAPID private key |
| `vapid_public` | `String` | no | URL-safe Base64 VAPID public key |
| `options` | `Map` | no | Push options {:subject "mailto:..." [:ttl Int :urgency String]} |

```tangu
(let req (web-push/encrypt sub body priv pub {:subject "mailto:ops@example.com" :ttl 3600}))
```

### generate-keys

`(generate-keys) -> Map`

Generates a fresh ECDSA P-256 VAPID keypair `{:public-key String :private-key String}` in URL-safe Base64.

```tangu
(let keys (web-push/generate-keys))
```
