forked from jrconlin/vapid
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from web-push-libs/bug/74
bug: Use RFC8282 Vapid by default
- Loading branch information
Showing
8 changed files
with
412 additions
and
34 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,77 @@ | ||
`PyPI version py_vapid <https://pypi.org/project/py-vapid/>`__ | ||
|
||
Easy VAPID generation | ||
===================== | ||
|
||
This minimal library contains the minimal set of functions you need to | ||
generate a VAPID key set and get the headers you'll need to sign a | ||
generate a VAPID key set and get the headers you’ll need to sign a | ||
WebPush subscription update. | ||
|
||
VAPID is a voluntary standard for WebPush subscription providers (sites | ||
that send WebPush updates to remote customers) to self-identify to Push | ||
Servers (the servers that convey the push notifications). | ||
|
||
The VAPID "claims" are a set of JSON keys and values. There are two | ||
The VAPID “claims” are a set of JSON keys and values. There are two | ||
required fields, one semi-optional and several optional additional | ||
fields. | ||
|
||
At a minimum a VAPID claim set should look like: | ||
|
||
:: | ||
|
||
{"sub":"mailto:[email protected]","aud":"https://PushServer","exp":"ExpirationTimestamp"} | ||
{"sub":"mailto:[email protected]","aud":"https://PushServer","exp":"ExpirationTimestamp"} | ||
|
||
A few notes: | ||
|
||
***sub*** is the email address you wish to have on record for this | ||
request, prefixed with "``mailto:``". If things go wrong, this is the | ||
**sub** is the email address you wish to have on record for this | ||
request, prefixed with “``mailto:``”. If things go wrong, this is the | ||
email that will be used to contact you (for instance). This can be a | ||
general delivery address like "``mailto:[email protected]``" | ||
or a specific address like "``mailto:[email protected]``". | ||
general delivery address like “``mailto:[email protected]``” | ||
or a specific address like “``mailto:[email protected]``”. | ||
|
||
***aud*** is the audience for the VAPID. This is the scheme and host you | ||
**aud** is the audience for the VAPID. This is the scheme and host you | ||
use to send subscription endpoints and generally coincides with the | ||
``endpoint`` specified in the Subscription Info block. | ||
|
||
As example, if a WebPush subscription info contains: | ||
``{"endpoint": "https://push.example.com:8012/v1/push/...", ...}`` | ||
|
||
then the ``aud`` would be "``https://push.example.com:8012``" | ||
then the ``aud`` would be “``https://push.example.com:8012``” | ||
|
||
While some Push Services consider this an optional field, others may be | ||
stricter. | ||
|
||
***exp*** This is the UTC timestamp for when this VAPID request will | ||
**exp** This is the UTC timestamp for when this VAPID request will | ||
expire. The maximum period is 24 hours. Setting a shorter period can | ||
prevent "replay" attacks. Setting a longer period allows you to reuse | ||
headers for multiple sends (e.g. if you're sending hundreds of updates | ||
prevent “replay” attacks. Setting a longer period allows you to reuse | ||
headers for multiple sends (e.g. if you’re sending hundreds of updates | ||
within an hour or so.) If no ``exp`` is included, one that will expire | ||
in 24 hours will be auto-generated for you. | ||
|
||
Claims should be stored in a JSON compatible file. In the examples | ||
below, we've stored the claims into a file named ``claims.json``. | ||
below, we’ve stored the claims into a file named ``claims.json``. | ||
|
||
py\_vapid can either be installed as a library or used as a stand along | ||
py_vapid can either be installed as a library or used as a stand along | ||
app, ``bin/vapid``. | ||
|
||
App Installation | ||
---------------- | ||
|
||
You'll need ``python virtualenv`` Run that in the current directory. | ||
You’ll need ``python virtualenv`` Run that in the current directory. | ||
|
||
Then run | ||
|
||
:: | ||
|
||
bin/pip install -r requirements.txt | ||
bin/pip install -r requirements.txt | ||
|
||
bin/python setup.py install | ||
bin/python setup.py install | ||
|
||
App Usage | ||
--------- | ||
|
||
Run by itself, ``bin/vapid`` will check and optionally create the | ||
public\_key.pem and private\_key.pem files. | ||
public_key.pem and private_key.pem files. | ||
|
||
``bin/vapid --gen`` can be used to generate a new set of public and | ||
private key PEM files. These will overwrite the contents of | ||
|
@@ -88,7 +90,7 @@ endpoint. See | |
https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe | ||
for more details. Be aware that this value is tied to the generated | ||
public/private key. If you remove or generate a new key, any restricted | ||
URL you've previously generated will need to be reallocated. Please note | ||
URL you’ve previously generated will need to be reallocated. Please note | ||
that some User Agents may require you `to decode this string into a | ||
Uint8Array <https://github.com/GoogleChrome/push-notifications/blob/master/app/scripts/main.js>`__. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[nosetests] | ||
verbose=True | ||
verbosity=1 | ||
cover-tests=True | ||
cover-erase=True | ||
with-coverage=True | ||
#cover-tests=True | ||
#cover-erase=True | ||
#with-coverage=True | ||
detailed-errors=True | ||
cover-package=py_vapid | ||
#cover-package=py_vapid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters