Comparing version 2.26.6 to 2.26.7
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateTwoFaSettings = void 0; | ||
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, | ||
@@ -83,0 +84,0 @@ email, |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
import { Api } from "../tl"; | ||
@@ -3,0 +3,0 @@ import type { TelegramClient } from "./TelegramClient"; |
@@ -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>; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
import { Api } from "../tl"; | ||
@@ -3,0 +3,0 @@ import type { TelegramClient } from "./TelegramClient"; |
@@ -37,2 +37,3 @@ "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"); | ||
@@ -137,3 +138,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 +149,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; | ||
@@ -235,4 +236,4 @@ } | ||
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 +262,3 @@ else if (typeof outputFile == "string") { | ||
else { | ||
return Buffer.from(writer.path); | ||
return buffer_1.Buffer.from(writer.path); | ||
} | ||
@@ -387,3 +388,3 @@ } | ||
else { | ||
return Buffer.alloc(0); | ||
return buffer_1.Buffer.alloc(0); | ||
} | ||
@@ -396,3 +397,3 @@ } | ||
if (!doc.document) { | ||
return Buffer.alloc(0); | ||
return buffer_1.Buffer.alloc(0); | ||
} | ||
@@ -402,3 +403,3 @@ doc = doc.document; | ||
if (!(doc instanceof tl_1.Api.Document)) { | ||
return Buffer.alloc(0); | ||
return buffer_1.Buffer.alloc(0); | ||
} | ||
@@ -536,3 +537,3 @@ let size; | ||
if (photo.photo instanceof tl_1.Api.PhotoEmpty || !photo.photo) { | ||
return Buffer.alloc(0); | ||
return buffer_1.Buffer.alloc(0); | ||
} | ||
@@ -542,3 +543,3 @@ photo = photo.photo; | ||
if (!(photo instanceof tl_1.Api.Photo)) { | ||
return Buffer.alloc(0); | ||
return buffer_1.Buffer.alloc(0); | ||
} | ||
@@ -548,3 +549,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); | ||
} | ||
@@ -606,3 +607,3 @@ if (!date) { | ||
else { | ||
return Buffer.alloc(0); | ||
return buffer_1.Buffer.alloc(0); | ||
} | ||
@@ -609,0 +610,0 @@ return client.downloadFile(loc, { |
@@ -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 = {}; |
@@ -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,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"; | ||
/** | ||
@@ -1035,6 +1034,2 @@ * 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; | ||
}; | ||
/** | ||
@@ -1041,0 +1036,0 @@ * Small hack for using it in browsers |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
import { Api } from "../tl"; | ||
@@ -3,0 +3,0 @@ import { TelegramClient } from "./TelegramClient"; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.sendFile = exports._sendAlbum = exports._fileToMedia = exports.uploadFile = exports.CustomFile = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const tl_1 = require("../tl"); | ||
@@ -44,9 +45,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 +67,3 @@ } | ||
else { | ||
options.buffer = Buffer.from(await fileToBuffer(file)); | ||
options.buffer = buffer_1.Buffer.from(await fileToBuffer(file)); | ||
} | ||
@@ -176,3 +177,3 @@ return new CustomBuffer(options); | ||
if (typeof file == "object" && | ||
!Buffer.isBuffer(file) && | ||
!buffer_1.Buffer.isBuffer(file) && | ||
!(file instanceof tl_1.Api.InputFile) && | ||
@@ -236,3 +237,3 @@ !(file instanceof tl_1.Api.InputFileBig) && | ||
} | ||
if (Buffer.isBuffer(file)) { | ||
if (buffer_1.Buffer.isBuffer(file)) { | ||
createdFile = new CustomFile(name, file.length, "", file); | ||
@@ -296,3 +297,3 @@ } | ||
} | ||
if (Buffer.isBuffer(thumb)) { | ||
if (buffer_1.Buffer.isBuffer(thumb)) { | ||
uploadedThumb = new CustomFile(name, thumb.length, "", thumb); | ||
@@ -299,0 +300,0 @@ } |
@@ -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 @@ } |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
export declare class Counter { | ||
@@ -3,0 +3,0 @@ _counter: Buffer; |
@@ -7,2 +7,3 @@ "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")); | ||
@@ -13,3 +14,3 @@ const converters_1 = require("./converters"); | ||
constructor(initialValue) { | ||
this._counter = Buffer.from(initialValue); | ||
this._counter = buffer_1.Buffer.from(initialValue); | ||
} | ||
@@ -43,6 +44,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; | ||
@@ -97,9 +98,9 @@ this._counter.increment(); | ||
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); | ||
} | ||
@@ -110,3 +111,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", | ||
@@ -113,0 +114,0 @@ hash: "SHA-512", |
@@ -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; |
@@ -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, { |
@@ -18,2 +18,3 @@ "use strict"; | ||
exports.encrypt = exports._serverKeys = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const big_integer_1 = __importDefault(require("big-integer")); | ||
@@ -63,3 +64,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 | ||
@@ -66,0 +67,0 @@ // rsa module uses rsa.transform.bytes2int(to_encrypt), easier way: |
@@ -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,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; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
import { EntityLike } from "../define"; | ||
@@ -3,0 +3,0 @@ import { EventBuilder, EventCommonSender } from "./common"; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
export declare class BinaryReader { | ||
@@ -3,0 +3,0 @@ private readonly stream; |
@@ -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; |
@@ -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; |
@@ -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"; | ||
@@ -3,0 +3,0 @@ import type { EntityLike } from "./define"; |
@@ -7,2 +7,3 @@ "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")); | ||
@@ -19,3 +20,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; | ||
@@ -109,3 +110,3 @@ if (little) { | ||
// smh hacks | ||
return Buffer.from(byteArray); | ||
return buffer_1.Buffer.from(byteArray); | ||
} | ||
@@ -137,3 +138,3 @@ exports.toSignedLittleBuffer = toSignedLittleBuffer; | ||
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) { | ||
@@ -179,3 +180,3 @@ buffer = buffer.reverse(); | ||
function generateRandomBytes(count) { | ||
return Buffer.from(CryptoFile_1.default.randomBytes(count)); | ||
return buffer_1.Buffer.from(CryptoFile_1.default.randomBytes(count)); | ||
} | ||
@@ -260,8 +261,8 @@ exports.generateRandomBytes = generateRandomBytes; | ||
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), | ||
@@ -278,3 +279,3 @@ hash3, | ||
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++) { | ||
@@ -410,3 +411,3 @@ correct.writeUInt32BE(buf[i], i * 4); | ||
} | ||
return Buffer.from(res); | ||
return buffer_1.Buffer.from(res); | ||
} | ||
@@ -432,4 +433,4 @@ exports.bufferXor = bufferXor; | ||
} | ||
if (!Buffer.isBuffer(buf)) { | ||
buf = Buffer.from(buf); | ||
if (!buffer_1.Buffer.isBuffer(buf)) { | ||
buf = buffer_1.Buffer.from(buf); | ||
} | ||
@@ -436,0 +437,0 @@ let crc = -1; |
@@ -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: "", | ||
}; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.doAuthentication = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const Helpers_1 = require("../Helpers"); | ||
@@ -63,16 +64,16 @@ const tl_1 = require("../tl"); | ||
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); | ||
@@ -154,3 +155,3 @@ if (keyAesEncryptedInt.greaterOrEquals(targetKey.n)) { | ||
}).getBytes(); | ||
const clientDdhInnerHashed = Buffer.concat([ | ||
const clientDdhInnerHashed = buffer_1.Buffer.concat([ | ||
await (0, Helpers_1.sha1)(clientDhInner), | ||
@@ -157,0 +158,0 @@ clientDhInner, |
@@ -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"; |
@@ -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"; | ||
@@ -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"); | ||
@@ -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; |
@@ -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 @@ ]); |
@@ -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"; |
{ | ||
"name": "telegram", | ||
"version": "2.26.6", | ||
"version": "2.26.7", | ||
"description": "NodeJS/Browser MTProto API Telegram client library,", | ||
@@ -69,6 +69,4 @@ "main": "index.js", | ||
"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 @@ /** |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.computeDigest = exports.computeCheck = void 0; | ||
const buffer_1 = require("buffer/"); | ||
const tl_1 = require("./tl"); | ||
@@ -70,3 +71,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 +119,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 +169,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])); | ||
} | ||
@@ -224,3 +225,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); | ||
@@ -236,3 +237,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))) { | ||
@@ -263,3 +264,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), | ||
@@ -274,3 +275,3 @@ salt1Sha, | ||
srpId: srpId, | ||
A: Buffer.from(aForHash), | ||
A: buffer_1.Buffer.from(aForHash), | ||
M1: M1, | ||
@@ -277,0 +278,0 @@ }); |
@@ -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 @@ }); |
@@ -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; |
@@ -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, |
@@ -1,3 +0,3 @@ | ||
export declare const LAYER = 184; | ||
export declare const LAYER = 193; | ||
declare const tlobjects: any; | ||
export { tlobjects }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.tlobjects = exports.LAYER = void 0; | ||
exports.LAYER = 184; | ||
exports.LAYER = 193; | ||
const _1 = require("./"); | ||
@@ -6,0 +6,0 @@ const tlobjects = {}; |
"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) { |
@@ -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)), |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
import { Api } from "../api"; | ||
@@ -3,0 +3,0 @@ import type { BinaryReader } from "../../extensions"; |
@@ -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,5 +9,2 @@ button: ButtonLike; | ||
singleUse: boolean | undefined; | ||
[inspect.custom](): { | ||
[key: string]: any; | ||
}; | ||
constructor(button: Api.TypeKeyboardButton, resize?: boolean, singleUse?: boolean, selective?: boolean); | ||
@@ -15,0 +11,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"); | ||
@@ -27,3 +28,3 @@ const __1 = require("../../"); | ||
if (!data) { | ||
data = Buffer.from(text, "utf-8"); | ||
data = buffer_1.Buffer.from(text, "utf-8"); | ||
} | ||
@@ -30,0 +31,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; |
@@ -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); | ||
} |
@@ -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; |
@@ -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; |
@@ -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 @@ } |
@@ -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; |
@@ -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; | ||
} |
@@ -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); |
@@ -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; |
@@ -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; |
@@ -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; | ||
const buffer_1 = require("buffer/"); | ||
const Helpers_1 = require("../Helpers"); | ||
@@ -70,3 +71,3 @@ const snakeToCamelCase = (name) => { | ||
} | ||
currentConfig.constructorId = (0, Helpers_1.crc32)(Buffer.from(representation, "utf8")); | ||
currentConfig.constructorId = (0, Helpers_1.crc32)(buffer_1.Buffer.from(representation, "utf8")); | ||
} | ||
@@ -241,5 +242,5 @@ for (const [brace, name, argType] of argsMatch) { | ||
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); | ||
} | ||
@@ -257,3 +258,3 @@ else { | ||
} | ||
r.push(Buffer.from([data.length])); | ||
r.push(buffer_1.Buffer.from([data.length])); | ||
r.push(data); | ||
@@ -266,3 +267,3 @@ } | ||
} | ||
r.push(Buffer.from([ | ||
r.push(buffer_1.Buffer.from([ | ||
254, | ||
@@ -275,4 +276,4 @@ 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); | ||
} | ||
@@ -282,3 +283,3 @@ exports.serializeBytes = serializeBytes; | ||
if (!dt) { | ||
return Buffer.alloc(4).fill(0); | ||
return buffer_1.Buffer.alloc(4).fill(0); | ||
} | ||
@@ -289,3 +290,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); | ||
@@ -292,0 +293,0 @@ return t; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { Buffer } from "buffer/"; | ||
export declare class MTProtoRequest { | ||
@@ -3,0 +3,0 @@ private sent; |
@@ -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 }); | ||
// Not sure what they are for. | ||
@@ -3,0 +4,0 @@ const WEIRD_TYPES = new Set(["Bool", "X", "Type"]); |
@@ -1,8 +0,8 @@ | ||
/// <reference types="node" /> | ||
import type { Entity, EntityLike, MessageIDLike } from "./define"; | ||
import { Api } from "./tl"; | ||
import { Buffer } from "buffer/"; | ||
import bigInt from "big-integer"; | ||
import { EntityCache } from "./entityCache"; | ||
import type { ParseInterface } from "./client/messageParse"; | ||
import { CustomFile } from "./client/uploads"; | ||
import type { Entity, EntityLike, MessageIDLike } from "./define"; | ||
import { EntityCache } from "./entityCache"; | ||
import { Api } from "./tl"; | ||
export declare function getFileInfo(fileLocation: Api.Message | Api.MessageMediaDocument | Api.MessageMediaPhoto | Api.TypeInputFileLocation): { | ||
@@ -9,0 +9,0 @@ dcId?: number; |
21
Utils.js
@@ -7,7 +7,10 @@ "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 tl_1 = require("./tl"); | ||
const buffer_1 = require("buffer/"); | ||
const big_integer_1 = __importDefault(require("big-integer")); | ||
const mime_1 = __importDefault(require("mime")); | ||
const html_1 = require("./extensions/html"); | ||
const markdown_1 = require("./extensions/markdown"); | ||
const markdownv2_1 = require("./extensions/markdownv2"); | ||
const Helpers_1 = require("./Helpers"); | ||
const tl_1 = require("./tl"); | ||
function getFileInfo(fileLocation) { | ||
@@ -71,8 +74,6 @@ if (!fileLocation || !fileLocation.SUBCLASS_OF_ID) { | ||
exports.chunks = chunks; | ||
const html_1 = require("./extensions/html"); | ||
const Helpers_1 = require("./Helpers"); | ||
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"); | ||
@@ -431,6 +432,6 @@ const VALID_USERNAME_RE = new RegExp("^([a-z]((?!__)[\\w\\d]){3,30}[a-z\\d]|gif|vid|" + | ||
} | ||
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]); | ||
} | ||
@@ -667,3 +668,7 @@ exports.strippedPhotoToJpg = strippedPhotoToJpg; | ||
var _a, _b, _c, _d; | ||
const name = typeof file == "string" ? file : file.name || "unnamed"; | ||
const name = typeof file == "string" | ||
? file | ||
: "name" in file | ||
? file.name || "unnamed" | ||
: "unnamed"; | ||
if (mimeType === undefined) { | ||
@@ -670,0 +675,0 @@ mimeType = mime_1.default.getType(name) || "application/octet-stream"; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
2271642
14
57088
3
0
- Removednode-localstorage@^2.2.1
- Removedsocks@^2.6.2
- Removedgraceful-fs@4.2.11(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedip-address@9.0.5(transitive)
- Removedjsbn@1.1.0(transitive)
- Removednode-localstorage@2.2.1(transitive)
- Removedslide@1.1.6(transitive)
- Removedsmart-buffer@4.2.0(transitive)
- Removedsocks@2.8.3(transitive)
- Removedsprintf-js@1.1.3(transitive)
- Removedwrite-file-atomic@1.3.4(transitive)