Classes

The following classes are available globally.

DeviceClient

  • Client for managing user devices

    DeviceClient provides a type-safe interface for managing various types of authentication devices registered to a user.

    Supported Device Types

    Mutable (Full CRUD)

    • Oath: TOTP/HOTP authentication devices
    • Push: Push notification authentication devices
    • Bound: Device binding for 2FA
    • Profile: Device profiling information
    • WebAuthn: WebAuthn/FIDO2 credentials

    Usage

    // Initialize with configuration
    let config = DeviceClientConfig(
        serverUrl: "https://openam.example.com",
        realm: "alpha",
        cookieName: "iPlanetDirectoryPro",
        ssoToken: token
    )
    let client = DeviceClient(config: config)
    
    // Fetch devices
    let result = await client.oath.get()
    switch result {
    case .success(let devices):
        print("Found \(devices.count) devices")
    case .failure(let error):
        print("Error: \(error)")
    }
    
    // Update a device
    if case .success(let devices) = await client.bound.get(),
       var device = devices.first {
        device.deviceName = "My Updated Device"
        let updateResult = await client.bound.update(device)
        if case .success = updateResult {
            print("Device updated successfully")
        }
    }
    
    // Delete a device
    let deleteResult = await client.oath.delete(deviceToDelete)
    if case .failure(let error) = deleteResult {
        print("Failed to delete: \(error)")
    }
    

    Error Handling

    All operations return Result types:

    let result = await client.oath.get()
    switch result {
    case .success(let devices):
        print("Fetched \(devices.count) devices")
    case .failure(let error):
        switch error {
        case .requestFailed(let statusCode, let message):
            print("Request failed: \(statusCode) - \(message)")
        case .networkError(let error):
            print("Network error: \(error)")
        default:
            print("Error: \(error.localizedDescription)")
        }
    }
    

    Thread Safety

    DeviceClient is safe to use from any thread. All async methods are marked with appropriate concurrency annotations and will execute on appropriate queues.

    Important

    Ensure the SSO token in the configuration is valid before making requests

    Note

    The client does not automatically refresh tokens; token management is the caller’s responsibility
    See more

    Declaration

    Swift

    public class DeviceClient : @unchecked Sendable