@socure-inc/docv-react-native 5.0.8 → 5.1.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.
@@ -136,7 +136,7 @@ dependencies {
136
136
  //noinspection GradleDynamicVersion
137
137
  implementation "com.facebook.react:react-native:+"
138
138
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
139
- implementation "com.socure.android:docv-capture:5.2.3"
139
+ implementation "com.socure.android:docv-capture:5.2.8"
140
140
 
141
141
  def retrofit_version = "2.9.0"
142
142
  implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
@@ -6,9 +6,5 @@ RCT_EXTERN_METHOD(launchSocureDocV:(NSString)docVTransactionToken socureApiKey:(
6
6
  onSuccess:(RCTResponseSenderBlock)success
7
7
  onError:(RCTResponseSenderBlock)error)
8
8
 
9
- + (BOOL)requiresMainQueueSetup
10
- {
11
- return NO;
12
- }
13
9
 
14
10
  @end
@@ -1,85 +1,75 @@
1
1
  import SocureDocV
2
2
 
3
- @objc(SocureDocVReactNative)
4
- class SocureDocVReactNative: NSObject {
5
-
6
- @objc(launchSocureDocV:socureApiKey:useSocureGov:onSuccess:onError:)
7
- func launchSocureDocV(docVTransactionToken: String,
8
- socureApiKey: String,
9
- useSocureGov: Bool,
10
- onSuccess: @escaping RCTResponseSenderBlock,
11
- onError: @escaping RCTResponseSenderBlock) -> Void {
12
-
13
- DispatchQueue.main.async {
14
- guard let root = RCTPresentedViewController() else {
15
- onError([["error": "Failed to get the root view controller"]])
16
- return
17
- }
18
- let options = SocureDocVOptions(
19
- publicKey: socureApiKey,
20
- docvTransactionToken: docVTransactionToken,
21
- presentingViewController: root,
22
- useSocureGov: useSocureGov
23
- )
24
-
25
- SocureDocVSDK.launch(options) { result in
26
- switch result {
27
- case .success(let success):
28
- onSuccess([["deviceSessionToken": success.deviceSessionToken]])
29
- case .failure(let failure):
30
- let errorMessage = self.getErrorMessage(from: failure.error)
31
- onError([["error": errorMessage,
32
- "deviceSessionToken": failure.deviceSessionToken]])
33
- }
34
- }
35
- }
36
- }
37
-
38
- @objc static func requiresMainQueueSetup() -> Bool {
39
- return false
40
- }
41
-
42
- func getErrorMessage(from error: SocureDocVError) -> String {
43
- switch error {
44
- case .noInternetConnection:
45
- return "No internet connection"
46
- case .sessionInitiationFailure:
47
- return "Failed to initiate the session"
48
- case .cameraPermissionDeclined:
49
- return "Permissions to open the camera declined by the user"
50
- case .consentDeclined:
51
- return "Consent declined by the user"
52
- case .documentUploadFailure:
53
- return "Failed to upload the documents"
54
- case .invalidDocvTransactionToken:
55
- return "Invalid transaction token"
56
- case .invalidPublicKey:
57
- return "Invalid or missing SDK key"
58
- case .sessionExpired:
59
- return "Session expired"
60
- case .userCanceled:
61
- return "Scan canceled by the user"
62
- case .unknown:
63
- fallthrough
64
- @unknown default:
65
- return "Unknown error"
66
- }
67
- }
68
- }
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
3
+ @objc(SocureDocVReactNative)
4
+ class SocureDocVReactNative: NSObject, RCTBridgeModule {
5
+
6
+ @objc(launchSocureDocV:socureApiKey:useSocureGov:onSuccess:onError:)
7
+ func launchSocureDocV(docVTransactionToken: String,
8
+ socureApiKey: String,
9
+ useSocureGov: Bool,
10
+ onSuccess: @escaping RCTResponseSenderBlock,
11
+ onError: @escaping RCTResponseSenderBlock) -> Void {
12
+
13
+ DispatchQueue.main.async {
14
+ guard let root = RCTPresentedViewController() else {
15
+ onError([["error": "Failed to get the root view controller"]])
16
+ return
17
+ }
18
+
19
+ let options = SocureDocVOptions(
20
+ publicKey: socureApiKey,
21
+ docvTransactionToken: docVTransactionToken,
22
+ presentingViewController: root,
23
+ useSocureGov: useSocureGov
24
+ )
25
+
26
+ SocureDocVSDK.launch(options) { result in
27
+ DispatchQueue.main.async {
28
+ switch result {
29
+ case .success(let success):
30
+ onSuccess([["deviceSessionToken": success.deviceSessionToken]])
31
+ case .failure(let failure):
32
+ let errorMessage = self.getErrorMessage(from: failure.error)
33
+ onError([["error": errorMessage,
34
+ "deviceSessionToken": failure.deviceSessionToken]])
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ static func requiresMainQueueSetup() -> Bool {
42
+ return true
43
+ }
44
+
45
+ static func moduleName() -> String! {
46
+ return "SocureDocVReactNative"
47
+ }
48
+
49
+ func getErrorMessage(from error: SocureDocVError) -> String {
50
+ switch error {
51
+ case .noInternetConnection:
52
+ return "No internet connection"
53
+ case .sessionInitiationFailure:
54
+ return "Failed to initiate the session"
55
+ case .cameraPermissionDeclined:
56
+ return "Permissions to open the camera declined by the user"
57
+ case .consentDeclined:
58
+ return "Consent declined by the user"
59
+ case .documentUploadFailure:
60
+ return "Failed to upload the documents"
61
+ case .invalidDocvTransactionToken:
62
+ return "Invalid transaction token"
63
+ case .invalidPublicKey:
64
+ return "Invalid or missing SDK key"
65
+ case .sessionExpired:
66
+ return "Session expired"
67
+ case .userCanceled:
68
+ return "Scan canceled by the user"
69
+ case .unknown:
70
+ fallthrough
71
+ @unknown default:
72
+ return "Unknown error"
73
+ }
74
+ }
75
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socure-inc/docv-react-native",
3
- "version": "5.0.8",
3
+ "version": "5.1.0",
4
4
  "description": "The Predictive Document Verification (DocV) SDK React Native bridge allows you to use the DocV SDK v4 for Android and iOS in your React Native application.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",