uqudosdk-react-native 2.2.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ ## 2.2.1
2
+
3
+ * Minor bug fixes
4
+
5
+ ## 2.2.0
6
+
7
+ * Added new document type Senegal National ID and Uganda Voter ID
8
+ * Added support to read the chip of Senegal ID through NFC
9
+ * Added new configuration option enableAgeVerification for the document scanning that allows to reject the scan if the age is not above or equals the one defined in the configuration
10
+ * We replaced the 5 images in the facial recognition popup when the face doesn't match. The images can now be replaced with your own images
11
+ * Improved glare detection during document scanning
12
+ * Removed additional dependency for the Android SDK
13
+ * Minor bug fixes and minor improvements
package/COPYRIGHT.md ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) uqudo 2022
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2022] [uqudo]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # uqudo SDK ReactNative plugin
2
+
3
+ The Official uqudo SDK wrapper for the Android and iOS SDKs.\
4
+ Onboard new users faster, easier, and cheaper with an experience that seamlessly fits into your onboarding journey. Fully supported across the Middle East & Africa.
5
+
6
+ ### Platform specifics
7
+
8
+ Plugin implementation is in folder `uqudoBuilder`, while platform specific implementations are in `android` and `ios` folders.
9
+
10
+ #### Android
11
+
12
+ https://docs.uqudo.com
13
+
14
+ #### iOS
15
+
16
+ https://docs.uqudo.com
17
+
18
+ ## Licensing
19
+
20
+ - In order to use the SDK you require a valid license. Contact us at https://uqudo.com/contact-us/
@@ -0,0 +1,37 @@
1
+ def DEFAULT_COMPILE_SDK_VERSION = 30
2
+ def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2'
3
+ def DEFAULT_MIN_SDK_VERSION = 21
4
+ def DEFAULT_TARGET_SDK_VERSION = 30
5
+
6
+ def safeExtGet(prop, fallback) {
7
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
8
+ }
9
+
10
+ apply plugin: 'com.android.library'
11
+
12
+
13
+ rootProject.allprojects {
14
+ repositories {
15
+ google()
16
+ maven { url "https://rm.dev.uqudo.io/repository/uqudo-public/" }
17
+ }
18
+ }
19
+
20
+ android {
21
+ compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
22
+ buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
23
+ defaultConfig {
24
+ minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
25
+ targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
26
+ versionCode 1
27
+ versionName "1.0"
28
+ }
29
+ lintOptions {
30
+ abortOnError false
31
+ }
32
+ }
33
+
34
+ dependencies {
35
+ implementation 'com.facebook.react:react-native:+'
36
+ implementation 'io.uqudo.sdk:Uqudo:2.2.1'
37
+ }
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="io.sdk.uqudoid">
3
+
4
+ </manifest>
@@ -0,0 +1,399 @@
1
+ package io.sdk.uqudoid;
2
+
3
+ import android.app.Activity;
4
+ import android.content.Intent;
5
+ import android.util.Log;
6
+ import android.util.SparseArray;
7
+ import android.content.Context;
8
+ import androidx.appcompat.app.AppCompatDelegate;
9
+ import com.facebook.react.bridge.ActivityEventListener;
10
+ import com.facebook.react.bridge.Arguments;
11
+ import com.facebook.react.bridge.Promise;
12
+ import com.facebook.react.bridge.ReactApplicationContext;
13
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
+ import com.facebook.react.bridge.ReactMethod;
15
+ import com.facebook.react.bridge.WritableMap;
16
+ import com.facebook.react.modules.core.DeviceEventManagerModule;
17
+
18
+ import org.jetbrains.annotations.NotNull;
19
+ import org.json.JSONArray;
20
+ import org.json.JSONObject;
21
+ import java.util.UUID;
22
+ import org.json.JSONException;
23
+ import java.util.ArrayList;
24
+ import java.util.Arrays;
25
+ import java.util.List;
26
+
27
+
28
+ import io.uqudo.sdk.core.DocumentBuilder;
29
+ import io.uqudo.sdk.core.SessionStatus;
30
+ import io.uqudo.sdk.core.SessionStatusCode;
31
+ import io.uqudo.sdk.core.UqudoBuilder;
32
+ import io.uqudo.sdk.core.UqudoSDK;
33
+ import io.uqudo.sdk.core.analytics.Trace;
34
+ import io.uqudo.sdk.core.analytics.Tracer;
35
+ import io.uqudo.sdk.core.builder.BackgroundCheckConfigurationBuilder;
36
+ import io.uqudo.sdk.core.builder.FacialRecognitionConfigurationBuilder;
37
+ import io.uqudo.sdk.core.builder.ReadingConfigurationBuilder;
38
+ import io.uqudo.sdk.core.domain.model.BackgroundCheckType;
39
+ import io.uqudo.sdk.core.domain.model.Document;
40
+ import io.uqudo.sdk.core.domain.model.DocumentType;
41
+
42
+ public class UqudoIdModule extends ReactContextBaseJavaModule implements ActivityEventListener {
43
+
44
+ private final ReactApplicationContext context;
45
+ private final SparseArray<Promise> mPromises;
46
+ public static final int REQUEST_CODE_ENROLLMENT = 1001;
47
+ public static final int REQUEST_CODE_ACCOUNT_RECOVERY = 1002;
48
+ public static final int REQUEST_CODE_FACE_SESSION = 1003;
49
+
50
+ public UqudoIdModule(ReactApplicationContext reactContext) {
51
+ super(reactContext);
52
+ this.context = reactContext;
53
+ mPromises = new SparseArray<>();
54
+ }
55
+
56
+ @Override
57
+ public String getName() {
58
+ return "UqudoId";
59
+ }
60
+
61
+ @Override
62
+ public void initialize() {
63
+ super.initialize();
64
+ getReactApplicationContext().addActivityEventListener(this);
65
+ }
66
+
67
+ @Override
68
+ public void onCatalystInstanceDestroy() {
69
+ super.onCatalystInstanceDestroy();
70
+ getReactApplicationContext().removeActivityEventListener(this);
71
+ }
72
+
73
+ @ReactMethod
74
+ public void init() {
75
+ UqudoSDK.init(context, new TraceObject());
76
+ }
77
+
78
+ private class TraceObject implements Tracer {
79
+ @Override
80
+ public void trace(@NotNull Trace trace) {
81
+ try {
82
+ JSONObject json = new JSONObject();
83
+ json.put("category", trace.getCategory());
84
+ json.put("sessionId", trace.getSessionId());
85
+ json.put("event", trace.getEvent());
86
+ json.put("page", trace.getPage());
87
+ json.put("statusCode", trace.getStatusCode());
88
+ json.put("status", trace.getStatus());
89
+ json.put("message", trace.getStatusMessage());
90
+ json.put("timestamp", trace.getTimestamp());
91
+ json.put("documentType", trace.getDocumentType());
92
+ String data = json.toString();
93
+ context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
94
+ .emit("TraceEvent", data);
95
+ } catch (Exception e) {
96
+ Log.e("UqudoIdModule", e.getMessage(), e);
97
+ }
98
+ }
99
+ }
100
+
101
+ @ReactMethod
102
+ public void setLocale(String locale) {
103
+ UqudoSDK.setLocale(context, locale);
104
+ }
105
+
106
+ @ReactMethod
107
+ public void enroll(String message, Promise promise) {
108
+ if (message != null && message.length() > 0) {
109
+ try {
110
+ JSONObject json = new JSONObject(message);
111
+ UqudoBuilder.Enrollment enrollment = new UqudoBuilder.Enrollment();
112
+ if (json.has("isSecuredWindowsDisabled") && json.getBoolean("isSecuredWindowsDisabled")) {
113
+ enrollment.disableSecureWindow();
114
+ }
115
+ if (json.has("isRootedDeviceAllowed") && json.getBoolean("isRootedDeviceAllowed")) {
116
+ enrollment.enableRootedDeviceUsage();
117
+ }
118
+ if (json.has("nonce")) {
119
+ enrollment.setNonce(json.getString("nonce"));
120
+ }
121
+ if (json.has("sessionId")) {
122
+ enrollment.setSessionId(json.getString("sessionId"));
123
+ }
124
+ if (json.has("userIdentifier")) {
125
+ enrollment.setUserIdentifier(UUID.fromString(json.getString("userIdentifier")));
126
+ }
127
+ if (json.has("isReturnDataForIncompleteSession") && json.getBoolean("isReturnDataForIncompleteSession")) {
128
+ enrollment.returnDataForIncompleteSession();
129
+ }
130
+ if (json.has("facialRecognitionSpecification")) {
131
+ FacialRecognitionConfigurationBuilder faceBuilder = new FacialRecognitionConfigurationBuilder();
132
+ JSONObject faceObject = json.getJSONObject("facialRecognitionSpecification");
133
+ if (faceObject.has("enrollFace") && faceObject.getBoolean("enrollFace")) {
134
+ faceBuilder.enrollFace();
135
+ }
136
+ if (faceObject.has("scanMinimumMatchLevel") && faceObject.getInt("scanMinimumMatchLevel") > 0) {
137
+ faceBuilder.setScanMinimumMatchLevel(faceObject.getInt("scanMinimumMatchLevel"));
138
+ }
139
+ if (faceObject.has("readMinimumMatchLevel") && faceObject.getInt("readMinimumMatchLevel") > 0) {
140
+ faceBuilder.setReadMinimumMatchLevel(faceObject.getInt("readMinimumMatchLevel"));
141
+ }
142
+ if (faceObject.has("maxAttempts") && faceObject.getInt("maxAttempts") > 0) {
143
+ faceBuilder.setMaxAttempts(faceObject.getInt("maxAttempts"));
144
+ }
145
+
146
+ enrollment.enableFacialRecognition(faceBuilder.build());
147
+ }
148
+ if (json.has("lookupConfiguration")) {
149
+ JSONObject lookupObject = json.getJSONObject("lookupConfiguration");
150
+ if (lookupObject.has("documentList")) {
151
+ JSONArray lookupDocuments = lookupObject.getJSONArray("documentList");
152
+ if (lookupDocuments.length() > 0) {
153
+ DocumentType[] documents = new DocumentType[lookupDocuments.length()];
154
+ for (int i = 0; i < lookupDocuments.length(); i++) {
155
+ String parsedDocument = lookupDocuments.getString(i);
156
+ documents[i] = DocumentType.valueOf(parsedDocument);
157
+ }
158
+ enrollment.enableLookup(documents);
159
+ } else {
160
+ enrollment.enableLookup();
161
+ }
162
+ } else {
163
+ enrollment.enableLookup();
164
+ }
165
+ }
166
+ if (json.has("backgroundCheckConfiguration")) {
167
+ BackgroundCheckConfigurationBuilder backgroundCheckConfigurationBuilder = new BackgroundCheckConfigurationBuilder();
168
+ JSONObject backgroundObject = json.getJSONObject("backgroundCheckConfiguration");
169
+ if (backgroundObject.has("disableConsent") && backgroundObject.getBoolean("disableConsent")) {
170
+ backgroundCheckConfigurationBuilder.disableConsent();
171
+ }
172
+ if (backgroundObject.has("backgroundCheckType")) {
173
+ backgroundCheckConfigurationBuilder.setBackgroundCheckType(BackgroundCheckType.valueOf(backgroundObject.getString("backgroundCheckType")));
174
+ }
175
+ if (backgroundObject.has("monitoringEnabled") && backgroundObject.getBoolean("monitoringEnabled")) {
176
+ backgroundCheckConfigurationBuilder.enableMonitoring();
177
+ }
178
+ if (backgroundObject.has("skipView") && backgroundObject.getBoolean("skipView")) {
179
+ backgroundCheckConfigurationBuilder.skipView();
180
+ }
181
+ enrollment.enableBackgroundCheck(backgroundCheckConfigurationBuilder.build());
182
+ }
183
+ enrollment.setToken(json.getString("authorizationToken"));
184
+ JSONArray documentList = json.getJSONArray("documentList");
185
+ for (int i = 0; i < documentList.length(); i++) {
186
+ JSONObject documentJson = documentList.getJSONObject(i);
187
+ DocumentBuilder documentBuilder = new DocumentBuilder(context);
188
+ documentBuilder.setDocumentType(DocumentType.valueOf(documentJson.getString("documentType")));
189
+ if (documentJson.has("isHelpPageDisabled") && documentJson.getBoolean("isHelpPageDisabled")) {
190
+ documentBuilder.disableHelpPage();
191
+ }
192
+ if (documentJson.has("isExpiredDocumentValidateDisabled") && documentJson.getBoolean("isExpiredDocumentValidateDisabled")) {
193
+ documentBuilder.disableExpiryValidation();
194
+ }
195
+ if (documentJson.has("isUserDataReviewDisabled") && documentJson.getBoolean("isUserDataReviewDisabled")) {
196
+ documentBuilder.disableUserDataReview();
197
+ }
198
+ if (documentJson.has("isFrontSideReviewEnabled") || documentJson.has("isBackSideReviewEnabled")) {
199
+ documentBuilder.enableScanReview(documentJson.optBoolean("isFrontSideReviewEnabled", false), documentJson.optBoolean("isBackSideReviewEnabled", false));
200
+ }
201
+ if (documentJson.has("isUploadEnabled") && documentJson.getBoolean("isUploadEnabled")) {
202
+ documentBuilder.enableUpload();
203
+ }
204
+ if (documentJson.has("readingConfiguration")) {
205
+ JSONObject readConfiguration = documentJson.getJSONObject("readingConfiguration");
206
+ if (readConfiguration.has("forceReading")) {
207
+ ReadingConfigurationBuilder readingConfigurationBuilder = new ReadingConfigurationBuilder();
208
+ if (readConfiguration.has("forceReading")) {
209
+ readingConfigurationBuilder.forceReading(readConfiguration.getBoolean("forceReading"));
210
+ }
211
+ if (readConfiguration.has("forceReadingIfSupported")) {
212
+ readingConfigurationBuilder.forceReadingIfSupported(readConfiguration.getBoolean("forceReadingIfSupported"));
213
+ }
214
+ if (readConfiguration.has("timeoutInSeconds")) {
215
+ readingConfigurationBuilder.forceReadingTimeout(readConfiguration.getInt("timeoutInSeconds"));
216
+ }
217
+ documentBuilder.enableReading(readingConfigurationBuilder.build());
218
+ } else {
219
+ documentBuilder.enableReading();
220
+ }
221
+ }
222
+ if (documentJson.has("faceScanMinimumMatchLevel") && documentJson.getInt("faceScanMinimumMatchLevel") > 0) {
223
+ documentBuilder.setFaceScanMinimumMatchLevel(documentJson.getInt("faceScanMinimumMatchLevel"));
224
+ }
225
+ if (documentJson.has("faceReadMinimumMatchLevel") && documentJson.getInt("faceReadMinimumMatchLevel") > 0) {
226
+ documentBuilder.setFaceReadMinimumMatchLevel(documentJson.getInt("faceReadMinimumMatchLevel"));
227
+ }
228
+ if (documentJson.has("minimumAge") && documentJson.getInt("minimumAge") > 0) {
229
+ documentBuilder.enableAgeVerification(documentJson.getInt("minimumAge"));
230
+ }
231
+
232
+ Document document = documentBuilder.build();
233
+ enrollment.add(document);
234
+ }
235
+ Intent intent = enrollment.build(context);
236
+ if (json.has("appearanceMode")) {
237
+ if ("LIGHT".equals(json.getString("appearanceMode"))) {
238
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
239
+ } else if ("DARK".equals(json.getString("appearanceMode"))) {
240
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
241
+ } else if ("SYSTEM".equals(json.getString("appearanceMode"))) {
242
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
243
+ }
244
+ }else{
245
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
246
+ }
247
+ getReactApplicationContext().startActivityForResult(intent, REQUEST_CODE_ENROLLMENT, null);
248
+ mPromises.put(REQUEST_CODE_ENROLLMENT, promise);
249
+ } catch (Exception e) {
250
+ Log.e("UqudoIdModule", e.getMessage(), e);
251
+ sendError(promise, SessionStatusCode.UNEXPECTED_ERROR.name(), e.getMessage(), null);
252
+ }
253
+ } else {
254
+ sendError(promise, SessionStatusCode.UNEXPECTED_ERROR.name(), "Expected enrollment object as argument.", null);
255
+ }
256
+ }
257
+
258
+ @ReactMethod
259
+ public void recover(String message, Promise promise) {
260
+ if (message != null && message.length() > 0) {
261
+ try {
262
+ JSONObject json = new JSONObject(message);
263
+ UqudoBuilder.AccountRecovery recovery = new UqudoBuilder.AccountRecovery();
264
+ recovery.setToken(json.getString("token"));
265
+ recovery.setEnrollmentIdentifier(json.getString("enrollmentIdentifier"));
266
+ if (json.has("nonce")) {
267
+ recovery.setNonce(json.getString("nonce"));
268
+ }
269
+ if (json.has("isRootedDeviceAllowed")) {
270
+ recovery.enableRootedDeviceUsage();
271
+ }
272
+ if (json.has("isSecuredWindowsDisabled")) {
273
+ recovery.disableSecureWindow();
274
+ }
275
+ if (json.has("minimumMatchLevel") && json.getInt("minimumMatchLevel") > 0) {
276
+ recovery.setMinimumMatchLevel(json.getInt("minimumMatchLevel"));
277
+ }
278
+ if (json.has("maxAttempts") && json.getInt("maxAttempts") > 0) {
279
+ recovery.setMaxAttempts(json.getInt("maxAttempts"));
280
+ }
281
+ if (json.has("isReturnDataForIncompleteSession") && json.getBoolean("isReturnDataForIncompleteSession")) {
282
+ recovery.returnDataForIncompleteSession();
283
+ }
284
+ Intent intent = recovery.build(context);
285
+
286
+ if (json.has("appearanceMode")) {
287
+ if ("LIGHT".equals(json.getString("appearanceMode"))) {
288
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
289
+ } else if ("DARK".equals(json.getString("appearanceMode"))) {
290
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
291
+ } else if ("SYSTEM".equals(json.getString("appearanceMode"))) {
292
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
293
+ }
294
+ }else{
295
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
296
+ }
297
+ getReactApplicationContext().startActivityForResult(intent, REQUEST_CODE_ACCOUNT_RECOVERY, null);
298
+ mPromises.put(REQUEST_CODE_ACCOUNT_RECOVERY, promise);
299
+ } catch (Exception e) {
300
+ Log.e("UqudoIdModule", e.getMessage(), e);
301
+ sendError(promise, SessionStatusCode.UNEXPECTED_ERROR.name(), e.getMessage(), null);
302
+ }
303
+ } else {
304
+ sendError(promise, SessionStatusCode.UNEXPECTED_ERROR.name(), "Expected account recovery object as argument.", null);
305
+ }
306
+ }
307
+
308
+ @ReactMethod
309
+ public void faceSession(String configuration, Promise promise) {
310
+ if (configuration != null && configuration.length() > 0) {
311
+ try {
312
+ JSONObject json = new JSONObject(configuration);
313
+ UqudoBuilder.FaceSession faceSession = new UqudoBuilder.FaceSession();
314
+ faceSession.setToken(json.getString("token"));
315
+ faceSession.setSessionId(json.getString("sessionId"));
316
+ if (json.has("nonce")) {
317
+ faceSession.setNonce(json.getString("nonce"));
318
+ }
319
+ if (json.has("isRootedDeviceAllowed")) {
320
+ faceSession.enableRootedDeviceUsage();
321
+ }
322
+ if (json.has("isSecuredWindowsDisabled")) {
323
+ faceSession.disableSecureWindow();
324
+ }
325
+ if (json.has("minimumMatchLevel") && json.getInt("minimumMatchLevel") > 0) {
326
+ faceSession.setMinimumMatchLevel(json.getInt("minimumMatchLevel"));
327
+ }
328
+ if (json.has("maxAttempts") && json.getInt("maxAttempts") > 0) {
329
+ faceSession.setMaxAttempts(json.getInt("maxAttempts"));
330
+ }
331
+ if (json.has("isReturnDataForIncompleteSession") && json.getBoolean("isReturnDataForIncompleteSession")) {
332
+ faceSession.returnDataForIncompleteSession();
333
+ }
334
+ Intent intent = faceSession.build(context);
335
+ if (json.has("appearanceMode")) {
336
+ if ("LIGHT".equals(json.getString("appearanceMode"))) {
337
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
338
+ } else if ("DARK".equals(json.getString("appearanceMode"))) {
339
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
340
+ } else if ("SYSTEM".equals(json.getString("appearanceMode"))) {
341
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
342
+ }
343
+ }else{
344
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
345
+ }
346
+ getReactApplicationContext().startActivityForResult(intent, REQUEST_CODE_FACE_SESSION, null);
347
+ mPromises.put(REQUEST_CODE_FACE_SESSION, promise);
348
+ } catch (Exception e) {
349
+ Log.e("UqudoIdModule", e.getMessage(), e);
350
+ sendError(promise, SessionStatusCode.UNEXPECTED_ERROR.name(), e.getMessage(), null);
351
+ }
352
+ } else {
353
+ sendError(promise, SessionStatusCode.UNEXPECTED_ERROR.name(), "Expected face session configuration as argument.", null);
354
+ }
355
+ }
356
+
357
+ private void sendError(Promise promise, String code, String message, String task) {
358
+ sendError(promise, code, message, task, null);
359
+ }
360
+
361
+ private void sendError(Promise promise, String code, String message, String task, String data) {
362
+ JSONObject error = new JSONObject();
363
+ try {
364
+ error.put("code", code);
365
+ error.put("message", message);
366
+ error.put("task", task);
367
+ error.put("data", data);
368
+ } catch (Exception e) {
369
+ e.printStackTrace();
370
+ }
371
+ promise.reject(error.toString(),"");
372
+ }
373
+
374
+ @Override
375
+ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
376
+ Promise promise = mPromises.get(requestCode);
377
+ if (promise == null) {
378
+ return;
379
+ }
380
+ if (requestCode == REQUEST_CODE_ENROLLMENT || requestCode == REQUEST_CODE_ACCOUNT_RECOVERY || requestCode == REQUEST_CODE_FACE_SESSION) {
381
+ if (resultCode == Activity.RESULT_OK) {
382
+ WritableMap map = Arguments.createMap();
383
+ map.putString("result", data.getStringExtra("data"));
384
+ promise.resolve(map);
385
+ } else if (resultCode == Activity.RESULT_CANCELED) {
386
+ if (data != null) {
387
+ SessionStatus sessionStatus = data.getParcelableExtra("key_session_status");
388
+ assert sessionStatus != null;
389
+ sendError(promise, sessionStatus.getSessionStatusCode().name(), sessionStatus.getSessionStatusCode().getMessage(), sessionStatus.getSessionTask().name(), sessionStatus.getData());
390
+ }
391
+ }
392
+ }
393
+ }
394
+
395
+ @Override
396
+ public void onNewIntent(Intent intent) {
397
+
398
+ }
399
+ }
@@ -0,0 +1,23 @@
1
+ package io.sdk.uqudoid;
2
+
3
+ import java.util.Arrays;
4
+ import java.util.Collections;
5
+ import java.util.List;
6
+
7
+ import com.facebook.react.ReactPackage;
8
+ import com.facebook.react.bridge.NativeModule;
9
+ import com.facebook.react.bridge.ReactApplicationContext;
10
+ import com.facebook.react.uimanager.ViewManager;
11
+ import com.facebook.react.bridge.JavaScriptModule;
12
+
13
+ public class UqudoIdPackage implements ReactPackage {
14
+ @Override
15
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
16
+ return Arrays.<NativeModule>asList(new UqudoIdModule(reactContext));
17
+ }
18
+
19
+ @Override
20
+ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
21
+ return Collections.emptyList();
22
+ }
23
+ }
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./uqudoBuilder/uqudo";
package/ios/MyTracer.h ADDED
@@ -0,0 +1,6 @@
1
+ #import <UqudoSDK/UQTracer.h>
2
+
3
+ @interface MyTracer : UQTracer
4
+ @property(nonatomic, retain) RCTEventEmitter *emitter;
5
+ @property(nonatomic, assign) bool hasListeners;
6
+ @end
package/ios/UqudoId.h ADDED
@@ -0,0 +1,8 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <UqudoSDK/UqudoSDK.h>
3
+ #import <React/RCTEventEmitter.h>
4
+
5
+ @interface UqudoId : RCTEventEmitter <RCTBridgeModule, UQBuilderControllerDelegate>
6
+ @property (nonatomic, strong) RCTPromiseResolveBlock promiseResolve;
7
+ @property (nonatomic, strong) RCTPromiseRejectBlock promiseReject;
8
+ @end