@veriff/react-native-sdk 2.12.0 → 3.0.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.
@@ -1 +1 @@
1
- @DariaRyazhskikhVeriff @MertCelik @yakovshkolnikovveriff
1
+ @yakovshkolnikovveriff @tauntz @catchakos @l3m4rk-veriff
@@ -23,8 +23,8 @@ apply plugin: 'kotlin-android'
23
23
  apply plugin: 'maven-publish'
24
24
 
25
25
  android {
26
- compileSdkVersion safeExtGet('compileSdkVersion', 31)
27
- buildToolsVersion safeExtGet('buildToolsVersion', '31.0.0')
26
+ compileSdkVersion safeExtGet('compileSdkVersion', 33)
27
+ buildToolsVersion safeExtGet('buildToolsVersion', '33.0.0')
28
28
 
29
29
  defaultConfig {
30
30
  minSdkVersion safeExtGet('minSdkVersion', 21)
@@ -42,5 +42,5 @@ repositories {
42
42
  dependencies {
43
43
  //noinspection GradleDynamicVersion
44
44
  implementation 'com.facebook.react:react-native:+'
45
- implementation 'com.veriff:veriff-library:4.7.0'
45
+ implementation 'com.veriff:veriff-library:6.0.0'
46
46
  }
@@ -28,7 +28,6 @@ import com.veriff.Sdk;
28
28
  import java.util.*;
29
29
 
30
30
  import com.veriff.GeneralConfig;
31
- import com.veriff.sdk.reactnative.mapper.ExternalResourcesMapper;
32
31
  import okhttp3.HttpUrl;
33
32
 
34
33
  import static android.app.Activity.RESULT_CANCELED;
@@ -74,25 +73,30 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
74
73
  private static final String KEY_BRANDING = "branding";
75
74
  private static final String KEY_LOCALE = "locale";
76
75
  private static final String KEY_STATUS = "status";
77
- private static final String KEY_ERROR = "error";
76
+ private static final String KEY_RESULT_ERROR = "result_error";
78
77
 
79
- private static final String KEY_THEME_COLOR = "themeColor";
80
78
  private static final String KEY_LOGO = "logo";
81
- private static final String KEY_NAVIGATION_BAR_IMAGE = "navigationBarImage";
82
- private static final String KEY_ANDROID_NOTIFICATION_ICON = "androidNotificationIcon";
83
- public static final String KEY_BACKGROUND_COLOR = "backgroundColor";
84
- public static final String KEY_STATUS_BAR_COLOR = "statusBarColor";
85
- public static final String KEY_PRIMARY_TEXT_COLOR = "primaryTextColor";
86
- public static final String KEY_SECONDARY_TEXT_COLOR = "secondaryTextColor";
87
- public static final String KEY_PRIMARY_BUTTON_BACKGROUND_COLOR = "primaryButtonBackgroundColor";
88
- public static final String KEY_BUTTON_CORNER_RADIUS = "buttonCornerRadius";
79
+ private static final String KEY_BACKGROUND = "background";
80
+ private static final String KEY_ON_BACKGROUND = "onBackground";
81
+ private static final String KEY_ON_BACKGROUND_SECONDARY = "onBackgroundSecondary";
82
+ private static final String KEY_ON_BACKGROUND_TERTIARY = "onBackgroundTertiary";
83
+ private static final String KEY_PRIMARY = "primary";
84
+ private static final String KEY_ON_PRIMARY = "onPrimary";
85
+ private static final String KEY_SECONDARY = "secondary";
86
+ private static final String KEY_ON_SECONDARY = "onSecondary";
87
+ private static final String KEY_OUTLINE = "outline";
88
+ private static final String KEY_SUCCESS = "success";
89
+ private static final String KEY_ERROR = "error";
90
+
91
+ public static final String KEY_BUTTON_RADIUS = "buttonRadius";
89
92
  private static final String KEY_CUSTOM_INTRO_SCREEN = "customIntroScreen";
90
- public static final String KEY_ADVANCED_CONFIGURATIONS = "advancedConfigurations";
91
93
  private static final String KEY_RN_IMAGE_URI = "uri";
92
94
 
93
95
  private static final String KEY_FONT = "androidFont";
94
- private static final String KEY_FONT_NORMAL = "regularFontName";
95
- private static final String KEY_FONT_BOLD = "boldFontName";
96
+
97
+ private static final String KEY_FONT_REGULAR = "regular";
98
+ private static final String KEY_FONT_MEDIUM = "medium";
99
+ private static final String KEY_FONT_BOLD = "bold";
96
100
 
97
101
  private static final String ERROR_UNABLE_TO_ACCESS_CAMERA = "UNABLE_TO_ACCESS_CAMERA";
98
102
  private static final String ERROR_UNABLE_TO_RECORD_AUDIO = "UNABLE_TO_RECORD_AUDIO";
@@ -213,7 +217,7 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
213
217
  }
214
218
  result.putString(KEY_STATUS, statusToString(status));
215
219
  if (veriffResult != null && veriffResult.getError() != null) {
216
- result.putString(KEY_ERROR, codeToError(veriffResult.getError()));
220
+ result.putString(KEY_RESULT_ERROR, codeToError(veriffResult.getError()));
217
221
  }
218
222
 
219
223
  promise.resolve(result);
@@ -233,38 +237,58 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
233
237
  ReadableMap brandConfig = configuration.getMap(KEY_BRANDING);
234
238
  if (brandConfig != null) {
235
239
  Branding.Builder branding = new Branding.Builder();
236
- if (brandConfig.hasKey(KEY_THEME_COLOR)) {
237
- branding.themeColor(parseColor(brandConfig.getString(KEY_THEME_COLOR)));
238
- }
239
- if (brandConfig.hasKey(KEY_NAVIGATION_BAR_IMAGE)) {
240
- handleLogo(activity, KEY_NAVIGATION_BAR_IMAGE, branding, brandConfig);
241
- }
240
+
242
241
  if (brandConfig.hasKey(KEY_LOGO)) {
243
242
  handleLogo(activity, KEY_LOGO, branding, brandConfig);
244
243
  }
245
- if (brandConfig.hasKey(KEY_ANDROID_NOTIFICATION_ICON)) {
246
- branding.notificationIcon(getDrawableId(activity, brandConfig.getString(KEY_ANDROID_NOTIFICATION_ICON)));
244
+
245
+ if (brandConfig.hasKey(KEY_BACKGROUND)) {
246
+ branding.background(parseColor(brandConfig.getString(KEY_BACKGROUND)));
247
247
  }
248
- if (brandConfig.hasKey(KEY_BACKGROUND_COLOR)) {
249
- branding.backgroundColor(parseColor(brandConfig.getString(KEY_BACKGROUND_COLOR)));
248
+
249
+ if (brandConfig.hasKey(KEY_ON_BACKGROUND)) {
250
+ branding.onBackground(parseColor(brandConfig.getString(KEY_ON_BACKGROUND)));
250
251
  }
251
- if (brandConfig.hasKey(KEY_STATUS_BAR_COLOR)) {
252
- branding.statusBarColor(parseColor(brandConfig.getString(KEY_STATUS_BAR_COLOR)));
252
+
253
+ if (brandConfig.hasKey(KEY_ON_BACKGROUND_SECONDARY)) {
254
+ branding.onBackgroundSecondary(parseColor(brandConfig.getString(KEY_ON_BACKGROUND_SECONDARY)));
255
+ }
256
+
257
+ if (brandConfig.hasKey(KEY_ON_BACKGROUND_TERTIARY)) {
258
+ branding.onBackgroundTertiary(parseColor(brandConfig.getString(KEY_ON_BACKGROUND_TERTIARY)));
259
+ }
260
+
261
+ if (brandConfig.hasKey(KEY_PRIMARY)) {
262
+ branding.primary(parseColor(brandConfig.getString(KEY_PRIMARY)));
253
263
  }
254
- if (brandConfig.hasKey(KEY_PRIMARY_TEXT_COLOR)) {
255
- branding.primaryTextColor(parseColor(brandConfig.getString(KEY_PRIMARY_TEXT_COLOR)));
264
+
265
+ if (brandConfig.hasKey(KEY_ON_PRIMARY)) {
266
+ branding.onPrimary(parseColor(brandConfig.getString(KEY_ON_PRIMARY)));
256
267
  }
257
- if (brandConfig.hasKey(KEY_SECONDARY_TEXT_COLOR)) {
258
- branding.secondaryTextColor(parseColor(brandConfig.getString(KEY_SECONDARY_TEXT_COLOR)));
268
+
269
+ if (brandConfig.hasKey(KEY_SECONDARY)) {
270
+ branding.secondary(parseColor(brandConfig.getString(KEY_SECONDARY)));
259
271
  }
260
- if (brandConfig.hasKey(KEY_PRIMARY_BUTTON_BACKGROUND_COLOR)) {
261
- branding.primaryButtonBackgroundColor(parseColor(brandConfig.getString(KEY_PRIMARY_BUTTON_BACKGROUND_COLOR)));
272
+
273
+ if (brandConfig.hasKey(KEY_ON_SECONDARY)) {
274
+ branding.onSecondary(parseColor(brandConfig.getString(KEY_ON_SECONDARY)));
262
275
  }
263
- if (brandConfig.hasKey(KEY_BUTTON_CORNER_RADIUS)) {
264
- branding.buttonCornerRadius((float) brandConfig.getDouble(KEY_BUTTON_CORNER_RADIUS));
276
+
277
+ if (brandConfig.hasKey(KEY_OUTLINE)) {
278
+ branding.outline(parseColor(brandConfig.getString(KEY_OUTLINE)));
279
+ }
280
+
281
+ if (brandConfig.hasKey(KEY_SUCCESS)) {
282
+ branding.success(parseColor(brandConfig.getString(KEY_SUCCESS)));
283
+ }
284
+
285
+ if (brandConfig.hasKey(KEY_ERROR)) {
286
+ branding.error(parseColor(brandConfig.getString(KEY_ERROR)));
287
+ }
288
+
289
+ if (brandConfig.hasKey(KEY_BUTTON_RADIUS)) {
290
+ branding.buttonRadius((float) brandConfig.getDouble(KEY_BUTTON_RADIUS));
265
291
  }
266
- handleExternalResources(brandConfig, branding);
267
- handleAdvancedConfigurations(brandConfig, branding);
268
292
 
269
293
  if (brandConfig.hasKey(KEY_FONT)) {
270
294
  ReadableMap srcFont = brandConfig.getMap(KEY_FONT);
@@ -289,43 +313,31 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
289
313
  }
290
314
 
291
315
  private Font buildFont(Context context, ReadableMap src) {
292
- int normalFont = getFontId(context, src.getString(KEY_FONT_NORMAL));
316
+ int regularFont = getFontId(context, src.getString(KEY_FONT_REGULAR));
317
+ int mediumFont = getFontId(context, src.getString(KEY_FONT_MEDIUM));
293
318
  int boldFont = getFontId(context, src.getString(KEY_FONT_BOLD));
294
319
 
295
- Log.v(TAG, String.format("Normal font: [%s], value [%s]",
296
- src.getString(KEY_FONT_NORMAL), normalFont));
320
+ Log.v(TAG, String.format("Regular font: [%s], value [%s]",
321
+ src.getString(KEY_FONT_REGULAR), regularFont));
322
+
323
+ Log.v(TAG, String.format("Medium font: [%s], value [%s]",
324
+ src.getString(KEY_FONT_MEDIUM), mediumFont));
297
325
 
298
326
  Log.v(TAG, String.format("Bold font: [%s], value [%s]",
299
327
  src.getString(KEY_FONT_BOLD), boldFont));
300
328
 
301
329
  return new Font.Builder()
302
- .setNormalAndBold(normalFont, boldFont)
330
+ .setRegular(regularFont)
331
+ .setMedium(mediumFont)
332
+ .setBold(boldFont)
303
333
  .build();
304
334
  }
305
335
 
306
-
307
- private void handleExternalResources(ReadableMap brandConfig, Branding.Builder branding) {
308
- ExternalResourcesMapper mapper = new ExternalResourcesMapper();
309
-
310
- branding.externalResources(mapper.map(brandConfig));
311
- }
312
-
313
- private void handleAdvancedConfigurations(ReadableMap brandConfig, Branding.Builder branding) {
314
- Map<String, Object> result = new HashMap<>();
315
-
316
- if (brandConfig.hasKey(KEY_ADVANCED_CONFIGURATIONS)) {
317
- ReadableMap config = brandConfig.getMap(KEY_ADVANCED_CONFIGURATIONS);
318
- result.put("customer", config.getString("customer"));
319
- }
320
-
321
- branding.advancedConfigurations(result);
322
- }
323
-
324
336
  private void handleLogo(Context context, String key, Branding.Builder branding, ReadableMap brandConfig) {
325
337
  ReadableType type = brandConfig.getType(key);
326
338
  Log.d(TAG, "Logo type" + type);
327
339
  if (ReadableType.String.equals(type)) {
328
- branding.toolbarIcon(getDrawableId(context, brandConfig.getString(key)));
340
+ branding.logo(getDrawableId(context, brandConfig.getString(key)));
329
341
  } else if (ReadableType.Map.equals(type)) {
330
342
  // check if it's a native RN image
331
343
  ReadableMap image = brandConfig.getMap(key);
@@ -336,10 +348,10 @@ public class VeriffSdkModule extends ReactContextBaseJavaModule {
336
348
  // check if url has an async scheme
337
349
  if (isAsyncLogoUrl(url)) {
338
350
  Log.d(TAG, "Async logo" + url);
339
- branding.toolbarIconProvider(new ReactNativeImageProvider(url));
351
+ branding.logo(new ReactNativeImageProvider(url));
340
352
  } else {
341
353
  Log.d(TAG, "Logo from resource" + url);
342
- branding.toolbarIcon(getDrawableId(context, url));
354
+ branding.logo(getDrawableId(context, url));
343
355
  }
344
356
  } else {
345
357
  Log.w(TAG, "Image url is empty: " + url);
package/ios/Podfile CHANGED
@@ -5,8 +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'
9
- pod 'lottie-ios'
8
+ pod 'VeriffSDK', '6.1.0'
10
9
 
11
10
  config = use_native_modules!
12
11
 
@@ -1,7 +1,6 @@
1
1
  import Foundation
2
2
  import Veriff
3
3
  import UIKit
4
- import Lottie
5
4
 
6
5
  @objc(VeriffSdkReactWrapper)
7
6
  class VeriffSdk: NSObject {
@@ -28,17 +27,8 @@ class VeriffSdk: NSObject {
28
27
  private static let SESSION_URL = "sessionUrl"
29
28
  private static let BRANDING = "branding"
30
29
  private static let LOCALE = "locale"
31
- private static let THEME_COLOR = "themeColor"
32
- static let LOGO = "logo"
33
- private static let BACKGROUND_COLOR = "backgroundColor"
34
- private static let STATUS_BAR_COLOR = "statusBarColor"
35
- private static let PRIMARY_TEXT_COLOR = "primaryTextColor"
36
- private static let SECONDARY_TEXT_COLOR = "secondaryTextColor"
37
- private static let PRIMARY_BUTTON_BACKGROUND_COLOR = "primaryButtonBackgroundColor"
38
- private static let BUTTON_CORNER_RADIUS = "buttonCornerRadius"
30
+ private static let LOGO = "logo"
39
31
  private static let USE_CUSTOM_INTRO_SCREEN = "customIntroScreen"
40
- private static let ADVANCED_CONFIGURATIONS = "advancedConfigurations"
41
- private static let FONT = "iOSFont"
42
32
 
43
33
  private static let STATUS = "status"
44
34
  private static let ERROR = "error"
@@ -64,84 +54,53 @@ class VeriffSdk: NSObject {
64
54
  @objc(launchVeriff:resolver:rejecter:)
65
55
  func launchVeriff(_ configuration: [String: AnyObject], resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
66
56
 
67
- var veriffConfiguration: Veriff.VeriffSdk.Configuration?
68
- var branding: Veriff.VeriffSdk.Branding?
57
+ var veriffConfiguration: Veriff.VeriffSdk.Configuration?
58
+ var veriffBranding: Veriff.VeriffSdk.Branding?
69
59
 
70
60
  if let brandingConfig = (configuration[VeriffSdk.BRANDING] as? [String: AnyObject]) {
71
- let color = (brandingConfig[VeriffSdk.THEME_COLOR] as? String).map { VeriffSdk.parseColor(hexcolor: $0) }
72
-
61
+ let branding = Veriff.VeriffSdk.Branding()
73
62
  let imageProvider = VeriffSdkImageProvider(imageSource: brandingConfig[VeriffSdk.LOGO])
74
63
 
75
- if let imageURI = brandingConfig[VeriffSdk.LOGO],
76
- let imageDict = imageURI as? [String: AnyObject],
77
- let urlString = imageDict["uri"] as? String,
78
- let url = URL(string: urlString),
79
- !url.isFileURL {
80
- let provider: Veriff.VeriffSdk.Branding.LogoProvider = { imageHandler in
81
- imageProvider.loadRemoteAsset(url: url) { (image) in
82
- guard let image = image else {
83
- return
84
- }
64
+ if
65
+ let imageURI = brandingConfig[VeriffSdk.LOGO],
66
+ let imageDict = imageURI as? [String: AnyObject],
67
+ let urlString = imageDict["uri"] as? String,
68
+ let url = URL(string: urlString),
69
+ !url.isFileURL
70
+ {
71
+ branding.logoProvider = { imageHandler in
72
+ imageProvider.loadRemoteAsset(url: url) { image in
73
+ guard let image else { return }
85
74
  imageHandler(image)
86
75
  }
87
76
  }
88
- branding = Veriff.VeriffSdk.Branding(themeColor: color, logoProvider: provider)
89
77
  } else {
90
- let image = imageProvider.loadLocalAsset()
91
- branding = Veriff.VeriffSdk.Branding(themeColor: color, logo: image)
78
+ branding.logo = imageProvider.loadLocalAsset()
92
79
  }
93
80
 
94
81
  // fill the other items in branding
95
- branding?.backgroundColor = (brandingConfig[VeriffSdk.BACKGROUND_COLOR] as? String).map { VeriffSdk.parseColor(hexcolor: $0) }
96
- branding?.statusBarColor = (brandingConfig[VeriffSdk.STATUS_BAR_COLOR] as? String).map { VeriffSdk.parseColor(hexcolor: $0) }
97
- branding?.primaryTextColor = (brandingConfig[VeriffSdk.PRIMARY_TEXT_COLOR] as? String).map { VeriffSdk.parseColor(hexcolor: $0) }
98
- branding?.secondaryTextColor = (brandingConfig[VeriffSdk.SECONDARY_TEXT_COLOR] as? String).map { VeriffSdk.parseColor(hexcolor: $0) }
99
- branding?.primaryButtonBackgroundColor = (brandingConfig[VeriffSdk.PRIMARY_BUTTON_BACKGROUND_COLOR] as? String).map { VeriffSdk.parseColor(hexcolor: $0) }
100
- branding?.buttonCornerRadius = (brandingConfig[VeriffSdk.BUTTON_CORNER_RADIUS] as? Double).map { CGFloat($0) }
101
- if let rnAdvancedConfigurations = brandingConfig[VeriffSdk.ADVANCED_CONFIGURATIONS] as? [String: Any] {
102
- var advancedConfigurations: [String: Any] = [:]
103
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "rotateToPortraitIcon"), for: "rotateToPortraitIcon")
104
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "rotateToLandscapeIcon"), for: "rotateToLandscapeIcon")
105
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "documentFrontIcon"), for: "documentFrontIcon")
106
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "documentBackIcon"), for: "documentBackIcon")
107
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "cameraUnavailableErrorIcon"), for: "cameraUnavailableErrorIcon")
108
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "microphoneUnavailableErrorIcon"), for: "microphoneUnavailableErrorIcon")
109
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "serverErrorIcon"), for: "serverErrorIcon")
110
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "localErrorIcon"), for: "localErrorIcon")
111
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "networkErrorIcon"), for: "networkErrorIcon")
112
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "uploadErrorIcon"), for: "uploadErrorIcon")
113
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "videoFailedErrorIcon"), for: "videoFailedErrorIcon")
114
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "deprecatedSDKVersionErrorIcon"), for: "deprecatedSDKVersionErrorIcon")
115
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "unknownErrorIcon"), for: "unknownErrorIcon")
116
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "bannerErrorIcon"), for: "bannerErrorIcon")
117
- advancedConfigurations.addValue(rnAdvancedConfigurations.image(for: "consentIcon"), for: "consentIcon")
118
- advancedConfigurations.addValue(rnAdvancedConfigurations["customer"], for: "customer")
119
- if let loadingAnimationString = rnAdvancedConfigurations["loadingAnimation"] as? String {
120
- if
121
- let jsonData = loadingAnimationString.data(using: .utf8),
122
- let animation = try? JSONDecoder().decode(Lottie.Animation.self, from: jsonData)
123
- {
124
- let animationView: () -> UIView = {
125
- let animationView = Lottie.AnimationView(animation: animation)
126
- animationView.backgroundBehavior = .pauseAndRestore
127
- animationView.loopMode = .loop
128
- animationView.play(completion: nil)
129
- return animationView
130
- }
131
- advancedConfigurations["loadingAnimation"] = animationView
132
- }
133
- }
134
- branding?.advancedConfigurations = advancedConfigurations
135
- }
82
+ branding.background = brandingConfig.color(for: "background")
83
+ branding.onBackground = brandingConfig.color(for: "onBackground")
84
+ branding.onBackgroundSecondary = brandingConfig.color(for: "onBackgroundSecondary")
85
+ branding.onBackgroundTertiary = brandingConfig.color(for: "onBackgroundTertiary")
86
+ branding.primary = brandingConfig.color(for: "primary")
87
+ branding.onPrimary = brandingConfig.color(for: "onPrimary")
88
+ branding.secondary = brandingConfig.color(for: "secondary")
89
+ branding.onSecondary = brandingConfig.color(for: "onSecondary")
90
+ branding.outline = brandingConfig.color(for: "outline")
91
+ branding.error = brandingConfig.color(for: "error")
92
+ branding.success = brandingConfig.color(for: "success")
93
+ branding.buttonRadius = (brandingConfig["buttonRadius"] as? Double).map { CGFloat($0) }
136
94
  if
137
- let font = brandingConfig[VeriffSdk.FONT] as? [String: Any],
138
- let regular = font["regularFontName"] as? String,
139
- let light = font["lightFontName"] as? String,
140
- let semiBold = font["semiBoldFontName"] as? String,
141
- let bold = font["boldFontName"] as? String
95
+ let font = brandingConfig["iOSFont"] as? [String: Any],
96
+ let regular = font["regular"] as? String,
97
+ let medium = font["medium"] as? String,
98
+ let bold = font["bold"] as? String
142
99
  {
143
- branding?.font = Veriff.VeriffSdk.Branding.Font(regularFontName: regular, lightFontName: light, semiBoldFontName: semiBold, boldFontName: bold)
100
+ branding.font = Veriff.VeriffSdk.Branding.Font(regular: regular, medium: medium, bold: bold)
144
101
  }
102
+
103
+ veriffBranding = branding
145
104
  }
146
105
 
147
106
  let sessionURL: URL
@@ -156,7 +115,7 @@ class VeriffSdk: NSObject {
156
115
  locale = Locale(identifier: languageLocale)
157
116
  }
158
117
 
159
- veriffConfiguration = Veriff.VeriffSdk.Configuration(branding: branding, languageLocale: locale)
118
+ veriffConfiguration = Veriff.VeriffSdk.Configuration(branding: veriffBranding, languageLocale: locale)
160
119
  veriffConfiguration?.customIntroScreen = VeriffSdk.checkCustomIntro(configuration: configuration)
161
120
  } else if let sessionToken = configuration[VeriffSdk.SESSION_TOKEN] as? String {
162
121
  // Using deprecated API
@@ -166,7 +125,7 @@ class VeriffSdk: NSObject {
166
125
  }
167
126
  sessionURL = baseURL.appendingPathComponent(sessionToken)
168
127
 
169
- veriffConfiguration = Veriff.VeriffSdk.Configuration(branding: branding)
128
+ veriffConfiguration = Veriff.VeriffSdk.Configuration(branding: veriffBranding)
170
129
  veriffConfiguration?.customIntroScreen = VeriffSdk.checkCustomIntro(configuration: configuration)
171
130
  } else {
172
131
  // Failed to configure
@@ -199,24 +158,6 @@ class VeriffSdk: NSObject {
199
158
  return components?.queryItems
200
159
  }
201
160
 
202
- private static func parseColor(hexcolor: String) -> UIColor {
203
- if (hexcolor.starts(with: "#")) {
204
- return parseColor(hexcolor: String(hexcolor.dropFirst()))
205
- }
206
- var color: UInt64 = 0
207
- Scanner(string: hexcolor).scanHexInt64(&color)
208
- var a: CGFloat = 1.0
209
- if (hexcolor.count > 7) {
210
- // #rrggbbaa
211
- a = CGFloat(color & 0xff) / 255.0
212
- color = color >> 8
213
- }
214
- let r = CGFloat((color >> 16) & 0xff) / 255.0
215
- let g = CGFloat((color >> 8) & 0xff) / 255.0
216
- let b = CGFloat(color & 0xff) / 255.0
217
- return UIColor(red: r, green: g, blue: b, alpha: a)
218
- }
219
-
220
161
  private static func resultToStatus(result: Veriff.VeriffSdk.Result) -> (Veriff.VeriffSdk.Status, String) {
221
162
  switch result.status {
222
163
  case .done:
@@ -264,9 +205,8 @@ extension VeriffSdk: VeriffSdkDelegate {
264
205
  }
265
206
  }
266
207
 
267
- private extension Dictionary where Key == String, Value == Any {
268
- func image(for key: String) -> Any? {
269
- let imageProvider = VeriffSdkImageProvider(imageSource: self[key])
208
+ private extension Dictionary where Key == String, Value == AnyObject {
209
+ func image(for key: String) -> UIImage? {
270
210
  if
271
211
  let imageDict = self[key] as? [String: AnyObject],
272
212
  let urlString = imageDict["uri"] as? String,
@@ -276,12 +216,31 @@ private extension Dictionary where Key == String, Value == Any {
276
216
  {
277
217
  return UIImage(data: data)
278
218
  } else {
279
- return imageProvider.loadLocalAsset()
219
+ return VeriffSdkImageProvider(imageSource: self[key]).loadLocalAsset()
280
220
  }
281
221
  }
282
222
 
283
- mutating func addValue(_ value: Any?, for key: String) {
284
- guard let value = value else { return }
285
- self[key] = value
223
+ func color(for key: String) -> UIColor? {
224
+ (self[key] as? String).map { $0.color }
225
+ }
226
+ }
227
+
228
+ private extension String {
229
+ var color: UIColor {
230
+ if starts(with: "#") {
231
+ return String(dropFirst()).color
232
+ }
233
+ var color: UInt64 = 0
234
+ Scanner(string: self).scanHexInt64(&color)
235
+ var a: CGFloat = 1
236
+ if count > 7 {
237
+ // #rrggbbaa
238
+ a = CGFloat(color & 0xff) / 255.0
239
+ color = color >> 8
240
+ }
241
+ let r = CGFloat((color >> 16) & 0xff) / 255.0
242
+ let g = CGFloat((color >> 8) & 0xff) / 255.0
243
+ let b = CGFloat(color & 0xff) / 255.0
244
+ return UIColor(red: r, green: g, blue: b, alpha: a)
286
245
  }
287
246
  }
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": "2.12.0",
4
+ "version": "3.0.0",
5
5
  "description": "React Native SDK for Veriff identity verification",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -20,6 +20,5 @@ Pod::Spec.new do |s|
20
20
  s.requires_arc = true
21
21
 
22
22
  s.dependency "React"
23
- s.dependency "VeriffSDK", ">= 4.34.0"
24
- s.dependency "lottie-ios"
23
+ s.dependency "VeriffSDK", "6.1.0"
25
24
  end
@@ -1,105 +0,0 @@
1
- package com.veriff.sdk.reactnative;
2
-
3
- import android.content.Context;
4
- import android.graphics.Typeface;
5
- import android.graphics.drawable.Drawable;
6
- import android.os.Parcel;
7
- import android.os.Parcelable;
8
- import android.util.Log;
9
- import androidx.annotation.NonNull;
10
- import androidx.annotation.Nullable;
11
- import com.veriff.Branding;
12
- import com.veriff.Branding.ExternalResources.Image;
13
- import com.veriff.Branding.ExternalResources.Lottie;
14
-
15
- import java.io.IOException;
16
- import java.util.HashMap;
17
- import java.util.Map;
18
-
19
- import static com.veriff.sdk.reactnative.VeriffSdkModule.TAG;
20
-
21
- public class ReactNativeExternalResources implements Branding.ExternalResources, Parcelable {
22
- private final ImageLoader imageLoader = new ImageLoader();
23
-
24
- private final Map<Image, String> imageUrls;
25
- private final Map<Lottie, String> lottieJson;
26
-
27
- protected ReactNativeExternalResources(Parcel in) {
28
- imageUrls = readMapFromParcel(in, Image.values());
29
- lottieJson = readMapFromParcel(in, Lottie.values());
30
- }
31
-
32
- public ReactNativeExternalResources(Map<Image, String> imageUrls, Map<Lottie, String> lottieJson) {
33
- this.imageUrls = imageUrls;
34
- this.lottieJson = lottieJson;
35
- }
36
-
37
- @Nullable
38
- @Override
39
- public Drawable loadImage(@NonNull Context context, @NonNull Image target) throws IOException {
40
- String imageUrl = imageUrls.get(target);
41
- if (imageUrl != null) {
42
- return imageLoader.load(context, imageUrl);
43
- } else {
44
- return null;
45
- }
46
- }
47
-
48
- @Nullable
49
- @Override
50
- public String getLottieJson(Context context, @NonNull Lottie target) {
51
- return lottieJson.get(target);
52
- }
53
-
54
- public static final Creator<ReactNativeExternalResources> CREATOR = new Creator<ReactNativeExternalResources>() {
55
- @Override
56
- public ReactNativeExternalResources createFromParcel(Parcel in) {
57
- return new ReactNativeExternalResources(in);
58
- }
59
-
60
- @Override
61
- public ReactNativeExternalResources[] newArray(int size) {
62
- return new ReactNativeExternalResources[size];
63
- }
64
- };
65
-
66
- @Override
67
- public int describeContents() {
68
- return 0;
69
- }
70
-
71
- @Override
72
- public void writeToParcel(Parcel dest, int flags) {
73
- writeMapToParcel(dest, imageUrls);
74
- writeMapToParcel(dest, lottieJson);
75
- }
76
-
77
- private <E extends Enum<E>> void writeMapToParcel(Parcel dest, Map<E, String> map) {
78
- dest.writeInt(map.size());
79
- for (Map.Entry<E, String> entry : map.entrySet()) {
80
- dest.writeInt(entry.getKey().ordinal());
81
- dest.writeString(entry.getValue());
82
- Log.d(TAG, String.format("Write to parcel [%s] -> [%s]", entry.getKey().ordinal(), entry.getValue()));
83
- }
84
- }
85
-
86
- public <E extends Enum<E>> Map<E, String> readMapFromParcel(Parcel in, E[] values) {
87
- int count = in.readInt();
88
-
89
- Map<E, String> map = new HashMap<>(count);
90
-
91
- int i = 0;
92
- while (i < count) {
93
- i++;
94
-
95
- int ordinal = in.readInt();
96
- String value = in.readString();
97
- Log.d(TAG, String.format("Read from parcel [%s] -> [%s]", ordinal, value));
98
-
99
- E key = values[ordinal];
100
- map.put(key, value);
101
- }
102
-
103
- return map;
104
- }
105
- }
@@ -1,114 +0,0 @@
1
- package com.veriff.sdk.reactnative.mapper;
2
-
3
- import android.graphics.Typeface;
4
- import android.util.JsonWriter;
5
- import android.util.Log;
6
- import androidx.annotation.NonNull;
7
- import com.facebook.infer.annotation.Assertions;
8
- import com.facebook.react.bridge.Dynamic;
9
- import com.facebook.react.bridge.ReadableArray;
10
- import com.facebook.react.bridge.ReadableMap;
11
- import com.facebook.react.bridge.ReadableNativeMap;
12
- import com.veriff.sdk.reactnative.ImageLoader;
13
- import com.veriff.sdk.reactnative.ReactNativeExternalResources;
14
- import com.veriff.Branding;
15
- import com.veriff.Branding.ExternalResources.Image;
16
- import com.veriff.Branding.ExternalResources.Lottie;
17
-
18
- import java.util.HashMap;
19
- import java.util.Iterator;
20
- import java.util.LinkedHashMap;
21
- import java.util.Map;
22
-
23
- import static com.veriff.sdk.reactnative.VeriffSdkModule.KEY_ADVANCED_CONFIGURATIONS;
24
- import static com.veriff.sdk.reactnative.VeriffSdkModule.TAG;
25
-
26
- public class ExternalResourcesMapper {
27
- public ReactNativeExternalResources map(ReadableMap brandConfig) {
28
- Map<Image, String> images = mapImages(brandConfig);
29
- Map<Lottie, String> lottie = mapLottie(brandConfig);
30
-
31
- if (!images.isEmpty() || !lottie.isEmpty()) {
32
- return new ReactNativeExternalResources(images, lottie);
33
- } else {
34
- return null;
35
- }
36
- }
37
-
38
- private Map<Image, String> mapImages(ReadableMap brandConfig) {
39
- Map<Image, String> images = new HashMap();
40
- if (brandConfig.hasKey(KEY_ADVANCED_CONFIGURATIONS)) {
41
- ReadableMap config = brandConfig.getMap(KEY_ADVANCED_CONFIGURATIONS);
42
-
43
- appendImage(config, KEY_DOCUMENT_FRONT, images, Image.DOCUMENT_FRONT);
44
- appendImage(config, KEY_DOCUMENT_BACK, images, Image.DOCUMENT_BACK_END);
45
- appendImage(config, KEY_BANNER_ERROR_ICON, images, Image.BANNER_ICON_ERROR);
46
- appendImage(config, KEY_CAMERA_ERROR, images, Image.ERROR_CAMERA);
47
- appendImage(config, KEY_MICROPHONE_ERROR, images, Image.ERROR_MICROPHONE);
48
- appendImage(config, KEY_SERVER_ERROR, images, Image.ERROR_SYSTEM);
49
- appendImage(config, KEY_LOCAL_ERROR, images, Image.ERROR_SYSTEM);
50
- appendImage(config, KEY_NETWORK_ERROR, images, Image.ERROR_NETWORK);
51
- appendImage(config, KEY_VERSION_ERROR, images, Image.ERROR_VERSION);
52
- appendImage(config, KEY_UNKNOWN_ERROR, images, Image.ERROR_UNKNOWN);
53
- appendImage(config, KEY_CONSENT_ICON, images, Image.CONSENT_IMAGE);
54
- }
55
-
56
- return images;
57
- }
58
-
59
- private void appendImage(
60
- ReadableMap advancedConfig,
61
- String configKey,
62
- Map<Branding.ExternalResources.Image, String> map,
63
- Branding.ExternalResources.Image mapKey
64
- ) {
65
- if (advancedConfig.hasKey(configKey)) {
66
- ReadableMap item = advancedConfig.getMap(configKey);
67
- String url = item.getString("uri");
68
- if (url != null) {
69
- map.put(mapKey, url);
70
- }
71
- }
72
- }
73
-
74
- private Map<Lottie, String> mapLottie(ReadableMap brandConfig) {
75
- Map<Lottie, String> lottie = new HashMap();
76
-
77
- if (brandConfig.hasKey(KEY_ADVANCED_CONFIGURATIONS)) {
78
- ReadableMap config = brandConfig.getMap(KEY_ADVANCED_CONFIGURATIONS);
79
-
80
- appendLottie(config, KEY_LOTTIE_PROGRESS, lottie, Lottie.PROGRESS);
81
-
82
- }
83
-
84
- return lottie;
85
- }
86
-
87
- private void appendLottie(
88
- ReadableMap advancedConfig,
89
- String configKey,
90
- Map<Lottie, String> map,
91
- Lottie mapKey
92
- ) {
93
- if (advancedConfig.hasKey(configKey)) {
94
- String lottie = advancedConfig.getString(configKey);
95
-
96
- map.put(mapKey, lottie);
97
- }
98
- }
99
-
100
- private final String KEY_DOCUMENT_FRONT = "documentFrontIcon";
101
- private final String KEY_DOCUMENT_BACK = "documentBackIcon";
102
- private final String KEY_BANNER_ERROR_ICON = "bannerErrorIcon";
103
- private final String KEY_CONSENT_ICON = "consentIcon";
104
-
105
- private final String KEY_CAMERA_ERROR = "cameraUnavailableErrorIcon";
106
- private final String KEY_MICROPHONE_ERROR = "microphoneUnavailableErrorIcon";
107
- private final String KEY_SERVER_ERROR = "serverErrorIcon";
108
- private final String KEY_LOCAL_ERROR = "localErrorIcon";
109
- private final String KEY_NETWORK_ERROR = "networkErrorIcon";
110
- private final String KEY_VERSION_ERROR = "deprecatedSDKVersionErrorIcon";
111
- private final String KEY_UNKNOWN_ERROR = "unknownErrorIcon";
112
-
113
- private final String KEY_LOTTIE_PROGRESS = "loadingAnimation";
114
- }