Skip to content

Commit de15d68

Browse files
authored
feat(ios-security): IOSSecuritySuite plugin for iOS (#168)
1 parent 9020edb commit de15d68

File tree

73 files changed

+5357
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+5357
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ npm start
2222
- @nativescript/geolocation
2323
- @nativescript/google-pay
2424
- @nativescript/imagepicker
25+
- @nativescript/ios-security
2526
- @nativescript/iqkeyboardmanager
2627
- @nativescript/local-notifications
2728
- @nativescript/localize
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<ActionBar title="ios-security" class="action-bar"> </ActionBar>
2+
<StackLayout class="p-20">
3+
<ScrollView class="h-full">
4+
<StackLayout>
5+
<Button text="Test ios-security" (tap)="demoShared.testIt()" class="btn btn-primary"></Button>
6+
</StackLayout>
7+
</ScrollView>
8+
</StackLayout>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Component, NgZone } from '@angular/core';
2+
import { DemoSharedIosSecurity } from '@demo/shared';
3+
import {} from '@nativescript/ios-security';
4+
5+
@Component({
6+
selector: 'demo-ios-security',
7+
templateUrl: 'ios-security.component.html',
8+
})
9+
export class IosSecurityComponent {
10+
demoShared: DemoSharedIosSecurity;
11+
12+
constructor(private _ngZone: NgZone) {}
13+
14+
ngOnInit() {
15+
this.demoShared = new DemoSharedIosSecurity();
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
3+
import { IosSecurityComponent } from './ios-security.component';
4+
5+
@NgModule({
6+
imports: [NativeScriptCommonModule, NativeScriptRouterModule.forChild([{ path: '', component: IosSecurityComponent }])],
7+
declarations: [IosSecurityComponent],
8+
schemas: [NO_ERRORS_SCHEMA],
9+
})
10+
export class IosSecurityModule {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Observable, EventData, Page } from '@nativescript/core';
2+
import { DemoSharedIosSecurity } from '@demo/shared';
3+
import {} from '@nativescript/ios-security';
4+
5+
export function navigatingTo(args: EventData) {
6+
const page = <Page>args.object;
7+
page.bindingContext = new DemoModel();
8+
}
9+
10+
export class DemoModel extends DemoSharedIosSecurity {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2+
<Page.actionBar>
3+
<ActionBar title="ios-security" icon="" class="action-bar">
4+
</ActionBar>
5+
</Page.actionBar>
6+
<StackLayout class="p-20">
7+
<ScrollView class="h-full">
8+
<StackLayout>
9+
<Button text="Test ios-security" tap="{{ testIt }}" class="btn btn-primary"/>
10+
11+
</StackLayout>
12+
</ScrollView>
13+
</StackLayout>
14+
</Page>

nx.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
},
9595
"google-pay": {
9696
"tags": []
97+
},
98+
"ios-security": {
99+
"tags": []
97100
}
98101
},
99102
"workspaceLayout": {

packages/ios-security/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# @nativescript/ios-security
2+
3+
```javascript
4+
ns plugin add @nativescript/ios-security
5+
```
6+
7+
## Usage
8+
9+
The best way to explore the usage of the plugin is to inspect both demo apps in the plugin repository.
10+
In `demo` folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to `demo/app/main-page.ts`.
11+
In `demo-angular` is the usage in an Angular app. Refer to `demo-angular/app/app.component.ts`.
12+
13+
In addition to the plugin usage, both apps are webpack configured.
14+
15+
In short here are the steps:
16+
17+
### Import the plugin
18+
19+
*TypeScript*
20+
```
21+
import * as IosSecurity from "@nativescript/ios-security";
22+
```
23+
24+
*Javascript*
25+
```
26+
var IosSecurity = require("@nativescript/ios-security");
27+
```
28+
29+
### Update Info.plist
30+
After adding ios-security to your project, you will also need to update your main Info.plist. There is a check in jailbreak detection module that uses ```canOpenURL(_:)``` method and [requires](https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl) specifying URLs that will be queried.
31+
32+
```xml
33+
<key>LSApplicationQueriesSchemes</key>
34+
<array>
35+
<string>cydia</string>
36+
<string>undecimus</string>
37+
<string>sileo</string>
38+
<string>zbra</string>
39+
<string>filza</string>
40+
<string>activator</string>
41+
</array>
42+
```
43+
44+
### Jailbreak detector module
45+
46+
* **The simplest method** returns True/False if you just want to know if the device is jailbroken or jailed
47+
48+
*Javascript*
49+
```
50+
if (IosSecurity.amIJailbroken()) {
51+
console.log("This device is jailbroken");
52+
} else {
53+
console.log("This device is not jailbroken");
54+
}
55+
```
56+
57+
### Debugger detector module
58+
```
59+
let amIDebugged = IosSecurity.amIDebugged();
60+
```
61+
62+
### Deny debugger at all
63+
```
64+
IosSecurity.denyDebugger();
65+
```
66+
67+
### Emulator detector module
68+
```
69+
let runInEmulator = IosSecurity.amIRunInEmulator();
70+
```
71+
72+
### Reverse engineering tools detector module
73+
```
74+
let amIReverseEngineered = IosSecurity.amIReverseEngineered();
75+
```
76+
77+
### System proxy detector module
78+
```
79+
let amIProxied = IosSecurity.amIProxied();
80+
```
81+
82+
## License
83+
84+
Apache License Version 2.0

packages/ios-security/index.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { IosSecurityCommon } from './common';
2+
3+
export declare class IosSecurity extends IosSecurityCommon {
4+
static amIJailbroken():boolean;
5+
6+
static amIDebugged(): boolean;
7+
8+
static amIRunInEmulator(): boolean;
9+
10+
static denyDebugger();
11+
12+
static amIReverseEngineered();
13+
14+
static amIProxied(): boolean;
15+
16+
// @ts-ignore
17+
static amIRuntimeHookedWithDyldWhiteListDetectionClassSelectorIsClassMethod(dyldWhiteList: NSArray<string> | string[], detectionClass: typeof NSObject, selector: string, isClassMethod: boolean): boolean;
18+
19+
// @ts-ignore
20+
static amITampered(checks: NSArray<FileIntegrityCheckFacade> | FileIntegrityCheckFacade[]): NSArray<any>;
21+
}

packages/ios-security/index.ios.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
declare var SecurityFacade;
2+
3+
export class IosSecurity {
4+
static amIJailbroken(): boolean {
5+
return SecurityFacade.amIJailbroken();
6+
}
7+
8+
static amIDebugged(): boolean {
9+
return SecurityFacade.amIDebugged();
10+
}
11+
12+
static amIRunInEmulator(): boolean {
13+
return SecurityFacade.amIRunInEmulator();
14+
}
15+
16+
static denyDebugger() {
17+
return SecurityFacade.denyDebugger();
18+
}
19+
20+
static amIReverseEngineered(): boolean {
21+
return SecurityFacade.amIReverseEngineered();
22+
}
23+
24+
static amIProxied(): boolean {
25+
return SecurityFacade.amIProxied();
26+
}
27+
28+
// @ts-ignore
29+
static amIRuntimeHookedWithDyldWhiteListDetectionClassSelectorIsClassMethod(dyldWhiteList: NSArray<string> | string[], detectionClass: typeof NSObject, selector: string, isClassMethod: boolean): boolean {
30+
return SecurityFacade.amIRuntimeHookedWithDyldWhiteListDetectionClassSelectorIsClassMethod(dyldWhiteList, detectionClass, selector, isClassMethod);
31+
}
32+
33+
// @ts-ignore
34+
static amITampered(checks: NSArray<FileIntegrityCheckFacade> | FileIntegrityCheckFacade[]): NSArray<any> {
35+
return SecurityFacade.amITampered(checks);
36+
}
37+
38+
}

0 commit comments

Comments
 (0)