@armatofik/tgsnake-core 1.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/COPYING +674 -0
- package/COPYING.lesser +165 -0
- package/README.md +88 -0
- package/lib/package.json +46 -0
- package/lib/src/Logger.d.ts +3 -0
- package/lib/src/Logger.js +9 -0
- package/lib/src/Queue.d.ts +19 -0
- package/lib/src/Queue.js +52 -0
- package/lib/src/Timeout.d.ts +9 -0
- package/lib/src/Timeout.js +44 -0
- package/lib/src/Version.node.d.ts +4 -0
- package/lib/src/Version.node.js +26 -0
- package/lib/src/client/Auth.d.ts +40 -0
- package/lib/src/client/Auth.js +317 -0
- package/lib/src/client/Client.d.ts +83 -0
- package/lib/src/client/Client.js +461 -0
- package/lib/src/client/Session.d.ts +9 -0
- package/lib/src/client/Session.js +132 -0
- package/lib/src/client/index.d.ts +3 -0
- package/lib/src/client/index.js +39 -0
- package/lib/src/connection/TCP/TCPAbridged.d.ts +9 -0
- package/lib/src/connection/TCP/TCPAbridged.js +47 -0
- package/lib/src/connection/TCP/TCPAbridgedO.d.ts +12 -0
- package/lib/src/connection/TCP/TCPAbridgedO.js +140 -0
- package/lib/src/connection/TCP/TCPFull.d.ts +10 -0
- package/lib/src/connection/TCP/TCPFull.js +43 -0
- package/lib/src/connection/TCP/TCPIntermediate.d.ts +9 -0
- package/lib/src/connection/TCP/TCPIntermediate.js +31 -0
- package/lib/src/connection/TCP/TCPIntermediateO.d.ts +12 -0
- package/lib/src/connection/TCP/TCPIntermediateO.js +123 -0
- package/lib/src/connection/TCP/TCPPaddedIntermediate.d.ts +9 -0
- package/lib/src/connection/TCP/TCPPaddedIntermediate.js +38 -0
- package/lib/src/connection/TCP/index.d.ts +7 -0
- package/lib/src/connection/TCP/index.js +17 -0
- package/lib/src/connection/TCP/tcp.d.ts +17 -0
- package/lib/src/connection/TCP/tcp.js +98 -0
- package/lib/src/connection/WebSocket.d.ts +21 -0
- package/lib/src/connection/WebSocket.js +279 -0
- package/lib/src/connection/connection.d.ts +53 -0
- package/lib/src/connection/connection.js +189 -0
- package/lib/src/connection/index.d.ts +4 -0
- package/lib/src/connection/index.js +41 -0
- package/lib/src/crypto/Aes.d.ts +10 -0
- package/lib/src/crypto/Aes.js +135 -0
- package/lib/src/crypto/Mtproto.d.ts +5 -0
- package/lib/src/crypto/Mtproto.js +123 -0
- package/lib/src/crypto/Password.d.ts +5 -0
- package/lib/src/crypto/Password.js +92 -0
- package/lib/src/crypto/Prime.d.ts +4 -0
- package/lib/src/crypto/Prime.js +64 -0
- package/lib/src/crypto/RSA.d.ts +7 -0
- package/lib/src/crypto/RSA.js +99 -0
- package/lib/src/crypto/SecretChat.d.ts +5 -0
- package/lib/src/crypto/SecretChat.js +136 -0
- package/lib/src/crypto/index.d.ts +6 -0
- package/lib/src/crypto/index.js +42 -0
- package/lib/src/errors/Base.d.ts +9 -0
- package/lib/src/errors/Base.js +50 -0
- package/lib/src/errors/Client.d.ts +21 -0
- package/lib/src/errors/Client.js +29 -0
- package/lib/src/errors/File.d.ts +13 -0
- package/lib/src/errors/File.js +30 -0
- package/lib/src/errors/RpcError.d.ts +22 -0
- package/lib/src/errors/RpcError.js +120 -0
- package/lib/src/errors/SecretChat.d.ts +13 -0
- package/lib/src/errors/SecretChat.js +30 -0
- package/lib/src/errors/WebSocket.d.ts +13 -0
- package/lib/src/errors/WebSocket.js +30 -0
- package/lib/src/errors/exceptions/All.d.ts +774 -0
- package/lib/src/errors/exceptions/All.js +778 -0
- package/lib/src/errors/exceptions/BadRequest400.d.ts +2345 -0
- package/lib/src/errors/exceptions/BadRequest400.js +2945 -0
- package/lib/src/errors/exceptions/Flood420.d.ts +37 -0
- package/lib/src/errors/exceptions/Flood420.js +49 -0
- package/lib/src/errors/exceptions/Forbidden403.d.ts +205 -0
- package/lib/src/errors/exceptions/Forbidden403.js +260 -0
- package/lib/src/errors/exceptions/InternalServerError500.d.ts +221 -0
- package/lib/src/errors/exceptions/InternalServerError500.js +280 -0
- package/lib/src/errors/exceptions/NotAcceptable406.d.ts +117 -0
- package/lib/src/errors/exceptions/NotAcceptable406.js +149 -0
- package/lib/src/errors/exceptions/NotFound404.d.ts +9 -0
- package/lib/src/errors/exceptions/NotFound404.js +14 -0
- package/lib/src/errors/exceptions/SeeOther303.d.ts +25 -0
- package/lib/src/errors/exceptions/SeeOther303.js +34 -0
- package/lib/src/errors/exceptions/ServiceUnavailable503.d.ts +17 -0
- package/lib/src/errors/exceptions/ServiceUnavailable503.js +24 -0
- package/lib/src/errors/exceptions/Unauthorized401.d.ts +41 -0
- package/lib/src/errors/exceptions/Unauthorized401.js +54 -0
- package/lib/src/errors/exceptions/index.d.ts +10 -0
- package/lib/src/errors/exceptions/index.js +48 -0
- package/lib/src/errors/index.d.ts +31 -0
- package/lib/src/errors/index.js +111 -0
- package/lib/src/file/Download.d.ts +11 -0
- package/lib/src/file/Download.js +118 -0
- package/lib/src/file/File.d.ts +20 -0
- package/lib/src/file/File.js +82 -0
- package/lib/src/file/Upload.d.ts +19 -0
- package/lib/src/file/Upload.js +250 -0
- package/lib/src/file/index.d.ts +3 -0
- package/lib/src/file/index.js +11 -0
- package/lib/src/helpers.d.ts +34 -0
- package/lib/src/helpers.js +358 -0
- package/lib/src/index.d.ts +16 -0
- package/lib/src/index.js +56 -0
- package/lib/src/platform.node.d.ts +36 -0
- package/lib/src/platform.node.js +109 -0
- package/lib/src/raw/All.d.ts +2400 -0
- package/lib/src/raw/All.js +2403 -0
- package/lib/src/raw/Raw.d.ts +29195 -0
- package/lib/src/raw/Raw.js +97277 -0
- package/lib/src/raw/core/BytesIO.d.ts +33 -0
- package/lib/src/raw/core/BytesIO.js +145 -0
- package/lib/src/raw/core/GzipPacked.d.ts +10 -0
- package/lib/src/raw/core/GzipPacked.js +60 -0
- package/lib/src/raw/core/Message.d.ts +13 -0
- package/lib/src/raw/core/Message.js +81 -0
- package/lib/src/raw/core/MsgContainer.d.ts +11 -0
- package/lib/src/raw/core/MsgContainer.js +69 -0
- package/lib/src/raw/core/TLObject.d.ts +19 -0
- package/lib/src/raw/core/TLObject.js +108 -0
- package/lib/src/raw/core/UpdateSecretChat.d.ts +40 -0
- package/lib/src/raw/core/UpdateSecretChat.js +88 -0
- package/lib/src/raw/core/index.d.ts +8 -0
- package/lib/src/raw/core/index.js +52 -0
- package/lib/src/raw/core/primitive/Bool.d.ts +20 -0
- package/lib/src/raw/core/primitive/Bool.js +41 -0
- package/lib/src/raw/core/primitive/Bytes.d.ts +7 -0
- package/lib/src/raw/core/primitive/Bytes.js +41 -0
- package/lib/src/raw/core/primitive/Double.d.ts +7 -0
- package/lib/src/raw/core/primitive/Double.js +24 -0
- package/lib/src/raw/core/primitive/Float.d.ts +7 -0
- package/lib/src/raw/core/primitive/Float.js +24 -0
- package/lib/src/raw/core/primitive/Int.d.ts +23 -0
- package/lib/src/raw/core/primitive/Int.js +122 -0
- package/lib/src/raw/core/primitive/String.d.ts +7 -0
- package/lib/src/raw/core/primitive/String.js +15 -0
- package/lib/src/raw/core/primitive/Vector.d.ts +9 -0
- package/lib/src/raw/core/primitive/Vector.js +50 -0
- package/lib/src/raw/core/primitive/index.d.ts +7 -0
- package/lib/src/raw/core/primitive/index.js +22 -0
- package/lib/src/raw/index.d.ts +3 -0
- package/lib/src/raw/index.js +17 -0
- package/lib/src/session/Auth.d.ts +15 -0
- package/lib/src/session/Auth.js +254 -0
- package/lib/src/session/Session.d.ts +58 -0
- package/lib/src/session/Session.js +571 -0
- package/lib/src/session/index.d.ts +7 -0
- package/lib/src/session/index.js +49 -0
- package/lib/src/session/internals/DataCenter.d.ts +42 -0
- package/lib/src/session/internals/DataCenter.js +80 -0
- package/lib/src/session/internals/MsgFactory.d.ts +3 -0
- package/lib/src/session/internals/MsgFactory.js +23 -0
- package/lib/src/session/internals/MsgId.d.ts +9 -0
- package/lib/src/session/internals/MsgId.js +24 -0
- package/lib/src/session/internals/SeqNo.d.ts +6 -0
- package/lib/src/session/internals/SeqNo.js +18 -0
- package/lib/src/session/secretChats/SecretChat.d.ts +29 -0
- package/lib/src/session/secretChats/SecretChat.js +527 -0
- package/lib/src/session/secretChats/index.d.ts +1 -0
- package/lib/src/session/secretChats/index.js +5 -0
- package/lib/src/storage/Abstract.d.ts +68 -0
- package/lib/src/storage/Abstract.js +6 -0
- package/lib/src/storage/SecretChat.d.ts +42 -0
- package/lib/src/storage/SecretChat.js +99 -0
- package/lib/src/storage/Session.d.ts +63 -0
- package/lib/src/storage/Session.js +245 -0
- package/lib/src/storage/StringSession.d.ts +4 -0
- package/lib/src/storage/StringSession.js +77 -0
- package/lib/src/storage/index.d.ts +4 -0
- package/lib/src/storage/index.js +12 -0
- package/package.json +46 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Primitive from './primitive/index.js';
|
|
2
|
+
export { Primitive };
|
|
3
|
+
export { BytesIO } from './BytesIO.js';
|
|
4
|
+
export { TLObject } from './TLObject.js';
|
|
5
|
+
export { GzipPacked } from './GzipPacked.js';
|
|
6
|
+
export { Message } from './Message.js';
|
|
7
|
+
export { MsgContainer } from './MsgContainer.js';
|
|
8
|
+
export { UpdateSecretChatMessage, SecretChatMessage, SecretChatMessageService, } from './UpdateSecretChat.js';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SecretChatMessageService = exports.SecretChatMessage = exports.UpdateSecretChatMessage = exports.MsgContainer = exports.Message = exports.GzipPacked = exports.TLObject = exports.BytesIO = exports.Primitive = void 0;
|
|
37
|
+
const Primitive = __importStar(require("./primitive/index.js"));
|
|
38
|
+
exports.Primitive = Primitive;
|
|
39
|
+
var BytesIO_js_1 = require("./BytesIO.js");
|
|
40
|
+
Object.defineProperty(exports, "BytesIO", { enumerable: true, get: function () { return BytesIO_js_1.BytesIO; } });
|
|
41
|
+
var TLObject_js_1 = require("./TLObject.js");
|
|
42
|
+
Object.defineProperty(exports, "TLObject", { enumerable: true, get: function () { return TLObject_js_1.TLObject; } });
|
|
43
|
+
var GzipPacked_js_1 = require("./GzipPacked.js");
|
|
44
|
+
Object.defineProperty(exports, "GzipPacked", { enumerable: true, get: function () { return GzipPacked_js_1.GzipPacked; } });
|
|
45
|
+
var Message_js_1 = require("./Message.js");
|
|
46
|
+
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return Message_js_1.Message; } });
|
|
47
|
+
var MsgContainer_js_1 = require("./MsgContainer.js");
|
|
48
|
+
Object.defineProperty(exports, "MsgContainer", { enumerable: true, get: function () { return MsgContainer_js_1.MsgContainer; } });
|
|
49
|
+
var UpdateSecretChat_js_1 = require("./UpdateSecretChat.js");
|
|
50
|
+
Object.defineProperty(exports, "UpdateSecretChatMessage", { enumerable: true, get: function () { return UpdateSecretChat_js_1.UpdateSecretChatMessage; } });
|
|
51
|
+
Object.defineProperty(exports, "SecretChatMessage", { enumerable: true, get: function () { return UpdateSecretChat_js_1.SecretChatMessage; } });
|
|
52
|
+
Object.defineProperty(exports, "SecretChatMessageService", { enumerable: true, get: function () { return UpdateSecretChat_js_1.SecretChatMessageService; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class BoolFalse extends TLObject {
|
|
5
|
+
static ID: number;
|
|
6
|
+
static value: boolean;
|
|
7
|
+
static write(): Buffer;
|
|
8
|
+
static read(_data: BytesIO, ..._arg: Array<any>): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
export declare class BoolTrue extends BoolFalse {
|
|
11
|
+
static ID: number;
|
|
12
|
+
static value: boolean;
|
|
13
|
+
static write(): Buffer;
|
|
14
|
+
static read(_data: BytesIO, ..._arg: Array<any>): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export declare class Bool extends TLObject {
|
|
17
|
+
className: string;
|
|
18
|
+
static write(value: boolean): Buffer;
|
|
19
|
+
static read(data: BytesIO, ..._arg: Array<any>): Promise<boolean>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bool = exports.BoolTrue = exports.BoolFalse = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
6
|
+
class BoolFalse extends TLObject_js_1.TLObject {
|
|
7
|
+
static ID = 0xbc799737;
|
|
8
|
+
static value = false;
|
|
9
|
+
static write() {
|
|
10
|
+
const buff = platform_node_js_1.Buffer.alloc(4);
|
|
11
|
+
buff.writeUInt32LE(BoolFalse.ID);
|
|
12
|
+
return buff;
|
|
13
|
+
}
|
|
14
|
+
static async read(_data, ..._arg) {
|
|
15
|
+
return BoolFalse.value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.BoolFalse = BoolFalse;
|
|
19
|
+
class BoolTrue extends BoolFalse {
|
|
20
|
+
static ID = 0x997275b5;
|
|
21
|
+
static value = true;
|
|
22
|
+
static write() {
|
|
23
|
+
const buff = platform_node_js_1.Buffer.alloc(4);
|
|
24
|
+
buff.writeUInt32LE(BoolTrue.ID);
|
|
25
|
+
return buff;
|
|
26
|
+
}
|
|
27
|
+
static async read(_data, ..._arg) {
|
|
28
|
+
return BoolTrue.value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BoolTrue = BoolTrue;
|
|
32
|
+
class Bool extends TLObject_js_1.TLObject {
|
|
33
|
+
className = 'Bool';
|
|
34
|
+
static write(value) {
|
|
35
|
+
return value ? BoolTrue.write() : BoolFalse.write();
|
|
36
|
+
}
|
|
37
|
+
static async read(data, ..._arg) {
|
|
38
|
+
return data.readUInt32LE(4) === BoolTrue.ID;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Bool = Bool;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class Bytes extends TLObject {
|
|
5
|
+
static write(value: Buffer): Buffer;
|
|
6
|
+
static read(data: BytesIO, ..._args: Array<any>): Promise<Buffer>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Bytes = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const helpers_js_1 = require("../../../helpers.js");
|
|
6
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
7
|
+
class Bytes extends TLObject_js_1.TLObject {
|
|
8
|
+
static write(value) {
|
|
9
|
+
const length = platform_node_js_1.Buffer.byteLength(value);
|
|
10
|
+
if (length <= 253) {
|
|
11
|
+
return platform_node_js_1.Buffer.concat([
|
|
12
|
+
platform_node_js_1.Buffer.from([length]),
|
|
13
|
+
value,
|
|
14
|
+
platform_node_js_1.Buffer.alloc((0, helpers_js_1.mod)(-(length + 1), 4)),
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return platform_node_js_1.Buffer.concat([
|
|
19
|
+
platform_node_js_1.Buffer.from([254]),
|
|
20
|
+
(0, helpers_js_1.bigintToBuffer)(BigInt(length), 3),
|
|
21
|
+
value,
|
|
22
|
+
platform_node_js_1.Buffer.alloc((0, helpers_js_1.mod)(-length, 4)),
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static async read(data, ..._args) {
|
|
27
|
+
let length = data.read(1)[0];
|
|
28
|
+
if (length <= 253) {
|
|
29
|
+
const x = data.read(length);
|
|
30
|
+
data.read((0, helpers_js_1.mod)(-(length + 1), 4));
|
|
31
|
+
return x;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
length = Number((0, helpers_js_1.bufferToBigint)(data.read(3)));
|
|
35
|
+
const x = data.read(length);
|
|
36
|
+
data.read((0, helpers_js_1.mod)(-length, 4));
|
|
37
|
+
return x;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Bytes = Bytes;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class Double extends TLObject {
|
|
5
|
+
static write(value: number, little?: boolean): Buffer;
|
|
6
|
+
static read(data: BytesIO, little?: boolean): Promise<number>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Double = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
6
|
+
class Double extends TLObject_js_1.TLObject {
|
|
7
|
+
static write(value, little = true) {
|
|
8
|
+
const buffer = platform_node_js_1.Buffer.alloc(8);
|
|
9
|
+
if (little) {
|
|
10
|
+
buffer.writeDoubleLE(value);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
buffer.writeDoubleBE(value);
|
|
14
|
+
}
|
|
15
|
+
return buffer;
|
|
16
|
+
}
|
|
17
|
+
static async read(data, little = true) {
|
|
18
|
+
if (little) {
|
|
19
|
+
return data.readDoubleLE();
|
|
20
|
+
}
|
|
21
|
+
return data.readDoubleBE();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Double = Double;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class Float extends TLObject {
|
|
5
|
+
static write(value: number, little?: boolean): Buffer;
|
|
6
|
+
static read(data: BytesIO, little?: boolean): Promise<number>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Float = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
6
|
+
class Float extends TLObject_js_1.TLObject {
|
|
7
|
+
static write(value, little = true) {
|
|
8
|
+
const buffer = platform_node_js_1.Buffer.alloc(4);
|
|
9
|
+
if (little) {
|
|
10
|
+
buffer.writeFloatLE(value);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
buffer.writeFloatBE(value);
|
|
14
|
+
}
|
|
15
|
+
return buffer;
|
|
16
|
+
}
|
|
17
|
+
static async read(data, little = true) {
|
|
18
|
+
if (little) {
|
|
19
|
+
return data.readFloatLE();
|
|
20
|
+
}
|
|
21
|
+
return data.readFloatBE();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Float = Float;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class Int extends TLObject {
|
|
5
|
+
static SIZE: number;
|
|
6
|
+
static write(value: number | bigint, signed?: boolean, little?: boolean): Buffer;
|
|
7
|
+
static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<number>;
|
|
8
|
+
}
|
|
9
|
+
export declare class Long extends TLObject {
|
|
10
|
+
static SIZE: number;
|
|
11
|
+
static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<bigint>;
|
|
12
|
+
static write(value: bigint, signed?: boolean, little?: boolean): Buffer;
|
|
13
|
+
}
|
|
14
|
+
export declare class Int128 extends Long {
|
|
15
|
+
static SIZE: number;
|
|
16
|
+
static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<bigint>;
|
|
17
|
+
static write(value: bigint, _signed?: boolean, _little?: boolean): Buffer;
|
|
18
|
+
}
|
|
19
|
+
export declare class Int256 extends Long {
|
|
20
|
+
static SIZE: number;
|
|
21
|
+
static read(data: BytesIO, signed?: boolean, little?: boolean, size?: number): Promise<bigint>;
|
|
22
|
+
static write(value: bigint, _signed?: boolean, _little?: boolean): Buffer;
|
|
23
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Int256 = exports.Int128 = exports.Long = exports.Int = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const helpers_js_1 = require("../../../helpers.js");
|
|
6
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
7
|
+
class Int extends TLObject_js_1.TLObject {
|
|
8
|
+
static SIZE = 4;
|
|
9
|
+
static write(value, signed = true, little = true) {
|
|
10
|
+
const buffer = platform_node_js_1.Buffer.alloc(Int.SIZE);
|
|
11
|
+
if (signed) {
|
|
12
|
+
if (little) {
|
|
13
|
+
buffer.writeInt32LE(Number(value));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
buffer.writeInt32BE(Number(value));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (little) {
|
|
21
|
+
buffer.writeUInt32LE(Number(value));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
buffer.writeUInt32BE(Number(value));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return buffer;
|
|
28
|
+
}
|
|
29
|
+
static async read(data, signed = true, little = true, size = Int.SIZE) {
|
|
30
|
+
if (signed) {
|
|
31
|
+
if (little) {
|
|
32
|
+
return data.readInt32LE(size);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return data.readInt32BE(size);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (little) {
|
|
40
|
+
return data.readUInt32LE(size);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
return data.readUInt32BE(size);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.Int = Int;
|
|
49
|
+
class Long extends TLObject_js_1.TLObject {
|
|
50
|
+
static SIZE = 8;
|
|
51
|
+
static async read(data, signed = true, little = true, size = Long.SIZE) {
|
|
52
|
+
if (signed) {
|
|
53
|
+
if (little) {
|
|
54
|
+
return data.readBigInt64LE(size);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return data.readBigInt64BE(size);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (little) {
|
|
62
|
+
return data.readBigUInt64LE(size);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return data.readBigUInt64BE(size);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static write(value, signed = true, little = true) {
|
|
70
|
+
const buffer = platform_node_js_1.Buffer.alloc(Long.SIZE);
|
|
71
|
+
if (signed) {
|
|
72
|
+
if (little) {
|
|
73
|
+
buffer.writeBigInt64LE(BigInt(value));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
buffer.writeBigInt64BE(BigInt(value));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (little) {
|
|
81
|
+
buffer.writeBigUInt64LE(BigInt(value));
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
buffer.writeBigUInt64BE(BigInt(value));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return buffer;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Long = Long;
|
|
91
|
+
class Int128 extends Long {
|
|
92
|
+
static SIZE = 16;
|
|
93
|
+
static async read(data, signed = true, little = true, size = Int128.SIZE) {
|
|
94
|
+
return (0, helpers_js_1.bufferToBigint)(data.read(size), little, signed);
|
|
95
|
+
}
|
|
96
|
+
static write(value, _signed = true, _little = true) {
|
|
97
|
+
const bytesArray = [];
|
|
98
|
+
for (let i = 0; i < Int128.SIZE; i++) {
|
|
99
|
+
let shift = value >> BigInt(Long.SIZE * i);
|
|
100
|
+
shift &= BigInt(255);
|
|
101
|
+
bytesArray[i] = Number(String(shift));
|
|
102
|
+
}
|
|
103
|
+
return platform_node_js_1.Buffer.from(bytesArray);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.Int128 = Int128;
|
|
107
|
+
class Int256 extends Long {
|
|
108
|
+
static SIZE = 32;
|
|
109
|
+
static async read(data, signed = true, little = true, size = Int256.SIZE) {
|
|
110
|
+
return Int128.read(data, signed, little, size);
|
|
111
|
+
}
|
|
112
|
+
static write(value, _signed = true, _little = true) {
|
|
113
|
+
const bytesArray = [];
|
|
114
|
+
for (let i = 0; i < Int256.SIZE; i++) {
|
|
115
|
+
let shift = value >> BigInt(Long.SIZE * i);
|
|
116
|
+
shift &= BigInt(255);
|
|
117
|
+
bytesArray[i] = Number(String(shift));
|
|
118
|
+
}
|
|
119
|
+
return platform_node_js_1.Buffer.from(bytesArray);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.Int256 = Int256;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class String extends TLObject {
|
|
5
|
+
static write(value: string): Buffer;
|
|
6
|
+
static read(data: BytesIO, ..._args: Array<any>): Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.String = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const Bytes_js_1 = require("./Bytes.js");
|
|
6
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
7
|
+
class String extends TLObject_js_1.TLObject {
|
|
8
|
+
static write(value) {
|
|
9
|
+
return Bytes_js_1.Bytes.write(platform_node_js_1.Buffer.from(value, 'utf8'));
|
|
10
|
+
}
|
|
11
|
+
static async read(data, ..._args) {
|
|
12
|
+
return (await Bytes_js_1.Bytes.read(data)).toString('utf8');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.String = String;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TLObject } from '../TLObject.js';
|
|
2
|
+
import { BytesIO } from '../BytesIO.js';
|
|
3
|
+
import { Buffer } from '../../../platform.node.js';
|
|
4
|
+
export declare class Vector extends TLObject {
|
|
5
|
+
static ID: number;
|
|
6
|
+
static write(value: Array<any>, tl?: any): Buffer;
|
|
7
|
+
static readBare(data: BytesIO, size: number): Promise<any>;
|
|
8
|
+
static read(data: BytesIO, tl?: any): Promise<Array<any>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vector = void 0;
|
|
4
|
+
const TLObject_js_1 = require("../TLObject.js");
|
|
5
|
+
const BytesIO_js_1 = require("../BytesIO.js");
|
|
6
|
+
const Int_js_1 = require("./Int.js");
|
|
7
|
+
const platform_node_js_1 = require("../../../platform.node.js");
|
|
8
|
+
class Vector extends TLObject_js_1.TLObject {
|
|
9
|
+
static ID = 0x1cb5c415;
|
|
10
|
+
static write(value, tl) {
|
|
11
|
+
const bytes = new BytesIO_js_1.BytesIO();
|
|
12
|
+
bytes.write(Int_js_1.Int.write(Vector.ID, false));
|
|
13
|
+
bytes.write(Int_js_1.Int.write(value.length));
|
|
14
|
+
for (const i of value) {
|
|
15
|
+
if (tl) {
|
|
16
|
+
bytes.write(tl.write(i));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
bytes.write(i.write());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return platform_node_js_1.Buffer.from(bytes.buffer);
|
|
23
|
+
}
|
|
24
|
+
static async readBare(data, size) {
|
|
25
|
+
if (size === 4) {
|
|
26
|
+
return await Int_js_1.Int.read(data);
|
|
27
|
+
}
|
|
28
|
+
if (size === 8) {
|
|
29
|
+
return await Int_js_1.Long.read(data);
|
|
30
|
+
}
|
|
31
|
+
return await TLObject_js_1.TLObject.read(data);
|
|
32
|
+
}
|
|
33
|
+
static async read(data, tl) {
|
|
34
|
+
const results = [];
|
|
35
|
+
const count = await Int_js_1.Int.read(data);
|
|
36
|
+
const left = platform_node_js_1.Buffer.byteLength(data.read());
|
|
37
|
+
const size = count ? left / count : 0;
|
|
38
|
+
data.seek(-left, 1);
|
|
39
|
+
for (let i = 0; i < count; i++) {
|
|
40
|
+
if (tl) {
|
|
41
|
+
results.push(await tl.read(data));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
results.push(await Vector.readBare(data, size));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return results;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Vector = Vector;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Int, Long, Int128, Int256 } from './Int.js';
|
|
2
|
+
export { Bytes } from './Bytes.js';
|
|
3
|
+
export { String } from './String.js';
|
|
4
|
+
export { Bool, BoolTrue, BoolFalse } from './Bool.js';
|
|
5
|
+
export { Vector } from './Vector.js';
|
|
6
|
+
export { Double } from './Double.js';
|
|
7
|
+
export { Float } from './Float.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Float = exports.Double = exports.Vector = exports.BoolFalse = exports.BoolTrue = exports.Bool = exports.String = exports.Bytes = exports.Int256 = exports.Int128 = exports.Long = exports.Int = void 0;
|
|
4
|
+
var Int_js_1 = require("./Int.js");
|
|
5
|
+
Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return Int_js_1.Int; } });
|
|
6
|
+
Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return Int_js_1.Long; } });
|
|
7
|
+
Object.defineProperty(exports, "Int128", { enumerable: true, get: function () { return Int_js_1.Int128; } });
|
|
8
|
+
Object.defineProperty(exports, "Int256", { enumerable: true, get: function () { return Int_js_1.Int256; } });
|
|
9
|
+
var Bytes_js_1 = require("./Bytes.js");
|
|
10
|
+
Object.defineProperty(exports, "Bytes", { enumerable: true, get: function () { return Bytes_js_1.Bytes; } });
|
|
11
|
+
var String_js_1 = require("./String.js");
|
|
12
|
+
Object.defineProperty(exports, "String", { enumerable: true, get: function () { return String_js_1.String; } });
|
|
13
|
+
var Bool_js_1 = require("./Bool.js");
|
|
14
|
+
Object.defineProperty(exports, "Bool", { enumerable: true, get: function () { return Bool_js_1.Bool; } });
|
|
15
|
+
Object.defineProperty(exports, "BoolTrue", { enumerable: true, get: function () { return Bool_js_1.BoolTrue; } });
|
|
16
|
+
Object.defineProperty(exports, "BoolFalse", { enumerable: true, get: function () { return Bool_js_1.BoolFalse; } });
|
|
17
|
+
var Vector_js_1 = require("./Vector.js");
|
|
18
|
+
Object.defineProperty(exports, "Vector", { enumerable: true, get: function () { return Vector_js_1.Vector; } });
|
|
19
|
+
var Double_js_1 = require("./Double.js");
|
|
20
|
+
Object.defineProperty(exports, "Double", { enumerable: true, get: function () { return Double_js_1.Double; } });
|
|
21
|
+
var Float_js_1 = require("./Float.js");
|
|
22
|
+
Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return Float_js_1.Float; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretChatMessageService = exports.SecretChatMessage = exports.UpdateSecretChatMessage = exports.MsgContainer = exports.Message = exports.GzipPacked = exports.TLObject = exports.Primitive = exports.BytesIO = exports.AllTLObject = exports.Raw = void 0;
|
|
4
|
+
var Raw_js_1 = require("./Raw.js");
|
|
5
|
+
Object.defineProperty(exports, "Raw", { enumerable: true, get: function () { return Raw_js_1.Raw; } });
|
|
6
|
+
var All_js_1 = require("./All.js");
|
|
7
|
+
Object.defineProperty(exports, "AllTLObject", { enumerable: true, get: function () { return All_js_1.AllTLObject; } });
|
|
8
|
+
var index_js_1 = require("./core/index.js");
|
|
9
|
+
Object.defineProperty(exports, "BytesIO", { enumerable: true, get: function () { return index_js_1.BytesIO; } });
|
|
10
|
+
Object.defineProperty(exports, "Primitive", { enumerable: true, get: function () { return index_js_1.Primitive; } });
|
|
11
|
+
Object.defineProperty(exports, "TLObject", { enumerable: true, get: function () { return index_js_1.TLObject; } });
|
|
12
|
+
Object.defineProperty(exports, "GzipPacked", { enumerable: true, get: function () { return index_js_1.GzipPacked; } });
|
|
13
|
+
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return index_js_1.Message; } });
|
|
14
|
+
Object.defineProperty(exports, "MsgContainer", { enumerable: true, get: function () { return index_js_1.MsgContainer; } });
|
|
15
|
+
Object.defineProperty(exports, "UpdateSecretChatMessage", { enumerable: true, get: function () { return index_js_1.UpdateSecretChatMessage; } });
|
|
16
|
+
Object.defineProperty(exports, "SecretChatMessage", { enumerable: true, get: function () { return index_js_1.SecretChatMessage; } });
|
|
17
|
+
Object.defineProperty(exports, "SecretChatMessageService", { enumerable: true, get: function () { return index_js_1.SecretChatMessageService; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Connection } from '../connection/connection.js';
|
|
2
|
+
import { Buffer } from '../platform.node.js';
|
|
3
|
+
import { TLObject, BytesIO } from '../raw/index.js';
|
|
4
|
+
export declare class Auth {
|
|
5
|
+
MAX_RETRIES: number;
|
|
6
|
+
dcId: number;
|
|
7
|
+
testMode: boolean;
|
|
8
|
+
ipv6: boolean;
|
|
9
|
+
connection: Connection;
|
|
10
|
+
constructor(dcId: number, testMode: boolean, ipv6: boolean);
|
|
11
|
+
static pack(data: TLObject): Buffer;
|
|
12
|
+
static unpack(b: BytesIO): Promise<any>;
|
|
13
|
+
invoke(data: TLObject): Promise<any>;
|
|
14
|
+
create(): Promise<Buffer<ArrayBufferLike>>;
|
|
15
|
+
}
|