@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.
- package/esm/3_types.d.ts +3 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +3 -0
- package/esm/4_constants.d.ts +1 -0
- package/esm/4_constants.d.ts.map +1 -1
- package/esm/4_constants.js +1 -0
- package/esm/client/0_markdown.js +4 -4
- package/esm/client/0_params.d.ts +11 -1
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +100 -3
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/1_client_plain.d.ts +1 -1
- package/esm/client/1_client_plain.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +25 -13
- package/esm/client/2_client_encrypted.d.ts +6 -3
- package/esm/client/2_client_encrypted.d.ts.map +1 -1
- package/esm/client/2_client_encrypted.js +166 -49
- package/esm/client/2_file_manager.js +1 -1
- package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +3 -2
- package/esm/client/2_payment_manager.js +2 -2
- package/esm/client/2_takeout_manager.js +2 -2
- package/esm/client/2_update_manager.d.ts.map +1 -1
- package/esm/client/2_update_manager.js +16 -11
- package/esm/client/3_account_manager.js +3 -3
- package/esm/client/3_message_manager.d.ts +11 -0
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +195 -74
- package/esm/client/3_sticker_set_manager.js +3 -3
- package/esm/client/3_video_chat_manager.js +1 -1
- package/esm/client/4_callback_query_manager.js +2 -2
- package/esm/client/4_chat_list_manager.js +3 -3
- package/esm/client/4_chat_manager.d.ts +3 -2
- package/esm/client/4_chat_manager.d.ts.map +1 -1
- package/esm/client/4_chat_manager.js +12 -5
- package/esm/client/4_contact_manager.js +1 -1
- package/esm/client/4_gift_manager.js +11 -11
- package/esm/client/4_inline_query_manager.js +1 -1
- package/esm/client/4_story_manager.d.ts +3 -1
- package/esm/client/4_story_manager.d.ts.map +1 -1
- package/esm/client/4_story_manager.js +17 -3
- package/esm/client/6_client.d.ts +102 -3
- package/esm/client/6_client.d.ts.map +1 -1
- package/esm/client/6_client.js +130 -2
- package/esm/client/6_client_dispatcher.d.ts +100 -3
- package/esm/client/6_client_dispatcher.d.ts.map +1 -1
- package/esm/client/6_client_dispatcher.js +126 -1
- package/esm/connection/0_get_tls_header.d.ts.map +1 -1
- package/esm/connection/0_get_tls_header.js +19 -0
- package/esm/connection/1_connection_web_socket.js +2 -2
- package/esm/session/0_session_state.d.ts +1 -0
- package/esm/session/0_session_state.d.ts.map +1 -1
- package/esm/session/0_session_state.js +8 -4
- package/esm/session/1_session.d.ts +1 -0
- package/esm/session/1_session.d.ts.map +1 -1
- package/esm/session/1_session.js +3 -0
- package/esm/session/2_session_encrypted.d.ts +11 -6
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +20 -12
- package/esm/storage/1_utilities.js +2 -2
- package/esm/transport/2_transport_provider_web_socket.js +1 -1
- package/esm/types/0_button_style.js +1 -1
- package/esm/types/0_chat_member_rights.js +34 -34
- package/esm/types/0_chat_photo.js +2 -2
- package/esm/types/0_dice.d.ts +1 -1
- package/esm/types/0_dice.d.ts.map +1 -1
- package/esm/types/0_giveaway_parameters.js +1 -1
- package/esm/types/0_live_stream_channel.d.ts +1 -1
- package/esm/types/0_live_stream_channel.d.ts.map +1 -1
- package/esm/types/0_report_reason.d.ts +53 -0
- package/esm/types/0_report_reason.d.ts.map +1 -0
- package/esm/types/0_report_reason.js +45 -0
- package/esm/types/0_story_report_option.d.ts +26 -0
- package/esm/types/0_story_report_option.d.ts.map +1 -0
- package/esm/types/0_story_report_option.js +25 -0
- package/esm/types/0_video_chat.js +2 -2
- package/esm/types/1_inline_keyboard_button.d.ts +2 -2
- package/esm/types/1_message_reaction.js +1 -1
- package/esm/types/1_sticker.js +1 -1
- package/esm/types/1_story_reaction.js +1 -1
- package/esm/types/1_story_report_result.d.ts +37 -0
- package/esm/types/1_story_report_result.d.ts.map +1 -0
- package/esm/types/1_story_report_result.js +36 -0
- package/esm/types/2_chat.js +2 -2
- package/esm/types/2_chat_member.js +3 -3
- package/esm/types/2_message_entity.js +1 -1
- package/esm/types/2_story_interactive_area.js +3 -3
- package/esm/types/3_chat_settings.js +1 -1
- package/esm/types/3_forward_header.js +3 -3
- package/esm/types/3_inline_query.js +1 -1
- package/esm/types/3_invite_link.js +2 -2
- package/esm/types/3_story.js +3 -3
- package/esm/types/4_gift.js +1 -1
- package/esm/types/5_gift_non_upgraded_information.js +8 -8
- package/esm/types/5_gift_upgraded_information.js +5 -5
- package/esm/types/6_poll_media.d.ts +1 -1
- package/esm/types/6_poll_media.d.ts.map +1 -1
- package/esm/types/7_inline_query_result.js +8 -8
- package/esm/types/7_poll_option.d.ts +1 -1
- package/esm/types/7_poll_option.d.ts.map +1 -1
- package/esm/types/8_inline_query_answer.js +1 -1
- package/esm/types/9_message.js +3 -3
- package/esm/utilities/0_env.js +1 -1
- package/package.json +1 -1
- package/script/3_types.d.ts +3 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +3 -0
- package/script/4_constants.d.ts +1 -0
- package/script/4_constants.d.ts.map +1 -1
- package/script/4_constants.js +2 -1
- package/script/client/0_markdown.js +4 -4
- package/script/client/0_params.d.ts +11 -1
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +100 -3
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/1_client_plain.d.ts +1 -1
- package/script/client/1_client_plain.d.ts.map +1 -1
- package/script/client/1_client_plain.js +24 -12
- package/script/client/2_client_encrypted.d.ts +6 -3
- package/script/client/2_client_encrypted.d.ts.map +1 -1
- package/script/client/2_client_encrypted.js +166 -49
- package/script/client/2_file_manager.js +1 -1
- package/script/client/2_network_statistics_manager.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +3 -2
- package/script/client/2_payment_manager.js +2 -2
- package/script/client/2_takeout_manager.js +2 -2
- package/script/client/2_update_manager.d.ts.map +1 -1
- package/script/client/2_update_manager.js +16 -11
- package/script/client/3_account_manager.js +3 -3
- package/script/client/3_message_manager.d.ts +11 -0
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +194 -73
- package/script/client/3_sticker_set_manager.js +3 -3
- package/script/client/3_video_chat_manager.js +1 -1
- package/script/client/4_callback_query_manager.js +2 -2
- package/script/client/4_chat_list_manager.js +3 -3
- package/script/client/4_chat_manager.d.ts +3 -2
- package/script/client/4_chat_manager.d.ts.map +1 -1
- package/script/client/4_chat_manager.js +11 -4
- package/script/client/4_contact_manager.js +1 -1
- package/script/client/4_gift_manager.js +11 -11
- package/script/client/4_inline_query_manager.js +1 -1
- package/script/client/4_story_manager.d.ts +3 -1
- package/script/client/4_story_manager.d.ts.map +1 -1
- package/script/client/4_story_manager.js +15 -1
- package/script/client/6_client.d.ts +102 -3
- package/script/client/6_client.d.ts.map +1 -1
- package/script/client/6_client.js +130 -2
- package/script/client/6_client_dispatcher.d.ts +100 -3
- package/script/client/6_client_dispatcher.d.ts.map +1 -1
- package/script/client/6_client_dispatcher.js +126 -1
- package/script/connection/0_get_tls_header.d.ts.map +1 -1
- package/script/connection/0_get_tls_header.js +19 -0
- package/script/connection/1_connection_web_socket.js +2 -2
- package/script/session/0_session_state.d.ts +1 -0
- package/script/session/0_session_state.d.ts.map +1 -1
- package/script/session/0_session_state.js +8 -4
- package/script/session/1_session.d.ts +1 -0
- package/script/session/1_session.d.ts.map +1 -1
- package/script/session/1_session.js +3 -0
- package/script/session/2_session_encrypted.d.ts +11 -6
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +20 -12
- package/script/storage/1_utilities.js +2 -2
- package/script/transport/2_transport_provider_web_socket.js +1 -1
- package/script/types/0_button_style.js +1 -1
- package/script/types/0_chat_member_rights.js +34 -34
- package/script/types/0_chat_photo.js +2 -2
- package/script/types/0_dice.d.ts +1 -1
- package/script/types/0_dice.d.ts.map +1 -1
- package/script/types/0_giveaway_parameters.js +1 -1
- package/script/types/0_live_stream_channel.d.ts +1 -1
- package/script/types/0_live_stream_channel.d.ts.map +1 -1
- package/script/types/0_report_reason.d.ts +53 -0
- package/script/types/0_report_reason.d.ts.map +1 -0
- package/script/types/0_report_reason.js +48 -0
- package/script/types/0_story_report_option.d.ts +26 -0
- package/script/types/0_story_report_option.d.ts.map +1 -0
- package/script/types/0_story_report_option.js +28 -0
- package/script/types/0_video_chat.js +2 -2
- package/script/types/1_inline_keyboard_button.d.ts +2 -2
- package/script/types/1_message_reaction.js +1 -1
- package/script/types/1_sticker.js +1 -1
- package/script/types/1_story_reaction.js +1 -1
- package/script/types/1_story_report_result.d.ts +37 -0
- package/script/types/1_story_report_result.d.ts.map +1 -0
- package/script/types/1_story_report_result.js +39 -0
- package/script/types/2_chat.js +2 -2
- package/script/types/2_chat_member.js +3 -3
- package/script/types/2_message_entity.js +1 -1
- package/script/types/2_story_interactive_area.js +3 -3
- package/script/types/3_chat_settings.js +1 -1
- package/script/types/3_forward_header.js +3 -3
- package/script/types/3_inline_query.js +1 -1
- package/script/types/3_invite_link.js +2 -2
- package/script/types/3_story.js +3 -3
- package/script/types/4_gift.js +1 -1
- package/script/types/5_gift_non_upgraded_information.js +8 -8
- package/script/types/5_gift_upgraded_information.js +5 -5
- package/script/types/6_poll_media.d.ts +1 -1
- package/script/types/6_poll_media.d.ts.map +1 -1
- package/script/types/7_inline_query_result.js +8 -8
- package/script/types/7_poll_option.d.ts +1 -1
- package/script/types/7_poll_option.d.ts.map +1 -1
- package/script/types/8_inline_query_answer.js +1 -1
- package/script/types/9_message.js +3 -3
- 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.
|
|
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.
|
|
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);
|
|
@@ -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;
|
|
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
|
-
|
|
34
|
-
|
|
36
|
+
let messageId = this.#messageId;
|
|
37
|
+
if (messageId >= newMessageId) {
|
|
38
|
+
messageId += 4n;
|
|
35
39
|
}
|
|
36
40
|
else {
|
|
37
|
-
|
|
41
|
+
messageId = newMessageId;
|
|
38
42
|
}
|
|
39
|
-
return
|
|
43
|
+
return messageId;
|
|
40
44
|
}
|
|
41
45
|
nextSeqNo(contentRelated) {
|
|
42
46
|
let seqNo = this.#seqNo * 2;
|
|
@@ -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;
|
|
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"}
|
|
@@ -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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
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.
|
|
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
|
-
|
|
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
|
|
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"
|
|
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"
|
|
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
|
|
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
|
|
37
|
-
canSendGames: rights.send_games
|
|
38
|
-
canSendInlineBotResults: rights.send_inline
|
|
39
|
-
canAddWebPagePreviews: rights.embed_links
|
|
40
|
-
canChangeInfo: rights.change_info
|
|
41
|
-
canInviteUsers: rights.invite_users
|
|
42
|
-
canPinMessages: rights.pin_messages
|
|
43
|
-
canManageTopics: rights.manage_topics
|
|
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
|
|
51
|
-
send_audios: rights?.canSendAudio
|
|
52
|
-
send_docs: rights?.canSendDocuments
|
|
53
|
-
send_photos: rights?.canSendPhotos
|
|
54
|
-
send_videos: rights?.canSendVideos
|
|
55
|
-
send_roundvideos: rights?.canSendVideoNotes
|
|
56
|
-
send_voices: rights?.canSendVoice
|
|
57
|
-
send_polls: rights?.canSendPolls
|
|
58
|
-
send_stickers: rights?.canSendStickers
|
|
59
|
-
send_gifs: rights?.canSendAnimations
|
|
60
|
-
send_games: rights?.canSendGames
|
|
61
|
-
send_inline: rights?.canSendInlineBotResults
|
|
62
|
-
embed_links: rights?.canAddWebPagePreviews
|
|
63
|
-
change_info: rights?.canChangeInfo
|
|
64
|
-
invite_users: rights?.canInviteUsers
|
|
65
|
-
pin_messages: rights?.canPinMessages
|
|
66
|
-
manage_topics: rights?.canManageTopics
|
|
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
|
|
58
|
-
isPersonal: photo.personal
|
|
57
|
+
hasVideo: !!photo.has_video,
|
|
58
|
+
isPersonal: !!photo.personal,
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
}
|
package/script/types/0_dice.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
53
|
+
isRecording: !!call.record_video_active,
|
|
54
54
|
participantCount,
|
|
55
55
|
};
|
|
56
56
|
}
|