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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +4 -4
- data/lib/ipgeolocation_sdk/client.rb +4 -0
- data/lib/ipgeolocation_sdk/client_config.rb +4 -0
- data/lib/ipgeolocation_sdk/serde.rb +1 -0
- data/lib/ipgeolocation_sdk/transport.rb +30 -15
- data/lib/ipgeolocation_sdk/version.rb +1 -1
- metadata +17 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f60b9f97f28aba01519af07108337e42f2038fe5788a4da3bdd00b8000d397d1
|
|
4
|
+
data.tar.gz: 22de7283e595d32c77ff4380a1cd016fb04470e92fab36b625e9d7843d9b25c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
|
@@ -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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
111
|
+
body
|
|
97
112
|
end
|
|
98
113
|
|
|
99
114
|
def normalize_headers(headers)
|
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.
|
|
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:
|
|
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:
|
|
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: []
|