@smile_identity/react-native 10.0.0-beta02 → 10.0.0
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 +172 -0
- package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +64 -87
- package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +4 -39
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +11 -8
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDConsentViewManager.kt +16 -10
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +14 -12
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +13 -11
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +7 -6
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +7 -6
- package/android/src/main/java/com/smileidentity/react/views/CustomViewModelStoreOwner.kt +12 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +30 -22
- package/android/src/main/java/com/smileidentity/react/views/SmileIDConsentView.kt +19 -14
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +34 -27
- package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +34 -26
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +28 -22
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +28 -22
- package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +20 -7
- package/android/src/oldarch/SmileIdSpec.kt +23 -1
- package/ios/RNSmileID.mm +10 -0
- package/ios/RNSmileID.swift +137 -0
- package/ios/Utils/SmileIDDictExt.swift +145 -6
- package/ios/View/BaseSmileIDView.swift +26 -9
- package/ios/View/SmileIDBiometricKYCView.swift +6 -4
- package/ios/View/SmileIDConsentView.swift +15 -8
- package/ios/View/SmileIDDocumentVerificationView.swift +5 -3
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +6 -4
- package/ios/View/SmileIDSmartSelfieAuthView.swift +6 -4
- package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +6 -4
- package/ios/ViewManagers/SmileIDBaseViewManager.swift +14 -4
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.m +1 -0
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +11 -10
- package/ios/ViewManagers/SmileIDConsentViewManager.m +1 -0
- package/ios/ViewManagers/SmileIDConsentViewManager.swift +9 -9
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.m +1 -0
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +17 -16
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.m +1 -0
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +16 -15
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.m +1 -0
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.swift +10 -9
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.m +1 -0
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.swift +10 -9
- package/ios/ViewModels/SmileIDProductModel.swift +2 -1
- package/lib/commonjs/NativeSmileId.js.map +1 -1
- package/lib/commonjs/index.js +144 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +511 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/NativeSmileId.js.map +1 -1
- package/lib/module/index.js +45 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +471 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/NativeSmileId.d.ts +13 -9
- package/lib/typescript/NativeSmileId.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +44 -6
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +410 -88
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/react-native-smile-id.podspec +1 -1
- package/src/NativeSmileId.ts +58 -11
- package/src/index.tsx +97 -7
- package/src/types.ts +985 -90
- package/android/src/main/assets/smile_config.json +0 -9
package/ios/RNSmileID.swift
CHANGED
|
@@ -11,6 +11,58 @@ class RNSmileID: NSObject {
|
|
|
11
11
|
resolve(nil)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
@objc(authenticate:withResolver:withRejecter:)
|
|
15
|
+
func authenticate(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
16
|
+
guard let authenticationRequest = request.toAuthenticationRequest() else {
|
|
17
|
+
reject("Error", "Invalid request data", nil)
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
SmileID.api.authenticate(request: authenticationRequest)
|
|
22
|
+
.sink(receiveCompletion: { completion in
|
|
23
|
+
self.handleCompletion(completion, reject: reject)
|
|
24
|
+
}, receiveValue: { response in
|
|
25
|
+
self.resolveResponse(response, resolve: resolve, reject: reject)
|
|
26
|
+
}).store(in: &cancellables)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@objc(prepUpload:withResolver:withRejecter:)
|
|
30
|
+
func prepUpload(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
31
|
+
guard let prepUploadRequest = request.toPrepUploadRequest() else {
|
|
32
|
+
reject("Error", "Invalid prep upload request", nil)
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
SmileID.api.prepUpload(request: prepUploadRequest)
|
|
37
|
+
.sink(
|
|
38
|
+
receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
|
|
39
|
+
receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject)
|
|
40
|
+
}).store(in: &cancellables)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@objc(upload:request:withResolver:withRejecter:)
|
|
44
|
+
func upload(url: String, request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
45
|
+
guard let uploadRequest = request.toUploadRequest() else {
|
|
46
|
+
reject("Error", "Invalid upload request", nil)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
guard let zipUrl = try? LocalStorage.toZip(uploadRequest: uploadRequest) else {
|
|
51
|
+
reject("Error", "Unable to zip file", nil)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
guard let zipData = try? Data(contentsOf: zipUrl) else {
|
|
56
|
+
reject("Error", "Unable to read zip file", nil)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
SmileID.api.upload(zip: zipData, to: url)
|
|
61
|
+
.sink(receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
|
|
62
|
+
receiveValue: { _ in resolve(nil) }) // Assuming no response to return
|
|
63
|
+
.store(in: &cancellables)
|
|
64
|
+
}
|
|
65
|
+
|
|
14
66
|
@objc(doEnhancedKyc:withResolver:withRejecter:)
|
|
15
67
|
func doEnhancedKyc(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
16
68
|
guard let partnerParamsDict = request["partnerParams"] as? NSDictionary else {
|
|
@@ -144,4 +196,89 @@ class RNSmileID: NSObject {
|
|
|
144
196
|
resolve(["result": String(data: jsonData, encoding: .utf8)!]) // Assuming you have a method to convert response to a dictionary
|
|
145
197
|
}).store(in: &cancellables)
|
|
146
198
|
}
|
|
199
|
+
|
|
200
|
+
@objc(getSmartSelfieJobStatus:withResolver:withRejecter:)
|
|
201
|
+
func getSmartSelfieJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
202
|
+
getJobStatus(request: request, resolve: resolve, reject: reject)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@objc(getDocumentVerificationJobStatus:withResolver:withRejecter:)
|
|
206
|
+
func getDocumentVerificationJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
207
|
+
getJobStatus(request: request, resolve: resolve, reject: reject)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@objc(getBiometricKycJobStatus:withResolver:withRejecter:)
|
|
211
|
+
func getBiometricKycJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
212
|
+
getJobStatus(request: request, resolve: resolve, reject: reject)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@objc(getEnhancedDocumentVerificationJobStatus:withResolver:withRejecter:)
|
|
216
|
+
func getEnhancedDocumentVerificationJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
217
|
+
getJobStatus(request: request, resolve: resolve, reject: reject)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@objc(getProductsConfig:withResolver:withRejecter:)
|
|
221
|
+
func getProductsConfig(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
222
|
+
guard let productsConfigRequest = request.toProductsConfigRequest() else {
|
|
223
|
+
reject("Error", "Invalid products config request", nil)
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
SmileID.api.getProductsConfig(request: productsConfigRequest)
|
|
228
|
+
.sink(
|
|
229
|
+
receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
|
|
230
|
+
receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject)
|
|
231
|
+
}).store(in: &cancellables)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@objc(getValidDocuments:withResolver:withRejecter:)
|
|
235
|
+
func getValidDocuments(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
236
|
+
guard let validDocumentsRequest = request.toProductsConfigRequest() else {
|
|
237
|
+
reject("Error", "Invalid valid documents request", nil)
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
SmileID.api.getValidDocuments(request: validDocumentsRequest)
|
|
242
|
+
.sink(receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
|
|
243
|
+
receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject) })
|
|
244
|
+
.store(in: &cancellables)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@objc(getServicesWithResolver:withRejecter:)
|
|
248
|
+
func getServices(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
249
|
+
SmileID.api.getServices()
|
|
250
|
+
.sink(receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
|
|
251
|
+
receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject) })
|
|
252
|
+
.store(in: &cancellables)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
private func getJobStatus(request: NSDictionary, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
256
|
+
guard let jobStatusRequest = request.toJobStatusRequest() else {
|
|
257
|
+
reject("Error", "Invalid job status request", nil)
|
|
258
|
+
return
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
SmileID.api.getJobStatus(request: jobStatusRequest)
|
|
262
|
+
.sink(receiveCompletion: { completion in self.handleCompletion(completion, reject: reject) },
|
|
263
|
+
receiveValue: { response in self.resolveResponse(response, resolve: resolve, reject: reject) })
|
|
264
|
+
.store(in: &cancellables)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private func handleCompletion(_ completion: Subscribers.Completion<Error>, reject: @escaping RCTPromiseRejectBlock) {
|
|
268
|
+
switch completion {
|
|
269
|
+
case let .failure(error):
|
|
270
|
+
reject("Error", error.localizedDescription, error)
|
|
271
|
+
case .finished:
|
|
272
|
+
break
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private func resolveResponse<T: Encodable>(_ response: T, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
277
|
+
let encoder = JSONEncoder()
|
|
278
|
+
guard let jsonData = try? encoder.encode(response) else {
|
|
279
|
+
reject("Error", "Encoding error", nil)
|
|
280
|
+
return
|
|
281
|
+
}
|
|
282
|
+
resolve(String(data: jsonData, encoding: .utf8) ?? "")
|
|
283
|
+
}
|
|
147
284
|
}
|
|
@@ -2,18 +2,85 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
|
|
4
4
|
extension NSDictionary {
|
|
5
|
+
func toAuthenticationRequest() -> AuthenticationRequest? {
|
|
6
|
+
guard let jobTypeValue = self["jobType"] as? Int,
|
|
7
|
+
let jobType = JobType(rawValue: jobTypeValue),
|
|
8
|
+
let country = self["country"] as? String,
|
|
9
|
+
let idType = self["idType"] as? String,
|
|
10
|
+
let updateEnrolledImage = self["updateEnrolledImage"] as? Bool,
|
|
11
|
+
let jobId = self["jobId"] as? String,
|
|
12
|
+
let userId = self["userId"] as? String else {
|
|
13
|
+
return nil
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return AuthenticationRequest(
|
|
17
|
+
jobType: jobType,
|
|
18
|
+
updateEnrolledImage: updateEnrolledImage,
|
|
19
|
+
jobId: jobId,
|
|
20
|
+
userId: userId,
|
|
21
|
+
country: country,
|
|
22
|
+
idType: idType
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
func toPrepUploadRequest() -> PrepUploadRequest? {
|
|
27
|
+
guard let partnerParamsDict = self["partnerParams"] as? NSDictionary,
|
|
28
|
+
let partnerParams = partnerParamsDict.toPartnerParams(),
|
|
29
|
+
let callbackUrl = self["callbackUrl"] as? String,
|
|
30
|
+
let partnerId = self["partnerId"] as? String,
|
|
31
|
+
let timestamp = self["timestamp"] as? String,
|
|
32
|
+
let signature = self["signature"] as? String else {
|
|
33
|
+
return nil
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return PrepUploadRequest(
|
|
37
|
+
partnerParams: partnerParams,
|
|
38
|
+
callbackUrl: callbackUrl,
|
|
39
|
+
partnerId: partnerId,
|
|
40
|
+
sourceSdk: self["sourceSdk"] as? String ?? "ios (react-native)",
|
|
41
|
+
timestamp: timestamp,
|
|
42
|
+
signature: signature
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
func toUploadRequest() -> UploadRequest? {
|
|
47
|
+
guard let imagesArray = self["images"] as? [NSDictionary] else {
|
|
48
|
+
return nil
|
|
49
|
+
}
|
|
50
|
+
let images = imagesArray.compactMap { $0.toUploadImageInfo() }
|
|
51
|
+
let idInfo = (self["idInfo"] as? NSDictionary)?.toIdInfo()
|
|
52
|
+
|
|
53
|
+
return UploadRequest(
|
|
54
|
+
images: images,
|
|
55
|
+
idInfo: idInfo
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
func toUploadImageInfo() -> UploadImageInfo? {
|
|
60
|
+
guard let imageTypeIdValue = self["imageTypeId"] as? String,
|
|
61
|
+
let imageTypeId = ImageType(rawValue: imageTypeIdValue),
|
|
62
|
+
let imageName = self["imageName"] as? String else {
|
|
63
|
+
return nil
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return UploadImageInfo(
|
|
67
|
+
imageTypeId: imageTypeId,
|
|
68
|
+
fileName: imageName
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
5
72
|
func toIdInfo() -> IdInfo? {
|
|
6
73
|
guard let country = self["country"] as? String else {
|
|
7
74
|
return nil
|
|
8
75
|
}
|
|
9
76
|
|
|
10
|
-
let idType = self["
|
|
11
|
-
let idNumber = self["
|
|
12
|
-
let firstName = self["
|
|
13
|
-
let middleName = self["
|
|
14
|
-
let lastName = self["
|
|
77
|
+
let idType = self["idType"] as? String
|
|
78
|
+
let idNumber = self["idNumber"] as? String
|
|
79
|
+
let firstName = self["firstName"] as? String
|
|
80
|
+
let middleName = self["middleName"] as? String
|
|
81
|
+
let lastName = self["lastName"] as? String
|
|
15
82
|
let dob = self["dob"] as? String
|
|
16
|
-
let bankCode = self["
|
|
83
|
+
let bankCode = self["bankCode"] as? String
|
|
17
84
|
let entered = self["entered"] as? Bool
|
|
18
85
|
|
|
19
86
|
return IdInfo(
|
|
@@ -29,6 +96,78 @@ extension NSDictionary {
|
|
|
29
96
|
)
|
|
30
97
|
}
|
|
31
98
|
|
|
99
|
+
func toEnhancedKycRequest() -> EnhancedKycRequest? {
|
|
100
|
+
guard let country = self["country"] as? String,
|
|
101
|
+
let idType = self["idType"] as? String,
|
|
102
|
+
let idNumber = self["idNumber"] as? String,
|
|
103
|
+
let firstName = self["firstName"] as? String,
|
|
104
|
+
let middleName = self["middleName"] as? String,
|
|
105
|
+
let lastName = self["lastName"] as? String,
|
|
106
|
+
let dob = self["dob"] as? String,
|
|
107
|
+
let phoneNumber = self["phoneNumber"] as? String,
|
|
108
|
+
let bankCode = self["bankCode"] as? String,
|
|
109
|
+
let callbackUrl = self["callbackUrl"] as? String,
|
|
110
|
+
let partnerParamsDict = self["partnerParams"] as? NSDictionary,
|
|
111
|
+
let partnerParams = partnerParamsDict.toPartnerParams(),
|
|
112
|
+
let timestamp = self["timestamp"] as? String,
|
|
113
|
+
let signature = self["signature"] as? String else {
|
|
114
|
+
return nil
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return EnhancedKycRequest(
|
|
118
|
+
country: country,
|
|
119
|
+
idType: idType,
|
|
120
|
+
idNumber: idNumber,
|
|
121
|
+
firstName: firstName,
|
|
122
|
+
middleName: middleName,
|
|
123
|
+
lastName: lastName,
|
|
124
|
+
dob: dob,
|
|
125
|
+
phoneNumber: phoneNumber,
|
|
126
|
+
bankCode: bankCode,
|
|
127
|
+
callbackUrl: callbackUrl,
|
|
128
|
+
partnerParams: partnerParams,
|
|
129
|
+
sourceSdk: self["sourceSdk"] as? String ?? "ios (react-native)",
|
|
130
|
+
timestamp: timestamp,
|
|
131
|
+
signature: signature
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
func toJobStatusRequest() -> JobStatusRequest? {
|
|
136
|
+
guard let userId = self["userId"] as? String,
|
|
137
|
+
let jobId = self["jobId"] as? String,
|
|
138
|
+
let includeImageLinks = self["includeImageLinks"] as? Bool,
|
|
139
|
+
let includeHistory = self["includeHistory"] as? Bool,
|
|
140
|
+
let partnerId = self["partnerId"] as? String,
|
|
141
|
+
let timestamp = self["timestamp"] as? String,
|
|
142
|
+
let signature = self["signature"] as? String else {
|
|
143
|
+
return nil
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return JobStatusRequest(
|
|
147
|
+
userId: userId,
|
|
148
|
+
jobId: jobId,
|
|
149
|
+
includeImageLinks: includeImageLinks,
|
|
150
|
+
includeHistory: includeHistory,
|
|
151
|
+
partnerId: partnerId,
|
|
152
|
+
timestamp: timestamp,
|
|
153
|
+
signature: signature
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
func toProductsConfigRequest() -> ProductsConfigRequest? {
|
|
158
|
+
guard let partnerId = self["partnerId"] as? String,
|
|
159
|
+
let timestamp = self["timestamp"] as? String,
|
|
160
|
+
let signature = self["signature"] as? String else {
|
|
161
|
+
return nil
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return ProductsConfigRequest(
|
|
165
|
+
timestamp: timestamp,
|
|
166
|
+
signature: signature,
|
|
167
|
+
partnerId: partnerId
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
32
171
|
func toPartnerParams() -> PartnerParams? {
|
|
33
172
|
guard let country = self["country"] as? String else {
|
|
34
173
|
return nil
|
|
@@ -3,23 +3,38 @@ import SwiftUI
|
|
|
3
3
|
|
|
4
4
|
class BaseSmileIDView: UIView {
|
|
5
5
|
typealias ContentView = AnyView
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var contentView : AnyView?
|
|
7
|
+
private var _onResult: RCTBubblingEventBlock?
|
|
8
|
+
var product : SmileIDProductModel?
|
|
9
|
+
|
|
10
|
+
@objc var onResult: RCTBubblingEventBlock? {
|
|
11
|
+
get {
|
|
12
|
+
return _onResult
|
|
13
|
+
}
|
|
14
|
+
set {
|
|
15
|
+
_onResult = newValue
|
|
16
|
+
if newValue != nil {
|
|
17
|
+
product?.onResult = newValue
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
init(frame: CGRect,contentView:AnyView,product:SmileIDProductModel) {
|
|
23
|
+
self.contentView = contentView
|
|
24
|
+
self.product = product
|
|
10
25
|
super.init(frame: frame)
|
|
11
26
|
commonInit()
|
|
12
27
|
}
|
|
13
|
-
|
|
28
|
+
|
|
14
29
|
required init?(coder aDecoder: NSCoder) {
|
|
15
30
|
super.init(coder: aDecoder)
|
|
16
31
|
commonInit()
|
|
17
32
|
}
|
|
18
|
-
|
|
33
|
+
|
|
19
34
|
private func commonInit() {
|
|
20
35
|
// Perform initialization tasks here
|
|
21
36
|
// For example, setup subviews, add constraints, configure appearance
|
|
22
|
-
let hostingController = UIHostingController(rootView:
|
|
37
|
+
let hostingController = UIHostingController(rootView:contentView)
|
|
23
38
|
let hostingView = hostingController.view!
|
|
24
39
|
hostingView.translatesAutoresizingMaskIntoConstraints = false
|
|
25
40
|
addSubview(hostingView)
|
|
@@ -28,8 +43,10 @@ class BaseSmileIDView: UIView {
|
|
|
28
43
|
hostingView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
|
29
44
|
hostingView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
|
|
30
45
|
}
|
|
31
|
-
|
|
32
|
-
func getView() -> AnyView {
|
|
46
|
+
|
|
47
|
+
func getView(product:SmileIDProductModel) -> AnyView {
|
|
33
48
|
fatalError("Must be implemented by subclass")
|
|
34
49
|
}
|
|
50
|
+
|
|
51
|
+
|
|
35
52
|
}
|
|
@@ -3,14 +3,16 @@ import Foundation
|
|
|
3
3
|
import SmileID
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
struct SmileIDBiometricKYCView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View{
|
|
9
|
+
NavigationView {
|
|
9
10
|
if let idInfo = product.idInfo {
|
|
10
11
|
SmileID.biometricKycScreen(
|
|
11
12
|
idInfo: idInfo, // already validated in the SmileIDBiometricKYCViewManager
|
|
12
13
|
userId: product.userId ?? generateUserId(),
|
|
13
14
|
jobId: product.jobId ?? generateJobId(),
|
|
15
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
14
16
|
allowAgentMode: product.allowAgentMode,
|
|
15
17
|
showAttribution: product.showAttribution,
|
|
16
18
|
showInstructions: product.showInstructions,
|
|
@@ -23,7 +25,7 @@ class SmileIDBiometricKYCView: BaseSmileIDView {
|
|
|
23
25
|
// return an error if the required data is missing
|
|
24
26
|
Text("An error has occured")
|
|
25
27
|
}
|
|
26
|
-
}.navigationViewStyle(StackNavigationViewStyle())
|
|
28
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -3,25 +3,32 @@ import Foundation
|
|
|
3
3
|
import SmileID
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
struct SmileIDConsentView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var onResult: RCTBubblingEventBlock?
|
|
9
|
+
var body: some View {
|
|
10
|
+
NavigationView {
|
|
9
11
|
if let partnerIcon = product.partnerIcon,
|
|
10
12
|
let partnerName = product.partnerName,
|
|
11
13
|
let productName = product.productName,
|
|
12
|
-
let partnerPrivacyPolicy = product.partnerPrivacyPolicy
|
|
14
|
+
let partnerPrivacyPolicy = product.partnerPrivacyPolicy,
|
|
15
|
+
let uiImage = UIImage(named: partnerIcon, in: Bundle.main, compatibleWith: nil)
|
|
13
16
|
{
|
|
14
17
|
SmileID.consentScreen(
|
|
15
|
-
partnerIcon:
|
|
18
|
+
partnerIcon: uiImage,
|
|
16
19
|
partnerName: partnerName,
|
|
17
20
|
productName: productName,
|
|
18
21
|
partnerPrivacyPolicy: URL(string: partnerPrivacyPolicy)!,
|
|
19
22
|
showAttribution: true,
|
|
20
23
|
onConsentGranted: {
|
|
21
|
-
|
|
24
|
+
DispatchQueue.main.async {
|
|
25
|
+
self.product.onResult?(["result": true])
|
|
26
|
+
}
|
|
22
27
|
},
|
|
23
28
|
onConsentDenied: {
|
|
24
|
-
|
|
29
|
+
DispatchQueue.main.async {
|
|
30
|
+
self.product.onResult?(["error": true])
|
|
31
|
+
}
|
|
25
32
|
}
|
|
26
33
|
)
|
|
27
34
|
} else {
|
|
@@ -30,6 +37,6 @@ class SmileIDConsentView: BaseSmileIDView {
|
|
|
30
37
|
// return an error if the required data is missing
|
|
31
38
|
Text("An error has occured")
|
|
32
39
|
}
|
|
33
|
-
}.navigationViewStyle(StackNavigationViewStyle())
|
|
40
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
34
41
|
}
|
|
35
42
|
}
|
|
@@ -3,13 +3,15 @@ import Foundation
|
|
|
3
3
|
import SmileID
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
struct SmileIDDocumentVerificationView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body : some View {
|
|
8
9
|
AnyView(NavigationView {
|
|
9
10
|
if let countryCode = product.countryCode {
|
|
10
11
|
SmileID.documentVerificationScreen(
|
|
11
12
|
userId: product.userId ?? generateUserId(),
|
|
12
13
|
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
13
15
|
countryCode: countryCode, // already validated in SmileIDDocumentVerificationViewManager
|
|
14
16
|
documentType: product.documentType,
|
|
15
17
|
idAspectRatio: product.idAspectRatio,
|
|
@@ -46,7 +48,7 @@ extension SmileIDDocumentVerificationView: DocumentVerificationResultDelegate {
|
|
|
46
48
|
}
|
|
47
49
|
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
48
50
|
}
|
|
49
|
-
|
|
51
|
+
|
|
50
52
|
func didError(error: Error) {
|
|
51
53
|
product.onResult?(["error": error.localizedDescription])
|
|
52
54
|
}
|
|
@@ -3,13 +3,15 @@ import Foundation
|
|
|
3
3
|
import SmileID
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
struct SmileIDEnhancedDocumentVerificationView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
9
10
|
if let countryCode = product.countryCode {
|
|
10
11
|
SmileID.enhancedDocumentVerificationScreen(
|
|
11
12
|
userId: product.userId ?? generateUserId(),
|
|
12
13
|
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
13
15
|
countryCode: countryCode, // already validated in the view manager
|
|
14
16
|
documentType: product.documentType,
|
|
15
17
|
idAspectRatio: product.idAspectRatio,
|
|
@@ -28,7 +30,7 @@ class SmileIDEnhancedDocumentVerificationView: BaseSmileIDView {
|
|
|
28
30
|
// return an error if the required data is missing
|
|
29
31
|
Text("An error has occured")
|
|
30
32
|
}
|
|
31
|
-
}.navigationViewStyle(StackNavigationViewStyle())
|
|
33
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -3,19 +3,21 @@ import Foundation
|
|
|
3
3
|
import SmileID
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
struct SmileIDSmartSelfieAuthView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
9
10
|
SmileID.smartSelfieAuthenticationScreen(
|
|
10
11
|
userId: product.userId ?? generateUserId(),
|
|
11
12
|
jobId: product.jobId ?? generateJobId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
12
14
|
allowAgentMode: product.allowAgentMode,
|
|
13
15
|
showAttribution: product.showAttribution,
|
|
14
16
|
showInstructions: product.showInstructions,
|
|
15
17
|
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
16
18
|
delegate: self
|
|
17
19
|
)
|
|
18
|
-
}.navigationViewStyle(StackNavigationViewStyle())
|
|
20
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -3,19 +3,21 @@ import Foundation
|
|
|
3
3
|
import SmileID
|
|
4
4
|
import SwiftUI
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
struct SmileIDSmartSelfieEnrollmentView: View {
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
9
10
|
SmileID.smartSelfieEnrollmentScreen(
|
|
10
11
|
userId: product.userId ?? generateUserId(),
|
|
11
12
|
jobId: product.jobId ?? generateJobId(),
|
|
13
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
12
14
|
allowAgentMode: product.allowAgentMode,
|
|
13
15
|
showAttribution: product.showAttribution,
|
|
14
16
|
showInstructions: product.showInstructions,
|
|
15
17
|
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
16
18
|
delegate: self
|
|
17
19
|
)
|
|
18
|
-
}.navigationViewStyle(StackNavigationViewStyle())
|
|
20
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -3,15 +3,25 @@ import React
|
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
5
|
class SmileIDBaseViewManager: RCTViewManager, SmileIDUIViewDelegate {
|
|
6
|
+
var product = SmileIDProductModel()
|
|
7
|
+
@objc var onResult: RCTDirectEventBlock?
|
|
6
8
|
func getView() -> UIView {
|
|
7
9
|
fatalError("Must be implemented by subclass")
|
|
8
10
|
}
|
|
9
|
-
|
|
11
|
+
|
|
10
12
|
override func view() -> UIView! {
|
|
11
13
|
getView()
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
override func customBubblingEventTypes() -> [String]! {
|
|
17
|
+
return ["onResult"]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@objc override func constantsToExport() -> [AnyHashable : Any]! {
|
|
21
|
+
return ["onResult": "onResult"]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
25
|
+
return true
|
|
16
26
|
}
|
|
17
27
|
}
|
|
@@ -6,27 +6,28 @@ import SwiftUI
|
|
|
6
6
|
@objc(SmileIDBiometricKYCViewManager)
|
|
7
7
|
class SmileIDBiometricKYCViewManager: SmileIDBaseViewManager {
|
|
8
8
|
override func getView() -> UIView {
|
|
9
|
-
SmileIDBiometricKYCView()
|
|
9
|
+
BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDBiometricKYCView(product: self.product)),product:self.product)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
@objc func setParams(_ node: NSNumber, params: NSDictionary) {
|
|
13
13
|
/* UI Updates on the Main Thread:async ensures that the UI update is scheduled to run on the next cycle of the run loop, preventing any potential blocking of the UI if the update were to take a noticeable amount of time
|
|
14
14
|
*/
|
|
15
15
|
DispatchQueue.main.async {
|
|
16
|
-
if let component = self.bridge.uiManager.view(forReactTag: node) as?
|
|
16
|
+
if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
|
|
17
17
|
let onResult = params["onResult"] as? RCTDirectEventBlock
|
|
18
18
|
guard let idInfo = params["idInfo"] as? NSDictionary else {
|
|
19
19
|
onResult?(["error": SmileIDError.unknown("idInfo is required to run Biometric KYC")])
|
|
20
20
|
return
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
|
|
23
|
+
self.product.userId = params["userId"] as? String
|
|
24
|
+
self.product.jobId = params["jobId"] as? String
|
|
25
|
+
self.product.allowNewEnroll = params["allowNewEnroll"] as? Bool ?? false
|
|
26
|
+
self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
|
|
27
|
+
self.product.showAttribution = params["showAttribution"] as? Bool ?? true
|
|
28
|
+
self.product.showInstructions = params["showInstructions"] as? Bool ?? true
|
|
29
|
+
self.product.idInfo = idInfo.toIdInfo()
|
|
30
|
+
self.product.onResult = onResult
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
}
|