@mtkruto/node 0.1.110 → 0.1.112
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/3_transport.d.ts +1 -0
- package/esm/3_transport.js +1 -0
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/1_client_abstract.js +2 -2
- package/esm/client/4_client.js +15 -5
- package/esm/mod.d.ts +2 -6
- package/esm/mod.js +2 -3
- package/esm/transport/2_transport_provider.d.ts +2 -3
- package/esm/transport/2_transport_provider.js +52 -24
- package/esm/transport/3_transport_provider_web_socket.d.ts +4 -0
- package/esm/transport/3_transport_provider_web_socket.js +24 -0
- package/package.json +1 -1
- package/script/3_transport.d.ts +1 -0
- package/script/3_transport.js +1 -0
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/1_client_abstract.js +1 -1
- package/script/client/4_client.js +15 -5
- package/script/mod.d.ts +2 -6
- package/script/mod.js +5 -4
- package/script/transport/2_transport_provider.d.ts +2 -3
- package/script/transport/2_transport_provider.js +54 -25
- package/script/transport/3_transport_provider_web_socket.d.ts +4 -0
- package/script/transport/3_transport_provider_web_socket.js +28 -0
package/esm/3_transport.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export * from "./transport/0_transport.js";
|
|
|
2
2
|
export * from "./transport/1_transport_abridged.js";
|
|
3
3
|
export * from "./transport/1_transport_intermediate.js";
|
|
4
4
|
export * from "./transport/2_transport_provider.js";
|
|
5
|
+
export * from "./transport/3_transport_provider_web_socket.js";
|
package/esm/3_transport.js
CHANGED
|
@@ -2,3 +2,4 @@ export * from "./transport/0_transport.js";
|
|
|
2
2
|
export * from "./transport/1_transport_abridged.js";
|
|
3
3
|
export * from "./transport/1_transport_intermediate.js";
|
|
4
4
|
export * from "./transport/2_transport_provider.js";
|
|
5
|
+
export * from "./transport/3_transport_provider_web_socket.js";
|
package/esm/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 166;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.112";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/esm/4_constants.js
CHANGED
|
@@ -54,7 +54,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
54
54
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
55
55
|
export const INITIAL_DC = "2";
|
|
56
56
|
export const LAYER = 166;
|
|
57
|
-
export const APP_VERSION = "MTKruto 0.1.
|
|
57
|
+
export const APP_VERSION = "MTKruto 0.1.112";
|
|
58
58
|
// @ts-ignore: lib
|
|
59
59
|
export const 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;
|
|
60
60
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _ClientAbstract_dc;
|
|
13
13
|
import { initTgCrypto } from "../0_deps.js";
|
|
14
|
-
import {
|
|
14
|
+
import { transportProviderWebSocket } from "../3_transport.js";
|
|
15
15
|
import { INITIAL_DC } from "../4_constants.js";
|
|
16
16
|
export class ClientAbstract {
|
|
17
17
|
constructor(params) {
|
|
@@ -47,7 +47,7 @@ export class ClientAbstract {
|
|
|
47
47
|
value: void 0
|
|
48
48
|
});
|
|
49
49
|
this.initialDc = params?.initialDc ?? INITIAL_DC;
|
|
50
|
-
this.transportProvider = params?.transportProvider ??
|
|
50
|
+
this.transportProvider = params?.transportProvider ?? transportProviderWebSocket();
|
|
51
51
|
this.cdn = params?.cdn ?? false;
|
|
52
52
|
}
|
|
53
53
|
get dcId() {
|
package/esm/client/4_client.js
CHANGED
|
@@ -237,7 +237,9 @@ export class Client extends ClientAbstract {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_errorHandler = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_lastOutgoing = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
240
|
-
|
|
240
|
+
__classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
|
|
241
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, { connectionState }, resolve);
|
|
242
|
+
});
|
|
241
243
|
}, _Client_setAuth = async function _Client_setAuth(key) {
|
|
242
244
|
const hash = await sha1(key);
|
|
243
245
|
const id = bigIntFromBuffer(hash.slice(-8), true, false);
|
|
@@ -1194,6 +1196,9 @@ export class Client extends ClientAbstract {
|
|
|
1194
1196
|
const messages = new Array();
|
|
1195
1197
|
if (updates instanceof types.Updates) {
|
|
1196
1198
|
for (const update of updates.updates) {
|
|
1199
|
+
if ("message" in update && update.message instanceof types.MessageEmpty) {
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1197
1202
|
if (update instanceof types.UpdateNewMessage || update instanceof types.UpdateEditMessage) {
|
|
1198
1203
|
messages.push(await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1199
1204
|
}
|
|
@@ -1265,6 +1270,9 @@ export class Client extends ClientAbstract {
|
|
|
1265
1270
|
}
|
|
1266
1271
|
const messages = new Array();
|
|
1267
1272
|
for (const message_ of messages_) {
|
|
1273
|
+
if (message_ instanceof types.MessageEmpty) {
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1268
1276
|
const message = await constructMessage(message_, this[getEntity].bind(this), null, this[getStickerSetName].bind(this));
|
|
1269
1277
|
const isReplyToMessage = message_ instanceof types.Message && message_.replyTo instanceof types.MessageReplyHeader;
|
|
1270
1278
|
messages.push({ message, isReplyToMessage });
|
|
@@ -1835,8 +1843,10 @@ async function _Client_handleUpdate(update) {
|
|
|
1835
1843
|
update instanceof types.UpdateEditMessage ||
|
|
1836
1844
|
update instanceof types.UpdateEditChannelMessage) {
|
|
1837
1845
|
const key = update instanceof types.UpdateNewMessage || update instanceof types.UpdateNewChannelMessage ? "message" : "editedMessage";
|
|
1838
|
-
|
|
1839
|
-
|
|
1846
|
+
if (!(update.message instanceof types.MessageEmpty)) {
|
|
1847
|
+
const message = await constructMessage(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
|
|
1848
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, { [key]: message }, resolve);
|
|
1849
|
+
}
|
|
1840
1850
|
}
|
|
1841
1851
|
if (update instanceof types.UpdateDeleteMessages) {
|
|
1842
1852
|
const deletedMessages = new Array();
|
|
@@ -1844,7 +1854,7 @@ async function _Client_handleUpdate(update) {
|
|
|
1844
1854
|
const chatId = await this.storage.getMessageChat(messageId);
|
|
1845
1855
|
if (chatId) {
|
|
1846
1856
|
const message = await this.storage.getMessage(chatId, messageId);
|
|
1847
|
-
if (message != null) {
|
|
1857
|
+
if (message != null && !(message instanceof types.MessageEmpty)) {
|
|
1848
1858
|
deletedMessages.push(await constructMessage(message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1849
1859
|
}
|
|
1850
1860
|
await this.storage.setMessage(chatId, messageId, null);
|
|
@@ -1859,7 +1869,7 @@ async function _Client_handleUpdate(update) {
|
|
|
1859
1869
|
const deletedMessages = new Array();
|
|
1860
1870
|
for (const messageId of update.messages) {
|
|
1861
1871
|
const message = await this.storage.getMessage(chatId, messageId);
|
|
1862
|
-
if (message) {
|
|
1872
|
+
if (message != null && !(message instanceof types.MessageEmpty)) {
|
|
1863
1873
|
deletedMessages.push(await constructMessage(message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1864
1874
|
}
|
|
1865
1875
|
await this.storage.setMessage(chatId, messageId, null);
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const utils: {
|
|
4
|
-
checkPassword: typeof checkPassword;
|
|
5
|
-
getRandomId: typeof getRandomId;
|
|
6
|
-
};
|
|
1
|
+
export { getRandomId } from "./1_utilities.js";
|
|
2
|
+
export { checkPassword } from "./client/0_password.js";
|
|
7
3
|
export * from "./2_connection.js";
|
|
8
4
|
export * from "./3_storage.js";
|
|
9
5
|
export * from "./3_transport.js";
|
package/esm/mod.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const utils = { checkPassword, getRandomId };
|
|
1
|
+
export { getRandomId } from "./1_utilities.js";
|
|
2
|
+
export { checkPassword } from "./client/0_password.js";
|
|
4
3
|
export * from "./2_connection.js";
|
|
5
4
|
export * from "./3_storage.js";
|
|
6
5
|
export * from "./3_transport.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export type DC = "1" | "2" | "3" | "4" | "5" | "1-test" | "2-test" | "3-test";
|
|
4
|
+
export declare function getDcIps(dc: DC, version: "ipv4" | "ipv6"): [string, ...string[]];
|
|
4
5
|
export interface TransportProviderParams {
|
|
5
6
|
dc: DC;
|
|
6
7
|
cdn: boolean;
|
|
@@ -10,6 +11,4 @@ export type TransportProvider = (params: TransportProviderParams) => {
|
|
|
10
11
|
transport: Transport;
|
|
11
12
|
dcId: number;
|
|
12
13
|
};
|
|
13
|
-
export declare
|
|
14
|
-
wss?: boolean;
|
|
15
|
-
}) => TransportProvider;
|
|
14
|
+
export declare function getDcId(dc: DC, cdn: boolean): number;
|
|
@@ -1,26 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { UNREACHABLE } from "../1_utilities.js";
|
|
2
|
+
export function getDcIps(dc, version) {
|
|
3
|
+
switch (version) {
|
|
4
|
+
case "ipv4":
|
|
5
|
+
switch (dc) {
|
|
6
|
+
case "1":
|
|
7
|
+
return ["149.154.175.50"];
|
|
8
|
+
case "2":
|
|
9
|
+
return ["149.154.167.51", "95.161.76.100"];
|
|
10
|
+
case "3":
|
|
11
|
+
return ["149.154.175.100"];
|
|
12
|
+
case "4":
|
|
13
|
+
return ["149.154.167.91"];
|
|
14
|
+
case "5":
|
|
15
|
+
return ["149.154.171.5"];
|
|
16
|
+
case "1-test":
|
|
17
|
+
return ["149.154.175.10"];
|
|
18
|
+
case "2-test":
|
|
19
|
+
return ["149.154.167.40"];
|
|
20
|
+
case "3-test":
|
|
21
|
+
return ["149.154.175.117"];
|
|
22
|
+
default:
|
|
23
|
+
UNREACHABLE();
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
case "ipv6":
|
|
27
|
+
switch (dc) {
|
|
28
|
+
case "1":
|
|
29
|
+
return ["2001:b28:f23d:f001::a"];
|
|
30
|
+
case "2":
|
|
31
|
+
return ["2001:67c:4e8:f002::a"];
|
|
32
|
+
case "3":
|
|
33
|
+
return ["2001:b28:f23d:f003::a"];
|
|
34
|
+
case "4":
|
|
35
|
+
return ["2001:67c:4e8:f004::a"];
|
|
36
|
+
case "5":
|
|
37
|
+
return ["2001:b28:f23f:f005::a"];
|
|
38
|
+
case "1-test":
|
|
39
|
+
return ["2001:b28:f23d:f001::e"];
|
|
40
|
+
case "2-test":
|
|
41
|
+
return ["2001:67c:4e8:f002::e"];
|
|
42
|
+
case "3-test":
|
|
43
|
+
return ["2001:b28:f23d:f003::e"];
|
|
44
|
+
default:
|
|
45
|
+
UNREACHABLE();
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
UNREACHABLE();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function getDcId(dc, cdn) {
|
|
14
53
|
return Number(dc[0]) + (dc.endsWith("-test") ? 10000 : 0) * (cdn ? -1 : 1);
|
|
15
54
|
}
|
|
16
|
-
export const webSocketTransportProvider = (params) => {
|
|
17
|
-
return ({ dc, cdn }) => {
|
|
18
|
-
params ??= {};
|
|
19
|
-
params.wss ??= typeof location !== "undefined" && location.protocol == "http:" && location.hostname != "localhost" ? false : true;
|
|
20
|
-
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${cdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
21
|
-
const connection = new ConnectionWebSocket(url);
|
|
22
|
-
const transport = new TransportIntermediate(connection, true);
|
|
23
|
-
const dcId = getDcId(dc, cdn);
|
|
24
|
-
return { connection, transport, dcId };
|
|
25
|
-
};
|
|
26
|
-
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConnectionWebSocket } from "../2_connection.js";
|
|
2
|
+
import { TransportIntermediate } from "./1_transport_intermediate.js";
|
|
3
|
+
import { getDcId } from "./2_transport_provider.js";
|
|
4
|
+
const dcToNameMap = {
|
|
5
|
+
"1": "pluto",
|
|
6
|
+
"1-test": "pluto",
|
|
7
|
+
"2": "venus",
|
|
8
|
+
"2-test": "venus",
|
|
9
|
+
"3": "aurora",
|
|
10
|
+
"3-test": "aurora",
|
|
11
|
+
"4": "vesta",
|
|
12
|
+
"5": "flora",
|
|
13
|
+
};
|
|
14
|
+
export const transportProviderWebSocket = (params) => {
|
|
15
|
+
return ({ dc, cdn }) => {
|
|
16
|
+
params ??= {};
|
|
17
|
+
params.wss ??= typeof location !== "undefined" && location.protocol == "http:" && location.hostname != "localhost" ? false : true;
|
|
18
|
+
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${cdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
19
|
+
const connection = new ConnectionWebSocket(url);
|
|
20
|
+
const transport = new TransportIntermediate(connection, true);
|
|
21
|
+
const dcId = getDcId(dc, cdn);
|
|
22
|
+
return { connection, transport, dcId };
|
|
23
|
+
};
|
|
24
|
+
};
|
package/package.json
CHANGED
package/script/3_transport.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export * from "./transport/0_transport.js";
|
|
|
2
2
|
export * from "./transport/1_transport_abridged.js";
|
|
3
3
|
export * from "./transport/1_transport_intermediate.js";
|
|
4
4
|
export * from "./transport/2_transport_provider.js";
|
|
5
|
+
export * from "./transport/3_transport_provider_web_socket.js";
|
package/script/3_transport.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./transport/0_transport.js"), exports);
|
|
|
18
18
|
__exportStar(require("./transport/1_transport_abridged.js"), exports);
|
|
19
19
|
__exportStar(require("./transport/1_transport_intermediate.js"), exports);
|
|
20
20
|
__exportStar(require("./transport/2_transport_provider.js"), exports);
|
|
21
|
+
__exportStar(require("./transport/3_transport_provider_web_socket.js"), exports);
|
package/script/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 166;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.112";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
80
80
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
81
|
exports.INITIAL_DC = "2";
|
|
82
82
|
exports.LAYER = 166;
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
83
|
+
exports.APP_VERSION = "MTKruto 0.1.112";
|
|
84
84
|
// @ts-ignore: lib
|
|
85
85
|
exports.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;
|
|
86
86
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -50,7 +50,7 @@ class ClientAbstract {
|
|
|
50
50
|
value: void 0
|
|
51
51
|
});
|
|
52
52
|
this.initialDc = params?.initialDc ?? _4_constants_js_1.INITIAL_DC;
|
|
53
|
-
this.transportProvider = params?.transportProvider ?? (0, _3_transport_js_1.
|
|
53
|
+
this.transportProvider = params?.transportProvider ?? (0, _3_transport_js_1.transportProviderWebSocket)();
|
|
54
54
|
this.cdn = params?.cdn ?? false;
|
|
55
55
|
}
|
|
56
56
|
get dcId() {
|
|
@@ -241,7 +241,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
async [(_Client_auth = new WeakMap(), _Client_sessionId = new WeakMap(), _Client_state = new WeakMap(), _Client_promises = new WeakMap(), _Client_toAcknowledge = new WeakMap(), _Client_updateState = new WeakMap(), _Client_errorHandler = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_autoStart = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_authKeyWasCreated = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_selfId = new WeakMap(), _Client_lastOutgoing = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_autoStarted = new WeakMap(), _Client_lastMsgId = new WeakMap(), _Client_handleUpdateQueue = new WeakMap(), _Client_processUpdatesQueue = new WeakMap(), _Client_usernameResolver = new WeakMap(), _Client_handle = new WeakMap(), _Client_instances = new WeakSet(), _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
|
|
244
|
-
|
|
244
|
+
__classPrivateFieldGet(this, _Client_handleUpdateQueue, "f").add(async () => {
|
|
245
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, { connectionState }, _0_utilities_js_1.resolve);
|
|
246
|
+
});
|
|
245
247
|
}, _Client_setAuth = async function _Client_setAuth(key) {
|
|
246
248
|
const hash = await (0, _1_utilities_js_1.sha1)(key);
|
|
247
249
|
const id = (0, _1_utilities_js_1.bigIntFromBuffer)(hash.slice(-8), true, false);
|
|
@@ -1198,6 +1200,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1198
1200
|
const messages = new Array();
|
|
1199
1201
|
if (updates instanceof _2_tl_js_1.types.Updates) {
|
|
1200
1202
|
for (const update of updates.updates) {
|
|
1203
|
+
if ("message" in update && update.message instanceof _2_tl_js_1.types.MessageEmpty) {
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1201
1206
|
if (update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateEditMessage) {
|
|
1202
1207
|
messages.push(await (0, _3_types_js_1.constructMessage)(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1203
1208
|
}
|
|
@@ -1269,6 +1274,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1269
1274
|
}
|
|
1270
1275
|
const messages = new Array();
|
|
1271
1276
|
for (const message_ of messages_) {
|
|
1277
|
+
if (message_ instanceof _2_tl_js_1.types.MessageEmpty) {
|
|
1278
|
+
continue;
|
|
1279
|
+
}
|
|
1272
1280
|
const message = await (0, _3_types_js_1.constructMessage)(message_, this[getEntity].bind(this), null, this[getStickerSetName].bind(this));
|
|
1273
1281
|
const isReplyToMessage = message_ instanceof _2_tl_js_1.types.Message && message_.replyTo instanceof _2_tl_js_1.types.MessageReplyHeader;
|
|
1274
1282
|
messages.push({ message, isReplyToMessage });
|
|
@@ -1840,8 +1848,10 @@ async function _Client_handleUpdate(update) {
|
|
|
1840
1848
|
update instanceof _2_tl_js_1.types.UpdateEditMessage ||
|
|
1841
1849
|
update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
|
|
1842
1850
|
const key = update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateNewChannelMessage ? "message" : "editedMessage";
|
|
1843
|
-
|
|
1844
|
-
|
|
1851
|
+
if (!(update.message instanceof _2_tl_js_1.types.MessageEmpty)) {
|
|
1852
|
+
const message = await (0, _3_types_js_1.constructMessage)(update.message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this));
|
|
1853
|
+
await __classPrivateFieldGet(this, _Client_handle, "f").call(this, { [key]: message }, _0_utilities_js_1.resolve);
|
|
1854
|
+
}
|
|
1845
1855
|
}
|
|
1846
1856
|
if (update instanceof _2_tl_js_1.types.UpdateDeleteMessages) {
|
|
1847
1857
|
const deletedMessages = new Array();
|
|
@@ -1849,7 +1859,7 @@ async function _Client_handleUpdate(update) {
|
|
|
1849
1859
|
const chatId = await this.storage.getMessageChat(messageId);
|
|
1850
1860
|
if (chatId) {
|
|
1851
1861
|
const message = await this.storage.getMessage(chatId, messageId);
|
|
1852
|
-
if (message != null) {
|
|
1862
|
+
if (message != null && !(message instanceof _2_tl_js_1.types.MessageEmpty)) {
|
|
1853
1863
|
deletedMessages.push(await (0, _3_types_js_1.constructMessage)(message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1854
1864
|
}
|
|
1855
1865
|
await this.storage.setMessage(chatId, messageId, null);
|
|
@@ -1864,7 +1874,7 @@ async function _Client_handleUpdate(update) {
|
|
|
1864
1874
|
const deletedMessages = new Array();
|
|
1865
1875
|
for (const messageId of update.messages) {
|
|
1866
1876
|
const message = await this.storage.getMessage(chatId, messageId);
|
|
1867
|
-
if (message) {
|
|
1877
|
+
if (message != null && !(message instanceof _2_tl_js_1.types.MessageEmpty)) {
|
|
1868
1878
|
deletedMessages.push(await (0, _3_types_js_1.constructMessage)(message, this[getEntity].bind(this), this.getMessage.bind(this), this[getStickerSetName].bind(this)));
|
|
1869
1879
|
}
|
|
1870
1880
|
await this.storage.setMessage(chatId, messageId, null);
|
package/script/mod.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const utils: {
|
|
4
|
-
checkPassword: typeof checkPassword;
|
|
5
|
-
getRandomId: typeof getRandomId;
|
|
6
|
-
};
|
|
1
|
+
export { getRandomId } from "./1_utilities.js";
|
|
2
|
+
export { checkPassword } from "./client/0_password.js";
|
|
7
3
|
export * from "./2_connection.js";
|
|
8
4
|
export * from "./3_storage.js";
|
|
9
5
|
export * from "./3_transport.js";
|
package/script/mod.js
CHANGED
|
@@ -26,10 +26,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.errors = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LAYER = exports.LANG_PACK = exports.LANG_CODE = exports.INITIAL_DC = exports.DEVICE_MODEL = exports.APP_VERSION = exports.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
exports.errors = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LAYER = exports.LANG_PACK = exports.LANG_CODE = exports.INITIAL_DC = exports.DEVICE_MODEL = exports.APP_VERSION = exports.checkPassword = exports.getRandomId = void 0;
|
|
30
|
+
var _1_utilities_js_1 = require("./1_utilities.js");
|
|
31
|
+
Object.defineProperty(exports, "getRandomId", { enumerable: true, get: function () { return _1_utilities_js_1.getRandomId; } });
|
|
32
|
+
var _0_password_js_1 = require("./client/0_password.js");
|
|
33
|
+
Object.defineProperty(exports, "checkPassword", { enumerable: true, get: function () { return _0_password_js_1.checkPassword; } });
|
|
33
34
|
__exportStar(require("./2_connection.js"), exports);
|
|
34
35
|
__exportStar(require("./3_storage.js"), exports);
|
|
35
36
|
__exportStar(require("./3_transport.js"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export type DC = "1" | "2" | "3" | "4" | "5" | "1-test" | "2-test" | "3-test";
|
|
4
|
+
export declare function getDcIps(dc: DC, version: "ipv4" | "ipv6"): [string, ...string[]];
|
|
4
5
|
export interface TransportProviderParams {
|
|
5
6
|
dc: DC;
|
|
6
7
|
cdn: boolean;
|
|
@@ -10,6 +11,4 @@ export type TransportProvider = (params: TransportProviderParams) => {
|
|
|
10
11
|
transport: Transport;
|
|
11
12
|
dcId: number;
|
|
12
13
|
};
|
|
13
|
-
export declare
|
|
14
|
-
wss?: boolean;
|
|
15
|
-
}) => TransportProvider;
|
|
14
|
+
export declare function getDcId(dc: DC, cdn: boolean): number;
|
|
@@ -1,30 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
exports.getDcId = exports.getDcIps = void 0;
|
|
4
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
|
+
function getDcIps(dc, version) {
|
|
6
|
+
switch (version) {
|
|
7
|
+
case "ipv4":
|
|
8
|
+
switch (dc) {
|
|
9
|
+
case "1":
|
|
10
|
+
return ["149.154.175.50"];
|
|
11
|
+
case "2":
|
|
12
|
+
return ["149.154.167.51", "95.161.76.100"];
|
|
13
|
+
case "3":
|
|
14
|
+
return ["149.154.175.100"];
|
|
15
|
+
case "4":
|
|
16
|
+
return ["149.154.167.91"];
|
|
17
|
+
case "5":
|
|
18
|
+
return ["149.154.171.5"];
|
|
19
|
+
case "1-test":
|
|
20
|
+
return ["149.154.175.10"];
|
|
21
|
+
case "2-test":
|
|
22
|
+
return ["149.154.167.40"];
|
|
23
|
+
case "3-test":
|
|
24
|
+
return ["149.154.175.117"];
|
|
25
|
+
default:
|
|
26
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case "ipv6":
|
|
30
|
+
switch (dc) {
|
|
31
|
+
case "1":
|
|
32
|
+
return ["2001:b28:f23d:f001::a"];
|
|
33
|
+
case "2":
|
|
34
|
+
return ["2001:67c:4e8:f002::a"];
|
|
35
|
+
case "3":
|
|
36
|
+
return ["2001:b28:f23d:f003::a"];
|
|
37
|
+
case "4":
|
|
38
|
+
return ["2001:67c:4e8:f004::a"];
|
|
39
|
+
case "5":
|
|
40
|
+
return ["2001:b28:f23f:f005::a"];
|
|
41
|
+
case "1-test":
|
|
42
|
+
return ["2001:b28:f23d:f001::e"];
|
|
43
|
+
case "2-test":
|
|
44
|
+
return ["2001:67c:4e8:f002::e"];
|
|
45
|
+
case "3-test":
|
|
46
|
+
return ["2001:b28:f23d:f003::e"];
|
|
47
|
+
default:
|
|
48
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
(0, _1_utilities_js_1.UNREACHABLE)();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.getDcIps = getDcIps;
|
|
16
56
|
function getDcId(dc, cdn) {
|
|
17
57
|
return Number(dc[0]) + (dc.endsWith("-test") ? 10000 : 0) * (cdn ? -1 : 1);
|
|
18
58
|
}
|
|
19
|
-
|
|
20
|
-
return ({ dc, cdn }) => {
|
|
21
|
-
params ??= {};
|
|
22
|
-
params.wss ??= typeof location !== "undefined" && location.protocol == "http:" && location.hostname != "localhost" ? false : true;
|
|
23
|
-
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${cdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
24
|
-
const connection = new _2_connection_js_1.ConnectionWebSocket(url);
|
|
25
|
-
const transport = new _1_transport_intermediate_js_1.TransportIntermediate(connection, true);
|
|
26
|
-
const dcId = getDcId(dc, cdn);
|
|
27
|
-
return { connection, transport, dcId };
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
exports.webSocketTransportProvider = webSocketTransportProvider;
|
|
59
|
+
exports.getDcId = getDcId;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transportProviderWebSocket = void 0;
|
|
4
|
+
const _2_connection_js_1 = require("../2_connection.js");
|
|
5
|
+
const _1_transport_intermediate_js_1 = require("./1_transport_intermediate.js");
|
|
6
|
+
const _2_transport_provider_js_1 = require("./2_transport_provider.js");
|
|
7
|
+
const dcToNameMap = {
|
|
8
|
+
"1": "pluto",
|
|
9
|
+
"1-test": "pluto",
|
|
10
|
+
"2": "venus",
|
|
11
|
+
"2-test": "venus",
|
|
12
|
+
"3": "aurora",
|
|
13
|
+
"3-test": "aurora",
|
|
14
|
+
"4": "vesta",
|
|
15
|
+
"5": "flora",
|
|
16
|
+
};
|
|
17
|
+
const transportProviderWebSocket = (params) => {
|
|
18
|
+
return ({ dc, cdn }) => {
|
|
19
|
+
params ??= {};
|
|
20
|
+
params.wss ??= typeof location !== "undefined" && location.protocol == "http:" && location.hostname != "localhost" ? false : true;
|
|
21
|
+
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${cdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
22
|
+
const connection = new _2_connection_js_1.ConnectionWebSocket(url);
|
|
23
|
+
const transport = new _1_transport_intermediate_js_1.TransportIntermediate(connection, true);
|
|
24
|
+
const dcId = (0, _2_transport_provider_js_1.getDcId)(dc, cdn);
|
|
25
|
+
return { connection, transport, dcId };
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.transportProviderWebSocket = transportProviderWebSocket;
|