From 87a6261744e9a844a0134ae61691b216a5726af1 Mon Sep 17 00:00:00 2001 From: Anya Zenkina Date: Mon, 1 Jul 2019 11:52:34 +0100 Subject: [PATCH 1/3] add Pusher Channels mention where absent --- README.md | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index b427df6..7b1bfc3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Pusher Node.js REST library +# Pusher Channels Node.js REST library In order to use this library, you need to have an account on . After registering, you will need the application credentials for your app. @@ -48,7 +48,7 @@ There are 3 ways to configure the client. First one is just using the Pusher con ```javascript var Pusher = require('pusher'); -var pusher = new Pusher({ +var channels_client = new Pusher({ appId: 'APP_ID', key: 'APP_KEY', secret: 'SECRET_KEY', @@ -65,7 +65,7 @@ For specific clusters, you can use the `forCluster` function. This is the same a ```javascript var Pusher = require('pusher'); -var pusher = Pusher.forCluster("CLUSTER", { +var channels_client = Pusher.forCluster("CLUSTER", { appId: 'APP_ID', key: 'APP_KEY', secret: 'SECRET_KEY', @@ -80,7 +80,7 @@ You can also specify auth and endpoint options by passing an URL: ```javascript var Pusher = require('pusher'); -var pusher = Pusher.forURL("SCHEME://APP_KEY:SECRET_KEY@HOST:PORT/apps/APP_ID"); +var channels_client = Pusher.forURL("SCHEME://APP_KEY:SECRET_KEY@HOST:PORT/apps/APP_ID"); ``` You can pass the optional second argument with options, as in `forCluster` function. @@ -95,7 +95,7 @@ There are a few additional options that can be used in all above methods: ```javascript var Pusher = require('pusher'); -var pusher = new Pusher({ +var channels_client = new Pusher({ // you can set other options in any of the 3 ways described above proxy: 'HTTP_PROXY_URL', // optional, URL to proxy the requests through timeout: TIMEOUT, // optional, timeout for all requests in milliseconds @@ -109,7 +109,7 @@ var pusher = new Pusher({ #### API requests -Asynchronous methods on the Pusher class (`trigger`, `get` and `post`) take an optional callback as the last argument. After performing the request, the callback is called with three arguments: +Asynchronous methods on the Pusher Channels class (`trigger`, `get` and `post`) take an optional callback as the last argument. After performing the request, the callback is called with three arguments: - error - if the request can't be performed or returns an error code, error will contain details, otherwise it will be null - request - the request object @@ -128,7 +128,7 @@ To send an event to one or more channels use the trigger function. Channel names #### Single channel ```javascript -pusher.trigger('channel-1', 'test_event', { message: "hello world" }); +channels_client.trigger('channel-1', 'test_event', { message: "hello world" }); ``` #### Multiple channels @@ -136,14 +136,14 @@ pusher.trigger('channel-1', 'test_event', { message: "hello world" }); To trigger an event on multiple channels: ```javascript -pusher.trigger([ 'channel-1', 'channel-2' ], 'test_event', { message: "hello world" }); +channels_client.trigger([ 'channel-1', 'channel-2' ], 'test_event', { message: "hello world" }); ``` You can trigger an event to at most 100 channels at once. Passing more than 100 channels will cause an exception to be thrown. #### Batch events -If you wish to send multiple events in a single HTTP request, you can pass an array of events to `pusher.triggerBatch`. You can send up to a maximum of 10 events at once. +If you wish to send multiple events in a single HTTP request, you can pass an array of events to `channels_client.triggerBatch`. You can send up to a maximum of 10 events at once. ```javascript var events = [{ @@ -157,7 +157,7 @@ var events = [{ data: {message: "hello another world"} }]; -pusher.triggerBatch(events); +channels_client.triggerBatch(events); ``` You can trigger a batch of up to 10 events. @@ -168,7 +168,7 @@ In order to avoid the client that triggered the event from also receiving it, th ```javascript var socketId = '1302.1081607'; -pusher.trigger(channel, event, data, socketId); +channels_client.trigger(channel, event, data, socketId); ``` ### End-to-end encryption [BETA] @@ -180,7 +180,7 @@ This library supports end-to-end encryption of your private channels. This means 2. Next, Specify your 32 character `encryption_master_key`. This is secret and you should never share this with anyone. Not even Pusher. ```javascript - var pusher = new Pusher({ + var channels_client = new Pusher({ appId: 'APP_ID', key: 'APP_KEY', secret: 'SECRET_KEY', @@ -198,7 +198,7 @@ This library supports end-to-end encryption of your private channels. This means **Limitation**: you cannot trigger a single event on multiple channels in a call to `trigger`, e.g. ```javascript -pusher.trigger([ 'channel-1', 'private-encrypted-channel-2' ], 'test_event', { message: "hello world" }); +channels_client.trigger([ 'channel-1', 'private-encrypted-channel-2' ], 'test_event', { message: "hello world" }); ``` Rationale: the methods in this library map directly to individual Channels HTTP API requests. If we allowed triggering a single event on multiple channels (some encrypted, some unencrypted), then it would require two API requests: one where the event is encrypted to the encrypted channels, and one where the event is unencrypted for unencrypted channels. @@ -208,7 +208,7 @@ Rationale: the methods in this library map directly to individual Channels HTTP To authorise your users to access private channels on Pusher, you can use the `authenticate` function: ```javascript -var auth = pusher.authenticate(socketId, channel); +var auth = channels_client.authenticate(socketId, channel); ``` For more information see: @@ -225,7 +225,7 @@ var channelData = { twitter_id: '@leggetter' } }; -var auth = pusher.authenticate(socketId, channel, channelData); +var auth = channels_client.authenticate(socketId, channel, channelData); ``` The `auth` is then returned to the caller as JSON. @@ -234,10 +234,10 @@ For more information see: ### Application state -It's possible to query the state of the application using the `pusher.get` function. +It's possible to query the state of the application using the `channels_client.get` function. ```javascript -pusher.get({ path: path, params: params }, callback); +channels_client.get({ path: path, params: params }, callback); ``` The `path` property identifies the resource that the request should be made to and the `params` property should be a map of additional query string key and value pairs. @@ -251,7 +251,7 @@ Params can't include following keys: The following example provides the signature of the callback and an example of parsing the result: ```javascript -pusher.get({ path: '/channels', params: {} }, function(error, request, response) { +channels_client.get({ path: '/channels', params: {} }, function(error, request, response) { if (response.statusCode === 200) { var result = JSON.parse(response.body); var channelsInfo = result.channels; @@ -262,7 +262,7 @@ pusher.get({ path: '/channels', params: {} }, function(error, request, response) #### Get the list of channels in an application ```javascript -pusher.get({ path: '/channels', params: params }, callback); +channels_client.get({ path: '/channels', params: params }, callback); ``` Information on the optional `params` and the structure of the returned JSON is defined in the [REST API reference](http://pusher.com/docs/rest_api#method-get-channels). @@ -270,7 +270,7 @@ Information on the optional `params` and the structure of the returned JSON is d #### Get the state of a channel ```javascript -pusher.get({ path: '/channels/[channel_name]', params: params }, callback); +channels_client.get({ path: '/channels/[channel_name]', params: params }, callback); ``` Information on the optional `params` option property and the structure of the returned JSON is defined in the [REST API reference](http://pusher.com/docs/rest_api#method-get-channel). @@ -278,7 +278,7 @@ Information on the optional `params` option property and the structure of the re #### Get the list of users in a presence channel ```javascript -pusher.get({ path: '/channels/[channel_name]/users' }, callback); +channels_client.get({ path: '/channels/[channel_name]/users' }, callback); ``` The `channel_name` in the path must be a [presence channel](http://pusher.com/docs/presence). The structure of the returned JSON is defined in the [REST API reference](http://pusher.com/docs/rest_api#method-get-users). @@ -288,7 +288,7 @@ The `channel_name` in the path must be a [presence channel](http://pusher.com/do The library provides a simple helper for WebHooks, which can be accessed via Pusher instances: ```javascript -var webhook = pusher.webhook(request); +var webhook = channels_client.webhook(request); ``` Requests must expose following fields: @@ -311,7 +311,7 @@ Validates the content type, body format and signature of the WebHook and returns Accepts an optional parameter containing additional application tokens (useful e.g. during migrations): ```javascript -var webhook = pusher.webhook(request); +var webhook = channels_client.webhook(request); // will check only the key and secret assigned to the pusher object: webhook.isValid(); // will also check two additional tokens: @@ -352,7 +352,7 @@ webhook.getTime(); If you wanted to send the REST API requests manually (e.g. using a different HTTP client), you can use the `createSignedQueryString` method to generate the whole request query string that includes the auth keys and your parameters. ```javascript -pusher.createSignedQueryString({ +channels_client.createSignedQueryString({ method: "POST", // the HTTP request method path: "/apps/3/events", // the HTTP request path body: '{"name":"foo","channel":"donuts","data":"2-for-1"}', // optional, the HTTP request body @@ -380,13 +380,13 @@ you've got all required modules installed: ### Running the local test suite -You can run local integration tests without setting up a Pusher app: +You can run local integration tests without setting up a Pusher Channels app: node_modules/.bin/mocha tests/integration/**/*.js ### Running the complete test suite -In order to run the full test suite, first you need a Pusher app. When starting +In order to run the full test suite, first you need a Pusher Channels app. When starting mocha, you need to set the PUSHER_URL environment variable to contain your app credentials, like following: From e5231687a0c3524fe559d46d4a710ae987f28467 Mon Sep 17 00:00:00 2001 From: Anya Zenkina Date: Tue, 2 Jul 2019 13:55:16 +0100 Subject: [PATCH 2/3] respect comments in pr --- CHANGELOG.md | 4 ++++ README.md | 14 +++++++------- package.json | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f48f3..02c1ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.1 (2019-07-02) + +no-op release to fix the description on https://www.npmjs.com/package/pusher + ## 2.2.0 (2018-11-26) [ADDED] This release adds support for end-to-end encryption, a new feature for Channels. Read more [in our docs](https://pusher.com/docs/client_api_guide/client_encrypted_channels). diff --git a/README.md b/README.md index 7b1bfc3..e89bd79 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pusher Channels Node.js REST library -In order to use this library, you need to have an account on . After registering, you will need the application credentials for your app. +In order to use this library, you need to have an account on . After registering, you will need the application credentials for your app. ## Installation @@ -109,7 +109,7 @@ var channels_client = new Pusher({ #### API requests -Asynchronous methods on the Pusher Channels class (`trigger`, `get` and `post`) take an optional callback as the last argument. After performing the request, the callback is called with three arguments: +Asynchronous methods on the `Pusher` class (`trigger`, `get` and `post`) take an optional callback as the last argument. After performing the request, the callback is called with three arguments: - error - if the request can't be performed or returns an error code, error will contain details, otherwise it will be null - request - the request object @@ -205,7 +205,7 @@ Rationale: the methods in this library map directly to individual Channels HTTP ### Authenticating private channels -To authorise your users to access private channels on Pusher, you can use the `authenticate` function: +To authorise your users to access private channels on Pusher Channels, you can use the `authenticate` function: ```javascript var auth = channels_client.authenticate(socketId, channel); @@ -298,9 +298,9 @@ Requests must expose following fields: Since neither Node.js nor express provide the body in the request, your application needs to read it and assign to the request object. See examples/webhook_endpoint.js for a simple webhook endpoint implementation using the express framework. Headers object must contain following headers: -- x-pusher-key - application key, sent by Pusher -- x-pusher-signature - WebHook signature, generated by Pusher -- content-type - must be set to application/json, what Pusher does +- x-pusher-key - application key, sent by Channels +- x-pusher-signature - WebHook signature, generated by Channels +- content-type - must be set to application/json, what Channels does After instantiating the WebHook object, you can use its following methods: @@ -340,7 +340,7 @@ webhook.getEvents(); #### getTime -Returns the Date object for the time when the WebHook was sent from Pusher. Throws a Pusher.WebHookError if the WebHook is invalid, so please check the `isValid` result before accessing the time. +Returns the Date object for the time when the WebHook was sent from Channels. Throws a `Pusher.WebHookError` if the WebHook is invalid, so please check the `isValid` result before accessing the time. ```javascript // will return a Date object diff --git a/package.json b/package.json index 5a9a159..f866bc1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pusher", - "description": "Node.js client to interact with the Pusher REST API", - "version": "2.2.0", + "description": "Node.js client to interact with the Pusher Channels REST API", + "version": "2.2.1", "author": "Pusher ", "contributors": [ { From cfa163f42ee7a728be98af9123009bb815a620f2 Mon Sep 17 00:00:00 2001 From: Anya Zenkina Date: Wed, 3 Jul 2019 11:13:27 +0100 Subject: [PATCH 3/3] remove unnecessary version change --- CHANGELOG.md | 4 ---- package.json | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c1ce6..a2f48f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,3 @@ -## 2.2.1 (2019-07-02) - -no-op release to fix the description on https://www.npmjs.com/package/pusher - ## 2.2.0 (2018-11-26) [ADDED] This release adds support for end-to-end encryption, a new feature for Channels. Read more [in our docs](https://pusher.com/docs/client_api_guide/client_encrypted_channels). diff --git a/package.json b/package.json index f866bc1..8b73b91 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pusher", "description": "Node.js client to interact with the Pusher Channels REST API", - "version": "2.2.1", + "version": "2.2.0", "author": "Pusher ", "contributors": [ {