Ask or search…
K
Links

FaceAuthenticator (Deprecated)

Plugin that calls native SDKs in Android and iOS. If you have any questions, please send an email to our Head of Mobile

Settings

Android
iOS
Ionic
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
}
}
Import the package and call the add() method inside the initialization in android/app/src/main/java/io/ionic/starter/MainActivity.java:
import com.authenticator.FaceAuthenticatorPlugin;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerPlugin(FaceAuthenticatorPlugin.class);
}
}
In the file ROOT_PROJECT/ios/App/Podfile, add to the end of the file:
source 'https://github.com/combateafraude/iOS.git'
source 'https://cdn.cocoapods.org/' # ou 'https://github.com/CocoaPods/Specs' se o CDN estiver fora do ar
Finally, add the camera permission to the file ROOT_PROJECT/ios/App/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>To read the documents</string>
Add the plugin to your file ROOT_PROJECT/package.json:
"dependencies": {
"face-authenticator-plugin": "https://github.com/combateafraude/Ionic/archive/refs/tags/face-authenticator-v2.7.0.tar.gz"
}
After, run:
npm install
ionic capacitor build < platform > [ options ]

Importing

import { FaceAuthenticator } from "face-authenticator-plugin";

Using

let faceAuthenticator = await new FaceAuthenticator();
faceAuthenticator.setMobileToken = "<mobile token>";
faceAuthenticator.setPeopleId = "<cpf>";
//Enable video capture
let captureMode = new CaptureMode({
videoCapture: new VideoCapture({ use: true, time: 3 }),
});
faceAuthenticator.setCaptureMode = captureMode;
const response = await faceAuthenticator.start();
if (response.result == "SUCCESS") {
// Success. Check response.isAuthenticated and response.signedResponse
} else if (response.result == "FAILURE") {
// Fault. Check reponse.type and response.message
} else {
// User closed the screen.
}

General customizations

FaceAuthenticator
.setPeopleId(String peopleId)
CPF of the user who is using the plugin to be used for fraud detection via analytics
.setAnalyticsSettings(bool useAnalytics)
Enables/disables data collection for maximizing anti-fraud information. Default is true.
.enableSound(bool enable)
Enables/disables sounds. Default is true.
.setNetworkSettings(int requestTimeout)
Change the default network settings. The default is 60 seconds
.setAndroidSettings(AndroidSettings androidSettings)
Customizations only applied on Android
.setIosSettings(IosSettings iosSettings)
customizations only applied on iOS
.setCaptureMode(CaptureMode captureMode)
Define the capture settings
CaptureMode
videoCapture: VideoCapture(use: boolean, time: number)
Configura a captura por vídeo
imageCapture: ImageCapture(use: boolean, beforePictureMillis: number, afterPictureMillis: number)
Configura a captura por foto
Example of use
let imageCapture = new ImageCapture({ use: true });
let captureMode = new CaptureMode({ imageCapture: imageCapture });
faceAuthenticator.setCaptureMode = captureMode;

Getting the result

The FaceAuthenticator return object will have the result attribute that contains a string SUCCESS, FAILURE or CLOSED. The return will default to PassiveFaceLivenessSuccess, PassiveFaceLivenessFailure, and PassiveFaceLivenessClosed, respectively, for each of the cases.

FaceAuthenticatorSuccess

Field
Description
Boolean isAuthenticated
Full address of the image on the device
String signedResponse
Signed response from the CAF server which confirmed that the captured selfie has a real face (not a photo or video). 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 intercepted request. If it is broken, there is a strong indication of request interception
String trackingId
Identifier of this execution on our servers. If possible, save this field and send it along to our API. This way we will have more data on 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
Fault type that shut down the SDK
Os tipos de falha existentes são:
Field
Description
InvalidTokenReason
When the token entered is invalid. Should not occur in a production environment.
PermissionReason
some mandatory permission was not granted by the user. It will only happen in a production environment if your app does not ask your user or the user manually disables it before starting.
NetworkReason
Server connection failure. Will occur in production if the user's device is without internet.
ServerReason
Failure in some request with our servers. It will occur in production only in case of our failure.
SecurityReason
When the device is not safe to run the SDK. If this failure occurs, let us know.
StorageReason
When the device does not have enough space for capturing some of the photos. Can occur in production.
LibraryReason
some internal failure made it impossible to run the SDK. It may occur due to project configuration errors, it should not occur in production.

FaceAuthenticatorClosed

Empty object indicating closure of the capture screen by the user.
Last modified 7mo ago