Instead of having a module-scoped gcmAPIKey and vapidDetails in src/web-push-lib.js, we change those to instance properties of a WebPushLib class instance.
When re-exporting the setGCMAPIKey, setVapidDetails, generateRequestDetails for the global instance of WebPushLib, we need to .bind() the methods to retain the this context.
Also export the WebPushLib constructor so users can create multiple instances instead of just using the global instance.
Goal
Resolves #876
Implementation
gcmAPIKey
andvapidDetails
insrc/web-push-lib.js
, we change those to instance properties of aWebPushLib
class instance.setGCMAPIKey
,setVapidDetails
,generateRequestDetails
for the global instance ofWebPushLib
, we need to.bind()
the methods to retain thethis
context.WebPushLib
constructor so users can create multiple instances instead of just using the global instance.