Skip to content

Commit 7fd84b6

Browse files
committed
Merge branch 'master' of github.com:web-push-libs/pywebpush
2 parents 97fbcf4 + 6401fa0 commit 7fd84b6

File tree

7 files changed

+38
-29
lines changed

7 files changed

+38
-29
lines changed

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Source is available on
1414

1515
You'll need to run `python virtualenv`.
1616
Then
17-
```commandline
17+
18+
```
1819
bin/pip install -r requirements.txt
1920
bin/python setup.py develop
2021
```
@@ -29,6 +30,7 @@ object. This object has a .toJSON() method that will return a JSON object that c
2930
and push data.
3031

3132
As illustration, a `subscription_info` object may look like:
33+
3234
```json
3335
{"endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...", "keys": {"auth": "k8J...", "p256dh": "BOr..."}}
3436
```
@@ -44,14 +46,15 @@ In many cases, your code will be sending a single message to many
4446
recipients. There's a "One Call" function which will make things
4547
easier.
4648

47-
```pythonstub
48-
from pywebpush import webpush
49+
```python
50+
from pywebpush import webpush
4951

50-
webpush(subscription_info,
51-
data,
52-
vapid_private_key="Private Key or File Path[1]",
53-
vapid_claims={"sub": "mailto:YourEmailAddress"})
52+
webpush(subscription_info,
53+
data,
54+
vapid_private_key="Private Key or File Path[1]",
55+
vapid_claims={"sub": "mailto:YourEmailAddress"})
5456
```
57+
5558
This will encode `data`, add the appropriate VAPID auth headers if required and send it to the push server identified
5659
in the `subscription_info` block.
5760

@@ -74,13 +77,14 @@ pywebpush will attempt to auto-fill from the `endpoint`.
7477
a base64 encoded DER formatted private key, or the path to an OpenSSL exported private key file.
7578

7679
e.g. the output of:
77-
```commandline
80+
81+
```
7882
openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
7983
```
8084

8185
**Example**
8286

83-
```pythonstub
87+
```python
8488
from pywebpush import webpush, WebPushException
8589

8690
try:
@@ -133,7 +137,8 @@ named `encrpypted.data`. This command is meant to be used for debugging purposes
133137
**Example**
134138

135139
to send from Chrome using the old GCM mode:
136-
```pythonstub
140+
141+
```python
137142
WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
138143
```
139144

@@ -149,7 +154,7 @@ Encode the `data` for future use. On error, returns a `WebPushException`
149154

150155
**Example**
151156

152-
```pythonstub
157+
```python
153158
encoded_data = WebPush(subscription_info).encode(data)
154159
```
155160

README.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Installation
1212

1313
You'll need to run ``python virtualenv``. Then
1414

15-
.. code:: commandline
15+
::
1616

1717
bin/pip install -r requirements.txt
1818
bin/python setup.py develop
@@ -43,14 +43,14 @@ Sending Data using ``webpush()`` One Call
4343
In many cases, your code will be sending a single message to many
4444
recipients. There's a "One Call" function which will make things easier.
4545

46-
.. code:: pythonstub
46+
.. code:: python
4747
48-
from pywebpush import webpush
48+
from pywebpush import webpush
4949
50-
webpush(subscription_info,
51-
data,
52-
vapid_private_key="Private Key or File Path[1]",
53-
vapid_claims={"sub": "mailto:YourEmailAddress"})
50+
webpush(subscription_info,
51+
data,
52+
vapid_private_key="Private Key or File Path[1]",
53+
vapid_claims={"sub": "mailto:YourEmailAddress"})
5454
5555
This will encode ``data``, add the appropriate VAPID auth headers if
5656
required and send it to the push server identified in the
@@ -84,13 +84,13 @@ file.
8484

8585
e.g. the output of:
8686

87-
.. code:: commandline
87+
::
8888

8989
openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
9090

9191
**Example**
9292

93-
.. code:: pythonstub
93+
.. code:: python
9494
9595
from pywebpush import webpush, WebPushException
9696
@@ -153,7 +153,7 @@ purposes.
153153

154154
to send from Chrome using the old GCM mode:
155155

156-
.. code:: pythonstub
156+
.. code:: python
157157
158158
WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
159159
@@ -171,7 +171,7 @@ Encode the ``data`` for future use. On error, returns a
171171

172172
**Example**
173173

174-
.. code:: pythonstub
174+
.. code:: python
175175
176176
encoded_data = WebPush(subscription_info).encode(data)
177177

convert_readme.sh

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
#!/bin/sh
2+
3+
# You will need pandoc to be installed for this to work correctly, as well as the PyPI packages docutils and pygments
4+
5+
set -e
16
pandoc --from=markdown --to=rst --output README.rst README.md
7+
python setup.py check --restructuredtext --strict --metadata

pywebpush/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,11 @@ def send(self, data=None, headers=None, ttl=0, gcm_key=None, reg_id=None,
249249
# use ';' instead of ',' to append the headers.
250250
# see https://github.com/webpush-wg/webpush-encryption/issues/6
251251
crypto_key += ';'
252-
crypto_key += (
253-
"keyid=p256dh;dh=" + encoded["crypto_key"].decode('utf8'))
252+
crypto_key += ("dh=" + encoded["crypto_key"].decode('utf8'))
254253
headers.update({
255254
'crypto-key': crypto_key,
256255
'content-encoding': content_encoding,
257-
'encryption': "keyid=p256dh;salt=" +
258-
encoded['salt'].decode('utf8'),
256+
'encryption': "salt=" + encoded['salt'].decode('utf8'),
259257
})
260258
if gcm_key:
261259
endpoint = 'https://android.googleapis.com/gcm/send'

pywebpush/tests/test_webpush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_as_curl(self, opener):
265265
"-H \"crypto-key: p256ecdsa=",
266266
"-H \"content-encoding: aesgcm\"",
267267
"-H \"authorization: WebPush ",
268-
"-H \"encryption: keyid=p256dh;salt=",
268+
"-H \"encryption: salt=",
269269
"-H \"ttl: 0\"",
270270
"-H \"content-length:"
271271
]:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cryptography==1.8.1
22
http-ece==1.0.1
33
requests==2.13.0
4-
py-vapid==1.2.1
4+
py-vapid==1.2.3

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 find_packages, setup
55

6-
__version__ = "1.0.0"
6+
__version__ = "1.0.2"
77

88

99
def read_from(file):

0 commit comments

Comments
 (0)