@veriff/react-native-sdk 3.1.0 → 4.1.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.
- package/android/build.gradle +3 -2
- package/android/gradle.properties +1 -0
- package/android/src/main/java/com/veriff/sdk/reactnative/VeriffSdkModule.java +65 -15
- package/android/src/main/java/com/veriff/sdk/reactnative/VeriffSdkPackage.java +1 -0
- package/babel.config.js +3 -0
- package/ios/Podfile +3 -3
- package/ios/VeriffSdk.swift +2 -6
- package/package.json +34 -8
- package/react-native-sdk.podspec +2 -2
package/android/build.gradle
CHANGED
|
@@ -41,6 +41,7 @@ repositories {
|
|
|
41
41
|
|
|
42
42
|
dependencies {
|
|
43
43
|
//noinspection GradleDynamicVersion
|
|
44
|
-
implementation 'com.facebook.react:react-
|
|
45
|
-
|
|
44
|
+
implementation 'com.facebook.react:react-android:+'
|
|
45
|
+
|
|
46
|
+
implementation 'com.veriff:veriff-library:6.5.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
|
-
|
|
212
|
-
|
|
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
|
|
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/babel.config.js
ADDED
package/ios/Podfile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
platform :ios, '
|
|
2
|
-
|
|
1
|
+
platform :ios, '12.4'
|
|
2
|
+
|
|
3
3
|
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
|
4
4
|
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
|
5
5
|
|
|
6
6
|
target 'VeriffSdk' do
|
|
7
7
|
# Pods for VeriffSdk
|
|
8
|
-
pod 'VeriffSDK', '6.
|
|
8
|
+
pod 'VeriffSDK', '6.7.0'
|
|
9
9
|
|
|
10
10
|
config = use_native_modules!
|
|
11
11
|
|
package/ios/VeriffSdk.swift
CHANGED
|
@@ -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,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veriff/react-native-sdk",
|
|
3
3
|
"title": "React Native Veriff SDK",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"description": "React Native SDK for Veriff identity verification",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"lint": "eslint ."
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"check-dependencies": "rnx-align-deps",
|
|
10
|
+
"fix-dependencies": "rnx-align-deps --write"
|
|
9
11
|
},
|
|
10
12
|
"homepage": "https://developers.veriff.com/#react-native-sdk-integration",
|
|
11
13
|
"keywords": [
|
|
@@ -25,14 +27,16 @@
|
|
|
25
27
|
"licenseFilename": "LICENSE",
|
|
26
28
|
"readmeFilename": "README.md",
|
|
27
29
|
"peerDependencies": {
|
|
28
|
-
"react": "
|
|
29
|
-
"react-native": "
|
|
30
|
+
"react": "18.2.0",
|
|
31
|
+
"react-native": "^0.71.0"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"react": "
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
35
|
+
"@rnx-kit/align-deps": "^2.2.0",
|
|
36
|
+
"eslint": "^8.19.0",
|
|
37
|
+
"react": "18.2.0",
|
|
38
|
+
"react-native": "^0.71.0",
|
|
39
|
+
"prettier": "^2.4.1"
|
|
36
40
|
},
|
|
37
41
|
"resolutions": {
|
|
38
42
|
"ansi-regex": "^5.0.1",
|
|
@@ -55,5 +59,27 @@
|
|
|
55
59
|
"node-fetch": "Resolving to 2.6.7 to fix vulnerability (https://www.npmjs.com/advisories/1064646)",
|
|
56
60
|
"plist": "Resolving to 3.0.4 to fix vulnerability (https://www.npmjs.com/advisories/1064605)",
|
|
57
61
|
"ajv": "Resolving to 6.12.3 to fix vulnerability (https://www.npmjs.com/advisories/1065159)"
|
|
62
|
+
},
|
|
63
|
+
"rnx-kit": {
|
|
64
|
+
"kitType": "library",
|
|
65
|
+
"alignDeps": {
|
|
66
|
+
"requirements": {
|
|
67
|
+
"development": [
|
|
68
|
+
"react-native@0.71"
|
|
69
|
+
],
|
|
70
|
+
"production": [
|
|
71
|
+
"react-native@0.71"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"capabilities": [
|
|
75
|
+
"core",
|
|
76
|
+
"core-android",
|
|
77
|
+
"core-ios",
|
|
78
|
+
"react"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"eslint-plugin-ft-flow": "^2.0.3"
|
|
58
84
|
}
|
|
59
85
|
}
|
package/react-native-sdk.podspec
CHANGED
|
@@ -13,12 +13,12 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.license = "MIT"
|
|
14
14
|
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
|
|
15
15
|
s.authors = { "Veriff" => "support@veriff.com" }
|
|
16
|
-
s.platforms = { :ios => "
|
|
16
|
+
s.platforms = { :ios => "12.4" }
|
|
17
17
|
s.source = { :git => "https://github.com/veriff/react-native-sdk.git", :tag => "#{s.version}" }
|
|
18
18
|
|
|
19
19
|
s.source_files = "ios/**/*.{h,m,swift}"
|
|
20
20
|
s.requires_arc = true
|
|
21
21
|
|
|
22
22
|
s.dependency "React"
|
|
23
|
-
s.dependency "VeriffSDK", "6.
|
|
23
|
+
s.dependency "VeriffSDK", "6.7.0"
|
|
24
24
|
end
|