react-native-hyperkyc-sdk 0.3.1 → 0.3.4-alpha02

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.
@@ -57,7 +57,7 @@ dependencies {
57
57
  //noinspection GradleDynamicVersion
58
58
  implementation "com.facebook.react:react-native:+" // From node_modules
59
59
  implementation("com.google.code.gson:gson:2.8.6")
60
- implementation('co.hyperverge:hyperkyc:0.2.0@aar', {
60
+ implementation('co.hyperverge:hyperkyc:0.2.2@aar', {
61
61
  transitive = true
62
62
  })
63
63
 
@@ -3,6 +3,7 @@ package com.reactnativehyperkycsdk;
3
3
 
4
4
  import android.app.Activity;
5
5
  import android.content.Intent;
6
+ import android.util.Log;
6
7
 
7
8
 
8
9
 
@@ -22,7 +23,10 @@ import com.google.gson.Gson;
22
23
 
23
24
 
24
25
  import java.util.ArrayList;
26
+ import java.util.HashMap;
25
27
  import java.util.List;
28
+ import java.util.Map;
29
+
26
30
  import org.json.JSONArray;
27
31
  import org.json.JSONException;
28
32
  import org.json.JSONObject;
@@ -30,9 +34,11 @@ import org.json.JSONObject;
30
34
  import co.hyperverge.hyperkyc.HyperKyc;
31
35
  import co.hyperverge.hyperkyc.data.models.DocFlowConfig;
32
36
  import co.hyperverge.hyperkyc.data.models.HyperKycConfig;
33
- import co.hyperverge.hyperkyc.data.models.HyperKycData;
37
+
34
38
  import co.hyperverge.hyperkyc.data.models.HyperKycFlow;
35
- import co.hyperverge.hyperkyc.data.models.HyperKycResult;
39
+
40
+ import co.hyperverge.hyperkyc.data.models.result.HyperKycData;
41
+ import co.hyperverge.hyperkyc.data.models.result.HyperKycResult;
36
42
  import androidx.annotation.NonNull;
37
43
 
38
44
 
@@ -74,6 +80,7 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
74
80
  String appKey = kycConfig.hasKey("appKey") ? kycConfig.getString("appKey") : null;
75
81
  String transactionId = kycConfig.hasKey("transactionId") ? kycConfig.getString("transactionId") : null;
76
82
  String accessToken = kycConfig.hasKey("accessToken")? kycConfig.getString("accessToken") : null;
83
+ ReadableMap inputsMap = kycConfig.hasKey("inputs")?kycConfig.getMap("inputs"): null;
77
84
 
78
85
  HyperKycConfig config = null;
79
86
  if(accessToken != null){
@@ -82,6 +89,10 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
82
89
 
83
90
  config = new HyperKycConfig(appId, appKey, workflowId, transactionId);
84
91
  }
92
+ if(inputsMap != null){
93
+ config.setInputs(processInputsArray(inputsMap));
94
+ }
95
+
85
96
  contract = new HyperKyc.Contract();
86
97
  Intent newIntent = contract.createIntent(currentActivity, config);
87
98
  if(currentActivity != null)
@@ -108,6 +119,7 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
108
119
  WritableMap resultMap = new WritableNativeMap();
109
120
  resultMap.putString("status", hyperKycResult.getStatus().toString());
110
121
  resultMap.putString("reason", hyperKycResult.getReason());
122
+ resultMap.putString("applicationStatus", hyperKycResult.getApplicationStatus());
111
123
  try {
112
124
  if (hyperKycData != null) {
113
125
 
@@ -133,6 +145,21 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
133
145
 
134
146
 
135
147
 
148
+ private Map<String, String> processInputsArray(ReadableMap inputs){
149
+ Map<String, String> inputsMap = new HashMap<>();
150
+
151
+ ReadableMapKeySetIterator iterator = inputs.keySetIterator();
152
+ while(iterator.hasNextKey()){
153
+ String key = iterator.nextKey();
154
+ String value = inputs.getString(key);
155
+ Log.e("TAG", key + "---" + value);
156
+ inputsMap.put(key, value);
157
+ }
158
+
159
+ return inputsMap;
160
+
161
+ }
162
+
136
163
  @Override
137
164
  public void onNewIntent(Intent intent) {
138
165
 
@@ -10,8 +10,11 @@ import org.json.JSONException;
10
10
  import org.json.JSONObject;
11
11
 
12
12
  import java.util.Iterator;
13
+ import java.util.Arrays;
13
14
 
14
15
  public class HyperkycSdkUtils {
16
+ static String[] skipVariables = new String[]{"variables"};
17
+
15
18
  public static WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONException {
16
19
  WritableArray array = new WritableNativeArray();
17
20
 
@@ -43,6 +46,7 @@ public class HyperkycSdkUtils {
43
46
  while (iterator.hasNext()) {
44
47
  String key = iterator.next();
45
48
  Object value = jsonObject.get(key);
49
+ if(!Arrays.asList(skipVariables).contains(key)){
46
50
  if (value instanceof JSONObject) {
47
51
  map.putMap(key, convertJsonToMap((JSONObject) value));
48
52
  } else if (value instanceof JSONArray) {
@@ -58,6 +62,7 @@ public class HyperkycSdkUtils {
58
62
  } else {
59
63
  map.putString(key, value.toString());
60
64
  }
65
+ }
61
66
  }
62
67
  return map;
63
68
  }
@@ -15,6 +15,7 @@ class Hyperkyc: NSObject {
15
15
  let appKey = _config["appKey"] as? String
16
16
  let accessToken = _config["accessToken"] as? String
17
17
  let workflowId = _config["workflowId"] as? String
18
+ let inputs = _config["inputs"] as? [String: String]
18
19
 
19
20
 
20
21
  DispatchQueue.main.async {
@@ -22,6 +23,9 @@ class Hyperkyc: NSObject {
22
23
 
23
24
  if let accessTokenConfig = accessToken{
24
25
  let hyperKYCConfig = HyperKycConfig(accessToken: accessTokenConfig, workflowId: workflowId!, transactionId: transactionId!)
26
+ if let inputs = inputs{
27
+ hyperKYCConfig.setInputs(inputs: inputs)
28
+ }
25
29
  HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
26
30
 
27
31
  }
@@ -29,7 +33,11 @@ class Hyperkyc: NSObject {
29
33
 
30
34
  if(appKey != nil && appId != nil){
31
35
  let hyperKYCConfig = HyperKycConfig(appId: appId!, appKey: appKey!, workflowId: workflowId!, transactionId: transactionId!)
32
-
36
+ if let inputs = inputs{
37
+ print(inputs)
38
+ hyperKYCConfig.setInputs(inputs: inputs)
39
+ }
40
+
33
41
  HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
34
42
 
35
43
  let result = self.processHyperKycResult(hyperKycResult: hyperKycResult)
@@ -47,6 +55,7 @@ class Hyperkyc: NSObject {
47
55
  var resultEnumString = ""
48
56
  var kycData = [:] as [String: Any]
49
57
  var errorMessage = ""
58
+ var applicationStatus = ""
50
59
 
51
60
  resultEnumString = String(describing: resultEnum)
52
61
 
@@ -58,7 +67,7 @@ class Hyperkyc: NSObject {
58
67
  "id": countryResult.id,
59
68
  "name": countryResult.name,
60
69
  "region": countryResult.region,
61
- "moduleId": countryResult.moduleId,
70
+ "tag": countryResult.moduleId,
62
71
  "baseUrl": countryResult.baseUrl
63
72
 
64
73
  ] as [String: Any]
@@ -75,7 +84,7 @@ class Hyperkyc: NSObject {
75
84
  }
76
85
  var docResultDictionary = [
77
86
  "documentId": docResult.documentId,
78
- "moduleId":docResult.moduleId,
87
+ "tag":docResult.moduleId,
79
88
  "docDataList": docDataList
80
89
  ] as [String : Any]
81
90
 
@@ -87,7 +96,7 @@ class Hyperkyc: NSObject {
87
96
  //
88
97
  // Process face data
89
98
  if let faceResult = hyperKycData.faceResult {
90
- var faceResultDictionary = ["moduleId": faceResult.moduleId] as [String:Any]
99
+ var faceResultDictionary = ["tag": faceResult.moduleId] as [String:Any]
91
100
  faceResultDictionary["faceData"] = processDictionary(inputDictionary: faceResult.faceData.asDictionary)
92
101
  kycData["faceResult"] = faceResultDictionary
93
102
  }
@@ -98,7 +107,7 @@ class Hyperkyc: NSObject {
98
107
  var apiResultList : [[String: Any]] = []
99
108
  for apiResult in hyperKycData.apiResultList{
100
109
  var apiResultDictionary = [
101
- "moduleId" : apiResult.moduleId
110
+ "tag" : apiResult.moduleId
102
111
  ] as [String : Any]
103
112
  apiResultDictionary["apiData"] = processDictionary(inputDictionary: apiResult.apiData.asDictionary)
104
113
  apiResultList.append(apiResultDictionary)
@@ -114,18 +123,18 @@ class Hyperkyc: NSObject {
114
123
 
115
124
  for formViewResult in hyperKycData.formResultList{
116
125
  var formViewResultDictionary = [
117
- "moduleId" : formViewResult.moduleId
126
+ "tag" : formViewResult.moduleId
118
127
  ] as [String : Any]
119
128
  formViewResultList.append(formViewResultDictionary)
120
129
  }
121
130
 
122
- kycData["formViewResultList"] = formViewResultList
131
+ kycData["formResultList"] = formViewResultList
123
132
 
124
133
  //Process webview data
125
134
  var webViewResultList : [[String: Any]] = []
126
135
  for webViewResult in hyperKycData.webviewResultList{
127
136
  var webViewResultDictionary = [
128
- "moduleId" : webViewResult.moduleId
137
+ "tag" : webViewResult.moduleId
129
138
  ] as [String : Any]
130
139
 
131
140
  webViewResultDictionary["webViewData"] = processDictionary(inputDictionary: webViewResult.webviewData.asDictionary)
@@ -140,10 +149,15 @@ class Hyperkyc: NSObject {
140
149
  if let errorMsg = hyperKycResult.reason {
141
150
  errorMessage = errorMsg
142
151
  }
152
+ if let applStatus = hyperKycResult.applicationStatus {
153
+ applicationStatus = applStatus
154
+ }
155
+
143
156
 
144
157
  let resultMap = [
145
158
  "status" : resultEnumString,
146
159
  "reason" : errorMessage,
160
+ "applicationStatus":applicationStatus,
147
161
  "hyperKycData" : kycData
148
162
 
149
163
  ] as [String : Any]
@@ -164,7 +178,7 @@ class Hyperkyc: NSObject {
164
178
  if(!skipKeysArray.contains(key) ){
165
179
  var keyName = key
166
180
  if(key == "responseResultRaw"){
167
- keyName = "responseResult"
181
+ keyName = "responseBody"
168
182
  }
169
183
  resultDictionary[keyName] = value
170
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hyperkyc-sdk",
3
- "version": "0.3.1",
3
+ "version": "0.3.4-alpha02",
4
4
  "description": "React Native wrapper for HyperKYC SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",