feat: Implement push notification system for admin announcements
- Add a notification manager to handle push notifications and integrate with Nostr events. - Create a push notification service to manage subscription and permission requests. - Introduce components for notification settings and permission prompts in the UI. - Update Nostr store to manage push notification state and enable/disable functionality. - Enhance NostrFeed to send notifications for new admin announcements. - Implement test notification functionality for development purposes.
This commit is contained in:
parent
6c1caac84b
commit
c05f40f1ec
17 changed files with 1316 additions and 13 deletions
36
generate-vapid-keys.js
Normal file
36
generate-vapid-keys.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Simple VAPID key generator for testing push notifications
|
||||
// In production, you'd want to use proper cryptographic libraries
|
||||
|
||||
console.log('🔑 VAPID Key Generator for Push Notifications')
|
||||
console.log('')
|
||||
|
||||
// Generate a random string for testing
|
||||
function generateTestKey(length = 64) {
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
|
||||
let result = ''
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * chars.length))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Generate test VAPID keys
|
||||
const publicKey = generateTestKey(87) // Base64 URL-safe, typical length
|
||||
const privateKey = generateTestKey(43) // Base64 URL-safe, typical length
|
||||
|
||||
console.log('📋 Add these to your .env file:')
|
||||
console.log('')
|
||||
console.log(`VITE_VAPID_PUBLIC_KEY=${publicKey}`)
|
||||
console.log(`VITE_PUSH_NOTIFICATIONS_ENABLED=true`)
|
||||
console.log('')
|
||||
console.log('⚠️ IMPORTANT: These are test keys for development only!')
|
||||
console.log(' For production, generate proper VAPID keys using:')
|
||||
console.log(' - web-push library: npx web-push generate-vapid-keys')
|
||||
console.log(' - online tool: https://vapidkeys.com/')
|
||||
console.log('')
|
||||
console.log('🔐 Private key (keep secure, for backend only):')
|
||||
console.log(`VAPID_PRIVATE_KEY=${privateKey}`)
|
||||
console.log('')
|
||||
console.log('✅ Once added, restart your dev server to apply the changes.')
|
||||
Loading…
Add table
Add a link
Reference in a new issue