web-push: Send messages using Web Push protocol.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Web Push is a simple protocol for delivery of real-time events to user agents using HTTP/2 server push. This can be used to send notifications to browsers using the Push API.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.2.0, 0.3, 0.5
Change log None available
Dependencies aeson (>=2.0 && <3.0), asn1-encoding (>=0.9 && <0.10), asn1-types (>=0.3 && <0.4), base (>=4.7 && <5), base64 (>=0.4 && <0.5), binary (>=0.7.5 && <0.9), bytestring (>=0.9 && <0.13), containers (>=0.6 && <0.7), crypton (>=0.30 && <1.0), crypton-x509 (>=1.7 && <1.8), crypton-x509-store (>=1.6 && <1.7), http-client (>=0.5.7 && <0.8), http-types (>=0.8.6 && <1.0), memory (>=0.14.5 && <0.19), mtl (>=2.2 && <3.0), network-uri (>=2.6 && <3.0), pem (>=0.2 && <0.3), random (>=1.2 && <1.3), safe-exceptions (>=0.1.7 && <0.2), text (>=0.11 && <3.0), time (>=1.0 && <2) [details]
License MIT
Copyright 2023 Kevin Cotrone
Author Sarthak Bagaria
Maintainer kevincotrone@gmail.com
Category Web
Home page https://github.com/cotrone/web-push#readme
Source repo head: git clone https://github.com/cotrone/web-push
Uploaded by KevinCotrone at 2023-11-08T06:23:13Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for web-push-0.5

[back to package description]

web-push

Hackage Spec and Mock Tests Example Browser Tests

Send web push notifications to browsers

Forked from https://github.com/sarthakbagaria/web-push

Usage

Guides to using Web Push API in browsers can be found on Mozilla's and Google's docs, or you can check out the demo app in the example folder. To run the demo app:

with nix: nix run .#web-push-example:exe:web-push-example-server

with cabal: cabal run web-push-example-server

stack: stack exec web-push-example-server

Then access localhost:3000 from a browser

For production use, store a set of VAPID keys securely and use them for all push notification subscriptions and messages; public key will have to be exposed to client's browser when subscribing to push notifications, but private key must be kept secret and used when generating push notifications on the server. If VAPID keys are re-generated, all push notifications will require re-subscriptions. Also save the latest subscription details such as endpoint from user's browser session securely in the database and use them to send push notifications to the user later.

Generating Keys

Generating VAPID keys should be done with openssl.

To generate the private key:

openssl ecparam -name prime256v1 -genkey -noout -out vapid_private.pem

to calculate the public key from the private key:

openssl ec -in vapid_private.pem -pubout -out vapid_public.pem

Build

The library builds and tests run with both cabal and stack.

There is also a nix flake setup to manage the dependencies for tests.

To build a cabal environment for the project that

Nix

The nix flake includes:

Example

There is a minimal example web application that generates keys, stores subscriptions, and sends notifications to all subscribers in web-push-example

References

Current implementation is based on the following versions of the drafts: