hyper-sdk 0.3.4__tar.gz → 0.4.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 (30) hide show
  1. hyper_sdk-0.4.0/PKG-INFO +42 -0
  2. hyper_sdk-0.4.0/README.md +23 -0
  3. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/session.py +49 -16
  4. hyper_sdk-0.4.0/hyper_sdk.egg-info/PKG-INFO +42 -0
  5. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/pyproject.toml +1 -1
  6. hyper_sdk-0.3.4/PKG-INFO +0 -290
  7. hyper_sdk-0.3.4/README.md +0 -271
  8. hyper_sdk-0.3.4/hyper_sdk.egg-info/PKG-INFO +0 -290
  9. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/LICENSE +0 -0
  10. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/__init__.py +0 -0
  11. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/akamai/__init__.py +0 -0
  12. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/akamai/pixel.py +0 -0
  13. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/akamai/script_path.py +0 -0
  14. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
  15. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/akamai/stop_signal.py +0 -0
  16. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/akamai_input.py +0 -0
  17. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/datadome/__init__.py +0 -0
  18. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/datadome/parse.py +0 -0
  19. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/datadome_input.py +0 -0
  20. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/incapsula/__init__.py +0 -0
  21. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/incapsula/utmvc.py +0 -0
  22. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/incapsula_input.py +0 -0
  23. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/kasada/__init__.py +0 -0
  24. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/kasada/parse.py +0 -0
  25. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk/kasada_input.py +0 -0
  26. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk.egg-info/SOURCES.txt +0 -0
  27. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
  28. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk.egg-info/requires.txt +0 -0
  29. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/hyper_sdk.egg-info/top_level.txt +0 -0
  30. {hyper_sdk-0.3.4 → hyper_sdk-0.4.0}/setup.cfg +0 -0
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.2
2
+ Name: hyper_sdk
3
+ Version: 0.4.0
4
+ Summary: Hyper Solutions Python SDK
5
+ Project-URL: homepage, https://github.com/Hyper-Solutions/hyper-sdk-py
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: certifi>=2024.2.2
13
+ Requires-Dist: charset-normalizer>=3.3.2
14
+ Requires-Dist: idna>=3.6
15
+ Requires-Dist: jsonpickle>=3.0.3
16
+ Requires-Dist: PyJWT>=2.8.0
17
+ Requires-Dist: requests>=2.31.0
18
+ Requires-Dist: urllib3>=2.2.1
19
+
20
+ # Hyper Solutions SDK for Python
21
+
22
+ ## Installation
23
+
24
+ To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:
25
+
26
+ ```
27
+ pip install hyper-sdk
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ For detailed documentation on how to use the SDK, including examples and API reference, please visit our documentation website:
33
+
34
+ [https://docs.justhyped.dev/](https://docs.justhyped.dev/)
35
+
36
+ ## Contributing
37
+
38
+ If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
39
+
40
+ ## License
41
+
42
+ This SDK is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,23 @@
1
+ # Hyper Solutions SDK for Python
2
+
3
+ ## Installation
4
+
5
+ To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:
6
+
7
+ ```
8
+ pip install hyper-sdk
9
+ ```
10
+
11
+ ## Documentation
12
+
13
+ For detailed documentation on how to use the SDK, including examples and API reference, please visit our documentation website:
14
+
15
+ [https://docs.justhyped.dev/](https://docs.justhyped.dev/)
16
+
17
+ ## Contributing
18
+
19
+ If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
20
+
21
+ ## License
22
+
23
+ This SDK is licensed under the [MIT License](LICENSE).
@@ -194,31 +194,33 @@ class Session:
194
194
 
195
195
  return response_data["payload"], response_data["headers"]
196
196
 
197
- def generate_interstitial_payload(self, input_data: DataDomeInterstitialInput) -> str:
197
+ def generate_interstitial_payload(self, input_data: DataDomeInterstitialInput) -> Dict[str, Any]:
198
198
  """
199
- Returns the DataDome interstitial payload value using the Hyper Solutions API.
199
+ Returns the DataDome interstitial payload value and response headers using the Hyper Solutions API.
200
200
 
201
- Args:
202
- session (Session): An instance of Session to handle the network request.
203
- input_data (DataDomeInterstitialInput): An instance of DataDomeInterstitialInput.
201
+ Args:
202
+ input_data (DataDomeInterstitialInput): An instance of DataDomeInterstitialInput.
204
203
 
205
- Returns:
206
- str: The payload to post to /interstitial/
204
+ Returns:
205
+ Dict[str, Any]: A dictionary containing:
206
+ - payload (str): The payload to post to /interstitial/
207
+ - headers (Dict[str, str]): The response headers
207
208
  """
208
- return self._send_request("https://datadome.justhyped.dev/interstitial", input_data.to_dict())
209
+ return self._send_request_with_headers("https://datadome.justhyped.dev/interstitial", input_data.to_dict())
209
210
 
210
- def generate_slider_payload(self, input_data: DataDomeSliderInput) -> str:
211
+ def generate_slider_payload(self, input_data: DataDomeSliderInput) -> Dict[str, Any]:
211
212
  """
212
- Returns the DataDome Slider URL value using the Hyper Solutions API.
213
+ Returns the DataDome Slider URL value and response headers using the Hyper Solutions API.
213
214
 
214
- Args:
215
- session (Session): An instance of Session to handle the network request.
216
- input_data (DataDomeSliderInput): An instance of DataDomeSliderInput.
215
+ Args:
216
+ input_data (DataDomeSliderInput): An instance of DataDomeSliderInput.
217
217
 
218
- Returns:
219
- str: The URL to make a GET request to and returns a solved datadome cookie.
218
+ Returns:
219
+ Dict[str, Any]: A dictionary containing:
220
+ - payload (str): The URL to make a GET request to for a solved datadome cookie
221
+ - headers (Dict[str, str]): The response headers
220
222
  """
221
- return self._send_request("https://datadome.justhyped.dev/slider", input_data.to_dict())
223
+ return self._send_request_with_headers("https://datadome.justhyped.dev/slider", input_data.to_dict())
222
224
 
223
225
  def generate_tags_payload(self, input_data: DataDomeTagsInput) -> str:
224
226
  """
@@ -266,3 +268,34 @@ class Session:
266
268
  raise Exception(f"API returned with status code: {response.status_code}")
267
269
 
268
270
  return response_data["payload"]
271
+
272
+ def _send_request_with_headers(self, url: str, input_data: Dict[str, Any]) -> Dict[str, Any]:
273
+ if not self.api_key:
274
+ raise ValueError("Missing API key")
275
+
276
+ headers = {
277
+ 'Content-Type': 'application/json',
278
+ 'Accept-Encoding': 'gzip',
279
+ 'X-Api-Key': self.api_key
280
+ }
281
+
282
+ if self.jwt_key:
283
+ signature = self.generate_signature()
284
+ headers['X-Signature'] = signature
285
+
286
+ response = self.client.post(url, headers=headers, json=input_data)
287
+
288
+ response_data = response.json()
289
+
290
+ if "error" in response_data and response_data["error"]:
291
+ raise Exception(f"API returned with error: {response_data['error']}")
292
+
293
+ if response.status_code != 200:
294
+ raise Exception(f"API returned with status code: {response.status_code}")
295
+
296
+ response_headers = dict(response.headers)
297
+
298
+ return {
299
+ "payload": response_data["payload"],
300
+ "headers": response_headers
301
+ }
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.2
2
+ Name: hyper_sdk
3
+ Version: 0.4.0
4
+ Summary: Hyper Solutions Python SDK
5
+ Project-URL: homepage, https://github.com/Hyper-Solutions/hyper-sdk-py
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Requires-Python: >=3.6
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: certifi>=2024.2.2
13
+ Requires-Dist: charset-normalizer>=3.3.2
14
+ Requires-Dist: idna>=3.6
15
+ Requires-Dist: jsonpickle>=3.0.3
16
+ Requires-Dist: PyJWT>=2.8.0
17
+ Requires-Dist: requests>=2.31.0
18
+ Requires-Dist: urllib3>=2.2.1
19
+
20
+ # Hyper Solutions SDK for Python
21
+
22
+ ## Installation
23
+
24
+ To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:
25
+
26
+ ```
27
+ pip install hyper-sdk
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ For detailed documentation on how to use the SDK, including examples and API reference, please visit our documentation website:
33
+
34
+ [https://docs.justhyped.dev/](https://docs.justhyped.dev/)
35
+
36
+ ## Contributing
37
+
38
+ If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
39
+
40
+ ## License
41
+
42
+ This SDK is licensed under the [MIT License](LICENSE).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hyper_sdk"
7
- version = "0.3.4"
7
+ version = "0.4.0"
8
8
  description = "Hyper Solutions Python SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.6"
hyper_sdk-0.3.4/PKG-INFO DELETED
@@ -1,290 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: hyper_sdk
3
- Version: 0.3.4
4
- Summary: Hyper Solutions Python SDK
5
- Project-URL: homepage, https://github.com/Hyper-Solutions/hyper-sdk-py
6
- Classifier: Intended Audience :: Developers
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Programming Language :: Python :: 3
9
- Requires-Python: >=3.6
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: certifi>=2024.2.2
13
- Requires-Dist: charset-normalizer>=3.3.2
14
- Requires-Dist: idna>=3.6
15
- Requires-Dist: jsonpickle>=3.0.3
16
- Requires-Dist: PyJWT>=2.8.0
17
- Requires-Dist: requests>=2.31.0
18
- Requires-Dist: urllib3>=2.2.1
19
-
20
- # Hyper Solutions SDK for Python
21
-
22
- ## Installation
23
-
24
- To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:
25
-
26
- ```
27
- pip install hyper-sdk
28
- ```
29
-
30
- ## Usage
31
-
32
- ### Creating a Session
33
-
34
- To start using the SDK, you need to create a new `Session` instance by providing your API key:
35
-
36
- ```python
37
- from hyper_sdk import Session
38
-
39
- session = Session(api_key="your-api-key")
40
- ```
41
-
42
- You can also optionally set a JWT key and a custom HTTP client:
43
-
44
- ```python
45
- from hyper_sdk import Session
46
-
47
- session = Session(api_key="your-api-key", jwt_key="your-jwt-key", client=custom_http_client)
48
- ```
49
-
50
- ## Akamai
51
-
52
- The Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.
53
-
54
- ### Generating Sensor Data
55
-
56
- To generate sensor data required for generating valid Akamai cookies, use the `generate_sensor_data` method:
57
-
58
- ```python
59
- from hyper_sdk import SensorInput
60
-
61
- sensor_input = SensorInput(
62
- page_url="https://example.com/",
63
- user_agent="your-user-agent",
64
- abck="your-abck-cookie",
65
- bmsz="your-bmsz-cookie",
66
- version="2.0"
67
- )
68
- sensor_data = session.generate_sensor_data(sensor_input)
69
- ```
70
-
71
- ### Parsing Script Path
72
-
73
- To parse the Akamai Bot Manager script path from the given HTML code, use the `parse_script_path` function from the `script_path` module:
74
-
75
- ```python
76
- from hyper_sdk.akamai.script_path import parse_script_path
77
-
78
- script_path = parse_script_path(html_source)
79
- ```
80
-
81
- ### Handling Sec-Cpt Challenges
82
-
83
- The Akamai package provides functions for handling sec-cpt challenges:
84
-
85
- - `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
86
- - `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
87
- - `sleep`: Sleeps for the duration specified in the sec-cpt challenge.
88
-
89
- Example usage:
90
-
91
- ```python
92
- from hyper_sdk.akamai.sec_cpt import SecCptChallenge
93
-
94
- challenge = SecCptChallenge.parse(html_source)
95
- payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
96
- challenge.sleep()
97
- ```
98
-
99
- ### Validating Cookies
100
-
101
- The Akamai package provides functions for validating cookies:
102
-
103
- - `is_cookie_valid`: Determines if the provided `_abck` cookie value is valid based on the given request count.
104
- - `is_cookie_invalidated`: Determines if the current session requires more sensors to be sent.
105
-
106
- Example usage:
107
-
108
- ```python
109
- from hyper_sdk.akamai.stop_signal import is_cookie_valid, is_cookie_invalidated
110
-
111
- is_valid = is_cookie_valid(abck_cookie, request_count)
112
- is_invalidated = is_cookie_invalidated(abck_cookie)
113
- ```
114
-
115
- ### Generating Pixel Data
116
-
117
- To generate pixel data, use the `generate_pixel_data` method:
118
-
119
- ```python
120
- from hyper_sdk import PixelInput
121
-
122
- pixel_input = PixelInput(
123
- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36",
124
- html_var="your-html-var",
125
- script_var="your-script-var"
126
- )
127
- pixel_data = session.generate_pixel_data(pixel_input)
128
- ```
129
-
130
- ### Parsing Pixel Challenges
131
-
132
- The Akamai package provides functions for parsing pixel challenges:
133
-
134
- - `parse_pixel_html_var`: Parses the required pixel challenge variable from the given HTML code.
135
- - `parse_pixel_script_url`: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.
136
- - `parse_pixel_script_var`: Parses the dynamic value from the pixel script.
137
-
138
- Example usage:
139
-
140
- ```python
141
- from hyper_sdk.akamai.pixel import parse_pixel_html_var, parse_pixel_script_url, parse_pixel_script_var
142
-
143
- html_var = parse_pixel_html_var(html_source)
144
- script_url, post_url = parse_pixel_script_url(html_source)
145
- script_var = parse_pixel_script_var(script_source)
146
- ```
147
-
148
-
149
- ## Incapsula
150
-
151
- The Incapsula package provides functions for interacting with Imperva Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.
152
-
153
- ### Generating Reese84 Sensor
154
-
155
- To generate sensor data required for generating valid Reese84 cookies, use the `generate_reese84_sensor` method:
156
-
157
- ```python
158
- sensor_data = session.generate_reese84_sensor(site="example.com", user_agent="your-user-agent")
159
- ```
160
-
161
- ### Generating UTMVC Cookie
162
-
163
- To generate the UTMVC cookie using the Hyper Solutions API, use the `generate_utmvc_cookie` method:
164
-
165
- ```python
166
- from hyper_sdk import UtmvcInput
167
-
168
- utmvc_input = UtmvcInput(
169
- user_agent="your-user-agent",
170
- session_ids=["session-id-1", "session-id-2"],
171
- script="your-script"
172
- )
173
- utmvc_cookie = session.generate_utmvc_cookie(utmvc_input)
174
- ```
175
-
176
- ### Parsing UTMVC Script Path
177
-
178
- To parse the UTMVC script path from a given script content, use the `parse_utmvc_script_path` function from the `utmvc` module:
179
-
180
- ```python
181
- from hyper_sdk.incapsula.utmvc import parse_utmvc_script_path
182
-
183
- script_path = parse_utmvc_script_path(script_content)
184
- ```
185
-
186
- ### Generating UTMVC Submit Path
187
-
188
- To generate a unique UTMVC submit path with a random query parameter, use the `get_utmvc_submit_path` function from the `utmvc` module:
189
-
190
- ```python
191
- from hyper_sdk.incapsula.utmvc import get_utmvc_submit_path
192
-
193
- submit_path = get_utmvc_submit_path()
194
- ```
195
-
196
- ## Kasada
197
-
198
- The Kasada package provides functions for interacting with Kasada Bot Manager, including parsing script path.
199
-
200
- ### Generating Payload Data (CT)
201
-
202
- To generate payload data required for generating valid `x-kpsdk-ct` tokens, use the `generate_kasada_payload` function:
203
-
204
- ```python
205
- payload, headers = hyper_session.generate_kasada_payload(hyper_sdk.KasadaPayloadInput(
206
- user_agent=USER_AGENT,
207
- ips_link=ips_link,
208
- script=ips_script,
209
- language="en-US"
210
- ))
211
- # Use payload and headers for the next request
212
- ```
213
-
214
- ### Generating Pow Data (CD)
215
-
216
- To generate POW data (`x-kpsdk-cd`) tokens, use the `generate_kasada_pow` function:
217
-
218
- ```python
219
- cd = hyper_session.generate_kasada_pow(hyper_sdk.KasadaPowInput(
220
- st=st,
221
- work_time=None
222
- ))
223
- # Use cd as the x-kpsdk-cd header in the next request
224
- ```
225
-
226
- ### Parsing Script Path
227
-
228
- To parse the Kasada script path from the given blocked page (status code 429) HTML code, use the `parse_script_path` function:
229
-
230
- ```python
231
- from hyper_sdk.kasada import parse_script_path
232
-
233
- script_path = parse_script_path(html_content)
234
- # script_path will look like: /ips.js?...
235
- ```
236
-
237
- ## DataDome
238
-
239
- The DataDome package provides functions for interacting with DataDome Bot Manager, including parsing device link URLs
240
- for interstitial and slider challenges.
241
-
242
- ### Generating Interstitial Payload
243
-
244
- To generate payload data required for solving interstitial challenges, use the `generate_interstitial_payload` function:
245
-
246
- ```python
247
- payload = hyper_session.generate_interstitial_payload(hyper_sdk.DataDomeInterstitialInput(
248
- user_agent=USER_AGENT,
249
- device_link=device_check_link,
250
- html=html_content
251
- ))
252
- # Use the payload to POST to https://geo.captcha-delivery.com/interstitial/
253
- ```
254
-
255
- ### Generating Slider Payload
256
-
257
- To solve DataDome Slider challenges, use the `generate_slider_payload` function:
258
-
259
- ```python
260
- payload = hyper_session.generate_slider_payload(hyper_sdk.DataDomeSliderInput(
261
- user_agent=USER_AGENT,
262
- device_link=device_check_link,
263
- html=html_content,
264
- puzzle=base64_encoded_puzzle,
265
- piece=base64_encoded_piece
266
- ))
267
- # Create a GET request to the payload URL
268
- ```
269
-
270
- ### Parsing Interstitial DeviceLink URL
271
-
272
- To parse the Interstitial DeviceLink URL from the HTML code, use the `parse_interstitial_device_check_link` function:
273
-
274
- ```python
275
- from hyper_sdk.datadome import parse_interstitial_device_check_link
276
-
277
- device_link = parse_interstitial_device_check_link(html_content, datadome_cookie, referer)
278
- # device_link will look like: https://geo.captcha-delivery.com/interstitial/?...
279
- ```
280
-
281
- ### Parsing Slider DeviceLink URL
282
-
283
- To parse the Slider DeviceLink URL from the HTML code, use the `parse_slider_device_check_link` function:
284
-
285
- ```python
286
- from hyper_sdk.datadome import parse_slider_device_check_link
287
-
288
- device_link = parse_slider_device_check_link(html_content, datadome_cookie, referer)
289
- # device_link will look like: https://geo.captcha-delivery.com/captcha/?...
290
- ```
hyper_sdk-0.3.4/README.md DELETED
@@ -1,271 +0,0 @@
1
- # Hyper Solutions SDK for Python
2
-
3
- ## Installation
4
-
5
- To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:
6
-
7
- ```
8
- pip install hyper-sdk
9
- ```
10
-
11
- ## Usage
12
-
13
- ### Creating a Session
14
-
15
- To start using the SDK, you need to create a new `Session` instance by providing your API key:
16
-
17
- ```python
18
- from hyper_sdk import Session
19
-
20
- session = Session(api_key="your-api-key")
21
- ```
22
-
23
- You can also optionally set a JWT key and a custom HTTP client:
24
-
25
- ```python
26
- from hyper_sdk import Session
27
-
28
- session = Session(api_key="your-api-key", jwt_key="your-jwt-key", client=custom_http_client)
29
- ```
30
-
31
- ## Akamai
32
-
33
- The Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.
34
-
35
- ### Generating Sensor Data
36
-
37
- To generate sensor data required for generating valid Akamai cookies, use the `generate_sensor_data` method:
38
-
39
- ```python
40
- from hyper_sdk import SensorInput
41
-
42
- sensor_input = SensorInput(
43
- page_url="https://example.com/",
44
- user_agent="your-user-agent",
45
- abck="your-abck-cookie",
46
- bmsz="your-bmsz-cookie",
47
- version="2.0"
48
- )
49
- sensor_data = session.generate_sensor_data(sensor_input)
50
- ```
51
-
52
- ### Parsing Script Path
53
-
54
- To parse the Akamai Bot Manager script path from the given HTML code, use the `parse_script_path` function from the `script_path` module:
55
-
56
- ```python
57
- from hyper_sdk.akamai.script_path import parse_script_path
58
-
59
- script_path = parse_script_path(html_source)
60
- ```
61
-
62
- ### Handling Sec-Cpt Challenges
63
-
64
- The Akamai package provides functions for handling sec-cpt challenges:
65
-
66
- - `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
67
- - `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
68
- - `sleep`: Sleeps for the duration specified in the sec-cpt challenge.
69
-
70
- Example usage:
71
-
72
- ```python
73
- from hyper_sdk.akamai.sec_cpt import SecCptChallenge
74
-
75
- challenge = SecCptChallenge.parse(html_source)
76
- payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
77
- challenge.sleep()
78
- ```
79
-
80
- ### Validating Cookies
81
-
82
- The Akamai package provides functions for validating cookies:
83
-
84
- - `is_cookie_valid`: Determines if the provided `_abck` cookie value is valid based on the given request count.
85
- - `is_cookie_invalidated`: Determines if the current session requires more sensors to be sent.
86
-
87
- Example usage:
88
-
89
- ```python
90
- from hyper_sdk.akamai.stop_signal import is_cookie_valid, is_cookie_invalidated
91
-
92
- is_valid = is_cookie_valid(abck_cookie, request_count)
93
- is_invalidated = is_cookie_invalidated(abck_cookie)
94
- ```
95
-
96
- ### Generating Pixel Data
97
-
98
- To generate pixel data, use the `generate_pixel_data` method:
99
-
100
- ```python
101
- from hyper_sdk import PixelInput
102
-
103
- pixel_input = PixelInput(
104
- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36",
105
- html_var="your-html-var",
106
- script_var="your-script-var"
107
- )
108
- pixel_data = session.generate_pixel_data(pixel_input)
109
- ```
110
-
111
- ### Parsing Pixel Challenges
112
-
113
- The Akamai package provides functions for parsing pixel challenges:
114
-
115
- - `parse_pixel_html_var`: Parses the required pixel challenge variable from the given HTML code.
116
- - `parse_pixel_script_url`: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.
117
- - `parse_pixel_script_var`: Parses the dynamic value from the pixel script.
118
-
119
- Example usage:
120
-
121
- ```python
122
- from hyper_sdk.akamai.pixel import parse_pixel_html_var, parse_pixel_script_url, parse_pixel_script_var
123
-
124
- html_var = parse_pixel_html_var(html_source)
125
- script_url, post_url = parse_pixel_script_url(html_source)
126
- script_var = parse_pixel_script_var(script_source)
127
- ```
128
-
129
-
130
- ## Incapsula
131
-
132
- The Incapsula package provides functions for interacting with Imperva Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.
133
-
134
- ### Generating Reese84 Sensor
135
-
136
- To generate sensor data required for generating valid Reese84 cookies, use the `generate_reese84_sensor` method:
137
-
138
- ```python
139
- sensor_data = session.generate_reese84_sensor(site="example.com", user_agent="your-user-agent")
140
- ```
141
-
142
- ### Generating UTMVC Cookie
143
-
144
- To generate the UTMVC cookie using the Hyper Solutions API, use the `generate_utmvc_cookie` method:
145
-
146
- ```python
147
- from hyper_sdk import UtmvcInput
148
-
149
- utmvc_input = UtmvcInput(
150
- user_agent="your-user-agent",
151
- session_ids=["session-id-1", "session-id-2"],
152
- script="your-script"
153
- )
154
- utmvc_cookie = session.generate_utmvc_cookie(utmvc_input)
155
- ```
156
-
157
- ### Parsing UTMVC Script Path
158
-
159
- To parse the UTMVC script path from a given script content, use the `parse_utmvc_script_path` function from the `utmvc` module:
160
-
161
- ```python
162
- from hyper_sdk.incapsula.utmvc import parse_utmvc_script_path
163
-
164
- script_path = parse_utmvc_script_path(script_content)
165
- ```
166
-
167
- ### Generating UTMVC Submit Path
168
-
169
- To generate a unique UTMVC submit path with a random query parameter, use the `get_utmvc_submit_path` function from the `utmvc` module:
170
-
171
- ```python
172
- from hyper_sdk.incapsula.utmvc import get_utmvc_submit_path
173
-
174
- submit_path = get_utmvc_submit_path()
175
- ```
176
-
177
- ## Kasada
178
-
179
- The Kasada package provides functions for interacting with Kasada Bot Manager, including parsing script path.
180
-
181
- ### Generating Payload Data (CT)
182
-
183
- To generate payload data required for generating valid `x-kpsdk-ct` tokens, use the `generate_kasada_payload` function:
184
-
185
- ```python
186
- payload, headers = hyper_session.generate_kasada_payload(hyper_sdk.KasadaPayloadInput(
187
- user_agent=USER_AGENT,
188
- ips_link=ips_link,
189
- script=ips_script,
190
- language="en-US"
191
- ))
192
- # Use payload and headers for the next request
193
- ```
194
-
195
- ### Generating Pow Data (CD)
196
-
197
- To generate POW data (`x-kpsdk-cd`) tokens, use the `generate_kasada_pow` function:
198
-
199
- ```python
200
- cd = hyper_session.generate_kasada_pow(hyper_sdk.KasadaPowInput(
201
- st=st,
202
- work_time=None
203
- ))
204
- # Use cd as the x-kpsdk-cd header in the next request
205
- ```
206
-
207
- ### Parsing Script Path
208
-
209
- To parse the Kasada script path from the given blocked page (status code 429) HTML code, use the `parse_script_path` function:
210
-
211
- ```python
212
- from hyper_sdk.kasada import parse_script_path
213
-
214
- script_path = parse_script_path(html_content)
215
- # script_path will look like: /ips.js?...
216
- ```
217
-
218
- ## DataDome
219
-
220
- The DataDome package provides functions for interacting with DataDome Bot Manager, including parsing device link URLs
221
- for interstitial and slider challenges.
222
-
223
- ### Generating Interstitial Payload
224
-
225
- To generate payload data required for solving interstitial challenges, use the `generate_interstitial_payload` function:
226
-
227
- ```python
228
- payload = hyper_session.generate_interstitial_payload(hyper_sdk.DataDomeInterstitialInput(
229
- user_agent=USER_AGENT,
230
- device_link=device_check_link,
231
- html=html_content
232
- ))
233
- # Use the payload to POST to https://geo.captcha-delivery.com/interstitial/
234
- ```
235
-
236
- ### Generating Slider Payload
237
-
238
- To solve DataDome Slider challenges, use the `generate_slider_payload` function:
239
-
240
- ```python
241
- payload = hyper_session.generate_slider_payload(hyper_sdk.DataDomeSliderInput(
242
- user_agent=USER_AGENT,
243
- device_link=device_check_link,
244
- html=html_content,
245
- puzzle=base64_encoded_puzzle,
246
- piece=base64_encoded_piece
247
- ))
248
- # Create a GET request to the payload URL
249
- ```
250
-
251
- ### Parsing Interstitial DeviceLink URL
252
-
253
- To parse the Interstitial DeviceLink URL from the HTML code, use the `parse_interstitial_device_check_link` function:
254
-
255
- ```python
256
- from hyper_sdk.datadome import parse_interstitial_device_check_link
257
-
258
- device_link = parse_interstitial_device_check_link(html_content, datadome_cookie, referer)
259
- # device_link will look like: https://geo.captcha-delivery.com/interstitial/?...
260
- ```
261
-
262
- ### Parsing Slider DeviceLink URL
263
-
264
- To parse the Slider DeviceLink URL from the HTML code, use the `parse_slider_device_check_link` function:
265
-
266
- ```python
267
- from hyper_sdk.datadome import parse_slider_device_check_link
268
-
269
- device_link = parse_slider_device_check_link(html_content, datadome_cookie, referer)
270
- # device_link will look like: https://geo.captcha-delivery.com/captcha/?...
271
- ```
@@ -1,290 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: hyper_sdk
3
- Version: 0.3.4
4
- Summary: Hyper Solutions Python SDK
5
- Project-URL: homepage, https://github.com/Hyper-Solutions/hyper-sdk-py
6
- Classifier: Intended Audience :: Developers
7
- Classifier: License :: OSI Approved :: MIT License
8
- Classifier: Programming Language :: Python :: 3
9
- Requires-Python: >=3.6
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: certifi>=2024.2.2
13
- Requires-Dist: charset-normalizer>=3.3.2
14
- Requires-Dist: idna>=3.6
15
- Requires-Dist: jsonpickle>=3.0.3
16
- Requires-Dist: PyJWT>=2.8.0
17
- Requires-Dist: requests>=2.31.0
18
- Requires-Dist: urllib3>=2.2.1
19
-
20
- # Hyper Solutions SDK for Python
21
-
22
- ## Installation
23
-
24
- To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:
25
-
26
- ```
27
- pip install hyper-sdk
28
- ```
29
-
30
- ## Usage
31
-
32
- ### Creating a Session
33
-
34
- To start using the SDK, you need to create a new `Session` instance by providing your API key:
35
-
36
- ```python
37
- from hyper_sdk import Session
38
-
39
- session = Session(api_key="your-api-key")
40
- ```
41
-
42
- You can also optionally set a JWT key and a custom HTTP client:
43
-
44
- ```python
45
- from hyper_sdk import Session
46
-
47
- session = Session(api_key="your-api-key", jwt_key="your-jwt-key", client=custom_http_client)
48
- ```
49
-
50
- ## Akamai
51
-
52
- The Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.
53
-
54
- ### Generating Sensor Data
55
-
56
- To generate sensor data required for generating valid Akamai cookies, use the `generate_sensor_data` method:
57
-
58
- ```python
59
- from hyper_sdk import SensorInput
60
-
61
- sensor_input = SensorInput(
62
- page_url="https://example.com/",
63
- user_agent="your-user-agent",
64
- abck="your-abck-cookie",
65
- bmsz="your-bmsz-cookie",
66
- version="2.0"
67
- )
68
- sensor_data = session.generate_sensor_data(sensor_input)
69
- ```
70
-
71
- ### Parsing Script Path
72
-
73
- To parse the Akamai Bot Manager script path from the given HTML code, use the `parse_script_path` function from the `script_path` module:
74
-
75
- ```python
76
- from hyper_sdk.akamai.script_path import parse_script_path
77
-
78
- script_path = parse_script_path(html_source)
79
- ```
80
-
81
- ### Handling Sec-Cpt Challenges
82
-
83
- The Akamai package provides functions for handling sec-cpt challenges:
84
-
85
- - `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
86
- - `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
87
- - `sleep`: Sleeps for the duration specified in the sec-cpt challenge.
88
-
89
- Example usage:
90
-
91
- ```python
92
- from hyper_sdk.akamai.sec_cpt import SecCptChallenge
93
-
94
- challenge = SecCptChallenge.parse(html_source)
95
- payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
96
- challenge.sleep()
97
- ```
98
-
99
- ### Validating Cookies
100
-
101
- The Akamai package provides functions for validating cookies:
102
-
103
- - `is_cookie_valid`: Determines if the provided `_abck` cookie value is valid based on the given request count.
104
- - `is_cookie_invalidated`: Determines if the current session requires more sensors to be sent.
105
-
106
- Example usage:
107
-
108
- ```python
109
- from hyper_sdk.akamai.stop_signal import is_cookie_valid, is_cookie_invalidated
110
-
111
- is_valid = is_cookie_valid(abck_cookie, request_count)
112
- is_invalidated = is_cookie_invalidated(abck_cookie)
113
- ```
114
-
115
- ### Generating Pixel Data
116
-
117
- To generate pixel data, use the `generate_pixel_data` method:
118
-
119
- ```python
120
- from hyper_sdk import PixelInput
121
-
122
- pixel_input = PixelInput(
123
- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36",
124
- html_var="your-html-var",
125
- script_var="your-script-var"
126
- )
127
- pixel_data = session.generate_pixel_data(pixel_input)
128
- ```
129
-
130
- ### Parsing Pixel Challenges
131
-
132
- The Akamai package provides functions for parsing pixel challenges:
133
-
134
- - `parse_pixel_html_var`: Parses the required pixel challenge variable from the given HTML code.
135
- - `parse_pixel_script_url`: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.
136
- - `parse_pixel_script_var`: Parses the dynamic value from the pixel script.
137
-
138
- Example usage:
139
-
140
- ```python
141
- from hyper_sdk.akamai.pixel import parse_pixel_html_var, parse_pixel_script_url, parse_pixel_script_var
142
-
143
- html_var = parse_pixel_html_var(html_source)
144
- script_url, post_url = parse_pixel_script_url(html_source)
145
- script_var = parse_pixel_script_var(script_source)
146
- ```
147
-
148
-
149
- ## Incapsula
150
-
151
- The Incapsula package provides functions for interacting with Imperva Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.
152
-
153
- ### Generating Reese84 Sensor
154
-
155
- To generate sensor data required for generating valid Reese84 cookies, use the `generate_reese84_sensor` method:
156
-
157
- ```python
158
- sensor_data = session.generate_reese84_sensor(site="example.com", user_agent="your-user-agent")
159
- ```
160
-
161
- ### Generating UTMVC Cookie
162
-
163
- To generate the UTMVC cookie using the Hyper Solutions API, use the `generate_utmvc_cookie` method:
164
-
165
- ```python
166
- from hyper_sdk import UtmvcInput
167
-
168
- utmvc_input = UtmvcInput(
169
- user_agent="your-user-agent",
170
- session_ids=["session-id-1", "session-id-2"],
171
- script="your-script"
172
- )
173
- utmvc_cookie = session.generate_utmvc_cookie(utmvc_input)
174
- ```
175
-
176
- ### Parsing UTMVC Script Path
177
-
178
- To parse the UTMVC script path from a given script content, use the `parse_utmvc_script_path` function from the `utmvc` module:
179
-
180
- ```python
181
- from hyper_sdk.incapsula.utmvc import parse_utmvc_script_path
182
-
183
- script_path = parse_utmvc_script_path(script_content)
184
- ```
185
-
186
- ### Generating UTMVC Submit Path
187
-
188
- To generate a unique UTMVC submit path with a random query parameter, use the `get_utmvc_submit_path` function from the `utmvc` module:
189
-
190
- ```python
191
- from hyper_sdk.incapsula.utmvc import get_utmvc_submit_path
192
-
193
- submit_path = get_utmvc_submit_path()
194
- ```
195
-
196
- ## Kasada
197
-
198
- The Kasada package provides functions for interacting with Kasada Bot Manager, including parsing script path.
199
-
200
- ### Generating Payload Data (CT)
201
-
202
- To generate payload data required for generating valid `x-kpsdk-ct` tokens, use the `generate_kasada_payload` function:
203
-
204
- ```python
205
- payload, headers = hyper_session.generate_kasada_payload(hyper_sdk.KasadaPayloadInput(
206
- user_agent=USER_AGENT,
207
- ips_link=ips_link,
208
- script=ips_script,
209
- language="en-US"
210
- ))
211
- # Use payload and headers for the next request
212
- ```
213
-
214
- ### Generating Pow Data (CD)
215
-
216
- To generate POW data (`x-kpsdk-cd`) tokens, use the `generate_kasada_pow` function:
217
-
218
- ```python
219
- cd = hyper_session.generate_kasada_pow(hyper_sdk.KasadaPowInput(
220
- st=st,
221
- work_time=None
222
- ))
223
- # Use cd as the x-kpsdk-cd header in the next request
224
- ```
225
-
226
- ### Parsing Script Path
227
-
228
- To parse the Kasada script path from the given blocked page (status code 429) HTML code, use the `parse_script_path` function:
229
-
230
- ```python
231
- from hyper_sdk.kasada import parse_script_path
232
-
233
- script_path = parse_script_path(html_content)
234
- # script_path will look like: /ips.js?...
235
- ```
236
-
237
- ## DataDome
238
-
239
- The DataDome package provides functions for interacting with DataDome Bot Manager, including parsing device link URLs
240
- for interstitial and slider challenges.
241
-
242
- ### Generating Interstitial Payload
243
-
244
- To generate payload data required for solving interstitial challenges, use the `generate_interstitial_payload` function:
245
-
246
- ```python
247
- payload = hyper_session.generate_interstitial_payload(hyper_sdk.DataDomeInterstitialInput(
248
- user_agent=USER_AGENT,
249
- device_link=device_check_link,
250
- html=html_content
251
- ))
252
- # Use the payload to POST to https://geo.captcha-delivery.com/interstitial/
253
- ```
254
-
255
- ### Generating Slider Payload
256
-
257
- To solve DataDome Slider challenges, use the `generate_slider_payload` function:
258
-
259
- ```python
260
- payload = hyper_session.generate_slider_payload(hyper_sdk.DataDomeSliderInput(
261
- user_agent=USER_AGENT,
262
- device_link=device_check_link,
263
- html=html_content,
264
- puzzle=base64_encoded_puzzle,
265
- piece=base64_encoded_piece
266
- ))
267
- # Create a GET request to the payload URL
268
- ```
269
-
270
- ### Parsing Interstitial DeviceLink URL
271
-
272
- To parse the Interstitial DeviceLink URL from the HTML code, use the `parse_interstitial_device_check_link` function:
273
-
274
- ```python
275
- from hyper_sdk.datadome import parse_interstitial_device_check_link
276
-
277
- device_link = parse_interstitial_device_check_link(html_content, datadome_cookie, referer)
278
- # device_link will look like: https://geo.captcha-delivery.com/interstitial/?...
279
- ```
280
-
281
- ### Parsing Slider DeviceLink URL
282
-
283
- To parse the Slider DeviceLink URL from the HTML code, use the `parse_slider_device_check_link` function:
284
-
285
- ```python
286
- from hyper_sdk.datadome import parse_slider_device_check_link
287
-
288
- device_link = parse_slider_device_check_link(html_content, datadome_cookie, referer)
289
- # device_link will look like: https://geo.captcha-delivery.com/captcha/?...
290
- ```
File without changes
File without changes