Comparing version 1.0.0 to 2.0.0
{ | ||
"name": "pushy", | ||
"description": "Publish-Subscribe system for realtime webapps", | ||
"version": "1.0.0", | ||
"author": { | ||
"name": "Julien Ballestracci", | ||
"email": "julien@nitronet.org" | ||
"version": "2.0.0", | ||
"description": "The official Node.js package for sending push notifications with Pushy.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"dependencies": { | ||
"express": "3.1.0", | ||
"node-uuid": "1.4.0", | ||
"sockjs": "0.3.5" | ||
}, | ||
"keywords": [ | ||
"pushy", | ||
"realtime", | ||
"system", | ||
"web", | ||
"publish", | ||
"subscribe", | ||
"pubsub", | ||
"api" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/spokela/pushy-node" | ||
"url": "git+https://github.com/pushy-me/pushy-node.git" | ||
}, | ||
"main": "./lib/pushy", | ||
"engines": { | ||
"node": "*" | ||
"author": "Pushy <support@pushy.me>", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/pushy-me/pushy-node/issues" | ||
}, | ||
"readmeFilename": "README.md", | ||
"license": "MIT", | ||
"preferGlobal": "false" | ||
"homepage": "https://github.com/pushy-me/pushy-node#readme", | ||
"dependencies": { | ||
"bluebird": "^3.4.1", | ||
"request": "^2.72.0" | ||
} | ||
} |
149
README.md
@@ -1,120 +0,71 @@ | ||
# Pushy Server | ||
# pushy-node | ||
[](https://www.npmjs.com/package/pushy-node) | ||
Pushy is a Publish/Subscribe system for realtime web applications. | ||
This is the server-side made on top of NodeJS and SockJS. | ||
The official Node.js package for sending push notifications with [Pushy](https://pushy.me/). | ||
## Install via NPM | ||
> [Pushy](https://pushy.me/) is the most reliable push notification gateway, perfect for real-time, mission-critical applications. | ||
``` | ||
npm install pushy | ||
``` | ||
**Note:** If you don't have an existing Node.js project, consider using our [sample Node.js API project](https://github.com/pushy-me/pushy-node-backend) as a starting point to make things easier for you. | ||
## Run the service | ||
## Usage | ||
### Start NodeJS/Pushy: | ||
First, install the package using npm: | ||
```shell | ||
npm install pushy-node --save | ||
``` | ||
$ node pushy-server.js config.json | ||
``` | ||
### Trigger an event on a channel | ||
Then, use the following sample code to send a push notification to target devices: | ||
To trigger an event on a specific channel, hit the following URL with the required parameters. POST data will be sent alongside the event. | ||
```js | ||
var Pushy = require('pushy-node'); | ||
``` | ||
http(s)://<pushy-host>:<pushy-port>/pushy/channel/<channel-name>/trigger?event=<event-name>×tamp=<current-ts>&auth_key=<auth-key> | ||
``` | ||
// Plug in your Secret API Key | ||
// Get it here: https://dashboard.pushy.me/ | ||
var pushyAPI = new Pushy('SECRET_API_KEY'); | ||
Parameters: | ||
* ```pushy-host``` : the hostname of your Pushy server | ||
* ```pushy-port``` : the listening port you defined in *config.json* | ||
* ```channel-name``` : name of the channel where the event should be dispatched | ||
* ```event-name``` : name of the event | ||
* ```current-ts``` : your app's timestamp (UNIXTIME). 600 seconds difference (+/-) is tolerated. | ||
* ```auth-key``` : SHA256 auth key for this command (read more bellow) | ||
// Set push payload data to deliver to device(s) | ||
var data = { | ||
message: 'Hello World!' | ||
}; | ||
### Generating authentication key | ||
// Insert target device token(s) here | ||
var tokens = ['DEVICE_TOKEN']; | ||
The authentication key is a SHA256 sum of: | ||
// Set optional push notification options (such as TTL) | ||
var options = { | ||
// Set the notification to expire if not delivered within 30 seconds | ||
time_to_live: 30 | ||
}; | ||
// Send push notification via the Push Notifications API | ||
// https://pushy.me/docs/api/send-notifications | ||
pushyAPI.sendPushNotification(data, tokens, options, function (err, id) { | ||
// Log errors to console | ||
if (err) { | ||
return console.log('Fatal Error', err); | ||
} | ||
// Log success | ||
console.log('Push sent successfully! (ID: ' + id + ')'); | ||
}); | ||
``` | ||
<channel>:<event>:<timestamp>:<JsonEncodedBody>:<secretKey> | ||
``` | ||
Example: we want to send a *test* event to the *Hello* channel, the current timestamp is *123456789* and we don't send any data. Our secret key is *secret*. | ||
Alternatively, send the notification using promises: | ||
```js | ||
pushyAPI.sendPushNotification(data, tokens, options) | ||
.then(function (id) { | ||
// Log success | ||
console.log('Push sent successfully! (ID: ' + id + ')'); | ||
}).catch(function (err) { | ||
// Log errors to console | ||
return console.log(err); | ||
}); | ||
``` | ||
signature string: hello:test:123456789:{}:secret | ||
auth_key: d7f4c3309757c4025269b6576eae10028ec0711c88e6ef605bb44d149cb07803 | ||
``` | ||
## Private and Presence-enabled Channels | ||
Make sure to replace `SECRET_API_KEY` with your app's Secret API Key listed in the [Dashboard](https://dashboard.pushy.me/). | ||
Any channel named ```private-```something will require an authentification string sent on subscription. If any complementary data is sent, *presence* will be enabled too. | ||
## License | ||
### Authentication | ||
The authentication token should be generated server-side when requested by the client. Then the client should resend his subscription request with this token. | ||
The authentication token is a SHA256 hash generated by this signature string: | ||
``` | ||
<connection_id>:<channel>[:<JsonEncodedPresenceData>]:<secretKey> | ||
``` | ||
Parameters: | ||
* ```connection_id``` : The connection ID (given to client on connection) | ||
* ```channel``` : Lowercased channel name | ||
* ```JsonEncodedPresenceData``` *optional* : Json encoded presence data (if any) | ||
* ```secretKey``` : Your configured secret key | ||
### Presence-enabled channels | ||
When *presence* is enabled on a channel, presence data sent on subscription will be shared between members everytime a new subscriber join. | ||
The channel will trigger two additionnal events: | ||
* ```pushy:presence-add``` : when a new subscriber join (with its presence data) | ||
* ```pushy:presence-quit``` : when a subscriber quit | ||
When subscribing to a presence-enabled channel, the client will recieve presence data from all current subscribers. | ||
**IMPORTANT** : Presence data is SHARED so please don't put passwords or any sensitive data here. Since its sent very often, it might also be a good idea to keep this data as light as possible (just a username and his avatar-url for example). | ||
## Configuration parameters | ||
* ```port``` *int* : HTTP Port number (default is 8123) | ||
* ```secretKey``` *string* : Secret/long string used server-side to do authentification. | ||
* ```ssl``` *boolean* : Run as an HTTPS server (defaults to false) | ||
* ```sockjs``` *object* : Default SockJS options (see SockJS documentation) | ||
## Commands | ||
Commands are callables made available to the client to interact with your Pushy server througth the SockJS socket. Obviously, the two default commands are *SUBSCRIBE* and *UNSUBSCRIBE* but you can easily add other commands to fit your needs. This can be useful for games, chats etc.. | ||
A command signature looks like this: | ||
``` javascript | ||
// Command example | ||
// | ||
// @param SockJsServer sockjs The SockJS server handle (@see lib/sockjs-server.js) | ||
// @param SockJSConnection connection The SockJS connection handle sending the command | ||
// @param Object data Data sent alongside the command | ||
// @param Manager channels Channels Manager instance (@see lib/manager.js) | ||
function(sockjs, connection, data, channels) { | ||
// do something | ||
} | ||
``` | ||
## LICENSE | ||
This software is licensed under the MIT License. Please refer to the LICENSE file for more details. | ||
``` | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
``` | ||
[Apache 2.0](LICENSE) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
2
0
100
0
0
18744
7
129
72
2
+ Addedbluebird@^3.4.1
+ Addedrequest@^2.72.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedexpress@3.1.0
- Removednode-uuid@1.4.0
- Removedsockjs@0.3.5
- Removedbuffer-crc32@0.1.1(transitive)
- Removedbytes@0.1.0(transitive)
- Removedcommander@0.6.1(transitive)
- Removedconnect@2.7.2(transitive)
- Removedcookie@0.0.5(transitive)
- Removedcookie-signature@0.0.1(transitive)
- Removeddebug@4.4.0(transitive)
- Removedexpress@3.1.0(transitive)
- Removedfaye-websocket@0.4.0(transitive)
- Removedformidable@1.0.11(transitive)
- Removedfresh@0.1.0(transitive)
- Removedmethods@0.0.1(transitive)
- Removedmime@1.2.6(transitive)
- Removedmkdirp@0.3.3(transitive)
- Removedms@2.1.3(transitive)
- Removednode-uuid@1.3.31.4.0(transitive)
- Removedpause@0.0.1(transitive)
- Removedqs@0.5.1(transitive)
- Removedrange-parser@0.0.4(transitive)
- Removedsend@0.1.0(transitive)
- Removedsockjs@0.3.5(transitive)