Skip to content

Commit

Permalink
feat: add pbkdf2 (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
boorad authored Nov 8, 2024
1 parent 7187258 commit c2828e6
Show file tree
Hide file tree
Showing 128 changed files with 4,484 additions and 2,748 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
- '*.podspec'
- 'example/ios/**'

defaults:
run:
working-directory: example

jobs:
build_ios_example:
name: Build iOS Example App
Expand All @@ -40,7 +44,7 @@ jobs:
with:
ruby-version: 3.3
bundler-cache: true
working-directory: example/ios
working-directory: example

- name: Restore Pods cache
uses: actions/cache@v4
Expand All @@ -53,10 +57,6 @@ jobs:
restore-keys: |
${{ runner.os }}-pods-
- name: Install Gems
working-directory: example
run: bundle config set deployment 'true' && bundle install

- name: Install Pods
run: bun pods

Expand All @@ -72,6 +72,6 @@ jobs:
-scheme QuickCryptoExample \
-sdk iphonesimulator \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11 Pro' \
-destination 'platform=iOS Simulator,name=iPhone 16 Pro' \
build \
CODE_SIGNING_ALLOWED=NO | xcpretty"
53 changes: 53 additions & 0 deletions .github/workflows/update-lockfiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Update Lockfiles (bun.lockb + Podfile.lock)'

on:
push:
branches:
- main
paths:
- ".github/workflows/update-lockfiles.yml"
pull_request:
paths:
- ".github/workflows/update-lockfiles.yml"
- "package.json"
- "**/package.json"

permissions:
contents: write

jobs:
update-lockfiles:
name: "Update lockfiles (bun.lockb + Podfile.lock)"
if: github.actor == 'dependabot[bot]'
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.26

- name: Setup Ruby (bundle)
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true
working-directory: example/ios

- run: |
bun install
git add bun.lockb
cd example
bundle install
bun pods
git add ios/Podfile.lock
cd ..
git config --global user.name 'dependabot[bot]'
git config --global user.email 'dependabot[bot]@users.noreply.github.com'
git commit --amend --no-edit
git push --force
18 changes: 13 additions & 5 deletions .github/workflows/validate-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,29 @@ jobs:
name: JS Lint (eslint, prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.1.26

- name: Bootstrap JS
run: |
bun install
bun install --frozen-lockfile
- name: Run ESLint (rnqc)
run: cd packages/react-native-quick-crypto && bun lint-fix
run: |
cd packages/react-native-quick-crypto
bun lint:fix
bun format:fix
- name: Run ESLint (example)
run: cd example && bun lint-fix
run: |
cd example
bun lint:fix
bun format:fix
- name: Verify no files have changed after auto-fix
run: git diff --exit-code HEAD
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ bun example
Make sure your code passes TypeScript and ESLint. Run the following to verify:

```sh
bun tsx
bun tsc
bun lint
bun format
```

To fix formatting errors, run the following:

```sh
bun lint-fix
bun lint:fix
bun format:fix
```

Remember to add tests for your change if possible. Run the unit tests by:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ A fast implementation of Node's `crypto` module.

> Note: This version `1.x` is undergoing a major refactor, porting to New Architecture, Bridgeless, and [`Nitro Modules`](https://github.com/mrousavy/react-native-nitro) and is incomplete compared to the `0.x` version. Status, as always, will be represented in [implementation-coverage.md](../main/docs/implementation-coverage.md).
> Note: Minimum supported version of React Native is `0.75`. If you need to use earlier versions, please use `0.x` versions of this library.
## Features

Unlike any other current JS-based polyfills, react-native-quick-crypto is written in C/C++ JSI and provides much greater performance - especially on mobile devices.
Expand Down
Binary file modified bun.lockb
Binary file not shown.
35 changes: 35 additions & 0 deletions config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"exclude": [
"**/node_modules",
"**/lib",
"**/.eslintrc.js",
"**/.prettierrc.js",
"**/jest.config.js",
"**/babel.config.js",
"**/metro.config.js",
"**/tsconfig.json"
],
"compilerOptions": {
"composite": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ESNext"],
"module": "ESNext",
"moduleResolution": "Node",
"noEmit": false,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitUseStrict": false,
"noStrictGenericChecks": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "esnext",
"verbatimModuleSyntax": true
}
}
4 changes: 2 additions & 2 deletions docs/implementation-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ This document attempts to describe the implementation status of Crypto APIs/Inte
*`crypto.getRandomValues(typedArray)`
*`crypto.hkdf(digest, ikm, salt, info, keylen, callback)`
*`crypto.hkdfSync(digest, ikm, salt, info, keylen)`
* `crypto.pbkdf2(password, salt, iterations, keylen, digest, callback)`
* `crypto.pbkdf2Sync(password, salt, iterations, keylen, digest)`
* `crypto.pbkdf2(password, salt, iterations, keylen, digest, callback)`
* `crypto.pbkdf2Sync(password, salt, iterations, keylen, digest)`
*`crypto.privateDecrypt(privateKey, buffer)`
*`crypto.privateEncrypt(privateKey, buffer)`
*`crypto.publicDecrypt(key, buffer)`
Expand Down
Binary file added docs/test_suite_results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
46 changes: 29 additions & 17 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@ GEM
base64
nkf
rexml
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
claide (1.1.0)
cocoapods (1.14.3)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
Expand All @@ -36,7 +45,7 @@ GEM
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand All @@ -57,6 +66,8 @@ GEM
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
Expand All @@ -65,41 +76,42 @@ GEM
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.2)
minitest (5.24.1)
json (2.8.1)
logger (1.6.1)
minitest (5.25.1)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.3.5)
strscan
rexml (3.3.9)
ruby-macho (2.5.1)
strscan (3.1.0)
securerandom (0.3.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.25.0)
xcodeproj (1.25.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (>= 3.3.2, < 4.0)
rexml (>= 3.3.6, < 4.0)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.5, < 7.1.0)
cocoapods (>= 1.13, < 1.15)
activesupport (>= 6.1.7.5, != 7.1.0)
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 2.7.6p219

BUNDLED WITH
2.1.4
2.5.23
9 changes: 5 additions & 4 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ apply plugin: "com.facebook.react"
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
reactNativeDir = file("../../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
Expand Down Expand Up @@ -49,6 +49,9 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -115,8 +118,6 @@ dependencies {
}
}

apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

project.ext.vectoricons = [
iconFontsDir: "../../../node_modules/react-native-vector-icons/Fonts",
iconFontNames: [ 'MaterialCommunityIcons.ttf' ]
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"

Check warning on line 10 in example/android/app/src/main/AndroidManifest.xml

View workflow job for this annotation

GitHub Actions / Gradle Lint

Missing data extraction rules: The attribute `android:allowBackup` is deprecated from Android 12 and higher and may be removed in future versions. Consider adding the attribute `android:dataExtractionRules` specifying an `@xml` resource which configures cloud backups and device transfers on Android 12 and higher.
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"

Check warning on line 15 in example/android/app/src/main/AndroidManifest.xml

View workflow job for this annotation

GitHub Actions / Gradle Lint

Redundant label on activity: Redundant label can be removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader

class MainApplication : Application(), ReactApplication {
Expand All @@ -34,7 +35,7 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
Expand Down
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.25"
kotlinVersion = "1.9.24"
}
repositories {
google()
Expand Down
Binary file modified example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit c2828e6

Please sign in to comment.