@@ -23,7 +23,7 @@ public enum ChainNamespace
2323 EIP155 , SOLANA
2424 }
2525
26- public enum BuildEnv
26+ public enum BuildEnv
2727 {
2828 PRODUCTION , STAGING , TESTING
2929 }
@@ -246,7 +246,7 @@ private async void request(string path, LoginParams loginParams = null, Dictiona
246246 this . initParams [ "redirectUrl" ] = Utils . GetCurrentURL ( ) ;
247247#endif
248248
249- loginParams . redirectUrl = new Uri ( StartLocalWebserver ( ) ) ;
249+ loginParams . redirectUrl = loginParams . redirectUrl ?? new Uri ( this . initParams [ "redirectUrl" ] . ToString ( ) ) ;
250250 Dictionary < string , object > paramMap = new Dictionary < string , object > ( ) ;
251251 paramMap [ "options" ] = this . initParams ;
252252 paramMap [ "params" ] = loginParams == null ? ( object ) new Dictionary < string , object > ( ) : ( object ) loginParams ;
@@ -258,30 +258,33 @@ private async void request(string path, LoginParams loginParams = null, Dictiona
258258 ( paramMap [ "params" ] as Dictionary < string , object > ) [ item . Key ] = item . Value ;
259259 }
260260
261- string loginId = await createSession ( JsonConvert . SerializeObject ( paramMap , Newtonsoft . Json . Formatting . None ,
261+ string loginId = await createSession ( JsonConvert . SerializeObject ( paramMap , Formatting . None ,
262262 new JsonSerializerSettings
263- {
264- NullValueHandling = NullValueHandling . Ignore
265- } ) , 600 ) ;
263+ {
264+ NullValueHandling = NullValueHandling . Ignore
265+ } ) , 600 ) ;
266266
267- if ( ! string . IsNullOrEmpty ( loginId ) ) {
267+ if ( ! string . IsNullOrEmpty ( loginId ) )
268+ {
268269 var loginIdObject = new Dictionary < string , string >
269270 {
270271 { "loginId" , loginId }
271272 } ;
272- string hash = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( JsonConvert . SerializeObject ( loginIdObject , Newtonsoft . Json . Formatting . None ,
273- new JsonSerializerSettings
274- {
275- NullValueHandling = NullValueHandling . Ignore
276- } ) ) ) ;
277-
278- UriBuilder uriBuilder = new UriBuilder ( this . web3AuthOptions . sdkUrl ) ;
279- uriBuilder . Path = path ;
280- uriBuilder . Fragment = "b64Params=" + hash ;
281-
282- Utils . LaunchUrl ( uriBuilder . ToString ( ) , this . initParams [ "redirectUrl" ] . ToString ( ) , gameObject . name ) ;
283- } else {
284- throw new Exception ( "Some went wrong. Please try again later." ) ;
273+ string hash = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( JsonConvert . SerializeObject ( loginIdObject , Formatting . None ,
274+ new JsonSerializerSettings
275+ {
276+ NullValueHandling = NullValueHandling . Ignore
277+ } ) ) ) ;
278+
279+ UriBuilder uriBuilder = new UriBuilder ( this . web3AuthOptions . sdkUrl ) ;
280+ uriBuilder . Path = path ;
281+ uriBuilder . Fragment = "b64Params=" + hash ;
282+
283+ Utils . LaunchUrl ( uriBuilder . ToString ( ) , this . initParams [ "redirectUrl" ] . ToString ( ) , gameObject . name ) ;
284+ }
285+ else
286+ {
287+ throw new Exception ( "Some went wrong. Please try again later." ) ;
285288 }
286289 }
287290
@@ -353,10 +356,13 @@ public void logout(Uri redirectUrl = null, string appState = null)
353356 private void authorizeSession ( string newSessionId )
354357 {
355358 string sessionId = "" ;
356- if ( string . IsNullOrEmpty ( newSessionId ) ) {
357- sessionId = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . SESSION_ID ) ;
358- } else {
359- sessionId = newSessionId ;
359+ if ( string . IsNullOrEmpty ( newSessionId ) )
360+ {
361+ sessionId = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . SESSION_ID ) ;
362+ }
363+ else
364+ {
365+ sessionId = newSessionId ;
360366 }
361367
362368 if ( ! string . IsNullOrEmpty ( sessionId ) )
@@ -386,7 +392,8 @@ private void authorizeSession(string newSessionId)
386392 throw new UnKnownException ( this . web3AuthResponse . error ?? "Something went wrong" ) ;
387393 }
388394
389- if ( ! string . IsNullOrEmpty ( this . web3AuthResponse . sessionId ) ) {
395+ if ( ! string . IsNullOrEmpty ( this . web3AuthResponse . sessionId ) )
396+ {
390397 KeyStoreManagerUtils . savePreferenceData ( KeyStoreManagerUtils . SESSION_ID , this . web3AuthResponse . sessionId ) ;
391398 }
392399
@@ -469,7 +476,8 @@ private void sessionTimeOutAPI()
469476 }
470477 }
471478
472- private async Task < string > createSession ( string data , long sessionTime ) {
479+ private async Task < string > createSession ( string data , long sessionTime )
480+ {
473481 TaskCompletionSource < string > createSessionResponse = new TaskCompletionSource < string > ( ) ;
474482 var newSessionKey = KeyStoreManagerUtils . generateRandomSessionKey ( ) ;
475483 var ephemKey = KeyStoreManagerUtils . getPubKey ( newSessionKey ) ;
@@ -514,7 +522,9 @@ private async Task<string> createSession(string data, long sessionTime) {
514522 createSessionResponse . SetException ( new Exception ( "Something went wrong. Please try again later." ) ) ;
515523 Debug . LogError ( ex . Message ) ;
516524 }
517- } else {
525+ }
526+ else
527+ {
518528 createSessionResponse . SetException ( new Exception ( "Something went wrong. Please try again later." ) ) ;
519529 }
520530 }
0 commit comments