react-native-hyperkyc-sdk 0.2.0-alpha1 → 0.3.0-alpha1

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
@@ -19,7 +19,7 @@ const { Hyperkyc } = NativeModules
19
19
  var configDictionary = {};
20
20
  configDictionary["appId"] = appID
21
21
  configDictionary["appKey"] = appKey
22
- configDictionary["defaultCountryId"] = ""
22
+ configDictionary["defaultCountryId"] = "ind"
23
23
 
24
24
  configDictionary["transactionId"] = transactionId
25
25
  configDictionary["workflow"] = JSON.stringify([ {
package/android/.DS_Store CHANGED
Binary file
@@ -56,9 +56,10 @@ repositories {
56
56
  dependencies {
57
57
  //noinspection GradleDynamicVersion
58
58
  implementation "com.facebook.react:react-native:+" // From node_modules
59
-
60
- implementation('co.hyperverge:hyperkyc:0.0.2-alpha02@aar', {
59
+ implementation("com.google.code.gson:gson:2.8.6")
60
+ implementation('co.hyperverge:hyperkyc:0.2.0@aar', {
61
61
  transitive = true
62
62
  })
63
+
63
64
  }
64
65
 
Binary file
Binary file
Binary file
Binary file
@@ -65,20 +65,22 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
65
65
  public void launch(ReadableMap kycConfig, Callback resultCallback ){
66
66
  callback = resultCallback;
67
67
 
68
+
69
+
70
+
68
71
  ReactActivity currentActivity = (ReactActivity)getCurrentActivity();
69
- List<HyperKycFlow> workflow = processWorkFlow(kycConfig.getString("workflow"));
72
+ String workflowId = kycConfig.getString("workflowId");
70
73
  String appId = kycConfig.hasKey("appId") ? kycConfig.getString("appId") : null;
71
74
  String appKey = kycConfig.hasKey("appKey") ? kycConfig.getString("appKey") : null;
72
75
  String transactionId = kycConfig.hasKey("transactionId") ? kycConfig.getString("transactionId") : null;
73
- String defaultCountryId = kycConfig.hasKey("defaultCountryId") ? kycConfig.getString("defaultCountryId"): null;
74
76
  String accessToken = kycConfig.hasKey("accessToken")? kycConfig.getString("accessToken") : null;
75
77
 
76
78
  HyperKycConfig config = null;
77
79
  if(accessToken != null){
78
- config = new HyperKycConfig(accessToken, workflow, transactionId, defaultCountryId );
80
+ config = new HyperKycConfig(accessToken, workflowId, transactionId);
79
81
  }else if(appId != null && appKey != null) {
80
82
 
81
- config = new HyperKycConfig(appId, appKey, workflow, transactionId, defaultCountryId);
83
+ config = new HyperKycConfig(appId, appKey, workflowId, transactionId);
82
84
  }
83
85
  contract = new HyperKyc.Contract();
84
86
  Intent newIntent = contract.createIntent(currentActivity, config);
@@ -101,11 +103,11 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
101
103
 
102
104
  private void parseKYCResult(HyperKycResult hyperKycResult){
103
105
 
104
- String errorMessage="";
106
+
105
107
  HyperKycData hyperKycData = hyperKycResult.getData();
106
108
  WritableMap resultMap = new WritableNativeMap();
107
- resultMap.putString("result", hyperKycResult.getStatus().toString());
108
- resultMap.putString("errorMessage", errorMessage);
109
+ resultMap.putString("status", hyperKycResult.getStatus().toString());
110
+ resultMap.putString("reason", hyperKycResult.getReason());
109
111
  try {
110
112
  if (hyperKycData != null) {
111
113
 
@@ -130,35 +132,7 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule implements Act
130
132
  }
131
133
 
132
134
 
133
- private List<HyperKycFlow> processWorkFlow(String workflowArray){
134
- List<HyperKycFlow> workflows = new ArrayList<>();
135
- try {
136
- JSONArray kycFlows = null;
137
-
138
- kycFlows = new JSONArray(workflowArray);
139
-
140
- for(int i = 0; i < kycFlows.length(); i++){
141
- JSONObject kycFlow = kycFlows.getJSONObject(i);
142
- if(kycFlow.has("type")){
143
- String flowStr = kycFlow.getString("type");
144
- switch (flowStr) {
145
- case "document":
146
- String countryId = kycFlow.has(HyperkycConstants.COUNTRY_ID) ? kycFlow.getString(HyperkycConstants.COUNTRY_ID): null;
147
- String documentId = kycFlow.has(HyperkycConstants.DOCUMENT_ID) ? kycFlow.getString(HyperkycConstants.DOCUMENT_ID): null;
148
- boolean useForFaceMatch = kycFlow.has(HyperkycConstants.USE_FOR_FACE_MATCH)? kycFlow.getBoolean(HyperkycConstants.USE_FOR_FACE_MATCH): false;
149
-
150
- workflows.add(new HyperKycFlow.Document(new DocFlowConfig(useForFaceMatch, countryId, documentId )));
151
- case "face":
152
- workflows.add(new HyperKycFlow.Face());
153
-
154
- }
155
- }
156
- }
157
- } catch (Exception e) {
158
- e.printStackTrace();
159
- }
160
- return workflows;
161
- }
135
+
162
136
  @Override
163
137
  public void onNewIntent(Intent intent) {
164
138
 
package/ios/.DS_Store CHANGED
Binary file
@@ -5,216 +5,180 @@ import HyperKYC
5
5
 
6
6
  @objc(Hyperkyc)
7
7
  class Hyperkyc: NSObject {
8
- @objc static func requiresMainQueueSetup() -> Bool {return true}
9
-
10
- @objc(launch:callback:)
11
- func launch(_config: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
12
- let appId = _config["appId"] as? String
13
- let transactionId = _config["transactionId"] as? String
14
- let appKey = _config["appKey"] as? String
15
- let accessToken = _config["accessToken"] as? String
16
- let kycFlow = _config["workflow"] as? String
17
- let defaultCountryId = _config["defaultCountryId"] as? String ?? nil
8
+ @objc static func requiresMainQueueSetup() -> Bool {return true}
18
9
 
19
- let hyperKycWorkflows = processKYCFlowStates(flows: kycFlow!)
20
- DispatchQueue.main.async {
21
- let controller = RCTPresentedViewController()
10
+ internal var skipKeysArray : [String] = ["responseResult", "variables", "moduleId"]
11
+ @objc(launch:callback:)
12
+ func launch(_config: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
13
+ let appId = _config["appId"] as? String
14
+ let transactionId = _config["transactionId"] as? String
15
+ let appKey = _config["appKey"] as? String
16
+ let accessToken = _config["accessToken"] as? String
17
+ let workflowId = _config["workflowId"] as? String
22
18
 
23
- if let accessTokenConfig = accessToken{
24
- let hyperKYCConfig = HyperKycConfig(accessToken: accessTokenConfig, workFlow: hyperKycWorkflows, transactionId: transactionId!, defaultCountryId: defaultCountryId)
25
- HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
26
-
27
- }
28
- }
29
19
 
30
- if(appKey != nil && appId != nil){
31
- let hyperKYCConfig = HyperKycConfig(appId: appId!, appKey: appKey!, workFlow: hyperKycWorkflows, transactionId: transactionId!, defaultCountryId: defaultCountryId)
20
+ DispatchQueue.main.async {
21
+ let controller = RCTPresentedViewController()
32
22
 
33
- HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
23
+ if let accessTokenConfig = accessToken{
24
+ let hyperKYCConfig = HyperKycConfig(accessToken: accessTokenConfig, workflowId: workflowId!, transactionId: transactionId!)
25
+ HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
26
+
27
+ }
28
+ }
34
29
 
35
- let result = self.processHyperKycResult(hyperKycResult: hyperKycResult)
36
- callback( [result])
30
+ if(appKey != nil && appId != nil){
31
+ let hyperKYCConfig = HyperKycConfig(appId: appId!, appKey: appKey!, workflowId: workflowId!, transactionId: transactionId!)
32
+
33
+ HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
34
+
35
+ let result = self.processHyperKycResult(hyperKycResult: hyperKycResult)
36
+ callback( [result])
37
+ }
37
38
  }
39
+
38
40
  }
39
-
40
41
  }
41
- }
42
-
43
-
44
-
45
-
46
- func processHyperKycResult(hyperKycResult: HyperKycResult) -> [String : Any] {
47
-
48
- let resultEnum = hyperKycResult.result! as KYCResult
49
- var resultEnumString = ""
50
- var kycData = [
51
- "selectedCountryId" : "",
52
-
53
- ] as [String: Any]
54
- var errorMessage = ""
55
42
 
56
- resultEnumString = String(describing: resultEnum)
57
43
 
58
- if let hyperKycData = hyperKycResult.hyperKYCData {
59
- if let country = hyperKycData.selectedCountry {
60
- kycData["selectedCountryId"] = country
61
- }
44
+ func processHyperKycResult(hyperKycResult: HyperKycResult) -> [String : Any] {
62
45
 
46
+ let resultEnum = hyperKycResult.status!
47
+ var resultEnumString = ""
48
+ var kycData = [:] as [String: Any]
49
+ var errorMessage = ""
63
50
 
64
- var docResultList : [[String: Any]] = []
65
- for docResult in hyperKycData.docResultList{
66
-
67
- var docDataList: [[String: Any]] = []
51
+ resultEnumString = String(describing: resultEnum)
52
+
53
+ if let hyperKycData = hyperKycResult.hyperKYCData {
68
54
 
69
- for docData in docResult.docDataList {
70
- var docDataDictionary = [
71
- "side" : docData.side,
72
- "docImagePath" : docData.docImagePath,
73
- "action" : docData.action,
74
-
55
+ //Process country data
56
+ if let countryResult = hyperKycData.countryResult{
57
+ var countryDataDictionary = [
58
+ "id": countryResult.id,
59
+ "name": countryResult.name,
60
+ "region": countryResult.region,
61
+ "moduleId": countryResult.moduleId,
62
+ "baseUrl": countryResult.baseUrl
63
+
75
64
  ] as [String: Any]
76
- if let responseHeaders = docData.responseHeaders {
77
- docDataDictionary["responseHeaders"] = responseHeaders
78
- }
79
- if let responseResult = docData.responseResult {
80
- docDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: responseResult, faceDataResponseResult: nil, faceMatchDataResponseResult: nil )
65
+
66
+ kycData["countryResult"] = countryDataDictionary
67
+ }
68
+
69
+ //Process doc data
70
+ var docResultList : [[String: Any]] = []
71
+ for docResult in hyperKycData.docResultList{
72
+ var docDataList: [[String: Any]] = []
73
+ for docData in docResult.docDataList {
74
+ docDataList.append(processDictionary(inputDictionary: docData.asDictionary))
81
75
  }
82
- docDataList.append(docDataDictionary as [String : Any])
76
+ var docResultDictionary = [
77
+ "documentId": docResult.documentId,
78
+ "moduleId":docResult.moduleId,
79
+ "docDataList": docDataList
80
+ ] as [String : Any]
81
+
82
+ docResultList.append(docResultDictionary as [String: Any])
83
83
  }
84
- var docResultDictionary = [
85
- "tag" : docResult.tag,
86
- "documentId": docResult.documentId,
87
- "docDataList": docDataList
88
- ] as [String : Any]
89
84
 
90
- docResultList.append(docResultDictionary as [String: Any])
91
- }
92
-
93
- kycData["docResultList"] = docResultList
94
-
95
- // Process face data
96
- if let faceData = hyperKycData.faceData {
97
- var faceDataDictionary = [
98
- "croppedFaceImagePath" : faceData.croppedFaceImagePath,
99
- "fullFaceImagePath" : faceData.fullFaceImagePath,
100
- "videoPath" : faceData.videoPath,
101
- "action" : faceData.action,
102
- ] as [String:Any]
103
- if let responseHeaders = faceData.responseHeaders {
104
- faceDataDictionary["responseHeaders"] = responseHeaders
85
+ kycData["docResultList"] = docResultList
86
+
87
+ //
88
+ // Process face data
89
+ if let faceResult = hyperKycData.faceResult {
90
+ var faceResultDictionary = ["moduleId": faceResult.moduleId] as [String:Any]
91
+ faceResultDictionary["faceData"] = processDictionary(inputDictionary: faceResult.faceData.asDictionary)
92
+ kycData["faceResult"] = faceResultDictionary
105
93
  }
106
- if let responseResult = faceData.responseResult {
107
- faceDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: nil, faceDataResponseResult: responseResult, faceMatchDataResponseResult: nil )
94
+
95
+
96
+
97
+ // Process api data
98
+ var apiResultList : [[String: Any]] = []
99
+ for apiResult in hyperKycData.apiResultList{
100
+ var apiResultDictionary = [
101
+ "moduleId" : apiResult.moduleId
102
+ ] as [String : Any]
103
+ apiResultDictionary["apiData"] = processDictionary(inputDictionary: apiResult.apiData.asDictionary)
104
+ apiResultList.append(apiResultDictionary)
108
105
  }
109
106
 
110
107
 
111
- kycData["faceData"] = faceDataDictionary
108
+ kycData["apiResultList"] = apiResultList
112
109
 
113
- }
114
110
 
115
- //Process face match data
116
- var faceMatchDataResultList : [[String: Any]] = []
117
- for faceMatchDataResult in hyperKycData.faceMatchDataResultList{
118
-
119
- var faceMatchDataDictionary = [
120
- "action" : faceMatchDataResult.facematchData.action,
121
- ] as [String:Any]
122
- if let responseHeaders = faceMatchDataResult.facematchData.responseHeaders {
123
- faceMatchDataDictionary["responseHeaders"] = responseHeaders
124
- }
125
- if let responseResult = faceMatchDataResult.facematchData.responseResult {
126
- faceMatchDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: nil, faceDataResponseResult: nil, faceMatchDataResponseResult: responseResult)
127
- }
128
- var faceMatchResultDictionary = [
129
- "tag": faceMatchDataResult.tag,
130
- "documentId":faceMatchDataResult.documentId,
131
- "faceMatchData":faceMatchDataDictionary
132
- ] as [String: Any]
133
- faceMatchDataResultList.append(faceMatchResultDictionary)
111
+
112
+ //Process formview data
113
+ var formViewResultList : [[String: Any]] = []
114
+
115
+ for formViewResult in hyperKycData.formResultList{
116
+ var formViewResultDictionary = [
117
+ "moduleId" : formViewResult.moduleId
118
+ ] as [String : Any]
119
+ formViewResultList.append(formViewResultDictionary)
134
120
  }
135
-
136
- kycData["faceMatchDataResultList"] = faceMatchDataResultList
137
121
 
138
- if let errorMsg = hyperKycResult.errorMessage {
139
- errorMessage = errorMsg
140
- }
122
+ kycData["formViewResultList"] = formViewResultList
141
123
 
142
- let resultMap = [
143
- "result" : resultEnumString,
144
- "hyperKycData" : kycData,
145
- "errorMessage" : errorMessage,
146
- ] as [String : Any]
147
- return resultMap
124
+ //Process webview data
125
+ var webViewResultList : [[String: Any]] = []
126
+ for webViewResult in hyperKycData.webviewResultList{
127
+ var webViewResultDictionary = [
128
+ "moduleId" : webViewResult.moduleId
129
+ ] as [String : Any]
130
+
131
+ webViewResultDictionary["webViewData"] = processDictionary(inputDictionary: webViewResult.webviewData.asDictionary)
132
+ webViewResultList.append(webViewResultDictionary)
133
+ }
148
134
 
149
-
150
-
151
- }
152
- return [:]
153
- }
135
+ kycData["webViewResultList"] = webViewResultList
136
+
137
+
138
+
139
+
140
+ if let errorMsg = hyperKycResult.reason {
141
+ errorMessage = errorMsg
142
+ }
143
+
144
+ let resultMap = [
145
+ "status" : resultEnumString,
146
+ "reason" : errorMessage,
147
+ "hyperKycData" : kycData
148
+
149
+ ] as [String : Any]
150
+ return resultMap
151
+
152
+ }
153
+
154
154
 
155
-
156
- //
157
- func getResponseResultJsonString(docDataResponseResult: DocCaptureApiDetail?, faceDataResponseResult: FaceCaptureApiDetail?, faceMatchDataResponseResult: FaceMatchApiDetail?) -> [String:Any] {
158
- let encoder = JSONEncoder()
159
-
160
- do {
161
- if let responseResult = docDataResponseResult {
162
- let responseResultData = try encoder.encode(responseResult)
163
- return try JSONSerialization.jsonObject(with: responseResultData, options: []) as? [String:Any] ?? [:]
164
- } else if let responseResult = faceDataResponseResult {
165
- let responseResultData = try encoder.encode(responseResult)
166
- return try JSONSerialization.jsonObject(with: responseResultData, options: []) as? [String:Any] ?? [:]
167
- } else if let responseResult = faceMatchDataResponseResult {
168
- let responseResultData = try encoder.encode(responseResult)
169
- return try JSONSerialization.jsonObject(with: responseResultData, options: []) as? [String:Any] ?? [:]
170
- } else {
171
155
  return [:]
172
156
  }
173
- } catch let parseError {
174
- print("JSON Error DocData ResponseResult : \(parseError.localizedDescription)")
175
- return [:]
176
- }
177
- return [:]
178
- }
179
-
180
-
181
-
182
- func processKYCFlowStates(flows : String) -> [HyperKycFlow] {
183
- var hyperKycFlows = [HyperKycFlow]()
184
- let workflows = convertToDictionary(json: flows)
185
-
186
- workflows?.forEach({ (value: Any) in
187
- let valueObj = (value as! [String:Any])
188
- switch(valueObj["type"] as! String){
189
- case "document":
190
- let useForFaceMatch = valueObj["useForFaceMatch"] as? Bool ?? false
191
- let countryId = valueObj["countryId"] as? String ?? nil
192
- let documentId = valueObj["documentId"] as? String ?? nil
193
- hyperKycFlows.append(HyperKycFlow.document(config: DocFlowConfig(useForFaceMatch: useForFaceMatch, countryId: countryId, documentId: documentId)))
194
- case "face":
195
- hyperKycFlows.append(HyperKycFlow.face())
196
- default:
197
- print("Case not handled")
198
- }
199
- })
200
-
201
- return hyperKycFlows
202
-
203
- }
157
+
158
+
204
159
 
205
- func convertToDictionary(json: String) -> [Any]? {
206
- if let data = json.data(using: .utf8) {
207
- do {
208
- return try JSONSerialization.jsonObject(with: data, options: []) as? [Any]
209
- } catch {
210
- print(error.localizedDescription)
160
+ func processDictionary(inputDictionary : [String : Any]) -> [String : Any]{
161
+ var resultDictionary = [:] as [String: Any]
162
+ for (key,value ) in inputDictionary{
163
+
164
+ if(!skipKeysArray.contains(key) ){
165
+ var keyName = key
166
+ if(key == "responseResultRaw"){
167
+ keyName = "responseResult"
168
+ }
169
+ resultDictionary[keyName] = value
170
+ }
171
+
172
+ }
173
+ return resultDictionary
174
+
211
175
  }
212
- }
213
- return nil
214
- }
176
+
177
+
178
+
215
179
 
216
180
  }
217
-
181
+
218
182
 
219
183
 
220
184
 
package/lib/.DS_Store ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hyperkyc-sdk",
3
- "version": "0.2.0-alpha1",
3
+ "version": "0.3.0-alpha1",
4
4
  "description": "React Native wrapper for HyperKYC SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",