@@ -11,7 +11,7 @@ public class Web3AuthSample : MonoBehaviour
1111 List < LoginVerifier > verifierList = new List < LoginVerifier > {
1212 new LoginVerifier ( "Google" , Provider . GOOGLE ) ,
1313 new LoginVerifier ( "Facebook" , Provider . FACEBOOK ) ,
14- new LoginVerifier ( "CUSTOM_VERIFIER" , Provider . CUSTOM_VERIFIER ) ,
14+ // new LoginVerifier("CUSTOM_VERIFIER", Provider.CUSTOM_VERIFIER),
1515 new LoginVerifier ( "Twitch" , Provider . TWITCH ) ,
1616 new LoginVerifier ( "Discord" , Provider . DISCORD ) ,
1717 new LoginVerifier ( "Reddit" , Provider . REDDIT ) ,
@@ -20,7 +20,9 @@ public class Web3AuthSample : MonoBehaviour
2020 new LoginVerifier ( "LinkedIn" , Provider . LINKEDIN ) ,
2121 new LoginVerifier ( "Twitter" , Provider . TWITTER ) ,
2222 new LoginVerifier ( "Line" , Provider . LINE ) ,
23- new LoginVerifier ( "Hosted Email Passwordless" , Provider . EMAIL_PASSWORDLESS ) ,
23+ new LoginVerifier ( "Email Passwordless" , Provider . EMAIL_PASSWORDLESS ) ,
24+ new LoginVerifier ( "SMS Passwordless" , Provider . SMS_PASSWORDLESS ) ,
25+ new LoginVerifier ( "Farcaster" , Provider . FARCASTER ) ,
2426 } ;
2527
2628 Web3Auth web3Auth ;
@@ -40,6 +42,12 @@ public class Web3AuthSample : MonoBehaviour
4042 [ SerializeField ]
4143 Button logoutButton ;
4244
45+ [ SerializeField ]
46+ Button mfaSetupButton ;
47+
48+ [ SerializeField ]
49+ Button launchWalletServicesButton ;
50+
4351 void Start ( )
4452 {
4553 var loginConfigItem = new LoginConfigItem ( )
@@ -61,7 +69,7 @@ void Start()
6169 mode = ThemeModes . dark ,
6270 theme = new Dictionary < string , string >
6371 {
64- { "primary" , "#123456 " }
72+ { "primary" , "#FFBF00 " }
6573 }
6674 } ,
6775 // If using your own custom verifier, uncomment this code.
@@ -73,19 +81,24 @@ void Start()
7381 }
7482 */
7583 clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ" ,
76- buildEnv = BuildEnv . TESTING ,
84+ buildEnv = BuildEnv . PRODUCTION ,
7785 redirectUrl = new Uri ( "torusapp://com.torus.Web3AuthUnity/auth" ) ,
7886 network = Web3Auth . Network . SAPPHIRE_MAINNET ,
7987 sessionTime = 86400
8088 } ) ;
8189 web3Auth . onLogin += onLogin ;
8290 web3Auth . onLogout += onLogout ;
91+ web3Auth . onMFASetup += onMFASetup ;
8392
8493 emailAddressField . gameObject . SetActive ( false ) ;
8594 logoutButton . gameObject . SetActive ( false ) ;
95+ mfaSetupButton . gameObject . SetActive ( false ) ;
96+ launchWalletServicesButton . gameObject . SetActive ( false ) ;
8697
8798 loginButton . onClick . AddListener ( login ) ;
8899 logoutButton . onClick . AddListener ( logout ) ;
100+ mfaSetupButton . onClick . AddListener ( enableMFA ) ;
101+ launchWalletServicesButton . onClick . AddListener ( launchWalletServices ) ;
89102
90103 verifierDropdown . AddOptions ( verifierList . Select ( x => x . name ) . ToList ( ) ) ;
91104 verifierDropdown . onValueChanged . AddListener ( onVerifierDropDownChange ) ;
@@ -101,17 +114,25 @@ private void onLogin(Web3AuthResponse response)
101114 verifierDropdown . gameObject . SetActive ( false ) ;
102115 emailAddressField . gameObject . SetActive ( false ) ;
103116 logoutButton . gameObject . SetActive ( true ) ;
117+ mfaSetupButton . gameObject . SetActive ( true ) ;
118+ launchWalletServicesButton . gameObject . SetActive ( true ) ;
104119 }
105120
106121 private void onLogout ( )
107122 {
108123 loginButton . gameObject . SetActive ( true ) ;
109124 verifierDropdown . gameObject . SetActive ( true ) ;
110125 logoutButton . gameObject . SetActive ( false ) ;
126+ mfaSetupButton . gameObject . SetActive ( false ) ;
127+ launchWalletServicesButton . gameObject . SetActive ( false ) ;
111128
112129 loginResponseText . text = "" ;
113130 }
114131
132+ private void onMFASetup ( bool response ) {
133+ Debug . Log ( "MFA Setup: " + response ) ;
134+ }
135+
115136
116137 private void onVerifierDropDownChange ( int selectedIndex )
117138 {
@@ -137,6 +158,13 @@ private void login()
137158 login_hint = emailAddressField . text
138159 } ;
139160 }
161+ if ( selectedProvider == Provider . SMS_PASSWORDLESS )
162+ {
163+ options . extraLoginOptions = new ExtraLoginOptions ( )
164+ {
165+ login_hint = "+XX-XXXXXXXXXX"
166+ } ;
167+ }
140168
141169 web3Auth . login ( options ) ;
142170 }
@@ -145,4 +173,37 @@ private void logout()
145173 {
146174 web3Auth . logout ( ) ;
147175 }
176+
177+ private void enableMFA ( )
178+ {
179+ var selectedProvider = verifierList [ verifierDropdown . value ] . loginProvider ;
180+
181+ var options = new LoginParams ( )
182+ {
183+ loginProvider = selectedProvider ,
184+ mfaLevel = MFALevel . MANDATORY
185+ } ;
186+
187+ if ( selectedProvider == Provider . EMAIL_PASSWORDLESS )
188+ {
189+ options . extraLoginOptions = new ExtraLoginOptions ( )
190+ {
191+ login_hint = emailAddressField . text
192+ } ;
193+ }
194+ web3Auth . enableMFA ( options ) ;
195+ }
196+
197+ private void launchWalletServices ( ) {
198+ var selectedProvider = verifierList [ verifierDropdown . value ] . loginProvider ;
199+
200+ var chainConfig = new ChainConfig ( )
201+ {
202+ chainId = "0x1" ,
203+ rpcTarget = "https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0" ,
204+ ticker = "ETH" ,
205+ chainNamespace = Web3Auth . ChainNamespace . EIP155
206+ } ;
207+ web3Auth . launchWalletServices ( chainConfig ) ;
208+ }
148209}
0 commit comments