> {
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 |
30 |
31 | ;
32 | }
33 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/fastopenpgpexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.fastopenpgpexample;
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 "FastOpenpgpExample";
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 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/utils/text-decoder.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.FastOpenPGPDecodeText === 'undefined' &&
9 | !isDebuggingEnabled &&
10 | FastOpenPGPNativeModules.install();
11 |
12 | interface TextDecoderOptions {
13 | fatal?: boolean;
14 | ignoreBOM?: boolean;
15 | }
16 |
17 | interface TextDecodeOptions {
18 | stream?: boolean;
19 | }
20 |
21 | export default class TextDecoder {
22 | private encoding: string;
23 | private fatal: boolean;
24 | private ignoreBOM: boolean;
25 |
26 | constructor(label: string = 'utf-8', options: TextDecoderOptions = {}) {
27 | this.encoding = label.toLowerCase();
28 | this.fatal = options.fatal ?? false;
29 | this.ignoreBOM = options.ignoreBOM ?? false;
30 | }
31 |
32 | decode(input?: Uint8Array, options: TextDecodeOptions = {}): string {
33 | if (!input) {
34 | return '';
35 | }
36 |
37 | if (typeof global.FastOpenPGPDecodeText === 'function') {
38 | const ress = global.FastOpenPGPDecodeText(
39 | input,
40 | this.encoding,
41 | this.fatal,
42 | this.ignoreBOM,
43 | options.stream ?? false
44 | );
45 | return ress;
46 | }
47 | return FastOpenPGPNativeModules.decodeText(
48 | Array.from(input),
49 | this.encoding,
50 | this.fatal,
51 | this.ignoreBOM,
52 | options.stream ?? false
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-fast-openpgp-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": "jest",
10 | "test:android": "detox test --configuration android.att.debug",
11 | "build:android": "detox build --configuration android.att.debug",
12 | "test:ios": "detox test --configuration ios.sim.debug",
13 | "build:ios": "detox build --configuration ios.sim.debug",
14 | "build:android:debug": "cd android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
15 | "build:ios:debug": "cd ios && xcodebuild -workspace FastOpenpgpExample.xcworkspace -scheme FastOpenpgpExample -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"
16 | },
17 | "dependencies": {
18 | "react": "18.2.0",
19 | "react-native": "0.72.6",
20 | "react-native-fs": "^2.20.0"
21 | },
22 | "devDependencies": {
23 | "@babel/core": "^7.20.0",
24 | "@babel/preset-env": "^7.20.0",
25 | "@babel/runtime": "^7.20.0",
26 | "@react-native/metro-config": "^0.72.11",
27 | "babel-plugin-module-resolver": "^5.0.0",
28 | "detox": "^20.13.1",
29 | "jest": "^29",
30 | "metro-react-native-babel-preset": "0.76.8",
31 | "pod-install": "^0.1.0"
32 | },
33 | "engines": {
34 | "node": ">=16"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/scripts/upgrade_bridge_flatbuffers.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #######################################################
3 | # Usage: #
4 | # ./upgrade_bridge_flatbuffers.sh #
5 | # #
6 | # or custom version: #
7 | # VERSION=v0.1.1 ./upgrade_bridge_flatbuffers.sh #
8 | #######################################################
9 |
10 | REPO="jerson/openpgp-mobile"
11 | NAME="flatbuffers_libopenpgp_bridge_ts"
12 | OUTPUT_DIR="src"
13 |
14 | #######################################################
15 | # you shouldn't edit below this line #
16 | #######################################################
17 |
18 | echo "Get latest release"
19 | RELEASE_PAYLOAD=$(curl --silent "https://api.github.com/repos/$REPO/releases/latest")
20 |
21 | get_version() {
22 | echo "$RELEASE_PAYLOAD" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
23 | }
24 |
25 | LATEST_VERSION=$(get_version $REPO)
26 | VERSION=${VERSION:-$LATEST_VERSION}
27 | TMP_DIR=$(dirname $(mktemp -u))
28 |
29 | echo "Using: $VERSION"
30 | echo "--------------------------------------------"
31 |
32 | FILE_NAME="${NAME}_${VERSION}.tar.gz"
33 | TMP_FILE="$TMP_DIR/$FILE_NAME"
34 | FILE_URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILE_NAME}"
35 |
36 | echo "Downloading: $FILE_URL to $TMP_FILE"
37 | curl -L -o $TMP_FILE "$FILE_URL"
38 |
39 | echo "Extracting: $TMP_FILE to $OUTPUT_DIR"
40 | mkdir -p $OUTPUT_DIR
41 | tar -xz --strip-components=1 --directory=$OUTPUT_DIR --file=$TMP_FILE
42 |
43 | echo "All updated"
44 |
45 |
--------------------------------------------------------------------------------
/example/src/modules/Generate.tsx:
--------------------------------------------------------------------------------
1 | import {Button} from "react-native";
2 | import React, {useState} from "react";
3 | import OpenPGP, { Algorithm, Curve } 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 | publicKey: string,
11 | privateKey: string,
12 | passphrase: string
13 | }
14 |
15 | export default function ({}: Props) {
16 |
17 | const [keyPair, setKeyPair] = useState({publicKey: '', privateKey: ''});
18 |
19 | return
20 |
21 | Generate
22 |
23 |
42 |
43 | ;
44 | }
45 |
--------------------------------------------------------------------------------
/example/ios/FastOpenpgpExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | FastOpenpgpExample
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/src/modules/Metadata.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 | publicKey: string;
11 | privateKey: string;
12 | }
13 |
14 | export default function ({ publicKey, privateKey }: Props) {
15 | const [metadataPrivateKey, setMetadataPrivateKey] = useState('');
16 | const [metadataPublicKey, setMetadataPublicKey] = useState('');
17 |
18 | return (
19 |
20 |
21 | Metadata PrivateKey
22 |
32 |
33 | Metadata PrivateKey
34 |
44 |
45 | );
46 | }
47 |
--------------------------------------------------------------------------------
/ios/OpenPGPBridge.xcframework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AvailableLibraries
6 |
7 |
8 | BinaryPath
9 | OpenPGPBridge.framework/OpenPGPBridge
10 | LibraryIdentifier
11 | ios-arm64_x86_64-maccatalyst
12 | LibraryPath
13 | OpenPGPBridge.framework
14 | SupportedArchitectures
15 |
16 | arm64
17 | x86_64
18 |
19 | SupportedPlatform
20 | ios
21 | SupportedPlatformVariant
22 | maccatalyst
23 |
24 |
25 | BinaryPath
26 | OpenPGPBridge.framework/OpenPGPBridge
27 | LibraryIdentifier
28 | ios-arm64_x86_64-simulator
29 | LibraryPath
30 | OpenPGPBridge.framework
31 | SupportedArchitectures
32 |
33 | arm64
34 | x86_64
35 |
36 | SupportedPlatform
37 | ios
38 | SupportedPlatformVariant
39 | simulator
40 |
41 |
42 | BinaryPath
43 | OpenPGPBridge.framework/OpenPGPBridge
44 | LibraryIdentifier
45 | ios-arm64
46 | LibraryPath
47 | OpenPGPBridge.framework
48 | SupportedArchitectures
49 |
50 | arm64
51 |
52 | SupportedPlatform
53 | ios
54 |
55 |
56 | CFBundlePackageType
57 | XFWK
58 | XCFrameworkFormatVersion
59 | 1.0
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/types.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Contains all method available inside of `NativeModules`
3 | */
4 | interface FastOpenPGPNativeModules {
5 | /**
6 | * this method use `NativeModules` in a more traditional way
7 | * using `JNI` on android in order to call shared a library.
8 | */
9 | call(name: string, payload: number[]): Promise;
10 |
11 | encodeText(input: string, encoding: string): number[];
12 | decodeText(
13 | input: number[],
14 | encoding: string,
15 | fatal: boolean,
16 | ignoreBOM: boolean,
17 | stream: boolean
18 | ): string;
19 | /**
20 | * this method will install JSI definitions
21 | */
22 | install(): boolean;
23 | }
24 |
25 | interface NativeModulesDef {
26 | FastOpenpgp: FastOpenPGPNativeModules;
27 | }
28 |
29 | interface Global {
30 | BigInt: any;
31 | TextEncoder: any;
32 | TextDecoder: any;
33 | // for now we are not going to use this way because of hermes on release mode only
34 | // FastOpenPGP:FastOpenPGPJSI
35 | /**
36 | * this method use `JSI`, but will return a `Promise` in order to use an async way,
37 | * at this moment is no real Async but in the future will be.
38 | * TODO: implement real promise here
39 | */
40 | FastOpenPGPCallPromise(
41 | name: string,
42 | payload: ArrayBuffer | SharedArrayBuffer
43 | ): Promise;
44 | /**
45 | * this method use `JSI`, and will use in a Sync way,
46 | * be careful if the method that you are using is a complex one like generate a new Key
47 | */
48 | FastOpenPGPCallSync(
49 | name: string,
50 | payload: ArrayBuffer | SharedArrayBuffer
51 | ): ArrayBuffer;
52 |
53 | FastOpenPGPEncodeText(input: string, encoding: string): Uint8Array;
54 | FastOpenPGPDecodeText(
55 | input: Uint8Array,
56 | encoding: string,
57 | fatal: boolean,
58 | ignoreBOM: boolean,
59 | stream: boolean
60 | ): string;
61 | }
62 |
63 | declare const global: Global;
64 | declare const module: any;
65 | declare const atob: any;
66 |
--------------------------------------------------------------------------------
/react-native-fast-openpgp.podspec:
--------------------------------------------------------------------------------
1 | require "json"
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4 | folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5 |
6 | Pod::Spec.new do |s|
7 | s.name = package["name"]
8 | s.version = package["version"]
9 | s.summary = package["description"]
10 | s.homepage = package["homepage"]
11 | s.license = package["license"]
12 | s.authors = package["author"]
13 |
14 | s.platforms = { :ios => "11.0" }
15 | s.source = { :git => "https://github.com/jerson/react-native-fast-openpgp.git", :tag => "#{s.version}" }
16 |
17 | s.source_files = "ios/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
18 | s.vendored_framework = 'ios/OpenPGPBridge.xcframework'
19 | s.static_framework = true
20 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
21 |
22 | # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23 | # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
24 | if respond_to?(:install_modules_dependencies, true)
25 | install_modules_dependencies(s)
26 | else
27 | s.dependency "React-Core"
28 |
29 | # Don't install the dependencies when we run `pod install` in the old architecture.
30 | if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
31 | s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
32 | s.pod_target_xcconfig = {
33 | "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
34 | "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
35 | "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
36 | }
37 | s.dependency "React-Codegen"
38 | s.dependency "RCT-Folly"
39 | s.dependency "RCTRequired"
40 | s.dependency "RCTTypeSafety"
41 | s.dependency "ReactCommon/turbomodule/core"
42 | end
43 | end
44 | end
45 |
46 |
--------------------------------------------------------------------------------
/src/model/generate-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { Options } from '../model/options';
8 |
9 |
10 | export class GenerateRequest {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):GenerateRequest {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsGenerateRequest(bb:flatbuffers.ByteBuffer, obj?:GenerateRequest):GenerateRequest {
20 | return (obj || new GenerateRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsGenerateRequest(bb:flatbuffers.ByteBuffer, obj?:GenerateRequest):GenerateRequest {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new GenerateRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | options(obj?:Options):Options|null {
29 | const offset = this.bb!.__offset(this.bb_pos, 4);
30 | return offset ? (obj || new Options()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
31 | }
32 |
33 | static startGenerateRequest(builder:flatbuffers.Builder) {
34 | builder.startObject(1);
35 | }
36 |
37 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
38 | builder.addFieldOffset(0, optionsOffset, 0);
39 | }
40 |
41 | static endGenerateRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
42 | const offset = builder.endObject();
43 | return offset;
44 | }
45 |
46 | static createGenerateRequest(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset):flatbuffers.Offset {
47 | GenerateRequest.startGenerateRequest(builder);
48 | GenerateRequest.addOptions(builder, optionsOffset);
49 | return GenerateRequest.endGenerateRequest(builder);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/src/model/armor-decode-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class ArmorDecodeRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):ArmorDecodeRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsArmorDecodeRequest(bb:flatbuffers.ByteBuffer, obj?:ArmorDecodeRequest):ArmorDecodeRequest {
17 | return (obj || new ArmorDecodeRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsArmorDecodeRequest(bb:flatbuffers.ByteBuffer, obj?:ArmorDecodeRequest):ArmorDecodeRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new ArmorDecodeRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | message():string|null
26 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | message(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | static startArmorDecodeRequest(builder:flatbuffers.Builder) {
33 | builder.startObject(1);
34 | }
35 |
36 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
37 | builder.addFieldOffset(0, messageOffset, 0);
38 | }
39 |
40 | static endArmorDecodeRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
41 | const offset = builder.endObject();
42 | return offset;
43 | }
44 |
45 | static createArmorDecodeRequest(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset {
46 | ArmorDecodeRequest.startArmorDecodeRequest(builder);
47 | ArmorDecodeRequest.addMessage(builder, messageOffset);
48 | return ArmorDecodeRequest.endArmorDecodeRequest(builder);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/scripts/upgrade_bridge_libs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | #######################################################
3 | # Usage: #
4 | # ./upgrade_bridge_libs.sh #
5 | # #
6 | # or custom version: #
7 | # VERSION=v0.1.1 ./upgrade_bridge_libs.sh #
8 | #######################################################
9 |
10 | REPO="jerson/openpgp-mobile"
11 | NAME="libopenpgp_bridge"
12 | PLATFORMS=("android" "ios_xcframework" )
13 | OUTPUT_DIRS=("android/src/main" "ios")
14 | OUTPUT_SUB_DIRS=("" "")
15 | OUTPUT_STRIP_DIRS=(1 1)
16 |
17 | #######################################################
18 | # you shouldn't edit below this line #
19 | #######################################################
20 |
21 | echo "Get latest release"
22 | RELEASE_PAYLOAD=$(curl --silent "https://api.github.com/repos/$REPO/releases/latest")
23 |
24 | get_version() {
25 | echo "$RELEASE_PAYLOAD" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
26 | }
27 |
28 | LATEST_VERSION=$(get_version $REPO)
29 | VERSION=${VERSION:-$LATEST_VERSION}
30 |
31 | echo "Using: $VERSION"
32 | echo "--------------------------------------------"
33 |
34 | INDEX=0
35 | TMP_DIR=$(dirname $(mktemp -u))
36 | for PLATFORM in "${PLATFORMS[@]}"
37 | do
38 | :
39 |
40 | OUTPUT_DIR=${OUTPUT_DIRS[$INDEX]}
41 | OUTPUT_SUB_DIR=${OUTPUT_SUB_DIRS[$INDEX]}
42 | OUTPUT_STRIP_DIR=${OUTPUT_STRIP_DIRS[$INDEX]}
43 |
44 | FILE_NAME="${NAME}_${PLATFORM}_${VERSION}.tar.gz"
45 | TMP_FILE="$TMP_DIR/$FILE_NAME"
46 | FILE_URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILE_NAME}"
47 |
48 | echo "Platform: $PLATFORM"
49 | echo "Downloading: $FILE_URL to $TMP_FILE"
50 | curl -L -o $TMP_FILE "$FILE_URL"
51 |
52 | echo "Extracting: $TMP_FILE to $OUTPUT_DIR"
53 | mkdir -p $OUTPUT_DIR
54 | tar -xz --strip-components=$OUTPUT_STRIP_DIR --directory=$OUTPUT_DIR --file=$TMP_FILE $OUTPUT_SUB_DIR
55 |
56 | INDEX=${INDEX}+1
57 |
58 | echo "Updated"
59 | echo "--------------------------------------------"
60 | done
61 | #
62 | echo "All updated"
63 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/fastopenpgpexample/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.fastopenpgpexample;
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 |
--------------------------------------------------------------------------------
/src/model/get-public-key-metadata-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class GetPublicKeyMetadataRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):GetPublicKeyMetadataRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsGetPublicKeyMetadataRequest(bb:flatbuffers.ByteBuffer, obj?:GetPublicKeyMetadataRequest):GetPublicKeyMetadataRequest {
17 | return (obj || new GetPublicKeyMetadataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsGetPublicKeyMetadataRequest(bb:flatbuffers.ByteBuffer, obj?:GetPublicKeyMetadataRequest):GetPublicKeyMetadataRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new GetPublicKeyMetadataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | publicKey():string|null
26 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | static startGetPublicKeyMetadataRequest(builder:flatbuffers.Builder) {
33 | builder.startObject(1);
34 | }
35 |
36 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
37 | builder.addFieldOffset(0, publicKeyOffset, 0);
38 | }
39 |
40 | static endGetPublicKeyMetadataRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
41 | const offset = builder.endObject();
42 | return offset;
43 | }
44 |
45 | static createGetPublicKeyMetadataRequest(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
46 | GetPublicKeyMetadataRequest.startGetPublicKeyMetadataRequest(builder);
47 | GetPublicKeyMetadataRequest.addPublicKey(builder, publicKeyOffset);
48 | return GetPublicKeyMetadataRequest.endGetPublicKeyMetadataRequest(builder);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/model/get-private-key-metadata-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class GetPrivateKeyMetadataRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):GetPrivateKeyMetadataRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsGetPrivateKeyMetadataRequest(bb:flatbuffers.ByteBuffer, obj?:GetPrivateKeyMetadataRequest):GetPrivateKeyMetadataRequest {
17 | return (obj || new GetPrivateKeyMetadataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsGetPrivateKeyMetadataRequest(bb:flatbuffers.ByteBuffer, obj?:GetPrivateKeyMetadataRequest):GetPrivateKeyMetadataRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new GetPrivateKeyMetadataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | privateKey():string|null
26 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | static startGetPrivateKeyMetadataRequest(builder:flatbuffers.Builder) {
33 | builder.startObject(1);
34 | }
35 |
36 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
37 | builder.addFieldOffset(0, privateKeyOffset, 0);
38 | }
39 |
40 | static endGetPrivateKeyMetadataRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
41 | const offset = builder.endObject();
42 | return offset;
43 | }
44 |
45 | static createGetPrivateKeyMetadataRequest(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
46 | GetPrivateKeyMetadataRequest.startGetPrivateKeyMetadataRequest(builder);
47 | GetPrivateKeyMetadataRequest.addPrivateKey(builder, privateKeyOffset);
48 | return GetPrivateKeyMetadataRequest.endGetPrivateKeyMetadataRequest(builder);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/example/ios/FastOpenpgpExampleTests/FastOpenpgpExampleTests.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 FastOpenpgpExampleTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation FastOpenpgpExampleTests
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/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 'FastOpenpgpExample' 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 'FastOpenpgpExampleTests' 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 |
--------------------------------------------------------------------------------
/src/model/convert-private-key-to-public-key-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class ConvertPrivateKeyToPublicKeyRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):ConvertPrivateKeyToPublicKeyRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsConvertPrivateKeyToPublicKeyRequest(bb:flatbuffers.ByteBuffer, obj?:ConvertPrivateKeyToPublicKeyRequest):ConvertPrivateKeyToPublicKeyRequest {
17 | return (obj || new ConvertPrivateKeyToPublicKeyRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsConvertPrivateKeyToPublicKeyRequest(bb:flatbuffers.ByteBuffer, obj?:ConvertPrivateKeyToPublicKeyRequest):ConvertPrivateKeyToPublicKeyRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new ConvertPrivateKeyToPublicKeyRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | privateKey():string|null
26 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | static startConvertPrivateKeyToPublicKeyRequest(builder:flatbuffers.Builder) {
33 | builder.startObject(1);
34 | }
35 |
36 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
37 | builder.addFieldOffset(0, privateKeyOffset, 0);
38 | }
39 |
40 | static endConvertPrivateKeyToPublicKeyRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
41 | const offset = builder.endObject();
42 | return offset;
43 | }
44 |
45 | static createConvertPrivateKeyToPublicKeyRequest(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
46 | ConvertPrivateKeyToPublicKeyRequest.startConvertPrivateKeyToPublicKeyRequest(builder);
47 | ConvertPrivateKeyToPublicKeyRequest.addPrivateKey(builder, privateKeyOffset);
48 | return ConvertPrivateKeyToPublicKeyRequest.endConvertPrivateKeyToPublicKeyRequest(builder);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/android/src/main/jniLibs/x86/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(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/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(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/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(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/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/src/model/key-pair.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class KeyPair {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):KeyPair {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsKeyPair(bb:flatbuffers.ByteBuffer, obj?:KeyPair):KeyPair {
17 | return (obj || new KeyPair()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsKeyPair(bb:flatbuffers.ByteBuffer, obj?:KeyPair):KeyPair {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new KeyPair()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | publicKey():string|null
26 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | privateKey():string|null
33 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
34 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
35 | const offset = this.bb!.__offset(this.bb_pos, 6);
36 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
37 | }
38 |
39 | static startKeyPair(builder:flatbuffers.Builder) {
40 | builder.startObject(2);
41 | }
42 |
43 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
44 | builder.addFieldOffset(0, publicKeyOffset, 0);
45 | }
46 |
47 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
48 | builder.addFieldOffset(1, privateKeyOffset, 0);
49 | }
50 |
51 | static endKeyPair(builder:flatbuffers.Builder):flatbuffers.Offset {
52 | const offset = builder.endObject();
53 | return offset;
54 | }
55 |
56 | static createKeyPair(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset, privateKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
57 | KeyPair.startKeyPair(builder);
58 | KeyPair.addPublicKey(builder, publicKeyOffset);
59 | KeyPair.addPrivateKey(builder, privateKeyOffset);
60 | return KeyPair.endKeyPair(builder);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ios/OpenPGPBridge.xcframework/ios-arm64/OpenPGPBridge.framework/Headers/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-simulator/OpenPGPBridge.framework/Headers/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/ios/OpenPGPBridge.xcframework/ios-arm64_x86_64-maccatalyst/OpenPGPBridge.framework/Headers/libopenpgp_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* OpenPGPBridgeCall(char* name, void* payload, int payloadSize);
84 | extern BytesReturn* OpenPGPEncodeText(char* input, char* encoding);
85 | extern char* OpenPGPDecodeText(void* input, int size, char* encoding, int fatal, int ignoreBOM, int stream);
86 |
87 | #ifdef __cplusplus
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/src/model/key-pair-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyPair } from '../model/key-pair';
8 |
9 |
10 | export class KeyPairResponse {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):KeyPairResponse {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsKeyPairResponse(bb:flatbuffers.ByteBuffer, obj?:KeyPairResponse):KeyPairResponse {
20 | return (obj || new KeyPairResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsKeyPairResponse(bb:flatbuffers.ByteBuffer, obj?:KeyPairResponse):KeyPairResponse {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new KeyPairResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | output(obj?:KeyPair):KeyPair|null {
29 | const offset = this.bb!.__offset(this.bb_pos, 4);
30 | return offset ? (obj || new KeyPair()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
31 | }
32 |
33 | error():string|null
34 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
35 | error(optionalEncoding?:any):string|Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 6);
37 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
38 | }
39 |
40 | static startKeyPairResponse(builder:flatbuffers.Builder) {
41 | builder.startObject(2);
42 | }
43 |
44 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
45 | builder.addFieldOffset(0, outputOffset, 0);
46 | }
47 |
48 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
49 | builder.addFieldOffset(1, errorOffset, 0);
50 | }
51 |
52 | static endKeyPairResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
53 | const offset = builder.endObject();
54 | return offset;
55 | }
56 |
57 | static createKeyPairResponse(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
58 | KeyPairResponse.startKeyPairResponse(builder);
59 | KeyPairResponse.addOutput(builder, outputOffset);
60 | KeyPairResponse.addError(builder, errorOffset);
61 | return KeyPairResponse.endKeyPairResponse(builder);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/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/FastOpenpgpExample.app',
16 | build: 'xcodebuild -workspace ios/FastOpenpgpExample.xcworkspace -scheme FastOpenpgpExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
17 | },
18 | 'ios.release': {
19 | type: 'ios.app',
20 | binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/FastOpenpgpExample.app',
21 | build: 'xcodebuild -workspace ios/FastOpenpgpExample.xcworkspace -scheme FastOpenpgpExample -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 |
--------------------------------------------------------------------------------
/src/model/string-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class StringResponse {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):StringResponse {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsStringResponse(bb:flatbuffers.ByteBuffer, obj?:StringResponse):StringResponse {
17 | return (obj || new StringResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsStringResponse(bb:flatbuffers.ByteBuffer, obj?:StringResponse):StringResponse {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new StringResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | output():string|null
26 | output(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | output(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | error():string|null
33 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
34 | error(optionalEncoding?:any):string|Uint8Array|null {
35 | const offset = this.bb!.__offset(this.bb_pos, 6);
36 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
37 | }
38 |
39 | static startStringResponse(builder:flatbuffers.Builder) {
40 | builder.startObject(2);
41 | }
42 |
43 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
44 | builder.addFieldOffset(0, outputOffset, 0);
45 | }
46 |
47 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
48 | builder.addFieldOffset(1, errorOffset, 0);
49 | }
50 |
51 | static endStringResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
52 | const offset = builder.endObject();
53 | return offset;
54 | }
55 |
56 | static createStringResponse(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
57 | StringResponse.startStringResponse(builder);
58 | StringResponse.addOutput(builder, outputOffset);
59 | StringResponse.addError(builder, errorOffset);
60 | return StringResponse.endStringResponse(builder);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/model/int-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class IntResponse {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):IntResponse {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsIntResponse(bb:flatbuffers.ByteBuffer, obj?:IntResponse):IntResponse {
17 | return (obj || new IntResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsIntResponse(bb:flatbuffers.ByteBuffer, obj?:IntResponse):IntResponse {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new IntResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | output():bigint {
26 | const offset = this.bb!.__offset(this.bb_pos, 4);
27 | return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
28 | }
29 |
30 | mutate_output(value:bigint):boolean {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 |
33 | if (offset === 0) {
34 | return false;
35 | }
36 |
37 | this.bb!.writeInt64(this.bb_pos + offset, value);
38 | return true;
39 | }
40 |
41 | error():string|null
42 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
43 | error(optionalEncoding?:any):string|Uint8Array|null {
44 | const offset = this.bb!.__offset(this.bb_pos, 6);
45 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
46 | }
47 |
48 | static startIntResponse(builder:flatbuffers.Builder) {
49 | builder.startObject(2);
50 | }
51 |
52 | static addOutput(builder:flatbuffers.Builder, output:bigint) {
53 | builder.addFieldInt64(0, output, BigInt('0'));
54 | }
55 |
56 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
57 | builder.addFieldOffset(1, errorOffset, 0);
58 | }
59 |
60 | static endIntResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
61 | const offset = builder.endObject();
62 | return offset;
63 | }
64 |
65 | static createIntResponse(builder:flatbuffers.Builder, output:bigint, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
66 | IntResponse.startIntResponse(builder);
67 | IntResponse.addOutput(builder, output);
68 | IntResponse.addError(builder, errorOffset);
69 | return IntResponse.endIntResponse(builder);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/model/bool-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class BoolResponse {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):BoolResponse {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsBoolResponse(bb:flatbuffers.ByteBuffer, obj?:BoolResponse):BoolResponse {
17 | return (obj || new BoolResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsBoolResponse(bb:flatbuffers.ByteBuffer, obj?:BoolResponse):BoolResponse {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new BoolResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | output():boolean {
26 | const offset = this.bb!.__offset(this.bb_pos, 4);
27 | return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
28 | }
29 |
30 | mutate_output(value:boolean):boolean {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 |
33 | if (offset === 0) {
34 | return false;
35 | }
36 |
37 | this.bb!.writeInt8(this.bb_pos + offset, +value);
38 | return true;
39 | }
40 |
41 | error():string|null
42 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
43 | error(optionalEncoding?:any):string|Uint8Array|null {
44 | const offset = this.bb!.__offset(this.bb_pos, 6);
45 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
46 | }
47 |
48 | static startBoolResponse(builder:flatbuffers.Builder) {
49 | builder.startObject(2);
50 | }
51 |
52 | static addOutput(builder:flatbuffers.Builder, output:boolean) {
53 | builder.addFieldInt8(0, +output, +false);
54 | }
55 |
56 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
57 | builder.addFieldOffset(1, errorOffset, 0);
58 | }
59 |
60 | static endBoolResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
61 | const offset = builder.endObject();
62 | return offset;
63 | }
64 |
65 | static createBoolResponse(builder:flatbuffers.Builder, output:boolean, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
66 | BoolResponse.startBoolResponse(builder);
67 | BoolResponse.addOutput(builder, output);
68 | BoolResponse.addError(builder, errorOffset);
69 | return BoolResponse.endBoolResponse(builder);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/model/armor-decode-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { ArmorMetadata } from '../model/armor-metadata';
8 |
9 |
10 | export class ArmorDecodeResponse {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):ArmorDecodeResponse {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsArmorDecodeResponse(bb:flatbuffers.ByteBuffer, obj?:ArmorDecodeResponse):ArmorDecodeResponse {
20 | return (obj || new ArmorDecodeResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsArmorDecodeResponse(bb:flatbuffers.ByteBuffer, obj?:ArmorDecodeResponse):ArmorDecodeResponse {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new ArmorDecodeResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | output(obj?:ArmorMetadata):ArmorMetadata|null {
29 | const offset = this.bb!.__offset(this.bb_pos, 4);
30 | return offset ? (obj || new ArmorMetadata()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
31 | }
32 |
33 | error():string|null
34 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
35 | error(optionalEncoding?:any):string|Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 6);
37 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
38 | }
39 |
40 | static startArmorDecodeResponse(builder:flatbuffers.Builder) {
41 | builder.startObject(2);
42 | }
43 |
44 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
45 | builder.addFieldOffset(0, outputOffset, 0);
46 | }
47 |
48 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
49 | builder.addFieldOffset(1, errorOffset, 0);
50 | }
51 |
52 | static endArmorDecodeResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
53 | const offset = builder.endObject();
54 | return offset;
55 | }
56 |
57 | static createArmorDecodeResponse(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
58 | ArmorDecodeResponse.startArmorDecodeResponse(builder);
59 | ArmorDecodeResponse.addOutput(builder, outputOffset);
60 | ArmorDecodeResponse.addError(builder, errorOffset);
61 | return ArmorDecodeResponse.endArmorDecodeResponse(builder);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/model/verify-data-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class VerifyDataRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):VerifyDataRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsVerifyDataRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyDataRequest):VerifyDataRequest {
17 | return (obj || new VerifyDataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsVerifyDataRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyDataRequest):VerifyDataRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new VerifyDataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | signature():string|null
26 | signature(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | signature(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | publicKey():string|null
33 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
34 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
35 | const offset = this.bb!.__offset(this.bb_pos, 6);
36 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
37 | }
38 |
39 | static startVerifyDataRequest(builder:flatbuffers.Builder) {
40 | builder.startObject(2);
41 | }
42 |
43 | static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) {
44 | builder.addFieldOffset(0, signatureOffset, 0);
45 | }
46 |
47 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
48 | builder.addFieldOffset(1, publicKeyOffset, 0);
49 | }
50 |
51 | static endVerifyDataRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
52 | const offset = builder.endObject();
53 | return offset;
54 | }
55 |
56 | static createVerifyDataRequest(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset, publicKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
57 | VerifyDataRequest.startVerifyDataRequest(builder);
58 | VerifyDataRequest.addSignature(builder, signatureOffset);
59 | VerifyDataRequest.addPublicKey(builder, publicKeyOffset);
60 | return VerifyDataRequest.endVerifyDataRequest(builder);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/example/src/modules/EncryptDecrypt.tsx:
--------------------------------------------------------------------------------
1 | import {Colors} from "react-native/Libraries/NewAppScreen";
2 | import {Button, TextInput} from "react-native";
3 | import React, {useState} from "react";
4 | import OpenPGP from 'react-native-fast-openpgp';
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 ({publicKey, privateKey, passphrase}: Props) {
17 |
18 | const [input, setInput] = useState('');
19 | const [encrypted, setEncrypted] = useState('');
20 | const [decrypted, setDecrypted] = useState('');
21 |
22 | return
23 |
24 | Encrypt
25 | {
29 | setInput(text);
30 | }}
31 | style={{backgroundColor: Colors.white, borderRadius: 4}}
32 | placeholder={"insert message here"}
33 | />
34 |
44 | {!!encrypted && (
45 |
46 | Decrypt
47 |
65 | )}
66 | ;
67 | }
68 |
--------------------------------------------------------------------------------
/example/src/modules/EncryptDecryptSymmetric.tsx:
--------------------------------------------------------------------------------
1 | import {Colors} from "react-native/Libraries/NewAppScreen";
2 | import {Button, TextInput} from "react-native";
3 | import React, {useState} from "react";
4 | import OpenPGP from 'react-native-fast-openpgp';
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 ({passphrase}: Props) {
17 |
18 | const [input, setInput] = useState('');
19 | const [encrypted, setEncrypted] = useState('');
20 | const [decrypted, setDecrypted] = useState('');
21 |
22 | return
23 |
24 | Encrypt Symmetric
25 | {
29 | setInput(text);
30 | }}
31 | style={{backgroundColor: Colors.white, borderRadius: 4}}
32 | placeholder={"insert message here"}
33 | />
34 |
47 | {!!encrypted && (
48 |
49 | Decrypt Symmetric
50 |
67 | )}
68 | ;
69 | }
--------------------------------------------------------------------------------
/src/model/decrypt-symmetric-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyOptions } from '../model/key-options';
8 |
9 |
10 | export class DecryptSymmetricRequest {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricRequest {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsDecryptSymmetricRequest(bb:flatbuffers.ByteBuffer, obj?:DecryptSymmetricRequest):DecryptSymmetricRequest {
20 | return (obj || new DecryptSymmetricRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsDecryptSymmetricRequest(bb:flatbuffers.ByteBuffer, obj?:DecryptSymmetricRequest):DecryptSymmetricRequest {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new DecryptSymmetricRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | message():string|null
29 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30 | message(optionalEncoding?:any):string|Uint8Array|null {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33 | }
34 |
35 | passphrase():string|null
36 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
37 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
38 | const offset = this.bb!.__offset(this.bb_pos, 6);
39 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40 | }
41 |
42 | options(obj?:KeyOptions):KeyOptions|null {
43 | const offset = this.bb!.__offset(this.bb_pos, 8);
44 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
45 | }
46 |
47 | static startDecryptSymmetricRequest(builder:flatbuffers.Builder) {
48 | builder.startObject(3);
49 | }
50 |
51 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
52 | builder.addFieldOffset(0, messageOffset, 0);
53 | }
54 |
55 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
56 | builder.addFieldOffset(1, passphraseOffset, 0);
57 | }
58 |
59 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
60 | builder.addFieldOffset(2, optionsOffset, 0);
61 | }
62 |
63 | static endDecryptSymmetricRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
64 | const offset = builder.endObject();
65 | return offset;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/model/public-key-metadata-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { PublicKeyMetadata } from '../model/public-key-metadata';
8 |
9 |
10 | export class PublicKeyMetadataResponse {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyMetadataResponse {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsPublicKeyMetadataResponse(bb:flatbuffers.ByteBuffer, obj?:PublicKeyMetadataResponse):PublicKeyMetadataResponse {
20 | return (obj || new PublicKeyMetadataResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsPublicKeyMetadataResponse(bb:flatbuffers.ByteBuffer, obj?:PublicKeyMetadataResponse):PublicKeyMetadataResponse {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new PublicKeyMetadataResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | output(obj?:PublicKeyMetadata):PublicKeyMetadata|null {
29 | const offset = this.bb!.__offset(this.bb_pos, 4);
30 | return offset ? (obj || new PublicKeyMetadata()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
31 | }
32 |
33 | error():string|null
34 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
35 | error(optionalEncoding?:any):string|Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 6);
37 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
38 | }
39 |
40 | static startPublicKeyMetadataResponse(builder:flatbuffers.Builder) {
41 | builder.startObject(2);
42 | }
43 |
44 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
45 | builder.addFieldOffset(0, outputOffset, 0);
46 | }
47 |
48 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
49 | builder.addFieldOffset(1, errorOffset, 0);
50 | }
51 |
52 | static endPublicKeyMetadataResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
53 | const offset = builder.endObject();
54 | return offset;
55 | }
56 |
57 | static createPublicKeyMetadataResponse(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
58 | PublicKeyMetadataResponse.startPublicKeyMetadataResponse(builder);
59 | PublicKeyMetadataResponse.addOutput(builder, outputOffset);
60 | PublicKeyMetadataResponse.addError(builder, errorOffset);
61 | return PublicKeyMetadataResponse.endPublicKeyMetadataResponse(builder);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/example/src/modules/SignVerify.tsx:
--------------------------------------------------------------------------------
1 | import {Colors} from "react-native/Libraries/NewAppScreen";
2 | import {Button, TextInput} from "react-native";
3 | import React, {useState} from "react";
4 | import OpenPGP from 'react-native-fast-openpgp';
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 ({publicKey, privateKey, passphrase}: Props) {
17 |
18 | const [input, setInput] = useState('');
19 | const [signed, setSigned] = useState('');
20 | const [verified, setVerified] = useState(false);
21 |
22 | return
23 |
24 | Sign
25 | {
29 | setInput(text);
30 | }}
31 | style={{backgroundColor: Colors.white, borderRadius: 4}}
32 | placeholder={"insert message here"}
33 | />
34 |
48 | {!!signed && (
49 |
50 | Verify
51 |
70 | )}
71 | ;
72 | }
73 |
--------------------------------------------------------------------------------
/src/model/private-key-metadata-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { PrivateKeyMetadata } from '../model/private-key-metadata';
8 |
9 |
10 | export class PrivateKeyMetadataResponse {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyMetadataResponse {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsPrivateKeyMetadataResponse(bb:flatbuffers.ByteBuffer, obj?:PrivateKeyMetadataResponse):PrivateKeyMetadataResponse {
20 | return (obj || new PrivateKeyMetadataResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsPrivateKeyMetadataResponse(bb:flatbuffers.ByteBuffer, obj?:PrivateKeyMetadataResponse):PrivateKeyMetadataResponse {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new PrivateKeyMetadataResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | output(obj?:PrivateKeyMetadata):PrivateKeyMetadata|null {
29 | const offset = this.bb!.__offset(this.bb_pos, 4);
30 | return offset ? (obj || new PrivateKeyMetadata()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
31 | }
32 |
33 | error():string|null
34 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
35 | error(optionalEncoding?:any):string|Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 6);
37 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
38 | }
39 |
40 | static startPrivateKeyMetadataResponse(builder:flatbuffers.Builder) {
41 | builder.startObject(2);
42 | }
43 |
44 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
45 | builder.addFieldOffset(0, outputOffset, 0);
46 | }
47 |
48 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
49 | builder.addFieldOffset(1, errorOffset, 0);
50 | }
51 |
52 | static endPrivateKeyMetadataResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
53 | const offset = builder.endObject();
54 | return offset;
55 | }
56 |
57 | static createPrivateKeyMetadataResponse(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
58 | PrivateKeyMetadataResponse.startPrivateKeyMetadataResponse(builder);
59 | PrivateKeyMetadataResponse.addOutput(builder, outputOffset);
60 | PrivateKeyMetadataResponse.addError(builder, errorOffset);
61 | return PrivateKeyMetadataResponse.endPrivateKeyMetadataResponse(builder);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/example/src/modules/SignVerifyFile.tsx:
--------------------------------------------------------------------------------
1 | import {Button, Text} from "react-native";
2 | import React, {useEffect, 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 | import {createFile, deleteFile } from "./Shared";
9 |
10 | interface Props {
11 | publicKey: string,
12 | privateKey: string,
13 | passphrase: string
14 | }
15 |
16 | export default function ({publicKey, privateKey, passphrase}: Props) {
17 |
18 | const fileName = "sample-sign-file.txt"
19 | const content = "sample"
20 | const [loading,setLoading] = useState(true);
21 | const [input,setInput] = useState('');
22 | const [signed, setSigned] = useState('');
23 | const [verified, setVerified] = useState(false);
24 |
25 | useEffect(() => {
26 | createFile(fileName,content).then((value)=>{
27 | setInput(value);
28 | setLoading(false);
29 | })
30 |
31 | return ()=>{
32 | deleteFile(fileName)
33 | }
34 | }, [])
35 |
36 | if (loading){
37 | return ...
38 | }
39 | return
40 |
41 | Sign File
42 |
56 | {!!signed && (
57 |
58 | Verify File
59 |
78 | )}
79 | ;
80 | }
81 |
--------------------------------------------------------------------------------
/src/model/sign-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyOptions } from '../model/key-options';
8 |
9 |
10 | export class SignRequest {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):SignRequest {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsSignRequest(bb:flatbuffers.ByteBuffer, obj?:SignRequest):SignRequest {
20 | return (obj || new SignRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsSignRequest(bb:flatbuffers.ByteBuffer, obj?:SignRequest):SignRequest {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new SignRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | message():string|null
29 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30 | message(optionalEncoding?:any):string|Uint8Array|null {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33 | }
34 |
35 | privateKey():string|null
36 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
37 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
38 | const offset = this.bb!.__offset(this.bb_pos, 8);
39 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40 | }
41 |
42 | passphrase():string|null
43 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
44 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
45 | const offset = this.bb!.__offset(this.bb_pos, 10);
46 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
47 | }
48 |
49 | options(obj?:KeyOptions):KeyOptions|null {
50 | const offset = this.bb!.__offset(this.bb_pos, 12);
51 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
52 | }
53 |
54 | static startSignRequest(builder:flatbuffers.Builder) {
55 | builder.startObject(5);
56 | }
57 |
58 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
59 | builder.addFieldOffset(0, messageOffset, 0);
60 | }
61 |
62 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
63 | builder.addFieldOffset(2, privateKeyOffset, 0);
64 | }
65 |
66 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
67 | builder.addFieldOffset(3, passphraseOffset, 0);
68 | }
69 |
70 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
71 | builder.addFieldOffset(4, optionsOffset, 0);
72 | }
73 |
74 | static endSignRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
75 | const offset = builder.endObject();
76 | return offset;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/model/verify-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class VerifyRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):VerifyRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsVerifyRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyRequest):VerifyRequest {
17 | return (obj || new VerifyRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsVerifyRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyRequest):VerifyRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new VerifyRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | signature():string|null
26 | signature(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | signature(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | message():string|null
33 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
34 | message(optionalEncoding?:any):string|Uint8Array|null {
35 | const offset = this.bb!.__offset(this.bb_pos, 6);
36 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
37 | }
38 |
39 | publicKey():string|null
40 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
41 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
42 | const offset = this.bb!.__offset(this.bb_pos, 8);
43 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
44 | }
45 |
46 | static startVerifyRequest(builder:flatbuffers.Builder) {
47 | builder.startObject(3);
48 | }
49 |
50 | static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) {
51 | builder.addFieldOffset(0, signatureOffset, 0);
52 | }
53 |
54 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
55 | builder.addFieldOffset(1, messageOffset, 0);
56 | }
57 |
58 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
59 | builder.addFieldOffset(2, publicKeyOffset, 0);
60 | }
61 |
62 | static endVerifyRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
63 | const offset = builder.endObject();
64 | return offset;
65 | }
66 |
67 | static createVerifyRequest(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset, messageOffset:flatbuffers.Offset, publicKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
68 | VerifyRequest.startVerifyRequest(builder);
69 | VerifyRequest.addSignature(builder, signatureOffset);
70 | VerifyRequest.addMessage(builder, messageOffset);
71 | VerifyRequest.addPublicKey(builder, publicKeyOffset);
72 | return VerifyRequest.endVerifyRequest(builder);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/model/sign-file-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyOptions } from '../model/key-options';
8 |
9 |
10 | export class SignFileRequest {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):SignFileRequest {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsSignFileRequest(bb:flatbuffers.ByteBuffer, obj?:SignFileRequest):SignFileRequest {
20 | return (obj || new SignFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsSignFileRequest(bb:flatbuffers.ByteBuffer, obj?:SignFileRequest):SignFileRequest {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new SignFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | input():string|null
29 | input(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30 | input(optionalEncoding?:any):string|Uint8Array|null {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33 | }
34 |
35 | privateKey():string|null
36 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
37 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
38 | const offset = this.bb!.__offset(this.bb_pos, 8);
39 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40 | }
41 |
42 | passphrase():string|null
43 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
44 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
45 | const offset = this.bb!.__offset(this.bb_pos, 10);
46 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
47 | }
48 |
49 | options(obj?:KeyOptions):KeyOptions|null {
50 | const offset = this.bb!.__offset(this.bb_pos, 12);
51 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
52 | }
53 |
54 | static startSignFileRequest(builder:flatbuffers.Builder) {
55 | builder.startObject(5);
56 | }
57 |
58 | static addInput(builder:flatbuffers.Builder, inputOffset:flatbuffers.Offset) {
59 | builder.addFieldOffset(0, inputOffset, 0);
60 | }
61 |
62 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
63 | builder.addFieldOffset(2, privateKeyOffset, 0);
64 | }
65 |
66 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
67 | builder.addFieldOffset(3, passphraseOffset, 0);
68 | }
69 |
70 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
71 | builder.addFieldOffset(4, optionsOffset, 0);
72 | }
73 |
74 | static endSignFileRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
75 | const offset = builder.endObject();
76 | return offset;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/model/sign-data-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyOptions } from '../model/key-options';
8 |
9 |
10 | export class SignDataRequest {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):SignDataRequest {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsSignDataRequest(bb:flatbuffers.ByteBuffer, obj?:SignDataRequest):SignDataRequest {
20 | return (obj || new SignDataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsSignDataRequest(bb:flatbuffers.ByteBuffer, obj?:SignDataRequest):SignDataRequest {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new SignDataRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | message():string|null
29 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30 | message(optionalEncoding?:any):string|Uint8Array|null {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33 | }
34 |
35 | privateKey():string|null
36 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
37 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
38 | const offset = this.bb!.__offset(this.bb_pos, 6);
39 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40 | }
41 |
42 | passphrase():string|null
43 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
44 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
45 | const offset = this.bb!.__offset(this.bb_pos, 8);
46 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
47 | }
48 |
49 | options(obj?:KeyOptions):KeyOptions|null {
50 | const offset = this.bb!.__offset(this.bb_pos, 10);
51 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
52 | }
53 |
54 | static startSignDataRequest(builder:flatbuffers.Builder) {
55 | builder.startObject(4);
56 | }
57 |
58 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
59 | builder.addFieldOffset(0, messageOffset, 0);
60 | }
61 |
62 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
63 | builder.addFieldOffset(1, privateKeyOffset, 0);
64 | }
65 |
66 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
67 | builder.addFieldOffset(2, passphraseOffset, 0);
68 | }
69 |
70 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
71 | builder.addFieldOffset(3, optionsOffset, 0);
72 | }
73 |
74 | static endSignDataRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
75 | const offset = builder.endObject();
76 | return offset;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/model/verify-file-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class VerifyFileRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):VerifyFileRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsVerifyFileRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyFileRequest):VerifyFileRequest {
17 | return (obj || new VerifyFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsVerifyFileRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyFileRequest):VerifyFileRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new VerifyFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | signature():string|null
26 | signature(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | signature(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | input():string|null
33 | input(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
34 | input(optionalEncoding?:any):string|Uint8Array|null {
35 | const offset = this.bb!.__offset(this.bb_pos, 6);
36 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
37 | }
38 |
39 | publicKey():string|null
40 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
41 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
42 | const offset = this.bb!.__offset(this.bb_pos, 8);
43 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
44 | }
45 |
46 | static startVerifyFileRequest(builder:flatbuffers.Builder) {
47 | builder.startObject(3);
48 | }
49 |
50 | static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) {
51 | builder.addFieldOffset(0, signatureOffset, 0);
52 | }
53 |
54 | static addInput(builder:flatbuffers.Builder, inputOffset:flatbuffers.Offset) {
55 | builder.addFieldOffset(1, inputOffset, 0);
56 | }
57 |
58 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
59 | builder.addFieldOffset(2, publicKeyOffset, 0);
60 | }
61 |
62 | static endVerifyFileRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
63 | const offset = builder.endObject();
64 | return offset;
65 | }
66 |
67 | static createVerifyFileRequest(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset, inputOffset:flatbuffers.Offset, publicKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
68 | VerifyFileRequest.startVerifyFileRequest(builder);
69 | VerifyFileRequest.addSignature(builder, signatureOffset);
70 | VerifyFileRequest.addInput(builder, inputOffset);
71 | VerifyFileRequest.addPublicKey(builder, publicKeyOffset);
72 | return VerifyFileRequest.endVerifyFileRequest(builder);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/model/encrypt-symmetric-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { FileHints } from '../model/file-hints';
8 | import { KeyOptions } from '../model/key-options';
9 |
10 |
11 | export class EncryptSymmetricRequest {
12 | bb: flatbuffers.ByteBuffer|null = null;
13 | bb_pos = 0;
14 | __init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricRequest {
15 | this.bb_pos = i;
16 | this.bb = bb;
17 | return this;
18 | }
19 |
20 | static getRootAsEncryptSymmetricRequest(bb:flatbuffers.ByteBuffer, obj?:EncryptSymmetricRequest):EncryptSymmetricRequest {
21 | return (obj || new EncryptSymmetricRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
22 | }
23 |
24 | static getSizePrefixedRootAsEncryptSymmetricRequest(bb:flatbuffers.ByteBuffer, obj?:EncryptSymmetricRequest):EncryptSymmetricRequest {
25 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
26 | return (obj || new EncryptSymmetricRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
27 | }
28 |
29 | message():string|null
30 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
31 | message(optionalEncoding?:any):string|Uint8Array|null {
32 | const offset = this.bb!.__offset(this.bb_pos, 4);
33 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
34 | }
35 |
36 | passphrase():string|null
37 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
38 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
39 | const offset = this.bb!.__offset(this.bb_pos, 6);
40 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
41 | }
42 |
43 | options(obj?:KeyOptions):KeyOptions|null {
44 | const offset = this.bb!.__offset(this.bb_pos, 8);
45 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
46 | }
47 |
48 | fileHints(obj?:FileHints):FileHints|null {
49 | const offset = this.bb!.__offset(this.bb_pos, 10);
50 | return offset ? (obj || new FileHints()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
51 | }
52 |
53 | static startEncryptSymmetricRequest(builder:flatbuffers.Builder) {
54 | builder.startObject(4);
55 | }
56 |
57 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
58 | builder.addFieldOffset(0, messageOffset, 0);
59 | }
60 |
61 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
62 | builder.addFieldOffset(1, passphraseOffset, 0);
63 | }
64 |
65 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
66 | builder.addFieldOffset(2, optionsOffset, 0);
67 | }
68 |
69 | static addFileHints(builder:flatbuffers.Builder, fileHintsOffset:flatbuffers.Offset) {
70 | builder.addFieldOffset(3, fileHintsOffset, 0);
71 | }
72 |
73 | static endEncryptSymmetricRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
74 | const offset = builder.endObject();
75 | return offset;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/model/armor-metadata.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class ArmorMetadata {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):ArmorMetadata {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsArmorMetadata(bb:flatbuffers.ByteBuffer, obj?:ArmorMetadata):ArmorMetadata {
17 | return (obj || new ArmorMetadata()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsArmorMetadata(bb:flatbuffers.ByteBuffer, obj?:ArmorMetadata):ArmorMetadata {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new ArmorMetadata()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | body(index: number):number|null {
26 | const offset = this.bb!.__offset(this.bb_pos, 4);
27 | return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
28 | }
29 |
30 | bodyLength():number {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
33 | }
34 |
35 | bodyArray():Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 4);
37 | return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
38 | }
39 |
40 | type():string|null
41 | type(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
42 | type(optionalEncoding?:any):string|Uint8Array|null {
43 | const offset = this.bb!.__offset(this.bb_pos, 6);
44 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
45 | }
46 |
47 | static startArmorMetadata(builder:flatbuffers.Builder) {
48 | builder.startObject(2);
49 | }
50 |
51 | static addBody(builder:flatbuffers.Builder, bodyOffset:flatbuffers.Offset) {
52 | builder.addFieldOffset(0, bodyOffset, 0);
53 | }
54 |
55 | static createBodyVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
56 | builder.startVector(1, data.length, 1);
57 | for (let i = data.length - 1; i >= 0; i--) {
58 | builder.addInt8(data[i]!);
59 | }
60 | return builder.endVector();
61 | }
62 |
63 | static startBodyVector(builder:flatbuffers.Builder, numElems:number) {
64 | builder.startVector(1, numElems, 1);
65 | }
66 |
67 | static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) {
68 | builder.addFieldOffset(1, typeOffset, 0);
69 | }
70 |
71 | static endArmorMetadata(builder:flatbuffers.Builder):flatbuffers.Offset {
72 | const offset = builder.endObject();
73 | return offset;
74 | }
75 |
76 | static createArmorMetadata(builder:flatbuffers.Builder, bodyOffset:flatbuffers.Offset, typeOffset:flatbuffers.Offset):flatbuffers.Offset {
77 | ArmorMetadata.startArmorMetadata(builder);
78 | ArmorMetadata.addBody(builder, bodyOffset);
79 | ArmorMetadata.addType(builder, typeOffset);
80 | return ArmorMetadata.endArmorMetadata(builder);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/model/entity.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | /**
8 | * An Entity represents the components of an OpenPGP key: a primary public key
9 | * (which must be a signing key), one or more identities claimed by that key,
10 | * and zero or more subkeys, which may be encryption keys.
11 | */
12 | export class Entity {
13 | bb: flatbuffers.ByteBuffer|null = null;
14 | bb_pos = 0;
15 | __init(i:number, bb:flatbuffers.ByteBuffer):Entity {
16 | this.bb_pos = i;
17 | this.bb = bb;
18 | return this;
19 | }
20 |
21 | static getRootAsEntity(bb:flatbuffers.ByteBuffer, obj?:Entity):Entity {
22 | return (obj || new Entity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | static getSizePrefixedRootAsEntity(bb:flatbuffers.ByteBuffer, obj?:Entity):Entity {
26 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
27 | return (obj || new Entity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
28 | }
29 |
30 | publicKey():string|null
31 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
32 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
33 | const offset = this.bb!.__offset(this.bb_pos, 4);
34 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
35 | }
36 |
37 | privateKey():string|null
38 | privateKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
39 | privateKey(optionalEncoding?:any):string|Uint8Array|null {
40 | const offset = this.bb!.__offset(this.bb_pos, 6);
41 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
42 | }
43 |
44 | passphrase():string|null
45 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
46 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
47 | const offset = this.bb!.__offset(this.bb_pos, 8);
48 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
49 | }
50 |
51 | static startEntity(builder:flatbuffers.Builder) {
52 | builder.startObject(3);
53 | }
54 |
55 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
56 | builder.addFieldOffset(0, publicKeyOffset, 0);
57 | }
58 |
59 | static addPrivateKey(builder:flatbuffers.Builder, privateKeyOffset:flatbuffers.Offset) {
60 | builder.addFieldOffset(1, privateKeyOffset, 0);
61 | }
62 |
63 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
64 | builder.addFieldOffset(2, passphraseOffset, 0);
65 | }
66 |
67 | static endEntity(builder:flatbuffers.Builder):flatbuffers.Offset {
68 | const offset = builder.endObject();
69 | return offset;
70 | }
71 |
72 | static createEntity(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset, privateKeyOffset:flatbuffers.Offset, passphraseOffset:flatbuffers.Offset):flatbuffers.Offset {
73 | Entity.startEntity(builder);
74 | Entity.addPublicKey(builder, publicKeyOffset);
75 | Entity.addPrivateKey(builder, privateKeyOffset);
76 | Entity.addPassphrase(builder, passphraseOffset);
77 | return Entity.endEntity(builder);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/model/decrypt-symmetric-file-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyOptions } from '../model/key-options';
8 |
9 |
10 | export class DecryptSymmetricFileRequest {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricFileRequest {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsDecryptSymmetricFileRequest(bb:flatbuffers.ByteBuffer, obj?:DecryptSymmetricFileRequest):DecryptSymmetricFileRequest {
20 | return (obj || new DecryptSymmetricFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsDecryptSymmetricFileRequest(bb:flatbuffers.ByteBuffer, obj?:DecryptSymmetricFileRequest):DecryptSymmetricFileRequest {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new DecryptSymmetricFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | input():string|null
29 | input(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30 | input(optionalEncoding?:any):string|Uint8Array|null {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33 | }
34 |
35 | output():string|null
36 | output(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
37 | output(optionalEncoding?:any):string|Uint8Array|null {
38 | const offset = this.bb!.__offset(this.bb_pos, 6);
39 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40 | }
41 |
42 | passphrase():string|null
43 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
44 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
45 | const offset = this.bb!.__offset(this.bb_pos, 8);
46 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
47 | }
48 |
49 | options(obj?:KeyOptions):KeyOptions|null {
50 | const offset = this.bb!.__offset(this.bb_pos, 10);
51 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
52 | }
53 |
54 | static startDecryptSymmetricFileRequest(builder:flatbuffers.Builder) {
55 | builder.startObject(4);
56 | }
57 |
58 | static addInput(builder:flatbuffers.Builder, inputOffset:flatbuffers.Offset) {
59 | builder.addFieldOffset(0, inputOffset, 0);
60 | }
61 |
62 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
63 | builder.addFieldOffset(1, outputOffset, 0);
64 | }
65 |
66 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
67 | builder.addFieldOffset(2, passphraseOffset, 0);
68 | }
69 |
70 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
71 | builder.addFieldOffset(3, optionsOffset, 0);
72 | }
73 |
74 | static endDecryptSymmetricFileRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
75 | const offset = builder.endObject();
76 | return offset;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/model/bytes-response.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class BytesResponse {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):BytesResponse {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsBytesResponse(bb:flatbuffers.ByteBuffer, obj?:BytesResponse):BytesResponse {
17 | return (obj || new BytesResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsBytesResponse(bb:flatbuffers.ByteBuffer, obj?:BytesResponse):BytesResponse {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new BytesResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | output(index: number):number|null {
26 | const offset = this.bb!.__offset(this.bb_pos, 4);
27 | return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
28 | }
29 |
30 | outputLength():number {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
33 | }
34 |
35 | outputArray():Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 4);
37 | return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
38 | }
39 |
40 | error():string|null
41 | error(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
42 | error(optionalEncoding?:any):string|Uint8Array|null {
43 | const offset = this.bb!.__offset(this.bb_pos, 6);
44 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
45 | }
46 |
47 | static startBytesResponse(builder:flatbuffers.Builder) {
48 | builder.startObject(2);
49 | }
50 |
51 | static addOutput(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset) {
52 | builder.addFieldOffset(0, outputOffset, 0);
53 | }
54 |
55 | static createOutputVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
56 | builder.startVector(1, data.length, 1);
57 | for (let i = data.length - 1; i >= 0; i--) {
58 | builder.addInt8(data[i]!);
59 | }
60 | return builder.endVector();
61 | }
62 |
63 | static startOutputVector(builder:flatbuffers.Builder, numElems:number) {
64 | builder.startVector(1, numElems, 1);
65 | }
66 |
67 | static addError(builder:flatbuffers.Builder, errorOffset:flatbuffers.Offset) {
68 | builder.addFieldOffset(1, errorOffset, 0);
69 | }
70 |
71 | static endBytesResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
72 | const offset = builder.endObject();
73 | return offset;
74 | }
75 |
76 | static createBytesResponse(builder:flatbuffers.Builder, outputOffset:flatbuffers.Offset, errorOffset:flatbuffers.Offset):flatbuffers.Offset {
77 | BytesResponse.startBytesResponse(builder);
78 | BytesResponse.addOutput(builder, outputOffset);
79 | BytesResponse.addError(builder, errorOffset);
80 | return BytesResponse.endBytesResponse(builder);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/model/armor-encode-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class ArmorEncodeRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):ArmorEncodeRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsArmorEncodeRequest(bb:flatbuffers.ByteBuffer, obj?:ArmorEncodeRequest):ArmorEncodeRequest {
17 | return (obj || new ArmorEncodeRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsArmorEncodeRequest(bb:flatbuffers.ByteBuffer, obj?:ArmorEncodeRequest):ArmorEncodeRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new ArmorEncodeRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | packet(index: number):number|null {
26 | const offset = this.bb!.__offset(this.bb_pos, 4);
27 | return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
28 | }
29 |
30 | packetLength():number {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
33 | }
34 |
35 | packetArray():Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 4);
37 | return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
38 | }
39 |
40 | type():string|null
41 | type(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
42 | type(optionalEncoding?:any):string|Uint8Array|null {
43 | const offset = this.bb!.__offset(this.bb_pos, 6);
44 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
45 | }
46 |
47 | static startArmorEncodeRequest(builder:flatbuffers.Builder) {
48 | builder.startObject(2);
49 | }
50 |
51 | static addPacket(builder:flatbuffers.Builder, packetOffset:flatbuffers.Offset) {
52 | builder.addFieldOffset(0, packetOffset, 0);
53 | }
54 |
55 | static createPacketVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
56 | builder.startVector(1, data.length, 1);
57 | for (let i = data.length - 1; i >= 0; i--) {
58 | builder.addInt8(data[i]!);
59 | }
60 | return builder.endVector();
61 | }
62 |
63 | static startPacketVector(builder:flatbuffers.Builder, numElems:number) {
64 | builder.startVector(1, numElems, 1);
65 | }
66 |
67 | static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) {
68 | builder.addFieldOffset(1, typeOffset, 0);
69 | }
70 |
71 | static endArmorEncodeRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
72 | const offset = builder.endObject();
73 | return offset;
74 | }
75 |
76 | static createArmorEncodeRequest(builder:flatbuffers.Builder, packetOffset:flatbuffers.Offset, typeOffset:flatbuffers.Offset):flatbuffers.Offset {
77 | ArmorEncodeRequest.startArmorEncodeRequest(builder);
78 | ArmorEncodeRequest.addPacket(builder, packetOffset);
79 | ArmorEncodeRequest.addType(builder, typeOffset);
80 | return ArmorEncodeRequest.endArmorEncodeRequest(builder);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/model.ts:
--------------------------------------------------------------------------------
1 | // automatically generated by the FlatBuffers compiler, do not modify
2 |
3 | export { Algorithm } from './model/algorithm';
4 | export { ArmorDecodeRequest } from './model/armor-decode-request';
5 | export { ArmorDecodeResponse } from './model/armor-decode-response';
6 | export { ArmorEncodeRequest } from './model/armor-encode-request';
7 | export { ArmorMetadata } from './model/armor-metadata';
8 | export { BoolResponse } from './model/bool-response';
9 | export { BytesResponse } from './model/bytes-response';
10 | export { Cipher } from './model/cipher';
11 | export { Compression } from './model/compression';
12 | export { ConvertPrivateKeyToPublicKeyRequest } from './model/convert-private-key-to-public-key-request';
13 | export { Curve } from './model/curve';
14 | export { DecryptBytesRequest } from './model/decrypt-bytes-request';
15 | export { DecryptFileRequest } from './model/decrypt-file-request';
16 | export { DecryptRequest } from './model/decrypt-request';
17 | export { DecryptSymmetricBytesRequest } from './model/decrypt-symmetric-bytes-request';
18 | export { DecryptSymmetricFileRequest } from './model/decrypt-symmetric-file-request';
19 | export { DecryptSymmetricRequest } from './model/decrypt-symmetric-request';
20 | export { EncryptBytesRequest } from './model/encrypt-bytes-request';
21 | export { EncryptFileRequest } from './model/encrypt-file-request';
22 | export { EncryptRequest } from './model/encrypt-request';
23 | export { EncryptSymmetricBytesRequest } from './model/encrypt-symmetric-bytes-request';
24 | export { EncryptSymmetricFileRequest } from './model/encrypt-symmetric-file-request';
25 | export { EncryptSymmetricRequest } from './model/encrypt-symmetric-request';
26 | export { Entity } from './model/entity';
27 | export { FileHints } from './model/file-hints';
28 | export { GenerateRequest } from './model/generate-request';
29 | export { GetPrivateKeyMetadataRequest } from './model/get-private-key-metadata-request';
30 | export { GetPublicKeyMetadataRequest } from './model/get-public-key-metadata-request';
31 | export { Hash } from './model/hash';
32 | export { Identity } from './model/identity';
33 | export { IntResponse } from './model/int-response';
34 | export { KeyOptions } from './model/key-options';
35 | export { KeyPair } from './model/key-pair';
36 | export { KeyPairResponse } from './model/key-pair-response';
37 | export { Options } from './model/options';
38 | export { PrivateKeyMetadata } from './model/private-key-metadata';
39 | export { PrivateKeyMetadataResponse } from './model/private-key-metadata-response';
40 | export { PublicKeyMetadata } from './model/public-key-metadata';
41 | export { PublicKeyMetadataResponse } from './model/public-key-metadata-response';
42 | export { SignBytesRequest } from './model/sign-bytes-request';
43 | export { SignDataBytesRequest } from './model/sign-data-bytes-request';
44 | export { SignDataRequest } from './model/sign-data-request';
45 | export { SignFileRequest } from './model/sign-file-request';
46 | export { SignRequest } from './model/sign-request';
47 | export { StringResponse } from './model/string-response';
48 | export { VerifyBytesRequest } from './model/verify-bytes-request';
49 | export { VerifyDataBytesRequest } from './model/verify-data-bytes-request';
50 | export { VerifyDataRequest } from './model/verify-data-request';
51 | export { VerifyFileRequest } from './model/verify-file-request';
52 | export { VerifyRequest } from './model/verify-request';
53 |
--------------------------------------------------------------------------------
/src/model/identity.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class Identity {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):Identity {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsIdentity(bb:flatbuffers.ByteBuffer, obj?:Identity):Identity {
17 | return (obj || new Identity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsIdentity(bb:flatbuffers.ByteBuffer, obj?:Identity):Identity {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new Identity()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | id():string|null
26 | id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
27 | id(optionalEncoding?:any):string|Uint8Array|null {
28 | const offset = this.bb!.__offset(this.bb_pos, 4);
29 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
30 | }
31 |
32 | comment():string|null
33 | comment(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
34 | comment(optionalEncoding?:any):string|Uint8Array|null {
35 | const offset = this.bb!.__offset(this.bb_pos, 6);
36 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
37 | }
38 |
39 | email():string|null
40 | email(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
41 | email(optionalEncoding?:any):string|Uint8Array|null {
42 | const offset = this.bb!.__offset(this.bb_pos, 8);
43 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
44 | }
45 |
46 | name():string|null
47 | name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
48 | name(optionalEncoding?:any):string|Uint8Array|null {
49 | const offset = this.bb!.__offset(this.bb_pos, 10);
50 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
51 | }
52 |
53 | static startIdentity(builder:flatbuffers.Builder) {
54 | builder.startObject(4);
55 | }
56 |
57 | static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
58 | builder.addFieldOffset(0, idOffset, 0);
59 | }
60 |
61 | static addComment(builder:flatbuffers.Builder, commentOffset:flatbuffers.Offset) {
62 | builder.addFieldOffset(1, commentOffset, 0);
63 | }
64 |
65 | static addEmail(builder:flatbuffers.Builder, emailOffset:flatbuffers.Offset) {
66 | builder.addFieldOffset(2, emailOffset, 0);
67 | }
68 |
69 | static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
70 | builder.addFieldOffset(3, nameOffset, 0);
71 | }
72 |
73 | static endIdentity(builder:flatbuffers.Builder):flatbuffers.Offset {
74 | const offset = builder.endObject();
75 | return offset;
76 | }
77 |
78 | static createIdentity(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, commentOffset:flatbuffers.Offset, emailOffset:flatbuffers.Offset, nameOffset:flatbuffers.Offset):flatbuffers.Offset {
79 | Identity.startIdentity(builder);
80 | Identity.addId(builder, idOffset);
81 | Identity.addComment(builder, commentOffset);
82 | Identity.addEmail(builder, emailOffset);
83 | Identity.addName(builder, nameOffset);
84 | return Identity.endIdentity(builder);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/model/options.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { KeyOptions } from '../model/key-options';
8 |
9 |
10 | export class Options {
11 | bb: flatbuffers.ByteBuffer|null = null;
12 | bb_pos = 0;
13 | __init(i:number, bb:flatbuffers.ByteBuffer):Options {
14 | this.bb_pos = i;
15 | this.bb = bb;
16 | return this;
17 | }
18 |
19 | static getRootAsOptions(bb:flatbuffers.ByteBuffer, obj?:Options):Options {
20 | return (obj || new Options()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
21 | }
22 |
23 | static getSizePrefixedRootAsOptions(bb:flatbuffers.ByteBuffer, obj?:Options):Options {
24 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
25 | return (obj || new Options()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
26 | }
27 |
28 | name():string|null
29 | name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
30 | name(optionalEncoding?:any):string|Uint8Array|null {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
33 | }
34 |
35 | comment():string|null
36 | comment(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
37 | comment(optionalEncoding?:any):string|Uint8Array|null {
38 | const offset = this.bb!.__offset(this.bb_pos, 6);
39 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
40 | }
41 |
42 | email():string|null
43 | email(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
44 | email(optionalEncoding?:any):string|Uint8Array|null {
45 | const offset = this.bb!.__offset(this.bb_pos, 8);
46 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
47 | }
48 |
49 | passphrase():string|null
50 | passphrase(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
51 | passphrase(optionalEncoding?:any):string|Uint8Array|null {
52 | const offset = this.bb!.__offset(this.bb_pos, 10);
53 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
54 | }
55 |
56 | keyOptions(obj?:KeyOptions):KeyOptions|null {
57 | const offset = this.bb!.__offset(this.bb_pos, 12);
58 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
59 | }
60 |
61 | static startOptions(builder:flatbuffers.Builder) {
62 | builder.startObject(5);
63 | }
64 |
65 | static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
66 | builder.addFieldOffset(0, nameOffset, 0);
67 | }
68 |
69 | static addComment(builder:flatbuffers.Builder, commentOffset:flatbuffers.Offset) {
70 | builder.addFieldOffset(1, commentOffset, 0);
71 | }
72 |
73 | static addEmail(builder:flatbuffers.Builder, emailOffset:flatbuffers.Offset) {
74 | builder.addFieldOffset(2, emailOffset, 0);
75 | }
76 |
77 | static addPassphrase(builder:flatbuffers.Builder, passphraseOffset:flatbuffers.Offset) {
78 | builder.addFieldOffset(3, passphraseOffset, 0);
79 | }
80 |
81 | static addKeyOptions(builder:flatbuffers.Builder, keyOptionsOffset:flatbuffers.Offset) {
82 | builder.addFieldOffset(4, keyOptionsOffset, 0);
83 | }
84 |
85 | static endOptions(builder:flatbuffers.Builder):flatbuffers.Offset {
86 | const offset = builder.endObject();
87 | return offset;
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/android/src/main/java/com/fastopenpgp/FastOpenpgpModule.kt:
--------------------------------------------------------------------------------
1 | package com.fastopenpgp
2 |
3 | import android.util.Log
4 | import androidx.annotation.NonNull
5 | import com.facebook.react.bridge.*
6 |
7 | internal class FastOpenpgpModule(reactContext: ReactApplicationContext) :
8 | ReactContextBaseJavaModule(reactContext) {
9 |
10 | val TAG = "[FastOpenPGPModule]"
11 |
12 | external fun initialize(jsContext: Long)
13 | external fun destruct();
14 | external fun callNative(name: String, payload: ByteArray): ByteArray;
15 | external fun encodeTextNative(input: String, encoding: String): ByteArray
16 | external fun decodeTextNative(input: ByteArray, encoding: String, fatal: Int, ignoreBOM: Int, stream: Int): String
17 |
18 | companion object {
19 | init {
20 | System.loadLibrary("fast-openpgp")
21 | }
22 | }
23 |
24 | @ReactMethod
25 | fun call(name: String, payload: ReadableArray, promise: Promise) {
26 | Thread {
27 | try {
28 | val bytes = ByteArray(payload.size()) { index ->
29 | payload.getInt(index).toByte()
30 | }
31 | val result = callNative(name, bytes)
32 | val resultList = Arguments.createArray().apply {
33 | result.forEach { pushInt(it.toInt()) }
34 | }
35 |
36 | promise.resolve(resultList)
37 | } catch (e: Exception) {
38 | promise.reject("CALL_ERROR", "An error occurred during native call", e)
39 | }
40 | }.start()
41 | }
42 |
43 | @ReactMethod(isBlockingSynchronousMethod = true)
44 | fun encodeText(input: String, encoding: String): WritableArray {
45 | return try {
46 | val result = encodeTextNative(input, encoding)
47 | Arguments.createArray().apply {
48 | result.forEach { byteValue: Byte -> pushInt(byteValue.toInt() and 0xFF) }
49 | }
50 | } catch (e: Exception) {
51 | Log.e(TAG, "Encoding error", e)
52 | throw RuntimeException("ENCODE_ERROR: Failed to encode text")
53 | }
54 | }
55 |
56 | @ReactMethod(isBlockingSynchronousMethod = true)
57 | fun decodeText(input: ReadableArray, encoding: String, fatal: Boolean, ignoreBOM: Boolean, stream: Boolean): String {
58 | return try {
59 | val bytes = ByteArray(input.size()) { index ->
60 | input.getInt(index).toByte()
61 | }
62 | decodeTextNative(bytes, encoding, if (fatal) 1 else 0, if (ignoreBOM) 1 else 0, if (stream) 1 else 0)
63 | } catch (e: Exception) {
64 | Log.e(TAG, "Decoding error", e)
65 | throw RuntimeException("DECODE_ERROR: Failed to decode text")
66 | }
67 | }
68 |
69 | @ReactMethod(isBlockingSynchronousMethod = true)
70 | fun install(): Boolean {
71 | Log.d(TAG, "Attempting to install JSI bindings...")
72 | return try {
73 | val contextHolder = reactApplicationContext.javaScriptContextHolder?.get()
74 | if (contextHolder == null || contextHolder.toInt() == 0) {
75 | Log.w(TAG, "JSI context is not available")
76 | false
77 | } else {
78 | initialize(contextHolder)
79 | Log.i(TAG, "JSI bindings successfully installed")
80 | true
81 | }
82 | } catch (e: Exception) {
83 | Log.e(TAG, "Failed to install JSI bindings", e)
84 | false
85 | }
86 | }
87 |
88 | override fun getName(): String {
89 | return "FastOpenpgp"
90 | }
91 |
92 | override fun onCatalystInstanceDestroy() {
93 | destruct();
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/model/encrypt-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | import { Entity } from '../model/entity';
8 | import { FileHints } from '../model/file-hints';
9 | import { KeyOptions } from '../model/key-options';
10 |
11 |
12 | export class EncryptRequest {
13 | bb: flatbuffers.ByteBuffer|null = null;
14 | bb_pos = 0;
15 | __init(i:number, bb:flatbuffers.ByteBuffer):EncryptRequest {
16 | this.bb_pos = i;
17 | this.bb = bb;
18 | return this;
19 | }
20 |
21 | static getRootAsEncryptRequest(bb:flatbuffers.ByteBuffer, obj?:EncryptRequest):EncryptRequest {
22 | return (obj || new EncryptRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | static getSizePrefixedRootAsEncryptRequest(bb:flatbuffers.ByteBuffer, obj?:EncryptRequest):EncryptRequest {
26 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
27 | return (obj || new EncryptRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
28 | }
29 |
30 | message():string|null
31 | message(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
32 | message(optionalEncoding?:any):string|Uint8Array|null {
33 | const offset = this.bb!.__offset(this.bb_pos, 4);
34 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
35 | }
36 |
37 | publicKey():string|null
38 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
39 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
40 | const offset = this.bb!.__offset(this.bb_pos, 6);
41 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
42 | }
43 |
44 | options(obj?:KeyOptions):KeyOptions|null {
45 | const offset = this.bb!.__offset(this.bb_pos, 8);
46 | return offset ? (obj || new KeyOptions()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
47 | }
48 |
49 | signed(obj?:Entity):Entity|null {
50 | const offset = this.bb!.__offset(this.bb_pos, 10);
51 | return offset ? (obj || new Entity()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
52 | }
53 |
54 | fileHints(obj?:FileHints):FileHints|null {
55 | const offset = this.bb!.__offset(this.bb_pos, 12);
56 | return offset ? (obj || new FileHints()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
57 | }
58 |
59 | static startEncryptRequest(builder:flatbuffers.Builder) {
60 | builder.startObject(5);
61 | }
62 |
63 | static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
64 | builder.addFieldOffset(0, messageOffset, 0);
65 | }
66 |
67 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
68 | builder.addFieldOffset(1, publicKeyOffset, 0);
69 | }
70 |
71 | static addOptions(builder:flatbuffers.Builder, optionsOffset:flatbuffers.Offset) {
72 | builder.addFieldOffset(2, optionsOffset, 0);
73 | }
74 |
75 | static addSigned(builder:flatbuffers.Builder, signedOffset:flatbuffers.Offset) {
76 | builder.addFieldOffset(3, signedOffset, 0);
77 | }
78 |
79 | static addFileHints(builder:flatbuffers.Builder, fileHintsOffset:flatbuffers.Offset) {
80 | builder.addFieldOffset(4, fileHintsOffset, 0);
81 | }
82 |
83 | static endEncryptRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
84 | const offset = builder.endObject();
85 | return offset;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['FastOpenpgp_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["FastOpenpgp_" + name]
31 | }
32 |
33 | def getExtOrIntegerDefault(name) {
34 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["FastOpenpgp_" + 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.fastopenpgp"
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", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
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 "**/libopenpgp_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 |
--------------------------------------------------------------------------------
/src/model/verify-data-bytes-request.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 | import * as flatbuffers from 'flatbuffers';
6 |
7 | export class VerifyDataBytesRequest {
8 | bb: flatbuffers.ByteBuffer|null = null;
9 | bb_pos = 0;
10 | __init(i:number, bb:flatbuffers.ByteBuffer):VerifyDataBytesRequest {
11 | this.bb_pos = i;
12 | this.bb = bb;
13 | return this;
14 | }
15 |
16 | static getRootAsVerifyDataBytesRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyDataBytesRequest):VerifyDataBytesRequest {
17 | return (obj || new VerifyDataBytesRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
18 | }
19 |
20 | static getSizePrefixedRootAsVerifyDataBytesRequest(bb:flatbuffers.ByteBuffer, obj?:VerifyDataBytesRequest):VerifyDataBytesRequest {
21 | bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
22 | return (obj || new VerifyDataBytesRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
23 | }
24 |
25 | signature(index: number):number|null {
26 | const offset = this.bb!.__offset(this.bb_pos, 4);
27 | return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
28 | }
29 |
30 | signatureLength():number {
31 | const offset = this.bb!.__offset(this.bb_pos, 4);
32 | return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
33 | }
34 |
35 | signatureArray():Uint8Array|null {
36 | const offset = this.bb!.__offset(this.bb_pos, 4);
37 | return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
38 | }
39 |
40 | publicKey():string|null
41 | publicKey(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
42 | publicKey(optionalEncoding?:any):string|Uint8Array|null {
43 | const offset = this.bb!.__offset(this.bb_pos, 6);
44 | return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
45 | }
46 |
47 | static startVerifyDataBytesRequest(builder:flatbuffers.Builder) {
48 | builder.startObject(2);
49 | }
50 |
51 | static addSignature(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset) {
52 | builder.addFieldOffset(0, signatureOffset, 0);
53 | }
54 |
55 | static createSignatureVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
56 | builder.startVector(1, data.length, 1);
57 | for (let i = data.length - 1; i >= 0; i--) {
58 | builder.addInt8(data[i]!);
59 | }
60 | return builder.endVector();
61 | }
62 |
63 | static startSignatureVector(builder:flatbuffers.Builder, numElems:number) {
64 | builder.startVector(1, numElems, 1);
65 | }
66 |
67 | static addPublicKey(builder:flatbuffers.Builder, publicKeyOffset:flatbuffers.Offset) {
68 | builder.addFieldOffset(1, publicKeyOffset, 0);
69 | }
70 |
71 | static endVerifyDataBytesRequest(builder:flatbuffers.Builder):flatbuffers.Offset {
72 | const offset = builder.endObject();
73 | return offset;
74 | }
75 |
76 | static createVerifyDataBytesRequest(builder:flatbuffers.Builder, signatureOffset:flatbuffers.Offset, publicKeyOffset:flatbuffers.Offset):flatbuffers.Offset {
77 | VerifyDataBytesRequest.startVerifyDataBytesRequest(builder);
78 | VerifyDataBytesRequest.addSignature(builder, signatureOffset);
79 | VerifyDataBytesRequest.addPublicKey(builder, publicKeyOffset);
80 | return VerifyDataBytesRequest.endVerifyDataBytesRequest(builder);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------