diff --git a/Assets/Plugins/Web3AuthSDK/Samples/LoginVerifier.cs b/Assets/Plugins/Web3AuthSDK/Samples/LoginVerifier.cs index d2a7cd8..29f9d4f 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/LoginVerifier.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/LoginVerifier.cs @@ -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; } } \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs index 91f6c09..1ab6c45 100644 --- a/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs +++ b/Assets/Plugins/Web3AuthSDK/Samples/Web3AuthSample.cs @@ -17,20 +17,20 @@ 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("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; @@ -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 { authConnectionItem }; web3Auth = GetComponent(); web3Auth.setOptions(new Web3AuthOptions() @@ -94,10 +95,19 @@ void Start() {"CUSTOM_VERIFIER", loginConfigItem} } */ + authConnectionConfig = new List() + { + 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; @@ -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); @@ -168,7 +178,7 @@ 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); @@ -176,21 +186,21 @@ private void onVerifierDropDownChange(int selectedIndex) 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() { @@ -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() { @@ -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() { @@ -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 }; + 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 diff --git a/Assets/Plugins/Web3AuthSDK/Types/Provider.cs b/Assets/Plugins/Web3AuthSDK/Types/AuthConnection.cs similarity index 93% rename from Assets/Plugins/Web3AuthSDK/Types/Provider.cs rename to Assets/Plugins/Web3AuthSDK/Types/AuthConnection.cs index 3b926c8..472aaf3 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Provider.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/AuthConnection.cs @@ -3,7 +3,7 @@ using System.Runtime.Serialization; [JsonConverter(typeof(StringEnumConverter))] -public enum Provider +public enum AuthConnection { [EnumMember(Value = "google")] GOOGLE, @@ -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")] diff --git a/Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs b/Assets/Plugins/Web3AuthSDK/Types/AuthConnectionConfig.cs similarity index 77% rename from Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs rename to Assets/Plugins/Web3AuthSDK/Types/AuthConnectionConfig.cs index 0f3ec18..f14aae4 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/AuthConnectionConfig.cs @@ -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; } diff --git a/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs b/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs index 27df1de..ba6c54e 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/ChainConfig.cs @@ -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; } diff --git a/Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs.meta b/Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs.meta deleted file mode 100644 index 2f5e627..0000000 --- a/Assets/Plugins/Web3AuthSDK/Types/LoginConfigItem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f2084deef0ee33142b69d4593c983a90 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs b/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs index ff3f7f4..c6fa0bb 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/LoginParams.cs @@ -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; } diff --git a/Assets/Plugins/Web3AuthSDK/Types/Provider.cs.meta b/Assets/Plugins/Web3AuthSDK/Types/Provider.cs.meta deleted file mode 100644 index 82d8ae8..0000000 --- a/Assets/Plugins/Web3AuthSDK/Types/Provider.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d726f63285867184a9016460e6f380f4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs b/Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs deleted file mode 100644 index 4960f4b..0000000 --- a/Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using System.Runtime.Serialization; - -[JsonConverter(typeof(StringEnumConverter))] -public enum TypeOfLogin -{ - [EnumMember(Value = "google")] - GOOGLE, - [EnumMember(Value = "facebook")] - FACEBOOK, - [EnumMember(Value = "reddit")] - REDDIT, - [EnumMember(Value = "discord")] - DISCORD, - [EnumMember(Value = "twitch")] - TWITCH, - [EnumMember(Value = "apple")] - APPLE, - [EnumMember(Value = "line")] - LINE, - [EnumMember(Value = "github")] - GITHUB, - [EnumMember(Value = "kakao")] - KAKAO, - [EnumMember(Value = "linkedin")] - LINKEDIN, - [EnumMember(Value = "twitter")] - TWITTER, - [EnumMember(Value = "weibo")] - WEIBO, - [EnumMember(Value = "wechat")] - WECHAT, - [EnumMember(Value = "email_passwordless")] - EMAIL_PASSWORDLESS, - [EnumMember(Value = "email_password")] - EMAIL_PASSWORD, - [EnumMember(Value = "jwt")] - JWT -} \ No newline at end of file diff --git a/Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs.meta b/Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs.meta deleted file mode 100644 index 5659d28..0000000 --- a/Assets/Plugins/Web3AuthSDK/Types/TypeOfLogin.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1465d9a3f378eb64692b5d08c2dee5a9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/Web3AuthSDK/Types/UserInfo.cs b/Assets/Plugins/Web3AuthSDK/Types/UserInfo.cs index 9de1c61..807ee0c 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/UserInfo.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/UserInfo.cs @@ -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; } diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs index 92543f1..7593519 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthOptions.cs @@ -1,30 +1,32 @@ using System; using System.Collections.Generic; +using Newtonsoft.Json; #nullable enable public class Web3AuthOptions { public string clientId { get; set; } - public Web3Auth.Network network { get; set; } + [JsonProperty("network")] + public Web3Auth.Network web3AuthNetwork { get; set; } - public Web3Auth.BuildEnv buildEnv { get; set; } = Web3Auth.BuildEnv.PRODUCTION; + public Web3Auth.BuildEnv authBuildEnv { get; set; } = Web3Auth.BuildEnv.PRODUCTION; public Uri redirectUrl { get; set; } public string sdkUrl { get { - if (buildEnv == Web3Auth.BuildEnv.STAGING) - return "https://staging-auth.web3auth.io/v9"; - else if (buildEnv == Web3Auth.BuildEnv.TESTING) + if (authBuildEnv == Web3Auth.BuildEnv.STAGING) + return "https://staging-auth.web3auth.io/v10"; + else if (authBuildEnv == Web3Auth.BuildEnv.TESTING) return "https://develop-auth.web3auth.io"; else - return "https://auth.web3auth.io/v9"; + return "https://auth.web3auth.io/v10"; } set { } } public string walletSdkUrl { get { - if (buildEnv == Web3Auth.BuildEnv.STAGING) + if (authBuildEnv == Web3Auth.BuildEnv.STAGING) return "https://staging-wallet.web3auth.io/v3"; - else if (buildEnv == Web3Auth.BuildEnv.TESTING) + else if (authBuildEnv == Web3Auth.BuildEnv.TESTING) return "https://develop-wallet.web3auth.io"; else return "https://wallet.web3auth.io/v3"; @@ -32,9 +34,9 @@ public string walletSdkUrl { set { } } public WhiteLabelData? whiteLabel { get; set; } - public Dictionary? loginConfig { get; set; } + public List? authConnectionConfig { get; set; } = new List(); public bool? useCoreKitKey { get; set; } = false; - public Web3Auth.ChainNamespace? chainNamespace { get; set; } = Web3Auth.ChainNamespace.EIP155; + 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; } @@ -44,7 +46,7 @@ public string dashboardUrl { get { - return buildEnv switch + return authBuildEnv switch { Web3Auth.BuildEnv.STAGING => $"https://staging-account.web3auth.io/{authDashboardVersion}/{walletAccountConstant}", Web3Auth.BuildEnv.TESTING => $"https://develop-account.web3auth.io/{walletAccountConstant}", diff --git a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthResponse.cs b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthResponse.cs index 607e47b..531cb29 100644 --- a/Assets/Plugins/Web3AuthSDK/Types/Web3AuthResponse.cs +++ b/Assets/Plugins/Web3AuthSDK/Types/Web3AuthResponse.cs @@ -1,6 +1,9 @@ -public class Web3AuthResponse +using Newtonsoft.Json; +public class Web3AuthResponse { - public string privKey { get; set; } + [JsonProperty("privKey")] + public string privateKey { get; set; } + public string ed25519PrivKey { get; set; } public UserInfo userInfo { get; set; } public string error { get; set; } diff --git a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs index 8b29eb4..a30a4bc 100644 --- a/Assets/Plugins/Web3AuthSDK/Web3Auth.cs +++ b/Assets/Plugins/Web3AuthSDK/Web3Auth.cs @@ -18,9 +18,10 @@ public enum Network MAINNET, TESTNET, CYAN, AQUA, SAPPHIRE_DEVNET, SAPPHIRE_MAINNET } + [JsonConverter(typeof(StringEnumConverter))] public enum ChainNamespace { - EIP155, SOLANA + eip155, solana } public enum BuildEnv @@ -125,16 +126,16 @@ public async void setOptions(Web3AuthOptions web3AuthOptions) if (this.web3AuthOptions.whiteLabel != null) this.initParams["whiteLabel"] = JsonConvert.SerializeObject(this.web3AuthOptions.whiteLabel, settings); - if (this.web3AuthOptions.loginConfig != null) - this.initParams["loginConfig"] = JsonConvert.SerializeObject(this.web3AuthOptions.loginConfig, settings); + if (this.web3AuthOptions.authConnectionConfig != null) + this.initParams["authConnectionConfig"] = JsonConvert.SerializeObject(this.web3AuthOptions.authConnectionConfig, settings); if (this.web3AuthOptions.clientId != null) this.initParams["clientId"] = this.web3AuthOptions.clientId; - if (this.web3AuthOptions.buildEnv != null) - this.initParams["buildEnv"] = this.web3AuthOptions.buildEnv.ToString().ToLower(); + if (this.web3AuthOptions.authBuildEnv != null) + this.initParams["authBuildEnv"] = this.web3AuthOptions.authBuildEnv.ToString().ToLower(); - this.initParams["network"] = this.web3AuthOptions.network.ToString().ToLower(); + this.initParams["network"] = this.web3AuthOptions.web3AuthNetwork.ToString().ToLower(); if (this.web3AuthOptions.useCoreKitKey.HasValue) this.initParams["useCoreKitKey"] = this.web3AuthOptions.useCoreKitKey.Value; @@ -353,7 +354,7 @@ private async void processRequest(string path, LoginParams loginParams = null) } } - public async void launchWalletServices(ChainConfig chainConfig, string path = "wallet") + public async void showWalletUI(List chainConfig, string chainId, string path = "wallet") { string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) @@ -370,7 +371,13 @@ public async void launchWalletServices(ChainConfig chainConfig, string path = "w this.initParams["redirectUrl"] = Utils.GetCurrentURL(); #endif - this.initParams["chainConfig"] = chainConfig; + string chainsJson = JsonConvert.SerializeObject(chainConfig, Formatting.None, new JsonSerializerSettings + { + Converters = new List { new StringEnumConverter() }, + NullValueHandling = NullValueHandling.Ignore + }); + this.initParams["chains"] = chainsJson; + this.initParams["chainId"] = chainId; Dictionary paramMap = new Dictionary(); paramMap["options"] = this.initParams; @@ -524,10 +531,10 @@ private string decodeBase64Params(string base64Params) public void login(LoginParams loginParams) { - if (web3AuthOptions.loginConfig != null) + if (web3AuthOptions.authConnectionConfig != null) { - var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); - var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); + var authConnectionItem = web3AuthOptions.authConnectionConfig?.FirstOrDefault(); + var share = KeyStoreManagerUtils.getPreferencesData(authConnectionItem?.authConnectionId); if (!string.IsNullOrEmpty(share)) { @@ -564,10 +571,10 @@ public void enableMFA(LoginParams loginParams) string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) { - if (web3AuthOptions.loginConfig != null) + if (web3AuthOptions.authConnectionConfig != null) { - var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); - var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); + var authConnectionItem = web3AuthOptions.authConnectionConfig?.FirstOrDefault(); + var share = KeyStoreManagerUtils.getPreferencesData(authConnectionItem?.authConnectionId); if (!string.IsNullOrEmpty(share)) { loginParams.dappShare = share; @@ -590,10 +597,10 @@ public void manageMFA(LoginParams loginParams) string sessionId = KeyStoreManagerUtils.getPreferencesData(KeyStoreManagerUtils.SESSION_ID); if (!string.IsNullOrEmpty(sessionId)) { - if (web3AuthOptions.loginConfig != null) + if (web3AuthOptions.authConnectionConfig != null) { - var loginConfigItem = web3AuthOptions.loginConfig?.Values.First(); - var share = KeyStoreManagerUtils.getPreferencesData(loginConfigItem?.verifier); + var authConnectionItem = web3AuthOptions.authConnectionConfig?.FirstOrDefault(); + var share = KeyStoreManagerUtils.getPreferencesData(authConnectionItem?.authConnectionId); if (!string.IsNullOrEmpty(share)) { loginParams.dappShare = share; @@ -623,10 +630,18 @@ public async void request(ChainConfig chainConfig, string method, JArray request this.initParams["redirectUrl"] = Utils.GetCurrentURL(); #endif - this.initParams["chainConfig"] = chainConfig; + var chainConfigList = new List { chainConfig }; + string chainConfigListJson = JsonConvert.SerializeObject(chainConfigList, Formatting.Indented); + this.initParams["chains"] = chainConfigListJson; + this.initParams["chainId"] = chainConfig.chainId; Dictionary paramMap = new Dictionary(); paramMap["options"] = this.initParams; + foreach (KeyValuePair entry in paramMap) + { + Debug.Log($"Key: {entry.Key}, Value: {JsonUtility.ToJson(entry.Value)}"); + } + var newSessionId = KeyStoreManagerUtils.generateRandomSessionKey(); string loginId = await createSession(JsonConvert.SerializeObject(paramMap, Formatting.None, new JsonSerializerSettings @@ -730,11 +745,11 @@ private void authorizeSession(string newSessionId, string origin) if (!string.IsNullOrEmpty(web3AuthResponse.userInfo?.dappShare)) { KeyStoreManagerUtils.savePreferenceData( - web3AuthResponse.userInfo?.verifier, web3AuthResponse.userInfo?.dappShare + web3AuthResponse.userInfo?.authConnectionId, web3AuthResponse.userInfo?.dappShare ); } - if (string.IsNullOrEmpty(this.web3AuthResponse.privKey) || string.IsNullOrEmpty(this.web3AuthResponse.privKey.Trim('0'))) + if (string.IsNullOrEmpty(this.web3AuthResponse.privateKey) || string.IsNullOrEmpty(this.web3AuthResponse.privateKey.Trim('0'))) this.Enqueue(() => this.onLogout?.Invoke()); else this.Enqueue(() => this.onLogin?.Invoke(this.web3AuthResponse)); @@ -792,8 +807,8 @@ private void sessionTimeOutAPI() try { KeyStoreManagerUtils.deletePreferencesData(KeyStoreManagerUtils.SESSION_ID); - if (web3AuthOptions.loginConfig != null) - KeyStoreManagerUtils.deletePreferencesData(web3AuthOptions.loginConfig?.Values.First()?.verifier); + if (web3AuthOptions.authConnectionConfig != null) + KeyStoreManagerUtils.deletePreferencesData(web3AuthOptions.authConnectionConfig?.FirstOrDefault()?.authConnectionId); this.Enqueue(() => this.onLogout?.Invoke()); } @@ -870,7 +885,7 @@ private async Task createSession(string data, long sessionTime, string a private async Task fetchProjectConfig() { TaskCompletionSource fetchProjectConfigResponse = new TaskCompletionSource(); - StartCoroutine(Web3AuthApi.getInstance().fetchProjectConfig(this.web3AuthOptions.clientId, this.web3AuthOptions.network.ToString().ToLower(), (response => + StartCoroutine(Web3AuthApi.getInstance().fetchProjectConfig(this.web3AuthOptions.clientId, this.web3AuthOptions.web3AuthNetwork.ToString().ToLower(), (response => { if (response != null) { @@ -915,7 +930,7 @@ public string getPrivKey() if (web3AuthResponse == null) return ""; - return web3AuthOptions.useCoreKitKey.Value ? web3AuthResponse.coreKitKey : web3AuthResponse.privKey; + return web3AuthOptions.useCoreKitKey.Value ? web3AuthResponse.coreKitKey : web3AuthResponse.privateKey; } public string getEd25519PrivKey()