Skip to content

Adding config - #2

Merged
tlgimenes merged 8 commits into
masterfrom
feature/lerna
Jun 18, 2020
Merged

tlgimenes merged 8 commits into
masterfrom
feature/lerna

Conversation

@tlgimenes

Copy link
Copy Markdown
Contributor

This PR adds maaaaany config files, like prettier, eslint, typescript and all

Comment thread lerna.json
@@ -0,0 +1,11 @@
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add to be different versions?

@tlgimenes
tlgimenes merged commit 6e4545d into master Jun 18, 2020
@tlgimenes
tlgimenes deleted the feature/lerna branch June 18, 2020 15:07
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants