the errors inside these server actions is causing:
 ⨯ Internal error: Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
    at eF (E:\BT-Projects\phoenix-next-app\node_modules\.pnpm\next@14.2.14_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:270333)
    at eq (E:\BT-Projects\phoenix-next-app\node_modules\.pnpm\next@14.2.14_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:274547)
    at eJ (E:\BT-Projects\phoenix-next-app\node_modules\.pnpm\next@14.2.14_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:275164)
    at Timeout._onTimeout (E:\BT-Projects\phoenix-next-app\node_modules\.pnpm\next@14.2.14_react-dom@18.3.1_react@18.3.1__react@18.3.1\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:264951)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)
digest: "2683469170"
 POST /test 200 in 62ms
"use server";
import { jwtVerify, SignJWT } from "jose";
import { getCookie, setCookie } from "cookies-next";
import { NextResponse } from "next/server";

const secretKey = new TextEncoder().encode(process.env.JWT_SECRET_KEY);
const accessTokenExpirationTime = "15m";
const refreshTokenExpirationTime = "7d";
function convertToPlainObject(decodedToken: any) {
  return {
    ...decodedToken.payload,
    protectedHeader: { ...decodedToken.protectedHeader },
  };
}

export async function signIn(username: string, password: string) {
  // Here you would typically validate the username and password
  // For this example, we'll just create a token
  const accessToken = await new SignJWT({ username })
    .setProtectedHeader({ alg: "HS256" })
    .setExpirationTime(accessTokenExpirationTime)
    .sign(secretKey);

  const refreshToken = await new SignJWT({ username })
    .setProtectedHeader({ alg: "HS256" })
    .setExpirationTime(refreshTokenExpirationTime)
    .sign(secretKey);

  setCookie("accessToken", accessToken, { httpOnly: true });
  setCookie("refreshToken", refreshToken, { httpOnly: true });

  const decodedToken = await jwtVerify(accessToken, secretKey);
  const plainDecodedToken = convertToPlainObject(decodedToken);
  return {
    success: true,
    decodedToken: plainDecodedToken,
  };
}

export async function refreshToken() {
  const refreshToken = getCookie("refreshToken");
  if (!refreshToken) {
    return NextResponse.json(
      { message: "No refresh token found" },
      { status: 401 },
    );
  }
  try {
    const { payload } = await jwtVerify(refreshToken, secretKey);
    const newAccessToken = await new SignJWT(payload)
      .setProtectedHeader({ alg: "HS256" })
      .setExpirationTime(accessTokenExpirationTime)
      .sign(secretKey);

    setCookie("accessToken", newAccessToken, { httpOnly: true });

    const decodedToken = await jwtVerify(newAccessToken, secretKey);
    const plainDecodedToken = convertToPlainObject(decodedToken);
    console.log(
      "Prototype of plainDecodedToken after refresh:",
      Object.getPrototypeOf(plainDecodedToken),
    );
    return {
      success: true,
      decodedToken: plainDecodedToken,
    };
  } catch (error) {
    console.error("Error refreshing token:", error); // Log error for debugging
    throw new Error("Invalid refresh token");
  }
}

export async function protectedAction() {
  const accessToken = getCookie("accessToken");
  if (!accessToken) {
    return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
  }

  try {
    await jwtVerify(accessToken, secretKey);
    return JSON.stringify({
      success: true,
      message: "Access granted to protected resource",
    });
  } catch (error) {
    throw new Error("Invalid access token");
  }
}