From b0a14fb067b1079ba03f890e3976b65ed255e9e4 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Sat, 30 Dec 2023 16:24:47 +0530 Subject: [PATCH 01/24] feat: add launchWalletServices() function in Web3Auth.cs Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Types/Web3AuthOptions.cs | 11 ++++ Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 58 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 7887975..3b4a1de 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -21,6 +21,17 @@ public string sdkUrl { } public const string openLoginVersion = "v6"; + public string walletSdkUrl { + get { + if (buildEnv == Web3Auth.BuildEnv.STAGING) + return "https://staging-wallet.web3auth.io"; + else if (buildEnv == Web3Auth.BuildEnv.TESTING) + return "https://develop-wallet.web3auth.io"; + else + return "https://wallet.web3auth.io"; + } + set { } + } public WhiteLabelData? whiteLabel { get; set; } public Dictionary? loginConfig { get; set; } public bool? useCoreKitKey { get; set; } = false; diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index e37dd14..d68d5e3 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -294,6 +294,64 @@ private async void request(string path, LoginParams loginParams = null, Dictiona } } + private async void launchWalletServices(string path, LoginParams loginParams = null, Dictionary extraParams = null) + { + string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); + if (!string.IsNullOrEmpty(sessionId)) + { + #if UNITY_STANDALONE || UNITY_EDITOR + this.initParams["redirectUrl"] = StartLocalWebserver(); + #elif UNITY_WEBGL + this.initParams["redirectUrl"] = Utils.GetCurrentURL(); + #endif + + loginParams.redirectUrl = loginParams.redirectUrl ?? new Uri(this.initParams["redirectUrl"].ToString()); + Dictionary paramMap = new Dictionary(); + paramMap["options"] = this.initParams; + paramMap["params"] = loginParams == null ? (object)new Dictionary() : (object)loginParams; + paramMap["actionType"] = "login"; + + if (extraParams != null && extraParams.Count > 0) + foreach (KeyValuePair item in extraParams) + { + (paramMap["params"] as Dictionary)[item.Key] = item.Value; + } + //Debug.Log("paramMap: =>" + JsonConvert.SerializeObject(paramMap)); + string loginId = await createSession(JsonConvert.SerializeObject(paramMap, Formatting.None, + new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }), 600); + + if (!string.IsNullOrEmpty(loginId)) + { + var loginIdObject = new Dictionary + { + { "loginId", loginId } + { "sessionId", sessionId } + }; + string hash = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(loginIdObject, Formatting.None, + new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + }))); + + UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.sdkUrl); + uriBuilder.Path = path; + uriBuilder.Fragment = "b64Params=" + hash; + + Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString(), gameObject.name); + } + else + { + throw new Exception("Some went wrong. Please try again later."); + } + } else + { + throw new Exception("SessionId not found. Please login first."); + } + } + public void setResultUrl(Uri uri) { string hash = uri.Fragment; From e3b6773254db18106afd8e3c634626aa8ec79e66 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 3 Jan 2024 09:26:51 +0530 Subject: [PATCH 02/24] feat: add launchWalletServices() function in Web3Auth.cs Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index d68d5e3..0b2a22e 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -336,7 +336,7 @@ private async void launchWalletServices(string path, LoginParams loginParams = n NullValueHandling = NullValueHandling.Ignore }))); - UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.sdkUrl); + UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.walletSdkUrl); uriBuilder.Path = path; uriBuilder.Fragment = "b64Params=" + hash; From e1f0488e4de1a2897a09ee08f2077ebea75f1cd4 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 5 Jan 2024 12:34:06 +0530 Subject: [PATCH 03/24] feat: add setupMfa() function in Web3Auth.cs Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Samples/Web3AuthSample.cs | 5 +++ Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 36 +++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index e03a424..2c31ecd 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -80,6 +80,7 @@ void Start() }); web3Auth.onLogin += onLogin; web3Auth.onLogout += onLogout; + web3Auth.onMFASetup += onMFASetup; emailAddressField.gameObject.SetActive(false); logoutButton.gameObject.SetActive(false); @@ -112,6 +113,10 @@ private void onLogout() loginResponseText.text = ""; } + private void onMFASetup(bool response) { + Debug.Log("MFA Setup: " + response); + } + private void onVerifierDropDownChange(int selectedIndex) { diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 0b2a22e..9b8ac42 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -45,6 +45,7 @@ public enum Language public event Action onLogin; public event Action onLogout; + public event Action onMFASetup; [SerializeField] private string clientId; @@ -256,7 +257,13 @@ private async void request(string path, LoginParams loginParams = null, Dictiona Dictionary paramMap = new Dictionary(); paramMap["options"] = this.initParams; paramMap["params"] = loginParams == null ? (object)new Dictionary() : (object)loginParams; - paramMap["actionType"] = "login"; + paramMap["actionType"] = path; + + if (path == "enable_mfa") + { + string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); + paramMap["sessionId"] = sessionId; + } if (extraParams != null && extraParams.Count > 0) foreach (KeyValuePair item in extraParams) @@ -283,7 +290,7 @@ private async void request(string path, LoginParams loginParams = null, Dictiona }))); UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.sdkUrl); - uriBuilder.Path = path; + uriBuilder.Path = "start"; uriBuilder.Fragment = "b64Params=" + hash; Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString(), gameObject.name); @@ -398,7 +405,7 @@ public void login(LoginParams loginParams) } } - request("start", loginParams); + request("login", loginParams); } public void logout(Dictionary extraParams) @@ -418,6 +425,28 @@ public void logout(Uri redirectUrl = null, string appState = null) logout(extraParams); } + public void setupMFA(LoginParams loginParams) + { + string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); + if (!string.IsNullOrEmpty(sessionId)) + { + if (web3AuthOptions.loginConfig != null) + { + var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); + var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); + if (!string.IsNullOrEmpty(share)) + { + loginParams.dappShare = share; + } + } + request("enable_mfa", loginParams); + } + else + { + throw new Exception("SessionId not found. Please login first."); + } + } + private void authorizeSession(string newSessionId) { string sessionId = ""; @@ -475,6 +504,7 @@ private void authorizeSession(string newSessionId) this.Enqueue(() => this.onLogout?.Invoke()); else this.Enqueue(() => this.onLogin?.Invoke(this.web3AuthResponse)); + this.Enqueue(() => this.onMFASetup?.Invoke(true)); } } From 71a28cfe2ce54340b49ed60ddfafd2134a1df950 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 26 Jan 2024 11:00:08 +0530 Subject: [PATCH 04/24] feat: example added for setupMfa() function Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Samples/Web3AuthSample.cs | 23 +++++++++++++++++++ Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index 2c31ecd..f443d22 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -40,6 +40,9 @@ public class Web3AuthSample : MonoBehaviour [SerializeField] Button logoutButton; + [SerializeField] + Button mfaSetupButton; + void Start() { var loginConfigItem = new LoginConfigItem() @@ -150,4 +153,24 @@ private void logout() { web3Auth.logout(); } + + private void mfaSetup() + { + var selectedProvider = verifierList[verifierDropdown.value].loginProvider; + + var options = new LoginParams() + { + loginProvider = selectedProvider, + mfaLevel = MFALevel.MANDATORY + }; + + if (selectedProvider == Provider.EMAIL_PASSWORDLESS) + { + options.extraLoginOptions = new ExtraLoginOptions() + { + login_hint = emailAddressField.text + }; + } + web3Auth.setupMFA(options); + } } diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 9b8ac42..f61bf3f 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -334,7 +334,7 @@ private async void launchWalletServices(string path, LoginParams loginParams = n { var loginIdObject = new Dictionary { - { "loginId", loginId } + { "loginId", loginId }, { "sessionId", sessionId } }; string hash = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(loginIdObject, Formatting.None, From 3b06947c6562f5d5758c981039599f5569274169 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 6 Feb 2024 09:19:34 +0530 Subject: [PATCH 05/24] feat: example added for setupMfa() and launchWalletServices() function Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Samples/Web3AuthSample.cs | 34 ++- .../Web3AuthSDK/Samples/Web3AuthSample.unity | 239 ++++++++++++++++-- .../Plugins/Web3AuthSDK/Types/ChainConfig.cs | 13 + .../Web3AuthSDK/Types/Web3AuthOptions.cs | 6 +- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 8 +- 5 files changed, 267 insertions(+), 33 deletions(-) create mode 100644 Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index f443d22..e5a4868 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -79,7 +79,14 @@ void Start() buildEnv = BuildEnv.TESTING, redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"), network = Web3Auth.Network.SAPPHIRE_MAINNET, - sessionTime = 86400 + sessionTime = 86400, + chainConfig = new ChainConfig() + { + chainId = "0x1", + rpcTarget = "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0", + ticker = "ETH", + chainNamespace = Web3Auth.ChainNamespace.EIP155 + } }); web3Auth.onLogin += onLogin; web3Auth.onLogout += onLogout; @@ -87,9 +94,11 @@ void Start() emailAddressField.gameObject.SetActive(false); logoutButton.gameObject.SetActive(false); + //mfaSetupButton.gameObject.SetActive(false); loginButton.onClick.AddListener(login); logoutButton.onClick.AddListener(logout); + //mfaSetupButton.onClick.AddListener(setupMFA); verifierDropdown.AddOptions(verifierList.Select(x => x.name).ToList()); verifierDropdown.onValueChanged.AddListener(onVerifierDropDownChange); @@ -105,6 +114,7 @@ private void onLogin(Web3AuthResponse response) verifierDropdown.gameObject.SetActive(false); emailAddressField.gameObject.SetActive(false); logoutButton.gameObject.SetActive(true); + //mfaSetupButton.gameObject.SetActive(true); } private void onLogout() @@ -112,6 +122,7 @@ private void onLogout() loginButton.gameObject.SetActive(true); verifierDropdown.gameObject.SetActive(true); logoutButton.gameObject.SetActive(false); + //mfaSetupButton.gameObject.SetActive(false); loginResponseText.text = ""; } @@ -154,7 +165,7 @@ private void logout() web3Auth.logout(); } - private void mfaSetup() + private void setupMFA() { var selectedProvider = verifierList[verifierDropdown.value].loginProvider; @@ -173,4 +184,23 @@ private void mfaSetup() } web3Auth.setupMFA(options); } + + private void launchWalletServices() { + var selectedProvider = verifierList[verifierDropdown.value].loginProvider; + + var options = new LoginParams() + { + loginProvider = selectedProvider + }; + + if (selectedProvider == Provider.EMAIL_PASSWORDLESS) + { + options.extraLoginOptions = new ExtraLoginOptions() + { + login_hint = emailAddressField.text + }; + } + + web3Auth.launchWalletServices(options); + } } diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity index f68e520..fe3de11 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity @@ -156,7 +156,6 @@ RectTransform: m_Children: - {fileID: 1131375143} m_Father: {fileID: 601569998} - m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0} @@ -276,7 +275,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 601569998} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1} @@ -354,7 +352,6 @@ RectTransform: m_Children: - {fileID: 1824598102} m_Father: {fileID: 1335677077} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -445,7 +442,6 @@ RectTransform: m_Children: - {fileID: 1081189870} m_Father: {fileID: 1335677077} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -625,13 +621,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 284411855} + serializedVersion: 2 m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!850595691 &334259782 LightingSettings: @@ -728,7 +724,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 630807054} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} @@ -859,13 +854,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 500698455} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &500698459 MonoBehaviour: @@ -884,6 +879,7 @@ MonoBehaviour: loginButton: {fileID: 1509531156} loginResponseText: {fileID: 529774073} logoutButton: {fileID: 14516521} + mfaSetupButton: {fileID: 0} --- !u!114 &500698460 MonoBehaviour: m_ObjectHideFlags: 0 @@ -930,7 +926,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 601569998} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.09670371, y: 0.23700002} m_AnchorMax: {x: 0.90000004, y: 0.7063542} @@ -1012,7 +1007,6 @@ RectTransform: - {fileID: 1035121763} - {fileID: 2108975589} m_Father: {fileID: 1824598102} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} @@ -1167,8 +1161,8 @@ RectTransform: - {fileID: 529774072} - {fileID: 1509531155} - {fileID: 14516520} + - {fileID: 1718326283} m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} @@ -1210,7 +1204,6 @@ RectTransform: - {fileID: 448986212} - {fileID: 1335677077} m_Father: {fileID: 601569998} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1342,7 +1335,6 @@ RectTransform: - {fileID: 1709238521} - {fileID: 1185819983} m_Father: {fileID: 601569998} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1455,6 +1447,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 711505054} m_CullTransparentMesh: 0 +--- !u!1 &850437700 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 850437701} + - component: {fileID: 850437703} + - component: {fileID: 850437702} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &850437701 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 850437700} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1718326283} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &850437702 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 850437700} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 24 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 2 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Setup MFA +--- !u!222 &850437703 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 850437700} + m_CullTransparentMesh: 1 --- !u!1 &1035121762 GameObject: m_ObjectHideFlags: 0 @@ -1486,7 +1557,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 531633353} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} @@ -1561,7 +1631,6 @@ RectTransform: m_Children: - {fileID: 1803321667} m_Father: {fileID: 235747597} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1599,7 +1668,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 14516520} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1708,13 +1776,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1134688701} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1185819982 GameObject: @@ -1747,7 +1815,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 711505055} - m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1827,7 +1894,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1509531155} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1907,7 +1973,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 630807054} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1990,7 +2055,6 @@ RectTransform: - {fileID: 159681585} - {fileID: 235747597} m_Father: {fileID: 630807054} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 0} @@ -2098,7 +2162,6 @@ RectTransform: m_Children: - {fileID: 1233346735} m_Father: {fileID: 601569998} - m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0} @@ -2218,7 +2281,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 711505055} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -2267,6 +2329,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1709238520} m_CullTransparentMesh: 0 +--- !u!1 &1718326282 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1718326283} + - component: {fileID: 1718326286} + - component: {fileID: 1718326285} + - component: {fileID: 1718326284} + m_Layer: 5 + m_Name: SetupMFA + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1718326283 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1718326282} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 850437701} + m_Father: {fileID: 601569998} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 400, y: -380} + m_SizeDelta: {x: 370.6666, y: 90.55688} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1718326284 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1718326282} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1718326285} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &1718326285 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1718326282} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.15294118, g: 0.68235296, b: 0.3764706, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1718326286 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1718326282} + m_CullTransparentMesh: 1 --- !u!1 &1803321666 GameObject: m_ObjectHideFlags: 0 @@ -2298,7 +2481,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1081189870} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -2374,7 +2556,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 531633353} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -2449,7 +2630,6 @@ RectTransform: m_Children: - {fileID: 531633353} m_Father: {fileID: 159681585} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} @@ -2487,7 +2667,6 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 531633353} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -2536,3 +2715,11 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2108975588} m_CullTransparentMesh: 0 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 500698458} + - {fileID: 284411857} + - {fileID: 601569998} + - {fileID: 1134688704} diff --git a/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs b/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs new file mode 100644 index 0000000..bf441e9 --- /dev/null +++ b/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +#nullable enable +public class ChainConfig { + public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155; + public int decimals { get; set; } = 18; + public string blockExplorerUrl { get; set; } = null; + public string chainId { get; set; } + public string displayName { get; set; } = null; + public string logo { get; set; } = null; + public string rpcTarget { get; set; } + public string ticker { get; set; } + public string tickerName { get; set; } = null; +} \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 3b4a1de..3871532 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -21,14 +21,15 @@ public string sdkUrl { } public const string openLoginVersion = "v6"; + public const string walletServicesVersion = "v1"; public string walletSdkUrl { get { if (buildEnv == Web3Auth.BuildEnv.STAGING) - return "https://staging-wallet.web3auth.io"; + return "https://staging-wallet.web3auth.io/{walletServicesVersion}"; else if (buildEnv == Web3Auth.BuildEnv.TESTING) return "https://develop-wallet.web3auth.io"; else - return "https://wallet.web3auth.io"; + return "https://wallet.web3auth.io/{walletServicesVersion}"; } set { } } @@ -38,4 +39,5 @@ public string walletSdkUrl { public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155; public MfaSettings? mfaSettings { get; set; } = null; public int sessionTime { get; set; } = 86400; + public ChainConfig chainConfig { get; set; } } \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index f61bf3f..d7efa19 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -128,6 +128,9 @@ public void setOptions(Web3AuthOptions web3AuthOptions) if (this.web3AuthOptions.sessionTime != null) this.initParams["sessionTime"] = this.web3AuthOptions.sessionTime; + + if (this.web3AuthOptions.chainConfig != null) + this.initParams["chainConfig"] = JsonConvert.SerializeObject(this.web3AuthOptions.chainConfig, settings); } private void onDeepLinkActivated(string url) @@ -301,7 +304,7 @@ private async void request(string path, LoginParams loginParams = null, Dictiona } } - private async void launchWalletServices(string path, LoginParams loginParams = null, Dictionary extraParams = null) + public async void launchWalletServices(LoginParams loginParams, Dictionary extraParams = null) { string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) @@ -316,7 +319,6 @@ private async void launchWalletServices(string path, LoginParams loginParams = n Dictionary paramMap = new Dictionary(); paramMap["options"] = this.initParams; paramMap["params"] = loginParams == null ? (object)new Dictionary() : (object)loginParams; - paramMap["actionType"] = "login"; if (extraParams != null && extraParams.Count > 0) foreach (KeyValuePair item in extraParams) @@ -344,7 +346,7 @@ private async void launchWalletServices(string path, LoginParams loginParams = n }))); UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.walletSdkUrl); - uriBuilder.Path = path; + uriBuilder.Path = "wallet"; uriBuilder.Fragment = "b64Params=" + hash; Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString(), gameObject.name); From 5490e522187065d0bb1052def5b4ab57626d8398 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 6 Feb 2024 11:47:48 +0530 Subject: [PATCH 06/24] feat: example added for launchWalletServices() function Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Samples/Web3AuthSample.cs | 15 +- .../Web3AuthSDK/Samples/Web3AuthSample.unity | 261 +++++++++++++++++- 2 files changed, 270 insertions(+), 6 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index e5a4868..e3b2d63 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -43,6 +43,9 @@ public class Web3AuthSample : MonoBehaviour [SerializeField] Button mfaSetupButton; + [SerializeField] + Button launchWalletServicesButton; + void Start() { var loginConfigItem = new LoginConfigItem() @@ -94,11 +97,13 @@ void Start() emailAddressField.gameObject.SetActive(false); logoutButton.gameObject.SetActive(false); - //mfaSetupButton.gameObject.SetActive(false); + mfaSetupButton.gameObject.SetActive(false); + launchWalletServicesButton.gameObject.SetActive(false); loginButton.onClick.AddListener(login); logoutButton.onClick.AddListener(logout); - //mfaSetupButton.onClick.AddListener(setupMFA); + mfaSetupButton.onClick.AddListener(setupMFA); + launchWalletServicesButton.onClick.AddListener(launchWalletServices); verifierDropdown.AddOptions(verifierList.Select(x => x.name).ToList()); verifierDropdown.onValueChanged.AddListener(onVerifierDropDownChange); @@ -114,7 +119,8 @@ private void onLogin(Web3AuthResponse response) verifierDropdown.gameObject.SetActive(false); emailAddressField.gameObject.SetActive(false); logoutButton.gameObject.SetActive(true); - //mfaSetupButton.gameObject.SetActive(true); + mfaSetupButton.gameObject.SetActive(true); + launchWalletServicesButton.gameObject.SetActive(true); } private void onLogout() @@ -122,7 +128,8 @@ private void onLogout() loginButton.gameObject.SetActive(true); verifierDropdown.gameObject.SetActive(true); logoutButton.gameObject.SetActive(false); - //mfaSetupButton.gameObject.SetActive(false); + mfaSetupButton.gameObject.SetActive(false); + launchWalletServicesButton.gameObject.SetActive(false); loginResponseText.text = ""; } diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity index fe3de11..3a3956d 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.unity @@ -879,7 +879,8 @@ MonoBehaviour: loginButton: {fileID: 1509531156} loginResponseText: {fileID: 529774073} logoutButton: {fileID: 14516521} - mfaSetupButton: {fileID: 0} + mfaSetupButton: {fileID: 1718326284} + launchWalletServicesButton: {fileID: 890593064} --- !u!114 &500698460 MonoBehaviour: m_ObjectHideFlags: 0 @@ -895,6 +896,140 @@ MonoBehaviour: clientId: BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ redirectUri: torusapp://com.torus.Web3AuthUnity/auth network: 5 +--- !u!1 &505954357 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 505954358} + - component: {fileID: 505954360} + - component: {fileID: 505954359} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &505954358 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 505954357} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 890593063} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &505954359 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 505954357} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Launch WalletServices + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 22 + m_fontSizeBase: 22 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 1 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &505954360 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 505954357} + m_CullTransparentMesh: 1 --- !u!1 &529774071 GameObject: m_ObjectHideFlags: 0 @@ -1162,6 +1297,7 @@ RectTransform: - {fileID: 1509531155} - {fileID: 14516520} - {fileID: 1718326283} + - {fileID: 890593063} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -1526,6 +1662,127 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 850437700} m_CullTransparentMesh: 1 +--- !u!1 &890593062 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 890593063} + - component: {fileID: 890593066} + - component: {fileID: 890593065} + - component: {fileID: 890593064} + m_Layer: 5 + m_Name: Launch Wallet Services + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &890593063 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890593062} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 505954358} + m_Father: {fileID: 601569998} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -570} + m_SizeDelta: {x: 370.6666, y: 90.55688} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &890593064 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890593062} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 890593065} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &890593065 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890593062} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.15294118, g: 0.68235296, b: 0.3764706, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &890593066 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 890593062} + m_CullTransparentMesh: 1 --- !u!1 &1035121762 GameObject: m_ObjectHideFlags: 0 @@ -2365,7 +2622,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 400, y: -380} + m_AnchoredPosition: {x: 0, y: -470} m_SizeDelta: {x: 370.6666, y: 90.55688} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1718326284 From 7d74e2a87ce6a81af97e90ea7bf4bdf145d3861a Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 9 Feb 2024 13:25:50 +0530 Subject: [PATCH 07/24] feat: wallet services changes added Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Samples/Web3AuthSample.cs | 24 +++++++++---------- .../Plugins/Web3AuthSDK/Types/LoginParams.cs | 1 + .../Plugins/Web3AuthSDK/Types/MfaSettings.cs | 8 ++++++- .../Web3AuthSDK/Types/SessionResponse.cs | 4 ++++ .../Web3AuthSDK/Types/Web3AuthOptions.cs | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index e3b2d63..d10acc0 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -82,14 +82,7 @@ void Start() buildEnv = BuildEnv.TESTING, redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"), network = Web3Auth.Network.SAPPHIRE_MAINNET, - sessionTime = 86400, - chainConfig = new ChainConfig() - { - chainId = "0x1", - rpcTarget = "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0", - ticker = "ETH", - chainNamespace = Web3Auth.ChainNamespace.EIP155 - } + sessionTime = 86400 }); web3Auth.onLogin += onLogin; web3Auth.onLogout += onLogout; @@ -102,7 +95,7 @@ void Start() loginButton.onClick.AddListener(login); logoutButton.onClick.AddListener(logout); - mfaSetupButton.onClick.AddListener(setupMFA); + mfaSetupButton.onClick.AddListener(enableMFA); launchWalletServicesButton.onClick.AddListener(launchWalletServices); verifierDropdown.AddOptions(verifierList.Select(x => x.name).ToList()); @@ -172,7 +165,7 @@ private void logout() web3Auth.logout(); } - private void setupMFA() + private void enableMFA() { var selectedProvider = verifierList[verifierDropdown.value].loginProvider; @@ -189,7 +182,7 @@ private void setupMFA() login_hint = emailAddressField.text }; } - web3Auth.setupMFA(options); + web3Auth.enableMFA(options); } private void launchWalletServices() { @@ -208,6 +201,13 @@ private void launchWalletServices() { }; } - web3Auth.launchWalletServices(options); + var chainConfig = new ChainConfig() + { + chainId = "0x1", + rpcTarget = "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0", + ticker = "ETH", + chainNamespace = Web3Auth.ChainNamespace.EIP155 + }; + web3Auth.launchWalletServices(options, chainConfig); } } diff --git a/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs b/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs index 63246e2..ff3f7f4 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs @@ -10,4 +10,5 @@ public class LoginParams public MFALevel mfaLevel { get; set; } public Curve curve { get; set; } = Curve.SECP256K1; + public string dappUrl { get; set; } } \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Types/MfaSettings.cs b/Assets/Plugins/Web3AuthSDK/Types/MfaSettings.cs index 388d36f..aafdde1 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/MfaSettings.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/MfaSettings.cs @@ -4,17 +4,23 @@ public class MfaSettings public MfaSetting? backUpShareFactor { get; set; } public MfaSetting? socialBackupFactor { get; set; } public MfaSetting? passwordFactor { get; set; } + public MfaSetting? passkeysFactor { get; set; } + public MfaSetting? authenticatorFactor { get; set; } // Constructors public MfaSettings( MfaSetting? deviceShareFactor, MfaSetting? backUpShareFactor, MfaSetting? socialBackupFactor, - MfaSetting? passwordFactor) + MfaSetting? passwordFactor, + MfaSetting? passkeysFactor, + MfaSetting? authenticatorFactor) { this.deviceShareFactor = deviceShareFactor; this.backUpShareFactor = backUpShareFactor; this.socialBackupFactor = socialBackupFactor; this.passwordFactor = passwordFactor; + this.passkeysFactor = passkeysFactor; + this.authenticatorFactor = authenticatorFactor; } } \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs b/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs new file mode 100644 index 0000000..e75ef7a --- /dev/null +++ b/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs @@ -0,0 +1,4 @@ +public class SessionResponse +{ + public string sessionId { get; set; } +} \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 3871532..342f3ad 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -39,5 +39,5 @@ public string walletSdkUrl { public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155; public MfaSettings? mfaSettings { get; set; } = null; public int sessionTime { get; set; } = 86400; - public ChainConfig chainConfig { get; set; } + public ChainConfig? chainConfig { get; set; } } \ No newline at end of file From d9641708b9010c2fe8eed13ea1620e75456bc5b8 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 28 Feb 2024 09:50:05 +0530 Subject: [PATCH 08/24] feat: wallet services and enableMFA changes added Signed-off-by: Gaurav Goel --- .../Web3AuthSDK/Types/SessionResponse.cs | 2 +- .../Web3AuthSDK/Types/Web3AuthOptions.cs | 2 +- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 93 +++++++++++-------- 3 files changed, 55 insertions(+), 42 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs b/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs index e75ef7a..ae516fe 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/SessionResponse.cs @@ -1,4 +1,4 @@ public class SessionResponse { - public string sessionId { get; set; } + public string sessionId; } \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 342f3ad..d391aee 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -19,7 +19,7 @@ public string sdkUrl { } set { } } - public const string openLoginVersion = "v6"; + public const string openLoginVersion = "v7"; public const string walletServicesVersion = "v1"; public string walletSdkUrl { diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index d7efa19..7673464 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -35,7 +35,7 @@ public enum ThemeModes public enum Language { - en, de, ja, ko, zh, es, fr, pt, nl + en, de, ja, ko, zh, es, fr, pt, nl, tr } private Web3AuthOptions web3AuthOptions; @@ -128,9 +128,6 @@ public void setOptions(Web3AuthOptions web3AuthOptions) if (this.web3AuthOptions.sessionTime != null) this.initParams["sessionTime"] = this.web3AuthOptions.sessionTime; - - if (this.web3AuthOptions.chainConfig != null) - this.initParams["chainConfig"] = JsonConvert.SerializeObject(this.web3AuthOptions.chainConfig, settings); } private void onDeepLinkActivated(string url) @@ -248,7 +245,7 @@ private void IncomingHttpRequest(IAsyncResult result) } #endif - private async void request(string path, LoginParams loginParams = null, Dictionary extraParams = null) + private async void request(string path, LoginParams loginParams = null) { #if UNITY_STANDALONE || UNITY_EDITOR this.initParams["redirectUrl"] = StartLocalWebserver(); @@ -268,11 +265,6 @@ private async void request(string path, LoginParams loginParams = null, Dictiona paramMap["sessionId"] = sessionId; } - if (extraParams != null && extraParams.Count > 0) - foreach (KeyValuePair item in extraParams) - { - (paramMap["params"] as Dictionary)[item.Key] = item.Value; - } //Debug.Log("paramMap: =>" + JsonConvert.SerializeObject(paramMap)); string loginId = await createSession(JsonConvert.SerializeObject(paramMap, Formatting.None, new JsonSerializerSettings @@ -295,6 +287,7 @@ private async void request(string path, LoginParams loginParams = null, Dictiona UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.sdkUrl); uriBuilder.Path = "start"; uriBuilder.Fragment = "b64Params=" + hash; + //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString(), gameObject.name); } @@ -304,8 +297,8 @@ private async void request(string path, LoginParams loginParams = null, Dictiona } } - public async void launchWalletServices(LoginParams loginParams, Dictionary extraParams = null) - { + public async void launchWalletServices(LoginParams loginParams, ChainConfig chainConfig, string path = "wallet") + { string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) { @@ -316,15 +309,11 @@ public async void launchWalletServices(LoginParams loginParams, Dictionary paramMap = new Dictionary(); paramMap["options"] = this.initParams; paramMap["params"] = loginParams == null ? (object)new Dictionary() : (object)loginParams; - if (extraParams != null && extraParams.Count > 0) - foreach (KeyValuePair item in extraParams) - { - (paramMap["params"] as Dictionary)[item.Key] = item.Value; - } //Debug.Log("paramMap: =>" + JsonConvert.SerializeObject(paramMap)); string loginId = await createSession(JsonConvert.SerializeObject(paramMap, Formatting.None, new JsonSerializerSettings @@ -346,7 +335,7 @@ public async void launchWalletServices(LoginParams loginParams, Dictionary(decodedString); + } + catch (Exception e) + { + Debug.Log("Failed to decode JSON: " + e.Message); + } + string sessionId = sessionResponse.sessionId; 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 @@ -394,6 +391,23 @@ public void setResultUrl(Uri uri) #endif } + private string decodeBase64Params(string base64Params) + { + if(string.IsNullOrEmpty(base64Params)) + return string.Empty; + // Replace URL-safe characters + base64Params = base64Params.Replace('-', '+').Replace('_', '/'); + var d = base64Params.Length % 4; + if (d != 0) + { + base64Params = base64Params.TrimEnd('='); + base64Params += d % 2 > 0 ? "=" : "=="; + } + byte[] bytes = Convert.FromBase64String(base64Params); + var decodedString = System.Text.Encoding.UTF8.GetString(bytes); + return decodedString; + } + public void login(LoginParams loginParams) { if (web3AuthOptions.loginConfig != null) @@ -427,27 +441,27 @@ public void logout(Uri redirectUrl = null, string appState = null) logout(extraParams); } - public void setupMFA(LoginParams loginParams) + public void enableMFA(LoginParams loginParams) + { + string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); + if (!string.IsNullOrEmpty(sessionId)) { - string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); - if (!string.IsNullOrEmpty(sessionId)) - { - if (web3AuthOptions.loginConfig != null) - { - var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); - var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); - if (!string.IsNullOrEmpty(share)) - { - loginParams.dappShare = share; - } - } - request("enable_mfa", loginParams); - } - else + if (web3AuthOptions.loginConfig != null) { - throw new Exception("SessionId not found. Please login first."); + var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); + var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); + if (!string.IsNullOrEmpty(share)) + { + loginParams.dappShare = share; + } } + request("enable_mfa", loginParams); + } + else + { + throw new Exception("SessionId not found. Please login first."); } + } private void authorizeSession(string newSessionId) { @@ -460,7 +474,6 @@ private void authorizeSession(string newSessionId) else { sessionId = newSessionId; - // Debug.Log("sessionId during authorizeSession in else part =>" + sessionId); } if (!string.IsNullOrEmpty(sessionId)) From 0627fe7bd4666de0e5e179a164692769498f6f5d Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Thu, 29 Feb 2024 12:48:35 +0530 Subject: [PATCH 09/24] feat: changes for unityeditor ws added. Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 7673464..5a76a15 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -233,11 +233,10 @@ private void IncomingHttpRequest(IAsyncResult result) System.IO.Stream output = httpResponse.OutputStream; output.Write(buffer, 0, buffer.Length); output.Close(); - - string code = httpRequest.QueryString.Get("code"); + string code = httpRequest.QueryString.Get("b64Params"); if (!string.IsNullOrEmpty(code)) { - this.setResultUrl(new Uri($"http://localhost#{code}")); + this.setResultUrl(new Uri($"http://localhost#state=&b64Params={code}")); } httpListener.Close(); From 117aaf9c4e5ce059663537d6b3c4f742cda4bb8b Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 26 Mar 2024 08:51:30 +0530 Subject: [PATCH 10/24] feat: metadata server base-url changes and updated auth-services to v8 Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs | 2 +- Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs b/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs index aaf4afe..5872b89 100644 --- a/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs +++ b/Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs @@ -8,7 +8,7 @@ public class Web3AuthApi { static Web3AuthApi instance; - static string baseAddress = "https://broadcast-server.tor.us"; + static string baseAddress = "https://session.web3auth.io"; public static Web3AuthApi getInstance() { diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index d391aee..7e2fb93 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -19,7 +19,7 @@ public string sdkUrl { } set { } } - public const string openLoginVersion = "v7"; + public const string openLoginVersion = "v8"; public const string walletServicesVersion = "v1"; public string walletSdkUrl { From a61e94233c5d4c2d1756f21d97905cf2ba80de18 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 5 Apr 2024 09:53:47 +0530 Subject: [PATCH 11/24] feat: ChainConfig schema updated Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs | 2 +- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs b/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs index bf441e9..27df1de 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs @@ -8,6 +8,6 @@ public class ChainConfig { public string displayName { get; set; } = null; public string logo { get; set; } = null; public string rpcTarget { get; set; } - public string ticker { get; set; } + public string ticker { get; set; } = null; public string tickerName { get; set; } = null; } \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 5a76a15..ddececc 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -233,10 +233,10 @@ private void IncomingHttpRequest(IAsyncResult result) System.IO.Stream output = httpResponse.OutputStream; output.Write(buffer, 0, buffer.Length); output.Close(); - string code = httpRequest.QueryString.Get("b64Params"); + string code = httpRequest.QueryString.Get("code"); if (!string.IsNullOrEmpty(code)) { - this.setResultUrl(new Uri($"http://localhost#state=&b64Params={code}")); + this.setResultUrl(new Uri($"http://localhost#state=&{code}")); } httpListener.Close(); From 73b38980e69db2f68d742090ed5beaed70ee2591 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Thu, 11 Apr 2024 09:30:37 +0530 Subject: [PATCH 12/24] feat: minor changes Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index ddececc..9bbd9da 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -236,7 +236,7 @@ private void IncomingHttpRequest(IAsyncResult result) string code = httpRequest.QueryString.Get("code"); if (!string.IsNullOrEmpty(code)) { - this.setResultUrl(new Uri($"http://localhost#state=&{code}")); + this.setResultUrl(new Uri($"http://localhost#{code}")); } httpListener.Close(); @@ -336,6 +336,7 @@ public async void launchWalletServices(LoginParams loginParams, ChainConfig chai UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.walletSdkUrl); uriBuilder.Path = path; uriBuilder.Fragment = "b64Params=" + hash; + //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); Utils.LaunchUrl(uriBuilder.ToString(), this.initParams["redirectUrl"].ToString(), gameObject.name); } @@ -365,7 +366,7 @@ public void setResultUrl(Uri uri) if (queryParameters.Keys.Contains("error")) throw new UnKnownException(queryParameters["error"]); - string b64Params = hash.Split('&')[1].Split('=')[1]; + string b64Params = hash.Split('=')[1]; string decodedString = decodeBase64Params(b64Params); SessionResponse sessionResponse = null; try From df6e13da289e6c0b7bc5f9a1377f9b84ef137e49 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 24 Apr 2024 12:23:37 +0530 Subject: [PATCH 13/24] feat: isMfaEnabled check added Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 9bbd9da..6e8b37a 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -443,6 +443,10 @@ public void logout(Uri redirectUrl = null, string appState = null) public void enableMFA(LoginParams loginParams) { + if(web3AuthResponse.userInfo.isMfaEnabled == true) + { + throw new Exception("MFA is already enabled for this user."); + } string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) { From 5a949fcd84619d45e5dcfcdae65b4d30ef904a9f Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 6 May 2024 09:47:01 +0530 Subject: [PATCH 14/24] feat: new providers added Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Types/Provider.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Assets/Plugins/Web3AuthSDK/Types/Provider.cs b/Assets/Plugins/Web3AuthSDK/Types/Provider.cs index a2269a8..3b926c8 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Provider.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Provider.cs @@ -38,5 +38,9 @@ public enum Provider [EnumMember(Value = "jwt")] JWT, [EnumMember(Value = "CUSTOM_VERIFIER")] - CUSTOM_VERIFIER + CUSTOM_VERIFIER, + [EnumMember(Value = "sms_passwordless")] + SMS_PASSWORDLESS, + [EnumMember(Value = "farcaster")] + FARCASTER } \ No newline at end of file From dd9098820f3a50b5874a6e9711918262c6aea726 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Mon, 6 May 2024 10:03:34 +0530 Subject: [PATCH 15/24] feat: updated new providers in example Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index d10acc0..d32ceaa 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -21,6 +21,8 @@ public class Web3AuthSample : MonoBehaviour new LoginVerifier("Twitter", Provider.TWITTER), new LoginVerifier("Line", Provider.LINE), new LoginVerifier("Hosted Email Passwordless", Provider.EMAIL_PASSWORDLESS), + new LoginVerifier("SMS Passwordless", Provider.SMS_PASSWORDLESS), + new LoginVerifier("Farcaster", Provider.FARCASTER), }; Web3Auth web3Auth; From 9124082e7885639b030921ce75733bde694b24a7 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Wed, 8 May 2024 08:28:22 +0530 Subject: [PATCH 16/24] feat: update wallet-services version to v2 Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 7e2fb93..31a2dca 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -21,7 +21,7 @@ public string sdkUrl { } public const string openLoginVersion = "v8"; - public const string walletServicesVersion = "v1"; + public const string walletServicesVersion = "v2"; public string walletSdkUrl { get { if (buildEnv == Web3Auth.BuildEnv.STAGING) From 064c4ac04d6e270867cb81bc13111207ac352ac4 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 14 May 2024 08:36:40 +0530 Subject: [PATCH 17/24] feat: removed loginParams parameter from launchWalletServices() function and updated example Signed-off-by: Gaurav Goel --- .../Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs | 15 +-------------- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 4 +--- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index d32ceaa..abd5c51 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -190,19 +190,6 @@ private void enableMFA() private void launchWalletServices() { var selectedProvider = verifierList[verifierDropdown.value].loginProvider; - var options = new LoginParams() - { - loginProvider = selectedProvider - }; - - if (selectedProvider == Provider.EMAIL_PASSWORDLESS) - { - options.extraLoginOptions = new ExtraLoginOptions() - { - login_hint = emailAddressField.text - }; - } - var chainConfig = new ChainConfig() { chainId = "0x1", @@ -210,6 +197,6 @@ private void launchWalletServices() { ticker = "ETH", chainNamespace = Web3Auth.ChainNamespace.EIP155 }; - web3Auth.launchWalletServices(options, chainConfig); + web3Auth.launchWalletServices(chainConfig); } } diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 6e8b37a..bbfc39e 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -296,7 +296,7 @@ private async void request(string path, LoginParams loginParams = null) } } - public async void launchWalletServices(LoginParams loginParams, ChainConfig chainConfig, string path = "wallet") + public async void launchWalletServices(ChainConfig chainConfig, string path = "wallet") { string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) @@ -307,11 +307,9 @@ public async void launchWalletServices(LoginParams loginParams, ChainConfig chai this.initParams["redirectUrl"] = Utils.GetCurrentURL(); #endif - loginParams.redirectUrl = loginParams.redirectUrl ?? new Uri(this.initParams["redirectUrl"].ToString()); this.initParams["chainConfig"] = chainConfig; Dictionary paramMap = new Dictionary(); paramMap["options"] = this.initParams; - paramMap["params"] = loginParams == null ? (object)new Dictionary() : (object)loginParams; //Debug.Log("paramMap: =>" + JsonConvert.SerializeObject(paramMap)); string loginId = await createSession(JsonConvert.SerializeObject(paramMap, Formatting.None, From 87d5a633c9b6dd011ce9d819160b7dcbe5e60db8 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 14 May 2024 11:41:05 +0530 Subject: [PATCH 18/24] feat: add platform parameter in launchWalletServices() function Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index bbfc39e..4f4cff3 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -324,6 +324,7 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w { { "loginId", loginId }, { "sessionId", sessionId } + { "platform", "unity" } }; string hash = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(loginIdObject, Formatting.None, new JsonSerializerSettings From 3d4fd3a174b7bfbd6a4d08c2af7e40ebad26d215 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 14 May 2024 13:21:12 +0530 Subject: [PATCH 19/24] feat: fix error Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 4f4cff3..d4cd47a 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -323,7 +323,7 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w var loginIdObject = new Dictionary { { "loginId", loginId }, - { "sessionId", sessionId } + { "sessionId", sessionId }, { "platform", "unity" } }; string hash = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(loginIdObject, Formatting.None, From 9a81653d64fe065fb823a6bda5d1e56b1970a0c5 Mon Sep 17 00:00:00 2001 From: Mohammad Shahbaz Alam Date: Tue, 14 May 2024 13:48:54 +0530 Subject: [PATCH 20/24] nit --- .../Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index abd5c51..018cddb 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -11,7 +11,7 @@ public class Web3AuthSample : MonoBehaviour List verifierList = new List { new LoginVerifier("Google", Provider.GOOGLE), new LoginVerifier("Facebook", Provider.FACEBOOK), - new LoginVerifier("CUSTOM_VERIFIER", Provider.CUSTOM_VERIFIER), + // new LoginVerifier("CUSTOM_VERIFIER", Provider.CUSTOM_VERIFIER), new LoginVerifier("Twitch", Provider.TWITCH), new LoginVerifier("Discord", Provider.DISCORD), new LoginVerifier("Reddit", Provider.REDDIT), @@ -20,7 +20,7 @@ public class Web3AuthSample : MonoBehaviour new LoginVerifier("LinkedIn", Provider.LINKEDIN), new LoginVerifier("Twitter", Provider.TWITTER), new LoginVerifier("Line", Provider.LINE), - new LoginVerifier("Hosted Email Passwordless", Provider.EMAIL_PASSWORDLESS), + new LoginVerifier("Email Passwordless", Provider.EMAIL_PASSWORDLESS), new LoginVerifier("SMS Passwordless", Provider.SMS_PASSWORDLESS), new LoginVerifier("Farcaster", Provider.FARCASTER), }; @@ -69,7 +69,7 @@ void Start() mode = ThemeModes.dark, theme = new Dictionary { - { "primary", "#123456" } + { "primary", "#FFBF00" } } }, // If using your own custom verifier, uncomment this code. @@ -158,6 +158,13 @@ private void login() login_hint = emailAddressField.text }; } + if (selectedProvider == Provider.SMS_PASSWORDLESS) + { + options.extraLoginOptions = new ExtraLoginOptions() + { + login_hint = "+XX-XXXXXXXXXX" + }; + } web3Auth.login(options); } From ddbe3ec831844cdb597ecae84d284402f4546680 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 14 May 2024 14:36:13 +0530 Subject: [PATCH 21/24] feat: fix errors in UriBuilder Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs | 2 +- Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs | 10 ++++------ Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index 018cddb..d272582 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -81,7 +81,7 @@ void Start() } */ clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ", - buildEnv = BuildEnv.TESTING, + buildEnv = BuildEnv.PRODUCTION, redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"), network = Web3Auth.Network.SAPPHIRE_MAINNET, sessionTime = 86400 diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 31a2dca..2fb8d67 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -11,25 +11,23 @@ public class Web3AuthOptions { public string sdkUrl { get { if (buildEnv == Web3Auth.BuildEnv.STAGING) - return "https://staging-auth.web3auth.io/{openLoginVersion}"; + return "https://staging-auth.web3auth.io/v8"; else if (buildEnv == Web3Auth.BuildEnv.TESTING) return "https://develop-auth.web3auth.io"; else - return "https://auth.web3auth.io/{openLoginVersion}"; + return "https://auth.web3auth.io/v8"; } set { } } - public const string openLoginVersion = "v8"; - public const string walletServicesVersion = "v2"; public string walletSdkUrl { get { if (buildEnv == Web3Auth.BuildEnv.STAGING) - return "https://staging-wallet.web3auth.io/{walletServicesVersion}"; + return "https://staging-wallet.web3auth.io/v2"; else if (buildEnv == Web3Auth.BuildEnv.TESTING) return "https://develop-wallet.web3auth.io"; else - return "https://wallet.web3auth.io/{walletServicesVersion}"; + return "https://wallet.web3auth.io/v2"; } set { } } diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index d4cd47a..f24786a 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -284,7 +284,7 @@ private async void request(string path, LoginParams loginParams = null) }))); UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.sdkUrl); - uriBuilder.Path = "start"; + uriBuilder.Path += "/" + "start"; uriBuilder.Fragment = "b64Params=" + hash; //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); @@ -333,7 +333,7 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w }))); UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.walletSdkUrl); - uriBuilder.Path = path; + uriBuilder.Path += "/" + path; uriBuilder.Fragment = "b64Params=" + hash; //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); From c0ee4aeeacdde30f12517719a28c02408224ad01 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 21 May 2024 15:30:51 +0530 Subject: [PATCH 22/24] feat: update uribuilder code Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index f24786a..9481f5d 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -284,7 +284,14 @@ private async void request(string path, LoginParams loginParams = null) }))); UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.sdkUrl); - uriBuilder.Path += "/" + "start"; + if(this.web3AuthOptions.sdkUrl.Contains("develop")) + { + uriBuilder.Path = "/" + "start"; + } + else + { + uriBuilder.Path += "/" + "start"; + } uriBuilder.Fragment = "b64Params=" + hash; //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); @@ -333,7 +340,14 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w }))); UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.walletSdkUrl); - uriBuilder.Path += "/" + path; + if(this.web3AuthOptions.sdkUrl.Contains("develop")) + { + uriBuilder.Path = "/" + "start"; + } + else + { + uriBuilder.Path += "/" + "start"; + } uriBuilder.Fragment = "b64Params=" + hash; //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); From 329c6f6806987d9be1e5c3cd62e7058a11888807 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 21 May 2024 15:52:09 +0530 Subject: [PATCH 23/24] feat: code refractored Signed-off-by: Gaurav Goel --- Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 9481f5d..6fa8716 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -342,11 +342,11 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w UriBuilder uriBuilder = new UriBuilder(this.web3AuthOptions.walletSdkUrl); if(this.web3AuthOptions.sdkUrl.Contains("develop")) { - uriBuilder.Path = "/" + "start"; + uriBuilder.Path = "/" + path; } else { - uriBuilder.Path += "/" + "start"; + uriBuilder.Path += "/" + path; } uriBuilder.Fragment = "b64Params=" + hash; //Debug.Log("finalUriBuilderToOpen: =>" + uriBuilder.ToString()); From 6cc364ac011e4577a547571fee49d5b45c9a88bd Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Tue, 21 May 2024 16:51:39 +0530 Subject: [PATCH 24/24] 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))