Skip to content

LLCFreedom-Space/fs-local-authentication-provider

FSLocalAuthenticationProvider

Swift Version License GitHub release (with filter) Read the Docs example workflow example workflow example workflow codecov

Provides methods to manage local authentication on iOS devices, including:

  • Checking biometric availability (Face ID, Touch ID, or Optic ID)
  • Setting up biometric authentication with a localized reason
  • Authenticating users using biometrics
  • Retrieving the available biometric type

Features

  • Clear and concise API for easy integration
  • Error handling for common authentication issues
  • Logging for debugging and troubleshooting
  • Support for testing with a mock LAContext
  • Compatibility with iOS 10.0 and later

Installation

Add the package to your Package.swift file:

dependencies: [
.package(url: "https://github.com/LLCFreedom-Space/fs-local-authentication-provider", from: "1.0.0")
]

Import the package in your Swift files:

import LocalAuthenticationProvider

Usage

Import the library:

import LocalAuthenticationProvider

Create an instance of LocalAuthenticationProvider:

let provider = LocalAuthenticationProvider()

Use the provided methods to perform authentication tasks:

// Check if biometric authentication is available
if try await provider.checkBiometricAvailable() {
    // Set up biometric authentication
    if try await provider.setBiometricAuthentication(localizedReason: "Authenticate to access your data") {
        // Authenticate the user
        if try await provider.authenticate(localizedReason: "Confirm your identity") {
            // Authentication successful!
        } else {
            // Authentication failed
        }
    } else {
        // Biometric authentication could not be set up
    }
} else {
    // Biometric authentication is not available
}

Contributions

We welcome contributions to this project! Please feel free to open issues or pull requests to help improve the package.

Links

LLC Freedom Space – @LLCFreedomSpacesupport@freedomspace.company

Distributed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3. See LICENSE.md for more information.

GitHub