@mtcute/core 0.21.0 → 0.22.0
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/client.cjs +13 -8
- package/client.js +13 -8
- package/highlevel/base.cjs +3 -3
- package/highlevel/base.js +3 -3
- package/highlevel/client.d.cts +27 -49
- package/highlevel/client.d.ts +27 -49
- package/highlevel/methods/auth/sign-in-qr.cjs +4 -4
- package/highlevel/methods/files/download-iterable.cjs +25 -0
- package/highlevel/methods/files/download-iterable.js +25 -0
- package/highlevel/methods/files/upload-file.js +1 -1
- package/highlevel/methods/messages/forward-messages.cjs +2 -1
- package/highlevel/methods/messages/forward-messages.d.cts +6 -0
- package/highlevel/methods/messages/forward-messages.d.ts +6 -0
- package/highlevel/methods/messages/forward-messages.js +2 -1
- package/highlevel/methods/messages/get-web-page-preview.cjs +22 -0
- package/highlevel/methods/messages/get-web-page-preview.d.cts +9 -0
- package/highlevel/methods/messages/get-web-page-preview.d.ts +9 -0
- package/highlevel/methods/messages/get-web-page-preview.js +17 -0
- package/highlevel/methods/messages/send-common.d.cts +5 -0
- package/highlevel/methods/messages/send-common.d.ts +5 -0
- package/highlevel/methods/messages/send-media-group.cjs +2 -1
- package/highlevel/methods/messages/send-media-group.js +2 -1
- package/highlevel/methods/messages/send-media.cjs +2 -1
- package/highlevel/methods/messages/send-media.js +2 -1
- package/highlevel/methods/messages/send-paid-reaction.cjs +8 -2
- package/highlevel/methods/messages/send-paid-reaction.d.cts +8 -2
- package/highlevel/methods/messages/send-paid-reaction.d.ts +8 -2
- package/highlevel/methods/messages/send-paid-reaction.js +8 -2
- package/highlevel/methods/messages/send-text.cjs +2 -1
- package/highlevel/methods/messages/send-text.js +2 -1
- package/highlevel/methods/premium/pin-star-gift.cjs +24 -0
- package/highlevel/methods/premium/pin-star-gift.d.cts +13 -0
- package/highlevel/methods/premium/pin-star-gift.d.ts +13 -0
- package/highlevel/methods/premium/pin-star-gift.js +19 -0
- package/highlevel/methods/{premium/get-star-gifts.cjs → users/get-peer-settings.cjs} +10 -6
- package/highlevel/methods/users/get-peer-settings.d.cts +4 -0
- package/highlevel/methods/users/get-peer-settings.d.ts +4 -0
- package/highlevel/methods/users/get-peer-settings.js +14 -0
- package/highlevel/methods/users/resolve-peer.cjs +16 -31
- package/highlevel/methods/users/resolve-peer.js +7 -22
- package/highlevel/methods.d.cts +3 -2
- package/highlevel/methods.d.ts +3 -2
- package/highlevel/storage/repository/peers.d.cts +2 -3
- package/highlevel/storage/repository/peers.d.ts +2 -3
- package/highlevel/storage/service/peers.cjs +10 -4
- package/highlevel/storage/service/peers.d.cts +1 -0
- package/highlevel/storage/service/peers.d.ts +1 -0
- package/highlevel/storage/service/peers.js +10 -4
- package/highlevel/types/bots/keyboards/factories.cjs +4 -4
- package/highlevel/types/media/document.cjs +1 -1
- package/highlevel/types/media/document.js +1 -1
- package/highlevel/types/media/web-page.cjs +40 -3
- package/highlevel/types/media/web-page.d.cts +23 -1
- package/highlevel/types/media/web-page.d.ts +23 -1
- package/highlevel/types/media/web-page.js +41 -4
- package/highlevel/types/messages/message-media.cjs +1 -1
- package/highlevel/types/messages/message-media.d.cts +2 -2
- package/highlevel/types/messages/message-media.d.ts +2 -2
- package/highlevel/types/messages/message-media.js +2 -2
- package/highlevel/types/messages/message.cjs +4 -0
- package/highlevel/types/messages/message.d.cts +2 -0
- package/highlevel/types/messages/message.d.ts +2 -0
- package/highlevel/types/messages/message.js +4 -0
- package/highlevel/types/peers/chat-event/actions.cjs +5 -0
- package/highlevel/types/peers/chat-event/actions.js +5 -0
- package/highlevel/types/peers/chat.cjs +4 -0
- package/highlevel/types/peers/chat.d.cts +2 -0
- package/highlevel/types/peers/chat.d.ts +2 -0
- package/highlevel/types/peers/chat.js +4 -0
- package/highlevel/types/peers/full-chat.cjs +4 -0
- package/highlevel/types/peers/full-chat.d.cts +2 -0
- package/highlevel/types/peers/full-chat.d.ts +2 -0
- package/highlevel/types/peers/full-chat.js +4 -0
- package/highlevel/types/peers/index.d.cts +1 -0
- package/highlevel/types/peers/index.d.ts +1 -0
- package/highlevel/types/peers/peer-settings.cjs +101 -0
- package/highlevel/types/peers/peer-settings.d.cts +84 -0
- package/highlevel/types/peers/peer-settings.d.ts +84 -0
- package/highlevel/types/peers/peer-settings.js +96 -0
- package/highlevel/types/peers/user.cjs +4 -0
- package/highlevel/types/peers/user.d.cts +2 -0
- package/highlevel/types/peers/user.d.ts +2 -0
- package/highlevel/types/peers/user.js +4 -0
- package/highlevel/types/premium/saved-star-gift.cjs +4 -1
- package/highlevel/types/premium/saved-star-gift.d.cts +2 -3
- package/highlevel/types/premium/saved-star-gift.d.ts +2 -3
- package/highlevel/types/premium/saved-star-gift.js +5 -2
- package/highlevel/types/premium/stars-gift-unique.cjs +4 -0
- package/highlevel/types/premium/stars-gift-unique.d.cts +2 -0
- package/highlevel/types/premium/stars-gift-unique.d.ts +2 -0
- package/highlevel/types/premium/stars-gift-unique.js +4 -0
- package/highlevel/types/premium/stars-transaction.cjs +14 -0
- package/highlevel/types/premium/stars-transaction.d.cts +14 -0
- package/highlevel/types/premium/stars-transaction.d.ts +14 -0
- package/highlevel/types/premium/stars-transaction.js +14 -0
- package/highlevel/types/stories/story-viewer.cjs +1 -1
- package/highlevel/types/stories/story-viewer.js +1 -1
- package/highlevel/types/updates/history-read-update.cjs +1 -0
- package/highlevel/types/updates/history-read-update.js +1 -0
- package/highlevel/updates/manager.js +2 -2
- package/highlevel/utils/file-utils.js +1 -1
- package/highlevel/utils/inline-utils.cjs +5 -5
- package/highlevel/utils/inline-utils.js +1 -1
- package/highlevel/worker/storage.cjs +2 -0
- package/highlevel/worker/storage.d.cts +1 -0
- package/highlevel/worker/storage.d.ts +1 -0
- package/highlevel/worker/storage.js +2 -0
- package/index.cjs +3 -1
- package/index.js +5 -3
- package/methods.cjs +6 -4
- package/methods.js +6 -4
- package/network/authorization.js +2 -2
- package/network/network-manager.cjs +1 -1
- package/network/network-manager.js +1 -1
- package/network/persistent-connection.cjs +6 -4
- package/network/persistent-connection.js +6 -4
- package/network/session-connection.cjs +14 -7
- package/network/session-connection.d.cts +1 -1
- package/network/session-connection.d.ts +1 -1
- package/network/session-connection.js +15 -8
- package/package.json +4 -4
- package/storage/memory/repository/peers.cjs +2 -2
- package/storage/memory/repository/peers.d.cts +1 -1
- package/storage/memory/repository/peers.d.ts +1 -1
- package/storage/memory/repository/peers.js +2 -2
- package/storage/sqlite/repository/peers.cjs +3 -5
- package/storage/sqlite/repository/peers.d.cts +1 -2
- package/storage/sqlite/repository/peers.d.ts +1 -2
- package/storage/sqlite/repository/peers.js +3 -5
- package/utils/binary/asn1-parser.js +1 -1
- package/utils/binary/compat.cjs +150 -0
- package/utils/binary/compat.d.cts +13 -0
- package/utils/binary/compat.d.ts +13 -0
- package/utils/binary/compat.js +145 -0
- package/utils/binary/compat.test.d.cts +1 -0
- package/utils/binary/compat.test.d.ts +1 -0
- package/utils/binary/serialization.cjs +59 -0
- package/utils/binary/serialization.d.cts +10 -0
- package/utils/binary/serialization.d.ts +10 -0
- package/utils/binary/serialization.js +54 -0
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/long-utils.js +1 -1
- package/utils/peer-utils.js +1 -1
- package/utils.cjs +8 -0
- package/utils.js +8 -0
- package/highlevel/methods/premium/get-star-gifts.d.cts +0 -23
- package/highlevel/methods/premium/get-star-gifts.d.ts +0 -23
- package/highlevel/methods/premium/get-star-gifts.js +0 -10
- package/highlevel/methods/premium/iter-star-gifts.cjs +0 -29
- package/highlevel/methods/premium/iter-star-gifts.d.cts +0 -26
- package/highlevel/methods/premium/iter-star-gifts.d.ts +0 -26
- package/highlevel/methods/premium/iter-star-gifts.js +0 -24
|
@@ -5,12 +5,12 @@ import { MtArgumentError } from "../../types/errors.js";
|
|
|
5
5
|
import { assertNever } from "../../types/utils.js";
|
|
6
6
|
import { EarlyTimer } from "../../utils/early-timer.js";
|
|
7
7
|
import { SortedLinkedList } from "../../utils/linked-list.js";
|
|
8
|
-
import { parseMarkedPeerId, getBarePeerId, getMarkedPeerId
|
|
8
|
+
import { toggleChannelIdMark, parseMarkedPeerId, getBarePeerId, getMarkedPeerId } from "../../utils/peer-utils.js";
|
|
9
9
|
import "@mtcute/tl-runtime";
|
|
10
10
|
import { _getChannelsBatched } from "../methods/chats/batched-queries.js";
|
|
11
11
|
import { PeersIndex } from "../types/peers/peers-index.js";
|
|
12
12
|
import { RawUpdateInfo } from "./types.js";
|
|
13
|
-
import {
|
|
13
|
+
import { toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer, extractChannelIdFromUpdate } from "./utils.js";
|
|
14
14
|
import { toInputChannel } from "../utils/peer-utils.js";
|
|
15
15
|
const KEEP_ALIVE_INTERVAL = 15 * 60 * 1e3;
|
|
16
16
|
const UPDATES_TOO_LONG = { _: "updatesTooLong" };
|
|
@@ -5,11 +5,11 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
|
|
|
5
5
|
}
|
|
6
6
|
"use strict";
|
|
7
7
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
8
|
-
const utils
|
|
8
|
+
const utils = require("@fuman/utils");
|
|
9
9
|
const tlRuntime = require("@mtcute/tl-runtime");
|
|
10
|
-
const utils = require("../../types/utils.cjs");
|
|
10
|
+
const utils$1 = require("../../types/utils.cjs");
|
|
11
11
|
function parseInlineMessageId(id) {
|
|
12
|
-
const buf = utils
|
|
12
|
+
const buf = utils.base64.decode(id, true);
|
|
13
13
|
const reader = tlRuntime.TlBinaryReader.manual(buf);
|
|
14
14
|
if (buf.length === 20) {
|
|
15
15
|
return {
|
|
@@ -44,9 +44,9 @@ function encodeInlineMessageId(id) {
|
|
|
44
44
|
writer.long(id.accessHash);
|
|
45
45
|
break;
|
|
46
46
|
default:
|
|
47
|
-
utils.assertNever();
|
|
47
|
+
utils$1.assertNever();
|
|
48
48
|
}
|
|
49
|
-
return utils
|
|
49
|
+
return utils.base64.encode(writer.result(), true);
|
|
50
50
|
}
|
|
51
51
|
function normalizeInlineId(id) {
|
|
52
52
|
if (typeof id === "string") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { base64 } from "@fuman/utils";
|
|
2
|
-
import {
|
|
2
|
+
import { TlBinaryReader, TlBinaryWriter } from "@mtcute/tl-runtime";
|
|
3
3
|
import { assertNever } from "../../types/utils.js";
|
|
4
4
|
function parseInlineMessageId(id) {
|
|
5
5
|
const buf = base64.decode(id, true);
|
|
@@ -54,6 +54,7 @@ class PeersServiceProxy {
|
|
|
54
54
|
this.getByPhone = bind("getByPhone");
|
|
55
55
|
this.getByUsername = bind("getByUsername");
|
|
56
56
|
this.getCompleteById = bind("getCompleteById");
|
|
57
|
+
this.getMinAccessHash = bind("getMinAccessHash");
|
|
57
58
|
}
|
|
58
59
|
updatePeersFrom;
|
|
59
60
|
store;
|
|
@@ -61,6 +62,7 @@ class PeersServiceProxy {
|
|
|
61
62
|
getByPhone;
|
|
62
63
|
getByUsername;
|
|
63
64
|
getCompleteById;
|
|
65
|
+
getMinAccessHash;
|
|
64
66
|
}
|
|
65
67
|
class TelegramStorageProxy {
|
|
66
68
|
constructor(_invoker) {
|
|
@@ -25,6 +25,7 @@ declare class PeersServiceProxy implements PublicPart<PeersService> {
|
|
|
25
25
|
readonly getByPhone: PeersService['getByPhone'];
|
|
26
26
|
readonly getByUsername: PeersService['getByUsername'];
|
|
27
27
|
readonly getCompleteById: PeersService['getCompleteById'];
|
|
28
|
+
readonly getMinAccessHash: PeersService['getMinAccessHash'];
|
|
28
29
|
constructor(_invoker: WorkerInvoker);
|
|
29
30
|
}
|
|
30
31
|
export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
|
|
@@ -25,6 +25,7 @@ declare class PeersServiceProxy implements PublicPart<PeersService> {
|
|
|
25
25
|
readonly getByPhone: PeersService['getByPhone'];
|
|
26
26
|
readonly getByUsername: PeersService['getByUsername'];
|
|
27
27
|
readonly getCompleteById: PeersService['getCompleteById'];
|
|
28
|
+
readonly getMinAccessHash: PeersService['getMinAccessHash'];
|
|
28
29
|
constructor(_invoker: WorkerInvoker);
|
|
29
30
|
}
|
|
30
31
|
export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
|
|
@@ -47,6 +47,7 @@ class PeersServiceProxy {
|
|
|
47
47
|
this.getByPhone = bind("getByPhone");
|
|
48
48
|
this.getByUsername = bind("getByUsername");
|
|
49
49
|
this.getCompleteById = bind("getCompleteById");
|
|
50
|
+
this.getMinAccessHash = bind("getMinAccessHash");
|
|
50
51
|
}
|
|
51
52
|
updatePeersFrom;
|
|
52
53
|
store;
|
|
@@ -54,6 +55,7 @@ class PeersServiceProxy {
|
|
|
54
55
|
getByPhone;
|
|
55
56
|
getByUsername;
|
|
56
57
|
getCompleteById;
|
|
58
|
+
getMinAccessHash;
|
|
57
59
|
}
|
|
58
60
|
class TelegramStorageProxy {
|
|
59
61
|
constructor(_invoker) {
|
package/index.cjs
CHANGED
|
@@ -77,6 +77,7 @@ const chatlistPreview = require("./highlevel/types/peers/chatlist-preview.cjs");
|
|
|
77
77
|
const forumTopic = require("./highlevel/types/peers/forum-topic.cjs");
|
|
78
78
|
const fullChat = require("./highlevel/types/peers/full-chat.cjs");
|
|
79
79
|
const fullUser = require("./highlevel/types/peers/full-user.cjs");
|
|
80
|
+
const peerSettings = require("./highlevel/types/peers/peer-settings.cjs");
|
|
80
81
|
const peer = require("./highlevel/types/peers/peer.cjs");
|
|
81
82
|
const peersIndex = require("./highlevel/types/peers/peers-index.cjs");
|
|
82
83
|
const user = require("./highlevel/types/peers/user.cjs");
|
|
@@ -205,6 +206,7 @@ exports.Venue = venue.Venue;
|
|
|
205
206
|
exports.Video = video.Video;
|
|
206
207
|
exports.Voice = voice.Voice;
|
|
207
208
|
exports.WebPage = webPage.WebPage;
|
|
209
|
+
exports.WebPageMedia = webPage.WebPageMedia;
|
|
208
210
|
exports.Dialog = dialog.Dialog;
|
|
209
211
|
exports.DraftMessage = draftMessage.DraftMessage;
|
|
210
212
|
exports.FactCheck = factCheck.FactCheck;
|
|
@@ -243,6 +245,7 @@ exports.ChatlistPreview = chatlistPreview.ChatlistPreview;
|
|
|
243
245
|
exports.ForumTopic = forumTopic.ForumTopic;
|
|
244
246
|
exports.FullChat = fullChat.FullChat;
|
|
245
247
|
exports.FullUser = fullUser.FullUser;
|
|
248
|
+
exports.PeerSettings = peerSettings.PeerSettings;
|
|
246
249
|
exports.parsePeer = peer.parsePeer;
|
|
247
250
|
exports.PeersIndex = peersIndex.PeersIndex;
|
|
248
251
|
exports.User = user.User;
|
|
@@ -257,7 +260,6 @@ exports.BusinessLocation = businessLocation.BusinessLocation;
|
|
|
257
260
|
exports.BusinessWorkHours = businessWorkHours.BusinessWorkHours;
|
|
258
261
|
exports.businessWorkHoursDaysToRaw = businessWorkHours.businessWorkHoursDaysToRaw;
|
|
259
262
|
exports.SavedStarGift = savedStarGift.SavedStarGift;
|
|
260
|
-
exports.UserStarGift = savedStarGift.UserStarGift;
|
|
261
263
|
exports.StarGiftUnique = starsGiftUnique.StarGiftUnique;
|
|
262
264
|
exports.StarGiftUniqueAttribute = starsGiftUnique.StarGiftUniqueAttribute;
|
|
263
265
|
exports.StarGiftUniqueBackdrop = starsGiftUnique.StarGiftUniqueBackdrop;
|
package/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import { Thumbnail } from "./highlevel/types/media/thumbnail.js";
|
|
|
33
33
|
import { Venue } from "./highlevel/types/media/venue.js";
|
|
34
34
|
import { Video } from "./highlevel/types/media/video.js";
|
|
35
35
|
import { Voice } from "./highlevel/types/media/voice.js";
|
|
36
|
-
import { WebPage } from "./highlevel/types/media/web-page.js";
|
|
36
|
+
import { WebPage, WebPageMedia } from "./highlevel/types/media/web-page.js";
|
|
37
37
|
import { Dialog } from "./highlevel/types/messages/dialog.js";
|
|
38
38
|
import { DraftMessage } from "./highlevel/types/messages/draft-message.js";
|
|
39
39
|
import { FactCheck } from "./highlevel/types/messages/fact-check.js";
|
|
@@ -70,6 +70,7 @@ import { ChatlistPreview } from "./highlevel/types/peers/chatlist-preview.js";
|
|
|
70
70
|
import { ForumTopic } from "./highlevel/types/peers/forum-topic.js";
|
|
71
71
|
import { FullChat } from "./highlevel/types/peers/full-chat.js";
|
|
72
72
|
import { FullUser } from "./highlevel/types/peers/full-user.js";
|
|
73
|
+
import { PeerSettings } from "./highlevel/types/peers/peer-settings.js";
|
|
73
74
|
import { parsePeer } from "./highlevel/types/peers/peer.js";
|
|
74
75
|
import { PeersIndex } from "./highlevel/types/peers/peers-index.js";
|
|
75
76
|
import { User } from "./highlevel/types/peers/user.js";
|
|
@@ -82,7 +83,7 @@ import { BusinessConnection } from "./highlevel/types/premium/business-connectio
|
|
|
82
83
|
import { BusinessIntro } from "./highlevel/types/premium/business-intro.js";
|
|
83
84
|
import { BusinessLocation } from "./highlevel/types/premium/business-location.js";
|
|
84
85
|
import { BusinessWorkHours, businessWorkHoursDaysToRaw } from "./highlevel/types/premium/business-work-hours.js";
|
|
85
|
-
import { SavedStarGift
|
|
86
|
+
import { SavedStarGift } from "./highlevel/types/premium/saved-star-gift.js";
|
|
86
87
|
import { StarGiftUnique, StarGiftUniqueAttribute, StarGiftUniqueBackdrop, StarGiftUniqueOriginalDetails } from "./highlevel/types/premium/stars-gift-unique.js";
|
|
87
88
|
import { StarGift } from "./highlevel/types/premium/stars-gift.js";
|
|
88
89
|
import { StarsStatus } from "./highlevel/types/premium/stars-status.js";
|
|
@@ -242,6 +243,7 @@ export {
|
|
|
242
243
|
PaidMedia,
|
|
243
244
|
PaidPeerReaction,
|
|
244
245
|
PeerReaction,
|
|
246
|
+
PeerSettings,
|
|
245
247
|
PeerStories,
|
|
246
248
|
PeersIndex,
|
|
247
249
|
Photo,
|
|
@@ -291,7 +293,6 @@ export {
|
|
|
291
293
|
TransportError,
|
|
292
294
|
UpdatesManager,
|
|
293
295
|
User,
|
|
294
|
-
UserStarGift,
|
|
295
296
|
UserStatusUpdate,
|
|
296
297
|
UserTypingUpdate,
|
|
297
298
|
Venue,
|
|
@@ -299,6 +300,7 @@ export {
|
|
|
299
300
|
Voice,
|
|
300
301
|
WebDocument,
|
|
301
302
|
WebPage,
|
|
303
|
+
WebPageMedia,
|
|
302
304
|
WebviewResult,
|
|
303
305
|
_actionFromTl,
|
|
304
306
|
_messageActionFromTl,
|
package/methods.cjs
CHANGED
|
@@ -148,6 +148,7 @@ const getMessages = require("./highlevel/methods/messages/get-messages.cjs");
|
|
|
148
148
|
const getReactionUsers = require("./highlevel/methods/messages/get-reaction-users.cjs");
|
|
149
149
|
const getReplyTo = require("./highlevel/methods/messages/get-reply-to.cjs");
|
|
150
150
|
const getScheduledMessages = require("./highlevel/methods/messages/get-scheduled-messages.cjs");
|
|
151
|
+
const getWebPagePreview = require("./highlevel/methods/messages/get-web-page-preview.cjs");
|
|
151
152
|
const iterHistory = require("./highlevel/methods/messages/iter-history.cjs");
|
|
152
153
|
const iterReactionUsers = require("./highlevel/methods/messages/iter-reaction-users.cjs");
|
|
153
154
|
const iterSearchGlobal = require("./highlevel/methods/messages/iter-search-global.cjs");
|
|
@@ -199,13 +200,12 @@ const getSavedStarGiftsById = require("./highlevel/methods/premium/get-saved-sta
|
|
|
199
200
|
const getSavedStarGifts = require("./highlevel/methods/premium/get-saved-star-gifts.cjs");
|
|
200
201
|
const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
|
|
201
202
|
const getStarGiftWithdrawalUrl = require("./highlevel/methods/premium/get-star-gift-withdrawal-url.cjs");
|
|
202
|
-
const getStarGifts = require("./highlevel/methods/premium/get-star-gifts.cjs");
|
|
203
203
|
const getStarsTransactions = require("./highlevel/methods/premium/get-stars-transactions.cjs");
|
|
204
204
|
const getUniqueStarGift = require("./highlevel/methods/premium/get-unique-star-gift.cjs");
|
|
205
205
|
const iterBoosters = require("./highlevel/methods/premium/iter-boosters.cjs");
|
|
206
206
|
const iterSavedStarGifts = require("./highlevel/methods/premium/iter-saved-star-gifts.cjs");
|
|
207
|
-
const iterStarGifts = require("./highlevel/methods/premium/iter-star-gifts.cjs");
|
|
208
207
|
const iterStarsTransactions = require("./highlevel/methods/premium/iter-stars-transactions.cjs");
|
|
208
|
+
const pinStarGift = require("./highlevel/methods/premium/pin-star-gift.cjs");
|
|
209
209
|
const sendStarGift = require("./highlevel/methods/premium/send-star-gift.cjs");
|
|
210
210
|
const setBusinessIntro = require("./highlevel/methods/premium/set-business-intro.cjs");
|
|
211
211
|
const setBusinessWorkHours = require("./highlevel/methods/premium/set-business-work-hours.cjs");
|
|
@@ -249,6 +249,7 @@ const getCommonChats = require("./highlevel/methods/users/get-common-chats.cjs")
|
|
|
249
249
|
const getGlobalTtl = require("./highlevel/methods/users/get-global-ttl.cjs");
|
|
250
250
|
const getMe = require("./highlevel/methods/users/get-me.cjs");
|
|
251
251
|
const getMyUsername = require("./highlevel/methods/users/get-my-username.cjs");
|
|
252
|
+
const getPeerSettings = require("./highlevel/methods/users/get-peer-settings.cjs");
|
|
252
253
|
const getProfilePhoto = require("./highlevel/methods/users/get-profile-photo.cjs");
|
|
253
254
|
const getProfilePhotos = require("./highlevel/methods/users/get-profile-photos.cjs");
|
|
254
255
|
const getUsers = require("./highlevel/methods/users/get-users.cjs");
|
|
@@ -414,6 +415,7 @@ exports.getMessages = getMessages.getMessages;
|
|
|
414
415
|
exports.getReactionUsers = getReactionUsers.getReactionUsers;
|
|
415
416
|
exports.getReplyTo = getReplyTo.getReplyTo;
|
|
416
417
|
exports.getScheduledMessages = getScheduledMessages.getScheduledMessages;
|
|
418
|
+
exports.getWebPagePreview = getWebPagePreview.getWebPagePreview;
|
|
417
419
|
exports.iterHistory = iterHistory.iterHistory;
|
|
418
420
|
exports.iterReactionUsers = iterReactionUsers.iterReactionUsers;
|
|
419
421
|
exports.iterSearchGlobal = iterSearchGlobal.iterSearchGlobal;
|
|
@@ -477,13 +479,12 @@ exports.getSavedStarGiftsById = getSavedStarGiftsById.getSavedStarGiftsById;
|
|
|
477
479
|
exports.getSavedStarGifts = getSavedStarGifts.getSavedStarGifts;
|
|
478
480
|
exports.getStarGiftOptions = getStarGiftOptions.getStarGiftOptions;
|
|
479
481
|
exports.getStarGiftWithdrawalUrl = getStarGiftWithdrawalUrl.getStarGiftWithdrawalUrl;
|
|
480
|
-
exports.getStarGifts = getStarGifts.getStarGifts;
|
|
481
482
|
exports.getStarsTransactions = getStarsTransactions.getStarsTransactions;
|
|
482
483
|
exports.getUniqueStarGift = getUniqueStarGift.getUniqueStarGift;
|
|
483
484
|
exports.iterBoosters = iterBoosters.iterBoosters;
|
|
484
485
|
exports.iterSavedStarGifts = iterSavedStarGifts.iterSavedStarGifts;
|
|
485
|
-
exports.iterStarGifts = iterStarGifts.iterStarGifts;
|
|
486
486
|
exports.iterStarsTransactions = iterStarsTransactions.iterStarsTransactions;
|
|
487
|
+
exports.togglePinnedStarGifts = pinStarGift.togglePinnedStarGifts;
|
|
487
488
|
exports.sendStarGift = sendStarGift.sendStarGift;
|
|
488
489
|
exports.setBusinessIntro = setBusinessIntro.setBusinessIntro;
|
|
489
490
|
exports.setBusinessWorkHours = setBusinessWorkHours.setBusinessWorkHours;
|
|
@@ -529,6 +530,7 @@ exports.getCommonChats = getCommonChats.getCommonChats;
|
|
|
529
530
|
exports.getGlobalTtl = getGlobalTtl.getGlobalTtl;
|
|
530
531
|
exports.getMe = getMe.getMe;
|
|
531
532
|
exports.getMyUsername = getMyUsername.getMyUsername;
|
|
533
|
+
exports.getPeerSettings = getPeerSettings.getPeerSettings;
|
|
532
534
|
exports.getProfilePhoto = getProfilePhoto.getProfilePhoto;
|
|
533
535
|
exports.getProfilePhotos = getProfilePhotos.getProfilePhotos;
|
|
534
536
|
exports.getUsers = getUsers.getUsers;
|
package/methods.js
CHANGED
|
@@ -141,6 +141,7 @@ import { getMessages } from "./highlevel/methods/messages/get-messages.js";
|
|
|
141
141
|
import { getReactionUsers } from "./highlevel/methods/messages/get-reaction-users.js";
|
|
142
142
|
import { getReplyTo } from "./highlevel/methods/messages/get-reply-to.js";
|
|
143
143
|
import { getScheduledMessages } from "./highlevel/methods/messages/get-scheduled-messages.js";
|
|
144
|
+
import { getWebPagePreview } from "./highlevel/methods/messages/get-web-page-preview.js";
|
|
144
145
|
import { iterHistory } from "./highlevel/methods/messages/iter-history.js";
|
|
145
146
|
import { iterReactionUsers } from "./highlevel/methods/messages/iter-reaction-users.js";
|
|
146
147
|
import { iterSearchGlobal } from "./highlevel/methods/messages/iter-search-global.js";
|
|
@@ -192,13 +193,12 @@ import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-sta
|
|
|
192
193
|
import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
|
|
193
194
|
import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
|
|
194
195
|
import { getStarGiftWithdrawalUrl } from "./highlevel/methods/premium/get-star-gift-withdrawal-url.js";
|
|
195
|
-
import { getStarGifts } from "./highlevel/methods/premium/get-star-gifts.js";
|
|
196
196
|
import { getStarsTransactions } from "./highlevel/methods/premium/get-stars-transactions.js";
|
|
197
197
|
import { getUniqueStarGift } from "./highlevel/methods/premium/get-unique-star-gift.js";
|
|
198
198
|
import { iterBoosters } from "./highlevel/methods/premium/iter-boosters.js";
|
|
199
199
|
import { iterSavedStarGifts } from "./highlevel/methods/premium/iter-saved-star-gifts.js";
|
|
200
|
-
import { iterStarGifts } from "./highlevel/methods/premium/iter-star-gifts.js";
|
|
201
200
|
import { iterStarsTransactions } from "./highlevel/methods/premium/iter-stars-transactions.js";
|
|
201
|
+
import { togglePinnedStarGifts } from "./highlevel/methods/premium/pin-star-gift.js";
|
|
202
202
|
import { sendStarGift } from "./highlevel/methods/premium/send-star-gift.js";
|
|
203
203
|
import { setBusinessIntro } from "./highlevel/methods/premium/set-business-intro.js";
|
|
204
204
|
import { setBusinessWorkHours } from "./highlevel/methods/premium/set-business-work-hours.js";
|
|
@@ -242,6 +242,7 @@ import { getCommonChats } from "./highlevel/methods/users/get-common-chats.js";
|
|
|
242
242
|
import { getGlobalTtl } from "./highlevel/methods/users/get-global-ttl.js";
|
|
243
243
|
import { getMe } from "./highlevel/methods/users/get-me.js";
|
|
244
244
|
import { getMyUsername } from "./highlevel/methods/users/get-my-username.js";
|
|
245
|
+
import { getPeerSettings } from "./highlevel/methods/users/get-peer-settings.js";
|
|
245
246
|
import { getProfilePhoto } from "./highlevel/methods/users/get-profile-photo.js";
|
|
246
247
|
import { getProfilePhotos } from "./highlevel/methods/users/get-profile-photos.js";
|
|
247
248
|
import { getUsers } from "./highlevel/methods/users/get-users.js";
|
|
@@ -382,6 +383,7 @@ export {
|
|
|
382
383
|
getPasswordHint,
|
|
383
384
|
getPeer,
|
|
384
385
|
getPeerDialogs,
|
|
386
|
+
getPeerSettings,
|
|
385
387
|
getPeerStories,
|
|
386
388
|
getPrimaryInviteLink,
|
|
387
389
|
getProfilePhoto,
|
|
@@ -395,7 +397,6 @@ export {
|
|
|
395
397
|
getSimilarChannels,
|
|
396
398
|
getStarGiftOptions,
|
|
397
399
|
getStarGiftWithdrawalUrl,
|
|
398
|
-
getStarGifts,
|
|
399
400
|
getStarsTransactions,
|
|
400
401
|
getStickerSet,
|
|
401
402
|
getStoriesById,
|
|
@@ -405,6 +406,7 @@ export {
|
|
|
405
406
|
getUniqueStarGift,
|
|
406
407
|
getUser,
|
|
407
408
|
getUsers,
|
|
409
|
+
getWebPagePreview,
|
|
408
410
|
hideAllJoinRequests,
|
|
409
411
|
hideJoinRequest,
|
|
410
412
|
hideMyStoriesViews,
|
|
@@ -429,7 +431,6 @@ export {
|
|
|
429
431
|
iterSearchGlobal,
|
|
430
432
|
iterSearchHashtag,
|
|
431
433
|
iterSearchMessages,
|
|
432
|
-
iterStarGifts,
|
|
433
434
|
iterStarsTransactions,
|
|
434
435
|
iterStoryViewers,
|
|
435
436
|
joinChat,
|
|
@@ -528,6 +529,7 @@ export {
|
|
|
528
529
|
toggleJoinRequests,
|
|
529
530
|
toggleJoinToSend,
|
|
530
531
|
togglePeerStoriesArchived,
|
|
532
|
+
togglePinnedStarGifts,
|
|
531
533
|
toggleStoriesPinned,
|
|
532
534
|
transferStarGift,
|
|
533
535
|
translateMessage,
|
package/network/authorization.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { typed, bigint, u8 } from "@fuman/utils";
|
|
2
2
|
import { mtp } from "@mtcute/tl";
|
|
3
|
-
import {
|
|
3
|
+
import { TlBinaryWriter, TlBinaryReader, TlSerializationCounter } from "@mtcute/tl-runtime";
|
|
4
4
|
import Long from "long";
|
|
5
5
|
import { findKeyByFingerprints } from "../utils/crypto/keys.js";
|
|
6
6
|
import { millerRabin } from "../utils/crypto/miller-rabin.js";
|
|
7
7
|
import { generateKeyAndIvFromNonce } from "../utils/crypto/mtproto.js";
|
|
8
8
|
import { mtpAssertTypeIs } from "../utils/type-assertions.js";
|
|
9
|
-
import { MtSecurityError,
|
|
9
|
+
import { MtSecurityError, MtTypeAssertionError, MtArgumentError } from "../types/errors.js";
|
|
10
10
|
const DH_SAFETY_RANGE = 2n ** (2048n - 64n);
|
|
11
11
|
const KNOWN_DH_PRIME = 0xC71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5Bn;
|
|
12
12
|
const TWO_POW_2047 = 2n ** 2047n;
|
|
@@ -172,10 +172,12 @@ class PersistentConnection {
|
|
|
172
172
|
try {
|
|
173
173
|
await this._writer.write(data);
|
|
174
174
|
} catch (e) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
if (!(e instanceof net.ConnectionClosedError)) {
|
|
176
|
+
this.log.warn("encountered an error while sending, reconnecting: %e", e);
|
|
177
|
+
this._writer = void 0;
|
|
178
|
+
this._fuman.reconnect(true);
|
|
179
|
+
this._sendOnceConnected.push(data);
|
|
180
|
+
}
|
|
179
181
|
}
|
|
180
182
|
} else {
|
|
181
183
|
this._sendOnceConnected.push(data);
|
|
@@ -165,10 +165,12 @@ class PersistentConnection {
|
|
|
165
165
|
try {
|
|
166
166
|
await this._writer.write(data);
|
|
167
167
|
} catch (e) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
if (!(e instanceof ConnectionClosedError)) {
|
|
169
|
+
this.log.warn("encountered an error while sending, reconnecting: %e", e);
|
|
170
|
+
this._writer = void 0;
|
|
171
|
+
this._fuman.reconnect(true);
|
|
172
|
+
this._sendOnceConnected.push(data);
|
|
173
|
+
}
|
|
172
174
|
}
|
|
173
175
|
} else {
|
|
174
176
|
this._sendOnceConnected.push(data);
|
|
@@ -88,7 +88,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
88
88
|
this._session._authKeyTemp.reset();
|
|
89
89
|
utils.timers.clearTimeout(this._pfsUpdateTimeout);
|
|
90
90
|
}
|
|
91
|
-
this._resetSession();
|
|
91
|
+
this._resetSession("use pfs changed");
|
|
92
92
|
}
|
|
93
93
|
onClosed() {
|
|
94
94
|
Object.values(this._pendingWaitForUnencrypted).forEach(([prom, timeout]) => {
|
|
@@ -168,13 +168,13 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
168
168
|
if (!this._triedReconnectingOn404) {
|
|
169
169
|
this.log.warn("transport error 404. trying to reconnect");
|
|
170
170
|
this._triedReconnectingOn404 = true;
|
|
171
|
-
this._resetSession();
|
|
171
|
+
this._resetSession("-404 reconnect");
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
this.log.warn("transport error 404, reauthorizing");
|
|
175
175
|
this.onError.emit(error);
|
|
176
176
|
this._session.resetAuthKey();
|
|
177
|
-
this._resetSession();
|
|
177
|
+
this._resetSession("-404 reconnect + reauth");
|
|
178
178
|
this.onKeyChange.emit(null);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
@@ -370,6 +370,11 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
370
370
|
try {
|
|
371
371
|
this._session.decryptMessage(data, this._handleRawMessage);
|
|
372
372
|
} catch (err) {
|
|
373
|
+
if (err instanceof tlRuntime.TlUnknownObjectError) {
|
|
374
|
+
this.log.warn("received unknown object %s, reconnecting...", err.objectId.toString(16));
|
|
375
|
+
this._resetSession("unknown object");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
373
378
|
this.log.error("failed to decrypt message: %s\ndata: %h", err, data);
|
|
374
379
|
}
|
|
375
380
|
}
|
|
@@ -655,6 +660,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
655
660
|
case "bind":
|
|
656
661
|
case "cancel":
|
|
657
662
|
break;
|
|
663
|
+
// do nothing, wait for the result
|
|
658
664
|
default:
|
|
659
665
|
if (!inContainer) {
|
|
660
666
|
this.log.warn("received unexpected ack for %s query %l", msg._, msgId);
|
|
@@ -788,7 +794,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
788
794
|
msg.badMsgId,
|
|
789
795
|
msg.errorCode
|
|
790
796
|
);
|
|
791
|
-
this._resetSession();
|
|
797
|
+
this._resetSession("bad_msg_notification");
|
|
792
798
|
break;
|
|
793
799
|
}
|
|
794
800
|
}
|
|
@@ -847,6 +853,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
847
853
|
);
|
|
848
854
|
return this._onMessageFailed(msgId, "message info state = 0, ans_id = 0");
|
|
849
855
|
}
|
|
856
|
+
// fallthrough
|
|
850
857
|
case 4:
|
|
851
858
|
this._onMessageAcked(msgId);
|
|
852
859
|
break;
|
|
@@ -916,10 +923,10 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
916
923
|
this._flushTimer.emitWhenIdle();
|
|
917
924
|
}
|
|
918
925
|
}
|
|
919
|
-
_resetSession() {
|
|
926
|
+
_resetSession(reason = "session reset") {
|
|
920
927
|
this._queuedDestroySession.push(this._session._sessionId);
|
|
921
928
|
this._session.resetState(true);
|
|
922
|
-
this._onAllFailed(
|
|
929
|
+
this._onAllFailed(reason);
|
|
923
930
|
this.reconnect();
|
|
924
931
|
this._flushTimer.reset();
|
|
925
932
|
}
|
|
@@ -1144,7 +1151,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
1144
1151
|
if (now - this._session.lastPingTime > this._pingInterval) {
|
|
1145
1152
|
if (!this._session.lastPingMsgId.isZero()) {
|
|
1146
1153
|
this.log.warn("didn't receive pong for previous ping (msg_id = %l). are we offline?", this._session.lastPingMsgId);
|
|
1147
|
-
this._resetSession();
|
|
1154
|
+
this._resetSession("ping timeout");
|
|
1148
1155
|
return;
|
|
1149
1156
|
}
|
|
1150
1157
|
pingId = longUtils.randomLong();
|
|
@@ -82,7 +82,7 @@ export declare class SessionConnection extends PersistentConnection {
|
|
|
82
82
|
private _onFutureSalts;
|
|
83
83
|
private _onDestroySessionResult;
|
|
84
84
|
private _enqueueRpc;
|
|
85
|
-
_resetSession(): void;
|
|
85
|
+
_resetSession(reason?: string): void;
|
|
86
86
|
private _sendAck;
|
|
87
87
|
sendRpc<T extends tl.RpcMethod>(request: T, timeout?: number, abortSignal?: AbortSignal, chainId?: string | number): Promise<tl.RpcCallReturn[T['_']]>;
|
|
88
88
|
notifyNetworkChanged(online: boolean): void;
|
|
@@ -82,7 +82,7 @@ export declare class SessionConnection extends PersistentConnection {
|
|
|
82
82
|
private _onFutureSalts;
|
|
83
83
|
private _onDestroySessionResult;
|
|
84
84
|
private _enqueueRpc;
|
|
85
|
-
_resetSession(): void;
|
|
85
|
+
_resetSession(reason?: string): void;
|
|
86
86
|
private _sendAck;
|
|
87
87
|
sendRpc<T extends tl.RpcMethod>(request: T, timeout?: number, abortSignal?: AbortSignal, chainId?: string | number): Promise<tl.RpcCallReturn[T['_']]>;
|
|
88
88
|
notifyNetworkChanged(online: boolean): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Emitter, timers, u8, Deferred } from "@fuman/utils";
|
|
2
2
|
import { tl } from "@mtcute/tl";
|
|
3
|
-
import { TlBinaryWriter, TlSerializationCounter, TlBinaryReader } from "@mtcute/tl-runtime";
|
|
3
|
+
import { TlBinaryWriter, TlSerializationCounter, TlUnknownObjectError, TlBinaryReader } from "@mtcute/tl-runtime";
|
|
4
4
|
import Long from "long";
|
|
5
5
|
import { createAesIgeForMessageOld } from "../utils/crypto/mtproto.js";
|
|
6
6
|
import { EarlyTimer } from "../utils/early-timer.js";
|
|
@@ -81,7 +81,7 @@ class SessionConnection extends PersistentConnection {
|
|
|
81
81
|
this._session._authKeyTemp.reset();
|
|
82
82
|
timers.clearTimeout(this._pfsUpdateTimeout);
|
|
83
83
|
}
|
|
84
|
-
this._resetSession();
|
|
84
|
+
this._resetSession("use pfs changed");
|
|
85
85
|
}
|
|
86
86
|
onClosed() {
|
|
87
87
|
Object.values(this._pendingWaitForUnencrypted).forEach(([prom, timeout]) => {
|
|
@@ -161,13 +161,13 @@ class SessionConnection extends PersistentConnection {
|
|
|
161
161
|
if (!this._triedReconnectingOn404) {
|
|
162
162
|
this.log.warn("transport error 404. trying to reconnect");
|
|
163
163
|
this._triedReconnectingOn404 = true;
|
|
164
|
-
this._resetSession();
|
|
164
|
+
this._resetSession("-404 reconnect");
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
this.log.warn("transport error 404, reauthorizing");
|
|
168
168
|
this.onError.emit(error);
|
|
169
169
|
this._session.resetAuthKey();
|
|
170
|
-
this._resetSession();
|
|
170
|
+
this._resetSession("-404 reconnect + reauth");
|
|
171
171
|
this.onKeyChange.emit(null);
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
@@ -363,6 +363,11 @@ class SessionConnection extends PersistentConnection {
|
|
|
363
363
|
try {
|
|
364
364
|
this._session.decryptMessage(data, this._handleRawMessage);
|
|
365
365
|
} catch (err) {
|
|
366
|
+
if (err instanceof TlUnknownObjectError) {
|
|
367
|
+
this.log.warn("received unknown object %s, reconnecting...", err.objectId.toString(16));
|
|
368
|
+
this._resetSession("unknown object");
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
366
371
|
this.log.error("failed to decrypt message: %s\ndata: %h", err, data);
|
|
367
372
|
}
|
|
368
373
|
}
|
|
@@ -648,6 +653,7 @@ class SessionConnection extends PersistentConnection {
|
|
|
648
653
|
case "bind":
|
|
649
654
|
case "cancel":
|
|
650
655
|
break;
|
|
656
|
+
// do nothing, wait for the result
|
|
651
657
|
default:
|
|
652
658
|
if (!inContainer) {
|
|
653
659
|
this.log.warn("received unexpected ack for %s query %l", msg._, msgId);
|
|
@@ -781,7 +787,7 @@ class SessionConnection extends PersistentConnection {
|
|
|
781
787
|
msg.badMsgId,
|
|
782
788
|
msg.errorCode
|
|
783
789
|
);
|
|
784
|
-
this._resetSession();
|
|
790
|
+
this._resetSession("bad_msg_notification");
|
|
785
791
|
break;
|
|
786
792
|
}
|
|
787
793
|
}
|
|
@@ -840,6 +846,7 @@ class SessionConnection extends PersistentConnection {
|
|
|
840
846
|
);
|
|
841
847
|
return this._onMessageFailed(msgId, "message info state = 0, ans_id = 0");
|
|
842
848
|
}
|
|
849
|
+
// fallthrough
|
|
843
850
|
case 4:
|
|
844
851
|
this._onMessageAcked(msgId);
|
|
845
852
|
break;
|
|
@@ -909,10 +916,10 @@ class SessionConnection extends PersistentConnection {
|
|
|
909
916
|
this._flushTimer.emitWhenIdle();
|
|
910
917
|
}
|
|
911
918
|
}
|
|
912
|
-
_resetSession() {
|
|
919
|
+
_resetSession(reason = "session reset") {
|
|
913
920
|
this._queuedDestroySession.push(this._session._sessionId);
|
|
914
921
|
this._session.resetState(true);
|
|
915
|
-
this._onAllFailed(
|
|
922
|
+
this._onAllFailed(reason);
|
|
916
923
|
this.reconnect();
|
|
917
924
|
this._flushTimer.reset();
|
|
918
925
|
}
|
|
@@ -1137,7 +1144,7 @@ class SessionConnection extends PersistentConnection {
|
|
|
1137
1144
|
if (now - this._session.lastPingTime > this._pingInterval) {
|
|
1138
1145
|
if (!this._session.lastPingMsgId.isZero()) {
|
|
1139
1146
|
this.log.warn("didn't receive pong for previous ping (msg_id = %l). are we offline?", this._session.lastPingMsgId);
|
|
1140
|
-
this._resetSession();
|
|
1147
|
+
this._resetSession("ping timeout");
|
|
1141
1148
|
return;
|
|
1142
1149
|
}
|
|
1143
1150
|
pingId = randomLong();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.22.0",
|
|
5
5
|
"description": "Type-safe library for MTProto (Telegram API)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"@fuman/io": "0.0.8",
|
|
10
10
|
"@fuman/net": "0.0.9",
|
|
11
11
|
"@fuman/utils": "0.0.4",
|
|
12
|
-
"@mtcute/file-id": "^0.
|
|
13
|
-
"@mtcute/tl": "^
|
|
14
|
-
"@mtcute/tl-runtime": "^0.
|
|
12
|
+
"@mtcute/file-id": "^0.22.0",
|
|
13
|
+
"@mtcute/tl": "^200.0.0",
|
|
14
|
+
"@mtcute/tl-runtime": "^0.22.0",
|
|
15
15
|
"@types/events": "3.0.0",
|
|
16
16
|
"long": "5.2.3"
|
|
17
17
|
},
|
|
@@ -33,9 +33,9 @@ class MemoryPeersRepository {
|
|
|
33
33
|
if (peer.phone) this.state.phoneIndex.set(peer.phone, peer.id);
|
|
34
34
|
this.state.entities.set(peer.id, peer);
|
|
35
35
|
}
|
|
36
|
-
getById(id
|
|
36
|
+
getById(id) {
|
|
37
37
|
const ent = this.state.entities.get(id);
|
|
38
|
-
if (!ent
|
|
38
|
+
if (!ent) return null;
|
|
39
39
|
return ent;
|
|
40
40
|
}
|
|
41
41
|
getByUsername(username) {
|
|
@@ -10,7 +10,7 @@ export declare class MemoryPeersRepository implements IPeersRepository {
|
|
|
10
10
|
readonly state: PeersState;
|
|
11
11
|
constructor(_driver: MemoryStorageDriver);
|
|
12
12
|
store(peer: IPeersRepository.PeerInfo): void;
|
|
13
|
-
getById(id: number
|
|
13
|
+
getById(id: number): IPeersRepository.PeerInfo | null;
|
|
14
14
|
getByUsername(username: string): IPeersRepository.PeerInfo | null;
|
|
15
15
|
getByPhone(phone: string): IPeersRepository.PeerInfo | null;
|
|
16
16
|
deleteAll(): void;
|
|
@@ -10,7 +10,7 @@ export declare class MemoryPeersRepository implements IPeersRepository {
|
|
|
10
10
|
readonly state: PeersState;
|
|
11
11
|
constructor(_driver: MemoryStorageDriver);
|
|
12
12
|
store(peer: IPeersRepository.PeerInfo): void;
|
|
13
|
-
getById(id: number
|
|
13
|
+
getById(id: number): IPeersRepository.PeerInfo | null;
|
|
14
14
|
getByUsername(username: string): IPeersRepository.PeerInfo | null;
|
|
15
15
|
getByPhone(phone: string): IPeersRepository.PeerInfo | null;
|
|
16
16
|
deleteAll(): void;
|