Skip to content

Commit

Permalink
dappshare feature added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Musab Hussain committed Jan 28, 2023
1 parent a9adddd commit 8f2a58a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Assets/Plugins/Web3AuthSDK/Keystore/KeyStoreManagerUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 22 additions & 6 deletions Assets/Plugins/Web3AuthSDK/Web3Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 8f2a58a

Please sign in to comment.