mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-22 17:51:29 +03:00
Merge PR #1498
This commit is contained in:
commit
941a4faed2
@ -175,7 +175,7 @@ class FidoManager(
|
||||
deviceManager.removeDeviceListener(this)
|
||||
fidoChannel.setMethodCallHandler(null)
|
||||
fidoViewModel.clearSessionState()
|
||||
fidoViewModel.updateCredentials(emptyList())
|
||||
fidoViewModel.updateCredentials(null)
|
||||
coroutineScope.cancel()
|
||||
}
|
||||
|
||||
@ -261,19 +261,11 @@ class FidoManager(
|
||||
val pinPermissionsBE = getPinPermissionsBE(fidoSession)
|
||||
val permissions = pinPermissionsCM or pinPermissionsBE
|
||||
|
||||
if (permissions != 0) {
|
||||
val token = clientPin.getPinToken(pin, permissions, null)
|
||||
val credentials = getCredentials(fidoSession, clientPin, token)
|
||||
logger.debug("Creds: {}", credentials)
|
||||
fidoViewModel.updateCredentials(credentials)
|
||||
|
||||
if (pinPermissionsBE != 0) {
|
||||
val fingerprints = getFingerprints(fidoSession, clientPin, token)
|
||||
logger.debug("Fingerprints: {}", fingerprints)
|
||||
fidoViewModel.updateFingerprints(fingerprints)
|
||||
}
|
||||
val token = if (permissions != 0) {
|
||||
clientPin.getPinToken(pin, permissions, null)
|
||||
} else {
|
||||
clientPin.getPinToken(pin, permissions, "yubico-authenticator.example.com")
|
||||
null
|
||||
}
|
||||
|
||||
pinStore.setPin(pin)
|
||||
@ -287,6 +279,19 @@ class FidoManager(
|
||||
pinRetries
|
||||
)
|
||||
)
|
||||
|
||||
token?.let {
|
||||
val credentials = getCredentials(fidoSession, clientPin, token)
|
||||
logger.debug("Creds: {}", credentials)
|
||||
fidoViewModel.updateCredentials(credentials)
|
||||
|
||||
if (pinPermissionsBE != 0) {
|
||||
val fingerprints = getFingerprints(fidoSession, clientPin, token)
|
||||
logger.debug("Fingerprints: {}", fingerprints)
|
||||
fidoViewModel.updateFingerprints(fingerprints)
|
||||
}
|
||||
}
|
||||
|
||||
return JSONObject(mapOf("success" to true)).toString()
|
||||
}
|
||||
|
||||
@ -304,7 +309,7 @@ class FidoManager(
|
||||
ctapException.ctapError == CtapException.ERR_PIN_POLICY_VIOLATION
|
||||
) {
|
||||
pinStore.setPin(null)
|
||||
fidoViewModel.updateCredentials(emptyList())
|
||||
fidoViewModel.updateCredentials(null)
|
||||
pinRetries = clientPin.pinRetries.count
|
||||
|
||||
fidoViewModel.setSessionState(
|
||||
@ -397,6 +402,7 @@ class FidoManager(
|
||||
pinUvAuthToken: ByteArray
|
||||
): List<FidoCredential> =
|
||||
try {
|
||||
fidoViewModel.updateCredentials(null)
|
||||
val credMan = CredentialManagement(fidoSession, clientPin.pinUvAuth, pinUvAuthToken)
|
||||
val rpIds = credMan.enumerateRps()
|
||||
|
||||
|
@ -38,10 +38,10 @@ class FidoViewModel : ViewModel() {
|
||||
_sessionState.postValue(ViewModelData.Empty)
|
||||
}
|
||||
|
||||
private val _credentials = MutableLiveData<List<FidoCredential>>()
|
||||
val credentials: LiveData<List<FidoCredential>> = _credentials
|
||||
private val _credentials = MutableLiveData<List<FidoCredential>?>()
|
||||
val credentials: LiveData<List<FidoCredential>?> = _credentials
|
||||
|
||||
fun updateCredentials(credentials: List<FidoCredential>) {
|
||||
fun updateCredentials(credentials: List<FidoCredential>?) {
|
||||
_credentials.postValue(credentials)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user