@mtkruto/node 0.76.1 → 0.77.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/0_deps.d.ts +1 -2
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +1 -2
- package/esm/0_errors.d.ts +6 -0
- package/esm/0_errors.d.ts.map +1 -1
- package/esm/0_errors.js +11 -0
- package/esm/1_utilities.d.ts +1 -2
- package/esm/1_utilities.d.ts.map +1 -1
- package/esm/1_utilities.js +1 -2
- package/esm/2_tl.d.ts +0 -1
- package/esm/2_tl.d.ts.map +1 -1
- package/esm/2_tl.js +0 -1
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password.js +8 -8
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +2 -2
- package/esm/client/1_client_plain.js +14 -14
- package/{script/deps/jsr.io/@std/assert/1.0.12 → esm/deps/jsr.io/@std/assert/1.0.16}/is_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/not_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/throws.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +6 -5
- package/esm/session/2_session_plain.js +2 -2
- package/esm/tl/0_utilities.d.ts +1 -0
- package/esm/tl/0_utilities.d.ts.map +1 -1
- package/esm/tl/0_utilities.js +3 -0
- package/esm/tl/1_tl_reader.d.ts +6 -8
- package/esm/tl/1_tl_reader.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +39 -30
- package/esm/tl/1_tl_writer.d.ts +5 -5
- package/esm/tl/1_tl_writer.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +49 -35
- package/esm/transport/0_obfuscation.d.ts.map +1 -1
- package/esm/transport/0_obfuscation.js +2 -2
- package/esm/transport/1_transport_abridged.js +3 -3
- package/esm/transport/1_transport_intermediate.js +2 -2
- package/esm/types/0_link_preview_media_size.d.ts +19 -0
- package/esm/types/0_link_preview_media_size.d.ts.map +1 -1
- package/esm/types/0_link_preview_media_size.js +19 -0
- package/esm/types/7_saved_chat.d.ts.map +1 -1
- package/esm/types/7_saved_chat.js +1 -1
- package/esm/utilities/0_int.d.ts +52 -0
- package/esm/utilities/0_int.d.ts.map +1 -0
- package/esm/utilities/0_int.js +141 -0
- package/esm/utilities/0_int_test.d.ts.map +1 -0
- package/esm/utilities/1_auth.d.ts.map +1 -1
- package/esm/utilities/1_auth.js +3 -4
- package/esm/utilities/1_base64.js +1 -1
- package/esm/utilities/1_crypto.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +2 -3
- package/esm/utilities/1_math.js +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -2
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +2 -4
- package/script/0_errors.d.ts +6 -0
- package/script/0_errors.d.ts.map +1 -1
- package/script/0_errors.js +13 -1
- package/script/1_utilities.d.ts +1 -2
- package/script/1_utilities.d.ts.map +1 -1
- package/script/1_utilities.js +1 -2
- package/script/2_tl.d.ts +0 -1
- package/script/2_tl.d.ts.map +1 -1
- package/script/2_tl.js +1 -3
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +7 -7
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +1 -1
- package/script/client/1_client_plain.js +13 -13
- package/{esm/deps/jsr.io/@std/assert/1.0.12 → script/deps/jsr.io/@std/assert/1.0.16}/is_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/not_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/throws.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts.map +1 -1
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +5 -4
- package/script/session/2_session_plain.js +1 -1
- package/script/tl/0_utilities.d.ts +1 -0
- package/script/tl/0_utilities.d.ts.map +1 -1
- package/script/tl/0_utilities.js +4 -0
- package/script/tl/1_tl_reader.d.ts +6 -8
- package/script/tl/1_tl_reader.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +38 -30
- package/script/tl/1_tl_writer.d.ts +5 -5
- package/script/tl/1_tl_writer.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +49 -35
- package/script/transport/0_obfuscation.d.ts.map +1 -1
- package/script/transport/0_obfuscation.js +1 -1
- package/script/transport/1_transport_abridged.js +2 -2
- package/script/transport/1_transport_intermediate.js +1 -1
- package/script/types/0_link_preview_media_size.d.ts +19 -0
- package/script/types/0_link_preview_media_size.d.ts.map +1 -1
- package/script/types/0_link_preview_media_size.js +19 -0
- package/script/types/7_saved_chat.d.ts.map +1 -1
- package/script/types/7_saved_chat.js +3 -3
- package/script/utilities/0_int.d.ts +52 -0
- package/script/utilities/0_int.d.ts.map +1 -0
- package/script/utilities/{0_bigint.js → 0_int.js} +66 -15
- package/script/utilities/0_int_test.d.ts.map +1 -0
- package/script/utilities/1_auth.d.ts.map +1 -1
- package/script/utilities/1_auth.js +4 -5
- package/script/utilities/1_base64.js +2 -2
- package/script/utilities/1_crypto.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +2 -3
- package/script/utilities/1_math.js +4 -4
- package/esm/deps/jsr.io/@std/assert/1.0.12/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.12/equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.12/instance_of.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.13/assertion_error.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.13/unreachable.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -52
- package/esm/tl/0_tl_error.d.ts +0 -23
- package/esm/tl/0_tl_error.d.ts.map +0 -1
- package/esm/tl/0_tl_error.js +0 -22
- package/esm/utilities/0_bigint.d.ts +0 -10
- package/esm/utilities/0_bigint.d.ts.map +0 -1
- package/esm/utilities/0_bigint.js +0 -91
- package/esm/utilities/0_bigint_test.d.ts.map +0 -1
- package/esm/utilities/0_buffer.d.ts +0 -21
- package/esm/utilities/0_buffer.d.ts.map +0 -1
- package/esm/utilities/0_buffer.js +0 -51
- package/esm/utilities/0_buffer_test.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.12/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.12/equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.12/instance_of.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts +0 -26
- package/script/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.13/assertion_error.js +0 -34
- package/script/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.13/unreachable.js +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -55
- package/script/tl/0_tl_error.d.ts +0 -23
- package/script/tl/0_tl_error.d.ts.map +0 -1
- package/script/tl/0_tl_error.js +0 -26
- package/script/utilities/0_bigint.d.ts +0 -10
- package/script/utilities/0_bigint.d.ts.map +0 -1
- package/script/utilities/0_bigint_test.d.ts.map +0 -1
- package/script/utilities/0_buffer.d.ts +0 -21
- package/script/utilities/0_buffer.d.ts.map +0 -1
- package/script/utilities/0_buffer.js +0 -54
- package/script/utilities/0_buffer_test.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.js +0 -0
- /package/script/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts +0 -0
- /package/script/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.js +0 -0
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
-
*
|
|
5
|
-
* This file is part of MTKruto.
|
|
6
|
-
*
|
|
7
|
-
* This program is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU Lesser General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
20
|
-
export declare function bufferFromBigInt(int: bigint | number, byteCount: number, littleEndian?: boolean, signed?: boolean): Uint8Array<ArrayBuffer>;
|
|
21
|
-
//# sourceMappingURL=0_buffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_buffer.d.ts","sourceRoot":"","sources":["../../src/utilities/0_buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,UAAO,EAAE,MAAM,UAAQ,2BAoC5G"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
-
*
|
|
5
|
-
* This file is part of MTKruto.
|
|
6
|
-
*
|
|
7
|
-
* This program is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU Lesser General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
20
|
-
const bufferFromHexString = (hexString) => Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
21
|
-
export function bufferFromBigInt(int, byteCount, littleEndian = true, signed = false) {
|
|
22
|
-
const actualByteCount = Math.ceil(int.toString(2).length / 8);
|
|
23
|
-
if (byteCount < actualByteCount) {
|
|
24
|
-
throw new Error("Int too big");
|
|
25
|
-
}
|
|
26
|
-
if (byteCount === 4 || byteCount === 2) { // fast path
|
|
27
|
-
const buffer = new Uint8Array(byteCount);
|
|
28
|
-
const dataView = new DataView(buffer.buffer);
|
|
29
|
-
(byteCount === 2 ? signed ? dataView.setInt16 : dataView.setUint16 : signed ? dataView.setInt32 : dataView.setUint32).call(dataView, 0, Number(int), littleEndian);
|
|
30
|
-
return buffer;
|
|
31
|
-
}
|
|
32
|
-
int = BigInt(typeof int === "number" ? Math.ceil(int) : int);
|
|
33
|
-
if (byteCount === 8) { // fast path
|
|
34
|
-
const buffer = new Uint8Array(byteCount);
|
|
35
|
-
const dataView = new DataView(buffer.buffer);
|
|
36
|
-
(signed ? dataView.setBigInt64 : dataView.setBigUint64).call(dataView, 0, int, littleEndian);
|
|
37
|
-
return buffer;
|
|
38
|
-
}
|
|
39
|
-
if (!signed && int < 0n) {
|
|
40
|
-
throw new Error("Got unexpected signed int");
|
|
41
|
-
}
|
|
42
|
-
if (signed && int < 0n) {
|
|
43
|
-
int = 2n ** BigInt(byteCount * 8) + int;
|
|
44
|
-
}
|
|
45
|
-
const hex = int.toString(16).padStart(byteCount * 2, "0");
|
|
46
|
-
const buffer = bufferFromHexString(hex);
|
|
47
|
-
if (littleEndian) {
|
|
48
|
-
buffer.reverse();
|
|
49
|
-
}
|
|
50
|
-
return buffer;
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_buffer_test.d.ts","sourceRoot":"","sources":["../../src/utilities/0_buffer_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.12/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.12/equal.ts"],"names":[],"mappings":"AA2FA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAuGrD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instance_of.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.12/instance_of.ts"],"names":[],"mappings":"AAIA,sBAAsB;AAEtB,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AACzD,4BAA4B;AAC5B,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAE9B,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAE9C,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,CAAC,EACf,GAAG,SAAK,GACP,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CA6BnC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error thrown when an assertion fails.
|
|
3
|
-
*
|
|
4
|
-
* @example Usage
|
|
5
|
-
* ```ts ignore
|
|
6
|
-
* import { AssertionError } from "@std/assert";
|
|
7
|
-
*
|
|
8
|
-
* try {
|
|
9
|
-
* throw new AssertionError("foo", { cause: "bar" });
|
|
10
|
-
* } catch (error) {
|
|
11
|
-
* if (error instanceof AssertionError) {
|
|
12
|
-
* error.message === "foo"; // true
|
|
13
|
-
* error.cause === "bar"; // true
|
|
14
|
-
* }
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class AssertionError extends Error {
|
|
19
|
-
/** Constructs a new instance.
|
|
20
|
-
*
|
|
21
|
-
* @param message The error message.
|
|
22
|
-
* @param options Additional options. This argument is still unstable. It may change in the future release.
|
|
23
|
-
*/
|
|
24
|
-
constructor(message: string, options?: ErrorOptions);
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=assertion_error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.13/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
3
|
-
// This module is browser compatible.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.AssertionError = void 0;
|
|
6
|
-
/**
|
|
7
|
-
* Error thrown when an assertion fails.
|
|
8
|
-
*
|
|
9
|
-
* @example Usage
|
|
10
|
-
* ```ts ignore
|
|
11
|
-
* import { AssertionError } from "@std/assert";
|
|
12
|
-
*
|
|
13
|
-
* try {
|
|
14
|
-
* throw new AssertionError("foo", { cause: "bar" });
|
|
15
|
-
* } catch (error) {
|
|
16
|
-
* if (error instanceof AssertionError) {
|
|
17
|
-
* error.message === "foo"; // true
|
|
18
|
-
* error.cause === "bar"; // true
|
|
19
|
-
* }
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
class AssertionError extends Error {
|
|
24
|
-
/** Constructs a new instance.
|
|
25
|
-
*
|
|
26
|
-
* @param message The error message.
|
|
27
|
-
* @param options Additional options. This argument is still unstable. It may change in the future release.
|
|
28
|
-
*/
|
|
29
|
-
constructor(message, options) {
|
|
30
|
-
super(message, options);
|
|
31
|
-
this.name = "AssertionError";
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.AssertionError = AssertionError;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use this to assert unreachable code.
|
|
3
|
-
*
|
|
4
|
-
* @example Usage
|
|
5
|
-
* ```ts ignore
|
|
6
|
-
* import { unreachable } from "@std/assert";
|
|
7
|
-
*
|
|
8
|
-
* unreachable(); // Throws
|
|
9
|
-
* ```
|
|
10
|
-
*
|
|
11
|
-
* @param msg Optional message to include in the error.
|
|
12
|
-
* @returns Never returns, always throws.
|
|
13
|
-
*/
|
|
14
|
-
export declare function unreachable(msg?: string): never;
|
|
15
|
-
//# sourceMappingURL=unreachable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unreachable.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.13/unreachable.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAG/C"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unreachable = unreachable;
|
|
4
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
5
|
-
// This module is browser compatible.
|
|
6
|
-
const assertion_error_js_1 = require("./assertion_error.js");
|
|
7
|
-
/**
|
|
8
|
-
* Use this to assert unreachable code.
|
|
9
|
-
*
|
|
10
|
-
* @example Usage
|
|
11
|
-
* ```ts ignore
|
|
12
|
-
* import { unreachable } from "@std/assert";
|
|
13
|
-
*
|
|
14
|
-
* unreachable(); // Throws
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @param msg Optional message to include in the error.
|
|
18
|
-
* @returns Never returns, always throws.
|
|
19
|
-
*/
|
|
20
|
-
function unreachable(msg) {
|
|
21
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
22
|
-
throw new assertion_error_js_1.AssertionError(`Unreachable${msgSuffix}`);
|
|
23
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** Any constructor */
|
|
2
|
-
export type AnyConstructor = new (...args: any[]) => any;
|
|
3
|
-
/** Gets constructor type */
|
|
4
|
-
export type GetConstructorType<T extends AnyConstructor> = InstanceType<T>;
|
|
5
|
-
/**
|
|
6
|
-
* Make an assertion that `obj` is an instance of `type`.
|
|
7
|
-
* If not then throw.
|
|
8
|
-
*
|
|
9
|
-
* @example Usage
|
|
10
|
-
* ```ts ignore
|
|
11
|
-
* import { assertInstanceOf } from "@std/assert";
|
|
12
|
-
*
|
|
13
|
-
* assertInstanceOf(new Date(), Date); // Doesn't throw
|
|
14
|
-
* assertInstanceOf(new Date(), Number); // Throws
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @typeParam T The expected type of the object.
|
|
18
|
-
* @param actual The object to check.
|
|
19
|
-
* @param expectedType The expected class constructor.
|
|
20
|
-
* @param msg The optional message to display if the assertion fails.
|
|
21
|
-
*/
|
|
22
|
-
export declare function assertInstanceOf<T extends abstract new (...args: any[]) => any>(actual: unknown, expectedType: T, msg?: string): asserts actual is InstanceType<T>;
|
|
23
|
-
//# sourceMappingURL=instance_of.d.ts.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertInstanceOf = assertInstanceOf;
|
|
4
|
-
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
5
|
-
// This module is browser compatible.
|
|
6
|
-
const assertion_error_js_1 = require("./assertion_error.js");
|
|
7
|
-
/**
|
|
8
|
-
* Make an assertion that `obj` is an instance of `type`.
|
|
9
|
-
* If not then throw.
|
|
10
|
-
*
|
|
11
|
-
* @example Usage
|
|
12
|
-
* ```ts ignore
|
|
13
|
-
* import { assertInstanceOf } from "@std/assert";
|
|
14
|
-
*
|
|
15
|
-
* assertInstanceOf(new Date(), Date); // Doesn't throw
|
|
16
|
-
* assertInstanceOf(new Date(), Number); // Throws
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @typeParam T The expected type of the object.
|
|
20
|
-
* @param actual The object to check.
|
|
21
|
-
* @param expectedType The expected class constructor.
|
|
22
|
-
* @param msg The optional message to display if the assertion fails.
|
|
23
|
-
*/
|
|
24
|
-
function assertInstanceOf(actual, expectedType, msg = "") {
|
|
25
|
-
if (actual instanceof expectedType)
|
|
26
|
-
return;
|
|
27
|
-
const msgSuffix = msg ? `: ${msg}` : ".";
|
|
28
|
-
const expectedTypeStr = expectedType.name;
|
|
29
|
-
let actualTypeStr = "";
|
|
30
|
-
if (actual === null) {
|
|
31
|
-
actualTypeStr = "null";
|
|
32
|
-
}
|
|
33
|
-
else if (actual === undefined) {
|
|
34
|
-
actualTypeStr = "undefined";
|
|
35
|
-
}
|
|
36
|
-
else if (typeof actual === "object") {
|
|
37
|
-
actualTypeStr = actual.constructor?.name ?? "Object";
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
actualTypeStr = typeof actual;
|
|
41
|
-
}
|
|
42
|
-
if (expectedTypeStr === actualTypeStr) {
|
|
43
|
-
msg =
|
|
44
|
-
`Expected object to be an instance of "${expectedTypeStr}"${msgSuffix}`;
|
|
45
|
-
}
|
|
46
|
-
else if (actualTypeStr === "function") {
|
|
47
|
-
msg =
|
|
48
|
-
`Expected object to be an instance of "${expectedTypeStr}" but was not an instanced object${msgSuffix}`;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
msg =
|
|
52
|
-
`Expected object to be an instance of "${expectedTypeStr}" but was "${actualTypeStr}"${msgSuffix}`;
|
|
53
|
-
}
|
|
54
|
-
throw new assertion_error_js_1.AssertionError(msg);
|
|
55
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
-
*
|
|
5
|
-
* This file is part of MTKruto.
|
|
6
|
-
*
|
|
7
|
-
* This program is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU Lesser General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
20
|
-
export declare class TLError extends Error {
|
|
21
|
-
name: string;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=0_tl_error.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_tl_error.d.ts","sourceRoot":"","sources":["../../src/tl/0_tl_error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,qBAAa,OAAQ,SAAQ,KAAK;IACvB,IAAI,SAAa;CAE3B"}
|
package/script/tl/0_tl_error.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
5
|
-
*
|
|
6
|
-
* This file is part of MTKruto.
|
|
7
|
-
*
|
|
8
|
-
* This program is free software: you can redistribute it and/or modify
|
|
9
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
* (at your option) any later version.
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU Lesser General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
-
*/
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.TLError = void 0;
|
|
23
|
-
class TLError extends Error {
|
|
24
|
-
name = "TLError";
|
|
25
|
-
}
|
|
26
|
-
exports.TLError = TLError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function modExp(a: bigint, b: bigint, n: bigint): bigint;
|
|
2
|
-
export declare function mod(n: bigint, m: bigint): bigint;
|
|
3
|
-
export declare function mod(n: number, m: number): number;
|
|
4
|
-
export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, signed?: boolean): bigint;
|
|
5
|
-
export declare function getRandomBigInt(byteLength: number, little?: boolean, signed?: boolean): bigint;
|
|
6
|
-
/** Get a random ID. Useful when calling API functions directly. */
|
|
7
|
-
export declare function getRandomId(number: true): number;
|
|
8
|
-
export declare function getRandomId(): bigint;
|
|
9
|
-
export declare function gcd(a: bigint, b: bigint): bigint;
|
|
10
|
-
//# sourceMappingURL=0_bigint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_bigint.d.ts","sourceRoot":"","sources":["../../src/utilities/0_bigint.ts"],"names":[],"mappings":"AAsBA,wBAAgB,MAAM,CACpB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,UAgBV;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AAClD,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;AAOlD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,UAAO,EAAE,MAAM,UAAQ,UAejF;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,UAIrF;AAED,mEAAmE;AACnE,wBAAgB,WAAW,CAAC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC;AAClD,wBAAgB,WAAW,IAAI,MAAM,CAAC;AAStC,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAwBvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_bigint_test.d.ts","sourceRoot":"","sources":["../../src/utilities/0_bigint_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
-
*
|
|
5
|
-
* This file is part of MTKruto.
|
|
6
|
-
*
|
|
7
|
-
* This program is free software: you can redistribute it and/or modify
|
|
8
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version.
|
|
11
|
-
*
|
|
12
|
-
* This program is distributed in the hope that it will be useful,
|
|
13
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
* GNU Lesser General Public License for more details.
|
|
16
|
-
*
|
|
17
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
-
*/
|
|
20
|
-
export declare function bufferFromBigInt(int: bigint | number, byteCount: number, littleEndian?: boolean, signed?: boolean): Uint8Array<ArrayBuffer>;
|
|
21
|
-
//# sourceMappingURL=0_buffer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_buffer.d.ts","sourceRoot":"","sources":["../../src/utilities/0_buffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,UAAO,EAAE,MAAM,UAAQ,2BAoC5G"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
-
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
5
|
-
*
|
|
6
|
-
* This file is part of MTKruto.
|
|
7
|
-
*
|
|
8
|
-
* This program is free software: you can redistribute it and/or modify
|
|
9
|
-
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
* (at your option) any later version.
|
|
12
|
-
*
|
|
13
|
-
* This program is distributed in the hope that it will be useful,
|
|
14
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
* GNU Lesser General Public License for more details.
|
|
17
|
-
*
|
|
18
|
-
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
-
*/
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.bufferFromBigInt = bufferFromBigInt;
|
|
23
|
-
const bufferFromHexString = (hexString) => Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
24
|
-
function bufferFromBigInt(int, byteCount, littleEndian = true, signed = false) {
|
|
25
|
-
const actualByteCount = Math.ceil(int.toString(2).length / 8);
|
|
26
|
-
if (byteCount < actualByteCount) {
|
|
27
|
-
throw new Error("Int too big");
|
|
28
|
-
}
|
|
29
|
-
if (byteCount === 4 || byteCount === 2) { // fast path
|
|
30
|
-
const buffer = new Uint8Array(byteCount);
|
|
31
|
-
const dataView = new DataView(buffer.buffer);
|
|
32
|
-
(byteCount === 2 ? signed ? dataView.setInt16 : dataView.setUint16 : signed ? dataView.setInt32 : dataView.setUint32).call(dataView, 0, Number(int), littleEndian);
|
|
33
|
-
return buffer;
|
|
34
|
-
}
|
|
35
|
-
int = BigInt(typeof int === "number" ? Math.ceil(int) : int);
|
|
36
|
-
if (byteCount === 8) { // fast path
|
|
37
|
-
const buffer = new Uint8Array(byteCount);
|
|
38
|
-
const dataView = new DataView(buffer.buffer);
|
|
39
|
-
(signed ? dataView.setBigInt64 : dataView.setBigUint64).call(dataView, 0, int, littleEndian);
|
|
40
|
-
return buffer;
|
|
41
|
-
}
|
|
42
|
-
if (!signed && int < 0n) {
|
|
43
|
-
throw new Error("Got unexpected signed int");
|
|
44
|
-
}
|
|
45
|
-
if (signed && int < 0n) {
|
|
46
|
-
int = 2n ** BigInt(byteCount * 8) + int;
|
|
47
|
-
}
|
|
48
|
-
const hex = int.toString(16).padStart(byteCount * 2, "0");
|
|
49
|
-
const buffer = bufferFromHexString(hex);
|
|
50
|
-
if (littleEndian) {
|
|
51
|
-
buffer.reverse();
|
|
52
|
-
}
|
|
53
|
-
return buffer;
|
|
54
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0_buffer_test.d.ts","sourceRoot":"","sources":["../../src/utilities/0_buffer_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|