Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt

Use this file to discover all available pages before exploring further.

Authentication

PrismCapabilities provides type-safe wrappers around Apple’s LocalAuthentication and AuthenticationServices frameworks. Authenticate users with biometrics or Apple ID without touching LAContext or ASAuthorizationController directly.

Biometric Auth

Face ID, Touch ID, and Optic ID with policy selection, error mapping, and device capability detection.

Sign in with Apple

Full Apple ID flow — authorization requests, credential handling, and revocation detection.

Biometric Authentication

Device Capability

Query which biometric type is available on the current device:
Check Biometric Type
import PrismCapabilities

let biometricType = PrismBiometricClient.availableBiometricType()

switch biometricType {
case .faceID:    print("Face ID available")
case .touchID:   print("Touch ID available")
case .opticID:   print("Optic ID available (Vision Pro)")
case .none:      print("No biometrics available")
}

Authentication Policies

Choose the level of fallback you want:
PolicyBehavior
.deviceOwnerAuthenticationWithBiometricsBiometrics only — no fallback
.deviceOwnerAuthenticationBiometrics with device passcode fallback

Authenticate

Biometric Authentication
let result = await PrismBiometricClient.authenticate(
    reason: "Unlock your vault",
    policy: .deviceOwnerAuthenticationWithBiometrics
)

switch result {
case .success:
    print("Authenticated!")
case .failure(let error):
    switch error {
    case .userCancel:       print("User cancelled")
    case .biometryLockout:  print("Too many failed attempts")
    case .biometryNotEnrolled: print("No biometrics enrolled")
    default:                print("Auth failed: \(error)")
    }
}

Error Types

PrismBiometricError maps all common LAError codes:
ErrorDescription
.authenticationFailedInvalid credentials provided
.userCancelUser tapped Cancel
.userFallbackUser tapped the fallback button
.systemCancelSystem interrupted authentication
.passcodeNotSetNo passcode configured on device
.biometryNotAvailableHardware not available
.biometryNotEnrolledNo biometric data enrolled
.biometryLockoutToo many failed attempts

Sign in with Apple

PrismSignInWithApple wraps ASAuthorizationController for Apple ID login:
Sign in with Apple
let client = PrismSignInWithApple()

let credential = try await client.signIn(
    scopes: [.fullName, .email]
)

print("User ID: \(credential.userID)")
print("Email: \(credential.email ?? "not shared")")
print("Name: \(credential.fullName ?? "not shared")")
Store the userID from the credential — it’s stable across sessions. The email and name are only provided on the first authorization.

Credential State

Check if a previously authorized user is still valid:
Check Credential State
let state = try await client.credentialState(
    forUserID: savedUserID
)

switch state {
case .authorized:    print("Still valid")
case .revoked:       print("User revoked access")
case .notFound:      print("No credential found")
case .transferred:   print("Transferred to new device")
}