ostatus2 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ostatus2.rb +0 -1
- data/lib/ostatus2/magic_key.rb +12 -1
- data/lib/ostatus2/subscription.rb +3 -4
- data/lib/ostatus2/version.rb +1 -1
- metadata +4 -5
- data/lib/ostatus2/subscription_response.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0594abb740fddf0384530828f2b967ce16825337'
|
4
|
+
data.tar.gz: 919ce48e3f4d2fffca662c1cc8feb439b4f927ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0efa9b1dfb6b14b396cdd93473422e6bef36fbbd902331a2311cc2f3ceed5cfc0c27ed2d071fb347759344d2c9d3e994fa317da11f51f9cf68c556584edde492
|
7
|
+
data.tar.gz: 64c872ce4d9ef4e8854f85d8bdb870ae33d43004e70d06935045a3d92eb12c357e37353219e3a81d61609a21927ce3534066270564ec5bc21763f7dc1f12a81f
|
data/lib/ostatus2.rb
CHANGED
data/lib/ostatus2/magic_key.rb
CHANGED
@@ -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
|
-
|
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 [
|
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 [
|
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
|
-
|
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
|
data/lib/ostatus2/version.rb
CHANGED
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:
|
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
|
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/
|
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.
|
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
|