@mtkruto/node 0.1.600 → 0.1.701

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.
Files changed (115) hide show
  1. package/esm/4_errors.js +2 -4
  2. package/esm/5_client.d.ts +1 -1
  3. package/esm/5_client.js +1 -1
  4. package/esm/client/0_params.d.ts +5 -1
  5. package/esm/client/0_storage_operations.d.ts +182 -0
  6. package/esm/client/0_storage_operations.js +611 -0
  7. package/esm/client/1_composer.d.ts +2 -0
  8. package/esm/client/1_composer.js +28 -0
  9. package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
  10. package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
  11. package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
  12. package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  13. package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +1 -1
  14. package/esm/client/{1_file_manager.js → 2_file_manager.js} +5 -3
  15. package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  16. package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
  17. package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
  18. package/{script/client/2_message_manager.d.ts → esm/client/3_message_manager.d.ts} +2 -2
  19. package/esm/client/{2_video_chat_manager.d.ts → 3_video_chat_manager.d.ts} +2 -2
  20. package/{script/client/3_callback_query_manager.d.ts → esm/client/4_callback_query_manager.d.ts} +2 -2
  21. package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +3 -3
  22. package/{script/client/3_inline_query_manager.d.ts → esm/client/4_inline_query_manager.d.ts} +2 -2
  23. package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  24. package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +39 -29
  25. package/esm/client/{4_client.js → 5_client.js} +83 -73
  26. package/esm/connection/0_connection.d.ts +6 -15
  27. package/esm/connection/0_connection.js +1 -38
  28. package/esm/connection/1_connection_web_socket.d.ts +3 -2
  29. package/esm/connection/1_connection_web_socket.js +7 -3
  30. package/esm/mod.d.ts +1 -1
  31. package/esm/mod.js +1 -1
  32. package/esm/storage/0_storage.d.ts +9 -159
  33. package/esm/storage/0_storage.js +1 -563
  34. package/esm/storage/2_storage_indexed_db.d.ts +3 -2
  35. package/esm/storage/2_storage_indexed_db.js +9 -8
  36. package/esm/storage/2_storage_local_storage.d.ts +3 -2
  37. package/esm/storage/2_storage_local_storage.js +5 -4
  38. package/esm/storage/2_storage_memory.d.ts +4 -4
  39. package/esm/storage/2_storage_memory.js +12 -19
  40. package/esm/storage/2_storage_session_storage.d.ts +2 -1
  41. package/esm/storage/2_storage_session_storage.js +5 -4
  42. package/esm/types/0_id.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/script/4_errors.js +2 -4
  45. package/script/5_client.d.ts +1 -1
  46. package/script/5_client.js +1 -1
  47. package/script/client/0_params.d.ts +5 -1
  48. package/script/client/0_storage_operations.d.ts +182 -0
  49. package/script/client/0_storage_operations.js +615 -0
  50. package/script/client/1_composer.d.ts +2 -0
  51. package/script/client/1_composer.js +28 -0
  52. package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
  53. package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
  54. package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
  55. package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  56. package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +1 -1
  57. package/script/client/{1_file_manager.js → 2_file_manager.js} +4 -2
  58. package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  59. package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
  60. package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
  61. package/{esm/client/2_message_manager.d.ts → script/client/3_message_manager.d.ts} +2 -2
  62. package/script/client/{2_video_chat_manager.d.ts → 3_video_chat_manager.d.ts} +2 -2
  63. package/{esm/client/3_callback_query_manager.d.ts → script/client/4_callback_query_manager.d.ts} +2 -2
  64. package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +3 -3
  65. package/{esm/client/3_inline_query_manager.d.ts → script/client/4_inline_query_manager.d.ts} +2 -2
  66. package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  67. package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +39 -29
  68. package/script/client/{4_client.js → 5_client.js} +105 -95
  69. package/script/connection/0_connection.d.ts +6 -15
  70. package/script/connection/0_connection.js +0 -41
  71. package/script/connection/1_connection_web_socket.d.ts +3 -2
  72. package/script/connection/1_connection_web_socket.js +7 -3
  73. package/script/mod.d.ts +1 -1
  74. package/script/mod.js +1 -1
  75. package/script/storage/0_storage.d.ts +9 -159
  76. package/script/storage/0_storage.js +0 -565
  77. package/script/storage/2_storage_indexed_db.d.ts +3 -2
  78. package/script/storage/2_storage_indexed_db.js +9 -8
  79. package/script/storage/2_storage_local_storage.d.ts +3 -2
  80. package/script/storage/2_storage_local_storage.js +5 -4
  81. package/script/storage/2_storage_memory.d.ts +4 -4
  82. package/script/storage/2_storage_memory.js +12 -19
  83. package/script/storage/2_storage_session_storage.d.ts +2 -1
  84. package/script/storage/2_storage_session_storage.js +5 -4
  85. package/script/types/0_id.d.ts +1 -1
  86. /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  87. /package/esm/{3_storage.js → 2_storage.js} +0 -0
  88. /package/esm/client/{0_types.js → 1_types.js} +0 -0
  89. /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  90. /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  91. /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  92. /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  93. /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  94. /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  95. /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  96. /package/esm/client/{2_video_chat_manager.js → 3_video_chat_manager.js} +0 -0
  97. /package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +0 -0
  98. /package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +0 -0
  99. /package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +0 -0
  100. /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
  101. /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  102. /package/script/{3_storage.js → 2_storage.js} +0 -0
  103. /package/script/client/{0_types.js → 1_types.js} +0 -0
  104. /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  105. /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  106. /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  107. /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  108. /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  109. /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  110. /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  111. /package/script/client/{2_video_chat_manager.js → 3_video_chat_manager.js} +0 -0
  112. /package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +0 -0
  113. /package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +0 -0
  114. /package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +0 -0
  115. /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
@@ -18,7 +18,7 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { enums, functions, types } from "../2_tl.js";
21
- import { Storage } from "../3_storage.js";
21
+ import { StorageOperations } from "./0_storage_operations.js";
22
22
  import { ConnectionState, EntityGetter, ID, ParseMode, Update } from "../3_types.js";
23
23
  type Functions = typeof functions;
24
24
  type Keys = keyof Functions;
@@ -53,8 +53,8 @@ interface GetCdnConnectionPool {
53
53
  export interface C {
54
54
  id: number;
55
55
  api: Api;
56
- storage: Storage;
57
- messageStorage: Storage;
56
+ storage: StorageOperations;
57
+ messageStorage: StorageOperations;
58
58
  guaranteeUpdateDelivery: boolean;
59
59
  setConnectionState: (connectionState: ConnectionState) => void;
60
60
  resetConnectionState: () => void;
@@ -18,7 +18,7 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { ID } from "../3_types.js";
21
- import { C } from "./0_types.js";
21
+ import { C } from "./1_types.js";
22
22
  export declare class AccountManager {
23
23
  #private;
24
24
  constructor(c: C);
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { BotCommand } from "../3_types.js";
21
21
  import { GetMyCommandsParams, SetMyCommandsParams } from "./0_params.js";
22
- import { C } from "./0_types.js";
22
+ import { C } from "./1_types.js";
23
23
  export declare class BotInfoManager {
24
24
  #private;
25
25
  constructor(c: C);
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { Update } from "../3_types.js";
22
- import { C } from "./0_types.js";
22
+ import { C } from "./1_types.js";
23
23
  export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect;
24
24
  export declare class BusinessConnectionManager {
25
25
  #private;
@@ -1,7 +1,7 @@
1
1
  import { enums, types } from "../2_tl.js";
2
2
  import { FileSource, Sticker } from "../3_types.js";
3
3
  import { DownloadParams, UploadParams } from "./0_params.js";
4
- import { C } from "./0_types.js";
4
+ import { C } from "./1_types.js";
5
5
  export declare class FileManager {
6
6
  #private;
7
7
  constructor(c: C);
@@ -318,14 +318,16 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
318
318
  const isBig = buffer.byteLength > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD);
319
319
  const partCount = Math.ceil(buffer.byteLength / chunkSize);
320
320
  let promises = new Array();
321
- for (let part = 0; part < partCount;) {
321
+ main: for (let part = 0; part < partCount;) {
322
322
  for (let i = 0; i < pool.size; ++i) {
323
323
  const api = pool.api();
324
324
  for (let i = 0; i < __classPrivateFieldGet(_a, _a, "f", _FileManager_UPLOAD_REQUEST_PER_CONNECTION); ++i) {
325
325
  const start = part * chunkSize;
326
326
  const end = start + chunkSize;
327
327
  const bytes = buffer.subarray(start, end);
328
- (0, _0_deps_js_1.assert)(bytes.length != 0);
328
+ if (!bytes.length) {
329
+ break main;
330
+ }
329
331
  const thisPart = part++; // `thisPart` must be used instead of `part` in the promise body
330
332
  promises.push(Promise.resolve().then(async () => {
331
333
  while (true) {
@@ -17,7 +17,7 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- import { C } from "./0_types.js";
20
+ import { C } from "./1_types.js";
21
21
  export declare class NetworkStatisticsManager {
22
22
  #private;
23
23
  constructor(c: C);
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { Update } from "../3_types.js";
22
- import { C } from "./0_types.js";
22
+ import { C } from "./1_types.js";
23
23
  type ReactionManagerUpdate = types.UpdateBotMessageReactions | types.UpdateBotMessageReaction | types.UpdateMessageReactions | types.UpdateChannelMessageViews | types.UpdateChannelMessageForwards;
24
24
  export declare class ReactionManager {
25
25
  #private;
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { Queue } from "../1_utilities.js";
21
21
  import { enums, ReadObject, TLObject, types } from "../2_tl.js";
22
- import { C } from "./0_types.js";
22
+ import { C } from "./1_types.js";
23
23
  type UpdateHandler = (update: enums.Update) => Promise<(() => Promise<unknown>)>;
24
24
  export type PtsUpdate = types.UpdateNewMessage | types.UpdateDeleteMessages | types.UpdateReadHistoryInbox | types.UpdateReadHistoryOutbox | types.UpdatePinnedChannelMessages | types.UpdatePinnedMessages | types.UpdateFolderPeers | types.UpdateChannelWebPage | types.UpdateEditMessage | types.UpdateReadMessagesContents | types.UpdateWebPage;
25
25
  export type ChannelPtsUpdate = types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages | types.UpdateChannelTooLong;
@@ -21,8 +21,8 @@ import { enums, types } from "../2_tl.js";
21
21
  import { InputMedia } from "../3_types.js";
22
22
  import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
23
23
  import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendChatActionParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
24
- import { C as C_ } from "./0_types.js";
25
- import { FileManager } from "./1_file_manager.js";
24
+ import { C as C_ } from "./1_types.js";
25
+ import { FileManager } from "./2_file_manager.js";
26
26
  interface C extends C_ {
27
27
  fileManager: FileManager;
28
28
  }
@@ -20,8 +20,8 @@
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { ID, Update, VideoChatActive, VideoChatScheduled } from "../3_types.js";
22
22
  import { DownloadLiveStreamChunkParams, JoinVideoChatParams, StartVideoChatParams } from "./0_params.js";
23
- import { C as C_ } from "./0_types.js";
24
- import { FileManager } from "./1_file_manager.js";
23
+ import { C as C_ } from "./1_types.js";
24
+ import { FileManager } from "./2_file_manager.js";
25
25
  interface C extends C_ {
26
26
  fileManager: FileManager;
27
27
  }
@@ -20,8 +20,8 @@
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { CallbackQueryQuestion, ID, Update } from "../3_types.js";
22
22
  import { AnswerCallbackQueryParams } from "./0_params.js";
23
- import { C as C_ } from "./0_types.js";
24
- import { MessageManager } from "./2_message_manager.js";
23
+ import { C as C_ } from "./1_types.js";
24
+ import { MessageManager } from "./3_message_manager.js";
25
25
  type C = C_ & {
26
26
  messageManager: MessageManager;
27
27
  };
@@ -19,9 +19,9 @@
19
19
  */
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { ChatListItem, ID } from "../3_types.js";
22
- import { C as C_ } from "./0_types.js";
23
- import { FileManager } from "./1_file_manager.js";
24
- import { MessageManager } from "./2_message_manager.js";
22
+ import { C as C_ } from "./1_types.js";
23
+ import { FileManager } from "./2_file_manager.js";
24
+ import { MessageManager } from "./3_message_manager.js";
25
25
  type C = C_ & {
26
26
  fileManager: FileManager;
27
27
  messageManager: MessageManager;
@@ -20,8 +20,8 @@
20
20
  import { enums, types } from "../2_tl.js";
21
21
  import { ID, InlineQueryResult, Update } from "../3_types.js";
22
22
  import { AnswerInlineQueryParams, SendInlineQueryParams } from "./0_params.js";
23
- import { C as C_ } from "./0_types.js";
24
- import { MessageManager } from "./2_message_manager.js";
23
+ import { C as C_ } from "./1_types.js";
24
+ import { MessageManager } from "./3_message_manager.js";
25
25
  type C = C_ & {
26
26
  messageManager: MessageManager;
27
27
  };
@@ -21,9 +21,9 @@ import { enums, types } from "../2_tl.js";
21
21
  import { ID, Story, Update } from "../3_types.js";
22
22
  import { InputStoryContent } from "../types/1_input_story_content.js";
23
23
  import { CreateStoryParams } from "./0_params.js";
24
- import { C as C_ } from "./0_types.js";
25
- import { FileManager } from "./1_file_manager.js";
26
- import { MessageManager } from "./2_message_manager.js";
24
+ import { C as C_ } from "./1_types.js";
25
+ import { FileManager } from "./2_file_manager.js";
26
+ import { MessageManager } from "./3_message_manager.js";
27
27
  type C = C_ & {
28
28
  fileManager: FileManager;
29
29
  messageManager: MessageManager;
@@ -19,18 +19,19 @@
19
19
  */
20
20
  import { MaybePromise } from "../1_utilities.js";
21
21
  import { enums, functions, types } from "../2_tl.js";
22
- import { Storage } from "../3_storage.js";
22
+ import { Storage } from "../2_storage.js";
23
23
  import { DC } from "../3_transport.js";
24
24
  import { BotCommand, BusinessConnection, CallbackQueryAnswer, CallbackQueryQuestion, Chat, ChatAction, ChatListItem, ChatMember, ChatP, FileSource, ID, InactiveChat, InlineQueryAnswer, InlineQueryResult, InputMedia, InputStoryContent, InviteLink, LiveStreamChannel, Message, MessageAnimation, MessageAudio, MessageContact, MessageDice, MessageDocument, MessageLocation, MessagePhoto, MessagePoll, MessageSticker, MessageText, MessageVenue, MessageVideo, MessageVideoNote, MessageVoice, NetworkStatistics, ParseMode, Poll, Reaction, Sticker, Story, Update, User, VideoChat, VideoChatActive, VideoChatScheduled } from "../3_types.js";
25
25
  import { Migrate } from "../4_errors.js";
26
- import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, BanChatMemberParams, CreateInviteLinkParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadLiveStreamChunkParams, DownloadParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetMyCommandsParams, JoinVideoChatParams, PinMessageParams, ReplyParams, ScheduleVideoChatParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendInlineQueryParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, StartVideoChatParams, StopPollParams } from "./0_params.js";
27
- import { Api } from "./0_types.js";
26
+ import { AddReactionParams, AnswerCallbackQueryParams, AnswerInlineQueryParams, BanChatMemberParams, CreateInviteLinkParams, CreateStoryParams, DeleteMessageParams, DeleteMessagesParams, DownloadLiveStreamChunkParams, DownloadParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetChatsParams, GetCreatedInviteLinksParams, GetHistoryParams, GetMyCommandsParams, JoinVideoChatParams, PinMessageParams, ReplyParams, ScheduleVideoChatParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendContactParams, SendDiceParams, SendDocumentParams, SendInlineQueryParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetMyCommandsParams, SetReactionsParams, SignInParams, StartVideoChatParams, StopPollParams } from "./0_params.js";
27
+ import { Api } from "./1_types.js";
28
28
  import { ClientPlainParams } from "./1_client_plain.js";
29
29
  import { Composer as Composer_, NextFunction } from "./1_composer.js";
30
+ import { StorageOperations } from "./0_storage_operations.js";
30
31
  export interface Context {
31
32
  /** The client that received the update. */
32
33
  client: Client;
33
- /** The currently authorized user. */
34
+ /** The currently signed in user. */
34
35
  me?: User;
35
36
  /** Resolves to `message`, `editedMessage`, or the `message` field of `callbackQuery`. */
36
37
  msg?: Message;
@@ -184,19 +185,25 @@ export declare const restartAuth: unique symbol;
184
185
  export declare const handleMigrationError: unique symbol;
185
186
  declare const getEntity: unique symbol;
186
187
  export interface ClientParams extends ClientPlainParams {
188
+ /** The storage provider to use. Defaults to memory storage. Passing a string constructs a memory storage with the string being the auth string. */
189
+ storage?: Storage;
190
+ /** App's API ID from [my.telegram.org/apps](https://my.telegram.org/apps). Required if no account was previously authorized. */
191
+ apiId?: number;
192
+ /** App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Required if no account was previously authorized. */
193
+ apiHash?: string;
187
194
  /** A parse mode to use when the `parseMode` parameter is not specified when sending or editing messages. Defaults to `ParseMode.None`. */
188
195
  parseMode?: ParseMode;
189
- /** The app_version parameter to be passed to initConnection when calling `authorize`. It is recommended that this parameter is changed if users are authorized. Defaults to _MTKruto_. */
196
+ /** The app_version parameter to be passed to initConnection. It is recommended that this parameter is changed if users are authorized. Defaults to _MTKruto_. */
190
197
  appVersion?: string;
191
- /** The device_version parameter to be passed to initConnection when calling `authorize`. The default varies by the current runtime. */
198
+ /** The device_version parameter to be passed to initConnection. The default varies by the current runtime. */
192
199
  deviceModel?: string;
193
- /** The lang_code parameter to be passed to initConnection when calling `authorize`. Defaults to the runtime's language or `"en"`. */
200
+ /** The lang_code parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
194
201
  langCode?: string;
195
- /** The lang_pack parameter to be passed to initConnection when calling `authorize`. Defaults to an empty string. */
202
+ /** The lang_pack parameter to be passed to initConnection. Defaults to an empty string. */
196
203
  langPack?: string;
197
- /** The system_lang_cde parameter to be passed to initConnection when calling `authorize`. Defaults to the runtime's language or `"en"`. */
204
+ /** The system_lang_cde parameter to be passed to initConnection. Defaults to the runtime's language or `"en"`. */
198
205
  systemLangCode?: string;
199
- /** The system_version parameter to be passed to initConnection when calling `authorize`. The default varies by the current runtime. */
206
+ /** The system_version parameter to be passed to initConnection. The default varies by the current runtime. */
200
207
  systemVersion?: string;
201
208
  /** Whether to use default handlers. Defaults to `true`. */
202
209
  defaultHandlers?: boolean;
@@ -208,18 +215,26 @@ export interface ClientParams extends ClientPlainParams {
208
215
  guaranteeUpdateDelivery?: boolean;
209
216
  /** Whether to not handle updates received when the client was not running. Defaults to `true` for bots, and `false` for users. */
210
217
  dropPendingUpdates?: boolean;
211
- /** Whether to store messages. Defaults to `false`. */
212
- storeMessages?: boolean;
218
+ /**
219
+ * Whether to persist cache to the provided storage, and not memory. Defaults to `false`.
220
+ *
221
+ * Explicitly setting this option to `true` is highly recommended if:
222
+ *
223
+ * - User accounts are authorized.
224
+ * - Less memory usage is demanded.
225
+ * - The client does not usually have a large uptime.
226
+ *
227
+ * When the provided storage takes advantage of memory, nothing changes, even if set to `true`.
228
+ */
229
+ persistCache?: boolean;
213
230
  }
214
231
  /**
215
232
  * An MTKruto client.
216
233
  */
217
234
  export declare class Client<C extends Context = Context> extends Composer<C> {
218
235
  #private;
219
- readonly apiId: number | null;
220
- readonly apiHash: string | null;
221
- readonly storage: Storage;
222
- readonly messageStorage: Storage;
236
+ readonly storage: StorageOperations;
237
+ readonly messageStorage: StorageOperations;
223
238
  readonly appVersion: string;
224
239
  readonly deviceModel: string;
225
240
  readonly langCode: string;
@@ -233,7 +248,7 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
233
248
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
234
249
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
235
250
  */
236
- constructor(storage?: Storage | string | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
251
+ constructor(params?: ClientParams);
237
252
  get connected(): boolean;
238
253
  get disconnected(): boolean;
239
254
  api: Api;
@@ -254,24 +269,19 @@ export declare class Client<C extends Context = Context> extends Composer<C> {
254
269
  [handleMigrationError](err: Migrate): Promise<void>;
255
270
  disconnect(): Promise<void>;
256
271
  /**
257
- * Authorizes the client with one of the following:
258
- *
259
- * - Bot token (`string`)
260
- * - User authorization handlers (`AuthorizeUserParams`)
261
- *
262
- * if the current auth key doesn't throw AUTH_KEY_UNREGISTERED when calling [updates.getState](1).
272
+ * Signs in using the provided parameters if not already signed in.
273
+ * If no parameters are provided, the credentials will be prompted in runtime.
263
274
  *
264
275
  * Notes:
265
276
  * 1. Requires the `apiId` and `apiHash` paramters to be passed when constructing the client.
266
- * 2. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
267
- *
268
- * [1]: https://core.telegram.org/method/updates.getState
277
+ * 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
269
278
  */
270
- authorize(params?: string | AuthorizeUserParams): Promise<void>;
279
+ signIn(params?: SignInParams): Promise<void>;
280
+ signOut(): Promise<void>;
271
281
  /**
272
- * Same as calling `.connect()` followed by `.authorize(params)`.
282
+ * Same as calling `.connect()` followed by `.signIn(params)`.
273
283
  */
274
- start(params?: string | AuthorizeUserParams): Promise<void>;
284
+ start(params?: SignInParams): Promise<void>;
275
285
  /**
276
286
  * Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
277
287
  * to be connected.