feat: add DateProvider to Lokksmith options#287
Merged
svenjacobs merged 4 commits intomainfrom Feb 24, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configurable, potentially network-synchronized time source to Lokksmith via a new DateProvider, and wires it through token validation and expiration logic to avoid relying solely on device time.
Changes:
- Introduces
DateProvider/DateProviders.Defaultand addsdateProvidertoLokksmith.Options, plumbing it intoClientImpl.DefaultProvider. - Updates token expiry/temporal validation to use
dateProvider().epochSeconds, and adjusts APIs tosuspendwhere needed. - Updates common tests to provide
kotlin.time.Instant-based time sources.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/lokksmith-core/src/commonTest/kotlin/dev/lokksmith/client/request/token/AbstractTokenResponseValidatorTest.kt | Updates helper to suspend to match validator API changes. |
| lib/lokksmith-core/src/commonTest/kotlin/dev/lokksmith/client/ClientTest.kt | Migrates tests to inject dateProvider returning Instant. |
| lib/lokksmith-core/src/commonTest/kotlin/dev/lokksmith/LokksmithTest.kt | Updates test container provider to supply dateProvider. |
| lib/lokksmith-core/src/commonMain/kotlin/dev/lokksmith/client/request/token/TokenResponseValidator.kt | Switches validation + expiry computations to use dateProvider and makes validate suspend. |
| lib/lokksmith-core/src/commonMain/kotlin/dev/lokksmith/client/TokensExtensions.kt | Refactors expiry helpers to accept currentSeconds rather than a provider callback. |
| lib/lokksmith-core/src/commonMain/kotlin/dev/lokksmith/client/Client.kt | Adds dateProvider to InternalClient.Provider, makes Client.isExpired suspend, and uses dateProvider in expiry checks. |
| lib/lokksmith-core/src/commonMain/kotlin/dev/lokksmith/Lokksmith.kt | Adds and documents Lokksmith.Options.dateProvider. |
| lib/lokksmith-core/src/commonMain/kotlin/dev/lokksmith/DateProvider.kt | Introduces public DateProvider and DateProviders.Default. |
| lib/lokksmith-core/src/commonMain/kotlin/dev/lokksmith/Container.kt | Forwards options.dateProvider into the created client provider. |
| lib/lokksmith-core/api/lokksmith-core.klib.api | ABI surface update reflecting new option and new suspend signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...mith-core/src/commonMain/kotlin/dev/lokksmith/client/request/token/TokenResponseValidator.kt
Show resolved
Hide resolved
...mith-core/src/commonMain/kotlin/dev/lokksmith/client/request/token/TokenResponseValidator.kt
Show resolved
Hide resolved
...mith-core/src/commonMain/kotlin/dev/lokksmith/client/request/token/TokenResponseValidator.kt
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
DateProviderto Lokksmith'sOptionswhich allows to provide a more reliable or network-synchronized time source like TrustedTime API on Android, if available.