react-native-quick-crypto 0.4.6 → 0.6.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/android/CMakeLists.txt +23 -66
- package/android/build.gradle +18 -262
- package/cpp/Cipher/MGLCipherHostObject.cpp +0 -8
- package/cpp/Cipher/MGLPublicCipherInstaller.h +0 -6
- package/cpp/Cipher/MGLRsa.cpp +1 -6
- package/cpp/MGLKeys.cpp +7 -15
- package/cpp/Sig/MGLSignHostObjects.cpp +6 -8
- package/lib/commonjs/Cipher.js +0 -1
- package/lib/commonjs/Cipher.js.map +1 -1
- package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +1 -1
- package/lib/commonjs/random.js +18 -0
- package/lib/commonjs/random.js.map +1 -1
- package/lib/module/Cipher.js +0 -1
- package/lib/module/Cipher.js.map +1 -1
- package/lib/module/NativeQuickCrypto/Cipher.js.map +1 -1
- package/lib/module/random.js +16 -0
- package/lib/module/random.js.map +1 -1
- package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +1 -1
- package/lib/typescript/QuickCrypto.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/random.d.ts +1 -0
- package/package.json +18 -15
- package/src/Cipher.ts +0 -1
- package/src/NativeQuickCrypto/Cipher.ts +1 -1
- package/src/random.ts +40 -0
- package/android/.DS_Store +0 -0
- package/android/gradle/.DS_Store +0 -0
- package/android/src/.DS_Store +0 -0
- package/android/src/main/.DS_Store +0 -0
- package/android/src/main/java/.DS_Store +0 -0
- package/android/src/main/java/com/.DS_Store +0 -0
- package/cpp/.DS_Store +0 -0
- package/ios/.DS_Store +0 -0
- package/lib/.DS_Store +0 -0
- package/src/.DS_Store +0 -0
package/android/CMakeLists.txt
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
|
+
project(react-native-quick-crypto)
|
|
1
2
|
cmake_minimum_required(VERSION 3.9.0)
|
|
2
3
|
|
|
3
|
-
set
|
|
4
|
-
set
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
set (CMAKE_CXX_STANDARD 17)
|
|
4
|
+
set(PACKAGE_NAME "reactnativequickcrypto")
|
|
5
|
+
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
|
6
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
7
|
+
|
|
8
8
|
# TODO(osp) remove before release
|
|
9
|
-
#set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
|
|
10
|
-
#set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
|
9
|
+
# set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
|
|
10
|
+
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
|
11
|
+
|
|
12
|
+
# Consume shared libraries and headers from prefabs
|
|
13
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
14
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
11
15
|
|
|
12
16
|
include_directories(
|
|
13
17
|
../cpp
|
|
14
|
-
"${NODE_MODULES_DIR}/react-native/
|
|
15
|
-
"${NODE_MODULES_DIR}/react-native/React/Base"
|
|
16
|
-
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni"
|
|
17
|
-
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
|
|
18
|
+
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
|
|
18
19
|
"${NODE_MODULES_DIR}/react-native/ReactCommon"
|
|
19
20
|
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
|
|
20
21
|
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
|
|
21
22
|
"${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
|
|
22
23
|
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
|
|
23
|
-
"${LIBFBJNI_INCLUDES}"
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
INCLUDE_JSI_CPP
|
|
29
|
-
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
|
|
30
|
-
)
|
|
31
|
-
endif()
|
|
32
|
-
|
|
33
|
-
add_library(reactnativequickcrypto # <-- Library name
|
|
26
|
+
add_library(
|
|
27
|
+
${PACKAGE_NAME}
|
|
34
28
|
SHARED
|
|
35
29
|
"src/main/cpp/cpp-adapter.cpp"
|
|
36
30
|
"../cpp/MGLQuickCryptoHostObject.cpp"
|
|
@@ -56,70 +50,33 @@ add_library(reactnativequickcrypto # <-- Library name
|
|
|
56
50
|
"../cpp/Sig/MGLSignInstaller.cpp"
|
|
57
51
|
"../cpp/Sig/MGLVerifyInstaller.cpp"
|
|
58
52
|
"../cpp/Sig/MGLSignHostObjects.cpp"
|
|
59
|
-
${INCLUDE_JSI_CPP} # only on older RN versions
|
|
60
53
|
)
|
|
61
54
|
|
|
62
55
|
set_target_properties(
|
|
63
|
-
|
|
56
|
+
${PACKAGE_NAME}
|
|
57
|
+
PROPERTIES
|
|
64
58
|
CXX_STANDARD 17
|
|
65
59
|
CXX_EXTENSIONS OFF
|
|
66
60
|
POSITION_INDEPENDENT_CODE ON
|
|
67
61
|
)
|
|
68
62
|
|
|
69
|
-
file
|
|
63
|
+
file(GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}")
|
|
70
64
|
|
|
71
65
|
find_library(
|
|
72
66
|
log-lib
|
|
73
67
|
log
|
|
74
68
|
)
|
|
75
|
-
find_library(
|
|
76
|
-
REACT_NATIVE_JNI_LIB
|
|
77
|
-
reactnativejni
|
|
78
|
-
PATHS ${LIBRN_DIR}
|
|
79
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
80
|
-
)
|
|
81
|
-
find_library(
|
|
82
|
-
FBJNI_LIB
|
|
83
|
-
fbjni
|
|
84
|
-
PATHS ${LIBRN_SO}
|
|
85
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
86
|
-
)
|
|
87
|
-
find_library(
|
|
88
|
-
TURBOMODULES_LIB
|
|
89
|
-
turbomodulejsijni
|
|
90
|
-
PATHS ${LIBRN_DIR}
|
|
91
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
92
|
-
)
|
|
93
|
-
find_library(
|
|
94
|
-
REACT_LIB
|
|
95
|
-
react_nativemodule_core
|
|
96
|
-
PATHS ${LIBRN_DIR}
|
|
97
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
if(${REACT_NATIVE_VERSION} LESS 66)
|
|
101
|
-
# JSI lib didn't exist on RN 0.65 and before. Simply omit it.
|
|
102
|
-
set (JSI_LIB "")
|
|
103
|
-
else()
|
|
104
|
-
# RN 0.66 distributes libjsi.so, can be used instead of compiling jsi.cpp manually.
|
|
105
|
-
find_library(
|
|
106
|
-
JSI_LIB
|
|
107
|
-
jsi
|
|
108
|
-
PATHS ${LIBRN_DIR}
|
|
109
|
-
NO_CMAKE_FIND_ROOT_PATH
|
|
110
|
-
)
|
|
111
|
-
endif()
|
|
112
69
|
|
|
113
70
|
find_package(openssl REQUIRED CONFIG)
|
|
114
71
|
|
|
115
72
|
target_link_libraries(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
73
|
+
${PACKAGE_NAME}
|
|
74
|
+
ReactAndroid::turbomodulejsijni
|
|
75
|
+
fbjni::fbjni
|
|
119
76
|
${log-lib}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
77
|
+
ReactAndroid::jsi
|
|
78
|
+
ReactAndroid::reactnativejni
|
|
79
|
+
ReactAndroid::react_nativemodule_core
|
|
123
80
|
android
|
|
124
81
|
openssl::crypto
|
|
125
82
|
)
|
package/android/build.gradle
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import groovy.json.JsonSlurper
|
|
2
|
-
import org.apache.tools.ant.filters.ReplaceTokens
|
|
3
1
|
import java.nio.file.Paths
|
|
4
2
|
|
|
5
3
|
static def findNodeModules(baseDir) {
|
|
@@ -31,12 +29,10 @@ buildscript {
|
|
|
31
29
|
|
|
32
30
|
dependencies {
|
|
33
31
|
classpath 'com.android.tools.build:gradle:4.2.2'
|
|
34
|
-
classpath 'de.undercouch:gradle-download-task:4.1.2'
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
apply plugin: 'com.android.library'
|
|
39
|
-
apply plugin: 'de.undercouch.download'
|
|
40
36
|
|
|
41
37
|
def getExtOrDefault(name) {
|
|
42
38
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['QuickCrypto_' + name]
|
|
@@ -51,43 +47,18 @@ def reactNativeArchitectures() {
|
|
|
51
47
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
def sourceBuild = false
|
|
55
|
-
def defaultDir = null
|
|
56
|
-
def androidSourcesDir = null
|
|
57
|
-
def androidSourcesName = 'React Native sources'
|
|
58
|
-
|
|
59
|
-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
60
|
-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
61
|
-
androidSourcesDir = defaultDir.parentFile.toString()
|
|
62
|
-
} else if (findProject(':ReactAndroid') != null) {
|
|
63
|
-
sourceBuild = true
|
|
64
|
-
defaultDir = project(':ReactAndroid').projectDir
|
|
65
|
-
androidSourcesDir = defaultDir.parentFile.toString()
|
|
66
|
-
} else {
|
|
67
|
-
defaultDir = file("$nodeModules/react-native/android")
|
|
68
|
-
androidSourcesDir = defaultDir.parentFile.toString()
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!defaultDir.exists()) {
|
|
72
|
-
throw new GradleException(
|
|
73
|
-
"${project.name}: React Native android directory (node_modules/react-native/android) does not exist! Resolved node_modules to: ${nodeModules}"
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
def prebuiltDir = sourceBuild
|
|
78
|
-
? "$nodeModules/react-native/ReactAndroid/src/main/jni/prebuilt/lib"
|
|
79
|
-
: "$buildDir/react-native-0*/jni"
|
|
80
|
-
|
|
81
|
-
|
|
82
50
|
def reactProperties = new Properties()
|
|
83
51
|
file("$nodeModules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
|
|
84
|
-
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME").split("\\.")[1].toInteger()
|
|
85
52
|
|
|
86
53
|
android {
|
|
87
54
|
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
88
55
|
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
89
56
|
ndkVersion getExtOrDefault('ndkVersion')
|
|
90
57
|
|
|
58
|
+
buildFeatures {
|
|
59
|
+
prefab true
|
|
60
|
+
}
|
|
61
|
+
|
|
91
62
|
defaultConfig {
|
|
92
63
|
minSdkVersion 21
|
|
93
64
|
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
@@ -95,11 +66,9 @@ android {
|
|
|
95
66
|
versionName "1.0"
|
|
96
67
|
externalNativeBuild {
|
|
97
68
|
cmake {
|
|
98
|
-
cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
|
|
69
|
+
cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID", "-DANDROID"
|
|
99
70
|
arguments '-DANDROID_STL=c++_shared',
|
|
100
|
-
"-
|
|
101
|
-
"-DNODE_MODULES_DIR=${nodeModules}",
|
|
102
|
-
"-DPREBUILT_DIR=${prebuiltDir}"
|
|
71
|
+
"-DNODE_MODULES_DIR=${nodeModules}"
|
|
103
72
|
}
|
|
104
73
|
}
|
|
105
74
|
ndk {
|
|
@@ -107,10 +76,6 @@ android {
|
|
|
107
76
|
}
|
|
108
77
|
}
|
|
109
78
|
|
|
110
|
-
dexOptions {
|
|
111
|
-
javaMaxHeapSize "4g"
|
|
112
|
-
}
|
|
113
|
-
|
|
114
79
|
externalNativeBuild {
|
|
115
80
|
cmake {
|
|
116
81
|
path "CMakeLists.txt"
|
|
@@ -118,7 +83,16 @@ android {
|
|
|
118
83
|
}
|
|
119
84
|
|
|
120
85
|
packagingOptions {
|
|
121
|
-
excludes = [
|
|
86
|
+
excludes = [
|
|
87
|
+
"**/libc++_shared.so",
|
|
88
|
+
"**/libfbjni.so",
|
|
89
|
+
"**/libreactnativejni.so",
|
|
90
|
+
"**/libjsi.so",
|
|
91
|
+
"**/libreact_nativemodule_core.so",
|
|
92
|
+
"**/libturbomodulejsijni.so",
|
|
93
|
+
"**/MANIFEST.MF",
|
|
94
|
+
""
|
|
95
|
+
]
|
|
122
96
|
doNotStrip '**/*.so'
|
|
123
97
|
}
|
|
124
98
|
|
|
@@ -145,11 +119,6 @@ android {
|
|
|
145
119
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
146
120
|
}
|
|
147
121
|
|
|
148
|
-
configurations {
|
|
149
|
-
extractHeaders
|
|
150
|
-
extractJNI
|
|
151
|
-
}
|
|
152
|
-
|
|
153
122
|
buildFeatures {
|
|
154
123
|
prefab true
|
|
155
124
|
}
|
|
@@ -158,225 +127,12 @@ android {
|
|
|
158
127
|
repositories {
|
|
159
128
|
mavenCentral()
|
|
160
129
|
google()
|
|
161
|
-
|
|
162
|
-
maven {
|
|
163
|
-
url defaultDir.toString()
|
|
164
|
-
name androidSourcesName
|
|
165
|
-
}
|
|
166
130
|
}
|
|
167
131
|
|
|
168
132
|
dependencies {
|
|
169
133
|
// https://mvnrepository.com/artifact/com.android.ndk.thirdparty/openssl
|
|
170
134
|
implementation 'com.android.ndk.thirdparty:openssl:1.1.1l-beta-1'
|
|
171
|
-
// noinspection GradleDynamicVersion
|
|
172
|
-
implementation 'com.facebook.react:react-native:+'
|
|
173
|
-
|
|
174
|
-
//noinspection GradleDynamicVersion
|
|
175
|
-
extractHeaders("com.facebook.fbjni:fbjni:+:headers")
|
|
176
|
-
//noinspection GradleDynamicVersion
|
|
177
|
-
extractJNI("com.facebook.fbjni:fbjni:+")
|
|
178
|
-
|
|
179
|
-
if (!sourceBuild) {
|
|
180
|
-
def buildType = "debug"
|
|
181
|
-
tasks.all({ task ->
|
|
182
|
-
if (task.name == "buildCMakeRelease") {
|
|
183
|
-
buildType = "release"
|
|
184
|
-
}
|
|
185
|
-
})
|
|
186
|
-
def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
|
|
187
|
-
if (REACT_NATIVE_VERSION < 69) {
|
|
188
|
-
rnAarMatcher = "**/**/*.aar"
|
|
189
|
-
}
|
|
190
|
-
def rnAAR = fileTree("${defaultDir.toString()}").matching({ it.include rnAarMatcher }).singleFile
|
|
191
|
-
extractJNI(files(rnAAR))
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// third-party-ndk deps headers
|
|
196
|
-
// mostly a copy of https://github.com/software-mansion/react-native-reanimated/blob/master/android/build.gradle#L115
|
|
197
|
-
|
|
198
|
-
def downloadsDir = new File("$buildDir/downloads")
|
|
199
|
-
def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
|
|
200
|
-
def thirdPartyVersionsFile = new File("${androidSourcesDir.toString()}/ReactAndroid/gradle.properties")
|
|
201
|
-
def thirdPartyVersions = new Properties()
|
|
202
|
-
thirdPartyVersions.load(new FileInputStream(thirdPartyVersionsFile))
|
|
203
|
-
|
|
204
|
-
def BOOST_VERSION = thirdPartyVersions["BOOST_VERSION"]
|
|
205
|
-
def boost_file = new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz")
|
|
206
|
-
def DOUBLE_CONVERSION_VERSION = thirdPartyVersions["DOUBLE_CONVERSION_VERSION"]
|
|
207
|
-
def double_conversion_file = new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz")
|
|
208
|
-
def FOLLY_VERSION = thirdPartyVersions["FOLLY_VERSION"]
|
|
209
|
-
def folly_file = new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz")
|
|
210
|
-
def GLOG_VERSION = thirdPartyVersions["GLOG_VERSION"]
|
|
211
|
-
def glog_file = new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz")
|
|
212
|
-
|
|
213
|
-
task createNativeDepsDirectories {
|
|
214
|
-
doLast {
|
|
215
|
-
downloadsDir.mkdirs()
|
|
216
|
-
thirdPartyNdkDir.mkdirs()
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
221
|
-
def transformedVersion = BOOST_VERSION.replace("_", ".")
|
|
222
|
-
def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
|
|
223
|
-
if (REACT_NATIVE_VERSION < 69) {
|
|
224
|
-
srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
|
|
225
|
-
}
|
|
226
|
-
src(srcUrl)
|
|
227
|
-
onlyIfNewer(true)
|
|
228
|
-
overwrite(false)
|
|
229
|
-
dest(boost_file)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
task prepareBoost(dependsOn: downloadBoost, type: Copy) {
|
|
233
|
-
from(tarTree(resources.gzip(downloadBoost.dest)))
|
|
234
|
-
from("src/main/jni/third-party/boost/Android.mk")
|
|
235
|
-
include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
|
|
236
|
-
includeEmptyDirs = false
|
|
237
|
-
into("$thirdPartyNdkDir") // /boost_X_XX_X
|
|
238
|
-
doLast {
|
|
239
|
-
file("$thirdPartyNdkDir/boost_${BOOST_VERSION}").renameTo("$thirdPartyNdkDir/boost")
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
244
|
-
src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
|
|
245
|
-
onlyIfNewer(true)
|
|
246
|
-
overwrite(false)
|
|
247
|
-
dest(double_conversion_file)
|
|
248
|
-
}
|
|
249
135
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
from("src/main/jni/third-party/double-conversion/Android.mk")
|
|
253
|
-
include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
|
|
254
|
-
filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
|
|
255
|
-
includeEmptyDirs = false
|
|
256
|
-
into("$thirdPartyNdkDir/double-conversion")
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
260
|
-
src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
|
|
261
|
-
onlyIfNewer(true)
|
|
262
|
-
overwrite(false)
|
|
263
|
-
dest(folly_file)
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
task prepareFolly(dependsOn: downloadFolly, type: Copy) {
|
|
267
|
-
from(tarTree(downloadFolly.dest))
|
|
268
|
-
from("src/main/jni/third-party/folly/Android.mk")
|
|
269
|
-
include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
|
|
270
|
-
eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
|
|
271
|
-
includeEmptyDirs = false
|
|
272
|
-
into("$thirdPartyNdkDir/folly")
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
|
|
276
|
-
src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
|
|
277
|
-
onlyIfNewer(true)
|
|
278
|
-
overwrite(false)
|
|
279
|
-
dest(glog_file)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
task prepareGlog(dependsOn: downloadGlog, type: Copy) {
|
|
283
|
-
from(tarTree(downloadGlog.dest))
|
|
284
|
-
from("src/main/jni/third-party/glog/")
|
|
285
|
-
include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
|
|
286
|
-
includeEmptyDirs = false
|
|
287
|
-
filesMatching("**/*.h.in") {
|
|
288
|
-
filter(ReplaceTokens, tokens: [
|
|
289
|
-
ac_cv_have_unistd_h : "1",
|
|
290
|
-
ac_cv_have_stdint_h : "1",
|
|
291
|
-
ac_cv_have_systypes_h : "1",
|
|
292
|
-
ac_cv_have_inttypes_h : "1",
|
|
293
|
-
ac_cv_have_libgflags : "0",
|
|
294
|
-
ac_google_start_namespace : "namespace google {",
|
|
295
|
-
ac_cv_have_uint16_t : "1",
|
|
296
|
-
ac_cv_have_u_int16_t : "1",
|
|
297
|
-
ac_cv_have___uint16 : "0",
|
|
298
|
-
ac_google_end_namespace : "}",
|
|
299
|
-
ac_cv_have___builtin_expect : "1",
|
|
300
|
-
ac_google_namespace : "google",
|
|
301
|
-
ac_cv___attribute___noinline : "__attribute__ ((noinline))",
|
|
302
|
-
ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
|
|
303
|
-
ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
|
|
304
|
-
])
|
|
305
|
-
it.path = (it.name - ".in")
|
|
306
|
-
}
|
|
307
|
-
into("$thirdPartyNdkDir/glog")
|
|
308
|
-
|
|
309
|
-
doLast {
|
|
310
|
-
copy {
|
|
311
|
-
from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
|
|
312
|
-
includeEmptyDirs = false
|
|
313
|
-
into("$thirdPartyNdkDir/glog/exported/glog")
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
task prepareThirdPartyNdkHeaders {
|
|
319
|
-
if (!boost_file.exists()) {
|
|
320
|
-
dependsOn(prepareBoost)
|
|
321
|
-
}
|
|
322
|
-
if (!double_conversion_file.exists()) {
|
|
323
|
-
dependsOn(prepareDoubleConversion)
|
|
324
|
-
}
|
|
325
|
-
if (!folly_file.exists()) {
|
|
326
|
-
dependsOn(prepareFolly)
|
|
327
|
-
}
|
|
328
|
-
if (!glog_file.exists()) {
|
|
329
|
-
dependsOn(prepareGlog)
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
prepareThirdPartyNdkHeaders.mustRunAfter createNativeDepsDirectories
|
|
334
|
-
|
|
335
|
-
task extractAARHeaders {
|
|
336
|
-
doLast {
|
|
337
|
-
configurations.extractHeaders.files.each {
|
|
338
|
-
def file = it.absoluteFile
|
|
339
|
-
copy {
|
|
340
|
-
from zipTree(file)
|
|
341
|
-
into "$buildDir/$file.name"
|
|
342
|
-
include "**/*.h"
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
extractAARHeaders.mustRunAfter prepareThirdPartyNdkHeaders
|
|
348
|
-
|
|
349
|
-
task extractJNIFiles {
|
|
350
|
-
doLast {
|
|
351
|
-
configurations.extractJNI.files.each {
|
|
352
|
-
def file = it.absoluteFile
|
|
353
|
-
|
|
354
|
-
copy {
|
|
355
|
-
from zipTree(file)
|
|
356
|
-
into "$buildDir/$file.name"
|
|
357
|
-
include "jni/**/*"
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
extractJNIFiles.mustRunAfter extractAARHeaders
|
|
363
|
-
|
|
364
|
-
def nativeBuildDependsOn(dependsOnTask, variant) {
|
|
365
|
-
def buildTasks = tasks.findAll({ task ->
|
|
366
|
-
!task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) })
|
|
367
|
-
if (variant != null) {
|
|
368
|
-
buildTasks = buildTasks.findAll({ task -> task.name.contains(variant) })
|
|
369
|
-
}
|
|
370
|
-
buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
afterEvaluate {
|
|
374
|
-
if (sourceBuild) {
|
|
375
|
-
nativeBuildDependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck", "Debug")
|
|
376
|
-
nativeBuildDependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck", "Rel")
|
|
377
|
-
} else {
|
|
378
|
-
nativeBuildDependsOn(extractAARHeaders, null)
|
|
379
|
-
nativeBuildDependsOn(extractJNIFiles, null)
|
|
380
|
-
nativeBuildDependsOn(prepareThirdPartyNdkHeaders, null)
|
|
381
|
-
}
|
|
136
|
+
implementation "com.facebook.react:react-android:"
|
|
137
|
+
implementation "com.facebook.react:hermes-android:"
|
|
382
138
|
}
|
|
@@ -451,9 +451,6 @@ void MGLCipherHostObject::installMethods() {
|
|
|
451
451
|
"setAuthTag", JSIF([=]) {
|
|
452
452
|
if (count != 1 || !arguments[0].isObject() ||
|
|
453
453
|
!arguments[0].asObject(runtime).isArrayBuffer(runtime)) {
|
|
454
|
-
jsi::detail::throwJSError(
|
|
455
|
-
runtime,
|
|
456
|
-
"cipher.setAuthTag requires an ArrayBuffer tag argument");
|
|
457
454
|
throw jsi::JSError(
|
|
458
455
|
runtime,
|
|
459
456
|
"cipher.setAuthTag requires an ArrayBuffer tag argument");
|
|
@@ -467,9 +464,6 @@ void MGLCipherHostObject::installMethods() {
|
|
|
467
464
|
auto authTagArrayBuffer =
|
|
468
465
|
arguments[0].asObject(runtime).getArrayBuffer(runtime);
|
|
469
466
|
if (!CheckSizeInt32(runtime, authTagArrayBuffer)) {
|
|
470
|
-
jsi::detail::throwJSError(
|
|
471
|
-
runtime,
|
|
472
|
-
"cipher.setAuthTag requires an ArrayBuffer tag argument");
|
|
473
467
|
throw jsi::JSError(
|
|
474
468
|
runtime,
|
|
475
469
|
"cipher.setAuthTag requires an ArrayBuffer tag argument");
|
|
@@ -502,8 +496,6 @@ void MGLCipherHostObject::installMethods() {
|
|
|
502
496
|
}
|
|
503
497
|
|
|
504
498
|
if (!is_valid) {
|
|
505
|
-
jsi::detail::throwJSError(runtime,
|
|
506
|
-
"Invalid authentication tag length");
|
|
507
499
|
throw jsi::JSError(runtime, "Invalid authentication tag length");
|
|
508
500
|
}
|
|
509
501
|
|
|
@@ -57,20 +57,17 @@ FieldDefinition getPublicCipherFieldDefinition(
|
|
|
57
57
|
runtime, arguments, &offset);
|
|
58
58
|
|
|
59
59
|
if (!pkey) {
|
|
60
|
-
jsi::detail::throwJSError(runtime, "Could not generate key");
|
|
61
60
|
throw new jsi::JSError(runtime, "Could not generate key");
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
auto buf = arguments[offset].asObject(runtime).getArrayBuffer(runtime);
|
|
65
64
|
if (!CheckSizeInt32(runtime, buf)) {
|
|
66
|
-
jsi::detail::throwJSError(runtime, "Data buffer is too long");
|
|
67
65
|
throw new jsi::JSError(runtime, "Data buffer is too long");
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
uint32_t padding =
|
|
71
69
|
static_cast<uint32_t>(arguments[offset + 1].getNumber());
|
|
72
70
|
if (!padding) {
|
|
73
|
-
jsi::detail::throwJSError(runtime, "Invalid padding");
|
|
74
71
|
throw new jsi::JSError(runtime, "Invalid padding");
|
|
75
72
|
}
|
|
76
73
|
|
|
@@ -81,7 +78,6 @@ FieldDefinition getPublicCipherFieldDefinition(
|
|
|
81
78
|
|
|
82
79
|
digest = EVP_get_digestbyname(oaep_str.c_str());
|
|
83
80
|
if (digest == nullptr) {
|
|
84
|
-
jsi::detail::throwJSError(runtime, "Invalid digest (oaep_str)");
|
|
85
81
|
throw new jsi::JSError(runtime, "Invalid digest (oaep_str)");
|
|
86
82
|
}
|
|
87
83
|
}
|
|
@@ -90,7 +86,6 @@ FieldDefinition getPublicCipherFieldDefinition(
|
|
|
90
86
|
auto oaep_label_buffer =
|
|
91
87
|
arguments[offset + 3].getObject(runtime).getArrayBuffer(runtime);
|
|
92
88
|
if (!CheckSizeInt32(runtime, oaep_label_buffer)) {
|
|
93
|
-
jsi::detail::throwJSError(runtime, "oaep_label buffer is too long");
|
|
94
89
|
throw new jsi::JSError(runtime, "oaep_label buffer is too long");
|
|
95
90
|
}
|
|
96
91
|
}
|
|
@@ -101,7 +96,6 @@ FieldDefinition getPublicCipherFieldDefinition(
|
|
|
101
96
|
runtime, pkey, padding, digest, arguments[offset + 3], buf);
|
|
102
97
|
|
|
103
98
|
if (!out.has_value()) {
|
|
104
|
-
jsi::detail::throwJSError(runtime, "Failed to decrypt");
|
|
105
99
|
throw new jsi::JSError(runtime, "Failed to decrypt");
|
|
106
100
|
}
|
|
107
101
|
|
package/cpp/Cipher/MGLRsa.cpp
CHANGED
|
@@ -108,7 +108,6 @@ RsaKeyPairGenConfig prepareRsaKeyGenConfig(jsi::Runtime& runtime,
|
|
|
108
108
|
arguments[offset].asString(runtime).utf8(runtime).c_str());
|
|
109
109
|
|
|
110
110
|
if (config.md == nullptr) {
|
|
111
|
-
jsi::detail::throwJSError(runtime, "invalid digest");
|
|
112
111
|
throw new jsi::JSError(runtime, "invalid digest");
|
|
113
112
|
}
|
|
114
113
|
}
|
|
@@ -119,7 +118,6 @@ RsaKeyPairGenConfig prepareRsaKeyGenConfig(jsi::Runtime& runtime,
|
|
|
119
118
|
arguments[offset + 1].asString(runtime).utf8(runtime).c_str());
|
|
120
119
|
|
|
121
120
|
if (config.mgf1_md == nullptr) {
|
|
122
|
-
jsi::detail::throwJSError(runtime, "invalid digest");
|
|
123
121
|
throw new jsi::JSError(runtime, "invalid digest");
|
|
124
122
|
}
|
|
125
123
|
}
|
|
@@ -129,7 +127,6 @@ RsaKeyPairGenConfig prepareRsaKeyGenConfig(jsi::Runtime& runtime,
|
|
|
129
127
|
config.saltlen = static_cast<int>(arguments[offset + 2].asNumber());
|
|
130
128
|
|
|
131
129
|
if (config.saltlen < 0) {
|
|
132
|
-
jsi::detail::throwJSError(runtime, "salt length is out of range");
|
|
133
130
|
throw new jsi::JSError(runtime, "salt length is out of range");
|
|
134
131
|
}
|
|
135
132
|
}
|
|
@@ -157,14 +154,12 @@ std::pair<StringOrBuffer, StringOrBuffer> generateRSAKeyPair(
|
|
|
157
154
|
EVPKeyCtxPointer ctx = setup(config);
|
|
158
155
|
|
|
159
156
|
if (!ctx) {
|
|
160
|
-
jsi::detail::throwJSError(runtime, "Error on key generation job");
|
|
161
157
|
throw new jsi::JSError(runtime, "Error on key generation job");
|
|
162
158
|
}
|
|
163
159
|
|
|
164
160
|
// Generate the key
|
|
165
161
|
EVP_PKEY* pkey = nullptr;
|
|
166
162
|
if (!EVP_PKEY_keygen(ctx.get(), &pkey)) {
|
|
167
|
-
jsi::detail::throwJSError(runtime, "Error generating key");
|
|
168
163
|
throw new jsi::JSError(runtime, "Error generating key");
|
|
169
164
|
}
|
|
170
165
|
|
|
@@ -178,7 +173,7 @@ std::pair<StringOrBuffer, StringOrBuffer> generateRSAKeyPair(
|
|
|
178
173
|
config->private_key_encoding);
|
|
179
174
|
|
|
180
175
|
if (!publicBuffer.has_value() || !privateBuffer.has_value()) {
|
|
181
|
-
jsi::
|
|
176
|
+
throw jsi::JSError(runtime,
|
|
182
177
|
"Failed to encode public and/or private key");
|
|
183
178
|
}
|
|
184
179
|
|
package/cpp/MGLKeys.cpp
CHANGED
|
@@ -348,8 +348,7 @@ std::optional<StringOrBuffer> WritePrivateKey(
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
if (err) {
|
|
351
|
-
jsi::
|
|
352
|
-
return {};
|
|
351
|
+
throw jsi::JSError(runtime, "Failed to encode private key");
|
|
353
352
|
}
|
|
354
353
|
|
|
355
354
|
return BIOToStringOrBuffer(bio.get(), config.format_);
|
|
@@ -389,8 +388,7 @@ std::optional<StringOrBuffer> WritePublicKey(
|
|
|
389
388
|
// CHECK(bio);
|
|
390
389
|
|
|
391
390
|
if (!WritePublicKeyInner(pkey, bio, config)) {
|
|
392
|
-
jsi::
|
|
393
|
-
return std::nullopt;
|
|
391
|
+
throw jsi::JSError(runtime, "Failed to encode public key");
|
|
394
392
|
}
|
|
395
393
|
|
|
396
394
|
return BIOToStringOrBuffer(bio.get(), config.format_);
|
|
@@ -648,8 +646,7 @@ ManagedEVPPKey::GetPrivateKeyEncodingFromJs(jsi::Runtime& runtime,
|
|
|
648
646
|
auto cipher_name = arguments[*offset].getString(runtime).utf8(runtime);
|
|
649
647
|
result.cipher_ = EVP_get_cipherbyname(cipher_name.c_str());
|
|
650
648
|
if (result.cipher_ == nullptr) {
|
|
651
|
-
jsi::
|
|
652
|
-
return NonCopyableMaybe<PrivateKeyEncodingConfig>();
|
|
649
|
+
throw jsi::JSError(runtime, "Unknown cipher");
|
|
653
650
|
}
|
|
654
651
|
needs_passphrase = true;
|
|
655
652
|
} else {
|
|
@@ -666,7 +663,7 @@ ManagedEVPPKey::GetPrivateKeyEncodingFromJs(jsi::Runtime& runtime,
|
|
|
666
663
|
jsi::ArrayBuffer passphrase =
|
|
667
664
|
arguments[*offset].asObject(runtime).getArrayBuffer(runtime);
|
|
668
665
|
if (!CheckSizeInt32(runtime, passphrase)) {
|
|
669
|
-
jsi::
|
|
666
|
+
throw jsi::JSError(runtime, "passphrase is too long");
|
|
670
667
|
}
|
|
671
668
|
|
|
672
669
|
result.passphrase_ = NonCopyableMaybe<ByteSource>(
|
|
@@ -674,7 +671,7 @@ ManagedEVPPKey::GetPrivateKeyEncodingFromJs(jsi::Runtime& runtime,
|
|
|
674
671
|
} else {
|
|
675
672
|
if (needs_passphrase &&
|
|
676
673
|
(arguments[*offset].isNull() || arguments[*offset].isUndefined())) {
|
|
677
|
-
jsi::
|
|
674
|
+
throw jsi::JSError(
|
|
678
675
|
runtime, "passphrase is null or unfedined but it is required");
|
|
679
676
|
}
|
|
680
677
|
}
|
|
@@ -728,7 +725,7 @@ ManagedEVPPKey ManagedEVPPKey::GetPublicOrPrivateKeyFromJs(
|
|
|
728
725
|
args[(*offset)++].asObject(runtime).getArrayBuffer(runtime);
|
|
729
726
|
|
|
730
727
|
if (!CheckSizeInt32(runtime, dataArrayBuffer)) {
|
|
731
|
-
jsi::
|
|
728
|
+
throw jsi::JSError(runtime, "data is too big");
|
|
732
729
|
}
|
|
733
730
|
|
|
734
731
|
NonCopyableMaybe<PrivateKeyEncodingConfig> config_ =
|
|
@@ -766,7 +763,6 @@ ManagedEVPPKey ManagedEVPPKey::GetPublicOrPrivateKeyFromJs(
|
|
|
766
763
|
is_public = false;
|
|
767
764
|
break;
|
|
768
765
|
default:
|
|
769
|
-
jsi::detail::throwJSError(runtime, "Invalid key encoding type");
|
|
770
766
|
throw new jsi::JSError(runtime, "Invalid key encoding type");
|
|
771
767
|
}
|
|
772
768
|
|
|
@@ -784,9 +780,6 @@ ManagedEVPPKey ManagedEVPPKey::GetPublicOrPrivateKeyFromJs(
|
|
|
784
780
|
return ManagedEVPPKey::GetParsedKey(runtime, std::move(pkey), ret,
|
|
785
781
|
"Failed to read asymmetric key");
|
|
786
782
|
} else {
|
|
787
|
-
jsi::detail::throwJSError(runtime,
|
|
788
|
-
"publicEncrypt api only supports ArrayBuffer keys"
|
|
789
|
-
"for now");
|
|
790
783
|
throw new jsi::JSError(
|
|
791
784
|
runtime, "public encrypt only supports ArrayBuffer at the moment");
|
|
792
785
|
// CHECK(args[*offset]->IsObject());
|
|
@@ -808,11 +801,10 @@ ManagedEVPPKey ManagedEVPPKey::GetParsedKey(jsi::Runtime& runtime,
|
|
|
808
801
|
// CHECK(pkey);
|
|
809
802
|
break;
|
|
810
803
|
case ParseKeyResult::kParseKeyNeedPassphrase:
|
|
811
|
-
jsi::
|
|
804
|
+
throw jsi::JSError(runtime,
|
|
812
805
|
"Passphrase required for encrypted key");
|
|
813
806
|
break;
|
|
814
807
|
default:
|
|
815
|
-
jsi::detail::throwJSError(runtime, default_msg);
|
|
816
808
|
throw new jsi::JSError(runtime, default_msg);
|
|
817
809
|
}
|
|
818
810
|
|