@regulaforensics/vp-frontend-document-components 7.2.1707-nightly → 7.2.1708-nightly

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 CHANGED
@@ -17,6 +17,7 @@
17
17
  * [Event Response](#event-response)
18
18
  * [Settings and Attributes](#settings-and-attributes)
19
19
  * [Backend reprocessing](#backend-reprocessing)
20
+ * [Delegating scan to device with better camera](#delegating-scan-to-device-with-better-camera)
20
21
  * [Appearance Customization](#appearance-customization)
21
22
  * [Font and Colors](#font-and-colors)
22
23
  * [Localized Messages](#localized-messages)
@@ -211,7 +212,14 @@ After adding `DocumentReaderService` to the global variable, you can change the
211
212
  },
212
213
  };
213
214
  ```
214
-
215
+
216
+ **Session ID** for video processing:
217
+ ```javascript
218
+ window.RegulaDocumentSDK.recognizerProcessParam = {
219
+ tag: 'your session id',
220
+ };
221
+ ```
222
+
215
223
  **Image processing** default settings. The functionality is available via the gallery button.
216
224
  ```javascript
217
225
  window.RegulaDocumentSDK.imageProcessParam = {
@@ -303,26 +311,29 @@ The fields of the `event.detail` object:
303
311
 
304
312
  #### Action Types
305
313
 
306
- | Type of action | Description of the action | Components and events, where present |
307
- |:-----------------------------|:------------------------------------------------------------------|:------------------------------------:|
308
- | `ELEMENT_VISIBLE` | Component is appended in the DOM. | `document-reader`, `camera-snapshot` |
309
- | `PRESS_CAMERA_BUTTON` | The "From camera" button is pressed. | `document-reader`, `camera-snapshot` |
310
- | `PRESS_FILE_BUTTON` | The "From gallery" button is pressed. | `document-reader`, `camera-snapshot` |
311
- | `PRESS_RETRY_BUTTON` | The "Retry" button is pressed. | `document-reader`, `camera-snapshot` |
312
- | `PRESS_SKIP_BUTTON` | The "Skip" button is pressed. | `document-reader` |
313
- | `PRESS_CAPTURE_BUTTON` | The "Capture" button is pressed. | `document-reader`, `camera-snapshot` |
314
- | `PRESS_CHANGE_CAMERA_BUTTON` | The "Change camera" button is pressed. | `document-reader`, `camera-snapshot` |
315
- | `PRESS_MIRRORING_BUTTON` | The "Mirroring" button is pressed. | `document-reader`, `camera-snapshot` |
316
- | `NEW_PAGE_AVAILABLE` | The document contains another page. | `document-reader` |
317
- | `NEW_PAGE_STARTED` | Recognition of a new page has started. | `document-reader` |
318
- | `CLOSE` | The "Close" button is pressed. | `document-reader`, `camera-snapshot` |
319
- | `CAMERA_PROCESS_CLOSED` | The "Close" button is pressed on the document recognition screen. | `document-reader`, `camera-snapshot` |
320
- | `CAMERA_PROCESS_STARTED` | Recognition from the camera has started. | `document-reader` |
321
- | `VIDEO_STARTED` | Video stream started. | `document-reader`, `camera-snapshot` |
322
- | `VIDEO_STOPPED` | Video stream stopped. | `document-reader`, `camera-snapshot` |
323
- | `FILE_PROCESS_STARTED` | File processing has started. | `document-reader`, `camera-snapshot` |
324
- | `PROCESS_FINISHED` | The component has finished its work. | `document-reader`, `camera-snapshot` |
325
- | `SERVICE_INITIALIZED` | The component has started its work. | `document-reader` |
314
+ | Type of action | Description of the action | Components and events, where present |
315
+ |:------------------------------|:------------------------------------------------------------------|:------------------------------------:|
316
+ | `ELEMENT_VISIBLE` | Component is appended in the DOM. | `document-reader`, `camera-snapshot` |
317
+ | `PRESS_CAMERA_BUTTON` | The "From camera" button is pressed. | `document-reader`, `camera-snapshot` |
318
+ | `PRESS_FILE_BUTTON` | The "From gallery" button is pressed. | `document-reader`, `camera-snapshot` |
319
+ | `PRESS_RETRY_BUTTON` | The "Retry" button is pressed. | `document-reader`, `camera-snapshot` |
320
+ | `PRESS_SKIP_BUTTON` | The "Skip" button is pressed. | `document-reader` |
321
+ | `PRESS_CAPTURE_BUTTON` | The "Capture" button is pressed. | `document-reader`, `camera-snapshot` |
322
+ | `PRESS_CHANGE_CAMERA_BUTTON` | The "Change camera" button is pressed. | `document-reader`, `camera-snapshot` |
323
+ | `PRESS_MIRRORING_BUTTON` | The "Mirroring" button is pressed. | `document-reader`, `camera-snapshot` |
324
+ | `NEW_PAGE_AVAILABLE` | The document contains another page. | `document-reader` |
325
+ | `NEW_PAGE_STARTED` | Recognition of a new page has started. | `document-reader` |
326
+ | `CLOSE` | The "Close" button is pressed. | `document-reader`, `camera-snapshot` |
327
+ | `CAMERA_PROCESS_CLOSED` | The "Close" button is pressed on the document recognition screen. | `document-reader`, `camera-snapshot` |
328
+ | `CAMERA_PROCESS_STARTED` | Recognition from the camera has started. | `document-reader` |
329
+ | `VIDEO_STARTED` | Video stream started. | `document-reader`, `camera-snapshot` |
330
+ | `VIDEO_STOPPED` | Video stream stopped. | `document-reader`, `camera-snapshot` |
331
+ | `FILE_PROCESS_STARTED` | File processing has started. | `document-reader`, `camera-snapshot` |
332
+ | `PROCESS_FINISHED` | The component has finished its work. | `document-reader`, `camera-snapshot` |
333
+ | `SERVICE_INITIALIZED` | The component has started its work. | `document-reader` |
334
+ | `PRESS_REMOTE_DEVICE_BUTTON` | The "From other phone" button is pressed. | `document-reader` |
335
+ | `REMOTE_TRANSACTION_UPLOADED` | Remote transaction with current tag was uploaded | `document-reader` |
336
+ | `REMOTE_PROCESS_FINISHED` | Remote transaction with current tag was processed | `document-reader` |
326
337
 
327
338
 
328
339
  #### Action Data
@@ -389,6 +400,21 @@ Available fields of `event.detail.data` object:
389
400
  | `INCORRECT_CAMERA_ID` | Camera with this ID was not found |
390
401
  | `CONNECTION_ERROR` | Connection errors |
391
402
 
403
+ #### Remote action data
404
+
405
+ **1.** In case of remote scan scenario REMOTE_TRANSACTION_UPLOADED `event.detail` will contain the following data:
406
+ ```javascript
407
+ {
408
+ action: EventActions.REMOTE_TRANSACTION_UPLOADED,
409
+ data: {
410
+ id: 1,
411
+ state: 1,
412
+ updatedAt: 'dateStr'
413
+ },
414
+ }
415
+ ```
416
+ Transaction id can be used to trigger reprocessing.
417
+
392
418
  #### Event Generation Logic
393
419
 
394
420
  The cases of event generation are described in the following table.
@@ -954,6 +980,46 @@ function listener(event) {
954
980
 
955
981
  component.addEventListener('document-reader', listener);
956
982
  ```
983
+ ### Delegating scan to device with better camera
984
+
985
+ For cases when user's main device lacks camera or does not succeed to scan with given camera quality,
986
+ you have an option to delegate scanning to another available device (i.e. phone).
987
+
988
+ #### 1. "From other phone" action may be configured on the start screen:
989
+ - configure [backend reprocessing](#backend-reprocessing)
990
+ - add 'delegateURL' and 'tag':
991
+ ```javascript
992
+ processor.recognizerProcessParam = {
993
+ delegateURL: 'https://your-page.com?tag={tag}', // the page which will be used by other device
994
+ tag: 123 // your session id, will be added to delegateURL in place of {tag} substring
995
+ }
996
+ ```
997
+ - these settings will unlock "From other phone" option
998
+
999
+ ![Delegate action](./docs/document-reader-delegate-button.png)
1000
+
1001
+ that shows the user QR Code with url (i.e. `https://your-page.com?tag=123`)
1002
+
1003
+ ![Delegate mode](./docs/document-reader-delegate-mode.png)
1004
+ - the component will emit **REMOTE_TRANSACTION_UPLOADED** event with the most recent transaction uploaded with your session tag.
1005
+ Transaction id may be used to trigger full process backend reprocessing (i.e use [Document Reader Webclient](https://www.npmjs.com/package/@regulaforensics/document-reader-webclient))
1006
+ - the component will emit **REMOTE_PROCESS_FINISHED** event with a result of the most recent processed transaction.
1007
+ It is similar to **PROCESS_FINISHED** event but may contain more data due to backend reprocessing
1008
+
1009
+ #### 2. Configure Delegate page component on delegateURL:
1010
+ - configure [backend reprocessing](#backend-reprocessing)
1011
+ - use the same tag as on the main page
1012
+ ```javascript
1013
+ window.RegulaDocumentSDK.recognizerProcessParam = {
1014
+ tag: 123 // your session id, i.e. it can be extracted from your delegate page URL
1015
+ };
1016
+
1017
+ element.settings = {
1018
+ startScreen: false, // From camera recognition is expected
1019
+ }
1020
+ ```
1021
+ - use finalizePackage() to send the data for further reprocessing
1022
+
957
1023
 
958
1024
  ### Appearance Customization
959
1025
 
@@ -1011,48 +1077,49 @@ body.append(element);
1011
1077
 
1012
1078
  See the following table with localized labels, used in the components.
1013
1079
 
1014
- | Label | Default message in `en` locale | Used in |
1015
- |:------------------------------|:---------------------------------------------------------------------------------------------|:------------------------------------:|
1016
- | **success** | Success! | `document-reader`, `camera-snapshot` |
1017
- | **fileCorrupt** | This file is corrupt or not supported | `document-reader`, `camera-snapshot` |
1018
- | **selectAnotherFile** | Please select another file | `document-reader`, `camera-snapshot` |
1019
- | **error** | Error! | `document-reader`, `camera-snapshot` |
1020
- | **somethingWentWrong** | Something went wrong | `document-reader`, `camera-snapshot` |
1021
- | **tryAgain** | Try again | `document-reader`, `camera-snapshot` |
1022
- | **fromCamera** | From camera | `document-reader`, `camera-snapshot` |
1023
- | **fromGallery** | From gallery | `document-reader`, `camera-snapshot` |
1024
- | **cameraUnavailable** | Camera unavailable! | `document-reader`, `camera-snapshot` |
1025
- | **preparingCamera** | Preparing the camera... | `document-reader`, `camera-snapshot` |
1026
- | **noCameraAvailable** | No camera available | `document-reader`, `camera-snapshot` |
1027
- | **incorrectCameraId** | No camera with the specified ID found. | `document-reader`, `camera-snapshot` |
1028
- | **allowAccessToCamera** | Allow access to the camera and reload this page to continue. | `document-reader`, `camera-snapshot` |
1029
- | **cameraConnection** | Make sure the camera is connected correctly. | `document-reader`, `camera-snapshot` |
1030
- | **checkCameraId** | Check if the specified camera ID is correct. | `document-reader`, `camera-snapshot` |
1031
- | **scanIDInBrowser** | Scan an ID in your browser | `document-reader` |
1032
- | **useYourDeviceCamera** | Use your device camera to scan a document or select a photo of the document from the gallery | `document-reader` |
1033
- | **processingFinished** | Processing finished. | `document-reader` |
1034
- | **largeFile** | This file is too large to be uploaded | `document-reader` |
1035
- | **selectSmallerFile** | Please select a smaller file | `document-reader` |
1036
- | **versionNotSupported** | Your browser version is not supported | `document-reader` |
1037
- | **updateBrowser** | Update your browser version | `document-reader` |
1038
- | **licenseError** | A license error has occurred | `document-reader` |
1039
- | **licenseExpired** | The license cannot be found or has expired | `document-reader` |
1040
- | **timeout** | Timeout | `document-reader` |
1041
- | **processing** | Processing... | `document-reader` |
1042
- | **preparingService** | Preparing the service... | `document-reader` |
1043
- | **placeDocumentIntoFrame** | Fit the document into the frame | `document-reader` |
1044
- | **noFocus** | No camera focus | `document-reader` |
1045
- | **moveCloser** | Move closer | `document-reader` |
1046
- | **glaresOnDocument** | Avoid glare on the document | `document-reader` |
1047
- | **holdDocumentStraight** | Hold the document straight | `document-reader` |
1048
- | **documentProcessing** | Document processing... | `document-reader` |
1049
- | **flipDocument** | Flip the document | `document-reader` |
1050
- | **verified** | Verified! | `document-reader` |
1051
- | **keepDeviceStill** | Hold the device still | `document-reader` |
1052
- | **positionDocumentCenter** | Position the document in the center | `camera-snapshot` |
1053
- | **photoCapturedSuccessfully** | The photo is captured successfully. | `camera-snapshot` |
1054
- | **uploadPhoto** | Upload a photo | `camera-snapshot` |
1055
- | **useCameraOrGallery** | Use your device camera or select a photo from the gallery | `camera-snapshot` |
1080
+ | Label | Default message in `en` locale | Used in |
1081
+ |:-------------------------------|:---------------------------------------------------------------------------------------------|:------------------------------------:|
1082
+ | **success** | Success! | `document-reader`, `camera-snapshot` |
1083
+ | **fileCorrupt** | This file is corrupt or not supported | `document-reader`, `camera-snapshot` |
1084
+ | **selectAnotherFile** | Please select another file | `document-reader`, `camera-snapshot` |
1085
+ | **error** | Error! | `document-reader`, `camera-snapshot` |
1086
+ | **somethingWentWrong** | Something went wrong | `document-reader`, `camera-snapshot` |
1087
+ | **tryAgain** | Try again | `document-reader`, `camera-snapshot` |
1088
+ | **fromCamera** | From camera | `document-reader`, `camera-snapshot` |
1089
+ | **fromGallery** | From gallery | `document-reader`, `camera-snapshot` |
1090
+ | **fromOtherPhone** | From other phone | `document-reader`, `camera-snapshot` |
1091
+ | **cameraUnavailable** | Camera unavailable! | `document-reader`, `camera-snapshot` |
1092
+ | **preparingCamera** | Preparing the camera... | `document-reader`, `camera-snapshot` |
1093
+ | **noCameraAvailable** | No camera available | `document-reader`, `camera-snapshot` |
1094
+ | **incorrectCameraId** | No camera with the specified ID found. | `document-reader`, `camera-snapshot` |
1095
+ | **allowAccessToCamera** | Allow access to the camera and reload this page to continue. | `document-reader`, `camera-snapshot` |
1096
+ | **cameraConnection** | Make sure the camera is connected correctly. | `document-reader`, `camera-snapshot` |
1097
+ | **checkCameraId** | Check if the specified camera ID is correct. | `document-reader`, `camera-snapshot` |
1098
+ | **scanIDInBrowser** | Scan an ID in your browser | `document-reader` |
1099
+ | **useYourDeviceCamera** | Use your device camera to scan a document or select a photo of the document from the gallery | `document-reader` |
1100
+ | **processingFinished** | Processing finished. | `document-reader` |
1101
+ | **largeFile** | This file is too large to be uploaded | `document-reader` |
1102
+ | **selectSmallerFile** | Please select a smaller file | `document-reader` |
1103
+ | **versionNotSupported** | Your browser version is not supported | `document-reader` |
1104
+ | **updateBrowser** | Update your browser version | `document-reader` |
1105
+ | **licenseError** | A license error has occurred | `document-reader` |
1106
+ | **licenseExpired** | The license cannot be found or has expired | `document-reader` |
1107
+ | **timeout** | Timeout | `document-reader` |
1108
+ | **processing** | Processing... | `document-reader` |
1109
+ | **preparingService** | Preparing the service... | `document-reader` |
1110
+ | **placeDocumentIntoFrame** | Fit the document into the frame | `document-reader` |
1111
+ | **noFocus** | No camera focus | `document-reader` |
1112
+ | **moveCloser** | Move closer | `document-reader` |
1113
+ | **glaresOnDocument** | Avoid glare on the document | `document-reader` |
1114
+ | **holdDocumentStraight** | Hold the document straight | `document-reader` |
1115
+ | **documentProcessing** | Document processing... | `document-reader` |
1116
+ | **flipDocument** | Flip the document | `document-reader` |
1117
+ | **verified** | Verified! | `document-reader` |
1118
+ | **keepDeviceStill** | Hold the device still | `document-reader` |
1119
+ | **positionDocumentCenter** | Position the document in the center | `camera-snapshot` |
1120
+ | **photoCapturedSuccessfully** | The photo is captured successfully. | `camera-snapshot` |
1121
+ | **uploadPhoto** | Upload a photo | `camera-snapshot` |
1122
+ | **useCameraOrGallery** | Use your device camera or select a photo from the gallery | `camera-snapshot` |
1056
1123
 
1057
1124
  ## Document Reader Processor
1058
1125
 
package/dist/index.d.ts CHANGED
@@ -6,12 +6,6 @@ import { Response as Response_2 } from '@regulaforensics/document-reader-webclie
6
6
  import { Result } from '@regulaforensics/document-reader-webclient';
7
7
  import { TextFieldType } from '@regulaforensics/document-reader-webclient';
8
8
 
9
- export declare interface BaseRequest {
10
- tag?: string;
11
- tenant?: string;
12
- env?: string;
13
- }
14
-
15
9
  export declare enum CameraFacingMode {
16
10
  user = "user",
17
11
  environment = "environment"
@@ -27,7 +21,7 @@ declare enum CameraSnapshotAttributes {
27
21
  closeButton = "close-button"
28
22
  }
29
23
 
30
- export declare type CameraSnapshotDetailType = DetailEvent<EventActions, CameraSnapshotResponseType>;
24
+ export declare type CameraSnapshotDetailType = DetailEvent<Exclude<EventActions, EventActions.REMOTE_TRANSACTION_UPLOADED>, CameraSnapshotResponseType>;
31
25
 
32
26
  export declare type CameraSnapshotResponseType = Array<{
33
27
  raw: string;
@@ -118,7 +112,7 @@ export declare class DocumentReaderCaptureWebComponent extends HTMLElement {
118
112
  disconnectedCallback(): void;
119
113
  }
120
114
 
121
- export declare type DocumentReaderDetailType = DetailEvent<EventActions, DocumentReaderResponseType>;
115
+ export declare type DocumentReaderDetailType = DetailEvent<Exclude<EventActions, EventActions.REMOTE_TRANSACTION_UPLOADED>, DocumentReaderResponseType>;
122
116
 
123
117
  export declare interface DocumentReaderImage {
124
118
  data: string;
@@ -377,6 +371,7 @@ export declare enum EventActions {
377
371
  PRESS_SKIP_BUTTON = "PRESS_SKIP_BUTTON",
378
372
  PRESS_CAPTURE_BUTTON = "PRESS_CAPTURE_BUTTON",
379
373
  PRESS_CHANGE_CAMERA_BUTTON = "PRESS_CHANGE_CAMERA_BUTTON",
374
+ PRESS_REMOTE_DEVICE_BUTTON = "PRESS_REMOTE_DEVICE_BUTTON",
380
375
  PRESS_MIRRORING_BUTTON = "PRESS_MIRRORING_BUTTON",
381
376
  PRESS_CONNECT_BUTTON = "PRESS_CONNECT_BUTTON",
382
377
  PRESS_DISCONNECT_BUTTON = "PRESS_DISCONNECT_BUTTON",
@@ -392,7 +387,9 @@ export declare enum EventActions {
392
387
  FILE_PROCESS_STARTED = "FILE_PROCESS_STARTED",
393
388
  PROCESS_STARTED = "PROCESS_STARTED",
394
389
  PROCESS_FINISHED = "PROCESS_FINISHED",
395
- SERVICE_INITIALIZED = "SERVICE_INITIALIZED"
390
+ SERVICE_INITIALIZED = "SERVICE_INITIALIZED",
391
+ REMOTE_TRANSACTION_UPLOADED = "REMOTE_TRANSACTION_UPLOADED",
392
+ REMOTE_PROCESS_FINISHED = "REMOTE_PROCESS_FINISHED"
396
393
  }
397
394
 
398
395
  export declare enum FrameLineCap {
@@ -437,7 +434,8 @@ export declare interface ImageInputParamType {
437
434
  resolutionType: number;
438
435
  }
439
436
 
440
- export declare interface ImageProcessingRequest extends BaseRequest {
437
+ export declare interface ImageProcessingRequest {
438
+ tag?: string;
441
439
  imageInputParam?: ImageInputParamType;
442
440
  processParam: Pick<DocumentReaderProcessParam, 'returnPackageForReprocess' | 'returnUncroppedImage' | 'scenario' | 'backendProcessing'>;
443
441
  }
@@ -498,8 +496,10 @@ export declare interface PackageParams {
498
496
  metadata?: Record<string, any>;
499
497
  }
500
498
 
501
- export declare interface ProcessingRequest extends BaseRequest {
499
+ export declare interface ProcessingRequest {
502
500
  metadata?: Record<string, any>;
501
+ tag?: string;
502
+ delegateURL?: string;
503
503
  processParam: DocumentReaderProcessParam;
504
504
  imagesList?: Array<DocumentReaderImage>;
505
505
  imageInputParam?: ImageInputParamType;
@@ -536,11 +536,32 @@ declare type TProcessingListener = ({ isProcessing }: {
536
536
  isProcessing: boolean;
537
537
  }) => void;
538
538
 
539
+ export declare interface TransactionEvent {
540
+ action: EventActions.REMOTE_TRANSACTION_UPLOADED;
541
+ data: TransactionStatusInfo;
542
+ }
543
+
539
544
  export declare interface TransactionInfo {
540
545
  tag: string;
541
546
  transactionId: string;
542
547
  }
543
548
 
549
+ export declare type TransactionsListResponse = {
550
+ items: TransactionStatusInfo[];
551
+ };
552
+
553
+ export declare enum TransactionStateStatus {
554
+ STARTED = 0,
555
+ UPLOADED = 1,
556
+ PROCESSED = 2
557
+ }
558
+
559
+ export declare type TransactionStatusInfo = {
560
+ id: number;
561
+ state: TransactionStateStatus;
562
+ updatedAt: string;
563
+ };
564
+
544
565
  export declare type TScenarioParams = {
545
566
  name: string;
546
567
  desc: string;
@@ -578,7 +599,7 @@ export { }
578
599
 
579
600
  declare global {
580
601
  interface HTMLElementEventMap {
581
- 'document-reader': CustomEvent<DocumentReaderDetailType>;
602
+ 'document-reader': CustomEvent<DocumentReaderDetailType | TransactionEvent>;
582
603
  'camera-snapshot': CustomEvent<CameraSnapshotDetailType>;
583
604
  }
584
605
  interface Window {