@mtkruto/node 0.0.950 → 0.0.952
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/client/3_client.d.ts +2 -0
- package/esm/client/3_client.js +19 -7
- package/esm/constants.d.ts +1 -1
- package/esm/constants.js +1 -1
- package/package.json +1 -1
- package/script/client/3_client.d.ts +2 -0
- package/script/client/3_client.js +20 -8
- package/script/constants.d.ts +1 -1
- package/script/constants.js +1 -1
package/esm/client/3_client.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { Message } from "../types/3_message.js";
|
|
|
13
13
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
14
14
|
export declare const getEntity: unique symbol;
|
|
15
15
|
export declare const getStickerSetName: unique symbol;
|
|
16
|
+
export declare const handleMigrationError: unique symbol;
|
|
16
17
|
export declare const restartAuth: unique symbol;
|
|
17
18
|
export declare enum ParseMode {
|
|
18
19
|
None = "none",
|
|
@@ -101,6 +102,7 @@ export declare class Client extends ClientAbstract {
|
|
|
101
102
|
*/
|
|
102
103
|
connect(): Promise<void>;
|
|
103
104
|
private fetchState;
|
|
105
|
+
[handleMigrationError](err: types.RPCError): Promise<void>;
|
|
104
106
|
/**
|
|
105
107
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
106
108
|
*
|
package/esm/client/3_client.js
CHANGED
|
@@ -31,6 +31,7 @@ const dRecv = debug("Client/receiveLoop");
|
|
|
31
31
|
const UPDATE_GAP = Symbol();
|
|
32
32
|
export const getEntity = Symbol();
|
|
33
33
|
export const getStickerSetName = Symbol();
|
|
34
|
+
export const handleMigrationError = Symbol();
|
|
34
35
|
export const restartAuth = Symbol();
|
|
35
36
|
export var ParseMode;
|
|
36
37
|
(function (ParseMode) {
|
|
@@ -249,6 +250,20 @@ export class Client extends ClientAbstract {
|
|
|
249
250
|
this.updateState = state;
|
|
250
251
|
d("state fetched [%s]", source);
|
|
251
252
|
}
|
|
253
|
+
async [handleMigrationError](err) {
|
|
254
|
+
const match = err.errorMessage.match(/MIGRATE_(\d)$/);
|
|
255
|
+
if (match) {
|
|
256
|
+
let newDc = match[1];
|
|
257
|
+
if (Math.abs(this.dcId) >= 10000) {
|
|
258
|
+
newDc += "-test";
|
|
259
|
+
}
|
|
260
|
+
await this.reconnect(newDc);
|
|
261
|
+
d("migrated to DC%s", newDc);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
UNREACHABLE();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
252
267
|
/**
|
|
253
268
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
254
269
|
*
|
|
@@ -405,12 +420,7 @@ export class Client extends ClientAbstract {
|
|
|
405
420
|
if (err instanceof types.RPCError) {
|
|
406
421
|
const match = err.errorMessage.match(/MIGRATE_(\d)$/);
|
|
407
422
|
if (match) {
|
|
408
|
-
|
|
409
|
-
if (Math.abs(this.dcId) >= 10000) {
|
|
410
|
-
newDc += "-test";
|
|
411
|
-
}
|
|
412
|
-
await this.reconnect(newDc);
|
|
413
|
-
d("migrated to DC%s", newDc);
|
|
423
|
+
await this[handleMigrationError](err);
|
|
414
424
|
if (typeof params === "object" && phoneNumber != null) {
|
|
415
425
|
params = Object.assign({}, params);
|
|
416
426
|
params.phone = phoneNumber;
|
|
@@ -548,8 +558,9 @@ export class Client extends ClientAbstract {
|
|
|
548
558
|
}
|
|
549
559
|
const message = new Message_(getMessageId(), seqNo, function_);
|
|
550
560
|
await this.transport.send(await encryptMessage(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
551
|
-
d("invoked %s", function_.constructor.name);
|
|
561
|
+
const d_ = () => d("invoked %s", function_.constructor.name);
|
|
552
562
|
if (noWait) {
|
|
563
|
+
d_();
|
|
553
564
|
return;
|
|
554
565
|
}
|
|
555
566
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -559,6 +570,7 @@ export class Client extends ClientAbstract {
|
|
|
559
570
|
return await this.invoke(function_);
|
|
560
571
|
}
|
|
561
572
|
else {
|
|
573
|
+
d_();
|
|
562
574
|
return result;
|
|
563
575
|
}
|
|
564
576
|
}
|
package/esm/constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
|
|
|
4
4
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
5
5
|
export declare const DEFAULT_INITIAL_DC: DC;
|
|
6
6
|
export declare const LAYER = 158;
|
|
7
|
-
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
7
|
+
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.952";
|
|
8
8
|
export declare const DEFAULT_DEVICE_MODEL: string;
|
|
9
9
|
export declare const DEFAULT_LANG_CODE: string;
|
|
10
10
|
export declare const DEFAULT_LANG_PACK = "";
|
package/esm/constants.js
CHANGED
|
@@ -62,7 +62,7 @@ export const publicKeys = new Map([
|
|
|
62
62
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
63
63
|
export const DEFAULT_INITIAL_DC = "2-test";
|
|
64
64
|
export const LAYER = 158;
|
|
65
|
-
export const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
65
|
+
export const DEFAULT_APP_VERSION = "MTKruto 0.0.952";
|
|
66
66
|
// @ts-ignore: lib
|
|
67
67
|
export const DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
68
68
|
export const DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import { Message } from "../types/3_message.js";
|
|
|
13
13
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
14
14
|
export declare const getEntity: unique symbol;
|
|
15
15
|
export declare const getStickerSetName: unique symbol;
|
|
16
|
+
export declare const handleMigrationError: unique symbol;
|
|
16
17
|
export declare const restartAuth: unique symbol;
|
|
17
18
|
export declare enum ParseMode {
|
|
18
19
|
None = "none",
|
|
@@ -101,6 +102,7 @@ export declare class Client extends ClientAbstract {
|
|
|
101
102
|
*/
|
|
102
103
|
connect(): Promise<void>;
|
|
103
104
|
private fetchState;
|
|
105
|
+
[handleMigrationError](err: types.RPCError): Promise<void>;
|
|
104
106
|
/**
|
|
105
107
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
106
108
|
*
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Client = exports.ParseMode = exports.restartAuth = exports.getStickerSetName = exports.getEntity = void 0;
|
|
26
|
+
exports.Client = exports.ParseMode = exports.restartAuth = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = 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");
|
|
@@ -57,6 +57,7 @@ const dRecv = (0, deps_js_1.debug)("Client/receiveLoop");
|
|
|
57
57
|
const UPDATE_GAP = Symbol();
|
|
58
58
|
exports.getEntity = Symbol();
|
|
59
59
|
exports.getStickerSetName = Symbol();
|
|
60
|
+
exports.handleMigrationError = Symbol();
|
|
60
61
|
exports.restartAuth = Symbol();
|
|
61
62
|
var ParseMode;
|
|
62
63
|
(function (ParseMode) {
|
|
@@ -275,6 +276,20 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
275
276
|
this.updateState = state;
|
|
276
277
|
d("state fetched [%s]", source);
|
|
277
278
|
}
|
|
279
|
+
async [exports.handleMigrationError](err) {
|
|
280
|
+
const match = err.errorMessage.match(/MIGRATE_(\d)$/);
|
|
281
|
+
if (match) {
|
|
282
|
+
let newDc = match[1];
|
|
283
|
+
if (Math.abs(this.dcId) >= 10000) {
|
|
284
|
+
newDc += "-test";
|
|
285
|
+
}
|
|
286
|
+
await this.reconnect(newDc);
|
|
287
|
+
d("migrated to DC%s", newDc);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
(0, _0_control_js_1.UNREACHABLE)();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
278
293
|
/**
|
|
279
294
|
* Calls [initConnection](1) and authorizes the client with one of the following:
|
|
280
295
|
*
|
|
@@ -431,12 +446,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
431
446
|
if (err instanceof types.RPCError) {
|
|
432
447
|
const match = err.errorMessage.match(/MIGRATE_(\d)$/);
|
|
433
448
|
if (match) {
|
|
434
|
-
|
|
435
|
-
if (Math.abs(this.dcId) >= 10000) {
|
|
436
|
-
newDc += "-test";
|
|
437
|
-
}
|
|
438
|
-
await this.reconnect(newDc);
|
|
439
|
-
d("migrated to DC%s", newDc);
|
|
449
|
+
await this[exports.handleMigrationError](err);
|
|
440
450
|
if (typeof params === "object" && phoneNumber != null) {
|
|
441
451
|
params = Object.assign({}, params);
|
|
442
452
|
params.phone = phoneNumber;
|
|
@@ -574,8 +584,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
574
584
|
}
|
|
575
585
|
const message = new _6_message_js_1.Message((0, _0_message_js_1.getMessageId)(), seqNo, function_);
|
|
576
586
|
await this.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
577
|
-
d("invoked %s", function_.constructor.name);
|
|
587
|
+
const d_ = () => d("invoked %s", function_.constructor.name);
|
|
578
588
|
if (noWait) {
|
|
589
|
+
d_();
|
|
579
590
|
return;
|
|
580
591
|
}
|
|
581
592
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -585,6 +596,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
585
596
|
return await this.invoke(function_);
|
|
586
597
|
}
|
|
587
598
|
else {
|
|
599
|
+
d_();
|
|
588
600
|
return result;
|
|
589
601
|
}
|
|
590
602
|
}
|
package/script/constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
|
|
|
4
4
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
5
5
|
export declare const DEFAULT_INITIAL_DC: DC;
|
|
6
6
|
export declare const LAYER = 158;
|
|
7
|
-
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
7
|
+
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.952";
|
|
8
8
|
export declare const DEFAULT_DEVICE_MODEL: string;
|
|
9
9
|
export declare const DEFAULT_LANG_CODE: string;
|
|
10
10
|
export declare const DEFAULT_LANG_PACK = "";
|
package/script/constants.js
CHANGED
|
@@ -88,7 +88,7 @@ exports.publicKeys = new Map([
|
|
|
88
88
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
89
89
|
exports.DEFAULT_INITIAL_DC = "2-test";
|
|
90
90
|
exports.LAYER = 158;
|
|
91
|
-
exports.DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
91
|
+
exports.DEFAULT_APP_VERSION = "MTKruto 0.0.952";
|
|
92
92
|
// @ts-ignore: lib
|
|
93
93
|
exports.DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
94
94
|
exports.DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|