From 2874d81d9e0ee05a1ed892a422100f4fdb6a339c Mon Sep 17 00:00:00 2001 From: Maharshi Mishra Date: Tue, 18 Nov 2025 11:09:43 +0530 Subject: [PATCH 1/5] Auth0 example updated and working --- android-auth0-example/app/build.gradle | 2 +- .../com/sbz/web3authdemoapp/MainActivity.kt | 123 +++++++++--------- 2 files changed, 65 insertions(+), 60 deletions(-) diff --git a/android-auth0-example/app/build.gradle b/android-auth0-example/app/build.gradle index 3b896f0..47bdd52 100644 --- a/android-auth0-example/app/build.gradle +++ b/android-auth0-example/app/build.gradle @@ -38,7 +38,7 @@ dependencies { implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.code.gson:gson:2.9.1' - implementation 'com.github.web3auth:web3auth-android-sdk:9.0.4' + implementation 'com.github.web3auth:web3auth-android-sdk:10.0.0' implementation 'org.web3j:core:4.8.7-android' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/android-auth0-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt b/android-auth0-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt index 1dcd3ba..b1fb39c 100644 --- a/android-auth0-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt +++ b/android-auth0-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt @@ -1,7 +1,6 @@ package com.sbz.web3authdemoapp import android.content.Intent -import android.net.Uri import android.os.Bundle import android.util.Log import android.view.View @@ -12,6 +11,7 @@ import androidx.appcompat.app.AppCompatActivity import com.google.gson.Gson import com.web3auth.core.Web3Auth import com.web3auth.core.types.* +import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork import org.web3j.crypto.Credentials import org.web3j.crypto.Hash import org.web3j.crypto.RawTransaction @@ -38,7 +38,6 @@ class MainActivity : AppCompatActivity() { private val gson = Gson() private lateinit var web3: Web3j private lateinit var credentials: Credentials - private lateinit var loginParams: LoginParams private val rpcUrl = "https://1rpc.io/sepolia" override fun onCreate(savedInstanceState: Bundle?) { @@ -46,41 +45,35 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity_main) web3 = Web3j.build(HttpService(rpcUrl)) - loginParams = LoginParams(Provider.JWT, extraLoginOptions = ExtraLoginOptions(domain = "https://web3auth.au.auth0.com", verifierIdField = "sub")) web3Auth = Web3Auth( Web3AuthOptions( - clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard - network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN) - buildEnv = BuildEnv.PRODUCTION, - redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth"), // your app's redirect URL + web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // pass over the network you want to use + redirectUrl = "com.sbz.web3authdemoapp://auth", // your app's redirect URL // Optional parameters - whiteLabel = WhiteLabelData( - "Web3Auth Android Auth0 Example", - null, - "https://cryptologos.cc/logos/ethereum-eth-logo.png", - "https://cryptologos.cc/logos/ethereum-eth-logo.png", - Language.EN, - ThemeModes.LIGHT, - true, - hashMapOf( - "primary" to "#eb5424" + walletServicesConfig = WalletServicesConfig( + whiteLabel = WhiteLabelData( + "Web3Auth Android Auth0 Example", + null, + "https://cryptologos.cc/logos/ethereum-eth-logo.png", + "https://cryptologos.cc/logos/ethereum-eth-logo.png", + Language.EN, + ThemeModes.LIGHT, + true, + hashMapOf( + "primary" to "#eb5424" + ) ) ), - mfaSettings = MfaSettings( - deviceShareFactor = MfaSetting(true, 1, true), - socialBackupFactor = MfaSetting(true, 2, true), - passwordFactor = MfaSetting(true, 3, false), - backUpShareFactor = MfaSetting(true, 4, false), - ), - loginConfig = hashMapOf("jwt" to LoginConfigItem( - verifier = "w3a-auth0-demo", - typeOfLogin = TypeOfLogin.JWT, - name = "Auth0 Login", - clientId = getString(R.string.web3auth_auth0_client_id) - )) - ), context = this + authConnectionConfig = listOf( + AuthConnectionConfig( + authConnection = AuthConnection.CUSTOM, + authConnectionId = "w3a-auth0-demo", + clientId = getString(R.string.web3auth_auth0_client_id) + ) + ) + ), this ) // Handle user signing in when app is not alive @@ -91,10 +84,10 @@ class MainActivity : AppCompatActivity() { sessionResponse.whenComplete { _, error -> if (error == null) { reRender() - println("PrivKey: " + web3Auth.getPrivkey()) - println("ed25519PrivKey: " + web3Auth.getEd25519PrivKey()) + println("PrivKey: " + web3Auth.getPrivateKey()) + println("ed25519PrivKey: " + web3Auth.getEd25519PrivateKey()) println("Web3Auth UserInfo" + web3Auth.getUserInfo()) - credentials = Credentials.create(web3Auth.getPrivkey()) + credentials = Credentials.create(web3Auth.getPrivateKey()) } else { Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") // Ideally, you should initiate the login function here. @@ -151,19 +144,34 @@ class MainActivity : AppCompatActivity() { } private fun signIn() { - val loginCompletableFuture: CompletableFuture = web3Auth.login(loginParams) - - // For Email Passwordless, use the below code and pass email id into extraLoginOptions of LoginParams. - // val selectedLoginProvider = Provider.EMAIL_PASSWORDLESS - // val loginCompletableFuture: CompletableFuture = web3Auth.login(LoginParams(selectedLoginProvider, extraLoginOptions = ExtraLoginOptions(login_hint = "shahbaz.web3@gmail.com"))) - - // For login with Custom JWT, use the below code and pass email id into extraLoginOptions of LoginParams. - // val selectedLoginProvider = Provider.JWT - // val loginCompletableFuture: CompletableFuture = web3Auth.login(LoginParams(selectedLoginProvider, extraLoginOptions = ExtraLoginOptions(id_token = "", domain: "your-domain"))) + val extraLoginOptionsData = ExtraLoginOptions( + domain = "https://web3auth.au.auth0.com" + ) + val loginParams = LoginParams( + authConnection = AuthConnection.CUSTOM, + authConnectionId = "w3a-auth0-demo", + extraLoginOptions = extraLoginOptionsData + ) + val loginCompletableFuture: CompletableFuture = web3Auth.connectTo(loginParams) + + // For Email Passwordless, use the below code and pass email id into loginHint of LoginParams. + // val loginParams = LoginParams( + // authConnection = AuthConnection.EMAIL_PASSWORDLESS, + // loginHint = "shahbaz.web3@gmail.com" + // ) + // val loginCompletableFuture: CompletableFuture = web3Auth.connectTo(loginParams) + + // For login with Custom JWT, use the below code and pass idToken into LoginParams. + // val loginParams = LoginParams( + // authConnection = AuthConnection.CUSTOM, + // authConnectionId = "your-verifier-id", + // idToken = "" + // ) + // val loginCompletableFuture: CompletableFuture = web3Auth.connectTo(loginParams) loginCompletableFuture.whenComplete { _, error -> if (error == null) { - credentials = Credentials.create(web3Auth.getPrivkey()) + credentials = Credentials.create(web3Auth.getPrivateKey()) reRender() } else { Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong" ) @@ -172,7 +180,14 @@ class MainActivity : AppCompatActivity() { } private fun enableMFA() { - + val extraLoginOptionsData = ExtraLoginOptions( + domain = "https://web3auth.au.auth0.com" + ) + val loginParams = LoginParams( + authConnection = AuthConnection.CUSTOM, + authConnectionId = "w3a-auth0-demo", + extraLoginOptions = extraLoginOptionsData + ) val completableFuture = web3Auth.enableMFA(loginParams) completableFuture.whenComplete{_, error -> @@ -187,21 +202,11 @@ class MainActivity : AppCompatActivity() { } private fun launchWalletServices() { - val completableFuture = web3Auth.launchWalletServices( - ChainConfig( - chainId = "0x1", - rpcTarget = "https://1rpc.io/eth", - ticker = "ETH", - chainNamespace = ChainNamespace.EIP155 - ) - ) - - completableFuture.whenComplete{_, error -> - if(error == null) { - // Add your logic - Log.d("MainActivity_Web3Auth", "Wallet services launched successfully") + val launchWalletCompletableFuture = web3Auth.showWalletUI() + launchWalletCompletableFuture.whenComplete { _, error -> + if (error == null) { + Log.d("MainActivity_Web3Auth", "Wallet launched successfully") } else { - // Add your logic for error Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") } } @@ -297,7 +302,7 @@ class MainActivity : AppCompatActivity() { var key: String? = null var userInfo: UserInfo? = null try { - key = web3Auth.getPrivkey() + key = web3Auth.getPrivateKey() userInfo = web3Auth.getUserInfo() } catch (ex: Exception) { print(ex) From 023b8ca7ab27a62b9627e0b00773d17b91a853a1 Mon Sep 17 00:00:00 2001 From: Maharshi Mishra Date: Tue, 18 Nov 2025 11:12:56 +0530 Subject: [PATCH 2/5] quickstart example updated and tested --- android-quick-start/app/build.gradle | 2 +- .../com/sbz/web3authdemoapp/MainActivity.kt | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/android-quick-start/app/build.gradle b/android-quick-start/app/build.gradle index 02a0202..7f7d227 100644 --- a/android-quick-start/app/build.gradle +++ b/android-quick-start/app/build.gradle @@ -44,7 +44,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.code.gson:gson:2.9.1' // IMP START - Installation - implementation 'com.github.web3auth:web3auth-android-sdk:9.0.4' + implementation 'com.github.web3auth:web3auth-android-sdk:10.0.0' // IMP END - Installation implementation 'org.web3j:core:4.8.7-android' testImplementation 'junit:junit:4.13.2' diff --git a/android-quick-start/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt b/android-quick-start/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt index 88be727..04d79ea 100644 --- a/android-quick-start/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt +++ b/android-quick-start/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt @@ -2,7 +2,6 @@ package com.sbz.web3authdemoapp import android.content.Intent -import android.net.Uri import android.os.Bundle import android.util.Log import android.view.View @@ -16,6 +15,7 @@ import com.google.gson.Gson import com.web3auth.core.Web3Auth // IMP END - Quick Start import com.web3auth.core.types.* +import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork import org.web3j.crypto.Credentials import org.web3j.crypto.Hash import org.web3j.crypto.RawTransaction @@ -54,9 +54,8 @@ class MainActivity : AppCompatActivity() { web3Auth = Web3Auth( Web3AuthOptions( clientId = getString(R.string.web3auth_project_id), - network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET) - buildEnv = BuildEnv.PRODUCTION, - redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth") + web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // pass over the network you want to use + redirectUrl = "com.sbz.web3authdemoapp://auth" ), this ) // IMP END - Initialize Web3Auth @@ -68,10 +67,10 @@ class MainActivity : AppCompatActivity() { sessionResponse.whenComplete { _, error -> if (error == null) { reRender() - println("PrivKey: " + web3Auth.getPrivkey()) - println("ed25519PrivKey: " + web3Auth.getEd25519PrivKey()) + println("PrivKey: " + web3Auth.getPrivateKey()) + println("ed25519PrivKey: " + web3Auth.getEd25519PrivateKey()) println("Web3Auth UserInfo" + web3Auth.getUserInfo()) - credentials = Credentials.create(web3Auth.getPrivkey()) + credentials = Credentials.create(web3Auth.getPrivateKey()) web3 = Web3j.build(HttpService(rpcUrl)) } else { Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") @@ -125,17 +124,20 @@ class MainActivity : AppCompatActivity() { private fun signIn() { val email = emailInput.text.toString() // IMP START - Login - val selectedLoginProvider = Provider.EMAIL_PASSWORDLESS // Can be GOOGLE, FACEBOOK, TWITCH etc. - val loginParams = LoginParams(selectedLoginProvider, extraLoginOptions = ExtraLoginOptions(login_hint = email)) + val selectedLoginProvider = AuthConnection.EMAIL_PASSWORDLESS // Can be GOOGLE, FACEBOOK, TWITCH etc. + val loginParams = LoginParams( + selectedLoginProvider, + loginHint = email + ) val loginCompletableFuture: CompletableFuture = - web3Auth.login(loginParams) + web3Auth.connectTo(loginParams) // IMP END - Login loginCompletableFuture.whenComplete { _, error -> if (error == null) { // Set the sessionId from Web3Auth in App State // This will be used when making blockchain calls with Web3j - credentials = Credentials.create(web3Auth.getPrivkey()) + credentials = Credentials.create(web3Auth.getPrivateKey()) web3 = Web3j.build(HttpService(rpcUrl)) reRender() } else { @@ -176,7 +178,7 @@ class MainActivity : AppCompatActivity() { var key: String? = null var userInfo: UserInfo? = null try { - key = web3Auth.getPrivkey() + key = web3Auth.getPrivateKey() // IMP START - Get User Info userInfo = web3Auth.getUserInfo() // IMP END - Get User Info From 3bd388dc8d98e42e737df913e37a2ccf1953f617 Mon Sep 17 00:00:00 2001 From: Maharshi Mishra Date: Tue, 18 Nov 2025 11:50:17 +0530 Subject: [PATCH 3/5] aggregate verifier updated and tested --- .../app/build.gradle | 2 +- .../com/sbz/web3authdemoapp/MainActivity.kt | 264 +++++++++++------- 2 files changed, 161 insertions(+), 105 deletions(-) diff --git a/android-aggregate-verifier-example/app/build.gradle b/android-aggregate-verifier-example/app/build.gradle index 6fdaa6b..1858aaa 100644 --- a/android-aggregate-verifier-example/app/build.gradle +++ b/android-aggregate-verifier-example/app/build.gradle @@ -38,7 +38,7 @@ dependencies { implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.google.code.gson:gson:2.9.1' - implementation 'com.github.web3auth:web3auth-android-sdk:9.0.4' + implementation 'com.github.web3auth:web3auth-android-sdk:10.0.0' implementation 'org.web3j:core:4.8.7-android' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/android-aggregate-verifier-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt b/android-aggregate-verifier-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt index 1acca2f..2567916 100644 --- a/android-aggregate-verifier-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt +++ b/android-aggregate-verifier-example/app/src/main/java/com/sbz/web3authdemoapp/MainActivity.kt @@ -1,7 +1,6 @@ package com.sbz.web3authdemoapp import android.content.Intent -import android.net.Uri import android.os.Bundle import android.util.Log import android.view.View @@ -11,7 +10,21 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.google.gson.Gson import com.web3auth.core.Web3Auth -import com.web3auth.core.types.* +import com.web3auth.core.types.AuthConnection +import com.web3auth.core.types.AuthConnectionConfig +import com.web3auth.core.types.BuildEnv +import com.web3auth.core.types.ExtraLoginOptions +import com.web3auth.core.types.Language +import com.web3auth.core.types.LoginParams +import com.web3auth.core.types.MfaSetting +import com.web3auth.core.types.MfaSettings +import com.web3auth.core.types.ThemeModes +import com.web3auth.core.types.UserInfo +import com.web3auth.core.types.WalletServicesConfig +import com.web3auth.core.types.Web3AuthOptions +import com.web3auth.core.types.Web3AuthResponse +import com.web3auth.core.types.WhiteLabelData +import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork import org.web3j.crypto.Credentials import org.web3j.crypto.Hash import org.web3j.crypto.RawTransaction @@ -32,9 +45,17 @@ import java.util.concurrent.CompletableFuture class MainActivity : AppCompatActivity() { + companion object { + private const val GROUPED_AUTH_CONNECTION_ID = "aggregate-sapphire" + private const val GOOGLE_AUTH_CONNECTION_ID = "w3a-google" + private const val AUTH0_AUTH_CONNECTION_ID = "w3a-a0-email-passwordless" + private const val AUTH0_DOMAIN = "https://web3auth.au.auth0.com" + private const val DEFAULT_CHAIN_ID = "0xaa36a7" // Sepolia + } + private lateinit var web3Auth: Web3Auth private lateinit var web3: Web3j - private lateinit var credentials: Credentials + private var credentials: Credentials? = null private val rpcUrl = "https://1rpc.io/sepolia" private val gson = Gson() @@ -43,69 +64,79 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity_main) web3 = Web3j.build(HttpService(rpcUrl)) + val whiteLabelData = WhiteLabelData( + "Web3Auth Android Example", + null, + "https://cryptologos.cc/logos/ethereum-eth-logo.png", + "https://cryptologos.cc/logos/ethereum-eth-logo.png", + Language.EN, + ThemeModes.LIGHT, + true, + hashMapOf("primary" to "#eb5424") + ) + + val authConnections = listOf( + AuthConnectionConfig( + authConnectionId = GOOGLE_AUTH_CONNECTION_ID, + authConnection = AuthConnection.GOOGLE, + clientId = getString(R.string.web3auth_google_client_id), + groupedAuthConnectionId = GROUPED_AUTH_CONNECTION_ID + ), + AuthConnectionConfig( + authConnectionId = AUTH0_AUTH_CONNECTION_ID, + authConnection = AuthConnection.CUSTOM, + clientId = getString(R.string.web3auth_auth0_client_id), + groupedAuthConnectionId = GROUPED_AUTH_CONNECTION_ID, + jwtParameters = ExtraLoginOptions( + domain = AUTH0_DOMAIN, + userIdField = "email", + isUserIdCaseSensitive = false + ) + ) + ) + web3Auth = Web3Auth( - Web3AuthOptions( - clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard - network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET) - buildEnv = BuildEnv.PRODUCTION, - redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth"), // your app's redirect URL - whiteLabel = WhiteLabelData( - "Web3Auth Android Example", - null, - "https://cryptologos.cc/logos/ethereum-eth-logo.png", - "https://cryptologos.cc/logos/ethereum-eth-logo.png", - Language.EN, - ThemeModes.LIGHT, - true, - hashMapOf( - "primary" to "#eb5424" - ) - ), - mfaSettings = MfaSettings( - deviceShareFactor = MfaSetting(true, 1, true), - socialBackupFactor = MfaSetting(true, 2, true), - passwordFactor = MfaSetting(true, 3, false), - backUpShareFactor = MfaSetting(true, 4, false), - ), - loginConfig = hashMapOf( - "google" to LoginConfigItem( - verifier = "aggregate-sapphire", - verifierSubIdentifier= "w3a-google", - typeOfLogin = TypeOfLogin.GOOGLE, - name = "Aggregate Login", - clientId = getString(R.string.web3auth_google_client_id) - ), - "jwt" to LoginConfigItem( - verifier = "aggregate-sapphire", - verifierSubIdentifier= "w3a-a0-email-passwordless", - typeOfLogin = TypeOfLogin.JWT, - name = "Aggregate Login", - clientId = getString(R.string.web3auth_auth0_client_id) - ) - ) - ), context = this + Web3AuthOptions( + clientId = getString(R.string.web3auth_project_id), + web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, + authBuildEnv = BuildEnv.PRODUCTION, + redirectUrl = "com.sbz.web3authdemoapp://auth", + whiteLabel = whiteLabelData, + walletServicesConfig = WalletServicesConfig(whiteLabel = whiteLabelData), + authConnectionConfig = authConnections, + mfaSettings = MfaSettings( + deviceShareFactor = MfaSetting(true, 1, true), + socialBackupFactor = MfaSetting(true, 2, true), + passwordFactor = MfaSetting(true, 3, false), + backUpShareFactor = MfaSetting(true, 4, false), + ), + defaultChainId = DEFAULT_CHAIN_ID + ), this ) - // Handle user signing in when app is not alive web3Auth.setResultUrl(intent?.data) - // Call initialize() in onCreate() to check for any existing session. val sessionResponse: CompletableFuture = web3Auth.initialize() sessionResponse.whenComplete { _, error -> if (error == null) { + setCredentialsIfPresent() reRender() - println("PrivKey: " + web3Auth.getPrivkey()) - println("ed25519PrivKey: " + web3Auth.getEd25519PrivKey()) - println("Web3Auth UserInfo" + web3Auth.getUserInfo()) - credentials = Credentials.create(web3Auth.getPrivkey()) - Log.d("MainActivity_Web3Auth", web3Auth.getUserInfo().toString()) + try { + println("PrivKey: ${web3Auth.getPrivateKey()}") + println("ed25519PrivKey: ${web3Auth.getEd25519PrivateKey()}") + } catch (ex: Exception) { + Log.d("MainActivity_Web3Auth", ex.message ?: "Unable to fetch keys") + } + println("Web3Auth UserInfo ${web3Auth.getUserInfo()}") + Log.d( + "MainActivity_Web3Auth", + web3Auth.getUserInfo()?.toString() ?: "No user logged in" + ) } else { Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong") - // Ideally, you should initiate the login function here. } } - // Setup UI and event handlers val signInGoogleButton = findViewById