https://github.com/negrel/webpush
Web Push library for Deno and other web compatible runtime.
https://github.com/negrel/webpush
Last synced: 3 months ago
JSON representation
Web Push library for Deno and other web compatible runtime.
- Host: GitHub
- URL: https://github.com/negrel/webpush
- Owner: negrel
- License: mit
- Created: 2024-05-22T16:25:28.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-22T16:49:28.000Z (about 1 year ago)
- Last Synced: 2024-05-22T17:56:45.765Z (about 1 year ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `webpush` - Web Push library for Deno and other web compatible runtime.


`webpush` is a Web Push library
([RFC 8291](https://www.rfc-editor.org/rfc/rfc8291) and
[RFC 8292](https://www.rfc-editor.org/rfc/rfc8292)) based on Web APIs.> NOTE: This library hasn't been reviewed by crypto experts and may be unsecure.
> I've done my best to follow RFC recommandation and I only used primitives
> provided by the SubtleCrypto API.`webpush` is available on [JSR](https://jsr.io/@negrel/webpush).
## Getting started
Before sending Web Push message to a user agent, you need to create VAPID keys
(see [RFC 8292](https://www.rfc-editor.org/rfc/rfc8292)) to identify your server
(`Application`) to the `Push Service`:```
+-------+ +--------------+ +-------------+
| UA | | Push Service | | Application |
+-------+ +--------------+ +-------------+
| | |
| Setup | |
|<====================>| |
| Provide Subscription |
|-------------------------------------------->|
| | |
: : :
| | Push Message |
| Push Message |<---------------------|
|<---------------------| |
| | |
```Run
[`generate-vapid-keys`](https://github.com/negrel/webpush/blob/master/cmd/generate-vapid-keys.ts)
script part of this repository to generate new keys:```sh
# You can use any Web compatible runtime.
$ deno run https://raw.githubusercontent.com/negrel/webpush/master/cmd/generate-vapid-keys.ts
```Copy the output of the command and save it in `example/vapid.json`. Now you can
run example server.```
$ cd example/
$ deno run -A ./main.ts
```Code is commented be sure to read it.
I also wrote an
[ok-ish blog post about Web Push and this library](https://www.negrel.dev/blog/deno-web-push-notifications/).## Dependencies
This library tries its best at keeping the minimum number of dependencies. It
has no external dependencies except some runtime agnostic
[`@std/`](https://jsr.io/@std/) packages maintained by Deno team and
[`http-ece`](https://github.com/negrel/http-ece), which I maintain.[`http-ece`](https://github.com/negrel/http-ece) also only depends on
[`@std/`](https://jsr.io/@std/) packages.## Contributing
If you want to contribute to `webpush` to add a feature or improve the code
contact me at [[email protected]](mailto:[email protected]), open an
[issue](https://github.com/negrel/webpush/issues) or make a
[pull request](https://github.com/negrel/webpush/pulls).## :stars: Show your support
Please give a :star: if this project helped you!
[](https://www.buymeacoffee.com/negrel)
## :scroll: License
MIT © [Alexandre Negrel](https://www.negrel.dev/)