@mtkruto/node 0.153.0 → 0.160.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 (207) hide show
  1. package/esm/3_types.d.ts +3 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +3 -0
  4. package/esm/4_constants.d.ts +1 -0
  5. package/esm/4_constants.d.ts.map +1 -1
  6. package/esm/4_constants.js +1 -0
  7. package/esm/client/0_markdown.js +4 -4
  8. package/esm/client/0_params.d.ts +11 -1
  9. package/esm/client/0_params.d.ts.map +1 -1
  10. package/esm/client/1_client_generic.d.ts +100 -3
  11. package/esm/client/1_client_generic.d.ts.map +1 -1
  12. package/esm/client/1_client_plain.d.ts +1 -1
  13. package/esm/client/1_client_plain.d.ts.map +1 -1
  14. package/esm/client/1_client_plain.js +25 -13
  15. package/esm/client/2_client_encrypted.d.ts +6 -3
  16. package/esm/client/2_client_encrypted.d.ts.map +1 -1
  17. package/esm/client/2_client_encrypted.js +166 -49
  18. package/esm/client/2_file_manager.js +1 -1
  19. package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
  20. package/esm/client/2_network_statistics_manager.js +3 -2
  21. package/esm/client/2_payment_manager.js +2 -2
  22. package/esm/client/2_takeout_manager.js +2 -2
  23. package/esm/client/2_update_manager.d.ts.map +1 -1
  24. package/esm/client/2_update_manager.js +16 -11
  25. package/esm/client/3_account_manager.js +3 -3
  26. package/esm/client/3_message_manager.d.ts +11 -0
  27. package/esm/client/3_message_manager.d.ts.map +1 -1
  28. package/esm/client/3_message_manager.js +195 -74
  29. package/esm/client/3_sticker_set_manager.js +3 -3
  30. package/esm/client/3_video_chat_manager.js +1 -1
  31. package/esm/client/4_callback_query_manager.js +2 -2
  32. package/esm/client/4_chat_list_manager.js +3 -3
  33. package/esm/client/4_chat_manager.d.ts +3 -2
  34. package/esm/client/4_chat_manager.d.ts.map +1 -1
  35. package/esm/client/4_chat_manager.js +12 -5
  36. package/esm/client/4_contact_manager.js +1 -1
  37. package/esm/client/4_gift_manager.js +11 -11
  38. package/esm/client/4_inline_query_manager.js +1 -1
  39. package/esm/client/4_story_manager.d.ts +3 -1
  40. package/esm/client/4_story_manager.d.ts.map +1 -1
  41. package/esm/client/4_story_manager.js +17 -3
  42. package/esm/client/6_client.d.ts +102 -3
  43. package/esm/client/6_client.d.ts.map +1 -1
  44. package/esm/client/6_client.js +130 -2
  45. package/esm/client/6_client_dispatcher.d.ts +100 -3
  46. package/esm/client/6_client_dispatcher.d.ts.map +1 -1
  47. package/esm/client/6_client_dispatcher.js +126 -1
  48. package/esm/connection/0_get_tls_header.d.ts.map +1 -1
  49. package/esm/connection/0_get_tls_header.js +19 -0
  50. package/esm/connection/1_connection_web_socket.js +2 -2
  51. package/esm/session/0_session_state.d.ts +1 -0
  52. package/esm/session/0_session_state.d.ts.map +1 -1
  53. package/esm/session/0_session_state.js +8 -4
  54. package/esm/session/1_session.d.ts +1 -0
  55. package/esm/session/1_session.d.ts.map +1 -1
  56. package/esm/session/1_session.js +3 -0
  57. package/esm/session/2_session_encrypted.d.ts +11 -6
  58. package/esm/session/2_session_encrypted.d.ts.map +1 -1
  59. package/esm/session/2_session_encrypted.js +20 -12
  60. package/esm/storage/1_utilities.js +2 -2
  61. package/esm/transport/2_transport_provider_web_socket.js +1 -1
  62. package/esm/types/0_button_style.js +1 -1
  63. package/esm/types/0_chat_member_rights.js +34 -34
  64. package/esm/types/0_chat_photo.js +2 -2
  65. package/esm/types/0_dice.d.ts +1 -1
  66. package/esm/types/0_dice.d.ts.map +1 -1
  67. package/esm/types/0_giveaway_parameters.js +1 -1
  68. package/esm/types/0_live_stream_channel.d.ts +1 -1
  69. package/esm/types/0_live_stream_channel.d.ts.map +1 -1
  70. package/esm/types/0_report_reason.d.ts +53 -0
  71. package/esm/types/0_report_reason.d.ts.map +1 -0
  72. package/esm/types/0_report_reason.js +45 -0
  73. package/esm/types/0_story_report_option.d.ts +26 -0
  74. package/esm/types/0_story_report_option.d.ts.map +1 -0
  75. package/esm/types/0_story_report_option.js +25 -0
  76. package/esm/types/0_video_chat.js +2 -2
  77. package/esm/types/1_inline_keyboard_button.d.ts +2 -2
  78. package/esm/types/1_message_reaction.js +1 -1
  79. package/esm/types/1_sticker.js +1 -1
  80. package/esm/types/1_story_reaction.js +1 -1
  81. package/esm/types/1_story_report_result.d.ts +37 -0
  82. package/esm/types/1_story_report_result.d.ts.map +1 -0
  83. package/esm/types/1_story_report_result.js +36 -0
  84. package/esm/types/2_chat.js +2 -2
  85. package/esm/types/2_chat_member.js +3 -3
  86. package/esm/types/2_message_entity.js +1 -1
  87. package/esm/types/2_story_interactive_area.js +3 -3
  88. package/esm/types/3_chat_settings.js +1 -1
  89. package/esm/types/3_forward_header.js +3 -3
  90. package/esm/types/3_inline_query.js +1 -1
  91. package/esm/types/3_invite_link.js +2 -2
  92. package/esm/types/3_story.js +3 -3
  93. package/esm/types/4_gift.js +1 -1
  94. package/esm/types/5_gift_non_upgraded_information.js +8 -8
  95. package/esm/types/5_gift_upgraded_information.js +5 -5
  96. package/esm/types/6_poll_media.d.ts +1 -1
  97. package/esm/types/6_poll_media.d.ts.map +1 -1
  98. package/esm/types/7_inline_query_result.js +8 -8
  99. package/esm/types/7_poll_option.d.ts +1 -1
  100. package/esm/types/7_poll_option.d.ts.map +1 -1
  101. package/esm/types/8_inline_query_answer.js +1 -1
  102. package/esm/types/9_message.js +3 -3
  103. package/esm/utilities/0_env.js +1 -1
  104. package/package.json +1 -1
  105. package/script/3_types.d.ts +3 -0
  106. package/script/3_types.d.ts.map +1 -1
  107. package/script/3_types.js +3 -0
  108. package/script/4_constants.d.ts +1 -0
  109. package/script/4_constants.d.ts.map +1 -1
  110. package/script/4_constants.js +2 -1
  111. package/script/client/0_markdown.js +4 -4
  112. package/script/client/0_params.d.ts +11 -1
  113. package/script/client/0_params.d.ts.map +1 -1
  114. package/script/client/1_client_generic.d.ts +100 -3
  115. package/script/client/1_client_generic.d.ts.map +1 -1
  116. package/script/client/1_client_plain.d.ts +1 -1
  117. package/script/client/1_client_plain.d.ts.map +1 -1
  118. package/script/client/1_client_plain.js +24 -12
  119. package/script/client/2_client_encrypted.d.ts +6 -3
  120. package/script/client/2_client_encrypted.d.ts.map +1 -1
  121. package/script/client/2_client_encrypted.js +166 -49
  122. package/script/client/2_file_manager.js +1 -1
  123. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  124. package/script/client/2_network_statistics_manager.js +3 -2
  125. package/script/client/2_payment_manager.js +2 -2
  126. package/script/client/2_takeout_manager.js +2 -2
  127. package/script/client/2_update_manager.d.ts.map +1 -1
  128. package/script/client/2_update_manager.js +16 -11
  129. package/script/client/3_account_manager.js +3 -3
  130. package/script/client/3_message_manager.d.ts +11 -0
  131. package/script/client/3_message_manager.d.ts.map +1 -1
  132. package/script/client/3_message_manager.js +194 -73
  133. package/script/client/3_sticker_set_manager.js +3 -3
  134. package/script/client/3_video_chat_manager.js +1 -1
  135. package/script/client/4_callback_query_manager.js +2 -2
  136. package/script/client/4_chat_list_manager.js +3 -3
  137. package/script/client/4_chat_manager.d.ts +3 -2
  138. package/script/client/4_chat_manager.d.ts.map +1 -1
  139. package/script/client/4_chat_manager.js +11 -4
  140. package/script/client/4_contact_manager.js +1 -1
  141. package/script/client/4_gift_manager.js +11 -11
  142. package/script/client/4_inline_query_manager.js +1 -1
  143. package/script/client/4_story_manager.d.ts +3 -1
  144. package/script/client/4_story_manager.d.ts.map +1 -1
  145. package/script/client/4_story_manager.js +15 -1
  146. package/script/client/6_client.d.ts +102 -3
  147. package/script/client/6_client.d.ts.map +1 -1
  148. package/script/client/6_client.js +130 -2
  149. package/script/client/6_client_dispatcher.d.ts +100 -3
  150. package/script/client/6_client_dispatcher.d.ts.map +1 -1
  151. package/script/client/6_client_dispatcher.js +126 -1
  152. package/script/connection/0_get_tls_header.d.ts.map +1 -1
  153. package/script/connection/0_get_tls_header.js +19 -0
  154. package/script/connection/1_connection_web_socket.js +2 -2
  155. package/script/session/0_session_state.d.ts +1 -0
  156. package/script/session/0_session_state.d.ts.map +1 -1
  157. package/script/session/0_session_state.js +8 -4
  158. package/script/session/1_session.d.ts +1 -0
  159. package/script/session/1_session.d.ts.map +1 -1
  160. package/script/session/1_session.js +3 -0
  161. package/script/session/2_session_encrypted.d.ts +11 -6
  162. package/script/session/2_session_encrypted.d.ts.map +1 -1
  163. package/script/session/2_session_encrypted.js +20 -12
  164. package/script/storage/1_utilities.js +2 -2
  165. package/script/transport/2_transport_provider_web_socket.js +1 -1
  166. package/script/types/0_button_style.js +1 -1
  167. package/script/types/0_chat_member_rights.js +34 -34
  168. package/script/types/0_chat_photo.js +2 -2
  169. package/script/types/0_dice.d.ts +1 -1
  170. package/script/types/0_dice.d.ts.map +1 -1
  171. package/script/types/0_giveaway_parameters.js +1 -1
  172. package/script/types/0_live_stream_channel.d.ts +1 -1
  173. package/script/types/0_live_stream_channel.d.ts.map +1 -1
  174. package/script/types/0_report_reason.d.ts +53 -0
  175. package/script/types/0_report_reason.d.ts.map +1 -0
  176. package/script/types/0_report_reason.js +48 -0
  177. package/script/types/0_story_report_option.d.ts +26 -0
  178. package/script/types/0_story_report_option.d.ts.map +1 -0
  179. package/script/types/0_story_report_option.js +28 -0
  180. package/script/types/0_video_chat.js +2 -2
  181. package/script/types/1_inline_keyboard_button.d.ts +2 -2
  182. package/script/types/1_message_reaction.js +1 -1
  183. package/script/types/1_sticker.js +1 -1
  184. package/script/types/1_story_reaction.js +1 -1
  185. package/script/types/1_story_report_result.d.ts +37 -0
  186. package/script/types/1_story_report_result.d.ts.map +1 -0
  187. package/script/types/1_story_report_result.js +39 -0
  188. package/script/types/2_chat.js +2 -2
  189. package/script/types/2_chat_member.js +3 -3
  190. package/script/types/2_message_entity.js +1 -1
  191. package/script/types/2_story_interactive_area.js +3 -3
  192. package/script/types/3_chat_settings.js +1 -1
  193. package/script/types/3_forward_header.js +3 -3
  194. package/script/types/3_inline_query.js +1 -1
  195. package/script/types/3_invite_link.js +2 -2
  196. package/script/types/3_story.js +3 -3
  197. package/script/types/4_gift.js +1 -1
  198. package/script/types/5_gift_non_upgraded_information.js +8 -8
  199. package/script/types/5_gift_upgraded_information.js +5 -5
  200. package/script/types/6_poll_media.d.ts +1 -1
  201. package/script/types/6_poll_media.d.ts.map +1 -1
  202. package/script/types/7_inline_query_result.js +8 -8
  203. package/script/types/7_poll_option.d.ts +1 -1
  204. package/script/types/7_poll_option.d.ts.map +1 -1
  205. package/script/types/8_inline_query_answer.js +1 -1
  206. package/script/types/9_message.js +3 -3
  207. package/script/utilities/0_env.js +1 -1
@@ -34,6 +34,25 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getTlsHeader = getTlsHeader;
37
+ /**
38
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
39
+ * Copyright (C) 2023-2026 Roj <https://roj.im/>
40
+ *
41
+ * This file is part of MTKruto.
42
+ *
43
+ * This program is free software: you can redistribute it and/or modify
44
+ * it under the terms of the GNU Lesser General Public License as published by
45
+ * the Free Software Foundation, either version 3 of the License, or
46
+ * (at your option) any later version.
47
+ *
48
+ * This program is distributed in the hope that it will be useful,
49
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
50
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51
+ * GNU Lesser General Public License for more details.
52
+ *
53
+ * You should have received a copy of the GNU Lesser General Public License
54
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
55
+ */
37
56
  const dntShim = __importStar(require("../_dnt.shims.js"));
38
57
  const _0_deps_js_1 = require("../0_deps.js");
39
58
  const _1_utilities_js_1 = require("../1_utilities.js");
@@ -90,7 +90,7 @@ class ConnectionWebSocket {
90
90
  const unlock = await mutex.lock();
91
91
  const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : (0, _0_deps_js_1.unreachable)())).arrayBuffer());
92
92
  this.#buffer = (0, _0_deps_js_1.concat)([this.#buffer, data]);
93
- if (this.#nextResolve !== null && this.#buffer.length >= this.#nextResolve[0]) {
93
+ if (this.#nextResolve !== null && this.#buffer.byteLength >= this.#nextResolve[0]) {
94
94
  this.#nextResolve[1].resolve();
95
95
  this.#nextResolve = null;
96
96
  }
@@ -132,7 +132,7 @@ class ConnectionWebSocket {
132
132
  const unlock = await this.#rMutex.lock();
133
133
  try {
134
134
  this.#assertConnected();
135
- if (this.#buffer.length < p.byteLength) {
135
+ if (this.#buffer.byteLength < p.byteLength) {
136
136
  await new Promise((resolve, reject) => this.#nextResolve = [p.byteLength, { resolve, reject }]);
137
137
  }
138
138
  const slice = this.#buffer.slice(0, p.byteLength);
@@ -22,6 +22,7 @@ export declare class SessionState {
22
22
  timeDifference: number;
23
23
  serverSalt: bigint;
24
24
  nextMessageId(): bigint;
25
+ previewNextMessageId(): bigint;
25
26
  nextSeqNo(contentRelated: boolean): number;
26
27
  reset(): void;
27
28
  }
@@ -1 +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"}
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;IAIvB,oBAAoB,IAAI,MAAM;IAa9B,SAAS,CAAC,cAAc,EAAE,OAAO,GAAG,MAAM;IAS1C,KAAK;CAKN"}
@@ -27,16 +27,20 @@ class SessionState {
27
27
  #seqNo = 0;
28
28
  #messageId = 0n;
29
29
  nextMessageId() {
30
+ return this.#messageId = this.previewNextMessageId();
31
+ }
32
+ previewNextMessageId() {
30
33
  const now = (0, _1_utilities_js_1.toUnixTimestamp)(new Date()) + this.timeDifference;
31
34
  const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
32
35
  const newMessageId = (BigInt(Math.floor(now)) << 32n) || (BigInt(nanoseconds) << 2n);
33
- if (this.#messageId >= newMessageId) {
34
- this.#messageId += 4n;
36
+ let messageId = this.#messageId;
37
+ if (messageId >= newMessageId) {
38
+ messageId += 4n;
35
39
  }
36
40
  else {
37
- this.#messageId = newMessageId;
41
+ messageId = newMessageId;
38
42
  }
39
- return this.#messageId;
43
+ return messageId;
40
44
  }
41
45
  nextSeqNo(contentRelated) {
42
46
  let seqNo = this.#seqNo * 2;
@@ -24,5 +24,6 @@ export declare abstract class Session {
24
24
  get isDisconnected(): boolean;
25
25
  disconnect(): void;
26
26
  abstract send(body: Uint8Array): Promise<bigint>;
27
+ previewNextMessageId(): bigint;
27
28
  }
28
29
  //# sourceMappingURL=1_session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B,wIAAwI;IACxI,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;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,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IA6BD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CACjD"}
1
+ {"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AACtH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B,wIAAwI;IACxI,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;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,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IA6BD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAEhD,oBAAoB,IAAI,MAAM;CAG/B"}
@@ -158,5 +158,8 @@ class Session {
158
158
  this.transport.connection.close();
159
159
  }
160
160
  }
161
+ previewNextMessageId() {
162
+ return this.state.previewNextMessageId();
163
+ }
161
164
  }
162
165
  exports.Session = Session;
@@ -17,23 +17,28 @@
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 { TransportError } from "../0_errors.js";
21
+ import { type MaybePromise } from "../1_utilities.js";
20
22
  import { Mtproto } from "../2_tl.js";
21
23
  import type { DC } from "../3_transport.js";
22
24
  import { Session, type SessionParams } from "./1_session.js";
23
25
  export interface Handlers {
24
- onUpdate?: (body: Uint8Array) => void;
25
- onNewServerSalt?: (serverSalt: bigint) => void;
26
- onMessageFailed?: (id: bigint, reason: unknown) => void;
27
- onPong?: (pong: Mtproto.pong) => void;
28
- onRpcError?: (id: bigint, error: Mtproto.rpc_error) => void;
29
- onRpcResult?: (id: bigint, result: Uint8Array) => void;
26
+ onTransportError?: (transportError: TransportError) => MaybePromise<void>;
27
+ onUpdate?: (body: Uint8Array) => MaybePromise<void>;
28
+ onNewServerSalt?: (serverSalt: bigint) => MaybePromise<void>;
29
+ onMessageFailed?: (id: bigint, reason: unknown) => MaybePromise<void>;
30
+ onPong?: (pong: Mtproto.pong) => MaybePromise<void>;
31
+ onRpcError?: (id: bigint, error: Mtproto.rpc_error) => MaybePromise<void>;
32
+ onRpcResult?: (id: bigint, result: Uint8Array) => MaybePromise<void>;
30
33
  }
31
34
  export declare class SessionEncrypted extends Session implements Session {
32
35
  #private;
33
36
  handlers: Handlers;
34
37
  constructor(dc: DC, params?: SessionParams);
35
38
  setAuthKey(key: Uint8Array<ArrayBuffer>): Promise<void>;
39
+ get id(): bigint;
36
40
  get authKey(): Uint8Array<ArrayBuffer>;
41
+ get authKeyId(): bigint;
37
42
  connect(): Promise<void>;
38
43
  disconnect(): void;
39
44
  send(body: Uint8Array<ArrayBuffer>): Promise<bigint>;
@@ -1 +1 @@
1
- {"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAwD,OAAO,EAAuC,MAAM,YAAY,CAAC;AAChI,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAa7D,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,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC;IACtC,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;gBAiBZ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAQpC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC;IAM7C,IAAI,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAErC;IAEc,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAe9B,UAAU,IAAI,IAAI;IA6ErB,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CA4X3D"}
1
+ {"version":3,"file":"2_session_encrypted.d.ts","sourceRoot":"","sources":["../../src/session/2_session_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAmB,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAA+E,KAAK,YAAY,EAAsC,MAAM,mBAAmB,CAAC;AACvK,OAAO,EAAwD,OAAO,EAAuC,MAAM,YAAY,CAAC;AAChI,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAa7D,MAAM,WAAW,QAAQ;IACvB,gBAAgB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1E,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC7D,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1E,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CACtE;AAED,qBAAa,gBAAiB,SAAQ,OAAQ,YAAW,OAAO;;IAI9D,QAAQ,EAAE,QAAQ,CAAM;gBAiBZ,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAQpC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC;IAM7C,IAAI,EAAE,IAAI,MAAM,CAEf;IAED,IAAI,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAErC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAEc,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAe9B,UAAU,IAAI,IAAI;IA+ErB,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CA6X3D"}
@@ -61,9 +61,15 @@ class SessionEncrypted extends _1_session_js_1.Session {
61
61
  this.#authKeyId = (0, _1_utilities_js_1.intFromBytes)(hash.slice(-8));
62
62
  this.#authKey = key;
63
63
  }
64
+ get id() {
65
+ return this.#id;
66
+ }
64
67
  get authKey() {
65
68
  return this.#authKey;
66
69
  }
70
+ get authKeyId() {
71
+ return this.#authKeyId;
72
+ }
67
73
  async connect() {
68
74
  if (!this.isConnected) {
69
75
  this.#rejectAllPending(new _0_errors_js_1.ConnectionError("The connection was closed."));
@@ -82,6 +88,8 @@ class SessionEncrypted extends _1_session_js_1.Session {
82
88
  super.disconnect();
83
89
  this.state.reset();
84
90
  this.#id = (0, _1_utilities_js_1.getRandomId)();
91
+ this.#receiveLoop.abort();
92
+ this.#sendLoop.abort();
85
93
  this.#pingLoop.abort();
86
94
  this.#awakeSendLoop?.();
87
95
  this.#rejectAllPending(new _0_errors_js_1.ConnectionError("The connection was disconnected."));
@@ -140,11 +148,11 @@ class SessionEncrypted extends _1_session_js_1.Session {
140
148
  return;
141
149
  }
142
150
  // message was not sent by us
143
- this.handlers.onMessageFailed?.(id, reason);
151
+ (0, _1_utilities_js_1.drop)(this.handlers.onMessageFailed?.(id, reason));
144
152
  }
145
153
  #setServerSalt(newServerSalt) {
146
154
  this.state.serverSalt = newServerSalt;
147
- this.handlers.onNewServerSalt?.(newServerSalt);
155
+ (0, _1_utilities_js_1.drop)(this.handlers.onNewServerSalt?.(newServerSalt));
148
156
  }
149
157
  async send(body) {
150
158
  if (!this.isDisconnected && !this.isConnected) {
@@ -179,7 +187,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
179
187
  payloadWriter.writeInt64(this.state.serverSalt);
180
188
  payloadWriter.writeInt64(this.#id);
181
189
  payloadWriter.write(await (0, _2_tl_js_1.serializeMessage)(message));
182
- payloadWriter.write(new Uint8Array((0, _1_utilities_js_1.mod)(-(payloadWriter.buffer.length + 12), 16) + 12));
190
+ payloadWriter.write(new Uint8Array((0, _1_utilities_js_1.mod)(-(payloadWriter.buffer.byteLength + 12), 16) + 12));
183
191
  const payload = payloadWriter.buffer;
184
192
  const messageKey = (await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([this.#authKey.subarray(88, 120), payload]))).subarray(8, 24);
185
193
  const a = await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([messageKey, this.#authKey.subarray(0, 36)]));
@@ -304,11 +312,11 @@ class SessionEncrypted extends _1_session_js_1.Session {
304
312
  if (!this.isConnected) {
305
313
  this.#LreceiveLoop.debug("aborting as not connected");
306
314
  loop.abort();
307
- return;
308
315
  }
309
- else {
310
- return;
316
+ else if (err instanceof _0_errors_js_1.TransportError) {
317
+ await this.handlers.onTransportError?.(err);
311
318
  }
319
+ return;
312
320
  }
313
321
  try {
314
322
  if (message.body instanceof Uint8Array) {
@@ -325,7 +333,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
325
333
  //// RECEIVE LOOP HANDLERS ////
326
334
  async #onMessage(msgId, body, containerId) {
327
335
  this.#LreceiveLoop.debug("received message with ID", msgId, "and size", body.byteLength, "inside", ...(containerId === null ? ["no container"] : ["container", containerId]));
328
- const logger = this.#LreceiveLoop.branch(msgId + "");
336
+ const logger = this.#LreceiveLoop.branch(String(msgId));
329
337
  let reader = new _2_tl_js_1.TLReader(body);
330
338
  let id = reader.readInt32(false);
331
339
  if (id === GZIP_PACKED) {
@@ -334,13 +342,13 @@ class SessionEncrypted extends _1_session_js_1.Session {
334
342
  id = reader.readInt32(false);
335
343
  }
336
344
  if (id === RPC_RESULT) {
337
- this.#onRpcResult(msgId, reader.buffer, logger);
345
+ await this.#onRpcResult(msgId, reader.buffer, logger);
338
346
  return;
339
347
  }
340
348
  if (!_2_tl_js_1.Mtproto.schema.identifierToName[id]) {
341
349
  logger.debug("identified body as a non-MTProto constructor");
342
350
  reader.unreadInt32();
343
- this.handlers.onUpdate?.(reader.buffer);
351
+ await this.handlers.onUpdate?.(reader.buffer);
344
352
  return;
345
353
  }
346
354
  let type;
@@ -393,10 +401,10 @@ class SessionEncrypted extends _1_session_js_1.Session {
393
401
  if (id === RPC_ERROR) {
394
402
  logger.debug("received rpc_error from message", msgId);
395
403
  const error = await _2_tl_js_1.Mtproto.deserializeType("rpc_error", reader);
396
- this.handlers.onRpcError?.(reqMsgId, error);
404
+ await this.handlers.onRpcError?.(reqMsgId, error);
397
405
  }
398
406
  else {
399
- this.handlers.onRpcResult?.(reqMsgId, reader.buffer);
407
+ await this.handlers.onRpcResult?.(reqMsgId, reader.buffer);
400
408
  }
401
409
  }
402
410
  #onMsgDetailedInfo(msgDetailedInfo, logger) {
@@ -448,7 +456,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
448
456
  }
449
457
  else {
450
458
  // pong is not ours
451
- this.handlers.onPong?.(pong);
459
+ (0, _1_utilities_js_1.drop)(this.handlers.onPong?.(pong));
452
460
  }
453
461
  }
454
462
  #onNewSessionCreated(msgId, newSessionCreated) {
@@ -76,7 +76,7 @@ function fromString(string) {
76
76
  const [type, value] = [Number(string[0]), string.slice(1)];
77
77
  switch (type) {
78
78
  case exports.ValueType.Boolean:
79
- return Boolean(Number(value));
79
+ return !!Number(value);
80
80
  case exports.ValueType.Number:
81
81
  return Number(value);
82
82
  case exports.ValueType.String:
@@ -100,7 +100,7 @@ function fromString(string) {
100
100
  return arr;
101
101
  }
102
102
  case exports.ValueType.Map:
103
- //deno-lint-ignore no-explicit-any
103
+ // deno-lint-ignore no-explicit-any
104
104
  return Object.fromEntries(fromString(`${exports.ValueType.Array}${value}`));
105
105
  }
106
106
  }
@@ -36,7 +36,7 @@ const dcToNameMap = {
36
36
  const transportProviderWebSocket = (params) => {
37
37
  return ({ dc, isMedia }) => {
38
38
  params ??= {};
39
- params.wss ??= typeof location !== "undefined" && location.protocol === "http:" && location.hostname !== "localhost" ? false : true;
39
+ params.wss ??= !(typeof location !== "undefined" && location.protocol === "http:" && location.hostname !== "localhost");
40
40
  const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${isMedia ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
41
41
  const connection = new _2_connection_js_1.ConnectionWebSocket(url);
42
42
  const dcId = (0, _1_transport_provider_js_1.getDcId)(dc, isMedia);
@@ -36,5 +36,5 @@ function buttonStyleToTlObject(buttonStyle) {
36
36
  if (buttonStyle === undefined) {
37
37
  return undefined;
38
38
  }
39
- return { _: "keyboardButtonStyle", bg_danger: buttonStyle.background === "danger" ? true : undefined, bg_primary: buttonStyle.background === "primary" ? true : undefined, bg_success: buttonStyle.background === "success" ? true : undefined, icon: buttonStyle.customEmojiId ? BigInt(buttonStyle.customEmojiId) : undefined };
39
+ return { _: "keyboardButtonStyle", bg_danger: buttonStyle.background === "danger" || undefined, bg_primary: buttonStyle.background === "primary" || undefined, bg_success: buttonStyle.background === "success" || undefined, icon: buttonStyle.customEmojiId ? BigInt(buttonStyle.customEmojiId) : undefined };
40
40
  }
@@ -24,45 +24,45 @@ exports.chatMemberRightsToTlObject = chatMemberRightsToTlObject;
24
24
  const _1_utilities_js_1 = require("../1_utilities.js");
25
25
  function constructChatMemberRights(rights) {
26
26
  return (0, _1_utilities_js_1.cleanObject)({
27
- canSendMessages: rights.send_messages ? true : false,
28
- canSendAudio: rights.send_audios ? true : false,
29
- canSendDocuments: rights.send_docs ? true : false,
30
- canSendPhotos: rights.send_photos ? true : false,
31
- canSendVideos: rights.send_messages ? true : false,
32
- canSendVideoNotes: rights.send_roundvideos ? true : false,
33
- canSendVoice: rights.send_voices ? true : false,
34
- canSendPolls: rights.send_polls ? true : false,
35
- canSendStickers: rights.send_stickers ? true : false,
36
- canSendAnimations: rights.send_gifs ? true : undefined,
37
- canSendGames: rights.send_games ? true : undefined,
38
- canSendInlineBotResults: rights.send_inline ? true : undefined,
39
- canAddWebPagePreviews: rights.embed_links ? true : undefined,
40
- canChangeInfo: rights.change_info ? true : undefined,
41
- canInviteUsers: rights.invite_users ? true : undefined,
42
- canPinMessages: rights.pin_messages ? true : undefined,
43
- canManageTopics: rights.manage_topics ? true : undefined,
27
+ canSendMessages: !!rights.send_messages,
28
+ canSendAudio: !!rights.send_audios,
29
+ canSendDocuments: !!rights.send_docs,
30
+ canSendPhotos: !!rights.send_photos,
31
+ canSendVideos: !!rights.send_messages,
32
+ canSendVideoNotes: !!rights.send_roundvideos,
33
+ canSendVoice: !!rights.send_voices,
34
+ canSendPolls: !!rights.send_polls,
35
+ canSendStickers: !!rights.send_stickers,
36
+ canSendAnimations: rights.send_gifs || undefined,
37
+ canSendGames: rights.send_games || undefined,
38
+ canSendInlineBotResults: rights.send_inline || undefined,
39
+ canAddWebPagePreviews: rights.embed_links || undefined,
40
+ canChangeInfo: rights.change_info || undefined,
41
+ canInviteUsers: rights.invite_users || undefined,
42
+ canPinMessages: rights.pin_messages || undefined,
43
+ canManageTopics: rights.manage_topics || undefined,
44
44
  });
45
45
  }
46
46
  function chatMemberRightsToTlObject(rights, until) {
47
47
  return {
48
48
  _: "chatBannedRights",
49
49
  until_date: until ?? 0,
50
- send_messages: rights?.canSendMessages !== false ? undefined : true,
51
- send_audios: rights?.canSendAudio !== false ? undefined : true,
52
- send_docs: rights?.canSendDocuments !== false ? undefined : true,
53
- send_photos: rights?.canSendPhotos !== false ? undefined : true,
54
- send_videos: rights?.canSendVideos !== false ? undefined : true,
55
- send_roundvideos: rights?.canSendVideoNotes !== false ? undefined : true,
56
- send_voices: rights?.canSendVoice !== false ? undefined : true,
57
- send_polls: rights?.canSendPolls !== false ? undefined : true,
58
- send_stickers: rights?.canSendStickers !== false ? undefined : true,
59
- send_gifs: rights?.canSendAnimations !== false ? undefined : true,
60
- send_games: rights?.canSendGames !== false ? undefined : true,
61
- send_inline: rights?.canSendInlineBotResults !== false ? undefined : true,
62
- embed_links: rights?.canAddWebPagePreviews !== false ? undefined : true,
63
- change_info: rights?.canChangeInfo !== false ? undefined : true,
64
- invite_users: rights?.canInviteUsers !== false ? undefined : true,
65
- pin_messages: rights?.canPinMessages !== false ? undefined : true,
66
- manage_topics: rights?.canManageTopics !== false ? undefined : true,
50
+ send_messages: rights?.canSendMessages === false || undefined,
51
+ send_audios: rights?.canSendAudio === false || undefined,
52
+ send_docs: rights?.canSendDocuments === false || undefined,
53
+ send_photos: rights?.canSendPhotos === false || undefined,
54
+ send_videos: rights?.canSendVideos === false || undefined,
55
+ send_roundvideos: rights?.canSendVideoNotes === false || undefined,
56
+ send_voices: rights?.canSendVoice === false || undefined,
57
+ send_polls: rights?.canSendPolls === false || undefined,
58
+ send_stickers: rights?.canSendStickers === false || undefined,
59
+ send_gifs: rights?.canSendAnimations === false || undefined,
60
+ send_games: rights?.canSendGames === false || undefined,
61
+ send_inline: rights?.canSendInlineBotResults === false || undefined,
62
+ embed_links: rights?.canAddWebPagePreviews === false || undefined,
63
+ change_info: rights?.canChangeInfo === false || undefined,
64
+ invite_users: rights?.canInviteUsers === false || undefined,
65
+ pin_messages: rights?.canPinMessages === false || undefined,
66
+ manage_topics: rights?.canManageTopics === false || undefined,
67
67
  };
68
68
  }
@@ -54,8 +54,8 @@ function constructChatPhoto(photo, chatId, chatAccessHash) {
54
54
  smallFileUniqueId,
55
55
  bigFileId,
56
56
  bigFileUniqueId,
57
- hasVideo: photo.has_video || false,
58
- isPersonal: photo.personal ? true : false,
57
+ hasVideo: !!photo.has_video,
58
+ isPersonal: !!photo.personal,
59
59
  });
60
60
  }
61
61
  }
@@ -20,7 +20,7 @@
20
20
  import type { Api } from "../2_tl.js";
21
21
  /** A rolled dice. */
22
22
  export interface Dice {
23
- /** The emoji on which the dice is based on. */
23
+ /** The emoji on which the dice is based. */
24
24
  emoji: string;
25
25
  /** The result of the roll, which is in the range of 1-6 for the emojis "🎲", "🎯" and "🎳", 1-5 for the emojis "🏀" and "⚽", and 1-64 for the emoji "🎰". */
26
26
  value: number;
@@ -1 +1 @@
1
- {"version":3,"file":"0_dice.d.ts","sourceRoot":"","sources":["../../src/types/0_dice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,WAAW,IAAI;IACnB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,6JAA6J;IAC7J,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAE/D"}
1
+ {"version":3,"file":"0_dice.d.ts","sourceRoot":"","sources":["../../src/types/0_dice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,WAAW,IAAI;IACnB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,6JAA6J;IAC7J,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAE/D"}
@@ -25,7 +25,7 @@ function constructGiveawayParameters(g) {
25
25
  const countries = g.countries_iso2 ?? [];
26
26
  const boostedChatId = _2_tl_js_1.Api.peerToChatId({ _: "peerChannel", channel_id: g.channels[0] });
27
27
  const additionalChatIds = g.channels.slice(1).map((v) => _2_tl_js_1.Api.peerToChatId({ _: "peerChannel", channel_id: v }));
28
- const onlyNewMembers = g.only_new_subscribers ? true : false;
28
+ const onlyNewMembers = !!g.only_new_subscribers;
29
29
  const winnerSelectionDate = g.until_date;
30
30
  return { boostedChatId, additionalChatIds, winnerSelectionDate, onlyNewMembers, countries };
31
31
  }
@@ -22,7 +22,7 @@ import type { Api } from "../2_tl.js";
22
22
  export interface LiveStreamChannel {
23
23
  /** The live stream channel's unique identifier. */
24
24
  id: number;
25
- /** The scale of the live stream channel's chunks. Duration of each chunk is equal to 1000 / 2 ^ scale. ` */
25
+ /** The scale of the live stream channel's chunks. Duration of each chunk is equal to 1000 / 2 ^ scale. */
26
26
  scale: number;
27
27
  /** The live stream channel's last timestamp. */
28
28
  timestamp: number;
@@ -1 +1 @@
1
- {"version":3,"file":"0_live_stream_channel.d.ts","sourceRoot":"","sources":["../../src/types/0_live_stream_channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,6BAA6B;AAC7B,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,4GAA4G;IAC5G,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,GAAG,CAAC,sBAAsB,GAAG,iBAAiB,CAMjG"}
1
+ {"version":3,"file":"0_live_stream_channel.d.ts","sourceRoot":"","sources":["../../src/types/0_live_stream_channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,6BAA6B;AAC7B,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,GAAG,CAAC,sBAAsB,GAAG,iBAAiB,CAMjG"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2026 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 type { Api } from "../2_tl.js";
21
+ export interface ReportReasonSpam {
22
+ type: "spam";
23
+ }
24
+ export interface ReportReasonViolence {
25
+ type: "violence";
26
+ }
27
+ export interface ReportReasonPornography {
28
+ type: "pornography";
29
+ }
30
+ export interface ReportReasonChildAbuse {
31
+ type: "childAbuse";
32
+ }
33
+ export interface ReportReasonOther {
34
+ type: "other";
35
+ }
36
+ export interface ReportReasonCopyright {
37
+ type: "copyright";
38
+ }
39
+ export interface ReportReasonLocationIrrelevant {
40
+ type: "locationIrrelevant";
41
+ }
42
+ export interface ReportReasonFake {
43
+ type: "fake";
44
+ }
45
+ export interface ReportReasonIllegalDrugs {
46
+ type: "illegalDrugs";
47
+ }
48
+ export interface ReportReasonPersonalDetails {
49
+ type: "personalDetails";
50
+ }
51
+ export type ReportReason = ReportReasonSpam | ReportReasonViolence | ReportReasonPornography | ReportReasonChildAbuse | ReportReasonOther | ReportReasonCopyright | ReportReasonLocationIrrelevant | ReportReasonFake | ReportReasonIllegalDrugs | ReportReasonPersonalDetails;
52
+ export declare function reportReasonToTlObject(reportReason: ReportReason): Api.ReportReason;
53
+ //# sourceMappingURL=0_report_reason.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_report_reason.d.ts","sourceRoot":"","sources":["../../src/types/0_report_reason.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,oBAAoB,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG,oBAAoB,GAAG,uBAAuB,GAAG,sBAAsB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,8BAA8B,GAAG,gBAAgB,GAAG,wBAAwB,GAAG,2BAA2B,CAAC;AAE/Q,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,GAAG,CAAC,YAAY,CAyBnF"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2026 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.reportReasonToTlObject = reportReasonToTlObject;
23
+ const _0_deps_js_1 = require("../0_deps.js");
24
+ function reportReasonToTlObject(reportReason) {
25
+ switch (reportReason.type) {
26
+ case "spam":
27
+ return { _: "inputReportReasonSpam" };
28
+ case "violence":
29
+ return { _: "inputReportReasonViolence" };
30
+ case "pornography":
31
+ return { _: "inputReportReasonPornography" };
32
+ case "childAbuse":
33
+ return { _: "inputReportReasonChildAbuse" };
34
+ case "other":
35
+ return { _: "inputReportReasonOther" };
36
+ case "copyright":
37
+ return { _: "inputReportReasonCopyright" };
38
+ case "locationIrrelevant":
39
+ return { _: "inputReportReasonGeoIrrelevant" };
40
+ case "fake":
41
+ return { _: "inputReportReasonFake" };
42
+ case "illegalDrugs":
43
+ return { _: "inputReportReasonIllegalDrugs" };
44
+ case "personalDetails":
45
+ return { _: "inputReportReasonPersonalDetails" };
46
+ }
47
+ (0, _0_deps_js_1.unreachable)();
48
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2026 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 type { Api } from "../2_tl.js";
21
+ export interface StoryReportOption {
22
+ text: string;
23
+ option: string;
24
+ }
25
+ export declare function constructStoryReportOption(rr: Api.messageReportOption): StoryReportOption;
26
+ //# sourceMappingURL=0_story_report_option.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_story_report_option.d.ts","sourceRoot":"","sources":["../../src/types/0_story_report_option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,GAAG,CAAC,mBAAmB,GAAG,iBAAiB,CAIzF"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2026 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.constructStoryReportOption = constructStoryReportOption;
23
+ const _1_utilities_js_1 = require("../1_utilities.js");
24
+ function constructStoryReportOption(rr) {
25
+ const text = rr.text;
26
+ const option = (0, _1_utilities_js_1.base64EncodeUrlSafe)(rr.option);
27
+ return { text, option };
28
+ }
@@ -32,7 +32,7 @@ function constructVideoChat(call) {
32
32
  }
33
33
  else {
34
34
  const title = call.title ?? "";
35
- const liveStream = call.rtmp_stream ? true : false;
35
+ const liveStream = !!call.rtmp_stream;
36
36
  const participantCount = call.participants_count;
37
37
  if (call.schedule_date) {
38
38
  return {
@@ -50,7 +50,7 @@ function constructVideoChat(call) {
50
50
  id,
51
51
  title,
52
52
  isLiveStream: liveStream,
53
- isRecording: call.record_video_active ? true : false,
53
+ isRecording: !!call.record_video_active,
54
54
  participantCount,
55
55
  };
56
56
  }