react-native-hyperkyc-sdk 2.8.0 → 3.0.0-rc.1

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.
@@ -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:2.7.0@aar', {
59
+ implementation('co.hyperverge:hyperkyc:3.0.0-rc.1@aar', {
60
60
  transitive = true
61
61
  exclude group: 'co.hyperverge', module: 'hyperdocdetect'
62
62
  exclude group: 'co.hyperverge', module: 'hypersnap-pdf'
@@ -37,41 +37,10 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule {
37
37
  private final ReactApplicationContext reactContext;
38
38
  private final int HYPERKYC_REQUEST_CODE = 56455;
39
39
  private boolean isEventListenerAdded = false;
40
- /* volatile because
41
- 1. the pendingCallback is written on JS bridge thread (launch()),
42
- 2. read/nulled on main thread (onActivityResult),
43
- 3. nulled on teardown thread (invalidate()).
44
- Without volatile, the JMM provides no happens-before guarantee — the main thread may cache a stale null
45
- and silently drop the KYC result. Works in practice without volatile (user spending more time in completing the workflow between write and read),
46
- but timing is not a JMM guarantee. */
47
- private volatile Callback pendingCallback = null;
48
- /* Contract is stateless — createIntent and parseResult carry no per-launch state. */
49
- private final HyperKyc.Contract contract = new HyperKyc.Contract();
50
- /* Registered once at construction; never re-registered. Accumulation is impossible. */
51
- private final ActivityEventListener kycActivityListener = new ActivityEventListener() {
52
- @Override
53
- public void onActivityResult(Activity activity, int requestCode,
54
- int resultCode, Intent data) {
55
- if (requestCode != HYPERKYC_REQUEST_CODE) return;
56
- Callback cb = pendingCallback;
57
- if (cb == null) return;
58
- pendingCallback = null;
59
- HyperKycResult result = contract.parseResult(resultCode, data);
60
- if (result == null) {
61
- cb.invoke(getDummyResultMap());
62
- } else {
63
- parseKYCResult(result, cb);
64
- }
65
- }
66
-
67
- @Override
68
- public void onNewIntent(Intent intent) {}
69
- };
70
40
 
71
41
  public HyperkycSdkModule(ReactApplicationContext reactContext) {
72
42
  super(reactContext);
73
43
  this.reactContext = reactContext;
74
- reactContext.addActivityEventListener(kycActivityListener);
75
44
  }
76
45
 
77
46
  @Override
@@ -106,15 +75,28 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule {
106
75
  @ReactMethod
107
76
  public void launch(ReadableMap kycConfig, Callback resultCallback) {
108
77
  ReactActivity currentActivity = (ReactActivity) getCurrentActivity();
109
- if (currentActivity == null || kycConfig == null) {
110
- resultCallback.invoke(getDummyResultMap());
111
- return;
112
- }
78
+ assert kycConfig != null;
113
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
+ });
114
98
 
115
- /* Clear any accumulated event listeners before adding a fresh one, so at most one event listener is active at any time. */
116
99
  if (isEventListenerAdded) {
117
- HyperKyc.removeAllEventListeners();
118
100
  Function1<JSONObject, Unit> listener = jsonObject -> {
119
101
  try {
120
102
  WritableMap eventMap = HyperkycSdkUtils.convertJsonToMap(jsonObject);
@@ -127,19 +109,12 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule {
127
109
  HyperKyc.addEventListener(listener);
128
110
  }
129
111
 
130
- /* Supersede any prior in-flight session — old callback silently discarded. */
131
- pendingCallback = resultCallback;
132
-
133
- Intent newIntent = contract.createIntent(currentActivity, config);
134
- currentActivity.startActivityIfNeeded(newIntent, HYPERKYC_REQUEST_CODE);
135
- }
136
-
137
- /* invalidate() is the correct teardown hook for both old and new RN architecture;
138
- onCatalystInstanceDestroy() is deprecated and removed in some RN versions. */
139
- @Override
140
- public void invalidate() {
141
- pendingCallback = null;
142
- reactContext.removeActivityEventListener(kycActivityListener);
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
+ }
143
118
  }
144
119
 
145
120
  private void sendEvent(String eventName, WritableMap eventProperties) {
@@ -206,7 +181,7 @@ public class HyperkycSdkModule extends ReactContextBaseJavaModule {
206
181
  Boolean useLocation = kycConfig.hasKey("useLocation") ? kycConfig.getBoolean("useLocation") : null;
207
182
  String uniqueId = kycConfig.hasKey("uniqueId") ? kycConfig.getString("uniqueId") : null;
208
183
  Map<String, String> metadata = new HashMap<>();
209
- metadata.put("sdk-version", "2.7.0");
184
+ metadata.put("sdk-version", "3.0.0-rc.1");
210
185
  metadata.put("sdk-type", "React Native");
211
186
  if (accessToken == null) {
212
187
  assert appId != null;
@@ -45,7 +45,7 @@ class Hyperkyc: RCTEventEmitter {
45
45
  let useLocation = _config["useLocation"] as? Bool
46
46
  let uniqueId = _config["uniqueId"] as? String
47
47
  let metadata: [String: String] = [
48
- "sdk-version": "2.7.0",
48
+ "sdk-version": "3.0.0-rc.1",
49
49
  "sdk-type": "React Native"
50
50
  ]
51
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-hyperkyc-sdk",
3
- "version": "2.8.0",
3
+ "version": "3.0.0-rc.1",
4
4
  "description": "React Native wrapper for HyperKYC SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -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", "1.3.0"
20
+ s.dependency "HyperKYC", "1.4.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' }