teleproto 1.214.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 (222) hide show
  1. package/CryptoFile.d.ts +2 -0
  2. package/CryptoFile.js +37 -0
  3. package/Helpers.d.ts +150 -0
  4. package/Helpers.js +477 -0
  5. package/LICENSE +23 -0
  6. package/Password.d.ts +14 -0
  7. package/Password.js +270 -0
  8. package/README.md +98 -0
  9. package/Utils.d.ts +227 -0
  10. package/Utils.js +1247 -0
  11. package/Version.d.ts +1 -0
  12. package/Version.js +4 -0
  13. package/client/2fa.d.ts +48 -0
  14. package/client/2fa.js +108 -0
  15. package/client/TelegramClient.d.ts +1043 -0
  16. package/client/TelegramClient.js +1181 -0
  17. package/client/account.d.ts +0 -0
  18. package/client/account.js +1 -0
  19. package/client/auth.d.ts +92 -0
  20. package/client/auth.js +388 -0
  21. package/client/bots.d.ts +6 -0
  22. package/client/bots.js +23 -0
  23. package/client/buttons.d.ts +4 -0
  24. package/client/buttons.js +86 -0
  25. package/client/chats.d.ts +45 -0
  26. package/client/chats.js +350 -0
  27. package/client/dialogs.d.ts +52 -0
  28. package/client/dialogs.js +174 -0
  29. package/client/downloads.d.ts +156 -0
  30. package/client/downloads.js +614 -0
  31. package/client/fs.d.ts +1 -0
  32. package/client/fs.js +17 -0
  33. package/client/index.d.ts +15 -0
  34. package/client/index.js +64 -0
  35. package/client/messageParse.d.ts +17 -0
  36. package/client/messageParse.js +191 -0
  37. package/client/messages.d.ts +263 -0
  38. package/client/messages.js +813 -0
  39. package/client/os.d.ts +2 -0
  40. package/client/os.js +37 -0
  41. package/client/path.d.ts +2 -0
  42. package/client/path.js +7 -0
  43. package/client/telegramBaseClient.d.ts +237 -0
  44. package/client/telegramBaseClient.js +368 -0
  45. package/client/updates.d.ts +33 -0
  46. package/client/updates.js +260 -0
  47. package/client/uploads.d.ts +136 -0
  48. package/client/uploads.js +514 -0
  49. package/client/users.d.ts +29 -0
  50. package/client/users.js +490 -0
  51. package/crypto/AuthKey.d.ts +19 -0
  52. package/crypto/AuthKey.js +76 -0
  53. package/crypto/CTR.d.ts +5 -0
  54. package/crypto/CTR.js +16 -0
  55. package/crypto/Factorizator.d.ts +19 -0
  56. package/crypto/Factorizator.js +74 -0
  57. package/crypto/IGE.d.ts +11 -0
  58. package/crypto/IGE.js +115 -0
  59. package/crypto/RSA.d.ts +14 -0
  60. package/crypto/RSA.js +70 -0
  61. package/crypto/converters.d.ts +19 -0
  62. package/crypto/converters.js +52 -0
  63. package/crypto/crypto.d.ts +19 -0
  64. package/crypto/crypto.js +58 -0
  65. package/crypto/words.d.ts +6 -0
  66. package/crypto/words.js +47 -0
  67. package/define.d.ts +77 -0
  68. package/entityCache.d.ts +7 -0
  69. package/entityCache.js +79 -0
  70. package/errors/Common.d.ts +71 -0
  71. package/errors/Common.js +122 -0
  72. package/errors/RPCBaseErrors.d.ts +84 -0
  73. package/errors/RPCBaseErrors.js +134 -0
  74. package/errors/RPCErrorList.d.ts +37 -0
  75. package/errors/RPCErrorList.js +117 -0
  76. package/errors/index.d.ts +11 -0
  77. package/errors/index.js +32 -0
  78. package/events/Album.d.ts +36 -0
  79. package/events/Album.js +104 -0
  80. package/events/CallbackQuery.d.ts +73 -0
  81. package/events/CallbackQuery.js +193 -0
  82. package/events/DeletedMessage.d.ts +45 -0
  83. package/events/DeletedMessage.js +63 -0
  84. package/events/EditedMessage.d.ts +30 -0
  85. package/events/EditedMessage.js +41 -0
  86. package/events/NewMessage.d.ts +89 -0
  87. package/events/NewMessage.js +182 -0
  88. package/events/Raw.d.ts +29 -0
  89. package/events/Raw.js +43 -0
  90. package/events/common.d.ts +66 -0
  91. package/events/common.js +141 -0
  92. package/events/index.d.ts +2 -0
  93. package/events/index.js +8 -0
  94. package/extensions/AsyncQueue.d.ts +10 -0
  95. package/extensions/AsyncQueue.js +32 -0
  96. package/extensions/BinaryReader.d.ts +99 -0
  97. package/extensions/BinaryReader.js +242 -0
  98. package/extensions/BinaryWriter.d.ts +6 -0
  99. package/extensions/BinaryWriter.js +15 -0
  100. package/extensions/Deferred.d.ts +8 -0
  101. package/extensions/Deferred.js +16 -0
  102. package/extensions/Logger.d.ts +54 -0
  103. package/extensions/Logger.js +128 -0
  104. package/extensions/MessagePacker.d.ts +21 -0
  105. package/extensions/MessagePacker.js +154 -0
  106. package/extensions/PendingState.d.ts +12 -0
  107. package/extensions/PendingState.js +29 -0
  108. package/extensions/PromisedNetSockets.d.ts +24 -0
  109. package/extensions/PromisedNetSockets.js +192 -0
  110. package/extensions/PromisedWebSockets.d.ts +18 -0
  111. package/extensions/PromisedWebSockets.js +124 -0
  112. package/extensions/html.d.ts +5 -0
  113. package/extensions/html.js +228 -0
  114. package/extensions/index.d.ts +7 -0
  115. package/extensions/index.js +17 -0
  116. package/extensions/markdown.d.ts +5 -0
  117. package/extensions/markdown.js +76 -0
  118. package/extensions/markdownv2.d.ts +5 -0
  119. package/extensions/markdownv2.js +51 -0
  120. package/extensions/net.d.ts +1 -0
  121. package/extensions/net.js +17 -0
  122. package/extensions/socks.d.ts +1 -0
  123. package/extensions/socks.js +17 -0
  124. package/index.d.ts +14 -0
  125. package/index.js +62 -0
  126. package/inspect.d.ts +1 -0
  127. package/inspect.js +5 -0
  128. package/network/Authenticator.d.ts +12 -0
  129. package/network/Authenticator.js +192 -0
  130. package/network/MTProtoPlainSender.d.ts +19 -0
  131. package/network/MTProtoPlainSender.js +74 -0
  132. package/network/MTProtoSender.d.ts +290 -0
  133. package/network/MTProtoSender.js +873 -0
  134. package/network/MTProtoState.d.ts +102 -0
  135. package/network/MTProtoState.js +267 -0
  136. package/network/RequestState.d.ts +18 -0
  137. package/network/RequestState.js +35 -0
  138. package/network/connection/Connection.d.ts +69 -0
  139. package/network/connection/Connection.js +162 -0
  140. package/network/connection/TCPAbridged.d.ts +19 -0
  141. package/network/connection/TCPAbridged.js +58 -0
  142. package/network/connection/TCPFull.d.ts +16 -0
  143. package/network/connection/TCPFull.js +61 -0
  144. package/network/connection/TCPMTProxy.d.ts +49 -0
  145. package/network/connection/TCPMTProxy.js +121 -0
  146. package/network/connection/TCPObfuscated.d.ts +18 -0
  147. package/network/connection/TCPObfuscated.js +78 -0
  148. package/network/connection/index.d.ts +4 -0
  149. package/network/connection/index.js +11 -0
  150. package/network/index.d.ts +11 -0
  151. package/network/index.js +23 -0
  152. package/package.json +50 -0
  153. package/requestIter.d.ts +24 -0
  154. package/requestIter.js +109 -0
  155. package/sessions/Abstract.d.ts +103 -0
  156. package/sessions/Abstract.js +6 -0
  157. package/sessions/Memory.d.ts +38 -0
  158. package/sessions/Memory.js +272 -0
  159. package/sessions/StoreSession.d.ts +14 -0
  160. package/sessions/StoreSession.js +77 -0
  161. package/sessions/StringSession.d.ts +32 -0
  162. package/sessions/StringSession.js +116 -0
  163. package/sessions/index.d.ts +4 -0
  164. package/sessions/index.js +11 -0
  165. package/sessions/localStorage.d.ts +1 -0
  166. package/sessions/localStorage.js +4 -0
  167. package/tl/AllTLObjects.d.ts +3 -0
  168. package/tl/AllTLObjects.js +17 -0
  169. package/tl/MTProtoRequest.d.ts +18 -0
  170. package/tl/MTProtoRequest.js +38 -0
  171. package/tl/api.d.ts +32488 -0
  172. package/tl/api.js +507 -0
  173. package/tl/apiTl.d.ts +2 -0
  174. package/tl/apiTl.js +2209 -0
  175. package/tl/core/GZIPPacked.d.ts +15 -0
  176. package/tl/core/GZIPPacked.js +51 -0
  177. package/tl/core/MessageContainer.d.ts +12 -0
  178. package/tl/core/MessageContainer.js +42 -0
  179. package/tl/core/RPCResult.d.ts +14 -0
  180. package/tl/core/RPCResult.js +32 -0
  181. package/tl/core/TLMessage.d.ts +10 -0
  182. package/tl/core/TLMessage.js +14 -0
  183. package/tl/core/index.d.ts +6 -0
  184. package/tl/core/index.js +16 -0
  185. package/tl/custom/button.d.ts +24 -0
  186. package/tl/custom/button.js +78 -0
  187. package/tl/custom/chatGetter.d.ts +29 -0
  188. package/tl/custom/chatGetter.js +116 -0
  189. package/tl/custom/dialog.d.ts +30 -0
  190. package/tl/custom/dialog.js +40 -0
  191. package/tl/custom/draft.d.ts +21 -0
  192. package/tl/custom/draft.js +48 -0
  193. package/tl/custom/file.d.ts +21 -0
  194. package/tl/custom/file.js +68 -0
  195. package/tl/custom/forward.d.ts +15 -0
  196. package/tl/custom/forward.js +47 -0
  197. package/tl/custom/index.d.ts +1 -0
  198. package/tl/custom/index.js +5 -0
  199. package/tl/custom/inlineResult.d.ts +32 -0
  200. package/tl/custom/inlineResult.js +87 -0
  201. package/tl/custom/inlineResults.d.ts +20 -0
  202. package/tl/custom/inlineResults.js +26 -0
  203. package/tl/custom/message.d.ts +427 -0
  204. package/tl/custom/message.js +716 -0
  205. package/tl/custom/messageButton.d.ts +54 -0
  206. package/tl/custom/messageButton.js +152 -0
  207. package/tl/custom/senderGetter.d.ts +28 -0
  208. package/tl/custom/senderGetter.js +55 -0
  209. package/tl/generateModule.d.ts +1 -0
  210. package/tl/generateModule.js +17 -0
  211. package/tl/generationHelpers.d.ts +11 -0
  212. package/tl/generationHelpers.js +289 -0
  213. package/tl/index.d.ts +3 -0
  214. package/tl/index.js +10 -0
  215. package/tl/patched/index.d.ts +2 -0
  216. package/tl/patched/index.js +76 -0
  217. package/tl/schemaTl.d.ts +2 -0
  218. package/tl/schemaTl.js +64 -0
  219. package/tl/types-generator/generate.d.ts +1 -0
  220. package/tl/types-generator/generate.js +84 -0
  221. package/tl/types-generator/template.d.ts +6 -0
  222. package/tl/types-generator/template.js +257 -0
@@ -0,0 +1,156 @@
1
+ import { Api } from "../tl";
2
+ import type { TelegramClient } from "./TelegramClient";
3
+ import { EntityLike, OutFile, ProgressCallback } from "../define";
4
+ import { RequestIter } from "../requestIter";
5
+ import bigInt from "big-integer";
6
+ /**
7
+ * progress callback that will be called each time a new chunk is downloaded.
8
+ */
9
+ export interface progressCallback {
10
+ (
11
+ /** How much was downloaded */
12
+ downloaded: bigInt.BigInteger,
13
+ /** Full size of the file to be downloaded */
14
+ fullSize: bigInt.BigInteger,
15
+ /** other args to be passed if needed */
16
+ ...args: any[]): void;
17
+ /** When this value is set to true the download will stop */
18
+ isCanceled?: boolean;
19
+ /** Does nothing for now. */
20
+ acceptsBuffer?: boolean;
21
+ }
22
+ /**
23
+ * Low level interface for downloading files
24
+ */
25
+ export interface DownloadFileParams {
26
+ /** The dcId that the file belongs to. Used to borrow a sender from that DC */
27
+ dcId: number;
28
+ /** How much to download. The library will download until it reaches this amount.<br/>
29
+ * can be useful for downloading by chunks */
30
+ fileSize?: number;
31
+ /** Used to determine how many download tasks should be run in parallel. anything above 16 is unstable. */
32
+ workers?: number;
33
+ /** How much to download in each chunk. The larger the less requests to be made. (max is 512kb). */
34
+ partSizeKb?: number;
35
+ /** Where to start downloading. useful for chunk downloading. */
36
+ start?: number;
37
+ /** Where to stop downloading. useful for chunk downloading. */
38
+ end?: number;
39
+ /** A callback function accepting two parameters: ``(received bytes, total)``. */
40
+ progressCallback?: progressCallback;
41
+ }
42
+ /**
43
+ * Low level interface for downloading files
44
+ */
45
+ export interface DownloadFileParamsV2 {
46
+ /**
47
+ * The output file path, directory,buffer, or stream-like object.
48
+ * If the path exists and is a file, it will be overwritten.
49
+
50
+ * If the file path is `undefined` or `Buffer`, then the result
51
+ will be saved in memory and returned as `Buffer`.
52
+ */
53
+ outputFile?: OutFile;
54
+ /** The dcId that the file belongs to. Used to borrow a sender from that DC. The library should handle this for you */
55
+ dcId?: number;
56
+ /** The file size that is about to be downloaded, if known.<br/>
57
+ Only used if ``progressCallback`` is specified. */
58
+ fileSize?: bigInt.BigInteger;
59
+ /** How much to download in each chunk. The larger the less requests to be made. (max is 512kb). */
60
+ partSizeKb?: number;
61
+ /** Progress callback accepting one param. (progress :number) which is a float between 0 and 1 */
62
+ progressCallback?: progressCallback;
63
+ /** */
64
+ msgData?: [EntityLike, number];
65
+ }
66
+ /**
67
+ * contains optional download params for profile photo.
68
+ */
69
+ export interface DownloadProfilePhotoParams {
70
+ /** Whether to download the big version or the small one of the photo */
71
+ isBig?: boolean;
72
+ outputFile?: OutFile;
73
+ }
74
+ export interface DirectDownloadIterInterface {
75
+ fileLocation: Api.TypeInputFileLocation;
76
+ dcId: number;
77
+ offset: bigInt.BigInteger;
78
+ stride: number;
79
+ chunkSize: number;
80
+ requestSize: number;
81
+ fileSize: number;
82
+ msgData: number;
83
+ }
84
+ export interface IterDownloadFunction {
85
+ file?: Api.TypeMessageMedia | Api.TypeInputFile | Api.TypeInputFileLocation;
86
+ offset?: bigInt.BigInteger;
87
+ stride?: number;
88
+ limit?: number;
89
+ chunkSize?: number;
90
+ requestSize: number;
91
+ fileSize?: bigInt.BigInteger;
92
+ dcId?: number;
93
+ msgData?: [EntityLike, number];
94
+ }
95
+ export declare class DirectDownloadIter extends RequestIter {
96
+ protected request?: Api.upload.GetFile;
97
+ private _sender?;
98
+ private _timedOut;
99
+ protected _stride?: number;
100
+ protected _chunkSize?: number;
101
+ protected _lastPart?: Buffer;
102
+ protected buffer: Buffer[] | undefined;
103
+ _init({ fileLocation, dcId, offset, stride, chunkSize, requestSize, fileSize, msgData, }: DirectDownloadIterInterface): Promise<void>;
104
+ _loadNextChunk(): Promise<boolean | undefined>;
105
+ _request(): Promise<Buffer>;
106
+ close(): Promise<void>;
107
+ [Symbol.asyncIterator](): AsyncIterator<Buffer, any, undefined>;
108
+ }
109
+ export declare class GenericDownloadIter extends DirectDownloadIter {
110
+ _loadNextChunk(): Promise<boolean | undefined>;
111
+ }
112
+ /** @hidden */
113
+ export declare function iterDownload(client: TelegramClient, { file, offset, stride, limit, chunkSize, requestSize, fileSize, dcId, msgData, }: IterDownloadFunction): DirectDownloadIter;
114
+ /** @hidden */
115
+ export declare function downloadFileV2(client: TelegramClient, inputLocation: Api.TypeInputFileLocation, { outputFile, partSizeKb, fileSize, progressCallback, dcId, msgData, }: DownloadFileParamsV2): Promise<string | Buffer<ArrayBufferLike> | undefined>;
116
+ /**
117
+ * All of these are optional and will be calculated automatically if not specified.
118
+ */
119
+ export interface DownloadMediaInterface {
120
+ /**
121
+ * The output file location, if left undefined this method will return a buffer
122
+ */
123
+ outputFile?: OutFile;
124
+ /**
125
+ * Which thumbnail size from the document or photo to download, instead of downloading the document or photo itself.<br/>
126
+ <br/>
127
+ If it's specified but the file does not have a thumbnail, this method will return `undefined`.<br/>
128
+ <br/>
129
+ The parameter should be an integer index between ``0`` and ``sizes.length``.<br/>
130
+ ``0`` will download the smallest thumbnail, and ``sizes.length - 1`` will download the largest thumbnail.<br/>
131
+ <br/>
132
+ You can also pass the `Api.PhotoSize` instance to use. Alternatively, the thumb size type `string` may be used.<br/>
133
+ <br/>
134
+ In short, use ``thumb=0`` if you want the smallest thumbnail and ``thumb=sizes.length`` if you want the largest thumbnail.
135
+ */
136
+ thumb?: number | Api.TypePhotoSize;
137
+ /**
138
+ * A callback function accepting two parameters:
139
+ * ``(received bytes, total)``.
140
+ */
141
+ progressCallback?: ProgressCallback;
142
+ }
143
+ /** @hidden */
144
+ export declare function downloadMedia(client: TelegramClient, messageOrMedia: Api.Message | Api.TypeMessageMedia, outputFile?: OutFile, thumb?: number | Api.TypePhotoSize, progressCallback?: ProgressCallback): Promise<Buffer | string | undefined>;
145
+ /** @hidden */
146
+ export declare function _downloadDocument(client: TelegramClient, doc: Api.MessageMediaDocument | Api.TypeDocument, outputFile: OutFile | undefined, date: number, thumb?: number | string | Api.TypePhotoSize, progressCallback?: ProgressCallback, msgData?: [EntityLike, number]): Promise<Buffer | string | undefined>;
147
+ /** @hidden */
148
+ export declare function _downloadContact(client: TelegramClient, media: Api.MessageMediaContact, args: DownloadMediaInterface): Promise<Buffer>;
149
+ /** @hidden */
150
+ export declare function _downloadWebDocument(client: TelegramClient, media: Api.WebDocument | Api.WebDocumentNoProxy, args: DownloadMediaInterface): Promise<Buffer>;
151
+ /** @hidden */
152
+ export declare function _downloadCachedPhotoSize(size: Api.PhotoCachedSize | Api.PhotoStrippedSize, outputFile?: OutFile): Promise<string | Buffer<ArrayBufferLike> | undefined>;
153
+ /** @hidden */
154
+ export declare function _downloadPhoto(client: TelegramClient, photo: Api.MessageMediaPhoto | Api.Photo, file?: OutFile, date?: number, thumb?: number | string | Api.TypePhotoSize, progressCallback?: progressCallback): Promise<Buffer | string | undefined>;
155
+ /** @hidden */
156
+ export declare function downloadProfilePhoto(client: TelegramClient, entity: EntityLike, fileParams: DownloadProfilePhotoParams): Promise<string | Buffer<ArrayBufferLike> | undefined>;