paystack_sdk 0.4.0 → 0.4.1

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: da9c2a9982f9eb4ec639e53651b7a54a20e0adda1d0f3f21b2add3bcf51194b2
4
- data.tar.gz: 12bc63e0ebc8e8448f2a73cbabe2230af8c0f783857b3931dc72973dfcb3581a
3
+ metadata.gz: 4d2f7a168f41486d2df726ca96f7f6ff1864e4f66b46a019a3894385c5a74a16
4
+ data.tar.gz: d2f63d9282c6fd568c8e9c16d7b91bbb65fe874fea489420af92f0336f9431e2
5
5
  SHA512:
6
- metadata.gz: ebf5ddb53f888f1d9aaa017b4aa9af1542f28aa563654f13de77ffc78f83043073c7aa2134e030853695e06dcc98ee88e5688d1e682462c4036df239e8605f26
7
- data.tar.gz: 2f7b2710265dcab7de4367ab68da1e7112e963d6a165ed3024f7881b81dc44032b0c706afddf896d52a4c0e5999208c397ae55c78ad07c5c5fefc2af13bc865d
6
+ metadata.gz: 9470f85d1e68ec70caa4b50e02c3ab001eef9490d2f562294c1067316ca12b43c6f6f74e876750b1ef8da6d2f88c88b56f0d2eeb234e95d92162fd4e09afd6ec
7
+ data.tar.gz: 92d8ddbc6768188517ad0dc39b36b64adb0faac6c13fa4a3c1b8bd29f6c8977f028b18c3ef892bd7e483c801eed68783a4e35607acf2cbd51fb3ac349cb1a70f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.4.1] - 2026-10-10
6
+
7
+ ### Security
8
+
9
+ - The secret key no longer appears when a `Client`, a resource (`client.transactions`...) or the Faraday connection is inspected. Ruby's default `inspect` and `pp` printed every instance variable, and the connection holds the key in its `Authorization` header, so `puts client`, `Rails.logger.info(client)`, an error page, or an error tracker that serialises locals wrote the key out. `Client#inspect` and `Resources::Base#inspect` now return only the class name, and the connection built by the SDK (and its `headers`) inspect without the key. The key is still sent. Errors raised by the SDK, their causes and `Response` never contained the key (checked). Affects every version before 0.4.1 (0.0.x to 0.4.0): if you may have logged one of these objects, rotate the key. A connection you pass in yourself (`Client.new(connection)`) is yours, and its own `inspect` is unchanged.
10
+
5
11
  ## [0.4.0] - 2026-10-09
6
12
 
7
13
  ### Added
@@ -344,6 +344,15 @@ module PaystackSdk
344
344
  @terminals ||= Resources::Terminals.new(@connection)
345
345
  end
346
346
 
347
+ # A short description that never includes the secret key. Ruby's default `inspect` prints every
348
+ # instance variable, and the connection holds the key in its `Authorization` header, so logging,
349
+ # `pp`, an error page or an error tracker would otherwise write the key out.
350
+ #
351
+ # @return [String]
352
+ def inspect
353
+ "#<#{self.class.name}>"
354
+ end
355
+
347
356
  private
348
357
 
349
358
  # The secret key a connection sends, read from its Authorization header.
@@ -35,6 +35,13 @@ module PaystackSdk
35
35
  @connection = initialize_connection(connection, secret_key: secret_key, **options)
36
36
  end
37
37
 
38
+ # A short description that never includes the secret key; see {PaystackSdk::Client#inspect}.
39
+ #
40
+ # @return [String]
41
+ def inspect
42
+ "#<#{self.class.name}>"
43
+ end
44
+
38
45
  private
39
46
 
40
47
  # Handles the API response, wrapping it in a Response object.
@@ -92,7 +92,7 @@ module PaystackSdk
92
92
  retry_non_idempotent: false)
93
93
  validate_connection_options!(timeout:, open_timeout:, max_retries:, retry_interval:)
94
94
 
95
- Faraday.new(url: BASE_URL, request: {timeout:, open_timeout:}) do |conn|
95
+ connection = Faraday.new(url: BASE_URL, request: {timeout:, open_timeout:}) do |conn|
96
96
  conn.use Middleware::TransportErrors
97
97
  if max_retries > 0
98
98
  conn.request :retry, retry_options(max_retries, retry_interval, retry_non_idempotent)
@@ -104,10 +104,21 @@ module PaystackSdk
104
104
  conn.headers["User-Agent"] = "paystack_sdk/#{PaystackSdk::VERSION}"
105
105
  conn.adapter Faraday.default_adapter
106
106
  end
107
+ redact_secret_key(connection)
107
108
  end
108
109
 
109
110
  private
110
111
 
112
+ # Faraday's default `inspect` prints the headers, and so the secret key. Replace it, on the
113
+ # connection and on its headers, so logging or `pp` of either never writes the key out.
114
+ def redact_secret_key(connection)
115
+ connection.define_singleton_method(:inspect) { "#<#{self.class.name} #{url_prefix}>" }
116
+ connection.headers.define_singleton_method(:inspect) do
117
+ to_h.merge("Authorization" => "[REDACTED]").inspect
118
+ end
119
+ connection
120
+ end
121
+
111
122
  def validate_connection_options!(timeout:, open_timeout:, max_retries:, retry_interval:)
112
123
  {timeout:, open_timeout:}.each do |name, value|
113
124
  raise ArgumentError, "#{name} must be a positive number" unless value.is_a?(Numeric) && value > 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaystackSdk
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paystack_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxwell Nana Forson (theLazyProgrammer)