diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..e3f2727 --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: Google +ColumnLimit: 0 \ No newline at end of file diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index b4a78d0..8766782 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -11,9 +11,9 @@ jobs: e2e: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - id: yarn-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | **/node_modules @@ -22,11 +22,11 @@ jobs: restore-keys: | ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} ${{ runner.os }}-yarn- - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' - - uses: android-actions/setup-android@v2 + - uses: android-actions/setup-android@v3 - uses: nttld/setup-ndk@v1 id: setup-ndk with: diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 0ef1a4b..523d7c4 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -2,18 +2,18 @@ name: iOS on: workflow_dispatch: - pull_request: - push: - tags: - - 'v*' +# pull_request: +# push: +# tags: +# - 'v*' jobs: e2e: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - id: yarn-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | **/node_modules diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml index 84c1ee5..5151841 100644 --- a/.github/workflows/npm.yml +++ b/.github/workflows/npm.yml @@ -9,10 +9,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '22' registry-url: https://registry.npmjs.org/ - run: yarn install - run: npm publish --access public diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47c7054..84c1ca9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: scottbrenner/generate-changelog-action@master diff --git a/android/fast-openpgp-adapter.cpp b/android/fast-openpgp-adapter.cpp index 9b92c3c..abb739e 100644 --- a/android/fast-openpgp-adapter.cpp +++ b/android/fast-openpgp-adapter.cpp @@ -1,83 +1,94 @@ -#include -#include "react-native-fast-openpgp.h" #include +#include #include -extern "C" -JNIEXPORT void JNICALL -Java_com_fastopenpgp_FastOpenpgpModule_initialize(JNIEnv *env, jobject thiz, - jlong jsi_ptr) { - __android_log_print(ANDROID_LOG_VERBOSE, "react-native-fast-openpgp", - "Initializing"); - fastOpenPGP::install(*reinterpret_cast(jsi_ptr)); -} - -extern "C" -JNIEXPORT void JNICALL -Java_com_fastopenpgp_FastOpenpgpModule_destruct(JNIEnv *env, jobject thiz) { - fastOpenPGP::cleanup(); -} -extern "C" -JNIEXPORT jbyteArray JNICALL -Java_com_fastopenpgp_FastOpenpgpModule_callNative(JNIEnv *env, jobject thiz, - jstring name, jbyteArray payload) { +#include "react-native-fast-openpgp.h" - auto nameConstChar = env->GetStringUTFChars(name, nullptr); - auto payloadBytes = env->GetByteArrayElements(payload, nullptr); - auto size = env->GetArrayLength(payload); +extern "C" JNIEXPORT void JNICALL +Java_com_fastopenpgp_FastOpenpgpModule_initialize(JNIEnv* env, + jobject /* thiz */, + jlong jsContext) { + if (jsContext == 0) { + __android_log_print(ANDROID_LOG_ERROR, "react-native-fast-openpgp", "Failed to initialize: jsContext is null"); + jclass Exception = env->FindClass("java/lang/IllegalArgumentException"); + env->ThrowNew(Exception, "JSI context is null"); + return; + } - auto nameChar = const_cast(nameConstChar); - auto response = OpenPGPBridgeCall(nameChar, payloadBytes, size); + __android_log_print(ANDROID_LOG_VERBOSE, "react-native-fast-openpgp", "Initializing JSI bindings"); - env->ReleaseStringUTFChars(name, nameConstChar); - env->ReleaseByteArrayElements(payload, payloadBytes, 0); + try { + auto* runtime = reinterpret_cast(jsContext); - if (response->error != nullptr) { - auto error = response->error; - free(response); - jclass Exception = env->FindClass("java/lang/Exception"); - env->ThrowNew(Exception, error); - return nullptr; - } + fastOpenPGP::install(*runtime); - auto result = env->NewByteArray(response->size); - env->SetByteArrayRegion(result, 0, response->size, (jbyte*) response->message); - free(response); - return result; + __android_log_print(ANDROID_LOG_INFO, "react-native-fast-openpgp", "JSI bindings successfully installed"); + } catch (const std::exception& e) { + __android_log_print(ANDROID_LOG_ERROR, "react-native-fast-openpgp", "Exception during initialization: %s", e.what()); + jclass Exception = env->FindClass("java/lang/RuntimeException"); + env->ThrowNew(Exception, e.what()); + } catch (...) { + __android_log_print(ANDROID_LOG_ERROR, "react-native-fast-openpgp", "Unknown error during initialization"); + jclass Exception = env->FindClass("java/lang/RuntimeException"); + env->ThrowNew(Exception, "Unknown error occurred during JSI initialization"); + } } +extern "C" JNIEXPORT void JNICALL +Java_com_fastopenpgp_FastOpenpgpModule_destruct(JNIEnv* env, jobject thiz) { + fastOpenPGP::cleanup(); +} +extern "C" JNIEXPORT jbyteArray JNICALL +Java_com_fastopenpgp_FastOpenpgpModule_callNative(JNIEnv* env, + jobject thiz, + jstring name, + jbyteArray payload) { + if (name == nullptr || payload == nullptr) { + jclass Exception = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(Exception, "Input parameters 'name' or 'payload' cannot be null"); + return nullptr; + } + const char* nameConstChar = env->GetStringUTFChars(name, nullptr); + if (nameConstChar == nullptr) { + jclass Exception = env->FindClass("java/lang/OutOfMemoryError"); + env->ThrowNew(Exception, "Failed to allocate memory for 'name'"); + return nullptr; + } -extern "C" -JNIEXPORT jbyteArray JNICALL -Java_com_fastopenpgp_FastOpenpgpModule_callJSI(JNIEnv *env, jobject thiz, jlong jsi_ptr, - jstring name, jbyteArray payload) { - auto &runtime = *reinterpret_cast(jsi_ptr); - auto nameConstChar = env->GetStringUTFChars(name, nullptr); - auto payloadBytes = env->GetByteArrayElements(payload, nullptr); - auto size = env->GetArrayLength(payload); - - auto nameValue = jsi::String::createFromAscii(runtime, nameConstChar); + jbyte* payloadBytes = env->GetByteArrayElements(payload, nullptr); + if (payloadBytes == nullptr) { env->ReleaseStringUTFChars(name, nameConstChar); + jclass Exception = env->FindClass("java/lang/OutOfMemoryError"); + env->ThrowNew(Exception, "Failed to allocate memory for 'payload'"); + return nullptr; + } + jsize size = env->GetArrayLength(payload); + auto response = + OpenPGPBridgeCall(const_cast(nameConstChar), payloadBytes, size); - auto arrayBuffer = runtime.global().getPropertyAsFunction(runtime, "ArrayBuffer"); - jsi::Object o = arrayBuffer.callAsConstructor(runtime, size).getObject(runtime); - jsi::ArrayBuffer payloadValue = o.getArrayBuffer(runtime); - memcpy(payloadValue.data(runtime), payloadBytes, size); - env->ReleaseByteArrayElements(payload, payloadBytes, 0); + // Release resources + env->ReleaseStringUTFChars(name, nameConstChar); + env->ReleaseByteArrayElements(payload, payloadBytes, JNI_ABORT); - auto response = fastOpenPGP::call(runtime, nameValue, payloadValue); + if (response->error != nullptr) { + const char* error = response->error; + free(response); + jclass Exception = env->FindClass("java/lang/Exception"); + env->ThrowNew(Exception, error); + return nullptr; + } + + jbyteArray result = env->NewByteArray(response->size); + if (result == nullptr) { + free(response); + jclass Exception = env->FindClass("java/lang/OutOfMemoryError"); + env->ThrowNew(Exception, "Failed to allocate memory for result"); + return nullptr; + } - if (response.isString()) { - auto error = response.asString(runtime); - jclass Exception = env->FindClass("java/lang/Exception"); - env->ThrowNew(Exception, error.utf8(runtime).c_str()); - return nullptr; + env->SetByteArrayRegion(result, 0, response->size, reinterpret_cast(response->message)); + free(response); - } - auto byteResult = response.asObject(runtime).getArrayBuffer(runtime); - auto sizeResult = byteResult.size(runtime); - auto result = env->NewByteArray(sizeResult); - env->SetByteArrayRegion(result, 0, sizeResult, (jbyte*) byteResult.data(runtime)); - return result; + return result; } diff --git a/android/gradle.properties b/android/gradle.properties index dd2b075..a3e3122 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ FastOpenpgp_kotlinVersion=1.7.0 FastOpenpgp_minSdkVersion=21 -FastOpenpgp_targetSdkVersion=31 -FastOpenpgp_compileSdkVersion=31 -FastOpenpgp_ndkversion=21.4.7075529 +FastOpenpgp_targetSdkVersion=33 +FastOpenpgp_compileSdkVersion=33 +FastOpenpgp_ndkversion=23.1.7779620 diff --git a/android/src/main/java/com/fastopenpgp/FastOpenpgpModule.kt b/android/src/main/java/com/fastopenpgp/FastOpenpgpModule.kt index fcde808..21f489b 100644 --- a/android/src/main/java/com/fastopenpgp/FastOpenpgpModule.kt +++ b/android/src/main/java/com/fastopenpgp/FastOpenpgpModule.kt @@ -9,9 +9,8 @@ internal class FastOpenpgpModule(reactContext: ReactApplicationContext) : val TAG = "[FastOpenPGPModule]" - external fun initialize(jsiPtr: Long); + external fun initialize(jsContext: Long) external fun destruct(); - external fun callJSI(jsiPtr: Long, name: String, payload: ByteArray): ByteArray; external fun callNative(name: String, payload: ByteArray): ByteArray; companion object { @@ -20,64 +19,43 @@ internal class FastOpenpgpModule(reactContext: ReactApplicationContext) : } } - @ReactMethod - fun callJSI(name: String, payload: ReadableArray, promise: Promise) { - Thread { - reactApplicationContext.runOnJSQueueThread { - try { - val contextHolder = this.reactApplicationContext.javaScriptContextHolder!!.get() - if (contextHolder.toInt() == 0) { - call(name, payload, promise) - return@runOnJSQueueThread - } - val bytes = ByteArray(payload.size()) { pos -> payload.getInt(pos).toByte() } - val result = callJSI(contextHolder, name, bytes) - val resultList = Arguments.createArray() - for (i in result.indices) { - resultList.pushInt(result[i].toInt()) - } - promise.resolve(resultList) - } catch (e: Exception) { - promise.reject(e) - } - } - }.start() - } - @ReactMethod fun call(name: String, payload: ReadableArray, promise: Promise) { Thread { try { - val bytes = ByteArray(payload.size()) { pos -> payload.getInt(pos).toByte() } + val bytes = ByteArray(payload.size()) { index -> + payload.getInt(index).toByte() + } val result = callNative(name, bytes) - val resultList = Arguments.createArray() - for (i in result.indices) { - resultList.pushInt(result[i].toInt()) + val resultList = Arguments.createArray().apply { + result.forEach { pushInt(it.toInt()) } } + promise.resolve(resultList) } catch (e: Exception) { - promise.reject(e) + promise.reject("CALL_ERROR", "An error occurred during native call", e) } }.start() } @ReactMethod(isBlockingSynchronousMethod = true) fun install(): Boolean { - Log.d(TAG, "installing") - try { - val contextHolder = this.reactApplicationContext.javaScriptContextHolder!!.get() - if (contextHolder.toInt() == 0) { - Log.d(TAG, "context not available") - return false - } - initialize(contextHolder) - Log.i(TAG, "successfully installed") - return true - } catch (exception: java.lang.Exception) { - Log.e(TAG, "failed to install JSI", exception) - return false + Log.d(TAG, "Attempting to install JSI bindings...") + return try { + val contextHolder = reactApplicationContext.javaScriptContextHolder?.get() + if (contextHolder == null || contextHolder.toInt() == 0) { + Log.w(TAG, "JSI context is not available") + false + } else { + initialize(contextHolder) + Log.i(TAG, "JSI bindings successfully installed") + true + } + } catch (e: Exception) { + Log.e(TAG, "Failed to install JSI bindings", e) + false } - } +} override fun getName(): String { return "FastOpenpgp" diff --git a/android/src/main/jniLibs/arm64-v8a/libopenpgp_bridge.so b/android/src/main/jniLibs/arm64-v8a/libopenpgp_bridge.so index 2d7388f..f7f3c27 100644 Binary files a/android/src/main/jniLibs/arm64-v8a/libopenpgp_bridge.so and b/android/src/main/jniLibs/arm64-v8a/libopenpgp_bridge.so differ diff --git a/android/src/main/jniLibs/armeabi-v7a/libopenpgp_bridge.so b/android/src/main/jniLibs/armeabi-v7a/libopenpgp_bridge.so index 9ed9600..538d637 100644 Binary files a/android/src/main/jniLibs/armeabi-v7a/libopenpgp_bridge.so and b/android/src/main/jniLibs/armeabi-v7a/libopenpgp_bridge.so differ diff --git a/android/src/main/jniLibs/x86/libopenpgp_bridge.so b/android/src/main/jniLibs/x86/libopenpgp_bridge.so index 396c569..927f708 100644 Binary files a/android/src/main/jniLibs/x86/libopenpgp_bridge.so and b/android/src/main/jniLibs/x86/libopenpgp_bridge.so differ diff --git a/android/src/main/jniLibs/x86_64/libopenpgp_bridge.so b/android/src/main/jniLibs/x86_64/libopenpgp_bridge.so index ce67fa9..bf6b1c3 100644 Binary files a/android/src/main/jniLibs/x86_64/libopenpgp_bridge.so and b/android/src/main/jniLibs/x86_64/libopenpgp_bridge.so differ diff --git a/cpp/libopenpgp_bridge.h b/cpp/libopenpgp_bridge.h index f5daf6b..b63f5e9 100644 --- a/cpp/libopenpgp_bridge.h +++ b/cpp/libopenpgp_bridge.h @@ -1,6 +1,10 @@ #include #include -typedef struct { void* message; int size; char* error; } BytesReturn; +typedef struct { + void* message; + int size; + char* error; +} BytesReturn; #ifdef __cplusplus extern "C" { diff --git a/cpp/react-native-fast-openpgp.cpp b/cpp/react-native-fast-openpgp.cpp index 8b4fa2f..9f8c358 100644 --- a/cpp/react-native-fast-openpgp.cpp +++ b/cpp/react-native-fast-openpgp.cpp @@ -1,170 +1,159 @@ #import "react-native-fast-openpgp.h" -#include "libopenpgp_bridge.h" -#include -#include #include #include #include #include +#include + +#include "libopenpgp_bridge.h" using namespace facebook; namespace fastOpenPGP { - jsi::Value call(jsi::Runtime &runtime, const jsi::String &nameValue, - const jsi::Object &payloadObject) { - auto nameString = nameValue.utf8(runtime); - auto nameChar = nameString.c_str(); - auto name = const_cast(nameChar); - - auto payload = payloadObject.getArrayBuffer(runtime); - auto size = (int) (payload.length(runtime)); - auto data = payload.data(runtime); - - auto response = OpenPGPBridgeCall(name, data, size); - - if (response->error != nullptr) { - auto error = response->error; - free(response); - return jsi::Value(jsi::String::createFromAscii(runtime, error)); +jsi::Value call(jsi::Runtime &runtime, const jsi::String &nameValue, + const jsi::Object &payloadObject) { + // Extract and validate name + std::string nameString = nameValue.utf8(runtime); + if (nameString.empty()) { + throw jsi::JSError(runtime, "Name string cannot be empty"); + } + + // Create a mutable copy of the name string + std::vector mutableName(nameString.begin(), nameString.end()); + mutableName.push_back('\0'); // Ensure null termination + + // Extract and validate payload + if (!payloadObject.isArrayBuffer(runtime)) { + throw jsi::JSError(runtime, "Payload must be an ArrayBuffer"); + } + jsi::ArrayBuffer payload = payloadObject.getArrayBuffer(runtime); + int size = static_cast(payload.length(runtime)); + const uint8_t *data = payload.data(runtime); + + // Cast const uint8_t* to void* + void *dataPointer = const_cast(static_cast(data)); + + // Call the OpenPGP bridge + auto response = OpenPGPBridgeCall(mutableName.data(), dataPointer, size); + + // Handle errors from the bridge + if (response->error != nullptr) { + std::string errorMessage(response->error); + free(response); + throw jsi::JSError(runtime, errorMessage); + } + + // Create and populate the ArrayBuffer result + auto arrayBufferConstructor = runtime.global().getPropertyAsFunction(runtime, "ArrayBuffer"); + jsi::Object result = arrayBufferConstructor.callAsConstructor(runtime, response->size).getObject(runtime); + jsi::ArrayBuffer resultBuffer = result.getArrayBuffer(runtime); + memcpy(resultBuffer.data(runtime), response->message, response->size); + + // Clean up and return the result + free(response); + return result; +} + +void install(jsi::Runtime &jsiRuntime) { + std::cout << "Initializing react-native-fast-openpgp" << "\n"; + + auto bridgeCallSync = jsi::Function::createFromHostFunction( + jsiRuntime, + jsi::PropNameID::forAscii(jsiRuntime, "callSync"), + 2, + [](jsi::Runtime &runtime, const jsi::Value & /*thisValue*/, const jsi::Value *arguments, size_t count) -> jsi::Value { + // Validate argument count + if (count != 2) { + throw jsi::JSError(runtime, "callSync expects exactly 2 arguments: (string name, ArrayBuffer payload)"); + } + + // Validate first argument: name (string) + if (!arguments[0].isString()) { + throw jsi::JSError(runtime, "First argument must be a string representing the name"); + } + auto nameString = arguments[0].getString(runtime); + + // Validate second argument: payload (ArrayBuffer) + if (!arguments[1].isObject() || !arguments[1].getObject(runtime).isArrayBuffer(runtime)) { + throw jsi::JSError(runtime, "Second argument must be an ArrayBuffer representing the payload"); } + auto payloadObject = arguments[1].getObject(runtime); + + // Call the native function + auto response = call(runtime, nameString, payloadObject); + + // Return the response (could be either an error or result) + return response; + }); + + auto bridgeCallPromise = jsi::Function::createFromHostFunction( + jsiRuntime, + jsi::PropNameID::forAscii(jsiRuntime, "callPromise"), + 2, + [](jsi::Runtime &runtime, const jsi::Value & /*thisValue*/, const jsi::Value *arguments, + size_t count) -> jsi::Value { + // Validate argument count + if (count != 2) { + throw jsi::JSError(runtime, "callPromise expects exactly 2 arguments: (string name, ArrayBuffer payload)"); + } + + // Validate and extract 'name' argument + if (!arguments[0].isString()) { + throw jsi::JSError(runtime, "First argument must be a string representing the name"); + } + auto name = arguments[0].getString(runtime); + + // Validate and extract 'payload' argument + if (!arguments[1].isObject() || !arguments[1].getObject(runtime).isArrayBuffer(runtime)) { + throw jsi::JSError(runtime, "Second argument must be an ArrayBuffer representing the payload"); + } + auto payload = arguments[1].getObject(runtime).getArrayBuffer(runtime); + + // Create shared pointers for name and payload + auto namePtr = std::make_shared(std::move(name)); + auto payloadPtr = std::make_shared(std::move(payload)); + + // Create the Promise executor function + auto promiseExecutor = jsi::Function::createFromHostFunction( + runtime, + jsi::PropNameID::forAscii(runtime, "executor"), + 2, + [namePtr, payloadPtr]( + jsi::Runtime &runtime, + const jsi::Value & /*thisValue*/, + const jsi::Value *executorArgs, + size_t executorArgCount) -> jsi::Value { + if (executorArgCount != 2) { + throw jsi::JSError(runtime, "Executor function expects exactly 2 arguments: (resolve, reject)"); + } + + auto resolve = executorArgs[0].asObject(runtime).asFunction(runtime); + auto reject = executorArgs[1].asObject(runtime).asFunction(runtime); + + try { + auto response = call(runtime, *namePtr, *payloadPtr); + resolve.call(runtime, response); + } catch (const jsi::JSError &error) { + reject.call(runtime, error.value()); + } catch (const std::exception &e) { + reject.call(runtime, jsi::String::createFromUtf8(runtime, e.what())); + } + + return jsi::Value::undefined(); + }); + + // Construct and return the Promise + auto promiseConstructor = runtime.global().getPropertyAsFunction(runtime, "Promise"); + auto promise = promiseConstructor.callAsConstructor(runtime, promiseExecutor); + + return promise; + }); + + jsiRuntime.global().setProperty(jsiRuntime, "FastOpenPGPCallPromise", std::move(bridgeCallPromise)); + jsiRuntime.global().setProperty(jsiRuntime, "FastOpenPGPCallSync", std::move(bridgeCallSync)); +} - auto arrayBuffer = runtime.global().getPropertyAsFunction( - runtime, - "ArrayBuffer" - ); - jsi::Object result = arrayBuffer.callAsConstructor( - runtime, - response->size - ).getObject(runtime); - jsi::ArrayBuffer buf = result.getArrayBuffer(runtime); - memcpy(buf.data(runtime), response->message, response->size); - free(response); - - return result; - } - - void install(jsi::Runtime &jsiRuntime) { - - std::cout << "Initializing react-native-fast-openpgp" << "\n"; - - auto bridgeCallSync = jsi::Function::createFromHostFunction( - jsiRuntime, - jsi::PropNameID::forAscii(jsiRuntime, "callSync"), - 2, - [](jsi::Runtime &runtime, const jsi::Value &thisValue, const jsi::Value *arguments, - size_t count) -> jsi::Value { - - if (!arguments[0].isString()) { - return jsi::Value( - jsi::String::createFromAscii(runtime, "name not an String")); - } - auto nameString = arguments[0].getString(runtime); - - if (!arguments[1].isObject()) { - return jsi::Value( - jsi::String::createFromAscii(runtime, "payload not an Object")); - } - auto obj = arguments[1].getObject(runtime); - if (!obj.isArrayBuffer(runtime)) { - return jsi::Value( - jsi::String::createFromAscii(runtime, - "payload not an ArrayBuffer")); - } - - auto response = call(runtime, nameString, obj); - if (response.isString()) { - // here in the future maybe we can throw an exception... - return response; - } - return response; - } - ); - - auto bridgeCallPromise = jsi::Function::createFromHostFunction( - jsiRuntime, - jsi::PropNameID::forAscii(jsiRuntime, "callPromise"), - 2, - [](jsi::Runtime &runtime, const jsi::Value &thisValue, const jsi::Value *arguments, - size_t count) -> jsi::Value { - - auto promise = runtime.global().getPropertyAsFunction(runtime, "Promise"); - auto rejecter = promise.getProperty(runtime, "reject").asObject( - runtime).asFunction(runtime); - if (!arguments[0].isString()) { - return rejecter.call( - runtime, - jsi::JSError(runtime, "name not an String").value() - ); - } - auto name = arguments[0].getString(runtime); - - if (!arguments[1].isObject()) { - return rejecter.call( - runtime, - jsi::JSError(runtime, "payload not an Object").value() - ); - } - auto obj = arguments[1].getObject(runtime); - if (!obj.isArrayBuffer(runtime)) { - return rejecter.call( - runtime, - jsi::JSError(runtime, "payload not an ArrayBuffer").value() - ); - } - auto payload = obj.getArrayBuffer(runtime); - - auto payloadFuture = std::make_shared(std::move(payload)); - auto nameFuture = std::make_shared(std::move(name)); - - auto bridgeCallPromise = jsi::Function::createFromHostFunction( - runtime, - jsi::PropNameID::forAscii(runtime, "promise"), - 2, - [nameFuture, payloadFuture](jsi::Runtime &runtime, - const jsi::Value &thisValue, - const jsi::Value *arguments, - size_t count) -> jsi::Value { - - auto resolveFunction = arguments[0].getObject(runtime).asFunction( - runtime); - auto rejectFunction = arguments[1].getObject(runtime).asFunction( - runtime); - - auto response = call(runtime, *nameFuture, *payloadFuture); - - if (response.isString()) { - rejectFunction.call(runtime, response); - } else { - resolveFunction.call(runtime, response); - } - - return jsi::Value(0); - } - ); - - - jsi::Object o = promise.callAsConstructor(runtime, bridgeCallPromise.asFunction( - runtime)).getObject( - runtime); - return o; - } - ); - - - // for now im not sure why, but create an object don't work with hermes release, but debug yes -// auto object = jsi::Object(jsiRuntime); -// object.setProperty(jsiRuntime, "callPromise", std::move(bridgeCallPromise)); -// object.setProperty(jsiRuntime, "callSync", std::move(bridgeCallSync)); -// jsiRuntime.global().setProperty(jsiRuntime, "FastOpenPGP", std::move(object)); - jsiRuntime.global().setProperty(jsiRuntime, "FastOpenPGPCallPromise", - std::move(bridgeCallPromise)); - jsiRuntime.global().setProperty(jsiRuntime, "FastOpenPGPCallSync", - std::move(bridgeCallSync)); - - } - - void cleanup() { - - } +void cleanup() { } +} // namespace fastOpenPGP diff --git a/cpp/react-native-fast-openpgp.h b/cpp/react-native-fast-openpgp.h index a782d47..8cb2cb1 100644 --- a/cpp/react-native-fast-openpgp.h +++ b/cpp/react-native-fast-openpgp.h @@ -1,18 +1,14 @@ #ifndef FASTOPENPGP_H #define FASTOPENPGP_H -#include #include +#include using namespace facebook; namespace fastOpenPGP { - void install(facebook::jsi::Runtime &jsiRuntime); - - void cleanup(); - - jsi::Value call(jsi::Runtime &runtime, const jsi::String &nameValue, - const jsi::Object &payloadObject); -} +void install(facebook::jsi::Runtime &jsiRuntime); +void cleanup(); +} // namespace fastOpenPGP #endif /* FASTOPENPGP_H */ diff --git a/example/.detoxrc.js b/example/.detoxrc.js index a3f457a..0ad1c30 100644 --- a/example/.detoxrc.js +++ b/example/.detoxrc.js @@ -38,7 +38,7 @@ module.exports = { simulator: { type: 'ios.simulator', device: { - type: 'iPhone 14' + type: 'iPhone 16' } }, attached: { diff --git a/example/ios/FastOpenpgpExample.xcodeproj/project.pbxproj b/example/ios/FastOpenpgpExample.xcodeproj/project.pbxproj index 9099567..d773e51 100644 --- a/example/ios/FastOpenpgpExample.xcodeproj/project.pbxproj +++ b/example/ios/FastOpenpgpExample.xcodeproj/project.pbxproj @@ -486,8 +486,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = EKR687JWFU; ENABLE_BITCODE = NO; INFOPLIST_FILE = FastOpenpgpExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -513,7 +515,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = EKR687JWFU; INFOPLIST_FILE = FastOpenpgpExample/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/example/ios/Podfile b/example/ios/Podfile index a185357..9c87ae5 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -17,7 +17,7 @@ prepare_react_native_project! # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` -flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled +flipper_config = FlipperConfiguration.disabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index cdb8939..325fd3f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,6 +1,5 @@ PODS: - boost (1.76.0) - - CocoaAsyncSocket (7.6.5) - DoubleConversion (1.1.6) - FBLazyVector (0.72.6) - FBReactNativeSpec (0.72.6): @@ -10,71 +9,12 @@ PODS: - React-Core (= 0.72.6) - React-jsi (= 0.72.6) - ReactCommon/turbomodule/core (= 0.72.6) - - Flipper (0.182.0): - - Flipper-Folly (~> 2.6) - - Flipper-Boost-iOSX (1.76.0.1.11) - - Flipper-DoubleConversion (3.2.0.1) - - Flipper-Fmt (7.1.7) - - Flipper-Folly (2.6.10): - - Flipper-Boost-iOSX - - Flipper-DoubleConversion - - Flipper-Fmt (= 7.1.7) - - Flipper-Glog - - libevent (~> 2.1.12) - - OpenSSL-Universal (= 1.1.1100) - - Flipper-Glog (0.5.0.5) - - Flipper-PeerTalk (0.0.4) - - FlipperKit (0.182.0): - - FlipperKit/Core (= 0.182.0) - - FlipperKit/Core (0.182.0): - - Flipper (~> 0.182.0) - - FlipperKit/CppBridge - - FlipperKit/FBCxxFollyDynamicConvert - - FlipperKit/FBDefines - - FlipperKit/FKPortForwarding - - SocketRocket (~> 0.6.0) - - FlipperKit/CppBridge (0.182.0): - - Flipper (~> 0.182.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.182.0): - - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.182.0) - - FlipperKit/FKPortForwarding (0.182.0): - - CocoaAsyncSocket (~> 7.6) - - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.182.0) - - FlipperKit/FlipperKitLayoutHelpers (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutHelpers - - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutIOSDescriptors - - FlipperKit/FlipperKitLayoutTextSearchable - - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutTextSearchable (0.182.0) - - FlipperKit/FlipperKitNetworkPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.182.0): - - FlipperKit/Core - - FlipperKit/FlipperKitNetworkPlugin - fmt (6.2.1) - glog (0.3.5) - hermes-engine (0.72.6): - hermes-engine/Pre-built (= 0.72.6) - hermes-engine/Pre-built (0.72.6) - libevent (2.1.12) - - OpenSSL-Universal (1.1.1100) - RCT-Folly (2021.07.22.00): - boost - DoubleConversion @@ -375,7 +315,7 @@ PODS: - React-jsinspector (0.72.6) - React-logger (0.72.6): - glog - - react-native-fast-openpgp (2.7.1): + - react-native-fast-openpgp (2.7.4): - RCT-Folly (= 2021.07.22.00) - React-Core - React-NativeModulesApple (0.72.6): @@ -492,38 +432,15 @@ PODS: - React-Core - SocketRocket (0.6.1) - Yoga (1.14.0) - - YogaKit (1.18.1): - - Yoga (~> 1.14) DEPENDENCIES: - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) - - Flipper (= 0.182.0) - - Flipper-Boost-iOSX (= 1.76.0.1.11) - - Flipper-DoubleConversion (= 3.2.0.1) - - Flipper-Fmt (= 7.1.7) - - Flipper-Folly (= 2.6.10) - - Flipper-Glog (= 0.5.0.5) - - Flipper-PeerTalk (= 0.0.4) - - FlipperKit (= 0.182.0) - - FlipperKit/Core (= 0.182.0) - - FlipperKit/CppBridge (= 0.182.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.182.0) - - FlipperKit/FBDefines (= 0.182.0) - - FlipperKit/FKPortForwarding (= 0.182.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.182.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.182.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.182.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.182.0) - - FlipperKit/FlipperKitReactPlugin (= 0.182.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.182.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.182.0) - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) - libevent (~> 2.1.12) - - OpenSSL-Universal (= 1.1.1100) - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) @@ -531,7 +448,6 @@ DEPENDENCIES: - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) - React-Codegen (from `build/generated/ios`) - React-Core (from `../node_modules/react-native/`) - - React-Core/DevSupport (from `../node_modules/react-native/`) - React-Core/RCTWebSocket (from `../node_modules/react-native/`) - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) @@ -564,20 +480,9 @@ DEPENDENCIES: SPEC REPOS: trunk: - - CocoaAsyncSocket - - Flipper - - Flipper-Boost-iOSX - - Flipper-DoubleConversion - - Flipper-Fmt - - Flipper-Folly - - Flipper-Glog - - Flipper-PeerTalk - - FlipperKit - fmt - libevent - - OpenSSL-Universal - SocketRocket - - YogaKit EXTERNAL SOURCES: boost: @@ -666,23 +571,13 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: boost: 57d2868c099736d80fcd648bf211b4431e51a558 - CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: 748c0ef74f2bf4b36cfcccf37916806940a64c32 FBReactNativeSpec: 966f29e4e697de53a3b366355e8f57375c856ad9 - Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818 - Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c - Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 - Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b - Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 - Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 - Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b hermes-engine: 8057e75cfc1437b178ac86c8654b24e7fead7f60 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: 28469809442eb4eb5528462705f7d852948c8a74 RCTTypeSafety: e9c6c409fca2cc584e5b086862d562540cb38d29 @@ -698,7 +593,7 @@ SPEC CHECKSUMS: React-jsiexecutor: 3bf18ff7cb03cd8dfdce08fbbc0d15058c1d71ae React-jsinspector: 194e32c6aab382d88713ad3dd0025c5f5c4ee072 React-logger: cebf22b6cf43434e471dc561e5911b40ac01d289 - react-native-fast-openpgp: 50b906a9d41f1a3c0f0190e755b7fc37060a6b55 + react-native-fast-openpgp: 736051c3a9847ede99b185e0cc123db2f7c7c504 React-NativeModulesApple: 02e35e9a51e10c6422f04f5e4076a7c02243fff2 React-perflogger: e3596db7e753f51766bceadc061936ef1472edc3 React-RCTActionSheet: 17ab132c748b4471012abbcdcf5befe860660485 @@ -719,8 +614,7 @@ SPEC CHECKSUMS: RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: b76f1acfda8212aa16b7e26bcce3983230c82603 - YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 71caf16b5cb1532cfe3e9f0ca018f42889cbeede +PODFILE CHECKSUM: f47cb17c40f5d7f780d703c4398503caf4f636b1 -COCOAPODS: 1.14.3 +COCOAPODS: 1.16.2 diff --git a/example/src/App.tsx b/example/src/App.tsx index 6cf543d..909dc8d 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -117,6 +117,7 @@ D4m65Neoc7DBEdvzgK9IUMpwG5N0t+0pfWLhs8AZdMxE7RbP -----END PGP PUBLIC KEY BLOCK-----`; OpenPGP.useJSI = true; + const App = () => { return ( <> diff --git a/ios/FastOpenpgp.mm b/ios/FastOpenpgp.mm index 238ab4a..029fc78 100644 --- a/ios/FastOpenpgp.mm +++ b/ios/FastOpenpgp.mm @@ -10,109 +10,95 @@ @implementation FastOpenpgp RCT_EXPORT_MODULE() -RCT_REMAP_METHOD(call,call:(nonnull NSString*)name withPayload:(nonnull NSArray*)payload +RCT_REMAP_METHOD(call, + call:(nonnull NSString *)name + withPayload:(nonnull NSArray *)payload withResolver:(RCTPromiseResolveBlock)resolve withReject:(RCTPromiseRejectBlock)reject) { - auto bytesCopy = (Byte*)malloc(payload.count); - [payload enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop){ + // Allocate memory for the payload + auto bytesCopy = (Byte *)malloc(payload.count); + if (!bytesCopy) { + reject(@"E002", @"Memory allocation for payload failed", nil); + return; + } + + // Convert NSArray to Byte array + [payload enumerateObjectsUsingBlock:^(NSNumber *number, NSUInteger index, BOOL *stop) { bytesCopy[index] = number.integerValue; }]; - char *cname= strdup([name UTF8String]); + // Convert NSString to C-string + char *cname = strdup([name UTF8String]); + if (!cname) { + free(bytesCopy); + reject(@"E002", @"Memory allocation for name string failed", nil); + return; + } + + // Call the OpenPGP bridge function auto response = OpenPGPBridgeCall(cname, bytesCopy, (int)payload.count); free(bytesCopy); free(cname); - if(response->error!=nil){ - NSString * error = @(response->error); - if(![error isEqual:@""]){ - reject(@"E001",error,nil); + if (!response) { + reject(@"E003", @"OpenPGPBridgeCall returned null response", nil); + return; + } + + // Handle errors in the response + if (response->error != nil) { + NSString *error = @(response->error); + if (![error isEqualToString:@""]) { + reject(@"E001", error, nil); free(response); return; } } - auto bytesResult= (Byte*)malloc( response->size); + // Copy response message to a Byte array + auto bytesResult = (Byte *)malloc(response->size); + if (!bytesResult) { + free(response); + reject(@"E002", @"Memory allocation for response bytes failed", nil); + return; + } memcpy(bytesResult, response->message, response->size); - NSMutableArray* result = [[NSMutableArray alloc] init]; - for (int i=0; isize; i++) { - result[i]=[NSNumber numberWithInt:(int)bytesResult[i]]; + // Convert Byte array to NSMutableArray + NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:response->size]; + for (int i = 0; i < response->size; i++) { + [result addObject:@(bytesResult[i])]; } + + // Free allocated resources free(response); free(bytesResult); + // Resolve the promise with the result resolve(result); } -RCT_REMAP_METHOD(callJSI,callJSI:(nonnull NSString*)name withPayload:(nonnull NSArray*)payload - withResolver:(RCTPromiseResolveBlock)resolve - withReject:(RCTPromiseRejectBlock)reject) +RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) { + // Ensure the bridge is valid and of the expected type RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge; - if (!cxxBridge.runtime) { - [self call:name withPayload:payload withResolver:resolve withReject:reject]; - return; + if (!cxxBridge || !cxxBridge.runtime) { + return @false; // Bridge or runtime is not initialized } - auto bytesCopy = (Byte*)malloc(payload.count); - [payload enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop){ - bytesCopy[index] = number.integerValue; - }]; - char *cname= strdup([name UTF8String]); - int size = (int) payload.count; - - - jsi::Runtime * runtime = (jsi::Runtime *)cxxBridge.runtime; - - auto nameValue = jsi::String::createFromAscii(*runtime, cname); - auto arrayBuffer = runtime->global().getPropertyAsFunction(*runtime, "ArrayBuffer"); - jsi::Object o = arrayBuffer.callAsConstructor(*runtime, size).getObject(*runtime); - jsi::ArrayBuffer payloadValue = o.getArrayBuffer(*runtime); - memcpy(payloadValue.data(*runtime), bytesCopy, size); - - auto response = fastOpenPGP::call(*runtime, nameValue, payloadValue); - free(bytesCopy); - free(cname); - - - if(response.isString()){ - NSString * error = [NSString stringWithUTF8String:response.asString(*runtime).utf8(*runtime).c_str()]; - if(![error isEqual:@""]){ - reject(@"E001",error,nil); - return; - } + // Obtain the JSI runtime + using facebook::jsi::Runtime; + Runtime *jsiRuntime = (Runtime *)cxxBridge.runtime; + if (!jsiRuntime) { + return @false; // JSI runtime is unavailable } - auto byteResult = response.asObject(*runtime).getArrayBuffer(*runtime); - auto sizeResult = byteResult.size(*runtime); - auto dataResult = byteResult.data(*runtime); - - NSMutableArray* result = [[NSMutableArray alloc] init]; - for (int i=0; iSupportedPlatformVariant simulator + + BinaryPath + libopenpgp_bridge.a + HeadersPath + Headers + LibraryIdentifier + ios-arm64_x86_64-maccatalyst + LibraryPath + libopenpgp_bridge.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + maccatalyst + CFBundlePackageType XFWK diff --git a/ios/Openpgp.xcframework/ios-arm64/libopenpgp_bridge.a b/ios/Openpgp.xcframework/ios-arm64/libopenpgp_bridge.a index f392a4d..23c6c8d 100644 Binary files a/ios/Openpgp.xcframework/ios-arm64/libopenpgp_bridge.a and b/ios/Openpgp.xcframework/ios-arm64/libopenpgp_bridge.a differ diff --git a/ios/Openpgp.xcframework/ios-arm64_x86_64-maccatalyst/Headers/libopenpgp_bridge.h b/ios/Openpgp.xcframework/ios-arm64_x86_64-maccatalyst/Headers/libopenpgp_bridge.h new file mode 100644 index 0000000..9b3d2bd --- /dev/null +++ b/ios/Openpgp.xcframework/ios-arm64_x86_64-maccatalyst/Headers/libopenpgp_bridge.h @@ -0,0 +1,87 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package command-line-arguments */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 3 "main.go" +#include +#include +typedef struct { void* message; int size; char* error; } BytesReturn; + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern BytesReturn* OpenPGPBridgeCall(char* name, void* payload, int payloadSize); + +#ifdef __cplusplus +} +#endif diff --git a/ios/Openpgp.xcframework/ios-arm64_x86_64-maccatalyst/libopenpgp_bridge.a b/ios/Openpgp.xcframework/ios-arm64_x86_64-maccatalyst/libopenpgp_bridge.a new file mode 100644 index 0000000..19f3692 Binary files /dev/null and b/ios/Openpgp.xcframework/ios-arm64_x86_64-maccatalyst/libopenpgp_bridge.a differ diff --git a/ios/Openpgp.xcframework/ios-arm64_x86_64-simulator/libopenpgp_bridge.a b/ios/Openpgp.xcframework/ios-arm64_x86_64-simulator/libopenpgp_bridge.a index 740d60a..ab57b29 100644 Binary files a/ios/Openpgp.xcframework/ios-arm64_x86_64-simulator/libopenpgp_bridge.a and b/ios/Openpgp.xcframework/ios-arm64_x86_64-simulator/libopenpgp_bridge.a differ diff --git a/package.json b/package.json index 8d4c379..6ee37b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-fast-openpgp", - "version": "2.7.4", + "version": "2.8.0", "description": "library for use openPGP", "main": "lib/commonjs/index", "module": "lib/module/index", @@ -165,7 +165,8 @@ }, "dependencies": { "big-integer": "^1.6.51", - "flatbuffers": "2.0.6" + "flatbuffers": "24.3.25", + "text-encoding-polyfill": "^0.6.7" }, "codegenConfig": { "name": "RNFastOpenpgpSpec", diff --git a/src/bridge.ts b/src/bridge.ts index 4a412f1..168f07a 100644 --- a/src/bridge.ts +++ b/src/bridge.ts @@ -1,14 +1,3 @@ -export { Algorithm } from './model/algorithm'; -export { ArmorMetadata } from './model/armor-metadata'; -export { Cipher } from './model/cipher'; -export { Compression } from './model/compression'; -export { Curve } from './model/curve'; -export { Entity } from './model/entity'; -export { FileHints } from './model/file-hints'; -export { Hash } from './model/hash'; -export { Identity } from './model/identity'; -export { KeyOptions } from './model/key-options'; -export { KeyPair } from './model/key-pair'; -export { Options } from './model/options'; -export { PrivateKeyMetadata } from './model/private-key-metadata'; -export { PublicKeyMetadata } from './model/public-key-metadata'; +// automatically generated by the FlatBuffers compiler, do not modify + +export * as model from './model'; diff --git a/src/index.tsx b/src/index.tsx index 0d7df68..507ebdb 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,5 @@ import { NativeModules } from 'react-native'; -import * as model from './bridge'; +import * as model from './model'; import * as flatbuffers from 'flatbuffers'; import { BoolResponse } from './model/bool-response'; import { DecryptRequest } from './model/decrypt-request'; @@ -215,7 +215,7 @@ export default class OpenPGP { privateKey: string, passphrase: string, options?: KeyOptions, - signedEntity?: Entity, + signedEntity?: Entity ): Promise { const builder = new flatbuffers.Builder(0); @@ -228,8 +228,8 @@ export default class OpenPGP { DecryptRequest.startDecryptRequest(builder); typeof optionsOffset !== 'undefined' && DecryptRequest.addOptions(builder, optionsOffset); - typeof signedEntityOffset !== 'undefined' && - DecryptRequest.addSigned(builder, signedEntityOffset); + typeof signedEntityOffset !== 'undefined' && + DecryptRequest.addSigned(builder, signedEntityOffset); DecryptRequest.addMessage(builder, messageOffset); DecryptRequest.addPassphrase(builder, passphraseOffset); DecryptRequest.addPrivateKey(builder, privateKeyOffset); @@ -246,7 +246,7 @@ export default class OpenPGP { privateKey: string, passphrase: string, options?: KeyOptions, - signedEntity?: Entity, + signedEntity?: Entity ): Promise { const builder = new flatbuffers.Builder(0); @@ -260,8 +260,8 @@ export default class OpenPGP { DecryptFileRequest.startDecryptFileRequest(builder); typeof optionsOffset !== 'undefined' && DecryptFileRequest.addOptions(builder, optionsOffset); - typeof signedEntityOffset !== 'undefined' && - DecryptFileRequest.addSigned(builder, signedEntityOffset); + typeof signedEntityOffset !== 'undefined' && + DecryptFileRequest.addSigned(builder, signedEntityOffset); DecryptFileRequest.addInput(builder, inputOffset); DecryptFileRequest.addOutput(builder, outputOffset); DecryptFileRequest.addPassphrase(builder, passphraseOffset); @@ -668,10 +668,7 @@ export default class OpenPGP { `(${name})`, 'cant use JSI in debug mode, fallback to NativeModules' ); - result = await FastOpenPGPNativeModules.callJSI( - name, - Array.from(bytes) - ); + result = await FastOpenPGPNativeModules.call(name, Array.from(bytes)); } } else { result = await FastOpenPGPNativeModules.call(name, Array.from(bytes)); diff --git a/src/model.ts b/src/model.ts new file mode 100644 index 0000000..fff5210 --- /dev/null +++ b/src/model.ts @@ -0,0 +1,52 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Algorithm } from './model/algorithm'; +export { ArmorDecodeRequest } from './model/armor-decode-request'; +export { ArmorDecodeResponse } from './model/armor-decode-response'; +export { ArmorEncodeRequest } from './model/armor-encode-request'; +export { ArmorMetadata } from './model/armor-metadata'; +export { BoolResponse } from './model/bool-response'; +export { BytesResponse } from './model/bytes-response'; +export { Cipher } from './model/cipher'; +export { Compression } from './model/compression'; +export { ConvertPrivateKeyToPublicKeyRequest } from './model/convert-private-key-to-public-key-request'; +export { Curve } from './model/curve'; +export { DecryptBytesRequest } from './model/decrypt-bytes-request'; +export { DecryptFileRequest } from './model/decrypt-file-request'; +export { DecryptRequest } from './model/decrypt-request'; +export { DecryptSymmetricBytesRequest } from './model/decrypt-symmetric-bytes-request'; +export { DecryptSymmetricFileRequest } from './model/decrypt-symmetric-file-request'; +export { DecryptSymmetricRequest } from './model/decrypt-symmetric-request'; +export { EncryptBytesRequest } from './model/encrypt-bytes-request'; +export { EncryptFileRequest } from './model/encrypt-file-request'; +export { EncryptRequest } from './model/encrypt-request'; +export { EncryptSymmetricBytesRequest } from './model/encrypt-symmetric-bytes-request'; +export { EncryptSymmetricFileRequest } from './model/encrypt-symmetric-file-request'; +export { EncryptSymmetricRequest } from './model/encrypt-symmetric-request'; +export { Entity } from './model/entity'; +export { FileHints } from './model/file-hints'; +export { GenerateRequest } from './model/generate-request'; +export { GetPrivateKeyMetadataRequest } from './model/get-private-key-metadata-request'; +export { GetPublicKeyMetadataRequest } from './model/get-public-key-metadata-request'; +export { Hash } from './model/hash'; +export { Identity } from './model/identity'; +export { IntResponse } from './model/int-response'; +export { KeyOptions } from './model/key-options'; +export { KeyPair } from './model/key-pair'; +export { KeyPairResponse } from './model/key-pair-response'; +export { Options } from './model/options'; +export { PrivateKeyMetadata } from './model/private-key-metadata'; +export { PrivateKeyMetadataResponse } from './model/private-key-metadata-response'; +export { PublicKeyMetadata } from './model/public-key-metadata'; +export { PublicKeyMetadataResponse } from './model/public-key-metadata-response'; +export { SignBytesRequest } from './model/sign-bytes-request'; +export { SignDataBytesRequest } from './model/sign-data-bytes-request'; +export { SignDataRequest } from './model/sign-data-request'; +export { SignFileRequest } from './model/sign-file-request'; +export { SignRequest } from './model/sign-request'; +export { StringResponse } from './model/string-response'; +export { VerifyBytesRequest } from './model/verify-bytes-request'; +export { VerifyDataBytesRequest } from './model/verify-data-bytes-request'; +export { VerifyDataRequest } from './model/verify-data-request'; +export { VerifyFileRequest } from './model/verify-file-request'; +export { VerifyRequest } from './model/verify-request'; diff --git a/src/model/algorithm.ts b/src/model/algorithm.ts index 1000394..f126103 100644 --- a/src/model/algorithm.ts +++ b/src/model/algorithm.ts @@ -1,6 +1,8 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum Algorithm{ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum Algorithm { RSA = 0, ECDSA = 1, EDDSA = 2, @@ -8,4 +10,3 @@ export enum Algorithm{ DSA = 4, ELGAMAL = 5 } - diff --git a/src/model/armor-decode-request.ts b/src/model/armor-decode-request.ts index c728ae3..00b4849 100644 --- a/src/model/armor-decode-request.ts +++ b/src/model/armor-decode-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class ArmorDecodeRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ArmorDecodeRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ArmorDecodeRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/armor-decode-response.ts b/src/model/armor-decode-response.ts index e2d561b..e23ae30 100644 --- a/src/model/armor-decode-response.ts +++ b/src/model/armor-decode-response.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { ArmorMetadata } from '../model/armor-metadata'; @@ -8,7 +10,7 @@ import { ArmorMetadata } from '../model/armor-metadata'; export class ArmorDecodeResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ArmorDecodeResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):ArmorDecodeResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/armor-encode-request.ts b/src/model/armor-encode-request.ts index 5f78c49..d0ce51e 100644 --- a/src/model/armor-encode-request.ts +++ b/src/model/armor-encode-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class ArmorEncodeRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ArmorEncodeRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ArmorEncodeRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/armor-metadata.ts b/src/model/armor-metadata.ts index b76115e..6129fc2 100644 --- a/src/model/armor-metadata.ts +++ b/src/model/armor-metadata.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class ArmorMetadata { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ArmorMetadata { + __init(i:number, bb:flatbuffers.ByteBuffer):ArmorMetadata { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/bool-response.ts b/src/model/bool-response.ts index 95ca090..0037f23 100644 --- a/src/model/bool-response.ts +++ b/src/model/bool-response.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class BoolResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):BoolResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):BoolResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/bytes-response.ts b/src/model/bytes-response.ts index fcc1269..9e70fbd 100644 --- a/src/model/bytes-response.ts +++ b/src/model/bytes-response.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class BytesResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):BytesResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):BytesResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/cipher.ts b/src/model/cipher.ts index dfcc4c9..1e78a12 100644 --- a/src/model/cipher.ts +++ b/src/model/cipher.ts @@ -1,10 +1,11 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum Cipher{ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum Cipher { AES128 = 0, AES192 = 1, AES256 = 2, DES = 3, CAST5 = 4 } - diff --git a/src/model/compression.ts b/src/model/compression.ts index d2c3d7c..36fa069 100644 --- a/src/model/compression.ts +++ b/src/model/compression.ts @@ -1,8 +1,9 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum Compression{ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum Compression { NONE = 0, ZLIB = 1, ZIP = 2 } - diff --git a/src/model/convert-private-key-to-public-key-request.ts b/src/model/convert-private-key-to-public-key-request.ts index 2caa1f3..7778017 100644 --- a/src/model/convert-private-key-to-public-key-request.ts +++ b/src/model/convert-private-key-to-public-key-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class ConvertPrivateKeyToPublicKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ConvertPrivateKeyToPublicKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ConvertPrivateKeyToPublicKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/curve.ts b/src/model/curve.ts index 71802ed..08cd0c6 100644 --- a/src/model/curve.ts +++ b/src/model/curve.ts @@ -1,6 +1,8 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum Curve{ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum Curve { CURVE25519 = 0, CURVE448 = 1, P256 = 2, @@ -11,4 +13,3 @@ export enum Curve{ BRAINPOOLP384 = 7, BRAINPOOLP512 = 8 } - diff --git a/src/model/decrypt-bytes-request.ts b/src/model/decrypt-bytes-request.ts index 68678f7..12c65d7 100644 --- a/src/model/decrypt-bytes-request.ts +++ b/src/model/decrypt-bytes-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Entity } from '../model/entity'; @@ -9,7 +11,7 @@ import { KeyOptions } from '../model/key-options'; export class DecryptBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-file-request.ts b/src/model/decrypt-file-request.ts index fb895d3..986b0e1 100644 --- a/src/model/decrypt-file-request.ts +++ b/src/model/decrypt-file-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Entity } from '../model/entity'; @@ -9,7 +11,7 @@ import { KeyOptions } from '../model/key-options'; export class DecryptFileRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptFileRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptFileRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-request.ts b/src/model/decrypt-request.ts index 8443a94..d1dd407 100644 --- a/src/model/decrypt-request.ts +++ b/src/model/decrypt-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Entity } from '../model/entity'; @@ -9,7 +11,7 @@ import { KeyOptions } from '../model/key-options'; export class DecryptRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-symmetric-bytes-request.ts b/src/model/decrypt-symmetric-bytes-request.ts index e94b207..37e3096 100644 --- a/src/model/decrypt-symmetric-bytes-request.ts +++ b/src/model/decrypt-symmetric-bytes-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class DecryptSymmetricBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-symmetric-file-request.ts b/src/model/decrypt-symmetric-file-request.ts index ba30c0f..1d06d57 100644 --- a/src/model/decrypt-symmetric-file-request.ts +++ b/src/model/decrypt-symmetric-file-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class DecryptSymmetricFileRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricFileRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricFileRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-symmetric-request.ts b/src/model/decrypt-symmetric-request.ts index e6ce704..92be0ad 100644 --- a/src/model/decrypt-symmetric-request.ts +++ b/src/model/decrypt-symmetric-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class DecryptSymmetricRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptSymmetricRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-bytes-request.ts b/src/model/encrypt-bytes-request.ts index a00b962..bc7f96e 100644 --- a/src/model/encrypt-bytes-request.ts +++ b/src/model/encrypt-bytes-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Entity } from '../model/entity'; @@ -10,7 +12,7 @@ import { KeyOptions } from '../model/key-options'; export class EncryptBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-file-request.ts b/src/model/encrypt-file-request.ts index 7663723..e3bba91 100644 --- a/src/model/encrypt-file-request.ts +++ b/src/model/encrypt-file-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Entity } from '../model/entity'; @@ -10,7 +12,7 @@ import { KeyOptions } from '../model/key-options'; export class EncryptFileRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptFileRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptFileRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-request.ts b/src/model/encrypt-request.ts index 0e5cde4..d0f4045 100644 --- a/src/model/encrypt-request.ts +++ b/src/model/encrypt-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Entity } from '../model/entity'; @@ -10,7 +12,7 @@ import { KeyOptions } from '../model/key-options'; export class EncryptRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-symmetric-bytes-request.ts b/src/model/encrypt-symmetric-bytes-request.ts index 7961439..acfe1eb 100644 --- a/src/model/encrypt-symmetric-bytes-request.ts +++ b/src/model/encrypt-symmetric-bytes-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { FileHints } from '../model/file-hints'; @@ -9,7 +11,7 @@ import { KeyOptions } from '../model/key-options'; export class EncryptSymmetricBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-symmetric-file-request.ts b/src/model/encrypt-symmetric-file-request.ts index a159d7f..bd5fd80 100644 --- a/src/model/encrypt-symmetric-file-request.ts +++ b/src/model/encrypt-symmetric-file-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { FileHints } from '../model/file-hints'; @@ -9,7 +11,7 @@ import { KeyOptions } from '../model/key-options'; export class EncryptSymmetricFileRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricFileRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricFileRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-symmetric-request.ts b/src/model/encrypt-symmetric-request.ts index c78a9e7..012d593 100644 --- a/src/model/encrypt-symmetric-request.ts +++ b/src/model/encrypt-symmetric-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { FileHints } from '../model/file-hints'; @@ -9,7 +11,7 @@ import { KeyOptions } from '../model/key-options'; export class EncryptSymmetricRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptSymmetricRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/entity.ts b/src/model/entity.ts index 275bf47..4dbad98 100644 --- a/src/model/entity.ts +++ b/src/model/entity.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; /** @@ -10,7 +12,7 @@ import * as flatbuffers from 'flatbuffers'; export class Entity { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Entity { + __init(i:number, bb:flatbuffers.ByteBuffer):Entity { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/file-hints.ts b/src/model/file-hints.ts index 32ee72f..0118b8c 100644 --- a/src/model/file-hints.ts +++ b/src/model/file-hints.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class FileHints { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):FileHints { + __init(i:number, bb:flatbuffers.ByteBuffer):FileHints { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/generate-request.ts b/src/model/generate-request.ts index ce7c6f0..58dd971 100644 --- a/src/model/generate-request.ts +++ b/src/model/generate-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Options } from '../model/options'; @@ -8,7 +10,7 @@ import { Options } from '../model/options'; export class GenerateRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):GenerateRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):GenerateRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/get-private-key-metadata-request.ts b/src/model/get-private-key-metadata-request.ts index 2213968..205cc1f 100644 --- a/src/model/get-private-key-metadata-request.ts +++ b/src/model/get-private-key-metadata-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class GetPrivateKeyMetadataRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):GetPrivateKeyMetadataRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):GetPrivateKeyMetadataRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/get-public-key-metadata-request.ts b/src/model/get-public-key-metadata-request.ts index 28ed340..ef7799a 100644 --- a/src/model/get-public-key-metadata-request.ts +++ b/src/model/get-public-key-metadata-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class GetPublicKeyMetadataRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):GetPublicKeyMetadataRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):GetPublicKeyMetadataRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/hash.ts b/src/model/hash.ts index 508a2c4..b581c12 100644 --- a/src/model/hash.ts +++ b/src/model/hash.ts @@ -1,9 +1,10 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum Hash{ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum Hash { SHA256 = 0, SHA224 = 1, SHA384 = 2, SHA512 = 3 } - diff --git a/src/model/identity.ts b/src/model/identity.ts index 8b26bef..751d3a8 100644 --- a/src/model/identity.ts +++ b/src/model/identity.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class Identity { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Identity { + __init(i:number, bb:flatbuffers.ByteBuffer):Identity { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/int-response.ts b/src/model/int-response.ts index 8371b3d..68e9d58 100644 --- a/src/model/int-response.ts +++ b/src/model/int-response.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class IntResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):IntResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):IntResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/key-options.ts b/src/model/key-options.ts index 94a6b76..e3e3f7c 100644 --- a/src/model/key-options.ts +++ b/src/model/key-options.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Algorithm } from '../model/algorithm'; @@ -15,7 +17,7 @@ import { Hash } from '../model/hash'; export class KeyOptions { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):KeyOptions { + __init(i:number, bb:flatbuffers.ByteBuffer):KeyOptions { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/key-pair-response.ts b/src/model/key-pair-response.ts index 8b60d69..db4c636 100644 --- a/src/model/key-pair-response.ts +++ b/src/model/key-pair-response.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyPair } from '../model/key-pair'; @@ -8,7 +10,7 @@ import { KeyPair } from '../model/key-pair'; export class KeyPairResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):KeyPairResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):KeyPairResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/key-pair.ts b/src/model/key-pair.ts index b80154b..55c66e1 100644 --- a/src/model/key-pair.ts +++ b/src/model/key-pair.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class KeyPair { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):KeyPair { + __init(i:number, bb:flatbuffers.ByteBuffer):KeyPair { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/options.ts b/src/model/options.ts index 11fc8c5..aeb8192 100644 --- a/src/model/options.ts +++ b/src/model/options.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class Options { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Options { + __init(i:number, bb:flatbuffers.ByteBuffer):Options { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/private-key-metadata-response.ts b/src/model/private-key-metadata-response.ts index 4b1a154..1d0b33e 100644 --- a/src/model/private-key-metadata-response.ts +++ b/src/model/private-key-metadata-response.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { PrivateKeyMetadata } from '../model/private-key-metadata'; @@ -8,7 +10,7 @@ import { PrivateKeyMetadata } from '../model/private-key-metadata'; export class PrivateKeyMetadataResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyMetadataResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyMetadataResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/private-key-metadata.ts b/src/model/private-key-metadata.ts index 673c06b..ac3f9f4 100644 --- a/src/model/private-key-metadata.ts +++ b/src/model/private-key-metadata.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Identity } from '../model/identity'; @@ -8,7 +10,7 @@ import { Identity } from '../model/identity'; export class PrivateKeyMetadata { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyMetadata { + __init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyMetadata { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/public-key-metadata-response.ts b/src/model/public-key-metadata-response.ts index ee5c4fa..9f3bf81 100644 --- a/src/model/public-key-metadata-response.ts +++ b/src/model/public-key-metadata-response.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { PublicKeyMetadata } from '../model/public-key-metadata'; @@ -8,7 +10,7 @@ import { PublicKeyMetadata } from '../model/public-key-metadata'; export class PublicKeyMetadataResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyMetadataResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyMetadataResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/public-key-metadata.ts b/src/model/public-key-metadata.ts index 2a8266d..c0c2813 100644 --- a/src/model/public-key-metadata.ts +++ b/src/model/public-key-metadata.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { Identity } from '../model/identity'; @@ -8,7 +10,7 @@ import { Identity } from '../model/identity'; export class PublicKeyMetadata { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyMetadata { + __init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyMetadata { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-bytes-request.ts b/src/model/sign-bytes-request.ts index 85b2ec5..42ac361 100644 --- a/src/model/sign-bytes-request.ts +++ b/src/model/sign-bytes-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class SignBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-data-bytes-request.ts b/src/model/sign-data-bytes-request.ts index 0f92ef8..fca3f18 100644 --- a/src/model/sign-data-bytes-request.ts +++ b/src/model/sign-data-bytes-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class SignDataBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignDataBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignDataBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-data-request.ts b/src/model/sign-data-request.ts index b9358f0..1c77cbc 100644 --- a/src/model/sign-data-request.ts +++ b/src/model/sign-data-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class SignDataRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignDataRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignDataRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-file-request.ts b/src/model/sign-file-request.ts index 0ec1048..3ea2e1d 100644 --- a/src/model/sign-file-request.ts +++ b/src/model/sign-file-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class SignFileRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignFileRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignFileRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-request.ts b/src/model/sign-request.ts index b057e6f..1b9d00c 100644 --- a/src/model/sign-request.ts +++ b/src/model/sign-request.ts @@ -1,5 +1,7 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; import { KeyOptions } from '../model/key-options'; @@ -8,7 +10,7 @@ import { KeyOptions } from '../model/key-options'; export class SignRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/string-response.ts b/src/model/string-response.ts index fea409c..0f05895 100644 --- a/src/model/string-response.ts +++ b/src/model/string-response.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class StringResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):StringResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):StringResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-bytes-request.ts b/src/model/verify-bytes-request.ts index 393dfd6..e0992ec 100644 --- a/src/model/verify-bytes-request.ts +++ b/src/model/verify-bytes-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class VerifyBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-data-bytes-request.ts b/src/model/verify-data-bytes-request.ts index fa7c50d..ebd607d 100644 --- a/src/model/verify-data-bytes-request.ts +++ b/src/model/verify-data-bytes-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class VerifyDataBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyDataBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyDataBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-data-request.ts b/src/model/verify-data-request.ts index ab00a30..69cc54a 100644 --- a/src/model/verify-data-request.ts +++ b/src/model/verify-data-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class VerifyDataRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyDataRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyDataRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-file-request.ts b/src/model/verify-file-request.ts index 9fd45a0..5227f4c 100644 --- a/src/model/verify-file-request.ts +++ b/src/model/verify-file-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class VerifyFileRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyFileRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyFileRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-request.ts b/src/model/verify-request.ts index a8c5281..a9eaa4e 100644 --- a/src/model/verify-request.ts +++ b/src/model/verify-request.ts @@ -1,11 +1,13 @@ // automatically generated by the FlatBuffers compiler, do not modify +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + import * as flatbuffers from 'flatbuffers'; export class VerifyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/shim.ts b/src/shim.ts new file mode 100644 index 0000000..e9241eb --- /dev/null +++ b/src/shim.ts @@ -0,0 +1,28 @@ +if (typeof global.TextEncoder === 'undefined') { + require('text-encoding-polyfill'); +} + +if (typeof global.BigInt === 'undefined') { + const bigInt = require('big-integer'); + bigInt.asUintN = function (bits: any, bigint: any) { + bigint = bigInt(bigint); + if (typeof bigint.value === 'bigint') { + return bigInt(BigInt.asUintN(bits, bigint.value)); + } + const p2bits = bigInt(1).shiftLeft(bits); + const mod = bigint.and(p2bits.subtract(1)); + return mod; + }; + bigInt.asIntN = function (bits: any, bigint: any) { + bigint = bigInt(bigint); + if (typeof bigint.value === 'bigint') { + return bigInt(BigInt.asIntN(bits, bigint.value)); + } + const p2bits = bigInt(1).shiftLeft(bits); + const mod = bigint.and(p2bits.subtract(1)); + return mod.greaterOrEquals(p2bits.subtract(mod)) + ? mod.subtract(p2bits) + : mod; + }; + global.BigInt = bigInt; +} diff --git a/src/shim.tsx b/src/shim.tsx deleted file mode 100644 index d4ac1c1..0000000 --- a/src/shim.tsx +++ /dev/null @@ -1,24 +0,0 @@ -if (typeof BigInt === 'undefined') { - const bigInt = require('big-integer'); - bigInt.asUintN = function (bits:any, bigint:any) { - bigint = bigInt(bigint); - if (typeof bigint.value === 'bigint') { - return bigInt(BigInt.asUintN(bits, bigint.value)); - } - const p2bits = bigInt(1).shiftLeft(bits); - const mod = bigint.and(p2bits.subtract(1)); - return mod; - }; - bigInt.asIntN = function (bits:any, bigint:any) { - bigint = bigInt(bigint); - if (typeof bigint.value === 'bigint') { - return bigInt(BigInt.asIntN(bits, bigint.value)); - } - const p2bits = bigInt(1).shiftLeft(bits); - const mod = bigint.and(p2bits.subtract(1)); - return mod.greaterOrEquals(p2bits.subtract(mod)) - ? mod.subtract(p2bits) - : mod; - }; - global.BigInt = bigInt; -} \ No newline at end of file diff --git a/src/types.d.ts b/src/types.d.ts index a0ac5f2..d1a8eb4 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,7 +1,6 @@ /** * `Array`: returned by NativeModules due to lack of ByteArray support * - * @see `FastOpenPGPNativeModules.callJSI` * @see `FastOpenPGPNativeModules.call` */ type BridgeResponseNativeModules = Array; @@ -27,14 +26,6 @@ type BridgeResponse = BridgeResponseNativeModules | BridgeResponseJSI; * Contains all method available inside of `NativeModules` */ interface FastOpenPGPNativeModules { - /** - * this method use `NativeModules` but also will send `JSI` reference to use same thread - * but it runs in a separated thread also. - */ - callJSI( - name: string, - payload: Array - ): Promise; /** * this method use `NativeModules` in a more traditional way * using `JNI` on android in order to call shared a library. @@ -55,6 +46,7 @@ interface NativeModulesDef { interface Global { BigInt: any; + TextEncoder: any; // for now we are not going to use this way because of hermes on release mode only // FastOpenPGP:FastOpenPGPJSI /** diff --git a/yarn.lock b/yarn.lock index 2227663..1a8bf38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7828,10 +7828,10 @@ __metadata: languageName: node linkType: hard -"flatbuffers@npm:2.0.6": - version: 2.0.6 - resolution: "flatbuffers@npm:2.0.6" - checksum: 88d907d3c9404c2e10c3e45e23a39ed5517b77c036738f88973933f50454a44f49336cbfbc5f3758b3eeb8e644902d84fdedd94c3fd0a54dfda724d4adb1155f +"flatbuffers@npm:24.3.25": + version: 24.3.25 + resolution: "flatbuffers@npm:24.3.25" + checksum: 418d946b9bec0bdc7d1212062f385f08cfc34fed4709fd3dbaf5d7b3e73a33188d964ac65843aaa4bce8a753631d9087cabb53dc94fb43a5da77cbc891eacaf5 languageName: node linkType: hard @@ -13430,7 +13430,7 @@ __metadata: eslint: ^8.4.1 eslint-config-prettier: ^8.5.0 eslint-plugin-prettier: ^4.0.0 - flatbuffers: 2.0.6 + flatbuffers: 24.3.25 jest: ^28.1.1 pod-install: ^0.1.0 prettier: ^2.0.5 @@ -13438,6 +13438,7 @@ __metadata: react-native: 0.72.6 react-native-builder-bob: ^0.20.0 release-it: ^15.0.0 + text-encoding-polyfill: ^0.6.7 turbo: ^1.10.7 typescript: ^5.0.2 peerDependencies: @@ -15224,6 +15225,13 @@ __metadata: languageName: node linkType: hard +"text-encoding-polyfill@npm:^0.6.7": + version: 0.6.7 + resolution: "text-encoding-polyfill@npm:0.6.7" + checksum: 8e5b45154f3394cd29af01760ec2f728caba7cfc57fbcab60c073dc9c6db479d923efda3e074ae467379c4a0710c45e6427c6917a70da3059876924c190e03ed + languageName: node + linkType: hard + "text-extensions@npm:^1.0.0": version: 1.9.0 resolution: "text-extensions@npm:1.9.0"