Partially revert "Implement perfect forward secrecy for MTProto (#4618)"

This partially reverts commit 5a3a94eb51.
It should be re-introduced once the rest of comments are addressed.

Session changes are kept for the future, even if unused for now,
as there may be people who have already upgraded their session.
This commit is contained in:
Lonami Exo
2025-11-13 18:09:38 +01:00
parent 5a3a94eb51
commit 302a9a8c5f
8 changed files with 40 additions and 206 deletions
+1 -7
View File
@@ -923,13 +923,7 @@ class MessageMethods:
effect=message_effect_id
)
try:
result = await self(request)
except errors.rpcerrorlist.AuthKeyPermEmptyError as e:
await self._sender._reconnect(e)
result = await self(request)
result = await self(request)
if isinstance(result, types.UpdateShortSentMessage):
message = types.Message(
id=result.id,
+2 -13
View File
@@ -262,8 +262,7 @@ class TelegramBaseClient(abc.ABC):
base_logger: typing.Union[str, logging.Logger] = None,
receive_updates: bool = True,
catch_up: bool = False,
entity_cache_limit: int = 5000,
store_tmp_auth_key_on_disk: bool = True
entity_cache_limit: int = 5000
):
if not api_id or not api_hash:
raise ValueError(
@@ -289,7 +288,7 @@ class TelegramBaseClient(abc.ABC):
# Determine what session object we have
if isinstance(session, (str, pathlib.Path)):
try:
session = SQLiteSession(str(session), store_tmp_auth_key_on_disk=store_tmp_auth_key_on_disk)
session = SQLiteSession(str(session))
except ImportError:
import warnings
warnings.warn(
@@ -433,7 +432,6 @@ class TelegramBaseClient(abc.ABC):
auto_reconnect=self._auto_reconnect,
connect_timeout=self._timeout,
auth_key_callback=self._auth_key_callback,
tmp_auth_key_callback=self._tmp_auth_key_callback,
updates_queue=self._updates_queue,
auto_reconnect_callback=self._handle_auto_reconnect
)
@@ -563,7 +561,6 @@ class TelegramBaseClient(abc.ABC):
return
self.session.auth_key = self._sender.auth_key
self.session.tmp_auth_key = self._sender.tmp_auth_key
await utils.maybe_async(self.session.save())
try:
@@ -786,14 +783,6 @@ class TelegramBaseClient(abc.ABC):
self.session.auth_key = auth_key
await utils.maybe_async(self.session.save())
def _tmp_auth_key_callback(self: 'TelegramClient', tmp_auth_key):
"""
Callback from the sender whenever it needed to generate a
new temporary authorization key. This means we are not authorized.
"""
self.session.tmp_auth_key = tmp_auth_key
self.session.save()
# endregion
# region Working with different connections/Data Centers