From 2329d0236ea39fd119b1199ae40d2b9f5a316506 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 2 Nov 2026 23:27:32 +0100 Subject: feat(app): add the entry view model and the OTP period Totp now carries its period, so the entry view can draw how much of the code's lifetime is left. EntryFields groups a decrypted entry the way the spec lays it out. Co-Authored-By: Claude Opus 5.5 --- .../main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt | 2 +- .../src/main/kotlin/app/passwordstore/data/passfile/Totp.kt | 8 ++++++-- .../kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'format/common/src') diff --git a/format/common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt b/format/common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt index f0009dcf..1995342e 100644 --- a/format/common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt +++ b/format/common/src/main/kotlin/app/passwordstore/data/passfile/PasswordEntry.kt @@ -224,7 +224,7 @@ constructor( digits, issuer, ) - .mapBoth({ code -> Ok(Totp(code, remainingTime)) }, ::Err) + .mapBoth({ code -> Ok(Totp(code, remainingTime, totpPeriod.seconds)) }, ::Err) } @AssistedFactory diff --git a/format/common/src/main/kotlin/app/passwordstore/data/passfile/Totp.kt b/format/common/src/main/kotlin/app/passwordstore/data/passfile/Totp.kt index 5e98ecd4..a26f03d9 100644 --- a/format/common/src/main/kotlin/app/passwordstore/data/passfile/Totp.kt +++ b/format/common/src/main/kotlin/app/passwordstore/data/passfile/Totp.kt @@ -7,5 +7,9 @@ package app.passwordstore.data.passfile import kotlin.time.Duration -/** Holder for a TOTP secret and the duration for which it is valid. */ -public data class Totp(public val value: String, public val remainingTime: Duration) +/** A TOTP code, how long it stays valid, and the full period it was generated for. */ +public data class Totp( + public val value: String, + public val remainingTime: Duration, + public val period: Duration, +) diff --git a/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt b/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt index 4efb140b..b7d41fd1 100644 --- a/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt +++ b/format/common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt @@ -134,6 +134,7 @@ class PasswordEntryTest { val otp = expectMostRecentItem() assertEquals("818800", otp.value) assertEquals(30.seconds, otp.remainingTime) + assertEquals(30.seconds, otp.period) cancelAndIgnoreRemainingEvents() } } -- cgit v1.2.3