@mtkruto/node 0.69.0 → 0.70.1
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.
- package/esm/0_deps.d.ts +3 -1
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +3 -1
- package/esm/3_types.d.ts +35 -35
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +35 -35
- package/esm/_dnt.polyfills.d.ts +20 -13
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +120 -11
- package/esm/client/0_abortable_loop.d.ts +27 -0
- package/esm/client/0_abortable_loop.d.ts.map +1 -0
- package/esm/client/0_abortable_loop.js +49 -0
- package/esm/client/0_client_abstract.d.ts +1 -0
- package/esm/client/0_client_abstract.d.ts.map +1 -1
- package/esm/client/0_client_abstract.js +3 -0
- package/esm/client/0_filters.d.ts +9 -3
- package/esm/client/0_filters.d.ts.map +1 -1
- package/esm/client/0_filters.js +4 -1
- package/esm/client/0_params.d.ts +1 -1
- package/esm/client/0_password.d.ts +2 -2
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_storage_operations.d.ts +53 -71
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +241 -238
- package/esm/client/0_update_processor.d.ts +2 -2
- package/esm/client/0_update_processor.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +2 -2
- package/esm/client/0_utilities.d.ts.map +1 -1
- package/esm/client/1_types.d.ts +2 -2
- package/esm/client/1_types.d.ts.map +1 -1
- package/esm/client/2_account_manager.js +5 -5
- package/esm/client/2_business_connection_manager.d.ts +1 -1
- package/esm/client/2_business_connection_manager.d.ts.map +1 -1
- package/esm/client/2_business_connection_manager.js +3 -3
- package/esm/client/2_client_encrypted.d.ts +1 -1
- package/esm/client/2_client_encrypted.d.ts.map +1 -1
- package/esm/client/2_client_encrypted.js +26 -23
- package/esm/client/2_file_manager.js +2 -2
- package/esm/client/2_network_statistics_manager.d.ts +2 -2
- package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +30 -4
- package/esm/client/2_payment_manager.d.ts +1 -1
- package/esm/client/2_payment_manager.d.ts.map +1 -1
- package/esm/client/2_payment_manager.js +2 -2
- package/esm/client/2_reaction_manager.d.ts +1 -1
- package/esm/client/2_reaction_manager.d.ts.map +1 -1
- package/esm/client/2_reaction_manager.js +2 -2
- package/esm/client/2_translations_manager.d.ts +1 -1
- package/esm/client/2_translations_manager.d.ts.map +1 -1
- package/esm/client/2_translations_manager.js +15 -11
- package/esm/client/2_update_manager.d.ts +4 -2
- package/esm/client/2_update_manager.d.ts.map +1 -1
- package/esm/client/2_update_manager.js +62 -80
- package/esm/client/3_message_manager.d.ts +2 -2
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +5 -5
- package/esm/client/3_video_chat_manager.d.ts +1 -1
- package/esm/client/3_video_chat_manager.d.ts.map +1 -1
- package/esm/client/4_callback_query_manager.d.ts +1 -1
- package/esm/client/4_callback_query_manager.d.ts.map +1 -1
- package/esm/client/4_callback_query_manager.js +1 -1
- package/esm/client/4_chat_list_manager.d.ts +2 -3
- package/esm/client/4_chat_list_manager.d.ts.map +1 -1
- package/esm/client/4_chat_list_manager.js +10 -265
- package/esm/client/4_chat_manager.d.ts +2 -2
- package/esm/client/4_chat_manager.d.ts.map +1 -1
- package/esm/client/4_chat_manager.js +7 -7
- package/esm/client/4_gift_manager.js +3 -3
- package/esm/client/4_inline_query_manager.d.ts +1 -1
- package/esm/client/4_inline_query_manager.d.ts.map +1 -1
- package/esm/client/4_inline_query_manager.js +3 -3
- package/esm/client/4_link_preview_manager.d.ts +1 -1
- package/esm/client/4_link_preview_manager.d.ts.map +1 -1
- package/esm/client/4_link_preview_manager.js +3 -3
- package/esm/client/4_poll_manager.d.ts +1 -1
- package/esm/client/4_poll_manager.d.ts.map +1 -1
- package/esm/client/4_poll_manager.js +1 -1
- package/esm/client/4_story_manager.d.ts +1 -1
- package/esm/client/4_story_manager.d.ts.map +1 -1
- package/esm/client/4_story_manager.js +7 -7
- package/esm/client/5_client.d.ts +15 -9
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +420 -382
- package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts +12 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.js +69 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts +112 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.js +140 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts +111 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.js +82 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +39 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +109 -0
- package/esm/session/1_session.d.ts +1 -0
- package/esm/session/1_session.d.ts.map +1 -1
- package/esm/session/1_session.js +3 -0
- package/esm/session/2_session_encrypted.d.ts +2 -2
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +198 -135
- package/esm/storage/0_storage.d.ts +1 -0
- package/esm/storage/0_storage.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.d.ts +1 -0
- package/esm/storage/2_storage_indexed_db.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.js +3 -0
- package/esm/storage/2_storage_local_storage.node.d.ts +1 -0
- package/esm/storage/2_storage_local_storage.node.d.ts.map +1 -1
- package/esm/storage/2_storage_local_storage.node.js +3 -0
- package/esm/storage/2_storage_memory.d.ts +1 -0
- package/esm/storage/2_storage_memory.d.ts.map +1 -1
- package/esm/storage/2_storage_memory.js +3 -0
- package/esm/storage/2_storage_session_storage.d.ts +1 -0
- package/esm/storage/2_storage_session_storage.d.ts.map +1 -1
- package/esm/storage/2_storage_session_storage.js +3 -0
- package/esm/tl/0_utilities.d.ts +1 -0
- package/esm/tl/0_utilities.d.ts.map +1 -1
- package/esm/tl/0_utilities.js +20 -1
- package/esm/tl/1_telegram_api.d.ts +810 -254
- package/esm/tl/1_telegram_api.d.ts.map +1 -1
- package/esm/tl/1_telegram_api.js +912 -213
- package/esm/tl/1_tl_reader.d.ts +2 -2
- package/esm/tl/1_tl_reader.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.d.ts +2 -2
- package/esm/tl/1_tl_writer.d.ts.map +1 -1
- package/esm/tl/2_mtproto.d.ts +1 -1
- package/esm/tl/2_mtproto.d.ts.map +1 -1
- package/esm/tl/2_telegram.d.ts +1 -1
- package/esm/tl/2_telegram.d.ts.map +1 -1
- package/esm/types/0_file_source.d.ts +1 -1
- package/esm/types/0_file_source.d.ts.map +1 -1
- package/esm/types/1_chat_p.d.ts +10 -0
- package/esm/types/1_chat_p.d.ts.map +1 -1
- package/esm/types/1_chat_p.js +4 -0
- package/esm/types/2_chat.d.ts +2 -5
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_chat.js +10 -15
- package/esm/types/{0_message_entity.d.ts → 2_message_entity.d.ts} +3 -3
- package/esm/types/{0_message_entity.d.ts.map → 2_message_entity.d.ts.map} +1 -1
- package/esm/types/{0_message_entity.js → 2_message_entity.js} +7 -7
- package/esm/types/2_message_reaction_count.d.ts +2 -3
- package/esm/types/2_message_reaction_count.d.ts.map +1 -1
- package/esm/types/2_message_reaction_count.js +4 -6
- package/esm/types/2_poll_answer.d.ts +2 -3
- package/esm/types/2_poll_answer.d.ts.map +1 -1
- package/esm/types/2_poll_answer.js +4 -5
- package/esm/types/2_story_interactive_area.d.ts +2 -2
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/2_story_interactive_area.js +2 -2
- package/esm/types/{1_story_privacy.d.ts → 2_story_privacy.d.ts} +3 -3
- package/esm/types/{1_story_privacy.d.ts.map → 2_story_privacy.d.ts.map} +1 -1
- package/esm/types/{1_story_privacy.js → 2_story_privacy.js} +10 -10
- package/{script/types/1_user.d.ts → esm/types/2_user.d.ts} +5 -1
- package/esm/types/2_user.d.ts.map +1 -0
- package/esm/types/{1_user.js → 2_user.js} +24 -0
- package/esm/types/{2_business_connection.d.ts → 3_business_connection.d.ts} +4 -4
- package/esm/types/3_business_connection.d.ts.map +1 -0
- package/esm/types/{2_business_connection.js → 3_business_connection.js} +10 -3
- package/{script/types/2_chat_member.d.ts → esm/types/3_chat_member.d.ts} +6 -4
- package/esm/types/{2_chat_member.d.ts.map → 3_chat_member.d.ts.map} +1 -1
- package/esm/types/{2_chat_member.js → 3_chat_member.js} +5 -5
- package/esm/types/{2_chat_settings.d.ts → 3_chat_settings.d.ts} +2 -2
- package/{script/types/2_chat_settings.d.ts.map → esm/types/3_chat_settings.d.ts.map} +1 -1
- package/esm/types/{2_chat_settings.js → 3_chat_settings.js} +1 -1
- package/esm/types/{2_chosen_inline_result.d.ts → 3_chosen_inline_result.d.ts} +4 -4
- package/esm/types/3_chosen_inline_result.d.ts.map +1 -0
- package/esm/types/{2_chosen_inline_result.js → 3_chosen_inline_result.js} +3 -3
- package/esm/types/{2_forward_header.d.ts → 3_forward_header.d.ts} +4 -5
- package/esm/types/3_forward_header.d.ts.map +1 -0
- package/esm/types/{2_forward_header.js → 3_forward_header.js} +11 -12
- package/{script/types/2_game.d.ts → esm/types/3_game.d.ts} +2 -2
- package/esm/types/3_game.d.ts.map +1 -0
- package/esm/types/{2_gift_upgraded_component.d.ts → 3_gift_upgraded_component.d.ts} +2 -2
- package/esm/types/{2_gift_upgraded_component.d.ts.map → 3_gift_upgraded_component.d.ts.map} +1 -1
- package/esm/types/{2_gift_upgraded_component.js → 3_gift_upgraded_component.js} +1 -1
- package/esm/types/{2_inline_query.d.ts → 3_inline_query.d.ts} +4 -4
- package/esm/types/3_inline_query.d.ts.map +1 -0
- package/esm/types/{2_inline_query.js → 3_inline_query.js} +5 -5
- package/{script/types/1_input_media.d.ts → esm/types/3_input_media.d.ts} +2 -2
- package/esm/types/{1_input_media.d.ts.map → 3_input_media.d.ts.map} +1 -1
- package/{script/types/2_invite_link.d.ts → esm/types/3_invite_link.d.ts} +4 -4
- package/{script/types/2_invite_link.d.ts.map → esm/types/3_invite_link.d.ts.map} +1 -1
- package/esm/types/{2_invite_link.js → 3_invite_link.js} +5 -5
- package/{script/types/2_message_reactions.d.ts → esm/types/3_message_reactions.d.ts} +5 -6
- package/esm/types/3_message_reactions.d.ts.map +1 -0
- package/esm/types/{2_message_reactions.js → 3_message_reactions.js} +10 -12
- package/esm/types/{1_poll_option.d.ts → 3_poll_option.d.ts} +2 -2
- package/esm/types/{1_poll_option.d.ts.map → 3_poll_option.d.ts.map} +1 -1
- package/esm/types/{1_poll_option.js → 3_poll_option.js} +1 -1
- package/esm/types/{2_pre_checkout_query.d.ts → 3_pre_checkout_query.d.ts} +4 -4
- package/esm/types/3_pre_checkout_query.d.ts.map +1 -0
- package/esm/types/{2_pre_checkout_query.js → 3_pre_checkout_query.js} +5 -5
- package/{script/types/1_reply_quote.d.ts → esm/types/3_reply_quote.d.ts} +2 -2
- package/esm/types/{1_reply_quote.d.ts.map → 3_reply_quote.d.ts.map} +1 -1
- package/esm/types/{1_reply_quote.js → 3_reply_quote.js} +1 -1
- package/esm/types/3_story.d.ts +4 -5
- package/esm/types/3_story.d.ts.map +1 -1
- package/esm/types/3_story.js +6 -7
- package/esm/types/{3_chat_member_updated.d.ts → 4_chat_member_updated.d.ts} +6 -7
- package/esm/types/4_chat_member_updated.d.ts.map +1 -0
- package/esm/types/{3_chat_member_updated.js → 4_chat_member_updated.js} +13 -14
- package/esm/types/{3_gift.d.ts → 4_gift.d.ts} +6 -6
- package/esm/types/{3_gift.d.ts.map → 4_gift.d.ts.map} +1 -1
- package/esm/types/{3_gift.js → 4_gift.js} +7 -7
- package/esm/types/{3_join_request.d.ts → 4_join_request.d.ts} +6 -7
- package/esm/types/4_join_request.d.ts.map +1 -0
- package/esm/types/{3_join_request.js → 4_join_request.js} +17 -18
- package/esm/types/{2_poll.d.ts → 4_poll.d.ts} +3 -3
- package/esm/types/{2_poll.d.ts.map → 4_poll.d.ts.map} +1 -1
- package/esm/types/{2_poll.js → 4_poll.js} +2 -2
- package/{script/types/2_reply_to.d.ts → esm/types/4_reply_to.d.ts} +2 -2
- package/esm/types/{2_reply_to.d.ts.map → 4_reply_to.d.ts.map} +1 -1
- package/esm/types/{4_claimed_gift.d.ts → 5_claimed_gift.d.ts} +5 -6
- package/esm/types/5_claimed_gift.d.ts.map +1 -0
- package/esm/types/{4_claimed_gift.js → 5_claimed_gift.js} +4 -4
- package/esm/types/{4_link_preview.d.ts → 5_link_preview.d.ts} +4 -4
- package/{script/types/4_link_preview.d.ts.map → esm/types/5_link_preview.d.ts.map} +1 -1
- package/esm/types/{4_link_preview.js → 5_link_preview.js} +3 -3
- package/esm/types/{5_claimed_gifts.d.ts → 6_claimed_gifts.d.ts} +4 -4
- package/esm/types/6_claimed_gifts.d.ts.map +1 -0
- package/esm/types/{5_claimed_gifts.js → 6_claimed_gifts.js} +4 -4
- package/esm/types/{5_message.d.ts → 6_message.d.ts} +10 -11
- package/esm/types/6_message.d.ts.map +1 -0
- package/esm/types/{5_message.js → 6_message.js} +41 -66
- package/{script/types/5_message_content.d.ts → esm/types/6_message_content.d.ts} +3 -3
- package/esm/types/{5_message_content.d.ts.map → 6_message_content.d.ts.map} +1 -1
- package/{script/types/6_callback_query.d.ts → esm/types/7_callback_query.d.ts} +5 -5
- package/esm/types/{6_callback_query.d.ts.map → 7_callback_query.d.ts.map} +1 -1
- package/esm/types/{6_callback_query.js → 7_callback_query.js} +5 -5
- package/{script/types/6_chat_list_item.d.ts → esm/types/7_chat_list_item.d.ts} +6 -7
- package/esm/types/7_chat_list_item.d.ts.map +1 -0
- package/esm/types/{6_chat_list_item.js → 7_chat_list_item.js} +11 -11
- package/{script/types/6_inline_query_result.d.ts → esm/types/7_inline_query_result.d.ts} +3 -3
- package/esm/types/{6_inline_query_result.d.ts.map → 7_inline_query_result.d.ts.map} +1 -1
- package/esm/types/{6_inline_query_result.js → 7_inline_query_result.js} +1 -1
- package/esm/types/{6_saved_chat.d.ts → 7_saved_chat.d.ts} +4 -5
- package/esm/types/7_saved_chat.d.ts.map +1 -0
- package/esm/types/{6_saved_chat.js → 7_saved_chat.js} +4 -4
- package/esm/types/{6_topic.d.ts → 7_topic.d.ts} +2 -2
- package/esm/types/{6_topic.d.ts.map → 7_topic.d.ts.map} +1 -1
- package/esm/types/{7_inline_query_answer.d.ts → 8_inline_query_answer.d.ts} +2 -2
- package/esm/types/{7_inline_query_answer.d.ts.map → 8_inline_query_answer.d.ts.map} +1 -1
- package/esm/types/{7_inline_query_answer.js → 8_inline_query_answer.js} +1 -1
- package/{script/types/7_saved_chats.d.ts → esm/types/8_saved_chats.d.ts} +5 -5
- package/esm/types/8_saved_chats.d.ts.map +1 -0
- package/esm/types/{7_saved_chats.js → 8_saved_chats.js} +3 -3
- package/esm/types/{7_update.d.ts → 8_update.d.ts} +35 -16
- package/esm/types/8_update.d.ts.map +1 -0
- package/esm/types/_file_id.d.ts +1 -1
- package/esm/types/_file_id.d.ts.map +1 -1
- package/esm/types/_getters.d.ts +0 -7
- package/esm/types/_getters.d.ts.map +1 -1
- package/esm/utilities/0_hash.d.ts +2 -2
- package/esm/utilities/0_hash.d.ts.map +1 -1
- package/esm/utilities/0_misc.d.ts +1 -0
- package/esm/utilities/0_misc.d.ts.map +1 -1
- package/esm/utilities/0_misc.js +14 -1
- package/esm/utilities/0_part_stream.d.ts +1 -1
- package/esm/utilities/0_part_stream.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +3 -1
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +6 -1
- package/script/3_types.d.ts +35 -35
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +35 -35
- package/script/_dnt.polyfills.d.ts +20 -13
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +120 -11
- package/script/client/0_abortable_loop.d.ts +27 -0
- package/script/client/0_abortable_loop.d.ts.map +1 -0
- package/script/client/0_abortable_loop.js +53 -0
- package/script/client/0_client_abstract.d.ts +1 -0
- package/script/client/0_client_abstract.d.ts.map +1 -1
- package/script/client/0_client_abstract.js +3 -0
- package/script/client/0_filters.d.ts +9 -3
- package/script/client/0_filters.d.ts.map +1 -1
- package/script/client/0_filters.js +4 -1
- package/script/client/0_params.d.ts +1 -1
- package/script/client/0_password.d.ts +2 -2
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_storage_operations.d.ts +53 -71
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +239 -236
- package/script/client/0_update_processor.d.ts +2 -2
- package/script/client/0_update_processor.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +2 -2
- package/script/client/0_utilities.d.ts.map +1 -1
- package/script/client/1_types.d.ts +2 -2
- package/script/client/1_types.d.ts.map +1 -1
- package/script/client/2_account_manager.js +5 -5
- package/script/client/2_business_connection_manager.d.ts +1 -1
- package/script/client/2_business_connection_manager.d.ts.map +1 -1
- package/script/client/2_business_connection_manager.js +3 -3
- package/script/client/2_client_encrypted.d.ts +1 -1
- package/script/client/2_client_encrypted.d.ts.map +1 -1
- package/script/client/2_client_encrypted.js +26 -23
- package/script/client/2_file_manager.js +2 -2
- package/script/client/2_network_statistics_manager.d.ts +2 -2
- package/script/client/2_network_statistics_manager.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +30 -4
- package/script/client/2_payment_manager.d.ts +1 -1
- package/script/client/2_payment_manager.d.ts.map +1 -1
- package/script/client/2_payment_manager.js +2 -2
- package/script/client/2_reaction_manager.d.ts +1 -1
- package/script/client/2_reaction_manager.d.ts.map +1 -1
- package/script/client/2_reaction_manager.js +2 -2
- package/script/client/2_translations_manager.d.ts +1 -1
- package/script/client/2_translations_manager.d.ts.map +1 -1
- package/script/client/2_translations_manager.js +15 -11
- package/script/client/2_update_manager.d.ts +4 -2
- package/script/client/2_update_manager.d.ts.map +1 -1
- package/script/client/2_update_manager.js +62 -80
- package/script/client/3_message_manager.d.ts +2 -2
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +5 -5
- package/script/client/3_video_chat_manager.d.ts +1 -1
- package/script/client/3_video_chat_manager.d.ts.map +1 -1
- package/script/client/4_callback_query_manager.d.ts +1 -1
- package/script/client/4_callback_query_manager.d.ts.map +1 -1
- package/script/client/4_callback_query_manager.js +1 -1
- package/script/client/4_chat_list_manager.d.ts +2 -3
- package/script/client/4_chat_list_manager.d.ts.map +1 -1
- package/script/client/4_chat_list_manager.js +9 -264
- package/script/client/4_chat_manager.d.ts +2 -2
- package/script/client/4_chat_manager.d.ts.map +1 -1
- package/script/client/4_chat_manager.js +7 -7
- package/script/client/4_gift_manager.js +3 -3
- package/script/client/4_inline_query_manager.d.ts +1 -1
- package/script/client/4_inline_query_manager.d.ts.map +1 -1
- package/script/client/4_inline_query_manager.js +3 -3
- package/script/client/4_link_preview_manager.d.ts +1 -1
- package/script/client/4_link_preview_manager.d.ts.map +1 -1
- package/script/client/4_link_preview_manager.js +3 -3
- package/script/client/4_poll_manager.d.ts +1 -1
- package/script/client/4_poll_manager.d.ts.map +1 -1
- package/script/client/4_poll_manager.js +1 -1
- package/script/client/4_story_manager.d.ts +1 -1
- package/script/client/4_story_manager.d.ts.map +1 -1
- package/script/client/4_story_manager.js +7 -7
- package/script/client/5_client.d.ts +15 -9
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +418 -380
- package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts +12 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.js +72 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts +112 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.js +144 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts +111 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/0.2.0/memoize.js +85 -0
- package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +39 -0
- package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +113 -0
- package/script/session/1_session.d.ts +1 -0
- package/script/session/1_session.d.ts.map +1 -1
- package/script/session/1_session.js +3 -0
- package/script/session/2_session_encrypted.d.ts +2 -2
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +197 -134
- package/script/storage/0_storage.d.ts +1 -0
- package/script/storage/0_storage.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.d.ts +1 -0
- package/script/storage/2_storage_indexed_db.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.js +3 -0
- package/script/storage/2_storage_local_storage.node.d.ts +1 -0
- package/script/storage/2_storage_local_storage.node.d.ts.map +1 -1
- package/script/storage/2_storage_local_storage.node.js +3 -0
- package/script/storage/2_storage_memory.d.ts +1 -0
- package/script/storage/2_storage_memory.d.ts.map +1 -1
- package/script/storage/2_storage_memory.js +3 -0
- package/script/storage/2_storage_session_storage.d.ts +1 -0
- package/script/storage/2_storage_session_storage.d.ts.map +1 -1
- package/script/storage/2_storage_session_storage.js +3 -0
- package/script/tl/0_utilities.d.ts +1 -0
- package/script/tl/0_utilities.d.ts.map +1 -1
- package/script/tl/0_utilities.js +20 -0
- package/script/tl/1_telegram_api.d.ts +810 -254
- package/script/tl/1_telegram_api.d.ts.map +1 -1
- package/script/tl/1_telegram_api.js +912 -213
- package/script/tl/1_tl_reader.d.ts +2 -2
- package/script/tl/1_tl_reader.d.ts.map +1 -1
- package/script/tl/1_tl_writer.d.ts +2 -2
- package/script/tl/1_tl_writer.d.ts.map +1 -1
- package/script/tl/2_mtproto.d.ts +1 -1
- package/script/tl/2_mtproto.d.ts.map +1 -1
- package/script/tl/2_telegram.d.ts +1 -1
- package/script/tl/2_telegram.d.ts.map +1 -1
- package/script/types/0_file_source.d.ts +1 -1
- package/script/types/0_file_source.d.ts.map +1 -1
- package/script/types/1_chat_p.d.ts +10 -0
- package/script/types/1_chat_p.d.ts.map +1 -1
- package/script/types/1_chat_p.js +5 -0
- package/script/types/2_chat.d.ts +2 -5
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_chat.js +10 -15
- package/script/types/{0_message_entity.d.ts → 2_message_entity.d.ts} +3 -3
- package/script/types/{0_message_entity.d.ts.map → 2_message_entity.d.ts.map} +1 -1
- package/script/types/{0_message_entity.js → 2_message_entity.js} +7 -7
- package/script/types/2_message_reaction_count.d.ts +2 -3
- package/script/types/2_message_reaction_count.d.ts.map +1 -1
- package/script/types/2_message_reaction_count.js +4 -6
- package/script/types/2_poll_answer.d.ts +2 -3
- package/script/types/2_poll_answer.d.ts.map +1 -1
- package/script/types/2_poll_answer.js +4 -5
- package/script/types/2_story_interactive_area.d.ts +2 -2
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/2_story_interactive_area.js +2 -2
- package/script/types/{1_story_privacy.d.ts → 2_story_privacy.d.ts} +3 -3
- package/script/types/{1_story_privacy.d.ts.map → 2_story_privacy.d.ts.map} +1 -1
- package/script/types/{1_story_privacy.js → 2_story_privacy.js} +10 -10
- package/{esm/types/1_user.d.ts → script/types/2_user.d.ts} +5 -1
- package/script/types/2_user.d.ts.map +1 -0
- package/script/types/{1_user.js → 2_user.js} +25 -0
- package/script/types/{2_business_connection.d.ts → 3_business_connection.d.ts} +4 -4
- package/script/types/3_business_connection.d.ts.map +1 -0
- package/script/types/{2_business_connection.js → 3_business_connection.js} +10 -3
- package/{esm/types/2_chat_member.d.ts → script/types/3_chat_member.d.ts} +6 -4
- package/script/types/{2_chat_member.d.ts.map → 3_chat_member.d.ts.map} +1 -1
- package/script/types/{2_chat_member.js → 3_chat_member.js} +5 -5
- package/script/types/{2_chat_settings.d.ts → 3_chat_settings.d.ts} +2 -2
- package/{esm/types/2_chat_settings.d.ts.map → script/types/3_chat_settings.d.ts.map} +1 -1
- package/script/types/{2_chat_settings.js → 3_chat_settings.js} +2 -2
- package/script/types/{2_chosen_inline_result.d.ts → 3_chosen_inline_result.d.ts} +4 -4
- package/script/types/3_chosen_inline_result.d.ts.map +1 -0
- package/script/types/{2_chosen_inline_result.js → 3_chosen_inline_result.js} +4 -4
- package/script/types/{2_forward_header.d.ts → 3_forward_header.d.ts} +4 -5
- package/script/types/3_forward_header.d.ts.map +1 -0
- package/script/types/{2_forward_header.js → 3_forward_header.js} +11 -12
- package/{esm/types/2_game.d.ts → script/types/3_game.d.ts} +2 -2
- package/script/types/3_game.d.ts.map +1 -0
- package/script/types/{2_gift_upgraded_component.d.ts → 3_gift_upgraded_component.d.ts} +2 -2
- package/script/types/{2_gift_upgraded_component.d.ts.map → 3_gift_upgraded_component.d.ts.map} +1 -1
- package/script/types/{2_gift_upgraded_component.js → 3_gift_upgraded_component.js} +2 -2
- package/script/types/{2_inline_query.d.ts → 3_inline_query.d.ts} +4 -4
- package/script/types/3_inline_query.d.ts.map +1 -0
- package/script/types/{2_inline_query.js → 3_inline_query.js} +5 -5
- package/{esm/types/1_input_media.d.ts → script/types/3_input_media.d.ts} +2 -2
- package/script/types/{1_input_media.d.ts.map → 3_input_media.d.ts.map} +1 -1
- package/{esm/types/2_invite_link.d.ts → script/types/3_invite_link.d.ts} +4 -4
- package/{esm/types/2_invite_link.d.ts.map → script/types/3_invite_link.d.ts.map} +1 -1
- package/script/types/{2_invite_link.js → 3_invite_link.js} +5 -5
- package/{esm/types/2_message_reactions.d.ts → script/types/3_message_reactions.d.ts} +5 -6
- package/script/types/3_message_reactions.d.ts.map +1 -0
- package/script/types/{2_message_reactions.js → 3_message_reactions.js} +10 -12
- package/script/types/{1_poll_option.d.ts → 3_poll_option.d.ts} +2 -2
- package/script/types/{1_poll_option.d.ts.map → 3_poll_option.d.ts.map} +1 -1
- package/script/types/{1_poll_option.js → 3_poll_option.js} +2 -2
- package/script/types/{2_pre_checkout_query.d.ts → 3_pre_checkout_query.d.ts} +4 -4
- package/script/types/3_pre_checkout_query.d.ts.map +1 -0
- package/script/types/{2_pre_checkout_query.js → 3_pre_checkout_query.js} +5 -5
- package/{esm/types/1_reply_quote.d.ts → script/types/3_reply_quote.d.ts} +2 -2
- package/script/types/{1_reply_quote.d.ts.map → 3_reply_quote.d.ts.map} +1 -1
- package/script/types/{1_reply_quote.js → 3_reply_quote.js} +2 -2
- package/script/types/3_story.d.ts +4 -5
- package/script/types/3_story.d.ts.map +1 -1
- package/script/types/3_story.js +8 -9
- package/script/types/{3_chat_member_updated.d.ts → 4_chat_member_updated.d.ts} +6 -7
- package/script/types/4_chat_member_updated.d.ts.map +1 -0
- package/script/types/{3_chat_member_updated.js → 4_chat_member_updated.js} +13 -14
- package/script/types/{3_gift.d.ts → 4_gift.d.ts} +6 -6
- package/script/types/{3_gift.d.ts.map → 4_gift.d.ts.map} +1 -1
- package/script/types/{3_gift.js → 4_gift.js} +9 -9
- package/script/types/{3_join_request.d.ts → 4_join_request.d.ts} +6 -7
- package/script/types/4_join_request.d.ts.map +1 -0
- package/script/types/{3_join_request.js → 4_join_request.js} +17 -18
- package/script/types/{2_poll.d.ts → 4_poll.d.ts} +3 -3
- package/script/types/{2_poll.d.ts.map → 4_poll.d.ts.map} +1 -1
- package/script/types/{2_poll.js → 4_poll.js} +5 -5
- package/{esm/types/2_reply_to.d.ts → script/types/4_reply_to.d.ts} +2 -2
- package/script/types/{2_reply_to.d.ts.map → 4_reply_to.d.ts.map} +1 -1
- package/script/types/{4_claimed_gift.d.ts → 5_claimed_gift.d.ts} +5 -6
- package/script/types/5_claimed_gift.d.ts.map +1 -0
- package/script/types/{4_claimed_gift.js → 5_claimed_gift.js} +5 -5
- package/script/types/{4_link_preview.d.ts → 5_link_preview.d.ts} +4 -4
- package/{esm/types/4_link_preview.d.ts.map → script/types/5_link_preview.d.ts.map} +1 -1
- package/script/types/{4_link_preview.js → 5_link_preview.js} +3 -3
- package/script/types/{5_claimed_gifts.d.ts → 6_claimed_gifts.d.ts} +4 -4
- package/script/types/6_claimed_gifts.d.ts.map +1 -0
- package/script/types/{5_claimed_gifts.js → 6_claimed_gifts.js} +4 -4
- package/script/types/{5_message.d.ts → 6_message.d.ts} +10 -11
- package/script/types/6_message.d.ts.map +1 -0
- package/script/types/{5_message.js → 6_message.js} +45 -70
- package/{esm/types/5_message_content.d.ts → script/types/6_message_content.d.ts} +3 -3
- package/script/types/{5_message_content.d.ts.map → 6_message_content.d.ts.map} +1 -1
- package/{esm/types/6_callback_query.d.ts → script/types/7_callback_query.d.ts} +5 -5
- package/script/types/{6_callback_query.d.ts.map → 7_callback_query.d.ts.map} +1 -1
- package/script/types/{6_callback_query.js → 7_callback_query.js} +5 -5
- package/{esm/types/6_chat_list_item.d.ts → script/types/7_chat_list_item.d.ts} +6 -7
- package/script/types/7_chat_list_item.d.ts.map +1 -0
- package/script/types/{6_chat_list_item.js → 7_chat_list_item.js} +11 -11
- package/{esm/types/6_inline_query_result.d.ts → script/types/7_inline_query_result.d.ts} +3 -3
- package/script/types/{6_inline_query_result.d.ts.map → 7_inline_query_result.d.ts.map} +1 -1
- package/script/types/{6_inline_query_result.js → 7_inline_query_result.js} +3 -3
- package/script/types/{6_saved_chat.d.ts → 7_saved_chat.d.ts} +4 -5
- package/script/types/7_saved_chat.d.ts.map +1 -0
- package/script/types/{6_saved_chat.js → 7_saved_chat.js} +4 -4
- package/script/types/{6_topic.d.ts → 7_topic.d.ts} +2 -2
- package/script/types/{6_topic.d.ts.map → 7_topic.d.ts.map} +1 -1
- package/script/types/{7_inline_query_answer.d.ts → 8_inline_query_answer.d.ts} +2 -2
- package/script/types/{7_inline_query_answer.d.ts.map → 8_inline_query_answer.d.ts.map} +1 -1
- package/script/types/{7_inline_query_answer.js → 8_inline_query_answer.js} +2 -2
- package/{esm/types/7_saved_chats.d.ts → script/types/8_saved_chats.d.ts} +5 -5
- package/script/types/8_saved_chats.d.ts.map +1 -0
- package/script/types/{7_saved_chats.js → 8_saved_chats.js} +3 -3
- package/script/types/{7_update.d.ts → 8_update.d.ts} +35 -16
- package/script/types/8_update.d.ts.map +1 -0
- package/script/types/_file_id.d.ts +1 -1
- package/script/types/_file_id.d.ts.map +1 -1
- package/script/types/_getters.d.ts +0 -7
- package/script/types/_getters.d.ts.map +1 -1
- package/script/utilities/0_hash.d.ts +2 -2
- package/script/utilities/0_hash.d.ts.map +1 -1
- package/script/utilities/0_misc.d.ts +1 -0
- package/script/utilities/0_misc.d.ts.map +1 -1
- package/script/utilities/0_misc.js +14 -0
- package/script/utilities/0_part_stream.d.ts +1 -1
- package/script/utilities/0_part_stream.d.ts.map +1 -1
- package/esm/types/1_user.d.ts.map +0 -1
- package/esm/types/2_business_connection.d.ts.map +0 -1
- package/esm/types/2_chosen_inline_result.d.ts.map +0 -1
- package/esm/types/2_forward_header.d.ts.map +0 -1
- package/esm/types/2_game.d.ts.map +0 -1
- package/esm/types/2_inline_query.d.ts.map +0 -1
- package/esm/types/2_message_reactions.d.ts.map +0 -1
- package/esm/types/2_pre_checkout_query.d.ts.map +0 -1
- package/esm/types/3_chat_member_updated.d.ts.map +0 -1
- package/esm/types/3_join_request.d.ts.map +0 -1
- package/esm/types/4_claimed_gift.d.ts.map +0 -1
- package/esm/types/5_claimed_gifts.d.ts.map +0 -1
- package/esm/types/5_message.d.ts.map +0 -1
- package/esm/types/6_chat_list_item.d.ts.map +0 -1
- package/esm/types/6_saved_chat.d.ts.map +0 -1
- package/esm/types/7_saved_chats.d.ts.map +0 -1
- package/esm/types/7_update.d.ts.map +0 -1
- package/script/types/1_user.d.ts.map +0 -1
- package/script/types/2_business_connection.d.ts.map +0 -1
- package/script/types/2_chosen_inline_result.d.ts.map +0 -1
- package/script/types/2_forward_header.d.ts.map +0 -1
- package/script/types/2_game.d.ts.map +0 -1
- package/script/types/2_inline_query.d.ts.map +0 -1
- package/script/types/2_message_reactions.d.ts.map +0 -1
- package/script/types/2_pre_checkout_query.d.ts.map +0 -1
- package/script/types/3_chat_member_updated.d.ts.map +0 -1
- package/script/types/3_join_request.d.ts.map +0 -1
- package/script/types/4_claimed_gift.d.ts.map +0 -1
- package/script/types/5_claimed_gifts.d.ts.map +0 -1
- package/script/types/5_message.d.ts.map +0 -1
- package/script/types/6_chat_list_item.d.ts.map +0 -1
- package/script/types/6_saved_chat.d.ts.map +0 -1
- package/script/types/7_saved_chats.d.ts.map +0 -1
- package/script/types/7_update.d.ts.map +0 -1
- /package/esm/types/{2_game.js → 3_game.js} +0 -0
- /package/esm/types/{1_input_media.js → 3_input_media.js} +0 -0
- /package/esm/types/{2_reply_to.js → 4_reply_to.js} +0 -0
- /package/esm/types/{5_message_content.js → 6_message_content.js} +0 -0
- /package/esm/types/{6_topic.js → 7_topic.js} +0 -0
- /package/esm/types/{7_update.js → 8_update.js} +0 -0
- /package/script/types/{2_game.js → 3_game.js} +0 -0
- /package/script/types/{1_input_media.js → 3_input_media.js} +0 -0
- /package/script/types/{2_reply_to.js → 4_reply_to.js} +0 -0
- /package/script/types/{5_message_content.js → 6_message_content.js} +0 -0
- /package/script/types/{6_topic.js → 7_topic.js} +0 -0
- /package/script/types/{7_update.js → 8_update.js} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright 2009 The Go Authors. All rights reserved.
|
|
2
|
+
// https://github.com/golang/go/blob/master/LICENSE
|
|
3
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
4
|
+
// This module is browser compatible.
|
|
5
|
+
/**
|
|
6
|
+
* Port of the Go
|
|
7
|
+
* {@link https://github.com/golang/go/blob/go1.12.5/src/encoding/hex/hex.go | encoding/hex}
|
|
8
|
+
* library.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import {
|
|
12
|
+
* decodeHex,
|
|
13
|
+
* encodeHex,
|
|
14
|
+
* } from "@std/encoding/hex";
|
|
15
|
+
* import { assertEquals } from "@std/assert";
|
|
16
|
+
*
|
|
17
|
+
* assertEquals(encodeHex("abc"), "616263");
|
|
18
|
+
*
|
|
19
|
+
* assertEquals(
|
|
20
|
+
* decodeHex("616263"),
|
|
21
|
+
* new TextEncoder().encode("abc"),
|
|
22
|
+
* );
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
import { validateBinaryLike } from "./_validate_binary_like.js";
|
|
28
|
+
const hexTable = new TextEncoder().encode("0123456789abcdef");
|
|
29
|
+
const textEncoder = new TextEncoder();
|
|
30
|
+
const textDecoder = new TextDecoder();
|
|
31
|
+
function errInvalidByte(byte) {
|
|
32
|
+
return new TypeError(`Invalid byte '${String.fromCharCode(byte)}'`);
|
|
33
|
+
}
|
|
34
|
+
function errLength(len) {
|
|
35
|
+
return new RangeError(`Cannot decode the hex string as the input length should be even: length is ${len}`);
|
|
36
|
+
}
|
|
37
|
+
/** Converts a hex character into its value. */
|
|
38
|
+
function fromHexChar(byte) {
|
|
39
|
+
// '0' <= byte && byte <= '9'
|
|
40
|
+
if (48 <= byte && byte <= 57)
|
|
41
|
+
return byte - 48;
|
|
42
|
+
// 'a' <= byte && byte <= 'f'
|
|
43
|
+
if (97 <= byte && byte <= 102)
|
|
44
|
+
return byte - 97 + 10;
|
|
45
|
+
// 'A' <= byte && byte <= 'F'
|
|
46
|
+
if (65 <= byte && byte <= 70)
|
|
47
|
+
return byte - 65 + 10;
|
|
48
|
+
throw errInvalidByte(byte);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts data into a hex-encoded string.
|
|
52
|
+
*
|
|
53
|
+
* @param src The data to encode.
|
|
54
|
+
*
|
|
55
|
+
* @returns The hex-encoded string.
|
|
56
|
+
*
|
|
57
|
+
* @example Usage
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { encodeHex } from "@std/encoding/hex";
|
|
60
|
+
* import { assertEquals } from "@std/assert";
|
|
61
|
+
*
|
|
62
|
+
* assertEquals(encodeHex("abc"), "616263");
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export function encodeHex(src) {
|
|
66
|
+
const u8 = validateBinaryLike(src);
|
|
67
|
+
const dst = new Uint8Array(u8.length * 2);
|
|
68
|
+
for (let i = 0; i < u8.length; i++) {
|
|
69
|
+
const v = u8[i];
|
|
70
|
+
dst[i * 2] = hexTable[v >> 4];
|
|
71
|
+
dst[i * 2 + 1] = hexTable[v & 0x0f];
|
|
72
|
+
}
|
|
73
|
+
return textDecoder.decode(dst);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Decodes the given hex-encoded string. If the input is malformed, an error is
|
|
77
|
+
* thrown.
|
|
78
|
+
*
|
|
79
|
+
* @param src The hex-encoded string to decode.
|
|
80
|
+
*
|
|
81
|
+
* @returns The decoded data.
|
|
82
|
+
*
|
|
83
|
+
* @example Usage
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { decodeHex } from "@std/encoding/hex";
|
|
86
|
+
* import { assertEquals } from "@std/assert";
|
|
87
|
+
*
|
|
88
|
+
* assertEquals(
|
|
89
|
+
* decodeHex("616263"),
|
|
90
|
+
* new TextEncoder().encode("abc"),
|
|
91
|
+
* );
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function decodeHex(src) {
|
|
95
|
+
const u8 = textEncoder.encode(src);
|
|
96
|
+
const dst = new Uint8Array(u8.length / 2);
|
|
97
|
+
for (let i = 0; i < dst.length; i++) {
|
|
98
|
+
const a = fromHexChar(u8[i * 2]);
|
|
99
|
+
const b = fromHexChar(u8[i * 2 + 1]);
|
|
100
|
+
dst[i] = (a << 4) | b;
|
|
101
|
+
}
|
|
102
|
+
if (u8.length % 2 === 1) {
|
|
103
|
+
// Check for invalid char before reporting bad length,
|
|
104
|
+
// since the invalid char (if present) is an earlier problem.
|
|
105
|
+
fromHexChar(u8[dst.length * 2]);
|
|
106
|
+
throw errLength(u8.length);
|
|
107
|
+
}
|
|
108
|
+
return dst;
|
|
109
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IA6BD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CACjD"}
|
|
1
|
+
{"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IA6BD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CACjD"}
|
package/esm/session/1_session.js
CHANGED
|
@@ -33,9 +33,9 @@ export declare class SessionEncrypted extends Session implements Session {
|
|
|
33
33
|
handlers: Handlers;
|
|
34
34
|
constructor(dc: DC, params?: SessionParams);
|
|
35
35
|
setAuthKey(key: Uint8Array<ArrayBuffer>): Promise<void>;
|
|
36
|
-
get authKey(): Uint8Array
|
|
36
|
+
get authKey(): Uint8Array<ArrayBuffer>;
|
|
37
37
|
connect(): Promise<void>;
|
|
38
38
|
disconnect(): void;
|
|
39
|
-
send(body: Uint8Array): Promise<bigint>;
|
|
39
|
+
send(body: Uint8Array<ArrayBuffer>): Promise<bigint>;
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=2_session_encrypted.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAwD,OAAO,EAAuC,MAAM,YAAY,CAAC;AAChI,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAwD,OAAO,EAAuC,MAAM,YAAY,CAAC;AAChI,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAa7D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC;IACtC,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;IAC5D,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxD;AAED,qBAAa,gBAAiB,SAAQ,OAAQ,YAAW,OAAO;;IAI9D,QAAQ,EAAE,QAAQ,CAAM;gBAiBZ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAQpC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC;IAM7C,IAAI,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAErC;IAEc,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAe9B,UAAU,IAAI,IAAI;IA6ErB,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CA6W3D"}
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import { assertEquals, concat, delay, ige256Decrypt, ige256Encrypt, initTgCrypto, SECOND } from "../0_deps.js";
|
|
20
|
+
import { assertEquals, concat, delay, ige256Decrypt, ige256Encrypt, initTgCrypto, LruCache, SECOND } from "../0_deps.js";
|
|
21
21
|
import { ConnectionError, TransportError } from "../0_errors.js";
|
|
22
22
|
import { bigIntFromBuffer, bufferFromBigInt, drop, getLogger, getRandomId, gunzip, mod, sha1, sha256, toUnixTimestamp } from "../1_utilities.js";
|
|
23
23
|
import { deserializeMessage, Mtproto, repr, serializeMessage, TLReader, X } from "../2_tl.js";
|
|
24
|
+
import { AbortableLoop } from "../client/0_abortable_loop.js";
|
|
24
25
|
import { TLWriter } from "../tl/1_tl_writer.js";
|
|
25
26
|
import { SessionError } from "./0_session_error.js";
|
|
26
27
|
import { Session } from "./1_session.js";
|
|
@@ -30,19 +31,27 @@ const GZIP_PACKED = 0x3072CFA1;
|
|
|
30
31
|
const RPC_RESULT = 0xF35C6D01;
|
|
31
32
|
const RPC_ERROR = Mtproto.schema.definitions["rpc_error"][0];
|
|
32
33
|
export class SessionEncrypted extends Session {
|
|
34
|
+
static #TGCRYPTO_INITED = false;
|
|
33
35
|
#id = getRandomId();
|
|
36
|
+
handlers = {};
|
|
37
|
+
#L;
|
|
38
|
+
#LsendLoop;
|
|
39
|
+
#LreceiveLoop;
|
|
40
|
+
#LpingLoop;
|
|
34
41
|
#authKey = new Uint8Array();
|
|
35
42
|
#authKeyId = 0n;
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
#
|
|
43
|
+
#sentMessages = new Set();
|
|
44
|
+
#pendingMessages = new Array();
|
|
45
|
+
#containers = new LruCache(20_000);
|
|
39
46
|
#pendingPings = new Map();
|
|
40
|
-
#
|
|
41
|
-
|
|
47
|
+
#toAcknowledge = new Array();
|
|
48
|
+
#pendingAcks = new LruCache(100);
|
|
42
49
|
constructor(dc, params) {
|
|
43
50
|
super(dc, params);
|
|
44
51
|
const L = this.#L = getLogger("SessionEncrypted").client(id++);
|
|
45
|
-
this.#
|
|
52
|
+
this.#LsendLoop = L.branch("sendLoop");
|
|
53
|
+
this.#LreceiveLoop = L.branch("receiveLoop");
|
|
54
|
+
this.#LpingLoop = L.branch("pingLoop");
|
|
46
55
|
}
|
|
47
56
|
async setAuthKey(key) {
|
|
48
57
|
const hash = await sha1(key);
|
|
@@ -61,14 +70,17 @@ export class SessionEncrypted extends Session {
|
|
|
61
70
|
await initTgCrypto();
|
|
62
71
|
SessionEncrypted.#TGCRYPTO_INITED = true;
|
|
63
72
|
}
|
|
64
|
-
this.#
|
|
65
|
-
this.#
|
|
73
|
+
this.#receiveLoop.start();
|
|
74
|
+
this.#sendLoop.start();
|
|
75
|
+
this.#pingLoop.start();
|
|
76
|
+
this.#awakeSendLoop?.();
|
|
66
77
|
}
|
|
67
78
|
disconnect() {
|
|
68
79
|
super.disconnect();
|
|
69
80
|
this.state.reset();
|
|
70
81
|
this.#id = getRandomId();
|
|
71
|
-
this.#
|
|
82
|
+
this.#pingLoop.abort();
|
|
83
|
+
this.#awakeSendLoop?.();
|
|
72
84
|
this.#rejectAllPending(new ConnectionError("Not connected."));
|
|
73
85
|
}
|
|
74
86
|
#assertNotDisconnected() {
|
|
@@ -85,17 +97,34 @@ export class SessionEncrypted extends Session {
|
|
|
85
97
|
this.#rejectAllPending(new SessionError("Session invalidated."));
|
|
86
98
|
}
|
|
87
99
|
#rejectAllPending(reason) {
|
|
88
|
-
for (const id of this.#
|
|
100
|
+
for (const id of this.#sentMessages) {
|
|
89
101
|
this.#onMessageFailed(id, reason);
|
|
90
102
|
}
|
|
91
|
-
this.#pendingMessages.clear();
|
|
92
103
|
for (const pendingPing of this.#pendingPings.values()) {
|
|
93
|
-
pendingPing.reject(reason);
|
|
104
|
+
pendingPing.promiseWithResolvers.reject(reason);
|
|
94
105
|
}
|
|
106
|
+
this.#sentMessages.clear();
|
|
95
107
|
this.#pendingPings.clear();
|
|
108
|
+
this.#containers.clear();
|
|
96
109
|
}
|
|
97
110
|
#onMessageFailed(id, reason) {
|
|
98
|
-
this.#
|
|
111
|
+
this.#sentMessages.delete(id);
|
|
112
|
+
const pendingContainer = this.#containers.get(id);
|
|
113
|
+
if (pendingContainer) {
|
|
114
|
+
for (const id of pendingContainer) {
|
|
115
|
+
this.#onMessageFailed(id, reason);
|
|
116
|
+
}
|
|
117
|
+
this.#containers.delete(id);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const pendingAck = this.#pendingAcks.get(id);
|
|
121
|
+
if (pendingAck) {
|
|
122
|
+
for (const id of pendingAck) {
|
|
123
|
+
this.#toAcknowledge.push(id);
|
|
124
|
+
}
|
|
125
|
+
this.#pendingAcks.delete(id);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
99
128
|
const pendingPing = this.#pendingPings.get(id);
|
|
100
129
|
if (pendingPing) {
|
|
101
130
|
this.#pendingPings.delete(id);
|
|
@@ -103,13 +132,12 @@ export class SessionEncrypted extends Session {
|
|
|
103
132
|
drop(this.#resendPendingPing(pendingPing));
|
|
104
133
|
}
|
|
105
134
|
else {
|
|
106
|
-
pendingPing.reject(reason);
|
|
135
|
+
pendingPing.promiseWithResolvers.reject(reason);
|
|
107
136
|
}
|
|
137
|
+
return;
|
|
108
138
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.handlers.onMessageFailed?.(id, reason);
|
|
112
|
-
}
|
|
139
|
+
// message was not sent by us
|
|
140
|
+
this.handlers.onMessageFailed?.(id, reason);
|
|
113
141
|
}
|
|
114
142
|
#setServerSalt(newServerSalt) {
|
|
115
143
|
this.state.serverSalt = newServerSalt;
|
|
@@ -120,36 +148,10 @@ export class SessionEncrypted extends Session {
|
|
|
120
148
|
await super.waitUntilConnected();
|
|
121
149
|
}
|
|
122
150
|
this.#assertNotDisconnected();
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
msg_id,
|
|
128
|
-
seqno,
|
|
129
|
-
body,
|
|
130
|
-
};
|
|
131
|
-
if (this.#toAcknowledge.length) {
|
|
132
|
-
const ack = {
|
|
133
|
-
_: "message",
|
|
134
|
-
msg_id: this.state.nextMessageId(),
|
|
135
|
-
seqno: this.state.nextSeqNo(false),
|
|
136
|
-
body: Mtproto.serializeObject({ _: "msgs_ack", msg_ids: this.#toAcknowledge.splice(0, 8192) }),
|
|
137
|
-
};
|
|
138
|
-
message = {
|
|
139
|
-
_: "message",
|
|
140
|
-
msg_id: this.state.nextMessageId(),
|
|
141
|
-
seqno: this.state.nextSeqNo(false),
|
|
142
|
-
body: {
|
|
143
|
-
_: "msg_container",
|
|
144
|
-
messages: [message, ack],
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
this.#L.out(message);
|
|
149
|
-
const payload = await this.#encryptMessage(message);
|
|
150
|
-
await this.transport.transport.send(payload);
|
|
151
|
-
this.#pendingMessages.add(msg_id);
|
|
152
|
-
return msg_id;
|
|
151
|
+
const pendingMessage = { body, promiseWithResolvers: Promise.withResolvers() };
|
|
152
|
+
this.#pendingMessages.push(pendingMessage);
|
|
153
|
+
this.#awakeSendLoop?.();
|
|
154
|
+
return await pendingMessage.promiseWithResolvers.promise;
|
|
153
155
|
}
|
|
154
156
|
async #receive() {
|
|
155
157
|
this.#assertNotDisconnected();
|
|
@@ -202,60 +204,133 @@ export class SessionEncrypted extends Session {
|
|
|
202
204
|
const _sessionId_ = plainReader.readInt64(false);
|
|
203
205
|
return deserializeMessage(plainReader);
|
|
204
206
|
}
|
|
205
|
-
////
|
|
206
|
-
#
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
//// SEND LOOP ////
|
|
208
|
+
#awakeSendLoop;
|
|
209
|
+
#sendLoop = new AbortableLoop(this.#sendLoopBody.bind(this), (err) => {
|
|
210
|
+
this.#LsendLoop.error("unhandled receive loop error:", err);
|
|
211
|
+
});
|
|
212
|
+
async #sendLoopBody(loop, signal) {
|
|
213
|
+
if (!this.connected) {
|
|
214
|
+
this.#LsendLoop.debug("aborting as not connected");
|
|
215
|
+
loop.abort();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const pendingMessage = this.#pendingMessages.shift();
|
|
219
|
+
if (pendingMessage === undefined) {
|
|
220
|
+
this.#LsendLoop.debug("no pending messages");
|
|
221
|
+
return await new Promise((resolve) => {
|
|
222
|
+
const onAbort = () => {
|
|
223
|
+
this.#LsendLoop.debug("got aborted while sleeping");
|
|
224
|
+
resolve();
|
|
225
|
+
};
|
|
226
|
+
signal.addEventListener("abort", onAbort);
|
|
227
|
+
this.#awakeSendLoop = () => {
|
|
228
|
+
this.#LsendLoop.debug("got awaken");
|
|
229
|
+
resolve();
|
|
230
|
+
signal.removeEventListener("abort", onAbort);
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
const msg_id = this.state.nextMessageId();
|
|
235
|
+
const seqno = this.state.nextSeqNo(true);
|
|
236
|
+
let message = {
|
|
237
|
+
_: "message",
|
|
238
|
+
msg_id,
|
|
239
|
+
seqno,
|
|
240
|
+
body: pendingMessage.body,
|
|
241
|
+
};
|
|
242
|
+
this.#LsendLoop.debug("msg_id =", msg_id, "seqno =", seqno);
|
|
243
|
+
if (this.#toAcknowledge.length) {
|
|
244
|
+
const msg_ids = this.#toAcknowledge.splice(0, 8192);
|
|
245
|
+
this.#LsendLoop.debug("acknowledging", msg_ids.length, "message(s) while sending this one");
|
|
246
|
+
const ack = {
|
|
247
|
+
_: "message",
|
|
248
|
+
msg_id: this.state.nextMessageId(),
|
|
249
|
+
seqno: this.state.nextSeqNo(false),
|
|
250
|
+
body: Mtproto.serializeObject({ _: "msgs_ack", msg_ids }),
|
|
251
|
+
};
|
|
252
|
+
this.#LsendLoop.debug("msgs_ack msg_id =", ack.msg_id, "seqno =", seqno);
|
|
253
|
+
this.#pendingAcks.set(ack.msg_id, msg_ids);
|
|
254
|
+
message = {
|
|
255
|
+
_: "message",
|
|
256
|
+
msg_id: this.state.nextMessageId(),
|
|
257
|
+
seqno: this.state.nextSeqNo(false),
|
|
258
|
+
body: {
|
|
259
|
+
_: "msg_container",
|
|
260
|
+
messages: [message, ack],
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
this.#LsendLoop.debug("container msg_id =", message.msg_id, "seqno =", message.seqno);
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const payload = await this.#encryptMessage(message);
|
|
267
|
+
await this.transport.transport.send(payload);
|
|
268
|
+
pendingMessage.promiseWithResolvers.resolve(msg_id);
|
|
269
|
+
}
|
|
270
|
+
catch (err) {
|
|
271
|
+
pendingMessage.promiseWithResolvers.reject(err);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
this.#LsendLoop.out(message);
|
|
275
|
+
this.#sentMessages.add(msg_id);
|
|
276
|
+
if (!(message.body instanceof Uint8Array)) {
|
|
277
|
+
const msg_ids = message.body.messages.map((v) => v.msg_id);
|
|
278
|
+
this.#LsendLoop.debug("sent container", message.msg_id, "with messages", ...msg_ids);
|
|
279
|
+
this.#containers.set(message.msg_id, msg_ids);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
this.#LsendLoop.debug("sent message", message.msg_id);
|
|
209
283
|
}
|
|
210
284
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
this.#
|
|
285
|
+
//// RECEIVE LOOP ////
|
|
286
|
+
#receiveLoop = new AbortableLoop(this.#receiveLoopBody.bind(this), (err) => {
|
|
287
|
+
this.#LreceiveLoop.error("unhandled receive loop error:", err);
|
|
288
|
+
});
|
|
289
|
+
async #receiveLoopBody(loop) {
|
|
290
|
+
let message;
|
|
214
291
|
try {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
if (message.body instanceof Uint8Array) {
|
|
231
|
-
this.#onMessage(message.msg_id, message.body);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
this.#onMessageContainer(message.msg_id, message.body);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
catch (err) {
|
|
238
|
-
this.#L.error("failed to handle message:", err);
|
|
239
|
-
}
|
|
292
|
+
message = await this.#receive();
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
this.#LreceiveLoop.error("failed to receive message:", err);
|
|
296
|
+
if (!this.connected) {
|
|
297
|
+
this.#LreceiveLoop.debug("aborting as not connected");
|
|
298
|
+
loop.abort();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
return;
|
|
240
303
|
}
|
|
241
304
|
}
|
|
242
|
-
|
|
243
|
-
|
|
305
|
+
try {
|
|
306
|
+
if (message.body instanceof Uint8Array) {
|
|
307
|
+
this.#onMessage(message.msg_id, message.body, null);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this.#onMessageContainer(message.msg_id, message.body);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
this.#LreceiveLoop.error("failed to handle message:", err);
|
|
244
315
|
}
|
|
245
316
|
}
|
|
246
317
|
//// RECEIVE LOOP HANDLERS ////
|
|
247
|
-
async #onMessage(msgId, body) {
|
|
318
|
+
async #onMessage(msgId, body, containerId) {
|
|
319
|
+
this.#LreceiveLoop.debug("received message with ID", msgId, "and size", body.length, "inside", ...(containerId === null ? ["no container"] : ["container", containerId]));
|
|
320
|
+
const logger = this.#LreceiveLoop.branch(msgId + "");
|
|
248
321
|
let reader = new TLReader(body);
|
|
249
322
|
let id = reader.readInt32(false);
|
|
250
323
|
if (id === GZIP_PACKED) {
|
|
324
|
+
logger.debug("unpacking compressed body");
|
|
251
325
|
reader = new TLReader(await gunzip(reader.readBytes()));
|
|
252
326
|
id = reader.readInt32(false);
|
|
253
327
|
}
|
|
254
328
|
if (id === RPC_RESULT) {
|
|
255
|
-
this.#onRpcResult(msgId, reader.buffer);
|
|
329
|
+
this.#onRpcResult(msgId, reader.buffer, logger);
|
|
256
330
|
return;
|
|
257
331
|
}
|
|
258
332
|
if (!Mtproto.schema.identifierToName[id]) {
|
|
333
|
+
logger.debug("identified body as a non-MTProto constructor");
|
|
259
334
|
reader.unreadInt32();
|
|
260
335
|
this.handlers.onUpdate?.(reader.buffer);
|
|
261
336
|
return;
|
|
@@ -266,10 +341,10 @@ export class SessionEncrypted extends Session {
|
|
|
266
341
|
type = await Mtproto.deserializeType(X, reader);
|
|
267
342
|
}
|
|
268
343
|
catch (err) {
|
|
269
|
-
|
|
344
|
+
logger.error("failed to deserialize MTProto type:", err);
|
|
270
345
|
return;
|
|
271
346
|
}
|
|
272
|
-
|
|
347
|
+
logger.debug("received", repr(type));
|
|
273
348
|
if (Mtproto.is("new_session_created", type)) {
|
|
274
349
|
this.#onNewSessionCreated(msgId, type);
|
|
275
350
|
}
|
|
@@ -280,24 +355,26 @@ export class SessionEncrypted extends Session {
|
|
|
280
355
|
this.#onBadServerSalt(type);
|
|
281
356
|
}
|
|
282
357
|
else if (Mtproto.is("bad_msg_notification", type)) {
|
|
283
|
-
await this.#onBadMsgNotification(msgId, type);
|
|
358
|
+
await this.#onBadMsgNotification(msgId, type, logger);
|
|
284
359
|
}
|
|
285
360
|
else if (Mtproto.is("msg_detailed_info", type)) {
|
|
286
|
-
this.#onMsgDetailedInfo(type);
|
|
361
|
+
this.#onMsgDetailedInfo(type, logger);
|
|
287
362
|
}
|
|
288
363
|
else if (Mtproto.is("msg_new_detailed_info", type)) {
|
|
289
|
-
this.#onMsgNewDetailedInfo(type);
|
|
364
|
+
this.#onMsgNewDetailedInfo(type, logger);
|
|
290
365
|
}
|
|
291
366
|
else {
|
|
292
|
-
|
|
367
|
+
logger.warning(`unhandled MTProto type: ${repr(type)}`);
|
|
293
368
|
}
|
|
294
369
|
}
|
|
295
|
-
async #onRpcResult(msgId, body) {
|
|
370
|
+
async #onRpcResult(msgId, body, logger) {
|
|
371
|
+
logger.debug("received rpc_result");
|
|
296
372
|
this.#toAcknowledge.push(msgId);
|
|
297
373
|
let reader = new TLReader(body);
|
|
298
374
|
const reqMsgId = reader.readInt64();
|
|
299
375
|
let id = reader.readInt32(false);
|
|
300
376
|
if (id === GZIP_PACKED) {
|
|
377
|
+
logger.debug("unpacking compressed rpc_result");
|
|
301
378
|
reader = new TLReader(await gunzip(reader.readBytes()));
|
|
302
379
|
id = reader.readInt32(false);
|
|
303
380
|
reader.unreadInt32();
|
|
@@ -306,6 +383,7 @@ export class SessionEncrypted extends Session {
|
|
|
306
383
|
reader.unreadInt32();
|
|
307
384
|
}
|
|
308
385
|
if (id === RPC_ERROR) {
|
|
386
|
+
logger.debug("received rpc_error from message", msgId);
|
|
309
387
|
const error = await Mtproto.deserializeType("rpc_error", reader);
|
|
310
388
|
this.handlers.onRpcError?.(reqMsgId, error);
|
|
311
389
|
}
|
|
@@ -313,13 +391,15 @@ export class SessionEncrypted extends Session {
|
|
|
313
391
|
this.handlers.onRpcResult?.(reqMsgId, reader.buffer);
|
|
314
392
|
}
|
|
315
393
|
}
|
|
316
|
-
#onMsgDetailedInfo(msgDetailedInfo) {
|
|
394
|
+
#onMsgDetailedInfo(msgDetailedInfo, logger) {
|
|
395
|
+
logger.debug("scheduling the acknowledgement of", msgDetailedInfo.answer_msg_id, "because of", msgDetailedInfo._);
|
|
317
396
|
this.#toAcknowledge.push(msgDetailedInfo.answer_msg_id);
|
|
318
397
|
}
|
|
319
|
-
#onMsgNewDetailedInfo(msgNewDetailedInfo) {
|
|
398
|
+
#onMsgNewDetailedInfo(msgNewDetailedInfo, logger) {
|
|
399
|
+
logger.debug("scheduling the acknowledgement of", msgNewDetailedInfo.answer_msg_id, "because of", msgNewDetailedInfo._);
|
|
320
400
|
this.#toAcknowledge.push(msgNewDetailedInfo.answer_msg_id);
|
|
321
401
|
}
|
|
322
|
-
async #onBadMsgNotification(msgId, badMsgNotification) {
|
|
402
|
+
async #onBadMsgNotification(msgId, badMsgNotification, logger) {
|
|
323
403
|
let low = false;
|
|
324
404
|
switch (badMsgNotification.error_code) {
|
|
325
405
|
case 16: // message ID too low
|
|
@@ -329,11 +409,12 @@ export class SessionEncrypted extends Session {
|
|
|
329
409
|
this.state.timeDifference = Math.abs(toUnixTimestamp(new Date()) - Number(msgId >> 32n));
|
|
330
410
|
if (!low) {
|
|
331
411
|
this.state.timeDifference = -this.state.timeDifference;
|
|
412
|
+
logger.debug("resetting time difference to", -this.state.timeDifference, "because the ID of the message", badMsgNotification.bad_msg_id, "was too high");
|
|
332
413
|
await this.#invalidateSession("message ID too high");
|
|
333
414
|
return;
|
|
334
415
|
}
|
|
335
416
|
else {
|
|
336
|
-
|
|
417
|
+
logger.debug("resending message", badMsgNotification.bad_msg_id, "because its ID was too low");
|
|
337
418
|
}
|
|
338
419
|
break;
|
|
339
420
|
case 48: // bad server salt
|
|
@@ -354,7 +435,7 @@ export class SessionEncrypted extends Session {
|
|
|
354
435
|
this.#toAcknowledge.push(msgId);
|
|
355
436
|
const pendingPing = this.#pendingPings.get(pong.msg_id);
|
|
356
437
|
if (pendingPing) {
|
|
357
|
-
pendingPing.resolve(pong);
|
|
438
|
+
pendingPing.promiseWithResolvers.resolve(pong);
|
|
358
439
|
this.#pendingPings.delete(pong.msg_id);
|
|
359
440
|
}
|
|
360
441
|
else {
|
|
@@ -367,9 +448,10 @@ export class SessionEncrypted extends Session {
|
|
|
367
448
|
this.#toAcknowledge.push(msgId);
|
|
368
449
|
}
|
|
369
450
|
#onMessageContainer(msgId, msgContainer) {
|
|
451
|
+
this.#LreceiveLoop.debug("received container with ID", msgId, "and", msgContainer.messages.length, "message(s)");
|
|
370
452
|
for (const message of msgContainer.messages) {
|
|
371
453
|
if (message.body instanceof Uint8Array) {
|
|
372
|
-
this.#onMessage(message.msg_id, message.body);
|
|
454
|
+
this.#onMessage(message.msg_id, message.body, msgId);
|
|
373
455
|
}
|
|
374
456
|
else {
|
|
375
457
|
this.#onMessageContainer(msgId, message.body);
|
|
@@ -378,49 +460,30 @@ export class SessionEncrypted extends Session {
|
|
|
378
460
|
}
|
|
379
461
|
//// PING LOOP ////
|
|
380
462
|
#pingInterval = 56 * SECOND;
|
|
381
|
-
#
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
#
|
|
385
|
-
#LpingLoop;
|
|
386
|
-
async #pingLoop() {
|
|
387
|
-
this.#pingLoopAbortController?.abort();
|
|
388
|
-
const controller = this.#pingLoopAbortController = new AbortController();
|
|
463
|
+
#pingLoop = new AbortableLoop(this.#pingLoopBody.bind(this), (err) => {
|
|
464
|
+
this.#LpingLoop.error(err);
|
|
465
|
+
});
|
|
466
|
+
async #pingLoopBody(_loop, signal) {
|
|
389
467
|
let timeElapsed = 0;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
finally {
|
|
402
|
-
timeElapsed = Date.now() - then;
|
|
403
|
-
}
|
|
404
|
-
controller.signal.throwIfAborted();
|
|
405
|
-
}
|
|
406
|
-
catch (err) {
|
|
407
|
-
if (err instanceof DOMException && err.name === "AbortError") {
|
|
408
|
-
break;
|
|
409
|
-
}
|
|
410
|
-
else if (!this.connected) {
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
this.#LpingLoop.error(err);
|
|
414
|
-
}
|
|
468
|
+
await delay(Math.max(0, this.#pingInterval - timeElapsed), { signal });
|
|
469
|
+
if (!this.connected) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
signal.throwIfAborted();
|
|
473
|
+
const then = Date.now();
|
|
474
|
+
try {
|
|
475
|
+
await this.#sendPingDelayDisconnect(this.#pingInterval / SECOND + 15);
|
|
476
|
+
}
|
|
477
|
+
finally {
|
|
478
|
+
timeElapsed = Date.now() - then;
|
|
415
479
|
}
|
|
480
|
+
signal.throwIfAborted();
|
|
416
481
|
}
|
|
417
482
|
async #sendPingDelayDisconnect(disconnect_delay) {
|
|
418
483
|
const ping_id = getRandomId();
|
|
419
484
|
const call = { _: "ping_delay_disconnect", ping_id, disconnect_delay };
|
|
420
485
|
const messageId = await this.send(Mtproto.serializeObject(call));
|
|
421
|
-
|
|
422
|
-
this.#pendingPings.set(messageId, { call, resolve, reject });
|
|
423
|
-
});
|
|
486
|
+
this.#pendingPings.set(messageId, { call, promiseWithResolvers: Promise.withResolvers() });
|
|
424
487
|
}
|
|
425
488
|
async #resendPendingPing(pendingPing) {
|
|
426
489
|
try {
|
|
@@ -428,7 +491,7 @@ export class SessionEncrypted extends Session {
|
|
|
428
491
|
this.#pendingPings.set(messageId, pendingPing);
|
|
429
492
|
}
|
|
430
493
|
catch (err) {
|
|
431
|
-
pendingPing.reject(err);
|
|
494
|
+
pendingPing.promiseWithResolvers.reject(err);
|
|
432
495
|
}
|
|
433
496
|
}
|
|
434
497
|
}
|