Skip to content

Commit c8e214f

Browse files
committed
README and CHANGELOG
1 parent e674130 commit c8e214f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
HEAD / 2020-09-29
2+
==================
3+
4+
* Support for end-to-end encryption.
5+
16
1.3.3 / 2019-07-02
27
==================
38

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,51 @@ else
248248
end
249249
```
250250

251+
### End-to-end encryption
252+
253+
This library supports end-to-end encryption of your private 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:
254+
255+
1. 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)
256+
257+
2. You should first set up Private channels. This involves [creating an authentication endpoint on your server](https://pusher.com/docs/authenticating_users).
258+
259+
3. Next, generate your 32 byte master encryption key, encode it as base64 and pass it to the Pusher constructor.
260+
261+
This is secret and you should never share this with anyone.
262+
Not even Pusher.
263+
264+
```bash
265+
openssl rand -base64 32
266+
```
267+
268+
```rb
269+
pusher = new Pusher::Client.new({
270+
app_id: 'your-app-id',
271+
key: 'your-app-key',
272+
secret: 'your-app-secret',
273+
cluster: 'your-app-cluster',
274+
use_tls: true
275+
encryption_master_key_base64: '<KEY GENERATED BY PREVIOUS COMMAND>',
276+
});
277+
```
278+
279+
4. Channels where you wish to use end-to-end encryption should be prefixed with `private-encrypted-`.
280+
281+
5. 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.
282+
283+
**Important note: This will __not__ encrypt messages on channels that are not prefixed by `private-encrypted-`.**
284+
285+
**Limitation**: you cannot trigger a single event on multiple channels in a call to `trigger`, e.g.
286+
287+
```rb
288+
pusher.trigger(
289+
['channel-1', 'private-encrypted-channel-2'],
290+
'test_event',
291+
{ message: 'hello world' },
292+
)
293+
```
294+
295+
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.
296+
251297
## Supported Ruby versions
252298
2.4+

0 commit comments

Comments
 (0)