├── .clang-format ├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── android.yml │ ├── ios.yml │ ├── npm.yml │ └── release.yml ├── .gitignore ├── .npmignore ├── .nvmrc ├── .watchmanconfig ├── .yarn ├── plugins │ └── @yarnpkg │ │ ├── plugin-interactive-tools.cjs │ │ └── plugin-workspace-tools.cjs └── releases │ └── yarn-3.6.1.cjs ├── .yarnrc.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── android ├── CMakeLists.txt ├── build.gradle ├── fast-rsa-adapter.cpp ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ ├── AndroidManifestNew.xml │ ├── java │ └── com │ │ └── fastrsa │ │ ├── FastRsaModule.kt │ │ └── FastRsaPackage.kt │ └── jniLibs │ ├── arm64-v8a │ ├── librsa_bridge.h │ └── librsa_bridge.so │ ├── armeabi-v7a │ ├── librsa_bridge.h │ └── librsa_bridge.so │ ├── x86 │ ├── librsa_bridge.h │ └── librsa_bridge.so │ └── x86_64 │ ├── librsa_bridge.h │ └── librsa_bridge.so ├── babel.config.js ├── cpp ├── librsa_bridge.h ├── react-native-fast-rsa.cpp └── react-native-fast-rsa.h ├── docs └── ios-settings.png ├── example ├── .detoxrc.js ├── Gemfile ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── fastrsaexample │ │ │ │ └── DetoxTest.java │ │ │ ├── debug │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── fastrsaexample │ │ │ │ └── ReactNativeFlipper.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── fastrsaexample │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ │ └── xml │ │ │ │ └── network_security_config.xml │ │ │ └── release │ │ │ └── java │ │ │ └── com │ │ │ └── fastrsaexample │ │ │ └── ReactNativeFlipper.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── app.json ├── babel.config.js ├── e2e │ ├── app.test.js │ └── jest.config.js ├── index.js ├── ios │ ├── .gitignore │ ├── .xcode.env │ ├── FastRsaExample-Bridging-Header.h │ ├── FastRsaExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── FastRsaExample.xcscheme │ ├── FastRsaExample.xcworkspace │ │ └── contents.xcworkspacedata │ ├── FastRsaExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── main.m │ ├── FastRsaExampleTests │ │ ├── FastRsaExampleTests.m │ │ └── Info.plist │ ├── File.swift │ ├── Podfile │ └── Podfile.lock ├── jest.config.js ├── metro.config.js ├── package.json ├── react-native.config.js └── src │ ├── App.tsx │ ├── components │ ├── Container.tsx │ ├── SectionContainer.tsx │ ├── SectionResult.tsx │ └── SectionTitle.tsx │ ├── modules │ ├── Base64.tsx │ ├── ConvertJWT.tsx │ ├── ConvertKeyPair.tsx │ ├── ConvertPrivate.tsx │ ├── ConvertPublic.tsx │ ├── EncryptDecryptOAEP.tsx │ ├── EncryptDecryptOAEPBytes.tsx │ ├── EncryptDecryptPKCS.tsx │ ├── Generate.tsx │ ├── HashExample.tsx │ ├── SignVerifyPKCS.tsx │ └── SignVerifyPSS.tsx │ └── utils │ ├── base64.ts │ └── codecs.ts ├── ios ├── FastRsa.h ├── FastRsa.mm └── RSABridge.xcframework │ ├── Info.plist │ ├── ios-arm64 │ └── RSABridge.framework │ │ ├── Headers │ │ └── librsa_bridge.h │ │ ├── Info.plist │ │ ├── Modules │ │ └── module.modulemap │ │ └── RSABridge │ ├── ios-arm64_x86_64-maccatalyst │ └── RSABridge.framework │ │ ├── Headers │ │ └── librsa_bridge.h │ │ ├── Info.plist │ │ ├── Modules │ │ └── module.modulemap │ │ └── RSABridge │ └── ios-arm64_x86_64-simulator │ └── RSABridge.framework │ ├── Headers │ └── librsa_bridge.h │ ├── Info.plist │ ├── Modules │ └── module.modulemap │ └── RSABridge ├── lefthook.yml ├── package.json ├── react-native-fast-rsa.podspec ├── scripts ├── pod-install.cjs ├── upgrade_bridge_flatbuffers.sh └── upgrade_bridge_libs.sh ├── src ├── __tests__ │ └── index.test.tsx ├── bridge.ts ├── index.ts ├── model.ts ├── model │ ├── base64-request.ts │ ├── bool-response.ts │ ├── bytes-response.ts │ ├── convert-jwtrequest.ts │ ├── convert-key-pair-request.ts │ ├── convert-pkcs12-request.ts │ ├── convert-private-key-request.ts │ ├── convert-public-key-request.ts │ ├── decrypt-oaepbytes-request.ts │ ├── decrypt-oaeprequest.ts │ ├── decrypt-pkcs1v15-bytes-request.ts │ ├── decrypt-pkcs1v15-request.ts │ ├── decrypt-private-key-request.ts │ ├── encrypt-oaepbytes-request.ts │ ├── encrypt-oaeprequest.ts │ ├── encrypt-pkcs1v15-bytes-request.ts │ ├── encrypt-pkcs1v15-request.ts │ ├── encrypt-private-key-request.ts │ ├── generate-request.ts │ ├── hash-request.ts │ ├── hash.ts │ ├── key-pair-response.ts │ ├── key-pair.ts │ ├── metadata-private-key-request.ts │ ├── metadata-public-key-request.ts │ ├── pemcipher.ts │ ├── pkcs12-key-pair-response.ts │ ├── pkcs12-key-pair.ts │ ├── private-key-info-response.ts │ ├── private-key-info.ts │ ├── public-key-info-response.ts │ ├── public-key-info.ts │ ├── salt-length.ts │ ├── sign-pkcs1v15-bytes-request.ts │ ├── sign-pkcs1v15-request.ts │ ├── sign-pssbytes-request.ts │ ├── sign-pssrequest.ts │ ├── string-response.ts │ ├── verify-pkcs1v15-bytes-request.ts │ ├── verify-pkcs1v15-request.ts │ ├── verify-pssbytes-request.ts │ └── verify-pssrequest.ts ├── shim.ts ├── types.d.ts └── utils │ ├── big-int.ts │ ├── text-decoder.ts │ └── text-encoder.ts ├── tsconfig.build.json ├── tsconfig.json ├── turbo.json └── yarn.lock /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | ColumnLimit: 0 -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | github: jerson 3 | patreon: jerson 4 | open_collective: # Replace with a single Open Collective username 5 | ko_fi: # Replace with a single Ko-fi username 6 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 7 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 8 | liberapay: # Replace with a single Liberapay username 9 | issuehunt: # Replace with a single IssueHunt username 10 | otechie: # Replace with a single Otechie username 11 | custom: https://paypal.me/gpardogamez 12 | -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | push: 7 | tags: 8 | - 'v*' 9 | 10 | jobs: 11 | e2e: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - id: yarn-cache 16 | uses: actions/cache@v4 17 | with: 18 | path: | 19 | **/node_modules 20 | .yarn/install-state.gz 21 | key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }} 22 | restore-keys: | 23 | ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} 24 | ${{ runner.os }}-yarn- 25 | - uses: actions/setup-java@v4 26 | with: 27 | distribution: 'temurin' 28 | java-version: '17' 29 | - uses: android-actions/setup-android@v3 30 | - uses: nttld/setup-ndk@v1 31 | id: setup-ndk 32 | with: 33 | ndk-version: r21d 34 | - uses: actions/setup-node@v4 35 | with: 36 | node-version-file: .nvmrc 37 | - run: | 38 | npm install -g detox-cli 39 | npm install -g yarn 40 | npm install -g node-gyp 41 | - if: steps.yarn-cache.outputs.cache-hit != 'true' 42 | run: yarn install --immutable 43 | shell: bash 44 | - run: yarn example build:android 45 | env: 46 | ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} 47 | - run: | 48 | rm -rf ~/.gradle 49 | rm -rf /usr/local/lib/android/sdk/ndk/ 50 | - run: yarn example start & 51 | timeout-minutes: 10 52 | - name: Enable KVM 53 | run: | 54 | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules 55 | sudo udevadm control --reload-rules 56 | sudo udevadm trigger --name-match=kvm 57 | - uses: reactivecircus/android-emulator-runner@v2 58 | with: 59 | api-level: 29 60 | avd-name: PhoneAPI30 61 | disable-animations: true 62 | script: yarn example test:android 63 | -------------------------------------------------------------------------------- /.github/workflows/ios.yml: -------------------------------------------------------------------------------- 1 | name: iOS 2 | 3 | on: 4 | workflow_dispatch: 5 | # pull_request: 6 | # push: 7 | # tags: 8 | # - 'v*' 9 | 10 | jobs: 11 | e2e: 12 | runs-on: macos-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - id: yarn-cache 16 | uses: actions/cache@v4 17 | with: 18 | path: | 19 | **/node_modules 20 | .yarn/install-state.gz 21 | key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }} 22 | restore-keys: | 23 | ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} 24 | ${{ runner.os }}-yarn- 25 | - uses: actions/setup-node@v4 26 | with: 27 | node-version-file: .nvmrc 28 | - run: | 29 | npm install -g detox-cli 30 | npm install -g yarn 31 | npm install -g node-gyp 32 | - name: Install Detox 33 | run: | 34 | brew tap wix/brew 35 | brew install applesimutils 36 | - if: steps.yarn-cache.outputs.cache-hit != 'true' 37 | run: yarn install --immutable 38 | shell: bash 39 | - run: yarn example build:ios 40 | - run: yarn example start & 41 | timeout-minutes: 20 42 | - run: yarn example test:ios 43 | -------------------------------------------------------------------------------- /.github/workflows/npm.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - uses: actions/setup-node@v4 14 | with: 15 | node-version: '22' 16 | registry-url: https://registry.npmjs.org/ 17 | - run: yarn install 18 | - run: npm publish --access public 19 | env: 20 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 21 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | tags: 7 | - 'v*' 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-24.04 12 | steps: 13 | - uses: actions/checkout@v4 14 | - uses: softprops/action-gh-release@v2 15 | if: github.ref_type == 'tag' 16 | with: 17 | generate_release_notes: true 18 | prerelease: ${{ contains(github.ref, '-rc') }} 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .classpath 35 | .cxx 36 | .gradle 37 | .idea 38 | .project 39 | .settings 40 | local.properties 41 | android.iml 42 | 43 | # Cocoapods 44 | # 45 | example/ios/Pods 46 | 47 | # Ruby 48 | example/vendor/ 49 | 50 | # node.js 51 | # 52 | node_modules/ 53 | npm-debug.log 54 | yarn-debug.log 55 | yarn-error.log 56 | 57 | # BUCK 58 | buck-out/ 59 | \.buckd/ 60 | android/app/libs 61 | android/keystores/debug.keystore 62 | 63 | # Yarn 64 | .yarn/* 65 | !.yarn/patches 66 | !.yarn/plugins 67 | !.yarn/releases 68 | !.yarn/sdks 69 | !.yarn/versions 70 | 71 | # Expo 72 | .expo/ 73 | 74 | # Turborepo 75 | .turbo/ 76 | 77 | # generated by bob 78 | lib/ 79 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | xcuserdata 2 | .project 3 | .settings 4 | !android/src 5 | .cxx/ 6 | docs/ 7 | src/ 8 | build/ 9 | example/ 10 | *.iml 11 | .idea 12 | .gradle 13 | local.properties 14 | .github 15 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | nmHoistingLimits: workspaces 3 | 4 | plugins: 5 | - path: scripts/pod-install.cjs 6 | - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs 7 | spec: "@yarnpkg/plugin-interactive-tools" 8 | - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs 9 | spec: "@yarnpkg/plugin-workspace-tools" 10 | 11 | yarnPath: .yarn/releases/yarn-3.6.1.cjs 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Gerson Alexander Pardo Gamez 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: test 2 | 3 | test: 4 | yarn test 5 | 6 | upgrade: upgrade-libs upgrade-flatbuffers 7 | 8 | upgrade-libs: 9 | ./scripts/upgrade_bridge_libs.sh 10 | 11 | upgrade-flatbuffers: 12 | ./scripts/upgrade_bridge_flatbuffers.sh 13 | -------------------------------------------------------------------------------- /android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9.0) 2 | 3 | set (CMAKE_VERBOSE_MAKEFILE ON) 4 | set (CMAKE_CXX_STANDARD 14) 5 | set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build) 6 | 7 | add_library(rsa_bridge SHARED IMPORTED) 8 | 9 | 10 | file(TO_CMAKE_PATH ${NODE_MODULES_DIR} NODE_MODULES_DIR) 11 | 12 | 13 | set_target_properties(rsa_bridge 14 | PROPERTIES 15 | IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librsa_bridge.so 16 | ) 17 | 18 | add_library(fast-rsa 19 | SHARED 20 | "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp" 21 | ../cpp/react-native-fast-rsa.cpp 22 | ../cpp/react-native-fast-rsa.h 23 | fast-rsa-adapter.cpp 24 | ) 25 | 26 | include_directories( 27 | fast-rsa 28 | PRIVATE 29 | "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi" 30 | ../cpp 31 | ) 32 | 33 | target_link_libraries(fast-rsa 34 | rsa_bridge 35 | android 36 | log) -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['FastRsa_kotlinVersion'] 3 | 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | classpath "com.android.tools.build:gradle:7.2.1" 11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 12 | } 13 | } 14 | 15 | def isNewArchitectureEnabled() { 16 | return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" 17 | } 18 | 19 | apply plugin: "com.android.library" 20 | apply plugin: 'kotlin-android' 21 | 22 | 23 | def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') } 24 | 25 | if (isNewArchitectureEnabled()) { 26 | apply plugin: "com.facebook.react" 27 | } 28 | 29 | def getExtOrDefault(name) { 30 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["FastRsa_" + name] 31 | } 32 | 33 | def getExtOrIntegerDefault(name) { 34 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["FastRsa_" + name]).toInteger() 35 | } 36 | 37 | def supportsNamespace() { 38 | def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.') 39 | def major = parsed[0].toInteger() 40 | def minor = parsed[1].toInteger() 41 | 42 | // Namespace support was added in 7.3.0 43 | if (major == 7 && minor >= 3) { 44 | return true 45 | } 46 | 47 | return major >= 8 48 | } 49 | 50 | android { 51 | if (supportsNamespace()) { 52 | namespace "com.fastrsa" 53 | 54 | sourceSets { 55 | main { 56 | manifest.srcFile "src/main/AndroidManifestNew.xml" 57 | } 58 | } 59 | } 60 | 61 | ndkVersion getExtOrDefault("ndkVersion") 62 | compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") 63 | 64 | defaultConfig { 65 | minSdkVersion getExtOrIntegerDefault("minSdkVersion") 66 | targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") 67 | 68 | externalNativeBuild { 69 | cmake { 70 | cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all" 71 | abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a" 72 | arguments "-DNODE_MODULES_DIR=${rootDir}/../node_modules" 73 | } 74 | } 75 | } 76 | 77 | externalNativeBuild { 78 | cmake { 79 | path "CMakeLists.txt" 80 | } 81 | } 82 | 83 | buildTypes { 84 | release { 85 | minifyEnabled false 86 | } 87 | } 88 | 89 | lintOptions { 90 | disable "GradleCompatible" 91 | } 92 | 93 | compileOptions { 94 | sourceCompatibility JavaVersion.VERSION_1_8 95 | targetCompatibility JavaVersion.VERSION_1_8 96 | } 97 | 98 | packagingOptions { 99 | pickFirst "**/librsa_bridge.so" 100 | } 101 | } 102 | 103 | repositories { 104 | mavenCentral() 105 | google() 106 | } 107 | 108 | def kotlin_version = getExtOrDefault('kotlinVersion') 109 | 110 | dependencies { 111 | // For < 0.71, this will be from the local maven repo 112 | // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin 113 | //noinspection GradleDynamicVersion 114 | implementation "com.facebook.react:react-native:+" 115 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 116 | } 117 | 118 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | FastRsa_kotlinVersion=1.7.0 2 | FastRsa_minSdkVersion=21 3 | FastRsa_targetSdkVersion=33 4 | FastRsa_compileSdkVersion=33 5 | FastRsa_ndkversion=28.0.13004108 6 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifestNew.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /android/src/main/java/com/fastrsa/FastRsaModule.kt: -------------------------------------------------------------------------------- 1 | package com.fastrsa 2 | 3 | import android.util.Log 4 | import com.facebook.react.bridge.* 5 | 6 | internal class FastRsaModule(reactContext: ReactApplicationContext) : 7 | ReactContextBaseJavaModule(reactContext) { 8 | 9 | val TAG = "[FastRsaModule]" 10 | 11 | external fun initialize(jsContext: Long) 12 | external fun destruct(); 13 | external fun callNative(name: String, payload: ByteArray): ByteArray; 14 | external fun encodeTextNative(input: String, encoding: String): ByteArray 15 | external fun decodeTextNative(input: ByteArray, encoding: String, fatal: Int, ignoreBOM: Int, stream: Int): String 16 | 17 | companion object { 18 | init { 19 | System.loadLibrary("fast-rsa") 20 | } 21 | } 22 | 23 | override fun getName(): String { 24 | return "FastRsa" 25 | } 26 | 27 | @ReactMethod 28 | fun call(name: String, payload: ReadableArray, promise: Promise) { 29 | Thread { 30 | try { 31 | val bytes = ByteArray(payload.size()) { index -> 32 | payload.getInt(index).toByte() 33 | } 34 | val result = callNative(name, bytes) 35 | val resultList = Arguments.createArray().apply { 36 | result.forEach { pushInt(it.toInt()) } 37 | } 38 | 39 | promise.resolve(resultList) 40 | } catch (e: Exception) { 41 | promise.reject("CALL_ERROR", "An error occurred during native call", e) 42 | } 43 | }.start() 44 | } 45 | 46 | @ReactMethod(isBlockingSynchronousMethod = true) 47 | fun encodeText(input: String, encoding: String): WritableArray { 48 | return try { 49 | val result = encodeTextNative(input, encoding) 50 | Arguments.createArray().apply { 51 | result.forEach { byteValue: Byte -> pushInt(byteValue.toInt() and 0xFF) } 52 | } 53 | } catch (e: Exception) { 54 | Log.e(TAG, "Encoding error", e) 55 | throw RuntimeException("ENCODE_ERROR: Failed to encode text") 56 | } 57 | } 58 | 59 | @ReactMethod(isBlockingSynchronousMethod = true) 60 | fun decodeText(input: ReadableArray, encoding: String, fatal: Boolean, ignoreBOM: Boolean, stream: Boolean): String { 61 | return try { 62 | val bytes = ByteArray(input.size()) { index -> 63 | input.getInt(index).toByte() 64 | } 65 | decodeTextNative(bytes, encoding, if (fatal) 1 else 0, if (ignoreBOM) 1 else 0, if (stream) 1 else 0) 66 | } catch (e: Exception) { 67 | Log.e(TAG, "Decoding error", e) 68 | throw RuntimeException("DECODE_ERROR: Failed to decode text") 69 | } 70 | } 71 | 72 | @ReactMethod(isBlockingSynchronousMethod = true) 73 | fun install(): Boolean { 74 | Log.d(TAG, "Attempting to install JSI bindings...") 75 | return try { 76 | val contextHolder = reactApplicationContext.javaScriptContextHolder?.get() 77 | if (contextHolder == null || contextHolder.toInt() == 0) { 78 | Log.w(TAG, "JSI context is not available") 79 | false 80 | } else { 81 | initialize(contextHolder) 82 | Log.i(TAG, "JSI bindings successfully installed") 83 | true 84 | } 85 | } catch (e: Exception) { 86 | Log.e(TAG, "Failed to install JSI bindings", e) 87 | false 88 | } 89 | } 90 | 91 | override fun onCatalystInstanceDestroy() { 92 | destruct(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /android/src/main/java/com/fastrsa/FastRsaPackage.kt: -------------------------------------------------------------------------------- 1 | package com.fastrsa 2 | 3 | import com.facebook.react.ReactPackage 4 | import com.facebook.react.bridge.NativeModule 5 | import com.facebook.react.bridge.ReactApplicationContext 6 | import com.facebook.react.uimanager.ViewManager 7 | 8 | 9 | class FastRsaPackage : ReactPackage { 10 | override fun createNativeModules(reactContext: ReactApplicationContext): List { 11 | return listOf(FastRsaModule(reactContext)) 12 | } 13 | 14 | override fun createViewManagers(reactContext: ReactApplicationContext): List> { 15 | return emptyList() 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/arm64-v8a/librsa_bridge.h: -------------------------------------------------------------------------------- 1 | /* Code generated by cmd/cgo; DO NOT EDIT. */ 2 | 3 | /* package command-line-arguments */ 4 | 5 | 6 | #line 1 "cgo-builtin-export-prolog" 7 | 8 | #include 9 | 10 | #ifndef GO_CGO_EXPORT_PROLOGUE_H 11 | #define GO_CGO_EXPORT_PROLOGUE_H 12 | 13 | #ifndef GO_CGO_GOSTRING_TYPEDEF 14 | typedef struct { const char *p; ptrdiff_t n; } _GoString_; 15 | #endif 16 | 17 | #endif 18 | 19 | /* Start of preamble from import "C" comments. */ 20 | 21 | 22 | #line 3 "main.go" 23 | #include 24 | #include 25 | typedef struct { void* message; int size; char* error; } BytesReturn; 26 | 27 | #line 1 "cgo-generated-wrapper" 28 | 29 | 30 | /* End of preamble from import "C" comments. */ 31 | 32 | 33 | /* Start of boilerplate cgo prologue. */ 34 | #line 1 "cgo-gcc-export-header-prolog" 35 | 36 | #ifndef GO_CGO_PROLOGUE_H 37 | #define GO_CGO_PROLOGUE_H 38 | 39 | typedef signed char GoInt8; 40 | typedef unsigned char GoUint8; 41 | typedef short GoInt16; 42 | typedef unsigned short GoUint16; 43 | typedef int GoInt32; 44 | typedef unsigned int GoUint32; 45 | typedef long long GoInt64; 46 | typedef unsigned long long GoUint64; 47 | typedef GoInt64 GoInt; 48 | typedef GoUint64 GoUint; 49 | typedef size_t GoUintptr; 50 | typedef float GoFloat32; 51 | typedef double GoFloat64; 52 | #ifdef _MSC_VER 53 | #include 54 | typedef _Fcomplex GoComplex64; 55 | typedef _Dcomplex GoComplex128; 56 | #else 57 | typedef float _Complex GoComplex64; 58 | typedef double _Complex GoComplex128; 59 | #endif 60 | 61 | /* 62 | static assertion to make sure the file is being used on architecture 63 | at least with matching size of GoInt. 64 | */ 65 | typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; 66 | 67 | #ifndef GO_CGO_GOSTRING_TYPEDEF 68 | typedef _GoString_ GoString; 69 | #endif 70 | typedef void *GoMap; 71 | typedef void *GoChan; 72 | typedef struct { void *t; void *v; } GoInterface; 73 | typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; 74 | 75 | #endif 76 | 77 | /* End of boilerplate cgo prologue. */ 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | extern BytesReturn* RSABridgeCall(char* name, void* payload, int payloadSize); 84 | extern BytesReturn* RSAEncodeText(char* input, char* encoding); 85 | extern char* RSADecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/arm64-v8a/librsa_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/android/src/main/jniLibs/arm64-v8a/librsa_bridge.so -------------------------------------------------------------------------------- /android/src/main/jniLibs/armeabi-v7a/librsa_bridge.h: -------------------------------------------------------------------------------- 1 | /* Code generated by cmd/cgo; DO NOT EDIT. */ 2 | 3 | /* package command-line-arguments */ 4 | 5 | 6 | #line 1 "cgo-builtin-export-prolog" 7 | 8 | #include 9 | 10 | #ifndef GO_CGO_EXPORT_PROLOGUE_H 11 | #define GO_CGO_EXPORT_PROLOGUE_H 12 | 13 | #ifndef GO_CGO_GOSTRING_TYPEDEF 14 | typedef struct { const char *p; ptrdiff_t n; } _GoString_; 15 | #endif 16 | 17 | #endif 18 | 19 | /* Start of preamble from import "C" comments. */ 20 | 21 | 22 | #line 3 "main.go" 23 | #include 24 | #include 25 | typedef struct { void* message; int size; char* error; } BytesReturn; 26 | 27 | #line 1 "cgo-generated-wrapper" 28 | 29 | 30 | /* End of preamble from import "C" comments. */ 31 | 32 | 33 | /* Start of boilerplate cgo prologue. */ 34 | #line 1 "cgo-gcc-export-header-prolog" 35 | 36 | #ifndef GO_CGO_PROLOGUE_H 37 | #define GO_CGO_PROLOGUE_H 38 | 39 | typedef signed char GoInt8; 40 | typedef unsigned char GoUint8; 41 | typedef short GoInt16; 42 | typedef unsigned short GoUint16; 43 | typedef int GoInt32; 44 | typedef unsigned int GoUint32; 45 | typedef long long GoInt64; 46 | typedef unsigned long long GoUint64; 47 | typedef GoInt32 GoInt; 48 | typedef GoUint32 GoUint; 49 | typedef size_t GoUintptr; 50 | typedef float GoFloat32; 51 | typedef double GoFloat64; 52 | #ifdef _MSC_VER 53 | #include 54 | typedef _Fcomplex GoComplex64; 55 | typedef _Dcomplex GoComplex128; 56 | #else 57 | typedef float _Complex GoComplex64; 58 | typedef double _Complex GoComplex128; 59 | #endif 60 | 61 | /* 62 | static assertion to make sure the file is being used on architecture 63 | at least with matching size of GoInt. 64 | */ 65 | typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1]; 66 | 67 | #ifndef GO_CGO_GOSTRING_TYPEDEF 68 | typedef _GoString_ GoString; 69 | #endif 70 | typedef void *GoMap; 71 | typedef void *GoChan; 72 | typedef struct { void *t; void *v; } GoInterface; 73 | typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; 74 | 75 | #endif 76 | 77 | /* End of boilerplate cgo prologue. */ 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | extern BytesReturn* RSABridgeCall(char* name, void* payload, int payloadSize); 84 | extern BytesReturn* RSAEncodeText(char* input, char* encoding); 85 | extern char* RSADecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/armeabi-v7a/librsa_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/android/src/main/jniLibs/armeabi-v7a/librsa_bridge.so -------------------------------------------------------------------------------- /android/src/main/jniLibs/x86/librsa_bridge.h: -------------------------------------------------------------------------------- 1 | /* Code generated by cmd/cgo; DO NOT EDIT. */ 2 | 3 | /* package command-line-arguments */ 4 | 5 | 6 | #line 1 "cgo-builtin-export-prolog" 7 | 8 | #include 9 | 10 | #ifndef GO_CGO_EXPORT_PROLOGUE_H 11 | #define GO_CGO_EXPORT_PROLOGUE_H 12 | 13 | #ifndef GO_CGO_GOSTRING_TYPEDEF 14 | typedef struct { const char *p; ptrdiff_t n; } _GoString_; 15 | #endif 16 | 17 | #endif 18 | 19 | /* Start of preamble from import "C" comments. */ 20 | 21 | 22 | #line 3 "main.go" 23 | #include 24 | #include 25 | typedef struct { void* message; int size; char* error; } BytesReturn; 26 | 27 | #line 1 "cgo-generated-wrapper" 28 | 29 | 30 | /* End of preamble from import "C" comments. */ 31 | 32 | 33 | /* Start of boilerplate cgo prologue. */ 34 | #line 1 "cgo-gcc-export-header-prolog" 35 | 36 | #ifndef GO_CGO_PROLOGUE_H 37 | #define GO_CGO_PROLOGUE_H 38 | 39 | typedef signed char GoInt8; 40 | typedef unsigned char GoUint8; 41 | typedef short GoInt16; 42 | typedef unsigned short GoUint16; 43 | typedef int GoInt32; 44 | typedef unsigned int GoUint32; 45 | typedef long long GoInt64; 46 | typedef unsigned long long GoUint64; 47 | typedef GoInt32 GoInt; 48 | typedef GoUint32 GoUint; 49 | typedef size_t GoUintptr; 50 | typedef float GoFloat32; 51 | typedef double GoFloat64; 52 | #ifdef _MSC_VER 53 | #include 54 | typedef _Fcomplex GoComplex64; 55 | typedef _Dcomplex GoComplex128; 56 | #else 57 | typedef float _Complex GoComplex64; 58 | typedef double _Complex GoComplex128; 59 | #endif 60 | 61 | /* 62 | static assertion to make sure the file is being used on architecture 63 | at least with matching size of GoInt. 64 | */ 65 | typedef char _check_for_32_bit_pointer_matching_GoInt[sizeof(void*)==32/8 ? 1:-1]; 66 | 67 | #ifndef GO_CGO_GOSTRING_TYPEDEF 68 | typedef _GoString_ GoString; 69 | #endif 70 | typedef void *GoMap; 71 | typedef void *GoChan; 72 | typedef struct { void *t; void *v; } GoInterface; 73 | typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; 74 | 75 | #endif 76 | 77 | /* End of boilerplate cgo prologue. */ 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | extern BytesReturn* RSABridgeCall(char* name, void* payload, int payloadSize); 84 | extern BytesReturn* RSAEncodeText(char* input, char* encoding); 85 | extern char* RSADecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/x86/librsa_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/android/src/main/jniLibs/x86/librsa_bridge.so -------------------------------------------------------------------------------- /android/src/main/jniLibs/x86_64/librsa_bridge.h: -------------------------------------------------------------------------------- 1 | /* Code generated by cmd/cgo; DO NOT EDIT. */ 2 | 3 | /* package command-line-arguments */ 4 | 5 | 6 | #line 1 "cgo-builtin-export-prolog" 7 | 8 | #include 9 | 10 | #ifndef GO_CGO_EXPORT_PROLOGUE_H 11 | #define GO_CGO_EXPORT_PROLOGUE_H 12 | 13 | #ifndef GO_CGO_GOSTRING_TYPEDEF 14 | typedef struct { const char *p; ptrdiff_t n; } _GoString_; 15 | #endif 16 | 17 | #endif 18 | 19 | /* Start of preamble from import "C" comments. */ 20 | 21 | 22 | #line 3 "main.go" 23 | #include 24 | #include 25 | typedef struct { void* message; int size; char* error; } BytesReturn; 26 | 27 | #line 1 "cgo-generated-wrapper" 28 | 29 | 30 | /* End of preamble from import "C" comments. */ 31 | 32 | 33 | /* Start of boilerplate cgo prologue. */ 34 | #line 1 "cgo-gcc-export-header-prolog" 35 | 36 | #ifndef GO_CGO_PROLOGUE_H 37 | #define GO_CGO_PROLOGUE_H 38 | 39 | typedef signed char GoInt8; 40 | typedef unsigned char GoUint8; 41 | typedef short GoInt16; 42 | typedef unsigned short GoUint16; 43 | typedef int GoInt32; 44 | typedef unsigned int GoUint32; 45 | typedef long long GoInt64; 46 | typedef unsigned long long GoUint64; 47 | typedef GoInt64 GoInt; 48 | typedef GoUint64 GoUint; 49 | typedef size_t GoUintptr; 50 | typedef float GoFloat32; 51 | typedef double GoFloat64; 52 | #ifdef _MSC_VER 53 | #include 54 | typedef _Fcomplex GoComplex64; 55 | typedef _Dcomplex GoComplex128; 56 | #else 57 | typedef float _Complex GoComplex64; 58 | typedef double _Complex GoComplex128; 59 | #endif 60 | 61 | /* 62 | static assertion to make sure the file is being used on architecture 63 | at least with matching size of GoInt. 64 | */ 65 | typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; 66 | 67 | #ifndef GO_CGO_GOSTRING_TYPEDEF 68 | typedef _GoString_ GoString; 69 | #endif 70 | typedef void *GoMap; 71 | typedef void *GoChan; 72 | typedef struct { void *t; void *v; } GoInterface; 73 | typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; 74 | 75 | #endif 76 | 77 | /* End of boilerplate cgo prologue. */ 78 | 79 | #ifdef __cplusplus 80 | extern "C" { 81 | #endif 82 | 83 | extern BytesReturn* RSABridgeCall(char* name, void* payload, int payloadSize); 84 | extern BytesReturn* RSAEncodeText(char* input, char* encoding); 85 | extern char* RSADecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/x86_64/librsa_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/android/src/main/jniLibs/x86_64/librsa_bridge.so -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /cpp/librsa_bridge.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | typedef struct { 4 | void* message; 5 | int size; 6 | char* error; 7 | } BytesReturn; 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern BytesReturn* RSABridgeCall(char* p0, void* p1, int p2); 13 | extern BytesReturn* RSAEncodeText(char* input, char* encoding); 14 | extern char* RSADecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream); 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /cpp/react-native-fast-rsa.h: -------------------------------------------------------------------------------- 1 | #ifndef FASTRSA_H 2 | #define FASTRSA_H 3 | #include 4 | #include 5 | 6 | using namespace facebook; 7 | 8 | namespace fastRSA { 9 | void install(facebook::jsi::Runtime &jsiRuntime); 10 | void cleanup(); 11 | } // namespace fastRSA 12 | 13 | #endif /* FASTRSA_H */ 14 | -------------------------------------------------------------------------------- /docs/ios-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/docs/ios-settings.png -------------------------------------------------------------------------------- /example/.detoxrc.js: -------------------------------------------------------------------------------- 1 | /** @type {Detox.DetoxConfig} */ 2 | module.exports = { 3 | testRunner: { 4 | args: { 5 | '$0': 'jest', 6 | config: 'e2e/jest.config.js' 7 | }, 8 | jest: { 9 | setupTimeout: 300000 10 | } 11 | }, 12 | apps: { 13 | 'ios.debug': { 14 | type: 'ios.app', 15 | binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/FastRsaExample.app', 16 | build: 'xcodebuild -workspace ios/FastRsaExample.xcworkspace -scheme FastRsaExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build' 17 | }, 18 | 'ios.release': { 19 | type: 'ios.app', 20 | binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/FastRsaExample.app', 21 | build: 'xcodebuild -workspace ios/FastRsaExample.xcworkspace -scheme FastRsaExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build' 22 | }, 23 | 'android.debug': { 24 | type: 'android.apk', 25 | binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk', 26 | build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug', 27 | reversePorts: [ 28 | 8081 29 | ] 30 | }, 31 | 'android.release': { 32 | type: 'android.apk', 33 | binaryPath: 'android/app/build/outputs/apk/release/app-release.apk', 34 | build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release' 35 | } 36 | }, 37 | devices: { 38 | simulator: { 39 | type: 'ios.simulator', 40 | device: { 41 | type: 'iPhone 16' 42 | } 43 | }, 44 | attached: { 45 | type: 'android.attached', 46 | device: { 47 | adbName: '.*' 48 | } 49 | }, 50 | emulator: { 51 | type: 'android.emulator', 52 | device: { 53 | avdName: 'PhoneAPI30' 54 | } 55 | } 56 | }, 57 | configurations: { 58 | 'ios.sim.debug': { 59 | device: 'simulator', 60 | app: 'ios.debug' 61 | }, 62 | 'ios.sim.release': { 63 | device: 'simulator', 64 | app: 'ios.release' 65 | }, 66 | 'android.att.debug': { 67 | device: 'attached', 68 | app: 'android.debug' 69 | }, 70 | 'android.att.release': { 71 | device: 'attached', 72 | app: 'android.release' 73 | }, 74 | 'android.emu.debug': { 75 | device: 'emulator', 76 | app: 'android.debug' 77 | }, 78 | 'android.emu.release': { 79 | device: 'emulator', 80 | app: 'android.release' 81 | } 82 | } 83 | }; 84 | -------------------------------------------------------------------------------- /example/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version 4 | ruby ">= 2.6.10" 5 | 6 | gem 'cocoapods', '~> 1.13' 7 | gem 'activesupport', '>= 6.1.7.3', '< 7.1.0' 8 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli). 2 | 3 | # Getting Started 4 | 5 | >**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. 6 | 7 | ## Step 1: Start the Metro Server 8 | 9 | First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. 10 | 11 | To start Metro, run the following command from the _root_ of your React Native project: 12 | 13 | ```bash 14 | # using npm 15 | npm start 16 | 17 | # OR using Yarn 18 | yarn start 19 | ``` 20 | 21 | ## Step 2: Start your Application 22 | 23 | Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: 24 | 25 | ### For Android 26 | 27 | ```bash 28 | # using npm 29 | npm run android 30 | 31 | # OR using Yarn 32 | yarn android 33 | ``` 34 | 35 | ### For iOS 36 | 37 | ```bash 38 | # using npm 39 | npm run ios 40 | 41 | # OR using Yarn 42 | yarn ios 43 | ``` 44 | 45 | If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. 46 | 47 | This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. 48 | 49 | ## Step 3: Modifying your App 50 | 51 | Now that you have successfully run the app, let's modify it. 52 | 53 | 1. Open `App.tsx` in your text editor of choice and edit some lines. 54 | 2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes! 55 | 56 | For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes! 57 | 58 | ## Congratulations! :tada: 59 | 60 | You've successfully run and modified your React Native App. :partying_face: 61 | 62 | ### Now what? 63 | 64 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). 65 | - If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). 66 | 67 | # Troubleshooting 68 | 69 | If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. 70 | 71 | # Learn More 72 | 73 | To learn more about React Native, take a look at the following resources: 74 | 75 | - [React Native Website](https://reactnative.dev) - learn more about React Native. 76 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. 77 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. 78 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. 79 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. 80 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /example/android/app/src/androidTest/java/com/fastrsaexample/DetoxTest.java: -------------------------------------------------------------------------------- 1 | package com.fastrsaexample; 2 | 3 | import com.wix.detox.Detox; 4 | import com.wix.detox.config.DetoxConfig; 5 | 6 | import org.junit.Rule; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import androidx.test.ext.junit.runners.AndroidJUnit4; 11 | import androidx.test.filters.LargeTest; 12 | import androidx.test.rule.ActivityTestRule; 13 | 14 | @RunWith(AndroidJUnit4.class) 15 | @LargeTest 16 | public class DetoxTest { 17 | // Replace 'MainActivity' with the value of android:name entry in 18 | // in AndroidManifest.xml 19 | @Rule 20 | public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false); 21 | 22 | @Test 23 | public void runDetoxTests() { 24 | DetoxConfig detoxConfig = new DetoxConfig(); 25 | detoxConfig.idlePolicyConfig.masterTimeoutSec = 90; 26 | detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60; 27 | detoxConfig.rnContextLoadTimeoutSec = (com.fastrsaexample.BuildConfig.DEBUG ? 360 : 180); 28 | 29 | Detox.runTests(mActivityRule, detoxConfig); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/fastrsaexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.fastrsaexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | import com.facebook.react.ReactActivityDelegate; 5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 6 | import com.facebook.react.defaults.DefaultReactActivityDelegate; 7 | 8 | public class MainActivity extends ReactActivity { 9 | 10 | /** 11 | * Returns the name of the main component registered from JavaScript. This is used to schedule 12 | * rendering of the component. 13 | */ 14 | @Override 15 | protected String getMainComponentName() { 16 | return "FastRsaExample"; 17 | } 18 | 19 | /** 20 | * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link 21 | * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React 22 | * (aka React 18) with two boolean flags. 23 | */ 24 | @Override 25 | protected ReactActivityDelegate createReactActivityDelegate() { 26 | return new DefaultReactActivityDelegate( 27 | this, 28 | getMainComponentName(), 29 | // If you opted-in for the New Architecture, we enable the Fabric Renderer. 30 | DefaultNewArchitectureEntryPoint.getFabricEnabled()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/fastrsaexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.fastrsaexample; 2 | 3 | import android.app.Application; 4 | import com.facebook.react.PackageList; 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; 9 | import com.facebook.react.defaults.DefaultReactNativeHost; 10 | import com.facebook.soloader.SoLoader; 11 | import java.util.List; 12 | 13 | public class MainApplication extends Application implements ReactApplication { 14 | 15 | private final ReactNativeHost mReactNativeHost = 16 | new DefaultReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | @SuppressWarnings("UnnecessaryLocalVariable") 25 | List packages = new PackageList(this).getPackages(); 26 | // Packages that cannot be autolinked yet can be added manually here, for example: 27 | // packages.add(new MyReactNativePackage()); 28 | return packages; 29 | } 30 | 31 | @Override 32 | protected String getJSMainModuleName() { 33 | return "index"; 34 | } 35 | 36 | @Override 37 | protected boolean isNewArchEnabled() { 38 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 39 | } 40 | 41 | @Override 42 | protected Boolean isHermesEnabled() { 43 | return BuildConfig.IS_HERMES_ENABLED; 44 | } 45 | }; 46 | 47 | @Override 48 | public ReactNativeHost getReactNativeHost() { 49 | return mReactNativeHost; 50 | } 51 | 52 | @Override 53 | public void onCreate() { 54 | super.onCreate(); 55 | SoLoader.init(this, /* native exopackage */ false); 56 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { 57 | // If you opted-in for the New Architecture, we load the native entry point for this app. 58 | DefaultNewArchitectureEntryPoint.load(); 59 | } 60 | ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FastRsaExample 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10.0.2.2 5 | localhost 6 | 7 | -------------------------------------------------------------------------------- /example/android/app/src/release/java/com/fastrsaexample/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.fastrsaexample; 8 | 9 | import android.content.Context; 10 | import com.facebook.react.ReactInstanceManager; 11 | 12 | /** 13 | * Class responsible of loading Flipper inside your React Native application. This is the release 14 | * flavor of it so it's empty as we don't want to load Flipper. 15 | */ 16 | public class ReactNativeFlipper { 17 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 18 | // Do nothing as we don't want to initialize Flipper on Release. 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "33.0.0" 6 | minSdkVersion = 21 7 | compileSdkVersion = 33 8 | targetSdkVersion = 33 9 | kotlinVersion = '1.7.0' 10 | 11 | 12 | // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. 13 | ndkVersion = "23.1.7779620" 14 | } 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | dependencies { 20 | classpath("com.android.tools.build:gradle") 21 | classpath("com.facebook.react:react-native-gradle-plugin") 22 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") 23 | } 24 | } 25 | 26 | allprojects { 27 | repositories { 28 | google() 29 | maven { 30 | url("$rootDir/../node_modules/detox/Detox-android") 31 | } 32 | maven { url 'https://www.jitpack.io' } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.182.0 29 | 30 | # Use this property to specify which architecture you want to build. 31 | # You can also override it from the CLI using 32 | # ./gradlew -PreactNativeArchitectures=x86_64 33 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 34 | 35 | # Use this property to enable support to the new architecture. 36 | # This will allow you to use TurboModules and the Fabric render in 37 | # your application. You should enable this flag either if you want 38 | # to write custom TurboModules/Fabric components OR use libraries that 39 | # are providing them. 40 | newArchEnabled=false 41 | 42 | # Use this property to enable or disable the Hermes JS engine. 43 | # If set to false, you will be using JSC instead. 44 | hermesEnabled=true 45 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-rsa/0813c4938362fbbf15c3c7a8448ce8f8f8eb65ac/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Mar 16 21:42:37 PET 2025 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip 5 | networkTimeout=10000 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | 9 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'FastRsaExample' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | includeBuild('../node_modules/@react-native/gradle-plugin') 5 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FastRsaExample", 3 | "displayName": "FastRsaExample" 4 | } 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | extensions: ['.tsx', '.ts', '.js', '.json'], 11 | alias: { 12 | [pak.name]: path.join(__dirname, '..', pak.source), 13 | }, 14 | }, 15 | ], 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /example/e2e/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('@jest/types').Config.InitialOptions} */ 2 | module.exports = { 3 | rootDir: '..', 4 | testMatch: ['/e2e/**/*.test.js'], 5 | testTimeout: 120000, 6 | maxWorkers: 1, 7 | globalSetup: 'detox/runners/jest/globalSetup', 8 | globalTeardown: 'detox/runners/jest/globalTeardown', 9 | reporters: ['detox/runners/jest/reporter'], 10 | testEnvironment: 'detox/runners/jest/testEnvironment', 11 | verbose: true, 12 | }; 13 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | import App from './src/App'; 3 | import { name as appName } from './app.json'; 4 | 5 | AppRegistry.registerComponent(appName, () => App); 6 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | Pods/ 2 | -------------------------------------------------------------------------------- /example/ios/.xcode.env: -------------------------------------------------------------------------------- 1 | # This `.xcode.env` file is versioned and is used to source the environment 2 | # used when running script phases inside Xcode. 3 | # To customize your local environment, you can create an `.xcode.env.local` 4 | # file that is not versioned. 5 | 6 | # NODE_BINARY variable contains the PATH to the node executable. 7 | # 8 | # Customize the NODE_BINARY variable here. 9 | # For example, to use nvm with brew, add the following line 10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use 11 | export NODE_BINARY=$(command -v node) 12 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : RCTAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample/AppDelegate.mm: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | 5 | @implementation AppDelegate 6 | 7 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 8 | { 9 | self.moduleName = @"FastRsaExample"; 10 | // You can add your custom initial props in the dictionary below. 11 | // They will be passed down to the ViewController used by React Native. 12 | self.initialProps = @{}; 13 | 14 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 15 | } 16 | 17 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 18 | { 19 | #if DEBUG 20 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"]; 21 | #else 22 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 23 | #endif 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "scale" : "1x", 46 | "size" : "1024x1024" 47 | } 48 | ], 49 | "info" : { 50 | "author" : "xcode", 51 | "version" : 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | FastRsaExample 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(CURRENT_PROJECT_VERSION) 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /example/ios/FastRsaExample/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | @autoreleasepool { 8 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /example/ios/FastRsaExampleTests/FastRsaExampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface FastRsaExampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation FastRsaExampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL (^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction( 38 | ^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 39 | if (level >= RCTLogLevelError) { 40 | redboxError = message; 41 | } 42 | }); 43 | #endif 44 | 45 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 46 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 48 | 49 | foundElement = [self findSubviewInView:vc.view 50 | matching:^BOOL(UIView *view) { 51 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 52 | return YES; 53 | } 54 | return NO; 55 | }]; 56 | } 57 | 58 | #ifdef DEBUG 59 | RCTSetLogFunction(RCTDefaultLogFunction); 60 | #endif 61 | 62 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 63 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /example/ios/FastRsaExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // FastRsaExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Resolve react_native_pods.rb with node to allow for hoisting 2 | require Pod::Executable.execute_command('node', ['-p', 3 | 'require.resolve( 4 | "react-native/scripts/react_native_pods.rb", 5 | {paths: [process.argv[1]]}, 6 | )', __dir__]).strip 7 | 8 | platform :ios, min_ios_version_supported 9 | prepare_react_native_project! 10 | 11 | # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. 12 | # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded 13 | # 14 | # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` 15 | # ```js 16 | # module.exports = { 17 | # dependencies: { 18 | # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), 19 | # ``` 20 | flipper_config = FlipperConfiguration.disabled 21 | 22 | linkage = ENV['USE_FRAMEWORKS'] 23 | if linkage != nil 24 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green 25 | use_frameworks! :linkage => linkage.to_sym 26 | end 27 | 28 | target 'FastRsaExample' do 29 | config = use_native_modules! 30 | 31 | # Flags change depending on the env values. 32 | flags = get_default_flags() 33 | 34 | use_react_native!( 35 | :path => config[:reactNativePath], 36 | # Hermes is now enabled by default. Disable by setting this flag to false. 37 | :hermes_enabled => flags[:hermes_enabled], 38 | :fabric_enabled => flags[:fabric_enabled], 39 | # Enables Flipper. 40 | # 41 | # Note that if you have use_frameworks! enabled, Flipper will not work and 42 | # you should disable the next line. 43 | :flipper_configuration => flipper_config, 44 | # An absolute path to your application root. 45 | :app_path => "#{Pod::Config.instance.installation_root}/.." 46 | ) 47 | 48 | target 'FastRsaExampleTests' do 49 | inherit! :complete 50 | # Pods for testing 51 | end 52 | 53 | post_install do |installer| 54 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 55 | react_native_post_install( 56 | installer, 57 | config[:reactNativePath], 58 | :mac_catalyst_enabled => false 59 | ) 60 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | }; 4 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); 2 | const path = require('path'); 3 | const escape = require('escape-string-regexp'); 4 | const exclusionList = require('metro-config/src/defaults/exclusionList'); 5 | const pak = require('../package.json'); 6 | 7 | const root = path.resolve(__dirname, '..'); 8 | const modules = Object.keys({ ...pak.peerDependencies }); 9 | 10 | /** 11 | * Metro configuration 12 | * https://facebook.github.io/metro/docs/configuration 13 | * 14 | * @type {import('metro-config').MetroConfig} 15 | */ 16 | const config = { 17 | watchFolders: [root], 18 | 19 | // We need to make sure that only one version is loaded for peerDependencies 20 | // So we block them at the root, and alias them to the versions in example's node_modules 21 | resolver: { 22 | blacklistRE: exclusionList( 23 | modules.map( 24 | (m) => 25 | new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`) 26 | ) 27 | ), 28 | 29 | extraNodeModules: modules.reduce((acc, name) => { 30 | acc[name] = path.join(__dirname, 'node_modules', name); 31 | return acc; 32 | }, {}), 33 | }, 34 | 35 | transformer: { 36 | getTransformOptions: async () => ({ 37 | transform: { 38 | experimentalImportSupport: false, 39 | inlineRequires: true, 40 | }, 41 | }), 42 | }, 43 | }; 44 | 45 | module.exports = mergeConfig(getDefaultConfig(__dirname), config); 46 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-fast-rsa-example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test:android": "detox test --configuration android.att.debug", 10 | "build:android": "detox build --configuration android.att.debug", 11 | "test:ios": "detox test --configuration ios.sim.debug", 12 | "build:ios": "detox build --configuration ios.sim.debug", 13 | "build:android:debug": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a", 14 | "build:ios:debug": "cd ios && xcodebuild -workspace FastRsaExample.xcworkspace -scheme FastRsaExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO" 15 | }, 16 | "dependencies": { 17 | "react": "18.2.0", 18 | "react-native": "0.72.6" 19 | }, 20 | "devDependencies": { 21 | "@babel/core": "^7.20.0", 22 | "@babel/preset-env": "^7.20.0", 23 | "@babel/runtime": "^7.20.0", 24 | "@react-native/metro-config": "^0.72.11", 25 | "babel-plugin-module-resolver": "^5.0.0", 26 | "detox": "^20.13.1", 27 | "jest": "^29", 28 | "metro-react-native-babel-preset": "0.76.8", 29 | "pod-install": "^0.1.0" 30 | }, 31 | "engines": { 32 | "node": ">=16" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/react-native.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | dependencies: { 6 | [pak.name]: { 7 | root: path.join(__dirname, '..'), 8 | }, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /example/src/components/Container.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {StyleSheet, View} from "react-native"; 3 | 4 | interface Props { 5 | children: React.ReactNode[] | React.ReactNode 6 | testID: string 7 | } 8 | 9 | export default function ({testID,children}: Props) { 10 | return {children}; 11 | } 12 | 13 | const styles = StyleSheet.create({ 14 | container: { 15 | backgroundColor: '#f1f0f0', 16 | borderRadius: 10, 17 | padding: 5, 18 | margin: 5, 19 | marginBottom:10, 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /example/src/components/SectionContainer.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {StyleSheet, View} from "react-native"; 3 | 4 | interface Props { 5 | children: React.ReactNode[] 6 | testID: string 7 | } 8 | 9 | export default function ({testID,children}: Props) { 10 | return {children}; 11 | } 12 | 13 | const styles = StyleSheet.create({ 14 | sectionContainer: { 15 | backgroundColor: '#f9f9f9', 16 | borderRadius: 10, 17 | padding: 10, 18 | paddingHorizontal: 20, 19 | margin: 10, 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /example/src/components/SectionResult.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {Colors} from "react-native/Libraries/NewAppScreen"; 4 | import {StyleSheet, Text} from "react-native"; 5 | 6 | interface Props { 7 | children: React.ReactNode 8 | testID: string 9 | } 10 | 11 | export default function ({children, testID}: Props) { 12 | return {children}; 13 | } 14 | const styles = StyleSheet.create({ 15 | sectionDescription: { 16 | marginTop: 8, 17 | fontSize: 14, 18 | fontWeight: '400', 19 | color: Colors.dark, 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /example/src/components/SectionTitle.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import {Colors} from "react-native/Libraries/NewAppScreen"; 4 | import {StyleSheet, Text} from "react-native"; 5 | 6 | interface Props { 7 | children: String 8 | } 9 | 10 | export default function ({children}: Props) { 11 | return {children}; 12 | } 13 | const styles = StyleSheet.create({ 14 | sectionTitle: { 15 | fontSize: 24, 16 | fontWeight: '600', 17 | color: Colors.black, 18 | }, 19 | }); 20 | -------------------------------------------------------------------------------- /example/src/modules/Base64.tsx: -------------------------------------------------------------------------------- 1 | import {Colors} from "react-native/Libraries/NewAppScreen"; 2 | import {Button, TextInput} from "react-native"; 3 | import React, {useState} from "react"; 4 | import RSA from 'react-native-fast-rsa'; 5 | import SectionContainer from "../components/SectionContainer"; 6 | import SectionTitle from "../components/SectionTitle"; 7 | import SectionResult from "../components/SectionResult"; 8 | import Container from "../components/Container"; 9 | 10 | interface Props { 11 | publicKey: string, 12 | privateKey: string, 13 | passphrase: string 14 | } 15 | 16 | export default function ({}: Props) { 17 | 18 | const [input, setInput] = useState(''); 19 | const [result, setResult] = useState(''); 20 | 21 | return 22 | 23 | Base64 24 | { 28 | setInput(text); 29 | }} 30 | style={{backgroundColor: Colors.white, borderRadius: 4}} 31 | placeholder={"insert message here"} 32 | /> 33 |