@regulaforensics/vp-frontend-document-components 7.2.1744-nightly → 7.2.1746-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)
@@ -232,7 +233,14 @@ After adding `DocumentReaderService` to the global variable, you can change the
232
233
  },
233
234
  };
234
235
  ```
235
-
236
+
237
+ **Session ID** for video processing:
238
+ ```javascript
239
+ window.RegulaDocumentSDK.recognizerProcessParam = {
240
+ tag: 'your session id',
241
+ };
242
+ ```
243
+
236
244
  **Image processing** default settings. The functionality is available via the gallery button.
237
245
  ```javascript
238
246
  window.RegulaDocumentSDK.imageProcessParam = {
@@ -323,26 +331,29 @@ The fields of the `event.detail` object:
323
331
 
324
332
  #### Action Types
325
333
 
326
- | Type of action | Description of the action | Components and events, where present |
327
- |:-----------------------------|:------------------------------------------------------------------|:------------------------------------:|
328
- | `ELEMENT_VISIBLE` | Component is appended in the DOM. | `document-reader`, `camera-snapshot` |
329
- | `PRESS_CAMERA_BUTTON` | The "From camera" button is pressed. | `document-reader`, `camera-snapshot` |
330
- | `PRESS_FILE_BUTTON` | The "From gallery" button is pressed. | `document-reader`, `camera-snapshot` |
331
- | `PRESS_RETRY_BUTTON` | The "Retry" button is pressed. | `document-reader`, `camera-snapshot` |
332
- | `PRESS_SKIP_BUTTON` | The "Skip" button is pressed. | `document-reader` |
333
- | `PRESS_CAPTURE_BUTTON` | The "Capture" button is pressed. | `document-reader`, `camera-snapshot` |
334
- | `PRESS_CHANGE_CAMERA_BUTTON` | The "Change camera" button is pressed. | `document-reader`, `camera-snapshot` |
335
- | `PRESS_MIRRORING_BUTTON` | The "Mirroring" button is pressed. | `document-reader`, `camera-snapshot` |
336
- | `NEW_PAGE_AVAILABLE` | The document contains another page. | `document-reader` |
337
- | `NEW_PAGE_STARTED` | Recognition of a new page has started. | `document-reader` |
338
- | `CLOSE` | The "Close" button is pressed. | `document-reader`, `camera-snapshot` |
339
- | `CAMERA_PROCESS_CLOSED` | The "Close" button is pressed on the document recognition screen. | `document-reader`, `camera-snapshot` |
340
- | `CAMERA_PROCESS_STARTED` | Recognition from the camera has started. | `document-reader` |
341
- | `VIDEO_STARTED` | Video stream started. | `document-reader`, `camera-snapshot` |
342
- | `VIDEO_STOPPED` | Video stream stopped. | `document-reader`, `camera-snapshot` |
343
- | `FILE_PROCESS_STARTED` | File processing has started. | `document-reader`, `camera-snapshot` |
344
- | `PROCESS_FINISHED` | The component has finished its work. | `document-reader`, `camera-snapshot` |
345
- | `SERVICE_INITIALIZED` | The component has started its work. | `document-reader` |
334
+ | Type of action | Description of the action | Components and events, where present |
335
+ |:------------------------------|:------------------------------------------------------------------|:------------------------------------:|
336
+ | `ELEMENT_VISIBLE` | Component is appended in the DOM. | `document-reader`, `camera-snapshot` |
337
+ | `PRESS_CAMERA_BUTTON` | The "From camera" button is pressed. | `document-reader`, `camera-snapshot` |
338
+ | `PRESS_FILE_BUTTON` | The "From gallery" button is pressed. | `document-reader`, `camera-snapshot` |
339
+ | `PRESS_RETRY_BUTTON` | The "Retry" button is pressed. | `document-reader`, `camera-snapshot` |
340
+ | `PRESS_SKIP_BUTTON` | The "Skip" button is pressed. | `document-reader` |
341
+ | `PRESS_CAPTURE_BUTTON` | The "Capture" button is pressed. | `document-reader`, `camera-snapshot` |
342
+ | `PRESS_CHANGE_CAMERA_BUTTON` | The "Change camera" button is pressed. | `document-reader`, `camera-snapshot` |
343
+ | `PRESS_MIRRORING_BUTTON` | The "Mirroring" button is pressed. | `document-reader`, `camera-snapshot` |
344
+ | `NEW_PAGE_AVAILABLE` | The document contains another page. | `document-reader` |
345
+ | `NEW_PAGE_STARTED` | Recognition of a new page has started. | `document-reader` |
346
+ | `CLOSE` | The "Close" button is pressed. | `document-reader`, `camera-snapshot` |
347
+ | `CAMERA_PROCESS_CLOSED` | The "Close" button is pressed on the document recognition screen. | `document-reader`, `camera-snapshot` |
348
+ | `CAMERA_PROCESS_STARTED` | Recognition from the camera has started. | `document-reader` |
349
+ | `VIDEO_STARTED` | Video stream started. | `document-reader`, `camera-snapshot` |
350
+ | `VIDEO_STOPPED` | Video stream stopped. | `document-reader`, `camera-snapshot` |
351
+ | `FILE_PROCESS_STARTED` | File processing has started. | `document-reader`, `camera-snapshot` |
352
+ | `PROCESS_FINISHED` | The component has finished its work. | `document-reader`, `camera-snapshot` |
353
+ | `SERVICE_INITIALIZED` | The component has started its work. | `document-reader` |
354
+ | `PRESS_REMOTE_DEVICE_BUTTON` | The "From other phone" button is pressed. | `document-reader` |
355
+ | `REMOTE_TRANSACTION_UPLOADED` | Remote transaction with current tag was uploaded | `document-reader` |
356
+ | `REMOTE_PROCESS_FINISHED` | Remote transaction with current tag was processed | `document-reader` |
346
357
 
347
358
 
348
359
  #### Action Data
@@ -410,6 +421,21 @@ Available fields of `event.detail.data` object:
410
421
  | `INCORRECT_CAMERA_ID` | Camera with this ID was not found |
411
422
  | `CONNECTION_ERROR` | Connection errors |
412
423
 
424
+ #### Remote action data
425
+
426
+ **1.** In case of remote scan scenario REMOTE_TRANSACTION_UPLOADED `event.detail` will contain the following data:
427
+ ```javascript
428
+ {
429
+ action: EventActions.REMOTE_TRANSACTION_UPLOADED,
430
+ data: {
431
+ id: 1,
432
+ state: 1,
433
+ updatedAt: 'dateStr'
434
+ },
435
+ }
436
+ ```
437
+ Transaction id can be used to trigger reprocessing.
438
+
413
439
  #### Event Generation Logic
414
440
 
415
441
  The cases of event generation are described in the following table.
@@ -975,6 +1001,46 @@ function listener(event) {
975
1001
 
976
1002
  component.addEventListener('document-reader', listener);
977
1003
  ```
1004
+ ### Delegating scan to device with better camera
1005
+
1006
+ For cases when user's main device lacks camera or does not succeed to scan with given camera quality,
1007
+ you have an option to delegate scanning to another available device (i.e. phone).
1008
+
1009
+ #### 1. "From other phone" action may be configured on the start screen:
1010
+ - configure [backend reprocessing](#backend-reprocessing)
1011
+ - add 'delegateURL' and 'tag':
1012
+ ```javascript
1013
+ processor.recognizerProcessParam = {
1014
+ delegateURL: 'https://your-page.com?tag={tag}', // the page which will be used by other device
1015
+ tag: 123 // your session id, will be added to delegateURL in place of {tag} substring
1016
+ }
1017
+ ```
1018
+ - these settings will unlock "From other phone" option
1019
+
1020
+ ![Delegate action](./docs/document-reader-delegate-button.jpg)
1021
+
1022
+ that shows the user QR Code with url (i.e. `https://your-page.com?tag=123`)
1023
+
1024
+ ![Delegate mode](./docs/document-reader-delegate-mode.jpg)
1025
+ - the component will emit **REMOTE_TRANSACTION_UPLOADED** event with the most recent transaction uploaded with your session tag.
1026
+ 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))
1027
+ - the component will emit **REMOTE_PROCESS_FINISHED** event with a result of the most recent processed transaction.
1028
+ It is similar to **PROCESS_FINISHED** event but may contain more data due to backend reprocessing
1029
+
1030
+ #### 2. Configure Delegate page component on delegateURL:
1031
+ - configure [backend reprocessing](#backend-reprocessing)
1032
+ - use the same tag as on the main page
1033
+ ```javascript
1034
+ window.RegulaDocumentSDK.recognizerProcessParam = {
1035
+ tag: 123 // your session id, i.e. it can be extracted from your delegate page URL
1036
+ };
1037
+
1038
+ element.settings = {
1039
+ startScreen: false, // From camera recognition is expected
1040
+ }
1041
+ ```
1042
+ - use finalizePackage() to send the data for further reprocessing
1043
+
978
1044
 
979
1045
  ### Appearance Customization
980
1046
 
@@ -1032,48 +1098,49 @@ body.append(element);
1032
1098
 
1033
1099
  See the following table with localized labels, used in the components.
1034
1100
 
1035
- | Label | Default message in `en` locale | Used in |
1036
- |:------------------------------|:---------------------------------------------------------------------------------------------|:------------------------------------:|
1037
- | **success** | Success! | `document-reader`, `camera-snapshot` |
1038
- | **fileCorrupt** | This file is corrupt or not supported | `document-reader`, `camera-snapshot` |
1039
- | **selectAnotherFile** | Please select another file | `document-reader`, `camera-snapshot` |
1040
- | **error** | Error! | `document-reader`, `camera-snapshot` |
1041
- | **somethingWentWrong** | Something went wrong | `document-reader`, `camera-snapshot` |
1042
- | **tryAgain** | Try again | `document-reader`, `camera-snapshot` |
1043
- | **fromCamera** | From camera | `document-reader`, `camera-snapshot` |
1044
- | **fromGallery** | From gallery | `document-reader`, `camera-snapshot` |
1045
- | **cameraUnavailable** | Camera unavailable! | `document-reader`, `camera-snapshot` |
1046
- | **preparingCamera** | Preparing the camera... | `document-reader`, `camera-snapshot` |
1047
- | **noCameraAvailable** | No camera available | `document-reader`, `camera-snapshot` |
1048
- | **incorrectCameraId** | No camera with the specified ID found. | `document-reader`, `camera-snapshot` |
1049
- | **allowAccessToCamera** | Allow access to the camera and reload this page to continue. | `document-reader`, `camera-snapshot` |
1050
- | **cameraConnection** | Make sure the camera is connected correctly. | `document-reader`, `camera-snapshot` |
1051
- | **checkCameraId** | Check if the specified camera ID is correct. | `document-reader`, `camera-snapshot` |
1052
- | **scanIDInBrowser** | Scan an ID in your browser | `document-reader` |
1053
- | **useYourDeviceCamera** | Use your device camera to scan a document or select a photo of the document from the gallery | `document-reader` |
1054
- | **processingFinished** | Processing finished. | `document-reader` |
1055
- | **largeFile** | This file is too large to be uploaded | `document-reader` |
1056
- | **selectSmallerFile** | Please select a smaller file | `document-reader` |
1057
- | **versionNotSupported** | Your browser version is not supported | `document-reader` |
1058
- | **updateBrowser** | Update your browser version | `document-reader` |
1059
- | **licenseError** | A license error has occurred | `document-reader` |
1060
- | **licenseExpired** | The license cannot be found or has expired | `document-reader` |
1061
- | **timeout** | Timeout | `document-reader` |
1062
- | **processing** | Processing... | `document-reader` |
1063
- | **preparingService** | Preparing the service... | `document-reader` |
1064
- | **placeDocumentIntoFrame** | Fit the document into the frame | `document-reader` |
1065
- | **noFocus** | No camera focus | `document-reader` |
1066
- | **moveCloser** | Move closer | `document-reader` |
1067
- | **glaresOnDocument** | Avoid glare on the document | `document-reader` |
1068
- | **holdDocumentStraight** | Hold the document straight | `document-reader` |
1069
- | **documentProcessing** | Document processing... | `document-reader` |
1070
- | **flipDocument** | Flip the document | `document-reader` |
1071
- | **verified** | Verified! | `document-reader` |
1072
- | **keepDeviceStill** | Hold the device still | `document-reader` |
1073
- | **positionDocumentCenter** | Position the document in the center | `camera-snapshot` |
1074
- | **photoCapturedSuccessfully** | The photo is captured successfully. | `camera-snapshot` |
1075
- | **uploadPhoto** | Upload a photo | `camera-snapshot` |
1076
- | **useCameraOrGallery** | Use your device camera or select a photo from the gallery | `camera-snapshot` |
1101
+ | Label | Default message in `en` locale | Used in |
1102
+ |:-------------------------------|:---------------------------------------------------------------------------------------------|:------------------------------------:|
1103
+ | **success** | Success! | `document-reader`, `camera-snapshot` |
1104
+ | **fileCorrupt** | This file is corrupt or not supported | `document-reader`, `camera-snapshot` |
1105
+ | **selectAnotherFile** | Please select another file | `document-reader`, `camera-snapshot` |
1106
+ | **error** | Error! | `document-reader`, `camera-snapshot` |
1107
+ | **somethingWentWrong** | Something went wrong | `document-reader`, `camera-snapshot` |
1108
+ | **tryAgain** | Try again | `document-reader`, `camera-snapshot` |
1109
+ | **fromCamera** | From camera | `document-reader`, `camera-snapshot` |
1110
+ | **fromGallery** | From gallery | `document-reader`, `camera-snapshot` |
1111
+ | **fromOtherPhone** | From other phone | `document-reader`, `camera-snapshot` |
1112
+ | **cameraUnavailable** | Camera unavailable! | `document-reader`, `camera-snapshot` |
1113
+ | **preparingCamera** | Preparing the camera... | `document-reader`, `camera-snapshot` |
1114
+ | **noCameraAvailable** | No camera available | `document-reader`, `camera-snapshot` |
1115
+ | **incorrectCameraId** | No camera with the specified ID found. | `document-reader`, `camera-snapshot` |
1116
+ | **allowAccessToCamera** | Allow access to the camera and reload this page to continue. | `document-reader`, `camera-snapshot` |
1117
+ | **cameraConnection** | Make sure the camera is connected correctly. | `document-reader`, `camera-snapshot` |
1118
+ | **checkCameraId** | Check if the specified camera ID is correct. | `document-reader`, `camera-snapshot` |
1119
+ | **scanIDInBrowser** | Scan an ID in your browser | `document-reader` |
1120
+ | **useYourDeviceCamera** | Use your device camera to scan a document or select a photo of the document from the gallery | `document-reader` |
1121
+ | **processingFinished** | Processing finished. | `document-reader` |
1122
+ | **largeFile** | This file is too large to be uploaded | `document-reader` |
1123
+ | **selectSmallerFile** | Please select a smaller file | `document-reader` |
1124
+ | **versionNotSupported** | Your browser version is not supported | `document-reader` |
1125
+ | **updateBrowser** | Update your browser version | `document-reader` |
1126
+ | **licenseError** | A license error has occurred | `document-reader` |
1127
+ | **licenseExpired** | The license cannot be found or has expired | `document-reader` |
1128
+ | **timeout** | Timeout | `document-reader` |
1129
+ | **processing** | Processing... | `document-reader` |
1130
+ | **preparingService** | Preparing the service... | `document-reader` |
1131
+ | **placeDocumentIntoFrame** | Fit the document into the frame | `document-reader` |
1132
+ | **noFocus** | No camera focus | `document-reader` |
1133
+ | **moveCloser** | Move closer | `document-reader` |
1134
+ | **glaresOnDocument** | Avoid glare on the document | `document-reader` |
1135
+ | **holdDocumentStraight** | Hold the document straight | `document-reader` |
1136
+ | **documentProcessing** | Document processing... | `document-reader` |
1137
+ | **flipDocument** | Flip the document | `document-reader` |
1138
+ | **verified** | Verified! | `document-reader` |
1139
+ | **keepDeviceStill** | Hold the device still | `document-reader` |
1140
+ | **positionDocumentCenter** | Position the document in the center | `camera-snapshot` |
1141
+ | **photoCapturedSuccessfully** | The photo is captured successfully. | `camera-snapshot` |
1142
+ | **uploadPhoto** | Upload a photo | `camera-snapshot` |
1143
+ | **useCameraOrGallery** | Use your device camera or select a photo from the gallery | `camera-snapshot` |
1077
1144
 
1078
1145
  ## Document Reader Processor
1079
1146
 
package/dist/index.d.ts CHANGED
@@ -27,7 +27,7 @@ declare enum CameraSnapshotAttributes {
27
27
  closeButton = "close-button"
28
28
  }
29
29
 
30
- export declare type CameraSnapshotDetailType = DetailEvent<EventActions, CameraSnapshotResponseType>;
30
+ export declare type CameraSnapshotDetailType = DetailEvent<Exclude<EventActions, EventActions.REMOTE_TRANSACTION_UPLOADED>, CameraSnapshotResponseType>;
31
31
 
32
32
  export declare type CameraSnapshotResponseType = Array<{
33
33
  raw: string;
@@ -118,7 +118,7 @@ export declare class DocumentReaderCaptureWebComponent extends HTMLElement {
118
118
  disconnectedCallback(): void;
119
119
  }
120
120
 
121
- export declare type DocumentReaderDetailType = DetailEvent<EventActions, DocumentReaderResponseType>;
121
+ export declare type DocumentReaderDetailType = DetailEvent<Exclude<EventActions, EventActions.REMOTE_TRANSACTION_UPLOADED>, DocumentReaderResponseType>;
122
122
 
123
123
  export declare interface DocumentReaderImage {
124
124
  data: string;
@@ -383,6 +383,7 @@ export declare enum EventActions {
383
383
  PRESS_SKIP_BUTTON = "PRESS_SKIP_BUTTON",
384
384
  PRESS_CAPTURE_BUTTON = "PRESS_CAPTURE_BUTTON",
385
385
  PRESS_CHANGE_CAMERA_BUTTON = "PRESS_CHANGE_CAMERA_BUTTON",
386
+ PRESS_REMOTE_DEVICE_BUTTON = "PRESS_REMOTE_DEVICE_BUTTON",
386
387
  PRESS_MIRRORING_BUTTON = "PRESS_MIRRORING_BUTTON",
387
388
  PRESS_CONNECT_BUTTON = "PRESS_CONNECT_BUTTON",
388
389
  PRESS_DISCONNECT_BUTTON = "PRESS_DISCONNECT_BUTTON",
@@ -398,7 +399,9 @@ export declare enum EventActions {
398
399
  FILE_PROCESS_STARTED = "FILE_PROCESS_STARTED",
399
400
  PROCESS_STARTED = "PROCESS_STARTED",
400
401
  PROCESS_FINISHED = "PROCESS_FINISHED",
401
- SERVICE_INITIALIZED = "SERVICE_INITIALIZED"
402
+ SERVICE_INITIALIZED = "SERVICE_INITIALIZED",
403
+ REMOTE_TRANSACTION_UPLOADED = "REMOTE_TRANSACTION_UPLOADED",
404
+ REMOTE_PROCESS_FINISHED = "REMOTE_PROCESS_FINISHED"
402
405
  }
403
406
 
404
407
  export declare enum FrameLineCap {
@@ -506,6 +509,7 @@ export declare interface PackageParams {
506
509
 
507
510
  export declare interface ProcessingRequest extends BaseRequest {
508
511
  metadata?: Record<string, any>;
512
+ delegateURL?: string;
509
513
  processParam: DocumentReaderProcessParam;
510
514
  imagesList?: Array<DocumentReaderImage>;
511
515
  imageInputParam?: ImageInputParamType;
@@ -542,11 +546,32 @@ declare type TProcessingListener = ({ isProcessing }: {
542
546
  isProcessing: boolean;
543
547
  }) => void;
544
548
 
549
+ export declare interface TransactionEvent {
550
+ action: EventActions.REMOTE_TRANSACTION_UPLOADED;
551
+ data: TransactionStatusInfo;
552
+ }
553
+
545
554
  export declare interface TransactionInfo {
546
555
  tag: string;
547
556
  transactionId: string;
548
557
  }
549
558
 
559
+ export declare type TransactionsListResponse = {
560
+ items: TransactionStatusInfo[];
561
+ };
562
+
563
+ export declare enum TransactionStateStatus {
564
+ STARTED = 0,
565
+ UPLOADED = 1,
566
+ PROCESSED = 2
567
+ }
568
+
569
+ export declare type TransactionStatusInfo = {
570
+ id: number;
571
+ state: TransactionStateStatus;
572
+ updatedAt: string;
573
+ };
574
+
550
575
  export declare type TScenarioParams = {
551
576
  name: string;
552
577
  desc: string;
@@ -584,7 +609,7 @@ export { }
584
609
 
585
610
  declare global {
586
611
  interface HTMLElementEventMap {
587
- 'document-reader': CustomEvent<DocumentReaderDetailType>;
612
+ 'document-reader': CustomEvent<DocumentReaderDetailType | TransactionEvent>;
588
613
  'camera-snapshot': CustomEvent<CameraSnapshotDetailType>;
589
614
  }
590
615
  interface Window {