hyper-sdk 0.1.0__tar.gz → 0.1.2__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-0.1.0 → hyper_sdk-0.1.2}/PKG-INFO +3 -3
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/README.md +2 -2
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/akamai/sec_cpt.py +22 -9
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/session.py +1 -1
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk.egg-info/PKG-INFO +3 -3
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/pyproject.toml +1 -1
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/LICENSE +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/__init__.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/akamai/__init__.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/akamai/pixel.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/akamai/script_path.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/akamai/stop_signal.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/akamai_input.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/incapsula/__init__.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/incapsula/utmvc.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk/incapsula_input.py +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk.egg-info/SOURCES.txt +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk.egg-info/dependency_links.txt +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk.egg-info/requires.txt +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/hyper_sdk.egg-info/top_level.txt +0 -0
- {hyper_sdk-0.1.0 → hyper_sdk-0.1.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hyper_sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Hyper Solutions Python SDK
|
|
5
5
|
Project-URL: homepage, https://github.com/Hyper-Solutions/hyper-sdk-py
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -84,7 +84,7 @@ The Akamai package provides functions for handling sec-cpt challenges:
|
|
|
84
84
|
|
|
85
85
|
- `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
|
|
86
86
|
- `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
|
|
87
|
-
- `
|
|
87
|
+
- `sleep`: Sleeps for the duration specified in the sec-cpt challenge.
|
|
88
88
|
|
|
89
89
|
Example usage:
|
|
90
90
|
|
|
@@ -93,7 +93,7 @@ from hyper_sdk.akamai.sec_cpt import SecCptChallenge
|
|
|
93
93
|
|
|
94
94
|
challenge = SecCptChallenge.parse(html_source)
|
|
95
95
|
payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
|
|
96
|
-
challenge.
|
|
96
|
+
challenge.sleep()
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### Validating Cookies
|
|
@@ -65,7 +65,7 @@ The Akamai package provides functions for handling sec-cpt challenges:
|
|
|
65
65
|
|
|
66
66
|
- `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
|
|
67
67
|
- `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
|
|
68
|
-
- `
|
|
68
|
+
- `sleep`: Sleeps for the duration specified in the sec-cpt challenge.
|
|
69
69
|
|
|
70
70
|
Example usage:
|
|
71
71
|
|
|
@@ -74,7 +74,7 @@ from hyper_sdk.akamai.sec_cpt import SecCptChallenge
|
|
|
74
74
|
|
|
75
75
|
challenge = SecCptChallenge.parse(html_source)
|
|
76
76
|
payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
|
|
77
|
-
challenge.
|
|
77
|
+
challenge.sleep()
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
### Validating Cookies
|
|
@@ -3,6 +3,7 @@ import hashlib
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
import re
|
|
6
|
+
import time
|
|
6
7
|
from collections import OrderedDict
|
|
7
8
|
from typing import List
|
|
8
9
|
|
|
@@ -33,6 +34,22 @@ class SecCptChallenge:
|
|
|
33
34
|
|
|
34
35
|
return SecCptChallenge(duration, challenge_path, challenge_data)
|
|
35
36
|
|
|
37
|
+
@staticmethod
|
|
38
|
+
def parse_from_json(json_payload: str) -> 'SecCptChallenge':
|
|
39
|
+
api_response = json.loads(json_payload)
|
|
40
|
+
|
|
41
|
+
challenge_data = SecCptChallengeData(
|
|
42
|
+
api_response.get('token', ''),
|
|
43
|
+
api_response.get('timestamp', 0),
|
|
44
|
+
api_response.get('nonce', ''),
|
|
45
|
+
api_response.get('difficulty', 0)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
duration = api_response.get('chlg_duration', 0)
|
|
49
|
+
challenge_path = api_response.get('branding_url_content', '')
|
|
50
|
+
|
|
51
|
+
return SecCptChallenge(duration, challenge_path, challenge_data)
|
|
52
|
+
|
|
36
53
|
@staticmethod
|
|
37
54
|
def _parse_challenge_data(src: str) -> SecCptChallengeData:
|
|
38
55
|
challenge_match = sec_challenge_expr.search(src)
|
|
@@ -72,6 +89,8 @@ class SecCptChallenge:
|
|
|
72
89
|
|
|
73
90
|
def generate_sec_cpt_payload(self, sec_cpt_cookie: str) -> str:
|
|
74
91
|
sec, _, _ = sec_cpt_cookie.partition("~")
|
|
92
|
+
if sec == sec_cpt_cookie:
|
|
93
|
+
raise Exception("hyper-sdk: Malformed sec_cpt cookie.")
|
|
75
94
|
|
|
76
95
|
answers = self._generate_sec_cpt_answers(sec)
|
|
77
96
|
|
|
@@ -82,14 +101,8 @@ class SecCptChallenge:
|
|
|
82
101
|
|
|
83
102
|
return json.dumps(payload)
|
|
84
103
|
|
|
85
|
-
def
|
|
86
|
-
|
|
87
|
-
self.challenge_data = SecCptChallengeData(
|
|
88
|
-
challenge_data.get('token', ''),
|
|
89
|
-
challenge_data.get('timestamp', 0),
|
|
90
|
-
challenge_data.get('nonce', ''),
|
|
91
|
-
challenge_data.get('difficulty', 0)
|
|
92
|
-
)
|
|
104
|
+
def sleep(self):
|
|
105
|
+
time.sleep(self.duration)
|
|
93
106
|
|
|
94
107
|
def _generate_sec_cpt_answers(self, sec: str) -> List[str]:
|
|
95
108
|
answers = []
|
|
@@ -112,4 +125,4 @@ class SecCptChallenge:
|
|
|
112
125
|
break
|
|
113
126
|
continue
|
|
114
127
|
|
|
115
|
-
return answers
|
|
128
|
+
return answers
|
|
@@ -106,7 +106,7 @@ class Session:
|
|
|
106
106
|
def generate_signature(self) -> str:
|
|
107
107
|
claims = {
|
|
108
108
|
"key": self.api_key,
|
|
109
|
-
"exp": datetime.now(timezone.utc) + timedelta(seconds=
|
|
109
|
+
"exp": datetime.now(timezone.utc) + timedelta(seconds=60)
|
|
110
110
|
}
|
|
111
111
|
token = jwt.encode(claims, self.jwt_key, algorithm='HS256')
|
|
112
112
|
return token.decode('utf-8')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hyper_sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Hyper Solutions Python SDK
|
|
5
5
|
Project-URL: homepage, https://github.com/Hyper-Solutions/hyper-sdk-py
|
|
6
6
|
Classifier: Intended Audience :: Developers
|
|
@@ -84,7 +84,7 @@ The Akamai package provides functions for handling sec-cpt challenges:
|
|
|
84
84
|
|
|
85
85
|
- `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
|
|
86
86
|
- `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
|
|
87
|
-
- `
|
|
87
|
+
- `sleep`: Sleeps for the duration specified in the sec-cpt challenge.
|
|
88
88
|
|
|
89
89
|
Example usage:
|
|
90
90
|
|
|
@@ -93,7 +93,7 @@ from hyper_sdk.akamai.sec_cpt import SecCptChallenge
|
|
|
93
93
|
|
|
94
94
|
challenge = SecCptChallenge.parse(html_source)
|
|
95
95
|
payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
|
|
96
|
-
challenge.
|
|
96
|
+
challenge.sleep()
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### Validating Cookies
|
|
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
|