init-data-py 0.2.5__tar.gz → 0.2.7__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.5 → init_data_py-0.2.7}/PKG-INFO +4 -3
- {init_data_py-0.2.5 → init_data_py-0.2.7}/pyproject.toml +1 -1
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/__init__.py +1 -1
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/init_data.py +7 -1
- {init_data_py-0.2.5 → init_data_py-0.2.7}/.github/workflows/publish.yml +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/.gitignore +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/.python-version +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/LICENCE +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/README.md +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/requirements-dev.lock +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/requirements.lock +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/errors/__init__.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/errors/errors.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/types/__init__.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/types/chat.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/types/object.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/src/init_data_py/types/user.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/tests/__init__.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/tests/test_parse.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/tests/test_sign.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/tests/test_to_query_string.py +0 -0
- {init_data_py-0.2.5 → init_data_py-0.2.7}/tests/test_validate.py +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: init-data-py
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: A Python library that provides tools for using and validating Telegram web app init data.
|
|
5
5
|
Author-email: nimaxin <nimaxin@proton.me>
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENCE
|
|
7
8
|
Requires-Python: >=3.8
|
|
8
9
|
Description-Content-Type: text/markdown
|
|
9
10
|
|
|
@@ -43,6 +43,9 @@ class InitData:
|
|
|
43
43
|
|
|
44
44
|
hash (`str`, optional):
|
|
45
45
|
A hash of all passed parameters, which the bot server can use to check their validity.
|
|
46
|
+
|
|
47
|
+
signature (`str`, optional):
|
|
48
|
+
A signature of all passed parameters (except hash), which the third party can use to check their validity.
|
|
46
49
|
"""
|
|
47
50
|
|
|
48
51
|
def __init__(
|
|
@@ -60,6 +63,7 @@ class InitData:
|
|
|
60
63
|
can_send_after: Optional[int] = None,
|
|
61
64
|
auth_date: Optional[int] = None,
|
|
62
65
|
hash: Optional[str] = None,
|
|
66
|
+
signature: Optional[str] = None,
|
|
63
67
|
) -> None:
|
|
64
68
|
self.query_id = query_id
|
|
65
69
|
self.user = user
|
|
@@ -71,6 +75,7 @@ class InitData:
|
|
|
71
75
|
self.can_send_after = can_send_after
|
|
72
76
|
self.auth_date = auth_date
|
|
73
77
|
self.hash = hash
|
|
78
|
+
self.signature = signature
|
|
74
79
|
|
|
75
80
|
def validate(
|
|
76
81
|
self,
|
|
@@ -166,7 +171,7 @@ class InitData:
|
|
|
166
171
|
sorted_attrs = sorted(init_data.items())
|
|
167
172
|
data_check_string = (
|
|
168
173
|
"\n".join(f"{k}={v}" for k, v in sorted_attrs)
|
|
169
|
-
.replace("/", "\/")
|
|
174
|
+
.replace("/", r"\/")
|
|
170
175
|
.encode()
|
|
171
176
|
)
|
|
172
177
|
secret_key = hmac.new(
|
|
@@ -214,6 +219,7 @@ class InitData:
|
|
|
214
219
|
for k, v in parsed_qs.items():
|
|
215
220
|
if k in {
|
|
216
221
|
"hash",
|
|
222
|
+
"signature",
|
|
217
223
|
"query_id",
|
|
218
224
|
"chat_type",
|
|
219
225
|
"chat_instance",
|
|
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
|