This repository has been archived by the owner on Apr 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Some basic docs to get started with #2
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,43 @@ This library provides the functions necessary to encrypt a payload for sending | |
with the Web Push protocol. It also includes a helper function for actually | ||
send the message to the Web Push endpoint. | ||
|
||
What is this for? | ||
----------------- | ||
|
||
The [Push API](http://w3c.github.io/push-api/) allow users to subscribe for | ||
notifications from a web site, which can be delivered to them even if the | ||
browser has been closed. This was first shipped as part of Chrome 42, but the | ||
push message could not contain any payload data. | ||
|
||
As of Chrome 50 and Firefox 44 (desktop-only) payloads are supported, but the | ||
server must encrypt the payload or the receiving browser will reject it. | ||
|
||
This library implements the necessary encryption as a Node module. | ||
|
||
Overview | ||
-------- | ||
|
||
Install the module using npm: | ||
|
||
`npm install web-push-encryption` | ||
|
||
Require the module: | ||
|
||
`var webpush = require('web-push-encryption');` | ||
|
||
Send a message: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seriously, that's all I need to do, I don't need to create any keys, certificates, sign anything, jump on one leg three times while patting my head? If so, I <3 this. |
||
|
||
`webpush.sendWebPush('Yay! Web Push!', subscription);` | ||
|
||
If the push service requires an authentication header (notably Google Cloud | ||
Messaging, used by Chrome) then you can add that as a third parameter: | ||
|
||
``` | ||
if (subscription.endpoint.indexOf('https://android.googleapis.com/gcm/send/') === 0) { | ||
webpush.sendWebPush('A message for Chrome', subscription, MY_GCM_KEY); | ||
} | ||
``` | ||
|
||
Support | ||
------- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the name we are actually published on? Does it make sense to make it slightly more generic if we can support encrypted push and just tickles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted
web-push
but Mozilla got there first :)Will open an issue.