teleproto 203.0.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 (224) hide show
  1. package/CryptoFile.d.ts +2 -0
  2. package/CryptoFile.js +23 -0
  3. package/Helpers.d.ts +151 -0
  4. package/Helpers.js +477 -0
  5. package/LICENSE +23 -0
  6. package/Password.d.ts +15 -0
  7. package/Password.js +271 -0
  8. package/README.md +111 -0
  9. package/Utils.d.ts +228 -0
  10. package/Utils.js +1248 -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 +109 -0
  15. package/client/TelegramClient.d.ts +1042 -0
  16. package/client/TelegramClient.js +1167 -0
  17. package/client/account.d.ts +0 -0
  18. package/client/account.js +1 -0
  19. package/client/auth.d.ts +93 -0
  20. package/client/auth.js +375 -0
  21. package/client/bots.d.ts +6 -0
  22. package/client/bots.js +24 -0
  23. package/client/buttons.d.ts +4 -0
  24. package/client/buttons.js +87 -0
  25. package/client/chats.d.ts +46 -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 +157 -0
  30. package/client/downloads.js +598 -0
  31. package/client/fs.d.ts +1 -0
  32. package/client/fs.js +13 -0
  33. package/client/index.d.ts +15 -0
  34. package/client/index.js +50 -0
  35. package/client/messageParse.d.ts +17 -0
  36. package/client/messageParse.js +191 -0
  37. package/client/messages.d.ts +259 -0
  38. package/client/messages.js +804 -0
  39. package/client/os.d.ts +2 -0
  40. package/client/os.js +23 -0
  41. package/client/path.d.ts +2 -0
  42. package/client/path.js +7 -0
  43. package/client/telegramBaseClient.d.ts +238 -0
  44. package/client/telegramBaseClient.js +368 -0
  45. package/client/updates.d.ts +31 -0
  46. package/client/updates.js +254 -0
  47. package/client/uploads.d.ts +137 -0
  48. package/client/uploads.js +514 -0
  49. package/client/users.d.ts +29 -0
  50. package/client/users.js +491 -0
  51. package/crypto/AuthKey.d.ts +20 -0
  52. package/crypto/AuthKey.js +76 -0
  53. package/crypto/CTR.d.ts +6 -0
  54. package/crypto/CTR.js +35 -0
  55. package/crypto/Factorizator.d.ts +19 -0
  56. package/crypto/Factorizator.js +74 -0
  57. package/crypto/IGE.d.ts +18 -0
  58. package/crypto/IGE.js +34 -0
  59. package/crypto/RSA.d.ts +15 -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 +27 -0
  64. package/crypto/crypto.js +117 -0
  65. package/crypto/words.d.ts +6 -0
  66. package/crypto/words.js +48 -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 +72 -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 +29 -0
  78. package/events/Album.d.ts +36 -0
  79. package/events/Album.js +104 -0
  80. package/events/CallbackQuery.d.ts +74 -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 +100 -0
  97. package/extensions/BinaryReader.js +242 -0
  98. package/extensions/BinaryWriter.d.ts +7 -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 +56 -0
  103. package/extensions/Logger.js +107 -0
  104. package/extensions/MessagePacker.d.ts +22 -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 +25 -0
  109. package/extensions/PromisedNetSockets.js +178 -0
  110. package/extensions/PromisedWebSockets.d.ts +19 -0
  111. package/extensions/PromisedWebSockets.js +124 -0
  112. package/extensions/html.d.ts +5 -0
  113. package/extensions/html.js +213 -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 +13 -0
  122. package/extensions/socks.d.ts +1 -0
  123. package/extensions/socks.js +13 -0
  124. package/index.d.ts +14 -0
  125. package/index.js +48 -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 +193 -0
  130. package/network/MTProtoPlainSender.d.ts +19 -0
  131. package/network/MTProtoPlainSender.js +74 -0
  132. package/network/MTProtoSender.d.ts +291 -0
  133. package/network/MTProtoSender.js +854 -0
  134. package/network/MTProtoState.d.ts +103 -0
  135. package/network/MTProtoState.js +267 -0
  136. package/network/RequestState.d.ts +19 -0
  137. package/network/RequestState.js +35 -0
  138. package/network/connection/Connection.d.ts +71 -0
  139. package/network/connection/Connection.js +157 -0
  140. package/network/connection/TCPAbridged.d.ts +20 -0
  141. package/network/connection/TCPAbridged.js +58 -0
  142. package/network/connection/TCPFull.d.ts +17 -0
  143. package/network/connection/TCPFull.js +61 -0
  144. package/network/connection/TCPMTProxy.d.ts +50 -0
  145. package/network/connection/TCPMTProxy.js +121 -0
  146. package/network/connection/TCPObfuscated.d.ts +19 -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 +69 -0
  153. package/requestIter.d.ts +24 -0
  154. package/requestIter.js +107 -0
  155. package/sessions/Abstract.d.ts +103 -0
  156. package/sessions/Abstract.js +6 -0
  157. package/sessions/CacheApiSession.d.ts +18 -0
  158. package/sessions/CacheApiSession.js +99 -0
  159. package/sessions/Memory.d.ts +38 -0
  160. package/sessions/Memory.js +272 -0
  161. package/sessions/StoreSession.d.ts +14 -0
  162. package/sessions/StoreSession.js +77 -0
  163. package/sessions/StringSession.d.ts +33 -0
  164. package/sessions/StringSession.js +116 -0
  165. package/sessions/index.d.ts +4 -0
  166. package/sessions/index.js +13 -0
  167. package/sessions/localStorage.d.ts +1 -0
  168. package/sessions/localStorage.js +4 -0
  169. package/tl/AllTLObjects.d.ts +3 -0
  170. package/tl/AllTLObjects.js +17 -0
  171. package/tl/MTProtoRequest.d.ts +19 -0
  172. package/tl/MTProtoRequest.js +38 -0
  173. package/tl/api.d.ts +31425 -0
  174. package/tl/api.js +507 -0
  175. package/tl/apiTl.d.ts +2 -0
  176. package/tl/apiTl.js +2142 -0
  177. package/tl/core/GZIPPacked.d.ts +16 -0
  178. package/tl/core/GZIPPacked.js +51 -0
  179. package/tl/core/MessageContainer.d.ts +12 -0
  180. package/tl/core/MessageContainer.js +42 -0
  181. package/tl/core/RPCResult.d.ts +15 -0
  182. package/tl/core/RPCResult.js +32 -0
  183. package/tl/core/TLMessage.d.ts +10 -0
  184. package/tl/core/TLMessage.js +14 -0
  185. package/tl/core/index.d.ts +6 -0
  186. package/tl/core/index.js +16 -0
  187. package/tl/custom/button.d.ts +25 -0
  188. package/tl/custom/button.js +78 -0
  189. package/tl/custom/chatGetter.d.ts +30 -0
  190. package/tl/custom/chatGetter.js +114 -0
  191. package/tl/custom/dialog.d.ts +31 -0
  192. package/tl/custom/dialog.js +40 -0
  193. package/tl/custom/draft.d.ts +22 -0
  194. package/tl/custom/draft.js +48 -0
  195. package/tl/custom/file.d.ts +22 -0
  196. package/tl/custom/file.js +68 -0
  197. package/tl/custom/forward.d.ts +16 -0
  198. package/tl/custom/forward.js +47 -0
  199. package/tl/custom/index.d.ts +1 -0
  200. package/tl/custom/index.js +5 -0
  201. package/tl/custom/inlineResult.d.ts +33 -0
  202. package/tl/custom/inlineResult.js +87 -0
  203. package/tl/custom/inlineResults.d.ts +21 -0
  204. package/tl/custom/inlineResults.js +26 -0
  205. package/tl/custom/message.d.ts +428 -0
  206. package/tl/custom/message.js +702 -0
  207. package/tl/custom/messageButton.d.ts +55 -0
  208. package/tl/custom/messageButton.js +152 -0
  209. package/tl/custom/senderGetter.d.ts +29 -0
  210. package/tl/custom/senderGetter.js +55 -0
  211. package/tl/generateModule.d.ts +1 -0
  212. package/tl/generateModule.js +17 -0
  213. package/tl/generationHelpers.d.ts +12 -0
  214. package/tl/generationHelpers.js +289 -0
  215. package/tl/index.d.ts +3 -0
  216. package/tl/index.js +10 -0
  217. package/tl/patched/index.d.ts +2 -0
  218. package/tl/patched/index.js +77 -0
  219. package/tl/schemaTl.d.ts +2 -0
  220. package/tl/schemaTl.js +64 -0
  221. package/tl/types-generator/generate.d.ts +1 -0
  222. package/tl/types-generator/generate.js +84 -0
  223. package/tl/types-generator/template.d.ts +6 -0
  224. package/tl/types-generator/template.js +257 -0
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StringSession = void 0;
4
+ const Memory_1 = require("./Memory");
5
+ const extensions_1 = require("../extensions");
6
+ const AuthKey_1 = require("../crypto/AuthKey");
7
+ const CURRENT_VERSION = "1";
8
+ class StringSession extends Memory_1.MemorySession {
9
+ /**
10
+ * This session file can be easily saved and loaded as a string. According
11
+ * to the initial design, it contains only the data that is necessary for
12
+ * successful connection and authentication, so takeout ID is not stored.
13
+
14
+ * It is thought to be used where you don't want to create any on-disk
15
+ * files but would still like to be able to save and load existing sessions
16
+ * by other means.
17
+
18
+ * You can use custom `encode` and `decode` functions, if present:
19
+
20
+ * `encode` definition must be ``function encode(value: Buffer) -> string:``.
21
+ * `decode` definition must be ``function decode(value: string) -> Buffer:``.
22
+ * @param session {string|null}
23
+ */
24
+ constructor(session) {
25
+ super();
26
+ if (session) {
27
+ if (session[0] !== CURRENT_VERSION) {
28
+ throw new Error("Not a valid string");
29
+ }
30
+ session = session.slice(1);
31
+ const r = StringSession.decode(session);
32
+ const reader = new extensions_1.BinaryReader(r);
33
+ this._dcId = reader.read(1).readUInt8(0);
34
+ if (session.length == 352) {
35
+ // Telethon session
36
+ const ip_v4 = reader.read(4);
37
+ // TODO looks ugly smh
38
+ this._serverAddress =
39
+ ip_v4[0].toString() +
40
+ "." +
41
+ ip_v4[1].toString() +
42
+ "." +
43
+ ip_v4[2].toString() +
44
+ "." +
45
+ ip_v4[3].toString();
46
+ }
47
+ else {
48
+ // TODO find a better of doing this
49
+ const serverAddressLen = reader.read(2).readInt16BE(0);
50
+ if (serverAddressLen > 100) {
51
+ reader.offset -= 2;
52
+ this._serverAddress = reader
53
+ .read(16)
54
+ .toString("hex")
55
+ .match(/.{1,4}/g)
56
+ .map((val) => val.replace(/^0+/, ""))
57
+ .join(":")
58
+ .replace(/0000\:/g, ":")
59
+ .replace(/:{2,}/g, "::");
60
+ }
61
+ else {
62
+ this._serverAddress = reader
63
+ .read(serverAddressLen)
64
+ .toString();
65
+ }
66
+ }
67
+ this._port = reader.read(2).readInt16BE(0);
68
+ this._key = reader.read(-1);
69
+ }
70
+ }
71
+ /**
72
+ * @param x {Buffer}
73
+ * @returns {string}
74
+ */
75
+ static encode(x) {
76
+ return x.toString("base64");
77
+ }
78
+ /**
79
+ * @param x {string}
80
+ * @returns {Buffer}
81
+ */
82
+ static decode(x) {
83
+ return Buffer.from(x, "base64");
84
+ }
85
+ async load() {
86
+ if (this._key) {
87
+ this._authKey = new AuthKey_1.AuthKey();
88
+ await this._authKey.setKey(this._key);
89
+ }
90
+ }
91
+ save() {
92
+ if (!this.authKey || !this.serverAddress || !this.port) {
93
+ return "";
94
+ }
95
+ // TS is weird
96
+ const key = this.authKey.getKey();
97
+ if (!key) {
98
+ return "";
99
+ }
100
+ const dcBuffer = Buffer.from([this.dcId]);
101
+ const addressBuffer = Buffer.from(this.serverAddress);
102
+ const addressLengthBuffer = Buffer.alloc(2);
103
+ addressLengthBuffer.writeInt16BE(addressBuffer.length, 0);
104
+ const portBuffer = Buffer.alloc(2);
105
+ portBuffer.writeInt16BE(this.port, 0);
106
+ return (CURRENT_VERSION +
107
+ StringSession.encode(Buffer.concat([
108
+ dcBuffer,
109
+ addressLengthBuffer,
110
+ addressBuffer,
111
+ portBuffer,
112
+ key,
113
+ ])));
114
+ }
115
+ }
116
+ exports.StringSession = StringSession;
@@ -0,0 +1,4 @@
1
+ export { MemorySession } from "./Memory";
2
+ export { StringSession } from "./StringSession";
3
+ export { StoreSession } from "./StoreSession";
4
+ export { Session } from "./Abstract";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Session = exports.StoreSession = exports.StringSession = exports.MemorySession = void 0;
4
+ var Memory_1 = require("./Memory");
5
+ Object.defineProperty(exports, "MemorySession", { enumerable: true, get: function () { return Memory_1.MemorySession; } });
6
+ var StringSession_1 = require("./StringSession");
7
+ Object.defineProperty(exports, "StringSession", { enumerable: true, get: function () { return StringSession_1.StringSession; } });
8
+ var StoreSession_1 = require("./StoreSession");
9
+ Object.defineProperty(exports, "StoreSession", { enumerable: true, get: function () { return StoreSession_1.StoreSession; } });
10
+ var Abstract_1 = require("./Abstract");
11
+ Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return Abstract_1.Session; } });
12
+ // @ts-ignore
13
+ //export {CacheApiSession} from './CacheApiSession';
@@ -0,0 +1 @@
1
+ export declare const LocalStorage: any;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalStorage = void 0;
4
+ exports.LocalStorage = require("node-localstorage").LocalStorage;
@@ -0,0 +1,3 @@
1
+ export declare const LAYER = 203;
2
+ declare const tlobjects: any;
3
+ export { tlobjects };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tlobjects = exports.LAYER = void 0;
4
+ exports.LAYER = 203;
5
+ const _1 = require(".");
6
+ const tlobjects = {};
7
+ exports.tlobjects = tlobjects;
8
+ for (const tl of Object.values(_1.Api)) {
9
+ if ("CONSTRUCTOR_ID" in tl) {
10
+ tlobjects[tl.CONSTRUCTOR_ID] = tl;
11
+ }
12
+ else {
13
+ for (const sub of Object.values(tl)) {
14
+ tlobjects[sub.CONSTRUCTOR_ID] = sub;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference types="node" />
2
+ export declare class MTProtoRequest {
3
+ private sent;
4
+ private sequence;
5
+ private msgId;
6
+ private readonly dirty;
7
+ private sendTime;
8
+ private confirmReceived;
9
+ private constructorId;
10
+ private readonly confirmed;
11
+ private responded;
12
+ constructor();
13
+ onSendSuccess(): void;
14
+ onConfirm(): void;
15
+ needResend(): boolean;
16
+ onSend(): void;
17
+ onResponse(buffer: Buffer): void;
18
+ onException(exception: Error): void;
19
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MTProtoRequest = void 0;
4
+ class MTProtoRequest {
5
+ constructor() {
6
+ this.sent = false;
7
+ this.msgId = 0; // long
8
+ this.sequence = 0;
9
+ this.dirty = false;
10
+ this.sendTime = 0;
11
+ this.confirmReceived = false;
12
+ // These should be overrode
13
+ this.constructorId = 0;
14
+ this.confirmed = false;
15
+ this.responded = false;
16
+ }
17
+ // these should not be overrode
18
+ onSendSuccess() {
19
+ this.sendTime = new Date().getTime();
20
+ this.sent = true;
21
+ }
22
+ onConfirm() {
23
+ this.confirmReceived = true;
24
+ }
25
+ needResend() {
26
+ return (this.dirty ||
27
+ (this.confirmed &&
28
+ !this.confirmReceived &&
29
+ new Date().getTime() - this.sendTime > 3000));
30
+ }
31
+ // These should be overrode
32
+ onSend() {
33
+ throw Error("Not overload " + this.constructor.name);
34
+ }
35
+ onResponse(buffer) { }
36
+ onException(exception) { }
37
+ }
38
+ exports.MTProtoRequest = MTProtoRequest;