react-native-hyperkyc-sdk 0.1.3-alpha → 0.1.5-alpha

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/ios/.DS_Store CHANGED
Binary file
@@ -5,10 +5,10 @@ import HyperKYC
5
5
 
6
6
  @objc(HyperkycSdk)
7
7
  class HyperkycSdk: NSObject {
8
- @objc static func requiresMainQueueSetup() -> Bool {return true}
8
+ @objc static func requiresMainQueueSetup() -> Bool {return true}
9
9
 
10
- @objc
11
- func launchKYC(_config: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
10
+ @objc(launch:callback:)
11
+ func launch(_config: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
12
12
  let appId = _config["appId"] as? String
13
13
  let transactionId = _config["transactionId"] as? String
14
14
  let accessToken = _config["accessToken"] as? String
@@ -21,136 +21,134 @@ class HyperkycSdk: NSObject {
21
21
  let hyperKYCConfig = HyperKycConfig(appId: appId!, accessToken: accessToken!, workFlow: workFlow,transactionId: transactionId!)
22
22
  HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
23
23
  // process the result hereDand send it back to JS
24
-
25
- callback([processHyperKycResult(hyperKycResult: hyperKycResult)])
26
-
24
+ callback( [self.processHyperKycResult(hyperKycResult: hyperKycResult)])
27
25
 
28
26
  }
29
27
  }
30
-
31
- func processHyperKycResult(hyperKycResult: HyperKycResult) -> [String: Any] {
32
- let encoder = JSONEncoder()
33
- encoder.outputFormatting = .prettyPrinted
34
- // MARK: Add result, kycData, errorMessage
35
- let resultEnum = hyperKycResult.result! as KYCResult
36
- var resultEnumString = ""
37
- var kycData = [
38
- "selectedCountry" : "",
39
- "selectedDocument" : "",
28
+
29
+ }
30
+
31
+ func processHyperKycResult(hyperKycResult: HyperKycResult) -> [String: Any] {
32
+
33
+ let resultEnum = hyperKycResult.result! as KYCResult
34
+ var resultEnumString = ""
35
+ var kycData = [
36
+ "selectedCountry" : "",
37
+ "selectedDocument" : "",
40
38
 
41
- ] as [String: Any]
42
- var errorMessage = ""
43
- // MARK: Add resultEnum
44
- resultEnumString = String(describing: resultEnum)
45
- // MARK: Add kycData
46
- if let hyperKycData = hyperKycResult.hyperKYCData {
47
- if let country = hyperKycData.selectedCountry {
48
- kycData["selectedCountry"] = country
49
- }
50
- if let document = hyperKycData.selectedDocument {
51
- kycData["selectedDocument"] = document
52
- }
53
- // MARK: Add docData to kycData
54
- var docDataList: [[String: Any]] = []
55
- for docData in hyperKycData.docDataList {
56
- var docDataDictionary = [
57
- "side" : docData.side,
58
- "docImagePath" : docData.docImagePath,
59
- "action" : docData.action,
60
- ]
61
- if let responseHeaders = docData.responseHeaders {
62
- do {
63
- let headersData = try JSONSerialization.data(withJSONObject: responseHeaders , options: JSONSerialization.WritingOptions.prettyPrinted)
64
- docDataDictionary["responseHeaders"] = String(data: headersData, encoding: String.Encoding.utf8)
65
- }catch let parseError{
66
- print("JSON Error DocData ResponseHeaders : \(parseError.localizedDescription)")
67
- }
68
- } else {
69
- docDataDictionary["responseHeaders"] = "{}"
39
+ ] as [String: Any]
40
+ var errorMessage = ""
41
+
42
+ resultEnumString = String(describing: resultEnum)
43
+
44
+ if let hyperKycData = hyperKycResult.hyperKYCData {
45
+ if let country = hyperKycData.selectedCountry {
46
+ kycData["selectedCountry"] = country
70
47
  }
71
- if let responseResult = docData.responseResult {
72
- do {
73
- let docDataResponseResult = try encoder.encode(responseResult)
74
- docDataDictionary["responseResult"] = String(data: docDataResponseResult, encoding: .utf8)!
75
- } catch let parseError {
76
- print("JSON Error DocData ResponseResult : \(parseError.localizedDescription)")
77
- }
78
- } else {
79
- docDataDictionary["responseResult"] = "{}"
48
+ if let document = hyperKycData.selectedDocument {
49
+ kycData["selectedDocument"] = document
80
50
  }
81
- docDataList.append(docDataDictionary as [String : Any])
82
- }
83
- kycData["docDataList"] = docDataList
84
- // MARK: Add faceData to kycData
85
- if let faceData = hyperKycData.faceData {
86
- var faceDataDictionary = [
87
- "croppedFaceImagePath" : faceData.croppedFaceImagePath,
88
- "fullFaceImagePath" : faceData.fullFaceImagePath,
89
- "videoPath" : faceData.videoPath,
90
- "action" : faceData.action,
91
- ]
92
- if let responseHeaders = faceData.responseHeaders {
93
- do {
94
- let headersData = try JSONSerialization.data(withJSONObject: responseHeaders , options: JSONSerialization.WritingOptions.prettyPrinted)
95
- faceDataDictionary["responseHeaders"] = String(data: headersData, encoding: String.Encoding.utf8)
96
- }catch let parseError{
97
- print("JSON Error FaceData ResponseHeaders : \(parseError.localizedDescription)")
98
- }
99
- } else {
100
- faceDataDictionary["responseHeaders"] = "{}"
51
+
52
+ var docDataList: [[String: Any]] = []
53
+ for docData in hyperKycData.docDataList {
54
+ var docDataDictionary = [
55
+ "side" : docData.side,
56
+ "docImagePath" : docData.docImagePath,
57
+ "action" : docData.action,
58
+ ]
59
+ if let responseHeaders = docData.responseHeaders {
60
+ docDataDictionary["responseHeaders"] = getResponseHeadersJsonString(responseHeaders: responseHeaders)
61
+ }
62
+ if let responseResult = docData.responseResult {
63
+ docDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: responseResult, faceDataResponseResult: nil, faceMatchDataResponseResult: nil )
64
+ }
65
+ docDataList.append(docDataDictionary as [String : Any])
101
66
  }
102
- if let responseResult = faceData.responseResult {
103
- do {
104
- let faceDataResponseResult = try encoder.encode(responseResult)
105
- faceDataDictionary["responseResult"] = String(data: faceDataResponseResult, encoding: .utf8)!
106
- } catch let parseError {
107
- print("JSON Error FaceData ResponseResult : \(parseError.localizedDescription)")
108
- }
109
- } else {
110
- faceDataDictionary["responseResult"] = "{}"
67
+ kycData["docDataList"] = docDataList
68
+ // MARK: Add faceData to kycData
69
+ if let faceData = hyperKycData.faceData {
70
+ var faceDataDictionary = [
71
+ "croppedFaceImagePath" : faceData.croppedFaceImagePath,
72
+ "fullFaceImagePath" : faceData.fullFaceImagePath,
73
+ "videoPath" : faceData.videoPath,
74
+ "action" : faceData.action,
75
+ ]
76
+ if let responseHeaders = faceData.responseHeaders {
77
+ faceDataDictionary["responseHeaders"] = getResponseHeadersJsonString(responseHeaders: responseHeaders)
78
+ }
79
+ if let responseResult = faceData.responseResult {
80
+ faceDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: nil, faceDataResponseResult: responseResult, faceMatchDataResponseResult: nil )
81
+ }
82
+
83
+ kycData["faceData"] = faceDataDictionary
84
+ }
85
+
86
+ if let faceMatchData = hyperKycData.faceMatchData {
87
+ var faceMatchDataDictionary = [
88
+ "action" : faceMatchData.action,
89
+ ]
90
+ if let responseHeaders = faceMatchData.responseHeaders {
91
+ faceMatchDataDictionary["responseHeaders"] = getResponseHeadersJsonString(responseHeaders: responseHeaders)
92
+ }
93
+ if let responseResult = faceMatchData.responseResult {
94
+ faceMatchDataDictionary["responseResult"] = getResponseResultJsonString(docDataResponseResult: nil, faceDataResponseResult: nil, faceMatchDataResponseResult: responseResult)
95
+ }
96
+
97
+ kycData["faceMatchData"] = faceMatchDataDictionary
111
98
  }
112
- kycData["faceData"] = faceDataDictionary
113
99
  }
114
- // MARK: Add faceMatchData to kycData
115
- if let faceMatchData = hyperKycData.faceMatchData {
116
- var faceMatchDataDictionary = [
117
- "action" : faceMatchData.action,
118
- ]
119
- if let responseHeaders = faceMatchData.responseHeaders {
120
- do {
100
+
101
+ if let errorMsg = hyperKycResult.errorMessage {
102
+ errorMessage = errorMsg
103
+ }
104
+
105
+ let resultMap = [
106
+ "result" : resultEnumString,
107
+ "hyperKYCData" : kycData,
108
+ "errorMessage" : errorMessage,
109
+ ] as [String : Any]
110
+ return resultMap
111
+ }
112
+
113
+ func getResponseHeadersJsonString(responseHeaders: [String: String]) -> String {
114
+ var responseHeadersJsonString :String = "{}"
115
+ do {
121
116
  let headersData = try JSONSerialization.data(withJSONObject: responseHeaders , options: JSONSerialization.WritingOptions.prettyPrinted)
122
- faceMatchDataDictionary["responseHeaders"] = String(data: headersData, encoding: String.Encoding.utf8)
123
- }catch let parseError{
124
- print("JSON Error FaceMatchData ResponseHeaders : \(parseError.localizedDescription)")
125
- }
126
- } else {
127
- faceMatchDataDictionary["responseHeaders"] = "{}"
117
+ responseHeadersJsonString = String(data: headersData, encoding: String.Encoding.utf8) ?? "{}"
118
+ return responseHeadersJsonString
119
+ } catch let parseError{
120
+ print("JSON Error Parsing ResponseHeaders : \(parseError.localizedDescription)")
121
+ return responseHeadersJsonString
128
122
  }
129
- if let responseResult = faceMatchData.responseResult {
130
- do {
131
- let faceMatchDataResponseResult = try encoder.encode(responseResult)
132
- faceMatchDataDictionary["responseResult"] = String(data: faceMatchDataResponseResult, encoding: .utf8)!
133
- } catch let parseError {
134
- print("JSON Error FaceMatchData ResponseResult : \(parseError.localizedDescription)")
135
- }
136
- } else {
137
- faceMatchDataDictionary["responseResult"] = "{}"
138
- }
139
- kycData["faceMatchData"] = faceMatchDataDictionary
140
- }
141
123
  }
142
- // MARK: Add errorMessage
143
- if let errorMsg = hyperKycResult.errorMessage {
144
- errorMessage = errorMsg
124
+
125
+ func getResponseResultJsonString(docDataResponseResult: DocCaptureApiDetail?, faceDataResponseResult: FaceCaptureApiDetail?, faceMatchDataResponseResult: FaceMatchApiDetail?) -> String {
126
+ let encoder = JSONEncoder()
127
+ encoder.outputFormatting = .prettyPrinted
128
+ var responseResultJsonString:String = "{}"
129
+ do {
130
+ if let responseResult = docDataResponseResult {
131
+ let responseResultData = try encoder.encode(responseResult)
132
+ responseResultJsonString = String(data: responseResultData, encoding: .utf8) ?? "{}"
133
+ return responseResultJsonString
134
+ } else if let responseResult = faceDataResponseResult {
135
+ let responseResultData = try encoder.encode(responseResult)
136
+ responseResultJsonString = String(data: responseResultData, encoding: .utf8) ?? "{}"
137
+ return responseResultJsonString
138
+ } else if let responseResult = faceMatchDataResponseResult {
139
+ let responseResultData = try encoder.encode(responseResult)
140
+ responseResultJsonString = String(data: responseResultData, encoding: .utf8) ?? "{}"
141
+ return responseResultJsonString
142
+ } else {
143
+ return responseResultJsonString
144
+ }
145
+ } catch let parseError {
146
+ print("JSON Error DocData ResponseResult : \(parseError.localizedDescription)")
147
+ return responseResultJsonString
148
+ }
145
149
  }
146
- // MARK: Create the final result map which will include resultEnum, kycData and errorMessage
147
- let resultMap = [
148
- "result" : resultEnumString,
149
- "hyperKYCData" : kycData,
150
- "errorMessage" : errorMessage,
151
- ] as [String : Any]
152
- return resultMap
153
- }
150
+
151
+
154
152
 
155
153
  func processKYCFlowStates(flows : [String]) -> [HyperKycFlow]{
156
154
  var workflows = [HyperKycFlow]()
@@ -168,6 +166,6 @@ class HyperkycSdk: NSObject {
168
166
  }
169
167
  return workflows
170
168
  }
171
- }
169
+
172
170
 
173
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hyperkyc-sdk",
3
- "version": "0.1.3-alpha",
3
+ "version": "0.1.5-alpha",
4
4
  "description": "React Native wrapper for HyperKYC SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",