diff --git a/app/src/main/java/com/web3auth/sfaexample/MainActivity.kt b/app/src/main/java/com/web3auth/sfaexample/MainActivity.kt index d22823f..361339e 100644 --- a/app/src/main/java/com/web3auth/sfaexample/MainActivity.kt +++ b/app/src/main/java/com/web3auth/sfaexample/MainActivity.kt @@ -35,23 +35,17 @@ class MainActivity : AppCompatActivity() { singleFactorAuth = SingleFactorAuth(sfaParams, this) loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken) - val res = singleFactorAuth.isSessionIdExists(this) - res.whenComplete { res, err -> - if (res) { - val sfakey = singleFactorAuth.initialize(this.applicationContext) - sfakey.whenComplete { response, error -> - if (error == null) { - val text = - "Public Address: ${response.getPublicAddress()} , Private Key: ${response.getPrivateKey()}" - tv.text = text - } else { - tv.text = error.message - } - } + val sfakey = singleFactorAuth.initialize(this.applicationContext) + sfakey.whenComplete { response, error -> + if (error == null) { + val text = + "Public Address: ${response.getPublicAddress()} , Private Key: ${response.getPrivateKey()}" + tv.text = text } else { - tv.text = err.message + tv.text = error.message } } + } private fun getSFAKey() { diff --git a/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/AquaTest.kt b/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/AquaTest.kt index 8ad2a5a..791cd5c 100644 --- a/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/AquaTest.kt +++ b/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/AquaTest.kt @@ -9,7 +9,6 @@ import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader import com.web3auth.singlefactorauth.utils.WellKnownSecret -import junit.framework.TestCase.assertEquals import junit.framework.TestCase.fail import org.junit.Test import org.junit.runner.RunWith @@ -100,39 +99,4 @@ class AquaTest { fail() } } - - @Test - @Throws(ExecutionException::class, InterruptedException::class) - fun testisSessionIdExistsWithLogoutApiCalled() { - val context = getInstrumentation().context - sfaParams = SFAParams(Web3AuthNetwork.AQUA, "YOUR_CLIENT_ID", 86400, null, 0) - singleFactorAuth = SingleFactorAuth(sfaParams, context) - val privateKey = readPrivateKeyFromReader( - WellKnownSecret.pem(), - "EC" - ) as ECPrivateKey - val publicKey = KeyFactory.getInstance("EC").generatePublic( - ECPublicKeySpec( - privateKey.params.generator, - privateKey.params - ) - ) as ECPublicKey - algorithmRs = Algorithm.ECDSA256(publicKey, privateKey) - val idToken: String = generateIdToken(TORUS_TEST_EMAIL, algorithmRs) - loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken) - singleFactorAuth.connect(loginParams, context) - val logoutCF = singleFactorAuth.logout(context).get() - if (logoutCF == true) { - val res = singleFactorAuth.isSessionIdExists(context) - res.whenComplete { res, err -> - if (err != null) { - fail() - } else { - assertEquals(res, false) - } - } - } else { - fail() - } - } } \ No newline at end of file diff --git a/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/SapphireMainnetTest.kt b/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/SapphireMainnetTest.kt index 0c338e8..355b62e 100644 --- a/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/SapphireMainnetTest.kt +++ b/singlefactorauth/src/androidTest/java/com/web3auth/singlefactorauth/SapphireMainnetTest.kt @@ -8,7 +8,6 @@ import com.web3auth.singlefactorauth.types.TorusSubVerifierInfo import com.web3auth.singlefactorauth.utils.JwtUtils.generateIdToken import com.web3auth.singlefactorauth.utils.PemUtils.readPrivateKeyFromReader import com.web3auth.singlefactorauth.utils.WellKnownSecret -import junit.framework.TestCase import junit.framework.TestCase.fail import org.junit.Test import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork @@ -105,69 +104,4 @@ class SapphireMainnetTest { fail() } } - - @Test - @Throws(ExecutionException::class, InterruptedException::class) - fun testisSessionIdExistsWithLogoutApiCalled() { - val context = InstrumentationRegistry.getInstrumentation().context - sfaParams = SFAParams(Web3AuthNetwork.SAPPHIRE_MAINNET, "YOUR_CLIENT_ID", 86400, null, 0) - singleFactorAuth = SingleFactorAuth(sfaParams, context) - val privateKey = readPrivateKeyFromReader( - WellKnownSecret.pem(), - "EC" - ) as ECPrivateKey - val publicKey = KeyFactory.getInstance("EC").generatePublic( - ECPublicKeySpec( - privateKey.params.generator, - privateKey.params - ) - ) as ECPublicKey - algorithmRs = Algorithm.ECDSA256(publicKey, privateKey) - val idToken: String = generateIdToken(TORUS_TEST_EMAIL, algorithmRs) - loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken) - singleFactorAuth.connect(loginParams, context) - val logoutCF = singleFactorAuth.logout(context).get() - if (logoutCF == true) { - val res = singleFactorAuth.isSessionIdExists(context) - res.whenComplete { res, err -> - if (err != null) { - fail() - } else { - TestCase.assertEquals(res, false) - } - } - } else { - fail() - } - } - - @Test - @Throws(ExecutionException::class, InterruptedException::class) - fun testisSessionIdExistsWithLogoutApiNotCalled() { - val context = InstrumentationRegistry.getInstrumentation().context - sfaParams = SFAParams(Web3AuthNetwork.SAPPHIRE_MAINNET, "YOUR_CLIENT_ID", 86400, null, 0) - singleFactorAuth = SingleFactorAuth(sfaParams, context) - val privateKey = readPrivateKeyFromReader( - WellKnownSecret.pem(), - "EC" - ) as ECPrivateKey - val publicKey = KeyFactory.getInstance("EC").generatePublic( - ECPublicKeySpec( - privateKey.params.generator, - privateKey.params - ) - ) as ECPublicKey - algorithmRs = Algorithm.ECDSA256(publicKey, privateKey) - val idToken: String = generateIdToken(TORUS_TEST_EMAIL, algorithmRs) - loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken) - singleFactorAuth.connect(loginParams, context) - val res = singleFactorAuth.isSessionIdExists(context) - res.whenComplete { res, err -> - if (err != null) { - fail() - } else { - TestCase.assertEquals(res, true) - } - } - } } \ No newline at end of file diff --git a/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt b/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt index b351563..cd54f6d 100644 --- a/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt +++ b/singlefactorauth/src/main/java/com/web3auth/singlefactorauth/SingleFactorAuth.kt @@ -70,19 +70,6 @@ class SingleFactorAuth( return nodeDetails.torusNodeEndpoints } - fun isSessionIdExists(ctx: Context): CompletableFuture { - val authorizeCF = CompletableFuture() - val data = sessionManager.authorizeSession(ctx.packageName, ctx) - data.whenComplete { res, error -> - if (res.startsWith("Error")) { - authorizeCF.complete(false) - } else { - authorizeCF.complete(true) - } - } - return authorizeCF - } - fun getTorusKey( loginParams: LoginParams ): TorusKey? {