STR-297 :: get user on refresh #97
Merged
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.
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
task/wil/str-297