@regulaforensics/vp-frontend-face-components 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +292 -29
- package/dist/main.js +1 -1
- package/dist/main.js.LICENSE.txt +42 -0
- package/lib/common/BackCameraIcon.d.ts +6 -0
- package/lib/common/Button.d.ts +7 -0
- package/lib/common/CameraChangeIcon.d.ts +6 -0
- package/lib/common/CameraIcon.d.ts +6 -0
- package/lib/common/CheckIcon.d.ts +6 -0
- package/lib/common/CrossIcon.d.ts +6 -0
- package/lib/common/DocReaderCameraDisabled.d.ts +5 -0
- package/lib/common/DocReaderCameraPreparing.d.ts +5 -0
- package/lib/common/DocReaderFlip.d.ts +5 -0
- package/lib/common/DocReaderProcessing.d.ts +5 -0
- package/lib/common/DocReaderProcessingError.d.ts +5 -0
- package/lib/common/DocReaderProcessingFinished.d.ts +6 -0
- package/lib/common/DocReaderSearch.d.ts +5 -0
- package/lib/common/ErrorIcon.d.ts +6 -0
- package/lib/common/FromCameraIcon.d.ts +5 -0
- package/lib/common/FromGalleryIcon.d.ts +5 -0
- package/lib/common/FrontCameraIcon.d.ts +6 -0
- package/lib/common/FullscreenExitIcon.d.ts +6 -0
- package/lib/common/FullscreenIcon.d.ts +6 -0
- package/lib/common/Icon.d.ts +7 -0
- package/lib/common/InstructionIconFaceDetection.d.ts +5 -0
- package/lib/common/InstructionIconFaceLiveness.d.ts +5 -0
- package/lib/common/Message.d.ts +7 -0
- package/lib/common/NoGlareIcon.d.ts +5 -0
- package/lib/common/NoSmilingIcon.d.ts +5 -0
- package/lib/common/RegulaLogo.d.ts +6 -0
- package/lib/common/SnapshotIcon.d.ts +6 -0
- package/lib/common/Spinner.d.ts +3 -0
- package/lib/common/SquareIcon.d.ts +6 -0
- package/lib/common/StopIcon.d.ts +6 -0
- package/lib/common/VerifiedIcon.d.ts +6 -0
- package/lib/components/ErrorBoundary.d.ts +17 -0
- package/lib/components/FaceCapture.d.ts +17 -0
- package/lib/components/FaceDetection.d.ts +2 -0
- package/lib/components/FaceFullScreenOverlay.d.ts +11 -0
- package/lib/components/FaceLayout.d.ts +19 -0
- package/lib/components/FaceLiveness.d.ts +2 -0
- package/lib/components/InfoScreen.d.ts +10 -0
- package/lib/components/InstructionScreen.d.ts +9 -0
- package/lib/components/ProcessScreen.d.ts +6 -0
- package/lib/components/RetryScreen.d.ts +7 -0
- package/lib/components/WebCamera.d.ts +20 -0
- package/lib/constants.d.ts +366 -0
- package/lib/contexts/FaceAttributesContext.d.ts +24 -0
- package/lib/hoc/withFaceAttributesContext.d.ts +4 -0
- package/lib/hoc/withLocalize.d.ts +7 -0
- package/lib/hooks/useDebounce.d.ts +2 -0
- package/lib/hooks/useFaceLiveness.d.ts +33 -0
- package/lib/hooks/useInterval.d.ts +3 -0
- package/lib/hooks/useOrientationChange.d.ts +10 -0
- package/lib/hooks/useStream.d.ts +16 -0
- package/lib/hooks/useUserAgent.d.ts +3 -0
- package/lib/hooks/useWindowBlur.d.ts +2 -0
- package/lib/i18n/dictionaries/_dictionaries.d.ts +2051 -0
- package/lib/index-face.d.ts +1 -0
- package/lib/models/CameraModel.d.ts +9 -0
- package/lib/models/ImageModel.d.ts +7 -0
- package/lib/services/DebugService.d.ts +13 -0
- package/lib/services/DocumentReaderService.d.ts +39 -0
- package/lib/services/EventEmitter.d.ts +9 -0
- package/lib/services/FaceLivenessService.d.ts +46 -0
- package/lib/services/FaceService.d.ts +11 -0
- package/lib/services/WasmFeatureDetectService.d.ts +4 -0
- package/lib/types.d.ts +219 -0
- package/lib/utils.d.ts +65 -0
- package/lib/web-components/FaceDetection.d.ts +11 -0
- package/lib/web-components/FaceLiveness.d.ts +14 -0
- package/lib/web-components/FullScreenContainer.d.ts +4 -0
- package/lib/web-components.d.ts +47 -0
- package/package.json +30 -35
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
1. [Install via NPM](#install-via-npm)
|
|
5
5
|
1. [Install via CDN](#install-via-cdn)
|
|
6
6
|
1. [Component settings](#component-settings)
|
|
7
|
-
1. [
|
|
7
|
+
1. [Components events](#components-events)
|
|
8
8
|
1. [Component response](#component-response)
|
|
9
9
|
1. [Component attributes](#component-attributes)
|
|
10
10
|
1. [Component customization](#component-customization)
|
|
@@ -20,8 +20,8 @@ This package contains web components for face recognition.
|
|
|
20
20
|
|
|
21
21
|
| Devices |  |  |  |
|
|
22
22
|
|:---------------------|:-------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------:|
|
|
23
|
-
| **Mobile (iOS)** |
|
|
24
|
-
| **Mobile (Android)** |
|
|
23
|
+
| **Mobile (iOS)** | 99 (iOS14.4+) | 99 (iOS14.4+) | 11 |
|
|
24
|
+
| **Mobile (Android)** | 66 | 62 | - |
|
|
25
25
|
| **Desktop** | 66 | 63 | 11 |
|
|
26
26
|
|
|
27
27
|
## Install via NPM
|
|
@@ -102,21 +102,280 @@ component.headers = {
|
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
##
|
|
105
|
+
## Components events
|
|
106
106
|
|
|
107
|
-
You can subscribe to component events.
|
|
107
|
+
You can subscribe to the component events.
|
|
108
108
|
|
|
109
|
-
For
|
|
110
|
-
|
|
109
|
+
For example:
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
const faceLivenessComponent = document.getElementsByTagName('face-liveness')[0];
|
|
113
|
+
const faceCaptureComponent = document.getElementsByTagName('face-capture')[0];
|
|
114
|
+
|
|
115
|
+
faceLivenessComponent.addEventListener('face-liveness', (event) => console.log(event.detail)); // event listener for face-liveness component
|
|
116
|
+
faceCaptureComponent.addEventListener('face-capture', (event) => console.log(event.detail)); // event listener for face-capture component
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The ```face-liveness``` type of event is generated for the face-liveness component, and ```face-capture``` type of event is generated for the face-capture component.
|
|
120
|
+
|
|
121
|
+
The generated event object (```event.detail```) contains three fields that describe the event:
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
{
|
|
125
|
+
action: "PRESS_START_BUTTON", // the type of action that generated the event (all actions are described in the table below)
|
|
126
|
+
data: null, // component data
|
|
127
|
+
manual: true // event generated by user action or component by itself
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Type of actions:
|
|
132
|
+
|
|
133
|
+
| Type of action | Description of the action | In which component is present |
|
|
134
|
+
|:--------------------------|:------------------------------------:|:---------------------------------------:|
|
|
135
|
+
| ```ELEMENT_VISIBLE``` | Component is appended in the DOM. | ```face-liveness```, ```face-capture``` |
|
|
136
|
+
| ```PRESS_START_BUTTON``` | The "Get started" button is pressed. | ```face-liveness```, ```face-capture``` |
|
|
137
|
+
| ```PRESS_RETRY_BUTTON``` | The "Retry" button is pressed. | ```face-liveness```, ```face-capture``` |
|
|
138
|
+
| ```CLOSE``` | The "Close" button is pressed. | ```face-liveness```, ```face-capture``` |
|
|
139
|
+
| ```PROCESS_FINISHED``` | The component has finished its work. | ```face-liveness```, ```face-capture``` |
|
|
140
|
+
| ```SERVICE_INITIALIZED``` | The component has started its work. | ```face-liveness```, ```face-capture``` |
|
|
141
|
+
|
|
142
|
+
In cases of successful operation of the components, the ```data``` field will contain the following fields:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
{
|
|
146
|
+
response: { ... }, // component result
|
|
147
|
+
status: 1 // 1 for successful work and 0 for unsuccessful
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
In cases of unsuccessful work, the ```data``` field will contain the following fields:
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
{
|
|
155
|
+
reason: "CAMERA_PERMISSION_DENIED", // error reason (possible causes of errors are described in the table below)
|
|
156
|
+
status: 0
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Table of error causes:
|
|
161
|
+
|
|
162
|
+
| Reason | Description of the reason |
|
|
163
|
+
|:--------------------------------|:--------------------------------------------:|
|
|
164
|
+
| ```WASM_ERROR``` | Error in WASM. |
|
|
165
|
+
| ```WASM_LICENSE``` | Missing or incorrect license. |
|
|
166
|
+
| ```UNKNOWN_ERROR``` | Unknown error. |
|
|
167
|
+
| ```NOT_SUPPORTED``` | The browser is not supported. |
|
|
168
|
+
| ```CAMERA_UNKNOWN_ERROR``` | Unknown camera error. |
|
|
169
|
+
| ```CAMERA_PERMISSION_DENIED``` | Access to the camera is prohibited. |
|
|
170
|
+
| ```NO_CAMERA``` | There is no camera. |
|
|
171
|
+
| ```CONNECTION_ERROR``` | Connection errors. |
|
|
172
|
+
| ```LANDSCAPE_MODE_RESTRICTED``` | Work in landscape orientation is prohibited. |
|
|
173
|
+
|
|
174
|
+
The table below describes the cases of event generation:
|
|
175
|
+
|
|
176
|
+
### face-liveness & face-capture
|
|
177
|
+
|
|
178
|
+
<table>
|
|
179
|
+
<thead>
|
|
180
|
+
<tr>
|
|
181
|
+
<th>Event condition </th>
|
|
182
|
+
<th>Event type</th>
|
|
183
|
+
<th>
|
|
184
|
+
|
|
185
|
+
Event object ```event.detail```
|
|
186
|
+
</th>
|
|
187
|
+
<th>Description</th>
|
|
188
|
+
</tr>
|
|
189
|
+
</thead>
|
|
190
|
+
<tbody>
|
|
191
|
+
<tr>
|
|
192
|
+
<td>The component is mounted in the DOM.</td>
|
|
193
|
+
<td>
|
|
194
|
+
|
|
195
|
+
For face-liveness:
|
|
196
|
+
```face-liveness```
|
|
197
|
+
|
|
198
|
+
For face-capture:
|
|
199
|
+
```face-capture```
|
|
200
|
+
|
|
201
|
+
</td>
|
|
202
|
+
<td>
|
|
203
|
+
|
|
204
|
+
```javascript
|
|
205
|
+
{
|
|
206
|
+
action: "ELEMENT_VISIBLE",
|
|
207
|
+
data: null,
|
|
208
|
+
manual: true
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
</td>
|
|
213
|
+
<td>
|
|
214
|
+
|
|
215
|
+
To receive this event, you must wrap the component in another element (for example, a div) and add an addEventListener to it. When the component appears in the DOM, the event will pop up.
|
|
111
216
|
|
|
112
217
|
Example:
|
|
218
|
+
```html
|
|
219
|
+
<div id="add-event-listener-to-this-element">
|
|
220
|
+
<face-liveness></face-liveness>
|
|
221
|
+
</div>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
</td>
|
|
225
|
+
</tr>
|
|
226
|
+
<tr>
|
|
227
|
+
<td>The "Get started" button is pressed.</td>
|
|
228
|
+
<td>
|
|
229
|
+
|
|
230
|
+
For face-liveness:
|
|
231
|
+
```face-liveness```
|
|
232
|
+
|
|
233
|
+
For face-capture:
|
|
234
|
+
```face-capture```
|
|
235
|
+
|
|
236
|
+
</td>
|
|
237
|
+
<td>
|
|
113
238
|
|
|
114
239
|
```javascript
|
|
115
|
-
|
|
240
|
+
{
|
|
241
|
+
action: "PRESS_START_BUTTON",
|
|
242
|
+
data: null,
|
|
243
|
+
manual: true
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
</td>
|
|
248
|
+
<td></td>
|
|
249
|
+
</tr>
|
|
250
|
+
<tr>
|
|
251
|
+
<td>The "Retry" button is pressed.</td>
|
|
252
|
+
<td>
|
|
116
253
|
|
|
117
|
-
|
|
254
|
+
For face-liveness:
|
|
255
|
+
```face-liveness```
|
|
256
|
+
|
|
257
|
+
For face-capture:
|
|
258
|
+
```face-capture```
|
|
259
|
+
|
|
260
|
+
</td>
|
|
261
|
+
<td>
|
|
262
|
+
|
|
263
|
+
```javascript
|
|
264
|
+
{
|
|
265
|
+
action: "PRESS_RETRY_BUTTON",
|
|
266
|
+
data: null,
|
|
267
|
+
manual: true
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
</td>
|
|
272
|
+
<td></td>
|
|
273
|
+
</tr>
|
|
274
|
+
<tr>
|
|
275
|
+
<td>The "Close" button is pressed.</td>
|
|
276
|
+
<td>
|
|
277
|
+
|
|
278
|
+
For face-liveness:
|
|
279
|
+
```face-liveness```
|
|
280
|
+
|
|
281
|
+
For face-capture:
|
|
282
|
+
```face-capture```
|
|
283
|
+
|
|
284
|
+
</td>
|
|
285
|
+
<td>
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
{
|
|
289
|
+
action: "CLOSE",
|
|
290
|
+
data: null,
|
|
291
|
+
manual: true
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
</td>
|
|
296
|
+
<td></td>
|
|
297
|
+
</tr>
|
|
298
|
+
<tr>
|
|
299
|
+
<td>The work of the component is completed successfully.</td>
|
|
300
|
+
<td>
|
|
301
|
+
|
|
302
|
+
For face-liveness:
|
|
303
|
+
```face-liveness```
|
|
304
|
+
|
|
305
|
+
For face-capture:
|
|
306
|
+
```face-capture```
|
|
307
|
+
|
|
308
|
+
</td>
|
|
309
|
+
<td>
|
|
310
|
+
|
|
311
|
+
```javascript
|
|
312
|
+
{
|
|
313
|
+
action: "PROCESS_FINISHED",
|
|
314
|
+
data: {
|
|
315
|
+
response: { ... },
|
|
316
|
+
status: 1
|
|
317
|
+
},
|
|
318
|
+
manual: false
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
</td>
|
|
323
|
+
<td></td>
|
|
324
|
+
</tr>
|
|
325
|
+
<tr>
|
|
326
|
+
<td>The work of the component failed.</td>
|
|
327
|
+
<td>
|
|
328
|
+
|
|
329
|
+
For face-liveness:
|
|
330
|
+
```face-liveness```
|
|
331
|
+
|
|
332
|
+
For face-capture:
|
|
333
|
+
```face-capture```
|
|
334
|
+
|
|
335
|
+
</td>
|
|
336
|
+
<td>
|
|
337
|
+
|
|
338
|
+
```javascript
|
|
339
|
+
{
|
|
340
|
+
action: "PROCESS_FINISHED",
|
|
341
|
+
data: {
|
|
342
|
+
reason: "An error has occurred",
|
|
343
|
+
status: 0
|
|
344
|
+
},
|
|
345
|
+
manual: false
|
|
346
|
+
}
|
|
118
347
|
```
|
|
119
348
|
|
|
349
|
+
</td>
|
|
350
|
+
<td></td>
|
|
351
|
+
</tr>
|
|
352
|
+
<tr>
|
|
353
|
+
<td>Component is initialized and ready to work.</td>
|
|
354
|
+
<td>
|
|
355
|
+
|
|
356
|
+
For face-liveness:
|
|
357
|
+
```face-liveness```
|
|
358
|
+
|
|
359
|
+
For face-capture:
|
|
360
|
+
```face-capture```
|
|
361
|
+
|
|
362
|
+
</td>
|
|
363
|
+
<td>
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
{
|
|
367
|
+
action: "SERVICE_INITIALIZED",
|
|
368
|
+
data: null,
|
|
369
|
+
manual: false
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
</td>
|
|
374
|
+
<td></td>
|
|
375
|
+
</tr>
|
|
376
|
+
</tbody>
|
|
377
|
+
</table>
|
|
378
|
+
|
|
120
379
|
## Component response
|
|
121
380
|
|
|
122
381
|
You can get the response of the component in the ```detail``` field of the event object.
|
|
@@ -127,8 +386,8 @@ Example:
|
|
|
127
386
|
const component = document.getElementsByTagName('face-capture')[0];
|
|
128
387
|
|
|
129
388
|
function listener(event) {
|
|
130
|
-
if (event.detail) {
|
|
131
|
-
const response = event.detail;
|
|
389
|
+
if (event.detail.action === 'PROCESS_FINISHED' && event.detail.data.status === 1) {
|
|
390
|
+
const response = event.detail.data.response;
|
|
132
391
|
console.log(response);
|
|
133
392
|
}
|
|
134
393
|
}
|
|
@@ -140,31 +399,35 @@ component.addEventListener('face-capture', listener);
|
|
|
140
399
|
|
|
141
400
|
### face-capture
|
|
142
401
|
|
|
143
|
-
| Attribute
|
|
144
|
-
|
|
145
|
-
| **locale**
|
|
402
|
+
| Attribute | Info | Default value | Values |
|
|
403
|
+
|:--------------|:-------------------------------|:---------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|
404
|
+
| **locale** | The language of the component. | ```en``` | ```ru```, ```en```, ```de```, ```pl```, ```it```, ```hu```, ```ch```, ```sk```, ```uk```, ```fr```, ```es```, ```pt```, ```ar```, ```nl```, ```id```, ```vi```, ```ko```, ```ms```, ```ro```, ```gr```, ```tr```, ```jp```, ```cz```, ```th```, ```hi```, ```bn```, ```he```, ```fi```, ```sv```, ```da```, ```hr```, ```no``` |
|
|
405
|
+
| **copyright** | Show Regula copyright footer | ```false``` | ```true```, ```false``` |
|
|
406
|
+
| **camera-id** | Ability to select a camera | ```undefined``` | ```camera id string value``` |
|
|
146
407
|
|
|
147
408
|
### face-liveness
|
|
148
409
|
|
|
149
|
-
| Attribute
|
|
150
|
-
|
|
151
|
-
| **locale**
|
|
152
|
-
| **url**
|
|
410
|
+
| Attribute | Info | Default value | Values |
|
|
411
|
+
|:--------------|:-------------------------------|:------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|
412
|
+
| **locale** | The language of the component. | ```en``` | ```ru```, ```en```, ```de```, ```pl```, ```it```, ```hu```, ```ch```, ```sk```, ```uk```, ```fr```, ```es```, ```pt```, ```ar```, ```nl```, ```id```, ```vi```, ```ko```, ```ms```, ```ro```, ```gr```, ```tr```, ```jp```, ```cz```, ```th```, ```hi```, ```bn```, ```he```, ```fi```, ```sv```, ```da```, ```hr```, ```no``` |
|
|
413
|
+
| **url** | Backend url. | ```https://faceapi.regulaforensics.com/``` | any url |
|
|
414
|
+
| **copyright** | Show Regula copyright footer | ```false``` | ```true```, ```false``` |
|
|
415
|
+
| **camera-id** | Ability to select a camera | ```undefined``` | ```camera id string value``` |
|
|
153
416
|
|
|
154
417
|
## Component customization
|
|
155
418
|
|
|
156
419
|
Using CSS variables, you can change the font and the main colors of the components.
|
|
157
420
|
|
|
158
|
-
| Variable | Info
|
|
159
|
-
|
|
160
|
-
| **--font-family** |
|
|
161
|
-
| **--font-size** |
|
|
162
|
-
| **--main-color** |
|
|
163
|
-
| **--second-color** |
|
|
164
|
-
| **--third-color** |
|
|
165
|
-
| **--hover-color** |
|
|
166
|
-
| **--active-color** |
|
|
167
|
-
| **--plate-color** |
|
|
421
|
+
| Variable | Info | Default value |
|
|
422
|
+
|:-------------------|:----------------------------------------------------------------------------------------|:---------------------------:|
|
|
423
|
+
| **--font-family** | Сomponent font. | ```Noto Sans, sans-serif``` |
|
|
424
|
+
| **--font-size** | Сomponent base font size. | ```16px``` |
|
|
425
|
+
| **--main-color** | Button and frame color. | ```#663399``` |
|
|
426
|
+
| **--second-color** | Instruction image background color. | ```#EBE1F6``` |
|
|
427
|
+
| **--third-color** | Instruction image portrait background color (available only in face-capture component). | ```#C5B9D2``` |
|
|
428
|
+
| **--hover-color** | Button hover color. | ```#7c45b4``` |
|
|
429
|
+
| **--active-color** | Button active color. | ```#663399``` |
|
|
430
|
+
| **--plate-color** | Information plate color. | ```rgba(0, 0, 0, 0.6)``` |
|
|
168
431
|
|
|
169
432
|
Example:
|
|
170
433
|
|
|
@@ -186,4 +449,4 @@ HTML:
|
|
|
186
449
|
|
|
187
450
|
## Examples
|
|
188
451
|
|
|
189
|
-
You can see examples of using the components [here](https://github.com/regulaforensics/face-web-components-samples).
|
|
452
|
+
You can see examples of using the components [here](https://github.com/regulaforensics/face-web-components-samples).
|