@mtkruto/node 0.76.1 → 0.77.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_deps.d.ts +1 -2
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +1 -2
- package/esm/0_errors.d.ts +6 -0
- package/esm/0_errors.d.ts.map +1 -1
- package/esm/0_errors.js +11 -0
- package/esm/1_utilities.d.ts +1 -2
- package/esm/1_utilities.d.ts.map +1 -1
- package/esm/1_utilities.js +1 -2
- package/esm/2_tl.d.ts +0 -1
- package/esm/2_tl.d.ts.map +1 -1
- package/esm/2_tl.js +0 -1
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password.js +8 -8
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +2 -2
- package/esm/client/1_client_plain.js +14 -14
- package/{script/deps/jsr.io/@std/assert/1.0.12 → esm/deps/jsr.io/@std/assert/1.0.16}/is_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/not_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/throws.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +6 -5
- package/esm/session/2_session_plain.js +2 -2
- package/esm/tl/0_utilities.d.ts +1 -0
- package/esm/tl/0_utilities.d.ts.map +1 -1
- package/esm/tl/0_utilities.js +3 -0
- package/esm/tl/1_tl_reader.d.ts +6 -8
- package/esm/tl/1_tl_reader.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +39 -30
- package/esm/tl/1_tl_writer.d.ts +5 -5
- package/esm/tl/1_tl_writer.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +49 -35
- package/esm/transport/0_obfuscation.d.ts.map +1 -1
- package/esm/transport/0_obfuscation.js +2 -2
- package/esm/transport/1_transport_abridged.js +3 -3
- package/esm/transport/1_transport_intermediate.js +2 -2
- package/esm/types/0_link_preview_media_size.d.ts +19 -0
- package/esm/types/0_link_preview_media_size.d.ts.map +1 -1
- package/esm/types/0_link_preview_media_size.js +19 -0
- package/esm/types/7_saved_chat.d.ts.map +1 -1
- package/esm/types/7_saved_chat.js +1 -1
- package/esm/utilities/0_int.d.ts +52 -0
- package/esm/utilities/0_int.d.ts.map +1 -0
- package/esm/utilities/0_int.js +141 -0
- package/esm/utilities/0_int_test.d.ts.map +1 -0
- package/esm/utilities/1_auth.d.ts.map +1 -1
- package/esm/utilities/1_auth.js +3 -4
- package/esm/utilities/1_base64.js +1 -1
- package/esm/utilities/1_crypto.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +2 -3
- package/esm/utilities/1_math.js +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -2
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +2 -4
- package/script/0_errors.d.ts +6 -0
- package/script/0_errors.d.ts.map +1 -1
- package/script/0_errors.js +13 -1
- package/script/1_utilities.d.ts +1 -2
- package/script/1_utilities.d.ts.map +1 -1
- package/script/1_utilities.js +1 -2
- package/script/2_tl.d.ts +0 -1
- package/script/2_tl.d.ts.map +1 -1
- package/script/2_tl.js +1 -3
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +7 -7
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +1 -1
- package/script/client/1_client_plain.js +13 -13
- package/{esm/deps/jsr.io/@std/assert/1.0.12 → script/deps/jsr.io/@std/assert/1.0.16}/is_error.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/not_equals.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/assert/{1.0.12 → 1.0.16}/throws.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts.map +1 -1
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +5 -4
- package/script/session/2_session_plain.js +1 -1
- package/script/tl/0_utilities.d.ts +1 -0
- package/script/tl/0_utilities.d.ts.map +1 -1
- package/script/tl/0_utilities.js +4 -0
- package/script/tl/1_tl_reader.d.ts +6 -8
- package/script/tl/1_tl_reader.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +38 -30
- package/script/tl/1_tl_writer.d.ts +5 -5
- package/script/tl/1_tl_writer.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +49 -35
- package/script/transport/0_obfuscation.d.ts.map +1 -1
- package/script/transport/0_obfuscation.js +1 -1
- package/script/transport/1_transport_abridged.js +2 -2
- package/script/transport/1_transport_intermediate.js +1 -1
- package/script/types/0_link_preview_media_size.d.ts +19 -0
- package/script/types/0_link_preview_media_size.d.ts.map +1 -1
- package/script/types/0_link_preview_media_size.js +19 -0
- package/script/types/7_saved_chat.d.ts.map +1 -1
- package/script/types/7_saved_chat.js +3 -3
- package/script/utilities/0_int.d.ts +52 -0
- package/script/utilities/0_int.d.ts.map +1 -0
- package/script/utilities/{0_bigint.js → 0_int.js} +66 -15
- package/script/utilities/0_int_test.d.ts.map +1 -0
- package/script/utilities/1_auth.d.ts.map +1 -1
- package/script/utilities/1_auth.js +4 -5
- package/script/utilities/1_base64.js +2 -2
- package/script/utilities/1_crypto.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +2 -3
- package/script/utilities/1_math.js +4 -4
- package/esm/deps/jsr.io/@std/assert/1.0.12/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.12/equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.12/instance_of.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.13/assertion_error.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts +0 -15
- package/esm/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.13/unreachable.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -52
- package/esm/tl/0_tl_error.d.ts +0 -23
- package/esm/tl/0_tl_error.d.ts.map +0 -1
- package/esm/tl/0_tl_error.js +0 -22
- package/esm/utilities/0_bigint.d.ts +0 -10
- package/esm/utilities/0_bigint.d.ts.map +0 -1
- package/esm/utilities/0_bigint.js +0 -91
- package/esm/utilities/0_bigint_test.d.ts.map +0 -1
- package/esm/utilities/0_buffer.d.ts +0 -21
- package/esm/utilities/0_buffer.d.ts.map +0 -1
- package/esm/utilities/0_buffer.js +0 -51
- package/esm/utilities/0_buffer_test.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.12/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.12/equal.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.12/instance_of.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts +0 -26
- package/script/deps/jsr.io/@std/assert/1.0.13/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.13/assertion_error.js +0 -34
- package/script/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts +0 -15
- package/script/deps/jsr.io/@std/assert/1.0.13/unreachable.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.13/unreachable.js +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.d.ts +0 -23
- package/script/deps/jsr.io/@std/assert/1.0.16/instance_of.js +0 -55
- package/script/tl/0_tl_error.d.ts +0 -23
- package/script/tl/0_tl_error.d.ts.map +0 -1
- package/script/tl/0_tl_error.js +0 -26
- package/script/utilities/0_bigint.d.ts +0 -10
- package/script/utilities/0_bigint.d.ts.map +0 -1
- package/script/utilities/0_bigint_test.d.ts.map +0 -1
- package/script/utilities/0_buffer.d.ts +0 -21
- package/script/utilities/0_buffer.d.ts.map +0 -1
- package/script/utilities/0_buffer.js +0 -54
- package/script/utilities/0_buffer_test.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.js +0 -0
- /package/script/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.d.ts +0 -0
- /package/script/deps/jsr.io/@std/streams/{1.0.12 → 1.0.14}/to_array_buffer.js +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2025 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
20
|
+
import * as dntShim from "../_dnt.shims.js";
|
|
21
|
+
import { TLError } from "../0_errors.js";
|
|
22
|
+
export function modExp(a, b, n) {
|
|
23
|
+
a %= n;
|
|
24
|
+
let result = 1n;
|
|
25
|
+
let x = a;
|
|
26
|
+
while (b > 0n) {
|
|
27
|
+
const leastSignificantBit = b % 2n;
|
|
28
|
+
b /= 2n;
|
|
29
|
+
if (leastSignificantBit === 1n) {
|
|
30
|
+
result *= x;
|
|
31
|
+
result %= n;
|
|
32
|
+
}
|
|
33
|
+
x *= x;
|
|
34
|
+
x %= n;
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
export function mod(n, m) {
|
|
39
|
+
// deno-lint-ignore ban-ts-comment
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
return ((n % m) + m) % m;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an integer from its byte representation.
|
|
45
|
+
*
|
|
46
|
+
* @param bytes The byte representation of the integer.
|
|
47
|
+
* @param params Additional parameters.
|
|
48
|
+
*/
|
|
49
|
+
export function intFromBytes(bytes, { byteOrder = "little", isSigned = true } = {}) {
|
|
50
|
+
const bytesLength = bytes.length;
|
|
51
|
+
if (byteOrder === "little") {
|
|
52
|
+
bytes = bytes.toReversed();
|
|
53
|
+
}
|
|
54
|
+
let bigIntVar = BigInt("0x" + [...bytes].map((v) => v.toString(16).padStart(2, "0")).join(""));
|
|
55
|
+
if (isSigned && Math.floor(bigIntVar.toString(2).length / 8) >= bytesLength) {
|
|
56
|
+
bigIntVar = bigIntVar - (2n ** (BigInt(bytesLength * 8)));
|
|
57
|
+
}
|
|
58
|
+
return bigIntVar;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates a random integer of an arbitrary size.
|
|
62
|
+
*
|
|
63
|
+
* @param isSigned Whether to allow signed integers. Defaults to `true`.
|
|
64
|
+
*/
|
|
65
|
+
export function getRandomInt(byteLength, isSigned = true) {
|
|
66
|
+
const randomBytes = new Uint8Array(byteLength);
|
|
67
|
+
dntShim.crypto.getRandomValues(randomBytes);
|
|
68
|
+
return intFromBytes(randomBytes, { isSigned });
|
|
69
|
+
}
|
|
70
|
+
export function getRandomId(isNumber) {
|
|
71
|
+
if (isNumber) {
|
|
72
|
+
return Number(getRandomInt(4, true));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return getRandomInt(8, true);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function gcd(a, b) {
|
|
79
|
+
if (a === 0n) {
|
|
80
|
+
return b;
|
|
81
|
+
}
|
|
82
|
+
while ((a & 1n) === 0n) {
|
|
83
|
+
a >>= 1n;
|
|
84
|
+
}
|
|
85
|
+
while (true) {
|
|
86
|
+
if (a > b) {
|
|
87
|
+
a = (a - b) >> 1n;
|
|
88
|
+
while ((a & 1n) === 0n) {
|
|
89
|
+
a >>= 1n;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (b > a) {
|
|
93
|
+
b = (b - a) >> 1n;
|
|
94
|
+
while ((b & 1n) === 0n) {
|
|
95
|
+
b >>= 1n;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return a;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const bufferFromHexString = (hexString) => Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
104
|
+
/**
|
|
105
|
+
* Converts an integer to its byte representation.
|
|
106
|
+
*
|
|
107
|
+
* @param int The integer to convert.
|
|
108
|
+
* @param byteCount The expected size of the integer in bytes.
|
|
109
|
+
* @param params Additional parameters.
|
|
110
|
+
*/
|
|
111
|
+
export function intToBytes(int, byteCount, { byteOrder = "little", isSigned = true, path = [], } = {}) {
|
|
112
|
+
const actualByteCount = Math.ceil(int.toString(2).length / 8);
|
|
113
|
+
if (byteCount < actualByteCount) {
|
|
114
|
+
throw new TLError(`The provided integer is too big for int${byteCount * 8}`, path);
|
|
115
|
+
}
|
|
116
|
+
if (byteCount === 4 || byteCount === 2) { // fast path
|
|
117
|
+
const buffer = new Uint8Array(byteCount);
|
|
118
|
+
const dataView = new DataView(buffer.buffer);
|
|
119
|
+
(byteCount === 2 ? isSigned ? dataView.setInt16 : dataView.setUint16 : isSigned ? dataView.setInt32 : dataView.setUint32).call(dataView, 0, Number(int), byteOrder === "little");
|
|
120
|
+
return buffer;
|
|
121
|
+
}
|
|
122
|
+
int = BigInt(typeof int === "number" ? Math.ceil(int) : int);
|
|
123
|
+
if (byteCount === 8) { // fast path
|
|
124
|
+
const buffer = new Uint8Array(byteCount);
|
|
125
|
+
const dataView = new DataView(buffer.buffer);
|
|
126
|
+
(isSigned ? dataView.setBigInt64 : dataView.setBigUint64).call(dataView, 0, int, byteOrder === "little");
|
|
127
|
+
return buffer;
|
|
128
|
+
}
|
|
129
|
+
if (!isSigned && int < 0n) {
|
|
130
|
+
throw new TLError("Received a signed integer while an unsigned one was expected", path);
|
|
131
|
+
}
|
|
132
|
+
if (isSigned && int < 0n) {
|
|
133
|
+
int = 2n ** BigInt(byteCount * 8) + int;
|
|
134
|
+
}
|
|
135
|
+
const hex = int.toString(16).padStart(byteCount * 2, "0");
|
|
136
|
+
const buffer = bufferFromHexString(hex);
|
|
137
|
+
if (byteOrder === "little") {
|
|
138
|
+
buffer.reverse();
|
|
139
|
+
}
|
|
140
|
+
return buffer;
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0_int_test.d.ts","sourceRoot":"","sources":["../../src/utilities/0_int_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_auth.d.ts","sourceRoot":"","sources":["../../src/utilities/1_auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1_auth.d.ts","sourceRoot":"","sources":["../../src/utilities/1_auth.ts"],"names":[],"mappings":"AA0BA,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,oCAiCrF"}
|
package/esm/utilities/1_auth.js
CHANGED
|
@@ -19,9 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import * as dntShim from "../_dnt.shims.js";
|
|
21
21
|
import { assert, assertEquals, concat, ige256Encrypt } from "../0_deps.js";
|
|
22
|
-
import { bigIntFromBuffer, modExp } from "./0_bigint.js";
|
|
23
|
-
import { bufferFromBigInt } from "./0_buffer.js";
|
|
24
22
|
import { sha256 } from "./0_hash.js";
|
|
23
|
+
import { intFromBytes, intToBytes, modExp } from "./0_int.js";
|
|
25
24
|
export async function rsaPad(data, [serverKey, exponent]) {
|
|
26
25
|
assert(data.length <= 144);
|
|
27
26
|
let keyAesEncryptedInt;
|
|
@@ -39,10 +38,10 @@ export async function rsaPad(data, [serverKey, exponent]) {
|
|
|
39
38
|
const tempKeyXor = tempKey.map((v, i) => v ^ aesEncryptedSha256[i]);
|
|
40
39
|
const keyAesEncrypted = concat([tempKeyXor, aesEncrypted]);
|
|
41
40
|
assertEquals(keyAesEncrypted.length, 256);
|
|
42
|
-
keyAesEncryptedInt =
|
|
41
|
+
keyAesEncryptedInt = intFromBytes(keyAesEncrypted, { byteOrder: "big", isSigned: false });
|
|
43
42
|
} while (keyAesEncryptedInt >= serverKey);
|
|
44
43
|
const encryptedDataInt = modExp(keyAesEncryptedInt, exponent, serverKey);
|
|
45
|
-
const encryptedData =
|
|
44
|
+
const encryptedData = intToBytes(encryptedDataInt, 256, { byteOrder: "big", isSigned: false });
|
|
46
45
|
assertEquals(encryptedData.length, 256);
|
|
47
46
|
return encryptedData;
|
|
48
47
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { decodeBase64, encodeBase64 } from "../0_deps.js";
|
|
21
|
-
import { mod } from "./
|
|
21
|
+
import { mod } from "./0_int.js";
|
|
22
22
|
export function base64EncodeUrlSafe(data) {
|
|
23
23
|
return encodeBase64(data).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,qBAAa,GAAG;;IAMd,IAAI,MAAM,IAAI;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAE9C;gBAEW,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,EAAE,UAAU;WAKrC,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAI1E,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;CAkD5E"}
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import * as dntShim from "../_dnt.shims.js";
|
|
21
21
|
import { concat } from "../0_deps.js";
|
|
22
|
-
import {
|
|
23
|
-
import { bufferFromBigInt } from "./0_buffer.js";
|
|
22
|
+
import { intFromBytes, intToBytes } from "./0_int.js";
|
|
24
23
|
export class CTR {
|
|
25
24
|
#key;
|
|
26
25
|
#iv;
|
|
@@ -76,6 +75,6 @@ export class CTR {
|
|
|
76
75
|
if (amount < 1) {
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
79
|
-
this.#iv =
|
|
78
|
+
this.#iv = intToBytes(intFromBytes(this.#iv, { byteOrder: "big", isSigned: false }) + BigInt(amount), this.#iv.length, { byteOrder: "big", isSigned: false });
|
|
80
79
|
}
|
|
81
80
|
}
|
package/esm/utilities/1_math.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { unreachable } from "../0_deps.js";
|
|
21
|
-
import { gcd, getRandomId, mod } from "./
|
|
21
|
+
import { gcd, getRandomId, mod } from "./0_int.js";
|
|
22
22
|
function getRandomNumberInRange(min, max) {
|
|
23
23
|
return Math.floor(Math.random() * (max - min) + min);
|
|
24
24
|
}
|
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export { assert } from "./deps/jsr.io/@std/assert/1.0.16/assert.js";
|
|
|
21
21
|
export { assertFalse } from "./deps/jsr.io/@std/assert/1.0.16/false.js";
|
|
22
22
|
export { assertEquals } from "./deps/jsr.io/@std/assert/1.0.16/equals.js";
|
|
23
23
|
export { unreachable } from "./deps/jsr.io/@std/assert/1.0.16/unreachable.js";
|
|
24
|
-
export { assertInstanceOf } from "./deps/jsr.io/@std/assert/1.0.16/instance_of.js";
|
|
25
24
|
export { AssertionError } from "./deps/jsr.io/@std/assert/1.0.16/assertion_error.js";
|
|
26
25
|
export { join } from "./deps/jsr.io/@std/path/1.1.3/join.js";
|
|
27
26
|
export { extname } from "./deps/jsr.io/@std/path/1.1.3/extname.js";
|
|
@@ -34,7 +33,7 @@ export { LruCache } from "./deps/jsr.io/@std/cache/0.2.1/lru_cache.js";
|
|
|
34
33
|
export { iterateReader } from "./deps/jsr.io/@std/io/0.225.2/iterate_reader.js";
|
|
35
34
|
export { format } from "./deps/jsr.io/@std/datetime/0.225.5/format.js";
|
|
36
35
|
export { MINUTE, SECOND } from "./deps/jsr.io/@std/datetime/0.225.5/constants.js";
|
|
37
|
-
export { toArrayBuffer } from "./deps/jsr.io/@std/streams/1.0.
|
|
36
|
+
export { toArrayBuffer } from "./deps/jsr.io/@std/streams/1.0.14/to_array_buffer.js";
|
|
38
37
|
export { decodeBase64, encodeBase64 } from "./deps/jsr.io/@std/encoding/1.0.7/base64.js";
|
|
39
38
|
export { encodeHex } from "./deps/jsr.io/@std/encoding/1.0.7/hex.js";
|
|
40
39
|
import { contentType as contentType_ } from "./deps/jsr.io/@std/media-types/1.1.0/content_type.js";
|
package/script/0_deps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_deps.d.ts","sourceRoot":"","sources":["../src/0_deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAC9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"0_deps.d.ts","sourceRoot":"","sources":["../src/0_deps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4CAA4C,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAErF,OAAO,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,8CAA8C,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,0CAA0C,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAEhF,OAAO,EAAE,MAAM,EAAE,MAAM,+CAA+C,CAAC;AAEvE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kDAAkD,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,sDAAsD,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,sDAAsD,CAAC;AACnG,eAAO,MAAM,WAAW,EAAE,OAAO,YAMhC,CAAC;AAEF,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,UAMzC;AAED,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,+CAA+C,CAAC"}
|
package/script/0_deps.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.contentType = exports.encodeHex = exports.encodeBase64 = exports.decodeBase64 = exports.toArrayBuffer = exports.SECOND = exports.MINUTE = exports.format = exports.iterateReader = exports.LruCache = exports.concat = exports.pooledMap = exports.delay = exports.isAbsolute = exports.toFileUrl = exports.basename = exports.extname = exports.join = exports.AssertionError = exports.
|
|
22
|
+
exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.contentType = exports.encodeHex = exports.encodeBase64 = exports.decodeBase64 = exports.toArrayBuffer = exports.SECOND = exports.MINUTE = exports.format = exports.iterateReader = exports.LruCache = exports.concat = exports.pooledMap = exports.delay = exports.isAbsolute = exports.toFileUrl = exports.basename = exports.extname = exports.join = exports.AssertionError = exports.unreachable = exports.assertEquals = exports.assertFalse = exports.assert = void 0;
|
|
23
23
|
exports.extension = extension;
|
|
24
24
|
var assert_js_1 = require("./deps/jsr.io/@std/assert/1.0.16/assert.js");
|
|
25
25
|
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_js_1.assert; } });
|
|
@@ -29,8 +29,6 @@ var equals_js_1 = require("./deps/jsr.io/@std/assert/1.0.16/equals.js");
|
|
|
29
29
|
Object.defineProperty(exports, "assertEquals", { enumerable: true, get: function () { return equals_js_1.assertEquals; } });
|
|
30
30
|
var unreachable_js_1 = require("./deps/jsr.io/@std/assert/1.0.16/unreachable.js");
|
|
31
31
|
Object.defineProperty(exports, "unreachable", { enumerable: true, get: function () { return unreachable_js_1.unreachable; } });
|
|
32
|
-
var instance_of_js_1 = require("./deps/jsr.io/@std/assert/1.0.16/instance_of.js");
|
|
33
|
-
Object.defineProperty(exports, "assertInstanceOf", { enumerable: true, get: function () { return instance_of_js_1.assertInstanceOf; } });
|
|
34
32
|
var assertion_error_js_1 = require("./deps/jsr.io/@std/assert/1.0.16/assertion_error.js");
|
|
35
33
|
Object.defineProperty(exports, "AssertionError", { enumerable: true, get: function () { return assertion_error_js_1.AssertionError; } });
|
|
36
34
|
var join_js_1 = require("./deps/jsr.io/@std/path/1.1.3/join.js");
|
|
@@ -57,7 +55,7 @@ Object.defineProperty(exports, "format", { enumerable: true, get: function () {
|
|
|
57
55
|
var constants_js_1 = require("./deps/jsr.io/@std/datetime/0.225.5/constants.js");
|
|
58
56
|
Object.defineProperty(exports, "MINUTE", { enumerable: true, get: function () { return constants_js_1.MINUTE; } });
|
|
59
57
|
Object.defineProperty(exports, "SECOND", { enumerable: true, get: function () { return constants_js_1.SECOND; } });
|
|
60
|
-
var to_array_buffer_js_1 = require("./deps/jsr.io/@std/streams/1.0.
|
|
58
|
+
var to_array_buffer_js_1 = require("./deps/jsr.io/@std/streams/1.0.14/to_array_buffer.js");
|
|
61
59
|
Object.defineProperty(exports, "toArrayBuffer", { enumerable: true, get: function () { return to_array_buffer_js_1.toArrayBuffer; } });
|
|
62
60
|
var base64_js_1 = require("./deps/jsr.io/@std/encoding/1.0.7/base64.js");
|
|
63
61
|
Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return base64_js_1.decodeBase64; } });
|
package/script/0_errors.d.ts
CHANGED
|
@@ -32,4 +32,10 @@ export declare class TransportError extends MtkrutoError {
|
|
|
32
32
|
readonly code: number;
|
|
33
33
|
constructor(code: number);
|
|
34
34
|
}
|
|
35
|
+
export declare class TLError extends MtkrutoError {
|
|
36
|
+
#private;
|
|
37
|
+
name: string;
|
|
38
|
+
constructor(message: string, path: string[]);
|
|
39
|
+
get path(): string[];
|
|
40
|
+
}
|
|
35
41
|
//# sourceMappingURL=0_errors.d.ts.map
|
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;aAClB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIzC"}
|
|
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;aAClB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIzC;AAED,qBAAa,OAAQ,SAAQ,YAAY;;IAC9B,IAAI,SAAa;gBAGd,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAK3C,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;CACF"}
|
package/script/0_errors.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.TransportError = exports.InputError = exports.AccessError = exports.ConnectionError = exports.MtkrutoError = void 0;
|
|
22
|
+
exports.TLError = exports.TransportError = exports.InputError = exports.AccessError = exports.ConnectionError = exports.MtkrutoError = void 0;
|
|
23
23
|
class MtkrutoError extends Error {
|
|
24
24
|
}
|
|
25
25
|
exports.MtkrutoError = MtkrutoError;
|
|
@@ -53,3 +53,15 @@ class TransportError extends MtkrutoError {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
exports.TransportError = TransportError;
|
|
56
|
+
class TLError extends MtkrutoError {
|
|
57
|
+
name = "TLError";
|
|
58
|
+
#path;
|
|
59
|
+
constructor(message, path) {
|
|
60
|
+
super(`${message}${path.length ? ` at ${path.join(" ")}` : ""}`);
|
|
61
|
+
this.#path = path;
|
|
62
|
+
}
|
|
63
|
+
get path() {
|
|
64
|
+
return this.#path;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.TLError = TLError;
|
package/script/1_utilities.d.ts
CHANGED
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import "./_dnt.polyfills.js";
|
|
21
|
-
export * from "./utilities/
|
|
22
|
-
export * from "./utilities/0_buffer.js";
|
|
21
|
+
export * from "./utilities/0_int.js";
|
|
23
22
|
export * from "./utilities/0_color.js";
|
|
24
23
|
export * from "./utilities/0_gzip.js";
|
|
25
24
|
export * from "./utilities/0_hash.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../src/1_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,qBAAqB,CAAC;AAG7B,cAAc,
|
|
1
|
+
{"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../src/1_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,qBAAqB,CAAC;AAG7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC"}
|
package/script/1_utilities.js
CHANGED
|
@@ -34,8 +34,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
34
34
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
35
35
|
*/
|
|
36
36
|
require("./_dnt.polyfills.js");
|
|
37
|
-
__exportStar(require("./utilities/
|
|
38
|
-
__exportStar(require("./utilities/0_buffer.js"), exports);
|
|
37
|
+
__exportStar(require("./utilities/0_int.js"), exports);
|
|
39
38
|
__exportStar(require("./utilities/0_color.js"), exports);
|
|
40
39
|
__exportStar(require("./utilities/0_gzip.js"), exports);
|
|
41
40
|
__exportStar(require("./utilities/0_hash.js"), exports);
|
package/script/2_tl.d.ts
CHANGED
|
@@ -17,7 +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
|
-
export { TLError } from "./tl/0_tl_error.js";
|
|
21
20
|
export * from "./tl/0_utilities.js";
|
|
22
21
|
export * from "./tl/1_tl_reader.js";
|
|
23
22
|
export * from "./tl/1_tl_writer.js";
|
package/script/2_tl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_tl.d.ts","sourceRoot":"","sources":["../src/2_tl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,
|
|
1
|
+
{"version":3,"file":"2_tl.d.ts","sourceRoot":"","sources":["../src/2_tl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC"}
|
package/script/2_tl.js
CHANGED
|
@@ -55,9 +55,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
55
55
|
};
|
|
56
56
|
})();
|
|
57
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
-
exports.Api = exports.Mtproto =
|
|
59
|
-
var _0_tl_error_js_1 = require("./tl/0_tl_error.js");
|
|
60
|
-
Object.defineProperty(exports, "TLError", { enumerable: true, get: function () { return _0_tl_error_js_1.TLError; } });
|
|
58
|
+
exports.Api = exports.Mtproto = void 0;
|
|
61
59
|
__exportStar(require("./tl/0_utilities.js"), exports);
|
|
62
60
|
__exportStar(require("./tl/1_tl_reader.js"), exports);
|
|
63
61
|
__exportStar(require("./tl/1_tl_writer.js"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_password.d.ts","sourceRoot":"","sources":["../../src/client/0_password.ts"],"names":[],"mappings":"AAuBA,OAAO,
|
|
1
|
+
{"version":3,"file":"0_password.d.ts","sourceRoot":"","sources":["../../src/client/0_password.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAmE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC5G,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,WAgC5D;AAGD,eAAO,MAAM,CAAC,eAAS,CAAC;AAGxB,eAAO,MAAM,EAAE,GAAI,MAAM,UAAU,EAAE,MAAM,UAAU,qCAAkC,CAAC;AAGxF,eAAO,MAAM,GAAG,GAAU,UAAU,UAAU,EAAE,OAAO,UAAU,EAAE,OAAO,UAAU,qCAA+C,CAAC;AAEpI,wBAAsB,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,MAAM,oCAIhH;AAGD,eAAO,MAAM,GAAG,GAAU,UAAU,UAAU,EAAE,OAAO,UAAU,CAAC,WAAW,CAAC,EAAE,OAAO,UAAU,qCAAqF,CAAC;AAEvL,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,WAWd;AAED,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,2BASvD;AAED,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAyFnH"}
|
|
@@ -125,7 +125,7 @@ function pad(bigint) {
|
|
|
125
125
|
bigint = BigInt(bigint);
|
|
126
126
|
}
|
|
127
127
|
if (typeof bigint === "bigint") {
|
|
128
|
-
return (0, _1_utilities_js_1.
|
|
128
|
+
return (0, _1_utilities_js_1.intToBytes)(bigint, 256, { byteOrder: "big", isSigned: false });
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
return (0, _0_deps_js_1.concat)([new Uint8Array(256 - bigint.length), bigint]);
|
|
@@ -140,7 +140,7 @@ async function checkPassword(password_, ap) {
|
|
|
140
140
|
// g := algo.g
|
|
141
141
|
const g = algo.g;
|
|
142
142
|
// p := algo.p
|
|
143
|
-
const p = (0, _1_utilities_js_1.
|
|
143
|
+
const p = (0, _1_utilities_js_1.intFromBytes)(algo.p, { byteOrder: "big", isSigned: false });
|
|
144
144
|
if (!isSafePrime(algo.p, g)) {
|
|
145
145
|
throw new Error("Got unsafe prime");
|
|
146
146
|
}
|
|
@@ -159,18 +159,18 @@ async function checkPassword(password_, ap) {
|
|
|
159
159
|
// salt2 := algo.salt2
|
|
160
160
|
const salt2 = algo.salt2;
|
|
161
161
|
// g_b := srp_B
|
|
162
|
-
const gB = (0, _1_utilities_js_1.
|
|
162
|
+
const gB = (0, _1_utilities_js_1.intFromBytes)(srpB, { byteOrder: "big", isSigned: false });
|
|
163
163
|
// k := H(p | g)
|
|
164
|
-
const k = (0, _1_utilities_js_1.
|
|
164
|
+
const k = (0, _1_utilities_js_1.intFromBytes)(await (0, exports.h)((0, _0_deps_js_1.concat)([pad(p), pad(g)])), { byteOrder: "big", isSigned: false });
|
|
165
165
|
let u = 0n;
|
|
166
166
|
let a = 0n;
|
|
167
167
|
let gA = 0n;
|
|
168
168
|
for (let i = 0; i < 1_000; i++) {
|
|
169
|
-
a = (0, _1_utilities_js_1.
|
|
169
|
+
a = (0, _1_utilities_js_1.getRandomInt)(256, false);
|
|
170
170
|
// g_a := pow(g, a) mod p
|
|
171
171
|
gA = (0, _1_utilities_js_1.modExp)(BigInt(g), a, p);
|
|
172
172
|
if (isGoodModExpFirst(gA, p)) {
|
|
173
|
-
u = (0, _1_utilities_js_1.
|
|
173
|
+
u = (0, _1_utilities_js_1.intFromBytes)(await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([pad(gA), pad(gB)])), { byteOrder: "big", isSigned: false });
|
|
174
174
|
if (u > 0n) {
|
|
175
175
|
break;
|
|
176
176
|
}
|
|
@@ -180,7 +180,7 @@ async function checkPassword(password_, ap) {
|
|
|
180
180
|
throw new Error();
|
|
181
181
|
}
|
|
182
182
|
// x := PH2(password, salt1, salt2)
|
|
183
|
-
const x = (0, _1_utilities_js_1.
|
|
183
|
+
const x = (0, _1_utilities_js_1.intFromBytes)(await (0, exports.ph2)(password, salt1, salt2), { byteOrder: "big", isSigned: false });
|
|
184
184
|
// v := pow(g, x) mod p
|
|
185
185
|
const v = (0, _1_utilities_js_1.modExp)(BigInt(g), x, p);
|
|
186
186
|
// k_v := (k * v) mod p
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_storage_operations.d.ts","sourceRoot":"","sources":["../../src/client/0_storage_operations.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AAE,MAAM,CAAC;CAChB;AACD,cAAM,WAAY,SAAQ,YAAY,CAAC,IAAI,CAAC;;gBAC9B,OAAO,EAAE,OAAO;IAIb,GAAG,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAMjC,OAAO,IAAI,IAAI;IAUT,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAK9B,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI;IAerC,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;CACF"}
|
|
@@ -703,7 +703,7 @@ class StorageAuth extends StorageValue {
|
|
|
703
703
|
#authKeyId = null;
|
|
704
704
|
async #resetAuthKeyId(auth) {
|
|
705
705
|
if (auth?.authKey) {
|
|
706
|
-
this.#authKeyId = (0, _1_utilities_js_1.
|
|
706
|
+
this.#authKeyId = (0, _1_utilities_js_1.intFromBytes)((await (0, _1_utilities_js_1.sha1)(auth.authKey)).subarray(-8));
|
|
707
707
|
}
|
|
708
708
|
else {
|
|
709
709
|
this.#authKeyId = null;
|
|
@@ -46,7 +46,7 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
46
46
|
return await _2_tl_js_1.Mtproto.deserializeType(_2_tl_js_1.Mtproto.mustGetReturnType(function_._), body);
|
|
47
47
|
}
|
|
48
48
|
async createAuthKey() {
|
|
49
|
-
const nonce = (0, _1_utilities_js_1.
|
|
49
|
+
const nonce = (0, _1_utilities_js_1.getRandomInt)(16);
|
|
50
50
|
LcreateAuthKey.debug("auth key creation started");
|
|
51
51
|
let resPq = null;
|
|
52
52
|
for (let i = 0; i < 10; i++) {
|
|
@@ -65,13 +65,13 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
65
65
|
if (!resPq) {
|
|
66
66
|
(0, _0_deps_js_1.unreachable)();
|
|
67
67
|
}
|
|
68
|
-
const pq_ = (0, _1_utilities_js_1.
|
|
68
|
+
const pq_ = (0, _1_utilities_js_1.intFromBytes)(resPq.pq, { byteOrder: "big", isSigned: false });
|
|
69
69
|
LcreateAuthKey.debug(`pq=${pq_}`);
|
|
70
70
|
const [p_, q_] = (0, _1_utilities_js_1.factorize)(pq_);
|
|
71
71
|
LcreateAuthKey.debug("factorized pq");
|
|
72
72
|
LcreateAuthKey.debug(`p=${p_}, q=${q_}`);
|
|
73
|
-
const p = (0, _1_utilities_js_1.
|
|
74
|
-
const q = (0, _1_utilities_js_1.
|
|
73
|
+
const p = (0, _1_utilities_js_1.intToBytes)(p_, 4, { byteOrder: "big", isSigned: false });
|
|
74
|
+
const q = (0, _1_utilities_js_1.intToBytes)(q_, 4, { byteOrder: "big", isSigned: false });
|
|
75
75
|
let publicKeyFingerprint;
|
|
76
76
|
let publicKey;
|
|
77
77
|
for (const fingerprint of resPq.server_public_key_fingerprints) {
|
|
@@ -88,7 +88,7 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
88
88
|
const dc = (0, _3_transport_js_1.getDcId)(this.dc, this.cdn);
|
|
89
89
|
const pq = resPq.pq;
|
|
90
90
|
const serverNonce = resPq.server_nonce;
|
|
91
|
-
const newNonce = (0, _1_utilities_js_1.
|
|
91
|
+
const newNonce = (0, _1_utilities_js_1.getRandomInt)(32);
|
|
92
92
|
let encryptedData = await (0, _1_utilities_js_1.rsaPad)(_2_tl_js_1.Mtproto.serializeObject({
|
|
93
93
|
_: "p_q_inner_data_dc",
|
|
94
94
|
pq,
|
|
@@ -110,23 +110,23 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
110
110
|
});
|
|
111
111
|
(0, _0_deps_js_1.assert)(_2_tl_js_1.Mtproto.is("server_DH_params_ok", dhParams));
|
|
112
112
|
LcreateAuthKey.debug("got server_DH_params_ok");
|
|
113
|
-
const newNonce_ = (0, _1_utilities_js_1.
|
|
114
|
-
const serverNonce_ = (0, _1_utilities_js_1.
|
|
113
|
+
const newNonce_ = (0, _1_utilities_js_1.intToBytes)(newNonce, 32);
|
|
114
|
+
const serverNonce_ = (0, _1_utilities_js_1.intToBytes)(serverNonce, 16);
|
|
115
115
|
const tmpAesKey = (0, _0_deps_js_1.concat)([await (0, _1_utilities_js_1.sha1)((0, _0_deps_js_1.concat)([newNonce_, serverNonce_])), (await (0, _1_utilities_js_1.sha1)((0, _0_deps_js_1.concat)([serverNonce_, newNonce_]))).subarray(0, 0 + 12)]);
|
|
116
116
|
const tmpAesIv = (0, _0_deps_js_1.concat)([(await (0, _1_utilities_js_1.sha1)((0, _0_deps_js_1.concat)([serverNonce_, newNonce_]))).subarray(12, 12 + 8), await (0, _1_utilities_js_1.sha1)((0, _0_deps_js_1.concat)([newNonce_, newNonce_])), newNonce_.subarray(0, 0 + 4)]);
|
|
117
117
|
const answerWithHash = (0, _0_deps_js_1.ige256Decrypt)(dhParams.encrypted_answer, tmpAesKey, tmpAesIv);
|
|
118
118
|
const dhInnerData = await _2_tl_js_1.Mtproto.deserializeType("server_DH_inner_data", answerWithHash.slice(20));
|
|
119
119
|
const { g, g_a: gA_, dh_prime: dhPrime_ } = dhInnerData;
|
|
120
|
-
const gA = (0, _1_utilities_js_1.
|
|
121
|
-
const dhPrime = (0, _1_utilities_js_1.
|
|
122
|
-
const b = (0, _1_utilities_js_1.
|
|
120
|
+
const gA = (0, _1_utilities_js_1.intFromBytes)(gA_, { byteOrder: "big", isSigned: false });
|
|
121
|
+
const dhPrime = (0, _1_utilities_js_1.intFromBytes)(dhPrime_, { byteOrder: "big", isSigned: false });
|
|
122
|
+
const b = (0, _1_utilities_js_1.getRandomInt)(256, false);
|
|
123
123
|
const gB = (0, _1_utilities_js_1.modExp)(BigInt(g), b, dhPrime);
|
|
124
124
|
const data = _2_tl_js_1.Mtproto.serializeObject({
|
|
125
125
|
_: "client_DH_inner_data",
|
|
126
126
|
nonce,
|
|
127
127
|
server_nonce: serverNonce,
|
|
128
128
|
retry_id: 0n,
|
|
129
|
-
g_b: (0, _1_utilities_js_1.
|
|
129
|
+
g_b: (0, _1_utilities_js_1.intToBytes)(gB, 256, { byteOrder: "big" }),
|
|
130
130
|
});
|
|
131
131
|
let dataWithHash = (0, _0_deps_js_1.concat)([await (0, _1_utilities_js_1.sha1)(data), data]);
|
|
132
132
|
while (dataWithHash.length % 16 !== 0) {
|
|
@@ -144,9 +144,9 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
|
|
|
144
144
|
const serverNonceSlice = serverNonce_.subarray(0, 8);
|
|
145
145
|
const salt = newNonce_.subarray(0, 0 + 8).map((v, i) => v ^ serverNonceSlice[i]);
|
|
146
146
|
const authKey_ = (0, _1_utilities_js_1.modExp)(gA, b, dhPrime);
|
|
147
|
-
const authKey = (0, _1_utilities_js_1.
|
|
147
|
+
const authKey = (0, _1_utilities_js_1.intToBytes)(authKey_, 256, { byteOrder: "big", isSigned: false });
|
|
148
148
|
LcreateAuthKey.debug("auth key created");
|
|
149
|
-
return [authKey, (0, _1_utilities_js_1.
|
|
149
|
+
return [authKey, (0, _1_utilities_js_1.intFromBytes)(salt)];
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
exports.ClientPlain = ClientPlain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"is_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/is_error.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACnD,KAAK,EAAE,OAAO,EAEd,UAAU,CAAC,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC/C,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAC5B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,IAAI,CAAC,CA8BpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"not_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/not_equals.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,QAUtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throws.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.
|
|
1
|
+
{"version":3,"file":"throws.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.16/throws.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,OAAO,EACjB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;AACX;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAClD,EAAE,EAAE,MAAM,OAAO,EAEjB,UAAU,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC9C,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to_array_buffer.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/streams/1.0.
|
|
1
|
+
{"version":3,"file":"to_array_buffer.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/streams/1.0.14/to_array_buffer.ts"],"names":[],"mappings":"AAKA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