Skip to content

Commit 427d89f

Browse files
authored
Merge pull request #75 from web-push-libs/bug/74
bug: Use RFC8282 Vapid by default
2 parents 21536e3 + 527b362 commit 427d89f

File tree

8 files changed

+412
-34
lines changed

8 files changed

+412
-34
lines changed

python/LICENSE

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

python/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![PyPI version py_vapid](https://badge.fury.io/py/py-vapid.svg)](https://pypi.org/project/py-vapid/)
2+
13
# Easy VAPID generation
24

35
This minimal library contains the minimal set of functions you need to

python/README.rst

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,77 @@
1+
`PyPI version py_vapid <https://pypi.org/project/py-vapid/>`__
2+
13
Easy VAPID generation
24
=====================
35

46
This minimal library contains the minimal set of functions you need to
5-
generate a VAPID key set and get the headers you'll need to sign a
7+
generate a VAPID key set and get the headers youll need to sign a
68
WebPush subscription update.
79

810
VAPID is a voluntary standard for WebPush subscription providers (sites
911
that send WebPush updates to remote customers) to self-identify to Push
1012
Servers (the servers that convey the push notifications).
1113

12-
The VAPID "claims" are a set of JSON keys and values. There are two
14+
The VAPID claims are a set of JSON keys and values. There are two
1315
required fields, one semi-optional and several optional additional
1416
fields.
1517

1618
At a minimum a VAPID claim set should look like:
1719

1820
::
1921

20-
{"sub":"mailto:[email protected]","aud":"https://PushServer","exp":"ExpirationTimestamp"}
22+
{"sub":"mailto:[email protected]","aud":"https://PushServer","exp":"ExpirationTimestamp"}
2123

2224
A few notes:
2325

24-
***sub*** is the email address you wish to have on record for this
25-
request, prefixed with "``mailto:``". If things go wrong, this is the
26+
**sub** is the email address you wish to have on record for this
27+
request, prefixed with ``mailto:``. If things go wrong, this is the
2628
email that will be used to contact you (for instance). This can be a
27-
general delivery address like "``mailto:[email protected]``"
28-
or a specific address like "``mailto:[email protected]``".
29+
general delivery address like ``mailto:[email protected]``
30+
or a specific address like ``mailto:[email protected]``.
2931

30-
***aud*** is the audience for the VAPID. This is the scheme and host you
32+
**aud** is the audience for the VAPID. This is the scheme and host you
3133
use to send subscription endpoints and generally coincides with the
3234
``endpoint`` specified in the Subscription Info block.
3335

3436
As example, if a WebPush subscription info contains:
3537
``{"endpoint": "https://push.example.com:8012/v1/push/...", ...}``
3638

37-
then the ``aud`` would be "``https://push.example.com:8012``"
39+
then the ``aud`` would be ``https://push.example.com:8012``
3840

3941
While some Push Services consider this an optional field, others may be
4042
stricter.
4143

42-
***exp*** This is the UTC timestamp for when this VAPID request will
44+
**exp** This is the UTC timestamp for when this VAPID request will
4345
expire. The maximum period is 24 hours. Setting a shorter period can
44-
prevent "replay" attacks. Setting a longer period allows you to reuse
45-
headers for multiple sends (e.g. if you're sending hundreds of updates
46+
prevent replay attacks. Setting a longer period allows you to reuse
47+
headers for multiple sends (e.g. if youre sending hundreds of updates
4648
within an hour or so.) If no ``exp`` is included, one that will expire
4749
in 24 hours will be auto-generated for you.
4850

4951
Claims should be stored in a JSON compatible file. In the examples
50-
below, we've stored the claims into a file named ``claims.json``.
52+
below, weve stored the claims into a file named ``claims.json``.
5153

52-
py\_vapid can either be installed as a library or used as a stand along
54+
py_vapid can either be installed as a library or used as a stand along
5355
app, ``bin/vapid``.
5456

5557
App Installation
5658
----------------
5759

58-
You'll need ``python virtualenv`` Run that in the current directory.
60+
Youll need ``python virtualenv`` Run that in the current directory.
5961

6062
Then run
6163

6264
::
6365

64-
bin/pip install -r requirements.txt
66+
bin/pip install -r requirements.txt
6567

66-
bin/python setup.py install
68+
bin/python setup.py install
6769

6870
App Usage
6971
---------
7072

7173
Run by itself, ``bin/vapid`` will check and optionally create the
72-
public\_key.pem and private\_key.pem files.
74+
public_key.pem and private_key.pem files.
7375

7476
``bin/vapid --gen`` can be used to generate a new set of public and
7577
private key PEM files. These will overwrite the contents of
@@ -88,7 +90,7 @@ endpoint. See
8890
https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe
8991
for more details. Be aware that this value is tied to the generated
9092
public/private key. If you remove or generate a new key, any restricted
91-
URL you've previously generated will need to be reallocated. Please note
93+
URL youve previously generated will need to be reallocated. Please note
9294
that some User Agents may require you `to decode this string into a
9395
Uint8Array <https://github.com/GoogleChrome/push-notifications/blob/master/app/scripts/main.js>`__.
9496

python/py_vapid/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from py_vapid.jwt import sign
2121

2222
# Show compliance version. For earlier versions see previously tagged releases.
23-
VERSION = "VAPID-DRAFT-02/ECE-DRAFT-07"
23+
VERSION = "VAPID-RFC/ECE-RFC"
2424

2525

2626
class VapidException(Exception):
@@ -303,9 +303,9 @@ def sign(self, claims, crypto_key=None):
303303

304304

305305
class Vapid02(Vapid01):
306-
"""Minimal Vapid 02 signature generation library
306+
"""Minimal Vapid RFC8292 signature generation library
307307
308-
https://tools.ietf.org/html/draft-ietf-webpush-vapid-02
308+
https://tools.ietf.org/html/rfc8292
309309
310310
"""
311311
_schema = "vapid"

python/py_vapid/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def main():
2525
parser.add_argument('--sign', '-s', help='claims file to sign')
2626
parser.add_argument('--gen', '-g', help='generate new key pairs',
2727
default=False, action="store_true")
28-
parser.add_argument('--version2', '-2', help="use VAPID spec Draft-02",
29-
default=False, action="store_true")
30-
parser.add_argument('--version1', '-1', help="use VAPID spec Draft-01",
28+
parser.add_argument('--version2', '-2', help="use RFC8292 VAPID spec",
3129
default=True, action="store_true")
30+
parser.add_argument('--version1', '-1', help="use VAPID spec Draft-01",
31+
default=False, action="store_true")
3232
parser.add_argument('--json', help="dump as json",
3333
default=False, action="store_true")
3434
parser.add_argument('--applicationServerKey',
@@ -37,9 +37,9 @@ def main():
3737
args = parser.parse_args()
3838

3939
# Added to solve 2.7 => 3.* incompatibility
40-
Vapid = Vapid01
41-
if args.version2:
42-
Vapid = Vapid02
40+
Vapid = Vapid02
41+
if args.version1:
42+
Vapid = Vapid01
4343
if args.gen or not os.path.exists('private_key.pem'):
4444
if not args.gen:
4545
print("No private_key.pem file found.")

python/setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[nosetests]
22
verbose=True
33
verbosity=1
4-
cover-tests=True
5-
cover-erase=True
6-
with-coverage=True
4+
#cover-tests=True
5+
#cover-erase=True
6+
#with-coverage=True
77
detailed-errors=True
8-
cover-package=py_vapid
8+
#cover-package=py_vapid

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from setuptools import setup, find_packages
55

6-
__version__ = "1.5.0"
6+
__version__ = "1.6.0"
77

88

99
def read_from(file):

python/upload.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
# Package the current branch up to pypi
33
# remember to update the README.rst file
44
pandoc --from=markdown --to=rst --output README.rst README.md
5-
bin/python setup.py sdist upload
5+
bin/python setup.py sdist
6+
bin/twine upload dist/*

0 commit comments

Comments
 (0)