Fix isTokenExpired() to validate JWT exp claim instead of presence check#558
Draft
sebastianbarrozo with Copilot wants to merge 2 commits into
Draft
Fix isTokenExpired() to validate JWT exp claim instead of presence check#558sebastianbarrozo with Copilot wants to merge 2 commits into
sebastianbarrozo with Copilot wants to merge 2 commits into
Conversation
Agent-Logs-Url: https://github.com/etendosoftware/etendo_schema_forge/sessions/44bca6b9-9466-434a-af9b-5d17002ececc Co-authored-by: sebastianbarrozo <64203789+sebastianbarrozo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix isTokenExpired() to validate JWT expiration
Fix isTokenExpired() to validate JWT exp claim instead of presence check
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isTokenExpired()only checked!token, treating any non-null token (including long-expired ones) as valid. This caused unnecessary 401s, potential incorrect auth-gated UI decisions, and degraded UX.Changes
auth/api.js—isTokenExpired(): Decodes the JWT payload viaatoband comparesexp * 1000againstDate.now(). Malformed or missing tokens returntrue.auth/api.js—detectBaseUrl(): Addedtypeof window === 'undefined'guard and switched toimport.meta.env?.VITE_API_BASEoptional chaining to prevent crashes in non-browser (test/SSR) environments.auth/api.js: Removed leftover debugconsole.logthat accessedwindowandimport.meta.envunconditionally at module load time.auth/__tests__/api.test.js: Replaced the stub'returns false for non-empty token'test with three real JWT cases: valid token (expfar-future), expired token (exppast), and malformed input.Makefile: Addedtools/app-shell/src/auth/__tests__/*.test.jsto thetesttarget — these tests existed but were never wired intomake test.