@mtcute/core 0.25.4 → 0.25.6

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 (31) hide show
  1. package/highlevel/client.types.d.cts +83 -0
  2. package/highlevel/client.types.d.ts +83 -0
  3. package/highlevel/methods/premium/get-saved-star-gifts.cjs +1 -0
  4. package/highlevel/methods/premium/get-saved-star-gifts.d.cts +2 -0
  5. package/highlevel/methods/premium/get-saved-star-gifts.d.ts +2 -0
  6. package/highlevel/methods/premium/get-saved-star-gifts.js +1 -0
  7. package/highlevel/types/peers/full-user.cjs +6 -0
  8. package/highlevel/types/peers/full-user.d.cts +4 -0
  9. package/highlevel/types/peers/full-user.d.ts +4 -0
  10. package/highlevel/types/peers/full-user.js +6 -0
  11. package/highlevel/types/premium/saved-star-gift.cjs +4 -0
  12. package/highlevel/types/premium/saved-star-gift.d.cts +2 -0
  13. package/highlevel/types/premium/saved-star-gift.d.ts +2 -0
  14. package/highlevel/types/premium/saved-star-gift.js +4 -0
  15. package/highlevel/types/premium/stars-gift-unique.cjs +4 -0
  16. package/highlevel/types/premium/stars-gift-unique.d.cts +2 -0
  17. package/highlevel/types/premium/stars-gift-unique.d.ts +2 -0
  18. package/highlevel/types/premium/stars-gift-unique.js +4 -0
  19. package/highlevel/types/premium/stars-gift.cjs +16 -0
  20. package/highlevel/types/premium/stars-gift.d.cts +10 -0
  21. package/highlevel/types/premium/stars-gift.d.ts +10 -0
  22. package/highlevel/types/premium/stars-gift.js +16 -0
  23. package/network/network-manager.cjs +1 -1
  24. package/network/network-manager.js +1 -1
  25. package/network/session-connection.cjs +5 -1
  26. package/network/session-connection.d.cts +1 -0
  27. package/network/session-connection.d.ts +1 -0
  28. package/network/session-connection.js +5 -1
  29. package/package.json +2 -2
  30. package/utils/binary/compat.cjs +3 -0
  31. package/utils/binary/compat.js +3 -0
@@ -24,39 +24,122 @@ import { InputStringSessionData } from './utils/string-session.js';
24
24
  */
25
25
  export type ConnectionState = 'offline' | 'connecting' | 'updating' | 'connected';
26
26
  export interface ITelegramClient {
27
+ /** Logger for the client */
27
28
  readonly log: Logger;
29
+ /** Storage manager */
28
30
  readonly storage: PublicPart<TelegramStorageManager>;
31
+ /** App config manager */
29
32
  readonly appConfig: PublicPart<AppConfigManager>;
33
+ /** Timers manager */
30
34
  readonly timers: Pick<TimersManager, 'create' | 'cancel' | 'exists'>;
35
+ /** Signal that will be aborted when the client is destroyed */
31
36
  readonly stopSignal: AbortSignal;
37
+ /** Platform used by the client */
32
38
  readonly platform: ICorePlatform;
39
+ /**
40
+ * **ADVANCED**
41
+ *
42
+ * Do all the preparations, but don't connect just yet.
43
+ * Useful when you want to do some preparations before
44
+ * connecting, like setting up session.
45
+ *
46
+ * Call {@link connect} to actually connect.
47
+ */
33
48
  prepare(): Promise<void>;
49
+ /**
50
+ * Initialize the connection to the primary DC.
51
+ *
52
+ * You shouldn't usually call this method directly as it is called
53
+ * implicitly the first time you call {@link call}.
54
+ */
34
55
  connect(): Promise<void>;
56
+ /**
57
+ * Terminate any connections to the Telegram servers, but keep the client usable
58
+ */
35
59
  disconnect(): Promise<void>;
60
+ /**
61
+ * Destroy the client and all its resources.
62
+ *
63
+ * This will terminate any connections to the Telegram servers,
64
+ * free all the resources, and make the client no longer usable
65
+ */
36
66
  destroy(): Promise<void>;
67
+ /** Notify the client that the user has logged in */
37
68
  notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>;
69
+ /** Notify the client that the user has logged out */
38
70
  notifyLoggedOut(): Promise<void>;
71
+ /** Notify the client that a channel has been opened */
39
72
  notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>;
73
+ /** Notify the client that a channel has been closed */
40
74
  notifyChannelClosed(channelId: number): Promise<boolean>;
75
+ /** Start the updates loop */
41
76
  startUpdatesLoop(): Promise<void>;
77
+ /** Stop the updates loop */
42
78
  stopUpdatesLoop(): Promise<void>;
79
+ /** Call an RPC method */
43
80
  call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions): Promise<tl.RpcCallReturn[T['_']]>;
81
+ /**
82
+ * Import the session from the given session string.
83
+ *
84
+ * Note that the session will only be imported in case
85
+ * the storage is missing authorization (i.e. does not contain
86
+ * auth key for the primary DC), otherwise it will be ignored (unless `force`).
87
+ *
88
+ * @param session Session string to import
89
+ * @param force Whether to overwrite existing session
90
+ */
44
91
  importSession(session: string | InputStringSessionData, force?: boolean): Promise<void>;
92
+ /**
93
+ * Export current session to a single *LONG* string, containing
94
+ * all the needed information.
95
+ *
96
+ * > **Warning!** Anyone with this string will be able
97
+ * > to authorize as you and do anything. Treat this
98
+ * > as your password, and never give it away!
99
+ * >
100
+ * > In case you have accidentally leaked this string,
101
+ * > make sure to revoke this session in account settings:
102
+ * > "Privacy & Security" > "Active sessions" >
103
+ * > find the one containing `mtcute` > Revoke,
104
+ * > or, in case this is a bot, revoke bot token
105
+ * > with [@BotFather](//t.me/botfather)
106
+ */
45
107
  exportSession(): Promise<string>;
108
+ /**
109
+ * Handle an update sent by the server in response to an RPC call
110
+ *
111
+ * @param updates Updates to handle
112
+ * @param noDispatch Whether the updates inside should not be dispatched as events
113
+ */
46
114
  handleClientUpdate(updates: tl.TypeUpdates, noDispatch?: boolean): void;
115
+ /** Emitted when a low-level `Updates` updates is received */
47
116
  onServerUpdate: Emitter<tl.TypeUpdates>;
117
+ /** Emitted when an update is received from the server. Requires updates loop to be running */
48
118
  onRawUpdate: Emitter<RawUpdateInfo>;
119
+ /** Emitted when the connection state changes */
49
120
  onConnectionState: Emitter<ConnectionState>;
121
+ /** Emitted when an error occurs */
50
122
  onError: Emitter<Error>;
123
+ /** Get the API credentials for use in authorization methods */
51
124
  getApiCredentials(): Promise<{
52
125
  id: number;
53
126
  hash: string;
54
127
  }>;
128
+ /** Get the number of connections of the given kind */
55
129
  getPoolSize(kind: ConnectionKind, dcId?: number): Promise<number>;
130
+ /** Get the primary DC ID */
56
131
  getPrimaryDcId(): Promise<number>;
132
+ /** Change the primary DC */
57
133
  changePrimaryDc(newDc: number): Promise<void>;
134
+ /** Compute SRP parameters for the given password */
58
135
  computeSrpParams(request: tl.account.RawPassword, password: string): Promise<tl.RawInputCheckPasswordSRP>;
136
+ /** Compute new password hash for the given algorithm and password */
59
137
  computeNewPasswordHash(algo: tl.TypePasswordKdfAlgo, password: string): Promise<Uint8Array>;
138
+ /** Generate a new time-based MTProto message ID */
60
139
  getMtprotoMessageId(): Promise<Long>;
140
+ /**
141
+ * **ADVANCED**
142
+ * Recreate the given DC, forcefully using the IP taken from server config.
143
+ */
61
144
  recreateDc(dcId: number): Promise<void>;
62
145
  }
@@ -24,39 +24,122 @@ import { InputStringSessionData } from './utils/string-session.js';
24
24
  */
25
25
  export type ConnectionState = 'offline' | 'connecting' | 'updating' | 'connected';
26
26
  export interface ITelegramClient {
27
+ /** Logger for the client */
27
28
  readonly log: Logger;
29
+ /** Storage manager */
28
30
  readonly storage: PublicPart<TelegramStorageManager>;
31
+ /** App config manager */
29
32
  readonly appConfig: PublicPart<AppConfigManager>;
33
+ /** Timers manager */
30
34
  readonly timers: Pick<TimersManager, 'create' | 'cancel' | 'exists'>;
35
+ /** Signal that will be aborted when the client is destroyed */
31
36
  readonly stopSignal: AbortSignal;
37
+ /** Platform used by the client */
32
38
  readonly platform: ICorePlatform;
39
+ /**
40
+ * **ADVANCED**
41
+ *
42
+ * Do all the preparations, but don't connect just yet.
43
+ * Useful when you want to do some preparations before
44
+ * connecting, like setting up session.
45
+ *
46
+ * Call {@link connect} to actually connect.
47
+ */
33
48
  prepare(): Promise<void>;
49
+ /**
50
+ * Initialize the connection to the primary DC.
51
+ *
52
+ * You shouldn't usually call this method directly as it is called
53
+ * implicitly the first time you call {@link call}.
54
+ */
34
55
  connect(): Promise<void>;
56
+ /**
57
+ * Terminate any connections to the Telegram servers, but keep the client usable
58
+ */
35
59
  disconnect(): Promise<void>;
60
+ /**
61
+ * Destroy the client and all its resources.
62
+ *
63
+ * This will terminate any connections to the Telegram servers,
64
+ * free all the resources, and make the client no longer usable
65
+ */
36
66
  destroy(): Promise<void>;
67
+ /** Notify the client that the user has logged in */
37
68
  notifyLoggedIn(auth: tl.auth.TypeAuthorization | tl.RawUser): Promise<tl.RawUser>;
69
+ /** Notify the client that the user has logged out */
38
70
  notifyLoggedOut(): Promise<void>;
71
+ /** Notify the client that a channel has been opened */
39
72
  notifyChannelOpened(channelId: number, pts?: number): Promise<boolean>;
73
+ /** Notify the client that a channel has been closed */
40
74
  notifyChannelClosed(channelId: number): Promise<boolean>;
75
+ /** Start the updates loop */
41
76
  startUpdatesLoop(): Promise<void>;
77
+ /** Stop the updates loop */
42
78
  stopUpdatesLoop(): Promise<void>;
79
+ /** Call an RPC method */
43
80
  call<T extends tl.RpcMethod>(message: MustEqual<T, tl.RpcMethod>, params?: RpcCallOptions): Promise<tl.RpcCallReturn[T['_']]>;
81
+ /**
82
+ * Import the session from the given session string.
83
+ *
84
+ * Note that the session will only be imported in case
85
+ * the storage is missing authorization (i.e. does not contain
86
+ * auth key for the primary DC), otherwise it will be ignored (unless `force`).
87
+ *
88
+ * @param session Session string to import
89
+ * @param force Whether to overwrite existing session
90
+ */
44
91
  importSession(session: string | InputStringSessionData, force?: boolean): Promise<void>;
92
+ /**
93
+ * Export current session to a single *LONG* string, containing
94
+ * all the needed information.
95
+ *
96
+ * > **Warning!** Anyone with this string will be able
97
+ * > to authorize as you and do anything. Treat this
98
+ * > as your password, and never give it away!
99
+ * >
100
+ * > In case you have accidentally leaked this string,
101
+ * > make sure to revoke this session in account settings:
102
+ * > "Privacy & Security" > "Active sessions" >
103
+ * > find the one containing `mtcute` > Revoke,
104
+ * > or, in case this is a bot, revoke bot token
105
+ * > with [@BotFather](//t.me/botfather)
106
+ */
45
107
  exportSession(): Promise<string>;
108
+ /**
109
+ * Handle an update sent by the server in response to an RPC call
110
+ *
111
+ * @param updates Updates to handle
112
+ * @param noDispatch Whether the updates inside should not be dispatched as events
113
+ */
46
114
  handleClientUpdate(updates: tl.TypeUpdates, noDispatch?: boolean): void;
115
+ /** Emitted when a low-level `Updates` updates is received */
47
116
  onServerUpdate: Emitter<tl.TypeUpdates>;
117
+ /** Emitted when an update is received from the server. Requires updates loop to be running */
48
118
  onRawUpdate: Emitter<RawUpdateInfo>;
119
+ /** Emitted when the connection state changes */
49
120
  onConnectionState: Emitter<ConnectionState>;
121
+ /** Emitted when an error occurs */
50
122
  onError: Emitter<Error>;
123
+ /** Get the API credentials for use in authorization methods */
51
124
  getApiCredentials(): Promise<{
52
125
  id: number;
53
126
  hash: string;
54
127
  }>;
128
+ /** Get the number of connections of the given kind */
55
129
  getPoolSize(kind: ConnectionKind, dcId?: number): Promise<number>;
130
+ /** Get the primary DC ID */
56
131
  getPrimaryDcId(): Promise<number>;
132
+ /** Change the primary DC */
57
133
  changePrimaryDc(newDc: number): Promise<void>;
134
+ /** Compute SRP parameters for the given password */
58
135
  computeSrpParams(request: tl.account.RawPassword, password: string): Promise<tl.RawInputCheckPasswordSRP>;
136
+ /** Compute new password hash for the given algorithm and password */
59
137
  computeNewPasswordHash(algo: tl.TypePasswordKdfAlgo, password: string): Promise<Uint8Array>;
138
+ /** Generate a new time-based MTProto message ID */
60
139
  getMtprotoMessageId(): Promise<Long>;
140
+ /**
141
+ * **ADVANCED**
142
+ * Recreate the given DC, forcefully using the IP taken from server config.
143
+ */
61
144
  recreateDc(dcId: number): Promise<void>;
62
145
  }
@@ -19,6 +19,7 @@ async function getSavedStarGifts(client, params) {
19
19
  excludeLimited: params.excludeLimited,
20
20
  excludeUnique: params.excludeUnique,
21
21
  sortByValue: params.sortByValue,
22
+ collectionId: params.collectionId,
22
23
  offset: params.offset ?? "",
23
24
  limit: params.limit ?? 100
24
25
  });
@@ -19,6 +19,8 @@ export declare function getSavedStarGifts(client: ITelegramClient, params: {
19
19
  excludeLimited?: boolean;
20
20
  /** Whether to exclude unique gifts */
21
21
  excludeUnique?: boolean;
22
+ /** ID of the collection to get gifts from */
23
+ collectionId?: number;
22
24
  /** Whether to sort by value */
23
25
  sortByValue?: boolean;
24
26
  /** Offset for pagination */
@@ -19,6 +19,8 @@ export declare function getSavedStarGifts(client: ITelegramClient, params: {
19
19
  excludeLimited?: boolean;
20
20
  /** Whether to exclude unique gifts */
21
21
  excludeUnique?: boolean;
22
+ /** ID of the collection to get gifts from */
23
+ collectionId?: number;
22
24
  /** Whether to sort by value */
23
25
  sortByValue?: boolean;
24
26
  /** Offset for pagination */
@@ -12,6 +12,7 @@ async function getSavedStarGifts(client, params) {
12
12
  excludeLimited: params.excludeLimited,
13
13
  excludeUnique: params.excludeUnique,
14
14
  sortByValue: params.sortByValue,
15
+ collectionId: params.collectionId,
15
16
  offset: params.offset ?? "",
16
17
  limit: params.limit ?? 100
17
18
  });
@@ -216,6 +216,12 @@ class FullUser extends user.User {
216
216
  if (!this.full.botVerification) return null;
217
217
  return new botVerification.BotVerification(this.full.botVerification);
218
218
  }
219
+ /**
220
+ * Information about the user's stars rating
221
+ */
222
+ get starsRating() {
223
+ return this.full.starsRating ?? null;
224
+ }
219
225
  }
220
226
  const FullUser$1 = /* @__PURE__ */ memoize.memoizeGetters(FullUser, [
221
227
  "fullPhoto",
@@ -119,4 +119,8 @@ export declare class FullUser extends User {
119
119
  get business(): BusinessAccount | null;
120
120
  /** Information about a bot-issued verification (if any) */
121
121
  get botVerification(): BotVerification | null;
122
+ /**
123
+ * Information about the user's stars rating
124
+ */
125
+ get starsRating(): tl.RawStarsRating | null;
122
126
  }
@@ -119,4 +119,8 @@ export declare class FullUser extends User {
119
119
  get business(): BusinessAccount | null;
120
120
  /** Information about a bot-issued verification (if any) */
121
121
  get botVerification(): BotVerification | null;
122
+ /**
123
+ * Information about the user's stars rating
124
+ */
125
+ get starsRating(): tl.RawStarsRating | null;
122
126
  }
@@ -209,6 +209,12 @@ class FullUser extends User$2 {
209
209
  if (!this.full.botVerification) return null;
210
210
  return new BotVerification$1(this.full.botVerification);
211
211
  }
212
+ /**
213
+ * Information about the user's stars rating
214
+ */
215
+ get starsRating() {
216
+ return this.full.starsRating ?? null;
217
+ }
212
218
  }
213
219
  const FullUser$1 = /* @__PURE__ */ memoizeGetters(FullUser, [
214
220
  "fullPhoto",
@@ -86,6 +86,10 @@ class SavedStarGift {
86
86
  get canResellAt() {
87
87
  return this.raw.canResellAt ? new Date(this.raw.canResellAt * 1e3) : null;
88
88
  }
89
+ /** IDs of the collections this gift belongs to */
90
+ get collectionIds() {
91
+ return this.raw.collectionId ?? [];
92
+ }
89
93
  }
90
94
  const SavedStarGift$1 = /* @__PURE__ */ inspectable.makeInspectable(SavedStarGift);
91
95
  const SavedStarGift$2 = /* @__PURE__ */ memoize.memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
@@ -42,4 +42,6 @@ export declare class SavedStarGift {
42
42
  get canTransferAt(): Date | null;
43
43
  /** Date when the gift can be resold */
44
44
  get canResellAt(): Date | null;
45
+ /** IDs of the collections this gift belongs to */
46
+ get collectionIds(): number[];
45
47
  }
@@ -42,4 +42,6 @@ export declare class SavedStarGift {
42
42
  get canTransferAt(): Date | null;
43
43
  /** Date when the gift can be resold */
44
44
  get canResellAt(): Date | null;
45
+ /** IDs of the collections this gift belongs to */
46
+ get collectionIds(): number[];
45
47
  }
@@ -79,6 +79,10 @@ class SavedStarGift {
79
79
  get canResellAt() {
80
80
  return this.raw.canResellAt ? new Date(this.raw.canResellAt * 1e3) : null;
81
81
  }
82
+ /** IDs of the collections this gift belongs to */
83
+ get collectionIds() {
84
+ return this.raw.collectionId ?? [];
85
+ }
82
86
  }
83
87
  const SavedStarGift$1 = /* @__PURE__ */ makeInspectable(SavedStarGift);
84
88
  const SavedStarGift$2 = /* @__PURE__ */ memoizeGetters(SavedStarGift$1, ["sender", "gift"]);
@@ -131,6 +131,10 @@ class StarGiftUnique {
131
131
  _originalDetails;
132
132
  /** Whether this gift is a unique gift */
133
133
  isUnique = true;
134
+ /** Whether this gift is available only to premium users */
135
+ get isPremiumOnly() {
136
+ return this.raw.requirePremium;
137
+ }
134
138
  /** Number of the NFT */
135
139
  get num() {
136
140
  return this.raw.num;
@@ -67,6 +67,8 @@ export declare class StarGiftUnique {
67
67
  /** Whether this gift is a unique gift */
68
68
  readonly isUnique: true;
69
69
  constructor(raw: tl.RawStarGiftUnique, _peers: PeersIndex);
70
+ /** Whether this gift is available only to premium users */
71
+ get isPremiumOnly(): boolean;
70
72
  /** Number of the NFT */
71
73
  get num(): number;
72
74
  /** Title of the NFT */
@@ -67,6 +67,8 @@ export declare class StarGiftUnique {
67
67
  /** Whether this gift is a unique gift */
68
68
  readonly isUnique: true;
69
69
  constructor(raw: tl.RawStarGiftUnique, _peers: PeersIndex);
70
+ /** Whether this gift is available only to premium users */
71
+ get isPremiumOnly(): boolean;
70
72
  /** Number of the NFT */
71
73
  get num(): number;
72
74
  /** Title of the NFT */
@@ -124,6 +124,10 @@ class StarGiftUnique {
124
124
  _originalDetails;
125
125
  /** Whether this gift is a unique gift */
126
126
  isUnique = true;
127
+ /** Whether this gift is available only to premium users */
128
+ get isPremiumOnly() {
129
+ return this.raw.requirePremium;
130
+ }
127
131
  /** Number of the NFT */
128
132
  get num() {
129
133
  return this.raw.num;
@@ -29,6 +29,10 @@ class StarGift {
29
29
  get isLimited() {
30
30
  return this.raw.limited;
31
31
  }
32
+ /** Whether this gift is available only to premium users */
33
+ get isPremiumOnly() {
34
+ return this.raw.requirePremium;
35
+ }
32
36
  /** Whether this gift is a unique gift */
33
37
  isUnique = false;
34
38
  /** Additional information for sold-out gifts */
@@ -80,6 +84,18 @@ class StarGift {
80
84
  resale: this.raw.availabilityResale ?? Long.ZERO
81
85
  };
82
86
  }
87
+ /**
88
+ * For gifts with limited availability per user,
89
+ * the number of remaining and total gifts available
90
+ */
91
+ get perUserAvailability() {
92
+ if (!this.raw.limitedPerUser) return null;
93
+ return {
94
+ // they share the same flag so they must be present
95
+ remains: this.raw.perUserRemains,
96
+ total: this.raw.perUserTotal
97
+ };
98
+ }
83
99
  /** Floor price for the gift on the secondary market */
84
100
  get resaleFloorPrice() {
85
101
  return this.raw.resellMinStars ?? null;
@@ -26,6 +26,8 @@ export declare class StarGift {
26
26
  get isSoldOut(): boolean;
27
27
  /** Whether this gift has limited availability */
28
28
  get isLimited(): boolean;
29
+ /** Whether this gift is available only to premium users */
30
+ get isPremiumOnly(): boolean;
29
31
  /** Whether this gift is a unique gift */
30
32
  readonly isUnique: false;
31
33
  /** Additional information for sold-out gifts */
@@ -57,6 +59,14 @@ export declare class StarGift {
57
59
  /** Number of gifts available on the secondary market */
58
60
  resale: Long;
59
61
  } | null;
62
+ /**
63
+ * For gifts with limited availability per user,
64
+ * the number of remaining and total gifts available
65
+ */
66
+ get perUserAvailability(): {
67
+ remains: number;
68
+ total: number;
69
+ } | null;
60
70
  /** Floor price for the gift on the secondary market */
61
71
  get resaleFloorPrice(): tl.Long | null;
62
72
  /** Title of the gift */
@@ -26,6 +26,8 @@ export declare class StarGift {
26
26
  get isSoldOut(): boolean;
27
27
  /** Whether this gift has limited availability */
28
28
  get isLimited(): boolean;
29
+ /** Whether this gift is available only to premium users */
30
+ get isPremiumOnly(): boolean;
29
31
  /** Whether this gift is a unique gift */
30
32
  readonly isUnique: false;
31
33
  /** Additional information for sold-out gifts */
@@ -57,6 +59,14 @@ export declare class StarGift {
57
59
  /** Number of gifts available on the secondary market */
58
60
  resale: Long;
59
61
  } | null;
62
+ /**
63
+ * For gifts with limited availability per user,
64
+ * the number of remaining and total gifts available
65
+ */
66
+ get perUserAvailability(): {
67
+ remains: number;
68
+ total: number;
69
+ } | null;
60
70
  /** Floor price for the gift on the secondary market */
61
71
  get resaleFloorPrice(): tl.Long | null;
62
72
  /** Title of the gift */
@@ -22,6 +22,10 @@ class StarGift {
22
22
  get isLimited() {
23
23
  return this.raw.limited;
24
24
  }
25
+ /** Whether this gift is available only to premium users */
26
+ get isPremiumOnly() {
27
+ return this.raw.requirePremium;
28
+ }
25
29
  /** Whether this gift is a unique gift */
26
30
  isUnique = false;
27
31
  /** Additional information for sold-out gifts */
@@ -73,6 +77,18 @@ class StarGift {
73
77
  resale: this.raw.availabilityResale ?? Long.ZERO
74
78
  };
75
79
  }
80
+ /**
81
+ * For gifts with limited availability per user,
82
+ * the number of remaining and total gifts available
83
+ */
84
+ get perUserAvailability() {
85
+ if (!this.raw.limitedPerUser) return null;
86
+ return {
87
+ // they share the same flag so they must be present
88
+ remains: this.raw.perUserRemains,
89
+ total: this.raw.perUserTotal
90
+ };
91
+ }
76
92
  /** Floor price for the gift on the secondary market */
77
93
  get resaleFloorPrice() {
78
94
  return this.raw.resellMinStars ?? null;
@@ -225,7 +225,7 @@ class NetworkManager {
225
225
  _: "initConnection",
226
226
  deviceModel,
227
227
  systemVersion: "1.0",
228
- appVersion: "0.25.4",
228
+ appVersion: "0.25.6",
229
229
  systemLangCode: "en",
230
230
  langPack: "",
231
231
  // "langPacks are for official apps only"
@@ -218,7 +218,7 @@ class NetworkManager {
218
218
  _: "initConnection",
219
219
  deviceModel,
220
220
  systemVersion: "1.0",
221
- appVersion: "0.25.4",
221
+ appVersion: "0.25.6",
222
222
  systemLangCode: "en",
223
223
  langPack: "",
224
224
  // "langPacks are for official apps only"
@@ -354,6 +354,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
354
354
  this._pendingWaitForUnencrypted.push([promise, timeoutId]);
355
355
  return promise.promise;
356
356
  }
357
+ _warnedAboutUpdates = false;
357
358
  onMessage(data) {
358
359
  if (this._pendingWaitForUnencrypted.length) {
359
360
  const int32 = new Int32Array(data.buffer, data.byteOffset, 2);
@@ -475,7 +476,10 @@ class SessionConnection extends persistentConnection.PersistentConnection {
475
476
  }
476
477
  this.log.verbose("<<< %j", message);
477
478
  if (this.params.disableUpdates) {
478
- this.log.warn("received updates, but updates are disabled");
479
+ if (!this._warnedAboutUpdates) {
480
+ this.log.warn("received updates, but updates are disabled");
481
+ this._warnedAboutUpdates = true;
482
+ }
479
483
  break;
480
484
  }
481
485
  this.onUpdate.emit(message);
@@ -63,6 +63,7 @@ export declare class SessionConnection extends PersistentConnection {
63
63
  _authorize(): void;
64
64
  private _authorizePfs;
65
65
  waitForUnencryptedMessage(timeout?: number): Promise<Uint8Array>;
66
+ private _warnedAboutUpdates;
66
67
  protected onMessage(data: Uint8Array): void;
67
68
  private _handleRawMessage;
68
69
  private _handleMessage;
@@ -63,6 +63,7 @@ export declare class SessionConnection extends PersistentConnection {
63
63
  _authorize(): void;
64
64
  private _authorizePfs;
65
65
  waitForUnencryptedMessage(timeout?: number): Promise<Uint8Array>;
66
+ private _warnedAboutUpdates;
66
67
  protected onMessage(data: Uint8Array): void;
67
68
  private _handleRawMessage;
68
69
  private _handleMessage;
@@ -347,6 +347,7 @@ class SessionConnection extends PersistentConnection {
347
347
  this._pendingWaitForUnencrypted.push([promise, timeoutId]);
348
348
  return promise.promise;
349
349
  }
350
+ _warnedAboutUpdates = false;
350
351
  onMessage(data) {
351
352
  if (this._pendingWaitForUnencrypted.length) {
352
353
  const int32 = new Int32Array(data.buffer, data.byteOffset, 2);
@@ -468,7 +469,10 @@ class SessionConnection extends PersistentConnection {
468
469
  }
469
470
  this.log.verbose("<<< %j", message);
470
471
  if (this.params.disableUpdates) {
471
- this.log.warn("received updates, but updates are disabled");
472
+ if (!this._warnedAboutUpdates) {
473
+ this.log.warn("received updates, but updates are disabled");
474
+ this._warnedAboutUpdates = true;
475
+ }
472
476
  break;
473
477
  }
474
478
  this.onUpdate.emit(message);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtcute/core",
3
3
  "type": "module",
4
- "version": "0.25.4",
4
+ "version": "0.25.6",
5
5
  "description": "Type-safe library for MTProto (Telegram API)",
6
6
  "license": "MIT",
7
7
  "scripts": {},
@@ -10,7 +10,7 @@
10
10
  "@fuman/net": "0.0.15",
11
11
  "@fuman/utils": "0.0.15",
12
12
  "@mtcute/file-id": "^0.24.3",
13
- "@mtcute/tl": "^208.0.0",
13
+ "@mtcute/tl": "^210.0.0",
14
14
  "@mtcute/tl-runtime": "^0.24.3",
15
15
  "@types/events": "3.0.0",
16
16
  "long": "5.2.3"
@@ -35,6 +35,7 @@ function mapCompatStarGift(obj) {
35
35
  return replaceType(obj, "starGiftUnique");
36
36
  case "starGift_layer202":
37
37
  case "starGift_layer206":
38
+ case "starGift_layer209":
38
39
  return replaceType(obj, "starGift");
39
40
  default:
40
41
  return obj;
@@ -122,6 +123,7 @@ function mapCompatObject(obj) {
122
123
  case "starGiftUnique_layer206":
123
124
  case "starGift_layer202":
124
125
  case "starGift_layer206":
126
+ case "starGift_layer209":
125
127
  return mapCompatStarGift(obj);
126
128
  case "emojiStatus_layer197":
127
129
  return mapCompatEmojiStatus(obj);
@@ -138,6 +140,7 @@ function mapCompatObject(obj) {
138
140
  case "userFull_layer199":
139
141
  return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
140
142
  case "userFull_layer200":
143
+ case "userFull_layer209":
141
144
  return replaceType(obj, "userFull");
142
145
  case "user_layer199":
143
146
  return {
@@ -28,6 +28,7 @@ function mapCompatStarGift(obj) {
28
28
  return replaceType(obj, "starGiftUnique");
29
29
  case "starGift_layer202":
30
30
  case "starGift_layer206":
31
+ case "starGift_layer209":
31
32
  return replaceType(obj, "starGift");
32
33
  default:
33
34
  return obj;
@@ -115,6 +116,7 @@ function mapCompatObject(obj) {
115
116
  case "starGiftUnique_layer206":
116
117
  case "starGift_layer202":
117
118
  case "starGift_layer206":
119
+ case "starGift_layer209":
118
120
  return mapCompatStarGift(obj);
119
121
  case "emojiStatus_layer197":
120
122
  return mapCompatEmojiStatus(obj);
@@ -131,6 +133,7 @@ function mapCompatObject(obj) {
131
133
  case "userFull_layer199":
132
134
  return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
133
135
  case "userFull_layer200":
136
+ case "userFull_layer209":
134
137
  return replaceType(obj, "userFull");
135
138
  case "user_layer199":
136
139
  return {