@mtkruto/node 0.2.10 → 0.2.20
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/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_filters.d.ts +1 -1
- package/esm/client/0_filters.d.ts.map +1 -1
- package/esm/client/0_html.js +1 -1
- package/esm/client/0_message.d.ts +1 -1
- package/esm/client/0_message.d.ts.map +1 -1
- package/esm/client/0_message.js +2 -2
- package/esm/client/0_params.d.ts +9 -6
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_storage_operations.d.ts +1 -1
- package/esm/client/0_storage_operations.d.ts.map +1 -1
- package/esm/client/1_client_encrypted.d.ts.map +1 -1
- package/esm/client/1_client_encrypted.js +66 -6
- package/esm/client/1_client_plain.js +1 -1
- package/esm/client/1_types.d.ts +1 -1
- package/esm/client/1_types.d.ts.map +1 -1
- package/esm/client/2_business_connection_manager.d.ts +3 -1
- package/esm/client/2_business_connection_manager.d.ts.map +1 -1
- package/esm/client/2_business_connection_manager.js +5 -3
- package/esm/client/2_payment_manager.d.ts +35 -0
- package/esm/client/2_payment_manager.d.ts.map +1 -0
- package/esm/client/2_payment_manager.js +68 -0
- package/esm/client/2_reaction_manager.d.ts +2 -1
- package/esm/client/2_reaction_manager.d.ts.map +1 -1
- package/esm/client/2_reaction_manager.js +8 -7
- package/esm/client/3_message_manager.d.ts +2 -1
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +15 -12
- package/esm/client/3_video_chat_manager.d.ts +2 -1
- package/esm/client/3_video_chat_manager.d.ts.map +1 -1
- package/esm/client/3_video_chat_manager.js +5 -2
- package/esm/client/4_callback_query_manager.d.ts +2 -1
- package/esm/client/4_callback_query_manager.d.ts.map +1 -1
- package/esm/client/4_callback_query_manager.js +6 -2
- package/esm/client/4_chat_list_manager.d.ts +2 -1
- package/esm/client/4_chat_list_manager.d.ts.map +1 -1
- package/esm/client/4_chat_list_manager.js +12 -2
- package/esm/client/4_inline_query_manager.d.ts +2 -1
- package/esm/client/4_inline_query_manager.d.ts.map +1 -1
- package/esm/client/4_inline_query_manager.js +6 -2
- package/esm/client/4_story_manager.d.ts +2 -1
- package/esm/client/4_story_manager.d.ts.map +1 -1
- package/esm/client/4_story_manager.js +5 -2
- package/esm/client/5_client.d.ts +21 -3
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +51 -20
- package/esm/connection/1_connection_tcp.node.d.ts +19 -0
- package/esm/connection/1_connection_tcp.node.d.ts.map +1 -1
- package/esm/connection/1_connection_tcp.node.js +22 -1
- package/esm/connection/1_connection_web_socket.d.ts.map +1 -1
- package/esm/connection/1_connection_web_socket.js +1 -0
- package/esm/tl/1_utilities.d.ts +1 -1
- package/esm/tl/1_utilities.d.ts.map +1 -1
- package/esm/tl/5_message.d.ts +1 -1
- package/esm/tl/5_message.d.ts.map +1 -1
- package/esm/tl/5_message.js +2 -2
- package/esm/types/0_invoice.d.ts +19 -0
- package/esm/types/0_invoice.d.ts.map +1 -1
- package/esm/types/0_invoice.js +19 -0
- package/esm/types/0_shipping_address.d.ts +31 -0
- package/esm/types/0_shipping_address.d.ts.map +1 -0
- package/esm/types/0_shipping_address.js +29 -0
- package/esm/types/1_order_info.d.ts +29 -0
- package/esm/types/1_order_info.d.ts.map +1 -0
- package/esm/types/1_order_info.js +29 -0
- package/esm/types/2_chat.d.ts +2 -2
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_chat.js +3 -3
- package/esm/types/2_pre_checkout_query.d.ts +34 -0
- package/esm/types/2_pre_checkout_query.d.ts.map +1 -0
- package/esm/types/2_pre_checkout_query.js +39 -0
- package/esm/types/2_successful_payment.d.ts +32 -0
- package/esm/types/2_successful_payment.d.ts.map +1 -0
- package/esm/types/2_successful_payment.js +32 -0
- package/esm/types/4_inline_query_result.d.ts +1 -1
- package/esm/types/4_inline_query_result.d.ts.map +1 -1
- package/esm/types/4_inline_query_result.js +2 -2
- package/esm/types/4_message.d.ts +11 -1
- package/esm/types/4_message.d.ts.map +1 -1
- package/esm/types/4_message.js +9 -0
- package/esm/types/6_update.d.ts +10 -3
- package/esm/types/6_update.d.ts.map +1 -1
- package/package.json +1 -1
- 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_filters.d.ts +1 -1
- package/script/client/0_filters.d.ts.map +1 -1
- package/script/client/0_html.js +1 -1
- package/script/client/0_message.d.ts +1 -1
- package/script/client/0_message.d.ts.map +1 -1
- package/script/client/0_message.js +2 -2
- package/script/client/0_params.d.ts +9 -6
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_storage_operations.d.ts +1 -1
- package/script/client/0_storage_operations.d.ts.map +1 -1
- package/script/client/1_client_encrypted.d.ts.map +1 -1
- package/script/client/1_client_encrypted.js +65 -5
- package/script/client/1_client_plain.js +1 -1
- package/script/client/1_types.d.ts +1 -1
- package/script/client/1_types.d.ts.map +1 -1
- package/script/client/2_business_connection_manager.d.ts +3 -1
- package/script/client/2_business_connection_manager.d.ts.map +1 -1
- package/script/client/2_business_connection_manager.js +6 -4
- package/script/client/2_payment_manager.d.ts +35 -0
- package/script/client/2_payment_manager.d.ts.map +1 -0
- package/script/client/2_payment_manager.js +72 -0
- package/script/client/2_reaction_manager.d.ts +2 -1
- package/script/client/2_reaction_manager.d.ts.map +1 -1
- package/script/client/2_reaction_manager.js +8 -7
- package/script/client/3_message_manager.d.ts +2 -1
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +14 -11
- package/script/client/3_video_chat_manager.d.ts +2 -1
- package/script/client/3_video_chat_manager.d.ts.map +1 -1
- package/script/client/3_video_chat_manager.js +4 -1
- package/script/client/4_callback_query_manager.d.ts +2 -1
- package/script/client/4_callback_query_manager.d.ts.map +1 -1
- package/script/client/4_callback_query_manager.js +6 -2
- package/script/client/4_chat_list_manager.d.ts +2 -1
- package/script/client/4_chat_list_manager.d.ts.map +1 -1
- package/script/client/4_chat_list_manager.js +11 -1
- package/script/client/4_inline_query_manager.d.ts +2 -1
- package/script/client/4_inline_query_manager.d.ts.map +1 -1
- package/script/client/4_inline_query_manager.js +5 -1
- package/script/client/4_story_manager.d.ts +2 -1
- package/script/client/4_story_manager.d.ts.map +1 -1
- package/script/client/4_story_manager.js +4 -1
- package/script/client/5_client.d.ts +21 -3
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +51 -20
- package/script/connection/1_connection_tcp.node.d.ts +19 -0
- package/script/connection/1_connection_tcp.node.d.ts.map +1 -1
- package/script/connection/1_connection_tcp.node.js +22 -1
- package/script/connection/1_connection_web_socket.d.ts.map +1 -1
- package/script/connection/1_connection_web_socket.js +1 -0
- package/script/tl/1_utilities.d.ts +1 -1
- package/script/tl/1_utilities.d.ts.map +1 -1
- package/script/tl/5_message.d.ts +1 -1
- package/script/tl/5_message.d.ts.map +1 -1
- package/script/tl/5_message.js +2 -2
- package/script/types/0_invoice.d.ts +19 -0
- package/script/types/0_invoice.d.ts.map +1 -1
- package/script/types/0_invoice.js +19 -0
- package/script/types/0_shipping_address.d.ts +31 -0
- package/script/types/0_shipping_address.d.ts.map +1 -0
- package/script/types/0_shipping_address.js +33 -0
- package/script/types/1_order_info.d.ts +29 -0
- package/script/types/1_order_info.d.ts.map +1 -0
- package/script/types/1_order_info.js +33 -0
- package/script/types/2_chat.d.ts +2 -2
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_chat.js +3 -3
- package/script/types/2_pre_checkout_query.d.ts +34 -0
- package/script/types/2_pre_checkout_query.d.ts.map +1 -0
- package/script/types/2_pre_checkout_query.js +43 -0
- package/script/types/2_successful_payment.d.ts +32 -0
- package/script/types/2_successful_payment.d.ts.map +1 -0
- package/script/types/2_successful_payment.js +36 -0
- package/script/types/4_inline_query_result.d.ts +1 -1
- package/script/types/4_inline_query_result.d.ts.map +1 -1
- package/script/types/4_inline_query_result.js +2 -2
- package/script/types/4_message.d.ts +11 -1
- package/script/types/4_message.d.ts.map +1 -1
- package/script/types/4_message.js +9 -0
- package/script/types/6_update.d.ts +10 -3
- package/script/types/6_update.d.ts.map +1 -1
package/esm/client/5_client.js
CHANGED
|
@@ -28,35 +28,36 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
28
28
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
29
29
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
30
|
};
|
|
31
|
-
var _Client_instances, _a, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_videoChatManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_publicKeys, _Client_ignoreOutgoing, _Client_persistCache, _Client_cdn, _Client_LsignIn, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_getApiId, _Client_getCdnConnectionPool, _Client_getCdnConnection, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastConnect, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId,
|
|
31
|
+
var _Client_instances, _a, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_videoChatManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_paymentManager, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_publicKeys, _Client_ignoreOutgoing, _Client_persistCache, _Client_cdn, _Client_LsignIn, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_getApiId, _Client_getCdnConnectionPool, _Client_getCdnConnection, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectMutex, _Client_lastConnect, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
|
|
32
32
|
import { unreachable } from "../0_deps.js";
|
|
33
33
|
import { AccessError, ConnectionError, InputError } from "../0_errors.js";
|
|
34
34
|
import { cleanObject, drop, getLogger, getRandomId, minute, mustPrompt, mustPromptOneOf, Mutex, second, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
35
|
-
import { as, chatIdToPeerId, getChatIdPeerType, is, peerToChatId } from "../2_tl.js";
|
|
36
35
|
import { StorageMemory } from "../2_storage.js";
|
|
36
|
+
import { as, chatIdToPeerId, getChatIdPeerType, is, peerToChatId } from "../2_tl.js";
|
|
37
37
|
import { constructUser } from "../3_types.js";
|
|
38
38
|
import { APP_VERSION, DEVICE_MODEL, LANG_CODE, LANG_PACK, LAYER, MAX_CHANNEL_ID, MAX_CHAT_ID, SYSTEM_LANG_CODE, SYSTEM_VERSION, USERNAME_TTL } from "../4_constants.js";
|
|
39
39
|
import { AuthKeyUnregistered, ConnectionNotInited, FloodWait, Migrate, PasswordHashInvalid, PhoneNumberInvalid, SessionPasswordNeeded } from "../4_errors.js";
|
|
40
|
+
import { PhoneCodeInvalid } from "../4_errors.js";
|
|
40
41
|
import { checkPassword } from "./0_password.js";
|
|
42
|
+
import { StorageOperations } from "./0_storage_operations.js";
|
|
41
43
|
import { getUsername, isMtprotoFunction, resolve } from "./0_utilities.js";
|
|
42
|
-
import { AccountManager } from "./2_account_manager.js";
|
|
43
|
-
import { BotInfoManager } from "./2_bot_info_manager.js";
|
|
44
|
-
import { BusinessConnectionManager } from "./2_business_connection_manager.js";
|
|
45
44
|
import { ClientEncrypted } from "./1_client_encrypted.js";
|
|
46
45
|
import { ClientPlain } from "./1_client_plain.js";
|
|
47
46
|
import { Composer as Composer_ } from "./1_composer.js";
|
|
47
|
+
import { AccountManager } from "./2_account_manager.js";
|
|
48
|
+
import { BotInfoManager } from "./2_bot_info_manager.js";
|
|
49
|
+
import { BusinessConnectionManager } from "./2_business_connection_manager.js";
|
|
48
50
|
import { FileManager } from "./2_file_manager.js";
|
|
49
51
|
import { NetworkStatisticsManager } from "./2_network_statistics_manager.js";
|
|
52
|
+
import { PaymentManager } from "./2_payment_manager.js";
|
|
50
53
|
import { ReactionManager } from "./2_reaction_manager.js";
|
|
51
54
|
import { UpdateManager } from "./2_update_manager.js";
|
|
52
55
|
import { MessageManager } from "./3_message_manager.js";
|
|
56
|
+
import { VideoChatManager } from "./3_video_chat_manager.js";
|
|
53
57
|
import { CallbackQueryManager } from "./4_callback_query_manager.js";
|
|
54
58
|
import { ChatListManager } from "./4_chat_list_manager.js";
|
|
55
59
|
import { InlineQueryManager } from "./4_inline_query_manager.js";
|
|
56
60
|
import { StoryManager } from "./4_story_manager.js";
|
|
57
|
-
import { VideoChatManager } from "./3_video_chat_manager.js";
|
|
58
|
-
import { StorageOperations } from "./0_storage_operations.js";
|
|
59
|
-
import { PhoneCodeInvalid } from "../4_errors.js";
|
|
60
61
|
export class Composer extends Composer_ {
|
|
61
62
|
}
|
|
62
63
|
function skipInvoke() {
|
|
@@ -92,6 +93,7 @@ export class Client extends Composer {
|
|
|
92
93
|
_Client_inlineQueryManager.set(this, void 0);
|
|
93
94
|
_Client_chatListManager.set(this, void 0);
|
|
94
95
|
_Client_accountManager.set(this, void 0);
|
|
96
|
+
_Client_paymentManager.set(this, void 0);
|
|
95
97
|
_Client_storage_.set(this, void 0);
|
|
96
98
|
_Client_messageStorage_.set(this, void 0);
|
|
97
99
|
Object.defineProperty(this, "storage", {
|
|
@@ -196,7 +198,7 @@ export class Client extends Composer {
|
|
|
196
198
|
};
|
|
197
199
|
const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : "chatMember" in update ? update.chatMember.chat : undefined;
|
|
198
200
|
const chat = chat_ ?? msg?.chat;
|
|
199
|
-
const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "message" in update ? update.message.from : "editedMessage" in update ? update.editedMessage?.from : "chatMember" in update ? update.chatMember.from : "messageReactions" in update ? update.messageReactions.user : undefined;
|
|
201
|
+
const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "message" in update ? update.message.from : "editedMessage" in update ? update.editedMessage?.from : "chatMember" in update ? update.chatMember.from : "messageReactions" in update ? update.messageReactions.user : "preCheckoutQuery" in update ? update.preCheckoutQuery.from : undefined;
|
|
200
202
|
const senderChat = msg?.senderChat;
|
|
201
203
|
const getReplyToMessageId = (quote, chatId, messageId) => {
|
|
202
204
|
const isPrivate = chatId > 0;
|
|
@@ -496,6 +498,12 @@ export class Client extends Composer {
|
|
|
496
498
|
}
|
|
497
499
|
return this.getBusinessConnection(businessConnectionId);
|
|
498
500
|
},
|
|
501
|
+
answerPreCheckoutQuery: (ok, params) => {
|
|
502
|
+
if (!("preCheckoutQuery" in update)) {
|
|
503
|
+
unreachable();
|
|
504
|
+
}
|
|
505
|
+
return this.answerPreCheckoutQuery(update.preCheckoutQuery.id, ok, params);
|
|
506
|
+
},
|
|
499
507
|
};
|
|
500
508
|
return cleanObject(context);
|
|
501
509
|
});
|
|
@@ -511,7 +519,6 @@ export class Client extends Composer {
|
|
|
511
519
|
_Client_lastConnect.set(this, null);
|
|
512
520
|
_Client_connectionInited.set(this, false);
|
|
513
521
|
_Client_lastPropagatedAuthorizationState.set(this, null);
|
|
514
|
-
_Client_pingLoopStarted.set(this, false);
|
|
515
522
|
_Client_pingLoopAbortController.set(this, null);
|
|
516
523
|
_Client_pingInterval.set(this, 1 * minute);
|
|
517
524
|
_Client_lastUpdates.set(this, new Date());
|
|
@@ -640,6 +647,7 @@ export class Client extends Composer {
|
|
|
640
647
|
__classPrivateFieldSet(this, _Client_inlineQueryManager, new InlineQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
641
648
|
__classPrivateFieldSet(this, _Client_chatListManager, new ChatListManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
642
649
|
__classPrivateFieldSet(this, _Client_accountManager, new AccountManager(c), "f");
|
|
650
|
+
__classPrivateFieldSet(this, _Client_paymentManager, new PaymentManager(c), "f");
|
|
643
651
|
__classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
|
|
644
652
|
const transportProvider = __classPrivateFieldGet(this, _Client_client, "f").transportProvider;
|
|
645
653
|
__classPrivateFieldGet(this, _Client_client, "f").transportProvider = (params) => {
|
|
@@ -662,6 +670,9 @@ export class Client extends Composer {
|
|
|
662
670
|
}
|
|
663
671
|
return true;
|
|
664
672
|
}
|
|
673
|
+
else if (is("bad_msg_notification", error)) {
|
|
674
|
+
return true;
|
|
675
|
+
}
|
|
665
676
|
else {
|
|
666
677
|
return next();
|
|
667
678
|
}
|
|
@@ -671,6 +682,7 @@ export class Client extends Composer {
|
|
|
671
682
|
if (connectionState != "notConnected") {
|
|
672
683
|
return next();
|
|
673
684
|
}
|
|
685
|
+
__classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.abort();
|
|
674
686
|
if (this.disconnected) {
|
|
675
687
|
L.debug("not reconnecting");
|
|
676
688
|
return next();
|
|
@@ -779,6 +791,7 @@ export class Client extends Composer {
|
|
|
779
791
|
await __classPrivateFieldGet(this, _Client_client, "f").connect();
|
|
780
792
|
__classPrivateFieldSet(this, _Client_lastConnect, new Date(), "f");
|
|
781
793
|
await Promise.all([this.storage.setAuthKey(__classPrivateFieldGet(this, _Client_client, "f").authKey), this.storage.setDc(__classPrivateFieldGet(this, _Client_client, "f").dc), this.storage.setServerSalt(__classPrivateFieldGet(this, _Client_client, "f").serverSalt)]);
|
|
794
|
+
__classPrivateFieldGet(this, _Client_instances, "m", _Client_startPingLoop).call(this);
|
|
782
795
|
}
|
|
783
796
|
finally {
|
|
784
797
|
unlock();
|
|
@@ -790,7 +803,7 @@ export class Client extends Composer {
|
|
|
790
803
|
}
|
|
791
804
|
await __classPrivateFieldGet(this, _Client_client, "f").reconnect();
|
|
792
805
|
}
|
|
793
|
-
async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_storage_ = new WeakMap(), _Client_messageStorage_ = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_apiId = new WeakMap(), _Client_apiHash = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_persistCache = new WeakMap(), _Client_cdn = new WeakMap(), _Client_LsignIn = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_lastConnect = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(),
|
|
806
|
+
async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_paymentManager = new WeakMap(), _Client_storage_ = new WeakMap(), _Client_messageStorage_ = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_apiId = new WeakMap(), _Client_apiHash = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_persistCache = new WeakMap(), _Client_cdn = new WeakMap(), _Client_LsignIn = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectMutex = new WeakMap(), _Client_lastConnect = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
|
|
794
807
|
const apiId = __classPrivateFieldGet(this, _Client_apiId, "f") || await this.storage.getApiId();
|
|
795
808
|
if (!apiId) {
|
|
796
809
|
throw new InputError("apiId not set");
|
|
@@ -888,7 +901,6 @@ export class Client extends Composer {
|
|
|
888
901
|
async disconnect() {
|
|
889
902
|
__classPrivateFieldSet(this, _Client_connectionInited, false, "f");
|
|
890
903
|
await __classPrivateFieldGet(this, _Client_client, "f").disconnect();
|
|
891
|
-
__classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.abort();
|
|
892
904
|
}
|
|
893
905
|
/**
|
|
894
906
|
* Signs in using the provided parameters if not already signed in.
|
|
@@ -1163,10 +1175,12 @@ export class Client extends Composer {
|
|
|
1163
1175
|
if (!this.connected) {
|
|
1164
1176
|
continue;
|
|
1165
1177
|
}
|
|
1166
|
-
__classPrivateFieldGet(this, _Client_pingLoopAbortController, "f").signal.throwIfAborted();
|
|
1167
1178
|
await this.invoke({ _: "ping_delay_disconnect", ping_id: getRandomId(), disconnect_delay: __classPrivateFieldGet(this, _Client_pingInterval, "f") / second + 15 });
|
|
1179
|
+
__classPrivateFieldGet(this, _Client_pingLoopAbortController, "f").signal.throwIfAborted();
|
|
1168
1180
|
if (Date.now() - __classPrivateFieldGet(this, _Client_lastUpdates, "f").getTime() >= 15 * minute) {
|
|
1169
|
-
drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates"))
|
|
1181
|
+
drop(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("lastUpdates").then(() => {
|
|
1182
|
+
__classPrivateFieldSet(this, _Client_lastUpdates, new Date(), "f");
|
|
1183
|
+
}));
|
|
1170
1184
|
}
|
|
1171
1185
|
}
|
|
1172
1186
|
catch (err) {
|
|
@@ -1216,12 +1230,6 @@ export class Client extends Composer {
|
|
|
1216
1230
|
throw err;
|
|
1217
1231
|
}
|
|
1218
1232
|
}
|
|
1219
|
-
finally {
|
|
1220
|
-
if (!__classPrivateFieldGet(this, _Client_pingLoopStarted, "f")) {
|
|
1221
|
-
__classPrivateFieldGet(this, _Client_instances, "m", _Client_startPingLoop).call(this);
|
|
1222
|
-
__classPrivateFieldSet(this, _Client_pingLoopStarted, true, "f");
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
1233
|
}
|
|
1226
1234
|
}, _Client_getUserAccessHash = async function _Client_getUserAccessHash(userId) {
|
|
1227
1235
|
const users = await this.invoke({ _: "users.getUsers", id: [{ _: "inputUser", user_id: userId, access_hash: 0n }] });
|
|
@@ -2386,6 +2394,29 @@ export class Client extends Composer {
|
|
|
2386
2394
|
async *downloadLiveStreamChunk(id, channelId, scale, timestamp, params) {
|
|
2387
2395
|
yield* __classPrivateFieldGet(this, _Client_videoChatManager, "f").downloadLiveStreamChunk(id, channelId, scale, timestamp, params);
|
|
2388
2396
|
}
|
|
2397
|
+
//
|
|
2398
|
+
// ========================= PAYMENTS ========================= //
|
|
2399
|
+
//
|
|
2400
|
+
/**
|
|
2401
|
+
* Answer a pre-checkout query. Bot-only.
|
|
2402
|
+
*
|
|
2403
|
+
* @method pa
|
|
2404
|
+
* @param preCheckoutQueryId The identifier of the pre-checkout query.
|
|
2405
|
+
* @param ok Whether the checkout is going to be processed.
|
|
2406
|
+
*/
|
|
2407
|
+
async answerPreCheckoutQuery(preCheckoutQueryId, ok, params) {
|
|
2408
|
+
await __classPrivateFieldGet(this, _Client_paymentManager, "f").answerPreCheckoutQuery(preCheckoutQueryId, ok, params);
|
|
2409
|
+
}
|
|
2410
|
+
/**
|
|
2411
|
+
* Refund a star payment. Bot-only.
|
|
2412
|
+
*
|
|
2413
|
+
* @method pa
|
|
2414
|
+
* @param userId The identifier of the user that was charged.
|
|
2415
|
+
* @param telegramPaymentChargeId The identifier of the charge.
|
|
2416
|
+
*/
|
|
2417
|
+
async refundStarPayment(userId, telegramPaymentChargeId) {
|
|
2418
|
+
await __classPrivateFieldGet(this, _Client_paymentManager, "f").refundStarPayment(userId, telegramPaymentChargeId);
|
|
2419
|
+
}
|
|
2389
2420
|
}
|
|
2390
2421
|
_a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
2391
2422
|
await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), resolve);
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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
|
+
*/
|
|
1
20
|
import { Connection } from "./0_connection.js";
|
|
2
21
|
export declare class ConnectionTCP implements Connection {
|
|
3
22
|
#private;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_connection_tcp.node.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_tcp.node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"1_connection_tcp.node.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_tcp.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,qBAAa,aAAc,YAAW,UAAU;;IAW9C,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAY1C,IAAI;IAuCJ,IAAI,SAAS,YAEZ;IAQK,IAAI,CAAC,CAAC,EAAE,UAAU;IAclB,KAAK,CAAC,CAAC,EAAE,UAAU;IA0BzB,KAAK;CAKN"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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
|
+
*/
|
|
1
20
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
21
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
22
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
@@ -11,8 +30,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
30
|
};
|
|
12
31
|
var _ConnectionTCP_instances, _ConnectionTCP_hostname, _ConnectionTCP_port, _ConnectionTCP_socket, _ConnectionTCP_rMutex, _ConnectionTCP_wMutex, _ConnectionTCP_buffer, _ConnectionTCP_nextResolve, _ConnectionTCP_rejectRead, _ConnectionTCP_assertConnected;
|
|
13
32
|
import { Socket } from "node:net";
|
|
14
|
-
import { Mutex } from "../1_utilities.js";
|
|
15
33
|
import { ConnectionError } from "../0_errors.js";
|
|
34
|
+
import { getLogger, Mutex } from "../1_utilities.js";
|
|
35
|
+
const L = getLogger("ConnectionTCP");
|
|
16
36
|
const errConnectionNotOpen = new ConnectionError("Connection not open");
|
|
17
37
|
export class ConnectionTCP {
|
|
18
38
|
constructor(hostname, port) {
|
|
@@ -59,6 +79,7 @@ export class ConnectionTCP {
|
|
|
59
79
|
__classPrivateFieldGet(this, _ConnectionTCP_socket, "f").off("error", reject);
|
|
60
80
|
resolve();
|
|
61
81
|
this.stateChangeHandler?.(true);
|
|
82
|
+
L.debug("connected to", __classPrivateFieldGet(this, _ConnectionTCP_hostname, "f"), "port", __classPrivateFieldGet(this, _ConnectionTCP_port, "f"));
|
|
62
83
|
});
|
|
63
84
|
});
|
|
64
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_connection_web_socket.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_web_socket.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,qBAAa,mBAAoB,YAAW,UAAU;;IAOpD,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,GAAG,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"1_connection_web_socket.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_web_socket.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C,qBAAa,mBAAoB,YAAW,UAAU;;IAOpD,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,GAAG,EAAE,MAAM;IA8CvB,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,IAAI;IAuBJ,IAAI,CAAC,CAAC,EAAE,UAAU;IAgBlB,KAAK,CAAC,CAAC,EAAE,UAAU;IAkBzB,KAAK;CAMN"}
|
|
@@ -116,6 +116,7 @@ _ConnectionWebSocket_url = new WeakMap(), _ConnectionWebSocket_webSocket = new W
|
|
|
116
116
|
webSocket.addEventListener("open", () => {
|
|
117
117
|
this.stateChangeHandler?.(true);
|
|
118
118
|
resolve(webSocket);
|
|
119
|
+
L.debug("connected to", __classPrivateFieldGet(this, _ConnectionWebSocket_url, "f"));
|
|
119
120
|
});
|
|
120
121
|
webSocket.addEventListener("message", async (e) => {
|
|
121
122
|
if (typeof e.data === "string") {
|
package/esm/tl/1_utilities.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function analyzeOptionalParam(ntype: string): {
|
|
|
26
26
|
export declare function isValidType(object: any): object is AnyType;
|
|
27
27
|
export declare function assertIsValidType(object: any): void;
|
|
28
28
|
export declare function is<S extends keyof (Types & Functions)>(typeName: S, value: unknown): value is S extends keyof Types ? Types[S] : S extends keyof Functions ? Functions[S] : never;
|
|
29
|
-
export declare function isOneOf<S extends keyof (Types & Functions)>(typeNames: S[], value: unknown): value is S extends keyof Types ? Types[S] : S extends keyof Functions ? Functions[S] : never;
|
|
29
|
+
export declare function isOneOf<S extends keyof (Types & Functions)>(typeNames: S[] | readonly S[], value: unknown): value is S extends keyof Types ? Types[S] : S extends keyof Functions ? Functions[S] : never;
|
|
30
30
|
export declare function isOfEnum<S extends keyof Enums>(enumName: S, value: unknown): value is Enums[S];
|
|
31
31
|
export declare function as<S extends keyof Types>(typeName: S, value: unknown): Types[S];
|
|
32
32
|
//# sourceMappingURL=1_utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/1_utilities.ts"],"names":[],"mappings":"AAAA;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
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
+
import { AnyObject } from "./0_api.js";
|
|
20
21
|
import { TLReader } from "./3_tl_reader.js";
|
|
21
22
|
import { rpc_result } from "./4_rpc_result.js";
|
|
22
|
-
import { AnyObject } from "./0_api.js";
|
|
23
23
|
export interface message {
|
|
24
24
|
_: "message";
|
|
25
25
|
msg_id: bigint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5_message.d.ts","sourceRoot":"","sources":["../../src/tl/5_message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"5_message.d.ts","sourceRoot":"","sources":["../../src/tl/5_message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAwB,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAKpF,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,SAAS,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;CAC9C;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG,MAAM,CAgBpF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,CAc7D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAiB5D;AAID,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,aAAa,GAAG,UAAU,CAQ7E;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAQzE"}
|
package/esm/tl/5_message.js
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
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 { serialize } from "./2_serialize.js";
|
|
20
21
|
import { TLReader } from "./3_tl_reader.js";
|
|
21
|
-
import { TLWriter } from "./4_tl_writer.js";
|
|
22
22
|
import { deserializeRpcResult, RPC_RESULT_ID } from "./4_rpc_result.js";
|
|
23
|
-
import {
|
|
23
|
+
import { TLWriter } from "./4_tl_writer.js";
|
|
24
24
|
export function calculateLength(object) {
|
|
25
25
|
let length = 0;
|
|
26
26
|
if (Array.isArray(object)) {
|
package/esm/types/0_invoice.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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
|
+
*/
|
|
1
20
|
import { Api } from "../2_tl.js";
|
|
2
21
|
export interface Invoice {
|
|
3
22
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_invoice.d.ts","sourceRoot":"","sources":["../../src/types/0_invoice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,mBAAmB,GAAG,OAAO,CAQ1E"}
|
|
1
|
+
{"version":3,"file":"0_invoice.d.ts","sourceRoot":"","sources":["../../src/types/0_invoice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,mBAAmB,GAAG,OAAO,CAQ1E"}
|
package/esm/types/0_invoice.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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
|
+
*/
|
|
1
20
|
export function constructInvoice(invoice) {
|
|
2
21
|
return {
|
|
3
22
|
title: invoice.title,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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
|
+
/** A shipping address. */
|
|
22
|
+
export interface ShippingAddress {
|
|
23
|
+
countryCode: string;
|
|
24
|
+
state: string;
|
|
25
|
+
city: string;
|
|
26
|
+
streetLine1: string;
|
|
27
|
+
streetLine2: string;
|
|
28
|
+
postCode: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function constructShippingAddress(shippingAddress: Api.postAddress): ShippingAddress;
|
|
31
|
+
//# sourceMappingURL=0_shipping_address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0_shipping_address.d.ts","sourceRoot":"","sources":["../../src/types/0_shipping_address.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,0BAA0B;AAC1B,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,GAAG,CAAC,WAAW,GAAG,eAAe,CAS1F"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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 constructShippingAddress(shippingAddress) {
|
|
21
|
+
return {
|
|
22
|
+
countryCode: shippingAddress.country_iso2,
|
|
23
|
+
state: shippingAddress.state,
|
|
24
|
+
city: shippingAddress.city,
|
|
25
|
+
streetLine1: shippingAddress.street_line1,
|
|
26
|
+
streetLine2: shippingAddress.street_line2,
|
|
27
|
+
postCode: shippingAddress.post_code,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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 { ShippingAddress } from "./0_shipping_address.js";
|
|
22
|
+
export interface OrderInfo {
|
|
23
|
+
name?: string;
|
|
24
|
+
phoneNumber?: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
shippingAddress?: ShippingAddress;
|
|
27
|
+
}
|
|
28
|
+
export declare function constructOrderInfo(info: Api.paymentRequestedInfo): OrderInfo;
|
|
29
|
+
//# sourceMappingURL=1_order_info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_order_info.d.ts","sourceRoot":"","sources":["../../src/types/1_order_info.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAA4B,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEpF,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,oBAAoB,GAAG,SAAS,CAO5E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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 { constructShippingAddress } from "./0_shipping_address.js";
|
|
22
|
+
export function constructOrderInfo(info) {
|
|
23
|
+
return cleanObject({
|
|
24
|
+
name: info.name,
|
|
25
|
+
phoneNumber: info.phone,
|
|
26
|
+
email: info.email,
|
|
27
|
+
shippingAddress: info.shipping_address ? constructShippingAddress(info.shipping_address) : undefined,
|
|
28
|
+
});
|
|
29
|
+
}
|
package/esm/types/2_chat.d.ts
CHANGED
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Api } from "../2_tl.js";
|
|
21
21
|
import { EntityGetter } from "./_getters.js";
|
|
22
|
+
import { Birthday } from "./0_birthday.js";
|
|
23
|
+
import { Location } from "./0_location.js";
|
|
22
24
|
import { OpeningHours } from "./0_opening_hours.js";
|
|
23
25
|
import { ChatPChannel, ChatPGroup, ChatPPrivate, ChatPSupergroup } from "./1_chat_p.js";
|
|
24
26
|
import { Photo } from "./1_photo.js";
|
|
25
|
-
import { Location } from "./0_location.js";
|
|
26
|
-
import { Birthday } from "./0_birthday.js";
|
|
27
27
|
/** @unlisted */
|
|
28
28
|
export interface ChatBase {
|
|
29
29
|
/** The chat's photo. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_chat.d.ts","sourceRoot":"","sources":["../../src/types/2_chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"2_chat.d.ts","sourceRoot":"","sources":["../../src/types/2_chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAM,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAqB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAqB,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAyB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YA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20
20
|
import { unreachable } from "../0_deps.js";
|
|
21
|
+
import { cleanObject } from "../1_utilities.js";
|
|
21
22
|
import { is } from "../2_tl.js";
|
|
23
|
+
import { constructBirthday } from "./0_birthday.js";
|
|
24
|
+
import { constructLocation } from "./0_location.js";
|
|
22
25
|
import { constructOpeningHours } from "./0_opening_hours.js";
|
|
23
26
|
import { constructChatP } from "./1_chat_p.js";
|
|
24
27
|
import { constructPhoto } from "./1_photo.js";
|
|
25
|
-
import { constructLocation } from "./0_location.js";
|
|
26
|
-
import { constructBirthday } from "./0_birthday.js";
|
|
27
|
-
import { cleanObject } from "../1_utilities.js";
|
|
28
28
|
export async function constructChat(fullChat, getEntity) {
|
|
29
29
|
if (is("userFull", fullChat)) {
|
|
30
30
|
const user = await getEntity({ _: "peerUser", user_id: fullChat.id });
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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 { EntityGetter } from "./_getters.js";
|
|
22
|
+
import { OrderInfo } from "./1_order_info.js";
|
|
23
|
+
import { User } from "./1_user.js";
|
|
24
|
+
export interface PreCheckoutQuery {
|
|
25
|
+
id: string;
|
|
26
|
+
from: User;
|
|
27
|
+
currency: string;
|
|
28
|
+
totalAmount: number;
|
|
29
|
+
invoicePayload: string;
|
|
30
|
+
shippingOptionId?: string;
|
|
31
|
+
orderInfo?: OrderInfo;
|
|
32
|
+
}
|
|
33
|
+
export declare function constructPreCheckoutQuery(query: Api.updateBotPrecheckoutQuery, getEntity: EntityGetter): Promise<PreCheckoutQuery>;
|
|
34
|
+
//# sourceMappingURL=2_pre_checkout_query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2_pre_checkout_query.d.ts","sourceRoot":"","sources":["../../src/types/2_pre_checkout_query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAiB,IAAI,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED,wBAAsB,yBAAyB,CAAC,KAAK,EAAE,GAAG,CAAC,yBAAyB,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAexI"}
|