bnet-authenticator 0.1.4 → 0.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 028841465a3483415e852b56a2ca8e05552dafd4
|
4
|
+
data.tar.gz: 2bf75662b2cdbe6bf3841e38fcc32b7a9a798b4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93b5da7a8a001dc4720f9a2c4947e267a2afe16400d6971c6995ad1e2af7fe71da58a142c0f8ae28ac91c566f3f9f701b963de51df49f7e68b04d2446f9748fc
|
7
|
+
data.tar.gz: 401d3af738845309d9690aaed1dfcb1cd33fec147e491afc370071c8f39d44b6a622c40338366025419b4a526b80a02216600a693372af4f9a80c625ec06ef0b
|
data/lib/bnet/authenticator.rb
CHANGED
@@ -91,7 +91,8 @@ module Bnet
|
|
91
91
|
# @param region [Symbol]
|
92
92
|
# @return [Integer] server timestamp in seconds
|
93
93
|
def self.request_server_time(region)
|
94
|
-
request_for('server time', region, TIME_REQUEST_PATH)
|
94
|
+
server_time_big_endian = request_for('server time', region, TIME_REQUEST_PATH)
|
95
|
+
server_time_big_endian.unpack('Q>')[0].to_f / 1000
|
95
96
|
end
|
96
97
|
|
97
98
|
# Get token from given secret and timestamp
|
@@ -105,9 +106,10 @@ module Bnet
|
|
105
106
|
current = (timestamp || Time.now.getutc.to_i) / 30
|
106
107
|
digest = Digest::HMAC.digest([current].pack('Q>'), secret.as_hex_to_bin, Digest::SHA1)
|
107
108
|
start_position = digest[19].ord & 0xf
|
108
|
-
token = '%08d' % (digest[start_position, 4].as_bin_to_i % 100000000)
|
109
109
|
|
110
|
-
|
110
|
+
token = digest[start_position, 4].unpack('L>')[0] & 0x7fffffff
|
111
|
+
|
112
|
+
return '%08d' % (token % 100000000), (current + 1) * 30
|
111
113
|
end
|
112
114
|
|
113
115
|
# Get authenticator's token from given timestamp
|
data/lib/bnet/commands/info.rb
CHANGED
data/lib/bnet/commands/new.rb
CHANGED
@@ -68,6 +68,6 @@ class Bnet::AuthenticatorTest < Minitest::Test
|
|
68
68
|
assert_equal DEFAULT_RSCODE, authenticator.restorecode
|
69
69
|
assert_equal ['61459300', 1347279360], authenticator.get_token(1347279358)
|
70
70
|
assert_equal ['61459300', 1347279360], authenticator.get_token(1347279359)
|
71
|
-
assert_equal ['
|
71
|
+
assert_equal ['75939986', 1347279390], authenticator.get_token(1347279360)
|
72
72
|
end
|
73
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bnet-authenticator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZHANG Yi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|