@mtkruto/node 0.62.1 → 0.63.0
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/2_tl.d.ts +6 -6
- package/esm/2_tl.d.ts.map +1 -1
- package/esm/2_tl.js +6 -6
- package/esm/3_errors.d.ts +1 -2
- package/esm/3_errors.d.ts.map +1 -1
- package/esm/3_errors.js +2 -1
- package/esm/4_constants.d.ts +0 -1
- package/esm/4_constants.d.ts.map +1 -1
- package/esm/4_constants.js +0 -1
- package/esm/4_errors.d.ts +2 -2
- package/esm/4_errors.d.ts.map +1 -1
- package/esm/4_session.d.ts +24 -0
- package/esm/4_session.d.ts.map +1 -0
- package/esm/4_session.js +23 -0
- package/esm/5_client.d.ts +1 -1
- package/esm/5_client.js +1 -1
- package/esm/client/0_client_abstract.d.ts +28 -26
- package/esm/client/0_client_abstract.d.ts.map +1 -1
- package/esm/client/0_client_abstract.js +16 -88
- package/esm/client/0_params.d.ts +5 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password.js +2 -2
- package/esm/client/0_storage_operations.d.ts +4 -4
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +14 -14
- package/esm/client/0_update_processor.d.ts +19 -0
- package/esm/client/0_update_processor.d.ts.map +1 -1
- package/esm/client/0_update_processor.js +19 -0
- package/esm/client/0_utilities.d.ts +6 -2
- package/esm/client/0_utilities.d.ts.map +1 -1
- package/esm/client/0_utilities.js +21 -23
- package/esm/client/1_client_plain.d.ts +9 -6
- package/esm/client/1_client_plain.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +26 -41
- package/esm/client/1_types.d.ts +4 -23
- package/esm/client/1_types.d.ts.map +1 -1
- package/esm/client/2_account_manager.js +10 -10
- package/esm/client/2_business_connection_manager.d.ts.map +1 -1
- package/esm/client/2_business_connection_manager.js +4 -4
- package/esm/client/2_client_encrypted.d.ts +58 -0
- package/esm/client/2_client_encrypted.d.ts.map +1 -0
- package/esm/client/2_client_encrypted.js +265 -0
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +54 -74
- package/esm/client/2_network_statistics_manager.d.ts +1 -1
- package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +3 -3
- package/esm/client/2_payment_manager.d.ts.map +1 -1
- package/esm/client/2_payment_manager.js +3 -3
- package/esm/client/2_reaction_manager.d.ts.map +1 -1
- package/esm/client/2_reaction_manager.js +10 -10
- package/esm/client/2_translations_manager.d.ts +19 -0
- package/esm/client/2_translations_manager.d.ts.map +1 -1
- package/esm/client/2_translations_manager.js +24 -5
- package/esm/client/2_update_manager.d.ts +4 -4
- package/esm/client/2_update_manager.d.ts.map +1 -1
- package/esm/client/2_update_manager.js +69 -79
- package/esm/client/3_client_encrypted_pool.d.ts +30 -0
- package/esm/client/3_client_encrypted_pool.d.ts.map +1 -0
- package/esm/client/3_client_encrypted_pool.js +70 -0
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +96 -70
- package/esm/client/3_video_chat_manager.d.ts.map +1 -1
- package/esm/client/3_video_chat_manager.js +15 -20
- package/esm/client/4_callback_query_manager.d.ts.map +1 -1
- package/esm/client/4_callback_query_manager.js +2 -2
- package/esm/client/4_chat_list_manager.d.ts.map +1 -1
- package/esm/client/4_chat_list_manager.js +33 -33
- package/esm/client/4_chat_manager.d.ts.map +1 -1
- package/esm/client/4_chat_manager.js +25 -25
- package/esm/client/4_gift_manager.js +2 -2
- package/esm/client/4_inline_query_manager.d.ts.map +1 -1
- package/esm/client/4_inline_query_manager.js +4 -4
- package/esm/client/4_poll_manager.d.ts.map +1 -1
- package/esm/client/4_poll_manager.js +5 -5
- package/esm/client/4_story_manager.d.ts.map +1 -1
- package/esm/client/4_story_manager.js +10 -10
- package/esm/client/5_client.d.ts +3 -9
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +290 -306
- package/esm/connection/0_connection.d.ts +5 -4
- package/esm/connection/0_connection.d.ts.map +1 -1
- package/esm/connection/1_connection_web_socket.js +2 -2
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -1
- package/{script/tl/2_tl_reader.d.ts → esm/session/0_session_error.d.ts} +4 -7
- package/esm/session/0_session_error.d.ts.map +1 -0
- package/esm/{tl/2_tl_reader.d.ts → session/0_session_error.js} +5 -7
- package/esm/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
- package/esm/session/0_session_state.d.ts.map +1 -0
- package/esm/session/0_session_state.js +77 -0
- package/esm/session/1_session.d.ts +31 -0
- package/esm/session/1_session.d.ts.map +1 -0
- package/esm/session/1_session.js +149 -0
- package/esm/session/2_session_encrypted.d.ts +40 -0
- package/esm/session/2_session_encrypted.d.ts.map +1 -0
- package/esm/session/2_session_encrypted.js +416 -0
- package/esm/session/2_session_plain.d.ts +25 -0
- package/esm/session/2_session_plain.d.ts.map +1 -0
- package/esm/session/2_session_plain.js +56 -0
- package/esm/tl/0_tl_error.d.ts +22 -0
- package/esm/tl/0_tl_error.d.ts.map +1 -0
- package/esm/tl/0_tl_error.js +21 -0
- package/esm/tl/0_types.d.ts +25 -0
- package/esm/tl/0_types.d.ts.map +1 -0
- package/esm/tl/0_types.js +20 -0
- package/esm/tl/0_utilities.d.ts +32 -0
- package/esm/tl/0_utilities.d.ts.map +1 -0
- package/esm/tl/0_utilities.js +51 -0
- package/esm/tl/0_utilities_test.d.ts.map +1 -0
- package/esm/tl/1_mtproto_api.d.ts +371 -0
- package/esm/tl/1_mtproto_api.d.ts.map +1 -0
- package/esm/tl/1_mtproto_api.js +416 -0
- package/esm/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
- package/esm/tl/1_telegram_api.d.ts.map +1 -0
- package/esm/tl/{0_api.js → 1_telegram_api.js} +4945 -11109
- package/{script/tl/0_tl_raw_reader.d.ts → esm/tl/1_tl_reader.d.ts} +5 -2
- package/esm/tl/1_tl_reader.d.ts.map +1 -0
- package/esm/tl/{2_tl_reader.js → 1_tl_reader.js} +107 -40
- package/esm/tl/1_tl_reader_test.d.ts.map +1 -0
- package/esm/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
- package/esm/tl/1_tl_writer.d.ts.map +1 -0
- package/esm/tl/{2_tl_writer.js → 1_tl_writer.js} +80 -23
- package/esm/tl/1_tl_writer_test.d.ts.map +1 -0
- package/esm/tl/1_utilities.d.ts +9 -24
- package/esm/tl/1_utilities.d.ts.map +1 -1
- package/esm/tl/1_utilities.js +18 -64
- package/esm/tl/2_message.d.ts +2 -2
- package/esm/tl/2_message.d.ts.map +1 -1
- package/esm/tl/2_message.js +7 -7
- package/esm/tl/2_mtproto.d.ts +33 -0
- package/esm/tl/2_mtproto.d.ts.map +1 -0
- package/esm/tl/2_mtproto.js +53 -0
- package/{script/tl/2_utilities.d.ts → esm/tl/2_telegram.d.ts} +16 -2
- package/esm/tl/2_telegram.d.ts.map +1 -0
- package/esm/tl/{2_utilities.js → 2_telegram.js} +46 -1
- package/esm/transport/0_transport.d.ts +1 -1
- package/esm/transport/0_transport.d.ts.map +1 -1
- package/esm/types/0_chat_photo.d.ts.map +1 -1
- package/esm/types/0_chat_photo.js +2 -2
- package/esm/types/0_giveaway_parameters.d.ts.map +1 -1
- package/esm/types/0_giveaway_parameters.js +3 -3
- package/esm/types/0_location.d.ts.map +1 -1
- package/esm/types/0_location.js +5 -5
- package/esm/types/0_message_entity.d.ts.map +1 -1
- package/esm/types/0_message_entity.js +20 -20
- package/esm/types/0_reaction.d.ts.map +1 -1
- package/esm/types/0_reaction.js +4 -4
- package/esm/types/0_slow_mode_duration.d.ts +19 -0
- package/esm/types/0_slow_mode_duration.d.ts.map +1 -1
- package/esm/types/0_slow_mode_duration.js +19 -0
- package/esm/types/0_thumbnail.d.ts.map +1 -1
- package/esm/types/0_thumbnail.js +3 -3
- package/esm/types/0_translation.d.ts +19 -0
- package/esm/types/0_translation.d.ts.map +1 -1
- package/esm/types/0_translation.js +22 -3
- package/esm/types/0_video_chat.d.ts.map +1 -1
- package/esm/types/0_video_chat.js +2 -2
- package/esm/types/1_animation.d.ts.map +1 -1
- package/esm/types/1_animation.js +2 -2
- package/esm/types/1_audio.d.ts.map +1 -1
- package/esm/types/1_audio.js +2 -2
- package/esm/types/1_bot_command_scope.d.ts.map +1 -1
- package/esm/types/1_bot_command_scope.js +2 -2
- package/esm/types/1_chat_p.d.ts.map +1 -1
- package/esm/types/1_chat_p.js +6 -6
- package/esm/types/1_document.d.ts.map +1 -1
- package/esm/types/1_document.js +2 -2
- package/esm/types/1_keyboard_button.d.ts.map +1 -1
- package/esm/types/1_keyboard_button.js +10 -10
- package/esm/types/1_message_reaction.d.ts.map +1 -1
- package/esm/types/1_message_reaction.js +6 -6
- package/esm/types/1_photo.d.ts.map +1 -1
- package/esm/types/1_photo.js +3 -3
- package/esm/types/1_sticker.d.ts.map +1 -1
- package/esm/types/1_sticker.js +8 -8
- package/esm/types/1_story_privacy.d.ts.map +1 -1
- package/esm/types/1_story_privacy.js +7 -7
- package/esm/types/1_user.d.ts.map +1 -1
- package/esm/types/1_user.js +2 -2
- package/esm/types/1_venue.d.ts.map +1 -1
- package/esm/types/1_venue.js +2 -2
- package/esm/types/1_video.d.ts.map +1 -1
- package/esm/types/1_video.js +2 -2
- package/esm/types/1_video_note.d.ts.map +1 -1
- package/esm/types/1_video_note.js +2 -2
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_chat.js +8 -8
- package/esm/types/2_chat_member.d.ts.map +1 -1
- package/esm/types/2_chat_member.js +10 -10
- package/esm/types/2_chat_settings.d.ts +19 -0
- package/esm/types/2_chat_settings.d.ts.map +1 -1
- package/esm/types/2_chat_settings.js +21 -2
- package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
- package/esm/types/2_chosen_inline_result.js +4 -4
- package/esm/types/2_game.d.ts.map +1 -1
- package/esm/types/2_game.js +4 -4
- package/esm/types/2_gift_upgraded_component.d.ts.map +1 -1
- package/esm/types/2_gift_upgraded_component.js +3 -3
- package/esm/types/2_inactive_chat.d.ts.map +1 -1
- package/esm/types/2_inactive_chat.js +2 -2
- package/esm/types/2_inline_keyboard_button.d.ts.map +1 -1
- package/esm/types/2_inline_keyboard_button.js +10 -10
- package/esm/types/2_inline_query.d.ts.map +1 -1
- package/esm/types/2_inline_query.js +7 -7
- package/esm/types/2_message_reactions.d.ts.map +1 -1
- package/esm/types/2_message_reactions.js +2 -2
- package/esm/types/2_story_content.d.ts.map +1 -1
- package/esm/types/2_story_content.js +6 -6
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/2_story_interactive_area.js +9 -9
- package/esm/types/3_chat_member_updated.d.ts.map +1 -1
- package/esm/types/3_chat_member_updated.js +2 -2
- package/esm/types/3_gift.d.ts.map +1 -1
- package/esm/types/3_gift.js +3 -3
- package/esm/types/3_join_request.d.ts.map +1 -1
- package/esm/types/3_join_request.js +2 -2
- package/esm/types/3_reply_markup.d.ts.map +1 -1
- package/esm/types/3_reply_markup.js +5 -5
- package/esm/types/4_claimed_gift.d.ts.map +1 -1
- package/esm/types/4_claimed_gift.js +2 -2
- package/esm/types/4_inline_query_result.d.ts.map +1 -1
- package/esm/types/4_inline_query_result.js +14 -14
- package/esm/types/4_message.d.ts.map +1 -1
- package/esm/types/4_message.js +57 -57
- package/esm/types/5_callback_query.d.ts.map +1 -1
- package/esm/types/5_callback_query.js +6 -7
- package/esm/types/5_chat_list_item.d.ts.map +1 -1
- package/esm/types/5_chat_list_item.js +5 -5
- package/esm/types/5_claimed_gifts.d.ts.map +1 -1
- package/esm/types/5_claimed_gifts.js +6 -6
- package/esm/types/_file_id.d.ts.map +1 -1
- package/esm/types/_file_id.js +3 -3
- package/package.json +1 -1
- package/script/2_tl.d.ts +6 -6
- package/script/2_tl.d.ts.map +1 -1
- package/script/2_tl.js +11 -11
- package/script/3_errors.d.ts +1 -2
- package/script/3_errors.d.ts.map +1 -1
- package/script/3_errors.js +2 -1
- package/script/4_constants.d.ts +0 -1
- package/script/4_constants.d.ts.map +1 -1
- package/script/4_constants.js +1 -2
- package/script/4_errors.d.ts +2 -2
- package/script/4_errors.d.ts.map +1 -1
- package/script/4_session.d.ts +24 -0
- package/script/4_session.d.ts.map +1 -0
- package/script/4_session.js +39 -0
- package/script/5_client.d.ts +1 -1
- package/script/5_client.js +1 -1
- package/script/client/0_client_abstract.d.ts +28 -26
- package/script/client/0_client_abstract.d.ts.map +1 -1
- package/script/client/0_client_abstract.js +18 -113
- package/script/client/0_params.d.ts +5 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +1 -1
- package/script/client/0_storage_operations.d.ts +4 -4
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +13 -13
- package/script/client/0_update_processor.d.ts +19 -0
- package/script/client/0_update_processor.d.ts.map +1 -1
- package/script/client/0_update_processor.js +19 -0
- package/script/client/0_utilities.d.ts +6 -2
- package/script/client/0_utilities.d.ts.map +1 -1
- package/script/client/0_utilities.js +22 -24
- package/script/client/1_client_plain.d.ts +9 -6
- package/script/client/1_client_plain.d.ts.map +1 -1
- package/script/client/1_client_plain.js +25 -40
- package/script/client/1_types.d.ts +4 -23
- package/script/client/1_types.d.ts.map +1 -1
- package/script/client/2_account_manager.js +9 -9
- 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 +58 -0
- package/script/client/2_client_encrypted.d.ts.map +1 -0
- package/script/client/2_client_encrypted.js +269 -0
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +52 -72
- package/script/client/2_network_statistics_manager.d.ts +1 -1
- package/script/client/2_network_statistics_manager.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +3 -3
- 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.map +1 -1
- package/script/client/2_reaction_manager.js +9 -9
- package/script/client/2_translations_manager.d.ts +19 -0
- package/script/client/2_translations_manager.d.ts.map +1 -1
- package/script/client/2_translations_manager.js +23 -4
- package/script/client/2_update_manager.d.ts +4 -4
- package/script/client/2_update_manager.d.ts.map +1 -1
- package/script/client/2_update_manager.js +68 -78
- package/script/client/3_client_encrypted_pool.d.ts +30 -0
- package/script/client/3_client_encrypted_pool.d.ts.map +1 -0
- package/script/client/3_client_encrypted_pool.js +74 -0
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +95 -69
- package/script/client/3_video_chat_manager.d.ts.map +1 -1
- package/script/client/3_video_chat_manager.js +14 -19
- 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.map +1 -1
- package/script/client/4_chat_list_manager.js +32 -32
- package/script/client/4_chat_manager.d.ts.map +1 -1
- package/script/client/4_chat_manager.js +24 -24
- package/script/client/4_gift_manager.js +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_poll_manager.d.ts.map +1 -1
- package/script/client/4_poll_manager.js +4 -4
- package/script/client/4_story_manager.d.ts.map +1 -1
- package/script/client/4_story_manager.js +9 -9
- package/script/client/5_client.d.ts +3 -9
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +284 -300
- package/script/connection/0_connection.d.ts +5 -4
- package/script/connection/0_connection.d.ts.map +1 -1
- package/script/connection/1_connection_web_socket.js +2 -2
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -2
- package/script/session/0_session_error.d.ts +24 -0
- package/script/session/0_session_error.d.ts.map +1 -0
- package/script/session/0_session_error.js +29 -0
- package/script/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
- package/script/session/0_session_state.d.ts.map +1 -0
- package/script/session/0_session_state.js +81 -0
- package/script/session/1_session.d.ts +31 -0
- package/script/session/1_session.d.ts.map +1 -0
- package/script/session/1_session.js +176 -0
- package/script/session/2_session_encrypted.d.ts +40 -0
- package/script/session/2_session_encrypted.d.ts.map +1 -0
- package/script/session/2_session_encrypted.js +420 -0
- package/script/session/2_session_plain.d.ts +25 -0
- package/script/session/2_session_plain.d.ts.map +1 -0
- package/script/session/2_session_plain.js +60 -0
- package/script/tl/0_tl_error.d.ts +22 -0
- package/script/tl/0_tl_error.d.ts.map +1 -0
- package/script/tl/0_tl_error.js +25 -0
- package/script/tl/0_types.d.ts +25 -0
- package/script/tl/0_types.d.ts.map +1 -0
- package/script/tl/0_types.js +21 -0
- package/script/tl/0_utilities.d.ts +32 -0
- package/script/tl/0_utilities.d.ts.map +1 -0
- package/script/tl/0_utilities.js +59 -0
- package/script/tl/0_utilities_test.d.ts.map +1 -0
- package/script/tl/1_mtproto_api.d.ts +371 -0
- package/script/tl/1_mtproto_api.d.ts.map +1 -0
- package/script/tl/1_mtproto_api.js +419 -0
- package/script/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
- package/script/tl/1_telegram_api.d.ts.map +1 -0
- package/script/tl/{0_api.js → 1_telegram_api.js} +4947 -11134
- package/{esm/tl/0_tl_raw_reader.d.ts → script/tl/1_tl_reader.d.ts} +5 -2
- package/script/tl/1_tl_reader.d.ts.map +1 -0
- package/script/tl/1_tl_reader.js +218 -0
- package/script/tl/1_tl_reader_test.d.ts.map +1 -0
- package/script/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
- package/script/tl/1_tl_writer.d.ts.map +1 -0
- package/script/tl/{2_tl_writer.js → 1_tl_writer.js} +102 -45
- package/script/tl/1_tl_writer_test.d.ts.map +1 -0
- package/script/tl/1_utilities.d.ts +9 -24
- package/script/tl/1_utilities.d.ts.map +1 -1
- package/script/tl/1_utilities.js +19 -72
- package/script/tl/2_message.d.ts +2 -2
- package/script/tl/2_message.d.ts.map +1 -1
- package/script/tl/2_message.js +7 -7
- package/script/tl/2_mtproto.d.ts +33 -0
- package/script/tl/2_mtproto.d.ts.map +1 -0
- package/script/tl/2_mtproto.js +78 -0
- package/{esm/tl/2_utilities.d.ts → script/tl/2_telegram.d.ts} +16 -2
- package/script/tl/2_telegram.d.ts.map +1 -0
- package/script/tl/2_telegram.js +167 -0
- package/script/transport/0_transport.d.ts +1 -1
- package/script/transport/0_transport.d.ts.map +1 -1
- package/script/types/0_chat_photo.d.ts.map +1 -1
- package/script/types/0_chat_photo.js +1 -1
- package/script/types/0_giveaway_parameters.d.ts.map +1 -1
- package/script/types/0_giveaway_parameters.js +2 -2
- package/script/types/0_location.d.ts.map +1 -1
- package/script/types/0_location.js +4 -4
- package/script/types/0_message_entity.d.ts.map +1 -1
- package/script/types/0_message_entity.js +19 -19
- package/script/types/0_reaction.d.ts.map +1 -1
- package/script/types/0_reaction.js +3 -3
- package/script/types/0_slow_mode_duration.d.ts +19 -0
- package/script/types/0_slow_mode_duration.d.ts.map +1 -1
- package/script/types/0_slow_mode_duration.js +19 -0
- package/script/types/0_thumbnail.d.ts.map +1 -1
- package/script/types/0_thumbnail.js +2 -2
- package/script/types/0_translation.d.ts +19 -0
- package/script/types/0_translation.d.ts.map +1 -1
- package/script/types/0_translation.js +21 -2
- package/script/types/0_video_chat.d.ts.map +1 -1
- package/script/types/0_video_chat.js +1 -1
- package/script/types/1_animation.d.ts.map +1 -1
- package/script/types/1_animation.js +1 -1
- package/script/types/1_audio.d.ts.map +1 -1
- package/script/types/1_audio.js +1 -1
- package/script/types/1_bot_command_scope.d.ts.map +1 -1
- package/script/types/1_bot_command_scope.js +1 -1
- package/script/types/1_chat_p.d.ts.map +1 -1
- package/script/types/1_chat_p.js +5 -5
- package/script/types/1_document.d.ts.map +1 -1
- package/script/types/1_document.js +1 -1
- package/script/types/1_keyboard_button.d.ts.map +1 -1
- package/script/types/1_keyboard_button.js +9 -9
- package/script/types/1_message_reaction.d.ts.map +1 -1
- package/script/types/1_message_reaction.js +5 -5
- package/script/types/1_photo.d.ts.map +1 -1
- package/script/types/1_photo.js +2 -2
- package/script/types/1_sticker.d.ts.map +1 -1
- package/script/types/1_sticker.js +7 -7
- package/script/types/1_story_privacy.d.ts.map +1 -1
- package/script/types/1_story_privacy.js +6 -6
- package/script/types/1_user.d.ts.map +1 -1
- package/script/types/1_user.js +1 -1
- package/script/types/1_venue.d.ts.map +1 -1
- package/script/types/1_venue.js +1 -1
- package/script/types/1_video.d.ts.map +1 -1
- package/script/types/1_video.js +1 -1
- package/script/types/1_video_note.d.ts.map +1 -1
- package/script/types/1_video_note.js +1 -1
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_chat.js +7 -7
- package/script/types/2_chat_member.d.ts.map +1 -1
- package/script/types/2_chat_member.js +9 -9
- package/script/types/2_chat_settings.d.ts +19 -0
- package/script/types/2_chat_settings.d.ts.map +1 -1
- package/script/types/2_chat_settings.js +20 -1
- package/script/types/2_chosen_inline_result.d.ts.map +1 -1
- package/script/types/2_chosen_inline_result.js +3 -3
- package/script/types/2_game.d.ts.map +1 -1
- package/script/types/2_game.js +3 -3
- package/script/types/2_gift_upgraded_component.d.ts.map +1 -1
- package/script/types/2_gift_upgraded_component.js +2 -2
- package/script/types/2_inactive_chat.d.ts.map +1 -1
- package/script/types/2_inactive_chat.js +1 -1
- package/script/types/2_inline_keyboard_button.d.ts.map +1 -1
- package/script/types/2_inline_keyboard_button.js +9 -9
- package/script/types/2_inline_query.d.ts.map +1 -1
- package/script/types/2_inline_query.js +6 -6
- package/script/types/2_message_reactions.d.ts.map +1 -1
- package/script/types/2_message_reactions.js +1 -1
- package/script/types/2_story_content.d.ts.map +1 -1
- package/script/types/2_story_content.js +5 -5
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/2_story_interactive_area.js +8 -8
- package/script/types/3_chat_member_updated.d.ts.map +1 -1
- package/script/types/3_chat_member_updated.js +1 -1
- package/script/types/3_gift.d.ts.map +1 -1
- package/script/types/3_gift.js +2 -2
- package/script/types/3_join_request.d.ts.map +1 -1
- package/script/types/3_join_request.js +1 -1
- package/script/types/3_reply_markup.d.ts.map +1 -1
- package/script/types/3_reply_markup.js +4 -4
- package/script/types/4_claimed_gift.d.ts.map +1 -1
- package/script/types/4_claimed_gift.js +1 -1
- package/script/types/4_inline_query_result.d.ts.map +1 -1
- package/script/types/4_inline_query_result.js +13 -13
- package/script/types/4_message.d.ts.map +1 -1
- package/script/types/4_message.js +56 -56
- package/script/types/5_callback_query.d.ts.map +1 -1
- package/script/types/5_callback_query.js +5 -6
- package/script/types/5_chat_list_item.d.ts.map +1 -1
- package/script/types/5_chat_list_item.js +4 -4
- package/script/types/5_claimed_gifts.d.ts.map +1 -1
- package/script/types/5_claimed_gifts.js +5 -5
- package/script/types/_file_id.d.ts.map +1 -1
- package/script/types/_file_id.js +2 -2
- package/esm/client/0_message.d.ts +0 -29
- package/esm/client/0_message.d.ts.map +0 -1
- package/esm/client/0_message.js +0 -83
- package/esm/client/1_client_encrypted.d.ts +0 -52
- package/esm/client/1_client_encrypted.d.ts.map +0 -1
- package/esm/client/1_client_encrypted.js +0 -381
- package/esm/tl/0_api.d.ts.map +0 -1
- package/esm/tl/0_tl_raw_reader.d.ts.map +0 -1
- package/esm/tl/0_tl_raw_reader.js +0 -97
- package/esm/tl/0_tl_raw_reader_test.d.ts.map +0 -1
- package/esm/tl/0_tl_raw_writer.d.ts.map +0 -1
- package/esm/tl/0_tl_raw_writer.js +0 -86
- package/esm/tl/0_tl_raw_writer_test.d.ts.map +0 -1
- package/esm/tl/1_utilities_test.d.ts.map +0 -1
- package/esm/tl/2_tl_reader.d.ts.map +0 -1
- package/esm/tl/2_tl_reader_test.d.ts.map +0 -1
- package/esm/tl/2_tl_writer.d.ts.map +0 -1
- package/esm/tl/2_tl_writer_test.d.ts.map +0 -1
- package/esm/tl/2_utilities.d.ts.map +0 -1
- package/script/client/0_message.d.ts +0 -29
- package/script/client/0_message.d.ts.map +0 -1
- package/script/client/0_message.js +0 -90
- package/script/client/1_client_encrypted.d.ts +0 -52
- package/script/client/1_client_encrypted.d.ts.map +0 -1
- package/script/client/1_client_encrypted.js +0 -385
- package/script/tl/0_api.d.ts.map +0 -1
- package/script/tl/0_tl_raw_reader.d.ts.map +0 -1
- package/script/tl/0_tl_raw_reader.js +0 -102
- package/script/tl/0_tl_raw_reader_test.d.ts.map +0 -1
- package/script/tl/0_tl_raw_writer.d.ts.map +0 -1
- package/script/tl/0_tl_raw_writer.js +0 -90
- package/script/tl/0_tl_raw_writer_test.d.ts.map +0 -1
- package/script/tl/1_utilities_test.d.ts.map +0 -1
- package/script/tl/2_tl_reader.d.ts.map +0 -1
- package/script/tl/2_tl_reader.js +0 -150
- package/script/tl/2_tl_reader_test.d.ts.map +0 -1
- package/script/tl/2_tl_writer.d.ts.map +0 -1
- package/script/tl/2_tl_writer_test.d.ts.map +0 -1
- package/script/tl/2_utilities.d.ts.map +0 -1
- package/script/tl/2_utilities.js +0 -98
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
5
|
-
*
|
|
6
|
-
* This file is part of MTKruto.
|
|
7
|
-
*
|
|
8
|
-
* This program is free software: you can redistribute it and/or modify
|
|
9
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
* (at your option) any later version.
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU Lesser General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
-
*/
|
|
21
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
25
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
-
};
|
|
27
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
28
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
30
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
-
};
|
|
32
|
-
var _ClientEncrypted_instances, _ClientEncrypted_authKey, _ClientEncrypted_authKeyId, _ClientEncrypted_sessionId, _ClientEncrypted_state, _ClientEncrypted_shouldInvalidateSession, _ClientEncrypted_toAcknowledge, _ClientEncrypted_recentAcks, _ClientEncrypted_promises, _ClientEncrypted_loopActive, _ClientEncrypted_L, _ClientEncrypted_LreceiveLoop, _ClientEncrypted_Linvoke, _ClientEncrypted_timeDifference, _ClientEncrypted_nextMessageId, _ClientEncrypted_nextSeqNo, _ClientEncrypted_invalidateSession, _ClientEncrypted_sendMessage, _ClientEncrypted_receiveLoop, _ClientEncrypted_handleIncomingMessage, _ClientEncrypted_handleRpcResult, _ClientEncrypted_handleType;
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.ClientEncrypted = void 0;
|
|
35
|
-
const _0_deps_js_1 = require("../0_deps.js");
|
|
36
|
-
const _0_errors_js_1 = require("../0_errors.js");
|
|
37
|
-
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
38
|
-
const _2_tl_js_1 = require("../2_tl.js");
|
|
39
|
-
const _4_errors_js_1 = require("../4_errors.js");
|
|
40
|
-
const _2_tl_writer_js_1 = require("../tl/2_tl_writer.js");
|
|
41
|
-
const _0_client_abstract_js_1 = require("./0_client_abstract.js");
|
|
42
|
-
const _0_message_js_1 = require("./0_message.js");
|
|
43
|
-
const COMPRESSION_THRESHOLD = 1024;
|
|
44
|
-
// global ClientEncrypted ID counter for logs
|
|
45
|
-
let id = 0;
|
|
46
|
-
const RPC_ERROR = _2_tl_js_1.Api.getType("rpc_error")[0];
|
|
47
|
-
/**
|
|
48
|
-
* An MTProto client for making encrypted connections. Most users won't need to interact with this. Used internally by `Client`.
|
|
49
|
-
*
|
|
50
|
-
* There are a few things to note:
|
|
51
|
-
*
|
|
52
|
-
* - This is a bare client and it stores nothing.
|
|
53
|
-
* - It expects an authorization key to be present before invoking any method.
|
|
54
|
-
* - Authorization must be set using `setAuthKey`.
|
|
55
|
-
* - Incoming packets that aren't a reply to a specific call are passed to the assigned handlers.
|
|
56
|
-
* - It doesn't uncompress compressed packets.
|
|
57
|
-
*/
|
|
58
|
-
class ClientEncrypted extends _0_client_abstract_js_1.ClientAbstract {
|
|
59
|
-
constructor(params) {
|
|
60
|
-
super(params);
|
|
61
|
-
_ClientEncrypted_instances.add(this);
|
|
62
|
-
_ClientEncrypted_authKey.set(this, new Uint8Array());
|
|
63
|
-
_ClientEncrypted_authKeyId.set(this, 0n);
|
|
64
|
-
_ClientEncrypted_sessionId.set(this, 0n);
|
|
65
|
-
_ClientEncrypted_state.set(this, { serverSalt: 0n, seqNo: 0, messageId: 0n });
|
|
66
|
-
_ClientEncrypted_shouldInvalidateSession.set(this, true);
|
|
67
|
-
_ClientEncrypted_toAcknowledge.set(this, new Array());
|
|
68
|
-
_ClientEncrypted_recentAcks.set(this, new _1_utilities_js_1.CacheMap(20));
|
|
69
|
-
_ClientEncrypted_promises.set(this, new Map());
|
|
70
|
-
_ClientEncrypted_loopActive.set(this, true);
|
|
71
|
-
// loggers
|
|
72
|
-
_ClientEncrypted_L.set(this, void 0);
|
|
73
|
-
_ClientEncrypted_LreceiveLoop.set(this, void 0);
|
|
74
|
-
_ClientEncrypted_Linvoke.set(this, void 0);
|
|
75
|
-
// receive loop handlers
|
|
76
|
-
Object.defineProperty(this, "handlers", {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true,
|
|
80
|
-
value: {}
|
|
81
|
-
});
|
|
82
|
-
_ClientEncrypted_timeDifference.set(this, 0);
|
|
83
|
-
const L = __classPrivateFieldSet(this, _ClientEncrypted_L, (0, _1_utilities_js_1.getLogger)("ClientEncrypted").client(id++), "f");
|
|
84
|
-
__classPrivateFieldSet(this, _ClientEncrypted_LreceiveLoop, L.branch("receiveLoop"), "f");
|
|
85
|
-
__classPrivateFieldSet(this, _ClientEncrypted_Linvoke, L.branch("invoke"), "f");
|
|
86
|
-
}
|
|
87
|
-
async connect() {
|
|
88
|
-
await super.connect();
|
|
89
|
-
if (__classPrivateFieldGet(this, _ClientEncrypted_shouldInvalidateSession, "f")) {
|
|
90
|
-
__classPrivateFieldSet(this, _ClientEncrypted_sessionId, (0, _1_utilities_js_1.getRandomBigInt)(8, true, false), "f");
|
|
91
|
-
__classPrivateFieldSet(this, _ClientEncrypted_state, { serverSalt: 0n, seqNo: 0, messageId: 0n }, "f");
|
|
92
|
-
__classPrivateFieldSet(this, _ClientEncrypted_shouldInvalidateSession, false, "f");
|
|
93
|
-
}
|
|
94
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_receiveLoop).call(this)); // TODO: ability to join this promise
|
|
95
|
-
}
|
|
96
|
-
async setAuthKey(key) {
|
|
97
|
-
const hash = await (0, _1_utilities_js_1.sha1)(key);
|
|
98
|
-
__classPrivateFieldSet(this, _ClientEncrypted_authKeyId, (0, _1_utilities_js_1.bigIntFromBuffer)(hash.slice(-8), true, false), "f");
|
|
99
|
-
__classPrivateFieldSet(this, _ClientEncrypted_authKey, key, "f");
|
|
100
|
-
}
|
|
101
|
-
get authKey() {
|
|
102
|
-
return __classPrivateFieldGet(this, _ClientEncrypted_authKey, "f");
|
|
103
|
-
}
|
|
104
|
-
set serverSalt(serverSalt) {
|
|
105
|
-
__classPrivateFieldGet(this, _ClientEncrypted_state, "f").serverSalt = serverSalt;
|
|
106
|
-
}
|
|
107
|
-
get serverSalt() {
|
|
108
|
-
return __classPrivateFieldGet(this, _ClientEncrypted_state, "f").serverSalt;
|
|
109
|
-
}
|
|
110
|
-
async invoke(function_, noWait) {
|
|
111
|
-
const messageId = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this);
|
|
112
|
-
let body = new _2_tl_writer_js_1.TLWriter().serialize(function_).buffer;
|
|
113
|
-
if (body.length > COMPRESSION_THRESHOLD) {
|
|
114
|
-
body = new _2_tl_writer_js_1.TLWriter()
|
|
115
|
-
.writeInt32(_2_tl_js_1.GZIP_PACKED, false)
|
|
116
|
-
.writeBytes(await (0, _1_utilities_js_1.gzip)(body))
|
|
117
|
-
.buffer;
|
|
118
|
-
}
|
|
119
|
-
let message_ = {
|
|
120
|
-
_: "message",
|
|
121
|
-
msg_id: messageId,
|
|
122
|
-
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, true),
|
|
123
|
-
body,
|
|
124
|
-
};
|
|
125
|
-
const message__ = message_;
|
|
126
|
-
let container = undefined;
|
|
127
|
-
if (__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").length) {
|
|
128
|
-
const ack = {
|
|
129
|
-
_: "message",
|
|
130
|
-
msg_id: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this),
|
|
131
|
-
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, false),
|
|
132
|
-
body: new _2_tl_writer_js_1.TLWriter().serialize({ _: "msgs_ack", msg_ids: __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").splice(0, 8192) }).buffer,
|
|
133
|
-
};
|
|
134
|
-
__classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").set(ack.msg_id, { container, message: ack });
|
|
135
|
-
message_ = {
|
|
136
|
-
_: "message",
|
|
137
|
-
msg_id: container = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this),
|
|
138
|
-
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, false),
|
|
139
|
-
body: {
|
|
140
|
-
_: "msg_container",
|
|
141
|
-
messages: [message_, ack],
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, message_);
|
|
146
|
-
__classPrivateFieldGet(this, _ClientEncrypted_Linvoke, "f").debug("invoked", function_._);
|
|
147
|
-
if (noWait) {
|
|
148
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").set(messageId, {
|
|
149
|
-
container,
|
|
150
|
-
message: message_,
|
|
151
|
-
call: function_,
|
|
152
|
-
});
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
return (await new Promise((resolve, reject) => {
|
|
156
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").set(messageId, { container, message: message__, resolve, reject, call: function_ });
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.ClientEncrypted = ClientEncrypted;
|
|
161
|
-
_ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakMap(), _ClientEncrypted_sessionId = new WeakMap(), _ClientEncrypted_state = new WeakMap(), _ClientEncrypted_shouldInvalidateSession = new WeakMap(), _ClientEncrypted_toAcknowledge = new WeakMap(), _ClientEncrypted_recentAcks = new WeakMap(), _ClientEncrypted_promises = new WeakMap(), _ClientEncrypted_loopActive = new WeakMap(), _ClientEncrypted_L = new WeakMap(), _ClientEncrypted_LreceiveLoop = new WeakMap(), _ClientEncrypted_Linvoke = new WeakMap(), _ClientEncrypted_timeDifference = new WeakMap(), _ClientEncrypted_instances = new WeakSet(), _ClientEncrypted_nextMessageId = function _ClientEncrypted_nextMessageId() {
|
|
162
|
-
return __classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId = (0, _0_message_js_1.getMessageId)(__classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId, __classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"));
|
|
163
|
-
}, _ClientEncrypted_nextSeqNo = function _ClientEncrypted_nextSeqNo(contentRelated) {
|
|
164
|
-
let seqNo = __classPrivateFieldGet(this, _ClientEncrypted_state, "f").seqNo * 2;
|
|
165
|
-
if (contentRelated) {
|
|
166
|
-
seqNo++;
|
|
167
|
-
__classPrivateFieldGet(this, _ClientEncrypted_state, "f").seqNo++;
|
|
168
|
-
}
|
|
169
|
-
return seqNo;
|
|
170
|
-
}, _ClientEncrypted_invalidateSession = async function _ClientEncrypted_invalidateSession() {
|
|
171
|
-
await this.transport?.transport.deinitialize();
|
|
172
|
-
await this.transport?.connection.close();
|
|
173
|
-
__classPrivateFieldSet(this, _ClientEncrypted_shouldInvalidateSession, true, "f");
|
|
174
|
-
}, _ClientEncrypted_sendMessage = async function _ClientEncrypted_sendMessage(message) {
|
|
175
|
-
const payload = await (0, _0_message_js_1.encryptMessage)(message, __classPrivateFieldGet(this, _ClientEncrypted_authKey, "f"), __classPrivateFieldGet(this, _ClientEncrypted_authKeyId, "f"), __classPrivateFieldGet(this, _ClientEncrypted_state, "f").serverSalt, __classPrivateFieldGet(this, _ClientEncrypted_sessionId, "f"));
|
|
176
|
-
if (!this.transport) {
|
|
177
|
-
throw new _0_errors_js_1.ConnectionError("Not connected.");
|
|
178
|
-
}
|
|
179
|
-
await this.transport.transport.send(payload);
|
|
180
|
-
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").out(message);
|
|
181
|
-
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").outBin(payload);
|
|
182
|
-
}, _ClientEncrypted_receiveLoop = async function _ClientEncrypted_receiveLoop() {
|
|
183
|
-
if (!this.transport) {
|
|
184
|
-
(0, _0_deps_js_1.unreachable)();
|
|
185
|
-
}
|
|
186
|
-
for (const [key, { reject }] of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").entries()) {
|
|
187
|
-
reject?.(new _0_errors_js_1.ConnectionError("Connection was closed"));
|
|
188
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(key);
|
|
189
|
-
}
|
|
190
|
-
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, true, "f");
|
|
191
|
-
while (this.connected && __classPrivateFieldGet(this, _ClientEncrypted_loopActive, "f")) {
|
|
192
|
-
try {
|
|
193
|
-
const buffer = await this.transport.transport.receive();
|
|
194
|
-
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").inBin(buffer);
|
|
195
|
-
let decrypted;
|
|
196
|
-
try {
|
|
197
|
-
decrypted = await ((0, _0_message_js_1.decryptMessage)(buffer, __classPrivateFieldGet(this, _ClientEncrypted_authKey, "f"), __classPrivateFieldGet(this, _ClientEncrypted_authKeyId, "f"), __classPrivateFieldGet(this, _ClientEncrypted_sessionId, "f")));
|
|
198
|
-
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").in(decrypted);
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").error("failed to decrypt message:", err);
|
|
202
|
-
(0, _1_utilities_js_1.drop)(this.handlers.error?.(err, "decryption"));
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
const messages = decrypted.body instanceof Uint8Array ? [decrypted] : decrypted.body.messages.map((v) => v);
|
|
206
|
-
for (const message of messages) {
|
|
207
|
-
if (!(message.body instanceof Uint8Array)) {
|
|
208
|
-
(0, _0_deps_js_1.unreachable)();
|
|
209
|
-
}
|
|
210
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleIncomingMessage).call(this, message);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
catch (err) {
|
|
214
|
-
if (!this.connected) {
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
else if (err instanceof _2_tl_js_1.TLError) {
|
|
218
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").error("failed to deserialize:", err);
|
|
219
|
-
(0, _1_utilities_js_1.drop)(this.handlers.error?.(err, "deserialization"));
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").error("unexpected error:", err);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
if (!this.connected) {
|
|
227
|
-
for (const [key, { reject }] of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").entries()) {
|
|
228
|
-
reject?.(new _0_errors_js_1.ConnectionError("Connection was closed"));
|
|
229
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(key);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
(0, _0_deps_js_1.unreachable)();
|
|
234
|
-
}
|
|
235
|
-
}, _ClientEncrypted_handleIncomingMessage = async function _ClientEncrypted_handleIncomingMessage(message) {
|
|
236
|
-
const body = message.body;
|
|
237
|
-
if (!(body instanceof Uint8Array)) {
|
|
238
|
-
(0, _0_deps_js_1.unreachable)();
|
|
239
|
-
}
|
|
240
|
-
let reader = new _2_tl_js_1.TLReader(body);
|
|
241
|
-
const id = reader.readInt32(false);
|
|
242
|
-
if (id == _2_tl_js_1.GZIP_PACKED) {
|
|
243
|
-
reader = new _2_tl_js_1.TLReader(await (0, _1_utilities_js_1.gunzip)(reader.readBytes()));
|
|
244
|
-
}
|
|
245
|
-
else if (id == _2_tl_js_1.RPC_RESULT) {
|
|
246
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleRpcResult).call(this, reader);
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
reader.unreadInt32();
|
|
250
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleType).call(this, message, reader);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
254
|
-
}, _ClientEncrypted_handleRpcResult = async function _ClientEncrypted_handleRpcResult(reader) {
|
|
255
|
-
const messageId = reader.readInt64();
|
|
256
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(messageId);
|
|
257
|
-
if (!promise) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
let id = reader.readInt32(false);
|
|
261
|
-
if (id == _2_tl_js_1.GZIP_PACKED) {
|
|
262
|
-
reader = new _2_tl_js_1.TLReader(await (0, _1_utilities_js_1.gunzip)(reader.readBytes()));
|
|
263
|
-
id = reader.readInt32(false);
|
|
264
|
-
reader.unreadInt32();
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
reader.unreadInt32();
|
|
268
|
-
}
|
|
269
|
-
// deno-lint-ignore no-explicit-any
|
|
270
|
-
let call = promise?.call ?? null;
|
|
271
|
-
while ((0, _2_tl_js_1.isGenericFunction)(call)) {
|
|
272
|
-
call = call.query;
|
|
273
|
-
}
|
|
274
|
-
// deno-lint-ignore no-explicit-any
|
|
275
|
-
let result;
|
|
276
|
-
if (id == RPC_ERROR) {
|
|
277
|
-
result = await reader.deserialize("rpc_error");
|
|
278
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", result.error_code, result.error_message);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
result = await reader.deserialize((0, _2_tl_js_1.mustGetReturnType)(call._));
|
|
282
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", Array.isArray(result) ? "Array" : typeof result === "object" ? result._ : result);
|
|
283
|
-
}
|
|
284
|
-
const resolvePromise = () => {
|
|
285
|
-
if ((0, _2_tl_js_1.is)("rpc_error", result)) {
|
|
286
|
-
promise.reject?.((0, _4_errors_js_1.constructTelegramError)(result, promise.call));
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
promise.resolve?.(result);
|
|
290
|
-
}
|
|
291
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(messageId);
|
|
292
|
-
};
|
|
293
|
-
if ((0, _2_tl_js_1.isOfEnum)("Updates", result) || (0, _2_tl_js_1.isOfEnum)("Update", result)) {
|
|
294
|
-
(0, _1_utilities_js_1.drop)(this.handlers.updates?.(result, call, resolvePromise));
|
|
295
|
-
}
|
|
296
|
-
else {
|
|
297
|
-
(0, _1_utilities_js_1.drop)(this.handlers.result?.(result, resolvePromise));
|
|
298
|
-
}
|
|
299
|
-
}, _ClientEncrypted_handleType = async function _ClientEncrypted_handleType(message, reader) {
|
|
300
|
-
const body = await reader.deserialize(_2_tl_js_1.X);
|
|
301
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("received", (0, _2_tl_js_1.repr)(body));
|
|
302
|
-
let sendAck = true;
|
|
303
|
-
if ((0, _2_tl_js_1.isOfEnum)("Updates", body) || (0, _2_tl_js_1.isOfEnum)("Update", body)) {
|
|
304
|
-
(0, _1_utilities_js_1.drop)(this.handlers.updates?.(body, null));
|
|
305
|
-
}
|
|
306
|
-
else if ((0, _2_tl_js_1.is)("new_session_created", body)) {
|
|
307
|
-
this.serverSalt = body.server_salt;
|
|
308
|
-
(0, _1_utilities_js_1.drop)(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
309
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("new session created with ID", body.unique_id);
|
|
310
|
-
}
|
|
311
|
-
else if ((0, _2_tl_js_1.is)("pong", body)) {
|
|
312
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.msg_id);
|
|
313
|
-
if (promise) {
|
|
314
|
-
promise.resolve?.(body);
|
|
315
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.msg_id);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
else if ((0, _2_tl_js_1.is)("bad_server_salt", body)) {
|
|
319
|
-
sendAck = false;
|
|
320
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("server salt reassigned");
|
|
321
|
-
this.serverSalt = body.new_server_salt;
|
|
322
|
-
(0, _1_utilities_js_1.drop)(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
323
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
324
|
-
const ack = __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").get(body.bad_msg_id);
|
|
325
|
-
if (promise) {
|
|
326
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
327
|
-
}
|
|
328
|
-
else if (ack) {
|
|
329
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
for (const promise of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").values()) {
|
|
333
|
-
if (promise.container && promise.container == body.bad_msg_id) {
|
|
334
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
for (const ack of __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").values()) {
|
|
338
|
-
if (ack.container && ack.container == body.bad_msg_id) {
|
|
339
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else if ((0, _2_tl_js_1.is)("bad_msg_notification", body)) {
|
|
345
|
-
sendAck = false;
|
|
346
|
-
let low = false;
|
|
347
|
-
switch (body.error_code) {
|
|
348
|
-
case 16: // message ID too low
|
|
349
|
-
low = true;
|
|
350
|
-
/* falls through */
|
|
351
|
-
case 17: // message ID too high
|
|
352
|
-
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, Math.abs((0, _1_utilities_js_1.toUnixTimestamp)(new Date()) - Number(message.msg_id >> 32n)), "f");
|
|
353
|
-
if (!low) {
|
|
354
|
-
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, -__classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"), "f");
|
|
355
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too high, invalidating session");
|
|
356
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
357
|
-
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too low, resending message");
|
|
361
|
-
}
|
|
362
|
-
break;
|
|
363
|
-
case 48: // bad server salt
|
|
364
|
-
// resend
|
|
365
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("resending message that caused bad_server_salt");
|
|
366
|
-
break;
|
|
367
|
-
default:
|
|
368
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
369
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("invalidating session because of unexpected bad_msg_notification:", body.error_code);
|
|
370
|
-
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
|
|
371
|
-
}
|
|
372
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
373
|
-
if (promise) {
|
|
374
|
-
promise.reject?.(body);
|
|
375
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.bad_msg_id);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
else if ((0, _2_tl_js_1.isOneOf)(["msg_detailed_info", "msg_new_detailed_info"], body)) {
|
|
379
|
-
sendAck = false;
|
|
380
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(body.answer_msg_id);
|
|
381
|
-
}
|
|
382
|
-
if (sendAck) {
|
|
383
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
384
|
-
}
|
|
385
|
-
};
|