dublib 0.30.2__tar.gz → 0.30.3__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.
- {dublib-0.30.2 → dublib-0.30.3}/PKG-INFO +1 -1
- {dublib-0.30.2 → dublib-0.30.3}/pyproject.toml +1 -1
- {dublib-0.30.2 → dublib-0.30.3}/pyproject.toml.orig +1 -1
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/config/authorization.py +45 -26
- {dublib-0.30.2 → dublib-0.30.3}/LICENSE +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/README.md +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/progress_indicator.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/readline.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/templates/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/templates/bus.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/commands/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/commands/group.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/commands/identificator.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/commands/model.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/commands/parameters.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/commands/positions.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/helper/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/helper/options.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/parser/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/parser/entitites.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/terminalyzer/parser/typing.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/text_styler/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/text_styler/codes.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/text_styler/escapes.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/cli/text_styler/fast_styler.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/core.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/engine/bus/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/engine/bus/enums.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/engine/bus/messages.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/engine/configurator.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/engine/get_text.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/engine/patcher.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/cli/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/cli/terminalyzer/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/cli/terminalyzer/groups.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/cli/terminalyzer/parameters.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/cli/terminalyzer/positions.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/engine/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/engine/bus.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/telebot_utils.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/validators.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/exceptions/web_requestor.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/data/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/data/dictionary.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/data/string.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/decorators.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/filesystem/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/filesystem/json.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/filesystem/text.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/filesystem/yaml.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/functions/system.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/polyglot/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/polyglot/html.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/polyglot/markdown.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/py.typed +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/telebot_utils/cache.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/telebot_utils/master/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/telebot_utils/master/decorators.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/telebot_utils/users.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/validators/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/validators/base.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/validators/types.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/config/__init__.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/config/constants.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/config/headers.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/enums.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/proxy.py +0 -0
- {dublib-0.30.2 → dublib-0.30.3}/src/dublib/web_requestor/response.py +0 -0
|
@@ -37,39 +37,38 @@ class _BaseAuthorizationMethod(ABC):
|
|
|
37
37
|
return self._Value
|
|
38
38
|
|
|
39
39
|
@property
|
|
40
|
-
def scheme(self) ->
|
|
40
|
+
def scheme(self) -> AuthorizationSchemes:
|
|
41
41
|
"""Схема авторизации."""
|
|
42
42
|
|
|
43
|
-
return self._Scheme
|
|
43
|
+
return self._Scheme
|
|
44
44
|
|
|
45
45
|
#==========================================================================================#
|
|
46
46
|
# >>>>> НАСЛЕДУЕМЫЕ МЕТОДЫ <<<<< #
|
|
47
47
|
#==========================================================================================#
|
|
48
48
|
|
|
49
|
-
def
|
|
49
|
+
def _remove_scheme(self, data: str) -> str:
|
|
50
50
|
"""
|
|
51
|
-
Удаляет из
|
|
51
|
+
Удаляет из данных авторизации схему.
|
|
52
52
|
|
|
53
|
-
:param
|
|
54
|
-
:type
|
|
55
|
-
:return:
|
|
53
|
+
:param data: Данные авторизации.
|
|
54
|
+
:type data: str
|
|
55
|
+
:return: Очищенные данные.
|
|
56
56
|
:rtype: str
|
|
57
57
|
"""
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
SchemaLength: int = len(Schema.value)
|
|
59
|
+
scheme_length: int = len(self._Scheme.value)
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if data.lower().startswith(self._Scheme.value.lower()):
|
|
62
|
+
return data[:scheme_length * -1].strip()
|
|
64
63
|
|
|
65
|
-
return
|
|
64
|
+
return data
|
|
66
65
|
|
|
67
66
|
#==========================================================================================#
|
|
68
67
|
# >>>>> ПЕРЕОПРЕДЕЛЯЕМЫЕ МЕТОДЫ <<<<< #
|
|
69
68
|
#==========================================================================================#
|
|
70
69
|
|
|
71
70
|
@abstractmethod
|
|
72
|
-
def
|
|
71
|
+
def _export_scheme(self) -> AuthorizationSchemes:
|
|
73
72
|
"""
|
|
74
73
|
Возвращает тип схемы авторизации.
|
|
75
74
|
|
|
@@ -86,7 +85,7 @@ class _BaseAuthorizationMethod(ABC):
|
|
|
86
85
|
def __init__(self):
|
|
87
86
|
"""Базовый метод авторизации."""
|
|
88
87
|
|
|
89
|
-
self._Scheme: AuthorizationSchemes = self.
|
|
88
|
+
self._Scheme: AuthorizationSchemes = self._export_scheme()
|
|
90
89
|
self._Value: str | None = None
|
|
91
90
|
|
|
92
91
|
def clear(self):
|
|
@@ -101,7 +100,7 @@ class Basic(_BaseAuthorizationMethod):
|
|
|
101
100
|
# >>>>> ПЕРЕОПРЕДЕЛЯЕМЫЕ МЕТОДЫ <<<<< #
|
|
102
101
|
#==========================================================================================#
|
|
103
102
|
|
|
104
|
-
def
|
|
103
|
+
def _export_scheme(self) -> AuthorizationSchemes:
|
|
105
104
|
"""
|
|
106
105
|
Возвращает тип схемы авторизации.
|
|
107
106
|
|
|
@@ -138,7 +137,7 @@ class Bearer(_BaseAuthorizationMethod):
|
|
|
138
137
|
# >>>>> ПЕРЕОПРЕДЕЛЯЕМЫЕ МЕТОДЫ <<<<< #
|
|
139
138
|
#==========================================================================================#
|
|
140
139
|
|
|
141
|
-
def
|
|
140
|
+
def _export_scheme(self) -> AuthorizationSchemes:
|
|
142
141
|
"""
|
|
143
142
|
Возвращает тип схемы авторизации.
|
|
144
143
|
|
|
@@ -152,6 +151,22 @@ class Bearer(_BaseAuthorizationMethod):
|
|
|
152
151
|
# >>>>> ПУБЛИЧНЫЕ МЕТОДЫ <<<<< #
|
|
153
152
|
#==========================================================================================#
|
|
154
153
|
|
|
154
|
+
def get_jwt_expiration_date(self, token: str) -> datetime:
|
|
155
|
+
"""
|
|
156
|
+
Определяет дату и время истечения токена.
|
|
157
|
+
|
|
158
|
+
:param token: **JSON Web Token** со схемой или без.
|
|
159
|
+
:type token: str
|
|
160
|
+
:return: Дата и время истечения токена.
|
|
161
|
+
:rtype: datetime
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
token = self._remove_scheme(token)
|
|
165
|
+
token_data: dict = jwt.decode(token, options = {"verify_signature": False})
|
|
166
|
+
expiration_timestamp: int = token_data["exp"]
|
|
167
|
+
|
|
168
|
+
return datetime.fromtimestamp(expiration_timestamp)
|
|
169
|
+
|
|
155
170
|
def is_jwt_expired(self, token: str, exception: bool = False) -> bool:
|
|
156
171
|
"""
|
|
157
172
|
Проверяет, устарел ли **JSON Web Token**.
|
|
@@ -166,15 +181,13 @@ class Bearer(_BaseAuthorizationMethod):
|
|
|
166
181
|
:raises TokenExpiredError: Токен устарел.
|
|
167
182
|
"""
|
|
168
183
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
ExpiratonTimestamp: int = TokenData["exp"]
|
|
172
|
-
IsExpired: bool = ExpiratonTimestamp < time()
|
|
184
|
+
expiration_date = self.get_jwt_expiration_date(token)
|
|
185
|
+
is_expired: bool = expiration_date.timestamp() < time()
|
|
173
186
|
|
|
174
|
-
if exception and
|
|
175
|
-
raise Exceptions.TokenExpiredError(
|
|
187
|
+
if exception and is_expired:
|
|
188
|
+
raise Exceptions.TokenExpiredError(expiration_date)
|
|
176
189
|
|
|
177
|
-
return
|
|
190
|
+
return is_expired
|
|
178
191
|
|
|
179
192
|
def set_jwt(self, token: str, validate: bool = True):
|
|
180
193
|
"""
|
|
@@ -188,7 +201,7 @@ class Bearer(_BaseAuthorizationMethod):
|
|
|
188
201
|
"""
|
|
189
202
|
|
|
190
203
|
if validate: self.is_jwt_expired(token, exception = True)
|
|
191
|
-
self._Value = self.
|
|
204
|
+
self._Value = self._remove_scheme(token)
|
|
192
205
|
|
|
193
206
|
def set_token(self, token: str):
|
|
194
207
|
"""
|
|
@@ -198,7 +211,7 @@ class Bearer(_BaseAuthorizationMethod):
|
|
|
198
211
|
:type token: str
|
|
199
212
|
"""
|
|
200
213
|
|
|
201
|
-
self._Value = self.
|
|
214
|
+
self._Value = self._remove_scheme(token)
|
|
202
215
|
|
|
203
216
|
#==========================================================================================#
|
|
204
217
|
# >>>>> ОСНОВНОЙ КЛАСС <<<<< #
|
|
@@ -218,7 +231,13 @@ class Authorizator:
|
|
|
218
231
|
if not self.__IsEnabled or not self.__AuthorizationMethod:
|
|
219
232
|
return {}
|
|
220
233
|
|
|
221
|
-
return {constants.AUTHORIZATION_HEADER: f"{self.__AuthorizationMethod.scheme} {self.__AuthorizationMethod.value}"}
|
|
234
|
+
return {constants.AUTHORIZATION_HEADER: f"{self.__AuthorizationMethod.scheme.value} {self.__AuthorizationMethod.value}"}
|
|
235
|
+
|
|
236
|
+
@property
|
|
237
|
+
def method(self) -> _BaseAuthorizationMethod | None:
|
|
238
|
+
"""Используемый метод авторизации."""
|
|
239
|
+
|
|
240
|
+
return self.__AuthorizationMethod
|
|
222
241
|
|
|
223
242
|
#==========================================================================================#
|
|
224
243
|
# >>>>> ПУБЛИЧНЫЕ МЕТОДЫ <<<<< #
|
|
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
|
|
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
|
|
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
|