@mtkruto/node 0.1.190 → 0.1.191

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 (47) hide show
  1. package/esm/0_errors.d.ts +12 -0
  2. package/esm/0_errors.js +19 -0
  3. package/esm/client/0_client_abstract.js +3 -2
  4. package/esm/client/0_html.js +4 -3
  5. package/esm/client/0_markdown.js +6 -5
  6. package/esm/client/0_types.d.ts +0 -2
  7. package/esm/client/0_types.js +1 -2
  8. package/esm/client/0_utilities.js +2 -1
  9. package/esm/client/1_client_encrypted.js +1 -1
  10. package/esm/client/1_client_plain.js +3 -4
  11. package/esm/client/1_composer.js +3 -2
  12. package/esm/client/1_file_manager.js +4 -4
  13. package/esm/client/2_message_manager.js +41 -43
  14. package/esm/client/3_chat_list_manager.js +3 -2
  15. package/esm/client/3_story_manager.js +2 -1
  16. package/esm/client/4_client.d.ts +1 -1
  17. package/esm/client/4_client.js +13 -4
  18. package/esm/mod.d.ts +1 -0
  19. package/esm/mod.js +1 -0
  20. package/esm/types/0__file_id.js +2 -1
  21. package/esm/types/0_chat_photo.d.ts +1 -0
  22. package/esm/types/0_chat_photo.js +7 -4
  23. package/esm/types/5_callback_query.js +2 -1
  24. package/package.json +1 -1
  25. package/script/0_errors.d.ts +12 -0
  26. package/script/0_errors.js +27 -0
  27. package/script/client/0_client_abstract.js +3 -2
  28. package/script/client/0_html.js +4 -3
  29. package/script/client/0_markdown.js +6 -5
  30. package/script/client/0_types.d.ts +0 -2
  31. package/script/client/0_types.js +0 -4
  32. package/script/client/0_utilities.js +2 -1
  33. package/script/client/1_client_encrypted.js +2 -2
  34. package/script/client/1_client_plain.js +3 -4
  35. package/script/client/1_composer.js +3 -2
  36. package/script/client/1_file_manager.js +5 -5
  37. package/script/client/2_message_manager.js +41 -43
  38. package/script/client/3_chat_list_manager.js +3 -2
  39. package/script/client/3_story_manager.js +2 -1
  40. package/script/client/4_client.d.ts +1 -1
  41. package/script/client/4_client.js +13 -4
  42. package/script/mod.d.ts +1 -0
  43. package/script/mod.js +1 -0
  44. package/script/types/0__file_id.js +2 -1
  45. package/script/types/0_chat_photo.d.ts +1 -0
  46. package/script/types/0_chat_photo.js +7 -4
  47. package/script/types/5_callback_query.js +2 -1
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var _Client_instances, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Client = exports.handleMigrationError = exports.restartAuth = exports.Composer = void 0;
16
+ const _0_errors_js_1 = require("../0_errors.js");
16
17
  const _1_utilities_js_1 = require("../1_utilities.js");
17
18
  const _2_tl_js_1 = require("../2_tl.js");
18
19
  const _3_storage_js_1 = require("../3_storage.js");
@@ -668,6 +669,7 @@ class Client extends Composer {
668
669
  try {
669
670
  const exportedAuth = await this.api.auth.exportAuthorization({ dc_id: dcId });
670
671
  await client.authorize(exportedAuth);
672
+ // throw 1;
671
673
  return true;
672
674
  }
673
675
  catch (err) {
@@ -810,7 +812,11 @@ class Client extends Composer {
810
812
  await Promise.all([this.storage.setAuthKey(__classPrivateFieldGet(this, _Client_client, "f").authKey), this.storage.setDc(__classPrivateFieldGet(this, _Client_client, "f").dc), this.storage.setServerSalt(__classPrivateFieldGet(this, _Client_client, "f").serverSalt)]);
811
813
  }
812
814
  async reconnect(dc) {
813
- await __classPrivateFieldGet(this, _Client_client, "f").reconnect(dc);
815
+ await this.disconnect();
816
+ if (dc) {
817
+ await this.setDc(dc);
818
+ }
819
+ await this.connect();
814
820
  }
815
821
  async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_storeMessages = new WeakMap(), _Client_Lauthorize = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
816
822
  const apiId = this.apiId || await this.storage.getApiId();
@@ -1054,6 +1060,9 @@ class Client extends Composer {
1054
1060
  inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getUserAccessHash).call(this, inputPeer.user_id);
1055
1061
  }
1056
1062
  }
1063
+ else {
1064
+ throw new _0_errors_js_1.AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
1065
+ }
1057
1066
  return inputPeer;
1058
1067
  }
1059
1068
  /**
@@ -1064,7 +1073,7 @@ class Client extends Composer {
1064
1073
  async getInputChannel(id) {
1065
1074
  const inputPeer = await this.getInputPeer(id);
1066
1075
  if (!(inputPeer instanceof _2_tl_js_1.types.InputPeerChannel)) {
1067
- (0, _1_utilities_js_1.UNREACHABLE)();
1076
+ throw new TypeError(`The chat ${id} is not a channel neither a supergroup.`);
1068
1077
  }
1069
1078
  return new _2_tl_js_1.types.InputChannel(inputPeer);
1070
1079
  }
@@ -1076,7 +1085,7 @@ class Client extends Composer {
1076
1085
  async getInputUser(id) {
1077
1086
  const inputPeer = await this.getInputPeer(id);
1078
1087
  if (!(inputPeer instanceof _2_tl_js_1.types.InputPeerUser)) {
1079
- (0, _1_utilities_js_1.UNREACHABLE)();
1088
+ throw new TypeError(`The chat ${id} is not a private chat.`);
1080
1089
  }
1081
1090
  return new _2_tl_js_1.types.InputUser(inputPeer);
1082
1091
  }
@@ -1231,7 +1240,7 @@ class Client extends Composer {
1231
1240
  return new _2_tl_js_1.types.InputPeerChannel({ channel_id: (0, _2_tl_js_1.chatIdToPeerId)(id), access_hash: accessHash ?? 0n });
1232
1241
  }
1233
1242
  else {
1234
- throw new Error("ID format unknown or not implemented");
1243
+ throw new _0_errors_js_1.InputError("The ID is of an format unknown.");
1235
1244
  }
1236
1245
  }, getEntity)](peer) {
1237
1246
  const id = (0, _2_tl_js_1.peerToChatId)(peer);
package/script/mod.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./0_errors.js";
1
2
  export { getColorFromPeerId, getColorName, getRandomId, setLogVerbosity } from "./1_utilities.js";
2
3
  export { checkPassword } from "./client/0_password.js";
3
4
  export * from "./2_connection.js";
package/script/mod.js CHANGED
@@ -27,6 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.errors = exports.SYSTEM_VERSION = exports.SYSTEM_LANG_CODE = exports.LAYER = exports.LANG_PACK = exports.LANG_CODE = exports.INITIAL_DC = exports.DEVICE_MODEL = exports.APP_VERSION = exports.checkPassword = exports.setLogVerbosity = exports.getRandomId = exports.getColorName = exports.getColorFromPeerId = void 0;
30
+ __exportStar(require("./0_errors.js"), exports);
30
31
  var _1_utilities_js_1 = require("./1_utilities.js");
31
32
  Object.defineProperty(exports, "getColorFromPeerId", { enumerable: true, get: function () { return _1_utilities_js_1.getColorFromPeerId; } });
32
33
  Object.defineProperty(exports, "getColorName", { enumerable: true, get: function () { return _1_utilities_js_1.getColorName; } });
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toUniqueFileId = exports.serializeFileId = exports.deserializeFileId = exports.PhotoSourceType = exports.FileType = void 0;
4
+ const _0_errors_js_1 = require("../0_errors.js");
4
5
  const _1_utilities_js_1 = require("../1_utilities.js");
5
6
  const _2_tl_js_1 = require("../2_tl.js");
6
7
  const NEXT_VERSION = 53;
@@ -218,7 +219,7 @@ function hasFileReference(fileType) {
218
219
  function deserializeFileId(fileId) {
219
220
  const reader = new _2_tl_js_1.TLReader((0, _1_utilities_js_1.rleDecode)((0, _1_utilities_js_1.base64DecodeUrlSafe)(fileId)));
220
221
  if (reader.buffer[reader.buffer.length - 1] != PERSISTENT_ID_VERSION) {
221
- throw new Error("Unsupported version");
222
+ throw new _0_errors_js_1.InputError("Unsupported file ID format");
222
223
  }
223
224
  const originalType = reader.readInt32();
224
225
  const type = ((originalType & ~WEB_LOCATION_FLAG) & ~FILE_REFERENCE_FLAG);
@@ -11,6 +11,7 @@ export interface _ChatPhotoBase {
11
11
  bigFileUniqueId: string;
12
12
  /** Whether the chat photo is animated. */
13
13
  hasVideo: boolean;
14
+ strippedThumbnail?: Uint8Array;
14
15
  }
15
16
  /** @unlisted */
16
17
  export interface ChatPhotoUser extends _ChatPhotoBase {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.constructChatPhoto = void 0;
4
+ const _1_utilities_js_1 = require("../1_utilities.js");
4
5
  const _2_tl_js_1 = require("../2_tl.js");
5
6
  const _0__file_id_js_1 = require("./0__file_id.js");
6
7
  function constructChatPhoto(photo, chatId, chatAccessHash) {
@@ -19,23 +20,25 @@ function constructChatPhoto(photo, chatId, chatAccessHash) {
19
20
  const bigFileId = (0, _0__file_id_js_1.serializeFileId)(bigFileId_);
20
21
  const bigFileUniqueId = (0, _0__file_id_js_1.toUniqueFileId)(bigFileId_);
21
22
  if (photo instanceof _2_tl_js_1.types.ChatPhoto) {
22
- return {
23
+ return (0, _1_utilities_js_1.cleanObject)({
23
24
  smallFileId,
24
25
  smallFileUniqueId,
25
26
  bigFileId,
26
27
  bigFileUniqueId,
27
28
  hasVideo: photo.has_video || false,
28
- };
29
+ strippedThumbnail: photo.stripped_thumb,
30
+ });
29
31
  }
30
32
  else {
31
- return {
33
+ return (0, _1_utilities_js_1.cleanObject)({
32
34
  personal: photo.personal ? true : undefined,
33
35
  smallFileId,
34
36
  smallFileUniqueId,
35
37
  bigFileId,
36
38
  bigFileUniqueId,
37
39
  hasVideo: photo.has_video || false,
38
- };
40
+ strippedThumbnail: photo.stripped_thumb,
41
+ });
39
42
  }
40
43
  }
41
44
  exports.constructChatPhoto = constructChatPhoto;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.constructCallbackQuery = exports.deserializeInlineMessageId = void 0;
4
+ const _0_errors_js_1 = require("../0_errors.js");
4
5
  const _1_utilities_js_1 = require("../1_utilities.js");
5
6
  const _2_tl_js_1 = require("../2_tl.js");
6
7
  const _1_user_js_1 = require("./1_user.js");
7
- const ERR_INVALID_INLINE_MESSAGE_ID = new Error("Invalid inline message ID");
8
+ const ERR_INVALID_INLINE_MESSAGE_ID = new _0_errors_js_1.InputError("Invalid inline message ID");
8
9
  function deserializeInlineMessageId(inlineMessageId) {
9
10
  try {
10
11
  const buffer = (0, _1_utilities_js_1.base64DecodeUrlSafe)(inlineMessageId);