Repository navigation
Use session storage for cached JWT - #70
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the LTI token retriever’s cached-JWT lookup to use sessionStorage (matching the existing write path) instead of localStorage, improving cache consistency for token fallback behavior.
Changes:
- Read cached JWT from
sessionStorageinloadJwt(). - Keep existing cached data parsing/handling behavior for missing entries.
Comments suppressed due to low confidence (2)
src/components/tokenRetriever/LtiTokenRetriever.tsx:158
loadJwt()rethrows any non-DOMException errors. A malformed cached value will causeJSON.parse(stored)to throw aSyntaxError, which will bubble up and show an internal parse error message instead of treating the cache as a miss (and contradicts the intent to guard against malformed entries). Consider catching parse/shape errors and returningnull(optionally clearing the badjwtentry) rather than rethrowing.
const stored = sessionStorage.getItem('jwt');
if (!stored) return null;
const data = JSON.parse(stored);
if (!data) return null;
return data.token ?? null;
} catch (e) {
if (!(e instanceof DOMException)) {
throw e;
}
src/components/tokenRetriever/LtiTokenRetriever.tsx:155
- The cached-JWT fallback path (including reading from
sessionStorageand handling missing/malformed entries) isn’t covered by tests inLtiTokenRetriever.test.jsx. Add test cases for: (1) non-OK token response uses the cached JWT, (2) missing cache shows the generic failure message, and (3) malformed cache contents are ignored rather than surfacing a JSON parse error.
const stored = sessionStorage.getItem('jwt');
if (!stored) return null;
const data = JSON.parse(stored);
if (!data) return null;
return data.token ?? null;
} catch (e) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
buckett
requested review from
lardo-de-arnaud,
nicholaswilson100 and
sebastianchristopher
February 19, 2026 09:28
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.
Summary
sessionStorageinstead oflocalStorageTesting