@mtkruto/node 0.0.820 → 0.0.822
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/_dnt.test_shims.d.ts +10 -0
- package/esm/client/client.d.ts +114 -0
- package/esm/client/client.js +126 -1
- package/esm/tl/0_tl_raw_reader_test.d.ts +1 -0
- package/esm/tl/0_tl_raw_writer_test.d.ts +1 -0
- package/esm/tl/1_tl_object_test.d.ts +1 -0
- package/{types → esm}/tl/2_types.d.ts +48 -48
- package/esm/tl/2_types.js +180 -180
- package/esm/tl/2_types_test.d.ts +1 -0
- package/esm/tl/3_deserialize_test.d.ts +1 -0
- package/{types → esm}/tl/3_functions.d.ts +13 -13
- package/esm/tl/3_functions.js +39 -39
- package/esm/tl/3_functions_test.d.ts +1 -0
- package/esm/utilities/0_bigint_test.d.ts +1 -0
- package/esm/utilities/0_buffer_test.d.ts +1 -0
- package/{types → esm}/utilities/1_password.d.ts +1 -1
- package/esm/utilities/1_password.js +2 -1
- package/esm/utilities/1_password_test.d.ts +1 -0
- package/package.json +5 -12
- package/script/_dnt.shims.d.ts +10 -0
- package/script/_dnt.test_shims.d.ts +10 -0
- package/script/client/client.d.ts +114 -0
- package/script/client/client.js +127 -2
- package/script/client/client_abstract.d.ts +16 -0
- package/script/client/client_plain.d.ts +9 -0
- package/script/connection/connection.d.ts +7 -0
- package/script/connection/connection_web_socket.d.ts +13 -0
- package/script/constants.d.ts +12 -0
- package/script/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
- package/script/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
- package/script/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
- package/script/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
- package/script/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.3/mod.d.ts +47 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +2 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
- package/script/deps.d.ts +4 -0
- package/script/mod.d.ts +24 -0
- package/script/session/session.d.ts +12 -0
- package/script/session/session_local_storage.d.ts +7 -0
- package/script/session/session_memory.d.ts +5 -0
- package/script/tl/0_tl_raw_reader.d.ts +13 -0
- package/script/tl/0_tl_raw_reader_test.d.ts +1 -0
- package/script/tl/0_tl_raw_writer.d.ts +13 -0
- package/script/tl/0_tl_raw_writer_test.d.ts +1 -0
- package/script/tl/1_tl_object.d.ts +40 -0
- package/script/tl/1_tl_object_test.d.ts +1 -0
- package/script/tl/2_types.d.ts +14815 -0
- package/script/tl/2_types.js +180 -180
- package/script/tl/2_types_test.d.ts +1 -0
- package/script/tl/3_deserialize.d.ts +3 -0
- package/script/tl/3_deserialize_test.d.ts +1 -0
- package/script/tl/3_functions.d.ts +6122 -0
- package/script/tl/3_functions.js +39 -39
- package/script/tl/3_functions_test.d.ts +1 -0
- package/script/tl/3_tl_reader.d.ts +6 -0
- package/script/tl/3_tl_writer.d.ts +5 -0
- package/script/tl/4_rpc_result.d.ts +8 -0
- package/script/tl/5_message.d.ts +11 -0
- package/script/tl/6_message_container.d.ts +9 -0
- package/script/transport/transport.d.ts +15 -0
- package/script/transport/transport_abridged.d.ts +11 -0
- package/script/transport/transport_intermediate.d.ts +11 -0
- package/script/transport/transport_provider.d.ts +17 -0
- package/script/types.d.ts +1 -0
- package/script/utilities/0_bigint.d.ts +5 -0
- package/script/utilities/0_bigint_test.d.ts +1 -0
- package/script/utilities/0_buffer.d.ts +2 -0
- package/script/utilities/0_buffer_test.d.ts +1 -0
- package/script/utilities/0_crypto.d.ts +8 -0
- package/script/utilities/0_hash.d.ts +2 -0
- package/script/utilities/1_auth.d.ts +1 -0
- package/script/utilities/1_message.d.ts +10 -0
- package/script/utilities/1_obfuscation.d.ts +6 -0
- package/script/utilities/1_password.d.ts +11 -0
- package/script/utilities/1_password.js +2 -1
- package/script/utilities/1_password_test.d.ts +1 -0
- package/types/client/client.d.ts +0 -50
- /package/{types → esm}/_dnt.shims.d.ts +0 -0
- /package/{types → esm}/client/client_abstract.d.ts +0 -0
- /package/{types → esm}/client/client_plain.d.ts +0 -0
- /package/{types → esm}/connection/connection.d.ts +0 -0
- /package/{types → esm}/connection/connection_web_socket.d.ts +0 -0
- /package/{types → esm}/constants.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/std@0.186.0/fmt/colors.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/std@0.186.0/testing/_diff.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/std@0.186.0/testing/_format.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/std@0.186.0/testing/asserts.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/tgcrypto@0.1.3/mod.d.ts +0 -0
- /package/{types → esm}/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +0 -0
- /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +0 -0
- /package/{types → esm}/deps.d.ts +0 -0
- /package/{types → esm}/mod.d.ts +0 -0
- /package/{types → esm}/session/session.d.ts +0 -0
- /package/{types → esm}/session/session_local_storage.d.ts +0 -0
- /package/{types → esm}/session/session_memory.d.ts +0 -0
- /package/{types → esm}/tl/0_tl_raw_reader.d.ts +0 -0
- /package/{types → esm}/tl/0_tl_raw_writer.d.ts +0 -0
- /package/{types → esm}/tl/1_tl_object.d.ts +0 -0
- /package/{types → esm}/tl/3_deserialize.d.ts +0 -0
- /package/{types → esm}/tl/3_tl_reader.d.ts +0 -0
- /package/{types → esm}/tl/3_tl_writer.d.ts +0 -0
- /package/{types → esm}/tl/4_rpc_result.d.ts +0 -0
- /package/{types → esm}/tl/5_message.d.ts +0 -0
- /package/{types → esm}/tl/6_message_container.d.ts +0 -0
- /package/{types → esm}/transport/transport.d.ts +0 -0
- /package/{types → esm}/transport/transport_abridged.d.ts +0 -0
- /package/{types → esm}/transport/transport_intermediate.d.ts +0 -0
- /package/{types → esm}/transport/transport_provider.d.ts +0 -0
- /package/{types → esm}/types.d.ts +0 -0
- /package/{types → esm}/utilities/0_bigint.d.ts +0 -0
- /package/{types → esm}/utilities/0_buffer.d.ts +0 -0
- /package/{types → esm}/utilities/0_crypto.d.ts +0 -0
- /package/{types → esm}/utilities/0_hash.d.ts +0 -0
- /package/{types → esm}/utilities/1_auth.d.ts +0 -0
- /package/{types → esm}/utilities/1_message.d.ts +0 -0
- /package/{types → esm}/utilities/1_obfuscation.d.ts +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
export declare class AssertionError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Deep equality comparison used in assertions
|
|
7
|
+
* @param c actual value
|
|
8
|
+
* @param d expected value
|
|
9
|
+
*/
|
|
10
|
+
export declare function equal(c: unknown, d: unknown): boolean;
|
|
11
|
+
/** Make an assertion, error will be thrown if `expr` does not have truthy value. */
|
|
12
|
+
export declare function assert(expr: unknown, msg?: string): asserts expr;
|
|
13
|
+
/** Make an assertion, error will be thrown if `expr` have truthy value. */
|
|
14
|
+
type Falsy = false | 0 | 0n | "" | null | undefined;
|
|
15
|
+
export declare function assertFalse(expr: unknown, msg?: string): asserts expr is Falsy;
|
|
16
|
+
/**
|
|
17
|
+
* Make an assertion that `actual` and `expected` are equal, deeply. If not
|
|
18
|
+
* deeply equal, then throw.
|
|
19
|
+
*
|
|
20
|
+
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
25
|
+
*
|
|
26
|
+
* Deno.test("example", function (): void {
|
|
27
|
+
* assertEquals("world", "world");
|
|
28
|
+
* assertEquals({ hello: "world" }, { hello: "world" });
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Make an assertion that `actual` and `expected` are not equal, deeply.
|
|
35
|
+
* If not then throw.
|
|
36
|
+
*
|
|
37
|
+
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { assertNotEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
42
|
+
*
|
|
43
|
+
* assertNotEquals<number>(1, 2)
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Make an assertion that `actual` and `expected` are strictly equal. If
|
|
49
|
+
* not then throw.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { assertStrictEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
54
|
+
*
|
|
55
|
+
* Deno.test("isStrictlyEqual", function (): void {
|
|
56
|
+
* const a = {};
|
|
57
|
+
* const b = a;
|
|
58
|
+
* assertStrictEquals(a, b);
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // This test fails
|
|
62
|
+
* Deno.test("isNotStrictlyEqual", function (): void {
|
|
63
|
+
* const a = {};
|
|
64
|
+
* const b = {};
|
|
65
|
+
* assertStrictEquals(a, b);
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function assertStrictEquals<T>(actual: unknown, expected: T, msg?: string): asserts actual is T;
|
|
70
|
+
/**
|
|
71
|
+
* Make an assertion that `actual` and `expected` are not strictly equal.
|
|
72
|
+
* If the values are strictly equal then throw.
|
|
73
|
+
*
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { assertNotStrictEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
76
|
+
*
|
|
77
|
+
* assertNotStrictEquals(1, 1)
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function assertNotStrictEquals<T>(actual: T, expected: T, msg?: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Make an assertion that `actual` and `expected` are almost equal numbers through
|
|
83
|
+
* a given tolerance. It can be used to take into account IEEE-754 double-precision
|
|
84
|
+
* floating-point representation limitations.
|
|
85
|
+
* If the values are not almost equal then throw.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { assertAlmostEquals, assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
90
|
+
*
|
|
91
|
+
* assertAlmostEquals(0.1, 0.2);
|
|
92
|
+
*
|
|
93
|
+
* // Using a custom tolerance value
|
|
94
|
+
* assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16);
|
|
95
|
+
* assertThrows(() => assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17));
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function assertAlmostEquals(actual: number, expected: number, tolerance?: number, msg?: string): void;
|
|
99
|
+
type AnyConstructor = new (...args: any[]) => any;
|
|
100
|
+
type GetConstructorType<T extends AnyConstructor> = T extends new (...args: any) => infer C ? C : never;
|
|
101
|
+
/**
|
|
102
|
+
* Make an assertion that `obj` is an instance of `type`.
|
|
103
|
+
* If not then throw.
|
|
104
|
+
*/
|
|
105
|
+
export declare function assertInstanceOf<T extends AnyConstructor>(actual: unknown, expectedType: T, msg?: string): asserts actual is GetConstructorType<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Make an assertion that `obj` is not an instance of `type`.
|
|
108
|
+
* If so, then throw.
|
|
109
|
+
*/
|
|
110
|
+
export declare function assertNotInstanceOf<A, T>(actual: A, unexpectedType: new (...args: any[]) => T, msg?: string): asserts actual is Exclude<A, T>;
|
|
111
|
+
/**
|
|
112
|
+
* Make an assertion that actual is not null or undefined.
|
|
113
|
+
* If not then throw.
|
|
114
|
+
*/
|
|
115
|
+
export declare function assertExists<T>(actual: T, msg?: string): asserts actual is NonNullable<T>;
|
|
116
|
+
/**
|
|
117
|
+
* Make an assertion that actual includes expected. If not
|
|
118
|
+
* then throw.
|
|
119
|
+
*/
|
|
120
|
+
export declare function assertStringIncludes(actual: string, expected: string, msg?: string): void;
|
|
121
|
+
/**
|
|
122
|
+
* Make an assertion that `actual` includes the `expected` values.
|
|
123
|
+
* If not then an error will be thrown.
|
|
124
|
+
*
|
|
125
|
+
* Type parameter can be specified to ensure values under comparison have the same type.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import { assertArrayIncludes } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
130
|
+
*
|
|
131
|
+
* assertArrayIncludes<number>([1, 2], [2])
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function assertArrayIncludes<T>(actual: ArrayLike<T>, expected: ArrayLike<T>, msg?: string): void;
|
|
135
|
+
/**
|
|
136
|
+
* Make an assertion that `actual` match RegExp `expected`. If not
|
|
137
|
+
* then throw.
|
|
138
|
+
*/
|
|
139
|
+
export declare function assertMatch(actual: string, expected: RegExp, msg?: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Make an assertion that `actual` not match RegExp `expected`. If match
|
|
142
|
+
* then throw.
|
|
143
|
+
*/
|
|
144
|
+
export declare function assertNotMatch(actual: string, expected: RegExp, msg?: string): void;
|
|
145
|
+
/**
|
|
146
|
+
* Make an assertion that `actual` object is a subset of `expected` object, deeply.
|
|
147
|
+
* If not, then throw.
|
|
148
|
+
*/
|
|
149
|
+
export declare function assertObjectMatch(actual: Record<PropertyKey, any>, expected: Record<PropertyKey, unknown>, msg?: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Forcefully throws a failed assertion
|
|
152
|
+
*/
|
|
153
|
+
export declare function fail(msg?: string): never;
|
|
154
|
+
/**
|
|
155
|
+
* Make an assertion that `error` is an `Error`.
|
|
156
|
+
* If not then an error will be thrown.
|
|
157
|
+
* An error class and a string that should be included in the
|
|
158
|
+
* error message can also be asserted.
|
|
159
|
+
*/
|
|
160
|
+
export declare function assertIsError<E extends Error = Error>(error: unknown, ErrorClass?: new (...args: any[]) => E, msgIncludes?: string, msg?: string): asserts error is E;
|
|
161
|
+
/**
|
|
162
|
+
* Executes a function, expecting it to throw. If it does not, then it
|
|
163
|
+
* throws.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import { assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
168
|
+
*
|
|
169
|
+
* Deno.test("doesThrow", function (): void {
|
|
170
|
+
* assertThrows((): void => {
|
|
171
|
+
* throw new TypeError("hello world!");
|
|
172
|
+
* });
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* // This test will not pass.
|
|
176
|
+
* Deno.test("fails", function (): void {
|
|
177
|
+
* assertThrows((): void => {
|
|
178
|
+
* console.log("Hello world");
|
|
179
|
+
* });
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export declare function assertThrows(fn: () => unknown, msg?: string): unknown;
|
|
184
|
+
/**
|
|
185
|
+
* Executes a function, expecting it to throw. If it does not, then it
|
|
186
|
+
* throws. An error class and a string that should be included in the
|
|
187
|
+
* error message can also be asserted.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* import { assertThrows } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
193
|
+
*
|
|
194
|
+
* Deno.test("doesThrow", function (): void {
|
|
195
|
+
* assertThrows((): void => {
|
|
196
|
+
* throw new TypeError("hello world!");
|
|
197
|
+
* }, TypeError);
|
|
198
|
+
* assertThrows(
|
|
199
|
+
* (): void => {
|
|
200
|
+
* throw new TypeError("hello world!");
|
|
201
|
+
* },
|
|
202
|
+
* TypeError,
|
|
203
|
+
* "hello",
|
|
204
|
+
* );
|
|
205
|
+
* });
|
|
206
|
+
*
|
|
207
|
+
* // This test will not pass.
|
|
208
|
+
* Deno.test("fails", function (): void {
|
|
209
|
+
* assertThrows((): void => {
|
|
210
|
+
* console.log("Hello world");
|
|
211
|
+
* });
|
|
212
|
+
* });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export declare function assertThrows<E extends Error = Error>(fn: () => unknown, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): E;
|
|
216
|
+
/**
|
|
217
|
+
* Executes a function which returns a promise, expecting it to reject.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```ts
|
|
221
|
+
* import { assertRejects } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
222
|
+
*
|
|
223
|
+
* Deno.test("doesThrow", async function () {
|
|
224
|
+
* await assertRejects(
|
|
225
|
+
* async () => {
|
|
226
|
+
* throw new TypeError("hello world!");
|
|
227
|
+
* },
|
|
228
|
+
* );
|
|
229
|
+
* await assertRejects(
|
|
230
|
+
* async () => {
|
|
231
|
+
* return Promise.reject(new Error());
|
|
232
|
+
* },
|
|
233
|
+
* );
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* // This test will not pass.
|
|
237
|
+
* Deno.test("fails", async function () {
|
|
238
|
+
* await assertRejects(
|
|
239
|
+
* async () => {
|
|
240
|
+
* console.log("Hello world");
|
|
241
|
+
* },
|
|
242
|
+
* );
|
|
243
|
+
* });
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function assertRejects(fn: () => PromiseLike<unknown>, msg?: string): Promise<unknown>;
|
|
247
|
+
/**
|
|
248
|
+
* Executes a function which returns a promise, expecting it to reject.
|
|
249
|
+
* If it does not, then it throws. An error class and a string that should be
|
|
250
|
+
* included in the error message can also be asserted.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import { assertRejects } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
|
|
255
|
+
*
|
|
256
|
+
* Deno.test("doesThrow", async function () {
|
|
257
|
+
* await assertRejects(async () => {
|
|
258
|
+
* throw new TypeError("hello world!");
|
|
259
|
+
* }, TypeError);
|
|
260
|
+
* await assertRejects(
|
|
261
|
+
* async () => {
|
|
262
|
+
* throw new TypeError("hello world!");
|
|
263
|
+
* },
|
|
264
|
+
* TypeError,
|
|
265
|
+
* "hello",
|
|
266
|
+
* );
|
|
267
|
+
* });
|
|
268
|
+
*
|
|
269
|
+
* // This test will not pass.
|
|
270
|
+
* Deno.test("fails", async function () {
|
|
271
|
+
* await assertRejects(
|
|
272
|
+
* async () => {
|
|
273
|
+
* console.log("Hello world");
|
|
274
|
+
* },
|
|
275
|
+
* );
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
export declare function assertRejects<E extends Error = Error>(fn: () => PromiseLike<unknown>, ErrorClass: new (...args: any[]) => E, msgIncludes?: string, msg?: string): Promise<E>;
|
|
280
|
+
/** Use this to stub out methods that will throw when invoked. */
|
|
281
|
+
export declare function unimplemented(msg?: string): never;
|
|
282
|
+
/** Use this to assert unreachable code. */
|
|
283
|
+
export declare function unreachable(): never;
|
|
284
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function crc32(arr: Uint8Array | string): string;
|
|
2
|
+
export declare class Crc32Stream {
|
|
3
|
+
#private;
|
|
4
|
+
private bytes;
|
|
5
|
+
private poly;
|
|
6
|
+
private crc;
|
|
7
|
+
private encoder;
|
|
8
|
+
constructor();
|
|
9
|
+
get crc32(): string;
|
|
10
|
+
reset(): void;
|
|
11
|
+
append(arr: Uint8Array | string): string;
|
|
12
|
+
}
|
|
13
|
+
export declare function numberToHex(n: number): string;
|
|
14
|
+
export declare function hexToUint8Array(str: string): Uint8Array;
|
|
15
|
+
export declare function uint8ArrayToHex(bytes: Uint8Array): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare function init(): Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* Performs IGE-256 encryption.
|
|
4
|
+
*
|
|
5
|
+
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
6
|
+
* @param key 32-byte encryption key
|
|
7
|
+
* @param iv 32-byte initialization vector
|
|
8
|
+
*/
|
|
9
|
+
export declare function ige256Encrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
10
|
+
/**
|
|
11
|
+
* Performs IGE-256 decryption.
|
|
12
|
+
*
|
|
13
|
+
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
14
|
+
* @param key 32-byte encryption key
|
|
15
|
+
* @param iv 32-byte initialization vector
|
|
16
|
+
*/
|
|
17
|
+
export declare function ige256Decrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
18
|
+
/**
|
|
19
|
+
* Performs CTR-256 encryption.
|
|
20
|
+
*
|
|
21
|
+
* @param data The data, larger than a byte
|
|
22
|
+
* @param key 32-byte encryption key
|
|
23
|
+
* @param iv 16-byte initialization vector
|
|
24
|
+
* @param state 1-byte state
|
|
25
|
+
*/
|
|
26
|
+
export declare function ctr256Encrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array, state: Uint8Array): [Uint8Array, Uint8Array, Uint8Array];
|
|
27
|
+
/**
|
|
28
|
+
* Alias of `ctr256Encrypt`
|
|
29
|
+
*/
|
|
30
|
+
export declare function ctr256Decrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array, state: Uint8Array): [Uint8Array, Uint8Array, Uint8Array];
|
|
31
|
+
/**
|
|
32
|
+
* Performs CBC-256 encryption.
|
|
33
|
+
*
|
|
34
|
+
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
35
|
+
* @param key 32-byte encryption key
|
|
36
|
+
* @param iv 16-byte initialization vector
|
|
37
|
+
*/
|
|
38
|
+
export declare function cbc256Encrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
39
|
+
/**
|
|
40
|
+
* Performs CBC-256 decryption.
|
|
41
|
+
*
|
|
42
|
+
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
43
|
+
* @param key 32-byte encryption key
|
|
44
|
+
* @param iv 16-byte initialization vector
|
|
45
|
+
*/
|
|
46
|
+
export declare function cbc256Decrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
47
|
+
export declare function factorize(pq: bigint): [bigint, bigint];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const DEFAULT_LEVEL = 6;
|
|
2
|
+
export declare function putLong(n: number, arr: number[]): void;
|
|
3
|
+
interface Options {
|
|
4
|
+
level?: number;
|
|
5
|
+
timestamp?: number;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function getHeader(options?: Options): Uint8Array;
|
|
9
|
+
export declare function gzip(bytes: Uint8Array, options?: Options): Uint8Array;
|
|
10
|
+
export declare function gunzip(bytes: Uint8Array): Uint8Array;
|
|
11
|
+
export declare function checkHeader(arr: number[]): void;
|
|
12
|
+
export declare function checkTail(arr: number[]): {
|
|
13
|
+
crc32: number;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function concatUint8Array(arr: Uint8Array[]): Uint8Array;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as zlibDeflate from "./zlib/deflate.js";
|
|
2
|
+
import ZStream from "./zlib/zstream.js";
|
|
3
|
+
import STATUS from "./zlib/status.js";
|
|
4
|
+
export interface DeflateOptions {
|
|
5
|
+
level?: number;
|
|
6
|
+
method?: number;
|
|
7
|
+
chunkSize?: number;
|
|
8
|
+
windowBits?: number;
|
|
9
|
+
memLevel?: number;
|
|
10
|
+
strategy?: number;
|
|
11
|
+
to?: string;
|
|
12
|
+
raw?: boolean;
|
|
13
|
+
gzip?: boolean;
|
|
14
|
+
dictionary?: Uint8Array;
|
|
15
|
+
header?: zlibDeflate.Header;
|
|
16
|
+
}
|
|
17
|
+
export declare class Deflate {
|
|
18
|
+
err: STATUS;
|
|
19
|
+
msg: string;
|
|
20
|
+
ended: boolean;
|
|
21
|
+
strm: ZStream;
|
|
22
|
+
_dict_set: boolean;
|
|
23
|
+
options: any;
|
|
24
|
+
constructor(options?: DeflateOptions);
|
|
25
|
+
push(data: Uint8Array, mode: boolean | number): Uint8Array;
|
|
26
|
+
}
|
|
27
|
+
export declare function deflate(input: Uint8Array, options?: DeflateOptions): Uint8Array;
|
|
28
|
+
export declare function deflateRaw(input: Uint8Array, options?: DeflateOptions): Uint8Array;
|
|
29
|
+
export declare function gzip(input: Uint8Array, options?: DeflateOptions): Uint8Array;
|
|
@@ -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 @@
|
|
|
1
|
+
export default function adler32(adler: 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 @@
|
|
|
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,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
|
+
}
|
package/script/deps.d.ts
ADDED
|
@@ -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";
|
package/script/mod.d.ts
ADDED
|
@@ -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";
|