Skip to content

Commit

Permalink
refactor: move all sources to src/ (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
rojvv authored Mar 17, 2023
1 parent 1ed22b1 commit 72613dc
Show file tree
Hide file tree
Showing 67 changed files with 65 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
run: deno lint

- name: Check
run: deno check mod.ts
run: deno check src/mod.ts
1 change: 0 additions & 1 deletion mod.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/classes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from "../deps.ts";
import { Buffer } from "./deps.ts";

export class CustomFile {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/client/2fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Api } from "../tl/api.js";
import { generateRandomBytes } from "../helpers.ts";
import { computeCheck, computeDigest } from "../password.ts";
import { EmailUnconfirmedError } from "../errors/mod.ts";
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";
import { AbstractTelegramClient } from "./abstract_telegram_client.ts";
import { TwoFaParams } from "./types.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/client/abstract_telegram_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Session } from "../sessions/mod.ts";
import { LogLevel } from "../extensions/logger.ts";
import { TotalList } from "../helpers.ts";
import { TelegramBaseClient, TelegramClientParams } from "./base_client.ts";
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";

export abstract class AbstractTelegramClient extends TelegramBaseClient {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/client/base_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ConnectionTCPMTProxyAbridged,
} from "../network/connection/tcpmt_proxy.ts";
import { ProxyInterface } from "../network/connection/types.ts";
import { Semaphore } from "../../deps.ts";
import { Semaphore } from "../deps.ts";

const EXPORTED_SENDER_RECONNECT_TIMEOUT = 1000; // 1 sec
const EXPORTED_SENDER_RELEASE_TIMEOUT = 30000; // 30 sec
Expand Down
2 changes: 1 addition & 1 deletion src/client/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EntityType_, entityType_ } from "../tl/helpers.ts";
import { getDisplayName } from "../utils.ts";
import { RequestIter } from "../request_iter.ts";
import { Api } from "../tl/api.js";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { IterParticipantsParams } from "./types.ts";

const MAX_PARTICIPANTS_CHUNK_SIZE = 200;
Expand Down
2 changes: 1 addition & 1 deletion src/client/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AbstractTelegramClient } from "./abstract_telegram_client.ts";
import { Dialog } from "../tl/custom/dialog.ts";
import { TotalList } from "../helpers.ts";
import { LogLevel } from "../extensions/logger.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { getPeerId } from "../utils.ts";
import { CustomMessage } from "../tl/custom/message.ts";
import { IterDialogsParams } from "./types.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/client/downloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
join,
resolve,
WriteStream,
} from "../../deps.ts";
} from "../deps.ts";
import {
DirectDownloadIterInterface,
DownloadFileParamsV2,
Expand Down
2 changes: 1 addition & 1 deletion src/client/message_parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getPeerId, sanitizeParseMode } from "../utils.ts";
import { AbstractTelegramClient } from "./abstract_telegram_client.ts";
import { isArrayLike } from "../helpers.ts";
import { EntityType_, entityType_ } from "../tl/helpers.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { CustomMessage } from "../tl/custom/message.ts";
import { ParseInterface } from "./types.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/client/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getPeerId,
parseID,
} from "../utils.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { _getPeer } from "./users.ts";
import { _parseMessageText } from "./message_parse.ts";
import { _fileToMedia } from "./utils.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/client/telegram_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { LogLevel } from "../extensions/logger.ts";
import { AbstractTelegramClient } from "./abstract_telegram_client.ts";
import { TotalList } from "../helpers.ts";
import * as types from "./types.ts";
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";

export class TelegramClient extends TelegramBaseClient
implements AbstractTelegramClient {
Expand Down
2 changes: 1 addition & 1 deletion src/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Api } from "../tl/api.js";
import { DateLike, OutFile, ProgressCallback } from "../define.d.ts";
import { CustomFile } from "../classes.ts";
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";

export interface ParseInterface {
parse: (message: string) => [string, Api.TypeMessageEntity[]];
Expand Down
2 changes: 1 addition & 1 deletion src/client/updates.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Api } from "../tl/api.js";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { UpdateConnectionState } from "../network/mod.ts";
import { getPeerId } from "../utils.ts";
import { getRandomInt, returnBigInt, sleep } from "../helpers.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/client/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
sleep,
} from "../helpers.ts";
import { FloodWaitError } from "../errors/mod.ts";
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";
import { SendFileInterface, UploadFileParams } from "./types.ts";
import { CustomFile } from "../classes.ts";
import { _fileToMedia } from "./utils.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/client/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as utils from "../utils.ts";
import { isArrayLike, returnBigInt, sleep } from "../helpers.ts";
import { EntityType_, entityType_ } from "../tl/helpers.ts";
import { AbstractTelegramClient } from "./abstract_telegram_client.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { LogLevel } from "../extensions/logger.ts";
import { MTProtoSender } from "../network/mtproto_sender.ts";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Api } from "../tl/api.js";
import { getAttributes, getInputMedia, isImage } from "../utils.ts";
import { AbstractTelegramClient } from "./abstract_telegram_client.ts";
import { _parseMessageText } from "./message_parse.ts";
import { basename, Buffer } from "../../deps.ts";
import { basename, Buffer } from "../deps.ts";
import { CustomFile } from "../classes.ts";
import { FileToMediaInterface } from "./types.ts";

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/authkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
toSignedLittleBuffer,
} from "../helpers.ts";
import { BinaryReader } from "../extensions/binary_reader.ts";
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

export class AuthKey {
private _key?: Buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ab2i, i2ab } from "./converters.ts";
import { AES, Buffer, getWords } from "../../deps.ts";
import { AES, Buffer, getWords } from "../deps.ts";

export class Counter {
_counter: Buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ctr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";
import { createCipheriv } from "../crypto/mod.ts";

export class CTR {
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/factorizator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { modExp } from "../helpers.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";

export class Factorizator {
static gcd(a: bigInt.BigInteger, b: bigInt.BigInteger) {
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ige.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { convertToLittle, generateRandomBytes } from "../helpers.ts";
import { Buffer, IGE as IGE_ } from "../../deps.ts";
import { Buffer, IGE as IGE_ } from "../deps.ts";

export class IGE {
// deno-lint-ignore no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/rsa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
readBufferFromBigInt,
sha1,
} from "../helpers.ts";
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

const PUBLIC_KEYS = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/define.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bigInt, Buffer, WriteStream } from "../deps.ts";
import { bigInt, Buffer, WriteStream } from "./deps.ts";

type ValueOf<T> = T[keyof T];
type Phone = string;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/entity_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Api } from "./tl/api.js";
import { getInputPeer, getPeerId } from "./utils.ts";
import { isArrayLike, returnBigInt } from "./helpers.ts";
import { bigInt } from "../deps.ts";
import { bigInt } from "./deps.ts";

export function getEntityPair_(
entityId: string,
Expand Down
2 changes: 1 addition & 1 deletion src/errors/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";

export class ReadCancelledError extends Error {
constructor() {
Expand Down
2 changes: 1 addition & 1 deletion src/events/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AbstractTelegramClient } from "../client/abstract_telegram_client.ts";
import { isArrayLike, returnBigInt } from "../helpers.ts";
import { getPeerId, parseID } from "../utils.ts";
import { SenderGetter } from "../tl/custom/sender_getter.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";

export async function _intoIdSet(
client: AbstractTelegramClient,
Expand Down
2 changes: 1 addition & 1 deletion src/events/deleted_message.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Api } from "../tl/api.js";
import { DefaultEventInterface, EventBuilder, EventCommon } from "./common.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";

export class DeletedMessage extends EventBuilder {
constructor(eventParams: DefaultEventInterface) {
Expand Down
2 changes: 1 addition & 1 deletion src/events/edited_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
NewMessageEvent,
NewMessageInterface,
} from "./new_message.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";

export interface EditedMessageInterface extends NewMessageInterface {
func?: { (event: EditedMessageEvent): boolean };
Expand Down
2 changes: 1 addition & 1 deletion src/events/new_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { AbstractTelegramClient } from "../client/abstract_telegram_client.ts";
import { Api } from "../tl/api.js";
import { LogLevel } from "../extensions/logger.ts";
import { bigInt } from "../../deps.ts";
import { bigInt } from "../deps.ts";
import { CustomMessage } from "../tl/custom/message.ts";

export interface NewMessageInterface extends DefaultEventInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/binary_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TypeNotFoundError } from "../errors/common.ts";
import { coreObjects } from "../tl/core/core_objects.ts";
import { tlObjects } from "../tl/all_tl_objects.ts";
import { readBigIntFromBuffer } from "../helpers.ts";
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";
import { BinaryReader as IBinaryReader } from "./interfaces.ts";

export class BinaryReader implements IBinaryReader {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/binary_writer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";

export class BinaryWriter {
private _stream: Buffer;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/html.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Api } from "../tl/api.js";
import { Handler, Parser } from "../../deps.ts";
import { Handler, Parser } from "../deps.ts";

function stripText(text: string, entities: Api.TypeMessageEntity[]) {
if (!entities || !entities.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

export interface BinaryReader {
offset: number;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/message_packer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import { Buffer } from "../../deps.ts";
import { Buffer } from "../deps.ts";
import { MessageContainer, TLMessage } from "../tl/core/mod.ts";
import { BinaryWriter } from "./binary_writer.ts";
import type { MTProtoState } from "../network/mtproto_state.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/promised_net_sockets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import { Buffer, Mutex, Socket, SocksClient } from "../../deps.ts";
import { Buffer, Mutex, Socket, SocksClient } from "../deps.ts";
import { ProxyInterface } from "../network/connection/types.ts";

const mutex = new Mutex();
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/promised_web_sockets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import { Buffer, Mutex } from "../../deps.ts";
import { Buffer, Mutex } from "../deps.ts";

const mutex = new Mutex();
const closeError = new Error("WebSocket was closed");
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bigInt, Buffer } from "../deps.ts";
import { bigInt, Buffer } from "./deps.ts";
import { createHash, randomBytes } from "./crypto/crypto.ts";

export function readBigIntFromBuffer(
Expand Down
2 changes: 1 addition & 1 deletion src/network/authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { serverKeys } from "../crypto/rsa.ts";
import { BinaryReader } from "../extensions/binary_reader.ts";
import { AuthKey } from "../crypto/authkey.ts";
import { IGE } from "../crypto/ige.ts";
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

const RETRIES = 20;

Expand Down
2 changes: 1 addition & 1 deletion src/network/connection/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CancellablePromise,
Cancellation,
pseudoCancellable,
} from "../../../deps.ts";
} from "../../deps.ts";
import { ProxyInterface } from "./types.ts";

export interface ConnectionInterfaceParams {
Expand Down
2 changes: 1 addition & 1 deletion src/network/connection/tcp_full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { crc32 } from "../../helpers.ts";
import { InvalidChecksumError } from "../../errors/mod.ts";
import type { PromisedNetSockets } from "../../extensions/promised_net_sockets.ts";
import type { PromisedWebSockets } from "../../extensions/promised_web_sockets.ts";
import { Buffer } from "../../../deps.ts";
import { Buffer } from "../../deps.ts";

export class FullPacketCodec extends PacketCodec {
private _sendCounter: number;
Expand Down
2 changes: 1 addition & 1 deletion src/network/connection/tcp_obfuscated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AbridgedPacketCodec } from "./tcpa_bridged.ts";
import { CTR } from "../../crypto/ctr.ts";
import type { PromisedNetSockets } from "../../extensions/promised_net_sockets.ts";
import type { PromisedWebSockets } from "../../extensions/promised_web_sockets.ts";
import { Buffer } from "../../../deps.ts";
import { Buffer } from "../../deps.ts";

class ObfuscatedIO {
header?: Buffer = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/network/connection/tcpa_bridged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Connection, PacketCodec } from "./connection.ts";
import { readBufferFromBigInt } from "../../helpers.ts";
import type { PromisedNetSockets } from "../../extensions/promised_net_sockets.ts";
import type { PromisedWebSockets } from "../../extensions/promised_web_sockets.ts";
import { bigInt, Buffer } from "../../../deps.ts";
import { bigInt, Buffer } from "../../deps.ts";

export class AbridgedPacketCodec extends PacketCodec implements PacketCodec {
static tag = Buffer.from("ef", "hex");
Expand Down
2 changes: 1 addition & 1 deletion src/network/connection/tcpmt_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CTR } from "../../crypto/ctr.ts";
import type { Logger } from "../../extensions/logger.ts";
import type { PromisedNetSockets } from "../../extensions/promised_net_sockets.ts";
import type { PromisedWebSockets } from "../../extensions/promised_web_sockets.ts";
import { Buffer } from "../../../deps.ts";
import { Buffer } from "../../deps.ts";
import { ProxyInterface } from "./types.ts";

export class MTProxyIO {
Expand Down
2 changes: 1 addition & 1 deletion src/network/mtproto_plain_sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toSignedLittleBuffer } from "../helpers.ts";
import { InvalidBufferError } from "../errors/mod.ts";
import { BinaryReader } from "../extensions/binary_reader.ts";
import type { Connection } from "./connection/connection.ts";
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

export class MTProtoPlainSender {
private _state: MTProtoState;
Expand Down
2 changes: 1 addition & 1 deletion src/network/mtproto_sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
Cancellation,
Mutex,
pseudoCancellable,
} from "../../deps.ts";
} from "../deps.ts";

export class UpdateConnectionState {
static disconnected = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/network/mtproto_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { BinaryReader } from "../extensions/binary_reader.ts";
import type { BinaryWriter } from "../extensions/binary_writer.ts";
import { InvalidBufferError, SecurityError } from "../errors/mod.ts";
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

export class MTProtoState {
private readonly authKey?: AuthKey;
Expand Down
2 changes: 1 addition & 1 deletion src/network/request_state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// deno-lint-ignore-file no-explicit-any
import { bigInt, Buffer } from "../../deps.ts";
import { bigInt, Buffer } from "../deps.ts";

export class RequestState {
public containerId?: bigInt.BigInteger;
Expand Down
2 changes: 1 addition & 1 deletion src/password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
readBufferFromBigInt,
sha256,
} from "./helpers.ts";
import { bigInt, Buffer } from "../deps.ts";
import { bigInt, Buffer } from "./deps.ts";
import { pbkdf2Sync } from "./crypto/crypto.ts";

const SIZE_FOR_HASH = 256;
Expand Down
Loading

0 comments on commit 72613dc

Please sign in to comment.