Skip to content

Commit a3675a3

Browse files
author
Braden Hancock
committed
Release 0.2.0
1 parent 1153013 commit a3675a3

26 files changed

Lines changed: 1692 additions & 2114 deletions

LICENSE.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
iProov React Native SDK
2+
3+
- Please refer to the iOS Biometrics SDK license here: https://github.com/iProov/ios/blob/master/LICENSE.md.
4+
5+
- Please refer to the Android Biometrics SDK license here: https://github.com/iProov/android/blob/master/LICENSE.md.
6+
7+
--------------------------------------------------------------------------------
8+
API Client and Sample Code
9+
10+
Copyright 2022 iProov Limited
11+
12+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
13+
14+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15+
16+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
17+
18+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21+
22+
--------------------------------------------------------------------------------
23+
react-native-uuid
24+
25+
MIT License
26+
27+
Copyright (c) 2016-2021 Eugene Hauptmann
28+
29+
Permission is hereby granted, free of charge, to any person obtaining a copy
30+
of this software and associated documentation files (the "Software"), to deal
31+
in the Software without restriction, including without limitation the rights
32+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33+
copies of the Software, and to permit persons to whom the Software is
34+
furnished to do so, subject to the following conditions:
35+
36+
The above copyright notice and this permission notice shall be included in all
37+
copies or substantial portions of the Software.
38+
39+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45+
SOFTWARE.
46+
47+
--------------------------------------------------------------------------------
48+
rn-fetch-blob
49+
50+
MIT License
51+
52+
Copyright (c) 2017 xeiyan@gmail.com
53+
54+
Permission is hereby granted, free of charge, to any person obtaining a copy
55+
of this software and associated documentation files (the "Software"), to deal
56+
in the Software without restriction, including without limitation the rights
57+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58+
copies of the Software, and to permit persons to whom the Software is
59+
furnished to do so, subject to the following conditions:
60+
61+
The above copyright notice and this permission notice shall be included in all
62+
copies or substantial portions of the Software.
63+
64+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
70+
SOFTWARE.

README.md

Lines changed: 137 additions & 98 deletions
Large diffs are not rendered by default.

android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ repositories {
3636
}
3737

3838
dependencies {
39-
implementation 'com.iproov.sdk:iproov:7.3.0'
39+
implementation 'com.iproov.sdk:iproov:8.3.1'
4040
implementation 'com.facebook.react:react-native:+'
41+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
4142
}

android/src/main/java/com/iproov/sdk/IProovReactNativeListener.java

Lines changed: 0 additions & 129 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.iproov.sdk
2+
3+
import android.graphics.Bitmap
4+
import android.util.Base64
5+
import androidx.core.content.ContextCompat
6+
import com.facebook.react.bridge.Arguments
7+
import com.facebook.react.bridge.ReactContext
8+
import com.facebook.react.bridge.WritableMap
9+
import com.facebook.react.modules.core.DeviceEventManagerModule
10+
import com.iproov.sdk.core.exception.*
11+
import java.io.ByteArrayOutputStream
12+
13+
class IProovReactNativeListener(private val reactContext: ReactContext) : IProovCallbackLauncher.Listener {
14+
15+
override fun onConnecting() { emitEvent(EVENT_CONNECTING) }
16+
17+
override fun onConnected() { emitEvent(EVENT_CONNECTED) }
18+
19+
override fun onProcessing(progress: Double, message: String?) {
20+
val params = Arguments.createMap().apply {
21+
putDouble("progress", progress)
22+
putString("message", message)
23+
}
24+
25+
emitEvent(EVENT_PROCESSING, params)
26+
}
27+
28+
override fun onSuccess(result: IProov.SuccessResult) {
29+
val params = Arguments.createMap()
30+
31+
result.frame?.let {
32+
params.putString("frame", base64EncodeBitmap(it))
33+
}
34+
35+
emitEvent(EVENT_SUCCESS, params)
36+
}
37+
38+
override fun onFailure(result: IProov.FailureResult) {
39+
val params = Arguments.createMap().apply {
40+
putString("feedbackCode", result.reason.feedbackCode)
41+
putString("reason", reactContext.getString(result.reason.description))
42+
}
43+
44+
result.frame?.let {
45+
params.putString("frame", base64EncodeBitmap(it))
46+
}
47+
48+
emitEvent(EVENT_FAILURE, params)
49+
}
50+
51+
override fun onCancelled(canceller: IProov.Canceller) {
52+
53+
val params = Arguments.createMap().apply {
54+
putString("canceller", canceller.name)
55+
}
56+
57+
emitEvent(EVENT_CANCELLED, params)
58+
}
59+
60+
override fun onError(exception: IProovException) {
61+
exception.printStackTrace()
62+
val params = Arguments.createMap().apply {
63+
putString("error", toErrorString(exception))
64+
putString("reason", exception.reason)
65+
putString("message", exception.localizedMessage)
66+
}
67+
68+
emitEvent(EVENT_ERROR, params)
69+
}
70+
71+
private fun toErrorString(e: IProovException): String =
72+
when(e) {
73+
is CaptureAlreadyActiveException -> "capture_already_active_error"
74+
is NetworkException -> "network_error"
75+
is CameraPermissionException -> "camera_permission_error"
76+
is ServerException -> "server_error"
77+
is MultiWindowUnsupportedException -> "multi_window_unsupported_error"
78+
is CameraException -> "camera_error"
79+
is FaceDetectorException -> "face_detector_error"
80+
is InvalidOptionsException -> "invalid_options_error"
81+
else -> "unexpected_error"
82+
}
83+
84+
private fun base64EncodeBitmap(bitmap: Bitmap): String {
85+
val byteArrayOutputStream = ByteArrayOutputStream()
86+
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream)
87+
val byteArray = byteArrayOutputStream.toByteArray()
88+
return Base64.encodeToString(byteArray, Base64.NO_WRAP)
89+
}
90+
91+
private fun emitEvent(name: String, params: WritableMap? = null) {
92+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
93+
.emit(name, params)
94+
}
95+
}

0 commit comments

Comments
 (0)