wreq 1.2.16-x86_64-linux → 1.3.0-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 +4 -4
- data/crates/wreq-util/CHANGELOG.md +2 -0
- data/lib/wreq_ruby/3.3/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/3.4/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/4.0/wreq_ruby.so +0 -0
- data/lib/wreq_ruby/emulate.rb +12 -0
- data/test/emulation_test.rb +76 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11cb302df09d662922bf651bce01a4546d9837a0a3fbf72e91082389a12d0086
|
|
4
|
+
data.tar.gz: 2347b0838438abc24735ecfca4e3208fa803f664c4a949a8a008811120d7ea90
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 773b652ce75c1eeb3fb68c337b3bf742fae06e6c04670dee6f21a3cbeff87cfb3f458ba8086008786eece70977ab64b6ad7a132b08385f6d936279ff44f0c15b
|
|
7
|
+
data.tar.gz: b00383d4fe2b8bf1fa688117fbba851256bd1a1d227aa03f9c8ce793a918cbb5261d38f588f9ea55b4c64e5e2da318143a298322c4d7d274131958d49910f2a6
|
|
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
17
17
|
|
|
18
18
|
### Fixed
|
|
19
19
|
|
|
20
|
+
- Match Trust Anchor ID ordering by Chrome version: randomized per native configuration for 152/153, and sorted by raw ID bytes for 154.
|
|
21
|
+
|
|
20
22
|
- *(emulate)* Fix Firefox 150 and 151 cipher suite lists.
|
|
21
23
|
|
|
22
24
|
## [3.0.0-rc.14](https://github.com/0x676e67/wreq-util/compare/v3.0.0-rc.13...v3.0.0-rc.14) - 2026-07-04
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/wreq_ruby/emulate.rb
CHANGED
|
@@ -264,6 +264,14 @@ module Wreq
|
|
|
264
264
|
# for HTTP/2 and automatic default headers. The actual implementation is
|
|
265
265
|
# provided by Rust.
|
|
266
266
|
#
|
|
267
|
+
# Construction generates the native configuration once. For Chrome 152/153,
|
|
268
|
+
# the TLS trust_anchors extension's ID order is randomized at construction;
|
|
269
|
+
# Chrome 154 sorts those IDs by their raw bytes instead. Reusing this object
|
|
270
|
+
# across clients or requests retains that order. Creating a new object generates
|
|
271
|
+
# a new configuration, including a fresh shuffle for Chrome 152/153.
|
|
272
|
+
# This does not freeze other per-handshake randomness or force a new handshake
|
|
273
|
+
# when a request reuses an existing connection.
|
|
274
|
+
#
|
|
267
275
|
# `profile:` defaults to the library's default profile when omitted.
|
|
268
276
|
# `platform:` defaults to the library's default platform when omitted.
|
|
269
277
|
#
|
|
@@ -289,6 +297,10 @@ module Wreq
|
|
|
289
297
|
# Native fields and methods are set by the extension.
|
|
290
298
|
# This stub is for documentation only.
|
|
291
299
|
unless singleton_methods(false).include?(:new)
|
|
300
|
+
# Generates a reusable native configuration. Chrome 152/153 Trust Anchor ID
|
|
301
|
+
# order is chosen here and retained when this object is reused; Chrome 154
|
|
302
|
+
# uses raw-byte sorted order. See {Emulation} for connection semantics.
|
|
303
|
+
#
|
|
292
304
|
# @param profile [Wreq::Profile, nil] Fingerprint profile to emulate
|
|
293
305
|
# @param platform [Wreq::Platform, nil] Operating system platform to emulate
|
|
294
306
|
# @param http2 [Boolean, nil] Whether HTTP/2 emulation is enabled; defaults
|
data/test/emulation_test.rb
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "test_helper"
|
|
4
|
+
require "socket"
|
|
5
|
+
require "stringio"
|
|
6
|
+
require "timeout"
|
|
4
7
|
|
|
5
8
|
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].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
|
+
|
|
6
26
|
def test_all_emulation_device_constants_are_non_nil
|
|
7
27
|
Wreq::Profile.constants.each do |name|
|
|
8
28
|
const = Wreq::Profile.const_get(name)
|
|
@@ -37,4 +57,60 @@ class EmulationTest < Minitest::Test
|
|
|
37
57
|
"#{name} should be Platform, got #{const.inspect}"
|
|
38
58
|
end
|
|
39
59
|
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
# Each listener forces a new connection. Stop after ClientHello so this test
|
|
64
|
+
# inspects the extension bytes without depending on certificates or the network.
|
|
65
|
+
def capture_trust_anchors
|
|
66
|
+
server = TCPServer.new("127.0.0.1", 0)
|
|
67
|
+
thread = Thread.new do
|
|
68
|
+
socket = nil
|
|
69
|
+
Timeout.timeout(5) do
|
|
70
|
+
socket = server.accept
|
|
71
|
+
handshake = +"".b
|
|
72
|
+
loop do
|
|
73
|
+
header = read_tls_bytes(socket, 5)
|
|
74
|
+
raise "expected a TLS handshake record" unless header.getbyte(0) == 22
|
|
75
|
+
handshake << read_tls_bytes(socket, header.byteslice(3, 2).unpack1("n"))
|
|
76
|
+
next if handshake.bytesize < 4
|
|
77
|
+
length = handshake.byteslice(1, 3).bytes.reduce(0) { |n, byte| (n << 8) | byte }
|
|
78
|
+
break if handshake.bytesize >= length + 4
|
|
79
|
+
end
|
|
80
|
+
trust_anchors_from_client_hello(handshake)
|
|
81
|
+
end
|
|
82
|
+
ensure
|
|
83
|
+
socket&.close
|
|
84
|
+
end
|
|
85
|
+
thread.report_on_exception = false
|
|
86
|
+
|
|
87
|
+
assert_raises(Wreq::ConnectionError) { yield "https://127.0.0.1:#{server.addr[1]}/" }
|
|
88
|
+
thread.value
|
|
89
|
+
ensure
|
|
90
|
+
server&.close
|
|
91
|
+
thread&.kill if thread&.alive?
|
|
92
|
+
thread&.join
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def read_tls_bytes(io, length)
|
|
96
|
+
bytes = io.read(length)
|
|
97
|
+
raise EOFError, "truncated ClientHello" unless bytes&.bytesize == length
|
|
98
|
+
bytes
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def trust_anchors_from_client_hello(handshake)
|
|
102
|
+
io = StringIO.new(handshake)
|
|
103
|
+
raise "expected ClientHello" unless read_tls_bytes(io, 1).unpack1("C") == 1
|
|
104
|
+
read_tls_bytes(io, 3 + 2 + 32) # Handshake length, legacy version and random.
|
|
105
|
+
read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Session ID.
|
|
106
|
+
read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")) # Cipher suites.
|
|
107
|
+
read_tls_bytes(io, read_tls_bytes(io, 1).unpack1("C")) # Compression methods.
|
|
108
|
+
extensions = StringIO.new(read_tls_bytes(io, read_tls_bytes(io, 2).unpack1("n")))
|
|
109
|
+
until extensions.eof?
|
|
110
|
+
type, length = read_tls_bytes(extensions, 4).unpack("nn")
|
|
111
|
+
data = read_tls_bytes(extensions, length)
|
|
112
|
+
return data if type == 51764
|
|
113
|
+
end
|
|
114
|
+
raise "missing trust_anchors extension"
|
|
115
|
+
end
|
|
40
116
|
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.
|
|
4
|
+
version: 1.3.0
|
|
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-09-
|
|
11
|
+
date: 2026-09-24 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
|