@smile_identity/react-native 10.0.2 → 10.1.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.
@@ -4,7 +4,6 @@ buildscript {
4
4
  // Buildscript is evaluated before everything else so we can't use getExtOrDefault
5
5
  def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SmileId_kotlinVersion"]
6
6
  def smile_id_sdk_version = rootProject.ext.has("androidVersion") ? rootProject.ext.get("androidVersion") : project.properties["SmileId_androidVersion"]
7
- project.logger.debug('Japhet Ndhlovu - SmileId - build.gradle - kotlin_version: ' + kotlin_version)
8
7
 
9
8
  repositories {
10
9
  google()
@@ -1,6 +1,6 @@
1
- SmileId_kotlinVersion=1.9.23
1
+ SmileId_kotlinVersion=2.0.0
2
2
  SmileId_minSdkVersion=21
3
3
  SmileId_targetSdkVersion=34
4
4
  SmileId_compileSdkVersion=34
5
5
  SmileId_ndkversion=21.4.7075529
6
- SmileId_androidVersion=10.0.4
6
+ SmileId_androidVersion=10.1.4
@@ -8,11 +8,22 @@ import com.smileidentity.SmileID
8
8
  import com.smileidentity.SmileIDCrashReporting
9
9
  import com.smileidentity.SmileIdSpec
10
10
  import com.smileidentity.models.EnhancedKycRequest
11
+ import com.smileidentity.networking.pollBiometricKycJobStatus
12
+ import com.smileidentity.networking.pollDocumentVerificationJobStatus
13
+ import com.smileidentity.networking.pollEnhancedDocumentVerificationJobStatus
14
+ import com.smileidentity.networking.pollSmartSelfieJobStatus
15
+ import com.smileidentity.react.utils.getIntOrDefault
11
16
  import com.smileidentity.react.utils.getStringOrDefault
12
17
  import kotlinx.coroutines.CoroutineExceptionHandler
13
18
  import kotlinx.coroutines.CoroutineScope
14
19
  import kotlinx.coroutines.Dispatchers
20
+ import kotlinx.coroutines.flow.Flow
21
+ import kotlinx.coroutines.flow.map
22
+ import kotlinx.coroutines.flow.single
15
23
  import kotlinx.coroutines.launch
24
+ import kotlinx.coroutines.withContext
25
+ import kotlin.time.Duration
26
+ import kotlin.time.Duration.Companion.milliseconds
16
27
 
17
28
 
18
29
  class SmileIdModule internal constructor(context: ReactApplicationContext) :
@@ -82,10 +93,11 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
82
93
  )
83
94
 
84
95
  @ReactMethod
85
- override fun getEnhancedDocumentVerificationJobStatus(request: ReadableMap, promise: Promise) = launch(
86
- work = { SmileID.api.getEnhancedDocumentVerificationJobStatus(request = request.toJobStatusRequest()) },
87
- promise = promise
88
- )
96
+ override fun getEnhancedDocumentVerificationJobStatus(request: ReadableMap, promise: Promise) =
97
+ launch(
98
+ work = { SmileID.api.getEnhancedDocumentVerificationJobStatus(request = request.toJobStatusRequest()) },
99
+ promise = promise
100
+ )
89
101
 
90
102
  @ReactMethod
91
103
  override fun getProductsConfig(request: ReadableMap, promise: Promise) = launch(
@@ -105,6 +117,106 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
105
117
  promise = promise
106
118
  )
107
119
 
120
+ @ReactMethod
121
+ override fun pollSmartSelfieJobStatus(request: ReadableMap, promise: Promise) = launch(
122
+ work = {
123
+ val jobStatusRequest = request.toJobStatusRequest()
124
+ val interval = request.getIntOrDefault("interval") ?: run {
125
+ throw IllegalArgumentException("interval is required")
126
+ }
127
+ val numAttempts = request.getIntOrDefault("numAttempts") ?: run {
128
+ throw IllegalArgumentException("numAttempts is required")
129
+ }
130
+ pollJobStatus(
131
+ apiCall = SmileID.api::pollSmartSelfieJobStatus,
132
+ request = jobStatusRequest,
133
+ interval = interval.toLong(),
134
+ numAttempts = numAttempts.toLong(),
135
+ )
136
+ },
137
+ promise = promise
138
+ )
139
+
140
+ @ReactMethod
141
+ override fun pollDocumentVerificationJobStatus(request: ReadableMap, promise: Promise) = launch(
142
+ work = {
143
+ val jobStatusRequest = request.toJobStatusRequest()
144
+ val interval = request.getIntOrDefault("interval") ?: run {
145
+ throw IllegalArgumentException("interval is required")
146
+ }
147
+ val numAttempts = request.getIntOrDefault("numAttempts") ?: run {
148
+ throw IllegalArgumentException("numAttempts is required")
149
+ }
150
+ pollJobStatus(
151
+ apiCall = SmileID.api::pollDocumentVerificationJobStatus,
152
+ request = jobStatusRequest,
153
+ interval = interval.toLong(),
154
+ numAttempts = numAttempts.toLong(),
155
+ )
156
+ },
157
+ promise = promise
158
+ )
159
+
160
+ @ReactMethod
161
+ override fun pollBiometricKycJobStatus(request: ReadableMap, promise: Promise) = launch(
162
+ work = {
163
+ val jobStatusRequest = request.toJobStatusRequest()
164
+ val interval = request.getIntOrDefault("interval") ?: run {
165
+ throw IllegalArgumentException("interval is required")
166
+ }
167
+ val numAttempts = request.getIntOrDefault("numAttempts") ?: run {
168
+ throw IllegalArgumentException("numAttempts is required")
169
+ }
170
+ pollJobStatus(
171
+ apiCall = SmileID.api::pollBiometricKycJobStatus,
172
+ request = jobStatusRequest,
173
+ interval = interval.toLong(),
174
+ numAttempts = numAttempts.toLong(),
175
+ )
176
+ },
177
+ promise = promise
178
+ )
179
+
180
+ @ReactMethod
181
+ override fun pollEnhancedDocumentVerificationJobStatus(request: ReadableMap, promise: Promise) =
182
+ launch(
183
+ work = {
184
+ val jobStatusRequest = request.toJobStatusRequest()
185
+ val interval = request.getIntOrDefault("interval") ?: run {
186
+ throw IllegalArgumentException("interval is required")
187
+ }
188
+ val numAttempts = request.getIntOrDefault("numAttempts") ?: run {
189
+ throw IllegalArgumentException("numAttempts is required")
190
+ }
191
+ pollJobStatus(
192
+ apiCall = SmileID.api::pollEnhancedDocumentVerificationJobStatus,
193
+ request = jobStatusRequest,
194
+ interval = interval.toLong(),
195
+ numAttempts = numAttempts.toLong(),
196
+ )
197
+ },
198
+ promise = promise
199
+ )
200
+
201
+ private suspend fun <RequestType, ResponseType> pollJobStatus(
202
+ apiCall: suspend (RequestType, Duration, Int) -> Flow<ResponseType>,
203
+ request: RequestType,
204
+ interval: Long,
205
+ numAttempts: Long,
206
+ ): ResponseType {
207
+ return try {
208
+ val response =
209
+ withContext(Dispatchers.IO) {
210
+ apiCall(request, interval.milliseconds, numAttempts.toInt())
211
+ .map { it }
212
+ .single()
213
+ }
214
+ response
215
+ } catch (e: Exception) {
216
+ throw e
217
+ }
218
+ }
219
+
108
220
  private fun <T> launch(
109
221
  work: suspend () -> T,
110
222
  promise: Promise,
@@ -35,4 +35,12 @@ abstract class SmileIdSpec internal constructor(context: ReactApplicationContext
35
35
  abstract fun getValidDocuments(request: ReadableMap, promise: Promise)
36
36
 
37
37
  abstract fun getServices(promise: Promise)
38
+
39
+ abstract fun pollSmartSelfieJobStatus(request: ReadableMap, promise: Promise)
40
+
41
+ abstract fun pollDocumentVerificationJobStatus(request: ReadableMap, promise: Promise)
42
+
43
+ abstract fun pollBiometricKycJobStatus(request: ReadableMap, promise: Promise)
44
+
45
+ abstract fun pollEnhancedDocumentVerificationJobStatus(request: ReadableMap, promise: Promise)
38
46
  }
package/ios/RNSmileID.mm CHANGED
@@ -14,4 +14,9 @@ RCT_EXTERN_METHOD(getEnhancedDocumentVerificationJobStatus:(NSDictionary *)reque
14
14
  RCT_EXTERN_METHOD(getProductsConfig:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
15
15
  RCT_EXTERN_METHOD(getValidDocuments:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
16
16
  RCT_EXTERN_METHOD(getServicesWithResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
17
+ RCT_EXTERN_METHOD(getJobStatus:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
18
+ RCT_EXTERN_METHOD(pollSmartSelfieJobStatus:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
19
+ RCT_EXTERN_METHOD(pollDocumentVerificationJobStatus:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
20
+ RCT_EXTERN_METHOD(pollBiometricKycJobStatus:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
21
+ RCT_EXTERN_METHOD(pollEnhancedDocumentVerificationJobStatus:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
17
22
  @end
@@ -37,7 +37,7 @@ class RNSmileID: NSObject {
37
37
  .sink(
38
38
  receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
39
39
  receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject)
40
- }).store(in: &cancellables)
40
+ }).store(in: &cancellables)
41
41
  }
42
42
 
43
43
  @objc(upload:request:withResolver:withRejecter:)
@@ -228,7 +228,7 @@ class RNSmileID: NSObject {
228
228
  .sink(
229
229
  receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
230
230
  receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject)
231
- }).store(in: &cancellables)
231
+ }).store(in: &cancellables)
232
232
  }
233
233
 
234
234
  @objc(getValidDocuments:withResolver:withRejecter:)
@@ -252,7 +252,8 @@ class RNSmileID: NSObject {
252
252
  .store(in: &cancellables)
253
253
  }
254
254
 
255
- private func getJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
255
+ @objc(getJobStatus:withResolver:withRejecter:)
256
+ func getJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
256
257
  guard let jobStatusRequest = request.toJobStatusRequest() else {
257
258
  reject("Error", "Invalid job status request", nil)
258
259
  return
@@ -264,6 +265,148 @@ class RNSmileID: NSObject {
264
265
  .store(in: &cancellables)
265
266
  }
266
267
 
268
+ @objc(pollSmartSelfieJobStatus:withResolver:withRejecter:)
269
+ func pollSmartSelfieJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
270
+ guard let jobStatusRequest = request.toJobStatusRequest() else {
271
+ reject("Error", "Invalid job status request", nil)
272
+ return
273
+ }
274
+
275
+ guard let interval = request["interval"] as? Int64 else {
276
+ reject("Error", "interval is required", nil)
277
+ return
278
+ }
279
+
280
+ guard let numAttempts = request["numAttempts"] as? Int64 else {
281
+ reject("Error", "numAttempts is required", nil)
282
+ return
283
+ }
284
+
285
+ pollJobStatus(
286
+ apiCall: SmileID.api.pollSmartSelfieJobStatus,
287
+ request: jobStatusRequest,
288
+ interval: interval,
289
+ numAttempts: numAttempts,
290
+ resolve: resolve,
291
+ reject: reject
292
+ )
293
+ }
294
+
295
+ @objc(pollDocumentVerificationJobStatus:withResolver:withRejecter:)
296
+ func pollDocumentVerificationJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
297
+ guard let jobStatusRequest = request.toJobStatusRequest() else {
298
+ reject("Error", "Invalid job status request", nil)
299
+ return
300
+ }
301
+
302
+ guard let interval = request["interval"] as? Int64 else {
303
+ reject("Error", "interval is required", nil)
304
+ return
305
+ }
306
+
307
+ guard let numAttempts = request["numAttempts"] as? Int64 else {
308
+ reject("Error", "numAttempts is required", nil)
309
+ return
310
+ }
311
+
312
+ pollJobStatus(
313
+ apiCall: SmileID.api.pollDocumentVerificationJobStatus,
314
+ request: jobStatusRequest,
315
+ interval: interval,
316
+ numAttempts: numAttempts,
317
+ resolve: resolve,
318
+ reject: reject
319
+ )
320
+ }
321
+
322
+ @objc(pollBiometricKycJobStatus:withResolver:withRejecter:)
323
+ func pollBiometricKycJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
324
+ guard let jobStatusRequest = request.toJobStatusRequest() else {
325
+ reject("Error", "Invalid job status request", nil)
326
+ return
327
+ }
328
+
329
+ guard let interval = request["interval"] as? Int64 else {
330
+ reject("Error", "interval is required", nil)
331
+ return
332
+ }
333
+
334
+ guard let numAttempts = request["numAttempts"] as? Int64 else {
335
+ reject("Error", "numAttempts is required", nil)
336
+ return
337
+ }
338
+
339
+ pollJobStatus(
340
+ apiCall: SmileID.api.pollBiometricKycJobStatus,
341
+ request: jobStatusRequest,
342
+ interval: interval,
343
+ numAttempts: numAttempts,
344
+ resolve: resolve,
345
+ reject: reject
346
+ )
347
+ }
348
+
349
+ @objc(pollEnhancedDocumentVerificationJobStatus:withResolver:withRejecter:)
350
+ func pollEnhancedDocumentVerificationJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
351
+ guard let jobStatusRequest = request.toJobStatusRequest() else {
352
+ reject("Error", "Invalid job status request", nil)
353
+ return
354
+ }
355
+
356
+ guard let interval = request["interval"] as? Int64 else {
357
+ reject("Error", "interval is required", nil)
358
+ return
359
+ }
360
+
361
+ guard let numAttempts = request["numAttempts"] as? Int64 else {
362
+ reject("Error", "numAttempts is required", nil)
363
+ return
364
+ }
365
+
366
+ pollJobStatus(
367
+ apiCall: SmileID.api.pollEnhancedDocumentVerificationJobStatus,
368
+ request: jobStatusRequest,
369
+ interval: interval,
370
+ numAttempts: numAttempts,
371
+ resolve: resolve,
372
+ reject: reject
373
+ )
374
+ }
375
+
376
+ func pollJobStatus<RequestType, ResponseType: Encodable>(
377
+ apiCall: @escaping (RequestType, TimeInterval, Int) -> AnyPublisher<ResponseType, Error>,
378
+ request: RequestType,
379
+ interval: Int64,
380
+ numAttempts: Int64,
381
+ resolve: @escaping RCTPromiseResolveBlock,
382
+ reject: @escaping RCTPromiseRejectBlock
383
+ ) {
384
+ let timeInterval = convertToTimeInterval(milliSeconds: interval)
385
+ guard let numAttemptsInt = Int(exactly: numAttempts) else {
386
+ reject("InvalidNumAttempts", "Invalid numAttempts value", NSError(domain: "Invalid numAttempts value", code: -1, userInfo: nil))
387
+ return
388
+ }
389
+
390
+ apiCall(request, timeInterval, numAttemptsInt)
391
+ .sink(receiveCompletion: { status in
392
+ switch status {
393
+ case .failure(let error):
394
+ reject("ApiCallFailure", "API call failed with error: \(error.localizedDescription)", error)
395
+ case .finished:
396
+ break
397
+ }
398
+ }, receiveValue: { [self] response in
399
+ resolveResponse(response, resolve: resolve, reject: reject)
400
+ })
401
+ .store(in: &cancellables)
402
+ }
403
+
404
+
405
+ func convertToTimeInterval(milliSeconds:Int64) -> TimeInterval {
406
+ let seconds = milliSeconds/1000
407
+ return TimeInterval(seconds)
408
+ }
409
+
267
410
  private func handleCompletion(_ completion: Subscribers.Completion<Error>, reject: @escaping RCTPromiseRejectBlock) {
268
411
  switch completion {
269
412
  case let .failure(error):
@@ -30,6 +30,21 @@ struct SmileIDBiometricKYCView: View {
30
30
  }
31
31
 
32
32
  extension SmileIDBiometricKYCView: BiometricKycResultDelegate {
33
+ func didSucceed(selfieImage: URL, livenessImages: [URL], didSubmitBiometricJob: Bool) {
34
+ let encoder = JSONEncoder()
35
+ var params: [String: Any] = [
36
+ "selfie": selfieImage.absoluteString,
37
+ "documentFrontImage": livenessImages,
38
+ "didSubmitBiometricJob": didSubmitBiometricJob,
39
+ ]
40
+
41
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted) else {
42
+ product.onResult?(["error": SmileIDError.unknown("SmileIDBiometricKYCView encoding error")])
43
+ return
44
+ }
45
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
46
+ }
47
+
33
48
  func didSucceed(
34
49
  selfieImage _: URL,
35
50
  livenessImages _: [URL],
@@ -39,7 +54,7 @@ extension SmileIDBiometricKYCView: BiometricKycResultDelegate {
39
54
  let jsonData = try! encoder.encode(jobStatusResponse)
40
55
  product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
41
56
  }
42
-
57
+
43
58
  func didError(error: Error) {
44
59
  product.onResult?(["error": error.localizedDescription])
45
60
  }
@@ -35,14 +35,18 @@ struct SmileIDDocumentVerificationView: View {
35
35
  }
36
36
 
37
37
  extension SmileIDDocumentVerificationView: DocumentVerificationResultDelegate {
38
- func didSucceed(
39
- selfie _: URL,
40
- documentFrontImage _: URL,
41
- documentBackImage _: URL?,
42
- jobStatusResponse: DocumentVerificationJobStatusResponse
43
- ) {
38
+ func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool) {
44
39
  let encoder = JSONEncoder()
45
- guard let jsonData = try? encoder.encode(jobStatusResponse) else {
40
+ var params: [String: Any] = [
41
+ "selfie": selfie.absoluteString,
42
+ "documentFrontImage": documentFrontImage.absoluteString,
43
+ "didSubmitDocumentVerificationJob": didSubmitDocumentVerificationJob
44
+ ]
45
+ if let documentBackImage = documentBackImage {
46
+ params["documentBackImage"] = documentBackImage.absoluteString
47
+ }
48
+
49
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted) else {
46
50
  product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentVerificationView encoding error")])
47
51
  return
48
52
  }
@@ -35,20 +35,25 @@ struct SmileIDEnhancedDocumentVerificationView: View {
35
35
  }
36
36
 
37
37
  extension SmileIDEnhancedDocumentVerificationView: EnhancedDocumentVerificationResultDelegate {
38
- func didSucceed(
39
- selfie _: URL,
40
- documentFrontImage _: URL,
41
- documentBackImage _: URL?,
42
- jobStatusResponse: EnhancedDocumentVerificationJobStatusResponse
43
- ) {
38
+ func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitEnhancedDocVJob: Bool) {
44
39
  let encoder = JSONEncoder()
45
- guard let jsonData = try? encoder.encode(jobStatusResponse) else {
40
+ var params: [String: Any] = [
41
+ "selfie": selfie.absoluteString,
42
+ "documentFrontImage": documentFrontImage.absoluteString,
43
+ "didSubmitEnhancedDocVJob": didSubmitEnhancedDocVJob,
44
+ ]
45
+ if let documentBackImage = documentBackImage {
46
+ params["documentBackImage"] = documentBackImage.absoluteString
47
+ }
48
+
49
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted) else {
46
50
  product.onResult?(["error": SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error")])
47
51
  return
48
52
  }
49
53
  product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
50
54
  }
51
-
55
+
56
+
52
57
  func didError(error: Error) {
53
58
  product.onResult?(["error": error.localizedDescription])
54
59
  }
@@ -22,27 +22,24 @@ struct SmileIDSmartSelfieAuthView: View {
22
22
  }
23
23
 
24
24
  extension SmileIDSmartSelfieAuthView: SmartSelfieResultDelegate {
25
- func didSucceed(
26
- selfieImage _: URL,
27
- livenessImages _: [URL],
28
- jobStatusResponse: SmartSelfieJobStatusResponse?
29
- ) {
25
+ func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
30
26
  let encoder = JSONEncoder()
31
- let jsonData: String
32
- if let jobStatusResponse {
33
- guard let encodedJsonData = try? encoder.encode(jobStatusResponse) else {
34
- product.onResult?(
35
- ["error": SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error")]
36
- )
37
- return
38
- }
39
- jsonData = String(data: encodedJsonData, encoding: .utf8)!
40
- } else {
41
- jsonData = "null"
27
+ var params: [String: Any] = [
28
+ "selfie": selfieImage.absoluteString,
29
+ "livenessImages": livenessImages,
30
+ ]
31
+ if let apiResponse = apiResponse {
32
+ params["apiResponse"] = apiResponse
42
33
  }
43
- product.onResult?(["result": jsonData])
34
+
35
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted) else {
36
+ product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error")])
37
+ return
38
+ }
39
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
44
40
  }
45
-
41
+
42
+
46
43
  func didError(error: Error) {
47
44
  product.onResult?(["error": error.localizedDescription])
48
45
  }
@@ -22,27 +22,24 @@ struct SmileIDSmartSelfieEnrollmentView: View {
22
22
  }
23
23
 
24
24
  extension SmileIDSmartSelfieEnrollmentView: SmartSelfieResultDelegate {
25
- func didSucceed(
26
- selfieImage _: URL,
27
- livenessImages _: [URL],
28
- jobStatusResponse: SmartSelfieJobStatusResponse?
29
- ) {
25
+ func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
30
26
  let encoder = JSONEncoder()
31
- let jsonData: String
32
- if let jobStatusResponse {
33
- guard let encodedJsonData = try? encoder.encode(jobStatusResponse) else {
34
- product.onResult?(
35
- ["error": SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error")]
36
- )
37
- return
38
- }
39
- jsonData = String(data: encodedJsonData, encoding: .utf8)!
40
- } else {
41
- jsonData = "null"
27
+ var params: [String: Any] = [
28
+ "selfie": selfieImage.absoluteString,
29
+ "livenessImages": livenessImages,
30
+ ]
31
+ if let apiResponse = apiResponse {
32
+ params["apiResponse"] = apiResponse
42
33
  }
43
- product.onResult?(["result": jsonData])
34
+
35
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params, options: .prettyPrinted) else {
36
+ product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error")])
37
+ return
38
+ }
39
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
44
40
  }
45
-
41
+
42
+
46
43
  func didError(error: Error) {
47
44
  product.onResult?(["error": error.localizedDescription])
48
45
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSmileId.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAuEpCC,gCAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSmileId.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAuFpCC,gCAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
@@ -254,6 +254,66 @@ const SmileID = exports.SmileID = {
254
254
  /**
255
255
  * Get available services
256
256
  */
257
- getServices: () => _SmileID.getServices()
257
+ getServices: () => _SmileID.getServices(),
258
+ /**
259
+ * Polls the status of a smart selfie job.
260
+ *
261
+ * @param {JobStatusRequest} request - The job status request object.
262
+ * @param {number} interval - The interval duration (in milliseconds) between each polling attempt.
263
+ * @param {number} numAttempts - The number of polling attempts before stopping.
264
+ */
265
+ pollSmartSelfieJobStatus: (request, interval, numAttempts) => {
266
+ if (!Number.isInteger(interval) || !Number.isInteger(numAttempts)) {
267
+ throw new Error(`interval and numAttempts must be an integer.`);
268
+ }
269
+ request.interval = interval;
270
+ request.numAttempts = numAttempts;
271
+ _SmileID.pollSmartSelfieJobStatus(request);
272
+ },
273
+ /**
274
+ * Polls the status of a document verification job.
275
+ *
276
+ * @param {JobStatusRequest} request - The job status request object.
277
+ * @param {number} interval - The interval duration (in milliseconds) between each polling attempt.
278
+ * @param {number} numAttempts - The number of polling attempts before stopping.
279
+ */
280
+ pollDocumentVerificationJobStatus: (request, interval, numAttempts) => {
281
+ if (!Number.isInteger(interval) || !Number.isInteger(numAttempts)) {
282
+ throw new Error(`interval and numAttempts must be an integer.`);
283
+ }
284
+ request.interval = interval;
285
+ request.numAttempts = numAttempts;
286
+ _SmileID.pollDocumentVerificationJobStatus(request);
287
+ },
288
+ /**
289
+ * Polls the status of a biometric KYC job.
290
+ *
291
+ * @param {JobStatusRequest} request - The job status request object.
292
+ * @param {number} interval - The interval duration (in milliseconds) between each polling attempt.
293
+ * @param {number} numAttempts - The number of polling attempts before stopping.
294
+ */
295
+ pollBiometricKycJobStatus: (request, interval, numAttempts) => {
296
+ if (!Number.isInteger(interval) || !Number.isInteger(numAttempts)) {
297
+ throw new Error(`interval and numAttempts must be an integer.`);
298
+ }
299
+ request.interval = interval;
300
+ request.numAttempts = numAttempts;
301
+ _SmileID.pollBiometricKycJobStatus(request);
302
+ },
303
+ /**
304
+ * Polls the status of an enhanced document verification job.
305
+ *
306
+ * @param {JobStatusRequest} request - The job status request object.
307
+ * @param {number} interval - The interval duration (in milliseconds) between each polling attempt.
308
+ * @param {number} numAttempts - The number of polling attempts before stopping.
309
+ */
310
+ pollEnhancedDocumentVerificationJobStatus: (request, interval, numAttempts) => {
311
+ if (!Number.isInteger(interval) || !Number.isInteger(numAttempts)) {
312
+ throw new Error(`interval and numAttempts must be an integer.`);
313
+ }
314
+ request.interval = interval;
315
+ request.numAttempts = numAttempts;
316
+ _SmileID.pollEnhancedDocumentVerificationJobStatus(request);
317
+ }
258
318
  };
259
319
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_SmileIDSmartSelfieEnrollmentView","_interopRequireDefault","_SmileIDSmartSelfieAuthenticationView","_SmileIDDocumentVerificationView","_SmileIDBiometricKYCView","_SmileIDEnhancedDocumentVerificationView","_SmileIDConsentView","_types","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","isTurboModuleEnabled","global","__turboModuleProxy","SmileIdModule","NativeModules","RNSmileID","_SmileID","Proxy","get","Error","SmileID","exports","initialize","useSandBox","disableCrashReporting","OS","authenticate","request","prepUpload","upload","url","doEnhancedKyc","doEnhancedKycAsync","getSmartSelfieJobStatus","getDocumentVerificationJobStatus","getBiometricKycJobStatus","getEnhancedDocumentVerificationJobStatus","getProductsConfig","getValidDocuments","getServices"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC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,CAAC,CAAC;EAEzEE,YAAY,EAAGC,OAA8B,IAC3CX,QAAQ,CAACU,YAAY,CAACC,OAAO,CAAC;EAEhC;AACF;AACA;EACEC,UAAU,EAAGD,OAA0B,IAAKX,QAAQ,CAACY,UAAU,CAACD,OAAO,CAAC;EAExE;AACF;AACA;EACEE,MAAM,EAAEA,CAACC,GAAW,EAAEH,OAAsB,KAC1CX,QAAQ,CAACa,MAAM,CAACC,GAAG,EAAEH,OAAO,CAAC;EAE/B;AACF;AACA;EACEI,aAAa,EAAGJ,OAA2B,IACzCX,QAAQ,CAACe,aAAa,CAACJ,OAAO,CAAC;EAEjC;AACF;AACA;EACEK,kBAAkB,EAAGL,OAA2B,IAC9CX,QAAQ,CAACgB,kBAAkB,CAACL,OAAO,CAAC;EAEtC;AACF;AACA;EACEM,uBAAuB,EAAGN,OAAyB,IACjDX,QAAQ,CAACiB,uBAAuB,CAACN,OAAO,CAAC;EAE3C;AACF;AACA;EACEO,gCAAgC,EAAGP,OAAyB,IAC1DX,QAAQ,CAACkB,gCAAgC,CAACP,OAAO,CAAC;EAEpD;AACF;AACA;EACEQ,wBAAwB,EAAGR,OAAyB,IAClDX,QAAQ,CAACmB,wBAAwB,CAACR,OAAO,CAAC;EAE5C;AACF;AACA;EACES,wCAAwC,EAAGT,OAAyB,IAClEX,QAAQ,CAACoB,wCAAwC,CAACT,OAAO,CAAC;EAE5D;AACF;AACA;EACEU,iBAAiB,EAAGV,OAA8B,IAChDX,QAAQ,CAACqB,iBAAiB,CAACV,OAAO,CAAC;EAErC;AACF;AACA;EACEW,iBAAiB,EAAGX,OAA8B,IAChDX,QAAQ,CAACsB,iBAAiB,CAACX,OAAO,CAAC;EAErC;AACF;AACA;EACEY,WAAW,EAAEA,CAAA,KAAMvB,QAAQ,CAACuB,WAAW,CAAC;AAC1C,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_SmileIDSmartSelfieEnrollmentView","_interopRequireDefault","_SmileIDSmartSelfieAuthenticationView","_SmileIDDocumentVerificationView","_SmileIDBiometricKYCView","_SmileIDEnhancedDocumentVerificationView","_SmileIDConsentView","_types","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","isTurboModuleEnabled","global","__turboModuleProxy","SmileIdModule","NativeModules","RNSmileID","_SmileID","Proxy","get","Error","SmileID","exports","initialize","useSandBox","disableCrashReporting","OS","authenticate","request","prepUpload","upload","url","doEnhancedKyc","doEnhancedKycAsync","getSmartSelfieJobStatus","getDocumentVerificationJobStatus","getBiometricKycJobStatus","getEnhancedDocumentVerificationJobStatus","getProductsConfig","getValidDocuments","getServices","pollSmartSelfieJobStatus","interval","numAttempts","Number","isInteger","pollDocumentVerificationJobStatus","pollBiometricKycJobStatus","pollEnhancedDocumentVerificationJobStatus"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iCAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,qCAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,gCAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,wBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,wCAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,mBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAwBiB,SAAAE,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjB,MAAMG,aAAa,GAChB,gFAA+E,GAChFC,qBAAQ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