Skip to content

Support platform attestation in the SDK and sample#8

Open
Malith-19 wants to merge 1 commit into
thunder-id:mainfrom
Malith-19:feat/4230-flutter-attestation
Open

Support platform attestation in the SDK and sample#8
Malith-19 wants to merge 1 commit into
thunder-id:mainfrom
Malith-19:feat/4230-flutter-attestation

Conversation

@Malith-19

@Malith-19 Malith-19 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Purpose

Add platform attestation support to the Flutter SDK and sample, following the native iOS and Android work (thunder-id/thunderid#4126).

Approach

The Flutter SDK is a thin wrapper over the native SDKs, so the attestation token is minted natively and driven by config flags from Dart:

  • ThunderIDConfig gains attestationEnabled and cloudProjectNumber, passed to native via toMap().
  • When enabled, the iOS bridge mints an Apple App Attest token and the Android bridge mints a Google Play Integrity token; the native SDK sends it as the Attestation-Token header on native flow-initiate requests.
  • Bumped native dependencies to the released versions (iOS ThunderID 0.2, Android android-sdks v0.2.0) and added the Play Integrity dependency.
  • Wired the sample via THUNDERID_ATTESTATION_ENABLED / THUNDERID_CLOUD_PROJECT_NUMBER and documented the setup.

End-to-end attestation still depends on the server issuing the challenge and verifying the token — tracked separately.

Related Issues

Related PRs

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified. (pending on-device + server verification)
  • Documentation provided. (sample README)
  • Tests provided.
    • Unit Tests
    • Integration Tests
  • Breaking changes.

Security checks

  • Followed secure coding standards in WSO2 Secure Coding Guidelines
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

Summary by CodeRabbit

  • New Features
    • Added optional platform attestation support for Android and iOS sign-in and sign-up flows.
    • Added configuration for enabling attestation and supplying an Android Cloud project number.
    • Added native token generation using Google Play Integrity on Android and App Attest on iOS.
  • Documentation
    • Updated the quickstart sample with attestation configuration, setup requirements, and testing guidance.
  • Tests
    • Added coverage for default and enabled attestation configuration serialization.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Malith-19, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 768bcb99-d926-4860-9620-114c1620ed77

📥 Commits

Reviewing files that changed from the base of the PR and between e419cee and 3ee54d8.

📒 Files selected for processing (11)
  • android/build.gradle
  • android/src/main/kotlin/dev/thunderid/flutter/PlayIntegrityTokenProvider.kt
  • android/src/main/kotlin/dev/thunderid/flutter/ThunderIDMethodHandler.kt
  • ios/Classes/AppAttestTokenProvider.swift
  • ios/Classes/ThunderIDMethodHandler.swift
  • ios/thunderid_flutter.podspec
  • lib/src/models/thunderid_config.dart
  • samples/quickstart/.env.example
  • samples/quickstart/README.md
  • samples/quickstart/lib/main.dart
  • test/thunderid_client_test.dart
📝 Walkthrough

Walkthrough

Adds optional platform attestation configuration to the Flutter SDK, with Android Play Integrity and iOS App Attest token providers, native wiring, updated dependencies, quickstart configuration, documentation, and serialization tests.

Changes

Platform attestation

Layer / File(s) Summary
Dart attestation contract
lib/src/models/thunderid_config.dart, test/thunderid_client_test.dart
ThunderIDConfig adds attestationEnabled and optional cloudProjectNumber, serializes them, and tests default and enabled mappings.
Android Play Integrity flow
android/build.gradle, android/src/main/kotlin/dev/thunderid/flutter/*
Adds the Play Integrity dependency, implements cached token generation, bridges Play Tasks to coroutines, and wires the provider into native configuration.
iOS App Attest flow
ios/Classes/*, ios/thunderid_flutter.podspec
Adds App Attest envelope generation with persisted keys and attestation state, wires it into native configuration, and updates the ThunderID pod constraint.
Quickstart configuration
samples/quickstart/.env.example, samples/quickstart/lib/main.dart, samples/quickstart/README.md
Adds environment-variable parsing and documents Android, iOS, and server requirements for attestation testing.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: brionmario

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding platform attestation support to the SDK and sample.
Description check ✅ Passed The description follows the required template and includes purpose, approach, related items, checklist, and security checks.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
android/src/main/kotlin/dev/thunderid/flutter/ThunderIDMethodHandler.kt (1)

150-162: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reject enabled Android attestation without a project number.

A missing value becomes 0L and still initializes PlayIntegrityTokenProvider; token minting then fails only during a flow. Throw IAMException(ThunderIDErrorCode.INVALID_CONFIGURATION, ...) when attestation is enabled and the number is null/non-positive.

Proposed fix
 val attestationEnabled = args["attestationEnabled"] as? Boolean ?: false
-val cloudProjectNumber = (args["cloudProjectNumber"] as? Number)?.toLong() ?: 0L
+val cloudProjectNumber = (args["cloudProjectNumber"] as? Number)?.toLong()
+if (attestationEnabled && (cloudProjectNumber == null || cloudProjectNumber <= 0)) {
+    throw IAMException(
+        ThunderIDErrorCode.INVALID_CONFIGURATION,
+        "cloudProjectNumber is required when Android attestation is enabled",
+    )
+}
 ...
-    PlayIntegrityTokenProvider(context, cloudProjectNumber)::requestToken
+    PlayIntegrityTokenProvider(context, cloudProjectNumber!!)::requestToken
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@android/src/main/kotlin/dev/thunderid/flutter/ThunderIDMethodHandler.kt`
around lines 150 - 162, Update the ThunderIDConfig construction in the method
handling attestation configuration to preserve the raw cloudProjectNumber value,
validate it before creating PlayIntegrityTokenProvider, and throw IAMException
with ThunderIDErrorCode.INVALID_CONFIGURATION when attestationEnabled is true
and the number is missing or non-positive. Continue using the validated positive
project number for token provider initialization.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ios/Classes/AppAttestTokenProvider.swift`:
- Around line 23-31: Update AppAttestTokenProvider’s failure handling so
AppAttestError.unsupported is converted to the SDK’s typed error contract using
ThunderIDErrorCode and IAMException before crossing the platform channel.
Preserve the unsupported-device distinction and ensure other provider failures
continue mapping to their appropriate typed operational errors rather than
UNKNOWN_ERROR.
- Around line 49-56: The attestation tokens are not bound to the individual
server request, and iOS marks keys attested before backend acceptance. In
ios/Classes/AppAttestTokenProvider.swift lines 49-56, update requestToken to
accept and use the server-issued challenge instead of calling makeChallenge; in
ios/Classes/AppAttestTokenProvider.swift lines 84-87, defer marking the key
attested until the backend confirms the attestation; in
android/src/main/kotlin/dev/thunderid/flutter/PlayIntegrityTokenProvider.kt
lines 41-43, set requestHash on StandardIntegrityTokenRequest using the
request-specific flow data.

In `@ios/thunderid_flutter.podspec`:
- Line 15: Update the ThunderID dependency declaration in the podspec from the
broad ~> 0.2 constraint to ~> 0.2.0, keeping iOS installs aligned with the
Android v0.2.0 dependency.

---

Outside diff comments:
In `@android/src/main/kotlin/dev/thunderid/flutter/ThunderIDMethodHandler.kt`:
- Around line 150-162: Update the ThunderIDConfig construction in the method
handling attestation configuration to preserve the raw cloudProjectNumber value,
validate it before creating PlayIntegrityTokenProvider, and throw IAMException
with ThunderIDErrorCode.INVALID_CONFIGURATION when attestationEnabled is true
and the number is missing or non-positive. Continue using the validated positive
project number for token provider initialization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fee84550-5d98-4fcf-9672-97e7c52d536e

📥 Commits

Reviewing files that changed from the base of the PR and between e722925 and e419cee.

📒 Files selected for processing (11)
  • android/build.gradle
  • android/src/main/kotlin/dev/thunderid/flutter/PlayIntegrityTokenProvider.kt
  • android/src/main/kotlin/dev/thunderid/flutter/ThunderIDMethodHandler.kt
  • ios/Classes/AppAttestTokenProvider.swift
  • ios/Classes/ThunderIDMethodHandler.swift
  • ios/thunderid_flutter.podspec
  • lib/src/models/thunderid_config.dart
  • samples/quickstart/.env.example
  • samples/quickstart/README.md
  • samples/quickstart/lib/main.dart
  • test/thunderid_client_test.dart

Comment thread ios/Classes/AppAttestTokenProvider.swift
Comment thread ios/Classes/AppAttestTokenProvider.swift
Comment thread ios/thunderid_flutter.podspec Outdated
@Malith-19
Malith-19 force-pushed the feat/4230-flutter-attestation branch from e419cee to 3ee54d8 Compare July 22, 2026 08:29
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.

Support attestation in the Flutter SDK and sample

1 participant