@mtkruto/node 0.1.100 → 0.1.102
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/0_deps.d.ts +3 -3
- package/esm/0_deps.js +3 -3
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/0_message.js +3 -9
- package/esm/client/3_types.d.ts +2 -0
- package/esm/client/4_client.d.ts +55 -4
- package/esm/client/4_client.js +260 -72
- package/esm/connection/1_connection_web_socket.js +5 -2
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.js +10 -3
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.js +1 -0
- package/esm/deps/deno.land/std@0.204.0/encoding/_util.d.ts +1 -0
- package/esm/deps/deno.land/std@0.204.0/encoding/_util.js +26 -0
- package/esm/deps/deno.land/std@0.204.0/encoding/base64.d.ts +23 -0
- package/{script/deps/deno.land/std@0.201.0 → esm/deps/deno.land/std@0.204.0}/encoding/base64.js +23 -18
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.js +1 -1
- package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +324 -0
- package/esm/tl/6_message.d.ts +1 -0
- package/esm/tl/6_message.js +1 -2
- package/esm/tl/6_message_test.d.ts +1 -0
- package/esm/transport/0_obfuscation.js +3 -3
- package/esm/transport/0_transport.d.ts +2 -2
- package/esm/transport/0_transport.js +2 -8
- package/esm/transport/1_transport_abridged.js +9 -7
- package/esm/transport/1_transport_intermediate.js +7 -3
- package/esm/types/3_message.d.ts +4 -0
- package/esm/types/3_message.js +4 -1
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +2 -0
- package/esm/utilities/0_crypto.d.ts +1 -1
- package/esm/utilities/0_crypto.js +1 -3
- package/esm/utilities/0_queue.js +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +3 -3
- package/script/0_deps.js +3 -3
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/0_message.js +2 -8
- package/script/client/3_types.d.ts +2 -0
- package/script/client/4_client.d.ts +55 -4
- package/script/client/4_client.js +260 -71
- package/script/connection/1_connection_web_socket.js +5 -2
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.js +10 -3
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.js +1 -0
- package/script/deps/deno.land/std@0.204.0/encoding/_util.d.ts +1 -0
- package/script/deps/deno.land/std@0.204.0/encoding/_util.js +30 -0
- package/script/deps/deno.land/std@0.204.0/encoding/base64.d.ts +23 -0
- package/{esm/deps/deno.land/std@0.201.0 → script/deps/deno.land/std@0.204.0}/encoding/base64.js +28 -13
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.js +1 -1
- package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
- package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +326 -0
- package/script/tl/6_message.d.ts +1 -0
- package/script/tl/6_message.js +2 -2
- package/script/tl/6_message_test.d.ts +1 -0
- package/script/transport/0_obfuscation.js +3 -3
- package/script/transport/0_transport.d.ts +2 -2
- package/script/transport/0_transport.js +2 -8
- package/script/transport/1_transport_abridged.js +9 -7
- package/script/transport/1_transport_intermediate.js +7 -3
- package/script/types/3_message.d.ts +4 -0
- package/script/types/3_message.js +4 -1
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +2 -0
- package/script/utilities/0_crypto.d.ts +1 -1
- package/script/utilities/0_crypto.js +1 -3
- package/script/utilities/0_queue.js +1 -1
- package/esm/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
- package/esm/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -308
- package/script/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
- package/script/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -310
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.d.ts +0 -0
- package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
- package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.d.ts +1 -1
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
|
@@ -15,18 +15,12 @@ export class Transport {
|
|
|
15
15
|
}
|
|
16
16
|
encrypt(buffer) {
|
|
17
17
|
if (this.obfuscationParameters) {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return buffer;
|
|
18
|
+
this.obfuscationParameters.encryptionCTR.call(buffer);
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
21
|
decrypt(buffer) {
|
|
25
22
|
if (this.obfuscationParameters) {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return buffer;
|
|
23
|
+
this.obfuscationParameters.decryptionCTR.call(buffer);
|
|
30
24
|
}
|
|
31
25
|
}
|
|
32
26
|
}
|
|
@@ -34,24 +34,24 @@ export class TransportAbridged extends Transport {
|
|
|
34
34
|
async receive() {
|
|
35
35
|
let length;
|
|
36
36
|
{
|
|
37
|
-
|
|
37
|
+
const buffer = new Uint8Array(1);
|
|
38
38
|
await this.connection.read(buffer);
|
|
39
|
-
|
|
39
|
+
this.decrypt(buffer);
|
|
40
40
|
if (buffer[0] < 0x7F) {
|
|
41
41
|
length = buffer[0];
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
|
|
44
|
+
const buffer = new Uint8Array(3);
|
|
45
45
|
await this.connection.read(buffer);
|
|
46
|
-
|
|
46
|
+
this.decrypt(buffer);
|
|
47
47
|
const dataView = new DataView(buffer.buffer);
|
|
48
48
|
length = dataView.getUint16(0, true);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
length *= 4;
|
|
52
|
-
|
|
52
|
+
const buffer = new Uint8Array(length);
|
|
53
53
|
await this.connection.read(buffer);
|
|
54
|
-
|
|
54
|
+
this.decrypt(buffer);
|
|
55
55
|
return buffer;
|
|
56
56
|
}
|
|
57
57
|
async send(buffer) {
|
|
@@ -61,7 +61,9 @@ export class TransportAbridged extends Transport {
|
|
|
61
61
|
const bufferLength = buffer.length / 4;
|
|
62
62
|
const header = new Uint8Array([bufferLength >= 0x7F ? 0x7F : bufferLength]);
|
|
63
63
|
const length = bufferLength >= 0x7F ? bufferFromBigInt(bufferLength, 3) : new Uint8Array();
|
|
64
|
-
|
|
64
|
+
const data = concat(header, length, buffer);
|
|
65
|
+
this.encrypt(data);
|
|
66
|
+
await this.connection.write(data);
|
|
65
67
|
}
|
|
66
68
|
deinitialize() {
|
|
67
69
|
this.initialized = false;
|
|
@@ -36,19 +36,23 @@ export class TransportIntermediate extends Transport {
|
|
|
36
36
|
{
|
|
37
37
|
const buffer = new Uint8Array(4);
|
|
38
38
|
await this.connection.read(buffer);
|
|
39
|
-
|
|
39
|
+
this.decrypt(buffer);
|
|
40
|
+
const dataView = new DataView(buffer.buffer);
|
|
40
41
|
length = dataView.getUint32(0, true);
|
|
41
42
|
}
|
|
42
43
|
const buffer = new Uint8Array(length);
|
|
43
44
|
await this.connection.read(buffer);
|
|
44
|
-
|
|
45
|
+
this.decrypt(buffer);
|
|
46
|
+
return buffer;
|
|
45
47
|
}
|
|
46
48
|
async send(buffer) {
|
|
47
49
|
if (!this.initialized) {
|
|
48
50
|
throw new Error("Transport not initialized");
|
|
49
51
|
}
|
|
50
52
|
const length = bufferFromBigInt(buffer.length, 4);
|
|
51
|
-
|
|
53
|
+
const data = concat(length, buffer);
|
|
54
|
+
this.encrypt(data);
|
|
55
|
+
await this.connection.write(data);
|
|
52
56
|
}
|
|
53
57
|
deinitialize() {
|
|
54
58
|
this.initialized = false;
|
package/esm/types/3_message.d.ts
CHANGED
|
@@ -126,6 +126,10 @@ export interface Message {
|
|
|
126
126
|
supergroupCreated?: true;
|
|
127
127
|
/** Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. */
|
|
128
128
|
channelCreated?: true;
|
|
129
|
+
/** Service message: auto-delete timer settings changed in the chat */
|
|
130
|
+
messageAutoDeleteTimerChanged?: {
|
|
131
|
+
messageAutoDeleteTime: number;
|
|
132
|
+
};
|
|
129
133
|
/** The group has been migrated to a supergroup with the specified identifier */
|
|
130
134
|
chatMigratedTo?: number;
|
|
131
135
|
/** The supergroup has been migrated from a group with the specified identifier */
|
package/esm/types/3_message.js
CHANGED
|
@@ -177,6 +177,9 @@ async function constructServiceMessage(message_, chat, getEntity, getMessage) {
|
|
|
177
177
|
message.videoChatStarted = {};
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
else if (message_.action instanceof types.MessageActionSetMessagesTTL) {
|
|
181
|
+
message.messageAutoDeleteTimerChanged = { messageAutoDeleteTime: message_.action.period || 0 };
|
|
182
|
+
}
|
|
180
183
|
return cleanObject(message);
|
|
181
184
|
}
|
|
182
185
|
export async function constructMessage(message_, getEntity, getMessage, getStickerSetName) {
|
|
@@ -368,7 +371,7 @@ export async function constructMessage(message_, getEntity, getMessage, getStick
|
|
|
368
371
|
message.document = constructDocument(document, fileName, getFileId(FileType.Document), fileUniqueId);
|
|
369
372
|
}
|
|
370
373
|
else {
|
|
371
|
-
|
|
374
|
+
message.document = constructDocument(document, new types.DocumentAttributeFilename({ fileName: "Unknown" }), getFileId(FileType.Document), fileUniqueId);
|
|
372
375
|
}
|
|
373
376
|
}
|
|
374
377
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function modExp(a: bigint, b: bigint, n: bigint): bigint;
|
|
2
2
|
export declare function mod(n: bigint, m: bigint): bigint;
|
|
3
|
+
export declare function mod(n: number, m: number): number;
|
|
3
4
|
export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, signed?: boolean): bigint;
|
|
4
5
|
export declare function getRandomBigInt(byteLength: number, little?: boolean, signed?: boolean): bigint;
|
|
5
6
|
export declare function getRandomId(): bigint;
|
package/esm/utilities/0_queue.js
CHANGED
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from "./deps/deno.land/std@0.
|
|
2
|
-
export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.
|
|
1
|
+
export * from "./deps/deno.land/std@0.204.0/assert/mod.js";
|
|
2
|
+
export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.3/mod.js";
|
|
3
3
|
export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/gzip/gzip.js";
|
|
4
4
|
export { Mutex, type MutexInterface } from "async-mutex";
|
|
5
5
|
export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
|
|
6
6
|
import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js";
|
|
7
7
|
export declare const debug: typeof debug_;
|
|
8
|
-
export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.
|
|
8
|
+
export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.204.0/encoding/base64.js";
|
package/script/0_deps.js
CHANGED
|
@@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.base64Encode = exports.base64Decode = exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.ctr256 = void 0;
|
|
18
|
-
__exportStar(require("./deps/deno.land/std@0.
|
|
19
|
-
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.3.
|
|
18
|
+
__exportStar(require("./deps/deno.land/std@0.204.0/assert/mod.js"), exports);
|
|
19
|
+
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.3.3/mod.js");
|
|
20
20
|
Object.defineProperty(exports, "ctr256", { enumerable: true, get: function () { return mod_js_1.ctr256; } });
|
|
21
21
|
Object.defineProperty(exports, "factorize", { enumerable: true, get: function () { return mod_js_1.factorize; } });
|
|
22
22
|
Object.defineProperty(exports, "ige256Decrypt", { enumerable: true, get: function () { return mod_js_1.ige256Decrypt; } });
|
|
@@ -32,6 +32,6 @@ Object.defineProperty(exports, "Parser", { enumerable: true, get: function () {
|
|
|
32
32
|
const mod_js_3 = require("./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js");
|
|
33
33
|
const debug = (v) => (0, mod_js_3.debug)(v);
|
|
34
34
|
exports.debug = debug;
|
|
35
|
-
var base64_js_1 = require("./deps/deno.land/std@0.
|
|
35
|
+
var base64_js_1 = require("./deps/deno.land/std@0.204.0/encoding/base64.js");
|
|
36
36
|
Object.defineProperty(exports, "base64Decode", { enumerable: true, get: function () { return base64_js_1.decode; } });
|
|
37
37
|
Object.defineProperty(exports, "base64Encode", { enumerable: true, get: function () { return base64_js_1.encode; } });
|
package/script/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 161;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.102";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
80
80
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
81
|
exports.INITIAL_DC = "2-test";
|
|
82
82
|
exports.LAYER = 161;
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
83
|
+
exports.APP_VERSION = "MTKruto 0.1.102";
|
|
84
84
|
// @ts-ignore: lib
|
|
85
85
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
86
86
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -43,14 +43,8 @@ async function encryptMessage(message, authKey, authKeyId, salt, sessionId) {
|
|
|
43
43
|
payloadWriter.writeInt32(message.seqNo);
|
|
44
44
|
payloadWriter.writeInt32(encoded.length);
|
|
45
45
|
payloadWriter.write(encoded);
|
|
46
|
-
payloadWriter.write(new Uint8Array(payloadWriter.buffer.length + 12
|
|
47
|
-
|
|
48
|
-
while (true) {
|
|
49
|
-
if (payload.length % 16 == 0 && (payload.length) % 4 == 0) {
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
payload = (0, _1_utilities_js_1.concat)(payload, new Uint8Array(1));
|
|
53
|
-
}
|
|
46
|
+
payloadWriter.write(new Uint8Array((0, _1_utilities_js_1.mod)(-(payloadWriter.buffer.length + 12), 16) + 12));
|
|
47
|
+
const payload = payloadWriter.buffer;
|
|
54
48
|
const messageKey = (await (0, _1_utilities_js_1.sha256)((0, _1_utilities_js_1.concat)(authKey.slice(88, 120), payload))).slice(8, 24);
|
|
55
49
|
const a = await (0, _1_utilities_js_1.sha256)((0, _1_utilities_js_1.concat)(messageKey, authKey.slice(0, 36)));
|
|
56
50
|
const b = await (0, _1_utilities_js_1.sha256)((0, _1_utilities_js_1.concat)(authKey.slice(40, 76), messageKey));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MaybePromise } from "../1_utilities.js";
|
|
2
|
+
import { functions, types } from "../2_tl.js";
|
|
2
3
|
import { CallbackQuery, ChatID, ForceReply, InlineKeyboardMarkup, InlineQuery, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
|
|
3
4
|
import { With } from "./0_utilities.js";
|
|
4
5
|
import { ClientPlainParams } from "./2_client_plain.js";
|
|
@@ -36,6 +37,7 @@ export interface ClientParams extends ClientPlainParams {
|
|
|
36
37
|
* Whether to automatically call `start` with no parameters in the first `invoke` call. Defaults to `true`.
|
|
37
38
|
*/
|
|
38
39
|
autoStart?: boolean;
|
|
40
|
+
errorHandler?: (err: unknown, function_: types.Type | functions.Function<unknown>, n: number) => MaybePromise<boolean>;
|
|
39
41
|
}
|
|
40
42
|
export interface AnswerCallbackQueryParams {
|
|
41
43
|
/** Text of the answer */
|
|
@@ -12,8 +12,9 @@ export declare const getStickerSetName: unique symbol;
|
|
|
12
12
|
export declare const handleMigrationError: unique symbol;
|
|
13
13
|
export declare const getMessageWithReply: unique symbol;
|
|
14
14
|
export declare const restartAuth: unique symbol;
|
|
15
|
+
export declare class ConnectionError extends Error {
|
|
16
|
+
}
|
|
15
17
|
export declare class Client extends ClientAbstract {
|
|
16
|
-
readonly storage: Storage;
|
|
17
18
|
readonly apiId: number | null;
|
|
18
19
|
readonly apiHash: string | null;
|
|
19
20
|
private auth;
|
|
@@ -22,6 +23,8 @@ export declare class Client extends ClientAbstract {
|
|
|
22
23
|
private promises;
|
|
23
24
|
private toAcknowledge;
|
|
24
25
|
private updateState?;
|
|
26
|
+
private readonly errorHandler?;
|
|
27
|
+
readonly storage: Storage;
|
|
25
28
|
readonly parseMode: ParseMode;
|
|
26
29
|
readonly appVersion: string;
|
|
27
30
|
readonly deviceModel: string;
|
|
@@ -38,7 +41,7 @@ export declare class Client extends ClientAbstract {
|
|
|
38
41
|
* @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
|
|
39
42
|
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
|
|
40
43
|
*/
|
|
41
|
-
constructor(storage
|
|
44
|
+
constructor(storage: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
|
|
42
45
|
private propagateConnectionState;
|
|
43
46
|
private lastPropagatedConnectionState;
|
|
44
47
|
protected stateChangeHandler: (connected: boolean) => void;
|
|
@@ -91,6 +94,7 @@ export declare class Client extends ClientAbstract {
|
|
|
91
94
|
start(params?: string | types.AuthExportedAuthorization | AuthorizeUserParams): Promise<void>;
|
|
92
95
|
private receiveLoop;
|
|
93
96
|
private pingLoop;
|
|
97
|
+
private pingLoopStarted;
|
|
94
98
|
private autoStarted;
|
|
95
99
|
private lastMsgId;
|
|
96
100
|
/**
|
|
@@ -141,7 +145,7 @@ export declare class Client extends ClientAbstract {
|
|
|
141
145
|
* @param messageId The ID of the message.
|
|
142
146
|
* @param text The new text of the message.
|
|
143
147
|
*/
|
|
144
|
-
editMessageText(chatId: ChatID, messageId: number, text: string, params?: EditMessageParams): Promise<
|
|
148
|
+
editMessageText(chatId: ChatID, messageId: number, text: string, params?: EditMessageParams): Promise<With<Message, "text">>;
|
|
145
149
|
private getMessagesInner;
|
|
146
150
|
/**
|
|
147
151
|
* Retrieve multiple messages.
|
|
@@ -164,7 +168,9 @@ export declare class Client extends ClientAbstract {
|
|
|
164
168
|
*
|
|
165
169
|
* @param fileId The identifier of the file to download.
|
|
166
170
|
*/
|
|
167
|
-
download(fileId: string
|
|
171
|
+
download(fileId: string, params?: {
|
|
172
|
+
chunkSize?: number;
|
|
173
|
+
}): Promise<AsyncGenerator<Uint8Array, void, unknown>>;
|
|
168
174
|
[getStickerSetName](inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
|
|
169
175
|
/**
|
|
170
176
|
* Forward multiple messages.
|
|
@@ -212,6 +218,16 @@ export declare class Client extends ClientAbstract {
|
|
|
212
218
|
* @param messageThreadId The thread to send the chat action to.
|
|
213
219
|
*/
|
|
214
220
|
sendChatAction(chatId: ChatID, action_: ChatAction, messageThreadId?: number): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Upload a file.
|
|
223
|
+
*
|
|
224
|
+
* @param contents The contents of the file.
|
|
225
|
+
*/
|
|
226
|
+
upload(contents: Uint8Array, params?: {
|
|
227
|
+
fileName?: string;
|
|
228
|
+
chunkSize?: number;
|
|
229
|
+
signal?: AbortSignal | null;
|
|
230
|
+
}): Promise<types.InputFile | types.InputFileBig>;
|
|
215
231
|
setMyCommands(commands: BotCommand[], params?: {
|
|
216
232
|
languageCode?: string;
|
|
217
233
|
scope?: BotCommandScope;
|
|
@@ -233,4 +249,39 @@ export declare class Client extends ClientAbstract {
|
|
|
233
249
|
filter<D extends Update>(predicate: (update: Update) => update is D, handler: Handler<D>): void;
|
|
234
250
|
filter(predicate: (update: Update) => MaybePromise<boolean>, handler: Handler): void;
|
|
235
251
|
on<T extends keyof Update, F extends keyof NonNullable<Update[T]>>(filter: T extends FilterableUpdates ? T | [T, F, ...F[]] : T, handler: Handler<FilterUpdate<Update, T, F>>): void;
|
|
252
|
+
setMyInfo(info: Omit<ConstructorParameters<typeof functions["BotsSetBotInfo"]>[0], "bot">): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
|
|
255
|
+
*/
|
|
256
|
+
setMyDescription({ description, languageCode }: {
|
|
257
|
+
description?: string;
|
|
258
|
+
languageCode?: string;
|
|
259
|
+
}): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Use this method to change the bot's name.
|
|
262
|
+
*/
|
|
263
|
+
setMyName({ name, languageCode }: {
|
|
264
|
+
name?: string;
|
|
265
|
+
languageCode?: string;
|
|
266
|
+
}): Promise<void>;
|
|
267
|
+
/**
|
|
268
|
+
* Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
|
|
269
|
+
*/
|
|
270
|
+
setMyShortDescription({ shortDescription: about, languageCode }: {
|
|
271
|
+
shortDescription?: string;
|
|
272
|
+
languageCode?: string;
|
|
273
|
+
}): Promise<void>;
|
|
274
|
+
private getMyInfo;
|
|
275
|
+
/**
|
|
276
|
+
* Use this method to get the current bot description for the given user language.
|
|
277
|
+
*/
|
|
278
|
+
getMyDescription(languageCode?: string): Promise<string>;
|
|
279
|
+
/**
|
|
280
|
+
* Use this method to get the current bot name for the given user language.
|
|
281
|
+
*/
|
|
282
|
+
getMyName(languageCode?: string): Promise<string>;
|
|
283
|
+
/**
|
|
284
|
+
* Use this method to get the current bot short description for the given user language.
|
|
285
|
+
*/
|
|
286
|
+
getMyShortDescription(languageCode?: string): Promise<string>;
|
|
236
287
|
}
|