Skip to content

saycel/webpush-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web push notification server

This script allows you to:

  • Generate the necessary keys for webpush
  • Expose the public key to the client
  • Register and update user subscriptions.
  • Send notifications to users by their number

Keys are randomly generated at startup or can be set using environment variables (PUSH_PUBLIC and PUSH_PRIVATE). The same for the express port (PUSH_PORT) and the secret key (PUSH_SECRET)

Methods

Displays the public key needed for the webApp to generate its credentials

Creates or updates the user record in the database This method requires the following data:

{
    "user": "user number",
    "endpoint": "endpoint generate by the webapp subscription",
    "auth": "auth key generate by the webapp subscription",
    "p256dh": "p256dh generate my the webapp subrcription"
}

Send a push notification to the user. You need to have the secret key to enable sending. This method requires the following data:

{
    "user": "user number",
    "secretKey": "secret key set in the server",
    "payload": "data sent with the push message"
}

About

Web push notification server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •