pusher 0.14.6 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/pusher/client.rb +27 -0
- data/pusher.gemspec +2 -1
- data/spec/client_spec.rb +18 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17463be3ad5649865f88dcdc2b88156ff48f4bc2
|
4
|
+
data.tar.gz: 6ee8e8605ae0f9fb4b31b8e5edab80046e52aecb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3609f83552197f602b3d25150c72880bf2f586ab8d32827e0d8ecaad9a6084c970134aae7fdf98e1c080555329802d31addd1832c9acd04c652ff188d27e6e1
|
7
|
+
data.tar.gz: 062fdc265e90f2a55f69ff83a0b3dcd3275ce2b36891ef1f75285492da457068cc778eb8b570e3f7eb3b467333f75ca20a7fc9e89d52ae5df137f6e17aadf3e7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.15.0 / 2015-11-02
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Added `Pusher.authenticate` method for authenticating private and presence channels.
|
5
|
+
This is prefered over the older `Pusher['a_channel'].authenticate(...)` style.
|
6
|
+
|
1
7
|
0.14.6 / 2015-09-29
|
2
8
|
==================
|
3
9
|
* Updated to use the `pusher-signature` gem instead of `signature`.
|
data/README.md
CHANGED
@@ -178,7 +178,7 @@ It's possible to use the gem to authenticate subscription requests to private or
|
|
178
178
|
### Private channels
|
179
179
|
|
180
180
|
``` ruby
|
181
|
-
Pusher
|
181
|
+
Pusher.authenticate('private-my_channel', params[:socket_id])
|
182
182
|
```
|
183
183
|
|
184
184
|
### Presence channels
|
@@ -186,7 +186,7 @@ Pusher['private-my_channel'].authenticate(params[:socket_id])
|
|
186
186
|
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:
|
187
187
|
|
188
188
|
``` ruby
|
189
|
-
Pusher
|
189
|
+
Pusher.authenticate('presence-my_channel', params[:socket_id], {
|
190
190
|
user_id: 'user_id',
|
191
191
|
user_info: {} # optional
|
192
192
|
})
|
data/lib/pusher/client.rb
CHANGED
@@ -235,6 +235,33 @@ module Pusher
|
|
235
235
|
post_async('/events', trigger_params(channels, event_name, data, params))
|
236
236
|
end
|
237
237
|
|
238
|
+
# Generate the expected response for an authentication endpoint.
|
239
|
+
# See http://pusher.com/docs/authenticating_users for details.
|
240
|
+
#
|
241
|
+
# @example Private channels
|
242
|
+
# render :json => Pusher.authenticate('private-my_channel', params[:socket_id])
|
243
|
+
#
|
244
|
+
# @example Presence channels
|
245
|
+
# render :json => Pusher.authenticate('presence-my_channel', params[:socket_id], {
|
246
|
+
# :user_id => current_user.id, # => required
|
247
|
+
# :user_info => { # => optional - for example
|
248
|
+
# :name => current_user.name,
|
249
|
+
# :email => current_user.email
|
250
|
+
# }
|
251
|
+
# })
|
252
|
+
#
|
253
|
+
# @param socket_id [String]
|
254
|
+
# @param custom_data [Hash] used for example by private channels
|
255
|
+
#
|
256
|
+
# @return [Hash]
|
257
|
+
#
|
258
|
+
# @private Custom data is sent to server as JSON-encoded string
|
259
|
+
#
|
260
|
+
def authenticate(channel_name, socket_id, custom_data = nil)
|
261
|
+
channel_instance = channel(channel_name)
|
262
|
+
channel_instance.authenticate(socket_id, custom_data)
|
263
|
+
end
|
264
|
+
|
238
265
|
# @private Construct a net/http http client
|
239
266
|
def sync_http_client
|
240
267
|
@client ||= begin
|
data/pusher.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "pusher"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.15.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Pusher"]
|
9
9
|
s.email = ["support@pusher.com"]
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_development_dependency "em-http-request", "~> 1.1.0"
|
23
23
|
s.add_development_dependency "rake"
|
24
24
|
s.add_development_dependency "rack"
|
25
|
+
s.add_development_dependency "json"
|
25
26
|
|
26
27
|
s.files = `git ls-files`.split("\n")
|
27
28
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/spec/client_spec.rb
CHANGED
@@ -128,6 +128,24 @@ describe Pusher do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
describe '#authenticate' do
|
132
|
+
before :each do
|
133
|
+
@custom_data = {:uid => 123, :info => {:name => 'Foo'}}
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should return a hash with signature including custom data and data as json string' do
|
137
|
+
allow(MultiJson).to receive(:encode).with(@custom_data).and_return 'a json string'
|
138
|
+
|
139
|
+
response = @client.authenticate('test_channel', '1.1', @custom_data)
|
140
|
+
|
141
|
+
expect(response).to eq({
|
142
|
+
:auth => "12345678900000001:#{hmac(@client.secret, "1.1:test_channel:a json string")}",
|
143
|
+
:channel_data => 'a json string'
|
144
|
+
})
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
131
149
|
describe '#trigger' do
|
132
150
|
before :each do
|
133
151
|
@api_path = %r{/apps/20/events}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pusher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: json
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: Wrapper for pusher.com REST api
|
126
140
|
email:
|
127
141
|
- support@pusher.com
|
@@ -170,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
184
|
version: '0'
|
171
185
|
requirements: []
|
172
186
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.4.
|
187
|
+
rubygems_version: 2.4.5.1
|
174
188
|
signing_key:
|
175
189
|
specification_version: 4
|
176
190
|
summary: Pusher API client
|