Skip to content

Commit 39a7d23

Browse files
authored
Merge pull request #11 from web-push-libs/bug/15
bug: fix "aud" to not be remote host url
2 parents 103757d + 3f8a3b5 commit 39a7d23

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

js/vapid.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class VapidToken {
2020
*
2121
* VAPID allows for self identification of a subscription update.
2222
*
23-
* :param aud: Audience - email of the admin contact for this update.
24-
* :param sub: Subscription - Optional site URL for this update.
23+
* :param sub: Subscription - email of the admin contact for this
24+
* update.
2525
* :param exp: Expiration - UTC expiration of this update. Defaults
2626
* to now + 24 hours
2727
*/
@@ -157,8 +157,8 @@ class VapidToken {
157157
if (! claims.hasOwnProperty("exp")) {
158158
claims.exp = parseInt(Date.now()*.001) + 86400;
159159
}
160-
if (! claims.hasOwnProperty("aud")) {
161-
throw new Error(this.lang.errs.ERR_CLAIM_MIS, "aud");
160+
if (! claims.hasOwnProperty("sub")) {
161+
throw new Error(this.lang.errs.ERR_CLAIM_MIS, "sub");
162162
}
163163
let alg = {name:"ECDSA", namedCurve: "P-256", hash:{name:"SHA-256"}};
164164
let headStr = this.mzcc.toUrlBase64(

python/py_vapid/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ def sign(self, claims, crypto_key=None):
106106
"""
107107
if not claims.get('exp'):
108108
claims['exp'] = int(time.time()) + 86400
109-
if not claims.get('aud'):
110-
raise VapidException(
111-
"Missing 'aud' from claims. "
112-
"'aud' is your site's URL.")
113109
if not claims.get('sub'):
114110
raise VapidException(
115111
"Missing 'sub' from claims. "

python/py_vapid/tests/test_vapid.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,5 @@ def test_bad_sign(self):
115115
v = Vapid("/tmp/private")
116116
self.assertRaises(VapidException,
117117
v.sign,
118-
{'sub': "[email protected]"})
119-
self.assertRaises(VapidException,
120-
v.sign,
121-
{'aud': "https://e.c"})
118+
{'aud': "p.example.com"})
122119

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

6-
__version__ = "0.4.1"
6+
__version__ = "0.5.0"
77

88

99
def read_from(file):

0 commit comments

Comments
 (0)