@socure-inc/docv-react-native 5.0.0 → 5.0.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
@@ -1,16 +1,32 @@
1
- # Predictive DocV SDK v4 React Native
1
+ # Predictive DocV SDK v5 React Native
2
2
 
3
- The Predictive Document Verification (DocV) SDK v5 for React Native is a React Native wrapper that allows you to use the DocV SDK for Android and iOS in your React Native application.
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: Document verification services will be disabled for older SDK versions soon. All SDK integrations must be updated to version **3.1.0 or later** to meet compliance requirements.
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
- ## Minimum Requirements
7
+ ## Table of Contents
8
8
 
9
- Before getting started, check that your development environment meets the following requirements:
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
- - Android SDK Version 22 (OS Version 5.1) and later
23
- - Android SDK is compiled with `compileSdkVersion 34` and Java 17
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 with NPM
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 drop down menus below to integrate the DocV SDK into your iOS or Android app.
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
- ### Configure your iOS app
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
- 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).
62
+ ### Add project dependencies
55
63
 
56
- #### Add project dependencies
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
- In your root project folder, open your Podfile with a text editor and specify the following project dependencies:
59
-
60
- - Replace the deployment target with `platform :ios, '13.0'`.
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
- #### Install the dependencies
116
+ ### Install the dependencies
98
117
 
99
- Change the location of your working directory to the `iOS` folder:
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
- #### Use the CocoaPods-generated `.xcworkspace` file
130
+ ### Use the CocoaPods-generated `.xcworkspace` file
112
131
 
113
- The CocoaPods installation command generates a `.xcworkspace` file with all the dependencies configured. To continue with the installation, complete the following:
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
- - Close Xcode and then open your project's `.xcworkspace` file to launch Xcode. From now on, use the `.xcworkspace` to open your project.
116
- - Check that your deployment target is set to iOS 13 or later.
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
- #### Request camera permissions
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 34.
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
- ```kotlin {5,6}
159
+ ```gradle
149
160
  buildscript {
150
161
  .....
151
162
  ext {
@@ -157,159 +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
- > **Note:** We recommend you check for camera permissions before calling the Socure DocV SDK’s launch API.
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
- #### Required permissions
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"/>
176
-
177
- <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
178
- <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
179
- <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
185
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
180
186
  ```
181
187
 
182
- ## Run the app
188
+ </details>
189
+
190
+ <br />
191
+
192
+ ## Step 3: Run the app
183
193
 
184
- From the command line, go to your root project folder and enter the following command to run the app:
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:
185
196
 
197
+ ```
198
+ react-native run-ios
199
+ ```
200
+
201
+ - For the DocV Android SDK, enter the following command to run the app:
186
202
  ```
187
203
  react-native run-android
188
204
  ```
189
205
 
190
- </details>
191
206
 
192
- <br />
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.
193
210
 
194
- ## Import and launch the SDK
211
+ ### Call the Document Request endpoint
195
212
 
196
- After you have installed the DocV SDK React Native wrapper using NPM and configured your iOS or Android app, add the following code to your `App.js` file to import `launchSocureDocV`:
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
+ ```
258
+
259
+ ## Step 5: Import and launch the SDK
260
+
261
+ 1. Add the following code to your `App.js` file to import `launchSocureDocV`:
197
262
 
198
263
  ```jsx
199
264
  import { launchSocureDocV } from "@socure-inc/docv-react-native"
200
265
  ```
201
266
 
202
- To launch the Socure DocV SDK, specify your SDK key and call the `launchSocureDocV` launch function:
267
+ 2. Call `launchSocureDocV` to initiate the Socure DocV SDK:
203
268
 
204
269
  ```jsx
205
- launchSocureDocV("SOCURE_SDK_KEY", flow, onSuccess, onError);
270
+ launchSocureDocV("docVTransactionToken", "SOCURE_SDK_KEY", userSocureGov, onSuccess, onError);
206
271
  ```
207
272
 
208
- ## How it works
209
-
210
- 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
211
274
 
212
- The following table lists the available `launchSocureDocV` properties:
275
+ The following table lists the parameters for the `launchSocureDocV` function:
213
276
 
214
- | Argument | Description |
215
- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
216
- | `socure_sdk_key` | The unique SDK key obtained from Admin Dashboard. For more information, see the [SDK Keys](https://developer.socure.com/docs/admin-dashboard/developers/sdk-keys) article in DevHub. |
217
- | `flow` | An optional JSON string or null value that specifies a custom flow. <br /><br /> `JSON.stringify({flow: {name: “FLOW_NAME”}, document_type: 'license'})` <br /><br />The `flow_name` value specifies the name of the customized Capture App UI flow (created in Admin Dashboard) that the DocV SDK should use for each transaction. If the value is incorrect or `null`, the DocV SDK will use flow set as **Default** in Admin Dashboard. <br /><br />The `document_type` value specifies a single acceptable document type for the transaction and skips the **Selected ID Type Screen** in the Capture App flow. Possible field values are `license` or `passport`. If the value is incorrect or `null`, the DocV SDK will use the document type defined for the flow in Admin Dashboard. | | |
218
- | `onSuccess` | A callback function that notifies you when the flow completes successfully. | | |
219
- | `onError` | A callback function that notifies you when the flow fails. | | |
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. |
220
284
 
221
-
222
- ## Response callbacks
285
+ ## Step 6: Handle response callbacks
223
286
 
224
- Your app can receive a response callback from the Socure DocV SDK when the flow completes successfully or returns with an error using the `onSuccess` and `onError` callback functions.
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.
225
288
 
226
289
  ### `onSuccess` response
227
- 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.
228
290
 
229
- | Result Field | Type | Description |
230
- |----------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
231
- | `docUUID` | string | The UUID for the uploaded scanned images. |
232
- | `sessionId` | string | The session ID for the scan session. |
233
- | `extractedData` | JSON object | Contains extractedInfo from the barcode or MRZ. |
234
- | `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` |
235
- | `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.
236
292
 
237
- #### Sample `onSuccess` response
238
- ```json
239
- {
240
- "docUUID": "UUID for the uploaded scanned images",
241
- "sessionId": "Session ID for the particular scan session",
242
- "extractedData": {
243
- "address": "123 TAYLOR AVE",
244
- "issueDate": "09282007",
245
- "parsedAddress": {
246
- "city": "SAN BRUNO",
247
- "country": "USA",
248
- "physicalAddress": "123 TAYLOR AVE",
249
- "physicalAddress2": "SAN BRUNO",
250
- "postalCode": "940660000",
251
- "state": "CA"
252
- },
253
- "dob": "07221977",
254
- "documentNumber": "D12345",
255
- "expirationDate": "07222022",
256
- "firstName": "SAM",
257
- "fullName": "SAM SOTO",
258
- "type": "barcode"
259
- },
260
- "captureData": {
261
- "lic_front": "auto",
262
- "lic_back": "auto",
263
- "passport": "auto",
264
- "selfie": "manual"
265
- },
266
- "capturedImages": {
267
- "lic_front": "base64 Image as String",
268
- "lic_back": "base64 Image as String",
269
- "selfie": "base64 Image as String"
270
- }
293
+ ```javascript
294
+ {
295
+ deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzd3QiOiJmZWJlMDYxNS0wYjgxLTRkNTMtYjgyMS03YTAxNjUwZTFiMjEifQ.kz3W8oQxmlqWk1x3W4mf7BSgGmr-qAyvN6fxR_yusbfWdznYVAzdeabHdyW0vAFGgGYvEmyX-5YUtHDMQB0ptA'
271
296
  }
272
297
  ```
273
298
 
274
299
  ### `onError` response
275
300
 
276
- If the consumer exits the flow without completing it or the SDK encounters an error, the `onError` callback receives the `ScanError` object which contains session information and the error. The table below lists the available `ScanError` properties.
277
-
278
- | Error Field | Type | Description |
279
- |----------------|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
280
- | `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. |
281
- | `errorMessage` | string | The error code description. |
282
- | `sessionId` | string | The session ID for the particular scan session. |
283
- | `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.
284
302
 
285
- #### Sample `onError` response
286
- ```json
287
- {
288
- "capturedImages": {
289
- "passport": "base64 Image as String"
290
- },
291
- "errorMessage": "Scan canceled by the user",
292
- "sessionId": "2a55f9-42bgfa-4fb3-9gf32e-6a6fec5",
293
- "statusCode": "7104"
303
+ ```javascript title="Error object example"
304
+ {
305
+ deviceSessionToken: 'eyJraWQiOiJmMzRiN2YiLCJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzd3QiOiJmZWJlMDYxNS0wYjgxLTRkNTMtYjgyMS03YTAxNjUwZTFiMjEifQ.kz3W8oQxmlqWk1x3W4mf7BSgGmr-qAyvN6fxR_yusbfWdznYVAzdeabHdyW0vAFGgGYvEmyX-5YUtHDMQB0ptA',
306
+ error: 'Scan canceled by the user'
294
307
  }
295
308
  ```
296
309
 
297
- ### Error codes
298
-
299
- The following table lists the errors that can be returned by Socure DocV SDK:
300
-
301
- | Error Code | Error Description (string) |
302
- | ---------- | ------------------------------------------------------- |
303
- | `7011` | `Invalid key` |
304
- | `7021` | `Failed to initiate the session ` |
305
- | `7014` | `Session expired ` |
306
- | `7101` | `Empty key ` |
307
- | `7103` | `No internet connection ` |
308
- | `7102` | `Do not have the required permissions to open the camera` |
309
- | `7022` | `Failed to upload the documents ` |
310
- | `7104` | `Scan canceled by the user` |
311
- | `7106` | `Camera error` |
312
- | `7107` | `Unknown error` |
313
- | `7108` | `Camera resolution doesn't match the minimum requirement` |
314
- | `7109` | `Invalid config data` |
315
- | `7110` | `Consent declined` |
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.
@@ -135,7 +135,7 @@ dependencies {
135
135
  //noinspection GradleDynamicVersion
136
136
  implementation "com.facebook.react:react-native:+"
137
137
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
138
- implementation "com.socure.android:docv-capture:5.0.6"
138
+ implementation "com.socure.android:docv-capture:5.0.7"
139
139
 
140
140
  def retrofit_version = "2.9.0"
141
141
  implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
@@ -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.name)
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
- @objc(launchSocureDocV:socureApiKey:useSocureGov:onSuccess:onError:)
7
- func launchSocureDocV(docVTransactionToken: String, socureApiKey: String, useSocureGov: Bool, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) -> Void {
8
-
9
- DispatchQueue.main.async {
10
- let root = RCTPresentedViewController()
11
- let options = SocureDocVOptions(
12
- publicKey: socureApiKey,
13
- docVTransactionToken: docVTransactionToken,
14
- presentingViewController: root!,
15
- useSocureGov: useSocureGov
16
- )
17
- SocureDocVSDK.launch(options, completionBlock: { result in
18
- switch result {
19
- case .success(let success):
20
- onSuccess([["deviceSessionToken": success.deviceSessionToken]])
21
- break
22
- case .failure(let failure):
23
- onError([["deviceSessionToken": failure.deviceSessionToken, "error": String(describing: failure.error)]])
24
- break
25
- }
26
- })
27
- }
28
- }
29
-
30
- @objc static func requiresMainQueueSetup() -> Bool {
31
- return false
32
- }
33
- }
34
-
35
- extension String {
36
- func convertToDictionary() throws -> [String: Any]? {
37
- if let data = self.data(using: .utf8) {
38
- do {
39
- return try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
40
- } catch {
41
- throw error
42
- }
43
- }
44
- return nil
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.0",
3
+ "version": "5.0.2",
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",