Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for subtle (importKey,exportKey) (raw,jwk) (aes,ec,rsa) #233

Merged
merged 10 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- 'example/yarn.lock'

jobs:
build_example:
build_android_example:
name: Build Android Example App
runs-on: ubuntu-latest
steps:
Expand All @@ -29,9 +29,17 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17
cache: gradle

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
Expand All @@ -49,16 +57,18 @@ jobs:
- name: Install node_modules for example/
run: yarn install --frozen-lockfile --cwd example

# - name: Restore Gradle cache
# uses: actions/cache@v4
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
# - name: Run Gradle Build for android/
# run: cd android && ./gradlew assembleDebug && cd ..
- name: Restore Gradle cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Run Gradle Build for android/
run: cd android && ./gradlew assembleDebug && cd ..

- name: Run Gradle Build for example/android/
run: cd example/android && ./gradlew assembleDebug && cd ../..
run: cd example/android && ./gradlew assembleDebug --build-cache && cd ../..
10 changes: 5 additions & 5 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- 'example/ios/**'

jobs:
build:
build_ios_example:
name: Build iOS Example App
runs-on: macOS-latest
defaults:
Expand All @@ -40,9 +40,9 @@ jobs:
- name: Install node_modules for example/
run: yarn install --frozen-lockfile --cwd ..

- name: Restore buildcache
uses: mikehardy/buildcache-action@v2
continue-on-error: true
# - name: Restore buildcache
# uses: mikehardy/buildcache-action@v2
# continue-on-error: true

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
Expand All @@ -65,7 +65,7 @@ jobs:
working-directory: example
run: bundle config set deployment 'true' && bundle install
- name: Install Pods
run: bundle exec pod install
run: yarn pods
- name: Install xcpretty
run: gem install xcpretty
- name: Build App
Expand Down
33 changes: 21 additions & 12 deletions .github/workflows/validate-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- '.editorconfig'

jobs:
lint:
validate_android:
name: Gradle Lint
runs-on: ubuntu-latest
defaults:
Expand All @@ -28,12 +28,21 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17
cache: gradle

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore node_modules from cache
uses: actions/cache@v4
id: yarn-cache
Expand All @@ -47,21 +56,21 @@ jobs:
- name: Install node_modules for example/
run: yarn install --frozen-lockfile --cwd ../example

# - name: Restore Gradle cache
# uses: actions/cache@v4
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
# restore-keys: |
# ${{ runner.os }}-gradle-
- name: Restore Gradle cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Run Gradle Lint
run: cd ../example/android && ./gradlew lint

- name: Parse Gradle Lint Report
uses: yutailang0119/action-android-lint@v3
uses: yutailang0119/action-android-lint@v4
with:
# ignore-warnings: true
report-path: example/android/app/build/reports/*.xml
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ on:
- 'android/src/main/cpp/**'

jobs:
lint:
name: cpplint
validate_cpp:
name: C++ Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/validate-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,24 @@ on:
- 'example/*.tsx'

jobs:
compile:
compile_js:
name: Compile JS (tsc)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable

- name: Install reviewdog
uses: reviewdog/action-setup@v1

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore node_modules from cache
uses: actions/cache@v4
id: yarn-cache
Expand All @@ -52,6 +58,7 @@ jobs:

- name: Install node_modules
run: yarn install --frozen-lockfile

- name: Install node_modules (example/)
run: yarn install --frozen-lockfile --cwd example

Expand All @@ -67,15 +74,21 @@ jobs:
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

lint:
name: Lint JS (eslint, prettier)
lint_js:
name: JS Lint (eslint, prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
- run: corepack enable

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Restore node_modules from cache
uses: actions/cache@v4
id: yarn-cache
Expand All @@ -87,6 +100,7 @@ jobs:

- name: Install node_modules
run: yarn install --frozen-lockfile

- name: Install node_modules (example/)
run: yarn install --frozen-lockfile --cwd example

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = {
+ {
+ alias: {
+ 'crypto': 'react-native-quick-crypto',
+ 'stream': 'stream-browserify',
+ 'stream': 'readable-stream',
+ 'buffer': '@craftzdog/react-native-buffer',
+ },
+ },
Expand Down
119 changes: 58 additions & 61 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,82 +1,79 @@
project(react-native-quick-crypto)
project(ReactNativeQuickCrypto)
cmake_minimum_required(VERSION 3.10.2)

set(PACKAGE_NAME "reactnativequickcrypto")
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(NODE_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../node_modules")

# set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")

# Consume shared libraries and headers from prefabs
# Third party libraries (Prefabs)
find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)

include_directories(
../cpp
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
)
find_package(openssl REQUIRED CONFIG)
find_library(LOG_LIB log)

add_library(
${PACKAGE_NAME}
SHARED
"src/main/cpp/cpp-adapter.cpp"
"../cpp/MGLQuickCryptoHostObject.cpp"
"../cpp/JSIUtils/MGLTypedArray.cpp"
"../cpp/Utils/MGLDispatchQueue.cpp"
"../cpp/JSIUtils/MGLThreadAwareHostObject.cpp"
"../cpp/JSIUtils/MGLSmartHostObject.cpp"
"../cpp/HMAC/MGLHmacInstaller.cpp"
"../cpp/HMAC/MGLHmacHostObject.cpp"
"../cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp"
"../cpp/fastpbkdf2/fastpbkdf2.c"
"../cpp/Random/MGLRandomHostObject.cpp"
"../cpp/Hash/MGLHashInstaller.cpp"
"../cpp/Hash/MGLHashHostObject.cpp"
"../cpp/Cipher/MGLCipherHostObject.cpp"
"../cpp/Cipher/MGLCreateCipherInstaller.cpp"
"../cpp/Cipher/MGLCreateDecipherInstaller.cpp"
"../cpp/MGLKeys.cpp"
"../cpp/Utils/MGLUtils.cpp"
"../cpp/Cipher/MGLRsa.cpp"
"../cpp/Cipher/MGLGenerateKeyPairInstaller.cpp"
"../cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp"
"../cpp/Sig/MGLSignInstaller.cpp"
"../cpp/Sig/MGLVerifyInstaller.cpp"
"../cpp/Sig/MGLSignHostObjects.cpp"
"../cpp/webcrypto/MGLWebCrypto.cpp"
"../cpp/webcrypto/crypto_ec.cpp"
${PACKAGE_NAME}
SHARED
"src/main/cpp/cpp-adapter.cpp"
"../cpp/MGLQuickCryptoHostObject.cpp"
"../cpp/JSIUtils/MGLTypedArray.cpp"
"../cpp/Utils/MGLDispatchQueue.cpp"
"../cpp/JSIUtils/MGLThreadAwareHostObject.cpp"
"../cpp/JSIUtils/MGLSmartHostObject.cpp"
"../cpp/HMAC/MGLHmacInstaller.cpp"
"../cpp/HMAC/MGLHmacHostObject.cpp"
"../cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp"
"../cpp/fastpbkdf2/fastpbkdf2.c"
"../cpp/Random/MGLRandomHostObject.cpp"
"../cpp/Hash/MGLHashInstaller.cpp"
"../cpp/Hash/MGLHashHostObject.cpp"
"../cpp/Cipher/MGLCipherHostObject.cpp"
"../cpp/Cipher/MGLCreateCipherInstaller.cpp"
"../cpp/Cipher/MGLCreateDecipherInstaller.cpp"
"../cpp/MGLKeys.cpp"
"../cpp/Utils/MGLUtils.cpp"
"../cpp/Cipher/MGLRsa.cpp"
"../cpp/Cipher/MGLGenerateKeyPairInstaller.cpp"
"../cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp"
"../cpp/Sig/MGLSignInstaller.cpp"
"../cpp/Sig/MGLVerifyInstaller.cpp"
"../cpp/Sig/MGLSignHostObjects.cpp"
"../cpp/webcrypto/MGLWebCrypto.cpp"
"../cpp/webcrypto/crypto_ec.cpp"
)

set_target_properties(
${PACKAGE_NAME}
PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON
include_directories(
"../node_modules/react-native-quick-base64/cpp"
)

file(GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}")

find_library(
log-lib
log
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"../cpp"
"src/main/cpp"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
)

find_package(openssl REQUIRED CONFIG)
#file(GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}")

target_link_libraries(
${PACKAGE_NAME}
ReactAndroid::turbomodulejsijni
fbjni::fbjni
${log-lib}
ReactAndroid::jsi
ReactAndroid::reactnativejni
ReactAndroid::react_nativemodule_core
android
openssl::crypto
${PACKAGE_NAME}
ReactAndroid::turbomodulejsijni
fbjni::fbjni # <-- fbjni
${LOG_LIB} # <-- Logcat logger
ReactAndroid::jsi # <-- RN: JSI
ReactAndroid::reactnativejni # <-- RN: React Native JNI bindings
ReactAndroid::react_nativemodule_core # <-- RN: React Native native module core
android # <-- Android JNI core
openssl::crypto # <-- OpenSSL (Crypto)
)
Loading
Loading