@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.
Files changed (511) hide show
  1. package/esm/2_tl.d.ts +6 -6
  2. package/esm/2_tl.d.ts.map +1 -1
  3. package/esm/2_tl.js +6 -6
  4. package/esm/3_errors.d.ts +1 -2
  5. package/esm/3_errors.d.ts.map +1 -1
  6. package/esm/3_errors.js +2 -1
  7. package/esm/4_constants.d.ts +0 -1
  8. package/esm/4_constants.d.ts.map +1 -1
  9. package/esm/4_constants.js +0 -1
  10. package/esm/4_errors.d.ts +2 -2
  11. package/esm/4_errors.d.ts.map +1 -1
  12. package/esm/4_session.d.ts +24 -0
  13. package/esm/4_session.d.ts.map +1 -0
  14. package/esm/4_session.js +23 -0
  15. package/esm/5_client.d.ts +1 -1
  16. package/esm/5_client.js +1 -1
  17. package/esm/client/0_client_abstract.d.ts +28 -26
  18. package/esm/client/0_client_abstract.d.ts.map +1 -1
  19. package/esm/client/0_client_abstract.js +16 -88
  20. package/esm/client/0_params.d.ts +5 -0
  21. package/esm/client/0_params.d.ts.map +1 -1
  22. package/esm/client/0_password.d.ts.map +1 -1
  23. package/esm/client/0_password.js +2 -2
  24. package/esm/client/0_storage_operations.d.ts +4 -4
  25. package/esm/client/0_storage_operations.d.ts.map +1 -1
  26. package/esm/client/0_storage_operations.js +14 -14
  27. package/esm/client/0_update_processor.d.ts +19 -0
  28. package/esm/client/0_update_processor.d.ts.map +1 -1
  29. package/esm/client/0_update_processor.js +19 -0
  30. package/esm/client/0_utilities.d.ts +6 -2
  31. package/esm/client/0_utilities.d.ts.map +1 -1
  32. package/esm/client/0_utilities.js +21 -23
  33. package/esm/client/1_client_plain.d.ts +9 -6
  34. package/esm/client/1_client_plain.d.ts.map +1 -1
  35. package/esm/client/1_client_plain.js +26 -41
  36. package/esm/client/1_types.d.ts +4 -23
  37. package/esm/client/1_types.d.ts.map +1 -1
  38. package/esm/client/2_account_manager.js +10 -10
  39. package/esm/client/2_business_connection_manager.d.ts.map +1 -1
  40. package/esm/client/2_business_connection_manager.js +4 -4
  41. package/esm/client/2_client_encrypted.d.ts +58 -0
  42. package/esm/client/2_client_encrypted.d.ts.map +1 -0
  43. package/esm/client/2_client_encrypted.js +265 -0
  44. package/esm/client/2_file_manager.d.ts.map +1 -1
  45. package/esm/client/2_file_manager.js +54 -74
  46. package/esm/client/2_network_statistics_manager.d.ts +1 -1
  47. package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
  48. package/esm/client/2_network_statistics_manager.js +3 -3
  49. package/esm/client/2_payment_manager.d.ts.map +1 -1
  50. package/esm/client/2_payment_manager.js +3 -3
  51. package/esm/client/2_reaction_manager.d.ts.map +1 -1
  52. package/esm/client/2_reaction_manager.js +10 -10
  53. package/esm/client/2_translations_manager.d.ts +19 -0
  54. package/esm/client/2_translations_manager.d.ts.map +1 -1
  55. package/esm/client/2_translations_manager.js +24 -5
  56. package/esm/client/2_update_manager.d.ts +4 -4
  57. package/esm/client/2_update_manager.d.ts.map +1 -1
  58. package/esm/client/2_update_manager.js +69 -79
  59. package/esm/client/3_client_encrypted_pool.d.ts +30 -0
  60. package/esm/client/3_client_encrypted_pool.d.ts.map +1 -0
  61. package/esm/client/3_client_encrypted_pool.js +70 -0
  62. package/esm/client/3_message_manager.d.ts.map +1 -1
  63. package/esm/client/3_message_manager.js +96 -70
  64. package/esm/client/3_video_chat_manager.d.ts.map +1 -1
  65. package/esm/client/3_video_chat_manager.js +15 -20
  66. package/esm/client/4_callback_query_manager.d.ts.map +1 -1
  67. package/esm/client/4_callback_query_manager.js +2 -2
  68. package/esm/client/4_chat_list_manager.d.ts.map +1 -1
  69. package/esm/client/4_chat_list_manager.js +33 -33
  70. package/esm/client/4_chat_manager.d.ts.map +1 -1
  71. package/esm/client/4_chat_manager.js +25 -25
  72. package/esm/client/4_gift_manager.js +2 -2
  73. package/esm/client/4_inline_query_manager.d.ts.map +1 -1
  74. package/esm/client/4_inline_query_manager.js +4 -4
  75. package/esm/client/4_poll_manager.d.ts.map +1 -1
  76. package/esm/client/4_poll_manager.js +5 -5
  77. package/esm/client/4_story_manager.d.ts.map +1 -1
  78. package/esm/client/4_story_manager.js +10 -10
  79. package/esm/client/5_client.d.ts +3 -9
  80. package/esm/client/5_client.d.ts.map +1 -1
  81. package/esm/client/5_client.js +290 -306
  82. package/esm/connection/0_connection.d.ts +5 -4
  83. package/esm/connection/0_connection.d.ts.map +1 -1
  84. package/esm/connection/1_connection_web_socket.js +2 -2
  85. package/esm/mod.d.ts +1 -1
  86. package/esm/mod.d.ts.map +1 -1
  87. package/esm/mod.js +1 -1
  88. package/{script/tl/2_tl_reader.d.ts → esm/session/0_session_error.d.ts} +4 -7
  89. package/esm/session/0_session_error.d.ts.map +1 -0
  90. package/esm/{tl/2_tl_reader.d.ts → session/0_session_error.js} +5 -7
  91. package/esm/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  92. package/esm/session/0_session_state.d.ts.map +1 -0
  93. package/esm/session/0_session_state.js +77 -0
  94. package/esm/session/1_session.d.ts +31 -0
  95. package/esm/session/1_session.d.ts.map +1 -0
  96. package/esm/session/1_session.js +149 -0
  97. package/esm/session/2_session_encrypted.d.ts +40 -0
  98. package/esm/session/2_session_encrypted.d.ts.map +1 -0
  99. package/esm/session/2_session_encrypted.js +416 -0
  100. package/esm/session/2_session_plain.d.ts +25 -0
  101. package/esm/session/2_session_plain.d.ts.map +1 -0
  102. package/esm/session/2_session_plain.js +56 -0
  103. package/esm/tl/0_tl_error.d.ts +22 -0
  104. package/esm/tl/0_tl_error.d.ts.map +1 -0
  105. package/esm/tl/0_tl_error.js +21 -0
  106. package/esm/tl/0_types.d.ts +25 -0
  107. package/esm/tl/0_types.d.ts.map +1 -0
  108. package/esm/tl/0_types.js +20 -0
  109. package/esm/tl/0_utilities.d.ts +32 -0
  110. package/esm/tl/0_utilities.d.ts.map +1 -0
  111. package/esm/tl/0_utilities.js +51 -0
  112. package/esm/tl/0_utilities_test.d.ts.map +1 -0
  113. package/esm/tl/1_mtproto_api.d.ts +371 -0
  114. package/esm/tl/1_mtproto_api.d.ts.map +1 -0
  115. package/esm/tl/1_mtproto_api.js +416 -0
  116. package/esm/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  117. package/esm/tl/1_telegram_api.d.ts.map +1 -0
  118. package/esm/tl/{0_api.js → 1_telegram_api.js} +4945 -11109
  119. package/{script/tl/0_tl_raw_reader.d.ts → esm/tl/1_tl_reader.d.ts} +5 -2
  120. package/esm/tl/1_tl_reader.d.ts.map +1 -0
  121. package/esm/tl/{2_tl_reader.js → 1_tl_reader.js} +107 -40
  122. package/esm/tl/1_tl_reader_test.d.ts.map +1 -0
  123. package/esm/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  124. package/esm/tl/1_tl_writer.d.ts.map +1 -0
  125. package/esm/tl/{2_tl_writer.js → 1_tl_writer.js} +80 -23
  126. package/esm/tl/1_tl_writer_test.d.ts.map +1 -0
  127. package/esm/tl/1_utilities.d.ts +9 -24
  128. package/esm/tl/1_utilities.d.ts.map +1 -1
  129. package/esm/tl/1_utilities.js +18 -64
  130. package/esm/tl/2_message.d.ts +2 -2
  131. package/esm/tl/2_message.d.ts.map +1 -1
  132. package/esm/tl/2_message.js +7 -7
  133. package/esm/tl/2_mtproto.d.ts +33 -0
  134. package/esm/tl/2_mtproto.d.ts.map +1 -0
  135. package/esm/tl/2_mtproto.js +53 -0
  136. package/{script/tl/2_utilities.d.ts → esm/tl/2_telegram.d.ts} +16 -2
  137. package/esm/tl/2_telegram.d.ts.map +1 -0
  138. package/esm/tl/{2_utilities.js → 2_telegram.js} +46 -1
  139. package/esm/transport/0_transport.d.ts +1 -1
  140. package/esm/transport/0_transport.d.ts.map +1 -1
  141. package/esm/types/0_chat_photo.d.ts.map +1 -1
  142. package/esm/types/0_chat_photo.js +2 -2
  143. package/esm/types/0_giveaway_parameters.d.ts.map +1 -1
  144. package/esm/types/0_giveaway_parameters.js +3 -3
  145. package/esm/types/0_location.d.ts.map +1 -1
  146. package/esm/types/0_location.js +5 -5
  147. package/esm/types/0_message_entity.d.ts.map +1 -1
  148. package/esm/types/0_message_entity.js +20 -20
  149. package/esm/types/0_reaction.d.ts.map +1 -1
  150. package/esm/types/0_reaction.js +4 -4
  151. package/esm/types/0_slow_mode_duration.d.ts +19 -0
  152. package/esm/types/0_slow_mode_duration.d.ts.map +1 -1
  153. package/esm/types/0_slow_mode_duration.js +19 -0
  154. package/esm/types/0_thumbnail.d.ts.map +1 -1
  155. package/esm/types/0_thumbnail.js +3 -3
  156. package/esm/types/0_translation.d.ts +19 -0
  157. package/esm/types/0_translation.d.ts.map +1 -1
  158. package/esm/types/0_translation.js +22 -3
  159. package/esm/types/0_video_chat.d.ts.map +1 -1
  160. package/esm/types/0_video_chat.js +2 -2
  161. package/esm/types/1_animation.d.ts.map +1 -1
  162. package/esm/types/1_animation.js +2 -2
  163. package/esm/types/1_audio.d.ts.map +1 -1
  164. package/esm/types/1_audio.js +2 -2
  165. package/esm/types/1_bot_command_scope.d.ts.map +1 -1
  166. package/esm/types/1_bot_command_scope.js +2 -2
  167. package/esm/types/1_chat_p.d.ts.map +1 -1
  168. package/esm/types/1_chat_p.js +6 -6
  169. package/esm/types/1_document.d.ts.map +1 -1
  170. package/esm/types/1_document.js +2 -2
  171. package/esm/types/1_keyboard_button.d.ts.map +1 -1
  172. package/esm/types/1_keyboard_button.js +10 -10
  173. package/esm/types/1_message_reaction.d.ts.map +1 -1
  174. package/esm/types/1_message_reaction.js +6 -6
  175. package/esm/types/1_photo.d.ts.map +1 -1
  176. package/esm/types/1_photo.js +3 -3
  177. package/esm/types/1_sticker.d.ts.map +1 -1
  178. package/esm/types/1_sticker.js +8 -8
  179. package/esm/types/1_story_privacy.d.ts.map +1 -1
  180. package/esm/types/1_story_privacy.js +7 -7
  181. package/esm/types/1_user.d.ts.map +1 -1
  182. package/esm/types/1_user.js +2 -2
  183. package/esm/types/1_venue.d.ts.map +1 -1
  184. package/esm/types/1_venue.js +2 -2
  185. package/esm/types/1_video.d.ts.map +1 -1
  186. package/esm/types/1_video.js +2 -2
  187. package/esm/types/1_video_note.d.ts.map +1 -1
  188. package/esm/types/1_video_note.js +2 -2
  189. package/esm/types/2_chat.d.ts.map +1 -1
  190. package/esm/types/2_chat.js +8 -8
  191. package/esm/types/2_chat_member.d.ts.map +1 -1
  192. package/esm/types/2_chat_member.js +10 -10
  193. package/esm/types/2_chat_settings.d.ts +19 -0
  194. package/esm/types/2_chat_settings.d.ts.map +1 -1
  195. package/esm/types/2_chat_settings.js +21 -2
  196. package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
  197. package/esm/types/2_chosen_inline_result.js +4 -4
  198. package/esm/types/2_game.d.ts.map +1 -1
  199. package/esm/types/2_game.js +4 -4
  200. package/esm/types/2_gift_upgraded_component.d.ts.map +1 -1
  201. package/esm/types/2_gift_upgraded_component.js +3 -3
  202. package/esm/types/2_inactive_chat.d.ts.map +1 -1
  203. package/esm/types/2_inactive_chat.js +2 -2
  204. package/esm/types/2_inline_keyboard_button.d.ts.map +1 -1
  205. package/esm/types/2_inline_keyboard_button.js +10 -10
  206. package/esm/types/2_inline_query.d.ts.map +1 -1
  207. package/esm/types/2_inline_query.js +7 -7
  208. package/esm/types/2_message_reactions.d.ts.map +1 -1
  209. package/esm/types/2_message_reactions.js +2 -2
  210. package/esm/types/2_story_content.d.ts.map +1 -1
  211. package/esm/types/2_story_content.js +6 -6
  212. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  213. package/esm/types/2_story_interactive_area.js +9 -9
  214. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  215. package/esm/types/3_chat_member_updated.js +2 -2
  216. package/esm/types/3_gift.d.ts.map +1 -1
  217. package/esm/types/3_gift.js +3 -3
  218. package/esm/types/3_join_request.d.ts.map +1 -1
  219. package/esm/types/3_join_request.js +2 -2
  220. package/esm/types/3_reply_markup.d.ts.map +1 -1
  221. package/esm/types/3_reply_markup.js +5 -5
  222. package/esm/types/4_claimed_gift.d.ts.map +1 -1
  223. package/esm/types/4_claimed_gift.js +2 -2
  224. package/esm/types/4_inline_query_result.d.ts.map +1 -1
  225. package/esm/types/4_inline_query_result.js +14 -14
  226. package/esm/types/4_message.d.ts.map +1 -1
  227. package/esm/types/4_message.js +57 -57
  228. package/esm/types/5_callback_query.d.ts.map +1 -1
  229. package/esm/types/5_callback_query.js +6 -7
  230. package/esm/types/5_chat_list_item.d.ts.map +1 -1
  231. package/esm/types/5_chat_list_item.js +5 -5
  232. package/esm/types/5_claimed_gifts.d.ts.map +1 -1
  233. package/esm/types/5_claimed_gifts.js +6 -6
  234. package/esm/types/_file_id.d.ts.map +1 -1
  235. package/esm/types/_file_id.js +3 -3
  236. package/package.json +1 -1
  237. package/script/2_tl.d.ts +6 -6
  238. package/script/2_tl.d.ts.map +1 -1
  239. package/script/2_tl.js +11 -11
  240. package/script/3_errors.d.ts +1 -2
  241. package/script/3_errors.d.ts.map +1 -1
  242. package/script/3_errors.js +2 -1
  243. package/script/4_constants.d.ts +0 -1
  244. package/script/4_constants.d.ts.map +1 -1
  245. package/script/4_constants.js +1 -2
  246. package/script/4_errors.d.ts +2 -2
  247. package/script/4_errors.d.ts.map +1 -1
  248. package/script/4_session.d.ts +24 -0
  249. package/script/4_session.d.ts.map +1 -0
  250. package/script/4_session.js +39 -0
  251. package/script/5_client.d.ts +1 -1
  252. package/script/5_client.js +1 -1
  253. package/script/client/0_client_abstract.d.ts +28 -26
  254. package/script/client/0_client_abstract.d.ts.map +1 -1
  255. package/script/client/0_client_abstract.js +18 -113
  256. package/script/client/0_params.d.ts +5 -0
  257. package/script/client/0_params.d.ts.map +1 -1
  258. package/script/client/0_password.d.ts.map +1 -1
  259. package/script/client/0_password.js +1 -1
  260. package/script/client/0_storage_operations.d.ts +4 -4
  261. package/script/client/0_storage_operations.d.ts.map +1 -1
  262. package/script/client/0_storage_operations.js +13 -13
  263. package/script/client/0_update_processor.d.ts +19 -0
  264. package/script/client/0_update_processor.d.ts.map +1 -1
  265. package/script/client/0_update_processor.js +19 -0
  266. package/script/client/0_utilities.d.ts +6 -2
  267. package/script/client/0_utilities.d.ts.map +1 -1
  268. package/script/client/0_utilities.js +22 -24
  269. package/script/client/1_client_plain.d.ts +9 -6
  270. package/script/client/1_client_plain.d.ts.map +1 -1
  271. package/script/client/1_client_plain.js +25 -40
  272. package/script/client/1_types.d.ts +4 -23
  273. package/script/client/1_types.d.ts.map +1 -1
  274. package/script/client/2_account_manager.js +9 -9
  275. package/script/client/2_business_connection_manager.d.ts.map +1 -1
  276. package/script/client/2_business_connection_manager.js +3 -3
  277. package/script/client/2_client_encrypted.d.ts +58 -0
  278. package/script/client/2_client_encrypted.d.ts.map +1 -0
  279. package/script/client/2_client_encrypted.js +269 -0
  280. package/script/client/2_file_manager.d.ts.map +1 -1
  281. package/script/client/2_file_manager.js +52 -72
  282. package/script/client/2_network_statistics_manager.d.ts +1 -1
  283. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  284. package/script/client/2_network_statistics_manager.js +3 -3
  285. package/script/client/2_payment_manager.d.ts.map +1 -1
  286. package/script/client/2_payment_manager.js +2 -2
  287. package/script/client/2_reaction_manager.d.ts.map +1 -1
  288. package/script/client/2_reaction_manager.js +9 -9
  289. package/script/client/2_translations_manager.d.ts +19 -0
  290. package/script/client/2_translations_manager.d.ts.map +1 -1
  291. package/script/client/2_translations_manager.js +23 -4
  292. package/script/client/2_update_manager.d.ts +4 -4
  293. package/script/client/2_update_manager.d.ts.map +1 -1
  294. package/script/client/2_update_manager.js +68 -78
  295. package/script/client/3_client_encrypted_pool.d.ts +30 -0
  296. package/script/client/3_client_encrypted_pool.d.ts.map +1 -0
  297. package/script/client/3_client_encrypted_pool.js +74 -0
  298. package/script/client/3_message_manager.d.ts.map +1 -1
  299. package/script/client/3_message_manager.js +95 -69
  300. package/script/client/3_video_chat_manager.d.ts.map +1 -1
  301. package/script/client/3_video_chat_manager.js +14 -19
  302. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  303. package/script/client/4_callback_query_manager.js +1 -1
  304. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  305. package/script/client/4_chat_list_manager.js +32 -32
  306. package/script/client/4_chat_manager.d.ts.map +1 -1
  307. package/script/client/4_chat_manager.js +24 -24
  308. package/script/client/4_gift_manager.js +1 -1
  309. package/script/client/4_inline_query_manager.d.ts.map +1 -1
  310. package/script/client/4_inline_query_manager.js +3 -3
  311. package/script/client/4_poll_manager.d.ts.map +1 -1
  312. package/script/client/4_poll_manager.js +4 -4
  313. package/script/client/4_story_manager.d.ts.map +1 -1
  314. package/script/client/4_story_manager.js +9 -9
  315. package/script/client/5_client.d.ts +3 -9
  316. package/script/client/5_client.d.ts.map +1 -1
  317. package/script/client/5_client.js +284 -300
  318. package/script/connection/0_connection.d.ts +5 -4
  319. package/script/connection/0_connection.d.ts.map +1 -1
  320. package/script/connection/1_connection_web_socket.js +2 -2
  321. package/script/mod.d.ts +1 -1
  322. package/script/mod.d.ts.map +1 -1
  323. package/script/mod.js +1 -2
  324. package/script/session/0_session_error.d.ts +24 -0
  325. package/script/session/0_session_error.d.ts.map +1 -0
  326. package/script/session/0_session_error.js +29 -0
  327. package/script/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  328. package/script/session/0_session_state.d.ts.map +1 -0
  329. package/script/session/0_session_state.js +81 -0
  330. package/script/session/1_session.d.ts +31 -0
  331. package/script/session/1_session.d.ts.map +1 -0
  332. package/script/session/1_session.js +176 -0
  333. package/script/session/2_session_encrypted.d.ts +40 -0
  334. package/script/session/2_session_encrypted.d.ts.map +1 -0
  335. package/script/session/2_session_encrypted.js +420 -0
  336. package/script/session/2_session_plain.d.ts +25 -0
  337. package/script/session/2_session_plain.d.ts.map +1 -0
  338. package/script/session/2_session_plain.js +60 -0
  339. package/script/tl/0_tl_error.d.ts +22 -0
  340. package/script/tl/0_tl_error.d.ts.map +1 -0
  341. package/script/tl/0_tl_error.js +25 -0
  342. package/script/tl/0_types.d.ts +25 -0
  343. package/script/tl/0_types.d.ts.map +1 -0
  344. package/script/tl/0_types.js +21 -0
  345. package/script/tl/0_utilities.d.ts +32 -0
  346. package/script/tl/0_utilities.d.ts.map +1 -0
  347. package/script/tl/0_utilities.js +59 -0
  348. package/script/tl/0_utilities_test.d.ts.map +1 -0
  349. package/script/tl/1_mtproto_api.d.ts +371 -0
  350. package/script/tl/1_mtproto_api.d.ts.map +1 -0
  351. package/script/tl/1_mtproto_api.js +419 -0
  352. package/script/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  353. package/script/tl/1_telegram_api.d.ts.map +1 -0
  354. package/script/tl/{0_api.js → 1_telegram_api.js} +4947 -11134
  355. package/{esm/tl/0_tl_raw_reader.d.ts → script/tl/1_tl_reader.d.ts} +5 -2
  356. package/script/tl/1_tl_reader.d.ts.map +1 -0
  357. package/script/tl/1_tl_reader.js +218 -0
  358. package/script/tl/1_tl_reader_test.d.ts.map +1 -0
  359. package/script/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  360. package/script/tl/1_tl_writer.d.ts.map +1 -0
  361. package/script/tl/{2_tl_writer.js → 1_tl_writer.js} +102 -45
  362. package/script/tl/1_tl_writer_test.d.ts.map +1 -0
  363. package/script/tl/1_utilities.d.ts +9 -24
  364. package/script/tl/1_utilities.d.ts.map +1 -1
  365. package/script/tl/1_utilities.js +19 -72
  366. package/script/tl/2_message.d.ts +2 -2
  367. package/script/tl/2_message.d.ts.map +1 -1
  368. package/script/tl/2_message.js +7 -7
  369. package/script/tl/2_mtproto.d.ts +33 -0
  370. package/script/tl/2_mtproto.d.ts.map +1 -0
  371. package/script/tl/2_mtproto.js +78 -0
  372. package/{esm/tl/2_utilities.d.ts → script/tl/2_telegram.d.ts} +16 -2
  373. package/script/tl/2_telegram.d.ts.map +1 -0
  374. package/script/tl/2_telegram.js +167 -0
  375. package/script/transport/0_transport.d.ts +1 -1
  376. package/script/transport/0_transport.d.ts.map +1 -1
  377. package/script/types/0_chat_photo.d.ts.map +1 -1
  378. package/script/types/0_chat_photo.js +1 -1
  379. package/script/types/0_giveaway_parameters.d.ts.map +1 -1
  380. package/script/types/0_giveaway_parameters.js +2 -2
  381. package/script/types/0_location.d.ts.map +1 -1
  382. package/script/types/0_location.js +4 -4
  383. package/script/types/0_message_entity.d.ts.map +1 -1
  384. package/script/types/0_message_entity.js +19 -19
  385. package/script/types/0_reaction.d.ts.map +1 -1
  386. package/script/types/0_reaction.js +3 -3
  387. package/script/types/0_slow_mode_duration.d.ts +19 -0
  388. package/script/types/0_slow_mode_duration.d.ts.map +1 -1
  389. package/script/types/0_slow_mode_duration.js +19 -0
  390. package/script/types/0_thumbnail.d.ts.map +1 -1
  391. package/script/types/0_thumbnail.js +2 -2
  392. package/script/types/0_translation.d.ts +19 -0
  393. package/script/types/0_translation.d.ts.map +1 -1
  394. package/script/types/0_translation.js +21 -2
  395. package/script/types/0_video_chat.d.ts.map +1 -1
  396. package/script/types/0_video_chat.js +1 -1
  397. package/script/types/1_animation.d.ts.map +1 -1
  398. package/script/types/1_animation.js +1 -1
  399. package/script/types/1_audio.d.ts.map +1 -1
  400. package/script/types/1_audio.js +1 -1
  401. package/script/types/1_bot_command_scope.d.ts.map +1 -1
  402. package/script/types/1_bot_command_scope.js +1 -1
  403. package/script/types/1_chat_p.d.ts.map +1 -1
  404. package/script/types/1_chat_p.js +5 -5
  405. package/script/types/1_document.d.ts.map +1 -1
  406. package/script/types/1_document.js +1 -1
  407. package/script/types/1_keyboard_button.d.ts.map +1 -1
  408. package/script/types/1_keyboard_button.js +9 -9
  409. package/script/types/1_message_reaction.d.ts.map +1 -1
  410. package/script/types/1_message_reaction.js +5 -5
  411. package/script/types/1_photo.d.ts.map +1 -1
  412. package/script/types/1_photo.js +2 -2
  413. package/script/types/1_sticker.d.ts.map +1 -1
  414. package/script/types/1_sticker.js +7 -7
  415. package/script/types/1_story_privacy.d.ts.map +1 -1
  416. package/script/types/1_story_privacy.js +6 -6
  417. package/script/types/1_user.d.ts.map +1 -1
  418. package/script/types/1_user.js +1 -1
  419. package/script/types/1_venue.d.ts.map +1 -1
  420. package/script/types/1_venue.js +1 -1
  421. package/script/types/1_video.d.ts.map +1 -1
  422. package/script/types/1_video.js +1 -1
  423. package/script/types/1_video_note.d.ts.map +1 -1
  424. package/script/types/1_video_note.js +1 -1
  425. package/script/types/2_chat.d.ts.map +1 -1
  426. package/script/types/2_chat.js +7 -7
  427. package/script/types/2_chat_member.d.ts.map +1 -1
  428. package/script/types/2_chat_member.js +9 -9
  429. package/script/types/2_chat_settings.d.ts +19 -0
  430. package/script/types/2_chat_settings.d.ts.map +1 -1
  431. package/script/types/2_chat_settings.js +20 -1
  432. package/script/types/2_chosen_inline_result.d.ts.map +1 -1
  433. package/script/types/2_chosen_inline_result.js +3 -3
  434. package/script/types/2_game.d.ts.map +1 -1
  435. package/script/types/2_game.js +3 -3
  436. package/script/types/2_gift_upgraded_component.d.ts.map +1 -1
  437. package/script/types/2_gift_upgraded_component.js +2 -2
  438. package/script/types/2_inactive_chat.d.ts.map +1 -1
  439. package/script/types/2_inactive_chat.js +1 -1
  440. package/script/types/2_inline_keyboard_button.d.ts.map +1 -1
  441. package/script/types/2_inline_keyboard_button.js +9 -9
  442. package/script/types/2_inline_query.d.ts.map +1 -1
  443. package/script/types/2_inline_query.js +6 -6
  444. package/script/types/2_message_reactions.d.ts.map +1 -1
  445. package/script/types/2_message_reactions.js +1 -1
  446. package/script/types/2_story_content.d.ts.map +1 -1
  447. package/script/types/2_story_content.js +5 -5
  448. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  449. package/script/types/2_story_interactive_area.js +8 -8
  450. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  451. package/script/types/3_chat_member_updated.js +1 -1
  452. package/script/types/3_gift.d.ts.map +1 -1
  453. package/script/types/3_gift.js +2 -2
  454. package/script/types/3_join_request.d.ts.map +1 -1
  455. package/script/types/3_join_request.js +1 -1
  456. package/script/types/3_reply_markup.d.ts.map +1 -1
  457. package/script/types/3_reply_markup.js +4 -4
  458. package/script/types/4_claimed_gift.d.ts.map +1 -1
  459. package/script/types/4_claimed_gift.js +1 -1
  460. package/script/types/4_inline_query_result.d.ts.map +1 -1
  461. package/script/types/4_inline_query_result.js +13 -13
  462. package/script/types/4_message.d.ts.map +1 -1
  463. package/script/types/4_message.js +56 -56
  464. package/script/types/5_callback_query.d.ts.map +1 -1
  465. package/script/types/5_callback_query.js +5 -6
  466. package/script/types/5_chat_list_item.d.ts.map +1 -1
  467. package/script/types/5_chat_list_item.js +4 -4
  468. package/script/types/5_claimed_gifts.d.ts.map +1 -1
  469. package/script/types/5_claimed_gifts.js +5 -5
  470. package/script/types/_file_id.d.ts.map +1 -1
  471. package/script/types/_file_id.js +2 -2
  472. package/esm/client/0_message.d.ts +0 -29
  473. package/esm/client/0_message.d.ts.map +0 -1
  474. package/esm/client/0_message.js +0 -83
  475. package/esm/client/1_client_encrypted.d.ts +0 -52
  476. package/esm/client/1_client_encrypted.d.ts.map +0 -1
  477. package/esm/client/1_client_encrypted.js +0 -381
  478. package/esm/tl/0_api.d.ts.map +0 -1
  479. package/esm/tl/0_tl_raw_reader.d.ts.map +0 -1
  480. package/esm/tl/0_tl_raw_reader.js +0 -97
  481. package/esm/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  482. package/esm/tl/0_tl_raw_writer.d.ts.map +0 -1
  483. package/esm/tl/0_tl_raw_writer.js +0 -86
  484. package/esm/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  485. package/esm/tl/1_utilities_test.d.ts.map +0 -1
  486. package/esm/tl/2_tl_reader.d.ts.map +0 -1
  487. package/esm/tl/2_tl_reader_test.d.ts.map +0 -1
  488. package/esm/tl/2_tl_writer.d.ts.map +0 -1
  489. package/esm/tl/2_tl_writer_test.d.ts.map +0 -1
  490. package/esm/tl/2_utilities.d.ts.map +0 -1
  491. package/script/client/0_message.d.ts +0 -29
  492. package/script/client/0_message.d.ts.map +0 -1
  493. package/script/client/0_message.js +0 -90
  494. package/script/client/1_client_encrypted.d.ts +0 -52
  495. package/script/client/1_client_encrypted.d.ts.map +0 -1
  496. package/script/client/1_client_encrypted.js +0 -385
  497. package/script/tl/0_api.d.ts.map +0 -1
  498. package/script/tl/0_tl_raw_reader.d.ts.map +0 -1
  499. package/script/tl/0_tl_raw_reader.js +0 -102
  500. package/script/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  501. package/script/tl/0_tl_raw_writer.d.ts.map +0 -1
  502. package/script/tl/0_tl_raw_writer.js +0 -90
  503. package/script/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  504. package/script/tl/1_utilities_test.d.ts.map +0 -1
  505. package/script/tl/2_tl_reader.d.ts.map +0 -1
  506. package/script/tl/2_tl_reader.js +0 -150
  507. package/script/tl/2_tl_reader_test.d.ts.map +0 -1
  508. package/script/tl/2_tl_writer.d.ts.map +0 -1
  509. package/script/tl/2_tl_writer_test.d.ts.map +0 -1
  510. package/script/tl/2_utilities.d.ts.map +0 -1
  511. package/script/tl/2_utilities.js +0 -98
@@ -1,381 +0,0 @@
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, _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;
32
- import { unreachable } from "../0_deps.js";
33
- import { ConnectionError } from "../0_errors.js";
34
- import { bigIntFromBuffer, CacheMap, drop, getLogger, getRandomBigInt, gunzip, gzip, sha1, toUnixTimestamp } from "../1_utilities.js";
35
- import { Api, GZIP_PACKED, is, isGenericFunction, isOfEnum, isOneOf, mustGetReturnType, repr, RPC_RESULT, TLError, TLReader, X } from "../2_tl.js";
36
- import { constructTelegramError } from "../4_errors.js";
37
- import { TLWriter } from "../tl/2_tl_writer.js";
38
- import { ClientAbstract } from "./0_client_abstract.js";
39
- import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
40
- const COMPRESSION_THRESHOLD = 1024;
41
- // global ClientEncrypted ID counter for logs
42
- let id = 0;
43
- const RPC_ERROR = Api.getType("rpc_error")[0];
44
- /**
45
- * An MTProto client for making encrypted connections. Most users won't need to interact with this. Used internally by `Client`.
46
- *
47
- * There are a few things to note:
48
- *
49
- * - This is a bare client and it stores nothing.
50
- * - It expects an authorization key to be present before invoking any method.
51
- * - Authorization must be set using `setAuthKey`.
52
- * - Incoming packets that aren't a reply to a specific call are passed to the assigned handlers.
53
- * - It doesn't uncompress compressed packets.
54
- */
55
- export class ClientEncrypted extends ClientAbstract {
56
- constructor(params) {
57
- super(params);
58
- _ClientEncrypted_instances.add(this);
59
- _ClientEncrypted_authKey.set(this, new Uint8Array());
60
- _ClientEncrypted_authKeyId.set(this, 0n);
61
- _ClientEncrypted_sessionId.set(this, 0n);
62
- _ClientEncrypted_state.set(this, { serverSalt: 0n, seqNo: 0, messageId: 0n });
63
- _ClientEncrypted_shouldInvalidateSession.set(this, true);
64
- _ClientEncrypted_toAcknowledge.set(this, new Array());
65
- _ClientEncrypted_recentAcks.set(this, new CacheMap(20));
66
- _ClientEncrypted_promises.set(this, new Map());
67
- _ClientEncrypted_loopActive.set(this, true);
68
- // loggers
69
- _ClientEncrypted_L.set(this, void 0);
70
- _ClientEncrypted_LreceiveLoop.set(this, void 0);
71
- _ClientEncrypted_Linvoke.set(this, void 0);
72
- // receive loop handlers
73
- Object.defineProperty(this, "handlers", {
74
- enumerable: true,
75
- configurable: true,
76
- writable: true,
77
- value: {}
78
- });
79
- _ClientEncrypted_timeDifference.set(this, 0);
80
- const L = __classPrivateFieldSet(this, _ClientEncrypted_L, getLogger("ClientEncrypted").client(id++), "f");
81
- __classPrivateFieldSet(this, _ClientEncrypted_LreceiveLoop, L.branch("receiveLoop"), "f");
82
- __classPrivateFieldSet(this, _ClientEncrypted_Linvoke, L.branch("invoke"), "f");
83
- }
84
- async connect() {
85
- await super.connect();
86
- if (__classPrivateFieldGet(this, _ClientEncrypted_shouldInvalidateSession, "f")) {
87
- __classPrivateFieldSet(this, _ClientEncrypted_sessionId, getRandomBigInt(8, true, false), "f");
88
- __classPrivateFieldSet(this, _ClientEncrypted_state, { serverSalt: 0n, seqNo: 0, messageId: 0n }, "f");
89
- __classPrivateFieldSet(this, _ClientEncrypted_shouldInvalidateSession, false, "f");
90
- }
91
- drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_receiveLoop).call(this)); // TODO: ability to join this promise
92
- }
93
- async setAuthKey(key) {
94
- const hash = await sha1(key);
95
- __classPrivateFieldSet(this, _ClientEncrypted_authKeyId, bigIntFromBuffer(hash.slice(-8), true, false), "f");
96
- __classPrivateFieldSet(this, _ClientEncrypted_authKey, key, "f");
97
- }
98
- get authKey() {
99
- return __classPrivateFieldGet(this, _ClientEncrypted_authKey, "f");
100
- }
101
- set serverSalt(serverSalt) {
102
- __classPrivateFieldGet(this, _ClientEncrypted_state, "f").serverSalt = serverSalt;
103
- }
104
- get serverSalt() {
105
- return __classPrivateFieldGet(this, _ClientEncrypted_state, "f").serverSalt;
106
- }
107
- async invoke(function_, noWait) {
108
- const messageId = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this);
109
- let body = new TLWriter().serialize(function_).buffer;
110
- if (body.length > COMPRESSION_THRESHOLD) {
111
- body = new TLWriter()
112
- .writeInt32(GZIP_PACKED, false)
113
- .writeBytes(await gzip(body))
114
- .buffer;
115
- }
116
- let message_ = {
117
- _: "message",
118
- msg_id: messageId,
119
- seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, true),
120
- body,
121
- };
122
- const message__ = message_;
123
- let container = undefined;
124
- if (__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").length) {
125
- const ack = {
126
- _: "message",
127
- msg_id: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this),
128
- seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, false),
129
- body: new TLWriter().serialize({ _: "msgs_ack", msg_ids: __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").splice(0, 8192) }).buffer,
130
- };
131
- __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").set(ack.msg_id, { container, message: ack });
132
- message_ = {
133
- _: "message",
134
- msg_id: container = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this),
135
- seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, false),
136
- body: {
137
- _: "msg_container",
138
- messages: [message_, ack],
139
- },
140
- };
141
- }
142
- await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, message_);
143
- __classPrivateFieldGet(this, _ClientEncrypted_Linvoke, "f").debug("invoked", function_._);
144
- if (noWait) {
145
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").set(messageId, {
146
- container,
147
- message: message_,
148
- call: function_,
149
- });
150
- return;
151
- }
152
- return (await new Promise((resolve, reject) => {
153
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").set(messageId, { container, message: message__, resolve, reject, call: function_ });
154
- }));
155
- }
156
- }
157
- _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() {
158
- return __classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId = getMessageId(__classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId, __classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"));
159
- }, _ClientEncrypted_nextSeqNo = function _ClientEncrypted_nextSeqNo(contentRelated) {
160
- let seqNo = __classPrivateFieldGet(this, _ClientEncrypted_state, "f").seqNo * 2;
161
- if (contentRelated) {
162
- seqNo++;
163
- __classPrivateFieldGet(this, _ClientEncrypted_state, "f").seqNo++;
164
- }
165
- return seqNo;
166
- }, _ClientEncrypted_invalidateSession = async function _ClientEncrypted_invalidateSession() {
167
- await this.transport?.transport.deinitialize();
168
- await this.transport?.connection.close();
169
- __classPrivateFieldSet(this, _ClientEncrypted_shouldInvalidateSession, true, "f");
170
- }, _ClientEncrypted_sendMessage = async function _ClientEncrypted_sendMessage(message) {
171
- const payload = await encryptMessage(message, __classPrivateFieldGet(this, _ClientEncrypted_authKey, "f"), __classPrivateFieldGet(this, _ClientEncrypted_authKeyId, "f"), __classPrivateFieldGet(this, _ClientEncrypted_state, "f").serverSalt, __classPrivateFieldGet(this, _ClientEncrypted_sessionId, "f"));
172
- if (!this.transport) {
173
- throw new ConnectionError("Not connected.");
174
- }
175
- await this.transport.transport.send(payload);
176
- __classPrivateFieldGet(this, _ClientEncrypted_L, "f").out(message);
177
- __classPrivateFieldGet(this, _ClientEncrypted_L, "f").outBin(payload);
178
- }, _ClientEncrypted_receiveLoop = async function _ClientEncrypted_receiveLoop() {
179
- if (!this.transport) {
180
- unreachable();
181
- }
182
- for (const [key, { reject }] of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").entries()) {
183
- reject?.(new ConnectionError("Connection was closed"));
184
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(key);
185
- }
186
- __classPrivateFieldSet(this, _ClientEncrypted_loopActive, true, "f");
187
- while (this.connected && __classPrivateFieldGet(this, _ClientEncrypted_loopActive, "f")) {
188
- try {
189
- const buffer = await this.transport.transport.receive();
190
- __classPrivateFieldGet(this, _ClientEncrypted_L, "f").inBin(buffer);
191
- let decrypted;
192
- try {
193
- decrypted = await (decryptMessage(buffer, __classPrivateFieldGet(this, _ClientEncrypted_authKey, "f"), __classPrivateFieldGet(this, _ClientEncrypted_authKeyId, "f"), __classPrivateFieldGet(this, _ClientEncrypted_sessionId, "f")));
194
- __classPrivateFieldGet(this, _ClientEncrypted_L, "f").in(decrypted);
195
- }
196
- catch (err) {
197
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").error("failed to decrypt message:", err);
198
- drop(this.handlers.error?.(err, "decryption"));
199
- continue;
200
- }
201
- const messages = decrypted.body instanceof Uint8Array ? [decrypted] : decrypted.body.messages.map((v) => v);
202
- for (const message of messages) {
203
- if (!(message.body instanceof Uint8Array)) {
204
- unreachable();
205
- }
206
- await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleIncomingMessage).call(this, message);
207
- }
208
- }
209
- catch (err) {
210
- if (!this.connected) {
211
- break;
212
- }
213
- else if (err instanceof TLError) {
214
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").error("failed to deserialize:", err);
215
- drop(this.handlers.error?.(err, "deserialization"));
216
- }
217
- else {
218
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").error("unexpected error:", err);
219
- }
220
- }
221
- }
222
- if (!this.connected) {
223
- for (const [key, { reject }] of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").entries()) {
224
- reject?.(new ConnectionError("Connection was closed"));
225
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(key);
226
- }
227
- }
228
- else {
229
- unreachable();
230
- }
231
- }, _ClientEncrypted_handleIncomingMessage = async function _ClientEncrypted_handleIncomingMessage(message) {
232
- const body = message.body;
233
- if (!(body instanceof Uint8Array)) {
234
- unreachable();
235
- }
236
- let reader = new TLReader(body);
237
- const id = reader.readInt32(false);
238
- if (id == GZIP_PACKED) {
239
- reader = new TLReader(await gunzip(reader.readBytes()));
240
- }
241
- else if (id == RPC_RESULT) {
242
- await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleRpcResult).call(this, reader);
243
- }
244
- else {
245
- reader.unreadInt32();
246
- await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleType).call(this, message, reader);
247
- return;
248
- }
249
- __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
250
- }, _ClientEncrypted_handleRpcResult = async function _ClientEncrypted_handleRpcResult(reader) {
251
- const messageId = reader.readInt64();
252
- const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(messageId);
253
- if (!promise) {
254
- return;
255
- }
256
- let id = reader.readInt32(false);
257
- if (id == GZIP_PACKED) {
258
- reader = new TLReader(await gunzip(reader.readBytes()));
259
- id = reader.readInt32(false);
260
- reader.unreadInt32();
261
- }
262
- else {
263
- reader.unreadInt32();
264
- }
265
- // deno-lint-ignore no-explicit-any
266
- let call = promise?.call ?? null;
267
- while (isGenericFunction(call)) {
268
- call = call.query;
269
- }
270
- // deno-lint-ignore no-explicit-any
271
- let result;
272
- if (id == RPC_ERROR) {
273
- result = await reader.deserialize("rpc_error");
274
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", result.error_code, result.error_message);
275
- }
276
- else {
277
- result = await reader.deserialize(mustGetReturnType(call._));
278
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", Array.isArray(result) ? "Array" : typeof result === "object" ? result._ : result);
279
- }
280
- const resolvePromise = () => {
281
- if (is("rpc_error", result)) {
282
- promise.reject?.(constructTelegramError(result, promise.call));
283
- }
284
- else {
285
- promise.resolve?.(result);
286
- }
287
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(messageId);
288
- };
289
- if (isOfEnum("Updates", result) || isOfEnum("Update", result)) {
290
- drop(this.handlers.updates?.(result, call, resolvePromise));
291
- }
292
- else {
293
- drop(this.handlers.result?.(result, resolvePromise));
294
- }
295
- }, _ClientEncrypted_handleType = async function _ClientEncrypted_handleType(message, reader) {
296
- const body = await reader.deserialize(X);
297
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("received", repr(body));
298
- let sendAck = true;
299
- if (isOfEnum("Updates", body) || isOfEnum("Update", body)) {
300
- drop(this.handlers.updates?.(body, null));
301
- }
302
- else if (is("new_session_created", body)) {
303
- this.serverSalt = body.server_salt;
304
- drop(this.handlers.serverSaltReassigned?.(this.serverSalt));
305
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("new session created with ID", body.unique_id);
306
- }
307
- else if (is("pong", body)) {
308
- const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.msg_id);
309
- if (promise) {
310
- promise.resolve?.(body);
311
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.msg_id);
312
- }
313
- }
314
- else if (is("bad_server_salt", body)) {
315
- sendAck = false;
316
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("server salt reassigned");
317
- this.serverSalt = body.new_server_salt;
318
- drop(this.handlers.serverSaltReassigned?.(this.serverSalt));
319
- const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
320
- const ack = __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").get(body.bad_msg_id);
321
- if (promise) {
322
- drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
323
- }
324
- else if (ack) {
325
- drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
326
- }
327
- else {
328
- for (const promise of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").values()) {
329
- if (promise.container && promise.container == body.bad_msg_id) {
330
- drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
331
- }
332
- }
333
- for (const ack of __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").values()) {
334
- if (ack.container && ack.container == body.bad_msg_id) {
335
- drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
336
- }
337
- }
338
- }
339
- }
340
- else if (is("bad_msg_notification", body)) {
341
- sendAck = false;
342
- let low = false;
343
- switch (body.error_code) {
344
- case 16: // message ID too low
345
- low = true;
346
- /* falls through */
347
- case 17: // message ID too high
348
- __classPrivateFieldSet(this, _ClientEncrypted_timeDifference, Math.abs(toUnixTimestamp(new Date()) - Number(message.msg_id >> 32n)), "f");
349
- if (!low) {
350
- __classPrivateFieldSet(this, _ClientEncrypted_timeDifference, -__classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"), "f");
351
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too high, invalidating session");
352
- await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
353
- __classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
354
- }
355
- else {
356
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too low, resending message");
357
- }
358
- break;
359
- case 48: // bad server salt
360
- // resend
361
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("resending message that caused bad_server_salt");
362
- break;
363
- default:
364
- await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
365
- __classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("invalidating session because of unexpected bad_msg_notification:", body.error_code);
366
- __classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
367
- }
368
- const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
369
- if (promise) {
370
- promise.reject?.(body);
371
- __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.bad_msg_id);
372
- }
373
- }
374
- else if (isOneOf(["msg_detailed_info", "msg_new_detailed_info"], body)) {
375
- sendAck = false;
376
- __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(body.answer_msg_id);
377
- }
378
- if (sendAck) {
379
- __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
380
- }
381
- };