1+ `PyPI version py_vapid <https://pypi.org/project/py-vapid/ >`__
2+
13Easy VAPID generation
24=====================
35
46This 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 you’ ll need to sign a
68WebPush subscription update.
79
810VAPID is a voluntary standard for WebPush subscription providers (sites
911that send WebPush updates to remote customers) to self-identify to Push
1012Servers (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
1315required fields, one semi-optional and several optional additional
1416fields.
1517
1618At 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
2224A 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
2628email 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
3133use to send subscription endpoints and generally coincides with the
3234``endpoint `` specified in the Subscription Info block.
3335
3436As 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
3941While some Push Services consider this an optional field, others may be
4042stricter.
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
4345expire. 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 you’ re sending hundreds of updates
4648within an hour or so.) If no ``exp `` is included, one that will expire
4749in 24 hours will be auto-generated for you.
4850
4951Claims 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, we’ ve 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
5355app, ``bin/vapid ``.
5456
5557App Installation
5658----------------
5759
58- You' ll need ``python virtualenv `` Run that in the current directory.
60+ You’ ll need ``python virtualenv `` Run that in the current directory.
5961
6062Then 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
6870App Usage
6971---------
7072
7173Run 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
7577private key PEM files. These will overwrite the contents of
@@ -88,7 +90,7 @@ endpoint. See
8890https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe
8991for more details. Be aware that this value is tied to the generated
9092public/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 you’ ve previously generated will need to be reallocated. Please note
9294that some User Agents may require you `to decode this string into a
9395Uint8Array <https://github.com/GoogleChrome/push-notifications/blob/master/app/scripts/main.js> `__.
9496
0 commit comments