@mtkruto/node 0.0.990 → 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 +43 -18
- package/esm/client/3_client.js +107 -46
- 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 +23 -23
- package/esm/types/3_message.js +19 -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 +43 -18
- package/script/client/3_client.js +342 -305
- 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 +23 -23
- package/script/types/3_message.js +97 -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
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ClientPlain = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const _0_control_js_1 = require("../utilities/0_control.js");
|
|
9
|
-
const _0_hash_js_1 = require("../utilities/0_hash.js");
|
|
10
|
-
const _1_auth_js_1 = require("../utilities/1_auth.js");
|
|
11
|
-
const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
|
|
12
|
-
const _2_types_js_1 = require("../tl/2_types.js");
|
|
13
|
-
const _3_functions_js_1 = require("../tl/3_functions.js");
|
|
14
|
-
const _3_tl_reader_js_1 = require("../tl/3_tl_reader.js");
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
6
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
7
|
+
const _4_constants_js_1 = require("../4_constants.js");
|
|
15
8
|
const _1_client_abstract_js_1 = require("./1_client_abstract.js");
|
|
16
9
|
const _0_message_js_1 = require("./0_message.js");
|
|
17
|
-
const d = (0,
|
|
10
|
+
const d = (0, _0_deps_js_1.debug)("ClientPlain/createAuthKey");
|
|
18
11
|
class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
19
12
|
constructor(params) {
|
|
20
13
|
super(params);
|
|
@@ -30,35 +23,35 @@ class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
30
23
|
writable: true,
|
|
31
24
|
value: 0n
|
|
32
25
|
});
|
|
33
|
-
this.publicKeys = params?.publicKeys ??
|
|
26
|
+
this.publicKeys = params?.publicKeys ?? _4_constants_js_1.PUBLIC_KEYS;
|
|
34
27
|
}
|
|
35
28
|
async invoke(function_) {
|
|
36
29
|
if (!this.transport) {
|
|
37
30
|
throw new Error("Not connected");
|
|
38
31
|
}
|
|
39
32
|
const msgId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
|
|
40
|
-
await this.transport.transport.send((0, _0_message_js_1.packUnencryptedMessage)(function_[
|
|
33
|
+
await this.transport.transport.send((0, _0_message_js_1.packUnencryptedMessage)(function_[_2_tl_js_1.serialize](), msgId));
|
|
41
34
|
const buffer = await this.transport.transport.receive();
|
|
42
35
|
if (buffer.length == 4) {
|
|
43
|
-
const int = (0,
|
|
36
|
+
const int = (0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, true);
|
|
44
37
|
if (int == -404n) {
|
|
45
38
|
throw new Error("-404");
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
41
|
const { message } = (0, _0_message_js_1.unpackUnencryptedMessage)(buffer);
|
|
49
|
-
const reader = new
|
|
42
|
+
const reader = new _2_tl_js_1.TLReader(message);
|
|
50
43
|
return reader.readObject();
|
|
51
44
|
}
|
|
52
45
|
async createAuthKey() {
|
|
53
|
-
const nonce = (0,
|
|
46
|
+
const nonce = (0, _1_utilities_js_1.getRandomBigInt)(16, false, true);
|
|
54
47
|
d("auth key creation started");
|
|
55
48
|
let resPq = null;
|
|
56
49
|
for (let i = 0; i < 10; i++) {
|
|
57
50
|
try {
|
|
58
51
|
d("req_pq_multi [%d]", i + 1);
|
|
59
|
-
resPq = await this.invoke(new
|
|
60
|
-
(0,
|
|
61
|
-
(0,
|
|
52
|
+
resPq = await this.invoke(new _2_tl_js_1.functions.ReqPQMulti({ nonce }));
|
|
53
|
+
(0, _0_deps_js_1.assertInstanceOf)(resPq, _2_tl_js_1.types.ResPQ);
|
|
54
|
+
(0, _0_deps_js_1.assertEquals)(resPq.nonce, nonce);
|
|
62
55
|
d("got res_pq");
|
|
63
56
|
break;
|
|
64
57
|
}
|
|
@@ -67,13 +60,13 @@ class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
67
60
|
}
|
|
68
61
|
}
|
|
69
62
|
if (!resPq) {
|
|
70
|
-
(0,
|
|
63
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
71
64
|
}
|
|
72
|
-
const pq_ = (0,
|
|
73
|
-
const [p_, q_] = (0,
|
|
65
|
+
const pq_ = (0, _1_utilities_js_1.bigIntFromBuffer)(resPq.pq, false, false);
|
|
66
|
+
const [p_, q_] = (0, _0_deps_js_1.factorize)(pq_);
|
|
74
67
|
d("factorized pq");
|
|
75
|
-
const p = (0,
|
|
76
|
-
const q = (0,
|
|
68
|
+
const p = (0, _1_utilities_js_1.bufferFromBigInt)(p_, 4, false, false);
|
|
69
|
+
const q = (0, _1_utilities_js_1.bufferFromBigInt)(q_, 4, false, false);
|
|
77
70
|
let publicKeyFingerprint;
|
|
78
71
|
let publicKey;
|
|
79
72
|
for (const fingerprint of resPq.serverPublicKeyFingerprints) {
|
|
@@ -90,8 +83,8 @@ class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
90
83
|
const dc = this.dcId;
|
|
91
84
|
const pq = resPq.pq;
|
|
92
85
|
const serverNonce = resPq.serverNonce;
|
|
93
|
-
const newNonce = (0,
|
|
94
|
-
let encryptedData = await (0,
|
|
86
|
+
const newNonce = (0, _1_utilities_js_1.getRandomBigInt)(32, false, true);
|
|
87
|
+
let encryptedData = await (0, _1_utilities_js_1.rsaPad)(new _2_tl_js_1.types.PQInnerDataDC({
|
|
95
88
|
pq,
|
|
96
89
|
p,
|
|
97
90
|
q,
|
|
@@ -99,8 +92,8 @@ class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
99
92
|
newNonce,
|
|
100
93
|
nonce,
|
|
101
94
|
serverNonce,
|
|
102
|
-
})[
|
|
103
|
-
const dhParams = await this.invoke(new
|
|
95
|
+
})[_2_tl_js_1.serialize](), publicKey);
|
|
96
|
+
const dhParams = await this.invoke(new _2_tl_js_1.functions.ReqDHParams({
|
|
104
97
|
nonce,
|
|
105
98
|
serverNonce,
|
|
106
99
|
p,
|
|
@@ -108,42 +101,42 @@ class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
108
101
|
publicKeyFingerprint,
|
|
109
102
|
encryptedData,
|
|
110
103
|
}));
|
|
111
|
-
(0,
|
|
104
|
+
(0, _0_deps_js_1.assertInstanceOf)(dhParams, _2_tl_js_1.types.ServerDHParamsOK);
|
|
112
105
|
d("got server_DH_params_ok");
|
|
113
|
-
const newNonce_ = (0,
|
|
114
|
-
const serverNonce_ = (0,
|
|
115
|
-
const tmpAesKey = (0,
|
|
116
|
-
const tmpAesIv = (0,
|
|
117
|
-
const answerWithHash = (0,
|
|
118
|
-
const dhInnerData = new
|
|
119
|
-
(0,
|
|
106
|
+
const newNonce_ = (0, _1_utilities_js_1.bufferFromBigInt)(newNonce, 32, true, true);
|
|
107
|
+
const serverNonce_ = (0, _1_utilities_js_1.bufferFromBigInt)(serverNonce, 16, true, true);
|
|
108
|
+
const tmpAesKey = (0, _1_utilities_js_1.concat)(await (0, _1_utilities_js_1.sha1)((0, _1_utilities_js_1.concat)(newNonce_, serverNonce_)), (await (0, _1_utilities_js_1.sha1)((0, _1_utilities_js_1.concat)(serverNonce_, newNonce_))).slice(0, 0 + 12));
|
|
109
|
+
const tmpAesIv = (0, _1_utilities_js_1.concat)((await (0, _1_utilities_js_1.sha1)((0, _1_utilities_js_1.concat)(serverNonce_, newNonce_))).slice(12, 12 + 8), await (0, _1_utilities_js_1.sha1)((0, _1_utilities_js_1.concat)(newNonce_, newNonce_)), newNonce_.slice(0, 0 + 4));
|
|
110
|
+
const answerWithHash = (0, _0_deps_js_1.ige256Decrypt)(dhParams.encryptedAnswer, tmpAesKey, tmpAesIv);
|
|
111
|
+
const dhInnerData = new _2_tl_js_1.TLReader(answerWithHash.slice(20)).readObject();
|
|
112
|
+
(0, _0_deps_js_1.assertInstanceOf)(dhInnerData, _2_tl_js_1.types.ServerDHInnerData);
|
|
120
113
|
const { g, gA: gA_, dhPrime: dhPrime_ } = dhInnerData;
|
|
121
|
-
const gA = (0,
|
|
122
|
-
const dhPrime = (0,
|
|
123
|
-
const b = (0,
|
|
124
|
-
const gB = (0,
|
|
125
|
-
const data = new
|
|
114
|
+
const gA = (0, _1_utilities_js_1.bigIntFromBuffer)(gA_, false, false);
|
|
115
|
+
const dhPrime = (0, _1_utilities_js_1.bigIntFromBuffer)(dhPrime_, false, false);
|
|
116
|
+
const b = (0, _1_utilities_js_1.getRandomBigInt)(256, false, false);
|
|
117
|
+
const gB = (0, _1_utilities_js_1.modExp)(BigInt(g), b, dhPrime);
|
|
118
|
+
const data = new _2_tl_js_1.types.ClientDHInnerData({
|
|
126
119
|
nonce,
|
|
127
120
|
serverNonce,
|
|
128
121
|
retryId: 0n,
|
|
129
|
-
gB: (0,
|
|
130
|
-
})[
|
|
131
|
-
let dataWithHash = (0,
|
|
122
|
+
gB: (0, _1_utilities_js_1.bufferFromBigInt)(gB, 256, false, false),
|
|
123
|
+
})[_2_tl_js_1.serialize]();
|
|
124
|
+
let dataWithHash = (0, _1_utilities_js_1.concat)(await (0, _1_utilities_js_1.sha1)(data), data);
|
|
132
125
|
while (dataWithHash.length % 16 != 0) {
|
|
133
|
-
dataWithHash = (0,
|
|
126
|
+
dataWithHash = (0, _1_utilities_js_1.concat)(dataWithHash, new Uint8Array(1));
|
|
134
127
|
}
|
|
135
|
-
encryptedData = (0,
|
|
136
|
-
const dhGenOk = await this.invoke(new
|
|
137
|
-
(0,
|
|
128
|
+
encryptedData = (0, _0_deps_js_1.ige256Encrypt)(dataWithHash, tmpAesKey, tmpAesIv);
|
|
129
|
+
const dhGenOk = await this.invoke(new _2_tl_js_1.functions.SetClientDHParams({ nonce, serverNonce, encryptedData }));
|
|
130
|
+
(0, _0_deps_js_1.assertInstanceOf)(dhGenOk, _2_tl_js_1.types.DHGenOK);
|
|
138
131
|
d("got dh_gen_ok");
|
|
139
132
|
const serverNonceSlice = serverNonce_.slice(0, 8);
|
|
140
133
|
const salt = newNonce_.slice(0, 0 + 8).map((v, i) => v ^ serverNonceSlice[i]);
|
|
141
|
-
const authKey_ = (0,
|
|
142
|
-
const authKey = (0,
|
|
134
|
+
const authKey_ = (0, _1_utilities_js_1.modExp)(gA, b, dhPrime);
|
|
135
|
+
const authKey = (0, _1_utilities_js_1.bufferFromBigInt)(authKey_, 256, false, false);
|
|
143
136
|
d("auth key created");
|
|
144
137
|
return {
|
|
145
138
|
authKey,
|
|
146
|
-
salt: (0,
|
|
139
|
+
salt: (0, _1_utilities_js_1.bigIntFromBuffer)(salt, true, false),
|
|
147
140
|
};
|
|
148
141
|
}
|
|
149
142
|
}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import { MaybePromise } from "../
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import { MessageEntity } from "../types/0_message_entity.js";
|
|
8
|
-
import { ForceReply } from "../types/0_force_reply.js";
|
|
9
|
-
import { InlineKeyboardMarkup } from "../types/2_inline_keyboard_markup.js";
|
|
10
|
-
import { ReplyKeyboardMarkup } from "../types/2_reply_keyboard_markup.js";
|
|
11
|
-
import { Message } from "../types/3_message.js";
|
|
12
|
-
import { Storage } from "../storage/0_storage.js";
|
|
1
|
+
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { functions, ReadObject, types } from "../2_tl.js";
|
|
3
|
+
import { Storage } from "../3_storage.js";
|
|
4
|
+
import { DC } from "../3_transport.js";
|
|
5
|
+
import { CallbackQuery, ForceReply, InlineKeyboardMarkup, InlineQuery, Message, // high-level Telegram API message
|
|
6
|
+
MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
13
7
|
import { ClientPlainParams } from "./2_client_plain.js";
|
|
14
8
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
15
9
|
export declare const getEntity: unique symbol;
|
|
16
10
|
export declare const getStickerSetName: unique symbol;
|
|
17
11
|
export declare const handleMigrationError: unique symbol;
|
|
12
|
+
export declare const getMessageWithReply: unique symbol;
|
|
18
13
|
export declare const restartAuth: unique symbol;
|
|
19
14
|
export declare enum ParseMode {
|
|
20
15
|
None = "none",
|
|
@@ -59,6 +54,16 @@ export interface ClientParams extends ClientPlainParams {
|
|
|
59
54
|
*/
|
|
60
55
|
autoStart?: boolean;
|
|
61
56
|
}
|
|
57
|
+
export interface AnswerCallbackQueryParams {
|
|
58
|
+
/** Text of the answer */
|
|
59
|
+
text?: string;
|
|
60
|
+
/** Pass true to show an alert to the user instead of a toast notification */
|
|
61
|
+
alert?: boolean;
|
|
62
|
+
/** URL to be opened */
|
|
63
|
+
url?: string;
|
|
64
|
+
/** Time during which the result of the query can be cached, in seconds */
|
|
65
|
+
cacheTime?: number;
|
|
66
|
+
}
|
|
62
67
|
/**
|
|
63
68
|
* A chat identifier as provided by MTKruto or a string starting with a @ that is followed by a username.
|
|
64
69
|
*/
|
|
@@ -93,11 +98,11 @@ export interface SendMessagesParams {
|
|
|
93
98
|
*/
|
|
94
99
|
messageThreadId?: number;
|
|
95
100
|
/**
|
|
96
|
-
* The identifier of the chat to send the message on behalf of.
|
|
101
|
+
* The identifier of the chat to send the message on behalf of. User-only.
|
|
97
102
|
*/
|
|
98
103
|
sendAs?: ChatID;
|
|
99
104
|
/**
|
|
100
|
-
* The reply markup of the message.
|
|
105
|
+
* The reply markup of the message. Bot-only.
|
|
101
106
|
*/
|
|
102
107
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
103
108
|
}
|
|
@@ -115,7 +120,7 @@ export interface EditMessageParams {
|
|
|
115
120
|
*/
|
|
116
121
|
disableWebPagePreview?: boolean;
|
|
117
122
|
/**
|
|
118
|
-
* The reply markup of the message.
|
|
123
|
+
* The reply markup of the message. Bot-only.
|
|
119
124
|
*/
|
|
120
125
|
replyMarkup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply;
|
|
121
126
|
}
|
|
@@ -130,7 +135,7 @@ export interface ForwardMessagesParams {
|
|
|
130
135
|
*/
|
|
131
136
|
protectContent?: boolean;
|
|
132
137
|
/**
|
|
133
|
-
* The identifier of the chat to forward the message on behalf of.
|
|
138
|
+
* The identifier of the chat to forward the message on behalf of. User-only.
|
|
134
139
|
*/
|
|
135
140
|
sendAs?: ChatID;
|
|
136
141
|
/**
|
|
@@ -194,6 +199,8 @@ export declare class Client extends ClientAbstract {
|
|
|
194
199
|
private connectionInited;
|
|
195
200
|
disconnect(): Promise<void>;
|
|
196
201
|
private initConnection;
|
|
202
|
+
private lastPropagatedAuthorizationState;
|
|
203
|
+
private propagateAuthorizationState;
|
|
197
204
|
/**
|
|
198
205
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
199
206
|
*
|
|
@@ -243,7 +250,10 @@ export declare class Client extends ClientAbstract {
|
|
|
243
250
|
private getLocalState;
|
|
244
251
|
private recoverUpdateGap;
|
|
245
252
|
private recoverChannelUpdateGap;
|
|
253
|
+
private getUserAccessHash;
|
|
254
|
+
private getChannelAccessHash;
|
|
246
255
|
getInputPeer(id: ChatID): Promise<types.InputPeerChat | types.InputPeerUser | types.InputPeerChannel>;
|
|
256
|
+
private getInputPeerInner;
|
|
247
257
|
[getEntity](peer: types.PeerUser): Promise<types.User | null>;
|
|
248
258
|
[getEntity](peer: types.PeerChat): Promise<types.Chat | null>;
|
|
249
259
|
[getEntity](peer: types.PeerChannel): Promise<types.Channel | null>;
|
|
@@ -264,6 +274,7 @@ export declare class Client extends ClientAbstract {
|
|
|
264
274
|
* @param text The new text of the message.
|
|
265
275
|
*/
|
|
266
276
|
editMessageText(chatId: ChatID, messageId: number, text: string, params?: EditMessageParams): Promise<void>;
|
|
277
|
+
private getMessagesInner;
|
|
267
278
|
/**
|
|
268
279
|
* Retrieve multiple messages.
|
|
269
280
|
*
|
|
@@ -271,6 +282,7 @@ export declare class Client extends ClientAbstract {
|
|
|
271
282
|
* @param messageIds The identifiers of the messages to retrieve.
|
|
272
283
|
*/
|
|
273
284
|
getMessages(chatId_: ChatID, messageIds: number[]): Promise<Omit<Message, "replyToMessage">[]>;
|
|
285
|
+
[getMessageWithReply](chatId: ChatID, messageId: number): Promise<Message | null>;
|
|
274
286
|
/**
|
|
275
287
|
* Retrieve a single message.
|
|
276
288
|
*
|
|
@@ -305,21 +317,34 @@ export declare class Client extends ClientAbstract {
|
|
|
305
317
|
/**
|
|
306
318
|
* Get information on the currently authorized user.
|
|
307
319
|
*/
|
|
308
|
-
getMe(): Promise<import("../
|
|
320
|
+
getMe(): Promise<import("../3_types.js").User>;
|
|
309
321
|
private handleUpdate;
|
|
310
322
|
handler: Handler;
|
|
311
323
|
use(middleware: Handler): void;
|
|
312
|
-
on<U extends keyof Update, K extends keyof Update[U]>(filter:
|
|
324
|
+
on<U extends keyof Update, K extends keyof Update[U]>(filter: U extends FilterableUpdates ? U | [U, K, ...K[]] : U, handler: Handler<Pick<{
|
|
313
325
|
[P in U]: With<Update[U], K>;
|
|
314
326
|
}, U>>): void;
|
|
327
|
+
/**
|
|
328
|
+
* Answer a callback query. Bot-only.
|
|
329
|
+
*
|
|
330
|
+
* @param id ID of the callback query to answer.
|
|
331
|
+
*/
|
|
332
|
+
answerCallbackQuery(id: string, params?: AnswerCallbackQueryParams): Promise<void>;
|
|
315
333
|
}
|
|
316
334
|
type With<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
317
335
|
export type ConnectionState = "not-connected" | "updating" | "ready";
|
|
336
|
+
export type AuthorizationState = {
|
|
337
|
+
authorized: boolean;
|
|
338
|
+
};
|
|
339
|
+
type FilterableUpdates = "message" | "editedMessage" | "callbackQuery";
|
|
318
340
|
export interface Update {
|
|
319
341
|
message: Message;
|
|
320
342
|
editedMessage: Message;
|
|
321
343
|
connectionState: ConnectionState;
|
|
344
|
+
authorizationState: AuthorizationState;
|
|
322
345
|
deletedMessages: [Message, ...Message[]];
|
|
346
|
+
callbackQuery: CallbackQuery;
|
|
347
|
+
inlineQuery: InlineQuery;
|
|
323
348
|
}
|
|
324
349
|
export interface Handler<U extends Partial<Update> = Partial<Update>> {
|
|
325
350
|
(update: U, next: () => Promise<void>): MaybePromise<void>;
|