omniauth-icos 1.0.5 → 1.0.6

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: 13f3ecbb3353218ade85bc0bb6a053ea85be4f0d
4
- data.tar.gz: 8b2e81eb93ca0917bbef7e194fb9f1b673181927
3
+ metadata.gz: c70d3a121648078ac962f604302607d3bf479761
4
+ data.tar.gz: ebfac26c55bd1c614b75e704ef48e623dbe309c3
5
5
  SHA512:
6
- metadata.gz: cb37b76a77d40c857087097074f98462a58da19ed4c9c47550f9930ba3daed42160aedbf513b4cf9f3ef38abc37885272a16742f4626a16ed5c37093f0b5f0fc
7
- data.tar.gz: 311eb9f5008312ecae7596a6cd230febcdb8be4467ae745d5f8b29b3a5f9c3839705cc54c5a7ca04ba5e1fea160ff02f4e2c2e8a2f13cbf7519dd1212b0fb233
6
+ metadata.gz: 031543e2f966eebc79c60b1da78591920f27ad3a3508ef554396497eb9f4d943e1a3fd9aff7a11a71c5c853be726ca48ac1404f07fc2d39d3505a7a6844c36a2
7
+ data.tar.gz: 9814c558980a4d5dcb4d8e26e2c2df06f40e9c853af9ca94d6f9460f109d7155ef9d3e650577c2cba69ead3badf1ba071bccb5e083f6cefc6771762a5c89de27
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module ICOS
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
@@ -11,7 +11,7 @@ module OmniAuth
11
11
 
12
12
  option :client_options, {
13
13
  authorize_url: '/oauth2/auth',
14
- token_url: '/oauth2/token',
14
+ token_url: '/v1/consents/exchange',
15
15
  site: 'https://icosid.com'
16
16
  }
17
17
 
@@ -27,7 +27,7 @@ module OmniAuth
27
27
 
28
28
  uid { user_info['Id'] }
29
29
 
30
- info do
30
+ info do
31
31
  {
32
32
  :email => user_info['Email'],
33
33
  :phone => user_info['Phone'],
@@ -35,31 +35,66 @@ module OmniAuth
35
35
  :first_name => user_info['FirstName'],
36
36
  :middle_name => user_info['MiddleName'],
37
37
  :last_name => user_info['LastName'],
38
- :county => user_info['County'],
38
+ :lang => user_info['Lang'],
39
+ :county_code => user_info['Country'],
40
+ :city => user_info['City'],
39
41
  :citizenship => user_info['Citizenship'],
40
42
  :address => user_info['Address'],
43
+ :state => user_info['State'],
44
+ :dob => user_info['Dob'],
41
45
  :document_number => user_info['DocumentNumber'],
46
+ :document_type => user_info['DocumentType'],
42
47
  :use_g2fa => user_info['UseG2fa'],
43
- :globalid_verify => user_info['GlobalidVerify'],
44
- :globalid_agent_verify => user_info['GlobalidAgentVerify'],
45
- :netki_status => user_info['NetkiStatus'],
46
- :eth_wallet => user_info['EthWallet']
48
+ :gender => user_info['Gender'],
49
+ :kyc_status => user_info['KycStatus'],
50
+ :kyc_reason => user_info['KycReason'],
51
+ :kyc_at => user_info['KycAt'],
52
+ :is_verified => user_info['IsVerified']
47
53
  }
48
54
  end
49
-
55
+
50
56
  extra do
51
57
  {
52
58
  :raw_info => raw_info
53
59
  }
54
60
  end
55
61
 
56
- def build_access_token
57
- options.token_params.merge!(:headers => {'Authorization' => basic_auth_header })
58
- super
62
+ def callback_url
63
+ options[:redirect_uri] || (full_host + script_name + callback_path)
59
64
  end
60
65
 
61
- def basic_auth_header
62
- 'Basic ' + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
66
+ def build_access_token
67
+ params = ::OAuth2::Authenticator.new(client.id, client.secret, :request_body).apply(
68
+ {
69
+ 'Redirect' => callback_url,
70
+ 'ClientId' => options[:client_id],
71
+ 'ClientSecret' => options[:client_secret],
72
+ 'Scopes' => DEFAULT_SCOPES,
73
+ 'Code' => request.params['code']
74
+ }
75
+ )
76
+
77
+ opts = {
78
+ :raise_errors => options[:raise_errors],
79
+ :parse => params.delete(:parse),
80
+ :body => params,
81
+ :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' }
82
+ }
83
+
84
+ headers = params.delete(:headers) || {}
85
+ opts[:headers].merge!(headers)
86
+
87
+ response = client.request(:post, client.token_url, opts)
88
+
89
+ if !response.parsed.is_a?(Hash) || !response.parsed['Result'] || !response.parsed['Result']['access_token']
90
+ error = ::OmniAuth::Error.new(response)
91
+ raise(error)
92
+ end
93
+
94
+ body = response.parsed['Result']
95
+ body['expires_at'] = body['expiry'].to_datetime.in_time_zone
96
+
97
+ ::OAuth2::AccessToken.from_hash(client, body)
63
98
  end
64
99
 
65
100
  def compact_full_name
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-icos
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Anistratenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-01 00:00:00.000000000 Z
11
+ date: 2018-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth