react-native-hyperkyc-sdk 0.46.0 → 0.47.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/README.md +11 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativehyperkycsdk/HyperkycSdkModule.java +218 -170
- package/ios/HyperkycSdk-Bridging-Header.h +1 -0
- package/ios/HyperkycSdk.m +4 -1
- package/ios/HyperkycSdk.swift +61 -12
- package/lib/commonjs/HyperKycEvents.js +91 -0
- package/lib/commonjs/HyperKycEvents.js.map +1 -0
- package/lib/commonjs/index.js +22 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/HyperKycEvents.js +78 -0
- package/lib/module/HyperKycEvents.js.map +1 -0
- package/lib/module/index.js +13 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/HyperKycEvents.d.ts +7 -0
- package/lib/typescript/index.d.ts +3 -0
- package/package.json +1 -1
- package/react-native-hyperkyc-sdk.podspec +1 -1
- package/src/HyperKycEvents.ts +88 -0
- package/src/index.tsx +12 -0
package/README.md
CHANGED
|
@@ -37,9 +37,18 @@ const { Hyperkyc } = NativeModules
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
//Prefetch configs
|
|
40
|
-
|
|
40
|
+
Hyperkyc.prefetch(appID, workflowID)
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
// [Recommended] Attach event listeners before launching HyperKYC SDK
|
|
44
|
+
HyperKyc.addEventListener((event) => {
|
|
45
|
+
// Handle the step_ended event
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// [Recommended] Remove all event listeners after receiving the SDK response from HyperKYC SDK
|
|
49
|
+
HyperKyc.removeAllEventListeners();
|
|
50
|
+
|
|
51
|
+
Hyperkyc.launch(configDictionary, function(response){
|
|
43
52
|
console.log(response)
|
|
44
53
|
})
|
|
45
54
|
```
|
package/android/build.gradle
CHANGED
|
@@ -56,7 +56,7 @@ repositories {
|
|
|
56
56
|
dependencies {
|
|
57
57
|
//noinspection GradleDynamicVersion
|
|
58
58
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
59
|
-
implementation('co.hyperverge:hyperkyc:0.
|
|
59
|
+
implementation('co.hyperverge:hyperkyc:0.47.2@aar', {
|
|
60
60
|
transitive = true
|
|
61
61
|
})
|
|
62
62
|
|
|
@@ -4,200 +4,248 @@ import android.app.Activity;
|
|
|
4
4
|
import android.content.Intent;
|
|
5
5
|
import android.util.Log;
|
|
6
6
|
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
|
|
7
9
|
import com.facebook.react.ReactActivity;
|
|
8
10
|
import com.facebook.react.bridge.ActivityEventListener;
|
|
11
|
+
import com.facebook.react.bridge.Callback;
|
|
9
12
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
13
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
14
|
import com.facebook.react.bridge.ReactMethod;
|
|
12
|
-
import com.facebook.react.bridge.Callback;
|
|
13
15
|
import com.facebook.react.bridge.ReadableMap;
|
|
14
16
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
15
|
-
import com.facebook.react.bridge.ReadableNativeMap;
|
|
16
17
|
import com.facebook.react.bridge.ReadableType;
|
|
18
|
+
import com.facebook.react.bridge.UiThreadUtil;
|
|
17
19
|
import com.facebook.react.bridge.WritableMap;
|
|
18
20
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
21
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
19
22
|
import com.google.gson.Gson;
|
|
20
23
|
|
|
24
|
+
import org.json.JSONObject;
|
|
25
|
+
|
|
21
26
|
import java.util.HashMap;
|
|
22
27
|
import java.util.Map;
|
|
23
28
|
|
|
24
|
-
import org.json.JSONObject;
|
|
25
|
-
|
|
26
29
|
import co.hyperverge.hyperkyc.HyperKyc;
|
|
27
30
|
import co.hyperverge.hyperkyc.data.models.HyperKycConfig;
|
|
28
31
|
import co.hyperverge.hyperkyc.data.models.result.HyperKycResult;
|
|
29
|
-
|
|
30
|
-
import
|
|
32
|
+
import kotlin.Unit;
|
|
33
|
+
import kotlin.jvm.functions.Function1;
|
|
31
34
|
|
|
32
35
|
public class HyperkycSdkModule extends ReactContextBaseJavaModule {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
public static final String NAME = "Hyperkyc";
|
|
37
|
+
private final ReactApplicationContext reactContext;
|
|
38
|
+
private final int HYPERKYC_REQUEST_CODE = 56455;
|
|
39
|
+
private boolean isEventListenerAdded = false;
|
|
40
|
+
|
|
41
|
+
public HyperkycSdkModule(ReactApplicationContext reactContext) {
|
|
42
|
+
super(reactContext);
|
|
43
|
+
this.reactContext = reactContext;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
@NonNull
|
|
48
|
+
public String getName() {
|
|
49
|
+
return NAME;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
public void createUniqueId(Callback callback) {
|
|
54
|
+
callback.invoke(HyperKyc.createUniqueId());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
public void prefetch(String appId, String workflowId) {
|
|
59
|
+
if (getReactApplicationContext() != null) {
|
|
60
|
+
HyperKyc.prefetch(getReactApplicationContext(), appId, workflowId);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@ReactMethod
|
|
65
|
+
public void addEventListener() {
|
|
66
|
+
isEventListenerAdded = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
public void removeAllEventListeners() {
|
|
71
|
+
HyperKyc.removeAllEventListeners();
|
|
72
|
+
isEventListenerAdded = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void launch(ReadableMap kycConfig, Callback resultCallback) {
|
|
77
|
+
ReactActivity currentActivity = (ReactActivity) getCurrentActivity();
|
|
78
|
+
assert kycConfig != null;
|
|
79
|
+
HyperKycConfig config = getHyperKycConfigFromMap(kycConfig);
|
|
80
|
+
HyperKyc.Contract contract = new HyperKyc.Contract();
|
|
81
|
+
|
|
82
|
+
reactContext.addActivityEventListener(new ActivityEventListener() {
|
|
83
|
+
@Override
|
|
84
|
+
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
85
|
+
if (requestCode == HYPERKYC_REQUEST_CODE) {
|
|
86
|
+
HyperKycResult hyperKycResult = contract.parseResult(resultCode, data);
|
|
87
|
+
parseKYCResult(hyperKycResult, resultCallback);
|
|
88
|
+
} else {
|
|
89
|
+
resultCallback.invoke(getDummyResultMap());
|
|
90
|
+
}
|
|
91
|
+
reactContext.removeActivityEventListener(this);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@Override
|
|
95
|
+
public void onNewIntent(Intent intent) {
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (isEventListenerAdded) {
|
|
100
|
+
Function1<JSONObject, Unit> listener = jsonObject -> {
|
|
101
|
+
try {
|
|
102
|
+
WritableMap eventMap = HyperkycSdkUtils.convertJsonToMap(jsonObject);
|
|
103
|
+
UiThreadUtil.runOnUiThread(() -> sendEvent("onHyperKycEvent", eventMap));
|
|
104
|
+
} catch (Exception e) {
|
|
105
|
+
Log.e(NAME, e.getLocalizedMessage());
|
|
106
|
+
}
|
|
107
|
+
return Unit.INSTANCE;
|
|
108
|
+
};
|
|
109
|
+
HyperKyc.addEventListener(listener);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (currentActivity != null) {
|
|
113
|
+
Intent newIntent = contract.createIntent(currentActivity, config);
|
|
114
|
+
currentActivity.startActivityIfNeeded(newIntent, HYPERKYC_REQUEST_CODE);
|
|
115
|
+
} else {
|
|
116
|
+
resultCallback.invoke(getDummyResultMap());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private void sendEvent(String eventName, WritableMap eventProperties) {
|
|
121
|
+
if (reactContext.hasActiveCatalystInstance()) {
|
|
122
|
+
reactContext
|
|
123
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
124
|
+
.emit(eventName, eventProperties);
|
|
125
|
+
}
|
|
57
126
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
127
|
+
|
|
128
|
+
private void parseKYCResult(HyperKycResult hyperKycResult, Callback callback) {
|
|
129
|
+
try {
|
|
130
|
+
Gson gson = new Gson();
|
|
131
|
+
String resultJSON = gson.toJson(hyperKycResult);
|
|
132
|
+
JSONObject result = new JSONObject(resultJSON);
|
|
133
|
+
WritableMap resultMap = HyperkycSdkUtils.convertJsonToMap(result);
|
|
134
|
+
callback.invoke(resultMap);
|
|
135
|
+
} catch (Exception e) {
|
|
136
|
+
if (e.getLocalizedMessage() != null) {
|
|
137
|
+
Log.e(NAME, e.getLocalizedMessage());
|
|
138
|
+
} else {
|
|
139
|
+
Log.e(NAME, "error parsing hyperKycResult");
|
|
140
|
+
}
|
|
141
|
+
callback.invoke(getDummyResultMap());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private Map<String, Object> processReadableMap(ReadableMap rm) {
|
|
146
|
+
Map<String, Object> map = new HashMap<>();
|
|
147
|
+
ReadableMapKeySetIterator iterator = rm.keySetIterator();
|
|
148
|
+
while (iterator.hasNextKey()) {
|
|
149
|
+
String key = iterator.nextKey();
|
|
150
|
+
ReadableType type = rm.getType(key);
|
|
151
|
+
|
|
152
|
+
// Handle different types of values
|
|
153
|
+
switch (type) {
|
|
154
|
+
case Number:
|
|
155
|
+
double numberValue = rm.getDouble(key);
|
|
156
|
+
// Check if the value is an integer by comparing its fractional part
|
|
157
|
+
if (numberValue == Math.rint(numberValue)) { // rint rounds to the nearest integer
|
|
158
|
+
map.put(key, (int) numberValue); // It's an int, cast and put as Integer
|
|
159
|
+
} else {
|
|
160
|
+
map.put(key, numberValue); // It's a double
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case Boolean:
|
|
164
|
+
map.put(key, rm.getBoolean(key));
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
map.put(key, rm.getString(key));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return map;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private HyperKycConfig getHyperKycConfigFromMap(ReadableMap kycConfig) {
|
|
174
|
+
String appId = kycConfig.hasKey("appId") ? kycConfig.getString("appId") : null;
|
|
175
|
+
String appKey = kycConfig.hasKey("appKey") ? kycConfig.getString("appKey") : null;
|
|
176
|
+
String accessToken = kycConfig.hasKey("accessToken") ? kycConfig.getString("accessToken") : null;
|
|
177
|
+
String workflowId = kycConfig.hasKey("workflowId") ? kycConfig.getString("workflowId") : null;
|
|
178
|
+
String transactionId = kycConfig.hasKey("transactionId") ? kycConfig.getString("transactionId") : null;
|
|
179
|
+
ReadableMap inputs = kycConfig.hasKey("inputs") ? kycConfig.getMap("inputs") : null;
|
|
180
|
+
String defaultLangCode = kycConfig.hasKey("defaultLangCode") ? kycConfig.getString("defaultLangCode") : null;
|
|
181
|
+
Boolean useLocation = kycConfig.hasKey("useLocation") ? kycConfig.getBoolean("useLocation") : null;
|
|
182
|
+
String uniqueId = kycConfig.hasKey("uniqueId") ? kycConfig.getString("uniqueId") : null;
|
|
183
|
+
Map<String, String> metadata = new HashMap<>();
|
|
184
|
+
metadata.put("sdk-version", "0.47.0");
|
|
185
|
+
metadata.put("sdk-type", "React Native");
|
|
186
|
+
if (accessToken == null) {
|
|
187
|
+
assert appId != null;
|
|
188
|
+
assert appKey != null;
|
|
189
|
+
assert workflowId != null;
|
|
190
|
+
assert transactionId != null;
|
|
191
|
+
HyperKycConfig hyperKycConfig = new HyperKycConfig(appId, appKey, workflowId, transactionId);
|
|
192
|
+
if (inputs != null) {
|
|
193
|
+
hyperKycConfig.setInputs(processReadableMap(inputs));
|
|
194
|
+
}
|
|
195
|
+
if (defaultLangCode != null) {
|
|
196
|
+
hyperKycConfig.setDefaultLangCode(defaultLangCode);
|
|
197
|
+
}
|
|
198
|
+
if (useLocation != null) {
|
|
199
|
+
hyperKycConfig.setUseLocation(useLocation);
|
|
200
|
+
}
|
|
201
|
+
if (uniqueId != null) {
|
|
202
|
+
hyperKycConfig.setUniqueId(uniqueId);
|
|
203
|
+
}
|
|
204
|
+
hyperKycConfig.addMetadata(metadata);
|
|
205
|
+
|
|
206
|
+
return hyperKycConfig;
|
|
73
207
|
} else {
|
|
74
|
-
|
|
208
|
+
assert workflowId != null;
|
|
209
|
+
assert transactionId != null;
|
|
210
|
+
HyperKycConfig hyperKycConfig = new HyperKycConfig(accessToken, workflowId, transactionId);
|
|
211
|
+
if (inputs != null) {
|
|
212
|
+
hyperKycConfig.setInputs(processReadableMap(inputs));
|
|
213
|
+
}
|
|
214
|
+
if (defaultLangCode != null) {
|
|
215
|
+
hyperKycConfig.setDefaultLangCode(defaultLangCode);
|
|
216
|
+
}
|
|
217
|
+
if (useLocation != null) {
|
|
218
|
+
hyperKycConfig.setUseLocation(useLocation);
|
|
219
|
+
}
|
|
220
|
+
if (uniqueId != null) {
|
|
221
|
+
hyperKycConfig.setUniqueId(uniqueId);
|
|
222
|
+
}
|
|
223
|
+
hyperKycConfig.addMetadata(metadata);
|
|
224
|
+
|
|
225
|
+
return hyperKycConfig;
|
|
75
226
|
}
|
|
76
|
-
reactContext.removeActivityEventListener(this);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@Override
|
|
80
|
-
public void onNewIntent(Intent intent) {
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (currentActivity != null) {
|
|
85
|
-
Intent newIntent = contract.createIntent(currentActivity, config);
|
|
86
|
-
currentActivity.startActivityIfNeeded(newIntent, HYPERKYC_REQUEST_CODE);
|
|
87
|
-
} else {
|
|
88
|
-
resultCallback.invoke(getDummyResultMap());
|
|
89
227
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (e.getLocalizedMessage() != null) {
|
|
101
|
-
Log.e(NAME, e.getLocalizedMessage());
|
|
102
|
-
} else {
|
|
103
|
-
Log.e(NAME, "error parsing hyperKycResult");
|
|
104
|
-
}
|
|
105
|
-
callback.invoke(getDummyResultMap());
|
|
228
|
+
|
|
229
|
+
private WritableMap getDummyResultMap() {
|
|
230
|
+
WritableMap dummyResult = new WritableNativeMap();
|
|
231
|
+
dummyResult.putString("status", "");
|
|
232
|
+
dummyResult.putString("transactionId", "");
|
|
233
|
+
dummyResult.putInt("errorCode", 0);
|
|
234
|
+
dummyResult.putString("errorMessage", "");
|
|
235
|
+
dummyResult.putString("latestModule", "");
|
|
236
|
+
dummyResult.putMap("details", new WritableNativeMap());
|
|
237
|
+
return dummyResult;
|
|
106
238
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
while (iterator.hasNextKey()) {
|
|
113
|
-
String key = iterator.nextKey();
|
|
114
|
-
ReadableType type = rm.getType(key);
|
|
115
|
-
|
|
116
|
-
// Handle different types of values
|
|
117
|
-
switch (type) {
|
|
118
|
-
case Number:
|
|
119
|
-
double numberValue = rm.getDouble(key);
|
|
120
|
-
// Check if the value is an integer by comparing its fractional part
|
|
121
|
-
if (numberValue == Math.rint(numberValue)) { // rint rounds to the nearest integer
|
|
122
|
-
map.put(key, (int) numberValue); // It's an int, cast and put as Integer
|
|
123
|
-
} else {
|
|
124
|
-
map.put(key, numberValue); // It's a double
|
|
125
|
-
}
|
|
126
|
-
break;
|
|
127
|
-
case Boolean:
|
|
128
|
-
map.put(key, rm.getBoolean(key));
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
map.put(key, rm.getString(key));
|
|
132
|
-
}
|
|
239
|
+
|
|
240
|
+
@ReactMethod
|
|
241
|
+
private void addListener(String eventName) {
|
|
242
|
+
// Required for RN built-in EventEmitter support.
|
|
243
|
+
// Can be empty if we don't need per-event management.
|
|
133
244
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
String appKey = kycConfig.hasKey("appKey") ? kycConfig.getString("appKey") : null;
|
|
140
|
-
String accessToken = kycConfig.hasKey("accessToken") ? kycConfig.getString("accessToken") : null;
|
|
141
|
-
String workflowId = kycConfig.hasKey("workflowId") ? kycConfig.getString("workflowId") : null;
|
|
142
|
-
String transactionId = kycConfig.hasKey("transactionId") ? kycConfig.getString("transactionId") : null;
|
|
143
|
-
ReadableMap inputs = kycConfig.hasKey("inputs") ? kycConfig.getMap("inputs") : null;
|
|
144
|
-
String defaultLangCode = kycConfig.hasKey("defaultLangCode") ? kycConfig.getString("defaultLangCode") : null;
|
|
145
|
-
Boolean useLocation = kycConfig.hasKey("useLocation") ? kycConfig.getBoolean("useLocation") : null;
|
|
146
|
-
String uniqueId = kycConfig.hasKey("uniqueId") ? kycConfig.getString("uniqueId") : null;
|
|
147
|
-
Map<String, String> metadata = new HashMap<>();
|
|
148
|
-
metadata.put("sdk-version", "0.46.0");
|
|
149
|
-
metadata.put("sdk-type", "React Native");
|
|
150
|
-
if (accessToken == null) {
|
|
151
|
-
assert appId != null;
|
|
152
|
-
assert appKey != null;
|
|
153
|
-
assert workflowId != null;
|
|
154
|
-
assert transactionId != null;
|
|
155
|
-
HyperKycConfig hyperKycConfig = new HyperKycConfig(appId, appKey, workflowId, transactionId);
|
|
156
|
-
if (inputs != null) {
|
|
157
|
-
hyperKycConfig.setInputs(processReadableMap(inputs));
|
|
158
|
-
}
|
|
159
|
-
if (defaultLangCode != null) {
|
|
160
|
-
hyperKycConfig.setDefaultLangCode(defaultLangCode);
|
|
161
|
-
}
|
|
162
|
-
if (useLocation != null) {
|
|
163
|
-
hyperKycConfig.setUseLocation(useLocation);
|
|
164
|
-
}
|
|
165
|
-
if (uniqueId != null) {
|
|
166
|
-
hyperKycConfig.setUniqueId(uniqueId);
|
|
167
|
-
}
|
|
168
|
-
hyperKycConfig.addMetadata(metadata);
|
|
169
|
-
|
|
170
|
-
return hyperKycConfig;
|
|
171
|
-
} else {
|
|
172
|
-
assert workflowId != null;
|
|
173
|
-
assert transactionId != null;
|
|
174
|
-
HyperKycConfig hyperKycConfig = new HyperKycConfig(accessToken, workflowId, transactionId);
|
|
175
|
-
if (inputs != null) {
|
|
176
|
-
hyperKycConfig.setInputs(processReadableMap(inputs));
|
|
177
|
-
}
|
|
178
|
-
if (defaultLangCode != null) {
|
|
179
|
-
hyperKycConfig.setDefaultLangCode(defaultLangCode);
|
|
180
|
-
}
|
|
181
|
-
if (useLocation != null) {
|
|
182
|
-
hyperKycConfig.setUseLocation(useLocation);
|
|
183
|
-
}
|
|
184
|
-
if (uniqueId != null) {
|
|
185
|
-
hyperKycConfig.setUniqueId(uniqueId);
|
|
186
|
-
}
|
|
187
|
-
hyperKycConfig.addMetadata(metadata);
|
|
188
|
-
|
|
189
|
-
return hyperKycConfig;
|
|
245
|
+
|
|
246
|
+
@ReactMethod
|
|
247
|
+
private void removeListeners(int count) {
|
|
248
|
+
// Required for RN built-in EventEmitter support.
|
|
249
|
+
// Can be empty if we don't need per-event management.
|
|
190
250
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
private WritableMap getDummyResultMap() {
|
|
194
|
-
WritableMap dummyResult = new WritableNativeMap();
|
|
195
|
-
dummyResult.putString("status", "");
|
|
196
|
-
dummyResult.putString("transactionId", "");
|
|
197
|
-
dummyResult.putInt("errorCode", 0);
|
|
198
|
-
dummyResult.putString("errorMessage", "");
|
|
199
|
-
dummyResult.putString("latestModule", "");
|
|
200
|
-
dummyResult.putMap("details", new WritableNativeMap());
|
|
201
|
-
return dummyResult;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
251
|
+
}
|
package/ios/HyperkycSdk.m
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
3
|
#import <React/RCTUtils.h>
|
|
4
|
+
#import <React/RCTEventEmitter.h>
|
|
4
5
|
|
|
5
|
-
@interface RCT_EXTERN_MODULE(Hyperkyc,
|
|
6
|
+
@interface RCT_EXTERN_MODULE(Hyperkyc, RCTEventEmitter)
|
|
6
7
|
RCT_EXTERN_METHOD(launch: (NSDictionary*)config callback:(RCTResponseSenderBlock)callback)
|
|
7
8
|
RCT_EXTERN_METHOD(createUniqueId: (RCTResponseSenderBlock*)callback)
|
|
8
9
|
RCT_EXTERN_METHOD(prefetch: (NSString*)appId workflowId:(NSString*)workflowId)
|
|
10
|
+
RCT_EXTERN_METHOD(addEventListener)
|
|
11
|
+
RCT_EXTERN_METHOD(removeAllEventListeners)
|
|
9
12
|
|
|
10
13
|
+ (BOOL) requiresMainQueueSetup {
|
|
11
14
|
return YES;
|
package/ios/HyperkycSdk.swift
CHANGED
|
@@ -4,22 +4,35 @@ import Foundation
|
|
|
4
4
|
import HyperKYC
|
|
5
5
|
|
|
6
6
|
@objc(Hyperkyc)
|
|
7
|
-
class Hyperkyc:
|
|
8
|
-
@objc
|
|
7
|
+
class Hyperkyc: RCTEventEmitter {
|
|
8
|
+
@objc override static func requiresMainQueueSetup() -> Bool { return true }
|
|
9
|
+
|
|
10
|
+
var skipKeysArray: [String] = ["responseResult", "variables", "moduleId"]
|
|
11
|
+
private var isEventListenerAdded: Bool = false
|
|
12
|
+
private var isNativeListenerRegistered = false
|
|
9
13
|
|
|
10
|
-
internal var skipKeysArray : [String] = ["responseResult", "variables", "moduleId"]
|
|
11
|
-
|
|
12
14
|
@objc(createUniqueId:)
|
|
13
15
|
func createUniqueId(_callback: @escaping RCTResponseSenderBlock) {
|
|
14
16
|
let uniqueId = HyperKyc.createUniqueId()
|
|
15
17
|
_callback([uniqueId])
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
|
|
18
20
|
@objc(prefetch:workflowId:)
|
|
19
21
|
func prefetch(_appId: String, workflowId: String) {
|
|
20
22
|
HyperKyc.prefetch(appId: _appId, workflowId: workflowId)
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
@objc(addEventListener)
|
|
26
|
+
func addEventListener() {
|
|
27
|
+
isEventListenerAdded = true
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@objc(removeAllEventListeners)
|
|
31
|
+
func removeAllEventListeners() {
|
|
32
|
+
HyperKyc.removeAllEventListeners()
|
|
33
|
+
isEventListenerAdded = false
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
@objc(launch:callback:)
|
|
24
37
|
func launch(_config: NSDictionary, callback: @escaping RCTResponseSenderBlock) {
|
|
25
38
|
let appId = _config["appId"] as? String
|
|
@@ -32,10 +45,18 @@ class Hyperkyc: NSObject {
|
|
|
32
45
|
let useLocation = _config["useLocation"] as? Bool
|
|
33
46
|
let uniqueId = _config["uniqueId"] as? String
|
|
34
47
|
let metadata: [String: String] = [
|
|
35
|
-
"sdk-version": "0.
|
|
48
|
+
"sdk-version": "0.47.0",
|
|
36
49
|
"sdk-type": "React Native"
|
|
37
50
|
]
|
|
38
51
|
|
|
52
|
+
if isEventListenerAdded {
|
|
53
|
+
HyperKyc.addEventListener { event in
|
|
54
|
+
if self.isNativeListenerRegistered {
|
|
55
|
+
self.sendEvent(withName: "onHyperKycEvent", body: event)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
39
60
|
DispatchQueue.main.async {
|
|
40
61
|
let controller = RCTPresentedViewController()
|
|
41
62
|
|
|
@@ -61,7 +82,7 @@ class Hyperkyc: NSObject {
|
|
|
61
82
|
}
|
|
62
83
|
hyperKYCConfig.addMetadata(metadata: metadata)
|
|
63
84
|
|
|
64
|
-
//launch HyperKyc
|
|
85
|
+
// launch HyperKyc
|
|
65
86
|
HyperKyc.launch(controller!, hyperKycConfig: hyperKYCConfig) { hyperKycResult in
|
|
66
87
|
let result = self.processHyperKycResponse(hyperKycResult: hyperKycResult)
|
|
67
88
|
callback([result])
|
|
@@ -69,17 +90,17 @@ class Hyperkyc: NSObject {
|
|
|
69
90
|
}
|
|
70
91
|
}
|
|
71
92
|
|
|
72
|
-
func processHyperKycResponse(hyperKycResult: HyperKycResult) -> [String
|
|
93
|
+
func processHyperKycResponse(hyperKycResult: HyperKycResult) -> [String: Any] {
|
|
73
94
|
var kycData = [:] as [String: Any]
|
|
74
95
|
|
|
75
96
|
kycData["status"] = hyperKycResult.status
|
|
76
97
|
kycData["transactionId"] = hyperKycResult.transactionId
|
|
77
98
|
|
|
78
99
|
kycData["details"] = hyperKycResult.details
|
|
79
|
-
if let errorCode = hyperKycResult.errorCode{
|
|
100
|
+
if let errorCode = hyperKycResult.errorCode {
|
|
80
101
|
kycData["errorCode"] = errorCode
|
|
81
102
|
}
|
|
82
|
-
if let errorMessage = hyperKycResult.errorMessage{
|
|
103
|
+
if let errorMessage = hyperKycResult.errorMessage {
|
|
83
104
|
kycData["errorMessage"] = errorMessage
|
|
84
105
|
}
|
|
85
106
|
|
|
@@ -89,4 +110,32 @@ class Hyperkyc: NSObject {
|
|
|
89
110
|
|
|
90
111
|
return kycData
|
|
91
112
|
}
|
|
92
|
-
|
|
113
|
+
|
|
114
|
+
// Required override
|
|
115
|
+
override func supportedEvents() -> [String] {
|
|
116
|
+
return ["onHyperKycEvent"]
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Optional: Called when JS side starts observing
|
|
120
|
+
override func startObserving() {
|
|
121
|
+
isNativeListenerRegistered = true
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Optional: Called when JS side stops observing
|
|
125
|
+
override func stopObserving() {
|
|
126
|
+
isNativeListenerRegistered = false
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Add these two methods
|
|
130
|
+
@objc override func addListener(_ eventName: String) {
|
|
131
|
+
// Required for RN built-in EventEmitter support
|
|
132
|
+
// Can be empty if we don't need per-event management.
|
|
133
|
+
super.addListener(eventName)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@objc override func removeListeners(_ count: Double) {
|
|
137
|
+
// Required for RN built-in EventEmitter support
|
|
138
|
+
// Can be empty if we don't need per-event management.
|
|
139
|
+
super.removeListeners(count)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addEventListener = addEventListener;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
exports.removeAllEventListeners = removeAllEventListeners;
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
// src/HyperKycEvents.ts
|
|
13
|
+
const LINKING_ERROR = `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
14
|
+
ios: "- You have run 'pod install'\n",
|
|
15
|
+
default: ''
|
|
16
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
17
|
+
const NativeHyperKyc = _reactNative.NativeModules.Hyperkyc ? _reactNative.NativeModules.Hyperkyc : new Proxy({}, {
|
|
18
|
+
get() {
|
|
19
|
+
throw new Error(LINKING_ERROR);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
const emitter = new _reactNative.NativeEventEmitter(NativeHyperKyc);
|
|
24
|
+
const EVENT_NAME = 'onHyperKycEvent'; // Array to store all client callbacks
|
|
25
|
+
|
|
26
|
+
let clientListeners = []; // Single subscription to native events
|
|
27
|
+
|
|
28
|
+
let nativeSubscription = null; // Function to broadcast events to all client listeners
|
|
29
|
+
|
|
30
|
+
const broadcastEvent = data => {
|
|
31
|
+
// Run the broadcast on a background thread using setTimeout
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
clientListeners.forEach(listener => {
|
|
34
|
+
try {
|
|
35
|
+
listener(data);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error in HyperKYC event listener:', error);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}, 0);
|
|
41
|
+
}; // Function to ensure native listener is set up
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const ensureNativeListener = () => {
|
|
45
|
+
if (!nativeSubscription) {
|
|
46
|
+
emitter.removeAllListeners(EVENT_NAME);
|
|
47
|
+
nativeSubscription = emitter.addListener(EVENT_NAME, broadcastEvent);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function addEventListener(callback) {
|
|
52
|
+
// Add callback to client listeners
|
|
53
|
+
clientListeners.push(callback); // Ensure native listener is set up
|
|
54
|
+
|
|
55
|
+
ensureNativeListener(); // Call native method to remove all listeners
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
var _NativeHyperKyc$addEv;
|
|
59
|
+
|
|
60
|
+
(_NativeHyperKyc$addEv = NativeHyperKyc.addEventListener) === null || _NativeHyperKyc$addEv === void 0 ? void 0 : _NativeHyperKyc$addEv.call(NativeHyperKyc);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Error adding native event listeners:', error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function removeAllEventListeners() {
|
|
67
|
+
// Clear all client listeners
|
|
68
|
+
clientListeners = []; // Remove native subscription
|
|
69
|
+
|
|
70
|
+
if (nativeSubscription) {
|
|
71
|
+
nativeSubscription.remove();
|
|
72
|
+
nativeSubscription = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
emitter.removeAllListeners(EVENT_NAME); // Call native method to remove all listeners
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
var _NativeHyperKyc$remov;
|
|
79
|
+
|
|
80
|
+
(_NativeHyperKyc$remov = NativeHyperKyc.removeAllEventListeners) === null || _NativeHyperKyc$remov === void 0 ? void 0 : _NativeHyperKyc$remov.call(NativeHyperKyc);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error('Error removing native event listeners:', error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var _default = {
|
|
87
|
+
addEventListener,
|
|
88
|
+
removeAllEventListeners
|
|
89
|
+
};
|
|
90
|
+
exports.default = _default;
|
|
91
|
+
//# sourceMappingURL=HyperKycEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["HyperKycEvents.ts"],"names":["LINKING_ERROR","Platform","select","ios","default","NativeHyperKyc","NativeModules","Hyperkyc","Proxy","get","Error","emitter","NativeEventEmitter","EVENT_NAME","clientListeners","nativeSubscription","broadcastEvent","data","setTimeout","forEach","listener","error","console","ensureNativeListener","removeAllListeners","addListener","addEventListener","callback","push","removeAllEventListeners","remove"],"mappings":";;;;;;;;;AACA;;AADA;AAGA,MAAMA,aAAa,GAChB,oFAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,cAAc,GAAGC,2BAAcC,QAAd,GACnBD,2BAAcC,QADK,GAEnB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUV,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA,MAAMW,OAAO,GAAG,IAAIC,+BAAJ,CAAuBP,cAAvB,CAAhB;AACA,MAAMQ,UAAU,GAAG,iBAAnB,C,CAEA;;AACA,IAAIC,eAA2C,GAAG,EAAlD,C,CACA;;AACA,IAAIC,kBAA8C,GAAG,IAArD,C,CAEA;;AACA,MAAMC,cAAc,GAAIC,IAAD,IAAe;AACpC;AACAC,EAAAA,UAAU,CAAC,MAAM;AACfJ,IAAAA,eAAe,CAACK,OAAhB,CAAwBC,QAAQ,IAAI;AAClC,UAAI;AACFA,QAAAA,QAAQ,CAACH,IAAD,CAAR;AACD,OAFD,CAEE,OAAOI,KAAP,EAAc;AACdC,QAAAA,OAAO,CAACD,KAAR,CAAc,mCAAd,EAAmDA,KAAnD;AACD;AACF,KAND;AAOD,GARS,EAQP,CARO,CAAV;AASD,CAXD,C,CAaA;;;AACA,MAAME,oBAAoB,GAAG,MAAM;AACjC,MAAI,CAACR,kBAAL,EAAyB;AACvBJ,IAAAA,OAAO,CAACa,kBAAR,CAA2BX,UAA3B;AACAE,IAAAA,kBAAkB,GAAGJ,OAAO,CAACc,WAAR,CAAoBZ,UAApB,EAAgCG,cAAhC,CAArB;AACD;AACF,CALD;;AAOO,SAASU,gBAAT,CAA0BC,QAA1B,EAA+D;AACpE;AACAb,EAAAA,eAAe,CAACc,IAAhB,CAAqBD,QAArB,EAFoE,CAGpE;;AACAJ,EAAAA,oBAAoB,GAJgD,CAMpE;;AACA,MAAI;AAAA;;AACF,6BAAAlB,cAAc,CAACqB,gBAAf,qFAAArB,cAAc;AACf,GAFD,CAEE,OAAOgB,KAAP,EAAc;AACdC,IAAAA,OAAO,CAACD,KAAR,CAAc,sCAAd,EAAsDA,KAAtD;AACD;AACF;;AAEM,SAASQ,uBAAT,GAAyC;AAC9C;AACAf,EAAAA,eAAe,GAAG,EAAlB,CAF8C,CAI9C;;AACA,MAAIC,kBAAJ,EAAwB;AACtBA,IAAAA,kBAAkB,CAACe,MAAnB;AACAf,IAAAA,kBAAkB,GAAG,IAArB;AACD;;AAEDJ,EAAAA,OAAO,CAACa,kBAAR,CAA2BX,UAA3B,EAV8C,CAY9C;;AACA,MAAI;AAAA;;AACF,6BAAAR,cAAc,CAACwB,uBAAf,qFAAAxB,cAAc;AACf,GAFD,CAEE,OAAOgB,KAAP,EAAc;AACdC,IAAAA,OAAO,CAACD,KAAR,CAAc,wCAAd,EAAwDA,KAAxD;AACD;AACF;;eAEc;AACbK,EAAAA,gBADa;AAEbG,EAAAA;AAFa,C","sourcesContent":["// src/HyperKycEvents.ts\nimport { NativeModules, NativeEventEmitter, EmitterSubscription, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst NativeHyperKyc = NativeModules.Hyperkyc\n ? NativeModules.Hyperkyc\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nconst emitter = new NativeEventEmitter(NativeHyperKyc);\nconst EVENT_NAME = 'onHyperKycEvent';\n\n// Array to store all client callbacks\nlet clientListeners: Array<(data: any) => void> = [];\n// Single subscription to native events\nlet nativeSubscription: EmitterSubscription | null = null;\n\n// Function to broadcast events to all client listeners\nconst broadcastEvent = (data: any) => {\n // Run the broadcast on a background thread using setTimeout\n setTimeout(() => {\n clientListeners.forEach(listener => {\n try {\n listener(data);\n } catch (error) {\n console.error('Error in HyperKYC event listener:', error);\n }\n });\n }, 0);\n};\n\n// Function to ensure native listener is set up\nconst ensureNativeListener = () => {\n if (!nativeSubscription) {\n emitter.removeAllListeners(EVENT_NAME);\n nativeSubscription = emitter.addListener(EVENT_NAME, broadcastEvent);\n }\n};\n\nexport function addEventListener(callback: (data: any) => void): void {\n // Add callback to client listeners\n clientListeners.push(callback);\n // Ensure native listener is set up\n ensureNativeListener();\n\n // Call native method to remove all listeners\n try {\n NativeHyperKyc.addEventListener?.();\n } catch (error) {\n console.error('Error adding native event listeners:', error);\n }\n}\n\nexport function removeAllEventListeners(): void {\n // Clear all client listeners\n clientListeners = [];\n \n // Remove native subscription\n if (nativeSubscription) {\n nativeSubscription.remove();\n nativeSubscription = null;\n }\n\n emitter.removeAllListeners(EVENT_NAME);\n \n // Call native method to remove all listeners\n try {\n NativeHyperKyc.removeAllEventListeners?.();\n } catch (error) {\n console.error('Error removing native event listeners:', error);\n }\n}\n\nexport default {\n addEventListener,\n removeAllEventListeners,\n};"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,10 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.default = exports.addEventListener = void 0;
|
|
6
7
|
exports.multiply = multiply;
|
|
8
|
+
exports.removeAllEventListeners = void 0;
|
|
7
9
|
|
|
8
10
|
var _reactNative = require("react-native");
|
|
9
11
|
|
|
12
|
+
var _HyperKycEvents = _interopRequireDefault(require("./HyperKycEvents"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// src/index.tsx
|
|
10
17
|
const LINKING_ERROR = `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
11
18
|
ios: "- You have run 'pod install'\n",
|
|
12
19
|
default: ''
|
|
@@ -17,8 +24,22 @@ const HyperkycSdk = _reactNative.NativeModules.HyperkycSdk ? _reactNative.Native
|
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
});
|
|
27
|
+
const {
|
|
28
|
+
addEventListener,
|
|
29
|
+
removeAllEventListeners
|
|
30
|
+
} = _HyperKycEvents.default; // Export any native methods if needed
|
|
31
|
+
|
|
32
|
+
exports.removeAllEventListeners = removeAllEventListeners;
|
|
33
|
+
exports.addEventListener = addEventListener;
|
|
20
34
|
|
|
21
35
|
function multiply(a, b) {
|
|
22
36
|
return HyperkycSdk.multiply(a, b);
|
|
23
|
-
}
|
|
37
|
+
} // You can also export the full native module if needed:
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var _default = { ...HyperkycSdk,
|
|
41
|
+
addEventListener,
|
|
42
|
+
removeAllEventListeners
|
|
43
|
+
};
|
|
44
|
+
exports.default = _default;
|
|
24
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["LINKING_ERROR","Platform","select","ios","default","HyperkycSdk","NativeModules","Proxy","get","Error","multiply","a","b"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["LINKING_ERROR","Platform","select","ios","default","HyperkycSdk","NativeModules","Proxy","get","Error","addEventListener","removeAllEventListeners","HyperKycEvents","multiply","a","b"],"mappings":";;;;;;;;;AACA;;AACA;;;;AAFA;AAIA,MAAMA,aAAa,GAChB,oFAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,WAAW,GAAGC,2BAAcD,WAAd,GAChBC,2BAAcD,WADE,GAEhB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWO,MAAM;AAAEU,EAAAA,gBAAF;AAAoBC,EAAAA;AAApB,IAAgDC,uBAAtD,C,CAEP;;;;;AACO,SAASC,QAAT,CAAkBC,CAAlB,EAA6BC,CAA7B,EAAyD;AAC9D,SAAOV,WAAW,CAACQ,QAAZ,CAAqBC,CAArB,EAAwBC,CAAxB,CAAP;AACD,C,CAED;;;eACe,EACb,GAAGV,WADU;AAEbK,EAAAA,gBAFa;AAGbC,EAAAA;AAHa,C","sourcesContent":["// src/index.tsx\nimport { NativeModules, Platform } from 'react-native';\nimport HyperKycEvents from './HyperKycEvents';\n\nconst LINKING_ERROR =\n `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst HyperkycSdk = NativeModules.HyperkycSdk\n ? NativeModules.HyperkycSdk\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const { addEventListener, removeAllEventListeners } = HyperKycEvents;\n\n// Export any native methods if needed\nexport function multiply(a: number, b: number): Promise<number> {\n return HyperkycSdk.multiply(a, b);\n}\n\n// You can also export the full native module if needed:\nexport default {\n ...HyperkycSdk,\n addEventListener,\n removeAllEventListeners,\n};"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/HyperKycEvents.ts
|
|
2
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
3
|
+
const LINKING_ERROR = `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
4
|
+
ios: "- You have run 'pod install'\n",
|
|
5
|
+
default: ''
|
|
6
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
7
|
+
const NativeHyperKyc = NativeModules.Hyperkyc ? NativeModules.Hyperkyc : new Proxy({}, {
|
|
8
|
+
get() {
|
|
9
|
+
throw new Error(LINKING_ERROR);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
});
|
|
13
|
+
const emitter = new NativeEventEmitter(NativeHyperKyc);
|
|
14
|
+
const EVENT_NAME = 'onHyperKycEvent'; // Array to store all client callbacks
|
|
15
|
+
|
|
16
|
+
let clientListeners = []; // Single subscription to native events
|
|
17
|
+
|
|
18
|
+
let nativeSubscription = null; // Function to broadcast events to all client listeners
|
|
19
|
+
|
|
20
|
+
const broadcastEvent = data => {
|
|
21
|
+
// Run the broadcast on a background thread using setTimeout
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
clientListeners.forEach(listener => {
|
|
24
|
+
try {
|
|
25
|
+
listener(data);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error('Error in HyperKYC event listener:', error);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}, 0);
|
|
31
|
+
}; // Function to ensure native listener is set up
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const ensureNativeListener = () => {
|
|
35
|
+
if (!nativeSubscription) {
|
|
36
|
+
emitter.removeAllListeners(EVENT_NAME);
|
|
37
|
+
nativeSubscription = emitter.addListener(EVENT_NAME, broadcastEvent);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export function addEventListener(callback) {
|
|
42
|
+
// Add callback to client listeners
|
|
43
|
+
clientListeners.push(callback); // Ensure native listener is set up
|
|
44
|
+
|
|
45
|
+
ensureNativeListener(); // Call native method to remove all listeners
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
var _NativeHyperKyc$addEv;
|
|
49
|
+
|
|
50
|
+
(_NativeHyperKyc$addEv = NativeHyperKyc.addEventListener) === null || _NativeHyperKyc$addEv === void 0 ? void 0 : _NativeHyperKyc$addEv.call(NativeHyperKyc);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error adding native event listeners:', error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function removeAllEventListeners() {
|
|
56
|
+
// Clear all client listeners
|
|
57
|
+
clientListeners = []; // Remove native subscription
|
|
58
|
+
|
|
59
|
+
if (nativeSubscription) {
|
|
60
|
+
nativeSubscription.remove();
|
|
61
|
+
nativeSubscription = null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
emitter.removeAllListeners(EVENT_NAME); // Call native method to remove all listeners
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
var _NativeHyperKyc$remov;
|
|
68
|
+
|
|
69
|
+
(_NativeHyperKyc$remov = NativeHyperKyc.removeAllEventListeners) === null || _NativeHyperKyc$remov === void 0 ? void 0 : _NativeHyperKyc$remov.call(NativeHyperKyc);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Error removing native event listeners:', error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export default {
|
|
75
|
+
addEventListener,
|
|
76
|
+
removeAllEventListeners
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=HyperKycEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["HyperKycEvents.ts"],"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","NativeHyperKyc","Hyperkyc","Proxy","get","Error","emitter","EVENT_NAME","clientListeners","nativeSubscription","broadcastEvent","data","setTimeout","forEach","listener","error","console","ensureNativeListener","removeAllListeners","addListener","addEventListener","callback","push","removeAllEventListeners","remove"],"mappings":"AAAA;AACA,SAASA,aAAT,EAAwBC,kBAAxB,EAAiEC,QAAjE,QAAiF,cAAjF;AAEA,MAAMC,aAAa,GAChB,oFAAD,GACAD,QAAQ,CAACE,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,cAAc,GAAGP,aAAa,CAACQ,QAAd,GACnBR,aAAa,CAACQ,QADK,GAEnB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUR,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA,MAAMS,OAAO,GAAG,IAAIX,kBAAJ,CAAuBM,cAAvB,CAAhB;AACA,MAAMM,UAAU,GAAG,iBAAnB,C,CAEA;;AACA,IAAIC,eAA2C,GAAG,EAAlD,C,CACA;;AACA,IAAIC,kBAA8C,GAAG,IAArD,C,CAEA;;AACA,MAAMC,cAAc,GAAIC,IAAD,IAAe;AACpC;AACAC,EAAAA,UAAU,CAAC,MAAM;AACfJ,IAAAA,eAAe,CAACK,OAAhB,CAAwBC,QAAQ,IAAI;AAClC,UAAI;AACFA,QAAAA,QAAQ,CAACH,IAAD,CAAR;AACD,OAFD,CAEE,OAAOI,KAAP,EAAc;AACdC,QAAAA,OAAO,CAACD,KAAR,CAAc,mCAAd,EAAmDA,KAAnD;AACD;AACF,KAND;AAOD,GARS,EAQP,CARO,CAAV;AASD,CAXD,C,CAaA;;;AACA,MAAME,oBAAoB,GAAG,MAAM;AACjC,MAAI,CAACR,kBAAL,EAAyB;AACvBH,IAAAA,OAAO,CAACY,kBAAR,CAA2BX,UAA3B;AACAE,IAAAA,kBAAkB,GAAGH,OAAO,CAACa,WAAR,CAAoBZ,UAApB,EAAgCG,cAAhC,CAArB;AACD;AACF,CALD;;AAOA,OAAO,SAASU,gBAAT,CAA0BC,QAA1B,EAA+D;AACpE;AACAb,EAAAA,eAAe,CAACc,IAAhB,CAAqBD,QAArB,EAFoE,CAGpE;;AACAJ,EAAAA,oBAAoB,GAJgD,CAMpE;;AACA,MAAI;AAAA;;AACF,6BAAAhB,cAAc,CAACmB,gBAAf,qFAAAnB,cAAc;AACf,GAFD,CAEE,OAAOc,KAAP,EAAc;AACdC,IAAAA,OAAO,CAACD,KAAR,CAAc,sCAAd,EAAsDA,KAAtD;AACD;AACF;AAED,OAAO,SAASQ,uBAAT,GAAyC;AAC9C;AACAf,EAAAA,eAAe,GAAG,EAAlB,CAF8C,CAI9C;;AACA,MAAIC,kBAAJ,EAAwB;AACtBA,IAAAA,kBAAkB,CAACe,MAAnB;AACAf,IAAAA,kBAAkB,GAAG,IAArB;AACD;;AAEDH,EAAAA,OAAO,CAACY,kBAAR,CAA2BX,UAA3B,EAV8C,CAY9C;;AACA,MAAI;AAAA;;AACF,6BAAAN,cAAc,CAACsB,uBAAf,qFAAAtB,cAAc;AACf,GAFD,CAEE,OAAOc,KAAP,EAAc;AACdC,IAAAA,OAAO,CAACD,KAAR,CAAc,wCAAd,EAAwDA,KAAxD;AACD;AACF;AAED,eAAe;AACbK,EAAAA,gBADa;AAEbG,EAAAA;AAFa,CAAf","sourcesContent":["// src/HyperKycEvents.ts\nimport { NativeModules, NativeEventEmitter, EmitterSubscription, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst NativeHyperKyc = NativeModules.Hyperkyc\n ? NativeModules.Hyperkyc\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nconst emitter = new NativeEventEmitter(NativeHyperKyc);\nconst EVENT_NAME = 'onHyperKycEvent';\n\n// Array to store all client callbacks\nlet clientListeners: Array<(data: any) => void> = [];\n// Single subscription to native events\nlet nativeSubscription: EmitterSubscription | null = null;\n\n// Function to broadcast events to all client listeners\nconst broadcastEvent = (data: any) => {\n // Run the broadcast on a background thread using setTimeout\n setTimeout(() => {\n clientListeners.forEach(listener => {\n try {\n listener(data);\n } catch (error) {\n console.error('Error in HyperKYC event listener:', error);\n }\n });\n }, 0);\n};\n\n// Function to ensure native listener is set up\nconst ensureNativeListener = () => {\n if (!nativeSubscription) {\n emitter.removeAllListeners(EVENT_NAME);\n nativeSubscription = emitter.addListener(EVENT_NAME, broadcastEvent);\n }\n};\n\nexport function addEventListener(callback: (data: any) => void): void {\n // Add callback to client listeners\n clientListeners.push(callback);\n // Ensure native listener is set up\n ensureNativeListener();\n\n // Call native method to remove all listeners\n try {\n NativeHyperKyc.addEventListener?.();\n } catch (error) {\n console.error('Error adding native event listeners:', error);\n }\n}\n\nexport function removeAllEventListeners(): void {\n // Clear all client listeners\n clientListeners = [];\n \n // Remove native subscription\n if (nativeSubscription) {\n nativeSubscription.remove();\n nativeSubscription = null;\n }\n\n emitter.removeAllListeners(EVENT_NAME);\n \n // Call native method to remove all listeners\n try {\n NativeHyperKyc.removeAllEventListeners?.();\n } catch (error) {\n console.error('Error removing native event listeners:', error);\n }\n}\n\nexport default {\n addEventListener,\n removeAllEventListeners,\n};"]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// src/index.tsx
|
|
1
2
|
import { NativeModules, Platform } from 'react-native';
|
|
3
|
+
import HyperKycEvents from './HyperKycEvents';
|
|
2
4
|
const LINKING_ERROR = `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
5
|
ios: "- You have run 'pod install'\n",
|
|
4
6
|
default: ''
|
|
@@ -9,7 +11,17 @@ const HyperkycSdk = NativeModules.HyperkycSdk ? NativeModules.HyperkycSdk : new
|
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
});
|
|
14
|
+
export const {
|
|
15
|
+
addEventListener,
|
|
16
|
+
removeAllEventListeners
|
|
17
|
+
} = HyperKycEvents; // Export any native methods if needed
|
|
18
|
+
|
|
12
19
|
export function multiply(a, b) {
|
|
13
20
|
return HyperkycSdk.multiply(a, b);
|
|
14
|
-
}
|
|
21
|
+
} // You can also export the full native module if needed:
|
|
22
|
+
|
|
23
|
+
export default { ...HyperkycSdk,
|
|
24
|
+
addEventListener,
|
|
25
|
+
removeAllEventListeners
|
|
26
|
+
};
|
|
15
27
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["NativeModules","Platform","LINKING_ERROR","select","ios","default","HyperkycSdk","Proxy","get","Error","multiply","a","b"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AAEA,MAAMC,aAAa,GAChB,oFAAD,
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["NativeModules","Platform","HyperKycEvents","LINKING_ERROR","select","ios","default","HyperkycSdk","Proxy","get","Error","addEventListener","removeAllEventListeners","multiply","a","b"],"mappings":"AAAA;AACA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,cAAxC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AAEA,MAAMC,aAAa,GAChB,oFAAD,GACAF,QAAQ,CAACG,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,WAAW,GAAGP,aAAa,CAACO,WAAd,GAChBP,aAAa,CAACO,WADE,GAEhB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUP,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAWA,OAAO,MAAM;AAAEQ,EAAAA,gBAAF;AAAoBC,EAAAA;AAApB,IAAgDV,cAAtD,C,CAEP;;AACA,OAAO,SAASW,QAAT,CAAkBC,CAAlB,EAA6BC,CAA7B,EAAyD;AAC9D,SAAOR,WAAW,CAACM,QAAZ,CAAqBC,CAArB,EAAwBC,CAAxB,CAAP;AACD,C,CAED;;AACA,eAAe,EACb,GAAGR,WADU;AAEbI,EAAAA,gBAFa;AAGbC,EAAAA;AAHa,CAAf","sourcesContent":["// src/index.tsx\nimport { NativeModules, Platform } from 'react-native';\nimport HyperKycEvents from './HyperKycEvents';\n\nconst LINKING_ERROR =\n `The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst HyperkycSdk = NativeModules.HyperkycSdk\n ? NativeModules.HyperkycSdk\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const { addEventListener, removeAllEventListeners } = HyperKycEvents;\n\n// Export any native methods if needed\nexport function multiply(a: number, b: number): Promise<number> {\n return HyperkycSdk.multiply(a, b);\n}\n\n// You can also export the full native module if needed:\nexport default {\n ...HyperkycSdk,\n addEventListener,\n removeAllEventListeners,\n};"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function addEventListener(callback: (data: any) => void): void;
|
|
2
|
+
export declare function removeAllEventListeners(): void;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
addEventListener: typeof addEventListener;
|
|
5
|
+
removeAllEventListeners: typeof removeAllEventListeners;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
+
export declare const addEventListener: typeof import("./HyperKycEvents").addEventListener, removeAllEventListeners: typeof import("./HyperKycEvents").removeAllEventListeners;
|
|
1
2
|
export declare function multiply(a: number, b: number): Promise<number>;
|
|
3
|
+
declare const _default: any;
|
|
4
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.static_framework = true
|
|
18
18
|
|
|
19
19
|
s.dependency "React-Core"
|
|
20
|
-
s.dependency "HyperKYC", "0.
|
|
20
|
+
s.dependency "HyperKYC", "0.47.0"
|
|
21
21
|
# Need these lines to support HyperKYC framework
|
|
22
22
|
s.preserve_paths = 'HyperKYC.framework'
|
|
23
23
|
s.xcconfig = { 'OTHER_LDFLAGS' => '-framework HyperKYC' }
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/HyperKycEvents.ts
|
|
2
|
+
import { NativeModules, NativeEventEmitter, EmitterSubscription, Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const LINKING_ERROR =
|
|
5
|
+
`The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
6
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
7
|
+
'- You rebuilt the app after installing the package\n' +
|
|
8
|
+
'- You are not using Expo managed workflow\n';
|
|
9
|
+
|
|
10
|
+
const NativeHyperKyc = NativeModules.Hyperkyc
|
|
11
|
+
? NativeModules.Hyperkyc
|
|
12
|
+
: new Proxy(
|
|
13
|
+
{},
|
|
14
|
+
{
|
|
15
|
+
get() {
|
|
16
|
+
throw new Error(LINKING_ERROR);
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const emitter = new NativeEventEmitter(NativeHyperKyc);
|
|
22
|
+
const EVENT_NAME = 'onHyperKycEvent';
|
|
23
|
+
|
|
24
|
+
// Array to store all client callbacks
|
|
25
|
+
let clientListeners: Array<(data: any) => void> = [];
|
|
26
|
+
// Single subscription to native events
|
|
27
|
+
let nativeSubscription: EmitterSubscription | null = null;
|
|
28
|
+
|
|
29
|
+
// Function to broadcast events to all client listeners
|
|
30
|
+
const broadcastEvent = (data: any) => {
|
|
31
|
+
// Run the broadcast on a background thread using setTimeout
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
clientListeners.forEach(listener => {
|
|
34
|
+
try {
|
|
35
|
+
listener(data);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error('Error in HyperKYC event listener:', error);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}, 0);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Function to ensure native listener is set up
|
|
44
|
+
const ensureNativeListener = () => {
|
|
45
|
+
if (!nativeSubscription) {
|
|
46
|
+
emitter.removeAllListeners(EVENT_NAME);
|
|
47
|
+
nativeSubscription = emitter.addListener(EVENT_NAME, broadcastEvent);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function addEventListener(callback: (data: any) => void): void {
|
|
52
|
+
// Add callback to client listeners
|
|
53
|
+
clientListeners.push(callback);
|
|
54
|
+
// Ensure native listener is set up
|
|
55
|
+
ensureNativeListener();
|
|
56
|
+
|
|
57
|
+
// Call native method to remove all listeners
|
|
58
|
+
try {
|
|
59
|
+
NativeHyperKyc.addEventListener?.();
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error('Error adding native event listeners:', error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function removeAllEventListeners(): void {
|
|
66
|
+
// Clear all client listeners
|
|
67
|
+
clientListeners = [];
|
|
68
|
+
|
|
69
|
+
// Remove native subscription
|
|
70
|
+
if (nativeSubscription) {
|
|
71
|
+
nativeSubscription.remove();
|
|
72
|
+
nativeSubscription = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
emitter.removeAllListeners(EVENT_NAME);
|
|
76
|
+
|
|
77
|
+
// Call native method to remove all listeners
|
|
78
|
+
try {
|
|
79
|
+
NativeHyperKyc.removeAllEventListeners?.();
|
|
80
|
+
} catch (error) {
|
|
81
|
+
console.error('Error removing native event listeners:', error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default {
|
|
86
|
+
addEventListener,
|
|
87
|
+
removeAllEventListeners,
|
|
88
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// src/index.tsx
|
|
1
2
|
import { NativeModules, Platform } from 'react-native';
|
|
3
|
+
import HyperKycEvents from './HyperKycEvents';
|
|
2
4
|
|
|
3
5
|
const LINKING_ERROR =
|
|
4
6
|
`The package 'react-native-hyperkyc-sdk' doesn't seem to be linked. Make sure: \n\n` +
|
|
@@ -17,6 +19,16 @@ const HyperkycSdk = NativeModules.HyperkycSdk
|
|
|
17
19
|
}
|
|
18
20
|
);
|
|
19
21
|
|
|
22
|
+
export const { addEventListener, removeAllEventListeners } = HyperKycEvents;
|
|
23
|
+
|
|
24
|
+
// Export any native methods if needed
|
|
20
25
|
export function multiply(a: number, b: number): Promise<number> {
|
|
21
26
|
return HyperkycSdk.multiply(a, b);
|
|
22
27
|
}
|
|
28
|
+
|
|
29
|
+
// You can also export the full native module if needed:
|
|
30
|
+
export default {
|
|
31
|
+
...HyperkycSdk,
|
|
32
|
+
addEventListener,
|
|
33
|
+
removeAllEventListeners,
|
|
34
|
+
};
|