@socure-inc/docv-react-native 4.3.3 → 5.0.0
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 +8 -4
- package/android/build.gradle +11 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/assets/index.js +0 -0
- package/android/src/main/java/com/socure/docv/reactnative/Api.kt +66 -0
- package/android/src/main/java/com/socure/docv/reactnative/SocureDocVReactNativeModule.kt +55 -98
- package/dist/index.d.ts +1 -41
- package/ios/SocureDocVReactNative.m +1 -4
- package/ios/SocureDocVReactNative.swift +15 -41
- package/package.json +1 -1
- package/socure-docv-react-native.podspec +2 -1
- package/src/index.tsx +2 -86
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Predictive DocV SDK v4 React Native
|
|
2
2
|
|
|
3
|
-
The Predictive Document Verification (DocV) SDK
|
|
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.
|
|
4
4
|
|
|
5
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.
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ Before getting started, check that your development environment meets the follow
|
|
|
20
20
|
**Android**
|
|
21
21
|
|
|
22
22
|
- Android SDK Version 22 (OS Version 5.1) and later
|
|
23
|
-
- Android SDK is compiled with `compileSdkVersion
|
|
23
|
+
- Android SDK is compiled with `compileSdkVersion 34` and Java 17
|
|
24
24
|
|
|
25
25
|
## Getting started
|
|
26
26
|
|
|
@@ -143,7 +143,7 @@ Using the command line, go to your root project folder and enter the following c
|
|
|
143
143
|
|
|
144
144
|
### Configure your Android app
|
|
145
145
|
|
|
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
|
|
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.
|
|
147
147
|
|
|
148
148
|
```kotlin {5,6}
|
|
149
149
|
buildscript {
|
|
@@ -151,7 +151,7 @@ buildscript {
|
|
|
151
151
|
ext {
|
|
152
152
|
....
|
|
153
153
|
minSdkVersion = 22
|
|
154
|
-
compileSdkVersion =
|
|
154
|
+
compileSdkVersion = 34
|
|
155
155
|
.....
|
|
156
156
|
}
|
|
157
157
|
}
|
|
@@ -173,6 +173,10 @@ Ensure that your app manifest has been set up properly to request the following
|
|
|
173
173
|
<uses-permission android:name="android.permission.CAMERA" />
|
|
174
174
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
175
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" />
|
|
176
180
|
```
|
|
177
181
|
|
|
178
182
|
## Run the app
|
package/android/build.gradle
CHANGED
|
@@ -135,7 +135,17 @@ 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:
|
|
138
|
+
implementation "com.socure.android:docv-capture:5.0.6"
|
|
139
|
+
|
|
140
|
+
def retrofit_version = "2.9.0"
|
|
141
|
+
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
|
142
|
+
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
|
143
|
+
|
|
144
|
+
def lifecycle_version = "2.5.1"
|
|
145
|
+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
|
|
146
|
+
|
|
147
|
+
def okhttp_version = "4.9.3"
|
|
148
|
+
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
|
|
139
149
|
// From node_modules
|
|
140
150
|
}
|
|
141
151
|
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package com.socure.docv.reactnative
|
|
2
|
+
|
|
3
|
+
import java.util.concurrent.TimeUnit
|
|
4
|
+
import okhttp3.OkHttpClient
|
|
5
|
+
import okhttp3.logging.HttpLoggingInterceptor
|
|
6
|
+
import retrofit2.Retrofit
|
|
7
|
+
import retrofit2.converter.gson.GsonConverterFactory
|
|
8
|
+
import retrofit2.http.Body
|
|
9
|
+
import retrofit2.http.HeaderMap
|
|
10
|
+
import retrofit2.http.POST
|
|
11
|
+
|
|
12
|
+
private const val BASE_URL = "https://service.socure.com/"
|
|
13
|
+
|
|
14
|
+
fun transaction(): TransactionService {
|
|
15
|
+
return Retrofit.Builder()
|
|
16
|
+
.baseUrl(BASE_URL)
|
|
17
|
+
.addConverterFactory(GsonConverterFactory.create())
|
|
18
|
+
.client(OkHttpBuilder().getBuilder())
|
|
19
|
+
.build().create(TransactionService::class.java)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TransactionService {
|
|
23
|
+
@POST("api/5.0/documents/request")
|
|
24
|
+
suspend fun createTransaction(
|
|
25
|
+
@HeaderMap headers: Map<String, String>,
|
|
26
|
+
@Body request: TransactionRequest
|
|
27
|
+
): TransactionResponse
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
data class TransactionResponse(
|
|
31
|
+
val data: Data
|
|
32
|
+
) {
|
|
33
|
+
|
|
34
|
+
data class Data(
|
|
35
|
+
val eventId: String,
|
|
36
|
+
val authToken: String,
|
|
37
|
+
val docVTransactionToken: String,
|
|
38
|
+
val qrcode: String,
|
|
39
|
+
val url: String
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
data class TransactionRequest(
|
|
44
|
+
val config: TransactionConfig,
|
|
45
|
+
val previousReferenceId: String? = null
|
|
46
|
+
) {
|
|
47
|
+
|
|
48
|
+
data class TransactionConfig(
|
|
49
|
+
val useCaseKey: String,
|
|
50
|
+
val language: String = "en"
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class OkHttpBuilder {
|
|
55
|
+
fun getBuilder(): OkHttpClient {
|
|
56
|
+
with(OkHttpClient.Builder()) {
|
|
57
|
+
readTimeout(120L, TimeUnit.SECONDS)
|
|
58
|
+
connectTimeout(120L, TimeUnit.SECONDS)
|
|
59
|
+
writeTimeout(120L, TimeUnit.SECONDS)
|
|
60
|
+
val loggingInterceptor = HttpLoggingInterceptor()
|
|
61
|
+
loggingInterceptor.level = HttpLoggingInterceptor.Level.HEADERS
|
|
62
|
+
addInterceptor(loggingInterceptor)
|
|
63
|
+
return build()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -3,26 +3,23 @@ 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
|
|
6
|
+
import androidx.appcompat.app.AppCompatActivity
|
|
7
7
|
import com.facebook.react.bridge.*
|
|
8
8
|
import com.socure.docv.capturesdk.api.Platform.REACT_NATIVE
|
|
9
|
-
import com.socure.docv.capturesdk.api.
|
|
10
|
-
import com.socure.docv.capturesdk.api.SocureDocVHelper.getResult
|
|
11
|
-
import com.socure.docv.capturesdk.api.SocureDocVHelper.setSource
|
|
12
|
-
import com.socure.docv.capturesdk.api.SocureDocVHelper.initSdk
|
|
9
|
+
import com.socure.docv.capturesdk.api.SocureDocVContext
|
|
13
10
|
import com.socure.docv.capturesdk.api.SocureExperimentalApi
|
|
14
|
-
import com.socure.docv.capturesdk.
|
|
15
|
-
import com.socure.docv.capturesdk.
|
|
16
|
-
import com.socure.docv.capturesdk.
|
|
17
|
-
import
|
|
18
|
-
import
|
|
11
|
+
import com.socure.docv.capturesdk.api.SocureSdk
|
|
12
|
+
import com.socure.docv.capturesdk.api.SocureSdk.getResult
|
|
13
|
+
import com.socure.docv.capturesdk.api.SocureSdk.initSdk
|
|
14
|
+
import com.socure.docv.capturesdk.common.utils.SocureDocVFailure
|
|
15
|
+
import com.socure.docv.capturesdk.common.utils.SocureDocVSuccess
|
|
16
|
+
import com.socure.docv.capturesdk.common.utils.SocureResult
|
|
19
17
|
|
|
20
18
|
class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
|
|
21
19
|
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
22
20
|
|
|
23
21
|
private val TAG = "SDLT_RN"
|
|
24
|
-
|
|
25
|
-
private val SOCURE_SDK_REQUEST_CODE = 753
|
|
22
|
+
private val SOCURE_SDK_REQUEST_CODE = 753
|
|
26
23
|
private var onSuccessCallback: Callback? = null
|
|
27
24
|
private var onErrorCallback: Callback? = null
|
|
28
25
|
|
|
@@ -32,35 +29,49 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
32
29
|
|
|
33
30
|
@OptIn(SocureExperimentalApi::class)
|
|
34
31
|
@ReactMethod
|
|
35
|
-
fun initDocVSdk(
|
|
32
|
+
fun initDocVSdk(verificationToken: String, publicKey: String, useSocureGov: Boolean) {
|
|
36
33
|
Log.d(TAG, "initDocVSdk - init native sdk")
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
initSdk(
|
|
35
|
+
SocureDocVContext(verificationToken, publicKey, useSocureGov, null, null)
|
|
36
|
+
)
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
@OptIn(SocureExperimentalApi::class)
|
|
42
40
|
@ReactMethod
|
|
43
|
-
fun launchDocVSdk(onSuccess: Callback,onError: Callback) {
|
|
41
|
+
fun launchDocVSdk(onSuccess: Callback, onError: Callback) {
|
|
44
42
|
Log.d(TAG, "launchDocVSdk - launch using experimental api")
|
|
45
|
-
|
|
46
43
|
setupLaunch(onSuccess, onError)
|
|
47
|
-
currentActivity?.
|
|
44
|
+
currentActivity?.run {
|
|
45
|
+
startActivityForResult(SocureSdk.getIntent(this), SOCURE_SDK_REQUEST_CODE)
|
|
46
|
+
}
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
@ReactMethod
|
|
51
50
|
fun launchSocureDocV(
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
verificationToken: String,
|
|
52
|
+
publicKey: String,
|
|
53
|
+
useSocureGov: Boolean,
|
|
54
54
|
onSuccess: Callback,
|
|
55
55
|
onError: Callback
|
|
56
56
|
) {
|
|
57
57
|
Log.d(TAG, "launchSocureDocV - launch Socure SDK")
|
|
58
|
-
|
|
59
58
|
setupLaunch(onSuccess, onError)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
|
|
60
|
+
currentActivity?.run {
|
|
61
|
+
startActivityForResult(
|
|
62
|
+
SocureSdk.getIntent(
|
|
63
|
+
this,
|
|
64
|
+
SocureDocVContext(
|
|
65
|
+
verificationToken,
|
|
66
|
+
publicKey,
|
|
67
|
+
useSocureGov,
|
|
68
|
+
null,
|
|
69
|
+
null
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
SOCURE_SDK_REQUEST_CODE
|
|
73
|
+
)
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
private fun setupLaunch(onSuccess: Callback, onError: Callback) {
|
|
@@ -68,10 +79,8 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
68
79
|
this.onErrorCallback = onError
|
|
69
80
|
|
|
70
81
|
Log.d(TAG, "launchSocureDocV - registering activity event listener")
|
|
71
|
-
|
|
72
82
|
reactApplicationContext.addActivityEventListener(this)
|
|
73
|
-
|
|
74
|
-
setSource(REACT_NATIVE)
|
|
83
|
+
SocureSdk.setSource(REACT_NATIVE)
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
override fun onActivityResult(
|
|
@@ -81,88 +90,36 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
|
|
|
81
90
|
data: Intent?
|
|
82
91
|
) {
|
|
83
92
|
if (requestCode == SOCURE_SDK_REQUEST_CODE) {
|
|
84
|
-
Log.d(TAG, "onActivityResult - requestCode matched, removing activity event listener")
|
|
85
|
-
|
|
86
93
|
data?.let {
|
|
87
|
-
getResult(
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
getResult(it) { result ->
|
|
95
|
+
Log.d(TAG, "onResult called: $result")
|
|
96
|
+
if (result is SocureDocVSuccess) {
|
|
97
|
+
onSuccessCallback?.invoke(convertResultToReadbleMap(result))
|
|
98
|
+
} else {
|
|
99
|
+
onErrorCallback?.invoke(convertResultToReadbleMap(result))
|
|
90
100
|
}
|
|
91
|
-
|
|
92
|
-
override fun onError(scanError: ScanError) {
|
|
93
|
-
onErrorCallback?.invoke(convertErrorToReadableMap(scanError))
|
|
94
|
-
}
|
|
95
|
-
})
|
|
101
|
+
}
|
|
96
102
|
}
|
|
97
|
-
|
|
103
|
+
Log.d(TAG, "onActivityResult - requestCode matched, removing activity event listener")
|
|
98
104
|
reactApplicationContext.removeActivityEventListener(this)
|
|
99
105
|
} else {
|
|
100
|
-
Log.d(
|
|
106
|
+
Log.d(
|
|
107
|
+
TAG,
|
|
108
|
+
"onActivityResult - requestCode does not match: $requestCode, not removing activity event listener"
|
|
109
|
+
)
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
override fun onNewIntent(intent: Intent?) {}
|
|
105
114
|
|
|
106
|
-
private fun convertResultToReadbleMap(
|
|
115
|
+
private fun convertResultToReadbleMap(result: SocureResult): ReadableMap {
|
|
107
116
|
val docVResponse: WritableMap = Arguments.createMap()
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
captureData.putString(it.key, it.value)
|
|
114
|
-
}
|
|
115
|
-
docVResponse.putMap("captureData", captureData)
|
|
116
|
-
|
|
117
|
-
val capturedImages: WritableMap = Arguments.createMap()
|
|
118
|
-
scannedData.capturedImages?.forEach {
|
|
119
|
-
capturedImages.putString(it.key, Base64.encodeToString(it.value, Base64.DEFAULT) ?: "")
|
|
120
|
-
}
|
|
121
|
-
docVResponse.putMap("capturedImages", capturedImages)
|
|
122
|
-
|
|
123
|
-
scannedData.extractedData?.let { jsonString ->
|
|
124
|
-
try {
|
|
125
|
-
docVResponse.putMap("extractedData", convertStringToMap(JSONObject(jsonString)))
|
|
126
|
-
} catch (ex: JSONException) {
|
|
127
|
-
docVResponse.putString("extractedData", jsonString)
|
|
128
|
-
}
|
|
117
|
+
if (result is SocureDocVSuccess) {
|
|
118
|
+
docVResponse.putString("deviceSessionToken", result.deviceSessionToken)
|
|
119
|
+
} else {
|
|
120
|
+
docVResponse.putString("deviceSessionToken", result.deviceSessionToken)
|
|
121
|
+
docVResponse.putString("error", (result as SocureDocVFailure).error.name)
|
|
129
122
|
}
|
|
130
|
-
|
|
131
123
|
return docVResponse
|
|
132
124
|
}
|
|
133
|
-
|
|
134
|
-
private fun convertErrorToReadableMap(scanError: ScanError): ReadableMap {
|
|
135
|
-
val docVErrResponse: WritableMap = Arguments.createMap()
|
|
136
|
-
docVErrResponse.putString("statusCode", scanError.statusCode.toString())
|
|
137
|
-
docVErrResponse.putString("errorMessage", scanError.errorMessage)
|
|
138
|
-
scanError.sessionId?.let {
|
|
139
|
-
docVErrResponse.putString("sessionId", it)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
val capturedImages: WritableMap = Arguments.createMap()
|
|
143
|
-
scanError.capturedImages?.forEach {
|
|
144
|
-
capturedImages.putString(it.key, Base64.encodeToString(it.value, Base64.DEFAULT) ?: "")
|
|
145
|
-
}
|
|
146
|
-
docVErrResponse.putMap("capturedImages", capturedImages)
|
|
147
|
-
|
|
148
|
-
return docVErrResponse
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
private fun convertStringToMap(jsonObject: JSONObject): ReadableMap {
|
|
152
|
-
val responseMap: WritableMap = Arguments.createMap()
|
|
153
|
-
val jsonIterator = jsonObject.keys()
|
|
154
|
-
while (jsonIterator.hasNext()) {
|
|
155
|
-
val key: String = jsonIterator.next()
|
|
156
|
-
when (val value = jsonObject[key]) {
|
|
157
|
-
is JSONObject -> {
|
|
158
|
-
responseMap.putMap(key, convertStringToMap(value))
|
|
159
|
-
}
|
|
160
|
-
is String -> {
|
|
161
|
-
responseMap.putString(key, value)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return responseMap
|
|
166
|
-
}
|
|
167
|
-
|
|
168
125
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
export declare function launchSocureDocV(
|
|
2
|
-
export declare function initDocVSdk(socureApiKey: string, flow: string | null | undefined): void;
|
|
3
|
-
export declare function launchDocVSdk(onSuccess: Function, onError: Function): any;
|
|
4
|
-
export interface ScannedData {
|
|
5
|
-
docUUID: string;
|
|
6
|
-
sessionId: string;
|
|
7
|
-
extractedData?: ExtractedInfo;
|
|
8
|
-
captureData: {
|
|
9
|
-
[doc_type: string]: [capture_type: string];
|
|
10
|
-
};
|
|
11
|
-
capturedImages: {
|
|
12
|
-
[doc_type: string]: [image_data: string];
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface ScanError {
|
|
16
|
-
statusCode: string;
|
|
17
|
-
errorMessage: string;
|
|
18
|
-
sessionId?: string;
|
|
19
|
-
capturedImages?: {
|
|
20
|
-
[doc_type: string]: [image_data: string];
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export interface ExtractedInfo {
|
|
24
|
-
type?: string;
|
|
25
|
-
expirationDate?: string;
|
|
26
|
-
dob?: string;
|
|
27
|
-
firstName?: string;
|
|
28
|
-
fullName?: string;
|
|
29
|
-
documentNumber?: string;
|
|
30
|
-
address?: string;
|
|
31
|
-
surName?: string;
|
|
32
|
-
issueDate?: string;
|
|
33
|
-
parsedAddress?: AddressInfo;
|
|
34
|
-
}
|
|
35
|
-
export interface AddressInfo {
|
|
36
|
-
state?: String;
|
|
37
|
-
postalCode?: String;
|
|
38
|
-
city?: String;
|
|
39
|
-
country?: String;
|
|
40
|
-
physicalAddress?: String;
|
|
41
|
-
}
|
|
1
|
+
export declare function launchSocureDocV(docVTransactionToken: string, publicKey: string, useSocureGov: boolean, onSuccess: Function, onError: Function): any;
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
@interface RCT_EXTERN_MODULE(SocureDocVReactNative, NSObject)
|
|
4
4
|
|
|
5
|
-
RCT_EXTERN_METHOD(launchSocureDocV:(NSString)socureApiKey
|
|
5
|
+
RCT_EXTERN_METHOD(launchSocureDocV:(NSString)docVTransactionToken socureApiKey:(NSString)socureApiKey useSocureGov:(BOOL)useSocureGov
|
|
6
6
|
onSuccess:(RCTResponseSenderBlock)success
|
|
7
7
|
onError:(RCTResponseSenderBlock)error)
|
|
8
|
-
RCT_EXTERN_METHOD(initDocVSdk:(NSString)socureApiKey flow:(NSString)flow)
|
|
9
|
-
RCT_EXTERN_METHOD(launchDocVSdk:(RCTResponseSenderBlock)success
|
|
10
|
-
onError:(RCTResponseSenderBlock)error)
|
|
11
8
|
|
|
12
9
|
+ (BOOL)requiresMainQueueSetup
|
|
13
10
|
{
|
|
@@ -2,51 +2,25 @@ import SocureDocV
|
|
|
2
2
|
|
|
3
3
|
@objc(SocureDocVReactNative)
|
|
4
4
|
class SocureDocVReactNative: NSObject {
|
|
5
|
-
lazy var objDocVHelper = SocureDocVHelper()
|
|
6
5
|
|
|
7
|
-
@objc(launchSocureDocV:
|
|
8
|
-
func launchSocureDocV(
|
|
9
|
-
|
|
10
|
-
do {
|
|
11
|
-
flowConfig = try flow?.convertToDictionary()
|
|
12
|
-
} catch {
|
|
13
|
-
let errorDict = ["errorMessage": "Invalid config data", "statusCode": "7109"]
|
|
14
|
-
onError([errorDict])
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
objDocVHelper.setSource(.reactNative)
|
|
18
|
-
DispatchQueue.main.async {
|
|
19
|
-
let root = RCTPresentedViewController()
|
|
20
|
-
self.objDocVHelper.launch(socureApiKey, presentingViewController: root!, config: flowConfig, completionBlock: { result in
|
|
21
|
-
switch result {
|
|
22
|
-
case .success(let scan):
|
|
23
|
-
onSuccess([scan.dictionary])
|
|
24
|
-
break
|
|
25
|
-
case .failure(let error):
|
|
26
|
-
onError([error.dictionary])
|
|
27
|
-
break
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@objc(initDocVSdk:flow:)
|
|
34
|
-
func initDocVSdk(socureApiKey: String, flow: String?) -> Void {
|
|
35
|
-
SocureDocVSdk.initSdk(publicKey: socureApiKey, config: try? flow?.convertToDictionary())
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@objc(launchDocVSdk:onError:)
|
|
39
|
-
func launchDocVSdk(onSuccess: @escaping RCTResponseSenderBlock,onError: @escaping RCTResponseSenderBlock) -> Void {
|
|
40
|
-
SocureDocVSdk.setSource(.reactNative)
|
|
6
|
+
@objc(launchSocureDocV:socureApiKey:useSocureGov:onSuccess:onError:)
|
|
7
|
+
func launchSocureDocV(docVTransactionToken: String, socureApiKey: String, useSocureGov: Bool, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) -> Void {
|
|
8
|
+
|
|
41
9
|
DispatchQueue.main.async {
|
|
42
10
|
let root = RCTPresentedViewController()
|
|
43
|
-
|
|
11
|
+
let options = SocureDocVOptions(
|
|
12
|
+
publicKey: socureApiKey,
|
|
13
|
+
docVTransactionToken: docVTransactionToken,
|
|
14
|
+
presentingViewController: root!,
|
|
15
|
+
useSocureGov: useSocureGov
|
|
16
|
+
)
|
|
17
|
+
SocureDocVSDK.launch(options, completionBlock: { result in
|
|
44
18
|
switch result {
|
|
45
|
-
case .success(let
|
|
46
|
-
onSuccess([
|
|
19
|
+
case .success(let success):
|
|
20
|
+
onSuccess([["deviceSessionToken": success.deviceSessionToken]])
|
|
47
21
|
break
|
|
48
|
-
case .failure(let
|
|
49
|
-
onError([error.
|
|
22
|
+
case .failure(let failure):
|
|
23
|
+
onError([["deviceSessionToken": failure.deviceSessionToken, "error": String(describing: failure.error)]])
|
|
50
24
|
break
|
|
51
25
|
}
|
|
52
26
|
})
|
|
@@ -69,4 +43,4 @@ extension String {
|
|
|
69
43
|
}
|
|
70
44
|
return nil
|
|
71
45
|
}
|
|
72
|
-
}
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socure-inc/docv-react-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
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",
|
package/src/index.tsx
CHANGED
|
@@ -13,90 +13,6 @@ const SocureDocVReactNative = NativeModules.SocureDocVReactNative ? NativeModule
|
|
|
13
13
|
}
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
-
export function launchSocureDocV(
|
|
17
|
-
|
|
18
|
-
onConfigError("7011", "Invalid key", onError)
|
|
19
|
-
} else if (flow && typeof flow !== 'string') {
|
|
20
|
-
onConfigError("7109", "Invalid config data", onError)
|
|
21
|
-
} else {
|
|
22
|
-
return SocureDocVReactNative.launchSocureDocV(socureApiKey, flow, onSuccess, onError);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
{/*
|
|
27
|
-
This API is experimental.
|
|
28
|
-
Please contact Socure before starting to use this.
|
|
29
|
-
*/}
|
|
30
|
-
export function initDocVSdk(socureApiKey: string, flow: string | null | undefined) {
|
|
31
|
-
if (socureApiKey && typeof socureApiKey === "string") {
|
|
32
|
-
if ((!flow && flow !== "") || (typeof flow === "string" && isValidJSON(flow))) {
|
|
33
|
-
SocureDocVReactNative.initDocVSdk(socureApiKey, flow);
|
|
34
|
-
} else {
|
|
35
|
-
onConfigError("7109", "Invalid config data")
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
onConfigError("7011", "Invalid key")
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
{/*
|
|
43
|
-
This API is experimental.
|
|
44
|
-
Please contact Socure before starting to use this.
|
|
45
|
-
*/}
|
|
46
|
-
export function launchDocVSdk(onSuccess: Function, onError: Function) {
|
|
47
|
-
return SocureDocVReactNative.launchDocVSdk(onSuccess, onError);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function isValidJSON(jsonString: string) {
|
|
51
|
-
try {
|
|
52
|
-
JSON.parse(jsonString);
|
|
53
|
-
return true;
|
|
54
|
-
} catch (e) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
function onConfigError(errorCode: string, errorMessage: string, onError?: Function) {
|
|
60
|
-
let error = { statusCode: errorCode, errorMessage: errorMessage } as ScanError
|
|
61
|
-
if (onError && typeof onError == 'function') {
|
|
62
|
-
onError(error)
|
|
63
|
-
} else {
|
|
64
|
-
throw Promise.reject(error)
|
|
65
|
-
}
|
|
16
|
+
export function launchSocureDocV(docVTransactionToken: string, publicKey: string, useSocureGov: boolean, onSuccess: Function, onError: Function) {
|
|
17
|
+
return SocureDocVReactNative.launchSocureDocV(docVTransactionToken, publicKey, useSocureGov, onSuccess, onError);
|
|
66
18
|
}
|
|
67
|
-
|
|
68
|
-
export interface ScannedData {
|
|
69
|
-
docUUID: string
|
|
70
|
-
sessionId: string
|
|
71
|
-
extractedData?: ExtractedInfo
|
|
72
|
-
captureData: { [doc_type: string]: [capture_type: string] }
|
|
73
|
-
capturedImages: { [doc_type: string]: [image_data: string] }
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface ScanError {
|
|
77
|
-
statusCode: string
|
|
78
|
-
errorMessage: string
|
|
79
|
-
sessionId?: string
|
|
80
|
-
capturedImages?: { [doc_type: string]: [image_data: string] }
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface ExtractedInfo {
|
|
84
|
-
type?: string
|
|
85
|
-
expirationDate?: string
|
|
86
|
-
dob?: string
|
|
87
|
-
firstName?: string
|
|
88
|
-
fullName?: string
|
|
89
|
-
documentNumber?: string
|
|
90
|
-
address?: string
|
|
91
|
-
surName?: string
|
|
92
|
-
issueDate?: string
|
|
93
|
-
parsedAddress?: AddressInfo
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface AddressInfo {
|
|
97
|
-
state?: String
|
|
98
|
-
postalCode?: String
|
|
99
|
-
city?: String
|
|
100
|
-
country?: String
|
|
101
|
-
physicalAddress?: String
|
|
102
|
-
}
|