@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
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { CTR } from "../1_utilities.js";
|
|
21
21
|
import type { Connection } from "../2_connection.js";
|
|
22
|
-
export
|
|
22
|
+
export interface GetObfuscationParametersParams {
|
|
23
|
+
dcId?: number;
|
|
24
|
+
secret?: Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
export declare function getObfuscationParameters(protocol: number, connection: Connection, params?: GetObfuscationParametersParams): Promise<{
|
|
23
27
|
encryptionCTR: CTR;
|
|
24
28
|
decryptionCTR: CTR;
|
|
25
29
|
}>;
|
|
@@ -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"}
|
|
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
22
22
|
exports.getObfuscationParameters = getObfuscationParameters;
|
|
23
23
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
24
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
25
|
-
async function getObfuscationParameters(protocol, connection) {
|
|
25
|
+
async function getObfuscationParameters(protocol, connection, params) {
|
|
26
26
|
let init;
|
|
27
27
|
while (true) {
|
|
28
28
|
init = (0, _0_deps_js_1.concat)([crypto.getRandomValues(new Uint8Array(56)), (0, _1_utilities_js_1.intToBytes)(protocol, 4, { byteOrder: "big", isSigned: false }), crypto.getRandomValues(new Uint8Array(4))]);
|
|
@@ -40,14 +40,27 @@ async function getObfuscationParameters(protocol, connection) {
|
|
|
40
40
|
}
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
if (params?.dcId !== undefined) {
|
|
44
|
+
init.set((0, _1_utilities_js_1.intToBytes)(params.dcId, 2, { byteOrder: "little" }), 60);
|
|
45
|
+
}
|
|
46
|
+
let secret = params?.secret;
|
|
47
|
+
if (secret !== undefined && secret.byteLength >= 17) {
|
|
48
|
+
secret = secret.subarray(1, 17);
|
|
49
|
+
}
|
|
50
|
+
let encryptKey = init.slice(8, 8 + 32);
|
|
44
51
|
const encryptIv = init.slice(40, 40 + 16);
|
|
52
|
+
if (secret) {
|
|
53
|
+
encryptKey = await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([encryptKey, secret]));
|
|
54
|
+
}
|
|
45
55
|
const importedEncryptedKey = await _1_utilities_js_1.CTR.importKey(encryptKey);
|
|
46
56
|
const encryptionCTR = new _1_utilities_js_1.CTR(importedEncryptedKey, encryptIv);
|
|
47
57
|
const encryptedInit = await encryptionCTR.call(init);
|
|
48
58
|
const initRev = new Uint8Array(init).reverse();
|
|
49
|
-
|
|
59
|
+
let decryptKey = initRev.slice(8, 8 + 32);
|
|
50
60
|
const decryptIv = initRev.slice(40, 40 + 16);
|
|
61
|
+
if (secret) {
|
|
62
|
+
decryptKey = await (0, _1_utilities_js_1.sha256)((0, _0_deps_js_1.concat)([decryptKey, secret]));
|
|
63
|
+
}
|
|
51
64
|
const importedDecryptKey = await _1_utilities_js_1.CTR.importKey(decryptKey);
|
|
52
65
|
const decryptionCTR = new _1_utilities_js_1.CTR(importedDecryptKey, decryptIv);
|
|
53
66
|
await connection.write((0, _0_deps_js_1.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"}
|
|
@@ -26,18 +26,24 @@ const _0_obfuscation_js_1 = require("./0_obfuscation.js");
|
|
|
26
26
|
const _0_transport_js_1 = require("./0_transport.js");
|
|
27
27
|
class TransportIntermediate extends _0_transport_js_1.Transport {
|
|
28
28
|
#connection;
|
|
29
|
-
#
|
|
30
|
-
|
|
29
|
+
#isObfuscated;
|
|
30
|
+
#isPadded;
|
|
31
|
+
#dcId;
|
|
32
|
+
#secret;
|
|
33
|
+
constructor(connection, params) {
|
|
31
34
|
super();
|
|
32
35
|
this.#connection = connection;
|
|
33
|
-
this.#
|
|
36
|
+
this.#isObfuscated = params?.isObfuscated ?? false;
|
|
37
|
+
this.#isPadded = params?.isPadded ?? false;
|
|
38
|
+
this.#dcId = params?.dcId;
|
|
39
|
+
this.#secret = params?.secret;
|
|
34
40
|
}
|
|
35
41
|
async initialize() {
|
|
36
|
-
if (this.#
|
|
37
|
-
this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEEEEEEEE, this.#connection);
|
|
42
|
+
if (this.#isObfuscated) {
|
|
43
|
+
this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(this.#isPadded ? 0xDDDDDDDD : 0xEEEEEEEE, this.#connection, { dcId: this.#dcId, secret: this.#secret });
|
|
38
44
|
}
|
|
39
45
|
else {
|
|
40
|
-
await this.#connection.write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
|
|
46
|
+
await this.#connection.write(new Uint8Array(this.#isPadded ? [0xDD, 0xDD, 0xDD, 0xDD] : [0xEE, 0xEE, 0xEE, 0xEE]));
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
async receive() {
|
|
@@ -54,6 +60,10 @@ class TransportIntermediate extends _0_transport_js_1.Transport {
|
|
|
54
60
|
return await this.decrypt(buffer);
|
|
55
61
|
}
|
|
56
62
|
async send(buffer) {
|
|
63
|
+
if (this.#isPadded) {
|
|
64
|
+
const padding = crypto.getRandomValues(new Uint8Array(Math.abs((0, _1_utilities_js_1.getRandomId)(true) % 16)));
|
|
65
|
+
buffer = (0, _0_deps_js_1.concat)([buffer, padding]);
|
|
66
|
+
}
|
|
57
67
|
const length = (0, _1_utilities_js_1.intToBytes)(buffer.length, 4);
|
|
58
68
|
const data = (0, _0_deps_js_1.concat)([length, buffer]);
|
|
59
69
|
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,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.transportProviderMtproxy = transportProviderMtproxy;
|
|
23
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
|
+
const _1_connection_tcp_js_1 = require("../connection/1_connection_tcp.js");
|
|
25
|
+
const _1_connection_tls_js_1 = require("../connection/1_connection_tls.js");
|
|
26
|
+
const _1_transport_intermediate_js_1 = require("./1_transport_intermediate.js");
|
|
27
|
+
const _1_transport_provider_js_1 = require("./1_transport_provider.js");
|
|
28
|
+
function transportProviderMtproxy(hostnameOrLink, port, secret) {
|
|
29
|
+
let hostname = hostnameOrLink;
|
|
30
|
+
if (port === undefined && secret === undefined) {
|
|
31
|
+
const url = new URL(hostnameOrLink);
|
|
32
|
+
const hostname_ = url.searchParams.get("server");
|
|
33
|
+
const port_ = url.searchParams.get("port");
|
|
34
|
+
const secret_ = url.searchParams.get("secret");
|
|
35
|
+
if (!hostname_ || !port_ || !secret_) {
|
|
36
|
+
throw new TypeError("Invalid MTProxy link.");
|
|
37
|
+
}
|
|
38
|
+
hostname = hostname_;
|
|
39
|
+
port = parseInt(port_);
|
|
40
|
+
secret = (0, _0_deps_js_1.decodeHex)(secret_);
|
|
41
|
+
if (isNaN(port) || port < 0 || port > 0xFFFF) {
|
|
42
|
+
throw new TypeError("Server port is invalid.");
|
|
43
|
+
}
|
|
44
|
+
if (secret.byteLength < 16) {
|
|
45
|
+
throw new TypeError("Proxy secret must be at least 16 bytes.");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return ({ dc, isCdn }) => {
|
|
49
|
+
const dcId = (0, _1_transport_provider_js_1.getDcId)(dc, isCdn);
|
|
50
|
+
const connection = secret.byteLength <= 17 ? new _1_connection_tcp_js_1.ConnectionTCP(hostname, port) : new _1_connection_tls_js_1.ConnectionTLS(hostname, port, secret);
|
|
51
|
+
const transport = new _1_transport_intermediate_js_1.TransportIntermediate(connection, { isPadded: true, isObfuscated: true, secret, dcId });
|
|
52
|
+
return { connection, transport, dcId };
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -39,8 +39,8 @@ const transportProviderWebSocket = (params) => {
|
|
|
39
39
|
params.wss ??= typeof location !== "undefined" && location.protocol === "http:" && location.hostname !== "localhost" ? false : true;
|
|
40
40
|
const url = `${params.wss ? "wss" : "ws"}://${dcToNameMap[dc]}${isCdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
41
41
|
const connection = new _2_connection_js_1.ConnectionWebSocket(url);
|
|
42
|
-
const transport = new _1_transport_intermediate_js_1.TransportIntermediate(connection, true);
|
|
43
42
|
const dcId = (0, _1_transport_provider_js_1.getDcId)(dc, isCdn);
|
|
43
|
+
const transport = new _1_transport_intermediate_js_1.TransportIntermediate(connection, { isObfuscated: true, dcId });
|
|
44
44
|
return { connection, transport, dcId };
|
|
45
45
|
};
|
|
46
46
|
};
|
|
@@ -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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.constructStarAmount = constructStarAmount;
|
|
23
|
+
function constructStarAmount(starsAmount) {
|
|
24
|
+
return {
|
|
25
|
+
amount: Number(starsAmount.amount),
|
|
26
|
+
nanos: Number(starsAmount.nanos),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -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,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.constructStarTransactionPeer = constructStarTransactionPeer;
|
|
23
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
|
+
function constructStarTransactionPeer(peer, getPeer) {
|
|
25
|
+
switch (peer._) {
|
|
26
|
+
case "starsTransactionPeerUnsupported":
|
|
27
|
+
return { type: "unsupported" };
|
|
28
|
+
case "starsTransactionPeerAppStore":
|
|
29
|
+
return { type: "appStore" };
|
|
30
|
+
case "starsTransactionPeerPlayMarket":
|
|
31
|
+
return { type: "playMarket" };
|
|
32
|
+
case "starsTransactionPeerPremiumBot":
|
|
33
|
+
return { type: "premiumBot" };
|
|
34
|
+
case "starsTransactionPeerFragment":
|
|
35
|
+
return { type: "fragment" };
|
|
36
|
+
case "starsTransactionPeer": {
|
|
37
|
+
const chat = getPeer(peer.peer)?.[0];
|
|
38
|
+
if (!chat) {
|
|
39
|
+
(0, _0_deps_js_1.unreachable)();
|
|
40
|
+
}
|
|
41
|
+
return { type: "chat", chat };
|
|
42
|
+
}
|
|
43
|
+
case "starsTransactionPeerAds":
|
|
44
|
+
return { type: "ads" };
|
|
45
|
+
case "starsTransactionPeerAPI":
|
|
46
|
+
return { type: "api" };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -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,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.constructStarTransaction = constructStarTransaction;
|
|
23
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
25
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
26
|
+
const _0_star_amount_js_1 = require("./0_star_amount.js");
|
|
27
|
+
const _2_star_transaction_peer_js_1 = require("./2_star_transaction_peer.js");
|
|
28
|
+
const _4_gift_js_1 = require("./4_gift.js");
|
|
29
|
+
function constructStarTransaction(starTransaction, getPeer) {
|
|
30
|
+
let starrefChat;
|
|
31
|
+
if (starTransaction.starref_peer) {
|
|
32
|
+
starrefChat = getPeer(starTransaction.starref_peer)?.[0];
|
|
33
|
+
if (!starrefChat) {
|
|
34
|
+
(0, _0_deps_js_1.unreachable)();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return (0, _1_utilities_js_1.cleanObject)({
|
|
38
|
+
isRefund: starTransaction.refund ?? false,
|
|
39
|
+
isPending: starTransaction.pending ?? false,
|
|
40
|
+
isFailed: starTransaction.failed ?? false,
|
|
41
|
+
isGift: starTransaction.gift ?? false,
|
|
42
|
+
isReaction: starTransaction.reaction ?? false,
|
|
43
|
+
isGiftUpgrade: starTransaction.stargift_upgrade ?? false,
|
|
44
|
+
isBusinessTransfer: starTransaction.business_transfer ?? false,
|
|
45
|
+
isGiftResale: starTransaction.stargift_resale ?? false,
|
|
46
|
+
isPostSearch: starTransaction.posts_search ?? false,
|
|
47
|
+
isGiftPrepaidUpgrade: starTransaction.stargift_prepaid_upgrade ?? false,
|
|
48
|
+
isGiftDetailDrop: starTransaction.stargift_drop_original_details ?? false,
|
|
49
|
+
isPhoneGroupMessage: starTransaction.phonegroup_message ?? false,
|
|
50
|
+
isGiftAuctionBid: starTransaction.stargift_auction_bid ?? false,
|
|
51
|
+
isOffer: starTransaction.offer ?? false,
|
|
52
|
+
id: starTransaction.id,
|
|
53
|
+
amount: (0, _0_star_amount_js_1.constructStarAmount)(_2_tl_js_1.Api.as("starsAmount", starTransaction.amount)),
|
|
54
|
+
date: starTransaction.date,
|
|
55
|
+
peer: (0, _2_star_transaction_peer_js_1.constructStarTransactionPeer)(starTransaction.peer, getPeer),
|
|
56
|
+
title: starTransaction.title,
|
|
57
|
+
description: starTransaction.description,
|
|
58
|
+
transactionDate: starTransaction.transaction_date,
|
|
59
|
+
transactionUrl: starTransaction.transaction_url,
|
|
60
|
+
botPayload: new TextDecoder().decode(starTransaction.bot_payload),
|
|
61
|
+
messageId: starTransaction.msg_id,
|
|
62
|
+
subscriptionPeriod: starTransaction.subscription_period,
|
|
63
|
+
giveawayMessageId: starTransaction.giveaway_post_id,
|
|
64
|
+
gift: starTransaction.stargift ? (0, _4_gift_js_1.constructGift)(starTransaction.stargift, getPeer) : undefined,
|
|
65
|
+
broadcastNumber: starTransaction.floodskip_number,
|
|
66
|
+
starrefCommissionPerMille: starTransaction.starref_commission_permille,
|
|
67
|
+
starrefChat,
|
|
68
|
+
starrefAmount: starTransaction.starref_amount ? (0, _0_star_amount_js_1.constructStarAmount)(_2_tl_js_1.Api.as("starsAmount", starTransaction.starref_amount)) : undefined,
|
|
69
|
+
paidMessages: starTransaction.paid_messages,
|
|
70
|
+
premiumGiftMonthCount: starTransaction.premium_gift_months,
|
|
71
|
+
adsProceedsFromDate: starTransaction.ads_proceeds_from_date,
|
|
72
|
+
adsProceedsToDate: starTransaction.ads_proceeds_to_date,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2026 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.constructStarTransactionList = constructStarTransactionList;
|
|
23
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
24
|
+
const _5_star_transaction_js_1 = require("./5_star_transaction.js");
|
|
25
|
+
function constructStarTransactionList(result, getPeer) {
|
|
26
|
+
const transactions = result.history?.map((v) => (0, _5_star_transaction_js_1.constructStarTransaction)(v, getPeer)) ?? [];
|
|
27
|
+
return (0, _1_utilities_js_1.cleanObject)({
|
|
28
|
+
transactions,
|
|
29
|
+
nextOffset: result.next_offset,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -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"}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.CTR = void 0;
|
|
23
|
+
exports.hmacSha256 = hmacSha256;
|
|
23
24
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
24
25
|
const _0_int_js_1 = require("./0_int.js");
|
|
25
26
|
class CTR {
|
|
@@ -81,3 +82,7 @@ class CTR {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
exports.CTR = CTR;
|
|
85
|
+
async function hmacSha256(data, secret) {
|
|
86
|
+
const key = await crypto.subtle.importKey("raw", secret, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
87
|
+
return new Uint8Array(await crypto.subtle.sign("HMAC", key, data.buffer));
|
|
88
|
+
}
|