@mtkruto/node 0.60.0 → 0.61.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 +209 -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 +213 -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
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { unreachable } from "../0_deps.js";
|
|
21
21
|
import { base64EncodeUrlSafe, cleanObject } from "../1_utilities.js";
|
|
22
|
-
import { is,
|
|
22
|
+
import { is, TLWriter } from "../2_tl.js";
|
|
23
23
|
import { constructLocation } from "./0_location.js";
|
|
24
24
|
import { constructUser } from "./1_user.js";
|
|
25
25
|
export async function constructChosenInlineResult(ubis, getEntity) {
|
|
@@ -31,7 +31,7 @@ export async function constructChosenInlineResult(ubis, getEntity) {
|
|
|
31
31
|
resultId: ubis.id,
|
|
32
32
|
from: constructUser(entity),
|
|
33
33
|
location: is("geoPoint", ubis.geo) ? constructLocation(ubis.geo) : undefined,
|
|
34
|
-
inlineMessageId: ubis.msg_id === undefined ? undefined : base64EncodeUrlSafe(serialize(ubis.msg_id)),
|
|
34
|
+
inlineMessageId: ubis.msg_id === undefined ? undefined : base64EncodeUrlSafe(new TLWriter().serialize(ubis.msg_id).buffer),
|
|
35
35
|
query: ubis.query,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5_callback_query.d.ts","sourceRoot":"","sources":["../../src/types/5_callback_query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"5_callback_query.d.ts","sourceRoot":"","sources":["../../src/types/5_callback_query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,GAAG,EAAwC,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAiB,IAAI,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExD,iCAAiC;AACjC,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,4CAA4C;IAC5C,IAAI,EAAE,IAAI,CAAC;IACX,uGAAuG;IACvG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oKAAoK;IACpK,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gHAAgH;IAChH,YAAY,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,MAAM,GAAG,GAAG,CAAC,uBAAuB,CAa/F;AAED,wBAAsB,sBAAsB,CAAC,aAAa,EAAE,GAAG,CAAC,sBAAsB,GAAG,GAAG,CAAC,4BAA4B,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBrM"}
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
import { unreachable } from "../0_deps.js";
|
|
21
21
|
import { InputError } from "../0_errors.js";
|
|
22
22
|
import { base64DecodeUrlSafe, base64EncodeUrlSafe, cleanObject } from "../1_utilities.js";
|
|
23
|
-
import { is, peerToChatId,
|
|
23
|
+
import { is, peerToChatId, TLReader, TLWriter } from "../2_tl.js";
|
|
24
24
|
import { constructUser } from "./1_user.js";
|
|
25
25
|
const ERR_INVALID_INLINE_MESSAGE_ID = new InputError("Invalid inline message ID");
|
|
26
26
|
export function deserializeInlineMessageId(inlineMessageId) {
|
|
27
27
|
try {
|
|
28
28
|
const buffer = base64DecodeUrlSafe(inlineMessageId);
|
|
29
29
|
const reader = new TLReader(buffer);
|
|
30
|
-
const object = reader.
|
|
30
|
+
const object = reader.deserialize("InputBotInlineMessageID");
|
|
31
31
|
if (is("inputBotInlineMessageID64", object) || is("inputBotInlineMessageID", object)) {
|
|
32
32
|
return object;
|
|
33
33
|
}
|
|
@@ -55,6 +55,6 @@ export async function constructCallbackQuery(callbackQuery, getEntity, getMessag
|
|
|
55
55
|
return cleanObject({ id, from: user, message, chatInstance, data, gameShortName });
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
return cleanObject({ id, from: user, inlineMessageId: base64EncodeUrlSafe(serialize(callbackQuery.msg_id)), chatInstance, data, gameShortName });
|
|
58
|
+
return cleanObject({ id, from: user, inlineMessageId: base64EncodeUrlSafe(new TLWriter().serialize(callbackQuery.msg_id).buffer), chatInstance, data, gameShortName });
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -3,7 +3,6 @@ export declare function mustPrompt(message: string): string;
|
|
|
3
3
|
export declare function mustPromptNumber(message: string): number;
|
|
4
4
|
export declare function mustPromptOneOf<T extends readonly string[]>(message: string, choices: T): T[number];
|
|
5
5
|
export declare const ZERO_CHANNEL_ID = -1000000000000;
|
|
6
|
-
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
7
6
|
export declare function toUnixTimestamp(date: Date): number;
|
|
8
7
|
export declare function fromUnixTimestamp(date: number): Date;
|
|
9
8
|
export declare function iterateReadableStream(stream: ReadableStream): AsyncGenerator<any, void, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_misc.d.ts","sourceRoot":"","sources":["../../src/utilities/0_misc.ts"],"names":[],"mappings":"AAwBA,wBAAgB,IAAI,CAAC,YAAY,EAAE,OAAO,QAIzC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UAOzC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,UAO/C;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAMnG;AAED,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"0_misc.d.ts","sourceRoot":"","sources":["../../src/utilities/0_misc.ts"],"names":[],"mappings":"AAwBA,wBAAgB,IAAI,CAAC,YAAY,EAAE,OAAO,QAIzC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UAOzC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,UAO/C;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAMnG;AAED,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,UAEzC;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,QAE7C;AAED,wBAAuB,qBAAqB,CAAC,MAAM,EAAE,cAAc,sCAWlE"}
|
package/esm/utilities/0_misc.js
CHANGED
|
@@ -49,7 +49,6 @@ export function mustPromptOneOf(message, choices) {
|
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
51
|
export const ZERO_CHANNEL_ID = -1000000000000;
|
|
52
|
-
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
53
52
|
export function toUnixTimestamp(date) {
|
|
54
53
|
return Math.floor(date.getTime() / SECOND);
|
|
55
54
|
}
|
package/package.json
CHANGED
package/script/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/script/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/script/2_tl.js
CHANGED
|
@@ -50,9 +50,7 @@ var _0_tl_raw_reader_js_1 = require("./tl/0_tl_raw_reader.js");
|
|
|
50
50
|
Object.defineProperty(exports, "TLError", { enumerable: true, get: function () { return _0_tl_raw_reader_js_1.TLError; } });
|
|
51
51
|
exports.Api = __importStar(require("./tl/0_api.js"));
|
|
52
52
|
__exportStar(require("./tl/1_utilities.js"), exports);
|
|
53
|
-
__exportStar(require("./tl/
|
|
54
|
-
__exportStar(require("./tl/
|
|
55
|
-
__exportStar(require("./tl/
|
|
56
|
-
__exportStar(require("./tl/
|
|
57
|
-
__exportStar(require("./tl/4_rpc_result.js"), exports);
|
|
58
|
-
__exportStar(require("./tl/5_message.js"), exports);
|
|
53
|
+
__exportStar(require("./tl/2_utilities.js"), exports);
|
|
54
|
+
__exportStar(require("./tl/2_message.js"), exports);
|
|
55
|
+
__exportStar(require("./tl/2_tl_reader.js"), exports);
|
|
56
|
+
__exportStar(require("./tl/2_tl_writer.js"), exports);
|
|
@@ -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,EAAE;;;oBAGpB,MAAM,KAAG,MAAM;kBACnB,cAAc,EAAE;mBACf,cAAc,EAAE;yBACV,cAAc,EAAE;2BACd,cAAc,EAAE;;;oBAGrB,MAAM,KAAG,MAAM;qBAChB,cAAc,EAAE;mBAClB,cAAc,EAAE;yBACR,MAAM,KAAG,cAAc,EAAE;wBAC1B,MAAM,MAAM,MAAM,KAAG,cAAc,EAAE;gCAC7B,MAAM,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AAE,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"}
|
|
@@ -246,15 +246,15 @@ class StorageOperations {
|
|
|
246
246
|
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
|
|
247
247
|
}
|
|
248
248
|
else {
|
|
249
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(
|
|
249
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? [value._, (0, _1_utilities_js_1.rleEncode)(new _2_tl_js_1.TLWriter().serialize(value).buffer)] : value);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
async getTlObject(keyOrBuffer) {
|
|
253
253
|
// @ts-ignore: TBD
|
|
254
254
|
const buffer = (keyOrBuffer instanceof Uint8Array || (0, _2_tl_js_1.isValidType)(keyOrBuffer)) ? keyOrBuffer : await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(keyOrBuffer);
|
|
255
255
|
if (buffer != null) {
|
|
256
|
-
if (buffer
|
|
257
|
-
return new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)(buffer)).
|
|
256
|
+
if (Array.isArray(buffer)) {
|
|
257
|
+
return await new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)(buffer[1])).deserialize(buffer[0]);
|
|
258
258
|
}
|
|
259
259
|
else {
|
|
260
260
|
return buffer;
|
|
@@ -302,7 +302,7 @@ class StorageOperations {
|
|
|
302
302
|
return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.updates.channelPts(channelId));
|
|
303
303
|
}
|
|
304
304
|
async setEntity(entity) {
|
|
305
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.peer((0, _2_tl_js_1.peerToChatId)(entity)), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(
|
|
305
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.peer((0, _2_tl_js_1.peerToChatId)(entity)), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(new _2_tl_js_1.TLWriter().serialize(entity).buffer) : entity, new Date()]);
|
|
306
306
|
}
|
|
307
307
|
async getEntity(key) {
|
|
308
308
|
const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.peer(key));
|
|
@@ -435,7 +435,7 @@ class StorageOperations {
|
|
|
435
435
|
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.file(id), [partCount, chunkSize]);
|
|
436
436
|
}
|
|
437
437
|
async setCustomEmojiDocument(id, document) {
|
|
438
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(
|
|
438
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(new _2_tl_js_1.TLWriter().serialize(document).buffer) : document, new Date()]);
|
|
439
439
|
}
|
|
440
440
|
async getCustomEmojiDocument(id) {
|
|
441
441
|
const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.customEmojiDocument(id));
|
|
@@ -447,7 +447,7 @@ class StorageOperations {
|
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
async setBusinessConnection(id, connection) {
|
|
450
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.businessConnection(id), connection == null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(
|
|
450
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.businessConnection(id), connection == null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(new _2_tl_js_1.TLWriter().serialize(connection).buffer) : connection);
|
|
451
451
|
}
|
|
452
452
|
async getBusinessConnection(id) {
|
|
453
453
|
const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.businessConnection(id));
|
|
@@ -459,7 +459,7 @@ class StorageOperations {
|
|
|
459
459
|
}
|
|
460
460
|
}
|
|
461
461
|
async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
|
|
462
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(
|
|
462
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(new _2_tl_js_1.TLWriter().serialize(results).buffer) : results, date]);
|
|
463
463
|
}
|
|
464
464
|
async getInlineQueryAnswer(userId, chatId, query, offset) {
|
|
465
465
|
const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
|
|
@@ -472,7 +472,7 @@ class StorageOperations {
|
|
|
472
472
|
}
|
|
473
473
|
}
|
|
474
474
|
async setCallbackQueryAnswer(chatId, messageId, question, answer) {
|
|
475
|
-
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(
|
|
475
|
+
await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(new _2_tl_js_1.TLWriter().serialize(answer).buffer) : answer, new Date()]);
|
|
476
476
|
}
|
|
477
477
|
async getCallbackQueryAnswer(chatId, messageId, question) {
|
|
478
478
|
const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.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,CAAC;AAGxK,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQ9D,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAAC;AAEvE,MAAM,WAAW,QAAQ;IACvB,oBAAoB,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,OAAO,CAAC,EAAE,CAAC,OAAO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ldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
29
29
|
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");
|
|
30
30
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
31
|
};
|
|
32
|
-
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;
|
|
32
|
+
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;
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.ClientEncrypted = void 0;
|
|
35
35
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -37,10 +37,13 @@ const _0_errors_js_1 = require("../0_errors.js");
|
|
|
37
37
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
38
38
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
39
39
|
const _4_errors_js_1 = require("../4_errors.js");
|
|
40
|
+
const _2_tl_writer_js_1 = require("../tl/2_tl_writer.js");
|
|
40
41
|
const _0_client_abstract_js_1 = require("./0_client_abstract.js");
|
|
41
42
|
const _0_message_js_1 = require("./0_message.js");
|
|
43
|
+
const COMPRESSION_THRESHOLD = 1024;
|
|
42
44
|
// global ClientEncrypted ID counter for logs
|
|
43
45
|
let id = 0;
|
|
46
|
+
const RPC_ERROR = _2_tl_js_1.Api.getType("rpc_error")[0];
|
|
44
47
|
/**
|
|
45
48
|
* An MTProto client for making encrypted connections. Most users won't need to interact with this. Used internally by `Client`.
|
|
46
49
|
*
|
|
@@ -64,6 +67,7 @@ class ClientEncrypted extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
64
67
|
_ClientEncrypted_toAcknowledge.set(this, new Array());
|
|
65
68
|
_ClientEncrypted_recentAcks.set(this, new _1_utilities_js_1.CacheMap(20));
|
|
66
69
|
_ClientEncrypted_promises.set(this, new Map());
|
|
70
|
+
_ClientEncrypted_loopActive.set(this, true);
|
|
67
71
|
// loggers
|
|
68
72
|
_ClientEncrypted_L.set(this, void 0);
|
|
69
73
|
_ClientEncrypted_LreceiveLoop.set(this, void 0);
|
|
@@ -105,13 +109,19 @@ class ClientEncrypted extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
105
109
|
}
|
|
106
110
|
async invoke(function_, noWait) {
|
|
107
111
|
const messageId = __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this);
|
|
112
|
+
let body = new _2_tl_writer_js_1.TLWriter().serialize(function_).buffer;
|
|
113
|
+
if (body.length > COMPRESSION_THRESHOLD) {
|
|
114
|
+
body = new _2_tl_writer_js_1.TLWriter()
|
|
115
|
+
.writeInt32(_2_tl_js_1.GZIP_PACKED, false)
|
|
116
|
+
.writeBytes(await (0, _1_utilities_js_1.gzip)(body))
|
|
117
|
+
.buffer;
|
|
118
|
+
}
|
|
108
119
|
let message_ = {
|
|
109
120
|
_: "message",
|
|
110
121
|
msg_id: messageId,
|
|
111
122
|
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, true),
|
|
112
|
-
body
|
|
123
|
+
body,
|
|
113
124
|
};
|
|
114
|
-
Object.assign(message_, { [_2_tl_js_1.compressible]: true });
|
|
115
125
|
const message__ = message_;
|
|
116
126
|
let container = undefined;
|
|
117
127
|
if (__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").length) {
|
|
@@ -119,7 +129,7 @@ class ClientEncrypted extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
119
129
|
_: "message",
|
|
120
130
|
msg_id: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextMessageId).call(this),
|
|
121
131
|
seqno: __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_nextSeqNo).call(this, false),
|
|
122
|
-
body: { _: "msgs_ack", msg_ids: __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").splice(0, 8192) },
|
|
132
|
+
body: new _2_tl_writer_js_1.TLWriter().serialize({ _: "msgs_ack", msg_ids: __classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").splice(0, 8192) }).buffer,
|
|
123
133
|
};
|
|
124
134
|
__classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").set(ack.msg_id, { container, message: ack });
|
|
125
135
|
message_ = {
|
|
@@ -148,7 +158,7 @@ class ClientEncrypted extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
exports.ClientEncrypted = ClientEncrypted;
|
|
151
|
-
_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() {
|
|
161
|
+
_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() {
|
|
152
162
|
return __classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId = (0, _0_message_js_1.getMessageId)(__classPrivateFieldGet(this, _ClientEncrypted_state, "f").messageId, __classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"));
|
|
153
163
|
}, _ClientEncrypted_nextSeqNo = function _ClientEncrypted_nextSeqNo(contentRelated) {
|
|
154
164
|
let seqNo = __classPrivateFieldGet(this, _ClientEncrypted_state, "f").seqNo * 2;
|
|
@@ -177,7 +187,8 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
|
|
|
177
187
|
reject?.(new _0_errors_js_1.ConnectionError("Connection was closed"));
|
|
178
188
|
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(key);
|
|
179
189
|
}
|
|
180
|
-
|
|
190
|
+
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, true, "f");
|
|
191
|
+
while (this.connected && __classPrivateFieldGet(this, _ClientEncrypted_loopActive, "f")) {
|
|
181
192
|
try {
|
|
182
193
|
const buffer = await this.transport.transport.receive();
|
|
183
194
|
__classPrivateFieldGet(this, _ClientEncrypted_L, "f").inBin(buffer);
|
|
@@ -191,126 +202,12 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
|
|
|
191
202
|
(0, _1_utilities_js_1.drop)(this.handlers.error?.(err, "decryption"));
|
|
192
203
|
continue;
|
|
193
204
|
}
|
|
194
|
-
const messages = decrypted.body
|
|
205
|
+
const messages = decrypted.body instanceof Uint8Array ? [decrypted] : decrypted.body.messages.map((v) => v);
|
|
195
206
|
for (const message of messages) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("received", body._);
|
|
199
|
-
if ((0, _2_tl_js_1.isOfEnum)("Updates", body) || (0, _2_tl_js_1.isOfEnum)("Update", body)) {
|
|
200
|
-
(0, _1_utilities_js_1.drop)(this.handlers.updates?.(body, null));
|
|
201
|
-
}
|
|
202
|
-
else if ((0, _2_tl_js_1.is)("new_session_created", body)) {
|
|
203
|
-
this.serverSalt = body.server_salt;
|
|
204
|
-
(0, _1_utilities_js_1.drop)(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
205
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("new session created with ID", body.unique_id);
|
|
206
|
-
}
|
|
207
|
-
else if (body._ == "rpc_result") {
|
|
208
|
-
const result = body.result;
|
|
209
|
-
if ((0, _2_tl_js_1.is)("rpc_error", result)) {
|
|
210
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", result.error_code, result.error_message);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", Array.isArray(result) ? "Array" : typeof result === "object" ? result._ : result);
|
|
214
|
-
}
|
|
215
|
-
const messageId = body.req_msg_id;
|
|
216
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(messageId);
|
|
217
|
-
const resolvePromise = () => {
|
|
218
|
-
if (promise) {
|
|
219
|
-
if ((0, _2_tl_js_1.is)("rpc_error", result)) {
|
|
220
|
-
promise.reject?.((0, _4_errors_js_1.constructTelegramError)(result, promise.call));
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
promise.resolve?.(result);
|
|
224
|
-
}
|
|
225
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(messageId);
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
if ((0, _2_tl_js_1.isOfEnum)("Updates", result) || (0, _2_tl_js_1.isOfEnum)("Update", result)) {
|
|
229
|
-
// @ts-ignore: tbd
|
|
230
|
-
let call = promise?.call ?? null;
|
|
231
|
-
if ((0, _2_tl_js_1.isGenericFunction)(call)) {
|
|
232
|
-
call = call.query;
|
|
233
|
-
}
|
|
234
|
-
(0, _1_utilities_js_1.drop)(this.handlers.updates?.(result, call, resolvePromise));
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
(0, _1_utilities_js_1.drop)(this.handlers.result?.(result, resolvePromise));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
else if ((0, _2_tl_js_1.is)("pong", body)) {
|
|
241
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.msg_id);
|
|
242
|
-
if (promise) {
|
|
243
|
-
promise.resolve?.(body);
|
|
244
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.msg_id);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else if ((0, _2_tl_js_1.is)("bad_server_salt", body)) {
|
|
248
|
-
sendAck = false;
|
|
249
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("server salt reassigned");
|
|
250
|
-
this.serverSalt = body.new_server_salt;
|
|
251
|
-
(0, _1_utilities_js_1.drop)(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
252
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
253
|
-
const ack = __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").get(body.bad_msg_id);
|
|
254
|
-
if (promise) {
|
|
255
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
256
|
-
}
|
|
257
|
-
else if (ack) {
|
|
258
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
for (const promise of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").values()) {
|
|
262
|
-
if (promise.container && promise.container == body.bad_msg_id) {
|
|
263
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
for (const ack of __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").values()) {
|
|
267
|
-
if (ack.container && ack.container == body.bad_msg_id) {
|
|
268
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
else if ((0, _2_tl_js_1.is)("bad_msg_notification", body)) {
|
|
274
|
-
sendAck = false;
|
|
275
|
-
let low = false;
|
|
276
|
-
switch (body.error_code) {
|
|
277
|
-
case 16: // message ID too low
|
|
278
|
-
low = true;
|
|
279
|
-
/* falls through */
|
|
280
|
-
case 17: // message ID too high
|
|
281
|
-
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, Math.abs((0, _1_utilities_js_1.toUnixTimestamp)(new Date()) - Number(message.msg_id >> 32n)), "f");
|
|
282
|
-
if (!low) {
|
|
283
|
-
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, -__classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"), "f");
|
|
284
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too high, invalidating session");
|
|
285
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
286
|
-
break loop;
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too low, resending message");
|
|
290
|
-
}
|
|
291
|
-
break;
|
|
292
|
-
case 48: // bad server salt
|
|
293
|
-
// resend
|
|
294
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("resending message that caused bad_server_salt");
|
|
295
|
-
break;
|
|
296
|
-
default:
|
|
297
|
-
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
298
|
-
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("invalidating session because of unexpected bad_msg_notification:", body.error_code);
|
|
299
|
-
break loop;
|
|
300
|
-
}
|
|
301
|
-
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
302
|
-
if (promise) {
|
|
303
|
-
promise.reject?.(body);
|
|
304
|
-
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.bad_msg_id);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
else if ((0, _2_tl_js_1.isOneOf)(["msg_detailed_info", "msg_new_detailed_info"], body)) {
|
|
308
|
-
sendAck = false;
|
|
309
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(body.answer_msg_id);
|
|
310
|
-
}
|
|
311
|
-
if (sendAck) {
|
|
312
|
-
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
207
|
+
if (!(message.body instanceof Uint8Array)) {
|
|
208
|
+
(0, _0_deps_js_1.unreachable)();
|
|
313
209
|
}
|
|
210
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleIncomingMessage).call(this, message);
|
|
314
211
|
}
|
|
315
212
|
}
|
|
316
213
|
catch (err) {
|
|
@@ -335,4 +232,154 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
|
|
|
335
232
|
else {
|
|
336
233
|
(0, _0_deps_js_1.unreachable)();
|
|
337
234
|
}
|
|
235
|
+
}, _ClientEncrypted_handleIncomingMessage = async function _ClientEncrypted_handleIncomingMessage(message) {
|
|
236
|
+
const body = message.body;
|
|
237
|
+
if (!(body instanceof Uint8Array)) {
|
|
238
|
+
(0, _0_deps_js_1.unreachable)();
|
|
239
|
+
}
|
|
240
|
+
let reader = new _2_tl_js_1.TLReader(body);
|
|
241
|
+
const id = reader.readInt32(false);
|
|
242
|
+
if (id == _2_tl_js_1.GZIP_PACKED) {
|
|
243
|
+
reader = new _2_tl_js_1.TLReader(await (0, _1_utilities_js_1.gunzip)(reader.readBytes()));
|
|
244
|
+
}
|
|
245
|
+
else if (id == _2_tl_js_1.RPC_RESULT) {
|
|
246
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleRpcResult).call(this, reader);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
reader.unreadInt32();
|
|
250
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_handleType).call(this, message, reader);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
254
|
+
}, _ClientEncrypted_handleRpcResult = async function _ClientEncrypted_handleRpcResult(reader) {
|
|
255
|
+
const messageId = reader.readInt64();
|
|
256
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(messageId);
|
|
257
|
+
if (!promise) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
let id = reader.readInt32(false);
|
|
261
|
+
if (id == _2_tl_js_1.GZIP_PACKED) {
|
|
262
|
+
reader = new _2_tl_js_1.TLReader(await (0, _1_utilities_js_1.gunzip)(reader.readBytes()));
|
|
263
|
+
id = reader.readInt32(false);
|
|
264
|
+
reader.unreadInt32();
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
reader.unreadInt32();
|
|
268
|
+
}
|
|
269
|
+
// deno-lint-ignore no-explicit-any
|
|
270
|
+
let call = promise?.call ?? null;
|
|
271
|
+
while ((0, _2_tl_js_1.isGenericFunction)(call)) {
|
|
272
|
+
call = call.query;
|
|
273
|
+
}
|
|
274
|
+
// deno-lint-ignore no-explicit-any
|
|
275
|
+
let result;
|
|
276
|
+
if (id == RPC_ERROR) {
|
|
277
|
+
result = await reader.deserialize("rpc_error");
|
|
278
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", result.error_code, result.error_message);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
result = await reader.deserialize((0, _2_tl_js_1.mustGetReturnType)(call._));
|
|
282
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("RPCResult:", Array.isArray(result) ? "Array" : typeof result === "object" ? result._ : result);
|
|
283
|
+
}
|
|
284
|
+
const resolvePromise = () => {
|
|
285
|
+
if ((0, _2_tl_js_1.is)("rpc_error", result)) {
|
|
286
|
+
promise.reject?.((0, _4_errors_js_1.constructTelegramError)(result, promise.call));
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
promise.resolve?.(result);
|
|
290
|
+
}
|
|
291
|
+
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(messageId);
|
|
292
|
+
};
|
|
293
|
+
if ((0, _2_tl_js_1.isOfEnum)("Updates", result) || (0, _2_tl_js_1.isOfEnum)("Update", result)) {
|
|
294
|
+
(0, _1_utilities_js_1.drop)(this.handlers.updates?.(result, call, resolvePromise));
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
(0, _1_utilities_js_1.drop)(this.handlers.result?.(result, resolvePromise));
|
|
298
|
+
}
|
|
299
|
+
}, _ClientEncrypted_handleType = async function _ClientEncrypted_handleType(message, reader) {
|
|
300
|
+
const body = await reader.deserialize(_2_tl_js_1.X);
|
|
301
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("received", (0, _2_tl_js_1.repr)(body));
|
|
302
|
+
let sendAck = true;
|
|
303
|
+
if ((0, _2_tl_js_1.isOfEnum)("Updates", body) || (0, _2_tl_js_1.isOfEnum)("Update", body)) {
|
|
304
|
+
(0, _1_utilities_js_1.drop)(this.handlers.updates?.(body, null));
|
|
305
|
+
}
|
|
306
|
+
else if ((0, _2_tl_js_1.is)("new_session_created", body)) {
|
|
307
|
+
this.serverSalt = body.server_salt;
|
|
308
|
+
(0, _1_utilities_js_1.drop)(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
309
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("new session created with ID", body.unique_id);
|
|
310
|
+
}
|
|
311
|
+
else if ((0, _2_tl_js_1.is)("pong", body)) {
|
|
312
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.msg_id);
|
|
313
|
+
if (promise) {
|
|
314
|
+
promise.resolve?.(body);
|
|
315
|
+
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.msg_id);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else if ((0, _2_tl_js_1.is)("bad_server_salt", body)) {
|
|
319
|
+
sendAck = false;
|
|
320
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("server salt reassigned");
|
|
321
|
+
this.serverSalt = body.new_server_salt;
|
|
322
|
+
(0, _1_utilities_js_1.drop)(this.handlers.serverSaltReassigned?.(this.serverSalt));
|
|
323
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
324
|
+
const ack = __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").get(body.bad_msg_id);
|
|
325
|
+
if (promise) {
|
|
326
|
+
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
327
|
+
}
|
|
328
|
+
else if (ack) {
|
|
329
|
+
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
for (const promise of __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").values()) {
|
|
333
|
+
if (promise.container && promise.container == body.bad_msg_id) {
|
|
334
|
+
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, promise.message));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for (const ack of __classPrivateFieldGet(this, _ClientEncrypted_recentAcks, "f").values()) {
|
|
338
|
+
if (ack.container && ack.container == body.bad_msg_id) {
|
|
339
|
+
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_sendMessage).call(this, ack.message));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else if ((0, _2_tl_js_1.is)("bad_msg_notification", body)) {
|
|
345
|
+
sendAck = false;
|
|
346
|
+
let low = false;
|
|
347
|
+
switch (body.error_code) {
|
|
348
|
+
case 16: // message ID too low
|
|
349
|
+
low = true;
|
|
350
|
+
/* falls through */
|
|
351
|
+
case 17: // message ID too high
|
|
352
|
+
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, Math.abs((0, _1_utilities_js_1.toUnixTimestamp)(new Date()) - Number(message.msg_id >> 32n)), "f");
|
|
353
|
+
if (!low) {
|
|
354
|
+
__classPrivateFieldSet(this, _ClientEncrypted_timeDifference, -__classPrivateFieldGet(this, _ClientEncrypted_timeDifference, "f"), "f");
|
|
355
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too high, invalidating session");
|
|
356
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
357
|
+
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("message ID too low, resending message");
|
|
361
|
+
}
|
|
362
|
+
break;
|
|
363
|
+
case 48: // bad server salt
|
|
364
|
+
// resend
|
|
365
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("resending message that caused bad_server_salt");
|
|
366
|
+
break;
|
|
367
|
+
default:
|
|
368
|
+
await __classPrivateFieldGet(this, _ClientEncrypted_instances, "m", _ClientEncrypted_invalidateSession).call(this);
|
|
369
|
+
__classPrivateFieldGet(this, _ClientEncrypted_LreceiveLoop, "f").debug("invalidating session because of unexpected bad_msg_notification:", body.error_code);
|
|
370
|
+
__classPrivateFieldSet(this, _ClientEncrypted_loopActive, false, "f");
|
|
371
|
+
}
|
|
372
|
+
const promise = __classPrivateFieldGet(this, _ClientEncrypted_promises, "f").get(body.bad_msg_id);
|
|
373
|
+
if (promise) {
|
|
374
|
+
promise.reject?.(body);
|
|
375
|
+
__classPrivateFieldGet(this, _ClientEncrypted_promises, "f").delete(body.bad_msg_id);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else if ((0, _2_tl_js_1.isOneOf)(["msg_detailed_info", "msg_new_detailed_info"], body)) {
|
|
379
|
+
sendAck = false;
|
|
380
|
+
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(body.answer_msg_id);
|
|
381
|
+
}
|
|
382
|
+
if (sendAck) {
|
|
383
|
+
__classPrivateFieldGet(this, _ClientEncrypted_toAcknowledge, "f").push(message.msg_id);
|
|
384
|
+
}
|
|
338
385
|
};
|
|
@@ -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"}
|