Optimizing Auth flow

Currently, we are facing some minor performance issues when loading our app after the user has closed it. It seems like one of the main bottlenecks is retrieving an AuthToken from our backend every time a user opens the app and attempts to login to Amity.

const authToken = await getAmityAuthToken();
await Client.login({ userId, displayName, authToken }, sessionHandler);

Since the AccessTokens are valid for 30 days, is there a way that I can login the first time with the AuthToken but have all sequential logins just use the userId and displayName and only retrieve a new AuthToken if the AccessToken expires?

Hello, there are two possible approaches to optimizing the Auth flow:

  1. Storing it on the frontend is feasible; however, please be advised that you will be responsible for managing security concerns.
  2. Alternatively, implement backend storage with caching, enabling efficient retrieval of stored values by the server.

Is storing the token locally something that Amity is considering applying to its Typescript sdk? This seems like a pretty straightforward way to significantly improve startup speed.

And if not then why not?

We’ve designed our flow with these specific measures to ensure the utmost security of our product. We encourage you to explore the approaches we’ve provided at your convenience.

But if you encrypt the session data when storing it locally then that should still allow you to take advantage of highly secure practices while not immensely sacrificing performance correct?

It is somewhat challenging that leveraging Amity necessitates a significant compromise in our app’s initial performance.

maybe this is something that you could consider adding the future versions

Hello, thank you for your feedback. We will be sure to pass it along to our team for consideration as a future improvement.

In order to modify the package, where can I fork the ts SDK?

Hello, this additional flow will need to be implemented separately on your end, rather than within the SDK.