@regulaforensics/vp-frontend-face-components 1.1.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.
Files changed (73) hide show
  1. package/README.md +346 -30
  2. package/dist/main.js +1 -1
  3. package/dist/main.js.LICENSE.txt +42 -0
  4. package/lib/common/BackCameraIcon.d.ts +6 -0
  5. package/lib/common/Button.d.ts +7 -0
  6. package/lib/common/CameraChangeIcon.d.ts +6 -0
  7. package/lib/common/CameraIcon.d.ts +6 -0
  8. package/lib/common/CheckIcon.d.ts +6 -0
  9. package/lib/common/CrossIcon.d.ts +6 -0
  10. package/lib/common/DocReaderCameraDisabled.d.ts +5 -0
  11. package/lib/common/DocReaderCameraPreparing.d.ts +5 -0
  12. package/lib/common/DocReaderFlip.d.ts +5 -0
  13. package/lib/common/DocReaderProcessing.d.ts +5 -0
  14. package/lib/common/DocReaderProcessingError.d.ts +5 -0
  15. package/lib/common/DocReaderProcessingFinished.d.ts +6 -0
  16. package/lib/common/DocReaderSearch.d.ts +5 -0
  17. package/lib/common/ErrorIcon.d.ts +6 -0
  18. package/lib/common/FromCameraIcon.d.ts +5 -0
  19. package/lib/common/FromGalleryIcon.d.ts +5 -0
  20. package/lib/common/FrontCameraIcon.d.ts +6 -0
  21. package/lib/common/FullscreenExitIcon.d.ts +6 -0
  22. package/lib/common/FullscreenIcon.d.ts +6 -0
  23. package/lib/common/Icon.d.ts +7 -0
  24. package/lib/common/InstructionIconFaceDetection.d.ts +5 -0
  25. package/lib/common/InstructionIconFaceLiveness.d.ts +5 -0
  26. package/lib/common/Message.d.ts +7 -0
  27. package/lib/common/NoGlareIcon.d.ts +5 -0
  28. package/lib/common/NoSmilingIcon.d.ts +5 -0
  29. package/lib/common/RegulaLogo.d.ts +6 -0
  30. package/lib/common/SnapshotIcon.d.ts +6 -0
  31. package/lib/common/Spinner.d.ts +3 -0
  32. package/lib/common/SquareIcon.d.ts +6 -0
  33. package/lib/common/StopIcon.d.ts +6 -0
  34. package/lib/common/VerifiedIcon.d.ts +6 -0
  35. package/lib/components/ErrorBoundary.d.ts +17 -0
  36. package/lib/components/FaceCapture.d.ts +17 -0
  37. package/lib/components/FaceDetection.d.ts +2 -0
  38. package/lib/components/FaceFullScreenOverlay.d.ts +11 -0
  39. package/lib/components/FaceLayout.d.ts +19 -0
  40. package/lib/components/FaceLiveness.d.ts +2 -0
  41. package/lib/components/InfoScreen.d.ts +10 -0
  42. package/lib/components/InstructionScreen.d.ts +9 -0
  43. package/lib/components/ProcessScreen.d.ts +6 -0
  44. package/lib/components/RetryScreen.d.ts +7 -0
  45. package/lib/components/WebCamera.d.ts +20 -0
  46. package/lib/constants.d.ts +366 -0
  47. package/lib/contexts/FaceAttributesContext.d.ts +24 -0
  48. package/lib/hoc/withFaceAttributesContext.d.ts +4 -0
  49. package/lib/hoc/withLocalize.d.ts +7 -0
  50. package/lib/hooks/useDebounce.d.ts +2 -0
  51. package/lib/hooks/useFaceLiveness.d.ts +33 -0
  52. package/lib/hooks/useInterval.d.ts +3 -0
  53. package/lib/hooks/useOrientationChange.d.ts +10 -0
  54. package/lib/hooks/useStream.d.ts +16 -0
  55. package/lib/hooks/useUserAgent.d.ts +3 -0
  56. package/lib/hooks/useWindowBlur.d.ts +2 -0
  57. package/lib/i18n/dictionaries/_dictionaries.d.ts +2051 -0
  58. package/lib/index-face.d.ts +1 -0
  59. package/lib/models/CameraModel.d.ts +9 -0
  60. package/lib/models/ImageModel.d.ts +7 -0
  61. package/lib/services/DebugService.d.ts +13 -0
  62. package/lib/services/DocumentReaderService.d.ts +39 -0
  63. package/lib/services/EventEmitter.d.ts +9 -0
  64. package/lib/services/FaceLivenessService.d.ts +46 -0
  65. package/lib/services/FaceService.d.ts +11 -0
  66. package/lib/services/WasmFeatureDetectService.d.ts +4 -0
  67. package/lib/types.d.ts +219 -0
  68. package/lib/utils.d.ts +65 -0
  69. package/lib/web-components/FaceDetection.d.ts +11 -0
  70. package/lib/web-components/FaceLiveness.d.ts +14 -0
  71. package/lib/web-components/FullScreenContainer.d.ts +4 -0
  72. package/lib/web-components.d.ts +47 -0
  73. package/package.json +37 -37
package/README.md CHANGED
@@ -1,20 +1,29 @@
1
- # Table of сontents
1
+ # Table of contents
2
2
  1. [About](#about)
3
- 1. [Install via NPM](#npm)
4
- 1. [Install via CDN](#cdn)
5
- 1. [Component events](#events)
6
- 1. [Component response](#response)
7
- 1. [Component attributes](#attributes)
3
+ 1. [Compatibility](#compatibility)
4
+ 1. [Install via NPM](#install-via-npm)
5
+ 1. [Install via CDN](#install-via-cdn)
6
+ 1. [Component settings](#component-settings)
7
+ 1. [Components events](#components-events)
8
+ 1. [Component response](#component-response)
9
+ 1. [Component attributes](#component-attributes)
10
+ 1. [Component customization](#component-customization)
8
11
  1. [Examples](#examples)
9
12
 
10
13
  ---
11
14
 
12
- <a name="about"></a>
13
15
  ## About
14
16
 
15
17
  This package contains web components for face recognition.
16
18
 
17
- <a name="npm"></a>
19
+ ## Compatibility
20
+
21
+ | Devices | ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![FireFox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) |
22
+ |:---------------------|:-------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------:|
23
+ | **Mobile (iOS)** | 99 (iOS14.4+) | 99 (iOS14.4+) | 11 |
24
+ | **Mobile (Android)** | 66 | 62 | - |
25
+ | **Desktop** | 66 | 63 | 11 |
26
+
18
27
  ## Install via NPM
19
28
 
20
29
  On the command line, navigate to the root directory of your project:
@@ -65,7 +74,6 @@ Example:
65
74
  </html>
66
75
  ```
67
76
 
68
- <a name="cdn"></a>
69
77
  ## Install via CDN
70
78
 
71
79
  Connect the script in your ```.html``` file. CDN link: ```unpkg.com/:package@:version/:file```
@@ -73,28 +81,301 @@ Connect the script in your ```.html``` file. CDN link: ```unpkg.com/:package@:ve
73
81
  Example:
74
82
 
75
83
  ```html
76
- <script src="https://unpkg.com/@regulaforensics/vp-frontend-face-components@1.1.0/dist/main.js"></script>
84
+ <script src="https://unpkg.com/@regulaforensics/vp-frontend-face-components@1.2.0/dist/main.js"></script>
77
85
  ```
78
86
 
79
87
  Add the name of the component to the html, as in the example above.
80
88
 
81
- <a name="events"></a>
82
- ## Component events
89
+ ## Component settings
83
90
 
84
- You can subscribe to component events. In cases of successful and unsuccessful work, the following events will be triggered:
91
+ ### face-liveness
85
92
 
86
- For the ```face-capture``` component - ```face-capture```
87
- For the ```face-liveness``` component - ```face-liveness```
93
+ After passing two stages of verification, the component sends the received data for processing to the API. Using ```headers``` setter you can set HTTP POST method headers.
88
94
 
89
95
  Example:
90
96
 
91
97
  ```javascript
92
- const component = document.getElementsByTagName('face-capture')[0];
98
+ const component = document.getElementsByTagName('face-liveness')[0];
99
+
100
+ component.headers = {
101
+ Authorization: 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='
102
+ }
103
+ ```
104
+
105
+ ## Components events
106
+
107
+ You can subscribe to the component events.
108
+
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.
93
216
 
94
- component.addEventListener('face-capture', () => alert('Event!'));
217
+ Example:
218
+ ```html
219
+ <div id="add-event-listener-to-this-element">
220
+ <face-liveness></face-liveness>
221
+ </div>
95
222
  ```
96
223
 
97
- <a name="response"></a>
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>
238
+
239
+ ```javascript
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>
253
+
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
+ }
347
+ ```
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
+
98
379
  ## Component response
99
380
 
100
381
  You can get the response of the component in the ```detail``` field of the event object.
@@ -105,8 +386,8 @@ Example:
105
386
  const component = document.getElementsByTagName('face-capture')[0];
106
387
 
107
388
  function listener(event) {
108
- if (event.detail) {
109
- const response = event.detail;
389
+ if (event.detail.action === 'PROCESS_FINISHED' && event.detail.data.status === 1) {
390
+ const response = event.detail.data.response;
110
391
  console.log(response);
111
392
  }
112
393
  }
@@ -114,23 +395,58 @@ function listener(event) {
114
395
  component.addEventListener('face-capture', listener);
115
396
  ```
116
397
 
117
- <a name="attributes"></a>
118
398
  ## Component attributes
119
399
 
120
400
  ### face-capture
121
401
 
122
- | Attribute | Info | Default value | Values |
123
- |:----------|:-----|:-------------:|:------:|
124
- | **locale** | the language of the component | ```en``` | ```en```, ```ru``` |
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``` |
125
407
 
126
408
  ### face-liveness
127
409
 
128
- | Attribute | Info | Default value | Values |
129
- |:----------|:-----|:-------------:|:------:|
130
- | **locale** | the language of the component | ```en``` | ```en```, ```ru``` |
131
- | **url** | backend url | ```https://faceapi.regulaforensics.com/``` | any 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``` |
416
+
417
+ ## Component customization
418
+
419
+ Using CSS variables, you can change the font and the main colors of the components.
420
+
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)``` |
431
+
432
+ Example:
433
+
434
+ CSS:
435
+
436
+ ```css
437
+ .my-custom-style {
438
+ --font-family: Arial, sans-serif;
439
+ --main-color: green;
440
+ --hover-color: red;
441
+ }
442
+ ```
443
+
444
+ HTML:
445
+
446
+ ```html
447
+ <face-capture class="my-custom-style"></face-capture>
448
+ ```
132
449
 
133
- <a name="examples"></a>
134
450
  ## Examples
135
451
 
136
- 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).