Repository navigation
Adding config - #2
Merged
Merged
Conversation
| @@ -0,0 +1,11 @@ | |||
| { | |||
Member
There was a problem hiding this comment.
can you add to be different versions?
gvc
pushed a commit
that referenced
this pull request
Feb 7, 2023
* upgrade deps * changelog * upgrade deps * upgrade deps
eduardoformiga
added a commit
that referenced
this pull request
Aug 5, 2025
## What's the purpose of this pull request? This PR aims to implement the refresh cookie logic to maintain the user logged in. ## How does it work? First, we are using the `refreshAfter` prop from the session to store the time when we can call the refresh token route again. After the login, some cookies are set in the response for the production URL: `VtexIdclientAutCookie_<account>` (access token), and the refresh token cookie in a specific path that we must call in the frontend. The workflow calls the refresh token request in the frontend (httpOnly), under three conditions, during the validate session mutation: 1. `tokenExistAndIsFirstRefreshTokenRequest`— The login has been made, but we need to call the refresh token request at least once to get the `refreshAfter` for the first time. 2. `tokenNotExistAndRefreshAfterExistAndIsExpired`— When the access token expires, the browser clears it, so the access token no longer exists. However, as we have the `refreshAfter` from the previous request to the refresh token route, we know when to call it again after the refreshAfter time. 3. `tokenExpiredAndRefreshAfterIsNullOrExpired` - just a fallback that double-checks the internal expires (claim) prop from the JWT token using the cookie, not the cookie expiration that the browser tasks care. ## How to test it? 1 - The `refreshToken` flag must be true in `discovery.config`. 2 - You need to ask the identity team (open a support ticket) to enable the refresh token feature and set a time, like 7 days. (`b2bfaststoredev` account is set to 7 days) 3 - Use a production URL like https://b2bfaststore.vtexfaststore.com/login to login. 4 - After login, the cookies should be set, and you can see a first `/webstore` request in devtools with the `refreshAfter` in the response, which will be stored in the session. 5—After 1 day, just double-check if this request is made again and if you will continue logged. ## References - [FastStore refresh token doc](https://docs.google.com/document/d/1ctMH7P5hCwvoRtlqtXWevUdmXYmtjeCTkxN-xsOZYi8/edit?tab=t.0#heading=h.hysy5010uuws) - https://developers.vtex.com/docs/guides/refresh-token-flow-for-headless-implementations - https://developers.vtex.com/docs/api-reference/vtex-id-api#post-/api/vtexid/refreshtoken/webstore - slack threads with videos: [#1](https://vtex.slack.com/archives/C03L3CRCDC4/p1753797589142619), [#2](https://vtex.slack.com/archives/C03L3CRCDC4/p1754314094298059).
5 tasks
3 of 4 tasks
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.
This PR adds maaaaany config files, like prettier, eslint, typescript and all