fix: breaking auth flow on Safari desktop - prevent confirmation popup #618
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.
Description
Auth flow on Safari desktop with agent-js
v0.13.x
is broken.Scenario:
authClient.login(...)
window.open
and ask user to confirm the opening of the new window/popup#authorize
馃憠 sign in flow is brokenRoot cause of the issue
Browsers prevent the opening of url (
window.open
ora.click
) - with target_blank
at least - without user interaction. In Safari, it seems that the browser also considers async callback that are executed within a function that opens new window as no user interaction and therefore prevent their opening.Agent-js
v0.13.x
introduces the usage of IndexedDB which requires async callback to be queried. As thelogin
function checks for the current key in the storage (KEY_STORAGE_KEY
), the function matches above criteria - an async callback is executed before window open in the same function - and that's why the issue occurs.Note that with agent-js
v0.12.x
there weren't such an issue because, I am assuming, using the local storage is not async.Solution - workaround
This PR fixes the issue by opening first the window, executing the async callback and then loading the IDP provider URL.
However, this feels like a temporary solution. I can imagine that a proper refactoring of
AuthClient
, rollbacking to localstorage or dropping the use of separate window would be cleaner solutions.How Has This Been Tested?
Locally and manually with NNS-dapp.
Screenshots