react-native-hyperkyc-sdk 0.2.0-alpha2 → 0.3.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.
- package/android/.DS_Store +0 -0
- package/android/build.gradle +3 -2
- package/android/src/.DS_Store +0 -0
- package/android/src/main/.DS_Store +0 -0
- package/android/src/main/java/.DS_Store +0 -0
- package/android/src/main/java/com/.DS_Store +0 -0
- package/android/src/main/java/com/reactnativehyperkycsdk/HyperkycSdkModule.java +10 -36
- package/ios/.DS_Store +0 -0
- package/ios/HyperkycSdk.swift +140 -176
- package/ios/HyperkycSdk.xcodeproj/project.xcworkspace/xcuserdata/niveditamuthusubramanian.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/.DS_Store +0 -0
- package/package.json +1 -1
package/android/.DS_Store
CHANGED
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -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
|
|
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
|
|
package/android/src/.DS_Store
CHANGED
|
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
|
-
|
|
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,
|
|
80
|
+
config = new HyperKycConfig(accessToken, workflowId, transactionId);
|
|
79
81
|
}else if(appId != null && appKey != null) {
|
|
80
82
|
|
|
81
|
-
config = new HyperKycConfig(appId, appKey,
|
|
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
|
-
|
|
106
|
+
|
|
105
107
|
HyperKycData hyperKycData = hyperKycResult.getData();
|
|
106
108
|
WritableMap resultMap = new WritableNativeMap();
|
|
107
|
-
resultMap.putString("
|
|
108
|
-
resultMap.putString("
|
|
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
|
-
|
|
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
|
package/ios/HyperkycSdk.swift
CHANGED
|
@@ -5,216 +5,180 @@ import HyperKYC
|
|
|
5
5
|
|
|
6
6
|
@objc(Hyperkyc)
|
|
7
7
|
class Hyperkyc: NSObject {
|
|
8
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
31
|
-
let
|
|
20
|
+
DispatchQueue.main.async {
|
|
21
|
+
let controller = RCTPresentedViewController()
|
|
32
22
|
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var docDataList: [[String: Any]] = []
|
|
51
|
+
resultEnumString = String(describing: resultEnum)
|
|
52
|
+
|
|
53
|
+
if let hyperKycData = hyperKycResult.hyperKYCData {
|
|
68
54
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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["
|
|
108
|
+
kycData["apiResultList"] = apiResultList
|
|
112
109
|
|
|
113
|
-
}
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
139
|
-
errorMessage = errorMsg
|
|
140
|
-
}
|
|
122
|
+
kycData["formViewResultList"] = formViewResultList
|
|
141
123
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
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
|
-
|
|
174
|
-
|
|
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
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
214
|
-
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
215
179
|
|
|
216
180
|
}
|
|
217
|
-
|
|
181
|
+
|
|
218
182
|
|
|
219
183
|
|
|
220
184
|
|
|
Binary file
|
package/lib/.DS_Store
ADDED
|
Binary file
|