@mtkruto/node 0.69.0 → 0.70.1

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 (565) hide show
  1. package/esm/0_deps.d.ts +3 -1
  2. package/esm/0_deps.d.ts.map +1 -1
  3. package/esm/0_deps.js +3 -1
  4. package/esm/3_types.d.ts +35 -35
  5. package/esm/3_types.d.ts.map +1 -1
  6. package/esm/3_types.js +35 -35
  7. package/esm/_dnt.polyfills.d.ts +20 -13
  8. package/esm/_dnt.polyfills.d.ts.map +1 -1
  9. package/esm/_dnt.polyfills.js +120 -11
  10. package/esm/client/0_abortable_loop.d.ts +27 -0
  11. package/esm/client/0_abortable_loop.d.ts.map +1 -0
  12. package/esm/client/0_abortable_loop.js +49 -0
  13. package/esm/client/0_client_abstract.d.ts +1 -0
  14. package/esm/client/0_client_abstract.d.ts.map +1 -1
  15. package/esm/client/0_client_abstract.js +3 -0
  16. package/esm/client/0_filters.d.ts +9 -3
  17. package/esm/client/0_filters.d.ts.map +1 -1
  18. package/esm/client/0_filters.js +4 -1
  19. package/esm/client/0_params.d.ts +1 -1
  20. package/esm/client/0_password.d.ts +2 -2
  21. package/esm/client/0_password.d.ts.map +1 -1
  22. package/esm/client/0_storage_operations.d.ts +53 -71
  23. package/esm/client/0_storage_operations.d.ts.map +1 -1
  24. package/esm/client/0_storage_operations.js +241 -238
  25. package/esm/client/0_update_processor.d.ts +2 -2
  26. package/esm/client/0_update_processor.d.ts.map +1 -1
  27. package/esm/client/0_utilities.d.ts +2 -2
  28. package/esm/client/0_utilities.d.ts.map +1 -1
  29. package/esm/client/1_types.d.ts +2 -2
  30. package/esm/client/1_types.d.ts.map +1 -1
  31. package/esm/client/2_account_manager.js +5 -5
  32. package/esm/client/2_business_connection_manager.d.ts +1 -1
  33. package/esm/client/2_business_connection_manager.d.ts.map +1 -1
  34. package/esm/client/2_business_connection_manager.js +3 -3
  35. package/esm/client/2_client_encrypted.d.ts +1 -1
  36. package/esm/client/2_client_encrypted.d.ts.map +1 -1
  37. package/esm/client/2_client_encrypted.js +26 -23
  38. package/esm/client/2_file_manager.js +2 -2
  39. package/esm/client/2_network_statistics_manager.d.ts +2 -2
  40. package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
  41. package/esm/client/2_network_statistics_manager.js +30 -4
  42. package/esm/client/2_payment_manager.d.ts +1 -1
  43. package/esm/client/2_payment_manager.d.ts.map +1 -1
  44. package/esm/client/2_payment_manager.js +2 -2
  45. package/esm/client/2_reaction_manager.d.ts +1 -1
  46. package/esm/client/2_reaction_manager.d.ts.map +1 -1
  47. package/esm/client/2_reaction_manager.js +2 -2
  48. package/esm/client/2_translations_manager.d.ts +1 -1
  49. package/esm/client/2_translations_manager.d.ts.map +1 -1
  50. package/esm/client/2_translations_manager.js +15 -11
  51. package/esm/client/2_update_manager.d.ts +4 -2
  52. package/esm/client/2_update_manager.d.ts.map +1 -1
  53. package/esm/client/2_update_manager.js +62 -80
  54. package/esm/client/3_message_manager.d.ts +2 -2
  55. package/esm/client/3_message_manager.d.ts.map +1 -1
  56. package/esm/client/3_message_manager.js +5 -5
  57. package/esm/client/3_video_chat_manager.d.ts +1 -1
  58. package/esm/client/3_video_chat_manager.d.ts.map +1 -1
  59. package/esm/client/4_callback_query_manager.d.ts +1 -1
  60. package/esm/client/4_callback_query_manager.d.ts.map +1 -1
  61. package/esm/client/4_callback_query_manager.js +1 -1
  62. package/esm/client/4_chat_list_manager.d.ts +2 -3
  63. package/esm/client/4_chat_list_manager.d.ts.map +1 -1
  64. package/esm/client/4_chat_list_manager.js +10 -265
  65. package/esm/client/4_chat_manager.d.ts +2 -2
  66. package/esm/client/4_chat_manager.d.ts.map +1 -1
  67. package/esm/client/4_chat_manager.js +7 -7
  68. package/esm/client/4_gift_manager.js +3 -3
  69. package/esm/client/4_inline_query_manager.d.ts +1 -1
  70. package/esm/client/4_inline_query_manager.d.ts.map +1 -1
  71. package/esm/client/4_inline_query_manager.js +3 -3
  72. package/esm/client/4_link_preview_manager.d.ts +1 -1
  73. package/esm/client/4_link_preview_manager.d.ts.map +1 -1
  74. package/esm/client/4_link_preview_manager.js +3 -3
  75. package/esm/client/4_poll_manager.d.ts +1 -1
  76. package/esm/client/4_poll_manager.d.ts.map +1 -1
  77. package/esm/client/4_poll_manager.js +1 -1
  78. package/esm/client/4_story_manager.d.ts +1 -1
  79. package/esm/client/4_story_manager.d.ts.map +1 -1
  80. package/esm/client/4_story_manager.js +7 -7
  81. package/esm/client/5_client.d.ts +15 -9
  82. package/esm/client/5_client.d.ts.map +1 -1
  83. package/esm/client/5_client.js +420 -382
  84. package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts +12 -0
  85. package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts.map +1 -0
  86. package/esm/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.js +69 -0
  87. package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts +112 -0
  88. package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts.map +1 -0
  89. package/esm/deps/jsr.io/@std/cache/0.2.0/lru_cache.js +140 -0
  90. package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts +111 -0
  91. package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts.map +1 -0
  92. package/esm/deps/jsr.io/@std/cache/0.2.0/memoize.js +82 -0
  93. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +39 -0
  94. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  95. package/esm/deps/jsr.io/@std/encoding/1.0.7/hex.js +109 -0
  96. package/esm/session/1_session.d.ts +1 -0
  97. package/esm/session/1_session.d.ts.map +1 -1
  98. package/esm/session/1_session.js +3 -0
  99. package/esm/session/2_session_encrypted.d.ts +2 -2
  100. package/esm/session/2_session_encrypted.d.ts.map +1 -1
  101. package/esm/session/2_session_encrypted.js +198 -135
  102. package/esm/storage/0_storage.d.ts +1 -0
  103. package/esm/storage/0_storage.d.ts.map +1 -1
  104. package/esm/storage/2_storage_indexed_db.d.ts +1 -0
  105. package/esm/storage/2_storage_indexed_db.d.ts.map +1 -1
  106. package/esm/storage/2_storage_indexed_db.js +3 -0
  107. package/esm/storage/2_storage_local_storage.node.d.ts +1 -0
  108. package/esm/storage/2_storage_local_storage.node.d.ts.map +1 -1
  109. package/esm/storage/2_storage_local_storage.node.js +3 -0
  110. package/esm/storage/2_storage_memory.d.ts +1 -0
  111. package/esm/storage/2_storage_memory.d.ts.map +1 -1
  112. package/esm/storage/2_storage_memory.js +3 -0
  113. package/esm/storage/2_storage_session_storage.d.ts +1 -0
  114. package/esm/storage/2_storage_session_storage.d.ts.map +1 -1
  115. package/esm/storage/2_storage_session_storage.js +3 -0
  116. package/esm/tl/0_utilities.d.ts +1 -0
  117. package/esm/tl/0_utilities.d.ts.map +1 -1
  118. package/esm/tl/0_utilities.js +20 -1
  119. package/esm/tl/1_telegram_api.d.ts +810 -254
  120. package/esm/tl/1_telegram_api.d.ts.map +1 -1
  121. package/esm/tl/1_telegram_api.js +912 -213
  122. package/esm/tl/1_tl_reader.d.ts +2 -2
  123. package/esm/tl/1_tl_reader.d.ts.map +1 -1
  124. package/esm/tl/1_tl_writer.d.ts +2 -2
  125. package/esm/tl/1_tl_writer.d.ts.map +1 -1
  126. package/esm/tl/2_mtproto.d.ts +1 -1
  127. package/esm/tl/2_mtproto.d.ts.map +1 -1
  128. package/esm/tl/2_telegram.d.ts +1 -1
  129. package/esm/tl/2_telegram.d.ts.map +1 -1
  130. package/esm/types/0_file_source.d.ts +1 -1
  131. package/esm/types/0_file_source.d.ts.map +1 -1
  132. package/esm/types/1_chat_p.d.ts +10 -0
  133. package/esm/types/1_chat_p.d.ts.map +1 -1
  134. package/esm/types/1_chat_p.js +4 -0
  135. package/esm/types/2_chat.d.ts +2 -5
  136. package/esm/types/2_chat.d.ts.map +1 -1
  137. package/esm/types/2_chat.js +10 -15
  138. package/esm/types/{0_message_entity.d.ts → 2_message_entity.d.ts} +3 -3
  139. package/esm/types/{0_message_entity.d.ts.map → 2_message_entity.d.ts.map} +1 -1
  140. package/esm/types/{0_message_entity.js → 2_message_entity.js} +7 -7
  141. package/esm/types/2_message_reaction_count.d.ts +2 -3
  142. package/esm/types/2_message_reaction_count.d.ts.map +1 -1
  143. package/esm/types/2_message_reaction_count.js +4 -6
  144. package/esm/types/2_poll_answer.d.ts +2 -3
  145. package/esm/types/2_poll_answer.d.ts.map +1 -1
  146. package/esm/types/2_poll_answer.js +4 -5
  147. package/esm/types/2_story_interactive_area.d.ts +2 -2
  148. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  149. package/esm/types/2_story_interactive_area.js +2 -2
  150. package/esm/types/{1_story_privacy.d.ts → 2_story_privacy.d.ts} +3 -3
  151. package/esm/types/{1_story_privacy.d.ts.map → 2_story_privacy.d.ts.map} +1 -1
  152. package/esm/types/{1_story_privacy.js → 2_story_privacy.js} +10 -10
  153. package/{script/types/1_user.d.ts → esm/types/2_user.d.ts} +5 -1
  154. package/esm/types/2_user.d.ts.map +1 -0
  155. package/esm/types/{1_user.js → 2_user.js} +24 -0
  156. package/esm/types/{2_business_connection.d.ts → 3_business_connection.d.ts} +4 -4
  157. package/esm/types/3_business_connection.d.ts.map +1 -0
  158. package/esm/types/{2_business_connection.js → 3_business_connection.js} +10 -3
  159. package/{script/types/2_chat_member.d.ts → esm/types/3_chat_member.d.ts} +6 -4
  160. package/esm/types/{2_chat_member.d.ts.map → 3_chat_member.d.ts.map} +1 -1
  161. package/esm/types/{2_chat_member.js → 3_chat_member.js} +5 -5
  162. package/esm/types/{2_chat_settings.d.ts → 3_chat_settings.d.ts} +2 -2
  163. package/{script/types/2_chat_settings.d.ts.map → esm/types/3_chat_settings.d.ts.map} +1 -1
  164. package/esm/types/{2_chat_settings.js → 3_chat_settings.js} +1 -1
  165. package/esm/types/{2_chosen_inline_result.d.ts → 3_chosen_inline_result.d.ts} +4 -4
  166. package/esm/types/3_chosen_inline_result.d.ts.map +1 -0
  167. package/esm/types/{2_chosen_inline_result.js → 3_chosen_inline_result.js} +3 -3
  168. package/esm/types/{2_forward_header.d.ts → 3_forward_header.d.ts} +4 -5
  169. package/esm/types/3_forward_header.d.ts.map +1 -0
  170. package/esm/types/{2_forward_header.js → 3_forward_header.js} +11 -12
  171. package/{script/types/2_game.d.ts → esm/types/3_game.d.ts} +2 -2
  172. package/esm/types/3_game.d.ts.map +1 -0
  173. package/esm/types/{2_gift_upgraded_component.d.ts → 3_gift_upgraded_component.d.ts} +2 -2
  174. package/esm/types/{2_gift_upgraded_component.d.ts.map → 3_gift_upgraded_component.d.ts.map} +1 -1
  175. package/esm/types/{2_gift_upgraded_component.js → 3_gift_upgraded_component.js} +1 -1
  176. package/esm/types/{2_inline_query.d.ts → 3_inline_query.d.ts} +4 -4
  177. package/esm/types/3_inline_query.d.ts.map +1 -0
  178. package/esm/types/{2_inline_query.js → 3_inline_query.js} +5 -5
  179. package/{script/types/1_input_media.d.ts → esm/types/3_input_media.d.ts} +2 -2
  180. package/esm/types/{1_input_media.d.ts.map → 3_input_media.d.ts.map} +1 -1
  181. package/{script/types/2_invite_link.d.ts → esm/types/3_invite_link.d.ts} +4 -4
  182. package/{script/types/2_invite_link.d.ts.map → esm/types/3_invite_link.d.ts.map} +1 -1
  183. package/esm/types/{2_invite_link.js → 3_invite_link.js} +5 -5
  184. package/{script/types/2_message_reactions.d.ts → esm/types/3_message_reactions.d.ts} +5 -6
  185. package/esm/types/3_message_reactions.d.ts.map +1 -0
  186. package/esm/types/{2_message_reactions.js → 3_message_reactions.js} +10 -12
  187. package/esm/types/{1_poll_option.d.ts → 3_poll_option.d.ts} +2 -2
  188. package/esm/types/{1_poll_option.d.ts.map → 3_poll_option.d.ts.map} +1 -1
  189. package/esm/types/{1_poll_option.js → 3_poll_option.js} +1 -1
  190. package/esm/types/{2_pre_checkout_query.d.ts → 3_pre_checkout_query.d.ts} +4 -4
  191. package/esm/types/3_pre_checkout_query.d.ts.map +1 -0
  192. package/esm/types/{2_pre_checkout_query.js → 3_pre_checkout_query.js} +5 -5
  193. package/{script/types/1_reply_quote.d.ts → esm/types/3_reply_quote.d.ts} +2 -2
  194. package/esm/types/{1_reply_quote.d.ts.map → 3_reply_quote.d.ts.map} +1 -1
  195. package/esm/types/{1_reply_quote.js → 3_reply_quote.js} +1 -1
  196. package/esm/types/3_story.d.ts +4 -5
  197. package/esm/types/3_story.d.ts.map +1 -1
  198. package/esm/types/3_story.js +6 -7
  199. package/esm/types/{3_chat_member_updated.d.ts → 4_chat_member_updated.d.ts} +6 -7
  200. package/esm/types/4_chat_member_updated.d.ts.map +1 -0
  201. package/esm/types/{3_chat_member_updated.js → 4_chat_member_updated.js} +13 -14
  202. package/esm/types/{3_gift.d.ts → 4_gift.d.ts} +6 -6
  203. package/esm/types/{3_gift.d.ts.map → 4_gift.d.ts.map} +1 -1
  204. package/esm/types/{3_gift.js → 4_gift.js} +7 -7
  205. package/esm/types/{3_join_request.d.ts → 4_join_request.d.ts} +6 -7
  206. package/esm/types/4_join_request.d.ts.map +1 -0
  207. package/esm/types/{3_join_request.js → 4_join_request.js} +17 -18
  208. package/esm/types/{2_poll.d.ts → 4_poll.d.ts} +3 -3
  209. package/esm/types/{2_poll.d.ts.map → 4_poll.d.ts.map} +1 -1
  210. package/esm/types/{2_poll.js → 4_poll.js} +2 -2
  211. package/{script/types/2_reply_to.d.ts → esm/types/4_reply_to.d.ts} +2 -2
  212. package/esm/types/{2_reply_to.d.ts.map → 4_reply_to.d.ts.map} +1 -1
  213. package/esm/types/{4_claimed_gift.d.ts → 5_claimed_gift.d.ts} +5 -6
  214. package/esm/types/5_claimed_gift.d.ts.map +1 -0
  215. package/esm/types/{4_claimed_gift.js → 5_claimed_gift.js} +4 -4
  216. package/esm/types/{4_link_preview.d.ts → 5_link_preview.d.ts} +4 -4
  217. package/{script/types/4_link_preview.d.ts.map → esm/types/5_link_preview.d.ts.map} +1 -1
  218. package/esm/types/{4_link_preview.js → 5_link_preview.js} +3 -3
  219. package/esm/types/{5_claimed_gifts.d.ts → 6_claimed_gifts.d.ts} +4 -4
  220. package/esm/types/6_claimed_gifts.d.ts.map +1 -0
  221. package/esm/types/{5_claimed_gifts.js → 6_claimed_gifts.js} +4 -4
  222. package/esm/types/{5_message.d.ts → 6_message.d.ts} +10 -11
  223. package/esm/types/6_message.d.ts.map +1 -0
  224. package/esm/types/{5_message.js → 6_message.js} +41 -66
  225. package/{script/types/5_message_content.d.ts → esm/types/6_message_content.d.ts} +3 -3
  226. package/esm/types/{5_message_content.d.ts.map → 6_message_content.d.ts.map} +1 -1
  227. package/{script/types/6_callback_query.d.ts → esm/types/7_callback_query.d.ts} +5 -5
  228. package/esm/types/{6_callback_query.d.ts.map → 7_callback_query.d.ts.map} +1 -1
  229. package/esm/types/{6_callback_query.js → 7_callback_query.js} +5 -5
  230. package/{script/types/6_chat_list_item.d.ts → esm/types/7_chat_list_item.d.ts} +6 -7
  231. package/esm/types/7_chat_list_item.d.ts.map +1 -0
  232. package/esm/types/{6_chat_list_item.js → 7_chat_list_item.js} +11 -11
  233. package/{script/types/6_inline_query_result.d.ts → esm/types/7_inline_query_result.d.ts} +3 -3
  234. package/esm/types/{6_inline_query_result.d.ts.map → 7_inline_query_result.d.ts.map} +1 -1
  235. package/esm/types/{6_inline_query_result.js → 7_inline_query_result.js} +1 -1
  236. package/esm/types/{6_saved_chat.d.ts → 7_saved_chat.d.ts} +4 -5
  237. package/esm/types/7_saved_chat.d.ts.map +1 -0
  238. package/esm/types/{6_saved_chat.js → 7_saved_chat.js} +4 -4
  239. package/esm/types/{6_topic.d.ts → 7_topic.d.ts} +2 -2
  240. package/esm/types/{6_topic.d.ts.map → 7_topic.d.ts.map} +1 -1
  241. package/esm/types/{7_inline_query_answer.d.ts → 8_inline_query_answer.d.ts} +2 -2
  242. package/esm/types/{7_inline_query_answer.d.ts.map → 8_inline_query_answer.d.ts.map} +1 -1
  243. package/esm/types/{7_inline_query_answer.js → 8_inline_query_answer.js} +1 -1
  244. package/{script/types/7_saved_chats.d.ts → esm/types/8_saved_chats.d.ts} +5 -5
  245. package/esm/types/8_saved_chats.d.ts.map +1 -0
  246. package/esm/types/{7_saved_chats.js → 8_saved_chats.js} +3 -3
  247. package/esm/types/{7_update.d.ts → 8_update.d.ts} +35 -16
  248. package/esm/types/8_update.d.ts.map +1 -0
  249. package/esm/types/_file_id.d.ts +1 -1
  250. package/esm/types/_file_id.d.ts.map +1 -1
  251. package/esm/types/_getters.d.ts +0 -7
  252. package/esm/types/_getters.d.ts.map +1 -1
  253. package/esm/utilities/0_hash.d.ts +2 -2
  254. package/esm/utilities/0_hash.d.ts.map +1 -1
  255. package/esm/utilities/0_misc.d.ts +1 -0
  256. package/esm/utilities/0_misc.d.ts.map +1 -1
  257. package/esm/utilities/0_misc.js +14 -1
  258. package/esm/utilities/0_part_stream.d.ts +1 -1
  259. package/esm/utilities/0_part_stream.d.ts.map +1 -1
  260. package/package.json +1 -1
  261. package/script/0_deps.d.ts +3 -1
  262. package/script/0_deps.d.ts.map +1 -1
  263. package/script/0_deps.js +6 -1
  264. package/script/3_types.d.ts +35 -35
  265. package/script/3_types.d.ts.map +1 -1
  266. package/script/3_types.js +35 -35
  267. package/script/_dnt.polyfills.d.ts +20 -13
  268. package/script/_dnt.polyfills.d.ts.map +1 -1
  269. package/script/_dnt.polyfills.js +120 -11
  270. package/script/client/0_abortable_loop.d.ts +27 -0
  271. package/script/client/0_abortable_loop.d.ts.map +1 -0
  272. package/script/client/0_abortable_loop.js +53 -0
  273. package/script/client/0_client_abstract.d.ts +1 -0
  274. package/script/client/0_client_abstract.d.ts.map +1 -1
  275. package/script/client/0_client_abstract.js +3 -0
  276. package/script/client/0_filters.d.ts +9 -3
  277. package/script/client/0_filters.d.ts.map +1 -1
  278. package/script/client/0_filters.js +4 -1
  279. package/script/client/0_params.d.ts +1 -1
  280. package/script/client/0_password.d.ts +2 -2
  281. package/script/client/0_password.d.ts.map +1 -1
  282. package/script/client/0_storage_operations.d.ts +53 -71
  283. package/script/client/0_storage_operations.d.ts.map +1 -1
  284. package/script/client/0_storage_operations.js +239 -236
  285. package/script/client/0_update_processor.d.ts +2 -2
  286. package/script/client/0_update_processor.d.ts.map +1 -1
  287. package/script/client/0_utilities.d.ts +2 -2
  288. package/script/client/0_utilities.d.ts.map +1 -1
  289. package/script/client/1_types.d.ts +2 -2
  290. package/script/client/1_types.d.ts.map +1 -1
  291. package/script/client/2_account_manager.js +5 -5
  292. package/script/client/2_business_connection_manager.d.ts +1 -1
  293. package/script/client/2_business_connection_manager.d.ts.map +1 -1
  294. package/script/client/2_business_connection_manager.js +3 -3
  295. package/script/client/2_client_encrypted.d.ts +1 -1
  296. package/script/client/2_client_encrypted.d.ts.map +1 -1
  297. package/script/client/2_client_encrypted.js +26 -23
  298. package/script/client/2_file_manager.js +2 -2
  299. package/script/client/2_network_statistics_manager.d.ts +2 -2
  300. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  301. package/script/client/2_network_statistics_manager.js +30 -4
  302. package/script/client/2_payment_manager.d.ts +1 -1
  303. package/script/client/2_payment_manager.d.ts.map +1 -1
  304. package/script/client/2_payment_manager.js +2 -2
  305. package/script/client/2_reaction_manager.d.ts +1 -1
  306. package/script/client/2_reaction_manager.d.ts.map +1 -1
  307. package/script/client/2_reaction_manager.js +2 -2
  308. package/script/client/2_translations_manager.d.ts +1 -1
  309. package/script/client/2_translations_manager.d.ts.map +1 -1
  310. package/script/client/2_translations_manager.js +15 -11
  311. package/script/client/2_update_manager.d.ts +4 -2
  312. package/script/client/2_update_manager.d.ts.map +1 -1
  313. package/script/client/2_update_manager.js +62 -80
  314. package/script/client/3_message_manager.d.ts +2 -2
  315. package/script/client/3_message_manager.d.ts.map +1 -1
  316. package/script/client/3_message_manager.js +5 -5
  317. package/script/client/3_video_chat_manager.d.ts +1 -1
  318. package/script/client/3_video_chat_manager.d.ts.map +1 -1
  319. package/script/client/4_callback_query_manager.d.ts +1 -1
  320. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  321. package/script/client/4_callback_query_manager.js +1 -1
  322. package/script/client/4_chat_list_manager.d.ts +2 -3
  323. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  324. package/script/client/4_chat_list_manager.js +9 -264
  325. package/script/client/4_chat_manager.d.ts +2 -2
  326. package/script/client/4_chat_manager.d.ts.map +1 -1
  327. package/script/client/4_chat_manager.js +7 -7
  328. package/script/client/4_gift_manager.js +3 -3
  329. package/script/client/4_inline_query_manager.d.ts +1 -1
  330. package/script/client/4_inline_query_manager.d.ts.map +1 -1
  331. package/script/client/4_inline_query_manager.js +3 -3
  332. package/script/client/4_link_preview_manager.d.ts +1 -1
  333. package/script/client/4_link_preview_manager.d.ts.map +1 -1
  334. package/script/client/4_link_preview_manager.js +3 -3
  335. package/script/client/4_poll_manager.d.ts +1 -1
  336. package/script/client/4_poll_manager.d.ts.map +1 -1
  337. package/script/client/4_poll_manager.js +1 -1
  338. package/script/client/4_story_manager.d.ts +1 -1
  339. package/script/client/4_story_manager.d.ts.map +1 -1
  340. package/script/client/4_story_manager.js +7 -7
  341. package/script/client/5_client.d.ts +15 -9
  342. package/script/client/5_client.d.ts.map +1 -1
  343. package/script/client/5_client.js +418 -380
  344. package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts +12 -0
  345. package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.d.ts.map +1 -0
  346. package/script/deps/jsr.io/@std/cache/0.2.0/_serialize_arg_list.js +72 -0
  347. package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts +112 -0
  348. package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.d.ts.map +1 -0
  349. package/script/deps/jsr.io/@std/cache/0.2.0/lru_cache.js +144 -0
  350. package/script/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts +111 -0
  351. package/script/deps/jsr.io/@std/cache/0.2.0/memoize.d.ts.map +1 -0
  352. package/script/deps/jsr.io/@std/cache/0.2.0/memoize.js +85 -0
  353. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts +39 -0
  354. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.d.ts.map +1 -0
  355. package/script/deps/jsr.io/@std/encoding/1.0.7/hex.js +113 -0
  356. package/script/session/1_session.d.ts +1 -0
  357. package/script/session/1_session.d.ts.map +1 -1
  358. package/script/session/1_session.js +3 -0
  359. package/script/session/2_session_encrypted.d.ts +2 -2
  360. package/script/session/2_session_encrypted.d.ts.map +1 -1
  361. package/script/session/2_session_encrypted.js +197 -134
  362. package/script/storage/0_storage.d.ts +1 -0
  363. package/script/storage/0_storage.d.ts.map +1 -1
  364. package/script/storage/2_storage_indexed_db.d.ts +1 -0
  365. package/script/storage/2_storage_indexed_db.d.ts.map +1 -1
  366. package/script/storage/2_storage_indexed_db.js +3 -0
  367. package/script/storage/2_storage_local_storage.node.d.ts +1 -0
  368. package/script/storage/2_storage_local_storage.node.d.ts.map +1 -1
  369. package/script/storage/2_storage_local_storage.node.js +3 -0
  370. package/script/storage/2_storage_memory.d.ts +1 -0
  371. package/script/storage/2_storage_memory.d.ts.map +1 -1
  372. package/script/storage/2_storage_memory.js +3 -0
  373. package/script/storage/2_storage_session_storage.d.ts +1 -0
  374. package/script/storage/2_storage_session_storage.d.ts.map +1 -1
  375. package/script/storage/2_storage_session_storage.js +3 -0
  376. package/script/tl/0_utilities.d.ts +1 -0
  377. package/script/tl/0_utilities.d.ts.map +1 -1
  378. package/script/tl/0_utilities.js +20 -0
  379. package/script/tl/1_telegram_api.d.ts +810 -254
  380. package/script/tl/1_telegram_api.d.ts.map +1 -1
  381. package/script/tl/1_telegram_api.js +912 -213
  382. package/script/tl/1_tl_reader.d.ts +2 -2
  383. package/script/tl/1_tl_reader.d.ts.map +1 -1
  384. package/script/tl/1_tl_writer.d.ts +2 -2
  385. package/script/tl/1_tl_writer.d.ts.map +1 -1
  386. package/script/tl/2_mtproto.d.ts +1 -1
  387. package/script/tl/2_mtproto.d.ts.map +1 -1
  388. package/script/tl/2_telegram.d.ts +1 -1
  389. package/script/tl/2_telegram.d.ts.map +1 -1
  390. package/script/types/0_file_source.d.ts +1 -1
  391. package/script/types/0_file_source.d.ts.map +1 -1
  392. package/script/types/1_chat_p.d.ts +10 -0
  393. package/script/types/1_chat_p.d.ts.map +1 -1
  394. package/script/types/1_chat_p.js +5 -0
  395. package/script/types/2_chat.d.ts +2 -5
  396. package/script/types/2_chat.d.ts.map +1 -1
  397. package/script/types/2_chat.js +10 -15
  398. package/script/types/{0_message_entity.d.ts → 2_message_entity.d.ts} +3 -3
  399. package/script/types/{0_message_entity.d.ts.map → 2_message_entity.d.ts.map} +1 -1
  400. package/script/types/{0_message_entity.js → 2_message_entity.js} +7 -7
  401. package/script/types/2_message_reaction_count.d.ts +2 -3
  402. package/script/types/2_message_reaction_count.d.ts.map +1 -1
  403. package/script/types/2_message_reaction_count.js +4 -6
  404. package/script/types/2_poll_answer.d.ts +2 -3
  405. package/script/types/2_poll_answer.d.ts.map +1 -1
  406. package/script/types/2_poll_answer.js +4 -5
  407. package/script/types/2_story_interactive_area.d.ts +2 -2
  408. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  409. package/script/types/2_story_interactive_area.js +2 -2
  410. package/script/types/{1_story_privacy.d.ts → 2_story_privacy.d.ts} +3 -3
  411. package/script/types/{1_story_privacy.d.ts.map → 2_story_privacy.d.ts.map} +1 -1
  412. package/script/types/{1_story_privacy.js → 2_story_privacy.js} +10 -10
  413. package/{esm/types/1_user.d.ts → script/types/2_user.d.ts} +5 -1
  414. package/script/types/2_user.d.ts.map +1 -0
  415. package/script/types/{1_user.js → 2_user.js} +25 -0
  416. package/script/types/{2_business_connection.d.ts → 3_business_connection.d.ts} +4 -4
  417. package/script/types/3_business_connection.d.ts.map +1 -0
  418. package/script/types/{2_business_connection.js → 3_business_connection.js} +10 -3
  419. package/{esm/types/2_chat_member.d.ts → script/types/3_chat_member.d.ts} +6 -4
  420. package/script/types/{2_chat_member.d.ts.map → 3_chat_member.d.ts.map} +1 -1
  421. package/script/types/{2_chat_member.js → 3_chat_member.js} +5 -5
  422. package/script/types/{2_chat_settings.d.ts → 3_chat_settings.d.ts} +2 -2
  423. package/{esm/types/2_chat_settings.d.ts.map → script/types/3_chat_settings.d.ts.map} +1 -1
  424. package/script/types/{2_chat_settings.js → 3_chat_settings.js} +2 -2
  425. package/script/types/{2_chosen_inline_result.d.ts → 3_chosen_inline_result.d.ts} +4 -4
  426. package/script/types/3_chosen_inline_result.d.ts.map +1 -0
  427. package/script/types/{2_chosen_inline_result.js → 3_chosen_inline_result.js} +4 -4
  428. package/script/types/{2_forward_header.d.ts → 3_forward_header.d.ts} +4 -5
  429. package/script/types/3_forward_header.d.ts.map +1 -0
  430. package/script/types/{2_forward_header.js → 3_forward_header.js} +11 -12
  431. package/{esm/types/2_game.d.ts → script/types/3_game.d.ts} +2 -2
  432. package/script/types/3_game.d.ts.map +1 -0
  433. package/script/types/{2_gift_upgraded_component.d.ts → 3_gift_upgraded_component.d.ts} +2 -2
  434. package/script/types/{2_gift_upgraded_component.d.ts.map → 3_gift_upgraded_component.d.ts.map} +1 -1
  435. package/script/types/{2_gift_upgraded_component.js → 3_gift_upgraded_component.js} +2 -2
  436. package/script/types/{2_inline_query.d.ts → 3_inline_query.d.ts} +4 -4
  437. package/script/types/3_inline_query.d.ts.map +1 -0
  438. package/script/types/{2_inline_query.js → 3_inline_query.js} +5 -5
  439. package/{esm/types/1_input_media.d.ts → script/types/3_input_media.d.ts} +2 -2
  440. package/script/types/{1_input_media.d.ts.map → 3_input_media.d.ts.map} +1 -1
  441. package/{esm/types/2_invite_link.d.ts → script/types/3_invite_link.d.ts} +4 -4
  442. package/{esm/types/2_invite_link.d.ts.map → script/types/3_invite_link.d.ts.map} +1 -1
  443. package/script/types/{2_invite_link.js → 3_invite_link.js} +5 -5
  444. package/{esm/types/2_message_reactions.d.ts → script/types/3_message_reactions.d.ts} +5 -6
  445. package/script/types/3_message_reactions.d.ts.map +1 -0
  446. package/script/types/{2_message_reactions.js → 3_message_reactions.js} +10 -12
  447. package/script/types/{1_poll_option.d.ts → 3_poll_option.d.ts} +2 -2
  448. package/script/types/{1_poll_option.d.ts.map → 3_poll_option.d.ts.map} +1 -1
  449. package/script/types/{1_poll_option.js → 3_poll_option.js} +2 -2
  450. package/script/types/{2_pre_checkout_query.d.ts → 3_pre_checkout_query.d.ts} +4 -4
  451. package/script/types/3_pre_checkout_query.d.ts.map +1 -0
  452. package/script/types/{2_pre_checkout_query.js → 3_pre_checkout_query.js} +5 -5
  453. package/{esm/types/1_reply_quote.d.ts → script/types/3_reply_quote.d.ts} +2 -2
  454. package/script/types/{1_reply_quote.d.ts.map → 3_reply_quote.d.ts.map} +1 -1
  455. package/script/types/{1_reply_quote.js → 3_reply_quote.js} +2 -2
  456. package/script/types/3_story.d.ts +4 -5
  457. package/script/types/3_story.d.ts.map +1 -1
  458. package/script/types/3_story.js +8 -9
  459. package/script/types/{3_chat_member_updated.d.ts → 4_chat_member_updated.d.ts} +6 -7
  460. package/script/types/4_chat_member_updated.d.ts.map +1 -0
  461. package/script/types/{3_chat_member_updated.js → 4_chat_member_updated.js} +13 -14
  462. package/script/types/{3_gift.d.ts → 4_gift.d.ts} +6 -6
  463. package/script/types/{3_gift.d.ts.map → 4_gift.d.ts.map} +1 -1
  464. package/script/types/{3_gift.js → 4_gift.js} +9 -9
  465. package/script/types/{3_join_request.d.ts → 4_join_request.d.ts} +6 -7
  466. package/script/types/4_join_request.d.ts.map +1 -0
  467. package/script/types/{3_join_request.js → 4_join_request.js} +17 -18
  468. package/script/types/{2_poll.d.ts → 4_poll.d.ts} +3 -3
  469. package/script/types/{2_poll.d.ts.map → 4_poll.d.ts.map} +1 -1
  470. package/script/types/{2_poll.js → 4_poll.js} +5 -5
  471. package/{esm/types/2_reply_to.d.ts → script/types/4_reply_to.d.ts} +2 -2
  472. package/script/types/{2_reply_to.d.ts.map → 4_reply_to.d.ts.map} +1 -1
  473. package/script/types/{4_claimed_gift.d.ts → 5_claimed_gift.d.ts} +5 -6
  474. package/script/types/5_claimed_gift.d.ts.map +1 -0
  475. package/script/types/{4_claimed_gift.js → 5_claimed_gift.js} +5 -5
  476. package/script/types/{4_link_preview.d.ts → 5_link_preview.d.ts} +4 -4
  477. package/{esm/types/4_link_preview.d.ts.map → script/types/5_link_preview.d.ts.map} +1 -1
  478. package/script/types/{4_link_preview.js → 5_link_preview.js} +3 -3
  479. package/script/types/{5_claimed_gifts.d.ts → 6_claimed_gifts.d.ts} +4 -4
  480. package/script/types/6_claimed_gifts.d.ts.map +1 -0
  481. package/script/types/{5_claimed_gifts.js → 6_claimed_gifts.js} +4 -4
  482. package/script/types/{5_message.d.ts → 6_message.d.ts} +10 -11
  483. package/script/types/6_message.d.ts.map +1 -0
  484. package/script/types/{5_message.js → 6_message.js} +45 -70
  485. package/{esm/types/5_message_content.d.ts → script/types/6_message_content.d.ts} +3 -3
  486. package/script/types/{5_message_content.d.ts.map → 6_message_content.d.ts.map} +1 -1
  487. package/{esm/types/6_callback_query.d.ts → script/types/7_callback_query.d.ts} +5 -5
  488. package/script/types/{6_callback_query.d.ts.map → 7_callback_query.d.ts.map} +1 -1
  489. package/script/types/{6_callback_query.js → 7_callback_query.js} +5 -5
  490. package/{esm/types/6_chat_list_item.d.ts → script/types/7_chat_list_item.d.ts} +6 -7
  491. package/script/types/7_chat_list_item.d.ts.map +1 -0
  492. package/script/types/{6_chat_list_item.js → 7_chat_list_item.js} +11 -11
  493. package/{esm/types/6_inline_query_result.d.ts → script/types/7_inline_query_result.d.ts} +3 -3
  494. package/script/types/{6_inline_query_result.d.ts.map → 7_inline_query_result.d.ts.map} +1 -1
  495. package/script/types/{6_inline_query_result.js → 7_inline_query_result.js} +3 -3
  496. package/script/types/{6_saved_chat.d.ts → 7_saved_chat.d.ts} +4 -5
  497. package/script/types/7_saved_chat.d.ts.map +1 -0
  498. package/script/types/{6_saved_chat.js → 7_saved_chat.js} +4 -4
  499. package/script/types/{6_topic.d.ts → 7_topic.d.ts} +2 -2
  500. package/script/types/{6_topic.d.ts.map → 7_topic.d.ts.map} +1 -1
  501. package/script/types/{7_inline_query_answer.d.ts → 8_inline_query_answer.d.ts} +2 -2
  502. package/script/types/{7_inline_query_answer.d.ts.map → 8_inline_query_answer.d.ts.map} +1 -1
  503. package/script/types/{7_inline_query_answer.js → 8_inline_query_answer.js} +2 -2
  504. package/{esm/types/7_saved_chats.d.ts → script/types/8_saved_chats.d.ts} +5 -5
  505. package/script/types/8_saved_chats.d.ts.map +1 -0
  506. package/script/types/{7_saved_chats.js → 8_saved_chats.js} +3 -3
  507. package/script/types/{7_update.d.ts → 8_update.d.ts} +35 -16
  508. package/script/types/8_update.d.ts.map +1 -0
  509. package/script/types/_file_id.d.ts +1 -1
  510. package/script/types/_file_id.d.ts.map +1 -1
  511. package/script/types/_getters.d.ts +0 -7
  512. package/script/types/_getters.d.ts.map +1 -1
  513. package/script/utilities/0_hash.d.ts +2 -2
  514. package/script/utilities/0_hash.d.ts.map +1 -1
  515. package/script/utilities/0_misc.d.ts +1 -0
  516. package/script/utilities/0_misc.d.ts.map +1 -1
  517. package/script/utilities/0_misc.js +14 -0
  518. package/script/utilities/0_part_stream.d.ts +1 -1
  519. package/script/utilities/0_part_stream.d.ts.map +1 -1
  520. package/esm/types/1_user.d.ts.map +0 -1
  521. package/esm/types/2_business_connection.d.ts.map +0 -1
  522. package/esm/types/2_chosen_inline_result.d.ts.map +0 -1
  523. package/esm/types/2_forward_header.d.ts.map +0 -1
  524. package/esm/types/2_game.d.ts.map +0 -1
  525. package/esm/types/2_inline_query.d.ts.map +0 -1
  526. package/esm/types/2_message_reactions.d.ts.map +0 -1
  527. package/esm/types/2_pre_checkout_query.d.ts.map +0 -1
  528. package/esm/types/3_chat_member_updated.d.ts.map +0 -1
  529. package/esm/types/3_join_request.d.ts.map +0 -1
  530. package/esm/types/4_claimed_gift.d.ts.map +0 -1
  531. package/esm/types/5_claimed_gifts.d.ts.map +0 -1
  532. package/esm/types/5_message.d.ts.map +0 -1
  533. package/esm/types/6_chat_list_item.d.ts.map +0 -1
  534. package/esm/types/6_saved_chat.d.ts.map +0 -1
  535. package/esm/types/7_saved_chats.d.ts.map +0 -1
  536. package/esm/types/7_update.d.ts.map +0 -1
  537. package/script/types/1_user.d.ts.map +0 -1
  538. package/script/types/2_business_connection.d.ts.map +0 -1
  539. package/script/types/2_chosen_inline_result.d.ts.map +0 -1
  540. package/script/types/2_forward_header.d.ts.map +0 -1
  541. package/script/types/2_game.d.ts.map +0 -1
  542. package/script/types/2_inline_query.d.ts.map +0 -1
  543. package/script/types/2_message_reactions.d.ts.map +0 -1
  544. package/script/types/2_pre_checkout_query.d.ts.map +0 -1
  545. package/script/types/3_chat_member_updated.d.ts.map +0 -1
  546. package/script/types/3_join_request.d.ts.map +0 -1
  547. package/script/types/4_claimed_gift.d.ts.map +0 -1
  548. package/script/types/5_claimed_gifts.d.ts.map +0 -1
  549. package/script/types/5_message.d.ts.map +0 -1
  550. package/script/types/6_chat_list_item.d.ts.map +0 -1
  551. package/script/types/6_saved_chat.d.ts.map +0 -1
  552. package/script/types/7_saved_chats.d.ts.map +0 -1
  553. package/script/types/7_update.d.ts.map +0 -1
  554. /package/esm/types/{2_game.js → 3_game.js} +0 -0
  555. /package/esm/types/{1_input_media.js → 3_input_media.js} +0 -0
  556. /package/esm/types/{2_reply_to.js → 4_reply_to.js} +0 -0
  557. /package/esm/types/{5_message_content.js → 6_message_content.js} +0 -0
  558. /package/esm/types/{6_topic.js → 7_topic.js} +0 -0
  559. /package/esm/types/{7_update.js → 8_update.js} +0 -0
  560. /package/script/types/{2_game.js → 3_game.js} +0 -0
  561. /package/script/types/{1_input_media.js → 3_input_media.js} +0 -0
  562. /package/script/types/{2_reply_to.js → 4_reply_to.js} +0 -0
  563. /package/script/types/{5_message_content.js → 6_message_content.js} +0 -0
  564. /package/script/types/{6_topic.js → 7_topic.js} +0 -0
  565. /package/script/types/{7_update.js → 8_update.js} +0 -0
@@ -17,26 +17,21 @@
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 { unreachable } from "../0_deps.js";
20
+ import { MINUTE } from "../0_deps.js";
21
+ import { LruCache, unreachable } from "../0_deps.js";
21
22
  import { InputError } from "../0_errors.js";
22
- import { base64DecodeUrlSafe, base64EncodeUrlSafe, bigIntFromBuffer, rleDecode, rleEncode, sha1, ZERO_CHANNEL_ID } from "../1_utilities.js";
23
+ import { base64DecodeUrlSafe, base64EncodeUrlSafe, bigIntFromBuffer, getLogger, rleDecode, rleEncode, sha1, ZERO_CHANNEL_ID } from "../1_utilities.js";
24
+ import { awaitablePooledMap } from "../1_utilities.js";
25
+ import { fromString, toString } from "../2_storage.js";
23
26
  import { Api, TLReader, TLWriter, X } from "../2_tl.js";
24
- // key parts
27
+ import { constructChatP } from "../3_types.js";
25
28
  export const K = {
26
- connection: {
27
- P: (string) => `connection.${string}`,
28
- apiId: () => [K.connection.P("apiId")],
29
- },
30
29
  session: {
31
30
  P: (string) => `session.${string}`,
32
31
  serverSalt: () => [K.session.P("serverSalt")],
33
32
  },
34
33
  auth: {
35
34
  P: (string) => `auth.${string}`,
36
- dc: () => [K.auth.P("dc")],
37
- key: () => [K.auth.P("key")],
38
- accountId: () => [K.auth.P("accountId")],
39
- accountType: () => [K.auth.P("accountType")],
40
35
  isPremium: () => [K.auth.P("isPremium")],
41
36
  },
42
37
  updates: {
@@ -45,14 +40,9 @@ export const K = {
45
40
  all: () => [K.updates.P("updates")],
46
41
  updates: (boxId) => [...K.updates.all(), boxId],
47
42
  update: (boxId, id) => [...K.updates.updates(boxId), id],
48
- channelPts: (channelId) => [K.updates.P("channelPts"), channelId],
49
43
  },
50
44
  cache: {
51
45
  P: (string) => `cache.${string}`,
52
- usernames: () => [K.cache.P("username")],
53
- username: (v) => [...K.cache.usernames(), v],
54
- peers: () => [K.cache.P("peer")],
55
- peer: (id) => [...K.cache.peers(), id],
56
46
  stickerSetNames: () => [K.cache.P("stickerSetNames")],
57
47
  stickerSetName: (id, accessHash) => [...K.cache.stickerSetNames(), id, accessHash],
58
48
  files: () => [K.cache.P("files")],
@@ -73,12 +63,6 @@ export const K = {
73
63
  groupCall: (id) => [...K.cache.groupCalls(), id],
74
64
  groupCallAccessHashes: () => [K.cache.P("groupCallAccessHashes")],
75
65
  groupCallAccessHash: (id) => [...K.cache.groupCallAccessHashes(), id],
76
- minPeerReferences: () => [K.cache.P("minPeerReferences")],
77
- minPeerReference: (senderId, chatId) => [...K.cache.minPeerReferences(), senderId, chatId],
78
- minPeerReferenceSender: (senderId) => [...K.cache.minPeerReferences(), senderId],
79
- allTranslations: () => [K.cache.P("translations")],
80
- platformTranslations: (platform) => [...K.cache.allTranslations(), platform],
81
- translations: (platform, language) => [...K.cache.platformTranslations(platform), language],
82
66
  pollResults: () => [K.cache.P("pollResults")],
83
67
  pollResult: (pollId) => [...K.cache.pollResults(), pollId],
84
68
  polls: () => [K.cache.P("polls")],
@@ -95,23 +79,37 @@ export const K = {
95
79
  allMessageRefs: () => [K.messages.P("messageRefs")],
96
80
  messageRef: (messageId) => [...K.messages.allMessageRefs(), messageId],
97
81
  },
98
- chatlists: {
99
- P: (string) => `chatlists.${string}`,
100
- hasAllChats: (listId) => [K.chatlists.P("hasAllChats"), listId],
101
- chats: (listId) => [K.chatlists.P("chats"), listId],
102
- chat: (listId, chatId) => [...K.chatlists.chats(listId), chatId],
103
- pinnedChats: (listId) => [K.chatlists.P("pinnedChats"), listId],
104
- },
105
82
  };
106
83
  export class StorageOperations {
107
84
  #storage;
108
85
  #supportsFiles;
109
86
  #mustSerialize;
110
- #authKeyId = null;
87
+ #L;
88
+ #maps = new Array();
89
+ #values = new Array();
90
+ auth;
91
+ channelPts;
92
+ peers;
93
+ usernames;
94
+ translations;
111
95
  constructor(storage) {
112
96
  this.#storage = storage;
113
97
  this.#supportsFiles = storage.supportsFiles;
114
98
  this.#mustSerialize = storage.mustSerialize;
99
+ this.#L = getLogger("StorageOperations");
100
+ this.auth = this.#addValue(new StorageAuth(storage));
101
+ this.channelPts = this.#addMap(new StorageMap(storage, "channelPts"));
102
+ this.peers = this.#addMap(new StorageMap(storage, "peers"));
103
+ this.usernames = this.#addMap(new StorageMap(storage, "usernames"));
104
+ this.translations = this.#addMap(new StorageMap(storage, "translations"));
105
+ }
106
+ #addMap(map) {
107
+ this.#maps.push(map);
108
+ return map;
109
+ }
110
+ #addValue(value) {
111
+ this.#values.push(value);
112
+ return value;
115
113
  }
116
114
  get provider() {
117
115
  return this.#storage;
@@ -121,7 +119,7 @@ export class StorageOperations {
121
119
  }
122
120
  async initialize() {
123
121
  await this.#storage.initialize();
124
- await this.getAccountType();
122
+ await this.auth.get();
125
123
  }
126
124
  set(...args) {
127
125
  return this.#storage.set(...args);
@@ -132,49 +130,20 @@ export class StorageOperations {
132
130
  get(...args) {
133
131
  return this.#storage.get(...args);
134
132
  }
135
- getMany(...args) {
136
- return this.#storage.getMany(...args);
137
- }
138
- async setDc(dc) {
139
- await this.#storage.set(K.auth.dc(), dc);
140
- }
141
- getDc() {
142
- return this.#storage.get(K.auth.dc());
143
- }
144
- async #resetAuthKeyId(authKey) {
145
- if (authKey !== null) {
146
- this.#authKeyId = bigIntFromBuffer((await sha1(authKey)).subarray(-8), true, false);
147
- }
148
- else {
149
- this.#authKeyId = null;
150
- }
151
- }
152
- async getAuthKey() {
153
- const authKey = await this.#storage.get(K.auth.key());
154
- await this.#resetAuthKeyId(authKey);
155
- return authKey;
156
- }
157
- async setAuthKey(authKey) {
158
- await this.#storage.set(K.auth.key(), authKey);
159
- await this.#resetAuthKeyId(authKey);
160
- }
161
- get authKeyId() {
162
- return this.#authKeyId;
163
- }
164
133
  async exportAuthString(apiId_) {
165
134
  if (typeof apiId_ === "number") {
166
- await this.setApiId(apiId_);
135
+ await this.auth.update((v) => v.apiId = apiId_);
167
136
  }
168
- const [dc, authKey, apiId, accountId, accountType] = await Promise.all([this.getDc(), this.getAuthKey(), this.getApiId(), this.getAccountId(), this.getAccountType()]);
169
- if (dc === null || authKey === null || apiId === null || accountId === null || accountType === null) {
137
+ const auth = this.auth.mustGet();
138
+ if (auth.dc === null || auth.authKey === null || auth.apiId === 0 || auth.userId === 0) {
170
139
  throw new Error("Not authorized");
171
140
  }
172
141
  const writer = new TLWriter();
173
- writer.writeString(dc);
174
- writer.writeBytes(authKey);
175
- writer.writeInt32(apiId);
176
- writer.write(new Uint8Array([accountType === "bot" ? 1 : 0]));
177
- writer.writeInt64(BigInt(accountId));
142
+ writer.writeString(auth.dc);
143
+ writer.writeBytes(auth.authKey);
144
+ writer.writeInt32(auth.apiId);
145
+ writer.write(new Uint8Array([auth.isBot ? 1 : 0]));
146
+ writer.writeInt64(BigInt(auth.userId));
178
147
  const data = rleEncode(writer.buffer);
179
148
  return base64EncodeUrlSafe(data);
180
149
  }
@@ -184,54 +153,56 @@ export class StorageOperations {
184
153
  const dc = reader.readString();
185
154
  const authKey = reader.readBytes();
186
155
  const apiId = reader.readInt32();
187
- const isBot = reader.read(1)[0];
188
- const accountId = Number(reader.readInt64());
189
- await this.setAccountId(accountId);
190
- await this.setAccountType(isBot ? "bot" : "user");
191
- await this.setApiId(apiId);
192
- await this.setDc(dc);
193
- await this.setAuthKey(authKey);
194
- }
195
- async getChannelAccessHash(id) {
196
- const channel = await this.getEntity(id);
197
- if (channel) {
198
- if (!(Api.is("channel", channel)) && !Api.is("channelForbidden", channel)) {
199
- unreachable();
200
- }
201
- if (Api.is("channel", channel) && channel.min) {
202
- return null;
203
- }
204
- return typeof channel.access_hash === "bigint" ? channel.access_hash : null;
156
+ const isBot = !!reader.read(1)[0];
157
+ const userId = Number(reader.readInt64());
158
+ await this.auth.set({
159
+ apiId,
160
+ authKey,
161
+ dc,
162
+ isBot,
163
+ userId,
164
+ });
165
+ }
166
+ #lastCommit = null;
167
+ async commit(force = false) {
168
+ if (this.#storage.isMemory) {
169
+ return;
205
170
  }
206
- else {
207
- return null;
171
+ const pending = this.#values.filter((v) => v.isUpdatePending).length + this.#maps.filter((v) => v.pendingUpdateCount > 0).length;
172
+ if (pending <= 0) {
173
+ this.#L.debug("nothing to commit");
174
+ return;
208
175
  }
209
- }
210
- async getUserAccessHash(id) {
211
- const user = await this.getEntity(id);
212
- if (user) {
213
- if (!Api.is("user", user)) {
214
- unreachable();
215
- }
216
- if (user.min) {
217
- return null;
218
- }
219
- return typeof user.access_hash === "bigint" ? user.access_hash : null;
176
+ let commit = false;
177
+ if (force) {
178
+ this.#L.debug("committing because force = true");
179
+ commit = true;
220
180
  }
221
181
  else {
222
- return null;
182
+ if (!commit && pending >= 1_000) {
183
+ this.#L.debug("committing because pending writes >= threshold");
184
+ commit = true;
185
+ }
186
+ else if (this.#lastCommit === null) {
187
+ this.#L.debug("committing because there is no last commit");
188
+ commit = true;
189
+ }
190
+ else if (Date.now() - this.#lastCommit.getTime() >= 5 * MINUTE) {
191
+ this.#L.debug("committing because last commit is older than threshold");
192
+ commit = true;
193
+ }
194
+ else {
195
+ this.#L.debug("not committing");
196
+ }
223
197
  }
224
- }
225
- async updateUsernames(id, usernames) {
226
- for (let username of usernames) {
227
- username = username.toLowerCase();
228
- await this.#storage.set(K.cache.username(username), [id, new Date()]);
198
+ if (commit) {
199
+ const values = this.#values.filter((v) => v.isUpdatePending).map((v) => v.commit());
200
+ const maps = this.#maps.filter((v) => v.pendingUpdateCount > 0).map((v) => v.commit());
201
+ await Promise.all(values.concat(maps));
202
+ this.#L.debug("committed", values.length, "value(s) and", maps.length, "map(s)");
203
+ this.#lastCommit = new Date();
229
204
  }
230
205
  }
231
- async getUsername(username) {
232
- username = username.toLowerCase();
233
- return await this.#storage.get(K.cache.username(username));
234
- }
235
206
  async setTlObject(key, value) {
236
207
  if (value === null) {
237
208
  await this.#storage.set(key, null);
@@ -283,33 +254,12 @@ export class StorageOperations {
283
254
  async getMessage(chatId, messageId) {
284
255
  return await this.getTlObject(K.messages.message(chatId, messageId));
285
256
  }
286
- async getLastMessage(chatId) {
287
- for await (const [_, buffer] of await this.#storage.getMany({ prefix: K.messages.messages(chatId) }, { limit: 1, reverse: true })) {
288
- return await this.getTlObject(buffer);
289
- }
290
- return null;
291
- }
292
- async setChannelPts(channelId, pts) {
293
- await this.#storage.set(K.updates.channelPts(channelId), pts);
294
- }
295
- getChannelPts(channelId) {
296
- return this.#storage.get(K.updates.channelPts(channelId));
297
- }
298
- async setEntity(entity) {
299
- await this.#storage.set(K.cache.peer(Api.peerToChatId(entity)), [this.#mustSerialize ? rleEncode(Api.serializeObject(entity)) : entity, new Date()]);
300
- }
301
- async getEntity(key) {
302
- const peer_ = await this.#storage.get(K.cache.peer(key));
303
- if (peer_ !== null) {
304
- const [obj_] = peer_;
305
- return await this.getTlObject(obj_);
306
- }
307
- else {
308
- return null;
309
- }
257
+ setPeer(peer_) {
258
+ const chatP = constructChatP(peer_);
259
+ this.setPeer2(chatP, "access_hash" in peer_ ? peer_.access_hash ?? 0n : 0n);
310
260
  }
311
- async setAccountId(accountId) {
312
- await this.#storage.set(K.auth.accountId(), accountId);
261
+ setPeer2(chatP, accessHash) {
262
+ this.peers.set([chatP.id], [chatP, accessHash]);
313
263
  }
314
264
  #accountId = null;
315
265
  async getAccountId() {
@@ -317,28 +267,9 @@ export class StorageOperations {
317
267
  return this.#accountId;
318
268
  }
319
269
  else {
320
- return (this.#accountId = await this.#storage.get(K.auth.accountId()));
321
- }
322
- }
323
- async setAccountType(type) {
324
- await this.#storage.set(K.auth.accountType(), type);
325
- await this.getAccountType();
326
- }
327
- #accountType = null;
328
- async getAccountType() {
329
- if (this.#accountType !== null) {
330
- return this.#accountType;
331
- }
332
- else {
333
- return this.#accountType = await this.#storage.get(K.auth.accountType());
270
+ return this.#accountId = (await this.auth.get())?.userId ?? null;
334
271
  }
335
272
  }
336
- get accountType() {
337
- if (this.#accountType === null) {
338
- unreachable();
339
- }
340
- return this.#accountType;
341
- }
342
273
  async setIsPremium(isPremium) {
343
274
  await this.#storage.set(K.auth.isPremium(), isPremium);
344
275
  }
@@ -357,39 +288,6 @@ export class StorageOperations {
357
288
  getServerSalt() {
358
289
  return this.#storage.get(K.session.serverSalt());
359
290
  }
360
- async setChat(listId, chatId, pinned, topMessageId, topMessageDate) {
361
- await this.#storage.set(K.chatlists.chat(listId, chatId), [pinned, topMessageId, topMessageDate]);
362
- }
363
- async getChats(listId) {
364
- const chats = new Array();
365
- for await (const [key, value] of await this.#storage.getMany({ prefix: K.chatlists.chats(listId) })) {
366
- if (key.length !== 3 || typeof key[2] !== "number") {
367
- continue;
368
- }
369
- chats.push({ chatId: key[2], pinned: value[0], topMessageId: value[1], topMessageDate: value[2] });
370
- }
371
- return chats;
372
- }
373
- async removeChats(listId) {
374
- for await (const [key] of await this.#storage.getMany({ prefix: K.chatlists.chats(listId) })) {
375
- await this.#storage.set(key, null);
376
- }
377
- await this.setHasAllChats(listId, false);
378
- await this.setPinnedChats(listId, null);
379
- }
380
- async setHasAllChats(listId, hasAllChats) {
381
- await this.#storage.set(K.chatlists.hasAllChats(listId), hasAllChats);
382
- }
383
- async hasAllChats(listId) {
384
- const v = await this.#storage.get(K.chatlists.hasAllChats(listId));
385
- return v === true;
386
- }
387
- async setPinnedChats(listId, chatIds) {
388
- await this.#storage.set(K.chatlists.pinnedChats(listId), chatIds);
389
- }
390
- async getPinnedChats(listId) {
391
- return await this.#storage.get(K.chatlists.pinnedChats(listId));
392
- }
393
291
  async getHistory(chatId, offsetId, limit) {
394
292
  if (offsetId === 0) {
395
293
  offsetId = Infinity;
@@ -531,15 +429,38 @@ export class StorageOperations {
531
429
  return null;
532
430
  }
533
431
  assertUser(source) {
534
- if (this.accountType !== "user") {
432
+ if (this.auth.mustGet().isBot) {
535
433
  throw new InputError(`${source}: not user a client`);
536
434
  }
537
435
  }
538
436
  assertBot(source) {
539
- if (this.accountType !== "bot") {
437
+ if (!this.auth.mustGet().isBot) {
540
438
  throw new InputError(`${source}: not a bot client`);
541
439
  }
542
440
  }
441
+ get isBot() {
442
+ return this.auth.mustGet().isBot;
443
+ }
444
+ async getChannelAccessHash(id) {
445
+ const peer = await this.peers.get([id]);
446
+ if (peer?.[0].type === "channel" || peer?.[0].type === "supergroup") {
447
+ return peer[1];
448
+ }
449
+ else {
450
+ // TODO: get min peer reference
451
+ return null;
452
+ }
453
+ }
454
+ async getUserAccessHash(id) {
455
+ const peer = await this.peers.get([id]);
456
+ if (peer?.[0].type === "private") {
457
+ return peer[1];
458
+ }
459
+ else {
460
+ // TODO: get min peer reference
461
+ return null;
462
+ }
463
+ }
543
464
  async deleteFiles() {
544
465
  if (!this.#supportsFiles) {
545
466
  return;
@@ -586,21 +507,9 @@ export class StorageOperations {
586
507
  await this.#storage.set(key, null);
587
508
  }
588
509
  }
589
- async deletePeers() {
590
- for await (const [key] of await this.#storage.getMany({ prefix: K.cache.peers() })) {
591
- await this.#storage.set(key, null);
592
- }
593
- }
594
- async deleteUsernames() {
595
- for await (const [key] of await this.#storage.getMany({ prefix: K.cache.usernames() })) {
596
- await this.#storage.set(key, null);
597
- }
598
- }
599
510
  async clear() {
600
511
  await Promise.all([
601
512
  this.deleteMessages(),
602
- this.removeChats(0),
603
- this.removeChats(1),
604
513
  this.deleteUpdates(),
605
514
  this.deleteFiles(),
606
515
  this.deleteCustomEmojiDocuments(),
@@ -610,49 +519,20 @@ export class StorageOperations {
610
519
  this.deleteFullChats(),
611
520
  this.deleteGroupCalls(),
612
521
  this.deleteStickerSetNames(),
613
- this.deletePeers(),
614
- this.deleteUsernames(),
615
- this.deleteTranslations(),
522
+ this.peers.clear(),
523
+ this.usernames.clear(),
524
+ this.translations.clear(),
616
525
  this.deletePollResults(),
617
526
  this.deletePolls(),
618
527
  this.deleteVoiceTranscriptions(),
619
528
  this.deleteVoiceTranscriptionReferences(),
620
529
  ]);
621
530
  }
622
- async setApiId(apiId) {
623
- await this.#storage.set(K.connection.apiId(), apiId);
624
- }
625
- async getApiId() {
626
- return await this.#storage.get(K.connection.apiId());
627
- }
628
531
  async reset() {
629
532
  for await (const [key] of await this.#storage.getMany({ prefix: [] })) {
630
533
  await this.#storage.set(key, null);
631
534
  }
632
535
  }
633
- async setMinPeerReference(chatId, senderId, messageId) {
634
- await this.#storage.set(K.cache.minPeerReference(senderId, chatId), [{ chatId, messageId }, new Date()]);
635
- }
636
- async getLastMinPeerReference(senderId) {
637
- const references = new Array();
638
- for await (const [, reference] of await this.#storage.getMany({ prefix: K.cache.minPeerReferenceSender(senderId) })) {
639
- references.push(reference);
640
- }
641
- return references.sort((a, b) => b[1].getTime() - a[1].getTime())[0]?.[0] ?? null;
642
- }
643
- async deleteTranslations() {
644
- const maybePromises = new Array();
645
- for await (const [key] of await this.#storage.getMany({ prefix: K.cache.allTranslations() })) {
646
- maybePromises.push(this.#storage.set(key, null));
647
- }
648
- await Promise.all(maybePromises);
649
- }
650
- async getTranslations(platform, language) {
651
- return await this.#storage.get(K.cache.translations(platform, language));
652
- }
653
- async setTranslations(platform, language, version, translations) {
654
- await this.#storage.set(K.cache.translations(platform, language), [version, translations, new Date()]);
655
- }
656
536
  async setPollResults(pollId, pollResults) {
657
537
  await this.setTlObject(K.cache.pollResult(pollId), pollResults);
658
538
  }
@@ -680,10 +560,10 @@ export class StorageOperations {
680
560
  await Promise.all(maybePromises);
681
561
  }
682
562
  async setVoiceTranscription(voiceTranscription) {
683
- await this.set(K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
563
+ await this.#storage.set(K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
684
564
  }
685
565
  async getVoiceTranscription(transcriptionId) {
686
- return await this.get(K.cache.voiceTranscription(transcriptionId));
566
+ return await this.#storage.get(K.cache.voiceTranscription(transcriptionId));
687
567
  }
688
568
  async deleteVoiceTranscriptions() {
689
569
  const maybePromises = new Array();
@@ -693,10 +573,10 @@ export class StorageOperations {
693
573
  await Promise.all(maybePromises);
694
574
  }
695
575
  async setVoiceTranscriptionReference(chatId, messageId, messageEditDate, transcriptionId) {
696
- await this.set(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
576
+ await this.#storage.set(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
697
577
  }
698
578
  async getVoiceTranscriptionReference(chatId, messageId, messageEditDate) {
699
- return await this.get(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
579
+ return await this.#storage.get(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
700
580
  }
701
581
  async deleteVoiceTranscriptionReferences() {
702
582
  const maybePromises = new Array();
@@ -706,3 +586,126 @@ export class StorageOperations {
706
586
  await Promise.all(maybePromises);
707
587
  }
708
588
  }
589
+ class StorageMap {
590
+ #storage;
591
+ #path;
592
+ constructor(storage, path) {
593
+ this.#storage = storage;
594
+ this.#path = path;
595
+ }
596
+ #pendingUpdates = new Map();
597
+ #cache = new LruCache(20_000);
598
+ set(key, value) {
599
+ const key_ = toString(key);
600
+ this.#cache.set(key_, value);
601
+ if (!this.#storage.isMemory) {
602
+ this.#pendingUpdates.set(key_, value);
603
+ }
604
+ }
605
+ get pendingUpdateCount() {
606
+ return this.#pendingUpdates.size;
607
+ }
608
+ mustGet(key) {
609
+ const value = this.#cache.get(toString(key));
610
+ if (value === undefined) {
611
+ unreachable();
612
+ }
613
+ else {
614
+ return value;
615
+ }
616
+ }
617
+ async clear() {
618
+ await awaitablePooledMap(10, await this.#storage.getMany({ prefix: [this.#path] }), async ([key]) => await this.#storage.set(key, null));
619
+ }
620
+ async get(key) {
621
+ const key_ = toString(key);
622
+ let value = this.#cache.get(key_);
623
+ if (value === undefined) {
624
+ value = await this.#storage.get([this.#path, ...key]);
625
+ this.#cache.set(key_, value);
626
+ }
627
+ return value;
628
+ }
629
+ async commit() {
630
+ if (this.#storage.isMemory) {
631
+ return;
632
+ }
633
+ await awaitablePooledMap(2, this.#pendingUpdates, async ([key, value]) => await this.#storage.set([this.#path, ...fromString(key)], value));
634
+ this.#pendingUpdates.clear();
635
+ }
636
+ }
637
+ class StorageValue {
638
+ #storage;
639
+ #key;
640
+ constructor(storage, path) {
641
+ this.#storage = storage;
642
+ this.#key = [path];
643
+ }
644
+ #updatePending = false;
645
+ #value;
646
+ set(value) {
647
+ this.#value = value;
648
+ if (!this.#storage.isMemory) {
649
+ this.#updatePending = true;
650
+ }
651
+ }
652
+ get isUpdatePending() {
653
+ return this.#updatePending;
654
+ }
655
+ mustGet() {
656
+ return this.#value === undefined ? unreachable() : this.#value;
657
+ }
658
+ async get() {
659
+ if (this.#value === undefined) {
660
+ this.#value = await this.#storage.get(this.#key);
661
+ }
662
+ return this.#value;
663
+ }
664
+ async commit() {
665
+ if (this.#storage.isMemory || this.#value === undefined) {
666
+ return;
667
+ }
668
+ await this.#storage.set(this.#key, this.#value);
669
+ this.#updatePending = false;
670
+ }
671
+ }
672
+ class StorageAuth extends StorageValue {
673
+ constructor(storage) {
674
+ super(storage, "auth");
675
+ }
676
+ async get() {
677
+ const value = await super.get();
678
+ await this.#resetAuthKeyId(value);
679
+ return value;
680
+ }
681
+ mustGet() {
682
+ return super.mustGet() ?? {
683
+ apiId: 0,
684
+ authKey: new Uint8Array(),
685
+ dc: null,
686
+ isBot: false,
687
+ userId: 0,
688
+ };
689
+ }
690
+ async set(auth) {
691
+ super.set(auth);
692
+ await this.#resetAuthKeyId(auth);
693
+ }
694
+ async update(fn) {
695
+ const auth = this.mustGet();
696
+ fn(auth);
697
+ await this.set(auth);
698
+ }
699
+ #authKeyId = null;
700
+ async #resetAuthKeyId(auth) {
701
+ if (auth?.authKey) {
702
+ this.#authKeyId = bigIntFromBuffer((await sha1(auth.authKey)).subarray(-8), true, false);
703
+ }
704
+ else {
705
+ this.#authKeyId = null;
706
+ }
707
+ }
708
+ get authKeyId() {
709
+ return this.#authKeyId;
710
+ }
711
+ }
@@ -19,8 +19,8 @@
19
19
  */
20
20
  import type { Api } from "../2_tl.js";
21
21
  import type { Update } from "../3_types.js";
22
- export interface UpdateProcessor<U extends Api.Update> {
22
+ export interface UpdateProcessor<U extends Api.Update, P extends boolean = false> {
23
23
  canHandleUpdate(update: Api.Update): update is U;
24
- handleUpdate(update: U): Promise<Update | null>;
24
+ handleUpdate(update: U): P extends false ? Update | null : Promise<Update | null>;
25
25
  }
26
26
  //# sourceMappingURL=0_update_processor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"0_update_processor.d.ts","sourceRoot":"","sources":["../../src/client/0_update_processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM;IACnD,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC;IACjD,YAAY,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACjD"}
1
+ {"version":3,"file":"0_update_processor.d.ts","sourceRoot":"","sources":["../../src/client/0_update_processor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE,CAAC,SAAS,OAAO,GAAG,KAAK;IAC9E,eAAe,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC;IACjD,YAAY,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACnF"}