react-native-hyperkyc-sdk 0.1.0-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/android/.idea/gradle.xml +1 -0
- package/android/src/main/java/com/reactnativehyperkycsdk/HyperkycSdkModule.java +11 -8
- package/android/src/main/java/com/reactnativehyperkycsdk/HyperkycSdkPackage.java +9 -1
- package/ios/.DS_Store +0 -0
- package/ios/HyperkycSdk.swift +119 -121
- package/package.json +1 -1
package/android/.idea/gradle.xml
CHANGED
|
@@ -3,16 +3,12 @@ package com.reactnativehyperkycsdk;
|
|
|
3
3
|
|
|
4
4
|
import android.app.Activity;
|
|
5
5
|
import android.content.Intent;
|
|
6
|
-
import android.
|
|
6
|
+
import android.support.annotation.NonNull;
|
|
7
7
|
|
|
8
|
-
import android.util.Log;
|
|
9
|
-
|
|
10
|
-
import androidx.activity.result.ActivityResultLauncher;
|
|
11
|
-
import androidx.appcompat.app.AppCompatActivity;
|
|
12
8
|
|
|
13
9
|
import com.facebook.react.ReactActivity;
|
|
14
10
|
import com.facebook.react.bridge.ActivityEventListener;
|
|
15
|
-
|
|
11
|
+
|
|
16
12
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
13
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
14
|
import com.facebook.react.bridge.ReactMethod;
|
|
@@ -26,12 +22,18 @@ import com.google.gson.Gson;
|
|
|
26
22
|
import org.json.JSONObject;
|
|
27
23
|
|
|
28
24
|
import java.util.ArrayList;
|
|
25
|
+
import java.util.List;
|
|
29
26
|
|
|
30
27
|
|
|
28
|
+
import co.hyperverge.hyperkyc.HyperKYC;
|
|
29
|
+
import co.hyperverge.hyperkyc.data.models.HyperKycConfig;
|
|
30
|
+
import co.hyperverge.hyperkyc.data.models.HyperKycData;
|
|
31
|
+
import co.hyperverge.hyperkyc.data.models.HyperKycFlow;
|
|
32
|
+
import co.hyperverge.hyperkyc.data.models.HyperKycResult;
|
|
31
33
|
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
public class HyperkycSdkModule extends ReactContextBaseJavaModule {
|
|
35
|
+
|
|
36
|
+
public class HyperkycSdkModule extends ReactContextBaseJavaModule implements ActivityEventListener {
|
|
35
37
|
public static final String NAME = "HyperkycSdk";
|
|
36
38
|
|
|
37
39
|
private final ReactApplicationContext reactContext;
|
|
@@ -146,4 +148,5 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule {
|
|
|
146
148
|
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
|
|
149
152
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
package com.reactnativehyperkycsdk;
|
|
2
2
|
|
|
3
|
+
import android.support.annotation.NonNull;
|
|
4
|
+
|
|
3
5
|
import androidx.annotation.NonNull;
|
|
4
6
|
|
|
5
7
|
import com.facebook.react.ReactPackage;
|
|
8
|
+
import com.facebook.react.bridge.JavaScriptModule;
|
|
6
9
|
import com.facebook.react.bridge.NativeModule;
|
|
7
10
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
11
|
import com.facebook.react.uimanager.ViewManager;
|
|
@@ -20,7 +23,12 @@ public class HyperkycSdkPackage implements ReactPackage {
|
|
|
20
23
|
return modules;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
|
|
26
|
+
|
|
27
|
+
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@NonNull
|
|
24
32
|
@Override
|
|
25
33
|
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
26
34
|
return Collections.emptyList();
|
package/ios/.DS_Store
CHANGED
|
Binary file
|
package/ios/HyperkycSdk.swift
CHANGED
|
@@ -5,10 +5,10 @@ import HyperKYC
|
|
|
5
5
|
|
|
6
6
|
@objc(HyperkycSdk)
|
|
7
7
|
class HyperkycSdk: NSObject {
|
|
8
|
-
|
|
8
|
+
@objc static func requiresMainQueueSetup() -> Bool {return true}
|
|
9
9
|
|
|
10
|
-
@objc
|
|
11
|
-
func
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
72
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
115
|
-
if let
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
147
|
-
|
|
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
|
}
|