stealthhttp 0.3.0__tar.gz → 0.3.1__tar.gz

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 (155) hide show
  1. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/CHANGELOG.md +20 -0
  2. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/PKG-INFO +1 -1
  3. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/pyproject.toml +1 -1
  4. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/__init__.py +1 -1
  5. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/async_session.py +1 -2
  6. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/backends/native_backend.py +3 -2
  7. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/cdp_solver.py +2 -1
  8. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/clienthints.py +1 -1
  9. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/__init__.py +5 -1
  10. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/detection.py +3 -2
  11. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/device_db.py +3 -3
  12. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/js_sandbox.py +3 -1
  13. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/jsenv.py +6 -5
  14. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/middleware.py +10 -9
  15. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/pow.py +6 -4
  16. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/proxy.py +0 -2
  17. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/session_coord.py +2 -2
  18. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/session_ext.py +1 -1
  19. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tests/test_features_v3.py +1 -1
  20. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tests/test_v030_features.py +1 -1
  21. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/websocket.py +2 -1
  22. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/.cargo/config.toml +0 -0
  23. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/.github/workflows/release.yml +0 -0
  24. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/.gitignore +0 -0
  25. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/Cargo.lock +0 -0
  26. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/Cargo.toml +0 -0
  27. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/LICENSE +0 -0
  28. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/README.md +0 -0
  29. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/benchmarks/bench.py +0 -0
  30. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/benchmarks/bench_native.py +0 -0
  31. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/examples/basic.py +0 -0
  32. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/_fallback.py +0 -0
  33. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/_loader.py +0 -0
  34. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/_rotation.py +0 -0
  35. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/ambient.py +0 -0
  36. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/antidetect.py +0 -0
  37. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/auto_bypass.py +0 -0
  38. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/auto_profile.py +0 -0
  39. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/backends/__init__.py +0 -0
  40. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/backends/base.py +0 -0
  41. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/backends/curl_backend.py +0 -0
  42. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/backends/wreq_backend.py +0 -0
  43. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/behavior.py +0 -0
  44. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/browser_cookies.py +0 -0
  45. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/browser_pool.py +0 -0
  46. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/browsing.py +0 -0
  47. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/__init__.py +0 -0
  48. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/akamai.py +0 -0
  49. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/captcha.py +0 -0
  50. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/cloudflare.py +0 -0
  51. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/datadome.py +0 -0
  52. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/flow.py +0 -0
  53. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/imperva.py +0 -0
  54. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/kasada.py +0 -0
  55. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/perimeterx.py +0 -0
  56. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/shape.py +0 -0
  57. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/bypasses/solver.py +0 -0
  58. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/capabilities.py +0 -0
  59. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/captcha.py +0 -0
  60. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/captcha_farm.py +0 -0
  61. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/challenge.py +0 -0
  62. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/akamai.py +0 -0
  63. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/datadome.py +0 -0
  64. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/imperva.py +0 -0
  65. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/kasada.py +0 -0
  66. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/perimeterx.py +0 -0
  67. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/collectors/shape.py +0 -0
  68. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/consistency.py +0 -0
  69. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/cookies.py +0 -0
  70. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/dns_intel.py +0 -0
  71. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/doh.py +0 -0
  72. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/error_analysis.py +0 -0
  73. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/exceptions.py +0 -0
  74. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/fingerprint_diff.py +0 -0
  75. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/forms.py +0 -0
  76. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/geo.py +0 -0
  77. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/graphql.py +0 -0
  78. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/h2_frames.py +0 -0
  79. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/har.py +0 -0
  80. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/header_canon.py +0 -0
  81. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/health_monitor.py +0 -0
  82. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/hooks.py +0 -0
  83. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/hsts.py +0 -0
  84. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/httpcache.py +0 -0
  85. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/humanize.py +0 -0
  86. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/identity.py +0 -0
  87. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/jsdb.py +0 -0
  88. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/lifecycle.py +0 -0
  89. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/lint.py +0 -0
  90. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/multipart.py +0 -0
  91. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/parsing.py +0 -0
  92. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/prepare.py +0 -0
  93. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/proxy_scoring.py +0 -0
  94. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/record_replay.py +0 -0
  95. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/redirect_intel.py +0 -0
  96. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/request_graph.py +0 -0
  97. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/response.py +0 -0
  98. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/response_decoder.py +0 -0
  99. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/response_intel.py +0 -0
  100. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/retry.py +0 -0
  101. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/rotation.py +0 -0
  102. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/selfcheck.py +0 -0
  103. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/sensors.py +0 -0
  104. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/session.py +0 -0
  105. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/site_recipes.py +0 -0
  106. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/smart_proxy.py +0 -0
  107. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/__init__.py +0 -0
  108. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/audio.py +0 -0
  109. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/base.py +0 -0
  110. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/browser.py +0 -0
  111. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/local.py +0 -0
  112. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/orchestrator.py +0 -0
  113. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/providers.py +0 -0
  114. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/solving/vision.py +0 -0
  115. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/stealth_audit.py +0 -0
  116. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/strategy.py +0 -0
  117. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tcp_tuning.py +0 -0
  118. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tests/test_cdp_solver.py +0 -0
  119. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tests/test_features_v3_live.py +0 -0
  120. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tls_ext.py +0 -0
  121. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tls_intel.py +0 -0
  122. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/tls_session.py +0 -0
  123. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/python/stealthhttp/traffic.py +0 -0
  124. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/fingerprint/headers.rs +0 -0
  125. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/fingerprint/ja3.rs +0 -0
  126. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/fingerprint/ja4.rs +0 -0
  127. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/fingerprint/mod.rs +0 -0
  128. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/fingerprint/profile.rs +0 -0
  129. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/lib.rs +0 -0
  130. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/proxypool.rs +0 -0
  131. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/rotation.rs +0 -0
  132. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/transport/decode.rs +0 -0
  133. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/transport/engine.rs +0 -0
  134. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/transport/mod.rs +0 -0
  135. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/src/transport/tls.rs +0 -0
  136. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/conftest.py +0 -0
  137. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_audio.py +0 -0
  138. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_bypass.py +0 -0
  139. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_bypasses.py +0 -0
  140. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_bypasses_live.py +0 -0
  141. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_emulation.py +0 -0
  142. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_features_v2.py +0 -0
  143. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_features_v2_live.py +0 -0
  144. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_fingerprint.py +0 -0
  145. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_humanize.py +0 -0
  146. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_jsemu.py +0 -0
  147. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_jsemu_live.py +0 -0
  148. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_live_bypass.py +0 -0
  149. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_live_detection.py +0 -0
  150. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_new_features.py +0 -0
  151. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_policies.py +0 -0
  152. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_routing.py +0 -0
  153. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_session.py +0 -0
  154. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_solving.py +0 -0
  155. {stealthhttp-0.3.0 → stealthhttp-0.3.1}/tests/test_vision.py +0 -0
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.1] - 2026-08-10
4
+
5
+ ### Fixed
6
+
7
+ - **proxy**: remove false-positive 403 ban detection (bare 403 is routine for APIs)
8
+ - **async_session**: remove semaphore from `each()._do` preventing deadlock
9
+ - **js_sandbox**: `return None` moved outside for-loop (was unreachable)
10
+ - **session_ext**: use `urlsplit().hostname` instead of `netloc.split(':')[0]` for credential URLs
11
+ - **native_backend**: add `time.monotonic()` for elapsed measurement
12
+ - **detection**: priority header check now accepts Firefox
13
+ - **device_db**: Android platform string corrected to 'Linux armv81'
14
+ - **clienthints**: thread-safe iteration with `list(policy.accepted)`
15
+ - **jsenv**: timing values chained sequentially
16
+ - **websocket**: CLOSE frame sent under lock
17
+ - **session_coord**: adaptive cutoff `now - max(1.0, 1/rps)` instead of hardcoded
18
+ - **middleware**: DedupeMiddleware wrapped in `threading.Lock()`
19
+ - **cdp_solver**: handle proxy URL without port
20
+ - **pow**: validate `nonce_size < 8`
21
+ - **collectors**: add KasadaCollector and ShapeCollector exports
22
+
3
23
  ## [0.3.0] - 2026-08-05
4
24
 
5
25
  ### Added — Killer Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stealthhttp
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -7,7 +7,7 @@ build-backend = "maturin"
7
7
 
8
8
  [project]
9
9
  name = "stealthhttp"
10
- version = "0.3.0"
10
+ version = "0.3.1"
11
11
  description = "HTTP with TLS fingerprint impersonation, rotation and proxy health tracking"
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.9"
@@ -118,7 +118,7 @@ from .browser_pool import BrowserPool
118
118
  from .record_replay import HttpRecorder, SessionReplayer, RecordedEntry, record_session
119
119
  from .captcha_farm import CaptchaFarm, SolveResult
120
120
 
121
- __version__ = "0.3.0"
121
+ __version__ = "0.3.1"
122
122
 
123
123
  __all__ = [
124
124
  "Session",
@@ -116,8 +116,7 @@ class AsyncSession:
116
116
  ) -> list[Any]:
117
117
  """Apply an async function to each item with concurrency limiting."""
118
118
  async def _do(item: Any) -> Any:
119
- async with self._semaphore:
120
- return await fn(item, self)
119
+ return await fn(item, self)
121
120
  return list(await asyncio.gather(*[_do(it) for it in items]))
122
121
 
123
122
  # -- stats -------------------------------------------------------------
@@ -23,6 +23,7 @@ to see each hop.
23
23
 
24
24
  from __future__ import annotations
25
25
 
26
+ import time
26
27
  from typing import Any
27
28
  from urllib.parse import urljoin, urlsplit
28
29
 
@@ -131,10 +132,12 @@ class NativeBackend:
131
132
  url = f"{url}{sep}{urlencode(dict(req.params))}"
132
133
 
133
134
  elapsed = 0.0
135
+ t0 = time.monotonic()
134
136
  for hop in range(max_redirects + 1):
135
137
  raw = self._engine.fetch_one(self._payload(
136
138
  method, url, headers, body, req, verify, resolve
137
139
  ))
140
+ elapsed = (time.monotonic() - t0) * 1000
138
141
  err = raw["error"]
139
142
  if err:
140
143
  raise _translate(err, method, url)
@@ -149,8 +152,6 @@ class NativeBackend:
149
152
  method, body = "GET", None
150
153
  headers.pop("content-type", None)
151
154
  headers.pop("content-length", None)
152
- # A redirect to another origin must not carry the first one's
153
- # cookies or Host-specific headers.
154
155
  continue
155
156
  if req.allow_redirects and location and 300 <= status < 400:
156
157
  raise TooManyRedirects(
@@ -290,7 +290,8 @@ class StealthBrowser:
290
290
  args.append(f"--user-agent={ua}")
291
291
  if self._proxy:
292
292
  p = urlparse(self._proxy)
293
- args.append(f"--proxy-server={p.scheme}://{p.hostname}:{p.port}")
293
+ port_part = f":{p.port}" if p.port else ""
294
+ args.append(f"--proxy-server={p.scheme}://{p.hostname}{port_part}")
294
295
  args.append("--host-resolver-rules=MAP * ~NOTFOUND , EXCLUDE 127.0.0.1")
295
296
  if p.username:
296
297
  self._proxy_creds = (p.username, p.password or "")
@@ -105,7 +105,7 @@ class HintStore:
105
105
  return out
106
106
 
107
107
  # High-entropy: only what the server requested
108
- for hint in policy.accepted:
108
+ for hint in list(policy.accepted):
109
109
  h = hint.lower()
110
110
  if h in LOW_ENTROPY:
111
111
  continue
@@ -19,11 +19,15 @@ Supported collectors:
19
19
  from .akamai import AkamaiSensor
20
20
  from .datadome import DataDomeCollector
21
21
  from .imperva import ImpervaCollector
22
+ from .kasada import KasadaCollector
22
23
  from .perimeterx import PerimeterXCollector
24
+ from .shape import ShapeCollector
23
25
 
24
26
  __all__ = [
25
27
  "AkamaiSensor",
26
- "PerimeterXCollector",
27
28
  "DataDomeCollector",
28
29
  "ImpervaCollector",
30
+ "KasadaCollector",
31
+ "PerimeterXCollector",
32
+ "ShapeCollector",
29
33
  ]
@@ -461,10 +461,11 @@ def audit(browser: str = "chrome136", *, timeout: float = 25.0,
461
461
  prof = predict(browser)
462
462
  is_chromium = any(x in prof.user_agent for x in ("Chrome/", "Edg/", "OPR/"))
463
463
  has_priority = "priority" in regular
464
+ priority_ok = has_priority or not is_chromium
464
465
  a.add("missing-headers",
465
- has_priority == is_chromium,
466
+ priority_ok,
466
467
  f"priority header {'present' if has_priority else 'absent'}, "
467
- f"{'expected' if is_chromium else 'not expected'} for this engine")
468
+ f"{'expected' if is_chromium else 'optional'} for this engine")
468
469
 
469
470
  enc = values.get("accept-encoding", "")
470
471
  decoded_ok = resp.status_code == 200 and bool(resp.content)
@@ -109,15 +109,15 @@ DEVICES: Dict[str, DeviceSpec] = {
109
109
  ),
110
110
  "samsung_s24": DeviceSpec(
111
111
  "Samsung Galaxy S24", 1080, 2340, 2.625, 412, 892,
112
- "Adreno 740", 8, 8.0, "Linux x86_64", True,
112
+ "Adreno 740", 8, 8.0, "Linux armv81", True,
113
113
  ),
114
114
  "pixel_8": DeviceSpec(
115
115
  "Google Pixel 8", 1080, 2400, 2.625, 412, 915,
116
- "Mali-G715", 8, 8.0, "Linux x86_64", True,
116
+ "Mali-G715", 8, 8.0, "Linux armv81", True,
117
117
  ),
118
118
  "samsung_s23": DeviceSpec(
119
119
  "Samsung Galaxy S23", 1080, 2340, 2.625, 412, 892,
120
- "Adreno 730", 8, 8.0, "Linux x86_64", True,
120
+ "Adreno 730", 8, 8.0, "Linux armv81", True,
121
121
  ),
122
122
  }
123
123
 
@@ -265,7 +265,9 @@ class JSSandbox:
265
265
  if isinstance(nd, _Call): return self._call(nd, sc)
266
266
  if isinstance(nd, _Tern): return self._ev(nd.y, sc) if self._ev(nd.c, sc) else self._ev(nd.n, sc)
267
267
  if isinstance(nd, _If):
268
- for s in (nd.b if self._ev(nd.c, sc) else (nd.e or [])): self._ev(s, sc); return None
268
+ for s in (nd.b if self._ev(nd.c, sc) else (nd.e or [])):
269
+ self._ev(s, sc)
270
+ return None
269
271
  if isinstance(nd, (_For, _Whl)): return self._loop(nd, sc)
270
272
  if isinstance(nd, _Ret): raise _RetSig(self._ev(nd.v, sc) if nd.v else None)
271
273
  if isinstance(nd, _Brk): raise _BrkSig()
@@ -369,9 +369,10 @@ def _normalize_platform(p: str) -> str:
369
369
 
370
370
  def _generate_timing(rng: random.Random) -> PerformanceTiming:
371
371
  connect = rng.randint(20, 80)
372
- ttfb = rng.randint(80, 250)
373
- resp_dur = rng.randint(30, 150)
374
- dom_int = rng.randint(300, 800)
372
+ req_start = connect + rng.randint(1, 5)
373
+ ttfb = req_start + rng.randint(15, 200)
374
+ resp_end = ttfb + rng.randint(30, 150)
375
+ dom_int = resp_end + rng.randint(30, 300)
375
376
  dcl = dom_int + rng.randint(30, 150)
376
377
  dom_comp = dcl + rng.randint(400, 1500)
377
378
  load_s = dom_comp + rng.randint(2, 20)
@@ -380,9 +381,9 @@ def _generate_timing(rng: random.Random) -> PerformanceTiming:
380
381
  navigation_start=0,
381
382
  connect_start=1,
382
383
  connect_end=connect,
383
- request_start=connect + 1,
384
+ request_start=req_start,
384
385
  response_start=ttfb,
385
- response_end=ttfb + resp_dur,
386
+ response_end=resp_end,
386
387
  dom_interactive=dom_int,
387
388
  dom_content_loaded=dcl,
388
389
  dom_complete=dom_comp,
@@ -88,11 +88,12 @@ class RateLimitMiddleware(Middleware):
88
88
 
89
89
 
90
90
  class DedupeMiddleware(Middleware):
91
- __slots__ = ("_window", "_seen")
91
+ __slots__ = ("_window", "_seen", "_lock")
92
92
 
93
93
  def __init__(self, window_seconds: float = 60.0) -> None:
94
94
  self._window = window_seconds
95
95
  self._seen: dict[str, float] = {}
96
+ self._lock = threading.Lock()
96
97
 
97
98
  @staticmethod
98
99
  def _hash_request(request: dict) -> str:
@@ -108,14 +109,14 @@ class DedupeMiddleware(Middleware):
108
109
 
109
110
  def process_request(self, request: dict) -> dict | None:
110
111
  now = time.monotonic()
111
- # evict expired entries
112
- expired = [k for k, ts in self._seen.items() if now - ts > self._window]
113
- for k in expired:
114
- del self._seen[k]
115
- h = self._hash_request(request)
116
- if h in self._seen:
117
- return None
118
- self._seen[h] = now
112
+ with self._lock:
113
+ expired = [k for k, ts in self._seen.items() if now - ts > self._window]
114
+ for k in expired:
115
+ del self._seen[k]
116
+ h = self._hash_request(request)
117
+ if h in self._seen:
118
+ return None
119
+ self._seen[h] = now
119
120
  return request
120
121
 
121
122
 
@@ -50,9 +50,10 @@ def solve_sha256(challenge: bytes, difficulty: int, *,
50
50
  remaining_bits = difficulty % 8
51
51
  target_prefix = b"\x00" * prefix_bytes
52
52
 
53
- rand_suffix = os.urandom(nonce_size - 8)
53
+ rand_suffix = os.urandom(max(0, nonce_size - 8))
54
54
  for i in range(max_iterations):
55
- nonce = struct.pack(">Q", i) + rand_suffix
55
+ counter = struct.pack(">Q", i)
56
+ nonce = (counter + rand_suffix)[:nonce_size] if nonce_size < 8 else counter + rand_suffix
56
57
  h = hashlib.sha256(challenge + nonce).digest()
57
58
 
58
59
  if h[:prefix_bytes] != target_prefix:
@@ -85,9 +86,10 @@ def solve_hmac_sha256(challenge: bytes, key: bytes, difficulty: int, *,
85
86
  remaining_bits = difficulty % 8
86
87
  target_prefix = b"\x00" * prefix_bytes
87
88
 
88
- rand_suffix = os.urandom(nonce_size - 8)
89
+ rand_suffix = os.urandom(max(0, nonce_size - 8))
89
90
  for i in range(max_iterations):
90
- nonce = struct.pack(">Q", i) + rand_suffix
91
+ counter = struct.pack(">Q", i)
92
+ nonce = (counter + rand_suffix)[:nonce_size] if nonce_size < 8 else counter + rand_suffix
91
93
  h = hmac.new(key, challenge + nonce, hashlib.sha256).digest()
92
94
 
93
95
  if h[:prefix_bytes] != target_prefix:
@@ -270,8 +270,6 @@ def detect_ban(status: int, headers: dict, body: bytes) -> str | None:
270
270
  if marker in sample:
271
271
  return marker.decode(errors="replace").strip("/_ ")
272
272
 
273
- if status in _BAN_STATUSES and status == 403:
274
- return "forbidden"
275
273
  return None
276
274
 
277
275
 
@@ -48,8 +48,8 @@ class SharedRateLimiter:
48
48
  window = 1.0 / rps
49
49
  stamps = self._timestamps.setdefault(domain, [])
50
50
 
51
- # Purge timestamps older than the window.
52
- cutoff = now - 1.0
51
+ purge_window = max(1.0, 1.0 / rps)
52
+ cutoff = now - purge_window
53
53
  while stamps and stamps[0] < cutoff:
54
54
  stamps.pop(0)
55
55
 
@@ -24,7 +24,7 @@ from .retry import parse_retry_after
24
24
 
25
25
  def _host(url: str) -> str:
26
26
  from urllib.parse import urlsplit
27
- return urlsplit(url).netloc.split(":")[0].lower()
27
+ return (urlsplit(url).hostname or "").lower()
28
28
 
29
29
 
30
30
  class SessionExtMixin:
@@ -478,7 +478,7 @@ def test_all_exports():
478
478
  assert not missing, f"Missing: {missing}"
479
479
 
480
480
  def test_version():
481
- assert stealthhttp.__version__ == '0.3.0'
481
+ assert stealthhttp.__version__ == '0.3.1'
482
482
 
483
483
 
484
484
  if __name__ == '__main__':
@@ -487,7 +487,7 @@ def test_exports_cdp_solver():
487
487
 
488
488
  def test_exports_version():
489
489
  import stealthhttp
490
- assert stealthhttp.__version__ == "0.3.0"
490
+ assert stealthhttp.__version__ == "0.3.1"
491
491
 
492
492
 
493
493
  # -----------------------------------------------------------------------
@@ -182,7 +182,8 @@ class WebSocket:
182
182
  if opcode == _OP_CLOSE:
183
183
  self._closed = True
184
184
  try:
185
- self._sock.sendall(_build_frame(_OP_CLOSE, b""))
185
+ with self._lock:
186
+ self._sock.sendall(_build_frame(_OP_CLOSE, b""))
186
187
  except OSError:
187
188
  pass
188
189
  return None
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes