CAF SDK Flutter Plugin
A Flutter plugin that provides native integration with the CAF (Combate à Fraude) SDK, enabling document detection, face liveness verification, and related UI components in Flutter applications.
Features
- Document Detector - Detect and validate identity documents
- Document Detector UI - Pre-built UI components for document capture
- Face Liveness - Verify face liveness for biometric authentication
- Face Liveness UI - Pre-built UI components for face capture
- Cross-platform - Native implementation for both Android and iOS
- Event-driven - Stream-based event handling for real-time updates
Installation
Add this to your package's pubspec.yaml file:
dependencies:
caf_sdk: ^1.0.0
Then run:
flutter pub get
Platform Setup
Android
- Add the following permissions to your
android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.android.permission.READ_EXTERNAL_STORAGE" />
- Ensure your
android/app/build.gradlehas the minimum SDK version:
android {
defaultConfig {
minSdkVersion 26
// ... other configurations
}
}
iOS
- Add camera usage description to your
ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Allows access to the camera to capture document images.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Allows access to stored files and images for processing, if necessary.</string>
<key>UILaunchStoryboardName</key>
- Ensure your iOS deployment target is at least 11.0 in
ios/Podfile:
platform :ios, '11.0'
Usage
Basic Setup
import 'package:caf_sdk/caf_sdk.dart';
final config = CafSdkConfiguration(
mobileToken: 'token',
personId: 'personId',
environment: CafEnvironment.dev,
configuration: CafSdkBuilderConfiguration(
presentationOrder: [
CafModuleType.faceLiveness,
CafModuleType.documentDetector,
],
waitForAllServices: true,
),
);
// Face Liveness Configuration
final faceLivenessConfig = CafFaceLivenessConfiguration(
configuration: CafFaceLivenessBuilderConfiguration(
loading: true,
debugModeEnabled: true,
),
);
// Document Detector Configuration
final documentDetectorConfig = CafDocumentDetectorConfiguration(
configuration: CafDocumentDetectorBuilderConfiguration(
flow: [
CafDocumentDetectorFlow(document: CafDocument.rgFront),
CafDocumentDetectorFlow(document: CafDocument.rgBack),
],
uploadSettings: CafDocumentDetectorUploadSettings(enable: false),
manualCaptureEnabled: false,
manualCaptureTime: 45,
showPopup: true,
previewShow: false,
securitySettings: CafDocumentDetectorSecuritySettings(
useAdb: true,
useDebug: true,
useDevelopmentMode: true,
),
),
);
await _cafSdk.initializeCafSdk(
cafSdkConfiguration: config,
faceLivenessConfiguration: faceLivenessConfig,
documentDetectorConfiguration: documentDetectorConfig,
);
Event Handling
// Listen to SDK events
void _initializeEventStream() {
_eventSubscription = _cafSdk.eventStream.listen((event) {
if (!mounted) return;
print('Caf SDK Event: $event');
});
}
Configuration
The plugin supports extensive configuration options for each module:
- CafSdkConfiguration - Main SDK configuration
- CafDocumentDetectorConfiguration - Document detection settings
- CafDocumentDetectorUIConfiguration - Document UI customization
- CafFaceLivenessConfiguration - Face liveness settings
- CafFaceLivenessUIConfiguration - Face UI customization
Refer to the API documentation for detailed configuration options.
Example
Check out the example app for a complete implementation example.
Requirements
- Flutter >= 3.3.0
- Dart ^3.9.0
- Android API level 26+
- iOS 11.0+
Support
For support and questions:
- Check the example app for implementation details
- Review the SDK documentation
- Contact the development team for technical support
License
This plugin is proprietary software. Please refer to the license terms for usage rights and restrictions.
Libraries
- caf_sdk
- caf_sdk_method_channel
- caf_sdk_platform_interface
- types/document_detector
- types/document_detector_ui
- types/face_liveness
- types/face_liveness_ui
- types/index
- Export file for all CAF SDK type definitions. This file provides convenient access to all type definitions across the CAF SDK modules.
- utils/caf_sdk_validator