Using SDK
Instantiation Example
import IdentityValidation from '@paag-io/sdk-identity-validation';
const identityValidation = new IdentityValidation({
host: 'https://your-host-of-validation.com',
token: 'your-token',
// target: document.querySelector('#target-element'), // Opcional
});
Available Methods
makeFullIdentityValidation(cpf)
Initiates the full identity validation process, including OCR, Liveness and Facematch.
Parameters:
- cpf (Optional): The user's CPF (Brazilian Individual Taxpayer Registry identification number). If provided, the user will not need to input it manually.
Usage Examples Full Validation with CPF:
Full Validation without CPF:
makeFacematchValidation(cpf, imageDocument)
Initiates the Liveness and Facematch validation process.
Parameters:
- cpf (Required): The user's CPF.
- imageDocument (Optional): The document image in base64 format.
Note: If the imageDocument parameter is not provided, the SDK will try to find the last document image uploaded by the user. If there is no image, the validation will fail.
Usage Examples Facematch Validation with Image Document:
Facematch Validation without Image Document:
Event Handling
The IdentityValidation class emits events that can be used to enhance user experience and handle different scenarios.
Supported Events
- success: Triggered when the validation is successful.
- fail: Triggered when the validation fails.
- close: Triggered when the user closes the iframe.
Event Handling Example
import IdentityValidation from '@paag-io/sdk-identity-validation';
const identityValidation = new IdentityValidation({
host: 'https://url.com',
token: 'your-token',
// target: document.querySelector('#target'), // Optional
});
identityValidation.on('success', () => {
console.log('with success');
});
identityValidation.on('fail', () => {
console.log('with fail');
});
identityValidation.on('close', () => {
console.log('with close');
});
Additional Notes
- CPF: "Cadastro de Pessoas Físicas," Brazilian individual taxpayer identification number.
- OCR: Optical Character Recognition, technology to extract text from images.
- Facematch: Facial comparison between the selfie and the document photo.
- Liveness Detection: Verification to ensure that the selfie was taken live and is not a static image.