Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buckket/go-mastopush
Decrypt and parse Web Push Notifications sent by Mastodon
https://github.com/buckket/go-mastopush
fediverse golang golang-library mastodon webpush webpush-notifications
Last synced: 27 days ago
JSON representation
Decrypt and parse Web Push Notifications sent by Mastodon
- Host: GitHub
- URL: https://github.com/buckket/go-mastopush
- Owner: buckket
- License: gpl-3.0
- Created: 2019-05-19T16:02:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-18T23:01:37.000Z (about 5 years ago)
- Last Synced: 2024-04-13T14:04:53.327Z (7 months ago)
- Topics: fediverse, golang, golang-library, mastodon, webpush, webpush-notifications
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# go-mastopush [![Build Status](https://travis-ci.org/buckket/go-mastopush.svg)](https://travis-ci.org/buckket/go-mastopush) [![Go Report Card](https://goreportcard.com/badge/github.com/buckket/go-mastopush)](https://goreportcard.com/report/github.com/buckket/go-mastopush) [![codecov](https://codecov.io/gh/buckket/go-mastopush/branch/master/graph/badge.svg)](https://codecov.io/gh/buckket/go-mastopush) [![GoDoc](https://godoc.org/github.com/buckket/go-mastopush?status.svg)](https://godoc.org/github.com/buckket/go-mastopush)
**go-mastopush** implements the decryption portion of the [Web Push standard](https://developers.google.com/web/fundamentals/push-notifications/) ([RFC8030](https://tools.ietf.org/html/rfc8030), [RFC8291](https://tools.ietf.org/html/rfc8291)),
as well as additional helper functions, which allow for easy decryption and parsing of Push Notifications sent by [Mastodon](https://github.com/tootsuite/mastodon).Here’s the output of the included example project:
```sh
[buckket@uncloaked go-mastopush]$ ./go-mastopush
2019/05/19 16:52:33 Added new push subscription (ID: 1, Endpoint: https://example.org/go-mastopush/)
2019/05/19 16:52:33 Mastodon ServerKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX="
2019/05/19 16:52:46 Incoming request from [::1]:39306
2019/05/19 16:52:46 JWT Header: &{Algorithm:ES256 KeyID: Type:JWT ContentType:}
2019/05/19 16:52:46 JWT Payload: &{Issuer: Subject:mailto:[email protected] Audience:[https://example.org] ExpirationTime:1558363966 NotBefore:0 IssuedAt:0 JWTID:}
2019/05/19 16:52:46 New push notification:
{
"access_token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"preferred_locale": "en",
"notification_id": "701",
"notification_type": "mention",
"icon": "https://social.buckket.org/avatars/original/missing.png",
"title": "You were mentioned by mirror",
"body": "@buckket Hello. Testing 123"
}
```## Installation
### From source
go get -u github.com/buckket/go-mastopush
## Usage
[Here’s](https://github.com/buckket/go-mastopush/tree/master/example) a simple example project. Check [GoDoc](https://godoc.org/github.com/buckket/go-mastopush) for the full documentation.
## Limitations
- Only supports `aesgcm` and not `aes128gcm`. Which is fine, because Mastodon only uses the former.
But implementing the later should be straight forward as well, as parsing the HTTP request headers is no
longer necessary.
- Documentation is still lacking.## Notes
- A remotely similar project which forwards notifications (to APN in this case) instead of decrypting them can be found here:
[https://github.com/DagAgren/toot-relay](https://github.com/DagAgren/toot-relay)
- Your HTTP handler should resepct [Section 6.2](https://tools.ietf.org/html/rfc8030#section-6.2) when it comes to returning HTTP status codes.## License
GNU GPLv3+