diff --git a/scripts/build-swift.sh b/scripts/build-swift.sh index 97d12f14..2c9cb9dd 100755 --- a/scripts/build-swift.sh +++ b/scripts/build-swift.sh @@ -24,9 +24,10 @@ echo "" echo "🔧 Step 2/3: Generating Swift bindings..." mkdir -p "$GENERATED_DIR" -uniffi-bindgen generate \ +cargo run -p uniffi-bindgen generate \ --library target/release/libidkit.dylib \ --language swift \ + --no-format \ --out-dir "$GENERATED_DIR" echo "✅ Generated Swift bindings to: $GENERATED_DIR" diff --git a/swift/Examples/IDKitSampleApp/IDKitSampleApp/ContentView.swift b/swift/Examples/IDKitSampleApp/IDKitSampleApp/ContentView.swift index 34400382..45a0dded 100644 --- a/swift/Examples/IDKitSampleApp/IDKitSampleApp/ContentView.swift +++ b/swift/Examples/IDKitSampleApp/IDKitSampleApp/ContentView.swift @@ -28,6 +28,7 @@ enum SampleLegacyPreset: String, CaseIterable, Identifiable { case document case device case selfieCheck = "selfie check" + case identityCheckWithProofOfHumanity = "identity check with proof of humanity" var id: String { rawValue } @@ -43,6 +44,14 @@ enum SampleLegacyPreset: String, CaseIterable, Identifiable { deviceLegacy(signal: signal) case .selfieCheck: selfieCheckLegacy(signal: signal) + case .identityCheckWithProofOfHumanity: + identityCheck( + attributes: [ + .minimumAge(21), + .nationality("JPN"), + .documentType(.passport), + ] + ) } } } @@ -102,7 +111,7 @@ struct ContentView: View { .pickerStyle(.segmented) } - Picker("Legacy preset", selection: $model.legacyPreset) { + Picker("Preset", selection: $model.legacyPreset) { ForEach(SampleLegacyPreset.allCases) { preset in Text(preset.rawValue).tag(preset) } @@ -271,7 +280,7 @@ final class SampleModel: ObservableObject { deepLinkReceivedForPendingRequest = false print("IDKit invite-code URL: \(request.connectorURL.absoluteString)") - log("Using legacy preset: \(legacyPreset.rawValue)") + log("Using preset: \(legacyPreset.rawValue)") log("Generated request ID: \(request.requestID)") log("Verify URL expires \(ISO8601DateFormatter().string(from: request.expiresAt))") startPolling( diff --git a/swift/README.md b/swift/README.md index 70171361..1c65a51b 100644 --- a/swift/README.md +++ b/swift/README.md @@ -74,6 +74,22 @@ let request = try IDKit .preset(selfieCheckLegacy(signal: "user-123")) ``` +For document-based identity attestation, use: + +```swift +let request = try IDKit + .request(config: config) + .preset( + identityCheck( + attributes: [ + .minimumAge(21), + .nationality("JPN"), + .documentType(.passport), + ] + ) + ) +``` + ## Canonical Swift API - Entry points: diff --git a/swift/Sources/IDKit/IDKit.swift b/swift/Sources/IDKit/IDKit.swift index aaa77783..b42c4572 100644 --- a/swift/Sources/IDKit/IDKit.swift +++ b/swift/Sources/IDKit/IDKit.swift @@ -477,6 +477,13 @@ public func selfieCheckLegacy(signal: String? = nil) -> Preset { .selfieCheckLegacy(signal: signal) } +/// Returns the identity check preset. +/// +/// This preset requires World ID 4.0-compatible clients. +public func identityCheck(attributes: [IdentityAttribute]) -> Preset { + .identityCheck(attributes: attributes) +} + // TODO: Re-enable when World ID 4.0 is live // private struct CredentialRequestJSON: Encodable { // let type: String diff --git a/swift/Tests/IDKitTests/IDKitTests.swift b/swift/Tests/IDKitTests/IDKitTests.swift index 720c39aa..96eb17c4 100644 --- a/swift/Tests/IDKitTests/IDKitTests.swift +++ b/swift/Tests/IDKitTests/IDKitTests.swift @@ -241,6 +241,13 @@ func legacyPresetHelpers() { let doc = documentLegacy(signal: "z") let device = deviceLegacy(signal: "d") let face = selfieCheckLegacy(signal: "f") + let identity = identityCheck( + attributes: [ + .minimumAge(21), + .nationality("JPN"), + .documentType(.passport) + ] + ) switch orb { case .orbLegacy(let signal): @@ -281,6 +288,18 @@ func legacyPresetHelpers() { .identityCheck, .proofOfHuman, .passport: Issue.record("Expected selfieCheckLegacy preset") } + + switch identity { + case let .identityCheck(attributes): + let expected: [IdentityAttribute] = [ + .minimumAge(21), + .nationality("JPN"), + .documentType(.passport) + ] + #expect(attributes == expected) + case .orbLegacy, .secureDocumentLegacy, .documentLegacy, .deviceLegacy, .selfieCheckLegacy: + Issue.record("Expected identityCheck preset") + } } // TODO: Re-enable when World ID 4.0 is live