Skip to content

Commit

Permalink
Merge pull request #50 from Keyri-Co/feature/update-sdks
Browse files Browse the repository at this point in the history
Updated dependencies, SDK-s, bridges
  • Loading branch information
AndrewKuliahin96 authored Apr 2, 2024
2 parents 4585b61 + 0d3c47c commit 2c11a5b
Show file tree
Hide file tree
Showing 11 changed files with 1,471 additions and 15,578 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.keyri:keyrisdk:4.2.4'
implementation 'com.keyri:scanner:4.2.4'
implementation 'com.keyri:keyrisdk:4.3.0-alpha05'
implementation 'com.keyri:scanner:4.3.0-alpha05'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0"
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.12.0")
Expand Down
39 changes: 33 additions & 6 deletions android/src/main/java/com/reactnativekeyri/KeyriNativeModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import com.facebook.react.bridge.ActivityEventListener
import com.facebook.react.bridge.Promise
import com.keyrico.keyrisdk.config.KeyriDetectionsConfig
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
Expand All @@ -26,7 +27,7 @@ class KeyriNativeModule(private val reactContext: ReactApplicationContext) : Rea
private lateinit var appKey: String
private var publicApiKey: String? = null
private var serviceEncryptionKey: String? = null
private var blockEmulatorDetection: Boolean = true
private var detectionsConfig: KeyriDetectionsConfig = KeyriDetectionsConfig()

private var authWithScannerPromise: Promise? = null

Expand Down Expand Up @@ -60,10 +61,29 @@ class KeyriNativeModule(private val reactContext: ReactApplicationContext) : Rea
appKey = data.getString("appKey") ?: throw IllegalStateException("You need to provide appKey")
publicApiKey = data.takeIf { it.hasKey("publicApiKey") }?.getString("publicApiKey")
serviceEncryptionKey = data.takeIf { it.hasKey("serviceEncryptionKey") }?.getString("serviceEncryptionKey")
blockEmulatorDetection = data.takeIf { it.hasKey("blockEmulatorDetection") }?.getBoolean("blockEmulatorDetection")
?: true

keyri = Keyri(reactContext, appKey, publicApiKey, serviceEncryptionKey, blockEmulatorDetection)
val detectionsConfigMap = data.takeIf { it.hasKey("detectionsConfig") }?.getMap("detectionsConfig")

val blockEmulatorDetection =
detectionsConfigMap?.takeIf { it.hasKey("blockEmulatorDetection") }?.getBoolean("blockEmulatorDetection") ?: true
val blockRootDetection =
detectionsConfigMap?.takeIf { it.hasKey("blockRootDetection") }?.getBoolean("blockRootDetection") ?: false
val blockDangerousAppsDetection =
detectionsConfigMap?.takeIf { it.hasKey("blockDangerousAppsDetection") }?.getBoolean("blockDangerousAppsDetection") ?: false
val blockTamperDetection =
detectionsConfigMap?.takeIf { it.hasKey("blockTamperDetection") }?.getBoolean("blockTamperDetection") ?: true
val blockSwizzleDetection =
detectionsConfigMap?.takeIf { it.hasKey("blockSwizzleDetection") }?.getBoolean("blockSwizzleDetection") ?: false

detectionsConfig = detectionsConfig.copy(
blockEmulatorDetection = blockEmulatorDetection,
blockRootDetection = blockRootDetection,
blockDangerousAppsDetection = blockDangerousAppsDetection,
blockTamperDetection = blockTamperDetection,
blockSwizzleDetection = blockSwizzleDetection,
)

keyri = Keyri(reactContext, appKey, publicApiKey, serviceEncryptionKey, detectionsConfig)
} catch (e: Throwable) {
promise.reject(e)
}
Expand All @@ -81,9 +101,9 @@ class KeyriNativeModule(private val reactContext: ReactApplicationContext) : Rea
appKey,
publicApiKey,
serviceEncryptionKey,
blockEmulatorDetection,
payload,
publicUserId
publicUserId,
detectionsConfig
)
} catch (e: Throwable) {
promise.reject(e)
Expand Down Expand Up @@ -351,6 +371,13 @@ class KeyriNativeModule(private val reactContext: ReactApplicationContext) : Rea
}
}

@ReactMethod
fun getCorrectedTimestampSeconds(promise: Promise) {
keyriCoroutineScope(promise) {
keyri.getCorrectedTimestampSeconds()
}
}

@ReactMethod
fun initializeDefaultConfirmationScreen(payload: String, promise: Promise) {
keyriCoroutineScope(promise) {
Expand Down
Loading

0 comments on commit 2c11a5b

Please sign in to comment.