-
Notifications
You must be signed in to change notification settings - Fork 377
feat(jwt): public API — IUserJwtInvalidatedListener, updateUserJwt, login JWT (5/6) #2633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nan-li
merged 8 commits into
feat/identity_verification_feature_flagged_major_release
from
feat/iv-public-api-05
May 7, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6b90ff2
feat(iv): public API — IUserJwtInvalidatedListener, updateUserJwt, lo…
nan-li 596d0b3
refactor(iv): align jwt-invalidated replay with #2613 buffer-and-consume
nan-li 1e8d3f2
fix(iv): gate jwt-invalidated listener add/remove on init
nan-li cbb01af
fix(iv): wake queue on login(sameId, freshJwt) refresh path
nan-li ee27ce4
fix(iv): expose new public methods on OneSignal facade + log hygiene
nan-li 71ed3a2
refactor(iv): drop jwt-invalidated buffer/replay; pure pub/sub matche…
nan-li aeb0d65
refactor(iv): move IUserJwtInvalidatedListener notifier into JwtToken…
nan-li a463522
nit: don't force executions if token no change
nan-li File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
26 changes: 26 additions & 0 deletions
26
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/IUserJwtInvalidatedListener.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.onesignal | ||
|
|
||
| /** | ||
| * Implement this interface and provide an instance to | ||
| * [IOneSignal.addUserJwtInvalidatedListener] to be notified when the SDK has | ||
| * detected that the JWT for a user is no longer valid (typically a 401 from | ||
| * the OneSignal backend on a request signed with that JWT). | ||
| * | ||
| * Threading: delivered on a background dispatcher | ||
| * (`OneSignalDispatchers.launchOnDefault`). Implementations should not assume a | ||
| * specific thread and should re-dispatch to the UI thread if needed. | ||
| * | ||
| * Pure pub/sub: only listeners subscribed at the time of the invalidation | ||
| * receive the event. Subscribe early (e.g. in `Application.onCreate`) to avoid | ||
| * missing cold-start 401s. | ||
| */ | ||
| fun interface IUserJwtInvalidatedListener { | ||
| /** | ||
| * Called when the JWT is invalidated for [UserJwtInvalidatedEvent.externalId]. | ||
| * Apps should use this signal to fetch a fresh JWT from their backend and | ||
| * supply it via [IOneSignal.updateUserJwt]. | ||
| * | ||
| * @param event Describes which user's JWT was invalidated. | ||
| */ | ||
| fun onUserJwtInvalidated(event: UserJwtInvalidatedEvent) | ||
| } |
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
9 changes: 9 additions & 0 deletions
9
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/UserJwtInvalidatedEvent.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.onesignal | ||
|
|
||
| /** | ||
| * The event passed into [IUserJwtInvalidatedListener.onUserJwtInvalidated]. | ||
| * Delivery occurs on a background thread. | ||
| */ | ||
| class UserJwtInvalidatedEvent( | ||
| val externalId: String, | ||
| ) |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Two detekt baseline entries added/amended in this PR are now stale: line 158 suppresses
ConstructorParameterNamingfor_jwtTokenStore: JwtTokenStore, but UserManager.kt:26-32 has no such constructor parameter, and line 416 keysTooManyFunctionsonUserManager : IUserManagerISingletonModelStoreChangeHandlerIJwtUpdateListener, but UserManager.kt:32 declares only: IUserManager, ISingletonModelStoreChangeHandler<IdentityModel>—IJwtUpdateListeneris not implemented. Both entries suppress non-existent warnings (created by an earlier version of this PR that was reverted by refactor commits 46d525f / 2a7edec which moved listener machinery into JwtTokenStore) and will silently mask any future legitimate detekt findings against UserManager. Fix: remove both lines, or regenerate the baseline.Extended reasoning...
What the bug is
Two entries in
OneSignalSDK/detekt/detekt-baseline-core.xmlwere added or amended by this PR but referenceUserManagerstate that does not exist in the current code:+ <ID>ConstructorParameterNaming:UserManager.kt$UserManager$private val _jwtTokenStore: JwtTokenStore</ID>) suppresses aConstructorParameterNamingfinding for a_jwtTokenStore: JwtTokenStoreconstructor parameter onUserManager.-IUserManagerISingletonModelStoreChangeHandler→+IUserManagerISingletonModelStoreChangeHandlerIJwtUpdateListener) suppresses aTooManyFunctionsfinding keyed onUserManagerimplementingIJwtUpdateListener.Step-by-step proof
UserManager.kt:26-32. The constructor signature is:_jwtTokenStore: JwtTokenStoreparameter, and the implemented-interface list is exactlyIUserManager, ISingletonModelStoreChangeHandler<IdentityModel>—IJwtUpdateListeneris absent.grepforJwtTokenStoreinUserManager.ktreturns no matches.ConstructorParameterNamingandTooManyFunctionsinclude the constructor parameter list and the implemented-interface signature respectively. The keys at lines 158 and 416 do not match the class as it now exists, so the suppressions never apply.Why this happened
This PR family went through several refactors. Earlier iterations injected
JwtTokenStoreintoUserManagerand madeUserManagerimplementIJwtUpdateListenerto bridge invalidation events to aUserManager-ownedEventProducer<IUserJwtInvalidatedListener>. Subsequent commits — notably 46d525f ("refactor(iv): drop jwt-invalidated buffer/replay; pure pub/sub matches iOS") and 2a7edec ("refactor(iv): move IUserJwtInvalidatedListener notifier into JwtTokenStore") — moved the listener machinery directly intoJwtTokenStoreand removed both the constructor parameter and the interface implementation. The detekt baseline was not regenerated, so the suppressions added for the earlier shape remain.Impact
No runtime impact — these are pure baseline-suppression entries. The cosmetic harm is real, though: stale entries silently mask any future legitimate detekt findings against
UserManager's constructor naming or implemented-interface count. A future engineer adding a JWT-related parameter would see the warning suppressed without realizing why; a future refactor that legitimately bumpsUserManager's function count past the threshold would have itsTooManyFunctionswarning auto-suppressed by a key that only happens to match an unrelated past shape. Detekt baselines exist to lock in known findings; stale entries undermine that contract.Fix
Mechanical: delete the two stale lines from
detekt-baseline-core.xml(line 158 and theIJwtUpdateListenerportion of line 416, restoring it toUserManager : IUserManagerISingletonModelStoreChangeHandlerif that finding still applies, or remove the line entirely if it does not). Alternatively, regenerate the baseline with./gradlew detektBaselineand let detekt emit only the entries that match the current code.