ipgeolocation_sdk 2.0.0 → 2.0.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: 2fd714873e10e71a93363b06825cc1320144c23e929c072f102249fb0b8698f4
4
- data.tar.gz: 367f9e3f264fa09ae56f526067d109df98f89bf1abb6bd8209479ed2b548713f
3
+ metadata.gz: f60b9f97f28aba01519af07108337e42f2038fe5788a4da3bdd00b8000d397d1
4
+ data.tar.gz: 22de7283e595d32c77ff4380a1cd016fb04470e92fab36b625e9d7843d9b25c0
5
5
  SHA512:
6
- metadata.gz: 227b7fa05d1368be46c949a82b31cf2267f2360e12f6af496bf11552f1371c1eeea5f684cdd0dc4729598d33a32eeab230d403f882430a780ec8c4befd5abd2f
7
- data.tar.gz: cee24a95e0cb12bc1e063bcff1ea6f77d050108476ce767670d649aebc4b2f00b20b0253835e081b0574c4afefc6f250e635509e63164f7f0e85deb300b185f0
6
+ metadata.gz: aa0d558ed904b8f1664b88f4d4e5fb5160c2d1190adeb0371101cd81350e5a8e6d22bdd6c48548de210c5864a3d7aac13dd75c113e519d5bf7b6ed769ae3b410
7
+ data.tar.gz: ef5a76d5e37060f1e756cd2dcf3d92ac0c7a62ae16fe0cdd7b21656bf44f3e1ce44ddbef9855c1f1997efe9c087fc5f4a44864f5e600f133248ef1f2db63961a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.1
4
+
5
+ - Mask API keys in configuration serialization and client/config inspection.
6
+ - Enforce response-size limits while reading HTTP responses.
7
+ - Preserve UTF-8 across response chunks and replace malformed bytes without losing adjacent text.
8
+ - Correct Bundler test dependencies and add Ruby compatibility checks.
9
+
10
+ Existing public methods and Ruby 2.7+ support are unchanged.
11
+
3
12
  ## 2.0.0
4
13
 
5
14
  - Replaced the old generated v1 gem with the new Ruby SDK for the IPGeolocation.io IP Location API.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # IPGeolocation Ruby SDK
1
+ # IPGeolocation.io Ruby SDK
2
2
 
3
- Official Ruby SDK for the IPGeolocation.io IP Location API.
3
+ Official Ruby SDK for the IPGeolocation.io IP Geolocation API.
4
4
 
5
5
  Look up IPv4, IPv6, and domains with `/v3/ipgeo` and `/v3/ipgeo-bulk`. Get geolocation, company, ASN, timezone, network, hostname, abuse, user-agent, and security data from one API.
6
6
 
@@ -93,7 +93,7 @@ You can also pass `LookupIpGeolocationRequest` and `BulkLookupIpGeolocationReque
93
93
 
94
94
  ## Get Your API Key
95
95
 
96
- To use most SDK features, create or access your IPGeolocation account and copy an API key from your dashboard.
96
+ To use most SDK features, create or access your IPGeolocation.io account and copy an API key from your dashboard.
97
97
 
98
98
  1. Sign up: <https://app.ipgeolocation.io/signup>
99
99
  2. Verify your email if prompted
@@ -331,7 +331,7 @@ puts IpgeolocationSdk.to_pretty_json(response.data)
331
331
  puts IpgeolocationSdk.to_pretty_json(response.data, :full)
332
332
  ```
333
333
 
334
- Compact mode omits `nil` fields. Full mode keeps them.
334
+ Compact mode omits `nil` fields. Full mode keeps them. When serializing a client configuration, both modes replace its API key with `[REDACTED]`. The original key remains available through `config.api_key` and is used for authentication.
335
335
 
336
336
  ## Errors
337
337
 
@@ -28,6 +28,10 @@ module IpgeolocationSdk
28
28
 
29
29
  attr_reader :config
30
30
 
31
+ def inspect
32
+ "#<#{self.class} config=#{@config.inspect} closed=#{@closed}>"
33
+ end
34
+
31
35
  def lookup_ip_geolocation(request = nil)
32
36
  ensure_open
33
37
  typed_request = to_lookup_request(request)
@@ -26,6 +26,10 @@ module IpgeolocationSdk
26
26
  )
27
27
  end
28
28
 
29
+ def inspect
30
+ "#<#{self.class} #{to_h(mode: JsonOutputMode::FULL).inspect}>"
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def normalize_api_key(value)
@@ -164,6 +164,7 @@ module IpgeolocationSdk
164
164
  item = value.public_send(name)
165
165
  next if normalized_mode == JsonOutputMode::COMPACT && item.nil?
166
166
 
167
+ item = "[REDACTED]" if value.is_a?(IpGeolocationClientConfig) && name == :api_key && !item.nil?
167
168
  result[name.to_s] = to_plain_data(item, normalized_mode)
168
169
  end
169
170
  when Array
@@ -15,6 +15,16 @@ module IpgeolocationSdk
15
15
 
16
16
  class NetHttpTransport
17
17
  DEFAULT_MAX_RESPONSE_BODY_CHARS = 128 * 1024 * 1024
18
+ INCOMPLETE_UTF8 = /(?:
19
+ [\xC2-\xDF] |
20
+ \xE0[\xA0-\xBF]? |
21
+ [\xE1-\xEC\xEE-\xEF][\x80-\xBF]? |
22
+ \xED[\x80-\x9F]? |
23
+ \xF0(?:[\x90-\xBF][\x80-\xBF]?)? |
24
+ [\xF1-\xF3][\x80-\xBF]{0,2} |
25
+ \xF4(?:[\x80-\x8F][\x80-\xBF]?)?
26
+ )\z/nx.freeze
27
+ private_constant :INCOMPLETE_UTF8
18
28
 
19
29
  def initialize(max_response_body_chars: DEFAULT_MAX_RESPONSE_BODY_CHARS)
20
30
  raise ArgumentError, "max_response_body_chars must be a positive integer" unless max_response_body_chars.is_a?(Integer) && max_response_body_chars.positive?
@@ -29,9 +39,10 @@ module IpgeolocationSdk
29
39
  http.open_timeout = request.connect_timeout
30
40
  http.read_timeout = request.read_timeout
31
41
 
32
- response = http.request(build_net_http_request(uri, request))
33
- body = response.body
34
- body = body.nil? ? read_response_body(response) : normalize_response_text(body.to_s)
42
+ body = nil
43
+ response = http.request(build_net_http_request(uri, request)) do |stream|
44
+ body = read_response_body(stream)
45
+ end
35
46
 
36
47
  HttpResponseData.new(
37
48
  status_code: response.code.to_i,
@@ -78,22 +89,26 @@ module IpgeolocationSdk
78
89
  end
79
90
 
80
91
  def read_response_body(response)
81
- body_parts = []
82
-
83
- response.read_body do |chunk|
84
- body_parts << normalize_response_text(chunk.to_s)
92
+ body = String.new(encoding: Encoding::UTF_8)
93
+ pending = String.new(encoding: Encoding::BINARY)
94
+ size = 0
95
+ append = lambda do |text|
96
+ normalized = text.force_encoding(Encoding::UTF_8).scrub
97
+ size += normalized.length
98
+ if size > @max_response_body_chars
99
+ raise TransportError, "Response body exceeded max size of #{@max_response_body_chars} characters"
100
+ end
101
+ body << normalized
85
102
  end
86
103
 
87
- body_parts.join
88
- end
89
-
90
- def normalize_response_text(text)
91
- normalized = text.encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
92
- if normalized.length > @max_response_body_chars
93
- raise TransportError, "Response body exceeded max size of #{@max_response_body_chars} characters"
104
+ response.read_body do |chunk|
105
+ bytes = pending << chunk.to_s.b
106
+ pending = bytes.slice!(INCOMPLETE_UTF8) || String.new(encoding: Encoding::BINARY)
107
+ append.call(bytes)
94
108
  end
109
+ append.call(pending)
95
110
 
96
- normalized
111
+ body
97
112
  end
98
113
 
99
114
  def normalize_headers(headers)
@@ -1,3 +1,3 @@
1
1
  module IpgeolocationSdk
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipgeolocation_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - IPGeolocation.io
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-04-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -38,6 +37,20 @@ dependencies:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
39
  version: '3.13'
40
+ - !ruby/object:Gem::Dependency
41
+ name: bigdecimal
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '1.4'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '1.4'
41
54
  description: Ruby SDK for IPGeolocation.io single and bulk IP geolocation lookups
42
55
  with typed and raw responses.
43
56
  email:
@@ -70,7 +83,6 @@ metadata:
70
83
  bug_tracker_uri: https://github.com/IPGeolocation/ip-geolocation-ruby-sdk/issues
71
84
  changelog_uri: https://github.com/IPGeolocation/ip-geolocation-ruby-sdk/blob/main/CHANGELOG.md
72
85
  rubygems_mfa_required: 'true'
73
- post_install_message:
74
86
  rdoc_options: []
75
87
  require_paths:
76
88
  - lib
@@ -85,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
97
  - !ruby/object:Gem::Version
86
98
  version: '0'
87
99
  requirements: []
88
- rubygems_version: 3.4.20
89
- signing_key:
100
+ rubygems_version: 4.0.21
90
101
  specification_version: 4
91
102
  summary: Official Ruby SDK for the IPGeolocation.io IP Location API
92
103
  test_files: []