feat: Web Push notification integration (PWA) - #460
Open
only1isaac wants to merge 1 commit into
Open
Conversation
- Add push event and notificationclick handlers to service worker (sw.js) - Create frontend/lib/pushNotifications.ts: requestPermission, subscribeUser, unsubscribeUser, isSubscribed helpers with VAPID key support - Create frontend/components/PushNotificationPrompt.tsx: gentle opt-in prompt shown after wallet connect; respects user choice with localStorage dismiss - Integrate PushNotificationPrompt into AppShellInner (_app.tsx) - Create backend/src/services/pushService.js: web-push VAPID sender with addSubscription, removeSubscription, sendNotification; auto-removes expired (HTTP 410) subscriptions - Create backend/src/routes/push.js: POST /api/push/subscribe, POST /api/push/unsubscribe, GET /api/push/vapid-public-key - Mount push routes at /api/push in server.js - Add migration 009_push_subscriptions.js: push_subscriptions table with public_key, endpoint, p256dh, auth columns and unique constraint - Trigger push notifications on: tip received (tipsService), escrow_create, escrow_claim, stream_open, stream_claim contract events (eventIndexer) - Add VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, VAPID_SUBJECT to backend .env.example - Add NEXT_PUBLIC_VAPID_PUBLIC_KEY to frontend .env.example - Document all VAPID env vars in ENV.md - Add 21 passing backend tests covering pushService and push routes Closes FinChippay#377
|
@only1isaac is attempting to deploy a commit to the Topmatrixmor2014 Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements full Web Push notification support for the Finchippay PWA, addressing all acceptance criteria from issue #377.
Changes
Frontend
frontend/public/sw.js— push and notificationclick event handlers already present; confirmed working with new subscription flowfrontend/lib/pushNotifications.ts(NEW) —requestPermission(),subscribeUser(publicKey),unsubscribeUser(publicKey),isSubscribed()helpers; converts VAPID key viaurlBase64ToUint8Arrayfrontend/components/PushNotificationPrompt.tsx(NEW) — Gentle opt-in banner shown after wallet connection; "Enable" / "Not Now" buttons; dismisses tolocalStorageso it doesn't re-nagfrontend/pages/_app.tsx— Imports and rendersPushNotificationPromptinAppShellInner(belowInstallBanner)frontend/.env.example— AddedNEXT_PUBLIC_VAPID_PUBLIC_KEYBackend
backend/src/services/pushService.js(NEW) —web-pushpowered VAPID sender;addSubscription/removeSubscription/sendNotification; auto-cleans expired (HTTP 410) subscriptionsbackend/src/routes/push.js(NEW) — Three endpoints:GET /api/push/vapid-public-key,POST /api/push/subscribe,POST /api/push/unsubscribe; Zod validation + strictLimiterbackend/src/server.js— Mounts push routes at/api/pushbackend/migrations/009_push_subscriptions.js(NEW) — Createspush_subscriptionstable withpublic_key,endpoint,p256dh,auth, unique constraint on(public_key, endpoint)backend/package.json— Addedweb-push@^3.6.7backend/.env.example— AddedVAPID_PUBLIC_KEY,VAPID_PRIVATE_KEY,VAPID_SUBJECTPush Notification Triggers
backend/src/services/tipsService.js— Fires push to creator on tip receiptbackend/src/services/eventIndexer.js— Fires push for contract events:tip,escrow_create,escrow_claim,stream_open,stream_claimDocs
ENV.md— Documented all VAPID backend and frontend env varsTests
backend/__tests__/pushService.test.js(NEW) — 21 passing tests coveringaddSubscription,removeSubscription,sendNotification(including 410 cleanup), and all three push route endpointsAcceptance Criteria
data.urlpush_subscriptionstable + remove endpointTesting
Generate VAPID keys:
Add to
backend/.envandfrontend/.env.local, then connect a wallet — the notification prompt will appear.Closes #377