Getting started

Remote

Include the .js file directly from the CDN:

<script src="https://repo.combateafraude.com/identity/<VERSION>/index.umd.js" type="text/javascript">
</script>

Current versions

Utilization

Creating an SDK instance

The SDK's constructor method takes the Identity token as a parameter (see how to get yours here). In addition, you can optionally enter the SDK's initialization options.

Example using import via CDN:

<script src="https://repo.combateafraude.com/identity/<VERSION>/index.umd.js" type="text/javascript">
</script>

[...]

<script>
    const identityToken = 'your token';
    const identity = new this['@combateafraude/identity-sdk'].Sdk(identityToken);
</script>

Options parameters:

*You must inform mobileToken when you are using facial authentication in your policy

Theme parameters:

Label parameters:

pendingPageSettings parameters:

faceLivenessSettings parameters:

styles parameters:

Exemple:

const identityOptions = {
mobileToken: 'seu token mobile',
throwOnRecall: true,
theme: {
    closeButton: '#000037',
    pendingIconSvg:'./example.svg'
},
smsLabel: {
    enable: true,
    link: "https://www.google.com/",
    text: "Its just a test SMS",
},
language: "string",
pendingPageSettings: {
        pendingIconSvg?: "",
        titleText?: "Não foi possível realizar a autenticação",
        descriptionText?: "Para sua segurança, entre em contato com o suporte para prosseguir",
        buttonContentText?: "Finalizar"
    },
faceLivenessSettings: {
      startButton:{
        label: 'Tirar foto',
        color: "white",// accept hex value too,
        backgroundColor: "#000037",
        border: '1px solid #000037'
      },
      permissionButton:{
        label: 'habilitar câmera',
        color: "white",// accept hex value too,
        backgroundColor: "#000037",
        border: '1px solid #000037'
      }
},
enableTimer: true,
authIcon:  (new Image().src = "./exemple-sdk.png"),
metadata: "{\"teste\":{\"dados\":{\"name\":\"JohnDoe\",\"personId\":\"999.999.999.99\",}}}",
};

const identityToken = 'seu token';

const identity = new IdentitySdk(identityToken, identityOptions);

Calling the SDK:

To verify a user, use the verifyPolicy method, available in the SDK instance.

You must enter the user's CPF and the policy ID to be used.

const cpf = 'User CPF';
const policyId = 'Policy ID'

const response = await identity.verifyPolicy(cpf, policyId);

if(identity.isSdkError(response)) {
    // Error when running the SDK
}
else {
    const { isAuthorized, attestation } = response;
    
    if(isAuthorized) {
        // User is authorized
        // Send the attestation to your backend and validate it there
    }
    else {
        // User is not authorized
    }
}

Last updated

Logo

2023 © Caf. - All rights reserved