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

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 (122) hide show
  1. package/android/gradle.properties +1 -1
  2. package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +59 -9
  3. package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +4 -2
  4. package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +16 -10
  5. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +38 -9
  6. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDConsentViewManager.kt +77 -0
  7. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +43 -9
  8. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +75 -0
  9. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +35 -9
  10. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +35 -9
  11. package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +54 -0
  12. package/android/src/main/java/com/smileidentity/react/views/SmileIDConsentView.kt +60 -0
  13. package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +69 -0
  14. package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +63 -0
  15. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +50 -0
  16. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +49 -0
  17. package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +2 -27
  18. package/android/src/oldarch/SmileIdSpec.kt +4 -1
  19. package/ios/RNDelegates/SmileIDUIViewDelegate.swift +4 -0
  20. package/ios/RNDelegates/SmileIDViewDelegate.swift +5 -0
  21. package/ios/RNSmileID.mm +7 -0
  22. package/ios/RNSmileID.swift +147 -0
  23. package/ios/SmileId.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  24. package/ios/SmileId.xcodeproj/project.xcworkspace/xcuserdata/japhetndhlovu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  25. package/ios/SmileId.xcodeproj/xcuserdata/japhetndhlovu.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  26. package/ios/Utils/SmileIDDictExt.swift +50 -0
  27. package/ios/Utils/SmileIDUtils.swift +10 -0
  28. package/ios/View/BaseSmileIDView.swift +35 -0
  29. package/ios/View/SmileIDBiometricKYCView.swift +44 -0
  30. package/ios/View/SmileIDConsentView.swift +35 -0
  31. package/ios/View/SmileIDDocumentVerificationView.swift +53 -0
  32. package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +53 -0
  33. package/ios/View/SmileIDSmartSelfieAuthView.swift +39 -0
  34. package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +39 -0
  35. package/ios/ViewManagers/SmileIDBaseViewManager.swift +17 -0
  36. package/ios/ViewManagers/SmileIDBiometricKYCViewManager.m +6 -0
  37. package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +33 -0
  38. package/ios/ViewManagers/SmileIDConsentViewManager.m +6 -0
  39. package/ios/ViewManagers/SmileIDConsentViewManager.swift +47 -0
  40. package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.m +6 -0
  41. package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +48 -0
  42. package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.m +6 -0
  43. package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +48 -0
  44. package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.m +6 -0
  45. package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.swift +26 -0
  46. package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.m +6 -0
  47. package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.swift +26 -0
  48. package/ios/ViewModels/SmileIDProductModel.swift +29 -0
  49. package/ios/react-native-smile-id-Bridging-Header.h +8 -0
  50. package/lib/commonjs/NativeSmileId.js +1 -1
  51. package/lib/commonjs/NativeSmileId.js.map +1 -1
  52. package/lib/commonjs/SmileIDBiometricKYCView.js +40 -0
  53. package/lib/commonjs/SmileIDBiometricKYCView.js.map +1 -0
  54. package/lib/commonjs/SmileIDConsentView.js +40 -0
  55. package/lib/commonjs/SmileIDConsentView.js.map +1 -0
  56. package/lib/commonjs/SmileIDDocumentVerificationView.js +40 -0
  57. package/lib/commonjs/SmileIDDocumentVerificationView.js.map +1 -0
  58. package/lib/commonjs/SmileIDEnhancedDocumentVerificationView.js +40 -0
  59. package/lib/commonjs/SmileIDEnhancedDocumentVerificationView.js.map +1 -0
  60. package/lib/commonjs/SmileIDSmartSelfieAuthenticationView.js +40 -0
  61. package/lib/commonjs/SmileIDSmartSelfieAuthenticationView.js.map +1 -0
  62. package/lib/commonjs/SmileIDSmartSelfieEnrollmentView.js +40 -0
  63. package/lib/commonjs/SmileIDSmartSelfieEnrollmentView.js.map +1 -0
  64. package/lib/commonjs/index.js +98 -27
  65. package/lib/commonjs/index.js.map +1 -1
  66. package/lib/commonjs/types.js +6 -0
  67. package/lib/commonjs/types.js.map +1 -0
  68. package/lib/module/NativeSmileId.js +1 -1
  69. package/lib/module/NativeSmileId.js.map +1 -1
  70. package/lib/module/SmileIDBiometricKYCView.js +30 -0
  71. package/lib/module/SmileIDBiometricKYCView.js.map +1 -0
  72. package/lib/module/SmileIDConsentView.js +30 -0
  73. package/lib/module/SmileIDConsentView.js.map +1 -0
  74. package/lib/module/SmileIDDocumentVerificationView.js +30 -0
  75. package/lib/module/SmileIDDocumentVerificationView.js.map +1 -0
  76. package/lib/module/SmileIDEnhancedDocumentVerificationView.js +30 -0
  77. package/lib/module/SmileIDEnhancedDocumentVerificationView.js.map +1 -0
  78. package/lib/module/SmileIDSmartSelfieAuthenticationView.js +30 -0
  79. package/lib/module/SmileIDSmartSelfieAuthenticationView.js.map +1 -0
  80. package/lib/module/SmileIDSmartSelfieEnrollmentView.js +30 -0
  81. package/lib/module/SmileIDSmartSelfieEnrollmentView.js.map +1 -0
  82. package/lib/module/index.js +33 -21
  83. package/lib/module/index.js.map +1 -1
  84. package/lib/module/types.js +2 -0
  85. package/lib/module/types.js.map +1 -0
  86. package/lib/typescript/NativeSmileId.d.ts +16 -1
  87. package/lib/typescript/NativeSmileId.d.ts.map +1 -1
  88. package/lib/typescript/SmileIDBiometricKYCView.d.ts +8 -0
  89. package/lib/typescript/SmileIDBiometricKYCView.d.ts.map +1 -0
  90. package/lib/typescript/SmileIDConsentView.d.ts +8 -0
  91. package/lib/typescript/SmileIDConsentView.d.ts.map +1 -0
  92. package/lib/typescript/SmileIDDocumentVerificationView.d.ts +8 -0
  93. package/lib/typescript/SmileIDDocumentVerificationView.d.ts.map +1 -0
  94. package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts +8 -0
  95. package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts.map +1 -0
  96. package/lib/typescript/SmileIDSmartSelfieAuthenticationView.d.ts +8 -0
  97. package/lib/typescript/SmileIDSmartSelfieAuthenticationView.d.ts.map +1 -0
  98. package/lib/typescript/SmileIDSmartSelfieEnrollmentView.d.ts +8 -0
  99. package/lib/typescript/SmileIDSmartSelfieEnrollmentView.d.ts.map +1 -0
  100. package/lib/typescript/index.d.ts +24 -86
  101. package/lib/typescript/index.d.ts.map +1 -1
  102. package/lib/typescript/types.d.ts +182 -0
  103. package/lib/typescript/types.d.ts.map +1 -0
  104. package/package.json +1 -2
  105. package/react-native-smile-id.podspec +2 -2
  106. package/src/NativeSmileId.ts +17 -5
  107. package/src/SmileIDBiometricKYCView.tsx +45 -0
  108. package/src/SmileIDConsentView.tsx +44 -0
  109. package/src/SmileIDDocumentVerificationView.tsx +51 -0
  110. package/src/SmileIDEnhancedDocumentVerificationView.tsx +51 -0
  111. package/src/SmileIDSmartSelfieAuthenticationView.tsx +51 -0
  112. package/src/SmileIDSmartSelfieEnrollmentView.tsx +51 -0
  113. package/src/index.tsx +54 -122
  114. package/src/types.ts +189 -0
  115. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBVNConsentViewManager.kt +0 -42
  116. package/android/src/main/java/com/smileidentity/react/views/SmileIDBVNConsentScreen.kt +0 -54
  117. package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYC.kt +0 -89
  118. package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerification.kt +0 -59
  119. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthentication.kt +0 -47
  120. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollment.kt +0 -48
  121. package/ios/SmileId.h +0 -12
  122. package/ios/SmileId.mm +0 -27
package/src/types.ts ADDED
@@ -0,0 +1,189 @@
1
+ import { ViewProps } from 'react-native';
2
+
3
+ export type SmileIDViewProps = ViewProps & {
4
+ /**
5
+ * The user ID to associate with the Document Verification. Most often, this will
6
+ * correspond to a unique User ID within your system. If not provided, a random user ID will
7
+ * be generated.
8
+ */
9
+ userId?: string;
10
+ /**
11
+ * The job ID to associate with the Document Verification. Most often, this will
12
+ * correspond to a unique Job ID within your system. If not provided, a random job ID will
13
+ * be generated.
14
+ */
15
+ jobId?: string;
16
+ /**
17
+ * Custom values specific to partners.
18
+ */
19
+ extraPartnerParams?: Record<string, any>;
20
+ /**
21
+ * The delegate object that receives the result of the native events
22
+ */
23
+ onResult?: (event: any) => void;
24
+ };
25
+
26
+ export type IdInfo = {
27
+ /**
28
+ * The ISO 3166-1 alpha-3 country code of the document.
29
+ */
30
+ country: string;
31
+ /**
32
+ * Optional The id type of the number.
33
+ */
34
+ idType?: string;
35
+ /**
36
+ * Optional The id number
37
+ */
38
+ idNumber?: string;
39
+ /**
40
+ * First name of the user.
41
+ */
42
+ firstName?: string;
43
+ /**
44
+ * Middle name of the user
45
+ */
46
+ middleName?: string;
47
+ /**
48
+ * Last name of the user
49
+ */
50
+ lastName?: string;
51
+ /**
52
+ * Date of birth of the user
53
+ */
54
+ dob?: string;
55
+ /**
56
+ * Bank code
57
+ */
58
+ bankCode?: string;
59
+ /**
60
+ * Set true if the user has entered the id number
61
+ */
62
+ entered?: boolean;
63
+ };
64
+
65
+ type SmartSelfieRequest = SmileIDViewProps & {
66
+ /**
67
+ * Whether to allow Agent Mode or not. If allowed, a switch will be
68
+ * displayed allowing toggling between the back camera and front camera. If not allowed, only
69
+ * the front camera will be used.
70
+ */
71
+ allowAgentMode: boolean;
72
+ /**
73
+ * Whether to deactivate capture screen's instructions before selfie of document capture
74
+ */
75
+ showInstructions?: boolean;
76
+ /**
77
+ * Whether to show the Smile ID attribution on the Instructions screen.
78
+ */
79
+ showAttribution?: boolean;
80
+ };
81
+
82
+ export type SmartSelfieEnrollmentRequest = SmartSelfieRequest;
83
+ export type SmartSelfieAuthenticationRequest = SmartSelfieRequest;
84
+
85
+ export type EnhancedKycRequest = SmileIDViewProps & {
86
+ /**
87
+ * The ISO 3166-1 alpha-3 country code of the document.
88
+ */
89
+ country: string;
90
+ /**
91
+ * A string for the type of document to be captured.
92
+ */
93
+ idType: string;
94
+ /**
95
+ * A string for the id number to be validated
96
+ */
97
+ idNumber: string;
98
+ /**
99
+ * First name of the user.
100
+ */
101
+ firstName?: string;
102
+ /**
103
+ * Middle name of the user
104
+ */
105
+ middleName?: string;
106
+ /**
107
+ * Last name of the user
108
+ */
109
+ lastName?: string;
110
+ /**
111
+ * Date of birth of the user
112
+ */
113
+ dob?: string;
114
+ /**
115
+ * Phone number of the user
116
+ */
117
+ phoneNumber?: string;
118
+ /**
119
+ * Bank code
120
+ */
121
+ bankCode?: string;
122
+ /**
123
+ * Your callback url, results of jobs will be sent to the specified url. You can read more about callback urls here: https://docs.smileidentity.com/#callback-urls
124
+ */
125
+ callbackUrl?: string;
126
+ /**
127
+ * The timestamp used to calculate the signature in ISO date/time format
128
+ */
129
+ timestamp: string;
130
+ /**
131
+ * The outgoing signature, you can use this to verify that the response is from Smile ID
132
+ */
133
+ signature: string;
134
+ };
135
+
136
+ export type DocumentVerificationRequest = SmartSelfieRequest & {
137
+ /**
138
+ * The country of issuance of the ID type to be captured.
139
+ */
140
+ countryCode: string;
141
+ /**
142
+ * The ID type of the document ID to be captured.
143
+ */
144
+ documentType: string;
145
+ /**
146
+ * An optional value for the aspect ratio of the document. If no value is
147
+ * supplied, image analysis is done to calculate the document's aspect ratio.
148
+ */
149
+ idAspectRatio?: number;
150
+ /**
151
+ * Whether to capture both sides of the ID or not. Otherwise, only the
152
+ * front side will be captured. If this is true, an option to skip back side will still be
153
+ * shown.
154
+ */
155
+ captureBothSides?: boolean;
156
+ /**
157
+ * Whether to allow the user to upload images from their gallery or not.
158
+ */
159
+ allowGalleryUpload?: boolean;
160
+ /**
161
+ * If provided, selfie capture will be bypassed using this image.
162
+ */
163
+ bypassSelfieCaptureWithFile?: string;
164
+ };
165
+
166
+ export type ConsentRequest = Omit<SmartSelfieRequest, 'allowAgentMode'> & {
167
+ /**
168
+ * String value of the resource in the app's drawable folder to use as the partner icon.
169
+ */
170
+ partnerIcon: string;
171
+ /**
172
+ * The name of the partner to display on the consent screen.
173
+ */
174
+ partnerName: string;
175
+
176
+ /**
177
+ * The privacy policy URL of the partner to display on the consent screen.
178
+ */
179
+ partnerPrivacyPolicy: string;
180
+ /**
181
+ * The product being requested consent for
182
+ */
183
+ productName: string;
184
+ };
185
+
186
+ export type BiometricKYCRequest = ConsentRequest & {
187
+ idInfo: IdInfo;
188
+ productName: string;
189
+ };
@@ -1,42 +0,0 @@
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
- }
@@ -1,54 +0,0 @@
1
- package com.smileidentity.react.views
2
-
3
- import android.webkit.URLUtil
4
- import androidx.compose.ui.res.painterResource
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.smileidentity.SmileID
7
- import com.smileidentity.compose.BvnConsentScreen
8
- import com.smileidentity.react.utils.getStringOrDefault
9
- import java.net.URL
10
-
11
- class SmileIDBVNConsentScreen (context: ReactApplicationContext) : SmileIDView(context) {
12
-
13
- override fun renderContent() {
14
- product?.let {product->
15
- val partnerName = product.getStringOrDefault("partnerName",null) ?: run {
16
- emitFailure(IllegalArgumentException("partnerName is required for BiometricKYC"))
17
- return
18
- }
19
- val partnerPrivacyPolicy = product.getStringOrDefault("partnerPrivacyPolicy",null) ?: run {
20
- emitFailure(IllegalArgumentException("partnerPrivacyPolicy is required for BiometricKYC"))
21
- return
22
- }
23
- if(!URLUtil.isValidUrl(partnerPrivacyPolicy)){
24
- emitFailure(IllegalArgumentException("a valid url for partnerPrivacyPolicy is required for BiometricKYC"))
25
- return
26
- }
27
- val logoResName = product.getStringOrDefault("partnerIcon",null) ?: run {
28
- emitFailure(IllegalArgumentException("partnerPrivacyPolicy is required for BiometricKYC"))
29
- return
30
- }
31
- val partnerIcon = context.resources.getIdentifier(
32
- logoResName,
33
- "drawable",
34
- (context as? ReactApplicationContext)?.currentActivity?.packageName
35
- )
36
- composeView.apply {
37
- setContent {
38
- SmileID.BvnConsentScreen(
39
- partnerIcon = painterResource(
40
- id = partnerIcon
41
- ),
42
- partnerName = partnerName,
43
- partnerPrivacyPolicy = URL(partnerPrivacyPolicy),
44
- onConsentDenied = {
45
- emitSuccess("denied")
46
- },
47
- onConsentGranted = {
48
- emitSuccess("accepted")
49
- },
50
- )
51
- }}
52
- }
53
- }
54
- }
@@ -1,89 +0,0 @@
1
- package com.smileidentity.react.views
2
-
3
- import android.webkit.URLUtil
4
- import androidx.compose.runtime.saveable.rememberSaveable
5
- import androidx.compose.ui.res.painterResource
6
- import com.facebook.react.bridge.ReactApplicationContext
7
- import com.smileidentity.SmileID
8
- import com.smileidentity.compose.BiometricKYC
9
- import com.smileidentity.react.utils.getStringOrDefault
10
- import com.smileidentity.react.utils.idInfo
11
- import com.smileidentity.results.BiometricKycResult
12
- import com.smileidentity.results.SmileIDResult
13
- import com.smileidentity.util.randomJobId
14
- import com.smileidentity.util.randomUserId
15
- import timber.log.Timber
16
- import java.net.URL
17
-
18
- class SmileIDBiometricKYC(context: ReactApplicationContext) : SmileIDView(context) {
19
- override fun renderContent() {
20
- product?.let { product ->
21
- val idInfo = product.idInfo() ?: run {
22
- emitFailure(IllegalArgumentException("idInfo is required for BiometricKYC"))
23
- return
24
- }
25
- val partnerName = product.getStringOrDefault("partnerName", null) ?: run {
26
- emitFailure(IllegalArgumentException("partnerName is required for BiometricKYC"))
27
- return
28
- }
29
-
30
- val partnerPrivacyPolicy = product.getStringOrDefault("partnerPrivacyPolicy", null) ?: run {
31
- emitFailure(IllegalArgumentException("partnerPrivacyPolicy is required for BiometricKYC"))
32
- return
33
- }
34
- if (!URLUtil.isValidUrl(partnerPrivacyPolicy)) {
35
- emitFailure(IllegalArgumentException("a valid url for partnerPrivacyPolicy is required for BiometricKYC"))
36
- return
37
- }
38
- val logoResName = product.getString("partnerIcon") ?: run {
39
- emitFailure(IllegalArgumentException("productName is required for BiometricKYC"))
40
- return
41
- }
42
- val partnerIcon = context.resources.getIdentifier(
43
- logoResName,
44
- "drawable",
45
- (context as? ReactApplicationContext)?.currentActivity?.packageName
46
- )
47
-
48
- val productName = product.getStringOrDefault("productName", null) ?: run {
49
- emitFailure(IllegalArgumentException("productName is required for BiometricKYC"))
50
- return
51
- }
52
- composeView.apply {
53
- setContent {
54
- SmileID.BiometricKYC(
55
- idInfo = idInfo,
56
- partnerIcon = painterResource(id = partnerIcon),
57
- partnerName = partnerName,
58
- productName = productName,
59
- partnerPrivacyPolicy = URL(partnerPrivacyPolicy),
60
- userId = userId ?: rememberSaveable { randomUserId() },
61
- jobId = jobId ?: rememberSaveable { randomJobId() },
62
- allowAgentMode = allowAgentMode ?: false,
63
- showAttribution = showInstructions ?: true,
64
- ) { result ->
65
- when (result) {
66
- is SmileIDResult.Success -> {
67
- val json = try {
68
- SmileID.moshi
69
- .adapter(BiometricKycResult::class.java)
70
- .toJson(result.data)
71
- } catch (e: Exception) {
72
- Timber.w(e)
73
- "null"
74
- }
75
- emitSuccess(json)
76
- }
77
-
78
- is SmileIDResult.Error -> {
79
- result.throwable.printStackTrace()
80
- emitFailure(result.throwable)
81
- }
82
- }
83
- }
84
- }
85
- }
86
- }
87
- }
88
-
89
- }
@@ -1,59 +0,0 @@
1
- package com.smileidentity.react.views
2
-
3
- import androidx.compose.runtime.saveable.rememberSaveable
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.smileidentity.SmileID
6
- import com.smileidentity.compose.DocumentVerification
7
- import com.smileidentity.react.utils.getBoolOrDefault
8
- import com.smileidentity.react.utils.getStringOrDefault
9
- import com.smileidentity.results.DocumentVerificationResult
10
- import com.smileidentity.results.SmileIDResult
11
- import com.smileidentity.util.randomJobId
12
- import com.smileidentity.util.randomUserId
13
- import timber.log.Timber
14
-
15
- class SmileIDDocumentVerification(context: ReactApplicationContext) : SmileIDView(context) {
16
-
17
- override fun renderContent() {
18
- product?.let{ product ->
19
- val countryCode = product.getStringOrDefault("countryCode",null) ?: run {
20
- emitFailure(IllegalArgumentException("countryCode is required for DocumentVerification"))
21
- return;
22
- }
23
- val allowGalleryUpload = product.getBoolOrDefault("allowGalleryUpload",false)
24
- val captureBothSides = product.getBoolOrDefault("captureBothSides",false)
25
- composeView.apply {
26
- setContent {
27
- SmileID.DocumentVerification(
28
- userId = userId ?: rememberSaveable { randomUserId() },
29
- jobId = jobId ?: rememberSaveable { randomJobId() },
30
- countryCode = countryCode!!,
31
- documentType = product.getString("documentType"),
32
- showInstructions = showInstructions ?: true,
33
- allowGalleryUpload = allowGalleryUpload,
34
- captureBothSides = captureBothSides
35
- ) { result ->
36
- when (result) {
37
- is SmileIDResult.Success -> {
38
- val json = try {
39
- SmileID.moshi
40
- .adapter(DocumentVerificationResult::class.java)
41
- .toJson(result.data)
42
- } catch (e: Exception) {
43
- Timber.w(e)
44
- "null"
45
- }
46
- emitSuccess(json)
47
- }
48
-
49
- is SmileIDResult.Error -> {
50
- result.throwable.printStackTrace()
51
- emitFailure(result.throwable)
52
- }
53
- }
54
- }
55
- }
56
- }
57
- }
58
- }
59
- }
@@ -1,47 +0,0 @@
1
- package com.smileidentity.react.views
2
-
3
- import androidx.compose.runtime.saveable.rememberSaveable
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.smileidentity.SmileID
6
- import com.smileidentity.compose.SmartSelfieAuthentication
7
- import com.smileidentity.results.SmartSelfieResult
8
- import com.smileidentity.results.SmileIDResult
9
- import com.smileidentity.util.randomJobId
10
- import com.smileidentity.util.randomUserId
11
- import timber.log.Timber
12
-
13
- class SmileIDSmartSelfieAuthentication(context: ReactApplicationContext) : SmileIDView(context) {
14
-
15
- override fun renderContent() {
16
- product?.let {
17
- composeView.apply {
18
- setContent {
19
- SmileID.SmartSelfieAuthentication(
20
- userId = userId ?: rememberSaveable { randomUserId() },
21
- jobId = jobId ?: rememberSaveable { randomJobId() },
22
- allowAgentMode = allowAgentMode ?: false,
23
- ) { result ->
24
- when (result) {
25
- is SmileIDResult.Success -> {
26
- val json = try {
27
- SmileID.moshi
28
- .adapter(SmartSelfieResult::class.java)
29
- .toJson(result.data)
30
- } catch (e: Exception) {
31
- Timber.w(e)
32
- "null"
33
- }
34
- emitSuccess(json)
35
- }
36
-
37
- is SmileIDResult.Error -> {
38
- result.throwable.printStackTrace()
39
- emitFailure(result.throwable)
40
- }
41
- }
42
- }
43
- }
44
- }
45
- }
46
- }
47
- }
@@ -1,48 +0,0 @@
1
- package com.smileidentity.react.views
2
-
3
- import androidx.compose.runtime.saveable.rememberSaveable
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.smileidentity.SmileID
6
- import com.smileidentity.compose.SmartSelfieEnrollment
7
- import com.smileidentity.results.SmartSelfieResult
8
- import com.smileidentity.results.SmileIDResult
9
- import com.smileidentity.util.randomJobId
10
- import com.smileidentity.util.randomUserId
11
- import timber.log.Timber
12
-
13
- class SmileIDSmartSelfieEnrollment (context: ReactApplicationContext) : SmileIDView(context) {
14
-
15
- override fun renderContent() {
16
- product?.let {
17
- composeView.apply {
18
- setContent {
19
- SmileID.SmartSelfieEnrollment(
20
- userId = userId ?: rememberSaveable { randomUserId() },
21
- jobId = jobId ?: rememberSaveable { randomJobId() },
22
- allowAgentMode = allowAgentMode ?: false,
23
- showInstructions = showInstructions ?: true
24
- ) { result ->
25
- when (result) {
26
- is SmileIDResult.Success -> {
27
- val json = try {
28
- SmileID.moshi
29
- .adapter(SmartSelfieResult::class.java)
30
- .toJson(result.data)
31
- } catch (e: Exception) {
32
- Timber.w(e)
33
- "null"
34
- }
35
- emitSuccess(json)
36
- }
37
-
38
- is SmileIDResult.Error -> {
39
- result.throwable.printStackTrace()
40
- emitFailure(result.throwable)
41
- }
42
- }
43
- }
44
- }
45
- }
46
- }
47
- }
48
- }
package/ios/SmileId.h DELETED
@@ -1,12 +0,0 @@
1
-
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
- #import "RNSmileIdSpec.h"
4
-
5
- @interface SmileId : NSObject <NativeSmileIdSpec>
6
- #else
7
- #import <React/RCTBridgeModule.h>
8
-
9
- @interface SmileId : NSObject <RCTBridgeModule>
10
- #endif
11
-
12
- @end
package/ios/SmileId.mm DELETED
@@ -1,27 +0,0 @@
1
- #import "SmileId.h"
2
-
3
- @implementation SmileId
4
- RCT_EXPORT_MODULE()
5
-
6
- // Example method
7
- // See // https://reactnative.dev/docs/native-modules-ios
8
- RCT_EXPORT_METHOD(multiply:(double)a
9
- b:(double)b
10
- resolve:(RCTPromiseResolveBlock)resolve
11
- reject:(RCTPromiseRejectBlock)reject)
12
- {
13
- NSNumber *result = @(a * b);
14
-
15
- resolve(result);
16
- }
17
-
18
- // Don't compile this code when we build for the old architecture.
19
- #ifdef RCT_NEW_ARCH_ENABLED
20
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
21
- (const facebook::react::ObjCTurboModule::InitParams &)params
22
- {
23
- return std::make_shared<facebook::react::NativeSmileIdSpecJSI>(params);
24
- }
25
- #endif
26
-
27
- @end