@trulioo/docv-capture-web 2.14.0 → 2.14.2

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
@@ -60,12 +60,18 @@ documentCamera.renderCamera("parent-element-id", cameraProps).then((_) => {
60
60
  })
61
61
  ```
62
62
 
63
- To remove/unrender the current camera on the screen, call the `removeCamera` function.
63
+ To remove the current camera on the screen, call the `removeCamera` function.
64
64
 
65
65
  ```javascript showLineNumbers
66
66
  documentCamera.removeCamera()
67
67
  ```
68
68
 
69
+ Additionally, if we want to resume the camera feed again after a successful auto or manual capture, we can call the `resumeCamera` function.
70
+
71
+ ```javascript showLineNumbers
72
+ documentCamera.resumeCamera()
73
+ ```
74
+
69
75
  ### Starting the document capture flow
70
76
 
71
77
 
@@ -77,7 +83,7 @@ currently active/rendered camera component. The promise will only resolve when t
77
83
 
78
84
  ```javascript showLineNumbers
79
85
  truliooCapture.startFeedback(documentCamera.id).then((result: TruliooCaptureResponse) => {
80
- console.log(`Succesfully captured a good image: ${result}`)
86
+ console.log(`Succesfully captured a good image with imageId: ${result.imageId}`)
81
87
  })
82
88
  ```
83
89
 
@@ -87,7 +93,32 @@ We can also stop the feedback by calling the `stopFeedback` function. This will
87
93
  truliooCapture.stopFeedback(documentCamera.id)
88
94
 
89
95
  ```
96
+ Note that if the `stopFeedback` function is called during an ongoing `startFeedback` promise, the `startFeedback` promise is expected to be rejected with the specific `FeedbackStopped` error.
97
+ It is recommended to check this specific error to make sure it is not treated as an unexpected error.
90
98
 
99
+ ```javascript showLineNumbers
100
+ import { HandledError } from '@trulioo/docv-capture-web'
101
+
102
+ truliooCapture.startFeedback(documentCamera.id).then((result: TruliooCaptureResponse) => {
103
+ console.log(`Succesfully captured a good image with imageId: ${result.imageId}`)
104
+ }).catch((error: unknown) => {
105
+ if (error == HandledError.FeedbackStopped) {
106
+ console.log("startFeedback is stopped.")
107
+ } else {
108
+ // Other error handling
109
+ }
110
+ })
111
+ ```
112
+
113
+ Additionally, if we want to do a manual capture instead. We can call the `captureLatestFrame` function. This will return a `TruliooManualCaptureResponse` that is similar to the `TruliooCaptureResponse` excluding the auto capture specific fields.
114
+ Note that we would want to make sure the camera feed is currently running before triggering the manual capture, hence we can resume the camera again after a successful auto or manual capture using the `resumeCamera` function if we want to trigger another capture.
115
+
116
+ ```javascript showLineNumbers
117
+ truliooCapture.captureLatestFrame(documentCamera.id).then((result: TruliooManualCaptureResponse) => {
118
+ console.log(`Succesfully captured an image with manual capture with imageId: ${result.imageId}`)
119
+ })
120
+
121
+ ```
91
122
 
92
123
  The SDK also provides the `onFeedbackState` function that we can listen to for the ongoing capture state updates that is started by the `startFeedback` function.
93
124
  This allows us to add any logic needed or render any necessary custom UI needed based on the current capture state.
@@ -122,7 +153,7 @@ Note that the above flow is the same for the selfie capture type too.
122
153
  ### Analysing the captured image result through post capture verify feedback
123
154
 
124
155
 
125
- Once we have the resulting `TruliooCaptureResponse` image data, we are able to get a post capture feedback by simply calling the `verifyImage` function that is
156
+ Once we have the resulting `TruliooCaptureResponse` or `TruliooManualCaptureResponse` image data, we are able to get a post capture feedback by simply calling the `verifyImage` function that is
126
157
  part of the response data. This will give use more information regarding the captured image and let us decide whether we should submit the captured image for
127
158
  verification by calling the `acceptImage` function.
128
159
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trulioo/docv-capture-web",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "main": "trulioo-docv-capture-web.js",
5
5
  "types": "trulioo-docv-capture-web.d.ts",
6
6
  "devDependencies": {
@@ -15,10 +15,10 @@
15
15
  "@connectrpc/connect": "1.4.0",
16
16
  "@connectrpc/connect-web": "1.4.0",
17
17
  "@bufbuild/protobuf": "1.10.0",
18
- "format-util": "^1.0.5",
19
18
  "node-fetch": "2.6.7",
20
19
  "abort-controller": "3.0.0",
21
20
  "ws": "8.5.0",
21
+ "format-util": "^1.0.5",
22
22
  "@js-joda/core": "3.2.0"
23
23
  },
24
24
  "dependencies": {},
@@ -40,6 +40,38 @@ export declare namespace com.trulioo.docv.core.workflow {
40
40
  equals(other: Nullable<any>): boolean;
41
41
  }
42
42
  }
43
+ export declare class TruliooError extends Error {
44
+ constructor(code?: number, message?: string);
45
+ get code(): number;
46
+ }
47
+ export declare abstract class NetworkError extends TruliooError {
48
+ protected constructor();
49
+ get code(): number;
50
+ static get NoInternet(): {
51
+ get code(): number;
52
+ toString(): string;
53
+ hashCode(): number;
54
+ equals(other: Nullable<any>): boolean;
55
+ } & NetworkError;
56
+ }
57
+ export declare class ConfigurationError extends TruliooError {
58
+ constructor(message: string);
59
+ get code(): number;
60
+ }
61
+ export declare abstract class HandledError extends TruliooError {
62
+ protected constructor();
63
+ get code(): number;
64
+ static get FeedbackStopped(): {
65
+ get code(): number;
66
+ toString(): string;
67
+ hashCode(): number;
68
+ equals(other: Nullable<any>): boolean;
69
+ } & HandledError;
70
+ }
71
+ export declare class GenericError extends TruliooError {
72
+ constructor(message: string);
73
+ get code(): number;
74
+ }
43
75
  export declare interface TruliooCameraConfig {
44
76
  readonly detectionType: DetectionType;
45
77
  readonly __doNotUseOrImplementIt: {
@@ -69,30 +101,49 @@ export declare abstract class DetectionType {
69
101
  get name(): "DOCUMENT" | "PASSPORT" | "BIOMETRIC_SELFIE" | "NO_DETECTION";
70
102
  get ordinal(): 0 | 1 | 2 | 3;
71
103
  }
104
+ export declare interface CaptureResponse {
105
+ readonly imageId: string;
106
+ readonly acceptImage: () => Promise<boolean>;
107
+ readonly verifyImage: () => Promise<TruliooVerifyFeedback>;
108
+ readonly __doNotUseOrImplementIt: {
109
+ readonly CaptureResponse: unique symbol;
110
+ };
111
+ }
72
112
  export declare interface TruliooImageFeedback {
73
113
  readonly imageId: string;
74
114
  readonly detectionType: DetectionType;
75
115
  readonly hasAcceptableQuality: boolean;
76
116
  readonly hasBlur: boolean;
77
117
  readonly hasDetection: boolean;
118
+ readonly requiresBackCapture: boolean;
119
+ readonly tooClose: boolean;
120
+ readonly tooFar: boolean;
78
121
  readonly __doNotUseOrImplementIt: {
79
122
  readonly TruliooImageFeedback: unique symbol;
80
123
  };
81
124
  }
82
- export declare interface TruliooCaptureResponse extends TruliooImageFeedback {
125
+ export declare interface TruliooCaptureResponse extends CaptureResponse, TruliooImageFeedback {
126
+ readonly imageId: string;
83
127
  readonly acceptImage: () => Promise<boolean>;
84
- readonly requiresBackCapture: boolean;
85
- readonly tooClose: boolean;
86
- readonly tooFar: boolean;
87
128
  readonly verifyImage: () => Promise<TruliooVerifyFeedback>;
88
- readonly imageId: string;
89
129
  readonly detectionType: DetectionType;
90
130
  readonly hasAcceptableQuality: boolean;
91
131
  readonly hasBlur: boolean;
92
132
  readonly hasDetection: boolean;
133
+ readonly requiresBackCapture: boolean;
134
+ readonly tooClose: boolean;
135
+ readonly tooFar: boolean;
93
136
  readonly __doNotUseOrImplementIt: {
94
137
  readonly TruliooCaptureResponse: unique symbol;
95
- } & TruliooImageFeedback["__doNotUseOrImplementIt"];
138
+ } & CaptureResponse["__doNotUseOrImplementIt"] & TruliooImageFeedback["__doNotUseOrImplementIt"];
139
+ }
140
+ export declare interface TruliooManualCaptureResponse extends CaptureResponse {
141
+ readonly imageId: string;
142
+ readonly acceptImage: () => Promise<boolean>;
143
+ readonly verifyImage: () => Promise<TruliooVerifyFeedback>;
144
+ readonly __doNotUseOrImplementIt: {
145
+ readonly TruliooManualCaptureResponse: unique symbol;
146
+ } & CaptureResponse["__doNotUseOrImplementIt"];
96
147
  }
97
148
  export declare interface TruliooVerifyFeedback {
98
149
  readonly isVerifyAttemptAvailable: boolean;
@@ -216,6 +267,7 @@ export declare class TruliooCamera /* extends capture.Camera */ {
216
267
  get detectionType(): DetectionType;
217
268
  removeCamera(): void;
218
269
  renderCamera(parentElementId: string, cameraProps?: Nullable<CameraProps>): Promise<boolean>;
270
+ resumeCamera(): void;
219
271
  }
220
272
  export declare class CameraProps {
221
273
  constructor(onCaptureRegionChange: Nullable<(p0: CaptureRegion) => void>);
@@ -248,7 +300,8 @@ export declare class TruliooCapture {
248
300
  startFeedback(cameraId: string, imageFeedback?: Nullable<(p0: TruliooImageFeedback) => void>): Promise<TruliooCaptureResponse>;
249
301
  stopFeedback(cameraId: string): Promise<boolean>;
250
302
  onFeedbackState(feedback: (p0: TruliooFeedbackState) => void): void;
251
- captureLatestFrame(): Promise<TruliooCaptureResponse>;
303
+ captureLatestFrame(cameraId: string): Promise<TruliooManualCaptureResponse>;
252
304
  submitTransaction(): Promise<boolean>;
305
+ static stopOngoingCaptureProcess$default($this: TruliooCapture, cameraController: any/* capture.CameraController */, isManual?: boolean): void;
253
306
  }
254
307
  export as namespace trulioo_docv_capture_web;