@smile_identity/react-native 10.3.3 → 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 +4 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +169 -93
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentCaptureView.kt +13 -11
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt +32 -45
- package/ios/RNSmileID.swift +469 -460
- 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/View/SmileIDDocumentCaptureView.swift +1 -2
- package/ios/ViewManagers/SmileIDSmartSelfieCaptureViewManager.swift +1 -2
- package/package.json +2 -2
- package/react-native-smile-id.podspec +10 -5
package/android/build.gradle
CHANGED
|
@@ -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 {
|
|
@@ -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()
|
|
@@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.consumeWindowInsets
|
|
|
7
7
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
8
8
|
import androidx.compose.foundation.layout.statusBars
|
|
9
9
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
10
|
+
import androidx.compose.material3.MaterialTheme
|
|
11
|
+
import androidx.compose.material3.Surface
|
|
10
12
|
import androidx.compose.runtime.Composable
|
|
11
13
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
12
14
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
@@ -17,9 +19,12 @@ import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
|
17
19
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
18
20
|
import com.smileidentity.R
|
|
19
21
|
import com.smileidentity.SmileID
|
|
22
|
+
import com.smileidentity.compose.SmartSelfieEnrollmentEnhanced
|
|
20
23
|
import com.smileidentity.compose.document.DocumentCaptureScreen
|
|
21
24
|
import com.smileidentity.compose.document.DocumentCaptureSide
|
|
22
25
|
import com.smileidentity.compose.theme.colorScheme
|
|
26
|
+
import com.smileidentity.compose.theme.typography
|
|
27
|
+
import com.smileidentity.metadata.LocalMetadataProvider
|
|
23
28
|
import com.smileidentity.react.results.DocumentCaptureResult
|
|
24
29
|
import com.smileidentity.react.utils.DocumentCaptureResultAdapter
|
|
25
30
|
import com.smileidentity.util.randomJobId
|
|
@@ -36,16 +41,13 @@ class SmileIDDocumentCaptureView(context: ReactApplicationContext) : SmileIDView
|
|
|
36
41
|
composeView.apply {
|
|
37
42
|
val customViewModelStoreOwner = CustomViewModelStoreOwner()
|
|
38
43
|
setContent {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.fillMaxSize()
|
|
47
|
-
) {
|
|
48
|
-
RenderDocumentCaptureScreen()
|
|
44
|
+
LocalMetadataProvider.MetadataProvider {
|
|
45
|
+
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
46
|
+
MaterialTheme(colorScheme = SmileID.colorScheme, typography = SmileID.typography) {
|
|
47
|
+
Surface(content = {
|
|
48
|
+
RenderDocumentCaptureScreen()
|
|
49
|
+
})
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -87,7 +89,7 @@ class SmileIDDocumentCaptureView(context: ReactApplicationContext) : SmileIDView
|
|
|
87
89
|
.build()
|
|
88
90
|
val result = DocumentCaptureResult(
|
|
89
91
|
documentFrontFile = if (front) file else null,
|
|
90
|
-
documentBackFile =
|
|
92
|
+
documentBackFile = if (!front) file else null,
|
|
91
93
|
)
|
|
92
94
|
val json = try {
|
|
93
95
|
newMoshi
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt
CHANGED
|
@@ -14,10 +14,8 @@ import androidx.compose.runtime.Composable
|
|
|
14
14
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
15
15
|
import androidx.compose.runtime.getValue
|
|
16
16
|
import androidx.compose.runtime.mutableStateOf
|
|
17
|
-
import androidx.compose.runtime.remember
|
|
18
17
|
import androidx.compose.runtime.saveable.rememberSaveable
|
|
19
18
|
import androidx.compose.runtime.setValue
|
|
20
|
-
import androidx.compose.runtime.toMutableStateList
|
|
21
19
|
import androidx.compose.ui.Modifier
|
|
22
20
|
import androidx.compose.ui.graphics.Color
|
|
23
21
|
import androidx.compose.ui.graphics.asImageBitmap
|
|
@@ -30,19 +28,13 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
30
28
|
import com.smileidentity.R
|
|
31
29
|
import com.smileidentity.SmileID
|
|
32
30
|
import com.smileidentity.SmileIDOptIn
|
|
33
|
-
import com.smileidentity.compose.SmartSelfieEnrollment
|
|
34
31
|
import com.smileidentity.compose.SmartSelfieEnrollmentEnhanced
|
|
35
32
|
import com.smileidentity.compose.components.ImageCaptureConfirmationDialog
|
|
36
|
-
import com.smileidentity.compose.components.LocalMetadata
|
|
37
33
|
import com.smileidentity.compose.selfie.SelfieCaptureScreen
|
|
38
34
|
import com.smileidentity.compose.selfie.SmartSelfieInstructionsScreen
|
|
39
35
|
import com.smileidentity.compose.theme.colorScheme
|
|
40
36
|
import com.smileidentity.compose.theme.typography
|
|
41
|
-
import com.smileidentity.
|
|
42
|
-
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
43
|
-
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
44
|
-
import com.smileidentity.results.SmartSelfieResult
|
|
45
|
-
import com.smileidentity.results.SmileIDResult
|
|
37
|
+
import com.smileidentity.metadata.LocalMetadataProvider
|
|
46
38
|
import com.smileidentity.util.randomJobId
|
|
47
39
|
import com.smileidentity.util.randomUserId
|
|
48
40
|
import com.smileidentity.viewmodel.SelfieUiState
|
|
@@ -59,23 +51,26 @@ class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDS
|
|
|
59
51
|
composeView.apply {
|
|
60
52
|
val customViewModelStoreOwner = CustomViewModelStoreOwner()
|
|
61
53
|
setContent {
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
LocalMetadataProvider.MetadataProvider {
|
|
55
|
+
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
64
56
|
val userId = randomUserId()
|
|
65
57
|
MaterialTheme(colorScheme = SmileID.colorScheme, typography = SmileID.typography) {
|
|
66
58
|
Surface(content = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
if (useStrictMode) {
|
|
60
|
+
SmileID.SmartSelfieEnrollmentEnhanced(
|
|
61
|
+
userId = userId,
|
|
62
|
+
showAttribution = showAttribution,
|
|
63
|
+
showInstructions = showInstructions,
|
|
64
|
+
skipApiSubmission = true,
|
|
65
|
+
extraPartnerParams = extraPartnerParams,
|
|
66
|
+
onResult = { res -> handleResultCallback(res) },
|
|
67
|
+
)
|
|
68
|
+
} else {
|
|
69
|
+
RenderSmartSelfieCaptureContent()
|
|
70
|
+
}
|
|
75
71
|
})
|
|
76
72
|
}
|
|
77
|
-
|
|
78
|
-
RenderSmartSelfieCaptureContent()
|
|
73
|
+
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
}
|
|
@@ -86,8 +81,6 @@ class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDS
|
|
|
86
81
|
private fun RenderSmartSelfieCaptureContent() {
|
|
87
82
|
val userId = randomUserId()
|
|
88
83
|
val jobId = randomJobId()
|
|
89
|
-
val metadata = Metadata.default().items.toMutableStateList()
|
|
90
|
-
|
|
91
84
|
val viewModel: SelfieViewModel = viewModel(
|
|
92
85
|
factory = viewModelFactory {
|
|
93
86
|
SelfieViewModel(
|
|
@@ -96,7 +89,7 @@ class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDS
|
|
|
96
89
|
jobId = jobId,
|
|
97
90
|
allowNewEnroll = false,
|
|
98
91
|
skipApiSubmission = true,
|
|
99
|
-
metadata =
|
|
92
|
+
metadata = mutableListOf(),
|
|
100
93
|
)
|
|
101
94
|
},
|
|
102
95
|
)
|
|
@@ -104,27 +97,21 @@ class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDS
|
|
|
104
97
|
val uiState = viewModel.uiState.collectAsStateWithLifecycle().value
|
|
105
98
|
var acknowledgedInstructions by rememberSaveable { mutableStateOf(false) }
|
|
106
99
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
when {
|
|
113
|
-
showInstructions && !acknowledgedInstructions -> SmartSelfieInstructionsScreen(
|
|
114
|
-
showAttribution = showAttribution,
|
|
115
|
-
) {
|
|
116
|
-
acknowledgedInstructions = true
|
|
117
|
-
}
|
|
118
|
-
uiState.processingState != null -> HandleProcessingState(viewModel)
|
|
119
|
-
uiState.selfieToConfirm != null -> HandleSelfieConfirmation(
|
|
120
|
-
showConfirmation,
|
|
121
|
-
uiState,
|
|
122
|
-
viewModel,
|
|
123
|
-
)
|
|
124
|
-
else -> RenderSelfieCaptureScreen(userId, jobId, allowAgentMode ?: true, viewModel)
|
|
125
|
-
}
|
|
126
|
-
})
|
|
100
|
+
when {
|
|
101
|
+
showInstructions && !acknowledgedInstructions -> SmartSelfieInstructionsScreen(
|
|
102
|
+
showAttribution = showAttribution,
|
|
103
|
+
) {
|
|
104
|
+
acknowledgedInstructions = true
|
|
127
105
|
}
|
|
106
|
+
|
|
107
|
+
uiState.processingState != null -> HandleProcessingState(viewModel)
|
|
108
|
+
uiState.selfieToConfirm != null -> HandleSelfieConfirmation(
|
|
109
|
+
showConfirmation,
|
|
110
|
+
uiState,
|
|
111
|
+
viewModel,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
else -> RenderSelfieCaptureScreen(userId, jobId, allowAgentMode ?: true, viewModel)
|
|
128
115
|
}
|
|
129
116
|
}
|
|
130
117
|
|
|
@@ -185,7 +172,7 @@ class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDS
|
|
|
185
172
|
@Composable
|
|
186
173
|
private fun HandleProcessingState(viewModel: SelfieViewModel) {
|
|
187
174
|
try {
|
|
188
|
-
viewModel.onFinished { res -> handleResultCallback(res)}
|
|
175
|
+
viewModel.onFinished { res -> handleResultCallback(res) }
|
|
189
176
|
} catch (e: Exception) {
|
|
190
177
|
emitFailure(e)
|
|
191
178
|
}
|