You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add documentation for setVapidDetails method (#787)
* add documentation for setVapidDetails method
document the setVapidDetails method
add warning about Safari and localhost URIs as VAPID subject
* add check for https://localhost to VAPID subject validator
emit sensible warning to user when localhost URI is detected
Copy file name to clipboardExpand all lines: README.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,6 +193,8 @@ that may either be a string URI of the proxy server (eg. http://< hostname >:< p
193
193
or an "options" object with more specific properties.
194
194
-**agent** is the [HTTPS Agent instance](https://nodejs.org/dist/latest/docs/api/https.html#https_class_https_agent) which will be used in the `https.request` method. If the `proxy` options defined, `agent` will be ignored!
195
195
196
+
> **Note:** As of this writing, if a push notification request contains a VAPID `subject` referencing an `https://localhost` URI (set either using the `options` argument or via the global `setVapidDetails()` method), Safari's push notification endpoint rejects the request with a `BadJwtToken` error.
197
+
196
198
### Returns
197
199
198
200
A promise that resolves if the notification was sent successfully
Globally sets the application's VAPID subject, public key, and private key, to be used in subsequent calls to `sendNotification()` and `generateRequestDetails()` that don't specifically override them in their `options` argument.
266
+
267
+
### Input
268
+
269
+
The `setVapidDetails` method expects the following input:
270
+
271
+
-*subject*: the VAPID server contact information, as either an `https:` or `mailto:` URI ([as per the VAPID spec](https://datatracker.ietf.org/doc/html/draft-thomson-webpush-vapid#section-2.1)).
console.warn('VAPID subject points to a localhost web URI, which is unsupported by Apple\'s push notification server and will result in a BadJwtToken error when sending notifications.');
0 commit comments