@trulioo/docv-capture-web 2.14.1 → 2.14.3
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 +16 -16
- package/package.json +2 -2
- package/trulioo-docv-capture-web.js +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ const shortCode = "generatedFromTruliooAPI"
|
|
|
17
17
|
const truliooCapture = new TruliooCapture()
|
|
18
18
|
|
|
19
19
|
truliooCapture.initialize(shortCode).then((transactionId) => {
|
|
20
|
-
console.log(`
|
|
20
|
+
console.log(`Successfully initialized with transaction ID: ${transactionId}`)
|
|
21
21
|
}).catch(error => {
|
|
22
22
|
console.log(`Error on initialize: ${error}`)
|
|
23
23
|
})
|
|
@@ -36,7 +36,7 @@ const documentCamera = truliooCapture.getCameraComponent()
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
// To get a selfie detection type camera.
|
|
39
|
-
const selfieCamera =
|
|
39
|
+
const selfieCamera = truliooCapture.getCameraComponent({
|
|
40
40
|
detectionType: DetectionType.BIOMETRIC_SELFIE,
|
|
41
41
|
})
|
|
42
42
|
```
|
|
@@ -44,7 +44,7 @@ const selfieCamera = truliooCaptureSdkInstance.getCameraComponent({
|
|
|
44
44
|
To render the camera component on the screen, we just need to call the `renderCamera` function. This will render a full screen camera on the screen by attaching
|
|
45
45
|
a video element to the parent element based on the provided element id. The `renderCamera` function will resolve when the camera is successfully loaded, otherwise it will reject with an error.
|
|
46
46
|
The `onCaptureRegionChange` callback function is provided, which will return the current capture frame coordinates location (the location on the camera screen where the document/face should be located to do a capture).
|
|
47
|
-
We can utilize this coordinate information to render custom UI overlay.
|
|
47
|
+
We can utilize this coordinate information to render a custom UI overlay.
|
|
48
48
|
|
|
49
49
|
```javascript showLineNumbers
|
|
50
50
|
const cameraProps = new CameraProps(
|
|
@@ -75,15 +75,15 @@ documentCamera.resumeCamera()
|
|
|
75
75
|
### Starting the document capture flow
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
Once the camera component is loaded and ready
|
|
78
|
+
Once the camera component is loaded and ready, we can start the document capture experience by calling `startFeedback` from previously created `TruliooCapture` instance.
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
To do an auto capture experience (a good document/selfie image criteria decided entirely by SDK), we can simply call `startFeedback` by just providing the camera id that refers to the
|
|
82
|
-
currently active/rendered camera component. The promise will only resolve when the SDK
|
|
82
|
+
currently active/rendered camera component. The promise will only resolve when the SDK manages to capture a good image that is presented in front of the camera capture frame.
|
|
83
83
|
|
|
84
84
|
```javascript showLineNumbers
|
|
85
85
|
truliooCapture.startFeedback(documentCamera.id).then((result: TruliooCaptureResponse) => {
|
|
86
|
-
console.log(`
|
|
86
|
+
console.log(`Successfully captured a good image with imageId: ${result.imageId}`)
|
|
87
87
|
})
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -100,10 +100,10 @@ It is recommended to check this specific error to make sure it is not treated as
|
|
|
100
100
|
import { HandledError } from '@trulioo/docv-capture-web'
|
|
101
101
|
|
|
102
102
|
truliooCapture.startFeedback(documentCamera.id).then((result: TruliooCaptureResponse) => {
|
|
103
|
-
console.log(`
|
|
103
|
+
console.log(`Successfully captured a good image with imageId: ${result.imageId}`)
|
|
104
104
|
}).catch((error: unknown) => {
|
|
105
105
|
if (error == HandledError.FeedbackStopped) {
|
|
106
|
-
console.log("startFeedback
|
|
106
|
+
console.log("startFeedback was stopped.")
|
|
107
107
|
} else {
|
|
108
108
|
// Other error handling
|
|
109
109
|
}
|
|
@@ -115,7 +115,7 @@ Note that we would want to make sure the camera feed is currently running before
|
|
|
115
115
|
|
|
116
116
|
```javascript showLineNumbers
|
|
117
117
|
truliooCapture.captureLatestFrame(documentCamera.id).then((result: TruliooManualCaptureResponse) => {
|
|
118
|
-
console.log(`
|
|
118
|
+
console.log(`Successfully captured an image manually with imageId: ${result.imageId}`)
|
|
119
119
|
})
|
|
120
120
|
|
|
121
121
|
```
|
|
@@ -138,7 +138,7 @@ truliooCapture.onFeedbackState(
|
|
|
138
138
|
// The detected document is blurry. Show a blur UI feedback to user.
|
|
139
139
|
break
|
|
140
140
|
case FeedbackState.SUCCESS:
|
|
141
|
-
//
|
|
141
|
+
// Managed to capture a document.
|
|
142
142
|
break
|
|
143
143
|
default:
|
|
144
144
|
break
|
|
@@ -154,7 +154,7 @@ Note that the above flow is the same for the selfie capture type too.
|
|
|
154
154
|
|
|
155
155
|
|
|
156
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
|
|
157
|
-
part of the response data. This will give
|
|
157
|
+
part of the response data. This will give us more information regarding the captured image and let us decide whether we should submit the captured image for
|
|
158
158
|
verification by calling the `acceptImage` function.
|
|
159
159
|
|
|
160
160
|
|
|
@@ -166,10 +166,10 @@ result.verifyImage().then((verifyFeedback: TruliooVerifyFeedback) => {
|
|
|
166
166
|
if (verifyFeedback.documentVerifyResponse.documentTypeAccepted !== ResultCheck.RESULT_CHECK_DECLINED) {
|
|
167
167
|
// Note that the acceptImage can be called outside of the verifyImage function.
|
|
168
168
|
result.acceptImage().then((status: boolean) => {
|
|
169
|
-
console.log("Successfully submitted the image")
|
|
169
|
+
console.log("Successfully submitted the image.")
|
|
170
170
|
})
|
|
171
171
|
} else {
|
|
172
|
-
// Do something else
|
|
172
|
+
// Do something else, e.g., notify the user about the not accepted image and retake a new image.
|
|
173
173
|
}
|
|
174
174
|
})
|
|
175
175
|
```
|
|
@@ -177,11 +177,11 @@ result.verifyImage().then((verifyFeedback: TruliooVerifyFeedback) => {
|
|
|
177
177
|
|
|
178
178
|
### Finalize the document verification transaction
|
|
179
179
|
|
|
180
|
-
Once we submitted all the necessary
|
|
180
|
+
Once we submitted all the necessary images for the transaction, we can finalize the transaction by calling the `submitTransaction` function.
|
|
181
181
|
|
|
182
182
|
|
|
183
183
|
```javascript showLineNumbers
|
|
184
|
-
truliooCapture.submitTransaction().then((status:
|
|
185
|
-
console.log("Transaction
|
|
184
|
+
truliooCapture.submitTransaction().then((status: boolean) => {
|
|
185
|
+
console.log("Transaction successfully submitted.")
|
|
186
186
|
})
|
|
187
187
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trulioo/docv-capture-web",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.3",
|
|
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": {},
|