bnet-authenticator 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82d4b4048774174d05fac51442d1fa7314c0cff7
4
- data.tar.gz: 79a85eaf15072ae7548b87eabbc344d5161e6fef
3
+ metadata.gz: 028841465a3483415e852b56a2ca8e05552dafd4
4
+ data.tar.gz: 2bf75662b2cdbe6bf3841e38fcc32b7a9a798b4c
5
5
  SHA512:
6
- metadata.gz: 7d2ac8f76a5e66e123f93ff4b44d4940222eb6eaa6d95c390c5944d4c95420661738d7e65ce87e042e2092b1348d0fb8c2535ca0b42f0af7549f90bb887904b2
7
- data.tar.gz: 2844c2afa341884aec85670c6c1d814381bf264d4f87c8b22b867fc756eae790b5b36a4ae286ec2f0f5517ed7bab3785ce51731ea23330830edc1e10c887a194
6
+ metadata.gz: 93b5da7a8a001dc4720f9a2c4947e267a2afe16400d6971c6995ad1e2af7fe71da58a142c0f8ae28ac91c566f3f9f701b963de51df49f7e68b04d2446f9748fc
7
+ data.tar.gz: 401d3af738845309d9690aaed1dfcb1cd33fec147e491afc370071c8f39d44b6a622c40338366025419b4a526b80a02216600a693372af4f9a80c625ec06ef0b
@@ -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).as_bin_to_i.to_f / 1000
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
- return token, (current + 1) * 30
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
@@ -1,5 +1,5 @@
1
1
  module Bnet
2
2
  class Authenticator
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -15,8 +15,7 @@ module Bnet
15
15
  end
16
16
 
17
17
  def run
18
- serial = @args.shift
19
- secret = @args.shift
18
+ serial, secret = @args.shift(2)
20
19
 
21
20
  authenticator = Authenticator.new(serial, secret)
22
21
  puts authenticator.to_readable_text
@@ -15,8 +15,7 @@ module Bnet
15
15
  end
16
16
 
17
17
  def run
18
- region = args.shift || 'US'
19
- region = region.to_sym
18
+ region = (args.shift || 'US').to_sym
20
19
 
21
20
  authenticator = Authenticator.request_authenticator(region)
22
21
  puts authenticator.to_readable_text
@@ -15,8 +15,7 @@ module Bnet
15
15
  end
16
16
 
17
17
  def run
18
- serial = @args.shift
19
- restorecode = @args.shift
18
+ serial, restorecode = @args.shift(2)
20
19
 
21
20
  authenticator = Authenticator.restore_authenticator(serial, restorecode)
22
21
  puts authenticator.to_readable_text
@@ -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 ['23423634', 1347279390], authenticator.get_token(1347279360)
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
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-16 00:00:00.000000000 Z
11
+ date: 2014-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake