Skip to content

Expose swift debug payload#283

Open
kchaw2005 wants to merge 16 commits into
mainfrom
expose-swift-debug-payload
Open

Expose swift debug payload#283
kchaw2005 wants to merge 16 commits into
mainfrom
expose-swift-debug-payload

Conversation

@kchaw2005

@kchaw2005 kchaw2005 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

We wanted to expose raw payload fields to Swift developers of IDKit. Moreover, we wanted to expose the fields as native swift structs to catch possible errors at compile time.

Fix

Added UniFFI records in bridge.rs that map from the existing build_request_payload wire JSON via parse helpers, plus new bridge_debug_payload methods on IDKitBuilder. Swift now exposes bridgeDebugPayload on IDKit and IDKitBuilder so devs can dot into fields like proofRequest.proofRequests instead of parsing dictionaries. Kept the JSON-returning helpers as a fallback for logging or if you need the raw wire string. Updated the swift test to assert on typed fields instead of JSONSerialization.


Note

Medium Risk
Changes the shared bridge payload construction API and adds FFI debug surfaces that mirror live request fields; production connect flows are mostly unchanged but mistakes in the debug mapping could mislead integrators.

Overview
Adds offline bridge payload inspection so mobile SDKs can read the plaintext request that would be sent to the wallet bridge—without opening a connection—using typed structs instead of hand-parsing JSON.

In Rust, build_request_payload now returns BridgeRequestPayload internally and build_request_payload_json is the public JSON entry point (WASM nativePayload follows this). New UniFFI records (BridgeDebugPayload, nested proof/identity types) map from the same builder path, and IDKitBuilder gains bridge_debug_payload / bridge_debug_payload_json (plus preset variants).

Swift wires this through internal _bridgeDebugPayload / _bridgeDebugPayloadJSON on IDKitBuilder with a DebugSpecification (preset vs constraints), plus small helpers for credential identifiers. Kotlin mirrors the same internal surface for bindings tests. Tests assert identity-check fields on typed payloads and that JSON stays aligned.

Also adjusts Swift XCFramework packaging so UniFFI headers live at the framework headers root rather than under IDKit/.

Reviewed by Cursor Bugbot for commit e104f1c. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
idkit-js-example Ready Ready Preview, Comment Jun 18, 2026 6:38am

Request Review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7350d5e. Configure here.

Comment thread scripts/package-swift.sh

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR exposes a “plaintext bridge payload” JSON builder for native SDKs (Swift and Kotlin) via UniFFI/Rust, enabling integrators to inspect and assert the bridge payload contract before encryption/upload—aligned with the bridgeDebugPayload* naming direction used in JS.

Changes:

  • Rust/UniFFI: Add IDKitBuilder.bridge_debug_payload_json* APIs that serialize the existing request payload builder output (without creating a bridge request and without a timestamp).
  • Swift & Kotlin: Add builder wrapper methods to surface the new UniFFI APIs (bridgeDebugPayloadJSON / bridgeDebugPayloadJson, plus preset variants).
  • Tests: Add Swift and Kotlin tests asserting the identity-check preset payload includes key contract fields and omits timestamp.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
swift/Tests/IDKitTests/IDKitTests.swift Adds a Swift test validating the identity-check plaintext bridge payload JSON contract.
swift/Sources/IDKit/IDKit.swift Exposes new Swift IDKitBuilder methods to fetch plaintext bridge payload JSON (constraints + preset).
scripts/package-swift.sh Adjusts Swift XCFramework header/modulemap staging to use ios_build/Headers/ root.
rust/core/src/bridge.rs Implements UniFFI-exposed Rust methods to build/serialize plaintext bridge payload JSON without creating a request.
kotlin/bindings/src/test/kotlin/com/worldcoin/idkit/IDKitTests.kt Adds a Kotlin test validating the identity-check plaintext bridge payload JSON contract.
kotlin/bindings/src/main/kotlin/com/worldcoin/idkit/IdKit.kt Exposes new Kotlin IDKitBuilder methods for plaintext bridge payload JSON (constraints + preset).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Kartike Chawla added 4 commits June 17, 2026 15:27
…wift gets typed structs instead of raw json

added BridgeDebugPayload (and related records) in bridge.rs with parsing from the
existing build_request_payload wire json, plus bridge_debug_payload ffi methods on
IDKitBuilder. swift now exposes bridgeDebugPayload on IDKit/IDKitBuilder for
property access in tests and app code. kept the json-returning helpers as a
fallback for logging or if you need the raw wire string. updated swift tests to
assert on typed fields instead of JSONSerialization.
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