How to handle user interruption in Internet Identity Auth?

Hi, Everyone,
I’m new to IC development, writing a simple demo to authenticate with Internet Identity.
I finally get the demo working, with one problem unsolved,
If the user closed the window accidentally, how can I know it?

I didn’t find a clue from the document of @dfinity/auth-client.

Anybody knows how to do that?

As far as I know - no

Child window _idpWindow is private field in auth-client

You can try the following:

  • handle onError callback of login function and hope for it callback handles accidentally child window close
  • or copy AuthClient implementation from this file to your repo and interact with child window yourself
    javascript - How to listen for child window closing? - Stack Overflow
  • or make Pull Request to @dfinity/internet-identity with close handling (best choice) :slight_smile:
1 Like

Thanks a lot. I already registered an onError callback, no error is raised.
I’ll give a try to the cross window communication, and make a PR if I can have a sound solution.

1 Like

GitHub Issue: Notify the user interruption as an error · Issue #525 · dfinity/agent-js (
PR: feat: notify user interruption by wewei · Pull Request #526 · dfinity/agent-js (

1 Like

@kpeacock need your review :slight_smile:

@kpeacock I updated the PR during the weekend, would you please take a look again?

1 Like