├── .nvmrc ├── .watchmanconfig ├── example ├── ios │ ├── .gitignore │ ├── File.swift │ ├── FastOpenpgpExample │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── AppDelegate.mm │ │ └── Info.plist │ ├── FastOpenpgpExample-Bridging-Header.h │ ├── FastOpenpgpExample.xcworkspace │ │ └── contents.xcworkspacedata │ ├── .xcode.env │ ├── FastOpenpgpExampleTests │ │ ├── Info.plist │ │ └── FastOpenpgpExampleTests.m │ └── Podfile ├── jest.config.js ├── .bundle │ └── config ├── app.json ├── android │ ├── app │ │ ├── debug.keystore │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.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 │ │ │ │ │ ├── xml │ │ │ │ │ │ └── network_security_config.xml │ │ │ │ │ └── drawable │ │ │ │ │ │ └── rn_edit_text_material.xml │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── fastopenpgpexample │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ ├── release │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── fastopenpgpexample │ │ │ │ │ └── ReactNativeFlipper.java │ │ │ └── androidTest │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── fastopenpgpexample │ │ │ │ └── DetoxTest.java │ │ └── proguard-rules.pro │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ └── gradlew.bat ├── index.js ├── Gemfile ├── react-native.config.js ├── babel.config.js ├── e2e │ └── jest.config.js ├── src │ ├── utils │ │ └── codecs.ts │ ├── components │ │ ├── SectionTitle.tsx │ │ ├── Container.tsx │ │ ├── SectionContainer.tsx │ │ └── SectionResult.tsx │ └── modules │ │ ├── Shared.tsx │ │ ├── Convert.tsx │ │ ├── Generate.tsx │ │ ├── Metadata.tsx │ │ ├── EncryptDecrypt.tsx │ │ ├── EncryptDecryptSymmetric.tsx │ │ ├── SignVerify.tsx │ │ └── SignVerifyFile.tsx ├── metro.config.js ├── package.json ├── .detoxrc.js └── README.md ├── .clang-format ├── src ├── __tests__ │ └── index.test.tsx ├── bridge.ts ├── model │ ├── compression.ts │ ├── hash.ts │ ├── cipher.ts │ ├── algorithm.ts │ ├── curve.ts │ ├── generate-request.ts │ ├── armor-decode-request.ts │ ├── get-public-key-metadata-request.ts │ ├── get-private-key-metadata-request.ts │ ├── convert-private-key-to-public-key-request.ts │ ├── key-pair.ts │ ├── key-pair-response.ts │ ├── string-response.ts │ ├── int-response.ts │ ├── bool-response.ts │ ├── armor-decode-response.ts │ ├── verify-data-request.ts │ ├── decrypt-symmetric-request.ts │ ├── public-key-metadata-response.ts │ ├── private-key-metadata-response.ts │ ├── sign-request.ts │ ├── verify-request.ts │ ├── sign-file-request.ts │ ├── sign-data-request.ts │ ├── verify-file-request.ts │ ├── encrypt-symmetric-request.ts │ ├── armor-metadata.ts │ ├── entity.ts │ ├── decrypt-symmetric-file-request.ts │ ├── bytes-response.ts │ ├── armor-encode-request.ts │ ├── identity.ts │ ├── options.ts │ ├── encrypt-request.ts │ └── verify-data-bytes-request.ts ├── shim.ts ├── utils │ ├── big-int.ts │ ├── text-encoder.ts │ └── text-decoder.ts ├── types.d.ts └── model.ts ├── .gitattributes ├── tsconfig.build.json ├── babel.config.js ├── docs └── ios-settings.png ├── android ├── src │ └── main │ │ ├── AndroidManifestNew.xml │ │ ├── AndroidManifest.xml │ │ ├── jniLibs │ │ ├── x86 │ │ │ ├── libopenpgp_bridge.so │ │ │ └── libopenpgp_bridge.h │ │ ├── x86_64 │ │ │ ├── libopenpgp_bridge.so │ │ │ └── libopenpgp_bridge.h │ │ ├── arm64-v8a │ │ │ ├── libopenpgp_bridge.so │ │ │ └── libopenpgp_bridge.h │ │ └── armeabi-v7a │ │ │ ├── libopenpgp_bridge.so │ │ │ └── libopenpgp_bridge.h │ │ └── java │ │ └── com │ │ └── fastopenpgp │ │ ├── FastOpenpgpPackage.kt │ │ └── FastOpenpgpModule.kt ├── gradle.properties ├── CMakeLists.txt └── build.gradle ├── ios ├── OpenPGPBridge.xcframework │ ├── ios-arm64 │ │ └── OpenPGPBridge.framework │ │ │ ├── Modules │ │ │ └── module.modulemap │ │ │ ├── OpenPGPBridge │ │ │ ├── Info.plist │ │ │ └── Headers │ │ │ └── libopenpgp_bridge.h │ ├── ios-arm64_x86_64-maccatalyst │ │ └── OpenPGPBridge.framework │ │ │ ├── Modules │ │ │ └── module.modulemap │ │ │ ├── OpenPGPBridge │ │ │ ├── Info.plist │ │ │ └── Headers │ │ │ └── libopenpgp_bridge.h │ ├── ios-arm64_x86_64-simulator │ │ └── OpenPGPBridge.framework │ │ │ ├── Modules │ │ │ └── module.modulemap │ │ │ ├── OpenPGPBridge │ │ │ ├── Info.plist │ │ │ └── Headers │ │ │ └── libopenpgp_bridge.h │ └── Info.plist └── FastOpenpgp.h ├── .npmignore ├── Makefile ├── cpp ├── react-native-fast-openpgp.h └── libopenpgp_bridge.h ├── .editorconfig ├── .yarnrc.yml ├── lefthook.yml ├── .github ├── workflows │ ├── npm.yml │ ├── release.yml │ ├── ios.yml │ └── android.yml └── FUNDING.yml ├── tsconfig.json ├── turbo.json ├── scripts ├── pod-install.cjs ├── upgrade_bridge_flatbuffers.sh └── upgrade_bridge_libs.sh ├── .gitignore ├── LICENSE └── react-native-fast-openpgp.podspec /.nvmrc: -------------------------------------------------------------------------------- 1 | v18 2 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | Pods/ 2 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | ColumnLimit: 0 -------------------------------------------------------------------------------- /src/__tests__/index.test.tsx: -------------------------------------------------------------------------------- 1 | it.todo('write a test'); 2 | -------------------------------------------------------------------------------- /example/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'react-native', 3 | }; 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /example/.bundle/config: -------------------------------------------------------------------------------- 1 | BUNDLE_PATH: "vendor/bundle" 2 | BUNDLE_FORCE_RUBY_PLATFORM: 1 3 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FastOpenpgpExample", 3 | "displayName": "FastOpenpgpExample" 4 | } 5 | -------------------------------------------------------------------------------- /docs/ios-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/docs/ios-settings.png -------------------------------------------------------------------------------- /example/ios/File.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // FastOpenpgpExample 4 | // 5 | 6 | import Foundation 7 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifestNew.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/bridge.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | export * as model from './model'; 4 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FastOpenpgpExample 3 | 4 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample-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 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/x86/libopenpgp_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/android/src/main/jniLibs/x86/libopenpgp_bridge.so -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : RCTAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /android/src/main/jniLibs/x86_64/libopenpgp_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/android/src/main/jniLibs/x86_64/libopenpgp_bridge.so -------------------------------------------------------------------------------- /android/src/main/jniLibs/arm64-v8a/libopenpgp_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/android/src/main/jniLibs/arm64-v8a/libopenpgp_bridge.so -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64/OpenPGPBridge.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module "OpenPGPBridge" { 2 | header "libopenpgp_bridge.h" 3 | export * 4 | } -------------------------------------------------------------------------------- /android/src/main/jniLibs/armeabi-v7a/libopenpgp_bridge.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/android/src/main/jniLibs/armeabi-v7a/libopenpgp_bridge.so -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-maccatalyst/OpenPGPBridge.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module "OpenPGPBridge" { 2 | header "libopenpgp_bridge.h" 3 | export * 4 | } -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-simulator/OpenPGPBridge.framework/Modules/module.modulemap: -------------------------------------------------------------------------------- 1 | framework module "OpenPGPBridge" { 2 | header "libopenpgp_bridge.h" 3 | export * 4 | } -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | FastOpenpgp_kotlinVersion=1.7.0 2 | FastOpenpgp_minSdkVersion=21 3 | FastOpenpgp_targetSdkVersion=33 4 | FastOpenpgp_compileSdkVersion=33 5 | FastOpenpgp_ndkversion=28.1.13356709 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64/OpenPGPBridge.framework/OpenPGPBridge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/ios/OpenPGPBridge.xcframework/ios-arm64/OpenPGPBridge.framework/OpenPGPBridge -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-simulator/OpenPGPBridge.framework/OpenPGPBridge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-simulator/OpenPGPBridge.framework/OpenPGPBridge -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-maccatalyst/OpenPGPBridge.framework/OpenPGPBridge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jerson/react-native-fast-openpgp/HEAD/ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-maccatalyst/OpenPGPBridge.framework/OpenPGPBridge -------------------------------------------------------------------------------- /ios/FastOpenpgp.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | #import "react-native-fast-openpgp.h" 3 | #endif 4 | 5 | #import 6 | 7 | @interface FastOpenpgp : NSObject 8 | @property (nonatomic, assign) BOOL setBridgeOnMainQueue; 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample/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/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'FastOpenpgpExample' 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 | -------------------------------------------------------------------------------- /src/model/compression.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ 4 | 5 | export enum Compression { 6 | NONE = 0, 7 | ZLIB = 1, 8 | ZIP = 2 9 | } 10 | -------------------------------------------------------------------------------- /src/model/hash.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ 4 | 5 | export enum Hash { 6 | SHA256 = 0, 7 | SHA224 = 1, 8 | SHA384 = 2, 9 | SHA512 = 3 10 | } 11 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /cpp/react-native-fast-openpgp.h: -------------------------------------------------------------------------------- 1 | #ifndef FASTOPENPGP_H 2 | #define FASTOPENPGP_H 3 | 4 | #include 5 | #include 6 | 7 | using namespace facebook; 8 | 9 | namespace fastOpenPGP { 10 | void install(facebook::jsi::Runtime &jsiRuntime); 11 | void cleanup(); 12 | } // namespace fastOpenPGP 13 | 14 | #endif /* FASTOPENPGP_H */ 15 | -------------------------------------------------------------------------------- /src/model/cipher.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ 4 | 5 | export enum Cipher { 6 | AES128 = 0, 7 | AES192 = 1, 8 | AES256 = 2, 9 | DES = 3, 10 | CAST5 = 4 11 | } 12 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/model/algorithm.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ 4 | 5 | export enum Algorithm { 6 | RSA = 0, 7 | ECDSA = 1, 8 | EDDSA = 2, 9 | ECHD = 3, 10 | DSA = 4, 11 | ELGAMAL = 5 12 | } 13 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /lefthook.yml: -------------------------------------------------------------------------------- 1 | pre-commit: 2 | parallel: true 3 | commands: 4 | lint: 5 | files: git diff --name-only @{push} 6 | glob: "*.{js,ts,jsx,tsx}" 7 | run: npx eslint {files} 8 | types: 9 | files: git diff --name-only @{push} 10 | glob: "*.{js,ts, jsx, tsx}" 11 | run: npx tsc --noEmit 12 | commit-msg: 13 | parallel: true 14 | commands: 15 | commitlint: 16 | run: npx commitlint --edit 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/model/curve.ts: -------------------------------------------------------------------------------- 1 | // automatically generated by the FlatBuffers compiler, do not modify 2 | 3 | /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ 4 | 5 | export enum Curve { 6 | CURVE25519 = 0, 7 | CURVE448 = 1, 8 | P256 = 2, 9 | P384 = 3, 10 | P521 = 4, 11 | SECP256K1 = 5, 12 | BRAINPOOLP256 = 6, 13 | BRAINPOOLP384 = 7, 14 | BRAINPOOLP512 = 8 15 | } 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/shim.ts: -------------------------------------------------------------------------------- 1 | if (typeof global.BigInt === 'undefined') { 2 | const BigInt = require('./utils/big-int').default; 3 | global.BigInt = BigInt; 4 | } 5 | 6 | if (typeof global.TextDecoder === 'undefined') { 7 | const TextDecoder = require('./utils/text-decoder').default; 8 | global.TextDecoder = TextDecoder; 9 | } 10 | 11 | if (typeof global.TextEncoder === 'undefined') { 12 | const TextEncoder = require('./utils/text-encoder').default; 13 | global.TextEncoder = TextEncoder; 14 | } 15 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cpp/libopenpgp_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* OpenPGPBridgeCall(char* p0, void* p1, int p2); 13 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding); 14 | extern char* OpenPGPDecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream); 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /.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 }} -------------------------------------------------------------------------------- /example/src/utils/codecs.ts: -------------------------------------------------------------------------------- 1 | import base64 from "./base64"; 2 | 3 | export function base64Encode(uint8Array:Uint8Array) { 4 | let binary = ''; 5 | uint8Array.forEach(byte => { 6 | binary += String.fromCharCode(byte); 7 | }); 8 | return base64.encode(binary); 9 | } 10 | 11 | export function stringToUint8Array(str:string) { 12 | return new global.TextEncoder().encode(str); 13 | } 14 | 15 | export function uint8ArrayToString(str:Uint8Array) { 16 | return new global.TextDecoder().decode(str); 17 | } 18 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/src/main/java/com/fastopenpgp/FastOpenpgpPackage.kt: -------------------------------------------------------------------------------- 1 | package com.fastopenpgp 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 FastOpenpgpPackage : ReactPackage { 10 | override fun createNativeModules(reactContext: ReactApplicationContext): List { 11 | return listOf(FastOpenpgpModule(reactContext)) 12 | } 13 | 14 | override fun createViewManagers(reactContext: ReactApplicationContext): List> { 15 | return emptyList() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64/OpenPGPBridge.framework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | OpenPGPBridge 7 | CFBundleIdentifier 8 | OpenPGPBridge 9 | MinimumOSVersion 10 | 100.0 11 | CFBundleShortVersionString 12 | 1.13.0 13 | CFBundleVersion 14 | 1.13.0.1745445221 15 | CFBundlePackageType 16 | FMWK 17 | 18 | 19 | -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-maccatalyst/OpenPGPBridge.framework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | OpenPGPBridge 7 | CFBundleIdentifier 8 | OpenPGPBridge 9 | MinimumOSVersion 10 | 100.0 11 | CFBundleShortVersionString 12 | 1.13.0 13 | CFBundleVersion 14 | 1.13.0.1745445221 15 | CFBundlePackageType 16 | FMWK 17 | 18 | 19 | -------------------------------------------------------------------------------- /ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-simulator/OpenPGPBridge.framework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | OpenPGPBridge 7 | CFBundleIdentifier 8 | OpenPGPBridge 9 | MinimumOSVersion 10 | 100.0 11 | CFBundleShortVersionString 12 | 1.13.0 13 | CFBundleVersion 14 | 1.13.0.1745445221 15 | CFBundlePackageType 16 | FMWK 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/utils/big-int.ts: -------------------------------------------------------------------------------- 1 | const BigInt = require('big-integer'); 2 | BigInt.asUintN = function (bits: any, bigint: any) { 3 | bigint = BigInt(bigint); 4 | if (typeof bigint.value === 'bigint') { 5 | return BigInt(BigInt.asUintN(bits, bigint.value)); 6 | } 7 | const p2bits = BigInt(1).shiftLeft(bits); 8 | const mod = bigint.and(p2bits.subtract(1)); 9 | return mod; 10 | }; 11 | BigInt.asIntN = function (bits: any, bigint: any) { 12 | bigint = BigInt(bigint); 13 | if (typeof bigint.value === 'bigint') { 14 | return BigInt(BigInt.asIntN(bits, bigint.value)); 15 | } 16 | const p2bits = BigInt(1).shiftLeft(bits); 17 | const mod = bigint.and(p2bits.subtract(1)); 18 | return mod.greaterOrEquals(p2bits.subtract(mod)) ? mod.subtract(p2bits) : mod; 19 | }; 20 | 21 | export default BigInt; 22 | -------------------------------------------------------------------------------- /example/src/modules/Shared.tsx: -------------------------------------------------------------------------------- 1 | import RNFS from 'react-native-fs' 2 | 3 | async function deleteFile(name:string){ 4 | const path = RNFS.DocumentDirectoryPath + '/'+ name; 5 | try { 6 | const exists = await RNFS.exists(path) 7 | if(exists){ 8 | await RNFS.unlink(path) 9 | } 10 | } catch (e:any) { 11 | console.warn('DeleteFile',e.message) 12 | } 13 | return path 14 | } 15 | async function createFile(name:string,content:string){ 16 | const path = RNFS.DocumentDirectoryPath + '/'+ name; 17 | 18 | await deleteFile(name) 19 | try { 20 | await RNFS.writeFile(path, content, 'utf8') 21 | } catch (e:any) { 22 | console.warn('CreateFile',e.message) 23 | } 24 | return path 25 | } 26 | export { 27 | deleteFile, 28 | createFile 29 | } 30 | -------------------------------------------------------------------------------- /example/android/app/src/release/java/com/fastopenpgpexample/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.fastopenpgpexample; 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 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "rootDir": ".", 4 | "paths": { 5 | "react-native-fast-openpgp": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "jsx": "react", 12 | "lib": ["esnext"], 13 | "module": "esnext", 14 | "moduleResolution": "node", 15 | "noFallthroughCasesInSwitch": true, 16 | "noImplicitReturns": true, 17 | "noImplicitUseStrict": false, 18 | "noStrictGenericChecks": false, 19 | "noUncheckedIndexedAccess": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext", 26 | "verbatimModuleSyntax": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "pipeline": { 4 | "build:android": { 5 | "inputs": [ 6 | "package.json", 7 | "android", 8 | "!android/build", 9 | "src/*.ts", 10 | "src/*.tsx", 11 | "example/package.json", 12 | "example/android", 13 | "!example/android/.gradle", 14 | "!example/android/build", 15 | "!example/android/app/build" 16 | ], 17 | "outputs": [] 18 | }, 19 | "build:ios": { 20 | "inputs": [ 21 | "package.json", 22 | "*.podspec", 23 | "ios", 24 | "src/*.ts", 25 | "src/*.tsx", 26 | "example/package.json", 27 | "example/ios", 28 | "!example/ios/build", 29 | "!example/ios/Pods" 30 | ], 31 | "outputs": [] 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExampleTests/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 | -------------------------------------------------------------------------------- /src/utils/text-encoder.ts: -------------------------------------------------------------------------------- 1 | import { NativeModules } from 'react-native'; 2 | 3 | const FastOpenPGPNativeModules = (NativeModules as NativeModulesDef) 4 | .FastOpenpgp; 5 | const isDebuggingEnabled = 6 | typeof atob !== 'undefined' && typeof HermesInternal === 'undefined'; 7 | 8 | typeof global.FastOpenPGPEncodeText === 'undefined' && 9 | !isDebuggingEnabled && 10 | FastOpenPGPNativeModules.install(); 11 | 12 | export default class TextEncoder { 13 | get encoding(): string { 14 | return 'utf-8'; 15 | } 16 | 17 | encode(input: string = ''): Uint8Array { 18 | if (typeof global.FastOpenPGPEncodeText === 'function') { 19 | const result = global.FastOpenPGPEncodeText(input, 'utf-8'); 20 | return new Uint8Array(result); 21 | } 22 | const result = FastOpenPGPNativeModules.encodeText(input, 'utf-8'); 23 | return new Uint8Array(result); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample/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 = @"FastOpenpgpExample"; 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 | -------------------------------------------------------------------------------- /android/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9.0) 2 | 3 | set (CMAKE_VERBOSE_MAKEFILE ON) 4 | set (CMAKE_CXX_STANDARD 17) 5 | set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build) 6 | 7 | add_library(openpgp_bridge SHARED IMPORTED) 8 | 9 | 10 | file(TO_CMAKE_PATH ${NODE_MODULES_DIR} NODE_MODULES_DIR) 11 | 12 | 13 | set_target_properties(openpgp_bridge 14 | PROPERTIES 15 | IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libopenpgp_bridge.so 16 | ) 17 | 18 | add_library(fast-openpgp 19 | SHARED 20 | "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp" 21 | ../cpp/react-native-fast-openpgp.cpp 22 | ../cpp/react-native-fast-openpgp.h 23 | fast-openpgp-adapter.cpp 24 | ) 25 | 26 | include_directories( 27 | fast-openpgp 28 | PRIVATE 29 | "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi" 30 | ../cpp 31 | ) 32 | 33 | target_link_libraries(fast-openpgp 34 | openpgp_bridge 35 | android 36 | log) 37 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /scripts/pod-install.cjs: -------------------------------------------------------------------------------- 1 | const child_process = require('child_process'); 2 | 3 | module.exports = { 4 | name: 'pod-install', 5 | factory() { 6 | return { 7 | hooks: { 8 | afterAllInstalled(project, options) { 9 | if (process.env.POD_INSTALL === '0') { 10 | return; 11 | } 12 | 13 | if ( 14 | options && 15 | (options.mode === 'update-lockfile' || 16 | options.mode === 'skip-build') 17 | ) { 18 | return; 19 | } 20 | 21 | const result = child_process.spawnSync( 22 | 'yarn', 23 | ['pod-install', 'example/ios'], 24 | { 25 | cwd: project.cwd, 26 | env: process.env, 27 | stdio: 'inherit', 28 | encoding: 'utf-8', 29 | shell: true, 30 | } 31 | ); 32 | 33 | if (result.status !== 0) { 34 | throw new Error('Failed to run pod-install'); 35 | } 36 | }, 37 | }, 38 | }; 39 | }, 40 | }; 41 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/ios/FastOpenpgpExample/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/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/android/app/src/androidTest/java/com/fastopenpgpexample/DetoxTest.java: -------------------------------------------------------------------------------- 1 | package com.fastopenpgpexample; 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.fastopenpgpexample.BuildConfig.DEBUG ? 360 : 180); 28 | 29 | Detox.runTests(mActivityRule, detoxConfig); 30 | } 31 | } -------------------------------------------------------------------------------- /example/src/modules/Convert.tsx: -------------------------------------------------------------------------------- 1 | import {Button} from "react-native"; 2 | import React, {useState} from "react"; 3 | import OpenPGP from 'react-native-fast-openpgp'; 4 | import SectionContainer from "../components/SectionContainer"; 5 | import SectionTitle from "../components/SectionTitle"; 6 | import SectionResult from "../components/SectionResult"; 7 | import Container from "../components/Container"; 8 | 9 | interface Props { 10 | privateKey: string 11 | } 12 | 13 | export default function ({privateKey}: Props) { 14 | 15 | const [output, setOutput] = useState(''); 16 | 17 | return 18 | 19 | Convert 20 |