1
+ `PyPI version py_vapid <https://pypi.org/project/py-vapid/ >`__
2
+
1
3
Easy VAPID generation
2
4
=====================
3
5
4
6
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 you’ ll need to sign a
6
8
WebPush subscription update.
7
9
8
10
VAPID is a voluntary standard for WebPush subscription providers (sites
9
11
that send WebPush updates to remote customers) to self-identify to Push
10
12
Servers (the servers that convey the push notifications).
11
13
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
13
15
required fields, one semi-optional and several optional additional
14
16
fields.
15
17
16
18
At a minimum a VAPID claim set should look like:
17
19
18
20
::
19
21
20
- {"sub":"mailto:[email protected] ","aud":"https://PushServer","exp":"ExpirationTimestamp"}
22
+ {"sub":"mailto:[email protected] ","aud":"https://PushServer","exp":"ExpirationTimestamp"}
21
23
22
24
A few notes:
23
25
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
26
28
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] ``
” .
29
31
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
31
33
use to send subscription endpoints and generally coincides with the
32
34
``endpoint `` specified in the Subscription Info block.
33
35
34
36
As example, if a WebPush subscription info contains:
35
37
``{"endpoint": "https://push.example.com:8012/v1/push/...", ...} ``
36
38
37
- then the ``aud `` would be " ``https://push.example.com:8012 ``"
39
+ then the ``aud `` would be “ ``https://push.example.com:8012 ``”
38
40
39
41
While some Push Services consider this an optional field, others may be
40
42
stricter.
41
43
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
43
45
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 you’ re sending hundreds of updates
46
48
within an hour or so.) If no ``exp `` is included, one that will expire
47
49
in 24 hours will be auto-generated for you.
48
50
49
51
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, we’ ve stored the claims into a file named ``claims.json ``.
51
53
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
53
55
app, ``bin/vapid ``.
54
56
55
57
App Installation
56
58
----------------
57
59
58
- You' ll need ``python virtualenv `` Run that in the current directory.
60
+ You’ ll need ``python virtualenv `` Run that in the current directory.
59
61
60
62
Then run
61
63
62
64
::
63
65
64
- bin/pip install -r requirements.txt
66
+ bin/pip install -r requirements.txt
65
67
66
- bin/python setup.py install
68
+ bin/python setup.py install
67
69
68
70
App Usage
69
71
---------
70
72
71
73
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.
73
75
74
76
``bin/vapid --gen `` can be used to generate a new set of public and
75
77
private key PEM files. These will overwrite the contents of
@@ -88,7 +90,7 @@ endpoint. See
88
90
https://developer.mozilla.org/en-US/docs/Web/API/PushManager/subscribe
89
91
for more details. Be aware that this value is tied to the generated
90
92
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 you’ ve previously generated will need to be reallocated. Please note
92
94
that some User Agents may require you `to decode this string into a
93
95
Uint8Array <https://github.com/GoogleChrome/push-notifications/blob/master/app/scripts/main.js> `__.
94
96
0 commit comments