@mtkruto/node 0.67.2 → 0.68.0

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 (244) hide show
  1. package/esm/0_errors.js +2 -6
  2. package/esm/3_errors.js +2 -12
  3. package/esm/3_types.d.ts +1 -0
  4. package/esm/3_types.d.ts.map +1 -1
  5. package/esm/3_types.js +1 -0
  6. package/esm/4_errors.js +2 -12
  7. package/esm/_dnt.polyfills.d.ts +99 -0
  8. package/esm/_dnt.polyfills.d.ts.map +1 -1
  9. package/esm/_dnt.polyfills.js +127 -1
  10. package/esm/_dnt.test_polyfills.d.ts.map +1 -0
  11. package/esm/client/0_filters_test.d.ts.map +1 -1
  12. package/esm/client/0_markdown_test.d.ts.map +1 -1
  13. package/esm/client/0_params.d.ts +2 -0
  14. package/esm/client/0_params.d.ts.map +1 -1
  15. package/esm/client/0_password.d.ts +5 -5
  16. package/esm/client/0_password.d.ts.map +1 -1
  17. package/esm/client/0_password_test.d.ts.map +1 -1
  18. package/esm/client/0_storage_operations.js +143 -155
  19. package/esm/client/0_storage_operations_test.d.ts.map +1 -1
  20. package/esm/client/0_utilities.d.ts +1 -1
  21. package/esm/client/0_utilities_test.d.ts.map +1 -1
  22. package/esm/client/1_client_plain.js +4 -22
  23. package/esm/client/1_composer.js +8 -21
  24. package/esm/client/2_account_manager.js +85 -97
  25. package/esm/client/2_bot_info_manager.js +26 -38
  26. package/esm/client/2_business_connection_manager.js +10 -23
  27. package/esm/client/2_client_encrypted.js +194 -211
  28. package/esm/client/2_file_manager.d.ts +4 -3
  29. package/esm/client/2_file_manager.d.ts.map +1 -1
  30. package/esm/client/2_file_manager.js +268 -224
  31. package/esm/client/2_file_manager_test.d.ts.map +1 -1
  32. package/esm/client/2_network_statistics_manager.js +8 -21
  33. package/esm/client/2_payment_manager.js +7 -20
  34. package/esm/client/2_reaction_manager.js +7 -20
  35. package/esm/client/2_translations_manager.js +97 -107
  36. package/esm/client/2_update_manager.js +764 -759
  37. package/esm/client/3_client_encrypted_pool.js +10 -26
  38. package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  39. package/esm/client/3_message_manager.d.ts +1 -1
  40. package/esm/client/3_message_manager.js +441 -448
  41. package/esm/client/3_message_manager_test.d.ts.map +1 -1
  42. package/esm/client/3_video_chat_manager.d.ts +1 -1
  43. package/esm/client/3_video_chat_manager.js +57 -68
  44. package/esm/client/4_callback_query_manager.js +18 -30
  45. package/esm/client/4_chat_list_manager.js +322 -318
  46. package/esm/client/4_chat_manager.js +118 -131
  47. package/esm/client/4_forum_manager.js +67 -73
  48. package/esm/client/4_gift_manager.js +16 -29
  49. package/esm/client/4_inline_query_manager.js +16 -28
  50. package/esm/client/4_link_preview_manager.js +6 -19
  51. package/esm/client/4_poll_manager.js +44 -57
  52. package/esm/client/4_story_manager.js +41 -53
  53. package/esm/client/5_client.d.ts +7 -0
  54. package/esm/client/5_client.d.ts.map +1 -1
  55. package/esm/client/5_client.js +1269 -1288
  56. package/esm/connection/1_connection_tcp.node.js +48 -65
  57. package/esm/connection/1_connection_web_socket.js +75 -91
  58. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  59. package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  60. package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  61. package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  62. package/esm/mod.js +2 -12
  63. package/esm/session/0_session_state.js +12 -38
  64. package/esm/session/1_session.js +49 -72
  65. package/esm/session/2_session_encrypted.js +324 -320
  66. package/esm/storage/1_utilities_test.d.ts.map +1 -1
  67. package/esm/storage/2_storage_indexed_db.js +26 -44
  68. package/esm/storage/2_storage_local_storage.node.js +12 -25
  69. package/esm/storage/2_storage_memory.js +24 -41
  70. package/esm/storage/2_storage_session_storage.js +3 -16
  71. package/esm/tl/0_utilities_test.d.ts.map +1 -1
  72. package/esm/tl/1_tl_reader.js +80 -88
  73. package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
  74. package/esm/tl/1_tl_writer.js +155 -164
  75. package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
  76. package/esm/transport/0_transport.js +1 -8
  77. package/esm/transport/1_transport_abridged.js +11 -24
  78. package/esm/transport/1_transport_intermediate.js +10 -23
  79. package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -1
  80. package/esm/types/0_upload_progress.d.ts +29 -0
  81. package/esm/types/0_upload_progress.d.ts.map +1 -0
  82. package/esm/types/0_upload_progress.js +20 -0
  83. package/esm/types/1_sticker.d.ts +1 -1
  84. package/esm/types/1_sticker.d.ts.map +1 -1
  85. package/esm/types/2_poll_answer.d.ts +19 -0
  86. package/esm/types/2_poll_answer.d.ts.map +1 -1
  87. package/esm/types/2_poll_answer.js +19 -0
  88. package/esm/types/7_update.d.ts +21 -2
  89. package/esm/types/7_update.d.ts.map +1 -1
  90. package/esm/utilities/0_bigint_test.d.ts.map +1 -1
  91. package/esm/utilities/0_buffer.d.ts +1 -1
  92. package/esm/utilities/0_buffer.d.ts.map +1 -1
  93. package/esm/utilities/0_buffer_test.d.ts.map +1 -1
  94. package/esm/utilities/0_hash.d.ts +2 -2
  95. package/esm/utilities/0_hash.d.ts.map +1 -1
  96. package/esm/utilities/0_mutex.js +4 -19
  97. package/esm/utilities/0_part_stream.js +11 -25
  98. package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
  99. package/esm/utilities/0_rle.d.ts +2 -2
  100. package/esm/utilities/0_rle.d.ts.map +1 -1
  101. package/esm/utilities/0_rle_test.d.ts.map +1 -1
  102. package/esm/utilities/0_text.d.ts +20 -1
  103. package/esm/utilities/0_text.d.ts.map +1 -1
  104. package/esm/utilities/0_text.js +19 -0
  105. package/esm/utilities/1_auth.d.ts +1 -1
  106. package/esm/utilities/1_auth.d.ts.map +1 -1
  107. package/esm/utilities/1_base64.d.ts +1 -1
  108. package/esm/utilities/1_base64.d.ts.map +1 -1
  109. package/esm/utilities/1_base64_test.d.ts.map +1 -1
  110. package/esm/utilities/1_crypto.js +42 -53
  111. package/esm/utilities/1_crypto_test.d.ts.map +1 -1
  112. package/esm/utilities/1_logger.d.ts +2 -2
  113. package/esm/utilities/1_math_test.d.ts.map +1 -1
  114. package/esm/utilities/2_queue.js +29 -47
  115. package/package.json +1 -1
  116. package/script/0_errors.js +2 -6
  117. package/script/2_tl.js +17 -7
  118. package/script/3_errors.js +2 -12
  119. package/script/3_types.d.ts +1 -0
  120. package/script/3_types.d.ts.map +1 -1
  121. package/script/3_types.js +1 -0
  122. package/script/4_constants.js +17 -7
  123. package/script/4_errors.js +2 -12
  124. package/script/_dnt.polyfills.d.ts +99 -0
  125. package/script/_dnt.polyfills.d.ts.map +1 -1
  126. package/script/_dnt.polyfills.js +128 -0
  127. package/script/_dnt.test_polyfills.d.ts.map +1 -0
  128. package/script/client/0_filters_test.d.ts.map +1 -1
  129. package/script/client/0_markdown_test.d.ts.map +1 -1
  130. package/script/client/0_params.d.ts +2 -0
  131. package/script/client/0_params.d.ts.map +1 -1
  132. package/script/client/0_password.d.ts +5 -5
  133. package/script/client/0_password.d.ts.map +1 -1
  134. package/script/client/0_password.js +17 -7
  135. package/script/client/0_password_test.d.ts.map +1 -1
  136. package/script/client/0_storage_operations.js +143 -155
  137. package/script/client/0_storage_operations_test.d.ts.map +1 -1
  138. package/script/client/0_utilities.d.ts +1 -1
  139. package/script/client/0_utilities_test.d.ts.map +1 -1
  140. package/script/client/1_client_plain.js +4 -22
  141. package/script/client/1_composer.js +8 -21
  142. package/script/client/2_account_manager.js +85 -97
  143. package/script/client/2_bot_info_manager.js +26 -38
  144. package/script/client/2_business_connection_manager.js +10 -23
  145. package/script/client/2_client_encrypted.js +195 -212
  146. package/script/client/2_file_manager.d.ts +4 -3
  147. package/script/client/2_file_manager.d.ts.map +1 -1
  148. package/script/client/2_file_manager.js +285 -231
  149. package/script/client/2_file_manager_test.d.ts.map +1 -1
  150. package/script/client/2_network_statistics_manager.js +8 -21
  151. package/script/client/2_payment_manager.js +7 -20
  152. package/script/client/2_reaction_manager.js +7 -20
  153. package/script/client/2_translations_manager.js +98 -108
  154. package/script/client/2_update_manager.js +764 -759
  155. package/script/client/3_client_encrypted_pool.js +10 -26
  156. package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  157. package/script/client/3_message_manager.d.ts +1 -1
  158. package/script/client/3_message_manager.js +441 -448
  159. package/script/client/3_message_manager_test.d.ts.map +1 -1
  160. package/script/client/3_video_chat_manager.d.ts +1 -1
  161. package/script/client/3_video_chat_manager.js +57 -68
  162. package/script/client/4_callback_query_manager.js +18 -30
  163. package/script/client/4_chat_list_manager.js +322 -318
  164. package/script/client/4_chat_manager.js +118 -131
  165. package/script/client/4_forum_manager.js +67 -73
  166. package/script/client/4_gift_manager.js +16 -29
  167. package/script/client/4_inline_query_manager.js +16 -28
  168. package/script/client/4_link_preview_manager.js +6 -19
  169. package/script/client/4_poll_manager.js +44 -57
  170. package/script/client/4_story_manager.js +41 -53
  171. package/script/client/5_client.d.ts +7 -0
  172. package/script/client/5_client.d.ts.map +1 -1
  173. package/script/client/5_client.js +1269 -1288
  174. package/script/connection/1_connection_tcp.node.js +48 -65
  175. package/script/connection/1_connection_web_socket.js +92 -98
  176. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  177. package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
  178. package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
  179. package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  180. package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  181. package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  182. package/script/deps/jsr.io/@std/internal/1.0.10/format.js +17 -7
  183. package/script/deps/jsr.io/@std/internal/1.0.10/styles.js +17 -7
  184. package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
  185. package/script/mod.js +19 -19
  186. package/script/session/0_session_state.js +12 -38
  187. package/script/session/1_session.js +66 -79
  188. package/script/session/2_session_encrypted.js +325 -321
  189. package/script/storage/1_utilities_test.d.ts.map +1 -1
  190. package/script/storage/2_storage_indexed_db.js +26 -44
  191. package/script/storage/2_storage_local_storage.node.js +12 -25
  192. package/script/storage/2_storage_memory.js +24 -41
  193. package/script/storage/2_storage_session_storage.js +3 -16
  194. package/script/tl/0_utilities_test.d.ts.map +1 -1
  195. package/script/tl/1_tl_reader.js +81 -89
  196. package/script/tl/1_tl_reader_test.d.ts.map +1 -1
  197. package/script/tl/1_tl_writer.js +156 -165
  198. package/script/tl/1_tl_writer_test.d.ts.map +1 -1
  199. package/script/tl/2_telegram.js +17 -7
  200. package/script/transport/0_obfuscation.js +17 -7
  201. package/script/transport/0_transport.js +1 -8
  202. package/script/transport/1_transport_abridged.js +11 -24
  203. package/script/transport/1_transport_intermediate.js +10 -23
  204. package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -1
  205. package/script/types/0_upload_progress.d.ts +29 -0
  206. package/script/types/0_upload_progress.d.ts.map +1 -0
  207. package/script/types/0_upload_progress.js +21 -0
  208. package/script/types/1_sticker.d.ts +1 -1
  209. package/script/types/1_sticker.d.ts.map +1 -1
  210. package/script/types/2_poll_answer.d.ts +19 -0
  211. package/script/types/2_poll_answer.d.ts.map +1 -1
  212. package/script/types/2_poll_answer.js +19 -0
  213. package/script/types/7_update.d.ts +21 -2
  214. package/script/types/7_update.d.ts.map +1 -1
  215. package/script/utilities/0_bigint.js +17 -7
  216. package/script/utilities/0_bigint_test.d.ts.map +1 -1
  217. package/script/utilities/0_buffer.d.ts +1 -1
  218. package/script/utilities/0_buffer.d.ts.map +1 -1
  219. package/script/utilities/0_buffer_test.d.ts.map +1 -1
  220. package/script/utilities/0_env.js +17 -7
  221. package/script/utilities/0_hash.d.ts +2 -2
  222. package/script/utilities/0_hash.d.ts.map +1 -1
  223. package/script/utilities/0_hash.js +17 -7
  224. package/script/utilities/0_misc.js +17 -7
  225. package/script/utilities/0_mutex.js +4 -19
  226. package/script/utilities/0_part_stream.js +11 -25
  227. package/script/utilities/0_part_stream_test.d.ts.map +1 -1
  228. package/script/utilities/0_rle.d.ts +2 -2
  229. package/script/utilities/0_rle.d.ts.map +1 -1
  230. package/script/utilities/0_rle_test.d.ts.map +1 -1
  231. package/script/utilities/0_text.d.ts +20 -1
  232. package/script/utilities/0_text.d.ts.map +1 -1
  233. package/script/utilities/0_text.js +19 -0
  234. package/script/utilities/1_auth.d.ts +1 -1
  235. package/script/utilities/1_auth.d.ts.map +1 -1
  236. package/script/utilities/1_auth.js +17 -7
  237. package/script/utilities/1_base64.d.ts +1 -1
  238. package/script/utilities/1_base64.d.ts.map +1 -1
  239. package/script/utilities/1_base64_test.d.ts.map +1 -1
  240. package/script/utilities/1_crypto.js +60 -61
  241. package/script/utilities/1_crypto_test.d.ts.map +1 -1
  242. package/script/utilities/1_logger.d.ts +2 -2
  243. package/script/utilities/1_math_test.d.ts.map +1 -1
  244. package/script/utilities/2_queue.js +30 -48
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- 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");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _StorageOperations_instances, _StorageOperations_storage, _StorageOperations_supportsFiles, _StorageOperations_mustSerialize, _StorageOperations_authKeyId, _StorageOperations_resetAuthKeyId, _StorageOperations_accountId, _StorageOperations_accountType, _StorageOperations_getUpdateId;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.StorageOperations = exports.K = void 0;
35
23
  const _0_deps_js_1 = require("../0_deps.js");
@@ -119,57 +107,62 @@ exports.K = {
119
107
  },
120
108
  };
121
109
  class StorageOperations {
110
+ #storage;
111
+ #supportsFiles;
112
+ #mustSerialize;
113
+ #authKeyId = null;
122
114
  constructor(storage) {
123
- _StorageOperations_instances.add(this);
124
- _StorageOperations_storage.set(this, void 0);
125
- _StorageOperations_supportsFiles.set(this, void 0);
126
- _StorageOperations_mustSerialize.set(this, void 0);
127
- _StorageOperations_authKeyId.set(this, null);
128
- _StorageOperations_accountId.set(this, null);
129
- _StorageOperations_accountType.set(this, null);
130
- __classPrivateFieldSet(this, _StorageOperations_storage, storage, "f");
131
- __classPrivateFieldSet(this, _StorageOperations_supportsFiles, storage.supportsFiles, "f");
132
- __classPrivateFieldSet(this, _StorageOperations_mustSerialize, storage.mustSerialize, "f");
115
+ this.#storage = storage;
116
+ this.#supportsFiles = storage.supportsFiles;
117
+ this.#mustSerialize = storage.mustSerialize;
133
118
  }
134
119
  get provider() {
135
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f");
120
+ return this.#storage;
136
121
  }
137
122
  get supportsFiles() {
138
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").supportsFiles;
123
+ return this.#storage.supportsFiles;
139
124
  }
140
125
  async initialize() {
141
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").initialize();
126
+ await this.#storage.initialize();
142
127
  await this.getAccountType();
143
128
  }
144
129
  set(...args) {
145
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(...args);
130
+ return this.#storage.set(...args);
146
131
  }
147
132
  incr(...args) {
148
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").incr(...args);
133
+ return this.#storage.incr(...args);
149
134
  }
150
135
  get(...args) {
151
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(...args);
136
+ return this.#storage.get(...args);
152
137
  }
153
138
  getMany(...args) {
154
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany(...args);
139
+ return this.#storage.getMany(...args);
155
140
  }
156
141
  async setDc(dc) {
157
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.auth.dc(), dc);
142
+ await this.#storage.set(exports.K.auth.dc(), dc);
158
143
  }
159
144
  getDc() {
160
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.auth.dc());
145
+ return this.#storage.get(exports.K.auth.dc());
146
+ }
147
+ async #resetAuthKeyId(authKey) {
148
+ if (authKey != null) {
149
+ this.#authKeyId = (0, _1_utilities_js_1.bigIntFromBuffer)((await (0, _1_utilities_js_1.sha1)(authKey)).subarray(-8), true, false);
150
+ }
151
+ else {
152
+ this.#authKeyId = null;
153
+ }
161
154
  }
162
155
  async getAuthKey() {
163
- const authKey = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.auth.key());
164
- await __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_resetAuthKeyId).call(this, authKey);
156
+ const authKey = await this.#storage.get(exports.K.auth.key());
157
+ await this.#resetAuthKeyId(authKey);
165
158
  return authKey;
166
159
  }
167
160
  async setAuthKey(authKey) {
168
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.auth.key(), authKey);
169
- await __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_resetAuthKeyId).call(this, authKey);
161
+ await this.#storage.set(exports.K.auth.key(), authKey);
162
+ await this.#resetAuthKeyId(authKey);
170
163
  }
171
164
  get authKeyId() {
172
- return __classPrivateFieldGet(this, _StorageOperations_authKeyId, "f");
165
+ return this.#authKeyId;
173
166
  }
174
167
  async exportAuthString(apiId_) {
175
168
  if (typeof apiId_ === "number") {
@@ -235,24 +228,24 @@ class StorageOperations {
235
228
  async updateUsernames(id, usernames) {
236
229
  for (let username of usernames) {
237
230
  username = username.toLowerCase();
238
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.username(username), [id, new Date()]);
231
+ await this.#storage.set(exports.K.cache.username(username), [id, new Date()]);
239
232
  }
240
233
  }
241
234
  async getUsername(username) {
242
235
  username = username.toLowerCase();
243
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.username(username));
236
+ return await this.#storage.get(exports.K.cache.username(username));
244
237
  }
245
238
  async setTlObject(key, value) {
246
239
  if (value == null) {
247
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
240
+ await this.#storage.set(key, null);
248
241
  }
249
242
  else {
250
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? [value._, (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(value))] : value);
243
+ await this.#storage.set(key, this.#mustSerialize ? [value._, (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(value))] : value);
251
244
  }
252
245
  }
253
246
  async getTlObject(keyOrBuffer) {
254
247
  // @ts-ignore: TBD
255
- const buffer = (keyOrBuffer instanceof Uint8Array || _2_tl_js_1.Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(keyOrBuffer);
248
+ const buffer = (keyOrBuffer instanceof Uint8Array || _2_tl_js_1.Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await this.#storage.get(keyOrBuffer);
256
249
  if (buffer != null) {
257
250
  if (buffer instanceof Uint8Array) {
258
251
  return await _2_tl_js_1.Api.deserializeType(_2_tl_js_1.X, (0, _1_utilities_js_1.rleDecode)(buffer));
@@ -276,40 +269,40 @@ class StorageOperations {
276
269
  }
277
270
  async setMessage(chatId, messageId, message) {
278
271
  if (chatId > _1_utilities_js_1.ZERO_CHANNEL_ID) {
279
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.messages.messageRef(messageId), message == null ? null : chatId);
272
+ await this.#storage.set(exports.K.messages.messageRef(messageId), message == null ? null : chatId);
280
273
  }
281
274
  await this.setTlObject(exports.K.messages.message(chatId, messageId), message);
282
275
  }
283
276
  async deleteMessages() {
284
277
  const maybePromises = new Array();
285
- for await (const [k, o] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.messages.allMessageRefs() })) {
286
- maybePromises.push(Promise.all([__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(k, null), o == null ? Promise.resolve() : __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.messages.message(o, k[1]), null)]));
278
+ for await (const [k, o] of await this.#storage.getMany({ prefix: exports.K.messages.allMessageRefs() })) {
279
+ maybePromises.push(Promise.all([this.#storage.set(k, null), o == null ? Promise.resolve() : this.#storage.set(exports.K.messages.message(o, k[1]), null)]));
287
280
  }
288
281
  await Promise.all(maybePromises.filter((v) => v instanceof Promise));
289
282
  }
290
283
  getMessageChat(messageId) {
291
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.messages.messageRef(messageId));
284
+ return this.#storage.get(exports.K.messages.messageRef(messageId));
292
285
  }
293
286
  async getMessage(chatId, messageId) {
294
287
  return await this.getTlObject(exports.K.messages.message(chatId, messageId));
295
288
  }
296
289
  async getLastMessage(chatId) {
297
- for await (const [_, buffer] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.messages.messages(chatId) }, { limit: 1, reverse: true })) {
290
+ for await (const [_, buffer] of await this.#storage.getMany({ prefix: exports.K.messages.messages(chatId) }, { limit: 1, reverse: true })) {
298
291
  return await this.getTlObject(buffer);
299
292
  }
300
293
  return null;
301
294
  }
302
295
  async setChannelPts(channelId, pts) {
303
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.updates.channelPts(channelId), pts);
296
+ await this.#storage.set(exports.K.updates.channelPts(channelId), pts);
304
297
  }
305
298
  getChannelPts(channelId) {
306
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.updates.channelPts(channelId));
299
+ return this.#storage.get(exports.K.updates.channelPts(channelId));
307
300
  }
308
301
  async setEntity(entity) {
309
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.peer(_2_tl_js_1.Api.peerToChatId(entity)), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(entity)) : entity, new Date()]);
302
+ await this.#storage.set(exports.K.cache.peer(_2_tl_js_1.Api.peerToChatId(entity)), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(entity)) : entity, new Date()]);
310
303
  }
311
304
  async getEntity(key) {
312
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.peer(key));
305
+ const peer_ = await this.#storage.get(exports.K.cache.peer(key));
313
306
  if (peer_ != null) {
314
307
  const [obj_] = peer_;
315
308
  return await this.getTlObject(obj_);
@@ -319,58 +312,60 @@ class StorageOperations {
319
312
  }
320
313
  }
321
314
  async setAccountId(accountId) {
322
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.auth.accountId(), accountId);
315
+ await this.#storage.set(exports.K.auth.accountId(), accountId);
323
316
  }
317
+ #accountId = null;
324
318
  async getAccountId() {
325
- if (__classPrivateFieldGet(this, _StorageOperations_accountId, "f") != null) {
326
- return __classPrivateFieldGet(this, _StorageOperations_accountId, "f");
319
+ if (this.#accountId != null) {
320
+ return this.#accountId;
327
321
  }
328
322
  else {
329
- return (__classPrivateFieldSet(this, _StorageOperations_accountId, await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.auth.accountId()), "f"));
323
+ return (this.#accountId = await this.#storage.get(exports.K.auth.accountId()));
330
324
  }
331
325
  }
332
326
  async setAccountType(type) {
333
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.auth.accountType(), type);
327
+ await this.#storage.set(exports.K.auth.accountType(), type);
334
328
  await this.getAccountType();
335
329
  }
330
+ #accountType = null;
336
331
  async getAccountType() {
337
- if (__classPrivateFieldGet(this, _StorageOperations_accountType, "f") != null) {
338
- return __classPrivateFieldGet(this, _StorageOperations_accountType, "f");
332
+ if (this.#accountType != null) {
333
+ return this.#accountType;
339
334
  }
340
335
  else {
341
- return __classPrivateFieldSet(this, _StorageOperations_accountType, await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.auth.accountType()), "f");
336
+ return this.#accountType = await this.#storage.get(exports.K.auth.accountType());
342
337
  }
343
338
  }
344
339
  get accountType() {
345
- if (__classPrivateFieldGet(this, _StorageOperations_accountType, "f") == null) {
340
+ if (this.#accountType == null) {
346
341
  (0, _0_deps_js_1.unreachable)();
347
342
  }
348
- return __classPrivateFieldGet(this, _StorageOperations_accountType, "f");
343
+ return this.#accountType;
349
344
  }
350
345
  async setIsPremium(isPremium) {
351
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.auth.isPremium(), isPremium);
346
+ await this.#storage.set(exports.K.auth.isPremium(), isPremium);
352
347
  }
353
348
  async getIsPremium() {
354
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.auth.isPremium());
349
+ return await this.#storage.get(exports.K.auth.isPremium());
355
350
  }
356
351
  async updateStickerSetName(id, accessHash, name) {
357
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.stickerSetName(id, accessHash), [name, new Date()]);
352
+ await this.#storage.set(exports.K.cache.stickerSetName(id, accessHash), [name, new Date()]);
358
353
  }
359
354
  getStickerSetName(id, accessHash) {
360
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.stickerSetName(id, accessHash));
355
+ return this.#storage.get(exports.K.cache.stickerSetName(id, accessHash));
361
356
  }
362
357
  async setServerSalt(serverSalt) {
363
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.session.serverSalt(), serverSalt);
358
+ await this.#storage.set(exports.K.session.serverSalt(), serverSalt);
364
359
  }
365
360
  getServerSalt() {
366
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.session.serverSalt());
361
+ return this.#storage.get(exports.K.session.serverSalt());
367
362
  }
368
363
  async setChat(listId, chatId, pinned, topMessageId, topMessageDate) {
369
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.chatlists.chat(listId, chatId), [pinned, topMessageId, topMessageDate]);
364
+ await this.#storage.set(exports.K.chatlists.chat(listId, chatId), [pinned, topMessageId, topMessageDate]);
370
365
  }
371
366
  async getChats(listId) {
372
367
  const chats = new Array();
373
- for await (const [key, value] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.chatlists.chats(listId) })) {
368
+ for await (const [key, value] of await this.#storage.getMany({ prefix: exports.K.chatlists.chats(listId) })) {
374
369
  if (key.length != 3 || typeof key[2] !== "number") {
375
370
  continue;
376
371
  }
@@ -379,24 +374,24 @@ class StorageOperations {
379
374
  return chats;
380
375
  }
381
376
  async removeChats(listId) {
382
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.chatlists.chats(listId) })) {
383
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
377
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.chatlists.chats(listId) })) {
378
+ await this.#storage.set(key, null);
384
379
  }
385
380
  await this.setHasAllChats(listId, false);
386
381
  await this.setPinnedChats(listId, null);
387
382
  }
388
383
  async setHasAllChats(listId, hasAllChats) {
389
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.chatlists.hasAllChats(listId), hasAllChats);
384
+ await this.#storage.set(exports.K.chatlists.hasAllChats(listId), hasAllChats);
390
385
  }
391
386
  async hasAllChats(listId) {
392
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.chatlists.hasAllChats(listId));
387
+ const v = await this.#storage.get(exports.K.chatlists.hasAllChats(listId));
393
388
  return v == true;
394
389
  }
395
390
  async setPinnedChats(listId, chatIds) {
396
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.chatlists.pinnedChats(listId), chatIds);
391
+ await this.#storage.set(exports.K.chatlists.pinnedChats(listId), chatIds);
397
392
  }
398
393
  async getPinnedChats(listId) {
399
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.chatlists.pinnedChats(listId));
394
+ return await this.#storage.get(exports.K.chatlists.pinnedChats(listId));
400
395
  }
401
396
  async getHistory(chatId, offsetId, limit) {
402
397
  if (offsetId == 0) {
@@ -404,7 +399,7 @@ class StorageOperations {
404
399
  }
405
400
  ++limit;
406
401
  const messages = new Array();
407
- for await (const [_, buffer] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ start: exports.K.messages.message(chatId, 0), end: exports.K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
402
+ for await (const [_, buffer] of await this.#storage.getMany({ start: exports.K.messages.message(chatId, 0), end: exports.K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
408
403
  const message = await this.getTlObject(buffer);
409
404
  if ("id" in message && message.id == offsetId) {
410
405
  continue;
@@ -414,18 +409,18 @@ class StorageOperations {
414
409
  return messages;
415
410
  }
416
411
  async getFile(id) {
417
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
412
+ if (!this.#supportsFiles) {
418
413
  return null;
419
414
  }
420
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.file(id));
415
+ return await this.#storage.get(exports.K.cache.file(id));
421
416
  }
422
417
  async *iterFileParts(id, partCount, offset, signal) {
423
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
418
+ if (!this.#supportsFiles) {
424
419
  return;
425
420
  }
426
421
  for (let i = offset; i < partCount; i++) {
427
422
  signal?.throwIfAborted();
428
- const part = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.filePart(id, i));
423
+ const part = await this.#storage.get(exports.K.cache.filePart(id, i));
429
424
  if (part == null) {
430
425
  continue;
431
426
  }
@@ -433,22 +428,22 @@ class StorageOperations {
433
428
  }
434
429
  }
435
430
  async saveFilePart(id, index, bytes) {
436
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
431
+ if (!this.#supportsFiles) {
437
432
  return;
438
433
  }
439
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.filePart(id, index), bytes);
434
+ await this.#storage.set(exports.K.cache.filePart(id, index), bytes);
440
435
  }
441
436
  async setFilePartCount(id, partCount, chunkSize) {
442
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
437
+ if (!this.#supportsFiles) {
443
438
  return;
444
439
  }
445
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.file(id), [partCount, chunkSize]);
440
+ await this.#storage.set(exports.K.cache.file(id), [partCount, chunkSize]);
446
441
  }
447
442
  async setCustomEmojiDocument(id, document) {
448
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(document)) : document, new Date()]);
443
+ await this.#storage.set(exports.K.cache.customEmojiDocument(id), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(document)) : document, new Date()]);
449
444
  }
450
445
  async getCustomEmojiDocument(id) {
451
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.customEmojiDocument(id));
446
+ const v = await this.#storage.get(exports.K.cache.customEmojiDocument(id));
452
447
  if (v != null) {
453
448
  return [await this.getTlObject(v[0]), v[1]];
454
449
  }
@@ -457,10 +452,10 @@ class StorageOperations {
457
452
  }
458
453
  }
459
454
  async setBusinessConnection(id, connection) {
460
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.businessConnection(id), connection == null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(connection)) : connection);
455
+ await this.#storage.set(exports.K.cache.businessConnection(id), connection == null ? null : this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(connection)) : connection);
461
456
  }
462
457
  async getBusinessConnection(id) {
463
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.businessConnection(id));
458
+ const v = await this.#storage.get(exports.K.cache.businessConnection(id));
464
459
  if (v != null) {
465
460
  return await this.getTlObject(v);
466
461
  }
@@ -469,10 +464,10 @@ class StorageOperations {
469
464
  }
470
465
  }
471
466
  async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
472
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(results)) : results, date]);
467
+ await this.#storage.set(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(results)) : results, date]);
473
468
  }
474
469
  async getInlineQueryAnswer(userId, chatId, query, offset) {
475
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
470
+ const peer_ = await this.#storage.get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
476
471
  if (peer_ != null) {
477
472
  const [obj_, date] = peer_;
478
473
  return [_2_tl_js_1.Api.as("messages.botResults", await this.getTlObject(obj_)), date];
@@ -482,10 +477,10 @@ class StorageOperations {
482
477
  }
483
478
  }
484
479
  async setCallbackQueryAnswer(chatId, messageId, question, answer) {
485
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(answer)) : answer, new Date()]);
480
+ await this.#storage.set(exports.K.cache.callbackQueryAnswer(chatId, messageId, question), [this.#mustSerialize ? (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(answer)) : answer, new Date()]);
486
481
  }
487
482
  async getCallbackQueryAnswer(chatId, messageId, question) {
488
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.callbackQueryAnswer(chatId, messageId, question));
483
+ const peer_ = await this.#storage.get(exports.K.cache.callbackQueryAnswer(chatId, messageId, question));
489
484
  if (peer_ != null) {
490
485
  const [obj_, date] = peer_;
491
486
  return [_2_tl_js_1.Api.as("messages.botCallbackAnswer", await this.getTlObject(obj_)), date];
@@ -507,23 +502,33 @@ class StorageOperations {
507
502
  return await this.getTlObject(exports.K.cache.groupCall(id));
508
503
  }
509
504
  async setGroupCallAccessHash(id, accessHash) {
510
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.groupCallAccessHash(id), accessHash);
505
+ await this.#storage.set(exports.K.cache.groupCallAccessHash(id), accessHash);
511
506
  }
512
507
  async getGroupCallAccessHash(id) {
513
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.groupCallAccessHash(id));
508
+ return await this.#storage.get(exports.K.cache.groupCallAccessHash(id));
509
+ }
510
+ #getUpdateId(update) {
511
+ let id = BigInt(Date.now()) << 32n;
512
+ if ("pts" in update && update.pts) {
513
+ id |= BigInt(update.pts);
514
+ }
515
+ else {
516
+ id |= BigInt(0xffffffffn);
517
+ }
518
+ return id;
514
519
  }
515
520
  async setUpdate(boxId, update) {
516
- await this.setTlObject(exports.K.updates.update(boxId, __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_getUpdateId).call(this, update)), update);
521
+ await this.setTlObject(exports.K.updates.update(boxId, this.#getUpdateId(update)), update);
517
522
  }
518
523
  async deleteUpdates() {
519
524
  const maybePromises = new Array();
520
- for await (const [k] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.updates.all() })) {
521
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(k, null));
525
+ for await (const [k] of await this.#storage.getMany({ prefix: exports.K.updates.all() })) {
526
+ maybePromises.push(this.#storage.set(k, null));
522
527
  }
523
528
  await Promise.all(maybePromises.filter((v) => v instanceof Promise));
524
529
  }
525
530
  async getFirstUpdate(boxId) {
526
- for await (const [key, update] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.updates.updates(boxId) }, { limit: 1 })) {
531
+ for await (const [key, update] of await this.#storage.getMany({ prefix: exports.K.updates.updates(boxId) }, { limit: 1 })) {
527
532
  return [key, (await this.getTlObject(update))];
528
533
  }
529
534
  return null;
@@ -539,59 +544,59 @@ class StorageOperations {
539
544
  }
540
545
  }
541
546
  async deleteFiles() {
542
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
547
+ if (!this.#supportsFiles) {
543
548
  return;
544
549
  }
545
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.fileParts() })) {
546
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
550
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.fileParts() })) {
551
+ await this.#storage.set(key, null);
547
552
  }
548
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.files() })) {
549
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
553
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.files() })) {
554
+ await this.#storage.set(key, null);
550
555
  }
551
556
  }
552
557
  async deleteCustomEmojiDocuments() {
553
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.customEmojiDocuments() })) {
554
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
558
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.customEmojiDocuments() })) {
559
+ await this.#storage.set(key, null);
555
560
  }
556
561
  }
557
562
  async deleteBusinessConnections() {
558
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.businessConnections() })) {
559
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
563
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.businessConnections() })) {
564
+ await this.#storage.set(key, null);
560
565
  }
561
566
  }
562
567
  async deleteInlineQueryAnswers() {
563
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.inlineQueryAnswers() })) {
564
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
568
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.inlineQueryAnswers() })) {
569
+ await this.#storage.set(key, null);
565
570
  }
566
571
  }
567
572
  async deleteCallbackQueryAnswers() {
568
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.callbackQueryAnswers() })) {
569
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
573
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.callbackQueryAnswers() })) {
574
+ await this.#storage.set(key, null);
570
575
  }
571
576
  }
572
577
  async deleteFullChats() {
573
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.fullChats() })) {
574
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
578
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.fullChats() })) {
579
+ await this.#storage.set(key, null);
575
580
  }
576
581
  }
577
582
  async deleteGroupCalls() {
578
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.groupCalls() })) {
579
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
583
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.groupCalls() })) {
584
+ await this.#storage.set(key, null);
580
585
  }
581
586
  }
582
587
  async deleteStickerSetNames() {
583
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.stickerSetNames() })) {
584
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
588
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.stickerSetNames() })) {
589
+ await this.#storage.set(key, null);
585
590
  }
586
591
  }
587
592
  async deletePeers() {
588
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.peers() })) {
589
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
593
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.peers() })) {
594
+ await this.#storage.set(key, null);
590
595
  }
591
596
  }
592
597
  async deleteUsernames() {
593
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.usernames() })) {
594
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
598
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.usernames() })) {
599
+ await this.#storage.set(key, null);
595
600
  }
596
601
  }
597
602
  async clear() {
@@ -618,38 +623,38 @@ class StorageOperations {
618
623
  ]);
619
624
  }
620
625
  async setApiId(apiId) {
621
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.connection.apiId(), apiId);
626
+ await this.#storage.set(exports.K.connection.apiId(), apiId);
622
627
  }
623
628
  async getApiId() {
624
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.connection.apiId());
629
+ return await this.#storage.get(exports.K.connection.apiId());
625
630
  }
626
631
  async reset() {
627
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: [] })) {
628
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
632
+ for await (const [key] of await this.#storage.getMany({ prefix: [] })) {
633
+ await this.#storage.set(key, null);
629
634
  }
630
635
  }
631
636
  async setMinPeerReference(chatId, senderId, messageId) {
632
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.minPeerReference(senderId, chatId), [{ chatId, messageId }, new Date()]);
637
+ await this.#storage.set(exports.K.cache.minPeerReference(senderId, chatId), [{ chatId, messageId }, new Date()]);
633
638
  }
634
639
  async getLastMinPeerReference(senderId) {
635
640
  const references = new Array();
636
- for await (const [, reference] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.minPeerReferenceSender(senderId) })) {
641
+ for await (const [, reference] of await this.#storage.getMany({ prefix: exports.K.cache.minPeerReferenceSender(senderId) })) {
637
642
  references.push(reference);
638
643
  }
639
644
  return references.sort((a, b) => b[1].getTime() - a[1].getTime())[0]?.[0] ?? null;
640
645
  }
641
646
  async deleteTranslations() {
642
647
  const maybePromises = new Array();
643
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.allTranslations() })) {
644
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
648
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.allTranslations() })) {
649
+ maybePromises.push(this.#storage.set(key, null));
645
650
  }
646
651
  await Promise.all(maybePromises);
647
652
  }
648
653
  async getTranslations(platform, language) {
649
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(exports.K.cache.translations(platform, language));
654
+ return await this.#storage.get(exports.K.cache.translations(platform, language));
650
655
  }
651
656
  async setTranslations(platform, language, version, translations) {
652
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(exports.K.cache.translations(platform, language), [version, translations, new Date()]);
657
+ await this.#storage.set(exports.K.cache.translations(platform, language), [version, translations, new Date()]);
653
658
  }
654
659
  async setPollResults(pollId, pollResults) {
655
660
  await this.setTlObject(exports.K.cache.pollResult(pollId), pollResults);
@@ -659,8 +664,8 @@ class StorageOperations {
659
664
  }
660
665
  async deletePollResults() {
661
666
  const maybePromises = new Array();
662
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.pollResults() })) {
663
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
667
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.pollResults() })) {
668
+ maybePromises.push(this.#storage.set(key, null));
664
669
  }
665
670
  await Promise.all(maybePromises);
666
671
  }
@@ -672,8 +677,8 @@ class StorageOperations {
672
677
  }
673
678
  async deletePolls() {
674
679
  const maybePromises = new Array();
675
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.polls() })) {
676
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
680
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.polls() })) {
681
+ maybePromises.push(this.#storage.set(key, null));
677
682
  }
678
683
  await Promise.all(maybePromises);
679
684
  }
@@ -685,8 +690,8 @@ class StorageOperations {
685
690
  }
686
691
  async deleteVoiceTranscriptions() {
687
692
  const maybePromises = new Array();
688
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
689
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
693
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
694
+ maybePromises.push(this.#storage.set(key, null));
690
695
  }
691
696
  await Promise.all(maybePromises);
692
697
  }
@@ -698,27 +703,10 @@ class StorageOperations {
698
703
  }
699
704
  async deleteVoiceTranscriptionReferences() {
700
705
  const maybePromises = new Array();
701
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
702
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
706
+ for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
707
+ maybePromises.push(this.#storage.set(key, null));
703
708
  }
704
709
  await Promise.all(maybePromises);
705
710
  }
706
711
  }
707
712
  exports.StorageOperations = StorageOperations;
708
- _StorageOperations_storage = new WeakMap(), _StorageOperations_supportsFiles = new WeakMap(), _StorageOperations_mustSerialize = new WeakMap(), _StorageOperations_authKeyId = new WeakMap(), _StorageOperations_accountId = new WeakMap(), _StorageOperations_accountType = new WeakMap(), _StorageOperations_instances = new WeakSet(), _StorageOperations_resetAuthKeyId = async function _StorageOperations_resetAuthKeyId(authKey) {
709
- if (authKey != null) {
710
- __classPrivateFieldSet(this, _StorageOperations_authKeyId, (0, _1_utilities_js_1.bigIntFromBuffer)((await (0, _1_utilities_js_1.sha1)(authKey)).subarray(-8), true, false), "f");
711
- }
712
- else {
713
- __classPrivateFieldSet(this, _StorageOperations_authKeyId, null, "f");
714
- }
715
- }, _StorageOperations_getUpdateId = function _StorageOperations_getUpdateId(update) {
716
- let id = BigInt(Date.now()) << 32n;
717
- if ("pts" in update && update.pts) {
718
- id |= BigInt(update.pts);
719
- }
720
- else {
721
- id |= BigInt(0xffffffffn);
722
- }
723
- return id;
724
- };
@@ -1 +1 @@
1
- {"version":3,"file":"0_storage_operations_test.d.ts","sourceRoot":"","sources":["../../src/client/0_storage_operations_test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"0_storage_operations_test.d.ts","sourceRoot":"","sources":["../../src/client/0_storage_operations_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}