Skip to content

Commit 8213ca5

Browse files
committed
feat(common): rename device binding to deviceBinding
1 parent 5217401 commit 8213ca5

File tree

5 files changed

+50
-47
lines changed

5 files changed

+50
-47
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,47 +199,47 @@ const config = {
199199
// reactions for detected threats
200200
const actions = {
201201
// Android & iOS
202-
'privilegedAccess': () => {
202+
privilegedAccess: () => {
203203
console.log('privilegedAccess');
204204
},
205205
// Android & iOS
206-
'debug': () => {
206+
debug: () => {
207207
console.log('debug');
208208
},
209209
// Android & iOS
210-
'simulator': () => {
210+
simulator: () => {
211211
console.log('simulator');
212212
},
213213
// Android & iOS
214-
'appIntegrity': () => {
214+
appIntegrity: () => {
215215
console.log('appIntegrity');
216216
},
217217
// Android & iOS
218-
'unofficialStore': () => {
218+
unofficialStore: () => {
219219
console.log('unofficialStore');
220220
},
221221
// Android & iOS
222-
'hooks': () => {
222+
hooks: () => {
223223
console.log('hooks');
224224
},
225225
// Android & iOS
226-
'device binding': () => {
227-
console.log('device binding');
226+
deviceBinding: () => {
227+
console.log('deviceBinding');
228228
},
229229
// Android & iOS
230-
'secureHardwareNotAvailable': () => {
230+
secureHardwareNotAvailable: () => {
231231
console.log('secureHardwareNotAvailable');
232232
},
233233
// Android & iOS
234-
'passcode': () => {
234+
passcode: () => {
235235
console.log('passcode');
236236
},
237237
// iOS only
238-
'deviceID': () => {
238+
deviceID: () => {
239239
console.log('deviceID');
240240
},
241241
// iOS only
242-
'passcodeChange': () => {
242+
passcodeChange: () => {
243243
console.log('passcodeChange');
244244
},
245245
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FreeraspReactNativeModule(val reactContext: ReactApplicationContext) :
7575
}
7676

7777
override fun onDeviceBindingDetected() {
78-
sendOngoingPluginResult("device binding", null)
78+
sendOngoingPluginResult("deviceBinding", null)
7979
}
8080

8181
override fun deviceStateChangeDetected(threatType: String) {

example/src/App.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const App = () => {
2626

2727
const actions = {
2828
// Android & iOS
29-
'privilegedAccess': () => {
29+
privilegedAccess: () => {
3030
setAppChecks((currentState) =>
3131
currentState.map((threat) =>
3232
threat.name === 'Privileged Access'
@@ -36,23 +36,23 @@ const App = () => {
3636
);
3737
},
3838
// Android & iOS
39-
'debug': () => {
39+
debug: () => {
4040
setAppChecks((currentState) =>
4141
currentState.map((threat) =>
4242
threat.name === 'Debug' ? { ...threat, status: 'nok' } : threat
4343
)
4444
);
4545
},
4646
// Android & iOS
47-
'simulator': () => {
47+
simulator: () => {
4848
setAppChecks((currentState) =>
4949
currentState.map((threat) =>
5050
threat.name === 'Simulator' ? { ...threat, status: 'nok' } : threat
5151
)
5252
);
5353
},
5454
// Android & iOS
55-
'appIntegrity': () => {
55+
appIntegrity: () => {
5656
setAppChecks((currentState) =>
5757
currentState.map((threat) =>
5858
threat.name === 'App Integrity'
@@ -62,7 +62,7 @@ const App = () => {
6262
);
6363
},
6464
// Android & iOS
65-
'unofficialStore': () => {
65+
unofficialStore: () => {
6666
setAppChecks((currentState) =>
6767
currentState.map((threat) =>
6868
threat.name === 'Unofficial Store'
@@ -72,15 +72,15 @@ const App = () => {
7272
);
7373
},
7474
// Android & iOS
75-
'hooks': () => {
75+
hooks: () => {
7676
setAppChecks((currentState) =>
7777
currentState.map((threat) =>
7878
threat.name === 'Hooks' ? { ...threat, status: 'nok' } : threat
7979
)
8080
);
8181
},
8282
// Android & iOS
83-
'device binding': () => {
83+
deviceBinding: () => {
8484
setAppChecks((currentState) =>
8585
currentState.map((threat) =>
8686
threat.name === 'Device Binding'
@@ -90,7 +90,7 @@ const App = () => {
9090
);
9191
},
9292
// Android & iOS
93-
'secureHardwareNotAvailable': () => {
93+
secureHardwareNotAvailable: () => {
9494
setAppChecks((currentState) =>
9595
currentState.map((threat) =>
9696
threat.name === 'Secure Hardware Not Available'
@@ -100,23 +100,23 @@ const App = () => {
100100
);
101101
},
102102
// Android & iOS
103-
'passcode': () => {
103+
passcode: () => {
104104
setAppChecks((currentState) =>
105105
currentState.map((threat) =>
106106
threat.name === 'Passcode' ? { ...threat, status: 'nok' } : threat
107107
)
108108
);
109109
},
110110
// iOS only
111-
'deviceID': () => {
111+
deviceID: () => {
112112
setAppChecks((currentState) =>
113113
currentState.map((threat) =>
114114
threat.name === 'Device ID' ? { ...threat, status: 'nok' } : threat
115115
)
116116
);
117117
},
118118
// iOS only
119-
'passcodeChange': () => {
119+
passcodeChange: () => {
120120
setAppChecks((currentState) =>
121121
currentState.map((threat) =>
122122
threat.name === 'Passcode Change'

ios/FreeraspReactNative.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import TalsecRuntime
33

44
@objc(FreeraspReactNative)
55
class FreeraspReactNative: RCTEventEmitter {
6-
6+
77
public static var shared:FreeraspReactNative?
8-
8+
99
override init() {
1010
super.init()
1111
FreeraspReactNative.shared = self
1212
}
13-
13+
1414
@objc(talsecStart:)
1515
func talsecStart(options: NSDictionary) -> Void {
1616
do {
@@ -22,7 +22,7 @@ class FreeraspReactNative: RCTEventEmitter {
2222
}
2323
self.sendEvent(withName: "started", body: "started")
2424
}
25-
25+
2626
func initializeTalsec(talsecConfig: NSDictionary) throws {
2727
guard let iosConfig = talsecConfig["iosConfig"] as? NSDictionary else {
2828
throw NSError(domain: "Missing iosConfig parameter in Talsec Native Plugin", code: 1)
@@ -39,19 +39,22 @@ class FreeraspReactNative: RCTEventEmitter {
3939
let config = TalsecConfig(appBundleIds: [appBundleIds], appTeamId: appTeamId, watcherMailAddress: watcherMailAddress)
4040
Talsec.start(config: config)
4141
}
42-
42+
4343
override func supportedEvents() -> [String]! {
44-
return ["initializationError", "started", "privilegedAccess", "debug", "simulator", "appIntegrity", "unofficialStore", "hooks", "device binding", "deviceID", "secureHardwareNotAvailable", "passcodeChange", "passcode"]
44+
return ["initializationError", "started", "privilegedAccess", "debug", "simulator", "appIntegrity", "unofficialStore", "hooks", "deviceBinding", "deviceID", "secureHardwareNotAvailable", "passcodeChange", "passcode"]
4545
}
4646
}
4747

4848
extension SecurityThreatCenter: SecurityThreatHandler {
4949
public func threatDetected(_ securityThreat: TalsecRuntime.SecurityThreat) {
5050
// It is better to implement security reactions (e.g. killing the app) here.
51-
if (securityThreat.rawValue == "missingSecureEnclave") {
52-
FreeraspReactNative.shared!.sendEvent(withName: "secureHardwareNotAvailable", body: "secureHardwareNotAvailable")
53-
} else {
54-
FreeraspReactNative.shared!.sendEvent(withName: securityThreat.rawValue, body: securityThreat.rawValue)
51+
switch securityThreat.rawValue {
52+
case "missingSecureEnclave":
53+
FreeraspReactNative.shared!.sendEvent(withName: "secureHardwareNotAvailable", body: "secureHardwareNotAvailable")
54+
case "device binding":
55+
FreeraspReactNative.shared!.sendEvent(withName: "deviceBinding", body: "deviceBinding")
56+
default:
57+
FreeraspReactNative.shared!.sendEvent(withName: securityThreat.rawValue, body: securityThreat.rawValue)
5558
}
5659
}
5760
}

src/index.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ type TalsecConfig = {
1919
};
2020

2121
type NativeEventEmitterActions = {
22-
'privilegedAccess'?: () => any;
23-
'debug'?: () => any;
24-
'simulator'?: () => any;
25-
'appIntegrity'?: () => any;
26-
'unofficialStore'?: () => any;
27-
'hooks'?: () => any;
28-
'device binding'?: () => any;
29-
'deviceID'?: () => any;
30-
'passcodeChange'?: () => any;
31-
'passcode'?: () => any;
32-
'secureHardwareNotAvailable'?: () => any;
33-
'started'?: () => any;
34-
'initializationError'?: (reason: { message: string }) => any;
22+
privilegedAccess?: () => any;
23+
debug?: () => any;
24+
simulator?: () => any;
25+
appIntegrity?: () => any;
26+
unofficialStore?: () => any;
27+
hooks?: () => any;
28+
deviceBinding?: () => any;
29+
deviceID?: () => any;
30+
passcodeChange?: () => any;
31+
passcode?: () => any;
32+
secureHardwareNotAvailable?: () => any;
33+
started?: () => any;
34+
initializationError?: (reason: { message: string }) => any;
3535
};
3636

3737
const { FreeraspReactNative } = NativeModules;

0 commit comments

Comments
 (0)