@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
package/script/client/client.js
CHANGED
|
@@ -23,11 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Client = void 0;
|
|
26
|
+
exports.Client = exports.restartAuth = void 0;
|
|
27
27
|
const deps_js_1 = require("../deps.js");
|
|
28
28
|
const constants_js_1 = require("../constants.js");
|
|
29
29
|
const _0_bigint_js_1 = require("../utilities/0_bigint.js");
|
|
30
30
|
const _1_message_js_1 = require("../utilities/1_message.js");
|
|
31
|
+
const _1_password_js_1 = require("../utilities/1_password.js");
|
|
31
32
|
const types = __importStar(require("../tl/2_types.js"));
|
|
32
33
|
const functions = __importStar(require("../tl/3_functions.js"));
|
|
33
34
|
const _3_tl_reader_js_1 = require("../tl/3_tl_reader.js");
|
|
@@ -37,7 +38,16 @@ const _6_message_container_js_1 = require("../tl/6_message_container.js");
|
|
|
37
38
|
const client_abstract_js_1 = require("./client_abstract.js");
|
|
38
39
|
const client_plain_js_1 = require("./client_plain.js");
|
|
39
40
|
const session_memory_js_1 = require("../session/session_memory.js");
|
|
41
|
+
exports.restartAuth = Symbol();
|
|
40
42
|
class Client extends client_abstract_js_1.ClientAbstract {
|
|
43
|
+
/**
|
|
44
|
+
* Constructs the client.
|
|
45
|
+
*
|
|
46
|
+
* @param session The session provider to use. Defaults to in-memory session.
|
|
47
|
+
* @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
|
|
48
|
+
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Default to empty string (unset).
|
|
49
|
+
* @param params Other parameters.
|
|
50
|
+
*/
|
|
41
51
|
constructor(session = new session_memory_js_1.SessionMemory(), apiId = 0, apiHash = "", params) {
|
|
42
52
|
super(params?.transportProvider);
|
|
43
53
|
Object.defineProperty(this, "session", {
|
|
@@ -137,6 +147,12 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
137
147
|
this.systemLangCode = params?.systemLangCode ?? constants_js_1.DEFAULT_SYSTEM_LANG_CODE;
|
|
138
148
|
this.systemVersion = params?.systemVersion ?? constants_js_1.DEFAULT_SYSTEM_VERSION;
|
|
139
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Sets the DC and resets the auth key stored in the session provider
|
|
152
|
+
* if the stored DC was not the same as the `dc` parameter.
|
|
153
|
+
*
|
|
154
|
+
* @param dc The DC to change to.
|
|
155
|
+
*/
|
|
140
156
|
setDc(dc) {
|
|
141
157
|
if (this.session.dc != dc) {
|
|
142
158
|
this.session.dc = dc;
|
|
@@ -147,6 +163,11 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
147
163
|
}
|
|
148
164
|
super.setDc(dc);
|
|
149
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Loads the session if `setDc` was not called, initializes and connnects
|
|
168
|
+
* a `ClientPlain` to generate auth key if there was none, and connects the client.
|
|
169
|
+
* Before establishing the connection, the session is saved.
|
|
170
|
+
*/
|
|
150
171
|
async connect() {
|
|
151
172
|
if (this.shouldLoadSession) {
|
|
152
173
|
await this.session.load();
|
|
@@ -172,6 +193,23 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
172
193
|
this.receiveLoop();
|
|
173
194
|
this.pingLoop();
|
|
174
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
198
|
+
*
|
|
199
|
+
* - Bot token (`string`)
|
|
200
|
+
* - Exported authorization (`types.AuthExportedAuthorization`)
|
|
201
|
+
* - User authorization handlers (`AuthorizeUserParams`)
|
|
202
|
+
*
|
|
203
|
+
* if the current auth key doesn't throw AUTH_KEY_UNREGISTERED when calling [updates.getState](2).
|
|
204
|
+
*
|
|
205
|
+
* Notes:
|
|
206
|
+
* 1. Requires the `apiId` and `apiHash` paramters to be passed when constructing the client.
|
|
207
|
+
* 2. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
|
|
208
|
+
* 3. The parameters passed to the [initConnection][1] call can be configured with the last parameter of the constructor.
|
|
209
|
+
*
|
|
210
|
+
* [1]: https://core.telegram.org/method/initConnection
|
|
211
|
+
* [2]: https://core.telegram.org/method/updates.getState
|
|
212
|
+
*/
|
|
175
213
|
async authorize(params) {
|
|
176
214
|
if (!this.apiId) {
|
|
177
215
|
throw new Error("apiId not set");
|
|
@@ -201,12 +239,92 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
201
239
|
throw err;
|
|
202
240
|
}
|
|
203
241
|
}
|
|
242
|
+
let signedIn = false;
|
|
243
|
+
let phoneNumber = null;
|
|
204
244
|
try {
|
|
205
245
|
if (params instanceof types.AuthExportedAuthorization) {
|
|
206
246
|
await this.invoke(new functions.AuthImportAuthorization({ id: params.id, bytes: params.bytes }));
|
|
207
247
|
}
|
|
208
248
|
else if (typeof params == "object") {
|
|
209
|
-
|
|
249
|
+
while (true) {
|
|
250
|
+
if (signedIn) {
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
try {
|
|
255
|
+
phoneNumber = typeof params.phone === "string" ? params.phone : await params.phone();
|
|
256
|
+
const sentCode = await this.invoke(new functions.AuthSendCode({
|
|
257
|
+
apiId: this.apiId,
|
|
258
|
+
apiHash: this.apiHash,
|
|
259
|
+
phoneNumber,
|
|
260
|
+
settings: new types.CodeSettings(),
|
|
261
|
+
}));
|
|
262
|
+
if (sentCode instanceof types.AuthSentCode) {
|
|
263
|
+
while (true) {
|
|
264
|
+
const phoneCode = typeof params.code === "string" ? params.code : await params.code();
|
|
265
|
+
try {
|
|
266
|
+
const auth = await this.invoke(new functions.AuthSignIn({ phoneNumber, phoneCode, phoneCodeHash: sentCode.phoneCodeHash }));
|
|
267
|
+
if (auth instanceof types.AuthAuthorizationSignUpRequired) {
|
|
268
|
+
throw new Error("Sign up not supported");
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
signedIn = true;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
if (err instanceof types.RPCError && err.errorMessage == "PHONE_CODE_INVALID") {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
throw err;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
throw new Error(`Handling ${sentCode.constructor.name} not implemented`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (err) {
|
|
290
|
+
if (err instanceof types.RPCError && err.errorMessage == "SESSION_PASSWORD_NEEDED") {
|
|
291
|
+
while (true) {
|
|
292
|
+
const ap = await this.invoke(new functions.AccountGetPassword());
|
|
293
|
+
if (ap.currentAlgo instanceof types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) {
|
|
294
|
+
try {
|
|
295
|
+
const password = typeof params.password === "string" ? params.password : await params.password();
|
|
296
|
+
const input = await (0, _1_password_js_1.checkPassword)(password, ap);
|
|
297
|
+
await this.invoke(new functions.AuthCheckPassword({ password: input }));
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
catch (err) {
|
|
301
|
+
if (err instanceof types.RPCError && err.errorMessage == "PASSWORD_HASH_INVALID") {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
throw err;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
throw new Error(`Handling ${ap.currentAlgo?.constructor.name} not implemented`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
throw err;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
catch (err) {
|
|
320
|
+
if (err == exports.restartAuth) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
throw err;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
210
328
|
}
|
|
211
329
|
else {
|
|
212
330
|
await this.invoke(new functions.AuthImportBotAuthorization({ apiId: this.apiId, apiHash: this.apiHash, botAuthToken: params, flags: 0 }));
|
|
@@ -221,6 +339,10 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
221
339
|
newDc += "-test";
|
|
222
340
|
}
|
|
223
341
|
await this.reconnect(newDc);
|
|
342
|
+
if (typeof params === "object" && phoneNumber != null) {
|
|
343
|
+
params = Object.assign({}, params);
|
|
344
|
+
params.phone = phoneNumber;
|
|
345
|
+
}
|
|
224
346
|
await this.authorize(params);
|
|
225
347
|
}
|
|
226
348
|
else {
|
|
@@ -344,6 +466,9 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
344
466
|
return result;
|
|
345
467
|
}
|
|
346
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Alias for `invoke` with its second parameter being `true`.
|
|
471
|
+
*/
|
|
347
472
|
send(function_) {
|
|
348
473
|
return this.invoke(function_, true);
|
|
349
474
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Connection } from "../connection/connection.js";
|
|
2
|
+
import { Transport } from "../transport/transport.js";
|
|
3
|
+
import { DC } from "../transport/transport_provider.js";
|
|
4
|
+
export declare abstract class ClientAbstract {
|
|
5
|
+
protected transportProvider: import("../transport/transport_provider.js").TransportProvider;
|
|
6
|
+
protected connection: Connection;
|
|
7
|
+
protected transport: Transport;
|
|
8
|
+
private _dcId;
|
|
9
|
+
protected connected: boolean;
|
|
10
|
+
constructor(transportProvider?: import("../transport/transport_provider.js").TransportProvider);
|
|
11
|
+
get dcId(): number;
|
|
12
|
+
setDc(dc: DC): void;
|
|
13
|
+
connect(): Promise<void>;
|
|
14
|
+
reconnect(dc?: DC): Promise<void>;
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Function } from "../tl/3_functions.js";
|
|
2
|
+
import { ClientAbstract } from "./client_abstract.js";
|
|
3
|
+
export declare class ClientPlain extends ClientAbstract {
|
|
4
|
+
invoke<T extends Function<unknown>>(function_: T): Promise<T["__R"]>;
|
|
5
|
+
createAuthKey(): Promise<{
|
|
6
|
+
authKey: Uint8Array;
|
|
7
|
+
salt: bigint;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MaybePromise } from "../types.js";
|
|
2
|
+
export declare abstract class Connection {
|
|
3
|
+
abstract open(): MaybePromise<void>;
|
|
4
|
+
abstract read(p: Uint8Array): MaybePromise<void>;
|
|
5
|
+
abstract write(p: Uint8Array): MaybePromise<void>;
|
|
6
|
+
abstract close(): MaybePromise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Connection } from "./connection.js";
|
|
2
|
+
export declare class ConnectionWebSocket implements Connection {
|
|
3
|
+
private webSocket;
|
|
4
|
+
private rMutex;
|
|
5
|
+
private wMutex;
|
|
6
|
+
private buffer;
|
|
7
|
+
private nextResolve;
|
|
8
|
+
constructor(url: string | URL);
|
|
9
|
+
open(): Promise<void>;
|
|
10
|
+
read(p: Uint8Array): Promise<void>;
|
|
11
|
+
write(p: Uint8Array): Promise<void>;
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DC } from "./transport/transport_provider.js";
|
|
2
|
+
export declare const ackThreshold = 10;
|
|
3
|
+
export declare const publicKeys: Map<bigint, [bigint, bigint]>;
|
|
4
|
+
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
5
|
+
export declare const DEFAULT_INITIAL_DC: DC;
|
|
6
|
+
export declare const LAYER = 158;
|
|
7
|
+
export declare const DEFAULT_APP_VERSION = "MTKruto Unstable <v1.0.0";
|
|
8
|
+
export declare const DEFAULT_DEVICE_MODEL = "Krutaya Device";
|
|
9
|
+
export declare const DEFAULT_LANG_CODE = "en";
|
|
10
|
+
export declare const DEFAULT_LANG_PACK = "";
|
|
11
|
+
export declare const DEFAULT_SYSTEM_LANG_CODE = "en";
|
|
12
|
+
export declare const DEFAULT_SYSTEM_VERSION = "1.0";
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */
|
|
2
|
+
interface Rgb {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Set changing text color to enabled or disabled
|
|
9
|
+
* @param value
|
|
10
|
+
*/
|
|
11
|
+
export declare function setColorEnabled(value: boolean): void;
|
|
12
|
+
/** Get whether text color change is enabled or disabled. */
|
|
13
|
+
export declare function getColorEnabled(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Reset the text modified
|
|
16
|
+
* @param str text to reset
|
|
17
|
+
*/
|
|
18
|
+
export declare function reset(str: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Make the text bold.
|
|
21
|
+
* @param str text to make bold
|
|
22
|
+
*/
|
|
23
|
+
export declare function bold(str: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* The text emits only a small amount of light.
|
|
26
|
+
* @param str text to dim
|
|
27
|
+
*/
|
|
28
|
+
export declare function dim(str: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Make the text italic.
|
|
31
|
+
* @param str text to make italic
|
|
32
|
+
*/
|
|
33
|
+
export declare function italic(str: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Make the text underline.
|
|
36
|
+
* @param str text to underline
|
|
37
|
+
*/
|
|
38
|
+
export declare function underline(str: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Invert background color and text color.
|
|
41
|
+
* @param str text to invert its color
|
|
42
|
+
*/
|
|
43
|
+
export declare function inverse(str: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Make the text hidden.
|
|
46
|
+
* @param str text to hide
|
|
47
|
+
*/
|
|
48
|
+
export declare function hidden(str: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Put horizontal line through the center of the text.
|
|
51
|
+
* @param str text to strike through
|
|
52
|
+
*/
|
|
53
|
+
export declare function strikethrough(str: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Set text color to black.
|
|
56
|
+
* @param str text to make black
|
|
57
|
+
*/
|
|
58
|
+
export declare function black(str: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Set text color to red.
|
|
61
|
+
* @param str text to make red
|
|
62
|
+
*/
|
|
63
|
+
export declare function red(str: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Set text color to green.
|
|
66
|
+
* @param str text to make green
|
|
67
|
+
*/
|
|
68
|
+
export declare function green(str: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Set text color to yellow.
|
|
71
|
+
* @param str text to make yellow
|
|
72
|
+
*/
|
|
73
|
+
export declare function yellow(str: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* Set text color to blue.
|
|
76
|
+
* @param str text to make blue
|
|
77
|
+
*/
|
|
78
|
+
export declare function blue(str: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Set text color to magenta.
|
|
81
|
+
* @param str text to make magenta
|
|
82
|
+
*/
|
|
83
|
+
export declare function magenta(str: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Set text color to cyan.
|
|
86
|
+
* @param str text to make cyan
|
|
87
|
+
*/
|
|
88
|
+
export declare function cyan(str: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Set text color to white.
|
|
91
|
+
* @param str text to make white
|
|
92
|
+
*/
|
|
93
|
+
export declare function white(str: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Set text color to gray.
|
|
96
|
+
* @param str text to make gray
|
|
97
|
+
*/
|
|
98
|
+
export declare function gray(str: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Set text color to bright black.
|
|
101
|
+
* @param str text to make bright-black
|
|
102
|
+
*/
|
|
103
|
+
export declare function brightBlack(str: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Set text color to bright red.
|
|
106
|
+
* @param str text to make bright-red
|
|
107
|
+
*/
|
|
108
|
+
export declare function brightRed(str: string): string;
|
|
109
|
+
/**
|
|
110
|
+
* Set text color to bright green.
|
|
111
|
+
* @param str text to make bright-green
|
|
112
|
+
*/
|
|
113
|
+
export declare function brightGreen(str: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Set text color to bright yellow.
|
|
116
|
+
* @param str text to make bright-yellow
|
|
117
|
+
*/
|
|
118
|
+
export declare function brightYellow(str: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Set text color to bright blue.
|
|
121
|
+
* @param str text to make bright-blue
|
|
122
|
+
*/
|
|
123
|
+
export declare function brightBlue(str: string): string;
|
|
124
|
+
/**
|
|
125
|
+
* Set text color to bright magenta.
|
|
126
|
+
* @param str text to make bright-magenta
|
|
127
|
+
*/
|
|
128
|
+
export declare function brightMagenta(str: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Set text color to bright cyan.
|
|
131
|
+
* @param str text to make bright-cyan
|
|
132
|
+
*/
|
|
133
|
+
export declare function brightCyan(str: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* Set text color to bright white.
|
|
136
|
+
* @param str text to make bright-white
|
|
137
|
+
*/
|
|
138
|
+
export declare function brightWhite(str: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Set background color to black.
|
|
141
|
+
* @param str text to make its background black
|
|
142
|
+
*/
|
|
143
|
+
export declare function bgBlack(str: string): string;
|
|
144
|
+
/**
|
|
145
|
+
* Set background color to red.
|
|
146
|
+
* @param str text to make its background red
|
|
147
|
+
*/
|
|
148
|
+
export declare function bgRed(str: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Set background color to green.
|
|
151
|
+
* @param str text to make its background green
|
|
152
|
+
*/
|
|
153
|
+
export declare function bgGreen(str: string): string;
|
|
154
|
+
/**
|
|
155
|
+
* Set background color to yellow.
|
|
156
|
+
* @param str text to make its background yellow
|
|
157
|
+
*/
|
|
158
|
+
export declare function bgYellow(str: string): string;
|
|
159
|
+
/**
|
|
160
|
+
* Set background color to blue.
|
|
161
|
+
* @param str text to make its background blue
|
|
162
|
+
*/
|
|
163
|
+
export declare function bgBlue(str: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* Set background color to magenta.
|
|
166
|
+
* @param str text to make its background magenta
|
|
167
|
+
*/
|
|
168
|
+
export declare function bgMagenta(str: string): string;
|
|
169
|
+
/**
|
|
170
|
+
* Set background color to cyan.
|
|
171
|
+
* @param str text to make its background cyan
|
|
172
|
+
*/
|
|
173
|
+
export declare function bgCyan(str: string): string;
|
|
174
|
+
/**
|
|
175
|
+
* Set background color to white.
|
|
176
|
+
* @param str text to make its background white
|
|
177
|
+
*/
|
|
178
|
+
export declare function bgWhite(str: string): string;
|
|
179
|
+
/**
|
|
180
|
+
* Set background color to bright black.
|
|
181
|
+
* @param str text to make its background bright-black
|
|
182
|
+
*/
|
|
183
|
+
export declare function bgBrightBlack(str: string): string;
|
|
184
|
+
/**
|
|
185
|
+
* Set background color to bright red.
|
|
186
|
+
* @param str text to make its background bright-red
|
|
187
|
+
*/
|
|
188
|
+
export declare function bgBrightRed(str: string): string;
|
|
189
|
+
/**
|
|
190
|
+
* Set background color to bright green.
|
|
191
|
+
* @param str text to make its background bright-green
|
|
192
|
+
*/
|
|
193
|
+
export declare function bgBrightGreen(str: string): string;
|
|
194
|
+
/**
|
|
195
|
+
* Set background color to bright yellow.
|
|
196
|
+
* @param str text to make its background bright-yellow
|
|
197
|
+
*/
|
|
198
|
+
export declare function bgBrightYellow(str: string): string;
|
|
199
|
+
/**
|
|
200
|
+
* Set background color to bright blue.
|
|
201
|
+
* @param str text to make its background bright-blue
|
|
202
|
+
*/
|
|
203
|
+
export declare function bgBrightBlue(str: string): string;
|
|
204
|
+
/**
|
|
205
|
+
* Set background color to bright magenta.
|
|
206
|
+
* @param str text to make its background bright-magenta
|
|
207
|
+
*/
|
|
208
|
+
export declare function bgBrightMagenta(str: string): string;
|
|
209
|
+
/**
|
|
210
|
+
* Set background color to bright cyan.
|
|
211
|
+
* @param str text to make its background bright-cyan
|
|
212
|
+
*/
|
|
213
|
+
export declare function bgBrightCyan(str: string): string;
|
|
214
|
+
/**
|
|
215
|
+
* Set background color to bright white.
|
|
216
|
+
* @param str text to make its background bright-white
|
|
217
|
+
*/
|
|
218
|
+
export declare function bgBrightWhite(str: string): string;
|
|
219
|
+
/**
|
|
220
|
+
* Set text color using paletted 8bit colors.
|
|
221
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
222
|
+
* @param str text color to apply paletted 8bit colors to
|
|
223
|
+
* @param color code
|
|
224
|
+
*/
|
|
225
|
+
export declare function rgb8(str: string, color: number): string;
|
|
226
|
+
/**
|
|
227
|
+
* Set background color using paletted 8bit colors.
|
|
228
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
|
229
|
+
* @param str text color to apply paletted 8bit background colors to
|
|
230
|
+
* @param color code
|
|
231
|
+
*/
|
|
232
|
+
export declare function bgRgb8(str: string, color: number): string;
|
|
233
|
+
/**
|
|
234
|
+
* Set text color using 24bit rgb.
|
|
235
|
+
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
236
|
+
* an `Rgb`.
|
|
237
|
+
*
|
|
238
|
+
* To produce the color magenta:
|
|
239
|
+
*
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { rgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
|
242
|
+
* rgb24("foo", 0xff00ff);
|
|
243
|
+
* rgb24("foo", {r: 255, g: 0, b: 255});
|
|
244
|
+
* ```
|
|
245
|
+
* @param str text color to apply 24bit rgb to
|
|
246
|
+
* @param color code
|
|
247
|
+
*/
|
|
248
|
+
export declare function rgb24(str: string, color: number | Rgb): string;
|
|
249
|
+
/**
|
|
250
|
+
* Set background color using 24bit rgb.
|
|
251
|
+
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
252
|
+
* an `Rgb`.
|
|
253
|
+
*
|
|
254
|
+
* To produce the color magenta:
|
|
255
|
+
*
|
|
256
|
+
* ```ts
|
|
257
|
+
* import { bgRgb24 } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
|
258
|
+
* bgRgb24("foo", 0xff00ff);
|
|
259
|
+
* bgRgb24("foo", {r: 255, g: 0, b: 255});
|
|
260
|
+
* ```
|
|
261
|
+
* @param str text color to apply 24bit rgb to
|
|
262
|
+
* @param color code
|
|
263
|
+
*/
|
|
264
|
+
export declare function bgRgb24(str: string, color: number | Rgb): string;
|
|
265
|
+
/**
|
|
266
|
+
* Remove ANSI escape codes from the string.
|
|
267
|
+
* @param string to remove ANSI escape codes from
|
|
268
|
+
*/
|
|
269
|
+
export declare function stripColor(string: string): string;
|
|
270
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare enum DiffType {
|
|
2
|
+
removed = "removed",
|
|
3
|
+
common = "common",
|
|
4
|
+
added = "added"
|
|
5
|
+
}
|
|
6
|
+
export interface DiffResult<T> {
|
|
7
|
+
type: DiffType;
|
|
8
|
+
value: T;
|
|
9
|
+
details?: Array<DiffResult<T>>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Renders the differences between the actual and expected values
|
|
13
|
+
* @param A Actual value
|
|
14
|
+
* @param B Expected value
|
|
15
|
+
*/
|
|
16
|
+
export declare function diff<T>(A: T[], B: T[]): Array<DiffResult<T>>;
|
|
17
|
+
/**
|
|
18
|
+
* Renders the differences between the actual and expected strings
|
|
19
|
+
* Partially inspired from https://github.com/kpdecker/jsdiff
|
|
20
|
+
* @param A Actual string
|
|
21
|
+
* @param B Expected string
|
|
22
|
+
*/
|
|
23
|
+
export declare function diffstr(A: string, B: string): DiffResult<string>[];
|
|
24
|
+
export declare function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>, { stringDiff }?: {
|
|
25
|
+
stringDiff?: boolean | undefined;
|
|
26
|
+
}): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function format(v: unknown): string;
|