Repository Public
1# MacLustr Identity — Swift demo23`IdentityDemo` is a small SwiftUI app (iOS and macOS) that runs the native flow or the web flow for a session.4It takes a hosted URL (`https://…/verify/vs_…#vsc_…`) pasted in the field, or fetched from a demo backend.56## Run it78```bash9cd sdk/swift/Examples/IdentityDemo10xcodegen generate # brew install xcodegen; the generated .xcodeproj is git-ignored11open IdentityDemo.xcodeproj12```1314Without xcodegen: create an app target in Xcode, add the package at `sdk/swift` as a local package, link the15`MacLustrIdentity` product, add `Sources/IdentityDemoApp.swift`, and set `NSCameraUsageDescription`.1617A real camera flow needs a physical iPhone (the Simulator has no camera) and a signing team of your own.1819## Demo backend2021A mobile app never holds an API key, so the demo fetches its session from a tiny backend that does:2223```bash24MLID_API_KEY=mlid_sk_test_… MLID_BASE_URL=http://localhost:8875 python3 ../demo-backend/server.py 889925```2627- `POST /session` creates a verification session and returns `{url, session_id, client_secret}`.28- `GET /result/{session_id}` returns the status as the backend sees it: the value an app should act on.2930It is for development only (no authentication, loopback only). The demo's Info.plist allows local networking31for that reason; do not copy that setting into a production app. From a physical phone, expose the two local32services over HTTPS or use a deployed sandbox, since `IdentitySession` refuses plain http outside loopback.3334## Automation3536The app accepts launch arguments: `-hostedURL <url> -autostart YES` opens the native flow at launch.37`UITests/SandboxFlowUITests.swift` uses them to drive the flow on a Simulator, without opening a window:3839```bash40UDID=$(xcrun simctl create "MLID iPhone" "iPhone 17 Pro"); xcrun simctl boot $UDID41TEST_RUNNER_MLID_TEST_BASE_URL=http://localhost:8875 \42TEST_RUNNER_MLID_TEST_API_KEY=mlid_sk_test_… \43xcodebuild test -project IdentityDemo.xcodeproj -scheme IdentityDemo -destination "id=$UDID"44```4546`TEST_RUNNER_MLID_TEST_LIVE_API_KEY` (a live key of a development database whose compliance gates are open)47enables the test of the document step without a camera. The tests are skipped when the variables are absent.4849The five cases: sandbox session to `verified`; leaving reports `canceled`; an invalid secret shows an error; a50live session without a camera offers a file, and "Cancel" then *Stay* leaves it intact while withdrawing only51happens after its confirmation; during a manual review the withdrawal button asks first, and dismissing the52question changes nothing. `xcodebuild test` boots the Simulator device without opening the Simulator app.5354