setsuzoku 0.13.0 → 0.14.3

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
  SHA256:
3
- metadata.gz: 2000ab035e24854f6a272d61a3ee639bb3e439b9b6a30ad6fb561619329d8f67
4
- data.tar.gz: 14424c08ba7e2a292df246c9ddfcc878ff40e041f969c12738eb73851fe38980
3
+ metadata.gz: 0c0b8c050fa9e109346e671c24de8e74926cebfeb633287d1ace06887f6f51c4
4
+ data.tar.gz: f848f52cfea63adb526db081c46e61988a17766d3965651de20f41eddaf55478
5
5
  SHA512:
6
- metadata.gz: 805e60a36064d10811169e66b8cf897240d747771780421f9ef1c9f39fcb7d3eda6216e85644bf1f77d7087664a5dd270ca53c7799b4cd53bcac20303e6bb6c9
7
- data.tar.gz: 4132dd8debf2539ec898eb3c2bbad9d2cd58ad4a4d1cb6669972a338bd5121470338fa16aa9d1b83777d7fc2b5c09dd63d57f613b6391c5ba2aba8ae7cd95f1e
6
+ metadata.gz: b0ec90c69f2c0b534fc2b9f8c41f8b16307b91c5a6c29dfa04f3f19b491d49ad976ebd1c1bd7d9080705d9840745255aa7311b73f156b174aa51d5121eb5d443
7
+ data.tar.gz: c751c9cc1d177c1aeefce1944751e361a01a5a2749c36abbfee713a2aaa564099b03092a38842839f6f5ab790515b9b88f786c123bac2dc1c3fdb4f671139d81
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- setsuzoku (0.13.0)
4
+ setsuzoku (0.14.3)
5
5
  activesupport (>= 5.0, < 7)
6
6
  faraday (~> 0.11)
7
7
  nokogiri (~> 1.10)
@@ -10,29 +10,31 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- activesupport (6.0.3.4)
13
+ activesupport (6.1.4)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- zeitwerk (~> 2.2, >= 2.2.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ zeitwerk (~> 2.3)
19
19
  addressable (2.7.0)
20
20
  public_suffix (>= 2.0.2, < 5.0)
21
- concurrent-ruby (1.1.7)
21
+ concurrent-ruby (1.1.9)
22
22
  crack (0.4.3)
23
23
  safe_yaml (~> 1.0.0)
24
24
  diff-lcs (1.4.2)
25
- faraday (0.17.3)
25
+ faraday (0.17.4)
26
26
  multipart-post (>= 1.2, < 3)
27
27
  hashdiff (1.0.1)
28
- i18n (1.8.5)
28
+ i18n (1.8.10)
29
29
  concurrent-ruby (~> 1.0)
30
- mini_portile2 (2.4.0)
31
- minitest (5.14.2)
30
+ mini_portile2 (2.5.3)
31
+ minitest (5.14.4)
32
32
  multipart-post (2.1.1)
33
- nokogiri (1.10.10)
34
- mini_portile2 (~> 2.4.0)
33
+ nokogiri (1.11.7)
34
+ mini_portile2 (~> 2.5.0)
35
+ racc (~> 1.4)
35
36
  public_suffix (4.0.5)
37
+ racc (1.5.2)
36
38
  rake (10.5.0)
37
39
  rspec (3.8.0)
38
40
  rspec-core (~> 3.8.0)
@@ -50,16 +52,15 @@ GEM
50
52
  safe_yaml (1.0.5)
51
53
  sorbet (0.5.5675)
52
54
  sorbet-static (= 0.5.5675)
53
- sorbet-runtime (0.5.5937)
55
+ sorbet-runtime (0.5.6480)
54
56
  sorbet-static (0.5.5675-universal-darwin-14)
55
- thread_safe (0.3.6)
56
- tzinfo (1.2.7)
57
- thread_safe (~> 0.1)
57
+ tzinfo (2.0.4)
58
+ concurrent-ruby (~> 1.0)
58
59
  webmock (3.8.0)
59
60
  addressable (>= 2.3.6)
60
61
  crack (>= 0.3.2)
61
62
  hashdiff (>= 0.4.0, < 2.0.0)
62
- zeitwerk (2.4.0)
63
+ zeitwerk (2.4.2)
63
64
 
64
65
  PLATFORMS
65
66
  ruby
@@ -147,7 +147,7 @@ module Setsuzoku
147
147
  .merge!(self.auth_strategy.get_from_context(:auth_headers).except(:authorization))
148
148
  .merge!(self.get_from_context(:api_headers))
149
149
  .merge!(action_details[:request_options] || {})
150
- request_options[:authorization] = self.auth_strategy.get_from_context(:auth_headers)[:authorization]
150
+ request_options[:authorization] = action_details[:authorization] || self.auth_strategy.get_from_context(:auth_headers)[:authorization]
151
151
 
152
152
  content_type = case request_format
153
153
  when :json
@@ -137,36 +137,14 @@ module Setsuzoku
137
137
  # @return void
138
138
  def get_token!(body, action)
139
139
  success = false
140
- request = self.api_strategy.request_class.new(action: action, body: body, without_headers: true)
140
+ without_headers = self.credential.auth_actions[action].has_key?(:without_headers) ? self.credential.auth_actions[action][:without_headers] : true
141
+ request = self.api_strategy.request_class.new(action: action, body: body, without_headers: without_headers)
141
142
 
142
143
  resp = self.api_strategy.call_external_api(request: request, strategy: :auth)
143
144
 
144
145
  return false unless resp.success
145
146
 
146
- attrs = self.credential.token_attributes_to_assign(resp)
147
- attrs[:status] = if attrs[:token]
148
- 'active'
149
- else
150
- 'error'
151
- end
152
-
153
- # Assign any additional attributes the plugin's credential needs to know about.
154
- # E.g. the extension for a phone_number.
155
- plugin_attrs = self.credential.additional_attributes_to_assign(resp) if self.plugin.respond_to?(:credential_fields_to_update)
156
- attrs.merge!(plugin_attrs) if plugin_attrs
157
-
158
- # Only save Setsuzoku known fields, and any additional attributes the plugin specifies
159
- # in credential_fields_to_update.
160
- if self.credential.respond_to?(:"update_columns")
161
- # we issue an update_columns instead of a save/update_attributes
162
- # so as to only mutate these attributes
163
- # and not any other fields that may have been set for the credential
164
- save = self.credential.update_columns(attrs)
165
- self.credential.touch if save && self.credential.respond_to?(:"touch")
166
- save
167
- else
168
- true
169
- end
147
+ self.credential.set_token!(resp)
170
148
  end
171
149
  end
172
150
  end
@@ -54,26 +54,6 @@ module Setsuzoku
54
54
  sig { abstract.returns(T.nilable(String)) }
55
55
  def redirect_url; end
56
56
 
57
- # The token, refresh_token, and expires_at to assign for an OAuth token request.
58
- #
59
- # @param resp [Hash] the response hash from the external api call for a token.
60
- #
61
- # @return [Hash] the attributes to assign to the credential.
62
- sig{ overridable.params(resp: Setsuzoku::ApiResponse).returns(T::Hash[Symbol, T.untyped]) }
63
- def token_attributes_to_assign(resp)
64
- attrs = {
65
- token: resp.data[:access_token],
66
- refresh_token: resp.data[:refresh_token]
67
- }
68
-
69
- expires_in = resp.data[:expires_in]
70
- if expires_in && (expires_in.is_a?(Integer) || expires_in.match(/^\d+$/))
71
- attrs[:expires_on] = expires_in.to_i.seconds.from_now
72
- end
73
-
74
- attrs
75
- end
76
-
77
57
  # Stub an o_auth_credential-like instance.
78
58
  #
79
59
  # @return [Struct] a stubbed o_auth_credential-like struct.
@@ -51,16 +51,16 @@ module Setsuzoku
51
51
  #
52
52
  # @return [Datetime] the time to set for the current token's expiry.
53
53
  sig{ abstract.params(val: DateTime).returns(T.nilable(DateTime)) }
54
- def expires_on=(val);
54
+ def expires_on=(val); end
55
55
 
56
- # The token fields to bet set for the custom credential.
56
+ # All credentials must have some implementation of storing their token details.
57
57
  #
58
- # @param resp [Hash] the response hash from the external api call for a token.
58
+ # @param resp [Setsuzoku::ApiResponse] the response hash from the external api call for a token.
59
+ # @param attrs [Hash] additional attrs to be passed to super if desired.
59
60
  #
60
61
  # @return [Hash] the attributes to assign to the credential.
61
- sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
62
- def token_attributes_to_assign(resp); end
63
- end
62
+ sig { abstract.params(resp: Setsuzoku::ApiResponse, attrs: T.nilable(T::Hash[Symbol, T.untyped])).void }
63
+ def set_token!(resp, attrs); end
64
64
  end
65
65
  end
66
66
  end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Setsuzoku
5
- VERSION = '0.13.0'
5
+ VERSION = '0.14.3'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: setsuzoku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Stadtler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2021-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -227,7 +227,7 @@ homepage: https://github.com/rocketreferrals/setsuzoku
227
227
  licenses:
228
228
  - MIT
229
229
  metadata: {}
230
- post_install_message:
230
+ post_install_message:
231
231
  rdoc_options: []
232
232
  require_paths:
233
233
  - lib
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubygems_version: 3.0.1
246
- signing_key:
246
+ signing_key:
247
247
  specification_version: 4
248
248
  summary: Extensible 3rd-party interface and functionality plugins
249
249
  test_files: []