From 8f2a58a8104c034797155e1b7dc446725ea79692 Mon Sep 17 00:00:00 2001 From: Musab Hussain Date: Sat, 28 Jan 2023 20:14:24 +0500 Subject: [PATCH] dappshare feature added. --- .../Keystore/KeyStoreManagerUtils.cs | 5 ++++ Assets/Plugins/Web3AuthSDK/Web3Auth.cs | 28 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs b/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs index f7bf3dc..7db3419 100644 --- a/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs +++ b/Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs @@ -44,6 +44,11 @@ public static void deletePreferencesData(string key) SecurePlayerPrefs.DeleteKey(key); } + public static void clearPreferencesData() + { + SecurePlayerPrefs.DeleteAll(); + } + public static string getECDSASignature(string privateKey, string data){ var curve = SecNamedCurves.GetByName("secp256k1"); var domain = new ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H); diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index c7b704a..ede7a01 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -242,10 +242,28 @@ public void setResultUrl(Uri uri) if (!string.IsNullOrEmpty(this.web3AuthResponse.sessionId)) this.Enqueue(() => KeyStoreManagerUtils.savePreferenceData(KeyStoreManagerUtils.SESSION_ID, this.web3AuthResponse.sessionId) ); + + if (!string.IsNullOrEmpty(web3AuthResponse.userInfo?.dappShare)) + { + KeyStoreManagerUtils.savePreferenceData( + web3AuthResponse.userInfo?.verifier, web3AuthResponse.userInfo?.dappShare + ); + } } public void login(LoginParams loginParams) { + if (web3AuthOptions.loginConfig != null) + { + var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); + var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); + + if (!string.IsNullOrEmpty(share)) + { + loginParams.dappShare = share; + } + } + request("login", loginParams); } @@ -366,12 +384,10 @@ private void sessionTimeOutAPI() ); - //if (result != null) - //{ - // //Delete local storage - // var loginConfigItem = web3AuthOptions.loginConfig.Values.First(); - // KeyStoreManagerUtils.deletePreferencesData(loginConfigItem.verifier); - //} + if (result != null) + { + KeyStoreManagerUtils.clearPreferencesData(); + } } }