vatusa_client 0.0.1a4 → 1.0.0rc1

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: 1730f81685798917b3da56b547c435b9470d8836
4
- data.tar.gz: 831b7fd5f6e9ed5ee1a6e0b061a801c8a848af4b
3
+ metadata.gz: c6a068db3e9c268dde7f1e381bdbf69f23b8e43f
4
+ data.tar.gz: 70016cbe37e86e307560de753865918a7eda95e0
5
5
  SHA512:
6
- metadata.gz: 7eb041f55b163158043435086253bbd3da817272c3c2530c9b220ed9f47b61d826069e5fee12160e306f10e6296bd5e3b73e1583b75daa5eb0e247c780240402
7
- data.tar.gz: 56ea82d682a7267f4cfd5bb28c25bb1171ccd44caf9b7bcd94bd29a33cc94515b9c2acdecaa052934b1629625438ee89a45942c16cd1e3f2064db16c468e3fb0
6
+ metadata.gz: 05170d4888b520dc5f399730bcadd4288ba74ff1b67f179eff0d0dde1dafd3dcc1806e699e27663b7245e305fce5b28c93ac525da85fd848814b911db58b836b
7
+ data.tar.gz: e30f0b281452bff0bdc14569ad2ace301ad39bdb93e4c4a7487baa31b037db2fa43770e20840fe249bff17795781657344d627f7e2460a13200572f12bcf8995
@@ -1,10 +1,12 @@
1
+ require 'jose'
1
2
  require 'jose/jwk'
2
3
  require 'typhoeus'
3
4
  require 'json'
5
+ require 'vatusa_client'
4
6
 
5
7
  module VatusaClient::ULS
6
8
  class ULSClient
7
- def new(jwk:, facility:, dev: false)
9
+ def initialize(jwk:, facility:, dev: false)
8
10
  @jwk = JOSE::JWK.from(jwk)
9
11
  @facility = facility
10
12
  @dev = dev
@@ -16,14 +18,26 @@ module VatusaClient::ULS
16
18
  end
17
19
  def c_returned(token:, ip:)
18
20
  v, tok = @jwk.verify(token)
19
- raise InvalidTokenException unless v
20
- raise IPMismatchException unless tok['ip'] == ip or @dev
21
+ raise VatusaClient::ULS::Exceptions::InvalidTokenException unless v
22
+ raise VatusaClient::ULS::Exceptions::IPMismatchException unless tok['ip'] == ip or @dev
21
23
  req = Typhoeus.get(
22
24
  'https://login.vatusa.net/uls/v2/info',
23
- params: { token: tok }
25
+ params: { token: token }
24
26
  )
25
- req.run
26
- return JSON.parse(req.body)
27
+ r = JSON.parse(req.body)
28
+ if r.key?('status')
29
+ case r['status']
30
+ when 'error'
31
+ if r.key?('msg')
32
+ case r['msg']
33
+ when 'Invalid token'
34
+ raise VatusaClient::ULS::Exceptions::InvalidTokenException
35
+ end
36
+ end
37
+ when 'Expired'
38
+ raise VatusaClient::ULS::Exceptions::ExpiredTokenException
39
+ end
40
+ end
27
41
  end
28
42
  end
29
43
  module Exceptions
@@ -35,5 +49,6 @@ module VatusaClient::ULS
35
49
  end
36
50
  class InvalidTokenException < VerificationException
37
51
  end
52
+ class ExpiredTokenException < VerificationException
38
53
  end
39
54
  end
@@ -1,3 +1,3 @@
1
1
  module VatusaClient
2
- VERSION = "0.0.1a4"
2
+ VERSION = "1.0.0rc1"
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vatusa_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1a4
4
+ version: 1.0.0rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian DeMille
@@ -100,6 +100,7 @@ files:
100
100
  - lib/vatusa_client/api.rb
101
101
  - lib/vatusa_client/uls.rb
102
102
  - lib/vatusa_client/version.rb
103
+ - vatusa_client-0.0.1a4.gem
103
104
  - vatusa_client.gemspec
104
105
  homepage: https://gitlab.com/vatusa-clients/vatusa_client_ruby
105
106
  licenses: []