From 6cc364ac011e4577a547571fee49d5b45c9a88bd Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 21 May 2024 16:51:39 +0530 Subject: [PATCH] feat: resolved PR comments. Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 6fa8716..18b1675 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -374,12 +374,14 @@ public void setResultUrl(Uri uri) throw new UserCancelledException(); #endif hash = hash.Remove(0, 1); - Dictionary queryParameters = Utils.ParseQuery(uri.Query); + Dictionary queryParameters = Utils.ParseQuery(uri.Query); if (queryParameters.Keys.Contains("error")) throw new UnKnownException(queryParameters["error"]); - string b64Params = hash.Split('=')[1]; + string newUriString = "http://" + uri.Host + "?" + hash; + Uri newUri = new Uri(newUriString); + string b64Params = getQueryParamValue(newUri, "b64Params"); string decodedString = decodeBase64Params(b64Params); SessionResponse sessionResponse = null; try @@ -404,6 +406,25 @@ public void setResultUrl(Uri uri) #endif } + private string getQueryParamValue(Uri uri, string key) + { + string value = ""; + if (uri.Query != null && uri.Query.Length > 0) + { + string[] queryParameters = uri.Query.Substring(1).Split('&'); + foreach (string queryParameter in queryParameters) + { + string[] keyValue = queryParameter.Split('='); + if (keyValue[0] == key) + { + value = keyValue[1]; + break; + } + } + } + return value; + } + private string decodeBase64Params(string base64Params) { if(string.IsNullOrEmpty(base64Params))