@soyio/soyio-rn-sdk-native-disclosure 0.0.0-bootstrap.0 → 6.0.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/README.md +105 -2
- package/android/build.gradle +57 -0
- package/android/libs/facetec-sdk-9.7.114.aar +0 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/java/com/soyio/soyiorndk/AndroidFacetecSdkModule.kt +224 -0
- package/android/src/main/java/com/soyio/soyiorndk/AndroidFacetecSdkPackage.kt +16 -0
- package/android/src/main/java/com/soyio/soyiorndk/ApiDate.kt +5 -0
- package/android/src/main/java/com/soyio/soyiorndk/BaseFaceTecProcessor.kt +75 -0
- package/android/src/main/java/com/soyio/soyiorndk/FaceTecRequestService.kt +115 -0
- package/android/src/main/java/com/soyio/soyiorndk/FacetecConfig.kt +311 -0
- package/android/src/main/java/com/soyio/soyiorndk/SoyioIdOnlyProcessor.kt +81 -0
- package/android/src/main/java/com/soyio/soyiorndk/SoyioValidationProcessor.kt +136 -0
- package/android/src/main/res/drawable-nodpi/soyio_facetec_close.png +0 -0
- package/android/src/main/res/drawable-nodpi/soyio_facetec_id_front.png +0 -0
- package/android/src/main/res/values/strings.xml +134 -0
- package/assets/fonts/RobotoFlex.ttf +0 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/Contents.json +23 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/facetec-close@1x.png +0 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/facetec-close@2x.png +0 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-close.imageset/facetec-close@3x.png +0 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/Contents.json +23 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/facetec-id-front@1x.png +0 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/facetec-id-front@2x.png +0 -0
- package/assets/images/SoyioRnSdk.xcassets/facetec-id-front.imageset/facetec-id-front@3x.png +0 -0
- package/index.js +1 -3
- package/ios/ApiDate.swift +5 -0
- package/ios/FacetecConfig.swift +217 -0
- package/ios/FacetecStrings.swift +139 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/Info.plist +44 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Assets.car +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/FaceTecSDK +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/GenericGuidanceContentLayout.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Headers/FaceTecPublicApi.h +1935 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Headers/FaceTecPublicStringKeys.h +109 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Headers/FaceTecSDK.h +16 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Info.plist +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Modules/module.modulemap +6 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/PrivacyInfo.xcprivacy +29 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/ReadyScreenGuidanceContentLayout.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/RetryScreenGuidanceContentLayout.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/SharedGuidanceLayout.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/9Uo-4b-JiE-view-Ae0-rb-UqS.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/CJ6-MX-bJp-view-8JL-Rc-0g1.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/FaceScanViewController.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/FaceTecAdditionalReviewViewController.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/FaceTecIDFeedbackViewController.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/FaceTecOCRConfirmationViewController.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/IDCaptureViewController.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/IDSelectionViewController.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/Info.plist +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/Pyw-6G-JSY-view-Zue-Eo-Q2U.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/QWA-8Y-vUM-view-wJB-Z5-eD2.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/alz-Ia-X3d-view-IKu-EI-Hug.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/Storyboard.storyboardc/l2Q-cc-kD8-view-UUy-6c-meu.nib +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/_CodeSignature/CodeResources +729 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/af.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/ar.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/attributions.txt +462 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/de.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/el.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/en.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/es.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/fr.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/kk.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/nb.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/pt-BR.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/ru.lproj/FaceTec.strings +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64/FaceTecSDK.framework/strip-unused-architectures-from-target.sh +62 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/FaceTecSDK +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/Headers/FaceTecPublicApi.h +1935 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/Headers/FaceTecPublicStringKeys.h +109 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/Headers/FaceTecSDK.h +16 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/Info.plist +0 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/Modules/module.modulemap +6 -0
- package/ios/Frameworks/FaceTecSDK.xcframework/ios-arm64_x86_64-simulator/FaceTecSDK.framework/_CodeSignature/CodeResources +146 -0
- package/ios/IOSFacetecSdk.m +22 -0
- package/ios/IOSFacetecSdk.swift +221 -0
- package/ios/ProcessorProtocol.swift +6 -0
- package/ios/SoyioIDOnlyProcessor.swift +170 -0
- package/ios/SoyioPhotoIDMatchProcessor.swift +264 -0
- package/package.json +38 -6
- package/react-native.config.js +14 -0
- package/scripts/prepare-facetec-xcframework.sh +38 -0
- package/soyio_rn_sdk_native_disclosure.podspec +52 -0
package/README.md
CHANGED
|
@@ -1,5 +1,108 @@
|
|
|
1
1
|
# @soyio/soyio-rn-sdk-native-disclosure
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Optional native disclosure addon for `@soyio/soyio-rn-sdk`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Install this package alongside the core SDK only if your disclosure flow requires the native FaceTec-backed experience.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
# Using npm
|
|
11
|
+
npm install @soyio/soyio-rn-sdk @soyio/soyio-rn-sdk-native-disclosure
|
|
12
|
+
|
|
13
|
+
# Using yarn
|
|
14
|
+
yarn add @soyio/soyio-rn-sdk @soyio/soyio-rn-sdk-native-disclosure
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
After installing on iOS, run:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
cd ios && pod install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Android Setup
|
|
24
|
+
|
|
25
|
+
Add the addon AAR repository to `android/settings.gradle`:
|
|
26
|
+
|
|
27
|
+
```gradle
|
|
28
|
+
dependencyResolutionManagement {
|
|
29
|
+
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
|
|
30
|
+
repositories {
|
|
31
|
+
flatDir {
|
|
32
|
+
dirs(
|
|
33
|
+
"$rootDir/../node_modules/@soyio/soyio-rn-sdk-native-disclosure/android/libs",
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Add the required manifest entries inside `android/app/src/main/AndroidManifest.xml`:
|
|
41
|
+
|
|
42
|
+
```xml
|
|
43
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
44
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
45
|
+
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If your disclosure flow requires NFC, also add:
|
|
49
|
+
|
|
50
|
+
```xml
|
|
51
|
+
<uses-permission android:name="android.permission.NFC" />
|
|
52
|
+
<uses-feature android:name="android.hardware.nfc" android:required="false" />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## iOS Setup
|
|
56
|
+
|
|
57
|
+
Add the required purpose string to `ios/YourApp/Info.plist`:
|
|
58
|
+
|
|
59
|
+
```xml
|
|
60
|
+
<key>NSCameraUsageDescription</key>
|
|
61
|
+
<string>This app needs access to camera for document verification</string>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If your disclosure flow requires NFC, also add:
|
|
65
|
+
|
|
66
|
+
```xml
|
|
67
|
+
<key>NFCReaderUsageDescription</key>
|
|
68
|
+
<string>This app needs access to NFC for identity document verification</string>
|
|
69
|
+
|
|
70
|
+
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
|
|
71
|
+
<array>
|
|
72
|
+
<string>A0000002471001</string>
|
|
73
|
+
<string>A0000002472001</string>
|
|
74
|
+
</array>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For NFC support, create or update `ios/YourApp/YourApp.entitlements`:
|
|
78
|
+
|
|
79
|
+
```xml
|
|
80
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
81
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
82
|
+
<plist version="1.0">
|
|
83
|
+
<dict>
|
|
84
|
+
<key>com.apple.developer.nfc.readersession.formats</key>
|
|
85
|
+
<array>
|
|
86
|
+
<string>TAG</string>
|
|
87
|
+
</array>
|
|
88
|
+
</dict>
|
|
89
|
+
</plist>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then add the **Near Field Communication Tag Reading** capability in Xcode and point **Build Settings -> Code Signing Entitlements** at that entitlements file.
|
|
93
|
+
|
|
94
|
+
## Apple Silicon Simulator Compatibility
|
|
95
|
+
|
|
96
|
+
The podspec for this addon is already configured to handle Apple Silicon simulators by excluding the `arm64` architecture for simulator builds. However, if you encounter linker issues on an Apple Silicon Mac, you can manually add the following to your app's `Podfile`:
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
post_install do |installer|
|
|
100
|
+
installer.pods_project.targets.each do |target|
|
|
101
|
+
if target.name == 'soyio_rn_sdk_native_disclosure'
|
|
102
|
+
target.build_configurations.each do |config|
|
|
103
|
+
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
apply plugin: 'kotlin-android'
|
|
3
|
+
|
|
4
|
+
def safeExtGet(prop, fallback) {
|
|
5
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
android {
|
|
9
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 34)
|
|
10
|
+
namespace "com.soyio.soyiorndk"
|
|
11
|
+
def javaVersion = safeExtGet('javaVersion', JavaVersion.VERSION_17)
|
|
12
|
+
|
|
13
|
+
defaultConfig {
|
|
14
|
+
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
15
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 34)
|
|
16
|
+
versionCode 1
|
|
17
|
+
versionName "1.0"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
buildTypes {
|
|
21
|
+
release {
|
|
22
|
+
minifyEnabled false
|
|
23
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
compileOptions {
|
|
28
|
+
sourceCompatibility javaVersion
|
|
29
|
+
targetCompatibility javaVersion
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
kotlinOptions {
|
|
33
|
+
jvmTarget = javaVersion.toString()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
sourceSets {
|
|
37
|
+
main {
|
|
38
|
+
assets.srcDirs += ['../assets']
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
repositories {
|
|
44
|
+
flatDir {
|
|
45
|
+
dirs 'libs'
|
|
46
|
+
}
|
|
47
|
+
google()
|
|
48
|
+
mavenCentral()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
dependencies {
|
|
52
|
+
def kotlinVersion = safeExtGet('kotlinVersion', '1.8.0')
|
|
53
|
+
implementation "com.facebook.react:react-android"
|
|
54
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
|
|
55
|
+
implementation(name: "facetec-sdk-9.7.114", ext: "aar")
|
|
56
|
+
implementation "com.squareup.okhttp3:okhttp:3.12.13"
|
|
57
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
package com.soyio.soyiorndk
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import com.facebook.react.bridge.*
|
|
5
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
6
|
+
import com.facetec.sdk.FaceTecSDK
|
|
7
|
+
|
|
8
|
+
class AndroidFacetecSdkModule(reactContext: ReactApplicationContext) :
|
|
9
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
10
|
+
|
|
11
|
+
private var isInitialized = false
|
|
12
|
+
|
|
13
|
+
override fun getName(): String = NAME
|
|
14
|
+
|
|
15
|
+
@ReactMethod
|
|
16
|
+
fun addListener(eventName: String) {
|
|
17
|
+
// No-op: required for NativeEventEmitter support
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@ReactMethod
|
|
21
|
+
fun removeListeners(count: Int) {
|
|
22
|
+
// No-op
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@ReactMethod
|
|
26
|
+
fun initialize(options: ReadableMap, promise: Promise) {
|
|
27
|
+
if (isInitialized) {
|
|
28
|
+
val result = Arguments.createMap().apply { putBoolean("success", true) }
|
|
29
|
+
promise.resolve(result)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
val productionKeyText = options.getRequiredString(MOBILE_PRODUCTION_KEY_TEXT, promise) ?: return
|
|
34
|
+
val deviceKeyIdentifier = options.getRequiredString(DEVICE_KEY_IDENTIFIER, promise) ?: return
|
|
35
|
+
val publicFaceScanEncryptionKey = options.getRequiredString(PUBLIC_FACE_SCAN_KEY, promise) ?: return
|
|
36
|
+
|
|
37
|
+
val activity: Activity? = currentActivity
|
|
38
|
+
val context = activity ?: reactApplicationContext
|
|
39
|
+
|
|
40
|
+
val initializeSdk = {
|
|
41
|
+
val theme = if (options.hasKey(THEME) && !options.isNull(THEME)) options.getMap(THEME) else null
|
|
42
|
+
FacetecConfig.apply(reactApplicationContext, theme)
|
|
43
|
+
|
|
44
|
+
val callback = { successful: Boolean ->
|
|
45
|
+
isInitialized = successful
|
|
46
|
+
if (successful) {
|
|
47
|
+
val result = Arguments.createMap().apply { putBoolean("success", true) }
|
|
48
|
+
promise.resolve(result)
|
|
49
|
+
} else {
|
|
50
|
+
val result = Arguments.createMap().apply {
|
|
51
|
+
putBoolean("success", false)
|
|
52
|
+
putString("error", "FaceTec SDK did not finish initialization. Verify the provided keys and device settings.")
|
|
53
|
+
}
|
|
54
|
+
promise.resolve(result)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
FaceTecSDK.initializeInProductionMode(
|
|
59
|
+
context,
|
|
60
|
+
productionKeyText,
|
|
61
|
+
deviceKeyIdentifier,
|
|
62
|
+
publicFaceScanEncryptionKey,
|
|
63
|
+
callback,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (UiThreadUtil.isOnUiThread()) {
|
|
68
|
+
initializeSdk()
|
|
69
|
+
} else {
|
|
70
|
+
UiThreadUtil.runOnUiThread(initializeSdk)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ReactMethod
|
|
75
|
+
fun initializeFaceTecSDK(config: ReadableMap, promise: Promise) {
|
|
76
|
+
val mapped = Arguments.createMap().apply {
|
|
77
|
+
putString(MOBILE_PRODUCTION_KEY_TEXT, config.getString("mobileProductionKey") ?: "")
|
|
78
|
+
putString(DEVICE_KEY_IDENTIFIER, config.getString("deviceKey") ?: "")
|
|
79
|
+
putString(PUBLIC_FACE_SCAN_KEY, config.getString("publicKey") ?: "")
|
|
80
|
+
if (config.hasKey("theme") && !config.isNull("theme")) {
|
|
81
|
+
putMap(THEME, config.getMap("theme"))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
initialize(mapped, promise)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@ReactMethod
|
|
88
|
+
fun startLivenessSession(options: ReadableMap, promise: Promise) {
|
|
89
|
+
if (!isInitialized) {
|
|
90
|
+
promise.reject(FACETEC_NOT_INITIALIZED, "Initialize FaceTec SDK before starting a session.")
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
val sessionToken = options.getRequiredString(SESSION_TOKEN, promise) ?: return
|
|
95
|
+
val requestableToken = options.getRequiredString(REQUESTABLE_TOKEN, promise) ?: return
|
|
96
|
+
val resourcePath = options.getRequiredString(RESOURCE_PATH, promise) ?: return
|
|
97
|
+
val baseUrl = options.getRequiredString(BASE_URL, promise) ?: return
|
|
98
|
+
val authToken = options.getRequiredString(AUTH_TOKEN, promise) ?: return
|
|
99
|
+
val isIdOnly = if (options.hasKey(IS_ID_ONLY)) options.getBoolean(IS_ID_ONLY) else false
|
|
100
|
+
|
|
101
|
+
val activity: Activity? = currentActivity
|
|
102
|
+
if (activity == null) {
|
|
103
|
+
promise.reject(NO_ACTIVITY, "Unable to access current Activity to show FaceTec UI.")
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (isIdOnly) {
|
|
108
|
+
SoyioIdOnlyProcessor(
|
|
109
|
+
activity,
|
|
110
|
+
sessionToken,
|
|
111
|
+
baseUrl,
|
|
112
|
+
resourcePath,
|
|
113
|
+
requestableToken,
|
|
114
|
+
authToken,
|
|
115
|
+
promise,
|
|
116
|
+
)
|
|
117
|
+
} else {
|
|
118
|
+
SoyioValidationProcessor(
|
|
119
|
+
activity,
|
|
120
|
+
sessionToken,
|
|
121
|
+
baseUrl,
|
|
122
|
+
resourcePath,
|
|
123
|
+
requestableToken,
|
|
124
|
+
authToken,
|
|
125
|
+
promise,
|
|
126
|
+
{ sendEvent(LIVENESS_SUCCESS_EVENT, null) },
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@ReactMethod
|
|
132
|
+
fun startLivenessAndIDVerification(config: ReadableMap, promise: Promise) {
|
|
133
|
+
startVerification(config, promise, false)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@ReactMethod
|
|
137
|
+
fun startIDOnlyVerification(config: ReadableMap, promise: Promise) {
|
|
138
|
+
startVerification(config, promise, true)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private fun startVerification(config: ReadableMap, promise: Promise, isIdOnly: Boolean) {
|
|
142
|
+
val facetecToken = config.getString("facetecSessionToken")
|
|
143
|
+
val soyioToken = config.getString("soyioSessionToken")
|
|
144
|
+
val requestableToken = config.getString("disclosureRequestToken")
|
|
145
|
+
val baseUrl = config.getString("baseUrl")
|
|
146
|
+
|
|
147
|
+
if (facetecToken.isNullOrBlank() || soyioToken.isNullOrBlank() || requestableToken.isNullOrBlank() || baseUrl.isNullOrBlank()) {
|
|
148
|
+
promise.reject(FACETEC_INVALID_CONFIG, "Invalid FaceTec verification configuration.")
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
val resourcePath = try {
|
|
153
|
+
mapTokenToResourcePath(requestableToken)
|
|
154
|
+
} catch (error: IllegalArgumentException) {
|
|
155
|
+
promise.reject(FACETEC_INVALID_CONFIG, error.message)
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
val options = Arguments.createMap().apply {
|
|
160
|
+
putString(SESSION_TOKEN, facetecToken)
|
|
161
|
+
putString(REQUESTABLE_TOKEN, requestableToken)
|
|
162
|
+
putString(RESOURCE_PATH, resourcePath)
|
|
163
|
+
putString(BASE_URL, baseUrl)
|
|
164
|
+
putString(AUTH_TOKEN, soyioToken)
|
|
165
|
+
putBoolean(IS_ID_ONLY, isIdOnly)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
startLivenessSession(options, promise)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private fun ReadableMap.getRequiredString(key: String, promise: Promise): String? {
|
|
172
|
+
if (!hasKey(key)) {
|
|
173
|
+
promise.reject(MISSING_OPTION, "Missing required FaceTec initialization field: $key")
|
|
174
|
+
return null
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
val value = getString(key)
|
|
178
|
+
if (value.isNullOrBlank()) {
|
|
179
|
+
promise.reject(MISSING_OPTION, "Field '$key' must be a non-empty string")
|
|
180
|
+
return null
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return value
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
companion object {
|
|
187
|
+
const val NAME = "AndroidFacetecSdk"
|
|
188
|
+
private const val MOBILE_PRODUCTION_KEY_TEXT = "mobileProductionKeyText"
|
|
189
|
+
private const val DEVICE_KEY_IDENTIFIER = "deviceKeyIdentifier"
|
|
190
|
+
private const val PUBLIC_FACE_SCAN_KEY = "publicFaceScanEncryptionKey"
|
|
191
|
+
private const val FACETEC_INIT_FAILED = "FACETEC_INIT_FAILED"
|
|
192
|
+
private const val MISSING_OPTION = "FACETEC_INIT_OPTION_MISSING"
|
|
193
|
+
private const val FACETEC_NOT_INITIALIZED = "FACETEC_NOT_INITIALIZED"
|
|
194
|
+
private const val NO_ACTIVITY = "FACETEC_NO_ACTIVITY"
|
|
195
|
+
private const val SESSION_TOKEN = "sessionToken"
|
|
196
|
+
private const val REQUESTABLE_TOKEN = "requestableToken"
|
|
197
|
+
private const val RESOURCE_PATH = "resourcePath"
|
|
198
|
+
private const val BASE_URL = "baseUrl"
|
|
199
|
+
private const val AUTH_TOKEN = "authToken"
|
|
200
|
+
private const val IS_ID_ONLY = "isIdOnly"
|
|
201
|
+
private const val THEME = "theme"
|
|
202
|
+
private const val FACETEC_INVALID_CONFIG = "FACETEC_INVALID_CONFIG"
|
|
203
|
+
private const val LIVENESS_SUCCESS_EVENT = "onLivenessSuccess"
|
|
204
|
+
private val TOKEN_PREFIXES = mapOf(
|
|
205
|
+
"dreq_" to "disclosure_requests",
|
|
206
|
+
"dsreq_" to "data_subject_requests",
|
|
207
|
+
"authreq_" to "auth_requests",
|
|
208
|
+
"va_" to "validation_attempts",
|
|
209
|
+
"aa_" to "auth_attempts",
|
|
210
|
+
"sa_" to "signature_attempts",
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private fun mapTokenToResourcePath(token: String): String {
|
|
215
|
+
return TOKEN_PREFIXES.entries.firstOrNull { token.startsWith(it.key) }?.value
|
|
216
|
+
?: throw IllegalArgumentException("Unrecognized token prefix for $token")
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private fun sendEvent(event: String, params: WritableMap?) {
|
|
220
|
+
reactApplicationContext
|
|
221
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
222
|
+
.emit(event, params)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
package com.soyio.soyiorndk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class AndroidFacetecSdkPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(AndroidFacetecSdkModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.soyio.soyiorndk
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.app.Application
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
import android.os.Handler
|
|
7
|
+
import android.os.Looper
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facetec.sdk.FaceTecSessionActivity
|
|
11
|
+
|
|
12
|
+
abstract class BaseFaceTecProcessor(
|
|
13
|
+
private val promise: Promise,
|
|
14
|
+
private val errorCode: String,
|
|
15
|
+
activity: Activity,
|
|
16
|
+
) {
|
|
17
|
+
private val mainHandler = Handler(Looper.getMainLooper())
|
|
18
|
+
private val application = activity.application
|
|
19
|
+
private var promiseResolved = false
|
|
20
|
+
protected val defaultError = "unknown_error"
|
|
21
|
+
protected val flowCancelledError = "FLOW_CANCELLED"
|
|
22
|
+
|
|
23
|
+
@Volatile private var isSuccess = false
|
|
24
|
+
@Volatile private var failureMessage: String? = null
|
|
25
|
+
|
|
26
|
+
private val lifecycleCallbacks = object : Application.ActivityLifecycleCallbacks {
|
|
27
|
+
override fun onActivityDestroyed(a: Activity) {
|
|
28
|
+
if (a is FaceTecSessionActivity) {
|
|
29
|
+
resolveFromTrackedState()
|
|
30
|
+
application.unregisterActivityLifecycleCallbacks(this)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
override fun onActivityCreated(a: Activity, b: Bundle?) {}
|
|
34
|
+
override fun onActivityStarted(a: Activity) {}
|
|
35
|
+
override fun onActivityResumed(a: Activity) {}
|
|
36
|
+
override fun onActivityPaused(a: Activity) {}
|
|
37
|
+
override fun onActivityStopped(a: Activity) {}
|
|
38
|
+
override fun onActivitySaveInstanceState(a: Activity, b: Bundle) {}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
init {
|
|
42
|
+
application.registerActivityLifecycleCallbacks(lifecycleCallbacks)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected fun markSuccess() {
|
|
46
|
+
isSuccess = true
|
|
47
|
+
failureMessage = null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected fun markFailure(message: String = defaultError) {
|
|
51
|
+
isSuccess = false
|
|
52
|
+
failureMessage = message
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Synchronized
|
|
56
|
+
private fun resolveFromTrackedState() {
|
|
57
|
+
if (promiseResolved) return
|
|
58
|
+
promiseResolved = true
|
|
59
|
+
mainHandler.post {
|
|
60
|
+
val result = Arguments.createMap().apply {
|
|
61
|
+
putBoolean("success", isSuccess)
|
|
62
|
+
if (!isSuccess) putString("error", failureMessage ?: defaultError)
|
|
63
|
+
}
|
|
64
|
+
promise.resolve(result)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Synchronized
|
|
69
|
+
protected fun reject(message: String) {
|
|
70
|
+
if (promiseResolved) return
|
|
71
|
+
promiseResolved = true
|
|
72
|
+
application.unregisterActivityLifecycleCallbacks(lifecycleCallbacks)
|
|
73
|
+
mainHandler.post { promise.reject(errorCode, message) }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
package com.soyio.soyiorndk
|
|
2
|
+
|
|
3
|
+
import com.facetec.sdk.FaceTecSDK
|
|
4
|
+
import okhttp3.Call
|
|
5
|
+
import okhttp3.Callback
|
|
6
|
+
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|
7
|
+
import okhttp3.OkHttpClient
|
|
8
|
+
import okhttp3.Request
|
|
9
|
+
import okhttp3.RequestBody
|
|
10
|
+
import okhttp3.RequestBody.Companion.toRequestBody
|
|
11
|
+
import okhttp3.Response
|
|
12
|
+
import okio.Buffer
|
|
13
|
+
import okio.ForwardingSink
|
|
14
|
+
import okio.buffer
|
|
15
|
+
import org.json.JSONObject
|
|
16
|
+
import java.io.IOException
|
|
17
|
+
import java.util.concurrent.TimeUnit
|
|
18
|
+
|
|
19
|
+
internal class FaceTecRequestService(
|
|
20
|
+
baseUrl: String,
|
|
21
|
+
private val resourcePath: String,
|
|
22
|
+
private val requestableToken: String,
|
|
23
|
+
private val authToken: String,
|
|
24
|
+
) {
|
|
25
|
+
private val normalizedBaseUrl = if (baseUrl.endsWith('/')) baseUrl.dropLast(1) else baseUrl
|
|
26
|
+
|
|
27
|
+
fun post(
|
|
28
|
+
endpoint: String,
|
|
29
|
+
payload: JSONObject,
|
|
30
|
+
sessionId: String?,
|
|
31
|
+
progress: ((Float) -> Unit)? = null,
|
|
32
|
+
networkErrorMessage: String = DEFAULT_NETWORK_ERROR,
|
|
33
|
+
onSuccess: (JSONObject) -> Unit,
|
|
34
|
+
onFailure: (String) -> Unit,
|
|
35
|
+
) {
|
|
36
|
+
val mediaType = "application/json; charset=utf-8".toMediaTypeOrNull()
|
|
37
|
+
val requestBody = payload.toString().toRequestBody(mediaType)
|
|
38
|
+
val bodyWithProgress = progress?.let { createProgressBody(requestBody, it) } ?: requestBody
|
|
39
|
+
|
|
40
|
+
val request = Request.Builder()
|
|
41
|
+
.url(buildUrl(endpoint))
|
|
42
|
+
.header("Content-Type", "application/json")
|
|
43
|
+
.header("Authorization", authToken)
|
|
44
|
+
.header("X-Facetec-Session-Id", sessionId ?: "")
|
|
45
|
+
.header(
|
|
46
|
+
"X-Facetec-User-Agent",
|
|
47
|
+
FaceTecSDK.createFaceTecAPIUserAgentString(sessionId ?: ""),
|
|
48
|
+
)
|
|
49
|
+
.header("X-Api-Version", ApiDate.iso)
|
|
50
|
+
.post(bodyWithProgress)
|
|
51
|
+
.build()
|
|
52
|
+
|
|
53
|
+
client.newCall(request).enqueue(object : Callback {
|
|
54
|
+
override fun onFailure(call: Call, e: IOException) {
|
|
55
|
+
onFailure(e.message ?: networkErrorMessage)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override fun onResponse(call: Call, response: Response) {
|
|
59
|
+
response.use {
|
|
60
|
+
val responseBody = response.body?.string().orEmpty()
|
|
61
|
+
if (!response.isSuccessful) {
|
|
62
|
+
onFailure("FaceTec API error ${response.code}: $responseBody")
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
val json = JSONObject(responseBody)
|
|
68
|
+
onSuccess(json)
|
|
69
|
+
} catch (exception: Exception) {
|
|
70
|
+
onFailure(exception.message ?: "Failed to parse FaceTec response.")
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private fun buildUrl(endpoint: String): String {
|
|
78
|
+
return "$normalizedBaseUrl/api/internal/$resourcePath/$requestableToken/facetec/$endpoint"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private fun createProgressBody(originalBody: RequestBody, onProgress: (Float) -> Unit): RequestBody {
|
|
82
|
+
return object : RequestBody() {
|
|
83
|
+
override fun contentType() = originalBody.contentType()
|
|
84
|
+
override fun contentLength() = originalBody.contentLength()
|
|
85
|
+
|
|
86
|
+
override fun writeTo(sink: okio.BufferedSink) {
|
|
87
|
+
val countingSink = object : ForwardingSink(sink) {
|
|
88
|
+
var bytesWritten = 0L
|
|
89
|
+
val totalLength = contentLength()
|
|
90
|
+
override fun write(source: Buffer, byteCount: Long) {
|
|
91
|
+
super.write(source, byteCount)
|
|
92
|
+
bytesWritten += byteCount
|
|
93
|
+
if (totalLength > 0) {
|
|
94
|
+
onProgress(bytesWritten.toFloat() / totalLength.toFloat())
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
val bufferedSink = countingSink.buffer()
|
|
100
|
+
originalBody.writeTo(bufferedSink)
|
|
101
|
+
bufferedSink.flush()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
companion object {
|
|
107
|
+
private val client = OkHttpClient.Builder()
|
|
108
|
+
.connectTimeout(60, TimeUnit.SECONDS)
|
|
109
|
+
.readTimeout(60, TimeUnit.SECONDS)
|
|
110
|
+
.writeTimeout(60, TimeUnit.SECONDS)
|
|
111
|
+
.build()
|
|
112
|
+
|
|
113
|
+
private const val DEFAULT_NETWORK_ERROR = "Network error while contacting FaceTec endpoint."
|
|
114
|
+
}
|
|
115
|
+
}
|