@socure-inc/docv-react-native 5.0.1 → 5.0.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
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
# Predictive DocV SDK
|
|
1
|
+
# Predictive DocV SDK v5 React Native
|
|
2
2
|
|
|
3
|
-
The Predictive Document Verification (DocV) SDK
|
|
3
|
+
The Predictive Document Verification (DocV) SDK for React Native is a React Native wrapper that allows you to use the DocV SDK for Android or iOS in your React Native application.
|
|
4
4
|
|
|
5
|
-
>Note
|
|
5
|
+
> **Note:** The Digital Intelligence SDK is required for all DocV iOS and Android SDK v5 integrations. For more information, see the [Digital Intelligence SDK Guides](https://developer.socure.com/docs/sdks/digital-intelligence/overview) in DevHub.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Table of Contents
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
1. [Getting Started](#getting-started)
|
|
10
|
+
2. [Step 1: Install the React Native Wrapper](#step-1-install-the-react-native-wrapper)
|
|
11
|
+
3. [Step 2: Configure Your iOS or Android App](#step-2-configure-your-ios-or-android-app)
|
|
12
|
+
4. [Step 3: Run the App](#step-3-run-the-app)
|
|
13
|
+
5. [Step 4: Generate a Transaction Token and Configure the Capture App](#step-4-generate-a-transaction-token-and-configure-the-capture-app)
|
|
14
|
+
6. [Step 5: Import and Launch the SDK](#step-5-import-and-launch-the-sdk)
|
|
15
|
+
7. [Step 6: Handle Response Callbacks](#step-6-handle-response-callbacks)
|
|
16
|
+
8. [Step 7: Fetch the Verification Results](#step-7-fetch-the-verification-results)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Getting started
|
|
20
|
+
|
|
21
|
+
Before you begin, ensure you have the following:
|
|
22
|
+
|
|
23
|
+
- Get a valid [ID+ key from Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/id-plus-keys) to authenticate API requests.
|
|
24
|
+
- Get a valid [SDK key from Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/sdk-keys) to initialize and authenticate the DocV SDK.
|
|
25
|
+
- Add your IP address to the [allowlist in Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/allowlist).
|
|
10
26
|
|
|
11
27
|
**React Native**
|
|
12
28
|
|
|
13
|
-
- React Native CLI. See the [React Native docs](https://reactnative.dev/docs/environment-setup) for instructions on how to set up your development environment.
|
|
29
|
+
- React Native CLI. See the [React Native docs](https://reactnative.dev/docs/environment-setup) for instructions on how to set up your development environment.
|
|
14
30
|
|
|
15
31
|
**iOS**
|
|
16
32
|
|
|
@@ -19,18 +35,10 @@ Before getting started, check that your development environment meets the follow
|
|
|
19
35
|
|
|
20
36
|
**Android**
|
|
21
37
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
## Getting started
|
|
26
|
-
|
|
27
|
-
To get started, complete the steps in the following sections:
|
|
28
|
-
|
|
29
|
-
- [Install the React Native wrapper with NPM](#install-the-react-native-wrapper-with-npm)
|
|
30
|
-
- [Configure your iOS or Android app](#configure-your-ios-or-android-app)
|
|
31
|
-
- [Import and launch the SDK](#import-and-launch-the-sdk)
|
|
38
|
+
- `compileSdkVersion: 34`
|
|
39
|
+
- `Java: 17`
|
|
32
40
|
|
|
33
|
-
## Install the React Native wrapper
|
|
41
|
+
## Step 1: Install the React Native wrapper
|
|
34
42
|
|
|
35
43
|
In your React Native project, install the DocV React Native wrapper by running the following NPM command:
|
|
36
44
|
|
|
@@ -38,9 +46,9 @@ In your React Native project, install the DocV React Native wrapper by running t
|
|
|
38
46
|
npm install @socure-inc/docv-react-native
|
|
39
47
|
```
|
|
40
48
|
|
|
41
|
-
## Configure your iOS or Android app
|
|
49
|
+
## Step 2: Configure your iOS or Android app
|
|
42
50
|
|
|
43
|
-
Your React Native project needs to access the DocV iOS or Android SDKs through the React Native wrapper. Follow the instructions in the
|
|
51
|
+
Your React Native project needs to access the DocV iOS or Android SDKs through the React Native wrapper. Follow the instructions in the dropdown menus below to integrate the DocV SDK into your iOS or Android app.
|
|
44
52
|
|
|
45
53
|
<br />
|
|
46
54
|
|
|
@@ -49,29 +57,36 @@ Your React Native project needs to access the DocV iOS or Android SDKs through t
|
|
|
49
57
|
|
|
50
58
|
<br />
|
|
51
59
|
|
|
52
|
-
|
|
60
|
+
For the iOS app, you can install the DocV iOS SDK into your project using Cocoapods. If you do not already have the CocoaPods tool installed, see the [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html#installation).
|
|
53
61
|
|
|
54
|
-
|
|
62
|
+
### Add project dependencies
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
1. In your root project folder, open your `Podfile` with a text editor.
|
|
65
|
+
2. Specify the following project dependencies:
|
|
66
|
+
- Replace the deployment target with `platform :ios, '13.0'`.
|
|
67
|
+
- Add the following line:
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- Add the line pod `'socure-docv-react-native', :path => '../node_modules/@socure-inc/docv-react-native'`
|
|
69
|
+
```
|
|
70
|
+
pod 'socure-docv-react-native', :path => '../node_modules/@socure-inc/docv-react-native'
|
|
71
|
+
```
|
|
62
72
|
|
|
63
|
-
Once completed, your Podfile should look like the following example:
|
|
73
|
+
Once completed, your `Podfile` should look like the following example:
|
|
64
74
|
|
|
65
75
|
```swift {4,36}
|
|
66
76
|
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
|
67
77
|
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
|
78
|
+
|
|
68
79
|
platform :ios, '13.0'
|
|
69
80
|
install! 'cocoapods', :deterministic_uuids => false
|
|
81
|
+
|
|
70
82
|
production = ENV["PRODUCTION"] == "1"
|
|
83
|
+
|
|
71
84
|
target 'SocureDocVDemo' do
|
|
72
85
|
config = use_native_modules!
|
|
86
|
+
|
|
73
87
|
# Flags change depending on the env values.
|
|
74
88
|
flags = get_default_flags()
|
|
89
|
+
|
|
75
90
|
use_react_native!(
|
|
76
91
|
:path => config[:reactNativePath],
|
|
77
92
|
# to enable hermes on iOS, change `false` to `true` and then install pods
|
|
@@ -82,70 +97,66 @@ target 'SocureDocVDemo' do
|
|
|
82
97
|
# An absolute path to your application root.
|
|
83
98
|
:app_path => "#{Pod::Config.instance.installation_root}/.."
|
|
84
99
|
)
|
|
100
|
+
|
|
85
101
|
target 'SocureDocVDemoTests' do
|
|
86
102
|
inherit! :complete
|
|
87
103
|
# Pods for testing
|
|
88
104
|
end
|
|
105
|
+
|
|
89
106
|
post_install do |installer|
|
|
90
107
|
react_native_post_install(installer)
|
|
91
108
|
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
|
92
109
|
end
|
|
110
|
+
|
|
93
111
|
pod 'socure-docv-react-native', :path => '../node_modules/@socure-inc/docv-react-native'
|
|
112
|
+
|
|
94
113
|
end
|
|
95
114
|
```
|
|
96
115
|
|
|
97
|
-
|
|
116
|
+
### Install the dependencies
|
|
98
117
|
|
|
99
|
-
|
|
118
|
+
1. Go to the `ios` folder in your project:
|
|
100
119
|
|
|
101
120
|
```
|
|
102
121
|
cd ios
|
|
103
122
|
```
|
|
104
123
|
|
|
105
|
-
Install the Cocoapods dependencies by running the following command:
|
|
124
|
+
2. Install the Cocoapods dependencies by running the following command:
|
|
106
125
|
|
|
107
126
|
```
|
|
108
127
|
pod install
|
|
109
128
|
```
|
|
110
129
|
|
|
111
|
-
|
|
130
|
+
### Use the CocoaPods-generated `.xcworkspace` file
|
|
112
131
|
|
|
113
|
-
The
|
|
132
|
+
The `pod install` command generates a `.xcworkspace` file with all the configured dependencies. To continue with the installation, complete the following:
|
|
114
133
|
|
|
115
|
-
|
|
116
|
-
|
|
134
|
+
1. Close Xcode if it's already open.
|
|
135
|
+
2. Use the `.xcworkspace` file reopen your project in Xcode.
|
|
136
|
+
3. Check that your deployment target is set to iOS 13.0 or later.
|
|
117
137
|
|
|
118
|
-
|
|
138
|
+
### Request camera permissions
|
|
119
139
|
|
|
120
|
-
The DocV iOS SDK requires a device's camera permission to capture identity documents. Upon the first invocation of the SDK, the app will request camera permission from the consumer. If the app does not already use the camera, you must add the following to the app’s `Info.plist file`:
|
|
140
|
+
The DocV iOS SDK requires a device's camera permission to capture identity documents. Upon the first invocation of the SDK, the app will request camera permission from the consumer. If the app does not already use the camera, you must add the following to the app’s `Info.plist file`:
|
|
121
141
|
|
|
122
142
|
| Key | Type | Value |
|
|
123
143
|
|------------------------------------|--------|---------------------------------------------------------------------------------------------|
|
|
124
144
|
| Privacy - Camera Usage Description | String | "This application requires use of your camera in order to capture your identity documents." |
|
|
125
145
|
|
|
126
|
-
|
|
127
|
-
> **Note:** We recommend you check for camera permission before calling the SocureDocV SDK’s launch API.
|
|
128
|
-
|
|
129
|
-
### Run the app
|
|
130
|
-
|
|
131
|
-
Using the command line, go to your root project folder and enter the following command to run the app:
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
"react-native run-ios"
|
|
135
|
-
```
|
|
146
|
+
> **Note:** We recommend you check for camera permission before calling the SocureDocV SDK’s launch API.
|
|
136
147
|
|
|
137
148
|
</details>
|
|
138
149
|
|
|
150
|
+
<br />
|
|
151
|
+
|
|
139
152
|
<details>
|
|
140
153
|
<summary><b>Integrate with the DocV Android SDK</b></summary>
|
|
141
154
|
|
|
142
155
|
<br />
|
|
143
|
-
|
|
144
|
-
### Configure your Android app
|
|
145
156
|
|
|
146
|
-
For the Android app, add your project dependencies by going to the module level `build.gradle` file and making sure the `minSdkVersion` is set to at least 22 and the `compileSdkVersion` is set to at least
|
|
157
|
+
For the Android app, add your project dependencies by going to the module level `build.gradle` file and making sure the `minSdkVersion` is set to at least 22 and the `compileSdkVersion` is set to at least 32.
|
|
147
158
|
|
|
148
|
-
```
|
|
159
|
+
```gradle
|
|
149
160
|
buildscript {
|
|
150
161
|
.....
|
|
151
162
|
ext {
|
|
@@ -157,155 +168,164 @@ buildscript {
|
|
|
157
168
|
}
|
|
158
169
|
```
|
|
159
170
|
|
|
160
|
-
### Camera permissions
|
|
161
|
-
|
|
162
|
-
The DocV Android SDK requires camera permission to capture identity documents. Upon the first invocation of the SDK, your app will request camera permission from the user.
|
|
171
|
+
### Camera and file permissions
|
|
163
172
|
|
|
164
|
-
|
|
173
|
+
The DocV SDK requires camera and file permission to capture identity documents. Upon the first invocation of the SDK, your app will request camera and file permission from the consumer.
|
|
165
174
|
|
|
166
|
-
|
|
175
|
+
> **Note:** We recommend you check for camera and file permissions before calling the Socure DocV SDK’s launch API.
|
|
167
176
|
|
|
168
177
|
Ensure that your app manifest has been set up properly to request the following required permissions:
|
|
169
178
|
|
|
170
|
-
```
|
|
179
|
+
```xml
|
|
171
180
|
<uses-feature android:name="android.hardware.camera" />
|
|
181
|
+
|
|
172
182
|
<!-- Declare permissions -->
|
|
173
183
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
174
184
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
175
|
-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
|
185
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
176
186
|
```
|
|
177
187
|
|
|
178
|
-
|
|
188
|
+
</details>
|
|
179
189
|
|
|
180
|
-
|
|
190
|
+
<br />
|
|
181
191
|
|
|
192
|
+
## Step 3: Run the app
|
|
193
|
+
|
|
194
|
+
1. Return to your root project folder in the command line.
|
|
195
|
+
- For the DocV iOS SDK, enter the following command to run the app:
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
react-native run-ios
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- For the DocV Android SDK, enter the following command to run the app:
|
|
182
202
|
```
|
|
183
203
|
react-native run-android
|
|
184
204
|
```
|
|
185
205
|
|
|
186
|
-
</details>
|
|
187
206
|
|
|
188
|
-
|
|
207
|
+
## Step 4: Generate a transaction token and configure the Capture App
|
|
208
|
+
|
|
209
|
+
To initiate the verification process, generate a transaction token (`docvTransactionToken`) by calling the Document Request endpoint v5. We strongly recommend that customers generate this token via a server-to-server API call and then pass it to the DocV SDK to ensure the security of their API key and any data they send to Socure.
|
|
210
|
+
|
|
211
|
+
### Call the Document Request endpoint
|
|
212
|
+
|
|
213
|
+
1. From your backend, make a `POST` request to the [`/documents/request`](https://developer.socure.com/reference#tag/Predictive-Document-Verification/operation/DocumentRequestV5) endpoint specifying the following information in the `config` object:
|
|
214
|
+
|
|
215
|
+
| Parameter | Required | Description |
|
|
216
|
+
|------------------|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
217
|
+
| `language` | Optional | Determines the language package for the UI text on the Capture App. Possible values are: <br/><br/> - Arabic: `ar` <br/> - Armenian: `hy` <br/> - Bengali: `bn` <br/> - Brazilian Portuguese: `pt-br` <br/> - Chinese (Simplified): `zh-cn` <br/> - Chinese (Traditional): `zh-tw` <br/> - English: `en` <br/> - French: `fr` <br/> - Haitian Creole: `ht` <br/> - Italian: `it` <br/> - Korean: `ko` <br/> - Polish: `pl-PL` <br/> - Russian: `ru` <br/> - Spanish (EU): `es` <br/> - Tagalog: `tl` <br/> - Urdu: `ur` <br/> - Vietnamese: `vi` <br/><br/> **Note**: Socure can quickly add support for new language requirements. For more information, contact [support@socure.com](mailto:support@socure.com). |
|
|
218
|
+
| `useCaseKey` | Optional | Deploys a customized Capture App flow on a per-transaction basis. Replace the `customer_use_case_key` value with the name of the flow you created in [Admin Dashboard](https://developer.socure.com/docs/sdks/docv/capture-app/customize-capture-app). <br/><br/> - If this field is empty, the Capture App will use the flow marked as **Default** in Admin Dashboard. <br/> - If the value provided is incorrect, the SDK will return an `Invalid Request` error. |
|
|
219
|
+
|
|
220
|
+
>Note: We recommend including as much consumer PII in the body of the request as possible to return the most accurate results.
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
curl --location 'https://service.socure.com/api/5.0/documents/request' \
|
|
224
|
+
--header 'Content-Type: application/json' \
|
|
225
|
+
--header 'Authorization: SocureApiKey a182150a-363a-4f4a-xxxx-xxxxxxxxxxxx' \
|
|
226
|
+
--data '{
|
|
227
|
+
"config": {
|
|
228
|
+
"useCaseKey": "customer_use_case_key",
|
|
229
|
+
...
|
|
230
|
+
}
|
|
231
|
+
"firstName": "Dwayne",
|
|
232
|
+
"surName": "Denver",
|
|
233
|
+
"dob": "1975-04-02",
|
|
234
|
+
"mobileNumber": "+13475550100",
|
|
235
|
+
"physicalAddress": "200 Key Square St",
|
|
236
|
+
"physicalAddress2": null,
|
|
237
|
+
"city": "Brownsville",
|
|
238
|
+
"state": "TN",
|
|
239
|
+
"zip": "38012",
|
|
240
|
+
"country": "US"
|
|
241
|
+
}'
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
2. When you receive the API response, collect the `docvTransactionToken`. This value is required to initialize the DocV Android SDK and fetch the DocV results.
|
|
245
|
+
|
|
246
|
+
```json
|
|
247
|
+
{
|
|
248
|
+
"referenceId": "123ab45d-2e34-46f3-8d17-6f540ae90303",
|
|
249
|
+
"data": {
|
|
250
|
+
"eventId": "acdf5b1a-c96b-4ed8-92b9-59471397d04a",
|
|
251
|
+
"customerUserId": "121212",
|
|
252
|
+
"docvTransactionToken" : "acdf5b1a-c96b-4ed8-92b9-59471397d04a",
|
|
253
|
+
"qrCode": "data:image/png;base64,iVBO......K5CYII=",
|
|
254
|
+
"url": "https://verify.socure.com/#/dv/acdf5b1a-c96b-4ed8-92b9-59471397d04a"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
189
258
|
|
|
190
|
-
## Import and launch the SDK
|
|
259
|
+
## Step 5: Import and launch the SDK
|
|
191
260
|
|
|
192
|
-
|
|
261
|
+
1. Add the following code to your `App.js` file to import `launchSocureDocV`:
|
|
193
262
|
|
|
194
263
|
```jsx
|
|
195
264
|
import { launchSocureDocV } from "@socure-inc/docv-react-native"
|
|
196
265
|
```
|
|
197
266
|
|
|
198
|
-
|
|
267
|
+
2. Call `launchSocureDocV` to initiate the Socure DocV SDK:
|
|
199
268
|
|
|
200
269
|
```jsx
|
|
201
|
-
launchSocureDocV("SOCURE_SDK_KEY",
|
|
270
|
+
launchSocureDocV("docVTransactionToken", "SOCURE_SDK_KEY", userSocureGov, onSuccess, onError);
|
|
202
271
|
```
|
|
203
272
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
Your React Native application initializes and communicates with the DocV SDK through the React Native wrapper using the `launchSocureDocV` instance. The `launchSocureDocV` function also includes two callback functions, one for `onSuccess` and one for `onError`. See [Response callbacks](#response-callbacks) below for more information.
|
|
273
|
+
### `launchSocureDocV` Parameters
|
|
207
274
|
|
|
208
|
-
The following table lists the
|
|
275
|
+
The following table lists the parameters for the `launchSocureDocV` function:
|
|
209
276
|
|
|
210
|
-
|
|
|
211
|
-
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
277
|
+
| Parameter | Type | Description |
|
|
278
|
+
|--------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
279
|
+
| `SOCURE_SDK_KEY` | String | The unique SDK key obtained from [Admin Dashboard](https://developer.socure.com/docs/admin-dashboard/developers/sdk-keys) used to authenticate the SDK. |
|
|
280
|
+
| `DocV_Transaction_Token` | String | The transaction token retrieved from the API response of the [`/documents/request`](https://developer.socure.com/reference#tag/Predictive-Document-Verification) endpoint. Required to initiate the document verification session. |
|
|
281
|
+
| `useSocureGov` | Bool | A Boolean flag indicating whether to use the GovCloud environment. It defaults to `false`. This is only applicable for customers provisioned in the SocureGov environment. |
|
|
282
|
+
| `onSuccess` | Function | A callback function invoked when the flow completes successfully. |
|
|
283
|
+
| `onError` | Function | A callback function invoked when the flow fails. |
|
|
216
284
|
|
|
217
|
-
|
|
218
|
-
## Response callbacks
|
|
285
|
+
## Step 6: Handle response callbacks
|
|
219
286
|
|
|
220
|
-
Your app can receive
|
|
287
|
+
Your app can receive response callbacks from the `launchSocureDocV` function when the flow either completes successfully or returns with an error. The SDK represents these outcomes using the `onSuccess` and `onError` callback functions.
|
|
221
288
|
|
|
222
289
|
### `onSuccess` response
|
|
223
|
-
When the consumer successfully completes the flow and the captured images are uploaded, the `onSuccess` callback receives the ScannedData object which contains session information and the extracted data. The table below lists the available `ScannedData` properties.
|
|
224
290
|
|
|
225
|
-
|
|
226
|
-
|----------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
227
|
-
| `docUUID` | string | The UUID for the uploaded scanned images. |
|
|
228
|
-
| `sessionId` | string | The session ID for the scan session. |
|
|
229
|
-
| `extractedData` | JSON object | Contains extractedInfo from the barcode or MRZ. |
|
|
230
|
-
| `captureData` | JSON object | The mapped capture type for every scan. <br /> Possible keys are: `lic_front`, `lic_back`, `passport`, `selfie` <br /> Possible values can be `manual` or `auto` |
|
|
231
|
-
| `capturedImages` | JSON object | The mapped image data of captured images. <br /> Possible keys are: `lic_front`, `lic_back`, `passport`, `selfie` <br /> Value will be a base64 image string <br />**Note**: Prefix `data:image/png;base64,` while using base64 string. |
|
|
291
|
+
The `onSuccess` callback is triggered when the consumer successfully completes the verification flow and the captured images are uploaded to Socure's servers. It returns an object containing a device session token, which can be used for accessing device details about the specific session.
|
|
232
292
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
"docUUID": "UUID for the uploaded scanned images",
|
|
237
|
-
"sessionId": "Session ID for the particular scan session",
|
|
238
|
-
"extractedData": {
|
|
239
|
-
"address": "123 TAYLOR AVE",
|
|
240
|
-
"issueDate": "09282007",
|
|
241
|
-
"parsedAddress": {
|
|
242
|
-
"city": "SAN BRUNO",
|
|
243
|
-
"country": "USA",
|
|
244
|
-
"physicalAddress": "123 TAYLOR AVE",
|
|
245
|
-
"physicalAddress2": "SAN BRUNO",
|
|
246
|
-
"postalCode": "940660000",
|
|
247
|
-
"state": "CA"
|
|
248
|
-
},
|
|
249
|
-
"dob": "07221977",
|
|
250
|
-
"documentNumber": "D12345",
|
|
251
|
-
"expirationDate": "07222022",
|
|
252
|
-
"firstName": "SAM",
|
|
253
|
-
"fullName": "SAM SOTO",
|
|
254
|
-
"type": "barcode"
|
|
255
|
-
},
|
|
256
|
-
"captureData": {
|
|
257
|
-
"lic_front": "auto",
|
|
258
|
-
"lic_back": "auto",
|
|
259
|
-
"passport": "auto",
|
|
260
|
-
"selfie": "manual"
|
|
261
|
-
},
|
|
262
|
-
"capturedImages": {
|
|
263
|
-
"lic_front": "base64 Image as String",
|
|
264
|
-
"lic_back": "base64 Image as String",
|
|
265
|
-
"selfie": "base64 Image as String"
|
|
266
|
-
}
|
|
293
|
+
```javascript
|
|
294
|
+
{
|
|
295
|
+
deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzd3QiOiJmZWJlMDYxNS0wYjgxLTRkNTMtYjgyMS03YTAxNjUwZTFiMjEifQ.kz3W8oQxmlqWk1x3W4mf7BSgGmr-qAyvN6fxR_yusbfWdznYVAzdeabHdyW0vAFGgGYvEmyX-5YUtHDMQB0ptA'
|
|
267
296
|
}
|
|
268
297
|
```
|
|
269
298
|
|
|
270
299
|
### `onError` response
|
|
271
300
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
| Error Field | Type | Description |
|
|
275
|
-
|----------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
276
|
-
| `capturedImages` | JSON object | The mapped image data of captured images (if available). <br /> Possible keys are: `lic_front`, `lic_back`, `passport`, `selfie` <br /> Value will be a base64 image string <br /> **Note**: Prefix `data:image/png;base64,` while using base64 string. |
|
|
277
|
-
| `errorMessage` | string | The error code description. |
|
|
278
|
-
| `sessionId` | string | The session ID for the particular scan session. |
|
|
279
|
-
| `statusCode` | string | The error code returned by Socure DocV SDK. |
|
|
301
|
+
The `onError` callback is triggered when the DocV SDK encounters an error or when the consumer exits the flow without completing it. It returns a message printed with the `deviceSessionToken` and specific error details.
|
|
280
302
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
"passport": "base64 Image as String"
|
|
286
|
-
},
|
|
287
|
-
"errorMessage": "Scan canceled by the user",
|
|
288
|
-
"sessionId": "2a55f9-42bgfa-4fb3-9gf32e-6a6fec5",
|
|
289
|
-
"statusCode": "7104"
|
|
303
|
+
```javascript title="Error object example"
|
|
304
|
+
{
|
|
305
|
+
deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzd3QiOiJmZWJlMDYxNS0wYjgxLTRkNTMtYjgyMS03YTAxNjUwZTFiMjEifQ.kz3W8oQxmlqWk1x3W4mf7BSgGmr-qAyvN6fxR_yusbfWdznYVAzdeabHdyW0vAFGgGYvEmyX-5YUtHDMQB0ptA',
|
|
306
|
+
error: 'Scan canceled by the user'
|
|
290
307
|
}
|
|
291
308
|
```
|
|
292
309
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
The following
|
|
296
|
-
|
|
297
|
-
| Error
|
|
298
|
-
|
|
299
|
-
| `
|
|
300
|
-
| `
|
|
301
|
-
| `
|
|
302
|
-
| `
|
|
303
|
-
| `
|
|
304
|
-
| `
|
|
305
|
-
| `
|
|
306
|
-
| `
|
|
307
|
-
| `
|
|
308
|
-
| `
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
#### Possible `onError` messages
|
|
311
|
+
|
|
312
|
+
The following error messages may be returned by the Socure DocV SDK:
|
|
313
|
+
|
|
314
|
+
| Error Message | Error Description |
|
|
315
|
+
|-------------------------------------------------------|-------------------------------------------------------------------|
|
|
316
|
+
| `"No internet connection"` | No internet connection |
|
|
317
|
+
| `"Failed to initiate the session"` | Failed to initiate the session |
|
|
318
|
+
| `"Permissions to open the camera declined by the user"` | Permissions to open the camera declined by the user |
|
|
319
|
+
| `"Consent declined by the user"` | Consent declined by the user |
|
|
320
|
+
| `"Failed to upload the documents"` | Failed to upload the documents |
|
|
321
|
+
| `"Invalid transaction token"` | Invalid transaction token |
|
|
322
|
+
| `"Invalid or missing SDK key"` | Invalid or missing SDK key |
|
|
323
|
+
| `"Session expired"` | Session expired |
|
|
324
|
+
| `"Scan canceled by the user"` | Scan canceled by the user |
|
|
325
|
+
| `"Unknown error"` | Unknown error |
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
## Step 7: Fetch the verification results
|
|
330
|
+
|
|
331
|
+
When the consumer successfully completes the document capture and upload process, call the ID+ endpoint fetch the results. See the [API Reference documentation](https://developer.socure.com/reference#tag/ID+/operation/ID+) on DevHub for more information.
|
|
@@ -3,10 +3,10 @@ package com.socure.docv.reactnative
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import android.util.Log
|
|
6
|
-
import androidx.appcompat.app.AppCompatActivity
|
|
7
6
|
import com.facebook.react.bridge.*
|
|
8
7
|
import com.socure.docv.capturesdk.api.Platform.REACT_NATIVE
|
|
9
8
|
import com.socure.docv.capturesdk.api.SocureDocVContext
|
|
9
|
+
import com.socure.docv.capturesdk.api.SocureDocVError
|
|
10
10
|
import com.socure.docv.capturesdk.api.SocureExperimentalApi
|
|
11
11
|
import com.socure.docv.capturesdk.api.SocureSdk
|
|
12
12
|
import com.socure.docv.capturesdk.api.SocureSdk.getResult
|
|
@@ -118,8 +118,25 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
118
118
|
docVResponse.putString("deviceSessionToken", result.deviceSessionToken)
|
|
119
119
|
} else {
|
|
120
120
|
docVResponse.putString("deviceSessionToken", result.deviceSessionToken)
|
|
121
|
-
docVResponse.putString("error", (result as SocureDocVFailure).error
|
|
121
|
+
docVResponse.putString("error", getErrorMessage((result as SocureDocVFailure).error))
|
|
122
122
|
}
|
|
123
123
|
return docVResponse
|
|
124
124
|
}
|
|
125
|
+
|
|
126
|
+
private fun getErrorMessage(socureDocVError: SocureDocVError): String{
|
|
127
|
+
when(socureDocVError){
|
|
128
|
+
|
|
129
|
+
SocureDocVError.NO_INTERNET_CONNECTION -> { return "No internet connection"}
|
|
130
|
+
SocureDocVError.SESSION_INITIATION_FAILURE -> {return "Failed to initiate the session"}
|
|
131
|
+
SocureDocVError.CAMERA_PERMISSION_DECLINED -> {return "Permissions to open the camera declined by the user"}
|
|
132
|
+
SocureDocVError.CONSENT_DECLINED -> {return "Consent declined by the user"}
|
|
133
|
+
SocureDocVError.DOCUMENT_UPLOAD_FAILURE -> {return "Failed to upload the documents"}
|
|
134
|
+
SocureDocVError.INVALID_DOCV_TRANSACTION_TOKEN -> {return "Invalid transaction token"}
|
|
135
|
+
SocureDocVError.INVALID_PUBLIC_KEY -> {return "Invalid or missing SDK key"}
|
|
136
|
+
SocureDocVError.SESSION_EXPIRED -> {return "Session expired"}
|
|
137
|
+
SocureDocVError.USER_CANCELED -> {return "Scan canceled by the user"}
|
|
138
|
+
else -> {return "Unknown error"}
|
|
139
|
+
|
|
140
|
+
}
|
|
141
|
+
}
|
|
125
142
|
}
|
|
@@ -1,46 +1,85 @@
|
|
|
1
1
|
import SocureDocV
|
|
2
2
|
|
|
3
|
-
@objc(SocureDocVReactNative)
|
|
4
|
-
class SocureDocVReactNative: NSObject {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
3
|
+
@objc(SocureDocVReactNative)
|
|
4
|
+
class SocureDocVReactNative: NSObject {
|
|
5
|
+
|
|
6
|
+
@objc(launchSocureDocV:socureApiKey:useSocureGov:onSuccess:onError:)
|
|
7
|
+
func launchSocureDocV(docVTransactionToken: String,
|
|
8
|
+
socureApiKey: String,
|
|
9
|
+
useSocureGov: Bool,
|
|
10
|
+
onSuccess: @escaping RCTResponseSenderBlock,
|
|
11
|
+
onError: @escaping RCTResponseSenderBlock) -> Void {
|
|
12
|
+
|
|
13
|
+
DispatchQueue.main.async {
|
|
14
|
+
guard let root = RCTPresentedViewController() else {
|
|
15
|
+
onError([["error": "Failed to get the root view controller"]])
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
let options = SocureDocVOptions(
|
|
19
|
+
publicKey: socureApiKey,
|
|
20
|
+
docVTransactionToken: docVTransactionToken,
|
|
21
|
+
presentingViewController: root,
|
|
22
|
+
useSocureGov: useSocureGov
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
SocureDocVSDK.launch(options) { result in
|
|
26
|
+
switch result {
|
|
27
|
+
case .success(let success):
|
|
28
|
+
onSuccess([["deviceSessionToken": success.deviceSessionToken]])
|
|
29
|
+
case .failure(let failure):
|
|
30
|
+
let errorMessage = self.getErrorMessage(from: failure.error)
|
|
31
|
+
onError([["error": errorMessage,
|
|
32
|
+
"deviceSessionToken": failure.deviceSessionToken]])
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@objc static func requiresMainQueueSetup() -> Bool {
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func getErrorMessage(from error: SocureDocVError) -> String {
|
|
43
|
+
switch error {
|
|
44
|
+
case .noInternetConnection:
|
|
45
|
+
return "No internet connection"
|
|
46
|
+
case .sessionInitiationFailure:
|
|
47
|
+
return "Failed to initiate the session"
|
|
48
|
+
case .cameraPermissionDeclined:
|
|
49
|
+
return "Permissions to open the camera declined by the user"
|
|
50
|
+
case .consentDeclined:
|
|
51
|
+
return "Consent declined by the user"
|
|
52
|
+
case .documentUploadFailure:
|
|
53
|
+
return "Failed to upload the documents"
|
|
54
|
+
case .invalidDocVTransactionToken:
|
|
55
|
+
return "Invalid transaction token"
|
|
56
|
+
case .invalidPublicKey:
|
|
57
|
+
return "Invalid or missing SDK key"
|
|
58
|
+
case .sessionExpired:
|
|
59
|
+
return "Session expired"
|
|
60
|
+
case .userCanceled:
|
|
61
|
+
return "Scan canceled by the user"
|
|
62
|
+
case .unknown:
|
|
63
|
+
fallthrough
|
|
64
|
+
@unknown default:
|
|
65
|
+
return "Unknown error"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socure-inc/docv-react-native",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "The Predictive Document Verification (DocV) SDK React Native bridge allows you to use the DocV SDK v4 for Android and iOS in your React Native application.",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"types": "dist/index.d.ts",
|