hyper-sdk 0.9.1__tar.gz → 0.10.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 (29) hide show
  1. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/PKG-INFO +1 -1
  2. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/__init__.py +1 -0
  3. hyper_sdk-0.10.0/hyper_sdk/incapsula/__init__.py +2 -0
  4. hyper_sdk-0.10.0/hyper_sdk/incapsula/dynamic.py +48 -0
  5. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk.egg-info/PKG-INFO +1 -1
  6. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk.egg-info/SOURCES.txt +1 -0
  7. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/pyproject.toml +1 -1
  8. hyper_sdk-0.9.1/hyper_sdk/incapsula/__init__.py +0 -1
  9. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/LICENSE +0 -0
  10. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/README.md +0 -0
  11. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/akamai/__init__.py +0 -0
  12. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/akamai/pixel.py +0 -0
  13. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/akamai/script_path.py +0 -0
  14. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
  15. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/akamai/stop_signal.py +0 -0
  16. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/akamai_input.py +0 -0
  17. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/datadome/__init__.py +0 -0
  18. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/datadome/parse.py +0 -0
  19. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/datadome_input.py +0 -0
  20. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/incapsula/utmvc.py +0 -0
  21. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/incapsula_input.py +0 -0
  22. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/kasada/__init__.py +0 -0
  23. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/kasada/parse.py +0 -0
  24. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/kasada_input.py +0 -0
  25. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk/session.py +0 -0
  26. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
  27. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk.egg-info/requires.txt +0 -0
  28. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/hyper_sdk.egg-info/top_level.txt +0 -0
  29. {hyper_sdk-0.9.1 → hyper_sdk-0.10.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyper_sdk
3
- Version: 0.9.1
3
+ Version: 0.10.0
4
4
  Summary: Hyper Solutions Python SDK
5
5
  License: MIT License
6
6
 
@@ -3,6 +3,7 @@ from .akamai.script_path import *
3
3
  from .akamai.sec_cpt import *
4
4
  from .akamai.stop_signal import *
5
5
  from .incapsula.utmvc import *
6
+ from .incapsula.dynamic import *
6
7
  from .session import *
7
8
  from .kasada.parse import *
8
9
  from .datadome.parse import *
@@ -0,0 +1,2 @@
1
+ from .utmvc import *
2
+ from .dynamic import *
@@ -0,0 +1,48 @@
1
+ import re
2
+ from urllib.parse import urlparse
3
+
4
+ # Precompiled regular expressions
5
+ reese_script_regex = re.compile(r'src\s*=\s*"((/[^/]+/\d+)(?:\?.*)?)"')
6
+
7
+
8
+ def parse_dynamic_reese_script(html_content: str, url_str: str) -> tuple[str, str]:
9
+ """
10
+ Parses the sensor path and script path from the given HTML content.
11
+
12
+ This function searches the provided HTML for a script element containing a specific pattern
13
+ and extracts both the sensor path (shortened path) and script path (the full path).
14
+ It requires that the HTML contains "Pardon Our Interruption" to confirm it's the correct page type.
15
+ It also takes a URL string, extracts the hostname, and appends it to the sensor path.
16
+
17
+ Args:
18
+ html_content (str): The HTML content to parse.
19
+ url_str (str): The URL string to extract the hostname from.
20
+
21
+ Returns:
22
+ tuple[str, str]: A tuple containing the sensor path (with hostname) and script path.
23
+
24
+ Raises:
25
+ ValueError: If the URL is invalid.
26
+ Exception: If the page is not an interruption page or if the Reese script is not found.
27
+ """
28
+ # Parse the URL to extract hostname
29
+ try:
30
+ parsed_url = urlparse(url_str)
31
+ hostname = parsed_url.netloc
32
+ except Exception:
33
+ raise ValueError("hyper-sdk: invalid URL")
34
+
35
+ # Verify this is an interruption page
36
+ if "Pardon Our Interruption" not in html_content:
37
+ raise Exception("hyper-sdk: not an interruption page")
38
+
39
+ # Find the Reese script
40
+ match = reese_script_regex.search(html_content)
41
+ if not match or len(match.groups()) < 2:
42
+ raise Exception("hyper-sdk: reese script not found")
43
+
44
+ script_path = match.group(1)
45
+ sensor_path = match.group(2)
46
+
47
+ # Append the hostname to the sensor path
48
+ return f"{sensor_path}?d={hostname}", script_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hyper_sdk
3
- Version: 0.9.1
3
+ Version: 0.10.0
4
4
  Summary: Hyper Solutions Python SDK
5
5
  License: MIT License
6
6
 
@@ -20,6 +20,7 @@ hyper_sdk/akamai/stop_signal.py
20
20
  hyper_sdk/datadome/__init__.py
21
21
  hyper_sdk/datadome/parse.py
22
22
  hyper_sdk/incapsula/__init__.py
23
+ hyper_sdk/incapsula/dynamic.py
23
24
  hyper_sdk/incapsula/utmvc.py
24
25
  hyper_sdk/kasada/__init__.py
25
26
  hyper_sdk/kasada/parse.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyper_sdk"
7
- version = "0.9.1"
7
+ version = "0.10.0"
8
8
  description = "Hyper Solutions Python SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6"
@@ -1 +0,0 @@
1
- from .utmvc import *
File without changes
File without changes
File without changes