├── .gitignore
├── .idea
├── .gitignore
├── .name
├── codeStyles
│ ├── Project.xml
│ └── codeStyleConfig.xml
├── compiler.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
├── kotlinc.xml
├── migrations.xml
├── misc.xml
├── saveactions_settings.xml
├── thriftCompiler.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── openlogin
│ │ └── app
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── web3auth
│ │ │ └── app
│ │ │ ├── LoginVerifier.kt
│ │ │ └── MainActivity.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── item_dropdown.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── web3auth
│ └── app
│ └── ExampleUnitTest.kt
├── build.gradle
├── core
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── gson.pro
├── proguard-rules.pro
├── retrofit2.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── openlogin
│ │ └── core
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── web3auth
│ │ │ └── core
│ │ │ ├── CustomChromeTabsActivity.kt
│ │ │ ├── Utils.kt
│ │ │ ├── Web3Auth.kt
│ │ │ ├── WebViewActivity.kt
│ │ │ ├── api
│ │ │ ├── ApiHelper.kt
│ │ │ └── ApiService.kt
│ │ │ ├── keystore
│ │ │ └── KeyStoreManagerUtils.kt
│ │ │ └── types
│ │ │ ├── BuildEnv.kt
│ │ │ ├── ChainConfig.kt
│ │ │ ├── ChainNamespace.kt
│ │ │ ├── Curve.kt
│ │ │ ├── Display.kt
│ │ │ ├── ExtraLoginOptions.kt
│ │ │ ├── InitOptions.kt
│ │ │ ├── InitParams.kt
│ │ │ ├── Language.kt
│ │ │ ├── LoginConfigItem.kt
│ │ │ ├── LoginParams.kt
│ │ │ ├── MFALevel.kt
│ │ │ ├── MfaSetting.kt
│ │ │ ├── MfaSettings.kt
│ │ │ ├── Network.kt
│ │ │ ├── ProjectConfigResponse.kt
│ │ │ ├── Prompt.kt
│ │ │ ├── Provider.kt
│ │ │ ├── SessionResponse.kt
│ │ │ ├── SignMessage.kt
│ │ │ ├── SignResponse.kt
│ │ │ ├── ThemeModes.kt
│ │ │ ├── TypeOfLogin.kt
│ │ │ ├── UserCancelledException.kt
│ │ │ ├── UserInfo.kt
│ │ │ ├── Web3AuthError.kt
│ │ │ ├── Web3AuthOptions.kt
│ │ │ ├── Web3AuthResponse.kt
│ │ │ ├── WebViewResultCallback.kt
│ │ │ └── WhiteLabelData.kt
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── activity_cct.xml
│ │ └── activity_webview.xml
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── web3auth
│ └── core
│ └── ExampleUnitTest.kt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jitpack.yml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/dictionaries
7 | /.idea/modules.xml
8 | /.idea/workspace.xml
9 | /.idea/navEditor.xml
10 | /.idea/assetWizardSettings.xml
11 | .DS_Store
12 | /build
13 | /captures
14 | .externalNativeBuild
15 | .cxx
16 | local.properties
17 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | web3auth
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | xmlns:android
19 |
20 | ^$
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | xmlns:.*
30 |
31 | ^$
32 |
33 |
34 | BY_NAME
35 |
36 |
37 |
38 |
39 |
40 |
41 | .*:id
42 |
43 | http://schemas.android.com/apk/res/android
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | .*:name
53 |
54 | http://schemas.android.com/apk/res/android
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | name
64 |
65 | ^$
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | style
75 |
76 | ^$
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | .*
86 |
87 | ^$
88 |
89 |
90 | BY_NAME
91 |
92 |
93 |
94 |
95 |
96 |
97 | .*
98 |
99 | http://schemas.android.com/apk/res/android
100 |
101 |
102 | ANDROID_ATTRIBUTE_ORDER
103 |
104 |
105 |
106 |
107 |
108 |
109 | .*
110 |
111 | .*
112 |
113 |
114 | BY_NAME
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/saveactions_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/thriftCompiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Web3Auth Android SDK
2 |
3 | 
4 |
5 | Web3Auth is where passwordless auth meets non-custodial key infrastructure for Web3 apps and wallets. By aggregating OAuth (Google, Twitter, Discord) logins, different wallets and innovative Multi Party Computation (MPC) - Web3Auth provides a seamless login experience to every user on your application.
6 |
7 | ## 📖 Documentation
8 |
9 | Checkout the official [Web3Auth Documentation](https://web3auth.io/docs) and [SDK Reference](https://web3auth.io/docs/sdk/android/) to get started!
10 |
11 | ## 💡 Features
12 | - Plug and Play, OAuth based Web3 Authentication Service
13 | - Fully decentralized, non-custodial key infrastructure
14 | - End to end Whitelabelable solution
15 | - Threshold Cryptography based Key Reconstruction
16 | - Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
17 | - Support for WebAuthn & Passwordless Login
18 | - Support for connecting to multiple wallets
19 | - DApp Active Session Management
20 |
21 | ...and a lot more
22 |
23 | ## ⏪ Requirements
24 |
25 | - Android API version 24 or newer is required.
26 | - `compileSdkVersion` needs to be 34
27 |
28 | ## ⚡ Installation
29 |
30 | In your project-level `settings.gradle` file, add JitPack repository:
31 |
32 | ```groovy
33 | dependencyResolutionManagement {
34 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
35 | repositories {
36 | google()
37 | mavenCentral()
38 | maven { url "https://jitpack.io" } // <-- Add this line
39 | }
40 | }
41 | ```
42 |
43 | Then, in your app-level `build.gradle` dependencies section, add the following:
44 |
45 | ```groovy
46 | dependencies {
47 | // ...
48 | implementation 'com.github.web3auth:web3auth-android-sdk:9.0.0'
49 | }
50 | ```
51 |
52 | ## 🌟 Configuration
53 | Checkout [SDK Reference](https://web3auth.io/docs/sdk/pnp/android/install#update-permissions) to configure for Android.
54 |
55 | ## 💥 Getting Started
56 |
57 | ```kotlin
58 | import com.web3auth.core.Web3Auth
59 | import com.web3auth.core.types.Web3AuthOptions
60 |
61 | class MainActivity : AppCompatActivity() {
62 | // ...
63 | private lateinit var web3Auth: Web3Auth
64 |
65 | override fun onCreate(savedInstanceState: Bundle?) {
66 | super.onCreate(savedInstanceState)
67 | setContentView(R.layout.activity_main)
68 |
69 | web3Auth = Web3Auth(
70 | Web3AuthOptions(
71 | context = this,
72 | clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
73 | network = Network.MAINNET,
74 | redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
75 | )
76 | )
77 |
78 | // Handle user signing in when app is not alive
79 | web3Auth.setResultUrl(intent?.data)
80 | }
81 |
82 | override fun onResume() {
83 | super.onResume()
84 | if (Web3Auth.getCustomTabsClosed()) {
85 | Toast.makeText(this, "User closed the browser.", Toast.LENGTH_SHORT).show()
86 | web3Auth.setResultUrl(null)
87 | Web3Auth.setCustomTabsClosed(false)
88 | }
89 | }
90 |
91 | override fun onNewIntent(intent: Intent?) {
92 | super.onNewIntent(intent)
93 |
94 | // Handle user signing in when app is active
95 | web3Auth.setResultUrl(intent?.data)
96 |
97 | // ...
98 | }
99 |
100 | private fun onClickLogin() {
101 | val selectedLoginProvider = Provider.GOOGLE // Can be Google, Facebook, Twitch etc
102 | val loginCompletableFuture: CompletableFuture = web3Auth.login(LoginParams(selectedLoginProvider))
103 |
104 | loginCompletableFuture.whenComplete { _, error ->
105 | if (error == null) {
106 | // render logged in UI
107 | } else {
108 | // render login error UI
109 | }
110 |
111 | }
112 | }
113 |
114 | //...
115 | }
116 | ```
117 |
118 | ## 🩹 Examples
119 |
120 | Checkout the examples for your preferred blockchain and platform in our [examples](https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/android)
121 |
122 | ## 🌐 Demo
123 |
124 | Checkout the [Web3Auth Demo](https://demo-app.web3auth.io/) to see how Web3Auth can be used in an application.
125 |
126 | Have a look at our [Web3Auth PnP Android Quick Start](https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/android/android-quick-start) to help you quickly integrate a basic instance of Web3Auth Plug and Play in your Android app.
127 |
128 | Further checkout the [app folder](https://https://github.com/Web3Auth/web3auth-android-sdk/tree/master/app) within this repository, which contains a sample app.
129 |
130 | ## 💬 Troubleshooting and Support
131 |
132 | - Have a look at our [Community Portal](https://community.web3auth.io/) to see if anyone has any questions or issues you might be having. Feel free to reate new topics and we'll help you out as soon as possible.
133 | - Checkout our [Troubleshooting Documentation Page](https://web3auth.io/docs/troubleshooting) to know the common issues and solutions.
134 | - For Priority Support, please have a look at our [Pricing Page](https://web3auth.io/pricing.html) for the plan that suits your needs.
135 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | }
5 |
6 | android {
7 | signingConfigs {
8 | release {
9 | storeFile file('/Users/tanuj/Desktop/Torus/open login/open_login')
10 | storePassword 'torus123'
11 | keyAlias 'key0'
12 | keyPassword 'torus123'
13 | }
14 | }
15 | compileSdk 34
16 |
17 | defaultConfig {
18 | applicationId "com.web3auth.app"
19 | minSdkVersion 26
20 | targetSdkVersion 34
21 | versionCode 1
22 | versionName "1.0"
23 | manifestPlaceholders = [
24 | 'torusRedirectScheme' : 'torusapp',
25 | 'torusRedirectHost' : 'org.torusresearch.web3authexample',
26 | 'torusRedirectPathPrefix': '/redirect'
27 | ]
28 |
29 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
30 | }
31 |
32 | buildTypes {
33 | release {
34 | minifyEnabled true
35 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
36 | signingConfig signingConfigs.debug
37 | }
38 | }
39 | compileOptions {
40 | sourceCompatibility JavaVersion.VERSION_1_8
41 | targetCompatibility JavaVersion.VERSION_1_8
42 | }
43 | kotlinOptions {
44 | jvmTarget = '1.8'
45 | }
46 | }
47 |
48 | dependencies {
49 | // Default
50 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
51 | implementation 'androidx.core:core-ktx:1.8.0'
52 | implementation 'androidx.appcompat:appcompat:1.4.2'
53 | implementation 'com.google.android.material:material:1.6.1'
54 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
55 |
56 | // Completable Futures support
57 | implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.4'
58 |
59 | // Encoding
60 | implementation 'com.google.code.gson:gson:2.9.0'
61 | implementation 'org.web3j:core:4.8.8-android'
62 |
63 | // Web3Auth
64 | implementation project(":core")
65 |
66 | // Test
67 | testImplementation 'junit:junit:4.13.2'
68 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
69 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
70 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | #### GSON
2 | # Prevent proguard from stripping interface information from TypeAdapterFactory,
3 | # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
4 | -keep class * implements com.google.gson.TypeAdapterFactory
5 | -keep class * implements com.google.gson.JsonSerializer
6 | -keep class * implements com.google.gson.JsonDeserializer
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/openlogin/app/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.web3auth.app
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | /**
10 | * Instrumented test, which will execute on an Android device.
11 | *
12 | * See [testing documentation](http://d.android.com/tools/testing).
13 | */
14 | @RunWith(AndroidJUnit4::class)
15 | class ExampleInstrumentedTest {
16 | @Test
17 | fun useAppContext() {
18 | // Context of the app under test.
19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20 | assertEquals("com.web3auth.app", appContext.packageName)
21 | }
22 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/web3auth/app/LoginVerifier.kt:
--------------------------------------------------------------------------------
1 | package com.web3auth.app
2 |
3 | import com.web3auth.core.types.Provider
4 |
5 | data class LoginVerifier(
6 | val name: String,
7 | val loginProvider: Provider
8 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/web3auth/app/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.web3auth.app
2 |
3 | import android.content.Intent
4 | import android.net.Uri
5 | import android.os.Bundle
6 | import android.text.method.ScrollingMovementMethod
7 | import android.util.Log
8 | import android.view.View
9 | import android.widget.AdapterView
10 | import android.widget.ArrayAdapter
11 | import android.widget.AutoCompleteTextView
12 | import android.widget.Button
13 | import android.widget.EditText
14 | import android.widget.TextView
15 | import android.widget.Toast
16 | import androidx.appcompat.app.AlertDialog
17 | import androidx.appcompat.app.AppCompatActivity
18 | import com.google.android.material.textfield.TextInputLayout
19 | import com.google.gson.Gson
20 | import com.google.gson.JsonArray
21 | import com.web3auth.core.Web3Auth
22 | import com.web3auth.core.isEmailValid
23 | import com.web3auth.core.isPhoneNumberValid
24 | import com.web3auth.core.types.BuildEnv
25 | import com.web3auth.core.types.ChainConfig
26 | import com.web3auth.core.types.ChainNamespace
27 | import com.web3auth.core.types.ExtraLoginOptions
28 | import com.web3auth.core.types.Language
29 | import com.web3auth.core.types.LoginConfigItem
30 | import com.web3auth.core.types.LoginParams
31 | import com.web3auth.core.types.MFALevel
32 | import com.web3auth.core.types.Network
33 | import com.web3auth.core.types.Provider
34 | import com.web3auth.core.types.ThemeModes
35 | import com.web3auth.core.types.TypeOfLogin
36 | import com.web3auth.core.types.UserInfo
37 | import com.web3auth.core.types.Web3AuthOptions
38 | import com.web3auth.core.types.Web3AuthResponse
39 | import com.web3auth.core.types.WhiteLabelData
40 | import org.json.JSONObject
41 | import org.web3j.crypto.Credentials
42 | import java.util.concurrent.CompletableFuture
43 |
44 | class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
45 | private lateinit var web3Auth: Web3Auth
46 |
47 | private val verifierList: List = listOf(
48 | LoginVerifier("Google", Provider.GOOGLE),
49 | LoginVerifier("Facebook", Provider.FACEBOOK),
50 | LoginVerifier("Twitch", Provider.TWITCH),
51 | LoginVerifier("Discord", Provider.DISCORD),
52 | LoginVerifier("Reddit", Provider.REDDIT),
53 | LoginVerifier("Apple", Provider.APPLE),
54 | LoginVerifier("Github", Provider.GITHUB),
55 | LoginVerifier("LinkedIn", Provider.LINKEDIN),
56 | LoginVerifier("Twitter", Provider.TWITTER),
57 | LoginVerifier("Line", Provider.LINE),
58 | LoginVerifier("Hosted Email Passwordless", Provider.EMAIL_PASSWORDLESS),
59 | LoginVerifier("SMS Passwordless", Provider.SMS_PASSWORDLESS),
60 | LoginVerifier("JWT", Provider.JWT),
61 | LoginVerifier("Farcaster", Provider.FARCASTER)
62 | )
63 |
64 | private var selectedLoginProvider: Provider = Provider.GOOGLE
65 |
66 | private val gson = Gson()
67 |
68 | private fun signIn() {
69 | val hintEmailEditText = findViewById(R.id.etEmailHint)
70 | var extraLoginOptions: ExtraLoginOptions? = null
71 | if (selectedLoginProvider == Provider.EMAIL_PASSWORDLESS) {
72 | val hintEmail = hintEmailEditText.text.toString()
73 | if (hintEmail.isBlank() || !hintEmail.isEmailValid()) {
74 | Toast.makeText(this, "Please enter a valid Email.", Toast.LENGTH_LONG).show()
75 | return
76 | }
77 | extraLoginOptions = ExtraLoginOptions(login_hint = hintEmail)
78 | }
79 |
80 | if (selectedLoginProvider == Provider.SMS_PASSWORDLESS) {
81 | val hintPhNo = hintEmailEditText.text.toString()
82 | if (hintPhNo.isBlank() || !hintPhNo.isPhoneNumberValid()) {
83 | Toast.makeText(this, "Please enter a valid Number.", Toast.LENGTH_LONG).show()
84 | return
85 | }
86 | extraLoginOptions = ExtraLoginOptions(login_hint = hintPhNo)
87 | }
88 |
89 | val loginCompletableFuture: CompletableFuture = web3Auth.login(
90 | LoginParams(
91 | selectedLoginProvider,
92 | extraLoginOptions = extraLoginOptions,
93 | mfaLevel = MFALevel.OPTIONAL
94 | )
95 | )
96 | loginCompletableFuture.whenComplete { _, error ->
97 | if (error == null) {
98 | reRender()
99 | println("PrivKey: " + web3Auth.getPrivkey())
100 | println("ed25519PrivKey: " + web3Auth.getEd25519PrivKey())
101 | println("Web3Auth UserInfo" + web3Auth.getUserInfo())
102 | } else {
103 | Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
104 | }
105 | }
106 | }
107 |
108 | private fun signOut() {
109 | val logoutCompletableFuture = web3Auth.logout()
110 | logoutCompletableFuture.whenComplete { _, error ->
111 | if (error == null) {
112 | reRender()
113 | } else {
114 | Log.d("MainActivity_Web3Auth", error.message ?: "Something went wrong")
115 | }
116 | }
117 | }
118 |
119 | private fun reRender() {
120 | val contentTextView = findViewById(R.id.contentTextView)
121 | val signInButton = findViewById