uqudosdk-capacitor 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/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 Capacitor 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 `src`, 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,19 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "UqudosdkCapacitor"
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['homepage']
11
+ s.author = package['author']
12
+ s.source = { :http => 'https://uqudo.com' }
13
+ s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '12.0'
15
+ s.dependency 'UqudoSDK', '2.2.1'
16
+ s.dependency 'OpenSSL-Universal', '1.1.1700'
17
+ s.dependency 'Capacitor'
18
+ s.swift_version = '5.1'
19
+ end
@@ -0,0 +1,65 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.1'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.2'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.3.0'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:4.2.1'
15
+ }
16
+ }
17
+
18
+ rootProject.allprojects {
19
+ repositories {
20
+ google()
21
+ maven { url "https://rm.dev.uqudo.io/repository/uqudo-public/" }
22
+ }
23
+ }
24
+ apply plugin: 'com.android.library'
25
+
26
+ android {
27
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 30
28
+ defaultConfig {
29
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
30
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30
31
+ versionCode 1
32
+ versionName "1.0"
33
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
34
+ }
35
+ buildTypes {
36
+ release {
37
+ minifyEnabled false
38
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
39
+ }
40
+ }
41
+ lintOptions {
42
+ abortOnError false
43
+ }
44
+ compileOptions {
45
+ sourceCompatibility JavaVersion.VERSION_1_8
46
+ targetCompatibility JavaVersion.VERSION_1_8
47
+ }
48
+ }
49
+
50
+ repositories {
51
+ google()
52
+ mavenCentral()
53
+ }
54
+
55
+
56
+ dependencies {
57
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
58
+ implementation project(':capacitor-android')
59
+ implementation "io.uqudo.sdk:Uqudo:2.2.1"
60
+
61
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
62
+ testImplementation "junit:junit:$junitVersion"
63
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
64
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
65
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="io.uqudo.sdk.id.capacitor">
3
+ </manifest>
@@ -0,0 +1,375 @@
1
+ package io.uqudo.sdk.id.capacitor;
2
+
3
+ import android.app.Activity;
4
+ import android.content.Intent;
5
+ import android.util.Log;
6
+
7
+ import androidx.activity.result.ActivityResult;
8
+ import androidx.appcompat.app.AppCompatDelegate;
9
+
10
+ import com.getcapacitor.JSObject;
11
+ import com.getcapacitor.Plugin;
12
+ import com.getcapacitor.PluginCall;
13
+ import com.getcapacitor.PluginMethod;
14
+ import com.getcapacitor.annotation.ActivityCallback;
15
+ import com.getcapacitor.annotation.CapacitorPlugin;
16
+
17
+ import org.jetbrains.annotations.NotNull;
18
+ import org.json.JSONArray;
19
+ import org.json.JSONObject;
20
+
21
+ import java.util.UUID;
22
+
23
+ import io.uqudo.sdk.core.DocumentBuilder;
24
+ import io.uqudo.sdk.core.SessionStatus;
25
+ import io.uqudo.sdk.core.SessionStatusCode;
26
+ import io.uqudo.sdk.core.UqudoBuilder;
27
+ import io.uqudo.sdk.core.UqudoSDK;
28
+ import io.uqudo.sdk.core.analytics.Trace;
29
+ import io.uqudo.sdk.core.analytics.Tracer;
30
+ import io.uqudo.sdk.core.builder.BackgroundCheckConfigurationBuilder;
31
+ import io.uqudo.sdk.core.builder.FacialRecognitionConfigurationBuilder;
32
+ import io.uqudo.sdk.core.builder.ReadingConfigurationBuilder;
33
+ import io.uqudo.sdk.core.domain.model.BackgroundCheckType;
34
+ import io.uqudo.sdk.core.domain.model.Document;
35
+ import io.uqudo.sdk.core.domain.model.DocumentType;
36
+
37
+ @CapacitorPlugin(name = "UqudoId")
38
+ public class UqudoIdPlugin extends Plugin {
39
+
40
+ @PluginMethod
41
+ public void init(PluginCall call) {
42
+ UqudoSDK.init(getContext(), new TraceObject());
43
+ call.resolve(new JSObject());
44
+ }
45
+
46
+ private class TraceObject implements Tracer {
47
+ @Override
48
+ public void trace(@NotNull Trace trace) {
49
+ try {
50
+ JSONObject json = new JSONObject();
51
+ json.put("category", trace.getCategory());
52
+ json.put("sessionId", trace.getSessionId());
53
+ json.put("event", trace.getEvent());
54
+ json.put("page", trace.getPage());
55
+ json.put("statusCode", trace.getStatusCode());
56
+ json.put("status", trace.getStatus());
57
+ json.put("statusMessage", trace.getStatusMessage());
58
+ json.put("timestamp", trace.getTimestamp());
59
+ json.put("documentType", trace.getDocumentType());
60
+ String data = json.toString();
61
+ bridge.triggerWindowJSEvent("TraceEvent", data);
62
+ } catch (Exception e) {
63
+ Log.e("UqudoIdPlugin", e.getMessage(), e);
64
+ }
65
+ }
66
+ }
67
+
68
+ @PluginMethod
69
+ public void setLocale(PluginCall call) {
70
+ String locale = call.getString("value");
71
+ if (locale != null) {
72
+ UqudoSDK.setLocale(getContext(), locale);
73
+ }
74
+ call.resolve(new JSObject());
75
+ }
76
+
77
+ @PluginMethod
78
+ public void enroll(PluginCall call) {
79
+ String message = call.getString("value");
80
+ if (message != null && message.length() > 0) {
81
+ try {
82
+ JSONObject json = new JSONObject(message);
83
+ UqudoBuilder.Enrollment enrollment = new UqudoBuilder.Enrollment();
84
+ if (json.has("isSecuredWindowsDisabled") && json.getBoolean("isSecuredWindowsDisabled")) {
85
+ enrollment.disableSecureWindow();
86
+ }
87
+ if (json.has("isRootedDeviceAllowed") && json.getBoolean("isRootedDeviceAllowed")) {
88
+ enrollment.enableRootedDeviceUsage();
89
+ }
90
+ if (json.has("nonce")) {
91
+ enrollment.setNonce(json.getString("nonce"));
92
+ }
93
+ if (json.has("sessionId")) {
94
+ enrollment.setSessionId(json.getString("sessionId"));
95
+ }
96
+ if (json.has("userIdentifier")) {
97
+ enrollment.setUserIdentifier(UUID.fromString(json.getString("userIdentifier")));
98
+ }
99
+ if (json.has("isReturnDataForIncompleteSession") && json.getBoolean("isReturnDataForIncompleteSession")) {
100
+ enrollment.returnDataForIncompleteSession();
101
+ }
102
+ if (json.has("facialRecognitionSpecification")) {
103
+ FacialRecognitionConfigurationBuilder faceBuilder = new FacialRecognitionConfigurationBuilder();
104
+ JSONObject faceObject = json.getJSONObject("facialRecognitionSpecification");
105
+ if (faceObject.has("enrollFace") && faceObject.getBoolean("enrollFace")) {
106
+ faceBuilder.enrollFace();
107
+ }
108
+ if (faceObject.has("scanMinimumMatchLevel") && faceObject.getInt("scanMinimumMatchLevel") > 0) {
109
+ faceBuilder.setScanMinimumMatchLevel(faceObject.getInt("scanMinimumMatchLevel"));
110
+ }
111
+ if (faceObject.has("readMinimumMatchLevel") && faceObject.getInt("readMinimumMatchLevel") > 0) {
112
+ faceBuilder.setReadMinimumMatchLevel(faceObject.getInt("readMinimumMatchLevel"));
113
+ }
114
+ if (faceObject.has("maxAttempts") && faceObject.getInt("maxAttempts") > 0) {
115
+ faceBuilder.setMaxAttempts(faceObject.getInt("maxAttempts"));
116
+ }
117
+ enrollment.enableFacialRecognition(faceBuilder.build());
118
+ }
119
+
120
+ if (json.has("lookupConfiguration")) {
121
+ JSONObject lookupObject = json.getJSONObject("lookupConfiguration");
122
+ if (lookupObject.has("documentList")) {
123
+ JSONArray lookupDocuments = lookupObject.getJSONArray("documentList");
124
+ if (lookupDocuments.length() > 0) {
125
+ DocumentType[] documents = new DocumentType[lookupDocuments.length()];
126
+ for (int i = 0; i < lookupDocuments.length(); i++) {
127
+ String parsedDocument = lookupDocuments.getString(i);
128
+ documents[i] = DocumentType.valueOf(parsedDocument);
129
+ }
130
+ enrollment.enableLookup(documents);
131
+ } else {
132
+ enrollment.enableLookup();
133
+ }
134
+ } else {
135
+ enrollment.enableLookup();
136
+ }
137
+ }
138
+
139
+ if (json.has("backgroundCheckConfiguration")) {
140
+ BackgroundCheckConfigurationBuilder backgroundCheckConfigurationBuilder = new BackgroundCheckConfigurationBuilder();
141
+ JSONObject backgroundObject = json.getJSONObject("backgroundCheckConfiguration");
142
+ if (backgroundObject.has("disableConsent") && backgroundObject.getBoolean("disableConsent")) {
143
+ backgroundCheckConfigurationBuilder.disableConsent();
144
+ }
145
+ if (backgroundObject.has("backgroundCheckType")) {
146
+ backgroundCheckConfigurationBuilder.setBackgroundCheckType(BackgroundCheckType.valueOf(backgroundObject.getString("backgroundCheckType")));
147
+ }
148
+ if (backgroundObject.has("monitoringEnabled") && backgroundObject.getBoolean("monitoringEnabled")) {
149
+ backgroundCheckConfigurationBuilder.enableMonitoring();
150
+ }
151
+ if (backgroundObject.has("skipView") && backgroundObject.getBoolean("skipView")) {
152
+ backgroundCheckConfigurationBuilder.skipView();
153
+ }
154
+ enrollment.enableBackgroundCheck(backgroundCheckConfigurationBuilder.build());
155
+ }
156
+ enrollment.setToken(json.getString("authorizationToken"));
157
+ JSONArray documentList = json.getJSONArray("documentList");
158
+ for (int i = 0; i < documentList.length(); i++) {
159
+ JSONObject documentJson = documentList.getJSONObject(i);
160
+ DocumentBuilder documentBuilder = new DocumentBuilder(getContext());
161
+ documentBuilder.setDocumentType(DocumentType.valueOf(documentJson.getString("documentType")));
162
+ if (documentJson.has("isHelpPageDisabled") && documentJson.getBoolean("isHelpPageDisabled")) {
163
+ documentBuilder.disableHelpPage();
164
+ }
165
+ if (documentJson.has("isExpiredDocumentValidateDisabled") && documentJson.getBoolean("isExpiredDocumentValidateDisabled")) {
166
+ documentBuilder.disableExpiryValidation();
167
+ }
168
+ if (documentJson.has("isFrontSideReviewEnabled") || documentJson.has("isBackSideReviewEnabled")) {
169
+ documentBuilder.enableScanReview(documentJson.optBoolean("isFrontSideReviewEnabled", false), documentJson.optBoolean("isBackSideReviewEnabled", false));
170
+ }
171
+ if (documentJson.has("isUploadEnabled") && documentJson.getBoolean("isUploadEnabled")) {
172
+ documentBuilder.enableUpload();
173
+ }
174
+ if (documentJson.has("minimumAge") && documentJson.getInt("minimumAge") > 0) {
175
+ documentBuilder.enableAgeVerification(documentJson.getInt("minimumAge"));
176
+ }
177
+
178
+ if (documentJson.has("readingConfiguration")) {
179
+ JSONObject readConfiguration = documentJson.getJSONObject("readingConfiguration");
180
+ if (readConfiguration.has("forceReading")) {
181
+ ReadingConfigurationBuilder readingConfigurationBuilder = new ReadingConfigurationBuilder();
182
+ if (readConfiguration.has("forceReading")) {
183
+ readingConfigurationBuilder.forceReading(readConfiguration.getBoolean("forceReading"));
184
+ }
185
+ if (readConfiguration.has("forceReadingIfSupported")) {
186
+ readingConfigurationBuilder.forceReadingIfSupported(readConfiguration.getBoolean("forceReadingIfSupported"));
187
+ }
188
+
189
+ if (readConfiguration.has("timeoutInSeconds")) {
190
+ readingConfigurationBuilder.forceReadingTimeout(readConfiguration.getInt("timeoutInSeconds"));
191
+ }
192
+
193
+
194
+ documentBuilder.enableReading(readingConfigurationBuilder.build());
195
+ } else {
196
+ documentBuilder.enableReading();
197
+ }
198
+ }
199
+ if (documentJson.has("faceScanMinimumMatchLevel") && documentJson.getInt("faceScanMinimumMatchLevel") > 0) {
200
+ documentBuilder.setFaceScanMinimumMatchLevel(documentJson.getInt("faceScanMinimumMatchLevel"));
201
+ }
202
+ if (documentJson.has("faceReadMinimumMatchLevel") && documentJson.getInt("faceReadMinimumMatchLevel") > 0) {
203
+ documentBuilder.setFaceReadMinimumMatchLevel(documentJson.getInt("faceReadMinimumMatchLevel"));
204
+ }
205
+
206
+
207
+ Document document = documentBuilder.build();
208
+ enrollment.add(document);
209
+ }
210
+ if (json.has("appearanceMode")) {
211
+ if ("LIGHT".equals(json.getString("appearanceMode"))) {
212
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
213
+ } else if ("DARK".equals(json.getString("appearanceMode"))) {
214
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
215
+ } else if ("SYSTEM".equals(json.getString("appearanceMode"))) {
216
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
217
+ }
218
+ }else{
219
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
220
+ }
221
+ call.setKeepAlive(true);
222
+ Intent intent = enrollment.build(getContext());
223
+
224
+ startActivityForResult(call, intent, "handleActivityResult");
225
+ } catch (Exception e) {
226
+ Log.d("UqudoPlugin", e.getMessage(), e);
227
+ sendError(call, SessionStatusCode.UNEXPECTED_ERROR.name(), e.getMessage(), null);
228
+ }
229
+ } else {
230
+ sendError(call, SessionStatusCode.UNEXPECTED_ERROR.name(), "Expected enrollment object as argument.", null);
231
+ }
232
+ }
233
+
234
+ @PluginMethod
235
+ public void recover(PluginCall call) {
236
+ String message = call.getString("value");
237
+ if (message != null && message.length() > 0) {
238
+ try {
239
+ JSONObject json = new JSONObject(message);
240
+ UqudoBuilder.AccountRecovery recovery = new UqudoBuilder.AccountRecovery();
241
+ recovery.setToken(json.getString("token"));
242
+ recovery.setEnrollmentIdentifier(json.getString("enrollmentIdentifier"));
243
+ if (json.has("nonce")) {
244
+ recovery.setNonce(json.getString("nonce"));
245
+ }
246
+ if (json.has("isRootedDeviceAllowed")) {
247
+ recovery.enableRootedDeviceUsage();
248
+ }
249
+ if (json.has("isSecuredWindowsDisabled")) {
250
+ recovery.disableSecureWindow();
251
+ }
252
+ if (json.has("minimumMatchLevel") && json.getInt("minimumMatchLevel") > 0) {
253
+ recovery.setMinimumMatchLevel(json.getInt("minimumMatchLevel"));
254
+ }
255
+ if (json.has("maxAttempts") && json.getInt("maxAttempts") > 0) {
256
+ recovery.setMaxAttempts(json.getInt("maxAttempts"));
257
+ }
258
+ if (json.has("isReturnDataForIncompleteSession") && json.getBoolean("isReturnDataForIncompleteSession")) {
259
+ recovery.returnDataForIncompleteSession();
260
+ }
261
+ if (json.has("appearanceMode")) {
262
+ if ("LIGHT".equals(json.getString("appearanceMode"))) {
263
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
264
+ } else if ("DARK".equals(json.getString("appearanceMode"))) {
265
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
266
+ } else if ("SYSTEM".equals(json.getString("appearanceMode"))) {
267
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
268
+ }
269
+ }else{
270
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
271
+ }
272
+ call.setKeepAlive(true);
273
+ Intent intent = recovery.build(getContext());
274
+ startActivityForResult(call, intent, "handleActivityResult");
275
+ } catch (Exception e) {
276
+ Log.d("UqudoPlugin", e.getMessage(), e);
277
+ sendError(call, SessionStatusCode.UNEXPECTED_ERROR.name(), e.getMessage(), null);
278
+ }
279
+ } else {
280
+ sendError(call, SessionStatusCode.UNEXPECTED_ERROR.name(), "Expected account recovery object as argument.", null);
281
+ }
282
+ }
283
+
284
+
285
+ @PluginMethod
286
+ public void faceSession(PluginCall call) {
287
+ String message = call.getString("value");
288
+ if (message != null && message.length() > 0) {
289
+ try {
290
+ JSONObject json = new JSONObject(message);
291
+ UqudoBuilder.FaceSession faceSessionBuilder = new UqudoBuilder.FaceSession();
292
+ faceSessionBuilder.setToken(json.getString("token"));
293
+ faceSessionBuilder.setSessionId(json.getString("sessionId"));
294
+ if (json.has("nonce")) {
295
+ faceSessionBuilder.setNonce(json.getString("nonce"));
296
+ }
297
+ if (json.has("isRootedDeviceAllowed")) {
298
+ faceSessionBuilder.enableRootedDeviceUsage();
299
+ }
300
+ if (json.has("isSecuredWindowsDisabled")) {
301
+ faceSessionBuilder.disableSecureWindow();
302
+ }
303
+ if (json.has("minimumMatchLevel") && json.getInt("minimumMatchLevel") > 0) {
304
+ faceSessionBuilder.setMinimumMatchLevel(json.getInt("minimumMatchLevel"));
305
+ }
306
+ if (json.has("maxAttempts") && json.getInt("maxAttempts") > 0) {
307
+ faceSessionBuilder.setMaxAttempts(json.getInt("maxAttempts"));
308
+ }
309
+ if (json.has("isReturnDataForIncompleteSession") && json.getBoolean("isReturnDataForIncompleteSession")) {
310
+ faceSessionBuilder.returnDataForIncompleteSession();
311
+ }
312
+ if (json.has("appearanceMode")) {
313
+ if ("LIGHT".equals(json.getString("appearanceMode"))) {
314
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
315
+ } else if ("DARK".equals(json.getString("appearanceMode"))) {
316
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
317
+ } else if ("SYSTEM".equals(json.getString("appearanceMode"))) {
318
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
319
+ }
320
+ }else{
321
+ AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
322
+ }
323
+ call.setKeepAlive(true);
324
+ Intent intent = faceSessionBuilder.build(getContext());
325
+ startActivityForResult(call, intent, "handleActivityResult");
326
+ } catch (Exception e) {
327
+ Log.d("UqudoPlugin", e.getMessage(), e);
328
+ sendError(call, SessionStatusCode.UNEXPECTED_ERROR.name(), e.getMessage(), null);
329
+ }
330
+ } else {
331
+ sendError(call, SessionStatusCode.UNEXPECTED_ERROR.name(), "Expected face session object as argument.", null);
332
+ }
333
+ }
334
+
335
+ private void sendError(PluginCall call, String code, String message, String task) {
336
+ sendError(call, code, message, task, null);
337
+ }
338
+
339
+ private void sendError(PluginCall call, String code, String message, String task, String data) {
340
+ JSONObject error = new JSONObject();
341
+ try {
342
+ error.put("code", code);
343
+ error.put("message", message);
344
+ error.put("task", task);
345
+ error.put("data", data);
346
+ } catch (Exception e) {
347
+ e.printStackTrace();
348
+ }
349
+ call.reject(error.toString(),"");
350
+ }
351
+
352
+ @ActivityCallback
353
+ protected void handleActivityResult(PluginCall savedCall, ActivityResult result) {
354
+ if (savedCall == null) {
355
+ Log.d("UqudoPlugin", "saved call is null");
356
+ return;
357
+ }
358
+
359
+ if (result.getResultCode() == Activity.RESULT_OK) {
360
+ try {
361
+ String response;
362
+ response = new JSONObject().put("value", result.getData().getStringExtra("data")).toString();
363
+ savedCall.resolve(new JSObject(response));
364
+ } catch (Exception e) {
365
+ e.printStackTrace();
366
+ }
367
+ } else if (result.getResultCode() == Activity.RESULT_CANCELED) {
368
+ if (result.getData() != null) {
369
+ SessionStatus sessionStatus = result.getData().getParcelableExtra("key_session_status");
370
+ assert sessionStatus != null;
371
+ sendError(savedCall, sessionStatus.getSessionStatusCode().name(), sessionStatus.getSessionStatusCode().getMessage(), sessionStatus.getSessionTask().name(), sessionStatus.getData());
372
+ }
373
+ }
374
+ }
375
+ }
File without changes
@@ -0,0 +1,21 @@
1
+ export interface UqudoIdPlugin {
2
+ init(): void;
3
+ setLocale(options: {
4
+ value: String;
5
+ }): void;
6
+ enroll(options: {
7
+ value: string;
8
+ }): Promise<{
9
+ value: string;
10
+ }>;
11
+ recover(options: {
12
+ value: string;
13
+ }): Promise<{
14
+ value: string;
15
+ }>;
16
+ faceSession(options: {
17
+ value: string;
18
+ }): Promise<{
19
+ value: string;
20
+ }>;
21
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}