capacitor-luna-id-sdk
v7.3.1
Published
LUNA SDK is a face recognition and analysis system that provides efficient and accurate processing of faces in images and video streams
Readme
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
npm install capacitor-luna-id-sdk
npx cap syncRequirements
| Plugin | LUNA ID (iOS / Android) | iOS | Android | | ------ | ----------------------- | ---- | ----------------------- | | 7.3.x | 1.23.0 / 1.23.0 | 15.0+ | 6.0+ (API 23) | | 7.2.x | 1.22.0 / 1.22.1 | 15.0+ | 6.0+ (API 23) |
Android 6–7 (API 23–25): VisionLabs documentation lists Android 8.0 (API 26) as the minimum for LUNA ID 1.23.0, but the SDK itself declares
minSdkVersion 23. The plugin keepsminSdk 23; test on Android 6–7 devices before release.
LICENCING & Configuration
- Get
licence.conffrom VisionLabs - Configure Luna Platform 5 and get
LunaAccountID - Configure
LunaServerURL
iOS
- Add to
./node_modules/capacitor-luna-id-sdk/ios/Frameworks/fsdk.framework/data/license.confyour ownlicence.conffile; - Add to
Info.plist
<key>LunaServerURL</key>
<string>https://[path-to-luna-platform-api]/6/</string><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
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_PASSWORDSecurity check errors
When the device fails the security check, start() is rejected with extra data in error.data
(see StartErrorData):
import type { StartErrorData } from 'capacitor-luna-id-sdk';
try {
await LunaSDK.start();
} catch (e: any) {
const data = e.data as StartErrorData | undefined;
if (data?.reasons) {
// Android: e.code === 'SECURITY', reasons: ROOT | VIRTUAL_CAMERA | CLOUD_PHONE | DESKTOP_EMULATOR | OTHER
// iOS: e.code === 'ERROR' (jailbroken device), reasons: ['ROOT']
console.log(data.primaryReason, data.reasons);
}
}Orientation error (iOS)
On iOS the capture is interrupted when the device orientation changes during the session
(for example, the phone is put flat on a table screen up). start() is then rejected with
e.code === 'ORIENTATION' and e.data.orientation (FACE_UP, FACE_DOWN, LANDSCAPE_LEFT, …).
Ask the user to hold the phone upright and call start() again. Android never returns this code.
try {
await LunaSDK.start();
} catch (e: any) {
if (e.code === 'ORIENTATION') {
// e.data.orientation: 'FACE_UP' | 'FACE_DOWN' | 'LANDSCAPE_LEFT' | ...
showHint('Держите телефон вертикально');
}
}API
initialize(...)
initialize(options?: LunaOptions | undefined) => Promise<InitializeResponse>Initialize plugin with configs
| Param | Type |
| ------------- | --------------------------------------------------- |
| options | LunaOptions |
Returns: Promise<InitializeResponse>
Since: 1.0.8
start(...)
start(options?: StartOptions | undefined) => Promise<BestShot>Start face recognition
| Param | Type |
| ------------- | ----------------------------------------------------- |
| options | StartOptions |
Returns: Promise<BestShot>
Since: 1.0.0
Interfaces
InitializeResponse
| Prop | Type | Description | Since |
| ------------------ | -------------------- | ---------------- | ----- |
| initialized | boolean | is initialized. | 1.0.0 |
| initializing | boolean | is initializing. | 7.0.4 |
LunaOptions
| Prop | Type | Description | Default | Since |
| -------------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
| livenessEnabled | boolean | | | |
| occludeCheck | boolean | | | |
| trackFaceIdentity | boolean | | | |
| eyesCheck | boolean | | | |
| glassesCheckEnabled | boolean | | | |
| interactionEnabled | boolean | | | |
| interactionTimeout | number | | | |
| plistLicenseFileName | string | | | |
| debugLogs | boolean | iOS only. Verbose LUNA ID SDK logs (LunaCore debug + low-level fsdk logs) in the Xcode console. Without it only SDK errors are logged. | false | 7.3.0 |
| security | SecurityOptions | Android only. Security check settings (LUNA ID Security feature). Applied on the first successful initialize() call. Not set — SDK defaults (LEGACY mode). | | 7.3.1 |
| lunaConfig | LunaConfig | | | |
| headers | Headers | | | |
SecurityOptions
Android only. Mirrors LUNA ID Security(...). Every field is optional — SDK default when omitted.
| Prop | Type | Description | Default |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| scoringMode | SecurityScoringMode | | 'LEGACY' |
| scoreThreshold | number | Score that blocks the session in BLOCKING mode. | 100 |
| blockOnReasons | SecurityReason[] | Reasons that may block the session. Default — all reasons. | |
| signalWeightOverrides | Record<number, SecurityWeightClass> | Override weights of individual signals by code (score.signals[].code), e.g. { 34: 'IGNORED' } — ignore missing sensors. | |
| allowBestShotOnFailure | boolean | Do not interrupt capture on a failed check (the result is still reported). | |
| blockUntrustedInstaller | boolean | Block when the app was installed not from a trusted store. | |
LunaConfig
| Prop | Type | Description | Since |
| ----------------------------- | ------------------------------------------------------- | ------------ | ----- |
| detectorStep | number | | |
| skipFrames | number | | |
| compressionQuality | number | | |
| minimalTrackLength | number | | |
| bestShotsCount | number | Android only | 5.0.0 |
| numberOfBestShots | number | ios only | 5.0.0 |
| borderDistance | number | | |
| detectFrameSize | number | | |
| bestShotInterval | number | | |
| headPitch | number | | |
| headYaw | number | | |
| headRoll | number | | |
| ags | number | | |
| eyesCheck | boolean | | |
| locationEnabled | boolean | ios only | 5.0.0 |
| interactionEnabled | boolean | | |
| interactionTimeout | number | | |
| uploadImagesForLiveness | boolean | | |
| livenessErrorTimeout | number | | |
| livenessQuality | number | | |
| livenessType | LivenessType | | |
| licenseParams | LicenseParams | android only | 5.3.0 |
LicenseParams
| Prop | Type |
| --------------- | ------------------- |
| server | string |
| eId | string |
| productId | string |
BestShot
| Prop | Type | Description | Since |
| ------------------ | ------------------- | ----------------------------------------------------------- | ----- |
| base64String | string | The base64 encoded string representation of found bestShot. | 1.0.0 |
| videoPath | string | The URI of video recorded from stream. | 5.0.0 |
StartOptions
| Prop | Type | Description | Default | Since |
| ---------------------------- | -------------------- | ----------------------------------------------------------------------------------- | -------------------- | ----- |
| disableErrors | boolean | Define whether to record video or not. | : false | 5.0.1 |
| disableInteractionTips | boolean | Define whether to disable interaction Tips. | : false | 5.0.1 |
| ignoreVideoWithoutFace | boolean | Define whether to start record video from camera activated or from face is deteced. | : false | 5.0.1 |
| interactionEnabled | boolean | Define whether to enable interaction or not. | : true | 5.0.1 |
| interactionTimeoutMs | number | Define timeout for interaction. | : 30000 | 5.0.1 |
| recordVideo | boolean | Define whether to record video or not. | : false | 5.0.0 |
Type Aliases
SecurityScoringMode
How the security check decides to block the session.
LEGACY(SDK default) — any fired signal blocks (hard OR, pre-1.23 behavior).BLOCKING— blocks when the score reachesscoreThreshold(or a STRONG signal fired).REPORT_ONLY— never blocks, only computes the score (shadow rollout).
'LEGACY' | 'BLOCKING' | 'REPORT_ONLY'
SecurityReason
Reason why the device failed the security check.
'ROOT' | 'CLOUD_PHONE' | 'DESKTOP_EMULATOR' | 'VIRTUAL_CAMERA' | 'OTHER'
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
SecurityWeightClass
Signal weight: IGNORED = 0, WEAK = 25, MEDIUM = 50, STRONG = 100 points.
'IGNORED' | 'WEAK' | 'MEDIUM' | 'STRONG'
Headers
Record<string, string> & Partial<Record<RestrictedHeaders, never>>
Partial
Make all properties in T optional
{ [P in keyof T]?: T[P]; }
RestrictedHeaders
'Authorization' | 'Luna-Account-Id'
Enums
LivenessType
| Members |
| ------------------ |
| None |
| ByDescriptor |
| ByPhoto |
