wework 0.2.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wework/config.rb +0 -1
- data/lib/wework/provider.rb +39 -0
- data/lib/wework/version.rb +1 -1
- 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: 717cb7ed89b19797fdac7c6a077cf73ed7ced467
|
4
|
+
data.tar.gz: 2958df54c9332520cdc5dec16f7405864c8ebf7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4baa61653bc4804a29d773b961da60fdde11370dfc7326086284f50e03306cfea3bcd06247e0d6319b6f7fa5ec93cc129c5c80a8c67701214ef887de68a1ee5c
|
7
|
+
data.tar.gz: 4a59d08dc5eb7f48837b27abda0b5b81bf3ec9eccb1543d215ac7e89b1d032a2e9402e37b6935717cf7e1cc0b347ded062a74766b107afdabc6908f1d9dc2796
|
data/lib/wework/config.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Wework
|
2
|
+
class Provider
|
3
|
+
include Wework::Cipher
|
4
|
+
|
5
|
+
attr_accessor :corp_id, :provider_secret, :encoding_aes_key, :token
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
@corp_id = options[:corp_id]
|
9
|
+
@provider_secret = options[:provider_secret]
|
10
|
+
@encoding_aes_key = options[:encoding_aes_key]
|
11
|
+
@token = options[:token]
|
12
|
+
end
|
13
|
+
|
14
|
+
def msg_decrypt msg
|
15
|
+
unpack(decrypt(Base64.decode64(msg), self.encoding_aes_key))[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
def msg_encrypt msg
|
19
|
+
Base64.strict_encode64(encrypt(pack(msg, self.corp_id), self.encoding_aes_key))
|
20
|
+
end
|
21
|
+
|
22
|
+
def signature(timestamp, nonce, encrypt)
|
23
|
+
array = [self.token, timestamp, nonce]
|
24
|
+
array << encrypt unless encrypt.nil?
|
25
|
+
dev_msg_signature = array.compact.collect(&:to_s).sort.join
|
26
|
+
Digest::SHA1.hexdigest(dev_msg_signature)
|
27
|
+
end
|
28
|
+
|
29
|
+
def generate_xml(msg, timestamp, nonce)
|
30
|
+
encrypt = msg_encrypt(msg)
|
31
|
+
{
|
32
|
+
Encrypt: encrypt,
|
33
|
+
MsgSignature: signature(timestamp, nonce, encrypt),
|
34
|
+
TimeStamp: timestamp,
|
35
|
+
Nonce: nonce
|
36
|
+
}.to_xml(root: 'xml', children: 'item', skip_instruct: true, skip_types: true)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/wework/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seandong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
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: http
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/wework/global_code.rb
|
127
127
|
- lib/wework/js_ticket/redis_store.rb
|
128
128
|
- lib/wework/js_ticket/store.rb
|
129
|
+
- lib/wework/provider.rb
|
129
130
|
- lib/wework/request.rb
|
130
131
|
- lib/wework/token/redis_store.rb
|
131
132
|
- lib/wework/token/store.rb
|