Open Mudbill opened 8 months ago
@Mudbill Stuck on same issue here
You could pass the array/object as a string 💀
You could pass the array/object as a string 💀
You could, but why should you? You could pass numbers as strings, but it's rarely a good idea.
A better solution (for the time being) is to just force override the type.
const token = await context.jwt.sign({
roles: ["admin"] as any
});
As per the JWT specification, it is a valid format to use arrays and objects as embedded payloads in JWT, however the TypeScript definition only allows values of
string | number
. This should be loosened up a bit.A valid JWT payload:
These two lines specify the types as
Record<string, string | number>
. In particular, allowing arrays is important, for situations such as the example here.