diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b55bc..ab43618 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# freeRASP 6.0.1 + +### Android +- ⚡ Fixed bug that prevented firing callbacks in specific situations + +### iOS +- ⚡ Fixed bug that caused app being killed in specific situations ([#42](https://github.com/talsec/Free-RASP-ReactNative/issues/42)) + # freeRASP 6.0.0 - ❗ **BREAKING API CHANGE**: changed the way how threats are received. Now, it is necessary to pass object with reactions to `talsec.start()` method instead of a function. diff --git a/package.json b/package.json index 1723af8..26361ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-talsec-plugin-freerasp", - "version": "6.0.0", + "version": "6.0.1", "description": "Cordova plugin for improving app security and threat monitoring on Android and iOS mobile devices.", "cordova": { "id": "cordova-talsec-plugin-freerasp", diff --git a/plugin.xml b/plugin.xml index 639d843..36a2c6e 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="6.0.1"> freerasp Talsec (info@talsec.app) diff --git a/src/android/TalsecPlugin.kt b/src/android/TalsecPlugin.kt index 3e32a39..8cd5149 100644 --- a/src/android/TalsecPlugin.kt +++ b/src/android/TalsecPlugin.kt @@ -54,8 +54,10 @@ class TalsecPlugin : CordovaPlugin() { override fun onPause(multitasking: Boolean) { super.onPause(multitasking) - listener.unregisterListener(this.cordova.context) - registered = false + if (this.cordova.activity.isFinishing) { + listener.unregisterListener(this.cordova.context) + registered = false + } } override fun onResume(multitasking: Boolean) { diff --git a/www/talsec.js b/www/talsec.js index d2218b3..1e9ac54 100644 --- a/www/talsec.js +++ b/www/talsec.js @@ -12,7 +12,6 @@ class Threat { static DeviceBinding = new Threat(0); static DeviceID = new Threat(0); static UnofficialStore = new Threat(0); - static Overlay = new Threat(0); static ObfuscationIssues = new Threat(0); constructor (value) { this.value = value; @@ -46,7 +45,6 @@ class Threat { ]; }; } - const getThreatCount = () => { return Threat.getValues().length; }; @@ -56,14 +54,21 @@ const itemsHaveType = (data, desidedType) => { }; const getThreatIdentifiers = async () => { const identifiers = await new Promise((resolve, reject) => { - cordova.exec((data) => { - resolve(data); - }, (error) => { - reject(error); - }, 'TalsecPlugin', 'getThreatIdentifiers'); + cordova.exec( + (data) => { + resolve(data); + }, + (error) => { + reject(error); + }, + 'TalsecPlugin', + 'getThreatIdentifiers' + ); }); - if (identifiers.length !== getThreatCount() || - !itemsHaveType(identifiers, 'number')) { + if ( + identifiers.length !== getThreatCount() || + !itemsHaveType(identifiers, 'number') + ) { onInvalidCallback(); } return identifiers; @@ -77,7 +82,12 @@ const prepareMapping = async () => { }); }; const onInvalidCallback = () => { - cordova.exec(() => { }, () => { }, 'TalsecPlugin', 'onInvalidCallback'); + cordova.exec( + () => {}, + () => {}, + 'TalsecPlugin', + 'onInvalidCallback' + ); }; const start = async (config, eventListenerConfig) => { await prepareMapping(); @@ -107,33 +117,38 @@ const start = async (config, eventListenerConfig) => { case Threat.Passcode.value: eventListenerConfig.passcode?.(); break; - case Threat.Overlay.value: - eventListenerConfig.overlay?.(); - break; case Threat.SecureHardwareNotAvailable.value: eventListenerConfig.secureHardwareNotAvailable?.(); break; case Threat.ObfuscationIssues.value: eventListenerConfig.obfuscationIssues?.(); break; + case Threat.DeviceID.value: + eventListenerConfig.deviceID?.(); + break; default: onInvalidCallback(); break; } }; return new Promise((resolve, reject) => { - cordova.exec((message) => { - if (message != null && message === 'started') { - resolve(); - } else { - eventListener(message); - } - }, (error) => { - reject(error); - }, 'TalsecPlugin', 'start', [config]); + cordova.exec( + (message) => { + if (message != null && message === 'started') { + resolve(); + } else { + eventListener(message); + } + }, + (error) => { + reject(error); + }, + 'TalsecPlugin', + 'start', + [config] + ); }); }; - module.exports = { start }; diff --git a/www/talsec.ts b/www/talsec.ts index 622b630..d873be5 100644 --- a/www/talsec.ts +++ b/www/talsec.ts @@ -10,7 +10,6 @@ type NativeEventEmitterActions = { deviceBinding?: () => any; deviceID?: () => any; passcode?: () => any; - overlay?: () => any; secureHardwareNotAvailable?: () => any; obfuscationIssues?: () => any; }; @@ -41,9 +40,8 @@ class Threat { static DeviceBinding = new Threat(0); static DeviceID = new Threat(0); static UnofficialStore = new Threat(0); - static Overlay = new Threat(0); static ObfuscationIssues = new Threat(0); - + constructor (value: number) { this.value = value; } @@ -75,7 +73,7 @@ class Threat { this.UnofficialStore ]; }; -}; +} const getThreatCount = (): number => { return Threat.getValues().length; @@ -87,19 +85,26 @@ const itemsHaveType = (data: any[], desidedType: string) => { }; const getThreatIdentifiers = async (): Promise => { const identifiers: number[] = await new Promise((resolve, reject) => { - cordova.exec((data) => { - resolve(data); - }, (error) => { - reject(error); - }, 'TalsecPlugin', 'getThreatIdentifiers'); + cordova.exec( + (data) => { + resolve(data); + }, + (error) => { + reject(error); + }, + 'TalsecPlugin', + 'getThreatIdentifiers' + ); }); - if (identifiers.length !== getThreatCount() || - !itemsHaveType(identifiers, 'number')) { + if ( + identifiers.length !== getThreatCount() || + !itemsHaveType(identifiers, 'number') + ) { onInvalidCallback(); } return identifiers; }; -const prepareMapping = async (): Promise => { +const prepareMapping = async (): Promise => { const newValues = await getThreatIdentifiers(); const threats = Threat.getValues(); // eslint-disable-next-line array-callback-return @@ -108,10 +113,18 @@ const prepareMapping = async (): Promise => { }); }; const onInvalidCallback = () => { - cordova.exec(() => { }, () => { }, 'TalsecPlugin', 'onInvalidCallback'); + cordova.exec( + () => {}, + () => {}, + 'TalsecPlugin', + 'onInvalidCallback' + ); }; -const start = async (config: TalsecConfig, eventListenerConfig: NativeEventEmitterActions) => { +const start = async ( + config: TalsecConfig, + eventListenerConfig: NativeEventEmitterActions +) => { await prepareMapping(); const eventListener = (event: number) => { @@ -140,15 +153,15 @@ const start = async (config: TalsecConfig, eventListenerConfig: NativeEventEmitt case Threat.Passcode.value: eventListenerConfig.passcode?.(); break; - case Threat.Overlay.value: - eventListenerConfig.overlay?.(); - break; case Threat.SecureHardwareNotAvailable.value: eventListenerConfig.secureHardwareNotAvailable?.(); break; case Threat.ObfuscationIssues.value: eventListenerConfig.obfuscationIssues?.(); break; + case Threat.DeviceID.value: + eventListenerConfig.deviceID?.(); + break; default: onInvalidCallback(); break; @@ -172,7 +185,7 @@ const start = async (config: TalsecConfig, eventListenerConfig: NativeEventEmitt [config] ); }); -} +}; module.exports = { start