@veriff/react-native-sdk 4.0.0 → 4.2.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.
@@ -41,6 +41,7 @@ repositories {
41
41
 
42
42
  dependencies {
43
43
  //noinspection GradleDynamicVersion
44
- implementation 'com.facebook.react:react-native:+'
45
- implementation 'com.veriff:veriff-library:6.3.0'
44
+ implementation 'com.facebook.react:react-android:+'
45
+
46
+ implementation 'com.veriff:veriff-library:6.6.0'
46
47
  }
@@ -0,0 +1 @@
1
+ android.useAndroidX=true
@@ -3,7 +3,6 @@ package com.veriff.sdk.reactnative;
3
3
  import android.app.Activity;
4
4
  import android.content.Context;
5
5
  import android.content.Intent;
6
- import android.content.res.Resources;
7
6
  import android.graphics.Color;
8
7
  import android.text.TextUtils;
9
8
  import android.util.Log;
@@ -28,12 +27,17 @@ import com.veriff.Sdk;
28
27
  import java.util.*;
29
28
 
30
29
  import com.veriff.GeneralConfig;
30
+
31
31
  import okhttp3.HttpUrl;
32
32
 
33
33
  import static android.app.Activity.RESULT_CANCELED;
34
34
  import static com.veriff.Result.Status.CANCELED;
35
35
  import static com.veriff.Result.Status.ERROR;
36
36
 
37
+ import androidx.annotation.NonNull;
38
+
39
+ import javax.annotation.Nullable;
40
+
37
41
  public class VeriffSdkModule extends ReactContextBaseJavaModule {
38
42
  /**
39
43
  * Indicates that the parameters passed to {@link #launchVeriff(ReadableMap, Promise)} were invalid.
@@ -84,6 +88,8 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
84
88
  private static final String KEY_ON_PRIMARY = "onPrimary";
85
89
  private static final String KEY_SECONDARY = "secondary";
86
90
  private static final String KEY_ON_SECONDARY = "onSecondary";
91
+ private static final String KEY_CAMERA_OVERLAY = "cameraOverlay";
92
+ private static final String KEY_ON_CAMERA_OVERLAY = "onCameraOverlay";
87
93
  private static final String KEY_OUTLINE = "outline";
88
94
  private static final String KEY_SUCCESS = "success";
89
95
  private static final String KEY_ERROR = "error";
@@ -125,11 +131,30 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
125
131
 
126
132
  private final ReactApplicationContext reactContext;
127
133
 
134
+ @Nullable
135
+ private Result lastResult;
136
+
137
+ @Nullable
138
+ private String sessionToken;
139
+
140
+ @Nullable
141
+ private String status;
142
+
128
143
  public VeriffSdkModule(ReactApplicationContext reactContext) {
129
144
  super(reactContext);
130
145
  this.reactContext = reactContext;
131
146
  }
132
147
 
148
+ @ReactMethod
149
+ public void recoverLastResult(final Promise promise) {
150
+ if (lastResult != null && status != null && sessionToken != null) {
151
+ sendResult(lastResult, status, sessionToken, promise);
152
+ lastResult = null;
153
+ sessionToken = null;
154
+ status = null;
155
+ }
156
+ }
157
+
133
158
  @Override
134
159
  public String getName() {
135
160
  return JS_NAME;
@@ -186,6 +211,9 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
186
211
  startUrl = baseUrl + "/v/" + sessionToken;
187
212
  }
188
213
 
214
+ this.sessionToken = sessionToken;
215
+ this.lastResult = null;
216
+ this.status = null;
189
217
 
190
218
  Activity activity = getCurrentActivity();
191
219
  if (activity == null) {
@@ -208,19 +236,10 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
208
236
  reactContext.removeActivityEventListener(this);
209
237
 
210
238
  Result veriffResult = Result.fromResultIntent(data);
211
- WritableMap result = Arguments.createMap();
212
- result.putString(KEY_TOKEN, sessionToken);
213
-
214
- Status status = resultCode == RESULT_CANCELED ? CANCELED : ERROR;
215
- if (veriffResult != null) {
216
- status = veriffResult.getStatus();
217
- }
218
- result.putString(KEY_STATUS, statusToString(status));
219
- if (veriffResult != null && veriffResult.getError() != null) {
220
- result.putString(KEY_RESULT_ERROR, codeToError(veriffResult.getError()));
221
- }
239
+ lastResult = veriffResult;
240
+ status = statusToString(getVeriffStatus(resultCode, veriffResult));
222
241
 
223
- promise.resolve(result);
242
+ sendResult(veriffResult, status, sessionToken, promise);
224
243
  }
225
244
  }
226
245
  };
@@ -269,11 +288,19 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
269
288
  if (brandConfig.hasKey(KEY_SECONDARY)) {
270
289
  branding.secondary(parseColor(brandConfig.getString(KEY_SECONDARY)));
271
290
  }
272
-
291
+
273
292
  if (brandConfig.hasKey(KEY_ON_SECONDARY)) {
274
293
  branding.onSecondary(parseColor(brandConfig.getString(KEY_ON_SECONDARY)));
275
294
  }
276
295
 
296
+ if (brandConfig.hasKey(KEY_CAMERA_OVERLAY)) {
297
+ branding.cameraOverlay(parseColor(brandConfig.getString(KEY_CAMERA_OVERLAY)));
298
+ }
299
+
300
+ if (brandConfig.hasKey(KEY_ON_CAMERA_OVERLAY)) {
301
+ branding.onCameraOverlay(parseColor(brandConfig.getString(KEY_ON_CAMERA_OVERLAY)));
302
+ }
303
+
277
304
  if (brandConfig.hasKey(KEY_OUTLINE)) {
278
305
  branding.outline(parseColor(brandConfig.getString(KEY_OUTLINE)));
279
306
  }
@@ -312,6 +339,29 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
312
339
  }
313
340
  }
314
341
 
342
+ private void sendResult(Result veriffResult, String status, String sessionToken, Promise promise) {
343
+ WritableMap result = Arguments.createMap();
344
+ result.putString(KEY_TOKEN, sessionToken);
345
+ result.putString(KEY_STATUS, status);
346
+
347
+ if (veriffResult != null && veriffResult.getError() != null) {
348
+ result.putString(KEY_RESULT_ERROR, codeToError(veriffResult.getError()));
349
+ }
350
+
351
+ promise.resolve(result);
352
+ }
353
+
354
+ @NonNull
355
+ private static Status getVeriffStatus(int resultCode, Result veriffResult) {
356
+ Status status;
357
+ if (veriffResult != null) {
358
+ status = veriffResult.getStatus();
359
+ } else {
360
+ status = resultCode == RESULT_CANCELED ? CANCELED : ERROR;
361
+ }
362
+ return status;
363
+ }
364
+
315
365
  private Font buildFont(Context context, ReadableMap src) {
316
366
  int regularFont = getFontId(context, src.getString(KEY_FONT_REGULAR));
317
367
  int mediumFont = getFontId(context, src.getString(KEY_FONT_MEDIUM));
@@ -321,7 +371,7 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
321
371
  src.getString(KEY_FONT_REGULAR), regularFont));
322
372
 
323
373
  Log.v(TAG, String.format("Medium font: [%s], value [%s]",
324
- src.getString(KEY_FONT_MEDIUM), mediumFont));
374
+ src.getString(KEY_FONT_MEDIUM), mediumFont));
325
375
 
326
376
  Log.v(TAG, String.format("Bold font: [%s], value [%s]",
327
377
  src.getString(KEY_FONT_BOLD), boldFont));
@@ -9,6 +9,7 @@ import java.util.Arrays;
9
9
  import java.util.Collections;
10
10
  import java.util.List;
11
11
 
12
+ @SuppressWarnings("unused")
12
13
  public class VeriffSdkPackage implements ReactPackage {
13
14
  @Override
14
15
  public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
package/ios/Podfile CHANGED
@@ -5,7 +5,7 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
5
5
 
6
6
  target 'VeriffSdk' do
7
7
  # Pods for VeriffSdk
8
- pod 'VeriffSDK', '6.5.0'
8
+ pod 'VeriffSDK', '6.8.0'
9
9
 
10
10
  config = use_native_modules!
11
11
 
@@ -87,6 +87,8 @@ class VeriffSdk: NSObject {
87
87
  branding.onPrimary = brandingConfig.color(for: "onPrimary")
88
88
  branding.secondary = brandingConfig.color(for: "secondary")
89
89
  branding.onSecondary = brandingConfig.color(for: "onSecondary")
90
+ branding.cameraOverlay = brandingConfig.color(for: "cameraOverlay")
91
+ branding.onCameraOverlay = brandingConfig.color(for: "onCameraOverlay")
90
92
  branding.outline = brandingConfig.color(for: "outline")
91
93
  branding.error = brandingConfig.color(for: "error")
92
94
  branding.success = brandingConfig.color(for: "success")
@@ -140,7 +142,6 @@ class VeriffSdk: NSObject {
140
142
  let veriff = Veriff.VeriffSdk.shared
141
143
  veriff.delegate = self
142
144
  veriff.implementationType = .reactNative
143
- veriffConfiguration?.queryItems = VeriffSdk.updateConfigWithQueryItems(url: sessionURL)
144
145
  veriff.startAuthentication(sessionUrl: sessionURL.absoluteString, configuration: veriffConfiguration)
145
146
  }
146
147
  }
@@ -153,11 +154,6 @@ class VeriffSdk: NSObject {
153
154
  }
154
155
  }
155
156
 
156
- private static func updateConfigWithQueryItems(url: URL) -> [URLQueryItem]? {
157
- let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
158
- return components?.queryItems
159
- }
160
-
161
157
  private static func resultToStatus(result: Veriff.VeriffSdk.Result) -> (Veriff.VeriffSdk.Status, String) {
162
158
  switch result.status {
163
159
  case .done:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@veriff/react-native-sdk",
3
3
  "title": "React Native Veriff SDK",
4
- "version": "4.0.0",
4
+ "version": "4.2.0",
5
5
  "description": "React Native SDK for Veriff identity verification",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -20,5 +20,5 @@ Pod::Spec.new do |s|
20
20
  s.requires_arc = true
21
21
 
22
22
  s.dependency "React"
23
- s.dependency "VeriffSDK", "6.5.0"
23
+ s.dependency "VeriffSDK", "6.8.0"
24
24
  end