-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Web3Auth/update-isSessionIdExists-method
feat: removed isSessionIdExists method and modified tests.
- Loading branch information
Showing
16 changed files
with
290 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +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.SFAParams | ||
import com.web3auth.singlefactorauth.types.Web3AuthOptions | ||
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: SFAParams | ||
lateinit var loginParams: LoginParams | ||
private lateinit var loginParams: LoginParams | ||
var TEST_VERIFIER = "torus-test-health" | ||
var TORUS_TEST_EMAIL = "[email protected]" | ||
|
||
|
@@ -30,23 +29,22 @@ class MainActivity : AppCompatActivity() { | |
getSFAKey() | ||
} | ||
val idToken = JwtUtils.generateIdToken(TORUS_TEST_EMAIL) | ||
sfaParams = | ||
SFAParams(Web3AuthNetwork.SAPPHIRE_MAINNET, "YOUR_CLIENT_ID", 86400, null, 0) | ||
singleFactorAuth = SingleFactorAuth(sfaParams, this) | ||
val web3AuthOptions = | ||
Web3AuthOptions("YOUR_CLIENT_ID", Web3AuthNetwork.SAPPHIRE_MAINNET, 86400) | ||
singleFactorAuth = SingleFactorAuth(web3AuthOptions, this) | ||
loginParams = LoginParams(TEST_VERIFIER, TORUS_TEST_EMAIL, idToken) | ||
|
||
if (singleFactorAuth.isSessionIdExists()) { | ||
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 (response != null) { | ||
val text = | ||
"Public Address: ${response?.publicAddress} , Private Key: ${response?.privateKey}" | ||
tv.text = text | ||
} else { | ||
tv.text = error.message | ||
} | ||
} | ||
|
||
} | ||
|
||
private fun getSFAKey() { | ||
|
@@ -56,7 +54,7 @@ class MainActivity : AppCompatActivity() { | |
singleFactorAuth.connect(loginParams, this.applicationContext) | ||
if (sfakey != null) { | ||
val text = | ||
"Public Address: ${sfakey.getPublicAddress()} , Private Key: ${sfakey.getPrivateKey()}" | ||
"Public Address: ${sfakey.publicAddress} , Private Key: ${sfakey.privateKey}" | ||
tv.text = text | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.