Require MEALQUEST_VAPID_PUBLIC_KEY, MEALQUEST_VAPID_PRIVATE_KEY_FILE and
MEALQUEST_VAPID_SUBJECT at boot. Both keys are unpadded base64url P-256
keys, the encoding webpush-go reads; boot derives the public point from the
private key and refuses a pair that does not match. The subject must be
mailto:<address> or an https:// URL.
internal/push stores subscriptions by endpoint: GET
/api/v1/push/vapid-public-key serves only the public key, POST
/api/v1/push/subscriptions upserts {endpoint, keys.p256dh, keys.auth,
user_agent}, and DELETE removes by endpoint, answering 204 whether or not
it was stored. cmd/vapidgen prints a new key pair. deploy/compose.yaml
mounts the vapid_private_key secret.
Maestro task e8a7b1f4-327a-478b-88c7-5d265afda153.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
689 B
SQL
21 lines
689 B
SQL
-- name: UpsertPushSubscription :one
|
|
-- Stores a browser's push subscription, keyed by its endpoint. Subscribing
|
|
-- an endpoint already stored replaces its keys and user agent and clears
|
|
-- its failure count, keeping its id, created_at and last_success_at.
|
|
INSERT INTO push_subscriptions (
|
|
id, endpoint, p256dh, auth, user_agent, failure_count, created_at, updated_at
|
|
) VALUES (
|
|
?, ?, ?, ?, ?, 0, ?, ?
|
|
)
|
|
ON CONFLICT (endpoint) DO UPDATE SET
|
|
p256dh = excluded.p256dh,
|
|
auth = excluded.auth,
|
|
user_agent = excluded.user_agent,
|
|
failure_count = 0,
|
|
updated_at = excluded.updated_at
|
|
RETURNING *;
|
|
|
|
-- name: DeletePushSubscription :execrows
|
|
DELETE FROM push_subscriptions
|
|
WHERE endpoint = ?;
|