You are an expert code reviewer. Your task is to analyze the provided code files and provide a comprehensive code review. For each file, consider:

1. Code Quality: Assess readability, maintainability, and adherence to best practices
2. Potential Issues: Identify bugs, security vulnerabilities, or performance concerns
3. Suggestions: Provide specific recommendations for improvements

Format your review as follows:
1. Start with a brief overview of all files
2. For each file, provide:
   - A summary of the file's purpose
   - Key findings (both positive and negative)
   - Specific recommendations
3. End with any overall suggestions for the codebase

Your review should be detailed but concise, focusing on the most important aspects of the code.

Files to review:

File: ./src/core/bypasses/vegax.ts
Content:
import { app } from "~/client.js";
import { bypassvip } from "~/core/bypasses/bypassvip.js";
import { stringify } from "querystring";
import { sleep } from "bun";
import { load } from "cheerio";
import { seconds } from "~/core/times.js";

export async function vegax(link: string, isRetry?: boolean) {
  const url = new URL(link);
  const hwid = url.searchParams.get("hwid") || url.searchParams.get("HWID");

  if (!hwid) {
    return {
      status: "error",
      message: "HWID not found in link.",
    };
  }

  let location: string | null = null;
  let retries = 0;
  const maxRetries = 3;

  while (retries < maxRetries) {
    try {
      location = await attemptProceed(hwid);
      break;
    } catch (error) {
      if (error instanceof Error && error.message.includes("Token mismatch")) {
        retries++;
        if (retries >= maxRetries) {
          if (isRetry) {
            return {
              status: "error",
              message: "Max retries reached. Unable to proceed.",
            };
          }
          return await vegax(link, true);
        }
      } else {
        if (isRetry) {
          return {
            status: "error",
            message: "Failed to proceed!",
          };
        }
        return await vegax(link, true);
      }
    }
  }

  if (!location) {
    if (isRetry) {
      return {
        status: "error",
        message: "Failed to get redirect location!",
      };
    }
    return await vegax(link, true);
  }

  let result = await bypassvip(location);

  const sessiontoken1 = new URL(result.result).searchParams.get("sessiontoken");
  if (!sessiontoken1) {
    if (isRetry) {
      return {
        status: "error",
        message: "Failed to get sessiontoken!",
      };
    }
    return await vegax(link, true);
  }

  const proceed: string | null = await attemptProceed(hwid, sessiontoken1);

  result = await bypassvip(proceed!);

  const now = Date.now();
  const clearance = await getClearance();
  const timeTaken = Date.now() - now;

  await sleep(Math.max(0, seconds(6.66) - timeTaken));
  const res = await fetch(result.result, {
    headers: {
      cookie: `cf_clearance=${clearance.clearance}`,
      "user-agent": clearance.userAgent,
    },
  });

  const text = await res.text();

  const $ = load(text);

  const key = $("textarea").text();
  if (key) {
    return {
      status: "success",
      key: key,
    };
  } else {
    if (isRetry) {
      console.log(text);
      return {
        status: "error",
        message: "Failed to scrape key!",
      };
    }
    return await vegax(link, true);
  }

  async function getClearance(isRetry?: boolean) {
    const { data, error } = await app.api.v1.scraper.post({
      url: "https://pandadevelopment.net/getkey?service=vegax&hwid=111",
      cache: true,
      delayBeforeClose: 1000,
      $headers: {
        authorization: `Bearer ${Bun.env.ADMIN_KEY}`,
      },
    });

    if (data?.status !== "success") {
      if (isRetry) {
        throw new Error(data?.error?.message || "Failed to get key");
      }
      return getClearance(true);
    }

    if (!data.result.metadata.cf_clearance) {
      if (isRetry) {
        throw new Error("Failed to bypass Cloudflare!");
      }
      return getClearance(true);
    }

    return {
      clearance: data.result.metadata.cf_clearance,
      userAgent: data.result.metadata.user_agent,
    };
  }
}

async function attemptProceed(hwid: string, sessionToken?: string) {
  const proceedData = {
    hwid,
    service: "vegax",
    mode: "REDIRECT",
    serviceCheckpoints: "2",
    title: "Vega X",
    tier_id: "2",
    numberOfTasks: "1",
    theme: "3",
    background: "",
    token: sessionToken ?? "",
    provider: "linkvertise",
  };

  const proceed = await fetch(
    "https://pandadevelopment.net/getkey/proceed?service=vegax",
    {
      method: "POST",
      headers: {
        "content-type": "application/x-www-form-urlencoded",
        Referer: sessionToken
          ? `https://pandadevelopment.net/getkey?service=vegax&hwid=${hwid}&provider=linkvertise&sessiontoken=${sessionToken}`
          : `https://pandadevelopment.net/getkey?service=vegax&hwid=${hwid}&provider=linkvertise`,
      },
      body: stringify(proceedData),
      redirect: "manual",
    }
  );
  const text = await proceed.text();

  if (
    text.includes(
      "Token mismatch, session invalidated!, please refresh this page to go back to main checkpoint"
    )
  ) {
    throw new Error("Token mismatch, session invalidated!");
  }

  const location = proceed.headers.get("location");
  return location;
}



PROMPT: You are an expert code reviewer. Your task is to analyze the provided code files and provide a comprehensive code review. For each file, consider:

1. Code Quality: Assess readability, maintainability, and adherence to best practices
2. Potential Issues: Identify bugs, security vulnerabilities, or performance concerns
3. Suggestions: Provide specific recommendations for improvements

Format your review as follows:
1. Start with a brief overview of all files
2. For each file, provide:
   - A summary of the file's purpose
   - Key findings (both positive and negative)
   - Specific recommendations
3. End with any overall suggestions for the codebase

Your review should be detailed but concise, focusing on the most important aspects of the code.

Files to review:

File: ./src/core/bypasses/vegax.ts
Content:
import { app } from "~/client.js";
import { bypassvip } from "~/core/bypasses/bypassvip.js";
import { stringify } from "querystring";
import { sleep } from "bun";
import { load } from "cheerio";
import { seconds } from "~/core/times.js";

export async function vegax(link: string, isRetry?: boolean) {
  const url = new URL(link);
  const hwid = url.searchParams.get("hwid") || url.searchParams.get("HWID");

  if (!hwid) {
    return {
      status: "error",
      message: "HWID not found in link.",
    };
  }

  let location: string | null = null;
  let retries = 0;
  const maxRetries = 3;

  while (retries < maxRetries) {
    try {
      location = await attemptProceed(hwid);
      break;
    } catch (error) {
      if (error instanceof Error && error.message.includes("Token mismatch")) {
        retries++;
        if (retries >= maxRetries) {
          if (isRetry) {
            return {
              status: "error",
              message: "Max retries reached. Unable to proceed.",
            };
          }
          return await vegax(link, true);
        }
      } else {
        if (isRetry) {
          return {
            status: "error",
            message: "Failed to proceed!",
          };
        }
        return await vegax(link, true);
      }
    }
  }

  if (!location) {
    if (isRetry) {
      return {
        status: "error",
        message: "Failed to get redirect location!",
      };
    }
    return await vegax(link, true);
  }

  let result = await bypassvip(location);

  const sessiontoken1 = new URL(result.result).searchParams.get("sessiontoken");
  if (!sessiontoken1) {
    if (isRetry) {
      return {
        status: "error",
        message: "Failed to get sessiontoken!",
      };
    }
    return await vegax(link, true);
  }

  const proceed: string | null = await attemptProceed(hwid, sessiontoken1);

  result = await bypassvip(proceed!);

  const now = Date.now();
  const clearance = await getClearance();
  const timeTaken = Date.now() - now;

  await sleep(Math.max(0, seconds(6.66) - timeTaken));
  const res = await fetch(result.result, {
    headers: {
      cookie: `cf_clearance=${clearance.clearance}`,
      "user-agent": clearance.userAgent,
    },
  });

  const text = await res.text();

  const $ = load(text);

  const key = $("textarea").text();
  if (key) {
    return {
      status: "success",
      key: key,
    };
  } else {
    if (isRetry) {
      console.log(text);
      return {
        status: "error",
        message: "Failed to scrape key!",
      };
    }
    return await vegax(link, true);
  }

  async function getClearance(isRetry?: boolean) {
    const { data, error } = await app.api.v1.scraper.post({
      url: "https://pandadevelopment.net/getkey?service=vegax&hwid=111",
      cache: true,
      delayBeforeClose: 1000,
      $headers: {
        authorization: `Bearer ${Bun.env.ADMIN_KEY}`,
      },
    });

    if (data?.status !== "success") {
      if (isRetry) {
        throw new Error(data?.error?.message || "Failed to get key");
      }
      return getClearance(true);
    }

    if (!data.result.metadata.cf_clearance) {
      if (isRetry) {
        throw new Error("Failed to bypass Cloudflare!");
      }
      return getClearance(true);
    }

    return {
      clearance: data.result.metadata.cf_clearance,
      userAgent: data.result.metadata.user_agent,
    };
  }
}

async function attemptProceed(hwid: string, sessionToken?: string) {
  const proceedData = {
    hwid,
    service: "vegax",
    mode: "REDIRECT",
    serviceCheckpoints: "2",
    title: "Vega X",
    tier_id: "2",
    numberOfTasks: "1",
    theme: "3",
    background: "",
    token: sessionToken ?? "",
    provider: "linkvertise",
  };

  const proceed = await fetch(
    "https://pandadevelopment.net/getkey/proceed?service=vegax",
    {
      method: "POST",
      headers: {
        "content-type": "application/x-www-form-urlencoded",
        Referer: sessionToken
          ? `https://pandadevelopment.net/getkey?service=vegax&hwid=${hwid}&provider=linkvertise&sessiontoken=${sessionToken}`
          : `https://pandadevelopment.net/getkey?service=vegax&hwid=${hwid}&provider=linkvertise`,
      },
      body: stringify(proceedData),
      redirect: "manual",
    }
  );
  const text = await proceed.text();

  if (
    text.includes(
      "Token mismatch, session invalidated!, please refresh this page to go back to main checkpoint"
    )
  ) {
    throw new Error("Token mismatch, session invalidated!");
  }

  const location = proceed.headers.get("location");
  return location;
}