@mtkruto/node 0.0.991 → 0.0.992
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/1_utilities.d.ts +12 -0
- package/esm/1_utilities.js +12 -0
- package/esm/2_connection.d.ts +2 -0
- package/esm/2_connection.js +2 -0
- package/esm/2_tl.d.ts +10 -0
- package/esm/2_tl.js +10 -0
- package/esm/3_storage.d.ts +6 -0
- package/esm/3_storage.js +6 -0
- package/esm/3_transport.d.ts +4 -0
- package/esm/3_transport.js +4 -0
- package/esm/3_types.d.ts +35 -0
- package/esm/3_types.js +35 -0
- package/esm/{constants.d.ts → 4_constants.d.ts} +2 -2
- package/esm/{constants.js → 4_constants.js} +1 -1
- package/esm/5_client.d.ts +2 -0
- package/esm/5_client.js +2 -0
- package/esm/client/0_html.d.ts +1 -1
- package/esm/client/0_html.js +1 -1
- package/esm/client/0_message.d.ts +1 -2
- package/esm/client/0_message.js +7 -14
- package/esm/client/0_password.d.ts +2 -2
- package/esm/client/0_password.js +2 -4
- package/esm/client/0_utilities.d.ts +3 -5
- package/esm/client/0_utilities.js +3 -22
- package/esm/client/1_client_abstract.d.ts +2 -2
- package/esm/client/1_client_abstract.js +3 -3
- package/esm/client/2_client_plain.d.ts +3 -3
- package/esm/client/2_client_plain.js +13 -20
- package/esm/client/3_client.d.ts +33 -18
- package/esm/client/3_client.js +47 -35
- package/esm/connection/0_connection.d.ts +1 -1
- package/esm/connection/1_connection_web_socket.js +1 -1
- package/esm/mod.d.ts +7 -21
- package/esm/mod.js +7 -21
- package/esm/storage/0_storage.d.ts +4 -5
- package/esm/storage/0_storage.js +3 -8
- package/esm/storage/0_utilities.js +2 -2
- package/esm/storage/1_storage_local_storage.d.ts +1 -1
- package/esm/storage/1_storage_memory.d.ts +1 -1
- package/esm/storage/1_storage_session_storage.d.ts +1 -1
- package/esm/tl/0_tl_raw_reader.js +1 -1
- package/esm/tl/0_tl_raw_writer.js +1 -1
- package/esm/tl/1_tl_object.js +1 -1
- package/esm/tl/3_deserialize.js +1 -1
- package/esm/tl/3_utilities.d.ts +3 -0
- package/esm/tl/3_utilities.js +20 -0
- package/esm/tl/4_tl_writer.js +1 -1
- package/esm/transport/0_obfuscation.d.ts +2 -2
- package/esm/transport/0_obfuscation.js +1 -2
- package/esm/transport/0_transport.d.ts +1 -2
- package/esm/transport/1_transport_abridged.d.ts +1 -1
- package/esm/transport/1_transport_abridged.js +1 -1
- package/esm/transport/1_transport_intermediate.d.ts +1 -1
- package/esm/transport/1_transport_intermediate.js +1 -1
- package/esm/transport/2_transport_provider.d.ts +1 -1
- package/esm/transport/2_transport_provider.js +1 -1
- package/esm/types/!0_file_id.js +6 -9
- package/esm/types/!0_misc.d.ts +7 -0
- package/esm/types/!0_misc.js +1 -0
- package/esm/types/0_audio.d.ts +3 -3
- package/esm/types/0_audio.js +1 -1
- package/esm/types/0_chat_administrator_rights.d.ts +1 -1
- package/esm/types/0_chat_administrator_rights.js +1 -1
- package/esm/types/0_chat_photo.d.ts +3 -3
- package/esm/types/0_chat_photo.js +1 -1
- package/esm/types/0_color.d.ts +2 -0
- package/esm/types/0_color.js +16 -0
- package/esm/types/0_contact.d.ts +2 -2
- package/esm/types/0_dice.d.ts +1 -1
- package/esm/types/0_force_reply.d.ts +1 -1
- package/esm/types/0_force_reply.js +1 -1
- package/esm/types/0_location.d.ts +1 -1
- package/esm/types/0_location.js +1 -2
- package/esm/types/0_mask_position.d.ts +1 -1
- package/esm/types/0_message_entity.d.ts +5 -5
- package/esm/types/0_message_entity.js +1 -1
- package/esm/types/0_poll_option.d.ts +1 -1
- package/esm/types/0_reply_keyboard_remove.d.ts +1 -1
- package/esm/types/0_reply_keyboard_remove.js +2 -2
- package/esm/types/0_thumbnail.d.ts +2 -2
- package/esm/types/0_thumbnail.js +1 -1
- package/esm/types/0_venue.d.ts +1 -1
- package/esm/types/0_venue.js +1 -2
- package/esm/types/0_voice.d.ts +3 -3
- package/esm/types/0_web_app_info.d.ts +2 -2
- package/esm/types/1_animation.d.ts +3 -3
- package/esm/types/1_animation.js +1 -1
- package/esm/types/1_chat.d.ts +5 -4
- package/esm/types/1_chat.js +8 -9
- package/esm/types/1_document.d.ts +4 -4
- package/esm/types/1_document.js +1 -1
- package/esm/types/1_inline_keyboard_button.d.ts +4 -4
- package/esm/types/1_inline_keyboard_button.js +2 -2
- package/esm/types/1_keyboard_button.d.ts +8 -8
- package/esm/types/1_keyboard_button.js +2 -2
- package/esm/types/1_photo.d.ts +2 -2
- package/esm/types/1_photo.js +1 -1
- package/esm/types/1_poll.d.ts +8 -8
- package/esm/types/1_poll.js +1 -1
- package/esm/types/1_sticker.d.ts +3 -3
- package/esm/types/1_sticker.js +1 -2
- package/esm/types/1_user.d.ts +4 -3
- package/esm/types/1_user.js +4 -4
- package/esm/types/1_video.d.ts +3 -3
- package/esm/types/1_video.js +1 -1
- package/esm/types/1_video_note.d.ts +2 -2
- package/esm/types/1_video_note.js +1 -1
- package/esm/types/2_game.d.ts +3 -3
- package/esm/types/2_game.js +2 -3
- package/esm/types/2_inline_keyboard_markup.d.ts +2 -2
- package/esm/types/2_inline_keyboard_markup.js +1 -1
- package/esm/types/2_inline_query.d.ts +19 -0
- package/esm/types/2_inline_query.js +41 -0
- package/esm/types/2_reply_keyboard_markup.d.ts +2 -2
- package/esm/types/2_reply_keyboard_markup.js +1 -1
- package/esm/types/3_message.d.ts +21 -23
- package/esm/types/3_message.js +16 -18
- package/esm/types/4_callback_query.d.ts +14 -0
- package/esm/types/4_callback_query.js +24 -0
- package/esm/utilities/0_base64.js +1 -1
- package/esm/utilities/0_crypto.js +1 -1
- package/esm/utilities/0_queue.js +1 -1
- package/esm/utilities/1_auth.js +1 -1
- package/package.json +1 -1
- package/script/1_utilities.d.ts +12 -0
- package/script/1_utilities.js +28 -0
- package/script/2_connection.d.ts +2 -0
- package/script/2_connection.js +18 -0
- package/script/2_tl.d.ts +10 -0
- package/script/2_tl.js +40 -0
- package/script/3_storage.d.ts +6 -0
- package/script/3_storage.js +22 -0
- package/script/3_transport.d.ts +4 -0
- package/script/3_transport.js +20 -0
- package/script/3_types.d.ts +35 -0
- package/script/3_types.js +51 -0
- package/script/{constants.d.ts → 4_constants.d.ts} +2 -2
- package/script/{constants.js → 4_constants.js} +1 -1
- package/script/5_client.d.ts +2 -0
- package/script/5_client.js +18 -0
- package/script/client/0_html.d.ts +1 -1
- package/script/client/0_html.js +2 -2
- package/script/client/0_message.d.ts +1 -2
- package/script/client/0_message.js +32 -39
- package/script/client/0_password.d.ts +2 -2
- package/script/client/0_password.js +20 -22
- package/script/client/0_utilities.d.ts +3 -5
- package/script/client/0_utilities.js +24 -68
- package/script/client/1_client_abstract.d.ts +2 -2
- package/script/client/1_client_abstract.js +6 -6
- package/script/client/2_client_plain.d.ts +3 -3
- package/script/client/2_client_plain.js +45 -52
- package/script/client/3_client.d.ts +33 -18
- package/script/client/3_client.js +291 -303
- package/script/connection/0_connection.d.ts +1 -1
- package/script/connection/1_connection_web_socket.js +5 -5
- package/script/mod.d.ts +7 -21
- package/script/mod.js +17 -45
- package/script/storage/0_storage.d.ts +4 -5
- package/script/storage/0_storage.js +11 -39
- package/script/storage/0_utilities.js +6 -6
- package/script/storage/1_storage_local_storage.d.ts +1 -1
- package/script/storage/1_storage_memory.d.ts +1 -1
- package/script/storage/1_storage_session_storage.d.ts +1 -1
- package/script/tl/0_tl_raw_reader.js +6 -6
- package/script/tl/0_tl_raw_writer.js +7 -7
- package/script/tl/1_tl_object.js +3 -3
- package/script/tl/3_deserialize.js +2 -2
- package/script/tl/3_utilities.d.ts +3 -0
- package/script/tl/3_utilities.js +48 -0
- package/script/tl/4_tl_writer.js +2 -2
- package/script/transport/0_obfuscation.d.ts +2 -2
- package/script/transport/0_obfuscation.js +5 -6
- package/script/transport/0_transport.d.ts +1 -2
- package/script/transport/1_transport_abridged.d.ts +1 -1
- package/script/transport/1_transport_abridged.js +3 -3
- package/script/transport/1_transport_intermediate.d.ts +1 -1
- package/script/transport/1_transport_intermediate.js +3 -3
- package/script/transport/2_transport_provider.d.ts +1 -1
- package/script/transport/2_transport_provider.js +2 -2
- package/script/types/!0_file_id.js +24 -27
- package/script/types/!0_misc.d.ts +7 -0
- package/script/types/!0_misc.js +2 -0
- package/script/types/0_audio.d.ts +3 -3
- package/script/types/0_audio.js +2 -25
- package/script/types/0_chat_administrator_rights.d.ts +1 -1
- package/script/types/0_chat_administrator_rights.js +2 -25
- package/script/types/0_chat_photo.d.ts +3 -3
- package/script/types/0_chat_photo.js +2 -25
- package/script/types/0_color.d.ts +2 -0
- package/script/types/{!0_id_color.js → 0_color.js} +10 -10
- package/script/types/0_contact.d.ts +2 -2
- package/script/types/0_dice.d.ts +1 -1
- package/script/types/0_force_reply.d.ts +1 -1
- package/script/types/0_force_reply.js +2 -25
- package/script/types/0_location.d.ts +1 -1
- package/script/types/0_location.js +5 -29
- package/script/types/0_mask_position.d.ts +1 -1
- package/script/types/0_message_entity.d.ts +5 -5
- package/script/types/0_message_entity.js +39 -62
- package/script/types/0_poll_option.d.ts +1 -1
- package/script/types/0_reply_keyboard_remove.d.ts +1 -1
- package/script/types/0_reply_keyboard_remove.js +4 -27
- package/script/types/0_thumbnail.d.ts +2 -2
- package/script/types/0_thumbnail.js +2 -25
- package/script/types/0_venue.d.ts +1 -1
- package/script/types/0_venue.js +2 -26
- package/script/types/0_voice.d.ts +3 -3
- package/script/types/0_web_app_info.d.ts +2 -2
- package/script/types/1_animation.d.ts +3 -3
- package/script/types/1_animation.js +2 -25
- package/script/types/1_chat.d.ts +5 -4
- package/script/types/1_chat.js +20 -44
- package/script/types/1_document.d.ts +4 -4
- package/script/types/1_document.js +2 -25
- package/script/types/1_inline_keyboard_button.d.ts +4 -4
- package/script/types/1_inline_keyboard_button.js +19 -42
- package/script/types/1_keyboard_button.d.ts +8 -8
- package/script/types/1_keyboard_button.js +24 -47
- package/script/types/1_photo.d.ts +2 -2
- package/script/types/1_photo.js +4 -27
- package/script/types/1_poll.d.ts +8 -8
- package/script/types/1_poll.js +2 -2
- package/script/types/1_sticker.d.ts +3 -3
- package/script/types/1_sticker.js +6 -30
- package/script/types/1_user.d.ts +4 -3
- package/script/types/1_user.js +6 -29
- package/script/types/1_video.d.ts +3 -3
- package/script/types/1_video.js +2 -25
- package/script/types/1_video_note.d.ts +2 -2
- package/script/types/1_video_note.js +2 -25
- package/script/types/2_game.d.ts +3 -3
- package/script/types/2_game.js +6 -30
- package/script/types/2_inline_keyboard_markup.d.ts +2 -2
- package/script/types/2_inline_keyboard_markup.js +3 -26
- package/script/types/2_inline_query.d.ts +19 -0
- package/script/types/2_inline_query.js +45 -0
- package/script/types/2_reply_keyboard_markup.d.ts +2 -2
- package/script/types/2_reply_keyboard_markup.js +3 -26
- package/script/types/3_message.d.ts +21 -23
- package/script/types/3_message.js +94 -119
- package/script/types/4_callback_query.d.ts +14 -0
- package/script/types/4_callback_query.js +28 -0
- package/script/utilities/0_base64.js +3 -3
- package/script/utilities/0_crypto.js +3 -3
- package/script/utilities/0_queue.js +2 -2
- package/script/utilities/1_auth.js +5 -5
- package/esm/types/!0_id_color.d.ts +0 -1
- package/esm/types/!0_id_color.js +0 -16
- package/script/types/!0_id_color.d.ts +0 -1
- /package/esm/{deps.d.ts → 0_deps.d.ts} +0 -0
- /package/esm/{deps.js → 0_deps.js} +0 -0
- /package/script/{deps.d.ts → 0_deps.d.ts} +0 -0
- /package/script/{deps.js → 0_deps.js} +0 -0
package/esm/client/3_client.js
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
import { debug, gunzip, Mutex } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { TLError } from "../tl/0_tl_raw_reader.js";
|
|
10
|
-
import { as } from "../tl/1_tl_object.js";
|
|
11
|
-
import * as types from "../tl/2_types.js";
|
|
12
|
-
import { TLReader } from "../tl/3_tl_reader.js";
|
|
13
|
-
import * as functions from "../tl/3_functions.js";
|
|
14
|
-
import { RPCResult } from "../tl/5_rpc_result.js";
|
|
15
|
-
import { Message as Message_ } from "../tl/6_message.js"; // MTProto API message
|
|
16
|
-
import { MessageContainer } from "../tl/7_message_container.js";
|
|
17
|
-
import { FileID, FileType, ThumbnailSource } from "../types/!0_file_id.js";
|
|
18
|
-
import { replyKeyboardRemoveToTlObject } from "../types/0_reply_keyboard_remove.js";
|
|
19
|
-
import { messageEntityToTlObject } from "../types/0_message_entity.js";
|
|
20
|
-
import { forceReplyToTlObject } from "../types/0_force_reply.js";
|
|
21
|
-
import { constructUser } from "../types/1_user.js";
|
|
22
|
-
import { inlineKeyboardMarkupToTlObject } from "../types/2_inline_keyboard_markup.js";
|
|
23
|
-
import { replyKeyboardMarkupToTlObject } from "../types/2_reply_keyboard_markup.js";
|
|
24
|
-
import { constructMessage } from "../types/3_message.js"; // high-level wrapper for Telegram API's message
|
|
25
|
-
import { StorageMemory } from "../storage/1_storage_memory.js";
|
|
1
|
+
import { debug, gunzip, Mutex } from "../0_deps.js";
|
|
2
|
+
import { bigIntFromBuffer, drop, getRandomBigInt, getRandomId, mustPrompt, mustPromptOneOf, Queue, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
3
|
+
import { as, functions, getChannelChatId, Message as Message_, // MTProto API message
|
|
4
|
+
MessageContainer, peerToChatId, RPCResult, TLError, TLReader, types, } from "../2_tl.js";
|
|
5
|
+
import { StorageMemory } from "../3_storage.js";
|
|
6
|
+
import { constructCallbackQuery, constructInlineQuery, constructMessage, constructUser, FileID, FileType, forceReplyToTlObject, inlineKeyboardMarkupToTlObject, messageEntityToTlObject, replyKeyboardMarkupToTlObject, replyKeyboardRemoveToTlObject, ThumbnailSource, } from "../3_types.js";
|
|
7
|
+
import { ACK_THRESHOLD, APP_VERSION, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, STICKER_SET_NAME_TTL, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL, ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
8
|
+
import { isChannelPtsUpdate, isPtsUpdate } from "./0_utilities.js";
|
|
26
9
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
27
10
|
import { checkPassword } from "./0_password.js";
|
|
28
11
|
import { parseHtml } from "./0_html.js";
|
|
@@ -36,6 +19,7 @@ const dRecv = debug("Client/receiveLoop");
|
|
|
36
19
|
export const getEntity = Symbol();
|
|
37
20
|
export const getStickerSetName = Symbol();
|
|
38
21
|
export const handleMigrationError = Symbol();
|
|
22
|
+
export const getMessageWithReply = Symbol();
|
|
39
23
|
export const restartAuth = Symbol();
|
|
40
24
|
export var ParseMode;
|
|
41
25
|
(function (ParseMode) {
|
|
@@ -820,7 +804,7 @@ export class Client extends ClientAbstract {
|
|
|
820
804
|
let originalPts = null;
|
|
821
805
|
const channelPtsMap = new Map();
|
|
822
806
|
for (const update of updates) {
|
|
823
|
-
if (
|
|
807
|
+
if (isPtsUpdate(update)) {
|
|
824
808
|
if (update.pts == 0) {
|
|
825
809
|
continue;
|
|
826
810
|
}
|
|
@@ -834,7 +818,7 @@ export class Client extends ClientAbstract {
|
|
|
834
818
|
localState.pts = update.pts;
|
|
835
819
|
}
|
|
836
820
|
}
|
|
837
|
-
else if (
|
|
821
|
+
else if (isChannelPtsUpdate(update)) {
|
|
838
822
|
if (update.pts == 0) {
|
|
839
823
|
continue;
|
|
840
824
|
}
|
|
@@ -1304,13 +1288,7 @@ export class Client extends ClientAbstract {
|
|
|
1304
1288
|
const noWebpage = params?.disableWebPagePreview ? true : undefined;
|
|
1305
1289
|
await this.invoke(new functions.MessagesEditMessage({ id, peer, entities, message, noWebpage, replyMarkup }));
|
|
1306
1290
|
}
|
|
1307
|
-
|
|
1308
|
-
* Retrieve multiple messages.
|
|
1309
|
-
*
|
|
1310
|
-
* @param chatId The identifier of the chat to retrieve the messages from.
|
|
1311
|
-
* @param messageIds The identifiers of the messages to retrieve.
|
|
1312
|
-
*/
|
|
1313
|
-
async getMessages(chatId_, messageIds) {
|
|
1291
|
+
async getMessagesInner(chatId_, messageIds) {
|
|
1314
1292
|
const peer = await this.getInputPeer(chatId_);
|
|
1315
1293
|
let messages_ = new Array();
|
|
1316
1294
|
const chatId = peerToChatId(peer);
|
|
@@ -1341,10 +1319,25 @@ export class Client extends ClientAbstract {
|
|
|
1341
1319
|
}
|
|
1342
1320
|
const messages = new Array();
|
|
1343
1321
|
for (const message_ of messages_) {
|
|
1344
|
-
|
|
1322
|
+
const message = await constructMessage(message_, this[getEntity].bind(this), null, this[getStickerSetName].bind(this));
|
|
1323
|
+
const isReplyToMessage = message_ instanceof types.Message && message_.replyTo instanceof types.MessageReplyHeader;
|
|
1324
|
+
messages.push({ message, isReplyToMessage });
|
|
1345
1325
|
}
|
|
1346
1326
|
return messages;
|
|
1347
1327
|
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Retrieve multiple messages.
|
|
1330
|
+
*
|
|
1331
|
+
* @param chatId The identifier of the chat to retrieve the messages from.
|
|
1332
|
+
* @param messageIds The identifiers of the messages to retrieve.
|
|
1333
|
+
*/
|
|
1334
|
+
async getMessages(chatId_, messageIds) {
|
|
1335
|
+
return await this.getMessagesInner(chatId_, messageIds).then((v) => v.map((v) => v.message));
|
|
1336
|
+
}
|
|
1337
|
+
async [getMessageWithReply](chatId, messageId) {
|
|
1338
|
+
const messages = await this.getMessagesInner(chatId, [messageId]);
|
|
1339
|
+
return messages[0]?.message ?? null;
|
|
1340
|
+
}
|
|
1348
1341
|
/**
|
|
1349
1342
|
* Retrieve a single message.
|
|
1350
1343
|
*
|
|
@@ -1524,6 +1517,12 @@ export class Client extends ClientAbstract {
|
|
|
1524
1517
|
await this.handler({ deletedMessages: deletedMessages }, resolve);
|
|
1525
1518
|
}
|
|
1526
1519
|
}
|
|
1520
|
+
if (update instanceof types.UpdateBotCallbackQuery || update instanceof types.UpdateInlineBotCallbackQuery) {
|
|
1521
|
+
await this.handler({ callbackQuery: await constructCallbackQuery(update, this[getEntity].bind(this), this[getMessageWithReply].bind(this)) }, resolve);
|
|
1522
|
+
}
|
|
1523
|
+
else if (update instanceof types.UpdateBotInlineQuery) {
|
|
1524
|
+
await this.handler({ inlineQuery: await constructInlineQuery(update, this[getEntity].bind(this)) }, resolve);
|
|
1525
|
+
}
|
|
1527
1526
|
}
|
|
1528
1527
|
use(middleware) {
|
|
1529
1528
|
const handler = this.handler;
|
|
@@ -1560,5 +1559,18 @@ export class Client extends ClientAbstract {
|
|
|
1560
1559
|
}
|
|
1561
1560
|
});
|
|
1562
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Answer a callback query. Bot-only.
|
|
1564
|
+
*
|
|
1565
|
+
* @param id ID of the callback query to answer.
|
|
1566
|
+
*/
|
|
1567
|
+
async answerCallbackQuery(id, params) {
|
|
1568
|
+
await this.invoke(new functions.MessagesSetBotCallbackAnswer({
|
|
1569
|
+
queryId: BigInt(id),
|
|
1570
|
+
cacheTime: params?.cacheTime ?? 0,
|
|
1571
|
+
message: params?.text,
|
|
1572
|
+
alert: params?.alert ? true : undefined,
|
|
1573
|
+
}));
|
|
1574
|
+
}
|
|
1563
1575
|
}
|
|
1564
1576
|
const resolve = () => Promise.resolve();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { debug, Mutex } from "../
|
|
2
|
+
import { debug, Mutex } from "../0_deps.js";
|
|
3
3
|
import { ConnectionUnframed } from "./0_connection.js";
|
|
4
4
|
const d = debug("ConnectionWebSocket");
|
|
5
5
|
export class ConnectionWebSocket extends ConnectionUnframed {
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import { getRandomId } from "./
|
|
1
|
+
import { getRandomId } from "./1_utilities.js";
|
|
2
2
|
import { checkPassword } from "./client/0_password.js";
|
|
3
3
|
export declare const utils: {
|
|
4
4
|
checkPassword: typeof checkPassword;
|
|
5
5
|
getRandomId: typeof getRandomId;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export *
|
|
9
|
-
export *
|
|
10
|
-
export * from "./
|
|
11
|
-
export
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./client/2_client_plain.js";
|
|
14
|
-
export * from "./client/3_client.js";
|
|
15
|
-
export * from "./storage/0_storage.js";
|
|
16
|
-
export * from "./storage/1_storage_memory.js";
|
|
17
|
-
export * from "./storage/1_storage_local_storage.js";
|
|
18
|
-
export * from "./storage/1_storage_session_storage.js";
|
|
19
|
-
export * from "./storage/1_storage_indexed_db.js";
|
|
20
|
-
export * from "./transport/1_transport_abridged.js";
|
|
21
|
-
export * from "./transport/1_transport_intermediate.js";
|
|
22
|
-
export * from "./transport/0_transport.js";
|
|
23
|
-
export * from "./transport/2_transport_provider.js";
|
|
24
|
-
export * from "./connection/0_connection.js";
|
|
25
|
-
export * from "./connection/1_connection_web_socket.js";
|
|
26
|
-
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./constants.js";
|
|
7
|
+
export * from "./2_tl.js";
|
|
8
|
+
export * from "./2_connection.js";
|
|
9
|
+
export * from "./3_storage.js";
|
|
10
|
+
export * from "./3_transport.js";
|
|
11
|
+
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
|
|
12
|
+
export * from "./5_client.js";
|
package/esm/mod.js
CHANGED
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
import { getRandomId } from "./
|
|
1
|
+
import { getRandomId } from "./1_utilities.js";
|
|
2
2
|
import { checkPassword } from "./client/0_password.js";
|
|
3
3
|
export const utils = { checkPassword, getRandomId };
|
|
4
|
-
export
|
|
5
|
-
export *
|
|
6
|
-
export *
|
|
7
|
-
export * from "./
|
|
8
|
-
export
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./client/2_client_plain.js";
|
|
11
|
-
export * from "./client/3_client.js";
|
|
12
|
-
export * from "./storage/0_storage.js";
|
|
13
|
-
export * from "./storage/1_storage_memory.js";
|
|
14
|
-
export * from "./storage/1_storage_local_storage.js";
|
|
15
|
-
export * from "./storage/1_storage_session_storage.js";
|
|
16
|
-
export * from "./storage/1_storage_indexed_db.js";
|
|
17
|
-
export * from "./transport/1_transport_abridged.js";
|
|
18
|
-
export * from "./transport/1_transport_intermediate.js";
|
|
19
|
-
export * from "./transport/0_transport.js";
|
|
20
|
-
export * from "./transport/2_transport_provider.js";
|
|
21
|
-
export * from "./connection/0_connection.js";
|
|
22
|
-
export * from "./connection/1_connection_web_socket.js";
|
|
23
|
-
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./constants.js";
|
|
4
|
+
export * from "./2_tl.js";
|
|
5
|
+
export * from "./2_connection.js";
|
|
6
|
+
export * from "./3_storage.js";
|
|
7
|
+
export * from "./3_transport.js";
|
|
8
|
+
export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
|
|
9
|
+
export * from "./5_client.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import * as types from "../tl/2_types.js";
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { TLObject, types } from "../2_tl.js";
|
|
3
|
+
import { DC } from "../3_transport.js";
|
|
5
4
|
export type StorageKeyPart = string | number | bigint | Uint8Array;
|
|
6
5
|
export declare abstract class Storage {
|
|
7
6
|
private _authKeyId;
|
|
@@ -21,7 +20,7 @@ export declare abstract class Storage {
|
|
|
21
20
|
updateUsernames(type: "user" | "channel", id: bigint, usernames: string[]): Promise<void>;
|
|
22
21
|
getUsername(username: string): Promise<["channel" | "user", bigint, Date] | null>;
|
|
23
22
|
setTlObject(key: readonly StorageKeyPart[], value: TLObject | null): Promise<void>;
|
|
24
|
-
getTLObject(key: readonly StorageKeyPart[]): Promise<import("../
|
|
23
|
+
getTLObject(key: readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
|
|
25
24
|
setState(state: types.UpdatesState): Promise<void>;
|
|
26
25
|
getState(): Promise<types.UpdatesState | null>;
|
|
27
26
|
setMessage(chatId: number, messageId: number, message: types.TypeMessage | null): Promise<void>;
|
package/esm/storage/0_storage.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { UNREACHABLE } from "../
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { serialize } from "../tl/1_tl_object.js";
|
|
5
|
-
import * as types from "../tl/2_types.js";
|
|
6
|
-
import { TLReader } from "../tl/3_tl_reader.js";
|
|
7
|
-
import { rleDecode, rleEncode } from "../utilities/0_rle.js";
|
|
8
|
-
import { ZERO_CHANNEL_ID } from "../constants.js";
|
|
1
|
+
import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { serialize, TLReader, types } from "../2_tl.js";
|
|
3
|
+
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
9
4
|
const KPARTS__DC = ["dc"];
|
|
10
5
|
const KPARTS__AUTH_KEY = ["authKey"];
|
|
11
6
|
const KPARTS__CHANNEL_ACCESS_HASH = (v) => ["channelAccessHash", v];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { base64Decode, base64Encode } from "../
|
|
2
|
-
import { UNREACHABLE } from "../
|
|
1
|
+
import { base64Decode, base64Encode } from "../0_deps.js";
|
|
2
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
3
3
|
export var ValueType;
|
|
4
4
|
(function (ValueType) {
|
|
5
5
|
ValueType[ValueType["Boolean"] = 0] = "Boolean";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageLocalStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageMemory extends Storage implements Storage {
|
|
4
4
|
protected map: Map<string, unknown>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
2
|
import { Storage, StorageKeyPart } from "./0_storage.js";
|
|
3
3
|
export declare class StorageSessionStorage extends Storage implements Storage {
|
|
4
4
|
private readonly prefix;
|
package/esm/tl/1_tl_object.js
CHANGED
package/esm/tl/3_deserialize.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertEquals } from "../
|
|
1
|
+
import { assertEquals } from "../0_deps.js";
|
|
2
2
|
import { analyzeOptionalParam, flags, isOptionalParam, isTLObjectConstructor, paramDesc } from "./1_tl_object.js";
|
|
3
3
|
import { map } from "./2_types.js";
|
|
4
4
|
function deserializeSingleParam(reader, type, ntype) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
3
|
+
import * as types from "./2_types.js";
|
|
4
|
+
export function getChannelChatId(channelId) {
|
|
5
|
+
return ZERO_CHANNEL_ID + -Number(channelId);
|
|
6
|
+
}
|
|
7
|
+
export function peerToChatId(peer) {
|
|
8
|
+
if (peer instanceof types.PeerUser || peer instanceof types.InputPeerUser) {
|
|
9
|
+
return Number(peer.userId);
|
|
10
|
+
}
|
|
11
|
+
else if (peer instanceof types.PeerChat || peer instanceof types.InputPeerChat) {
|
|
12
|
+
return -Number(peer.chatId);
|
|
13
|
+
}
|
|
14
|
+
else if (peer instanceof types.PeerChannel || peer instanceof types.InputPeerChannel) {
|
|
15
|
+
return getChannelChatId(peer.channelId);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
UNREACHABLE();
|
|
19
|
+
}
|
|
20
|
+
}
|
package/esm/tl/4_tl_writer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CTR } from "../
|
|
2
|
-
import { Connection } from "../
|
|
1
|
+
import { CTR } from "../1_utilities.js";
|
|
2
|
+
import { Connection } from "../2_connection.js";
|
|
3
3
|
export declare function getObfuscationParameters(protocol: number, connection: Connection): Promise<{
|
|
4
4
|
encryptionCTR: CTR;
|
|
5
5
|
decryptionCTR: CTR;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { bufferFromBigInt, concat } from "../
|
|
3
|
-
import { CTR } from "../utilities/0_crypto.js";
|
|
2
|
+
import { bufferFromBigInt, concat, CTR } from "../1_utilities.js";
|
|
4
3
|
export async function getObfuscationParameters(protocol, connection) {
|
|
5
4
|
const dc = 0xFCFF;
|
|
6
5
|
let init;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import { CTR } from "../utilities/0_crypto.js";
|
|
1
|
+
import { CTR, MaybePromise } from "../1_utilities.js";
|
|
3
2
|
export declare abstract class Transport {
|
|
4
3
|
protected initialized: boolean;
|
|
5
4
|
protected obfuscationParameters: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bufferFromBigInt, concat } from "../
|
|
1
|
+
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
2
2
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
3
3
|
import { Transport } from "./0_transport.js";
|
|
4
4
|
export class TransportAbridged extends Transport {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection } from "../
|
|
1
|
+
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export declare class TransportIntermediate extends Transport implements Transport {
|
|
4
4
|
private readonly connection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bufferFromBigInt, concat } from "../
|
|
1
|
+
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
2
2
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
3
3
|
import { Transport } from "./0_transport.js";
|
|
4
4
|
export class TransportIntermediate extends Transport {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Connection } from "../
|
|
1
|
+
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export type DC = "1" | "2" | "3" | "4" | "5" | "1-test" | "2-test" | "3-test";
|
|
4
4
|
export interface TransportProviderParams {
|
package/esm/types/!0_file_id.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Direct port from Pyrogram
|
|
2
|
-
import { base64DecodeUrlSafe, base64EncodeUrlSafe } from "../
|
|
3
|
-
import {
|
|
4
|
-
import { rleDecode, rleEncode } from "../utilities/0_rle.js";
|
|
5
|
-
import { TLRawWriter } from "../tl/0_tl_raw_writer.js";
|
|
6
|
-
import { TLRawReader } from "../tl/0_tl_raw_reader.js";
|
|
2
|
+
import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode, UNREACHABLE } from "../1_utilities.js";
|
|
3
|
+
import { TLReader, TLWriter } from "../2_tl.js";
|
|
7
4
|
export var FileType;
|
|
8
5
|
(function (FileType) {
|
|
9
6
|
FileType[FileType["Thumbnail"] = 0] = "Thumbnail";
|
|
@@ -96,7 +93,7 @@ class FileID {
|
|
|
96
93
|
minor = decoded[decoded.length - 2];
|
|
97
94
|
buffer = decoded.slice(0, -2);
|
|
98
95
|
}
|
|
99
|
-
const reader = new
|
|
96
|
+
const reader = new TLReader(buffer);
|
|
100
97
|
let fileType = reader.readInt32();
|
|
101
98
|
const dcId = reader.readInt32();
|
|
102
99
|
const hasWebLocation = Boolean(fileType & WEB_LOCATION_FLAG);
|
|
@@ -159,7 +156,7 @@ class FileID {
|
|
|
159
156
|
encode(major, minor) {
|
|
160
157
|
major ??= this.major;
|
|
161
158
|
minor ??= this.minor;
|
|
162
|
-
const writer = new
|
|
159
|
+
const writer = new TLWriter();
|
|
163
160
|
let fileType = this.fileType;
|
|
164
161
|
if (this.params.url) {
|
|
165
162
|
fileType |= WEB_LOCATION_FLAG;
|
|
@@ -274,7 +271,7 @@ export class FileUniqueID {
|
|
|
274
271
|
});
|
|
275
272
|
}
|
|
276
273
|
static decode(fileId) {
|
|
277
|
-
const reader = new
|
|
274
|
+
const reader = new TLReader(rleDecode(base64DecodeUrlSafe(fileId)));
|
|
278
275
|
const fileUniqueType = reader.readInt32();
|
|
279
276
|
switch (fileUniqueType) {
|
|
280
277
|
case FileUniqueType.Web: {
|
|
@@ -295,7 +292,7 @@ export class FileUniqueID {
|
|
|
295
292
|
}
|
|
296
293
|
}
|
|
297
294
|
encode() {
|
|
298
|
-
const writer = new
|
|
295
|
+
const writer = new TLWriter();
|
|
299
296
|
writer.writeInt32(this.fileUniqueType);
|
|
300
297
|
switch (this.fileUniqueType) {
|
|
301
298
|
case FileUniqueType.Web:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { types } from "../2_tl.js";
|
|
3
|
+
export interface EntityGetter {
|
|
4
|
+
(peer: types.PeerUser): MaybePromise<types.User | null>;
|
|
5
|
+
(peer: types.PeerChat): MaybePromise<types.Chat | null>;
|
|
6
|
+
(peer: types.PeerChannel): MaybePromise<types.Channel | null>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/types/0_audio.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
2
|
import { Thumbnail } from "./0_thumbnail.js";
|
|
3
3
|
/** This object represents an audio file to be treated as music by the Telegram clients. */
|
|
4
4
|
export interface Audio {
|
|
5
5
|
/** Identifier for this file, which can be used to download or reuse the file */
|
|
6
6
|
fileId: string;
|
|
7
|
-
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
|
|
7
|
+
/** Unique identifier for this file, which is supposed to be the same over time and for different users and bots. Can't be used to download or reuse the file. */
|
|
8
8
|
fileUniqueId: string;
|
|
9
9
|
/** Duration of the audio in seconds as defined by sender */
|
|
10
10
|
duration: number;
|
|
@@ -14,7 +14,7 @@ export interface Audio {
|
|
|
14
14
|
title?: string;
|
|
15
15
|
/** MIME type of the file as defined by sender */
|
|
16
16
|
mimeType: string;
|
|
17
|
-
/** File size in bytes
|
|
17
|
+
/** File size in bytes */
|
|
18
18
|
fileSize: number;
|
|
19
19
|
/** Thumbnail of the album cover to which the music file belongs */
|
|
20
20
|
thumbnails: Thumbnail[];
|
package/esm/types/0_audio.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
2
|
export declare namespace ChatPhoto {
|
|
3
3
|
interface Base {
|
|
4
4
|
/** File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */
|
|
5
5
|
smallFileId: string;
|
|
6
|
-
/** Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
|
|
6
|
+
/** Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different users and bots. Can't be used to download or reuse the file. */
|
|
7
7
|
smallFileUniqueId: string;
|
|
8
8
|
/** File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed. */
|
|
9
9
|
bigFileId: string;
|
|
10
|
-
/** Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
|
|
10
|
+
/** Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different users and bots. Can't be used to download or reuse the file. */
|
|
11
11
|
bigFileUniqueId: string;
|
|
12
12
|
/** True, if an [animated profile picture](https://core.telegram.org/api/files#animated-profile-pictures) is available for the user */
|
|
13
13
|
hasVideo: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
2
|
import { FileID, FileType, FileUniqueID, FileUniqueType, ThumbnailSource } from "./!0_file_id.js";
|
|
3
3
|
export function constructChatPhoto(photo, chatId, chatAccessHash) {
|
|
4
4
|
const smallFileId = new FileID(null, null, FileType.ChatPhoto, photo.dcId, {
|
package/esm/types/0_contact.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
2
|
/** This object represents a phone contact. */
|
|
3
3
|
export interface Contact {
|
|
4
4
|
/** Contact's phone number */
|
|
@@ -7,7 +7,7 @@ export interface Contact {
|
|
|
7
7
|
firstName: string;
|
|
8
8
|
/** Contact's last name */
|
|
9
9
|
lastName?: string;
|
|
10
|
-
/** Contact's user identifier in Telegram
|
|
10
|
+
/** Contact's user identifier in Telegram */
|
|
11
11
|
userId?: number;
|
|
12
12
|
/** Additional data about the contact in the form of a [vCard](https://en.wikipedia.org/wiki/VCard) */
|
|
13
13
|
vcard?: string;
|
package/esm/types/0_dice.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { types } from "../2_tl.js";
|
|
2
2
|
/** Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. */
|
|
3
3
|
export interface ForceReply {
|
|
4
4
|
/** Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply' */
|