Skip to content

Commit

Permalink
feat: Rename SingleFactorAuthArgs to SFAParams
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Goel <[email protected]>
  • Loading branch information
grvgoel81 authored and Gaurav Goel committed Sep 2, 2024
1 parent 5ebe8cf commit f8d8695
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 28 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/web3auth/sfaexample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.web3auth.singlefactorauth.SingleFactorAuth
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

class MainActivity : AppCompatActivity() {

private lateinit var btnTorusKey: Button
private lateinit var tv: TextView
lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var sfaParams: SingleFactorAuthArgs
private lateinit var sfaParams: SFAParams
lateinit var loginParams: LoginParams
var TEST_VERIFIER = "torus-test-health"
var TORUS_TEST_EMAIL = "[email protected]"
Expand All @@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity() {
}
val idToken = JwtUtils.generateIdToken(TORUS_TEST_EMAIL)
sfaParams =
SingleFactorAuthArgs(Web3AuthNetwork.SAPPHIRE_MAINNET, "YOUR_CLIENT_ID", null,0)
SFAParams(Web3AuthNetwork.SAPPHIRE_MAINNET, "YOUR_CLIENT_ID", null, 0)
singleFactorAuth = SingleFactorAuth(sfaParams, this)
loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.auth0.jwt.algorithms.Algorithm
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo
import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken
import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader
Expand All @@ -25,7 +25,7 @@ import java.util.concurrent.ExecutionException
class AquaTest {

lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var sfaParams: SingleFactorAuthArgs
private lateinit var sfaParams: SFAParams
lateinit var loginParams: LoginParams
lateinit var algorithmRs: Algorithm
var TEST_VERIFIER = "torus-test-health"
Expand All @@ -37,7 +37,7 @@ class AquaTest {
fun shouldGetTorusKey() {

val context = getInstrumentation().context
sfaParams = SingleFactorAuthArgs(Web3AuthNetwork.AQUA, "YOUR_CLIENT_ID", null, 0)
sfaParams = SFAParams(Web3AuthNetwork.AQUA, "YOUR_CLIENT_ID", null, 0)
singleFactorAuth = SingleFactorAuth(sfaParams, context)
val privateKey = readPrivateKeyFromReader(
WellKnownSecret.pem(),
Expand Down Expand Up @@ -67,7 +67,7 @@ class AquaTest {
@Test
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldAggregrateGetTorusKey() {
sfaParams = SingleFactorAuthArgs(Web3AuthNetwork.AQUA, "YOUR_CLIENT_ID")
sfaParams = SFAParams(Web3AuthNetwork.AQUA, "YOUR_CLIENT_ID")
val context = getInstrumentation().context
singleFactorAuth = SingleFactorAuth(sfaParams, context)
val privateKey = readPrivateKeyFromReader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.web3auth.singlefactorauth
import androidx.test.platform.app.InstrumentationRegistry
import com.auth0.jwt.algorithms.Algorithm
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo
import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken
import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader
Expand All @@ -21,7 +21,7 @@ import java.util.concurrent.ExecutionException
class CyanTest {

lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var sfaParams: SingleFactorAuthArgs
private lateinit var sfaParams: SFAParams
lateinit var loginParams: LoginParams
lateinit var algorithmRs: Algorithm
var TEST_VERIFIER = "torus-test-health"
Expand All @@ -32,7 +32,7 @@ class CyanTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(Web3AuthNetwork.CYAN, "YOUR_CLIENT_ID", null, 0)
sfaParams = SFAParams(Web3AuthNetwork.CYAN, "YOUR_CLIENT_ID", null, 0)
singleFactorAuth = SingleFactorAuth(sfaParams,context)
val privateKey = readPrivateKeyFromReader(
WellKnownSecret.pem(),
Expand Down Expand Up @@ -62,7 +62,7 @@ class CyanTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldAggregrateGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(Web3AuthNetwork.CYAN, "YOUR_CLIENT_ID")
sfaParams = SFAParams(Web3AuthNetwork.CYAN, "YOUR_CLIENT_ID")
singleFactorAuth = SingleFactorAuth(sfaParams, context)
val privateKey = readPrivateKeyFromReader(
WellKnownSecret.pem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.web3auth.singlefactorauth
import androidx.test.platform.app.InstrumentationRegistry
import com.auth0.jwt.algorithms.Algorithm
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo
import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken
import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader
Expand All @@ -21,7 +21,7 @@ import java.util.concurrent.ExecutionException
class SapphireDevnetTest {

lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var sfaParams: SingleFactorAuthArgs
private lateinit var sfaParams: SFAParams
lateinit var loginParams: LoginParams
lateinit var algorithmRs: Algorithm
var TEST_VERIFIER = "torus-test-health"
Expand All @@ -32,7 +32,7 @@ class SapphireDevnetTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(
sfaParams = SFAParams(
Web3AuthNetwork.SAPPHIRE_DEVNET,
"CLIENT ID", null, 0
)
Expand Down Expand Up @@ -65,7 +65,7 @@ class SapphireDevnetTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldAggregrateGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(
sfaParams = SFAParams(
Web3AuthNetwork.SAPPHIRE_DEVNET,
"CLIENT_ID"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.web3auth.singlefactorauth
import androidx.test.platform.app.InstrumentationRegistry
import com.auth0.jwt.algorithms.Algorithm
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo
import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken
import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader
Expand All @@ -21,7 +21,7 @@ import java.util.concurrent.ExecutionException
class SapphireMainnetTest {

lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var sfaParams: SingleFactorAuthArgs
private lateinit var sfaParams: SFAParams
lateinit var loginParams: LoginParams
lateinit var algorithmRs: Algorithm
var TEST_VERIFIER = "torus-test-health"
Expand All @@ -32,7 +32,7 @@ class SapphireMainnetTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(
sfaParams = SFAParams(
Web3AuthNetwork.SAPPHIRE_MAINNET,
"CLIENT ID",
null, 0
Expand Down Expand Up @@ -66,7 +66,7 @@ class SapphireMainnetTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldAggregrateGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(
sfaParams = SFAParams(
Web3AuthNetwork.SAPPHIRE_MAINNET,
"CLIENT_ID"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.web3auth.singlefactorauth
import androidx.test.platform.app.InstrumentationRegistry
import com.auth0.jwt.algorithms.Algorithm
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo
import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken
import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader
Expand All @@ -21,7 +21,7 @@ import java.util.concurrent.ExecutionException
class SingleFactorAuthTest {

lateinit var singleFactorAuth: SingleFactorAuth
private lateinit var sfaParams: SingleFactorAuthArgs
private lateinit var sfaParams: SFAParams
lateinit var loginParams: LoginParams
lateinit var algorithmRs: Algorithm
var TEST_VERIFIER = "torus-test-health"
Expand All @@ -32,7 +32,7 @@ class SingleFactorAuthTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(Web3AuthNetwork.MAINNET, "CLIENT_ID", null, 0)
sfaParams = SFAParams(Web3AuthNetwork.MAINNET, "CLIENT_ID", null, 0)
singleFactorAuth = SingleFactorAuth(sfaParams, context)
val privateKey = readPrivateKeyFromReader(
WellKnownSecret.pem(),
Expand Down Expand Up @@ -62,7 +62,7 @@ class SingleFactorAuthTest {
@Throws(ExecutionException::class, InterruptedException::class)
fun shouldAggregrateGetTorusKey() {
val context = InstrumentationRegistry.getInstrumentation().context
sfaParams = SingleFactorAuthArgs(Web3AuthNetwork.MAINNET, "YOUR_CLIENT_ID")
sfaParams = SFAParams(Web3AuthNetwork.MAINNET, "YOUR_CLIENT_ID")
singleFactorAuth = SingleFactorAuth(sfaParams, context)
val privateKey = readPrivateKeyFromReader(
WellKnownSecret.pem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.web3auth.session_manager_android.SessionManager
import com.web3auth.singlefactorauth.types.ErrorCode
import com.web3auth.singlefactorauth.types.LoginParams
import com.web3auth.singlefactorauth.types.SFAError
import com.web3auth.singlefactorauth.types.SingleFactorAuthArgs
import com.web3auth.singlefactorauth.types.SFAParams
import com.web3auth.singlefactorauth.types.TorusSFAKey
import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo
import org.json.JSONObject
Expand All @@ -21,7 +21,7 @@ import org.torusresearch.torusutils.types.common.TorusOptions
import org.torusresearch.torusutils.types.common.TorusPublicKey
import org.web3j.crypto.Hash

class SingleFactorAuth(sfaParams: SingleFactorAuthArgs, ctx: Context) {
class SingleFactorAuth(sfaParams: SFAParams, ctx: Context) {
private var nodeDetailManager: FetchNodeDetails =
FetchNodeDetails(sfaParams.getNetwork())
private val torusUtils: TorusUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ package com.web3auth.singlefactorauth.types

import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

class SingleFactorAuthArgs(network: Web3AuthNetwork, clientid: String, networkUrl: String? = null, serverTimeOffset: Int = 0) {
private var network: Web3AuthNetwork
class SFAParams(
private var network: Web3AuthNetwork,
clientid: String,
networkUrl: String? = null,
serverTimeOffset: Int = 0
) {
private var clientid: String = "torus-default"
private var networkUrl: String? = networkUrl
private var enableOneKey: Boolean
private var serverTimeOffset: Int = serverTimeOffset


init {
this.network = network
this.clientid = clientid
this.enableOneKey = true
this.networkUrl = networkUrl
Expand Down

0 comments on commit f8d8695

Please sign in to comment.