@smile_identity/react-native 10.1.8 → 10.1.10

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.
Files changed (47) hide show
  1. package/android/build.gradle +10 -11
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/smileidentity/react/Mapper.kt +18 -0
  4. package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +41 -16
  5. package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +2 -2
  6. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +5 -7
  7. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDConsentViewManager.kt +5 -7
  8. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +5 -7
  9. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +5 -7
  10. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +5 -7
  11. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +5 -7
  12. package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +1 -1
  13. package/android/src/main/java/com/smileidentity/react/views/SmileIDConsentView.kt +1 -0
  14. package/android/src/oldarch/SmileIdSpec.kt +16 -3
  15. package/ios/RNDelegates/SmileIDUIViewDelegate.swift +1 -0
  16. package/ios/RNDelegates/SmileIDViewDelegate.swift +1 -0
  17. package/ios/RNSmileID.mm +2 -1
  18. package/ios/RNSmileID.swift +57 -28
  19. package/ios/Utils/SmileIDDictExt.swift +10 -0
  20. package/ios/View/BaseSmileIDView.swift +5 -7
  21. package/ios/View/SmileIDBiometricKYCView.swift +0 -1
  22. package/ios/View/SmileIDConsentView.swift +0 -1
  23. package/ios/View/SmileIDDocumentVerificationView.swift +0 -1
  24. package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +0 -2
  25. package/ios/View/SmileIDSmartSelfieAuthView.swift +0 -2
  26. package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +0 -2
  27. package/lib/commonjs/NativeSmileId.js.map +1 -1
  28. package/lib/commonjs/index.js +7 -1
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/commonjs/types.js +13 -1
  31. package/lib/commonjs/types.js.map +1 -1
  32. package/lib/module/NativeSmileId.js.map +1 -1
  33. package/lib/module/index.js +7 -1
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/module/types.js +11 -0
  36. package/lib/module/types.js.map +1 -1
  37. package/lib/typescript/src/NativeSmileId.d.ts +3 -5
  38. package/lib/typescript/src/NativeSmileId.d.ts.map +1 -1
  39. package/lib/typescript/src/index.d.ts +6 -0
  40. package/lib/typescript/src/index.d.ts.map +1 -1
  41. package/lib/typescript/src/types.d.ts +10 -0
  42. package/lib/typescript/src/types.d.ts.map +1 -1
  43. package/package.json +1 -1
  44. package/react-native-smile-id.podspec +1 -1
  45. package/src/NativeSmileId.ts +14 -6
  46. package/src/index.tsx +7 -0
  47. package/src/types.ts +22 -0
@@ -12,9 +12,9 @@ buildscript {
12
12
  }
13
13
 
14
14
  dependencies {
15
- classpath "com.android.tools.build:gradle:8.3.1"
15
+ classpath "com.android.tools.build:gradle:8.3.2"
16
16
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17
- classpath "org.jlleitschuh.gradle:ktlint-gradle:12.1.0"
17
+ classpath "org.jlleitschuh.gradle:ktlint-gradle:12.1.1"
18
18
  }
19
19
  }
20
20
 
@@ -87,7 +87,7 @@ android {
87
87
  }
88
88
 
89
89
  composeOptions {
90
- kotlinCompilerExtensionVersion '1.5.11'
90
+ kotlinCompilerExtensionVersion rootProject.ext.has("kotlinCompilerExtensionVersion") ? rootProject.ext.get("kotlinCompilerExtensionVersion") : '1.5.11'
91
91
  }
92
92
 
93
93
  compileOptions {
@@ -117,18 +117,17 @@ dependencies {
117
117
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core"
118
118
  implementation "com.smileidentity:android-sdk:$smile_id_sdk_version"
119
119
  implementation "com.jakewharton.timber:timber"
120
- implementation 'androidx.appcompat:appcompat:1.6.1'
120
+ implementation 'androidx.appcompat:appcompat:1.7.0'
121
121
  implementation("androidx.navigation:navigation-compose:2.7.7")
122
- testImplementation 'junit:junit:4.13.2'
123
- androidTestImplementation 'androidx.test.ext:junit:1.1.5'
124
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
125
- androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
126
- androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
127
122
 
123
+ testImplementation 'junit:junit:4.13.2'
128
124
 
129
- androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
125
+ androidTestImplementation 'androidx.test.ext:junit:1.2.1'
126
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
127
+ androidTestImplementation platform('androidx.compose:compose-bom:2024.06.00')
128
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
129
+ androidTestImplementation platform('androidx.compose:compose-bom:2024.06.00')
130
130
  androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
131
-
132
131
 
133
132
  debugImplementation 'androidx.compose.ui:ui-tooling'
134
133
  debugImplementation 'androidx.compose.ui:ui-test-manifest'
@@ -3,4 +3,4 @@ SmileId_minSdkVersion=21
3
3
  SmileId_targetSdkVersion=34
4
4
  SmileId_compileSdkVersion=34
5
5
  SmileId_ndkversion=21.4.7075529
6
- SmileId_androidVersion=10.2.2
6
+ SmileId_androidVersion=10.2.5
@@ -2,6 +2,7 @@ package com.smileidentity.react
2
2
 
3
3
  import com.facebook.react.bridge.ReadableMap
4
4
  import com.smileidentity.models.AuthenticationRequest
5
+ import com.smileidentity.models.Config
5
6
  import com.smileidentity.models.ConsentInfo
6
7
  import com.smileidentity.models.EnhancedKycRequest
7
8
  import com.smileidentity.models.IdInfo
@@ -22,6 +23,23 @@ import com.smileidentity.util.randomJobId
22
23
  import com.smileidentity.util.randomUserId
23
24
  import java.io.File
24
25
 
26
+ fun ReadableMap.toConfig(): Config {
27
+ return Config(
28
+ partnerId = getStringOrDefault("partnerId") ?: run {
29
+ throw IllegalArgumentException("partnerId is required")
30
+ },
31
+ authToken = getStringOrDefault("authToken") ?: run {
32
+ throw IllegalArgumentException("authToken is required")
33
+ },
34
+ prodBaseUrl = getStringOrDefault("prodBaseUrl") ?: run {
35
+ throw IllegalArgumentException("prodBaseUrl is required")
36
+ },
37
+ sandboxBaseUrl = getStringOrDefault("sandboxBaseUrl") ?: run {
38
+ throw IllegalArgumentException("sandboxBaseUrl is required")
39
+ },
40
+ )
41
+ }
42
+
25
43
  fun ReadableMap.toAuthenticationRequest(): AuthenticationRequest {
26
44
  return AuthenticationRequest(
27
45
  jobType = getIntOrDefault("jobType")?.let { JobType.fromValue(it) } ?: run {
@@ -42,26 +42,52 @@ import kotlinx.coroutines.withContext
42
42
  import kotlin.time.Duration
43
43
  import kotlin.time.Duration.Companion.milliseconds
44
44
 
45
+ class SmileIdModule internal constructor(
46
+ context: ReactApplicationContext
47
+ ) : SmileIdSpec(context) {
45
48
 
46
- class SmileIdModule internal constructor(context: ReactApplicationContext) :
47
- SmileIdSpec(context) {
48
-
49
- override fun getName(): String {
50
- return NAME
51
- }
49
+ override fun getName(): String = NAME
52
50
 
53
51
  @ReactMethod
54
- override fun initialize(useSandBox: Boolean, promise: Promise) {
55
- SmileID.initialize(reactApplicationContext, useSandbox = useSandBox)
52
+ override fun initializeWithApiKey(
53
+ apiKey: String,
54
+ config: ReadableMap,
55
+ useSandBox: Boolean,
56
+ enableCrashReporting: Boolean,
57
+ promise: Promise
58
+ ) {
59
+ SmileID.initialize(
60
+ context = reactApplicationContext,
61
+ apiKey = apiKey,
62
+ config = config.toConfig(),
63
+ useSandbox = useSandBox,
64
+ enableCrashReporting = enableCrashReporting
65
+ )
56
66
  promise.resolve(null)
57
67
  }
58
68
 
59
69
  @ReactMethod
60
- override fun setEnvironment(useSandBox: Boolean, promise: Promise) {
61
- SmileID.setEnvironment(useSandbox = useSandBox)
70
+ override fun initializeWithConfig(
71
+ config: ReadableMap,
72
+ useSandBox: Boolean,
73
+ enableCrashReporting: Boolean,
74
+ promise: Promise
75
+ ) {
76
+ SmileID.initialize(
77
+ context = reactApplicationContext,
78
+ config = config.toConfig(),
79
+ useSandbox = useSandBox,
80
+ enableCrashReporting = enableCrashReporting
81
+ )
62
82
  promise.resolve(null)
63
83
  }
64
84
 
85
+ @ReactMethod
86
+ override fun initialize(useSandBox: Boolean, promise: Promise) {
87
+ SmileID.initialize(context = reactApplicationContext, useSandbox = useSandBox)
88
+ promise.resolve(null)
89
+ }
90
+
65
91
  @ReactMethod
66
92
  override fun setCallbackUrl(callbackUrl: String, promise: Promise) {
67
93
  SmileID.setCallbackUrl(callbackUrl = URL(callbackUrl))
@@ -73,20 +99,20 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
73
99
  SmileIDCrashReporting.disable()
74
100
  }
75
101
 
76
- @ReactMethod
102
+ @ReactMethod
77
103
  override fun setAllowOfflineMode(allowOfflineMode: Boolean, promise: Promise) {
78
104
  SmileID.setAllowOfflineMode(allowOfflineMode)
79
105
  promise.resolve(null)
80
106
  }
81
107
 
82
- @ReactMethod
108
+ @ReactMethod
83
109
  override fun submitJob(jobId: String, promise: Promise) = launch(
84
110
  work = { SmileID.submitJob(jobId) },
85
111
  clazz = Unit::class.java,
86
112
  promise = promise
87
113
  )
88
114
 
89
- @ReactMethod
115
+ @ReactMethod
90
116
  override fun getUnsubmittedJobs(promise: Promise) {
91
117
  try {
92
118
  val writableArray: WritableArray = Arguments.createArray()
@@ -99,7 +125,7 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
99
125
  }
100
126
  }
101
127
 
102
- @ReactMethod
128
+ @ReactMethod
103
129
  override fun getSubmittedJobs(promise: Promise) {
104
130
  try {
105
131
  val writableArray: WritableArray = Arguments.createArray()
@@ -112,7 +138,7 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
112
138
  }
113
139
  }
114
140
 
115
- @ReactMethod
141
+ @ReactMethod
116
142
  override fun cleanup(jobId: String, promise: Promise) {
117
143
  try {
118
144
  SmileID.cleanup(jobId)
@@ -320,7 +346,6 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
320
346
  return adapter.toJson(result)
321
347
  }
322
348
 
323
-
324
349
  private fun <T> launch(
325
350
  work: suspend () -> T,
326
351
  clazz: Class<T>,
@@ -16,7 +16,8 @@ import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieEnrollmentViewMana
16
16
  class SmileIdPackage : TurboReactPackage() {
17
17
 
18
18
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
19
- listOf(SmileIDSmartSelfieEnrollmentViewManager(reactContext),
19
+ listOf(
20
+ SmileIDSmartSelfieEnrollmentViewManager(reactContext),
20
21
  SmileIDSmartSelfieAuthenticationViewManager(reactContext),
21
22
  SmileIDDocumentVerificationViewManager(reactContext),
22
23
  SmileIDEnhancedDocumentVerificationViewManager(reactContext),
@@ -24,7 +25,6 @@ class SmileIdPackage : TurboReactPackage() {
24
25
  SmileIDBiometricKYCViewManager(reactContext),
25
26
  )
26
27
 
27
-
28
28
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
29
29
  return if (name == SmileIdModule.NAME) {
30
30
  SmileIdModule(reactContext)
@@ -11,13 +11,12 @@ import com.smileidentity.react.utils.getStringOrDefault
11
11
  import com.smileidentity.react.utils.toMap
12
12
  import com.smileidentity.react.views.SmileIDBiometricKYCView
13
13
 
14
-
15
14
  @ReactModule(name = SmileIDBiometricKYCViewManager.NAME)
16
- class SmileIDBiometricKYCViewManager(private val reactApplicationContext: ReactApplicationContext) :
17
- SimpleViewManager<SmileIDBiometricKYCView>() {
18
- override fun getName(): String {
19
- return NAME
20
- }
15
+ class SmileIDBiometricKYCViewManager(
16
+ private val reactApplicationContext: ReactApplicationContext
17
+ ) : SimpleViewManager<SmileIDBiometricKYCView>() {
18
+
19
+ override fun getName(): String = NAME
21
20
 
22
21
  override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
23
22
  return mapOf(
@@ -70,5 +69,4 @@ class SmileIDBiometricKYCViewManager(private val reactApplicationContext: ReactA
70
69
  const val NAME = "SmileIDBiometricKYCView"
71
70
  const val COMMAND_SET_PARAMS = 6
72
71
  }
73
-
74
72
  }
@@ -11,13 +11,12 @@ import com.smileidentity.react.utils.getStringOrDefault
11
11
  import com.smileidentity.react.utils.toMap
12
12
  import com.smileidentity.react.views.SmileIDConsentView
13
13
 
14
-
15
14
  @ReactModule(name = SmileIDConsentViewManager.NAME)
16
- class SmileIDConsentViewManager(private val reactApplicationContext: ReactApplicationContext) :
17
- SimpleViewManager<SmileIDConsentView>() {
18
- override fun getName(): String {
19
- return NAME
20
- }
15
+ class SmileIDConsentViewManager(
16
+ private val reactApplicationContext: ReactApplicationContext
17
+ ) : SimpleViewManager<SmileIDConsentView>() {
18
+
19
+ override fun getName(): String = NAME
21
20
 
22
21
  override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
23
22
  return mapOf(
@@ -79,5 +78,4 @@ class SmileIDConsentViewManager(private val reactApplicationContext: ReactApplic
79
78
  const val NAME = "SmileIDConsentView"
80
79
  const val COMMAND_SET_PARAMS = 5
81
80
  }
82
-
83
81
  }
@@ -12,13 +12,12 @@ import com.smileidentity.react.utils.getStringOrDefault
12
12
  import com.smileidentity.react.utils.toMap
13
13
  import com.smileidentity.react.views.SmileIDDocumentVerificationView
14
14
 
15
-
16
15
  @ReactModule(name = SmileIDDocumentVerificationViewManager.NAME)
17
- class SmileIDDocumentVerificationViewManager(private val reactApplicationContext: ReactApplicationContext) :
18
- SimpleViewManager<SmileIDDocumentVerificationView>() {
19
- override fun getName(): String {
20
- return NAME
21
- }
16
+ class SmileIDDocumentVerificationViewManager(
17
+ private val reactApplicationContext: ReactApplicationContext
18
+ ) : SimpleViewManager<SmileIDDocumentVerificationView>() {
19
+
20
+ override fun getName(): String = NAME
22
21
 
23
22
  override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
24
23
  return mapOf(
@@ -74,5 +73,4 @@ class SmileIDDocumentVerificationViewManager(private val reactApplicationContext
74
73
  const val NAME = "SmileIDDocumentVerificationView"
75
74
  const val COMMAND_SET_PARAMS = 4
76
75
  }
77
-
78
76
  }
@@ -12,13 +12,12 @@ import com.smileidentity.react.utils.getStringOrDefault
12
12
  import com.smileidentity.react.utils.toMap
13
13
  import com.smileidentity.react.views.SmileIDEnhancedDocumentVerificationView
14
14
 
15
-
16
15
  @ReactModule(name = SmileIDEnhancedDocumentVerificationViewManager.NAME)
17
- class SmileIDEnhancedDocumentVerificationViewManager(private val reactApplicationContext: ReactApplicationContext) :
18
- SimpleViewManager<SmileIDEnhancedDocumentVerificationView>() {
19
- override fun getName(): String {
20
- return NAME
21
- }
16
+ class SmileIDEnhancedDocumentVerificationViewManager(
17
+ private val reactApplicationContext: ReactApplicationContext
18
+ ) : SimpleViewManager<SmileIDEnhancedDocumentVerificationView>() {
19
+
20
+ override fun getName(): String = NAME
22
21
 
23
22
  override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
24
23
  return mapOf(
@@ -73,5 +72,4 @@ class SmileIDEnhancedDocumentVerificationViewManager(private val reactApplicatio
73
72
  const val NAME = "SmileIDEnhancedDocumentVerificationView"
74
73
  const val COMMAND_SET_PARAMS = 3
75
74
  }
76
-
77
75
  }
@@ -11,13 +11,12 @@ import com.smileidentity.react.utils.getStringOrDefault
11
11
  import com.smileidentity.react.utils.toMap
12
12
  import com.smileidentity.react.views.SmileIDSmartSelfieAuthenticationView
13
13
 
14
-
15
14
  @ReactModule(name = SmileIDSmartSelfieAuthenticationViewManager.NAME)
16
- class SmileIDSmartSelfieAuthenticationViewManager(private val reactApplicationContext: ReactApplicationContext) :
17
- SimpleViewManager<SmileIDSmartSelfieAuthenticationView>() {
18
- override fun getName(): String {
19
- return NAME
20
- }
15
+ class SmileIDSmartSelfieAuthenticationViewManager(
16
+ private val reactApplicationContext: ReactApplicationContext
17
+ ) : SimpleViewManager<SmileIDSmartSelfieAuthenticationView>() {
18
+
19
+ override fun getName(): String = NAME
21
20
 
22
21
  override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
23
22
  return mapOf(
@@ -65,5 +64,4 @@ class SmileIDSmartSelfieAuthenticationViewManager(private val reactApplicationCo
65
64
  const val NAME = "SmileIDSmartSelfieAuthenticationView"
66
65
  const val COMMAND_SET_PARAMS = 2
67
66
  }
68
-
69
67
  }
@@ -11,13 +11,12 @@ import com.smileidentity.react.utils.getStringOrDefault
11
11
  import com.smileidentity.react.utils.toMap
12
12
  import com.smileidentity.react.views.SmileIDSmartSelfieEnrollmentView
13
13
 
14
-
15
14
  @ReactModule(name = SmileIDSmartSelfieEnrollmentViewManager.NAME)
16
- class SmileIDSmartSelfieEnrollmentViewManager(private val reactApplicationContext: ReactApplicationContext) :
17
- SimpleViewManager<SmileIDSmartSelfieEnrollmentView>() {
18
- override fun getName(): String {
19
- return NAME
20
- }
15
+ class SmileIDSmartSelfieEnrollmentViewManager(
16
+ private val reactApplicationContext: ReactApplicationContext
17
+ ) : SimpleViewManager<SmileIDSmartSelfieEnrollmentView>() {
18
+
19
+ override fun getName(): String = NAME
21
20
 
22
21
  override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
23
22
  return mapOf(
@@ -65,5 +64,4 @@ class SmileIDSmartSelfieEnrollmentViewManager(private val reactApplicationContex
65
64
  const val NAME = "SmileIDSmartSelfieEnrollmentView"
66
65
  const val COMMAND_SET_PARAMS = 1
67
66
  }
68
-
69
67
  }
@@ -16,6 +16,7 @@ import timber.log.Timber
16
16
 
17
17
  class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(context) {
18
18
  var idInfo: IdInfo? = null
19
+
19
20
  override fun renderContent() {
20
21
  idInfo ?: run {
21
22
  emitFailure(IllegalArgumentException("idInfo is required for BiometricKYC"))
@@ -58,5 +59,4 @@ class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(co
58
59
  }
59
60
  }
60
61
  }
61
-
62
62
  }
@@ -14,6 +14,7 @@ class SmileIDConsentView(context: ReactApplicationContext) : SmileIDView(context
14
14
  var partnerPrivacyPolicy : String? = null
15
15
  var logoResName : String? = null
16
16
  var productName : String? = null
17
+
17
18
  override fun renderContent() {
18
19
  partnerName ?: run {
19
20
  emitFailure(IllegalArgumentException("partnerName is required for BiometricKYC"))
@@ -8,9 +8,22 @@ import com.facebook.react.bridge.ReadableMap
8
8
  abstract class SmileIdSpec internal constructor(context: ReactApplicationContext) :
9
9
  ReactContextBaseJavaModule(context) {
10
10
 
11
- abstract fun initialize(useSandBox: Boolean ,promise: Promise)
12
-
13
- abstract fun setEnvironment(useSandbox: Boolean, promise: Promise)
11
+ abstract fun initializeWithApiKey(
12
+ apiKey: String,
13
+ config: ReadableMap,
14
+ useSandBox: Boolean,
15
+ enableCrashReporting: Boolean,
16
+ promise: Promise
17
+ )
18
+
19
+ abstract fun initializeWithConfig(
20
+ config: ReadableMap,
21
+ useSandBox: Boolean,
22
+ enableCrashReporting: Boolean,
23
+ promise: Promise
24
+ )
25
+
26
+ abstract fun initialize(useSandBox: Boolean, promise: Promise)
14
27
 
15
28
  abstract fun setCallbackUrl(callbackUrl: String, promise: Promise)
16
29
 
@@ -1,4 +1,5 @@
1
1
  import UIKit
2
+
2
3
  protocol SmileIDUIViewDelegate {
3
4
  func getView() -> UIView
4
5
  }
@@ -1,4 +1,5 @@
1
1
  import SwiftUI
2
+
2
3
  protocol SmileIDViewDelegate {
3
4
  associatedtype ContentView: View
4
5
  func getView() -> ContentView
package/ios/RNSmileID.mm CHANGED
@@ -1,8 +1,9 @@
1
1
  #import <React/RCTBridgeModule.h>
2
2
 
3
3
  @interface RCT_EXTERN_MODULE(RNSmileID, NSObject)
4
+ RCT_EXTERN_METHOD(initializeWithApiKey:(NSString)apiKey, (NSDictionary *)config, (BOOL)useSandBox, (BOOL)enableCrashReporting withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
5
+ RCT_EXTERN_METHOD(initializeWithConfig:(NSDictionary *)config, (BOOL)useSandBox, (BOOL)enableCrashReporting withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
4
6
  RCT_EXTERN_METHOD(initialize:(BOOL)useSandBox withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
5
- RCT_EXTERN_METHOD(setEnvironment:(BOOL)useSandBox withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
6
7
  RCT_EXTERN_METHOD(setCallbackUrl:(NSString)callbackUrl withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
7
8
  RCT_EXTERN_METHOD(setAllowOfflineMode:(BOOL)allowOfflineMode withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
8
9
  RCT_EXTERN_METHOD(submitJob:(NSString *)jobId withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
@@ -2,18 +2,44 @@ import SmileID
2
2
 
3
3
  @objc(RNSmileID)
4
4
  class RNSmileID: NSObject {
5
+ @objc(initializeWithApiKey:withResolver:withRejecter:)
6
+ func initializeWithApiKey(
7
+ apiKey: String,
8
+ config: NSDictionary,
9
+ useSandBox: Bool,
10
+ enableCrashReporting: Bool,
11
+ resolve: @escaping RCTPromiseResolveBlock,
12
+ reject _: @escaping RCTPromiseRejectBlock
13
+ ) {
14
+ SmileID.initialize(
15
+ apiKey: apiKey,
16
+ config: config.toConfig(),
17
+ useSandbox: useSandBox
18
+ )
19
+ resolve(nil)
20
+ }
21
+
22
+ @objc(initializeWithConfig:withResolver:withRejecter:)
23
+ func initializeWithConfig(
24
+ config: NSDictionary,
25
+ useSandBox: Bool,
26
+ enableCrashReporting: Bool,
27
+ resolve: @escaping RCTPromiseResolveBlock,
28
+ reject _: @escaping RCTPromiseRejectBlock
29
+ ) {
30
+ SmileID.initialize(
31
+ config: config.toConfig(),
32
+ useSandbox: useSandBox
33
+ )
34
+ resolve(nil)
35
+ }
36
+
5
37
  @objc(initialize:withResolver:withRejecter:)
6
38
  func initialize(useSandBox: Bool, resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
7
39
  SmileID.initialize(useSandbox: useSandBox)
8
40
  resolve(nil)
9
41
  }
10
42
 
11
- @objc(setEnvironment:withResolver:withRejecter:)
12
- func setEnvironment(useSandBox: Bool, resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
13
- SmileID.setEnvironment(useSandbox: useSandBox)
14
- resolve(nil)
15
- }
16
-
17
43
  @objc(setCallbackUrl:withResolver:withRejecter:)
18
44
  func setCallbackUrl(callbackUrl: String, resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
19
45
  SmileID.setCallbackUrl(url: URL(string: callbackUrl))
@@ -107,16 +133,10 @@ class RNSmileID: NSObject {
107
133
  return
108
134
  }
109
135
 
110
- guard let zipUrl = try? LocalStorage.toZip(uploadRequest: uploadRequest) else {
136
+ guard let zipData = try? LocalStorage.toZip(uploadRequest: uploadRequest) else {
111
137
  reject("Error", "Unable to zip file", nil)
112
138
  return
113
139
  }
114
-
115
- guard let zipData = try? Data(contentsOf: zipUrl) else {
116
- reject("Error", "Unable to read zip file", nil)
117
- return
118
- }
119
-
120
140
  Task {
121
141
  do {
122
142
  try await SmileID.api.upload(zip: zipData, to: url)
@@ -239,17 +259,17 @@ class RNSmileID: NSObject {
239
259
  )
240
260
 
241
261
  Task {
242
- do {
243
- let response = try await SmileID.api.doEnhancedKycAsync(request: request)
244
- let encoder = JSONEncoder()
245
- guard let jsonData = try? encoder.encode(response) else {
246
- throw SmileIDError.unknown("doEnhancedKyc encoding error")
247
- }
248
- // Assuming you have a method to convert response to a dictionary
249
- resolve(["result": String(data: jsonData, encoding: .utf8)!])
250
- } catch {
251
- reject("Error", error.localizedDescription, error)
252
- }
262
+ do {
263
+ let response = try await SmileID.api.doEnhancedKycAsync(request: request)
264
+ let encoder = JSONEncoder()
265
+ guard let jsonData = try? encoder.encode(response) else {
266
+ throw SmileIDError.unknown("doEnhancedKyc encoding error")
267
+ }
268
+ // Assuming you have a method to convert response to a dictionary
269
+ resolve(["result": String(data: jsonData, encoding: .utf8)!])
270
+ } catch {
271
+ reject("Error", error.localizedDescription, error)
272
+ }
253
273
  }
254
274
  }
255
275
 
@@ -444,8 +464,8 @@ class RNSmileID: NSObject {
444
464
  )
445
465
  }
446
466
 
447
- func pollJobStatus<RequestType, ResponseType: Encodable>(
448
- apiCall: @escaping (RequestType, TimeInterval, Int) async throws -> ResponseType,
467
+ func pollJobStatus<RequestType, T: JobResult>(
468
+ apiCall: @escaping (RequestType, TimeInterval, Int) async throws -> AsyncThrowingStream<JobStatusResponse<T>, Error>,
449
469
  request: RequestType,
450
470
  interval: Int64,
451
471
  numAttempts: Int64,
@@ -460,8 +480,17 @@ class RNSmileID: NSObject {
460
480
 
461
481
  Task {
462
482
  do {
463
- let response = try await apiCall(request, timeInterval, numAttemptsInt)
464
- self.resolveResponse(response, resolve: resolve, reject: reject)
483
+ let pollStream = try await apiCall(request, timeInterval, numAttemptsInt)
484
+ var result: JobStatusResponse<T>? = nil
485
+
486
+ for try await res in pollStream {
487
+ result = res
488
+ }
489
+ if let finalResult = result {
490
+ self.resolveResponse(finalResult, resolve: resolve, reject: reject)
491
+ } else {
492
+ reject("NoResult", "Polling completed without a result", NSError(domain: "No result obtained", code: -1, userInfo: nil))
493
+ }
465
494
  } catch {
466
495
  reject("ApiCallFailure", "API call failed with error: \(error.localizedDescription)", error)
467
496
  }
@@ -2,6 +2,16 @@ import Foundation
2
2
  import SmileID
3
3
 
4
4
  extension NSDictionary {
5
+
6
+ func toConfig() -> Config {
7
+ return Config (
8
+ partnerId: (self["partnerId"] as? String)!,
9
+ authToken: (self["authToken"] as? String)!,
10
+ prodLambdaUrl: (self["prodLambdaUrl"] as? String)!,
11
+ testLambdaUrl: (self["testLambdaUrl"] as? String)!
12
+ )
13
+ }
14
+
5
15
  func toAuthenticationRequest() -> AuthenticationRequest? {
6
16
  guard let jobTypeValue = self["jobType"] as? Int,
7
17
  let jobType = JobType(rawValue: jobTypeValue),
@@ -6,7 +6,7 @@ class BaseSmileIDView: UIView {
6
6
  var contentView : AnyView?
7
7
  private var _onResult: RCTBubblingEventBlock?
8
8
  var product : SmileIDProductModel?
9
-
9
+
10
10
  @objc var onResult: RCTBubblingEventBlock? {
11
11
  get {
12
12
  return _onResult
@@ -18,19 +18,19 @@ class BaseSmileIDView: UIView {
18
18
  }
19
19
  }
20
20
  }
21
-
21
+
22
22
  init(frame: CGRect,contentView:AnyView,product:SmileIDProductModel) {
23
23
  self.contentView = contentView
24
24
  self.product = product
25
25
  super.init(frame: frame)
26
26
  commonInit()
27
27
  }
28
-
28
+
29
29
  required init?(coder aDecoder: NSCoder) {
30
30
  super.init(coder: aDecoder)
31
31
  commonInit()
32
32
  }
33
-
33
+
34
34
  private func commonInit() {
35
35
  // Perform initialization tasks here
36
36
  // For example, setup subviews, add constraints, configure appearance
@@ -43,10 +43,8 @@ class BaseSmileIDView: UIView {
43
43
  hostingView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
44
44
  hostingView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
45
45
  }
46
-
46
+
47
47
  func getView(product:SmileIDProductModel) -> AnyView {
48
48
  fatalError("Must be implemented by subclass")
49
49
  }
50
-
51
-
52
50
  }
@@ -1,5 +1,4 @@
1
1
  import Foundation
2
-
3
2
  import SmileID
4
3
  import SwiftUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  import Foundation
2
-
3
2
  import SmileID
4
3
  import SwiftUI
5
4
 
@@ -1,5 +1,4 @@
1
1
  import Foundation
2
-
3
2
  import SmileID
4
3
  import SwiftUI
5
4