@mtkruto/node 0.0.999 → 0.1.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 (77) hide show
  1. package/esm/0_deps.d.ts +1 -1
  2. package/esm/0_deps.js +1 -1
  3. package/esm/3_errors.d.ts +1531 -0
  4. package/esm/3_errors.js +1531 -0
  5. package/esm/4_constants.d.ts +1 -1
  6. package/esm/4_constants.js +1 -1
  7. package/esm/4_errors.d.ts +25 -0
  8. package/esm/4_errors.js +64 -0
  9. package/esm/client/2_client_plain.js +1 -1
  10. package/esm/client/4_client.d.ts +2 -1
  11. package/esm/client/4_client.js +24 -41
  12. package/esm/deps/deno.land/x/{tgcrypto@0.1.3 → tgcrypto@0.2.1}/mod.d.ts +2 -2
  13. package/esm/deps/deno.land/x/{tgcrypto@0.1.3 → tgcrypto@0.2.1}/mod.js +19 -6
  14. package/esm/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.d.ts +2 -0
  15. package/esm/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.js +991 -0
  16. package/esm/mod.d.ts +3 -2
  17. package/esm/mod.js +3 -2
  18. package/esm/tl/2_types.d.ts +1 -1
  19. package/esm/tl/2_types.js +1 -2
  20. package/esm/tl/3_functions.d.ts +1 -1
  21. package/esm/tl/3_functions.js +1 -2
  22. package/esm/types/0__file_id.js +0 -1
  23. package/esm/types/1_bot_command_scope.d.ts +1 -1
  24. package/esm/types/1_bot_command_scope.js +1 -1
  25. package/esm/types/1_chat.d.ts +1 -1
  26. package/esm/types/1_chat.js +1 -1
  27. package/esm/types/1_sticker.d.ts +1 -1
  28. package/esm/types/1_sticker.js +1 -1
  29. package/esm/types/1_user.d.ts +1 -1
  30. package/esm/types/1_user.js +1 -1
  31. package/esm/types/2_inline_keyboard_button.d.ts +1 -1
  32. package/esm/types/3_message.d.ts +12 -12
  33. package/esm/types/3_message.js +12 -12
  34. package/esm/types/5_inline_query_result.d.ts +1 -1
  35. package/esm/types/5_inline_query_result.js +1 -1
  36. package/esm/utilities/0_crypto.js +6 -4
  37. package/package.json +1 -1
  38. package/script/0_deps.d.ts +1 -1
  39. package/script/0_deps.js +1 -1
  40. package/script/3_errors.d.ts +1531 -0
  41. package/script/3_errors.js +2053 -0
  42. package/script/4_constants.d.ts +1 -1
  43. package/script/4_constants.js +1 -1
  44. package/script/4_errors.d.ts +25 -0
  45. package/script/4_errors.js +88 -0
  46. package/script/client/2_client_plain.js +1 -1
  47. package/script/client/4_client.d.ts +2 -1
  48. package/script/client/4_client.js +24 -41
  49. package/script/deps/deno.land/x/{tgcrypto@0.1.3 → tgcrypto@0.2.1}/mod.d.ts +2 -2
  50. package/script/deps/deno.land/x/{tgcrypto@0.1.3 → tgcrypto@0.2.1}/mod.js +19 -6
  51. package/script/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.d.ts +2 -0
  52. package/script/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.js +993 -0
  53. package/script/mod.d.ts +3 -2
  54. package/script/mod.js +16 -3
  55. package/script/tl/2_types.d.ts +1 -1
  56. package/script/tl/2_types.js +0 -1
  57. package/script/tl/3_functions.d.ts +1 -1
  58. package/script/tl/3_functions.js +0 -1
  59. package/script/types/0__file_id.js +0 -1
  60. package/script/types/1_bot_command_scope.d.ts +1 -1
  61. package/script/types/1_bot_command_scope.js +1 -1
  62. package/script/types/1_chat.d.ts +1 -1
  63. package/script/types/1_chat.js +1 -1
  64. package/script/types/1_sticker.d.ts +1 -1
  65. package/script/types/1_sticker.js +1 -1
  66. package/script/types/1_user.d.ts +1 -1
  67. package/script/types/1_user.js +1 -1
  68. package/script/types/2_inline_keyboard_button.d.ts +1 -1
  69. package/script/types/3_message.d.ts +12 -12
  70. package/script/types/3_message.js +12 -12
  71. package/script/types/5_inline_query_result.d.ts +1 -1
  72. package/script/types/5_inline_query_result.js +1 -1
  73. package/script/utilities/0_crypto.js +6 -4
  74. package/esm/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +0 -2
  75. package/esm/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.js +0 -1078
  76. package/script/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +0 -2
  77. package/script/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.js +0 -1080
package/esm/mod.d.ts CHANGED
@@ -4,10 +4,11 @@ export declare const utils: {
4
4
  checkPassword: typeof checkPassword;
5
5
  getRandomId: typeof getRandomId;
6
6
  };
7
- export * from "./2_tl.js";
8
7
  export * from "./2_connection.js";
9
8
  export * from "./3_storage.js";
10
9
  export * from "./3_transport.js";
10
+ export * from "./2_tl.js";
11
+ export * from "./3_types.js";
11
12
  export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
13
+ export * as errors from "./4_errors.js";
12
14
  export * from "./5_client.js";
13
- export * from "./3_types.js";
package/esm/mod.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { getRandomId } from "./1_utilities.js";
2
2
  import { checkPassword } from "./client/0_password.js";
3
3
  export const utils = { checkPassword, getRandomId };
4
- export * from "./2_tl.js";
5
4
  export * from "./2_connection.js";
6
5
  export * from "./3_storage.js";
7
6
  export * from "./3_transport.js";
7
+ export * from "./2_tl.js";
8
+ export * from "./3_types.js";
8
9
  export { APP_VERSION, DEVICE_MODEL, INITIAL_DC, LANG_CODE, LANG_PACK, LAYER, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "./4_constants.js";
10
+ export * as errors from "./4_errors.js";
9
11
  export * from "./5_client.js";
10
- export * from "./3_types.js";
@@ -1,4 +1,4 @@
1
- import { id, params, TLObject, Params, TLObjectConstructor, ParamDesc, paramDesc } from "./1_tl_object.js";
1
+ import { id, ParamDesc, paramDesc, Params, params, TLObject, TLObjectConstructor } from "./1_tl_object.js";
2
2
  export declare abstract class Type extends TLObject {
3
3
  }
4
4
  export declare abstract class TypeX extends Type {
package/esm/tl/2_types.js CHANGED
@@ -1,5 +1,4 @@
1
- // deno-fmt-ignore-file
2
- import { id, params, TLObject, paramDesc, flags } from "./1_tl_object.js";
1
+ import { flags, id, paramDesc, params, TLObject } from "./1_tl_object.js";
3
2
  export class Type extends TLObject {
4
3
  }
5
4
  // Unknown type (generic)
@@ -1,4 +1,4 @@
1
- import { id, params, TLObject, Params, paramDesc, ParamDesc } from "./1_tl_object.js";
1
+ import { id, ParamDesc, paramDesc, Params, params, TLObject } from "./1_tl_object.js";
2
2
  import * as types from "./2_types.js";
3
3
  export declare abstract class Function<T> extends TLObject {
4
4
  __R: T;
@@ -1,5 +1,4 @@
1
- // deno-fmt-ignore-file
2
- import { id, params, TLObject, paramDesc, flags } from "./1_tl_object.js";
1
+ import { flags, id, paramDesc, params, TLObject } from "./1_tl_object.js";
3
2
  import * as types from "./2_types.js";
4
3
  export class Function extends TLObject {
5
4
  constructor() {
@@ -1,4 +1,3 @@
1
- // Direct port from Pyrogram
2
1
  import { base64DecodeUrlSafe, base64EncodeUrlSafe, rleDecode, rleEncode, UNREACHABLE } from "../1_utilities.js";
3
2
  import { TLReader, TLWriter } from "../2_tl.js";
4
3
  export var FileType;
@@ -1,5 +1,5 @@
1
- import { ChatID } from "./0_chat_id.js";
2
1
  import { types } from "../2_tl.js";
2
+ import { ChatID } from "./0_chat_id.js";
3
3
  import { InputPeerGetter } from "./1__getters.js";
4
4
  export declare namespace BotCommandScope {
5
5
  interface Default {
@@ -1,5 +1,5 @@
1
- import { types } from "../2_tl.js";
2
1
  import { UNREACHABLE } from "../1_utilities.js";
2
+ import { types } from "../2_tl.js";
3
3
  export async function botCommandScopeToTlObject(scope, getInputPeer) {
4
4
  switch (scope.type) {
5
5
  case "default":
@@ -1,6 +1,6 @@
1
1
  import { types } from "../2_tl.js";
2
- import { Color } from "./0_color.js";
3
2
  import { ChatPhoto } from "./0_chat_photo.js";
3
+ import { Color } from "./0_color.js";
4
4
  export type ChatType = "private" | "group" | "supergroup" | "channel";
5
5
  export declare namespace Chat {
6
6
  interface Base {
@@ -1,8 +1,8 @@
1
1
  import { cleanObject, UNREACHABLE } from "../1_utilities.js";
2
2
  import { types } from "../2_tl.js";
3
3
  import { ZERO_CHANNEL_ID } from "../4_constants.js";
4
- import { getColor } from "./0_color.js";
5
4
  import { constructChatPhoto } from "./0_chat_photo.js";
5
+ import { getColor } from "./0_color.js";
6
6
  export function constructChat(chat) {
7
7
  if (chat instanceof types.User) {
8
8
  const id = Number(chat.id);
@@ -1,7 +1,7 @@
1
1
  import { MaybePromise } from "../1_utilities.js";
2
2
  import { types } from "../2_tl.js";
3
- import { Thumbnail } from "./0_thumbnail.js";
4
3
  import { MaskPosition } from "./0_mask_position.js";
4
+ import { Thumbnail } from "./0_thumbnail.js";
5
5
  /** This object represents a sticker. */
6
6
  export interface Sticker {
7
7
  /** Identifier for this file, which can be used to download or reuse the file */
@@ -1,6 +1,6 @@
1
1
  import { as, types } from "../2_tl.js";
2
- import { constructThumbnail } from "./0_thumbnail.js";
3
2
  import { constructMaskPosition } from "./0_mask_position.js";
3
+ import { constructThumbnail } from "./0_thumbnail.js";
4
4
  export async function constructSticker(document, fileId, fileUniqueId, getStickerSetName) {
5
5
  const stickerAttribute = document.attributes.find((v) => v instanceof types.DocumentAttributeSticker);
6
6
  const imageSizeAttribute = document.attributes.find((v) => v instanceof types.DocumentAttributeImageSize);
@@ -1,6 +1,6 @@
1
1
  import { types } from "../2_tl.js";
2
- import { Color } from "./0_color.js";
3
2
  import { ChatPhoto } from "./0_chat_photo.js";
3
+ import { Color } from "./0_color.js";
4
4
  /** This object represents a Telegram user or bot. */
5
5
  export interface User {
6
6
  /** Unique identifier for this user or bot */
@@ -1,7 +1,7 @@
1
1
  import { cleanObject } from "../1_utilities.js";
2
2
  import { types } from "../2_tl.js";
3
- import { getColor } from "./0_color.js";
4
3
  import { constructChatPhoto } from "./0_chat_photo.js";
4
+ import { getColor } from "./0_color.js";
5
5
  export function constructUser(user_) {
6
6
  const id = Number(user_.id);
7
7
  const user = {
@@ -1,6 +1,6 @@
1
1
  import { types } from "../2_tl.js";
2
- import { WebAppInfo } from "./0_web_app_info.js";
3
2
  import { LoginUrl } from "./0_login_url.js";
3
+ import { WebAppInfo } from "./0_web_app_info.js";
4
4
  import { UsernameResolver } from "./1__getters.js";
5
5
  export declare namespace InlineKeyboardButton {
6
6
  interface Base {
@@ -1,27 +1,27 @@
1
1
  import { MaybePromise } from "../1_utilities.js";
2
2
  import { types } from "../2_tl.js";
3
- import { ForceReply } from "./0_force_reply.js";
4
- import { MessageEntity } from "./0_message_entity.js";
5
3
  import { Audio } from "./0_audio.js";
6
4
  import { Contact } from "./0_contact.js";
7
- import { Voice } from "./0_voice.js";
8
- import { Venue } from "./0_venue.js";
9
- import { Location } from "./0_location.js";
10
5
  import { Dice } from "./0_dice.js";
6
+ import { ForceReply } from "./0_force_reply.js";
7
+ import { Location } from "./0_location.js";
8
+ import { MessageEntity } from "./0_message_entity.js";
11
9
  import { ReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
10
+ import { Venue } from "./0_venue.js";
11
+ import { Voice } from "./0_voice.js";
12
12
  import { EntityGetter } from "./1__getters.js";
13
+ import { Animation } from "./1_animation.js";
13
14
  import { Chat } from "./1_chat.js";
14
- import { Photo } from "./1_photo.js";
15
15
  import { Document } from "./1_document.js";
16
- import { Video } from "./1_video.js";
17
- import { VideoNote } from "./1_video_note.js";
18
- import { Animation } from "./1_animation.js";
19
- import { User } from "./1_user.js";
16
+ import { Photo } from "./1_photo.js";
20
17
  import { Poll } from "./1_poll.js";
21
18
  import { Sticker, StickerSetNameGetter } from "./1_sticker.js";
22
- import { InlineKeyboardMarkup } from "./3_inline_keyboard_markup.js";
23
- import { ReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
19
+ import { User } from "./1_user.js";
20
+ import { VideoNote } from "./1_video_note.js";
21
+ import { Video } from "./1_video.js";
24
22
  import { Game } from "./2_game.js";
23
+ import { ReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
24
+ import { InlineKeyboardMarkup } from "./3_inline_keyboard_markup.js";
25
25
  /** This object represents a message. */
26
26
  export interface Message {
27
27
  /** Whether the message is outgoing */
@@ -3,27 +3,27 @@ import { cleanObject, UNREACHABLE } from "../1_utilities.js";
3
3
  import { as, types } from "../2_tl.js";
4
4
  import { ZERO_CHANNEL_ID } from "../4_constants.js";
5
5
  import { FileID, FileType, FileUniqueID, FileUniqueType } from "./0__file_id.js";
6
- import { constructForceReply } from "./0_force_reply.js";
7
- import { constructMessageEntity } from "./0_message_entity.js";
8
6
  import { constructAudio } from "./0_audio.js";
9
7
  import { constructContact } from "./0_contact.js";
10
- import { constructVoice } from "./0_voice.js";
11
- import { constructVenue } from "./0_venue.js";
12
- import { constructLocation } from "./0_location.js";
13
8
  import { constructDice } from "./0_dice.js";
9
+ import { constructForceReply } from "./0_force_reply.js";
10
+ import { constructLocation } from "./0_location.js";
11
+ import { constructMessageEntity } from "./0_message_entity.js";
14
12
  import { constructReplyKeyboardRemove } from "./0_reply_keyboard_remove.js";
13
+ import { constructVenue } from "./0_venue.js";
14
+ import { constructVoice } from "./0_voice.js";
15
+ import { constructAnimation } from "./1_animation.js";
15
16
  import { constructChat } from "./1_chat.js";
16
- import { constructPhoto } from "./1_photo.js";
17
17
  import { constructDocument } from "./1_document.js";
18
- import { constructVideo } from "./1_video.js";
19
- import { constructVideoNote } from "./1_video_note.js";
20
- import { constructAnimation } from "./1_animation.js";
21
- import { constructUser } from "./1_user.js";
18
+ import { constructPhoto } from "./1_photo.js";
22
19
  import { constructPoll } from "./1_poll.js";
23
20
  import { constructSticker } from "./1_sticker.js";
24
- import { constructInlineKeyboardMarkup } from "./3_inline_keyboard_markup.js";
25
- import { constructReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
21
+ import { constructUser } from "./1_user.js";
22
+ import { constructVideoNote } from "./1_video_note.js";
23
+ import { constructVideo } from "./1_video.js";
26
24
  import { constructGame } from "./2_game.js";
25
+ import { constructReplyKeyboardMarkup } from "./2_reply_keyboard_markup.js";
26
+ import { constructInlineKeyboardMarkup } from "./3_inline_keyboard_markup.js";
27
27
  const d = debug("types/Message");
28
28
  async function getSender(message_, getEntity) {
29
29
  if (message_.fromId instanceof types.PeerUser) {
@@ -1,6 +1,7 @@
1
1
  import { types } from "../2_tl.js";
2
2
  import { MessageEntity } from "./0_message_entity.js";
3
3
  import { ParseMode } from "./0_parse_mode.js";
4
+ import { UsernameResolver } from "./1__getters.js";
4
5
  import { InlineQueryResultArticle } from "./4_inline_query_result_article.js";
5
6
  import { InlineQueryResultAudio } from "./4_inline_query_result_audio.js";
6
7
  import { InlineQueryResultCachedAudio } from "./4_inline_query_result_cached_audio.js";
@@ -21,7 +22,6 @@ import { InlineQueryResultPhoto } from "./4_inline_query_result_photo.js";
21
22
  import { InlineQueryResultVenue } from "./4_inline_query_result_venue.js";
22
23
  import { InlineQueryResultVideo } from "./4_inline_query_result_video.js";
23
24
  import { InlineQueryResultVoice } from "./4_inline_query_result_voice.js";
24
- import { UsernameResolver } from "./1__getters.js";
25
25
  export type InlineQueryResult = InlineQueryResultCachedAudio | InlineQueryResultCachedDocument | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedPhoto | InlineQueryResultCachedSticker | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultArticle | InlineQueryResultAudio | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultDocument | InlineQueryResultGif | InlineQueryResultLocation | InlineQueryResultMpeg4Gif | InlineQueryResultPhoto | InlineQueryResultVenue | InlineQueryResultVideo | InlineQueryResultVoice;
26
26
  export declare function inlineQueryResultToTlObject(result_: InlineQueryResult, parseText: (text: string, params?: {
27
27
  parseMode?: ParseMode;
@@ -1,6 +1,6 @@
1
+ import { UNREACHABLE } from "../1_utilities.js";
1
2
  import { types } from "../2_tl.js";
2
3
  import { FileID } from "./0__file_id.js";
3
- import { UNREACHABLE } from "../1_utilities.js";
4
4
  import { replyMarkupToTlObject } from "./4_reply_markup.js";
5
5
  // deno-lint-ignore no-explicit-any
6
6
  export async function inlineQueryResultToTlObject(result_, parseText, usernameResolver) {
@@ -21,15 +21,17 @@ export class CTR {
21
21
  });
22
22
  }
23
23
  encrypt(data) {
24
- const [encrypted, iv, state] = ctr256Encrypt(data, this.key, this.iv, this.state);
24
+ const v = new Uint8Array(data); // TODO: don't copy
25
+ const [iv, state] = ctr256Encrypt(v, this.key, this.iv, this.state);
25
26
  this.iv = iv;
26
27
  this.state = state;
27
- return new Uint8Array(encrypted);
28
+ return v;
28
29
  }
29
30
  decrypt(data) {
30
- const [decrypted, iv, state] = ctr256Decrypt(data, this.key, this.iv, this.state);
31
+ const v = new Uint8Array(data); // TODO: don't copy
32
+ const [iv, state] = ctr256Decrypt(v, this.key, this.iv, this.state);
31
33
  this.iv = iv;
32
34
  this.state = state;
33
- return new Uint8Array(decrypted);
35
+ return v;
34
36
  }
35
37
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "module": "./esm/mod.js",
3
3
  "main": "./script/mod.js",
4
4
  "name": "@mtkruto/node",
5
- "version": "0.0.999",
5
+ "version": "0.1.0",
6
6
  "description": "MTKruto for Node.js",
7
7
  "author": "Roj <rojvv@icloud.com>",
8
8
  "license": "LGPL-3.0-or-later",
@@ -1,5 +1,5 @@
1
1
  export * from "./deps/deno.land/std@0.201.0/assert/mod.js";
2
- export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.1.3/mod.js";
2
+ export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.2.1/mod.js";
3
3
  export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/gzip/gzip.js";
4
4
  export { Mutex, type MutexInterface } from "async-mutex";
5
5
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
package/script/0_deps.js CHANGED
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.base64Encode = exports.base64Decode = exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.ctr256Encrypt = exports.ctr256Decrypt = void 0;
18
18
  __exportStar(require("./deps/deno.land/std@0.201.0/assert/mod.js"), exports);
19
- var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.1.3/mod.js");
19
+ var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.2.1/mod.js");
20
20
  Object.defineProperty(exports, "ctr256Decrypt", { enumerable: true, get: function () { return mod_js_1.ctr256Decrypt; } });
21
21
  Object.defineProperty(exports, "ctr256Encrypt", { enumerable: true, get: function () { return mod_js_1.ctr256Encrypt; } });
22
22
  Object.defineProperty(exports, "factorize", { enumerable: true, get: function () { return mod_js_1.factorize; } });