-
Notifications
You must be signed in to change notification settings - Fork 44
Add eager auth for synchronous token access #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/components/tokenStore.ts
Outdated
| return; | ||
| } | ||
|
|
||
| const pattern = new RegExp(`${this.escapeRegExp(jwtCookieName)}=([^;]+)`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm slightly uncomfortable that we're having to string interpolate a regexp here... can we do some light-weight parsing or something instead?
dandorman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! (and very thorough job on the tests)
Summary
eagerAuthmiddleware option for synchronous access token availabilityKey Changes
eagerAuthoption: Enables synchronous token access on initial page loadUsage
To opt-in to this feature, add the following in
middleware.ts:With this enabled, the token will now be immediately accessible via the
useAccessTokenhook on the client.Without that, the first couple of renders will not have the
accessTokenavailable until it is asynchronously loaded.Fixes #286