> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-sdk/web-javascript/getting-started/passivefaceliveness.md).

# PassiveFaceLiveness (Deprecated)

## **Importing SDK** <a href="#ec6hruocgdfc" id="ec6hruocgdfc"></a>

To use PassiveFaceLiveness, you can either remotely import the `.js` file or download it locally.

## **Remotely** <a href="#vbdis2v796qu" id="vbdis2v796qu"></a>

Include the `.js` file directly from the CDN:

```html
<script
  src="https://repo.combateafraude.com/javascript/release/passive-face-liveness/<VERSION>.umd.js"
  type="text/javascript"
></script>
```

You can retrieve the class from the SDK using the following code:

```javascript
const { PassiveFaceLivenessSdk } =
  window["@combateafraude/passive-face-liveness"];
```

## **Locally** <a href="#tt8trg6eu4c" id="tt8trg6eu4c"></a>

Download the `.js` file and import it as an ES6 module:

```javascript
import { PassiveFaceLivenessSdk } from "../assets/js/passive-face-liveness-<VERSION>.js";
```

## **Construction** <a href="#qucx2l4rkel" id="qucx2l4rkel"></a>

In the builder, the SDK receives a single parameter with the settings:

```javascript
const sdk = new PassiveFaceLivenessSdk(options);
```

## Supported Parameters <a href="#m3han9t9fipv" id="m3han9t9fipv"></a>

| Parameter                                                                                                                                                                                                                           | Required?                                                                                |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| <p><a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/web-javascript/getting-started/broken-reference/README.md"><strong><code>token</code></strong></a></p><p>Authentication token for consuming the SDK.</p>   | Yes.                                                                                     |
| <p><strong><code>language</code></strong></p><p>Default message language, valid values: en\_US, en\_BR, es\_MX.</p>                                                                                                                 | No. The default is **`pt_BR`**                                                           |
| <p><strong><code>environmentSettings.disableDesktopExecution</code></strong></p><p>Flag indicating whether execution on desktops should be blocked.</p>                                                                             | No. The default is **`false`**                                                           |
| <p><strong><code>environmentSettings.disableVisibilityChangeSecurity</code></strong></p><p>Disables the security enhancement responsible for closing the SDK when the user switches browser tabs.</p>                               | No. The default is **`false`**                                                           |
| <p><strong><code>environmentSettings.disableFaceDetectionSecurity</code></strong></p><p>Disables the security enhancement responsible for closing the SDK when the user moves the face away from the mask in automatic capture.</p> | No. The default is **`false`**                                                           |
| <p><strong><code>capturerSettings.disableAdvancedCapturing</code></strong></p><p>Flag indicating whether advanced capture should be disabled\*.</p>                                                                                 | No. The default is **`false`**                                                           |
| <p><strong><code>capturerSettings.disableVideoCapturing</code></strong></p><p>Flag indicating whether video capture should be disabled\*.</p>                                                                                       | No. The default is **`false`**                                                           |
| <p><strong><code>appearenceSettings.hideSwitchCameraButton</code></strong></p><p>hide the switch camera button.</p>                                                                                                                 | No                                                                                       |
| <p><strong><code>appearenceSettings.captureButtonIcon</code></strong></p><p>Customization of the capture icon accepts values such as image URL or base64 of SVGs.</p>                                                               | No                                                                                       |
| <p><strong><code>appearenceSettings.captureIconSize</code></strong></p><p>Customization of the icon size for the captureButtonIcon field</p>                                                                                        | No                                                                                       |
| <p><strong><code>appearenceSettings.captureButtonColor</code></strong></p><p>Customization of the default image capture button color.</p>                                                                                           | No                                                                                       |
| <p><strong><code>appearenceSettings.switchButtonIcon</code></strong></p><p>Customization of the camera switch icon accepts values such as image URL or base64 from SVGs.</p>                                                        | No                                                                                       |
| <p><strong><code>appearenceSettings.switchIconSize</code></strong></p><p>Customization of the icon size for the switchButtonIcon field.</p>                                                                                         | No                                                                                       |
| <p><strong><code>appearenceSettings.switchIconColor</code></strong></p><p>Customization of the color of the default camera switching icon.</p>                                                                                      | No                                                                                       |
| <p><strong><code>appearenceSettings.fontFamily</code></strong></p><p>Changes the font for all elements contained in the SDK.</p>                                                                                                    | No. The pattern is inherited from the page                                               |
| <p><strong><code>textSettings.messages.processMessage</code></strong></p><p>Customization of the image processing message.</p>                                                                                                      | No. The default is `"Processando sua foto, aguarde um momento"`                          |
| <p><strong><code>textSettings.messages.isNotAliveMessage</code></strong></p><p>Customization of the message when the isAlive parameter returns as false.</p>                                                                        | No. The default is `"Não conseguimos capturar seu rosto :( Por favor, tente novamente."` |
| <p><strong><code>textSettings.messages.captureFailedMessage</code></strong></p><p>Customization of the capture failure message.</p>                                                                                                 | No. The default is `"Ops! Tivemos um problema ao processar sua imagem."`                 |

\* Advanced capture consists of using more complex and not-so-stable APIs in browsers that support them (e.g. [ImageCapture](https://developer.mozilla.org/pt-BR/docs/Web/API/ImageCapture))

### **Example** <a href="#lul8krq92ug" id="lul8krq92ug"></a>

```javascript
const sdk = new PassiveFaceLivenessSdk({
  token: `my-sdk-token`,

  analyticsSettings: {
    disableAnalytics: false,
    trackingId: "",
    trackingInfo: "",
  },

  environmentSettings: {
    disableDesktopExecution: false,
    disableVisibilityChangeSecurity: true,
    disableFaceDetectionSecurity: true,
  },

  capturerSettings: {
    disableAdvancedCapturing: true,
    disableVideoCapturing: true,
  },

  appearenceSettings: {
    captureButtonIcon: "",
    captureIconSize: "",
    captureButtonColor: "",
    switchButtonIcon: "",
    switchIconSize: "",
    switchIconColor: "",
    fontFamily: "",
  },

  textSettings: {
    title: "",
    messages: {
      processMessage: "",
      isNotAliveMessage: "",
      captureFailedMessage: "",
    },
  },
});
```

### **CaptureStage** <a href="#id-92kmg2xacqxa" id="id-92kmg2xacqxa"></a>

CaptureStage allows the client to configure the stages. To do this, we offer the CaptureStage object, where you can set the following parameters:

| **Parameter**                                                                                                                                                                                                                                                                                                        |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>mode</code></strong></p><p>Desired capture mode. It can be used <code>manually</code> or <code>automatically</code>. In the manual capture, a button will be enabled for the user to perform the capture.</p>                                                                                       |
| <p><strong><code>attempts</code></strong></p><p>The number of attempts of the current stage. If it is the only stage, the value <code>0</code> must be passed.</p>                                                                                                                                                   |
| <p><strong><code>duration</code></strong></p><p>Duration time of the current stage. If more than one stage is set, the total time for each stage can be set, and when the total time is reached, the stage will move on to the next one. Set it to <code>0</code> if you don't want to set a time for the stage.</p> |

### **Example CaptureStage**

```javascript
const stages = [
  { mode: "automatic", attempts: 3, duration: 60 },
  { mode: "manual", attempts: 0, duration: 0 },
];
```

***

Objects are defined for each stage, according to an example, the SDK will start with the automatic capture, where there will be 3 capture attempts or a time limit of 60 seconds for each attempt, after exceeding the time or attempts, the SDK will automatically move on to the next stage, where the manual capture will be performed without time or attempt limits, so the user can perform as many attempts as he/she wants without time limits.

### **Limit SDK attempts** <a href="#q9gx4v6b5jyt" id="q9gx4v6b5jyt"></a>

Through the `totalAttempts` parameter you can set the total number of attempts to run the SDK, after reaching the limit value the SDK will automatically terminate.

#### **Example totalAttempts**

```javascript
await sdk.capture(sdkContainer, stages, { personData, totalAttempts: 3 });
```

***

### **Initialization** <a href="#e8bl0o5hv2i4" id="e8bl0o5hv2i4"></a>

### `initialize(): Promise<void>` <a href="#tdlbz5hosfd" id="tdlbz5hosfd"></a>

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.

\[!]Initializing the SDK can take a few seconds. We recommend that you call this function as early as possible in your flow so that opening the SDK is smooth for the user.

#### **Example** <a href="#j4h8eo4ng95u" id="j4h8eo4ng95u"></a>

```javascript
await sdk.initialize();
```

### **Utilization** <a href="#id-1zo6vxxf782" id="id-1zo6vxxf782"></a>

## **Opening and taking selfies** <a href="#s3y7w2l7a01m" id="s3y7w2l7a01m"></a>

### `capture(container: HTMLElement, stages, {personData?: LivenessPersonData, totalAttempts?: Number}): Promise<Result>` <a href="#id-1l7spulz52hu" id="id-1l7spulz52hu"></a>

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.

#### &#x20;<a href="#id-6um1unzdgbz4" id="id-6um1unzdgbz4"></a>

### Parameters <a href="#id-1g9l1uslwr9z" id="id-1g9l1uslwr9z"></a>

| **Parameter**                                                                                                                        | **Type** |
| ------------------------------------------------------------------------------------------------------------------------------------ | -------- |
| <p><strong><code>personData.cpf</code></strong></p><p>This variable has been deprecated, use personId</p>                            | `string` |
| <p><strong><code>personData.name</code></strong></p><p>Name of the user doing the authentication (optional).</p>                     | `string` |
| <p><strong><code>personData.personId</code></strong></p><p>Document number used as a unique identifier for each user (optional).</p> | `string` |

¹ If not specified, automatic capture is used.

² If not specified, a default value of 30 seconds is used.

### **Example** <a href="#rb9d2o76lxbw" id="rb9d2o76lxbw"></a>

```javascript
// div or another element on DOM
const sdkContainer = document.getElementById("sdk-displayer");
const personData = { personId: "user-identifier", name: "user-name" };
await sdk.capture(sdkContainer, stages, { personData, totalAttempts });
```

### **Return** <a href="#exv8broymq71" id="exv8broymq71"></a>

The return consists of an object with the following fields:

| **Field**  | **Type** | **Description**                                   |
| ---------- | -------- | ------------------------------------------------- |
| `imageUrl` | `string` | Temporary link to the image, generated by our API |
| `imageKey` | `string` | Object key                                        |
| `blob`     | `Blob`   | Blob of the captured image                        |

### **Example** <a href="#li5quwhp57l9" id="li5quwhp57l9"></a>

```javascript
const result = await sdk.capture(sdkContainer, stages, {
  personData,
  totalAttempts,
});
// { imageUrl: '[link da imagem]', imageKey: '[key da imagem]', blob: Blob
```

***

## **Close SDK** <a href="#id-8euaozxxp6bw" id="id-8euaozxxp6bw"></a>

### `close(): Promise<void>` <a href="#nj8efubqe3g2" id="nj8efubqe3g2"></a>

The method used to remove the SDK on the canvas, removing the SDK's visual elements from the DOM.

## **De-initialize the SDK** <a href="#otwhtgpzdv3a" id="otwhtgpzdv3a"></a>

### `dispose(): Promise<void>` <a href="#yuh6kpn5iwwq" id="yuh6kpn5iwwq"></a>

The method used to remove the SDK on the screen.

Will de-initialize the video *stream* and clear the SDK's internal variables

### **Complete Example** <a href="#sunlk9v2ojm3" id="sunlk9v2ojm3"></a>

Soon.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-sdk/web-javascript/getting-started/passivefaceliveness.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
