@mtkruto/browser 0.119.0 → 0.120.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/README.md +1 -1
- package/esm/0_errors.d.ts.map +1 -1
- package/esm/0_errors.js +9 -31
- package/esm/3_errors.js +2 -12
- package/esm/4_errors.js +2 -12
- package/esm/_dnt.polyfills.d.ts +0 -99
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +1 -127
- package/esm/client/0_abortable_loop.js +26 -39
- package/esm/client/0_storage_operations.js +179 -218
- package/esm/client/1_client_plain.js +4 -22
- package/esm/client/2_account_manager.js +140 -149
- 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 +198 -215
- package/esm/client/2_file_manager.js +255 -262
- package/esm/client/2_network_statistics_manager.js +31 -44
- 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 +101 -111
- package/esm/client/2_update_manager.js +750 -745
- package/esm/client/3_client_encrypted_pool.js +10 -26
- package/esm/client/3_message_manager.js +503 -508
- 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 +140 -146
- package/esm/client/4_chat_manager.js +161 -169
- package/esm/client/4_checklist_manager.js +26 -39
- package/esm/client/4_context.js +244 -259
- package/esm/client/4_forum_manager.js +67 -73
- package/esm/client/4_gift_manager.js +22 -35
- 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_composer.js +13 -26
- package/esm/client/6_client.js +866 -896
- package/esm/client/6_client_dispatcher.js +308 -325
- package/esm/client/7_client_worker.js +16 -29
- package/esm/connection/1_connection_tcp.js +55 -82
- 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.2.0/mux_async_iterator.js +31 -47
- package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
- package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
- package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
- package/esm/session/0_session_state.js +12 -38
- package/esm/session/1_session.js +49 -72
- package/esm/session/2_session_encrypted.js +422 -420
- package/esm/storage/2_storage_indexed_db.js +26 -44
- package/esm/storage/2_storage_local_storage.js +3 -16
- package/esm/storage/2_storage_memory.js +24 -41
- package/esm/storage/2_storage_session_storage.js +3 -16
- package/esm/tl/1_tl_reader.d.ts +1 -1
- package/esm/tl/1_tl_reader.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +95 -103
- package/esm/tl/1_tl_writer.js +169 -178
- 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/utilities/0_mutex.js +4 -19
- package/esm/utilities/0_part_stream.js +11 -25
- package/esm/utilities/1_crypto.js +42 -53
- package/esm/utilities/2_queue.js +29 -47
- package/package.json +1 -1
- package/script/0_errors.d.ts.map +1 -1
- package/script/0_errors.js +9 -31
- package/script/3_errors.js +2 -12
- package/script/4_errors.js +2 -12
- package/script/_dnt.polyfills.d.ts +0 -99
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +0 -128
- package/script/client/0_abortable_loop.js +27 -40
- package/script/client/0_storage_operations.js +179 -218
- package/script/client/1_client_plain.js +4 -22
- package/script/client/2_account_manager.js +140 -149
- 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 +199 -216
- package/script/client/2_file_manager.js +255 -262
- package/script/client/2_network_statistics_manager.js +32 -45
- 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 +102 -112
- package/script/client/2_update_manager.js +750 -745
- package/script/client/3_client_encrypted_pool.js +10 -26
- package/script/client/3_message_manager.js +503 -508
- 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 +140 -146
- package/script/client/4_chat_manager.js +161 -169
- package/script/client/4_checklist_manager.js +26 -39
- package/script/client/4_context.js +244 -259
- package/script/client/4_forum_manager.js +67 -73
- package/script/client/4_gift_manager.js +22 -35
- 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_composer.js +13 -26
- package/script/client/6_client.js +866 -896
- package/script/client/6_client_dispatcher.js +308 -325
- package/script/client/7_client_worker.js +16 -29
- package/script/connection/1_connection_tcp.js +55 -82
- package/script/connection/1_connection_web_socket.js +75 -91
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
- package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
- package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
- package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
- package/script/session/0_session_state.js +12 -38
- package/script/session/1_session.js +49 -72
- package/script/session/2_session_encrypted.js +423 -421
- package/script/storage/2_storage_indexed_db.js +26 -44
- package/script/storage/2_storage_local_storage.js +3 -16
- package/script/storage/2_storage_memory.js +24 -41
- package/script/storage/2_storage_session_storage.js +3 -16
- package/script/tl/1_tl_reader.d.ts +1 -1
- package/script/tl/1_tl_reader.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +96 -104
- package/script/tl/1_tl_writer.js +170 -179
- 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/utilities/0_mutex.js +4 -19
- package/script/utilities/0_part_stream.js +11 -25
- package/script/utilities/1_crypto.js +43 -54
- 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_L, _StorageOperations_maps, _StorageOperations_values, _StorageOperations_addMap, _StorageOperations_addValue, _StorageOperations_lastCommit, _StorageOperations_accountId, _StorageOperations_getUpdateId, _StorageMap_storage, _StorageMap_path, _StorageMap_pendingUpdates, _StorageMap_cache, _StorageValue_storage, _StorageValue_key, _StorageValue_updatePending, _StorageValue_value, _StorageAuth_instances, _StorageAuth_authKeyId, _StorageAuth_resetAuthKeyId;
|
|
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");
|
|
@@ -96,74 +84,54 @@ exports.K = {
|
|
|
96
84
|
},
|
|
97
85
|
};
|
|
98
86
|
class StorageOperations {
|
|
87
|
+
#storage;
|
|
88
|
+
#supportsFiles;
|
|
89
|
+
#mustSerialize;
|
|
90
|
+
#L;
|
|
91
|
+
#maps = new Array();
|
|
92
|
+
#values = new Array();
|
|
93
|
+
auth;
|
|
94
|
+
channelPts;
|
|
95
|
+
peers;
|
|
96
|
+
usernames;
|
|
97
|
+
translations;
|
|
99
98
|
constructor(storage) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
value: void 0
|
|
118
|
-
});
|
|
119
|
-
Object.defineProperty(this, "peers", {
|
|
120
|
-
enumerable: true,
|
|
121
|
-
configurable: true,
|
|
122
|
-
writable: true,
|
|
123
|
-
value: void 0
|
|
124
|
-
});
|
|
125
|
-
Object.defineProperty(this, "usernames", {
|
|
126
|
-
enumerable: true,
|
|
127
|
-
configurable: true,
|
|
128
|
-
writable: true,
|
|
129
|
-
value: void 0
|
|
130
|
-
});
|
|
131
|
-
Object.defineProperty(this, "translations", {
|
|
132
|
-
enumerable: true,
|
|
133
|
-
configurable: true,
|
|
134
|
-
writable: true,
|
|
135
|
-
value: void 0
|
|
136
|
-
});
|
|
137
|
-
_StorageOperations_lastCommit.set(this, null);
|
|
138
|
-
_StorageOperations_accountId.set(this, null);
|
|
139
|
-
__classPrivateFieldSet(this, _StorageOperations_storage, storage, "f");
|
|
140
|
-
__classPrivateFieldSet(this, _StorageOperations_supportsFiles, storage.supportsFiles, "f");
|
|
141
|
-
__classPrivateFieldSet(this, _StorageOperations_mustSerialize, storage.mustSerialize, "f");
|
|
142
|
-
__classPrivateFieldSet(this, _StorageOperations_L, (0, _1_utilities_js_1.getLogger)("StorageOperations"), "f");
|
|
143
|
-
this.auth = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addValue).call(this, new StorageAuth(storage));
|
|
144
|
-
this.channelPts = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "channelPts"));
|
|
145
|
-
this.peers = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "peers"));
|
|
146
|
-
this.usernames = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "usernames"));
|
|
147
|
-
this.translations = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "translations"));
|
|
99
|
+
this.#storage = storage;
|
|
100
|
+
this.#supportsFiles = storage.supportsFiles;
|
|
101
|
+
this.#mustSerialize = storage.mustSerialize;
|
|
102
|
+
this.#L = (0, _1_utilities_js_1.getLogger)("StorageOperations");
|
|
103
|
+
this.auth = this.#addValue(new StorageAuth(storage));
|
|
104
|
+
this.channelPts = this.#addMap(new StorageMap(storage, "channelPts"));
|
|
105
|
+
this.peers = this.#addMap(new StorageMap(storage, "peers"));
|
|
106
|
+
this.usernames = this.#addMap(new StorageMap(storage, "usernames"));
|
|
107
|
+
this.translations = this.#addMap(new StorageMap(storage, "translations"));
|
|
108
|
+
}
|
|
109
|
+
#addMap(map) {
|
|
110
|
+
this.#maps.push(map);
|
|
111
|
+
return map;
|
|
112
|
+
}
|
|
113
|
+
#addValue(value) {
|
|
114
|
+
this.#values.push(value);
|
|
115
|
+
return value;
|
|
148
116
|
}
|
|
149
117
|
get provider() {
|
|
150
|
-
return
|
|
118
|
+
return this.#storage;
|
|
151
119
|
}
|
|
152
120
|
get supportsFiles() {
|
|
153
|
-
return
|
|
121
|
+
return this.#storage.supportsFiles;
|
|
154
122
|
}
|
|
155
123
|
async initialize() {
|
|
156
|
-
await
|
|
124
|
+
await this.#storage.initialize();
|
|
157
125
|
await this.auth.get();
|
|
158
126
|
}
|
|
159
127
|
set(...args) {
|
|
160
|
-
return
|
|
128
|
+
return this.#storage.set(...args);
|
|
161
129
|
}
|
|
162
130
|
incr(...args) {
|
|
163
|
-
return
|
|
131
|
+
return this.#storage.incr(...args);
|
|
164
132
|
}
|
|
165
133
|
get(...args) {
|
|
166
|
-
return
|
|
134
|
+
return this.#storage.get(...args);
|
|
167
135
|
}
|
|
168
136
|
async exportAuthString(apiId_) {
|
|
169
137
|
if (typeof apiId_ === "number") {
|
|
@@ -198,56 +166,57 @@ class StorageOperations {
|
|
|
198
166
|
userId,
|
|
199
167
|
});
|
|
200
168
|
}
|
|
169
|
+
#lastCommit = null;
|
|
201
170
|
async commit(force = false) {
|
|
202
|
-
if (
|
|
171
|
+
if (this.#storage.isMemory) {
|
|
203
172
|
return;
|
|
204
173
|
}
|
|
205
|
-
const pending =
|
|
174
|
+
const pending = this.#values.filter((v) => v.isUpdatePending).length + this.#maps.filter((v) => v.pendingUpdateCount > 0).length;
|
|
206
175
|
if (pending <= 0) {
|
|
207
|
-
|
|
176
|
+
this.#L.debug("nothing to commit");
|
|
208
177
|
return;
|
|
209
178
|
}
|
|
210
179
|
let commit = false;
|
|
211
180
|
if (force) {
|
|
212
|
-
|
|
181
|
+
this.#L.debug("committing because force = true");
|
|
213
182
|
commit = true;
|
|
214
183
|
}
|
|
215
184
|
else {
|
|
216
185
|
if (!commit && pending >= 1_000) {
|
|
217
|
-
|
|
186
|
+
this.#L.debug("committing because pending writes >= threshold");
|
|
218
187
|
commit = true;
|
|
219
188
|
}
|
|
220
|
-
else if (
|
|
221
|
-
|
|
189
|
+
else if (this.#lastCommit === null) {
|
|
190
|
+
this.#L.debug("committing because there is no last commit");
|
|
222
191
|
commit = true;
|
|
223
192
|
}
|
|
224
|
-
else if (Date.now() -
|
|
225
|
-
|
|
193
|
+
else if (Date.now() - this.#lastCommit.getTime() >= 5 * _0_deps_js_1.MINUTE) {
|
|
194
|
+
this.#L.debug("committing because last commit is older than threshold");
|
|
226
195
|
commit = true;
|
|
227
196
|
}
|
|
228
197
|
else {
|
|
229
|
-
|
|
198
|
+
this.#L.debug("not committing");
|
|
230
199
|
}
|
|
231
200
|
}
|
|
232
201
|
if (commit) {
|
|
233
|
-
const values =
|
|
234
|
-
const maps =
|
|
202
|
+
const values = this.#values.filter((v) => v.isUpdatePending).map((v) => v.commit());
|
|
203
|
+
const maps = this.#maps.filter((v) => v.pendingUpdateCount > 0).map((v) => v.commit());
|
|
235
204
|
await Promise.all(values.concat(maps));
|
|
236
|
-
|
|
237
|
-
|
|
205
|
+
this.#L.debug("committed", values.length, "value(s) and", maps.length, "map(s)");
|
|
206
|
+
this.#lastCommit = new Date();
|
|
238
207
|
}
|
|
239
208
|
}
|
|
240
209
|
async setTlObject(key, value) {
|
|
241
210
|
if (value === null) {
|
|
242
|
-
await
|
|
211
|
+
await this.#storage.set(key, null);
|
|
243
212
|
}
|
|
244
213
|
else {
|
|
245
|
-
await
|
|
214
|
+
await this.#storage.set(key, this.#mustSerialize ? [value._, (0, _1_utilities_js_1.rleEncode)(_2_tl_js_1.Api.serializeObject(value))] : value);
|
|
246
215
|
}
|
|
247
216
|
}
|
|
248
217
|
async getTlObject(keyOrBuffer) {
|
|
249
218
|
// @ts-ignore: TBD
|
|
250
|
-
const buffer = (keyOrBuffer instanceof Uint8Array || _2_tl_js_1.Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await
|
|
219
|
+
const buffer = (keyOrBuffer instanceof Uint8Array || _2_tl_js_1.Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await this.#storage.get(keyOrBuffer);
|
|
251
220
|
if (buffer !== null) {
|
|
252
221
|
if (buffer instanceof Uint8Array) {
|
|
253
222
|
return await _2_tl_js_1.Api.deserializeType(_2_tl_js_1.X, (0, _1_utilities_js_1.rleDecode)(buffer));
|
|
@@ -271,19 +240,19 @@ class StorageOperations {
|
|
|
271
240
|
}
|
|
272
241
|
async setMessage(chatId, messageId, message) {
|
|
273
242
|
if (chatId > _1_utilities_js_1.ZERO_CHANNEL_ID) {
|
|
274
|
-
await
|
|
243
|
+
await this.#storage.set(exports.K.messages.messageRef(messageId), message === null ? null : chatId);
|
|
275
244
|
}
|
|
276
245
|
await this.setTlObject(exports.K.messages.message(chatId, messageId), message);
|
|
277
246
|
}
|
|
278
247
|
async deleteMessages() {
|
|
279
248
|
const maybePromises = new Array();
|
|
280
|
-
for await (const [k, o] of await
|
|
281
|
-
maybePromises.push(Promise.all([
|
|
249
|
+
for await (const [k, o] of await this.#storage.getMany({ prefix: exports.K.messages.allMessageRefs() })) {
|
|
250
|
+
maybePromises.push(Promise.all([this.#storage.set(k, null), o === null ? Promise.resolve() : this.#storage.set(exports.K.messages.message(o, k[1]), null)]));
|
|
282
251
|
}
|
|
283
252
|
await Promise.all(maybePromises.filter((v) => v instanceof Promise));
|
|
284
253
|
}
|
|
285
254
|
getMessageChat(messageId) {
|
|
286
|
-
return
|
|
255
|
+
return this.#storage.get(exports.K.messages.messageRef(messageId));
|
|
287
256
|
}
|
|
288
257
|
async getMessage(chatId, messageId) {
|
|
289
258
|
return await this.getTlObject(exports.K.messages.message(chatId, messageId));
|
|
@@ -295,31 +264,32 @@ class StorageOperations {
|
|
|
295
264
|
setPeer2(chatP, accessHash) {
|
|
296
265
|
this.peers.set([chatP.id], [chatP, accessHash]);
|
|
297
266
|
}
|
|
267
|
+
#accountId = null;
|
|
298
268
|
async getAccountId() {
|
|
299
|
-
if (
|
|
300
|
-
return
|
|
269
|
+
if (this.#accountId !== null) {
|
|
270
|
+
return this.#accountId;
|
|
301
271
|
}
|
|
302
272
|
else {
|
|
303
|
-
return
|
|
273
|
+
return this.#accountId = (await this.auth.get())?.userId ?? null;
|
|
304
274
|
}
|
|
305
275
|
}
|
|
306
276
|
async setIsPremium(isPremium) {
|
|
307
|
-
await
|
|
277
|
+
await this.#storage.set(exports.K.auth.isPremium(), isPremium);
|
|
308
278
|
}
|
|
309
279
|
async getIsPremium() {
|
|
310
|
-
return await
|
|
280
|
+
return await this.#storage.get(exports.K.auth.isPremium());
|
|
311
281
|
}
|
|
312
282
|
async updateStickerSetName(id, accessHash, name) {
|
|
313
|
-
await
|
|
283
|
+
await this.#storage.set(exports.K.cache.stickerSetName(id, accessHash), [name, new Date()]);
|
|
314
284
|
}
|
|
315
285
|
getStickerSetName(id, accessHash) {
|
|
316
|
-
return
|
|
286
|
+
return this.#storage.get(exports.K.cache.stickerSetName(id, accessHash));
|
|
317
287
|
}
|
|
318
288
|
async setServerSalt(serverSalt) {
|
|
319
|
-
await
|
|
289
|
+
await this.#storage.set(exports.K.session.serverSalt(), serverSalt);
|
|
320
290
|
}
|
|
321
291
|
getServerSalt() {
|
|
322
|
-
return
|
|
292
|
+
return this.#storage.get(exports.K.session.serverSalt());
|
|
323
293
|
}
|
|
324
294
|
async getHistory(chatId, offsetId, limit) {
|
|
325
295
|
if (offsetId === 0) {
|
|
@@ -327,7 +297,7 @@ class StorageOperations {
|
|
|
327
297
|
}
|
|
328
298
|
++limit;
|
|
329
299
|
const messages = new Array();
|
|
330
|
-
for await (const [_, buffer] of await
|
|
300
|
+
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 })) {
|
|
331
301
|
const message = await this.getTlObject(buffer);
|
|
332
302
|
if ("id" in message && message.id === offsetId) {
|
|
333
303
|
continue;
|
|
@@ -337,18 +307,18 @@ class StorageOperations {
|
|
|
337
307
|
return messages;
|
|
338
308
|
}
|
|
339
309
|
async getFile(id) {
|
|
340
|
-
if (!
|
|
310
|
+
if (!this.#supportsFiles) {
|
|
341
311
|
return null;
|
|
342
312
|
}
|
|
343
|
-
return await
|
|
313
|
+
return await this.#storage.get(exports.K.cache.file(id));
|
|
344
314
|
}
|
|
345
315
|
async *iterFileParts(id, partCount, offset, signal) {
|
|
346
|
-
if (!
|
|
316
|
+
if (!this.#supportsFiles) {
|
|
347
317
|
return;
|
|
348
318
|
}
|
|
349
319
|
for (let i = offset; i < partCount; i++) {
|
|
350
320
|
signal?.throwIfAborted();
|
|
351
|
-
const part = await
|
|
321
|
+
const part = await this.#storage.get(exports.K.cache.filePart(id, i));
|
|
352
322
|
if (part === null) {
|
|
353
323
|
continue;
|
|
354
324
|
}
|
|
@@ -356,22 +326,22 @@ class StorageOperations {
|
|
|
356
326
|
}
|
|
357
327
|
}
|
|
358
328
|
async saveFilePart(id, index, bytes) {
|
|
359
|
-
if (!
|
|
329
|
+
if (!this.#supportsFiles) {
|
|
360
330
|
return;
|
|
361
331
|
}
|
|
362
|
-
await
|
|
332
|
+
await this.#storage.set(exports.K.cache.filePart(id, index), bytes);
|
|
363
333
|
}
|
|
364
334
|
async setFilePartCount(id, partCount, chunkSize) {
|
|
365
|
-
if (!
|
|
335
|
+
if (!this.#supportsFiles) {
|
|
366
336
|
return;
|
|
367
337
|
}
|
|
368
|
-
await
|
|
338
|
+
await this.#storage.set(exports.K.cache.file(id), [partCount, chunkSize]);
|
|
369
339
|
}
|
|
370
340
|
async setCustomEmojiDocument(id, document) {
|
|
371
|
-
await
|
|
341
|
+
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()]);
|
|
372
342
|
}
|
|
373
343
|
async getCustomEmojiDocument(id) {
|
|
374
|
-
const v = await
|
|
344
|
+
const v = await this.#storage.get(exports.K.cache.customEmojiDocument(id));
|
|
375
345
|
if (v !== null) {
|
|
376
346
|
return [await this.getTlObject(v[0]), v[1]];
|
|
377
347
|
}
|
|
@@ -380,10 +350,10 @@ class StorageOperations {
|
|
|
380
350
|
}
|
|
381
351
|
}
|
|
382
352
|
async setBusinessConnection(id, connection) {
|
|
383
|
-
await
|
|
353
|
+
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);
|
|
384
354
|
}
|
|
385
355
|
async getBusinessConnection(id) {
|
|
386
|
-
const v = await
|
|
356
|
+
const v = await this.#storage.get(exports.K.cache.businessConnection(id));
|
|
387
357
|
if (v !== null) {
|
|
388
358
|
return await this.getTlObject(v);
|
|
389
359
|
}
|
|
@@ -392,10 +362,10 @@ class StorageOperations {
|
|
|
392
362
|
}
|
|
393
363
|
}
|
|
394
364
|
async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
|
|
395
|
-
await
|
|
365
|
+
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]);
|
|
396
366
|
}
|
|
397
367
|
async getInlineQueryAnswer(userId, chatId, query, offset) {
|
|
398
|
-
const peer_ = await
|
|
368
|
+
const peer_ = await this.#storage.get(exports.K.cache.inlineQueryAnswer(userId, chatId, query, offset));
|
|
399
369
|
if (peer_ !== null) {
|
|
400
370
|
const [obj_, date] = peer_;
|
|
401
371
|
return [_2_tl_js_1.Api.as("messages.botResults", await this.getTlObject(obj_)), date];
|
|
@@ -405,10 +375,10 @@ class StorageOperations {
|
|
|
405
375
|
}
|
|
406
376
|
}
|
|
407
377
|
async setCallbackQueryAnswer(chatId, messageId, question, answer) {
|
|
408
|
-
await
|
|
378
|
+
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()]);
|
|
409
379
|
}
|
|
410
380
|
async getCallbackQueryAnswer(chatId, messageId, question) {
|
|
411
|
-
const peer_ = await
|
|
381
|
+
const peer_ = await this.#storage.get(exports.K.cache.callbackQueryAnswer(chatId, messageId, question));
|
|
412
382
|
if (peer_ !== null) {
|
|
413
383
|
const [obj_, date] = peer_;
|
|
414
384
|
return [_2_tl_js_1.Api.as("messages.botCallbackAnswer", await this.getTlObject(obj_)), date];
|
|
@@ -430,23 +400,33 @@ class StorageOperations {
|
|
|
430
400
|
return await this.getTlObject(exports.K.cache.groupCall(id));
|
|
431
401
|
}
|
|
432
402
|
async setGroupCallAccessHash(id, accessHash) {
|
|
433
|
-
await
|
|
403
|
+
await this.#storage.set(exports.K.cache.groupCallAccessHash(id), accessHash);
|
|
434
404
|
}
|
|
435
405
|
async getGroupCallAccessHash(id) {
|
|
436
|
-
return await
|
|
406
|
+
return await this.#storage.get(exports.K.cache.groupCallAccessHash(id));
|
|
407
|
+
}
|
|
408
|
+
#getUpdateId(update) {
|
|
409
|
+
let id = BigInt(Date.now()) << 32n;
|
|
410
|
+
if ("pts" in update && update.pts) {
|
|
411
|
+
id |= BigInt(update.pts);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
id |= BigInt(0xffffffffn);
|
|
415
|
+
}
|
|
416
|
+
return id;
|
|
437
417
|
}
|
|
438
418
|
async setUpdate(boxId, update) {
|
|
439
|
-
await this.setTlObject(exports.K.updates.update(boxId,
|
|
419
|
+
await this.setTlObject(exports.K.updates.update(boxId, this.#getUpdateId(update)), update);
|
|
440
420
|
}
|
|
441
421
|
async deleteUpdates() {
|
|
442
422
|
const maybePromises = new Array();
|
|
443
|
-
for await (const [k] of await
|
|
444
|
-
maybePromises.push(
|
|
423
|
+
for await (const [k] of await this.#storage.getMany({ prefix: exports.K.updates.all() })) {
|
|
424
|
+
maybePromises.push(this.#storage.set(k, null));
|
|
445
425
|
}
|
|
446
426
|
await Promise.all(maybePromises.filter((v) => v instanceof Promise));
|
|
447
427
|
}
|
|
448
428
|
async getFirstUpdate(boxId) {
|
|
449
|
-
for await (const [key, update] of await
|
|
429
|
+
for await (const [key, update] of await this.#storage.getMany({ prefix: exports.K.updates.updates(boxId) }, { limit: 1 })) {
|
|
450
430
|
return [key, (await this.getTlObject(update))];
|
|
451
431
|
}
|
|
452
432
|
return null;
|
|
@@ -485,49 +465,49 @@ class StorageOperations {
|
|
|
485
465
|
}
|
|
486
466
|
}
|
|
487
467
|
async deleteFiles() {
|
|
488
|
-
if (!
|
|
468
|
+
if (!this.#supportsFiles) {
|
|
489
469
|
return;
|
|
490
470
|
}
|
|
491
|
-
for await (const [key] of await
|
|
492
|
-
await
|
|
471
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.fileParts() })) {
|
|
472
|
+
await this.#storage.set(key, null);
|
|
493
473
|
}
|
|
494
|
-
for await (const [key] of await
|
|
495
|
-
await
|
|
474
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.files() })) {
|
|
475
|
+
await this.#storage.set(key, null);
|
|
496
476
|
}
|
|
497
477
|
}
|
|
498
478
|
async deleteCustomEmojiDocuments() {
|
|
499
|
-
for await (const [key] of await
|
|
500
|
-
await
|
|
479
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.customEmojiDocuments() })) {
|
|
480
|
+
await this.#storage.set(key, null);
|
|
501
481
|
}
|
|
502
482
|
}
|
|
503
483
|
async deleteBusinessConnections() {
|
|
504
|
-
for await (const [key] of await
|
|
505
|
-
await
|
|
484
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.businessConnections() })) {
|
|
485
|
+
await this.#storage.set(key, null);
|
|
506
486
|
}
|
|
507
487
|
}
|
|
508
488
|
async deleteInlineQueryAnswers() {
|
|
509
|
-
for await (const [key] of await
|
|
510
|
-
await
|
|
489
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.inlineQueryAnswers() })) {
|
|
490
|
+
await this.#storage.set(key, null);
|
|
511
491
|
}
|
|
512
492
|
}
|
|
513
493
|
async deleteCallbackQueryAnswers() {
|
|
514
|
-
for await (const [key] of await
|
|
515
|
-
await
|
|
494
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.callbackQueryAnswers() })) {
|
|
495
|
+
await this.#storage.set(key, null);
|
|
516
496
|
}
|
|
517
497
|
}
|
|
518
498
|
async deleteFullChats() {
|
|
519
|
-
for await (const [key] of await
|
|
520
|
-
await
|
|
499
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.fullChats() })) {
|
|
500
|
+
await this.#storage.set(key, null);
|
|
521
501
|
}
|
|
522
502
|
}
|
|
523
503
|
async deleteGroupCalls() {
|
|
524
|
-
for await (const [key] of await
|
|
525
|
-
await
|
|
504
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.groupCalls() })) {
|
|
505
|
+
await this.#storage.set(key, null);
|
|
526
506
|
}
|
|
527
507
|
}
|
|
528
508
|
async deleteStickerSetNames() {
|
|
529
|
-
for await (const [key] of await
|
|
530
|
-
await
|
|
509
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.stickerSetNames() })) {
|
|
510
|
+
await this.#storage.set(key, null);
|
|
531
511
|
}
|
|
532
512
|
}
|
|
533
513
|
async clear() {
|
|
@@ -552,8 +532,8 @@ class StorageOperations {
|
|
|
552
532
|
]);
|
|
553
533
|
}
|
|
554
534
|
async reset() {
|
|
555
|
-
for await (const [key] of await
|
|
556
|
-
await
|
|
535
|
+
for await (const [key] of await this.#storage.getMany({ prefix: [] })) {
|
|
536
|
+
await this.#storage.set(key, null);
|
|
557
537
|
}
|
|
558
538
|
}
|
|
559
539
|
async setPollResults(pollId, pollResults) {
|
|
@@ -564,8 +544,8 @@ class StorageOperations {
|
|
|
564
544
|
}
|
|
565
545
|
async deletePollResults() {
|
|
566
546
|
const maybePromises = new Array();
|
|
567
|
-
for await (const [key] of await
|
|
568
|
-
maybePromises.push(
|
|
547
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.pollResults() })) {
|
|
548
|
+
maybePromises.push(this.#storage.set(key, null));
|
|
569
549
|
}
|
|
570
550
|
await Promise.all(maybePromises);
|
|
571
551
|
}
|
|
@@ -577,76 +557,60 @@ class StorageOperations {
|
|
|
577
557
|
}
|
|
578
558
|
async deletePolls() {
|
|
579
559
|
const maybePromises = new Array();
|
|
580
|
-
for await (const [key] of await
|
|
581
|
-
maybePromises.push(
|
|
560
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.polls() })) {
|
|
561
|
+
maybePromises.push(this.#storage.set(key, null));
|
|
582
562
|
}
|
|
583
563
|
await Promise.all(maybePromises);
|
|
584
564
|
}
|
|
585
565
|
async setVoiceTranscription(voiceTranscription) {
|
|
586
|
-
await
|
|
566
|
+
await this.#storage.set(exports.K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
|
|
587
567
|
}
|
|
588
568
|
async getVoiceTranscription(transcriptionId) {
|
|
589
|
-
return await
|
|
569
|
+
return await this.#storage.get(exports.K.cache.voiceTranscription(transcriptionId));
|
|
590
570
|
}
|
|
591
571
|
async deleteVoiceTranscriptions() {
|
|
592
572
|
const maybePromises = new Array();
|
|
593
|
-
for await (const [key] of await
|
|
594
|
-
maybePromises.push(
|
|
573
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
|
|
574
|
+
maybePromises.push(this.#storage.set(key, null));
|
|
595
575
|
}
|
|
596
576
|
await Promise.all(maybePromises);
|
|
597
577
|
}
|
|
598
578
|
async setVoiceTranscriptionReference(chatId, messageId, messageEditDate, transcriptionId) {
|
|
599
|
-
await
|
|
579
|
+
await this.#storage.set(exports.K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
|
|
600
580
|
}
|
|
601
581
|
async getVoiceTranscriptionReference(chatId, messageId, messageEditDate) {
|
|
602
|
-
return await
|
|
582
|
+
return await this.#storage.get(exports.K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
|
|
603
583
|
}
|
|
604
584
|
async deleteVoiceTranscriptionReferences() {
|
|
605
585
|
const maybePromises = new Array();
|
|
606
|
-
for await (const [key] of await
|
|
607
|
-
maybePromises.push(
|
|
586
|
+
for await (const [key] of await this.#storage.getMany({ prefix: exports.K.cache.voiceTranscriptions() })) {
|
|
587
|
+
maybePromises.push(this.#storage.set(key, null));
|
|
608
588
|
}
|
|
609
589
|
await Promise.all(maybePromises);
|
|
610
590
|
}
|
|
611
591
|
}
|
|
612
592
|
exports.StorageOperations = StorageOperations;
|
|
613
|
-
_StorageOperations_storage = new WeakMap(), _StorageOperations_supportsFiles = new WeakMap(), _StorageOperations_mustSerialize = new WeakMap(), _StorageOperations_L = new WeakMap(), _StorageOperations_maps = new WeakMap(), _StorageOperations_values = new WeakMap(), _StorageOperations_lastCommit = new WeakMap(), _StorageOperations_accountId = new WeakMap(), _StorageOperations_instances = new WeakSet(), _StorageOperations_addMap = function _StorageOperations_addMap(map) {
|
|
614
|
-
__classPrivateFieldGet(this, _StorageOperations_maps, "f").push(map);
|
|
615
|
-
return map;
|
|
616
|
-
}, _StorageOperations_addValue = function _StorageOperations_addValue(value) {
|
|
617
|
-
__classPrivateFieldGet(this, _StorageOperations_values, "f").push(value);
|
|
618
|
-
return value;
|
|
619
|
-
}, _StorageOperations_getUpdateId = function _StorageOperations_getUpdateId(update) {
|
|
620
|
-
let id = BigInt(Date.now()) << 32n;
|
|
621
|
-
if ("pts" in update && update.pts) {
|
|
622
|
-
id |= BigInt(update.pts);
|
|
623
|
-
}
|
|
624
|
-
else {
|
|
625
|
-
id |= BigInt(0xffffffffn);
|
|
626
|
-
}
|
|
627
|
-
return id;
|
|
628
|
-
};
|
|
629
593
|
class StorageMap {
|
|
594
|
+
#storage;
|
|
595
|
+
#path;
|
|
630
596
|
constructor(storage, path) {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
_StorageMap_pendingUpdates.set(this, new Map());
|
|
634
|
-
_StorageMap_cache.set(this, new _0_deps_js_2.LruCache(20_000));
|
|
635
|
-
__classPrivateFieldSet(this, _StorageMap_storage, storage, "f");
|
|
636
|
-
__classPrivateFieldSet(this, _StorageMap_path, path, "f");
|
|
597
|
+
this.#storage = storage;
|
|
598
|
+
this.#path = path;
|
|
637
599
|
}
|
|
600
|
+
#pendingUpdates = new Map();
|
|
601
|
+
#cache = new _0_deps_js_2.LruCache(20_000);
|
|
638
602
|
set(key, value) {
|
|
639
603
|
const key_ = (0, _2_storage_js_1.toString)(key);
|
|
640
|
-
|
|
641
|
-
if (!
|
|
642
|
-
|
|
604
|
+
this.#cache.set(key_, value);
|
|
605
|
+
if (!this.#storage.isMemory) {
|
|
606
|
+
this.#pendingUpdates.set(key_, value);
|
|
643
607
|
}
|
|
644
608
|
}
|
|
645
609
|
get pendingUpdateCount() {
|
|
646
|
-
return
|
|
610
|
+
return this.#pendingUpdates.size;
|
|
647
611
|
}
|
|
648
612
|
mustGet(key) {
|
|
649
|
-
const value =
|
|
613
|
+
const value = this.#cache.get((0, _2_storage_js_1.toString)(key));
|
|
650
614
|
if (value === undefined) {
|
|
651
615
|
(0, _0_deps_js_2.unreachable)();
|
|
652
616
|
}
|
|
@@ -655,71 +619,67 @@ class StorageMap {
|
|
|
655
619
|
}
|
|
656
620
|
}
|
|
657
621
|
async clear() {
|
|
658
|
-
await (0, _1_utilities_js_2.awaitablePooledMap)(10, await
|
|
622
|
+
await (0, _1_utilities_js_2.awaitablePooledMap)(10, await this.#storage.getMany({ prefix: [this.#path] }), async ([key]) => await this.#storage.set(key, null));
|
|
659
623
|
}
|
|
660
624
|
async get(key) {
|
|
661
625
|
const key_ = (0, _2_storage_js_1.toString)(key);
|
|
662
|
-
let value =
|
|
626
|
+
let value = this.#cache.get(key_);
|
|
663
627
|
if (value === undefined) {
|
|
664
|
-
value = await
|
|
665
|
-
|
|
628
|
+
value = await this.#storage.get([this.#path, ...key]);
|
|
629
|
+
this.#cache.set(key_, value);
|
|
666
630
|
}
|
|
667
631
|
return value;
|
|
668
632
|
}
|
|
669
633
|
async commit() {
|
|
670
|
-
if (
|
|
634
|
+
if (this.#storage.isMemory) {
|
|
671
635
|
return;
|
|
672
636
|
}
|
|
673
|
-
await (0, _1_utilities_js_2.awaitablePooledMap)(2,
|
|
674
|
-
|
|
637
|
+
await (0, _1_utilities_js_2.awaitablePooledMap)(2, this.#pendingUpdates, async ([key, value]) => await this.#storage.set([this.#path, ...(0, _2_storage_js_1.fromString)(key)], value));
|
|
638
|
+
this.#pendingUpdates.clear();
|
|
675
639
|
}
|
|
676
640
|
}
|
|
677
|
-
_StorageMap_storage = new WeakMap(), _StorageMap_path = new WeakMap(), _StorageMap_pendingUpdates = new WeakMap(), _StorageMap_cache = new WeakMap();
|
|
678
641
|
class StorageValue {
|
|
642
|
+
#storage;
|
|
643
|
+
#key;
|
|
679
644
|
constructor(storage, path) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
_StorageValue_updatePending.set(this, false);
|
|
683
|
-
_StorageValue_value.set(this, void 0);
|
|
684
|
-
__classPrivateFieldSet(this, _StorageValue_storage, storage, "f");
|
|
685
|
-
__classPrivateFieldSet(this, _StorageValue_key, [path], "f");
|
|
645
|
+
this.#storage = storage;
|
|
646
|
+
this.#key = [path];
|
|
686
647
|
}
|
|
648
|
+
#updatePending = false;
|
|
649
|
+
#value;
|
|
687
650
|
set(value) {
|
|
688
|
-
|
|
689
|
-
if (!
|
|
690
|
-
|
|
651
|
+
this.#value = value;
|
|
652
|
+
if (!this.#storage.isMemory) {
|
|
653
|
+
this.#updatePending = true;
|
|
691
654
|
}
|
|
692
655
|
}
|
|
693
656
|
get isUpdatePending() {
|
|
694
|
-
return
|
|
657
|
+
return this.#updatePending;
|
|
695
658
|
}
|
|
696
659
|
mustGet() {
|
|
697
|
-
return
|
|
660
|
+
return this.#value === undefined ? (0, _0_deps_js_2.unreachable)() : this.#value;
|
|
698
661
|
}
|
|
699
662
|
async get() {
|
|
700
|
-
if (
|
|
701
|
-
|
|
663
|
+
if (this.#value === undefined) {
|
|
664
|
+
this.#value = await this.#storage.get(this.#key);
|
|
702
665
|
}
|
|
703
|
-
return
|
|
666
|
+
return this.#value;
|
|
704
667
|
}
|
|
705
668
|
async commit() {
|
|
706
|
-
if (
|
|
669
|
+
if (this.#storage.isMemory || this.#value === undefined) {
|
|
707
670
|
return;
|
|
708
671
|
}
|
|
709
|
-
await
|
|
710
|
-
|
|
672
|
+
await this.#storage.set(this.#key, this.#value);
|
|
673
|
+
this.#updatePending = false;
|
|
711
674
|
}
|
|
712
675
|
}
|
|
713
|
-
_StorageValue_storage = new WeakMap(), _StorageValue_key = new WeakMap(), _StorageValue_updatePending = new WeakMap(), _StorageValue_value = new WeakMap();
|
|
714
676
|
class StorageAuth extends StorageValue {
|
|
715
677
|
constructor(storage) {
|
|
716
678
|
super(storage, "auth");
|
|
717
|
-
_StorageAuth_instances.add(this);
|
|
718
|
-
_StorageAuth_authKeyId.set(this, null);
|
|
719
679
|
}
|
|
720
680
|
async get() {
|
|
721
681
|
const value = await super.get();
|
|
722
|
-
await
|
|
682
|
+
await this.#resetAuthKeyId(value);
|
|
723
683
|
return value;
|
|
724
684
|
}
|
|
725
685
|
mustGet() {
|
|
@@ -733,22 +693,23 @@ class StorageAuth extends StorageValue {
|
|
|
733
693
|
}
|
|
734
694
|
async set(auth) {
|
|
735
695
|
super.set(auth);
|
|
736
|
-
await
|
|
696
|
+
await this.#resetAuthKeyId(auth);
|
|
737
697
|
}
|
|
738
698
|
async update(fn) {
|
|
739
699
|
const auth = this.mustGet();
|
|
740
700
|
fn(auth);
|
|
741
701
|
await this.set(auth);
|
|
742
702
|
}
|
|
703
|
+
#authKeyId = null;
|
|
704
|
+
async #resetAuthKeyId(auth) {
|
|
705
|
+
if (auth?.authKey) {
|
|
706
|
+
this.#authKeyId = (0, _1_utilities_js_1.intFromBytes)((await (0, _1_utilities_js_1.sha1)(auth.authKey)).subarray(-8));
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
this.#authKeyId = null;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
743
712
|
get authKeyId() {
|
|
744
|
-
return
|
|
713
|
+
return this.#authKeyId;
|
|
745
714
|
}
|
|
746
715
|
}
|
|
747
|
-
_StorageAuth_authKeyId = new WeakMap(), _StorageAuth_instances = new WeakSet(), _StorageAuth_resetAuthKeyId = async function _StorageAuth_resetAuthKeyId(auth) {
|
|
748
|
-
if (auth?.authKey) {
|
|
749
|
-
__classPrivateFieldSet(this, _StorageAuth_authKeyId, (0, _1_utilities_js_1.intFromBytes)((await (0, _1_utilities_js_1.sha1)(auth.authKey)).subarray(-8)), "f");
|
|
750
|
-
}
|
|
751
|
-
else {
|
|
752
|
-
__classPrivateFieldSet(this, _StorageAuth_authKeyId, null, "f");
|
|
753
|
-
}
|
|
754
|
-
};
|