@mtkruto/browser 0.131.0 → 0.132.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 +2 -2
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +2 -2
- package/esm/2_connection.d.ts +2 -0
- package/esm/2_connection.d.ts.map +1 -1
- package/esm/2_connection.js +2 -0
- package/esm/3_transport.d.ts +1 -0
- package/esm/3_transport.d.ts.map +1 -1
- package/esm/3_transport.js +1 -0
- package/esm/3_types.d.ts +4 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +4 -0
- package/esm/client/0_params.d.ts +16 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +26 -5
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/2_payment_manager.d.ts +4 -1
- package/esm/client/2_payment_manager.d.ts.map +1 -1
- package/esm/client/2_payment_manager.js +33 -1
- package/esm/client/6_client.d.ts +26 -5
- package/esm/client/6_client.d.ts.map +1 -1
- package/esm/client/6_client.js +30 -3
- package/esm/client/6_client_dispatcher.d.ts +26 -5
- package/esm/client/6_client_dispatcher.d.ts.map +1 -1
- package/esm/client/6_client_dispatcher.js +30 -3
- package/esm/connection/0_get_tls_header.d.ts +2 -0
- package/esm/connection/0_get_tls_header.d.ts.map +1 -0
- package/esm/connection/0_get_tls_header.js +151 -0
- package/esm/connection/1_connection_tcp.d.ts.map +1 -1
- package/esm/connection/1_connection_tcp.js +21 -52
- package/esm/connection/1_connection_tls.d.ts +33 -0
- package/esm/connection/1_connection_tls.d.ts.map +1 -0
- package/esm/connection/1_connection_tls.js +203 -0
- package/esm/deps/jsr.io/@std/io/0.225.3/write_all.d.ts +52 -0
- package/esm/deps/jsr.io/@std/io/0.225.3/write_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.3/write_all.js +61 -0
- package/esm/session/2_session_encrypted.d.ts.map +1 -1
- package/esm/session/2_session_encrypted.js +4 -1
- package/esm/transport/0_obfuscation.d.ts +5 -1
- package/esm/transport/0_obfuscation.d.ts.map +1 -1
- package/esm/transport/0_obfuscation.js +17 -4
- package/esm/transport/1_transport_intermediate.d.ts +7 -1
- package/esm/transport/1_transport_intermediate.d.ts.map +1 -1
- package/esm/transport/1_transport_intermediate.js +17 -7
- package/esm/transport/2_transport_provider_mtproxy.d.ts +23 -0
- package/esm/transport/2_transport_provider_mtproxy.d.ts.map +1 -0
- package/esm/transport/2_transport_provider_mtproxy.js +51 -0
- package/esm/transport/2_transport_provider_web_socket.js +1 -1
- package/esm/types/0_star_amount.d.ts +29 -0
- package/esm/types/0_star_amount.d.ts.map +1 -0
- package/esm/types/0_star_amount.js +25 -0
- package/esm/types/2_star_transaction_peer.d.ts +66 -0
- package/esm/types/2_star_transaction_peer.d.ts.map +1 -0
- package/esm/types/2_star_transaction_peer.js +45 -0
- package/esm/types/5_star_transaction.d.ts +64 -0
- package/esm/types/5_star_transaction.d.ts.map +1 -0
- package/esm/types/5_star_transaction.js +71 -0
- package/esm/types/6_star_transaction_list.d.ts +31 -0
- package/esm/types/6_star_transaction_list.d.ts.map +1 -0
- package/esm/types/6_star_transaction_list.js +28 -0
- package/esm/utilities/1_crypto.d.ts +1 -0
- package/esm/utilities/1_crypto.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +4 -0
- package/package.json +1 -1
- package/script/0_deps.d.ts +2 -2
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +4 -3
- package/script/2_connection.d.ts +2 -0
- package/script/2_connection.d.ts.map +1 -1
- package/script/2_connection.js +2 -0
- package/script/3_transport.d.ts +1 -0
- package/script/3_transport.d.ts.map +1 -1
- package/script/3_transport.js +1 -0
- package/script/3_types.d.ts +4 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +4 -0
- package/script/client/0_params.d.ts +16 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +26 -5
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/2_payment_manager.d.ts +4 -1
- package/script/client/2_payment_manager.d.ts.map +1 -1
- package/script/client/2_payment_manager.js +32 -0
- package/script/client/6_client.d.ts +26 -5
- package/script/client/6_client.d.ts.map +1 -1
- package/script/client/6_client.js +30 -3
- package/script/client/6_client_dispatcher.d.ts +26 -5
- package/script/client/6_client_dispatcher.d.ts.map +1 -1
- package/script/client/6_client_dispatcher.js +30 -3
- package/script/connection/0_get_tls_header.d.ts +2 -0
- package/script/connection/0_get_tls_header.d.ts.map +1 -0
- package/script/connection/0_get_tls_header.js +154 -0
- package/script/connection/1_connection_tcp.d.ts.map +1 -1
- package/script/connection/1_connection_tcp.js +21 -52
- package/script/connection/1_connection_tls.d.ts +33 -0
- package/script/connection/1_connection_tls.d.ts.map +1 -0
- package/script/connection/1_connection_tls.js +207 -0
- package/script/deps/jsr.io/@std/io/0.225.3/write_all.d.ts +52 -0
- package/script/deps/jsr.io/@std/io/0.225.3/write_all.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.3/write_all.js +65 -0
- package/script/session/2_session_encrypted.d.ts.map +1 -1
- package/script/session/2_session_encrypted.js +4 -1
- package/script/transport/0_obfuscation.d.ts +5 -1
- package/script/transport/0_obfuscation.d.ts.map +1 -1
- package/script/transport/0_obfuscation.js +16 -3
- package/script/transport/1_transport_intermediate.d.ts +7 -1
- package/script/transport/1_transport_intermediate.d.ts.map +1 -1
- package/script/transport/1_transport_intermediate.js +16 -6
- package/script/transport/2_transport_provider_mtproxy.d.ts +23 -0
- package/script/transport/2_transport_provider_mtproxy.d.ts.map +1 -0
- package/script/transport/2_transport_provider_mtproxy.js +54 -0
- package/script/transport/2_transport_provider_web_socket.js +1 -1
- package/script/types/0_star_amount.d.ts +29 -0
- package/script/types/0_star_amount.d.ts.map +1 -0
- package/script/types/0_star_amount.js +28 -0
- package/script/types/2_star_transaction_peer.d.ts +66 -0
- package/script/types/2_star_transaction_peer.d.ts.map +1 -0
- package/script/types/2_star_transaction_peer.js +48 -0
- package/script/types/5_star_transaction.d.ts +64 -0
- package/script/types/5_star_transaction.d.ts.map +1 -0
- package/script/types/5_star_transaction.js +74 -0
- package/script/types/6_star_transaction_list.d.ts +31 -0
- package/script/types/6_star_transaction_list.d.ts.map +1 -0
- package/script/types/6_star_transaction_list.js +31 -0
- package/script/utilities/1_crypto.d.ts +1 -0
- package/script/utilities/1_crypto.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +5 -0
- package/esm/deps/jsr.io/@std/io/0.225.3/_constants.d.ts +0 -3
- package/esm/deps/jsr.io/@std/io/0.225.3/_constants.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/io/0.225.3/_constants.js +0 -4
- package/esm/deps/jsr.io/@std/io/0.225.3/iterate_reader.d.ts +0 -80
- package/esm/deps/jsr.io/@std/io/0.225.3/iterate_reader.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/io/0.225.3/iterate_reader.js +0 -96
- package/script/deps/jsr.io/@std/io/0.225.3/_constants.d.ts +0 -3
- package/script/deps/jsr.io/@std/io/0.225.3/_constants.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/io/0.225.3/_constants.js +0 -7
- package/script/deps/jsr.io/@std/io/0.225.3/iterate_reader.d.ts +0 -80
- package/script/deps/jsr.io/@std/io/0.225.3/iterate_reader.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/io/0.225.3/iterate_reader.js +0 -100
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_obfuscation.d.ts","sourceRoot":"","sources":["../../src/transport/0_obfuscation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"0_obfuscation.d.ts","sourceRoot":"","sources":["../../src/transport/0_obfuscation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,GAAG,EAAsB,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,8BAA8B;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,8BAA8B;;;GAyD/H"}
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { concat } from "../0_deps.js";
|
|
21
|
-
import { CTR, intToBytes } from "../1_utilities.js";
|
|
22
|
-
export async function getObfuscationParameters(protocol, connection) {
|
|
21
|
+
import { CTR, intToBytes, sha256 } from "../1_utilities.js";
|
|
22
|
+
export async function getObfuscationParameters(protocol, connection, params) {
|
|
23
23
|
let init;
|
|
24
24
|
while (true) {
|
|
25
25
|
init = concat([crypto.getRandomValues(new Uint8Array(56)), intToBytes(protocol, 4, { byteOrder: "big", isSigned: false }), crypto.getRandomValues(new Uint8Array(4))]);
|
|
@@ -37,14 +37,27 @@ export async function getObfuscationParameters(protocol, connection) {
|
|
|
37
37
|
}
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
if (params?.dcId !== undefined) {
|
|
41
|
+
init.set(intToBytes(params.dcId, 2, { byteOrder: "little" }), 60);
|
|
42
|
+
}
|
|
43
|
+
let secret = params?.secret;
|
|
44
|
+
if (secret !== undefined && secret.byteLength >= 17) {
|
|
45
|
+
secret = secret.subarray(1, 17);
|
|
46
|
+
}
|
|
47
|
+
let encryptKey = init.slice(8, 8 + 32);
|
|
41
48
|
const encryptIv = init.slice(40, 40 + 16);
|
|
49
|
+
if (secret) {
|
|
50
|
+
encryptKey = await sha256(concat([encryptKey, secret]));
|
|
51
|
+
}
|
|
42
52
|
const importedEncryptedKey = await CTR.importKey(encryptKey);
|
|
43
53
|
const encryptionCTR = new CTR(importedEncryptedKey, encryptIv);
|
|
44
54
|
const encryptedInit = await encryptionCTR.call(init);
|
|
45
55
|
const initRev = new Uint8Array(init).reverse();
|
|
46
|
-
|
|
56
|
+
let decryptKey = initRev.slice(8, 8 + 32);
|
|
47
57
|
const decryptIv = initRev.slice(40, 40 + 16);
|
|
58
|
+
if (secret) {
|
|
59
|
+
decryptKey = await sha256(concat([decryptKey, secret]));
|
|
60
|
+
}
|
|
48
61
|
const importedDecryptKey = await CTR.importKey(decryptKey);
|
|
49
62
|
const decryptionCTR = new CTR(importedDecryptKey, decryptIv);
|
|
50
63
|
await connection.write(concat([init.subarray(0, 56), encryptedInit.subarray(56, 56 + 8)]));
|
|
@@ -19,9 +19,15 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type { Connection } from "../2_connection.js";
|
|
21
21
|
import { Transport } from "./0_transport.js";
|
|
22
|
+
export interface TransportIntermediateParams {
|
|
23
|
+
isObfuscated?: boolean;
|
|
24
|
+
isPadded?: boolean;
|
|
25
|
+
dcId?: number;
|
|
26
|
+
secret?: Uint8Array;
|
|
27
|
+
}
|
|
22
28
|
export declare class TransportIntermediate extends Transport implements Transport {
|
|
23
29
|
#private;
|
|
24
|
-
constructor(connection: Connection,
|
|
30
|
+
constructor(connection: Connection, params?: TransportIntermediateParams);
|
|
25
31
|
initialize(): Promise<void>;
|
|
26
32
|
receive(): Promise<Uint8Array>;
|
|
27
33
|
send(buffer: Uint8Array): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_transport_intermediate.d.ts","sourceRoot":"","sources":["../../src/transport/1_transport_intermediate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,qBAAsB,SAAQ,SAAU,YAAW,SAAS;;
|
|
1
|
+
{"version":3,"file":"1_transport_intermediate.d.ts","sourceRoot":"","sources":["../../src/transport/1_transport_intermediate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,2BAA2B;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,qBAAa,qBAAsB,SAAQ,SAAU,YAAW,SAAS;;gBAO3D,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,2BAA2B;IASlE,UAAU;IAYV,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC;IAiB9B,IAAI,CAAC,MAAM,EAAE,UAAU;CAW9B"}
|
|
@@ -18,23 +18,29 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { concat } from "../0_deps.js";
|
|
21
|
-
import { intToBytes } from "../1_utilities.js";
|
|
21
|
+
import { getRandomId, intToBytes } from "../1_utilities.js";
|
|
22
22
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
23
23
|
import { Transport } from "./0_transport.js";
|
|
24
24
|
export class TransportIntermediate extends Transport {
|
|
25
25
|
#connection;
|
|
26
|
-
#
|
|
27
|
-
|
|
26
|
+
#isObfuscated;
|
|
27
|
+
#isPadded;
|
|
28
|
+
#dcId;
|
|
29
|
+
#secret;
|
|
30
|
+
constructor(connection, params) {
|
|
28
31
|
super();
|
|
29
32
|
this.#connection = connection;
|
|
30
|
-
this.#
|
|
33
|
+
this.#isObfuscated = params?.isObfuscated ?? false;
|
|
34
|
+
this.#isPadded = params?.isPadded ?? false;
|
|
35
|
+
this.#dcId = params?.dcId;
|
|
36
|
+
this.#secret = params?.secret;
|
|
31
37
|
}
|
|
32
38
|
async initialize() {
|
|
33
|
-
if (this.#
|
|
34
|
-
this.obfuscationParameters = await getObfuscationParameters(0xEEEEEEEE, this.#connection);
|
|
39
|
+
if (this.#isObfuscated) {
|
|
40
|
+
this.obfuscationParameters = await getObfuscationParameters(this.#isPadded ? 0xDDDDDDDD : 0xEEEEEEEE, this.#connection, { dcId: this.#dcId, secret: this.#secret });
|
|
35
41
|
}
|
|
36
42
|
else {
|
|
37
|
-
await this.#connection.write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
|
|
43
|
+
await this.#connection.write(new Uint8Array(this.#isPadded ? [0xDD, 0xDD, 0xDD, 0xDD] : [0xEE, 0xEE, 0xEE, 0xEE]));
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
async receive() {
|
|
@@ -51,6 +57,10 @@ export class TransportIntermediate extends Transport {
|
|
|
51
57
|
return await this.decrypt(buffer);
|
|
52
58
|
}
|
|
53
59
|
async send(buffer) {
|
|
60
|
+
if (this.#isPadded) {
|
|
61
|
+
const padding = crypto.getRandomValues(new Uint8Array(Math.abs(getRandomId(true) % 16)));
|
|
62
|
+
buffer = concat([buffer, padding]);
|
|
63
|
+
}
|
|
54
64
|
const length = intToBytes(buffer.length, 4);
|
|
55
65
|
const data = concat([length, buffer]);
|
|
56
66
|
await this.#connection.write(await this.encrypt(data));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 { type TransportProvider } from "./1_transport_provider.js";
|
|
21
|
+
export declare function transportProviderMtproxy(link: string): TransportProvider;
|
|
22
|
+
export declare function transportProviderMtproxy(hostname: string, port: number, secret: Uint8Array<ArrayBuffer>): TransportProvider;
|
|
23
|
+
//# sourceMappingURL=2_transport_provider_mtproxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_transport_provider_mtproxy.d.ts","sourceRoot":"","sources":["../../src/transport/2_transport_provider_mtproxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EAAW,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE5E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAAC;AAC1E,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 { decodeHex } from "../0_deps.js";
|
|
21
|
+
import { ConnectionTCP } from "../connection/1_connection_tcp.js";
|
|
22
|
+
import { ConnectionTLS } from "../connection/1_connection_tls.js";
|
|
23
|
+
import { TransportIntermediate } from "./1_transport_intermediate.js";
|
|
24
|
+
import { getDcId } from "./1_transport_provider.js";
|
|
25
|
+
export function transportProviderMtproxy(hostnameOrLink, port, secret) {
|
|
26
|
+
let hostname = hostnameOrLink;
|
|
27
|
+
if (port === undefined && secret === undefined) {
|
|
28
|
+
const url = new URL(hostnameOrLink);
|
|
29
|
+
const hostname_ = url.searchParams.get("server");
|
|
30
|
+
const port_ = url.searchParams.get("port");
|
|
31
|
+
const secret_ = url.searchParams.get("secret");
|
|
32
|
+
if (!hostname_ || !port_ || !secret_) {
|
|
33
|
+
throw new TypeError("Invalid MTProxy link.");
|
|
34
|
+
}
|
|
35
|
+
hostname = hostname_;
|
|
36
|
+
port = parseInt(port_);
|
|
37
|
+
secret = decodeHex(secret_);
|
|
38
|
+
if (isNaN(port) || port < 0 || port > 0xFFFF) {
|
|
39
|
+
throw new TypeError("Server port is invalid.");
|
|
40
|
+
}
|
|
41
|
+
if (secret.byteLength < 16) {
|
|
42
|
+
throw new TypeError("Proxy secret must be at least 16 bytes.");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return ({ dc, isCdn }) => {
|
|
46
|
+
const dcId = getDcId(dc, isCdn);
|
|
47
|
+
const connection = secret.byteLength <= 17 ? new ConnectionTCP(hostname, port) : new ConnectionTLS(hostname, port, secret);
|
|
48
|
+
const transport = new TransportIntermediate(connection, { isPadded: true, isObfuscated: true, secret, dcId });
|
|
49
|
+
return { connection, transport, dcId };
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -36,8 +36,8 @@ export const transportProviderWebSocket = (params) => {
|
|
|
36
36
|
params.wss ??= typeof location !== "undefined" && location.protocol === "http:" && location.hostname !== "localhost" ? false : true;
|
|
37
37
|
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${isCdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
38
38
|
const connection = new ConnectionWebSocket(url);
|
|
39
|
-
const transport = new TransportIntermediate(connection, true);
|
|
40
39
|
const dcId = getDcId(dc, isCdn);
|
|
40
|
+
const transport = new TransportIntermediate(connection, { isObfuscated: true, dcId });
|
|
41
41
|
return { connection, transport, dcId };
|
|
42
42
|
};
|
|
43
43
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 type { Api } from "../2_tl.js";
|
|
21
|
+
/** A star amount. */
|
|
22
|
+
export interface StarAmount {
|
|
23
|
+
/** The amount of stars. */
|
|
24
|
+
amount: number;
|
|
25
|
+
/** The decimal star amount. */
|
|
26
|
+
nanos: number;
|
|
27
|
+
}
|
|
28
|
+
export declare function constructStarAmount(starsAmount: Api.starsAmount): StarAmount;
|
|
29
|
+
//# sourceMappingURL=0_star_amount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0_star_amount.d.ts","sourceRoot":"","sources":["../../src/types/0_star_amount.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAqB;AACrB,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,GAAG,CAAC,WAAW,GAAG,UAAU,CAK5E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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
|
+
export function constructStarAmount(starsAmount) {
|
|
21
|
+
return {
|
|
22
|
+
amount: Number(starsAmount.amount),
|
|
23
|
+
nanos: Number(starsAmount.nanos),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 type { Api } from "../2_tl.js";
|
|
21
|
+
import type { ChatP, PeerGetter } from "./1_chat_p.js";
|
|
22
|
+
/** @unlisted */
|
|
23
|
+
export interface StarTransactionPeerUnsupported {
|
|
24
|
+
/** @discriminator */
|
|
25
|
+
type: "unsupported";
|
|
26
|
+
}
|
|
27
|
+
/** @unlisted */
|
|
28
|
+
export interface StarTransactionPeerAppStore {
|
|
29
|
+
/** @discriminator */
|
|
30
|
+
type: "appStore";
|
|
31
|
+
}
|
|
32
|
+
/** @unlisted */
|
|
33
|
+
export interface StarTransactionPeerPlayMarket {
|
|
34
|
+
/** @discriminator */
|
|
35
|
+
type: "playMarket";
|
|
36
|
+
}
|
|
37
|
+
/** @unlisted */
|
|
38
|
+
export interface StarTransactionPeerPremiumBot {
|
|
39
|
+
/** @discriminator */
|
|
40
|
+
type: "premiumBot";
|
|
41
|
+
}
|
|
42
|
+
/** @unlisted */
|
|
43
|
+
export interface StarTransactionPeerFragment {
|
|
44
|
+
/** @discriminator */
|
|
45
|
+
type: "fragment";
|
|
46
|
+
}
|
|
47
|
+
/** @unlisted */
|
|
48
|
+
export interface StarTransactionPeerChat {
|
|
49
|
+
/** @discriminator */
|
|
50
|
+
type: "chat";
|
|
51
|
+
chat: ChatP;
|
|
52
|
+
}
|
|
53
|
+
/** @unlisted */
|
|
54
|
+
export interface StarTransactionPeerAds {
|
|
55
|
+
/** @discriminator */
|
|
56
|
+
type: "ads";
|
|
57
|
+
}
|
|
58
|
+
/** @unlisted */
|
|
59
|
+
export interface StarTransactionPeerApi {
|
|
60
|
+
/** @discriminator */
|
|
61
|
+
type: "api";
|
|
62
|
+
}
|
|
63
|
+
/** Any type of star transaction peer. */
|
|
64
|
+
export type StarTransactionPeer = StarTransactionPeerUnsupported | StarTransactionPeerAppStore | StarTransactionPeerPlayMarket | StarTransactionPeerPremiumBot | StarTransactionPeerFragment | StarTransactionPeerChat | StarTransactionPeerAds | StarTransactionPeerApi;
|
|
65
|
+
export declare function constructStarTransactionPeer(peer: Api.StarsTransactionPeer, getPeer: PeerGetter): StarTransactionPeer;
|
|
66
|
+
//# sourceMappingURL=2_star_transaction_peer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_star_transaction_peer.d.ts","sourceRoot":"","sources":["../../src/types/2_star_transaction_peer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvD,gBAAgB;AAChB,MAAM,WAAW,8BAA8B;IAC7C,qBAAqB;IACrB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,gBAAgB;AAChB,MAAM,WAAW,2BAA2B;IAC1C,qBAAqB;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,gBAAgB;AAChB,MAAM,WAAW,6BAA6B;IAC5C,qBAAqB;IACrB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,gBAAgB;AAChB,MAAM,WAAW,6BAA6B;IAC5C,qBAAqB;IACrB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,gBAAgB;AAChB,MAAM,WAAW,2BAA2B;IAC1C,qBAAqB;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,gBAAgB;AAChB,MAAM,WAAW,uBAAuB;IACtC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,CAAC;CACb;AAED,gBAAgB;AAChB,MAAM,WAAW,sBAAsB;IACrC,qBAAqB;IACrB,IAAI,EAAE,KAAK,CAAC;CACb;AAED,gBAAgB;AAChB,MAAM,WAAW,sBAAsB;IACrC,qBAAqB;IACrB,IAAI,EAAE,KAAK,CAAC;CACb;AAED,yCAAyC;AACzC,MAAM,MAAM,mBAAmB,GAAG,8BAA8B,GAAG,2BAA2B,GAAG,6BAA6B,GAAG,6BAA6B,GAAG,2BAA2B,GAAG,uBAAuB,GAAG,sBAAsB,GAAG,sBAAsB,CAAC;AAEzQ,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,UAAU,GAAG,mBAAmB,CAwBrH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 { unreachable } from "../0_deps.js";
|
|
21
|
+
export function constructStarTransactionPeer(peer, getPeer) {
|
|
22
|
+
switch (peer._) {
|
|
23
|
+
case "starsTransactionPeerUnsupported":
|
|
24
|
+
return { type: "unsupported" };
|
|
25
|
+
case "starsTransactionPeerAppStore":
|
|
26
|
+
return { type: "appStore" };
|
|
27
|
+
case "starsTransactionPeerPlayMarket":
|
|
28
|
+
return { type: "playMarket" };
|
|
29
|
+
case "starsTransactionPeerPremiumBot":
|
|
30
|
+
return { type: "premiumBot" };
|
|
31
|
+
case "starsTransactionPeerFragment":
|
|
32
|
+
return { type: "fragment" };
|
|
33
|
+
case "starsTransactionPeer": {
|
|
34
|
+
const chat = getPeer(peer.peer)?.[0];
|
|
35
|
+
if (!chat) {
|
|
36
|
+
unreachable();
|
|
37
|
+
}
|
|
38
|
+
return { type: "chat", chat };
|
|
39
|
+
}
|
|
40
|
+
case "starsTransactionPeerAds":
|
|
41
|
+
return { type: "ads" };
|
|
42
|
+
case "starsTransactionPeerAPI":
|
|
43
|
+
return { type: "api" };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 { Api } from "../2_tl.js";
|
|
21
|
+
import { type StarAmount } from "./0_star_amount.js";
|
|
22
|
+
import type { ChatP, PeerGetter } from "./1_chat_p.js";
|
|
23
|
+
import { type StarTransactionPeer } from "./2_star_transaction_peer.js";
|
|
24
|
+
import { type Gift } from "./4_gift.js";
|
|
25
|
+
/** A star transaction. */
|
|
26
|
+
export interface StarTransaction {
|
|
27
|
+
isRefund: boolean;
|
|
28
|
+
isPending: boolean;
|
|
29
|
+
isFailed: boolean;
|
|
30
|
+
isGift: boolean;
|
|
31
|
+
isReaction: boolean;
|
|
32
|
+
isGiftUpgrade: boolean;
|
|
33
|
+
isBusinessTransfer: boolean;
|
|
34
|
+
isGiftResale: boolean;
|
|
35
|
+
isPostSearch: boolean;
|
|
36
|
+
isGiftPrepaidUpgrade: boolean;
|
|
37
|
+
isGiftDetailDrop: boolean;
|
|
38
|
+
isPhoneGroupMessage: boolean;
|
|
39
|
+
isGiftAuctionBid: boolean;
|
|
40
|
+
isOffer: boolean;
|
|
41
|
+
id: string;
|
|
42
|
+
amount: StarAmount;
|
|
43
|
+
date: number;
|
|
44
|
+
peer: StarTransactionPeer;
|
|
45
|
+
title?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
transactionDate?: number;
|
|
48
|
+
transactionUrl?: string;
|
|
49
|
+
botPayload?: string;
|
|
50
|
+
messageId?: number;
|
|
51
|
+
subscriptionPeriod?: number;
|
|
52
|
+
giveawayMessageId?: number;
|
|
53
|
+
gift?: Gift;
|
|
54
|
+
broadcastNumber?: number;
|
|
55
|
+
starrefCommissionPerMille?: number;
|
|
56
|
+
starrefChat?: ChatP;
|
|
57
|
+
starrefAmount?: StarAmount;
|
|
58
|
+
paidMessages?: number;
|
|
59
|
+
premiumGiftMonthCount?: number;
|
|
60
|
+
adsProceedsFromDate?: number;
|
|
61
|
+
adsProceedsToDate?: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function constructStarTransaction(starTransaction: Api.StarsTransaction, getPeer: PeerGetter): StarTransaction;
|
|
64
|
+
//# sourceMappingURL=5_star_transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5_star_transaction.d.ts","sourceRoot":"","sources":["../../src/types/5_star_transaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAgC,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAiB,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAEvD,0BAA0B;AAC1B,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,GAAG,CAAC,gBAAgB,EAAE,OAAO,EAAE,UAAU,GAAG,eAAe,CA8CpH"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 { unreachable } from "../0_deps.js";
|
|
21
|
+
import { cleanObject } from "../1_utilities.js";
|
|
22
|
+
import { Api } from "../2_tl.js";
|
|
23
|
+
import { constructStarAmount } from "./0_star_amount.js";
|
|
24
|
+
import { constructStarTransactionPeer } from "./2_star_transaction_peer.js";
|
|
25
|
+
import { constructGift } from "./4_gift.js";
|
|
26
|
+
export function constructStarTransaction(starTransaction, getPeer) {
|
|
27
|
+
let starrefChat;
|
|
28
|
+
if (starTransaction.starref_peer) {
|
|
29
|
+
starrefChat = getPeer(starTransaction.starref_peer)?.[0];
|
|
30
|
+
if (!starrefChat) {
|
|
31
|
+
unreachable();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return cleanObject({
|
|
35
|
+
isRefund: starTransaction.refund ?? false,
|
|
36
|
+
isPending: starTransaction.pending ?? false,
|
|
37
|
+
isFailed: starTransaction.failed ?? false,
|
|
38
|
+
isGift: starTransaction.gift ?? false,
|
|
39
|
+
isReaction: starTransaction.reaction ?? false,
|
|
40
|
+
isGiftUpgrade: starTransaction.stargift_upgrade ?? false,
|
|
41
|
+
isBusinessTransfer: starTransaction.business_transfer ?? false,
|
|
42
|
+
isGiftResale: starTransaction.stargift_resale ?? false,
|
|
43
|
+
isPostSearch: starTransaction.posts_search ?? false,
|
|
44
|
+
isGiftPrepaidUpgrade: starTransaction.stargift_prepaid_upgrade ?? false,
|
|
45
|
+
isGiftDetailDrop: starTransaction.stargift_drop_original_details ?? false,
|
|
46
|
+
isPhoneGroupMessage: starTransaction.phonegroup_message ?? false,
|
|
47
|
+
isGiftAuctionBid: starTransaction.stargift_auction_bid ?? false,
|
|
48
|
+
isOffer: starTransaction.offer ?? false,
|
|
49
|
+
id: starTransaction.id,
|
|
50
|
+
amount: constructStarAmount(Api.as("starsAmount", starTransaction.amount)),
|
|
51
|
+
date: starTransaction.date,
|
|
52
|
+
peer: constructStarTransactionPeer(starTransaction.peer, getPeer),
|
|
53
|
+
title: starTransaction.title,
|
|
54
|
+
description: starTransaction.description,
|
|
55
|
+
transactionDate: starTransaction.transaction_date,
|
|
56
|
+
transactionUrl: starTransaction.transaction_url,
|
|
57
|
+
botPayload: new TextDecoder().decode(starTransaction.bot_payload),
|
|
58
|
+
messageId: starTransaction.msg_id,
|
|
59
|
+
subscriptionPeriod: starTransaction.subscription_period,
|
|
60
|
+
giveawayMessageId: starTransaction.giveaway_post_id,
|
|
61
|
+
gift: starTransaction.stargift ? constructGift(starTransaction.stargift, getPeer) : undefined,
|
|
62
|
+
broadcastNumber: starTransaction.floodskip_number,
|
|
63
|
+
starrefCommissionPerMille: starTransaction.starref_commission_permille,
|
|
64
|
+
starrefChat,
|
|
65
|
+
starrefAmount: starTransaction.starref_amount ? constructStarAmount(Api.as("starsAmount", starTransaction.starref_amount)) : undefined,
|
|
66
|
+
paidMessages: starTransaction.paid_messages,
|
|
67
|
+
premiumGiftMonthCount: starTransaction.premium_gift_months,
|
|
68
|
+
adsProceedsFromDate: starTransaction.ads_proceeds_from_date,
|
|
69
|
+
adsProceedsToDate: starTransaction.ads_proceeds_to_date,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 type { Api } from "../2_tl.js";
|
|
21
|
+
import type { PeerGetter } from "./1_chat_p.js";
|
|
22
|
+
import { type StarTransaction } from "./5_star_transaction.js";
|
|
23
|
+
/** A list of star transactions. */
|
|
24
|
+
export interface StarTransactionList {
|
|
25
|
+
/** The transactions included in this list. */
|
|
26
|
+
transactions: StarTransaction[];
|
|
27
|
+
/** Key to fetch further transactions. */
|
|
28
|
+
nextOffset?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function constructStarTransactionList(result: Api.payments_starsStatus, getPeer: PeerGetter): StarTransactionList;
|
|
31
|
+
//# sourceMappingURL=6_star_transaction_list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"6_star_transaction_list.d.ts","sourceRoot":"","sources":["../../src/types/6_star_transaction_list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAA4B,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEzF,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,UAAU,GAAG,mBAAmB,CAMvH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2026 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 { cleanObject } from "../1_utilities.js";
|
|
21
|
+
import { constructStarTransaction } from "./5_star_transaction.js";
|
|
22
|
+
export function constructStarTransactionList(result, getPeer) {
|
|
23
|
+
const transactions = result.history?.map((v) => constructStarTransaction(v, getPeer)) ?? [];
|
|
24
|
+
return cleanObject({
|
|
25
|
+
transactions,
|
|
26
|
+
nextOffset: result.next_offset,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -27,4 +27,5 @@ export declare class CTR {
|
|
|
27
27
|
static importKey(key: Uint8Array<ArrayBuffer>): Promise<CryptoKey>;
|
|
28
28
|
call(data: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer>>;
|
|
29
29
|
}
|
|
30
|
+
export declare function hmacSha256(data: Uint8Array<ArrayBuffer>, secret: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer>>;
|
|
30
31
|
//# sourceMappingURL=1_crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,qBAAa,GAAG;;IAMd,IAAI,MAAM,IAAI;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAE9C;gBAEW,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU;WAK7B,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAIlE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;CAkD5E"}
|
|
1
|
+
{"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,qBAAa,GAAG;;IAMd,IAAI,MAAM,IAAI;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAE9C;gBAEW,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU;WAK7B,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAIlE,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;CAkD5E;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,oCAe9F"}
|
|
@@ -77,3 +77,7 @@ export class CTR {
|
|
|
77
77
|
this.#iv = intToBytes(intFromBytes(this.#iv, { byteOrder: "big", isSigned: false }) + BigInt(amount), this.#iv.length, { byteOrder: "big", isSigned: false });
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
export async function hmacSha256(data, secret) {
|
|
81
|
+
const key = await crypto.subtle.importKey("raw", secret, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
82
|
+
return new Uint8Array(await crypto.subtle.sign("HMAC", key, data.buffer));
|
|
83
|
+
}
|
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -33,11 +33,11 @@ export { concat } from "./deps/jsr.io/@std/bytes/1.0.6/concat.js";
|
|
|
33
33
|
export { equals } from "./deps/jsr.io/@std/bytes/1.0.6/equals.js";
|
|
34
34
|
export { startsWith } from "./deps/jsr.io/@std/bytes/1.0.6/starts_with.js";
|
|
35
35
|
export { LruCache } from "./deps/jsr.io/@std/cache/0.2.2/lru_cache.js";
|
|
36
|
-
export {
|
|
36
|
+
export { writeAll } from "./deps/jsr.io/@std/io/0.225.3/write_all.js";
|
|
37
37
|
export { format } from "./deps/jsr.io/@std/datetime/0.225.7/format.js";
|
|
38
38
|
export { MINUTE, SECOND } from "./deps/jsr.io/@std/datetime/0.225.7/constants.js";
|
|
39
39
|
export { toArrayBuffer } from "./deps/jsr.io/@std/streams/1.0.17/to_array_buffer.js";
|
|
40
|
-
export { encodeHex } from "./deps/jsr.io/@std/encoding/1.0.10/hex.js";
|
|
40
|
+
export { decodeHex, encodeHex } from "./deps/jsr.io/@std/encoding/1.0.10/hex.js";
|
|
41
41
|
export { decodeBase64, encodeBase64 } from "./deps/jsr.io/@std/encoding/1.0.10/base64.js";
|
|
42
42
|
import { contentType as contentType_ } from "./deps/jsr.io/@std/media-types/1.1.0/content_type.js";
|
|
43
43
|
export declare const contentType: typeof contentType_;
|