@mtkruto/node 0.0.801 → 0.0.821

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.
Files changed (157) hide show
  1. package/esm/_dnt.test_shims.d.ts +10 -0
  2. package/esm/client/client_plain.js +4 -3
  3. package/esm/connection/connection_web_socket.js +3 -1
  4. package/{types → esm}/mod.d.ts +1 -0
  5. package/esm/mod.js +1 -0
  6. package/esm/tl/0_tl_raw_reader_test.d.ts +1 -0
  7. package/esm/tl/0_tl_raw_writer_test.d.ts +1 -0
  8. package/{types → esm}/tl/1_tl_object.d.ts +5 -2
  9. package/esm/tl/1_tl_object.js +14 -7
  10. package/esm/tl/1_tl_object_test.d.ts +1 -0
  11. package/esm/tl/2_types_test.d.ts +1 -0
  12. package/esm/tl/3_deserialize_test.d.ts +1 -0
  13. package/esm/tl/3_functions_test.d.ts +1 -0
  14. package/esm/tl/3_tl_reader.js +1 -1
  15. package/esm/tl/3_tl_writer.js +2 -1
  16. package/esm/tl/5_message.js +2 -2
  17. package/esm/utilities/0_bigint_test.d.ts +1 -0
  18. package/esm/utilities/0_buffer_test.d.ts +1 -0
  19. package/esm/utilities/1_message.js +2 -2
  20. package/esm/utilities/1_password_test.d.ts +1 -0
  21. package/package.json +5 -12
  22. package/script/_dnt.shims.d.ts +10 -0
  23. package/script/_dnt.test_shims.d.ts +10 -0
  24. package/script/client/client.d.ts +50 -0
  25. package/script/client/client_abstract.d.ts +16 -0
  26. package/script/client/client_plain.d.ts +9 -0
  27. package/script/client/client_plain.js +4 -3
  28. package/script/connection/connection.d.ts +7 -0
  29. package/script/connection/connection_web_socket.d.ts +13 -0
  30. package/script/connection/connection_web_socket.js +3 -1
  31. package/script/constants.d.ts +12 -0
  32. package/script/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
  33. package/script/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
  34. package/script/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
  35. package/script/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
  36. package/script/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
  37. package/script/deps/deno.land/x/tgcrypto@0.1.3/mod.d.ts +47 -0
  38. package/script/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +2 -0
  39. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
  40. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
  41. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
  42. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
  43. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
  44. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
  45. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
  46. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
  47. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
  48. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
  49. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
  50. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
  51. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
  52. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
  53. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
  54. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
  55. package/script/deps.d.ts +4 -0
  56. package/script/mod.d.ts +24 -0
  57. package/script/mod.js +3 -1
  58. package/script/session/session.d.ts +12 -0
  59. package/script/session/session_local_storage.d.ts +7 -0
  60. package/script/session/session_memory.d.ts +5 -0
  61. package/script/tl/0_tl_raw_reader.d.ts +13 -0
  62. package/script/tl/0_tl_raw_reader_test.d.ts +1 -0
  63. package/script/tl/0_tl_raw_writer.d.ts +13 -0
  64. package/script/tl/0_tl_raw_writer_test.d.ts +1 -0
  65. package/script/tl/1_tl_object.d.ts +40 -0
  66. package/script/tl/1_tl_object.js +15 -8
  67. package/script/tl/1_tl_object_test.d.ts +1 -0
  68. package/script/tl/2_types.d.ts +14815 -0
  69. package/script/tl/2_types_test.d.ts +1 -0
  70. package/script/tl/3_deserialize.d.ts +3 -0
  71. package/script/tl/3_deserialize_test.d.ts +1 -0
  72. package/script/tl/3_functions.d.ts +6122 -0
  73. package/script/tl/3_functions_test.d.ts +1 -0
  74. package/script/tl/3_tl_reader.d.ts +6 -0
  75. package/script/tl/3_tl_reader.js +2 -2
  76. package/script/tl/3_tl_writer.d.ts +5 -0
  77. package/script/tl/3_tl_writer.js +2 -1
  78. package/script/tl/4_rpc_result.d.ts +8 -0
  79. package/script/tl/5_message.d.ts +11 -0
  80. package/script/tl/5_message.js +1 -1
  81. package/script/tl/6_message_container.d.ts +9 -0
  82. package/script/transport/transport.d.ts +15 -0
  83. package/script/transport/transport_abridged.d.ts +11 -0
  84. package/script/transport/transport_intermediate.d.ts +11 -0
  85. package/script/transport/transport_provider.d.ts +17 -0
  86. package/script/types.d.ts +1 -0
  87. package/script/utilities/0_bigint.d.ts +5 -0
  88. package/script/utilities/0_bigint_test.d.ts +1 -0
  89. package/script/utilities/0_buffer.d.ts +2 -0
  90. package/script/utilities/0_buffer_test.d.ts +1 -0
  91. package/script/utilities/0_crypto.d.ts +8 -0
  92. package/script/utilities/0_hash.d.ts +2 -0
  93. package/script/utilities/1_auth.d.ts +1 -0
  94. package/script/utilities/1_message.d.ts +10 -0
  95. package/script/utilities/1_message.js +1 -1
  96. package/script/utilities/1_obfuscation.d.ts +6 -0
  97. package/script/utilities/1_password.d.ts +11 -0
  98. package/script/utilities/1_password_test.d.ts +1 -0
  99. /package/{types → esm}/_dnt.shims.d.ts +0 -0
  100. /package/{types → esm}/client/client.d.ts +0 -0
  101. /package/{types → esm}/client/client_abstract.d.ts +0 -0
  102. /package/{types → esm}/client/client_plain.d.ts +0 -0
  103. /package/{types → esm}/connection/connection.d.ts +0 -0
  104. /package/{types → esm}/connection/connection_web_socket.d.ts +0 -0
  105. /package/{types → esm}/constants.d.ts +0 -0
  106. /package/{types → esm}/deps/deno.land/std@0.186.0/fmt/colors.d.ts +0 -0
  107. /package/{types → esm}/deps/deno.land/std@0.186.0/testing/_diff.d.ts +0 -0
  108. /package/{types → esm}/deps/deno.land/std@0.186.0/testing/_format.d.ts +0 -0
  109. /package/{types → esm}/deps/deno.land/std@0.186.0/testing/asserts.d.ts +0 -0
  110. /package/{types → esm}/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +0 -0
  111. /package/{types → esm}/deps/deno.land/x/tgcrypto@0.1.3/mod.d.ts +0 -0
  112. /package/{types → esm}/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +0 -0
  113. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +0 -0
  114. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +0 -0
  115. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +0 -0
  116. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +0 -0
  117. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +0 -0
  118. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +0 -0
  119. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +0 -0
  120. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +0 -0
  121. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +0 -0
  122. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +0 -0
  123. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +0 -0
  124. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +0 -0
  125. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +0 -0
  126. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +0 -0
  127. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +0 -0
  128. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +0 -0
  129. /package/{types → esm}/deps.d.ts +0 -0
  130. /package/{types → esm}/session/session.d.ts +0 -0
  131. /package/{types → esm}/session/session_local_storage.d.ts +0 -0
  132. /package/{types → esm}/session/session_memory.d.ts +0 -0
  133. /package/{types → esm}/tl/0_tl_raw_reader.d.ts +0 -0
  134. /package/{types → esm}/tl/0_tl_raw_writer.d.ts +0 -0
  135. /package/{types → esm}/tl/2_types.d.ts +0 -0
  136. /package/{types/tl/3_tl_object_deserializer.d.ts → esm/tl/3_deserialize.d.ts} +0 -0
  137. /package/esm/tl/{3_tl_object_deserializer.js → 3_deserialize.js} +0 -0
  138. /package/{types → esm}/tl/3_functions.d.ts +0 -0
  139. /package/{types → esm}/tl/3_tl_reader.d.ts +0 -0
  140. /package/{types → esm}/tl/3_tl_writer.d.ts +0 -0
  141. /package/{types → esm}/tl/4_rpc_result.d.ts +0 -0
  142. /package/{types → esm}/tl/5_message.d.ts +0 -0
  143. /package/{types → esm}/tl/6_message_container.d.ts +0 -0
  144. /package/{types → esm}/transport/transport.d.ts +0 -0
  145. /package/{types → esm}/transport/transport_abridged.d.ts +0 -0
  146. /package/{types → esm}/transport/transport_intermediate.d.ts +0 -0
  147. /package/{types → esm}/transport/transport_provider.d.ts +0 -0
  148. /package/{types → esm}/types.d.ts +0 -0
  149. /package/{types → esm}/utilities/0_bigint.d.ts +0 -0
  150. /package/{types → esm}/utilities/0_buffer.d.ts +0 -0
  151. /package/{types → esm}/utilities/0_crypto.d.ts +0 -0
  152. /package/{types → esm}/utilities/0_hash.d.ts +0 -0
  153. /package/{types → esm}/utilities/1_auth.d.ts +0 -0
  154. /package/{types → esm}/utilities/1_message.d.ts +0 -0
  155. /package/{types → esm}/utilities/1_obfuscation.d.ts +0 -0
  156. /package/{types → esm}/utilities/1_password.d.ts +0 -0
  157. /package/script/tl/{3_tl_object_deserializer.js → 3_deserialize.js} +0 -0
@@ -0,0 +1,23 @@
1
+ import STATUS from "./zlib/status.js";
2
+ import ZStream from "./zlib/zstream.js";
3
+ import GZheader from "./zlib/gzheader.js";
4
+ export interface InflateOptions {
5
+ windowBits?: number;
6
+ dictionary?: Uint8Array;
7
+ chunkSize?: number;
8
+ to?: string;
9
+ raw?: boolean;
10
+ }
11
+ export declare class Inflate {
12
+ err: STATUS;
13
+ msg: string;
14
+ ended: boolean;
15
+ strm: ZStream;
16
+ options: any;
17
+ header: GZheader;
18
+ constructor(options: InflateOptions);
19
+ push(data: Uint8Array, mode: boolean | number): Uint8Array;
20
+ }
21
+ export declare function inflate(input: Uint8Array, options?: InflateOptions): Uint8Array;
22
+ export declare function inflateRaw(input: Uint8Array, options?: InflateOptions): Uint8Array;
23
+ export declare const gunzip: typeof inflate;
@@ -0,0 +1,2 @@
1
+ export * from "./deflate.js";
2
+ export * from "./inflate.js";
@@ -0,0 +1 @@
1
+ export default function adler32(adler: any, buf: any, len: any, pos: any): number;
@@ -0,0 +1,2 @@
1
+ export declare function makeTable(): number[];
2
+ export declare function crc32(crc: any, buf: any, len: any, pos: any): number;
@@ -0,0 +1,78 @@
1
+ import { CODE } from "./messages.js";
2
+ import type ZStream from "./zstream.js";
3
+ import STATUS from "./status.js";
4
+ export interface Header {
5
+ text: boolean;
6
+ time: number;
7
+ os: number;
8
+ extra: string[];
9
+ name: string;
10
+ comment: string;
11
+ hcrc: boolean;
12
+ }
13
+ export declare class DeflateState {
14
+ strm: ZStream | null;
15
+ status: number;
16
+ pending_buf: any;
17
+ pending_buf_size: number;
18
+ pending_out: number;
19
+ pending: number;
20
+ wrap: number;
21
+ gzhead: Header | null;
22
+ gzindex: number;
23
+ method: number;
24
+ last_flush: number;
25
+ w_size: number;
26
+ w_bits: number;
27
+ w_mask: number;
28
+ window: any;
29
+ window_size: number;
30
+ prev: any;
31
+ head: any;
32
+ ins_h: number;
33
+ hash_size: number;
34
+ hash_bits: number;
35
+ hash_mask: number;
36
+ hash_shift: number;
37
+ block_start: number;
38
+ match_length: number;
39
+ prev_match: number;
40
+ match_available: number;
41
+ strstart: number;
42
+ match_start: number;
43
+ lookahead: number;
44
+ prev_length: number;
45
+ max_chain_length: number;
46
+ max_lazy_match: number;
47
+ level: number;
48
+ strategy: number;
49
+ good_match: number;
50
+ nice_match: number;
51
+ dyn_ltree: Uint16Array;
52
+ dyn_dtree: Uint16Array;
53
+ bl_tree: Uint16Array;
54
+ l_desc: null;
55
+ d_desc: null;
56
+ bl_desc: null;
57
+ bl_count: Uint16Array;
58
+ heap: Uint16Array;
59
+ heap_len: number;
60
+ heap_max: number;
61
+ depth: Uint16Array;
62
+ l_buf: number;
63
+ lit_bufsize: number;
64
+ last_lit: number;
65
+ d_buf: number;
66
+ opt_len: number;
67
+ static_len: number;
68
+ matches: number;
69
+ insert: number;
70
+ bi_buf: number;
71
+ bi_valid: number;
72
+ constructor();
73
+ }
74
+ export declare function deflateSetHeader(strm: ZStream, head: Header): 0 | -2;
75
+ export declare function deflateInit2(strm: ZStream, level: number, method: number, windowBits: number, memLevel: number, strategy: number): CODE;
76
+ export declare function deflate(strm: ZStream, flush: number): CODE | -2 | STATUS.Z_NO_FLUSH | STATUS.Z_PARTIAL_FLUSH;
77
+ export declare function deflateEnd(strm: ZStream): any;
78
+ export declare function deflateSetDictionary(strm: ZStream, dictionary: Uint8Array): any;
@@ -0,0 +1,12 @@
1
+ export default class GZheader {
2
+ text: number;
3
+ time: number;
4
+ xflags: number;
5
+ os: number;
6
+ extra: any;
7
+ extra_len: number;
8
+ name: string;
9
+ comment: string;
10
+ hcrc: number;
11
+ done: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export default function inflate_fast(strm: any, start: number): void;
@@ -0,0 +1,47 @@
1
+ import type ZStream from "./zstream.js";
2
+ export declare class InflateState {
3
+ mode: number;
4
+ last: boolean;
5
+ wrap: number;
6
+ havedict: boolean;
7
+ flags: number;
8
+ dmax: number;
9
+ check: number;
10
+ total: number;
11
+ head: null;
12
+ wbits: number;
13
+ wsize: number;
14
+ whave: number;
15
+ wnext: number;
16
+ window: null;
17
+ hold: number;
18
+ bits: number;
19
+ length: number;
20
+ offset: number;
21
+ extra: number;
22
+ lencode: null;
23
+ distcode: null;
24
+ lenbits: number;
25
+ distbits: number;
26
+ ncode: number;
27
+ nlen: number;
28
+ ndist: number;
29
+ have: number;
30
+ next: null;
31
+ lens: Uint16Array;
32
+ work: Uint16Array;
33
+ lendyn: null;
34
+ distdyn: null;
35
+ sane: number;
36
+ back: number;
37
+ was: number;
38
+ }
39
+ export declare function inflateResetKeep(strm: ZStream): 0 | -2;
40
+ export declare function inflateReset(strm: ZStream): 0 | -2;
41
+ export declare function inflateReset2(strm: any, windowBits: any): 0 | -2;
42
+ export declare function inflateInit2(strm: ZStream, windowBits: any): number;
43
+ export declare function inflateInit(strm: ZStream): number;
44
+ export declare function inflate(strm: ZStream, flush: any): number;
45
+ export declare function inflateEnd(strm: ZStream): 0 | -2;
46
+ export declare function inflateGetHeader(strm: ZStream, head: any): 0 | -2;
47
+ export declare function inflateSetDictionary(strm: ZStream, dictionary: any): 0 | -2 | -3 | -4;
@@ -0,0 +1 @@
1
+ export default function inflate_table(type: any, lens: any, lens_index: any, codes: any, table: any, table_index: any, work: any, opts: any): 0 | 1 | -1;
@@ -0,0 +1,12 @@
1
+ export declare const message: {
2
+ 2: string;
3
+ 1: string;
4
+ 0: string;
5
+ "-1": string;
6
+ "-2": string;
7
+ "-3": string;
8
+ "-4": string;
9
+ "-5": string;
10
+ "-6": string;
11
+ };
12
+ export type CODE = 2 | 1 | 0 | "-1" | "-2" | "-3" | "-4" | "-5" | "-6";
@@ -0,0 +1,30 @@
1
+ declare enum STATUS {
2
+ Z_NO_FLUSH = 0,
3
+ Z_PARTIAL_FLUSH = 1,
4
+ Z_SYNC_FLUSH = 2,
5
+ Z_FULL_FLUSH = 3,
6
+ Z_FINISH = 4,
7
+ Z_BLOCK = 5,
8
+ Z_TREES = 6,
9
+ Z_OK = 0,
10
+ Z_STREAM_END = 1,
11
+ Z_NEED_DICT = 2,
12
+ Z_ERRNO = -1,
13
+ Z_STREAM_ERROR = -2,
14
+ Z_DATA_ERROR = -3,
15
+ Z_BUF_ERROR = -5,
16
+ Z_NO_COMPRESSION = 0,
17
+ Z_BEST_SPEED = 1,
18
+ Z_BEST_COMPRESSION = 9,
19
+ Z_DEFAULT_COMPRESSION = -1,
20
+ Z_FILTERED = 1,
21
+ Z_HUFFMAN_ONLY = 2,
22
+ Z_RLE = 3,
23
+ Z_FIXED = 4,
24
+ Z_DEFAULT_STRATEGY = 0,
25
+ Z_BINARY = 0,
26
+ Z_TEXT = 1,
27
+ Z_UNKNOWN = 2,
28
+ Z_DEFLATED = 8
29
+ }
30
+ export default STATUS;
@@ -0,0 +1,5 @@
1
+ export declare function _tr_init(s: any): void;
2
+ export declare function _tr_stored_block(s: any, buf: any, stored_len: any, last: any): void;
3
+ export declare function _tr_align(s: any): void;
4
+ export declare function _tr_flush_block(s: any, buf: any, stored_len: any, last: any): void;
5
+ export declare function _tr_tally(s: any, dist: any, lc: any): boolean;
@@ -0,0 +1,14 @@
1
+ export default class ZStream {
2
+ input: Uint8Array | null;
3
+ next_in: number;
4
+ avail_in: number;
5
+ total_in: number;
6
+ output: Uint8Array | null;
7
+ next_out: number;
8
+ avail_out: number;
9
+ total_out: number;
10
+ msg: string;
11
+ state: any;
12
+ data_type: number;
13
+ adler: number;
14
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./deps/deno.land/std@0.186.0/testing/asserts.js";
2
+ export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.1.3/mod.js";
3
+ export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js";
4
+ export { Mutex } from "async-mutex";
@@ -0,0 +1,24 @@
1
+ import { checkPassword } from "./utilities/1_password.js";
2
+ import { getRandomId } from "./utilities/0_bigint.js";
3
+ export declare const utils: {
4
+ checkPassword: typeof checkPassword;
5
+ getRandomId: typeof getRandomId;
6
+ };
7
+ export { as } from "./tl/1_tl_object.js";
8
+ export * as types from "./tl/2_types.js";
9
+ export * as functions from "./tl/3_functions.js";
10
+ export * from "./tl/4_rpc_result.js";
11
+ export * from "./tl/5_message.js";
12
+ export * from "./tl/6_message_container.js";
13
+ export * from "./client/client_plain.js";
14
+ export * from "./client/client.js";
15
+ export * from "./session/session.js";
16
+ export * from "./session/session_memory.js";
17
+ export * from "./session/session_local_storage.js";
18
+ export * from "./transport/transport_abridged.js";
19
+ export * from "./transport/transport_intermediate.js";
20
+ export * from "./transport/transport.js";
21
+ export * from "./transport/transport_provider.js";
22
+ export * from "./connection/connection.js";
23
+ export * from "./connection/connection_web_socket.js";
24
+ export { DEFAULT_APP_VERSION, DEFAULT_DEVICE_MODEL, DEFAULT_INITIAL_DC, DEFAULT_LANG_CODE, DEFAULT_LANG_PACK, DEFAULT_SYSTEM_LANG_CODE, DEFAULT_SYSTEM_VERSION, LAYER } from "./constants.js";
package/script/mod.js CHANGED
@@ -26,10 +26,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.LAYER = exports.DEFAULT_SYSTEM_VERSION = exports.DEFAULT_SYSTEM_LANG_CODE = exports.DEFAULT_LANG_PACK = exports.DEFAULT_LANG_CODE = exports.DEFAULT_INITIAL_DC = exports.DEFAULT_DEVICE_MODEL = exports.DEFAULT_APP_VERSION = exports.functions = exports.types = exports.utils = void 0;
29
+ exports.LAYER = exports.DEFAULT_SYSTEM_VERSION = exports.DEFAULT_SYSTEM_LANG_CODE = exports.DEFAULT_LANG_PACK = exports.DEFAULT_LANG_CODE = exports.DEFAULT_INITIAL_DC = exports.DEFAULT_DEVICE_MODEL = exports.DEFAULT_APP_VERSION = exports.functions = exports.types = exports.as = exports.utils = void 0;
30
30
  const _1_password_js_1 = require("./utilities/1_password.js");
31
31
  const _0_bigint_js_1 = require("./utilities/0_bigint.js");
32
32
  exports.utils = { checkPassword: _1_password_js_1.checkPassword, getRandomId: _0_bigint_js_1.getRandomId };
33
+ var _1_tl_object_js_1 = require("./tl/1_tl_object.js");
34
+ Object.defineProperty(exports, "as", { enumerable: true, get: function () { return _1_tl_object_js_1.as; } });
33
35
  exports.types = __importStar(require("./tl/2_types.js"));
34
36
  exports.functions = __importStar(require("./tl/3_functions.js"));
35
37
  __exportStar(require("./tl/4_rpc_result.js"), exports);
@@ -0,0 +1,12 @@
1
+ import { MaybePromise } from "../types.js";
2
+ import { DC } from "../transport/transport_provider.js";
3
+ export declare abstract class Session {
4
+ dc: DC | null;
5
+ private _authKeyId;
6
+ private _authKey;
7
+ abstract load(): MaybePromise<void>;
8
+ abstract save(): MaybePromise<void>;
9
+ get authKeyId(): Promise<bigint | null>;
10
+ set authKey(authKey: Uint8Array | null);
11
+ get authKey(): Uint8Array | null;
12
+ }
@@ -0,0 +1,7 @@
1
+ import { Session } from "./session.js";
2
+ export declare class SessionLocalStorage extends Session implements Session {
3
+ private readonly key;
4
+ constructor(key: string);
5
+ load(): void;
6
+ save(): void;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { Session } from "./session.js";
2
+ export declare class SessionMemory extends Session implements Session {
3
+ load(): void;
4
+ save(): void;
5
+ }
@@ -0,0 +1,13 @@
1
+ export declare class TLRawReader {
2
+ protected _buffer: Uint8Array;
3
+ constructor(_buffer: Uint8Array);
4
+ get buffer(): Uint8Array;
5
+ read(count: number): Uint8Array;
6
+ readInt24(signed?: boolean): number;
7
+ readInt32(signed?: boolean): number;
8
+ readInt64(signed?: boolean): bigint;
9
+ readInt128(signed?: boolean): bigint;
10
+ readInt256(signed?: boolean): bigint;
11
+ readBytes(): Uint8Array;
12
+ readString(): string;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export declare class TLRawWriter {
2
+ protected _buffer: Uint8Array;
3
+ constructor();
4
+ get buffer(): Uint8Array;
5
+ write(buffer: Uint8Array): this;
6
+ writeInt24(int: number, signed?: boolean): this;
7
+ writeInt32(int: number, signed?: boolean): this;
8
+ writeInt64(int: bigint, signed?: boolean): this;
9
+ writeInt128(int: bigint, signed?: boolean): this;
10
+ writeInt256(int: bigint, signed?: boolean): this;
11
+ writeBytes(bytes: Uint8Array): this;
12
+ writeString(string: string): this;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ type MaybeArrayOf<T> = T | T[];
2
+ type MaybeInArray<T> = T | [T];
3
+ export type ParamDesc = ([
4
+ string,
5
+ MaybeInArray<typeof TLObject | typeof Uint8Array | "string" | "number" | "bigint" | "boolean" | "true">,
6
+ string
7
+ ] | [string, typeof flags, "#"])[];
8
+ export type Param = null | MaybeArrayOf<string | number | bigint | boolean | Uint8Array | TLObject>;
9
+ export declare const flags: unique symbol;
10
+ export type Params = ([
11
+ Param,
12
+ MaybeInArray<typeof TLObject | typeof Uint8Array | "string" | "number" | "bigint" | "boolean" | "true">,
13
+ string
14
+ ] | [string, typeof flags, "#"])[];
15
+ export declare const id: unique symbol;
16
+ export declare const params: unique symbol;
17
+ export declare const paramDesc: unique symbol;
18
+ export declare const length: unique symbol;
19
+ export declare const serialize: unique symbol;
20
+ export declare const as: unique symbol;
21
+ export declare function isOptionalParam(ntype: string): boolean;
22
+ export declare function analyzeOptionalParam(ntype: string): {
23
+ flagField: string;
24
+ bitIndex: number;
25
+ };
26
+ export declare abstract class TLObject {
27
+ protected abstract get [id](): number;
28
+ protected abstract get [params](): Params;
29
+ protected static get [paramDesc](): ParamDesc;
30
+ get [length](): number;
31
+ [serialize](): Uint8Array;
32
+ [as]<T extends TLObjectConstructor<InstanceType<T>>>(constructor: T): InstanceType<T>;
33
+ }
34
+ export type MaybeVectorTLObject = TLObject | Array<MaybeVectorTLObject | TLObject>;
35
+ export interface TLObjectConstructor<T = TLObject> {
36
+ new (params: any): T;
37
+ [paramDesc]: ParamDesc;
38
+ }
39
+ export declare function isTLObjectConstructor(t: unknown): t is typeof TLObject;
40
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTLObjectConstructor = exports.TLObject = exports.analyzeOptionalParam = exports.isOptionalParam = exports.length = exports.paramDesc = exports.params = exports.id = exports.flags = void 0;
3
+ exports.isTLObjectConstructor = exports.TLObject = exports.analyzeOptionalParam = exports.isOptionalParam = exports.as = exports.serialize = exports.length = exports.paramDesc = exports.params = exports.id = exports.flags = void 0;
4
4
  const deps_js_1 = require("../deps.js");
5
5
  const _0_tl_raw_writer_js_1 = require("./0_tl_raw_writer.js");
6
6
  exports.flags = Symbol("flags");
@@ -8,6 +8,8 @@ exports.id = Symbol("id");
8
8
  exports.params = Symbol("params");
9
9
  exports.paramDesc = Symbol("paramDesc");
10
10
  exports.length = Symbol("length");
11
+ exports.serialize = Symbol();
12
+ exports.as = Symbol();
11
13
  function isOptionalParam(ntype) {
12
14
  return ntype.includes("?");
13
15
  }
@@ -27,7 +29,7 @@ function serializeSingleParam(writer, value, type, ntype) {
27
29
  if (isTLObjectConstructor(type)) {
28
30
  if ((type.name == "TypeX" && value instanceof TLObject) ||
29
31
  value instanceof type) {
30
- writer.write(value.serialize());
32
+ writer.write(value[exports.serialize]());
31
33
  return;
32
34
  }
33
35
  else {
@@ -92,10 +94,7 @@ function serializeSingleParam(writer, value, type, ntype) {
92
94
  }
93
95
  break;
94
96
  case "true":
95
- if (value === true) {
96
- writer.writeInt32(0x997275B5);
97
- }
98
- else {
97
+ if (value !== true) {
99
98
  throw new TypeError("Expected true");
100
99
  }
101
100
  }
@@ -106,9 +105,9 @@ class TLObject {
106
105
  return [];
107
106
  }
108
107
  get [exports.length]() {
109
- return this.serialize().byteLength;
108
+ return this[exports.serialize]().byteLength;
110
109
  }
111
- serialize() {
110
+ [exports.serialize]() {
112
111
  const writer = new _0_tl_raw_writer_js_1.TLRawWriter();
113
112
  writer.writeInt32(this[exports.id], false);
114
113
  for (const [value, type, ntype] of this[exports.params]) {
@@ -147,6 +146,14 @@ class TLObject {
147
146
  }
148
147
  return writer.buffer;
149
148
  }
149
+ [exports.as](constructor) {
150
+ if (this instanceof constructor) {
151
+ return this;
152
+ }
153
+ else {
154
+ throw new TypeError(`Expected ${constructor.name}, got ${this.constructor.name}`);
155
+ }
156
+ }
150
157
  }
151
158
  exports.TLObject = TLObject;
152
159
  function isTLObjectConstructor(t) {
@@ -0,0 +1 @@
1
+ export {};