Skip to content

STR-297 :: get user on refresh #97

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

Merged
merged 2 commits into from
Jan 25, 2023
Merged

STR-297 :: get user on refresh #97

merged 2 commits into from
Jan 25, 2023

Conversation

alcalawil
Copy link
Contributor

@alcalawil alcalawil commented Jan 17, 2023

Changes summary

  • I've moved all of the logic and API calls from the iframe to the SDK, so now the iFrame is just an event emitter/listener that handles user interactions and listens for SDK events. I created a custom EventEmitter class (like the Node.js ones) to propagate events so svelte components can subscribe to changes.

  • I got rid of Axios (the HTTP client) because is quite difficult to make it work alongside rollup.js. As a result, we do not have all of the Axios cool features like interceptors, and timeouts. So I created a custom request interceptor for token refreshing but request timeouts are not working yet.

  • I've made good improvements to the communication protocol between iframe and SDK (which is based on events). Now we can send an event and wait for a response (simulating a synchronous communication like HTTP). So the user starts a flow, the iframe sends an event to the SDK, the SDK executes business logic and API calls, gets a response from the server, and sends an event to the iframe, the iframe keeps waiting for this event until it either resolves with data or throws a timeout error.

  • Now the iframe does not keep any state in localStorage or in cookies. Auth states are now managed by the SDK

To test
This is a refactor task so the app's behavior should be the same in terms of the user's perspective

  1. Run api, sdk and iframe all of them on branch task/wil/str-297
  2. Test every flow you can (Create User, Verify Email, New Device Verification, Login (remember to set a short JWT expiration time on the api to test the token is refreshing), Quote refreshing, Purchase Successful, Purchase Fail. Please try to test edge cases.
  3. Everything should be working as usual.

@alcalawil alcalawil changed the base branch from main to develop January 17, 2023 04:54
@alcalawil alcalawil marked this pull request as ready for review January 17, 2023 20:44
@frostbournesb frostbournesb self-requested a review January 25, 2023 21:37
@alcalawil alcalawil merged commit 7f9ba60 into develop Jan 25, 2023
@alcalawil alcalawil deleted the task/wil/str-297 branch January 25, 2023 21:46
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.

3 participants