@mtcute/core 0.18.0-rc.5 → 0.18.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,57 @@
|
|
|
1
|
+
import { tl } from '@mtcute/tl';
|
|
2
|
+
import { Worker as NodeWorker } from 'node:worker_threads';
|
|
3
|
+
import { ConnectionState } from '../client.types.js';
|
|
4
|
+
import { SerializedError } from './errors.js';
|
|
5
|
+
export type WorkerInboundMessage = {
|
|
6
|
+
type: 'invoke';
|
|
7
|
+
id: number;
|
|
8
|
+
target: 'custom' | 'client' | 'storage' | 'storage-self' | 'storage-peers' | 'app-config';
|
|
9
|
+
method: string;
|
|
10
|
+
args: SerializedResult<unknown[]>;
|
|
11
|
+
void: boolean;
|
|
12
|
+
withAbort: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'abort';
|
|
15
|
+
id: number;
|
|
16
|
+
};
|
|
17
|
+
export type WorkerOutboundMessage = {
|
|
18
|
+
type: 'server_update';
|
|
19
|
+
update: SerializedResult<tl.TypeUpdates>;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'update';
|
|
22
|
+
update: SerializedResult<tl.TypeUpdate>;
|
|
23
|
+
users: SerializedResult<Map<number, tl.TypeUser>>;
|
|
24
|
+
chats: SerializedResult<Map<number, tl.TypeChat>>;
|
|
25
|
+
hasMin: boolean;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'error';
|
|
28
|
+
error: SerializedError;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'stop';
|
|
31
|
+
} | {
|
|
32
|
+
type: 'conn_state';
|
|
33
|
+
state: ConnectionState;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'log';
|
|
36
|
+
color: number;
|
|
37
|
+
level: number;
|
|
38
|
+
tag: string;
|
|
39
|
+
fmt: string;
|
|
40
|
+
args: unknown[];
|
|
41
|
+
} | {
|
|
42
|
+
type: 'result';
|
|
43
|
+
id: number;
|
|
44
|
+
result?: SerializedResult<unknown>;
|
|
45
|
+
error?: SerializedError;
|
|
46
|
+
};
|
|
47
|
+
export type SomeWorker = NodeWorker | Worker | SharedWorker;
|
|
48
|
+
export type SendFn = (message: WorkerInboundMessage) => void;
|
|
49
|
+
export type ClientMessageHandler = (message: WorkerOutboundMessage) => void;
|
|
50
|
+
export type RespondFn = (message: WorkerOutboundMessage) => void;
|
|
51
|
+
export type WorkerMessageHandler = (message: WorkerInboundMessage, respond: RespondFn) => void;
|
|
52
|
+
export type WorkerCustomMethods = Record<string, (...args: any[]) => Promise<any>>;
|
|
53
|
+
export interface SerializedResult<T> {
|
|
54
|
+
__serialized__: T;
|
|
55
|
+
}
|
|
56
|
+
export declare function serializeResult<T>(result: T): SerializedResult<T>;
|
|
57
|
+
export declare function deserializeResult<T>(result: SerializedResult<T>): T;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { tl } from '@mtcute/tl';
|
|
2
|
+
import { PublicPart } from '../../types/utils.js';
|
|
3
|
+
import { CurrentUserInfo, CurrentUserService } from '../storage/service/current-user.js';
|
|
4
|
+
import { PeersService } from '../storage/service/peers.js';
|
|
5
|
+
import { TelegramStorageManager } from '../storage/storage.js';
|
|
6
|
+
import { WorkerInvoker } from './invoker.js';
|
|
7
|
+
declare class CurrentUserServiceProxy implements PublicPart<CurrentUserService> {
|
|
8
|
+
private _store;
|
|
9
|
+
private _storeFrom;
|
|
10
|
+
private _fetch;
|
|
11
|
+
private _update;
|
|
12
|
+
constructor(invoker: WorkerInvoker);
|
|
13
|
+
private _cached?;
|
|
14
|
+
store(info: CurrentUserInfo | null): Promise<void>;
|
|
15
|
+
storeFrom(user: tl.TypeUser): Promise<CurrentUserInfo>;
|
|
16
|
+
fetch(): Promise<CurrentUserInfo | null>;
|
|
17
|
+
getCached(safe?: boolean): CurrentUserInfo | null;
|
|
18
|
+
update(params: Parameters<CurrentUserService['update']>[0]): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
declare class PeersServiceProxy implements PublicPart<PeersService> {
|
|
21
|
+
private _invoker;
|
|
22
|
+
readonly updatePeersFrom: PeersService['updatePeersFrom'];
|
|
23
|
+
readonly store: PeersService['store'];
|
|
24
|
+
readonly getById: PeersService['getById'];
|
|
25
|
+
readonly getByPhone: PeersService['getByPhone'];
|
|
26
|
+
readonly getByUsername: PeersService['getByUsername'];
|
|
27
|
+
readonly getCompleteById: PeersService['getCompleteById'];
|
|
28
|
+
constructor(_invoker: WorkerInvoker);
|
|
29
|
+
}
|
|
30
|
+
export declare class TelegramStorageProxy implements PublicPart<TelegramStorageManager> {
|
|
31
|
+
private _invoker;
|
|
32
|
+
readonly self: CurrentUserServiceProxy;
|
|
33
|
+
readonly peers: PeersServiceProxy;
|
|
34
|
+
readonly clear: TelegramStorageManager['clear'];
|
|
35
|
+
constructor(_invoker: WorkerInvoker);
|
|
36
|
+
readonly updates: never;
|
|
37
|
+
readonly refMsgs: never;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseTelegramClient } from '../base.js';
|
|
2
|
+
import { RespondFn, WorkerCustomMethods, WorkerMessageHandler } from './protocol.js';
|
|
3
|
+
export interface TelegramWorkerOptions<T extends WorkerCustomMethods> {
|
|
4
|
+
client: BaseTelegramClient;
|
|
5
|
+
customMethods?: T;
|
|
6
|
+
}
|
|
7
|
+
export declare abstract class TelegramWorker<T extends WorkerCustomMethods> {
|
|
8
|
+
readonly params: TelegramWorkerOptions<T>;
|
|
9
|
+
readonly client: BaseTelegramClient;
|
|
10
|
+
readonly broadcast: RespondFn;
|
|
11
|
+
abstract registerWorker(handler: WorkerMessageHandler): RespondFn;
|
|
12
|
+
readonly pendingAborts: Map<number, AbortController>;
|
|
13
|
+
constructor(params: TelegramWorkerOptions<T>);
|
|
14
|
+
private onInvoke;
|
|
15
|
+
}
|
package/index.cjs
CHANGED
|
@@ -62,6 +62,7 @@ const bundle = require("./highlevel/types/misc/input-privacy-rule/bundle.cjs");
|
|
|
62
62
|
const stickerSet = require("./highlevel/types/misc/sticker-set.cjs");
|
|
63
63
|
const takeoutSession = require("./highlevel/types/misc/takeout-session.cjs");
|
|
64
64
|
const botInfo = require("./highlevel/types/peers/bot-info.cjs");
|
|
65
|
+
const chatColors = require("./highlevel/types/peers/chat-colors.cjs");
|
|
65
66
|
const actions = require("./highlevel/types/peers/chat-event/actions.cjs");
|
|
66
67
|
const index = require("./highlevel/types/peers/chat-event/index.cjs");
|
|
67
68
|
const chatInviteLinkMember = require("./highlevel/types/peers/chat-invite-link-member.cjs");
|
|
@@ -86,11 +87,14 @@ const businessAccount = require("./highlevel/types/premium/business-account.cjs"
|
|
|
86
87
|
const businessChatLink = require("./highlevel/types/premium/business-chat-link.cjs");
|
|
87
88
|
const businessConnection = require("./highlevel/types/premium/business-connection.cjs");
|
|
88
89
|
const businessIntro = require("./highlevel/types/premium/business-intro.cjs");
|
|
90
|
+
const businessLocation = require("./highlevel/types/premium/business-location.cjs");
|
|
89
91
|
const businessWorkHours = require("./highlevel/types/premium/business-work-hours.cjs");
|
|
90
92
|
const starsGift = require("./highlevel/types/premium/stars-gift.cjs");
|
|
91
93
|
const starsStatus = require("./highlevel/types/premium/stars-status.cjs");
|
|
92
94
|
const starsTransaction = require("./highlevel/types/premium/stars-transaction.cjs");
|
|
95
|
+
const emojiStatus = require("./highlevel/types/reactions/emoji-status.cjs");
|
|
93
96
|
const peerReaction = require("./highlevel/types/reactions/peer-reaction.cjs");
|
|
97
|
+
const reactionCount = require("./highlevel/types/reactions/reaction-count.cjs");
|
|
94
98
|
const types = require("./highlevel/types/reactions/types.cjs");
|
|
95
99
|
const allStories = require("./highlevel/types/stories/all-stories.cjs");
|
|
96
100
|
const input = require("./highlevel/types/stories/interactive/input.cjs");
|
|
@@ -220,6 +224,7 @@ exports.StickerSet = stickerSet.StickerSet;
|
|
|
220
224
|
exports.normalizeInputStickerSet = stickerSet.normalizeInputStickerSet;
|
|
221
225
|
exports.TakeoutSession = takeoutSession.TakeoutSession;
|
|
222
226
|
exports.BotInfo = botInfo.BotInfo;
|
|
227
|
+
exports.ChatColors = chatColors.ChatColors;
|
|
223
228
|
exports._actionFromTl = actions._actionFromTl;
|
|
224
229
|
exports.ChatEvent = index.ChatEvent;
|
|
225
230
|
exports.ChatInviteLinkMember = chatInviteLinkMember.ChatInviteLinkMember;
|
|
@@ -245,14 +250,17 @@ exports.BusinessAccount = businessAccount.BusinessAccount;
|
|
|
245
250
|
exports.BusinessChatLink = businessChatLink.BusinessChatLink;
|
|
246
251
|
exports.BusinessConnection = businessConnection.BusinessConnection;
|
|
247
252
|
exports.BusinessIntro = businessIntro.BusinessIntro;
|
|
253
|
+
exports.BusinessLocation = businessLocation.BusinessLocation;
|
|
248
254
|
exports.BusinessWorkHours = businessWorkHours.BusinessWorkHours;
|
|
249
255
|
exports.businessWorkHoursDaysToRaw = businessWorkHours.businessWorkHoursDaysToRaw;
|
|
250
256
|
exports.StarGift = starsGift.StarGift;
|
|
251
257
|
exports.UserStarGift = starsGift.UserStarGift;
|
|
252
258
|
exports.StarsStatus = starsStatus.StarsStatus;
|
|
253
259
|
exports.StarsTransaction = starsTransaction.StarsTransaction;
|
|
260
|
+
exports.EmojiStatus = emojiStatus.EmojiStatus;
|
|
254
261
|
exports.PaidPeerReaction = peerReaction.PaidPeerReaction;
|
|
255
262
|
exports.PeerReaction = peerReaction.PeerReaction;
|
|
263
|
+
exports.ReactionCount = reactionCount.ReactionCount;
|
|
256
264
|
exports.normalizeInputReaction = types.normalizeInputReaction;
|
|
257
265
|
exports.toReactionEmoji = types.toReactionEmoji;
|
|
258
266
|
exports.AllStories = allStories.AllStories;
|
package/index.d.cts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as Long } from 'long';
|
|
2
|
+
export * from './highlevel/index.js';
|
|
3
|
+
export * from './network/index.js';
|
|
4
|
+
export * from './storage/index.js';
|
|
5
|
+
export * from './types/index.js';
|
|
6
|
+
export * from './utils/peer-utils.js';
|
|
7
|
+
/** @hidden */
|
|
8
|
+
export { mtp, tl } from '@mtcute/tl';
|
|
9
|
+
/** @hidden */
|
|
10
|
+
export { Long };
|
package/index.js
CHANGED
|
@@ -55,6 +55,7 @@ import * as bundle from "./highlevel/types/misc/input-privacy-rule/bundle.js";
|
|
|
55
55
|
import { StickerSet, normalizeInputStickerSet } from "./highlevel/types/misc/sticker-set.js";
|
|
56
56
|
import { TakeoutSession } from "./highlevel/types/misc/takeout-session.js";
|
|
57
57
|
import { BotInfo } from "./highlevel/types/peers/bot-info.js";
|
|
58
|
+
import { ChatColors } from "./highlevel/types/peers/chat-colors.js";
|
|
58
59
|
import { _actionFromTl } from "./highlevel/types/peers/chat-event/actions.js";
|
|
59
60
|
import { ChatEvent } from "./highlevel/types/peers/chat-event/index.js";
|
|
60
61
|
import { ChatInviteLinkMember } from "./highlevel/types/peers/chat-invite-link-member.js";
|
|
@@ -79,11 +80,14 @@ import { BusinessAccount } from "./highlevel/types/premium/business-account.js";
|
|
|
79
80
|
import { BusinessChatLink } from "./highlevel/types/premium/business-chat-link.js";
|
|
80
81
|
import { BusinessConnection } from "./highlevel/types/premium/business-connection.js";
|
|
81
82
|
import { BusinessIntro } from "./highlevel/types/premium/business-intro.js";
|
|
83
|
+
import { BusinessLocation } from "./highlevel/types/premium/business-location.js";
|
|
82
84
|
import { BusinessWorkHours, businessWorkHoursDaysToRaw } from "./highlevel/types/premium/business-work-hours.js";
|
|
83
85
|
import { StarGift, UserStarGift } from "./highlevel/types/premium/stars-gift.js";
|
|
84
86
|
import { StarsStatus } from "./highlevel/types/premium/stars-status.js";
|
|
85
87
|
import { StarsTransaction } from "./highlevel/types/premium/stars-transaction.js";
|
|
88
|
+
import { EmojiStatus } from "./highlevel/types/reactions/emoji-status.js";
|
|
86
89
|
import { PaidPeerReaction, PeerReaction } from "./highlevel/types/reactions/peer-reaction.js";
|
|
90
|
+
import { ReactionCount } from "./highlevel/types/reactions/reaction-count.js";
|
|
87
91
|
import { normalizeInputReaction, toReactionEmoji } from "./highlevel/types/reactions/types.js";
|
|
88
92
|
import { AllStories } from "./highlevel/types/stories/all-stories.js";
|
|
89
93
|
import { StoryElement } from "./highlevel/types/stories/interactive/input.js";
|
|
@@ -160,10 +164,12 @@ export {
|
|
|
160
164
|
BusinessChatLink,
|
|
161
165
|
BusinessConnection,
|
|
162
166
|
BusinessIntro,
|
|
167
|
+
BusinessLocation,
|
|
163
168
|
BusinessMessage,
|
|
164
169
|
BusinessWorkHours,
|
|
165
170
|
CallbackQuery,
|
|
166
171
|
Chat,
|
|
172
|
+
ChatColors,
|
|
167
173
|
ChatEvent,
|
|
168
174
|
ChatInviteLink,
|
|
169
175
|
ChatInviteLinkMember,
|
|
@@ -187,6 +193,7 @@ export {
|
|
|
187
193
|
Dice,
|
|
188
194
|
Document,
|
|
189
195
|
DraftMessage,
|
|
196
|
+
EmojiStatus,
|
|
190
197
|
ExtendedMediaPreview,
|
|
191
198
|
FactCheck,
|
|
192
199
|
FileLocation,
|
|
@@ -242,6 +249,7 @@ export {
|
|
|
242
249
|
RawDocument,
|
|
243
250
|
RawLocation,
|
|
244
251
|
RawUpdateInfo,
|
|
252
|
+
ReactionCount,
|
|
245
253
|
RepliedMessageInfo,
|
|
246
254
|
SearchFilters,
|
|
247
255
|
SentCode,
|
package/methods.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./highlevel/methods.js"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { tl } from '@mtcute/tl';
|
|
2
|
+
import { TlReaderMap, TlBinaryReader } from '@mtcute/tl-runtime';
|
|
3
|
+
import { default as Long } from 'long';
|
|
4
|
+
import { ICryptoProvider, Logger } from '../utils/index.js';
|
|
5
|
+
export declare class AuthKey {
|
|
6
|
+
readonly _crypto: ICryptoProvider;
|
|
7
|
+
readonly log: Logger;
|
|
8
|
+
readonly _readerMap: TlReaderMap;
|
|
9
|
+
ready: boolean;
|
|
10
|
+
key: Uint8Array;
|
|
11
|
+
id: Uint8Array;
|
|
12
|
+
clientSalt: Uint8Array;
|
|
13
|
+
serverSalt: Uint8Array;
|
|
14
|
+
constructor(_crypto: ICryptoProvider, log: Logger, _readerMap: TlReaderMap);
|
|
15
|
+
match(keyId: Uint8Array): boolean;
|
|
16
|
+
setup(authKey?: Uint8Array | null): void;
|
|
17
|
+
encryptMessage(message: Uint8Array, serverSalt: Long, sessionId: Long): Uint8Array;
|
|
18
|
+
decryptMessage(data: Uint8Array, sessionId: Long, callback: (msgId: tl.Long, seqNo: number, data: TlBinaryReader) => void): void;
|
|
19
|
+
copyFrom(authKey: AuthKey): void;
|
|
20
|
+
reset(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICryptoProvider } from '../utils/index.js';
|
|
2
|
+
import { SessionConnection } from './session-connection.js';
|
|
3
|
+
import { default as Long } from 'long';
|
|
4
|
+
/**
|
|
5
|
+
* Execute authorization flow on `connection` using `crypto`.
|
|
6
|
+
*
|
|
7
|
+
* @returns tuple: [authKey, serverSalt, timeOffset]
|
|
8
|
+
*/
|
|
9
|
+
export declare function doAuthorization(connection: SessionConnection, crypto: ICryptoProvider, expiresIn?: number): Promise<[Uint8Array, Long, number]>;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { ReconnectionStrategy } from '@fuman/net';
|
|
2
|
+
import { mtp, tl } from '@mtcute/tl';
|
|
3
|
+
import { TlReaderMap, TlWriterMap } from '@mtcute/tl-runtime';
|
|
4
|
+
import { IMtStorageProvider } from '../storage/provider.js';
|
|
5
|
+
import { StorageManagerExtraOptions, StorageManager } from '../storage/storage.js';
|
|
6
|
+
import { MustEqual } from '../types/index.js';
|
|
7
|
+
import { ICorePlatform } from '../types/platform.js';
|
|
8
|
+
import { DcOptions, ICryptoProvider, Logger } from '../utils/index.js';
|
|
9
|
+
import { NetworkManagerExtraParams, RpcCallOptions, NetworkManager } from './network-manager.js';
|
|
10
|
+
import { TelegramTransport } from './transports/abstract.js';
|
|
11
|
+
import { Emitter } from '@fuman/utils';
|
|
12
|
+
import { ConfigManager } from './config-manager.js';
|
|
13
|
+
/** Options for {@link MtClient} */
|
|
14
|
+
export interface MtClientOptions {
|
|
15
|
+
/**
|
|
16
|
+
* API ID from my.telegram.org
|
|
17
|
+
*/
|
|
18
|
+
apiId: number;
|
|
19
|
+
/**
|
|
20
|
+
* API hash from my.telegram.org
|
|
21
|
+
*/
|
|
22
|
+
apiHash: string;
|
|
23
|
+
/**
|
|
24
|
+
* Storage to use for this client.
|
|
25
|
+
*/
|
|
26
|
+
storage: IMtStorageProvider;
|
|
27
|
+
/** Additional options for the storage manager */
|
|
28
|
+
storageOptions?: StorageManagerExtraOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Cryptography provider to allow delegating
|
|
31
|
+
* crypto to native addon, worker, etc.
|
|
32
|
+
*/
|
|
33
|
+
crypto: ICryptoProvider;
|
|
34
|
+
platform: ICorePlatform;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to use IPv6 datacenters
|
|
37
|
+
* (IPv6 will be preferred when choosing a DC by id)
|
|
38
|
+
* (default: false)
|
|
39
|
+
*/
|
|
40
|
+
useIpv6?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Primary DC to use for initial connection.
|
|
43
|
+
* This does not mean this will be the only DC used,
|
|
44
|
+
* nor that this DC will actually be primary, this only
|
|
45
|
+
* determines the first DC the library will try to connect to.
|
|
46
|
+
* Can be used to connect to other networks (like test DCs).
|
|
47
|
+
*
|
|
48
|
+
* When session already contains primary DC, this parameter is ignored.
|
|
49
|
+
*
|
|
50
|
+
* @default Production DC 2.
|
|
51
|
+
*/
|
|
52
|
+
defaultDcs?: DcOptions;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to connect to test servers.
|
|
55
|
+
*
|
|
56
|
+
* If passed, {@link defaultDc} defaults to Test DC 2.
|
|
57
|
+
*
|
|
58
|
+
* **Must** be passed if using test servers, even if
|
|
59
|
+
* you passed custom {@link defaultDc}
|
|
60
|
+
*/
|
|
61
|
+
testMode?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Additional options for initConnection call.
|
|
64
|
+
* `apiId` and `query` are not available and will be ignored.
|
|
65
|
+
* Omitted values will be filled with defaults
|
|
66
|
+
*/
|
|
67
|
+
initConnectionOptions?: Partial<Omit<tl.RawInitConnectionRequest, 'apiId' | 'query'>>;
|
|
68
|
+
/**
|
|
69
|
+
* Transport to use in the client.
|
|
70
|
+
*
|
|
71
|
+
* @default platform-specific transport: WebSocket on the web, TCP in node
|
|
72
|
+
*/
|
|
73
|
+
transport: TelegramTransport;
|
|
74
|
+
/**
|
|
75
|
+
* Reconnection strategy.
|
|
76
|
+
*
|
|
77
|
+
* @default simple reconnection strategy: first 0ms, then up to 5s (increasing by 1s)
|
|
78
|
+
*/
|
|
79
|
+
reconnectionStrategy?: ReconnectionStrategy;
|
|
80
|
+
/**
|
|
81
|
+
* If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,
|
|
82
|
+
* effectively disabling the server-sent events for the clients.
|
|
83
|
+
* May be useful in some cases.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
disableUpdates?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* mtcute can send all unknown RPC errors to [danog](https://github.com/danog)'s
|
|
90
|
+
* [error reporting service](https://report-rpc-error.madelineproto.xyz/).
|
|
91
|
+
*
|
|
92
|
+
* This is fully anonymous (except maybe IP) and is only used to improve the library
|
|
93
|
+
* and developer experience for everyone working with MTProto. This is fully opt-in,
|
|
94
|
+
* and if you're too paranoid, you can disable it by manually passing `enableErrorReporting: false` to the client.
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
enableErrorReporting?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Extra parameters for {@link NetworkManager}
|
|
101
|
+
*/
|
|
102
|
+
network?: NetworkManagerExtraParams;
|
|
103
|
+
/**
|
|
104
|
+
* Logger instance for the client.
|
|
105
|
+
* If not passed, a new one will be created.
|
|
106
|
+
*/
|
|
107
|
+
logger?: Logger;
|
|
108
|
+
/**
|
|
109
|
+
* Set logging level for the client.
|
|
110
|
+
* Shorthand for `client.log.level = level`.
|
|
111
|
+
*
|
|
112
|
+
* See static members of {@link LogManager} for possible values.
|
|
113
|
+
*/
|
|
114
|
+
logLevel?: number;
|
|
115
|
+
/**
|
|
116
|
+
* **EXPERT USE ONLY!**
|
|
117
|
+
*
|
|
118
|
+
* Override TL layer used for the connection.
|
|
119
|
+
*
|
|
120
|
+
* **Does not** change the schema used.
|
|
121
|
+
*/
|
|
122
|
+
overrideLayer?: number;
|
|
123
|
+
/**
|
|
124
|
+
* **EXPERT USE ONLY**
|
|
125
|
+
*
|
|
126
|
+
* Override reader map used for the connection.
|
|
127
|
+
*/
|
|
128
|
+
readerMap?: TlReaderMap;
|
|
129
|
+
/**
|
|
130
|
+
* **EXPERT USE ONLY**
|
|
131
|
+
*
|
|
132
|
+
* Override writer map used for the connection.
|
|
133
|
+
*/
|
|
134
|
+
writerMap?: TlWriterMap;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Basic MTProto client implementation, only doing the bare minimum
|
|
138
|
+
* to make RPC calls and receive low-level updates, as well as providing
|
|
139
|
+
* some APIs to manage that.
|
|
140
|
+
*/
|
|
141
|
+
export declare class MtClient {
|
|
142
|
+
readonly params: MtClientOptions;
|
|
143
|
+
/**
|
|
144
|
+
* Crypto provider taken from {@link MtClientOptions.crypto}
|
|
145
|
+
*/
|
|
146
|
+
readonly crypto: ICryptoProvider;
|
|
147
|
+
/** Storage manager */
|
|
148
|
+
readonly storage: StorageManager;
|
|
149
|
+
/**
|
|
150
|
+
* "Test mode" taken from {@link MtClientOptions.testMode}
|
|
151
|
+
*/
|
|
152
|
+
protected readonly _testMode: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Primary DCs taken from {@link MtClientOptions.defaultDcs},
|
|
155
|
+
* loaded from session or changed by other means (like redirecting).
|
|
156
|
+
*/
|
|
157
|
+
_defaultDcs: DcOptions;
|
|
158
|
+
/** TL layer used by the client */
|
|
159
|
+
readonly _layer: number;
|
|
160
|
+
/** TL readers map used by the client */
|
|
161
|
+
readonly _readerMap: TlReaderMap;
|
|
162
|
+
/** TL writers map used by the client */
|
|
163
|
+
readonly _writerMap: TlWriterMap;
|
|
164
|
+
readonly _config: ConfigManager;
|
|
165
|
+
private _emitError?;
|
|
166
|
+
readonly log: Logger;
|
|
167
|
+
readonly network: NetworkManager;
|
|
168
|
+
private _abortController;
|
|
169
|
+
readonly stopSignal: AbortSignal;
|
|
170
|
+
readonly onUsable: Emitter<void>;
|
|
171
|
+
readonly onConnecting: Emitter<void>;
|
|
172
|
+
readonly onNetworkChanged: Emitter<boolean>;
|
|
173
|
+
readonly onUpdate: Emitter<tl.TypeUpdates>;
|
|
174
|
+
constructor(params: MtClientOptions);
|
|
175
|
+
emitError(err: unknown): void;
|
|
176
|
+
private _prepare;
|
|
177
|
+
/**
|
|
178
|
+
* **ADVANCED**
|
|
179
|
+
*
|
|
180
|
+
* Do all the preparations, but don't connect just yet.
|
|
181
|
+
* Useful when you want to do some preparations before
|
|
182
|
+
* connecting, like setting up session.
|
|
183
|
+
*
|
|
184
|
+
* Call {@link connect} to actually connect.
|
|
185
|
+
*/
|
|
186
|
+
prepare(): Promise<void>;
|
|
187
|
+
private _connect;
|
|
188
|
+
/**
|
|
189
|
+
* Initialize the connection to the primary DC.
|
|
190
|
+
*
|
|
191
|
+
* You shouldn't usually call this method directly as it is called
|
|
192
|
+
* implicitly the first time you call {@link call}.
|
|
193
|
+
*/
|
|
194
|
+
connect(): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Close all connections and finalize the client.
|
|
197
|
+
*/
|
|
198
|
+
close(): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Make an RPC call.
|
|
201
|
+
*
|
|
202
|
+
* The connection must have been {@link connect}-ed
|
|
203
|
+
* before calling this method.
|
|
204
|
+
*
|
|
205
|
+
* This method is still quite low-level and you shouldn't use this
|
|
206
|
+
* when using high-level API provided by `@mtcute/client`.
|
|
207
|
+
*
|
|
208
|
+
* @param message RPC method to call
|
|
209
|
+
* @param params Additional call parameters
|
|
210
|
+
*/
|
|
211
|
+
call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions): Promise<tl.RpcCallReturn[T['_']] | mtp.RawMt_rpc_error>;
|
|
212
|
+
/**
|
|
213
|
+
* Register an error handler for the client
|
|
214
|
+
*
|
|
215
|
+
* @param handler Error handler.
|
|
216
|
+
*/
|
|
217
|
+
onError(handler: (err: unknown) => void): void;
|
|
218
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { tl } from '@mtcute/tl';
|
|
2
|
+
import { AsyncResource } from '@fuman/utils';
|
|
3
|
+
/**
|
|
4
|
+
* Config manager is responsible for keeping
|
|
5
|
+
* the current server configuration up-to-date
|
|
6
|
+
* and providing methods to find the best DC
|
|
7
|
+
* option for the current session.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConfigManager extends AsyncResource<tl.RawConfig> {
|
|
10
|
+
constructor(update: () => Promise<tl.RawConfig>);
|
|
11
|
+
findOption(params: {
|
|
12
|
+
dcId: number;
|
|
13
|
+
allowIpv6?: boolean;
|
|
14
|
+
preferIpv6?: boolean;
|
|
15
|
+
allowMedia?: boolean;
|
|
16
|
+
preferMedia?: boolean;
|
|
17
|
+
cdn?: boolean;
|
|
18
|
+
}): Promise<tl.RawDcOption | undefined>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './client.js';
|
|
2
|
+
export * from './middlewares/index.js';
|
|
3
|
+
export * from './mtproxy/index.js';
|
|
4
|
+
export type { ConnectionKind, NetworkManagerExtraParams, RpcCallMiddleware, RpcCallMiddlewareContext, RpcCallOptions, } from './network-manager.js';
|
|
5
|
+
export * from './session-connection.js';
|
|
6
|
+
export * from './transports/index.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RpcCallMiddleware } from '../network-manager.js';
|
|
2
|
+
import { FloodWaiterOptions } from './flood-waiter.js';
|
|
3
|
+
import { InternalErrorsHandlerOptions } from './internal-errors.js';
|
|
4
|
+
export interface BasicMiddlewaresOptions {
|
|
5
|
+
floodWaiter?: FloodWaiterOptions;
|
|
6
|
+
internalErrors?: InternalErrorsHandlerOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function basic(options?: BasicMiddlewaresOptions): RpcCallMiddleware[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RpcCallMiddleware } from '../network-manager.js';
|
|
2
|
+
export interface FloodWaiterOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Maximum number of ms to wait when a FLOOD_WAIT_X
|
|
5
|
+
* error is encountered. If the wait time is greater
|
|
6
|
+
* than this value, the request will throw an error instead
|
|
7
|
+
*
|
|
8
|
+
* This can be overwritten on a per-request basis by setting
|
|
9
|
+
* `floodSleepThreshold` in the request parameters
|
|
10
|
+
*
|
|
11
|
+
* @default 10_000
|
|
12
|
+
*/
|
|
13
|
+
maxWait?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of retries to perform when a FLOOD_WAIT_X
|
|
16
|
+
* error is encountered. After this number of retries, the
|
|
17
|
+
* last error will be thrown
|
|
18
|
+
*
|
|
19
|
+
* @default 5
|
|
20
|
+
*/
|
|
21
|
+
maxRetries?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to store the last flood wait time and delay
|
|
24
|
+
* the consecutive requests accordingly
|
|
25
|
+
*
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
store?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* If the stored wait time is less than this value,
|
|
31
|
+
* the request will not be delayed
|
|
32
|
+
*
|
|
33
|
+
* @default 3_000
|
|
34
|
+
*/
|
|
35
|
+
minStoredWait?: number;
|
|
36
|
+
}
|
|
37
|
+
export declare function floodWaiter(options: FloodWaiterOptions): RpcCallMiddleware;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RpcCallMiddleware } from '../network-manager.js';
|
|
2
|
+
export interface InternalErrorsHandlerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Maximum number of retries to perform when an internal server error is encountered.
|
|
5
|
+
*
|
|
6
|
+
* @default Infinity
|
|
7
|
+
*/
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Number of seconds to wait before retrying
|
|
11
|
+
* when an internal server error is encountered.
|
|
12
|
+
*
|
|
13
|
+
* @default 1
|
|
14
|
+
*/
|
|
15
|
+
waitTime?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function internalErrorsHandler(params: InternalErrorsHandlerOptions): RpcCallMiddleware;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mtp } from '@mtcute/tl';
|
|
2
|
+
import { MaybePromise } from '../../types/utils.js';
|
|
3
|
+
import { RpcCallMiddleware, RpcCallMiddlewareContext } from '../network-manager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Middleware that will call `handler` whenever an RPC error happens,
|
|
6
|
+
* with the error object itself.
|
|
7
|
+
*
|
|
8
|
+
* The handler can either return nothing
|
|
9
|
+
* (in which case the original error will be thrown), a new error
|
|
10
|
+
* (via the `_: 'mt_rpc_error'` object), or any other value, which
|
|
11
|
+
* will be returned as the result of the RPC call.
|
|
12
|
+
*
|
|
13
|
+
* Note that the return value is **not type-checked**
|
|
14
|
+
* due to limitations of TypeScript. You'll probably want to use `satisfies`
|
|
15
|
+
* keyword to ensure the return value is correct, for example:
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* networkMiddlewares.onRpcError(async (ctx, error) => {
|
|
19
|
+
* if (rpc.request._ === 'help.getNearestDc') {
|
|
20
|
+
* return {
|
|
21
|
+
* _: 'nearestDc',
|
|
22
|
+
* country: 'RU',
|
|
23
|
+
* thisDc: 2,
|
|
24
|
+
* nearestDc: 2,
|
|
25
|
+
* } satisfies tl.RpcCallReturn['help.getNearestDc']
|
|
26
|
+
* }
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function onRpcError(handler: (ctx: RpcCallMiddlewareContext, error: mtp.RawMt_rpc_error) => MaybePromise<unknown>): RpcCallMiddleware;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Middleware } from '@fuman/utils';
|
|
2
|
+
import { tl } from '@mtcute/tl';
|
|
3
|
+
import { RpcCallMiddleware, RpcCallMiddlewareContext } from '../network-manager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Middleware that will call `handler` whenever `method` RPC method is called.
|
|
6
|
+
*
|
|
7
|
+
* This helper exists due to TypeScript limitations not allowing us to
|
|
8
|
+
* properly type the return type without explicit type annotations,
|
|
9
|
+
* for a bit more type-safe and clean code:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* // before
|
|
13
|
+
* async (ctx, next) => {
|
|
14
|
+
* if (rpc.request._ === 'help.getNearestDc') {
|
|
15
|
+
* return {
|
|
16
|
+
* _: 'nearestDc',
|
|
17
|
+
* country: 'RU',
|
|
18
|
+
* thisDc: 2,
|
|
19
|
+
* nearestDc: 2,
|
|
20
|
+
* } satisfies tl.RpcCallReturn['help.getNearestDc']
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* return next(ctx)
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // after
|
|
27
|
+
* onMethod('help.getNearestDc', async () => ({
|
|
28
|
+
* _: 'nearestDc' as const, // (otherwise ts will infer this as `string` and will complain)
|
|
29
|
+
* country: 'RU',
|
|
30
|
+
* thisDc: 2,
|
|
31
|
+
* nearestDc: 2,
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function onMethod<T extends tl.RpcMethod['_']>(method: T, middleware: Middleware<Omit<RpcCallMiddlewareContext, 'request'> & {
|
|
36
|
+
request: Extract<tl.RpcMethod, {
|
|
37
|
+
_: T;
|
|
38
|
+
}>;
|
|
39
|
+
}, tl.RpcCallReturn[T]>): RpcCallMiddleware;
|