wreq 1.3.2.4 → 1.3.3

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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +470 -50
  3. data/Cargo.toml +19 -16
  4. data/README.md +5 -12
  5. data/Rakefile +3 -9
  6. data/crates/wreq-util/Cargo.toml +1 -1
  7. data/crates/wreq-util/README.md +4 -2
  8. data/crates/wreq-util/examples/emulate.rs +7 -3
  9. data/crates/wreq-util/examples/tower_delay.rs +4 -4
  10. data/crates/wreq-util/src/emulate/macros.rs +197 -32
  11. data/crates/wreq-util/src/emulate/profile/chrome/header.rs +116 -0
  12. data/crates/wreq-util/src/emulate/profile/chrome/http2.rs +65 -0
  13. data/crates/wreq-util/src/emulate/profile/chrome/tls.rs +268 -0
  14. data/crates/wreq-util/src/emulate/profile/chrome.rs +2269 -0
  15. data/crates/wreq-util/src/emulate/profile/firefox/header.rs +54 -48
  16. data/crates/wreq-util/src/emulate/profile/firefox/http2.rs +102 -92
  17. data/crates/wreq-util/src/emulate/profile/firefox/tls.rs +146 -155
  18. data/crates/wreq-util/src/emulate/profile/firefox.rs +440 -312
  19. data/crates/wreq-util/src/emulate/profile/okhttp.rs +2 -3
  20. data/crates/wreq-util/src/emulate/profile/opera/header.rs +29 -0
  21. data/crates/wreq-util/src/emulate/profile/opera/http2.rs +50 -0
  22. data/crates/wreq-util/src/emulate/profile/opera/tls.rs +103 -0
  23. data/crates/wreq-util/src/emulate/profile/opera.rs +299 -0
  24. data/crates/wreq-util/src/emulate/profile.rs +10 -10
  25. data/crates/wreq-util/src/emulate.rs +1 -34
  26. data/crates/wreq-util/src/tower/delay/layer.rs +5 -5
  27. data/crates/wreq-util/src/tower/delay.rs +4 -4
  28. data/crates/wreq-util/tests/client.rs +50 -187
  29. data/crates/wreq-util/tests/emulate_chrome.rs +0 -17
  30. data/crates/wreq-util/tests/emulate_firefox.rs +26 -36
  31. data/crates/wreq-util/tests/emulate_opera.rs +0 -24
  32. data/crates/wreq-util/tests/support/mod.rs +1 -1
  33. data/lib/wreq_ruby/client.rb +27 -13
  34. data/lib/wreq_ruby/emulate.rb +3 -28
  35. data/lib/wreq_ruby/http.rb +9 -2
  36. data/src/client/body/json.rs +1 -2
  37. data/src/client/resp.rs +1 -1
  38. data/src/client.rs +8 -4
  39. data/src/emulate.rs +5 -28
  40. data/src/error.rs +23 -3
  41. data/src/lib.rs +3 -2
  42. data/src/options.rs +17 -19
  43. data/{crates/serde-magnus/src → src/serde}/de/array_deserializer.rs +2 -2
  44. data/{crates/serde-magnus/src → src/serde}/de/array_enumerator.rs +1 -1
  45. data/{crates/serde-magnus/src → src/serde}/de/deserializer.rs +31 -25
  46. data/{crates/serde-magnus/src → src/serde}/de/enum_deserializer.rs +3 -3
  47. data/{crates/serde-magnus/src → src/serde}/de/hash_deserializer.rs +2 -2
  48. data/{crates/serde-magnus/src → src/serde}/de/number_deserializer.rs +2 -2
  49. data/{crates/serde-magnus/src → src/serde}/de/variant_deserializer.rs +20 -11
  50. data/src/serde/de.rs +33 -0
  51. data/src/serde/error.rs +146 -0
  52. data/src/serde/ser/enums.rs +14 -0
  53. data/{crates/serde-magnus/src → src/serde}/ser/map_serializer.rs +2 -2
  54. data/src/serde/ser/seq_serializer.rs +71 -0
  55. data/src/serde/ser/serializer.rs +194 -0
  56. data/{crates/serde-magnus/src → src/serde}/ser/struct_serializer.rs +4 -4
  57. data/src/serde/ser/struct_variant_serializer.rs +44 -0
  58. data/src/serde/ser/tuple_variant_serializer.rs +41 -0
  59. data/src/serde/ser.rs +18 -0
  60. data/{crates/serde-magnus/src → src/serde}/tests.rs +68 -19
  61. data/src/serde.rs +202 -0
  62. data/test/emulation_test.rb +104 -21
  63. data/test/option_validation_test.rb +13 -4
  64. data/wreq.gemspec +15 -3
  65. metadata +29 -35
  66. data/VERSION +0 -1
  67. data/crates/README.md +0 -6
  68. data/crates/serde-magnus/Cargo.toml +0 -29
  69. data/crates/serde-magnus/LICENSE +0 -19
  70. data/crates/serde-magnus/README.md +0 -147
  71. data/crates/serde-magnus/src/de/mod.rs +0 -554
  72. data/crates/serde-magnus/src/error.rs +0 -84
  73. data/crates/serde-magnus/src/lib.rs +0 -137
  74. data/crates/serde-magnus/src/options.rs +0 -151
  75. data/crates/serde-magnus/src/ser/enums.rs +0 -11
  76. data/crates/serde-magnus/src/ser/mod.rs +0 -428
  77. data/crates/serde-magnus/src/ser/seq_serializer.rs +0 -68
  78. data/crates/serde-magnus/src/ser/serializer.rs +0 -220
  79. data/crates/serde-magnus/src/ser/struct_variant_serializer.rs +0 -45
  80. data/crates/serde-magnus/src/ser/tuple_variant_serializer.rs +0 -38
  81. data/crates/wreq-util/src/emulate/profile/chromium/chrome.rs +0 -731
  82. data/crates/wreq-util/src/emulate/profile/chromium/edge.rs +0 -418
  83. data/crates/wreq-util/src/emulate/profile/chromium/header.rs +0 -74
  84. data/crates/wreq-util/src/emulate/profile/chromium/http2.rs +0 -59
  85. data/crates/wreq-util/src/emulate/profile/chromium/opera.rs +0 -312
  86. data/crates/wreq-util/src/emulate/profile/chromium/tls.rs +0 -310
  87. data/crates/wreq-util/src/emulate/profile/chromium.rs +0 -9
  88. data/test/emulation_client_hello_test.rb +0 -142
@@ -1,312 +0,0 @@
1
- use super::super::{Emulation, HeaderMap, Platform, build_standard_emulation};
2
- use super::{header, http2, tls};
3
-
4
- chromium_profile!(
5
- opera116,
6
- tls: tls::Preset::ResumptionWithMlkem,
7
- http2: http2::Preset::NoPush,
8
- headers: header::Preset::ZstdWithPriority,
9
- brands: r#""Opera";v="116", "Chromium";v="131", "Not_A Brand";v="24""#,
10
- [
11
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0"),
12
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0"),
13
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/116.0.0.0")
14
- ]
15
- );
16
-
17
- chromium_profile!(
18
- opera117,
19
- transport: opera116::build_emulation,
20
- headers: header::Preset::ZstdWithPriority,
21
- brands: r#""Not A(Brand";v="8", "Chromium";v="132", "Opera";v="117""#,
22
- [
23
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0"),
24
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0"),
25
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 OPR/117.0.0.0")
26
- ]
27
- );
28
-
29
- chromium_profile!(
30
- opera118,
31
- transport: opera116::build_emulation,
32
- headers: header::Preset::ZstdWithPriority,
33
- brands: r#""Not(A:Brand";v="99", "Opera";v="118", "Chromium";v="133""#,
34
- [
35
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0"),
36
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0"),
37
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 OPR/118.0.0.0")
38
- ]
39
- );
40
-
41
- chromium_profile!(
42
- opera119,
43
- transport: opera116::build_emulation,
44
- headers: header::Preset::ZstdWithPriority,
45
- brands: r#""Chromium";v="134", "Not:A-Brand";v="24", "Opera";v="119""#,
46
- [
47
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0"),
48
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0"),
49
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 OPR/119.0.0.0")
50
- ]
51
- );
52
-
53
- chromium_profile!(
54
- opera120,
55
- transport: opera116::build_emulation,
56
- headers: header::Preset::ZstdWithPriority,
57
- brands: r#""Chromium";v="135", "Not:A-Brand";v="24", "Opera";v="120""#,
58
- [
59
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0"),
60
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0"),
61
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 OPR/120.0.0.0")
62
- ]
63
- );
64
-
65
- chromium_profile!(
66
- opera121,
67
- transport: opera116::build_emulation,
68
- headers: header::Preset::ZstdWithPriority,
69
- brands: r#""Opera";v="121", "Chromium";v="137", "Not/A)Brand";v="24""#,
70
- [
71
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0"),
72
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0"),
73
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 OPR/121.0.0.0")
74
- ]
75
- );
76
-
77
- chromium_profile!(
78
- opera122,
79
- transport: opera116::build_emulation,
80
- headers: header::Preset::ZstdWithPriority,
81
- brands: r#""Chromium";v="138", "Not=A?Brand";v="24", "Opera";v="122""#,
82
- [
83
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0"),
84
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0"),
85
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 OPR/122.0.0.0")
86
- ]
87
- );
88
-
89
- chromium_profile!(
90
- opera123,
91
- transport: opera116::build_emulation,
92
- headers: header::Preset::ZstdWithPriority,
93
- brands: r#""Chromium";v="139", "Not=A?Brand";v="24", "Opera";v="123""#,
94
- [
95
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0"),
96
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0"),
97
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 OPR/123.0.0.0")
98
- ]
99
- );
100
-
101
- chromium_profile!(
102
- opera124,
103
- transport: opera116::build_emulation,
104
- headers: header::Preset::ZstdWithPriority,
105
- brands: r#""Chromium";v="140", "Not=A?Brand";v="24", "Opera";v="124""#,
106
- [
107
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0"),
108
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0"),
109
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 OPR/124.0.0.0")
110
- ]
111
- );
112
-
113
- chromium_profile!(
114
- opera125,
115
- transport: opera116::build_emulation,
116
- headers: header::Preset::ZstdWithPriority,
117
- brands: r#""Opera";v="125", "Not?A_Brand";v="8", "Chromium";v="141""#,
118
- [
119
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0"),
120
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0"),
121
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 OPR/125.0.0.0")
122
- ]
123
- );
124
-
125
- chromium_profile!(
126
- opera126,
127
- transport: opera116::build_emulation,
128
- headers: header::Preset::ZstdWithPriority,
129
- brands: r#""Not:A-Brand";v="99", "Opera";v="126", "Chromium";v="142""#,
130
- [
131
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0"),
132
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0"),
133
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 OPR/126.0.0.0")
134
- ]
135
- );
136
-
137
- chromium_profile!(
138
- opera127,
139
- transport: opera116::build_emulation,
140
- headers: header::Preset::ZstdWithPriority,
141
- brands: r#""Not:A-Brand";v="99", "Opera";v="127", "Chromium";v="143""#,
142
- [
143
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0"),
144
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0"),
145
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36 OPR/127.0.0.0")
146
- ]
147
- );
148
-
149
- chromium_profile!(
150
- opera128,
151
- transport: opera116::build_emulation,
152
- headers: header::Preset::ZstdWithPriority,
153
- brands: r#""Not:A-Brand";v="99", "Opera";v="128", "Chromium";v="144""#,
154
- [
155
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0"),
156
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0"),
157
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 OPR/128.0.0.0")
158
- ]
159
- );
160
-
161
- chromium_profile!(
162
- opera129,
163
- transport: opera116::build_emulation,
164
- headers: header::Preset::ZstdWithPriority,
165
- brands: r#""Not:A-Brand";v="99", "Opera";v="129", "Chromium";v="145""#,
166
- [
167
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0"),
168
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0"),
169
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 OPR/129.0.0.0")
170
- ]
171
- );
172
-
173
- chromium_profile!(
174
- opera130,
175
- transport: opera116::build_emulation,
176
- headers: header::Preset::ZstdWithPriority,
177
- brands: r#""Not:A-Brand";v="99", "Opera";v="130", "Chromium";v="146""#,
178
- [
179
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0"),
180
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0"),
181
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 OPR/130.0.0.0")
182
- ]
183
- );
184
-
185
- chromium_profile!(
186
- opera131,
187
- transport: opera116::build_emulation,
188
- headers: header::Preset::ZstdWithPriority,
189
- brands: r#""Opera";v="131", "Not.A/Brand";v="8", "Chromium";v="147""#,
190
- [
191
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0"),
192
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0"),
193
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 OPR/131.0.0.0")
194
- ]
195
- );
196
-
197
- // Reuse Chromium's TLS defaults with Opera's existing HTTP/2 settings.
198
- // Brand hints use Chromium's milestone seed with Opera as the product brand.
199
- chromium_profile!(
200
- opera132,
201
- tls: tls::Preset::MlkemNewAlps,
202
- http2: http2::Preset::NoPush,
203
- headers: header::Preset::ZstdWithPriority,
204
- brands: r#""Chromium";v="148", "Opera";v="132", "Not/A)Brand";v="99""#,
205
- [
206
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 OPR/132.0.0.0"),
207
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 OPR/132.0.0.0"),
208
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 OPR/132.0.0.0")
209
- ]
210
- );
211
-
212
- chromium_profile!(
213
- opera133,
214
- transport: opera132::build_emulation,
215
- headers: header::Preset::ZstdWithPriority,
216
- brands: r#""Opera";v="133", "Chromium";v="149", "Not)A;Brand";v="24""#,
217
- [
218
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.0"),
219
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.0"),
220
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 OPR/133.0.0.0")
221
- ]
222
- );
223
-
224
- chromium_profile!(
225
- opera134,
226
- tls: tls::Preset::MlkemNewAlpsWithMldsa,
227
- http2: http2::Preset::NoPush,
228
- headers: header::Preset::ZstdWithPriority,
229
- brands: r#""Not;A=Brand";v="8", "Chromium";v="150", "Opera";v="134""#,
230
- [
231
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0"),
232
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0"),
233
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36 OPR/134.0.0.0")
234
- ]
235
- );
236
-
237
- chromium_profile!(
238
- opera135,
239
- transport: opera134::build_emulation,
240
- headers: header::Preset::ZstdWithPriority,
241
- brands: r#""Not=A?Brand";v="99", "Opera";v="135", "Chromium";v="151""#,
242
- [
243
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 OPR/135.0.0.0"),
244
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 OPR/135.0.0.0"),
245
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 OPR/135.0.0.0")
246
- ]
247
- );
248
-
249
- // Use Chromium's shuffled Trust Anchor IDs with Opera's existing HTTP/2 settings.
250
- chromium_profile!(
251
- opera136,
252
- tls: tls::Preset::ShuffledTrustAnchorIds,
253
- http2: http2::Preset::NoPush,
254
- headers: header::Preset::ZstdWithPriority,
255
- brands: r#""Chromium";v="152", "Not?A_Brand";v="24", "Opera";v="136""#,
256
- [
257
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 OPR/136.0.0.0"),
258
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 OPR/136.0.0.0"),
259
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36 OPR/136.0.0.0")
260
- ]
261
- );
262
-
263
- chromium_profile!(
264
- opera137,
265
- transport: opera136::build_emulation,
266
- headers: header::Preset::ZstdWithPriority,
267
- brands: r#""Opera";v="137", "Not_A Brand";v="8", "Chromium";v="153""#,
268
- [
269
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 OPR/137.0.0.0"),
270
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 OPR/137.0.0.0"),
271
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36 OPR/137.0.0.0")
272
- ]
273
- );
274
-
275
- // Switch from shuffled to sorted Trust Anchor IDs.
276
- chromium_profile!(
277
- opera138,
278
- tls: tls::Preset::SortedTrustAnchorIds,
279
- http2: http2::Preset::NoPush,
280
- headers: header::Preset::ZstdWithPriority,
281
- brands: r#""Chromium";v="154", "Opera";v="138", "Not A(Brand";v="99""#,
282
- [
283
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0"),
284
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0"),
285
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36 OPR/138.0.0.0")
286
- ]
287
- );
288
-
289
- // Reuse Chromium's JPEG XL navigation headers without changing the Opera transport.
290
- chromium_profile!(
291
- opera139,
292
- transport: opera138::build_emulation,
293
- headers: header::Preset::Jxl,
294
- brands: r#""Opera";v="139", "Chromium";v="155", "Not(A:Brand";v="24""#,
295
- [
296
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0"),
297
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0"),
298
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36 OPR/139.0.0.0")
299
- ]
300
- );
301
-
302
- chromium_profile!(
303
- opera140,
304
- transport: opera138::build_emulation,
305
- headers: header::Preset::Jxl,
306
- brands: r#""Not-A.Brand";v="99", "Opera";v="140", "Chromium";v="157""#,
307
- [
308
- (MacOS, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0"),
309
- (Windows, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0"),
310
- (Linux, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 OPR/140.0.0.0")
311
- ]
312
- );
@@ -1,310 +0,0 @@
1
- use super::super::{
2
- AlpsProtocol, BrotliCompressor, CertificateCompressor, EchGrease, EchGreaseAead, Tls13Cipher,
3
- TlsOptions, TlsVersion,
4
- };
5
-
6
- #[derive(Clone, Copy)]
7
- pub(super) enum Preset {
8
- ClassicGroups,
9
- EchGrease,
10
- PermutedExtensions,
11
- PermutedExtensionsWithEchGrease,
12
- Resumption,
13
- ResumptionWithKyber,
14
- ResumptionWithMlkem,
15
- MlkemNewAlps,
16
- MlkemNewAlpsWithMldsa,
17
- ShuffledTrustAnchorIds,
18
- SortedTrustAnchorIds,
19
- EdgeSignatureGrease,
20
- }
21
-
22
- struct Settings {
23
- curves: &'static str,
24
- sigalgs: &'static str,
25
- permute_extensions: bool,
26
- ech_grease: bool,
27
- pre_shared_key: bool,
28
- new_alps: bool,
29
- grease_sigalgs: Option<bool>,
30
- trust_anchors: Option<TrustAnchorOrder>,
31
- }
32
-
33
- enum TrustAnchorOrder {
34
- Shuffled,
35
- Sorted,
36
- }
37
-
38
- impl Preset {
39
- pub(super) fn build(self) -> TlsOptions {
40
- const CLASSIC: Settings = Settings {
41
- curves: CLASSIC_X25519_GROUPS,
42
- sigalgs: SIGALGS_LIST,
43
- permute_extensions: false,
44
- ech_grease: false,
45
- pre_shared_key: false,
46
- new_alps: false,
47
- grease_sigalgs: None,
48
- trust_anchors: None,
49
- };
50
-
51
- const PERMUTED_ECH: Settings = Settings {
52
- permute_extensions: true,
53
- ech_grease: true,
54
- ..CLASSIC
55
- };
56
-
57
- const RESUMPTION: Settings = Settings {
58
- pre_shared_key: true,
59
- ..PERMUTED_ECH
60
- };
61
-
62
- const MLKEM_NEW_ALPS: Settings = Settings {
63
- curves: MLKEM_GROUPS,
64
- new_alps: true,
65
- ..RESUMPTION
66
- };
67
-
68
- const MLDSA: Settings = Settings {
69
- sigalgs: SIGALGS_WITH_MLDSA,
70
- ..MLKEM_NEW_ALPS
71
- };
72
-
73
- const SIGNATURE_GREASE: Settings = Settings {
74
- grease_sigalgs: Some(true),
75
- ..MLDSA
76
- };
77
-
78
- let settings = match self {
79
- Self::ClassicGroups => CLASSIC,
80
- Self::EchGrease => Settings {
81
- ech_grease: true,
82
- ..CLASSIC
83
- },
84
- Self::PermutedExtensions => Settings {
85
- permute_extensions: true,
86
- ..CLASSIC
87
- },
88
- Self::PermutedExtensionsWithEchGrease => PERMUTED_ECH,
89
- Self::Resumption => RESUMPTION,
90
- Self::ResumptionWithKyber => Settings {
91
- curves: KYBER_DRAFT_GROUPS,
92
- ..RESUMPTION
93
- },
94
- Self::ResumptionWithMlkem => Settings {
95
- curves: MLKEM_GROUPS,
96
- ..RESUMPTION
97
- },
98
- Self::MlkemNewAlps => MLKEM_NEW_ALPS,
99
- Self::MlkemNewAlpsWithMldsa => MLDSA,
100
- Self::ShuffledTrustAnchorIds => Settings {
101
- trust_anchors: Some(TrustAnchorOrder::Shuffled),
102
- ..SIGNATURE_GREASE
103
- },
104
- Self::SortedTrustAnchorIds => Settings {
105
- trust_anchors: Some(TrustAnchorOrder::Sorted),
106
- ..SIGNATURE_GREASE
107
- },
108
- Self::EdgeSignatureGrease => SIGNATURE_GREASE,
109
- };
110
-
111
- let builder = TlsOptions::builder()
112
- .grease_enabled(true)
113
- .enable_ocsp_stapling(true)
114
- .enable_signed_cert_timestamps(true)
115
- .curves_list(settings.curves)
116
- .sigalgs_list(settings.sigalgs)
117
- .cipher_list(CIPHER_LIST)
118
- .tls13_cipher_list(TLS13_CIPHER_LIST)
119
- .min_tls_version(TlsVersion::TLS_1_2)
120
- .max_tls_version(TlsVersion::TLS_1_3)
121
- .permute_extensions(settings.permute_extensions)
122
- .pre_shared_key(settings.pre_shared_key)
123
- .ech_grease(
124
- settings
125
- .ech_grease
126
- .then_some(EchGrease::Aead(EchGreaseAead::AES_128_GCM)),
127
- )
128
- .alps_protocols([AlpsProtocol::HTTP2])
129
- .alps_use_new_codepoint(settings.new_alps)
130
- .certificate_compressors(CERTIFICATE_COMPRESSORS)
131
- .grease_sigalgs_enabled(settings.grease_sigalgs);
132
-
133
- // Skipping this setter omits the extension; an empty list would still send it.
134
- let builder = match settings.trust_anchors {
135
- Some(TrustAnchorOrder::Shuffled) => {
136
- builder.trust_anchors(shuffled_trust_anchors(crate::rand::fast_random))
137
- }
138
- Some(TrustAnchorOrder::Sorted) => builder.trust_anchors(sorted_trust_anchors()),
139
- None => builder,
140
- };
141
- builder.build()
142
- }
143
- }
144
-
145
- const CLASSIC_X25519_GROUPS: &str = join!(":", "X25519", "P-256", "P-384");
146
- const KYBER_DRAFT_GROUPS: &str = join!(":", "X25519Kyber768Draft00", "X25519", "P-256", "P-384");
147
- const MLKEM_GROUPS: &str = join!(":", "X25519MLKEM768", "X25519", "P-256", "P-384");
148
-
149
- pub const CIPHER_LIST: &str = join!(
150
- ":",
151
- "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
152
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
153
- "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
154
- "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
155
- "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
156
- "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
157
- "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
158
- "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
159
- "TLS_RSA_WITH_AES_128_GCM_SHA256",
160
- "TLS_RSA_WITH_AES_256_GCM_SHA384",
161
- "TLS_RSA_WITH_AES_128_CBC_SHA",
162
- "TLS_RSA_WITH_AES_256_CBC_SHA"
163
- );
164
-
165
- pub const TLS13_CIPHER_LIST: &[Tls13Cipher] = &[
166
- Tls13Cipher::AES_128_GCM_SHA256,
167
- Tls13Cipher::AES_256_GCM_SHA384,
168
- Tls13Cipher::CHACHA20_POLY1305_SHA256,
169
- ];
170
-
171
- pub const SIGALGS_LIST: &str = join!(
172
- ":",
173
- "ecdsa_secp256r1_sha256",
174
- "rsa_pss_rsae_sha256",
175
- "rsa_pkcs1_sha256",
176
- "ecdsa_secp384r1_sha384",
177
- "rsa_pss_rsae_sha384",
178
- "rsa_pkcs1_sha384",
179
- "rsa_pss_rsae_sha512",
180
- "rsa_pkcs1_sha512"
181
- );
182
-
183
- const SIGALGS_WITH_MLDSA: &str = join!(
184
- ":",
185
- "mldsa44",
186
- "mldsa65",
187
- "mldsa87",
188
- "ecdsa_secp256r1_sha256",
189
- "rsa_pss_rsae_sha256",
190
- "rsa_pkcs1_sha256",
191
- "ecdsa_secp384r1_sha384",
192
- "rsa_pss_rsae_sha384",
193
- "rsa_pkcs1_sha384",
194
- "rsa_pss_rsae_sha512",
195
- "rsa_pkcs1_sha512"
196
- );
197
-
198
- // Encoded IDs and wreq's Chromium root store come from the same root set.
199
- pub(super) const CHROME_TRUST_ANCHORS: &[u8] = &chromium_roots::encoded_trust_anchor_ids();
200
-
201
- // Chrome 152/153 iterate a salted flat_hash_set held by SSLClientContext, rather than
202
- // the root store's source order. Generate an order once per native configuration;
203
- // connections using that client configuration retain the order.
204
- // https://chromium.googlesource.com/chromium/src/+/f7b831a4e249fbd98eae4b391c69f70300a849d1/net/ssl/ssl_config_service.cc
205
- fn shuffled_trust_anchors(mut random: impl FnMut() -> u64) -> Vec<u8> {
206
- let mut ids = chromium_roots::trust_anchor_ids();
207
- for index in (1..ids.len()).rev() {
208
- let bound = (index + 1) as u64;
209
- let limit = u64::MAX - u64::MAX % bound;
210
- let mut value = random();
211
- while value >= limit {
212
- value = random();
213
- }
214
- ids.swap(index, (value % bound) as usize);
215
- }
216
-
217
- encode_trust_anchors(&ids)
218
- }
219
-
220
- // Chrome 154 sorts the raw IDs before adding their length prefixes.
221
- // https://chromium.googlesource.com/chromium/src/+/731082f0a26ce4b3976c3d82943092f5d13daf13/net/cert/x509_util.cc
222
- fn sorted_trust_anchors() -> Vec<u8> {
223
- let mut ids = chromium_roots::trust_anchor_ids();
224
- ids.sort_unstable();
225
- encode_trust_anchors(&ids)
226
- }
227
-
228
- fn encode_trust_anchors(ids: &[&[u8]]) -> Vec<u8> {
229
- let mut encoded = Vec::with_capacity(CHROME_TRUST_ANCHORS.len());
230
- for id in ids {
231
- // encoded_trust_anchor_ids() validates these same IDs at compile time:
232
- // each length is nonzero and fits in one byte.
233
- encoded.push(id.len() as u8);
234
- encoded.extend_from_slice(id);
235
- }
236
- encoded
237
- }
238
-
239
- pub const CERTIFICATE_COMPRESSORS: &[&'static dyn CertificateCompressor] = &[&BrotliCompressor];
240
-
241
- #[cfg(test)]
242
- mod tests {
243
- use super::*;
244
- use wreq::IntoEmulation;
245
-
246
- #[test]
247
- fn chrome_profiles_retain_trust_anchor_order_when_cloned() {
248
- for profile in [
249
- crate::Profile::Chrome152,
250
- crate::Profile::Chrome153,
251
- crate::Profile::Chrome154,
252
- crate::Profile::Chrome155,
253
- crate::Profile::Chrome156,
254
- crate::Profile::Chrome157,
255
- ] {
256
- let native = profile.into_emulation();
257
- let cloned = native.clone();
258
- let ids = native.tls_options.unwrap().trust_anchors.unwrap();
259
- assert_eq!(ids.len(), CHROME_TRUST_ANCHORS.len());
260
- assert_eq!(ids, cloned.tls_options.unwrap().trust_anchors.unwrap());
261
- let decoded = decode_ids(&ids);
262
- let mut expected = chromium_roots::trust_anchor_ids();
263
- expected.sort_unstable();
264
- if matches!(
265
- profile,
266
- crate::Profile::Chrome154
267
- | crate::Profile::Chrome155
268
- | crate::Profile::Chrome156
269
- | crate::Profile::Chrome157
270
- ) {
271
- assert_eq!(decoded, expected);
272
- }
273
- let mut actual = decoded;
274
- actual.sort_unstable();
275
- assert_eq!(actual, expected);
276
- }
277
- assert!(
278
- crate::Profile::Chrome151
279
- .into_emulation()
280
- .tls_options
281
- .unwrap()
282
- .trust_anchors
283
- .is_none()
284
- );
285
- }
286
-
287
- #[test]
288
- fn trust_anchor_shuffle_preserves_ids_without_pinning_the_first() {
289
- // Choosing index zero at every step rotates the entire list left.
290
- // Rejecting u64::MAX also covers the unbiased sampling boundary.
291
- let mut samples = std::iter::once(u64::MAX).chain(std::iter::repeat(0));
292
- let encoded = shuffled_trust_anchors(|| samples.next().unwrap());
293
- let decoded = decode_ids(&encoded);
294
- let mut expected = chromium_roots::trust_anchor_ids();
295
- expected.rotate_left(1);
296
- assert_eq!(decoded, expected);
297
- assert_eq!(encoded.len(), CHROME_TRUST_ANCHORS.len());
298
- }
299
-
300
- fn decode_ids(mut remaining: &[u8]) -> Vec<&[u8]> {
301
- let mut decoded = Vec::new();
302
- while let Some((&length, rest)) = remaining.split_first() {
303
- assert_ne!(length, 0);
304
- let (id, rest) = rest.split_at(usize::from(length));
305
- decoded.push(id);
306
- remaining = rest;
307
- }
308
- decoded
309
- }
310
- }
@@ -1,9 +0,0 @@
1
- //! Presets and shared options for Chromium-based browsers.
2
-
3
- pub mod chrome;
4
- pub(in crate::emulate) mod edge;
5
- pub mod opera;
6
-
7
- mod header;
8
- mod http2;
9
- mod tls;