Skip to content

Commit a2dbc6f

Browse files
committed
chore: tag 1.13.0
1 parent 336b1fb commit a2dbc6f

File tree

3 files changed

+69
-66
lines changed

3 files changed

+69
-66
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# I am terrible at keeping this up-to-date.
22

3+
## 1.13.0 (2021-03-15)
4+
Support requests_session param in webpush fn too
5+
36
## 1.12.0 (2021-03-15)
47
chore: library update, remove nose tests
58

README.rst

+65-65
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ available on `github <https://github.com/mozilla-services/pywebpush>`__.
1010
Installation
1111
------------
1212

13-
You'll need to run ``python virtualenv``. Then
13+
Youll need to run ``python virtualenv``. Then
1414

1515
::
1616

17-
bin/pip install -r requirements.txt
18-
bin/python setup.py develop
17+
bin/pip install -r requirements.txt
18+
bin/python setup.py develop
1919

2020
Usage
2121
-----
@@ -31,94 +31,94 @@ As illustration, a ``subscription_info`` object may look like:
3131

3232
.. code:: json
3333
34-
{"endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...", "keys": {"auth": "k8J...", "p256dh": "BOr..."}}
34+
{"endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...", "keys": {"auth": "k8J...", "p256dh": "BOr..."}}
3535
3636
How you send the PushSubscription data to your backend, store it
37-
referenced to the user who requested it, and recall it when there's a
37+
referenced to the user who requested it, and recall it when theres a
3838
new push subscription update is left as an exercise for the reader.
3939

4040
Sending Data using ``webpush()`` One Call
4141
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4242

4343
In many cases, your code will be sending a single message to many
44-
recipients. There's a "One Call" function which will make things easier.
44+
recipients. Theres a One Call function which will make things easier.
4545

4646
.. 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
5757
``subscription_info`` block.
5858

5959
**Parameters**
6060

61-
*subscription\_info* - The ``dict`` of the subscription info (described
61+
*subscription_info* - The ``dict`` of the subscription info (described
6262
above).
6363

6464
*data* - can be any serial content (string, bit array, serialized JSON,
6565
etc), but be sure that your receiving application is able to parse and
66-
understand it. (e.g. ``data = "Mary had a little lamb."``)
66+
understand it. (e.g. ``data = "Mary had a little lamb."``)
6767
68-
*content\_type* - specifies the form of Encryption to use, either
68+
*content_type* - specifies the form of Encryption to use, either
6969
``'aes128gcm'`` or the deprecated ``'aesgcm'``. NOTE that not all User
7070
Agents can decrypt ``'aesgcm'``, so the library defaults to the RFC 8188
7171
standard form.
7272

73-
*vapid\_claims* - a ``dict`` containing the VAPID claims required for
73+
*vapid_claims* - a ``dict`` containing the VAPID claims required for
7474
authorization (See
75-
`py\_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
75+
`py_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
7676
for more details). If ``aud`` is not specified, pywebpush will attempt
7777
to auto-fill from the ``endpoint``.
7878

79-
*vapid\_private\_key* - Either a path to a VAPID EC2 private key PEM
80-
file, or a string containing the DER representation. (See
81-
`py\_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
79+
*vapid_private_key* - Either a path to a VAPID EC2 private key PEM file,
80+
or a string containing the DER representation. (See
81+
`py_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
8282
for more details.) The ``private_key`` may be a base64 encoded DER
8383
formatted private key, or the path to an OpenSSL exported private key
8484
file.
8585

86-
e.g. the output of:
86+
e.g. the output of:
8787

8888
::
8989

90-
openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
90+
openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
9191

9292
**Example**
9393

9494
.. code:: python
9595
96-
from pywebpush import webpush, WebPushException
97-
98-
try:
99-
webpush(
100-
subscription_info={
101-
"endpoint": "https://push.example.com/v1/12345",
102-
"keys": {
103-
"p256dh": "0123abcde...",
104-
"auth": "abc123..."
105-
}},
106-
data="Mary had a little lamb, with a nice mint jelly",
107-
vapid_private_key="path/to/vapid_private.pem",
108-
vapid_claims={
109-
"sub": "mailto:[email protected]",
110-
}
111-
)
112-
except WebPushException as ex:
113-
print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
114-
# Mozilla returns additional information in the body of the response.
115-
if ex.response and ex.response.json():
116-
extra = ex.response.json()
117-
print("Remote service replied with a {}:{}, {}",
118-
extra.code,
119-
extra.errno,
120-
extra.message
121-
)
96+
from pywebpush import webpush, WebPushException
97+
98+
try:
99+
webpush(
100+
subscription_info={
101+
"endpoint": "https://push.example.com/v1/12345",
102+
"keys": {
103+
"p256dh": "0123abcde...",
104+
"auth": "abc123..."
105+
}},
106+
data="Mary had a little lamb, with a nice mint jelly",
107+
vapid_private_key="path/to/vapid_private.pem",
108+
vapid_claims={
109+
"sub": "mailto:[email protected]",
110+
}
111+
)
112+
except WebPushException as ex:
113+
print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
114+
# Mozilla returns additional information in the body of the response.
115+
if ex.response and ex.response.json():
116+
extra = ex.response.json()
117+
print("Remote service replied with a {}:{}, {}",
118+
extra.code,
119+
extra.errno,
120+
extra.message
121+
)
122122
123123
Methods
124124
~~~~~~~
@@ -145,13 +145,13 @@ Send the data using additional parameters. On error, returns a
145145
*ttl* Message Time To Live on Push Server waiting for the client to
146146
reconnect (in seconds)
147147

148-
*gcm\_key* Google Cloud Messaging key (if using the older GCM push
148+
*gcm_key* Google Cloud Messaging key (if using the older GCM push
149149
system) This is the API key obtained from the Google Developer Console.
150150

151-
*reg\_id* Google Cloud Messaging registration ID (will be extracted from
151+
*reg_id* Google Cloud Messaging registration ID (will be extracted from
152152
endpoint if not specified)
153153

154-
*content\_encoding* ECE content encoding type (defaults to "aes128gcm")
154+
*content_encoding* ECE content encoding type (defaults to aes128gcm)
155155

156156
*curl* Do not execute the POST, but return as a ``curl`` command. This
157157
will write the encrypted content to a local file named
@@ -167,7 +167,7 @@ to send from Chrome using the old GCM mode:
167167

168168
.. code:: python
169169
170-
WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
170+
WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
171171
172172
``.encode(data, content_encoding="aes128gcm")``
173173
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -179,19 +179,19 @@ Encode the ``data`` for future use. On error, returns a
179179

180180
*data* Binary string of data to send
181181

182-
*content\_encoding* ECE content encoding type (defaults to "aes128gcm")
182+
*content_encoding* ECE content encoding type (defaults to aes128gcm)
183183

184184
**Example**
185185

186186
.. code:: python
187187
188-
encoded_data = WebPush(subscription_info).encode(data)
188+
encoded_data = WebPush(subscription_info).encode(data)
189189
190190
Stand Alone Webpush
191191
-------------------
192192

193-
If you're not really into coding your own solution, there's also a
194-
"stand-alone" ``pywebpush`` command in the ./bin directory.
193+
If youre not really into coding your own solution, theres also a
194+
stand-alone ``pywebpush`` command in the ./bin directory.
195195

196196
This uses two files: \* the *data* file, which contains the message to
197197
send, in whatever form you like. \* the *subscription info* file, which
@@ -201,24 +201,24 @@ like:
201201

202202
.. code:: json
203203
204-
{"endpoint": "https://push...",
205-
"keys": {
206-
"auth": "ab01...",
207-
"p256dh": "aa02..."
208-
}}
204+
{"endpoint": "https://push...",
205+
"keys": {
206+
"auth": "ab01...",
207+
"p256dh": "aa02..."
208+
}}
209209
210-
If you're interested in just testing your applications WebPush
210+
If youre interested in just testing your applications WebPush
211211
interface, you could use the Command Line:
212212

213213
.. code:: bash
214214
215-
./bin/pywebpush --data stuff_to_send.data --info subscription.info
215+
./bin/pywebpush --data stuff_to_send.data --info subscription.info
216216
217217
which will encrypt and send the contents of ``stuff_to_send.data``.
218218

219219
See ``./bin/pywebpush --help`` for available commands and options.
220220

221-
.. |Build Status| image:: https://travis-ci.org/web-push-libs/pywebpush.svg?branch=master
221+
.. |Build Status| image:: https://travis-ci.org/web-push-libs/pywebpush.svg?branch=main
222222
:target: https://travis-ci.org/web-push-libs/pywebpush
223-
.. |Requirements Status| image:: https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=master
224-
:target: https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=master
223+
.. |Requirements Status| image:: https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=main
224+
:target: https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=main

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import find_packages, setup
55

66

7-
__version__ = "1.12.0"
7+
__version__ = "1.13.0"
88

99

1010
def read_from(file):

0 commit comments

Comments
 (0)