When using the single-factor-auth SDK in Node mode, it seems that there is no way to disconnect in order to clear the internal state/status of the instantiated instance after a connect.
This caused the logout method to always fail because the sdk instance was never “connected”.
In Node (backend) usecase, I should be able to init the sdk once and keep reusing it for different users. Unless there use-case is I am expected to recreate the SDK instance and reinitiate it everytime I need to use it? If so, why?
Hi Jacky! Thanks for reaching out with such a detailed explanation. Let’s see if we can provide some guidance on this.
From what you’ve described, it appears you’re encountering an issue with the Web3Auth Single-Factor-Auth SDK when using it in Node mode. The main concern seems to be the inability to clear the internal state of the Web3Auth instance effectively for reuse across different users.
From Your Details:
SDK: Single-Factor-Auth (Plug n Play)
Mode: Node Mode
Issue: Inability to disconnect or clear state properly due to the sessionManager not being instantiated in Node mode.
Concern: The logout method relies on connected, which isn’t instantiated in Node mode.
Suggested Approach:
Given the issue you’re facing, it might indeed be expected to reinitialize the SDK instance when using it for different users in a backend setup. The lack of a sessionManager instantiation for Node mode implies that session management might need to occur at a higher application logic level, such as handling instantiation and cleanup per user session manually.
What You Can Do:
Reinitialize Per Session: As you suggested, creating a fresh instance of the SDK for each user session might be the required approach due to the lack of a session mechanism in Node mode.
Feature Request: If this behavior doesn’t align with your needs, consider reaching out with a feature request. It might be helpful for others as well who require persistent sessions in Node mode.
You might also want to add your voice to the discussion on feature requests or improvements directly on their GitHub repository to potentially influence future SDK enhancements.
If you’d like further assistance or confirmation, feel free to ask! We’re here to help.
Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.
Thanks for bringing this up! I looked into it, and it does seem like logout() in Node mode isn’t working as expected since SessionManager isn’t instantiated, meaning the SDK never technically considers itself “connected.”
I’ve reached out to a senior engineer to confirm if the expected approach in backend use cases is to recreate the SDK instance per request or if there’s another way to properly clear state. Will update here once I get a response.
Hey @jcani
This has been fixed in the latest minor release, please update the SFA SDK to the latest version and let me know if it works as you were expecting. And thanks for reporting this, folks like you help us make our offerings better.
Here’s the relevant changelog: fixes logout in node sdk · Web3Auth/single-factor-auth@cf3e13f · GitHub