hyper-sdk 2.3.0__tar.gz → 2.4.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.
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/PKG-INFO +1 -1
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/session.py +43 -55
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk.egg-info/PKG-INFO +1 -1
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/pyproject.toml +1 -1
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/LICENSE +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/README.md +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/__init__.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/akamai/__init__.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/akamai/pixel.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/akamai/script_path.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/akamai/sec_cpt.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/akamai/stop_signal.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/akamai_input.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/datadome/__init__.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/datadome/parse.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/datadome_input.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/incapsula/__init__.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/incapsula/dynamic.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/incapsula/utmvc.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/incapsula_input.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/kasada/__init__.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/kasada/parse.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/kasada_input.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk/trustdecision_input.py +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk.egg-info/SOURCES.txt +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk.egg-info/dependency_links.txt +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk.egg-info/requires.txt +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/hyper_sdk.egg-info/top_level.txt +0 -0
- {hyper_sdk-2.3.0 → hyper_sdk-2.4.1}/setup.cfg +0 -0
|
@@ -13,9 +13,12 @@ from .trustdecision_input import PayloadInput, DecodeInput, SignatureInput
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class Session:
|
|
16
|
-
def __init__(self, api_key: str, jwt_key: Optional[str] = None,
|
|
16
|
+
def __init__(self, api_key: str, jwt_key: Optional[str] = None, app_key: Optional[str] = None,
|
|
17
|
+
app_secret: Optional[str] = None, client: Optional[requests.Session] = None) -> None:
|
|
17
18
|
self.api_key = api_key
|
|
18
19
|
self.jwt_key = jwt_key
|
|
20
|
+
self.app_key = app_key
|
|
21
|
+
self.app_secret = app_secret
|
|
19
22
|
self.client = requests.Session() if client is None else client
|
|
20
23
|
|
|
21
24
|
def generate_sensor_data(self, input_data: SensorInput) -> tuple[str, str]:
|
|
@@ -33,15 +36,7 @@ class Session:
|
|
|
33
36
|
if not self.api_key:
|
|
34
37
|
raise ValueError("Missing API key")
|
|
35
38
|
|
|
36
|
-
headers =
|
|
37
|
-
'Content-Type': 'application/json',
|
|
38
|
-
'Accept-Encoding': 'gzip',
|
|
39
|
-
'X-Api-Key': self.api_key
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if self.jwt_key:
|
|
43
|
-
signature = self.generate_signature()
|
|
44
|
-
headers['X-Signature'] = signature
|
|
39
|
+
headers = self._build_headers()
|
|
45
40
|
|
|
46
41
|
response = self.client.post(sensor_endpoint, headers=headers, json={
|
|
47
42
|
'userAgent': input_data.user_agent,
|
|
@@ -64,7 +59,7 @@ class Session:
|
|
|
64
59
|
if response.status_code != 200:
|
|
65
60
|
raise Exception(f"API returned with status code: {response.status_code}")
|
|
66
61
|
|
|
67
|
-
return response_data["payload"], response_data
|
|
62
|
+
return response_data["payload"], response_data.get("context", "")
|
|
68
63
|
|
|
69
64
|
def generate_sbsd_data(self, input_data: SbsdInput) -> str:
|
|
70
65
|
"""
|
|
@@ -171,15 +166,7 @@ class Session:
|
|
|
171
166
|
if not self.api_key:
|
|
172
167
|
raise ValueError("Missing API key")
|
|
173
168
|
|
|
174
|
-
headers =
|
|
175
|
-
'Content-Type': 'application/json',
|
|
176
|
-
'Accept-Encoding': 'gzip',
|
|
177
|
-
'X-Api-Key': self.api_key
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if self.jwt_key:
|
|
181
|
-
signature = self.generate_signature()
|
|
182
|
-
headers['X-Signature'] = signature
|
|
169
|
+
headers = self._build_headers()
|
|
183
170
|
|
|
184
171
|
response = self.client.post("https://incapsula.hypersolutions.co/utmvc", headers=headers, json={
|
|
185
172
|
'userAgent': input_data.user_agent,
|
|
@@ -223,17 +210,10 @@ class Session:
|
|
|
223
210
|
if not self.api_key:
|
|
224
211
|
raise ValueError("Missing API key")
|
|
225
212
|
|
|
226
|
-
headers =
|
|
227
|
-
'Content-Type': 'application/json',
|
|
228
|
-
'Accept-Encoding': 'gzip',
|
|
229
|
-
'X-Api-Key': self.api_key
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if self.jwt_key:
|
|
233
|
-
signature = self.generate_signature()
|
|
234
|
-
headers['X-Signature'] = signature
|
|
213
|
+
headers = self._build_headers()
|
|
235
214
|
|
|
236
|
-
response = self.client.post("https://kasada.hypersolutions.co/payload", headers=headers,
|
|
215
|
+
response = self.client.post("https://kasada.hypersolutions.co/payload", headers=headers,
|
|
216
|
+
json=input_data.to_dict())
|
|
237
217
|
|
|
238
218
|
response_data = response.json()
|
|
239
219
|
|
|
@@ -303,14 +283,7 @@ class Session:
|
|
|
303
283
|
if not self.api_key:
|
|
304
284
|
raise ValueError("Missing API key")
|
|
305
285
|
|
|
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
|
|
286
|
+
headers = self._build_headers()
|
|
314
287
|
|
|
315
288
|
response = self.client.post("https://trustdecision.hypersolutions.co/payload", headers=headers, json={
|
|
316
289
|
'userAgent': input_data.user_agent,
|
|
@@ -363,15 +336,31 @@ class Session:
|
|
|
363
336
|
'path': input_data.path,
|
|
364
337
|
})
|
|
365
338
|
|
|
366
|
-
def generate_signature(self) -> str:
|
|
339
|
+
def generate_signature(self, key: str, secret: str) -> str:
|
|
340
|
+
"""
|
|
341
|
+
Generates a JWT signature using the provided key and secret.
|
|
342
|
+
|
|
343
|
+
Args:
|
|
344
|
+
key (str): The key to include in the JWT claims
|
|
345
|
+
secret (str): The secret used to sign the JWT
|
|
346
|
+
|
|
347
|
+
Returns:
|
|
348
|
+
str: The generated JWT token
|
|
349
|
+
"""
|
|
367
350
|
claims = {
|
|
368
|
-
"key":
|
|
351
|
+
"key": key,
|
|
369
352
|
"exp": datetime.now(timezone.utc) + timedelta(seconds=60)
|
|
370
353
|
}
|
|
371
|
-
token = jwt.encode(claims,
|
|
354
|
+
token = jwt.encode(claims, secret, algorithm='HS256')
|
|
372
355
|
return token.decode('utf-8') if type(token) == bytes else token
|
|
373
356
|
|
|
374
|
-
def
|
|
357
|
+
def _build_headers(self) -> Dict[str, str]:
|
|
358
|
+
"""
|
|
359
|
+
Builds the headers dictionary including organization credentials if available.
|
|
360
|
+
|
|
361
|
+
Returns:
|
|
362
|
+
Dict[str, str]: Headers dictionary with all required authentication headers
|
|
363
|
+
"""
|
|
375
364
|
if not self.api_key:
|
|
376
365
|
raise ValueError("Missing API key")
|
|
377
366
|
|
|
@@ -382,9 +371,19 @@ class Session:
|
|
|
382
371
|
}
|
|
383
372
|
|
|
384
373
|
if self.jwt_key:
|
|
385
|
-
signature = self.generate_signature()
|
|
374
|
+
signature = self.generate_signature(self.api_key, self.jwt_key)
|
|
386
375
|
headers['X-Signature'] = signature
|
|
387
376
|
|
|
377
|
+
if self.app_key and self.app_secret:
|
|
378
|
+
app_signature = self.generate_signature(self.app_key, self.app_secret)
|
|
379
|
+
headers['X-App-Signature'] = app_signature
|
|
380
|
+
headers['X-App-Key'] = self.app_key
|
|
381
|
+
|
|
382
|
+
return headers
|
|
383
|
+
|
|
384
|
+
def _send_request(self, url: str, input_data: Dict[str, Any]) -> str:
|
|
385
|
+
headers = self._build_headers()
|
|
386
|
+
|
|
388
387
|
response = self.client.post(url, headers=headers, json=input_data)
|
|
389
388
|
|
|
390
389
|
response_data = response.json()
|
|
@@ -398,18 +397,7 @@ class Session:
|
|
|
398
397
|
return response_data["payload"]
|
|
399
398
|
|
|
400
399
|
def _send_request_with_headers(self, url: str, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
401
|
-
|
|
402
|
-
raise ValueError("Missing API key")
|
|
403
|
-
|
|
404
|
-
headers = {
|
|
405
|
-
'Content-Type': 'application/json',
|
|
406
|
-
'Accept-Encoding': 'gzip',
|
|
407
|
-
'X-Api-Key': self.api_key
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if self.jwt_key:
|
|
411
|
-
signature = self.generate_signature()
|
|
412
|
-
headers['X-Signature'] = signature
|
|
400
|
+
headers = self._build_headers()
|
|
413
401
|
|
|
414
402
|
response = self.client.post(url, headers=headers, json=input_data)
|
|
415
403
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|