Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-pywebpush for
openSUSE:Factory checked in at 2021-09-28 19:16:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pywebpush (Old)
and /work/SRC/openSUSE:Factory/.python-pywebpush.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pywebpush"
Tue Sep 28 19:16:35 2021 rev:2 rq:921903 version:1.14.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pywebpush/python-pywebpush.changes
2020-06-18 10:27:51.524775293 +0200
+++
/work/SRC/openSUSE:Factory/.python-pywebpush.new.1899/python-pywebpush.changes
2021-09-28 19:17:28.540251044 +0200
@@ -1,0 +2,8 @@
+Tue Sep 28 01:08:03 UTC 2021 - Steve Kowalik <[email protected]>
+
+- Update to 1.14.0:
+ * bug: accept all VAPID key instances (thanks @mthu)
+ * Support requests_session param in webpush fn too
+ * chore: library update, remove nose tests
+
+-------------------------------------------------------------------
Old:
----
pywebpush-1.11.0.tar.gz
New:
----
pywebpush-1.14.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pywebpush.spec ++++++
--- /var/tmp/diff_new_pack.jKAcdO/_old 2021-09-28 19:17:28.936251500 +0200
+++ /var/tmp/diff_new_pack.jKAcdO/_new 2021-09-28 19:17:28.944251509 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-pywebpush
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,11 +18,10 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pywebpush
-Version: 1.11.0
+Version: 1.14.0
Release: 0
Summary: WebPush publication library
License: MPL-2.0
-Group: Development/Languages/Python
URL: https://github.com/web-push-libs/pywebpush
Source:
https://files.pythonhosted.org/packages/source/p/pywebpush/pywebpush-%{version}.tar.gz
BuildRequires: %{python_module setuptools}
@@ -33,14 +32,14 @@
Requires: python-py-vapid >= 1.5.0
Requires: python-requests >= 2.21.0
Requires(post): update-alternatives
-Requires(postun): update-alternatives
+Requires(postun):update-alternatives
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module cryptography >= 2.6.1}
BuildRequires: %{python_module http-ece >= 1.1.0}
BuildRequires: %{python_module mock >= 2.0.0}
-BuildRequires: %{python_module nose >= 1.3.7}
BuildRequires: %{python_module py-vapid >= 1.5.0}
+BuildRequires: %{python_module pytest}
BuildRequires: %{python_module requests >= 2.21.0}
# /SECTION
%python_subpackages
@@ -60,7 +59,7 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%python_exec -m nose
+%pytest
%post
%python_install_alternative pywebpush
++++++ pywebpush-1.11.0.tar.gz -> pywebpush-1.14.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/CHANGELOG.md
new/pywebpush-1.14.0/CHANGELOG.md
--- old/pywebpush-1.11.0/CHANGELOG.md 2020-04-29 22:19:32.000000000 +0200
+++ new/pywebpush-1.14.0/CHANGELOG.md 2021-07-28 16:42:42.000000000 +0200
@@ -1,5 +1,14 @@
# I am terrible at keeping this up-to-date.
+## 1.14.0 (2021-07-28)
+bug: accept all VAPID key instances (thanks @mthu)
+
+## 1.13.0 (2021-03-15)
+Support requests_session param in webpush fn too
+
+## 1.12.0 (2021-03-15)
+chore: library update, remove nose tests
+
## 1.11.0 (2020-04-29)
feat: add `--head` to read headers out of a json file (thanks @braedon)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/PKG-INFO
new/pywebpush-1.14.0/PKG-INFO
--- old/pywebpush-1.11.0/PKG-INFO 2020-04-29 22:21:36.000000000 +0200
+++ new/pywebpush-1.14.0/PKG-INFO 2021-07-28 16:53:28.490836400 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pywebpush
-Version: 1.11.0
+Version: 1.14.0
Summary: WebPush publication library
Home-page: https://github.com/web-push-libs/pywebpush
Author: JR Conlin
@@ -18,12 +18,12 @@
Installation
------------
- You'll need to run ``python virtualenv``. Then
+ You???ll need to run ``python virtualenv``. Then
::
- bin/pip install -r requirements.txt
- bin/python setup.py develop
+ bin/pip install -r requirements.txt
+ bin/python setup.py develop
Usage
-----
@@ -39,26 +39,29 @@
.. code:: json
- {"endpoint":
"https://updates.push.services.mozilla.com/push/v1/gAA...", "keys": {"auth":
"k8J...", "p256dh": "BOr..."}}
+ {
+ "endpoint":
"https://updates.push.services.mozilla.com/push/v1/gAA...",
+ "keys": { "auth": "k8J...", "p256dh": "BOr..." }
+ }
How you send the PushSubscription data to your backend, store it
- referenced to the user who requested it, and recall it when there's a
+ referenced to the user who requested it, and recall it when there???s a
new push subscription update is left as an exercise for the reader.
Sending Data using ``webpush()`` One Call
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In many cases, your code will be sending a single message to many
- recipients. There's a "One Call" function which will make things
easier.
+ recipients. There???s a ???One Call??? function which will make things
easier.
.. code:: python
- from pywebpush import webpush
+ from pywebpush import webpush
- webpush(subscription_info,
- data,
- vapid_private_key="Private Key or File Path[1]",
- vapid_claims={"sub": "mailto:YourEmailAddress"})
+ webpush(subscription_info,
+ data,
+ vapid_private_key="Private Key or File Path[1]",
+ vapid_claims={"sub": "mailto:YourEmailAddress"})
This will encode ``data``, add the appropriate VAPID auth headers if
required and send it to the push server identified in the
@@ -66,67 +69,67 @@
**Parameters**
- *subscription\_info* - The ``dict`` of the subscription info (described
+ *subscription_info* - The ``dict`` of the subscription info (described
above).
*data* - can be any serial content (string, bit array, serialized JSON,
etc), but be sure that your receiving application is able to parse and
- understand it. (e.g. ``data = "Mary had a little lamb."``)
+ understand it. (e.g.??``data = "Mary had a little lamb."``)
- *content\_type* - specifies the form of Encryption to use, either
+ *content_type* - specifies the form of Encryption to use, either
``'aes128gcm'`` or the deprecated ``'aesgcm'``. NOTE that not all User
Agents can decrypt ``'aesgcm'``, so the library defaults to the RFC
8188
standard form.
- *vapid\_claims* - a ``dict`` containing the VAPID claims required for
+ *vapid_claims* - a ``dict`` containing the VAPID claims required for
authorization (See
- `py\_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
+ `py_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
for more details). If ``aud`` is not specified, pywebpush will attempt
to auto-fill from the ``endpoint``.
- *vapid\_private\_key* - Either a path to a VAPID EC2 private key PEM
- file, or a string containing the DER representation. (See
- `py\_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
+ *vapid_private_key* - Either a path to a VAPID EC2 private key PEM
file,
+ or a string containing the DER representation. (See
+ `py_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
for more details.) The ``private_key`` may be a base64 encoded DER
formatted private key, or the path to an OpenSSL exported private key
file.
- e.g. the output of:
+ e.g.??the output of:
::
- openssl ecparam -name prime256v1 -genkey -noout -out
private_key.pem
+ openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
**Example**
.. code:: python
- from pywebpush import webpush, WebPushException
+ from pywebpush import webpush, WebPushException
- try:
- webpush(
- subscription_info={
- "endpoint": "https://push.example.com/v1/12345",
- "keys": {
- "p256dh": "0123abcde...",
- "auth": "abc123..."
- }},
- data="Mary had a little lamb, with a nice mint jelly",
- vapid_private_key="path/to/vapid_private.pem",
- vapid_claims={
- "sub": "mailto:[email protected]",
- }
- )
- except WebPushException as ex:
- print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
- # Mozilla returns additional information in the body of the
response.
- if ex.response and ex.response.json():
- extra = ex.response.json()
- print("Remote service replied with a {}:{}, {}",
- extra.code,
- extra.errno,
- extra.message
- )
+ try:
+ webpush(
+ subscription_info={
+ "endpoint": "https://push.example.com/v1/12345",
+ "keys": {
+ "p256dh": "0123abcde...",
+ "auth": "abc123..."
+ }},
+ data="Mary had a little lamb, with a nice mint jelly",
+ vapid_private_key="path/to/vapid_private.pem",
+ vapid_claims={
+ "sub": "mailto:[email protected]",
+ }
+ )
+ except WebPushException as ex:
+ print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
+ # Mozilla returns additional information in the body of the
response.
+ if ex.response and ex.response.json():
+ extra = ex.response.json()
+ print("Remote service replied with a {}:{}, {}",
+ extra.code,
+ extra.errno,
+ extra.message
+ )
Methods
~~~~~~~
@@ -153,13 +156,13 @@
*ttl* Message Time To Live on Push Server waiting for the client to
reconnect (in seconds)
- *gcm\_key* Google Cloud Messaging key (if using the older GCM push
+ *gcm_key* Google Cloud Messaging key (if using the older GCM push
system) This is the API key obtained from the Google Developer Console.
- *reg\_id* Google Cloud Messaging registration ID (will be extracted
from
+ *reg_id* Google Cloud Messaging registration ID (will be extracted from
endpoint if not specified)
- *content\_encoding* ECE content encoding type (defaults to "aes128gcm")
+ *content_encoding* ECE content encoding type (defaults to
???aes128gcm???)
*curl* Do not execute the POST, but return as a ``curl`` command. This
will write the encrypted content to a local file named
@@ -175,7 +178,7 @@
.. code:: python
- WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
+ WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
``.encode(data, content_encoding="aes128gcm")``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -187,53 +190,66 @@
*data* Binary string of data to send
- *content\_encoding* ECE content encoding type (defaults to "aes128gcm")
+ *content_encoding* ECE content encoding type (defaults to
???aes128gcm???)
**Example**
.. code:: python
- encoded_data = WebPush(subscription_info).encode(data)
+ encoded_data = WebPush(subscription_info).encode(data)
Stand Alone Webpush
-------------------
- If you're not really into coding your own solution, there's also a
- "stand-alone" ``pywebpush`` command in the ./bin directory.
+ If you???re not really into coding your own solution, there???s also a
+ ???stand-alone??? ``pywebpush`` command in the ./bin directory.
- This uses two files: \* the *data* file, which contains the message to
- send, in whatever form you like. \* the *subscription info* file, which
- contains the subscription information as JSON encoded data. This is
- usually returned by the Push ``subscribe`` method and looks something
- like:
+ This uses two files:
+
+ - the *data* file, which contains the message to send, in whatever
form
+ you like.
+ - the *subscription info* file, which contains the subscription
+ information as JSON encoded data. This is usually returned by the
+ Push ``subscribe`` method and looks something like:
.. code:: json
- {"endpoint": "https://push...",
+ {
+ "endpoint": "https://push...",
"keys": {
- "auth": "ab01...",
- "p256dh": "aa02..."
- }}
+ "auth": "ab01...",
+ "p256dh": "aa02..."
+ }
+ }
- If you're interested in just testing your applications WebPush
+ If you???re interested in just testing your applications WebPush
interface, you could use the Command Line:
.. code:: bash
- ./bin/pywebpush --data stuff_to_send.data --info subscription.info
+ ./bin/pywebpush --data stuff_to_send.data --info subscription.info
which will encrypt and send the contents of ``stuff_to_send.data``.
See ``./bin/pywebpush --help`` for available commands and options.
- .. |Build Status| image::
https://travis-ci.org/web-push-libs/pywebpush.svg?branch=master
+ .. |Build Status| image::
https://travis-ci.org/web-push-libs/pywebpush.svg?branch=main
:target: https://travis-ci.org/web-push-libs/pywebpush
- .. |Requirements Status| image::
https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=master
- :target:
https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=master
+ .. |Requirements Status| image::
https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=main
+ :target:
https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=main
# I am terrible at keeping this up-to-date.
+ ## 1.14.0 (2021-07-28)
+ bug: accept all VAPID key instances (thanks @mthu)
+
+ ## 1.13.0 (2021-03-15)
+ Support requests_session param in webpush fn too
+
+ ## 1.12.0 (2021-03-15)
+ chore: library update, remove nose tests
+
## 1.11.0 (2020-04-29)
feat: add `--head` to read headers out of a json file (thanks @braedon)
@@ -286,9 +302,4 @@
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/README.md
new/pywebpush-1.14.0/README.md
--- old/pywebpush-1.11.0/README.md 2019-12-04 01:45:22.000000000 +0100
+++ new/pywebpush-1.14.0/README.md 2021-07-28 16:37:26.000000000 +0200
@@ -1,7 +1,7 @@
[](https://travis-ci.org/web-push-libs/pywebpush)
+Status](https://travis-ci.org/web-push-libs/pywebpush.svg?branch=main)](https://travis-ci.org/web-push-libs/pywebpush)
[](https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=master)
+Status](https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=main)](https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=main)
# Webpush Data encryption library for Python
@@ -32,7 +32,10 @@
As illustration, a `subscription_info` object may look like:
```json
-{"endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...",
"keys": {"auth": "k8J...", "p256dh": "BOr..."}}
+{
+ "endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...",
+ "keys": { "auth": "k8J...", "p256dh": "BOr..." }
+}
```
How you send the PushSubscription data to your backend, store it
@@ -60,19 +63,19 @@
**Parameters**
-*subscription_info* - The `dict` of the subscription info (described above).
+_subscription_info_ - The `dict` of the subscription info (described above).
-*data* - can be any serial content (string, bit array, serialized JSON, etc),
but be sure that your receiving
+_data_ - can be any serial content (string, bit array, serialized JSON, etc),
but be sure that your receiving
application is able to parse and understand it. (e.g. `data = "Mary had a
little lamb."`)
-*content_type* - specifies the form of Encryption to use, either `'aes128gcm'`
or the deprecated `'aesgcm'`. NOTE that
+_content_type_ - specifies the form of Encryption to use, either `'aes128gcm'`
or the deprecated `'aesgcm'`. NOTE that
not all User Agents can decrypt `'aesgcm'`, so the library defaults to the RFC
8188 standard form.
-*vapid_claims* - a `dict` containing the VAPID claims required for
authorization (See
+_vapid_claims_ - a `dict` containing the VAPID claims required for
authorization (See
[py_vapid](https://github.com/web-push-libs/vapid/tree/master/python) for more
details). If `aud` is not specified,
pywebpush will attempt to auto-fill from the `endpoint`.
-*vapid_private_key* - Either a path to a VAPID EC2 private key PEM file, or a
string containing the DER representation.
+_vapid_private_key_ - Either a path to a VAPID EC2 private key PEM file, or a
string containing the DER representation.
(See [py_vapid](https://github.com/web-push-libs/vapid/tree/master/python) for
more details.) The `private_key` may be
a base64 encoded DER formatted private key, or the path to an OpenSSL exported
private key file.
@@ -126,23 +129,23 @@
**Parameters**
-*data* Binary string of data to send
+_data_ Binary string of data to send
-*headers* A `dict` containing any additional headers to send
+_headers_ A `dict` containing any additional headers to send
-*ttl* Message Time To Live on Push Server waiting for the client to reconnect
(in seconds)
+_ttl_ Message Time To Live on Push Server waiting for the client to reconnect
(in seconds)
-*gcm_key* Google Cloud Messaging key (if using the older GCM push system) This
is the API key obtained from the Google
+_gcm_key_ Google Cloud Messaging key (if using the older GCM push system) This
is the API key obtained from the Google
Developer Console.
-*reg_id* Google Cloud Messaging registration ID (will be extracted from
endpoint if not specified)
+_reg_id_ Google Cloud Messaging registration ID (will be extracted from
endpoint if not specified)
-*content_encoding* ECE content encoding type (defaults to "aes128gcm")
+_content_encoding_ ECE content encoding type (defaults to "aes128gcm")
-*curl* Do not execute the POST, but return as a `curl` command. This will
write the encrypted content to a local file
+_curl_ Do not execute the POST, but return as a `curl` command. This will
write the encrypted content to a local file
named `encrpypted.data`. This command is meant to be used for debugging
purposes.
-*timeout* timeout for requests POST query.
+_timeout_ timeout for requests POST query.
See [requests
documentation](http://docs.python-requests.org/en/master/user/quickstart/#timeouts).
**Example**
@@ -159,9 +162,9 @@
**Parameters**
-*data* Binary string of data to send
+_data_ Binary string of data to send
-*content_encoding* ECE content encoding type (defaults to "aes128gcm")
+_content_encoding_ ECE content encoding type (defaults to "aes128gcm")
**Example**
@@ -175,15 +178,18 @@
./bin directory.
This uses two files:
-* the *data* file, which contains the message to send, in whatever form you
like.
-* the *subscription info* file, which contains the subscription information as
JSON encoded data. This is usually returned by the Push `subscribe` method and
looks something like:
+
+- the _data_ file, which contains the message to send, in whatever form you
like.
+- the _subscription info_ file, which contains the subscription information as
JSON encoded data. This is usually returned by the Push `subscribe` method and
looks something like:
```json
-{"endpoint": "https://push...",
- "keys": {
- "auth": "ab01...",
- "p256dh": "aa02..."
- }}
+{
+ "endpoint": "https://push...",
+ "keys": {
+ "auth": "ab01...",
+ "p256dh": "aa02..."
+ }
+}
```
If you're interested in just testing your applications WebPush interface, you
could use the Command Line:
@@ -191,8 +197,7 @@
```bash
./bin/pywebpush --data stuff_to_send.data --info subscription.info
```
+
which will encrypt and send the contents of `stuff_to_send.data`.
See `./bin/pywebpush --help` for available commands and options.
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/README.rst
new/pywebpush-1.14.0/README.rst
--- old/pywebpush-1.11.0/README.rst 2020-04-29 22:21:34.000000000 +0200
+++ new/pywebpush-1.14.0/README.rst 2021-07-28 16:53:28.000000000 +0200
@@ -10,12 +10,12 @@
Installation
------------
-You'll need to run ``python virtualenv``. Then
+You???ll need to run ``python virtualenv``. Then
::
- bin/pip install -r requirements.txt
- bin/python setup.py develop
+ bin/pip install -r requirements.txt
+ bin/python setup.py develop
Usage
-----
@@ -31,26 +31,29 @@
.. code:: json
- {"endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...",
"keys": {"auth": "k8J...", "p256dh": "BOr..."}}
+ {
+ "endpoint": "https://updates.push.services.mozilla.com/push/v1/gAA...",
+ "keys": { "auth": "k8J...", "p256dh": "BOr..." }
+ }
How you send the PushSubscription data to your backend, store it
-referenced to the user who requested it, and recall it when there's a
+referenced to the user who requested it, and recall it when there???s a
new push subscription update is left as an exercise for the reader.
Sending Data using ``webpush()`` One Call
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In many cases, your code will be sending a single message to many
-recipients. There's a "One Call" function which will make things easier.
+recipients. There???s a ???One Call??? function which will make things easier.
.. code:: python
- from pywebpush import webpush
+ from pywebpush import webpush
- webpush(subscription_info,
- data,
- vapid_private_key="Private Key or File Path[1]",
- vapid_claims={"sub": "mailto:YourEmailAddress"})
+ webpush(subscription_info,
+ data,
+ vapid_private_key="Private Key or File Path[1]",
+ vapid_claims={"sub": "mailto:YourEmailAddress"})
This will encode ``data``, add the appropriate VAPID auth headers if
required and send it to the push server identified in the
@@ -58,67 +61,67 @@
**Parameters**
-*subscription\_info* - The ``dict`` of the subscription info (described
+*subscription_info* - The ``dict`` of the subscription info (described
above).
*data* - can be any serial content (string, bit array, serialized JSON,
etc), but be sure that your receiving application is able to parse and
-understand it. (e.g. ``data = "Mary had a little lamb."``)
+understand it. (e.g.??``data = "Mary had a little lamb."``)
-*content\_type* - specifies the form of Encryption to use, either
+*content_type* - specifies the form of Encryption to use, either
``'aes128gcm'`` or the deprecated ``'aesgcm'``. NOTE that not all User
Agents can decrypt ``'aesgcm'``, so the library defaults to the RFC 8188
standard form.
-*vapid\_claims* - a ``dict`` containing the VAPID claims required for
+*vapid_claims* - a ``dict`` containing the VAPID claims required for
authorization (See
-`py\_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
+`py_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
for more details). If ``aud`` is not specified, pywebpush will attempt
to auto-fill from the ``endpoint``.
-*vapid\_private\_key* - Either a path to a VAPID EC2 private key PEM
-file, or a string containing the DER representation. (See
-`py\_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
+*vapid_private_key* - Either a path to a VAPID EC2 private key PEM file,
+or a string containing the DER representation. (See
+`py_vapid <https://github.com/web-push-libs/vapid/tree/master/python>`__
for more details.) The ``private_key`` may be a base64 encoded DER
formatted private key, or the path to an OpenSSL exported private key
file.
-e.g. the output of:
+e.g.??the output of:
::
- openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
+ openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
**Example**
.. code:: python
- from pywebpush import webpush, WebPushException
+ from pywebpush import webpush, WebPushException
- try:
- webpush(
- subscription_info={
- "endpoint": "https://push.example.com/v1/12345",
- "keys": {
- "p256dh": "0123abcde...",
- "auth": "abc123..."
- }},
- data="Mary had a little lamb, with a nice mint jelly",
- vapid_private_key="path/to/vapid_private.pem",
- vapid_claims={
- "sub": "mailto:[email protected]",
- }
- )
- except WebPushException as ex:
- print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
- # Mozilla returns additional information in the body of the response.
- if ex.response and ex.response.json():
- extra = ex.response.json()
- print("Remote service replied with a {}:{}, {}",
- extra.code,
- extra.errno,
- extra.message
- )
+ try:
+ webpush(
+ subscription_info={
+ "endpoint": "https://push.example.com/v1/12345",
+ "keys": {
+ "p256dh": "0123abcde...",
+ "auth": "abc123..."
+ }},
+ data="Mary had a little lamb, with a nice mint jelly",
+ vapid_private_key="path/to/vapid_private.pem",
+ vapid_claims={
+ "sub": "mailto:[email protected]",
+ }
+ )
+ except WebPushException as ex:
+ print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
+ # Mozilla returns additional information in the body of the response.
+ if ex.response and ex.response.json():
+ extra = ex.response.json()
+ print("Remote service replied with a {}:{}, {}",
+ extra.code,
+ extra.errno,
+ extra.message
+ )
Methods
~~~~~~~
@@ -145,13 +148,13 @@
*ttl* Message Time To Live on Push Server waiting for the client to
reconnect (in seconds)
-*gcm\_key* Google Cloud Messaging key (if using the older GCM push
+*gcm_key* Google Cloud Messaging key (if using the older GCM push
system) This is the API key obtained from the Google Developer Console.
-*reg\_id* Google Cloud Messaging registration ID (will be extracted from
+*reg_id* Google Cloud Messaging registration ID (will be extracted from
endpoint if not specified)
-*content\_encoding* ECE content encoding type (defaults to "aes128gcm")
+*content_encoding* ECE content encoding type (defaults to ???aes128gcm???)
*curl* Do not execute the POST, but return as a ``curl`` command. This
will write the encrypted content to a local file named
@@ -167,7 +170,7 @@
.. code:: python
- WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
+ WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
``.encode(data, content_encoding="aes128gcm")``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -179,46 +182,50 @@
*data* Binary string of data to send
-*content\_encoding* ECE content encoding type (defaults to "aes128gcm")
+*content_encoding* ECE content encoding type (defaults to ???aes128gcm???)
**Example**
.. code:: python
- encoded_data = WebPush(subscription_info).encode(data)
+ encoded_data = WebPush(subscription_info).encode(data)
Stand Alone Webpush
-------------------
-If you're not really into coding your own solution, there's also a
-"stand-alone" ``pywebpush`` command in the ./bin directory.
+If you???re not really into coding your own solution, there???s also a
+???stand-alone??? ``pywebpush`` command in the ./bin directory.
-This uses two files: \* the *data* file, which contains the message to
-send, in whatever form you like. \* the *subscription info* file, which
-contains the subscription information as JSON encoded data. This is
-usually returned by the Push ``subscribe`` method and looks something
-like:
+This uses two files:
+
+- the *data* file, which contains the message to send, in whatever form
+ you like.
+- the *subscription info* file, which contains the subscription
+ information as JSON encoded data. This is usually returned by the
+ Push ``subscribe`` method and looks something like:
.. code:: json
- {"endpoint": "https://push...",
+ {
+ "endpoint": "https://push...",
"keys": {
- "auth": "ab01...",
- "p256dh": "aa02..."
- }}
+ "auth": "ab01...",
+ "p256dh": "aa02..."
+ }
+ }
-If you're interested in just testing your applications WebPush
+If you???re interested in just testing your applications WebPush
interface, you could use the Command Line:
.. code:: bash
- ./bin/pywebpush --data stuff_to_send.data --info subscription.info
+ ./bin/pywebpush --data stuff_to_send.data --info subscription.info
which will encrypt and send the contents of ``stuff_to_send.data``.
See ``./bin/pywebpush --help`` for available commands and options.
-.. |Build Status| image::
https://travis-ci.org/web-push-libs/pywebpush.svg?branch=master
+.. |Build Status| image::
https://travis-ci.org/web-push-libs/pywebpush.svg?branch=main
:target: https://travis-ci.org/web-push-libs/pywebpush
-.. |Requirements Status| image::
https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=master
- :target:
https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=master
+.. |Requirements Status| image::
https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=main
+ :target:
https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=main
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/data.txt
new/pywebpush-1.14.0/data.txt
--- old/pywebpush-1.11.0/data.txt 1970-01-01 01:00:00.000000000 +0100
+++ new/pywebpush-1.14.0/data.txt 2019-01-08 19:58:51.000000000 +0100
@@ -0,0 +1,2 @@
+Amidst the mists and coldest frosts I thrust my fists against the
+posts and still demand to see the ghosts.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/data_128.txt
new/pywebpush-1.14.0/data_128.txt
--- old/pywebpush-1.11.0/data_128.txt 1970-01-01 01:00:00.000000000 +0100
+++ new/pywebpush-1.14.0/data_128.txt 2019-01-05 05:22:44.000000000 +0100
@@ -0,0 +1 @@
+{"title": "hello", "body": "world", "format":"aes128gcm"}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/local_test.txt
new/pywebpush-1.14.0/local_test.txt
--- old/pywebpush-1.11.0/local_test.txt 2019-01-17 22:25:50.000000000 +0100
+++ new/pywebpush-1.14.0/local_test.txt 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-Amidst the mists and coldest frosts I thrust my fists against the
-posts and still demand to see the ghosts.
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/pywebpush/__init__.py
new/pywebpush-1.14.0/pywebpush/__init__.py
--- old/pywebpush-1.11.0/pywebpush/__init__.py 2020-04-29 22:17:24.000000000
+0200
+++ new/pywebpush-1.14.0/pywebpush/__init__.py 2021-07-28 16:32:58.000000000
+0200
@@ -19,7 +19,7 @@
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
-from py_vapid import Vapid
+from py_vapid import Vapid, Vapid01
class WebPushException(Exception):
@@ -383,7 +383,8 @@
timeout=None,
ttl=0,
verbose=False,
- headers=None):
+ headers=None,
+ requests_session=None):
"""
One call solution to endcode and send `data` to the endpoint
contained in `subscription_info` using optional VAPID auth headers.
@@ -457,7 +458,7 @@
vapid_claims['exp']))
if not vapid_private_key:
raise WebPushException("VAPID dict missing 'private_key'")
- if isinstance(vapid_private_key, Vapid):
+ if isinstance(vapid_private_key, Vapid01):
vv = vapid_private_key
elif os.path.isfile(vapid_private_key):
# Presume that key from file is handled correctly by
@@ -473,7 +474,9 @@
print("\t headers: {}".format(vapid_headers))
headers.update(vapid_headers)
- response = WebPusher(subscription_info, verbose=verbose).send(
+ response = WebPusher(
+ subscription_info, requests_session=requests_session, verbose=verbose
+ ).send(
data,
headers,
ttl=ttl,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/pywebpush/tests/test_webpush.py
new/pywebpush-1.14.0/pywebpush/tests/test_webpush.py
--- old/pywebpush-1.11.0/pywebpush/tests/test_webpush.py 2020-04-29
22:17:24.000000000 +0200
+++ new/pywebpush-1.14.0/pywebpush/tests/test_webpush.py 2021-04-07
04:05:47.000000000 +0200
@@ -5,7 +5,6 @@
import time
from mock import patch, Mock
-from nose.tools import eq_, ok_, assert_is_not, assert_raises
import http_ece
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
@@ -79,12 +78,11 @@
"keys": {'p256dh': 'AAA=', 'auth': 'AAA='}})
push = WebPusher(subscription_info)
- assert_is_not(push.subscription_info, subscription_info)
- assert_is_not(push.subscription_info['keys'],
- subscription_info['keys'])
- eq_(push.subscription_info['endpoint'], subscription_info['endpoint'])
- eq_(push.receiver_key, rk_decode)
- eq_(push.auth_key, b'\x93\xc2U\xea\xc8\xddn\x10"\xd6}\xff,0K\xbc')
+ assert push.subscription_info != subscription_info
+ assert push.subscription_info['keys'] != subscription_info['keys']
+ assert push.subscription_info['endpoint'] ==
subscription_info['endpoint']
+ assert push.receiver_key == rk_decode
+ assert push.auth_key == b'\x93\xc2U\xea\xc8\xddn\x10"\xd6}\xff,0K\xbc'
def test_encode(self):
for content_encoding in ["aesgcm", "aes128gcm"]:
@@ -118,7 +116,7 @@
auth_secret=raw_auth,
version=content_encoding
)
- eq_(decoded.decode('utf8'), data)
+ assert decoded.decode('utf8') == data
def test_bad_content_encoding(self):
subscription_info = self._gen_subscription_info()
@@ -136,13 +134,13 @@
"Authentication": "bearer vapid"}
data = "Mary had a little lamb"
WebPusher(subscription_info).send(data, headers)
- eq_(subscription_info.get('endpoint'), mock_post.call_args[0][0])
+ assert subscription_info.get('endpoint') == mock_post.call_args[0][0]
pheaders = mock_post.call_args[1].get('headers')
- eq_(pheaders.get('ttl'), '0')
- eq_(pheaders.get('AUTHENTICATION'), headers.get('Authentication'))
+ assert pheaders.get('ttl') == '0'
+ assert pheaders.get('AUTHENTICATION') == headers.get('Authentication')
ckey = pheaders.get('crypto-key')
- ok_('pre-existing' in ckey)
- eq_(pheaders.get('content-encoding'), 'aes128gcm')
+ assert 'pre-existing' in ckey
+ assert pheaders.get('content-encoding') == 'aes128gcm'
@patch("requests.post")
def test_send_vapid(self, mock_post):
@@ -157,9 +155,9 @@
content_encoding="aesgcm",
headers={"Test-Header": "test-value"}
)
- eq_(subscription_info.get('endpoint'), mock_post.call_args[0][0])
+ assert subscription_info.get('endpoint') == mock_post.call_args[0][0]
pheaders = mock_post.call_args[1].get('headers')
- eq_(pheaders.get('ttl'), '0')
+ assert pheaders.get('ttl') == '0'
def repad(str):
return str + "===="[:len(str) % 4]
@@ -169,12 +167,12 @@
repad(pheaders['authorization'].split('.')[1])
).decode('utf8')
)
- ok_(subscription_info.get('endpoint').startswith(auth['aud']))
- ok_('vapid' in pheaders.get('authorization'))
+ assert subscription_info.get('endpoint').startswith(auth['aud'])
+ assert 'vapid' in pheaders.get('authorization')
ckey = pheaders.get('crypto-key')
- ok_('dh=' in ckey)
- eq_(pheaders.get('content-encoding'), 'aesgcm')
- eq_(pheaders.get('test-header'), 'test-value')
+ assert 'dh=' in ckey
+ assert pheaders.get('content-encoding') == 'aesgcm'
+ assert pheaders.get('test-header') == 'test-value'
@patch.object(WebPusher, "send")
@patch.object(py_vapid.Vapid, "sign")
@@ -211,7 +209,7 @@
)
vapid_sign.assert_called_once_with(claims)
pusher_send.assert_called_once()
- ok_(claims['exp'] > int(time.time()))
+ assert claims['exp'] > int(time.time())
@patch("requests.post")
def test_send_bad_vapid_no_key(self, mock_post):
@@ -219,15 +217,15 @@
subscription_info = self._gen_subscription_info()
data = "Mary had a little lamb"
- assert_raises(WebPushException,
- webpush,
- subscription_info=subscription_info,
- data=data,
- vapid_claims={
- "aud": "https://example.com",
- "sub": "mailto:[email protected]"
- }
- )
+ self.assertRaises(
+ WebPushException,
+ webpush,
+ subscription_info=subscription_info,
+ data=data,
+ vapid_claims={
+ "aud": "https://example.com",
+ "sub": "mailto:[email protected]"
+ })
@patch("requests.post")
def test_send_bad_vapid_bad_return(self, mock_post):
@@ -235,16 +233,16 @@
subscription_info = self._gen_subscription_info()
data = "Mary had a little lamb"
- assert_raises(WebPushException,
- webpush,
- subscription_info=subscription_info,
- data=data,
- vapid_claims={
- "aud": "https://example.com",
- "sub": "mailto:[email protected]"
- },
- vapid_private_key=self.vapid_key
- )
+ self.assertRaises(
+ WebPushException,
+ webpush,
+ subscription_info=subscription_info,
+ data=data,
+ vapid_claims={
+ "aud": "https://example.com",
+ "sub": "mailto:[email protected]"
+ },
+ vapid_private_key=self.vapid_key)
@patch("requests.post")
def test_send_empty(self, mock_post):
@@ -252,20 +250,20 @@
headers = {"Crypto-Key": "pre-existing",
"Authentication": "bearer vapid"}
WebPusher(subscription_info).send('', headers)
- eq_(subscription_info.get('endpoint'), mock_post.call_args[0][0])
+ assert subscription_info.get('endpoint') == mock_post.call_args[0][0]
pheaders = mock_post.call_args[1].get('headers')
- eq_(pheaders.get('ttl'), '0')
- ok_('encryption' not in pheaders)
- eq_(pheaders.get('AUTHENTICATION'), headers.get('Authentication'))
+ assert pheaders.get('ttl') == '0'
+ assert 'encryption' not in pheaders
+ assert pheaders.get('AUTHENTICATION') == headers.get('Authentication')
ckey = pheaders.get('crypto-key')
- ok_('pre-existing' in ckey)
+ assert 'pre-existing' in ckey
def test_encode_empty(self):
subscription_info = self._gen_subscription_info()
headers = {"Crypto-Key": "pre-existing",
"Authentication": "bearer vapid"}
encoded = WebPusher(subscription_info).encode('', headers)
- eq_(encoded, None)
+ assert encoded is None
def test_encode_no_crypto(self):
subscription_info = self._gen_subscription_info()
@@ -274,20 +272,21 @@
"Authentication": "bearer vapid"}
data = 'Something'
pusher = WebPusher(subscription_info)
- assert_raises(WebPushException,
- pusher.encode,
- data,
- headers)
+ self.assertRaises(
+ WebPushException,
+ pusher.encode,
+ data,
+ headers)
@patch("requests.post")
def test_send_no_headers(self, mock_post):
subscription_info = self._gen_subscription_info()
data = "Mary had a little lamb"
WebPusher(subscription_info).send(data)
- eq_(subscription_info.get('endpoint'), mock_post.call_args[0][0])
+ assert subscription_info.get('endpoint') == mock_post.call_args[0][0]
pheaders = mock_post.call_args[1].get('headers')
- eq_(pheaders.get('ttl'), '0')
- eq_(pheaders.get('content-encoding'), 'aes128gcm')
+ assert pheaders.get('ttl') == '0'
+ assert pheaders.get('content-encoding') == 'aes128gcm'
@patch("pywebpush.open")
def test_as_curl(self, opener):
@@ -309,15 +308,15 @@
"-H \"ttl: 0\"",
"-H \"content-length:"
]:
- ok_(s in result, "missing: {}".format(s))
+ assert s in result, "missing: {}".format(s)
def test_ci_dict(self):
ci = CaseInsensitiveDict({"Foo": "apple", "bar": "banana"})
- eq_('apple', ci["foo"])
- eq_('apple', ci.get("FOO"))
- eq_('apple', ci.get("Foo"))
+ assert 'apple' == ci["foo"]
+ assert 'apple' == ci.get("FOO")
+ assert 'apple' == ci.get("Foo")
del (ci['FOO'])
- eq_(None, ci.get('Foo'))
+ assert ci.get('Foo') is None
@patch("requests.post")
def test_gcm(self, mock_post):
@@ -331,18 +330,18 @@
wp.send(data, headers, gcm_key="gcm_key_value")
pdata = json.loads(mock_post.call_args[1].get('data'))
pheaders = mock_post.call_args[1].get('headers')
- eq_(pdata["registration_ids"][0], "regid123")
- eq_(pheaders.get("authorization"), "key=gcm_key_value")
- eq_(pheaders.get("content-type"), "application/json")
+ assert pdata["registration_ids"][0] == "regid123"
+ assert pheaders.get("authorization") == "key=gcm_key_value"
+ assert pheaders.get("content-type") == "application/json"
@patch("requests.post")
def test_timeout(self, mock_post):
mock_post.return_value.status_code = 200
subscription_info = self._gen_subscription_info()
WebPusher(subscription_info).send(timeout=5.2)
- eq_(mock_post.call_args[1].get('timeout'), 5.2)
+ assert mock_post.call_args[1].get('timeout') == 5.2
webpush(subscription_info, timeout=10.001)
- eq_(mock_post.call_args[1].get('timeout'), 10.001)
+ assert mock_post.call_args[1].get('timeout') == 10.001
@patch("requests.Session")
def test_send_using_requests_session(self, mock_session):
@@ -352,14 +351,14 @@
data = "Mary had a little lamb"
WebPusher(subscription_info,
requests_session=mock_session).send(data, headers)
- eq_(subscription_info.get('endpoint'),
- mock_session.post.call_args[0][0])
+ assert subscription_info.get(
+ 'endpoint') == mock_session.post.call_args[0][0]
pheaders = mock_session.post.call_args[1].get('headers')
- eq_(pheaders.get('ttl'), '0')
- eq_(pheaders.get('AUTHENTICATION'), headers.get('Authentication'))
+ assert pheaders.get('ttl') == '0'
+ assert pheaders.get('AUTHENTICATION') == headers.get('Authentication')
ckey = pheaders.get('crypto-key')
- ok_('pre-existing' in ckey)
- eq_(pheaders.get('content-encoding'), 'aes128gcm')
+ assert 'pre-existing' in ckey
+ assert pheaders.get('content-encoding') == 'aes128gcm'
class WebpushExceptionTestCase(unittest.TestCase):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/pywebpush.egg-info/PKG-INFO
new/pywebpush-1.14.0/pywebpush.egg-info/PKG-INFO
--- old/pywebpush-1.11.0/pywebpush.egg-info/PKG-INFO 2020-04-29
22:21:35.000000000 +0200
+++ new/pywebpush-1.14.0/pywebpush.egg-info/PKG-INFO 2021-07-28
16:53:28.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pywebpush
-Version: 1.11.0
+Version: 1.14.0
Summary: WebPush publication library
Home-page: https://github.com/web-push-libs/pywebpush
Author: JR Conlin
@@ -18,12 +18,12 @@
Installation
------------
- You'll need to run ``python virtualenv``. Then
+ You???ll need to run ``python virtualenv``. Then
::
- bin/pip install -r requirements.txt
- bin/python setup.py develop
+ bin/pip install -r requirements.txt
+ bin/python setup.py develop
Usage
-----
@@ -39,26 +39,29 @@
.. code:: json
- {"endpoint":
"https://updates.push.services.mozilla.com/push/v1/gAA...", "keys": {"auth":
"k8J...", "p256dh": "BOr..."}}
+ {
+ "endpoint":
"https://updates.push.services.mozilla.com/push/v1/gAA...",
+ "keys": { "auth": "k8J...", "p256dh": "BOr..." }
+ }
How you send the PushSubscription data to your backend, store it
- referenced to the user who requested it, and recall it when there's a
+ referenced to the user who requested it, and recall it when there???s a
new push subscription update is left as an exercise for the reader.
Sending Data using ``webpush()`` One Call
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In many cases, your code will be sending a single message to many
- recipients. There's a "One Call" function which will make things
easier.
+ recipients. There???s a ???One Call??? function which will make things
easier.
.. code:: python
- from pywebpush import webpush
+ from pywebpush import webpush
- webpush(subscription_info,
- data,
- vapid_private_key="Private Key or File Path[1]",
- vapid_claims={"sub": "mailto:YourEmailAddress"})
+ webpush(subscription_info,
+ data,
+ vapid_private_key="Private Key or File Path[1]",
+ vapid_claims={"sub": "mailto:YourEmailAddress"})
This will encode ``data``, add the appropriate VAPID auth headers if
required and send it to the push server identified in the
@@ -66,67 +69,67 @@
**Parameters**
- *subscription\_info* - The ``dict`` of the subscription info (described
+ *subscription_info* - The ``dict`` of the subscription info (described
above).
*data* - can be any serial content (string, bit array, serialized JSON,
etc), but be sure that your receiving application is able to parse and
- understand it. (e.g. ``data = "Mary had a little lamb."``)
+ understand it. (e.g.??``data = "Mary had a little lamb."``)
- *content\_type* - specifies the form of Encryption to use, either
+ *content_type* - specifies the form of Encryption to use, either
``'aes128gcm'`` or the deprecated ``'aesgcm'``. NOTE that not all User
Agents can decrypt ``'aesgcm'``, so the library defaults to the RFC
8188
standard form.
- *vapid\_claims* - a ``dict`` containing the VAPID claims required for
+ *vapid_claims* - a ``dict`` containing the VAPID claims required for
authorization (See
- `py\_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
+ `py_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
for more details). If ``aud`` is not specified, pywebpush will attempt
to auto-fill from the ``endpoint``.
- *vapid\_private\_key* - Either a path to a VAPID EC2 private key PEM
- file, or a string containing the DER representation. (See
- `py\_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
+ *vapid_private_key* - Either a path to a VAPID EC2 private key PEM
file,
+ or a string containing the DER representation. (See
+ `py_vapid
<https://github.com/web-push-libs/vapid/tree/master/python>`__
for more details.) The ``private_key`` may be a base64 encoded DER
formatted private key, or the path to an OpenSSL exported private key
file.
- e.g. the output of:
+ e.g.??the output of:
::
- openssl ecparam -name prime256v1 -genkey -noout -out
private_key.pem
+ openssl ecparam -name prime256v1 -genkey -noout -out private_key.pem
**Example**
.. code:: python
- from pywebpush import webpush, WebPushException
+ from pywebpush import webpush, WebPushException
- try:
- webpush(
- subscription_info={
- "endpoint": "https://push.example.com/v1/12345",
- "keys": {
- "p256dh": "0123abcde...",
- "auth": "abc123..."
- }},
- data="Mary had a little lamb, with a nice mint jelly",
- vapid_private_key="path/to/vapid_private.pem",
- vapid_claims={
- "sub": "mailto:[email protected]",
- }
- )
- except WebPushException as ex:
- print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
- # Mozilla returns additional information in the body of the
response.
- if ex.response and ex.response.json():
- extra = ex.response.json()
- print("Remote service replied with a {}:{}, {}",
- extra.code,
- extra.errno,
- extra.message
- )
+ try:
+ webpush(
+ subscription_info={
+ "endpoint": "https://push.example.com/v1/12345",
+ "keys": {
+ "p256dh": "0123abcde...",
+ "auth": "abc123..."
+ }},
+ data="Mary had a little lamb, with a nice mint jelly",
+ vapid_private_key="path/to/vapid_private.pem",
+ vapid_claims={
+ "sub": "mailto:[email protected]",
+ }
+ )
+ except WebPushException as ex:
+ print("I'm sorry, Dave, but I can't do that: {}", repr(ex))
+ # Mozilla returns additional information in the body of the
response.
+ if ex.response and ex.response.json():
+ extra = ex.response.json()
+ print("Remote service replied with a {}:{}, {}",
+ extra.code,
+ extra.errno,
+ extra.message
+ )
Methods
~~~~~~~
@@ -153,13 +156,13 @@
*ttl* Message Time To Live on Push Server waiting for the client to
reconnect (in seconds)
- *gcm\_key* Google Cloud Messaging key (if using the older GCM push
+ *gcm_key* Google Cloud Messaging key (if using the older GCM push
system) This is the API key obtained from the Google Developer Console.
- *reg\_id* Google Cloud Messaging registration ID (will be extracted
from
+ *reg_id* Google Cloud Messaging registration ID (will be extracted from
endpoint if not specified)
- *content\_encoding* ECE content encoding type (defaults to "aes128gcm")
+ *content_encoding* ECE content encoding type (defaults to
???aes128gcm???)
*curl* Do not execute the POST, but return as a ``curl`` command. This
will write the encrypted content to a local file named
@@ -175,7 +178,7 @@
.. code:: python
- WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
+ WebPusher(subscription_info).send(data, headers, ttl, gcm_key)
``.encode(data, content_encoding="aes128gcm")``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -187,53 +190,66 @@
*data* Binary string of data to send
- *content\_encoding* ECE content encoding type (defaults to "aes128gcm")
+ *content_encoding* ECE content encoding type (defaults to
???aes128gcm???)
**Example**
.. code:: python
- encoded_data = WebPush(subscription_info).encode(data)
+ encoded_data = WebPush(subscription_info).encode(data)
Stand Alone Webpush
-------------------
- If you're not really into coding your own solution, there's also a
- "stand-alone" ``pywebpush`` command in the ./bin directory.
+ If you???re not really into coding your own solution, there???s also a
+ ???stand-alone??? ``pywebpush`` command in the ./bin directory.
- This uses two files: \* the *data* file, which contains the message to
- send, in whatever form you like. \* the *subscription info* file, which
- contains the subscription information as JSON encoded data. This is
- usually returned by the Push ``subscribe`` method and looks something
- like:
+ This uses two files:
+
+ - the *data* file, which contains the message to send, in whatever
form
+ you like.
+ - the *subscription info* file, which contains the subscription
+ information as JSON encoded data. This is usually returned by the
+ Push ``subscribe`` method and looks something like:
.. code:: json
- {"endpoint": "https://push...",
+ {
+ "endpoint": "https://push...",
"keys": {
- "auth": "ab01...",
- "p256dh": "aa02..."
- }}
+ "auth": "ab01...",
+ "p256dh": "aa02..."
+ }
+ }
- If you're interested in just testing your applications WebPush
+ If you???re interested in just testing your applications WebPush
interface, you could use the Command Line:
.. code:: bash
- ./bin/pywebpush --data stuff_to_send.data --info subscription.info
+ ./bin/pywebpush --data stuff_to_send.data --info subscription.info
which will encrypt and send the contents of ``stuff_to_send.data``.
See ``./bin/pywebpush --help`` for available commands and options.
- .. |Build Status| image::
https://travis-ci.org/web-push-libs/pywebpush.svg?branch=master
+ .. |Build Status| image::
https://travis-ci.org/web-push-libs/pywebpush.svg?branch=main
:target: https://travis-ci.org/web-push-libs/pywebpush
- .. |Requirements Status| image::
https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=master
- :target:
https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=master
+ .. |Requirements Status| image::
https://requires.io/github/web-push-libs/pywebpush/requirements.svg?branch=main
+ :target:
https://requires.io/github/web-push-libs/pywebpush/requirements/?branch=main
# I am terrible at keeping this up-to-date.
+ ## 1.14.0 (2021-07-28)
+ bug: accept all VAPID key instances (thanks @mthu)
+
+ ## 1.13.0 (2021-03-15)
+ Support requests_session param in webpush fn too
+
+ ## 1.12.0 (2021-03-15)
+ chore: library update, remove nose tests
+
## 1.11.0 (2020-04-29)
feat: add `--head` to read headers out of a json file (thanks @braedon)
@@ -286,9 +302,4 @@
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/pywebpush.egg-info/SOURCES.txt
new/pywebpush-1.14.0/pywebpush.egg-info/SOURCES.txt
--- old/pywebpush-1.11.0/pywebpush.egg-info/SOURCES.txt 2020-04-29
22:21:35.000000000 +0200
+++ new/pywebpush-1.14.0/pywebpush.egg-info/SOURCES.txt 2021-07-28
16:53:28.000000000 +0200
@@ -4,7 +4,8 @@
MANIFEST.in
README.md
README.rst
-local_test.txt
+data.txt
+data_128.txt
requirements.txt
setup.cfg
setup.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/pywebpush.egg-info/requires.txt
new/pywebpush-1.14.0/pywebpush.egg-info/requires.txt
--- old/pywebpush-1.11.0/pywebpush.egg-info/requires.txt 2020-04-29
22:21:35.000000000 +0200
+++ new/pywebpush-1.14.0/pywebpush.egg-info/requires.txt 2021-07-28
16:53:28.000000000 +0200
@@ -1,4 +1,5 @@
cryptography>=2.6.1
http-ece>=1.1.0
-requests>=2.21.0
py-vapid>=1.7.0
+requests>=2.21.0
+six>=1.15.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/requirements.txt
new/pywebpush-1.14.0/requirements.txt
--- old/pywebpush-1.11.0/requirements.txt 2020-04-29 22:17:24.000000000
+0200
+++ new/pywebpush-1.14.0/requirements.txt 2021-04-07 04:05:47.000000000
+0200
@@ -1,4 +1,5 @@
cryptography>=2.6.1
http-ece>=1.1.0
requests>=2.21.0
+six>=1.15.0
py-vapid>=1.7.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/setup.py
new/pywebpush-1.14.0/setup.py
--- old/pywebpush-1.11.0/setup.py 2020-04-29 22:17:41.000000000 +0200
+++ new/pywebpush-1.14.0/setup.py 2021-07-28 16:33:32.000000000 +0200
@@ -4,7 +4,7 @@
from setuptools import find_packages, setup
-__version__ = "1.11.0"
+__version__ = "1.14.0"
def read_from(file):
@@ -38,19 +38,13 @@
"Topic :: Internet :: WWW/HTTP",
"Programming Language :: Python :: Implementation :: PyPy",
'Programming Language :: Python',
- "Programming Language :: Python :: 2",
- "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.4",
- "Programming Language :: Python :: 3.5",
- "Programming Language :: Python :: 3.6",
],
keywords='push webpush publication',
author="JR Conlin",
author_email="[email protected]",
url='https://github.com/web-push-libs/pywebpush',
license="MPL2",
- test_suite="nose.collector",
include_package_data=True,
zip_safe=False,
install_requires=read_from('requirements.txt'),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pywebpush-1.11.0/test-requirements.txt
new/pywebpush-1.14.0/test-requirements.txt
--- old/pywebpush-1.11.0/test-requirements.txt 2017-06-05 16:47:08.000000000
+0200
+++ new/pywebpush-1.14.0/test-requirements.txt 2021-04-07 04:05:47.000000000
+0200
@@ -1,5 +1,5 @@
-r requirements.txt
-nose>=1.3.7
+pytest
coverage>=4.4.1
mock>=2.0.0
flake8>=3.3.0