@mtkruto/browser 0.119.0 → 0.119.1
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.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
|
@@ -17,49 +17,35 @@
|
|
|
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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
21
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
22
|
-
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");
|
|
23
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
24
|
-
};
|
|
25
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
-
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");
|
|
29
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
-
};
|
|
31
|
-
var _PartStream_buffer, _PartStream_totalRead, _PartStream_part;
|
|
32
20
|
import { concat } from "../0_deps.js";
|
|
33
21
|
export class PartStream extends TransformStream {
|
|
22
|
+
#buffer = new Uint8Array();
|
|
23
|
+
#totalRead = 0;
|
|
24
|
+
#part = 0;
|
|
34
25
|
constructor(chunkSize) {
|
|
35
26
|
super({
|
|
36
27
|
transform: (chunk, controller) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
chunk = concat([__classPrivateFieldGet(this, _PartStream_buffer, "f"), chunk]);
|
|
28
|
+
this.#totalRead += chunk.byteLength;
|
|
29
|
+
chunk = concat([this.#buffer, chunk]);
|
|
40
30
|
while (chunk.byteLength > chunkSize) {
|
|
41
31
|
controller.enqueue({
|
|
42
32
|
isSmall: false,
|
|
43
|
-
part:
|
|
33
|
+
part: this.#part++,
|
|
44
34
|
totalParts: -1,
|
|
45
35
|
bytes: chunk.slice(0, chunkSize),
|
|
46
36
|
});
|
|
47
37
|
chunk = chunk.slice(chunkSize);
|
|
48
38
|
}
|
|
49
|
-
|
|
39
|
+
this.#buffer = chunk;
|
|
50
40
|
},
|
|
51
41
|
flush: (controller) => {
|
|
52
42
|
controller.enqueue({
|
|
53
|
-
isSmall:
|
|
54
|
-
part:
|
|
55
|
-
totalParts: Math.ceil(
|
|
56
|
-
bytes:
|
|
43
|
+
isSmall: this.#totalRead <= chunkSize,
|
|
44
|
+
part: this.#part,
|
|
45
|
+
totalParts: Math.ceil(this.#totalRead / chunkSize),
|
|
46
|
+
bytes: this.#buffer,
|
|
57
47
|
});
|
|
58
48
|
},
|
|
59
49
|
});
|
|
60
|
-
_PartStream_buffer.set(this, new Uint8Array());
|
|
61
|
-
_PartStream_totalRead.set(this, 0);
|
|
62
|
-
_PartStream_part.set(this, 0);
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
|
-
_PartStream_buffer = new WeakMap(), _PartStream_totalRead = new WeakMap(), _PartStream_part = new WeakMap();
|
|
@@ -17,74 +17,63 @@
|
|
|
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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
21
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
22
|
-
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");
|
|
23
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
24
|
-
};
|
|
25
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
26
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
27
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
28
|
-
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");
|
|
29
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
30
|
-
};
|
|
31
|
-
var _CTR_instances, _CTR_key, _CTR_iv, _CTR_bytesUntilNextBlock, _CTR_promise, _CTR_call, _CTR_encrypt, _CTR_increaseIv;
|
|
32
20
|
import { concat } from "../0_deps.js";
|
|
33
21
|
import { intFromBytes, intToBytes } from "./0_int.js";
|
|
34
22
|
export class CTR {
|
|
23
|
+
#key;
|
|
24
|
+
#iv;
|
|
25
|
+
#bytesUntilNextBlock = 0;
|
|
26
|
+
#promise;
|
|
35
27
|
get _state() {
|
|
36
|
-
return { iv: new Uint8Array(
|
|
28
|
+
return { iv: new Uint8Array(this.#iv), state: this.#bytesUntilNextBlock };
|
|
37
29
|
}
|
|
38
30
|
constructor(key, iv) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
_CTR_iv.set(this, void 0);
|
|
42
|
-
_CTR_bytesUntilNextBlock.set(this, 0);
|
|
43
|
-
_CTR_promise.set(this, void 0);
|
|
44
|
-
__classPrivateFieldSet(this, _CTR_key, key, "f");
|
|
45
|
-
__classPrivateFieldSet(this, _CTR_iv, iv, "f");
|
|
31
|
+
this.#key = key;
|
|
32
|
+
this.#iv = iv;
|
|
46
33
|
}
|
|
47
34
|
static async importKey(key) {
|
|
48
35
|
return await crypto.subtle.importKey("raw", key, "AES-CTR", false, ["encrypt"]);
|
|
49
36
|
}
|
|
50
37
|
async call(data) {
|
|
51
|
-
if (
|
|
52
|
-
await Promise.allSettled([
|
|
38
|
+
if (this.#promise) {
|
|
39
|
+
await Promise.allSettled([this.#promise]);
|
|
53
40
|
}
|
|
54
|
-
return await (
|
|
41
|
+
return await (this.#promise = this.#call(data));
|
|
55
42
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
43
|
+
async #call(data) {
|
|
44
|
+
let header;
|
|
45
|
+
if (this.#bytesUntilNextBlock) {
|
|
46
|
+
const headerLength = Math.min(data.length, this.#iv.length - this.#bytesUntilNextBlock);
|
|
47
|
+
const encrypted = await this.#encrypt(concat([new Uint8Array(this.#bytesUntilNextBlock), data.subarray(0, headerLength)]));
|
|
48
|
+
header = encrypted.subarray(this.#bytesUntilNextBlock);
|
|
49
|
+
data = data.subarray(headerLength);
|
|
50
|
+
if (encrypted.length === this.#iv.length) {
|
|
51
|
+
this.#increaseIv(1);
|
|
52
|
+
this.#bytesUntilNextBlock = 0;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.#bytesUntilNextBlock += headerLength;
|
|
56
|
+
}
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
if (!data.length && header) {
|
|
59
|
+
return header;
|
|
70
60
|
}
|
|
61
|
+
const encrypted = await this.#encrypt(data);
|
|
62
|
+
this.#bytesUntilNextBlock = encrypted.length % this.#iv.length;
|
|
63
|
+
this.#increaseIv((encrypted.length - this.#bytesUntilNextBlock) / this.#iv.length);
|
|
64
|
+
return header ? concat([header, encrypted]) : encrypted;
|
|
71
65
|
}
|
|
72
|
-
|
|
73
|
-
return
|
|
66
|
+
async #encrypt(data) {
|
|
67
|
+
return new Uint8Array(await crypto.subtle.encrypt({
|
|
68
|
+
name: "AES-CTR",
|
|
69
|
+
counter: new Uint8Array(this.#iv),
|
|
70
|
+
length: this.#iv.length * 8,
|
|
71
|
+
}, this.#key, data));
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return new Uint8Array(await crypto.subtle.encrypt({
|
|
81
|
-
name: "AES-CTR",
|
|
82
|
-
counter: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")),
|
|
83
|
-
length: __classPrivateFieldGet(this, _CTR_iv, "f").length * 8,
|
|
84
|
-
}, __classPrivateFieldGet(this, _CTR_key, "f"), data));
|
|
85
|
-
}, _CTR_increaseIv = function _CTR_increaseIv(amount) {
|
|
86
|
-
if (amount < 1) {
|
|
87
|
-
return;
|
|
73
|
+
#increaseIv(amount) {
|
|
74
|
+
if (amount < 1) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.#iv = intToBytes(intFromBytes(this.#iv, { byteOrder: "big", isSigned: false }) + BigInt(amount), this.#iv.length, { byteOrder: "big", isSigned: false });
|
|
88
78
|
}
|
|
89
|
-
|
|
90
|
-
};
|
|
79
|
+
}
|
package/esm/utilities/2_queue.js
CHANGED
|
@@ -17,60 +17,42 @@
|
|
|
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 _Queue_instances, _Queue_logger, _Queue_throw, _Queue_busy, _Queue_check;
|
|
32
20
|
import { getLogger } from "./1_logger.js";
|
|
33
21
|
export class Queue {
|
|
22
|
+
#logger;
|
|
23
|
+
functions = new Array();
|
|
24
|
+
#throw;
|
|
34
25
|
constructor(name, throw_ = false) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Object.defineProperty(this, "functions", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
configurable: true,
|
|
40
|
-
writable: true,
|
|
41
|
-
value: new Array()
|
|
42
|
-
});
|
|
43
|
-
_Queue_throw.set(this, void 0);
|
|
44
|
-
_Queue_busy.set(this, false);
|
|
45
|
-
__classPrivateFieldSet(this, _Queue_logger, getLogger(`q/${name}`), "f");
|
|
46
|
-
__classPrivateFieldSet(this, _Queue_throw, throw_, "f");
|
|
26
|
+
this.#logger = getLogger(`q/${name}`);
|
|
27
|
+
this.#throw = throw_;
|
|
47
28
|
}
|
|
48
29
|
add(fn) {
|
|
49
30
|
this.functions.push(fn);
|
|
50
|
-
|
|
31
|
+
this.#check();
|
|
51
32
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
if (!__classPrivateFieldGet(this, _Queue_throw, "f")) {
|
|
68
|
-
promise.catch((err) => {
|
|
69
|
-
__classPrivateFieldGet(this, _Queue_logger, "f").error((typeof err === "object" && err !== null && "stack" in err) ? err.stack : err);
|
|
33
|
+
#busy = false;
|
|
34
|
+
#check() {
|
|
35
|
+
if (this.#busy) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.#busy = true;
|
|
40
|
+
}
|
|
41
|
+
const fn = this.functions.shift();
|
|
42
|
+
if (fn !== undefined) {
|
|
43
|
+
const promise = fn()
|
|
44
|
+
.finally(() => {
|
|
45
|
+
this.#busy = false;
|
|
46
|
+
this.#check();
|
|
70
47
|
});
|
|
48
|
+
if (!this.#throw) {
|
|
49
|
+
promise.catch((err) => {
|
|
50
|
+
this.#logger.error((typeof err === "object" && err !== null && "stack" in err) ? err.stack : err);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.#busy = false;
|
|
71
56
|
}
|
|
72
57
|
}
|
|
73
|
-
|
|
74
|
-
__classPrivateFieldSet(this, _Queue_busy, false, "f");
|
|
75
|
-
}
|
|
76
|
-
};
|
|
58
|
+
}
|
package/package.json
CHANGED
package/script/0_errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_errors.d.ts","sourceRoot":"","sources":["../src/0_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8BAAsB,YAAa,SAAQ,KAAK;CAC/C;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,cAAe,SAAQ,YAAY;
|
|
1
|
+
{"version":3,"file":"0_errors.d.ts","sourceRoot":"","sources":["../src/0_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8BAAsB,YAAa,SAAQ,KAAK;CAC/C;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,MAAM;CAKzB;AAED,qBAAa,OAAQ,SAAQ,YAAY;;IAC9B,IAAI,SAAa;gBAId,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAM3C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;CACF"}
|
package/script/0_errors.js
CHANGED
|
@@ -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 _TLError_originalMessage, _TLError_path;
|
|
33
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
22
|
exports.TLError = exports.TransportError = exports.InputError = exports.AccessError = exports.ConnectionError = exports.MtkrutoError = void 0;
|
|
35
23
|
class MtkrutoError extends Error {
|
|
@@ -57,38 +45,28 @@ class InputError extends MtkrutoError {
|
|
|
57
45
|
}
|
|
58
46
|
exports.InputError = InputError;
|
|
59
47
|
class TransportError extends MtkrutoError {
|
|
48
|
+
code;
|
|
60
49
|
constructor(code) {
|
|
61
50
|
super(`Transport error: ${code}`);
|
|
62
|
-
Object.defineProperty(this, "code", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: code
|
|
67
|
-
});
|
|
68
51
|
this.name = "TransportError";
|
|
52
|
+
this.code = code;
|
|
69
53
|
}
|
|
70
54
|
}
|
|
71
55
|
exports.TransportError = TransportError;
|
|
72
56
|
class TLError extends MtkrutoError {
|
|
57
|
+
name = "TLError";
|
|
58
|
+
#originalMessage;
|
|
59
|
+
#path;
|
|
73
60
|
constructor(message, path) {
|
|
74
61
|
super(`${message}${path.length ? ` at ${path.join(" ")}` : ""}`);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
configurable: true,
|
|
78
|
-
writable: true,
|
|
79
|
-
value: "TLError"
|
|
80
|
-
});
|
|
81
|
-
_TLError_originalMessage.set(this, void 0);
|
|
82
|
-
_TLError_path.set(this, void 0);
|
|
83
|
-
__classPrivateFieldSet(this, _TLError_originalMessage, message, "f");
|
|
84
|
-
__classPrivateFieldSet(this, _TLError_path, path, "f");
|
|
62
|
+
this.#originalMessage = message;
|
|
63
|
+
this.#path = path;
|
|
85
64
|
}
|
|
86
65
|
get originalMessage() {
|
|
87
|
-
return
|
|
66
|
+
return this.#originalMessage;
|
|
88
67
|
}
|
|
89
68
|
get path() {
|
|
90
|
-
return
|
|
69
|
+
return this.#path;
|
|
91
70
|
}
|
|
92
71
|
}
|
|
93
72
|
exports.TLError = TLError;
|
|
94
|
-
_TLError_originalMessage = new WeakMap(), _TLError_path = new WeakMap();
|
package/script/3_errors.js
CHANGED
|
@@ -48,20 +48,10 @@ const _0_errors_js_1 = require("./0_errors.js");
|
|
|
48
48
|
const _2_tl_js_1 = require("./2_tl.js");
|
|
49
49
|
__exportStar(require("./0_errors.js"), exports);
|
|
50
50
|
class TelegramError extends _0_errors_js_1.MtkrutoError {
|
|
51
|
+
errorCode;
|
|
52
|
+
errorMessage;
|
|
51
53
|
constructor(params) {
|
|
52
54
|
super(`${params.error_code}: ${params.error_message} (${(0, _2_tl_js_1.repr)(params.call)})`);
|
|
53
|
-
Object.defineProperty(this, "errorCode", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "errorMessage", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
55
|
this.name = "TelegramError";
|
|
66
56
|
this.errorCode = params.error_code;
|
|
67
57
|
this.errorMessage = params.error_message;
|
package/script/4_errors.js
CHANGED
|
@@ -39,14 +39,9 @@ const _0_deps_js_1 = require("./0_deps.js");
|
|
|
39
39
|
const _3_errors_js_1 = require("./3_errors.js");
|
|
40
40
|
__exportStar(require("./3_errors.js"), exports);
|
|
41
41
|
class FloodWait extends _3_errors_js_1.TelegramError {
|
|
42
|
+
seconds;
|
|
42
43
|
constructor(params) {
|
|
43
44
|
super(params);
|
|
44
|
-
Object.defineProperty(this, "seconds", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: void 0
|
|
49
|
-
});
|
|
50
45
|
const p = params.error_message.split("_");
|
|
51
46
|
this.seconds = Number(p[p.length - 1]);
|
|
52
47
|
if (isNaN(this.seconds)) {
|
|
@@ -56,14 +51,9 @@ class FloodWait extends _3_errors_js_1.TelegramError {
|
|
|
56
51
|
}
|
|
57
52
|
exports.FloodWait = FloodWait;
|
|
58
53
|
class Migrate extends _3_errors_js_1.TelegramError {
|
|
54
|
+
dc;
|
|
59
55
|
constructor(params) {
|
|
60
56
|
super(params);
|
|
61
|
-
Object.defineProperty(this, "dc", {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
configurable: true,
|
|
64
|
-
writable: true,
|
|
65
|
-
value: void 0
|
|
66
|
-
});
|
|
67
57
|
const p = params.error_message.split("_");
|
|
68
58
|
this.dc = Number(p[p.length - 1]);
|
|
69
59
|
if (isNaN(this.dc)) {
|
|
@@ -24,103 +24,4 @@ declare global {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
export {};
|
|
27
|
-
/**
|
|
28
|
-
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
29
|
-
* but instead of using npm to install additional dependencies,
|
|
30
|
-
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
31
|
-
*
|
|
32
|
-
* Note that this code might be imported multiple times
|
|
33
|
-
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
34
|
-
* or Node.js might dynamically clear the cache and then force a require).
|
|
35
|
-
* Therefore, it's important to avoid redundant writes to global objects.
|
|
36
|
-
* Additionally, consider that commonjs is used alongside esm,
|
|
37
|
-
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
38
|
-
*/
|
|
39
|
-
import { createRequire } from "node:module";
|
|
40
|
-
import { type URL } from "node:url";
|
|
41
|
-
declare global {
|
|
42
|
-
interface ImportMeta {
|
|
43
|
-
/** A string representation of the fully qualified module URL. When the
|
|
44
|
-
* module is loaded locally, the value will be a file URL (e.g.
|
|
45
|
-
* `file:///path/module.ts`).
|
|
46
|
-
*
|
|
47
|
-
* You can also parse the string as a URL to determine more information about
|
|
48
|
-
* how the current module was loaded. For example to determine if a module was
|
|
49
|
-
* local or not:
|
|
50
|
-
*
|
|
51
|
-
* ```ts
|
|
52
|
-
* const url = new URL(import.meta.url);
|
|
53
|
-
* if (url.protocol === "file:") {
|
|
54
|
-
* console.log("this module was loaded locally");
|
|
55
|
-
* }
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
url: string;
|
|
59
|
-
/**
|
|
60
|
-
* A function that returns resolved specifier as if it would be imported
|
|
61
|
-
* using `import(specifier)`.
|
|
62
|
-
*
|
|
63
|
-
* ```ts
|
|
64
|
-
* console.log(import.meta.resolve("./foo.js"));
|
|
65
|
-
* // file:///dev/foo.js
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @param specifier The module specifier to resolve relative to `parent`.
|
|
69
|
-
* @param parent The absolute parent module URL to resolve from.
|
|
70
|
-
* @returns The absolute (`file:`) URL string for the resolved module.
|
|
71
|
-
*/
|
|
72
|
-
resolve(specifier: string, parent?: string | URL | undefined): string;
|
|
73
|
-
/** A flag that indicates if the current module is the main module that was
|
|
74
|
-
* called when starting the program under Deno.
|
|
75
|
-
*
|
|
76
|
-
* ```ts
|
|
77
|
-
* if (import.meta.main) {
|
|
78
|
-
* // this was loaded as the main module, maybe do some bootstrapping
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
main: boolean;
|
|
83
|
-
/** The absolute path of the current module.
|
|
84
|
-
*
|
|
85
|
-
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
86
|
-
*
|
|
87
|
-
* Example:
|
|
88
|
-
* ```
|
|
89
|
-
* // Unix
|
|
90
|
-
* console.log(import.meta.filename); // /home/alice/my_module.ts
|
|
91
|
-
*
|
|
92
|
-
* // Windows
|
|
93
|
-
* console.log(import.meta.filename); // C:\alice\my_module.ts
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
filename: string;
|
|
97
|
-
/** The absolute path of the directory containing the current module.
|
|
98
|
-
*
|
|
99
|
-
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
100
|
-
*
|
|
101
|
-
* * Example:
|
|
102
|
-
* ```
|
|
103
|
-
* // Unix
|
|
104
|
-
* console.log(import.meta.dirname); // /home/alice
|
|
105
|
-
*
|
|
106
|
-
* // Windows
|
|
107
|
-
* console.log(import.meta.dirname); // C:\alice
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
dirname: string;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
type NodeRequest = ReturnType<typeof createRequire>;
|
|
114
|
-
type NodeModule = NonNullable<NodeRequest["main"]>;
|
|
115
|
-
interface ImportMetaPonyfillCommonjs {
|
|
116
|
-
(require: NodeRequest, module: NodeModule): ImportMeta;
|
|
117
|
-
}
|
|
118
|
-
interface ImportMetaPonyfillEsmodule {
|
|
119
|
-
(importMeta: ImportMeta): ImportMeta;
|
|
120
|
-
}
|
|
121
|
-
interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
|
|
122
|
-
}
|
|
123
|
-
export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
|
|
124
|
-
export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
|
|
125
|
-
export declare let import_meta_ponyfill: ImportMetaPonyfill;
|
|
126
27
|
//# sourceMappingURL=_dnt.polyfills.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,kBAAkB;QAC1B;;;WAGG;QACH,aAAa,CAAC,CAAC,KAAK;YAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;YAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;SAAE,CAAC;KAC3H;CACF;AAcD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,SAAS,CAAC,CAAC,EACP,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAC7F,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;QAEhB,SAAS,CAAC,CAAC,EAAE,CAAC,EACV,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EAClE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAC/B,OAAO,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC1B;CACF;AAoID,OAAO,EAAE,CAAC;AAAA,OAAO,CAAC,MAAM,CAAC;IACvB,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,kBAAkB;QAC1B;;;WAGG;QACH,aAAa,CAAC,CAAC,KAAK;YAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;YAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;SAAE,CAAC;KAC3H;CACF;AAcD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,SAAS,CAAC,CAAC,EACP,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAC7F,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;QAEhB,SAAS,CAAC,CAAC,EAAE,CAAC,EACV,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EAClE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAC/B,OAAO,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC1B;CACF;AAoID,OAAO,EAAE,CAAC;AAAA,OAAO,CAAC,MAAM,CAAC;IACvB,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC"}
|