ostatus2 1.1.0 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18dc56ea9ff324180e2e9affcf6bf11f11683ea7
4
- data.tar.gz: afb7271a4ef3e3f2e055cdbe40b5c66dfedb9c92
3
+ metadata.gz: '0594abb740fddf0384530828f2b967ce16825337'
4
+ data.tar.gz: 919ce48e3f4d2fffca662c1cc8feb439b4f927ef
5
5
  SHA512:
6
- metadata.gz: 82c9d569c44779bbae951dcc29a7984aec733fec1444972bb9344128517993c80fc6a1d8711d34c3ba3617d4e364353dc52529236db5af127d70e53e32e49607
7
- data.tar.gz: 4cdc243b0d69f63c49287e8cbd47262958d6ebd91157d9324fe97fe9f55a84b8601d8f020ecd822fe65e1e0704b3915fb4306ade50c6ce9e20128443a632b384
6
+ metadata.gz: 0efa9b1dfb6b14b396cdd93473422e6bef36fbbd902331a2311cc2f3ceed5cfc0c27ed2d071fb347759344d2c9d3e994fa317da11f51f9cf68c556584edde492
7
+ data.tar.gz: 64c872ce4d9ef4e8854f85d8bdb870ae33d43004e70d06935045a3d92eb12c357e37353219e3a81d61609a21927ce3534066270564ec5bc21763f7dc1f12a81f
data/lib/ostatus2.rb CHANGED
@@ -6,7 +6,6 @@ require 'nokogiri'
6
6
 
7
7
  require 'ostatus2/version'
8
8
  require 'ostatus2/publication'
9
- require 'ostatus2/subscription_response'
10
9
  require 'ostatus2/subscription'
11
10
  require 'ostatus2/magic_key'
12
11
  require 'ostatus2/salmon'
@@ -1,11 +1,22 @@
1
1
  module OStatus2
2
2
  module MagicKey
3
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.0')
4
+ def set_key(key, modulus, exponent)
5
+ key.n = modulus
6
+ key.e = exponent
7
+ end
8
+ else
9
+ def set_key(key, modulus, exponent)
10
+ key.set_key(modulus, exponent, nil)
11
+ end
12
+ end
13
+
3
14
  def magic_key_to_pem(magic_key)
4
15
  _, modulus, exponent = magic_key.split('.')
5
16
  modulus, exponent = [modulus, exponent].map { |n| decode_base64(n).bytes.inject(0) { |a, e| (a << 8) | e } }
6
17
 
7
18
  key = OpenSSL::PKey::RSA.new
8
- key.set_key(modulus, exponent, nil)
19
+ set_key(key, modulus, exponent)
9
20
  key.to_pem
10
21
  end
11
22
 
@@ -18,7 +18,7 @@ module OStatus2
18
18
  # Subscribe to the topic via a specified hub
19
19
  # @raise [HTTP::Error] Error raised upon delivery failure
20
20
  # @raise [OpenSSL::SSL::SSLError] Error raised upon SSL-related failure during delivery
21
- # @return [Boolean]
21
+ # @return [HTTP::Response]
22
22
  def subscribe
23
23
  update_subscription(:subscribe)
24
24
  end
@@ -26,7 +26,7 @@ module OStatus2
26
26
  # Unsubscribe from the topic via a specified hub
27
27
  # @raise [HTTP::Error] Error raised upon delivery failure
28
28
  # @raise [OpenSSL::SSL::SSLError] Error raised upon SSL-related failure during delivery
29
- # @return [Boolean]
29
+ # @return [HTTP::Response]
30
30
  def unsubscribe
31
31
  update_subscription(:unsubscribe)
32
32
  end
@@ -51,8 +51,7 @@ module OStatus2
51
51
 
52
52
  def update_subscription(mode)
53
53
  hub_url = Addressable::URI.parse(@hub)
54
- response = http_client.post(hub_url, form: { 'hub.mode' => mode.to_s, 'hub.callback' => @webhook_url, 'hub.verify' => 'async', 'hub.lease_seconds' => '', 'hub.secret' => @secret, 'hub.topic' => @topic_url })
55
- SubscriptionResponse.new(response.code, response.body.to_s)
54
+ http_client.post(hub_url, form: { 'hub.mode' => mode.to_s, 'hub.callback' => @webhook_url, 'hub.verify' => 'async', 'hub.lease_seconds' => '', 'hub.secret' => @secret, 'hub.topic' => @topic_url })
56
55
  end
57
56
 
58
57
  def http_client
@@ -1,3 +1,3 @@
1
1
  module OStatus2
2
- VERSION = "1.1.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ostatus2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Rochko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-16 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openssl
@@ -93,9 +93,8 @@ files:
93
93
  - lib/ostatus2/publication.rb
94
94
  - lib/ostatus2/salmon.rb
95
95
  - lib/ostatus2/subscription.rb
96
- - lib/ostatus2/subscription_response.rb
97
96
  - lib/ostatus2/version.rb
98
- homepage: https://github.com/Gargron/ostatus2
97
+ homepage: https://github.com/tootsuite/ostatus2
99
98
  licenses:
100
99
  - MIT
101
100
  metadata: {}
@@ -115,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
114
  version: '0'
116
115
  requirements: []
117
116
  rubyforge_project:
118
- rubygems_version: 2.4.5.1
117
+ rubygems_version: 2.6.11
119
118
  signing_key:
120
119
  specification_version: 4
121
120
  summary: Toolset for interacting with the OStatus2 suite of protocols
@@ -1,28 +0,0 @@
1
- module OStatus2
2
- class SubscriptionResponse
3
- # @param [Integer] code HTTP status code
4
- # @param [String] body HTTP response body
5
- def initialize(code, body)
6
- @code = code
7
- @body = body
8
- end
9
-
10
- # Was the hub operation successful?
11
- # @return [Boolean]
12
- def successful?
13
- @code == 202
14
- end
15
-
16
- # Was the hub operation not successful?
17
- # @return [Boolean]
18
- def failed?
19
- !successful?
20
- end
21
-
22
- # Returns error message if the operation was not successful
23
- # @return [String]
24
- def message
25
- @body
26
- end
27
- end
28
- end