Skip to content

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

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 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
73c72bc
feat: auth-service v10 changes
grvgoel81 Apr 17, 2025
d01e486
feat: wallet-service and request fucntion changes added.
grvgoel81 Apr 17, 2025
34b9742
feat: example updated.
grvgoel81 Apr 17, 2025
29c158d
feat: bump auth-services version
grvgoel81 Apr 21, 2025
bfbf5cb
feat: bump auth-services version
grvgoel81 Apr 21, 2025
301fe71
feat: auth-service and wallet-service changes added.
grvgoel81 Apr 23, 2025
279f8c8
feat: Rename var names ChainConfig, network to web3AuthNetwork
grvgoel81 Apr 25, 2025
ae7bccc
feat: default value added for authConnectionConfig
grvgoel81 Apr 28, 2025
2943eb7
feat: changed authConnection jwt to custom
grvgoel81 Apr 29, 2025
472f1fb
feat: renaming variables
grvgoel81 May 14, 2025
d97e8d4
feat: Update Input config params
grvgoel81 May 14, 2025
0049a3b
feat: update wallet-services to v5 version
grvgoel81 May 14, 2025
cc37dfd
feat: update ExtraLoginOptions.cs
grvgoel81 May 15, 2025
2b48b3c
feat: update Web3AuthOptions
grvgoel81 May 15, 2025
d7dedde
feat: update Web3AuthOptions
grvgoel81 May 15, 2025
2512b38
feat: update Web3AuthResponse
grvgoel81 May 20, 2025
21f379a
feat: Update fetchprojectConfig API response, Web3AuthOptions.cs and …
grvgoel81 Jun 16, 2025
ed79bc4
feat: modify project config response
grvgoel81 Jul 28, 2025
9af6d7b
Update project config url and Web3Auth.cs
grvgoel81 Jul 28, 2025
70cae01
Update example
grvgoel81 Jul 28, 2025
5819fd6
feat: update example
grvgoel81 Jul 30, 2025
e1bfdce
Merge remote-tracking branch 'origin/feat/auth_service_v10_change_plu…
grvgoel81 Jul 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Assets/Plugins/Web3AuthSDK/Api/Models/ProjectConfigResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Plugins.Web3AuthSDK.Types;

public class WhitelistResponse
{
Expand All @@ -8,9 +9,16 @@ public class WhitelistResponse

public class ProjectConfigResponse
{
public WhiteLabelData whitelabel { get; set; }
public bool? userDataInIdToken { get; set; } = true;
public int? sessionTime { get; set; } = 30 * 86400;
public bool? enableKeyExport { get; set; } = false;
public WhitelistResponse whitelist { get; set; }
public List<Chains> chains { get; set; }
public SmartAccountsConfig smartAccounts { get; set; }
public WalletUiConfig walletUiConfig { get; set; }
public List<AuthConnectionConfig> embeddedWalletAuth { get; set; }
public bool sms_otp_enabled { get; set; }
public bool wallet_connect_enabled { get; set; }
public string wallet_connect_project_id { get; set; }
public WhitelistResponse whitelist { get; set; }
public string walletConnectProjectId { get; set; }
public WhiteLabelData whitelabel { get; set; }
}
5 changes: 3 additions & 2 deletions Assets/Plugins/Web3AuthSDK/Api/Web3AuthApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,19 @@ public IEnumerator createSession(LogoutApiRequest logoutApiRequest, Action<JObje
callback(null);
}

public IEnumerator fetchProjectConfig(string project_id, string network, Action<ProjectConfigResponse> callback)
public IEnumerator fetchProjectConfig(string project_id, string network, string build_env, Action<ProjectConfigResponse> callback)
{
//Debug.Log("network =>" + network);
string baseUrl = SIGNER_MAP[network];
var requestURL = $"{baseUrl}/api/configuration?project_id={project_id}&network={network}&whitelist=true";
var requestURL = $"{baseUrl}/api/v2/configuration?project_id={project_id}&network={network}&build_env={build_env}";
var request = UnityWebRequest.Get(requestURL);

yield return request.SendWebRequest();

if (request.result == UnityWebRequest.Result.Success)
{
string result = request.downloadHandler.text;
//Debug.Log("fetch config raw API result: " + result);
callback(Newtonsoft.Json.JsonConvert.DeserializeObject<ProjectConfigResponse>(result));
}
else
Expand Down
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;
}
}
112 changes: 63 additions & 49 deletions Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static Web3Auth;
using Org.BouncyCastle.Asn1.Sec;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Digests;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Math.EC;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities.Encoders;
using Org.BouncyCastle.Crypto.Digests;
using UnityEngine;
using UnityEngine.UI;
using static Web3Auth;

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 +62,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 +93,20 @@ void Start()
{"CUSTOM_VERIFIER", loginConfigItem}
}
*/
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
buildEnv = BuildEnv.PRODUCTION,
authConnectionConfig = new List<AuthConnectionConfig>()
{
new AuthConnectionConfig()
{
authConnectionId = "web3auth-auth0-email-passwordless-sapphire-devnet",
authConnection = AuthConnection.CUSTOM,
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C"
}
},
clientId = "BHgArYmWwSeq21czpcarYh0EVq2WWOzflX-NTK-tY1-1pauPzHKRRLgpABkmYiIV_og9jAvoIxQ8L3Smrwe04Lw",
authBuildEnv = BuildEnv.TESTING,
redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity"),
network = Web3Auth.Network.SAPPHIRE_DEVNET,
web3AuthNetwork = Web3Auth.Network.SAPPHIRE_DEVNET,
defaultChainId = "0x1",
sessionTime = 86400
});
web3Auth.onLogin += onLogin;
Expand All @@ -116,7 +125,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 +177,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 +217,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 +237,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,37 +255,42 @@ 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()
var chainConfig = new Chains()
{
chainId = "0x1",
rpcTarget = "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0",
ticker = "ETH",
chainNamespace = Web3Auth.ChainNamespace.EIP155
chainNamespace = ChainNamespace.eip155
};
web3Auth.launchWalletServices(chainConfig);
var chainConfigList = new List<Chains> { chainConfig };
foreach (var config in chainConfigList)
{
Debug.Log($"Chain ID: {config.chainId}, RPC Target: {config.rpcTarget}, Ticker: {config.ticker}, Namespace: {config.chainNamespace}");
}
web3Auth.showWalletUI("0x1");
}

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

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

JArray paramsArray = new JArray
{
"Hello, World!",
getPublicAddressFromPrivateKey(web3Auth.getPrivKey()),
getPublicAddressFromPrivateKey(web3Auth.getPrivateKey()),
"Android"
};

web3Auth.request(chainConfig, "personal_sign", paramsArray);
web3Auth.request("personal_sign", paramsArray);
}

public string getPublicAddressFromPrivateKey(string privateKeyHex)
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,15 +1,16 @@
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; }
public string verifierSubIdentifier { get; set; }
public string groupedAuthConnectionId { get; set; }
public string logoHover { get; set; }
public string logoLight { get; set; }
public string logoDark { get; set; }
public bool mainOption { get; set; } = false;
public bool showOnModal { get; set; } = true;
public bool showOnDesktop { get; set; } = true;
public bool showOnMobile { get; set; } = true;
public ExtraLoginOptions extraLoginOptions { get; set; }
}
7 changes: 7 additions & 0 deletions Assets/Plugins/Web3AuthSDK/Types/BundlerConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Plugins.Web3AuthSDK.Types
{
public class BundlerConfig
{
public string url { get; set; }
}
}
3 changes: 3 additions & 0 deletions Assets/Plugins/Web3AuthSDK/Types/BundlerConfig.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Collections.Generic;
#nullable enable
public class ChainConfig {
public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

public class Chains {

[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: 9 additions & 2 deletions Assets/Plugins/Web3AuthSDK/Types/ExtraLoginOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ public class ExtraLoginOptions {
public string domain { get; set; }
public string client_id { get; set; }
public string leeway { get; set; }
public string verifierIdField { get; set; }
public bool isVerifierIdCaseSensitive { get; set; }
public string userIdField { get; set; }
public bool isUserIdCaseSensitive { get; set; }
public Display display { get; set; }
public Prompt prompt { get; set; }
public string max_age { get; set; }
public string ui_locales { get; set; }
public string id_token { get; set; }
public string access_token { get; set; }
private EmailFlowType flow_type { get; set; } = EmailFlowType.link;
public string id_token_hint { get; set; }
public string login_hint { get; set; }
public string acr_values { get; set; }
Expand All @@ -22,4 +24,9 @@ public class ExtraLoginOptions {
public string response_type { get; set; }
public string nonce { get; set; }
public string redirect_uri { get; set; }
}

public enum EmailFlowType
{
link, code
}
Loading