react-native-security-pack 1.0.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.
- package/LICENSE +20 -0
- package/README.md +33 -0
- package/android/build.gradle +130 -0
- package/android/generated/java/com/leerman/rnsecuritypack/NativeSecurityPackSpec.java +42 -0
- package/android/generated/jni/CMakeLists.txt +49 -0
- package/android/generated/jni/RNSecurityPackSpec-generated.cpp +38 -0
- package/android/generated/jni/RNSecurityPackSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/ComponentDescriptors.h +24 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/EventEmitters.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/EventEmitters.h +17 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/Props.cpp +19 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/Props.h +18 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/RNSecurityPackSpecJSI-generated.cpp +32 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/RNSecurityPackSpecJSI.h +76 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/ShadowNodes.cpp +17 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/ShadowNodes.h +23 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/States.cpp +16 -0
- package/android/generated/jni/react/renderer/components/RNSecurityPackSpec/States.h +19 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/leerman/rnsecuritypack/SecurityPackModule.kt +85 -0
- package/android/src/main/java/com/leerman/rnsecuritypack/SecurityPackPackage.kt +35 -0
- package/android/src/newarch/SecurityPackSpec.kt +7 -0
- package/android/src/oldarch/SecurityPackSpec.kt +12 -0
- package/ios/SecurityPack.h +12 -0
- package/ios/SecurityPack.mm +25 -0
- package/ios/generated/RNSecurityPackSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/RNSecurityPackSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/RNSecurityPackSpec/EventEmitters.cpp +16 -0
- package/ios/generated/RNSecurityPackSpec/EventEmitters.h +17 -0
- package/ios/generated/RNSecurityPackSpec/Props.cpp +19 -0
- package/ios/generated/RNSecurityPackSpec/Props.h +18 -0
- package/ios/generated/RNSecurityPackSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/RNSecurityPackSpec/RNSecurityPackSpec-generated.mm +36 -0
- package/ios/generated/RNSecurityPackSpec/RNSecurityPackSpec.h +52 -0
- package/ios/generated/RNSecurityPackSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/RNSecurityPackSpec/ShadowNodes.h +23 -0
- package/ios/generated/RNSecurityPackSpec/States.cpp +16 -0
- package/ios/generated/RNSecurityPackSpec/States.h +19 -0
- package/ios/generated/RNSecurityPackSpecJSI-generated.cpp +32 -0
- package/ios/generated/RNSecurityPackSpecJSI.h +76 -0
- package/lib/commonjs/NativeSecurityPack.js +9 -0
- package/lib/commonjs/NativeSecurityPack.js.map +1 -0
- package/lib/commonjs/index.js +34 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeSecurityPack.js +5 -0
- package/lib/module/NativeSecurityPack.js.map +1 -0
- package/lib/module/index.js +29 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeSecurityPack.d.ts +8 -0
- package/lib/typescript/commonjs/src/NativeSecurityPack.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeSecurityPack.d.ts +8 -0
- package/lib/typescript/module/src/NativeSecurityPack.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +201 -0
- package/react-native-security-pack.podspec +43 -0
- package/src/NativeSecurityPack.ts +9 -0
- package/src/index.tsx +43 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
package com.leerman.rnsecuritypack
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
7
|
+
|
|
8
|
+
import android.os.Build
|
|
9
|
+
import android.content.pm.PackageManager
|
|
10
|
+
import com.kimchangyoun.rootbeerFresh.RootBeer
|
|
11
|
+
|
|
12
|
+
import java.security.MessageDigest
|
|
13
|
+
|
|
14
|
+
class SecurityPackModule internal constructor(context: ReactApplicationContext) :
|
|
15
|
+
SecurityPackSpec(context) {
|
|
16
|
+
|
|
17
|
+
override fun getName(): String {
|
|
18
|
+
return NAME
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
companion object {
|
|
22
|
+
const val NAME = "SecurityPack"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private val mContext: ReactApplicationContext = context
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
override fun isRooted(promise: Promise) {
|
|
29
|
+
val rootBeer = RootBeer(mContext)
|
|
30
|
+
promise.resolve(rootBeer.isRooted)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@ReactMethod
|
|
34
|
+
override fun getSignatures(promise: Promise) {
|
|
35
|
+
val signatureList: List<String>
|
|
36
|
+
try {
|
|
37
|
+
val packageName = mContext.getPackageName()
|
|
38
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
39
|
+
// New signature
|
|
40
|
+
val sig = mContext.packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNING_CERTIFICATES).signingInfo
|
|
41
|
+
signatureList = if (sig.hasMultipleSigners()) {
|
|
42
|
+
// Send all with apkContentsSigners
|
|
43
|
+
sig.apkContentsSigners.map {
|
|
44
|
+
val digest = MessageDigest.getInstance("SHA")
|
|
45
|
+
digest.update(it.toByteArray())
|
|
46
|
+
bytesToHex(digest.digest())
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
// Send one with signingCertificateHistory
|
|
50
|
+
sig.signingCertificateHistory.map {
|
|
51
|
+
val digest = MessageDigest.getInstance("SHA")
|
|
52
|
+
digest.update(it.toByteArray())
|
|
53
|
+
bytesToHex(digest.digest())
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
val sig = mContext.packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures
|
|
58
|
+
signatureList = sig.map {
|
|
59
|
+
val digest = MessageDigest.getInstance("SHA")
|
|
60
|
+
digest.update(it.toByteArray())
|
|
61
|
+
bytesToHex(digest.digest())
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
val array = Arguments.fromList(signatureList)
|
|
65
|
+
promise.resolve(array)
|
|
66
|
+
} catch (e: Exception) {
|
|
67
|
+
// Handle error
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
val empty = Arguments.fromList(emptyList<String>())
|
|
71
|
+
promise.resolve(empty)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fun bytesToHex(bytes: ByteArray): String {
|
|
75
|
+
val hexArray = charArrayOf('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F')
|
|
76
|
+
val hexChars = CharArray(bytes.size * 2)
|
|
77
|
+
var v: Int
|
|
78
|
+
for (j in bytes.indices) {
|
|
79
|
+
v = bytes[j].toInt() and 0xFF
|
|
80
|
+
hexChars[j * 2] = hexArray[v.ushr(4)]
|
|
81
|
+
hexChars[j * 2 + 1] = hexArray[v and 0x0F]
|
|
82
|
+
}
|
|
83
|
+
return String(hexChars)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package com.leerman.rnsecuritypack
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class SecurityPackPackage : TurboReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == SecurityPackModule.NAME) {
|
|
13
|
+
SecurityPackModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
23
|
+
moduleInfos[SecurityPackModule.NAME] = ReactModuleInfo(
|
|
24
|
+
SecurityPackModule.NAME,
|
|
25
|
+
SecurityPackModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
true, // hasConstants
|
|
29
|
+
false, // isCxxModule
|
|
30
|
+
isTurboModule // isTurboModule
|
|
31
|
+
)
|
|
32
|
+
moduleInfos
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.leerman.rnsecuritypack
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.Promise
|
|
6
|
+
|
|
7
|
+
abstract class SecurityPackSpec internal constructor(context: ReactApplicationContext) :
|
|
8
|
+
ReactContextBaseJavaModule(context) {
|
|
9
|
+
|
|
10
|
+
abstract fun getSignatures(promise: Promise)
|
|
11
|
+
abstract fun isRooted(promise: Promise)
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#import "SecurityPack.h"
|
|
2
|
+
#import <DTTJailbreakDetection/DTTJailbreakDetection.h>
|
|
3
|
+
|
|
4
|
+
@implementation SecurityPack
|
|
5
|
+
RCT_EXPORT_MODULE()
|
|
6
|
+
|
|
7
|
+
// Example method
|
|
8
|
+
// See // https://reactnative.dev/docs/native-modules-ios
|
|
9
|
+
RCT_EXPORT_METHOD(isRooted:(RCTPromiseResolveBlock)resolve
|
|
10
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
11
|
+
{
|
|
12
|
+
BOOL rooted = [DTTJailbreakDetection isJailbroken];
|
|
13
|
+
resolve(@(rooted));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Don't compile this code when we build for the old architecture.
|
|
17
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
18
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
19
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
20
|
+
{
|
|
21
|
+
return std::make_shared<facebook::react::NativeSecurityPackSpecJSI>(params);
|
|
22
|
+
}
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
@end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ComponentDescriptors.h"
|
|
12
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
13
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
void RNSecurityPackSpec_registerComponentDescriptorsFromCodegen(
|
|
18
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateComponentDescriptorH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ShadowNodes.h"
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
void RNSecurityPackSpec_registerComponentDescriptorsFromCodegen(
|
|
22
|
+
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
23
|
+
|
|
24
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "EventEmitters.h"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateEventEmitterH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "Props.h"
|
|
12
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
13
|
+
#include <react/renderer/core/propsConversions.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GeneratePropsH.js
|
|
9
|
+
*/
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace facebook::react {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateComponentHObjCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
#import <React/RCTDefines.h>
|
|
12
|
+
#import <React/RCTLog.h>
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#import "RNSecurityPackSpec.h"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
static facebook::jsi::Value __hostFunction_NativeSecurityPackSpecJSI_getSignatures(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getSignatures", @selector(getSignatures:reject:), args, count);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static facebook::jsi::Value __hostFunction_NativeSecurityPackSpecJSI_isRooted(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
24
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "isRooted", @selector(isRooted:reject:), args, count);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NativeSecurityPackSpecJSI::NativeSecurityPackSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
|
28
|
+
: ObjCTurboModule(params) {
|
|
29
|
+
|
|
30
|
+
methodMap_["getSignatures"] = MethodMetadata {0, __hostFunction_NativeSecurityPackSpecJSI_getSignatures};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
methodMap_["isRooted"] = MethodMetadata {0, __hostFunction_NativeSecurityPackSpecJSI_isRooted};
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
|
8
|
+
*
|
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
#ifndef __cplusplus
|
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
// Avoid multiple includes of RNSecurityPackSpec symbols
|
|
19
|
+
#ifndef RNSecurityPackSpec_H
|
|
20
|
+
#define RNSecurityPackSpec_H
|
|
21
|
+
|
|
22
|
+
#import <Foundation/Foundation.h>
|
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
|
26
|
+
#import <React/RCTBridgeModule.h>
|
|
27
|
+
#import <React/RCTCxxConvert.h>
|
|
28
|
+
#import <React/RCTManagedPointer.h>
|
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
|
30
|
+
#import <optional>
|
|
31
|
+
#import <vector>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@protocol NativeSecurityPackSpec <RCTBridgeModule, RCTTurboModule>
|
|
35
|
+
|
|
36
|
+
- (void)getSignatures:(RCTPromiseResolveBlock)resolve
|
|
37
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
38
|
+
- (void)isRooted:(RCTPromiseResolveBlock)resolve
|
|
39
|
+
reject:(RCTPromiseRejectBlock)reject;
|
|
40
|
+
|
|
41
|
+
@end
|
|
42
|
+
namespace facebook::react {
|
|
43
|
+
/**
|
|
44
|
+
* ObjC++ class for module 'NativeSecurityPack'
|
|
45
|
+
*/
|
|
46
|
+
class JSI_EXPORT NativeSecurityPackSpecJSI : public ObjCTurboModule {
|
|
47
|
+
public:
|
|
48
|
+
NativeSecurityPackSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
|
49
|
+
};
|
|
50
|
+
} // namespace facebook::react
|
|
51
|
+
|
|
52
|
+
#endif // RNSecurityPackSpec_H
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "ShadowNodes.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateShadowNodeH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "EventEmitters.h"
|
|
14
|
+
#include "Props.h"
|
|
15
|
+
#include "States.h"
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <jsi/jsi.h>
|
|
18
|
+
|
|
19
|
+
namespace facebook::react {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateStateCpp.js
|
|
9
|
+
*/
|
|
10
|
+
#include "States.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateStateH.js
|
|
8
|
+
*/
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#ifdef ANDROID
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNSecurityPackSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeSecurityPackCxxSpecJSI_getSignatures(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeSecurityPackCxxSpecJSI *>(&turboModule)->getSignatures(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeSecurityPackCxxSpecJSI_isRooted(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeSecurityPackCxxSpecJSI *>(&turboModule)->isRooted(
|
|
21
|
+
rt
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeSecurityPackCxxSpecJSI::NativeSecurityPackCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
26
|
+
: TurboModule("SecurityPack", jsInvoker) {
|
|
27
|
+
methodMap_["getSignatures"] = MethodMetadata {0, __hostFunction_NativeSecurityPackCxxSpecJSI_getSignatures};
|
|
28
|
+
methodMap_["isRooted"] = MethodMetadata {0, __hostFunction_NativeSecurityPackCxxSpecJSI_isRooted};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeSecurityPackCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeSecurityPackCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual jsi::Value getSignatures(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual jsi::Value isRooted(jsi::Runtime &rt) = 0;
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
template <typename T>
|
|
29
|
+
class JSI_EXPORT NativeSecurityPackCxxSpec : public TurboModule {
|
|
30
|
+
public:
|
|
31
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
32
|
+
return delegate_.get(rt, propName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static constexpr std::string_view kModuleName = "SecurityPack";
|
|
36
|
+
|
|
37
|
+
protected:
|
|
38
|
+
NativeSecurityPackCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
39
|
+
: TurboModule(std::string{NativeSecurityPackCxxSpec::kModuleName}, jsInvoker),
|
|
40
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
private:
|
|
44
|
+
class Delegate : public NativeSecurityPackCxxSpecJSI {
|
|
45
|
+
public:
|
|
46
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
47
|
+
NativeSecurityPackCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
jsi::Value getSignatures(jsi::Runtime &rt) override {
|
|
52
|
+
static_assert(
|
|
53
|
+
bridging::getParameterCount(&T::getSignatures) == 1,
|
|
54
|
+
"Expected getSignatures(...) to have 1 parameters");
|
|
55
|
+
|
|
56
|
+
return bridging::callFromJs<jsi::Value>(
|
|
57
|
+
rt, &T::getSignatures, jsInvoker_, instance_);
|
|
58
|
+
}
|
|
59
|
+
jsi::Value isRooted(jsi::Runtime &rt) override {
|
|
60
|
+
static_assert(
|
|
61
|
+
bridging::getParameterCount(&T::isRooted) == 1,
|
|
62
|
+
"Expected isRooted(...) to have 1 parameters");
|
|
63
|
+
|
|
64
|
+
return bridging::callFromJs<jsi::Value>(
|
|
65
|
+
rt, &T::isRooted, jsInvoker_, instance_);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
friend class NativeSecurityPackCxxSpec;
|
|
70
|
+
T *instance_;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Delegate delegate_;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('SecurityPack');
|
|
9
|
+
//# sourceMappingURL=NativeSecurityPack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeSecurityPack.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAOpCC,gCAAmB,CAACC,YAAY,CAAO,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.containsSignatures = containsSignatures;
|
|
7
|
+
exports.isRooted = isRooted;
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
const LINKING_ERROR = `The package 'react-native-security-pack' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
10
|
+
ios: "- You have run 'pod install'\n",
|
|
11
|
+
default: ''
|
|
12
|
+
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
|
|
13
|
+
|
|
14
|
+
// @ts-expect-error
|
|
15
|
+
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
16
|
+
const SecurityPackModule = isTurboModuleEnabled ? require('./NativeSecurityPack').default : _reactNative.NativeModules.SecurityPack;
|
|
17
|
+
const SecurityPack = SecurityPackModule ? SecurityPackModule : new Proxy({}, {
|
|
18
|
+
get() {
|
|
19
|
+
throw new Error(LINKING_ERROR);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
async function getSignatures() {
|
|
23
|
+
return (await SecurityPack.getSignatures()).map(item => item.toUpperCase());
|
|
24
|
+
}
|
|
25
|
+
async function containsSignatures(sigs) {
|
|
26
|
+
if (_reactNative.Platform.OS === 'ios') return true;
|
|
27
|
+
const signatures = await getSignatures();
|
|
28
|
+
const sigUpper = sigs.map(item => item.toUpperCase());
|
|
29
|
+
return signatures.some(item => sigUpper.includes(item));
|
|
30
|
+
}
|
|
31
|
+
async function isRooted() {
|
|
32
|
+
return SecurityPack.isRooted();
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","isTurboModuleEnabled","global","__turboModuleProxy","SecurityPackModule","NativeModules","SecurityPack","Proxy","get","Error","getSignatures","map","item","toUpperCase","containsSignatures","sigs","OS","signatures","sigUpper","some","includes","isRooted"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,qFAAqF,GACrFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;;AAEjC;AACA,MAAMC,oBAAoB,GAAGC,MAAM,CAACC,kBAAkB,IAAI,IAAI;AAE9D,MAAMC,kBAAkB,GAAGH,oBAAoB,GAC3CN,OAAO,CAAC,sBAAsB,CAAC,CAACK,OAAO,GACvCK,0BAAa,CAACC,YAAY;AAE9B,MAAMA,YAAY,GAAGF,kBAAkB,GACnCA,kBAAkB,GAClB,IAAIG,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACb,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,eAAec,aAAaA,CAAA,EAAsB;EAChD,OAAO,CAAC,MAAMJ,YAAY,CAACI,aAAa,CAAC,CAAC,EAAEC,GAAG,CAAEC,IAAY,IAC3DA,IAAI,CAACC,WAAW,CAAC,CACnB,CAAC;AACH;AAEO,eAAeC,kBAAkBA,CAACC,IAAc,EAAoB;EACzE,IAAIlB,qBAAQ,CAACmB,EAAE,KAAK,KAAK,EAAE,OAAO,IAAI;EAEtC,MAAMC,UAAoB,GAAG,MAAMP,aAAa,CAAC,CAAC;EAClD,MAAMQ,QAAQ,GAAGH,IAAI,CAACJ,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,WAAW,CAAC,CAAC,CAAC;EACvD,OAAOI,UAAU,CAACE,IAAI,CAAEP,IAAI,IAAKM,QAAQ,CAACE,QAAQ,CAACR,IAAI,CAAC,CAAC;AAC3D;AAEO,eAAeS,QAAQA,CAAA,EAAqB;EACjD,OAAOf,YAAY,CAACe,QAAQ,CAAC,CAAC;AAChC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|