strongmind-platform-sdk 3.34.1 → 3.34.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: fd51875610b6504f5d6cdc31e8384443b384e90ed25a5293d34a1592eba93180
4
- data.tar.gz: fbd570234a1128e37a2b8e8dfc408fce6a98cc995486855e6bf600df736a795d
3
+ metadata.gz: '028ca313c6f9bce49fb5b02e6f929b2ed0939f191938d450d5433647e6ef644b'
4
+ data.tar.gz: 71e0174a2f1929f7acad9727f71c4286ba9791b5f02a0a011a23485de2d22886
5
5
  SHA512:
6
- metadata.gz: 30f9636c5de88c33b9e005d7c68cb351c2ebf44e69fab99c10e3c80f9ef9ed62c69e6e2b1c701d6fb96de6c958ee7814ad69fb2819c57a17595c95cdbccce328
7
- data.tar.gz: 68fe58679f511b353f348d5fd5c4624b856858127026293b1a8ef175be3ceb9b9d8d4d9999a5dfa3ad3ee7dc206a65fe2ca3fefc1b9640d59a34595ac13ce441
6
+ metadata.gz: fc53e003fdc583a4afc1c0ea2cd8e4253a23f44f38d08849b2d56c2a57d625e876cadb668df2bbbbdc705ef2d0b57362462baf27336f9fa05e337841b321aebc
7
+ data.tar.gz: b4a08cd44666bbc7c467afc211f92084b55942609231d121b04e3bee5078a6577be028b0556e8352d080f1695be0055e582250f59775db58a73d607a92c18e9a
@@ -4,12 +4,7 @@ module PlatformSdk
4
4
  module Identity
5
5
  # Error handling for Identity SDK
6
6
  module ErrorHandleable
7
- # The logged payload is the raw request body, which for token endpoints
8
- # carries client credentials; redact those fields (form-encoded and
9
- # JSON shapes) so an auth outage can't write secrets to consumer logs.
10
- SENSITIVE_KEYS = 'client_secret|client_assertion|refresh_token|password'
11
- FORM_SECRET_PATTERN = /(#{SENSITIVE_KEYS})=[^&]*/i
12
- JSON_SECRET_PATTERN = /("(?:#{SENSITIVE_KEYS})"\s*:\s*")[^"]*(")/i
7
+ REDACTED = '[REDACTED]'
13
8
 
14
9
  def with_rescue
15
10
  yield
@@ -22,12 +17,9 @@ module PlatformSdk
22
17
  end
23
18
 
24
19
  def raise_error_with_payload(exception_class, error)
25
- Rails.logger.info(error_log_payload(exception_class, error).to_json) if defined?(Rails)
26
- # The exception itself carries error.response on to consumer
27
- # instrumentation (Sentry, custom error handlers), so the raw
28
- # request body/headers - which can hold a client_secret or bearer
29
- # token - must be scrubbed here too, not just in the log line above.
30
- raise exception_class, scrub_response(error.response)
20
+ payload = error_log_payload(exception_class, error)
21
+ Rails.logger.info(payload.to_json) if defined?(Rails)
22
+ raise exception_class.new(error_message(payload), scrub_response(error.response)), cause: nil
31
23
  end
32
24
 
33
25
  # No ActiveSupport here (String#demodulize): this must work for
@@ -36,25 +28,20 @@ module PlatformSdk
36
28
  def error_log_payload(exception_class, error)
37
29
  {
38
30
  exception: exception_class.name.split('::').last,
39
- payload: scrub_secrets(error.response.dig(:request, :body)),
31
+ method: error.response.dig(:request, :method),
32
+ path: error.response.dig(:request, :url_path),
40
33
  response_body: error.response[:body],
41
34
  status: error.response[:status]
42
35
  }.compact
43
36
  end
44
37
 
45
- def scrub_secrets(body)
46
- return body unless body.is_a?(String)
38
+ def error_message(payload)
39
+ message = "the server responded with status #{payload[:status]}"
40
+ return message unless payload[:method] && payload[:path]
47
41
 
48
- body.gsub(FORM_SECRET_PATTERN) { "#{Regexp.last_match(1)}=[REDACTED]" }
49
- .gsub(JSON_SECRET_PATTERN, '\1[REDACTED]\2')
42
+ "#{message} for #{payload[:method].to_s.upcase} #{payload[:path]}"
50
43
  end
51
44
 
52
- # Returns a scrubbed copy of the Faraday error response hash; the
53
- # original (and its nested :request hash) are left untouched. Only
54
- # [:request][:body] and [:request][:headers] are touched -
55
- # [:status] and [:body] (the response body) are read elsewhere
56
- # (e.g. e.response&.dig(:status), e.response&.dig(:body, 'paramName'))
57
- # and must reach consumers unchanged.
58
45
  def scrub_response(response)
59
46
  return response unless response.is_a?(Hash)
60
47
 
@@ -65,7 +52,9 @@ module PlatformSdk
65
52
 
66
53
  def scrub_request(request)
67
54
  scrubbed_request = request.dup
68
- scrubbed_request[:body] = scrub_secrets(request[:body]) if request[:body].is_a?(String)
55
+ scrubbed_request[:body] = REDACTED if request.key?(:body)
56
+ scrubbed_request[:params] = REDACTED if request.key?(:params)
57
+ scrubbed_request[:url] = request[:url_path] if request.key?(:url)
69
58
  scrubbed_request[:headers] = scrub_headers(request[:headers]) if request[:headers].is_a?(Hash)
70
59
  scrubbed_request
71
60
  end
@@ -75,7 +64,7 @@ module PlatformSdk
75
64
  def scrub_headers(headers)
76
65
  scrubbed = headers.dup
77
66
  scrubbed.each_key do |key|
78
- scrubbed[key] = '[REDACTED]' if key.to_s.casecmp('authorization').zero?
67
+ scrubbed[key] = REDACTED if key.to_s.casecmp('authorization').zero?
79
68
  end
80
69
  scrubbed
81
70
  end
@@ -3,7 +3,7 @@
3
3
  module PlatformSdk
4
4
  MAJOR = 3
5
5
  MINOR = 34
6
- PATCH = 1
6
+ PATCH = 2
7
7
 
8
8
  VERSION = "#{PlatformSdk::MAJOR}.#{PlatformSdk::MINOR}.#{PlatformSdk::PATCH}".freeze
9
9
  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.34.1
4
+ version: 3.34.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: 2026-10-12 00:00:00.000000000 Z
11
+ date: 2026-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -392,7 +392,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
392
392
  - !ruby/object:Gem::Version
393
393
  version: '0'
394
394
  requirements: []
395
- rubygems_version: 3.4.10
395
+ rubygems_version: 3.4.19
396
396
  signing_key:
397
397
  specification_version: 4
398
398
  summary: This gem is intended to provide clients and models for accessing the Platform