hyper-sdk 4.1.0__tar.gz → 4.2.0__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 (39) hide show
  1. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/PKG-INFO +20 -1
  2. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/README.md +19 -0
  3. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/__init__.py +1 -0
  4. hyper_sdk-4.2.0/hyper_sdk/kasada/dv.py +38 -0
  5. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/kasada_input.py +9 -1
  6. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk.egg-info/PKG-INFO +20 -1
  7. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk.egg-info/SOURCES.txt +2 -0
  8. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/pyproject.toml +1 -1
  9. hyper_sdk-4.2.0/tests/test_dv.py +25 -0
  10. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/LICENSE +0 -0
  11. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/akamai/__init__.py +0 -0
  12. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/akamai/pixel.py +0 -0
  13. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/akamai/script_path.py +0 -0
  14. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
  15. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/akamai/stop_signal.py +0 -0
  16. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/akamai_input.py +0 -0
  17. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/datadome/__init__.py +0 -0
  18. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/datadome/parse.py +0 -0
  19. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/datadome_input.py +0 -0
  20. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/incapsula/__init__.py +0 -0
  21. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/incapsula/dynamic.py +0 -0
  22. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/incapsula/utmvc.py +0 -0
  23. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/incapsula_input.py +0 -0
  24. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/kasada/__init__.py +0 -0
  25. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/kasada/parse.py +0 -0
  26. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/kasada/user_agent.py +0 -0
  27. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/payloads.py +0 -0
  28. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/results.py +0 -0
  29. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/session.py +0 -0
  30. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/session_async.py +0 -0
  31. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/shared.py +0 -0
  32. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk/trustdecision_input.py +0 -0
  33. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
  34. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk.egg-info/requires.txt +0 -0
  35. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/hyper_sdk.egg-info/top_level.txt +0 -0
  36. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/setup.cfg +0 -0
  37. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/tests/test_results.py +0 -0
  38. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/tests/test_script_hash.py +0 -0
  39. {hyper_sdk-4.1.0 → hyper_sdk-4.2.0}/tests/test_user_agent.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyper_sdk
3
- Version: 4.1.0
3
+ Version: 4.2.0
4
4
  Summary: Hyper Solutions Python SDK
5
5
  License: MIT License
6
6
 
@@ -368,6 +368,25 @@ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
368
368
 
369
369
  Available in `hyper_sdk` 3.1.0 and later.
370
370
 
371
+ ### Mobile x-kpsdk-dv Generation
372
+
373
+ On iOS the Kasada SDK (`x-kpsdk-v` i-2.x) also sends an **`x-kpsdk-dv`** header describing the device and the app. Build it from the same values as the user-agent, plus the model identifier, and pass the same value as `dv` on the payload request so the payload is generated on an iPhone with that model's screen and iOS version:
374
+
375
+ ```python
376
+ from hyper_sdk import KasadaPayloadInput, generate_kasada_dv, generate_kasada_user_agent
377
+
378
+ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
379
+ dv = generate_kasada_dv("18.0.1", "iPhone13,2", "com.example.app", "9.15.0")
380
+ # hardware_id is the model identifier from utsname.machine ("iPhone13,2" is an iPhone 12)
381
+
382
+ result = session.generate_kasada_payload(KasadaPayloadInput(
383
+ user_agent, ips_link, script, "en-US,en;q=0.9", ip,
384
+ dv=dv, # the x-kpsdk-dv value you send to the site
385
+ ))
386
+ ```
387
+
388
+ Available in `hyper_sdk` 4.2.0 and later.
389
+
371
390
  ## 🎯 DataDome Solutions
372
391
 
373
392
  Solve **DataDome captchas** including slider challenges and interstitial pages.
@@ -325,6 +325,25 @@ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
325
325
 
326
326
  Available in `hyper_sdk` 3.1.0 and later.
327
327
 
328
+ ### Mobile x-kpsdk-dv Generation
329
+
330
+ On iOS the Kasada SDK (`x-kpsdk-v` i-2.x) also sends an **`x-kpsdk-dv`** header describing the device and the app. Build it from the same values as the user-agent, plus the model identifier, and pass the same value as `dv` on the payload request so the payload is generated on an iPhone with that model's screen and iOS version:
331
+
332
+ ```python
333
+ from hyper_sdk import KasadaPayloadInput, generate_kasada_dv, generate_kasada_user_agent
334
+
335
+ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
336
+ dv = generate_kasada_dv("18.0.1", "iPhone13,2", "com.example.app", "9.15.0")
337
+ # hardware_id is the model identifier from utsname.machine ("iPhone13,2" is an iPhone 12)
338
+
339
+ result = session.generate_kasada_payload(KasadaPayloadInput(
340
+ user_agent, ips_link, script, "en-US,en;q=0.9", ip,
341
+ dv=dv, # the x-kpsdk-dv value you send to the site
342
+ ))
343
+ ```
344
+
345
+ Available in `hyper_sdk` 4.2.0 and later.
346
+
328
347
  ## 🎯 DataDome Solutions
329
348
 
330
349
  Solve **DataDome captchas** including slider challenges and interstitial pages.
@@ -9,4 +9,5 @@ from .session import *
9
9
  from .session_async import *
10
10
  from .kasada.parse import *
11
11
  from .kasada.user_agent import *
12
+ from .kasada.dv import *
12
13
  from .datadome.parse import *
@@ -0,0 +1,38 @@
1
+ import base64
2
+ import json
3
+
4
+ __all__ = ["generate_kasada_dv"]
5
+
6
+ # The key the Kasada iOS SDK XORs the x-kpsdk-dv header with.
7
+ _DV_KEY = b"9d9a1f73-a488-464c-9f73-8c87d018363c"
8
+
9
+
10
+ def generate_kasada_dv(os_version: str, hardware_id: str, app_id: str, app_version: str) -> str:
11
+ """
12
+ Generates the x-kpsdk-dv header value the Kasada iOS SDK (i-2.x) sends.
13
+
14
+ The value is base64 of {"osVersion","hardwareId","appId","appVersion"} XORed with a key
15
+ fixed in the SDK. app_id and app_version are the same values generate_kasada_user_agent
16
+ takes as bundle_id and app_version, so a user-agent and a dv built from one set of inputs
17
+ describe the same app and device.
18
+
19
+ Send the same value as the dv field of KasadaPayloadInput, so the payload is generated on
20
+ a device with that model's screen and iOS release.
21
+
22
+ Args:
23
+ os_version (str): UIDevice.systemVersion (e.g. "18.0.1").
24
+ hardware_id (str): The model identifier from utsname.machine (e.g. "iPhone13,2" for
25
+ an iPhone 12), not the marketing name.
26
+ app_id (str): The app bundle id (e.g. "com.example.app").
27
+ app_version (str): The app version (e.g. "9.15.0").
28
+
29
+ Returns:
30
+ str: The x-kpsdk-dv header value.
31
+ """
32
+ plain = json.dumps(
33
+ {"osVersion": os_version, "hardwareId": hardware_id, "appId": app_id, "appVersion": app_version},
34
+ separators=(",", ":"),
35
+ ensure_ascii=False,
36
+ ).encode("utf-8")
37
+ key = _DV_KEY[:len(plain)]
38
+ return base64.b64encode(bytes(b ^ key[i % len(key)] for i, b in enumerate(plain))).decode("ascii")
@@ -21,7 +21,7 @@ class KasadaPowInput:
21
21
 
22
22
  class KasadaPayloadInput:
23
23
  def __init__(self, user_agent: str, ips_link: str, script: str, accept_language: str, ip: str,
24
- strict: bool = False):
24
+ strict: bool = False, dv: str = ""):
25
25
  # UserAgent must be a Chrome Windows User-Agent.
26
26
  self.user_agent = user_agent
27
27
 
@@ -41,6 +41,12 @@ class KasadaPayloadInput:
41
41
  # set". Off by default: such a payload usually still works.
42
42
  self.strict = strict
43
43
 
44
+ # Dv is the x-kpsdk-dv header the iOS app flow sends, exactly as sent (see
45
+ # generate_kasada_dv). Optional, iOS app user agents only: the payload is then
46
+ # generated on a device with the screen of the model it names and the iOS
47
+ # release it names, so the two agree.
48
+ self.dv = dv
49
+
44
50
  def to_dict(self):
45
51
  result = {
46
52
  "userAgent": self.user_agent,
@@ -51,6 +57,8 @@ class KasadaPayloadInput:
51
57
  }
52
58
  if self.strict:
53
59
  result["strict"] = True
60
+ if self.dv:
61
+ result["dv"] = self.dv
54
62
  return result
55
63
 
56
64
  class KasadaVersionInput:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyper_sdk
3
- Version: 4.1.0
3
+ Version: 4.2.0
4
4
  Summary: Hyper Solutions Python SDK
5
5
  License: MIT License
6
6
 
@@ -368,6 +368,25 @@ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
368
368
 
369
369
  Available in `hyper_sdk` 3.1.0 and later.
370
370
 
371
+ ### Mobile x-kpsdk-dv Generation
372
+
373
+ On iOS the Kasada SDK (`x-kpsdk-v` i-2.x) also sends an **`x-kpsdk-dv`** header describing the device and the app. Build it from the same values as the user-agent, plus the model identifier, and pass the same value as `dv` on the payload request so the payload is generated on an iPhone with that model's screen and iOS version:
374
+
375
+ ```python
376
+ from hyper_sdk import KasadaPayloadInput, generate_kasada_dv, generate_kasada_user_agent
377
+
378
+ user_agent = generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0")
379
+ dv = generate_kasada_dv("18.0.1", "iPhone13,2", "com.example.app", "9.15.0")
380
+ # hardware_id is the model identifier from utsname.machine ("iPhone13,2" is an iPhone 12)
381
+
382
+ result = session.generate_kasada_payload(KasadaPayloadInput(
383
+ user_agent, ips_link, script, "en-US,en;q=0.9", ip,
384
+ dv=dv, # the x-kpsdk-dv value you send to the site
385
+ ))
386
+ ```
387
+
388
+ Available in `hyper_sdk` 4.2.0 and later.
389
+
371
390
  ## 🎯 DataDome Solutions
372
391
 
373
392
  Solve **DataDome captchas** including slider challenges and interstitial pages.
@@ -28,8 +28,10 @@ hyper_sdk/incapsula/__init__.py
28
28
  hyper_sdk/incapsula/dynamic.py
29
29
  hyper_sdk/incapsula/utmvc.py
30
30
  hyper_sdk/kasada/__init__.py
31
+ hyper_sdk/kasada/dv.py
31
32
  hyper_sdk/kasada/parse.py
32
33
  hyper_sdk/kasada/user_agent.py
34
+ tests/test_dv.py
33
35
  tests/test_results.py
34
36
  tests/test_script_hash.py
35
37
  tests/test_user_agent.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyper_sdk"
7
- version = "4.1.0"
7
+ version = "4.2.0"
8
8
  description = "Hyper Solutions Python SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -0,0 +1,25 @@
1
+ import unittest
2
+
3
+ from hyper_sdk import KasadaPayloadInput, generate_kasada_dv, generate_kasada_user_agent
4
+
5
+
6
+ class KasadaDv(unittest.TestCase):
7
+ # A user-agent and dv built from one set of inputs, in the four-field form the i-2.x iOS SDK sends.
8
+ def test_matches_documented_vector(self):
9
+ self.assertEqual(
10
+ generate_kasada_dv("18.0.1", "iPhone13,2", "com.example.app", "9.15.0"),
11
+ "QkZWEmcDRUBEDloaAg8FDhpTAwhEGxFFWRFcQAVCVHFXFAlBUDRRDl8DBgABUxYUGkxERn0HDwNEVFxAFgZAVglAXV0dV0MTG0gbAEEWYVZfEl1XVg8OFA1NHAxIBxFQ",
12
+ )
13
+ self.assertEqual(
14
+ generate_kasada_user_agent("18.0.1", "com.example.app", "9.15.0"),
15
+ "7016adc4ba8d433533954ebad33be424",
16
+ )
17
+
18
+ def test_payload_input_sends_dv_only_when_set(self):
19
+ base = ("ua", "https://example.com/ips.js", "script", "en-US", "203.0.113.7")
20
+ self.assertNotIn("dv", KasadaPayloadInput(*base).to_dict())
21
+ self.assertEqual(KasadaPayloadInput(*base, dv="abc").to_dict()["dv"], "abc")
22
+
23
+
24
+ if __name__ == "__main__":
25
+ unittest.main()
File without changes
File without changes
File without changes