react-native-rootbeer-checkroot 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
+
3
+ export interface Spec extends TurboModule {
4
+ /** Runs all RootBeer checks (includes BusyBox check). */
5
+ isRooted(): boolean;
6
+
7
+ /** Runs all RootBeer checks except the BusyBox check. */
8
+ isRootedWithoutBusyBoxCheck(): boolean;
9
+
10
+ /** Checks for the presence of known potentially-dangerous rooting apps. */
11
+ detectPotentiallyDangerousApps(): boolean;
12
+
13
+ /** Checks for the presence of known root management apps (e.g. SuperSU, Magisk Manager). */
14
+ detectRootManagementApps(): boolean;
15
+
16
+ /** Checks if the device is running a test-keys build (non-official ROM). */
17
+ detectTestKeys(): boolean;
18
+
19
+ /**
20
+ * Checks for the presence of a specific binary (e.g. "su", "busybox").
21
+ * @param binaryName - The name of the binary to look for.
22
+ */
23
+ checkForBinary(binaryName: string): boolean;
24
+
25
+ /** Checks for dangerous system properties that indicate rooting. */
26
+ checkForDangerousProps(): boolean;
27
+
28
+ /** Checks for writable paths that should be read-only on a stock device. */
29
+ checkForRWPaths(): boolean;
30
+
31
+ /** Checks for the presence of known root-cloaking apps (e.g. RootCloak). */
32
+ detectRootCloakingApps(): boolean;
33
+
34
+ /** Attempts to execute `su` and checks whether it succeeds. */
35
+ checkSuExists(): boolean;
36
+
37
+ /** Scans common binary paths for the `su` binary. */
38
+ checkForSuBinary(): boolean;
39
+
40
+ /** Scans common binary paths for the Magisk binary. */
41
+ checkForMagiskBinary(): boolean;
42
+ }
43
+
44
+ export default TurboModuleRegistry.getEnforcing<Spec>('RootBeer');
@@ -0,0 +1,118 @@
1
+ import NativeRootBeer from './NativeRootBeer';
2
+
3
+ /**
4
+ * A wrapper around the RootBeer Android root-detection library.
5
+ * All methods call through to `com.scottyab:rootbeer-lib` via JSI.
6
+ *
7
+ * On iOS (or any non-Android platform) these methods will throw because
8
+ * the TurboModule is enforcing — guard calls with `Platform.OS === 'android'`
9
+ * if cross-platform support is needed.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { Platform } from 'react-native';
14
+ * import { RootBeer } from 'react-native-root-beer';
15
+ *
16
+ * if (Platform.OS === 'android') {
17
+ * const rooted = RootBeer.isRooted();
18
+ * console.log('Device is rooted:', rooted);
19
+ * }
20
+ * ```
21
+ */
22
+ export const RootBeer = {
23
+ /**
24
+ * Runs all RootBeer checks (includes BusyBox check).
25
+ * This is the main high-level check — prefer this for most use cases.
26
+ */
27
+ isRooted(): boolean {
28
+ return NativeRootBeer.isRooted();
29
+ },
30
+
31
+ /**
32
+ * Runs all RootBeer checks except the BusyBox check.
33
+ * Use this if BusyBox false-positives are a concern in your environment.
34
+ */
35
+ isRootedWithoutBusyBoxCheck(): boolean {
36
+ return NativeRootBeer.isRootedWithoutBusyBoxCheck();
37
+ },
38
+
39
+ /**
40
+ * Checks for the presence of known potentially-dangerous rooting apps
41
+ * (e.g. apps that typically accompany root access).
42
+ */
43
+ detectPotentiallyDangerousApps(): boolean {
44
+ return NativeRootBeer.detectPotentiallyDangerousApps();
45
+ },
46
+
47
+ /**
48
+ * Checks for the presence of known root management apps
49
+ * (e.g. SuperSU, Magisk Manager, KingRoot).
50
+ */
51
+ detectRootManagementApps(): boolean {
52
+ return NativeRootBeer.detectRootManagementApps();
53
+ },
54
+
55
+ /**
56
+ * Checks if the device build is signed with test-keys instead of
57
+ * release-keys. Test-key builds typically indicate a custom/rooted ROM.
58
+ */
59
+ detectTestKeys(): boolean {
60
+ return NativeRootBeer.detectTestKeys();
61
+ },
62
+
63
+ /**
64
+ * Checks for the presence of a specific binary by scanning common paths.
65
+ * @param binaryName - The binary to search for, e.g. `"su"`, `"busybox"`.
66
+ */
67
+ checkForBinary(binaryName: string): boolean {
68
+ return NativeRootBeer.checkForBinary(binaryName);
69
+ },
70
+
71
+ /**
72
+ * Checks for dangerous system properties that are commonly set on rooted
73
+ * devices (e.g. `ro.debuggable=1`, `ro.secure=0`).
74
+ */
75
+ checkForDangerousProps(): boolean {
76
+ return NativeRootBeer.checkForDangerousProps();
77
+ },
78
+
79
+ /**
80
+ * Checks for file-system paths that should be read-only on a stock device
81
+ * but are mounted as read-write — a strong indicator of root access.
82
+ */
83
+ checkForRWPaths(): boolean {
84
+ return NativeRootBeer.checkForRWPaths();
85
+ },
86
+
87
+ /**
88
+ * Checks for the presence of known root-cloaking apps (e.g. RootCloak,
89
+ * Hide My Root) that try to hide root from other apps.
90
+ */
91
+ detectRootCloakingApps(): boolean {
92
+ return NativeRootBeer.detectRootCloakingApps();
93
+ },
94
+
95
+ /**
96
+ * Attempts to execute `su` and returns `true` if it succeeds.
97
+ * This is a runtime probe rather than a static file check.
98
+ */
99
+ checkSuExists(): boolean {
100
+ return NativeRootBeer.checkSuExists();
101
+ },
102
+
103
+ /**
104
+ * Scans a list of well-known binary paths for the `su` executable.
105
+ * Less invasive than `checkSuExists()` as it doesn't execute anything.
106
+ */
107
+ checkForSuBinary(): boolean {
108
+ return NativeRootBeer.checkForSuBinary();
109
+ },
110
+
111
+ /**
112
+ * Scans common binary paths for the Magisk binary.
113
+ * Useful for detecting Magisk-based root even when it hides itself.
114
+ */
115
+ checkForMagiskBinary(): boolean {
116
+ return NativeRootBeer.checkForMagiskBinary();
117
+ },
118
+ } as const;
package/src/index.tsx ADDED
@@ -0,0 +1 @@
1
+ export { RootBeer } from './RootBeer';