hyper-sdk 2.2.1__tar.gz → 2.3.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.
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/PKG-INFO +1 -1
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/akamai_input.py +2 -1
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/session.py +80 -2
- hyper_sdk-2.3.0/hyper_sdk/trustdecision_input.py +45 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk.egg-info/PKG-INFO +1 -1
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk.egg-info/SOURCES.txt +1 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/pyproject.toml +1 -1
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/LICENSE +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/README.md +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/__init__.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/akamai/__init__.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/akamai/pixel.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/akamai/script_path.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/akamai/sec_cpt.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/akamai/stop_signal.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/datadome/__init__.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/datadome/parse.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/datadome_input.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/incapsula/__init__.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/incapsula/dynamic.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/incapsula/utmvc.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/incapsula_input.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/kasada/__init__.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/kasada/parse.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk/kasada_input.py +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk.egg-info/dependency_links.txt +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk.egg-info/requires.txt +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/hyper_sdk.egg-info/top_level.txt +0 -0
- {hyper_sdk-2.2.1 → hyper_sdk-2.3.0}/setup.cfg +0 -0
|
@@ -27,7 +27,8 @@ class DynamicInput:
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
class SbsdInput:
|
|
30
|
-
def __init__(self, user_agent: str, uuid: str, page_url: str, o_cookie: str, script: str, acceptLanguage: str, ip: str):
|
|
30
|
+
def __init__(self, index: int, user_agent: str, uuid: str, page_url: str, o_cookie: str, script: str, acceptLanguage: str, ip: str):
|
|
31
|
+
self.index = index
|
|
31
32
|
self.user_agent = user_agent
|
|
32
33
|
self.uuid = uuid
|
|
33
34
|
self.page_url = page_url
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, Dict, Any
|
|
1
|
+
from typing import Optional, Dict, Any, Tuple
|
|
2
2
|
from urllib.parse import quote
|
|
3
3
|
|
|
4
4
|
import requests
|
|
@@ -9,6 +9,7 @@ from .akamai_input import SensorInput, PixelInput, DynamicInput, SbsdInput
|
|
|
9
9
|
from .kasada_input import KasadaPowInput, KasadaPayloadInput
|
|
10
10
|
from .datadome_input import DataDomeSliderInput, DataDomeInterstitialInput, DataDomeTagsInput
|
|
11
11
|
from .incapsula_input import UtmvcInput, ReeseInput
|
|
12
|
+
from .trustdecision_input import PayloadInput, DecodeInput, SignatureInput
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class Session:
|
|
@@ -84,6 +85,7 @@ class Session:
|
|
|
84
85
|
'script': input_data.script,
|
|
85
86
|
'acceptLanguage': input_data.acceptLanguage,
|
|
86
87
|
'ip': input_data.ip,
|
|
88
|
+
'index': input_data.index,
|
|
87
89
|
})
|
|
88
90
|
|
|
89
91
|
def parse_v3_dynamic(self, input_data: DynamicInput) -> str:
|
|
@@ -195,7 +197,6 @@ class Session:
|
|
|
195
197
|
|
|
196
198
|
return response_data["payload"], response_data["swhanedl"]
|
|
197
199
|
|
|
198
|
-
|
|
199
200
|
def generate_kasada_pow(self, input_data: KasadaPowInput) -> str:
|
|
200
201
|
"""
|
|
201
202
|
Returns the x-kpsdk-cd value using the Hyper Solutions API.
|
|
@@ -285,6 +286,83 @@ class Session:
|
|
|
285
286
|
"""
|
|
286
287
|
return self._send_request("https://datadome.hypersolutions.co/tags", input_data.to_dict())
|
|
287
288
|
|
|
289
|
+
def generate_trustdecision_payload(self, input_data: PayloadInput) -> Tuple[str, str, str]:
|
|
290
|
+
"""
|
|
291
|
+
Generates TrustDecision payload that should be posted to TrustDecision's fingerprinting endpoint.
|
|
292
|
+
Also returns timezone and clientId required for subsequent operations.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
input_data (PayloadInput): An instance of PayloadInput containing the necessary data for generating the payload.
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
Tuple[str, str, str]: A tuple containing:
|
|
299
|
+
- payload (str): The generated TrustDecision payload for posting to the fingerprinting endpoint
|
|
300
|
+
- timeZone (str): The timezone to use in the tz header for subsequent requests
|
|
301
|
+
- clientId (str): The client ID required for generating session signatures
|
|
302
|
+
"""
|
|
303
|
+
if not self.api_key:
|
|
304
|
+
raise ValueError("Missing API key")
|
|
305
|
+
|
|
306
|
+
headers = {
|
|
307
|
+
'Content-Type': 'application/json',
|
|
308
|
+
'x-api-key': self.api_key
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if self.jwt_key:
|
|
312
|
+
signature = self.generate_signature()
|
|
313
|
+
headers['x-signature'] = signature
|
|
314
|
+
|
|
315
|
+
response = self.client.post("https://trustdecision.hypersolutions.co/payload", headers=headers, json={
|
|
316
|
+
'userAgent': input_data.user_agent,
|
|
317
|
+
'pageUrl': input_data.page_url,
|
|
318
|
+
'fpUrl': input_data.fp_url,
|
|
319
|
+
'ip': input_data.ip,
|
|
320
|
+
'acceptLanguage': input_data.accept_language,
|
|
321
|
+
'script': input_data.script,
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
response_data = response.json()
|
|
325
|
+
|
|
326
|
+
if "error" in response_data and response_data["error"]:
|
|
327
|
+
raise Exception(f"API returned with error: {response_data['error']}")
|
|
328
|
+
|
|
329
|
+
if response.status_code != 200:
|
|
330
|
+
raise Exception(f"API returned with status code: {response.status_code}")
|
|
331
|
+
|
|
332
|
+
return response_data["payload"], response_data["timeZone"], response_data["clientId"]
|
|
333
|
+
|
|
334
|
+
def decode_trustdecision_session_key(self, input_data: DecodeInput) -> str:
|
|
335
|
+
"""
|
|
336
|
+
Decodes the result and requestId from TrustDecision's fingerprinting endpoint
|
|
337
|
+
to generate the td-session-key header value.
|
|
338
|
+
|
|
339
|
+
Args:
|
|
340
|
+
input_data (DecodeInput): An instance of DecodeInput containing the result and requestId.
|
|
341
|
+
|
|
342
|
+
Returns:
|
|
343
|
+
str: The decoded session key value for use in the td-session-key header
|
|
344
|
+
"""
|
|
345
|
+
return self._send_request("https://trustdecision.hypersolutions.co/decode", {
|
|
346
|
+
'result': input_data.result,
|
|
347
|
+
'requestId': input_data.request_id,
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
def generate_trustdecision_signature(self, input_data: SignatureInput) -> str:
|
|
351
|
+
"""
|
|
352
|
+
Generates a unique td-session-sign header value for each API request.
|
|
353
|
+
This signature can only be used once and must be regenerated for every request.
|
|
354
|
+
|
|
355
|
+
Args:
|
|
356
|
+
input_data (SignatureInput): An instance of SignatureInput containing the clientId and path.
|
|
357
|
+
|
|
358
|
+
Returns:
|
|
359
|
+
str: The generated signature value for use in the td-session-sign header (single-use only)
|
|
360
|
+
"""
|
|
361
|
+
return self._send_request("https://trustdecision.hypersolutions.co/sign", {
|
|
362
|
+
'clientId': input_data.client_id,
|
|
363
|
+
'path': input_data.path,
|
|
364
|
+
})
|
|
365
|
+
|
|
288
366
|
def generate_signature(self) -> str:
|
|
289
367
|
claims = {
|
|
290
368
|
"key": self.api_key,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
class PayloadInput:
|
|
2
|
+
def __init__(self, user_agent: str, page_url: str, fp_url: str, ip: str, accept_language: str, script: str):
|
|
3
|
+
"""
|
|
4
|
+
Creates a new PayloadInput instance for generating TrustDecision payloads.
|
|
5
|
+
|
|
6
|
+
Args:
|
|
7
|
+
user_agent (str): The userAgent that you're using for the entire session
|
|
8
|
+
page_url (str): The target page URL where TrustDecision protection is active
|
|
9
|
+
fp_url (str): The td-fp URL where the payload is posted
|
|
10
|
+
ip (str): The IP address that will be used to post the sensor data to the target site
|
|
11
|
+
accept_language (str): Your accept-language header value
|
|
12
|
+
script (str): The TrustDecision fingerprinting script source code obtained from the fm.js endpoint
|
|
13
|
+
"""
|
|
14
|
+
self.user_agent = user_agent
|
|
15
|
+
self.page_url = page_url
|
|
16
|
+
self.fp_url = fp_url
|
|
17
|
+
self.ip = ip
|
|
18
|
+
self.accept_language = accept_language
|
|
19
|
+
self.script = script
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DecodeInput:
|
|
23
|
+
def __init__(self, result: str, request_id: str):
|
|
24
|
+
"""
|
|
25
|
+
Creates a new DecodeInput instance for decoding TrustDecision session keys.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
result (str): The result field from TrustDecision's fingerprinting endpoint response
|
|
29
|
+
request_id (str): The requestId field from TrustDecision's fingerprinting endpoint response
|
|
30
|
+
"""
|
|
31
|
+
self.result = result
|
|
32
|
+
self.request_id = request_id
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SignatureInput:
|
|
36
|
+
def __init__(self, client_id: str, path: str):
|
|
37
|
+
"""
|
|
38
|
+
Creates a new SignatureInput instance for generating TrustDecision session signatures.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
client_id (str): The client ID returned from the payload generation endpoint
|
|
42
|
+
path (str): The API endpoint path that will be called. This should match the value used in the td-session-path header of your actual request.
|
|
43
|
+
"""
|
|
44
|
+
self.client_id = client_id
|
|
45
|
+
self.path = path
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|