@mtkruto/node 0.60.0 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/2_tl.d.ts +4 -6
- package/esm/2_tl.d.ts.map +1 -1
- package/esm/2_tl.js +4 -6
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +9 -9
- package/esm/client/1_client_encrypted.d.ts.map +1 -1
- package/esm/client/1_client_encrypted.js +173 -126
- package/esm/client/1_client_plain.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +12 -8
- package/esm/tl/0_api.d.ts +1 -2
- package/esm/tl/0_api.d.ts.map +1 -1
- package/esm/tl/0_api.js +7345 -6639
- package/esm/tl/0_tl_raw_reader.d.ts +2 -0
- package/esm/tl/0_tl_raw_reader.d.ts.map +1 -1
- package/esm/tl/0_tl_raw_reader.js +10 -0
- package/esm/tl/1_utilities.d.ts +10 -1
- package/esm/tl/1_utilities.d.ts.map +1 -1
- package/esm/tl/1_utilities.js +25 -1
- package/esm/tl/{5_message.d.ts → 2_message.d.ts} +5 -8
- package/esm/tl/2_message.d.ts.map +1 -0
- package/esm/tl/{5_message.js → 2_message.js} +16 -33
- package/esm/tl/{3_tl_reader.d.ts → 2_tl_reader.d.ts} +4 -3
- package/esm/tl/2_tl_reader.d.ts.map +1 -0
- package/esm/tl/2_tl_reader.js +146 -0
- package/esm/tl/2_tl_reader_test.d.ts.map +1 -0
- package/{script/tl/4_tl_writer.d.ts → esm/tl/2_tl_writer.d.ts} +4 -3
- package/esm/tl/2_tl_writer.d.ts.map +1 -0
- package/esm/tl/2_tl_writer.js +206 -0
- package/esm/tl/2_tl_writer_test.d.ts.map +1 -0
- package/{script/tl/3_utilities.d.ts → esm/tl/2_utilities.d.ts} +1 -1
- package/esm/tl/{3_utilities.d.ts.map → 2_utilities.d.ts.map} +1 -1
- package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
- package/esm/types/2_chosen_inline_result.js +2 -2
- package/esm/types/5_callback_query.d.ts.map +1 -1
- package/esm/types/5_callback_query.js +3 -3
- package/esm/utilities/0_misc.d.ts +0 -1
- package/esm/utilities/0_misc.d.ts.map +1 -1
- package/esm/utilities/0_misc.js +0 -1
- package/package.json +1 -1
- package/script/2_tl.d.ts +4 -6
- package/script/2_tl.d.ts.map +1 -1
- package/script/2_tl.js +4 -6
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +8 -8
- package/script/client/1_client_encrypted.d.ts.map +1 -1
- package/script/client/1_client_encrypted.js +171 -124
- package/script/client/1_client_plain.d.ts.map +1 -1
- package/script/client/1_client_plain.js +11 -7
- package/script/tl/0_api.d.ts +1 -2
- package/script/tl/0_api.d.ts.map +1 -1
- package/script/tl/0_api.js +7346 -6640
- package/script/tl/0_tl_raw_reader.d.ts +2 -0
- package/script/tl/0_tl_raw_reader.d.ts.map +1 -1
- package/script/tl/0_tl_raw_reader.js +10 -0
- package/script/tl/1_utilities.d.ts +10 -1
- package/script/tl/1_utilities.d.ts.map +1 -1
- package/script/tl/1_utilities.js +29 -1
- package/script/tl/{5_message.d.ts → 2_message.d.ts} +5 -8
- package/script/tl/2_message.d.ts.map +1 -0
- package/script/tl/{5_message.js → 2_message.js} +17 -34
- package/script/tl/{3_tl_reader.d.ts → 2_tl_reader.d.ts} +4 -3
- package/script/tl/2_tl_reader.d.ts.map +1 -0
- package/script/tl/2_tl_reader.js +150 -0
- package/script/tl/2_tl_reader_test.d.ts.map +1 -0
- package/{esm/tl/4_tl_writer.d.ts → script/tl/2_tl_writer.d.ts} +4 -3
- package/script/tl/2_tl_writer.d.ts.map +1 -0
- package/script/tl/2_tl_writer.js +210 -0
- package/script/tl/2_tl_writer_test.d.ts.map +1 -0
- package/{esm/tl/3_utilities.d.ts → script/tl/2_utilities.d.ts} +1 -1
- package/script/tl/{3_utilities.d.ts.map → 2_utilities.d.ts.map} +1 -1
- package/script/types/2_chosen_inline_result.d.ts.map +1 -1
- package/script/types/2_chosen_inline_result.js +1 -1
- package/script/types/5_callback_query.d.ts.map +1 -1
- package/script/types/5_callback_query.js +2 -2
- package/script/utilities/0_misc.d.ts +0 -1
- package/script/utilities/0_misc.d.ts.map +1 -1
- package/script/utilities/0_misc.js +1 -2
- package/esm/tl/2_deserialize.d.ts +0 -23
- package/esm/tl/2_deserialize.d.ts.map +0 -1
- package/esm/tl/2_deserialize.js +0 -98
- package/esm/tl/2_serialize.d.ts +0 -22
- package/esm/tl/2_serialize.d.ts.map +0 -1
- package/esm/tl/2_serialize.js +0 -163
- package/esm/tl/2_serialize_test.d.ts.map +0 -1
- package/esm/tl/3_deserialize_test.d.ts.map +0 -1
- package/esm/tl/3_tl_reader.d.ts.map +0 -1
- package/esm/tl/3_tl_reader.js +0 -49
- package/esm/tl/4_rpc_result.d.ts +0 -27
- package/esm/tl/4_rpc_result.d.ts.map +0 -1
- package/esm/tl/4_rpc_result.js +0 -33
- package/esm/tl/4_tl_writer.d.ts.map +0 -1
- package/esm/tl/4_tl_writer.js +0 -45
- package/esm/tl/5_message.d.ts.map +0 -1
- package/script/tl/2_deserialize.d.ts +0 -23
- package/script/tl/2_deserialize.d.ts.map +0 -1
- package/script/tl/2_deserialize.js +0 -101
- package/script/tl/2_serialize.d.ts +0 -22
- package/script/tl/2_serialize.d.ts.map +0 -1
- package/script/tl/2_serialize.js +0 -166
- package/script/tl/2_serialize_test.d.ts.map +0 -1
- package/script/tl/3_deserialize_test.d.ts.map +0 -1
- package/script/tl/3_tl_reader.d.ts.map +0 -1
- package/script/tl/3_tl_reader.js +0 -53
- package/script/tl/4_rpc_result.d.ts +0 -27
- package/script/tl/4_rpc_result.d.ts.map +0 -1
- package/script/tl/4_rpc_result.js +0 -37
- package/script/tl/4_tl_writer.d.ts.map +0 -1
- package/script/tl/4_tl_writer.js +0 -49
- package/script/tl/5_message.d.ts.map +0 -1
- /package/esm/tl/{3_utilities.js → 2_utilities.js} +0 -0
- /package/script/tl/{3_utilities.js → 2_utilities.js} +0 -0
|
@@ -24,8 +24,10 @@ export declare class TLRawReader {
|
|
|
24
24
|
constructor(_buffer: Uint8Array);
|
|
25
25
|
get buffer(): Uint8Array;
|
|
26
26
|
read(count: number): Uint8Array;
|
|
27
|
+
unread(count: number): void;
|
|
27
28
|
readInt24(signed?: boolean): number;
|
|
28
29
|
readInt32(signed?: boolean): number;
|
|
30
|
+
unreadInt32(): void;
|
|
29
31
|
readInt64(signed?: boolean): bigint;
|
|
30
32
|
readDouble(): number;
|
|
31
33
|
readInt128(signed?: boolean): bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_tl_raw_reader.d.ts","sourceRoot":"","sources":["../../src/tl/0_tl_raw_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,qBAAa,OAAQ,SAAQ,KAAK;CAEjC;AAED,qBAAa,WAAW;IACV,SAAS,CAAC,OAAO,EAAE,UAAU;gBAAnB,OAAO,EAAE,UAAU;IAGzC,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAS/B,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,UAAU,IAAI,MAAM;IAKpB,UAAU,CAAC,MAAM,UAAO,GAAG,MAAM;IAKjC,UAAU,CAAC,MAAM,UAAO,GAAG,MAAM;IAKjC,SAAS,IAAI,UAAU;IAiBvB,UAAU,IAAI,MAAM;CAGrB"}
|
|
1
|
+
{"version":3,"file":"0_tl_raw_reader.d.ts","sourceRoot":"","sources":["../../src/tl/0_tl_raw_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,qBAAa,OAAQ,SAAQ,KAAK;CAEjC;AAED,qBAAa,WAAW;IACV,SAAS,CAAC,OAAO,EAAE,UAAU;gBAAnB,OAAO,EAAE,UAAU;IAGzC,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAS/B,MAAM,CAAC,KAAK,EAAE,MAAM;IAQpB,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,WAAW;IAIX,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,UAAU,IAAI,MAAM;IAKpB,UAAU,CAAC,MAAM,UAAO,GAAG,MAAM;IAKjC,UAAU,CAAC,MAAM,UAAO,GAAG,MAAM;IAKjC,SAAS,IAAI,UAAU;IAiBvB,UAAU,IAAI,MAAM;CAGrB"}
|
|
@@ -40,6 +40,13 @@ export class TLRawReader {
|
|
|
40
40
|
this._buffer = this._buffer.subarray(count);
|
|
41
41
|
return buffer;
|
|
42
42
|
}
|
|
43
|
+
unread(count) {
|
|
44
|
+
const newOffest = this._buffer.byteOffset - count;
|
|
45
|
+
if (newOffest < 0) {
|
|
46
|
+
throw new TLError("No data has been read");
|
|
47
|
+
}
|
|
48
|
+
this._buffer = new Uint8Array(this._buffer.buffer, newOffest);
|
|
49
|
+
}
|
|
43
50
|
readInt24(signed = true) {
|
|
44
51
|
const buffer = this.read(24 / 8);
|
|
45
52
|
return Number(bigIntFromBuffer(buffer, true, signed));
|
|
@@ -48,6 +55,9 @@ export class TLRawReader {
|
|
|
48
55
|
const buffer = this.read(32 / 8);
|
|
49
56
|
return Number(bigIntFromBuffer(buffer, true, signed));
|
|
50
57
|
}
|
|
58
|
+
unreadInt32() {
|
|
59
|
+
this.unread(32 / 8);
|
|
60
|
+
}
|
|
51
61
|
readInt64(signed = true) {
|
|
52
62
|
const buffer = this.read(64 / 8);
|
|
53
63
|
return bigIntFromBuffer(buffer, true, signed);
|
package/esm/tl/1_utilities.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This program is free software: you can redistribute it and/or modify
|
|
8
8
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
9
|
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version
|
|
10
|
+
* (at your option) any later version.,,
|
|
11
11
|
*
|
|
12
12
|
* This program is distributed in the hope that it will be useful,
|
|
13
13
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
@@ -31,4 +31,13 @@ export declare function isOneOf<S extends keyof (Types & Functions)>(typeNames:
|
|
|
31
31
|
export declare function isOfEnum<S extends keyof Enums>(enumName: S, value: unknown): value is Enums[S];
|
|
32
32
|
export declare function as<S extends keyof Types>(typeName: S, value: unknown): Types[S];
|
|
33
33
|
export declare function isGenericFunction(value: unknown): boolean;
|
|
34
|
+
export declare function mustGetReturnType(name: string): string;
|
|
35
|
+
export declare function repr(value: unknown): string | null;
|
|
36
|
+
export declare function getVectorItemType(type: string): string | null;
|
|
37
|
+
export declare const X = "X";
|
|
38
|
+
export declare const VECTOR = 481674261;
|
|
39
|
+
export declare const BOOL_TRUE = 2574415285;
|
|
40
|
+
export declare const BOOL_FALSE = 3162085175;
|
|
41
|
+
export declare const GZIP_PACKED = 812830625;
|
|
42
|
+
export declare const RPC_RESULT = 4082920705;
|
|
34
43
|
//# sourceMappingURL=1_utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/1_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAoB,KAAK,EAAE,MAAM,YAAY,CAAC;AAEhF,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,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,OAAO,CAE1D;AACD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,QAI5C;AAED,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAMjL;AACD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAExM;AACD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAE9F;AACD,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAM/E;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEzD"}
|
|
1
|
+
{"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/1_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAoB,KAAK,EAAE,MAAM,YAAY,CAAC;AAEhF,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,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,OAAO,CAE1D;AACD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,QAI5C;AAED,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAMjL;AACD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAExM;AACD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAE9F;AACD,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAM/E;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAElD;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;AACrC,eAAO,MAAM,WAAW,YAAa,CAAC;AACtC,eAAO,MAAM,UAAU,aAAa,CAAC"}
|
package/esm/tl/1_utilities.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* This program is free software: you can redistribute it and/or modify
|
|
8
8
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
9
|
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
* (at your option) any later version
|
|
10
|
+
* (at your option) any later version.,,
|
|
11
11
|
*
|
|
12
12
|
* This program is distributed in the hope that it will be useful,
|
|
13
13
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
@@ -78,3 +78,27 @@ const GENERIC_FUNCTIONS = [
|
|
|
78
78
|
export function isGenericFunction(value) {
|
|
79
79
|
return isOneOf(GENERIC_FUNCTIONS, value);
|
|
80
80
|
}
|
|
81
|
+
export function mustGetReturnType(name) {
|
|
82
|
+
const type = getType(name);
|
|
83
|
+
if (!type || type.length < 3 || !type[2]) {
|
|
84
|
+
unreachable();
|
|
85
|
+
}
|
|
86
|
+
return type[2];
|
|
87
|
+
}
|
|
88
|
+
export function repr(value) {
|
|
89
|
+
return value == null ? null : (typeof value === "object" && "_" in value) ? value._ : value.constructor.name;
|
|
90
|
+
}
|
|
91
|
+
export function getVectorItemType(type) {
|
|
92
|
+
if (!type.startsWith(VECTOR_PREFIX) || !type.endsWith(VECTOR_SUFFIX)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return type.slice(VECTOR_PREFIX.length).slice(0, -1 * VECTOR_SUFFIX.length);
|
|
96
|
+
}
|
|
97
|
+
const VECTOR_PREFIX = "Vector<";
|
|
98
|
+
const VECTOR_SUFFIX = ">";
|
|
99
|
+
export const X = "X";
|
|
100
|
+
export const VECTOR = 0x1CB5C415;
|
|
101
|
+
export const BOOL_TRUE = 0x997275b5;
|
|
102
|
+
export const BOOL_FALSE = 0xbc799737;
|
|
103
|
+
export const GZIP_PACKED = 0x3072CFA1;
|
|
104
|
+
export const RPC_RESULT = 0xF35C6D01;
|
|
@@ -17,23 +17,20 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
21
|
-
import { TLReader } from "./3_tl_reader.js";
|
|
22
|
-
import { rpc_result } from "./4_rpc_result.js";
|
|
23
|
-
export declare const compressible: unique symbol;
|
|
20
|
+
import { TLRawReader } from "./0_tl_raw_reader.js";
|
|
24
21
|
export interface message {
|
|
25
22
|
_: "message";
|
|
26
23
|
msg_id: bigint;
|
|
27
24
|
seqno: number;
|
|
28
|
-
body:
|
|
25
|
+
body: Uint8Array | msg_container;
|
|
29
26
|
}
|
|
30
27
|
export declare function serializeMessage(message: message): Promise<Uint8Array>;
|
|
31
|
-
export declare function deserializeMessage(reader:
|
|
28
|
+
export declare function deserializeMessage(reader: TLRawReader): Promise<message>;
|
|
32
29
|
export interface msg_container {
|
|
33
30
|
_: "msg_container";
|
|
34
31
|
messages: message[];
|
|
35
32
|
}
|
|
36
|
-
export declare const
|
|
33
|
+
export declare const MSG_CONTAINER_CONSTRUCTOR = 1945237724;
|
|
37
34
|
export declare function serializeMsgContainer(msgContainer: msg_container): Promise<Uint8Array>;
|
|
38
35
|
export declare function deserializeMsgContainer(buffer: Uint8Array): Promise<msg_container>;
|
|
39
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=2_message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_message.d.ts","sourceRoot":"","sources":["../../src/tl/2_message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKnD,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,SAAS,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,aAAa,CAAC;CAClC;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAa5E;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAgB9E;AAID,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,yBAAyB,aAAa,CAAC;AAEpD,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAQ5F;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAQxF"}
|
|
@@ -17,29 +17,17 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { TLReader } from "./3_tl_reader.js";
|
|
23
|
-
import { deserializeRpcResult, RPC_RESULT_ID } from "./4_rpc_result.js";
|
|
24
|
-
import { TLWriter } from "./4_tl_writer.js";
|
|
25
|
-
const COMPRESSION_THREHSOLD = 1024;
|
|
26
|
-
export const compressible = Symbol.for("compressible");
|
|
20
|
+
import { TLRawReader } from "./0_tl_raw_reader.js";
|
|
21
|
+
import { TLRawWriter } from "./0_tl_raw_writer.js";
|
|
27
22
|
export async function serializeMessage(message) {
|
|
28
|
-
if (message.body._ == "rpc_result") {
|
|
29
|
-
throw new Error("Not applicable");
|
|
30
|
-
}
|
|
31
23
|
let body;
|
|
32
|
-
if (message.body
|
|
33
|
-
body =
|
|
24
|
+
if (message.body instanceof Uint8Array) {
|
|
25
|
+
body = message.body;
|
|
34
26
|
}
|
|
35
27
|
else {
|
|
36
|
-
body =
|
|
37
|
-
}
|
|
38
|
-
if (compressible in message && body.length >= COMPRESSION_THREHSOLD) {
|
|
39
|
-
const packed_data = await gzip(body);
|
|
40
|
-
body = new TLWriter().writeObject({ _: "gzip_packed", packed_data }).buffer;
|
|
28
|
+
body = await serializeMsgContainer(message.body);
|
|
41
29
|
}
|
|
42
|
-
const writer = new
|
|
30
|
+
const writer = new TLRawWriter()
|
|
43
31
|
.writeInt64(message.msg_id)
|
|
44
32
|
.writeInt32(message.seqno)
|
|
45
33
|
.writeInt32(body.length)
|
|
@@ -50,29 +38,24 @@ export async function deserializeMessage(reader) {
|
|
|
50
38
|
const id_ = reader.readInt64();
|
|
51
39
|
const seqno = reader.readInt32();
|
|
52
40
|
const length = reader.readInt32();
|
|
53
|
-
reader = new
|
|
54
|
-
const
|
|
41
|
+
reader = new TLRawReader(reader.read(length));
|
|
42
|
+
const reader2 = new TLRawReader(reader.buffer);
|
|
43
|
+
const id = reader2.readInt32(false);
|
|
55
44
|
let body;
|
|
56
45
|
{
|
|
57
|
-
if (
|
|
58
|
-
body = await
|
|
59
|
-
}
|
|
60
|
-
else if (cid == MSG_CONTAINER_ID) {
|
|
61
|
-
body = await deserializeMsgContainer(reader.buffer);
|
|
46
|
+
if (id == MSG_CONTAINER_CONSTRUCTOR) {
|
|
47
|
+
body = await deserializeMsgContainer(reader2.buffer);
|
|
62
48
|
}
|
|
63
49
|
else {
|
|
64
|
-
body = reader.
|
|
50
|
+
body = reader.buffer;
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
|
-
if (is("gzip_packed", body)) {
|
|
68
|
-
body = new TLReader(await gunzip(body.packed_data)).readObject();
|
|
69
|
-
}
|
|
70
53
|
return { _: "message", msg_id: id_, seqno, body };
|
|
71
54
|
}
|
|
72
|
-
export const
|
|
55
|
+
export const MSG_CONTAINER_CONSTRUCTOR = 0x73F1F8DC;
|
|
73
56
|
export async function serializeMsgContainer(msgContainer) {
|
|
74
|
-
const writer = new
|
|
75
|
-
writer.writeInt32(
|
|
57
|
+
const writer = new TLRawWriter();
|
|
58
|
+
writer.writeInt32(MSG_CONTAINER_CONSTRUCTOR, false);
|
|
76
59
|
writer.writeInt32(msgContainer.messages.length);
|
|
77
60
|
for (const message of msgContainer.messages) {
|
|
78
61
|
writer.write(await serializeMessage(message));
|
|
@@ -80,7 +63,7 @@ export async function serializeMsgContainer(msgContainer) {
|
|
|
80
63
|
return writer.buffer;
|
|
81
64
|
}
|
|
82
65
|
export async function deserializeMsgContainer(buffer) {
|
|
83
|
-
const reader = new
|
|
66
|
+
const reader = new TLRawReader(buffer);
|
|
84
67
|
const length = reader.readInt32();
|
|
85
68
|
const messages = new Array();
|
|
86
69
|
for (let i = 0; i < length; i++) {
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { TLRawReader } from "./0_tl_raw_reader.js";
|
|
21
21
|
import { AnyObject } from "./0_api.js";
|
|
22
|
-
export type ReadObject = boolean | AnyObject | Array<ReadObject>;
|
|
22
|
+
export type ReadObject = boolean | number | bigint | string | Uint8Array | AnyObject | Array<ReadObject>;
|
|
23
23
|
export declare class TLReader extends TLRawReader {
|
|
24
|
-
|
|
24
|
+
#private;
|
|
25
|
+
deserialize(type: string): Promise<ReadObject>;
|
|
25
26
|
}
|
|
26
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=2_tl_reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_tl_reader.d.ts","sourceRoot":"","sources":["../../src/tl/2_tl_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAW,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAoD,MAAM,YAAY,CAAC;AAKzF,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAEzG,qBAAa,QAAS,SAAQ,WAAW;;IACjC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAqHrD"}
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
// deno-lint-ignore-file no-explicit-any
|
|
21
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
22
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
23
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
24
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
25
|
+
};
|
|
26
|
+
var _TLReader_instances, _TLReader_deserializeEnum, _TLReader_deserializeType, _TLReader_deserializeVector, _TLReader_deserializePrimitive;
|
|
27
|
+
import { TLError, TLRawReader } from "./0_tl_raw_reader.js";
|
|
28
|
+
import { getEnum, getType, getTypeName } from "./0_api.js";
|
|
29
|
+
import { unreachable } from "../0_deps.js";
|
|
30
|
+
import { gunzip } from "../1_utilities.js";
|
|
31
|
+
import { analyzeOptionalParam, BOOL_FALSE, BOOL_TRUE, getOptionalParamInnerType, getVectorItemType, GZIP_PACKED, isOptionalParam, VECTOR, X } from "./1_utilities.js";
|
|
32
|
+
export class TLReader extends TLRawReader {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
_TLReader_instances.add(this);
|
|
36
|
+
}
|
|
37
|
+
async deserialize(type) {
|
|
38
|
+
if (isOptionalParam(type)) {
|
|
39
|
+
type = getOptionalParamInnerType(type);
|
|
40
|
+
}
|
|
41
|
+
const primitive = __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializePrimitive).call(this, type);
|
|
42
|
+
if (primitive !== undefined) {
|
|
43
|
+
return primitive;
|
|
44
|
+
}
|
|
45
|
+
const id = this.readInt32(false);
|
|
46
|
+
if (id == GZIP_PACKED) {
|
|
47
|
+
const buffer = await gunzip(this.readBytes());
|
|
48
|
+
return await new TLReader(buffer).deserialize(type);
|
|
49
|
+
}
|
|
50
|
+
if (type == X) {
|
|
51
|
+
const typeName = getTypeName(id);
|
|
52
|
+
if (!typeName) {
|
|
53
|
+
throw new TLError(`Unknown constructor: ${id.toString(16)}`);
|
|
54
|
+
}
|
|
55
|
+
this.unreadInt32();
|
|
56
|
+
return await this.deserialize(typeName);
|
|
57
|
+
}
|
|
58
|
+
if (id == VECTOR) {
|
|
59
|
+
return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeVector).call(this, type);
|
|
60
|
+
}
|
|
61
|
+
const enum_ = getEnum(type);
|
|
62
|
+
if (enum_) {
|
|
63
|
+
return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeEnum).call(this, enum_, id);
|
|
64
|
+
}
|
|
65
|
+
const type_ = getType(type);
|
|
66
|
+
if (type_) {
|
|
67
|
+
return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeType).call(this, type, type_, id);
|
|
68
|
+
}
|
|
69
|
+
unreachable(`unknown type: ${type} id ${id}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
_TLReader_instances = new WeakSet(), _TLReader_deserializeEnum = async function _TLReader_deserializeEnum(enum_, id) {
|
|
73
|
+
const validTypes = enum_.map((v) => [v, getType(v)]);
|
|
74
|
+
const type = validTypes.find((v) => v[1] && v[1][0] == id);
|
|
75
|
+
if (!type || !type[1]) {
|
|
76
|
+
throw new TLError(`Constructor not in enum: ${id.toString(16)}`);
|
|
77
|
+
}
|
|
78
|
+
return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeType).call(this, type[0], type[1], id);
|
|
79
|
+
}, _TLReader_deserializeType = async function _TLReader_deserializeType(type, desc, id) {
|
|
80
|
+
if (desc[0] != id) {
|
|
81
|
+
throw new TLError(`Expected constructor ${desc[0].toString(16)} but got ${id}`);
|
|
82
|
+
}
|
|
83
|
+
const type_ = { _: type };
|
|
84
|
+
const flagFields = {};
|
|
85
|
+
for (const [name, type] of desc[1]) {
|
|
86
|
+
if (isOptionalParam(type)) {
|
|
87
|
+
const { flagField, bitIndex } = analyzeOptionalParam(type);
|
|
88
|
+
const bits = flagFields[flagField];
|
|
89
|
+
if ((bits & (1 << bitIndex)) == 0) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (type == "#") {
|
|
94
|
+
flagFields[name] = this.readInt32();
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const value = await this.deserialize(type);
|
|
98
|
+
if (typeof value !== "boolean" || value) {
|
|
99
|
+
type_[name] = value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return type_;
|
|
103
|
+
}, _TLReader_deserializeVector = async function _TLReader_deserializeVector(type) {
|
|
104
|
+
const itemType = getVectorItemType(type);
|
|
105
|
+
if (!itemType) {
|
|
106
|
+
throw new TLError(`Expected Vector but received ${type}`);
|
|
107
|
+
}
|
|
108
|
+
const size = this.readInt32();
|
|
109
|
+
const array = new Array();
|
|
110
|
+
for (let i = 0; i < size; ++i) {
|
|
111
|
+
array.push(await this.deserialize(itemType));
|
|
112
|
+
}
|
|
113
|
+
return array;
|
|
114
|
+
}, _TLReader_deserializePrimitive = function _TLReader_deserializePrimitive(type) {
|
|
115
|
+
switch (type) {
|
|
116
|
+
case "bytes":
|
|
117
|
+
return this.readBytes();
|
|
118
|
+
case "int128":
|
|
119
|
+
return this.readInt128();
|
|
120
|
+
case "int256":
|
|
121
|
+
return this.readInt256();
|
|
122
|
+
case "double":
|
|
123
|
+
return this.readDouble();
|
|
124
|
+
case "long":
|
|
125
|
+
return this.readInt64();
|
|
126
|
+
case "true":
|
|
127
|
+
return true;
|
|
128
|
+
case "int":
|
|
129
|
+
return this.readInt32();
|
|
130
|
+
case "Bool": {
|
|
131
|
+
const id = this.readInt32(false);
|
|
132
|
+
if (id == BOOL_TRUE) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
else if (id == BOOL_FALSE) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
unreachable(`expected boolTrue or boolFalse but got ${id}`);
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "string":
|
|
144
|
+
return this.readString();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_tl_reader_test.d.ts","sourceRoot":"","sources":["../../src/tl/2_tl_reader_test.ts"],"names":[],"mappings":""}
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
+
import { AnyObject } from "./0_api.js";
|
|
20
21
|
import { TLRawWriter } from "./0_tl_raw_writer.js";
|
|
21
|
-
import { ReadObject } from "./3_tl_reader.js";
|
|
22
22
|
export declare class TLWriter extends TLRawWriter {
|
|
23
|
-
|
|
23
|
+
#private;
|
|
24
|
+
serialize(value: AnyObject): typeof this;
|
|
24
25
|
}
|
|
25
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=2_tl_writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_tl_writer.d.ts","sourceRoot":"","sources":["../../src/tl/2_tl_writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,qBAAa,QAAS,SAAQ,WAAW;;IACvC,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,IAAI;CAqLzC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
21
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
22
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
23
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
24
|
+
};
|
|
25
|
+
var _TLWriter_instances, _TLWriter_serialize, _TLWriter_serializeVector, _TLWriter_serializePrimitive, _TLWriter_isTypeValid;
|
|
26
|
+
// deno-lint-ignore-file no-explicit-any
|
|
27
|
+
import { getEnum, getType } from "./0_api.js";
|
|
28
|
+
import { TLError } from "./0_tl_raw_reader.js";
|
|
29
|
+
import { TLRawWriter } from "./0_tl_raw_writer.js";
|
|
30
|
+
import { analyzeOptionalParam, assertIsValidType, BOOL_FALSE, BOOL_TRUE, getOptionalParamInnerType, getVectorItemType, isOptionalParam, repr, VECTOR } from "./1_utilities.js";
|
|
31
|
+
export class TLWriter extends TLRawWriter {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
_TLWriter_instances.add(this);
|
|
35
|
+
}
|
|
36
|
+
serialize(value) {
|
|
37
|
+
assertIsValidType(value);
|
|
38
|
+
__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, value._, value, "");
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_serialize(type, value, debugInfo) {
|
|
43
|
+
if (__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serializePrimitive).call(this, type, value, debugInfo)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serializeVector).call(this, type, value, debugInfo)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
assertIsValidType(value);
|
|
50
|
+
const maybeParameters = getType(value._);
|
|
51
|
+
if (!maybeParameters) {
|
|
52
|
+
throw new TLError(`Unknown type: ${value._}`);
|
|
53
|
+
}
|
|
54
|
+
if (type != "!X" && !__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_isTypeValid).call(this, type, value)) {
|
|
55
|
+
throw new TLError(`Expected ${type} but got ${value._}`);
|
|
56
|
+
}
|
|
57
|
+
const type__ = value;
|
|
58
|
+
const [id, parameters_] = maybeParameters;
|
|
59
|
+
this.writeInt32(id, false);
|
|
60
|
+
for (let [i, [name, type]] of parameters_.entries()) {
|
|
61
|
+
if (isOptionalParam(type) && type__[name] === undefined) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const debugInfo = ` [0x${id.toString(16).toUpperCase()}::${i}]`;
|
|
65
|
+
if (type == "#") {
|
|
66
|
+
let flags = 0;
|
|
67
|
+
const flagField_ = name;
|
|
68
|
+
for (const [name, type] of parameters_) {
|
|
69
|
+
if (isOptionalParam(type)) {
|
|
70
|
+
const { flagField, bitIndex } = analyzeOptionalParam(type);
|
|
71
|
+
if (flagField == flagField_) {
|
|
72
|
+
if (type__[name] !== undefined) {
|
|
73
|
+
flags |= 1 << bitIndex;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.writeInt32(flags);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (type__[name] === undefined && !isOptionalParam(type)) {
|
|
82
|
+
throw new Error(`Missing required parameter: ${name}`);
|
|
83
|
+
}
|
|
84
|
+
if (isOptionalParam(type)) {
|
|
85
|
+
type = getOptionalParamInnerType(type);
|
|
86
|
+
}
|
|
87
|
+
__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, type, type__[name], debugInfo);
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}, _TLWriter_serializeVector = function _TLWriter_serializeVector(type, value, debugInfo) {
|
|
91
|
+
const itemType = getVectorItemType(type);
|
|
92
|
+
if (!itemType) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (!Array.isArray(value)) {
|
|
96
|
+
throw new TypeError(`Expected array but received ${repr(value)}${debugInfo}`);
|
|
97
|
+
}
|
|
98
|
+
this.writeInt32(VECTOR, false);
|
|
99
|
+
this.writeInt32(value.length);
|
|
100
|
+
for (const item of value) {
|
|
101
|
+
__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, itemType, item, debugInfo);
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}, _TLWriter_serializePrimitive = function _TLWriter_serializePrimitive(type, value, debugInfo) {
|
|
105
|
+
const valueRepr = repr(value);
|
|
106
|
+
switch (type) {
|
|
107
|
+
case "bytes":
|
|
108
|
+
if ((value instanceof Uint8Array)) {
|
|
109
|
+
this.writeBytes(value);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw new TLError(`Expected Uint8Array but received ${valueRepr}${debugInfo}`);
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
case "int128":
|
|
116
|
+
if (typeof value === "bigint") {
|
|
117
|
+
this.writeInt128(value);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
case "int256":
|
|
124
|
+
if (typeof value === "bigint") {
|
|
125
|
+
this.writeInt256(value);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
throw new TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
case "long":
|
|
132
|
+
if (typeof value === "bigint") {
|
|
133
|
+
this.writeInt64(value);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
throw new TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
case "Bool":
|
|
140
|
+
if (typeof value === "boolean") {
|
|
141
|
+
if (value) {
|
|
142
|
+
this.writeInt32(BOOL_TRUE);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.writeInt32(BOOL_FALSE);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new TLError(`Expected boolean but received ${valueRepr}${debugInfo}`);
|
|
150
|
+
}
|
|
151
|
+
return true;
|
|
152
|
+
case "int":
|
|
153
|
+
//
|
|
154
|
+
if (value == null) {
|
|
155
|
+
value = 0;
|
|
156
|
+
}
|
|
157
|
+
//
|
|
158
|
+
if (typeof value === "number") {
|
|
159
|
+
this.writeInt32(value);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
throw new TLError(`Expected number but received ${valueRepr}${debugInfo}`);
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
case "double":
|
|
166
|
+
//
|
|
167
|
+
if (value == null) {
|
|
168
|
+
value = 0;
|
|
169
|
+
}
|
|
170
|
+
//
|
|
171
|
+
if (typeof value === "number") {
|
|
172
|
+
this.writeDouble(value);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
throw new TLError(`Expected number but received ${valueRepr}${debugInfo}`);
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
case "string":
|
|
179
|
+
if (typeof value === "string") {
|
|
180
|
+
this.writeString(value);
|
|
181
|
+
}
|
|
182
|
+
else if (value instanceof Uint8Array) {
|
|
183
|
+
this.writeBytes(value);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
this.writeString("");
|
|
187
|
+
}
|
|
188
|
+
// else {
|
|
189
|
+
// throw new TypeError(`Expected string or Uint8Array but received ${valueRepr}`);
|
|
190
|
+
// }
|
|
191
|
+
return true;
|
|
192
|
+
case "true":
|
|
193
|
+
if (value !== true) {
|
|
194
|
+
throw new TLError(`Expected true but received ${valueRepr}${debugInfo}`);
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
default:
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}, _TLWriter_isTypeValid = function _TLWriter_isTypeValid(type, value) {
|
|
201
|
+
if (type == value._) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
const enum_ = getEnum(type);
|
|
205
|
+
return enum_?.includes(value._) || false;
|
|
206
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_tl_writer_test.d.ts","sourceRoot":"","sources":["../../src/tl/2_tl_writer_test.ts"],"names":[],"mappings":""}
|
|
@@ -33,4 +33,4 @@ export declare function chatIdToPeer(chatId: number): Api.Peer;
|
|
|
33
33
|
export declare function chatIdToPeerId(chatId: number): bigint;
|
|
34
34
|
export declare function getChatIdPeerType(chatId: number): "user" | "chat" | "channel";
|
|
35
35
|
export declare function inputPeerToPeer(inputPeer: Api.InputPeer): Api.Peer;
|
|
36
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=2_utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"2_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/2_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAGlC,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE1D;AAGD,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC;AAErG,MAAM,MAAM,uBAAuB,GAAG,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC,wBAAwB,GAAG,GAAG,CAAC,2BAA2B,CAAC;AAEpK,MAAM,MAAM,mBAAmB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAErG,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,uBAAuB,GAAG,GAAG,CAAC,IAAI,GAAG,mBAAmB,GAAG,MAAM,CAU/G;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,IAAI,CAQrD;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWrD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ7E;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,IAAI,CAUlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_chosen_inline_result.d.ts","sourceRoot":"","sources":["../../src/types/2_chosen_inline_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"2_chosen_inline_result.d.ts","sourceRoot":"","sources":["../../src/types/2_chosen_inline_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAgB,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAqB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAiB,IAAI,EAAE,MAAM,aAAa,CAAC;AAElD,8BAA8B;AAC9B,MAAM,WAAW,kBAAkB;IACjC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,IAAI,EAAE,IAAI,CAAC;IACX,qDAAqD;IACrD,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,2BAA2B,CAAC,IAAI,EAAE,GAAG,CAAC,mBAAmB,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAYrI"}
|