# capacitor-luna-id-sdk

LUNA SDK is a face recognition and analysis system that provides efficient and accurate processing of faces in images and video streams, and can run on a wide variety of mobile operating systems.

## Install

```bash
npm install capacitor-luna-id-sdk
npx cap sync
```

## LICENCING & Configuration

1. Get `licence.conf` from VisionLabs
2. Configure Luna Platform 5 and get `LunaAccountID`
3. Configure `LunaServerURL`


## iOS

1. Add to  `./node_modules/capacitor-luna-id-sdk/ios/Frameworks/fsdk.framework/data/license.conf` your own `licence.conf` file;
2. Add to `Info.plist`
```bash
<key>LunaServerURL</key>
<string>https://[path-to-luna-platform-api]/6/</string>
```
```bash
<key>LunaAccountID</key>
<string><your luna account id></string>
```

## Android

Add to your project `android/app/src/main/assets/data/license.conf` license file


Add to your root project `local.properties`
```bash
DEFAULT_BASE_URL="https://[path-to-luna-platform-api]/6/"
DEFAULT_LUNA_ACCOUNT_ID="<your luna account id>"
vl.login=YOUR_LOGIN
vl.pass=YOUR_PASSWORD
```

## API

<docgen-index>

* [`initialize(...)`](#initialize)
* [`start(...)`](#start)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
* [Enums](#enums)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### initialize(...)

```typescript
initialize(options?: LunaOptions | undefined) => Promise<InitializeResponse>
```

Initialize plugin with configs

| Param         | Type                                                |
| ------------- | --------------------------------------------------- |
| **`options`** | <code><a href="#lunaoptions">LunaOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#initializeresponse">InitializeResponse</a>&gt;</code>

**Since:** 1.0.8

--------------------


### start(...)

```typescript
start(options?: StartOptions | undefined) => Promise<BestShot>
```

Start face recognition

| Param         | Type                                                  |
| ------------- | ----------------------------------------------------- |
| **`options`** | <code><a href="#startoptions">StartOptions</a></code> |

**Returns:** <code>Promise&lt;<a href="#bestshot">BestShot</a>&gt;</code>

**Since:** 1.0.0

--------------------


### Interfaces


#### InitializeResponse

| Prop               | Type                 | Description      | Since |
| ------------------ | -------------------- | ---------------- | ----- |
| **`initialized`**  | <code>boolean</code> | is initialized.  | 1.0.0 |
| **`initializing`** | <code>boolean</code> | is initializing. | 7.0.4 |


#### LunaOptions

| Prop                       | Type                                              |
| -------------------------- | ------------------------------------------------- |
| **`livenessEnabled`**      | <code>boolean</code>                              |
| **`occludeCheck`**         | <code>boolean</code>                              |
| **`trackFaceIdentity`**    | <code>boolean</code>                              |
| **`eyesCheck`**            | <code>boolean</code>                              |
| **`glassesCheckEnabled`**  | <code>boolean</code>                              |
| **`interactionEnabled`**   | <code>boolean</code>                              |
| **`interactionTimeout`**   | <code>number</code>                               |
| **`plistLicenseFileName`** | <code>string</code>                               |
| **`lunaConfig`**           | <code><a href="#lunaconfig">LunaConfig</a></code> |
| **`headers`**              | <code><a href="#headers">Headers</a></code>       |


#### LunaConfig

| Prop                          | Type                                                    | Description  | Since |
| ----------------------------- | ------------------------------------------------------- | ------------ | ----- |
| **`detectorStep`**            | <code>number</code>                                     |              |       |
| **`skipFrames`**              | <code>number</code>                                     |              |       |
| **`compressionQuality`**      | <code>number</code>                                     |              |       |
| **`minimalTrackLength`**      | <code>number</code>                                     |              |       |
| **`bestShotsCount`**          | <code>number</code>                                     | Android only | 5.0.0 |
| **`numberOfBestShots`**       | <code>number</code>                                     | ios only     | 5.0.0 |
| **`borderDistance`**          | <code>number</code>                                     |              |       |
| **`detectFrameSize`**         | <code>number</code>                                     |              |       |
| **`bestShotInterval`**        | <code>number</code>                                     |              |       |
| **`headPitch`**               | <code>number</code>                                     |              |       |
| **`headYaw`**                 | <code>number</code>                                     |              |       |
| **`headRoll`**                | <code>number</code>                                     |              |       |
| **`ags`**                     | <code>number</code>                                     |              |       |
| **`eyesCheck`**               | <code>boolean</code>                                    |              |       |
| **`locationEnabled`**         | <code>boolean</code>                                    | ios only     | 5.0.0 |
| **`interactionEnabled`**      | <code>boolean</code>                                    |              |       |
| **`interactionTimeout`**      | <code>number</code>                                     |              |       |
| **`uploadImagesForLiveness`** | <code>boolean</code>                                    |              |       |
| **`livenessErrorTimeout`**    | <code>number</code>                                     |              |       |
| **`livenessQuality`**         | <code>number</code>                                     |              |       |
| **`livenessType`**            | <code><a href="#livenesstype">LivenessType</a></code>   |              |       |
| **`licenseParams`**           | <code><a href="#licenseparams">LicenseParams</a></code> | android only | 5.3.0 |


#### LicenseParams

| Prop            | Type                |
| --------------- | ------------------- |
| **`server`**    | <code>string</code> |
| **`eId`**       | <code>string</code> |
| **`productId`** | <code>string</code> |


#### BestShot

| Prop               | Type                | Description                                                 | Since |
| ------------------ | ------------------- | ----------------------------------------------------------- | ----- |
| **`base64String`** | <code>string</code> | The base64 encoded string representation of found bestShot. | 1.0.0 |
| **`videoPath`**    | <code>string</code> | The URI of video recorded from stream.                      | 5.0.0 |


#### StartOptions

| Prop                         | Type                 | Description                                                                         | Default              | Since |
| ---------------------------- | -------------------- | ----------------------------------------------------------------------------------- | -------------------- | ----- |
| **`disableErrors`**          | <code>boolean</code> | Define whether to record video or not.                                              | <code>: false</code> | 5.0.1 |
| **`disableInteractionTips`** | <code>boolean</code> | Define whether to disable interaction Tips.                                         | <code>: false</code> | 5.0.1 |
| **`ignoreVideoWithoutFace`** | <code>boolean</code> | Define whether to start record video from camera activated or from face is deteced. | <code>: false</code> | 5.0.1 |
| **`interactionEnabled`**     | <code>boolean</code> | Define whether to enable interaction or not.                                        | <code>: true</code>  | 5.0.1 |
| **`interactionTimeoutMs`**   | <code>number</code>  | Define timeout for interaction.                                                     | <code>: 30000</code> | 5.0.1 |
| **`recordVideo`**            | <code>boolean</code> | Define whether to record video or not.                                              | <code>: false</code> | 5.0.0 |


### Type Aliases


#### Headers

<code><a href="#record">Record</a>&lt;string, string&gt; & <a href="#partial">Partial</a>&lt;<a href="#record">Record</a>&lt;<a href="#restrictedheaders">RestrictedHeaders</a>, never&gt;&gt;</code>


#### Record

Construct a type with a set of properties K of type T

<code>{ [P in K]: T; }</code>


#### Partial

Make all properties in T optional

<code>{ [P in keyof T]?: T[P]; }</code>


#### RestrictedHeaders

<code>'Authorization' | 'Luna-Account-Id'</code>


### Enums


#### LivenessType

| Members            |
| ------------------ |
| **`None`**         |
| **`ByDescriptor`** |
| **`ByPhoto`**      |

</docgen-api>
