diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt index 23519f9a..94c8e44d 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsJobExecutor.kt @@ -3,6 +3,7 @@ package net.codinux.banking.fints import kotlinx.coroutines.delay import kotlinx.datetime.Instant import kotlinx.datetime.LocalDate +import net.codinux.banking.fints.extensions.* import net.codinux.log.logger import net.codinux.banking.fints.messages.MessageBuilder import net.codinux.banking.fints.messages.MessageBuilderResult @@ -19,9 +20,6 @@ import net.codinux.banking.fints.response.segments.* import net.codinux.banking.fints.tan.FlickerCodeDecoder import net.codinux.banking.fints.tan.TanImageDecoder import net.codinux.banking.fints.util.TanMethodSelector -import net.codinux.banking.fints.extensions.minusDays -import net.codinux.banking.fints.extensions.todayAtEuropeBerlin -import net.codinux.banking.fints.extensions.todayAtSystemDefaultTimeZone import kotlin.math.max import kotlin.time.Duration.Companion.seconds @@ -389,7 +387,14 @@ open class FinTsJobExecutor( while (tanChallenge.isEnteringTanDone == false) { delay(500) - // TODO: add a timeout of e.g. 30 min + // most TANs a valid 5 - 15 minutes. So terminate wait process after that time + if (Instant.nowExt() > tanChallenge.timestamp.plusMinutes(15)) { + if (tanChallenge.isEnteringTanDone == false) { + tanChallenge.userDidNotEnterTan() + } + + break + } } val enteredTanResult = tanChallenge.enterTanResult!! diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/extensions/InstantExtensions.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/extensions/InstantExtensions.kt index a9b7d258..2e6891f7 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/extensions/InstantExtensions.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/extensions/InstantExtensions.kt @@ -1,8 +1,12 @@ package net.codinux.banking.fints.extensions import kotlinx.datetime.Clock +import kotlinx.datetime.DateTimeUnit import kotlinx.datetime.Instant +import kotlinx.datetime.plus // should actually be named `now()`, but that name is already shadowed by deprecated Instant.Companion.now() method -fun Instant.Companion.nowExt(): Instant = Clock.System.now() \ No newline at end of file +fun Instant.Companion.nowExt(): Instant = Clock.System.now() + +fun Instant.plusMinutes(minutes: Int) = this.plus(minutes, DateTimeUnit.MINUTE) \ No newline at end of file