@smile_identity/react-native 10.1.11 → 10.2.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.
Files changed (84) hide show
  1. package/android/build.gradle +4 -4
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +5 -0
  4. package/android/src/main/java/com/smileidentity/react/results/DocumentCaptureResult.kt +12 -0
  5. package/android/src/main/java/com/smileidentity/react/results/SmartSelfieCaptureResult.kt +11 -0
  6. package/android/src/main/java/com/smileidentity/react/utils/DocumentCaptureResultAdapter.kt +98 -0
  7. package/android/src/main/java/com/smileidentity/react/utils/SelfieCaptureResultAdapter.kt +78 -0
  8. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentCaptureViewManager.kt +65 -0
  9. package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieCaptureViewManager.kt +63 -0
  10. package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +26 -15
  11. package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentCaptureView.kt +102 -0
  12. package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +28 -15
  13. package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +28 -15
  14. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +26 -16
  15. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt +209 -0
  16. package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +26 -16
  17. package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +7 -2
  18. package/ios/RNSmileID.swift +1 -1
  19. package/ios/SmileId.xcodeproj/xcuserdata/japhetndhlovu.xcuserdatad/xcschemes/SmileId.xcscheme +23 -0
  20. package/ios/SmileId.xcodeproj/xcuserdata/japhetndhlovu.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  21. package/ios/Utils/FileUtils.swift +24 -0
  22. package/ios/View/SmileIDBiometricKYCView.swift +54 -51
  23. package/ios/View/SmileIDDocumentCaptureView.swift +82 -0
  24. package/ios/View/SmileIDDocumentVerificationView.swift +50 -47
  25. package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +49 -47
  26. package/ios/View/SmileIDSmartSelfieAuthView.swift +35 -33
  27. package/ios/View/SmileIDSmartSelfieCaptureView.swift +71 -0
  28. package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +35 -33
  29. package/ios/ViewManagers/SmileIDDocumentCaptureViewManager.m +7 -0
  30. package/ios/ViewManagers/SmileIDDocumentCaptureViewManager.swift +29 -0
  31. package/ios/ViewManagers/SmileIDSmartSelfieCaptureViewManager.m +7 -0
  32. package/ios/ViewManagers/SmileIDSmartSelfieCaptureViewManager.swift +36 -0
  33. package/ios/ViewModels/SmileIDProductModel.swift +2 -0
  34. package/lib/commonjs/SmileIDDocumentCaptureView.js +40 -0
  35. package/lib/commonjs/SmileIDDocumentCaptureView.js.map +1 -0
  36. package/lib/commonjs/SmileIDSmartSelfieCaptureView.js +40 -0
  37. package/lib/commonjs/SmileIDSmartSelfieCaptureView.js.map +1 -0
  38. package/lib/commonjs/index.js +14 -0
  39. package/lib/commonjs/index.js.map +1 -1
  40. package/lib/commonjs/types.js.map +1 -1
  41. package/lib/module/SmileIDDocumentCaptureView.js +30 -0
  42. package/lib/module/SmileIDDocumentCaptureView.js.map +1 -0
  43. package/lib/module/SmileIDSmartSelfieCaptureView.js +30 -0
  44. package/lib/module/SmileIDSmartSelfieCaptureView.js.map +1 -0
  45. package/lib/module/index.js +3 -1
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/types.js.map +1 -1
  48. package/lib/typescript/NativeSmileId.d.ts.map +1 -0
  49. package/lib/typescript/SmileIDBiometricKYCView.d.ts.map +1 -0
  50. package/lib/typescript/SmileIDConsentView.d.ts.map +1 -0
  51. package/lib/typescript/SmileIDDocumentCaptureView.d.ts +8 -0
  52. package/lib/typescript/SmileIDDocumentCaptureView.d.ts.map +1 -0
  53. package/lib/typescript/SmileIDDocumentVerificationView.d.ts.map +1 -0
  54. package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts.map +1 -0
  55. package/lib/typescript/SmileIDSmartSelfieAuthenticationView.d.ts.map +1 -0
  56. package/lib/typescript/SmileIDSmartSelfieCaptureView.d.ts +8 -0
  57. package/lib/typescript/SmileIDSmartSelfieCaptureView.d.ts.map +1 -0
  58. package/lib/typescript/SmileIDSmartSelfieEnrollmentView.d.ts.map +1 -0
  59. package/lib/typescript/{src/index.d.ts → index.d.ts} +3 -1
  60. package/lib/typescript/index.d.ts.map +1 -0
  61. package/lib/typescript/{src/types.d.ts → types.d.ts} +13 -2
  62. package/lib/typescript/types.d.ts.map +1 -0
  63. package/package.json +1 -1
  64. package/react-native-smile-id.podspec +1 -1
  65. package/src/SmileIDDocumentCaptureView.tsx +44 -0
  66. package/src/SmileIDSmartSelfieCaptureView.tsx +44 -0
  67. package/src/index.tsx +4 -0
  68. package/src/types.ts +21 -2
  69. package/lib/typescript/src/NativeSmileId.d.ts.map +0 -1
  70. package/lib/typescript/src/SmileIDBiometricKYCView.d.ts.map +0 -1
  71. package/lib/typescript/src/SmileIDConsentView.d.ts.map +0 -1
  72. package/lib/typescript/src/SmileIDDocumentVerificationView.d.ts.map +0 -1
  73. package/lib/typescript/src/SmileIDEnhancedDocumentVerificationView.d.ts.map +0 -1
  74. package/lib/typescript/src/SmileIDSmartSelfieAuthenticationView.d.ts.map +0 -1
  75. package/lib/typescript/src/SmileIDSmartSelfieEnrollmentView.d.ts.map +0 -1
  76. package/lib/typescript/src/index.d.ts.map +0 -1
  77. package/lib/typescript/src/types.d.ts.map +0 -1
  78. /package/lib/typescript/{src/NativeSmileId.d.ts → NativeSmileId.d.ts} +0 -0
  79. /package/lib/typescript/{src/SmileIDBiometricKYCView.d.ts → SmileIDBiometricKYCView.d.ts} +0 -0
  80. /package/lib/typescript/{src/SmileIDConsentView.d.ts → SmileIDConsentView.d.ts} +0 -0
  81. /package/lib/typescript/{src/SmileIDDocumentVerificationView.d.ts → SmileIDDocumentVerificationView.d.ts} +0 -0
  82. /package/lib/typescript/{src/SmileIDEnhancedDocumentVerificationView.d.ts → SmileIDEnhancedDocumentVerificationView.d.ts} +0 -0
  83. /package/lib/typescript/{src/SmileIDSmartSelfieAuthenticationView.d.ts → SmileIDSmartSelfieAuthenticationView.d.ts} +0 -0
  84. /package/lib/typescript/{src/SmileIDSmartSelfieEnrollmentView.d.ts → SmileIDSmartSelfieEnrollmentView.d.ts} +0 -0
@@ -0,0 +1,82 @@
1
+ import Foundation
2
+ import SmileID
3
+ import SwiftUI
4
+
5
+ struct DocumentCaptureResult {
6
+ let documentFile: URL? // Using URL to represent file paths in Swift
7
+
8
+ init(documentFile: URL?) {
9
+ self.documentFile = documentFile
10
+ }
11
+ }
12
+
13
+ struct SmileIDDocumentCaptureView: View {
14
+ @ObservedObject var product : SmileIDProductModel
15
+ @State private var localMetadata = LocalMetadata()
16
+ var body: some View {
17
+ NavigationView {
18
+ DocumentCaptureScreen(
19
+ side: self.product.front ? .front : .back,
20
+ showInstructions: self.product.showInstructions,
21
+ showAttribution: self.product.showAttribution,
22
+ allowGallerySelection: self.product.allowGalleryUpload,
23
+ showSkipButton: false,
24
+ instructionsHeroImage: self.product.front ? SmileIDResourcesHelper.DocVFrontHero : SmileIDResourcesHelper.DocVBackHero,
25
+ instructionsTitleText: SmileIDResourcesHelper.localizedString(
26
+ for: self.product.front ? "Instructions.Document.Front.Header": "Instructions.Document.Back.Header"
27
+ ),
28
+ instructionsSubtitleText: SmileIDResourcesHelper.localizedString(
29
+ for: self.product.front ? "Instructions.Document.Front.Callout": "Instructions.Document.Back.Callout"
30
+ ),
31
+ captureTitleText: SmileIDResourcesHelper.localizedString(for: "Action.TakePhoto"),
32
+ knownIdAspectRatio: self.product.idAspectRatio,
33
+ showConfirmation:self.product.showConfirmation,
34
+ onConfirm: onConfirmed,
35
+ onError: onError,
36
+ onSkip: onSkip
37
+ )
38
+ }.navigationViewStyle(StackNavigationViewStyle()).environmentObject(localMetadata)
39
+ }
40
+
41
+ func onConfirmed(data: Data) {
42
+ do {
43
+ // Attempt to create the document file
44
+ let url = try LocalStorage.createDocumentFile(
45
+ jobId: self.product.jobId ?? generateJobId(),
46
+ fileType: self.product.front ? FileType.documentFront : FileType.documentBack,
47
+ document: data
48
+ )
49
+
50
+
51
+ // Create params dictionary
52
+ var params: [String: Any] = [
53
+ "documentFrontImage": product.front ? url.absoluteString : nil ,
54
+ "documentBackImage": product.front ? nil : url.absoluteString
55
+ ]
56
+
57
+ // Convert params to JSON-compatible dictionary and serialize to JSON
58
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted),
59
+ let jsonString = String(data: jsonData, encoding: .utf8) else {
60
+ // If serialization fails, call the error handler
61
+ product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentCaptureView encoding error")])
62
+ return
63
+ }
64
+
65
+ // Send the result as a JSON string
66
+ product.onResult?(["result": jsonString])
67
+
68
+ } catch {
69
+ // Handle file creation error
70
+ product.onResult?(["error": SmileIDError.unknown("Error creating document file: \(error.localizedDescription)")])
71
+ }
72
+ }
73
+
74
+ func onError(error: Error) {
75
+ product.onResult?(["error": error.localizedDescription])
76
+ }
77
+
78
+ func onSkip() {
79
+ product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentCaptureView skipped")])
80
+ }
81
+ }
82
+
@@ -2,56 +2,59 @@ import Foundation
2
2
  import SmileID
3
3
  import SwiftUI
4
4
 
5
- struct SmileIDDocumentVerificationView: View {
6
- @ObservedObject var product : SmileIDProductModel
7
- var body : some View {
8
- AnyView(NavigationView {
9
- if let countryCode = product.countryCode {
10
- SmileID.documentVerificationScreen(
11
- userId: product.userId ?? generateUserId(),
12
- jobId: product.jobId ?? generateJobId(),
13
- allowNewEnroll: product.allowNewEnroll,
14
- countryCode: countryCode, // already validated in SmileIDDocumentVerificationViewManager
15
- documentType: product.documentType,
16
- idAspectRatio: product.idAspectRatio,
17
- bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
18
- captureBothSides: product.captureBothSides,
19
- allowAgentMode: product.allowAgentMode,
20
- allowGalleryUpload: product.allowGalleryUpload,
21
- showInstructions: product.showInstructions,
22
- showAttribution: product.showAttribution,
23
- extraPartnerParams: product.extraPartnerParams as [String: String],
24
- delegate: self
25
- )
26
- } else {
27
- // This exists for debugging purposes and will show in extreme cases
28
- // when the params were not set NB: setParams in the viewmanager will always
29
- // return an error if the required data is missing
30
- Text("An error has occured")
31
- }
32
- }.navigationViewStyle(StackNavigationViewStyle()))
33
- }
5
+ struct SmileIDDocumentVerificationView: View ,SmileIDFileUtilsProtocol {
6
+ var fileManager: FileManager = Foundation.FileManager.default
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
+ }
34
35
  }
35
36
 
36
37
  extension SmileIDDocumentVerificationView: DocumentVerificationResultDelegate {
37
- func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool) {
38
- var params: [String: Any] = [
39
- "selfieFile": selfie.absoluteString,
40
- "documentFrontFile": documentFrontImage.absoluteString,
41
- "didSubmitDocumentVerificationJob": didSubmitDocumentVerificationJob
42
- ]
43
- if let documentBackImage = documentBackImage {
44
- params["documentBackFile"] = documentBackImage.absoluteString
45
- }
46
-
47
- guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
48
- product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentVerificationView encoding error")])
49
- return
50
- }
51
- product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
38
+ func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool) {
39
+
40
+ var params: [String: Any] = [
41
+ "selfieFile": getFilePath(fileName: selfie.absoluteString),
42
+ "documentFrontFile": getFilePath(fileName: documentFrontImage.absoluteString),
43
+ "didSubmitDocumentVerificationJob": didSubmitDocumentVerificationJob
44
+ ]
45
+
46
+ if let documentBackImage = documentBackImage {
47
+ params["documentBackFile"] = getFilePath(fileName: documentBackImage.absoluteString)
52
48
  }
53
-
54
- func didError(error: Error) {
55
- product.onResult?(["error": error.localizedDescription])
49
+
50
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
51
+ product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentVerificationView encoding error")])
52
+ return
56
53
  }
54
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
55
+ }
56
+
57
+ func didError(error: Error) {
58
+ product.onResult?(["error": error.localizedDescription])
59
+ }
57
60
  }
@@ -2,56 +2,58 @@ import Foundation
2
2
  import SmileID
3
3
  import SwiftUI
4
4
 
5
- struct SmileIDEnhancedDocumentVerificationView: View {
6
- @ObservedObject var product : SmileIDProductModel
7
- var body: some View {
8
- NavigationView {
9
- if let countryCode = product.countryCode {
10
- SmileID.enhancedDocumentVerificationScreen(
11
- userId: product.userId ?? generateUserId(),
12
- jobId: product.jobId ?? generateJobId(),
13
- allowNewEnroll: product.allowNewEnroll,
14
- countryCode: countryCode, // already validated in the view manager
15
- documentType: product.documentType,
16
- idAspectRatio: product.idAspectRatio,
17
- bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
18
- captureBothSides: product.captureBothSides,
19
- allowAgentMode: product.allowAgentMode,
20
- allowGalleryUpload: product.allowGalleryUpload,
21
- showInstructions: product.showInstructions,
22
- showAttribution: product.showAttribution,
23
- extraPartnerParams: product.extraPartnerParams as [String: String],
24
- delegate: self
25
- )
26
- } else {
27
- // This exists for debugging purposes and will show in extreme cases
28
- // when the params were not set NB: setParams in the viewmanager will always
29
- // return an error if the required data is missing
30
- Text("An error has occured")
31
- }
32
- }.navigationViewStyle(StackNavigationViewStyle())
33
- }
5
+ struct SmileIDEnhancedDocumentVerificationView: View,SmileIDFileUtilsProtocol {
6
+ var fileManager: FileManager = Foundation.FileManager.default
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
+ }
34
35
  }
35
36
 
36
37
  extension SmileIDEnhancedDocumentVerificationView: EnhancedDocumentVerificationResultDelegate {
37
- func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitEnhancedDocVJob: Bool) {
38
- var params: [String: Any] = [
39
- "selfieFile": selfie.absoluteString,
40
- "documentFrontFile": documentFrontImage.absoluteString,
41
- "didSubmitEnhancedDocVJob": didSubmitEnhancedDocVJob
42
- ]
43
- if let documentBackImage = documentBackImage {
44
- params["documentBackFile"] = documentBackImage.absoluteString
45
- }
46
-
47
- guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
48
- product.onResult?(["error": SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error")])
49
- return
50
- }
51
- product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
38
+ func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitEnhancedDocVJob: Bool) {
39
+ var params: [String: Any] = [
40
+ "selfieFile": getFilePath(fileName: selfie.absoluteString),
41
+ "documentFrontFile": getFilePath(fileName: documentFrontImage.absoluteString),
42
+ "didSubmitEnhancedDocVJob": didSubmitEnhancedDocVJob
43
+ ]
44
+
45
+ if let documentBackImage = documentBackImage {
46
+ params["documentBackFile"] = getFilePath(fileName: documentBackImage.absoluteString)
52
47
  }
53
-
54
- func didError(error: Error) {
55
- product.onResult?(["error": error.localizedDescription])
48
+
49
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
50
+ product.onResult?(["error": SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error")])
51
+ return
56
52
  }
53
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
54
+ }
55
+
56
+ func didError(error: Error) {
57
+ product.onResult?(["error": error.localizedDescription])
58
+ }
57
59
  }
@@ -2,42 +2,44 @@ import Foundation
2
2
  import SmileID
3
3
  import SwiftUI
4
4
 
5
- struct SmileIDSmartSelfieAuthView: View {
6
- @ObservedObject var product : SmileIDProductModel
7
- var body: some View {
8
- NavigationView {
9
- SmileID.smartSelfieAuthenticationScreen(
10
- userId: product.userId ?? generateUserId(),
11
- jobId: product.jobId ?? generateJobId(),
12
- allowNewEnroll: product.allowNewEnroll,
13
- allowAgentMode: product.allowAgentMode,
14
- showAttribution: product.showAttribution,
15
- showInstructions: product.showInstructions,
16
- extraPartnerParams: product.extraPartnerParams as [String: String],
17
- delegate: self
18
- )
19
- }.navigationViewStyle(StackNavigationViewStyle())
20
- }
5
+ struct SmileIDSmartSelfieAuthView: View,SmileIDFileUtilsProtocol {
6
+ var fileManager: FileManager = Foundation.FileManager.default
7
+ @ObservedObject var product : SmileIDProductModel
8
+ var body: some View {
9
+ NavigationView {
10
+ SmileID.smartSelfieAuthenticationScreen(
11
+ userId: product.userId ?? generateUserId(),
12
+ allowNewEnroll: product.allowNewEnroll,
13
+ allowAgentMode: product.allowAgentMode,
14
+ showAttribution: product.showAttribution,
15
+ showInstructions: product.showInstructions,
16
+ extraPartnerParams: product.extraPartnerParams as [String: String],
17
+ delegate: self
18
+ )
19
+ }.navigationViewStyle(StackNavigationViewStyle())
20
+ }
21
21
  }
22
22
 
23
23
  extension SmileIDSmartSelfieAuthView: SmartSelfieResultDelegate {
24
- func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
25
- var params: [String: Any] = [
26
- "selfieFile": selfieImage.absoluteString,
27
- "livenessFiles": livenessImages,
28
- ]
29
- if let apiResponse = apiResponse {
30
- params["apiResponse"] = apiResponse
31
- }
32
-
33
- guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
34
- product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error")])
35
- return
36
- }
37
- product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
24
+ func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
25
+ var params: [String: Any] = [
26
+ "selfieFile": getFilePath(fileName: selfieImage.absoluteString),
27
+ "livenessFiles": livenessImages.map {
28
+ getFilePath(fileName: $0.absoluteString)
29
+ }
30
+ ]
31
+ if let apiResponse = apiResponse {
32
+ params["apiResponse"] = apiResponse
38
33
  }
39
-
40
- func didError(error: Error) {
41
- product.onResult?(["error": error.localizedDescription])
34
+
35
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
36
+ product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieAuthView encoding error")])
37
+ return
42
38
  }
39
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
40
+ }
41
+
42
+ func didError(error: Error) {
43
+ product.onResult?(["error": error.localizedDescription])
44
+ }
43
45
  }
@@ -0,0 +1,71 @@
1
+ import Foundation
2
+ import SmileID
3
+ import SwiftUI
4
+
5
+
6
+ struct SmileIDSmartSelfieCaptureView: View, SmileIDFileUtilsProtocol {
7
+ var fileManager: FileManager = Foundation.FileManager.default
8
+ @ObservedObject var viewModel: SelfieViewModel
9
+ @ObservedObject var product: SmileIDProductModel
10
+ @State private var acknowledgedInstructions = false
11
+
12
+ var body: some View {
13
+ NavigationView {
14
+ Group {
15
+ if product.showInstructions, !acknowledgedInstructions {
16
+ SmartSelfieInstructionsScreen(showAttribution: product.showAttribution) {
17
+ acknowledgedInstructions = true
18
+ }
19
+ } else if viewModel.processingState != nil {
20
+ Color.clear.onAppear {
21
+ self.viewModel.onFinished(callback: self)
22
+ }
23
+ } else if let selfieToConfirm = viewModel.selfieToConfirm {
24
+ if (self.product.showConfirmation) {
25
+ ImageCaptureConfirmationDialog(
26
+ title: SmileIDResourcesHelper.localizedString(for: "Confirmation.GoodSelfie"),
27
+ subtitle: SmileIDResourcesHelper.localizedString(for: "Confirmation.FaceClear"),
28
+ image: UIImage(data: selfieToConfirm)!,
29
+ confirmationButtonText: SmileIDResourcesHelper.localizedString(for: "Confirmation.YesUse"),
30
+ onConfirm: viewModel.submitJob,
31
+ retakeButtonText: SmileIDResourcesHelper.localizedString(for: "Confirmation.Retake"),
32
+ onRetake: viewModel.onSelfieRejected,
33
+ scaleFactor: 1.25
34
+ ).preferredColorScheme(.light)
35
+ } else {
36
+ Color.clear.onAppear {
37
+ self.viewModel.submitJob()
38
+ }
39
+ }
40
+ } else {
41
+ SelfieCaptureScreen(
42
+ allowAgentMode: self.product.allowAgentMode,
43
+ viewModel: viewModel
44
+ ).preferredColorScheme(.light)
45
+ }
46
+ }
47
+ }
48
+ .navigationViewStyle(StackNavigationViewStyle()).padding()
49
+ }
50
+ }
51
+
52
+ extension SmileIDSmartSelfieCaptureView: SmartSelfieResultDelegate {
53
+ func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
54
+ let params: [String: Any] = [
55
+ "selfieFile": getFilePath(fileName: selfieImage.absoluteString),
56
+ "livenessFiles": livenessImages.map {
57
+ getFilePath(fileName: $0.absoluteString)
58
+ }
59
+ ]
60
+
61
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
62
+ product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieCaptureView encoding error")])
63
+ return
64
+ }
65
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
66
+ }
67
+
68
+ func didError(error: Error) {
69
+ product.onResult?(["error": error.localizedDescription])
70
+ }
71
+ }
@@ -2,42 +2,44 @@ import Foundation
2
2
  import SmileID
3
3
  import SwiftUI
4
4
 
5
- struct SmileIDSmartSelfieEnrollmentView: View {
6
- @ObservedObject var product : SmileIDProductModel
7
- var body: some View {
8
- NavigationView {
9
- SmileID.smartSelfieEnrollmentScreen(
10
- userId: product.userId ?? generateUserId(),
11
- jobId: product.jobId ?? generateJobId(),
12
- allowNewEnroll: product.allowNewEnroll,
13
- allowAgentMode: product.allowAgentMode,
14
- showAttribution: product.showAttribution,
15
- showInstructions: product.showInstructions,
16
- extraPartnerParams: product.extraPartnerParams as [String: String],
17
- delegate: self
18
- )
19
- }.navigationViewStyle(StackNavigationViewStyle())
20
- }
5
+ struct SmileIDSmartSelfieEnrollmentView: View,SmileIDFileUtilsProtocol {
6
+ var fileManager: FileManager = Foundation.FileManager.default
7
+ @ObservedObject var product : SmileIDProductModel
8
+ var body: some View {
9
+ NavigationView {
10
+ SmileID.smartSelfieEnrollmentScreen(
11
+ userId: product.userId ?? generateUserId(),
12
+ allowNewEnroll: product.allowNewEnroll,
13
+ allowAgentMode: product.allowAgentMode,
14
+ showAttribution: product.showAttribution,
15
+ showInstructions: product.showInstructions,
16
+ extraPartnerParams: product.extraPartnerParams as [String: String],
17
+ delegate: self
18
+ )
19
+ }.navigationViewStyle(StackNavigationViewStyle())
20
+ }
21
21
  }
22
22
 
23
23
  extension SmileIDSmartSelfieEnrollmentView: SmartSelfieResultDelegate {
24
- func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
25
- var params: [String: Any] = [
26
- "selfieFile": selfieImage.absoluteString,
27
- "livenessFiles": livenessImages,
28
- ]
29
- if let apiResponse = apiResponse {
30
- params["apiResponse"] = apiResponse
31
- }
32
-
33
- guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
34
- product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error")])
35
- return
36
- }
37
- product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
24
+ func didSucceed(selfieImage: URL, livenessImages: [URL], apiResponse: SmartSelfieResponse?) {
25
+ var params: [String: Any] = [
26
+ "selfieFile": getFilePath(fileName: selfieImage.absoluteString),
27
+ "livenessFiles": livenessImages.map {
28
+ getFilePath(fileName: $0.absoluteString)
29
+ },
30
+ ]
31
+ if let apiResponse = apiResponse {
32
+ params["apiResponse"] = apiResponse
38
33
  }
39
-
40
- func didError(error: Error) {
41
- product.onResult?(["error": error.localizedDescription])
34
+
35
+ guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
36
+ product.onResult?(["error": SmileIDError.unknown("SmileIDSmartSelfieEnrollmentView encoding error")])
37
+ return
42
38
  }
39
+ product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
40
+ }
41
+
42
+ func didError(error: Error) {
43
+ product.onResult?(["error": error.localizedDescription])
44
+ }
43
45
  }
@@ -0,0 +1,7 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTViewManager.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(SmileIDDocumentCaptureViewManager, RCTViewManager)
5
+ RCT_EXTERN_METHOD(setParams:(nonnull NSNumber *)node params:(NSDictionary *)params)
6
+ RCT_EXPORT_VIEW_PROPERTY(onResult, RCTBubblingEventBlock);
7
+ @end
@@ -0,0 +1,29 @@
1
+ import Foundation
2
+ import React
3
+ import SwiftUI
4
+
5
+ @objc(SmileIDDocumentCaptureViewManager)
6
+ class SmileIDDocumentCaptureViewManager: SmileIDBaseViewManager {
7
+ override func getView() -> UIView {
8
+ BaseSmileIDView(frame: .zero, contentView: AnyView(SmileIDDocumentCaptureView(product: self.product)), product: self.product)
9
+ }
10
+
11
+ @objc func setParams(_ node: NSNumber, params: NSDictionary) {
12
+ /* 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
13
+ */
14
+ DispatchQueue.main.async {
15
+ if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
16
+ self.product.extraPartnerParams = params["extraPartnerParams"] as? [String: String] ?? [:]
17
+ self.product.userId = params["userId"] as? String
18
+ self.product.jobId = params["jobId"] as? String
19
+ self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
20
+ self.product.front = params["isDocumentFrontSide"] as? Bool ?? true
21
+ self.product.showAttribution = params["showAttribution"] as? Bool ?? true
22
+ self.product.showInstructions = params["showInstructions"] as? Bool ?? true
23
+ self.product.showConfirmation = params["showConfirmation"] as? Bool ?? true
24
+ self.product.allowGalleryUpload = params["allowGalleryUpload"] as? Bool ?? false
25
+ self.product.onResult = params["onResult"] as? RCTBubblingEventBlock
26
+ }
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,7 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTViewManager.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(SmileIDSmartSelfieCaptureViewManager, RCTViewManager)
5
+ RCT_EXTERN_METHOD(setParams:(nonnull NSNumber *)node params:(NSDictionary *)params)
6
+ RCT_EXPORT_VIEW_PROPERTY(onResult, RCTBubblingEventBlock);
7
+ @end
@@ -0,0 +1,36 @@
1
+ import Foundation
2
+ import React
3
+ import SwiftUI
4
+ import SmileID
5
+
6
+ @objc(SmileIDSmartSelfieCaptureViewManager)
7
+ class SmileIDSmartSelfieCaptureViewManager: SmileIDBaseViewManager {
8
+ override func getView() -> UIView {
9
+ BaseSmileIDView(frame: .zero, contentView: AnyView(
10
+ SmileIDSmartSelfieCaptureView(
11
+ viewModel: SelfieViewModel(isEnroll: false,
12
+ userId: self.product.userId ?? generateUserId(),
13
+ jobId: self.product.jobId ?? generateJobId(),
14
+ allowNewEnroll: false,
15
+ skipApiSubmission: true,
16
+ extraPartnerParams: [:],
17
+ localMetadata: LocalMetadata()), product: self.product)),
18
+ product: self.product)
19
+ }
20
+
21
+ @objc func setParams(_ node: NSNumber, params: NSDictionary) {
22
+ /* 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
23
+ */
24
+ DispatchQueue.main.async {
25
+ if let component = self.bridge.uiManager.view(forReactTag: node) as? BaseSmileIDView {
26
+ self.product.allowAgentMode = params["allowAgentMode"] as? Bool ?? false
27
+ self.product.userId = params["userId"] as? String
28
+ self.product.jobId = params["jobId"] as? String
29
+ self.product.showConfirmation = params["showConfirmation"] as? Bool ?? true
30
+ self.product.showInstructions = params["showInstructions"] as? Bool ?? true
31
+ self.product.showAttribution = params["showAttribution"] as? Bool ?? true
32
+ self.product.onResult = params["onResult"] as? RCTBubblingEventBlock
33
+ }
34
+ }
35
+ }
36
+ }
@@ -16,6 +16,8 @@ class SmileIDProductModel: ObservableObject {
16
16
  @Published var partnerPrivacyPolicy: String?
17
17
  @Published var allowAgentMode: Bool = false
18
18
  @Published var allowNewEnroll: Bool = false
19
+ @Published var front: Bool = true
20
+ @Published var showConfirmation: Bool = true
19
21
  @Published var showAttribution: Bool = true
20
22
  @Published var showInstructions: Bool = true
21
23
  @Published var extraPartnerParams: [String: String] = [:]