@smile_identity/react-native 10.3.2 → 11.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/android/build.gradle +12 -8
- package/android/gradle.properties +1 -3
- package/android/src/main/java/com/smileidentity/react/Mapper.kt +35 -10
- package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +169 -93
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +8 -5
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +7 -4
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentCaptureView.kt +13 -11
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt +149 -32
- package/ios/RNSmileID.swift +18 -10
- package/ios/SmileId.xcodeproj/xcuserdata/japhetndhlovu.xcuserdatad/xcschemes/SmileId.xcscheme +23 -0
- package/ios/SmileId.xcodeproj/xcuserdata/japhetndhlovu.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/Utils/SmileIDDictExt.swift +35 -11
- package/ios/View/SmileIDDocumentCaptureView.swift +1 -2
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +38 -10
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +6 -4
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +6 -4
- package/ios/ViewManagers/SmileIDSmartSelfieCaptureViewManager.swift +1 -2
- package/ios/ViewModels/SmileIDProductModel.swift +6 -4
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +28 -8
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +28 -8
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +22 -4
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/react-native-smile-id.podspec +10 -5
- package/src/index.tsx +2 -0
- package/src/types.ts +41 -13
package/android/build.gradle
CHANGED
|
@@ -8,10 +8,10 @@ buildscript {
|
|
|
8
8
|
google()
|
|
9
9
|
mavenCentral()
|
|
10
10
|
gradlePluginPortal()
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
11
|
+
// uncomment for development to test snapshots
|
|
12
|
+
// maven {
|
|
13
|
+
// url = 'https://central.sonatype.com/repository/maven-snapshots/'
|
|
14
|
+
// }
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
dependencies {
|
|
@@ -78,7 +78,10 @@ android {
|
|
|
78
78
|
defaultConfig {
|
|
79
79
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
80
80
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
// Read version from package.json for setWrapperInfo
|
|
83
|
+
def packageJson = new groovy.json.JsonSlurper().parseText(file("../package.json").text)
|
|
84
|
+
buildConfigField "String", "SMILE_ID_VERSION", "\"${packageJson.version}\""
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
buildTypes {
|
|
@@ -121,9 +124,10 @@ repositories {
|
|
|
121
124
|
mavenCentral()
|
|
122
125
|
google()
|
|
123
126
|
gradlePluginPortal()
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
// uncomment for development to test snapshots
|
|
128
|
+
// maven {
|
|
129
|
+
// url = 'https://central.sonatype.com/repository/maven-snapshots/'
|
|
130
|
+
// }
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SmileId_kotlinVersion"]
|
|
@@ -3,7 +3,5 @@ SmileId_minSdkVersion=21
|
|
|
3
3
|
SmileId_targetSdkVersion=35
|
|
4
4
|
SmileId_compileSdkVersion=35
|
|
5
5
|
SmileId_ndkversion=21.4.7075529
|
|
6
|
-
SmileId_androidVersion=
|
|
7
|
-
; Uncomment for dev also uncomment snapshots repo in build.gradle
|
|
8
|
-
; SmileId_androidVersion=10.6.1-SNAPSHOT
|
|
6
|
+
SmileId_androidVersion=11.0.3
|
|
9
7
|
SmileId_kotlinCompilerExtensionVersion=1.5.11
|
|
@@ -5,6 +5,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
5
5
|
import com.smileidentity.models.AuthenticationRequest
|
|
6
6
|
import com.smileidentity.models.Config
|
|
7
7
|
import com.smileidentity.models.ConsentInformation
|
|
8
|
+
import com.smileidentity.models.ConsentedInformation
|
|
8
9
|
import com.smileidentity.models.EnhancedKycRequest
|
|
9
10
|
import com.smileidentity.models.IdInfo
|
|
10
11
|
import com.smileidentity.models.ImageType
|
|
@@ -153,23 +154,47 @@ fun ReadableMap.toEnhancedKycRequest(): EnhancedKycRequest {
|
|
|
153
154
|
},
|
|
154
155
|
consentInformation = getMapOrDefault("consentInformation", null)?.toConsentInfo() ?: run {
|
|
155
156
|
ConsentInformation(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
consented = ConsentedInformation(
|
|
158
|
+
consentGrantedDate = getCurrentIsoTimestamp(),
|
|
159
|
+
personalDetails = false,
|
|
160
|
+
contactInformation = false,
|
|
161
|
+
documentInformation = false
|
|
162
|
+
)
|
|
160
163
|
)
|
|
161
164
|
},
|
|
162
165
|
)
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
fun ReadableMap.toConsentInfo(): ConsentInformation {
|
|
169
|
+
val consentGrantedDate =
|
|
170
|
+
getStringOrDefault("consentGrantedDate", getCurrentIsoTimestamp()) ?: getCurrentIsoTimestamp()
|
|
171
|
+
|
|
172
|
+
// Try the new property names first, fall back to old property names if new ones aren't present
|
|
173
|
+
val personalDetailsConsentGranted = if (hasKey("personalDetails")) {
|
|
174
|
+
getBoolOrDefault("personalDetails", false)
|
|
175
|
+
} else {
|
|
176
|
+
getBoolOrDefault("personalDetailsConsentGranted", false)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
val contactInfoConsentGranted = if (hasKey("contactInformation")) {
|
|
180
|
+
getBoolOrDefault("contactInformation", false)
|
|
181
|
+
} else {
|
|
182
|
+
getBoolOrDefault("contactInfoConsentGranted", false)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
val documentInfoConsentGranted = if (hasKey("documentInformation")) {
|
|
186
|
+
getBoolOrDefault("documentInformation", false)
|
|
187
|
+
} else {
|
|
188
|
+
getBoolOrDefault("documentInfoConsentGranted", false)
|
|
189
|
+
}
|
|
190
|
+
|
|
166
191
|
return ConsentInformation(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
192
|
+
consented = ConsentedInformation(
|
|
193
|
+
consentGrantedDate = consentGrantedDate,
|
|
194
|
+
personalDetails = personalDetailsConsentGranted,
|
|
195
|
+
contactInformation = contactInfoConsentGranted,
|
|
196
|
+
documentInformation = documentInfoConsentGranted
|
|
197
|
+
),
|
|
173
198
|
)
|
|
174
199
|
}
|
|
175
200
|
|
|
@@ -9,6 +9,7 @@ import com.facebook.react.bridge.WritableArray
|
|
|
9
9
|
import com.smileidentity.SmileID
|
|
10
10
|
import com.smileidentity.SmileIDCrashReporting
|
|
11
11
|
import com.smileidentity.SmileIdSpec
|
|
12
|
+
import com.smileidentity.metadata.models.WrapperSdkName
|
|
12
13
|
import com.smileidentity.models.AuthenticationResponse
|
|
13
14
|
import com.smileidentity.models.BiometricKycJobStatusResponse
|
|
14
15
|
import com.smileidentity.models.DocumentVerificationJobStatusResponse
|
|
@@ -38,10 +39,9 @@ import kotlin.time.Duration
|
|
|
38
39
|
import kotlin.time.Duration.Companion.milliseconds
|
|
39
40
|
|
|
40
41
|
class SmileIdModule internal constructor(
|
|
41
|
-
context: ReactApplicationContext
|
|
42
|
+
context: ReactApplicationContext,
|
|
42
43
|
) : SmileIdSpec(context) {
|
|
43
|
-
|
|
44
|
-
override fun getName(): String = NAME
|
|
44
|
+
override fun getName(): String = NAME
|
|
45
45
|
|
|
46
46
|
@ReactMethod
|
|
47
47
|
override fun initialize(
|
|
@@ -49,9 +49,18 @@ class SmileIdModule internal constructor(
|
|
|
49
49
|
enableCrashReporting: Boolean,
|
|
50
50
|
config: ReadableMap?,
|
|
51
51
|
apiKey: String?,
|
|
52
|
-
promise: Promise
|
|
52
|
+
promise: Promise,
|
|
53
53
|
) {
|
|
54
54
|
try {
|
|
55
|
+
// Set wrapper info for React Native SDK
|
|
56
|
+
try {
|
|
57
|
+
val version = com.smileidentity.react.BuildConfig.SMILE_ID_VERSION
|
|
58
|
+
SmileID.setWrapperInfo(WrapperSdkName.ReactNative, version)
|
|
59
|
+
} catch (e: Exception) {
|
|
60
|
+
// Fallback to default version if BuildConfig is not available
|
|
61
|
+
SmileID.setWrapperInfo(WrapperSdkName.ReactNative, "unknown")
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
when {
|
|
56
65
|
// Case 1: Initialize with API key and config
|
|
57
66
|
apiKey != null && config != null -> {
|
|
@@ -60,7 +69,7 @@ class SmileIdModule internal constructor(
|
|
|
60
69
|
apiKey = apiKey,
|
|
61
70
|
config = config.toConfig(),
|
|
62
71
|
useSandbox = useSandBox,
|
|
63
|
-
enableCrashReporting = enableCrashReporting
|
|
72
|
+
enableCrashReporting = enableCrashReporting,
|
|
64
73
|
)
|
|
65
74
|
}
|
|
66
75
|
// Case 2: Initialize with just config
|
|
@@ -69,14 +78,14 @@ class SmileIdModule internal constructor(
|
|
|
69
78
|
context = reactApplicationContext,
|
|
70
79
|
config = config.toConfig(),
|
|
71
80
|
useSandbox = useSandBox,
|
|
72
|
-
enableCrashReporting = enableCrashReporting
|
|
81
|
+
enableCrashReporting = enableCrashReporting,
|
|
73
82
|
)
|
|
74
83
|
}
|
|
75
84
|
// Case 3: Basic initialization
|
|
76
85
|
else -> {
|
|
77
86
|
SmileID.initialize(
|
|
78
87
|
context = reactApplicationContext,
|
|
79
|
-
useSandbox = useSandBox
|
|
88
|
+
useSandbox = useSandBox,
|
|
80
89
|
)
|
|
81
90
|
}
|
|
82
91
|
}
|
|
@@ -87,7 +96,10 @@ class SmileIdModule internal constructor(
|
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
@ReactMethod
|
|
90
|
-
override fun setCallbackUrl(
|
|
99
|
+
override fun setCallbackUrl(
|
|
100
|
+
callbackUrl: String,
|
|
101
|
+
promise: Promise,
|
|
102
|
+
) {
|
|
91
103
|
SmileID.setCallbackUrl(callbackUrl = URL(callbackUrl))
|
|
92
104
|
promise.resolve(null)
|
|
93
105
|
}
|
|
@@ -98,16 +110,22 @@ class SmileIdModule internal constructor(
|
|
|
98
110
|
}
|
|
99
111
|
|
|
100
112
|
@ReactMethod
|
|
101
|
-
override fun setAllowOfflineMode(
|
|
113
|
+
override fun setAllowOfflineMode(
|
|
114
|
+
allowOfflineMode: Boolean,
|
|
115
|
+
promise: Promise,
|
|
116
|
+
) {
|
|
102
117
|
SmileID.setAllowOfflineMode(allowOfflineMode)
|
|
103
118
|
promise.resolve(null)
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
@ReactMethod
|
|
107
|
-
override fun submitJob(
|
|
122
|
+
override fun submitJob(
|
|
123
|
+
jobId: String,
|
|
124
|
+
promise: Promise,
|
|
125
|
+
) = launch(
|
|
108
126
|
work = { SmileID.submitJob(jobId) },
|
|
109
127
|
clazz = Unit::class.java,
|
|
110
|
-
promise = promise
|
|
128
|
+
promise = promise,
|
|
111
129
|
)
|
|
112
130
|
|
|
113
131
|
@ReactMethod
|
|
@@ -137,7 +155,10 @@ class SmileIdModule internal constructor(
|
|
|
137
155
|
}
|
|
138
156
|
|
|
139
157
|
@ReactMethod
|
|
140
|
-
override fun cleanup(
|
|
158
|
+
override fun cleanup(
|
|
159
|
+
jobId: String,
|
|
160
|
+
promise: Promise,
|
|
161
|
+
) {
|
|
141
162
|
try {
|
|
142
163
|
SmileID.cleanup(jobId)
|
|
143
164
|
promise.resolve(null)
|
|
@@ -147,102 +168,141 @@ class SmileIdModule internal constructor(
|
|
|
147
168
|
}
|
|
148
169
|
|
|
149
170
|
@ReactMethod
|
|
150
|
-
override fun authenticate(
|
|
171
|
+
override fun authenticate(
|
|
172
|
+
request: ReadableMap,
|
|
173
|
+
promise: Promise,
|
|
174
|
+
) = launch(
|
|
151
175
|
work = {
|
|
152
176
|
SmileID.api.authenticate(request = request.toAuthenticationRequest())
|
|
153
177
|
},
|
|
154
178
|
clazz = AuthenticationResponse::class.java,
|
|
155
|
-
promise = promise
|
|
179
|
+
promise = promise,
|
|
156
180
|
)
|
|
157
181
|
|
|
158
182
|
@ReactMethod
|
|
159
|
-
override fun prepUpload(
|
|
183
|
+
override fun prepUpload(
|
|
184
|
+
request: ReadableMap,
|
|
185
|
+
promise: Promise,
|
|
186
|
+
) = launch(
|
|
160
187
|
work = { SmileID.api.prepUpload(request = request.toPrepUploadRequest()) },
|
|
161
188
|
clazz = PrepUploadResponse::class.java,
|
|
162
|
-
promise = promise
|
|
189
|
+
promise = promise,
|
|
163
190
|
)
|
|
164
191
|
|
|
165
192
|
@ReactMethod
|
|
166
|
-
override fun upload(
|
|
193
|
+
override fun upload(
|
|
194
|
+
url: String,
|
|
195
|
+
request: ReadableMap,
|
|
196
|
+
promise: Promise,
|
|
197
|
+
) = launch(
|
|
167
198
|
work = { SmileID.api.upload(url, request.toUploadRequest()) },
|
|
168
199
|
clazz = Unit::class.java,
|
|
169
|
-
promise = promise
|
|
200
|
+
promise = promise,
|
|
170
201
|
)
|
|
171
202
|
|
|
172
203
|
@ReactMethod
|
|
173
|
-
override fun doEnhancedKyc(
|
|
204
|
+
override fun doEnhancedKyc(
|
|
205
|
+
request: ReadableMap,
|
|
206
|
+
promise: Promise,
|
|
207
|
+
) = launch(
|
|
174
208
|
work = { SmileID.api.doEnhancedKyc(request = request.toEnhancedKycRequest()) },
|
|
175
209
|
clazz = EnhancedKycResponse::class.java,
|
|
176
|
-
promise = promise
|
|
210
|
+
promise = promise,
|
|
177
211
|
)
|
|
178
212
|
|
|
179
213
|
@ReactMethod
|
|
180
|
-
override fun doEnhancedKycAsync(
|
|
214
|
+
override fun doEnhancedKycAsync(
|
|
215
|
+
request: ReadableMap,
|
|
216
|
+
promise: Promise,
|
|
217
|
+
) = launch(
|
|
181
218
|
work = { SmileID.api.doEnhancedKycAsync(request = request.toEnhancedKycRequest()) },
|
|
182
219
|
clazz = EnhancedKycAsyncResponse::class.java,
|
|
183
|
-
promise = promise
|
|
220
|
+
promise = promise,
|
|
184
221
|
)
|
|
185
222
|
|
|
186
223
|
@ReactMethod
|
|
187
|
-
override fun getSmartSelfieJobStatus(
|
|
224
|
+
override fun getSmartSelfieJobStatus(
|
|
225
|
+
request: ReadableMap,
|
|
226
|
+
promise: Promise,
|
|
227
|
+
) = launch(
|
|
188
228
|
work = { SmileID.api.getSmartSelfieJobStatus(request = request.toJobStatusRequest()) },
|
|
189
229
|
clazz = SmartSelfieJobStatusResponse::class.java,
|
|
190
|
-
promise = promise
|
|
230
|
+
promise = promise,
|
|
191
231
|
)
|
|
192
232
|
|
|
193
233
|
@ReactMethod
|
|
194
|
-
override fun getDocumentVerificationJobStatus(
|
|
234
|
+
override fun getDocumentVerificationJobStatus(
|
|
235
|
+
request: ReadableMap,
|
|
236
|
+
promise: Promise,
|
|
237
|
+
) = launch(
|
|
195
238
|
work = { SmileID.api.getDocumentVerificationJobStatus(request = request.toJobStatusRequest()) },
|
|
196
239
|
clazz = DocumentVerificationJobStatusResponse::class.java,
|
|
197
|
-
promise = promise
|
|
240
|
+
promise = promise,
|
|
198
241
|
)
|
|
199
242
|
|
|
200
243
|
@ReactMethod
|
|
201
|
-
override fun getBiometricKycJobStatus(
|
|
244
|
+
override fun getBiometricKycJobStatus(
|
|
245
|
+
request: ReadableMap,
|
|
246
|
+
promise: Promise,
|
|
247
|
+
) = launch(
|
|
202
248
|
work = { SmileID.api.getBiometricKycJobStatus(request = request.toJobStatusRequest()) },
|
|
203
249
|
clazz = BiometricKycJobStatusResponse::class.java,
|
|
204
|
-
promise = promise
|
|
250
|
+
promise = promise,
|
|
205
251
|
)
|
|
206
252
|
|
|
207
253
|
@ReactMethod
|
|
208
|
-
override fun getEnhancedDocumentVerificationJobStatus(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
254
|
+
override fun getEnhancedDocumentVerificationJobStatus(
|
|
255
|
+
request: ReadableMap,
|
|
256
|
+
promise: Promise,
|
|
257
|
+
) = launch(
|
|
258
|
+
work = { SmileID.api.getEnhancedDocumentVerificationJobStatus(request = request.toJobStatusRequest()) },
|
|
259
|
+
clazz = EnhancedDocumentVerificationJobStatusResponse::class.java,
|
|
260
|
+
promise = promise,
|
|
261
|
+
)
|
|
214
262
|
|
|
215
263
|
@ReactMethod
|
|
216
|
-
override fun getProductsConfig(
|
|
264
|
+
override fun getProductsConfig(
|
|
265
|
+
request: ReadableMap,
|
|
266
|
+
promise: Promise,
|
|
267
|
+
) = launch(
|
|
217
268
|
work = { SmileID.api.getProductsConfig(request = request.toProductsConfigRequest()) },
|
|
218
269
|
clazz = ProductsConfigResponse::class.java,
|
|
219
|
-
promise = promise
|
|
270
|
+
promise = promise,
|
|
220
271
|
)
|
|
221
272
|
|
|
222
273
|
@ReactMethod
|
|
223
|
-
override fun getValidDocuments(
|
|
274
|
+
override fun getValidDocuments(
|
|
275
|
+
request: ReadableMap,
|
|
276
|
+
promise: Promise,
|
|
277
|
+
) = launch(
|
|
224
278
|
work = { SmileID.api.getValidDocuments(request = request.toProductsConfigRequest()) },
|
|
225
279
|
clazz = ValidDocumentsResponse::class.java,
|
|
226
|
-
promise = promise
|
|
280
|
+
promise = promise,
|
|
227
281
|
)
|
|
228
282
|
|
|
229
283
|
@ReactMethod
|
|
230
|
-
override fun getServices(promise: Promise) =
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
284
|
+
override fun getServices(promise: Promise) =
|
|
285
|
+
launch(
|
|
286
|
+
work = { SmileID.api.getServices() },
|
|
287
|
+
clazz = ServicesResponse::class.java,
|
|
288
|
+
promise = promise,
|
|
289
|
+
)
|
|
235
290
|
|
|
236
291
|
@ReactMethod
|
|
237
|
-
override fun pollSmartSelfieJobStatus(
|
|
292
|
+
override fun pollSmartSelfieJobStatus(
|
|
293
|
+
request: ReadableMap,
|
|
294
|
+
promise: Promise,
|
|
295
|
+
) = launch(
|
|
238
296
|
work = {
|
|
239
297
|
val jobStatusRequest = request.toJobStatusRequest()
|
|
240
|
-
val interval =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
298
|
+
val interval =
|
|
299
|
+
request.getIntOrDefault("interval") ?: run {
|
|
300
|
+
throw IllegalArgumentException("interval is required")
|
|
301
|
+
}
|
|
302
|
+
val numAttempts =
|
|
303
|
+
request.getIntOrDefault("numAttempts") ?: run {
|
|
304
|
+
throw IllegalArgumentException("numAttempts is required")
|
|
305
|
+
}
|
|
246
306
|
pollJobStatus(
|
|
247
307
|
apiCall = SmileID.api::pollSmartSelfieJobStatus,
|
|
248
308
|
request = jobStatusRequest,
|
|
@@ -251,19 +311,24 @@ class SmileIdModule internal constructor(
|
|
|
251
311
|
)
|
|
252
312
|
},
|
|
253
313
|
clazz = SmartSelfieJobStatusResponse::class.java,
|
|
254
|
-
promise = promise
|
|
314
|
+
promise = promise,
|
|
255
315
|
)
|
|
256
316
|
|
|
257
317
|
@ReactMethod
|
|
258
|
-
override fun pollDocumentVerificationJobStatus(
|
|
318
|
+
override fun pollDocumentVerificationJobStatus(
|
|
319
|
+
request: ReadableMap,
|
|
320
|
+
promise: Promise,
|
|
321
|
+
) = launch(
|
|
259
322
|
work = {
|
|
260
323
|
val jobStatusRequest = request.toJobStatusRequest()
|
|
261
|
-
val interval =
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
324
|
+
val interval =
|
|
325
|
+
request.getIntOrDefault("interval") ?: run {
|
|
326
|
+
throw IllegalArgumentException("interval is required")
|
|
327
|
+
}
|
|
328
|
+
val numAttempts =
|
|
329
|
+
request.getIntOrDefault("numAttempts") ?: run {
|
|
330
|
+
throw IllegalArgumentException("numAttempts is required")
|
|
331
|
+
}
|
|
267
332
|
pollJobStatus(
|
|
268
333
|
apiCall = SmileID.api::pollDocumentVerificationJobStatus,
|
|
269
334
|
request = jobStatusRequest,
|
|
@@ -272,19 +337,24 @@ class SmileIdModule internal constructor(
|
|
|
272
337
|
)
|
|
273
338
|
},
|
|
274
339
|
clazz = DocumentVerificationJobStatusResponse::class.java,
|
|
275
|
-
promise = promise
|
|
340
|
+
promise = promise,
|
|
276
341
|
)
|
|
277
342
|
|
|
278
343
|
@ReactMethod
|
|
279
|
-
override fun pollBiometricKycJobStatus(
|
|
344
|
+
override fun pollBiometricKycJobStatus(
|
|
345
|
+
request: ReadableMap,
|
|
346
|
+
promise: Promise,
|
|
347
|
+
) = launch(
|
|
280
348
|
work = {
|
|
281
349
|
val jobStatusRequest = request.toJobStatusRequest()
|
|
282
|
-
val interval =
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
350
|
+
val interval =
|
|
351
|
+
request.getIntOrDefault("interval") ?: run {
|
|
352
|
+
throw IllegalArgumentException("interval is required")
|
|
353
|
+
}
|
|
354
|
+
val numAttempts =
|
|
355
|
+
request.getIntOrDefault("numAttempts") ?: run {
|
|
356
|
+
throw IllegalArgumentException("numAttempts is required")
|
|
357
|
+
}
|
|
288
358
|
pollJobStatus(
|
|
289
359
|
apiCall = SmileID.api::pollBiometricKycJobStatus,
|
|
290
360
|
request = jobStatusRequest,
|
|
@@ -293,53 +363,58 @@ class SmileIdModule internal constructor(
|
|
|
293
363
|
)
|
|
294
364
|
},
|
|
295
365
|
clazz = BiometricKycJobStatusResponse::class.java,
|
|
296
|
-
promise = promise
|
|
366
|
+
promise = promise,
|
|
297
367
|
)
|
|
298
368
|
|
|
299
369
|
@ReactMethod
|
|
300
|
-
override fun pollEnhancedDocumentVerificationJobStatus(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
370
|
+
override fun pollEnhancedDocumentVerificationJobStatus(
|
|
371
|
+
request: ReadableMap,
|
|
372
|
+
promise: Promise,
|
|
373
|
+
) = launch(
|
|
374
|
+
work = {
|
|
375
|
+
val jobStatusRequest = request.toJobStatusRequest()
|
|
376
|
+
val interval =
|
|
377
|
+
request.getIntOrDefault("interval") ?: run {
|
|
305
378
|
throw IllegalArgumentException("interval is required")
|
|
306
379
|
}
|
|
307
|
-
|
|
380
|
+
val numAttempts =
|
|
381
|
+
request.getIntOrDefault("numAttempts") ?: run {
|
|
308
382
|
throw IllegalArgumentException("numAttempts is required")
|
|
309
383
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
384
|
+
pollJobStatus(
|
|
385
|
+
apiCall = SmileID.api::pollEnhancedDocumentVerificationJobStatus,
|
|
386
|
+
request = jobStatusRequest,
|
|
387
|
+
interval = interval.toLong(),
|
|
388
|
+
numAttempts = numAttempts.toLong(),
|
|
389
|
+
)
|
|
390
|
+
},
|
|
391
|
+
clazz = EnhancedDocumentVerificationJobStatusResponse::class.java,
|
|
392
|
+
promise = promise,
|
|
393
|
+
)
|
|
320
394
|
|
|
321
395
|
private suspend fun <RequestType, ResponseType> pollJobStatus(
|
|
322
396
|
apiCall: suspend (RequestType, Duration, Int) -> Flow<ResponseType>,
|
|
323
397
|
request: RequestType,
|
|
324
398
|
interval: Long,
|
|
325
399
|
numAttempts: Long,
|
|
326
|
-
): ResponseType
|
|
327
|
-
|
|
400
|
+
): ResponseType =
|
|
401
|
+
try {
|
|
328
402
|
val response =
|
|
329
403
|
withContext(Dispatchers.IO) {
|
|
330
404
|
apiCall(request, interval.milliseconds, numAttempts.toInt())
|
|
331
405
|
.map {
|
|
332
406
|
it
|
|
333
|
-
}
|
|
334
|
-
.last()
|
|
407
|
+
}.last()
|
|
335
408
|
}
|
|
336
409
|
response
|
|
337
410
|
} catch (e: Exception) {
|
|
338
411
|
throw e
|
|
339
412
|
}
|
|
340
|
-
}
|
|
341
413
|
|
|
342
|
-
private fun <T> toJson(
|
|
414
|
+
private fun <T> toJson(
|
|
415
|
+
result: T,
|
|
416
|
+
clazz: Class<T>,
|
|
417
|
+
): String {
|
|
343
418
|
val adapter = SmileID.moshi.adapter(clazz)
|
|
344
419
|
return adapter.toJson(result)
|
|
345
420
|
}
|
|
@@ -348,11 +423,12 @@ class SmileIdModule internal constructor(
|
|
|
348
423
|
work: suspend () -> T,
|
|
349
424
|
clazz: Class<T>,
|
|
350
425
|
promise: Promise,
|
|
351
|
-
scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
|
|
426
|
+
scope: CoroutineScope = CoroutineScope(Dispatchers.IO),
|
|
352
427
|
) {
|
|
353
|
-
val handler =
|
|
354
|
-
|
|
355
|
-
|
|
428
|
+
val handler =
|
|
429
|
+
CoroutineExceptionHandler { _, throwable ->
|
|
430
|
+
promise.reject(throwable)
|
|
431
|
+
}
|
|
356
432
|
scope.launch(handler) {
|
|
357
433
|
try {
|
|
358
434
|
val result = work()
|
package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt
CHANGED
|
@@ -4,6 +4,7 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
4
4
|
import com.facebook.react.bridge.ReadableMap
|
|
5
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
6
6
|
import com.smileidentity.models.ConsentInformation
|
|
7
|
+
import com.smileidentity.models.ConsentedInformation
|
|
7
8
|
import com.smileidentity.react.toConsentInfo
|
|
8
9
|
import com.smileidentity.react.toIdInfo
|
|
9
10
|
import com.smileidentity.react.utils.getBoolOrDefault
|
|
@@ -31,11 +32,13 @@ class SmileIDBiometricKYCViewManager(
|
|
|
31
32
|
val idInfo = idInfoMap.toIdInfo()
|
|
32
33
|
view.consentInformation = it.getMapOrDefault("consentInformation")?.toConsentInfo()
|
|
33
34
|
?: ConsentInformation(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
consented = ConsentedInformation(
|
|
36
|
+
consentGrantedDate = getCurrentIsoTimestamp(),
|
|
37
|
+
personalDetails = false,
|
|
38
|
+
contactInformation = false,
|
|
39
|
+
documentInformation = false
|
|
40
|
+
),
|
|
41
|
+
)
|
|
39
42
|
view.extraPartnerParams = it.getImmutableMapOrDefault("extraPartnerParams")
|
|
40
43
|
view.userId = it.getStringOrDefault("userId")
|
|
41
44
|
view.jobId = it.getStringOrDefault("jobId")
|
|
@@ -7,6 +7,7 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
7
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
9
|
import com.smileidentity.models.ConsentInformation
|
|
10
|
+
import com.smileidentity.models.ConsentedInformation
|
|
10
11
|
import com.smileidentity.react.toConsentInfo
|
|
11
12
|
import com.smileidentity.react.toIdInfo
|
|
12
13
|
import com.smileidentity.react.utils.getBoolOrDefault
|
|
@@ -37,10 +38,12 @@ class SmileIDEnhancedDocumentVerificationViewManager(
|
|
|
37
38
|
)
|
|
38
39
|
view.consentInformation = it.getMapOrDefault("consentInformation")?.toConsentInfo()
|
|
39
40
|
?: ConsentInformation(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
consented = ConsentedInformation(
|
|
42
|
+
consentGrantedDate = getCurrentIsoTimestamp(),
|
|
43
|
+
personalDetails = false,
|
|
44
|
+
contactInformation = false,
|
|
45
|
+
documentInformation = false
|
|
46
|
+
),
|
|
44
47
|
)
|
|
45
48
|
view.extraPartnerParams = it.getImmutableMapOrDefault("extraPartnerParams")
|
|
46
49
|
view.userId = it.getStringOrDefault("userId")
|