diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt index 980daa71..f5dde824 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt @@ -54,6 +54,17 @@ open class TanChallenge( get() = availableTanMedia.firstOrNull { it.mediumName == selectedTanMediumName } + /** + * Principally a no-op method, not implemented for all client, only implementing client for not: FinTs4jBankingClient. + * + * If a TAN is requested for a decoupled TAN method like [TanMethodType.DecoupledTan] or [TanMethodType.DecoupledPushTan], + * you can add a callback to get notified when user approved TAN in her app e.g. to close a EnterTanDialog. + */ + open fun addUserApprovedDecoupledTanCallback(callback: () -> Unit) { + + } + + override fun toString(): String { return "$selectedTanMethod $forAction: $messageToShowToUser" + when (type) { TanChallengeType.EnterTan -> "" diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt index 4fda176d..377e890e 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt @@ -17,22 +17,30 @@ enum class TanMethodType { AppTan, + DecoupledTan, + + DecoupledPushTan, + photoTan, QrCode ; + val isDecoupledMethod: Boolean + get() = this == DecoupledTan || this == DecoupledPushTan + + companion object { - val NonVisual = listOf(TanMethodType.AppTan, TanMethodType.SmsTan, TanMethodType.ChipTanManuell, TanMethodType.EnterTan) + val NonVisual = listOf(TanMethodType.DecoupledTan, TanMethodType.DecoupledPushTan, TanMethodType.AppTan, TanMethodType.SmsTan, TanMethodType.ChipTanManuell, TanMethodType.EnterTan) val ImageBased = listOf(TanMethodType.QrCode, TanMethodType.ChipTanQrCode, TanMethodType.photoTan, TanMethodType.ChipTanPhotoTanMatrixCode) val NonVisualOrImageBased = buildList { - addAll(listOf(TanMethodType.AppTan, TanMethodType.SmsTan, TanMethodType.EnterTan)) + addAll(listOf(TanMethodType.DecoupledTan, TanMethodType.DecoupledPushTan, TanMethodType.AppTan, TanMethodType.SmsTan, TanMethodType.EnterTan)) addAll(ImageBased) - addAll(listOf(TanMethodType.ChipTanManuell)) // this is quite inconvenient for user, so i added it at last + addAll(listOf(TanMethodType.ChipTanManuell)) // this is quite inconvenient for user, so i added it as last } } diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt index 8352f3c9..f9c1a2ea 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt @@ -152,7 +152,11 @@ open class FinTs4kMapper { val tanImage = if (challenge is ImageTanChallenge) mapTanImage(challenge.image) else null val flickerCode = if (challenge is FlickerCodeTanChallenge) mapFlickerCode(challenge.flickerCode) else null - return TanChallenge(type, action, challenge.messageToShowToUser, selectedTanMethodId, tanMethods, selectedTanMediumName, tanMedia, tanImage, flickerCode, user, account) + return object : TanChallenge(type, action, challenge.messageToShowToUser, selectedTanMethodId, tanMethods, selectedTanMediumName, tanMedia, tanImage, flickerCode, user, account) { + override fun addUserApprovedDecoupledTanCallback(callback: () -> Unit) { + challenge.addUserApprovedDecoupledTanCallback(callback) + } + } } protected open fun mapTanChallengeType(challenge: net.codinux.banking.fints.model.TanChallenge): TanChallengeType = when {