wreq 1.3.2.2-x86_64-linux → 1.3.2.3-x86_64-linux

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: ba25cc7ca82ec6e3d3cdf06868d0489e0b67c0c05fc4e1c7789cc2e634c2a941
4
- data.tar.gz: 0b9f3b0000415e9033ef8fe90552afc7b107eb19fcce951d57d72e545ed000a4
3
+ metadata.gz: 3774c37ca88d27e117ef354ab1aff26d5161a51c9d8dcd8792f205e806076517
4
+ data.tar.gz: dcb2bbbf6565d6c5290451dd514c6f3be764ae226a3f9572077481908bfd21cc
5
5
  SHA512:
6
- metadata.gz: 54f330da229ec49badf943ac2cf8217b66115b2fa4a9ebb9617f8eb162fc84ff124bdf63b0784c87c2f1b6cf112cc92f5ccc0f217ad48b477100ce7ed9cea1e1
7
- data.tar.gz: a64f6733932b627bb2bfb8436bbb75dd2e64cea75233cd64c8dca25544a70dfd8896087329107ba3984c940fa070d5320134033e9779884dbb79035a7fcbcd20
6
+ metadata.gz: 587009f9e9057d9b5a46954f55aea88cfaf3a2d93a29662cd81f4c0a621132103608a17cdfdeea954a42692c7b79167f4b16166b009499a9a034e4068b755fbf
7
+ data.tar.gz: 0cf0bd9c15a6e8cb5d32047bfc6fcd288a05df88a51628e7f80e980178c725bb4b20a8dfd32be021ac5a9f590b4bae0877ad569a7c8e25479ddc76bf14ef1fb1
data/README.md CHANGED
@@ -89,14 +89,21 @@ Most browser device models share identical TLS and HTTP/2 configurations, differ
89
89
  - <details>
90
90
  <summary>Available browser emulations</summary>
91
91
 
92
+ Edge 149–158 provide request-header presets for Windows, macOS, Linux, Android, and iOS.
93
+ Firefox 153–160 provide Android and iPhone presets for `User-Agent` and `Accept-Language`.
94
+ Both use the same TLS and HTTP/2 settings as the corresponding desktop Firefox preset.
95
+ Opera 116–140 provide desktop request-header presets for Windows, macOS, and Linux.
96
+
92
97
  | **Browser** | **Versions** |
93
98
  | ----------- | ------------ |
94
99
  | **Chrome** | `Chrome100`, `Chrome101`, `Chrome104`, `Chrome105`, `Chrome106`, `Chrome107`, `Chrome108`, `Chrome109`, `Chrome110`, `Chrome114`, `Chrome116`, `Chrome117`, `Chrome118`, `Chrome119`, `Chrome120`, `Chrome123`, `Chrome124`, `Chrome126`, `Chrome127`, `Chrome128`, `Chrome129`, `Chrome130`, `Chrome131`, `Chrome132`, `Chrome133`, `Chrome134`, `Chrome135`, `Chrome136`, `Chrome137`, `Chrome138`, `Chrome139`, `Chrome140`, `Chrome141`, `Chrome142`, `Chrome143`, `Chrome144`, `Chrome145`, `Chrome146`, `Chrome147`, `Chrome148`, `Chrome149`, `Chrome150`, `Chrome151`, `Chrome152`, `Chrome153`, `Chrome154`, `Chrome155`, `Chrome156`, `Chrome157`, `Chrome158` |
95
- | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`, `Edge135`, `Edge136`, `Edge137`, `Edge138`, `Edge139`, `Edge140`, `Edge141`, `Edge142`, `Edge143`, `Edge144`, `Edge145`, `Edge146`, `Edge147`, `Edge148` |
96
- | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152` |
100
+ | **Edge** | `Edge101`, `Edge122`, `Edge127`, `Edge131`, `Edge134`–`Edge158` |
101
+ | **Firefox** | `Firefox109`, `Firefox117`, `Firefox128`, `Firefox133`, `Firefox135`, `FirefoxPrivate135`, `FirefoxAndroid135`, `Firefox136`, `FirefoxPrivate136`, `Firefox139`, `Firefox142`, `Firefox143`, `Firefox144`, `Firefox145`, `Firefox146`, `Firefox147`, `Firefox148`, `Firefox149`, `Firefox150`, `Firefox151`, `Firefox152`, `Firefox153`–`Firefox160` |
97
102
  | **Safari** | `Safari15_3`, `Safari15_5`, `Safari15_6_1`, `Safari16`, `Safari16_5`, `Safari17_0`, `Safari17_2_1`, `Safari17_4_1`, `Safari17_5`, `Safari17_6`, `Safari18`, `Safari18_2`, `Safari18_3`, `Safari18_3_1`, `Safari18_5`, `Safari26`, `Safari26_1`, `Safari26_2`, `SafariIos16_5`, `SafariIos17_2`, `SafariIos17_4_1`, `SafariIos18_1_1`, `SafariIos26`, `SafariIos26_2`, `SafariIPad18`, `SafariIPad26`, `SafariIpad26_2` |
98
- | **OkHttp** | `Opera116`, `Opera117`, `Opera118`, `Opera119`, `Opera120`, `Opera121`, `Opera122`, `Opera123`, `Opera124`, `Opera125`, `Opera126`, `Opera127`, `Opera128`, `Opera129`, `Opera130` |
99
- | **Opera** | `Opera116`, `Opera117`, `Opera118`, `Opera119` |
103
+ | **OkHttp** | `OkHttp3_9`, `OkHttp3_11`, `OkHttp3_13`, `OkHttp3_14`, `OkHttp4_9`, `OkHttp4_10`, `OkHttp4_12`, `OkHttp5` |
104
+ | **Opera** | `Opera116`–`Opera140` |
105
+
106
+ Opera 132–140 use the corresponding Chromium desktop TLS and HTTP/2 defaults with Opera-branded request headers.
100
107
 
101
108
  </details>
102
109
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.2.2
1
+ 1.3.2.3
Binary file
Binary file
Binary file
@@ -90,6 +90,16 @@ module Wreq
90
90
  Edge146 = nil
91
91
  Edge147 = nil
92
92
  Edge148 = nil
93
+ Edge149 = nil
94
+ Edge150 = nil
95
+ Edge151 = nil
96
+ Edge152 = nil
97
+ Edge153 = nil
98
+ Edge154 = nil
99
+ Edge155 = nil
100
+ Edge156 = nil
101
+ Edge157 = nil
102
+ Edge158 = nil
93
103
 
94
104
  Firefox109 = nil
95
105
  Firefox117 = nil
@@ -112,6 +122,14 @@ module Wreq
112
122
  Firefox150 = nil
113
123
  Firefox151 = nil
114
124
  Firefox152 = nil
125
+ Firefox153 = nil
126
+ Firefox154 = nil
127
+ Firefox155 = nil
128
+ Firefox156 = nil
129
+ Firefox157 = nil
130
+ Firefox158 = nil
131
+ Firefox159 = nil
132
+ Firefox160 = nil
115
133
 
116
134
  SafariIos17_2 = nil
117
135
  SafariIos17_4_1 = nil
@@ -168,6 +186,15 @@ module Wreq
168
186
  Opera129 = nil
169
187
  Opera130 = nil
170
188
  Opera131 = nil
189
+ Opera132 = nil
190
+ Opera133 = nil
191
+ Opera134 = nil
192
+ Opera135 = nil
193
+ Opera136 = nil
194
+ Opera137 = nil
195
+ Opera138 = nil
196
+ Opera139 = nil
197
+ Opera140 = nil
171
198
  end
172
199
 
173
200
  unless method_defined?(:to_s)
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "socket"
5
+ require "stringio"
6
+ require "timeout"
7
+
8
+ class EmulationClientHelloTest < Minitest::Test
9
+ SUPPORTED_GROUPS = 10
10
+ SIGNATURE_ALGORITHMS = 13
11
+ KEY_SHARE = 51
12
+ TRUST_ANCHOR_IDS = 51_764
13
+ ENCRYPTED_CLIENT_HELLO = 65_037
14
+
15
+ def test_reusing_chrome_emulation_preserves_trust_anchors
16
+ [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156, Wreq::Profile::Chrome157].each do |profile|
17
+ emulation = Wreq::Emulation.new(profile: profile)
18
+ client = Wreq::Client.new(emulation: emulation, no_proxy: true)
19
+ _, extensions = capture_client_hello { |url| client.get(url, timeout: 5) }
20
+ expected = extensions.fetch(TRUST_ANCHOR_IDS)
21
+ refute_empty expected, profile.to_s
22
+
23
+ request_client = Wreq::Client.new(no_proxy: true)
24
+ 2.times do
25
+ _, actual_extensions = capture_client_hello do |url|
26
+ request_client.get(url, emulation: emulation, timeout: 5)
27
+ end
28
+ assert_equal expected, actual_extensions.fetch(TRUST_ANCHOR_IDS), "#{profile}: reusing an object must retain its configuration"
29
+ end
30
+ end
31
+ end
32
+
33
+ def test_edge158_sends_signature_grease_without_trust_anchors
34
+ client = Wreq::Client.new(emulation: Wreq::Emulation.new(profile: Wreq::Profile::Edge158), no_proxy: true)
35
+ _, extensions = capture_client_hello { |url| client.get(url, timeout: 5) }
36
+
37
+ _, grease, *signatures = extensions.fetch(SIGNATURE_ALGORITHMS).unpack("n*")
38
+ assert_equal 0x0a0a, grease & 0x0f0f
39
+ assert_equal grease >> 8, grease & 0xff
40
+ assert_equal [0x0904, 0x0905, 0x0906], signatures.first(3) # ML-DSA
41
+ refute extensions.key?(TRUST_ANCHOR_IDS)
42
+ end
43
+
44
+ def test_firefox_client_hello_matches_version
45
+ suites_153 = [
46
+ 0x1301, 0x1303, 0x1302,
47
+ 0xc02b, 0xc02f, 0xcca9, 0xcca8, 0xc02c, 0xc030, 0xc00a, 0xc013, 0xc014, 0x009c, 0x009d, 0x002f, 0x0035
48
+ ]
49
+ # Firefox 154 disabled TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA.
50
+ suites_154 = suites_153.reject { |suite| suite == 0xc00a }
51
+
52
+ [
53
+ [Wreq::Profile::Firefox153, suites_153, 15, [4588, 29, 23, 24, 25, 256, 257]],
54
+ [Wreq::Profile::Firefox154, suites_154, 15, [4588, 29, 23, 24, 25, 256, 257]],
55
+ [Wreq::Profile::Firefox155, suites_154, 16, [4588, 29, 23, 24, 25, 256, 257]],
56
+ [Wreq::Profile::Firefox156, suites_154, 16, [4588, 29, 23, 24, 25]]
57
+ ].each do |profile, expected_suites, padding_remainder, groups|
58
+ client = Wreq::Client.new(emulation: Wreq::Emulation.new(profile: profile), no_proxy: true)
59
+ suites, extensions = capture_client_hello { |url| client.get(url, timeout: 5) }
60
+ assert_equal [4588, 29, 23], key_share_groups(extensions.fetch(KEY_SHARE)), "#{profile}: key share groups"
61
+ assert_equal expected_suites, suites, "#{profile}: cipher suites"
62
+
63
+ assert_equal padding_remainder, ech_payload_size(extensions.fetch(ENCRYPTED_CLIENT_HELLO)) % 32, "#{profile}: ECH GREASE ciphertext"
64
+ assert_equal groups, extensions.fetch(SUPPORTED_GROUPS).unpack("n*").drop(1), "#{profile}: supported groups"
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ # Each listener forces a new connection. Stop after ClientHello so this test
71
+ # inspects the wire bytes without depending on certificates or an external service.
72
+ def capture_client_hello
73
+ server = TCPServer.new("127.0.0.1", 0)
74
+ thread = Thread.new do
75
+ socket = nil
76
+ Timeout.timeout(5) do
77
+ socket = server.accept
78
+ handshake = +"".b
79
+ loop do
80
+ header = read_tls_bytes(socket, 5)
81
+ raise "expected a TLS handshake record" unless header.getbyte(0) == 22
82
+ handshake << read_tls_bytes(socket, header.byteslice(3, 2).unpack1("n"))
83
+ next if handshake.bytesize < 4
84
+ length = handshake.byteslice(1, 3).bytes.reduce(0) { |n, byte| (n << 8) | byte }
85
+ break if handshake.bytesize >= length + 4
86
+ end
87
+ parse_client_hello(handshake)
88
+ end
89
+ ensure
90
+ socket&.close
91
+ end
92
+ thread.report_on_exception = false
93
+
94
+ assert_raises(Wreq::ConnectionError) { yield "https://127.0.0.1:#{server.addr[1]}/" }
95
+ thread.value
96
+ ensure
97
+ server&.close
98
+ thread&.kill if thread&.alive?
99
+ thread&.join
100
+ end
101
+
102
+ def read_tls_bytes(io, length)
103
+ bytes = io.read(length)
104
+ raise EOFError, "truncated ClientHello" unless bytes&.bytesize == length
105
+ bytes
106
+ end
107
+
108
+ def parse_client_hello(handshake)
109
+ io = StringIO.new(handshake)
110
+ raise "expected ClientHello" unless read_tls_bytes(io, 1).unpack1("C") == 1
111
+ read_tls_bytes(io, 3 + 2 + 32) # Handshake length, legacy version and random.
112
+ read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Session ID.
113
+ suites = read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")).unpack("n*")
114
+ read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Compression methods.
115
+ extensions = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
116
+ parsed = {}
117
+ until extensions.eof?
118
+ type, length = read_tls_bytes(extensions, 4).unpack("nn")
119
+ parsed[type] = read_tls_bytes(extensions, length)
120
+ end
121
+ [suites, parsed]
122
+ end
123
+
124
+ def ech_payload_size(extension)
125
+ io = StringIO.new(extension)
126
+ read_tls_bytes(io, 6) # Outer tag, HPKE suite and config ID.
127
+ read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")) # Encapsulated key.
128
+ read_tls_bytes(io, 2).unpack1("n")
129
+ end
130
+
131
+ def key_share_groups(extension)
132
+ io = StringIO.new(extension)
133
+ entries = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
134
+ groups = []
135
+ until entries.eof?
136
+ group, length = read_tls_bytes(entries, 4).unpack("nn")
137
+ read_tls_bytes(entries, length) # Key exchange bytes.
138
+ groups << group
139
+ end
140
+ groups
141
+ end
142
+ end
@@ -1,120 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "test_helper"
4
- require "socket"
5
- require "stringio"
6
- require "timeout"
7
4
 
8
5
  class EmulationTest < Minitest::Test
9
- def test_reused_emulation_retains_trust_anchors_across_clients_and_requests
10
- [Wreq::Profile::Chrome152, Wreq::Profile::Chrome153, Wreq::Profile::Chrome154, Wreq::Profile::Chrome155, Wreq::Profile::Chrome156, Wreq::Profile::Chrome157].each do |profile|
11
- emulation = Wreq::Emulation.new(profile: profile)
12
- client = Wreq::Client.new(emulation: emulation, no_proxy: true)
13
- expected = capture_trust_anchors { |url| client.get(url, timeout: 5) }
14
- refute_empty expected, profile.to_s
15
-
16
- request_client = Wreq::Client.new(no_proxy: true)
17
- 2.times do
18
- actual = capture_trust_anchors do |url|
19
- request_client.get(url, emulation: emulation, timeout: 5)
20
- end
21
- assert_equal expected, actual, "#{profile}: reusing an object must retain its configuration"
22
- end
23
- end
24
- end
25
-
26
- def test_all_emulation_device_constants_are_non_nil
27
- Wreq::Profile.constants.each do |name|
28
- const = Wreq::Profile.const_get(name)
29
- assert_instance_of Wreq::Profile, const,
30
- "#{name} should be Profile, got #{const.inspect}"
31
- end
32
- end
33
-
34
- def test_chrome151_profile_is_available
35
- profile = Wreq::Profile::Chrome151
36
-
37
- assert_equal "Chrome151", profile.to_s
38
- assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile)
39
- end
40
-
41
- def test_new_browser_profiles_are_available
42
- {
43
- Wreq::Profile::Chrome152 => "Chrome152",
44
- Wreq::Profile::Chrome153 => "Chrome153",
45
- Wreq::Profile::Chrome154 => "Chrome154",
46
- Wreq::Profile::Chrome155 => "Chrome155",
47
- Wreq::Profile::Chrome156 => "Chrome156",
48
- Wreq::Profile::Chrome157 => "Chrome157",
49
- Wreq::Profile::Chrome158 => "Chrome158",
50
- Wreq::Profile::Firefox152 => "Firefox152"
51
- }.each do |profile, name|
52
- assert_equal name, profile.to_s
53
- assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile)
6
+ def test_expected_browser_profiles_are_registered
7
+ versions_by_browser = {
8
+ "Chrome" => 151..158,
9
+ "Edge" => [101, 122, 127, 131, *(134..158)],
10
+ "Firefox" => [109, 117, 128, 133, 135, 136, 139, *(142..160)],
11
+ "Opera" => 116..140
12
+ }
13
+ expected = versions_by_browser.flat_map do |browser, versions|
14
+ versions.map { |version| "#{browser}#{version}" }
54
15
  end
55
- end
16
+ expected.concat(%w[FirefoxPrivate135 FirefoxAndroid135 FirefoxPrivate136])
56
17
 
57
- def test_all_emulation_os_constants_are_non_nil
58
- Wreq::Platform.constants.each do |name|
59
- const = Wreq::Platform.const_get(name)
60
- assert_instance_of Wreq::Platform, const,
61
- "#{name} should be Platform, got #{const.inspect}"
62
- end
18
+ registered = Wreq::Profile.constants(false).map(&:to_s)
19
+ assert_empty expected - registered, "missing browser profiles"
63
20
  end
64
21
 
65
- private
66
-
67
- # Each listener forces a new connection. Stop after ClientHello so this test
68
- # inspects the extension bytes without depending on certificates or the network.
69
- def capture_trust_anchors
70
- server = TCPServer.new("127.0.0.1", 0)
71
- thread = Thread.new do
72
- socket = nil
73
- Timeout.timeout(5) do
74
- socket = server.accept
75
- handshake = +"".b
76
- loop do
77
- header = read_tls_bytes(socket, 5)
78
- raise "expected a TLS handshake record" unless header.getbyte(0) == 22
79
- handshake << read_tls_bytes(socket, header.byteslice(3, 2).unpack1("n"))
80
- next if handshake.bytesize < 4
81
- length = handshake.byteslice(1, 3).bytes.reduce(0) { |n, byte| (n << 8) | byte }
82
- break if handshake.bytesize >= length + 4
83
- end
84
- trust_anchors_from_client_hello(handshake)
85
- end
86
- ensure
87
- socket&.close
22
+ def test_registered_profiles_have_matching_names_and_build_emulation
23
+ Wreq::Profile.constants(false).each do |name|
24
+ profile = Wreq::Profile.const_get(name, false)
25
+ assert_instance_of Wreq::Profile, profile, name.to_s
26
+ assert_equal name.to_s, profile.to_s
27
+ assert_instance_of Wreq::Emulation, Wreq::Emulation.new(profile: profile), name.to_s
88
28
  end
89
- thread.report_on_exception = false
90
-
91
- assert_raises(Wreq::ConnectionError) { yield "https://127.0.0.1:#{server.addr[1]}/" }
92
- thread.value
93
- ensure
94
- server&.close
95
- thread&.kill if thread&.alive?
96
- thread&.join
97
- end
98
-
99
- def read_tls_bytes(io, length)
100
- bytes = io.read(length)
101
- raise EOFError, "truncated ClientHello" unless bytes&.bytesize == length
102
- bytes
103
29
  end
104
30
 
105
- def trust_anchors_from_client_hello(handshake)
106
- io = StringIO.new(handshake)
107
- raise "expected ClientHello" unless read_tls_bytes(io, 1).unpack1("C") == 1
108
- read_tls_bytes(io, 3 + 2 + 32) # Handshake length, legacy version and random.
109
- read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Session ID.
110
- read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")) # Cipher suites.
111
- read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Compression methods.
112
- extensions = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
113
- until extensions.eof?
114
- type, length = read_tls_bytes(extensions, 4).unpack("nn")
115
- data = read_tls_bytes(extensions, length)
116
- return data if type == 51764
31
+ def test_registered_platforms_are_platform_values
32
+ Wreq::Platform.constants(false).each do |name|
33
+ assert_instance_of Wreq::Platform, Wreq::Platform.const_get(name, false), name.to_s
117
34
  end
118
- raise "missing trust_anchors extension"
119
35
  end
120
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wreq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2.2
4
+ version: 1.3.2.3
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - SearchApi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-20 00:00:00.000000000 Z
11
+ date: 2026-11-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An easy and powerful Ruby HTTP client with advanced browser fingerprinting
14
14
  that accurately emulates Chrome, Edge, Firefox, Safari, Opera, and OkHttp with precise
@@ -71,6 +71,7 @@ files:
71
71
  - test/client_cookie_test.rb
72
72
  - test/client_test.rb
73
73
  - test/cookie_test.rb
74
+ - test/emulation_client_hello_test.rb
74
75
  - test/emulation_test.rb
75
76
  - test/error_handling_test.rb
76
77
  - test/fork_test.rb