blockstack 0.5.1 → 0.5.2

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: 856db619c8ab5d624bc8402faa47989eedc93b76
4
- data.tar.gz: 266805065350e09d91e97e72c3ed63a5abee3a21
3
+ metadata.gz: 2d182963e3410d64223d4e5617b937dacdb0ddde
4
+ data.tar.gz: 9ea95bcb1501f22f18dddbeffa11a572971334ff
5
5
  SHA512:
6
- metadata.gz: ba8fa9ff258002553320ae0002ac29606c9e50f723b7a74052c242f48a9351714c8a822cc742a1e4075cf75bcd8c4962ec27f3956872056a8e3b7dcdd99e23e6
7
- data.tar.gz: 965b2275f7a4f2e059b6cc0fec8b815a4d707d899c06e1799372bee67f9b723169c06aaecd2f506f17bdce6784f800c7cc1897e39a5111923c85c7a47dd7033f
6
+ metadata.gz: 9072263456ede40a861129b34c6e96d7960c4a60f7dbaa480600aa30947e1bb44a415ba75b5ba14110bb5d1a31dd71aec9afb254ef0a30a35592dce17e782aea
7
+ data.tar.gz: da42e8b8dc4526fac002e79e509a82b82a238b76c1579e4456711ddcf9a5827ce02373fe4ca0ef2fb3484d9528283bd7c7b12563025d03230db52dd22163a76d
@@ -1,3 +1,3 @@
1
1
  module Blockstack
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
data/lib/blockstack.rb CHANGED
@@ -4,14 +4,39 @@ require "faraday"
4
4
  require "jwt"
5
5
 
6
6
  module Blockstack
7
+ class InvalidAuthResponse < StandardError; end
8
+
7
9
  USER_AGENT = "blockstack-ruby #{VERSION}"
8
10
  ALGORITHM = "ES256K"
9
11
  REQUIRED_CLAIMS = %w(iss iat jti exp username profile publicKeys)
10
- LEEWAY = 300 # seconds
11
- VALID_WITHIN = 300 # seconds
12
- BLOCKSTACK_API = "http://localhost:6270"
13
12
 
14
- class InvalidAuthResponse < StandardError; end
13
+ DEFAULT_LEEWAY = 30 # seconds
14
+ DEFAULT_VALID_WITHIN = 30 # seconds
15
+ DEFAULT_API = "http://localhost:6270"
16
+
17
+ def self.api=(api)
18
+ @@api = api.nil? ? DEFAULT_API : api
19
+ end
20
+
21
+ def self.api
22
+ @@api
23
+ end
24
+
25
+ def self.leeway=(leeway)
26
+ @@leeway = leeway.nil? ? DEFAULT_LEEWAY : leeway
27
+ end
28
+
29
+ def self.leeway
30
+ @@leeway
31
+ end
32
+
33
+ def self.valid_within=(valid_within)
34
+ @@valid_within = valid_within.nil? ? DEFAULT_VALID_WITHIN : valid_within
35
+ end
36
+
37
+ def self.valid_within
38
+ @@valid_within
39
+ end
15
40
 
16
41
  def self.verify_auth_response(auth_token)
17
42
  # decode & verify token without checking signature so we can extract
@@ -20,7 +45,7 @@ module Blockstack
20
45
  verify = false
21
46
  decoded_tokens = JWT.decode auth_token, public_key, verify, algorithm: ALGORITHM
22
47
  decoded_token = decoded_tokens[0]
23
- puts decoded_token
48
+
24
49
  REQUIRED_CLAIMS.each do |field|
25
50
  raise InvalidAuthResponse.new("Missing required '#{field}' claim.") if !decoded_token.key?(field.to_s)
26
51
  end
@@ -102,4 +127,10 @@ module Blockstack
102
127
  connection.headers[:user_agent] = USER_AGENT
103
128
  connection
104
129
  end
130
+
131
+ private
132
+
133
+ @@leeway = DEFAULT_LEEWAY
134
+ @@valid_within = DEFAULT_VALID_WITHIN
135
+ @@api = DEFAULT_API
105
136
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Larry Salibra