@smile_identity/react-native 10.0.0-beta02 → 10.0.0-beta03

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 (56) hide show
  1. package/README.md +1 -1
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/smileidentity/react/Mapper.kt +179 -0
  4. package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +64 -87
  5. package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +4 -39
  6. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +11 -8
  7. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDConsentViewManager.kt +16 -10
  8. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +14 -12
  9. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +13 -11
  10. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +7 -6
  11. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +7 -6
  12. package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +32 -22
  13. package/android/src/main/java/com/smileidentity/react/views/SmileIDConsentView.kt +21 -14
  14. package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +35 -27
  15. package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +34 -26
  16. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +30 -22
  17. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +30 -22
  18. package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +1 -0
  19. package/android/src/oldarch/SmileIdSpec.kt +23 -1
  20. package/ios/View/BaseSmileIDView.swift +5 -5
  21. package/ios/View/SmileIDBiometricKYCView.swift +6 -4
  22. package/ios/View/SmileIDConsentView.swift +5 -4
  23. package/ios/View/SmileIDDocumentVerificationView.swift +5 -3
  24. package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +6 -4
  25. package/ios/View/SmileIDSmartSelfieAuthView.swift +6 -4
  26. package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +6 -4
  27. package/ios/ViewManagers/SmileIDBaseViewManager.swift +1 -0
  28. package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +11 -10
  29. package/ios/ViewManagers/SmileIDConsentViewManager.swift +8 -8
  30. package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +17 -16
  31. package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +16 -15
  32. package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.swift +10 -9
  33. package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.swift +10 -9
  34. package/ios/ViewModels/SmileIDProductModel.swift +1 -0
  35. package/lib/commonjs/NativeSmileId.js.map +1 -1
  36. package/lib/commonjs/index.js +96 -0
  37. package/lib/commonjs/index.js.map +1 -1
  38. package/lib/commonjs/types.js +511 -0
  39. package/lib/commonjs/types.js.map +1 -1
  40. package/lib/module/NativeSmileId.js.map +1 -1
  41. package/lib/module/index.js +2 -2
  42. package/lib/module/index.js.map +1 -1
  43. package/lib/module/types.js +471 -1
  44. package/lib/module/types.js.map +1 -1
  45. package/lib/typescript/NativeSmileId.d.ts +13 -9
  46. package/lib/typescript/NativeSmileId.d.ts.map +1 -1
  47. package/lib/typescript/index.d.ts +2 -2
  48. package/lib/typescript/index.d.ts.map +1 -1
  49. package/lib/typescript/types.d.ts +410 -88
  50. package/lib/typescript/types.d.ts.map +1 -1
  51. package/package.json +3 -3
  52. package/react-native-smile-id.podspec +1 -1
  53. package/src/NativeSmileId.ts +58 -11
  54. package/src/index.tsx +33 -1
  55. package/src/types.ts +985 -90
  56. package/android/src/main/assets/smile_config.json +0 -9
package/README.md CHANGED
@@ -27,7 +27,7 @@ Add the dependency to your `package.json`:
27
27
  ```json
28
28
  {
29
29
  "dependencies": {
30
- "rn-smile-id": "<latest-version>"
30
+ "@smile_identity/react-native": "<latest-version>"
31
31
  }
32
32
  }
33
33
  ```
@@ -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.0.1
6
+ SmileId_androidVersion=10.0.2
@@ -0,0 +1,179 @@
1
+ package com.smileidentity.react
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+ import com.smileidentity.models.AuthenticationRequest
5
+ import com.smileidentity.models.ConsentInfo
6
+ import com.smileidentity.models.EnhancedKycRequest
7
+ import com.smileidentity.models.IdInfo
8
+ import com.smileidentity.models.ImageType
9
+ import com.smileidentity.models.JobStatusRequest
10
+ import com.smileidentity.models.JobType
11
+ import com.smileidentity.models.PartnerParams
12
+ import com.smileidentity.models.PrepUploadRequest
13
+ import com.smileidentity.models.ProductsConfigRequest
14
+ import com.smileidentity.models.UploadImageInfo
15
+ import com.smileidentity.models.UploadRequest
16
+ import com.smileidentity.react.utils.getBoolOrDefault
17
+ import com.smileidentity.react.utils.getIntOrDefault
18
+ import com.smileidentity.react.utils.getMapOrDefault
19
+ import com.smileidentity.react.utils.getStringOrDefault
20
+ import com.smileidentity.react.utils.toMap
21
+ import com.smileidentity.util.randomJobId
22
+ import com.smileidentity.util.randomUserId
23
+ import java.io.File
24
+
25
+ fun ReadableMap.toAuthenticationRequest(): AuthenticationRequest {
26
+ return AuthenticationRequest(
27
+ jobType = getIntOrDefault("jobType")?.let { JobType.fromValue(it) } ?: run {
28
+ throw IllegalArgumentException("jobType is required")
29
+ },
30
+ country = getStringOrDefault("country"),
31
+ idType = getStringOrDefault("idType"),
32
+ updateEnrolledImage = getBoolOrDefault("updateEnrolledImage", false),
33
+ jobId = getStringOrDefault("jobId"),
34
+ userId = getStringOrDefault("userId"),
35
+ )
36
+ }
37
+
38
+ fun ReadableMap.toPartnerParams(): PartnerParams {
39
+ return PartnerParams(
40
+ jobType = getIntOrDefault("jobType")?.let { JobType.fromValue(it) } ?: run {
41
+ throw IllegalArgumentException("jobType is required")
42
+ },
43
+ jobId = getStringOrDefault("jobId") ?: randomJobId(),
44
+ userId = getStringOrDefault("userId") ?: randomUserId(),
45
+ extras = getMapOrDefault("extras")?.toMap() ?: emptyMap()
46
+ )
47
+ }
48
+
49
+ fun ReadableMap.toConsentInfo(): ConsentInfo {
50
+ return ConsentInfo(
51
+ canAccess = getBoolOrDefault("canAccess", false),
52
+ consentRequired = getBoolOrDefault("consentRequired", true)
53
+ )
54
+ }
55
+
56
+ fun ReadableMap.toPrepUploadRequest(): PrepUploadRequest {
57
+ return PrepUploadRequest(
58
+ partnerParams = getMapOrDefault("partnerParams")?.toPartnerParams() ?: run {
59
+ throw IllegalArgumentException("partnerParams is required")
60
+ },
61
+ callbackUrl = getStringOrDefault("callbackUrl"),
62
+ partnerId = getStringOrDefault("partnerId") ?: run {
63
+ throw IllegalArgumentException("partnerId is required")
64
+ },
65
+ sourceSdk = getStringOrDefault("sourceSdk") ?: "react-native",
66
+ timestamp = getStringOrDefault("timestamp") ?: run {
67
+ throw IllegalArgumentException("timestamp is required")
68
+ },
69
+ //TODO: Remove this and use strings once the backend is updated
70
+ allowNewEnroll = getBoolOrDefault("allowNewEnroll", false).toString(),
71
+ signature = getStringOrDefault("signature") ?: run {
72
+ throw IllegalArgumentException("signature is required")
73
+ },
74
+ )
75
+ }
76
+
77
+ fun ReadableMap.toUploadRequest(): UploadRequest {
78
+ val imagesArray = getArray("images")?.toArrayList()?.map {
79
+ (it as ReadableMap).toUploadImageInfo()
80
+ }
81
+ return UploadRequest(
82
+ images = imagesArray ?: emptyList(),
83
+ idInfo = getMapOrDefault("idInfo")?.toIdInfo()
84
+ )
85
+ }
86
+
87
+ fun ReadableMap.toUploadImageInfo(): UploadImageInfo {
88
+ return UploadImageInfo(
89
+ imageTypeId = getStringOrDefault("imageTypeId")?.let { ImageType.valueOf(it) } ?: run {
90
+ throw IllegalArgumentException("imageTypeId is required")
91
+ },
92
+ image = File(getStringOrDefault("imageName") ?: run {
93
+ throw IllegalArgumentException("imageName is required")
94
+ }),
95
+ )
96
+ }
97
+
98
+ fun ReadableMap.toIdInfo(): IdInfo {
99
+ return IdInfo(
100
+ country = getStringOrDefault("country") ?: run {
101
+ throw IllegalArgumentException("country is required")
102
+ },
103
+ idType = getStringOrDefault("idType"),
104
+ idNumber = getStringOrDefault("idNumber"),
105
+ firstName = getStringOrDefault("firstName"),
106
+ middleName = getStringOrDefault("middleName"),
107
+ lastName = getStringOrDefault("lastName"),
108
+ dob = getStringOrDefault("dob"),
109
+ bankCode = getStringOrDefault("bankCode"),
110
+ entered = getBoolean("entered")
111
+ )
112
+ }
113
+
114
+ fun ReadableMap.toEnhancedKycRequest(): EnhancedKycRequest {
115
+ return EnhancedKycRequest(
116
+ country = getStringOrDefault("country") ?: run {
117
+ throw IllegalArgumentException("country is required")
118
+ },
119
+ idType = getStringOrDefault("idType") ?: run {
120
+ throw IllegalArgumentException("idType is required")
121
+ },
122
+ idNumber = getStringOrDefault("idNumber") ?: run {
123
+ throw IllegalArgumentException("idNumber is required")
124
+ },
125
+ firstName = getStringOrDefault("firstName"),
126
+ middleName = getStringOrDefault("middleName"),
127
+ lastName = getStringOrDefault("lastName"),
128
+ dob = getStringOrDefault("dob"),
129
+ phoneNumber = getStringOrDefault("phoneNumber"),
130
+ bankCode = getStringOrDefault("bankCode"),
131
+ callbackUrl = getStringOrDefault("callbackUrl"),
132
+ partnerParams = getMapOrDefault("partnerParams")?.toPartnerParams() ?: run {
133
+ throw IllegalArgumentException("partnerParams is required")
134
+ },
135
+ sourceSdk = getStringOrDefault("sourceSdk") ?: "react-native",
136
+ timestamp = getStringOrDefault("timestamp") ?: run {
137
+ throw IllegalArgumentException("timestamp is required")
138
+ },
139
+ signature = getStringOrDefault("signature") ?: run {
140
+ throw IllegalArgumentException("signature is required")
141
+ },
142
+ )
143
+ }
144
+
145
+ fun ReadableMap.toJobStatusRequest(): JobStatusRequest {
146
+ return JobStatusRequest(
147
+ userId = getStringOrDefault("userId") ?: run {
148
+ throw IllegalArgumentException("userId is required")
149
+ },
150
+ jobId = getStringOrDefault("jobId") ?: run {
151
+ throw IllegalArgumentException("jobId is required")
152
+ },
153
+ includeImageLinks = getBoolOrDefault("includeImageLinks", false),
154
+ includeHistory = getBoolOrDefault("includeHistory", false),
155
+ partnerId = getStringOrDefault("partnerId") ?: run {
156
+ throw IllegalArgumentException("partnerId is required")
157
+ },
158
+ timestamp = getStringOrDefault("timestamp") ?: run {
159
+ throw IllegalArgumentException("timestamp is required")
160
+ },
161
+ signature = getStringOrDefault("signature") ?: run {
162
+ throw IllegalArgumentException("signature is required")
163
+ }
164
+ )
165
+ }
166
+
167
+ fun ReadableMap.toProductsConfigRequest(): ProductsConfigRequest {
168
+ return ProductsConfigRequest(
169
+ partnerId = getStringOrDefault("partnerId") ?: run {
170
+ throw IllegalArgumentException("partnerId is required")
171
+ },
172
+ timestamp = getStringOrDefault("timestamp") ?: run {
173
+ throw IllegalArgumentException("timestamp is required")
174
+ },
175
+ signature = getStringOrDefault("signature") ?: run {
176
+ throw IllegalArgumentException("signature is required")
177
+ }
178
+ )
179
+ }
@@ -9,7 +9,6 @@ import com.smileidentity.SmileIDCrashReporting
9
9
  import com.smileidentity.SmileIdSpec
10
10
  import com.smileidentity.models.EnhancedKycRequest
11
11
  import com.smileidentity.react.utils.getStringOrDefault
12
- import com.smileidentity.react.utils.partnerParams
13
12
  import kotlinx.coroutines.CoroutineExceptionHandler
14
13
  import kotlinx.coroutines.CoroutineScope
15
14
  import kotlinx.coroutines.Dispatchers
@@ -25,10 +24,7 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
25
24
 
26
25
  @ReactMethod
27
26
  override fun initialize(useSandBox: Boolean, promise: Promise) {
28
- SmileID.initialize(
29
- reactApplicationContext,
30
- useSandbox = useSandBox
31
- )
27
+ SmileID.initialize(reactApplicationContext, useSandbox = useSandBox)
32
28
  promise.resolve(null)
33
29
  }
34
30
 
@@ -38,95 +34,76 @@ class SmileIdModule internal constructor(context: ReactApplicationContext) :
38
34
  }
39
35
 
40
36
  @ReactMethod
41
- override fun doEnhancedKycAsync(product: ReadableMap, promise: Promise) = launch(
42
- work = {
43
- val partnerParams = product.partnerParams()
44
- partnerParams ?: run {
45
- throw IllegalArgumentException("partnerParams is required for enhanced kyc")
46
- }
47
- val country = product.getStringOrDefault("country", null) ?: run {
48
- throw IllegalArgumentException("country is required for enhanced kyc")
49
- }
50
- val idType = product.getStringOrDefault("idType", null) ?: run {
51
- throw IllegalArgumentException("idType is required for enhanced kyc")
52
- }
53
- val idNumber = product.getStringOrDefault("idNumber", null) ?: run {
54
- throw IllegalArgumentException("idNumber is required for enhanced kyc")
55
- }
56
-
57
- val timestamp = partnerParams?.extras?.get("timestamp") ?: run {
58
- throw IllegalArgumentException("partnerParams.timestamp is required for enhanced kyc")
59
- }
60
- val signature = partnerParams?.extras?.get("timestamp") ?: run {
61
- throw IllegalArgumentException("partnerParams.signature is required for enhanced kyc")
62
- }
63
- SmileID.api.doEnhancedKycAsync(
64
- request = EnhancedKycRequest(
65
- country = country,
66
- idType = idType,
67
- idNumber = idNumber,
68
- firstName = product.getString("firstName"),
69
- middleName = product.getString("middleName"),
70
- lastName = product.getString("lastName"),
71
- dob = product.getString("dob"),
72
- phoneNumber = product.getString("phoneNumber"),
73
- bankCode = product.getString("bankCode"),
74
- callbackUrl = product.getString("callbackUrl"),
75
- partnerParams = partnerParams,
76
- sourceSdk = "android (react-native)",
77
- timestamp = timestamp,
78
- signature = signature,
79
- )
80
- )
81
- },
37
+ override fun authenticate(request: ReadableMap, promise: Promise) = launch(
38
+ work = { SmileID.api.authenticate(request = request.toAuthenticationRequest()) },
82
39
  promise = promise
83
40
  )
84
41
 
85
42
  @ReactMethod
86
- override fun doEnhancedKyc(product: ReadableMap, promise: Promise) = launch(
87
- work = {
88
- val partnerParams = product.partnerParams()
89
- partnerParams ?: run {
90
- throw IllegalArgumentException("partnerParams is required for enhanced kyc")
91
- }
92
- val country = product.getStringOrDefault("country", null) ?: run {
93
- throw IllegalArgumentException("country is required for enhanced kyc")
94
- }
95
- val idType = product.getStringOrDefault("idType", null) ?: run {
96
- throw IllegalArgumentException("idType is required for enhanced kyc")
97
- }
98
- val idNumber = product.getStringOrDefault("idNumber", null) ?: run {
99
- throw IllegalArgumentException("idNumber is required for enhanced kyc")
100
- }
101
-
102
- val timestamp = partnerParams?.extras?.get("timestamp") ?: run {
103
- throw IllegalArgumentException("partnerParams.timestamp is required for enhanced kyc")
104
- }
105
- val signature = partnerParams?.extras?.get("timestamp") ?: run {
106
- throw IllegalArgumentException("partnerParams.signature is required for enhanced kyc")
107
- }
108
- SmileID.api.doEnhancedKyc(
109
- request = EnhancedKycRequest(
110
- country = country,
111
- idType = idType,
112
- idNumber = idNumber,
113
- firstName = product.getString("firstName"),
114
- middleName = product.getString("middleName"),
115
- lastName = product.getString("lastName"),
116
- dob = product.getString("dob"),
117
- phoneNumber = product.getString("phoneNumber"),
118
- bankCode = product.getString("bankCode"),
119
- callbackUrl = product.getString("callbackUrl"),
120
- partnerParams = partnerParams,
121
- sourceSdk = "android (react-native)",
122
- timestamp = timestamp,
123
- signature = signature,
124
- )
125
- )
126
- },
43
+ override fun prepUpload(request: ReadableMap, promise: Promise) = launch(
44
+ work = { SmileID.api.prepUpload(request = request.toPrepUploadRequest()) },
127
45
  promise = promise
128
46
  )
129
47
 
48
+ @ReactMethod
49
+ override fun upload(url: String, request: ReadableMap, promise: Promise) = launch(
50
+ work = { SmileID.api.upload(url, request.toUploadRequest()) },
51
+ promise = promise
52
+ )
53
+
54
+ @ReactMethod
55
+ override fun doEnhancedKyc(request: ReadableMap, promise: Promise) = launch(
56
+ work = { SmileID.api.doEnhancedKyc(request = request.toEnhancedKycRequest()) },
57
+ promise = promise
58
+ )
59
+
60
+ @ReactMethod
61
+ override fun doEnhancedKycAsync(request: ReadableMap, promise: Promise) = launch(
62
+ work = { SmileID.api.doEnhancedKycAsync(request = request.toEnhancedKycRequest()) },
63
+ promise = promise
64
+ )
65
+
66
+ @ReactMethod
67
+ override fun getSmartSelfieJobStatus(request: ReadableMap, promise: Promise) = launch(
68
+ work = { SmileID.api.getSmartSelfieJobStatus(request = request.toJobStatusRequest()) },
69
+ promise = promise
70
+ )
71
+
72
+ @ReactMethod
73
+ override fun getDocumentVerificationJobStatus(request: ReadableMap, promise: Promise) = launch(
74
+ work = { SmileID.api.getDocumentVerificationJobStatus(request = request.toJobStatusRequest()) },
75
+ promise = promise
76
+ )
77
+
78
+ @ReactMethod
79
+ override fun getBiometricKycJobStatus(request: ReadableMap, promise: Promise) = launch(
80
+ work = { SmileID.api.getBiometricKycJobStatus(request = request.toJobStatusRequest()) },
81
+ promise = promise
82
+ )
83
+
84
+ @ReactMethod
85
+ override fun getEnhancedDocumentVerificationJobStatus(request: ReadableMap, promise: Promise) = launch(
86
+ work = { SmileID.api.getEnhancedDocumentVerificationJobStatus(request = request.toJobStatusRequest()) },
87
+ promise = promise
88
+ )
89
+
90
+ @ReactMethod
91
+ override fun getProductsConfig(request: ReadableMap, promise: Promise) = launch(
92
+ work = { SmileID.api.getProductsConfig(request = request.toProductsConfigRequest()) },
93
+ promise = promise
94
+ )
95
+
96
+ @ReactMethod
97
+ override fun getValidDocuments(request: ReadableMap, promise: Promise) = launch(
98
+ work = { SmileID.api.getValidDocuments(request = request.toProductsConfigRequest()) },
99
+ promise = promise
100
+ )
101
+
102
+ @ReactMethod
103
+ override fun getServices(promise: Promise) = launch(
104
+ work = { SmileID.api.getServices() },
105
+ promise = promise
106
+ )
130
107
 
131
108
  private fun <T> launch(
132
109
  work: suspend () -> T,
@@ -26,41 +26,6 @@ fun ReadableMap.toMap(): Map<String, String> {
26
26
  return map
27
27
  }
28
28
 
29
- fun ReadableMap.idInfo(): IdInfo? {
30
- val country = getStringOrDefault("country", null) ?: run {
31
- Timber.e("idInfo.country is required")
32
- return null
33
- }
34
- return IdInfo(
35
- country = country,
36
- idType = getStringOrDefault("idType", null),
37
- idNumber = getStringOrDefault("idNumber", null),
38
- firstName = getStringOrDefault("firstName", null),
39
- middleName = getStringOrDefault("middleName", null),
40
- lastName = getStringOrDefault("lastName", null),
41
- dob = getStringOrDefault("dob", null),
42
- bankCode = getStringOrDefault("bankCode", null),
43
- entered = getBoolOrDefault("entered", false),
44
- )
45
- }
46
-
47
-
48
- fun ReadableMap.partnerParams(): PartnerParams? {
49
- val partnerParams = getMapOrDefault("partnerParams", null) ?: run {
50
- Timber.w("partnerParams is required")
51
- return null
52
- }
53
- val jobTypeValue = partnerParams.getIntOrDefault("jobType", null)
54
- val jobType = if (jobTypeValue != null) JobType.fromValue(jobTypeValue) else null
55
- return PartnerParams(
56
- jobType = jobType,
57
- userId = partnerParams.getStringOrDefault("userId", null) ?: run { randomUserId() },
58
- jobId = partnerParams.getStringOrDefault("jobId", null) ?: run { randomUserId() },
59
- extras = partnerParams.getMapOrDefault("extras", null)?.toMap() ?: run { emptyMap() },
60
- )
61
- }
62
-
63
-
64
29
  fun ReadableMap.getBoolOrDefault(key: String, defaultValue: Boolean): Boolean {
65
30
  if (hasKey(key)) {
66
31
  return getBoolean(key)
@@ -68,28 +33,28 @@ fun ReadableMap.getBoolOrDefault(key: String, defaultValue: Boolean): Boolean {
68
33
  return defaultValue
69
34
  }
70
35
 
71
- fun ReadableMap.getFloatOrDefault(key: String, defaultValue: Float?): Float? {
36
+ fun ReadableMap.getFloatOrDefault(key: String, defaultValue: Float? = null): Float? {
72
37
  if (hasKey(key)) {
73
38
  return getDouble(key).toFloat()
74
39
  }
75
40
  return defaultValue
76
41
  }
77
42
 
78
- fun ReadableMap.getStringOrDefault(key: String, defaultValue: String?): String? {
43
+ fun ReadableMap.getStringOrDefault(key: String, defaultValue: String? = null): String? {
79
44
  if (hasKey(key)) {
80
45
  return getString(key)
81
46
  }
82
47
  return defaultValue
83
48
  }
84
49
 
85
- fun ReadableMap.getIntOrDefault(key: String, defaultValue: Int?): Int? {
50
+ fun ReadableMap.getIntOrDefault(key: String, defaultValue: Int? = null): Int? {
86
51
  if (hasKey(key)) {
87
52
  return getInt(key)
88
53
  }
89
54
  return defaultValue
90
55
  }
91
56
 
92
- fun ReadableMap.getMapOrDefault(key: String, defaultValue: ReadableMap?): ReadableMap? {
57
+ fun ReadableMap.getMapOrDefault(key: String, defaultValue: ReadableMap? = null): ReadableMap? {
93
58
  if (hasKey(key)) {
94
59
  return getMap(key)
95
60
  }
@@ -5,9 +5,9 @@ import com.facebook.react.bridge.ReadableArray
5
5
  import com.facebook.react.module.annotations.ReactModule
6
6
  import com.facebook.react.uimanager.SimpleViewManager
7
7
  import com.facebook.react.uimanager.ThemedReactContext
8
+ import com.smileidentity.react.toIdInfo
8
9
  import com.smileidentity.react.utils.getBoolOrDefault
9
10
  import com.smileidentity.react.utils.getStringOrDefault
10
- import com.smileidentity.react.utils.idInfo
11
11
  import com.smileidentity.react.utils.toMap
12
12
  import com.smileidentity.react.views.SmileIDBiometricKYCView
13
13
 
@@ -44,15 +44,18 @@ class SmileIDBiometricKYCViewManager(private val reactApplicationContext: ReactA
44
44
  // Extract params from args and apply to view
45
45
  val params = args?.getMap(0)
46
46
  params?.let {
47
- val idInfoMap = params.getMap("idInfo") ?: return view.emitFailure(IllegalArgumentException("idInfo is required to run Biometric KYC"))
48
- val idInfo = idInfoMap.idInfo() ?: return view.emitFailure(IllegalArgumentException("idInfo is required to run Biometric KYC"))
47
+ val idInfoMap = params.getMap("idInfo")
48
+ ?: return view.emitFailure(IllegalArgumentException("idInfo is required to run Biometric KYC"))
49
+ val idInfo = idInfoMap.toIdInfo()
50
+ ?: return view.emitFailure(IllegalArgumentException("idInfo is required to run Biometric KYC"))
49
51
  view.extraPartnerParams = params.getMap("extraPartnerParams")?.toMap()
50
- view.userId = params.getStringOrDefault("userId",null)
51
- view.jobId = params.getStringOrDefault("jobId",null)
52
+ view.userId = params.getStringOrDefault("userId")
53
+ view.jobId = params.getStringOrDefault("jobId")
52
54
  view.idInfo = idInfo
53
- view.allowAgentMode = params.getBoolOrDefault("allowAgentMode",false)
54
- view.showAttribution = params.getBoolOrDefault("showAttribution",true)
55
- view.showInstructions = params.getBoolOrDefault("showInstructions",true)
55
+ view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false)
56
+ view.showAttribution = params.getBoolOrDefault("showAttribution", true)
57
+ view.showInstructions = params.getBoolOrDefault("showInstructions", true)
58
+ view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
56
59
  view.renderContent()
57
60
  }
58
61
  }
@@ -45,26 +45,32 @@ class SmileIDConsentViewManager(private val reactApplicationContext: ReactApplic
45
45
  val params = args?.getMap(0)
46
46
  params?.let {
47
47
 
48
- val partnerName = params.getString("partnerName") ?: return view.emitFailure(IllegalArgumentException("partnerName is required to show Consent Screen"))
49
- val partnerPrivacyPolicy = params.getString("partnerPrivacyPolicy") ?: return view.emitFailure(IllegalArgumentException("partnerPrivacyPolicy is required to show Consent Screen"))
50
- val logoResName = params.getString("partnerIcon") ?: return view.emitFailure(IllegalArgumentException("partnerIcon is required to show Consent Screen"))
51
- val productName = params.getString("productName") ?: return view.emitFailure(IllegalArgumentException("productName is required to show Consent Screen"))
48
+ val partnerName = params.getString("partnerName")
49
+ ?: return view.emitFailure(IllegalArgumentException("partnerName is required to show Consent Screen"))
50
+ val partnerPrivacyPolicy = params.getString("partnerPrivacyPolicy") ?: return view.emitFailure(
51
+ IllegalArgumentException("partnerPrivacyPolicy is required to show Consent Screen")
52
+ )
53
+ val logoResName = params.getString("partnerIcon")
54
+ ?: return view.emitFailure(IllegalArgumentException("partnerIcon is required to show Consent Screen"))
55
+ val productName = params.getString("productName")
56
+ ?: return view.emitFailure(IllegalArgumentException("productName is required to show Consent Screen"))
52
57
 
53
- view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams",null)?.toMap()
54
- view.userId = params.getStringOrDefault("userId",null)
55
- view.jobId = params.getStringOrDefault("jobId",null)
58
+ view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams")?.toMap()
59
+ view.userId = params.getStringOrDefault("userId")
60
+ view.jobId = params.getStringOrDefault("jobId")
56
61
  view.partnerName = partnerName
57
62
  view.partnerPrivacyPolicy = partnerPrivacyPolicy
58
63
  view.logoResName = logoResName
59
64
  view.productName = productName
60
- view.allowAgentMode = params.getBoolOrDefault("allowAgentMode",false)
61
- view.showAttribution = params.getBoolOrDefault("showAttribution",true)
62
- view.showInstructions = params.getBoolOrDefault("showInstructions",true)
65
+ view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false)
66
+ view.showAttribution = params.getBoolOrDefault("showAttribution", true)
67
+ view.showInstructions = params.getBoolOrDefault("showInstructions", true)
63
68
  view.renderContent()
64
69
  }
65
70
  }
66
71
  }
67
72
  }
73
+
68
74
  override fun createViewInstance(p0: ThemedReactContext): SmileIDConsentView {
69
75
  return SmileIDConsentView(reactApplicationContext)
70
76
  }
@@ -45,19 +45,21 @@ class SmileIDDocumentVerificationViewManager(private val reactApplicationContext
45
45
  // Extract params from args and apply to view
46
46
  val params = args?.getMap(0)
47
47
  params?.let {
48
- val countryCode = params.getString("countryCode") ?: return view.emitFailure(IllegalArgumentException("countryCode is required to run Document Verification"))
49
- view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams", null)?.toMap()
50
- view.userId = params.getStringOrDefault("userId",null)
51
- view.jobId = params.getStringOrDefault("jobId",null)
48
+ val countryCode = params.getString("countryCode")
49
+ ?: return view.emitFailure(IllegalArgumentException("countryCode is required to run Document Verification"))
50
+ view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams")?.toMap()
51
+ view.userId = params.getStringOrDefault("userId")
52
+ view.jobId = params.getStringOrDefault("jobId")
52
53
  view.countryCode = countryCode
53
- view.allowAgentMode = params.getBoolOrDefault("allowAgentMode",false)
54
- view.showAttribution = params.getBoolOrDefault("showAttribution",true)
55
- view.captureBothSides = params.getBoolOrDefault("captureBothSides",false)
56
- view.showInstructions = params.getBoolOrDefault("showInstructions",true)
57
- view.allowGalleryUpload = params.getBoolOrDefault("allowGalleryUpload",false)
58
- view.bypassSelfieCaptureWithFilePath = params.getStringOrDefault("bypassSelfieCaptureWithFilePath",null)
59
- view.documentType = params.getStringOrDefault("documentType",null)
60
- view.idAspectRatio = params.getFloatOrDefault("idAspectRatio",-1f)
54
+ view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false)
55
+ view.showAttribution = params.getBoolOrDefault("showAttribution", true)
56
+ view.captureBothSides = params.getBoolOrDefault("captureBothSides", false)
57
+ view.showInstructions = params.getBoolOrDefault("showInstructions", true)
58
+ view.allowGalleryUpload = params.getBoolOrDefault("allowGalleryUpload", false)
59
+ view.bypassSelfieCaptureWithFilePath = params.getStringOrDefault("bypassSelfieCaptureWithFilePath", null)
60
+ view.documentType = params.getStringOrDefault("documentType", null)
61
+ view.idAspectRatio = params.getFloatOrDefault("idAspectRatio", -1f)
62
+ view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
61
63
  view.renderContent()
62
64
  }
63
65
  }
@@ -45,18 +45,20 @@ class SmileIDEnhancedDocumentVerificationViewManager(private val reactApplicatio
45
45
  // Extract params from args and apply to view
46
46
  val params = args?.getMap(0)
47
47
  params?.let {
48
- val countryCode = params.getString("countryCode") ?: return view.emitFailure(IllegalArgumentException("countryCode is required to run Enhanced Document Verification"))
49
- view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams", null)?.toMap()
50
- view.userId = params.getStringOrDefault("userId",null)
51
- view.jobId = params.getStringOrDefault("jobId",null)
48
+ val countryCode = params.getString("countryCode")
49
+ ?: return view.emitFailure(IllegalArgumentException("countryCode is required to run Enhanced Document Verification"))
50
+ view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams")?.toMap()
51
+ view.userId = params.getStringOrDefault("userId")
52
+ view.jobId = params.getStringOrDefault("jobId")
52
53
  view.countryCode = countryCode
53
- view.allowAgentMode = params.getBoolOrDefault("allowAgentMode",false)
54
- view.showAttribution = params.getBoolOrDefault("showAttribution",true)
55
- view.captureBothSides = params.getBoolOrDefault("captureBothSides",false)
56
- view.showInstructions = params.getBoolOrDefault("showInstructions",true)
57
- view.allowGalleryUpload = params.getBoolOrDefault("allowGalleryUpload",false)
58
- view.documentType = params.getStringOrDefault("documentType",null)
59
- view.idAspectRatio = params.getFloatOrDefault("idAspectRatio",-1f)
54
+ view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false)
55
+ view.showAttribution = params.getBoolOrDefault("showAttribution", true)
56
+ view.captureBothSides = params.getBoolOrDefault("captureBothSides", false)
57
+ view.showInstructions = params.getBoolOrDefault("showInstructions", true)
58
+ view.allowGalleryUpload = params.getBoolOrDefault("allowGalleryUpload", false)
59
+ view.documentType = params.getStringOrDefault("documentType")
60
+ view.idAspectRatio = params.getFloatOrDefault("idAspectRatio", -1f)
61
+ view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
60
62
  view.renderContent()
61
63
  }
62
64
  }
@@ -44,12 +44,13 @@ class SmileIDSmartSelfieAuthenticationViewManager(private val reactApplicationCo
44
44
  // Extract params from args and apply to view
45
45
  val params = args?.getMap(0)
46
46
  params?.let {
47
- view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams", null)?.toMap()
48
- view.userId = params.getStringOrDefault("userId",null)
49
- view.jobId = params.getStringOrDefault("jobId",null)
50
- view.allowAgentMode = params.getBoolOrDefault("allowAgentMode",false)
51
- view.showAttribution = params.getBoolOrDefault("showAttribution",true)
52
- view.showInstructions = params.getBoolOrDefault("showInstructions",true)
47
+ view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams")?.toMap()
48
+ view.userId = params.getStringOrDefault("userId")
49
+ view.jobId = params.getStringOrDefault("jobId")
50
+ view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false)
51
+ view.showAttribution = params.getBoolOrDefault("showAttribution", true)
52
+ view.showInstructions = params.getBoolOrDefault("showInstructions", true)
53
+ view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
53
54
  view.renderContent()
54
55
  }
55
56
  }
@@ -44,12 +44,13 @@ class SmileIDSmartSelfieEnrollmentViewManager(private val reactApplicationContex
44
44
  // Extract params from args and apply to view
45
45
  val params = args?.getMap(0)
46
46
  params?.let {
47
- view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams", null)?.toMap()
48
- view.userId = params.getStringOrDefault("userId",null)
49
- view.jobId = params.getStringOrDefault("jobId",null)
50
- view.allowAgentMode = params.getBoolOrDefault("allowAgentMode",false)
51
- view.showAttribution = params.getBoolOrDefault("showAttribution",true)
52
- view.showInstructions = params.getBoolOrDefault("showInstructions",true)
47
+ view.extraPartnerParams = params.getMapOrDefault("extraPartnerParams")?.toMap()
48
+ view.userId = params.getStringOrDefault("userId")
49
+ view.jobId = params.getStringOrDefault("jobId")
50
+ view.allowAgentMode = params.getBoolOrDefault("allowAgentMode", false)
51
+ view.showAttribution = params.getBoolOrDefault("showAttribution", true)
52
+ view.showInstructions = params.getBoolOrDefault("showInstructions", true)
53
+ view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
53
54
  view.renderContent()
54
55
  }
55
56
  }