-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Braden Hancock
committed
Apr 26, 2023
1 parent
1153013
commit a3675a3
Showing
26 changed files
with
1,692 additions
and
2,114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
iProov React Native SDK | ||
|
||
- Please refer to the iOS Biometrics SDK license here: https://github.com/iProov/ios/blob/master/LICENSE.md. | ||
|
||
- Please refer to the Android Biometrics SDK license here: https://github.com/iProov/android/blob/master/LICENSE.md. | ||
|
||
-------------------------------------------------------------------------------- | ||
API Client and Sample Code | ||
|
||
Copyright 2022 iProov Limited | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
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. | ||
|
||
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. | ||
|
||
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. | ||
|
||
-------------------------------------------------------------------------------- | ||
react-native-uuid | ||
|
||
MIT License | ||
|
||
Copyright (c) 2016-2021 Eugene Hauptmann | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
-------------------------------------------------------------------------------- | ||
rn-fetch-blob | ||
|
||
MIT License | ||
|
||
Copyright (c) 2017 [email protected] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 0 additions & 129 deletions
129
android/src/main/java/com/iproov/sdk/IProovReactNativeListener.java
This file was deleted.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
android/src/main/java/com/iproov/sdk/IProovReactNativeListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.iproov.sdk | ||
|
||
import android.graphics.Bitmap | ||
import android.util.Base64 | ||
import androidx.core.content.ContextCompat | ||
import com.facebook.react.bridge.Arguments | ||
import com.facebook.react.bridge.ReactContext | ||
import com.facebook.react.bridge.WritableMap | ||
import com.facebook.react.modules.core.DeviceEventManagerModule | ||
import com.iproov.sdk.core.exception.* | ||
import java.io.ByteArrayOutputStream | ||
|
||
class IProovReactNativeListener(private val reactContext: ReactContext) : IProovCallbackLauncher.Listener { | ||
|
||
override fun onConnecting() { emitEvent(EVENT_CONNECTING) } | ||
|
||
override fun onConnected() { emitEvent(EVENT_CONNECTED) } | ||
|
||
override fun onProcessing(progress: Double, message: String?) { | ||
val params = Arguments.createMap().apply { | ||
putDouble("progress", progress) | ||
putString("message", message) | ||
} | ||
|
||
emitEvent(EVENT_PROCESSING, params) | ||
} | ||
|
||
override fun onSuccess(result: IProov.SuccessResult) { | ||
val params = Arguments.createMap() | ||
|
||
result.frame?.let { | ||
params.putString("frame", base64EncodeBitmap(it)) | ||
} | ||
|
||
emitEvent(EVENT_SUCCESS, params) | ||
} | ||
|
||
override fun onFailure(result: IProov.FailureResult) { | ||
val params = Arguments.createMap().apply { | ||
putString("feedbackCode", result.reason.feedbackCode) | ||
putString("reason", reactContext.getString(result.reason.description)) | ||
} | ||
|
||
result.frame?.let { | ||
params.putString("frame", base64EncodeBitmap(it)) | ||
} | ||
|
||
emitEvent(EVENT_FAILURE, params) | ||
} | ||
|
||
override fun onCancelled(canceller: IProov.Canceller) { | ||
|
||
val params = Arguments.createMap().apply { | ||
putString("canceller", canceller.name) | ||
} | ||
|
||
emitEvent(EVENT_CANCELLED, params) | ||
} | ||
|
||
override fun onError(exception: IProovException) { | ||
exception.printStackTrace() | ||
val params = Arguments.createMap().apply { | ||
putString("error", toErrorString(exception)) | ||
putString("reason", exception.reason) | ||
putString("message", exception.localizedMessage) | ||
} | ||
|
||
emitEvent(EVENT_ERROR, params) | ||
} | ||
|
||
private fun toErrorString(e: IProovException): String = | ||
when(e) { | ||
is CaptureAlreadyActiveException -> "capture_already_active_error" | ||
is NetworkException -> "network_error" | ||
is CameraPermissionException -> "camera_permission_error" | ||
is ServerException -> "server_error" | ||
is MultiWindowUnsupportedException -> "multi_window_unsupported_error" | ||
is CameraException -> "camera_error" | ||
is FaceDetectorException -> "face_detector_error" | ||
is InvalidOptionsException -> "invalid_options_error" | ||
else -> "unexpected_error" | ||
} | ||
|
||
private fun base64EncodeBitmap(bitmap: Bitmap): String { | ||
val byteArrayOutputStream = ByteArrayOutputStream() | ||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream) | ||
val byteArray = byteArrayOutputStream.toByteArray() | ||
return Base64.encodeToString(byteArray, Base64.NO_WRAP) | ||
} | ||
|
||
private fun emitEvent(name: String, params: WritableMap? = null) { | ||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java) | ||
.emit(name, params) | ||
} | ||
} |
Oops, something went wrong.