@mtkruto/browser 0.133.0 → 0.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/esm/0_deps.d.ts +1 -0
  2. package/esm/0_deps.d.ts.map +1 -1
  3. package/esm/0_deps.js +1 -0
  4. package/esm/1_utilities.d.ts +1 -0
  5. package/esm/1_utilities.d.ts.map +1 -1
  6. package/esm/1_utilities.js +1 -0
  7. package/esm/2_connection.d.ts +1 -0
  8. package/esm/2_connection.d.ts.map +1 -1
  9. package/esm/2_connection.js +1 -0
  10. package/esm/3_transport.d.ts +1 -0
  11. package/esm/3_transport.d.ts.map +1 -1
  12. package/esm/3_transport.js +1 -0
  13. package/esm/3_types.d.ts +1 -0
  14. package/esm/3_types.d.ts.map +1 -1
  15. package/esm/3_types.js +1 -0
  16. package/esm/client/0_params.d.ts +24 -2
  17. package/esm/client/0_params.d.ts.map +1 -1
  18. package/esm/client/0_utilities.d.ts +1 -1
  19. package/esm/client/0_utilities.d.ts.map +1 -1
  20. package/esm/client/1_client_generic.d.ts +11 -3
  21. package/esm/client/1_client_generic.d.ts.map +1 -1
  22. package/esm/client/3_message_manager.d.ts.map +1 -1
  23. package/esm/client/3_message_manager.js +13 -9
  24. package/esm/client/4_gift_manager.d.ts +3 -2
  25. package/esm/client/4_gift_manager.d.ts.map +1 -1
  26. package/esm/client/4_gift_manager.js +9 -0
  27. package/esm/client/4_poll_manager.js +1 -1
  28. package/esm/client/6_client.d.ts +11 -3
  29. package/esm/client/6_client.d.ts.map +1 -1
  30. package/esm/client/6_client.js +11 -1
  31. package/esm/client/6_client_dispatcher.d.ts +11 -3
  32. package/esm/client/6_client_dispatcher.d.ts.map +1 -1
  33. package/esm/client/6_client_dispatcher.js +11 -1
  34. package/esm/connection/1_connection_socks5.d.ts +36 -0
  35. package/esm/connection/1_connection_socks5.d.ts.map +1 -0
  36. package/esm/connection/1_connection_socks5.js +192 -0
  37. package/esm/connection/1_connection_socks5.node.d.ts +35 -0
  38. package/esm/connection/1_connection_socks5.node.d.ts.map +1 -0
  39. package/esm/connection/1_connection_socks5.node.js +214 -0
  40. package/esm/connection/1_connection_tcp.d.ts.map +1 -1
  41. package/esm/connection/1_connection_tcp.js +0 -1
  42. package/esm/deps/jsr.io/@std/net/1.0.6/unstable_ip.d.ts +103 -0
  43. package/esm/deps/jsr.io/@std/net/1.0.6/unstable_ip.d.ts.map +1 -0
  44. package/esm/deps/jsr.io/@std/net/1.0.6/unstable_ip.js +296 -0
  45. package/esm/tl/1_telegram_api.d.ts +1616 -10
  46. package/esm/tl/1_telegram_api.d.ts.map +1 -1
  47. package/esm/tl/1_telegram_api.js +333 -48
  48. package/esm/transport/2_transport_provider_mtproxy.d.ts +1 -1
  49. package/esm/transport/2_transport_provider_mtproxy.d.ts.map +1 -1
  50. package/esm/transport/2_transport_provider_mtproxy.js +3 -3
  51. package/esm/transport/2_transport_provider_socks5.d.ts +27 -0
  52. package/esm/transport/2_transport_provider_socks5.d.ts.map +1 -0
  53. package/esm/transport/2_transport_provider_socks5.js +45 -0
  54. package/esm/types/0_premium_subscription_duration.d.ts +21 -0
  55. package/esm/types/0_premium_subscription_duration.d.ts.map +1 -0
  56. package/esm/types/0_premium_subscription_duration.js +20 -0
  57. package/esm/types/3_poll_option.d.ts +1 -1
  58. package/esm/types/3_poll_option.d.ts.map +1 -1
  59. package/esm/types/3_poll_option.js +2 -1
  60. package/esm/types/4_poll.d.ts +3 -3
  61. package/esm/types/4_poll.d.ts.map +1 -1
  62. package/esm/types/4_poll.js +5 -3
  63. package/esm/types/5_star_transaction.js +2 -2
  64. package/esm/utilities/0_ip.d.ts +22 -0
  65. package/esm/utilities/0_ip.d.ts.map +1 -0
  66. package/esm/utilities/0_ip.js +73 -0
  67. package/package.json +1 -1
  68. package/script/0_deps.d.ts +1 -0
  69. package/script/0_deps.d.ts.map +1 -1
  70. package/script/0_deps.js +4 -1
  71. package/script/1_utilities.d.ts +1 -0
  72. package/script/1_utilities.d.ts.map +1 -1
  73. package/script/1_utilities.js +1 -0
  74. package/script/2_connection.d.ts +1 -0
  75. package/script/2_connection.d.ts.map +1 -1
  76. package/script/2_connection.js +1 -0
  77. package/script/3_transport.d.ts +1 -0
  78. package/script/3_transport.d.ts.map +1 -1
  79. package/script/3_transport.js +1 -0
  80. package/script/3_types.d.ts +1 -0
  81. package/script/3_types.d.ts.map +1 -1
  82. package/script/3_types.js +1 -0
  83. package/script/client/0_params.d.ts +24 -2
  84. package/script/client/0_params.d.ts.map +1 -1
  85. package/script/client/0_utilities.d.ts +1 -1
  86. package/script/client/0_utilities.d.ts.map +1 -1
  87. package/script/client/1_client_generic.d.ts +11 -3
  88. package/script/client/1_client_generic.d.ts.map +1 -1
  89. package/script/client/3_message_manager.d.ts.map +1 -1
  90. package/script/client/3_message_manager.js +13 -9
  91. package/script/client/4_gift_manager.d.ts +3 -2
  92. package/script/client/4_gift_manager.d.ts.map +1 -1
  93. package/script/client/4_gift_manager.js +9 -0
  94. package/script/client/4_poll_manager.js +1 -1
  95. package/script/client/6_client.d.ts +11 -3
  96. package/script/client/6_client.d.ts.map +1 -1
  97. package/script/client/6_client.js +11 -1
  98. package/script/client/6_client_dispatcher.d.ts +11 -3
  99. package/script/client/6_client_dispatcher.d.ts.map +1 -1
  100. package/script/client/6_client_dispatcher.js +11 -1
  101. package/script/connection/1_connection_socks5.d.ts +36 -0
  102. package/script/connection/1_connection_socks5.d.ts.map +1 -0
  103. package/script/connection/1_connection_socks5.js +196 -0
  104. package/script/connection/1_connection_socks5.node.d.ts +35 -0
  105. package/script/connection/1_connection_socks5.node.d.ts.map +1 -0
  106. package/script/connection/1_connection_socks5.node.js +218 -0
  107. package/script/connection/1_connection_tcp.d.ts.map +1 -1
  108. package/script/connection/1_connection_tcp.js +0 -1
  109. package/script/deps/jsr.io/@std/net/1.0.6/unstable_ip.d.ts +103 -0
  110. package/script/deps/jsr.io/@std/net/1.0.6/unstable_ip.d.ts.map +1 -0
  111. package/script/deps/jsr.io/@std/net/1.0.6/unstable_ip.js +303 -0
  112. package/script/tl/1_telegram_api.d.ts +1616 -10
  113. package/script/tl/1_telegram_api.d.ts.map +1 -1
  114. package/script/tl/1_telegram_api.js +333 -48
  115. package/script/transport/2_transport_provider_mtproxy.d.ts +1 -1
  116. package/script/transport/2_transport_provider_mtproxy.d.ts.map +1 -1
  117. package/script/transport/2_transport_provider_mtproxy.js +3 -3
  118. package/script/transport/2_transport_provider_socks5.d.ts +27 -0
  119. package/script/transport/2_transport_provider_socks5.d.ts.map +1 -0
  120. package/script/transport/2_transport_provider_socks5.js +48 -0
  121. package/script/types/0_premium_subscription_duration.d.ts +21 -0
  122. package/script/types/0_premium_subscription_duration.d.ts.map +1 -0
  123. package/script/types/0_premium_subscription_duration.js +21 -0
  124. package/script/types/3_poll_option.d.ts +1 -1
  125. package/script/types/3_poll_option.d.ts.map +1 -1
  126. package/script/types/3_poll_option.js +2 -1
  127. package/script/types/4_poll.d.ts +3 -3
  128. package/script/types/4_poll.d.ts.map +1 -1
  129. package/script/types/4_poll.js +5 -3
  130. package/script/types/5_star_transaction.js +1 -1
  131. package/script/utilities/0_ip.d.ts +22 -0
  132. package/script/utilities/0_ip.d.ts.map +1 -0
  133. package/script/utilities/0_ip.js +77 -0
@@ -18,6 +18,6 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { type TransportProvider } from "./1_transport_provider.js";
21
- export declare function transportProviderMtproxy(link: string): TransportProvider;
21
+ export declare function transportProviderMtproxy(url: string): TransportProvider;
22
22
  export declare function transportProviderMtproxy(hostname: string, port: number, secret: Uint8Array<ArrayBuffer>): TransportProvider;
23
23
  //# sourceMappingURL=2_transport_provider_mtproxy.d.ts.map
@@ -1 +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"}
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,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;AACzE,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,iBAAiB,CAAC"}
@@ -25,10 +25,10 @@ const _1_connection_tcp_js_1 = require("../connection/1_connection_tcp.js");
25
25
  const _1_connection_tls_js_1 = require("../connection/1_connection_tls.js");
26
26
  const _1_transport_intermediate_js_1 = require("./1_transport_intermediate.js");
27
27
  const _1_transport_provider_js_1 = require("./1_transport_provider.js");
28
- function transportProviderMtproxy(hostnameOrLink, port, secret) {
29
- let hostname = hostnameOrLink;
28
+ function transportProviderMtproxy(urlOrHostname, port, secret) {
29
+ let hostname = urlOrHostname;
30
30
  if (port === undefined && secret === undefined) {
31
- const url = new URL(hostnameOrLink);
31
+ const url = new URL(urlOrHostname);
32
32
  const hostname_ = url.searchParams.get("server");
33
33
  const port_ = url.searchParams.get("port");
34
34
  const secret_ = url.searchParams.get("secret");
@@ -0,0 +1,27 @@
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 interface TransportProviderSocks5Params {
22
+ username: string;
23
+ password: string;
24
+ }
25
+ export declare function transportProviderSocks5(url: string): TransportProvider;
26
+ export declare function transportProviderSocks5(hostname: string, port: number, params?: TransportProviderSocks5Params): TransportProvider;
27
+ //# sourceMappingURL=2_transport_provider_socks5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2_transport_provider_socks5.d.ts","sourceRoot":"","sources":["../../src/transport/2_transport_provider_socks5.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;AACxE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,6BAA6B,GAAG,iBAAiB,CAAC"}
@@ -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.transportProviderSocks5 = transportProviderSocks5;
23
+ const _1_connection_socks5_node_js_1 = require("../connection/1_connection_socks5.node.js");
24
+ const _0_deps_js_1 = require("../0_deps.js");
25
+ const _1_transport_abridged_js_1 = require("./1_transport_abridged.js");
26
+ const _1_transport_provider_js_1 = require("./1_transport_provider.js");
27
+ function transportProviderSocks5(urlOrHostname, port, params) {
28
+ let hostname = urlOrHostname;
29
+ if (port === undefined && params === undefined) {
30
+ const url = new URL(urlOrHostname);
31
+ const hostname_ = url.hostname;
32
+ const port_ = url.port || "1080";
33
+ const username = url.username;
34
+ const password = url.password;
35
+ if (!hostname_ || !port_) {
36
+ throw new TypeError("Invalid SOCKS5 URL.");
37
+ }
38
+ hostname = hostname_;
39
+ port = parseInt(port_);
40
+ params = { ...(params ?? {}), username, password };
41
+ }
42
+ return ({ dc, isCdn }) => {
43
+ const dcId = (0, _1_transport_provider_js_1.getDcId)(dc, isCdn);
44
+ const connection = new _1_connection_socks5_node_js_1.ConnectionSocks5((0, _1_transport_provider_js_1.getDcIps)(dc, (0, _0_deps_js_1.isIPv6)(hostname) ? "ipv6" : "ipv4")[0], 80, hostname, port, params);
45
+ const transport = new _1_transport_abridged_js_1.TransportAbridged(connection, false);
46
+ return { connection, transport, dcId };
47
+ };
48
+ }
@@ -0,0 +1,21 @@
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 type PremiumSubscriptionDuration = 3 | 6 | 12;
21
+ //# sourceMappingURL=0_premium_subscription_duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_premium_subscription_duration.d.ts","sourceRoot":"","sources":["../../src/types/0_premium_subscription_duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC"}
@@ -0,0 +1,21 @@
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 });
@@ -17,7 +17,7 @@
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
- import type { Api } from "../2_tl.js";
20
+ import { Api } from "../2_tl.js";
21
21
  import { type MessageEntity } from "./2_message_entity.js";
22
22
  /** A poll option. */
23
23
  export interface PollOption {
@@ -1 +1 @@
1
- {"version":3,"file":"3_poll_option.d.ts","sourceRoot":"","sources":["../../src/types/3_poll_option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEnF,qBAAqB;AACrB,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAQ5G"}
1
+ {"version":3,"file":"3_poll_option.d.ts","sourceRoot":"","sources":["../../src/types/3_poll_option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEnF,qBAAqB;AACrB,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAQ5G"}
@@ -20,9 +20,10 @@
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.constructPollOption = constructPollOption;
23
+ const _2_tl_js_1 = require("../2_tl.js");
23
24
  const _2_message_entity_js_1 = require("./2_message_entity.js");
24
25
  function constructPollOption(option, results) {
25
- const result = results.find((v) => v.option.every((v, i) => option.option[i] === v));
26
+ const result = results.find((v) => v.option.every((v, i) => _2_tl_js_1.Api.as("pollAnswer", option).option[i] === v));
26
27
  return {
27
28
  text: option.text.text,
28
29
  entities: option.text.entities?.map(_2_message_entity_js_1.constructMessageEntity).filter((v) => v !== null),
@@ -17,7 +17,7 @@
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
- import type { Api } from "../2_tl.js";
20
+ import { Api } from "../2_tl.js";
21
21
  import { type MessageEntity } from "./2_message_entity.js";
22
22
  import { type PollOption } from "./3_poll_option.js";
23
23
  /** A poll. */
@@ -40,8 +40,8 @@ export interface Poll {
40
40
  type: "regular" | "quiz";
41
41
  /** Whether the poll allows multiple answers. */
42
42
  allowMultipleAnswers?: boolean;
43
- /** Index of the correct option. */
44
- correctOptionIndex?: number;
43
+ /** The indexes of correct options. */
44
+ correctOptionIndexes?: number[];
45
45
  /** A text that is shown to the user when the poll is answered. */
46
46
  explanation?: string;
47
47
  /** The explanation's entities. */
@@ -1 +1 @@
1
- {"version":3,"file":"4_poll.d.ts","sourceRoot":"","sources":["../../src/types/4_poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1E,cAAc;AACd,MAAM,WAAW,IAAI;IACnB,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,gBAAgB,EAAE,aAAa,EAAE,CAAC;IAClC,0BAA0B;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,4BAA4B;IAC5B,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mCAAmC;IACnC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;IACtC,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAoBhE"}
1
+ {"version":3,"file":"4_poll.d.ts","sourceRoot":"","sources":["../../src/types/4_poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1E,cAAc;AACd,MAAM,WAAW,IAAI;IACnB,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,gBAAgB,EAAE,aAAa,EAAE,CAAC;IAClC,0BAA0B;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,4BAA4B;IAC5B,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;IACtC,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAoBhE"}
@@ -20,13 +20,15 @@
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.constructPoll = constructPoll;
23
+ const _0_deps_js_1 = require("../0_deps.js");
23
24
  const _1_utilities_js_1 = require("../1_utilities.js");
25
+ const _2_tl_js_1 = require("../2_tl.js");
24
26
  const _2_message_entity_js_1 = require("./2_message_entity.js");
25
27
  const _3_poll_option_js_1 = require("./3_poll_option.js");
26
28
  function constructPoll(media_) {
27
29
  const poll = media_.poll;
28
- const correctOption = media_.results.results?.find((v) => v.correct)?.option;
29
- const correctOptionIndex = correctOption !== undefined ? poll.answers.findIndex((v) => v.option.every((v, i) => correctOption[i] === v)) : undefined;
30
+ const correctOptions = media_.results.results?.filter((v) => v.correct).map((v) => v.option);
31
+ const correctOptionIndexes = correctOptions !== undefined ? poll.answers.filter((v) => correctOptions.some((v_) => (0, _0_deps_js_1.equals)(v_, _2_tl_js_1.Api.as("pollAnswer", v).option))).map((_, i) => i) : undefined;
30
32
  return (0, _1_utilities_js_1.cleanObject)({
31
33
  id: String(poll.id),
32
34
  question: poll.question.text,
@@ -37,7 +39,7 @@ function constructPoll(media_) {
37
39
  isAnonymous: !poll.public_voters,
38
40
  type: poll.quiz ? "quiz" : "regular",
39
41
  allowMultipleAnswers: poll.quiz ? undefined : poll.multiple_choice || false,
40
- correctOptionIndex,
42
+ correctOptionIndexes,
41
43
  explanation: media_.results.solution,
42
44
  explanationEntities: media_.results.solution_entities?.map(_2_message_entity_js_1.constructMessageEntity).filter((v) => v !== null),
43
45
  openPeriod: poll.close_period,
@@ -57,7 +57,7 @@ function constructStarTransaction(starTransaction, getPeer) {
57
57
  description: starTransaction.description,
58
58
  transactionDate: starTransaction.transaction_date,
59
59
  transactionUrl: starTransaction.transaction_url,
60
- botPayload: new TextDecoder().decode(starTransaction.bot_payload),
60
+ botPayload: starTransaction.bot_payload ? (0, _1_utilities_js_1.decodeText)(starTransaction.bot_payload) : undefined,
61
61
  messageId: starTransaction.msg_id,
62
62
  subscriptionPeriod: starTransaction.subscription_period,
63
63
  giveawayMessageId: starTransaction.giveaway_post_id,
@@ -0,0 +1,22 @@
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 declare function ipv4ToBytes(ipv4: string): number[];
21
+ export declare function ipv6ToBytes(ipv6: string): number[];
22
+ //# sourceMappingURL=0_ip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_ip.d.ts","sourceRoot":"","sources":["../../src/utilities/0_ip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAElD;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAOlD"}
@@ -0,0 +1,77 @@
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.ipv4ToBytes = ipv4ToBytes;
23
+ exports.ipv6ToBytes = ipv6ToBytes;
24
+ function ipv4ToBytes(ipv4) {
25
+ return ipv4.split(".").map(Number);
26
+ }
27
+ // https://jsr.io/@std/net/1.0.6/unstable_ip.ts
28
+ function ipv6ToBytes(ipv6) {
29
+ const expandedIpv6 = expandIpv6(ipv6);
30
+ if (expandedIpv6 === null) {
31
+ throw new TypeError("Invalid IPv6");
32
+ }
33
+ return expandedIpv6ToBytes(expandedIpv6);
34
+ }
35
+ function expandIpv6(addr) {
36
+ if (addr.includes(".")) {
37
+ const parts = addr.split(":");
38
+ const ipv4Part = parts.pop();
39
+ if (!ipv4Part) {
40
+ return null;
41
+ }
42
+ const ipv4Bytes = ipv4Part.split(".").map(Number);
43
+ if (ipv4Bytes.length !== 4) {
44
+ return null;
45
+ }
46
+ const ipv4Hex = ((ipv4Bytes[0] << 8) | ipv4Bytes[1]).toString(16).padStart(4, "0") +
47
+ ":" +
48
+ ((ipv4Bytes[2] << 8) | ipv4Bytes[3]).toString(16).padStart(4, "0");
49
+ addr = parts.join(":") + ":" + ipv4Hex;
50
+ }
51
+ let expanded = addr;
52
+ // Handle ::
53
+ if (expanded.includes("::")) {
54
+ const parts = expanded.split("::");
55
+ const leftParts = parts[0] ? parts[0].split(":") : [];
56
+ const rightParts = parts[1] ? parts[1].split(":") : [];
57
+ const missingParts = 8 - leftParts.length - rightParts.length;
58
+ expanded = leftParts
59
+ .concat(new Array(missingParts).fill("0"))
60
+ .concat(rightParts)
61
+ .join(":");
62
+ }
63
+ // Pad each hextet to 4 digits
64
+ return expanded
65
+ .split(":")
66
+ .map((hextet) => hextet.padStart(4, "0"))
67
+ .join(":");
68
+ }
69
+ function expandedIpv6ToBytes(expandedIPv6) {
70
+ const hextets = expandedIPv6.split(":");
71
+ const bytes = [];
72
+ for (const hextet of hextets) {
73
+ const value = parseInt(hextet, 16);
74
+ bytes.push((value >> 8) & 0xff, value & 0xff);
75
+ }
76
+ return bytes;
77
+ }