@trulioo/docv-capture-web 2.13.1 → 2.14.1

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,16 +153,17 @@ 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
 
129
160
 
130
161
 
131
162
  ```javascript showLineNumbers
132
- // As an example, we will submit the captured image for document verification if the post capture feedback returns a CAN_BE_PROCESSED status.
133
- result.verifyImage().then((verifyFeedback: TruliooVerifyResponse) => {
134
- if (verifyFeedback.verificationStatus == VerificationStatus.CAN_BE_PROCESSED) {
163
+ // As an example, we will submit the captured image for document verification if the post capture feedback documentVerifyResponse.documentTypeAccepted is not RESULT_CHECK_DECLINED.
164
+ // Note that the documentVerifyResponse will have more than just documentTypeAccepted, the below code is just an example of just checking for documentTypeAccepted.
165
+ result.verifyImage().then((verifyFeedback: TruliooVerifyFeedback) => {
166
+ if (verifyFeedback.documentVerifyResponse.documentTypeAccepted !== ResultCheck.RESULT_CHECK_DECLINED) {
135
167
  // Note that the acceptImage can be called outside of the verifyImage function.
136
168
  result.acceptImage().then((status: boolean) => {
137
169
  console.log("Successfully submitted the image")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trulioo/docv-capture-web",
3
- "version": "2.13.1",
3
+ "version": "2.14.1",
4
4
  "main": "trulioo-docv-capture-web.js",
5
5
  "types": "trulioo-docv-capture-web.d.ts",
6
6
  "devDependencies": {
@@ -40,46 +40,37 @@ export declare namespace com.trulioo.docv.core.workflow {
40
40
  equals(other: Nullable<any>): boolean;
41
41
  }
42
42
  }
43
- export declare class TruliooCamera /* extends capture.Camera */ {
44
- constructor(cameraId: string, cameraDetectionType: DetectionType);
45
- get id(): string;
46
- get detectionType(): DetectionType;
47
- removeCamera(): void;
48
- renderCamera(parentElementId: string, cameraProps?: Nullable<CameraProps>): Promise<boolean>;
43
+ export declare class TruliooError extends Error {
44
+ constructor(code?: number, message?: string);
45
+ get code(): number;
49
46
  }
50
- export declare class CameraProps {
51
- constructor(onCaptureRegionChange: Nullable<(p0: CaptureRegion) => void>);
52
- get onCaptureRegionChange(): Nullable<(p0: CaptureRegion) => void>;
53
- copy(onCaptureRegionChange?: Nullable<(p0: CaptureRegion) => void>): CameraProps;
54
- toString(): string;
55
- hashCode(): number;
56
- equals(other: Nullable<any>): boolean;
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;
57
56
  }
58
- export declare interface CaptureRegion {
59
- readonly bottomRight: PointCoordinates;
60
- readonly center: PointCoordinates;
61
- readonly selfieRadius: number;
62
- readonly topLeft: PointCoordinates;
63
- readonly __doNotUseOrImplementIt: {
64
- readonly CaptureRegion: unique symbol;
65
- };
57
+ export declare class ConfigurationError extends TruliooError {
58
+ constructor(message: string);
59
+ get code(): number;
66
60
  }
67
- export declare interface PointCoordinates {
68
- readonly x: number;
69
- readonly y: number;
70
- readonly __doNotUseOrImplementIt: {
71
- readonly PointCoordinates: unique symbol;
72
- };
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;
73
70
  }
74
- export declare class TruliooCapture {
75
- constructor();
76
- initialize(shortCode: string, previewMode?: boolean): Promise<string>;
77
- getCameraComponent(config?: Nullable<TruliooCameraConfig>): TruliooCamera;
78
- startFeedback(cameraId: string, imageFeedback?: Nullable<(p0: TruliooImageFeedback) => void>): Promise<TruliooCaptureResponse>;
79
- stopFeedback(cameraId: string): Promise<boolean>;
80
- onFeedbackState(feedback: (p0: TruliooFeedbackState) => void): void;
81
- captureLatestFrame(): Promise<TruliooCaptureResponse>;
82
- submitTransaction(): Promise<boolean>;
71
+ export declare class GenericError extends TruliooError {
72
+ constructor(message: string);
73
+ get code(): number;
83
74
  }
84
75
  export declare interface TruliooCameraConfig {
85
76
  readonly detectionType: DetectionType;
@@ -110,65 +101,57 @@ export declare abstract class DetectionType {
110
101
  get name(): "DOCUMENT" | "PASSPORT" | "BIOMETRIC_SELFIE" | "NO_DETECTION";
111
102
  get ordinal(): 0 | 1 | 2 | 3;
112
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
+ }
113
112
  export declare interface TruliooImageFeedback {
114
113
  readonly imageId: string;
115
114
  readonly detectionType: DetectionType;
116
115
  readonly hasAcceptableQuality: boolean;
117
116
  readonly hasBlur: boolean;
118
117
  readonly hasDetection: boolean;
118
+ readonly requiresBackCapture: boolean;
119
+ readonly tooClose: boolean;
120
+ readonly tooFar: boolean;
119
121
  readonly __doNotUseOrImplementIt: {
120
122
  readonly TruliooImageFeedback: unique symbol;
121
123
  };
122
124
  }
123
- export declare interface TruliooCaptureResponse extends TruliooImageFeedback {
125
+ export declare interface TruliooCaptureResponse extends CaptureResponse, TruliooImageFeedback {
126
+ readonly imageId: string;
124
127
  readonly acceptImage: () => Promise<boolean>;
125
- readonly requiresBackCapture: boolean;
126
- readonly tooClose: boolean;
127
- readonly tooFar: boolean;
128
128
  readonly verifyImage: () => Promise<TruliooVerifyFeedback>;
129
- readonly imageId: string;
130
129
  readonly detectionType: DetectionType;
131
130
  readonly hasAcceptableQuality: boolean;
132
131
  readonly hasBlur: boolean;
133
132
  readonly hasDetection: boolean;
133
+ readonly requiresBackCapture: boolean;
134
+ readonly tooClose: boolean;
135
+ readonly tooFar: boolean;
134
136
  readonly __doNotUseOrImplementIt: {
135
137
  readonly TruliooCaptureResponse: unique symbol;
136
- } & 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"];
137
147
  }
138
148
  export declare interface TruliooVerifyFeedback {
139
149
  readonly isVerifyAttemptAvailable: boolean;
140
- readonly verificationStatus: VerificationStatus;
150
+ readonly documentVerifyResponse: DocumentVerifyResponse;
141
151
  readonly __doNotUseOrImplementIt: {
142
152
  readonly TruliooVerifyFeedback: unique symbol;
143
153
  };
144
154
  }
145
- export declare abstract class VerificationStatus {
146
- private constructor();
147
- static get CAN_BE_PROCESSED(): VerificationStatus & {
148
- get name(): "CAN_BE_PROCESSED";
149
- get ordinal(): 0;
150
- };
151
- static get CANNOT_BE_CLASSIFIED(): VerificationStatus & {
152
- get name(): "CANNOT_BE_CLASSIFIED";
153
- get ordinal(): 1;
154
- };
155
- static get UNSUPPORTED_DOCUMENT(): VerificationStatus & {
156
- get name(): "UNSUPPORTED_DOCUMENT";
157
- get ordinal(): 2;
158
- };
159
- static get EXPIRED_DOCUMENT(): VerificationStatus & {
160
- get name(): "EXPIRED_DOCUMENT";
161
- get ordinal(): 3;
162
- };
163
- static get ERROR(): VerificationStatus & {
164
- get name(): "ERROR";
165
- get ordinal(): 4;
166
- };
167
- static values(): Array<VerificationStatus>;
168
- static valueOf(value: string): VerificationStatus;
169
- get name(): "CAN_BE_PROCESSED" | "CANNOT_BE_CLASSIFIED" | "UNSUPPORTED_DOCUMENT" | "EXPIRED_DOCUMENT" | "ERROR";
170
- get ordinal(): 0 | 1 | 2 | 3 | 4;
171
- }
172
155
  export declare abstract class TruliooFeedbackState {
173
156
  private constructor();
174
157
  static get NONE(): TruliooFeedbackState & {
@@ -204,4 +187,121 @@ export declare abstract class TruliooFeedbackState {
204
187
  get name(): "NONE" | "CAPTURING" | "BLUR" | "SUCCESS" | "ERROR" | "TOO_CLOSE" | "TOO_FAR";
205
188
  get ordinal(): 0 | 1 | 2 | 3 | 4 | 5 | 6;
206
189
  }
190
+ export declare abstract class ResultCheck {
191
+ private constructor();
192
+ static get RESULT_CHECK_UNSPECIFIED(): ResultCheck & {
193
+ get name(): "RESULT_CHECK_UNSPECIFIED";
194
+ get ordinal(): 0;
195
+ };
196
+ static get RESULT_CHECK_DECLINED(): ResultCheck & {
197
+ get name(): "RESULT_CHECK_DECLINED";
198
+ get ordinal(): 1;
199
+ };
200
+ static get RESULT_CHECK_ACCEPTED(): ResultCheck & {
201
+ get name(): "RESULT_CHECK_ACCEPTED";
202
+ get ordinal(): 2;
203
+ };
204
+ static values(): Array<ResultCheck>;
205
+ static valueOf(value: string): ResultCheck;
206
+ get name(): "RESULT_CHECK_UNSPECIFIED" | "RESULT_CHECK_DECLINED" | "RESULT_CHECK_ACCEPTED";
207
+ get ordinal(): 0 | 1 | 2;
208
+ }
209
+ export declare abstract class DocumentExpirationCheck {
210
+ private constructor();
211
+ static get DOCUMENT_EXPIRATION_CHECK_UNSPECIFIED(): DocumentExpirationCheck & {
212
+ get name(): "DOCUMENT_EXPIRATION_CHECK_UNSPECIFIED";
213
+ get ordinal(): 0;
214
+ };
215
+ static get DOCUMENT_EXPIRATION_CHECK_EXPIRED(): DocumentExpirationCheck & {
216
+ get name(): "DOCUMENT_EXPIRATION_CHECK_EXPIRED";
217
+ get ordinal(): 1;
218
+ };
219
+ static get DOCUMENT_EXPIRATION_CHECK_VALID(): DocumentExpirationCheck & {
220
+ get name(): "DOCUMENT_EXPIRATION_CHECK_VALID";
221
+ get ordinal(): 2;
222
+ };
223
+ static values(): Array<DocumentExpirationCheck>;
224
+ static valueOf(value: string): DocumentExpirationCheck;
225
+ get name(): "DOCUMENT_EXPIRATION_CHECK_UNSPECIFIED" | "DOCUMENT_EXPIRATION_CHECK_EXPIRED" | "DOCUMENT_EXPIRATION_CHECK_VALID";
226
+ get ordinal(): 0 | 1 | 2;
227
+ }
228
+ export declare abstract class BackImageRequirement {
229
+ private constructor();
230
+ static get BACK_IMAGE_REQUIREMENT_UNSPECIFIED(): BackImageRequirement & {
231
+ get name(): "BACK_IMAGE_REQUIREMENT_UNSPECIFIED";
232
+ get ordinal(): 0;
233
+ };
234
+ static get BACK_IMAGE_REQUIREMENT_NOT_REQUIRED(): BackImageRequirement & {
235
+ get name(): "BACK_IMAGE_REQUIREMENT_NOT_REQUIRED";
236
+ get ordinal(): 1;
237
+ };
238
+ static get BACK_IMAGE_REQUIREMENT_REQUIRED(): BackImageRequirement & {
239
+ get name(): "BACK_IMAGE_REQUIREMENT_REQUIRED";
240
+ get ordinal(): 2;
241
+ };
242
+ static values(): Array<BackImageRequirement>;
243
+ static valueOf(value: string): BackImageRequirement;
244
+ get name(): "BACK_IMAGE_REQUIREMENT_UNSPECIFIED" | "BACK_IMAGE_REQUIREMENT_NOT_REQUIRED" | "BACK_IMAGE_REQUIREMENT_REQUIRED";
245
+ get ordinal(): 0 | 1 | 2;
246
+ }
247
+ export declare class DocumentVerifyResponse {
248
+ constructor(documentDetected: ResultCheck, documentTypeAccepted: ResultCheck, documentCountryAccepted: ResultCheck, documentJurisdictionAccepted: ResultCheck, blur: ResultCheck, glare: ResultCheck, skewed: ResultCheck, bright: ResultCheck, documentExpirationCheck: DocumentExpirationCheck, backImageRequirement: BackImageRequirement);
249
+ get documentDetected(): ResultCheck;
250
+ get documentTypeAccepted(): ResultCheck;
251
+ get documentCountryAccepted(): ResultCheck;
252
+ get documentJurisdictionAccepted(): ResultCheck;
253
+ get blur(): ResultCheck;
254
+ get glare(): ResultCheck;
255
+ get skewed(): ResultCheck;
256
+ get bright(): ResultCheck;
257
+ get documentExpirationCheck(): DocumentExpirationCheck;
258
+ get backImageRequirement(): BackImageRequirement;
259
+ copy(documentDetected?: ResultCheck, documentTypeAccepted?: ResultCheck, documentCountryAccepted?: ResultCheck, documentJurisdictionAccepted?: ResultCheck, blur?: ResultCheck, glare?: ResultCheck, skewed?: ResultCheck, bright?: ResultCheck, documentExpirationCheck?: DocumentExpirationCheck, backImageRequirement?: BackImageRequirement): DocumentVerifyResponse;
260
+ toString(): string;
261
+ hashCode(): number;
262
+ equals(other: Nullable<any>): boolean;
263
+ }
264
+ export declare class TruliooCamera /* extends capture.Camera */ {
265
+ constructor(cameraId: string, cameraDetectionType: DetectionType);
266
+ get id(): string;
267
+ get detectionType(): DetectionType;
268
+ removeCamera(): void;
269
+ renderCamera(parentElementId: string, cameraProps?: Nullable<CameraProps>): Promise<boolean>;
270
+ resumeCamera(): void;
271
+ }
272
+ export declare class CameraProps {
273
+ constructor(onCaptureRegionChange: Nullable<(p0: CaptureRegion) => void>);
274
+ get onCaptureRegionChange(): Nullable<(p0: CaptureRegion) => void>;
275
+ copy(onCaptureRegionChange?: Nullable<(p0: CaptureRegion) => void>): CameraProps;
276
+ toString(): string;
277
+ hashCode(): number;
278
+ equals(other: Nullable<any>): boolean;
279
+ }
280
+ export declare interface CaptureRegion {
281
+ readonly bottomRight: PointCoordinates;
282
+ readonly center: PointCoordinates;
283
+ readonly selfieRadius: number;
284
+ readonly topLeft: PointCoordinates;
285
+ readonly __doNotUseOrImplementIt: {
286
+ readonly CaptureRegion: unique symbol;
287
+ };
288
+ }
289
+ export declare interface PointCoordinates {
290
+ readonly x: number;
291
+ readonly y: number;
292
+ readonly __doNotUseOrImplementIt: {
293
+ readonly PointCoordinates: unique symbol;
294
+ };
295
+ }
296
+ export declare class TruliooCapture {
297
+ constructor();
298
+ initialize(shortCode: string, previewMode?: boolean): Promise<string>;
299
+ getCameraComponent(config?: Nullable<TruliooCameraConfig>): TruliooCamera;
300
+ startFeedback(cameraId: string, imageFeedback?: Nullable<(p0: TruliooImageFeedback) => void>): Promise<TruliooCaptureResponse>;
301
+ stopFeedback(cameraId: string): Promise<boolean>;
302
+ onFeedbackState(feedback: (p0: TruliooFeedbackState) => void): void;
303
+ captureLatestFrame(cameraId: string): Promise<TruliooManualCaptureResponse>;
304
+ submitTransaction(): Promise<boolean>;
305
+ static stopOngoingCaptureProcess$default($this: TruliooCapture, cameraController: any/* capture.CameraController */, isManual?: boolean): void;
306
+ }
207
307
  export as namespace trulioo_docv_capture_web;