Skip to content

Commit 9bf9a0e

Browse files
gansu18tompsota
authored andcommitted
feat new endpoint
1 parent 1f84e52 commit 9bf9a0e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,15 @@ const actions = {
253253
// iOS only
254254
'passcode': () => {
255255
console.log('passcode');
256+
}
257+
// Android only
258+
'onUnlockedDevice': () => {
259+
console.log('onUnlockedDeviceDetected');
256260
},
261+
// Android only
262+
'onHardwareBackedKeystoreNotAvailable': () => {
263+
console.log('onHardwareBackedKeystoreNotAvailableDetected');
264+
}
257265
};
258266
259267
useFreeRasp(config, actions);

android/src/main/java/com/freeraspreactnative/FreeraspReactNativeModule.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class FreeraspReactNativeModule(val reactContext: ReactApplicationContext) :
2828
try {
2929
val config = parseTalsecConfig(options)
3030
listener.registerListener(reactContext)
31+
ThreatListener( this,deviceStateListener).registerListener(reactContext)
3132
Talsec.start(reactContext, config)
3233
sendOngoingPluginResult("started", null)
3334

@@ -83,6 +84,18 @@ class FreeraspReactNativeModule(val reactContext: ReactApplicationContext) :
8384
.emit(eventName, params)
8485
}
8586

87+
// This is optional. Use only if you are interested in device state information like device lock and HW backed keystore state
88+
private val deviceStateListener = object : ThreatListener.DeviceState {
89+
override fun onUnlockedDeviceDetected() {
90+
sendOngoingPluginResult("onUnlockedDeviceDetected", null)
91+
}
92+
93+
override fun onHardwareBackedKeystoreNotAvailableDetected() {
94+
// Set your reaction
95+
sendOngoingPluginResult("onHardwareBackedKeystoreNotAvailableDetected", null)
96+
}
97+
}
98+
8699
private fun parseTalsecConfig(config: ReadableMap): TalsecConfig {
87100
val androidConfig = config.getMap("androidConfig")!!
88101
val packageName = androidConfig.getString("packageName")!!

0 commit comments

Comments
 (0)