@mtkruto/node 0.62.0 → 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 +100 -74
- 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 +1 -1
- package/esm/types/5_callback_query.d.ts.map +1 -1
- package/esm/types/5_callback_query.js +7 -8
- 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 +99 -73
- 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 +1 -1
- package/script/types/5_callback_query.d.ts.map +1 -1
- package/script/types/5_callback_query.js +6 -7
- 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
|
@@ -28,46 +28,36 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
28
28
|
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");
|
|
29
29
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
30
|
};
|
|
31
|
-
var _ClientPlain_publicKeys
|
|
31
|
+
var _ClientPlain_publicKeys;
|
|
32
32
|
import { assert, assertEquals, concat, ige256Decrypt, ige256Encrypt, unreachable } from "../0_deps.js";
|
|
33
|
-
import { ConnectionError, TransportError } from "../0_errors.js";
|
|
34
33
|
import { bigIntFromBuffer, bufferFromBigInt, factorize, getLogger, getRandomBigInt, modExp, rsaPad, sha1 } from "../1_utilities.js";
|
|
35
|
-
import {
|
|
34
|
+
import { Mtproto } from "../2_tl.js";
|
|
35
|
+
import { getDcId } from "../3_transport.js";
|
|
36
36
|
import { PUBLIC_KEYS } from "../4_constants.js";
|
|
37
|
+
import { SessionPlain } from "../4_session.js";
|
|
37
38
|
import { ClientAbstract } from "./0_client_abstract.js";
|
|
38
|
-
import { getMessageId, packUnencryptedMessage, unpackUnencryptedMessage } from "./0_message.js";
|
|
39
39
|
const L = getLogger("ClientPlain");
|
|
40
40
|
const LcreateAuthKey = L.branch("createAuthKey");
|
|
41
41
|
/**
|
|
42
42
|
* An MTProto client for making plain connections. Most users won't need to interact with this. Used internally for creating authorization keys.
|
|
43
43
|
*/
|
|
44
44
|
export class ClientPlain extends ClientAbstract {
|
|
45
|
-
constructor(params) {
|
|
46
|
-
super(
|
|
45
|
+
constructor(dc, params) {
|
|
46
|
+
super();
|
|
47
47
|
_ClientPlain_publicKeys.set(this, void 0);
|
|
48
|
-
|
|
48
|
+
Object.defineProperty(this, "session", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: void 0
|
|
53
|
+
});
|
|
49
54
|
__classPrivateFieldSet(this, _ClientPlain_publicKeys, params?.publicKeys ?? PUBLIC_KEYS, "f");
|
|
55
|
+
this.session = new SessionPlain(dc, params);
|
|
50
56
|
}
|
|
51
57
|
async invoke(function_) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const messageId = __classPrivateFieldSet(this, _ClientPlain_lastMessageId, getMessageId(__classPrivateFieldGet(this, _ClientPlain_lastMessageId, "f"), 0), "f");
|
|
56
|
-
const payload = packUnencryptedMessage(new TLWriter().serialize(function_).buffer, messageId);
|
|
57
|
-
await this.transport.transport.send(payload);
|
|
58
|
-
L.out(function_);
|
|
59
|
-
L.outBin(payload);
|
|
60
|
-
const buffer = await this.transport.transport.receive();
|
|
61
|
-
L.inBin(payload);
|
|
62
|
-
if (buffer.length == 4) {
|
|
63
|
-
const int = bigIntFromBuffer(buffer, true, true);
|
|
64
|
-
throw new TransportError(Number(int));
|
|
65
|
-
}
|
|
66
|
-
const { message } = unpackUnencryptedMessage(buffer);
|
|
67
|
-
const reader = new TLReader(message);
|
|
68
|
-
const result = await reader.deserialize(mustGetReturnType(function_._));
|
|
69
|
-
L.in(result);
|
|
70
|
-
return result;
|
|
58
|
+
await this.session.send(Mtproto.serializeObject(function_));
|
|
59
|
+
const body = await this.session.receive();
|
|
60
|
+
return await Mtproto.deserializeType(Mtproto.mustGetReturnType(function_._), body);
|
|
71
61
|
}
|
|
72
62
|
async createAuthKey() {
|
|
73
63
|
const nonce = getRandomBigInt(16, false, true);
|
|
@@ -77,7 +67,7 @@ export class ClientPlain extends ClientAbstract {
|
|
|
77
67
|
try {
|
|
78
68
|
LcreateAuthKey.debug(`req_pq_multi [${i + 1}]`);
|
|
79
69
|
resPq = await this.invoke({ _: "req_pq_multi", nonce });
|
|
80
|
-
assert(is("resPQ", resPq));
|
|
70
|
+
assert(Mtproto.is("resPQ", resPq));
|
|
81
71
|
assertEquals(resPq.nonce, nonce);
|
|
82
72
|
LcreateAuthKey.debug("got res_pq");
|
|
83
73
|
break;
|
|
@@ -109,12 +99,11 @@ export class ClientPlain extends ClientAbstract {
|
|
|
109
99
|
if (!publicKeyFingerprint || !publicKey) {
|
|
110
100
|
throw new Error("No corresponding public key found");
|
|
111
101
|
}
|
|
112
|
-
const dc = this.
|
|
102
|
+
const dc = getDcId(this.dc, this.cdn);
|
|
113
103
|
const pq = resPq.pq;
|
|
114
104
|
const serverNonce = resPq.server_nonce;
|
|
115
105
|
const newNonce = getRandomBigInt(32, false, true);
|
|
116
|
-
let encryptedData = await rsaPad(
|
|
117
|
-
.serialize({
|
|
106
|
+
let encryptedData = await rsaPad(Mtproto.serializeObject({
|
|
118
107
|
_: "p_q_inner_data_dc",
|
|
119
108
|
pq,
|
|
120
109
|
p,
|
|
@@ -123,8 +112,7 @@ export class ClientPlain extends ClientAbstract {
|
|
|
123
112
|
new_nonce: newNonce,
|
|
124
113
|
nonce,
|
|
125
114
|
server_nonce: serverNonce,
|
|
126
|
-
})
|
|
127
|
-
.buffer, publicKey);
|
|
115
|
+
}), publicKey);
|
|
128
116
|
const dhParams = await this.invoke({
|
|
129
117
|
_: "req_DH_params",
|
|
130
118
|
nonce,
|
|
@@ -134,29 +122,26 @@ export class ClientPlain extends ClientAbstract {
|
|
|
134
122
|
public_key_fingerprint: publicKeyFingerprint,
|
|
135
123
|
encrypted_data: encryptedData,
|
|
136
124
|
});
|
|
137
|
-
assert(is("server_DH_params_ok", dhParams));
|
|
125
|
+
assert(Mtproto.is("server_DH_params_ok", dhParams));
|
|
138
126
|
LcreateAuthKey.debug("got server_DH_params_ok");
|
|
139
127
|
const newNonce_ = bufferFromBigInt(newNonce, 32, true, true);
|
|
140
128
|
const serverNonce_ = bufferFromBigInt(serverNonce, 16, true, true);
|
|
141
129
|
const tmpAesKey = concat([await sha1(concat([newNonce_, serverNonce_])), (await sha1(concat([serverNonce_, newNonce_]))).subarray(0, 0 + 12)]);
|
|
142
130
|
const tmpAesIv = concat([(await sha1(concat([serverNonce_, newNonce_]))).subarray(12, 12 + 8), await sha1(concat([newNonce_, newNonce_])), newNonce_.subarray(0, 0 + 4)]);
|
|
143
131
|
const answerWithHash = ige256Decrypt(dhParams.encrypted_answer, tmpAesKey, tmpAesIv);
|
|
144
|
-
const dhInnerData = await
|
|
145
|
-
assert(is("server_DH_inner_data", dhInnerData));
|
|
132
|
+
const dhInnerData = await Mtproto.deserializeType("server_DH_inner_data", answerWithHash.slice(20));
|
|
146
133
|
const { g, g_a: gA_, dh_prime: dhPrime_ } = dhInnerData;
|
|
147
134
|
const gA = bigIntFromBuffer(gA_, false, false);
|
|
148
135
|
const dhPrime = bigIntFromBuffer(dhPrime_, false, false);
|
|
149
136
|
const b = getRandomBigInt(256, false, false);
|
|
150
137
|
const gB = modExp(BigInt(g), b, dhPrime);
|
|
151
|
-
const data =
|
|
152
|
-
.serialize({
|
|
138
|
+
const data = Mtproto.serializeObject({
|
|
153
139
|
_: "client_DH_inner_data",
|
|
154
140
|
nonce,
|
|
155
141
|
server_nonce: serverNonce,
|
|
156
142
|
retry_id: 0n,
|
|
157
143
|
g_b: bufferFromBigInt(gB, 256, false, false),
|
|
158
|
-
})
|
|
159
|
-
.buffer;
|
|
144
|
+
});
|
|
160
145
|
let dataWithHash = concat([await sha1(data), data]);
|
|
161
146
|
while (dataWithHash.length % 16 != 0) {
|
|
162
147
|
dataWithHash = concat([dataWithHash, new Uint8Array(1)]);
|
|
@@ -168,7 +153,7 @@ export class ClientPlain extends ClientAbstract {
|
|
|
168
153
|
server_nonce: serverNonce,
|
|
169
154
|
encrypted_data: encryptedData,
|
|
170
155
|
});
|
|
171
|
-
assert(is("dh_gen_ok", dhGenOk));
|
|
156
|
+
assert(Mtproto.is("dh_gen_ok", dhGenOk));
|
|
172
157
|
LcreateAuthKey.debug("got dh_gen_ok");
|
|
173
158
|
const serverNonceSlice = serverNonce_.subarray(0, 8);
|
|
174
159
|
const salt = newNonce_.subarray(0, 0 + 8).map((v, i) => v ^ serverNonceSlice[i]);
|
|
@@ -178,4 +163,4 @@ export class ClientPlain extends ClientAbstract {
|
|
|
178
163
|
return [authKey, bigIntFromBuffer(salt, true, false)];
|
|
179
164
|
}
|
|
180
165
|
}
|
|
181
|
-
_ClientPlain_publicKeys = new WeakMap()
|
|
166
|
+
_ClientPlain_publicKeys = new WeakMap();
|
package/esm/client/1_types.d.ts
CHANGED
|
@@ -19,25 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Api } from "../2_tl.js";
|
|
21
21
|
import { ConnectionState, EntityGetter, ID, ParseMode, Update } from "../3_types.js";
|
|
22
|
+
import { InvokeParams } from "./0_params.js";
|
|
22
23
|
import { StorageOperations } from "./0_storage_operations.js";
|
|
23
|
-
export type Invoke = <T extends Api.AnyFunction<P>, P extends Api.Function, R extends unknown = Api.ReturnType<Api.Functions[T["_"]]>>(function_: T, businessConnectionId?: string) => Promise<R>;
|
|
24
|
-
interface Connection {
|
|
25
|
-
invoke: Invoke;
|
|
26
|
-
connect: () => Promise<void>;
|
|
27
|
-
disconnect: () => Promise<void>;
|
|
28
|
-
}
|
|
29
|
-
export interface ConnectionPool extends Omit<Connection, "invoke"> {
|
|
30
|
-
size: number;
|
|
31
|
-
invoke: () => Invoke;
|
|
32
|
-
connect: () => Promise<void>;
|
|
33
|
-
disconnect: () => Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
interface GetCdnConnection {
|
|
36
|
-
(dcId?: number): Connection;
|
|
37
|
-
}
|
|
38
|
-
interface GetCdnConnectionPool {
|
|
39
|
-
(size: number, dcId?: number): ConnectionPool;
|
|
40
|
-
}
|
|
41
24
|
export interface C {
|
|
42
25
|
id: number;
|
|
43
26
|
storage: StorageOperations;
|
|
@@ -53,15 +36,13 @@ export interface C {
|
|
|
53
36
|
getEntity: EntityGetter;
|
|
54
37
|
handleUpdate: (update: Update) => void;
|
|
55
38
|
parseMode: ParseMode;
|
|
56
|
-
getCdnConnection: GetCdnConnection;
|
|
57
|
-
getCdnConnectionPool: GetCdnConnectionPool;
|
|
58
39
|
outgoingMessages: "none" | "business" | "all" | null;
|
|
59
|
-
cdn: boolean;
|
|
60
40
|
dropPendingUpdates?: boolean;
|
|
61
|
-
invoke: Invoke;
|
|
62
41
|
disconnected: () => boolean;
|
|
63
42
|
langPack?: string;
|
|
64
43
|
langCode?: string;
|
|
44
|
+
invoke<T extends Api.AnyFunction<P>, P extends Api.Function, R extends unknown = Api.ReturnType<Api.Functions[T["_"]]>>(function_: T, params?: InvokeParams & {
|
|
45
|
+
businessConnectionId?: string;
|
|
46
|
+
}): Promise<R>;
|
|
65
47
|
}
|
|
66
|
-
export {};
|
|
67
48
|
//# sourceMappingURL=1_types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_types.d.ts","sourceRoot":"","sources":["../../src/client/1_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"1_types.d.ts","sourceRoot":"","sources":["../../src/client/1_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,WAAW,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,iBAAiB,CAAC;IAC3B,cAAc,EAAE,iBAAiB,CAAC;IAClC,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;IAC/D,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,SAAS,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACjD,eAAe,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACrF,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAChG,kBAAkB,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,YAAY,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrG,SAAS,EAAE,YAAY,CAAC;IACxB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,SAAS,CAAC;IACrB,gBAAgB,EAAE,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC;IACrD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE,MAAM,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,CAAC,SAAS,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,CAAC,QAAQ,EAAE,CAAC,SAAS,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG;QAAE,oBAAoB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9M"}
|
|
@@ -32,7 +32,7 @@ var _AccountManager_instances, _AccountManager_c, _AccountManager_toggleUsername
|
|
|
32
32
|
import { unreachable } from "../0_deps.js";
|
|
33
33
|
import { InputError } from "../0_errors.js";
|
|
34
34
|
import { toUnixTimestamp } from "../1_utilities.js";
|
|
35
|
-
import {
|
|
35
|
+
import { Api } from "../2_tl.js";
|
|
36
36
|
import { birthdayToTlObject, constructInactiveChat, constructUser } from "../3_types.js";
|
|
37
37
|
import { canBeInputChannel, canBeInputUser, toInputChannel, toInputUser } from "./0_utilities.js";
|
|
38
38
|
export class AccountManager {
|
|
@@ -52,7 +52,7 @@ export class AccountManager {
|
|
|
52
52
|
async reorderUsernames(id, order) {
|
|
53
53
|
__classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("reorderUsernames");
|
|
54
54
|
const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
|
|
55
|
-
if (is("inputPeerSelf", peer)) {
|
|
55
|
+
if (Api.is("inputPeerSelf", peer)) {
|
|
56
56
|
return await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.reorderUsernames", order });
|
|
57
57
|
}
|
|
58
58
|
else if (canBeInputUser(peer)) {
|
|
@@ -108,10 +108,10 @@ export class AccountManager {
|
|
|
108
108
|
async getContacts() {
|
|
109
109
|
__classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("getContacts");
|
|
110
110
|
const result = await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "contacts.getContacts", hash: 0n });
|
|
111
|
-
if (!is("contacts.contacts", result)) {
|
|
111
|
+
if (!Api.is("contacts.contacts", result)) {
|
|
112
112
|
unreachable();
|
|
113
113
|
}
|
|
114
|
-
return result.users.map((v) => is("user", v) ? constructUser(v) : null).filter((v) => v != null);
|
|
114
|
+
return result.users.map((v) => Api.is("user", v) ? constructUser(v) : null).filter((v) => v != null);
|
|
115
115
|
}
|
|
116
116
|
async deleteContacts(userIds) {
|
|
117
117
|
__classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("deleteContacts");
|
|
@@ -125,10 +125,10 @@ export class AccountManager {
|
|
|
125
125
|
async addContact(userId, params) {
|
|
126
126
|
__classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("addContact");
|
|
127
127
|
const id = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputUser(userId);
|
|
128
|
-
if (!is("inputPeerUser", id)) {
|
|
128
|
+
if (!Api.is("inputPeerUser", id)) {
|
|
129
129
|
unreachable();
|
|
130
130
|
}
|
|
131
|
-
const user = await __classPrivateFieldGet(this, _AccountManager_c, "f").getEntity(inputPeerToPeer(id));
|
|
131
|
+
const user = await __classPrivateFieldGet(this, _AccountManager_c, "f").getEntity(Api.inputPeerToPeer(id));
|
|
132
132
|
if (!user || !("first_name" in user)) {
|
|
133
133
|
unreachable();
|
|
134
134
|
}
|
|
@@ -142,8 +142,8 @@ export class AccountManager {
|
|
|
142
142
|
__classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("updateProfile");
|
|
143
143
|
const selfId = await __classPrivateFieldGet(this, _AccountManager_c, "f").getSelfId();
|
|
144
144
|
const userFull = await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_getUserFull).call(this, selfId);
|
|
145
|
-
const entity = await __classPrivateFieldGet(this, _AccountManager_c, "f").getEntity(chatIdToPeer(selfId));
|
|
146
|
-
if (!is("user", entity)) {
|
|
145
|
+
const entity = await __classPrivateFieldGet(this, _AccountManager_c, "f").getEntity(Api.chatIdToPeer(selfId));
|
|
146
|
+
if (!Api.is("user", entity)) {
|
|
147
147
|
unreachable();
|
|
148
148
|
}
|
|
149
149
|
params ??= {};
|
|
@@ -214,7 +214,7 @@ export class AccountManager {
|
|
|
214
214
|
}
|
|
215
215
|
_AccountManager_c = new WeakMap(), _AccountManager_instances = new WeakSet(), _AccountManager_toggleUsername = async function _AccountManager_toggleUsername(id, username, active) {
|
|
216
216
|
const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
|
|
217
|
-
if (is("inputPeerSelf", peer)) {
|
|
217
|
+
if (Api.is("inputPeerSelf", peer)) {
|
|
218
218
|
await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.toggleUsername", username, active });
|
|
219
219
|
}
|
|
220
220
|
else if (canBeInputUser(peer)) {
|
|
@@ -231,7 +231,7 @@ _AccountManager_c = new WeakMap(), _AccountManager_instances = new WeakSet(), _A
|
|
|
231
231
|
const chatId_ = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeerChatId(inputPeer);
|
|
232
232
|
let fullChat = await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.getFullChat(chatId_);
|
|
233
233
|
if (fullChat != null) {
|
|
234
|
-
if (!is("userFull", fullChat)) {
|
|
234
|
+
if (!Api.is("userFull", fullChat)) {
|
|
235
235
|
unreachable();
|
|
236
236
|
}
|
|
237
237
|
return fullChat;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_business_connection_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_business_connection_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"2_business_connection_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_business_connection_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAA+B,MAAM,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,QAAA,MAAM,gCAAgC,uCAE5B,CAAC;AAEX,KAAK,+BAA+B,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,gCAAgC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpG,qBAAa,yBAA0B,YAAW,eAAe,CAAC,+BAA+B,CAAC;;gBAGpF,CAAC,EAAE,CAAC;IAIV,qBAAqB,CAAC,EAAE,EAAE,MAAM;IAatC,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,IAAI,+BAA+B;IAIxE,YAAY,CAAC,MAAM,EAAE,+BAA+B,GAAG,OAAO,CAAC,MAAM,CAAC;CAS7E"}
|
|
@@ -29,7 +29,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
29
29
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
30
|
};
|
|
31
31
|
var _BusinessConnectionManager_c;
|
|
32
|
-
import {
|
|
32
|
+
import { Api } from "../2_tl.js";
|
|
33
33
|
import { constructBusinessConnection } from "../3_types.js";
|
|
34
34
|
const businessConnectionManagerUpdates = [
|
|
35
35
|
"updateBotBusinessConnect",
|
|
@@ -43,8 +43,8 @@ export class BusinessConnectionManager {
|
|
|
43
43
|
const connection_ = await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.getBusinessConnection(id);
|
|
44
44
|
if (!connection_) {
|
|
45
45
|
const connection_ = await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").invoke({ _: "account.getBotBusinessConnection", connection_id: id })
|
|
46
|
-
.then((v) => as("updates", v))
|
|
47
|
-
.then((v) => as("updateBotBusinessConnect", v.updates[0]).connection);
|
|
46
|
+
.then((v) => Api.as("updates", v))
|
|
47
|
+
.then((v) => Api.as("updateBotBusinessConnect", v.updates[0]).connection);
|
|
48
48
|
await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(id, connection_);
|
|
49
49
|
return await constructBusinessConnection(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity);
|
|
50
50
|
}
|
|
@@ -53,7 +53,7 @@ export class BusinessConnectionManager {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
canHandleUpdate(update) {
|
|
56
|
-
return isOneOf(businessConnectionManagerUpdates, update);
|
|
56
|
+
return Api.isOneOf(businessConnectionManagerUpdates, update);
|
|
57
57
|
}
|
|
58
58
|
async handleUpdate(update) {
|
|
59
59
|
if (update.connection.disabled) {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import { Api } from "../2_tl.js";
|
|
21
|
+
import { DC } from "../3_transport.js";
|
|
22
|
+
import { SessionEncrypted } from "../4_session.js";
|
|
23
|
+
import { ClientAbstract } from "./0_client_abstract.js";
|
|
24
|
+
import { ClientPlainParams } from "./1_client_plain.js";
|
|
25
|
+
export interface ClientEncryptedParams extends ClientPlainParams {
|
|
26
|
+
/** The app_version parameter to be passed to initConnection. It is recommended that this parameter is changed if users are authorized. Defaults to _MTKruto_. */
|
|
27
|
+
appVersion?: string;
|
|
28
|
+
/** The device_version parameter to be passed to initConnection. The default varies by the current runtime. */
|
|
29
|
+
deviceModel?: string;
|
|
30
|
+
/** The lang_pack parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
|
|
31
|
+
langCode?: string;
|
|
32
|
+
/** The lang_pack parameter to be passed to initConnection. Defaults to an empty string. */
|
|
33
|
+
langPack?: string;
|
|
34
|
+
/** The system_lang_code parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
|
|
35
|
+
systemLangCode?: string;
|
|
36
|
+
/** The system_version parameter to be passed to initConnection. The default varies by the current runtime. */
|
|
37
|
+
systemVersion?: string;
|
|
38
|
+
/** Whether to disable receiving updates. Defaults to `false`. */
|
|
39
|
+
disableUpdates?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface ClientEncryptedHandlers {
|
|
42
|
+
onNewServerSalt?: (newServerSalt: bigint) => void;
|
|
43
|
+
onUpdate?: (update: Api.Updates | Api.Update) => void;
|
|
44
|
+
onDeserializationError?: () => void;
|
|
45
|
+
}
|
|
46
|
+
export declare class ClientEncrypted extends ClientAbstract {
|
|
47
|
+
#private;
|
|
48
|
+
handlers: ClientEncryptedHandlers;
|
|
49
|
+
session: SessionEncrypted;
|
|
50
|
+
constructor(dc: DC, apiId: number, params?: ClientEncryptedParams);
|
|
51
|
+
connect(): Promise<void>;
|
|
52
|
+
disconnect(): void;
|
|
53
|
+
get authKey(): Uint8Array;
|
|
54
|
+
setAuthKey(authKey: Uint8Array<ArrayBuffer>): Promise<void>;
|
|
55
|
+
lastRequest?: Date;
|
|
56
|
+
invoke<T extends Api.AnyFunction, R = T extends Api.AnyGenericFunction<infer X> ? Api.ReturnType<X> : T["_"] extends keyof Api.Functions ? Api.ReturnType<T> extends never ? Api.ReturnType<Api.Functions[T["_"]]> : never : never>(function_: T): Promise<R>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=2_client_encrypted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_client_encrypted.d.ts","sourceRoot":"","sources":["../../src/client/2_client_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,GAAG,EAAc,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAe,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKrE,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,iKAAiK;IACjK,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8GAA8G;IAC9G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mHAAmH;IACnH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8GAA8G;IAC9G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC;IACtD,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAQD,qBAAa,eAAgB,SAAQ,cAAc;;IAIjD,QAAQ,EAAE,uBAAuB,CAAM;IAIvC,OAAO,EAAE,gBAAgB,CAAC;gBAYd,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,qBAAqB;IAsBlD,OAAO;IAOb,UAAU;IAsCnB,IAAI,OAAO,IAAI,UAAU,CAExB;IAEK,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC;IAKjD,WAAW,CAAC,EAAE,IAAI,CAAC;IAuDb,MAAM,CAAC,CAAC,SAAS,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAuEpQ"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
21
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
22
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
23
|
+
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");
|
|
24
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
|
+
};
|
|
26
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
28
|
+
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");
|
|
29
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
|
+
};
|
|
31
|
+
var _ClientEncrypted_instances, _a, _ClientEncrypted_SEND_MAX_TRIES, _ClientEncrypted_AUTH_KEY_CREATION_MAX_TRIES, _ClientEncrypted_L, _ClientEncrypted_plain, _ClientEncrypted_pendingRequests, _ClientEncrypted_apiId, _ClientEncrypted_appVersion, _ClientEncrypted_deviceModel, _ClientEncrypted_langCode, _ClientEncrypted_langPack, _ClientEncrypted_systemLangCode, _ClientEncrypted_systemVersion, _ClientEncrypted_disableUpdates, _ClientEncrypted_createAuthKeyPromise, _ClientEncrypted_createAuthKey, _ClientEncrypted_createAuthKeyInner, _ClientEncrypted_connectionInited, _ClientEncrypted_send, _ClientEncrypted_resend, _ClientEncrypted_onUpdate, _ClientEncrypted_onNewServerSalt, _ClientEncrypted_onMessageFailed, _ClientEncrypted_onRpcError, _ClientEncrypted_onRpcResult;
|
|
32
|
+
import { getLogger } from "../1_utilities.js";
|
|
33
|
+
import { Api, X } from "../2_tl.js";
|
|
34
|
+
import { ConnectionNotInited } from "../3_errors.js";
|
|
35
|
+
import { APP_VERSION, DEVICE_MODEL, LANG_CODE, LANG_PACK, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "../4_constants.js";
|
|
36
|
+
import { constructTelegramError } from "../4_errors.js";
|
|
37
|
+
import { SessionEncrypted, SessionError } from "../4_session.js";
|
|
38
|
+
import { ClientAbstract } from "./0_client_abstract.js";
|
|
39
|
+
import { isCdnFunction, repr } from "./0_utilities.js";
|
|
40
|
+
import { ClientPlain } from "./1_client_plain.js";
|
|
41
|
+
// global ClientEncrypted ID counter for logs
|
|
42
|
+
let id = 0;
|
|
43
|
+
export class ClientEncrypted extends ClientAbstract {
|
|
44
|
+
constructor(dc, apiId, params) {
|
|
45
|
+
super();
|
|
46
|
+
_ClientEncrypted_instances.add(this);
|
|
47
|
+
Object.defineProperty(this, "handlers", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: {}
|
|
52
|
+
});
|
|
53
|
+
_ClientEncrypted_L.set(this, void 0);
|
|
54
|
+
_ClientEncrypted_plain.set(this, void 0);
|
|
55
|
+
Object.defineProperty(this, "session", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: void 0
|
|
60
|
+
});
|
|
61
|
+
_ClientEncrypted_pendingRequests.set(this, new Map());
|
|
62
|
+
_ClientEncrypted_apiId.set(this, void 0);
|
|
63
|
+
_ClientEncrypted_appVersion.set(this, void 0);
|
|
64
|
+
_ClientEncrypted_deviceModel.set(this, void 0);
|
|
65
|
+
_ClientEncrypted_langCode.set(this, void 0);
|
|
66
|
+
_ClientEncrypted_langPack.set(this, void 0);
|
|
67
|
+
_ClientEncrypted_systemLangCode.set(this, void 0);
|
|
68
|
+
_ClientEncrypted_systemVersion.set(this, void 0);
|
|
69
|
+
_ClientEncrypted_disableUpdates.set(this, void 0);
|
|
70
|
+
_ClientEncrypted_createAuthKeyPromise.set(this, void 0);
|
|
71
|
+
_ClientEncrypted_connectionInited.set(this, false);
|
|
72
|
+
Object.defineProperty(this, "lastRequest", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
writable: true,
|
|
76
|
+
value: void 0
|
|
77
|
+
});
|
|
78
|
+
__classPrivateFieldSet(this, _ClientEncrypted_L, getLogger("ClientEncrypted").client(id++), "f");
|
|
79
|
+
__classPrivateFieldSet(this, _ClientEncrypted_plain, new ClientPlain(dc, params), "f");
|
|
80
|
+
this.session = new SessionEncrypted(dc, params);
|
|
81
|
+
this.session.handlers.onUpdate = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_onUpdate).bind(this);
|
|
82
|
+
this.session.handlers.onNewServerSalt = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_onNewServerSalt).bind(this);
|
|
83
|
+
this.session.handlers.onMessageFailed = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_onMessageFailed).bind(this);
|
|
84
|
+
this.session.handlers.onRpcError = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_onRpcError).bind(this);
|
|
85
|
+
this.session.handlers.onRpcResult = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_onRpcResult).bind(this);
|
|
86
|
+
__classPrivateFieldSet(this, _ClientEncrypted_apiId, apiId, "f");
|
|
87
|
+
__classPrivateFieldSet(this, _ClientEncrypted_appVersion, params?.appVersion ?? APP_VERSION, "f");
|
|
88
|
+
__classPrivateFieldSet(this, _ClientEncrypted_deviceModel, params?.deviceModel ?? DEVICE_MODEL, "f");
|
|
89
|
+
__classPrivateFieldSet(this, _ClientEncrypted_langCode, params?.langCode ?? LANG_CODE, "f");
|
|
90
|
+
__classPrivateFieldSet(this, _ClientEncrypted_langPack, params?.langPack ?? LANG_PACK, "f");
|
|
91
|
+
__classPrivateFieldSet(this, _ClientEncrypted_systemLangCode, params?.systemLangCode ?? SYSTEM_LANG_CODE, "f");
|
|
92
|
+
__classPrivateFieldSet(this, _ClientEncrypted_systemVersion, params?.systemVersion ?? SYSTEM_VERSION, "f");
|
|
93
|
+
__classPrivateFieldSet(this, _ClientEncrypted_disableUpdates, params?.disableUpdates ?? false, "f");
|
|
94
|
+
}
|
|
95
|
+
async connect() {
|
|
96
|
+
if (!this.authKey.length) {
|
|
97
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_createAuthKey).call(this);
|
|
98
|
+
}
|
|
99
|
+
await super.connect();
|
|
100
|
+
}
|
|
101
|
+
disconnect() {
|
|
102
|
+
super.disconnect();
|
|
103
|
+
this.lastRequest = undefined;
|
|
104
|
+
}
|
|
105
|
+
get authKey() {
|
|
106
|
+
return this.session.authKey;
|
|
107
|
+
}
|
|
108
|
+
async setAuthKey(authKey) {
|
|
109
|
+
await this.session.setAuthKey(authKey);
|
|
110
|
+
}
|
|
111
|
+
async invoke(function_) {
|
|
112
|
+
const messageId = await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_send).call(this, function_);
|
|
113
|
+
return (await new Promise((resolve, reject) => {
|
|
114
|
+
__classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").set(messageId, { resolve, reject, call: function_ });
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
_a = ClientEncrypted, _ClientEncrypted_L = new WeakMap(), _ClientEncrypted_plain = new WeakMap(), _ClientEncrypted_pendingRequests = new WeakMap(), _ClientEncrypted_apiId = new WeakMap(), _ClientEncrypted_appVersion = new WeakMap(), _ClientEncrypted_deviceModel = new WeakMap(), _ClientEncrypted_langCode = new WeakMap(), _ClientEncrypted_langPack = new WeakMap(), _ClientEncrypted_systemLangCode = new WeakMap(), _ClientEncrypted_systemVersion = new WeakMap(), _ClientEncrypted_disableUpdates = new WeakMap(), _ClientEncrypted_createAuthKeyPromise = new WeakMap(), _ClientEncrypted_connectionInited = new WeakMap(), _ClientEncrypted_instances = new WeakSet(), _ClientEncrypted_createAuthKey = function _ClientEncrypted_createAuthKey() {
|
|
119
|
+
return __classPrivateFieldSet(this, _ClientEncrypted_createAuthKeyPromise, __classPrivateFieldGet(this, _ClientEncrypted_createAuthKeyPromise, "f") ?? __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_createAuthKeyInner).call(this).finally(() => {
|
|
120
|
+
__classPrivateFieldSet(this, _ClientEncrypted_createAuthKeyPromise, undefined, "f");
|
|
121
|
+
}), "f");
|
|
122
|
+
}, _ClientEncrypted_createAuthKeyInner = async function _ClientEncrypted_createAuthKeyInner() {
|
|
123
|
+
let lastErr;
|
|
124
|
+
let errored = false;
|
|
125
|
+
for (let i = 0; i < __classPrivateFieldGet(_a, _a, "f", _ClientEncrypted_AUTH_KEY_CREATION_MAX_TRIES); ++i) {
|
|
126
|
+
try {
|
|
127
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_plain, "f").connect();
|
|
128
|
+
const [authKey, serverSalt] = await __classPrivateFieldGet(this, _ClientEncrypted_plain, "f").createAuthKey();
|
|
129
|
+
await this.setAuthKey(authKey);
|
|
130
|
+
this.serverSalt = serverSalt;
|
|
131
|
+
errored = false;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
errored = true;
|
|
136
|
+
lastErr = err;
|
|
137
|
+
if (this.disconnected) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").error("failed to create auth key:", err);
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
__classPrivateFieldGet(this, _ClientEncrypted_plain, "f").disconnect();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (errored) {
|
|
147
|
+
throw lastErr;
|
|
148
|
+
}
|
|
149
|
+
}, _ClientEncrypted_send = async function _ClientEncrypted_send(function_) {
|
|
150
|
+
this.lastRequest = new Date();
|
|
151
|
+
if (__classPrivateFieldGet(this, _ClientEncrypted_disableUpdates, "f") && !isCdnFunction(function_)) {
|
|
152
|
+
function_ = { _: "invokeWithoutUpdates", query: function_ };
|
|
153
|
+
}
|
|
154
|
+
if (!__classPrivateFieldGet(this, _ClientEncrypted_connectionInited, "f")) {
|
|
155
|
+
function_ = {
|
|
156
|
+
_: "initConnection",
|
|
157
|
+
api_id: __classPrivateFieldGet(this, _ClientEncrypted_apiId, "f"),
|
|
158
|
+
app_version: __classPrivateFieldGet(this, _ClientEncrypted_appVersion, "f"),
|
|
159
|
+
device_model: __classPrivateFieldGet(this, _ClientEncrypted_deviceModel, "f"),
|
|
160
|
+
lang_code: __classPrivateFieldGet(this, _ClientEncrypted_langCode, "f"),
|
|
161
|
+
lang_pack: __classPrivateFieldGet(this, _ClientEncrypted_langPack, "f"),
|
|
162
|
+
query: {
|
|
163
|
+
_: "invokeWithLayer",
|
|
164
|
+
layer: Api.LAYER,
|
|
165
|
+
query: function_,
|
|
166
|
+
},
|
|
167
|
+
system_lang_code: __classPrivateFieldGet(this, _ClientEncrypted_systemLangCode, "f"),
|
|
168
|
+
system_version: __classPrivateFieldGet(this, _ClientEncrypted_systemVersion, "f"),
|
|
169
|
+
};
|
|
170
|
+
__classPrivateFieldSet(this, _ClientEncrypted_connectionInited, true, "f");
|
|
171
|
+
}
|
|
172
|
+
const body = Api.serializeObject(function_);
|
|
173
|
+
let lastErr;
|
|
174
|
+
for (let i = 0; i < __classPrivateFieldGet(_a, _a, "f", _ClientEncrypted_SEND_MAX_TRIES); ++i) {
|
|
175
|
+
let errored = false;
|
|
176
|
+
try {
|
|
177
|
+
return await this.session.send(body);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
errored = true;
|
|
181
|
+
lastErr = err;
|
|
182
|
+
if (this.disconnected) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").error("send failed:", err);
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
if (!errored) {
|
|
189
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").debug("invoked", repr(function_));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
throw new Error(`Failed to invoke function after ${__classPrivateFieldGet(_a, _a, "f", _ClientEncrypted_SEND_MAX_TRIES)} tries.`, { cause: lastErr });
|
|
194
|
+
}, _ClientEncrypted_resend = async function _ClientEncrypted_resend(request) {
|
|
195
|
+
try {
|
|
196
|
+
const messageId = await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_send).call(this, request.call);
|
|
197
|
+
__classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").set(messageId, request);
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
request.reject(err);
|
|
201
|
+
}
|
|
202
|
+
}, _ClientEncrypted_onUpdate = async function _ClientEncrypted_onUpdate(body) {
|
|
203
|
+
let type;
|
|
204
|
+
try {
|
|
205
|
+
type = await Api.deserializeType(X, body);
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").error("failed to deserialize update:", err);
|
|
209
|
+
this.handlers.onDeserializationError?.();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (Api.isOfEnum("Update", type) || Api.isOfEnum("Updates", type)) {
|
|
213
|
+
this.handlers.onUpdate?.(type);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").warning("received unknown type:", repr(type));
|
|
217
|
+
}
|
|
218
|
+
}, _ClientEncrypted_onNewServerSalt = function _ClientEncrypted_onNewServerSalt(serverSalt) {
|
|
219
|
+
this.handlers.onNewServerSalt?.(serverSalt);
|
|
220
|
+
}, _ClientEncrypted_onMessageFailed = async function _ClientEncrypted_onMessageFailed(msgId, error) {
|
|
221
|
+
const request = __classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").get(msgId);
|
|
222
|
+
if (request) {
|
|
223
|
+
__classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").delete(msgId);
|
|
224
|
+
if (error instanceof SessionError) {
|
|
225
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_resend).call(this, request);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
request.reject(error);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, _ClientEncrypted_onRpcError = async function _ClientEncrypted_onRpcError(msgId, error) {
|
|
232
|
+
const request = __classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").get(msgId);
|
|
233
|
+
if (request) {
|
|
234
|
+
__classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").delete(msgId);
|
|
235
|
+
const reason = constructTelegramError(error, request.call);
|
|
236
|
+
if (reason instanceof ConnectionNotInited) {
|
|
237
|
+
__classPrivateFieldSet(this, _ClientEncrypted_connectionInited, false, "f");
|
|
238
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_resend).call(this, request);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
request.reject(constructTelegramError(error, request.call));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}, _ClientEncrypted_onRpcResult = async function _ClientEncrypted_onRpcResult(msgId, body) {
|
|
245
|
+
const request = __classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").get(msgId);
|
|
246
|
+
if (request) {
|
|
247
|
+
let type;
|
|
248
|
+
try {
|
|
249
|
+
type = await Api.deserializeType(Api.mustGetReturnType(request.call._), body);
|
|
250
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").debug("received rpc_result", repr(type));
|
|
251
|
+
request.resolve(type);
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
request.reject(err);
|
|
255
|
+
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").error("failed to deserialize RPC result body:", err);
|
|
256
|
+
this.handlers.onDeserializationError?.();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
__classPrivateFieldGet(this, _ClientEncrypted_pendingRequests, "f").delete(msgId);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
_ClientEncrypted_SEND_MAX_TRIES = { value: 10 };
|
|
265
|
+
_ClientEncrypted_AUTH_KEY_CREATION_MAX_TRIES = { value: 10 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_file_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_file_manager.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"2_file_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_file_manager.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAA+C,UAAU,EAA8C,OAAO,EAAkB,MAAM,eAAe,CAAC;AAE7J,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,qBAAa,WAAW;;gBAQV,CAAC,EAAE,CAAC;IAOV,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,EAAE,WAAW,UAAO,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAmO1I,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,SAAS;IAuEtG,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAevD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM;IAY7B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,cAAc;IAmDjD,iBAAiB,CAAC,eAAe,EAAE,GAAG,CAAC,iBAAiB,EAAE,IAAI,SAAI;IAalE,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE;CA6CnD"}
|