Skip to content

Commit

Permalink
feat: resolved PR comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Goel <[email protected]>
  • Loading branch information
grvgoel81 authored and Gaurav Goel committed May 21, 2024
1 parent 329c6f6 commit 6cc364a
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Assets/Plugins/Web3AuthSDK/Web3Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,14 @@ public void setResultUrl(Uri uri)
throw new UserCancelledException();
#endif
hash = hash.Remove(0, 1);
Dictionary<string, string> queryParameters = Utils.ParseQuery(uri.Query);

Dictionary<string, string> 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
Expand All @@ -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))
Expand Down

0 comments on commit 6cc364a

Please sign in to comment.