Ask or search…
K
Links
Comment on page

FaceAuthenticator (Deprecated)

Privacy Policy and Terms & Conditions of Use

When using our plugin, please make sure that you agree with our Privacy Policy and our Terms and Conditions of Use.

Pre-requirements

Minimum configuration
Version
Flutter
1.12+
Dart
2.12+
Minimum Android API
21+
Compile SDK Version
33
iOS
11.0+
If you use Dart in a version below 2.12, check the compatible version here.

Settings

Android

In the file ** ROOT_PROJECT/android/app/build.gradle**, add:
android {
...
dataBinding.enabled = true
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
//To perform layout customization from the SDK import the following libraries
dependencies {
implementation "androidx.camera:camera-view:1.2.0-alpha02"
implementation 'com.combateafraude.sdk:face-authenticator:5.8.13'
//native Android SDK that the plugin implements
//design libraries that you will use in your layout (these are used in our example template for customization)
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
}

iOS

In the ROOT_PROJECT/ios/Podfile, add to the end of the file:
source 'https://github.com/combateafraude/iOS.git'
source 'https://cdn.cocoapods.org/' # or 'https://github.com/CocoaPods/Specs' if the CDN is down
Finally, add the camera permission to the file ROOT_PROJECT/ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>To capture the selfie</string>

Flutter

Add the plugin to your ROOT_PROJECT/pubspec.yaml file:
dependencies:
face_authenticator:
git:
url: https://github.com/combateafraude/Flutter.git
ref: face-authenticator-v3.9.0

Utilization

FaceAuthenticator faceAuthenticator = new FaceAuthenticator(mobileToken: mobileToken);
faceAuthenticator.setPeopleId("The user CPF");
// Other customization parameters
FaceAuthenticatorResult faceAuthenticatorResult = await faceAuthenticator.start();
if (faceAuthenticatorResult is FaceAuthenticatorSuccess) {
// The SDK was successfully closed and we got an authentication result, which can be true or false
} else if (faceAuthenticatorResult is FaceAuthenticatorFailure) {
// The SDK was closed due to some failure and we could not get an authentication result
} else {
// The user simply closed the SDK, with no result
}

Disabling Security Validations for Testing

We are constantly taking actions to make the product more and more secure, mitigating a number of attacks observed in the capture process and, consequently, reducing as many possible identity frauds as possible. The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below:
FaceAuthenticatorAndroidSettings androidSettings =
FaceAuthenticatorAndroidSettings(
emulatorSettings: true,
rootSettings: true,
useDeveloperMode: true,
useAdb: true,
useDebug: true,
);
faceAuthenticator.setAndroidSettings(androidSettings);
Attention! Disabling security validations is recommended for test environments only. For publishing your application in production, we recommend using the default settings.

General customizations

FaceAuthenticator
.setPeopleId(String peopleId)
CPF of the user that will authenticate
.setAudioSettings(bool enable, String audioResIdName)
Enables/disables sounds. Allows you to customize the audio used by the SDK. If you want to change the SDK's audio, add the audio file in ROOT_PROJECT/android/app/src/main/res/raw/ with the desired name below and parameterize it
.setAnalyticsSettings(bool useAnalytics)
Enables/disables data collection for maximizing anti-fraud information. Default is true
.setNetworkSettings(int requestTimeout)
Change the default network settings. Default is 60 seconds
.setAndroidSettings(FaceAuthenticatorAndroidSettings androidSettings)
Customizations only applied on Android
.setIosSettings(FaceAuthenticatorIosSettings iosSettings)
Customizations only applied on iOS
.setEyesClosedSettings(bool enable, double threshold)
Lets you customize the eyes-open validation in the SDK
|
.setStage(String stage)
Allows you to choose the environment in wich the SDK will run (production or beta). The expected String values are: "PROD" and "BETA". This setting is not mandatory, by default the SDK will use the production environment.
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
|

Android

FaceAuthenticatorAndroidSettings constructor
FaceAuthenticatorCustomizationAndroid customization
Activity's Android layout customization
CaptureSettings captureSettings
Stabilization time settings for capturing the selfie
SensorSettingsAndroid sensorSettings
Customization of the capture sensor settings
bool enableEmulator
Enables the use of an emulator when true
bool enableRootDevices
Enables the use of root devices when true
bool enableSwitchCameraButton
Allows you to enable or disable the camera flip button. Default is True
bool enableBrightnessIncrease
Enables/disables device brightness increment on opening the SDK
bool useDebug
Enables/disables the use of the app in debug mode. Default is false
FaceAuthenticatorCustomizationAndroid constructor
String styleResIdName
Name of the style resource that defines the colors of the SDK. For example, if you want to change the SDK colors, create a style in ROOT_PROJECT/android/app/src/main/res/values/styles.xml with the name R.style.my_custom_style following the template and parameterize "my_custom_style".
String layoutResIdName
Name of the layout resource that will replace the default SDK layout. For example, if you want to change the SDK layout, create a layout in ROOT_PROJECT/android/app/src/main/res/layout/my_custom_layout.xml following the template and parameterize "my_custom_layout". Check the import libraries mentioned here
String greenMaskResIdName
Name of the drawable resource to replace the default green mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in ROOT_PROJECT/android/app/src/main/res/drawable/my_custom_green_mask.png and parameterize "my_custom_green_mask".
String redMaskResIdName
Name of the drawable resource to replace the default red mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in ROOT_PROJECT/android/app/src/main/res/drawable/my_custom_red_mask.png and parameterize "my_custom_red_mask".
String whiteMaskResIdName
Name of the drawable resource to replace the default white mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in ROOT_PROJECT/android/app/src/main/res/drawable/my_custom_white_mask.png and parameterize "my_custom_white_mask".
SensorSettingsAndroid constructor
SensorStabilitySettingsAndroid sensorStabilitySettings
Orientation sensor settings to be applied in all SDK steps
SensorStabilitySettingsAndroid constructor
String messageResourceIdName
Name of the string resource to be shown when the phone is not stable. The default message is "Keep cell phone still". For example, if you want to show the String "Test", create a String in ROOT_PROJECT/android/app/src/main/res/values/strings.xml with the name R.string.my_custom_stability_string and value "Test" and parametrize "my_custom_stability_string".
int stabilityStabledMillis
How many milliseconds the mobile must stay at the correct threshold to be considered stable. The default is 2000 ms
double stabilityThreshold
Lower threshold between stable/unstable, in m/s² variation between the last two sensor collections. The default is 0.5 m/s².

iOS

FaceAuthenticatorIosSettings constructor
FaceAuthenticatorCustomizationIos customization
Customização visual do SDK
int beforePictureMillis
Duration in milliseconds between the first detection of the face and the actual capture of the picture
SensorStabilitySettingsIos sensorStability
Stability sensor settings to be applied in the SDK

FaceAuthenticatorCustomizationIos constructor
String colorHex
The SDK's theme color. For example, if you want to use the color black, use "#000000".
String greenMaskImageName
Name of the image to replace the default green mask. Remember to add the image in Assets Catalog Document in your XCode project
String whiteMaskImageName
Name of the image to replace the default white mask. Remember to add the image in Assets Catalog Document in your XCode project
String redMaskImageName
Name of the image to replace the default red mask. Remember to add the image in Assets Catalog Document in your XCode project
String closeImageName
Name of the image to replace the SDK's close button. Remember to add the image in Assets Catalog Document in your XCode project
bool showStepLabel
Flag indicating whether to show the label of the current step
bool showStatusLabel
Flag indicating whether to show the current status label

SensorStabilitySettingsAndroid constructor
String message
String to be shown when the cell phone is not stable
double stabilityThreshold
Lower threshold between stable/unstable, in m/s² variation between the last two sensor collections. The default is 0.3 m/s².

Collecting the result

The FaceAuthenticator return object is of abstract type FaceAuthenticatorResult. It can be an instance of FaceAuthenticatorSuccess, FaceAuthenticatorFailure, or FaceAuthenticatorClosed.

FaceAuthenticatorSuccess

Field
bool authenticated
Flag indicating whether the user has passed face authentication
String signedResponse
Signed response from the CAF server that confirmed the face authentication. Use this parameter if you want an extra layer of security by checking that the signature of the response is not broken, caused by an interception of the request. If it is broken, there is a strong indication of request interception
String trackingId
Identifier of this run on our servers. If possible, save this field and send it along to our API. This way we will have more data about how the user behaved during the execution
Will be null if the user sets useAnalytics = false or the analytics calls do not work

FaceAuthenticatorFailure

Field
String message
Friendly message explaining why the SDK failed
String type
Type of fault that shut down the SDK
The existing fault types are:
  • InvalidTokenReason: when the token entered is invalid. It should not occur in a production environment;
  • PermissionReason: when some mandatory permission was not granted by the user. It will only occur in a production environment if your app does not ask the user or the user manually disables it before starting;
  • NetworkReason: server connection failure. It will occur in production if the user's device is not connected to the Internet;
  • ServerReason: failure in some request to our servers;
  • SecurityReason: when the device is not safe to run the SDK;
  • StorageReason: when the device does not have enough space to capture a photo. This can happen in production;
  • LibraryReason: when some internal failure made it impossible to run the SDK. It may occur due to project configuration errors, and should not occur in production.
Last modified 2mo ago