Skip to content

feat: auth-service v10 and wallet-service changes #114

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 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {

buildTypes {
release {
minifyEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/web3auth/app/AuthConnectionLogin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.web3auth.app

import com.web3auth.core.types.AuthConnection

data class AuthConnectionLogin(
val name: String,
val authConnection: AuthConnection
)
8 changes: 0 additions & 8 deletions app/src/main/java/com/web3auth/app/LoginVerifier.kt

This file was deleted.

89 changes: 46 additions & 43 deletions app/src/main/java/com/web3auth/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ import com.google.gson.JsonArray
import com.web3auth.core.Web3Auth
import com.web3auth.core.isEmailValid
import com.web3auth.core.isPhoneNumberValid
import com.web3auth.core.types.AuthConnection
import com.web3auth.core.types.AuthConnectionConfig
import com.web3auth.core.types.BuildEnv
import com.web3auth.core.types.ChainConfig
import com.web3auth.core.types.ChainNamespace
import com.web3auth.core.types.ExtraLoginOptions
import com.web3auth.core.types.Language
import com.web3auth.core.types.LoginConfigItem
import com.web3auth.core.types.LoginParams
import com.web3auth.core.types.MFALevel
import com.web3auth.core.types.Network
import com.web3auth.core.types.Provider
import com.web3auth.core.types.ThemeModes
import com.web3auth.core.types.TypeOfLogin
import com.web3auth.core.types.UserInfo
import com.web3auth.core.types.Web3AuthNetwork
import com.web3auth.core.types.Web3AuthOptions
import com.web3auth.core.types.Web3AuthResponse
import com.web3auth.core.types.WhiteLabelData
Expand All @@ -44,31 +43,31 @@ import java.util.concurrent.CompletableFuture
class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
private lateinit var web3Auth: Web3Auth

private val verifierList: List<LoginVerifier> = listOf(
LoginVerifier("Google", Provider.GOOGLE),
LoginVerifier("Facebook", Provider.FACEBOOK),
LoginVerifier("Twitch", Provider.TWITCH),
LoginVerifier("Discord", Provider.DISCORD),
LoginVerifier("Reddit", Provider.REDDIT),
LoginVerifier("Apple", Provider.APPLE),
LoginVerifier("Github", Provider.GITHUB),
LoginVerifier("LinkedIn", Provider.LINKEDIN),
LoginVerifier("Twitter", Provider.TWITTER),
LoginVerifier("Line", Provider.LINE),
LoginVerifier("Hosted Email Passwordless", Provider.EMAIL_PASSWORDLESS),
LoginVerifier("SMS Passwordless", Provider.SMS_PASSWORDLESS),
LoginVerifier("JWT", Provider.JWT),
LoginVerifier("Farcaster", Provider.FARCASTER)
private val authConnectionList: List<AuthConnectionLogin> = listOf(
AuthConnectionLogin("Google", AuthConnection.GOOGLE),
AuthConnectionLogin("Facebook", AuthConnection.FACEBOOK),
AuthConnectionLogin("Twitch", AuthConnection.TWITCH),
AuthConnectionLogin("Discord", AuthConnection.DISCORD),
AuthConnectionLogin("Reddit", AuthConnection.REDDIT),
AuthConnectionLogin("Apple", AuthConnection.APPLE),
AuthConnectionLogin("Github", AuthConnection.GITHUB),
AuthConnectionLogin("LinkedIn", AuthConnection.LINKEDIN),
AuthConnectionLogin("Twitter", AuthConnection.TWITTER),
AuthConnectionLogin("Line", AuthConnection.LINE),
AuthConnectionLogin("Hosted Email Passwordless", AuthConnection.EMAIL_PASSWORDLESS),
AuthConnectionLogin("SMS Passwordless", AuthConnection.SMS_PASSWORDLESS),
AuthConnectionLogin("CUSTOM", AuthConnection.CUSTOM),
AuthConnectionLogin("Farcaster", AuthConnection.FARCASTER)
)

private var selectedLoginProvider: Provider = Provider.GOOGLE
private var selectedLoginProvider: AuthConnection = AuthConnection.GOOGLE

private val gson = Gson()

private fun signIn() {
val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)
var extraLoginOptions: ExtraLoginOptions? = null
if (selectedLoginProvider == Provider.EMAIL_PASSWORDLESS) {
if (selectedLoginProvider == AuthConnection.EMAIL_PASSWORDLESS) {
val hintEmail = hintEmailEditText.text.toString()
if (hintEmail.isBlank() || !hintEmail.isEmailValid()) {
Toast.makeText(this, "Please enter a valid Email.", Toast.LENGTH_LONG).show()
Expand All @@ -77,7 +76,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
extraLoginOptions = ExtraLoginOptions(login_hint = hintEmail)
}

if (selectedLoginProvider == Provider.SMS_PASSWORDLESS) {
if (selectedLoginProvider == AuthConnection.SMS_PASSWORDLESS) {
val hintPhNo = hintEmailEditText.text.toString()
if (hintPhNo.isBlank() || !hintPhNo.isPhoneNumberValid()) {
Toast.makeText(this, "Please enter a valid Number.", Toast.LENGTH_LONG).show()
Expand Down Expand Up @@ -124,7 +123,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
val signMsgButton = findViewById<Button>(R.id.signMsgButton)
val btnSetUpMfa = findViewById<Button>(R.id.btnSetUpMfa)
val btnManageMfa = findViewById<Button>(R.id.btn_manageMfa)
val spinner = findViewById<TextInputLayout>(R.id.verifierList)
val spinner = findViewById<TextInputLayout>(R.id.authConnectionList)
val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)
var key: String? = null
var userInfo: UserInfo? = null
Expand Down Expand Up @@ -168,10 +167,10 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {

val options = Web3AuthOptions(
clientId = "BFuUqebV5I8Pz5F7a5A2ihW7YVmbv_OHXnHYDv6OltAD5NGr6e-ViNvde3U4BHdn6HvwfkgobhVu4VwC-OSJkik",
network = Network.SAPPHIRE_DEVNET,
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_DEVNET,
redirectUrl = Uri.parse("torusapp://org.torusresearch.web3authexample"),
// sdkUrl = "https://auth.mocaverse.xyz",
// walletSdkUrl = "https://lrc-mocaverse.web3auth.io",
//sdkUrl = "https://auth.mocaverse.xyz",
//walletSdkUrl = "https://lrc-mocaverse.web3auth.io",
whiteLabel = WhiteLabelData(
"Web3Auth Sample App", null, null, null,
Language.EN, ThemeModes.LIGHT, true,
Expand All @@ -180,14 +179,14 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
"onPrimary" to "#0000FF"
)
),
loginConfig = hashMapOf(
"loginConfig" to LoginConfigItem(
"web3auth-auth0-email-passwordless-sapphire-devnet",
typeOfLogin = TypeOfLogin.JWT,
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C",
authConnectionConfig = listOf(
AuthConnectionConfig(
authConnectionId = "web3auth-auth0-email-passwordless-sapphire-devnet",
authConnection = AuthConnection.CUSTOM,
clientId = "d84f6xvbdV75VTGmHiMWfZLeSPk8M07C"
)
),
buildEnv = BuildEnv.PRODUCTION,
authBuildEnv = BuildEnv.TESTING,
sessionTime = 86400,
)

Expand All @@ -198,6 +197,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
options, this
)

//Set intent result url from Web3Auth redirect
web3Auth.setResultUrl(intent.data)

// for session response
Expand All @@ -223,12 +223,15 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {

val launchWalletButton = findViewById<Button>(R.id.launchWalletButton)
launchWalletButton.setOnClickListener {
val launchWalletCompletableFuture = web3Auth.launchWalletServices(
chainConfig = ChainConfig(
chainId = "0x89",
rpcTarget = "https://1rpc.io/matic",
chainNamespace = ChainNamespace.EIP155
)
val launchWalletCompletableFuture = web3Auth.showWalletUI(
chainConfig = listOf(
ChainConfig(
chainId = "0x89",
rpcTarget = "https://1rpc.io/matic",
chainNamespace = ChainNamespace.EIP155
)
),
chainId = "0x89",
)
launchWalletCompletableFuture.whenComplete { _, error ->
if (error == null) {
Expand Down Expand Up @@ -288,7 +291,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
}

val spinner = findViewById<AutoCompleteTextView>(R.id.spinnerTextView)
val loginVerifierList: List<String> = verifierList.map { item ->
val loginVerifierList: List<String> = authConnectionList.map { item ->
item.name
}
val adapter: ArrayAdapter<String> =
Expand All @@ -312,17 +315,17 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemClickListener {
}

override fun onItemClick(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
selectedLoginProvider = verifierList[p2].loginProvider
selectedLoginProvider = authConnectionList[p2].authConnection

val hintEmailEditText = findViewById<EditText>(R.id.etEmailHint)

if (selectedLoginProvider == Provider.EMAIL_PASSWORDLESS) {
if (selectedLoginProvider == AuthConnection.EMAIL_PASSWORDLESS) {
hintEmailEditText.hint = "Enter Email"
} else if (selectedLoginProvider == Provider.SMS_PASSWORDLESS) {
} else if (selectedLoginProvider == AuthConnection.SMS_PASSWORDLESS) {
hintEmailEditText.hint = "Enter Phone Number"
}

if (selectedLoginProvider == Provider.EMAIL_PASSWORDLESS || selectedLoginProvider == Provider.SMS_PASSWORDLESS) {
if (selectedLoginProvider == AuthConnection.EMAIL_PASSWORDLESS || selectedLoginProvider == AuthConnection.SMS_PASSWORDLESS) {
hintEmailEditText.visibility = View.VISIBLE
} else {
hintEmailEditText.visibility = View.GONE
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tools:context="com.web3auth.app.MainActivity">

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/verifierList"
android:id="@+id/authConnectionList"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -39,7 +39,7 @@
android:backgroundTint="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/verifierList" />
app:layout_constraintTop_toBottomOf="@id/authConnectionList" />


<TextView
Expand Down
4 changes: 4 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ android {
}

buildTypes {
debug {
minifyEnabled false
debuggable true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand Down
Loading