Skip to content

auth-service v10 and wallet-service changes. #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions Assets/Plugins/Web3AuthSDK/Samples/LoginVerifier.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
public class LoginVerifier {
public string name { get; set; }
public Provider loginProvider { get; set; }
public AuthConnection authConnection { get; set; }

public LoginVerifier(string name, Provider loginProvider)
public LoginVerifier(string name, AuthConnection authConnection)
{
this.name = name;
this.loginProvider = loginProvider;
this.authConnection = authConnection;
}
}
89 changes: 52 additions & 37 deletions Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
public class Web3AuthSample : MonoBehaviour
{
List<LoginVerifier> verifierList = new List<LoginVerifier> {
new LoginVerifier("Google", Provider.GOOGLE),
new LoginVerifier("Facebook", Provider.FACEBOOK),
// new LoginVerifier("CUSTOM_VERIFIER", Provider.CUSTOM_VERIFIER),
new LoginVerifier("Twitch", Provider.TWITCH),
new LoginVerifier("Discord", Provider.DISCORD),
new LoginVerifier("Reddit", Provider.REDDIT),
new LoginVerifier("Apple", Provider.APPLE),
new LoginVerifier("Github", Provider.GITHUB),
new LoginVerifier("LinkedIn", Provider.LINKEDIN),
new LoginVerifier("Twitter", Provider.TWITTER),
new LoginVerifier("Line", Provider.LINE),
new LoginVerifier("Email Passwordless", Provider.EMAIL_PASSWORDLESS),
new LoginVerifier("SMS Passwordless", Provider.SMS_PASSWORDLESS),
new LoginVerifier("Farcaster", Provider.FARCASTER),
new LoginVerifier("Google", AuthConnection.GOOGLE),
new LoginVerifier("Facebook", AuthConnection.FACEBOOK),
// new LoginVerifier("CUSTOM_VERIFIER", AuthConnection.CUSTOM_VERIFIER),
new LoginVerifier("Twitch", AuthConnection.TWITCH),
new LoginVerifier("Discord", AuthConnection.DISCORD),
new LoginVerifier("Reddit", AuthConnection.REDDIT),
new LoginVerifier("Apple", AuthConnection.APPLE),
new LoginVerifier("Github", AuthConnection.GITHUB),
new LoginVerifier("LinkedIn", AuthConnection.LINKEDIN),
new LoginVerifier("Twitter", AuthConnection.TWITTER),
new LoginVerifier("Line", AuthConnection.LINE),
new LoginVerifier("Email Passwordless", AuthConnection.EMAIL_PASSWORDLESS),
new LoginVerifier("SMS Passwordless", AuthConnection.SMS_PASSWORDLESS),
new LoginVerifier("Farcaster", AuthConnection.FARCASTER),
};

Web3Auth web3Auth;
Expand Down Expand Up @@ -64,12 +64,13 @@ public class Web3AuthSample : MonoBehaviour

void Start()
{
var loginConfigItem = new LoginConfigItem()
var authConnectionItem = new AuthConnectionConfig()
{
verifier = "your_verifierid_from_web3auth_dashboard",
typeOfLogin = TypeOfLogin.GOOGLE,
authConnectionId = "your_verifierid_from_web3auth_dashboard", // corresponds to `verifier`
authConnection = AuthConnection.GOOGLE,
clientId = "your_clientId_from_web3auth_dashboard"
};
var authConnectionConfig = new List<AuthConnectionConfig> { authConnectionItem };

web3Auth = GetComponent<Web3Auth>();
web3Auth.setOptions(new Web3AuthOptions()
Expand All @@ -94,10 +95,19 @@ void Start()
{"CUSTOM_VERIFIER", loginConfigItem}
}
*/
authConnectionConfig = new List<AuthConnectionConfig>()
{
new AuthConnectionConfig()
{
authConnectionId = "web3auth-auth0-email-passwordless-sapphire-devnet",
authConnection = AuthConnection.CUSTOM,
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C"
}
},
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
buildEnv = BuildEnv.PRODUCTION,
authBuildEnv = BuildEnv.TESTING,
redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity"),
network = Web3Auth.Network.SAPPHIRE_DEVNET,
web3AuthNetwork = Web3Auth.Network.SAPPHIRE_DEVNET,
sessionTime = 86400
});
web3Auth.onLogin += onLogin;
Expand All @@ -116,7 +126,7 @@ void Start()
loginButton.onClick.AddListener(login);
logoutButton.onClick.AddListener(logout);
mfaSetupButton.onClick.AddListener(enableMFA);
launchWalletServicesButton.onClick.AddListener(launchWalletServices);
launchWalletServicesButton.onClick.AddListener(showWalletUI);
signMessageButton.onClick.AddListener(request);
signResponseButton.onClick.AddListener(manageMFA);

Expand Down Expand Up @@ -168,29 +178,29 @@ private void onManageMFA(bool response) {

private void onVerifierDropDownChange(int selectedIndex)
{
if (verifierList[selectedIndex].loginProvider == Provider.EMAIL_PASSWORDLESS)
if (verifierList[selectedIndex].authConnection == AuthConnection.EMAIL_PASSWORDLESS)
emailAddressField.gameObject.SetActive(true);
else
emailAddressField.gameObject.SetActive(false);
}

private void login()
{
var selectedProvider = verifierList[verifierDropdown.value].loginProvider;
var selectedProvider = verifierList[verifierDropdown.value].authConnection;

var options = new LoginParams()
{
loginProvider = selectedProvider
authConnection = selectedProvider
};

if (selectedProvider == Provider.EMAIL_PASSWORDLESS)
if (selectedProvider == AuthConnection.EMAIL_PASSWORDLESS)
{
options.extraLoginOptions = new ExtraLoginOptions()
{
login_hint = emailAddressField.text
};
}
if (selectedProvider == Provider.SMS_PASSWORDLESS)
if (selectedProvider == AuthConnection.SMS_PASSWORDLESS)
{
options.extraLoginOptions = new ExtraLoginOptions()
{
Expand All @@ -208,15 +218,15 @@ private void logout()

private void enableMFA()
{
var selectedProvider = verifierList[verifierDropdown.value].loginProvider;
var selectedProvider = verifierList[verifierDropdown.value].authConnection;

var options = new LoginParams()
{
loginProvider = selectedProvider,
authConnection = selectedProvider,
mfaLevel = MFALevel.MANDATORY
};

if (selectedProvider == Provider.EMAIL_PASSWORDLESS)
if (selectedProvider == AuthConnection.EMAIL_PASSWORDLESS)
{
options.extraLoginOptions = new ExtraLoginOptions()
{
Expand All @@ -228,15 +238,15 @@ private void enableMFA()

private void manageMFA()
{
var selectedProvider = verifierList[verifierDropdown.value].loginProvider;
var selectedProvider = verifierList[verifierDropdown.value].authConnection;

var options = new LoginParams()
{
loginProvider = selectedProvider,
authConnection = selectedProvider,
mfaLevel = MFALevel.MANDATORY
};

if (selectedProvider == Provider.EMAIL_PASSWORDLESS)
if (selectedProvider == AuthConnection.EMAIL_PASSWORDLESS)
{
options.extraLoginOptions = new ExtraLoginOptions()
{
Expand All @@ -246,27 +256,32 @@ private void manageMFA()
web3Auth.manageMFA(options);
}

private void launchWalletServices() {
var selectedProvider = verifierList[verifierDropdown.value].loginProvider;
private void showWalletUI() {
var selectedProvider = verifierList[verifierDropdown.value].authConnection;

var chainConfig = new ChainConfig()
{
chainId = "0x1",
rpcTarget = "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0",
ticker = "ETH",
chainNamespace = Web3Auth.ChainNamespace.EIP155
chainNamespace = Web3Auth.ChainNamespace.eip155
};
web3Auth.launchWalletServices(chainConfig);
var chainConfigList = new List<ChainConfig> { chainConfig };
foreach (var config in chainConfigList)
{
Debug.Log($"Chain ID: {config.chainId}, RPC Target: {config.rpcTarget}, Ticker: {config.ticker}, Namespace: {config.chainNamespace}");
}
web3Auth.showWalletUI(chainConfigList, "0x1");
}

private void request() {
var selectedProvider = verifierList[verifierDropdown.value].loginProvider;
var selectedProvider = verifierList[verifierDropdown.value].authConnection;

var chainConfig = new ChainConfig()
{
chainId = "0x89",
rpcTarget = "https://1rpc.io/matic",
chainNamespace = Web3Auth.ChainNamespace.EIP155
chainNamespace = Web3Auth.ChainNamespace.eip155
};

JArray paramsArray = new JArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.Serialization;

[JsonConverter(typeof(StringEnumConverter))]
public enum Provider
public enum AuthConnection
{
[EnumMember(Value = "google")]
GOOGLE,
Expand Down Expand Up @@ -35,8 +35,8 @@ public enum Provider
EMAIL_PASSWORDLESS,
[EnumMember(Value = "email_password")]
EMAIL_PASSWORD,
[EnumMember(Value = "jwt")]
JWT,
[EnumMember(Value = "custom")]
CUSTOM,
[EnumMember(Value = "CUSTOM_VERIFIER")]
CUSTOM_VERIFIER,
[EnumMember(Value = "sms_passwordless")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public class LoginConfigItem {
public string verifier { get; set; }
public TypeOfLogin typeOfLogin { get; set; }
public class AuthConnectionConfig {
public string authConnectionId { get; set; }
public AuthConnection authConnection { get; set; }
public string name { get; set; }
public string description { get; set; }
public string clientId { get; set; }
Expand Down
7 changes: 6 additions & 1 deletion Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
#nullable enable
public class ChainConfig {
public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155;

[JsonConverter(typeof(StringEnumConverter))]
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; }
Expand Down
11 changes: 0 additions & 11 deletions Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs.meta

This file was deleted.

2 changes: 1 addition & 1 deletion Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class LoginParams
{
public Provider loginProvider { get; set; }
public AuthConnection authConnection { get; set; }
public string dappShare { get; set; }
public ExtraLoginOptions extraLoginOptions { get; set; }
public Uri redirectUrl { get; set; }
Expand Down
11 changes: 0 additions & 11 deletions Assets/Plugins/Web3AuthSDK/Types/Provider.cs.meta

This file was deleted.

40 changes: 0 additions & 40 deletions Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs.meta

This file was deleted.

8 changes: 4 additions & 4 deletions Assets/Plugins/Web3AuthSDK/Types/UserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
public string email { get; set; }
public string name { get; set; }
public string profileImage { get; set; }
public string aggregateVerifier { get; set; }
public string verifier { get; set; }
public string verifierId { get; set; }
public string typeOfLogin { get; set; }
public string groupedAuthConnectionId { get; set; }
public string authConnectionId { get; set; }
public string userId { get; set; }
public string authConnection { get; set; }
public string dappShare { get; set; }
public string idToken { get; set; }
public string oAuthIdToken { get; set; }
Expand Down
Loading