init-data-py 0.2.0__tar.gz → 0.2.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.
- {init_data_py-0.2.0 → init_data_py-0.2.2}/PKG-INFO +1 -1
- {init_data_py-0.2.0 → init_data_py-0.2.2}/pyproject.toml +1 -1
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/__init__.py +1 -1
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/init_data.py +2 -2
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/types/object.py +3 -1
- {init_data_py-0.2.0 → init_data_py-0.2.2}/tests/test_validate.py +8 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/.github/workflows/publish.yml +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/.gitignore +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/.python-version +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/LICENCE +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/README.md +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/requirements-dev.lock +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/requirements.lock +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/errors/__init__.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/errors/errors.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/types/__init__.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/types/chat.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/src/init_data_py/types/user.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/tests/__init__.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/tests/test_parse.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/tests/test_sign.py +0 -0
- {init_data_py-0.2.0 → init_data_py-0.2.2}/tests/test_to_query_string.py +0 -0
|
@@ -113,7 +113,7 @@ class InitData:
|
|
|
113
113
|
|
|
114
114
|
if lifetime is not None:
|
|
115
115
|
auth_date = datetime.fromtimestamp(self.auth_date)
|
|
116
|
-
expire_date = auth_date
|
|
116
|
+
expire_date = auth_date + timedelta(seconds=lifetime)
|
|
117
117
|
if datetime.now() > expire_date:
|
|
118
118
|
if raise_error:
|
|
119
119
|
raise errors.ExpiredError()
|
|
@@ -246,7 +246,7 @@ class InitData:
|
|
|
246
246
|
|
|
247
247
|
def to_json(self):
|
|
248
248
|
"""Returns a JSON serialized representation of the object."""
|
|
249
|
-
return json.dumps(self.to_dict(nested=True))
|
|
249
|
+
return json.dumps(self.to_dict(nested=True), ensure_ascii=False)
|
|
250
250
|
|
|
251
251
|
def to_dict(self, nested=True):
|
|
252
252
|
"""Returns a dictionary representation of the object.
|
|
@@ -4,7 +4,9 @@ import json
|
|
|
4
4
|
class Object:
|
|
5
5
|
def to_json(self):
|
|
6
6
|
"""Returns a JSON serialized representation of the object."""
|
|
7
|
-
return json.dumps(
|
|
7
|
+
return json.dumps(
|
|
8
|
+
self.to_dict(), separators=(",", ":"), ensure_ascii=False
|
|
9
|
+
)
|
|
8
10
|
|
|
9
11
|
def to_dict(self):
|
|
10
12
|
"""Returns a dictionary representation of the object."""
|
|
@@ -21,6 +21,14 @@ class TestValidateInitData(unittest.TestCase):
|
|
|
21
21
|
)
|
|
22
22
|
self.bot_token = "7244657541:AAEgqk0HDC3WD5cdbnGMdd6L0TJ74FDp97Y"
|
|
23
23
|
|
|
24
|
+
self.utf8_qs = "query_id=AAF2GVE4AwAAAHYZUTgHczdc&user=%7B%22id%22%3A7387289974%2C%22first_name%22%3A%22%D0%90%D1%80%D1%82%D1%91%D0%BC%22%2C%22last_name%22%3A%22%D0%9E%D0%BD%D1%83%D1%84%D1%80%D0%B8%D0%B9%22%2C%22username%22%3A%22typexin%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%7D&auth_date=1724048856&hash=53b22bc70a748dae613a5aa91890b387b9cc0356c5dcffca173816b6e40a17e5"
|
|
25
|
+
|
|
26
|
+
def test_utf8_support(self):
|
|
27
|
+
query_string = "query_id=AAF2GVE4AwAAAHYZUTgHczdc&user=%7B%22id%22%3A7387289974%2C%22first_name%22%3A%22%D0%90%D1%80%D1%82%D1%91%D0%BC%22%2C%22last_name%22%3A%22%D0%9E%D0%BD%D1%83%D1%84%D1%80%D0%B8%D0%B9%22%2C%22username%22%3A%22typexin%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%7D&auth_date=1724048856&hash=53b22bc70a748dae613a5aa91890b387b9cc0356c5dcffca173816b6e40a17e5"
|
|
28
|
+
bot_token = "7244657541:AAHAJP25XehV6N02kiLLAEi2el-xLsSw29w"
|
|
29
|
+
init_data = InitData.parse(query_string)
|
|
30
|
+
self.assertTrue(init_data.validate(bot_token))
|
|
31
|
+
|
|
24
32
|
def test_valid_init_data(self):
|
|
25
33
|
self.assertTrue(self.init_data.validate(self.bot_token))
|
|
26
34
|
|
|
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
|