@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
@@ -18,16 +18,17 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { MaybePromise } from "../1_utilities.js";
21
+ export interface ConnectionCallback {
22
+ read(count: number): void;
23
+ write(count: number): void;
24
+ }
21
25
  export interface Connection {
22
26
  get connected(): boolean;
23
27
  stateChangeHandler?: (connected: boolean) => void;
24
28
  open(): MaybePromise<void>;
25
29
  write(p: Uint8Array): MaybePromise<void>;
26
30
  close(): MaybePromise<void>;
27
- callback?: {
28
- read(count: number): void;
29
- write(count: number): void;
30
- };
31
+ callback?: ConnectionCallback;
31
32
  read(p: Uint8Array): MaybePromise<void>;
32
33
  }
33
34
  //# sourceMappingURL=0_connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"0_connection.d.ts","sourceRoot":"","sources":["../../src/connection/0_connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,UAAU;IACzB,IAAI,SAAS,IAAI,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACzC,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACrE,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;CACzC"}
1
+ {"version":3,"file":"0_connection.d.ts","sourceRoot":"","sources":["../../src/connection/0_connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,SAAS,IAAI,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAC3B,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACzC,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;CACzC"}
@@ -58,11 +58,11 @@ export class ConnectionWebSocket {
58
58
  }
59
59
  async open() {
60
60
  if (__classPrivateFieldGet(this, _ConnectionWebSocket_isConnecting, "f")) {
61
- throw new Error("Already connecting");
61
+ throw new ConnectionError("Already connecting");
62
62
  }
63
63
  __classPrivateFieldSet(this, _ConnectionWebSocket_isConnecting, true, "f");
64
64
  if (this.connected) {
65
- throw new Error("Already connected");
65
+ throw new ConnectionError("Already connected");
66
66
  }
67
67
  try {
68
68
  __classPrivateFieldSet(this, _ConnectionWebSocket_webSocket, await __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_initWs).call(this), "f");
package/esm/mod.d.ts CHANGED
@@ -25,7 +25,7 @@ export * from "./2_storage.js";
25
25
  export * from "./3_transport.js";
26
26
  export * from "./2_tl.js";
27
27
  export * from "./3_types.js";
28
- export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
28
+ export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
29
29
  export * as errors from "./4_errors.js";
30
30
  export * from "./5_client.js";
31
31
  //# sourceMappingURL=mod.d.ts.map
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1J,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxI,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC1J,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjI,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,cAAc,eAAe,CAAC"}
package/esm/mod.js CHANGED
@@ -25,6 +25,6 @@ export * from "./2_storage.js";
25
25
  export * from "./3_transport.js";
26
26
  export * from "./2_tl.js";
27
27
  export * from "./3_types.js";
28
- export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
28
+ export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
29
29
  export * as errors from "./4_errors.js";
30
30
  export * from "./5_client.js";
@@ -17,11 +17,8 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- import { TLRawReader } from "./0_tl_raw_reader.js";
21
- import { AnyObject } from "./0_api.js";
22
- export type ReadObject = boolean | number | bigint | string | Uint8Array | AnyObject | Array<ReadObject>;
23
- export declare class TLReader extends TLRawReader {
24
- #private;
25
- deserialize(type: string): Promise<ReadObject>;
20
+ import { MtkrutoError } from "../0_errors.js";
21
+ export declare class SessionError extends MtkrutoError {
22
+ constructor(message: string);
26
23
  }
27
- //# sourceMappingURL=2_tl_reader.d.ts.map
24
+ //# sourceMappingURL=0_session_error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_session_error.d.ts","sourceRoot":"","sources":["../../src/session/0_session_error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,YAAa,SAAQ,YAAY;gBAChC,OAAO,EAAE,MAAM;CAG5B"}
@@ -17,11 +17,9 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- import { TLRawReader } from "./0_tl_raw_reader.js";
21
- import { AnyObject } from "./0_api.js";
22
- export type ReadObject = boolean | number | bigint | string | Uint8Array | AnyObject | Array<ReadObject>;
23
- export declare class TLReader extends TLRawReader {
24
- #private;
25
- deserialize(type: string): Promise<ReadObject>;
20
+ import { MtkrutoError } from "../0_errors.js";
21
+ export class SessionError extends MtkrutoError {
22
+ constructor(message) {
23
+ super(message);
24
+ }
26
25
  }
27
- //# sourceMappingURL=2_tl_reader.d.ts.map
@@ -17,10 +17,12 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- import { AnyObject } from "./0_api.js";
21
- import { TLRawWriter } from "./0_tl_raw_writer.js";
22
- export declare class TLWriter extends TLRawWriter {
20
+ export declare class SessionState {
23
21
  #private;
24
- serialize(value: AnyObject): typeof this;
22
+ timeDifference: number;
23
+ serverSalt: bigint;
24
+ nextMessageId(): bigint;
25
+ nextSeqNo(contentRelated: boolean): number;
26
+ reset(): void;
25
27
  }
26
- //# sourceMappingURL=2_tl_writer.d.ts.map
28
+ //# sourceMappingURL=0_session_state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_session_state.d.ts","sourceRoot":"","sources":["../../src/session/0_session_state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,qBAAa,YAAY;;IACvB,cAAc,SAAK;IACnB,UAAU,SAAM;IAIhB,aAAa,IAAI,MAAM;IAYvB,SAAS,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM;IAS1C,KAAK;CAKN"}
@@ -0,0 +1,77 @@
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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
21
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
22
+ 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");
23
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24
+ };
25
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ 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");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var _SessionState_seqNo, _SessionState_messageId;
32
+ import { toUnixTimestamp } from "../1_utilities.js";
33
+ export class SessionState {
34
+ constructor() {
35
+ Object.defineProperty(this, "timeDifference", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: 0
40
+ });
41
+ Object.defineProperty(this, "serverSalt", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: 0n
46
+ });
47
+ _SessionState_seqNo.set(this, 0);
48
+ _SessionState_messageId.set(this, 0n);
49
+ }
50
+ nextMessageId() {
51
+ const now = toUnixTimestamp(new Date()) + this.timeDifference;
52
+ const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
53
+ const newMessageId = (BigInt(Math.floor(now)) << 32n) || (BigInt(nanoseconds) << 2n);
54
+ if (__classPrivateFieldGet(this, _SessionState_messageId, "f") >= newMessageId) {
55
+ __classPrivateFieldSet(this, _SessionState_messageId, __classPrivateFieldGet(this, _SessionState_messageId, "f") + 4n, "f");
56
+ }
57
+ else {
58
+ __classPrivateFieldSet(this, _SessionState_messageId, newMessageId, "f");
59
+ }
60
+ return __classPrivateFieldGet(this, _SessionState_messageId, "f");
61
+ }
62
+ nextSeqNo(contentRelated) {
63
+ var _a;
64
+ let seqNo = __classPrivateFieldGet(this, _SessionState_seqNo, "f") * 2;
65
+ if (contentRelated) {
66
+ seqNo++;
67
+ __classPrivateFieldSet(this, _SessionState_seqNo, (_a = __classPrivateFieldGet(this, _SessionState_seqNo, "f"), _a++, _a), "f");
68
+ }
69
+ return seqNo;
70
+ }
71
+ reset() {
72
+ this.serverSalt = 0n;
73
+ __classPrivateFieldSet(this, _SessionState_seqNo, 0, "f");
74
+ __classPrivateFieldSet(this, _SessionState_messageId, 0n, "f");
75
+ }
76
+ }
77
+ _SessionState_seqNo = new WeakMap(), _SessionState_messageId = new WeakMap();
@@ -0,0 +1,31 @@
1
+ import { Connection, ConnectionCallback } from "../2_connection.js";
2
+ import { DC, TransportProvider } from "../3_transport.js";
3
+ import { SessionState } from "./0_session_state.js";
4
+ export interface SessionParams {
5
+ /**
6
+ * The transport provider to use. Defaults to `webSocketTransportProvider` with its default options.
7
+ */
8
+ transportProvider?: TransportProvider;
9
+ /**
10
+ * Whether the connection is with a CDN server. Defaults to false.
11
+ */
12
+ cdn?: boolean;
13
+ }
14
+ export declare abstract class Session {
15
+ #private;
16
+ protected state: SessionState;
17
+ protected transport: ReturnType<TransportProvider>;
18
+ constructor(dc: DC, params?: SessionParams);
19
+ set onConnectionStateChange(onConnectionStateChange: Connection["stateChangeHandler"]);
20
+ set connectionCallback(connectionCallback: ConnectionCallback | undefined);
21
+ get dc(): DC;
22
+ get cdn(): boolean;
23
+ set serverSalt(serverSalt: bigint);
24
+ get connected(): boolean;
25
+ connect(): Promise<void>;
26
+ protected waitUntilConnected(): Promise<void>;
27
+ get disconnected(): boolean;
28
+ disconnect(): void;
29
+ abstract send(body: Uint8Array): Promise<bigint>;
30
+ }
31
+ //# sourceMappingURL=1_session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAgCD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,UAAU;IAQV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CACjD"}
@@ -0,0 +1,149 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ 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");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _Session_instances, _Session_dc, _Session_cdn, _Session_lastConnect, _Session_disconnected, _Session_L, _Session_onConnectionStateChange, _Session_lastState, _Session_stateChangeHandler, _Session_connectMutex;
13
+ /**
14
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
15
+ * Copyright (C) 2023-2025 Roj <https://roj.im/>
16
+ *
17
+ * This file is part of MTKruto.
18
+ *
19
+ * This program is free software: you can redistribute it and/or modify
20
+ * it under the terms of the GNU Lesser General Public License as published by
21
+ * the Free Software Foundation, either version 3 of the License, or
22
+ * (at your option) any later version.
23
+ *
24
+ * This program is distributed in the hope that it will be useful,
25
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ * GNU Lesser General Public License for more details.
28
+ *
29
+ * You should have received a copy of the GNU Lesser General Public License
30
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
31
+ */
32
+ import * as dntShim from "../_dnt.shims.js";
33
+ import { SECOND } from "../0_deps.js";
34
+ import { drop, getLogger, Mutex } from "../1_utilities.js";
35
+ import { transportProviderTcp, transportProviderWebSocket } from "../3_transport.js";
36
+ import { SessionState } from "./0_session_state.js";
37
+ // global Session ID counter for logs
38
+ let id = 0;
39
+ // @ts-ignore: lib
40
+ const defaultTransportProvider = typeof dntShim.Deno === "undefined" ? transportProviderWebSocket : transportProviderTcp;
41
+ export class Session {
42
+ constructor(dc, params) {
43
+ _Session_instances.add(this);
44
+ _Session_dc.set(this, void 0);
45
+ _Session_cdn.set(this, void 0);
46
+ Object.defineProperty(this, "state", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: new SessionState()
51
+ });
52
+ Object.defineProperty(this, "transport", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: void 0
57
+ });
58
+ _Session_lastConnect.set(this, void 0);
59
+ _Session_disconnected.set(this, true);
60
+ _Session_L.set(this, void 0);
61
+ _Session_onConnectionStateChange.set(this, void 0);
62
+ _Session_lastState.set(this, void 0);
63
+ _Session_connectMutex.set(this, new Mutex());
64
+ __classPrivateFieldSet(this, _Session_dc, dc, "f");
65
+ __classPrivateFieldSet(this, _Session_cdn, params?.cdn ?? false, "f");
66
+ const transportProvider = params?.transportProvider ?? defaultTransportProvider();
67
+ this.transport = transportProvider({ dc: __classPrivateFieldGet(this, _Session_dc, "f"), cdn: __classPrivateFieldGet(this, _Session_cdn, "f") });
68
+ this.transport.connection.stateChangeHandler = (connected) => {
69
+ setTimeout(() => {
70
+ drop(__classPrivateFieldGet(this, _Session_instances, "m", _Session_stateChangeHandler).call(this, connected));
71
+ });
72
+ };
73
+ __classPrivateFieldSet(this, _Session_L, getLogger("Session").client(id++), "f");
74
+ }
75
+ set onConnectionStateChange(onConnectionStateChange) {
76
+ __classPrivateFieldSet(this, _Session_onConnectionStateChange, onConnectionStateChange, "f");
77
+ }
78
+ set connectionCallback(connectionCallback) {
79
+ this.transport.connection.callback = connectionCallback;
80
+ }
81
+ get dc() {
82
+ return __classPrivateFieldGet(this, _Session_dc, "f");
83
+ }
84
+ get cdn() {
85
+ return __classPrivateFieldGet(this, _Session_cdn, "f");
86
+ }
87
+ set serverSalt(serverSalt) {
88
+ this.state.serverSalt = serverSalt;
89
+ }
90
+ get connected() {
91
+ return this.transport.connection.connected;
92
+ }
93
+ async connect() {
94
+ const release = await __classPrivateFieldGet(this, _Session_connectMutex, "f").lock();
95
+ try {
96
+ if (this.connected) {
97
+ return;
98
+ }
99
+ await this.transport.connection.open();
100
+ await this.transport.transport.initialize();
101
+ __classPrivateFieldSet(this, _Session_lastConnect, new Date(), "f");
102
+ __classPrivateFieldSet(this, _Session_disconnected, false, "f");
103
+ }
104
+ finally {
105
+ release();
106
+ }
107
+ }
108
+ async waitUntilConnected() {
109
+ (await __classPrivateFieldGet(this, _Session_connectMutex, "f").lock())();
110
+ }
111
+ get disconnected() {
112
+ return __classPrivateFieldGet(this, _Session_disconnected, "f");
113
+ }
114
+ disconnect() {
115
+ __classPrivateFieldSet(this, _Session_disconnected, true, "f");
116
+ if (this.transport.connection.connected) {
117
+ this.transport.connection.close();
118
+ this.transport.transport.deinitialize();
119
+ }
120
+ }
121
+ }
122
+ _Session_dc = new WeakMap(), _Session_cdn = new WeakMap(), _Session_lastConnect = new WeakMap(), _Session_disconnected = new WeakMap(), _Session_L = new WeakMap(), _Session_onConnectionStateChange = new WeakMap(), _Session_lastState = new WeakMap(), _Session_connectMutex = new WeakMap(), _Session_instances = new WeakSet(), _Session_stateChangeHandler = async function _Session_stateChangeHandler(connected) {
123
+ if (__classPrivateFieldGet(this, _Session_lastState, "f") !== connected) {
124
+ setTimeout(() => {
125
+ __classPrivateFieldGet(this, _Session_onConnectionStateChange, "f")?.call(this, connected);
126
+ });
127
+ }
128
+ if (!connected) {
129
+ this.transport.transport.deinitialize();
130
+ }
131
+ if (__classPrivateFieldGet(this, _Session_lastState, "f") === connected) {
132
+ return;
133
+ }
134
+ __classPrivateFieldSet(this, _Session_lastState, connected, "f");
135
+ if (connected || __classPrivateFieldGet(this, _Session_disconnected, "f")) {
136
+ if (__classPrivateFieldGet(this, _Session_disconnected, "f")) {
137
+ __classPrivateFieldGet(this, _Session_L, "f").debug("not reconnecting because explicitly disconnected");
138
+ }
139
+ return;
140
+ }
141
+ if (__classPrivateFieldGet(this, _Session_lastConnect, "f") && Date.now() - __classPrivateFieldGet(this, _Session_lastConnect, "f").getTime() <= 10 * SECOND) {
142
+ __classPrivateFieldGet(this, _Session_L, "f").debug("reconnecting after a delay");
143
+ await new Promise((r) => setTimeout(r, 3 * SECOND));
144
+ }
145
+ else {
146
+ __classPrivateFieldGet(this, _Session_L, "f").debug("reconnecting");
147
+ }
148
+ await this.connect();
149
+ };
@@ -0,0 +1,40 @@
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 { Mtproto } from "../2_tl.js";
21
+ import { DC } from "../3_transport.js";
22
+ import { Session, SessionParams } from "./1_session.js";
23
+ export interface Handlers {
24
+ onUpdate?: (body: Uint8Array) => void;
25
+ onNewServerSalt?: (serverSalt: bigint) => void;
26
+ onMessageFailed?: (id: bigint, reason: unknown) => void;
27
+ onRpcError?: (id: bigint, error: Mtproto.rpc_error) => void;
28
+ onRpcResult?: (id: bigint, result: Uint8Array) => void;
29
+ }
30
+ export declare class SessionEncrypted extends Session implements Session {
31
+ #private;
32
+ handlers: Handlers;
33
+ constructor(dc: DC, params?: SessionParams);
34
+ setAuthKey(key: Uint8Array<ArrayBuffer>): Promise<void>;
35
+ get authKey(): Uint8Array;
36
+ connect(): Promise<void>;
37
+ disconnect(): void;
38
+ send(body: Uint8Array): Promise<bigint>;
39
+ }
40
+ //# sourceMappingURL=2_session_encrypted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAA8C,OAAO,EAAuC,MAAM,YAAY,CAAC;AACtH,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASxD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC;IAC5D,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxD;AAED,qBAAa,gBAAiB,SAAQ,OAAQ,YAAW,OAAO;;IAI9D,QAAQ,EAAE,QAAQ,CAAM;gBAQZ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAMpC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC;IAM7C,IAAI,OAAO,IAAI,UAAU,CAExB;IAEc,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,UAAU,IAAI,IAAI;IAgDrB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CAwU9C"}