@socure-inc/docv-react-native 3.2.0 → 4.0.0-alpha.1

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 CHANGED
@@ -13,12 +13,12 @@ The Predictive Document Verification (DocV) SDK v3 for React Native is a React N
13
13
  **iOS**
14
14
 
15
15
  - Support for iOS 13 and later
16
- - Xcode version 13+
16
+ - Xcode version 14.1+
17
17
 
18
18
  **Android**
19
19
 
20
20
  - Android SDK Version 22 (OS Version 5.1) and later
21
- - Android SDK is compiled with `compileSdkVersion` 32 and Java 11
21
+ - Android SDK is compiled with `compileSdkVersion` 33 and Java 11
22
22
 
23
23
  ## Getting started
24
24
 
@@ -150,7 +150,7 @@ Using the command line, go to your root project folder and enter the following c
150
150
 
151
151
  ### Configure your Android app
152
152
 
153
- For the Android app, add your project dependencies by going to the module level `build.gradle` file and making sure the `minSdkVersion` is set to at least 22 and the `compileSdkVersion` is set to at least 32.
153
+ For the Android app, add your project dependencies by going to the module level `build.gradle` file and making sure the `minSdkVersion` is set to at least 22 and the `compileSdkVersion` is set to at least 33.
154
154
 
155
155
  ```kotlin {5,6}
156
156
  buildscript {
@@ -158,7 +158,7 @@ buildscript {
158
158
  ext {
159
159
  ....
160
160
  minSdkVersion = 22
161
- compileSdkVersion = 32
161
+ compileSdkVersion = 33
162
162
  .....
163
163
  }
164
164
  }
@@ -134,7 +134,7 @@ dependencies {
134
134
  //noinspection GradleDynamicVersion
135
135
  implementation "com.facebook.react:react-native:+"
136
136
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
137
- implementation "com.github.socure-inc:socure-docv:3.2.0"
137
+ implementation "com.github.socure-inc:socure-docv:4.0.0"
138
138
  // From node_modules
139
139
  }
140
140
 
@@ -9,6 +9,8 @@ import com.socure.docv.capturesdk.api.Platform.REACT_NATIVE
9
9
  import com.socure.docv.capturesdk.api.SocureDocVHelper.getIntent
10
10
  import com.socure.docv.capturesdk.api.SocureDocVHelper.getResult
11
11
  import com.socure.docv.capturesdk.api.SocureDocVHelper.setSource
12
+ import com.socure.docv.capturesdk.api.SocureDocVHelper.initSdk
13
+ import com.socure.docv.capturesdk.api.SocureExperimentalApi
12
14
  import com.socure.docv.capturesdk.common.utils.ResultListener
13
15
  import com.socure.docv.capturesdk.common.utils.ScanError
14
16
  import com.socure.docv.capturesdk.common.utils.ScannedData
@@ -28,6 +30,23 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
28
30
  return "SocureDocVReactNative"
29
31
  }
30
32
 
33
+ @OptIn(SocureExperimentalApi::class)
34
+ @ReactMethod
35
+ fun initDocVSdk(socureApiKey: String, flow: String?) {
36
+ Log.d(TAG, "initDocVSdk - init native sdk")
37
+
38
+ initSdk(currentActivity!!, socureApiKey, flow)
39
+ }
40
+
41
+ @OptIn(SocureExperimentalApi::class)
42
+ @ReactMethod
43
+ fun launchDocVSdk(onSuccess: Callback,onError: Callback) {
44
+ Log.d(TAG, "launchDocVSdk - launch using experimental api")
45
+
46
+ setupLaunch(onSuccess, onError)
47
+ currentActivity?.startActivityForResult(getIntent(currentActivity!!), SOCURE_SDK_REQUEST_CODE)
48
+ }
49
+
31
50
  @ReactMethod
32
51
  fun launchSocureDocV(
33
52
  socureApiKey: String,
@@ -35,6 +54,16 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
35
54
  onSuccess: Callback,
36
55
  onError: Callback
37
56
  ) {
57
+ Log.d(TAG, "launchSocureDocV - launch Socure SDK")
58
+
59
+ setupLaunch(onSuccess, onError)
60
+ currentActivity?.startActivityForResult(
61
+ getIntent(currentActivity!!, socureApiKey, flow),
62
+ SOCURE_SDK_REQUEST_CODE
63
+ )
64
+ }
65
+
66
+ private fun setupLaunch(onSuccess: Callback, onError: Callback) {
38
67
  this.onSuccessCallback = onSuccess
39
68
  this.onErrorCallback = onError
40
69
 
@@ -43,10 +72,6 @@ class SocureDocVReactNativeModule(reactContext: ReactApplicationContext) :
43
72
  reactApplicationContext.addActivityEventListener(this)
44
73
 
45
74
  setSource(REACT_NATIVE)
46
- currentActivity?.startActivityForResult(
47
- getIntent(currentActivity!!, socureApiKey, flow),
48
- SOCURE_SDK_REQUEST_CODE
49
- )
50
75
  }
51
76
 
52
77
  override fun onActivityResult(
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export declare function launchSocureDocV(socureApiKey: string, flow: string | null | undefined, onSuccess: Function, onError: Function): any;
2
+ export declare function initDocVSdk(socureApiKey: string, flow: string | null | undefined): void;
3
+ export declare function launchDocVSdk(onSuccess: Function, onError: Function): any;
2
4
  export interface ScannedData {
3
5
  docUUID: string;
4
6
  sessionId: string;
@@ -5,6 +5,9 @@
5
5
  RCT_EXTERN_METHOD(launchSocureDocV:(NSString)socureApiKey flow:(NSString)flow
6
6
  onSuccess:(RCTResponseSenderBlock)success
7
7
  onError:(RCTResponseSenderBlock)error)
8
+ RCT_EXTERN_METHOD(initDocVSdk:(NSString)socureApiKey flow:(NSString)flow)
9
+ RCT_EXTERN_METHOD(launchDocVSdk:(RCTResponseSenderBlock)success
10
+ onError:(RCTResponseSenderBlock)error)
8
11
 
9
12
  + (BOOL)requiresMainQueueSetup
10
13
  {
@@ -2,35 +2,59 @@ import SocureDocV
2
2
 
3
3
  @objc(SocureDocVReactNative)
4
4
  class SocureDocVReactNative: NSObject {
5
- let objDocVHelper = SocureDocVHelper()
6
- @objc(launchSocureDocV:flow:onSuccess:onError:)
7
- func launchSocureDocV(socureApiKey: String, flow: String?, onSuccess: @escaping RCTResponseSenderBlock,onError: @escaping RCTResponseSenderBlock) -> Void {
8
- var flowConfig: [String: Any]?
9
- do {
10
- flowConfig = try flow?.convertToDictionary()
11
- } catch {
12
- let errorDict = ["errorMessage": "Invalid config data", "statusCode": "7109"]
13
- onError([errorDict])
14
- return
15
- }
16
- objDocVHelper.setSource(.reactNative)
17
- DispatchQueue.main.async {
18
- let root = RCTPresentedViewController()
19
- self.objDocVHelper.launch(socureApiKey, presentingViewController: root!, config: flowConfig, completionBlock: { result in
20
- switch result {
21
- case .success(let scan):
22
- onSuccess([scan.dictionary])
23
- break
24
- case .failure(let error):
25
- onError([error.dictionary])
26
- break
27
- }
28
- })
29
- }
30
- }
5
+ lazy var objDocVHelper = SocureDocVHelper()
6
+
7
+ @objc(launchSocureDocV:flow:onSuccess:onError:)
8
+ func launchSocureDocV(socureApiKey: String, flow: String?, onSuccess: @escaping RCTResponseSenderBlock,onError: @escaping RCTResponseSenderBlock) -> Void {
9
+ var flowConfig: [String: Any]?
10
+ do {
11
+ flowConfig = try flow?.convertToDictionary()
12
+ } catch {
13
+ let errorDict = ["errorMessage": "Invalid config data", "statusCode": "7109"]
14
+ onError([errorDict])
15
+ return
16
+ }
17
+ objDocVHelper.setSource(.reactNative)
18
+ DispatchQueue.main.async {
19
+ let root = RCTPresentedViewController()
20
+ self.objDocVHelper.launch(socureApiKey, presentingViewController: root!, config: flowConfig, completionBlock: { result in
21
+ switch result {
22
+ case .success(let scan):
23
+ onSuccess([scan.dictionary])
24
+ break
25
+ case .failure(let error):
26
+ onError([error.dictionary])
27
+ break
28
+ }
29
+ })
30
+ }
31
+ }
32
+
33
+ @objc(initDocVSdk:flow:)
34
+ func initDocVSdk(socureApiKey: String, flow: String?) -> Void {
35
+ SocureDocVSdk.initSdk(publicKey: socureApiKey, config: try? flow?.convertToDictionary())
36
+ }
37
+
38
+ @objc(launchDocVSdk:onError:)
39
+ func launchDocVSdk(onSuccess: @escaping RCTResponseSenderBlock,onError: @escaping RCTResponseSenderBlock) -> Void {
40
+ SocureDocVSdk.setSource(.reactNative)
41
+ DispatchQueue.main.async {
42
+ let root = RCTPresentedViewController()
43
+ SocureDocVSdk.launch(presentingViewController: root!, completionBlock: { result in
44
+ switch result {
45
+ case .success(let scan):
46
+ onSuccess([scan.dictionary])
47
+ break
48
+ case .failure(let error):
49
+ onError([error.dictionary])
50
+ break
51
+ }
52
+ })
53
+ }
54
+ }
31
55
 
32
56
  @objc static func requiresMainQueueSetup() -> Bool {
33
- return false
57
+ return false
34
58
  }
35
59
  }
36
60
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@socure-inc/docv-react-native",
3
- "version": "3.2.0",
4
- "description": "The Predictive Document Verification (DocV) SDK React Native bridge allows you to use the DocV SDK v3 for Android and iOS in your React Native application.",
3
+ "version": "4.0.0-alpha.1",
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": "src/index",
6
6
  "types": "dist/index.d.ts",
7
7
  "keywords": [
@@ -37,4 +37,4 @@
37
37
  "prepack": "tsc -p tsconfig.json",
38
38
  "test": "echo \"Error: no test specified\" && exit 1"
39
39
  }
40
- }
40
+ }
@@ -18,6 +18,6 @@ Pod::Spec.new do |s|
18
18
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
19
 
20
20
  s.dependency "React"
21
- s.dependency "SocureDocV", "3.2.0"
21
+ s.dependency "SocureDocV", "4.0.1"
22
22
 
23
23
  end
package/src/index.tsx CHANGED
@@ -23,6 +23,39 @@ export function launchSocureDocV(socureApiKey: string, flow: string | null | und
23
23
  }
24
24
  }
25
25
 
26
+ {/*
27
+ This API is experimental.
28
+ Please contact Socure before starting to use this.
29
+ */}
30
+ export function initDocVSdk(socureApiKey: string, flow: string | null | undefined) {
31
+ if (socureApiKey && typeof socureApiKey === "string") {
32
+ if ((!flow && flow !== "") || (typeof flow === "string" && isValidJSON(flow))) {
33
+ SocureDocVReactNative.initDocVSdk(socureApiKey, flow);
34
+ } else {
35
+ onConfigError("7109", "Invalid config data")
36
+ }
37
+ } else {
38
+ onConfigError("7011", "Invalid key")
39
+ }
40
+ }
41
+
42
+ {/*
43
+ This API is experimental.
44
+ Please contact Socure before starting to use this.
45
+ */}
46
+ export function launchDocVSdk(onSuccess: Function, onError: Function) {
47
+ return SocureDocVReactNative.launchDocVSdk(onSuccess, onError);
48
+ }
49
+
50
+ function isValidJSON(jsonString: string) {
51
+ try {
52
+ JSON.parse(jsonString);
53
+ return true;
54
+ } catch (e) {
55
+ return false;
56
+ }
57
+ };
58
+
26
59
  function onConfigError(errorCode: string, errorMessage: string, onError?: Function) {
27
60
  let error = { statusCode: errorCode, errorMessage: errorMessage } as ScanError
28
61
  if (onError && typeof onError == 'function') {