@smile_identity/react-native 10.0.0-beta01 → 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.
- package/README.md +1 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/smileidentity/react/Mapper.kt +179 -0
- package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +76 -49
- package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +4 -2
- package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +9 -38
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +41 -9
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDConsentViewManager.kt +83 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +45 -9
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +77 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +36 -9
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +36 -9
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +64 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDConsentView.kt +67 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +77 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +71 -0
- package/android/src/main/java/com/smileidentity/react/views/{SmileIDSmartSelfieAuthentication.kt → SmileIDSmartSelfieAuthenticationView.kt} +15 -4
- package/android/src/main/java/com/smileidentity/react/views/{SmileIDSmartSelfieEnrollment.kt → SmileIDSmartSelfieEnrollmentView.kt} +14 -5
- package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +3 -27
- package/android/src/oldarch/SmileIdSpec.kt +26 -1
- package/ios/RNDelegates/SmileIDUIViewDelegate.swift +4 -0
- package/ios/RNDelegates/SmileIDViewDelegate.swift +5 -0
- package/ios/RNSmileID.mm +7 -0
- package/ios/RNSmileID.swift +147 -0
- package/ios/SmileId.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/SmileId.xcodeproj/project.xcworkspace/xcuserdata/japhetndhlovu.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/SmileId.xcodeproj/xcuserdata/japhetndhlovu.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/Utils/SmileIDDictExt.swift +50 -0
- package/ios/Utils/SmileIDUtils.swift +10 -0
- package/ios/View/BaseSmileIDView.swift +35 -0
- package/ios/View/SmileIDBiometricKYCView.swift +46 -0
- package/ios/View/SmileIDConsentView.swift +36 -0
- package/ios/View/SmileIDDocumentVerificationView.swift +55 -0
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +55 -0
- package/ios/View/SmileIDSmartSelfieAuthView.swift +41 -0
- package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +41 -0
- package/ios/ViewManagers/SmileIDBaseViewManager.swift +18 -0
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.m +6 -0
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +34 -0
- package/ios/ViewManagers/SmileIDConsentViewManager.m +6 -0
- package/ios/ViewManagers/SmileIDConsentViewManager.swift +47 -0
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.m +6 -0
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +49 -0
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.m +6 -0
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +49 -0
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.m +6 -0
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.swift +27 -0
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.m +6 -0
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.swift +27 -0
- package/ios/ViewModels/SmileIDProductModel.swift +30 -0
- package/ios/react-native-smile-id-Bridging-Header.h +8 -0
- package/lib/commonjs/NativeSmileId.js +1 -1
- package/lib/commonjs/NativeSmileId.js.map +1 -1
- package/lib/commonjs/SmileIDBiometricKYCView.js +40 -0
- package/lib/commonjs/SmileIDBiometricKYCView.js.map +1 -0
- package/lib/commonjs/SmileIDConsentView.js +40 -0
- package/lib/commonjs/SmileIDConsentView.js.map +1 -0
- package/lib/commonjs/SmileIDDocumentVerificationView.js +40 -0
- package/lib/commonjs/SmileIDDocumentVerificationView.js.map +1 -0
- package/lib/commonjs/SmileIDEnhancedDocumentVerificationView.js +40 -0
- package/lib/commonjs/SmileIDEnhancedDocumentVerificationView.js.map +1 -0
- package/lib/commonjs/SmileIDSmartSelfieAuthenticationView.js +40 -0
- package/lib/commonjs/SmileIDSmartSelfieAuthenticationView.js.map +1 -0
- package/lib/commonjs/SmileIDSmartSelfieEnrollmentView.js +40 -0
- package/lib/commonjs/SmileIDSmartSelfieEnrollmentView.js.map +1 -0
- package/lib/commonjs/index.js +194 -27
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +517 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/NativeSmileId.js +1 -1
- package/lib/module/NativeSmileId.js.map +1 -1
- package/lib/module/SmileIDBiometricKYCView.js +30 -0
- package/lib/module/SmileIDBiometricKYCView.js.map +1 -0
- package/lib/module/SmileIDConsentView.js +30 -0
- package/lib/module/SmileIDConsentView.js.map +1 -0
- package/lib/module/SmileIDDocumentVerificationView.js +30 -0
- package/lib/module/SmileIDDocumentVerificationView.js.map +1 -0
- package/lib/module/SmileIDEnhancedDocumentVerificationView.js +30 -0
- package/lib/module/SmileIDEnhancedDocumentVerificationView.js.map +1 -0
- package/lib/module/SmileIDSmartSelfieAuthenticationView.js +30 -0
- package/lib/module/SmileIDSmartSelfieAuthenticationView.js.map +1 -0
- package/lib/module/SmileIDSmartSelfieEnrollmentView.js +30 -0
- package/lib/module/SmileIDSmartSelfieEnrollmentView.js.map +1 -0
- package/lib/module/index.js +33 -21
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +472 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/NativeSmileId.d.ts +22 -3
- package/lib/typescript/NativeSmileId.d.ts.map +1 -1
- package/lib/typescript/SmileIDBiometricKYCView.d.ts +8 -0
- package/lib/typescript/SmileIDBiometricKYCView.d.ts.map +1 -0
- package/lib/typescript/SmileIDConsentView.d.ts +8 -0
- package/lib/typescript/SmileIDConsentView.d.ts.map +1 -0
- package/lib/typescript/SmileIDDocumentVerificationView.d.ts +8 -0
- package/lib/typescript/SmileIDDocumentVerificationView.d.ts.map +1 -0
- package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts +8 -0
- package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts.map +1 -0
- package/lib/typescript/SmileIDSmartSelfieAuthenticationView.d.ts +8 -0
- package/lib/typescript/SmileIDSmartSelfieAuthenticationView.d.ts.map +1 -0
- package/lib/typescript/SmileIDSmartSelfieEnrollmentView.d.ts +8 -0
- package/lib/typescript/SmileIDSmartSelfieEnrollmentView.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +24 -86
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +504 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +3 -4
- package/react-native-smile-id.podspec +2 -2
- package/src/NativeSmileId.ts +68 -9
- package/src/SmileIDBiometricKYCView.tsx +45 -0
- package/src/SmileIDConsentView.tsx +44 -0
- package/src/SmileIDDocumentVerificationView.tsx +51 -0
- package/src/SmileIDEnhancedDocumentVerificationView.tsx +51 -0
- package/src/SmileIDSmartSelfieAuthenticationView.tsx +51 -0
- package/src/SmileIDSmartSelfieEnrollmentView.tsx +51 -0
- package/src/index.tsx +86 -122
- package/src/types.ts +1084 -0
- package/android/src/main/assets/smile_config.json +0 -9
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBVNConsentViewManager.kt +0 -42
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBVNConsentScreen.kt +0 -54
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYC.kt +0 -89
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerification.kt +0 -59
- package/ios/SmileId.h +0 -12
- package/ios/SmileId.mm +0 -27
|
@@ -7,12 +7,9 @@ import androidx.compose.ui.platform.ComposeView
|
|
|
7
7
|
import com.facebook.react.bridge.Arguments
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
9
|
import com.facebook.react.bridge.ReactContext
|
|
10
|
-
import com.facebook.react.bridge.ReadableMap
|
|
11
10
|
import com.facebook.react.bridge.WritableMap
|
|
12
11
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
13
12
|
import com.smileidentity.models.JobType
|
|
14
|
-
import com.smileidentity.react.utils.getBoolOrDefault
|
|
15
|
-
import com.smileidentity.react.utils.getIntOrDefault
|
|
16
13
|
import timber.log.Timber
|
|
17
14
|
|
|
18
15
|
abstract class SmileIDView(context: ReactApplicationContext) : LinearLayout(context) {
|
|
@@ -21,14 +18,12 @@ abstract class SmileIDView(context: ReactApplicationContext) : LinearLayout(cont
|
|
|
21
18
|
var jobId: String? = null
|
|
22
19
|
private var jobType: JobType? = null
|
|
23
20
|
var allowAgentMode: Boolean? = false
|
|
21
|
+
var allowNewEnroll: Boolean? = false
|
|
24
22
|
var showInstructions: Boolean? = true
|
|
23
|
+
var showAttribution: Boolean? = true
|
|
24
|
+
var extraPartnerParams: Map<String, String>? = null
|
|
25
25
|
private var eventEmitter: RCTEventEmitter
|
|
26
26
|
private var productThrowable: Throwable? = null
|
|
27
|
-
var product: ReadableMap? = null
|
|
28
|
-
set(value) {
|
|
29
|
-
field = value
|
|
30
|
-
render()
|
|
31
|
-
}
|
|
32
27
|
|
|
33
28
|
init {
|
|
34
29
|
val layoutParams = ViewGroup.LayoutParams(
|
|
@@ -50,28 +45,9 @@ abstract class SmileIDView(context: ReactApplicationContext) : LinearLayout(cont
|
|
|
50
45
|
manuallyLayoutChildren()
|
|
51
46
|
}
|
|
52
47
|
|
|
53
|
-
private fun checkCommonArgs() {
|
|
54
|
-
if (product == null) {
|
|
55
|
-
productThrowable = IllegalArgumentException("Product is null")
|
|
56
|
-
emitFailure(productThrowable!!)
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
userId = product?.getString("userId")
|
|
60
|
-
jobId = product?.getString("userId")
|
|
61
|
-
|
|
62
|
-
allowAgentMode = product?.getBoolOrDefault("allowAgentMode", false)
|
|
63
|
-
showInstructions = product?.getBoolOrDefault("showInstructions", true)
|
|
64
|
-
val setJobType = product?.getIntOrDefault("jobType", null)
|
|
65
|
-
setJobType?.let { jobTypeValue ->
|
|
66
|
-
jobType = JobType.fromValue(jobTypeValue)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
48
|
abstract fun renderContent()
|
|
71
49
|
|
|
72
50
|
open fun render() {
|
|
73
|
-
checkCommonArgs();
|
|
74
|
-
checkCommonArgs();
|
|
75
51
|
renderContent()
|
|
76
52
|
}
|
|
77
53
|
|
|
@@ -8,6 +8,31 @@ 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(
|
|
11
|
+
abstract fun initialize(useSandBox: Boolean ,promise: Promise)
|
|
12
|
+
|
|
13
|
+
abstract fun disableCrashReporting(promise: Promise)
|
|
14
|
+
|
|
15
|
+
abstract fun authenticate(request: ReadableMap, promise: Promise)
|
|
16
|
+
|
|
17
|
+
abstract fun prepUpload(request: ReadableMap, promise: Promise)
|
|
18
|
+
|
|
19
|
+
abstract fun upload(url: String, request: ReadableMap, promise: Promise)
|
|
20
|
+
|
|
21
|
+
abstract fun doEnhancedKyc(request: ReadableMap, promise: Promise)
|
|
22
|
+
|
|
12
23
|
abstract fun doEnhancedKycAsync(request: ReadableMap, promise: Promise)
|
|
24
|
+
|
|
25
|
+
abstract fun getSmartSelfieJobStatus(request: ReadableMap, promise: Promise)
|
|
26
|
+
|
|
27
|
+
abstract fun getDocumentVerificationJobStatus(request: ReadableMap, promise: Promise)
|
|
28
|
+
|
|
29
|
+
abstract fun getBiometricKycJobStatus(request: ReadableMap, promise: Promise)
|
|
30
|
+
|
|
31
|
+
abstract fun getEnhancedDocumentVerificationJobStatus(request: ReadableMap, promise: Promise)
|
|
32
|
+
|
|
33
|
+
abstract fun getProductsConfig(request: ReadableMap, promise: Promise)
|
|
34
|
+
|
|
35
|
+
abstract fun getValidDocuments(request: ReadableMap, promise: Promise)
|
|
36
|
+
|
|
37
|
+
abstract fun getServices(promise: Promise)
|
|
13
38
|
}
|
package/ios/RNSmileID.mm
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(RNSmileID, NSObject)
|
|
4
|
+
RCT_EXTERN_METHOD(initialize:(BOOL)useSandBox withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
|
|
5
|
+
RCT_EXTERN_METHOD(doEnhancedKyc:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
|
|
6
|
+
RCT_EXTERN_METHOD(doEnhancedKycAsync:(NSDictionary *)request withResolver:(RCTPromiseResolveBlock)resolve withRejecter:(RCTPromiseRejectBlock)reject)
|
|
7
|
+
@end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import Combine
|
|
2
|
+
import SmileID
|
|
3
|
+
|
|
4
|
+
@objc(RNSmileID)
|
|
5
|
+
class RNSmileID: NSObject {
|
|
6
|
+
private var cancellables = Set<AnyCancellable>()
|
|
7
|
+
|
|
8
|
+
@objc(initialize:withResolver:withRejecter:)
|
|
9
|
+
func initialize(useSandBox: Bool, resolve: @escaping RCTPromiseResolveBlock, reject _: @escaping RCTPromiseRejectBlock) {
|
|
10
|
+
SmileID.initialize(useSandbox: useSandBox)
|
|
11
|
+
resolve(nil)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@objc(doEnhancedKyc:withResolver:withRejecter:)
|
|
15
|
+
func doEnhancedKyc(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
16
|
+
guard let partnerParamsDict = request["partnerParams"] as? NSDictionary else {
|
|
17
|
+
reject("doEnhancedKyc", "partnerParams is required", nil)
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
guard let partnerParams = partnerParamsDict.toPartnerParams() else {
|
|
21
|
+
reject("doEnhancedKyc", "partnerParams is missing required data", nil)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
guard let country = request["country"] as? String else {
|
|
25
|
+
reject("doEnhancedKyc", "country is required", nil)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
guard let idType = request["idType"] as? String else {
|
|
29
|
+
reject("doEnhancedKyc", "idType is required", nil)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
guard let idNumber = request["idNumber"] as? String else {
|
|
33
|
+
reject("doEnhancedKyc", "idNumber is required", nil)
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
guard let timestamp = request["timestamp"] as? String else {
|
|
37
|
+
reject("doEnhancedKyc", "timestamp is required", nil)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
guard let signature = request["signature"] as? String else {
|
|
41
|
+
reject("doEnhancedKyc", "signature is required", nil)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let request = EnhancedKycRequest(
|
|
46
|
+
country: country,
|
|
47
|
+
idType: idType,
|
|
48
|
+
idNumber: idNumber,
|
|
49
|
+
firstName: request["firstName"] as? String,
|
|
50
|
+
middleName: request["middleName"] as? String,
|
|
51
|
+
lastName: request["lastName"] as? String,
|
|
52
|
+
dob: request["dob"] as? String,
|
|
53
|
+
phoneNumber: request["phoneNumber"] as? String,
|
|
54
|
+
bankCode: request["bankCode"] as? String,
|
|
55
|
+
callbackUrl: request["callbackUrl"] as? String,
|
|
56
|
+
partnerParams: partnerParams,
|
|
57
|
+
sourceSdk: "ios (react-native)",
|
|
58
|
+
timestamp: timestamp,
|
|
59
|
+
signature: signature
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
SmileID.api.doEnhancedKyc(request: request)
|
|
63
|
+
.sink(receiveCompletion: { completion in
|
|
64
|
+
switch completion {
|
|
65
|
+
case let .failure(error):
|
|
66
|
+
reject("Error", error.localizedDescription, error)
|
|
67
|
+
case .finished:
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
}, receiveValue: { response in
|
|
71
|
+
let encoder = JSONEncoder()
|
|
72
|
+
guard let jsonData = try? encoder.encode(response) else {
|
|
73
|
+
reject("Error", "doEnhancedKyc encoding error ",
|
|
74
|
+
SmileIDError.unknown("doEnhancedKyc encoding error "))
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
resolve(["result": String(data: jsonData, encoding: .utf8)!]) // Assuming you have a method to convert response to a dictionary
|
|
78
|
+
}).store(in: &cancellables)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@objc(doEnhancedKycAsync:withResolver:withRejecter:)
|
|
82
|
+
func doEnhancedKycAsync(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
83
|
+
guard let partnerParamsDict = request["partnerParams"] as? NSDictionary else {
|
|
84
|
+
reject("doEnhancedKyc", "partnerParams is required", nil)
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
guard let partnerParams = partnerParamsDict.toPartnerParams() else {
|
|
88
|
+
reject("doEnhancedKyc", "partnerParams is missing required data", nil)
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
guard let country = request["country"] as? String else {
|
|
92
|
+
reject("doEnhancedKyc", "country is required", nil)
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
guard let idType = request["idType"] as? String else {
|
|
96
|
+
reject("doEnhancedKyc", "idType is required", nil)
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
guard let idNumber = request["idNumber"] as? String else {
|
|
100
|
+
reject("doEnhancedKyc", "idNumber is required", nil)
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
guard let timestamp = request["timestamp"] as? String else {
|
|
104
|
+
reject("doEnhancedKyc", "timestamp is required", nil)
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
guard let signature = request["signature"] as? String else {
|
|
108
|
+
reject("doEnhancedKyc", "signature is required", nil)
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let request = EnhancedKycRequest(
|
|
113
|
+
country: country,
|
|
114
|
+
idType: idType,
|
|
115
|
+
idNumber: idNumber,
|
|
116
|
+
firstName: request["firstName"] as? String,
|
|
117
|
+
middleName: request["middleName"] as? String,
|
|
118
|
+
lastName: request["lastName"] as? String,
|
|
119
|
+
dob: request["dob"] as? String,
|
|
120
|
+
phoneNumber: request["phoneNumber"] as? String,
|
|
121
|
+
bankCode: request["bankCode"] as? String,
|
|
122
|
+
callbackUrl: request["callbackUrl"] as? String,
|
|
123
|
+
partnerParams: partnerParams,
|
|
124
|
+
sourceSdk: "ios (react-native)",
|
|
125
|
+
timestamp: timestamp,
|
|
126
|
+
signature: signature
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
SmileID.api.doEnhancedKycAsync(request: request)
|
|
130
|
+
.sink(receiveCompletion: { completion in
|
|
131
|
+
switch completion {
|
|
132
|
+
case let .failure(error):
|
|
133
|
+
reject("Error", error.localizedDescription, error)
|
|
134
|
+
case .finished:
|
|
135
|
+
break
|
|
136
|
+
}
|
|
137
|
+
}, receiveValue: { response in
|
|
138
|
+
let encoder = JSONEncoder()
|
|
139
|
+
guard let jsonData = try? encoder.encode(response) else {
|
|
140
|
+
reject("Error", "doEnhancedKyc encoding error ",
|
|
141
|
+
SmileIDError.unknown("doEnhancedKyc encoding error "))
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
resolve(["result": String(data: jsonData, encoding: .utf8)!]) // Assuming you have a method to convert response to a dictionary
|
|
145
|
+
}).store(in: &cancellables)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>SmileId.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SmileID
|
|
3
|
+
|
|
4
|
+
extension NSDictionary {
|
|
5
|
+
func toIdInfo() -> IdInfo? {
|
|
6
|
+
guard let country = self["country"] as? String else {
|
|
7
|
+
return nil
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let idType = self["id_type"] as? String
|
|
11
|
+
let idNumber = self["id_number"] as? String
|
|
12
|
+
let firstName = self["first_name"] as? String
|
|
13
|
+
let middleName = self["middle_name"] as? String
|
|
14
|
+
let lastName = self["last_name"] as? String
|
|
15
|
+
let dob = self["dob"] as? String
|
|
16
|
+
let bankCode = self["bank_code"] as? String
|
|
17
|
+
let entered = self["entered"] as? Bool
|
|
18
|
+
|
|
19
|
+
return IdInfo(
|
|
20
|
+
country: country,
|
|
21
|
+
idType: idType,
|
|
22
|
+
idNumber: idNumber,
|
|
23
|
+
firstName: firstName,
|
|
24
|
+
middleName: middleName,
|
|
25
|
+
lastName: lastName,
|
|
26
|
+
dob: dob,
|
|
27
|
+
bankCode: bankCode,
|
|
28
|
+
entered: entered
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func toPartnerParams() -> PartnerParams? {
|
|
33
|
+
guard let country = self["country"] as? String else {
|
|
34
|
+
return nil
|
|
35
|
+
}
|
|
36
|
+
var jobType: JobType?
|
|
37
|
+
let jobId = self["jobId"] as? String
|
|
38
|
+
let userId = self["userId"] as? String
|
|
39
|
+
if let jobTypeValue = self["jobType"] as? Int {
|
|
40
|
+
jobType = JobType(rawValue: jobTypeValue)
|
|
41
|
+
}
|
|
42
|
+
let extras = self["extras"] as? [String: String] ?? [:]
|
|
43
|
+
return PartnerParams(
|
|
44
|
+
jobId: jobId ?? generateJobId(),
|
|
45
|
+
userId: userId ?? generateUserId(),
|
|
46
|
+
jobType: jobType,
|
|
47
|
+
extras: extras
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SwiftUI
|
|
3
|
+
|
|
4
|
+
class BaseSmileIDView: UIView {
|
|
5
|
+
typealias ContentView = AnyView
|
|
6
|
+
var contentView : AnyView?
|
|
7
|
+
|
|
8
|
+
init(frame: CGRect,contentView:AnyView) {
|
|
9
|
+
self.contentView = contentView
|
|
10
|
+
super.init(frame: frame)
|
|
11
|
+
commonInit()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
required init?(coder aDecoder: NSCoder) {
|
|
15
|
+
super.init(coder: aDecoder)
|
|
16
|
+
commonInit()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private func commonInit() {
|
|
20
|
+
// Perform initialization tasks here
|
|
21
|
+
// For example, setup subviews, add constraints, configure appearance
|
|
22
|
+
let hostingController = UIHostingController(rootView:contentView)
|
|
23
|
+
let hostingView = hostingController.view!
|
|
24
|
+
hostingView.translatesAutoresizingMaskIntoConstraints = false
|
|
25
|
+
addSubview(hostingView)
|
|
26
|
+
hostingView.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
|
27
|
+
hostingView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
|
|
28
|
+
hostingView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
|
29
|
+
hostingView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func getView(product:SmileIDProductModel) -> AnyView {
|
|
33
|
+
fatalError("Must be implemented by subclass")
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
struct SmileIDBiometricKYCView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View{
|
|
9
|
+
NavigationView {
|
|
10
|
+
if let idInfo = product.idInfo {
|
|
11
|
+
SmileID.biometricKycScreen(
|
|
12
|
+
idInfo: idInfo, // already validated in the SmileIDBiometricKYCViewManager
|
|
13
|
+
userId: product.userId ?? generateUserId(),
|
|
14
|
+
jobId: product.jobId ?? generateJobId(),
|
|
15
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
16
|
+
allowAgentMode: product.allowAgentMode,
|
|
17
|
+
showAttribution: product.showAttribution,
|
|
18
|
+
showInstructions: product.showInstructions,
|
|
19
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
20
|
+
delegate: self
|
|
21
|
+
)
|
|
22
|
+
} else {
|
|
23
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
24
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
25
|
+
// return an error if the required data is missing
|
|
26
|
+
Text("An error has occured")
|
|
27
|
+
}
|
|
28
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
extension SmileIDBiometricKYCView: BiometricKycResultDelegate {
|
|
33
|
+
func didSucceed(
|
|
34
|
+
selfieImage _: URL,
|
|
35
|
+
livenessImages _: [URL],
|
|
36
|
+
jobStatusResponse: BiometricKycJobStatusResponse
|
|
37
|
+
) {
|
|
38
|
+
let encoder = JSONEncoder()
|
|
39
|
+
let jsonData = try! encoder.encode(jobStatusResponse)
|
|
40
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
func didError(error: Error) {
|
|
44
|
+
product.onResult?(["error": error.localizedDescription])
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
struct SmileIDConsentView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
10
|
+
if let partnerIcon = product.partnerIcon,
|
|
11
|
+
let partnerName = product.partnerName,
|
|
12
|
+
let productName = product.productName,
|
|
13
|
+
let partnerPrivacyPolicy = product.partnerPrivacyPolicy
|
|
14
|
+
{
|
|
15
|
+
SmileID.consentScreen(
|
|
16
|
+
partnerIcon: UIImage(named: partnerIcon)!,
|
|
17
|
+
partnerName: partnerName,
|
|
18
|
+
productName: productName,
|
|
19
|
+
partnerPrivacyPolicy: URL(string: partnerPrivacyPolicy)!,
|
|
20
|
+
showAttribution: true,
|
|
21
|
+
onConsentGranted: {
|
|
22
|
+
self.product.onResult?(["result": true])
|
|
23
|
+
},
|
|
24
|
+
onConsentDenied: {
|
|
25
|
+
self.product.onResult?(["error": SmileIDError.consentDenied])
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
} else {
|
|
29
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
30
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
31
|
+
// return an error if the required data is missing
|
|
32
|
+
Text("An error has occured")
|
|
33
|
+
}
|
|
34
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
struct SmileIDDocumentVerificationView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body : some View {
|
|
9
|
+
AnyView(NavigationView {
|
|
10
|
+
if let countryCode = product.countryCode {
|
|
11
|
+
SmileID.documentVerificationScreen(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
15
|
+
countryCode: countryCode, // already validated in SmileIDDocumentVerificationViewManager
|
|
16
|
+
documentType: product.documentType,
|
|
17
|
+
idAspectRatio: product.idAspectRatio,
|
|
18
|
+
bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
|
|
19
|
+
captureBothSides: product.captureBothSides,
|
|
20
|
+
allowAgentMode: product.allowAgentMode,
|
|
21
|
+
allowGalleryUpload: product.allowGalleryUpload,
|
|
22
|
+
showInstructions: product.showInstructions,
|
|
23
|
+
showAttribution: product.showAttribution,
|
|
24
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
25
|
+
delegate: self
|
|
26
|
+
)
|
|
27
|
+
} else {
|
|
28
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
29
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
30
|
+
// return an error if the required data is missing
|
|
31
|
+
Text("An error has occured")
|
|
32
|
+
}
|
|
33
|
+
}.navigationViewStyle(StackNavigationViewStyle()))
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
extension SmileIDDocumentVerificationView: DocumentVerificationResultDelegate {
|
|
38
|
+
func didSucceed(
|
|
39
|
+
selfie _: URL,
|
|
40
|
+
documentFrontImage _: URL,
|
|
41
|
+
documentBackImage _: URL?,
|
|
42
|
+
jobStatusResponse: DocumentVerificationJobStatusResponse
|
|
43
|
+
) {
|
|
44
|
+
let encoder = JSONEncoder()
|
|
45
|
+
guard let jsonData = try? encoder.encode(jobStatusResponse) else {
|
|
46
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentVerificationView encoding error")])
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func didError(error: Error) {
|
|
53
|
+
product.onResult?(["error": error.localizedDescription])
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
struct SmileIDEnhancedDocumentVerificationView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
10
|
+
if let countryCode = product.countryCode {
|
|
11
|
+
SmileID.enhancedDocumentVerificationScreen(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
15
|
+
countryCode: countryCode, // already validated in the view manager
|
|
16
|
+
documentType: product.documentType,
|
|
17
|
+
idAspectRatio: product.idAspectRatio,
|
|
18
|
+
bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
|
|
19
|
+
captureBothSides: product.captureBothSides,
|
|
20
|
+
allowAgentMode: product.allowAgentMode,
|
|
21
|
+
allowGalleryUpload: product.allowGalleryUpload,
|
|
22
|
+
showInstructions: product.showInstructions,
|
|
23
|
+
showAttribution: product.showAttribution,
|
|
24
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
25
|
+
delegate: self
|
|
26
|
+
)
|
|
27
|
+
} else {
|
|
28
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
29
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
30
|
+
// return an error if the required data is missing
|
|
31
|
+
Text("An error has occured")
|
|
32
|
+
}
|
|
33
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
extension SmileIDEnhancedDocumentVerificationView: EnhancedDocumentVerificationResultDelegate {
|
|
38
|
+
func didSucceed(
|
|
39
|
+
selfie _: URL,
|
|
40
|
+
documentFrontImage _: URL,
|
|
41
|
+
documentBackImage _: URL?,
|
|
42
|
+
jobStatusResponse: EnhancedDocumentVerificationJobStatusResponse
|
|
43
|
+
) {
|
|
44
|
+
let encoder = JSONEncoder()
|
|
45
|
+
guard let jsonData = try? encoder.encode(jobStatusResponse) else {
|
|
46
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error")])
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func didError(error: Error) {
|
|
53
|
+
product.onResult?(["error": error.localizedDescription])
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
struct SmileIDSmartSelfieAuthView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
10
|
+
SmileID.smartSelfieAuthenticationScreen(
|
|
11
|
+
userId: product.userId ?? generateUserId(),
|
|
12
|
+
jobId: product.jobId ?? generateJobId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
|
+
allowAgentMode: product.allowAgentMode,
|
|
15
|
+
showAttribution: product.showAttribution,
|
|
16
|
+
showInstructions: product.showInstructions,
|
|
17
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
18
|
+
delegate: self
|
|
19
|
+
)
|
|
20
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
extension SmileIDSmartSelfieAuthView: SmartSelfieResultDelegate {
|
|
25
|
+
func didSucceed(
|
|
26
|
+
selfieImage _: URL,
|
|
27
|
+
livenessImages _: [URL],
|
|
28
|
+
jobStatusResponse: SmartSelfieJobStatusResponse
|
|
29
|
+
) {
|
|
30
|
+
let encoder = JSONEncoder()
|
|
31
|
+
guard let jsonData = try? encoder.encode(jobStatusResponse) else {
|
|
32
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error")])
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func didError(error: Error) {
|
|
39
|
+
product.onResult?(["error": error.localizedDescription])
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
import SmileID
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
struct SmileIDSmartSelfieEnrollmentView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
10
|
+
SmileID.smartSelfieEnrollmentScreen(
|
|
11
|
+
userId: product.userId ?? generateUserId(),
|
|
12
|
+
jobId: product.jobId ?? generateJobId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
|
+
allowAgentMode: product.allowAgentMode,
|
|
15
|
+
showAttribution: product.showAttribution,
|
|
16
|
+
showInstructions: product.showInstructions,
|
|
17
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
18
|
+
delegate: self
|
|
19
|
+
)
|
|
20
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
extension SmileIDSmartSelfieEnrollmentView: SmartSelfieResultDelegate {
|
|
25
|
+
func didSucceed(
|
|
26
|
+
selfieImage _: URL,
|
|
27
|
+
livenessImages _: [URL],
|
|
28
|
+
jobStatusResponse: SmartSelfieJobStatusResponse
|
|
29
|
+
) {
|
|
30
|
+
let encoder = JSONEncoder()
|
|
31
|
+
guard let jsonData = try? encoder.encode(jobStatusResponse) else {
|
|
32
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error")])
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func didError(error: Error) {
|
|
39
|
+
product.onResult?(["error": error.localizedDescription])
|
|
40
|
+
}
|
|
41
|
+
}
|