@mtkruto/node 0.152.0 → 0.153.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/client/0_client_abstract.d.ts +1 -1
- package/esm/client/0_client_abstract.d.ts.map +1 -1
- package/esm/client/0_client_abstract.js +2 -2
- package/esm/client/0_password.js +1 -1
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities.d.ts.map +1 -1
- package/esm/client/0_utilities.js +4 -4
- package/esm/client/1_client_plain.js +2 -2
- package/esm/client/2_client_encrypted.js +3 -3
- package/esm/client/2_file_manager.js +7 -7
- package/esm/client/2_network_statistics_manager.d.ts +2 -2
- package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +10 -10
- package/esm/client/6_client.js +10 -10
- package/esm/client/6_client_dispatcher.js +2 -2
- package/esm/connection/0_get_tls_header.js +5 -5
- package/esm/connection/1_connection_socks5.node.js +3 -3
- package/esm/connection/1_connection_tcp.node.js +3 -3
- package/esm/connection/1_connection_tls.node.js +3 -3
- package/esm/connection/1_connection_web_socket.js +4 -4
- package/esm/session/1_session.d.ts +3 -3
- package/esm/session/1_session.d.ts.map +1 -1
- package/esm/session/1_session.js +5 -5
- package/esm/session/2_session_encrypted.js +4 -4
- package/esm/session/2_session_plain.js +2 -2
- package/esm/tl/1_tl_writer.js +5 -5
- package/esm/tl/2_message.js +1 -1
- package/esm/transport/1_transport_abridged.js +1 -1
- package/esm/transport/1_transport_intermediate.js +1 -1
- package/esm/transport/1_transport_provider.d.ts +2 -2
- package/esm/transport/1_transport_provider.d.ts.map +1 -1
- package/esm/transport/1_transport_provider.js +5 -5
- package/esm/transport/2_transport_provider_mtproxy.js +2 -2
- package/esm/transport/2_transport_provider_socks5.js +2 -2
- package/esm/transport/2_transport_provider_tcp.js +2 -2
- package/esm/transport/2_transport_provider_web_socket.js +3 -3
- package/esm/types/1_network_statistics.d.ts +1 -1
- package/esm/types/1_network_statistics.d.ts.map +1 -1
- package/esm/types/_file_id.js +1 -1
- package/esm/utilities/0_int.js +1 -1
- package/esm/utilities/1_auth.js +4 -4
- package/esm/utilities/1_crypto.js +7 -7
- package/package.json +1 -1
- package/script/client/0_client_abstract.d.ts +1 -1
- package/script/client/0_client_abstract.d.ts.map +1 -1
- package/script/client/0_client_abstract.js +2 -2
- package/script/client/0_password.js +1 -1
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities.d.ts.map +1 -1
- package/script/client/0_utilities.js +5 -5
- package/script/client/1_client_plain.js +2 -2
- package/script/client/2_client_encrypted.js +2 -2
- package/script/client/2_file_manager.js +7 -7
- package/script/client/2_network_statistics_manager.d.ts +2 -2
- package/script/client/2_network_statistics_manager.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +10 -10
- package/script/client/6_client.js +10 -10
- package/script/client/6_client_dispatcher.js +2 -2
- package/script/connection/0_get_tls_header.js +5 -5
- package/script/connection/1_connection_socks5.node.js +3 -3
- package/script/connection/1_connection_tcp.node.js +3 -3
- package/script/connection/1_connection_tls.node.js +3 -3
- package/script/connection/1_connection_web_socket.js +4 -4
- package/script/session/1_session.d.ts +3 -3
- package/script/session/1_session.d.ts.map +1 -1
- package/script/session/1_session.js +5 -5
- package/script/session/2_session_encrypted.js +4 -4
- package/script/session/2_session_plain.js +2 -2
- package/script/tl/1_tl_writer.js +5 -5
- package/script/tl/2_message.js +1 -1
- package/script/transport/1_transport_abridged.js +1 -1
- package/script/transport/1_transport_intermediate.js +1 -1
- package/script/transport/1_transport_provider.d.ts +2 -2
- package/script/transport/1_transport_provider.d.ts.map +1 -1
- package/script/transport/1_transport_provider.js +5 -5
- package/script/transport/2_transport_provider_mtproxy.js +2 -2
- package/script/transport/2_transport_provider_socks5.js +2 -2
- package/script/transport/2_transport_provider_tcp.js +2 -2
- package/script/transport/2_transport_provider_web_socket.js +3 -3
- package/script/types/1_network_statistics.d.ts +1 -1
- package/script/types/1_network_statistics.d.ts.map +1 -1
- package/script/types/_file_id.js +1 -1
- package/script/utilities/0_int.js +1 -1
- package/script/utilities/1_auth.js +4 -4
- package/script/utilities/1_crypto.js +7 -7
|
@@ -58,14 +58,14 @@ const _0_deps_js_1 = require("../0_deps.js");
|
|
|
58
58
|
const _0_hash_js_1 = require("./0_hash.js");
|
|
59
59
|
const _0_int_js_1 = require("./0_int.js");
|
|
60
60
|
async function rsaPad(data, [serverKey, exponent]) {
|
|
61
|
-
(0, _0_deps_js_1.assert)(data.
|
|
61
|
+
(0, _0_deps_js_1.assert)(data.byteLength <= 144);
|
|
62
62
|
let keyAesEncryptedInt;
|
|
63
63
|
let tries = 0;
|
|
64
64
|
do {
|
|
65
65
|
if (++tries === 10) {
|
|
66
66
|
throw new Error("Out of tries");
|
|
67
67
|
}
|
|
68
|
-
const dataWithPadding = (0, _0_deps_js_1.concat)([data, new Uint8Array(192 - data.
|
|
68
|
+
const dataWithPadding = (0, _0_deps_js_1.concat)([data, new Uint8Array(192 - data.byteLength)]);
|
|
69
69
|
const dataPadReversed = new Uint8Array(dataWithPadding).reverse();
|
|
70
70
|
const tempKey = dntShim.crypto.getRandomValues(new Uint8Array(32));
|
|
71
71
|
const dataWithHash = (0, _0_deps_js_1.concat)([dataPadReversed, await (0, _0_hash_js_1.sha256)((0, _0_deps_js_1.concat)([tempKey, dataWithPadding]))]);
|
|
@@ -73,11 +73,11 @@ async function rsaPad(data, [serverKey, exponent]) {
|
|
|
73
73
|
const aesEncryptedSha256 = await (0, _0_hash_js_1.sha256)(aesEncrypted);
|
|
74
74
|
const tempKeyXor = tempKey.map((v, i) => v ^ aesEncryptedSha256[i]);
|
|
75
75
|
const keyAesEncrypted = (0, _0_deps_js_1.concat)([tempKeyXor, aesEncrypted]);
|
|
76
|
-
(0, _0_deps_js_1.assertEquals)(keyAesEncrypted.
|
|
76
|
+
(0, _0_deps_js_1.assertEquals)(keyAesEncrypted.byteLength, 256);
|
|
77
77
|
keyAesEncryptedInt = (0, _0_int_js_1.intFromBytes)(keyAesEncrypted, { byteOrder: "big", isSigned: false });
|
|
78
78
|
} while (keyAesEncryptedInt >= serverKey);
|
|
79
79
|
const encryptedDataInt = (0, _0_int_js_1.modExp)(keyAesEncryptedInt, exponent, serverKey);
|
|
80
80
|
const encryptedData = (0, _0_int_js_1.intToBytes)(encryptedDataInt, 256, { byteOrder: "big", isSigned: false });
|
|
81
|
-
(0, _0_deps_js_1.assertEquals)(encryptedData.
|
|
81
|
+
(0, _0_deps_js_1.assertEquals)(encryptedData.byteLength, 256);
|
|
82
82
|
return encryptedData;
|
|
83
83
|
}
|
|
@@ -81,11 +81,11 @@ class CTR {
|
|
|
81
81
|
async #call(data) {
|
|
82
82
|
let header;
|
|
83
83
|
if (this.#bytesUntilNextBlock) {
|
|
84
|
-
const headerLength = Math.min(data.
|
|
84
|
+
const headerLength = Math.min(data.byteLength, this.#iv.byteLength - this.#bytesUntilNextBlock);
|
|
85
85
|
const encrypted = await this.#encrypt((0, _0_deps_js_1.concat)([new Uint8Array(this.#bytesUntilNextBlock), data.subarray(0, headerLength)]));
|
|
86
86
|
header = encrypted.subarray(this.#bytesUntilNextBlock);
|
|
87
87
|
data = data.subarray(headerLength);
|
|
88
|
-
if (encrypted.
|
|
88
|
+
if (encrypted.byteLength === this.#iv.byteLength) {
|
|
89
89
|
this.#increaseIv(1);
|
|
90
90
|
this.#bytesUntilNextBlock = 0;
|
|
91
91
|
}
|
|
@@ -93,26 +93,26 @@ class CTR {
|
|
|
93
93
|
this.#bytesUntilNextBlock += headerLength;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
if (!data.
|
|
96
|
+
if (!data.byteLength && header) {
|
|
97
97
|
return header;
|
|
98
98
|
}
|
|
99
99
|
const encrypted = await this.#encrypt(data);
|
|
100
|
-
this.#bytesUntilNextBlock = encrypted.
|
|
101
|
-
this.#increaseIv((encrypted.
|
|
100
|
+
this.#bytesUntilNextBlock = encrypted.byteLength % this.#iv.byteLength;
|
|
101
|
+
this.#increaseIv((encrypted.byteLength - this.#bytesUntilNextBlock) / this.#iv.byteLength);
|
|
102
102
|
return header ? (0, _0_deps_js_1.concat)([header, encrypted]) : encrypted;
|
|
103
103
|
}
|
|
104
104
|
async #encrypt(data) {
|
|
105
105
|
return new Uint8Array(await dntShim.crypto.subtle.encrypt({
|
|
106
106
|
name: "AES-CTR",
|
|
107
107
|
counter: new Uint8Array(this.#iv),
|
|
108
|
-
length: this.#iv.
|
|
108
|
+
length: this.#iv.byteLength * 8,
|
|
109
109
|
}, this.#key, data));
|
|
110
110
|
}
|
|
111
111
|
#increaseIv(amount) {
|
|
112
112
|
if (amount < 1) {
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
this.#iv = (0, _0_int_js_1.intToBytes)((0, _0_int_js_1.intFromBytes)(this.#iv, { byteOrder: "big", isSigned: false }) + BigInt(amount), this.#iv.
|
|
115
|
+
this.#iv = (0, _0_int_js_1.intToBytes)((0, _0_int_js_1.intFromBytes)(this.#iv, { byteOrder: "big", isSigned: false }) + BigInt(amount), this.#iv.byteLength, { byteOrder: "big", isSigned: false });
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
exports.CTR = CTR;
|