@mtkruto/node 0.1.0 → 0.1.101
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 +4 -3
- package/esm/0_deps.js +4 -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 +19 -3
- package/esm/client/4_client.js +209 -68
- package/esm/connection/1_connection_web_socket.js +5 -2
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.js +1 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.d.ts +2 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.js +24 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.d.ts +2 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.js +27 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/mod.d.ts +1 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/mod.js +21 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/util.d.ts +13 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/util.js +48 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.ts +125 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.js +3337 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/mod.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/mod.js +39 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/crypto.d.ts +157 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/crypto.js +266 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/keystack.d.ts +4 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/keystack.js +6 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/mod.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/mod.js +14 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.d.ts +28 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.js +54 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/to_hash_string.d.ts +19 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/to_hash_string.js +31 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/unstable/keystack.d.ts +46 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/unstable/keystack.js +149 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/_util.d.ts +1 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/_util.js +26 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/base64.d.ts +23 -0
- package/{script/deps/deno.land/std@0.201.0 → esm/deps/deno.land/std@0.203.0}/encoding/base64.js +23 -18
- package/esm/deps/deno.land/std@0.203.0/encoding/base64url.d.ts +24 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/base64url.js +80 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/hex.d.ts +18 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/hex.js +115 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.js +1 -1
- package/{script/deps/deno.land/x/tgcrypto@0.2.1 → esm/deps/deno.land/x/tgcrypto@0.3.3}/mod.d.ts +2 -6
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/mod.js +164 -0
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +324 -0
- package/esm/transport/0_obfuscation.js +1 -1
- package/esm/transport/0_transport.js +2 -2
- package/esm/types/3_message.js +1 -1
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +1 -0
- package/esm/utilities/0_crypto.d.ts +1 -2
- package/esm/utilities/0_crypto.js +3 -12
- package/esm/utilities/0_queue.js +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +4 -3
- package/script/0_deps.js +7 -6
- 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 +19 -3
- package/script/client/4_client.js +208 -66
- package/script/connection/1_connection_web_socket.js +5 -2
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.js +1 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.d.ts +2 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.js +29 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.d.ts +2 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.js +32 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/mod.d.ts +1 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/mod.js +25 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/util.d.ts +13 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/util.js +54 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.ts +125 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.js +3345 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/mod.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/mod.js +44 -0
- package/script/deps/deno.land/std@0.203.0/crypto/crypto.d.ts +157 -0
- package/script/deps/deno.land/std@0.203.0/crypto/crypto.js +292 -0
- package/script/deps/deno.land/std@0.203.0/crypto/keystack.d.ts +4 -0
- package/script/deps/deno.land/std@0.203.0/crypto/keystack.js +22 -0
- package/script/deps/deno.land/std@0.203.0/crypto/mod.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/crypto/mod.js +30 -0
- package/script/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.d.ts +28 -0
- package/script/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.js +58 -0
- package/script/deps/deno.land/std@0.203.0/crypto/to_hash_string.d.ts +19 -0
- package/script/deps/deno.land/std@0.203.0/crypto/to_hash_string.js +35 -0
- package/script/deps/deno.land/std@0.203.0/crypto/unstable/keystack.d.ts +46 -0
- package/script/deps/deno.land/std@0.203.0/crypto/unstable/keystack.js +176 -0
- package/script/deps/deno.land/std@0.203.0/encoding/_util.d.ts +1 -0
- package/script/deps/deno.land/std@0.203.0/encoding/_util.js +30 -0
- package/script/deps/deno.land/std@0.203.0/encoding/base64.d.ts +23 -0
- package/{esm/deps/deno.land/std@0.201.0 → script/deps/deno.land/std@0.203.0}/encoding/base64.js +28 -13
- package/script/deps/deno.land/std@0.203.0/encoding/base64url.d.ts +24 -0
- package/script/deps/deno.land/std@0.203.0/encoding/base64url.js +108 -0
- package/script/deps/deno.land/std@0.203.0/encoding/hex.d.ts +18 -0
- package/script/deps/deno.land/std@0.203.0/encoding/hex.js +122 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.js +1 -1
- package/{esm/deps/deno.land/x/tgcrypto@0.2.1 → script/deps/deno.land/x/tgcrypto@0.3.3}/mod.d.ts +2 -6
- package/script/deps/deno.land/x/tgcrypto@0.3.3/mod.js +177 -0
- package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +326 -0
- package/script/transport/0_obfuscation.js +1 -1
- package/script/transport/0_transport.js +2 -2
- package/script/types/3_message.js +1 -1
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +1 -0
- package/script/utilities/0_crypto.d.ts +1 -2
- package/script/utilities/0_crypto.js +2 -11
- 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.2.1/mod.js +0 -81
- package/esm/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.js +0 -991
- package/script/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
- package/script/deps/deno.land/x/tgcrypto@0.2.1/mod.js +0 -95
- package/script/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.js +0 -993
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.d.ts +0 -0
- package/esm/deps/deno.land/x/{tgcrypto@0.2.1 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.d.ts +1 -1
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.2.1 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ctr256 } from "../0_deps.js";
|
|
2
2
|
export class CTR {
|
|
3
3
|
constructor(key, iv) {
|
|
4
4
|
Object.defineProperty(this, "key", {
|
|
@@ -20,18 +20,9 @@ export class CTR {
|
|
|
20
20
|
value: new Uint8Array(1)
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
call(data) {
|
|
24
24
|
const v = new Uint8Array(data); // TODO: don't copy
|
|
25
|
-
|
|
26
|
-
this.iv = iv;
|
|
27
|
-
this.state = state;
|
|
28
|
-
return v;
|
|
29
|
-
}
|
|
30
|
-
decrypt(data) {
|
|
31
|
-
const v = new Uint8Array(data); // TODO: don't copy
|
|
32
|
-
const [iv, state] = ctr256Decrypt(v, this.key, this.iv, this.state);
|
|
33
|
-
this.iv = iv;
|
|
34
|
-
this.state = state;
|
|
25
|
+
ctr256(v, this.key, this.iv, this.state);
|
|
35
26
|
return v;
|
|
36
27
|
}
|
|
37
28
|
}
|
package/esm/utilities/0_queue.js
CHANGED
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from "./deps/deno.land/std@0.
|
|
2
|
-
export {
|
|
1
|
+
export * from "./deps/deno.land/std@0.203.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.203.0/encoding/base64.js";
|
|
9
|
+
export { crypto } from "./deps/deno.land/std@0.203.0/crypto/mod.js";
|
package/script/0_deps.js
CHANGED
|
@@ -14,11 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.base64Encode = exports.base64Decode = exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.
|
|
18
|
-
__exportStar(require("./deps/deno.land/std@0.
|
|
19
|
-
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
Object.defineProperty(exports, "ctr256Encrypt", { enumerable: true, get: function () { return mod_js_1.ctr256Encrypt; } });
|
|
17
|
+
exports.crypto = 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.203.0/assert/mod.js"), exports);
|
|
19
|
+
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.3.3/mod.js");
|
|
20
|
+
Object.defineProperty(exports, "ctr256", { enumerable: true, get: function () { return mod_js_1.ctr256; } });
|
|
22
21
|
Object.defineProperty(exports, "factorize", { enumerable: true, get: function () { return mod_js_1.factorize; } });
|
|
23
22
|
Object.defineProperty(exports, "ige256Decrypt", { enumerable: true, get: function () { return mod_js_1.ige256Decrypt; } });
|
|
24
23
|
Object.defineProperty(exports, "ige256Encrypt", { enumerable: true, get: function () { return mod_js_1.ige256Encrypt; } });
|
|
@@ -33,6 +32,8 @@ Object.defineProperty(exports, "Parser", { enumerable: true, get: function () {
|
|
|
33
32
|
const mod_js_3 = require("./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js");
|
|
34
33
|
const debug = (v) => (0, mod_js_3.debug)(v);
|
|
35
34
|
exports.debug = debug;
|
|
36
|
-
var base64_js_1 = require("./deps/deno.land/std@0.
|
|
35
|
+
var base64_js_1 = require("./deps/deno.land/std@0.203.0/encoding/base64.js");
|
|
37
36
|
Object.defineProperty(exports, "base64Decode", { enumerable: true, get: function () { return base64_js_1.decode; } });
|
|
38
37
|
Object.defineProperty(exports, "base64Encode", { enumerable: true, get: function () { return base64_js_1.encode; } });
|
|
38
|
+
var mod_js_4 = require("./deps/deno.land/std@0.203.0/crypto/mod.js");
|
|
39
|
+
Object.defineProperty(exports, "crypto", { enumerable: true, get: function () { return mod_js_4.crypto; } });
|
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.101";
|
|
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.101";
|
|
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
|
/**
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Client = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
|
|
3
|
+
exports.Client = exports.ConnectionError = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
|
|
4
4
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
5
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
6
6
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
@@ -20,11 +20,15 @@ const dGap = (0, _0_deps_js_1.debug)("Client/recoverUpdateGap");
|
|
|
20
20
|
const dGapC = (0, _0_deps_js_1.debug)("Client/recoverChannelUpdateGap");
|
|
21
21
|
const dAuth = (0, _0_deps_js_1.debug)("Client/authorize");
|
|
22
22
|
const dRecv = (0, _0_deps_js_1.debug)("Client/receiveLoop");
|
|
23
|
+
const dUpload = (0, _0_deps_js_1.debug)("Client/upload");
|
|
23
24
|
exports.getEntity = Symbol();
|
|
24
25
|
exports.getStickerSetName = Symbol();
|
|
25
26
|
exports.handleMigrationError = Symbol();
|
|
26
27
|
exports.getMessageWithReply = Symbol();
|
|
27
28
|
exports.restartAuth = Symbol();
|
|
29
|
+
class ConnectionError extends Error {
|
|
30
|
+
}
|
|
31
|
+
exports.ConnectionError = ConnectionError;
|
|
28
32
|
class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
29
33
|
/**
|
|
30
34
|
* Constructs the client.
|
|
@@ -33,14 +37,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
33
37
|
* @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
|
|
34
38
|
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
|
|
35
39
|
*/
|
|
36
|
-
constructor(storage
|
|
40
|
+
constructor(storage, apiId = 0, apiHash = "", params) {
|
|
37
41
|
super(params);
|
|
38
|
-
Object.defineProperty(this, "storage", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: storage
|
|
43
|
-
});
|
|
44
42
|
Object.defineProperty(this, "apiId", {
|
|
45
43
|
enumerable: true,
|
|
46
44
|
configurable: true,
|
|
@@ -89,6 +87,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
89
87
|
writable: true,
|
|
90
88
|
value: void 0
|
|
91
89
|
});
|
|
90
|
+
Object.defineProperty(this, "errorHandler", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
value: void 0
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(this, "storage", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
configurable: true,
|
|
99
|
+
writable: true,
|
|
100
|
+
value: void 0
|
|
101
|
+
});
|
|
92
102
|
Object.defineProperty(this, "parseMode", {
|
|
93
103
|
enumerable: true,
|
|
94
104
|
configurable: true,
|
|
@@ -192,6 +202,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
192
202
|
writable: true,
|
|
193
203
|
value: null
|
|
194
204
|
});
|
|
205
|
+
Object.defineProperty(this, "pingLoopStarted", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
configurable: true,
|
|
208
|
+
writable: true,
|
|
209
|
+
value: false
|
|
210
|
+
});
|
|
195
211
|
Object.defineProperty(this, "autoStarted", {
|
|
196
212
|
enumerable: true,
|
|
197
213
|
configurable: true,
|
|
@@ -231,6 +247,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
231
247
|
writable: true,
|
|
232
248
|
value: _3_types_js_2.skip
|
|
233
249
|
});
|
|
250
|
+
this.storage = storage ?? new _3_storage_js_1.StorageMemory();
|
|
234
251
|
this.parseMode = params?.parseMode ?? null;
|
|
235
252
|
this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
|
|
236
253
|
this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
|
|
@@ -240,6 +257,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
240
257
|
this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
|
|
241
258
|
this.publicKeys = params?.publicKeys;
|
|
242
259
|
this.autoStart = params?.autoStart ?? true;
|
|
260
|
+
this.errorHandler = params?.errorHandler;
|
|
243
261
|
}
|
|
244
262
|
propagateConnectionState(connectionState) {
|
|
245
263
|
return this.handle({ connectionState }, _0_utilities_js_1.resolve);
|
|
@@ -309,7 +327,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
309
327
|
}
|
|
310
328
|
d("encrypted client connected");
|
|
311
329
|
(0, _1_utilities_js_1.drop)(this.receiveLoop());
|
|
312
|
-
(0, _1_utilities_js_1.drop)(this.pingLoop());
|
|
313
330
|
}
|
|
314
331
|
finally {
|
|
315
332
|
release();
|
|
@@ -551,7 +568,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
551
568
|
}
|
|
552
569
|
async receiveLoop() {
|
|
553
570
|
if (!this.auth || !this.transport) {
|
|
554
|
-
throw new
|
|
571
|
+
throw new ConnectionError("Not connected");
|
|
555
572
|
}
|
|
556
573
|
while (this.connected) {
|
|
557
574
|
try {
|
|
@@ -579,6 +596,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
579
596
|
if (body instanceof _2_tl_js_1.types._TypeUpdates || body instanceof _2_tl_js_1.types._TypeUpdate) {
|
|
580
597
|
this.processUpdatesQueue.add(() => this.processUpdates(body));
|
|
581
598
|
}
|
|
599
|
+
else if (body instanceof _2_tl_js_1.types.NewSessionCreated) {
|
|
600
|
+
this.state.salt = body.serverSalt;
|
|
601
|
+
}
|
|
582
602
|
else if (message.body instanceof _2_tl_js_1.RPCResult) {
|
|
583
603
|
let result = message.body.result;
|
|
584
604
|
if (result instanceof _2_tl_js_1.types.GZIPPacked) {
|
|
@@ -642,10 +662,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
642
662
|
(0, _1_utilities_js_1.drop)(this.recoverUpdateGap("deserialize"));
|
|
643
663
|
}
|
|
644
664
|
else {
|
|
645
|
-
|
|
665
|
+
dRecv("uncaught error: %o", err);
|
|
646
666
|
}
|
|
647
667
|
}
|
|
648
668
|
}
|
|
669
|
+
if (!this.connected) {
|
|
670
|
+
for (const { reject } of this.promises.values()) {
|
|
671
|
+
reject(new ConnectionError("Connection was closed"));
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
676
|
+
}
|
|
649
677
|
}
|
|
650
678
|
async pingLoop() {
|
|
651
679
|
while (this.connected) {
|
|
@@ -664,41 +692,61 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
664
692
|
await this.start();
|
|
665
693
|
}
|
|
666
694
|
else {
|
|
667
|
-
throw new
|
|
695
|
+
throw new ConnectionError("Not connected");
|
|
668
696
|
}
|
|
669
697
|
}
|
|
670
698
|
if (!this.auth || !this.transport) {
|
|
671
699
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
672
700
|
}
|
|
673
|
-
let
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
701
|
+
let n = 1;
|
|
702
|
+
while (true) {
|
|
703
|
+
try {
|
|
704
|
+
let seqNo = this.state.seqNo * 2;
|
|
705
|
+
if (!(function_ instanceof _2_tl_js_1.functions.Ping) && !(function_ instanceof _2_tl_js_1.types.MsgsAck)) {
|
|
706
|
+
seqNo++;
|
|
707
|
+
this.state.seqNo++;
|
|
708
|
+
}
|
|
709
|
+
const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
|
|
710
|
+
const message = new _2_tl_js_1.Message_(messageId, seqNo, function_);
|
|
711
|
+
await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
712
|
+
d("invoked %s", function_.constructor.name);
|
|
713
|
+
if (noWait) {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
let result;
|
|
717
|
+
try {
|
|
718
|
+
result = await new Promise((resolve, reject) => {
|
|
719
|
+
this.promises.set(message.id, { resolve, reject });
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
catch (err) {
|
|
723
|
+
if (err instanceof _4_errors_js_1.AuthKeyUnregistered) {
|
|
724
|
+
await this.propagateAuthorizationState(false);
|
|
725
|
+
}
|
|
726
|
+
throw err;
|
|
727
|
+
}
|
|
728
|
+
if (result instanceof _2_tl_js_1.types.BadServerSalt) {
|
|
729
|
+
return await this.invoke(function_);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
if (!this.pingLoopStarted) {
|
|
733
|
+
(0, _1_utilities_js_1.drop)(this.pingLoop());
|
|
734
|
+
this.pingLoopStarted = true;
|
|
735
|
+
}
|
|
736
|
+
return result;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
catch (err) {
|
|
740
|
+
if (this.errorHandler === undefined) {
|
|
741
|
+
throw err;
|
|
742
|
+
}
|
|
743
|
+
if (this.errorHandler !== undefined && await this.errorHandler(err, function_, n++)) {
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
throw err;
|
|
748
|
+
}
|
|
694
749
|
}
|
|
695
|
-
throw err;
|
|
696
|
-
}
|
|
697
|
-
if (result instanceof _2_tl_js_1.types.BadServerSalt) {
|
|
698
|
-
return await this.invoke(function_);
|
|
699
|
-
}
|
|
700
|
-
else {
|
|
701
|
-
return result;
|
|
702
750
|
}
|
|
703
751
|
}
|
|
704
752
|
/**
|
|
@@ -1308,29 +1356,30 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1308
1356
|
const messages = await this.getMessages(chatId, [messageId]);
|
|
1309
1357
|
return messages[0] ?? null;
|
|
1310
1358
|
}
|
|
1311
|
-
async *downloadInner(location, dcId) {
|
|
1312
|
-
|
|
1313
|
-
if (
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1359
|
+
async *downloadInner(location, dcId, params) {
|
|
1360
|
+
const chunkSize = params?.chunkSize ?? 1024 * 1024;
|
|
1361
|
+
if ((0, _1_utilities_js_1.mod)(chunkSize, 1024) != 0) {
|
|
1362
|
+
throw new Error("chunkSize must be divisible by 1024");
|
|
1363
|
+
}
|
|
1364
|
+
const exportedAuth = await this.invoke(new _2_tl_js_1.functions.AuthExportAuthorization({ dcId }));
|
|
1365
|
+
const client = new Client(new _3_storage_js_1.StorageMemory(), this.apiId, this.apiHash, {
|
|
1366
|
+
transportProvider: this.transportProvider,
|
|
1367
|
+
appVersion: this.appVersion,
|
|
1368
|
+
deviceModel: this.deviceModel,
|
|
1369
|
+
langCode: this.langCode,
|
|
1370
|
+
langPack: this.langPack,
|
|
1371
|
+
systemLangCode: this.systemLangCode,
|
|
1372
|
+
systemVersion: this.systemVersion,
|
|
1373
|
+
cdn: true,
|
|
1374
|
+
});
|
|
1375
|
+
let dc = String(dcId);
|
|
1376
|
+
if (this.dcId < 0) {
|
|
1377
|
+
dc += "-test";
|
|
1378
|
+
}
|
|
1379
|
+
await client.setDc(dc);
|
|
1380
|
+
await client.connect();
|
|
1381
|
+
await client.authorize(exportedAuth);
|
|
1382
|
+
const limit = chunkSize;
|
|
1334
1383
|
let offset = 0n;
|
|
1335
1384
|
while (true) {
|
|
1336
1385
|
const file = await (client ?? this).invoke(new _2_tl_js_1.functions.UploadGetFile({ location, offset, limit }));
|
|
@@ -1353,14 +1402,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1353
1402
|
*
|
|
1354
1403
|
* @param fileId The identifier of the file to download.
|
|
1355
1404
|
*/
|
|
1356
|
-
async download(fileId) {
|
|
1405
|
+
async download(fileId, params) {
|
|
1357
1406
|
const fileId_ = _3_types_js_1.FileID.decode(fileId);
|
|
1358
1407
|
switch (fileId_.fileType) {
|
|
1359
1408
|
case _3_types_js_1.FileType.ChatPhoto: {
|
|
1360
1409
|
const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
|
|
1361
1410
|
const peer = await this.getInputPeer(fileId_.params.chatId);
|
|
1362
1411
|
const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photoId: fileId_.params.mediaId });
|
|
1363
|
-
return this.downloadInner(location);
|
|
1412
|
+
return this.downloadInner(location, fileId_.dcId, params);
|
|
1364
1413
|
}
|
|
1365
1414
|
case _3_types_js_1.FileType.Photo: {
|
|
1366
1415
|
if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
|
|
@@ -1372,7 +1421,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1372
1421
|
fileReference: fileId_.params.fileReference,
|
|
1373
1422
|
thumbSize: fileId_.params.thumbnailSize,
|
|
1374
1423
|
});
|
|
1375
|
-
return this.downloadInner(location);
|
|
1424
|
+
return this.downloadInner(location, fileId_.dcId, params);
|
|
1376
1425
|
}
|
|
1377
1426
|
default:
|
|
1378
1427
|
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
@@ -1610,6 +1659,99 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1610
1659
|
}
|
|
1611
1660
|
await this.invoke(new _2_tl_js_1.functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
|
|
1612
1661
|
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Upload a file.
|
|
1664
|
+
*
|
|
1665
|
+
* @param contents The contents of the file.
|
|
1666
|
+
*/
|
|
1667
|
+
async upload(contents, params) {
|
|
1668
|
+
const isBig = contents.length > 1048576; // 10 MB
|
|
1669
|
+
const chunkSize = params?.chunkSize ?? 512 * 1024;
|
|
1670
|
+
if ((0, _1_utilities_js_1.mod)(chunkSize, 1024) != 0) {
|
|
1671
|
+
throw new Error("chunkSize must be divisible by 1024");
|
|
1672
|
+
}
|
|
1673
|
+
const signal = params?.signal;
|
|
1674
|
+
dUpload("uploading " + (isBig ? "big " : "") + "file of size " + contents.length + " with chunk size of " + chunkSize);
|
|
1675
|
+
const fileId = (0, _1_utilities_js_1.getRandomId)();
|
|
1676
|
+
const name = params?.fileName ?? fileId.toString();
|
|
1677
|
+
const client = new Client(this.storage, this.apiId, this.apiHash, {
|
|
1678
|
+
transportProvider: this.transportProvider,
|
|
1679
|
+
appVersion: this.appVersion,
|
|
1680
|
+
deviceModel: this.deviceModel,
|
|
1681
|
+
langCode: this.langCode,
|
|
1682
|
+
langPack: this.langPack,
|
|
1683
|
+
systemLangCode: this.systemLangCode,
|
|
1684
|
+
systemVersion: this.systemVersion,
|
|
1685
|
+
cdn: true,
|
|
1686
|
+
initialDc: this.initialDc,
|
|
1687
|
+
autoStart: false,
|
|
1688
|
+
});
|
|
1689
|
+
signal?.addEventListener("abort", () => (0, _1_utilities_js_1.drop)(client.disconnect()));
|
|
1690
|
+
client.state.salt = this.state.salt;
|
|
1691
|
+
await client.connect();
|
|
1692
|
+
let part = 0;
|
|
1693
|
+
const md5sum = await _0_deps_js_1.crypto.subtle.digest("MD5", contents).then((v) => [...new Uint8Array(v)]
|
|
1694
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
1695
|
+
.join(""));
|
|
1696
|
+
const partCount = Math.ceil(contents.length / chunkSize);
|
|
1697
|
+
try {
|
|
1698
|
+
main: for (; part < partCount; part++) {
|
|
1699
|
+
chunk: while (true) {
|
|
1700
|
+
try {
|
|
1701
|
+
const start = part * chunkSize;
|
|
1702
|
+
const end = start + chunkSize;
|
|
1703
|
+
const bytes = contents.slice(start, end);
|
|
1704
|
+
if (bytes.length == 0) {
|
|
1705
|
+
continue main;
|
|
1706
|
+
}
|
|
1707
|
+
if (isBig) {
|
|
1708
|
+
await client.invoke(new _2_tl_js_1.functions.UploadSaveBigFilePart({ fileId, filePart: part, bytes, fileTotalParts: partCount }));
|
|
1709
|
+
}
|
|
1710
|
+
else {
|
|
1711
|
+
await client.invoke(new _2_tl_js_1.functions.UploadSaveFilePart({ fileId, bytes, filePart: part }));
|
|
1712
|
+
}
|
|
1713
|
+
dUpload((part + 1) + " out of " + partCount + " chunks have been uploaded so far");
|
|
1714
|
+
break chunk;
|
|
1715
|
+
}
|
|
1716
|
+
catch (err) {
|
|
1717
|
+
if (signal?.aborted) {
|
|
1718
|
+
break main;
|
|
1719
|
+
}
|
|
1720
|
+
if (err instanceof _4_errors_js_1.FloodWait) {
|
|
1721
|
+
dUpload("got a flood wait of " + err.seconds + " seconds");
|
|
1722
|
+
await new Promise((r) => setTimeout(r, err.seconds * 1000));
|
|
1723
|
+
}
|
|
1724
|
+
else if (err instanceof ConnectionError) {
|
|
1725
|
+
while (true) {
|
|
1726
|
+
try {
|
|
1727
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
1728
|
+
await client.connect();
|
|
1729
|
+
}
|
|
1730
|
+
catch {
|
|
1731
|
+
if (signal?.aborted) {
|
|
1732
|
+
break main;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
else {
|
|
1738
|
+
throw err;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
finally {
|
|
1745
|
+
(0, _1_utilities_js_1.drop)(client.disconnect());
|
|
1746
|
+
}
|
|
1747
|
+
dUpload("uploaded all " + partCount + " chunk(s)");
|
|
1748
|
+
if (isBig) {
|
|
1749
|
+
return new _2_tl_js_1.types.InputFileBig({ id: fileId, parts: contents.length / chunkSize, name });
|
|
1750
|
+
}
|
|
1751
|
+
else {
|
|
1752
|
+
return new _2_tl_js_1.types.InputFile({ id: fileId, name, parts: part, md5Checksum: md5sum });
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1613
1755
|
async setMyCommands(commands, params) {
|
|
1614
1756
|
await this.invoke(new _2_tl_js_1.functions.BotsSetBotCommands({
|
|
1615
1757
|
commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
|