Comment on page
FaceLiveness
To use Sdk, you can either remotely import the
.js
file or download it locally.Include the
.js
file directly from the CDN:<script src="https://repo.combateafraude.com/javascript/release/face-liveness/<VERSION>.zip" type="text/javascript"></script>
You can retrieve the class from the SDK using the following code:
const sdk = window['FacesSDK'];
The SDK has an isolated initialization method, to allow greater control over when it occurs.
During this process, the SDK will initialize its internal variables and download the resources it needs to run.
[!]You must call this method before using other SDK methods.
Parameter | Required? |
---|---|
Authentication token for consuming the SDK. | Yes. |
sdkContainer Id of the container where the SDK will be inserted. | Yes. |
useFaceAuthenticator Flag indicating whether to use FaceAuthenticator. | No. The default is false |
personId Document number used as a unique identifier for each user. | Yes. |
options.timeExpiresUrl Customizing the expiration time of the image Url returned by Sdk. | No. The default is 30 minutes, the accepted values are 3H or 30D . |
Image capture filter customization. | No. The default is shaded |
Language customization. | No. The default is pt_BR |
options.permissionButton.label Customize the camera permission button text. | No. |
options.permissionButton.color Customize the camera permission button text color. | No. |
options.permissionButton.backgroundColor Customize camera permission button background color. | No. |
options.permissionButton.borderRadius Customize camera permission button border radius. | No. |
options.permissionButton.border Customize camera permission button border. | No. |
options.startButton.label Customize sdk start button text. | No. |
options.startButton.color Customize sdk start button text color. | No. |
options.startButton.backgroundColor Customize sdk start button background color. | No. |
options.startButton.borderRadius Customize sdk start button border radius. | No. |
options.startButton.border Customize sdk start button border. | No. |
const options = {
timeExpiresrUrl: '30D',
settings: {
filter: 'classic',
language: 'pt_BR'
},
permissionButton: {
label: 'Permitir',
color: '#F9F9F9',
backgroundColor: '#39C560',
borderRadius: '10px',
border: '1px solid'
},
startButton: {
label: 'Escanear rosto',
color: '#F9F9F9',
backgroundColor: 'blue',
borderRadius: '0.25rem',
border: '1px solid #2D994B'
}
}
const facesSdk = await sdk.initializeSdk(token, sdkContainer, useFaceAuthenticator, personId, options);
Filter configuration for camera preview. It can be
classic
, shaded
(additional detail, the default), vibrant
(full color), clear
(no filter) and blur
(starts blurred).Through the
language
parameter, the application language can be changed, the default value is pt_BR
, check the availability below:Parameter | Language |
cy_GB | Welsh. |
de | German. |
en | English. |
es | Spanish. |
fr | French. |
it | Italian. |
nl | Dutch. |
pt_BR | Portuguese. |
To perform integration through an iframe, camera and fullscreen permissions must be provided.
<iframe
src="https://caf.example"
allow="camera;fullscreen;accelerometer;gyroscope;magnetometer;"
></iframe>
To use the SDK through a Webview, camera permission must be granted in your native application.
Example implementation on Android.
AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
MainActivity
@Override
public void onPermissionRequest(final PermissionRequest request) {
request.grant(request.getResources());
}
On IOS, camera and notion permissions must be granted with
NSCameraUsageDescription
and NSMotionUsageDescription
according to the example project.The method used to load the SDK onto the screen and perform selfie capture.
It will initialize the video stream (requesting permissions if needed) and load it into the container.
await facesSdk.execute();
Field | Type | Description |
signedResponse | string | Signed response from the CAF server confirming that the captured selfie has a real face. This parameter is used to get an extra layer of security, checking that the signature of the response is not broken, or caused by request interception. If it is broken, there is a strong indication of request interception. |
{
"signedResponse": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyZXF1ZXN0SWQiOiIyY2QwMTkxZS1jNzc0LTRjZWEtYjliNC1hOGJhYjRiODEzNGQiLCJpc0FsaXZlIjp0cnVlLCJ0b2tlbiI6ImYyOWFhNmM0YjczMmYyYWNhZTJjOGMxZWYxZDUyN2FhMDY0ZTI1YTg1OWMyNWU2MzZhMzQ0MTAzMTgwMXZ1MDEiLCJ1c2VySWQiOiJlZmI1NTg5NS1lMmY0LTRkMjQtOGE4OS04NGI0Nzg3ZjViM2EiLCJpbWFnZVVybCI6ImltYWdlVXJsIiwicGVyc29uSWQiOiJwZXJzb25JZCIsInNka1ZlcnNpb24iOiIxLjAuNCIsImF0dGVtcHRJZCI6IjY1M2ZmYjg2ZmViZTZhMzJiZWMyOWM1ZSIsImlhdCI6MTY5ODY5MTk3NH0.BKCtQUbPRBMchHX30_fqf6vSWVN__K4nsOecKLoybGs"
}
Event | Description |
requestId | Request identifier. |
isAlive | Validation of a living person, identifies whether the user passed successfully or not. |
token | Request token. |
userId | User identifier provided for the request. |
imageUrl | Temporary link to the image, generated by our API. |
personId | User identifier provided for the SDK. |
sdkVersion | Sdk version in use. |
iat | Token expiration. ` |
The isAlive parameter is VERY IMPORTANT, based on it validation must be carried out to continue with the flow or not, in case of
isAlive: true
, your user is able to continue with the journey, in case of isAlive: false
, this user is not is valid and should be barred from the remainder of the journey.Currently the SDK emits three types of events:
Event | Description |
started | Capture stream initialization. |
sdk-button-ready | SDK components have been loaded and ready to use. |
passed | Image capture was successful. |
failed | Image capture failed. |
error | An error occurred during the capture process. |
streaming | streaming started, full screen start. |
streamed | End of streaming, closing full screen. |
cancelled | Capture flow cancellation. |
permission | Camera permission is requested. |
permission_denied | Camera permission was denied. |
unsupported | Browser does not support Sdk. |
Last modified 3d ago