strongmind-platform-sdk 3.10.1 → 3.10.2

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
  SHA256:
3
- metadata.gz: cf9bfdc1d3b87dbbefbe4b9e1b08d25b544ded0718d31d28d6224e976c4d440c
4
- data.tar.gz: eb316b3acc88e86d6e5a326a2a0e8e6c4d50d8ff92cade77f8228b15e80d5940
3
+ metadata.gz: fca9cc6c8dcf5d60413ccaade1fe75d0d1c3034984d26f4fbfd2a72ec7eeee6b
4
+ data.tar.gz: 66c6e120f49d0898618ca43879f09808b3e4042c25e3a57c14b5c65b21935372
5
5
  SHA512:
6
- metadata.gz: 9ebfdbd2952f4455141f4addd23675245bd048fa9050c01586cd2d6b7ec66ba0348e9f52c9cf0867967712556cfd8b7b0ccc2a2756d02610497f7380206ca3de
7
- data.tar.gz: cdc7fa6f4909e56ad84f271dbd8cb8826d941f6ffd51e256a682088400d4fae5f61a7305c6dd45323f1f05b62e69c5c2dca197941da0199e3e192f8bae13f57b
6
+ metadata.gz: 74ca995cf7efa813996ff36cd0d260376a0964d54f30abaeecc90841ef2cd716c9ee58f2f2cf7af4546e65f5a21b0266930657b493c5c7e4556b25335e18402c
7
+ data.tar.gz: 4355b9b306fd3cbdae3bf12cf956677eb8ed58c4a276afc0abc5e8954c5f335c966518bac240f9fd5956d19651f99fa208108fb3ec7df2c996f921fb5a7961c5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strongmind-platform-sdk (3.10.1)
4
+ strongmind-platform-sdk (3.10.2)
5
5
  aws-sdk-secretsmanager (~> 1.66)
6
6
  devise
7
7
  faraday (~> 2.5, >= 2.5.2)
@@ -19,26 +19,27 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- actionpack (7.0.5)
23
- actionview (= 7.0.5)
24
- activesupport (= 7.0.5)
25
- rack (~> 2.0, >= 2.2.4)
22
+ actionpack (6.1.7.7)
23
+ actionview (= 6.1.7.7)
24
+ activesupport (= 6.1.7.7)
25
+ rack (~> 2.0, >= 2.0.9)
26
26
  rack-test (>= 0.6.3)
27
27
  rails-dom-testing (~> 2.0)
28
28
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
29
- actionview (7.0.5)
30
- activesupport (= 7.0.5)
29
+ actionview (6.1.7.7)
30
+ activesupport (= 6.1.7.7)
31
31
  builder (~> 3.1)
32
32
  erubi (~> 1.4)
33
33
  rails-dom-testing (~> 2.0)
34
34
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
35
- activemodel (7.0.5)
36
- activesupport (= 7.0.5)
37
- activesupport (7.0.5)
35
+ activemodel (6.1.7.7)
36
+ activesupport (= 6.1.7.7)
37
+ activesupport (6.1.7.7)
38
38
  concurrent-ruby (~> 1.0, >= 1.0.2)
39
39
  i18n (>= 1.6, < 2)
40
40
  minitest (>= 5.1)
41
41
  tzinfo (~> 2.0)
42
+ zeitwerk (~> 2.3)
42
43
  addressable (2.8.6)
43
44
  public_suffix (>= 2.0.2, < 6.0)
44
45
  aes_key_wrap (1.1.0)
@@ -61,7 +62,7 @@ GEM
61
62
  bigdecimal (3.1.6)
62
63
  bindata (2.5.0)
63
64
  builder (3.2.4)
64
- concurrent-ruby (1.2.2)
65
+ concurrent-ruby (1.2.3)
65
66
  crack (1.0.0)
66
67
  bigdecimal
67
68
  rexml
@@ -79,9 +80,9 @@ GEM
79
80
  erubi (1.12.0)
80
81
  ethon (0.16.0)
81
82
  ffi (>= 1.15.0)
82
- factory_bot (6.2.1)
83
+ factory_bot (6.4.5)
83
84
  activesupport (>= 5.0.0)
84
- faker (3.2.0)
85
+ faker (2.22.0)
85
86
  i18n (>= 1.8.11, < 2)
86
87
  faraday (2.7.7)
87
88
  faraday-net_http (>= 2.0, < 3.1)
@@ -94,11 +95,11 @@ GEM
94
95
  ffi (1.15.5)
95
96
  hashdiff (1.1.0)
96
97
  hashie (5.0.0)
97
- i18n (1.13.0)
98
+ i18n (1.14.1)
98
99
  concurrent-ruby (~> 1.0)
99
100
  jmespath (1.6.2)
100
101
  json (2.6.3)
101
- json-jwt (1.16.5)
102
+ json-jwt (1.16.6)
102
103
  activesupport (>= 4.2)
103
104
  aes_key_wrap
104
105
  base64
@@ -119,7 +120,7 @@ GEM
119
120
  method_source (1.0.0)
120
121
  mini_mime (1.1.5)
121
122
  mini_portile2 (2.8.5)
122
- minitest (5.18.0)
123
+ minitest (5.22.2)
123
124
  multi_json (1.15.0)
124
125
  net-imap (0.4.10)
125
126
  date
@@ -133,10 +134,6 @@ GEM
133
134
  nokogiri (1.16.2)
134
135
  mini_portile2 (~> 2.8.2)
135
136
  racc (~> 1.4)
136
- nokogiri (1.16.2-x86_64-darwin)
137
- racc (~> 1.4)
138
- nokogiri (1.16.2-x86_64-linux)
139
- racc (~> 1.4)
140
137
  omniauth (2.1.2)
141
138
  hashie (>= 3.4.6)
142
139
  rack (>= 2.2.3)
@@ -186,13 +183,12 @@ GEM
186
183
  rails-html-sanitizer (1.6.0)
187
184
  loofah (~> 2.21)
188
185
  nokogiri (~> 1.14)
189
- railties (7.0.5)
190
- actionpack (= 7.0.5)
191
- activesupport (= 7.0.5)
186
+ railties (6.1.7.7)
187
+ actionpack (= 6.1.7.7)
188
+ activesupport (= 6.1.7.7)
192
189
  method_source
193
190
  rake (>= 12.2)
194
191
  thor (~> 1.0)
195
- zeitwerk (~> 2.5)
196
192
  rainbow (3.1.1)
197
193
  rake (13.0.6)
198
194
  regexp_parser (2.8.0)
@@ -37,11 +37,23 @@ module PlatformSdk
37
37
  end
38
38
  end
39
39
 
40
- def auth_token
41
- if expired?
42
- response = @conn.post("/connect/token", request_body)
43
- @token = response.body.transform_keys(&:to_sym)
40
+ def with_rescue
41
+ yield
42
+ rescue Faraday::ServerError => e
43
+ raise_error_with_payload(IdentityServerError, e)
44
+ rescue Faraday::ClientError => e
45
+ raise_error_with_payload(IdentityClientError, e)
46
+ end
47
+
48
+ def post_payload(path, body)
49
+ with_rescue do
50
+ response = @conn.post(path, body)
51
+ response.body.transform_keys!(&:to_sym)
44
52
  end
53
+ end
54
+
55
+ def auth_token
56
+ @token = post_payload("/connect/token", request_body) if expired?
45
57
 
46
58
  @token[:access_token]
47
59
  end
@@ -75,9 +87,8 @@ module PlatformSdk
75
87
  def refresh_token(refresh_token)
76
88
  raise ArgumentError if refresh_token.nil?
77
89
 
78
- response = @conn.post("/connect/token", request_body(
90
+ post_payload("/connect/token", request_body(
79
91
  grant_type: "refresh_token", refresh_token:))
80
- response.body.transform_keys!(&:to_sym)
81
92
  end
82
93
 
83
94
  def refresh_session(session: {})
@@ -92,6 +103,17 @@ module PlatformSdk
92
103
  session[:refresh_token] = refreshed_tokens[:refresh_token]
93
104
  end
94
105
 
106
+ def raise_error_with_payload(exception_class, error)
107
+ json_log = {
108
+ exception: exception_class.new.class.name.demodulize,
109
+ payload: error.response.dig(:request, :body),
110
+ response_body: error.response[:body],
111
+ status: error.response[:status]
112
+ }.compact
113
+ Rails.logger.info json_log.to_json if respond_to?(:Rails)
114
+ raise exception_class, error.response
115
+ end
116
+
95
117
  private
96
118
 
97
119
  def request_body(grant_type: "client_credentials", refresh_token: nil)
@@ -11,5 +11,7 @@ require "platform_sdk/identity/clients"
11
11
  module PlatformSdk
12
12
  module Identity
13
13
  class IdentityNotFoundError < StandardError; end
14
+ class IdentityServerError < Faraday::ServerError; end
15
+ class IdentityClientError < Faraday::ClientError; end
14
16
  end
15
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PlatformSdk
4
- VERSION = "3.10.1"
4
+ VERSION = "3.10.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strongmind-platform-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.1
4
+ version: 3.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platform Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-26 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday