Passing Cookies as arguments in ElysiaJS

Not sure if this is possible exactly but I wanted to try anyway. I have my Elysia server set up like the following:

server.ts

export const server = new Elysia({
  cookie: {
    secrets: Bun.env.COOKIE_SECRET,
    sign: ["profile"]
  }
})

Then I have this route that executes a function called handleUserRedirect(). This function takes a query parameter (which I have no issue passing) and I want to pass it a cookie so I could change the cookie’s value after some receiving some response data within this function.

server.ts

.get("/user-redirect", async ({ query, cookie }) => handleUserRedirect(query.code, cookie.profile), {
    query: t.Object({
      id: t.String(),
    }),
    cookie: t.Cookie({
      profile: t.Object({
        token: t.String(),
        name: t.String(),
      })
    })

  })

handler.ts

export async function handleUserRedirect(id: string, profile: { token: string, name: string }) {
...
// make a get request to an api and receive a response containing some basic user information
const responseData = await response.json();
profile.token = responseData.token;
profile.name = responseData.name;
}

This is the error I get:
Argument of type ‘Cookie<{ name: string; token: string; }>’ is not assignable to parameter of type ‘{ profile: { token: string; name: string; }; }’. Property ‘profile’ is missing in type ‘Cookie<{ name: string; sub: string; }>’ but required in type ‘{ profile: { sub: string; name: string; }; }’.

I have been stuck on this for a while now and have tried using various functions within the Elysia docs such as afterHandle where I tried returning just the response and tried to set the cookies in my server based on that but that didn’t work either. The only solution I have been able to come up with thus far is using Elysia’s store instead of cookies.