For the complete documentation index, see llms.txt. This page is also available as Markdown.

Getting Started with the SDK

About CafSDK

This technical documentation covers the implementation of CafSDK for Flutter, detailing the configuration, initialization, execution of capture flows, and advanced customizations.

CafSDK is a unified SDK that integrates multiple modules for identity verification: Face Liveness (FL) and Document Detector (DD), executed sequentially with a unified configuration interface.

What is Face Liveness

Face Liveness is the module that validates the authenticity of a face captured by a photo application, ensuring that the image corresponds to a real person and not a spoofing attempt.

Technical characteristics:

  • URL configuration for authentication (authBaseUrl) and liveness verification (livenessBaseUrl)

  • Support for reverse proxy configuration with certificate pinning

  • Flags to enable screen capture and debug mode

  • Configurable retry attempts and face authentication execution

  • Support for multiple authentication providers

What is Document Detector

Document Detector is the module that enables the capture and processing of documents (e.g., ID card, social security card, passport, etc.).

Technical characteristics:

  • Configuration of a step-by-step flow defined by CafDocumentDetectorFlow for document capture

  • Support for multiple document types (RG, CNH, Passport, etc.)

  • Operational parameters, such as timeout, manual capture flags, and other settings

  • Possibility of using the camera for framing validations, or document file upload

  • Advanced customization options for UI, messages, and behavior


Example

Check out the example app for a complete implementation example.


Installation

Requirements

To use the CafSDK modules in Flutter, ensure that your project meets the minimum requirements:

Flutter

Requirement
Version

Flutter Version

3.3.0+

Dart

3.9.0+

Android

Requirement
Version

Android SDK API - minimum version (minSdk)

26

Android SDK API - compile version (compileSdk)

36+

Kotlin

1.8+

Gradle

8.0+

Android Gradle Plugin (AGP)

8.0+

iOS

Requirement
Version

iOS Deployment Target

13.0+

Xcode

14.0+

Swift

5.0+

Step 1: Install the SDK

Install the main SDK package:

Step 2: Configure Module Selection

Create a caf-modules-config.json file in your project root to specify which modules to include:

Note: If you omit this file, all modules are enabled by default and iproov-lite is used as the default Face Liveness provider.

Set to true the modules you want to use in your application.

For a single provider, livenessProviders can be a string. Allowed values are iproov-lite, iproov-full, payface, and facetec. To use several providers, use an array (see the example below).

iProov and Protobuf

  • iproov-lite: use when your app targets Protobuf JavaLiteβ€”the usual choice for a smaller binary footprint on Android.

  • iproov-full: use when you need Protobuf Java (full) together with iProov.

You can declare more than one provider by setting livenessProviders to an array when your integration requires it.

Set to true the modules you want to use in your application.

Fingerprint

The Fingerprint module is optional and is configured in caf-modules-config.json via the fingerprint property (boolean). It defaults to false, so you don't need to add the property unless you want to use it. To enable the module, explicitly set "fingerprint": true.

Requires a Face Liveness module. Fingerprint is collected as part of the liveness flow, so it is only bundled when faceLiveness or faceLivenessUI is also enabled. Setting "fingerprint": true without a liveness module enabled has no effect.

Important: Please contact CAF Support to request activation. If it is not enabled on our side, the SDK will not trigger the fingerprint library and no data will be sent, even if the property is set to true locally.

Step 3: Android Configuration

Add Maven Repositories

Configure the project's build.gradle.kts file (usually located at the root level):

Step 4: iOS Configuration

Navigate to the ios/ directory of your Flutter project and run:

  • This step is mandatory for iOS to correctly link the native modules and their required dependencies.

  • Always re-run pod install whenever native dependencies are added or updated.


Permissions

Android

For the modules to operate correctly, you must declare the following permissions in your AndroidManifest.xml:

For Face Liveness

Permission
Description
Necessity

android.permission.CAMERA

Allows access to the camera to capture images and perform face verification (liveness).

Mandatory

android.permission.INTERNET

Allows communication with authentication and verification services (HTTPS/WSS).

Mandatory

For Document Detector

Permission
Description
Necessity

android.permission.CAMERA

Allows access to the camera to capture document images.

Only for capture

android.permission.INTERNET

Allows captured images to be sent to servers for processing and validation.

Mandatory

android.permission.READ_EXTERNAL_STORAGE

Allows access to stored files and images for processing, if necessary.

Only for upload

iOS

For the SDK modules to function correctly, you must declare the following permissions in your Info.plist:

For Face Liveness:

Permission
Description
Necessity

NSCameraUsageDescription

Allows access to the camera to capture images and perform face verification (liveness).

Mandatory

Network access

Allows communication with authentication and verification services (HTTPS/WSS).

Mandatory

For Document Detector:

Permission
Description
Necessity

NSCameraUsageDescription

Allows access to the camera to capture document images.

Only for capture

Network access

Allows captured images to be sent to servers for processing and validation.

Mandatory

NSPhotoLibraryUsageDescription

Allows access to stored files and images for processing, if necessary.

Only for upload


Basic Implementation

Simple Example

Here's a basic implementation example:


Configuration

Language

Android

The language is automatically set according to the language configured on the device without any additional settings.

iOS

According to Apple's documentation, configuring Localizations and CFBundleLocalizations should be done in Xcode:

After these settings, the SDK will recognize the device's language.

Global Configuration

The CafSdk class serves as the central container for all configurations. This configuration defines the execution order of the modules and the visual identity.

Essential parameters:

  • mobileToken: Token that authenticates the request and ensures that only authorized clients start the flow

  • personId: Unique user identifier for which the flow will be executed

  • environment: Defines the execution environment (PROD, BETA, DEV)

  • presentationOrder: Defines the sequence in which the modules will be executed

  • enableSecurityModule: Enables or disables the security module. Optional, default is true

Code example for creating the global configuration:

Module-Specific Configuration

Face Liveness Configuration

You can configure the Face Liveness module by creating a CafFaceLivenessConfiguration. When using the optional PayFace (Fortface) provider, use payFaceDebugMode to enable debug mode for that provider.

Document Detector Configuration

You can configure the Document Detector module by creating a CafDocumentDetectorConfiguration:


Event Handling

The eventStream from the CafSdk class provides a typed Stream<CafResponse> generated during the execution of the capture flow. Each CafResponse has exactly one populated field, which indicates the event type:

Field
Type
Description

loading

bool

Indicates the start of module processing

loaded

bool

Indicates that the module has been processed

success

CafSuccessResponse?

Upon successful completion; contains moduleName and signedResponse

error

CafErrorResponse?

A problem occurred during execution; contains type and description

failure

CafFailureResponse?

Indicates a Face Liveness failure; contains type, description, and response

log

CafLog?

Log messages with different levels; contains level (DEBUG, USAGE, INFO) and message

cancelled

bool

Indicates that the user or system interrupted the flow

Migration note (v2.0.0): eventStream now emits typed CafResponse objects instead of raw Map payloads. Replace any event['eventName'] / event['response'] access with the typed fields shown above.

Example of event handling:

Error Types (CafErrorType)

Enum Case
Trigger Condition

CAMERA_PERMISSION

Camera access denied

UNSUPPORTED_DEVICE

Unsupported device specs

NETWORK_EXCEPTION

Network connectivity issues

SERVER_EXCEPTION

Backend processing failure

TOKEN_EXCEPTION

Invalid/expired token

CAPTURE_ALREADY_ACTIVE_EXCEPTION

Concurrent capture session

UNEXPECTED_ERROR_EXCEPTION

Critical unrecoverable error

USER_TIMEOUT_EXCEPTION

Capture timeout exceeded

IMAGE_NOT_FOUND_EXCEPTION

Missing image data

TOO_MANY_REQUESTS_EXCEPTION

API rate limit exceeded

UNKNOWN_EXCEPTION

Unclassified error

LIBRARY_EXCEPTION

Low-level framework error

PERMISSION_EXCEPTION

Missing system permissions

INVALID_EXCEPTION

Invalid response received

SEQUENCE_INVALID

Invalid operation sequence

LIVENESS_EXCEPTION

Face liveness specific error

FINGERPRINT_EXCEPTION

Fingerprint related error

STORAGE_EXCEPTION

Storage access error

PROXY_EXCEPTION

Proxy configuration error

SECURITY_EXCEPTION

Security validation error

INVALID_RESPONSE_EXCEPTION

Invalid response payload received from a module

CAMERA_EXCEPTION

Camera initialization or runtime failure

FACE_AUTHENTICATION

Error during face authentication (executeFaceAuth)

BRIDGE_EXCEPTION

Native ↔ Flutter bridge communication error

Failure Types (CafFailureType)

Enum Case
Trigger Condition
GPA
LA

UNKNOWN

Generic failure

βœ…

❌

TOO_MUCH_MOVEMENT

Excessive head motion

βœ…

❌

TOO_BRIGHT

Over-illumination

βœ…

❌

TOO_DARK

Low light conditions

βœ…

❌

MISALIGNED_FACE

Face alignment failure

βœ…

❌

FACE_TOO_FAR

Face too distant

βœ…

❌

FACE_TOO_CLOSE

Face too close

βœ…

❌

SUNGLASSES

Eye-obscuring eyewear

βœ…

❌

OBSCURED_FACE

Partial face obstruction

βœ…

βœ…

EYES_CLOSED

Closed eyes during capture

βœ…

βœ…

MULTIPLE_FACES

Multiple faces detected

βœ…οΈ

βœ…οΈ

BACKGROUND_ISSUE

Unsuitable background

❌

βœ…

DEVICE_ISSUE

Incompatible device

❌

βœ…

EYEWEAR

Eyewear detected

❌

βœ…

FACE_NOT_FOUND

Face detection failure

❌

βœ…

FRAMES_BLURRY

Blurry frames detected

❌

βœ…

MOTION_ISSUE

Device motion error

❌

βœ…

LIGHTING_ISSUES

Poor lighting conditions

❌

βœ…

REJECTED

Transaction rejected

❌

βœ…

SYSTEM_ERROR

Internal system error

❌

βœ…

TIMEOUT

Session timeout

❌

βœ…

USER_NOT_FOUND

User lookup failure

❌

βœ…

DEVICE_RESTART

Device state error

❌

βœ…

PROCESSING_FAULT

Processing error

❌

βœ…


Document Types

Supported Documents (CafDocument)

Name
Description

RG_FRONT

Front side of the RG document, where the photo is located

RG_BACK

Back side of the RG document

RG_FULL

Open RG document, displaying both the front and back sides together

CNH_FRONT

Front side of the CNH document, where the photo is located

CNH_BACK

Back side of the CNH document

CNH_FULL

Open CNH document, displaying both the front and back sides together

CRLV

CRLV document

RNE_FRONT

Front side of the RNE or RNM document

RNE_BACK

Back side of the RNE or RNM document

CTPS_FRONT

Front side of the CTPS document, where the photo is located

CTPS_BACK

Back side of the CTPS document

PASSPORT

Passport document, displaying the photo and personal data

ANY

Allows submission of any type of document, including all those listed above or any other unclassified document

Supported File Formats (CafFileFormat)

Type
Value

PNG

image/png

JPG

image/jpg

JPEG

image/jpeg

PDF

application/pdf

HEIF

image/heif

HEIC

image/heic


Advanced Configuration

Face Liveness UI Configuration

When using the UI module, you can customize instruction screens:

Document Detector UI Configuration

Proxy Configuration

For Document Detector proxy settings:

Message Customization

Customize messages displayed during the capture flow:


Complete Implementation Example

Here's a complete example showing both Face Liveness UI and Document Detector UI:


ProGuard/R8 Rules

Add these ProGuard/R8 rules to your proguard-rules.pro file for Android:


Technical Support and Usage Tips

Technical Support If you have any questions or difficulties with the integration, contact Caf's technical support.

Usage Tips

  • Run tests: Perform tests on real devices to validate requirements and flow performance

  • Explore customizations: Use advanced customization options to tailor the flow to your project's needs

  • Monitor performance: Integrate monitoring tools to track logs and the flow's performance in production

  • Handle errors gracefully: Implement proper error handling for all possible error and failure scenarios

  • Test with different devices: Ensure compatibility across various device specifications and screen sizes


Release Notes

[email protected]

Release date

  • 08-03-2026

Highlights

  • Optional Fingerprint module: Control the inclusion of the fingerprint feature directly from caf-modules-config.json. It is disabled by default, ensuring you only include the dependency when strictly necessary.

Updates

  • New fingerprint boolean field in caf-modules-config.json for Android and iOS.

[email protected]

Release date

  • 07-06-2026

Highlights

  • More consistent error reporting: Errors occurring during flow initialization that relate to the SDK's internal integration are now emitted via the error event as BRIDGE_EXCEPTION, so they can be handled the same way as any other SDK error.

Breaking Changes

  • Typed event stream: CafSdk.eventStream is now Stream<CafResponse>. Consumers must access the typed fields of CafResponse (success, error, failure, log, loading, loaded, cancelled) instead of indexing a Map.

  • Flattened module configuration classes: The per-module ...BuilderConfiguration wrappers were removed. Fields are now passed directly on the module configuration objects, and the UI configurations extend the base configuration instead of nesting it:

    • CafFaceLivenessBuilderConfiguration removed β€” pass fields directly on CafFaceLivenessConfiguration.

    • CafDocumentDetectorBuilderConfiguration removed β€” pass fields directly on CafDocumentDetectorConfiguration.

    • CafFaceLivenessUIBuilderInstructionScreenConfiguration β†’ CafFaceLivenessUIInstructionScreenConfiguration, and the field instructionScreenConfiguration β†’ instructionScreen.

    • CafDocumentDetectorUIBuilderInstructionScreenConfiguration β†’ CafDocumentDetectorUIInstructionScreenConfiguration, and the field instructionScreenConfiguration β†’ instructionScreen.

    • CafDocumentDetectorUIBuilderDocumentSelectionScreenConfiguration β†’ CafDocumentDetectorUIDocumentSelectionScreenConfiguration, and the field documentSelectionScreenConfiguration β†’ documentSelectionScreen.

    • The SDK-level CafSdkConfiguration is unchanged and still takes configuration: CafSdkBuilderConfiguration(...).

  • initializeCafSdk return type: changed from Future<bool?> to Future<bool>.

Updates

  • Event name constants: Added the CafSdkEventName constants (CafUnifiedEvent.*) for identifying emitted events.

  • New CafErrorType values: Added INVALID_RESPONSE_EXCEPTION, CAMERA_EXCEPTION, FACE_AUTHENTICATION, and BRIDGE_EXCEPTION. Note that BRIDGE_EXCEPTION reports errors that occur while initializing or starting the flow; listen for it on the error event and handle it as part of your normal error handling.

  • CafSuccessResponse: signedResponse is now typed as String? (previously dynamic), and moduleName resolution is more resilient to native identifier variations.

Migration Guide β€” 1.x β†’ 2.0.0

Three things changed for integrators: how you read events, how you build module configurations, and the return type of initializeCafSdk. The SDK-level CafSdkConfiguration (with CafSdkBuilderConfiguration) is unchanged.

1. Read events from the typed stream

2. Remove the module ...BuilderConfiguration wrapper

Pass the fields directly on the module configuration object.

3. Update the UI configurations (wrapper + renamed types and fields)

4. Rename type imports (if you imported the removed types)

Removed (1.x)
Use instead (2.0.0)

CafFaceLivenessBuilderConfiguration

CafFaceLivenessConfiguration

CafDocumentDetectorBuilderConfiguration

CafDocumentDetectorConfiguration

CafFaceLivenessUIBuilderInstructionScreenConfiguration

CafFaceLivenessUIInstructionScreenConfiguration

CafDocumentDetectorUIBuilderInstructionScreenConfiguration

CafDocumentDetectorUIInstructionScreenConfiguration

CafDocumentDetectorUIBuilderDocumentSelectionScreenConfiguration

CafDocumentDetectorUIDocumentSelectionScreenConfiguration

5. Update the initializeCafSdk return type

initializeCafSdk now returns Future<bool> instead of Future<bool?>. Remove any null checks on the awaited result.

[email protected]

Release date

  • 05-25-2026

Updates

  • Payface Liveness Provider (Android): Update version from 1.18.2 to 1.19.2.

  • Payface Liveness Provider (iOS): Update version from 1.5.2 to 1.8.2.

Fixes

FaceLiveness

  • Infinite loading error occurs when the SDK returns an error.

  • First initialization not working when using Payface provider.

[email protected]

Release date

  • 05-08-2026

Fixes

  • DocumentDetector: Fixed behavior when handling RG (Brazilian National Identity Card) with the digital document option.

[email protected]

Release date

  • 04-13-2026

Highlights

  • Configurable Face Liveness providers: Choose iproov-lite, iproov-full, payface, and/or facetec from caf-modules-config.json instead of relying on implicit native defaults.

Updates

  • Liveness provider configuration:

    • New livenessProviders field in caf-modules-config.json for Android and iOS.

    • Documented Protobuf JavaLite vs Protobuf Java mapping for iproov-lite vs iproov-full.

    • Clarified multi-provider setups using an array, and the PayFace + iProov Lite requirement.

  • iProov Liveness Provider: Documentation and defaults updated to reflect the new provider selection model.

  • Android ProGuard / R8: If R8 reports missing classes for lint stubs shipped with the SDK, add the following to proguard-rules.pro (also listed under ProGuard/R8 Rules):

[email protected]

Release date

  • 02-09-2026

Highlights

  • Updated Liveness Provider: Critical update to the iProov provider version for improved stability

Updates

  • iProov Liveness Provider: Updated the internal iProov provider version.

[email protected]

Release date

  • 02-09-2026

Highlights

  • New Security Module: Introduction of CafSecurity module for security validations

  • PayFace Integration: Added support for PayFace (Fortface) as an optional Face Liveness provider

  • Stability Improvements: Major crash fixes and stability improvements for the Document Detector module

Features

  • CafSecurity Module:

    • Added a new module specifically for security validations

    • Configuration: Added enableSecurityModule flag in CafSdkConfiguration (default value: true)

  • PayFace (Fortface) Integration:

    • Optional Face Liveness provider integration

    • Configuration: New property payFaceDebugMode in CafFaceLivenessConfiguration to enable debug mode for the PayFace provider

Fixes

  • DocumentDetector:

    • Activity Lifecycle: Resolved multiple crashes related to activity lifecycle management (initialization, pause, and resume states)

    • Camera Lifecycle: Improved camera resource management and thread lifecycle to prevent crashes during SDK shutdown

    • UI Components: Resolved theme compatibility issues and fragment transaction exceptions

    • Network Requests: Corrected response body handling to prevent errors when reading network responses

    • Data Access: Improved cursor initialization and validation before accessing database data

    • ANR Prevention: Optimized document controller instance checks to prevent "Application Not Responding" issues

    • General: Internal improvements and stability corrections

  • FaceLiveness:

    • Sessions: Fixed session creation errors

    • UI: Fixed color tint on remote images in the Instructions screen

Updates

  • Build Configuration:

    • ProGuard Rules: Added necessary ProGuard rules for PayFace integration

[email protected]

Release date

  • 03-09-2026

Updates

  • Updated iProov Liveness Provider: Update iProov provider version.

  • Updated iOS minimum deployment target: Updated to 15.0.

Fixes

  • DocumentDetector

    • Fixed crashes in Document Detector module: Resolved multiple crashes related to activity lifecycle management, including initialization, pause, and resume states.

    • Fixed crashes related to camera lifecycle: Improved camera resource management and thread lifecycle to prevent crashes during SDK shutdown and state transitions.

    • Fixed crashes in UI components: Resolved theme compatibility issues and fragment transaction exceptions to ensure proper UI behavior.

    • Fixed crashes in network requests: Corrected response body handling to prevent errors when reading network responses.

    • Fixed crashes in data access: Improved cursor initialization and validation before accessing database data.

    • Fixed ANR in Document Controller: Optimized document controller instance checks to prevent application not responding issues.

    • Internal improvements and corrections: Additional stability enhancements and bug fixes.

[email protected]

Release date

  • 10-27-2025

Highlights

  • First Flutter SDK Release: Complete Flutter implementation of the CAF SDK for identity verification

  • Unified SDK: Single package containing all CAF modules (Face Liveness and Document Detector) with both core and UI variants

  • Flutter-Native Integration: Seamless integration with Flutter's widget system and state management

  • Cross-Platform Support: Full support for both Android and iOS platforms

  • Type-Safe Configuration: Strongly typed Dart configuration classes for better development experience

Features

  • Module Configuration System:

    • caf-modules-config.json: Configuration file in project root to specify which modules to include

    • Available modules:

      • documentDetector: Enable/disable Document Detector module

      • faceLiveness: Enable/disable Face Liveness module

      • documentDetectorUI: Enable/disable Document Detector UI module

      • faceLivenessUI: Enable/disable Face Liveness UI module

    • Example configuration:

  • Core SDK Features:

    • CafSdk Class: Main SDK class for initialization and configuration

    • Event Stream: Real-time event handling through Dart streams

    • Module Management: Sequential execution of modules with configurable presentation order

    • Error Handling: Comprehensive error types and failure handling

    • Configuration Builder: Type-safe configuration using builder pattern

  • Face Liveness Module:

    • Core Module: CafFaceLivenessConfiguration for programmatic control

    • UI Module: CafFaceLivenessUIConfiguration with customizable instruction screens

    • Features: Authentication URLs, certificate pinning, debug mode, retry attempts

    • Customization: Instruction screens with images, titles, descriptions, and steps

  • Document Detector Module:

    • Core Module: CafDocumentDetectorConfiguration for programmatic control

    • UI Module: CafDocumentDetectorUIConfiguration with full UI customization

    • Document Types: Support for RG, CNH, Passport, RNE, CTPS, and more

    • Upload Support: File upload with compression, format control, and size limits

    • Proxy Configuration: Support for proxy servers with authentication

    • Message Customization: Customizable user messages throughout the flow

  • Advanced Configuration:

    • Color Theming: Complete UI color customization through CafColorConfiguration

    • Security Settings: Development flags, debug mode, and security controls

    • Flow Control: Manual capture, timeouts, retry attempts, and popup controls

    • Instruction Screens: Customizable instruction screens for both modules

Technical Implementation

  • Flutter Integration:

    • Method Channels: Native communication through Flutter's method channel system

    • Stream-Based Events: Real-time event handling using Dart streams

    • State Management: Proper lifecycle management with StatefulWidget support

    • Error Handling: Comprehensive error handling with typed exceptions

  • Platform Support:

    • Android: Full support with ProGuard/R8 rules and Maven repository configuration

    • iOS: Complete integration with CocoaPods and native iOS modules

    • Permissions: Proper permission handling for camera and network access

  • Performance:

    • Selective Module Loading: Only load enabled modules to optimize bundle size

    • Memory Management: Proper resource cleanup and memory management

    • Network Optimization: Efficient network communication with retry mechanisms

Installation and Setup

  • Package Installation: Simple installation via flutter pub add caf_sdk

  • Module Configuration: Easy module selection through JSON configuration file

  • Platform Setup: Clear instructions for Android and iOS platform configuration

  • Permission Management: Comprehensive permission setup for both platforms

Documentation

  • Complete Examples: Full implementation examples for both basic and advanced usage

  • Configuration Guide: Detailed configuration options for all modules

  • Event Handling: Comprehensive event handling examples and patterns

  • Error Reference: Complete error types and failure scenarios documentation

Breaking Changes

  • First Release: This is the first release of the Flutter SDK, so there are no breaking changes from previous versions.

Known Issues

  • iOS Simulator: Some features may not work properly in iOS Simulator due to camera limitations

  • Android Emulator: Camera-dependent features require physical devices for testing

  • Network Requirements: All modules require internet connectivity for proper operation

Last updated