pusher 1.3.2 → 2.0.3

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: d7b2bbdf8bc09f38d44a290d712f4e4cfea3c02d
4
- data.tar.gz: 72350a25756be9e9bff440195d2efba5d6f91a17
2
+ SHA256:
3
+ metadata.gz: 71dc5eb4f9d389dce37f6ec8c1f78390402b31bd94edcb6f22094c70edeb2d72
4
+ data.tar.gz: 3b2d0db0ffe052cbd8c71b252ced1d5910ece64a08100a92c0f17b5ac9b6fa8a
5
5
  SHA512:
6
- metadata.gz: 177ffe40c85c424260852a5928196bd56d0bd40984635426d82f57d5ec6f126f4ce0e6eb99ee87b2e821a29b35e9640abde5a80895f0f71795f2d99c809d7a9a
7
- data.tar.gz: 76a3284cc6ec3ea2686066cad60a020ca34399bdec353ccf5b2dc776ff8f57b9d1f68c2ce4a5ad10e2166de4757c995d16500b7c42b8af235338493dcf2b315a
6
+ metadata.gz: 2f644cc58f1b8accd8785eeffc3fc74bad4c20677032455d96e655944ee0818f99802ed339a3f5f9049acd57ea1166817f6c01feba926c9b61256260239c6354
7
+ data.tar.gz: c0d4edd095918225bea29707df4e8e0364b16218c367b40f72c5541fe98232e4698e83e58ea8260b7caeeea54d314ec343ea25050f1f7847747d01a003c68221
data/CHANGELOG.md CHANGED
@@ -1,103 +1,133 @@
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.3
7
4
 
8
- 1.3.0 / 2016-08-23
9
- ==================
5
+ * [FIXED] Corrected the channels limit when publishing events. Upped from 10 to 100.
10
6
 
11
- * Add support for sending push notifications on up to 10 interests.
7
+ ## 2.0.2
12
8
 
13
- 1.2.1 / 2016-08-22
14
- ==================
9
+ * [CHANGED] made encryption_master_key_base64 globally configurable
15
10
 
16
- * Fixes Rails 5 compatibility. Use duck-typing to detect request object
11
+ ## 2.0.1
17
12
 
18
- 1.2.0 / 2016-08-15
19
- ==================
13
+ * [CHANGED] Only include lib and essential docs in gem.
20
14
 
21
- * Minor release for Native notifications
15
+ ## 2.0.0
22
16
 
23
- 1.2.0.rc1 / 2016-07-18
24
- ==================
17
+ * [CHANGED] Use TLS by default.
18
+ * [REMOVED] Support for Ruby 2.4 and 2.5.
19
+ * [FIXED] Handle empty or nil configuration.
20
+ * [REMOVED] Legacy Push Notification integration.
21
+ * [ADDED] Stalebot and Github actions.
22
+
23
+ ## 1.4.3
25
24
 
26
- * Add support for Native notifications
25
+ * [FIXED] Remove newline from end of base64 encoded strings, some decoders don't like
26
+ them.
27
27
 
28
- 1.1.0 / 2016-05-20
28
+ ## 1.4.2
29
29
  ==================
30
30
 
31
- * Add support for batch events
31
+ * [FIXED] Return `shared_secret` to support authenticating encrypted channels. Thanks
32
+ @Benjaminpjacobs
32
33
 
33
- 1.0.0 / 2016-05-19
34
- ==================
34
+ ## 1.4.1
35
35
 
36
- No breaking changes, this release is just to follow semver and show that we
37
- are stable.
36
+ * [CHANGED] Remove rbnacl from dependencies so we don't get errors when it isn't
37
+ required. Thanks @y-yagi!
38
38
 
39
- 0.18.0 / 2016-05-15
40
- ==================
39
+ ## 1.4.0
41
40
 
42
- * Introduce `Pusher::Client.from_env`
43
- * Improve error handling on missing config
41
+ * [ADDED] Support for end-to-end encryption.
44
42
 
45
- 0.17.0 / 2016-02-22
46
- ==================
43
+ ## 1.3.3
47
44
 
48
- * Introduce the `cluster` option.
45
+ * [CHANGED] Rewording to clarify "Pusher Channels" or simply "Channels" product name.
49
46
 
50
- 0.16.0 / 2016-01-21
51
- ==================
47
+ ## 1.3.2
52
48
 
53
- * Bump httpclient version to 2.7
54
- * Ruby 1.8.7 is not supported anymore.
49
+ * [FIXED] Return a specific error for "Request Entity Too Large" (body over 10KB).
50
+ * [ADDED] Add a `use_tls` option for SSL (defaults to false).
51
+ * [ADDED] Add a `from_url` client method (in addition to existing `from_env` option).
52
+ * [CHANGED] Improved documentation and fixed typos.
53
+ * [ADDED] Add Ruby 2.4 to test matrix.
55
54
 
56
- 0.15.2 / 2015-12-03
57
- ==================
55
+ ## 1.3.1
58
56
 
59
- * Documented `Pusher.channel_info`, `Pusher.channels`
60
- * Added `Pusher.channel_users`
57
+ * [FIXED] Added missing client batch methods to default client delegations
58
+ * [CHANGED] Document raised exception in the `authenticate` method
59
+ * [FIXED] Fixes em-http-request from using v2.5.0 of `addressable` breaking builds.
61
60
 
62
- 0.15.1 / 2015-11-03
63
- ==================
61
+ ## 1.3.0
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 sending push notifications on up to 10 interests.
66
64
 
67
- 0.15.0 / 2015-11-02
68
- ==================
65
+ ## 1.2.1
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
+ * [FIXED] Fixes Rails 5 compatibility. Use duck-typing to detect request object
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.2.0
77
70
 
78
- 0.14.5 / 2015-05-11
79
- ==================
71
+ * [CHANGED] Minor release for Native notifications
80
72
 
81
- * SECURITY: Prevent auth delegation trough crafted socket IDs
73
+ ## 1.2.0.rc1
82
74
 
83
- 0.14.4 / 2015-01-20
84
- ==================
75
+ * [ADDED] Add support for Native notifications
85
76
 
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
77
+ ## 1.1.0
90
78
 
91
- 0.14.3 / 2015-01-20
92
- ==================
79
+ * [ADDED] Add support for batch events
93
80
 
94
- Yanked, bad release
81
+ ## 1.0.0
95
82
 
96
- 0.14.2 / 2014-10-16
97
- ==================
83
+ * [CHANGED] No breaking changes, this release is just to follow semver and show that we
84
+ are stable.
85
+
86
+ ## 0.18.0
87
+
88
+ * [ADDED] Introduce `Pusher::Client.from_env`
89
+ * [FIXED] Improve error handling on missing config
90
+
91
+ ## 0.17.0
92
+
93
+ * [ADDED] Introduce the `cluster` option.
94
+
95
+ ## 0.16.0
96
+
97
+ * [CHANGED] Bump httpclient version to 2.7
98
+ * [REMOVED] Ruby 1.8.7 is not supported anymore.
99
+
100
+ ## 0.15.2
101
+
102
+ * [CHANGED] Documented `Pusher.channel_info`, `Pusher.channels`
103
+ * [ADDED] Added `Pusher.channel_users`
104
+
105
+ ## 0.15.1
106
+
107
+ * [FIXED] Fixed a bug where the `authenticate` method added in 0.15.0 wasn't exposed on the Pusher class.
108
+
109
+ ## 0.15.0
110
+
111
+ * [ADDED] Added `Pusher.authenticate` method for authenticating private and presence channels.
112
+ This is prefered over the older `Pusher['a_channel'].authenticate(...)` style.
113
+
114
+ ## 0.14.6
115
+
116
+ * [CHANGED] Updated to use the `pusher-signature` gem instead of `signature`.
117
+ This resolves namespace related issues.
118
+
119
+ ## 0.14.5
120
+
121
+ * [SECURITY] Prevent auth delegation trough crafted socket IDs
122
+
123
+ ## 0.14.4
98
124
 
99
- First release with a changelog !
125
+ * [SECURITY] Prevent timing attack, update signature to v0.1.8
126
+ * [SECURITY] Prevent POODLE. Disable SSLv3, update httpclient to v2.5
127
+ * [FIXED] Fix channel name character limit.
128
+ * [ADDED] Adds support for listing users on a presence channel
100
129
 
101
- * Bump httpclient to v2.4. See #62 (POODLE SSL)
102
- * Fix limited channel count at README.md. Thanks @tricknotes
130
+ ## 0.14.2
103
131
 
132
+ * [CHANGED] Bump httpclient to v2.4. See #62 (POODLE SSL)
133
+ * [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](https://img.shields.io/gem/v/pusher)](https://rubygems.org/gems/pusher) [![Gem](https://img.shields.io/gem/dt/pusher)](https://rubygems.org/gems/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 Pusher 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',
@@ -36,14 +40,14 @@ channels_client = Pusher::Client.new(
36
40
  )
37
41
  ```
38
42
 
39
- The `cluster` value will set the `host` to `api-<cluster>.pusher.com`. The `use_tls` value is optional and defaults to `false`. It will set the `scheme` and `port`. Custom `scheme` and `port` values take precendence over `use_tls`.
43
+ The `cluster` value will set the `host` to `api-<cluster>.pusher.com`. The `use_tls` value is optional and defaults to `true`. It will set the `scheme` and `port`. A custom `port` value takes precendence over `use_tls`.
40
44
 
41
45
  If you want to set a custom `host` value for your client then you can do so when instantiating a Pusher Channels client like so:
42
46
 
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,12 +61,12 @@ 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
64
68
 
65
- Configuring Pusher can also be done globally on the Pusher class.
69
+ The library can also be configured globally on the `Pusher` class.
66
70
 
67
71
  ``` ruby
68
72
  Pusher.app_id = 'your-app-id'
@@ -79,11 +83,11 @@ If you need to make requests via a HTTP proxy then it can be configured
79
83
  Pusher.http_proxy = 'http://(user):(password)@(host):(port)'
80
84
  ```
81
85
 
82
- By default API requests are made over HTTP. HTTPS can be used by setting `encrypted` to `true`.
86
+ By default API requests are made over HTTPS. HTTP can be used by setting `use_tls` to `false`.
83
87
  Issuing this command is going to reset `port` value if it was previously specified.
84
88
 
85
89
  ``` ruby
86
- Pusher.encrypted = true
90
+ Pusher.use_tls = false
87
91
  ```
88
92
 
89
93
  As of version 0.12, SSL certificates are verified when using the synchronous http client. If you need to disable this behaviour for any reason use:
@@ -92,9 +96,9 @@ As of version 0.12, SSL certificates are verified when using the synchronous htt
92
96
  Pusher.default_client.sync_http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
93
97
  ```
94
98
 
95
- ## Interacting with the Pusher service
99
+ ## Interacting with the Channels HTTP API
96
100
 
97
- The Pusher gem contains a number of helpers for interacting with the service. As a general rule, the library adheres to a set of conventions that we have aimed to make universal.
101
+ The `pusher` gem contains a number of helpers for interacting with the API. As a general rule, the library adheres to a set of conventions that we have aimed to make universal.
98
102
 
99
103
  ### Handling errors
100
104
 
@@ -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,36 +155,36 @@ 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 [Pusher 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 Pusher 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
 
170
174
  There are two main reasons for using the `_async` methods:
171
175
 
172
- * In a web application where the response from the Pusher Channels HTTP API is not used, but you'd like to avoid a blocking call in the request-response cycle
176
+ * In a web application where the response from the Channels HTTP API is not used, but you'd like to avoid a blocking call in the request-response cycle
173
177
  * Your application is running in an event loop and you need to avoid blocking the reactor
174
178
 
175
179
  Asynchronous calls are supported either by using an event loop (eventmachine, preferred), or via a thread.
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
- It is of course also possible to make calls to the Pusher Channels HTTP API via a job queue. This approach is recommended if you're sending a large number of events.
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
 
185
189
  #### With EventMachine
186
190
 
@@ -190,14 +194,14 @@ It is of course also possible to make calls to the Pusher Channels HTTP API via
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
197
201
  }
198
202
  ```
199
203
 
200
- A HTTP error or an error response from pusher will cause the errback to be called with an appropriate error object.
204
+ A HTTP error or an error response from Channels will cause the errback to be called with an appropriate error object.
201
205
 
202
206
  #### Without EventMachine
203
207
 
@@ -208,12 +212,12 @@ An `HTTPClient::Connection` object is returned immediately which can be [interro
208
212
 
209
213
  ## Authenticating subscription requests
210
214
 
211
- It's possible to use the gem to authenticate subscription requests to private or presence channels. The `authenticate` method is available on a channel object for this purpose and returns a JSON object that can be returned to the client that made the request. More information on this authentication scheme can be found in the docs on <http://pusher.com>
215
+ It's possible to use the gem to authenticate subscription requests to private or presence channels. The `authenticate` method is available on a channel object for this purpose and returns a JSON object that can be returned to the client that made the request. More information on this authentication scheme can be found in the docs on <https://pusher.com/docs/channels/server_api/authenticating-users>
212
216
 
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.
@@ -174,6 +174,15 @@ module Pusher
174
174
  r
175
175
  end
176
176
 
177
+ def shared_secret(encryption_master_key)
178
+ return unless encryption_master_key
179
+
180
+ secret_string = @name + encryption_master_key
181
+ digest = OpenSSL::Digest::SHA256.new
182
+ digest << secret_string
183
+ digest.digest
184
+ end
185
+
177
186
  private
178
187
 
179
188
  def validate_socket_id(socket_id)