@mtcute/core 0.18.0-rc.5 → 0.19.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.d.cts +1 -0
- package/highlevel/base.d.cts +115 -0
- package/highlevel/base.test.d.cts +1 -0
- package/highlevel/client.d.cts +5045 -0
- package/highlevel/client.types.d.cts +61 -0
- package/highlevel/index.d.cts +4 -0
- package/highlevel/managers/app-config-manager.d.cts +11 -0
- package/highlevel/managers/timers.d.cts +10 -0
- package/highlevel/methods/_imports.d.cts +1 -0
- package/highlevel/methods/_init.d.cts +1 -0
- package/highlevel/methods/auth/check-password.d.cts +10 -0
- package/highlevel/methods/auth/get-password-hint.d.cts +7 -0
- package/highlevel/methods/auth/log-out.d.cts +17 -0
- package/highlevel/methods/auth/recover-password.d.cts +12 -0
- package/highlevel/methods/auth/resend-code.d.cts +16 -0
- package/highlevel/methods/auth/run.d.cts +16 -0
- package/highlevel/methods/auth/send-code.d.cts +18 -0
- package/highlevel/methods/auth/send-recovery-code.d.cts +7 -0
- package/highlevel/methods/auth/sign-in-bot.d.cts +10 -0
- package/highlevel/methods/auth/sign-in-qr.d.cts +33 -0
- package/highlevel/methods/auth/sign-in.d.cts +19 -0
- package/highlevel/methods/auth/start-test.d.cts +30 -0
- package/highlevel/methods/auth/start.d.cts +89 -0
- package/highlevel/methods/auth/utils.d.cts +9 -0
- package/highlevel/methods/bots/answer-callback-query.d.cts +41 -0
- package/highlevel/methods/bots/answer-inline-query.d.cts +88 -0
- package/highlevel/methods/bots/answer-pre-checkout-query.d.cts +12 -0
- package/highlevel/methods/bots/delete-my-commands.d.cts +22 -0
- package/highlevel/methods/bots/get-bot-info.d.cts +18 -0
- package/highlevel/methods/bots/get-bot-menu-button.d.cts +7 -0
- package/highlevel/methods/bots/get-callback-answer.d.cts +41 -0
- package/highlevel/methods/bots/get-game-high-scores.d.cts +17 -0
- package/highlevel/methods/bots/get-my-commands.d.cts +21 -0
- package/highlevel/methods/bots/normalize-command-scope.d.cts +5 -0
- package/highlevel/methods/bots/open-webview.d.cts +73 -0
- package/highlevel/methods/bots/prepare-inline-message.d.cts +32 -0
- package/highlevel/methods/bots/set-bot-info.d.cts +23 -0
- package/highlevel/methods/bots/set-bot-menu-button.d.cts +7 -0
- package/highlevel/methods/bots/set-game-score.d.cts +54 -0
- package/highlevel/methods/bots/set-my-commands.d.cts +26 -0
- package/highlevel/methods/bots/set-my-default-rights.d.cts +11 -0
- package/highlevel/methods/bots/toggle-emoji-status-permission.d.cts +11 -0
- package/highlevel/methods/chats/add-chat-members.d.cts +20 -0
- package/highlevel/methods/chats/archive-chats.d.cts +9 -0
- package/highlevel/methods/chats/ban-chat-member.d.cts +24 -0
- package/highlevel/methods/chats/batched-queries.d.cts +11 -0
- package/highlevel/methods/chats/create-channel.d.cts +17 -0
- package/highlevel/methods/chats/create-group.d.cts +33 -0
- package/highlevel/methods/chats/create-supergroup.d.cts +27 -0
- package/highlevel/methods/chats/delete-channel.d.cts +8 -0
- package/highlevel/methods/chats/delete-chat-photo.d.cts +10 -0
- package/highlevel/methods/chats/delete-group.d.cts +8 -0
- package/highlevel/methods/chats/delete-history.d.cts +22 -0
- package/highlevel/methods/chats/delete-user-history.d.cts +16 -0
- package/highlevel/methods/chats/edit-admin-rights.d.cts +16 -0
- package/highlevel/methods/chats/get-chat-event-log.d.cts +61 -0
- package/highlevel/methods/chats/get-chat-member.d.cts +15 -0
- package/highlevel/methods/chats/get-chat-members.d.cts +51 -0
- package/highlevel/methods/chats/get-chat-preview.d.cts +12 -0
- package/highlevel/methods/chats/get-chat.d.cts +11 -0
- package/highlevel/methods/chats/get-full-chat.d.cts +11 -0
- package/highlevel/methods/chats/get-full-user.d.cts +8 -0
- package/highlevel/methods/chats/get-nearby-chats.d.cts +9 -0
- package/highlevel/methods/chats/get-similar-channels.d.cts +12 -0
- package/highlevel/methods/chats/get-user.d.cts +8 -0
- package/highlevel/methods/chats/iter-chat-event-log.d.cts +26 -0
- package/highlevel/methods/chats/iter-chat-members.d.cts +22 -0
- package/highlevel/methods/chats/join-chat.d.cts +14 -0
- package/highlevel/methods/chats/kick-chat-member.d.cts +15 -0
- package/highlevel/methods/chats/leave-chat.d.cts +13 -0
- package/highlevel/methods/chats/mark-chat-unread.d.cts +8 -0
- package/highlevel/methods/chats/open-chat.d.cts +26 -0
- package/highlevel/methods/chats/reorder-usernames.d.cts +8 -0
- package/highlevel/methods/chats/restrict-chat-member.d.cts +28 -0
- package/highlevel/methods/chats/save-draft.d.cts +10 -0
- package/highlevel/methods/chats/set-chat-color.d.cts +38 -0
- package/highlevel/methods/chats/set-chat-default-permissions.d.cts +16 -0
- package/highlevel/methods/chats/set-chat-description.d.cts +11 -0
- package/highlevel/methods/chats/set-chat-photo.d.cts +20 -0
- package/highlevel/methods/chats/set-chat-title.d.cts +11 -0
- package/highlevel/methods/chats/set-chat-ttl.d.cts +9 -0
- package/highlevel/methods/chats/set-chat-username.d.cts +11 -0
- package/highlevel/methods/chats/set-slow-mode.d.cts +12 -0
- package/highlevel/methods/chats/toggle-content-protection.d.cts +9 -0
- package/highlevel/methods/chats/toggle-fragment-username.d.cts +20 -0
- package/highlevel/methods/chats/toggle-join-requests.d.cts +12 -0
- package/highlevel/methods/chats/toggle-join-to-send.d.cts +12 -0
- package/highlevel/methods/chats/unarchive-chats.d.cts +9 -0
- package/highlevel/methods/chats/unban-chat-member.d.cts +16 -0
- package/highlevel/methods/contacts/add-contact.d.cts +28 -0
- package/highlevel/methods/contacts/delete-contacts.d.cts +12 -0
- package/highlevel/methods/contacts/get-contacts.d.cts +6 -0
- package/highlevel/methods/contacts/import-contacts.d.cts +9 -0
- package/highlevel/methods/dialogs/create-folder.d.cts +13 -0
- package/highlevel/methods/dialogs/delete-folder.d.cts +8 -0
- package/highlevel/methods/dialogs/edit-folder.d.cts +18 -0
- package/highlevel/methods/dialogs/find-dialogs.d.cts +12 -0
- package/highlevel/methods/dialogs/find-folder.d.cts +19 -0
- package/highlevel/methods/dialogs/get-chatlist-preview.d.cts +8 -0
- package/highlevel/methods/dialogs/get-folders.d.cts +9 -0
- package/highlevel/methods/dialogs/get-peer-dialogs.d.cts +10 -0
- package/highlevel/methods/dialogs/iter-dialogs.d.cts +103 -0
- package/highlevel/methods/dialogs/join-chatlist.d.cts +15 -0
- package/highlevel/methods/dialogs/set-folders-order.d.cts +7 -0
- package/highlevel/methods/files/download-buffer.d.cts +11 -0
- package/highlevel/methods/files/download-file.d.cts +1 -0
- package/highlevel/methods/files/download-iterable.cjs +9 -7
- package/highlevel/methods/files/download-iterable.d.cts +10 -0
- package/highlevel/methods/files/download-iterable.js +9 -7
- package/highlevel/methods/files/download-node-stream.d.cts +1 -0
- package/highlevel/methods/files/download-stream.d.cts +9 -0
- package/highlevel/methods/files/normalize-file-to-document.d.cts +9 -0
- package/highlevel/methods/files/normalize-input-file.d.cts +13 -0
- package/highlevel/methods/files/normalize-input-media.d.cts +12 -0
- package/highlevel/methods/files/upload-file.d.cts +72 -0
- package/highlevel/methods/files/upload-media.d.cts +28 -0
- package/highlevel/methods/forums/create-forum-topic.d.cts +36 -0
- package/highlevel/methods/forums/delete-forum-topic-history.d.cts +15 -0
- package/highlevel/methods/forums/edit-forum-topic.d.cts +34 -0
- package/highlevel/methods/forums/get-forum-topics-by-id.d.cts +9 -0
- package/highlevel/methods/forums/get-forum-topics.d.cts +28 -0
- package/highlevel/methods/forums/iter-forum-topics.d.cts +20 -0
- package/highlevel/methods/forums/reorder-pinned-forum-topics.d.cts +19 -0
- package/highlevel/methods/forums/toggle-forum-topic-closed.d.cts +22 -0
- package/highlevel/methods/forums/toggle-forum-topic-pinned.d.cts +15 -0
- package/highlevel/methods/forums/toggle-forum.d.cts +11 -0
- package/highlevel/methods/forums/toggle-general-topic-hidden.d.cts +20 -0
- package/highlevel/methods/invite-links/create-invite-link.d.cts +38 -0
- package/highlevel/methods/invite-links/edit-invite-link.d.cts +36 -0
- package/highlevel/methods/invite-links/export-invite-link.d.cts +12 -0
- package/highlevel/methods/invite-links/get-invite-link-members.d.cts +45 -0
- package/highlevel/methods/invite-links/get-invite-link.d.cts +9 -0
- package/highlevel/methods/invite-links/get-invite-links.d.cts +39 -0
- package/highlevel/methods/invite-links/get-primary-invite-link.d.cts +8 -0
- package/highlevel/methods/invite-links/hide-all-join-requests.d.cts +13 -0
- package/highlevel/methods/invite-links/hide-join-request.d.cts +13 -0
- package/highlevel/methods/invite-links/iter-invite-link-members.d.cts +25 -0
- package/highlevel/methods/invite-links/iter-invite-links.d.cts +27 -0
- package/highlevel/methods/invite-links/revoke-invite-link.d.cts +13 -0
- package/highlevel/methods/messages/_business-connection.d.cts +8 -0
- package/highlevel/methods/messages/close-poll.d.cts +15 -0
- package/highlevel/methods/messages/delete-messages.d.cts +29 -0
- package/highlevel/methods/messages/delete-scheduled-messages.d.cts +9 -0
- package/highlevel/methods/messages/edit-inline-message.d.cts +51 -0
- package/highlevel/methods/messages/edit-message.d.cts +55 -0
- package/highlevel/methods/messages/find-in-update.d.cts +13 -0
- package/highlevel/methods/messages/forward-messages.d.cts +84 -0
- package/highlevel/methods/messages/get-all-scheduled-messages.d.cts +8 -0
- package/highlevel/methods/messages/get-available-effects.d.cts +6 -0
- package/highlevel/methods/messages/get-callback-query-message.d.cts +14 -0
- package/highlevel/methods/messages/get-discussion-message.d.cts +21 -0
- package/highlevel/methods/messages/get-fact-check.d.cts +11 -0
- package/highlevel/methods/messages/get-history.d.cts +59 -0
- package/highlevel/methods/messages/get-message-by-link.d.cts +6 -0
- package/highlevel/methods/messages/get-message-group.d.cts +9 -0
- package/highlevel/methods/messages/get-message-reactions.d.cts +28 -0
- package/highlevel/methods/messages/get-messages-unsafe.d.cts +19 -0
- package/highlevel/methods/messages/get-messages.d.cts +17 -0
- package/highlevel/methods/messages/get-reaction-users.d.cts +24 -0
- package/highlevel/methods/messages/get-reply-to.d.cts +10 -0
- package/highlevel/methods/messages/get-scheduled-messages.d.cts +13 -0
- package/highlevel/methods/messages/iter-history.d.cts +23 -0
- package/highlevel/methods/messages/iter-reaction-users.d.cts +26 -0
- package/highlevel/methods/messages/iter-search-global.d.cts +27 -0
- package/highlevel/methods/messages/iter-search-messages.d.cts +26 -0
- package/highlevel/methods/messages/pin-message.d.cts +21 -0
- package/highlevel/methods/messages/read-history.d.cts +24 -0
- package/highlevel/methods/messages/read-reactions.d.cts +14 -0
- package/highlevel/methods/messages/search-global.d.cts +51 -0
- package/highlevel/methods/messages/search-hashtag.d.cts +44 -0
- package/highlevel/methods/messages/search-messages.d.cts +93 -0
- package/highlevel/methods/messages/send-answer.d.cts +12 -0
- package/highlevel/methods/messages/send-comment.d.cts +39 -0
- package/highlevel/methods/messages/send-common.d.cts +122 -0
- package/highlevel/methods/messages/send-copy-group.d.cts +21 -0
- package/highlevel/methods/messages/send-copy.d.cts +32 -0
- package/highlevel/methods/messages/send-media-group.d.cts +35 -0
- package/highlevel/methods/messages/send-media.d.cts +48 -0
- package/highlevel/methods/messages/send-paid-reaction.d.cts +24 -0
- package/highlevel/methods/messages/send-quote.d.cts +33 -0
- package/highlevel/methods/messages/send-reaction.d.cts +21 -0
- package/highlevel/methods/messages/send-reply.d.cts +12 -0
- package/highlevel/methods/messages/send-scheduled.d.cts +14 -0
- package/highlevel/methods/messages/send-text.d.cts +31 -0
- package/highlevel/methods/messages/send-text.test.d.cts +1 -0
- package/highlevel/methods/messages/send-typing.d.cts +32 -0
- package/highlevel/methods/messages/send-vote.d.cts +15 -0
- package/highlevel/methods/messages/set-typing.d.cts +33 -0
- package/highlevel/methods/messages/translate-message.d.cts +11 -0
- package/highlevel/methods/messages/translate-text.d.cts +9 -0
- package/highlevel/methods/messages/unpin-all-messages.d.cts +18 -0
- package/highlevel/methods/messages/unpin-message.d.cts +12 -0
- package/highlevel/methods/misc/chain-id.d.cts +4 -0
- package/highlevel/methods/misc/get-collectible-info.d.cts +6 -0
- package/highlevel/methods/misc/init-takeout-session.d.cts +9 -0
- package/highlevel/methods/misc/normalize-privacy-rules.d.cts +8 -0
- package/highlevel/methods/misc/normalize-text.d.cts +5 -0
- package/highlevel/methods/misc/with-params.d.cts +10 -0
- package/highlevel/methods/password/change-cloud-password.d.cts +12 -0
- package/highlevel/methods/password/enable-cloud-password.d.cts +17 -0
- package/highlevel/methods/password/password-email.d.cts +15 -0
- package/highlevel/methods/password/remove-cloud-password.d.cts +7 -0
- package/highlevel/methods/premium/accept-star-gift.d.cts +16 -0
- package/highlevel/methods/premium/apply-boost.d.cts +8 -0
- package/highlevel/methods/premium/can-apply-boost.d.cts +29 -0
- package/highlevel/methods/premium/create-business-chat-link.d.cts +12 -0
- package/highlevel/methods/premium/edit-business-chat-link.d.cts +20 -0
- package/highlevel/methods/premium/get-boost-stats.d.cts +9 -0
- package/highlevel/methods/premium/get-boosts.d.cts +18 -0
- package/highlevel/methods/premium/get-business-chat-links.d.cts +6 -0
- package/highlevel/methods/premium/get-business-connection.d.cts +8 -0
- package/highlevel/methods/premium/get-my-boost-slots.d.cts +9 -0
- package/highlevel/methods/premium/get-star-gift-options.d.cts +6 -0
- package/highlevel/methods/premium/get-star-gifts.d.cts +22 -0
- package/highlevel/methods/premium/get-stars-transactions.d.cts +34 -0
- package/highlevel/methods/premium/iter-boosters.d.cts +24 -0
- package/highlevel/methods/premium/iter-star-gifts.d.cts +26 -0
- package/highlevel/methods/premium/iter-stars-transactions.d.cts +29 -0
- package/highlevel/methods/premium/send-star-gift.d.cts +35 -0
- package/highlevel/methods/premium/set-business-intro.d.cts +22 -0
- package/highlevel/methods/premium/set-business-work-hours.d.cts +18 -0
- package/highlevel/methods/stickers/_utils.d.cts +10 -0
- package/highlevel/methods/stickers/add-sticker-to-set.d.cts +21 -0
- package/highlevel/methods/stickers/create-sticker-set.d.cts +66 -0
- package/highlevel/methods/stickers/delete-sticker-from-set.d.cts +15 -0
- package/highlevel/methods/stickers/get-custom-emojis.d.cts +14 -0
- package/highlevel/methods/stickers/get-installed-stickers.d.cts +10 -0
- package/highlevel/methods/stickers/get-my-sticker-sets.d.cts +13 -0
- package/highlevel/methods/stickers/get-sticker-set.d.cts +8 -0
- package/highlevel/methods/stickers/move-sticker-in-set.d.cts +17 -0
- package/highlevel/methods/stickers/replace-sticker-in-set.d.cts +24 -0
- package/highlevel/methods/stickers/set-chat-sticker-set.d.cts +11 -0
- package/highlevel/methods/stickers/set-sticker-set-thumb.d.cts +20 -0
- package/highlevel/methods/stories/can-send-story.d.cts +13 -0
- package/highlevel/methods/stories/delete-stories.d.cts +20 -0
- package/highlevel/methods/stories/edit-story.d.cts +38 -0
- package/highlevel/methods/stories/find-in-update.d.cts +5 -0
- package/highlevel/methods/stories/get-all-stories.d.cts +15 -0
- package/highlevel/methods/stories/get-peer-stories.d.cts +8 -0
- package/highlevel/methods/stories/get-profile-stories.d.cts +25 -0
- package/highlevel/methods/stories/get-stories-by-id.d.cts +10 -0
- package/highlevel/methods/stories/get-stories-interactions.d.cts +9 -0
- package/highlevel/methods/stories/get-story-link.d.cts +11 -0
- package/highlevel/methods/stories/get-story-viewers.d.cts +33 -0
- package/highlevel/methods/stories/hide-my-stories-views.d.cts +21 -0
- package/highlevel/methods/stories/increment-stories-views.d.cts +13 -0
- package/highlevel/methods/stories/iter-all-stories.d.cts +16 -0
- package/highlevel/methods/stories/iter-profile-stories.d.cts +21 -0
- package/highlevel/methods/stories/iter-story-viewers.d.cts +22 -0
- package/highlevel/methods/stories/read-stories.d.cts +11 -0
- package/highlevel/methods/stories/send-story-reaction.d.cts +14 -0
- package/highlevel/methods/stories/send-story.d.cts +51 -0
- package/highlevel/methods/stories/toggle-peer-stories-archived.d.cts +8 -0
- package/highlevel/methods/stories/toggle-stories-pinned.d.cts +24 -0
- package/highlevel/methods/users/block-user.d.cts +8 -0
- package/highlevel/methods/users/delete-profile-photos.d.cts +9 -0
- package/highlevel/methods/users/edit-close-friends.d.cts +14 -0
- package/highlevel/methods/users/get-common-chats.d.cts +9 -0
- package/highlevel/methods/users/get-global-ttl.d.cts +5 -0
- package/highlevel/methods/users/get-me.d.cts +6 -0
- package/highlevel/methods/users/get-my-username.d.cts +8 -0
- package/highlevel/methods/users/get-profile-photo.d.cts +11 -0
- package/highlevel/methods/users/get-profile-photos.d.cts +22 -0
- package/highlevel/methods/users/get-users.d.cts +12 -0
- package/highlevel/methods/users/get-users.test.d.cts +1 -0
- package/highlevel/methods/users/is-peer-available.d.cts +20 -0
- package/highlevel/methods/users/iter-profile-photos.d.cts +23 -0
- package/highlevel/methods/users/resolve-peer-many.d.cts +26 -0
- package/highlevel/methods/users/resolve-peer.d.cts +20 -0
- package/highlevel/methods/users/resolve-peer.test.d.cts +1 -0
- package/highlevel/methods/users/set-emoji-status.d.cts +32 -0
- package/highlevel/methods/users/set-global-ttl.d.cts +8 -0
- package/highlevel/methods/users/set-my-birthday.d.cts +12 -0
- package/highlevel/methods/users/set-my-profile-photo.d.cts +16 -0
- package/highlevel/methods/users/set-my-username.d.cts +11 -0
- package/highlevel/methods/users/set-online.d.cts +19 -0
- package/highlevel/methods/users/unblock-user.d.cts +8 -0
- package/highlevel/methods/users/update-profile.d.cts +23 -0
- package/highlevel/methods.d.cts +291 -0
- package/highlevel/storage/index.d.cts +4 -0
- package/highlevel/storage/provider.d.cts +7 -0
- package/highlevel/storage/repository/peers.d.cts +44 -0
- package/highlevel/storage/repository/ref-messages.d.cts +20 -0
- package/highlevel/storage/service/current-user.d.cts +23 -0
- package/highlevel/storage/service/peers.d.cts +23 -0
- package/highlevel/storage/service/ref-messages.d.cts +15 -0
- package/highlevel/storage/service/updates.d.cts +16 -0
- package/highlevel/storage/storage.d.cts +27 -0
- package/highlevel/types/auth/index.d.cts +1 -0
- package/highlevel/types/auth/sent-code.d.cts +56 -0
- package/highlevel/types/bots/command-scope/index.d.cts +10 -0
- package/highlevel/types/bots/command-scope/inner.d.cts +54 -0
- package/highlevel/types/bots/game-high-score.d.cts +23 -0
- package/highlevel/types/bots/index.d.cts +6 -0
- package/highlevel/types/bots/inline-message/factories.d.cts +47 -0
- package/highlevel/types/bots/inline-message/index.d.cts +3 -0
- package/highlevel/types/bots/inline-message/types.d.cts +114 -0
- package/highlevel/types/bots/inline-result/factories.d.cts +97 -0
- package/highlevel/types/bots/inline-result/index.d.cts +3 -0
- package/highlevel/types/bots/inline-result/types.d.cts +417 -0
- package/highlevel/types/bots/keyboards/builder.d.cts +38 -0
- package/highlevel/types/bots/keyboards/builder.test.d.cts +1 -0
- package/highlevel/types/bots/keyboards/factories.d.cts +208 -0
- package/highlevel/types/bots/keyboards/index.d.cts +15 -0
- package/highlevel/types/bots/keyboards/keyboards.test.d.cts +1 -0
- package/highlevel/types/bots/keyboards/types.d.cts +34 -0
- package/highlevel/types/bots/webview.d.cts +114 -0
- package/highlevel/types/calls/discard-reason.d.cts +13 -0
- package/highlevel/types/calls/index.d.cts +1 -0
- package/highlevel/types/conversation.d.cts +210 -0
- package/highlevel/types/errors.d.cts +33 -0
- package/highlevel/types/files/file-location.d.cts +48 -0
- package/highlevel/types/files/index.d.cts +4 -0
- package/highlevel/types/files/uploaded-file.d.cts +24 -0
- package/highlevel/types/files/utils.d.cts +89 -0
- package/highlevel/types/files/web-document.d.cts +32 -0
- package/highlevel/types/index.d.cts +15 -0
- package/highlevel/types/media/audio.d.cts +31 -0
- package/highlevel/types/media/contact.d.cts +31 -0
- package/highlevel/types/media/dice.d.cts +155 -0
- package/highlevel/types/media/document-utils.d.cts +11 -0
- package/highlevel/types/media/document.d.cts +75 -0
- package/highlevel/types/media/extended-media.d.cts +20 -0
- package/highlevel/types/media/game.d.cts +38 -0
- package/highlevel/types/media/index.d.cts +19 -0
- package/highlevel/types/media/input-media/factories.d.cts +142 -0
- package/highlevel/types/media/input-media/index.d.cts +3 -0
- package/highlevel/types/media/input-media/types.d.cts +520 -0
- package/highlevel/types/media/invoice.d.cts +89 -0
- package/highlevel/types/media/location.d.cts +83 -0
- package/highlevel/types/media/paid-media.d.cts +33 -0
- package/highlevel/types/media/photo.d.cts +72 -0
- package/highlevel/types/media/poll.d.cts +110 -0
- package/highlevel/types/media/sticker.d.cts +123 -0
- package/highlevel/types/media/story.d.cts +33 -0
- package/highlevel/types/media/thumbnail.d.cts +70 -0
- package/highlevel/types/media/venue.d.cts +58 -0
- package/highlevel/types/media/video.d.cts +48 -0
- package/highlevel/types/media/voice.d.cts +23 -0
- package/highlevel/types/media/web-page.d.cts +151 -0
- package/highlevel/types/messages/dialog.d.cts +110 -0
- package/highlevel/types/messages/draft-message.d.cts +29 -0
- package/highlevel/types/messages/fact-check.d.cts +30 -0
- package/highlevel/types/messages/index.d.cts +14 -0
- package/highlevel/types/messages/input-message-id.d.cts +20 -0
- package/highlevel/types/messages/message-action.d.cts +420 -0
- package/highlevel/types/messages/message-effect.d.cts +20 -0
- package/highlevel/types/messages/message-entity.d.cts +89 -0
- package/highlevel/types/messages/message-forward.d.cts +39 -0
- package/highlevel/types/messages/message-media.d.cts +23 -0
- package/highlevel/types/messages/message-reactions.d.cts +31 -0
- package/highlevel/types/messages/message-replies.d.cts +42 -0
- package/highlevel/types/messages/message.d.cts +249 -0
- package/highlevel/types/messages/replied-message.d.cts +103 -0
- package/highlevel/types/messages/search-filters.d.cts +82 -0
- package/highlevel/types/misc/app-config.d.cts +887 -0
- package/highlevel/types/misc/collectible-info.d.cts +27 -0
- package/highlevel/types/misc/entities.d.cts +22 -0
- package/highlevel/types/misc/index.d.cts +6 -0
- package/highlevel/types/misc/input-privacy-rule/allow.d.cts +22 -0
- package/highlevel/types/misc/input-privacy-rule/bundle.d.cts +3 -0
- package/highlevel/types/misc/input-privacy-rule/disallow.d.cts +20 -0
- package/highlevel/types/misc/input-privacy-rule/index.d.cts +3 -0
- package/highlevel/types/misc/input-privacy-rule/types.d.cts +11 -0
- package/highlevel/types/misc/sticker-set.d.cts +154 -0
- package/highlevel/types/misc/takeout-session.d.cts +49 -0
- package/highlevel/types/peers/bot-info.d.cts +21 -0
- package/highlevel/types/peers/chat-colors.d.cts +25 -0
- package/highlevel/types/peers/chat-event/actions.d.cts +279 -0
- package/highlevel/types/peers/chat-event/filters.d.cts +10 -0
- package/highlevel/types/peers/chat-event/index.d.cts +27 -0
- package/highlevel/types/peers/chat-invite-link-member.d.cts +33 -0
- package/highlevel/types/peers/chat-invite-link.d.cts +72 -0
- package/highlevel/types/peers/chat-location.d.cts +17 -0
- package/highlevel/types/peers/chat-member.d.cts +86 -0
- package/highlevel/types/peers/chat-permissions.d.cts +127 -0
- package/highlevel/types/peers/chat-photo.d.cts +39 -0
- package/highlevel/types/peers/chat-preview.d.cts +55 -0
- package/highlevel/types/peers/chat.d.cts +250 -0
- package/highlevel/types/peers/chatlist-preview.d.cts +21 -0
- package/highlevel/types/peers/forum-topic.d.cts +96 -0
- package/highlevel/types/peers/full-chat.cjs +1 -1
- package/highlevel/types/peers/full-chat.d.cts +161 -0
- package/highlevel/types/peers/full-chat.js +1 -1
- package/highlevel/types/peers/full-user.d.cts +115 -0
- package/highlevel/types/peers/index.d.cts +19 -0
- package/highlevel/types/peers/index.d.ts +1 -0
- package/highlevel/types/peers/peer.d.cts +49 -0
- package/highlevel/types/peers/peers-index.d.cts +15 -0
- package/highlevel/types/peers/peers-index.test.d.cts +1 -0
- package/highlevel/types/peers/typing-status.d.cts +26 -0
- package/highlevel/types/peers/user.d.cts +268 -0
- package/highlevel/types/peers/user.test.d.cts +1 -0
- package/highlevel/types/premium/boost-slot.d.cts +37 -0
- package/highlevel/types/premium/boost-stats.d.cts +54 -0
- package/highlevel/types/premium/boost.d.cts +56 -0
- package/highlevel/types/premium/boost.d.ts +1 -2
- package/highlevel/types/premium/business-account.d.cts +19 -0
- package/highlevel/types/premium/business-chat-link.d.cts +19 -0
- package/highlevel/types/premium/business-connection.d.cts +23 -0
- package/highlevel/types/premium/business-intro.d.cts +22 -0
- package/highlevel/types/premium/business-location.d.cts +10 -0
- package/highlevel/types/premium/business-work-hours.d.cts +42 -0
- package/highlevel/types/premium/business-work-hours.test.d.cts +1 -0
- package/highlevel/types/premium/index.d.cts +12 -0
- package/highlevel/types/premium/index.d.ts +1 -0
- package/highlevel/types/premium/stars-gift.d.cts +68 -0
- package/highlevel/types/premium/stars-status.d.cts +16 -0
- package/highlevel/types/premium/stars-status.d.ts +1 -1
- package/highlevel/types/premium/stars-transaction.cjs +7 -3
- package/highlevel/types/premium/stars-transaction.d.cts +134 -0
- package/highlevel/types/premium/stars-transaction.d.ts +1 -1
- package/highlevel/types/premium/stars-transaction.js +7 -3
- package/highlevel/types/reactions/emoji-status.d.cts +12 -0
- package/highlevel/types/reactions/index.d.cts +4 -0
- package/highlevel/types/reactions/index.d.ts +2 -0
- package/highlevel/types/reactions/peer-reaction.d.cts +53 -0
- package/highlevel/types/reactions/reaction-count.d.cts +25 -0
- package/highlevel/types/reactions/types.d.cts +16 -0
- package/highlevel/types/stories/all-stories.d.cts +28 -0
- package/highlevel/types/stories/index.d.cts +7 -0
- package/highlevel/types/stories/interactive/base.d.cts +16 -0
- package/highlevel/types/stories/interactive/channel-post.d.cts +17 -0
- package/highlevel/types/stories/interactive/index.d.cts +12 -0
- package/highlevel/types/stories/interactive/input.d.cts +68 -0
- package/highlevel/types/stories/interactive/location.d.cts +15 -0
- package/highlevel/types/stories/interactive/reaction.d.cts +21 -0
- package/highlevel/types/stories/interactive/url.d.cts +11 -0
- package/highlevel/types/stories/interactive/venue.d.cts +28 -0
- package/highlevel/types/stories/interactive/weather.d.cts +15 -0
- package/highlevel/types/stories/peer-stories.d.cts +20 -0
- package/highlevel/types/stories/stealth-mode.d.cts +9 -0
- package/highlevel/types/stories/story-interactions.d.cts +34 -0
- package/highlevel/types/stories/story-viewer.d.cts +75 -0
- package/highlevel/types/stories/story.d.cts +79 -0
- package/highlevel/types/updates/bot-chat-join-request.d.cts +42 -0
- package/highlevel/types/updates/bot-reaction.d.cts +71 -0
- package/highlevel/types/updates/bot-stopped.d.cts +28 -0
- package/highlevel/types/updates/business-message.d.cts +18 -0
- package/highlevel/types/updates/callback-query.d.cts +95 -0
- package/highlevel/types/updates/chat-join-request.d.cts +30 -0
- package/highlevel/types/updates/chat-member-update.cjs +1 -0
- package/highlevel/types/updates/chat-member-update.d.cts +76 -0
- package/highlevel/types/updates/chat-member-update.js +1 -0
- package/highlevel/types/updates/chosen-inline-result.d.cts +50 -0
- package/highlevel/types/updates/delete-business-message-update.d.cts +21 -0
- package/highlevel/types/updates/delete-message-update.d.cts +16 -0
- package/highlevel/types/updates/delete-story-update.d.cts +18 -0
- package/highlevel/types/updates/history-read-update.d.cts +39 -0
- package/highlevel/types/updates/index.d.cts +107 -0
- package/highlevel/types/updates/inline-query.d.cts +42 -0
- package/highlevel/types/updates/parse-update.d.cts +4 -0
- package/highlevel/types/updates/poll-update.d.cts +39 -0
- package/highlevel/types/updates/poll-vote.d.cts +52 -0
- package/highlevel/types/updates/pre-checkout-query.d.cts +36 -0
- package/highlevel/types/updates/story-update.d.cts +22 -0
- package/highlevel/types/updates/user-status-update.d.cts +28 -0
- package/highlevel/types/updates/user-typing-update.d.cts +31 -0
- package/highlevel/types/utils.d.cts +12 -0
- package/highlevel/updates/index.d.cts +2 -0
- package/highlevel/updates/manager.d.cts +121 -0
- package/highlevel/updates/parsed.d.cts +26 -0
- package/highlevel/updates/types.d.cts +147 -0
- package/highlevel/updates/utils.d.cts +21 -0
- package/highlevel/utils/convert-file-id.d.cts +46 -0
- package/highlevel/utils/entities.d.cts +19 -0
- package/highlevel/utils/entities.test.d.cts +1 -0
- package/highlevel/utils/file-type.d.cts +2 -0
- package/highlevel/utils/file-type.test.d.cts +1 -0
- package/highlevel/utils/file-utils.d.cts +31 -0
- package/highlevel/utils/file-utils.test.d.cts +1 -0
- package/highlevel/utils/index.d.cts +11 -0
- package/highlevel/utils/inline-utils.d.cts +14 -0
- package/highlevel/utils/inline-utils.test.d.cts +1 -0
- package/highlevel/utils/inspectable.d.cts +9 -0
- package/highlevel/utils/inspectable.test.d.cts +1 -0
- package/highlevel/utils/memoize.d.cts +1 -0
- package/highlevel/utils/memoize.test.d.cts +1 -0
- package/highlevel/utils/misc-utils.d.cts +12 -0
- package/highlevel/utils/peer-utils.d.cts +11 -0
- package/highlevel/utils/peer-utils.test.d.cts +1 -0
- package/highlevel/utils/query-batcher.d.cts +49 -0
- package/highlevel/utils/query-batcher.test.d.cts +1 -0
- package/highlevel/utils/rps-meter.d.cts +9 -0
- package/highlevel/utils/stream-utils.d.cts +1 -0
- package/highlevel/utils/string-session.d.cts +16 -0
- package/highlevel/utils/string-session.test.d.cts +1 -0
- package/highlevel/utils/voice-utils.d.cts +14 -0
- package/highlevel/utils/voice-utils.test.d.cts +1 -0
- package/highlevel/worker/app-config.d.cts +9 -0
- package/highlevel/worker/errors.d.cts +8 -0
- package/highlevel/worker/index.d.cts +3 -0
- package/highlevel/worker/invoker.d.cts +18 -0
- package/highlevel/worker/port.d.cts +60 -0
- package/highlevel/worker/protocol.d.cts +57 -0
- package/highlevel/worker/storage.d.cts +39 -0
- package/highlevel/worker/worker.d.cts +15 -0
- package/index.cjs +8 -0
- package/index.d.cts +10 -0
- package/index.js +8 -0
- package/methods.d.cts +1 -0
- package/network/auth-key.d.cts +21 -0
- package/network/auth-key.test.d.cts +1 -0
- package/network/authorization.d.cts +9 -0
- package/network/client.d.cts +218 -0
- package/network/config-manager.d.cts +19 -0
- package/network/config-manager.test.d.cts +1 -0
- package/network/index.d.cts +6 -0
- package/network/middlewares/bundle.d.cts +3 -0
- package/network/middlewares/default.d.cts +8 -0
- package/network/middlewares/flood-waiter.d.cts +37 -0
- package/network/middlewares/index.d.cts +4 -0
- package/network/middlewares/index.d.ts +2 -0
- package/network/middlewares/internal-errors.d.cts +17 -0
- package/network/middlewares/on-error.d.cts +30 -0
- package/network/middlewares/on-method.d.cts +39 -0
- package/network/mtproto-session.d.cts +127 -0
- package/network/mtproxy/_fake-tls.d.cts +22 -0
- package/network/mtproxy/index.d.cts +42 -0
- package/network/multi-session-connection.cjs +25 -43
- package/network/multi-session-connection.d.cts +43 -0
- package/network/multi-session-connection.d.ts +5 -5
- package/network/multi-session-connection.js +25 -43
- package/network/network-manager.cjs +7 -20
- package/network/network-manager.d.cts +256 -0
- package/network/network-manager.js +7 -20
- package/network/persistent-connection.cjs +8 -0
- package/network/persistent-connection.d.cts +55 -0
- package/network/persistent-connection.d.ts +3 -1
- package/network/persistent-connection.js +8 -0
- package/network/server-salt.d.cts +12 -0
- package/network/session-connection.cjs +35 -18
- package/network/session-connection.d.cts +94 -0
- package/network/session-connection.d.ts +5 -3
- package/network/session-connection.js +35 -18
- package/network/transports/abstract.d.cts +47 -0
- package/network/transports/index.d.cts +3 -0
- package/network/transports/intermediate.d.cts +23 -0
- package/network/transports/intermediate.test.d.cts +1 -0
- package/network/transports/obfuscated.d.cts +23 -0
- package/network/transports/obfuscated.test.d.cts +1 -0
- package/package.json +13 -13
- package/storage/driver.d.cts +58 -0
- package/storage/index.d.cts +6 -0
- package/storage/memory/driver.d.cts +6 -0
- package/storage/memory/index.d.cts +22 -0
- package/storage/memory/memory.test.d.cts +1 -0
- package/storage/memory/repository/auth-keys.d.cts +19 -0
- package/storage/memory/repository/kv.d.cts +11 -0
- package/storage/memory/repository/peers.d.cts +18 -0
- package/storage/memory/repository/ref-messages.d.cts +16 -0
- package/storage/provider.d.cts +10 -0
- package/storage/repository/auth-keys.d.cts +41 -0
- package/storage/repository/index.d.cts +2 -0
- package/storage/repository/key-value.d.cts +10 -0
- package/storage/service/auth-keys.d.cts +9 -0
- package/storage/service/auth-keys.test.d.cts +1 -0
- package/storage/service/base.d.cts +19 -0
- package/storage/service/default-dcs.d.cts +10 -0
- package/storage/service/future-salts.d.cts +11 -0
- package/storage/service/updates.test.d.cts +1 -0
- package/storage/service/utils.test-utils.d.cts +2 -0
- package/storage/sqlite/driver.d.cts +24 -0
- package/storage/sqlite/index.d.cts +17 -0
- package/storage/sqlite/repository/auth-keys.d.cts +20 -0
- package/storage/sqlite/repository/kv.d.cts +14 -0
- package/storage/sqlite/repository/peers.d.cts +19 -0
- package/storage/sqlite/repository/ref-messages.d.cts +16 -0
- package/storage/sqlite/types.d.cts +18 -0
- package/storage/storage.d.cts +55 -0
- package/types/errors.d.cts +53 -0
- package/types/index.d.cts +4 -0
- package/types/peers.d.cts +4 -0
- package/types/platform.d.cts +15 -0
- package/types/utils.d.cts +9 -0
- package/utils/abort-signal.d.cts +1 -0
- package/utils/bigint-utils.d.cts +18 -0
- package/utils/bigint-utils.test.d.cts +1 -0
- package/utils/binary/asn1-parser.d.cts +17 -0
- package/utils/crypto/abstract.d.cts +29 -0
- package/utils/crypto/factorization.d.cts +6 -0
- package/utils/crypto/factorization.test.d.cts +1 -0
- package/utils/crypto/index.d.cts +6 -0
- package/utils/crypto/keys.d.cts +27 -0
- package/utils/crypto/keys.test.d.cts +1 -0
- package/utils/crypto/miller-rabin.d.cts +2 -0
- package/utils/crypto/miller-rabin.test.d.cts +1 -0
- package/utils/crypto/mtproto.d.cts +31 -0
- package/utils/crypto/mtproto.test.d.cts +1 -0
- package/utils/crypto/password.d.cts +29 -0
- package/utils/crypto/password.test.d.cts +1 -0
- package/utils/dcs.d.cts +18 -0
- package/utils/early-timer.d.cts +41 -0
- package/utils/error-reporting.d.cts +3 -0
- package/utils/function-utils.d.cts +22 -0
- package/utils/function-utils.test.d.cts +1 -0
- package/utils/index.d.cts +20 -0
- package/utils/linked-list.d.cts +21 -0
- package/utils/linked-list.test.d.cts +1 -0
- package/utils/links/bots.d.cts +72 -0
- package/utils/links/bots.test.d.cts +1 -0
- package/utils/links/bundle.d.cts +7 -0
- package/utils/links/calls.d.cts +17 -0
- package/utils/links/chat.d.cts +47 -0
- package/utils/links/chat.test.d.cts +1 -0
- package/utils/links/common.d.cts +31 -0
- package/utils/links/index.d.cts +2 -0
- package/utils/links/misc.d.cts +26 -0
- package/utils/links/misc.test.d.cts +1 -0
- package/utils/links/proxy.d.cts +18 -0
- package/utils/links/proxy.test.d.cts +1 -0
- package/utils/links/stickers.d.cts +10 -0
- package/utils/links/user.d.cts +28 -0
- package/utils/links/user.test.d.cts +1 -0
- package/utils/logger.d.cts +54 -0
- package/utils/logger.test.d.cts +1 -0
- package/utils/long-utils.d.cts +67 -0
- package/utils/long-utils.test.d.cts +1 -0
- package/utils/misc-utils.d.cts +2 -0
- package/utils/peer-utils.d.cts +29 -0
- package/utils/peer-utils.test.d.cts +1 -0
- package/utils/sorted-array.d.cts +17 -0
- package/utils/sorted-array.test.d.cts +1 -0
- package/utils/timers.d.cts +1 -0
- package/utils/tl-json.d.cts +13 -0
- package/utils/tl-json.test.d.cts +1 -0
- package/utils/type-assertions.d.cts +29 -0
- package/utils/type-assertions.test.d.cts +1 -0
- package/utils.d.cts +1 -0
- package/worker.d.cts +1 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { Middleware, Deferred } from '@fuman/utils';
|
|
2
|
+
import { mtp, tl } from '@mtcute/tl';
|
|
3
|
+
import { TlReaderMap, TlWriterMap } from '@mtcute/tl-runtime';
|
|
4
|
+
import { default as Long } from 'long';
|
|
5
|
+
import { StorageManager } from '../storage/storage.js';
|
|
6
|
+
import { ICorePlatform } from '../types/platform.js';
|
|
7
|
+
import { DcOptions, ICryptoProvider, Logger } from '../utils/index.js';
|
|
8
|
+
import { ConfigManager } from './config-manager.js';
|
|
9
|
+
import { TelegramTransport } from './transports/abstract.js';
|
|
10
|
+
import { ReconnectionStrategy } from '@fuman/net';
|
|
11
|
+
import { MultiSessionConnection } from './multi-session-connection.js';
|
|
12
|
+
export type ConnectionKind = 'main' | 'upload' | 'download' | 'downloadSmall';
|
|
13
|
+
/**
|
|
14
|
+
* Params passed into {@link NetworkManager} by {@link TelegramClient}.
|
|
15
|
+
* This type is intended for internal usage only.
|
|
16
|
+
*/
|
|
17
|
+
export interface NetworkManagerParams {
|
|
18
|
+
storage: StorageManager;
|
|
19
|
+
crypto: ICryptoProvider;
|
|
20
|
+
log: Logger;
|
|
21
|
+
platform: ICorePlatform;
|
|
22
|
+
enableErrorReporting: boolean;
|
|
23
|
+
apiId: number;
|
|
24
|
+
initConnectionOptions?: Partial<Omit<tl.RawInitConnectionRequest, 'apiId' | 'query'>>;
|
|
25
|
+
transport: TelegramTransport;
|
|
26
|
+
reconnectionStrategy?: ReconnectionStrategy;
|
|
27
|
+
disableUpdates?: boolean;
|
|
28
|
+
testMode: boolean;
|
|
29
|
+
layer: number;
|
|
30
|
+
useIpv6: boolean;
|
|
31
|
+
readerMap: TlReaderMap;
|
|
32
|
+
writerMap: TlWriterMap;
|
|
33
|
+
isPremium: boolean;
|
|
34
|
+
emitError: (err: Error) => void;
|
|
35
|
+
onUpdate: (upd: tl.TypeUpdates) => void;
|
|
36
|
+
onUsable: () => void;
|
|
37
|
+
onConnecting: () => void;
|
|
38
|
+
onNetworkChanged: (connected: boolean) => void;
|
|
39
|
+
stopSignal: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
export type ConnectionCountDelegate = (kind: ConnectionKind, dcId: number, isPremium: boolean) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Additional params passed into {@link NetworkManager} by the user
|
|
44
|
+
* that customize the behavior of the manager
|
|
45
|
+
*/
|
|
46
|
+
export interface NetworkManagerExtraParams {
|
|
47
|
+
/**
|
|
48
|
+
* Whether to use PFS (Perfect Forward Secrecy) for all connections.
|
|
49
|
+
* This is disabled by default
|
|
50
|
+
*/
|
|
51
|
+
usePfs?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Connection count for each connection kind.
|
|
54
|
+
* The function should be pure to avoid unexpected behavior.
|
|
55
|
+
*
|
|
56
|
+
* Defaults to TDLib logic:
|
|
57
|
+
* - main: 0 (which stands for "handle internally, based on tmp_sessions value")
|
|
58
|
+
* - upload: if premium or dc id is other than 2 or 4, then 8, otherwise 4
|
|
59
|
+
* - download: if premium then 8, otherwise 2
|
|
60
|
+
* - downloadSmall: 2
|
|
61
|
+
*
|
|
62
|
+
* Non-zero value for `main` is **for advanced users only**
|
|
63
|
+
* as it may lead to unexpected behavior, and is generally not recommended
|
|
64
|
+
* because of unnecessary extra load on both the server and the client as well as
|
|
65
|
+
* increased possibility of encountering AUTH_KEY_DUPLICATED errors.
|
|
66
|
+
*/
|
|
67
|
+
connectionCount?: ConnectionCountDelegate;
|
|
68
|
+
/**
|
|
69
|
+
* Idle timeout for non-main connections, in ms
|
|
70
|
+
*
|
|
71
|
+
* @default 60000 (60 seconds).
|
|
72
|
+
*/
|
|
73
|
+
inactivityTimeout?: number;
|
|
74
|
+
/**
|
|
75
|
+
* List of middlewares to use for the network manager
|
|
76
|
+
*
|
|
77
|
+
* > **Note**: these middlewares apply to **outgoing requests only**.
|
|
78
|
+
* > If you need to handle incoming updates, use a {@link Dispatcher} instead.
|
|
79
|
+
*/
|
|
80
|
+
middlewares?: Middleware<RpcCallMiddlewareContext, unknown>[];
|
|
81
|
+
/**
|
|
82
|
+
* Ping interval in milliseconds.
|
|
83
|
+
*
|
|
84
|
+
* @default 60000 (1 minute)
|
|
85
|
+
*/
|
|
86
|
+
pingInterval?: number;
|
|
87
|
+
}
|
|
88
|
+
/** Options that can be customized when making an RPC call */
|
|
89
|
+
export interface RpcCallOptions {
|
|
90
|
+
/**
|
|
91
|
+
* If the call results in a `FLOOD_WAIT_X` error,
|
|
92
|
+
* the maximum amount of time to wait before retrying.
|
|
93
|
+
*
|
|
94
|
+
* If set to `0`, the call will not be retried.
|
|
95
|
+
*
|
|
96
|
+
* Only applies when the flood waiter middleware is enabled.
|
|
97
|
+
*/
|
|
98
|
+
floodSleepThreshold?: number;
|
|
99
|
+
/**
|
|
100
|
+
* If the call results in an internal server error or a flood wait,
|
|
101
|
+
* the maximum amount of times to retry the call.
|
|
102
|
+
*
|
|
103
|
+
* Only applies when the flood waiter middleware and/or
|
|
104
|
+
* internal errors handler middleware is enabled.
|
|
105
|
+
*/
|
|
106
|
+
maxRetryCount?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Timeout for the call, in milliseconds.
|
|
109
|
+
*
|
|
110
|
+
* @default Infinity
|
|
111
|
+
*/
|
|
112
|
+
timeout?: number;
|
|
113
|
+
/**
|
|
114
|
+
* **ADVANCED**
|
|
115
|
+
*
|
|
116
|
+
* Kind of connection to use for this call.
|
|
117
|
+
*
|
|
118
|
+
* @default 'main'
|
|
119
|
+
*/
|
|
120
|
+
kind?: ConnectionKind;
|
|
121
|
+
/**
|
|
122
|
+
* **ADVANCED**
|
|
123
|
+
*
|
|
124
|
+
* ID of the DC to use for this call
|
|
125
|
+
*/
|
|
126
|
+
dcId?: number;
|
|
127
|
+
/**
|
|
128
|
+
* **ADVANCED**
|
|
129
|
+
*
|
|
130
|
+
* DC connection manager to use for this call.
|
|
131
|
+
* Overrides `dcId` if set.
|
|
132
|
+
*/
|
|
133
|
+
manager?: DcConnectionManager;
|
|
134
|
+
/**
|
|
135
|
+
* Abort signal for the call.
|
|
136
|
+
*/
|
|
137
|
+
abortSignal?: AbortSignal;
|
|
138
|
+
/**
|
|
139
|
+
* Whether we should not retry on -503 errors and throw {@link MtTimeoutError} immediately instead.
|
|
140
|
+
*
|
|
141
|
+
* Useful for methods like `messages.getBotCallbackAnswer` that reliably return
|
|
142
|
+
* -503 in case the upstream bot failed to respond.
|
|
143
|
+
*
|
|
144
|
+
* Only applies if the internal error handler middleware is enabled,
|
|
145
|
+
* otherwise -503 is always thrown.
|
|
146
|
+
*/
|
|
147
|
+
throw503?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Whether the `X_MIGRATE_%d` errors should be handled locally on request level
|
|
150
|
+
* instead of changing the default datacenter for the entire client.
|
|
151
|
+
*
|
|
152
|
+
* Useful for `invokeWithBusinessConnection`, as it returns a `USER_MIGRATE_%d` error
|
|
153
|
+
* that is in fact not related to the user, but to the specific request.
|
|
154
|
+
*/
|
|
155
|
+
localMigrate?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Some requests should be processed consecutively, and not in parallel.
|
|
158
|
+
* Using the same `chainId` for multiple requests will ensure that they are processed in the order
|
|
159
|
+
* of calling `.call()`.
|
|
160
|
+
*
|
|
161
|
+
* Particularly useful for `messages.sendMessage` and alike.
|
|
162
|
+
*/
|
|
163
|
+
chainId?: string | number;
|
|
164
|
+
}
|
|
165
|
+
export interface RpcCallMiddlewareContext {
|
|
166
|
+
request: tl.RpcMethod;
|
|
167
|
+
manager: NetworkManager;
|
|
168
|
+
params?: RpcCallOptions;
|
|
169
|
+
}
|
|
170
|
+
export type RpcCallMiddleware<Result = unknown> = Middleware<RpcCallMiddlewareContext, Result>;
|
|
171
|
+
/**
|
|
172
|
+
* Wrapper over all connection pools for a single DC.
|
|
173
|
+
*/
|
|
174
|
+
export declare class DcConnectionManager {
|
|
175
|
+
/** Network manager instance */
|
|
176
|
+
readonly manager: NetworkManager;
|
|
177
|
+
/** DC ID */
|
|
178
|
+
readonly dcId: number;
|
|
179
|
+
/** DC options to use */
|
|
180
|
+
readonly _dcs: DcOptions;
|
|
181
|
+
/** Whether this DC is the primary one */
|
|
182
|
+
isPrimary: boolean;
|
|
183
|
+
private _salts;
|
|
184
|
+
private _log;
|
|
185
|
+
/** Main connection pool */
|
|
186
|
+
main: MultiSessionConnection;
|
|
187
|
+
/** Upload connection pool */
|
|
188
|
+
upload: MultiSessionConnection;
|
|
189
|
+
/** Download connection pool */
|
|
190
|
+
download: MultiSessionConnection;
|
|
191
|
+
/** Download connection pool (for small files) */
|
|
192
|
+
downloadSmall: MultiSessionConnection;
|
|
193
|
+
private get _mainCountOverride();
|
|
194
|
+
constructor(
|
|
195
|
+
/** Network manager instance */
|
|
196
|
+
manager: NetworkManager,
|
|
197
|
+
/** DC ID */
|
|
198
|
+
dcId: number,
|
|
199
|
+
/** DC options to use */
|
|
200
|
+
_dcs: DcOptions,
|
|
201
|
+
/** Whether this DC is the primary one */
|
|
202
|
+
isPrimary?: boolean);
|
|
203
|
+
private _setupMulti;
|
|
204
|
+
setIsPrimary(isPrimary: boolean): void;
|
|
205
|
+
setIsPremium(isPremium: boolean): void;
|
|
206
|
+
loadKeys(forcePfs?: boolean): Promise<boolean>;
|
|
207
|
+
setMainConnectionCount(count: number): void;
|
|
208
|
+
destroy(): Promise<void>;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Class that manages all connections to Telegram servers.
|
|
212
|
+
*/
|
|
213
|
+
export declare class NetworkManager {
|
|
214
|
+
readonly params: NetworkManagerParams & NetworkManagerExtraParams;
|
|
215
|
+
readonly config: ConfigManager;
|
|
216
|
+
readonly _log: Logger;
|
|
217
|
+
readonly _storage: StorageManager;
|
|
218
|
+
readonly _initConnectionParams: tl.RawInitConnectionRequest;
|
|
219
|
+
readonly _transport: TelegramTransport;
|
|
220
|
+
readonly _reconnectionStrategy: ReconnectionStrategy;
|
|
221
|
+
readonly _connectionCount: ConnectionCountDelegate;
|
|
222
|
+
protected readonly _dcConnections: Map<number, DcConnectionManager>;
|
|
223
|
+
protected _primaryDc?: DcConnectionManager;
|
|
224
|
+
protected _primaryDcRecreationPromise?: Deferred<void>;
|
|
225
|
+
private _updateHandler;
|
|
226
|
+
constructor(params: NetworkManagerParams & NetworkManagerExtraParams, config: ConfigManager);
|
|
227
|
+
private _findDcOptions;
|
|
228
|
+
private _resetOnNetworkChange?;
|
|
229
|
+
private _switchPrimaryDc;
|
|
230
|
+
private _dcCreationPromise;
|
|
231
|
+
_getOtherDc(dcId: number): Promise<DcConnectionManager>;
|
|
232
|
+
/**
|
|
233
|
+
* Perform initial connection to the default DC
|
|
234
|
+
*
|
|
235
|
+
* @param defaultDcs Default DCs to connect to
|
|
236
|
+
*/
|
|
237
|
+
connect(defaultDcs: DcOptions): Promise<void>;
|
|
238
|
+
private _pendingExports;
|
|
239
|
+
private _exportAuthTo;
|
|
240
|
+
setIsPremium(isPremium: boolean): void;
|
|
241
|
+
notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): tl.RawUser;
|
|
242
|
+
notifyLoggedOut(): void;
|
|
243
|
+
notifyNetworkChanged(connected: boolean): void;
|
|
244
|
+
resetSessions(): void;
|
|
245
|
+
private _onConfigChanged;
|
|
246
|
+
changePrimaryDc(newDc: number): Promise<void>;
|
|
247
|
+
readonly call: <T extends tl.RpcMethod>(message: T, params?: RpcCallOptions) => Promise<tl.RpcCallReturn[T['_']] | mtp.RawMt_rpc_error>;
|
|
248
|
+
private _composeCall;
|
|
249
|
+
private _call;
|
|
250
|
+
changeTransport(transport: TelegramTransport): Promise<void>;
|
|
251
|
+
getPoolSize(kind: ConnectionKind, dcId?: number): number;
|
|
252
|
+
getPrimaryDcId(): number;
|
|
253
|
+
destroy(): Promise<void>;
|
|
254
|
+
getMtprotoMessageId(): Long;
|
|
255
|
+
recreateDc(dcId: number): Promise<void>;
|
|
256
|
+
}
|
|
@@ -100,11 +100,11 @@ class DcConnectionManager {
|
|
|
100
100
|
_setupMulti(kind) {
|
|
101
101
|
const connection = this[kind];
|
|
102
102
|
connection.onKeyChange.add(([idx, key]) => {
|
|
103
|
-
if (kind !== "main") {
|
|
103
|
+
if (kind !== "main" && key !== null) {
|
|
104
104
|
this.manager._log.warn("got key-change from non-main connection, ignoring");
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
this.manager._log.debug("key change for dc %d from connection %d", this.dcId, idx);
|
|
107
|
+
this.manager._log.debug("key change (empty=%b) for dc %d from connection %d", key === null, this.dcId, idx);
|
|
108
108
|
this.upload.setAuthKey(key);
|
|
109
109
|
this.download.setAuthKey(key);
|
|
110
110
|
this.downloadSmall.setAuthKey(key);
|
|
@@ -119,18 +119,10 @@ class DcConnectionManager {
|
|
|
119
119
|
});
|
|
120
120
|
connection.onTmpKeyChange.add(([idx, key, expires]) => {
|
|
121
121
|
if (kind !== "main") {
|
|
122
|
-
this.manager._log.warn("got tmp-key-change from non-main connection, ignoring");
|
|
123
122
|
return;
|
|
124
123
|
}
|
|
125
124
|
this.manager._log.debug("temp key change for dc %d from connection %d", this.dcId, idx);
|
|
126
|
-
this.
|
|
127
|
-
this.download.setAuthKey(key, true);
|
|
128
|
-
this.downloadSmall.setAuthKey(key, true);
|
|
129
|
-
Promise.resolve(this.manager._storage.provider.authKeys.setTemp(this.dcId, idx, key, expires * 1e3)).then(() => {
|
|
130
|
-
this.upload.notifyKeyChange();
|
|
131
|
-
this.download.notifyKeyChange();
|
|
132
|
-
this.downloadSmall.notifyKeyChange();
|
|
133
|
-
}).catch((e) => {
|
|
125
|
+
Promise.resolve(this.manager._storage.provider.authKeys.setTemp(this.dcId, idx, key, expires * 1e3)).catch((e) => {
|
|
134
126
|
this.manager._log.warn("failed to save temp auth key %d for dc %d: %e", idx, this.dcId, e);
|
|
135
127
|
this.manager.params.emitError(e);
|
|
136
128
|
});
|
|
@@ -192,14 +184,9 @@ class DcConnectionManager {
|
|
|
192
184
|
if (this.manager.params.usePfs || forcePfs) {
|
|
193
185
|
const now = Date.now();
|
|
194
186
|
await Promise.all(
|
|
195
|
-
this.main.
|
|
187
|
+
Array.from({ length: this.main.getCount() }, async (_, i) => {
|
|
196
188
|
const temp = await this.manager._storage.provider.authKeys.getTemp(this.dcId, i, now);
|
|
197
|
-
this.main.
|
|
198
|
-
if (i === 0) {
|
|
199
|
-
this.upload.setAuthKey(temp, true);
|
|
200
|
-
this.download.setAuthKey(temp, true);
|
|
201
|
-
this.downloadSmall.setAuthKey(temp, true);
|
|
202
|
-
}
|
|
189
|
+
this.main.setTempAuthKey(temp, i);
|
|
203
190
|
})
|
|
204
191
|
);
|
|
205
192
|
}
|
|
@@ -226,7 +213,7 @@ class NetworkManager {
|
|
|
226
213
|
_: "initConnection",
|
|
227
214
|
deviceModel,
|
|
228
215
|
systemVersion: "1.0",
|
|
229
|
-
appVersion: "0.
|
|
216
|
+
appVersion: "0.19.0",
|
|
230
217
|
systemLangCode: "en",
|
|
231
218
|
langPack: "",
|
|
232
219
|
// "langPacks are for official apps only"
|
|
@@ -544,7 +531,7 @@ class NetworkManager {
|
|
|
544
531
|
this._resetOnNetworkChange?.();
|
|
545
532
|
}
|
|
546
533
|
getMtprotoMessageId() {
|
|
547
|
-
return this._primaryDc.main.
|
|
534
|
+
return this._primaryDc.main._connections[0]._session.getMessageId();
|
|
548
535
|
}
|
|
549
536
|
async recreateDc(dcId) {
|
|
550
537
|
this._log.debug("recreating dc %d", dcId);
|
|
@@ -64,6 +64,7 @@ class PersistentConnection {
|
|
|
64
64
|
return this._fuman.isConnected;
|
|
65
65
|
}
|
|
66
66
|
_writer;
|
|
67
|
+
_mtproxyInfo;
|
|
67
68
|
async _onOpen(conn) {
|
|
68
69
|
this._updateLogPrefix();
|
|
69
70
|
this.log.debug("connected");
|
|
@@ -71,6 +72,7 @@ class PersistentConnection {
|
|
|
71
72
|
if (tag) {
|
|
72
73
|
await conn.write(tag);
|
|
73
74
|
}
|
|
75
|
+
this._mtproxyInfo = conn.getMtproxyInfo?.();
|
|
74
76
|
const reader = new io.FramedReader(conn, this._codec);
|
|
75
77
|
this._writer = new io.FramedWriter(conn, this._codec);
|
|
76
78
|
while (this._sendOnceConnected.length) {
|
|
@@ -116,12 +118,18 @@ class PersistentConnection {
|
|
|
116
118
|
this._inactive = false;
|
|
117
119
|
}
|
|
118
120
|
reconnect() {
|
|
121
|
+
if (this._disconnectedManually) {
|
|
122
|
+
this._disconnectedManually = false;
|
|
123
|
+
this.connect();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
119
126
|
this._fuman.reconnect(true);
|
|
120
127
|
}
|
|
121
128
|
async disconnectManual() {
|
|
122
129
|
if (this._inactivityTimeout) {
|
|
123
130
|
utils.timers.clearTimeout(this._inactivityTimeout);
|
|
124
131
|
}
|
|
132
|
+
this._disconnectedManually = true;
|
|
125
133
|
await this._fuman.close();
|
|
126
134
|
}
|
|
127
135
|
async destroy() {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ReconnectionStrategy } from '@fuman/net';
|
|
2
|
+
import { tl } from '@mtcute/tl';
|
|
3
|
+
import { BasicDcOption, ICryptoProvider, Logger } from '../utils/index.js';
|
|
4
|
+
import { TelegramTransport } from './transports/abstract.js';
|
|
5
|
+
import { Emitter } from '@fuman/utils';
|
|
6
|
+
export interface PersistentConnectionParams {
|
|
7
|
+
crypto: ICryptoProvider;
|
|
8
|
+
transport: TelegramTransport;
|
|
9
|
+
dc: BasicDcOption;
|
|
10
|
+
testMode: boolean;
|
|
11
|
+
reconnectionStrategy: ReconnectionStrategy;
|
|
12
|
+
inactivityTimeout?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Base class for persistent connections.
|
|
16
|
+
* Only used for {@link PersistentConnection} and used as a mean of code splitting.
|
|
17
|
+
* This class doesn't know anything about MTProto, it just manages the transport.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class PersistentConnection {
|
|
20
|
+
readonly log: Logger;
|
|
21
|
+
private _uid;
|
|
22
|
+
readonly params: PersistentConnectionParams;
|
|
23
|
+
private _sendOnceConnected;
|
|
24
|
+
private _codec;
|
|
25
|
+
private _fuman;
|
|
26
|
+
protected _disconnectedManually: boolean;
|
|
27
|
+
private _inactivityTimeout;
|
|
28
|
+
_inactive: boolean;
|
|
29
|
+
_destroyed: boolean;
|
|
30
|
+
_usable: boolean;
|
|
31
|
+
readonly onWait: Emitter<number>;
|
|
32
|
+
readonly onUsable: Emitter<void>;
|
|
33
|
+
readonly onError: Emitter<Error>;
|
|
34
|
+
protected abstract onConnected(): void;
|
|
35
|
+
protected abstract onClosed(): void;
|
|
36
|
+
protected abstract handleError(err: Error): void;
|
|
37
|
+
protected abstract onMessage(data: Uint8Array): void;
|
|
38
|
+
protected constructor(params: PersistentConnectionParams, log: Logger);
|
|
39
|
+
private _updateLogPrefix;
|
|
40
|
+
get isConnected(): boolean;
|
|
41
|
+
private _writer?;
|
|
42
|
+
protected _mtproxyInfo?: tl.RawInputClientProxy;
|
|
43
|
+
private _onOpen;
|
|
44
|
+
private _onClose;
|
|
45
|
+
private _onError;
|
|
46
|
+
changeTransport(transport: TelegramTransport): Promise<void>;
|
|
47
|
+
connect(): void;
|
|
48
|
+
reconnect(): void;
|
|
49
|
+
disconnectManual(): Promise<void>;
|
|
50
|
+
destroy(): Promise<void>;
|
|
51
|
+
protected _rescheduleInactivity(): void;
|
|
52
|
+
protected _onInactivityTimeout(): void;
|
|
53
|
+
setInactivityTimeout(timeout?: number): void;
|
|
54
|
+
send(data: Uint8Array): Promise<void>;
|
|
55
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReconnectionStrategy } from '@fuman/net';
|
|
2
|
+
import { tl } from '@mtcute/tl';
|
|
2
3
|
import { BasicDcOption, ICryptoProvider, Logger } from '../utils/index.js';
|
|
3
4
|
import { TelegramTransport } from './transports/abstract.js';
|
|
4
5
|
import { Emitter } from '@fuman/utils';
|
|
@@ -24,7 +25,7 @@ export declare abstract class PersistentConnection {
|
|
|
24
25
|
private _fuman;
|
|
25
26
|
protected _disconnectedManually: boolean;
|
|
26
27
|
private _inactivityTimeout;
|
|
27
|
-
|
|
28
|
+
_inactive: boolean;
|
|
28
29
|
_destroyed: boolean;
|
|
29
30
|
_usable: boolean;
|
|
30
31
|
readonly onWait: Emitter<number>;
|
|
@@ -38,6 +39,7 @@ export declare abstract class PersistentConnection {
|
|
|
38
39
|
private _updateLogPrefix;
|
|
39
40
|
get isConnected(): boolean;
|
|
40
41
|
private _writer?;
|
|
42
|
+
protected _mtproxyInfo?: tl.RawInputClientProxy;
|
|
41
43
|
private _onOpen;
|
|
42
44
|
private _onClose;
|
|
43
45
|
private _onError;
|
|
@@ -57,6 +57,7 @@ class PersistentConnection {
|
|
|
57
57
|
return this._fuman.isConnected;
|
|
58
58
|
}
|
|
59
59
|
_writer;
|
|
60
|
+
_mtproxyInfo;
|
|
60
61
|
async _onOpen(conn) {
|
|
61
62
|
this._updateLogPrefix();
|
|
62
63
|
this.log.debug("connected");
|
|
@@ -64,6 +65,7 @@ class PersistentConnection {
|
|
|
64
65
|
if (tag) {
|
|
65
66
|
await conn.write(tag);
|
|
66
67
|
}
|
|
68
|
+
this._mtproxyInfo = conn.getMtproxyInfo?.();
|
|
67
69
|
const reader = new FramedReader(conn, this._codec);
|
|
68
70
|
this._writer = new FramedWriter(conn, this._codec);
|
|
69
71
|
while (this._sendOnceConnected.length) {
|
|
@@ -109,12 +111,18 @@ class PersistentConnection {
|
|
|
109
111
|
this._inactive = false;
|
|
110
112
|
}
|
|
111
113
|
reconnect() {
|
|
114
|
+
if (this._disconnectedManually) {
|
|
115
|
+
this._disconnectedManually = false;
|
|
116
|
+
this.connect();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
112
119
|
this._fuman.reconnect(true);
|
|
113
120
|
}
|
|
114
121
|
async disconnectManual() {
|
|
115
122
|
if (this._inactivityTimeout) {
|
|
116
123
|
timers.clearTimeout(this._inactivityTimeout);
|
|
117
124
|
}
|
|
125
|
+
this._disconnectedManually = true;
|
|
118
126
|
await this._fuman.close();
|
|
119
127
|
}
|
|
120
128
|
async destroy() {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mtp } from '@mtcute/tl';
|
|
2
|
+
import { default as Long } from 'long';
|
|
3
|
+
export declare class ServerSaltManager {
|
|
4
|
+
private _futureSalts;
|
|
5
|
+
currentSalt: Long;
|
|
6
|
+
isFetching: boolean;
|
|
7
|
+
shouldFetchSalts(): boolean;
|
|
8
|
+
setFutureSalts(salts: mtp.RawMt_future_salt[]): void;
|
|
9
|
+
private _timer?;
|
|
10
|
+
private _scheduleNext;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
@@ -13,6 +13,7 @@ const mtproto = require("../utils/crypto/mtproto.cjs");
|
|
|
13
13
|
const earlyTimer = require("../utils/early-timer.cjs");
|
|
14
14
|
const longUtils = require("../utils/long-utils.cjs");
|
|
15
15
|
const authorization = require("./authorization.cjs");
|
|
16
|
+
const mtprotoSession = require("./mtproto-session.cjs");
|
|
16
17
|
const persistentConnection = require("./persistent-connection.cjs");
|
|
17
18
|
const abstract = require("./transports/abstract.cjs");
|
|
18
19
|
const errors = require("../types/errors.cjs");
|
|
@@ -25,19 +26,6 @@ const RPC_ERROR_ID = 558156313;
|
|
|
25
26
|
const INVOKE_AFTER_MSG_ID = 3416209197;
|
|
26
27
|
const INVOKE_AFTER_MSG_SIZE = 12;
|
|
27
28
|
class SessionConnection extends persistentConnection.PersistentConnection {
|
|
28
|
-
constructor(params, _session) {
|
|
29
|
-
super(params, _session.log.create("conn"));
|
|
30
|
-
this._session = _session;
|
|
31
|
-
this._flushTimer.onTimeout(this._flush.bind(this));
|
|
32
|
-
this._pingInterval = params.pingInterval;
|
|
33
|
-
this._readerMap = params.readerMap;
|
|
34
|
-
this._writerMap = params.writerMap;
|
|
35
|
-
this._crypto = params.crypto;
|
|
36
|
-
this._salts = params.salts;
|
|
37
|
-
this._handleRawMessage = this._handleRawMessage.bind(this);
|
|
38
|
-
this._usePfs = this.params.usePfs ?? false;
|
|
39
|
-
this._online = params.platform.isOnline?.() ?? true;
|
|
40
|
-
}
|
|
41
29
|
_flushTimer = new earlyTimer.EarlyTimer();
|
|
42
30
|
_queuedDestroySession = [];
|
|
43
31
|
// waitForMessage
|
|
@@ -51,6 +39,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
51
39
|
_writerMap;
|
|
52
40
|
_crypto;
|
|
53
41
|
_salts;
|
|
42
|
+
_session;
|
|
54
43
|
// todo: we should probably do adaptive ping interval based on rtt like tdlib:
|
|
55
44
|
// https://github.com/tdlib/td/blob/91aa6c9e4d0774eabf4f8d7f3aa51239032059a6/td/mtproto/SessionConnection.h
|
|
56
45
|
_pingInterval;
|
|
@@ -63,6 +52,26 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
63
52
|
onAuthBegin = new utils.Emitter();
|
|
64
53
|
onUpdate = new utils.Emitter();
|
|
65
54
|
onFutureSalts = new utils.Emitter();
|
|
55
|
+
_triedReconnectingOn404 = false;
|
|
56
|
+
constructor(params, log) {
|
|
57
|
+
super(params, log.create("conn"));
|
|
58
|
+
this._session = new mtprotoSession.MtprotoSession(
|
|
59
|
+
params.crypto,
|
|
60
|
+
log.create("session"),
|
|
61
|
+
params.readerMap,
|
|
62
|
+
params.writerMap,
|
|
63
|
+
params.salts
|
|
64
|
+
);
|
|
65
|
+
this._flushTimer.onTimeout(this._flush.bind(this));
|
|
66
|
+
this._pingInterval = params.pingInterval;
|
|
67
|
+
this._readerMap = params.readerMap;
|
|
68
|
+
this._writerMap = params.writerMap;
|
|
69
|
+
this._crypto = params.crypto;
|
|
70
|
+
this._salts = params.salts;
|
|
71
|
+
this._handleRawMessage = this._handleRawMessage.bind(this);
|
|
72
|
+
this._usePfs = this.params.usePfs ?? false;
|
|
73
|
+
this._online = params.platform.isOnline?.() ?? true;
|
|
74
|
+
}
|
|
66
75
|
_online;
|
|
67
76
|
getAuthKey(temp = false) {
|
|
68
77
|
const key = temp ? this._session._authKeyTemp : this._session._authKey;
|
|
@@ -119,6 +128,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
119
128
|
this.onError.add((err) => {
|
|
120
129
|
this.log.warn("caught error after destroying: %s", err);
|
|
121
130
|
});
|
|
131
|
+
this._session.reset();
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
onConnected() {
|
|
@@ -144,22 +154,27 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
144
154
|
if (error.code === 404) {
|
|
145
155
|
if (this._usePfs) {
|
|
146
156
|
if (!this._isPfsBindingPending && this._session._authKeyTemp.ready) {
|
|
147
|
-
this.log.
|
|
157
|
+
this.log.debug("transport error 404, reauthorizing pfs");
|
|
148
158
|
this._session._authKeyTemp.reset();
|
|
149
159
|
this._authorizePfs();
|
|
150
160
|
this._onAllFailed("temp key expired, binding started");
|
|
151
161
|
return;
|
|
152
162
|
} else if (this._isPfsBindingPending) {
|
|
153
|
-
this.log.
|
|
163
|
+
this.log.debug("transport error 404, pfs binding in progress");
|
|
154
164
|
this._onAllFailed("temp key expired, binding pending");
|
|
155
165
|
return;
|
|
156
166
|
}
|
|
157
167
|
}
|
|
158
|
-
this.
|
|
168
|
+
if (!this._triedReconnectingOn404) {
|
|
169
|
+
this.log.warn("transport error 404. trying to reconnect");
|
|
170
|
+
this._triedReconnectingOn404 = true;
|
|
171
|
+
this._resetSession();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.log.warn("transport error 404, reauthorizing");
|
|
159
175
|
this._session.resetAuthKey();
|
|
160
176
|
this._resetSession();
|
|
161
177
|
this.onKeyChange.emit(null);
|
|
162
|
-
this.onError.emit(error);
|
|
163
178
|
return;
|
|
164
179
|
}
|
|
165
180
|
this.log.error("transport error %d", error.code);
|
|
@@ -785,6 +800,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
785
800
|
this.onUpdate.emit({ _: "updatesTooLong" });
|
|
786
801
|
}
|
|
787
802
|
this._salts.currentSalt = serverSalt;
|
|
803
|
+
this._triedReconnectingOn404 = false;
|
|
788
804
|
this.log.debug("received new_session_created, uid = %l, first msg_id = %l", uniqueId, firstMsgId);
|
|
789
805
|
for (const msgId of this._session.pendingMessages.keys()) {
|
|
790
806
|
const val = this._session.pendingMessages.get(msgId);
|
|
@@ -935,7 +951,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
935
951
|
layer: this.params.layer,
|
|
936
952
|
query: {
|
|
937
953
|
...this.params.initConnection,
|
|
938
|
-
|
|
954
|
+
proxy: this._mtproxyInfo,
|
|
939
955
|
query: obj
|
|
940
956
|
}
|
|
941
957
|
};
|
|
@@ -1001,6 +1017,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
|
|
|
1001
1017
|
notifyNetworkChanged(online) {
|
|
1002
1018
|
this._online = online;
|
|
1003
1019
|
if (online) {
|
|
1020
|
+
if (this._inactive) return;
|
|
1004
1021
|
this.reconnect();
|
|
1005
1022
|
} else {
|
|
1006
1023
|
this.disconnectManual().catch((err) => {
|