-
-
Notifications
You must be signed in to change notification settings - Fork 487
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.3.8
What platform is your computer?
(Arch) Linux 6.15.9-arch1-1 x86_64 unknown
What steps can reproduce the bug?
It appears that the setting of additionalProperties: false in 3dbb73a breaks @elysiajs/jwt. For some reason, the resulting schema rejects any additional properties in my custom schema beyond the base JWT fields Elysia expects.
To reproduce:
const baseJwtSchema = t.Object({
id: t.String(),
sessionId: t.String(),
roles: t.Array(t.Enum(Role)),
verification: t.String(),
});
const accessJwtSchema = t.Composite([
baseJwtSchema,
t.Object({
firstName: t.String(),
lastName: t.String(),
email: t.String(),
phone: t.Optional(t.String()),
company: t.Optional(t.String()),
}),
]);
const jwtSchema = t.Union([baseJwtSchema, accessJwtSchema]);
const authJwtPlugin = new Elysia({ name: 'auth-jwt-plugin' }).use(
jwt({ name: 'authJwt', secret: environment.jwt.secret, schema: jwtSchema }),
);Then try to pass in a token to authJwt.verify() with either of the two schemas. Validation will fail.
What is the expected behavior?
This same schema to work as it did in 1.3.5.
What do you see instead?
It doesn't :)
Additional information
Let me know if you need more info. I would fix it myself but I am not confident of the knock-on effects (I don't want to cause a regression of #1281).
Have you try removing the node_modules and bun.lockb and try again yet?
yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working