@mtkruto/node 0.62.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (513) 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 +100 -74
  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 +1 -1
  229. package/esm/types/5_callback_query.d.ts.map +1 -1
  230. package/esm/types/5_callback_query.js +7 -8
  231. package/esm/types/5_chat_list_item.d.ts.map +1 -1
  232. package/esm/types/5_chat_list_item.js +5 -5
  233. package/esm/types/5_claimed_gifts.d.ts.map +1 -1
  234. package/esm/types/5_claimed_gifts.js +6 -6
  235. package/esm/types/_file_id.d.ts.map +1 -1
  236. package/esm/types/_file_id.js +3 -3
  237. package/package.json +1 -1
  238. package/script/2_tl.d.ts +6 -6
  239. package/script/2_tl.d.ts.map +1 -1
  240. package/script/2_tl.js +11 -11
  241. package/script/3_errors.d.ts +1 -2
  242. package/script/3_errors.d.ts.map +1 -1
  243. package/script/3_errors.js +2 -1
  244. package/script/4_constants.d.ts +0 -1
  245. package/script/4_constants.d.ts.map +1 -1
  246. package/script/4_constants.js +1 -2
  247. package/script/4_errors.d.ts +2 -2
  248. package/script/4_errors.d.ts.map +1 -1
  249. package/script/4_session.d.ts +24 -0
  250. package/script/4_session.d.ts.map +1 -0
  251. package/script/4_session.js +39 -0
  252. package/script/5_client.d.ts +1 -1
  253. package/script/5_client.js +1 -1
  254. package/script/client/0_client_abstract.d.ts +28 -26
  255. package/script/client/0_client_abstract.d.ts.map +1 -1
  256. package/script/client/0_client_abstract.js +18 -113
  257. package/script/client/0_params.d.ts +5 -0
  258. package/script/client/0_params.d.ts.map +1 -1
  259. package/script/client/0_password.d.ts.map +1 -1
  260. package/script/client/0_password.js +1 -1
  261. package/script/client/0_storage_operations.d.ts +4 -4
  262. package/script/client/0_storage_operations.d.ts.map +1 -1
  263. package/script/client/0_storage_operations.js +13 -13
  264. package/script/client/0_update_processor.d.ts +19 -0
  265. package/script/client/0_update_processor.d.ts.map +1 -1
  266. package/script/client/0_update_processor.js +19 -0
  267. package/script/client/0_utilities.d.ts +6 -2
  268. package/script/client/0_utilities.d.ts.map +1 -1
  269. package/script/client/0_utilities.js +22 -24
  270. package/script/client/1_client_plain.d.ts +9 -6
  271. package/script/client/1_client_plain.d.ts.map +1 -1
  272. package/script/client/1_client_plain.js +25 -40
  273. package/script/client/1_types.d.ts +4 -23
  274. package/script/client/1_types.d.ts.map +1 -1
  275. package/script/client/2_account_manager.js +9 -9
  276. package/script/client/2_business_connection_manager.d.ts.map +1 -1
  277. package/script/client/2_business_connection_manager.js +3 -3
  278. package/script/client/2_client_encrypted.d.ts +58 -0
  279. package/script/client/2_client_encrypted.d.ts.map +1 -0
  280. package/script/client/2_client_encrypted.js +269 -0
  281. package/script/client/2_file_manager.d.ts.map +1 -1
  282. package/script/client/2_file_manager.js +52 -72
  283. package/script/client/2_network_statistics_manager.d.ts +1 -1
  284. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  285. package/script/client/2_network_statistics_manager.js +3 -3
  286. package/script/client/2_payment_manager.d.ts.map +1 -1
  287. package/script/client/2_payment_manager.js +2 -2
  288. package/script/client/2_reaction_manager.d.ts.map +1 -1
  289. package/script/client/2_reaction_manager.js +9 -9
  290. package/script/client/2_translations_manager.d.ts +19 -0
  291. package/script/client/2_translations_manager.d.ts.map +1 -1
  292. package/script/client/2_translations_manager.js +23 -4
  293. package/script/client/2_update_manager.d.ts +4 -4
  294. package/script/client/2_update_manager.d.ts.map +1 -1
  295. package/script/client/2_update_manager.js +68 -78
  296. package/script/client/3_client_encrypted_pool.d.ts +30 -0
  297. package/script/client/3_client_encrypted_pool.d.ts.map +1 -0
  298. package/script/client/3_client_encrypted_pool.js +74 -0
  299. package/script/client/3_message_manager.d.ts.map +1 -1
  300. package/script/client/3_message_manager.js +99 -73
  301. package/script/client/3_video_chat_manager.d.ts.map +1 -1
  302. package/script/client/3_video_chat_manager.js +14 -19
  303. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  304. package/script/client/4_callback_query_manager.js +1 -1
  305. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  306. package/script/client/4_chat_list_manager.js +32 -32
  307. package/script/client/4_chat_manager.d.ts.map +1 -1
  308. package/script/client/4_chat_manager.js +24 -24
  309. package/script/client/4_gift_manager.js +1 -1
  310. package/script/client/4_inline_query_manager.d.ts.map +1 -1
  311. package/script/client/4_inline_query_manager.js +3 -3
  312. package/script/client/4_poll_manager.d.ts.map +1 -1
  313. package/script/client/4_poll_manager.js +4 -4
  314. package/script/client/4_story_manager.d.ts.map +1 -1
  315. package/script/client/4_story_manager.js +9 -9
  316. package/script/client/5_client.d.ts +3 -9
  317. package/script/client/5_client.d.ts.map +1 -1
  318. package/script/client/5_client.js +284 -300
  319. package/script/connection/0_connection.d.ts +5 -4
  320. package/script/connection/0_connection.d.ts.map +1 -1
  321. package/script/connection/1_connection_web_socket.js +2 -2
  322. package/script/mod.d.ts +1 -1
  323. package/script/mod.d.ts.map +1 -1
  324. package/script/mod.js +1 -2
  325. package/script/session/0_session_error.d.ts +24 -0
  326. package/script/session/0_session_error.d.ts.map +1 -0
  327. package/script/session/0_session_error.js +29 -0
  328. package/script/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  329. package/script/session/0_session_state.d.ts.map +1 -0
  330. package/script/session/0_session_state.js +81 -0
  331. package/script/session/1_session.d.ts +31 -0
  332. package/script/session/1_session.d.ts.map +1 -0
  333. package/script/session/1_session.js +176 -0
  334. package/script/session/2_session_encrypted.d.ts +40 -0
  335. package/script/session/2_session_encrypted.d.ts.map +1 -0
  336. package/script/session/2_session_encrypted.js +420 -0
  337. package/script/session/2_session_plain.d.ts +25 -0
  338. package/script/session/2_session_plain.d.ts.map +1 -0
  339. package/script/session/2_session_plain.js +60 -0
  340. package/script/tl/0_tl_error.d.ts +22 -0
  341. package/script/tl/0_tl_error.d.ts.map +1 -0
  342. package/script/tl/0_tl_error.js +25 -0
  343. package/script/tl/0_types.d.ts +25 -0
  344. package/script/tl/0_types.d.ts.map +1 -0
  345. package/script/tl/0_types.js +21 -0
  346. package/script/tl/0_utilities.d.ts +32 -0
  347. package/script/tl/0_utilities.d.ts.map +1 -0
  348. package/script/tl/0_utilities.js +59 -0
  349. package/script/tl/0_utilities_test.d.ts.map +1 -0
  350. package/script/tl/1_mtproto_api.d.ts +371 -0
  351. package/script/tl/1_mtproto_api.d.ts.map +1 -0
  352. package/script/tl/1_mtproto_api.js +419 -0
  353. package/script/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  354. package/script/tl/1_telegram_api.d.ts.map +1 -0
  355. package/script/tl/{0_api.js → 1_telegram_api.js} +4947 -11134
  356. package/{esm/tl/0_tl_raw_reader.d.ts → script/tl/1_tl_reader.d.ts} +5 -2
  357. package/script/tl/1_tl_reader.d.ts.map +1 -0
  358. package/script/tl/1_tl_reader.js +218 -0
  359. package/script/tl/1_tl_reader_test.d.ts.map +1 -0
  360. package/script/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  361. package/script/tl/1_tl_writer.d.ts.map +1 -0
  362. package/script/tl/{2_tl_writer.js → 1_tl_writer.js} +102 -45
  363. package/script/tl/1_tl_writer_test.d.ts.map +1 -0
  364. package/script/tl/1_utilities.d.ts +9 -24
  365. package/script/tl/1_utilities.d.ts.map +1 -1
  366. package/script/tl/1_utilities.js +19 -72
  367. package/script/tl/2_message.d.ts +2 -2
  368. package/script/tl/2_message.d.ts.map +1 -1
  369. package/script/tl/2_message.js +7 -7
  370. package/script/tl/2_mtproto.d.ts +33 -0
  371. package/script/tl/2_mtproto.d.ts.map +1 -0
  372. package/script/tl/2_mtproto.js +78 -0
  373. package/{esm/tl/2_utilities.d.ts → script/tl/2_telegram.d.ts} +16 -2
  374. package/script/tl/2_telegram.d.ts.map +1 -0
  375. package/script/tl/2_telegram.js +167 -0
  376. package/script/transport/0_transport.d.ts +1 -1
  377. package/script/transport/0_transport.d.ts.map +1 -1
  378. package/script/types/0_chat_photo.d.ts.map +1 -1
  379. package/script/types/0_chat_photo.js +1 -1
  380. package/script/types/0_giveaway_parameters.d.ts.map +1 -1
  381. package/script/types/0_giveaway_parameters.js +2 -2
  382. package/script/types/0_location.d.ts.map +1 -1
  383. package/script/types/0_location.js +4 -4
  384. package/script/types/0_message_entity.d.ts.map +1 -1
  385. package/script/types/0_message_entity.js +19 -19
  386. package/script/types/0_reaction.d.ts.map +1 -1
  387. package/script/types/0_reaction.js +3 -3
  388. package/script/types/0_slow_mode_duration.d.ts +19 -0
  389. package/script/types/0_slow_mode_duration.d.ts.map +1 -1
  390. package/script/types/0_slow_mode_duration.js +19 -0
  391. package/script/types/0_thumbnail.d.ts.map +1 -1
  392. package/script/types/0_thumbnail.js +2 -2
  393. package/script/types/0_translation.d.ts +19 -0
  394. package/script/types/0_translation.d.ts.map +1 -1
  395. package/script/types/0_translation.js +21 -2
  396. package/script/types/0_video_chat.d.ts.map +1 -1
  397. package/script/types/0_video_chat.js +1 -1
  398. package/script/types/1_animation.d.ts.map +1 -1
  399. package/script/types/1_animation.js +1 -1
  400. package/script/types/1_audio.d.ts.map +1 -1
  401. package/script/types/1_audio.js +1 -1
  402. package/script/types/1_bot_command_scope.d.ts.map +1 -1
  403. package/script/types/1_bot_command_scope.js +1 -1
  404. package/script/types/1_chat_p.d.ts.map +1 -1
  405. package/script/types/1_chat_p.js +5 -5
  406. package/script/types/1_document.d.ts.map +1 -1
  407. package/script/types/1_document.js +1 -1
  408. package/script/types/1_keyboard_button.d.ts.map +1 -1
  409. package/script/types/1_keyboard_button.js +9 -9
  410. package/script/types/1_message_reaction.d.ts.map +1 -1
  411. package/script/types/1_message_reaction.js +5 -5
  412. package/script/types/1_photo.d.ts.map +1 -1
  413. package/script/types/1_photo.js +2 -2
  414. package/script/types/1_sticker.d.ts.map +1 -1
  415. package/script/types/1_sticker.js +7 -7
  416. package/script/types/1_story_privacy.d.ts.map +1 -1
  417. package/script/types/1_story_privacy.js +6 -6
  418. package/script/types/1_user.d.ts.map +1 -1
  419. package/script/types/1_user.js +1 -1
  420. package/script/types/1_venue.d.ts.map +1 -1
  421. package/script/types/1_venue.js +1 -1
  422. package/script/types/1_video.d.ts.map +1 -1
  423. package/script/types/1_video.js +1 -1
  424. package/script/types/1_video_note.d.ts.map +1 -1
  425. package/script/types/1_video_note.js +1 -1
  426. package/script/types/2_chat.d.ts.map +1 -1
  427. package/script/types/2_chat.js +7 -7
  428. package/script/types/2_chat_member.d.ts.map +1 -1
  429. package/script/types/2_chat_member.js +9 -9
  430. package/script/types/2_chat_settings.d.ts +19 -0
  431. package/script/types/2_chat_settings.d.ts.map +1 -1
  432. package/script/types/2_chat_settings.js +20 -1
  433. package/script/types/2_chosen_inline_result.d.ts.map +1 -1
  434. package/script/types/2_chosen_inline_result.js +3 -3
  435. package/script/types/2_game.d.ts.map +1 -1
  436. package/script/types/2_game.js +3 -3
  437. package/script/types/2_gift_upgraded_component.d.ts.map +1 -1
  438. package/script/types/2_gift_upgraded_component.js +2 -2
  439. package/script/types/2_inactive_chat.d.ts.map +1 -1
  440. package/script/types/2_inactive_chat.js +1 -1
  441. package/script/types/2_inline_keyboard_button.d.ts.map +1 -1
  442. package/script/types/2_inline_keyboard_button.js +9 -9
  443. package/script/types/2_inline_query.d.ts.map +1 -1
  444. package/script/types/2_inline_query.js +6 -6
  445. package/script/types/2_message_reactions.d.ts.map +1 -1
  446. package/script/types/2_message_reactions.js +1 -1
  447. package/script/types/2_story_content.d.ts.map +1 -1
  448. package/script/types/2_story_content.js +5 -5
  449. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  450. package/script/types/2_story_interactive_area.js +8 -8
  451. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  452. package/script/types/3_chat_member_updated.js +1 -1
  453. package/script/types/3_gift.d.ts.map +1 -1
  454. package/script/types/3_gift.js +2 -2
  455. package/script/types/3_join_request.d.ts.map +1 -1
  456. package/script/types/3_join_request.js +1 -1
  457. package/script/types/3_reply_markup.d.ts.map +1 -1
  458. package/script/types/3_reply_markup.js +4 -4
  459. package/script/types/4_claimed_gift.d.ts.map +1 -1
  460. package/script/types/4_claimed_gift.js +1 -1
  461. package/script/types/4_inline_query_result.d.ts.map +1 -1
  462. package/script/types/4_inline_query_result.js +13 -13
  463. package/script/types/4_message.d.ts.map +1 -1
  464. package/script/types/4_message.js +56 -56
  465. package/script/types/5_callback_query.d.ts +1 -1
  466. package/script/types/5_callback_query.d.ts.map +1 -1
  467. package/script/types/5_callback_query.js +6 -7
  468. package/script/types/5_chat_list_item.d.ts.map +1 -1
  469. package/script/types/5_chat_list_item.js +4 -4
  470. package/script/types/5_claimed_gifts.d.ts.map +1 -1
  471. package/script/types/5_claimed_gifts.js +5 -5
  472. package/script/types/_file_id.d.ts.map +1 -1
  473. package/script/types/_file_id.js +2 -2
  474. package/esm/client/0_message.d.ts +0 -29
  475. package/esm/client/0_message.d.ts.map +0 -1
  476. package/esm/client/0_message.js +0 -83
  477. package/esm/client/1_client_encrypted.d.ts +0 -52
  478. package/esm/client/1_client_encrypted.d.ts.map +0 -1
  479. package/esm/client/1_client_encrypted.js +0 -381
  480. package/esm/tl/0_api.d.ts.map +0 -1
  481. package/esm/tl/0_tl_raw_reader.d.ts.map +0 -1
  482. package/esm/tl/0_tl_raw_reader.js +0 -97
  483. package/esm/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  484. package/esm/tl/0_tl_raw_writer.d.ts.map +0 -1
  485. package/esm/tl/0_tl_raw_writer.js +0 -86
  486. package/esm/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  487. package/esm/tl/1_utilities_test.d.ts.map +0 -1
  488. package/esm/tl/2_tl_reader.d.ts.map +0 -1
  489. package/esm/tl/2_tl_reader_test.d.ts.map +0 -1
  490. package/esm/tl/2_tl_writer.d.ts.map +0 -1
  491. package/esm/tl/2_tl_writer_test.d.ts.map +0 -1
  492. package/esm/tl/2_utilities.d.ts.map +0 -1
  493. package/script/client/0_message.d.ts +0 -29
  494. package/script/client/0_message.d.ts.map +0 -1
  495. package/script/client/0_message.js +0 -90
  496. package/script/client/1_client_encrypted.d.ts +0 -52
  497. package/script/client/1_client_encrypted.d.ts.map +0 -1
  498. package/script/client/1_client_encrypted.js +0 -385
  499. package/script/tl/0_api.d.ts.map +0 -1
  500. package/script/tl/0_tl_raw_reader.d.ts.map +0 -1
  501. package/script/tl/0_tl_raw_reader.js +0 -102
  502. package/script/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  503. package/script/tl/0_tl_raw_writer.d.ts.map +0 -1
  504. package/script/tl/0_tl_raw_writer.js +0 -90
  505. package/script/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  506. package/script/tl/1_utilities_test.d.ts.map +0 -1
  507. package/script/tl/2_tl_reader.d.ts.map +0 -1
  508. package/script/tl/2_tl_reader.js +0 -150
  509. package/script/tl/2_tl_reader_test.d.ts.map +0 -1
  510. package/script/tl/2_tl_writer.d.ts.map +0 -1
  511. package/script/tl/2_tl_writer_test.d.ts.map +0 -1
  512. package/script/tl/2_utilities.d.ts.map +0 -1
  513. 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"}
@@ -84,11 +84,11 @@ class ConnectionWebSocket {
84
84
  }
85
85
  async open() {
86
86
  if (__classPrivateFieldGet(this, _ConnectionWebSocket_isConnecting, "f")) {
87
- throw new Error("Already connecting");
87
+ throw new _0_errors_js_1.ConnectionError("Already connecting");
88
88
  }
89
89
  __classPrivateFieldSet(this, _ConnectionWebSocket_isConnecting, true, "f");
90
90
  if (this.connected) {
91
- throw new Error("Already connected");
91
+ throw new _0_errors_js_1.ConnectionError("Already connected");
92
92
  }
93
93
  try {
94
94
  __classPrivateFieldSet(this, _ConnectionWebSocket_webSocket, await __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_initWs).call(this), "f");
package/script/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
@@ -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/script/mod.js CHANGED
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.errors = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LAYER = exports.LANG_PACK = exports.LANG_CODE = exports.INITIAL_DC = exports.DEVICE_MODEL = exports.APP_VERSION = exports.checkPassword = exports.setLogVerbosity = exports.setLoggingProvider = exports.setLogFilter = exports.getRandomId = exports.getColorName = exports.getColorFromPeerId = void 0;
29
+ exports.errors = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LANG_PACK = exports.LANG_CODE = exports.INITIAL_DC = exports.DEVICE_MODEL = exports.APP_VERSION = exports.checkPassword = exports.setLogVerbosity = exports.setLoggingProvider = exports.setLogFilter = exports.getRandomId = exports.getColorName = exports.getColorFromPeerId = void 0;
30
30
  /**
31
31
  * MTKruto - Cross-runtime JavaScript library for building Telegram clients
32
32
  * Copyright (C) 2023-2025 Roj <https://roj.im/>
@@ -67,7 +67,6 @@ Object.defineProperty(exports, "DEVICE_MODEL", { enumerable: true, get: function
67
67
  Object.defineProperty(exports, "INITIAL_DC", { enumerable: true, get: function () { return _4_constants_js_1.INITIAL_DC; } });
68
68
  Object.defineProperty(exports, "LANG_CODE", { enumerable: true, get: function () { return _4_constants_js_1.LANG_CODE; } });
69
69
  Object.defineProperty(exports, "LANG_PACK", { enumerable: true, get: function () { return _4_constants_js_1.LANG_PACK; } });
70
- Object.defineProperty(exports, "LAYER", { enumerable: true, get: function () { return _4_constants_js_1.LAYER; } });
71
70
  Object.defineProperty(exports, "SYSTEM_LANG_CODE", { enumerable: true, get: function () { return _4_constants_js_1.SYSTEM_LANG_CODE; } });
72
71
  Object.defineProperty(exports, "SYSTEM_VERSION", { enumerable: true, get: function () { return _4_constants_js_1.SYSTEM_VERSION; } });
73
72
  exports.errors = __importStar(require("./4_errors.js"));
@@ -0,0 +1,24 @@
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 { MtkrutoError } from "../0_errors.js";
21
+ export declare class SessionError extends MtkrutoError {
22
+ constructor(message: string);
23
+ }
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"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2025 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.SessionError = void 0;
23
+ const _0_errors_js_1 = require("../0_errors.js");
24
+ class SessionError extends _0_errors_js_1.MtkrutoError {
25
+ constructor(message) {
26
+ super(message);
27
+ }
28
+ }
29
+ exports.SessionError = SessionError;
@@ -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,81 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2025 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
22
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
23
+ 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");
24
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
25
+ };
26
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
27
+ if (kind === "m") throw new TypeError("Private method is not writable");
28
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
29
+ 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");
30
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
31
+ };
32
+ var _SessionState_seqNo, _SessionState_messageId;
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.SessionState = void 0;
35
+ const _1_utilities_js_1 = require("../1_utilities.js");
36
+ class SessionState {
37
+ constructor() {
38
+ Object.defineProperty(this, "timeDifference", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: 0
43
+ });
44
+ Object.defineProperty(this, "serverSalt", {
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true,
48
+ value: 0n
49
+ });
50
+ _SessionState_seqNo.set(this, 0);
51
+ _SessionState_messageId.set(this, 0n);
52
+ }
53
+ nextMessageId() {
54
+ const now = (0, _1_utilities_js_1.toUnixTimestamp)(new Date()) + this.timeDifference;
55
+ const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
56
+ const newMessageId = (BigInt(Math.floor(now)) << 32n) || (BigInt(nanoseconds) << 2n);
57
+ if (__classPrivateFieldGet(this, _SessionState_messageId, "f") >= newMessageId) {
58
+ __classPrivateFieldSet(this, _SessionState_messageId, __classPrivateFieldGet(this, _SessionState_messageId, "f") + 4n, "f");
59
+ }
60
+ else {
61
+ __classPrivateFieldSet(this, _SessionState_messageId, newMessageId, "f");
62
+ }
63
+ return __classPrivateFieldGet(this, _SessionState_messageId, "f");
64
+ }
65
+ nextSeqNo(contentRelated) {
66
+ var _a;
67
+ let seqNo = __classPrivateFieldGet(this, _SessionState_seqNo, "f") * 2;
68
+ if (contentRelated) {
69
+ seqNo++;
70
+ __classPrivateFieldSet(this, _SessionState_seqNo, (_a = __classPrivateFieldGet(this, _SessionState_seqNo, "f"), _a++, _a), "f");
71
+ }
72
+ return seqNo;
73
+ }
74
+ reset() {
75
+ this.serverSalt = 0n;
76
+ __classPrivateFieldSet(this, _SessionState_seqNo, 0, "f");
77
+ __classPrivateFieldSet(this, _SessionState_messageId, 0n, "f");
78
+ }
79
+ }
80
+ exports.SessionState = SessionState;
81
+ _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,176 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
+ 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");
34
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
+ };
36
+ var _Session_instances, _Session_dc, _Session_cdn, _Session_lastConnect, _Session_disconnected, _Session_L, _Session_onConnectionStateChange, _Session_lastState, _Session_stateChangeHandler, _Session_connectMutex;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.Session = void 0;
39
+ /**
40
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
41
+ * Copyright (C) 2023-2025 Roj <https://roj.im/>
42
+ *
43
+ * This file is part of MTKruto.
44
+ *
45
+ * This program is free software: you can redistribute it and/or modify
46
+ * it under the terms of the GNU Lesser General Public License as published by
47
+ * the Free Software Foundation, either version 3 of the License, or
48
+ * (at your option) any later version.
49
+ *
50
+ * This program is distributed in the hope that it will be useful,
51
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
52
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53
+ * GNU Lesser General Public License for more details.
54
+ *
55
+ * You should have received a copy of the GNU Lesser General Public License
56
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
57
+ */
58
+ const dntShim = __importStar(require("../_dnt.shims.js"));
59
+ const _0_deps_js_1 = require("../0_deps.js");
60
+ const _1_utilities_js_1 = require("../1_utilities.js");
61
+ const _3_transport_js_1 = require("../3_transport.js");
62
+ const _0_session_state_js_1 = require("./0_session_state.js");
63
+ // global Session ID counter for logs
64
+ let id = 0;
65
+ // @ts-ignore: lib
66
+ const defaultTransportProvider = typeof dntShim.Deno === "undefined" ? _3_transport_js_1.transportProviderWebSocket : _3_transport_js_1.transportProviderTcp;
67
+ class Session {
68
+ constructor(dc, params) {
69
+ _Session_instances.add(this);
70
+ _Session_dc.set(this, void 0);
71
+ _Session_cdn.set(this, void 0);
72
+ Object.defineProperty(this, "state", {
73
+ enumerable: true,
74
+ configurable: true,
75
+ writable: true,
76
+ value: new _0_session_state_js_1.SessionState()
77
+ });
78
+ Object.defineProperty(this, "transport", {
79
+ enumerable: true,
80
+ configurable: true,
81
+ writable: true,
82
+ value: void 0
83
+ });
84
+ _Session_lastConnect.set(this, void 0);
85
+ _Session_disconnected.set(this, true);
86
+ _Session_L.set(this, void 0);
87
+ _Session_onConnectionStateChange.set(this, void 0);
88
+ _Session_lastState.set(this, void 0);
89
+ _Session_connectMutex.set(this, new _1_utilities_js_1.Mutex());
90
+ __classPrivateFieldSet(this, _Session_dc, dc, "f");
91
+ __classPrivateFieldSet(this, _Session_cdn, params?.cdn ?? false, "f");
92
+ const transportProvider = params?.transportProvider ?? defaultTransportProvider();
93
+ this.transport = transportProvider({ dc: __classPrivateFieldGet(this, _Session_dc, "f"), cdn: __classPrivateFieldGet(this, _Session_cdn, "f") });
94
+ this.transport.connection.stateChangeHandler = (connected) => {
95
+ setTimeout(() => {
96
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Session_instances, "m", _Session_stateChangeHandler).call(this, connected));
97
+ });
98
+ };
99
+ __classPrivateFieldSet(this, _Session_L, (0, _1_utilities_js_1.getLogger)("Session").client(id++), "f");
100
+ }
101
+ set onConnectionStateChange(onConnectionStateChange) {
102
+ __classPrivateFieldSet(this, _Session_onConnectionStateChange, onConnectionStateChange, "f");
103
+ }
104
+ set connectionCallback(connectionCallback) {
105
+ this.transport.connection.callback = connectionCallback;
106
+ }
107
+ get dc() {
108
+ return __classPrivateFieldGet(this, _Session_dc, "f");
109
+ }
110
+ get cdn() {
111
+ return __classPrivateFieldGet(this, _Session_cdn, "f");
112
+ }
113
+ set serverSalt(serverSalt) {
114
+ this.state.serverSalt = serverSalt;
115
+ }
116
+ get connected() {
117
+ return this.transport.connection.connected;
118
+ }
119
+ async connect() {
120
+ const release = await __classPrivateFieldGet(this, _Session_connectMutex, "f").lock();
121
+ try {
122
+ if (this.connected) {
123
+ return;
124
+ }
125
+ await this.transport.connection.open();
126
+ await this.transport.transport.initialize();
127
+ __classPrivateFieldSet(this, _Session_lastConnect, new Date(), "f");
128
+ __classPrivateFieldSet(this, _Session_disconnected, false, "f");
129
+ }
130
+ finally {
131
+ release();
132
+ }
133
+ }
134
+ async waitUntilConnected() {
135
+ (await __classPrivateFieldGet(this, _Session_connectMutex, "f").lock())();
136
+ }
137
+ get disconnected() {
138
+ return __classPrivateFieldGet(this, _Session_disconnected, "f");
139
+ }
140
+ disconnect() {
141
+ __classPrivateFieldSet(this, _Session_disconnected, true, "f");
142
+ if (this.transport.connection.connected) {
143
+ this.transport.connection.close();
144
+ this.transport.transport.deinitialize();
145
+ }
146
+ }
147
+ }
148
+ exports.Session = Session;
149
+ _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) {
150
+ if (__classPrivateFieldGet(this, _Session_lastState, "f") !== connected) {
151
+ setTimeout(() => {
152
+ __classPrivateFieldGet(this, _Session_onConnectionStateChange, "f")?.call(this, connected);
153
+ });
154
+ }
155
+ if (!connected) {
156
+ this.transport.transport.deinitialize();
157
+ }
158
+ if (__classPrivateFieldGet(this, _Session_lastState, "f") === connected) {
159
+ return;
160
+ }
161
+ __classPrivateFieldSet(this, _Session_lastState, connected, "f");
162
+ if (connected || __classPrivateFieldGet(this, _Session_disconnected, "f")) {
163
+ if (__classPrivateFieldGet(this, _Session_disconnected, "f")) {
164
+ __classPrivateFieldGet(this, _Session_L, "f").debug("not reconnecting because explicitly disconnected");
165
+ }
166
+ return;
167
+ }
168
+ if (__classPrivateFieldGet(this, _Session_lastConnect, "f") && Date.now() - __classPrivateFieldGet(this, _Session_lastConnect, "f").getTime() <= 10 * _0_deps_js_1.SECOND) {
169
+ __classPrivateFieldGet(this, _Session_L, "f").debug("reconnecting after a delay");
170
+ await new Promise((r) => setTimeout(r, 3 * _0_deps_js_1.SECOND));
171
+ }
172
+ else {
173
+ __classPrivateFieldGet(this, _Session_L, "f").debug("reconnecting");
174
+ }
175
+ await this.connect();
176
+ };
@@ -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"}