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