Skip to content

refactor(api): delete unused device attestation and Play Integrity - #1001

Closed
mikepitre wants to merge 4 commits into
mainfrom
mike/silly-poitras-ca23da
Closed

mikepitre wants to merge 4 commits into
mainfrom
mike/silly-poitras-ca23da

Conversation

@mikepitre

@mikepitre mikepitre commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Nothing in the SDK has called device attestation since #571 removed the startup flow and DeviceAssertionMiddleware. The helper, its API, and the Play Integrity dependency stayed behind. DeviceAttestationApi.getChallenge() is also a non-suspend void method that Retrofit rejects, so #997 had to exclude it from ServiceInterfaceValidationTest. This PR deletes the dead code and the exclusion.

Scope

  • Delete DeviceAttestationHelper, DeviceAttestationHelperTest, and DeviceAttestationApi.
  • Remove ClerkApi.deviceAttestation, the DeviceAttestationHelper.clearCache() call in Clerk.reset(), and ApiPaths.Client.DeviceAttestation.
  • Remove the google-playIntegrity catalog entry and implementation(libs.google.playIntegrity).
  • Remove the three detekt baseline entries for DeviceAttestationHelper and DeviceAssertionMiddleware.
  • Remove the DeviceAttestationApi exclusion from ServiceInterfaceValidationTest.
  • Deprecate Constants.Attestation instead of deleting it. Nothing reads it, but it is part of the public Constants object, and deleting it would break any app that references it. Delete it in the next major version.
  • Reformat Clerk.kt in a separate commit. Spotless checks only files that differ from origin/main, and the Clerk.kt on main no longer matches the pinned ktfmt output. That commit changes formatting only.

Blast Radius

Apps that use the SDK no longer get com.google.android.play:integrity or its dependency com.google.android.play:core-common at runtime. The SDK declared Play Integrity as implementation, so apps never compiled against it through the SDK. An app breaks only if it loads Play Integrity classes at runtime without declaring the dependency itself.

Two open PRs touch the same code. #985 edits DeviceAttestationHelperTest.kt, which this PR deletes. Resolve that conflict by deleting the file. #910 adds ClerkProtect.reset() next to the removed clearCache() call. Resolve that conflict by keeping ClerkProtect.reset().

Verification

  • ./gradlew :source:api:testDebugUnitTest :source:api:spotlessCheck :source:api:detekt on JDK 21 passes with 752 tests and 0 failures. ServiceInterfaceValidationTest now passes with no exclusion.
  • A repo-wide search for DeviceAttestation, playIntegrity, DeviceAssertion, and Constants.Attestation finds no matches.
  • :source:api:dependencies --configuration releaseRuntimeClasspath before and after this change differ by only com.google.android.play:integrity and com.google.android.play:core-common.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Changes
    • Removed device attestation support, including Play Integrity token preparation and verification.
    • Deprecated the attestation constants; they remain available but are no longer used by the SDK.

mikepitre and others added 3 commits October 1, 2026 10:21
…call

UserApi.deletePassword had a bare @post, so Retrofit threw "Missing
either @post URL or @url parameter." the first time User.deletePassword()
ran. Point it at ApiPaths.User.Password.DELETE (POST me/remove_password).

SessionApi.revokeSession declared its @query before its @path, which
Retrofit rejects, so Session.revoke() threw too. Put the @path first.

The per-API tests mock these interfaces, so Retrofit never parsed them.
ServiceInterfaceValidationTest builds every service ClerkApi creates
with validateEagerly(true). DeviceAttestationApi is excluded: its
getChallenge() returns void and nothing has called it since #571.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spotless ratchets from origin/main, so it checks Clerk.kt only when a
change touches it. The next commit touches it, and main's copy no longer
matches the pinned ktfmt output. This commit changes formatting only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing has called DeviceAttestationHelper since #571 removed the
startup flow and DeviceAssertionMiddleware. Delete the helper, its
test, DeviceAttestationApi, the ClerkApi wiring, the reset hook, the
API path, and the Play Integrity dependency.

Deprecate the public Constants.Attestation object instead of removing
it, so this change does not break consumers who reference it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository: clerk/clerk-android/.coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 771687a8-4a5b-4399-89ac-bd39da55e317

📥 Commits

Reviewing files that changed from the base of the PR and between 15dc8a1 and 7fff699.

📒 Files selected for processing (11)
  • config/detekt/detekt-baseline.xml
  • gradle/libs.versions.toml
  • source/api/build.gradle.kts
  • source/api/src/main/kotlin/com/clerk/api/Clerk.kt
  • source/api/src/main/kotlin/com/clerk/api/Constants.kt
  • source/api/src/main/kotlin/com/clerk/api/attestation/DeviceAttestationHelper.kt
  • source/api/src/main/kotlin/com/clerk/api/network/ApiPaths.kt
  • source/api/src/main/kotlin/com/clerk/api/network/ClerkApi.kt
  • source/api/src/main/kotlin/com/clerk/api/network/api/DeviceAttestationApi.kt
  • source/api/src/test/java/com/clerk/api/attestation/DeviceAttestationHelperTest.kt
  • source/api/src/test/java/com/clerk/api/network/api/ServiceInterfaceValidationTest.kt
 _______________________________________________________________________________
< Fancy algorithms are slow when n is small, and n is usually small. - Rob Pike >
 -------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

swolfand
swolfand previously approved these changes Oct 1, 2026

@swolfand swolfand left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deletion is complete, and deprecating Constants.Attestation instead of deleting it keeps the API compatible. Two things to watch, neither blocking: (1) The base isn't main, so CI ran only detekt and semgrep here. Retarget to main after #997 merges and let the unit tests run. (2) config/bin/ktfmt bundles ktfmt 0.54 while spotless uses 0.64, so the pre-commit hook will undo the Clerk.kt reformat. Bumping the hook binary is worth a follow-up.

@swolfand
swolfand dismissed their stale review October 1, 2026 19:36

Withdrawing until this is retargeted to main and the unit-test jobs pass; CI has only run detekt/semgrep on this branch.

Base automatically changed from mike/fix-retrofit-service-methods to main October 1, 2026 19:41
…23da

# Conflicts:
#	source/api/src/main/kotlin/com/clerk/api/network/api/SessionApi.kt
#	source/api/src/test/java/com/clerk/api/network/api/ServiceInterfaceValidationTest.kt
@mikepitre mikepitre closed this Oct 1, 2026
@mikepitre
mikepitre deleted the mike/silly-poitras-ca23da branch October 1, 2026 19:48
swolfand added a commit that referenced this pull request Oct 5, 2026
Nothing has called DeviceAttestationHelper since #571 removed the
startup flow and DeviceAssertionMiddleware. Delete the helper, its
test, DeviceAttestationApi, the ClerkApi wiring, the reset hook, the
API path, and the Play Integrity dependency. Drop the
ServiceInterfaceValidationTest exclusion and the detekt baseline
entries that only existed for the deleted code.

Deprecate the public Constants.Attestation object instead of removing
it, so this change does not break consumers who reference it.

Reuses the approach from #1001, which was closed without being merged.
swolfand added a commit that referenced this pull request Oct 6, 2026
Nothing has called DeviceAttestationHelper since #571 removed the
startup flow and DeviceAssertionMiddleware. Delete the helper, its
test, DeviceAttestationApi, the ClerkApi wiring, the reset hook, the
API path, and the Play Integrity dependency. Drop the
ServiceInterfaceValidationTest exclusion and the detekt baseline
entries that only existed for the deleted code.

Deprecate the public Constants.Attestation object instead of removing
it, so this change does not break consumers who reference it.

Reuses the approach from #1001, which was closed without being merged.
swolfand added a commit that referenced this pull request Oct 6, 2026
Nothing has called DeviceAttestationHelper since #571 removed the
startup flow and DeviceAssertionMiddleware. Delete the helper, its
test, DeviceAttestationApi, the ClerkApi wiring, the reset hook, the
API path, and the Play Integrity dependency. Drop the
ServiceInterfaceValidationTest exclusion and the detekt baseline
entries that only existed for the deleted code.

Deprecate the public Constants.Attestation object instead of removing
it, so this change does not break consumers who reference it.

Reuses the approach from #1001, which was closed without being merged.
swolfand added a commit that referenced this pull request Oct 6, 2026
…and dependencies (#1016)

* refactor(api): delete unused device attestation

Nothing has called DeviceAttestationHelper since #571 removed the
startup flow and DeviceAssertionMiddleware. Delete the helper, its
test, DeviceAttestationApi, the ClerkApi wiring, the reset hook, the
API path, and the Play Integrity dependency. Drop the
ServiceInterfaceValidationTest exclusion and the detekt baseline
entries that only existed for the deleted code.

Deprecate the public Constants.Attestation object instead of removing
it, so this change does not break consumers who reference it.

Reuses the approach from #1001, which was closed without being merged.

* refactor(api): delete reflection helpers that only build unread annotations

ClerkApiResultConverterFactory built a ResultType annotation for the
error type, and ClerkApiResultCallAdapterFactory built a StatusCode
annotation for each failed response. Both were appended to the
annotations handed to the next converter, which is the kotlinx
serialization converter, and it never reads them. Nothing else did
either.

Delete the two annotations and the Types, ParameterizedTypeImpl,
WildcardTypeImpl, and GenericArrayTypeImpl helpers that existed only to
build them, and pass the caller's annotations through unchanged. Pin
that pass-through with a converter factory test.

* build(api): drop unused kotlinx-datetime and lifecycle-viewmodel dependencies

Nothing in :source:api imports kotlinx.datetime or the ViewModel APIs
from lifecycle-viewmodel-ktx, and both were implementation
dependencies, so no public signature exposes their types. They still
reached every app's runtime classpath. Remove them, and the now-unused
kotlinx-datetime catalog entry. The lifecycle-viewmodel catalog entry
stays because the samples and e2e app use it directly; :source:ui gets
the ViewModel APIs from lifecycle-viewmodel-compose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants