Skip to content

Conversation

kimzuni
Copy link
Contributor

@kimzuni kimzuni commented Aug 5, 2025

If schema is undefined, claim values should support not only string and number, but also boolean, null, array and object.

This also resolves the TypeScript error for jwt.sign({ iat: boolean }).

before

const jwt = plugin({
	secret: "x",
}).decorator.jwt;

const token = await jwt.sign({
	iat: false, // ts(2345) error
});

after

const jwt = plugin({
	secret: "x",
}).decorator.jwt;

const token = await jwt.sign({
	iat: false, // ok
	// iat: {}, // disallowed
	custom: null, // or string, number, boolean, [], {} // ok
	deep: { key: [{ custom: {} }] }, // ok
});

@kimzuni kimzuni force-pushed the fix/allow-claim-value-type branch from 3f8d6ac to a5ba65e Compare August 5, 2025 15:30
@SaltyAom SaltyAom merged commit a5ba65e into elysiajs:main Aug 24, 2025
@kimzuni kimzuni deleted the fix/allow-claim-value-type branch August 25, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants