pusher 1.3.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7460762ae77605d5132b729dfccf7610ec5eb956
4
- data.tar.gz: bf8ce2cb6c8a433e261d0c314dc65ec56e6fe9f7
2
+ SHA256:
3
+ metadata.gz: 9c186f5455002119a1783a5d4fe40df5f60db90a5a028fbcfc2d792efd3ef993
4
+ data.tar.gz: 8efdc4ef40dd9fbe41ce6d9695e2e4a5eddb79d2f462d3ce2a68f6475cb6afe8
5
5
  SHA512:
6
- metadata.gz: 98f95bce77fe09335f14f45b99edcf7e5d40f59cd1fd7660b3a6ba86678d34169747534bcdb9af64cdb364d60ca42ea03e1070e28594a5c4eacc5d34bfd75553
7
- data.tar.gz: b79d4eba9c63c4a4e421b3d2f8a93f4017c9053d5dd6994d4405460c02f14a2c12aaadbff27408c88fc2a0b0df9871a45b309ca6683b9803c793b33e3c92eac6
6
+ metadata.gz: 9182e53ee76a64c33205fd7dfbcf5ad7b35bcf9934096baa380fa1f6ab89acaeb770ccba76eb8a9a6c4fd8abe8f848cae605a784ed67ed2a52b52bbc65a0495e
7
+ data.tar.gz: aa4faf02269292f19ea9724de6562a128dfaf37cc3ee34caf7941a9f3e50cb55cdea1a75b05323d3fe8ed93a92ce7e682fc59d1116e5377f3c1c73af6eea015e
data/.github/stale.yml ADDED
@@ -0,0 +1,26 @@
1
+ # Configuration for probot-stale - https://github.com/probot/stale
2
+
3
+ # Number of days of inactivity before an Issue or Pull Request becomes stale
4
+ daysUntilStale: 90
5
+
6
+ # Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7
+ # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8
+ daysUntilClose: 7
9
+
10
+ # Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11
+ onlyLabels: []
12
+
13
+ # Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14
+ exemptLabels:
15
+ - pinned
16
+ - security
17
+
18
+ # Set to true to ignore issues with an assignee (defaults to false)
19
+ exemptAssignees: true
20
+
21
+ # Comment to post when marking as stale. Set to `false` to disable
22
+ markComment: >
23
+ This issue has been automatically marked as stale because it has not had
24
+ recent activity. It will be closed if no further activity occurs. If you'd
25
+ like this issue to stay open please leave a comment indicating how this issue
26
+ is affecting you. Thank you.
@@ -0,0 +1,35 @@
1
+ name: Github Release
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ jobs:
8
+ create-release:
9
+ name: Create Release
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v2
14
+ - name: Setup git
15
+ run: |
16
+ git config user.email "pusher-ci@pusher.com"
17
+ git config user.name "Pusher CI"
18
+ - name: Prepare description
19
+ run: |
20
+ csplit -s CHANGELOG.md "/##/" {1}
21
+ cat xx01 > CHANGELOG.tmp
22
+ - name: Prepare tag
23
+ run: |
24
+ export TAG=$(head -1 CHANGELOG.tmp | cut -d' ' -f2)
25
+ echo "TAG=$TAG" >> $GITHUB_ENV
26
+ - name: Create Release
27
+ uses: actions/create-release@v1
28
+ env:
29
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30
+ with:
31
+ tag_name: ${{ env.TAG }}
32
+ release_name: ${{ env.TAG }}
33
+ body_path: CHANGELOG.tmp
34
+ draft: false
35
+ prerelease: false
@@ -0,0 +1,17 @@
1
+ name: RubyGems release
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v1
13
+
14
+ - name: Publish gem
15
+ uses: dawidd6/action-publish-gem@v1
16
+ with:
17
+ api_key: ${{secrets.RUBYGEMS_API_KEY}}
@@ -0,0 +1,71 @@
1
+ name: Release
2
+
3
+ on:
4
+ pull_request:
5
+ types: [ labeled ]
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ prepare-release:
11
+ name: Prepare release
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Set major release
16
+ if: ${{ github.event.label.name == 'release-major' }}
17
+ run: echo "RELEASE=major" >> $GITHUB_ENV
18
+ - name: Set minor release
19
+ if: ${{ github.event.label.name == 'release-minor' }}
20
+ run: echo "RELEASE=minor" >> $GITHUB_ENV
21
+ - name: Set patch release
22
+ if: ${{ github.event.label.name == 'release-patch' }}
23
+ run: echo "RELEASE=patch" >> $GITHUB_ENV
24
+ - name: Check release env
25
+ run: |
26
+ if [[ -z "${{ env.RELEASE }}" ]];
27
+ then
28
+ echo "You need to set a release label on PRs to the main branch"
29
+ exit 1
30
+ else
31
+ exit 0
32
+ fi
33
+ - name: Install semver-tool
34
+ run: |
35
+ export DIR=$(mktemp -d)
36
+ cd $DIR
37
+ curl https://github.com/fsaintjacques/semver-tool/archive/3.2.0.tar.gz -L -o semver.tar.gz
38
+ tar -xvf semver.tar.gz
39
+ sudo cp semver-tool-3.2.0/src/semver /usr/local/bin
40
+ - name: Bump version
41
+ run: |
42
+ export CURRENT=$(gem info pusher --remote --exact | grep -o "pusher ([0-9]*\.[0-9]*\.[0-9]*)" | awk -F '[()]' '{print $2}')
43
+ export NEW_VERSION=$(semver bump ${{ env.RELEASE }} $CURRENT)
44
+ echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
45
+ - name: Checkout code
46
+ uses: actions/checkout@v2
47
+ - name: Setup git
48
+ run: |
49
+ git config user.email "pusher-ci@pusher.com"
50
+ git config user.name "Pusher CI"
51
+ git fetch
52
+ git checkout ${{ github.event.pull_request.head.ref }}
53
+ - name: Prepare CHANGELOG
54
+ run: |
55
+ echo "${{ github.event.pull_request.body }}" | csplit -s - "/##/"
56
+ echo "# Changelog
57
+
58
+ ## ${{ env.VERSION }}
59
+ " >> CHANGELOG.tmp
60
+ grep "^*" xx01 >> CHANGELOG.tmp
61
+ grep -v "^# " CHANGELOG.md >> CHANGELOG.tmp
62
+ cp CHANGELOG.tmp CHANGELOG.md
63
+ - name: Prepare version.rb
64
+ run: |
65
+ sed -i "s|VERSION = '[^']*'|VERSION = '${{ env.VERSION }}'|" lib/pusher/version.rb
66
+ - name: Commit changes
67
+ run: |
68
+ git add CHANGELOG.md lib/pusher/version.rb
69
+ git commit -m "Bump to version ${{ env.VERSION }}"
70
+ - name: Push
71
+ run: git push
@@ -0,0 +1,31 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [master, main]
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-20.04
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby: ['2.6', '2.7', '3.0']
15
+
16
+ name: Ruby ${{ matrix.ruby }} Test
17
+
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v2
21
+
22
+ - name: Setup Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby }}
26
+
27
+ - name: Install dependencies
28
+ run: bundle install
29
+
30
+ - name: Run test suite
31
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,103 +1,121 @@
1
- 1.3.1 / 2017-03-15
2
- ==================
1
+ # Changelog
3
2
 
4
- * Added missing client batch methods to default client delegations
5
- * Document raised exception in the `authenticate` method
6
- * Fixes em-http-request from using v2.5.0 of `addressable` breaking builds.
3
+ ## 2.0.0
7
4
 
8
- 1.3.0 / 2016-08-23
9
- ==================
5
+ * [CHANGED] Use TLS by default.
6
+ * [REMOVED] Support for Ruby 2.4 and 2.5.
7
+ * [FIXED] Handle empty or nil configuration.
8
+ * [REMOVED] Legacy Push Notification integration.
9
+ * [ADDED] Stalebot and Github actions.
10
+
11
+ ## 1.4.3
10
12
 
11
- * Add support for sending push notifications on up to 10 interests.
13
+ * [FIXED] Remove newline from end of base64 encoded strings, some decoders don't like
14
+ them.
12
15
 
13
- 1.2.1 / 2016-08-22
16
+ ## 1.4.2
14
17
  ==================
15
18
 
16
- * Fixes Rails 5 compatibility. Use duck-typing to detect request object
19
+ * [FIXED] Return `shared_secret` to support authenticating encrypted channels. Thanks
20
+ @Benjaminpjacobs
17
21
 
18
- 1.2.0 / 2016-08-15
19
- ==================
22
+ ## 1.4.1
20
23
 
21
- * Minor release for Native notifications
24
+ * [CHANGED] Remove rbnacl from dependencies so we don't get errors when it isn't
25
+ required. Thanks @y-yagi!
22
26
 
23
- 1.2.0.rc1 / 2016-07-18
24
- ==================
27
+ ## 1.4.0
25
28
 
26
- * Add support for Native notifications
29
+ * [ADDED] Support for end-to-end encryption.
27
30
 
28
- 1.1.0 / 2016-05-20
29
- ==================
31
+ ## 1.3.3
30
32
 
31
- * Add support for batch events
33
+ * [CHANGED] Rewording to clarify "Pusher Channels" or simply "Channels" product name.
32
34
 
33
- 1.0.0 / 2016-05-19
34
- ==================
35
+ ## 1.3.2
35
36
 
36
- No breaking changes, this release is just to follow semver and show that we
37
- are stable.
37
+ * [FIXED] Return a specific error for "Request Entity Too Large" (body over 10KB).
38
+ * [ADDED] Add a `use_tls` option for SSL (defaults to false).
39
+ * [ADDED] Add a `from_url` client method (in addition to existing `from_env` option).
40
+ * [CHANGED] Improved documentation and fixed typos.
41
+ * [ADDED] Add Ruby 2.4 to test matrix.
38
42
 
39
- 0.18.0 / 2016-05-15
40
- ==================
43
+ ## 1.3.1
41
44
 
42
- * Introduce `Pusher::Client.from_env`
43
- * Improve error handling on missing config
45
+ * [FIXED] Added missing client batch methods to default client delegations
46
+ * [CHANGED] Document raised exception in the `authenticate` method
47
+ * [FIXED] Fixes em-http-request from using v2.5.0 of `addressable` breaking builds.
44
48
 
45
- 0.17.0 / 2016-02-22
46
- ==================
49
+ ## 1.3.0
47
50
 
48
- * Introduce the `cluster` option.
51
+ * [ADDED] Add support for sending push notifications on up to 10 interests.
49
52
 
50
- 0.16.0 / 2016-01-21
51
- ==================
53
+ ## 1.2.1
52
54
 
53
- * Bump httpclient version to 2.7
54
- * Ruby 1.8.7 is not supported anymore.
55
+ * [FIXED] Fixes Rails 5 compatibility. Use duck-typing to detect request object
55
56
 
56
- 0.15.2 / 2015-12-03
57
- ==================
57
+ ## 1.2.0
58
58
 
59
- * Documented `Pusher.channel_info`, `Pusher.channels`
60
- * Added `Pusher.channel_users`
59
+ * [CHANGED] Minor release for Native notifications
61
60
 
62
- 0.15.1 / 2015-11-03
63
- ==================
61
+ ## 1.2.0.rc1
64
62
 
65
- * Fixed a bug where the `authenticate` method added in 0.15.0 wasn't exposed on the Pusher class.
63
+ * [ADDED] Add support for Native notifications
66
64
 
67
- 0.15.0 / 2015-11-02
68
- ==================
65
+ ## 1.1.0
69
66
 
70
- * Added `Pusher.authenticate` method for authenticating private and presence channels.
71
- This is prefered over the older `Pusher['a_channel'].authenticate(...)` style.
67
+ * [ADDED] Add support for batch events
72
68
 
73
- 0.14.6 / 2015-09-29
74
- ==================
75
- * Updated to use the `pusher-signature` gem instead of `signature`.
76
- This resolves namespace related issues.
69
+ ## 1.0.0
77
70
 
78
- 0.14.5 / 2015-05-11
79
- ==================
71
+ * [CHANGED] No breaking changes, this release is just to follow semver and show that we
72
+ are stable.
80
73
 
81
- * SECURITY: Prevent auth delegation trough crafted socket IDs
74
+ ## 0.18.0
82
75
 
83
- 0.14.4 / 2015-01-20
84
- ==================
76
+ * [ADDED] Introduce `Pusher::Client.from_env`
77
+ * [FIXED] Improve error handling on missing config
85
78
 
86
- * SECURITY: Prevent timing attack, update signature to v0.1.8
87
- * SECURITY: Prevent POODLE. Disable SSLv3, update httpclient to v2.5
88
- * Fix channel name character limit.
89
- * Adds support for listing users on a presence channel
79
+ ## 0.17.0
90
80
 
91
- 0.14.3 / 2015-01-20
92
- ==================
81
+ * [ADDED] Introduce the `cluster` option.
93
82
 
94
- Yanked, bad release
83
+ ## 0.16.0
95
84
 
96
- 0.14.2 / 2014-10-16
97
- ==================
85
+ * [CHANGED] Bump httpclient version to 2.7
86
+ * [REMOVED] Ruby 1.8.7 is not supported anymore.
87
+
88
+ ## 0.15.2
89
+
90
+ * [CHANGED] Documented `Pusher.channel_info`, `Pusher.channels`
91
+ * [ADDED] Added `Pusher.channel_users`
92
+
93
+ ## 0.15.1
94
+
95
+ * [FIXED] Fixed a bug where the `authenticate` method added in 0.15.0 wasn't exposed on the Pusher class.
96
+
97
+ ## 0.15.0
98
+
99
+ * [ADDED] Added `Pusher.authenticate` method for authenticating private and presence channels.
100
+ This is prefered over the older `Pusher['a_channel'].authenticate(...)` style.
101
+
102
+ ## 0.14.6
103
+
104
+ * [CHANGED] Updated to use the `pusher-signature` gem instead of `signature`.
105
+ This resolves namespace related issues.
106
+
107
+ ## 0.14.5
108
+
109
+ * [SECURITY] Prevent auth delegation trough crafted socket IDs
110
+
111
+ ## 0.14.4
98
112
 
99
- First release with a changelog !
113
+ * [SECURITY] Prevent timing attack, update signature to v0.1.8
114
+ * [SECURITY] Prevent POODLE. Disable SSLv3, update httpclient to v2.5
115
+ * [FIXED] Fix channel name character limit.
116
+ * [ADDED] Adds support for listing users on a presence channel
100
117
 
101
- * Bump httpclient to v2.4. See #62 (POODLE SSL)
102
- * Fix limited channel count at README.md. Thanks @tricknotes
118
+ ## 0.14.2
103
119
 
120
+ * [CHANGED] Bump httpclient to v2.4. See #62 (POODLE SSL)
121
+ * [CHANGED] Fix limited channel count at README.md. Thanks @tricknotes
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Gem for Pusher Channels
2
2
 
3
- This Gem provides a Ruby interface to [the Pusher HTTP API for Pusher Channels](https://pusher.com/docs/rest_api).
3
+ This Gem provides a Ruby interface to [the Pusher HTTP API for Pusher Channels](https://pusher.com/docs/channels/library_auth_reference/rest-api).
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/pusher/pusher-http-ruby.svg?branch=master)](http://travis-ci.org/pusher/pusher-http-ruby)
5
+ [![Build Status](https://github.com/pusher/pusher-http-ruby/workflows/Tests/badge.svg)](https://github.com/pusher/pusher-http-ruby/actions?query=workflow%3ATests+branch%3Amaster) [![Gem Version](https://badge.fury.io/rb/pusher.svg)](https://badge.fury.io/rb/pusher)
6
+
7
+ ## Supported Platforms
8
+
9
+ * Ruby - supports **Ruby 2.6 or greater**.
6
10
 
7
11
  ## Installation and Configuration
8
12
 
@@ -18,7 +22,7 @@ or install via gem
18
22
  gem install pusher
19
23
  ```
20
24
 
21
- After registering at <https://dashboard.pusher.com/>, configure your Channels app with the security credentials.
25
+ After registering at [Pusher](https://dashboard.pusher.com/accounts/sign_up), configure your Channels app with the security credentials.
22
26
 
23
27
  ### Instantiating a Pusher Channels client
24
28
 
@@ -27,7 +31,7 @@ Creating a new Pusher Channels `client` can be done as follows.
27
31
  ``` ruby
28
32
  require 'pusher'
29
33
 
30
- channels_client = Pusher::Client.new(
34
+ pusher = Pusher::Client.new(
31
35
  app_id: 'your-app-id',
32
36
  key: 'your-app-key',
33
37
  secret: 'your-app-secret',
@@ -43,7 +47,7 @@ If you want to set a custom `host` value for your client then you can do so when
43
47
  ``` ruby
44
48
  require 'pusher'
45
49
 
46
- channels_client = Pusher::Client.new(
50
+ pusher = Pusher::Client.new(
47
51
  app_id: 'your-app-id',
48
52
  key: 'your-app-key',
49
53
  secret: 'your-app-secret',
@@ -57,7 +61,7 @@ Finally, if you have the configuration set in an `PUSHER_URL` environment
57
61
  variable, you can use:
58
62
 
59
63
  ``` ruby
60
- channels_client = Pusher::Client.from_env
64
+ pusher = Pusher::Client.from_env
61
65
  ```
62
66
 
63
67
  ### Global configuration
@@ -102,7 +106,7 @@ Handle errors by rescuing `Pusher::Error` (all errors are descendants of this er
102
106
 
103
107
  ``` ruby
104
108
  begin
105
- channels_client.trigger('a_channel', 'an_event', :some => 'data')
109
+ pusher.trigger('a_channel', 'an_event', :some => 'data')
106
110
  rescue Pusher::Error => e
107
111
  # (Pusher::AuthenticationError, Pusher::HTTPError, or Pusher::Error)
108
112
  end
@@ -121,14 +125,14 @@ Pusher.logger = Rails.logger
121
125
  An event can be published to one or more channels (limited to 10) in one API call:
122
126
 
123
127
  ``` ruby
124
- channels_client.trigger('channel', 'event', foo: 'bar')
125
- channels_client.trigger(['channel_1', 'channel_2'], 'event_name', foo: 'bar')
128
+ pusher.trigger('channel', 'event', foo: 'bar')
129
+ pusher.trigger(['channel_1', 'channel_2'], 'event_name', foo: 'bar')
126
130
  ```
127
131
 
128
- An optional fourth argument may be used to send additional parameters to the API, for example to [exclude a single connection from receiving the event](http://pusher.com/docs/publisher_api_guide/publisher_excluding_recipients).
132
+ An optional fourth argument may be used to send additional parameters to the API, for example to [exclude a single connection from receiving the event](https://pusher.com/docs/channels/server_api/excluding-event-recipients).
129
133
 
130
134
  ``` ruby
131
- channels_client.trigger('channel', 'event', {foo: 'bar'}, {socket_id: '123.456'})
135
+ pusher.trigger('channel', 'event', {foo: 'bar'}, {socket_id: '123.456'})
132
136
  ```
133
137
 
134
138
  #### Batches
@@ -137,7 +141,7 @@ It's also possible to send multiple events with a single API call (max 10
137
141
  events per call on multi-tenant clusters):
138
142
 
139
143
  ``` ruby
140
- channels_client.trigger_batch([
144
+ pusher.trigger_batch([
141
145
  {channel: 'channel_1', name: 'event_name', data: { foo: 'bar' }},
142
146
  {channel: 'channel_1', name: 'event_name', data: { hello: 'world' }}
143
147
  ])
@@ -151,19 +155,19 @@ Most examples and documentation will refer to the following syntax for triggerin
151
155
  Pusher['a_channel'].trigger('an_event', :some => 'data')
152
156
  ```
153
157
 
154
- This will continue to work, but has been replaced by `channels_client.trigger` which supports one or multiple channels.
158
+ This will continue to work, but has been replaced by `pusher.trigger` which supports one or multiple channels.
155
159
 
156
160
  ### Getting information about the channels in your Pusher Channels app
157
161
 
158
- This gem provides methods for accessing information from the [Channels HTTP API](https://pusher.com/docs/rest_api). The documentation also shows an example of the responses from each of the API endpoints.
162
+ This gem provides methods for accessing information from the [Channels HTTP API](https://pusher.com/docs/channels/library_auth_reference/rest-api). The documentation also shows an example of the responses from each of the API endpoints.
159
163
 
160
164
  The following methods are provided by the gem.
161
165
 
162
- - `channels_client.channel_info('channel_name')` returns information about that channel.
166
+ - `pusher.channel_info('channel_name', {info:"user_count,subscription_count"})` returns a hash describing the state of the channel([docs](https://pusher.com/docs/channels/library_auth_reference/rest-api#get-channels-fetch-info-for-multiple-channels-)).
163
167
 
164
- - `channels_client.channel_users('channel_name')` returns a list of all the users subscribed to the channel.
168
+ - `pusher.channel_users('presence-channel_name')` returns a list of all the users subscribed to the channel (only for Presence Channels) ([docs](https://pusher.com/docs/channels/library_auth_reference/rest-api#get-channels-fetch-info-for-multiple-channels-)).
165
169
 
166
- - `channels_client.channels` returns information about all the channels in your Channels application.
170
+ - `pusher.channels({filter_by_prefix: 'presence-', info: 'user_count'})` returns a hash of occupied channels (optionally filtered by prefix, f.i. `presence-`), and optionally attributes for these channels ([docs](https://pusher.com/docs/channels/library_auth_reference/rest-api#get-channels-fetch-info-for-multiple-channels-)).
167
171
 
168
172
  ### Asynchronous requests
169
173
 
@@ -176,9 +180,9 @@ Asynchronous calls are supported either by using an event loop (eventmachine, pr
176
180
 
177
181
  The following methods are available (in each case the calling interface matches the non-async version):
178
182
 
179
- * `channels_client.get_async`
180
- * `channels_client.post_async`
181
- * `channels_client.trigger_async`
183
+ * `pusher.get_async`
184
+ * `pusher.post_async`
185
+ * `pusher.trigger_async`
182
186
 
183
187
  It is of course also possible to make calls to the Channels HTTP API via a job queue. This approach is recommended if you're sending a large number of events.
184
188
 
@@ -190,7 +194,7 @@ It is of course also possible to make calls to the Channels HTTP API via a job q
190
194
  The `_async` methods return an `EM::Deferrable` which you can bind callbacks to:
191
195
 
192
196
  ``` ruby
193
- channels_client.get_async("/channels").callback { |response|
197
+ pusher.get_async("/channels").callback { |response|
194
198
  # use reponse[:channels]
195
199
  }.errback { |error|
196
200
  # error is an instance of Pusher::Error
@@ -213,7 +217,7 @@ It's possible to use the gem to authenticate subscription requests to private or
213
217
  ### Private channels
214
218
 
215
219
  ``` ruby
216
- channels_client.authenticate('private-my_channel', params[:socket_id])
220
+ pusher.authenticate('private-my_channel', params[:socket_id])
217
221
  ```
218
222
 
219
223
  ### Presence channels
@@ -221,7 +225,7 @@ channels_client.authenticate('private-my_channel', params[:socket_id])
221
225
  These work in a very similar way, but require a unique identifier for the user being authenticated, and optionally some attributes that are provided to clients via presence events:
222
226
 
223
227
  ``` ruby
224
- channels_client.authenticate('presence-my_channel', params[:socket_id],
228
+ pusher.authenticate('presence-my_channel', params[:socket_id],
225
229
  user_id: 'user_id',
226
230
  user_info: {} # optional
227
231
  )
@@ -232,7 +236,7 @@ channels_client.authenticate('presence-my_channel', params[:socket_id],
232
236
  A WebHook object may be created to validate received WebHooks against your app credentials, and to extract events. It should be created with the `Rack::Request` object (available as `request` in Rails controllers or Sinatra handlers for example).
233
237
 
234
238
  ``` ruby
235
- webhook = channels_client.webhook(request)
239
+ webhook = pusher.webhook(request)
236
240
  if webhook.valid?
237
241
  webhook.events.each do |event|
238
242
  case event["name"]
@@ -247,3 +251,51 @@ else
247
251
  render text: 'invalid', status: 401
248
252
  end
249
253
  ```
254
+
255
+ ### End-to-end encryption
256
+
257
+ This library supports [end-to-end encrypted channels](https://pusher.com/docs/channels/using_channels/encrypted-channels). This means that only you and your connected clients will be able to read your messages. Pusher cannot decrypt them. You can enable this feature by following these steps:
258
+
259
+ 1. Add the `rbnacl` gem to your Gemfile (it's not a gem dependency).
260
+
261
+ 2. Install [Libsodium](https://github.com/jedisct1/libsodium), which we rely on to do the heavy lifting. [Follow the installation instructions for your platform.](https://github.com/RubyCrypto/rbnacl/wiki/Installing-libsodium)
262
+
263
+ 3. Encrypted channel subscriptions must be authenticated in the exact same way as private channels. You should therefore [create an authentication endpoint on your server](https://pusher.com/docs/authenticating_users).
264
+
265
+ 4. Next, generate your 32 byte master encryption key, encode it as base64 and pass it to the Pusher constructor.
266
+
267
+ This is secret and you should never share this with anyone.
268
+ Not even Pusher.
269
+
270
+ ```bash
271
+ openssl rand -base64 32
272
+ ```
273
+
274
+ ```rb
275
+ pusher = new Pusher::Client.new({
276
+ app_id: 'your-app-id',
277
+ key: 'your-app-key',
278
+ secret: 'your-app-secret',
279
+ cluster: 'your-app-cluster',
280
+ use_tls: true
281
+ encryption_master_key_base64: '<KEY GENERATED BY PREVIOUS COMMAND>',
282
+ });
283
+ ```
284
+
285
+ 5. Channels where you wish to use end-to-end encryption should be prefixed with `private-encrypted-`.
286
+
287
+ 6. Subscribe to these channels in your client, and you're done! You can verify it is working by checking out the debug console on the [https://dashboard.pusher.com/](dashboard) and seeing the scrambled ciphertext.
288
+
289
+ **Important note: This will __not__ encrypt messages on channels that are not prefixed by `private-encrypted-`.**
290
+
291
+ **Limitation**: you cannot trigger a single event on multiple channels in a call to `trigger`, e.g.
292
+
293
+ ```rb
294
+ pusher.trigger(
295
+ ['channel-1', 'private-encrypted-channel-2'],
296
+ 'test_event',
297
+ { message: 'hello world' },
298
+ )
299
+ ```
300
+
301
+ 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.