@@ -64,6 +64,7 @@ public static void setSignResponse(SignResponse _response)
6464
6565 [ SerializeField ]
6666 private Web3Auth . Network network ;
67+ private string redirectUrl ;
6768
6869 private static readonly Queue < Action > _executionQueue = new Queue < Action > ( ) ;
6970
@@ -108,7 +109,8 @@ public async void setOptions(Web3AuthOptions web3AuthOptions)
108109 {
109110 throw new Exception ( "Failed to fetch project config. Please try again later." ) ;
110111 } else {
111- authorizeSession ( "" , this . web3AuthOptions . redirectUrl . ToString ( ) ) ;
112+ var redirectUrl = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . REDIRECT_URL ) ;
113+ authorizeSession ( "" , redirectUrl ) ;
112114
113115 JsonSerializerSettings settings = new JsonSerializerSettings
114116 {
@@ -264,8 +266,11 @@ private void IncomingHttpRequest(IAsyncResult result)
264266
265267 private async void processRequest ( string path , LoginParams loginParams = null )
266268 {
269+ redirectUrl = this . initParams [ "redirectUrl" ] . ToString ( ) ;
270+
267271#if UNITY_STANDALONE || UNITY_EDITOR
268272 this . initParams [ "redirectUrl" ] = StartLocalWebserver ( ) ;
273+ redirectUrl = this . initParams [ "redirectUrl" ] . ToString ( ) . Replace ( "/complete/" , "" ) ;
269274#elif UNITY_WEBGL
270275 this . initParams [ "redirectUrl" ] = Utils . GetCurrentURL ( ) ;
271276#endif
@@ -326,8 +331,10 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w
326331 string sessionId = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . SESSION_ID ) ;
327332 if ( ! string . IsNullOrEmpty ( sessionId ) )
328333 {
334+ redirectUrl = this . initParams [ "redirectUrl" ] . ToString ( ) ;
329335 #if UNITY_STANDALONE || UNITY_EDITOR
330336 this . initParams [ "redirectUrl" ] = StartLocalWebserver ( ) ;
337+ redirectUrl = this . initParams [ "redirectUrl" ] . ToString ( ) . Replace ( "/complete/" , "" ) ;
331338 #elif UNITY_WEBGL
332339 this . initParams [ "redirectUrl" ] = Utils . GetCurrentURL ( ) ;
333340 #endif
@@ -425,9 +432,11 @@ public void setResultUrl(Uri uri)
425432 }
426433 string sessionId = sessionResponse . sessionId ;
427434 this . Enqueue ( ( ) => KeyStoreManagerUtils . savePreferenceData ( KeyStoreManagerUtils . SESSION_ID , sessionId ) ) ;
435+ this . Enqueue ( ( ) => KeyStoreManagerUtils . savePreferenceData ( KeyStoreManagerUtils . REDIRECT_URL , redirectUrl ) ) ;
428436
429437 //call authorize session API
430- this . Enqueue ( ( ) => authorizeSession ( sessionId , this . web3AuthOptions . redirectUrl . ToString ( ) ) ) ;
438+ //Debug.Log("redirectUrl: =>" + redirectUrl);
439+ this . Enqueue ( ( ) => authorizeSession ( sessionId , redirectUrl ) ) ;
431440
432441#if ! UNITY_EDITOR && UNITY_WEBGL
433442 if ( this . web3AuthResponse != null )
@@ -536,8 +545,10 @@ public async void request(ChainConfig chainConfig, string method, JArray request
536545 string sessionId = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . SESSION_ID ) ;
537546 if ( ! string . IsNullOrEmpty ( sessionId ) )
538547 {
548+ redirectUrl = this . initParams [ "redirectUrl" ] . ToString ( ) ;
539549 #if UNITY_STANDALONE || UNITY_EDITOR
540550 this . initParams [ "redirectUrl" ] = StartLocalWebserver ( ) ;
551+ redirectUrl = this . initParams [ "redirectUrl" ] . ToString ( ) . Replace ( "/complete/" , "" ) ;
541552 #elif UNITY_WEBGL
542553 this . initParams [ "redirectUrl" ] = Utils . GetCurrentURL ( ) ;
543554 #endif
@@ -614,8 +625,8 @@ private void authorizeSession(string newSessionId, string origin)
614625 if ( ! string . IsNullOrEmpty ( sessionId ) )
615626 {
616627 var pubKey = KeyStoreManagerUtils . getPubKey ( sessionId ) ;
617- Debug . Log ( "pubKey: =>" + pubKey ) ;
618- Debug . Log ( "origin: =>" + origin ) ;
628+ // Debug.Log("pubKey: =>" + pubKey);
629+ // Debug.Log("origin: =>" + origin);
619630 StartCoroutine ( Web3AuthApi . getInstance ( ) . authorizeSession ( pubKey , origin , ( response =>
620631 {
621632 if ( response != null )
@@ -643,6 +654,7 @@ private void authorizeSession(string newSessionId, string origin)
643654 if ( ! string . IsNullOrEmpty ( this . web3AuthResponse . sessionId ) )
644655 {
645656 KeyStoreManagerUtils . savePreferenceData ( KeyStoreManagerUtils . SESSION_ID , this . web3AuthResponse . sessionId ) ;
657+ //Debug.Log("redirectUrl: =>" + redirectUrl);
646658 }
647659
648660 if ( ! string . IsNullOrEmpty ( web3AuthResponse . userInfo ? . dappShare ) )
@@ -667,10 +679,11 @@ private void authorizeSession(string newSessionId, string origin)
667679 private void sessionTimeOutAPI ( )
668680 {
669681 string sessionId = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . SESSION_ID ) ;
682+ string redirectUrl = KeyStoreManagerUtils . getPreferencesData ( KeyStoreManagerUtils . REDIRECT_URL ) ;
670683 if ( ! string . IsNullOrEmpty ( sessionId ) )
671684 {
672685 var pubKey = KeyStoreManagerUtils . getPubKey ( sessionId ) ;
673- StartCoroutine ( Web3AuthApi . getInstance ( ) . authorizeSession ( pubKey , this . web3AuthOptions . redirectUrl . ToString ( ) , ( response =>
686+ StartCoroutine ( Web3AuthApi . getInstance ( ) . authorizeSession ( pubKey , redirectUrl , ( response =>
674687 {
675688 if ( response != null )
676689 {
0 commit comments