@mtkruto/node 0.1.149 → 0.1.151

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.
@@ -3,8 +3,8 @@ export declare const ACK_THRESHOLD = 10;
3
3
  export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
- export declare const LAYER = 172;
7
- export declare const APP_VERSION = "MTKruto 0.1.149";
6
+ export declare const LAYER = 173;
7
+ export declare const APP_VERSION = "MTKruto 0.1.150";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -52,8 +52,8 @@ export const PUBLIC_KEYS = Object.freeze([
52
52
  ],
53
53
  ]);
54
54
  export const INITIAL_DC = "2";
55
- export const LAYER = 172;
56
- export const APP_VERSION = "MTKruto 0.1.149";
55
+ export const LAYER = 173;
56
+ export const APP_VERSION = "MTKruto 0.1.150";
57
57
  // @ts-ignore: lib
58
58
  export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
59
59
  export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _UpdateManager_instances, _a, _UpdateManager_c, _UpdateManager_updateState, _UpdateManager_updateHandler, _UpdateManager_defaultDropPendingUpdates, _UpdateManager_mustDropPendingUpdates, _UpdateManager_handleUpdateQueues, _UpdateManager_nonFirst, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck, _UpdateManager_checkGap, _UpdateManager_checkChannelGap, _UpdateManager_channelUpdateQueues, _UpdateManager_processChannelPtsUpdateInner, _UpdateManager_queueUpdate, _UpdateManager_processChannelPtsUpdate, _UpdateManager_processPtsUpdateInner, _UpdateManager_ptsUpdateQueue, _UpdateManager_processPtsUpdate, _UpdateManager_processUpdatesQueue, _UpdateManager_processUpdates, _UpdateManager_setUpdateStateDate, _UpdateManager_setUpdatePts, _UpdateManager_getLocalState, _UpdateManager_recoverChannelUpdateGap, _UpdateManager_handleUpdatesSet, _UpdateManager_handleStoredUpdates, _UpdateManager_handleUpdate;
12
+ var _UpdateManager_instances, _a, _UpdateManager_c, _UpdateManager_updateState, _UpdateManager_updateHandler, _UpdateManager_defaultDropPendingUpdates, _UpdateManager_mustDropPendingUpdates, _UpdateManager_state, _UpdateManager_getState, _UpdateManager_setState, _UpdateManager_handleUpdateQueues, _UpdateManager_nonFirst, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck, _UpdateManager_checkGap, _UpdateManager_checkChannelGap, _UpdateManager_channelUpdateQueues, _UpdateManager_processChannelPtsUpdateInner, _UpdateManager_queueUpdate, _UpdateManager_processChannelPtsUpdate, _UpdateManager_processPtsUpdateInner, _UpdateManager_ptsUpdateQueue, _UpdateManager_processPtsUpdate, _UpdateManager_processUpdatesQueue, _UpdateManager_processUpdates, _UpdateManager_setUpdateStateDate, _UpdateManager_setUpdatePts, _UpdateManager_getLocalState, _UpdateManager_recoverChannelUpdateGap, _UpdateManager_handleUpdatesSet, _UpdateManager_handleStoredUpdates, _UpdateManager_handleUpdate;
13
13
  import { debug } from "../0_deps.js";
14
14
  import { Queue, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
15
15
  import { as, functions, inputPeerToPeer, peerToChatId, types } from "../2_tl.js";
@@ -25,6 +25,7 @@ export class UpdateManager {
25
25
  _UpdateManager_updateState.set(this, void 0);
26
26
  _UpdateManager_updateHandler.set(this, void 0);
27
27
  _UpdateManager_defaultDropPendingUpdates.set(this, null);
28
+ _UpdateManager_state.set(this, undefined);
28
29
  _UpdateManager_handleUpdateQueues.set(this, new Map());
29
30
  _UpdateManager_nonFirst.set(this, new Set());
30
31
  _UpdateManager_channelUpdateQueues.set(this, new Map());
@@ -38,7 +39,7 @@ export class UpdateManager {
38
39
  __classPrivateFieldSet(this, _UpdateManager_updateState, state, "f");
39
40
  d("state fetched [%s]", source);
40
41
  if (await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this)) {
41
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(state);
42
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, state);
42
43
  }
43
44
  }
44
45
  async processChats(chats) {
@@ -157,7 +158,7 @@ export class UpdateManager {
157
158
  await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_processUpdates).call(this, update, false);
158
159
  }
159
160
  if (difference instanceof types.updates.Difference) {
160
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(difference.state);
161
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, difference.state);
161
162
  dGap("recovered from update gap");
162
163
  break;
163
164
  }
@@ -193,7 +194,7 @@ export class UpdateManager {
193
194
  __classPrivateFieldSet(this, _UpdateManager_updateHandler, handler, "f");
194
195
  }
195
196
  }
196
- _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState = new WeakMap(), _UpdateManager_updateHandler = new WeakMap(), _UpdateManager_defaultDropPendingUpdates = new WeakMap(), _UpdateManager_handleUpdateQueues = new WeakMap(), _UpdateManager_nonFirst = new WeakMap(), _UpdateManager_channelUpdateQueues = new WeakMap(), _UpdateManager_ptsUpdateQueue = new WeakMap(), _UpdateManager_processUpdatesQueue = new WeakMap(), _UpdateManager_handleUpdatesSet = new WeakMap(), _UpdateManager_instances = new WeakSet(), _UpdateManager_mustDropPendingUpdates = async function _UpdateManager_mustDropPendingUpdates() {
197
+ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState = new WeakMap(), _UpdateManager_updateHandler = new WeakMap(), _UpdateManager_defaultDropPendingUpdates = new WeakMap(), _UpdateManager_state = new WeakMap(), _UpdateManager_handleUpdateQueues = new WeakMap(), _UpdateManager_nonFirst = new WeakMap(), _UpdateManager_channelUpdateQueues = new WeakMap(), _UpdateManager_ptsUpdateQueue = new WeakMap(), _UpdateManager_processUpdatesQueue = new WeakMap(), _UpdateManager_handleUpdatesSet = new WeakMap(), _UpdateManager_instances = new WeakSet(), _UpdateManager_mustDropPendingUpdates = async function _UpdateManager_mustDropPendingUpdates() {
197
198
  if (typeof __classPrivateFieldGet(this, _UpdateManager_c, "f").dropPendingUpdates === "boolean") {
198
199
  return __classPrivateFieldGet(this, _UpdateManager_c, "f").dropPendingUpdates;
199
200
  }
@@ -201,6 +202,20 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
201
202
  __classPrivateFieldSet(this, _UpdateManager_defaultDropPendingUpdates, await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getAccountType() == "bot", "f");
202
203
  }
203
204
  return __classPrivateFieldGet(this, _UpdateManager_defaultDropPendingUpdates, "f");
205
+ }, _UpdateManager_getState = async function _UpdateManager_getState() {
206
+ if (await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this)) {
207
+ return __classPrivateFieldGet(this, _UpdateManager_state, "f") ?? null;
208
+ }
209
+ if (__classPrivateFieldGet(this, _UpdateManager_state, "f") !== undefined) {
210
+ return __classPrivateFieldGet(this, _UpdateManager_state, "f");
211
+ }
212
+ const state = await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getState();
213
+ return __classPrivateFieldSet(this, _UpdateManager_state, state, "f");
214
+ }, _UpdateManager_setState = async function _UpdateManager_setState(state) {
215
+ __classPrivateFieldSet(this, _UpdateManager_state, state, "f");
216
+ if (!await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this)) {
217
+ await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(state);
218
+ }
204
219
  }, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck = async function _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck(channelId) {
205
220
  if (!(await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this))) {
206
221
  return await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getChannelPts(channelId);
@@ -319,7 +334,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
319
334
  localState.seq = seq;
320
335
  localState.date = updates_.date;
321
336
  await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setUpdateStateDate).call(this, updates_.date);
322
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
337
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
323
338
  }
324
339
  else if (localSeq + 1 > seqStart) {
325
340
  // The update sequence was already applied, and must be ignored.
@@ -434,7 +449,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
434
449
  if (update instanceof types.UpdatePtsChanged) {
435
450
  await this.fetchState("updatePtsChanged");
436
451
  if (__classPrivateFieldGet(this, _UpdateManager_updateState, "f")) {
437
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(__classPrivateFieldGet(this, _UpdateManager_updateState, "f"));
452
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, __classPrivateFieldGet(this, _UpdateManager_updateState, "f"));
438
453
  }
439
454
  else {
440
455
  UNREACHABLE();
@@ -453,23 +468,23 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
453
468
  }, _UpdateManager_setUpdateStateDate = async function _UpdateManager_setUpdateStateDate(date) {
454
469
  const localState = await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_getLocalState).call(this);
455
470
  localState.date = date;
456
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
471
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
457
472
  }, _UpdateManager_setUpdatePts = async function _UpdateManager_setUpdatePts(pts) {
458
473
  const localState = await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_getLocalState).call(this);
459
474
  localState.pts = pts;
460
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
475
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
461
476
  }, _UpdateManager_getLocalState = async function _UpdateManager_getLocalState() {
462
- let localState = await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getState();
477
+ let localState = await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_getState).call(this);
463
478
  if (!localState) {
464
479
  if (__classPrivateFieldGet(this, _UpdateManager_updateState, "f")) {
465
480
  localState = __classPrivateFieldGet(this, _UpdateManager_updateState, "f");
466
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
481
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
467
482
  }
468
483
  else {
469
484
  await this.fetchState("getLocalState");
470
485
  if (__classPrivateFieldGet(this, _UpdateManager_updateState, "f")) {
471
486
  localState = __classPrivateFieldGet(this, _UpdateManager_updateState, "f");
472
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
487
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
473
488
  }
474
489
  else {
475
490
  UNREACHABLE();
@@ -242,6 +242,8 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
242
242
  */
243
243
  send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
244
244
  getInputPeer(id: ID): Promise<import("../tl/2_types.js").InputPeerChat_ | import("../tl/2_types.js").InputPeerUser_ | import("../tl/2_types.js").InputPeerChannel_>;
245
+ getInputChannel(id: ID): Promise<import("../tl/2_types.js").InputChannel_>;
246
+ getInputUser(id: ID): Promise<import("../tl/2_types.js").InputUser_>;
245
247
  private [getEntity];
246
248
  private [getEntity];
247
249
  private [getEntity];
@@ -212,6 +212,11 @@ export class Client extends ClientAbstract {
212
212
  return update.chosenInlineResult.inlineMessageId;
213
213
  }
214
214
  }
215
+ else if ("callbackQuery" in update) {
216
+ if (update.callbackQuery.inlineMessageId) {
217
+ return update.callbackQuery.inlineMessageId;
218
+ }
219
+ }
215
220
  UNREACHABLE();
216
221
  };
217
222
  const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : undefined;
@@ -953,7 +958,21 @@ export class Client extends ClientAbstract {
953
958
  }
954
959
  return inputPeer;
955
960
  }
956
- [(_Client_initConnection = async function _Client_initConnection() {
961
+ async getInputChannel(id) {
962
+ const inputPeer = await this.getInputPeer(id);
963
+ if (!(inputPeer instanceof types.InputPeerChannel)) {
964
+ UNREACHABLE();
965
+ }
966
+ return new types.InputChannel(inputPeer);
967
+ }
968
+ async getInputUser(id) {
969
+ const inputPeer = await this.getInputPeer(id);
970
+ if (!(inputPeer instanceof types.InputPeerUser)) {
971
+ UNREACHABLE();
972
+ }
973
+ return new types.InputUser(inputPeer);
974
+ }
975
+ async [(_Client_initConnection = async function _Client_initConnection() {
957
976
  if (!__classPrivateFieldGet(this, _Client_connectionInited, "f")) {
958
977
  await this.api.initConnection({
959
978
  api_id: this.apiId,
@@ -1194,10 +1213,18 @@ export class Client extends ClientAbstract {
1194
1213
  }
1195
1214
  }, _Client_getUserAccessHash = async function _Client_getUserAccessHash(userId) {
1196
1215
  const users = await this.api.users.getUsers({ id: [new types.InputUser({ user_id: userId, access_hash: 0n })] });
1197
- return users[0]?.[as](types.User).access_hash ?? 0n;
1216
+ const user = users[0]?.[as](types.User);
1217
+ if (user) {
1218
+ await this.messageStorage.setEntity(user);
1219
+ }
1220
+ return user?.access_hash ?? 0n;
1198
1221
  }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
1199
1222
  const channels = await this.api.channels.getChannels({ id: [new types.InputChannel({ channel_id: channelId, access_hash: 0n })] });
1200
- return channels.chats[0][as](types.Channel).access_hash ?? 0n;
1223
+ const channel = channels.chats[0][as](types.Channel);
1224
+ if (channel) {
1225
+ await this.messageStorage.setEntity(channel);
1226
+ }
1227
+ return channel?.access_hash ?? 0n;
1201
1228
  }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
1202
1229
  const idn = Number(id);
1203
1230
  if (!isNaN(idn)) {
@@ -1254,7 +1281,14 @@ export class Client extends ClientAbstract {
1254
1281
  }
1255
1282
  }, getEntity)](peer) {
1256
1283
  const id = peerToChatId(peer);
1257
- return this.messageStorage.getEntity(id);
1284
+ const entity = await this.messageStorage.getEntity(id);
1285
+ if (entity == null && await this.storage.getAccountType() == "bot" && peer instanceof types.PeerUser || peer instanceof types.PeerChannel) {
1286
+ await this.getInputPeer(id);
1287
+ }
1288
+ else {
1289
+ return entity;
1290
+ }
1291
+ return await this.messageStorage.getEntity(id);
1258
1292
  }
1259
1293
  use(...middleware) {
1260
1294
  const composer = new Composer(...middleware);
@@ -69,6 +69,7 @@ export declare abstract class Storage {
69
69
  }): MaybePromise<Generator<[readonly StorageKeyPart[], T]> | AsyncGenerator<[readonly StorageKeyPart[], T]>>;
70
70
  abstract get supportsFiles(): boolean;
71
71
  abstract branch(id: string): Storage;
72
+ get isMemoryStorage(): boolean;
72
73
  setDc(dc: DC | null): MaybePromise<void>;
73
74
  getDc(): MaybePromise<DC | null>;
74
75
  getAuthKey(): Promise<Uint8Array | null>;
@@ -79,7 +80,7 @@ export declare abstract class Storage {
79
80
  updateUsernames(id: number, usernames: string[]): Promise<void>;
80
81
  getUsername(username: string): Promise<[number, Date] | null>;
81
82
  setTlObject(key: readonly StorageKeyPart[], value: TLObject | null): Promise<void>;
82
- getTlObject(keyOrBuffer: Uint8Array | readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
83
+ getTlObject(keyOrBuffer: TLObject | Uint8Array | readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
83
84
  setState(state: enums.updates.State): Promise<void>;
84
85
  getState(): Promise<import("../tl/2_types.js").updates_State_ | null>;
85
86
  setMessage(chatId: number, messageId: number, message: enums.Message | null): Promise<void>;
@@ -90,7 +91,7 @@ export declare abstract class Storage {
90
91
  setChannelPts(channelId: bigint, pts: number): Promise<void>;
91
92
  getChannelPts(channelId: bigint): MaybePromise<number | null>;
92
93
  setEntity(entity: AnyEntity): Promise<void>;
93
- getEntity(key: number): Promise<AnyEntity | null>;
94
+ getEntity(key: number): Promise<import("../2_tl.js").ReadObject | null>;
94
95
  setAccountType(type: "user" | "bot"): Promise<void>;
95
96
  getAccountType(): Promise<"bot" | "user" | null>;
96
97
  updateStickerSetName(id: bigint, accessHash: bigint, name: string): Promise<void>;
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _Storage_instances, _Storage_authKeyId, _Storage_resetAuthKeyId, _Storage_accountType, _Storage_getUpdateId;
13
13
  import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
14
- import { peerToChatId, serialize, TLReader, types } from "../2_tl.js";
14
+ import { peerToChatId, serialize, TLObject, TLReader, types } from "../2_tl.js";
15
15
  // key parts
16
16
  export const K = {
17
17
  session: {
@@ -68,6 +68,9 @@ export class Storage {
68
68
  _Storage_authKeyId.set(this, null);
69
69
  _Storage_accountType.set(this, null);
70
70
  }
71
+ get isMemoryStorage() {
72
+ return false;
73
+ }
71
74
  setDc(dc) {
72
75
  return this.set(K.auth.dc(), dc);
73
76
  }
@@ -125,13 +128,18 @@ export class Storage {
125
128
  await this.set(key, null);
126
129
  }
127
130
  else {
128
- await this.set(key, rleEncode(value[serialize]()));
131
+ await this.set(key, this.isMemoryStorage ? value : rleEncode(value[serialize]()));
129
132
  }
130
133
  }
131
134
  async getTlObject(keyOrBuffer) {
132
- const buffer = keyOrBuffer instanceof Uint8Array ? keyOrBuffer : await this.get(keyOrBuffer);
135
+ const buffer = (keyOrBuffer instanceof Uint8Array || keyOrBuffer instanceof TLObject) ? keyOrBuffer : await this.get(keyOrBuffer);
133
136
  if (buffer != null) {
134
- return new TLReader(rleDecode(buffer)).readObject();
137
+ if (buffer instanceof Uint8Array) {
138
+ return new TLReader(rleDecode(buffer)).readObject();
139
+ }
140
+ else {
141
+ return buffer;
142
+ }
135
143
  }
136
144
  else {
137
145
  return null;
@@ -175,14 +183,13 @@ export class Storage {
175
183
  return this.get(K.updates.channelPts(channelId));
176
184
  }
177
185
  async setEntity(entity) {
178
- await this.set(K.cache.peer(peerToChatId(entity)), [rleEncode(entity[serialize]()), new Date()]);
186
+ await this.set(K.cache.peer(peerToChatId(entity)), [this.isMemoryStorage ? entity : rleEncode(entity[serialize]()), new Date()]);
179
187
  }
180
188
  async getEntity(key) {
181
189
  const peer_ = await this.get(K.cache.peer(key));
182
190
  if (peer_ != null) {
183
191
  const [obj_] = peer_;
184
- const entity = new TLReader(rleDecode(obj_)).readObject();
185
- return entity;
192
+ return await this.getTlObject(obj_);
186
193
  }
187
194
  else {
188
195
  return null;
@@ -301,12 +308,12 @@ export class Storage {
301
308
  await this.set(K.cache.file(id), [partCount, chunkSize]);
302
309
  }
303
310
  async setCustomEmojiDocument(id, document) {
304
- await this.set(K.cache.customEmojiDocument(id), [rleEncode(document[serialize]()), new Date()]);
311
+ await this.set(K.cache.customEmojiDocument(id), [this.isMemoryStorage ? document : rleEncode(document[serialize]()), new Date()]);
305
312
  }
306
313
  async getCustomEmojiDocument(id) {
307
314
  const v = await this.get(K.cache.customEmojiDocument(id));
308
315
  if (v != null) {
309
- return [await this.getTlObject([0]), v[1]];
316
+ return [await this.getTlObject(v[0]), v[1]];
310
317
  }
311
318
  else {
312
319
  return null;
@@ -8,6 +8,7 @@ export declare enum ValueType {
8
8
  Uint8Array = 5,
9
9
  Array = 6
10
10
  }
11
+ export declare const WEB_STORAGE_PREFIX_EXP: RegExp;
11
12
  export declare function toString(value: unknown): string;
12
13
  export declare function fromString<T>(string: string): T;
13
14
  export declare function fixKey(key: readonly StorageKeyPart[]): (string | number)[];
@@ -10,6 +10,7 @@ export var ValueType;
10
10
  ValueType[ValueType["Uint8Array"] = 5] = "Uint8Array";
11
11
  ValueType[ValueType["Array"] = 6] = "Array";
12
12
  })(ValueType || (ValueType = {}));
13
+ export const WEB_STORAGE_PREFIX_EXP = /^[\d\w]+$/;
13
14
  export function toString(value) {
14
15
  if (typeof value === "boolean") {
15
16
  return `${ValueType.Boolean}${Number(value)}`;
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _StorageLocalStorage_prefix;
13
13
  import { Storage } from "./0_storage.js";
14
- import { fromString, isInRange, toString } from "./0_utilities.js";
14
+ import { fromString, isInRange, toString, WEB_STORAGE_PREFIX_EXP } from "./0_utilities.js";
15
15
  export class StorageLocalStorage extends Storage {
16
16
  constructor(prefix) {
17
17
  if (typeof localStorage === "undefined") {
@@ -20,7 +20,7 @@ export class StorageLocalStorage extends Storage {
20
20
  if (prefix.length <= 0) {
21
21
  throw new Error("Empty prefix");
22
22
  }
23
- else if (!/^[0-9a-zA-Z]+$/.test(prefix)) {
23
+ else if (!WEB_STORAGE_PREFIX_EXP.test(prefix)) {
24
24
  throw new Error("Unallowed prefix");
25
25
  }
26
26
  super();
@@ -4,6 +4,7 @@ export declare class StorageMemory extends Storage implements Storage {
4
4
  #private;
5
5
  protected map: Map<string, unknown>;
6
6
  protected messageMap: CacheMap<string, unknown>;
7
+ get isMemoryStorage(): boolean;
7
8
  initialize(): void;
8
9
  getMap(key: readonly StorageKeyPart[]): Map<string, unknown>;
9
10
  getMaps(): Map<string, unknown>[];
@@ -31,6 +31,9 @@ export class StorageMemory extends Storage {
31
31
  });
32
32
  _StorageMemory_id.set(this, null);
33
33
  }
34
+ get isMemoryStorage() {
35
+ return true;
36
+ }
34
37
  initialize() {
35
38
  }
36
39
  getMap(key) {
@@ -11,7 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _StorageSessionStorage_prefix;
13
13
  import { Storage } from "./0_storage.js";
14
- import { fromString, isInRange, toString } from "./0_utilities.js";
14
+ import { fromString, isInRange, toString, WEB_STORAGE_PREFIX_EXP } from "./0_utilities.js";
15
15
  export class StorageSessionStorage extends Storage {
16
16
  constructor(prefix) {
17
17
  if (typeof sessionStorage === "undefined") {
@@ -20,7 +20,7 @@ export class StorageSessionStorage extends Storage {
20
20
  if (prefix.length <= 0) {
21
21
  throw new Error("Empty prefix");
22
22
  }
23
- else if (!/^[0-9a-zA-Z]+$/.test(prefix)) {
23
+ else if (!WEB_STORAGE_PREFIX_EXP.test(prefix)) {
24
24
  throw new Error("Unallowed prefix");
25
25
  }
26
26
  super();
@@ -296,11 +296,13 @@ export declare class auth_sendCode_ extends Function_<enums.auth.SentCode> {
296
296
  }
297
297
  export declare class auth_signUp_ extends Function_<enums.auth.Authorization> {
298
298
  static __F: (params: {
299
+ no_joined_notifications?: true;
299
300
  phone_number: string;
300
301
  phone_code_hash: string;
301
302
  first_name: string;
302
303
  last_name: string;
303
304
  }) => enums.auth.Authorization;
305
+ no_joined_notifications?: true;
304
306
  phone_number: string;
305
307
  phone_code_hash: string;
306
308
  first_name: string;
@@ -310,6 +312,7 @@ export declare class auth_signUp_ extends Function_<enums.auth.Authorization> {
310
312
  static get [paramDesc](): ParamDesc;
311
313
  protected get [params](): Params;
312
314
  constructor(params: {
315
+ no_joined_notifications?: true;
313
316
  phone_number: string;
314
317
  phone_code_hash: string;
315
318
  first_name: string;
@@ -6148,14 +6151,17 @@ export declare class messages_reorderPinnedSavedDialogs_ extends Function_<boole
6148
6151
  }
6149
6152
  export declare class messages_getSavedReactionTags_ extends Function_<enums.messages.SavedReactionTags> {
6150
6153
  static __F: (params: {
6154
+ peer?: enums.InputPeer;
6151
6155
  hash: bigint;
6152
6156
  }) => enums.messages.SavedReactionTags;
6157
+ peer?: enums.InputPeer;
6153
6158
  hash: bigint;
6154
6159
  protected get [id](): number;
6155
6160
  static get [name](): string;
6156
6161
  static get [paramDesc](): ParamDesc;
6157
6162
  protected get [params](): Params;
6158
6163
  constructor(params: {
6164
+ peer?: enums.InputPeer;
6159
6165
  hash: bigint;
6160
6166
  });
6161
6167
  }
@@ -808,13 +808,15 @@ Object.defineProperty(auth_sendCode_, "__F", {
808
808
  });
809
809
  export class auth_signUp_ extends Function_ {
810
810
  get [id]() {
811
- return 0x80EEE427;
811
+ return 0xAAC7B717;
812
812
  }
813
813
  static get [name]() {
814
814
  return "auth.signUp";
815
815
  }
816
816
  static get [paramDesc]() {
817
817
  return [
818
+ ["flags", flags, "#"],
819
+ ["no_joined_notifications", "true", "flags.0?true"],
818
820
  ["phone_number", "string", "string"],
819
821
  ["phone_code_hash", "string", "string"],
820
822
  ["first_name", "string", "string"],
@@ -823,6 +825,8 @@ export class auth_signUp_ extends Function_ {
823
825
  }
824
826
  get [params]() {
825
827
  return [
828
+ ["flags", flags, "#"],
829
+ [this.no_joined_notifications ?? null, "true", "flags.0?true"],
826
830
  [this.phone_number, "string", "string"],
827
831
  [this.phone_code_hash, "string", "string"],
828
832
  [this.first_name, "string", "string"],
@@ -831,6 +835,12 @@ export class auth_signUp_ extends Function_ {
831
835
  }
832
836
  constructor(params) {
833
837
  super();
838
+ Object.defineProperty(this, "no_joined_notifications", {
839
+ enumerable: true,
840
+ configurable: true,
841
+ writable: true,
842
+ value: void 0
843
+ });
834
844
  Object.defineProperty(this, "phone_number", {
835
845
  enumerable: true,
836
846
  configurable: true,
@@ -855,6 +865,7 @@ export class auth_signUp_ extends Function_ {
855
865
  writable: true,
856
866
  value: void 0
857
867
  });
868
+ this.no_joined_notifications = params.no_joined_notifications;
858
869
  this.phone_number = params.phone_number;
859
870
  this.phone_code_hash = params.phone_code_hash;
860
871
  this.first_name = params.first_name;
@@ -17024,29 +17035,40 @@ Object.defineProperty(messages_reorderPinnedSavedDialogs_, "__F", {
17024
17035
  });
17025
17036
  export class messages_getSavedReactionTags_ extends Function_ {
17026
17037
  get [id]() {
17027
- return 0x761DDACF;
17038
+ return 0x3637E05B;
17028
17039
  }
17029
17040
  static get [name]() {
17030
17041
  return "messages.getSavedReactionTags";
17031
17042
  }
17032
17043
  static get [paramDesc]() {
17033
17044
  return [
17045
+ ["flags", flags, "#"],
17046
+ ["peer", types._InputPeer, "flags.0?InputPeer"],
17034
17047
  ["hash", "bigint", "long"],
17035
17048
  ];
17036
17049
  }
17037
17050
  get [params]() {
17038
17051
  return [
17052
+ ["flags", flags, "#"],
17053
+ [this.peer ?? null, types._InputPeer, "flags.0?InputPeer"],
17039
17054
  [this.hash, "bigint", "long"],
17040
17055
  ];
17041
17056
  }
17042
17057
  constructor(params) {
17043
17058
  super();
17059
+ Object.defineProperty(this, "peer", {
17060
+ enumerable: true,
17061
+ configurable: true,
17062
+ writable: true,
17063
+ value: void 0
17064
+ });
17044
17065
  Object.defineProperty(this, "hash", {
17045
17066
  enumerable: true,
17046
17067
  configurable: true,
17047
17068
  writable: true,
17048
17069
  value: void 0
17049
17070
  });
17071
+ this.peer = params.peer;
17050
17072
  this.hash = params.hash;
17051
17073
  }
17052
17074
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/node",
3
- "version": "0.1.149",
3
+ "version": "0.1.151",
4
4
  "description": "MTKruto for Node.js",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -3,8 +3,8 @@ export declare const ACK_THRESHOLD = 10;
3
3
  export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const INITIAL_DC: DC;
6
- export declare const LAYER = 172;
7
- export declare const APP_VERSION = "MTKruto 0.1.149";
6
+ export declare const LAYER = 173;
7
+ export declare const APP_VERSION = "MTKruto 0.1.150";
8
8
  export declare const DEVICE_MODEL: string;
9
9
  export declare const LANG_CODE: string;
10
10
  export declare const LANG_PACK = "";
@@ -78,8 +78,8 @@ exports.PUBLIC_KEYS = Object.freeze([
78
78
  ],
79
79
  ]);
80
80
  exports.INITIAL_DC = "2";
81
- exports.LAYER = 172;
82
- exports.APP_VERSION = "MTKruto 0.1.149";
81
+ exports.LAYER = 173;
82
+ exports.APP_VERSION = "MTKruto 0.1.150";
83
83
  // @ts-ignore: lib
84
84
  exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
85
85
  exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _UpdateManager_instances, _a, _UpdateManager_c, _UpdateManager_updateState, _UpdateManager_updateHandler, _UpdateManager_defaultDropPendingUpdates, _UpdateManager_mustDropPendingUpdates, _UpdateManager_handleUpdateQueues, _UpdateManager_nonFirst, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck, _UpdateManager_checkGap, _UpdateManager_checkChannelGap, _UpdateManager_channelUpdateQueues, _UpdateManager_processChannelPtsUpdateInner, _UpdateManager_queueUpdate, _UpdateManager_processChannelPtsUpdate, _UpdateManager_processPtsUpdateInner, _UpdateManager_ptsUpdateQueue, _UpdateManager_processPtsUpdate, _UpdateManager_processUpdatesQueue, _UpdateManager_processUpdates, _UpdateManager_setUpdateStateDate, _UpdateManager_setUpdatePts, _UpdateManager_getLocalState, _UpdateManager_recoverChannelUpdateGap, _UpdateManager_handleUpdatesSet, _UpdateManager_handleStoredUpdates, _UpdateManager_handleUpdate;
13
+ var _UpdateManager_instances, _a, _UpdateManager_c, _UpdateManager_updateState, _UpdateManager_updateHandler, _UpdateManager_defaultDropPendingUpdates, _UpdateManager_mustDropPendingUpdates, _UpdateManager_state, _UpdateManager_getState, _UpdateManager_setState, _UpdateManager_handleUpdateQueues, _UpdateManager_nonFirst, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck, _UpdateManager_checkGap, _UpdateManager_checkChannelGap, _UpdateManager_channelUpdateQueues, _UpdateManager_processChannelPtsUpdateInner, _UpdateManager_queueUpdate, _UpdateManager_processChannelPtsUpdate, _UpdateManager_processPtsUpdateInner, _UpdateManager_ptsUpdateQueue, _UpdateManager_processPtsUpdate, _UpdateManager_processUpdatesQueue, _UpdateManager_processUpdates, _UpdateManager_setUpdateStateDate, _UpdateManager_setUpdatePts, _UpdateManager_getLocalState, _UpdateManager_recoverChannelUpdateGap, _UpdateManager_handleUpdatesSet, _UpdateManager_handleStoredUpdates, _UpdateManager_handleUpdate;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.UpdateManager = void 0;
16
16
  const _0_deps_js_1 = require("../0_deps.js");
@@ -28,6 +28,7 @@ class UpdateManager {
28
28
  _UpdateManager_updateState.set(this, void 0);
29
29
  _UpdateManager_updateHandler.set(this, void 0);
30
30
  _UpdateManager_defaultDropPendingUpdates.set(this, null);
31
+ _UpdateManager_state.set(this, undefined);
31
32
  _UpdateManager_handleUpdateQueues.set(this, new Map());
32
33
  _UpdateManager_nonFirst.set(this, new Set());
33
34
  _UpdateManager_channelUpdateQueues.set(this, new Map());
@@ -41,7 +42,7 @@ class UpdateManager {
41
42
  __classPrivateFieldSet(this, _UpdateManager_updateState, state, "f");
42
43
  d("state fetched [%s]", source);
43
44
  if (await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this)) {
44
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(state);
45
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, state);
45
46
  }
46
47
  }
47
48
  async processChats(chats) {
@@ -160,7 +161,7 @@ class UpdateManager {
160
161
  await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_processUpdates).call(this, update, false);
161
162
  }
162
163
  if (difference instanceof _2_tl_js_1.types.updates.Difference) {
163
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(difference.state);
164
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, difference.state);
164
165
  dGap("recovered from update gap");
165
166
  break;
166
167
  }
@@ -197,7 +198,7 @@ class UpdateManager {
197
198
  }
198
199
  }
199
200
  exports.UpdateManager = UpdateManager;
200
- _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState = new WeakMap(), _UpdateManager_updateHandler = new WeakMap(), _UpdateManager_defaultDropPendingUpdates = new WeakMap(), _UpdateManager_handleUpdateQueues = new WeakMap(), _UpdateManager_nonFirst = new WeakMap(), _UpdateManager_channelUpdateQueues = new WeakMap(), _UpdateManager_ptsUpdateQueue = new WeakMap(), _UpdateManager_processUpdatesQueue = new WeakMap(), _UpdateManager_handleUpdatesSet = new WeakMap(), _UpdateManager_instances = new WeakSet(), _UpdateManager_mustDropPendingUpdates = async function _UpdateManager_mustDropPendingUpdates() {
201
+ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState = new WeakMap(), _UpdateManager_updateHandler = new WeakMap(), _UpdateManager_defaultDropPendingUpdates = new WeakMap(), _UpdateManager_state = new WeakMap(), _UpdateManager_handleUpdateQueues = new WeakMap(), _UpdateManager_nonFirst = new WeakMap(), _UpdateManager_channelUpdateQueues = new WeakMap(), _UpdateManager_ptsUpdateQueue = new WeakMap(), _UpdateManager_processUpdatesQueue = new WeakMap(), _UpdateManager_handleUpdatesSet = new WeakMap(), _UpdateManager_instances = new WeakSet(), _UpdateManager_mustDropPendingUpdates = async function _UpdateManager_mustDropPendingUpdates() {
201
202
  if (typeof __classPrivateFieldGet(this, _UpdateManager_c, "f").dropPendingUpdates === "boolean") {
202
203
  return __classPrivateFieldGet(this, _UpdateManager_c, "f").dropPendingUpdates;
203
204
  }
@@ -205,6 +206,20 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
205
206
  __classPrivateFieldSet(this, _UpdateManager_defaultDropPendingUpdates, await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getAccountType() == "bot", "f");
206
207
  }
207
208
  return __classPrivateFieldGet(this, _UpdateManager_defaultDropPendingUpdates, "f");
209
+ }, _UpdateManager_getState = async function _UpdateManager_getState() {
210
+ if (await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this)) {
211
+ return __classPrivateFieldGet(this, _UpdateManager_state, "f") ?? null;
212
+ }
213
+ if (__classPrivateFieldGet(this, _UpdateManager_state, "f") !== undefined) {
214
+ return __classPrivateFieldGet(this, _UpdateManager_state, "f");
215
+ }
216
+ const state = await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getState();
217
+ return __classPrivateFieldSet(this, _UpdateManager_state, state, "f");
218
+ }, _UpdateManager_setState = async function _UpdateManager_setState(state) {
219
+ __classPrivateFieldSet(this, _UpdateManager_state, state, "f");
220
+ if (!await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this)) {
221
+ await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(state);
222
+ }
208
223
  }, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck = async function _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck(channelId) {
209
224
  if (!(await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_mustDropPendingUpdates).call(this))) {
210
225
  return await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getChannelPts(channelId);
@@ -323,7 +338,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
323
338
  localState.seq = seq;
324
339
  localState.date = updates_.date;
325
340
  await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setUpdateStateDate).call(this, updates_.date);
326
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
341
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
327
342
  }
328
343
  else if (localSeq + 1 > seqStart) {
329
344
  // The update sequence was already applied, and must be ignored.
@@ -438,7 +453,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
438
453
  if (update instanceof _2_tl_js_1.types.UpdatePtsChanged) {
439
454
  await this.fetchState("updatePtsChanged");
440
455
  if (__classPrivateFieldGet(this, _UpdateManager_updateState, "f")) {
441
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(__classPrivateFieldGet(this, _UpdateManager_updateState, "f"));
456
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, __classPrivateFieldGet(this, _UpdateManager_updateState, "f"));
442
457
  }
443
458
  else {
444
459
  (0, _1_utilities_js_1.UNREACHABLE)();
@@ -457,23 +472,23 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
457
472
  }, _UpdateManager_setUpdateStateDate = async function _UpdateManager_setUpdateStateDate(date) {
458
473
  const localState = await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_getLocalState).call(this);
459
474
  localState.date = date;
460
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
475
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
461
476
  }, _UpdateManager_setUpdatePts = async function _UpdateManager_setUpdatePts(pts) {
462
477
  const localState = await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_getLocalState).call(this);
463
478
  localState.pts = pts;
464
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
479
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
465
480
  }, _UpdateManager_getLocalState = async function _UpdateManager_getLocalState() {
466
- let localState = await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.getState();
481
+ let localState = await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_getState).call(this);
467
482
  if (!localState) {
468
483
  if (__classPrivateFieldGet(this, _UpdateManager_updateState, "f")) {
469
484
  localState = __classPrivateFieldGet(this, _UpdateManager_updateState, "f");
470
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
485
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
471
486
  }
472
487
  else {
473
488
  await this.fetchState("getLocalState");
474
489
  if (__classPrivateFieldGet(this, _UpdateManager_updateState, "f")) {
475
490
  localState = __classPrivateFieldGet(this, _UpdateManager_updateState, "f");
476
- await __classPrivateFieldGet(this, _UpdateManager_c, "f").storage.setState(localState);
491
+ await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
477
492
  }
478
493
  else {
479
494
  (0, _1_utilities_js_1.UNREACHABLE)();
@@ -242,6 +242,8 @@ export declare class Client<C extends Context = Context> extends ClientAbstract
242
242
  */
243
243
  send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
244
244
  getInputPeer(id: ID): Promise<import("../tl/2_types.js").InputPeerChat_ | import("../tl/2_types.js").InputPeerUser_ | import("../tl/2_types.js").InputPeerChannel_>;
245
+ getInputChannel(id: ID): Promise<import("../tl/2_types.js").InputChannel_>;
246
+ getInputUser(id: ID): Promise<import("../tl/2_types.js").InputUser_>;
245
247
  private [getEntity];
246
248
  private [getEntity];
247
249
  private [getEntity];
@@ -216,6 +216,11 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
216
216
  return update.chosenInlineResult.inlineMessageId;
217
217
  }
218
218
  }
219
+ else if ("callbackQuery" in update) {
220
+ if (update.callbackQuery.inlineMessageId) {
221
+ return update.callbackQuery.inlineMessageId;
222
+ }
223
+ }
219
224
  (0, _1_utilities_js_1.UNREACHABLE)();
220
225
  };
221
226
  const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : undefined;
@@ -957,7 +962,21 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
957
962
  }
958
963
  return inputPeer;
959
964
  }
960
- [(_Client_initConnection = async function _Client_initConnection() {
965
+ async getInputChannel(id) {
966
+ const inputPeer = await this.getInputPeer(id);
967
+ if (!(inputPeer instanceof _2_tl_js_1.types.InputPeerChannel)) {
968
+ (0, _1_utilities_js_1.UNREACHABLE)();
969
+ }
970
+ return new _2_tl_js_1.types.InputChannel(inputPeer);
971
+ }
972
+ async getInputUser(id) {
973
+ const inputPeer = await this.getInputPeer(id);
974
+ if (!(inputPeer instanceof _2_tl_js_1.types.InputPeerUser)) {
975
+ (0, _1_utilities_js_1.UNREACHABLE)();
976
+ }
977
+ return new _2_tl_js_1.types.InputUser(inputPeer);
978
+ }
979
+ async [(_Client_initConnection = async function _Client_initConnection() {
961
980
  if (!__classPrivateFieldGet(this, _Client_connectionInited, "f")) {
962
981
  await this.api.initConnection({
963
982
  api_id: this.apiId,
@@ -1198,10 +1217,18 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
1198
1217
  }
1199
1218
  }, _Client_getUserAccessHash = async function _Client_getUserAccessHash(userId) {
1200
1219
  const users = await this.api.users.getUsers({ id: [new _2_tl_js_1.types.InputUser({ user_id: userId, access_hash: 0n })] });
1201
- return users[0]?.[_2_tl_js_1.as](_2_tl_js_1.types.User).access_hash ?? 0n;
1220
+ const user = users[0]?.[_2_tl_js_1.as](_2_tl_js_1.types.User);
1221
+ if (user) {
1222
+ await this.messageStorage.setEntity(user);
1223
+ }
1224
+ return user?.access_hash ?? 0n;
1202
1225
  }, _Client_getChannelAccessHash = async function _Client_getChannelAccessHash(channelId) {
1203
1226
  const channels = await this.api.channels.getChannels({ id: [new _2_tl_js_1.types.InputChannel({ channel_id: channelId, access_hash: 0n })] });
1204
- return channels.chats[0][_2_tl_js_1.as](_2_tl_js_1.types.Channel).access_hash ?? 0n;
1227
+ const channel = channels.chats[0][_2_tl_js_1.as](_2_tl_js_1.types.Channel);
1228
+ if (channel) {
1229
+ await this.messageStorage.setEntity(channel);
1230
+ }
1231
+ return channel?.access_hash ?? 0n;
1205
1232
  }, _Client_getInputPeerInner = async function _Client_getInputPeerInner(id) {
1206
1233
  const idn = Number(id);
1207
1234
  if (!isNaN(idn)) {
@@ -1258,7 +1285,14 @@ class Client extends _0_client_abstract_js_1.ClientAbstract {
1258
1285
  }
1259
1286
  }, getEntity)](peer) {
1260
1287
  const id = (0, _2_tl_js_1.peerToChatId)(peer);
1261
- return this.messageStorage.getEntity(id);
1288
+ const entity = await this.messageStorage.getEntity(id);
1289
+ if (entity == null && await this.storage.getAccountType() == "bot" && peer instanceof _2_tl_js_1.types.PeerUser || peer instanceof _2_tl_js_1.types.PeerChannel) {
1290
+ await this.getInputPeer(id);
1291
+ }
1292
+ else {
1293
+ return entity;
1294
+ }
1295
+ return await this.messageStorage.getEntity(id);
1262
1296
  }
1263
1297
  use(...middleware) {
1264
1298
  const composer = new _1_composer_js_1.Composer(...middleware);
@@ -69,6 +69,7 @@ export declare abstract class Storage {
69
69
  }): MaybePromise<Generator<[readonly StorageKeyPart[], T]> | AsyncGenerator<[readonly StorageKeyPart[], T]>>;
70
70
  abstract get supportsFiles(): boolean;
71
71
  abstract branch(id: string): Storage;
72
+ get isMemoryStorage(): boolean;
72
73
  setDc(dc: DC | null): MaybePromise<void>;
73
74
  getDc(): MaybePromise<DC | null>;
74
75
  getAuthKey(): Promise<Uint8Array | null>;
@@ -79,7 +80,7 @@ export declare abstract class Storage {
79
80
  updateUsernames(id: number, usernames: string[]): Promise<void>;
80
81
  getUsername(username: string): Promise<[number, Date] | null>;
81
82
  setTlObject(key: readonly StorageKeyPart[], value: TLObject | null): Promise<void>;
82
- getTlObject(keyOrBuffer: Uint8Array | readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
83
+ getTlObject(keyOrBuffer: TLObject | Uint8Array | readonly StorageKeyPart[]): Promise<import("../2_tl.js").ReadObject | null>;
83
84
  setState(state: enums.updates.State): Promise<void>;
84
85
  getState(): Promise<import("../tl/2_types.js").updates_State_ | null>;
85
86
  setMessage(chatId: number, messageId: number, message: enums.Message | null): Promise<void>;
@@ -90,7 +91,7 @@ export declare abstract class Storage {
90
91
  setChannelPts(channelId: bigint, pts: number): Promise<void>;
91
92
  getChannelPts(channelId: bigint): MaybePromise<number | null>;
92
93
  setEntity(entity: AnyEntity): Promise<void>;
93
- getEntity(key: number): Promise<AnyEntity | null>;
94
+ getEntity(key: number): Promise<import("../2_tl.js").ReadObject | null>;
94
95
  setAccountType(type: "user" | "bot"): Promise<void>;
95
96
  getAccountType(): Promise<"bot" | "user" | null>;
96
97
  updateStickerSetName(id: bigint, accessHash: bigint, name: string): Promise<void>;
@@ -71,6 +71,9 @@ class Storage {
71
71
  _Storage_authKeyId.set(this, null);
72
72
  _Storage_accountType.set(this, null);
73
73
  }
74
+ get isMemoryStorage() {
75
+ return false;
76
+ }
74
77
  setDc(dc) {
75
78
  return this.set(exports.K.auth.dc(), dc);
76
79
  }
@@ -128,13 +131,18 @@ class Storage {
128
131
  await this.set(key, null);
129
132
  }
130
133
  else {
131
- await this.set(key, (0, _1_utilities_js_1.rleEncode)(value[_2_tl_js_1.serialize]()));
134
+ await this.set(key, this.isMemoryStorage ? value : (0, _1_utilities_js_1.rleEncode)(value[_2_tl_js_1.serialize]()));
132
135
  }
133
136
  }
134
137
  async getTlObject(keyOrBuffer) {
135
- const buffer = keyOrBuffer instanceof Uint8Array ? keyOrBuffer : await this.get(keyOrBuffer);
138
+ const buffer = (keyOrBuffer instanceof Uint8Array || keyOrBuffer instanceof _2_tl_js_1.TLObject) ? keyOrBuffer : await this.get(keyOrBuffer);
136
139
  if (buffer != null) {
137
- return new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)(buffer)).readObject();
140
+ if (buffer instanceof Uint8Array) {
141
+ return new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)(buffer)).readObject();
142
+ }
143
+ else {
144
+ return buffer;
145
+ }
138
146
  }
139
147
  else {
140
148
  return null;
@@ -178,14 +186,13 @@ class Storage {
178
186
  return this.get(exports.K.updates.channelPts(channelId));
179
187
  }
180
188
  async setEntity(entity) {
181
- await this.set(exports.K.cache.peer((0, _2_tl_js_1.peerToChatId)(entity)), [(0, _1_utilities_js_1.rleEncode)(entity[_2_tl_js_1.serialize]()), new Date()]);
189
+ await this.set(exports.K.cache.peer((0, _2_tl_js_1.peerToChatId)(entity)), [this.isMemoryStorage ? entity : (0, _1_utilities_js_1.rleEncode)(entity[_2_tl_js_1.serialize]()), new Date()]);
182
190
  }
183
191
  async getEntity(key) {
184
192
  const peer_ = await this.get(exports.K.cache.peer(key));
185
193
  if (peer_ != null) {
186
194
  const [obj_] = peer_;
187
- const entity = new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)(obj_)).readObject();
188
- return entity;
195
+ return await this.getTlObject(obj_);
189
196
  }
190
197
  else {
191
198
  return null;
@@ -304,12 +311,12 @@ class Storage {
304
311
  await this.set(exports.K.cache.file(id), [partCount, chunkSize]);
305
312
  }
306
313
  async setCustomEmojiDocument(id, document) {
307
- await this.set(exports.K.cache.customEmojiDocument(id), [(0, _1_utilities_js_1.rleEncode)(document[_2_tl_js_1.serialize]()), new Date()]);
314
+ await this.set(exports.K.cache.customEmojiDocument(id), [this.isMemoryStorage ? document : (0, _1_utilities_js_1.rleEncode)(document[_2_tl_js_1.serialize]()), new Date()]);
308
315
  }
309
316
  async getCustomEmojiDocument(id) {
310
317
  const v = await this.get(exports.K.cache.customEmojiDocument(id));
311
318
  if (v != null) {
312
- return [await this.getTlObject([0]), v[1]];
319
+ return [await this.getTlObject(v[0]), v[1]];
313
320
  }
314
321
  else {
315
322
  return null;
@@ -8,6 +8,7 @@ export declare enum ValueType {
8
8
  Uint8Array = 5,
9
9
  Array = 6
10
10
  }
11
+ export declare const WEB_STORAGE_PREFIX_EXP: RegExp;
11
12
  export declare function toString(value: unknown): string;
12
13
  export declare function fromString<T>(string: string): T;
13
14
  export declare function fixKey(key: readonly StorageKeyPart[]): (string | number)[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isInRange = exports.getPrefixKeyRange = exports.restoreKey = exports.fixKey = exports.fromString = exports.toString = exports.ValueType = void 0;
3
+ exports.isInRange = exports.getPrefixKeyRange = exports.restoreKey = exports.fixKey = exports.fromString = exports.toString = exports.WEB_STORAGE_PREFIX_EXP = exports.ValueType = void 0;
4
4
  const _0_deps_js_1 = require("../0_deps.js");
5
5
  const _1_utilities_js_1 = require("../1_utilities.js");
6
6
  var ValueType;
@@ -13,6 +13,7 @@ var ValueType;
13
13
  ValueType[ValueType["Uint8Array"] = 5] = "Uint8Array";
14
14
  ValueType[ValueType["Array"] = 6] = "Array";
15
15
  })(ValueType || (exports.ValueType = ValueType = {}));
16
+ exports.WEB_STORAGE_PREFIX_EXP = /^[\d\w]+$/;
16
17
  function toString(value) {
17
18
  if (typeof value === "boolean") {
18
19
  return `${ValueType.Boolean}${Number(value)}`;
@@ -23,7 +23,7 @@ class StorageLocalStorage extends _0_storage_js_1.Storage {
23
23
  if (prefix.length <= 0) {
24
24
  throw new Error("Empty prefix");
25
25
  }
26
- else if (!/^[0-9a-zA-Z]+$/.test(prefix)) {
26
+ else if (!_0_utilities_js_1.WEB_STORAGE_PREFIX_EXP.test(prefix)) {
27
27
  throw new Error("Unallowed prefix");
28
28
  }
29
29
  super();
@@ -4,6 +4,7 @@ export declare class StorageMemory extends Storage implements Storage {
4
4
  #private;
5
5
  protected map: Map<string, unknown>;
6
6
  protected messageMap: CacheMap<string, unknown>;
7
+ get isMemoryStorage(): boolean;
7
8
  initialize(): void;
8
9
  getMap(key: readonly StorageKeyPart[]): Map<string, unknown>;
9
10
  getMaps(): Map<string, unknown>[];
@@ -34,6 +34,9 @@ class StorageMemory extends _0_storage_js_1.Storage {
34
34
  });
35
35
  _StorageMemory_id.set(this, null);
36
36
  }
37
+ get isMemoryStorage() {
38
+ return true;
39
+ }
37
40
  initialize() {
38
41
  }
39
42
  getMap(key) {
@@ -23,7 +23,7 @@ class StorageSessionStorage extends _0_storage_js_1.Storage {
23
23
  if (prefix.length <= 0) {
24
24
  throw new Error("Empty prefix");
25
25
  }
26
- else if (!/^[0-9a-zA-Z]+$/.test(prefix)) {
26
+ else if (!_0_utilities_js_1.WEB_STORAGE_PREFIX_EXP.test(prefix)) {
27
27
  throw new Error("Unallowed prefix");
28
28
  }
29
29
  super();
@@ -296,11 +296,13 @@ export declare class auth_sendCode_ extends Function_<enums.auth.SentCode> {
296
296
  }
297
297
  export declare class auth_signUp_ extends Function_<enums.auth.Authorization> {
298
298
  static __F: (params: {
299
+ no_joined_notifications?: true;
299
300
  phone_number: string;
300
301
  phone_code_hash: string;
301
302
  first_name: string;
302
303
  last_name: string;
303
304
  }) => enums.auth.Authorization;
305
+ no_joined_notifications?: true;
304
306
  phone_number: string;
305
307
  phone_code_hash: string;
306
308
  first_name: string;
@@ -310,6 +312,7 @@ export declare class auth_signUp_ extends Function_<enums.auth.Authorization> {
310
312
  static get [paramDesc](): ParamDesc;
311
313
  protected get [params](): Params;
312
314
  constructor(params: {
315
+ no_joined_notifications?: true;
313
316
  phone_number: string;
314
317
  phone_code_hash: string;
315
318
  first_name: string;
@@ -6148,14 +6151,17 @@ export declare class messages_reorderPinnedSavedDialogs_ extends Function_<boole
6148
6151
  }
6149
6152
  export declare class messages_getSavedReactionTags_ extends Function_<enums.messages.SavedReactionTags> {
6150
6153
  static __F: (params: {
6154
+ peer?: enums.InputPeer;
6151
6155
  hash: bigint;
6152
6156
  }) => enums.messages.SavedReactionTags;
6157
+ peer?: enums.InputPeer;
6153
6158
  hash: bigint;
6154
6159
  protected get [id](): number;
6155
6160
  static get [name](): string;
6156
6161
  static get [paramDesc](): ParamDesc;
6157
6162
  protected get [params](): Params;
6158
6163
  constructor(params: {
6164
+ peer?: enums.InputPeer;
6159
6165
  hash: bigint;
6160
6166
  });
6161
6167
  }
@@ -840,13 +840,15 @@ Object.defineProperty(auth_sendCode_, "__F", {
840
840
  });
841
841
  class auth_signUp_ extends Function_ {
842
842
  get [_1_tl_object_js_1.id]() {
843
- return 0x80EEE427;
843
+ return 0xAAC7B717;
844
844
  }
845
845
  static get [_1_tl_object_js_1.name]() {
846
846
  return "auth.signUp";
847
847
  }
848
848
  static get [_1_tl_object_js_1.paramDesc]() {
849
849
  return [
850
+ ["flags", _1_tl_object_js_1.flags, "#"],
851
+ ["no_joined_notifications", "true", "flags.0?true"],
850
852
  ["phone_number", "string", "string"],
851
853
  ["phone_code_hash", "string", "string"],
852
854
  ["first_name", "string", "string"],
@@ -855,6 +857,8 @@ class auth_signUp_ extends Function_ {
855
857
  }
856
858
  get [_1_tl_object_js_1.params]() {
857
859
  return [
860
+ ["flags", _1_tl_object_js_1.flags, "#"],
861
+ [this.no_joined_notifications ?? null, "true", "flags.0?true"],
858
862
  [this.phone_number, "string", "string"],
859
863
  [this.phone_code_hash, "string", "string"],
860
864
  [this.first_name, "string", "string"],
@@ -863,6 +867,12 @@ class auth_signUp_ extends Function_ {
863
867
  }
864
868
  constructor(params) {
865
869
  super();
870
+ Object.defineProperty(this, "no_joined_notifications", {
871
+ enumerable: true,
872
+ configurable: true,
873
+ writable: true,
874
+ value: void 0
875
+ });
866
876
  Object.defineProperty(this, "phone_number", {
867
877
  enumerable: true,
868
878
  configurable: true,
@@ -887,6 +897,7 @@ class auth_signUp_ extends Function_ {
887
897
  writable: true,
888
898
  value: void 0
889
899
  });
900
+ this.no_joined_notifications = params.no_joined_notifications;
890
901
  this.phone_number = params.phone_number;
891
902
  this.phone_code_hash = params.phone_code_hash;
892
903
  this.first_name = params.first_name;
@@ -17392,29 +17403,40 @@ Object.defineProperty(messages_reorderPinnedSavedDialogs_, "__F", {
17392
17403
  });
17393
17404
  class messages_getSavedReactionTags_ extends Function_ {
17394
17405
  get [_1_tl_object_js_1.id]() {
17395
- return 0x761DDACF;
17406
+ return 0x3637E05B;
17396
17407
  }
17397
17408
  static get [_1_tl_object_js_1.name]() {
17398
17409
  return "messages.getSavedReactionTags";
17399
17410
  }
17400
17411
  static get [_1_tl_object_js_1.paramDesc]() {
17401
17412
  return [
17413
+ ["flags", _1_tl_object_js_1.flags, "#"],
17414
+ ["peer", _2_types_js_1.types._InputPeer, "flags.0?InputPeer"],
17402
17415
  ["hash", "bigint", "long"],
17403
17416
  ];
17404
17417
  }
17405
17418
  get [_1_tl_object_js_1.params]() {
17406
17419
  return [
17420
+ ["flags", _1_tl_object_js_1.flags, "#"],
17421
+ [this.peer ?? null, _2_types_js_1.types._InputPeer, "flags.0?InputPeer"],
17407
17422
  [this.hash, "bigint", "long"],
17408
17423
  ];
17409
17424
  }
17410
17425
  constructor(params) {
17411
17426
  super();
17427
+ Object.defineProperty(this, "peer", {
17428
+ enumerable: true,
17429
+ configurable: true,
17430
+ writable: true,
17431
+ value: void 0
17432
+ });
17412
17433
  Object.defineProperty(this, "hash", {
17413
17434
  enumerable: true,
17414
17435
  configurable: true,
17415
17436
  writable: true,
17416
17437
  value: void 0
17417
17438
  });
17439
+ this.peer = params.peer;
17418
17440
  this.hash = params.hash;
17419
17441
  }
17420
17442
  }