ostatus2 0.3.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ostatus2/magic_key.rb +26 -0
- data/lib/ostatus2/salmon.rb +4 -2
- data/lib/ostatus2/version.rb +1 -1
- data/lib/ostatus2.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf294e569b899f5aeb8406caca3a35230ac66d1
|
4
|
+
data.tar.gz: dfb5ffa9813a7738bdaa54fca1726fcdd58375ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 327e56801a53d5c0cf885c5d8523b5d05c7773aa0a44f6a5017fc35f08dc3c5360ab9a543a17a300f646d8cf1babdb150a428652301f0929ce7959a883392c7b
|
7
|
+
data.tar.gz: 20eb364b94680f55ce7421e6cb202a99eecacb411e84f7ed376fcfd063601beb964e07b03152a998092ad9c5c03aa578766d1d57e20edb99012f2d6636cf258a
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OStatus2
|
2
|
+
module MagicKey
|
3
|
+
def magic_key_to_pem(magic_key)
|
4
|
+
_, modulus, exponent = magic_key.split('.')
|
5
|
+
modulus, exponent = [modulus, exponent].map { |n| decode_base64(n).bytes.inject(0) { |a, e| (a << 8) | e } }
|
6
|
+
|
7
|
+
key = OpenSSL::PKey::RSA.new
|
8
|
+
key.n = modulus
|
9
|
+
key.e = exponent
|
10
|
+
|
11
|
+
key.to_pem
|
12
|
+
end
|
13
|
+
|
14
|
+
def decode_base64(string)
|
15
|
+
retries = 0
|
16
|
+
|
17
|
+
begin
|
18
|
+
return Base64::urlsafe_decode64(string)
|
19
|
+
rescue ArgumentError
|
20
|
+
retries += 1
|
21
|
+
string = "#{string}="
|
22
|
+
retry unless retries > 2
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/ostatus2/salmon.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module OStatus2
|
2
2
|
class Salmon
|
3
|
+
include OStatus2::MagicKey
|
4
|
+
|
3
5
|
XMLNS = 'http://salmon-protocol.org/ns/magic-env'
|
4
6
|
|
5
7
|
# Create a magical envelope XML document around the original body
|
@@ -68,9 +70,9 @@ module OStatus2
|
|
68
70
|
|
69
71
|
data = xml.at_xpath('//me:data')
|
70
72
|
type = data.attribute('type').value
|
71
|
-
body =
|
73
|
+
body = decode_base64(data.content)
|
72
74
|
sig = xml.at_xpath('//me:sig')
|
73
|
-
signature =
|
75
|
+
signature = decode_base64(sig.content)
|
74
76
|
encoding = xml.at_xpath('//me:encoding').content
|
75
77
|
alg = xml.at_xpath('//me:alg').content
|
76
78
|
plaintext = plaintext_signature(body, type, encoding, alg)
|
data/lib/ostatus2/version.rb
CHANGED
data/lib/ostatus2.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: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Rochko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- README.md
|
77
77
|
- lib/ostatus2.rb
|
78
|
+
- lib/ostatus2/magic_key.rb
|
78
79
|
- lib/ostatus2/publication.rb
|
79
80
|
- lib/ostatus2/salmon.rb
|
80
81
|
- lib/ostatus2/subscription.rb
|