Comparing version 2.26.1 to 2.26.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateTwoFaSettings = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const Helpers_1 = require("../Helpers"); | ||
@@ -55,3 +54,3 @@ const Password_1 = require("../Password"); | ||
if (!(pwd.newAlgo instanceof tl_1.Api.PasswordKdfAlgoUnknown)) { | ||
pwd.newAlgo.salt1 = buffer_1.Buffer.concat([ | ||
pwd.newAlgo.salt1 = Buffer.concat([ | ||
pwd.newAlgo.salt1, | ||
@@ -81,3 +80,3 @@ (0, Helpers_1.generateRandomBytes)(32), | ||
? await (0, Password_1.computeDigest)(pwd.newAlgo, newPassword) | ||
: buffer_1.Buffer.alloc(0), | ||
: Buffer.alloc(0), | ||
hint, | ||
@@ -84,0 +83,0 @@ email, |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Api } from "../tl"; | ||
@@ -3,0 +3,0 @@ import type { TelegramClient } from "./TelegramClient"; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type { TelegramClient } from "./TelegramClient"; | ||
@@ -6,2 +7,3 @@ import type { EntityLike } from "../define"; | ||
import { Api } from "../tl"; | ||
import { inspect } from "../inspect"; | ||
interface ParticipantsIterInterface { | ||
@@ -17,2 +19,5 @@ entity: EntityLike; | ||
private requests?; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
_init({ entity, filter, offset, search, showTotal, }: ParticipantsIterInterface): Promise<boolean | void>; | ||
@@ -19,0 +24,0 @@ _loadNextChunk(): Promise<boolean | undefined>; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Api } from "../tl"; | ||
@@ -3,0 +3,0 @@ import type { TelegramClient } from "./TelegramClient"; |
@@ -37,3 +37,2 @@ "use strict"; | ||
exports.downloadProfilePhoto = exports._downloadPhoto = exports._downloadCachedPhotoSize = exports._downloadWebDocument = exports._downloadContact = exports._downloadDocument = exports.downloadMedia = exports.downloadFileV2 = exports.iterDownload = exports.GenericDownloadIter = exports.DirectDownloadIter = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const tl_1 = require("../tl"); | ||
@@ -138,3 +137,3 @@ const Utils_1 = require("../Utils"); | ||
// 1. Fetch enough for one chunk | ||
let data = buffer_1.Buffer.alloc(0); | ||
let data = Buffer.alloc(0); | ||
// 1.1. ``bad`` is how much into the data we have we need to offset | ||
@@ -149,3 +148,3 @@ const bad = this.request.offset.mod(this.request.limit).toJSNumber(); | ||
this.request.offset = this.request.offset.add(this.request.limit); | ||
data = buffer_1.Buffer.concat([data, current]); | ||
data = Buffer.concat([data, current]); | ||
done = current.length < this.request.limit; | ||
@@ -236,4 +235,4 @@ } | ||
function getWriter(outputFile) { | ||
if (!outputFile || buffer_1.Buffer.isBuffer(outputFile)) { | ||
return new extensions_1.BinaryWriter(buffer_1.Buffer.alloc(0)); | ||
if (!outputFile || Buffer.isBuffer(outputFile)) { | ||
return new extensions_1.BinaryWriter(Buffer.alloc(0)); | ||
} | ||
@@ -262,3 +261,3 @@ else if (typeof outputFile == "string") { | ||
else { | ||
return buffer_1.Buffer.from(writer.path); | ||
return Buffer.from(writer.path); | ||
} | ||
@@ -388,3 +387,3 @@ } | ||
else { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -397,3 +396,3 @@ } | ||
if (!doc.document) { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -403,3 +402,3 @@ doc = doc.document; | ||
if (!(doc instanceof tl_1.Api.Document)) { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -537,3 +536,3 @@ let size; | ||
if (photo.photo instanceof tl_1.Api.PhotoEmpty || !photo.photo) { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -543,3 +542,3 @@ photo = photo.photo; | ||
if (!(photo instanceof tl_1.Api.Photo)) { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -549,3 +548,3 @@ const photoSizes = [...(photo.sizes || []), ...(photo.videoSizes || [])]; | ||
if (!size || size instanceof tl_1.Api.PhotoSizeEmpty) { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -607,3 +606,3 @@ if (!date) { | ||
else { | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -610,0 +609,0 @@ return client.downloadFile(loc, { |
@@ -1,10 +0,1 @@ | ||
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; | ||
export * from "fs"; |
"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) => { }, | ||
}; | ||
exports.createWriteStream = {}; | ||
exports.WriteStream = {}; | ||
exports.lstatSync = {}; | ||
exports.existsSync = {}; | ||
__exportStar(require("fs"), exports); |
@@ -1,5 +0,2 @@ | ||
declare const _default: { | ||
type: () => string; | ||
release: () => string; | ||
}; | ||
export default _default; | ||
import * as os from "os"; | ||
export default os; |
"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"; | ||
}, | ||
}; | ||
const os = __importStar(require("os")); | ||
exports.default = os; |
@@ -1,7 +0,2 @@ | ||
declare const _default: { | ||
basename(...args: any): any; | ||
resolve(...args: any): any; | ||
path(...args: any): any; | ||
join(...args: any): any; | ||
}; | ||
export default _default; | ||
import path from "path"; | ||
export default path; |
"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) { }, | ||
}; | ||
const path_1 = __importDefault(require("path")); | ||
exports.default = path_1.default; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { TelegramBaseClient, TelegramClientParams } from "./telegramBaseClient"; | ||
@@ -22,2 +22,3 @@ import * as authMethods from "./auth"; | ||
import { DeletedMessage, DeletedMessageEvent } from "../events/DeletedMessage"; | ||
import { inspect } from "../inspect"; | ||
/** | ||
@@ -1034,2 +1035,6 @@ * The TelegramClient uses several methods in different files to provide all the common functionality in a nice interface.</br> | ||
_getResponseMessage(req: any, result: any, inputChat: any): Api.TypeMessage | Map<number, Api.Message> | (Api.Message | undefined)[] | undefined; | ||
/** @hidden */ | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
/** | ||
@@ -1036,0 +1041,0 @@ * Small hack for using it in browsers |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Api } from "../tl"; | ||
@@ -3,0 +3,0 @@ import { TelegramClient } from "./TelegramClient"; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.sendFile = exports._sendAlbum = exports._fileToMedia = exports.uploadFile = exports.CustomFile = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const tl_1 = require("../tl"); | ||
@@ -45,9 +44,9 @@ const Helpers_1 = require("../Helpers"); | ||
const buffSize = end - begin; | ||
const buff = buffer_1.Buffer.alloc(buffSize); | ||
const buff = Buffer.alloc(buffSize); | ||
const fHandle = await fs_1.promises.open(filePath, "r"); | ||
await fHandle.read(buff, 0, buffSize, begin); | ||
await fHandle.close(); | ||
return buffer_1.Buffer.from(buff); | ||
return Buffer.from(buff); | ||
} | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -67,3 +66,3 @@ } | ||
else { | ||
options.buffer = buffer_1.Buffer.from(await fileToBuffer(file)); | ||
options.buffer = Buffer.from(await fileToBuffer(file)); | ||
} | ||
@@ -177,3 +176,3 @@ return new CustomBuffer(options); | ||
if (typeof file == "object" && | ||
!buffer_1.Buffer.isBuffer(file) && | ||
!Buffer.isBuffer(file) && | ||
!(file instanceof tl_1.Api.InputFile) && | ||
@@ -237,3 +236,3 @@ !(file instanceof tl_1.Api.InputFileBig) && | ||
} | ||
if (buffer_1.Buffer.isBuffer(file)) { | ||
if (Buffer.isBuffer(file)) { | ||
createdFile = new CustomFile(name, file.length, "", file); | ||
@@ -297,3 +296,3 @@ } | ||
} | ||
if (buffer_1.Buffer.isBuffer(thumb)) { | ||
if (Buffer.isBuffer(thumb)) { | ||
uploadedThumb = new CustomFile(name, thumb.length, "", thumb); | ||
@@ -300,0 +299,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -57,7 +56,7 @@ const extensions_1 = require("../extensions"); | ||
const nonce = (0, Helpers_1.toSignedLittleBuffer)(newNonce, 32); | ||
const n = buffer_1.Buffer.alloc(1); | ||
const n = Buffer.alloc(1); | ||
n.writeUInt8(number, 0); | ||
const data = buffer_1.Buffer.concat([ | ||
const data = Buffer.concat([ | ||
nonce, | ||
buffer_1.Buffer.concat([n, (0, Helpers_1.readBufferFromBigInt)(this.auxHash, 8, true)]), | ||
Buffer.concat([n, (0, Helpers_1.readBufferFromBigInt)(this.auxHash, 8, true)]), | ||
]); | ||
@@ -74,3 +73,3 @@ // Calculates the message key from the given data | ||
this._key && | ||
buffer_1.Buffer.isBuffer(other.getKey()) && | ||
Buffer.isBuffer(other.getKey()) && | ||
((_a = other.getKey()) === null || _a === void 0 ? void 0 : _a.equals(this._key))); | ||
@@ -77,0 +76,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
export declare class Counter { | ||
@@ -3,0 +3,0 @@ _counter: Buffer; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.createHash = exports.pbkdf2Sync = exports.Hash = exports.randomBytes = exports.createCipheriv = exports.createDecipheriv = exports.CTR = exports.Counter = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const aes_1 = __importDefault(require("@cryptography/aes")); | ||
@@ -14,3 +13,3 @@ const converters_1 = require("./converters"); | ||
constructor(initialValue) { | ||
this._counter = buffer_1.Buffer.from(initialValue); | ||
this._counter = Buffer.from(initialValue); | ||
} | ||
@@ -44,6 +43,6 @@ increment() { | ||
encrypt(plainText) { | ||
const encrypted = buffer_1.Buffer.from(plainText); | ||
const encrypted = Buffer.from(plainText); | ||
for (let i = 0; i < encrypted.length; i++) { | ||
if (this._remainingCounterIndex === 16) { | ||
this._remainingCounter = buffer_1.Buffer.from((0, converters_1.i2ab)(this._aes.encrypt((0, converters_1.ab2i)(this._counter._counter)))); | ||
this._remainingCounter = Buffer.from((0, converters_1.i2ab)(this._aes.encrypt((0, converters_1.ab2i)(this._counter._counter)))); | ||
this._remainingCounterIndex = 0; | ||
@@ -98,9 +97,9 @@ this._counter.increment(); | ||
if (this.algorithm === "sha1") { | ||
return buffer_1.Buffer.from(await self.crypto.subtle.digest("SHA-1", this.data)); | ||
return Buffer.from(await self.crypto.subtle.digest("SHA-1", this.data)); | ||
} | ||
else if (this.algorithm === "sha256") { | ||
return buffer_1.Buffer.from(await self.crypto.subtle.digest("SHA-256", this.data)); | ||
return Buffer.from(await self.crypto.subtle.digest("SHA-256", this.data)); | ||
} | ||
} | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -111,3 +110,3 @@ } | ||
const passwordKey = await crypto.subtle.importKey("raw", password, { name: "PBKDF2" }, false, ["deriveBits"]); | ||
return buffer_1.Buffer.from(await crypto.subtle.deriveBits({ | ||
return Buffer.from(await crypto.subtle.deriveBits({ | ||
name: "PBKDF2", | ||
@@ -114,0 +113,0 @@ hash: "SHA-512", |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
export declare class CTR { | ||
@@ -3,0 +3,0 @@ private cipher; |
@@ -27,7 +27,6 @@ "use strict"; | ||
exports.CTR = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const crypto = __importStar(require("./crypto")); | ||
class CTR { | ||
constructor(key, iv) { | ||
if (!buffer_1.Buffer.isBuffer(key) || !buffer_1.Buffer.isBuffer(iv) || iv.length !== 16) { | ||
if (!Buffer.isBuffer(key) || !Buffer.isBuffer(iv) || iv.length !== 16) { | ||
throw new Error("Key and iv need to be a buffer"); | ||
@@ -38,5 +37,5 @@ } | ||
encrypt(data) { | ||
return buffer_1.Buffer.from(this.cipher.update(data)); | ||
return Buffer.from(this.cipher.update(data)); | ||
} | ||
} | ||
exports.CTR = CTR; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -27,3 +26,3 @@ const { IGE: aes_ige } = require("@cryptography/aes"); | ||
if (padding) { | ||
plainText = buffer_1.Buffer.concat([ | ||
plainText = Buffer.concat([ | ||
plainText, | ||
@@ -30,0 +29,0 @@ Helpers.generateRandomBytes(16 - padding), |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import bigInt from "big-integer"; | ||
@@ -3,0 +3,0 @@ export declare const _serverKeys: Map<string, { |
@@ -18,3 +18,2 @@ "use strict"; | ||
exports.encrypt = exports._serverKeys = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const big_integer_1 = __importDefault(require("big-integer")); | ||
@@ -64,3 +63,3 @@ const Helpers_1 = require("../Helpers"); | ||
const rand = (0, Helpers_1.generateRandomBytes)(235 - data.length); | ||
const toEncrypt = buffer_1.Buffer.concat([await (0, Helpers_1.sha1)(data), data, rand]); | ||
const toEncrypt = Buffer.concat([await (0, Helpers_1.sha1)(data), data, rand]); | ||
// rsa module rsa.encrypt adds 11 bits for padding which we don't want | ||
@@ -67,0 +66,0 @@ // rsa module uses rsa.transform.bytes2int(to_encrypt), easier way: |
@@ -1,2 +0,2 @@ | ||
import * as crypto from "./crypto/crypto"; | ||
import * as crypto from "crypto"; | ||
export default crypto; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const crypto = __importStar(require("./crypto/crypto")); | ||
const crypto = __importStar(require("crypto")); | ||
exports.default = crypto; |
@@ -1,5 +0,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 }); | ||
@@ -3,0 +6,0 @@ exports.BadMessageError = exports.CdnFileTamperedError = exports.SecurityError = exports.InvalidBufferError = exports.InvalidChecksumError = exports.TypeNotFoundError = exports.ReadCancelledError = void 0; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { EntityLike } from "../define"; | ||
@@ -3,0 +3,0 @@ import { EventBuilder, EventCommonSender } from "./common"; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
export declare class BinaryReader { | ||
@@ -3,0 +3,0 @@ private readonly stream; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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 { | ||
@@ -13,5 +12,5 @@ constructor(stream) { | ||
getValue() { | ||
return buffer_1.Buffer.concat(this._buffers); | ||
return Buffer.concat(this._buffers); | ||
} | ||
} | ||
exports.BinaryWriter = BinaryWriter; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -105,3 +104,3 @@ const core_2 = require("../tl/core"); | ||
let data; | ||
let buffer = new BinaryWriter_1.BinaryWriter(buffer_1.Buffer.alloc(0)); | ||
let buffer = new BinaryWriter_1.BinaryWriter(Buffer.alloc(0)); | ||
const batch = []; | ||
@@ -142,7 +141,7 @@ let size = 0; | ||
if (batch.length > 1) { | ||
const b = buffer_1.Buffer.alloc(8); | ||
const b = Buffer.alloc(8); | ||
b.writeUInt32LE(core_1.MessageContainer.CONSTRUCTOR_ID, 0); | ||
b.writeInt32LE(batch.length, 4); | ||
data = buffer_1.Buffer.concat([b, buffer.getValue()]); | ||
buffer = new BinaryWriter_1.BinaryWriter(buffer_1.Buffer.alloc(0)); | ||
data = Buffer.concat([b, buffer.getValue()]); | ||
buffer = new BinaryWriter_1.BinaryWriter(Buffer.alloc(0)); | ||
const containerId = await this._state.writeDataAsMessage(buffer, data, false); | ||
@@ -149,0 +148,0 @@ for (const s of batch) { |
@@ -1,8 +0,1 @@ | ||
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; | ||
} | ||
export * from "net"; |
"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.Socket = void 0; | ||
class Socket { | ||
connect(...args) { } | ||
on(...args) { } | ||
write(...args) { } | ||
destroy(...args) { } | ||
unref(...args) { } | ||
} | ||
exports.Socket = Socket; | ||
__exportStar(require("net"), exports); |
@@ -0,8 +1,25 @@ | ||
/// <reference types="node" /> | ||
import { ProxyInterface } from "../network/connection/TCPMTProxy"; | ||
export declare class PromisedNetSockets { | ||
constructor(...args: any); | ||
connect(...args: any): any; | ||
close(...args: any): any; | ||
write(...args: any): any; | ||
readExactly(...args: any): any; | ||
read(...args: any): any; | ||
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; | ||
} |
"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(...args) { } | ||
connect(...args) { } | ||
close(...args) { } | ||
write(...args) { } | ||
readExactly(...args) { } | ||
read(...args) { } | ||
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"; | ||
} | ||
} | ||
exports.PromisedNetSockets = PromisedNetSockets; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -13,10 +12,10 @@ const async_mutex_1 = require("async-mutex"); | ||
this.client = undefined; | ||
this.stream = buffer_1.Buffer.alloc(0); | ||
this.stream = Buffer.alloc(0); | ||
this.closed = true; | ||
} | ||
async readExactly(number) { | ||
let readData = buffer_1.Buffer.alloc(0); | ||
let readData = Buffer.alloc(0); | ||
while (true) { | ||
const thisTime = await this.read(number); | ||
readData = buffer_1.Buffer.concat([readData, thisTime]); | ||
readData = Buffer.concat([readData, thisTime]); | ||
number = number - thisTime.length; | ||
@@ -50,3 +49,3 @@ if (!number) { | ||
const toReturn = this.stream; | ||
this.stream = buffer_1.Buffer.alloc(0); | ||
this.stream = Buffer.alloc(0); | ||
this.canRead = new Promise((resolve) => { | ||
@@ -66,3 +65,3 @@ this.resolveRead = resolve; | ||
async connect(port, ip, testServers = false) { | ||
this.stream = buffer_1.Buffer.alloc(0); | ||
this.stream = Buffer.alloc(0); | ||
this.canRead = new Promise((resolve) => { | ||
@@ -122,4 +121,4 @@ this.resolveRead = resolve; | ||
//CONTEST BROWSER | ||
data = buffer_1.Buffer.from(await new Response(message.data).arrayBuffer()); | ||
this.stream = buffer_1.Buffer.concat([this.stream, data]); | ||
data = Buffer.from(await new Response(message.data).arrayBuffer()); | ||
this.stream = Buffer.concat([this.stream, data]); | ||
if (this.resolveRead) { | ||
@@ -126,0 +125,0 @@ this.resolveRead(true); |
@@ -1,3 +0,1 @@ | ||
export declare const SocksClient: { | ||
createConnection: (x: any) => any; | ||
}; | ||
export * from "socks"; |
"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) => { }, | ||
}; | ||
__exportStar(require("socks"), exports); |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import bigInt from "big-integer"; | ||
@@ -3,0 +3,0 @@ import type { EntityLike } from "./define"; |
@@ -7,3 +7,2 @@ "use strict"; | ||
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; | ||
const buffer_1 = require("buffer/"); | ||
const big_integer_1 = __importDefault(require("big-integer")); | ||
@@ -20,3 +19,3 @@ const CryptoFile_1 = __importDefault(require("./CryptoFile")); | ||
function readBigIntFromBuffer(buffer, little = true, signed = false) { | ||
let randBuffer = buffer_1.Buffer.from(buffer); | ||
let randBuffer = Buffer.from(buffer); | ||
const bytesNumber = randBuffer.length; | ||
@@ -110,3 +109,3 @@ if (little) { | ||
// smh hacks | ||
return buffer_1.Buffer.from(byteArray); | ||
return Buffer.from(byteArray); | ||
} | ||
@@ -138,3 +137,3 @@ exports.toSignedLittleBuffer = toSignedLittleBuffer; | ||
const hex = bigIntVar.toString(16).padStart(bytesNumber * 2, "0"); | ||
let buffer = buffer_1.Buffer.from(hex, "hex"); | ||
let buffer = Buffer.from(hex, "hex"); | ||
if (little) { | ||
@@ -180,3 +179,3 @@ buffer = buffer.reverse(); | ||
function generateRandomBytes(count) { | ||
return buffer_1.Buffer.from(CryptoFile_1.default.randomBytes(count)); | ||
return Buffer.from(CryptoFile_1.default.randomBytes(count)); | ||
} | ||
@@ -261,8 +260,8 @@ exports.generateRandomBytes = generateRandomBytes; | ||
const [hash1, hash2, hash3] = await Promise.all([ | ||
sha1(buffer_1.Buffer.concat([newNonce, serverNonce])), | ||
sha1(buffer_1.Buffer.concat([serverNonce, newNonce])), | ||
sha1(buffer_1.Buffer.concat([newNonce, newNonce])), | ||
sha1(Buffer.concat([newNonce, serverNonce])), | ||
sha1(Buffer.concat([serverNonce, newNonce])), | ||
sha1(Buffer.concat([newNonce, newNonce])), | ||
]); | ||
const keyBuffer = buffer_1.Buffer.concat([hash1, hash2.slice(0, 12)]); | ||
const ivBuffer = buffer_1.Buffer.concat([ | ||
const keyBuffer = Buffer.concat([hash1, hash2.slice(0, 12)]); | ||
const ivBuffer = Buffer.concat([ | ||
hash2.slice(12, 20), | ||
@@ -279,3 +278,3 @@ hash3, | ||
function convertToLittle(buf) { | ||
const correct = buffer_1.Buffer.alloc(buf.length * 4); | ||
const correct = Buffer.alloc(buf.length * 4); | ||
for (let i = 0; i < buf.length; i++) { | ||
@@ -411,3 +410,3 @@ correct.writeUInt32BE(buf[i], i * 4); | ||
} | ||
return buffer_1.Buffer.from(res); | ||
return Buffer.from(res); | ||
} | ||
@@ -433,4 +432,4 @@ exports.bufferXor = bufferXor; | ||
} | ||
if (!buffer_1.Buffer.isBuffer(buf)) { | ||
buf = buffer_1.Buffer.from(buf); | ||
if (!Buffer.isBuffer(buf)) { | ||
buf = Buffer.from(buf); | ||
} | ||
@@ -437,0 +436,0 @@ let crc = -1; |
@@ -1,3 +0,1 @@ | ||
export declare const inspect: { | ||
custom: string; | ||
}; | ||
export { inspect } from "util"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.inspect = void 0; | ||
exports.inspect = { | ||
custom: "", | ||
}; | ||
var util_1 = require("util"); | ||
Object.defineProperty(exports, "inspect", { enumerable: true, get: function () { return util_1.inspect; } }); |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.doAuthentication = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const Helpers_1 = require("../Helpers"); | ||
@@ -64,16 +63,16 @@ const tl_1 = require("../tl"); | ||
const padding = (0, Helpers_1.generateRandomBytes)(192 - pqInnerData.length); | ||
const dataWithPadding = buffer_1.Buffer.concat([pqInnerData, padding]); | ||
const dataPadReversed = buffer_1.Buffer.from(dataWithPadding).reverse(); | ||
const dataWithPadding = Buffer.concat([pqInnerData, padding]); | ||
const dataPadReversed = 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_1.Buffer.concat([tempKey, dataWithPadding])); | ||
const dataWithHash = buffer_1.Buffer.concat([ | ||
const shaDigestKeyWithData = await (0, Helpers_1.sha256)(Buffer.concat([tempKey, dataWithPadding])); | ||
const dataWithHash = Buffer.concat([ | ||
dataPadReversed, | ||
shaDigestKeyWithData, | ||
]); | ||
const ige = new IGE_1.IGE(tempKey, buffer_1.Buffer.alloc(32)); | ||
const ige = new IGE_1.IGE(tempKey, Buffer.alloc(32)); | ||
const aesEncrypted = ige.encryptIge(dataWithHash); | ||
const tempKeyXor = (0, Helpers_1.bufferXor)(tempKey, await (0, Helpers_1.sha256)(aesEncrypted)); | ||
const keyAesEncrypted = buffer_1.Buffer.concat([tempKeyXor, aesEncrypted]); | ||
const keyAesEncrypted = Buffer.concat([tempKeyXor, aesEncrypted]); | ||
const keyAesEncryptedInt = (0, Helpers_1.readBigIntFromBuffer)(keyAesEncrypted, false, false); | ||
@@ -155,3 +154,3 @@ if (keyAesEncryptedInt.greaterOrEquals(targetKey.n)) { | ||
}).getBytes(); | ||
const clientDdhInnerHashed = buffer_1.Buffer.concat([ | ||
const clientDdhInnerHashed = Buffer.concat([ | ||
await (0, Helpers_1.sha1)(clientDhInner), | ||
@@ -158,0 +157,0 @@ clientDhInner, |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Logger, PromisedNetSockets, PromisedWebSockets } from "../../extensions"; | ||
@@ -3,0 +3,0 @@ import { AsyncQueue } from "../../extensions"; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Connection, PacketCodec } from "./Connection"; | ||
@@ -3,0 +3,0 @@ import type { PromisedNetSockets, PromisedWebSockets } from "../../extensions"; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.ConnectionTCPAbridged = exports.AbridgedPacketCodec = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const Helpers_1 = require("../../Helpers"); | ||
@@ -22,3 +21,3 @@ const Connection_1 = require("./Connection"); | ||
if (length < 127) { | ||
const b = buffer_1.Buffer.alloc(1); | ||
const b = Buffer.alloc(1); | ||
b.writeUInt8(length, 0); | ||
@@ -28,8 +27,8 @@ temp = b; | ||
else { | ||
temp = buffer_1.Buffer.concat([ | ||
buffer_1.Buffer.from("7f", "hex"), | ||
temp = Buffer.concat([ | ||
Buffer.from("7f", "hex"), | ||
(0, Helpers_1.readBufferFromBigInt)((0, big_integer_1.default)(length), 3), | ||
]); | ||
} | ||
return buffer_1.Buffer.concat([temp, data]); | ||
return Buffer.concat([temp, data]); | ||
} | ||
@@ -40,5 +39,5 @@ async readPacket(reader) { | ||
if (length >= 127) { | ||
length = buffer_1.Buffer.concat([ | ||
length = Buffer.concat([ | ||
await reader.read(3), | ||
buffer_1.Buffer.alloc(1), | ||
Buffer.alloc(1), | ||
]).readInt32LE(0); | ||
@@ -50,4 +49,4 @@ } | ||
exports.AbridgedPacketCodec = AbridgedPacketCodec; | ||
AbridgedPacketCodec.tag = buffer_1.Buffer.from("ef", "hex"); | ||
AbridgedPacketCodec.obfuscateTag = buffer_1.Buffer.from("efefefef", "hex"); | ||
AbridgedPacketCodec.tag = Buffer.from("ef", "hex"); | ||
AbridgedPacketCodec.obfuscateTag = Buffer.from("efefefef", "hex"); | ||
/** | ||
@@ -54,0 +53,0 @@ * This is the mode with the lowest overhead, as it will |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -17,10 +16,10 @@ const Helpers_1 = require("../../Helpers"); | ||
const length = data.length + 12; | ||
const e = buffer_1.Buffer.alloc(8); | ||
const e = Buffer.alloc(8); | ||
e.writeInt32LE(length, 0); | ||
e.writeInt32LE(this._sendCounter, 4); | ||
data = buffer_1.Buffer.concat([e, data]); | ||
const crc = buffer_1.Buffer.alloc(4); | ||
data = Buffer.concat([e, data]); | ||
const crc = Buffer.alloc(4); | ||
crc.writeUInt32LE((0, Helpers_1.crc32)(data), 0); | ||
this._sendCounter += 1; | ||
return buffer_1.Buffer.concat([data, crc]); | ||
return Buffer.concat([data, crc]); | ||
} | ||
@@ -36,3 +35,3 @@ /** | ||
// Return empty buffer in case of issue | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
} | ||
@@ -50,3 +49,3 @@ const packetLen = packetLenSeq.readInt32LE(0); | ||
body = body.slice(0, -4); | ||
const validChecksum = (0, Helpers_1.crc32)(buffer_1.Buffer.concat([packetLenSeq, body])); | ||
const validChecksum = (0, Helpers_1.crc32)(Buffer.concat([packetLenSeq, body])); | ||
if (!(validChecksum === checksum)) { | ||
@@ -53,0 +52,0 @@ throw new errors_1.InvalidChecksumError(checksum, validChecksum); |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { ObfuscatedConnection } from "./Connection"; | ||
@@ -3,0 +3,0 @@ import { AbridgedPacketCodec } from "./TCPAbridged"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConnectionTCPMTProxyAbridged = exports.TCPMTProxy = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const Connection_1 = require("./Connection"); | ||
@@ -26,6 +25,6 @@ const TCPAbridged_1 = require("./TCPAbridged"); | ||
const keywords = [ | ||
buffer_1.Buffer.from("50567247", "hex"), | ||
buffer_1.Buffer.from("474554", "hex"), | ||
buffer_1.Buffer.from("504f5354", "hex"), | ||
buffer_1.Buffer.from("eeeeeeee", "hex"), | ||
Buffer.from("50567247", "hex"), | ||
Buffer.from("474554", "hex"), | ||
Buffer.from("504f5354", "hex"), | ||
Buffer.from("eeeeeeee", "hex"), | ||
]; | ||
@@ -37,3 +36,3 @@ let random; | ||
if (random[0] !== 0xef && | ||
!random.slice(4, 8).equals(buffer_1.Buffer.alloc(4))) { | ||
!random.slice(4, 8).equals(Buffer.alloc(4))) { | ||
let ok = true; | ||
@@ -52,26 +51,26 @@ for (const key of keywords) { | ||
random = random.toJSON().data; | ||
const randomReversed = buffer_1.Buffer.from(random.slice(8, 56)).reverse(); | ||
const randomReversed = Buffer.from(random.slice(8, 56)).reverse(); | ||
// Encryption has "continuous buffer" enabled | ||
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 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 encryptor = new CTR_1.CTR(encryptKey, encryptIv); | ||
const decryptor = new CTR_1.CTR(decryptKey, decryptIv); | ||
random = buffer_1.Buffer.concat([ | ||
buffer_1.Buffer.from(random.slice(0, 56)), | ||
random = Buffer.concat([ | ||
Buffer.from(random.slice(0, 56)), | ||
this._packetClass.obfuscateTag, | ||
buffer_1.Buffer.from(random.slice(60)), | ||
Buffer.from(random.slice(60)), | ||
]); | ||
const dcIdBytes = buffer_1.Buffer.alloc(2); | ||
const dcIdBytes = Buffer.alloc(2); | ||
dcIdBytes.writeInt8(this._dcId, 0); | ||
random = buffer_1.Buffer.concat([ | ||
buffer_1.Buffer.from(random.slice(0, 60)), | ||
random = Buffer.concat([ | ||
Buffer.from(random.slice(0, 60)), | ||
dcIdBytes, | ||
buffer_1.Buffer.from(random.slice(62)), | ||
Buffer.from(random.slice(62)), | ||
]); | ||
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)), | ||
random = Buffer.concat([ | ||
Buffer.from(random.slice(0, 56)), | ||
Buffer.from(encryptor.encrypt(random).slice(56, 64)), | ||
Buffer.from(random.slice(64)), | ||
]); | ||
@@ -110,7 +109,7 @@ this.header = random; | ||
// probably hex | ||
this._secret = buffer_1.Buffer.from(proxy.secret, "hex"); | ||
this._secret = Buffer.from(proxy.secret, "hex"); | ||
} | ||
else { | ||
// probably b64 | ||
this._secret = buffer_1.Buffer.from(proxy.secret, "base64"); | ||
this._secret = Buffer.from(proxy.secret, "base64"); | ||
} | ||
@@ -117,0 +116,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -18,6 +17,6 @@ const Connection_1 = require("./Connection"); | ||
const keywords = [ | ||
buffer_1.Buffer.from("50567247", "hex"), | ||
buffer_1.Buffer.from("474554", "hex"), | ||
buffer_1.Buffer.from("504f5354", "hex"), | ||
buffer_1.Buffer.from("eeeeeeee", "hex"), | ||
Buffer.from("50567247", "hex"), | ||
Buffer.from("474554", "hex"), | ||
Buffer.from("504f5354", "hex"), | ||
Buffer.from("eeeeeeee", "hex"), | ||
]; | ||
@@ -29,3 +28,3 @@ let random; | ||
if (random[0] !== 0xef && | ||
!random.slice(4, 8).equals(buffer_1.Buffer.alloc(4))) { | ||
!random.slice(4, 8).equals(Buffer.alloc(4))) { | ||
let ok = true; | ||
@@ -44,19 +43,19 @@ for (const key of keywords) { | ||
random = random.toJSON().data; | ||
const randomReversed = buffer_1.Buffer.from(random.slice(8, 56)).reverse(); | ||
const randomReversed = Buffer.from(random.slice(8, 56)).reverse(); | ||
// Encryption has "continuous buffer" enabled | ||
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 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 encryptor = new CTR_1.CTR(encryptKey, encryptIv); | ||
const decryptor = new CTR_1.CTR(decryptKey, decryptIv); | ||
random = buffer_1.Buffer.concat([ | ||
buffer_1.Buffer.from(random.slice(0, 56)), | ||
random = Buffer.concat([ | ||
Buffer.from(random.slice(0, 56)), | ||
this._packetClass.obfuscateTag, | ||
buffer_1.Buffer.from(random.slice(60)), | ||
Buffer.from(random.slice(60)), | ||
]); | ||
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)), | ||
random = Buffer.concat([ | ||
Buffer.from(random.slice(0, 56)), | ||
Buffer.from(encryptor.encrypt(random).slice(56, 64)), | ||
Buffer.from(random.slice(64)), | ||
]); | ||
@@ -63,0 +62,0 @@ this.header = random; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.MTProtoPlainSender = void 0; | ||
const buffer_1 = require("buffer/"); | ||
/** | ||
@@ -39,6 +38,6 @@ * This module contains the class used to communicate with Telegram's servers | ||
const m = (0, Helpers_1.toSignedLittleBuffer)(msgId, 8); | ||
const b = buffer_1.Buffer.alloc(4); | ||
const b = Buffer.alloc(4); | ||
b.writeInt32LE(body.length, 0); | ||
const res = buffer_1.Buffer.concat([ | ||
buffer_1.Buffer.concat([buffer_1.Buffer.alloc(8), m, b]), | ||
const res = Buffer.concat([ | ||
Buffer.concat([Buffer.alloc(8), m, b]), | ||
body, | ||
@@ -45,0 +44,0 @@ ]); |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.MTProtoSender = void 0; | ||
const buffer_1 = require("buffer/"); | ||
/** | ||
@@ -539,3 +538,3 @@ * MTProto Mobile Protocol sender | ||
if (!(reader.tgReadObject() instanceof tl_1.Api.upload.File)) { | ||
throw new errors_1.TypeNotFoundError(0, buffer_1.Buffer.alloc(0)); | ||
throw new errors_1.TypeNotFoundError(0, Buffer.alloc(0)); | ||
} | ||
@@ -542,0 +541,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import bigInt from "big-integer"; | ||
@@ -3,0 +3,0 @@ import type { AuthKey } from "../crypto/AuthKey"; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.MTProtoState = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const big_integer_1 = __importDefault(require("big-integer")); | ||
@@ -83,6 +82,6 @@ const __1 = require("../"); | ||
const [sha256a, sha256b] = await Promise.all([ | ||
(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])), | ||
(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])), | ||
]); | ||
const key = buffer_1.Buffer.concat([ | ||
const key = Buffer.concat([ | ||
sha256a.slice(0, 8), | ||
@@ -92,3 +91,3 @@ sha256b.slice(8, 24), | ||
]); | ||
const iv = buffer_1.Buffer.concat([ | ||
const iv = Buffer.concat([ | ||
sha256b.slice(0, 8), | ||
@@ -125,8 +124,8 @@ sha256a.slice(8, 24), | ||
} | ||
const s = buffer_1.Buffer.alloc(4); | ||
const s = Buffer.alloc(4); | ||
s.writeInt32LE(seqNo, 0); | ||
const b = buffer_1.Buffer.alloc(4); | ||
const b = Buffer.alloc(4); | ||
b.writeInt32LE(body.length, 0); | ||
const m = (0, Helpers_1.toSignedLittleBuffer)(msgId, 8); | ||
buffer.write(buffer_1.Buffer.concat([m, s, b])); | ||
buffer.write(Buffer.concat([m, s, b])); | ||
buffer.write(body); | ||
@@ -154,7 +153,7 @@ return msgId; | ||
const i = (0, Helpers_1.toSignedLittleBuffer)(this.id, 8); | ||
data = buffer_1.Buffer.concat([buffer_1.Buffer.concat([s, i]), data]); | ||
data = Buffer.concat([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_1.Buffer.concat([authKey.slice(88, 88 + 32), data, padding])); | ||
const msgKeyLarge = await (0, Helpers_1.sha256)(Buffer.concat([authKey.slice(88, 88 + 32), data, padding])); | ||
// "msg_key = substr (msg_key_large, 8, 16)" | ||
@@ -164,6 +163,6 @@ const msgKey = msgKeyLarge.slice(8, 24); | ||
const keyId = __1.helpers.readBufferFromBigInt(this.authKey.keyId, 8); | ||
return buffer_1.Buffer.concat([ | ||
return Buffer.concat([ | ||
keyId, | ||
msgKey, | ||
new IGE_1.IGE(key, iv).encryptIge(buffer_1.Buffer.concat([data, padding])), | ||
new IGE_1.IGE(key, iv).encryptIge(Buffer.concat([data, padding])), | ||
]); | ||
@@ -196,3 +195,3 @@ } | ||
// Sections "checking sha256 hash" and "message length" | ||
const ourKey = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([authKey.slice(96, 96 + 32), body])); | ||
const ourKey = await (0, Helpers_1.sha256)(Buffer.concat([authKey.slice(96, 96 + 32), body])); | ||
if (!msgKey.equals(ourKey.slice(8, 24))) { | ||
@@ -199,0 +198,0 @@ throw new errors_1.SecurityError("Received msg_key doesn't match with expected one"); |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import bigInt from "big-integer"; | ||
@@ -3,0 +3,0 @@ import Deferred from "../extensions/Deferred"; |
{ | ||
"name": "telegram", | ||
"version": "2.26.1", | ||
"version": "2.26.2", | ||
"description": "NodeJS/Browser MTProto API Telegram client library,", | ||
@@ -69,4 +69,6 @@ "main": "index.js", | ||
"ts-custom-error": "^3.2.0", | ||
"websocket": "^1.0.34" | ||
"websocket": "^1.0.34", | ||
"node-localstorage": "^2.2.1", | ||
"socks": "^2.6.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Api } from "./tl"; | ||
@@ -3,0 +3,0 @@ /** |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.computeDigest = exports.computeCheck = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const tl_1 = require("./tl"); | ||
@@ -71,3 +70,3 @@ const Helpers_1 = require("./Helpers"); | ||
function checkPrimeAndGood(primeBytes, g) { | ||
const goodPrime = buffer_1.Buffer.from([ | ||
const goodPrime = Buffer.from([ | ||
0xc7, 0x1c, 0xae, 0xb9, 0xc6, 0xb1, 0xc9, 0x04, 0x8e, 0x6c, 0x52, 0x2f, | ||
@@ -119,3 +118,3 @@ 0x70, 0xf1, 0x3f, 0x73, 0x98, 0x0d, 0x40, 0x23, 0x8e, 0x3e, 0x21, 0xc1, | ||
function numBytesForHash(number) { | ||
return buffer_1.Buffer.concat([buffer_1.Buffer.alloc(SIZE_FOR_HASH - number.length), number]); | ||
return Buffer.concat([Buffer.alloc(SIZE_FOR_HASH - number.length), number]); | ||
} | ||
@@ -169,6 +168,6 @@ /** | ||
async function computeHash(algo, password) { | ||
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 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 hash3 = await pbkdf2sha512(hash2, algo.salt1, 100000); | ||
return (0, Helpers_1.sha256)(buffer_1.Buffer.concat([algo.salt2, hash3, algo.salt2])); | ||
return (0, Helpers_1.sha256)(Buffer.concat([algo.salt2, hash3, algo.salt2])); | ||
} | ||
@@ -225,3 +224,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_1.Buffer.concat([pForHash, gForHash])), false); | ||
const k = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(Buffer.concat([pForHash, gForHash])), false); | ||
const kgX = (0, Helpers_1.bigIntMod)(k.multiply(gX), p); | ||
@@ -237,3 +236,3 @@ const generateAndCheckRandom = async () => { | ||
const aForHash = bigNumForHash(A); | ||
const u = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([aForHash, bForHash])), false); | ||
const u = (0, Helpers_1.readBigIntFromBuffer)(await (0, Helpers_1.sha256)(Buffer.concat([aForHash, bForHash])), false); | ||
if (u.greater((0, big_integer_1.default)(0))) { | ||
@@ -264,3 +263,3 @@ return { | ||
]); | ||
const M1 = await (0, Helpers_1.sha256)(buffer_1.Buffer.concat([ | ||
const M1 = await (0, Helpers_1.sha256)(Buffer.concat([ | ||
xor(pSha, gSha), | ||
@@ -275,3 +274,3 @@ salt1Sha, | ||
srpId: srpId, | ||
A: buffer_1.Buffer.from(aForHash), | ||
A: Buffer.from(aForHash), | ||
M1: M1, | ||
@@ -278,0 +277,0 @@ }); |
@@ -1,1 +0,18 @@ | ||
export {}; | ||
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>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const buffer_1 = require("buffer/"); | ||
const MemorySession = require("./Memory"); | ||
@@ -26,3 +24,3 @@ const AuthKey = require("../crypto/AuthKey"); | ||
if (keys[dcId] && hashes[dcId]) { | ||
this._authKeys[dcId] = new AuthKey(buffer_1.Buffer.from(keys[dcId].data), buffer_1.Buffer.from(hashes[dcId].data)); | ||
this._authKeys[dcId] = new AuthKey(Buffer.from(keys[dcId].data), Buffer.from(hashes[dcId].data)); | ||
} | ||
@@ -29,0 +27,0 @@ }); |
@@ -1,3 +0,1 @@ | ||
export declare class LocalStorage { | ||
constructor(location: string); | ||
} | ||
export declare const LocalStorage: any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LocalStorage = void 0; | ||
class LocalStorage { | ||
constructor(location) { | ||
throw new Error("Do not call me"); | ||
} | ||
} | ||
exports.LocalStorage = LocalStorage; | ||
exports.LocalStorage = require("node-localstorage").LocalStorage; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.StoreSession = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const Memory_1 = require("./Memory"); | ||
@@ -35,3 +34,3 @@ const store2_1 = __importDefault(require("store2")); | ||
if ("data" in authKey) { | ||
authKey = buffer_1.Buffer.from(authKey.data); | ||
authKey = Buffer.from(authKey.data); | ||
} | ||
@@ -38,0 +37,0 @@ await this._authKey.setKey(authKey); |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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"); | ||
@@ -84,3 +83,3 @@ const extensions_1 = require("../extensions"); | ||
static decode(x) { | ||
return buffer_1.Buffer.from(x, "base64"); | ||
return Buffer.from(x, "base64"); | ||
} | ||
@@ -102,10 +101,10 @@ async load() { | ||
} | ||
const dcBuffer = buffer_1.Buffer.from([this.dcId]); | ||
const addressBuffer = buffer_1.Buffer.from(this.serverAddress); | ||
const addressLengthBuffer = buffer_1.Buffer.alloc(2); | ||
const dcBuffer = Buffer.from([this.dcId]); | ||
const addressBuffer = Buffer.from(this.serverAddress); | ||
const addressLengthBuffer = Buffer.alloc(2); | ||
addressLengthBuffer.writeInt16BE(addressBuffer.length, 0); | ||
const portBuffer = buffer_1.Buffer.alloc(2); | ||
const portBuffer = Buffer.alloc(2); | ||
portBuffer.writeInt16BE(this.port, 0); | ||
return (CURRENT_VERSION + | ||
StringSession.encode(buffer_1.Buffer.concat([ | ||
StringSession.encode(Buffer.concat([ | ||
dcBuffer, | ||
@@ -112,0 +111,0 @@ addressLengthBuffer, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const buffer_1 = require("buffer/"); | ||
const { inspect } = require("../inspect"); | ||
@@ -86,3 +84,3 @@ const bigInt = require("big-integer"); | ||
case "int": | ||
const i = buffer_1.Buffer.alloc(4); | ||
const i = Buffer.alloc(4); | ||
i.writeInt32LE(x, 0); | ||
@@ -97,3 +95,3 @@ return i; | ||
case "double": | ||
const d = buffer_1.Buffer.alloc(8); | ||
const d = Buffer.alloc(8); | ||
d.writeDoubleLE(x, 0); | ||
@@ -105,6 +103,6 @@ return d; | ||
return x | ||
? buffer_1.Buffer.from("b5757299", "hex") | ||
: buffer_1.Buffer.from("379779bc", "hex"); | ||
? Buffer.from("b5757299", "hex") | ||
: Buffer.from("379779bc", "hex"); | ||
case "true": | ||
return buffer_1.Buffer.alloc(0); | ||
return Buffer.alloc(0); | ||
case "bytes": | ||
@@ -220,3 +218,3 @@ return serializeBytes(x); | ||
case "buffer": | ||
correct = buffer_1.Buffer.isBuffer(value); | ||
correct = Buffer.isBuffer(value); | ||
break; | ||
@@ -371,3 +369,3 @@ case "date": | ||
const idForBytes = this.CONSTRUCTOR_ID; | ||
const c = buffer_1.Buffer.alloc(4); | ||
const c = Buffer.alloc(4); | ||
c.writeUInt32LE(idForBytes, 0); | ||
@@ -388,11 +386,11 @@ const buffers = [c]; | ||
if (argsConfig[arg].useVectorId) { | ||
buffers.push(buffer_1.Buffer.from("15c4b51c", "hex")); | ||
buffers.push(Buffer.from("15c4b51c", "hex")); | ||
} | ||
const l = buffer_1.Buffer.alloc(4); | ||
const l = Buffer.alloc(4); | ||
l.writeInt32LE(this[arg].length, 0); | ||
buffers.push(l, buffer_1.Buffer.concat(this[arg].map((x) => argToBytes(x, argsConfig[arg].type, fullName)))); | ||
buffers.push(l, 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_1.Buffer.alloc(4)); | ||
buffers.push(Buffer.alloc(4)); | ||
} | ||
@@ -417,3 +415,3 @@ else { | ||
} | ||
const f = buffer_1.Buffer.alloc(4); | ||
const f = Buffer.alloc(4); | ||
f.writeUInt32LE(flagCalculate, 0); | ||
@@ -436,3 +434,3 @@ buffers.push(f); | ||
} | ||
return buffer_1.Buffer.concat(buffers); | ||
return Buffer.concat(buffers); | ||
} | ||
@@ -439,0 +437,0 @@ readResult(reader) { |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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("../"); | ||
@@ -23,3 +22,3 @@ const pako_1 = require("pako"); | ||
static gzip(input) { | ||
return buffer_1.Buffer.from(input); | ||
return Buffer.from(input); | ||
// TODO this usually makes it faster for large requests | ||
@@ -29,8 +28,8 @@ //return Buffer.from(deflate(input, { level: 9, gzip: true })) | ||
static ungzip(input) { | ||
return buffer_1.Buffer.from((0, pako_1.inflate)(input)); | ||
return Buffer.from((0, pako_1.inflate)(input)); | ||
} | ||
async toBytes() { | ||
const g = buffer_1.Buffer.alloc(4); | ||
const g = Buffer.alloc(4); | ||
g.writeUInt32LE(GZIPPacked.CONSTRUCTOR_ID, 0); | ||
return buffer_1.Buffer.concat([ | ||
return Buffer.concat([ | ||
g, | ||
@@ -37,0 +36,0 @@ (0, __1.serializeBytes)(await GZIPPacked.gzip(this.data)), |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { Api } from "../api"; | ||
@@ -3,0 +3,0 @@ import type { BinaryReader } from "../../extensions"; |
@@ -1,4 +0,5 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import type { ButtonLike, EntityLike } from "../../define"; | ||
import { Api } from "../api"; | ||
import { inspect } from "../../inspect"; | ||
export declare class Button { | ||
@@ -9,2 +10,5 @@ button: ButtonLike; | ||
singleUse: boolean | undefined; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
constructor(button: Api.TypeKeyboardButton, resize?: boolean, singleUse?: boolean, selective?: boolean); | ||
@@ -11,0 +15,0 @@ static _isInline(button: ButtonLike): boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Button = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const api_1 = require("../api"); | ||
@@ -28,3 +27,3 @@ const __1 = require("../../"); | ||
if (!data) { | ||
data = buffer_1.Buffer.from(text, "utf-8"); | ||
data = Buffer.from(text, "utf-8"); | ||
} | ||
@@ -31,0 +30,0 @@ if (data.length > 64) { |
@@ -0,3 +1,5 @@ | ||
/// <reference types="node" /> | ||
import type { Entity, EntityLike } from "../../define"; | ||
import type { TelegramClient } from "../../client/TelegramClient"; | ||
import { inspect } from "../../inspect"; | ||
export interface ChatGetterConstructorParams { | ||
@@ -15,2 +17,5 @@ chatPeer?: EntityLike; | ||
_client?: TelegramClient; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
static initChatClass(c: any, { chatPeer, inputChat, chat, broadcast }: ChatGetterConstructorParams): void; | ||
@@ -17,0 +22,0 @@ get chat(): Entity | undefined; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type { TelegramClient } from "../.."; | ||
@@ -6,2 +7,3 @@ import { Api } from "../api"; | ||
import bigInt from "big-integer"; | ||
import { inspect } from "../../inspect"; | ||
export declare class Dialog { | ||
@@ -26,3 +28,6 @@ _client: TelegramClient; | ||
isChannel: boolean; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
constructor(client: TelegramClient, dialog: Api.Dialog, entities: Map<string, Entity>, message?: Api.Message); | ||
} |
@@ -0,4 +1,6 @@ | ||
/// <reference types="node" /> | ||
import type { Entity } from "../../define"; | ||
import type { TelegramClient } from "../.."; | ||
import { Api } from "../api"; | ||
import { inspect } from "../../inspect"; | ||
export declare class Draft { | ||
@@ -14,2 +16,5 @@ private _client; | ||
private replyToMsgId?; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
constructor(client: TelegramClient, entity: Entity, draft: Api.TypeDraftMessage | undefined); | ||
@@ -16,0 +21,0 @@ get entity(): Entity | undefined; |
@@ -0,4 +1,9 @@ | ||
/// <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); | ||
@@ -5,0 +10,0 @@ get id(): void; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { ChatGetter } from "./chatGetter"; | ||
@@ -6,4 +7,8 @@ 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>); | ||
@@ -10,0 +15,0 @@ } |
@@ -0,4 +1,6 @@ | ||
/// <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 { | ||
@@ -20,2 +22,5 @@ private _ARTICLE; | ||
private _client; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
constructor(client: TelegramClient, original: Api.TypeBotInlineResult, queryId?: Api.long, entity?: EntityLike); | ||
@@ -22,0 +27,0 @@ get type(): string; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type { TelegramClient } from "../.."; | ||
@@ -5,2 +6,3 @@ import type { EntityLike } from "../../define"; | ||
import { InlineResult } from "./inlineResult"; | ||
import { inspect } from "../../inspect"; | ||
export declare class InlineResults extends Array<InlineResult> { | ||
@@ -15,4 +17,7 @@ private result; | ||
private switchPm; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
constructor(client: TelegramClient, original: Api.messages.TypeBotResults, entity?: EntityLike); | ||
resultsValid(): boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import { SenderGetter } from "./senderGetter"; | ||
@@ -12,2 +12,3 @@ import type { Entity, EntityLike } from "../../define"; | ||
import { MessageButton } from "./messageButton"; | ||
import { inspect } from "../../inspect"; | ||
interface MessageBaseInterface { | ||
@@ -345,2 +346,5 @@ 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; | ||
@@ -347,0 +351,0 @@ constructor(args: MessageBaseInterface); |
@@ -0,4 +1,6 @@ | ||
/// <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 { | ||
@@ -10,6 +12,9 @@ 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(): import("buffer").Buffer | undefined; | ||
get data(): Buffer | undefined; | ||
get inlineQuery(): string | undefined; | ||
@@ -16,0 +21,0 @@ get url(): string | undefined; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import type { Entity } from "../../define"; | ||
@@ -6,2 +7,3 @@ import type { TelegramClient } from "../.."; | ||
import bigInt from "big-integer"; | ||
import { inspect } from "../../inspect"; | ||
interface SenderGetterConstructorInterface { | ||
@@ -17,2 +19,5 @@ senderId?: bigInt.BigInteger; | ||
_client?: TelegramClient; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
static initSenderClass(c: any, { senderId, sender, inputSender }: SenderGetterConstructorInterface): void; | ||
@@ -19,0 +24,0 @@ get sender(): Entity | undefined; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
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; | ||
const buffer_1 = require("buffer/"); | ||
const Helpers_1 = require("../Helpers"); | ||
@@ -71,3 +70,3 @@ const snakeToCamelCase = (name) => { | ||
} | ||
currentConfig.constructorId = (0, Helpers_1.crc32)(buffer_1.Buffer.from(representation, "utf8")); | ||
currentConfig.constructorId = (0, Helpers_1.crc32)(Buffer.from(representation, "utf8")); | ||
} | ||
@@ -242,5 +241,5 @@ for (const [brace, name, argType] of argsMatch) { | ||
function serializeBytes(data) { | ||
if (!(data instanceof buffer_1.Buffer)) { | ||
if (!(data instanceof Buffer)) { | ||
if (typeof data == "string") { | ||
data = buffer_1.Buffer.from(data); | ||
data = Buffer.from(data); | ||
} | ||
@@ -258,3 +257,3 @@ else { | ||
} | ||
r.push(buffer_1.Buffer.from([data.length])); | ||
r.push(Buffer.from([data.length])); | ||
r.push(data); | ||
@@ -267,3 +266,3 @@ } | ||
} | ||
r.push(buffer_1.Buffer.from([ | ||
r.push(Buffer.from([ | ||
254, | ||
@@ -276,4 +275,4 @@ data.length % 256, | ||
} | ||
r.push(buffer_1.Buffer.alloc(padding).fill(0)); | ||
return buffer_1.Buffer.concat(r); | ||
r.push(Buffer.alloc(padding).fill(0)); | ||
return Buffer.concat(r); | ||
} | ||
@@ -283,3 +282,3 @@ exports.serializeBytes = serializeBytes; | ||
if (!dt) { | ||
return buffer_1.Buffer.alloc(4).fill(0); | ||
return Buffer.alloc(4).fill(0); | ||
} | ||
@@ -290,3 +289,3 @@ if (dt instanceof Date) { | ||
if (typeof dt == "number") { | ||
const t = buffer_1.Buffer.alloc(4); | ||
const t = Buffer.alloc(4); | ||
t.writeInt32LE(dt, 0); | ||
@@ -293,0 +292,0 @@ return t; |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
export declare class MTProtoRequest { | ||
@@ -3,0 +3,0 @@ private sent; |
@@ -1,1 +0,6 @@ | ||
export {}; | ||
declare function _exports({ types, constructors, functions }: { | ||
types: any; | ||
constructors: any; | ||
functions: any; | ||
}): string; | ||
export = _exports; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// Not sure what they are for. | ||
@@ -4,0 +3,0 @@ const WEIRD_TYPES = new Set(["Bool", "X", "Type"]); |
@@ -1,2 +0,2 @@ | ||
import { Buffer } from "buffer/"; | ||
/// <reference types="node" /> | ||
import type { Entity, EntityLike, MessageIDLike } from "./define"; | ||
@@ -3,0 +3,0 @@ import { Api } from "./tl"; |
@@ -7,3 +7,2 @@ "use strict"; | ||
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; | ||
const buffer_1 = require("buffer/"); | ||
const tl_1 = require("./tl"); | ||
@@ -76,4 +75,4 @@ const big_integer_1 = __importDefault(require("big-integer")); | ||
"(?:telegram\\.(?:me|dog)|t\\.me)\\/(@|joinchat\\/)?", "i"); | ||
const JPEG_HEADER = buffer_1.Buffer.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00", "hex"); | ||
const JPEG_FOOTER = buffer_1.Buffer.from("ffd9", "hex"); | ||
const JPEG_HEADER = Buffer.from("ffd8ffe000104a46494600010100000100010000ffdb004300281c1e231e19282321232d2b28303c64413c37373c7b585d4964918099968f808c8aa0b4e6c3a0aadaad8a8cc8ffcbdaeef5ffffff9bc1fffffffaffe6fdfff8ffdb0043012b2d2d3c353c76414176f8a58ca5f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8f8ffc00011080000000003012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00", "hex"); | ||
const JPEG_FOOTER = Buffer.from("ffd9", "hex"); | ||
const TG_JOIN_RE = new RegExp("tg:\\/\\/(join)\\?invite=", "i"); | ||
@@ -432,6 +431,6 @@ const VALID_USERNAME_RE = new RegExp("^([a-z]((?!__)[\\w\\d]){3,30}[a-z\\d]|gif|vid|" + | ||
} | ||
const header = buffer_1.Buffer.from(JPEG_HEADER); | ||
const header = Buffer.from(JPEG_HEADER); | ||
header[164] = stripped[1]; | ||
header[166] = stripped[2]; | ||
return buffer_1.Buffer.concat([header, stripped.slice(3), JPEG_FOOTER]); | ||
return Buffer.concat([header, stripped.slice(3), JPEG_FOOTER]); | ||
} | ||
@@ -438,0 +437,0 @@ exports.strippedPhotoToJpg = strippedPhotoToJpg; |
@@ -1,1 +0,1 @@ | ||
export declare const version = "2.26.0"; | ||
export declare const version = "2.26.1"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "2.26.0"; | ||
exports.version = "2.26.1"; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
2219018
55869
16
4
1
+ Addednode-localstorage@^2.2.1
+ Addedsocks@^2.6.2
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addednode-localstorage@2.2.1(transitive)
+ Addedslide@1.1.6(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedwrite-file-atomic@1.3.4(transitive)