@mtkruto/node 0.63.7 → 0.63.10

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 (37) hide show
  1. package/esm/client/0_utilities.d.ts +2 -2
  2. package/esm/client/0_utilities.js +2 -2
  3. package/esm/client/2_file_manager.d.ts.map +1 -1
  4. package/esm/client/2_file_manager.js +44 -60
  5. package/esm/client/5_client.d.ts.map +1 -1
  6. package/esm/client/5_client.js +36 -36
  7. package/esm/session/1_session.d.ts.map +1 -1
  8. package/esm/session/1_session.js +0 -4
  9. package/esm/session/2_session_encrypted.js +9 -8
  10. package/esm/transport/0_transport.d.ts +0 -2
  11. package/esm/transport/0_transport.d.ts.map +1 -1
  12. package/esm/transport/0_transport.js +0 -5
  13. package/esm/transport/1_transport_abridged.d.ts +0 -2
  14. package/esm/transport/1_transport_abridged.d.ts.map +1 -1
  15. package/esm/transport/1_transport_abridged.js +8 -23
  16. package/esm/transport/1_transport_intermediate.d.ts +0 -2
  17. package/esm/transport/1_transport_intermediate.d.ts.map +1 -1
  18. package/esm/transport/1_transport_intermediate.js +5 -22
  19. package/package.json +1 -1
  20. package/script/client/0_utilities.d.ts +2 -2
  21. package/script/client/0_utilities.js +2 -2
  22. package/script/client/2_file_manager.d.ts.map +1 -1
  23. package/script/client/2_file_manager.js +43 -59
  24. package/script/client/5_client.d.ts.map +1 -1
  25. package/script/client/5_client.js +36 -36
  26. package/script/session/1_session.d.ts.map +1 -1
  27. package/script/session/1_session.js +0 -4
  28. package/script/session/2_session_encrypted.js +9 -8
  29. package/script/transport/0_transport.d.ts +0 -2
  30. package/script/transport/0_transport.d.ts.map +1 -1
  31. package/script/transport/0_transport.js +0 -5
  32. package/script/transport/1_transport_abridged.d.ts +0 -2
  33. package/script/transport/1_transport_abridged.d.ts.map +1 -1
  34. package/script/transport/1_transport_abridged.js +8 -23
  35. package/script/transport/1_transport_intermediate.d.ts +0 -2
  36. package/script/transport/1_transport_intermediate.d.ts.map +1 -1
  37. package/script/transport/1_transport_intermediate.js +5 -22
@@ -29,7 +29,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
29
29
  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");
30
30
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
31
31
  };
32
- var _Client_instances, _Client_clients, _Client_downloadPools, _Client_uploadPools, _Client_guaranteeUpdateDelivery, _Client_accountManager, _Client_botInfoManager, _Client_businessConnectionManager, _Client_fileManager, _Client_networkStatisticsManager, _Client_paymentManager, _Client_reactionManager, _Client_translationsManager, _Client_updateManager, _Client_messageManager, _Client_videoChatManager, _Client_callbackQueryManager, _Client_chatListManager, _Client_chatManager, _Client_forumManager, _Client_giftManager, _Client_inlineQueryManager, _Client_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_transportProvider, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_getApiId, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_lastUpdates, _Client_updateGapRecoveryLoopAbortController, _Client_startUpdateGapRecoveryLoop, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoopAbortController, _Client_startClientDisconnectionLoop, _Client_clientDisconnectionLoop, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _Client_getUploadClient, _Client_setupClient, _Client_importAuthorization, _Client_invoke, _Client_handleInvokeError, _Client_authStringImported, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerChatId, _Client_getInputPeerInner, _Client_getMinInputPeer, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_previouslyConnected, _Client_lastConnectionState, _Client_onConnectionStateChange;
32
+ var _Client_instances, _Client_clients, _Client_downloadPools, _Client_uploadPools, _Client_guaranteeUpdateDelivery, _Client_accountManager, _Client_botInfoManager, _Client_businessConnectionManager, _Client_fileManager, _Client_networkStatisticsManager, _Client_paymentManager, _Client_reactionManager, _Client_translationsManager, _Client_updateManager, _Client_messageManager, _Client_videoChatManager, _Client_callbackQueryManager, _Client_chatListManager, _Client_chatManager, _Client_forumManager, _Client_giftManager, _Client_inlineQueryManager, _Client_pollManager, _Client_storyManager, _Client_managers, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_transportProvider, _Client_publicKeys, _Client_outgoingMessages, _Client_persistCache, _Client_disableUpdates, _Client_authString, _Client_L, _Client_LsignIn, _Client_LupdateGapRecoveryLoop, _Client_LhandleMigrationError, _Client_Lmin, _Client_setMainClient, _Client_newClient, _Client_disconnectAllClients, _Client_client_get, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_lastUpdates, _Client_updateGapRecoveryLoopAbortController, _Client_startUpdateGapRecoveryLoop, _Client_updateGapRecoveryLoop, _Client_clientDisconnectionLoopAbortController, _Client_startClientDisconnectionLoop, _Client_clientDisconnectionLoop, _Client_getClient, _Client_getMainClientMutex, _Client_getMainClient, _Client_getDownloadClient, _Client_getUploadClient, _Client_setupClient, _Client_importAuthorization, _Client_invoke, _Client_handleInvokeError, _Client_authStringImported, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerChatId, _Client_getInputPeerInner, _Client_getMinInputPeer, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe, _Client_previouslyConnected, _Client_lastConnectionState, _Client_onConnectionStateChange;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.Client = exports.handleMigrationError = exports.restartAuth = exports.Composer = void 0;
35
35
  const _0_deps_js_1 = require("../0_deps.js");
@@ -620,8 +620,8 @@ class Client extends Composer {
620
620
  _Client_connectMutex.set(this, new _1_utilities_js_1.Mutex());
621
621
  _Client_lastPropagatedAuthorizationState.set(this, null);
622
622
  _Client_lastUpdates.set(this, new Date());
623
- _Client_updateGapRecoveryLoopAbortController.set(this, null);
624
- _Client_clientDisconnectionLoopAbortController.set(this, null);
623
+ _Client_updateGapRecoveryLoopAbortController.set(this, void 0);
624
+ _Client_clientDisconnectionLoopAbortController.set(this, void 0);
625
625
  _Client_getMainClientMutex.set(this, new _1_utilities_js_1.Mutex());
626
626
  _Client_handleInvokeError.set(this, skipInvoke());
627
627
  /**
@@ -780,7 +780,7 @@ class Client extends Composer {
780
780
  if (authKey != null && dc != null) {
781
781
  if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc != dc) {
782
782
  __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
783
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
783
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
784
784
  }
785
785
  await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).setAuthKey(authKey);
786
786
  if (__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).serverSalt == 0n) {
@@ -791,7 +791,7 @@ class Client extends Composer {
791
791
  const dc = await this.storage.getDc() ?? _4_constants_js_1.INITIAL_DC;
792
792
  if (!__classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get) || __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc != dc) {
793
793
  __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get)?.disconnect();
794
- __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
794
+ __classPrivateFieldGet(this, _Client_instances, "m", _Client_setMainClient).call(this, __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, true, false));
795
795
  }
796
796
  }
797
797
  await __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).connect();
@@ -817,9 +817,8 @@ class Client extends Composer {
817
817
  await this.storage.setServerSalt(serverSalt);
818
818
  };
819
819
  client.onConnectionStateChange = __classPrivateFieldGet(this, _Client_instances, "m", _Client_onConnectionStateChange).bind(this);
820
- }, _Client_newClient = async function _Client_newClient(dc, main, cdn) {
821
- const apiId = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this);
822
- const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, apiId, {
820
+ }, _Client_newClient = function _Client_newClient(dc, main, cdn) {
821
+ const client = new _2_client_encrypted_js_1.ClientEncrypted(dc, __classPrivateFieldGet(this, _Client_apiId, "f"), {
823
822
  appVersion: this.appVersion,
824
823
  deviceModel: this.deviceModel,
825
824
  langCode: this.language,
@@ -845,9 +844,6 @@ class Client extends Composer {
845
844
  }
846
845
  }, _Client_client_get = function _Client_client_get() {
847
846
  return __classPrivateFieldGet(this, _Client_clients, "f")[0];
848
- }, _Client_getApiId = async function _Client_getApiId() {
849
- const apiId = __classPrivateFieldGet(this, _Client_apiId, "f") || await this.storage.getApiId();
850
- return apiId || 0;
851
847
  }, _Client_propagateConnectionState = function _Client_propagateConnectionState(connectionState) {
852
848
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_queueHandleCtxUpdate).call(this, { connectionState });
853
849
  __classPrivateFieldSet(this, _Client_lastPropagatedConnectionState, connectionState, "f");
@@ -872,6 +868,8 @@ class Client extends Composer {
872
868
  }
873
869
  disconnect() {
874
870
  __classPrivateFieldGet(this, _Client_instances, "m", _Client_disconnectAllClients).call(this);
871
+ __classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f")?.abort();
872
+ __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f")?.abort();
875
873
  __classPrivateFieldGet(this, _Client_updateManager, "f").closeAllChats();
876
874
  }
877
875
  /**
@@ -895,7 +893,9 @@ class Client extends Composer {
895
893
  throw err;
896
894
  }
897
895
  }
898
- const apiId = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this);
896
+ if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
897
+ throw new _0_errors_js_1.InputError("apiId not set");
898
+ }
899
899
  if (!__classPrivateFieldGet(this, _Client_apiHash, "f")) {
900
900
  throw new _0_errors_js_1.InputError("apiHash not set");
901
901
  }
@@ -912,7 +912,7 @@ class Client extends Composer {
912
912
  if (params && "botToken" in params) {
913
913
  while (true) {
914
914
  try {
915
- const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id: apiId, api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"), bot_auth_token: params.botToken, flags: 0 });
915
+ const auth = await this.invoke({ _: "auth.importBotAuthorization", api_id: __classPrivateFieldGet(this, _Client_apiId, "f"), api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"), bot_auth_token: params.botToken, flags: 0 });
916
916
  await this.storage.setAccountId(Number(_2_tl_js_1.Api.as("auth.authorization", auth).user.id));
917
917
  await this.storage.setAccountType("bot");
918
918
  break;
@@ -1068,6 +1068,9 @@ class Client extends Composer {
1068
1068
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
1069
1069
  await this.storage.importAuthString(authString);
1070
1070
  __classPrivateFieldSet(this, _Client_authStringImported, true, "f");
1071
+ if (!__classPrivateFieldGet(this, _Client_apiId, "f")) {
1072
+ __classPrivateFieldSet(this, _Client_apiId, await this.storage.getApiId() ?? 0, "f");
1073
+ }
1071
1074
  }
1072
1075
  /**
1073
1076
  * Get a chat's inputPeer. Useful when calling API functions directly.
@@ -1130,14 +1133,15 @@ class Client extends Composer {
1130
1133
  }, _Client_startUpdateGapRecoveryLoop = function _Client_startUpdateGapRecoveryLoop() {
1131
1134
  (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_updateGapRecoveryLoop).call(this));
1132
1135
  }, _Client_updateGapRecoveryLoop = async function _Client_updateGapRecoveryLoop() {
1133
- __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
1136
+ __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f")?.abort();
1137
+ const controller = __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
1134
1138
  while (this.connected) {
1135
1139
  try {
1136
- await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f").signal });
1140
+ await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: controller.signal });
1137
1141
  if (!this.connected) {
1138
- continue;
1142
+ break;
1139
1143
  }
1140
- __classPrivateFieldGet(this, _Client_updateGapRecoveryLoopAbortController, "f").signal.throwIfAborted();
1144
+ controller.signal.throwIfAborted();
1141
1145
  if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * _0_deps_js_1.MINUTE) {
1142
1146
  (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
1143
1147
  __classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
@@ -1146,10 +1150,10 @@ class Client extends Composer {
1146
1150
  }
1147
1151
  catch (err) {
1148
1152
  if (err instanceof DOMException && err.name == "AbortError") {
1149
- __classPrivateFieldSet(this, _Client_updateGapRecoveryLoopAbortController, new AbortController(), "f");
1153
+ break;
1150
1154
  }
1151
- if (!this.connected) {
1152
- continue;
1155
+ else if (!this.connected) {
1156
+ break;
1153
1157
  }
1154
1158
  __classPrivateFieldGet(this, _Client_LupdateGapRecoveryLoop, "f").error(err);
1155
1159
  }
@@ -1157,20 +1161,14 @@ class Client extends Composer {
1157
1161
  }, _Client_startClientDisconnectionLoop = function _Client_startClientDisconnectionLoop() {
1158
1162
  (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_instances, "m", _Client_clientDisconnectionLoop).call(this));
1159
1163
  }, _Client_clientDisconnectionLoop = async function _Client_clientDisconnectionLoop() {
1160
- __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
1164
+ const controller = __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
1161
1165
  while (this.connected) {
1162
1166
  try {
1163
- await new Promise((resolve, reject) => {
1164
- const timeout = setTimeout(resolve, 60 * _0_deps_js_1.SECOND);
1165
- __classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f").signal.onabort = () => {
1166
- reject(__classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f")?.signal.reason);
1167
- clearTimeout(timeout);
1168
- };
1169
- });
1167
+ await (0, _0_deps_js_1.delay)(60 * _0_deps_js_1.SECOND, { signal: controller.signal });
1170
1168
  if (!this.connected) {
1171
- continue;
1169
+ break;
1172
1170
  }
1173
- __classPrivateFieldGet(this, _Client_clientDisconnectionLoopAbortController, "f").signal.throwIfAborted();
1171
+ controller.signal.throwIfAborted();
1174
1172
  const now = Date.now();
1175
1173
  const disconnectAfter = 5 * _0_deps_js_1.MINUTE;
1176
1174
  __classPrivateFieldGet(this, _Client_clients, "f").map((client, i) => {
@@ -1181,10 +1179,10 @@ class Client extends Composer {
1181
1179
  }
1182
1180
  catch (err) {
1183
1181
  if (err instanceof DOMException && err.name == "AbortError") {
1184
- __classPrivateFieldSet(this, _Client_clientDisconnectionLoopAbortController, new AbortController(), "f");
1182
+ break;
1185
1183
  }
1186
- if (!this.connected) {
1187
- continue;
1184
+ else if (!this.connected) {
1185
+ break;
1188
1186
  }
1189
1187
  }
1190
1188
  }
@@ -1219,7 +1217,7 @@ class Client extends Composer {
1219
1217
  return client;
1220
1218
  }
1221
1219
  try {
1222
- client = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, false);
1220
+ client = __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, false);
1223
1221
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_setupClient).call(this, client);
1224
1222
  __classPrivateFieldGet(this, _Client_clients, "f").push(client);
1225
1223
  return client;
@@ -1231,8 +1229,10 @@ class Client extends Composer {
1231
1229
  dc ??= __classPrivateFieldGet(this, _Client_instances, "a", _Client_client_get).dc;
1232
1230
  const pool = __classPrivateFieldGet(this, _Client_downloadPools, "f")[dc] ??= new _3_client_encrypted_pool_js_1.ClientEncryptedPool();
1233
1231
  if (!pool.size) {
1234
- for (let i = 0; i < _0_utilities_js_1.DOWNLOAD_POOL_SIZE; ++i) {
1235
- pool.add(await __classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
1232
+ if (!pool.size) {
1233
+ for (let i = 0; i < _0_utilities_js_1.DOWNLOAD_POOL_SIZE; ++i) {
1234
+ pool.add(__classPrivateFieldGet(this, _Client_instances, "m", _Client_newClient).call(this, dc, false, true));
1235
+ }
1236
1236
  }
1237
1237
  }
1238
1238
  const client = pool.nextClient();
@@ -1 +1 @@
1
- {"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IAgCD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,UAAU;IAQV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CACjD"}
1
+ {"version":3,"file":"1_session.d.ts","sourceRoot":"","sources":["../../src/session/1_session.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAoD,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,8BAAsB,OAAO;;IAG3B,SAAS,CAAC,KAAK,EAAE,YAAY,CAAsB;IACnD,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;gBAMvC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,aAAa;IAc1C,IAAI,uBAAuB,CAAC,uBAAuB,EAAE,UAAU,CAAC,oBAAoB,CAAC,EAEpF;IAED,IAAI,kBAAkB,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,EAExE;IAED,IAAI,EAAE,IAAI,EAAE,CAEX;IAED,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAEhC;IA6BD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,OAAO;cAeG,kBAAkB;IAIlC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,UAAU;IAOV,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;CACjD"}
@@ -141,7 +141,6 @@ class Session {
141
141
  __classPrivateFieldSet(this, _Session_disconnected, true, "f");
142
142
  if (this.transport.connection.connected) {
143
143
  this.transport.connection.close();
144
- this.transport.transport.deinitialize();
145
144
  }
146
145
  }
147
146
  }
@@ -152,9 +151,6 @@ _Session_dc = new WeakMap(), _Session_cdn = new WeakMap(), _Session_lastConnect
152
151
  __classPrivateFieldGet(this, _Session_onConnectionStateChange, "f")?.call(this, connected);
153
152
  });
154
153
  }
155
- if (!connected) {
156
- this.transport.transport.deinitialize();
157
- }
158
154
  if (__classPrivateFieldGet(this, _Session_lastState, "f") === connected) {
159
155
  return;
160
156
  }
@@ -234,11 +234,11 @@ _a = SessionEncrypted, _SessionEncrypted_id = new WeakMap(), _SessionEncrypted_a
234
234
  message = await __classPrivateFieldGet(this, _SessionEncrypted_instances, "m", _SessionEncrypted_receive).call(this);
235
235
  }
236
236
  catch (err) {
237
+ __classPrivateFieldGet(this, _SessionEncrypted_L, "f").error("failed to receive message:", err);
237
238
  if (!this.connected) {
238
239
  break;
239
240
  }
240
241
  else {
241
- __classPrivateFieldGet(this, _SessionEncrypted_L, "f").error("failed to receive message:", err);
242
242
  continue;
243
243
  }
244
244
  }
@@ -385,25 +385,26 @@ async function _SessionEncrypted_onMessage(msgId, body) {
385
385
  }, _SessionEncrypted_startPingLoop = function _SessionEncrypted_startPingLoop() {
386
386
  (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _SessionEncrypted_instances, "m", _SessionEncrypted_pingLoop).call(this));
387
387
  }, _SessionEncrypted_pingLoop = async function _SessionEncrypted_pingLoop() {
388
- __classPrivateFieldSet(this, _SessionEncrypted_pingLoopAbortController, new AbortController(), "f");
388
+ __classPrivateFieldGet(this, _SessionEncrypted_pingLoopAbortController, "f")?.abort();
389
+ const controller = __classPrivateFieldSet(this, _SessionEncrypted_pingLoopAbortController, new AbortController(), "f");
389
390
  let timeElapsed = 0;
390
391
  while (this.connected) {
391
392
  const then = Date.now();
392
393
  try {
393
- await (0, _0_deps_js_1.delay)(__classPrivateFieldGet(this, _SessionEncrypted_pingInterval, "f") - timeElapsed, { signal: __classPrivateFieldGet(this, _SessionEncrypted_pingLoopAbortController, "f").signal });
394
+ await (0, _0_deps_js_1.delay)(__classPrivateFieldGet(this, _SessionEncrypted_pingInterval, "f") - timeElapsed, { signal: controller.signal });
394
395
  if (!this.connected) {
395
396
  continue;
396
397
  }
397
- __classPrivateFieldGet(this, _SessionEncrypted_pingLoopAbortController, "f").signal.throwIfAborted();
398
+ controller.signal.throwIfAborted();
398
399
  await __classPrivateFieldGet(this, _SessionEncrypted_instances, "m", _SessionEncrypted_sendPingDelayDisconnect).call(this, __classPrivateFieldGet(this, _SessionEncrypted_pingInterval, "f") / _0_deps_js_1.SECOND + 15);
399
- __classPrivateFieldGet(this, _SessionEncrypted_pingLoopAbortController, "f").signal.throwIfAborted();
400
+ controller.signal.throwIfAborted();
400
401
  }
401
402
  catch (err) {
402
403
  if (err instanceof DOMException && err.name == "AbortError") {
403
- __classPrivateFieldSet(this, _SessionEncrypted_pingLoopAbortController, new AbortController(), "f");
404
+ break;
404
405
  }
405
- if (!this.connected) {
406
- continue;
406
+ else if (!this.connected) {
407
+ break;
407
408
  }
408
409
  __classPrivateFieldGet(this, _SessionEncrypted_LpingLoop, "f").error(err);
409
410
  }
@@ -25,10 +25,8 @@ export declare abstract class Transport {
25
25
  } | null;
26
26
  protected encrypt(buffer: Uint8Array<ArrayBuffer>): Promise<Uint8Array>;
27
27
  protected decrypt(buffer: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer>>;
28
- abstract get initialized(): boolean;
29
28
  abstract initialize(): MaybePromise<void>;
30
29
  abstract receive(): MaybePromise<Uint8Array>;
31
30
  abstract send(buffer: Uint8Array): MaybePromise<void>;
32
- deinitialize(): void;
33
31
  }
34
32
  //# sourceMappingURL=0_transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"0_transport.d.ts","sourceRoot":"","sources":["../../src/transport/0_transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,8BAAsB,SAAS;IAC7B,SAAS,CAAC,qBAAqB,EAAE;QAAE,aAAa,EAAE,GAAG,CAAC;QAAC,aAAa,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAQ;cAE1E,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;cAQ7D,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAQ1F,QAAQ,KAAK,WAAW,IAAI,OAAO,CAAC;IACpC,QAAQ,CAAC,UAAU,IAAI,YAAY,CAAC,IAAI,CAAC;IACzC,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC;IACrD,YAAY;CAKb"}
1
+ {"version":3,"file":"0_transport.d.ts","sourceRoot":"","sources":["../../src/transport/0_transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,8BAAsB,SAAS;IAC7B,SAAS,CAAC,qBAAqB,EAAE;QAAE,aAAa,EAAE,GAAG,CAAC;QAAC,aAAa,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAQ;cAE1E,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;cAQ7D,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAQ1F,QAAQ,CAAC,UAAU,IAAI,YAAY,CAAC,IAAI,CAAC;IACzC,QAAQ,CAAC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC;IAC5C,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC;CACtD"}
@@ -45,10 +45,5 @@ class Transport {
45
45
  return buffer;
46
46
  }
47
47
  }
48
- deinitialize() {
49
- if (this.obfuscationParameters) {
50
- this.obfuscationParameters = null;
51
- }
52
- }
53
48
  }
54
49
  exports.Transport = Transport;
@@ -25,7 +25,5 @@ export declare class TransportAbridged extends Transport implements Transport {
25
25
  initialize(): Promise<void>;
26
26
  receive(): Promise<Uint8Array>;
27
27
  send(buffer: Uint8Array): Promise<void>;
28
- deinitialize(): void;
29
- get initialized(): boolean;
30
28
  }
31
29
  //# sourceMappingURL=1_transport_abridged.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"1_transport_abridged.d.ts","sourceRoot":"","sources":["../../src/transport/1_transport_abridged.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,iBAAkB,SAAQ,SAAU,YAAW,SAAS;;gBAKvD,UAAU,EAAE,UAAU,EAAE,UAAU,UAAQ;IAMhD,UAAU;IAWV,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IA0B9B,IAAI,CAAC,MAAM,EAAE,UAAU;IAcpB,YAAY;IAKrB,IAAI,WAAW,IAAI,OAAO,CAEzB;CACF"}
1
+ {"version":3,"file":"1_transport_abridged.d.ts","sourceRoot":"","sources":["../../src/transport/1_transport_abridged.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,iBAAkB,SAAQ,SAAU,YAAW,SAAS;;gBAIvD,UAAU,EAAE,UAAU,EAAE,UAAU,UAAQ;IAMhD,UAAU;IAQV,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IA0B9B,IAAI,CAAC,MAAM,EAAE,UAAU;CAS9B"}
@@ -29,32 +29,27 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
29
29
  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");
30
30
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
31
  };
32
- var _TransportAbridged_initialized, _TransportAbridged_connection, _TransportAbridged_obfuscated;
32
+ var _TransportAbridged_connection, _TransportAbridged_obfuscated;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.TransportAbridged = void 0;
35
35
  const _0_deps_js_1 = require("../0_deps.js");
36
- const _0_errors_js_1 = require("../0_errors.js");
37
36
  const _1_utilities_js_1 = require("../1_utilities.js");
38
37
  const _0_obfuscation_js_1 = require("./0_obfuscation.js");
39
38
  const _0_transport_js_1 = require("./0_transport.js");
40
39
  class TransportAbridged extends _0_transport_js_1.Transport {
41
40
  constructor(connection, obfuscated = false) {
42
41
  super();
43
- _TransportAbridged_initialized.set(this, false);
44
42
  _TransportAbridged_connection.set(this, void 0);
45
43
  _TransportAbridged_obfuscated.set(this, void 0);
46
44
  __classPrivateFieldSet(this, _TransportAbridged_connection, connection, "f");
47
45
  __classPrivateFieldSet(this, _TransportAbridged_obfuscated, obfuscated, "f");
48
46
  }
49
47
  async initialize() {
50
- if (!__classPrivateFieldGet(this, _TransportAbridged_initialized, "f")) {
51
- if (__classPrivateFieldGet(this, _TransportAbridged_obfuscated, "f")) {
52
- this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEFEFEFEF, __classPrivateFieldGet(this, _TransportAbridged_connection, "f"));
53
- }
54
- else {
55
- await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(new Uint8Array([0xEF]));
56
- }
57
- __classPrivateFieldSet(this, _TransportAbridged_initialized, true, "f");
48
+ if (__classPrivateFieldGet(this, _TransportAbridged_obfuscated, "f")) {
49
+ this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEFEFEFEF, __classPrivateFieldGet(this, _TransportAbridged_connection, "f"));
50
+ }
51
+ else {
52
+ await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(new Uint8Array([0xEF]));
58
53
  }
59
54
  }
60
55
  async receive() {
@@ -70,7 +65,7 @@ class TransportAbridged extends _0_transport_js_1.Transport {
70
65
  let buffer = new Uint8Array(3);
71
66
  await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").read(buffer);
72
67
  buffer = await this.decrypt(buffer);
73
- length = Number((0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, true));
68
+ length = Number((0, _1_utilities_js_1.bigIntFromBuffer)(buffer));
74
69
  }
75
70
  }
76
71
  length *= 4;
@@ -79,22 +74,12 @@ class TransportAbridged extends _0_transport_js_1.Transport {
79
74
  return await this.decrypt(buffer);
80
75
  }
81
76
  async send(buffer) {
82
- if (!this.initialized) {
83
- throw new _0_errors_js_1.ConnectionError("Transport not initialized");
84
- }
85
77
  const bufferLength = buffer.length / 4;
86
78
  const header = new Uint8Array([bufferLength >= 0x7F ? 0x7F : bufferLength]);
87
79
  const length = bufferLength >= 0x7F ? (0, _1_utilities_js_1.bufferFromBigInt)(bufferLength, 3) : new Uint8Array();
88
80
  const data = (0, _0_deps_js_1.concat)([header, length, buffer]);
89
81
  await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(await this.encrypt(data));
90
82
  }
91
- deinitialize() {
92
- super.deinitialize();
93
- __classPrivateFieldSet(this, _TransportAbridged_initialized, false, "f");
94
- }
95
- get initialized() {
96
- return __classPrivateFieldGet(this, _TransportAbridged_initialized, "f");
97
- }
98
83
  }
99
84
  exports.TransportAbridged = TransportAbridged;
100
- _TransportAbridged_initialized = new WeakMap(), _TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
85
+ _TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
@@ -25,7 +25,5 @@ export declare class TransportIntermediate extends Transport implements Transpor
25
25
  initialize(): Promise<void>;
26
26
  receive(): Promise<Uint8Array>;
27
27
  send(buffer: Uint8Array): Promise<void>;
28
- deinitialize(): void;
29
- get initialized(): boolean;
30
28
  }
31
29
  //# sourceMappingURL=1_transport_intermediate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"1_transport_intermediate.d.ts","sourceRoot":"","sources":["../../src/transport/1_transport_intermediate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,qBAAsB,SAAQ,SAAU,YAAW,SAAS;;gBAK3D,UAAU,EAAE,UAAU,EAAE,UAAU,UAAQ;IAMhD,UAAU;IAaV,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAiB9B,IAAI,CAAC,MAAM,EAAE,UAAU;IAWpB,YAAY;IAKrB,IAAI,WAAW,IAAI,OAAO,CAEzB;CACF"}
1
+ {"version":3,"file":"1_transport_intermediate.d.ts","sourceRoot":"","sources":["../../src/transport/1_transport_intermediate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,qBAAsB,SAAQ,SAAU,YAAW,SAAS;;gBAI3D,UAAU,EAAE,UAAU,EAAE,UAAU,UAAQ;IAMhD,UAAU;IAQV,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAiB9B,IAAI,CAAC,MAAM,EAAE,UAAU;CAM9B"}
@@ -29,7 +29,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
29
29
  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");
30
30
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
31
  };
32
- var _TransportIntermediate_connection, _TransportIntermediate_initialized, _TransportIntermediate_obfuscated;
32
+ var _TransportIntermediate_connection, _TransportIntermediate_obfuscated;
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.TransportIntermediate = void 0;
35
35
  const _0_deps_js_1 = require("../0_deps.js");
@@ -40,23 +40,16 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
40
40
  constructor(connection, obfuscated = false) {
41
41
  super();
42
42
  _TransportIntermediate_connection.set(this, void 0);
43
- _TransportIntermediate_initialized.set(this, false);
44
43
  _TransportIntermediate_obfuscated.set(this, void 0);
45
44
  __classPrivateFieldSet(this, _TransportIntermediate_connection, connection, "f");
46
45
  __classPrivateFieldSet(this, _TransportIntermediate_obfuscated, obfuscated, "f");
47
46
  }
48
47
  async initialize() {
49
- if (!this.initialized) {
50
- if (__classPrivateFieldGet(this, _TransportIntermediate_obfuscated, "f")) {
51
- this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEEEEEEEE, __classPrivateFieldGet(this, _TransportIntermediate_connection, "f"));
52
- }
53
- else {
54
- await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
55
- }
56
- __classPrivateFieldSet(this, _TransportIntermediate_initialized, true, "f");
48
+ if (__classPrivateFieldGet(this, _TransportIntermediate_obfuscated, "f")) {
49
+ this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEEEEEEEE, __classPrivateFieldGet(this, _TransportIntermediate_connection, "f"));
57
50
  }
58
51
  else {
59
- throw new Error("Transport already initialized");
52
+ await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
60
53
  }
61
54
  }
62
55
  async receive() {
@@ -73,20 +66,10 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
73
66
  return await this.decrypt(buffer);
74
67
  }
75
68
  async send(buffer) {
76
- if (!this.initialized) {
77
- throw new Error("Transport not initialized");
78
- }
79
69
  const length = (0, _1_utilities_js_1.bufferFromBigInt)(buffer.length, 4);
80
70
  const data = (0, _0_deps_js_1.concat)([length, buffer]);
81
71
  await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(await this.encrypt(data));
82
72
  }
83
- deinitialize() {
84
- super.deinitialize();
85
- __classPrivateFieldSet(this, _TransportIntermediate_initialized, false, "f");
86
- }
87
- get initialized() {
88
- return __classPrivateFieldGet(this, _TransportIntermediate_initialized, "f");
89
- }
90
73
  }
91
74
  exports.TransportIntermediate = TransportIntermediate;
92
- _TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_initialized = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();
75
+ _TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();