diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-02 23:27:32 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-02 23:27:32 +0100 |
| commit | 2329d0236ea39fd119b1199ae40d2b9f5a316506 (patch) | |
| tree | 74f5df6efca79fe46c96313a0ef7756e9cdad7d1 /format/common/src | |
| parent | 8ae382468d2fea8b42bc9d2e3bd67be9144873ed (diff) | |
| download | HardenedPass-2329d0236ea39fd119b1199ae40d2b9f5a316506.tar.gz HardenedPass-2329d0236ea39fd119b1199ae40d2b9f5a316506.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'format/common/src')
3 files changed, 8 insertions, 3 deletions
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() } } |
