@mtkruto/node 0.60.0 → 0.62.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/2_tl.d.ts +4 -6
- package/esm/2_tl.d.ts.map +1 -1
- package/esm/2_tl.js +4 -6
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +9 -9
- package/esm/client/1_client_encrypted.d.ts.map +1 -1
- package/esm/client/1_client_encrypted.js +173 -126
- package/esm/client/1_client_plain.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +12 -8
- package/esm/tl/0_api.d.ts +1 -2
- package/esm/tl/0_api.d.ts.map +1 -1
- package/esm/tl/0_api.js +7345 -6639
- package/esm/tl/0_tl_raw_reader.d.ts +2 -0
- package/esm/tl/0_tl_raw_reader.d.ts.map +1 -1
- package/esm/tl/0_tl_raw_reader.js +10 -0
- package/esm/tl/1_utilities.d.ts +10 -1
- package/esm/tl/1_utilities.d.ts.map +1 -1
- package/esm/tl/1_utilities.js +25 -1
- package/esm/tl/{5_message.d.ts → 2_message.d.ts} +5 -8
- package/esm/tl/2_message.d.ts.map +1 -0
- package/esm/tl/{5_message.js → 2_message.js} +16 -33
- package/esm/tl/{3_tl_reader.d.ts → 2_tl_reader.d.ts} +4 -3
- package/esm/tl/2_tl_reader.d.ts.map +1 -0
- package/esm/tl/2_tl_reader.js +146 -0
- package/esm/tl/2_tl_reader_test.d.ts.map +1 -0
- package/{script/tl/4_tl_writer.d.ts → esm/tl/2_tl_writer.d.ts} +4 -3
- package/esm/tl/2_tl_writer.d.ts.map +1 -0
- package/esm/tl/2_tl_writer.js +206 -0
- package/esm/tl/2_tl_writer_test.d.ts.map +1 -0
- package/{script/tl/3_utilities.d.ts → esm/tl/2_utilities.d.ts} +1 -1
- package/esm/tl/{3_utilities.d.ts.map → 2_utilities.d.ts.map} +1 -1
- package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
- package/esm/types/2_chosen_inline_result.js +2 -2
- package/esm/types/5_callback_query.d.ts.map +1 -1
- package/esm/types/5_callback_query.js +3 -3
- package/esm/utilities/0_misc.d.ts +0 -1
- package/esm/utilities/0_misc.d.ts.map +1 -1
- package/esm/utilities/0_misc.js +0 -1
- package/package.json +1 -1
- package/script/2_tl.d.ts +4 -6
- package/script/2_tl.d.ts.map +1 -1
- package/script/2_tl.js +4 -6
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +8 -8
- package/script/client/1_client_encrypted.d.ts.map +1 -1
- package/script/client/1_client_encrypted.js +171 -124
- package/script/client/1_client_plain.d.ts.map +1 -1
- package/script/client/1_client_plain.js +11 -7
- package/script/tl/0_api.d.ts +1 -2
- package/script/tl/0_api.d.ts.map +1 -1
- package/script/tl/0_api.js +7346 -6640
- package/script/tl/0_tl_raw_reader.d.ts +2 -0
- package/script/tl/0_tl_raw_reader.d.ts.map +1 -1
- package/script/tl/0_tl_raw_reader.js +10 -0
- package/script/tl/1_utilities.d.ts +10 -1
- package/script/tl/1_utilities.d.ts.map +1 -1
- package/script/tl/1_utilities.js +29 -1
- package/script/tl/{5_message.d.ts → 2_message.d.ts} +5 -8
- package/script/tl/2_message.d.ts.map +1 -0
- package/script/tl/{5_message.js → 2_message.js} +17 -34
- package/script/tl/{3_tl_reader.d.ts → 2_tl_reader.d.ts} +4 -3
- package/script/tl/2_tl_reader.d.ts.map +1 -0
- package/script/tl/2_tl_reader.js +150 -0
- package/script/tl/2_tl_reader_test.d.ts.map +1 -0
- package/{esm/tl/4_tl_writer.d.ts → script/tl/2_tl_writer.d.ts} +4 -3
- package/script/tl/2_tl_writer.d.ts.map +1 -0
- package/script/tl/2_tl_writer.js +210 -0
- package/script/tl/2_tl_writer_test.d.ts.map +1 -0
- package/{esm/tl/3_utilities.d.ts → script/tl/2_utilities.d.ts} +1 -1
- package/script/tl/{3_utilities.d.ts.map → 2_utilities.d.ts.map} +1 -1
- package/script/types/2_chosen_inline_result.d.ts.map +1 -1
- package/script/types/2_chosen_inline_result.js +1 -1
- package/script/types/5_callback_query.d.ts.map +1 -1
- package/script/types/5_callback_query.js +2 -2
- package/script/utilities/0_misc.d.ts +0 -1
- package/script/utilities/0_misc.d.ts.map +1 -1
- package/script/utilities/0_misc.js +1 -2
- package/esm/tl/2_deserialize.d.ts +0 -23
- package/esm/tl/2_deserialize.d.ts.map +0 -1
- package/esm/tl/2_deserialize.js +0 -98
- package/esm/tl/2_serialize.d.ts +0 -22
- package/esm/tl/2_serialize.d.ts.map +0 -1
- package/esm/tl/2_serialize.js +0 -163
- package/esm/tl/2_serialize_test.d.ts.map +0 -1
- package/esm/tl/3_deserialize_test.d.ts.map +0 -1
- package/esm/tl/3_tl_reader.d.ts.map +0 -1
- package/esm/tl/3_tl_reader.js +0 -49
- package/esm/tl/4_rpc_result.d.ts +0 -27
- package/esm/tl/4_rpc_result.d.ts.map +0 -1
- package/esm/tl/4_rpc_result.js +0 -33
- package/esm/tl/4_tl_writer.d.ts.map +0 -1
- package/esm/tl/4_tl_writer.js +0 -45
- package/esm/tl/5_message.d.ts.map +0 -1
- package/script/tl/2_deserialize.d.ts +0 -23
- package/script/tl/2_deserialize.d.ts.map +0 -1
- package/script/tl/2_deserialize.js +0 -101
- package/script/tl/2_serialize.d.ts +0 -22
- package/script/tl/2_serialize.d.ts.map +0 -1
- package/script/tl/2_serialize.js +0 -166
- package/script/tl/2_serialize_test.d.ts.map +0 -1
- package/script/tl/3_deserialize_test.d.ts.map +0 -1
- package/script/tl/3_tl_reader.d.ts.map +0 -1
- package/script/tl/3_tl_reader.js +0 -53
- package/script/tl/4_rpc_result.d.ts +0 -27
- package/script/tl/4_rpc_result.d.ts.map +0 -1
- package/script/tl/4_rpc_result.js +0 -37
- package/script/tl/4_tl_writer.d.ts.map +0 -1
- package/script/tl/4_tl_writer.js +0 -49
- package/script/tl/5_message.d.ts.map +0 -1
- /package/esm/tl/{3_utilities.js → 2_utilities.js} +0 -0
- /package/script/tl/{3_utilities.js → 2_utilities.js} +0 -0
package/esm/2_tl.d.ts
CHANGED
|
@@ -20,10 +20,8 @@
|
|
|
20
20
|
export { TLError } from "./tl/0_tl_raw_reader.js";
|
|
21
21
|
export * as Api from "./tl/0_api.js";
|
|
22
22
|
export * from "./tl/1_utilities.js";
|
|
23
|
-
export * from "./tl/
|
|
24
|
-
export * from "./tl/
|
|
25
|
-
export * from "./tl/
|
|
26
|
-
export * from "./tl/
|
|
27
|
-
export * from "./tl/4_rpc_result.js";
|
|
28
|
-
export * from "./tl/5_message.js";
|
|
23
|
+
export * from "./tl/2_utilities.js";
|
|
24
|
+
export * from "./tl/2_message.js";
|
|
25
|
+
export * from "./tl/2_tl_reader.js";
|
|
26
|
+
export * from "./tl/2_tl_writer.js";
|
|
29
27
|
//# sourceMappingURL=2_tl.d.ts.map
|
package/esm/2_tl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_tl.d.ts","sourceRoot":"","sources":["../src/2_tl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,
|
|
1
|
+
{"version":3,"file":"2_tl.d.ts","sourceRoot":"","sources":["../src/2_tl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
package/esm/2_tl.js
CHANGED
|
@@ -20,9 +20,7 @@
|
|
|
20
20
|
export { TLError } from "./tl/0_tl_raw_reader.js";
|
|
21
21
|
export * as Api from "./tl/0_api.js";
|
|
22
22
|
export * from "./tl/1_utilities.js";
|
|
23
|
-
export * from "./tl/
|
|
24
|
-
export * from "./tl/
|
|
25
|
-
export * from "./tl/
|
|
26
|
-
export * from "./tl/
|
|
27
|
-
export * from "./tl/4_rpc_result.js";
|
|
28
|
-
export * from "./tl/5_message.js";
|
|
23
|
+
export * from "./tl/2_utilities.js";
|
|
24
|
+
export * from "./tl/2_message.js";
|
|
25
|
+
export * from "./tl/2_tl_reader.js";
|
|
26
|
+
export * from "./tl/2_tl_writer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_storage_operations.d.ts","sourceRoot":"","sources":["../../src/client/0_storage_operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAA8D,YAAY,EAA+C,MAAM,mBAAmB,CAAC;AAC1J,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAqC,UAAU,
|
|
1
|
+
{"version":3,"file":"0_storage_operations.d.ts","sourceRoot":"","sources":["../../src/client/0_storage_operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAA8D,YAAY,EAA+C,MAAM,mBAAmB,CAAC;AAC1J,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAqC,UAAU,EAAsB,MAAM,YAAY,CAAC;AAC/G,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGhE,eAAO,MAAM,CAAC;;oBAEE,MAAM,KAAG,MAAM;qBAChB,cAAc,EAAE;;;oBAGf,MAAM,KAAG,MAAM;0BACX,cAAc,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IAI/D,iBAAiB;IAQjB,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI;IAItC,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;IAIjD,WAAW;IAQX,qBAAqB,CAAC,kBAAkB,EAAE,kBAAkB;IAI5D,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAIlF,yBAAyB;IAQzB,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM;IAIhH,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIhH,kCAAkC;CAOzC"}
|
|
@@ -32,7 +32,7 @@ var _StorageOperations_instances, _StorageOperations_storage, _StorageOperations
|
|
|
32
32
|
import { unreachable } from "../0_deps.js";
|
|
33
33
|
import { InputError } from "../0_errors.js";
|
|
34
34
|
import { base64DecodeUrlSafe, base64EncodeUrlSafe, bigIntFromBuffer, rleDecode, rleEncode, sha1, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
35
|
-
import { as, is, isValidType, peerToChatId,
|
|
35
|
+
import { as, is, isValidType, peerToChatId, TLReader, TLWriter } from "../2_tl.js";
|
|
36
36
|
// key parts
|
|
37
37
|
export const K = {
|
|
38
38
|
connection: {
|
|
@@ -243,15 +243,15 @@ export class StorageOperations {
|
|
|
243
243
|
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
|
|
244
244
|
}
|
|
245
245
|
else {
|
|
246
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(serialize(value)) : value);
|
|
246
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? [value._, rleEncode(new TLWriter().serialize(value).buffer)] : value);
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
async getTlObject(keyOrBuffer) {
|
|
250
250
|
// @ts-ignore: TBD
|
|
251
251
|
const buffer = (keyOrBuffer instanceof Uint8Array || isValidType(keyOrBuffer)) ? keyOrBuffer : await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(keyOrBuffer);
|
|
252
252
|
if (buffer != null) {
|
|
253
|
-
if (buffer
|
|
254
|
-
return new TLReader(rleDecode(buffer)).
|
|
253
|
+
if (Array.isArray(buffer)) {
|
|
254
|
+
return await new TLReader(rleDecode(buffer[1])).deserialize(buffer[0]);
|
|
255
255
|
}
|
|
256
256
|
else {
|
|
257
257
|
return buffer;
|
|
@@ -299,7 +299,7 @@ export class StorageOperations {
|
|
|
299
299
|
return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.updates.channelPts(channelId));
|
|
300
300
|
}
|
|
301
301
|
async setEntity(entity) {
|
|
302
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.peer(peerToChatId(entity)), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(serialize(entity)) : entity, new Date()]);
|
|
302
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.peer(peerToChatId(entity)), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(new TLWriter().serialize(entity).buffer) : entity, new Date()]);
|
|
303
303
|
}
|
|
304
304
|
async getEntity(key) {
|
|
305
305
|
const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.peer(key));
|
|
@@ -432,7 +432,7 @@ export class StorageOperations {
|
|
|
432
432
|
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.file(id), [partCount, chunkSize]);
|
|
433
433
|
}
|
|
434
434
|
async setCustomEmojiDocument(id, document) {
|
|
435
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(serialize(document)) : document, new Date()]);
|
|
435
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(new TLWriter().serialize(document).buffer) : document, new Date()]);
|
|
436
436
|
}
|
|
437
437
|
async getCustomEmojiDocument(id) {
|
|
438
438
|
const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.customEmojiDocument(id));
|
|
@@ -444,7 +444,7 @@ export class StorageOperations {
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
async setBusinessConnection(id, connection) {
|
|
447
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.businessConnection(id), connection == null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(serialize(connection)) : connection);
|
|
447
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.businessConnection(id), connection == null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(new TLWriter().serialize(connection).buffer) : connection);
|
|
448
448
|
}
|
|
449
449
|
async getBusinessConnection(id) {
|
|
450
450
|
const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.businessConnection(id));
|
|
@@ -456,7 +456,7 @@ export class StorageOperations {
|
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
|
|
459
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(serialize(results)) : results, date]);
|
|
459
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(new TLWriter().serialize(results).buffer) : results, date]);
|
|
460
460
|
}
|
|
461
461
|
async getInlineQueryAnswer(userId, chatId, query, offset) {
|
|
462
462
|
const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.inlineQueryAnswer(userId, chatId, query, offset));
|
|
@@ -469,7 +469,7 @@ export class StorageOperations {
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
async setCallbackQueryAnswer(chatId, messageId, question, answer) {
|
|
472
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(serialize(answer)) : answer, new Date()]);
|
|
472
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(new TLWriter().serialize(answer).buffer) : answer, new Date()]);
|
|
473
473
|
}
|
|
474
474
|
async getCallbackQueryAnswer(chatId, messageId, question) {
|
|
475
475
|
const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.callbackQueryAnswer(chatId, messageId, question));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_client_encrypted.d.ts","sourceRoot":"","sources":["../../src/client/1_client_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"1_client_encrypted.d.ts","sourceRoot":"","sources":["../../src/client/1_client_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,EAAqF,UAAU,EAA0C,MAAM,YAAY,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GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAkQ3R"}
|
|
@@ -28,16 +28,19 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
28
28
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
29
29
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
30
|
};
|
|
31
|
-
var _ClientEncrypted_instances, _ClientEncrypted_authKey, _ClientEncrypted_authKeyId, _ClientEncrypted_sessionId, _ClientEncrypted_state, _ClientEncrypted_shouldInvalidateSession, _ClientEncrypted_toAcknowledge, _ClientEncrypted_recentAcks, _ClientEncrypted_promises, _ClientEncrypted_L, _ClientEncrypted_LreceiveLoop, _ClientEncrypted_Linvoke, _ClientEncrypted_timeDifference, _ClientEncrypted_nextMessageId, _ClientEncrypted_nextSeqNo, _ClientEncrypted_invalidateSession, _ClientEncrypted_sendMessage, _ClientEncrypted_receiveLoop;
|
|
31
|
+
var _ClientEncrypted_instances, _ClientEncrypted_authKey, _ClientEncrypted_authKeyId, _ClientEncrypted_sessionId, _ClientEncrypted_state, _ClientEncrypted_shouldInvalidateSession, _ClientEncrypted_toAcknowledge, _ClientEncrypted_recentAcks, _ClientEncrypted_promises, _ClientEncrypted_loopActive, _ClientEncrypted_L, _ClientEncrypted_LreceiveLoop, _ClientEncrypted_Linvoke, _ClientEncrypted_timeDifference, _ClientEncrypted_nextMessageId, _ClientEncrypted_nextSeqNo, _ClientEncrypted_invalidateSession, _ClientEncrypted_sendMessage, _ClientEncrypted_receiveLoop, _ClientEncrypted_handleIncomingMessage, _ClientEncrypted_handleRpcResult, _ClientEncrypted_handleType;
|
|
32
32
|
import { unreachable } from "../0_deps.js";
|
|
33
33
|
import { ConnectionError } from "../0_errors.js";
|
|
34
|
-
import { bigIntFromBuffer, CacheMap, drop, getLogger, getRandomBigInt, sha1, toUnixTimestamp } from "../1_utilities.js";
|
|
35
|
-
import {
|
|
34
|
+
import { bigIntFromBuffer, CacheMap, drop, getLogger, getRandomBigInt, gunzip, gzip, sha1, toUnixTimestamp } from "../1_utilities.js";
|
|
35
|
+
import { Api, GZIP_PACKED, is, isGenericFunction, isOfEnum, isOneOf, mustGetReturnType, repr, RPC_RESULT, TLError, TLReader, X } from "../2_tl.js";
|
|
36
36
|
import { constructTelegramError } from "../4_errors.js";
|
|
37
|
+
import { TLWriter } from "../tl/2_tl_writer.js";
|
|
37
38
|
import { ClientAbstract } from "./0_client_abstract.js";
|
|
38
39
|
import { decryptMessage, encryptMessage, getMessageId } from "./0_message.js";
|
|
40
|
+
const COMPRESSION_THRESHOLD = 1024;
|
|
39
41
|
// global ClientEncrypted ID counter for logs
|
|
40
42
|
let id = 0;
|
|
43
|
+
const RPC_ERROR = Api.getType("rpc_error")[0];
|
|
41
44
|
/**
|
|
42
45
|
* An MTProto client for making encrypted connections. Most users won't need to interact with this. Used internally by `Client`.
|
|
43
46
|
*
|
|
@@ -61,6 +64,7 @@ export class ClientEncrypted extends ClientAbstract {
|
|
|
61
64
|
_ClientEncrypted_toAcknowledge.set(this, new Array());
|
|
62
65
|
_ClientEncrypted_recentAcks.set(this, new CacheMap(20));
|
|
63
66
|
_ClientEncrypted_promises.set(this, new Map());
|
|
67
|
+
_ClientEncrypted_loopActive.set(this, true);
|
|
64
68
|
// loggers
|
|
65
69
|
_ClientEncrypted_L.set(this, void 0);
|
|
66
70
|
_ClientEncrypted_LreceiveLoop.set(this, void 0);
|
|
@@ -102,13 +106,19 @@ export class ClientEncrypted extends ClientAbstract {
|
|
|
102
106
|
}
|
|
103
107
|
async invoke(function_, noWait) {
|
|
104
108
|
const messageId = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this);
|
|
109
|
+
let body = new TLWriter().serialize(function_).buffer;
|
|
110
|
+
if (body.length > COMPRESSION_THRESHOLD) {
|
|
111
|
+
body = new TLWriter()
|
|
112
|
+
.writeInt32(GZIP_PACKED, false)
|
|
113
|
+
.writeBytes(await gzip(body))
|
|
114
|
+
.buffer;
|
|
115
|
+
}
|
|
105
116
|
let message_ = {
|
|
106
117
|
_: "message",
|
|
107
118
|
msg_id: messageId,
|
|
108
119
|
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, true),
|
|
109
|
-
body
|
|
120
|
+
body,
|
|
110
121
|
};
|
|
111
|
-
Object.assign(message_, { [compressible]: true });
|
|
112
122
|
const message__ = message_;
|
|
113
123
|
let container = undefined;
|
|
114
124
|
if (__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").length) {
|
|
@@ -116,7 +126,7 @@ export class ClientEncrypted extends ClientAbstract {
|
|
|
116
126
|
_: "message",
|
|
117
127
|
msg_id: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this),
|
|
118
128
|
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, false),
|
|
119
|
-
body: { _: "msgs_ack", msg_ids: __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").splice(0, 8192) },
|
|
129
|
+
body: new TLWriter().serialize({ _: "msgs_ack", msg_ids: __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").splice(0, 8192) }).buffer,
|
|
120
130
|
};
|
|
121
131
|
__classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").set(ack.msg_id, { container, message: ack });
|
|
122
132
|
message_ = {
|
|
@@ -144,7 +154,7 @@ export class ClientEncrypted extends ClientAbstract {
|
|
|
144
154
|
}));
|
|
145
155
|
}
|
|
146
156
|
}
|
|
147
|
-
_ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakMap(), _ClientEncrypted_sessionId = new WeakMap(), _ClientEncrypted_state = new WeakMap(), _ClientEncrypted_shouldInvalidateSession = new WeakMap(), _ClientEncrypted_toAcknowledge = new WeakMap(), _ClientEncrypted_recentAcks = new WeakMap(), _ClientEncrypted_promises = new WeakMap(), _ClientEncrypted_L = new WeakMap(), _ClientEncrypted_LreceiveLoop = new WeakMap(), _ClientEncrypted_Linvoke = new WeakMap(), _ClientEncrypted_timeDifference = new WeakMap(), _ClientEncrypted_instances = new WeakSet(), _ClientEncrypted_nextMessageId = function _ClientEncrypted_nextMessageId() {
|
|
157
|
+
_ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakMap(), _ClientEncrypted_sessionId = new WeakMap(), _ClientEncrypted_state = new WeakMap(), _ClientEncrypted_shouldInvalidateSession = new WeakMap(), _ClientEncrypted_toAcknowledge = new WeakMap(), _ClientEncrypted_recentAcks = new WeakMap(), _ClientEncrypted_promises = new WeakMap(), _ClientEncrypted_loopActive = new WeakMap(), _ClientEncrypted_L = new WeakMap(), _ClientEncrypted_LreceiveLoop = new WeakMap(), _ClientEncrypted_Linvoke = new WeakMap(), _ClientEncrypted_timeDifference = new WeakMap(), _ClientEncrypted_instances = new WeakSet(), _ClientEncrypted_nextMessageId = function _ClientEncrypted_nextMessageId() {
|
|
148
158
|
return __classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId = getMessageId(__classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId, __classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"));
|
|
149
159
|
}, _ClientEncrypted_nextSeqNo = function _ClientEncrypted_nextSeqNo(contentRelated) {
|
|
150
160
|
let seqNo = __classPrivateFieldGet(this, _ClientEncrypted_state, "f").seqNo * 2;
|
|
@@ -173,7 +183,8 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
|
|
|
173
183
|
reject?.(new ConnectionError("Connection was closed"));
|
|
174
184
|
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(key);
|
|
175
185
|
}
|
|
176
|
-
|
|
186
|
+
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, true, "f");
|
|
187
|
+
while (this.connected && __classPrivateFieldGet(this, _ClientEncrypted_loopActive, "f")) {
|
|
177
188
|
try {
|
|
178
189
|
const buffer = await this.transport.transport.receive();
|
|
179
190
|
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").inBin(buffer);
|
|
@@ -187,126 +198,12 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
|
|
|
187
198
|
drop(this.handlers.error?.(err, "decryption"));
|
|
188
199
|
continue;
|
|
189
200
|
}
|
|
190
|
-
const messages = decrypted.body
|
|
201
|
+
const messages = decrypted.body instanceof Uint8Array ? [decrypted] : decrypted.body.messages.map((v) => v);
|
|
191
202
|
for (const message of messages) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("received", body._);
|
|
195
|
-
if (isOfEnum("Updates", body) || isOfEnum("Update", body)) {
|
|
196
|
-
drop(this.handlers.updates?.(body, null));
|
|
197
|
-
}
|
|
198
|
-
else if (is("new_session_created", body)) {
|
|
199
|
-
this.serverSalt = body.server_salt;
|
|
200
|
-
drop(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
201
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("new session created with ID", body.unique_id);
|
|
202
|
-
}
|
|
203
|
-
else if (body._ == "rpc_result") {
|
|
204
|
-
const result = body.result;
|
|
205
|
-
if (is("rpc_error", result)) {
|
|
206
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", result.error_code, result.error_message);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", Array.isArray(result) ? "Array" : typeof result === "object" ? result._ : result);
|
|
210
|
-
}
|
|
211
|
-
const messageId = body.req_msg_id;
|
|
212
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(messageId);
|
|
213
|
-
const resolvePromise = () => {
|
|
214
|
-
if (promise) {
|
|
215
|
-
if (is("rpc_error", result)) {
|
|
216
|
-
promise.reject?.(constructTelegramError(result, promise.call));
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
promise.resolve?.(result);
|
|
220
|
-
}
|
|
221
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(messageId);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
if (isOfEnum("Updates", result) || isOfEnum("Update", result)) {
|
|
225
|
-
// @ts-ignore: tbd
|
|
226
|
-
let call = promise?.call ?? null;
|
|
227
|
-
if (isGenericFunction(call)) {
|
|
228
|
-
call = call.query;
|
|
229
|
-
}
|
|
230
|
-
drop(this.handlers.updates?.(result, call, resolvePromise));
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
drop(this.handlers.result?.(result, resolvePromise));
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else if (is("pong", body)) {
|
|
237
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.msg_id);
|
|
238
|
-
if (promise) {
|
|
239
|
-
promise.resolve?.(body);
|
|
240
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.msg_id);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
else if (is("bad_server_salt", body)) {
|
|
244
|
-
sendAck = false;
|
|
245
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("server salt reassigned");
|
|
246
|
-
this.serverSalt = body.new_server_salt;
|
|
247
|
-
drop(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
248
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
249
|
-
const ack = __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").get(body.bad_msg_id);
|
|
250
|
-
if (promise) {
|
|
251
|
-
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
252
|
-
}
|
|
253
|
-
else if (ack) {
|
|
254
|
-
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
for (const promise of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").values()) {
|
|
258
|
-
if (promise.container && promise.container == body.bad_msg_id) {
|
|
259
|
-
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
for (const ack of __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").values()) {
|
|
263
|
-
if (ack.container && ack.container == body.bad_msg_id) {
|
|
264
|
-
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
else if (is("bad_msg_notification", body)) {
|
|
270
|
-
sendAck = false;
|
|
271
|
-
let low = false;
|
|
272
|
-
switch (body.error_code) {
|
|
273
|
-
case 16: // message ID too low
|
|
274
|
-
low = true;
|
|
275
|
-
/* falls through */
|
|
276
|
-
case 17: // message ID too high
|
|
277
|
-
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, Math.abs(toUnixTimestamp(new Date()) - Number(message.msg_id >> 32n)), "f");
|
|
278
|
-
if (!low) {
|
|
279
|
-
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, -__classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"), "f");
|
|
280
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too high, invalidating session");
|
|
281
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
282
|
-
break loop;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too low, resending message");
|
|
286
|
-
}
|
|
287
|
-
break;
|
|
288
|
-
case 48: // bad server salt
|
|
289
|
-
// resend
|
|
290
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("resending message that caused bad_server_salt");
|
|
291
|
-
break;
|
|
292
|
-
default:
|
|
293
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
294
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("invalidating session because of unexpected bad_msg_notification:", body.error_code);
|
|
295
|
-
break loop;
|
|
296
|
-
}
|
|
297
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
298
|
-
if (promise) {
|
|
299
|
-
promise.reject?.(body);
|
|
300
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.bad_msg_id);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
else if (isOneOf(["msg_detailed_info", "msg_new_detailed_info"], body)) {
|
|
304
|
-
sendAck = false;
|
|
305
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(body.answer_msg_id);
|
|
306
|
-
}
|
|
307
|
-
if (sendAck) {
|
|
308
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
203
|
+
if (!(message.body instanceof Uint8Array)) {
|
|
204
|
+
unreachable();
|
|
309
205
|
}
|
|
206
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleIncomingMessage).call(this, message);
|
|
310
207
|
}
|
|
311
208
|
}
|
|
312
209
|
catch (err) {
|
|
@@ -331,4 +228,154 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
|
|
|
331
228
|
else {
|
|
332
229
|
unreachable();
|
|
333
230
|
}
|
|
231
|
+
}, _ClientEncrypted_handleIncomingMessage = async function _ClientEncrypted_handleIncomingMessage(message) {
|
|
232
|
+
const body = message.body;
|
|
233
|
+
if (!(body instanceof Uint8Array)) {
|
|
234
|
+
unreachable();
|
|
235
|
+
}
|
|
236
|
+
let reader = new TLReader(body);
|
|
237
|
+
const id = reader.readInt32(false);
|
|
238
|
+
if (id == GZIP_PACKED) {
|
|
239
|
+
reader = new TLReader(await gunzip(reader.readBytes()));
|
|
240
|
+
}
|
|
241
|
+
else if (id == RPC_RESULT) {
|
|
242
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleRpcResult).call(this, reader);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
reader.unreadInt32();
|
|
246
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleType).call(this, message, reader);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
250
|
+
}, _ClientEncrypted_handleRpcResult = async function _ClientEncrypted_handleRpcResult(reader) {
|
|
251
|
+
const messageId = reader.readInt64();
|
|
252
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(messageId);
|
|
253
|
+
if (!promise) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let id = reader.readInt32(false);
|
|
257
|
+
if (id == GZIP_PACKED) {
|
|
258
|
+
reader = new TLReader(await gunzip(reader.readBytes()));
|
|
259
|
+
id = reader.readInt32(false);
|
|
260
|
+
reader.unreadInt32();
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
reader.unreadInt32();
|
|
264
|
+
}
|
|
265
|
+
// deno-lint-ignore no-explicit-any
|
|
266
|
+
let call = promise?.call ?? null;
|
|
267
|
+
while (isGenericFunction(call)) {
|
|
268
|
+
call = call.query;
|
|
269
|
+
}
|
|
270
|
+
// deno-lint-ignore no-explicit-any
|
|
271
|
+
let result;
|
|
272
|
+
if (id == RPC_ERROR) {
|
|
273
|
+
result = await reader.deserialize("rpc_error");
|
|
274
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", result.error_code, result.error_message);
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
result = await reader.deserialize(mustGetReturnType(call._));
|
|
278
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", Array.isArray(result) ? "Array" : typeof result === "object" ? result._ : result);
|
|
279
|
+
}
|
|
280
|
+
const resolvePromise = () => {
|
|
281
|
+
if (is("rpc_error", result)) {
|
|
282
|
+
promise.reject?.(constructTelegramError(result, promise.call));
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
promise.resolve?.(result);
|
|
286
|
+
}
|
|
287
|
+
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(messageId);
|
|
288
|
+
};
|
|
289
|
+
if (isOfEnum("Updates", result) || isOfEnum("Update", result)) {
|
|
290
|
+
drop(this.handlers.updates?.(result, call, resolvePromise));
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
drop(this.handlers.result?.(result, resolvePromise));
|
|
294
|
+
}
|
|
295
|
+
}, _ClientEncrypted_handleType = async function _ClientEncrypted_handleType(message, reader) {
|
|
296
|
+
const body = await reader.deserialize(X);
|
|
297
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("received", repr(body));
|
|
298
|
+
let sendAck = true;
|
|
299
|
+
if (isOfEnum("Updates", body) || isOfEnum("Update", body)) {
|
|
300
|
+
drop(this.handlers.updates?.(body, null));
|
|
301
|
+
}
|
|
302
|
+
else if (is("new_session_created", body)) {
|
|
303
|
+
this.serverSalt = body.server_salt;
|
|
304
|
+
drop(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
305
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("new session created with ID", body.unique_id);
|
|
306
|
+
}
|
|
307
|
+
else if (is("pong", body)) {
|
|
308
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.msg_id);
|
|
309
|
+
if (promise) {
|
|
310
|
+
promise.resolve?.(body);
|
|
311
|
+
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.msg_id);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else if (is("bad_server_salt", body)) {
|
|
315
|
+
sendAck = false;
|
|
316
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("server salt reassigned");
|
|
317
|
+
this.serverSalt = body.new_server_salt;
|
|
318
|
+
drop(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
319
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
320
|
+
const ack = __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").get(body.bad_msg_id);
|
|
321
|
+
if (promise) {
|
|
322
|
+
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
323
|
+
}
|
|
324
|
+
else if (ack) {
|
|
325
|
+
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
for (const promise of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").values()) {
|
|
329
|
+
if (promise.container && promise.container == body.bad_msg_id) {
|
|
330
|
+
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
for (const ack of __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").values()) {
|
|
334
|
+
if (ack.container && ack.container == body.bad_msg_id) {
|
|
335
|
+
drop(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if (is("bad_msg_notification", body)) {
|
|
341
|
+
sendAck = false;
|
|
342
|
+
let low = false;
|
|
343
|
+
switch (body.error_code) {
|
|
344
|
+
case 16: // message ID too low
|
|
345
|
+
low = true;
|
|
346
|
+
/* falls through */
|
|
347
|
+
case 17: // message ID too high
|
|
348
|
+
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, Math.abs(toUnixTimestamp(new Date()) - Number(message.msg_id >> 32n)), "f");
|
|
349
|
+
if (!low) {
|
|
350
|
+
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, -__classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"), "f");
|
|
351
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too high, invalidating session");
|
|
352
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
353
|
+
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too low, resending message");
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case 48: // bad server salt
|
|
360
|
+
// resend
|
|
361
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("resending message that caused bad_server_salt");
|
|
362
|
+
break;
|
|
363
|
+
default:
|
|
364
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
365
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("invalidating session because of unexpected bad_msg_notification:", body.error_code);
|
|
366
|
+
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
|
|
367
|
+
}
|
|
368
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
369
|
+
if (promise) {
|
|
370
|
+
promise.reject?.(body);
|
|
371
|
+
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.bad_msg_id);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else if (isOneOf(["msg_detailed_info", "msg_new_detailed_info"], body)) {
|
|
375
|
+
sendAck = false;
|
|
376
|
+
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(body.answer_msg_id);
|
|
377
|
+
}
|
|
378
|
+
if (sendAck) {
|
|
379
|
+
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
380
|
+
}
|
|
334
381
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_client_plain.d.ts","sourceRoot":"","sources":["../../src/client/1_client_plain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"1_client_plain.d.ts","sourceRoot":"","sources":["../../src/client/1_client_plain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,EAA6C,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAM9E,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,cAAc;;gBAIjC,MAAM,CAAC,EAAE,iBAAiB;IAKhC,MAAM,CAAC,CAAC,SAAS,GAAG,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAwB3P,aAAa,IAAI,OAAO,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;CAmIlE"}
|
|
@@ -32,7 +32,7 @@ var _ClientPlain_publicKeys, _ClientPlain_lastMessageId;
|
|
|
32
32
|
import { assert, assertEquals, concat, ige256Decrypt, ige256Encrypt, unreachable } from "../0_deps.js";
|
|
33
33
|
import { ConnectionError, TransportError } from "../0_errors.js";
|
|
34
34
|
import { bigIntFromBuffer, bufferFromBigInt, factorize, getLogger, getRandomBigInt, modExp, rsaPad, sha1 } from "../1_utilities.js";
|
|
35
|
-
import { is,
|
|
35
|
+
import { is, mustGetReturnType, TLReader, TLWriter } from "../2_tl.js";
|
|
36
36
|
import { PUBLIC_KEYS } from "../4_constants.js";
|
|
37
37
|
import { ClientAbstract } from "./0_client_abstract.js";
|
|
38
38
|
import { getMessageId, packUnencryptedMessage, unpackUnencryptedMessage } from "./0_message.js";
|
|
@@ -53,7 +53,7 @@ export class ClientPlain extends ClientAbstract {
|
|
|
53
53
|
throw new ConnectionError("Not connected.");
|
|
54
54
|
}
|
|
55
55
|
const messageId = __classPrivateFieldSet(this, _ClientPlain_lastMessageId, getMessageId(__classPrivateFieldGet(this, _ClientPlain_lastMessageId, "f"), 0), "f");
|
|
56
|
-
const payload = packUnencryptedMessage(serialize(function_), messageId);
|
|
56
|
+
const payload = packUnencryptedMessage(new TLWriter().serialize(function_).buffer, messageId);
|
|
57
57
|
await this.transport.transport.send(payload);
|
|
58
58
|
L.out(function_);
|
|
59
59
|
L.outBin(payload);
|
|
@@ -65,7 +65,7 @@ export class ClientPlain extends ClientAbstract {
|
|
|
65
65
|
}
|
|
66
66
|
const { message } = unpackUnencryptedMessage(buffer);
|
|
67
67
|
const reader = new TLReader(message);
|
|
68
|
-
const result = reader.
|
|
68
|
+
const result = await reader.deserialize(mustGetReturnType(function_._));
|
|
69
69
|
L.in(result);
|
|
70
70
|
return result;
|
|
71
71
|
}
|
|
@@ -113,7 +113,8 @@ export class ClientPlain extends ClientAbstract {
|
|
|
113
113
|
const pq = resPq.pq;
|
|
114
114
|
const serverNonce = resPq.server_nonce;
|
|
115
115
|
const newNonce = getRandomBigInt(32, false, true);
|
|
116
|
-
let encryptedData = await rsaPad(
|
|
116
|
+
let encryptedData = await rsaPad(new TLWriter()
|
|
117
|
+
.serialize({
|
|
117
118
|
_: "p_q_inner_data_dc",
|
|
118
119
|
pq,
|
|
119
120
|
p,
|
|
@@ -122,7 +123,8 @@ export class ClientPlain extends ClientAbstract {
|
|
|
122
123
|
new_nonce: newNonce,
|
|
123
124
|
nonce,
|
|
124
125
|
server_nonce: serverNonce,
|
|
125
|
-
})
|
|
126
|
+
})
|
|
127
|
+
.buffer, publicKey);
|
|
126
128
|
const dhParams = await this.invoke({
|
|
127
129
|
_: "req_DH_params",
|
|
128
130
|
nonce,
|
|
@@ -139,20 +141,22 @@ export class ClientPlain extends ClientAbstract {
|
|
|
139
141
|
const tmpAesKey = concat([await sha1(concat([newNonce_, serverNonce_])), (await sha1(concat([serverNonce_, newNonce_]))).subarray(0, 0 + 12)]);
|
|
140
142
|
const tmpAesIv = concat([(await sha1(concat([serverNonce_, newNonce_]))).subarray(12, 12 + 8), await sha1(concat([newNonce_, newNonce_])), newNonce_.subarray(0, 0 + 4)]);
|
|
141
143
|
const answerWithHash = ige256Decrypt(dhParams.encrypted_answer, tmpAesKey, tmpAesIv);
|
|
142
|
-
const dhInnerData = new TLReader(answerWithHash.slice(20)).
|
|
144
|
+
const dhInnerData = await new TLReader(answerWithHash.slice(20)).deserialize("server_DH_inner_data");
|
|
143
145
|
assert(is("server_DH_inner_data", dhInnerData));
|
|
144
146
|
const { g, g_a: gA_, dh_prime: dhPrime_ } = dhInnerData;
|
|
145
147
|
const gA = bigIntFromBuffer(gA_, false, false);
|
|
146
148
|
const dhPrime = bigIntFromBuffer(dhPrime_, false, false);
|
|
147
149
|
const b = getRandomBigInt(256, false, false);
|
|
148
150
|
const gB = modExp(BigInt(g), b, dhPrime);
|
|
149
|
-
const data =
|
|
151
|
+
const data = new TLWriter()
|
|
152
|
+
.serialize({
|
|
150
153
|
_: "client_DH_inner_data",
|
|
151
154
|
nonce,
|
|
152
155
|
server_nonce: serverNonce,
|
|
153
156
|
retry_id: 0n,
|
|
154
157
|
g_b: bufferFromBigInt(gB, 256, false, false),
|
|
155
|
-
})
|
|
158
|
+
})
|
|
159
|
+
.buffer;
|
|
156
160
|
let dataWithHash = concat([await sha1(data), data]);
|
|
157
161
|
while (dataWithHash.length % 16 != 0) {
|
|
158
162
|
dataWithHash = concat([dataWithHash, new Uint8Array(1)]);
|
package/esm/tl/0_api.d.ts
CHANGED
|
@@ -16501,8 +16501,7 @@ export type PaidReactionPrivacy = paidReactionPrivacyDefault | paidReactionPriva
|
|
|
16501
16501
|
export type account_PaidMessagesRevenue = account_paidMessagesRevenue;
|
|
16502
16502
|
export type RequirementToContact = requirementToContactEmpty | requirementToContactPremium | requirementToContactPaidMessages;
|
|
16503
16503
|
export declare const getTypeName: (id: number) => string | undefined;
|
|
16504
|
-
export
|
|
16505
|
-
export type Parameters = [number, [string, unknown, string][]];
|
|
16504
|
+
export type Parameters = [number, [string, string][]] | [number, [string, string][], string];
|
|
16506
16505
|
export declare const getType: (name: string) => Parameters | undefined;
|
|
16507
16506
|
export declare const getEnum: (name: string) => (keyof Types)[] | undefined;
|
|
16508
16507
|
export declare const _types: Map<string, Parameters> | undefined;
|