@mtcute/core 0.16.13 → 0.17.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.
Files changed (36) hide show
  1. package/chunks/cjs/{CntZHjXA.js → BcdQkLTS.js} +83 -15
  2. package/chunks/cjs/{chPq0GcA.js → CSfUPcui.js} +914 -796
  3. package/chunks/cjs/{BO3RV06t.js → kxT7E_JE.js} +3 -3
  4. package/chunks/es/{xihQcMp0.js → BJRm2PAH.js} +3 -3
  5. package/chunks/es/{Jz_hDg6M.js → CbXFWEiB.js} +83 -15
  6. package/chunks/es/{Btmu4f4t.js → DKzd1_Yg.js} +914 -796
  7. package/client.cjs +21 -9
  8. package/client.js +21 -9
  9. package/highlevel/client.d.ts +109 -25
  10. package/highlevel/methods/files/upload-file.d.ts +8 -0
  11. package/highlevel/methods/premium/accept-star-gift.d.ts +16 -0
  12. package/highlevel/methods/premium/get-star-gift-options.d.ts +6 -0
  13. package/highlevel/methods/premium/get-star-gifts.d.ts +22 -0
  14. package/highlevel/methods/premium/iter-star-gifts.d.ts +26 -0
  15. package/highlevel/methods/premium/send-star-gift.d.ts +35 -0
  16. package/highlevel/methods/stickers/create-sticker-set.d.ts +1 -7
  17. package/highlevel/methods.d.ts +5 -1
  18. package/highlevel/types/bots/keyboards/factories.d.ts +7 -0
  19. package/highlevel/types/media/video.d.ts +1 -0
  20. package/highlevel/types/messages/message-action.d.ts +19 -2
  21. package/highlevel/types/misc/sticker-set.d.ts +1 -5
  22. package/highlevel/types/premium/index.d.ts +1 -0
  23. package/highlevel/types/premium/stars-gift.d.ts +57 -0
  24. package/highlevel/types/premium/stars-transaction.d.ts +8 -0
  25. package/index.cjs +5 -3
  26. package/index.js +7 -5
  27. package/methods.cjs +7 -3
  28. package/methods.js +7 -3
  29. package/network/client.d.ts +1 -1
  30. package/network/multi-session-connection.d.ts +1 -1
  31. package/network/persistent-connection.d.ts +1 -1
  32. package/network/transports/abstract.d.ts +1 -1
  33. package/network/transports/streamed.d.ts +1 -1
  34. package/network/transports/wrapped.d.ts +1 -1
  35. package/package.json +4 -4
  36. package/highlevel/methods/stories/report-story.d.ts +0 -19
@@ -9,11 +9,11 @@ const Long = require("long");
9
9
  const conditionVariable = require("./eX3zeDAz.js");
10
10
  const platform = require("./j7rWn_1y.js");
11
11
  const controllablePromise = require("./CZAB54t2.js");
12
- const storyViewer = require("./chPq0GcA.js");
12
+ const storyViewer = require("./CSfUPcui.js");
13
13
  const tlRuntime = require("@mtcute/tl-runtime");
14
14
  const tl = require("@mtcute/tl");
15
15
  const peersIndex = require("./ija5tZ1t.js");
16
- const EventEmitter = require("node:events");
16
+ const EventEmitter = require("events");
17
17
  const reader_js = require("@mtcute/tl/binary/reader.js");
18
18
  const writer_js = require("@mtcute/tl/binary/writer.js");
19
19
  const logger = require("./D4qcXFYA.js");
@@ -6215,7 +6215,7 @@ class NetworkManager {
6215
6215
  _: "initConnection",
6216
6216
  deviceModel,
6217
6217
  systemVersion: "1.0",
6218
- appVersion: "0.16.13",
6218
+ appVersion: "0.17.0",
6219
6219
  systemLangCode: "en",
6220
6220
  langPack: "",
6221
6221
  // "langPacks are for official apps only"
@@ -3,11 +3,11 @@ import Long from "long";
3
3
  import { LruMap, getAllPeersFrom, toggleChannelIdMark, longToFastString, extractUsernames, parseMarkedPeerId, longFromFastString, Deque, AsyncLock, getMarkedPeerId, setTimeoutWrap, clearTimeoutWrap, makeInspectable, getBarePeerId, encodeInlineMessageId, assertNever, ConditionVariable, clearIntervalWrap, setIntervalWrap, toInputChannel, sleepWithAbort, buffersEqual, dataViewFromBuffer, concatBuffers, randomLong, LongMap, compareLongs, getRandomInt, longFromBuffer, removeFromLongArray } from "./DY1E3mHM.js";
4
4
  import { MtArgumentError, MtTimeoutError, getPlatform, MtUnsupportedError, MtcuteError, MtSecurityError, MtTypeAssertionError } from "./DBMBgE7t.js";
5
5
  import { createControllablePromise, assertTypeIs, isTlRpcError, mtpAssertTypeIs } from "./BN3qj7tU.js";
6
- import { resolvePeer, getPeerDialogs, sendText, sendMedia, sendMediaGroup, readHistory, memoizeGetters, Chat$2, User$2, ChatInviteLink$2, Message$2, ChatMember$2, Location$1, parsePeer, toReactionEmoji, ReactionCount$1, Poll$2, Story$2, toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer, extractChannelIdFromUpdate, _getChannelsBatched } from "./Btmu4f4t.js";
6
+ import { resolvePeer, getPeerDialogs, sendText, sendMedia, sendMediaGroup, readHistory, memoizeGetters, Chat$2, User$2, ChatInviteLink$2, Message$2, ChatMember$2, Location$1, parsePeer, toReactionEmoji, ReactionCount$1, Poll$2, Story$2, toPendingUpdate, messageToUpdate, isMessageEmpty, createDummyUpdatesContainer, extractChannelIdFromUpdate, _getChannelsBatched } from "./DKzd1_Yg.js";
7
7
  import { TlBinaryWriter, TlBinaryReader, TlSerializationCounter } from "@mtcute/tl-runtime";
8
8
  import { tl, mtp } from "@mtcute/tl";
9
9
  import { PeersIndex } from "./N3PMYmCL.js";
10
- import EventEmitter from "node:events";
10
+ import EventEmitter from "events";
11
11
  import { __tlReaderMap } from "@mtcute/tl/binary/reader.js";
12
12
  import { __tlWriterMap } from "@mtcute/tl/binary/writer.js";
13
13
  import { LogManager } from "./BRgz_-S8.js";
@@ -6209,7 +6209,7 @@ class NetworkManager {
6209
6209
  _: "initConnection",
6210
6210
  deviceModel,
6211
6211
  systemVersion: "1.0",
6212
- appVersion: "0.16.13",
6212
+ appVersion: "0.17.0",
6213
6213
  systemLangCode: "en",
6214
6214
  langPack: "",
6215
6215
  // "langPacks are for official apps only"
@@ -2,7 +2,7 @@ import { getPlatform, MtArgumentError, MtcuteError, MtTypeAssertionError, MtUnsu
2
2
  import { tl } from "@mtcute/tl";
3
3
  import { normalizePhoneNumber, sleepWithAbort, resolveMaybeDynamic, assertNever, normalizeInlineId, isInputPeerChat, isInputPeerChannel, toInputChannel, toInputUser, normalizeDate, isInputPeerUser, makeArrayWithTotal, INVITE_LINK_REGEX, getMarkedPeerId, determinePartSize, ConditionVariable, concatBuffers, bufferToStream, randomLong, makeArrayPaginated, LongMap, toggleChannelIdMark, LongSet, parseMarkedPeerId } from "./DY1E3mHM.js";
4
4
  import { assertTypeIs, createControllablePromise, assertTrue, MtInvalidPeerTypeError, isPresent, MtPeerNotFoundError, assertTypeIsNot, MtMessageNotFoundError, hasValueAtKey } from "./BN3qj7tU.js";
5
- import { User$2, SentCode$1, _convertToTl, resolveUser, resolvePeer, normalizeInputMessageId, GameHighScore$2, _findMessageInUpdate, resolvePeerMany, assertIsUpdatesGroup, Chat$2, resolveChannel, createDummyUpdate, ChatEvent$2, ChatMember$2, ChatPreview$2, _getRawPeerBatched, FullChat$2, getPeerDialogs, uploadFile, fileIdToInputPhoto, isUploadedFile, Dialog$2, ChatlistPreview$2, FileLocation$1, fileIdToInputWebFileLocation, fileIdToInputFileLocation, _normalizeInputMedia, parseDocument, Photo$2, ForumTopic$2, ChatInviteLink$2, ChatInviteLinkMember$2, Poll$2, _normalizeInputText, _convertToTl$1, _maybeInvokeWithBusinessConnection, _normalizeQuickReplyShortcut, Message$2, MessageEffect$2, FactCheck$2, _getDiscussionMessage, getMessages, MessageReactions$2, normalizeInputReaction, PeerReaction$2, SearchFilters, sendText, sendMedia, sendMediaGroup, CollectibleInfo$1, TakeoutSession$1, BoostSlot$2, BusinessChatLink$2, BoostStats$1, Boost$2, StarsStatus$2, businessWorkHoursDaysToRaw, MASK_POSITION_POINT_TO_TL, normalizeInputStickerSet, StickerSet$2, fileIdToInputDocument, Story$2, AllStories$2, PeerStories$2, StoryInteractions$2, StoryViewersList$2, StoriesStealthMode$1, _getUsersBatched, _normalizePeerId, _normalizeInputFile } from "./Btmu4f4t.js";
5
+ import { User$2, SentCode$1, _convertToTl, resolveUser, resolvePeer, normalizeInputMessageId, GameHighScore$2, _findMessageInUpdate, resolvePeerMany, assertIsUpdatesGroup, Chat$2, resolveChannel, createDummyUpdate, ChatEvent$2, ChatMember$2, ChatPreview$2, _getRawPeerBatched, FullChat$2, getPeerDialogs, uploadFile, fileIdToInputPhoto, isUploadedFile, Dialog$2, ChatlistPreview$2, FileLocation$1, fileIdToInputWebFileLocation, fileIdToInputFileLocation, _normalizeInputMedia, parseDocument, Photo$2, ForumTopic$2, ChatInviteLink$2, ChatInviteLinkMember$2, Poll$2, _normalizeInputText, _convertToTl$1, _maybeInvokeWithBusinessConnection, _normalizeQuickReplyShortcut, Message$2, MessageEffect$2, FactCheck$2, _getDiscussionMessage, getMessages, MessageReactions$2, normalizeInputReaction, PeerReaction$2, SearchFilters, sendText, sendMedia, sendMediaGroup, CollectibleInfo$1, TakeoutSession$1, BoostSlot$2, BusinessChatLink$2, BoostStats$1, Boost$2, StarGift$2, UserStarGift$2, StarsStatus$2, inputTextToTl, businessWorkHoursDaysToRaw, MASK_POSITION_POINT_TO_TL, normalizeInputStickerSet, StickerSet$2, fileIdToInputDocument, Story$2, AllStories$2, PeerStories$2, StoryInteractions$2, StoryViewersList$2, StoriesStealthMode$1, _getUsersBatched, _normalizePeerId, _normalizeInputFile } from "./DKzd1_Yg.js";
6
6
  import Long from "long";
7
7
  import { PeersIndex } from "./N3PMYmCL.js";
8
8
  import { tdFileId, parseFileId } from "@mtcute/file-id";
@@ -3855,6 +3855,23 @@ async function removeCloudPassword(client, password) {
3855
3855
  }
3856
3856
  });
3857
3857
  }
3858
+ async function acceptStarGift(client, params) {
3859
+ const { action } = params;
3860
+ const { chatId, message: message2 } = normalizeInputMessageId(params);
3861
+ const userId = await resolveUser(client, chatId);
3862
+ return client.call(
3863
+ action === "convert" ? {
3864
+ _: "payments.convertStarGift",
3865
+ userId,
3866
+ msgId: message2
3867
+ } : {
3868
+ _: "payments.saveStarGift",
3869
+ unsave: action === "hide",
3870
+ userId,
3871
+ msgId: message2
3872
+ }
3873
+ );
3874
+ }
3858
3875
  async function applyBoost(client, peerId) {
3859
3876
  await client.call({
3860
3877
  _: "premium.applyBoost",
@@ -3943,6 +3960,26 @@ async function getBusinessChatLinks(client) {
3943
3960
  const res = await client.call({ _: "account.getBusinessChatLinks" });
3944
3961
  return res.links.map((x) => new BusinessChatLink$2(x));
3945
3962
  }
3963
+ async function getStarGiftOptions(client) {
3964
+ const res = await client.call({
3965
+ _: "payments.getStarGifts",
3966
+ hash: 0
3967
+ });
3968
+ assertTypeIsNot("payments.getStarGifts", res, "payments.starGiftsNotModified");
3969
+ return res.gifts.map((gift) => new StarGift$2(gift));
3970
+ }
3971
+ async function getStarGifts(client, userId, params) {
3972
+ const { offset = "", limit = 100 } = params ?? {};
3973
+ const res = await client.call({
3974
+ _: "payments.getUserStarGifts",
3975
+ userId: await resolveUser(client, userId),
3976
+ offset,
3977
+ limit
3978
+ });
3979
+ const peers = PeersIndex.from(res);
3980
+ const gifts = res.gifts.map((gift) => new UserStarGift$2(gift, peers));
3981
+ return makeArrayPaginated(gifts, res.count, offset);
3982
+ }
3946
3983
  async function getStarsTransactions(client, peerId, params) {
3947
3984
  const { direction, sort, subscriptionId, offset = "", limit = 100 } = params ?? {};
3948
3985
  const res = await client.call({
@@ -3976,6 +4013,25 @@ async function* iterBoosters(client, peerId, params) {
3976
4013
  offset = res.next;
3977
4014
  }
3978
4015
  }
4016
+ async function* iterStarGifts(client, peerId, params) {
4017
+ if (!params) params = {};
4018
+ const { limit = Infinity, chunkSize = 100 } = params;
4019
+ let { offset } = params;
4020
+ let current = 0;
4021
+ const peer = await resolvePeer(client, peerId);
4022
+ for (; ; ) {
4023
+ const res = await getStarGifts(client, peer, {
4024
+ offset,
4025
+ limit: Math.min(limit - current, chunkSize)
4026
+ });
4027
+ for (const gift of res) {
4028
+ yield gift;
4029
+ if (++current >= limit) return;
4030
+ }
4031
+ if (!res.next) return;
4032
+ offset = res.next;
4033
+ }
4034
+ }
3979
4035
  async function* iterStarsTransactions(client, peerId, params) {
3980
4036
  if (!params) params = {};
3981
4037
  const { limit = Infinity, chunkSize = 100 } = params;
@@ -3995,6 +4051,27 @@ async function* iterStarsTransactions(client, peerId, params) {
3995
4051
  offset = res.transactionsNextOffset;
3996
4052
  }
3997
4053
  }
4054
+ async function sendStarGift(client, params) {
4055
+ const { userId, gift, anonymous, message: message2, shouldDispatch } = params;
4056
+ const invoice = {
4057
+ _: "inputInvoiceStarGift",
4058
+ hideName: anonymous,
4059
+ userId: await resolveUser(client, userId),
4060
+ giftId: Long.isLong(gift) ? gift : gift.id,
4061
+ message: message2 ? inputTextToTl(message2) : void 0
4062
+ };
4063
+ const form = await client.call({
4064
+ _: "payments.getPaymentForm",
4065
+ invoice
4066
+ });
4067
+ const res = await client.call({
4068
+ _: "payments.sendStarsForm",
4069
+ invoice,
4070
+ formId: form.formId
4071
+ });
4072
+ assertTypeIs("payments.sendStarsForm", res, "payments.paymentResult");
4073
+ return _findMessageInUpdate(client, res.updates, false, !shouldDispatch);
4074
+ }
3998
4075
  async function _normalizeFileToDocument(client, file, params) {
3999
4076
  if (typeof file === "object" && tl.isAnyInputDocument(file)) {
4000
4077
  return file;
@@ -4095,8 +4172,6 @@ async function createStickerSet(client, params) {
4095
4172
  }
4096
4173
  const res = await client.call({
4097
4174
  _: "stickers.createStickerSet",
4098
- animated: params.sourceType === "animated",
4099
- videos: params.sourceType === "video",
4100
4175
  masks: params.type === "mask",
4101
4176
  emojis: params.type === "emoji",
4102
4177
  textColor: params.adaptive,
@@ -4449,17 +4524,6 @@ async function readStories(client, peerId, maxId) {
4449
4524
  maxId
4450
4525
  });
4451
4526
  }
4452
- async function reportStory(client, peerId, storyIds, params) {
4453
- const { reason = { _: "inputReportReasonSpam" }, message: message2 = "" } = params ?? {};
4454
- const r = await client.call({
4455
- _: "stories.report",
4456
- peer: await resolvePeer(client, peerId),
4457
- id: Array.isArray(storyIds) ? storyIds : [storyIds],
4458
- message: message2,
4459
- reason
4460
- });
4461
- assertTrue("stories.report", r);
4462
- }
4463
4527
  async function sendStoryReaction(client, params) {
4464
4528
  const { peerId, storyId, reaction, addToRecent } = params;
4465
4529
  const res = await client.call({
@@ -4762,6 +4826,7 @@ async function updateProfile(client, params) {
4762
4826
  }
4763
4827
  export {
4764
4828
  _normalizePrivacyRules,
4829
+ acceptStarGift,
4765
4830
  addChatMembers,
4766
4831
  addContact,
4767
4832
  addStickerToSet,
@@ -4883,6 +4948,8 @@ export {
4883
4948
  getReplyTo,
4884
4949
  getScheduledMessages,
4885
4950
  getSimilarChannels,
4951
+ getStarGiftOptions,
4952
+ getStarGifts,
4886
4953
  getStarsTransactions,
4887
4954
  getStickerSet,
4888
4955
  getStoriesById,
@@ -4913,6 +4980,7 @@ export {
4913
4980
  iterSearchGlobal,
4914
4981
  iterSearchHashtag,
4915
4982
  iterSearchMessages,
4983
+ iterStarGifts,
4916
4984
  iterStarsTransactions,
4917
4985
  iterStoryViewers,
4918
4986
  joinChat,
@@ -4937,7 +5005,6 @@ export {
4937
5005
  replyMedia,
4938
5006
  replyMediaGroup,
4939
5007
  replyText,
4940
- reportStory,
4941
5008
  resendCode,
4942
5009
  resendPasswordEmail,
4943
5010
  restrictChatMember,
@@ -4954,6 +5021,7 @@ export {
4954
5021
  sendReaction,
4955
5022
  sendRecoveryCode,
4956
5023
  sendScheduled,
5024
+ sendStarGift,
4957
5025
  sendStory,
4958
5026
  sendStoryReaction,
4959
5027
  sendTyping,