SIGN IN SIGN UP
honojs / hono UNCLAIMED

Web framework built on Web Standards

0 0 80 TypeScript

fix(jwt): use `Math.floor` instead of bitwise OR for safe timestamp (#4754)

* fix(jwt): use Math.floor instead of bitwise OR for Y2038-safe timestamp

The bitwise OR operator `| 0` truncates numbers to 32-bit signed integers,
causing overflow after 2038-01-19 when Unix timestamps exceed 2^31-1.
This would make expired JWT tokens pass validation.

Replace `(Date.now() / 1000) | 0` with `Math.floor(Date.now() / 1000)`
and add a regression test that verifies expired tokens are correctly
rejected when the current time is past the Y2038 boundary.

* Update jwt.test.ts

* Update jwt.test.ts
E
EdamAmex committed
e4602ad11a2879eeb4f06d5114d21e0565c114a9
Parent: 4bb70fa
Committed by GitHub <noreply@github.com> on 2/24/2026, 7:21:31 AM