@mtkruto/node 0.76.1 → 0.77.1
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
|
@@ -58,7 +58,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
|
|
|
58
58
|
}
|
|
59
59
|
async setAuthKey(key) {
|
|
60
60
|
const hash = await (0, _1_utilities_js_1.sha1)(key);
|
|
61
|
-
this.#authKeyId = (0, _1_utilities_js_1.
|
|
61
|
+
this.#authKeyId = (0, _1_utilities_js_1.intFromBytes)(hash.slice(-8));
|
|
62
62
|
this.#authKey = key;
|
|
63
63
|
}
|
|
64
64
|
get authKey() {
|
|
@@ -160,7 +160,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
|
|
|
160
160
|
this.#assertNotDisconnected();
|
|
161
161
|
const buffer = await this.transport.transport.receive();
|
|
162
162
|
if (buffer.length === 4) {
|
|
163
|
-
const int = (0, _1_utilities_js_1.
|
|
163
|
+
const int = (0, _1_utilities_js_1.intFromBytes)(buffer);
|
|
164
164
|
throw new _0_errors_js_1.TransportError(Number(int));
|
|
165
165
|
}
|
|
166
166
|
try {
|
|
@@ -169,6 +169,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
|
|
|
169
169
|
return decrypted;
|
|
170
170
|
}
|
|
171
171
|
catch (err) {
|
|
172
|
+
this.#L.error("decryption error:", err);
|
|
172
173
|
await this.#invalidateSession("decryption error");
|
|
173
174
|
throw err;
|
|
174
175
|
}
|
|
@@ -193,9 +194,9 @@ class SessionEncrypted extends _1_session_js_1.Session {
|
|
|
193
194
|
}
|
|
194
195
|
async #decryptMessage(buffer) {
|
|
195
196
|
const reader = new _2_tl_js_1.TLReader(buffer);
|
|
196
|
-
(0, _0_deps_js_1.assertEquals)(reader.readInt64(
|
|
197
|
+
(0, _0_deps_js_1.assertEquals)(reader.readInt64(), this.#authKeyId);
|
|
197
198
|
const messageKey_ = reader.readInt128();
|
|
198
|
-
const messageKey = (0, _1_utilities_js_1.
|
|
199
|
+
const messageKey = (0, _1_utilities_js_1.intToBytes)(messageKey_, 16);
|
|
199
200
|
const a = await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([messageKey, this.#authKey.subarray(8, 44)]));
|
|
200
201
|
const b = await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([this.#authKey.subarray(48, 84), messageKey]));
|
|
201
202
|
const aesKey = (0, _0_deps_js_1.concat)([a.subarray(0, 8), b.subarray(8, 24), a.subarray(24, 32)]);
|
|
@@ -46,7 +46,7 @@ class SessionPlain extends _1_session_js_1.Session {
|
|
|
46
46
|
}
|
|
47
47
|
const buffer = await this.transport.transport.receive();
|
|
48
48
|
if (buffer.length === 4) {
|
|
49
|
-
const int = (0, _1_utilities_js_1.
|
|
49
|
+
const int = (0, _1_utilities_js_1.intFromBytes)(buffer);
|
|
50
50
|
throw new _0_errors_js_1.TransportError(Number(int));
|
|
51
51
|
}
|
|
52
52
|
const reader = new _1_tl_reader_js_1.TLReader(buffer);
|
|
@@ -30,4 +30,5 @@ export declare const X = "X";
|
|
|
30
30
|
export declare const VECTOR = 481674261;
|
|
31
31
|
export declare const BOOL_TRUE = 2574415285;
|
|
32
32
|
export declare const BOOL_FALSE = 3162085175;
|
|
33
|
+
export declare function constructorIdToHex(constructorId: number): string;
|
|
33
34
|
//# sourceMappingURL=0_utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/0_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AACD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAY3F;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAElD;AAGD,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,GAAG,CAkB3C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D;AAID,eAAO,MAAM,CAAC,MAAM,CAAC;AACrB,eAAO,MAAM,MAAM,YAAa,CAAC;AACjC,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,eAAO,MAAM,UAAU,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"0_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/0_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AACD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAY3F;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAElD;AAGD,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,GAAG,CAkB3C;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D;AAID,eAAO,MAAM,CAAC,MAAM,CAAC;AACrB,eAAO,MAAM,MAAM,YAAa,CAAC;AACjC,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,eAAO,MAAM,UAAU,aAAa,CAAC;AAErC,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEhE"}
|
package/script/tl/0_utilities.js
CHANGED
|
@@ -26,6 +26,7 @@ exports.analyzeOptionalParam = analyzeOptionalParam;
|
|
|
26
26
|
exports.repr = repr;
|
|
27
27
|
exports.toJSON = toJSON;
|
|
28
28
|
exports.getVectorItemType = getVectorItemType;
|
|
29
|
+
exports.constructorIdToHex = constructorIdToHex;
|
|
29
30
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
30
31
|
function isOptionalParam(ntype) {
|
|
31
32
|
return ntype.includes("?");
|
|
@@ -83,3 +84,6 @@ exports.X = "X";
|
|
|
83
84
|
exports.VECTOR = 0x1CB5C415;
|
|
84
85
|
exports.BOOL_TRUE = 0x997275b5;
|
|
85
86
|
exports.BOOL_FALSE = 0xbc799737;
|
|
87
|
+
function constructorIdToHex(constructorId) {
|
|
88
|
+
return constructorId.toString(16);
|
|
89
|
+
}
|
|
@@ -18,22 +18,20 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import type { Schema } from "./0_types.js";
|
|
21
|
-
export declare class TLError extends Error {
|
|
22
|
-
}
|
|
23
21
|
export declare class TLReader {
|
|
24
22
|
#private;
|
|
25
23
|
protected _buffer: Uint8Array;
|
|
26
24
|
constructor(_buffer: Uint8Array);
|
|
27
25
|
get buffer(): Uint8Array;
|
|
28
|
-
read(
|
|
26
|
+
read(byteCount: number): Uint8Array<ArrayBuffer>;
|
|
29
27
|
unread(count: number): void;
|
|
30
|
-
readInt24(
|
|
31
|
-
readInt32(
|
|
28
|
+
readInt24(isSigned?: boolean): number;
|
|
29
|
+
readInt32(isSigned?: boolean): number;
|
|
32
30
|
unreadInt32(): void;
|
|
33
|
-
readInt64(
|
|
31
|
+
readInt64(isSigned?: boolean): bigint;
|
|
34
32
|
readDouble(): number;
|
|
35
|
-
readInt128(
|
|
36
|
-
readInt256(
|
|
33
|
+
readInt128(isSigned?: boolean): bigint;
|
|
34
|
+
readInt256(isSigned?: boolean): bigint;
|
|
37
35
|
readBytes(): Uint8Array<ArrayBuffer>;
|
|
38
36
|
readString(): string;
|
|
39
37
|
readType(name: string, schema: Schema): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_tl_reader.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"1_tl_reader.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAoB,MAAM,EAAE,MAAM,cAAc,CAAC;AAG7D,qBAAa,QAAQ;;IAGP,SAAS,CAAC,OAAO,EAAE,UAAU;gBAAnB,OAAO,EAAE,UAAU;IAGzC,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC;IAUhD,MAAM,CAAC,KAAK,EAAE,MAAM;IASpB,SAAS,CAAC,QAAQ,UAAO,GAAG,MAAM;IAKlC,SAAS,CAAC,QAAQ,UAAO,GAAG,MAAM;IAKlC,WAAW;IAIX,SAAS,CAAC,QAAQ,UAAO,GAAG,MAAM;IAKlC,UAAU,IAAI,MAAM;IAKpB,UAAU,CAAC,QAAQ,UAAO,GAAG,MAAM;IAKnC,UAAU,CAAC,QAAQ,UAAO,GAAG,MAAM;IAKnC,SAAS,IAAI,UAAU,CAAC,WAAW,CAAC;IAiBpC,UAAU,IAAI,MAAM;IAId,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CA6H3D"}
|
package/script/tl/1_tl_reader.js
CHANGED
|
@@ -20,61 +20,60 @@
|
|
|
20
20
|
*/
|
|
21
21
|
// deno-lint-ignore-file no-explicit-any
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.TLReader =
|
|
23
|
+
exports.TLReader = void 0;
|
|
24
24
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
25
|
+
const _0_errors_js_1 = require("../0_errors.js");
|
|
25
26
|
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
26
|
-
class TLError extends Error {
|
|
27
|
-
}
|
|
28
|
-
exports.TLError = TLError;
|
|
29
27
|
class TLReader {
|
|
30
28
|
_buffer;
|
|
29
|
+
#path = new Array();
|
|
31
30
|
constructor(_buffer) {
|
|
32
31
|
this._buffer = _buffer;
|
|
33
32
|
}
|
|
34
33
|
get buffer() {
|
|
35
34
|
return this._buffer;
|
|
36
35
|
}
|
|
37
|
-
read(
|
|
38
|
-
if (this._buffer.
|
|
39
|
-
throw new TLError("No data remaining");
|
|
36
|
+
read(byteCount) {
|
|
37
|
+
if (this._buffer.byteLength < byteCount) {
|
|
38
|
+
throw new _0_errors_js_1.TLError("No data remaining", this.#path);
|
|
40
39
|
}
|
|
41
|
-
const buffer = this._buffer.slice(0,
|
|
42
|
-
this._buffer = this._buffer.subarray(
|
|
40
|
+
const buffer = this._buffer.slice(0, byteCount);
|
|
41
|
+
this._buffer = this._buffer.subarray(byteCount);
|
|
43
42
|
return buffer;
|
|
44
43
|
}
|
|
45
44
|
unread(count) {
|
|
46
45
|
const newOffest = this._buffer.byteOffset - count;
|
|
47
46
|
if (newOffest < 0) {
|
|
48
|
-
throw new TLError("No data has been read");
|
|
47
|
+
throw new _0_errors_js_1.TLError("No data has been read", this.#path);
|
|
49
48
|
}
|
|
50
49
|
this._buffer = new Uint8Array(this._buffer.buffer, newOffest);
|
|
51
50
|
}
|
|
52
|
-
readInt24(
|
|
51
|
+
readInt24(isSigned = true) {
|
|
53
52
|
const buffer = this.read(24 / 8);
|
|
54
|
-
return Number((0, _1_utilities_js_1.
|
|
53
|
+
return Number((0, _1_utilities_js_1.intFromBytes)(buffer, { isSigned }));
|
|
55
54
|
}
|
|
56
|
-
readInt32(
|
|
55
|
+
readInt32(isSigned = true) {
|
|
57
56
|
const buffer = this.read(32 / 8);
|
|
58
|
-
return Number((0, _1_utilities_js_1.
|
|
57
|
+
return Number((0, _1_utilities_js_1.intFromBytes)(buffer, { isSigned }));
|
|
59
58
|
}
|
|
60
59
|
unreadInt32() {
|
|
61
60
|
this.unread(32 / 8);
|
|
62
61
|
}
|
|
63
|
-
readInt64(
|
|
62
|
+
readInt64(isSigned = true) {
|
|
64
63
|
const buffer = this.read(64 / 8);
|
|
65
|
-
return (0, _1_utilities_js_1.
|
|
64
|
+
return (0, _1_utilities_js_1.intFromBytes)(buffer, { isSigned });
|
|
66
65
|
}
|
|
67
66
|
readDouble() {
|
|
68
67
|
const buffer = this.read(8);
|
|
69
68
|
return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getFloat64(0, true);
|
|
70
69
|
}
|
|
71
|
-
readInt128(
|
|
70
|
+
readInt128(isSigned = true) {
|
|
72
71
|
const buffer = this.read(128 / 8);
|
|
73
|
-
return (0, _1_utilities_js_1.
|
|
72
|
+
return (0, _1_utilities_js_1.intFromBytes)(buffer, { isSigned });
|
|
74
73
|
}
|
|
75
|
-
readInt256(
|
|
74
|
+
readInt256(isSigned = true) {
|
|
76
75
|
const buffer = this.read(256 / 8);
|
|
77
|
-
return (0, _1_utilities_js_1.
|
|
76
|
+
return (0, _1_utilities_js_1.intFromBytes)(buffer, { isSigned });
|
|
78
77
|
}
|
|
79
78
|
readBytes() {
|
|
80
79
|
let L = this.read(1)[0];
|
|
@@ -108,7 +107,7 @@ class TLReader {
|
|
|
108
107
|
if (name === _0_utilities_js_1.X) {
|
|
109
108
|
const typeName = schema.identifierToName[id];
|
|
110
109
|
if (!typeName) {
|
|
111
|
-
throw new TLError(`Unknown constructor: ${
|
|
110
|
+
throw new _0_errors_js_1.TLError(`Unknown constructor ID: ${(0, _0_utilities_js_1.constructorIdToHex)(id)}`, this.#path);
|
|
112
111
|
}
|
|
113
112
|
this.unreadInt32();
|
|
114
113
|
return await this.readType(typeName, schema);
|
|
@@ -124,7 +123,7 @@ class TLReader {
|
|
|
124
123
|
if (deserializedEnum !== undefined) {
|
|
125
124
|
return deserializedEnum;
|
|
126
125
|
}
|
|
127
|
-
throw new TLError(`Unknown type: ${name}
|
|
126
|
+
throw new _0_errors_js_1.TLError(`Unknown type: ${name}#${(0, _0_utilities_js_1.constructorIdToHex)(id)}`, this.#path);
|
|
128
127
|
}
|
|
129
128
|
async #deserializeEnum(type, id, schema) {
|
|
130
129
|
const name = schema.identifierToName[id];
|
|
@@ -139,23 +138,32 @@ class TLReader {
|
|
|
139
138
|
}
|
|
140
139
|
async #deserializeType(type, desc, id, schema) {
|
|
141
140
|
if (desc[0] !== id) {
|
|
142
|
-
throw new TLError(`Expected constructor ${desc[0]
|
|
141
|
+
throw new _0_errors_js_1.TLError(`Expected constructor with ID ${(0, _0_utilities_js_1.constructorIdToHex)(desc[0])} but received ${(0, _0_utilities_js_1.constructorIdToHex)(id)}`, this.#path);
|
|
143
142
|
}
|
|
143
|
+
let isFirstPathElementExisting = false;
|
|
144
144
|
const type_ = { _: type };
|
|
145
145
|
const flagFields = {};
|
|
146
|
-
for (const [name,
|
|
147
|
-
if ((0, _0_utilities_js_1.isOptionalParam)(
|
|
148
|
-
const { flagField, bitIndex } = (0, _0_utilities_js_1.analyzeOptionalParam)(
|
|
146
|
+
for (const [name, fieldType] of desc[1]) {
|
|
147
|
+
if ((0, _0_utilities_js_1.isOptionalParam)(fieldType)) {
|
|
148
|
+
const { flagField, bitIndex } = (0, _0_utilities_js_1.analyzeOptionalParam)(fieldType);
|
|
149
149
|
const bits = flagFields[flagField];
|
|
150
150
|
if ((bits & (1 << bitIndex)) === 0) {
|
|
151
151
|
continue;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
if (
|
|
154
|
+
if (fieldType === "#") {
|
|
155
155
|
flagFields[name] = this.readInt32();
|
|
156
156
|
continue;
|
|
157
157
|
}
|
|
158
|
-
const
|
|
158
|
+
const pathElement = `[${type}.]${name}`;
|
|
159
|
+
if (isFirstPathElementExisting) {
|
|
160
|
+
this.#path[this.#path.length - 1] = pathElement;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.#path.push(pathElement);
|
|
164
|
+
isFirstPathElementExisting = true;
|
|
165
|
+
}
|
|
166
|
+
const value = await this.readType(fieldType, schema);
|
|
159
167
|
if (typeof value !== "boolean" || value) {
|
|
160
168
|
type_[name] = value;
|
|
161
169
|
}
|
|
@@ -165,7 +173,7 @@ class TLReader {
|
|
|
165
173
|
async #deserializeVector(type, schema) {
|
|
166
174
|
const itemType = (0, _0_utilities_js_1.getVectorItemType)(type);
|
|
167
175
|
if (!itemType) {
|
|
168
|
-
throw new TLError(`Expected Vector but received ${type}
|
|
176
|
+
throw new _0_errors_js_1.TLError(`Expected Vector but received ${type}`, this.#path);
|
|
169
177
|
}
|
|
170
178
|
const size = this.readInt32();
|
|
171
179
|
const array = new Array();
|
|
@@ -199,7 +207,7 @@ class TLReader {
|
|
|
199
207
|
return false;
|
|
200
208
|
}
|
|
201
209
|
else {
|
|
202
|
-
throw new TLError(`Expected boolTrue or boolFalse but
|
|
210
|
+
throw new _0_errors_js_1.TLError(`Expected boolTrue or boolFalse but received ${(0, _0_utilities_js_1.constructorIdToHex)(id)}`, this.#path);
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
213
|
case "string":
|
|
@@ -24,12 +24,12 @@ export declare class TLWriter {
|
|
|
24
24
|
constructor();
|
|
25
25
|
get buffer(): Uint8Array<ArrayBuffer>;
|
|
26
26
|
write(buffer: Uint8Array): typeof this;
|
|
27
|
-
writeInt24(int: number,
|
|
28
|
-
writeInt32(int: number,
|
|
29
|
-
writeInt64(int: bigint,
|
|
27
|
+
writeInt24(int: number, isSigned?: boolean): typeof this;
|
|
28
|
+
writeInt32(int: number, isSigned?: boolean): typeof this;
|
|
29
|
+
writeInt64(int: bigint, isSigned?: boolean): typeof this;
|
|
30
30
|
writeDouble(double: number): typeof this;
|
|
31
|
-
writeInt128(int: bigint,
|
|
32
|
-
writeInt256(int: bigint,
|
|
31
|
+
writeInt128(int: bigint, isSigned?: boolean): typeof this;
|
|
32
|
+
writeInt256(int: bigint, isSigned?: boolean): typeof this;
|
|
33
33
|
writeBytes(bytes: Uint8Array): typeof this;
|
|
34
34
|
writeString(string: string): typeof this;
|
|
35
35
|
writeObject(value: any, schema: Schema): typeof this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_tl_writer.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,qBAAa,QAAQ;;IACnB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAoB;;
|
|
1
|
+
{"version":3,"file":"1_tl_writer.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,qBAAa,QAAQ;;IACnB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAoB;;IAM9D,IAAI,MAAM,IAAI,UAAU,CAAC,WAAW,CAAC,CAEpC;IAED,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,IAAI;IAKtC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,OAAO,IAAI;IAKrD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,OAAO,IAAI;IAKrD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,OAAO,IAAI;IAKrD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;IAOxC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,OAAO,IAAI;IAKtD,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAO,GAAG,OAAO,IAAI;IAKtD,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,IAAI;IAkB1C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;IAKxC,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;CAyLrD"}
|
package/script/tl/1_tl_writer.js
CHANGED
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.TLWriter = void 0;
|
|
24
24
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
25
|
-
const
|
|
25
|
+
const _0_errors_js_1 = require("../0_errors.js");
|
|
26
26
|
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
27
|
-
const
|
|
27
|
+
const _0_int_js_1 = require("../utilities/0_int.js");
|
|
28
28
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
29
29
|
class TLWriter {
|
|
30
30
|
_buffer = new Uint8Array();
|
|
31
|
+
#path = new Array();
|
|
31
32
|
constructor() {
|
|
32
33
|
}
|
|
33
34
|
get buffer() {
|
|
@@ -37,16 +38,16 @@ class TLWriter {
|
|
|
37
38
|
this._buffer = (0, _0_deps_js_1.concat)([this._buffer, buffer]);
|
|
38
39
|
return this;
|
|
39
40
|
}
|
|
40
|
-
writeInt24(int,
|
|
41
|
-
this.write((0,
|
|
41
|
+
writeInt24(int, isSigned = true) {
|
|
42
|
+
this.write((0, _0_int_js_1.intToBytes)(int, 24 / 8, { isSigned, path: this.#path }));
|
|
42
43
|
return this;
|
|
43
44
|
}
|
|
44
|
-
writeInt32(int,
|
|
45
|
-
this.write((0,
|
|
45
|
+
writeInt32(int, isSigned = true) {
|
|
46
|
+
this.write((0, _0_int_js_1.intToBytes)(int, 32 / 8, { isSigned, path: this.#path }));
|
|
46
47
|
return this;
|
|
47
48
|
}
|
|
48
|
-
writeInt64(int,
|
|
49
|
-
this.write((0,
|
|
49
|
+
writeInt64(int, isSigned = true) {
|
|
50
|
+
this.write((0, _0_int_js_1.intToBytes)(int, 64 / 8, { isSigned, path: this.#path }));
|
|
50
51
|
return this;
|
|
51
52
|
}
|
|
52
53
|
writeDouble(double) {
|
|
@@ -55,12 +56,12 @@ class TLWriter {
|
|
|
55
56
|
this.write(buffer);
|
|
56
57
|
return this;
|
|
57
58
|
}
|
|
58
|
-
writeInt128(int,
|
|
59
|
-
this.write((0,
|
|
59
|
+
writeInt128(int, isSigned = true) {
|
|
60
|
+
this.write((0, _0_int_js_1.intToBytes)(int, 128 / 8, { isSigned, path: this.#path }));
|
|
60
61
|
return this;
|
|
61
62
|
}
|
|
62
|
-
writeInt256(int,
|
|
63
|
-
this.write((0,
|
|
63
|
+
writeInt256(int, isSigned = true) {
|
|
64
|
+
this.write((0, _0_int_js_1.intToBytes)(int, 256 / 8, { isSigned, path: this.#path }));
|
|
64
65
|
return this;
|
|
65
66
|
}
|
|
66
67
|
writeBytes(bytes) {
|
|
@@ -86,31 +87,31 @@ class TLWriter {
|
|
|
86
87
|
return this;
|
|
87
88
|
}
|
|
88
89
|
writeObject(value, schema) {
|
|
89
|
-
this.#serialize(value._, value,
|
|
90
|
+
this.#serialize(value._, value, schema);
|
|
90
91
|
return this;
|
|
91
92
|
}
|
|
92
|
-
#serialize(type, value,
|
|
93
|
-
if (this.#serializePrimitive(type, value
|
|
93
|
+
#serialize(type, value, schema) {
|
|
94
|
+
if (this.#serializePrimitive(type, value)) {
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
|
-
if (this.#serializeVector(type, value,
|
|
97
|
+
if (this.#serializeVector(type, value, schema)) {
|
|
97
98
|
return;
|
|
98
99
|
}
|
|
99
100
|
const maybeDefinition = schema.definitions[value._];
|
|
100
101
|
if (!maybeDefinition) {
|
|
101
|
-
throw new
|
|
102
|
+
throw new _0_errors_js_1.TLError(`Unknown constructor: ${value._}`, this.#path);
|
|
102
103
|
}
|
|
103
104
|
if (type !== "!X" && !this.#isTypeValid(type, value, schema)) {
|
|
104
|
-
throw new
|
|
105
|
+
throw new _0_errors_js_1.TLError(`Expected ${type} but instead got ${value._}`, this.#path);
|
|
105
106
|
}
|
|
106
107
|
const type__ = value;
|
|
107
108
|
const [id, parameters_] = maybeDefinition;
|
|
108
109
|
this.writeInt32(id, false);
|
|
109
|
-
|
|
110
|
+
let isFirstPathElementExisting = false;
|
|
111
|
+
for (let [name, type] of parameters_.values()) {
|
|
110
112
|
if ((0, _0_utilities_js_1.isOptionalParam)(type) && type__[name] === undefined) {
|
|
111
113
|
continue;
|
|
112
114
|
}
|
|
113
|
-
const debugInfo = ` [0x${id.toString(16).toUpperCase()}::${i}]`;
|
|
114
115
|
if (type === "#") {
|
|
115
116
|
let flags = 0;
|
|
116
117
|
const flagField_ = name;
|
|
@@ -127,32 +128,40 @@ class TLWriter {
|
|
|
127
128
|
this.writeInt32(flags);
|
|
128
129
|
continue;
|
|
129
130
|
}
|
|
131
|
+
const pathElement = `[${value._}.]${name}`;
|
|
132
|
+
if (isFirstPathElementExisting) {
|
|
133
|
+
this.#path[this.#path.length - 1] = pathElement;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.#path.push(pathElement);
|
|
137
|
+
isFirstPathElementExisting = true;
|
|
138
|
+
}
|
|
130
139
|
if (type__[name] === undefined && !(0, _0_utilities_js_1.isOptionalParam)(type)) {
|
|
131
|
-
throw new
|
|
140
|
+
throw new _0_errors_js_1.TLError("Missing required field", this.#path);
|
|
132
141
|
}
|
|
133
142
|
if ((0, _0_utilities_js_1.isOptionalParam)(type)) {
|
|
134
143
|
type = (0, _0_utilities_js_1.getOptionalParamInnerType)(type);
|
|
135
144
|
}
|
|
136
|
-
this.#serialize(type, type__[name],
|
|
145
|
+
this.#serialize(type, type__[name], schema);
|
|
137
146
|
}
|
|
138
147
|
return;
|
|
139
148
|
}
|
|
140
|
-
#serializeVector(type, value,
|
|
149
|
+
#serializeVector(type, value, schema) {
|
|
141
150
|
const itemType = (0, _0_utilities_js_1.getVectorItemType)(type);
|
|
142
151
|
if (!itemType) {
|
|
143
152
|
return false;
|
|
144
153
|
}
|
|
145
154
|
if (!Array.isArray(value)) {
|
|
146
|
-
throw new
|
|
155
|
+
throw new _0_errors_js_1.TLError(`Expected an array but received ${(0, _0_utilities_js_1.repr)(value)}`, this.#path);
|
|
147
156
|
}
|
|
148
157
|
this.writeInt32(_0_utilities_js_1.VECTOR, false);
|
|
149
158
|
this.writeInt32(value.length);
|
|
150
159
|
for (const item of value) {
|
|
151
|
-
this.#serialize(itemType, item,
|
|
160
|
+
this.#serialize(itemType, item, schema);
|
|
152
161
|
}
|
|
153
162
|
return true;
|
|
154
163
|
}
|
|
155
|
-
#serializePrimitive(type, value
|
|
164
|
+
#serializePrimitive(type, value) {
|
|
156
165
|
const valueRepr = (0, _0_utilities_js_1.repr)(value);
|
|
157
166
|
switch (type) {
|
|
158
167
|
case "bytes":
|
|
@@ -160,7 +169,7 @@ class TLWriter {
|
|
|
160
169
|
this.writeBytes(value);
|
|
161
170
|
}
|
|
162
171
|
else {
|
|
163
|
-
throw new
|
|
172
|
+
throw new _0_errors_js_1.TLError(`Expected Uint8Array but received ${valueRepr}`, this.#path);
|
|
164
173
|
}
|
|
165
174
|
return true;
|
|
166
175
|
case "int128":
|
|
@@ -168,7 +177,7 @@ class TLWriter {
|
|
|
168
177
|
this.writeInt128(value);
|
|
169
178
|
}
|
|
170
179
|
else {
|
|
171
|
-
throw new
|
|
180
|
+
throw new _0_errors_js_1.TLError(`Expected bigint but received ${valueRepr}`, this.#path);
|
|
172
181
|
}
|
|
173
182
|
return true;
|
|
174
183
|
case "int256":
|
|
@@ -176,7 +185,7 @@ class TLWriter {
|
|
|
176
185
|
this.writeInt256(value);
|
|
177
186
|
}
|
|
178
187
|
else {
|
|
179
|
-
throw new
|
|
188
|
+
throw new _0_errors_js_1.TLError(`Expected bigint but received ${valueRepr}`, this.#path);
|
|
180
189
|
}
|
|
181
190
|
return true;
|
|
182
191
|
case "long":
|
|
@@ -184,7 +193,7 @@ class TLWriter {
|
|
|
184
193
|
this.writeInt64(value);
|
|
185
194
|
}
|
|
186
195
|
else {
|
|
187
|
-
throw new
|
|
196
|
+
throw new _0_errors_js_1.TLError(`Expected bigint but received ${valueRepr}`, this.#path);
|
|
188
197
|
}
|
|
189
198
|
return true;
|
|
190
199
|
case "Bool":
|
|
@@ -197,7 +206,7 @@ class TLWriter {
|
|
|
197
206
|
}
|
|
198
207
|
}
|
|
199
208
|
else {
|
|
200
|
-
throw new
|
|
209
|
+
throw new _0_errors_js_1.TLError(`Expected boolean but received ${valueRepr}`, this.#path);
|
|
201
210
|
}
|
|
202
211
|
return true;
|
|
203
212
|
case "int":
|
|
@@ -207,10 +216,15 @@ class TLWriter {
|
|
|
207
216
|
}
|
|
208
217
|
//
|
|
209
218
|
if (typeof value === "number") {
|
|
210
|
-
|
|
219
|
+
if (value % 1 === 0) {
|
|
220
|
+
this.writeInt32(value);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
throw new _0_errors_js_1.TLError("Expected an integer value but received a floating point", this.#path);
|
|
224
|
+
}
|
|
211
225
|
}
|
|
212
226
|
else {
|
|
213
|
-
throw new
|
|
227
|
+
throw new _0_errors_js_1.TLError(`Expected number but received ${valueRepr}`, this.#path);
|
|
214
228
|
}
|
|
215
229
|
return true;
|
|
216
230
|
case "double":
|
|
@@ -223,7 +237,7 @@ class TLWriter {
|
|
|
223
237
|
this.writeDouble(value);
|
|
224
238
|
}
|
|
225
239
|
else {
|
|
226
|
-
throw new
|
|
240
|
+
throw new _0_errors_js_1.TLError(`Expected number but received ${valueRepr}`, this.#path);
|
|
227
241
|
}
|
|
228
242
|
return true;
|
|
229
243
|
case "string":
|
|
@@ -242,7 +256,7 @@ class TLWriter {
|
|
|
242
256
|
return true;
|
|
243
257
|
case "true":
|
|
244
258
|
if (value !== true) {
|
|
245
|
-
throw new
|
|
259
|
+
throw new _0_errors_js_1.TLError(`Expected \`true\` but received ${valueRepr}`, this.#path);
|
|
246
260
|
}
|
|
247
261
|
return true;
|
|
248
262
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_obfuscation.d.ts","sourceRoot":"","sources":["../../src/transport/0_obfuscation.ts"],"names":[],"mappings":"AAuBA,OAAO,
|
|
1
|
+
{"version":3,"file":"0_obfuscation.d.ts","sourceRoot":"","sources":["../../src/transport/0_obfuscation.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,GAAG,EAAc,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU;;;GA0CtF"}
|
|
@@ -59,7 +59,7 @@ const _1_utilities_js_1 = require("../1_utilities.js");
|
|
|
59
59
|
async function getObfuscationParameters(protocol, connection) {
|
|
60
60
|
let init;
|
|
61
61
|
while (true) {
|
|
62
|
-
init = (0, _0_deps_js_1.concat)([dntShim.crypto.getRandomValues(new Uint8Array(56)), (0, _1_utilities_js_1.
|
|
62
|
+
init = (0, _0_deps_js_1.concat)([dntShim.crypto.getRandomValues(new Uint8Array(56)), (0, _1_utilities_js_1.intToBytes)(protocol, 4, { byteOrder: "big", isSigned: false }), dntShim.crypto.getRandomValues(new Uint8Array(4))]);
|
|
63
63
|
if (init[0] === 0xEF) {
|
|
64
64
|
continue;
|
|
65
65
|
}
|
|
@@ -53,7 +53,7 @@ class TransportAbridged extends _0_transport_js_1.Transport {
|
|
|
53
53
|
let buffer = new Uint8Array(3);
|
|
54
54
|
await this.#connection.read(buffer);
|
|
55
55
|
buffer = await this.decrypt(buffer);
|
|
56
|
-
length = Number((0, _1_utilities_js_1.
|
|
56
|
+
length = Number((0, _1_utilities_js_1.intFromBytes)(buffer, { isSigned: false }));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
length *= 4;
|
|
@@ -64,7 +64,7 @@ class TransportAbridged extends _0_transport_js_1.Transport {
|
|
|
64
64
|
async send(buffer) {
|
|
65
65
|
const bufferLength = buffer.length / 4;
|
|
66
66
|
const header = new Uint8Array([bufferLength >= 0x7F ? 0x7F : bufferLength]);
|
|
67
|
-
const length = bufferLength >= 0x7F ? (0, _1_utilities_js_1.
|
|
67
|
+
const length = bufferLength >= 0x7F ? (0, _1_utilities_js_1.intToBytes)(bufferLength, 3, { isSigned: false }) : new Uint8Array();
|
|
68
68
|
const data = (0, _0_deps_js_1.concat)([header, length, buffer]);
|
|
69
69
|
await this.#connection.write(await this.encrypt(data));
|
|
70
70
|
}
|
|
@@ -54,7 +54,7 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
|
|
|
54
54
|
return await this.decrypt(buffer);
|
|
55
55
|
}
|
|
56
56
|
async send(buffer) {
|
|
57
|
-
const length = (0, _1_utilities_js_1.
|
|
57
|
+
const length = (0, _1_utilities_js_1.intToBytes)(buffer.length, 4);
|
|
58
58
|
const data = (0, _0_deps_js_1.concat)([length, buffer]);
|
|
59
59
|
await this.#connection.write(await this.encrypt(data));
|
|
60
60
|
}
|
|
@@ -1,2 +1,21 @@
|
|
|
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
|
+
*/
|
|
1
20
|
export type LinkPreviewMediaSize = "small" | "large";
|
|
2
21
|
//# sourceMappingURL=0_link_preview_media_size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_link_preview_media_size.d.ts","sourceRoot":"","sources":["../../src/types/0_link_preview_media_size.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"0_link_preview_media_size.d.ts","sourceRoot":"","sources":["../../src/types/0_link_preview_media_size.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -1,2 +1,21 @@
|
|
|
1
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
|
+
*/
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"7_saved_chat.d.ts","sourceRoot":"","sources":["../../src/types/7_saved_chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"7_saved_chat.d.ts","sourceRoot":"","sources":["../../src/types/7_saved_chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,KAAK,KAAK,EAAkB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,gBAAgB;IAChB,IAAI,EAAE,KAAK,CAAC;IACZ,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,qBAAqB,GAAG,GAAG,CAAC,0BAA0B,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAkB7O"}
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.constructSavedChat = constructSavedChat;
|
|
23
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
23
24
|
const _2_telegram_js_1 = require("../tl/2_telegram.js");
|
|
24
25
|
const _1_chat_p_js_1 = require("./1_chat_p.js");
|
|
25
26
|
const _6_message_js_1 = require("./6_message.js");
|
|
26
|
-
const unreachable_js_1 = require("../deps/jsr.io/@std/assert/1.0.13/unreachable.js");
|
|
27
27
|
async function constructSavedChat(dialog, result, getPeer, getMessage, getStickerSetName) {
|
|
28
28
|
const message = result.messages.find((v) => v.id === dialog.top_message);
|
|
29
29
|
if (message === undefined) {
|
|
30
|
-
(0,
|
|
30
|
+
(0, _0_deps_js_1.unreachable)();
|
|
31
31
|
}
|
|
32
32
|
const dialogId = (0, _2_telegram_js_1.peerToChatId)(dialog.peer);
|
|
33
33
|
const chat_ = (dialog.peer._ === "peerUser" ? result.users : result.chats).find((v) => (0, _2_telegram_js_1.peerToChatId)(v) === dialogId);
|
|
34
34
|
if (chat_ === undefined) {
|
|
35
|
-
(0,
|
|
35
|
+
(0, _0_deps_js_1.unreachable)();
|
|
36
36
|
}
|
|
37
37
|
const chat = (0, _1_chat_p_js_1.constructChatP)(chat_);
|
|
38
38
|
const lastMessage = await (0, _6_message_js_1.constructMessage)(message, getPeer, getMessage, getStickerSetName, false);
|