pusher 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'hmac-sha2'
1
+ require 'openssl'
2
2
  require 'multi_json'
3
3
 
4
4
  module Pusher
@@ -91,7 +91,8 @@ module Pusher
91
91
  string_to_sign = [socket_id, name, custom_string].compact.map{|e|e.to_s}.join(':')
92
92
  Pusher.logger.debug "Signing #{string_to_sign}"
93
93
  token = @client.authentication_token
94
- signature = HMAC::SHA256.hexdigest(token.secret, string_to_sign)
94
+ digest = OpenSSL::Digest::SHA256.new
95
+ signature = OpenSSL::HMAC.hexdigest(digest, token.secret, string_to_sign)
95
96
 
96
97
  return "#{token.key}:#{signature}"
97
98
  end
@@ -1,5 +1,5 @@
1
1
  require 'multi_json'
2
- require 'hmac-sha2'
2
+ require 'openssl'
3
3
 
4
4
  module Pusher
5
5
  # Used to parse and authenticate WebHooks
@@ -96,7 +96,8 @@ module Pusher
96
96
  # Checks signature against secret and returns boolean
97
97
  #
98
98
  def check_signature(secret)
99
- expected = HMAC::SHA256.hexdigest(secret, @body)
99
+ digest = OpenSSL::Digest::SHA256.new
100
+ expected = OpenSSL::HMAC.hexdigest(digest, secret, @body)
100
101
  if @signature == expected
101
102
  return true
102
103
  else
@@ -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.9.2"
6
+ s.version = "0.9.3"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Pusher"]
9
9
  s.email = ["support@pusher.com"]
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.description = %q{Wrapper for pusher.com REST api}
13
13
 
14
14
  s.add_dependency "multi_json", "~> 1.0"
15
- s.add_dependency "ruby-hmac", "~> 0.4.0"
16
15
  s.add_dependency 'signature', "~> 0.1.2"
17
16
 
18
17
  s.add_development_dependency "rspec", "~> 2.0"
@@ -41,7 +41,7 @@ describe Pusher::Channel do
41
41
  :name => 'Pusher',
42
42
  :last_name => 'App'
43
43
  })
44
- WebMock.should have_requested(:post, %r{/apps/20/channels/test_channel/events}).with do |req|
44
+ WebMock.should have_requested(:post, %r{/apps/20/channels/test_channel/events}).with { |req|
45
45
  query_hash = req.uri.query_values
46
46
  query_hash["name"].should == 'new_event'
47
47
  query_hash["auth_key"].should == @client.key
@@ -54,15 +54,13 @@ describe Pusher::Channel do
54
54
  }
55
55
 
56
56
  req.headers['Content-Type'].should == 'application/json'
57
- end
57
+ }
58
58
  end
59
59
 
60
60
  it "should POST string data unmodified in request body" do
61
61
  string = "foo\nbar\""
62
62
  @channel.trigger!('new_event', string)
63
- WebMock.should have_requested(:post, %r{/apps/20/channels/test_channel/events}).with do |req|
64
- req.body.should == "foo\nbar\""
65
- end
63
+ WebMock.should have_requested(:post, %r{/apps/20/channels/test_channel/events}).with { |req| req.body.should == "foo\nbar\"" }
66
64
  end
67
65
 
68
66
  it "should catch all Net::HTTP exceptions and raise a Pusher::HTTPError, exposing the original error if required" do
@@ -246,7 +244,7 @@ describe Pusher::Channel do
246
244
  it "should return an authentication string given a socket id and custom args" do
247
245
  auth = @channel.socket_auth('socketid', 'foobar')
248
246
 
249
- auth.should == "12345678900000001:#{HMAC::SHA256.hexdigest(@client.secret, "socketid:test_channel:foobar")}"
247
+ auth.should == "12345678900000001:#{hmac(@client.secret, "socketid:test_channel:foobar")}"
250
248
  end
251
249
 
252
250
  end
@@ -265,7 +263,7 @@ describe Pusher::Channel do
265
263
  response = @channel.authenticate('socketid', @custom_data)
266
264
 
267
265
  response.should == {
268
- :auth => "12345678900000001:#{HMAC::SHA256.hexdigest(@client.secret, "socketid:test_channel:a json string")}",
266
+ :auth => "12345678900000001:#{hmac(@client.secret, "socketid:test_channel:a json string")}",
269
267
  :channel_data => 'a json string'
270
268
  }
271
269
  end
@@ -11,3 +11,8 @@ require 'webmock/rspec'
11
11
 
12
12
  require 'pusher'
13
13
  require 'eventmachine'
14
+
15
+ def hmac(key, data)
16
+ digest = OpenSSL::Digest::SHA256.new
17
+ expected = OpenSSL::HMAC.hexdigest(digest, key, data)
18
+ end
@@ -46,7 +46,7 @@ describe Pusher::WebHook do
46
46
  body = MultiJson.encode(@hook_data)
47
47
  request = {
48
48
  :key => '1234',
49
- :signature => HMAC::SHA256.hexdigest('asdf', body),
49
+ :signature => hmac('asdf', body),
50
50
  :content_type => 'application/json',
51
51
  :body => body
52
52
  }
metadata CHANGED
@@ -1,152 +1,100 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pusher
3
- version: !ruby/object:Gem::Version
4
- hash: 63
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Pusher
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-01-27 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-05-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: multi_json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2173495100 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 15
29
- segments:
30
- - 1
31
- - 0
32
- version: "1.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: ruby-hmac
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 15
44
- segments:
45
- - 0
46
- - 4
47
- - 0
48
- version: 0.4.0
49
- type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2173495100
25
+ - !ruby/object:Gem::Dependency
52
26
  name: signature
53
- prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
27
+ requirement: &2173493980 !ruby/object:Gem::Requirement
55
28
  none: false
56
- requirements:
29
+ requirements:
57
30
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 31
60
- segments:
61
- - 0
62
- - 1
63
- - 2
31
+ - !ruby/object:Gem::Version
64
32
  version: 0.1.2
65
33
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: rspec
69
34
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
35
+ version_requirements: *2173493980
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &2173493120 !ruby/object:Gem::Requirement
71
39
  none: false
72
- requirements:
40
+ requirements:
73
41
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 2
78
- - 0
79
- version: "2.0"
42
+ - !ruby/object:Gem::Version
43
+ version: '2.0'
80
44
  type: :development
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- name: webmock
84
45
  prerelease: false
85
- requirement: &id005 !ruby/object:Gem::Requirement
46
+ version_requirements: *2173493120
47
+ - !ruby/object:Gem::Dependency
48
+ name: webmock
49
+ requirement: &2173492340 !ruby/object:Gem::Requirement
86
50
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
94
55
  type: :development
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- name: em-http-request
98
56
  prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
57
+ version_requirements: *2173492340
58
+ - !ruby/object:Gem::Dependency
59
+ name: em-http-request
60
+ requirement: &2173491540 !ruby/object:Gem::Requirement
100
61
  none: false
101
- requirements:
62
+ requirements:
102
63
  - - ~>
103
- - !ruby/object:Gem::Version
104
- hash: 23
105
- segments:
106
- - 1
107
- - 0
108
- - 0
64
+ - !ruby/object:Gem::Version
109
65
  version: 1.0.0
110
66
  type: :development
111
- version_requirements: *id006
112
- - !ruby/object:Gem::Dependency
113
- name: rake
114
67
  prerelease: false
115
- requirement: &id007 !ruby/object:Gem::Requirement
68
+ version_requirements: *2173491540
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &2173491080 !ruby/object:Gem::Requirement
116
72
  none: false
117
- requirements:
118
- - - ">="
119
- - !ruby/object:Gem::Version
120
- hash: 3
121
- segments:
122
- - 0
123
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
124
77
  type: :development
125
- version_requirements: *id007
126
- - !ruby/object:Gem::Dependency
127
- name: rack
128
78
  prerelease: false
129
- requirement: &id008 !ruby/object:Gem::Requirement
79
+ version_requirements: *2173491080
80
+ - !ruby/object:Gem::Dependency
81
+ name: rack
82
+ requirement: &2173490340 !ruby/object:Gem::Requirement
130
83
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- hash: 3
135
- segments:
136
- - 0
137
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
138
88
  type: :development
139
- version_requirements: *id008
89
+ prerelease: false
90
+ version_requirements: *2173490340
140
91
  description: Wrapper for pusher.com REST api
141
- email:
92
+ email:
142
93
  - support@pusher.com
143
94
  executables: []
144
-
145
95
  extensions: []
146
-
147
96
  extra_rdoc_files: []
148
-
149
- files:
97
+ files:
150
98
  - .document
151
99
  - .gemtest
152
100
  - .gitignore
@@ -168,39 +116,31 @@ files:
168
116
  - spec/web_hook_spec.rb
169
117
  homepage: http://github.com/pusher/pusher-gem
170
118
  licenses: []
171
-
172
119
  post_install_message:
173
120
  rdoc_options: []
174
-
175
- require_paths:
121
+ require_paths:
176
122
  - lib
177
- required_ruby_version: !ruby/object:Gem::Requirement
123
+ required_ruby_version: !ruby/object:Gem::Requirement
178
124
  none: false
179
- requirements:
180
- - - ">="
181
- - !ruby/object:Gem::Version
182
- hash: 3
183
- segments:
184
- - 0
185
- version: "0"
186
- required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
187
130
  none: false
188
- requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- hash: 3
192
- segments:
193
- - 0
194
- version: "0"
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
195
135
  requirements: []
196
-
197
136
  rubyforge_project:
198
- rubygems_version: 1.8.6
137
+ rubygems_version: 1.8.10
199
138
  signing_key:
200
139
  specification_version: 3
201
140
  summary: Pusher API client
202
- test_files:
141
+ test_files:
203
142
  - spec/channel_spec.rb
204
143
  - spec/client_spec.rb
205
144
  - spec/spec_helper.rb
206
145
  - spec/web_hook_spec.rb
146
+ has_rdoc: