@mtkruto/node 0.1.107 → 0.1.109

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 (83) hide show
  1. package/esm/0_deps.d.ts +1 -1
  2. package/esm/0_deps.js +1 -1
  3. package/esm/4_constants.d.ts +2 -2
  4. package/esm/4_constants.js +3 -3
  5. package/esm/5_client.d.ts +1 -0
  6. package/esm/5_client.js +1 -0
  7. package/esm/client/0_html.js +26 -14
  8. package/esm/client/0_utilities.d.ts +1 -1
  9. package/esm/client/0_utilities.js +1 -2
  10. package/esm/client/1_client_abstract.d.ts +1 -1
  11. package/esm/client/1_client_abstract.js +16 -8
  12. package/esm/client/2_client_plain.d.ts +1 -2
  13. package/esm/client/2_client_plain.js +20 -15
  14. package/esm/client/3_types.d.ts +1 -1
  15. package/esm/client/4_client.d.ts +6 -57
  16. package/esm/client/4_client.js +619 -716
  17. package/esm/connection/1_connection_web_socket.d.ts +1 -9
  18. package/esm/connection/1_connection_web_socket.js +81 -108
  19. package/esm/storage/0_storage.d.ts +3 -2
  20. package/esm/storage/0_storage.js +35 -26
  21. package/esm/storage/0_utilities.d.ts +1 -1
  22. package/esm/storage/0_utilities.js +56 -26
  23. package/esm/storage/1_storage_local_storage.d.ts +1 -1
  24. package/esm/storage/1_storage_session_storage.d.ts +1 -1
  25. package/esm/tl/2_types.d.ts +441 -58
  26. package/esm/tl/2_types.js +1584 -118
  27. package/esm/tl/3_functions.d.ts +113 -16
  28. package/esm/tl/3_functions.js +364 -39
  29. package/esm/transport/1_transport_abridged.d.ts +1 -2
  30. package/esm/transport/1_transport_abridged.js +24 -19
  31. package/esm/transport/1_transport_intermediate.d.ts +1 -2
  32. package/esm/transport/1_transport_intermediate.js +23 -18
  33. package/esm/types/0_color.d.ts +2 -1
  34. package/esm/types/0_color.js +21 -1
  35. package/esm/types/0_message_entity.d.ts +1 -1
  36. package/esm/types/1_chat.js +5 -5
  37. package/esm/types/1_user.js +2 -2
  38. package/esm/types/3_message.js +1 -1
  39. package/esm/utilities/0_base64.js +3 -3
  40. package/esm/utilities/0_queue.d.ts +2 -4
  41. package/esm/utilities/0_queue.js +39 -36
  42. package/package.json +1 -1
  43. package/script/0_deps.d.ts +1 -1
  44. package/script/0_deps.js +3 -3
  45. package/script/4_constants.d.ts +2 -2
  46. package/script/4_constants.js +3 -3
  47. package/script/5_client.d.ts +1 -0
  48. package/script/5_client.js +1 -0
  49. package/script/client/0_html.js +26 -14
  50. package/script/client/0_utilities.d.ts +1 -1
  51. package/script/client/0_utilities.js +1 -2
  52. package/script/client/1_client_abstract.d.ts +1 -1
  53. package/script/client/1_client_abstract.js +16 -8
  54. package/script/client/2_client_plain.d.ts +1 -2
  55. package/script/client/2_client_plain.js +20 -15
  56. package/script/client/3_types.d.ts +1 -1
  57. package/script/client/4_client.d.ts +6 -57
  58. package/script/client/4_client.js +619 -716
  59. package/script/connection/1_connection_web_socket.d.ts +1 -9
  60. package/script/connection/1_connection_web_socket.js +81 -108
  61. package/script/storage/0_storage.d.ts +3 -2
  62. package/script/storage/0_storage.js +35 -26
  63. package/script/storage/0_utilities.d.ts +1 -1
  64. package/script/storage/0_utilities.js +55 -25
  65. package/script/storage/1_storage_local_storage.d.ts +1 -1
  66. package/script/storage/1_storage_session_storage.d.ts +1 -1
  67. package/script/tl/2_types.d.ts +441 -58
  68. package/script/tl/2_types.js +1646 -158
  69. package/script/tl/3_functions.d.ts +113 -16
  70. package/script/tl/3_functions.js +386 -53
  71. package/script/transport/1_transport_abridged.d.ts +1 -2
  72. package/script/transport/1_transport_abridged.js +24 -19
  73. package/script/transport/1_transport_intermediate.d.ts +1 -2
  74. package/script/transport/1_transport_intermediate.js +23 -18
  75. package/script/types/0_color.d.ts +2 -1
  76. package/script/types/0_color.js +24 -3
  77. package/script/types/0_message_entity.d.ts +1 -1
  78. package/script/types/1_chat.js +4 -4
  79. package/script/types/1_user.js +1 -1
  80. package/script/types/3_message.js +1 -1
  81. package/script/utilities/0_base64.js +2 -2
  82. package/script/utilities/0_queue.d.ts +2 -4
  83. package/script/utilities/0_queue.js +39 -36
package/esm/0_deps.d.ts CHANGED
@@ -5,4 +5,4 @@ export { Mutex, type MutexInterface } from "async-mutex";
5
5
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
6
6
  import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js";
7
7
  export declare const debug: typeof debug_;
8
- export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.204.0/encoding/base64.js";
8
+ export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.204.0/encoding/base64.js";
package/esm/0_deps.js CHANGED
@@ -5,4 +5,4 @@ export { Mutex } from "async-mutex";
5
5
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
6
6
  import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js";
7
7
  export const debug = (v) => debug_(v);
8
- export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.204.0/encoding/base64.js";
8
+ export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.204.0/encoding/base64.js";
@@ -4,8 +4,8 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
4
4
  export declare const PUBLIC_KEYS: PublicKeys;
5
5
  export declare const VECTOR_CONSTRUCTOR = 481674261;
6
6
  export declare const INITIAL_DC: DC;
7
- export declare const LAYER = 165;
8
- export declare const APP_VERSION = "MTKruto 0.1.107";
7
+ export declare const LAYER = 166;
8
+ export declare const APP_VERSION = "MTKruto 0.1.109";
9
9
  export declare const DEVICE_MODEL: string;
10
10
  export declare const LANG_CODE: string;
11
11
  export declare const LANG_PACK = "";
@@ -52,9 +52,9 @@ export const PUBLIC_KEYS = Object.freeze([
52
52
  ],
53
53
  ]);
54
54
  export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
55
- export const INITIAL_DC = "2-test";
56
- export const LAYER = 165;
57
- export const APP_VERSION = "MTKruto 0.1.107";
55
+ export const INITIAL_DC = "2";
56
+ export const LAYER = 166;
57
+ export const APP_VERSION = "MTKruto 0.1.109";
58
58
  // @ts-ignore: lib
59
59
  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;
60
60
  export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
package/esm/5_client.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./client/2_client_plain.js";
2
+ export * from "./client/3_types.js";
2
3
  export * from "./client/4_client.js";
package/esm/5_client.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./client/2_client_plain.js";
2
+ export * from "./client/3_types.js";
2
3
  export * from "./client/4_client.js";
@@ -1,25 +1,26 @@
1
1
  import { Parser } from "../0_deps.js";
2
2
  export function parseHtml(html) {
3
+ html = html.trim();
3
4
  let text = "";
4
5
  const entities = new Array();
5
- const queue = new Array();
6
+ const stack = new Array();
6
7
  const parser = new Parser({
7
8
  onopentag(name, attribs) {
8
9
  switch (name) {
9
10
  case "b":
10
11
  case "strong":
11
- queue.push({ type: "bold", offset: text.length, length: 0 });
12
+ stack.push({ type: "bold", offset: text.length, length: 0 });
12
13
  break;
13
14
  case "em":
14
15
  case "i":
15
- queue.push({ type: "italic", offset: text.length, length: 0 });
16
+ stack.push({ type: "italic", offset: text.length, length: 0 });
16
17
  break;
17
18
  case "code":
18
- queue.push({ type: "code", offset: text.length, length: 0 });
19
+ stack.push({ type: "code", offset: text.length, length: 0 });
19
20
  break;
20
21
  case "pre": {
21
22
  const language = attribs.language ?? "";
22
- queue.push({ type: "pre", offset: text.length, length: 0, language });
23
+ stack.push({ type: "pre", offset: text.length, length: 0, language });
23
24
  break;
24
25
  }
25
26
  case "a": {
@@ -27,16 +28,16 @@ export function parseHtml(html) {
27
28
  if (!url) {
28
29
  throw new Error("Missing attribute href");
29
30
  }
30
- queue.push({ type: "textLink", offset: text.length, length: 0, url });
31
+ stack.push({ type: "textLink", offset: text.length, length: 0, url });
31
32
  break;
32
33
  }
33
34
  case "ins":
34
35
  case "u":
35
- queue.push({ type: "underline", offset: text.length, length: 0 });
36
+ stack.push({ type: "underline", offset: text.length, length: 0 });
36
37
  break;
37
38
  case "del":
38
39
  case "strike":
39
- queue.push({ type: "strikethrough", offset: text.length, length: 0 });
40
+ stack.push({ type: "strikethrough", offset: text.length, length: 0 });
40
41
  break;
41
42
  case "span":
42
43
  if (attribs.class != "tg-spoiler") {
@@ -44,24 +45,29 @@ export function parseHtml(html) {
44
45
  }
45
46
  // falls through
46
47
  case "tg-spoiler":
47
- queue.push({ type: "spoiler", offset: text.length, length: 0 });
48
+ stack.push({ type: "spoiler", offset: text.length, length: 0 });
48
49
  break;
49
50
  case "tg-emoji":
50
51
  if (!attribs["emoji-id"]) {
51
52
  throw new Error("Missing attribute emoji-id");
52
53
  }
53
- queue.push({ type: "spoiler", offset: text.length, length: 0 });
54
+ stack.push({ type: "spoiler", offset: text.length, length: 0 });
55
+ break;
56
+ case "blockquote":
57
+ stack.push({ type: "blockquote", offset: text.length, length: 0 });
54
58
  }
55
59
  },
56
60
  ontext(data) {
61
+ if (!text.length) {
62
+ data = data.trimStart();
63
+ }
57
64
  text += data;
58
- const lastItem = queue[queue.length - 1];
59
- if (lastItem) {
60
- lastItem.length += data.length;
65
+ for (const item of stack) {
66
+ item.length += data.length;
61
67
  }
62
68
  },
63
69
  onclosetag() {
64
- const lastItem = queue.pop();
70
+ const lastItem = stack.pop();
65
71
  if (lastItem) {
66
72
  entities.push(lastItem);
67
73
  }
@@ -69,5 +75,11 @@ export function parseHtml(html) {
69
75
  });
70
76
  parser.write(html);
71
77
  parser.end();
78
+ text = text.trimEnd();
79
+ for (const entity of entities) {
80
+ while (text[entity.offset + (entity.length - 1)] === undefined) {
81
+ --entity.length;
82
+ }
83
+ }
72
84
  return [text, entities];
73
85
  }
@@ -2,4 +2,4 @@ import { types } from "../2_tl.js";
2
2
  export declare const resolve: () => Promise<void>;
3
3
  export type With<T, K extends keyof T> = T & Required<Pick<T, K>>;
4
4
  export declare function isPtsUpdate(v: types.TypeUpdate | types.TypeUpdates): v is types.UpdateShortMessage | types.UpdateShortChatMessage | types.UpdateShortSentMessage | types.UpdateNewMessage | types.UpdateDeleteMessages | types.UpdateReadHistoryInbox | types.UpdateReadHistoryOutbox | types.UpdatePinnedChannelMessages | types.UpdatePinnedMessages | types.UpdateFolderPeers | types.UpdateChannelWebPage | types.UpdateEditMessage | types.UpdateReadMessagesContents | types.UpdateWebPage;
5
- export declare function isChannelPtsUpdate(v: types.TypeUpdate | types.TypeUpdates): v is types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages | types.UpdateReadChannelInbox;
5
+ export declare function isChannelPtsUpdate(v: types.TypeUpdate | types.TypeUpdates): v is types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages;
@@ -19,6 +19,5 @@ export function isPtsUpdate(v) {
19
19
  export function isChannelPtsUpdate(v) {
20
20
  return v instanceof types.UpdateNewChannelMessage ||
21
21
  v instanceof types.UpdateEditChannelMessage ||
22
- v instanceof types.UpdateDeleteChannelMessages ||
23
- v instanceof types.UpdateReadChannelInbox;
22
+ v instanceof types.UpdateDeleteChannelMessages;
24
23
  }
@@ -15,11 +15,11 @@ export interface ClientAbstractParams {
15
15
  cdn?: boolean;
16
16
  }
17
17
  export declare abstract class ClientAbstract {
18
+ #private;
18
19
  protected readonly initialDc: DC;
19
20
  protected readonly transportProvider: TransportProvider;
20
21
  protected readonly cdn: boolean;
21
22
  protected transport?: ReturnType<TransportProvider>;
22
- private dc?;
23
23
  constructor(params?: ClientAbstractParams);
24
24
  protected stateChangeHandler?: (connected: boolean) => void;
25
25
  get dcId(): number;
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ClientAbstract_dc;
1
13
  import { initTgCrypto } from "../0_deps.js";
2
14
  import { webSocketTransportProvider } from "../3_transport.js";
3
15
  import { INITIAL_DC } from "../4_constants.js";
@@ -27,12 +39,7 @@ export class ClientAbstract {
27
39
  writable: true,
28
40
  value: void 0
29
41
  });
30
- Object.defineProperty(this, "dc", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: void 0
35
- });
42
+ _ClientAbstract_dc.set(this, void 0);
36
43
  Object.defineProperty(this, "stateChangeHandler", {
37
44
  enumerable: true,
38
45
  configurable: true,
@@ -51,13 +58,13 @@ export class ClientAbstract {
51
58
  }
52
59
  // MaybePromise since `Client` has to deal with `Storage.set()`
53
60
  setDc(dc) {
54
- this.dc = dc;
61
+ __classPrivateFieldSet(this, _ClientAbstract_dc, dc, "f");
55
62
  }
56
63
  get connected() {
57
64
  return this.transport === undefined ? false : this.transport.connection.connected;
58
65
  }
59
66
  async connect() {
60
- this.transport = this.transportProvider({ dc: this.dc ?? this.initialDc, cdn: this.cdn });
67
+ this.transport = this.transportProvider({ dc: __classPrivateFieldGet(this, _ClientAbstract_dc, "f") ?? this.initialDc, cdn: this.cdn });
61
68
  this.transport.connection.stateChangeHandler = this.stateChangeHandler;
62
69
  await initTgCrypto();
63
70
  await this.transport.connection.open();
@@ -78,3 +85,4 @@ export class ClientAbstract {
78
85
  await this.transport.connection.close();
79
86
  }
80
87
  }
88
+ _ClientAbstract_dc = new WeakMap();
@@ -8,8 +8,7 @@ export interface ClientPlainParams extends ClientAbstractParams {
8
8
  publicKeys?: PublicKeys;
9
9
  }
10
10
  export declare class ClientPlain extends ClientAbstract {
11
- private readonly publicKeys;
12
- private lastMsgId;
11
+ #private;
13
12
  constructor(params?: ClientPlainParams);
14
13
  invoke<T extends functions.Function<unknown>>(function_: T): Promise<T["__R"]>;
15
14
  createAuthKey(): Promise<{
@@ -1,3 +1,15 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ClientPlain_publicKeys, _ClientPlain_lastMsgId;
1
13
  import { assertEquals, assertInstanceOf, debug, factorize, ige256Decrypt, ige256Encrypt } from "../0_deps.js";
2
14
  import { bigIntFromBuffer, bufferFromBigInt, concat, getRandomBigInt, modExp, rsaPad, sha1, UNREACHABLE } from "../1_utilities.js";
3
15
  import { functions, serialize, TLReader, types } from "../2_tl.js";
@@ -8,25 +20,15 @@ const d = debug("ClientPlain/createAuthKey");
8
20
  export class ClientPlain extends ClientAbstract {
9
21
  constructor(params) {
10
22
  super(params);
11
- Object.defineProperty(this, "publicKeys", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "lastMsgId", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: 0n
22
- });
23
- this.publicKeys = params?.publicKeys ?? PUBLIC_KEYS;
23
+ _ClientPlain_publicKeys.set(this, void 0);
24
+ _ClientPlain_lastMsgId.set(this, 0n);
25
+ __classPrivateFieldSet(this, _ClientPlain_publicKeys, params?.publicKeys ?? PUBLIC_KEYS, "f");
24
26
  }
25
27
  async invoke(function_) {
26
28
  if (!this.transport) {
27
29
  throw new Error("Not connected");
28
30
  }
29
- const msgId = this.lastMsgId = getMessageId(this.lastMsgId);
31
+ const msgId = __classPrivateFieldSet(this, _ClientPlain_lastMsgId, getMessageId(__classPrivateFieldGet(this, _ClientPlain_lastMsgId, "f")), "f");
30
32
  await this.transport.transport.send(packUnencryptedMessage(function_[serialize](), msgId));
31
33
  const buffer = await this.transport.transport.receive();
32
34
  if (buffer.length == 4) {
@@ -60,14 +62,16 @@ export class ClientPlain extends ClientAbstract {
60
62
  UNREACHABLE();
61
63
  }
62
64
  const pq_ = bigIntFromBuffer(resPq.pq, false, false);
65
+ d("pq=%d", pq_);
63
66
  const [p_, q_] = factorize(pq_);
64
67
  d("factorized pq");
68
+ d("p=%d, q=%d", p_, q_);
65
69
  const p = bufferFromBigInt(p_, 4, false, false);
66
70
  const q = bufferFromBigInt(q_, 4, false, false);
67
71
  let publicKeyFingerprint;
68
72
  let publicKey;
69
73
  for (const fingerprint of resPq.serverPublicKeyFingerprints) {
70
- const maybePublicKey = this.publicKeys.find(([k]) => (k == fingerprint));
74
+ const maybePublicKey = __classPrivateFieldGet(this, _ClientPlain_publicKeys, "f").find(([k]) => (k == fingerprint));
71
75
  if (maybePublicKey) {
72
76
  publicKeyFingerprint = fingerprint;
73
77
  publicKey = maybePublicKey[1];
@@ -137,3 +141,4 @@ export class ClientPlain extends ClientAbstract {
137
141
  };
138
142
  }
139
143
  }
144
+ _ClientPlain_publicKeys = new WeakMap(), _ClientPlain_lastMsgId = new WeakMap();
@@ -3,7 +3,7 @@ import { functions, types } from "../2_tl.js";
3
3
  import { BotCommandScope, CallbackQuery, ChatID, ForceReply, InlineKeyboardMarkup, InlineQuery, InlineQueryResultButton, Message, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove } from "../3_types.js";
4
4
  import { With } from "./0_utilities.js";
5
5
  import { ClientPlainParams } from "./2_client_plain.js";
6
- export type ParseMode = "HTML" | null;
6
+ import { ParseMode } from "../3_types.js";
7
7
  export interface ClientParams extends ClientPlainParams {
8
8
  /**
9
9
  * A parse mode to use when the `parseMode` parameter is not specified when sending or editing messages. Defauls to `ParseMode.None`.
@@ -2,11 +2,11 @@ import { MaybePromise } from "../1_utilities.js";
2
2
  import { functions, ReadObject, types } from "../2_tl.js";
3
3
  import { Storage } from "../3_storage.js";
4
4
  import { DC } from "../3_transport.js";
5
- import { BotCommand, ChatAction, ChatID, InlineQueryResult, Message, User } from "../3_types.js";
5
+ import { BotCommand, ChatAction, ChatID, InlineQueryResult, Message, ParseMode, User } from "../3_types.js";
6
6
  import { Migrate } from "../4_errors.js";
7
7
  import { With } from "./0_utilities.js";
8
8
  import { ClientAbstract } from "./1_client_abstract.js";
9
- import { AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, ClientParams, DownloadParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, GetMyCommandsParams, Handler, ParseMode, SendMessagesParams, SendPollParams, SetMyCommandsParams, Update, UploadParams } from "./3_types.js";
9
+ import { AnswerCallbackQueryParams, AnswerInlineQueryParams, AuthorizeUserParams, ClientParams, DownloadParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, GetMyCommandsParams, Handler, SendMessagesParams, SendPollParams, SetMyCommandsParams, Update, UploadParams } from "./3_types.js";
10
10
  declare const getEntity: unique symbol;
11
11
  declare const getStickerSetName: unique symbol;
12
12
  export declare const handleMigrationError: unique symbol;
@@ -15,15 +15,9 @@ export declare const restartAuth: unique symbol;
15
15
  export declare class ConnectionError extends Error {
16
16
  }
17
17
  export declare class Client extends ClientAbstract {
18
+ #private;
18
19
  readonly apiId: number | null;
19
20
  readonly apiHash: string | null;
20
- private auth;
21
- private sessionId;
22
- private state;
23
- private promises;
24
- private toAcknowledge;
25
- private updateState?;
26
- private readonly errorHandler?;
27
21
  readonly storage: Storage;
28
22
  readonly parseMode: ParseMode;
29
23
  readonly appVersion: string;
@@ -32,8 +26,6 @@ export declare class Client extends ClientAbstract {
32
26
  readonly langPack: string;
33
27
  readonly systemLangCode: string;
34
28
  readonly systemVersion: string;
35
- private readonly publicKeys?;
36
- private readonly autoStart;
37
29
  /**
38
30
  * Constructs the client.
39
31
  *
@@ -42,10 +34,7 @@ export declare class Client extends ClientAbstract {
42
34
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
43
35
  */
44
36
  constructor(storage: Storage | null, apiId?: number | null, apiHash?: string | null, params?: ClientParams);
45
- private propagateConnectionState;
46
- private lastPropagatedConnectionState;
47
37
  protected stateChangeHandler: (connected: boolean) => void;
48
- private storageInited;
49
38
  /**
50
39
  * Sets the DC and resets the auth key stored in the session provider
51
40
  * if the stored DC was not the same as the `dc` parameter.
@@ -53,25 +42,14 @@ export declare class Client extends ClientAbstract {
53
42
  * @param dc The DC to change to.
54
43
  */
55
44
  setDc(dc: DC): Promise<void>;
56
- private setAuth;
57
- private connectMutex;
58
45
  /**
59
46
  * Loads the session if `setDc` was not called, initializes and connnects
60
47
  * a `ClientPlain` to generate auth key if there was none, and connects the client.
61
48
  * Before establishing the connection, the session is saved.
62
49
  */
63
50
  connect(): Promise<void>;
64
- private assertUser;
65
- private assertBot;
66
- private fetchState;
67
51
  [handleMigrationError](err: Migrate): Promise<void>;
68
- private connectionInited;
69
52
  disconnect(): Promise<void>;
70
- private initConnection;
71
- private lastPropagatedAuthorizationState;
72
- private propagateAuthorizationState;
73
- private selfId;
74
- private getSelfId;
75
53
  /**
76
54
  * Calls [initConnection](1) and authorizes the client with one of the following:
77
55
  *
@@ -91,14 +69,9 @@ export declare class Client extends ClientAbstract {
91
69
  */
92
70
  authorize(params?: string | types.AuthExportedAuthorization | AuthorizeUserParams): Promise<void>;
93
71
  /**
94
- * Same as calling `.connect()` followed by `.authorize(params)`.
72
+ * Same as calling `.connect()` followed by `.authorize(params)` if the session didn't have an auth key.
95
73
  */
96
74
  start(params?: string | types.AuthExportedAuthorization | AuthorizeUserParams): Promise<void>;
97
- private receiveLoop;
98
- private pingLoop;
99
- private pingLoopStarted;
100
- private autoStarted;
101
- private lastMsgId;
102
75
  /**
103
76
  * Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
104
77
  * to be connected.
@@ -111,27 +84,13 @@ export declare class Client extends ClientAbstract {
111
84
  * Alias for `invoke` with its second parameter being `true`.
112
85
  */
113
86
  send<T extends (functions.Function<unknown> | types.Type) = functions.Function<unknown>>(function_: T): Promise<void>;
114
- private processChats;
115
- private processUsers;
116
- private handleUpdateQueue;
117
- private processUpdatesQueue;
118
- private checkGap;
119
- private checkChannelGap;
120
- private processUpdates;
121
- private setUpdateStateDate;
122
- private getLocalState;
123
- private recoverUpdateGap;
124
- private recoverChannelUpdateGap;
125
- private getUserAccessHash;
126
- private getChannelAccessHash;
87
+ checkGap(pts: number, ptsCount: number, assertNoGap: boolean): Promise<void>;
88
+ getUserAccessHash(userId: bigint): Promise<bigint>;
127
89
  getInputPeer(id: ChatID): Promise<types.InputPeerChat | types.InputPeerUser | types.InputPeerChannel>;
128
- private getInputPeerInner;
129
90
  private [getEntity];
130
91
  private [getEntity];
131
92
  private [getEntity];
132
93
  processResult(result: ReadObject): Promise<void>;
133
- private updatesToMessages;
134
- private resolveSendAs;
135
94
  /**
136
95
  * Send a text message.
137
96
  *
@@ -141,7 +100,6 @@ export declare class Client extends ClientAbstract {
141
100
  * @returns The sent text message.
142
101
  */
143
102
  sendMessage(chatId: ChatID, text: string, params?: SendMessagesParams): Promise<With<Message, "text">>;
144
- private parseText;
145
103
  /**
146
104
  * Edit a message's text.
147
105
  *
@@ -152,7 +110,6 @@ export declare class Client extends ClientAbstract {
152
110
  * @returns The edited text message.
153
111
  */
154
112
  editMessageText(chatId: ChatID, messageId: number, text: string, params?: EditMessageParams): Promise<With<Message, "text">>;
155
- private getMessagesInner;
156
113
  /**
157
114
  * Retrieve multiple messages.
158
115
  *
@@ -178,7 +135,6 @@ export declare class Client extends ClientAbstract {
178
135
  * @returns The retrieved message.
179
136
  */
180
137
  getMessage(chatId: ChatID, messageId: number): Promise<Omit<Message, "replyToMessage"> | null>;
181
- private downloadInner;
182
138
  /**
183
139
  * Download a file.
184
140
  *
@@ -219,7 +175,6 @@ export declare class Client extends ClientAbstract {
219
175
  * @method
220
176
  */
221
177
  getMe(): Promise<User>;
222
- private handleUpdate;
223
178
  /**
224
179
  * Answer a callback query. Bot-only.
225
180
  *
@@ -227,9 +182,6 @@ export declare class Client extends ClientAbstract {
227
182
  * @param id ID of the callback query to answer.
228
183
  */
229
184
  answerCallbackQuery(id: string, params?: AnswerCallbackQueryParams): Promise<void>;
230
- private usernameResolver;
231
- private constructReplyMarkup;
232
- private static assertMsgHas;
233
185
  /**
234
186
  * Send a poll.
235
187
  *
@@ -277,13 +229,11 @@ export declare class Client extends ClientAbstract {
277
229
  * @param results The results to answer with.
278
230
  */
279
231
  answerInlineQuery(id: string, results: InlineQueryResult[], params?: AnswerInlineQueryParams): Promise<void>;
280
- private handle;
281
232
  use(handler: Handler): void;
282
233
  branch(predicate: (upd: Update) => MaybePromise<boolean>, trueHandler: Handler, falseHandler: Handler): void;
283
234
  filter<D extends Update>(predicate: (update: Update) => update is D, handler: Handler<D>): void;
284
235
  filter(predicate: (update: Update) => MaybePromise<boolean>, handler: Handler): void;
285
236
  on<T extends keyof Update, F extends keyof NonNullable<Update[T]>>(filter: T extends FilterableUpdates ? T | [T, F, ...F[]] : T, handler: Handler<FilterUpdate<Update, T, F>>): void;
286
- private setMyInfo;
287
237
  /**
288
238
  * Set the bot's description in the given language. Bot-only.
289
239
  *
@@ -311,7 +261,6 @@ export declare class Client extends ClientAbstract {
311
261
  shortDescription?: string;
312
262
  languageCode?: string;
313
263
  }): Promise<void>;
314
- private getMyInfo;
315
264
  /**
316
265
  * Get the bot's description in the given language. Bot-only.
317
266
  *