Skip to content
SDKs · ClientIn developmentView source

iOS

A Swift package over DCAppAttestService, iOS 14+. It holds no Root Herald key and makes no request to Root Herald; enroll is the only call that contacts Apple. ABI 8.0.

In development

This SDK is implemented but not yet published to its package registry. Until it ships, collect an opaque evidence blob on the device and appraise it server-side with @rootherald/node (or any available server SDK). The API shown below is the planned surface and may change before release.

Package.swiftswift
.package(url: "https://github.com/RootHerald/sdk-ios.git", from: "0.6.0")
// product: "RootHerald". Enable the App Attest capability under Signing & Capabilities.

The calls

  • RootHeraldClient() — persists only the App Attest key id in UserDefaults.
  • collectPosture() → Posture: hasHardwareKeyStore, isEnrolled, appKeysSupported, keyId. Local, free.
  • enroll(to: challenge) → Data to relay to POST /api/v1/attest/enroll. One leg, once per install; the body carries the nonce read from the challenge string, and the 201 response is empty.
  • markEnrolled() — call it once your server has relayed the enrollment. Until then, attest, mintKey and assert throw .notEnrolled.
  • attest(to: challenge) → Evidence(assertion, keyId); evidence.jsonData() is the blob for verify. Serves identity; a posture ask throws .askUnsupported(.posture).
  • mintKey(keyChallenge) → a certification for POST /api/v1/keys/certify. The App Attest key is the key: no blob, nothing to load, and certifyKey returns its JWK. Purpose sign only; decrypt throws .purposeUnsupported.
  • assert(_ message: Data) → an App Attest assertion over your message, signed by the enrolled key. A message beginning with the ceremony prefix throws .reservedPrefix.
  • reset() — forget the key; the next enroll mints a new identity.
  • Errors: RootHeraldError.notSupported, .invalidChallenge, .askUnsupported, .purposeUnsupported, .reservedPrefix, .notEnrolled, .keyGenerationFailed, .attestationFailed, .attestationUnavailable, .alreadyEnrolled, .assertionFailed.
Signatures are assertions

assert(_:) produces an App Attest assertion, not raw r||s, and verifyKeySignature doesn't read assertions: your backend verifies it as an App Attest assertion under the JWK, with a counter that only moves forward; see Verify data came from a device. App Attest is unavailable on the Simulator.