@smile_identity/react-native 10.0.0-beta01

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 (43) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +78 -0
  3. package/android/build.gradle +155 -0
  4. package/android/gradle.properties +6 -0
  5. package/android/src/main/AndroidManifest.xml +3 -0
  6. package/android/src/main/AndroidManifestNew.xml +2 -0
  7. package/android/src/main/assets/smile_config.json +9 -0
  8. package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +97 -0
  9. package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +50 -0
  10. package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +91 -0
  11. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBVNConsentViewManager.kt +42 -0
  12. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +42 -0
  13. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +42 -0
  14. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +42 -0
  15. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +42 -0
  16. package/android/src/main/java/com/smileidentity/react/views/SmileIDBVNConsentScreen.kt +54 -0
  17. package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYC.kt +89 -0
  18. package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerification.kt +59 -0
  19. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthentication.kt +47 -0
  20. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollment.kt +48 -0
  21. package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +121 -0
  22. package/android/src/newarch/SmileIdSpec.kt +7 -0
  23. package/android/src/oldarch/SmileIdSpec.kt +13 -0
  24. package/ios/SmileId.h +12 -0
  25. package/ios/SmileId.mm +27 -0
  26. package/ios/SmileId.xcodeproj/project.pbxproj +274 -0
  27. package/ios/SmileId.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  28. package/lib/commonjs/NativeSmileId.js +10 -0
  29. package/lib/commonjs/NativeSmileId.js.map +1 -0
  30. package/lib/commonjs/index.js +52 -0
  31. package/lib/commonjs/index.js.map +1 -0
  32. package/lib/module/NativeSmileId.js +3 -0
  33. package/lib/module/NativeSmileId.js.map +1 -0
  34. package/lib/module/index.js +38 -0
  35. package/lib/module/index.js.map +1 -0
  36. package/lib/typescript/NativeSmileId.d.ts +9 -0
  37. package/lib/typescript/NativeSmileId.d.ts.map +1 -0
  38. package/lib/typescript/index.d.ts +89 -0
  39. package/lib/typescript/index.d.ts.map +1 -0
  40. package/package.json +169 -0
  41. package/react-native-smile-id.podspec +42 -0
  42. package/src/NativeSmileId.ts +14 -0
  43. package/src/index.tsx +150 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Smile ID
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Smile ID React Native SDK
2
+
3
+ Smile ID provides premier solutions for Real Time Digital KYC, Identity Verification, User Onboarding, and User Authentication across Africa.
4
+
5
+ If you haven’t already, [sign up](https://www.usesmileid.com/schedule-a-demo/) for a free Smile ID account, which comes with Sandbox access.
6
+
7
+ Please see [CHANGELOG.md](CHANGELOG.md) or [Releases](https://github.com/smileidentity/react-native/releases) for the most recent version and release notes.
8
+
9
+ ## Getting Started
10
+
11
+ Full documentation is available at [Smile ID Documentation](https://docs.usesmileid.com/integration-options/mobile)
12
+
13
+ ### 0. Requirements
14
+
15
+ * Node.js >=16.0
16
+ * React Native >=0.70
17
+ * A `smile_config.json` file from [Smile ID Portal](https://portal.usesmileid.com/sdk)
18
+ * See: [Android Requirements](https://github.com/smileidentity/android) for Android specific requirements.
19
+ * See: [iOS Requirements](https://github.com/smileidentity/ios) for iOS specific requirements.
20
+
21
+ ### 1. Dependency
22
+
23
+ The latest release is available on [npm](https://www.npmjs.com/package/rn-smile-id)
24
+
25
+ Add the dependency to your `package.json`:
26
+
27
+ ```json
28
+ {
29
+ "dependencies": {
30
+ "rn-smile-id": "<latest-version>"
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### 2. Smile Config
36
+
37
+ #### Android
38
+
39
+ Place the `smile_config.json` file under your application's assets, located at `src/main/assets` (This should be at the same level as your `java` and `res` directories). You may need to create the directory if it does not already exist.
40
+
41
+ #### iOS
42
+
43
+ Drag the `smile_config.json` into your project's file inspector and ensure that the file is added to your app's target. Confirm that it is by checking the Copy Bundle Resources drop down in the Build Phases tab as shown below.
44
+
45
+ ### 3. Initialization
46
+
47
+ Initialize the Smile ID SDK in your app's entry file (normally `index.tsx`) by calling `initialize`:
48
+
49
+ ```typescript
50
+ import { initialize } from 'rn-smile-id';
51
+ import React, { useEffect } from 'react';
52
+
53
+ const App = () => {
54
+ useEffect(() => {
55
+ initialize().then(() => console.log('Smile ID Initialized'));
56
+ }, []);
57
+
58
+ return (
59
+ // ...rest of your component
60
+ );
61
+ };
62
+
63
+ export default App;
64
+ ```
65
+
66
+ ## Getting Help
67
+
68
+ For detailed documentation, please visit [Smile ID Documentation](https://docs.usesmileid.com/integration-options/mobile)
69
+
70
+ If you require further assistance, you can [file a support ticket](https://portal.usesmileid.com/partner/support/tickets) or [contact us](https://www.usesmileid.com/contact-us/)
71
+
72
+ ## Contributing
73
+
74
+ Bug reports and Pull Requests are welcomed. Please see [CONTRIBUTING.md](CONTRIBUTING.md)
75
+
76
+ ## License
77
+
78
+ [MIT License](LICENSE)
@@ -0,0 +1,155 @@
1
+ import com.android.Version
2
+
3
+ buildscript {
4
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
5
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SmileId_kotlinVersion"]
6
+ def smile_id_sdk_version = rootProject.ext.has("androidVersion") ? rootProject.ext.get("androidVersion") : project.properties["SmileId_androidVersion"]
7
+
8
+ repositories {
9
+ google()
10
+ mavenCentral()
11
+ gradlePluginPortal()
12
+ }
13
+
14
+ dependencies {
15
+ classpath "com.android.tools.build:gradle:8.1.2"
16
+ // noinspection DifferentKotlinGradleVersion
17
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18
+ classpath "org.jlleitschuh.gradle:ktlint-gradle:11.6.0"
19
+ }
20
+ }
21
+
22
+ def isNewArchitectureEnabled() {
23
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24
+ }
25
+
26
+ apply plugin: "com.android.library"
27
+ apply plugin: "kotlin-android"
28
+ apply plugin: 'kotlin-kapt'
29
+ apply plugin: "org.jlleitschuh.gradle.ktlint"
30
+
31
+ if (isNewArchitectureEnabled()) {
32
+ apply plugin: "com.facebook.react"
33
+ }
34
+
35
+ def getExtOrDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SmileId_" + name]
37
+ }
38
+
39
+ def getExtOrIntegerDefault(name) {
40
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SmileId_" + name]).toInteger()
41
+ }
42
+
43
+ def supportsNamespace() {
44
+ def parsed = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
45
+ def major = parsed[0].toInteger()
46
+ def minor = parsed[1].toInteger()
47
+
48
+ // Namespace support was added in 7.3.0
49
+ if (major == 7 && minor >= 3) {
50
+ return true
51
+ }
52
+
53
+ return major >= 8
54
+ }
55
+
56
+ android {
57
+ if (supportsNamespace()) {
58
+ namespace "com.smileidentity.react"
59
+
60
+ sourceSets {
61
+ main {
62
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
63
+ }
64
+ }
65
+ }
66
+
67
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
68
+
69
+ defaultConfig {
70
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
71
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
72
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
73
+ }
74
+ buildTypes {
75
+ release {
76
+ minifyEnabled false
77
+ }
78
+ }
79
+
80
+ buildFeatures {
81
+ buildConfig true
82
+ compose = true
83
+ }
84
+
85
+ kotlinOptions {
86
+ jvmTarget = JavaVersion.VERSION_11.toString()
87
+ }
88
+
89
+ lintOptions {
90
+ disable "GradleCompatible"
91
+ }
92
+
93
+ composeOptions {
94
+ kotlinCompilerExtensionVersion '1.5.3'
95
+ }
96
+
97
+ compileOptions {
98
+ sourceCompatibility JavaVersion.VERSION_11
99
+ targetCompatibility JavaVersion.VERSION_11
100
+ }
101
+
102
+ sourceSets {
103
+ main {
104
+ if (isNewArchitectureEnabled()) {
105
+ java.srcDirs += [
106
+ "src/newarch",
107
+ // This is needed to build Kotlin project with NewArch enabled
108
+ "${project.buildDir}/generated/source/codegen/java"
109
+ ]
110
+ } else {
111
+ java.srcDirs += ["src/oldarch"]
112
+ }
113
+ }
114
+ }
115
+ }
116
+
117
+ repositories {
118
+ mavenCentral()
119
+ google()
120
+ gradlePluginPortal()
121
+ }
122
+
123
+ def kotlin_version = getExtOrDefault("kotlinVersion")
124
+ def smile_id_sdk_version = getExtOrDefault("androidVersion")
125
+
126
+ dependencies {
127
+ implementation "com.facebook.react:react-native:0.72"
128
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
129
+ implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core"
130
+ implementation "com.smileidentity:android-sdk:$smile_id_sdk_version"
131
+ implementation "com.jakewharton.timber:timber"
132
+ implementation 'androidx.appcompat:appcompat:1.6.1'
133
+ implementation("androidx.navigation:navigation-compose:2.7.4")
134
+ testImplementation 'junit:junit:4.13.2'
135
+ androidTestImplementation 'androidx.test.ext:junit:1.1.5'
136
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
137
+ androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
138
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
139
+
140
+
141
+ androidTestImplementation platform('androidx.compose:compose-bom:2022.10.00')
142
+ androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
143
+
144
+
145
+ debugImplementation 'androidx.compose.ui:ui-tooling'
146
+ debugImplementation 'androidx.compose.ui:ui-test-manifest'
147
+ }
148
+
149
+ if (isNewArchitectureEnabled()) {
150
+ react {
151
+ jsRootDir = file("../src/")
152
+ libraryName = "SmileId"
153
+ codegenJavaPackageName = "com.smileidentity.react"
154
+ }
155
+ }
@@ -0,0 +1,6 @@
1
+ SmileId_kotlinVersion=1.9.10
2
+ SmileId_minSdkVersion=21
3
+ SmileId_targetSdkVersion=34
4
+ SmileId_compileSdkVersion=34
5
+ SmileId_ndkversion=21.4.7075529
6
+ SmileId_androidVersion=10.0.0-beta09
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.smileidentity.react">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,9 @@
1
+ {
2
+ "test_url": "https://sdktest.smileidentity.com/",
3
+ "test_lambda_url": "https://testapi.smileidentity.com/v1/",
4
+ "prod_url": "https://sdk.smileidentity.com/",
5
+ "prod_lambda_url": "https://api.smileidentity.com/v1/",
6
+ "auth_token": "MvQpF7JAuKQsftLonrk0Uoq5D5kcw7syp/YbGd1vxV8Tf5nzJfutQcz9c4RkdisV8Aj/tMq/LZyKFKd4MOIub1tf09AsNelW2OzkzaLn95OyVgfbSMyBq7eqc1rObqkzX9nvx6EBr7O1An07JfOqxOaySlR6qxJth5sO5OjBfHg=",
7
+ "partner_id": "210",
8
+ "version": "1.0.0"
9
+ }
@@ -0,0 +1,97 @@
1
+ package com.smileidentity.react
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.ReadableMap
7
+ import com.smileidentity.SmileID
8
+ import com.smileidentity.SmileIdSpec
9
+ import com.smileidentity.models.EnhancedKycRequest
10
+ import com.smileidentity.react.utils.getStringOrDefault
11
+ import com.smileidentity.react.utils.partnerParams
12
+ import kotlinx.coroutines.CoroutineExceptionHandler
13
+ import kotlinx.coroutines.CoroutineScope
14
+ import kotlinx.coroutines.Dispatchers
15
+ import kotlinx.coroutines.launch
16
+
17
+
18
+ class SmileIdModule internal constructor(context: ReactApplicationContext) :
19
+ SmileIdSpec(context) {
20
+
21
+ override fun getName(): String {
22
+ return NAME
23
+ }
24
+
25
+ @ReactMethod
26
+ override fun initialize(enableCrashReporting: Boolean, useSandBox: Boolean, promise: Promise) {
27
+ SmileID.initialize(
28
+ reactApplicationContext,
29
+ enableCrashReporting = enableCrashReporting,
30
+ useSandbox = useSandBox
31
+ )
32
+ promise.resolve(null)
33
+ }
34
+
35
+ @ReactMethod
36
+ override fun doEnhancedKycAsync(product: ReadableMap, promise: Promise) = launch(
37
+ work = {
38
+ val partnerParams = product.partnerParams()
39
+ partnerParams ?: run {
40
+ throw IllegalArgumentException("partnerParams is required for enhanced kyc")
41
+ }
42
+ val country = product.getStringOrDefault("country",null) ?: run {
43
+ throw IllegalArgumentException("country is required for enhanced kyc")
44
+ }
45
+ val idType = product.getStringOrDefault("idType",null) ?: run {
46
+ throw IllegalArgumentException("idType is required for enhanced kyc")
47
+ }
48
+ val idNumber = product.getStringOrDefault("idNumber",null) ?: run {
49
+ throw IllegalArgumentException("idNumber is required for enhanced kyc")
50
+ }
51
+
52
+ val timestamp = partnerParams?.extras?.get("timestamp") ?: run {
53
+ throw IllegalArgumentException("partnerParams.timestamp is required for enhanced kyc")
54
+ }
55
+ val signature = partnerParams?.extras?.get("timestamp") ?: run {
56
+ throw IllegalArgumentException("partnerParams.signature is required for enhanced kyc")
57
+ }
58
+ SmileID.api.doEnhancedKycAsync(
59
+ EnhancedKycRequest(
60
+ country = country,
61
+ idType = idType,
62
+ idNumber = idNumber,
63
+ firstName = product.getString("firstName"),
64
+ middleName = product.getString("middleName"),
65
+ lastName = product.getString("lastName"),
66
+ dob = product.getString("dob"),
67
+ phoneNumber = product.getString("phoneNumber"),
68
+ bankCode = product.getString("bankCode"),
69
+ callbackUrl = product.getString("callbackUrl"),
70
+ partnerParams = partnerParams,
71
+ sourceSdk = "android (react-native)",
72
+ timestamp = timestamp,
73
+ signature = signature,
74
+ )
75
+ )
76
+ },
77
+ promise = promise
78
+ )
79
+
80
+
81
+ private fun <T> launch(
82
+ work: suspend () -> T,
83
+ promise: Promise,
84
+ scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
85
+ ) {
86
+ val handler = CoroutineExceptionHandler { _, throwable ->
87
+ promise.reject(throwable.message)
88
+ }
89
+ scope.launch(handler) {
90
+ promise.resolve(Result.success(work()))
91
+ }
92
+ }
93
+
94
+ companion object {
95
+ const val NAME = "SmileID"
96
+ }
97
+ }
@@ -0,0 +1,50 @@
1
+ package com.smileidentity.react
2
+
3
+ import com.facebook.react.TurboReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.module.model.ReactModuleInfo
7
+ import com.facebook.react.module.model.ReactModuleInfoProvider
8
+ import com.facebook.react.uimanager.ViewManager
9
+ import com.smileidentity.react.viewmanagers.SmileIDBVNConsentViewManager
10
+ import com.smileidentity.react.viewmanagers.SmileIDBiometricKYCViewManager
11
+ import com.smileidentity.react.viewmanagers.SmileIDDocumentVerificationViewManager
12
+ import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieAuthenticationViewManager
13
+ import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieEnrollmentViewManager
14
+
15
+ class SmileIdPackage : TurboReactPackage() {
16
+
17
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
18
+ listOf(SmileIDSmartSelfieEnrollmentViewManager(reactContext),
19
+ SmileIDSmartSelfieAuthenticationViewManager(reactContext),
20
+ SmileIDDocumentVerificationViewManager(reactContext),
21
+ SmileIDBVNConsentViewManager(reactContext),
22
+ SmileIDBiometricKYCViewManager(reactContext),
23
+ )
24
+
25
+
26
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
27
+ return if (name == SmileIdModule.NAME) {
28
+ SmileIdModule(reactContext)
29
+ } else {
30
+ null
31
+ }
32
+ }
33
+
34
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
35
+ return ReactModuleInfoProvider {
36
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
37
+ val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
38
+ moduleInfos[SmileIdModule.NAME] = ReactModuleInfo(
39
+ SmileIdModule.NAME,
40
+ SmileIdModule.NAME,
41
+ false, // canOverrideExistingModule
42
+ false, // needsEagerInit
43
+ true, // hasConstants
44
+ false, // isCxxModule
45
+ isTurboModule // isTurboModule
46
+ )
47
+ moduleInfos
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,91 @@
1
+ package com.smileidentity.react.utils
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+ import com.facebook.react.bridge.ReadableType
5
+ import com.smileidentity.models.IdInfo
6
+ import com.smileidentity.models.JobType
7
+ import com.smileidentity.models.PartnerParams
8
+ import com.smileidentity.util.randomUserId
9
+ import timber.log.Timber
10
+
11
+ fun ReadableMap.toMap(): Map<String, String> {
12
+ val map = mutableMapOf<String, String>()
13
+ val iterator = keySetIterator()
14
+ while (iterator.hasNextKey()) {
15
+ val key = iterator.nextKey()
16
+ val value: String = when (getType(key)) {
17
+ ReadableType.Null -> null.toString()
18
+ ReadableType.Boolean -> getBoolean(key).toString()
19
+ ReadableType.Number -> getDouble(key).toString()
20
+ ReadableType.String -> getString(key)!!
21
+ ReadableType.Map -> getMap(key)?.toMap().toString()
22
+ ReadableType.Array -> getArray(key).toString()
23
+ }
24
+ map[key] = value
25
+ }
26
+ return map
27
+ }
28
+
29
+ fun ReadableMap.idInfo(): IdInfo? {
30
+ val idInfoMap = getMapOrDefault("idInfo", null)
31
+ val country = idInfoMap?.getStringOrDefault("country", null) ?: run {
32
+ Timber.e("idInfo.country is required")
33
+ return null
34
+ }
35
+ return IdInfo(
36
+ country = country,
37
+ idType = idInfoMap.getStringOrDefault("idType", null),
38
+ idNumber = idInfoMap.getStringOrDefault("idNumber", null),
39
+ firstName = idInfoMap.getStringOrDefault("firstName", null),
40
+ middleName = idInfoMap.getStringOrDefault("middleName", null),
41
+ lastName = idInfoMap.getStringOrDefault("lastName", null),
42
+ dob = idInfoMap.getStringOrDefault("dob", null),
43
+ bankCode = idInfoMap.getStringOrDefault("bankCode", null),
44
+ entered = idInfoMap.getBoolOrDefault("entered", false),
45
+ )
46
+ }
47
+
48
+
49
+ fun ReadableMap.partnerParams(): PartnerParams? {
50
+ val partnerParams = getMapOrDefault("partnerParams", null) ?: run {
51
+ Timber.w("partnerParams is required")
52
+ return null
53
+ }
54
+ val jobTypeValue = partnerParams.getIntOrDefault("jobType", null)
55
+ val jobType = if (jobTypeValue != null) JobType.fromValue(jobTypeValue) else null
56
+ return PartnerParams(
57
+ jobType = jobType,
58
+ userId = partnerParams.getStringOrDefault("userId", null) ?: run { randomUserId() },
59
+ jobId = partnerParams.getStringOrDefault("jobId", null) ?: run { randomUserId() },
60
+ extras = partnerParams.getMapOrDefault("extras", null)?.toMap() ?: run { emptyMap() },
61
+ )
62
+ }
63
+
64
+
65
+ fun ReadableMap.getBoolOrDefault(key: String, defaultValue: Boolean): Boolean {
66
+ if (hasKey(key)) {
67
+ return getBoolean(key)
68
+ }
69
+ return defaultValue
70
+ }
71
+
72
+ fun ReadableMap.getStringOrDefault(key: String, defaultValue: String?): String? {
73
+ if (hasKey(key)) {
74
+ return getString(key)
75
+ }
76
+ return defaultValue
77
+ }
78
+
79
+ fun ReadableMap.getIntOrDefault(key: String, defaultValue: Int?): Int? {
80
+ if (hasKey(key)) {
81
+ return getInt(key)
82
+ }
83
+ return defaultValue
84
+ }
85
+
86
+ fun ReadableMap.getMapOrDefault(key: String, defaultValue: ReadableMap?): ReadableMap? {
87
+ if (hasKey(key)) {
88
+ return getMap(key)
89
+ }
90
+ return defaultValue
91
+ }
@@ -0,0 +1,42 @@
1
+ package com.smileidentity.react.viewmanagers
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.facebook.react.module.annotations.ReactModule
6
+ import com.facebook.react.uimanager.SimpleViewManager
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.smileidentity.react.views.SmileIDBVNConsentScreen
10
+
11
+
12
+ @ReactModule(name = SmileIDBVNConsentViewManager.NAME)
13
+ class SmileIDBVNConsentViewManager(private val reactApplicationContext: ReactApplicationContext) :
14
+ SimpleViewManager<SmileIDBVNConsentScreen>() {
15
+ override fun getName(): String {
16
+ return NAME
17
+ }
18
+
19
+ override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
20
+ return mapOf(
21
+ "onSmileResult" to mapOf(
22
+ "phasedRegistrationNames" to mapOf(
23
+ "bubbled" to "onResult"
24
+ )
25
+ )
26
+ )
27
+ }
28
+
29
+ @ReactProp(name = "product")
30
+ fun setProduct(view: SmileIDBVNConsentScreen, product: ReadableMap) {
31
+ view.product = product
32
+ }
33
+
34
+ override fun createViewInstance(p0: ThemedReactContext): SmileIDBVNConsentScreen {
35
+ return SmileIDBVNConsentScreen(reactApplicationContext)
36
+ }
37
+
38
+ companion object {
39
+ const val NAME = "SmileIDBVNConsentScreenView"
40
+ }
41
+
42
+ }
@@ -0,0 +1,42 @@
1
+ package com.smileidentity.react.viewmanagers
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.facebook.react.module.annotations.ReactModule
6
+ import com.facebook.react.uimanager.SimpleViewManager
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.smileidentity.react.views.SmileIDBiometricKYC
10
+
11
+
12
+ @ReactModule(name = SmileIDBiometricKYCViewManager.NAME)
13
+ class SmileIDBiometricKYCViewManager(private val reactApplicationContext: ReactApplicationContext) :
14
+ SimpleViewManager<SmileIDBiometricKYC>() {
15
+ override fun getName(): String {
16
+ return NAME
17
+ }
18
+
19
+ override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
20
+ return mapOf(
21
+ "onSmileResult" to mapOf(
22
+ "phasedRegistrationNames" to mapOf(
23
+ "bubbled" to "onResult"
24
+ )
25
+ )
26
+ )
27
+ }
28
+
29
+ @ReactProp(name = "product")
30
+ fun setProduct(view: SmileIDBiometricKYC, product: ReadableMap) {
31
+ view.product = product
32
+ }
33
+
34
+ override fun createViewInstance(p0: ThemedReactContext): SmileIDBiometricKYC {
35
+ return SmileIDBiometricKYC(reactApplicationContext)
36
+ }
37
+
38
+ companion object {
39
+ const val NAME = "SmileIDBiometricKYCView"
40
+ }
41
+
42
+ }
@@ -0,0 +1,42 @@
1
+ package com.smileidentity.react.viewmanagers
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReadableMap
5
+ import com.facebook.react.module.annotations.ReactModule
6
+ import com.facebook.react.uimanager.SimpleViewManager
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+ import com.smileidentity.react.views.SmileIDDocumentVerification
10
+
11
+
12
+ @ReactModule(name = SmileIDDocumentVerificationViewManager.NAME)
13
+ class SmileIDDocumentVerificationViewManager(private val reactApplicationContext: ReactApplicationContext) :
14
+ SimpleViewManager<SmileIDDocumentVerification>() {
15
+ override fun getName(): String {
16
+ return NAME
17
+ }
18
+
19
+ override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
20
+ return mapOf(
21
+ "onSmileResult" to mapOf(
22
+ "phasedRegistrationNames" to mapOf(
23
+ "bubbled" to "onResult"
24
+ )
25
+ )
26
+ )
27
+ }
28
+
29
+ @ReactProp(name = "product")
30
+ fun setProduct(view: SmileIDDocumentVerification, product: ReadableMap) {
31
+ view.product = product
32
+ }
33
+
34
+ override fun createViewInstance(p0: ThemedReactContext): SmileIDDocumentVerification {
35
+ return SmileIDDocumentVerification(reactApplicationContext)
36
+ }
37
+
38
+ companion object {
39
+ const val NAME = "SmileIDDocumentVerificationView"
40
+ }
41
+
42
+ }