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.
- package/CryptoFile.d.ts +2 -0
- package/CryptoFile.js +23 -0
- package/Helpers.d.ts +151 -0
- package/Helpers.js +477 -0
- package/LICENSE +23 -0
- package/Password.d.ts +15 -0
- package/Password.js +271 -0
- package/README.md +111 -0
- package/Utils.d.ts +228 -0
- package/Utils.js +1248 -0
- package/Version.d.ts +1 -0
- package/Version.js +4 -0
- package/client/2fa.d.ts +48 -0
- package/client/2fa.js +109 -0
- package/client/TelegramClient.d.ts +1042 -0
- package/client/TelegramClient.js +1167 -0
- package/client/account.d.ts +0 -0
- package/client/account.js +1 -0
- package/client/auth.d.ts +93 -0
- package/client/auth.js +375 -0
- package/client/bots.d.ts +6 -0
- package/client/bots.js +24 -0
- package/client/buttons.d.ts +4 -0
- package/client/buttons.js +87 -0
- package/client/chats.d.ts +46 -0
- package/client/chats.js +350 -0
- package/client/dialogs.d.ts +52 -0
- package/client/dialogs.js +174 -0
- package/client/downloads.d.ts +157 -0
- package/client/downloads.js +598 -0
- package/client/fs.d.ts +1 -0
- package/client/fs.js +13 -0
- package/client/index.d.ts +15 -0
- package/client/index.js +50 -0
- package/client/messageParse.d.ts +17 -0
- package/client/messageParse.js +191 -0
- package/client/messages.d.ts +259 -0
- package/client/messages.js +804 -0
- package/client/os.d.ts +2 -0
- package/client/os.js +23 -0
- package/client/path.d.ts +2 -0
- package/client/path.js +7 -0
- package/client/telegramBaseClient.d.ts +238 -0
- package/client/telegramBaseClient.js +368 -0
- package/client/updates.d.ts +31 -0
- package/client/updates.js +254 -0
- package/client/uploads.d.ts +137 -0
- package/client/uploads.js +514 -0
- package/client/users.d.ts +29 -0
- package/client/users.js +491 -0
- package/crypto/AuthKey.d.ts +20 -0
- package/crypto/AuthKey.js +76 -0
- package/crypto/CTR.d.ts +6 -0
- package/crypto/CTR.js +35 -0
- package/crypto/Factorizator.d.ts +19 -0
- package/crypto/Factorizator.js +74 -0
- package/crypto/IGE.d.ts +18 -0
- package/crypto/IGE.js +34 -0
- package/crypto/RSA.d.ts +15 -0
- package/crypto/RSA.js +70 -0
- package/crypto/converters.d.ts +19 -0
- package/crypto/converters.js +52 -0
- package/crypto/crypto.d.ts +27 -0
- package/crypto/crypto.js +117 -0
- package/crypto/words.d.ts +6 -0
- package/crypto/words.js +48 -0
- package/define.d.ts +77 -0
- package/entityCache.d.ts +7 -0
- package/entityCache.js +79 -0
- package/errors/Common.d.ts +72 -0
- package/errors/Common.js +122 -0
- package/errors/RPCBaseErrors.d.ts +84 -0
- package/errors/RPCBaseErrors.js +134 -0
- package/errors/RPCErrorList.d.ts +37 -0
- package/errors/RPCErrorList.js +117 -0
- package/errors/index.d.ts +11 -0
- package/errors/index.js +29 -0
- package/events/Album.d.ts +36 -0
- package/events/Album.js +104 -0
- package/events/CallbackQuery.d.ts +74 -0
- package/events/CallbackQuery.js +193 -0
- package/events/DeletedMessage.d.ts +45 -0
- package/events/DeletedMessage.js +63 -0
- package/events/EditedMessage.d.ts +30 -0
- package/events/EditedMessage.js +41 -0
- package/events/NewMessage.d.ts +89 -0
- package/events/NewMessage.js +182 -0
- package/events/Raw.d.ts +29 -0
- package/events/Raw.js +43 -0
- package/events/common.d.ts +66 -0
- package/events/common.js +141 -0
- package/events/index.d.ts +2 -0
- package/events/index.js +8 -0
- package/extensions/AsyncQueue.d.ts +10 -0
- package/extensions/AsyncQueue.js +32 -0
- package/extensions/BinaryReader.d.ts +100 -0
- package/extensions/BinaryReader.js +242 -0
- package/extensions/BinaryWriter.d.ts +7 -0
- package/extensions/BinaryWriter.js +15 -0
- package/extensions/Deferred.d.ts +8 -0
- package/extensions/Deferred.js +16 -0
- package/extensions/Logger.d.ts +56 -0
- package/extensions/Logger.js +107 -0
- package/extensions/MessagePacker.d.ts +22 -0
- package/extensions/MessagePacker.js +154 -0
- package/extensions/PendingState.d.ts +12 -0
- package/extensions/PendingState.js +29 -0
- package/extensions/PromisedNetSockets.d.ts +25 -0
- package/extensions/PromisedNetSockets.js +178 -0
- package/extensions/PromisedWebSockets.d.ts +19 -0
- package/extensions/PromisedWebSockets.js +124 -0
- package/extensions/html.d.ts +5 -0
- package/extensions/html.js +213 -0
- package/extensions/index.d.ts +7 -0
- package/extensions/index.js +17 -0
- package/extensions/markdown.d.ts +5 -0
- package/extensions/markdown.js +76 -0
- package/extensions/markdownv2.d.ts +5 -0
- package/extensions/markdownv2.js +51 -0
- package/extensions/net.d.ts +1 -0
- package/extensions/net.js +13 -0
- package/extensions/socks.d.ts +1 -0
- package/extensions/socks.js +13 -0
- package/index.d.ts +14 -0
- package/index.js +48 -0
- package/inspect.d.ts +1 -0
- package/inspect.js +5 -0
- package/network/Authenticator.d.ts +12 -0
- package/network/Authenticator.js +193 -0
- package/network/MTProtoPlainSender.d.ts +19 -0
- package/network/MTProtoPlainSender.js +74 -0
- package/network/MTProtoSender.d.ts +291 -0
- package/network/MTProtoSender.js +854 -0
- package/network/MTProtoState.d.ts +103 -0
- package/network/MTProtoState.js +267 -0
- package/network/RequestState.d.ts +19 -0
- package/network/RequestState.js +35 -0
- package/network/connection/Connection.d.ts +71 -0
- package/network/connection/Connection.js +157 -0
- package/network/connection/TCPAbridged.d.ts +20 -0
- package/network/connection/TCPAbridged.js +58 -0
- package/network/connection/TCPFull.d.ts +17 -0
- package/network/connection/TCPFull.js +61 -0
- package/network/connection/TCPMTProxy.d.ts +50 -0
- package/network/connection/TCPMTProxy.js +121 -0
- package/network/connection/TCPObfuscated.d.ts +19 -0
- package/network/connection/TCPObfuscated.js +78 -0
- package/network/connection/index.d.ts +4 -0
- package/network/connection/index.js +11 -0
- package/network/index.d.ts +11 -0
- package/network/index.js +23 -0
- package/package.json +69 -0
- package/requestIter.d.ts +24 -0
- package/requestIter.js +107 -0
- package/sessions/Abstract.d.ts +103 -0
- package/sessions/Abstract.js +6 -0
- package/sessions/CacheApiSession.d.ts +18 -0
- package/sessions/CacheApiSession.js +99 -0
- package/sessions/Memory.d.ts +38 -0
- package/sessions/Memory.js +272 -0
- package/sessions/StoreSession.d.ts +14 -0
- package/sessions/StoreSession.js +77 -0
- package/sessions/StringSession.d.ts +33 -0
- package/sessions/StringSession.js +116 -0
- package/sessions/index.d.ts +4 -0
- package/sessions/index.js +13 -0
- package/sessions/localStorage.d.ts +1 -0
- package/sessions/localStorage.js +4 -0
- package/tl/AllTLObjects.d.ts +3 -0
- package/tl/AllTLObjects.js +17 -0
- package/tl/MTProtoRequest.d.ts +19 -0
- package/tl/MTProtoRequest.js +38 -0
- package/tl/api.d.ts +31425 -0
- package/tl/api.js +507 -0
- package/tl/apiTl.d.ts +2 -0
- package/tl/apiTl.js +2142 -0
- package/tl/core/GZIPPacked.d.ts +16 -0
- package/tl/core/GZIPPacked.js +51 -0
- package/tl/core/MessageContainer.d.ts +12 -0
- package/tl/core/MessageContainer.js +42 -0
- package/tl/core/RPCResult.d.ts +15 -0
- package/tl/core/RPCResult.js +32 -0
- package/tl/core/TLMessage.d.ts +10 -0
- package/tl/core/TLMessage.js +14 -0
- package/tl/core/index.d.ts +6 -0
- package/tl/core/index.js +16 -0
- package/tl/custom/button.d.ts +25 -0
- package/tl/custom/button.js +78 -0
- package/tl/custom/chatGetter.d.ts +30 -0
- package/tl/custom/chatGetter.js +114 -0
- package/tl/custom/dialog.d.ts +31 -0
- package/tl/custom/dialog.js +40 -0
- package/tl/custom/draft.d.ts +22 -0
- package/tl/custom/draft.js +48 -0
- package/tl/custom/file.d.ts +22 -0
- package/tl/custom/file.js +68 -0
- package/tl/custom/forward.d.ts +16 -0
- package/tl/custom/forward.js +47 -0
- package/tl/custom/index.d.ts +1 -0
- package/tl/custom/index.js +5 -0
- package/tl/custom/inlineResult.d.ts +33 -0
- package/tl/custom/inlineResult.js +87 -0
- package/tl/custom/inlineResults.d.ts +21 -0
- package/tl/custom/inlineResults.js +26 -0
- package/tl/custom/message.d.ts +428 -0
- package/tl/custom/message.js +702 -0
- package/tl/custom/messageButton.d.ts +55 -0
- package/tl/custom/messageButton.js +152 -0
- package/tl/custom/senderGetter.d.ts +29 -0
- package/tl/custom/senderGetter.js +55 -0
- package/tl/generateModule.d.ts +1 -0
- package/tl/generateModule.js +17 -0
- package/tl/generationHelpers.d.ts +12 -0
- package/tl/generationHelpers.js +289 -0
- package/tl/index.d.ts +3 -0
- package/tl/index.js +10 -0
- package/tl/patched/index.d.ts +2 -0
- package/tl/patched/index.js +77 -0
- package/tl/schemaTl.d.ts +2 -0
- package/tl/schemaTl.js +64 -0
- package/tl/types-generator/generate.d.ts +1 -0
- package/tl/types-generator/generate.js +84 -0
- package/tl/types-generator/template.d.ts +6 -0
- 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,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,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;
|