SPB Git

Repository Public

README.md 2.6 KB

# MacLustr Identity — Swift demo

IdentityDemo is a small SwiftUI app (iOS and macOS) that runs the native flow or the web flow for a session. It takes a hosted URL (https://…/verify/vs_…#vsc_…) pasted in the field, or fetched from a demo backend.

# Run it

bash
cd sdk/swift/Examples/IdentityDemo
xcodegen generate          # brew install xcodegen; the generated .xcodeproj is git-ignored
open IdentityDemo.xcodeproj

Without xcodegen: create an app target in Xcode, add the package at sdk/swift as a local package, link the MacLustrIdentity product, add Sources/IdentityDemoApp.swift, and set NSCameraUsageDescription.

A real camera flow needs a physical iPhone (the Simulator has no camera) and a signing team of your own.

# Demo backend

A mobile app never holds an API key, so the demo fetches its session from a tiny backend that does:

bash
MLID_API_KEY=mlid_sk_test_… MLID_BASE_URL=http://localhost:8875 python3 ../demo-backend/server.py 8899
  • POST /session creates a verification session and returns {url, session_id, client_secret}.
  • GET /result/{session_id} returns the status as the backend sees it: the value an app should act on.

It is for development only (no authentication, loopback only). The demo's Info.plist allows local networking for that reason; do not copy that setting into a production app. From a physical phone, expose the two local services over HTTPS or use a deployed sandbox, since IdentitySession refuses plain http outside loopback.

# Automation

The app accepts launch arguments: -hostedURL <url> -autostart YES opens the native flow at launch. UITests/SandboxFlowUITests.swift uses them to drive the flow on a Simulator, without opening a window:

bash
UDID=$(xcrun simctl create "MLID iPhone" "iPhone 17 Pro"); xcrun simctl boot $UDID
TEST_RUNNER_MLID_TEST_BASE_URL=http://localhost:8875 \
TEST_RUNNER_MLID_TEST_API_KEY=mlid_sk_test_… \
xcodebuild test -project IdentityDemo.xcodeproj -scheme IdentityDemo -destination "id=$UDID"

TEST_RUNNER_MLID_TEST_LIVE_API_KEY (a live key of a development database whose compliance gates are open) enables the test of the document step without a camera. The tests are skipped when the variables are absent.

The five cases: sandbox session to verified; leaving reports canceled; an invalid secret shows an error; a live session without a camera offers a file, and "Cancel" then Stay leaves it intact while withdrawing only happens after its confirmation; during a manual review the withdrawal button asks first, and dismissing the question changes nothing. xcodebuild test boots the Simulator device without opening the Simulator app.

Files main
Menu

Theme