diff --git a/.DS_Store b/.DS_Store index eb199b4..19c00da 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs b/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs index 968cd06..aaf4afe 100644 --- a/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs +++ b/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs @@ -19,9 +19,22 @@ public static Web3AuthApi getInstance() public IEnumerator authorizeSession(string key, Action callback) { - var request = UnityWebRequest.Get($"{baseAddress}/store/get?key={key}"); - yield return request.SendWebRequest(); + //var requestURL = $"{baseAddress}/store/get?key={key}"; + //var request = UnityWebRequest.Get(requestURL); + WWWForm data = new WWWForm(); + data.AddField("key", key); + + var request = UnityWebRequest.Post($"{baseAddress}/store/get", data); + yield return request.SendWebRequest(); + // Debug.Log("baseAddress =>" + baseAddress); + // Debug.Log("key =>" + key); + // //Debug.Log("request URL =>"+ requestURL); + // Debug.Log("request.isNetworkError =>" + request.isNetworkError); + // Debug.Log("request.isHttpError =>" + request.isHttpError); + // Debug.Log("request.isHttpError =>" + request.error); + // Debug.Log("request.result =>" + request.result); + // Debug.Log("request.downloadHandler.text =>" + request.downloadHandler.text); if (request.result == UnityWebRequest.Result.Success) { string result = request.downloadHandler.text; @@ -38,10 +51,20 @@ public IEnumerator logout(LogoutApiRequest logoutApiRequest, Action cal data.AddField("data", logoutApiRequest.data); data.AddField("signature", logoutApiRequest.signature); data.AddField("timeout", logoutApiRequest.timeout.ToString()); + // Debug.Log("key during logout session =>" + logoutApiRequest.key); var request = UnityWebRequest.Post($"{baseAddress}/store/set", data); yield return request.SendWebRequest(); + // Debug.Log("baseAddress =>" + baseAddress); + // Debug.Log("key =>" + logoutApiRequest.key); + // Debug.Log("request URL =>"+ requestURL); + // Debug.Log("request.isNetworkError =>" + request.isNetworkError); + // Debug.Log("request.isHttpError =>" + request.isHttpError); + // Debug.Log("request.isHttpError =>" + request.error); + // Debug.Log("request.result =>" + request.result); + // Debug.Log("request.downloadHandler.text =>" + request.downloadHandler.text); + if (request.result == UnityWebRequest.Result.Success) { string result = request.downloadHandler.text; @@ -52,22 +75,22 @@ public IEnumerator logout(LogoutApiRequest logoutApiRequest, Action cal } public IEnumerator createSession(LogoutApiRequest logoutApiRequest, Action callback) - { - WWWForm data = new WWWForm(); - data.AddField("key", logoutApiRequest.key); - data.AddField("data", logoutApiRequest.data); - data.AddField("signature", logoutApiRequest.signature); - data.AddField("timeout", logoutApiRequest.timeout.ToString()); - - var request = UnityWebRequest.Post($"{baseAddress}/store/set", data); - yield return request.SendWebRequest(); + { + WWWForm data = new WWWForm(); + data.AddField("key", logoutApiRequest.key); + data.AddField("data", logoutApiRequest.data); + data.AddField("signature", logoutApiRequest.signature); + data.AddField("timeout", logoutApiRequest.timeout.ToString()); + // Debug.Log("key during create session =>" + logoutApiRequest.key); + var request = UnityWebRequest.Post($"{baseAddress}/store/set", data); + yield return request.SendWebRequest(); - if (request.result == UnityWebRequest.Result.Success) - { - string result = request.downloadHandler.text; - callback(Newtonsoft.Json.JsonConvert.DeserializeObject(result)); - } - else - callback(null); + if (request.result == UnityWebRequest.Result.Success) + { + string result = request.downloadHandler.text; + callback(Newtonsoft.Json.JsonConvert.DeserializeObject(result)); } + else + callback(null); + } } diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index a948a4b..ffa71b0 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -310,6 +310,7 @@ public void setResultUrl(Uri uri) this.Enqueue(() => KeyStoreManagerUtils.savePreferenceData(KeyStoreManagerUtils.SESSION_ID, sessionId)); //call authorize session API + // Debug.Log("publickey after successful redirection from web. =>" + sessionId); this.Enqueue(() => authorizeSession(sessionId)); #if !UNITY_EDITOR && UNITY_WEBGL @@ -359,10 +360,12 @@ private void authorizeSession(string newSessionId) if (string.IsNullOrEmpty(newSessionId)) { sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); + // Debug.Log("sessionId during authorizeSession in if part =>" + sessionId); } else { sessionId = newSessionId; + // Debug.Log("sessionId during authorizeSession in else part =>" + sessionId); } if (!string.IsNullOrEmpty(sessionId)) @@ -460,7 +463,8 @@ private void sessionTimeOutAPI() try { KeyStoreManagerUtils.deletePreferencesData(KeyStoreManagerUtils.SESSION_ID); - KeyStoreManagerUtils.deletePreferencesData(web3AuthOptions.loginConfig?.Values.First()?.verifier); + if (web3AuthOptions.loginConfig != null) + KeyStoreManagerUtils.deletePreferencesData(web3AuthOptions.loginConfig?.Values.First()?.verifier); this.Enqueue(() => this.onLogout?.Invoke()); } @@ -480,6 +484,7 @@ private async Task createSession(string data, long sessionTime) { TaskCompletionSource createSessionResponse = new TaskCompletionSource(); var newSessionKey = KeyStoreManagerUtils.generateRandomSessionKey(); + // Debug.Log("newSessionKey =>" + newSessionKey); var ephemKey = KeyStoreManagerUtils.getPubKey(newSessionKey); var ivKey = KeyStoreManagerUtils.generateRandomBytes(); @@ -514,6 +519,7 @@ private async Task createSession(string data, long sessionTime) { try { + // Debug.Log("newSessionKey before saving into keystore =>" + newSessionKey); this.Enqueue(() => KeyStoreManagerUtils.savePreferenceData(KeyStoreManagerUtils.SESSION_ID, newSessionKey)); createSessionResponse.SetResult(newSessionKey); }