@mtkruto/node 0.17.0 → 0.18.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.
Files changed (39) hide show
  1. package/esm/3_types.d.ts +1 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +1 -0
  4. package/esm/client/0_storage_operations.d.ts +11 -1
  5. package/esm/client/0_storage_operations.d.ts.map +1 -1
  6. package/esm/client/0_storage_operations.js +36 -4
  7. package/esm/client/3_message_manager.d.ts +3 -2
  8. package/esm/client/3_message_manager.d.ts.map +1 -1
  9. package/esm/client/3_message_manager.js +39 -2
  10. package/esm/client/5_client.d.ts +9 -1
  11. package/esm/client/5_client.d.ts.map +1 -1
  12. package/esm/client/5_client.js +10 -0
  13. package/esm/types/0_voice_transcription.d.ts +31 -0
  14. package/esm/types/0_voice_transcription.d.ts.map +1 -0
  15. package/esm/types/0_voice_transcription.js +26 -0
  16. package/esm/types/6_update.d.ts +21 -2
  17. package/esm/types/6_update.d.ts.map +1 -1
  18. package/esm/utilities/1_crypto.d.ts.map +1 -1
  19. package/esm/utilities/1_crypto.js +43 -19
  20. package/package.json +1 -1
  21. package/script/3_types.d.ts +1 -0
  22. package/script/3_types.d.ts.map +1 -1
  23. package/script/3_types.js +1 -0
  24. package/script/client/0_storage_operations.d.ts +11 -1
  25. package/script/client/0_storage_operations.d.ts.map +1 -1
  26. package/script/client/0_storage_operations.js +36 -4
  27. package/script/client/3_message_manager.d.ts +3 -2
  28. package/script/client/3_message_manager.d.ts.map +1 -1
  29. package/script/client/3_message_manager.js +38 -1
  30. package/script/client/5_client.d.ts +9 -1
  31. package/script/client/5_client.d.ts.map +1 -1
  32. package/script/client/5_client.js +10 -0
  33. package/script/types/0_voice_transcription.d.ts +31 -0
  34. package/script/types/0_voice_transcription.d.ts.map +1 -0
  35. package/script/types/0_voice_transcription.js +29 -0
  36. package/script/types/6_update.d.ts +21 -2
  37. package/script/types/6_update.d.ts.map +1 -1
  38. package/script/utilities/1_crypto.d.ts.map +1 -1
  39. package/script/utilities/1_crypto.js +43 -19
@@ -2115,6 +2115,16 @@ class Client extends Composer {
2115
2115
  async startBot(botId, params) {
2116
2116
  return await __classPrivateFieldGet(this, _Client_messageManager, "f").startBot(botId, params);
2117
2117
  }
2118
+ /**
2119
+ * Transcribe a voice message. User-only.
2120
+ *
2121
+ * @method ms
2122
+ * @param chatId The identifier of the chat that includes the message.
2123
+ * @param messageId The identifier of the message.
2124
+ */
2125
+ async transcribeVoice(chatId, messageId) {
2126
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").transcribeVoice(chatId, messageId);
2127
+ }
2118
2128
  //
2119
2129
  // ========================= POLLS ========================= //
2120
2130
  //
@@ -0,0 +1,31 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import { Api } from "../2_tl.js";
21
+ /** An audio transcription. */
22
+ export interface VoiceTranscription {
23
+ /** The identifier of the transcription. */
24
+ id: string;
25
+ /** Whether the transciption is complete. */
26
+ done: boolean;
27
+ /** The transcription result. */
28
+ text: string;
29
+ }
30
+ export declare function constructVoiceTranscription(transcribedAudio: Api.messages_TranscribedAudio | Api.updateTranscribedAudio): VoiceTranscription;
31
+ //# sourceMappingURL=0_voice_transcription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_voice_transcription.d.ts","sourceRoot":"","sources":["../../src/types/0_voice_transcription.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,8BAA8B;AAC9B,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,4CAA4C;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,2BAA2B,CAAC,gBAAgB,EAAE,GAAG,CAAC,yBAAyB,GAAG,GAAG,CAAC,sBAAsB,GAAG,kBAAkB,CAM5I"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2025 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.constructVoiceTranscription = constructVoiceTranscription;
23
+ function constructVoiceTranscription(transcribedAudio) {
24
+ return {
25
+ id: String(transcribedAudio.transcription_id),
26
+ done: !transcribedAudio.pending,
27
+ text: transcribedAudio.text,
28
+ };
29
+ }
@@ -23,6 +23,7 @@ import { MessageReference } from "./0_message_reference.js";
23
23
  import { StoryReference } from "./0_story_reference.js";
24
24
  import { Translation } from "./0_translation.js";
25
25
  import { VideoChat } from "./0_video_chat.js";
26
+ import { VoiceTranscription } from "./0_voice_transcription.js";
26
27
  import { BusinessConnection } from "./2_business_connection.js";
27
28
  import { ChosenInlineResult } from "./2_chosen_inline_result.js";
28
29
  import { InlineQuery } from "./2_inline_query.js";
@@ -397,6 +398,23 @@ export interface UpdatePoll {
397
398
  */
398
399
  poll: Poll;
399
400
  }
401
+ /**
402
+ * A voice transcription was updated.
403
+ *
404
+ * ```
405
+ * client.on("voiceTranscription", (ctx) => {
406
+ * // ctx.voiceTranscription
407
+ * });
408
+ * ```
409
+ * @unlisted
410
+ */
411
+ export interface UpdateVoiceTranscription {
412
+ /**
413
+ * The new voice transcription.
414
+ * @discriminator
415
+ */
416
+ voiceTranscription: VoiceTranscription;
417
+ }
400
418
  /** @unlisted */
401
419
  export interface UpdateMap {
402
420
  message: UpdateNewMessage;
@@ -424,9 +442,10 @@ export interface UpdateMap {
424
442
  joinRequest: UpdateJoinRequest;
425
443
  translations: UpdateTranslations;
426
444
  poll: UpdatePoll;
445
+ voiceTranscription: UpdateVoiceTranscription;
427
446
  }
428
447
  /** @unlisted */
429
- export type UpdateIntersection = Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateMessageEdited & UpdateMessageScheduled & UpdateMessagesDeleted & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory & UpdateBusinessConnection & UpdateVideoChat & UpdatePreCheckoutQuery & UpdateJoinRequest & UpdateTranslations & UpdatePoll>;
448
+ export type UpdateIntersection = Partial<UpdateConnectionState & UpdateAuthorizationState & UpdateNewMessage & UpdateMessageEdited & UpdateMessageScheduled & UpdateMessagesDeleted & UpdateCallbackQuery & UpdateInlineQuery & UpdateChosenInlineResult & UpdateNewChat & UpdateEditedChat & UpdateDeletedChat & UpdateMessageInteractions & UpdateMessageReactionCount & UpdateMessageReactions & UpdateChatMember & UpdateMyChatMember & UpdateDeletedStory & UpdateNewStory & UpdateBusinessConnection & UpdateVideoChat & UpdatePreCheckoutQuery & UpdateJoinRequest & UpdateTranslations & UpdatePoll & UpdateVoiceTranscription>;
430
449
  /** An incoming update. */
431
- export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateMessageEdited | UpdateMessageScheduled | UpdateMessagesDeleted | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory | UpdateBusinessConnection | UpdateVideoChat | UpdatePreCheckoutQuery | UpdateJoinRequest | UpdateTranslations | UpdatePoll;
450
+ export type Update = UpdateConnectionState | UpdateAuthorizationState | UpdateNewMessage | UpdateMessageEdited | UpdateMessageScheduled | UpdateMessagesDeleted | UpdateCallbackQuery | UpdateInlineQuery | UpdateChosenInlineResult | UpdateNewChat | UpdateEditedChat | UpdateDeletedChat | UpdateMessageInteractions | UpdateMessageReactionCount | UpdateMessageReactions | UpdateChatMember | UpdateMyChatMember | UpdateDeletedStory | UpdateNewStory | UpdateBusinessConnection | UpdateVideoChat | UpdatePreCheckoutQuery | UpdateJoinRequest | UpdateTranslations | UpdatePoll | UpdateVoiceTranscription;
432
451
  //# sourceMappingURL=6_update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"6_update.d.ts","sourceRoot":"","sources":["../../src/types/6_update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAA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IACzC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,YAAY,EAAE,kBAAkB,CAAC;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,kBAAkB,EAAE,wBAAwB,CAAC;CAC9C;AAED,gBAAgB;AAChB,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACpC,qBAAqB,GACrB,wBAAwB,GACxB,gBAAgB,GAChB,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,mBAAmB,GACnB,iBAAiB,GACjB,wBAAwB,GACxB,aAAa,GACb,gBAAgB,GAChB,iBAAiB,GACjB,yBAAyB,GACzB,0BAA0B,GAC1B,sBAAsB,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,wBAAwB,GACxB,eAAe,GACf,sBAAsB,GACtB,iBAAiB,GACjB,kBAAkB,GAClB,UAAU,GACV,wBAAwB,CAC3B,CAAC;AAEF,0BAA0B;AAC1B,MAAM,MAAM,MAAM,GACd,qBAAqB,GACrB,wBAAwB,GACxB,gBAAgB,GAChB,mBAAmB,GACnB,sBAAsB,GACtB,qBAAqB,GACrB,mBAAmB,GACnB,iBAAiB,GACjB,wBAAwB,GACxB,aAAa,GACb,gBAAgB,GAChB,iBAAiB,GACjB,yBAAyB,GACzB,0BAA0B,GAC1B,sBAAsB,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,cAAc,GACd,wBAAwB,GACxB,eAAe,GACf,sBAAsB,GACtB,iBAAiB,GACjB,kBAAkB,GAClB,UAAU,GACV,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,qBAAa,GAAG;;IAKd,IAAI,MAAM,IAAI;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAE9C;gBAEW,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,EAAE,UAAU;WAKrC,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAI7D,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAuBlD"}
1
+ {"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAO5C,qBAAa,GAAG;;IAMd,IAAI,MAAM,IAAI;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAE9C;gBAEW,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,EAAE,UAAU;WAKrC,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAI7D,IAAI,CAAC,IAAI,EAAE,UAAU;CAkD5B"}
@@ -33,7 +33,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
33
33
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
34
34
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
35
35
  };
36
- var _CTR_key, _CTR_iv, _CTR_incrementPending;
36
+ var _CTR_instances, _CTR_key, _CTR_iv, _CTR_bytesUntilNextBlock, _CTR_promise, _CTR_call, _CTR_encrypt, _CTR_increaseIv;
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.CTR = void 0;
39
39
  /**
@@ -56,16 +56,19 @@ exports.CTR = void 0;
56
56
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
57
57
  */
58
58
  const dntShim = __importStar(require("../_dnt.shims.js"));
59
+ const _0_deps_js_1 = require("../0_deps.js");
59
60
  const _0_bigint_js_1 = require("./0_bigint.js");
60
61
  const _0_buffer_js_1 = require("./0_buffer.js");
61
62
  class CTR {
62
63
  get _state() {
63
- return { iv: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")), state: __classPrivateFieldGet(this, _CTR_incrementPending, "f") };
64
+ return { iv: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")), state: __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f") };
64
65
  }
65
66
  constructor(key, iv) {
67
+ _CTR_instances.add(this);
66
68
  _CTR_key.set(this, void 0);
67
69
  _CTR_iv.set(this, void 0);
68
- _CTR_incrementPending.set(this, 0);
70
+ _CTR_bytesUntilNextBlock.set(this, 0);
71
+ _CTR_promise.set(this, void 0);
69
72
  __classPrivateFieldSet(this, _CTR_key, key, "f");
70
73
  __classPrivateFieldSet(this, _CTR_iv, iv, "f");
71
74
  }
@@ -73,23 +76,44 @@ class CTR {
73
76
  return await dntShim.crypto.subtle.importKey("raw", key, "AES-CTR", false, ["encrypt"]);
74
77
  }
75
78
  async call(data) {
76
- const promise = dntShim.crypto.subtle.encrypt({
77
- name: "AES-CTR",
78
- counter: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")),
79
- length: __classPrivateFieldGet(this, _CTR_iv, "f").length * 8,
80
- }, __classPrivateFieldGet(this, _CTR_key, "f"), data);
81
- const incrementPending = data.length % __classPrivateFieldGet(this, _CTR_iv, "f").length;
82
- let incrementBy = (data.length - incrementPending) / __classPrivateFieldGet(this, _CTR_iv, "f").length;
83
- __classPrivateFieldSet(this, _CTR_incrementPending, __classPrivateFieldGet(this, _CTR_incrementPending, "f") + incrementPending, "f");
84
- while (__classPrivateFieldGet(this, _CTR_incrementPending, "f") >= __classPrivateFieldGet(this, _CTR_iv, "f").length) {
85
- __classPrivateFieldSet(this, _CTR_incrementPending, __classPrivateFieldGet(this, _CTR_incrementPending, "f") - __classPrivateFieldGet(this, _CTR_iv, "f").length, "f");
86
- incrementBy += 1;
79
+ if (__classPrivateFieldGet(this, _CTR_promise, "f")) {
80
+ await Promise.allSettled([__classPrivateFieldGet(this, _CTR_promise, "f")]);
87
81
  }
88
- if (incrementBy) {
89
- __classPrivateFieldSet(this, _CTR_iv, (0, _0_buffer_js_1.bufferFromBigInt)((0, _0_bigint_js_1.bigIntFromBuffer)(__classPrivateFieldGet(this, _CTR_iv, "f"), false, false) + BigInt(incrementBy), 16, false, false), "f");
90
- }
91
- return new Uint8Array(await promise);
82
+ return await (__classPrivateFieldSet(this, _CTR_promise, __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_call).call(this, data), "f"));
92
83
  }
93
84
  }
94
85
  exports.CTR = CTR;
95
- _CTR_key = new WeakMap(), _CTR_iv = new WeakMap(), _CTR_incrementPending = new WeakMap();
86
+ _CTR_key = new WeakMap(), _CTR_iv = new WeakMap(), _CTR_bytesUntilNextBlock = new WeakMap(), _CTR_promise = new WeakMap(), _CTR_instances = new WeakSet(), _CTR_call = async function _CTR_call(data) {
87
+ let header;
88
+ if (__classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f")) {
89
+ const headerLength = Math.min(data.length, __classPrivateFieldGet(this, _CTR_iv, "f").length - __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f"));
90
+ const encrypted = await __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_encrypt).call(this, (0, _0_deps_js_1.concat)([new Uint8Array(__classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f")), data.subarray(0, headerLength)]));
91
+ header = encrypted.subarray(__classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f"));
92
+ data = data.subarray(headerLength);
93
+ if (encrypted.length === __classPrivateFieldGet(this, _CTR_iv, "f").length) {
94
+ __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_increaseIv).call(this, 1);
95
+ __classPrivateFieldSet(this, _CTR_bytesUntilNextBlock, 0, "f");
96
+ }
97
+ else {
98
+ __classPrivateFieldSet(this, _CTR_bytesUntilNextBlock, __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f") + headerLength, "f");
99
+ }
100
+ }
101
+ if (!data.length && header) {
102
+ return header;
103
+ }
104
+ const encrypted = await __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_encrypt).call(this, data);
105
+ __classPrivateFieldSet(this, _CTR_bytesUntilNextBlock, encrypted.length % __classPrivateFieldGet(this, _CTR_iv, "f").length, "f");
106
+ __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_increaseIv).call(this, (encrypted.length - __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f")) / __classPrivateFieldGet(this, _CTR_iv, "f").length);
107
+ return header ? (0, _0_deps_js_1.concat)([header, encrypted]) : encrypted;
108
+ }, _CTR_encrypt = async function _CTR_encrypt(data) {
109
+ return new Uint8Array(await dntShim.crypto.subtle.encrypt({
110
+ name: "AES-CTR",
111
+ counter: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")),
112
+ length: __classPrivateFieldGet(this, _CTR_iv, "f").length * 8,
113
+ }, __classPrivateFieldGet(this, _CTR_key, "f"), data));
114
+ }, _CTR_increaseIv = function _CTR_increaseIv(amount) {
115
+ if (amount < 1) {
116
+ return;
117
+ }
118
+ __classPrivateFieldSet(this, _CTR_iv, (0, _0_buffer_js_1.bufferFromBigInt)((0, _0_bigint_js_1.bigIntFromBuffer)(__classPrivateFieldGet(this, _CTR_iv, "f"), false, false) + BigInt(amount), __classPrivateFieldGet(this, _CTR_iv, "f").length, false, false), "f");
119
+ };