New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

telegram

Package Overview
Dependencies
Maintainers
0
Versions
331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telegram - npm Package Compare versions

Comparing version 2.26.8 to 2.26.9

0

client/2fa.d.ts

@@ -0,0 +0,0 @@ import type { TelegramClient } from "./TelegramClient";

8

client/2fa.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateTwoFaSettings = void 0;
exports.updateTwoFaSettings = updateTwoFaSettings;
const buffer_1 = require("buffer/");
const Helpers_1 = require("../Helpers");

@@ -54,3 +55,3 @@ const Password_1 = require("../Password");

if (!(pwd.newAlgo instanceof tl_1.Api.PasswordKdfAlgoUnknown)) {
pwd.newAlgo.salt1 = Buffer.concat([
pwd.newAlgo.salt1 = buffer_1.Buffer.concat([
pwd.newAlgo.salt1,

@@ -80,3 +81,3 @@ (0, Helpers_1.generateRandomBytes)(32),

? await (0, Password_1.computeDigest)(pwd.newAlgo, newPassword)
: Buffer.alloc(0),
: buffer_1.Buffer.alloc(0),
hint,

@@ -111,2 +112,1 @@ email,

}
exports.updateTwoFaSettings = updateTwoFaSettings;
"use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Api } from "../tl";

@@ -3,0 +3,0 @@ import type { TelegramClient } from "./TelegramClient";

@@ -26,3 +26,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports._authFlow = exports.signInBot = exports.signInWithPassword = exports.sendCode = exports.signInUserWithQrCode = exports.signInUser = exports.checkAuthorization = exports.start = void 0;
exports.start = start;
exports.checkAuthorization = checkAuthorization;
exports.signInUser = signInUser;
exports.signInUserWithQrCode = signInUserWithQrCode;
exports.sendCode = sendCode;
exports.signInWithPassword = signInWithPassword;
exports.signInBot = signInBot;
exports._authFlow = _authFlow;
const tl_1 = require("../tl");

@@ -48,3 +55,2 @@ const utils = __importStar(require("../Utils"));

}
exports.start = start;
/** @hidden */

@@ -60,3 +66,2 @@ async function checkAuthorization(client) {

}
exports.checkAuthorization = checkAuthorization;
/** @hidden */

@@ -182,3 +187,2 @@ async function signInUser(client, apiCredentials, authParams) {

}
exports.signInUser = signInUser;
/** @hidden */

@@ -265,3 +269,2 @@ async function signInUserWithQrCode(client, apiCredentials, authParams) {

}
exports.signInUserWithQrCode = signInUserWithQrCode;
/** @hidden */

@@ -306,3 +309,2 @@ async function sendCode(client, apiCredentials, phoneNumber, forceSMS = false) {

}
exports.sendCode = sendCode;
/** @hidden */

@@ -340,3 +342,2 @@ async function signInWithPassword(client, apiCredentials, authParams) {

}
exports.signInWithPassword = signInWithPassword;
/** @hidden */

@@ -366,3 +367,2 @@ async function signInBot(client, apiCredentials, authParams) {

}
exports.signInBot = signInBot;
/** @hidden */

@@ -375,2 +375,1 @@ async function _authFlow(client, apiCredentials, authParams) {

}
exports._authFlow = _authFlow;

@@ -0,0 +0,0 @@ import type { EntityLike } from "../define";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.inlineQuery = void 0;
exports.inlineQuery = inlineQuery;
const tl_1 = require("../tl");

@@ -24,2 +24,1 @@ const inlineResults_1 = require("../tl/custom/inlineResults");

}
exports.inlineQuery = inlineQuery;

@@ -0,0 +0,0 @@ import { Api } from "../tl";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildReplyMarkup = void 0;
exports.buildReplyMarkup = buildReplyMarkup;
const tl_1 = require("../tl");

@@ -87,2 +87,1 @@ const button_1 = require("../tl/custom/button");

}
exports.buildReplyMarkup = buildReplyMarkup;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import type { TelegramClient } from "./TelegramClient";

@@ -7,3 +6,2 @@ import type { EntityLike } from "../define";

import { Api } from "../tl";
import { inspect } from "../inspect";
interface ParticipantsIterInterface {

@@ -19,5 +17,2 @@ entity: EntityLike;

private requests?;
[inspect.custom](): {
[key: string]: any;
};
_init({ entity, filter, offset, search, showTotal, }: ParticipantsIterInterface): Promise<boolean | void>;

@@ -24,0 +19,0 @@ _loadNextChunk(): Promise<boolean | undefined>;

@@ -6,3 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.kickParticipant = exports.getParticipants = exports.iterParticipants = exports._ParticipantsIter = void 0;
exports._ParticipantsIter = void 0;
exports.iterParticipants = iterParticipants;
exports.getParticipants = getParticipants;
exports.kickParticipant = kickParticipant;
const Helpers_1 = require("../Helpers");

@@ -19,2 +22,5 @@ const requestIter_1 = require("../requestIter");

class _ChatAction {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, chat, action, params = {

@@ -33,5 +39,2 @@ delay: 4,

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
async start() {

@@ -74,8 +77,8 @@ this._request = new tl_1.Api.messages.SetTyping({

"record-audio": new tl_1.Api.SendMessageRecordAudioAction(),
"record-voice": new tl_1.Api.SendMessageRecordAudioAction(),
"record-voice": new tl_1.Api.SendMessageRecordAudioAction(), //alias
"record-round": new tl_1.Api.SendMessageRecordRoundAction(),
"record-video": new tl_1.Api.SendMessageRecordVideoAction(),
audio: new tl_1.Api.SendMessageUploadAudioAction({ progress: 1 }),
voice: new tl_1.Api.SendMessageUploadAudioAction({ progress: 1 }),
song: new tl_1.Api.SendMessageUploadAudioAction({ progress: 1 }),
voice: new tl_1.Api.SendMessageUploadAudioAction({ progress: 1 }), // alias
song: new tl_1.Api.SendMessageUploadAudioAction({ progress: 1 }), // alias
round: new tl_1.Api.SendMessageUploadRoundAction({ progress: 1 }),

@@ -85,3 +88,3 @@ video: new tl_1.Api.SendMessageUploadVideoAction({ progress: 1 }),

document: new tl_1.Api.SendMessageUploadDocumentAction({ progress: 1 }),
file: new tl_1.Api.SendMessageUploadDocumentAction({ progress: 1 }),
file: new tl_1.Api.SendMessageUploadDocumentAction({ progress: 1 }), // alias
cancel: new tl_1.Api.SendMessageCancelAction(),

@@ -304,3 +307,2 @@ };

}
exports.iterParticipants = iterParticipants;
/** @hidden */

@@ -311,3 +313,2 @@ async function getParticipants(client, entity, params) {

}
exports.getParticipants = getParticipants;
/** @hidden */

@@ -357,2 +358,1 @@ async function kickParticipant(client, entity, participant) {

}
exports.kickParticipant = kickParticipant;

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getDialogs = exports.iterDialogs = exports._DialogsIter = void 0;
exports._DialogsIter = void 0;
exports.iterDialogs = iterDialogs;
exports.getDialogs = getDialogs;
const tl_1 = require("../tl");

@@ -170,3 +172,2 @@ const requestIter_1 = require("../requestIter");

}
exports.iterDialogs = iterDialogs;
/** @hidden */

@@ -176,2 +177,1 @@ async function getDialogs(client, params) {

}
exports.getDialogs = getDialogs;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Api } from "../tl";

@@ -3,0 +3,0 @@ import type { TelegramClient } from "./TelegramClient";

@@ -36,3 +36,13 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.downloadProfilePhoto = exports._downloadPhoto = exports._downloadCachedPhotoSize = exports._downloadWebDocument = exports._downloadContact = exports._downloadDocument = exports.downloadMedia = exports.downloadFileV2 = exports.iterDownload = exports.GenericDownloadIter = exports.DirectDownloadIter = void 0;
exports.GenericDownloadIter = exports.DirectDownloadIter = void 0;
exports.iterDownload = iterDownload;
exports.downloadFileV2 = downloadFileV2;
exports.downloadMedia = downloadMedia;
exports._downloadDocument = _downloadDocument;
exports._downloadContact = _downloadContact;
exports._downloadWebDocument = _downloadWebDocument;
exports._downloadCachedPhotoSize = _downloadCachedPhotoSize;
exports._downloadPhoto = _downloadPhoto;
exports.downloadProfilePhoto = downloadProfilePhoto;
const buffer_1 = require("buffer/");
const tl_1 = require("../tl");

@@ -137,3 +147,3 @@ const Utils_1 = require("../Utils");

// 1. Fetch enough for one chunk
let data = Buffer.alloc(0);
let data = buffer_1.Buffer.alloc(0);
// 1.1. ``bad`` is how much into the data we have we need to offset

@@ -148,3 +158,3 @@ const bad = this.request.offset.mod(this.request.limit).toJSNumber();

this.request.offset = this.request.offset.add(this.request.limit);
data = Buffer.concat([data, current]);
data = buffer_1.Buffer.concat([data, current]);
done = current.length < this.request.limit;

@@ -233,6 +243,5 @@ }

}
exports.iterDownload = iterDownload;
function getWriter(outputFile) {
if (!outputFile || Buffer.isBuffer(outputFile)) {
return new extensions_1.BinaryWriter(Buffer.alloc(0));
if (!outputFile || buffer_1.Buffer.isBuffer(outputFile)) {
return new extensions_1.BinaryWriter(buffer_1.Buffer.alloc(0));
}

@@ -261,3 +270,3 @@ else if (typeof outputFile == "string") {

else {
return Buffer.from(writer.path);
return buffer_1.Buffer.from(writer.path);
}

@@ -268,3 +277,3 @@ }

async function downloadFileV2(client, inputLocation, { outputFile = undefined, partSizeKb = undefined, fileSize = undefined, progressCallback = undefined, dcId = undefined, msgData = undefined, }) {
var e_1, _a;
var _a, e_1, _b, _c;
if (!partSizeKb) {

@@ -286,3 +295,3 @@ if (!fileSize) {

try {
for (var _b = __asyncValues(iterDownload(client, {
for (var _d = true, _e = __asyncValues(iterDownload(client, {
file: inputLocation,

@@ -292,4 +301,6 @@ requestSize: partSize,

msgData: msgData,
})), _c; _c = await _b.next(), !_c.done;) {
const chunk = _c.value;
})), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const chunk = _c;
await writer.write(chunk);

@@ -305,3 +316,3 @@ downloaded = downloaded.add(chunk.length);

try {
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
}

@@ -316,3 +327,2 @@ finally { if (e_1) throw e_1.error; }

}
exports.downloadFileV2 = downloadFileV2;
class Foreman {

@@ -392,6 +402,5 @@ constructor(maxWorkers) {

else {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}
}
exports.downloadMedia = downloadMedia;
/** @hidden */

@@ -401,3 +410,3 @@ async function _downloadDocument(client, doc, outputFile, date, thumb, progressCallback, msgData) {

if (!doc.document) {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -407,3 +416,3 @@ doc = doc.document;

if (!(doc instanceof tl_1.Api.Document)) {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -434,3 +443,2 @@ let size;

}
exports._downloadDocument = _downloadDocument;
/** @hidden */

@@ -440,3 +448,2 @@ async function _downloadContact(client, media, args) {

}
exports._downloadContact = _downloadContact;
/** @hidden */

@@ -446,3 +453,2 @@ async function _downloadWebDocument(client, media, args) {

}
exports._downloadWebDocument = _downloadWebDocument;
function pickFileSize(sizes, sizeType) {

@@ -528,3 +534,2 @@ if (!sizeType || !sizes || !sizes.length) {

}
exports._downloadCachedPhotoSize = _downloadCachedPhotoSize;
/** @hidden */

@@ -545,3 +550,3 @@ function getProperFilename(file, fileType, extension, date) {

if (photo.photo instanceof tl_1.Api.PhotoEmpty || !photo.photo) {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -551,3 +556,3 @@ photo = photo.photo;

if (!(photo instanceof tl_1.Api.Photo)) {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -557,3 +562,3 @@ const photoSizes = [...(photo.sizes || []), ...(photo.videoSizes || [])];

if (!size || size instanceof tl_1.Api.PhotoSizeEmpty) {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -587,3 +592,2 @@ if (!date) {

}
exports._downloadPhoto = _downloadPhoto;
/** @hidden */

@@ -616,3 +620,3 @@ async function downloadProfilePhoto(client, entity, fileParams) {

else {
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -624,2 +628,1 @@ return client.downloadFile(loc, {

}
exports.downloadProfilePhoto = downloadProfilePhoto;

@@ -1,1 +0,10 @@

export * from "fs";
export declare const promises: {
lstat: (...args: any) => any;
stat: (...args: any) => any;
readFile: (...args: any) => any;
open: (...args: any) => any;
};
export declare const createWriteStream: any;
export declare const WriteStream: any;
export declare const lstatSync: any;
export declare const existsSync: any;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
Object.defineProperty(exports, "__esModule", { value: true });
exports.existsSync = exports.lstatSync = exports.WriteStream = exports.createWriteStream = exports.promises = void 0;
exports.promises = {
lstat: (...args) => { },
stat: (...args) => { },
readFile: (...args) => { },
open: (...args) => { },
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("fs"), exports);
exports.createWriteStream = {};
exports.WriteStream = {};
exports.lstatSync = {};
exports.existsSync = {};

@@ -0,0 +0,0 @@ import * as twoFA from "./2fa";

@@ -0,0 +0,0 @@ "use strict";

import { Api } from "../tl/api";
import type { EntityLike } from "../define";
import type { TelegramClient } from "./TelegramClient";
export declare type messageEntities = typeof Api.MessageEntityBold | typeof Api.MessageEntityItalic | typeof Api.MessageEntityStrike | typeof Api.MessageEntityCode | typeof Api.MessageEntityPre;
export type messageEntities = typeof Api.MessageEntityBold | typeof Api.MessageEntityItalic | typeof Api.MessageEntityStrike | typeof Api.MessageEntityCode | typeof Api.MessageEntityPre;
export declare const DEFAULT_DELIMITERS: {

@@ -6,0 +6,0 @@ [key: string]: messageEntities;

@@ -6,3 +6,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports._getResponseMessage = exports._parseMessageText = exports._replaceWithMention = exports.DEFAULT_DELIMITERS = void 0;
exports.DEFAULT_DELIMITERS = void 0;
exports._replaceWithMention = _replaceWithMention;
exports._parseMessageText = _parseMessageText;
exports._getResponseMessage = _getResponseMessage;
const Utils_1 = require("../Utils");

@@ -34,3 +37,2 @@ const api_1 = require("../tl/api");

}
exports._replaceWithMention = _replaceWithMention;
/** @hidden */

@@ -66,3 +68,2 @@ async function _parseMessageText(client, message, parseMode) {

}
exports._parseMessageText = _parseMessageText;
/** @hidden */

@@ -194,2 +195,1 @@ function _getResponseMessage(client, request, result, inputChat) {

}
exports._getResponseMessage = _getResponseMessage;

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -13,3 +13,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getCommentData = exports.markAsRead = exports._pin = exports.unpinMessage = exports.pinMessage = exports.deleteMessages = exports.editMessage = exports.forwardMessages = exports.sendMessage = exports.getMessages = exports.iterMessages = exports._IDsIter = exports._MessagesIter = void 0;
exports._IDsIter = exports._MessagesIter = void 0;
exports.iterMessages = iterMessages;
exports.getMessages = getMessages;
exports.sendMessage = sendMessage;
exports.forwardMessages = forwardMessages;
exports.editMessage = editMessage;
exports.deleteMessages = deleteMessages;
exports.pinMessage = pinMessage;
exports.unpinMessage = unpinMessage;
exports._pin = _pin;
exports.markAsRead = markAsRead;
exports.getCommentData = getCommentData;
const tl_1 = require("../tl");

@@ -27,3 +38,3 @@ const requestIter_1 = require("../requestIter");

async _init({ entity, offsetId, minId, maxId, fromUser, offsetDate, addOffset, filter, search, replyTo, }) {
var e_1, _a;
var _a, e_1, _b, _c;
if (entity) {

@@ -122,7 +133,9 @@ this.entity = await this.client.getInputEntity(entity);

try {
for (var _b = __asyncValues(this.client.iterMessages(this.entity, {
for (var _d = true, _e = __asyncValues(this.client.iterMessages(this.entity, {
limit: 1,
offsetDate: offsetDate,
})), _c; _c = await _b.next(), !_c.done;) {
const m = _c.value;
})), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const m = _c;
this.request.offsetId = m.id + 1;

@@ -134,3 +147,3 @@ }

try {
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
}

@@ -404,6 +417,5 @@ finally { if (e_1) throw e_1.error; }

}
exports.iterMessages = iterMessages;
/** @hidden */
async function getMessages(client, entity, params) {
var e_2, _a;
var _a, e_2, _b, _c;
if (Object.keys(params).length == 1 && params.limit === undefined) {

@@ -421,4 +433,6 @@ if (params.minId === undefined && params.maxId === undefined) {

try {
for (var it_1 = __asyncValues(it), it_1_1; it_1_1 = await it_1.next(), !it_1_1.done;) {
const message = it_1_1.value;
for (var _d = true, it_1 = __asyncValues(it), it_1_1; it_1_1 = await it_1.next(), _a = it_1_1.done, !_a; _d = true) {
_c = it_1_1.value;
_d = false;
const message = _c;
return [message];

@@ -430,3 +444,3 @@ }

try {
if (it_1_1 && !it_1_1.done && (_a = it_1.return)) await _a.call(it_1);
if (!_d && !_a && (_b = it_1.return)) await _b.call(it_1);
}

@@ -439,3 +453,2 @@ finally { if (e_2) throw e_2.error; }

}
exports.getMessages = getMessages;
// region Message

@@ -562,3 +575,2 @@ /** @hidden */

}
exports.sendMessage = sendMessage;
/** @hidden */

@@ -617,3 +629,2 @@ async function forwardMessages(client, entity, { messages, fromPeer, silent, schedule, noforwards, dropAuthor, }) {

}
exports.forwardMessages = forwardMessages;
/** @hidden */

@@ -679,3 +690,2 @@ async function editMessage(client, entity, { message, text, parseMode, formattingEntities, linkPreview = true, file, forceDocument, buttons, schedule, }) {

}
exports.editMessage = editMessage;
/** @hidden */

@@ -721,3 +731,2 @@ async function deleteMessages(client, entity, messageIds, { revoke = false }) {

}
exports.deleteMessages = deleteMessages;
/** @hidden */

@@ -727,3 +736,2 @@ async function pinMessage(client, entity, message, pinMessageParams) {

}
exports.pinMessage = pinMessage;
/** @hidden */

@@ -733,3 +741,2 @@ async function unpinMessage(client, entity, message, unpinMessageParams) {

}
exports.unpinMessage = unpinMessage;
/** @hidden */

@@ -766,3 +773,2 @@ async function _pin(client, entity, message, unpin, notify = false, pmOneSide = false) {

}
exports._pin = _pin;
/** @hidden */

@@ -797,3 +803,2 @@ async function markAsRead(client, entity, message, markAsReadParams) {

}
exports.markAsRead = markAsRead;
/** @hidden */

@@ -819,3 +824,2 @@ async function getCommentData(client, entity, message) {

}
exports.getCommentData = getCommentData;
// TODO do the rest

@@ -1,2 +0,5 @@

import * as os from "os";
export default os;
declare const _default: {
type: () => string;
release: () => string;
};
export default _default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
type: () => {
return "Browser";
},
release: () => {
return "1.0";
},
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(require("os"));
exports.default = os;

@@ -1,2 +0,7 @@

import path from "path";
export default path;
declare const _default: {
basename(...args: any): any;
resolve(...args: any): any;
path(...args: any): any;
join(...args: any): any;
};
export default _default;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
basename(...args) { },
resolve(...args) { },
path(...args) { },
join(...args) { },
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
exports.default = path_1.default;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { Connection } from "../";

@@ -3,0 +2,0 @@ import { Session } from "../sessions";

@@ -110,3 +110,3 @@ "use strict";

langCode: clientParams.langCode,
langPack: "",
langPack: "", // this should be left empty.
systemLangCode: clientParams.systemLangCode,

@@ -113,0 +113,0 @@ proxy: initProxy,

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { TelegramBaseClient, TelegramClientParams } from "./telegramBaseClient";

@@ -22,3 +22,2 @@ import * as authMethods from "./auth";

import { DeletedMessage, DeletedMessageEvent } from "../events/DeletedMessage";
import { inspect } from "../inspect";
/**

@@ -758,3 +757,5 @@ * The TelegramClient uses several methods in different files to provide all the common functionality in a nice interface.</br>

/** TODO */
on(event: any): (f: (event: any) => void) => (event: any) => void;
on(event: any): (f: {
(event: any): void;
}) => (event: any) => void;
/**

@@ -1036,6 +1037,2 @@ * Registers a new event handler callback.<br/>

_getResponseMessage(req: any, result: any, inputChat: any): Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined;
/** @hidden */
[inspect.custom](): {
[key: string]: any;
};
/**

@@ -1042,0 +1039,0 @@ * Small hack for using it in browsers

@@ -0,0 +0,0 @@ "use strict";

@@ -13,3 +13,5 @@ import type { EventBuilder } from "../events/common";

/** @hidden */
export declare function on(client: TelegramClient, event?: EventBuilder): (f: (event: any) => void) => (event: any) => void;
export declare function on(client: TelegramClient, event?: EventBuilder): (f: {
(event: any): void;
}) => (event: any) => void;
/** @hidden */

@@ -16,0 +18,0 @@ export declare function addEventHandler(client: TelegramClient, callback: CallableFunction, event?: EventBuilder): void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._updateLoop = exports._dispatchUpdate = exports._processUpdate = exports._handleUpdate = exports.catchUp = exports.listEventHandlers = exports.removeEventHandler = exports.addEventHandler = exports.on = exports.StopPropagation = void 0;
exports.StopPropagation = void 0;
exports.on = on;
exports.addEventHandler = addEventHandler;
exports.removeEventHandler = removeEventHandler;
exports.listEventHandlers = listEventHandlers;
exports.catchUp = catchUp;
exports._handleUpdate = _handleUpdate;
exports._processUpdate = _processUpdate;
exports._dispatchUpdate = _dispatchUpdate;
exports._updateLoop = _updateLoop;
const tl_1 = require("../tl");

@@ -35,3 +44,2 @@ const network_1 = require("../network");

}
exports.on = on;
/** @hidden */

@@ -47,3 +55,2 @@ function addEventHandler(client, callback, event) {

}
exports.addEventHandler = addEventHandler;
/** @hidden */

@@ -55,3 +62,2 @@ function removeEventHandler(client, callback, event) {

}
exports.removeEventHandler = removeEventHandler;
/** @hidden */

@@ -61,3 +67,2 @@ function listEventHandlers(client) {

}
exports.listEventHandlers = listEventHandlers;
/** @hidden */

@@ -67,3 +72,2 @@ function catchUp() {

}
exports.catchUp = catchUp;
/** @hidden */

@@ -100,3 +104,2 @@ function _handleUpdate(client, update) {

}
exports._handleUpdate = _handleUpdate;
/** @hidden */

@@ -111,3 +114,2 @@ function _processUpdate(client, update, others, entities) {

}
exports._processUpdate = _processUpdate;
/** @hidden */

@@ -168,3 +170,2 @@ async function _dispatchUpdate(client, args) {

}
exports._dispatchUpdate = _dispatchUpdate;
/** @hidden */

@@ -236,3 +237,2 @@ async function _updateLoop(client) {

}
exports._updateLoop = _updateLoop;
/** @hidden */

@@ -239,0 +239,0 @@ async function attempts(cb, times, pause) {

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Api } from "../tl";

@@ -3,0 +3,0 @@ import { TelegramClient } from "./TelegramClient";

@@ -6,3 +6,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.sendFile = exports._sendAlbum = exports._fileToMedia = exports.uploadFile = exports.CustomFile = void 0;
exports.CustomFile = void 0;
exports.uploadFile = uploadFile;
exports._fileToMedia = _fileToMedia;
exports._sendAlbum = _sendAlbum;
exports.sendFile = sendFile;
const buffer_1 = require("buffer/");
const tl_1 = require("../tl");

@@ -44,9 +49,9 @@ const Helpers_1 = require("../Helpers");

const buffSize = end - begin;
const buff = Buffer.alloc(buffSize);
const buff = buffer_1.Buffer.alloc(buffSize);
const fHandle = await fs_1.promises.open(filePath, "r");
await fHandle.read(buff, 0, buffSize, begin);
await fHandle.close();
return Buffer.from(buff);
return buffer_1.Buffer.from(buff);
}
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -66,3 +71,3 @@ }

else {
options.buffer = Buffer.from(await fileToBuffer(file));
options.buffer = buffer_1.Buffer.from(await fileToBuffer(file));
}

@@ -165,3 +170,2 @@ return new CustomBuffer(options);

}
exports.uploadFile = uploadFile;
/** @hidden */

@@ -177,3 +181,3 @@ async function _fileToMedia(client, { file, forceDocument, fileSize, progressCallback, attributes, thumb, voiceNote = false, videoNote = false, supportsStreaming = false, mimeType, asImage, workers = 1, }) {

if (typeof file == "object" &&
!Buffer.isBuffer(file) &&
!buffer_1.Buffer.isBuffer(file) &&
!(file instanceof tl_1.Api.InputFile) &&

@@ -237,3 +241,3 @@ !(file instanceof tl_1.Api.InputFileBig) &&

}
if (Buffer.isBuffer(file)) {
if (buffer_1.Buffer.isBuffer(file)) {
createdFile = new CustomFile(name, file.length, "", file);

@@ -297,3 +301,3 @@ }

}
if (Buffer.isBuffer(thumb)) {
if (buffer_1.Buffer.isBuffer(thumb)) {
uploadedThumb = new CustomFile(name, thumb.length, "", thumb);

@@ -324,3 +328,2 @@ }

}
exports._fileToMedia = _fileToMedia;
/** @hidden */

@@ -423,3 +426,2 @@ async function _sendAlbum(client, entity, { file, caption, forceDocument = false, fileSize, clearDraft = false, progressCallback, replyTo, attributes, thumb, parseMode, voiceNote = false, videoNote = false, silent, supportsStreaming = false, scheduleDate, workers = 1, noforwards, commentTo, topMsgId, }) {

}
exports._sendAlbum = _sendAlbum;
/** @hidden */

@@ -507,3 +509,2 @@ async function sendFile(client, entity, { file, caption, forceDocument = false, fileSize, clearDraft = false, progressCallback, replyTo, attributes, thumb, parseMode, formattingEntities, voiceNote = false, videoNote = false, buttons, silent, supportsStreaming = false, scheduleDate, workers = 1, noforwards, commentTo, topMsgId, }) {

}
exports.sendFile = sendFile;
function fileToBuffer(file) {

@@ -510,0 +511,0 @@ if (typeof File !== "undefined" && file instanceof File) {

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -6,3 +6,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports._selfId = exports._getInputNotify = exports._getInputDialog = exports._getPeer = exports.getPeerId = exports._getEntityFromString = exports.getInputEntity = exports.getEntity = exports.isUserAuthorized = exports.isBot = exports.getMe = exports.invoke = void 0;
exports.invoke = invoke;
exports.getMe = getMe;
exports.isBot = isBot;
exports.isUserAuthorized = isUserAuthorized;
exports.getEntity = getEntity;
exports.getInputEntity = getInputEntity;
exports._getEntityFromString = _getEntityFromString;
exports.getPeerId = getPeerId;
exports._getPeer = _getPeer;
exports._getInputDialog = _getInputDialog;
exports._getInputNotify = _getInputNotify;
exports._selfId = _selfId;
const tl_1 = require("../tl");

@@ -102,3 +113,2 @@ const Utils_1 = require("../Utils");

}
exports.invoke = invoke;
/** @hidden */

@@ -118,3 +128,2 @@ async function getMe(client, inputPeer) {

}
exports.getMe = getMe;
/** @hidden */

@@ -130,3 +139,2 @@ async function isBot(client) {

}
exports.isBot = isBot;
/** @hidden */

@@ -142,3 +150,2 @@ async function isUserAuthorized(client) {

}
exports.isUserAuthorized = isUserAuthorized;
/** @hidden */

@@ -224,3 +231,2 @@ async function getEntity(client, entity) {

}
exports.getEntity = getEntity;
/** @hidden */

@@ -342,3 +348,2 @@ async function getInputEntity(client, peer) {

}
exports.getInputEntity = getInputEntity;
/** @hidden */

@@ -418,3 +423,2 @@ async function _getEntityFromString(client, string) {

}
exports._getEntityFromString = _getEntityFromString;
/** @hidden */

@@ -444,3 +448,2 @@ async function getPeerId(client, peer, addMark = true) {

}
exports.getPeerId = getPeerId;
/** @hidden */

@@ -458,3 +461,2 @@ async function _getPeer(client, peer) {

}
exports._getPeer = _getPeer;
/** @hidden */

@@ -480,3 +482,2 @@ async function _getInputDialog(client, dialog) {

}
exports._getInputDialog = _getInputDialog;
/** @hidden */

@@ -497,3 +498,2 @@ async function _getInputNotify(client, notify) {

}
exports._getInputNotify = _getInputNotify;
/** @hidden */

@@ -503,2 +503,1 @@ function _selfId(client) {

}
exports._selfId = _selfId;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import bigInt from "big-integer";

@@ -3,0 +3,0 @@ export declare class AuthKey {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthKey = void 0;
const buffer_1 = require("buffer/");
const Helpers_1 = require("../Helpers");

@@ -56,7 +57,7 @@ const extensions_1 = require("../extensions");

const nonce = (0, Helpers_1.toSignedLittleBuffer)(newNonce, 32);
const n = Buffer.alloc(1);
const n = buffer_1.Buffer.alloc(1);
n.writeUInt8(number, 0);
const data = Buffer.concat([
const data = buffer_1.Buffer.concat([
nonce,
Buffer.concat([n, (0, Helpers_1.readBufferFromBigInt)(this.auxHash, 8, true)]),
buffer_1.Buffer.concat([n, (0, Helpers_1.readBufferFromBigInt)(this.auxHash, 8, true)]),
]);

@@ -73,3 +74,3 @@ // Calculates the message key from the given data

this._key &&
Buffer.isBuffer(other.getKey()) &&
buffer_1.Buffer.isBuffer(other.getKey()) &&
((_a = other.getKey()) === null || _a === void 0 ? void 0 : _a.equals(this._key)));

@@ -76,0 +77,0 @@ }

@@ -0,0 +0,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ab2i = exports.i2ab = exports.isBigEndian = exports.ab2iBig = exports.ab2iLow = exports.i2abBig = exports.i2abLow = void 0;
exports.ab2i = exports.i2ab = exports.isBigEndian = void 0;
exports.i2abLow = i2abLow;
exports.i2abBig = i2abBig;
exports.ab2iLow = ab2iLow;
exports.ab2iBig = ab2iBig;
/**

@@ -19,3 +23,2 @@ * Uint32Array -> ArrayBuffer (low-endian os)

}
exports.i2abLow = i2abLow;
/**

@@ -27,3 +30,2 @@ * Uint32Array -> ArrayBuffer (big-endian os)

}
exports.i2abBig = i2abBig;
/**

@@ -44,3 +46,2 @@ * ArrayBuffer -> Uint32Array (low-endian os)

}
exports.ab2iLow = ab2iLow;
/**

@@ -52,5 +53,4 @@ * ArrayBuffer -> Uint32Array (big-endian os)

}
exports.ab2iBig = ab2iBig;
exports.isBigEndian = new Uint8Array(new Uint32Array([0x01020304]))[0] === 0x01;
exports.i2ab = exports.isBigEndian ? i2abBig : i2abLow;
exports.ab2i = exports.isBigEndian ? ab2iBig : ab2iLow;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
export declare class Counter {

@@ -3,0 +3,0 @@ _counter: Buffer;

@@ -6,3 +6,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createHash = exports.pbkdf2Sync = exports.Hash = exports.randomBytes = exports.createCipheriv = exports.createDecipheriv = exports.CTR = exports.Counter = void 0;
exports.Hash = exports.CTR = exports.Counter = void 0;
exports.createDecipheriv = createDecipheriv;
exports.createCipheriv = createCipheriv;
exports.randomBytes = randomBytes;
exports.pbkdf2Sync = pbkdf2Sync;
exports.createHash = createHash;
const buffer_1 = require("buffer/");
const aes_1 = __importDefault(require("@cryptography/aes"));

@@ -13,3 +19,3 @@ const converters_1 = require("./converters");

constructor(initialValue) {
this._counter = Buffer.from(initialValue);
this._counter = buffer_1.Buffer.from(initialValue);
}

@@ -43,6 +49,6 @@ increment() {

encrypt(plainText) {
const encrypted = Buffer.from(plainText);
const encrypted = buffer_1.Buffer.from(plainText);
for (let i = 0; i < encrypted.length; i++) {
if (this._remainingCounterIndex === 16) {
this._remainingCounter = Buffer.from((0, converters_1.i2ab)(this._aes.encrypt((0, converters_1.ab2i)(this._counter._counter))));
this._remainingCounter = buffer_1.Buffer.from((0, converters_1.i2ab)(this._aes.encrypt((0, converters_1.ab2i)(this._counter._counter))));
this._remainingCounterIndex = 0;

@@ -69,3 +75,2 @@ this._counter.increment();

}
exports.createDecipheriv = createDecipheriv;
function createCipheriv(algorithm, key, iv) {

@@ -79,3 +84,2 @@ if (algorithm.includes("ECB")) {

}
exports.createCipheriv = createCipheriv;
function randomBytes(count) {

@@ -86,3 +90,2 @@ const bytes = new Uint8Array(count);

}
exports.randomBytes = randomBytes;
class Hash {

@@ -100,9 +103,9 @@ constructor(algorithm) {

if (this.algorithm === "sha1") {
return Buffer.from(await self.crypto.subtle.digest("SHA-1", this.data));
return buffer_1.Buffer.from(await self.crypto.subtle.digest("SHA-1", this.data));
}
else if (this.algorithm === "sha256") {
return Buffer.from(await self.crypto.subtle.digest("SHA-256", this.data));
return buffer_1.Buffer.from(await self.crypto.subtle.digest("SHA-256", this.data));
}
}
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -113,3 +116,3 @@ }

const passwordKey = await crypto.subtle.importKey("raw", password, { name: "PBKDF2" }, false, ["deriveBits"]);
return Buffer.from(await crypto.subtle.deriveBits({
return buffer_1.Buffer.from(await crypto.subtle.deriveBits({
name: "PBKDF2",

@@ -121,6 +124,4 @@ hash: "SHA-512",

}
exports.pbkdf2Sync = pbkdf2Sync;
function createHash(algorithm) {
return new Hash(algorithm);
}
exports.createHash = createHash;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
export declare class CTR {

@@ -3,0 +3,0 @@ private cipher;

@@ -27,6 +27,7 @@ "use strict";

exports.CTR = void 0;
const buffer_1 = require("buffer/");
const crypto = __importStar(require("./crypto"));
class CTR {
constructor(key, iv) {
if (!Buffer.isBuffer(key) || !Buffer.isBuffer(iv) || iv.length !== 16) {
if (!buffer_1.Buffer.isBuffer(key) || !buffer_1.Buffer.isBuffer(iv) || iv.length !== 16) {
throw new Error("Key and iv need to be a buffer");

@@ -37,5 +38,5 @@ }

encrypt(data) {
return Buffer.from(this.cipher.update(data));
return buffer_1.Buffer.from(this.cipher.update(data));
}
}
exports.CTR = CTR;

@@ -0,0 +0,0 @@ import bigInt from "big-integer";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
declare class IGENEW {

@@ -3,0 +3,0 @@ private ige;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IGE = void 0;
const buffer_1 = require("buffer/");
const Helpers = require("../Helpers");

@@ -26,3 +27,3 @@ const { IGE: aes_ige } = require("@cryptography/aes");

if (padding) {
plainText = Buffer.concat([
plainText = buffer_1.Buffer.concat([
plainText,

@@ -29,0 +30,0 @@ Helpers.generateRandomBytes(16 - padding),

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import bigInt from "big-integer";

@@ -3,0 +3,0 @@ export declare const _serverKeys: Map<string, {

@@ -17,3 +17,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.encrypt = exports._serverKeys = void 0;
exports._serverKeys = void 0;
exports.encrypt = encrypt;
const buffer_1 = require("buffer/");
const big_integer_1 = __importDefault(require("big-integer"));

@@ -63,3 +65,3 @@ const Helpers_1 = require("../Helpers");

const rand = (0, Helpers_1.generateRandomBytes)(235 - data.length);
const toEncrypt = Buffer.concat([await (0, Helpers_1.sha1)(data), data, rand]);
const toEncrypt = buffer_1.Buffer.concat([await (0, Helpers_1.sha1)(data), data, rand]);
// rsa module rsa.encrypt adds 11 bits for padding which we don't want

@@ -72,2 +74,1 @@ // rsa module uses rsa.transform.bytes2int(to_encrypt), easier way:

}
exports.encrypt = encrypt;

@@ -0,0 +0,0 @@ export declare function s2i(str: string, pos: number): number;

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.xor = exports.getWords = exports.s2i = void 0;
exports.s2i = s2i;
exports.getWords = getWords;
exports.xor = xor;
function s2i(str, pos) {

@@ -14,3 +16,2 @@ return ((str.charCodeAt(pos) << 24) ^

}
exports.s2i = s2i;
/**

@@ -45,3 +46,2 @@ * Helper function for transforming string key to Uint32Array

}
exports.getWords = getWords;
function xor(left, right, to = left) {

@@ -51,2 +51,1 @@ for (let i = 0; i < left.length; i++)

}
exports.xor = xor;

@@ -1,2 +0,2 @@

import * as crypto from "crypto";
import * as crypto from "./crypto/crypto";
export default crypto;

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const crypto = __importStar(require("crypto"));
const crypto = __importStar(require("./crypto/crypto"));
exports.default = crypto;

@@ -0,0 +0,0 @@ import bigInt from "big-integer";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,5 +1,5 @@

import { Buffer } from "buffer/";
/**
* Errors not related to the Telegram API itself
*/
/// <reference types="node" />
import { Api } from "../tl";

@@ -6,0 +6,0 @@ /**

"use strict";
/**
* Errors not related to the Telegram API itself
*/
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,0 +3,0 @@ exports.BadMessageError = exports.CdnFileTamperedError = exports.SecurityError = exports.InvalidBufferError = exports.InvalidChecksumError = exports.TypeNotFoundError = exports.ReadCancelledError = void 0;

@@ -0,0 +0,0 @@ /**

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RPCMessageToError = void 0;
exports.RPCMessageToError = RPCMessageToError;
const RPCBaseErrors_1 = require("./RPCBaseErrors");

@@ -31,5 +31,4 @@ const RPCErrorList_1 = require("./RPCErrorList");

}
exports.RPCMessageToError = RPCMessageToError;
__exportStar(require("./Common"), exports);
__exportStar(require("./RPCBaseErrors"), exports);
__exportStar(require("./RPCErrorList"), exports);

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { InvalidDCError, FloodError, BadRequestError } from "./RPCBaseErrors";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { DefaultEventInterface, EventBuilder, EventCommon } from "./common";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { EntityLike } from "../define";

@@ -3,0 +3,0 @@ import { EventBuilder, EventCommonSender } from "./common";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.EventCommonSender = exports.EventCommon = exports.EventBuilder = exports._intoIdSet = void 0;
exports.EventCommonSender = exports.EventCommon = exports.EventBuilder = void 0;
exports._intoIdSet = _intoIdSet;
const tl_1 = require("../tl");

@@ -59,3 +60,2 @@ const custom_1 = require("../tl/custom");

}
exports._intoIdSet = _intoIdSet;
/**

@@ -62,0 +62,0 @@ * The common event builder, with builtin support to filter per chat.<br/>

@@ -0,0 +0,0 @@ import { EntityLike } from "../define";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -0,0 +0,0 @@ "use strict";

export { Raw } from "./Raw";
export { NewMessage, NewMessageEvent } from "./NewMessage";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { DefaultEventInterface, EventBuilder, EventCommon } from "./common";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { EventBuilder, EventCommon } from "./common";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare class AsyncQueue {

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
export declare class BinaryReader {

@@ -3,0 +3,0 @@ private readonly stream;

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
export declare class BinaryWriter {

@@ -3,0 +3,0 @@ private readonly _buffers;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BinaryWriter = void 0;
const buffer_1 = require("buffer/");
class BinaryWriter {

@@ -12,5 +13,5 @@ constructor(stream) {

getValue() {
return Buffer.concat(this._buffers);
return buffer_1.Buffer.concat(this._buffers);
}
}
exports.BinaryWriter = BinaryWriter;

@@ -0,0 +0,0 @@ export default class Deferred<T = void> {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export { Logger } from "./Logger";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare enum LogLevel {

@@ -13,3 +13,3 @@ "use strict";

LogLevel["DEBUG"] = "debug";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
})(LogLevel || (exports.LogLevel = LogLevel = {}));
class Logger {

@@ -16,0 +16,0 @@ constructor(level) {

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import type { MTProtoState } from "../network/MTProtoState";

@@ -3,0 +3,0 @@ import type { RequestState } from "../network/RequestState";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessagePacker = void 0;
const buffer_1 = require("buffer/");
const core_1 = require("../tl/core");

@@ -104,3 +105,3 @@ const core_2 = require("../tl/core");

let data;
let buffer = new BinaryWriter_1.BinaryWriter(Buffer.alloc(0));
let buffer = new BinaryWriter_1.BinaryWriter(buffer_1.Buffer.alloc(0));
const batch = [];

@@ -141,7 +142,7 @@ let size = 0;

if (batch.length > 1) {
const b = Buffer.alloc(8);
const b = buffer_1.Buffer.alloc(8);
b.writeUInt32LE(core_1.MessageContainer.CONSTRUCTOR_ID, 0);
b.writeInt32LE(batch.length, 4);
data = Buffer.concat([b, buffer.getValue()]);
buffer = new BinaryWriter_1.BinaryWriter(Buffer.alloc(0));
data = buffer_1.Buffer.concat([b, buffer.getValue()]);
buffer = new BinaryWriter_1.BinaryWriter(buffer_1.Buffer.alloc(0));
const containerId = await this._state.writeDataAsMessage(buffer, data, false);

@@ -148,0 +149,0 @@ for (const s of batch) {

@@ -1,1 +0,8 @@

export * from "net";
export declare class Socket {
destroyed?: boolean;
connect(...args: any): any;
on(...args: any): any;
write(...args: any): any;
destroy(...args: any): any;
unref(...args: any): any;
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("net"), exports);
exports.Socket = void 0;
class Socket {
connect(...args) { }
on(...args) { }
write(...args) { }
destroy(...args) { }
unref(...args) { }
}
exports.Socket = Socket;

@@ -0,0 +0,0 @@ import { RequestState } from "../network/RequestState";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,25 +0,8 @@

/// <reference types="node" />
import { ProxyInterface } from "../network/connection/TCPMTProxy";
export declare class PromisedNetSockets {
private client?;
private closed;
private stream;
private canRead?;
private resolveRead;
private proxy?;
constructor(proxy?: ProxyInterface);
readExactly(number: number): Promise<Buffer>;
read(number: number): Promise<Buffer>;
readAll(): Promise<Buffer>;
/**
* Creates a new connection
* @param port
* @param ip
* @returns {Promise<void>}
*/
connect(port: number, ip: string): Promise<unknown>;
write(data: Buffer): void;
close(): Promise<void>;
receive(): Promise<void>;
toString(): string;
constructor(...args: any);
connect(...args: any): any;
close(...args: any): any;
write(...args: any): any;
readExactly(...args: any): any;
read(...args: any): any;
}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PromisedNetSockets = void 0;
const net = __importStar(require("./net"));
const socks_1 = require("./socks");
const async_mutex_1 = require("async-mutex");
const mutex = new async_mutex_1.Mutex();
const closeError = new Error("NetSocket was closed");
class PromisedNetSockets {
constructor(proxy) {
this.client = undefined;
this.closed = true;
this.stream = Buffer.alloc(0);
if (proxy) {
// we only want to use this when it's not an MTProto proxy.
if (!("MTProxy" in proxy)) {
if (!proxy.ip || !proxy.port || !proxy.socksType) {
throw new Error(`Invalid sockets params: ip=${proxy.ip}, port=${proxy.port}, socksType=${proxy.socksType}`);
}
this.proxy = proxy;
}
}
}
async readExactly(number) {
let readData = Buffer.alloc(0);
while (true) {
const thisTime = await this.read(number);
readData = Buffer.concat([readData, thisTime]);
number = number - thisTime.length;
if (!number || number === -437) {
return readData;
}
}
}
async read(number) {
if (this.closed) {
throw closeError;
}
await this.canRead;
if (this.closed) {
throw closeError;
}
const toReturn = this.stream.slice(0, number);
this.stream = this.stream.slice(number);
if (this.stream.length === 0) {
this.canRead = new Promise((resolve) => {
this.resolveRead = resolve;
});
}
return toReturn;
}
async readAll() {
if (this.closed || !(await this.canRead)) {
throw closeError;
}
const toReturn = this.stream;
this.stream = Buffer.alloc(0);
this.canRead = new Promise((resolve) => {
this.resolveRead = resolve;
});
return toReturn;
}
/**
* Creates a new connection
* @param port
* @param ip
* @returns {Promise<void>}
*/
async connect(port, ip) {
this.stream = Buffer.alloc(0);
let connected = false;
if (this.proxy) {
const info = await socks_1.SocksClient.createConnection({
proxy: {
host: this.proxy.ip,
port: this.proxy.port,
type: this.proxy.socksType,
userId: this.proxy.username,
password: this.proxy.password,
},
command: "connect",
timeout: (this.proxy.timeout || 5) * 1000,
destination: {
host: ip,
port: port,
},
});
this.client = info.socket;
connected = true;
}
else {
this.client = new net.Socket();
}
this.canRead = new Promise((resolve) => {
this.resolveRead = resolve;
});
this.closed = false;
return new Promise((resolve, reject) => {
if (this.client) {
if (connected) {
this.receive();
resolve(this);
}
else {
this.client.connect(port, ip, () => {
this.receive();
resolve(this);
});
}
this.client.on("error", reject);
this.client.on("close", () => {
if (this.client && this.client.destroyed) {
if (this.resolveRead) {
this.resolveRead(false);
}
this.closed = true;
}
});
}
});
}
write(data) {
if (this.closed) {
throw closeError;
}
if (this.client) {
this.client.write(data);
}
}
async close() {
if (this.client) {
await this.client.destroy();
this.client.unref();
}
this.closed = true;
}
async receive() {
if (this.client) {
this.client.on("data", async (message) => {
const release = await mutex.acquire();
try {
let data;
//CONTEST BROWSER
this.stream = Buffer.concat([this.stream, message]);
if (this.resolveRead) {
this.resolveRead(true);
}
}
finally {
release();
}
});
}
}
toString() {
return "PromisedNetSocket";
}
constructor(...args) { }
connect(...args) { }
close(...args) { }
write(...args) { }
readExactly(...args) { }
read(...args) { }
}
exports.PromisedNetSockets = PromisedNetSockets;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
export declare class PromisedWebSockets {

@@ -3,0 +3,0 @@ private closed;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PromisedWebSockets = void 0;
const buffer_1 = require("buffer/");
const websocket_1 = require("websocket");

@@ -12,10 +13,10 @@ const async_mutex_1 = require("async-mutex");

this.client = undefined;
this.stream = Buffer.alloc(0);
this.stream = buffer_1.Buffer.alloc(0);
this.closed = true;
}
async readExactly(number) {
let readData = Buffer.alloc(0);
let readData = buffer_1.Buffer.alloc(0);
while (true) {
const thisTime = await this.read(number);
readData = Buffer.concat([readData, thisTime]);
readData = buffer_1.Buffer.concat([readData, thisTime]);
number = number - thisTime.length;

@@ -49,3 +50,3 @@ if (!number) {

const toReturn = this.stream;
this.stream = Buffer.alloc(0);
this.stream = buffer_1.Buffer.alloc(0);
this.canRead = new Promise((resolve) => {

@@ -65,3 +66,3 @@ this.resolveRead = resolve;

async connect(port, ip, testServers = false) {
this.stream = Buffer.alloc(0);
this.stream = buffer_1.Buffer.alloc(0);
this.canRead = new Promise((resolve) => {

@@ -121,4 +122,4 @@ this.resolveRead = resolve;

//CONTEST BROWSER
data = Buffer.from(await new Response(message.data).arrayBuffer());
this.stream = Buffer.concat([this.stream, data]);
data = buffer_1.Buffer.from(await new Response(message.data).arrayBuffer());
this.stream = buffer_1.Buffer.concat([this.stream, data]);
if (this.resolveRead) {

@@ -125,0 +126,0 @@ this.resolveRead(true);

@@ -1,1 +0,3 @@

export * from "socks";
export declare const SocksClient: {
createConnection: (x: any) => any;
};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocksClient = void 0;
exports.SocksClient = {
createConnection: (x) => { },
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("socks"), exports);

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import bigInt from "big-integer";

@@ -28,3 +28,3 @@ import type { EntityLike } from "./define";

*/
export declare const isArrayLike: <T>(x: any) => x is T[];
export declare const isArrayLike: <T>(x: any) => x is Array<T>;
/**

@@ -31,0 +31,0 @@ * Special case signed little ints

@@ -6,3 +6,28 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports._entityType = exports._EntityType = exports.TotalList = exports.crc32 = exports.bufferXor = exports.sleep = exports.getRandomInt = exports.getMinBigInt = exports.returnBigInt = exports.getByteArray = exports.modExp = exports.sha256 = exports.sha1 = exports.convertToLittle = exports.generateKeyDataFromNonce = exports.stripText = exports.generateRandomBytes = exports.bigIntMod = exports.mod = exports.generateRandomLong = exports.readBufferFromBigInt = exports.toSignedLittleBuffer = exports.isArrayLike = exports.betterConsoleLog = exports.groupBy = exports.escapeRegex = exports.generateRandomBigInt = exports.readBigIntFromBuffer = void 0;
exports._EntityType = exports.TotalList = exports.sleep = exports.isArrayLike = void 0;
exports.readBigIntFromBuffer = readBigIntFromBuffer;
exports.generateRandomBigInt = generateRandomBigInt;
exports.escapeRegex = escapeRegex;
exports.groupBy = groupBy;
exports.betterConsoleLog = betterConsoleLog;
exports.toSignedLittleBuffer = toSignedLittleBuffer;
exports.readBufferFromBigInt = readBufferFromBigInt;
exports.generateRandomLong = generateRandomLong;
exports.mod = mod;
exports.bigIntMod = bigIntMod;
exports.generateRandomBytes = generateRandomBytes;
exports.stripText = stripText;
exports.generateKeyDataFromNonce = generateKeyDataFromNonce;
exports.convertToLittle = convertToLittle;
exports.sha1 = sha1;
exports.sha256 = sha256;
exports.modExp = modExp;
exports.getByteArray = getByteArray;
exports.returnBigInt = returnBigInt;
exports.getMinBigInt = getMinBigInt;
exports.getRandomInt = getRandomInt;
exports.bufferXor = bufferXor;
exports.crc32 = crc32;
exports._entityType = _entityType;
const buffer_1 = require("buffer/");
const big_integer_1 = __importDefault(require("big-integer"));

@@ -19,3 +44,3 @@ const CryptoFile_1 = __importDefault(require("./CryptoFile"));

function readBigIntFromBuffer(buffer, little = true, signed = false) {
let randBuffer = Buffer.from(buffer);
let randBuffer = buffer_1.Buffer.from(buffer);
const bytesNumber = randBuffer.length;

@@ -31,11 +56,8 @@ if (little) {

}
exports.readBigIntFromBuffer = readBigIntFromBuffer;
function generateRandomBigInt() {
return readBigIntFromBuffer(generateRandomBytes(8), false);
}
exports.generateRandomBigInt = generateRandomBigInt;
function escapeRegex(string) {
return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
}
exports.escapeRegex = escapeRegex;
function groupBy(list, keyGetter) {

@@ -55,3 +77,2 @@ const map = new Map();

}
exports.groupBy = groupBy;
/**

@@ -72,3 +93,2 @@ * Outputs the object in a better way by hiding all the private methods/attributes.

}
exports.betterConsoleLog = betterConsoleLog;
/**

@@ -112,5 +132,4 @@ * Helper to find if a given object is an array (or similar)

// smh hacks
return Buffer.from(byteArray);
return buffer_1.Buffer.from(byteArray);
}
exports.toSignedLittleBuffer = toSignedLittleBuffer;
/**

@@ -140,3 +159,3 @@ * converts a big int to a buffer

const hex = bigIntVar.toString(16).padStart(bytesNumber * 2, "0");
let buffer = Buffer.from(hex, "hex");
let buffer = buffer_1.Buffer.from(hex, "hex");
if (little) {

@@ -147,3 +166,2 @@ buffer = buffer.reverse();

}
exports.readBufferFromBigInt = readBufferFromBigInt;
/**

@@ -156,3 +174,2 @@ * Generates a random long integer (8 bytes), which is optionally signed

}
exports.generateRandomLong = generateRandomLong;
/**

@@ -167,3 +184,2 @@ * .... really javascript

}
exports.mod = mod;
/**

@@ -178,3 +194,2 @@ * returns a positive bigInt

}
exports.bigIntMod = bigIntMod;
/**

@@ -186,5 +201,4 @@ * Generates a random bytes array

function generateRandomBytes(count) {
return Buffer.from(CryptoFile_1.default.randomBytes(count));
return buffer_1.Buffer.from(CryptoFile_1.default.randomBytes(count));
}
exports.generateRandomBytes = generateRandomBytes;
/**

@@ -256,3 +270,2 @@ * Calculate the key based on Telegram guidelines, specifying whether it's the client or not

}
exports.stripText = stripText;
/**

@@ -268,8 +281,8 @@ * Generates the key data corresponding to the given nonces

const [hash1, hash2, hash3] = await Promise.all([
sha1(Buffer.concat([newNonce, serverNonce])),
sha1(Buffer.concat([serverNonce, newNonce])),
sha1(Buffer.concat([newNonce, newNonce])),
sha1(buffer_1.Buffer.concat([newNonce, serverNonce])),
sha1(buffer_1.Buffer.concat([serverNonce, newNonce])),
sha1(buffer_1.Buffer.concat([newNonce, newNonce])),
]);
const keyBuffer = Buffer.concat([hash1, hash2.slice(0, 12)]);
const ivBuffer = Buffer.concat([
const keyBuffer = buffer_1.Buffer.concat([hash1, hash2.slice(0, 12)]);
const ivBuffer = buffer_1.Buffer.concat([
hash2.slice(12, 20),

@@ -284,5 +297,4 @@ hash3,

}
exports.generateKeyDataFromNonce = generateKeyDataFromNonce;
function convertToLittle(buf) {
const correct = Buffer.alloc(buf.length * 4);
const correct = buffer_1.Buffer.alloc(buf.length * 4);
for (let i = 0; i < buf.length; i++) {

@@ -293,3 +305,2 @@ correct.writeUInt32BE(buf[i], i * 4);

}
exports.convertToLittle = convertToLittle;
/**

@@ -306,3 +317,2 @@ * Calculates the SHA1 digest for the given data

}
exports.sha1 = sha1;
/**

@@ -319,3 +329,2 @@ * Calculates the SHA256 digest for the given data

}
exports.sha256 = sha256;
/**

@@ -344,3 +353,2 @@ * Fast mod pow for RSA calculation. a^b % n

}
exports.modExp = modExp;
/**

@@ -357,3 +365,2 @@ * Gets the arbitrary-length byte array corresponding to the given integer

}
exports.getByteArray = getByteArray;
function returnBigInt(num) {

@@ -371,3 +378,2 @@ if (big_integer_1.default.isInstance(num)) {

}
exports.returnBigInt = returnBigInt;
/**

@@ -392,3 +398,2 @@ * Helper function to return the smaller big int in an array

}
exports.getMinBigInt = getMinBigInt;
/**

@@ -405,3 +410,2 @@ * returns a random int from min (inclusive) and max (inclusive)

}
exports.getRandomInt = getRandomInt;
/**

@@ -426,5 +430,4 @@ * Sleeps a specified amount of time

}
return Buffer.from(res);
return buffer_1.Buffer.from(res);
}
exports.bufferXor = bufferXor;
// Taken from https://stackoverflow.com/questions/18638900/javascript-crc32/18639999#18639999

@@ -448,4 +451,4 @@ function makeCRCTable() {

}
if (!Buffer.isBuffer(buf)) {
buf = Buffer.from(buf);
if (!buffer_1.Buffer.isBuffer(buf)) {
buf = buffer_1.Buffer.from(buf);
}

@@ -459,3 +462,2 @@ let crc = -1;

}
exports.crc32 = crc32;
class TotalList extends Array {

@@ -479,9 +481,9 @@ constructor() {

if (![
0x2d45687,
0xc91c90b6,
0xe669bf46,
0x40f202fd,
0x2da17977,
0xc5af5d94,
0x1f4661b9,
0x2d45687, // crc32('Peer')
0xc91c90b6, // crc32('InputPeer')
0xe669bf46, // crc32('InputUser')
0x40f202fd, // crc32('InputChannel')
0x2da17977, // crc32('User')
0xc5af5d94, // crc32('Chat')
0x1f4661b9, // crc32('UserFull')
0xd49a2697, // crc32('ChatFull')

@@ -507,2 +509,1 @@ ].includes(entity.SUBCLASS_OF_ID)) {

}
exports._entityType = _entityType;

@@ -0,0 +0,0 @@ export { Api } from "./tl";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,1 +0,3 @@

export { inspect } from "util";
export declare const inspect: {
custom: string;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.inspect = void 0;
var util_1 = require("util");
Object.defineProperty(exports, "inspect", { enumerable: true, get: function () { return util_1.inspect; } });
exports.inspect = {
custom: "",
};

@@ -0,0 +0,0 @@ /**

@@ -6,3 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.doAuthentication = void 0;
exports.doAuthentication = doAuthentication;
const buffer_1 = require("buffer/");
const Helpers_1 = require("../Helpers");

@@ -39,3 +40,3 @@ const tl_1 = require("../tl");

const pqInnerData = new tl_1.Api.PQInnerData({
pq: (0, Helpers_1.getByteArray)(pq),
pq: (0, Helpers_1.getByteArray)(pq), // unsigned
p: pBuffer,

@@ -64,16 +65,16 @@ q: qBuffer,

const padding = (0, Helpers_1.generateRandomBytes)(192 - pqInnerData.length);
const dataWithPadding = Buffer.concat([pqInnerData, padding]);
const dataPadReversed = Buffer.from(dataWithPadding).reverse();
const dataWithPadding = buffer_1.Buffer.concat([pqInnerData, padding]);
const dataPadReversed = buffer_1.Buffer.from(dataWithPadding).reverse();
let encryptedData;
for (let i = 0; i < RETRIES; i++) {
const tempKey = (0, Helpers_1.generateRandomBytes)(32);
const shaDigestKeyWithData = await (0, Helpers_1.sha256)(Buffer.concat([tempKey, dataWithPadding]));
const dataWithHash = Buffer.concat([
const shaDigestKeyWithData = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([tempKey, dataWithPadding]));
const dataWithHash = buffer_1.Buffer.concat([
dataPadReversed,
shaDigestKeyWithData,
]);
const ige = new IGE_1.IGE(tempKey, Buffer.alloc(32));
const ige = new IGE_1.IGE(tempKey, buffer_1.Buffer.alloc(32));
const aesEncrypted = ige.encryptIge(dataWithHash);
const tempKeyXor = (0, Helpers_1.bufferXor)(tempKey, await (0, Helpers_1.sha256)(aesEncrypted));
const keyAesEncrypted = Buffer.concat([tempKeyXor, aesEncrypted]);
const keyAesEncrypted = buffer_1.Buffer.concat([tempKeyXor, aesEncrypted]);
const keyAesEncryptedInt = (0, Helpers_1.readBigIntFromBuffer)(keyAesEncrypted, false, false);

@@ -152,6 +153,6 @@ if (keyAesEncryptedInt.greaterOrEquals(targetKey.n)) {

serverNonce: resPQ.serverNonce,
retryId: big_integer_1.default.zero,
retryId: big_integer_1.default.zero, // TODO Actual retry ID
gB: (0, Helpers_1.getByteArray)(gb, false),
}).getBytes();
const clientDdhInnerHashed = Buffer.concat([
const clientDdhInnerHashed = buffer_1.Buffer.concat([
await (0, Helpers_1.sha1)(clientDhInner),

@@ -197,2 +198,1 @@ clientDhInner,

}
exports.doAuthentication = doAuthentication;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Logger, PromisedNetSockets, PromisedWebSockets } from "../../extensions";

@@ -3,0 +3,0 @@ import { AsyncQueue } from "../../extensions";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export { Connection } from "./Connection";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Connection, PacketCodec } from "./Connection";

@@ -3,0 +3,0 @@ import type { PromisedNetSockets, PromisedWebSockets } from "../../extensions";

@@ -7,2 +7,3 @@ "use strict";

exports.ConnectionTCPAbridged = exports.AbridgedPacketCodec = void 0;
const buffer_1 = require("buffer/");
const Helpers_1 = require("../../Helpers");

@@ -21,3 +22,3 @@ const Connection_1 = require("./Connection");

if (length < 127) {
const b = Buffer.alloc(1);
const b = buffer_1.Buffer.alloc(1);
b.writeUInt8(length, 0);

@@ -27,8 +28,8 @@ temp = b;

else {
temp = Buffer.concat([
Buffer.from("7f", "hex"),
temp = buffer_1.Buffer.concat([
buffer_1.Buffer.from("7f", "hex"),
(0, Helpers_1.readBufferFromBigInt)((0, big_integer_1.default)(length), 3),
]);
}
return Buffer.concat([temp, data]);
return buffer_1.Buffer.concat([temp, data]);
}

@@ -39,5 +40,5 @@ async readPacket(reader) {

if (length >= 127) {
length = Buffer.concat([
length = buffer_1.Buffer.concat([
await reader.read(3),
Buffer.alloc(1),
buffer_1.Buffer.alloc(1),
]).readInt32LE(0);

@@ -49,4 +50,4 @@ }

exports.AbridgedPacketCodec = AbridgedPacketCodec;
AbridgedPacketCodec.tag = Buffer.from("ef", "hex");
AbridgedPacketCodec.obfuscateTag = Buffer.from("efefefef", "hex");
AbridgedPacketCodec.tag = buffer_1.Buffer.from("ef", "hex");
AbridgedPacketCodec.obfuscateTag = buffer_1.Buffer.from("efefefef", "hex");
/**

@@ -53,0 +54,0 @@ * This is the mode with the lowest overhead, as it will

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Connection, PacketCodec } from "./Connection";

@@ -3,0 +3,0 @@ import type { PromisedNetSockets, PromisedWebSockets } from "../../extensions";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionTCPFull = exports.FullPacketCodec = void 0;
const buffer_1 = require("buffer/");
const Connection_1 = require("./Connection");

@@ -16,10 +17,10 @@ const Helpers_1 = require("../../Helpers");

const length = data.length + 12;
const e = Buffer.alloc(8);
const e = buffer_1.Buffer.alloc(8);
e.writeInt32LE(length, 0);
e.writeInt32LE(this._sendCounter, 4);
data = Buffer.concat([e, data]);
const crc = Buffer.alloc(4);
data = buffer_1.Buffer.concat([e, data]);
const crc = buffer_1.Buffer.alloc(4);
crc.writeUInt32LE((0, Helpers_1.crc32)(data), 0);
this._sendCounter += 1;
return Buffer.concat([data, crc]);
return buffer_1.Buffer.concat([data, crc]);
}

@@ -35,3 +36,3 @@ /**

// Return empty buffer in case of issue
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
}

@@ -49,3 +50,3 @@ const packetLen = packetLenSeq.readInt32LE(0);

body = body.slice(0, -4);
const validChecksum = (0, Helpers_1.crc32)(Buffer.concat([packetLenSeq, body]));
const validChecksum = (0, Helpers_1.crc32)(buffer_1.Buffer.concat([packetLenSeq, body]));
if (!(validChecksum === checksum)) {

@@ -52,0 +53,0 @@ throw new errors_1.InvalidChecksumError(checksum, validChecksum);

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { ObfuscatedConnection } from "./Connection";

@@ -12,10 +12,10 @@ import { AbridgedPacketCodec } from "./TCPAbridged";

}
export declare type MTProxyType = BasicProxyInterface & {
export type MTProxyType = BasicProxyInterface & {
secret: string;
MTProxy: true;
};
export declare type SocksProxyType = BasicProxyInterface & {
export type SocksProxyType = BasicProxyInterface & {
socksType: 4 | 5;
};
export declare type ProxyInterface = MTProxyType | SocksProxyType;
export type ProxyInterface = MTProxyType | SocksProxyType;
declare class MTProxyIO {

@@ -22,0 +22,0 @@ header?: Buffer;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionTCPMTProxyAbridged = exports.TCPMTProxy = void 0;
const buffer_1 = require("buffer/");
const Connection_1 = require("./Connection");

@@ -25,6 +26,6 @@ const TCPAbridged_1 = require("./TCPAbridged");

const keywords = [
Buffer.from("50567247", "hex"),
Buffer.from("474554", "hex"),
Buffer.from("504f5354", "hex"),
Buffer.from("eeeeeeee", "hex"),
buffer_1.Buffer.from("50567247", "hex"),
buffer_1.Buffer.from("474554", "hex"),
buffer_1.Buffer.from("504f5354", "hex"),
buffer_1.Buffer.from("eeeeeeee", "hex"),
];

@@ -36,3 +37,3 @@ let random;

if (random[0] !== 0xef &&
!random.slice(4, 8).equals(Buffer.alloc(4))) {
!random.slice(4, 8).equals(buffer_1.Buffer.alloc(4))) {
let ok = true;

@@ -51,26 +52,26 @@ for (const key of keywords) {

random = random.toJSON().data;
const randomReversed = Buffer.from(random.slice(8, 56)).reverse();
const randomReversed = buffer_1.Buffer.from(random.slice(8, 56)).reverse();
// Encryption has "continuous buffer" enabled
const encryptKey = await (0, Helpers_1.sha256)(Buffer.concat([Buffer.from(random.slice(8, 40)), secret]));
const encryptIv = Buffer.from(random.slice(40, 56));
const decryptKey = await (0, Helpers_1.sha256)(Buffer.concat([Buffer.from(randomReversed.slice(0, 32)), secret]));
const decryptIv = Buffer.from(randomReversed.slice(32, 48));
const encryptKey = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([buffer_1.Buffer.from(random.slice(8, 40)), secret]));
const encryptIv = buffer_1.Buffer.from(random.slice(40, 56));
const decryptKey = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([buffer_1.Buffer.from(randomReversed.slice(0, 32)), secret]));
const decryptIv = buffer_1.Buffer.from(randomReversed.slice(32, 48));
const encryptor = new CTR_1.CTR(encryptKey, encryptIv);
const decryptor = new CTR_1.CTR(decryptKey, decryptIv);
random = Buffer.concat([
Buffer.from(random.slice(0, 56)),
random = buffer_1.Buffer.concat([
buffer_1.Buffer.from(random.slice(0, 56)),
this._packetClass.obfuscateTag,
Buffer.from(random.slice(60)),
buffer_1.Buffer.from(random.slice(60)),
]);
const dcIdBytes = Buffer.alloc(2);
const dcIdBytes = buffer_1.Buffer.alloc(2);
dcIdBytes.writeInt8(this._dcId, 0);
random = Buffer.concat([
Buffer.from(random.slice(0, 60)),
random = buffer_1.Buffer.concat([
buffer_1.Buffer.from(random.slice(0, 60)),
dcIdBytes,
Buffer.from(random.slice(62)),
buffer_1.Buffer.from(random.slice(62)),
]);
random = Buffer.concat([
Buffer.from(random.slice(0, 56)),
Buffer.from(encryptor.encrypt(random).slice(56, 64)),
Buffer.from(random.slice(64)),
random = buffer_1.Buffer.concat([
buffer_1.Buffer.from(random.slice(0, 56)),
buffer_1.Buffer.from(encryptor.encrypt(random).slice(56, 64)),
buffer_1.Buffer.from(random.slice(64)),
]);

@@ -109,7 +110,7 @@ this.header = random;

// probably hex
this._secret = Buffer.from(proxy.secret, "hex");
this._secret = buffer_1.Buffer.from(proxy.secret, "hex");
}
else {
// probably b64
this._secret = Buffer.from(proxy.secret, "base64");
this._secret = buffer_1.Buffer.from(proxy.secret, "base64");
}

@@ -116,0 +117,0 @@ }

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { ObfuscatedConnection } from "./Connection";

@@ -3,0 +3,0 @@ import { AbridgedPacketCodec } from "./TCPAbridged";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionTCPObfuscated = void 0;
const buffer_1 = require("buffer/");
const Helpers_1 = require("../../Helpers");

@@ -17,6 +18,6 @@ const Connection_1 = require("./Connection");

const keywords = [
Buffer.from("50567247", "hex"),
Buffer.from("474554", "hex"),
Buffer.from("504f5354", "hex"),
Buffer.from("eeeeeeee", "hex"),
buffer_1.Buffer.from("50567247", "hex"),
buffer_1.Buffer.from("474554", "hex"),
buffer_1.Buffer.from("504f5354", "hex"),
buffer_1.Buffer.from("eeeeeeee", "hex"),
];

@@ -28,3 +29,3 @@ let random;

if (random[0] !== 0xef &&
!random.slice(4, 8).equals(Buffer.alloc(4))) {
!random.slice(4, 8).equals(buffer_1.Buffer.alloc(4))) {
let ok = true;

@@ -43,19 +44,19 @@ for (const key of keywords) {

random = random.toJSON().data;
const randomReversed = Buffer.from(random.slice(8, 56)).reverse();
const randomReversed = buffer_1.Buffer.from(random.slice(8, 56)).reverse();
// Encryption has "continuous buffer" enabled
const encryptKey = Buffer.from(random.slice(8, 40));
const encryptIv = Buffer.from(random.slice(40, 56));
const decryptKey = Buffer.from(randomReversed.slice(0, 32));
const decryptIv = Buffer.from(randomReversed.slice(32, 48));
const encryptKey = buffer_1.Buffer.from(random.slice(8, 40));
const encryptIv = buffer_1.Buffer.from(random.slice(40, 56));
const decryptKey = buffer_1.Buffer.from(randomReversed.slice(0, 32));
const decryptIv = buffer_1.Buffer.from(randomReversed.slice(32, 48));
const encryptor = new CTR_1.CTR(encryptKey, encryptIv);
const decryptor = new CTR_1.CTR(decryptKey, decryptIv);
random = Buffer.concat([
Buffer.from(random.slice(0, 56)),
random = buffer_1.Buffer.concat([
buffer_1.Buffer.from(random.slice(0, 56)),
this._packetClass.obfuscateTag,
Buffer.from(random.slice(60)),
buffer_1.Buffer.from(random.slice(60)),
]);
random = Buffer.concat([
Buffer.from(random.slice(0, 56)),
Buffer.from(encryptor.encrypt(random).slice(56, 64)),
Buffer.from(random.slice(64)),
random = buffer_1.Buffer.concat([
buffer_1.Buffer.from(random.slice(0, 56)),
buffer_1.Buffer.from(encryptor.encrypt(random).slice(56, 64)),
buffer_1.Buffer.from(random.slice(64)),
]);

@@ -62,0 +63,0 @@ this.header = random;

@@ -0,0 +0,0 @@ export { MTProtoPlainSender } from "./MTProtoPlainSender";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Api } from "../tl";

@@ -7,2 +7,3 @@ "use strict";

exports.MTProtoPlainSender = void 0;
const buffer_1 = require("buffer/");
/**

@@ -38,6 +39,6 @@ * This module contains the class used to communicate with Telegram's servers

const m = (0, Helpers_1.toSignedLittleBuffer)(msgId, 8);
const b = Buffer.alloc(4);
const b = buffer_1.Buffer.alloc(4);
b.writeInt32LE(body.length, 0);
const res = Buffer.concat([
Buffer.concat([Buffer.alloc(8), m, b]),
const res = buffer_1.Buffer.concat([
buffer_1.Buffer.concat([buffer_1.Buffer.alloc(8), m, b]),
body,

@@ -44,0 +45,0 @@ ]);

@@ -0,0 +0,0 @@ /**

@@ -7,2 +7,3 @@ "use strict";

exports.MTProtoSender = void 0;
const buffer_1 = require("buffer/");
/**

@@ -548,3 +549,3 @@ * MTProto Mobile Protocol sender

if (!(reader.tgReadObject() instanceof tl_1.Api.upload.File)) {
throw new errors_1.TypeNotFoundError(0, Buffer.alloc(0));
throw new errors_1.TypeNotFoundError(0, buffer_1.Buffer.alloc(0));
}

@@ -551,0 +552,0 @@ }

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import bigInt from "big-integer";

@@ -3,0 +3,0 @@ import type { AuthKey } from "../crypto/AuthKey";

@@ -7,2 +7,3 @@ "use strict";

exports.MTProtoState = void 0;
const buffer_1 = require("buffer/");
const big_integer_1 = __importDefault(require("big-integer"));

@@ -82,6 +83,6 @@ const __1 = require("../");

const [sha256a, sha256b] = await Promise.all([
(0, Helpers_1.sha256)(Buffer.concat([msgKey, authKey.slice(x, x + 36)])),
(0, Helpers_1.sha256)(Buffer.concat([authKey.slice(x + 40, x + 76), msgKey])),
(0, Helpers_1.sha256)(buffer_1.Buffer.concat([msgKey, authKey.slice(x, x + 36)])),
(0, Helpers_1.sha256)(buffer_1.Buffer.concat([authKey.slice(x + 40, x + 76), msgKey])),
]);
const key = Buffer.concat([
const key = buffer_1.Buffer.concat([
sha256a.slice(0, 8),

@@ -91,3 +92,3 @@ sha256b.slice(8, 24),

]);
const iv = Buffer.concat([
const iv = buffer_1.Buffer.concat([
sha256b.slice(0, 8),

@@ -124,8 +125,8 @@ sha256a.slice(8, 24),

}
const s = Buffer.alloc(4);
const s = buffer_1.Buffer.alloc(4);
s.writeInt32LE(seqNo, 0);
const b = Buffer.alloc(4);
const b = buffer_1.Buffer.alloc(4);
b.writeInt32LE(body.length, 0);
const m = (0, Helpers_1.toSignedLittleBuffer)(msgId, 8);
buffer.write(Buffer.concat([m, s, b]));
buffer.write(buffer_1.Buffer.concat([m, s, b]));
buffer.write(body);

@@ -153,7 +154,7 @@ return msgId;

const i = (0, Helpers_1.toSignedLittleBuffer)(this.id, 8);
data = Buffer.concat([Buffer.concat([s, i]), data]);
data = buffer_1.Buffer.concat([buffer_1.Buffer.concat([s, i]), data]);
const padding = __1.helpers.generateRandomBytes(__1.helpers.mod(-(data.length + 12), 16) + 12);
// Being substr(what, offset, length); x = 0 for client
// "msg_key_large = SHA256(substr(auth_key, 88+x, 32) + pt + padding)"
const msgKeyLarge = await (0, Helpers_1.sha256)(Buffer.concat([authKey.slice(88, 88 + 32), data, padding]));
const msgKeyLarge = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([authKey.slice(88, 88 + 32), data, padding]));
// "msg_key = substr (msg_key_large, 8, 16)"

@@ -163,6 +164,6 @@ const msgKey = msgKeyLarge.slice(8, 24);

const keyId = __1.helpers.readBufferFromBigInt(this.authKey.keyId, 8);
return Buffer.concat([
return buffer_1.Buffer.concat([
keyId,
msgKey,
new IGE_1.IGE(key, iv).encryptIge(Buffer.concat([data, padding])),
new IGE_1.IGE(key, iv).encryptIge(buffer_1.Buffer.concat([data, padding])),
]);

@@ -195,3 +196,3 @@ }

// Sections "checking sha256 hash" and "message length"
const ourKey = await (0, Helpers_1.sha256)(Buffer.concat([authKey.slice(96, 96 + 32), body]));
const ourKey = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([authKey.slice(96, 96 + 32), body]));
if (!msgKey.equals(ourKey.slice(8, 24))) {

@@ -198,0 +199,0 @@ throw new errors_1.SecurityError("Received msg_key doesn't match with expected one");

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import bigInt from "big-integer";

@@ -3,0 +3,0 @@ import Deferred from "../extensions/Deferred";

@@ -0,0 +0,0 @@ "use strict";

{
"name": "telegram",
"version": "2.26.8",
"version": "2.26.9",
"description": "NodeJS/Browser MTProto API Telegram client library,",

@@ -32,2 +32,7 @@ "main": "index.js",

},
"exports": {
".": "./index.js",
"./session": "./session/index.js",
"./events": "./events/index.js"
},
"devDependencies": {

@@ -70,6 +75,4 @@ "@babel/core": "^7.12.13",

"ts-custom-error": "^3.2.0",
"websocket": "^1.0.34",
"node-localstorage": "^2.2.1",
"socks": "^2.6.2"
"websocket": "^1.0.34"
}
}

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Api } from "./tl";

@@ -3,0 +3,0 @@ /**

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.computeDigest = exports.computeCheck = void 0;
exports.computeCheck = computeCheck;
exports.computeDigest = computeDigest;
const buffer_1 = require("buffer/");
const tl_1 = require("./tl");

@@ -70,3 +72,3 @@ const Helpers_1 = require("./Helpers");

function checkPrimeAndGood(primeBytes, g) {
const goodPrime = Buffer.from([
const goodPrime = buffer_1.Buffer.from([
0xc7, 0x1c, 0xae, 0xb9, 0xc6, 0xb1, 0xc9, 0x04, 0x8e, 0x6c, 0x52, 0x2f,

@@ -118,3 +120,3 @@ 0x70, 0xf1, 0x3f, 0x73, 0x98, 0x0d, 0x40, 0x23, 0x8e, 0x3e, 0x21, 0xc1,

function numBytesForHash(number) {
return Buffer.concat([Buffer.alloc(SIZE_FOR_HASH - number.length), number]);
return buffer_1.Buffer.concat([buffer_1.Buffer.alloc(SIZE_FOR_HASH - number.length), number]);
}

@@ -168,6 +170,6 @@ /**

async function computeHash(algo, password) {
const hash1 = await (0, Helpers_1.sha256)(Buffer.concat([algo.salt1, Buffer.from(password, "utf-8"), algo.salt1]));
const hash2 = await (0, Helpers_1.sha256)(Buffer.concat([algo.salt2, hash1, algo.salt2]));
const hash1 = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([algo.salt1, buffer_1.Buffer.from(password, "utf-8"), algo.salt1]));
const hash2 = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([algo.salt2, hash1, algo.salt2]));
const hash3 = await pbkdf2sha512(hash2, algo.salt1, 100000);
return (0, Helpers_1.sha256)(Buffer.concat([algo.salt2, hash3, algo.salt2]));
return (0, Helpers_1.sha256)(buffer_1.Buffer.concat([algo.salt2, hash3, algo.salt2]));
}

@@ -189,3 +191,2 @@ /**

}
exports.computeDigest = computeDigest;
/**

@@ -225,3 +226,3 @@ *

const gX = (0, Helpers_1.modExp)((0, big_integer_1.default)(g), x, p);
const k = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(Buffer.concat([pForHash, gForHash])), false);
const k = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([pForHash, gForHash])), false);
const kgX = (0, Helpers_1.bigIntMod)(k.multiply(gX), p);

@@ -237,3 +238,3 @@ const generateAndCheckRandom = async () => {

const aForHash = bigNumForHash(A);
const u = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(Buffer.concat([aForHash, bForHash])), false);
const u = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([aForHash, bForHash])), false);
if (u.greater((0, big_integer_1.default)(0))) {

@@ -264,3 +265,3 @@ return {

]);
const M1 = await (0, Helpers_1.sha256)(Buffer.concat([
const M1 = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([
xor(pSha, gSha),

@@ -275,6 +276,5 @@ salt1Sha,

srpId: srpId,
A: Buffer.from(aForHash),
A: buffer_1.Buffer.from(aForHash),
M1: M1,
});
}
exports.computeCheck = computeCheck;
export declare const isDeno: boolean;
export declare const isBrowser: boolean;
export declare const isNode: boolean;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import type { TelegramClient } from "./client/TelegramClient";

@@ -85,7 +85,9 @@ "use strict";

async collect() {
var e_1, _a;
var _a, e_1, _b, _c;
const result = new _1.helpers.TotalList();
try {
for (var _b = __asyncValues(this), _c; _c = await _b.next(), !_c.done;) {
const message = _c.value;
for (var _d = true, _e = __asyncValues(this), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const message = _c;
result.push(message);

@@ -97,3 +99,3 @@ }

try {
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
}

@@ -100,0 +102,0 @@ finally { if (e_1) throw e_1.error; }

@@ -0,0 +0,0 @@ import type { AuthKey } from "../crypto/AuthKey";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,18 +0,1 @@

export = CacheApi;
declare class CacheApi {
constructor(sessionId: any);
_storageKey: any;
_authKeys: {};
load(): Promise<void>;
setDC(dcId: any, serverAddress: any, port: any, skipUpdateStorage?: boolean): void;
_dcId: any;
_serverAddress: any;
_port: any;
save(): Promise<any>;
set authKey(arg: void);
get authKey(): void;
getAuthKey(dcId?: any): any;
setAuthKey(authKey: any, dcId?: any): void;
_updateStorage(): Promise<void>;
delete(): Promise<void>;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer/");
const MemorySession = require("./Memory");

@@ -24,3 +26,3 @@ const AuthKey = require("../crypto/AuthKey");

if (keys[dcId] && hashes[dcId]) {
this._authKeys[dcId] = new AuthKey(Buffer.from(keys[dcId].data), Buffer.from(hashes[dcId].data));
this._authKeys[dcId] = new AuthKey(buffer_1.Buffer.from(keys[dcId].data), buffer_1.Buffer.from(hashes[dcId].data));
}

@@ -27,0 +29,0 @@ });

@@ -0,0 +0,0 @@ export { MemorySession } from "./Memory";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,1 +0,3 @@

export declare const LocalStorage: any;
export declare class LocalStorage {
constructor(location: string);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalStorage = void 0;
exports.LocalStorage = require("node-localstorage").LocalStorage;
class LocalStorage {
constructor(location) {
throw new Error("Do not call me");
}
}
exports.LocalStorage = LocalStorage;

@@ -0,0 +0,0 @@ import { Session } from "./Abstract";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { MemorySession } from "./Memory";

@@ -7,2 +7,3 @@ "use strict";

exports.StoreSession = void 0;
const buffer_1 = require("buffer/");
const Memory_1 = require("./Memory");

@@ -34,3 +35,3 @@ const store2_1 = __importDefault(require("store2"));

if ("data" in authKey) {
authKey = Buffer.from(authKey.data);
authKey = buffer_1.Buffer.from(authKey.data);
}

@@ -37,0 +38,0 @@ await this._authKey.setKey(authKey);

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { MemorySession } from "./Memory";

@@ -3,0 +3,0 @@ export declare class StringSession extends MemorySession {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StringSession = void 0;
const buffer_1 = require("buffer/");
const Memory_1 = require("./Memory");

@@ -83,3 +84,3 @@ const extensions_1 = require("../extensions");

static decode(x) {
return Buffer.from(x, "base64");
return buffer_1.Buffer.from(x, "base64");
}

@@ -101,10 +102,10 @@ async load() {

}
const dcBuffer = Buffer.from([this.dcId]);
const addressBuffer = Buffer.from(this.serverAddress);
const addressLengthBuffer = Buffer.alloc(2);
const dcBuffer = buffer_1.Buffer.from([this.dcId]);
const addressBuffer = buffer_1.Buffer.from(this.serverAddress);
const addressLengthBuffer = buffer_1.Buffer.alloc(2);
addressLengthBuffer.writeInt16BE(addressBuffer.length, 0);
const portBuffer = Buffer.alloc(2);
const portBuffer = buffer_1.Buffer.alloc(2);
portBuffer.writeInt16BE(this.port, 0);
return (CURRENT_VERSION +
StringSession.encode(Buffer.concat([
StringSession.encode(buffer_1.Buffer.concat([
dcBuffer,

@@ -111,0 +112,0 @@ addressLengthBuffer,

export declare const LAYER = 193;
declare const tlobjects: any;
export { tlobjects };

@@ -0,0 +0,0 @@ "use strict";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer/");
const { inspect } = require("../inspect");

@@ -84,3 +86,3 @@ const bigInt = require("big-integer");

case "int":
const i = Buffer.alloc(4);
const i = buffer_1.Buffer.alloc(4);
i.writeInt32LE(x, 0);

@@ -95,3 +97,3 @@ return i;

case "double":
const d = Buffer.alloc(8);
const d = buffer_1.Buffer.alloc(8);
d.writeDoubleLE(x, 0);

@@ -103,6 +105,6 @@ return d;

return x
? Buffer.from("b5757299", "hex")
: Buffer.from("379779bc", "hex");
? buffer_1.Buffer.from("b5757299", "hex")
: buffer_1.Buffer.from("379779bc", "hex");
case "true":
return Buffer.alloc(0);
return buffer_1.Buffer.alloc(0);
case "bytes":

@@ -218,3 +220,3 @@ return serializeBytes(x);

case "buffer":
correct = Buffer.isBuffer(value);
correct = buffer_1.Buffer.isBuffer(value);
break;

@@ -369,3 +371,3 @@ case "date":

const idForBytes = this.CONSTRUCTOR_ID;
const c = Buffer.alloc(4);
const c = buffer_1.Buffer.alloc(4);
c.writeUInt32LE(idForBytes, 0);

@@ -386,11 +388,11 @@ const buffers = [c];

if (argsConfig[arg].useVectorId) {
buffers.push(Buffer.from("15c4b51c", "hex"));
buffers.push(buffer_1.Buffer.from("15c4b51c", "hex"));
}
const l = Buffer.alloc(4);
const l = buffer_1.Buffer.alloc(4);
l.writeInt32LE(this[arg].length, 0);
buffers.push(l, Buffer.concat(this[arg].map((x) => argToBytes(x, argsConfig[arg].type, fullName))));
buffers.push(l, buffer_1.Buffer.concat(this[arg].map((x) => argToBytes(x, argsConfig[arg].type, fullName))));
}
else if (argsConfig[arg].flagIndicator) {
if (!Object.values(argsConfig).some((f) => f.isFlag)) {
buffers.push(Buffer.alloc(4));
buffers.push(buffer_1.Buffer.alloc(4));
}

@@ -415,3 +417,3 @@ else {

}
const f = Buffer.alloc(4);
const f = buffer_1.Buffer.alloc(4);
f.writeUInt32LE(flagCalculate, 0);

@@ -434,3 +436,3 @@ buffers.push(f);

}
return Buffer.concat(buffers);
return buffer_1.Buffer.concat(buffers);
}

@@ -437,0 +439,0 @@ readResult(reader) {

declare const _exports: string;
export = _exports;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import type { BinaryReader } from "../../extensions";

@@ -3,0 +3,0 @@ export declare class GZIPPacked {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GZIPPacked = void 0;
const buffer_1 = require("buffer/");
const __1 = require("../");

@@ -22,3 +23,3 @@ const pako_1 = require("pako");

static gzip(input) {
return Buffer.from(input);
return buffer_1.Buffer.from(input);
// TODO this usually makes it faster for large requests

@@ -28,8 +29,8 @@ //return Buffer.from(deflate(input, { level: 9, gzip: true }))

static ungzip(input) {
return Buffer.from((0, pako_1.inflate)(input));
return buffer_1.Buffer.from((0, pako_1.inflate)(input));
}
async toBytes() {
const g = Buffer.alloc(4);
const g = buffer_1.Buffer.alloc(4);
g.writeUInt32LE(GZIPPacked.CONSTRUCTOR_ID, 0);
return Buffer.concat([
return buffer_1.Buffer.concat([
g,

@@ -36,0 +37,0 @@ (0, __1.serializeBytes)(await GZIPPacked.gzip(this.data)),

@@ -0,0 +0,0 @@ import { TLMessage } from "./TLMessage";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import type { BinaryReader } from "../../extensions";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { Api } from "../api";

@@ -3,0 +3,0 @@ import type { BinaryReader } from "../../extensions";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import bigInt from "big-integer";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,5 +0,4 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import type { ButtonLike, EntityLike } from "../../define";
import { Api } from "../api";
import { inspect } from "../../inspect";
export declare class Button {

@@ -10,7 +9,4 @@ button: ButtonLike;

singleUse: boolean | undefined;
[inspect.custom](): {
[key: string]: any;
};
constructor(button: Api.TypeKeyboardButton, resize?: boolean, singleUse?: boolean, selective?: boolean);
static _isInline(button: ButtonLike): boolean;
static _isInline(button: ButtonLike): button is Api.KeyboardButtonUrl | Api.KeyboardButtonCallback | Api.KeyboardButtonSwitchInline | Api.KeyboardButtonUrlAuth | Api.InputKeyboardButtonUrlAuth;
static inline(text: string, data?: Buffer): Api.KeyboardButtonCallback;

@@ -17,0 +13,0 @@ static switchInline(text: string, query?: string, samePeer?: boolean): Api.KeyboardButtonSwitchInline;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Button = void 0;
const buffer_1 = require("buffer/");
const api_1 = require("../api");

@@ -9,2 +10,5 @@ const __1 = require("../../");

class Button {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(button, resize, singleUse, selective) {

@@ -16,5 +20,2 @@ this.button = button;

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
static _isInline(button) {

@@ -29,3 +30,3 @@ return (button instanceof api_1.Api.KeyboardButtonCallback ||

if (!data) {
data = Buffer.from(text, "utf-8");
data = buffer_1.Buffer.from(text, "utf-8");
}

@@ -32,0 +33,0 @@ if (data.length > 64) {

@@ -1,5 +0,3 @@

/// <reference types="node" />
import type { Entity, EntityLike } from "../../define";
import type { TelegramClient } from "../../client/TelegramClient";
import { inspect } from "../../inspect";
export interface ChatGetterConstructorParams {

@@ -17,5 +15,2 @@ chatPeer?: EntityLike;

_client?: TelegramClient;
[inspect.custom](): {
[key: string]: any;
};
static initChatClass(c: any, { chatPeer, inputChat, chat, broadcast }: ChatGetterConstructorParams): void;

@@ -22,0 +17,0 @@ get chat(): Entity | undefined;

@@ -54,3 +54,3 @@ "use strict";

async getInputChat() {
var e_1, _a;
var _a, e_1, _b, _c;
if (!this.inputChat && this.chatId && this._client) {

@@ -60,6 +60,8 @@ try {

try {
for (var _b = __asyncValues(this._client.iterDialogs({
for (var _d = true, _e = __asyncValues(this._client.iterDialogs({
limit: 100,
})), _c; _c = await _b.next(), !_c.done;) {
const dialog = _c.value;
})), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
_c = _f.value;
_d = false;
const dialog = _c;
if (dialog.id.eq(target)) {

@@ -75,3 +77,3 @@ this._chat = dialog.entity;

try {
if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
}

@@ -78,0 +80,0 @@ finally { if (e_1) throw e_1.error; }

@@ -1,2 +0,1 @@

/// <reference types="node" />
import type { TelegramClient } from "../..";

@@ -7,3 +6,2 @@ import { Api } from "../api";

import bigInt from "big-integer";
import { inspect } from "../../inspect";
export declare class Dialog {

@@ -28,6 +26,3 @@ _client: TelegramClient;

isChannel: boolean;
[inspect.custom](): {
[key: string]: any;
};
constructor(client: TelegramClient, dialog: Api.Dialog, entities: Map<string, Entity>, message?: Api.Message);
}

@@ -10,2 +10,5 @@ "use strict";

class Dialog {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, dialog, entities, message) {

@@ -37,6 +40,3 @@ this._client = client;

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
}
exports.Dialog = Dialog;

@@ -1,6 +0,4 @@

/// <reference types="node" />
import type { Entity } from "../../define";
import type { TelegramClient } from "../..";
import { Api } from "../api";
import { inspect } from "../../inspect";
export declare class Draft {

@@ -16,5 +14,2 @@ private _client;

private replyToMsgId?;
[inspect.custom](): {
[key: string]: any;
};
constructor(client: TelegramClient, entity: Entity, draft: Api.TypeDraftMessage | undefined);

@@ -21,0 +16,0 @@ get entity(): Entity | undefined;

@@ -9,2 +9,5 @@ "use strict";

class Draft {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, entity, draft) {

@@ -36,5 +39,2 @@ this._client = client;

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
get entity() {

@@ -41,0 +41,0 @@ return this._entity;

@@ -1,9 +0,4 @@

/// <reference types="node" />
import type { FileLike } from "../../define";
import { inspect } from "../../inspect";
export declare class File {
private readonly media;
[inspect.custom](): {
[key: string]: any;
};
constructor(media: FileLike);

@@ -10,0 +5,0 @@ get id(): void;

@@ -9,8 +9,8 @@ "use strict";

class File {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(media) {
this.media = media;
}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
get id() {

@@ -17,0 +17,0 @@ throw new Error("Unsupported");

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { ChatGetter } from "./chatGetter";

@@ -7,8 +6,4 @@ import { SenderGetter } from "./senderGetter";

import type { Entity } from "../../define";
import { inspect } from "../../inspect";
export declare class Forward extends SenderGetter {
private originalFwd;
[inspect.custom](): {
[key: string]: any;
};
constructor(client: TelegramClient, original: Api.MessageFwdHeader, entities: Map<string, Entity>);

@@ -15,0 +10,0 @@ }

@@ -10,2 +10,5 @@ "use strict";

class Forward extends senderGetter_1.SenderGetter {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, original, entities) {

@@ -44,6 +47,3 @@ super();

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
}
exports.Forward = Forward;
export { ChatGetter } from "./chatGetter";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,6 +0,4 @@

/// <reference types="node" />
import type { TelegramClient } from "../..";
import type { EntityLike, MessageIDLike } from "../../define";
import { Api } from "../api";
import { inspect } from "../../inspect";
export declare class InlineResult {

@@ -22,5 +20,2 @@ private _ARTICLE;

private _client;
[inspect.custom](): {
[key: string]: any;
};
constructor(client: TelegramClient, original: Api.TypeBotInlineResult, queryId?: Api.long, entity?: EntityLike);

@@ -27,0 +22,0 @@ get type(): string;

@@ -9,2 +9,5 @@ "use strict";

class InlineResult {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, original, queryId, entity) {

@@ -27,5 +30,2 @@ this._ARTICLE = "article";

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
get type() {

@@ -32,0 +32,0 @@ return this.result.type;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import type { TelegramClient } from "../..";

@@ -6,3 +5,2 @@ import type { EntityLike } from "../../define";

import { InlineResult } from "./inlineResult";
import { inspect } from "../../inspect";
export declare class InlineResults extends Array<InlineResult> {

@@ -17,7 +15,4 @@ private result;

private switchPm;
[inspect.custom](): {
[key: string]: any;
};
constructor(client: TelegramClient, original: Api.messages.TypeBotResults, entity?: EntityLike);
resultsValid(): boolean;
}

@@ -8,2 +8,5 @@ "use strict";

class InlineResults extends Array {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, original, entity) {

@@ -20,5 +23,2 @@ super(...original.results.map((res) => new inlineResult_1.InlineResult(client, res, original.queryId, entity)));

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
resultsValid() {

@@ -25,0 +25,0 @@ return new Date().getTime() / 1000 < this._validUntil;

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import { SenderGetter } from "./senderGetter";

@@ -12,3 +12,2 @@ import type { Entity, EntityLike } from "../../define";

import { MessageButton } from "./messageButton";
import { inspect } from "../../inspect";
interface MessageBaseInterface {

@@ -346,5 +345,2 @@ id: any;

patternMatch?: RegExpMatchArray;
[inspect.custom](): {
[key: string]: any;
};
init({ id, peerId, date, out, mentioned, mediaUnread, silent, post, fromId, replyTo, message, fwdFrom, viaBotId, media, replyMarkup, entities, views, editDate, postAuthor, groupedId, fromScheduled, legacy, editHide, pinned, restrictionReason, forwards, replies, action, reactions, noforwards, ttlPeriod, _entities, }: MessageBaseInterface): void;

@@ -351,0 +347,0 @@ constructor(args: MessageBaseInterface);

@@ -45,6 +45,2 @@ "use strict";

class CustomMessage extends senderGetter_1.SenderGetter {
constructor(args) {
super();
this.init(args);
}
[inspect_1.inspect.custom]() {

@@ -116,2 +112,6 @@ return (0, Helpers_1.betterConsoleLog)(this);

}
constructor(args) {
super();
this.init(args);
}
_finishInit(client, entities, inputChat) {

@@ -118,0 +118,0 @@ this._client = client;

@@ -1,6 +0,4 @@

/// <reference types="node" />
import type { TelegramClient } from "../../client/TelegramClient";
import type { ButtonLike, EntityLike, MessageIDLike } from "../../define";
import { Api } from "../api";
import { inspect } from "../../inspect";
export declare class MessageButton {

@@ -12,9 +10,6 @@ private readonly _client;

private readonly _msgId;
[inspect.custom](): {
[key: string]: any;
};
constructor(client: TelegramClient, original: ButtonLike, chat: EntityLike, bot: EntityLike | undefined, msgId: MessageIDLike);
get client(): TelegramClient;
get text(): string;
get data(): Buffer | undefined;
get data(): import("buffer").Buffer | undefined;
get inlineQuery(): string | undefined;

@@ -21,0 +16,0 @@ get url(): string | undefined;

@@ -10,2 +10,5 @@ "use strict";

class MessageButton {
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
constructor(client, original, chat, bot, msgId) {

@@ -18,5 +21,2 @@ this.button = original;

}
[inspect_1.inspect.custom]() {
return (0, Helpers_1.betterConsoleLog)(this);
}
get client() {

@@ -23,0 +23,0 @@ return this._client;

@@ -1,2 +0,1 @@

/// <reference types="node" />
import type { Entity } from "../../define";

@@ -7,3 +6,2 @@ import type { TelegramClient } from "../..";

import bigInt from "big-integer";
import { inspect } from "../../inspect";
interface SenderGetterConstructorInterface {

@@ -19,5 +17,2 @@ senderId?: bigInt.BigInteger;

_client?: TelegramClient;
[inspect.custom](): {
[key: string]: any;
};
static initSenderClass(c: any, { senderId, sender, inputSender }: SenderGetterConstructorInterface): void;

@@ -24,0 +19,0 @@ get sender(): Entity | undefined;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import type { DateLike } from "../define";

@@ -3,0 +3,0 @@ declare const snakeToCamelCase: (name: string) => string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.variableSnakeToCamelCase = exports.snakeToCamelCase = exports.CORE_TYPES = exports.fromLine = exports.buildArgConfig = exports.parseTl = exports.findAll = exports.serializeDate = exports.serializeBytes = void 0;
exports.variableSnakeToCamelCase = exports.snakeToCamelCase = exports.CORE_TYPES = exports.fromLine = exports.parseTl = exports.findAll = void 0;
exports.serializeBytes = serializeBytes;
exports.serializeDate = serializeDate;
exports.buildArgConfig = buildArgConfig;
const buffer_1 = require("buffer/");
const Helpers_1 = require("../Helpers");

@@ -13,6 +17,6 @@ const snakeToCamelCase = (name) => {

const CORE_TYPES = new Set([
0xbc799737,
0x997275b5,
0x3fedd339,
0xc4b9f9bb,
0xbc799737, // boolFalse#bc799737 = Bool;
0x997275b5, // boolTrue#997275b5 = Bool;
0x3fedd339, // true#3fedd339 = True;
0xc4b9f9bb, // error#c4b9f9bb code:int text:string = Error;
0x56730bcc, // null#56730bcc = Null;

@@ -22,12 +26,12 @@ ]);

const AUTH_KEY_TYPES = new Set([
0x05162463,
0x83c95aec,
0xa9f55f95,
0x3c6a84d4,
0x56fddf88,
0xd0e8075c,
0xb5890dba,
0x6643b654,
0xd712e4be,
0xf5045f1f,
0x05162463, // resPQ,
0x83c95aec, // p_q_inner_data
0xa9f55f95, // p_q_inner_data_dc
0x3c6a84d4, // p_q_inner_data_temp
0x56fddf88, // p_q_inner_data_temp_dc
0xd0e8075c, // server_DH_params_ok
0xb5890dba, // server_DH_inner_data
0x6643b654, // client_DH_inner_data
0xd712e4be, // req_DH_params
0xf5045f1f, // set_client_DH_params
0x3072cfa1, // gzip_packed

@@ -72,3 +76,3 @@ ]);

}
currentConfig.constructorId = (0, Helpers_1.crc32)(Buffer.from(representation, "utf8"));
currentConfig.constructorId = (0, Helpers_1.crc32)(buffer_1.Buffer.from(representation, "utf8"));
}

@@ -171,3 +175,2 @@ for (const [brace, name, argType] of argsMatch) {

}
exports.buildArgConfig = buildArgConfig;
const parseTl = function* (content, layer, methods = [], ignoreIds = CORE_TYPES) {

@@ -244,5 +247,5 @@ const methodInfo = (methods || []).reduce((o, m) => (Object.assign(Object.assign({}, o), { [m.name]: m })), {});

function serializeBytes(data) {
if (!(data instanceof Buffer)) {
if (!(data instanceof buffer_1.Buffer)) {
if (typeof data == "string") {
data = Buffer.from(data);
data = buffer_1.Buffer.from(data);
}

@@ -260,3 +263,3 @@ else {

}
r.push(Buffer.from([data.length]));
r.push(buffer_1.Buffer.from([data.length]));
r.push(data);

@@ -269,3 +272,3 @@ }

}
r.push(Buffer.from([
r.push(buffer_1.Buffer.from([
254,

@@ -278,9 +281,8 @@ data.length % 256,

}
r.push(Buffer.alloc(padding).fill(0));
return Buffer.concat(r);
r.push(buffer_1.Buffer.alloc(padding).fill(0));
return buffer_1.Buffer.concat(r);
}
exports.serializeBytes = serializeBytes;
function serializeDate(dt) {
if (!dt) {
return Buffer.alloc(4).fill(0);
return buffer_1.Buffer.alloc(4).fill(0);
}

@@ -291,3 +293,3 @@ if (dt instanceof Date) {

if (typeof dt == "number") {
const t = Buffer.alloc(4);
const t = buffer_1.Buffer.alloc(4);
t.writeInt32LE(dt, 0);

@@ -298,2 +300,1 @@ return t;

}
exports.serializeDate = serializeDate;
import { Api } from "./api";
export { Api };
export { serializeBytes, serializeDate } from "./generationHelpers";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
export declare class MTProtoRequest {

@@ -3,0 +3,0 @@ private sent;

@@ -0,0 +0,0 @@ "use strict";

declare function patchAll(): void;
export { patchAll };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.patchAll = void 0;
exports.patchAll = patchAll;
const api_1 = require("../api");

@@ -77,2 +77,1 @@ const message_1 = require("../custom/message");

}
exports.patchAll = patchAll;
declare const _exports: string;
export = _exports;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -1,6 +0,1 @@

declare function _exports({ types, constructors, functions }: {
types: any;
constructors: any;
functions: any;
}): string;
export = _exports;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = require("buffer/");
// Not sure what they are for.

@@ -3,0 +5,0 @@ const WEIRD_TYPES = new Set(["Bool", "X", "Type"]);

@@ -1,2 +0,2 @@

/// <reference types="node" />
import { Buffer } from "buffer/";
import bigInt from "big-integer";

@@ -3,0 +3,0 @@ import type { ParseInterface } from "./client/messageParse";

@@ -6,3 +6,34 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getDisplayName = exports.rtrim = exports.parseUsername = exports.resolveInviteLink = exports.parseID = exports.parsePhone = exports.getMessageId = exports.resolveId = exports.getPeerId = exports.sanitizeParseMode = exports.getPeer = exports.getAppropriatedPartSize = exports.getInputMedia = exports.getInputGeo = exports.getAttributes = exports.getExtension = exports.isImage = exports.isAudio = exports.getInputDocument = exports.getInputPhoto = exports.strippedPhotoToJpg = exports.getInputChatPhoto = exports.getInputMessage = exports.getInputUser = exports.getInputChannel = exports.getInnerText = exports._getEntityPair = exports._photoSizeByteCount = exports.getInputPeer = exports.chunks = exports.getFileInfo = void 0;
exports.getFileInfo = getFileInfo;
exports.chunks = chunks;
exports.getInputPeer = getInputPeer;
exports._photoSizeByteCount = _photoSizeByteCount;
exports._getEntityPair = _getEntityPair;
exports.getInnerText = getInnerText;
exports.getInputChannel = getInputChannel;
exports.getInputUser = getInputUser;
exports.getInputMessage = getInputMessage;
exports.getInputChatPhoto = getInputChatPhoto;
exports.strippedPhotoToJpg = strippedPhotoToJpg;
exports.getInputPhoto = getInputPhoto;
exports.getInputDocument = getInputDocument;
exports.isAudio = isAudio;
exports.isImage = isImage;
exports.getExtension = getExtension;
exports.getAttributes = getAttributes;
exports.getInputGeo = getInputGeo;
exports.getInputMedia = getInputMedia;
exports.getAppropriatedPartSize = getAppropriatedPartSize;
exports.getPeer = getPeer;
exports.sanitizeParseMode = sanitizeParseMode;
exports.getPeerId = getPeerId;
exports.resolveId = resolveId;
exports.getMessageId = getMessageId;
exports.parsePhone = parsePhone;
exports.parseID = parseID;
exports.resolveInviteLink = resolveInviteLink;
exports.parseUsername = parseUsername;
exports.rtrim = rtrim;
exports.getDisplayName = getDisplayName;
const buffer_1 = require("buffer/");
const big_integer_1 = __importDefault(require("big-integer"));

@@ -62,3 +93,2 @@ const mime_1 = __importDefault(require("mime"));

}
exports.getFileInfo = getFileInfo;
/**

@@ -73,7 +103,6 @@ * Turns the given iterable into chunks of the specified size,

}
exports.chunks = chunks;
const USERNAME_RE = new RegExp("@|(?:https?:\\/\\/)?(?:www\\.)?" +
"(?:telegram\\.(?:me|dog)|t\\.me)\\/(@|joinchat\\/)?", "i");
const JPEG_HEADER = Buffer.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00", "hex");
const JPEG_FOOTER = Buffer.from("ffd9", "hex");
const JPEG_HEADER = buffer_1.Buffer.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00", "hex");
const JPEG_FOOTER = buffer_1.Buffer.from("ffd9", "hex");
const TG_JOIN_RE = new RegExp("tg:\\/\\/(join)\\?invite=", "i");

@@ -190,3 +219,2 @@ const VALID_USERNAME_RE = new RegExp("^([a-z]((?!__)[\\w\\d]){3,30}[a-z\\d]|gif|vid|" +

}
exports.getInputPeer = getInputPeer;
function _photoSizeByteCount(size) {

@@ -215,3 +243,2 @@ if (size instanceof tl_1.Api.PhotoSize) {

}
exports._photoSizeByteCount = _photoSizeByteCount;
function _getEntityPair(entityId, entities, cache, getInputPeerFunction = getInputPeer) {

@@ -231,3 +258,2 @@ const entity = entities.get(entityId);

}
exports._getEntityPair = _getEntityPair;
function getInnerText(text, entities) {

@@ -242,3 +268,2 @@ const result = [];

}
exports.getInnerText = getInnerText;
/**

@@ -285,3 +310,2 @@ Similar to :meth:`get_input_peer`, but for :tl:`InputChannel`'s alone.

}
exports.getInputChannel = getInputChannel;
/**

@@ -348,3 +372,2 @@ Similar to :meth:`getInputPeer`, but for :tl:`InputUser`'s alone.

}
exports.getInputUser = getInputUser;
/**

@@ -396,3 +419,2 @@ Similar to :meth:`get_input_peer`, but for dialogs

}
exports.getInputMessage = getInputMessage;
/**

@@ -426,3 +448,2 @@ * Similar to :meth:`get_input_peer`, but for input messages.

}
exports.getInputChatPhoto = getInputChatPhoto;
/**

@@ -440,8 +461,7 @@ * Adds the JPG header and footer to a stripped image.

}
const header = Buffer.from(JPEG_HEADER);
const header = buffer_1.Buffer.from(JPEG_HEADER);
header[164] = stripped[1];
header[166] = stripped[2];
return Buffer.concat([header, stripped.slice(3), JPEG_FOOTER]);
return buffer_1.Buffer.concat([header, stripped.slice(3), JPEG_FOOTER]);
}
exports.strippedPhotoToJpg = strippedPhotoToJpg;
/*CONTEST

@@ -553,3 +573,2 @@ function getInputLocation(location) {

}
exports.getInputPhoto = getInputPhoto;
/**

@@ -583,3 +602,2 @@ * Similar to :meth:`get_input_peer`, but for documents

}
exports.getInputDocument = getInputDocument;
/**

@@ -599,3 +617,2 @@ * Returns `True` if the file has an audio mime type.

}
exports.isAudio = isAudio;
/**

@@ -608,3 +625,2 @@ * Returns `True` if the file has an image mime type.

}
exports.isImage = isImage;
function getExtension(media) {

@@ -637,3 +653,2 @@ // Photos are always compressed as .jpg by Telegram

}
exports.getExtension = getExtension;
/**

@@ -753,3 +768,2 @@ * Gets the extension for the given file, which can be either a

}
exports.getAttributes = getAttributes;
/**

@@ -780,3 +794,2 @@ * Similar to :meth:`get_input_peer`, but for geo points

}
exports.getInputGeo = getInputGeo;
/**

@@ -932,3 +945,2 @@ *

}
exports.getInputMedia = getInputMedia;
/**

@@ -951,3 +963,2 @@ * Gets the appropriated part size when uploading or downloading files,

}
exports.getAppropriatedPartSize = getAppropriatedPartSize;
function getPeer(peer) {

@@ -1014,3 +1025,2 @@ if (!peer) {

}
exports.getPeer = getPeer;
function sanitizeParseMode(mode) {

@@ -1033,3 +1043,2 @@ if (mode === "md" || mode === "markdown") {

}
exports.sanitizeParseMode = sanitizeParseMode;
/**

@@ -1092,3 +1101,2 @@ Convert the given peer into its marked ID by default.

}
exports.getPeerId = getPeerId;
/**

@@ -1112,3 +1120,2 @@ * Given a marked ID, returns the original ID and its :tl:`Peer` type.

}
exports.resolveId = resolveId;
/**

@@ -1156,3 +1163,2 @@ * returns an entity pair

}
exports.getMessageId = getMessageId;
/**

@@ -1168,3 +1174,2 @@ * Parses the given phone, or returns `undefined` if it's invalid.

}
exports.parsePhone = parsePhone;
/**

@@ -1178,7 +1183,5 @@ * Parses a string ID into a big int

}
exports.parseID = parseID;
function resolveInviteLink(link) {
throw new Error("not implemented");
}
exports.resolveInviteLink = resolveInviteLink;
/**

@@ -1222,3 +1225,2 @@ Parses the given username or channel access hash, given

}
exports.parseUsername = parseUsername;
function rtrim(s, mask) {

@@ -1230,3 +1232,2 @@ while (~mask.indexOf(s[s.length - 1])) {

}
exports.rtrim = rtrim;
/**

@@ -1257,3 +1258,2 @@ * Gets the display name for the given :tl:`User`,

}
exports.getDisplayName = getDisplayName;
/**

@@ -1260,0 +1260,0 @@ * check if a given item is an array like or not

export declare const version = "2.26.7";

@@ -0,0 +0,0 @@ "use strict";

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc