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 7eec4eb..523d7c4 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -11,9 +11,9 @@ 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-rsa-adapter.cpp b/android/fast-rsa-adapter.cpp index 6cb59a7..88c3566 100644 --- a/android/fast-rsa-adapter.cpp +++ b/android/fast-rsa-adapter.cpp @@ -1,83 +1,96 @@ -#include -#include "react-native-fast-rsa.h" #include +#include #include -extern "C" -JNIEXPORT void JNICALL -Java_com_fastrsa_FastRsaModule_initialize(JNIEnv *env, jobject thiz, - jlong jsi_ptr) { - __android_log_print(ANDROID_LOG_VERBOSE, "react-native-fast-rsa", - "Initializing"); - fastRSA::install(*reinterpret_cast(jsi_ptr)); -} +#include "react-native-fast-rsa.h" -extern "C" -JNIEXPORT void JNICALL -Java_com_fastrsa_FastRsaModule_destruct(JNIEnv *env, jobject thiz) { - fastRSA::cleanup(); -} -extern "C" -JNIEXPORT jbyteArray JNICALL -Java_com_fastrsa_FastRsaModule_callNative(JNIEnv *env, jobject thiz, - jstring name, jbyteArray payload) { +extern "C" JNIEXPORT void JNICALL +Java_com_fastrsa_FastRsaModule_initialize(JNIEnv* env, + jobject /* thiz */, + jlong jsContext) { + if (jsContext == 0) { + __android_log_print(ANDROID_LOG_ERROR, "react-native-fast-rsa", "Failed to initialize: jsContext is null"); + jclass Exception = env->FindClass("java/lang/IllegalArgumentException"); + env->ThrowNew(Exception, "JSI context is null"); + return; + } - auto nameConstChar = env->GetStringUTFChars(name, nullptr); - auto payloadBytes = env->GetByteArrayElements(payload, nullptr); - auto size = env->GetArrayLength(payload); + __android_log_print(ANDROID_LOG_VERBOSE, "react-native-fast-rsa", "Initializing JSI bindings"); - auto nameChar = const_cast(nameConstChar); - auto response = RSABridgeCall(nameChar, payloadBytes, size); + try { + auto* runtime = reinterpret_cast(jsContext); - env->ReleaseStringUTFChars(name, nameConstChar); - env->ReleaseByteArrayElements(payload, payloadBytes, 0); - - if (response->error != nullptr) { - auto error = response->error; - free(response); - jclass Exception = env->FindClass("java/lang/Exception"); - env->ThrowNew(Exception, error); - return nullptr; - } - - auto result = env->NewByteArray(response->size); - env->SetByteArrayRegion(result, 0, response->size, (jbyte*) response->message); - free(response); - return result; + fastRSA::install(*runtime); + + __android_log_print(ANDROID_LOG_INFO, "react-native-fast-rsa", "JSI bindings successfully installed"); + } catch (const std::exception& e) { + __android_log_print(ANDROID_LOG_ERROR, "react-native-fast-rsa", "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-rsa", "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_fastrsa_FastRsaModule_destruct(JNIEnv* env, jobject thiz) { + fastRSA::cleanup(); } +extern "C" JNIEXPORT jbyteArray JNICALL +Java_com_fastrsa_FastRsaModule_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; + } -extern "C" -JNIEXPORT jbyteArray JNICALL -Java_com_fastrsa_FastRsaModule_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); + 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; + } - 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 = + RSABridgeCall(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 = fastRSA::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; + } - 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; + 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; + } - } - 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; -} + env->SetByteArrayRegion(result, 0, response->size, reinterpret_cast(response->message)); + free(response); + + return result; +} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 99f83ad..0a395ea 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ FastRsa_kotlinVersion=1.7.0 FastRsa_minSdkVersion=21 -FastRsa_targetSdkVersion=31 -FastRsa_compileSdkVersion=31 -FastRsa_ndkversion=21.4.7075529 +FastRsa_targetSdkVersion=33 +FastRsa_compileSdkVersion=33 +FastRsa_ndkversion=23.1.7779620 diff --git a/android/src/main/java/com/fastrsa/FastRsaModule.kt b/android/src/main/java/com/fastrsa/FastRsaModule.kt index b87eb0c..1eeb912 100644 --- a/android/src/main/java/com/fastrsa/FastRsaModule.kt +++ b/android/src/main/java/com/fastrsa/FastRsaModule.kt @@ -8,9 +8,8 @@ internal class FastRsaModule(reactContext: ReactApplicationContext) : val TAG = "[FastRsaModule]" - 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 { @@ -18,68 +17,47 @@ internal class FastRsaModule(reactContext: ReactApplicationContext) : System.loadLibrary("fast-rsa") } } - - @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() + + override fun getName(): String { + return "FastRsa" } @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 + 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 } - initialize(contextHolder) - Log.i(TAG, "successfully installed") - return true - } catch (exception: java.lang.Exception) { - Log.e(TAG, "failed to install JSI", exception) - return false - } - } - - override fun getName(): String { - return "FastRsa" } override fun onCatalystInstanceDestroy() { diff --git a/android/src/main/jniLibs/arm64-v8a/librsa_bridge.so b/android/src/main/jniLibs/arm64-v8a/librsa_bridge.so index 7b5a6a9..d945813 100644 Binary files a/android/src/main/jniLibs/arm64-v8a/librsa_bridge.so and b/android/src/main/jniLibs/arm64-v8a/librsa_bridge.so differ diff --git a/android/src/main/jniLibs/armeabi-v7a/librsa_bridge.so b/android/src/main/jniLibs/armeabi-v7a/librsa_bridge.so index 466231d..30e8fe6 100644 Binary files a/android/src/main/jniLibs/armeabi-v7a/librsa_bridge.so and b/android/src/main/jniLibs/armeabi-v7a/librsa_bridge.so differ diff --git a/android/src/main/jniLibs/x86/librsa_bridge.so b/android/src/main/jniLibs/x86/librsa_bridge.so index 907b58f..693f11e 100644 Binary files a/android/src/main/jniLibs/x86/librsa_bridge.so and b/android/src/main/jniLibs/x86/librsa_bridge.so differ diff --git a/android/src/main/jniLibs/x86_64/librsa_bridge.so b/android/src/main/jniLibs/x86_64/librsa_bridge.so index 70909b3..13cecf8 100644 Binary files a/android/src/main/jniLibs/x86_64/librsa_bridge.so and b/android/src/main/jniLibs/x86_64/librsa_bridge.so differ diff --git a/cpp/librsa_bridge.h b/cpp/librsa_bridge.h index 81841f4..6212809 100644 --- a/cpp/librsa_bridge.h +++ b/cpp/librsa_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-rsa.cpp b/cpp/react-native-fast-rsa.cpp index cea53c1..20c78ae 100644 --- a/cpp/react-native-fast-rsa.cpp +++ b/cpp/react-native-fast-rsa.cpp @@ -1,171 +1,161 @@ #import "react-native-fast-rsa.h" -#include "librsa_bridge.h" -#include -#include #include #include #include #include +#include +#include +#include + +#include "librsa_bridge.h" using namespace facebook; namespace fastRSA { - 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 = RSABridgeCall(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 RSA bridge + auto response = RSABridgeCall(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-rsa" << "\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, "FastRSACallPromise", std::move(bridgeCallPromise)); + jsiRuntime.global().setProperty(jsiRuntime, "FastRSACallSync", 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-rsa" << "\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, "FastRSA", std::move(object)); - jsiRuntime.global().setProperty(jsiRuntime, "FastRSACallPromise", - std::move(bridgeCallPromise)); - jsiRuntime.global().setProperty(jsiRuntime, "FastRSACallSync", - std::move(bridgeCallSync)); - - } - - void cleanup() { - - } +void cleanup() { } +} // namespace fastRSA diff --git a/cpp/react-native-fast-rsa.h b/cpp/react-native-fast-rsa.h index ba5aaf9..23f2741 100644 --- a/cpp/react-native-fast-rsa.h +++ b/cpp/react-native-fast-rsa.h @@ -7,11 +7,7 @@ using namespace facebook; namespace fastRSA { void install(facebook::jsi::Runtime &jsiRuntime); - void cleanup(); - - jsi::Value call(jsi::Runtime &runtime, const jsi::String &nameValue, - const jsi::Object &payloadObject); -} +} // namespace fastRSA #endif /* FASTRSA_H */ diff --git a/example/.detoxrc.js b/example/.detoxrc.js index 126b742..b4db7eb 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/FastRsaExample.xcodeproj/project.pbxproj b/example/ios/FastRsaExample.xcodeproj/project.pbxproj index e8c8ad1..73a8cd0 100644 --- a/example/ios/FastRsaExample.xcodeproj/project.pbxproj +++ b/example/ios/FastRsaExample.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 = FastRsaExample/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 = FastRsaExample/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 581134b..f0d52fb 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 c4851ae..ef54c43 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-rsa (2.4.0): + - react-native-fast-rsa (2.5.0): - RCT-Folly (= 2021.07.22.00) - React-Core - React-NativeModulesApple (0.72.6): @@ -490,38 +430,15 @@ PODS: - React-perflogger (= 0.72.6) - 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`) @@ -529,7 +446,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`) @@ -561,20 +477,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: @@ -661,23 +566,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 @@ -693,7 +588,7 @@ SPEC CHECKSUMS: React-jsiexecutor: 3bf18ff7cb03cd8dfdce08fbbc0d15058c1d71ae React-jsinspector: 194e32c6aab382d88713ad3dd0025c5f5c4ee072 React-logger: cebf22b6cf43434e471dc561e5911b40ac01d289 - react-native-fast-rsa: a2fe83e35ca07b2df8c37f760c8c4b863025df39 + react-native-fast-rsa: a2151e7c9167ad4d2cd1c9592787d37de493e269 React-NativeModulesApple: 02e35e9a51e10c6422f04f5e4076a7c02243fff2 React-perflogger: e3596db7e753f51766bceadc061936ef1472edc3 React-RCTActionSheet: 17ab132c748b4471012abbcdcf5befe860660485 @@ -713,8 +608,7 @@ SPEC CHECKSUMS: ReactCommon: dd03c17275c200496f346af93a7b94c53f3093a4 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: b76f1acfda8212aa16b7e26bcce3983230c82603 - YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 4e6712403750b10ad0383a09676cf8924fced3b7 +PODFILE CHECKSUM: 1b42c23bac371dd39494e5706f6a24ecaba4ce09 -COCOAPODS: 1.13.0 +COCOAPODS: 1.16.2 diff --git a/example/src/App.tsx b/example/src/App.tsx index e607316..81834cd 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { Dimensions, KeyboardAvoidingView, @@ -63,11 +63,10 @@ QIihOzUzOFbPeXXhwgmqsQ7wNn9yeTcNGwIDAQAB -----END PUBLIC KEY----- `; +RSA.useJSI=true + const App = () => { - useEffect(()=>{ - RSA.useJSI=true - },[]) return ( <> diff --git a/example/src/modules/Generate.tsx b/example/src/modules/Generate.tsx index 8991ee2..3f5f05c 100644 --- a/example/src/modules/Generate.tsx +++ b/example/src/modules/Generate.tsx @@ -24,7 +24,7 @@ export default function ({}: Props) { title={"Generate"} testID={'button'} onPress={async () => { - const output = await RSA.generate(2048); + const output = await RSA.generate(4096); setKeyPair(output); }} /> diff --git a/ios/FastRsa.mm b/ios/FastRsa.mm index 64132c2..8465882 100644 --- a/ios/FastRsa.mm +++ b/ios/FastRsa.mm @@ -10,108 +10,95 @@ @implementation FastRsa 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 RSA bridge function auto response = RSABridgeCall(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", @"RSABridgeCall 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; - } - - 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 = fastRSA::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; - } + if (!cxxBridge || !cxxBridge.runtime) { + return @false; // Bridge or runtime is not initialized } - 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 + librsa_bridge.a + HeadersPath + Headers + LibraryIdentifier + ios-arm64_x86_64-maccatalyst + LibraryPath + librsa_bridge.a + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + maccatalyst + BinaryPath librsa_bridge.a diff --git a/ios/Rsa.xcframework/ios-arm64/librsa_bridge.a b/ios/Rsa.xcframework/ios-arm64/librsa_bridge.a index 369f9ac..3f0ee20 100644 Binary files a/ios/Rsa.xcframework/ios-arm64/librsa_bridge.a and b/ios/Rsa.xcframework/ios-arm64/librsa_bridge.a differ diff --git a/ios/Rsa.xcframework/ios-arm64_x86_64-maccatalyst/Headers/librsa_bridge.h b/ios/Rsa.xcframework/ios-arm64_x86_64-maccatalyst/Headers/librsa_bridge.h new file mode 100644 index 0000000..ff18cc0 --- /dev/null +++ b/ios/Rsa.xcframework/ios-arm64_x86_64-maccatalyst/Headers/librsa_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* RSABridgeCall(char* name, void* payload, int payloadSize); + +#ifdef __cplusplus +} +#endif diff --git a/ios/Rsa.xcframework/ios-arm64_x86_64-maccatalyst/librsa_bridge.a b/ios/Rsa.xcframework/ios-arm64_x86_64-maccatalyst/librsa_bridge.a new file mode 100644 index 0000000..3fbc893 Binary files /dev/null and b/ios/Rsa.xcframework/ios-arm64_x86_64-maccatalyst/librsa_bridge.a differ diff --git a/ios/Rsa.xcframework/ios-arm64_x86_64-simulator/librsa_bridge.a b/ios/Rsa.xcframework/ios-arm64_x86_64-simulator/librsa_bridge.a index 809f6ab..2a84a10 100644 Binary files a/ios/Rsa.xcframework/ios-arm64_x86_64-simulator/librsa_bridge.a and b/ios/Rsa.xcframework/ios-arm64_x86_64-simulator/librsa_bridge.a differ diff --git a/package.json b/package.json index 72e50d4..e6f85ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-fast-rsa", - "version": "2.4.4", + "version": "2.5.0", "description": "library for use RSA", "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": "RNFastRsaSpec", diff --git a/src/bridge.ts b/src/bridge.ts index 8ebf9be..168f07a 100644 --- a/src/bridge.ts +++ b/src/bridge.ts @@ -1,7 +1,3 @@ -export { Hash } from './model/hash'; -export { KeyPair } from './model/key-pair'; -export { PEMCipher } from './model/p-e-m-cipher'; -export { PKCS12KeyPair } from './model/p-k-c-s12-key-pair'; -export { PrivateKeyInfo } from './model/private-key-info'; -export { PublicKeyInfo } from './model/public-key-info'; -export { SaltLength } from './model/salt-length'; +// 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 4b2b1eb..0980f34 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,23 +5,23 @@ import { GenerateRequest } from './model/generate-request'; import { KeyPairResponse } from './model/key-pair-response'; import { StringResponse } from './model/string-response'; import { ConvertPrivateKeyRequest } from './model/convert-private-key-request'; -import { ConvertJWTRequest } from './model/convert-j-w-t-request'; +import { ConvertJWTRequest } from './model/convert-jwtrequest'; import { ConvertKeyPairRequest } from './model/convert-key-pair-request'; -import { ConvertPKCS12Request } from './model/convert-p-k-c-s12-request'; +import { ConvertPKCS12Request } from './model/convert-pkcs12-request'; import { ConvertPublicKeyRequest } from './model/convert-public-key-request'; import { DecryptPrivateKeyRequest } from './model/decrypt-private-key-request'; import { EncryptPrivateKeyRequest } from './model/encrypt-private-key-request'; -import { DecryptOAEPRequest } from './model/decrypt-o-a-e-p-request'; -import { DecryptPKCS1v15Request } from './model/decrypt-p-k-c-s1v15-request'; -import { EncryptOAEPRequest } from './model/encrypt-o-a-e-p-request'; -import { EncryptPKCS1v15Request } from './model/encrypt-p-k-c-s1v15-request'; -import { SignPSSRequest } from './model/sign-p-s-s-request'; -import { SignPKCS1v15Request } from './model/sign-p-k-c-s1v15-request'; -import { VerifyPSSRequest } from './model/verify-p-s-s-request'; -import { VerifyPKCS1v15Request } from './model/verify-p-k-c-s1v15-request'; +import { DecryptOAEPRequest } from './model/decrypt-oaeprequest'; +import { DecryptPKCS1v15Request } from './model/decrypt-pkcs1v15-request'; +import { EncryptOAEPRequest } from './model/encrypt-oaeprequest'; +import { EncryptPKCS1v15Request } from './model/encrypt-pkcs1v15-request'; +import { SignPSSRequest } from './model/sign-pssrequest'; +import { SignPKCS1v15Request } from './model/sign-pkcs1v15-request'; +import { VerifyPSSRequest } from './model/verify-pssrequest'; +import { VerifyPKCS1v15Request } from './model/verify-pkcs1v15-request'; import { HashRequest } from './model/hash-request'; import { Base64Request } from './model/base64-request'; -import { PKCS12KeyPairResponse } from './model/p-k-c-s12-key-pair-response'; +import { PKCS12KeyPairResponse } from './model/pkcs12-key-pair-response'; import './shim'; const FastRSANativeModules = (NativeModules as NativeModulesDef).FastRsa; @@ -564,7 +564,7 @@ export default class RSA { `(${name})`, 'cant use JSI in debug mode, fallback to NativeModules' ); - result = await FastRSANativeModules.callJSI(name, Array.from(bytes)); + result = await FastRSANativeModules.call(name, Array.from(bytes)); } } else { result = await FastRSANativeModules.call(name, Array.from(bytes)); diff --git a/src/model.ts b/src/model.ts new file mode 100644 index 0000000..851b21f --- /dev/null +++ b/src/model.ts @@ -0,0 +1,44 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +export { Base64Request } from './model/base64-request'; +export { BoolResponse } from './model/bool-response'; +export { BytesResponse } from './model/bytes-response'; +export { ConvertJWTRequest } from './model/convert-jwtrequest'; +export { ConvertKeyPairRequest } from './model/convert-key-pair-request'; +export { ConvertPKCS12Request } from './model/convert-pkcs12-request'; +export { ConvertPrivateKeyRequest } from './model/convert-private-key-request'; +export { ConvertPublicKeyRequest } from './model/convert-public-key-request'; +export { DecryptOAEPBytesRequest } from './model/decrypt-oaepbytes-request'; +export { DecryptOAEPRequest } from './model/decrypt-oaeprequest'; +export { DecryptPKCS1v15BytesRequest } from './model/decrypt-pkcs1v15-bytes-request'; +export { DecryptPKCS1v15Request } from './model/decrypt-pkcs1v15-request'; +export { DecryptPrivateKeyRequest } from './model/decrypt-private-key-request'; +export { EncryptOAEPBytesRequest } from './model/encrypt-oaepbytes-request'; +export { EncryptOAEPRequest } from './model/encrypt-oaeprequest'; +export { EncryptPKCS1v15BytesRequest } from './model/encrypt-pkcs1v15-bytes-request'; +export { EncryptPKCS1v15Request } from './model/encrypt-pkcs1v15-request'; +export { EncryptPrivateKeyRequest } from './model/encrypt-private-key-request'; +export { GenerateRequest } from './model/generate-request'; +export { Hash } from './model/hash'; +export { HashRequest } from './model/hash-request'; +export { KeyPair } from './model/key-pair'; +export { KeyPairResponse } from './model/key-pair-response'; +export { MetadataPrivateKeyRequest } from './model/metadata-private-key-request'; +export { MetadataPublicKeyRequest } from './model/metadata-public-key-request'; +export { PEMCipher } from './model/pemcipher'; +export { PKCS12KeyPair } from './model/pkcs12-key-pair'; +export { PKCS12KeyPairResponse } from './model/pkcs12-key-pair-response'; +export { PrivateKeyInfo } from './model/private-key-info'; +export { PrivateKeyInfoResponse } from './model/private-key-info-response'; +export { PublicKeyInfo } from './model/public-key-info'; +export { PublicKeyInfoResponse } from './model/public-key-info-response'; +export { SaltLength } from './model/salt-length'; +export { SignPKCS1v15BytesRequest } from './model/sign-pkcs1v15-bytes-request'; +export { SignPKCS1v15Request } from './model/sign-pkcs1v15-request'; +export { SignPSSBytesRequest } from './model/sign-pssbytes-request'; +export { SignPSSRequest } from './model/sign-pssrequest'; +export { StringResponse } from './model/string-response'; +export { VerifyPKCS1v15BytesRequest } from './model/verify-pkcs1v15-bytes-request'; +export { VerifyPKCS1v15Request } from './model/verify-pkcs1v15-request'; +export { VerifyPSSBytesRequest } from './model/verify-pssbytes-request'; +export { VerifyPSSRequest } from './model/verify-pssrequest'; diff --git a/src/model/base64-request.ts b/src/model/base64-request.ts index 0fde1a0..1882dea 100644 --- a/src/model/base64-request.ts +++ b/src/model/base64-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 Base64Request { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):Base64Request { + __init(i:number, bb:flatbuffers.ByteBuffer):Base64Request { 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/convert-j-w-t-request.ts b/src/model/convert-jwtrequest.ts similarity index 91% rename from src/model/convert-j-w-t-request.ts rename to src/model/convert-jwtrequest.ts index 3df0bcc..2f201b9 100644 --- a/src/model/convert-j-w-t-request.ts +++ b/src/model/convert-jwtrequest.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 ConvertJWTRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ConvertJWTRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ConvertJWTRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/convert-key-pair-request.ts b/src/model/convert-key-pair-request.ts index 7daaa82..52f7582 100644 --- a/src/model/convert-key-pair-request.ts +++ b/src/model/convert-key-pair-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 ConvertKeyPairRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ConvertKeyPairRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ConvertKeyPairRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/convert-p-k-c-s12-request.ts b/src/model/convert-pkcs12-request.ts similarity index 91% rename from src/model/convert-p-k-c-s12-request.ts rename to src/model/convert-pkcs12-request.ts index 7f2b949..a3a91e6 100644 --- a/src/model/convert-p-k-c-s12-request.ts +++ b/src/model/convert-pkcs12-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 ConvertPKCS12Request { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ConvertPKCS12Request { + __init(i:number, bb:flatbuffers.ByteBuffer):ConvertPKCS12Request { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/convert-private-key-request.ts b/src/model/convert-private-key-request.ts index 90b1ed7..b95d87a 100644 --- a/src/model/convert-private-key-request.ts +++ b/src/model/convert-private-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 ConvertPrivateKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ConvertPrivateKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ConvertPrivateKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/convert-public-key-request.ts b/src/model/convert-public-key-request.ts index 9ba5917..76d12f7 100644 --- a/src/model/convert-public-key-request.ts +++ b/src/model/convert-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 ConvertPublicKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):ConvertPublicKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):ConvertPublicKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-o-a-e-p-bytes-request.ts b/src/model/decrypt-oaepbytes-request.ts similarity index 95% rename from src/model/decrypt-o-a-e-p-bytes-request.ts rename to src/model/decrypt-oaepbytes-request.ts index 8ba3437..f7a91e2 100644 --- a/src/model/decrypt-o-a-e-p-bytes-request.ts +++ b/src/model/decrypt-oaepbytes-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class DecryptOAEPBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptOAEPBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptOAEPBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-o-a-e-p-request.ts b/src/model/decrypt-oaeprequest.ts similarity index 94% rename from src/model/decrypt-o-a-e-p-request.ts rename to src/model/decrypt-oaeprequest.ts index 18402dc..c83683b 100644 --- a/src/model/decrypt-o-a-e-p-request.ts +++ b/src/model/decrypt-oaeprequest.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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class DecryptOAEPRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptOAEPRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptOAEPRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-p-k-c-s1v15-bytes-request.ts b/src/model/decrypt-pkcs1v15-bytes-request.ts similarity index 93% rename from src/model/decrypt-p-k-c-s1v15-bytes-request.ts rename to src/model/decrypt-pkcs1v15-bytes-request.ts index c6fcc37..759ca04 100644 --- a/src/model/decrypt-p-k-c-s1v15-bytes-request.ts +++ b/src/model/decrypt-pkcs1v15-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 DecryptPKCS1v15BytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptPKCS1v15BytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptPKCS1v15BytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-p-k-c-s1v15-request.ts b/src/model/decrypt-pkcs1v15-request.ts similarity index 91% rename from src/model/decrypt-p-k-c-s1v15-request.ts rename to src/model/decrypt-pkcs1v15-request.ts index b1f9e6d..ede6839 100644 --- a/src/model/decrypt-p-k-c-s1v15-request.ts +++ b/src/model/decrypt-pkcs1v15-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 DecryptPKCS1v15Request { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptPKCS1v15Request { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptPKCS1v15Request { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/decrypt-private-key-request.ts b/src/model/decrypt-private-key-request.ts index 0c79e91..4348877 100644 --- a/src/model/decrypt-private-key-request.ts +++ b/src/model/decrypt-private-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 DecryptPrivateKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):DecryptPrivateKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):DecryptPrivateKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-o-a-e-p-bytes-request.ts b/src/model/encrypt-oaepbytes-request.ts similarity index 95% rename from src/model/encrypt-o-a-e-p-bytes-request.ts rename to src/model/encrypt-oaepbytes-request.ts index 809c5b1..fd70dce 100644 --- a/src/model/encrypt-o-a-e-p-bytes-request.ts +++ b/src/model/encrypt-oaepbytes-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class EncryptOAEPBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptOAEPBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptOAEPBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-o-a-e-p-request.ts b/src/model/encrypt-oaeprequest.ts similarity index 94% rename from src/model/encrypt-o-a-e-p-request.ts rename to src/model/encrypt-oaeprequest.ts index 0208651..3bb5152 100644 --- a/src/model/encrypt-o-a-e-p-request.ts +++ b/src/model/encrypt-oaeprequest.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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class EncryptOAEPRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptOAEPRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptOAEPRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-p-k-c-s1v15-bytes-request.ts b/src/model/encrypt-pkcs1v15-bytes-request.ts similarity index 93% rename from src/model/encrypt-p-k-c-s1v15-bytes-request.ts rename to src/model/encrypt-pkcs1v15-bytes-request.ts index d5b0db5..92f1c42 100644 --- a/src/model/encrypt-p-k-c-s1v15-bytes-request.ts +++ b/src/model/encrypt-pkcs1v15-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 EncryptPKCS1v15BytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptPKCS1v15BytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptPKCS1v15BytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-p-k-c-s1v15-request.ts b/src/model/encrypt-pkcs1v15-request.ts similarity index 91% rename from src/model/encrypt-p-k-c-s1v15-request.ts rename to src/model/encrypt-pkcs1v15-request.ts index a659cf2..3d609f0 100644 --- a/src/model/encrypt-p-k-c-s1v15-request.ts +++ b/src/model/encrypt-pkcs1v15-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 EncryptPKCS1v15Request { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptPKCS1v15Request { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptPKCS1v15Request { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/encrypt-private-key-request.ts b/src/model/encrypt-private-key-request.ts index ae9193e..5a1c605 100644 --- a/src/model/encrypt-private-key-request.ts +++ b/src/model/encrypt-private-key-request.ts @@ -1,14 +1,16 @@ // 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 { PEMCipher } from '../model/p-e-m-cipher'; +import { PEMCipher } from '../model/pemcipher'; export class EncryptPrivateKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):EncryptPrivateKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):EncryptPrivateKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/generate-request.ts b/src/model/generate-request.ts index 6f3b513..6d095f5 100644 --- a/src/model/generate-request.ts +++ b/src/model/generate-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 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/hash-request.ts b/src/model/hash-request.ts index 482d8b9..8147490 100644 --- a/src/model/hash-request.ts +++ b/src/model/hash-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class HashRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):HashRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):HashRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/hash.ts b/src/model/hash.ts index 656136a..1b19083 100644 --- a/src/model/hash.ts +++ b/src/model/hash.ts @@ -1,6 +1,8 @@ // 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 { MD5 = 0, SHA1 = 1, SHA224 = 2, @@ -8,4 +10,3 @@ export enum Hash{ SHA384 = 4, SHA512 = 5 } - 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 202ccc9..e52d2e8 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/metadata-private-key-request.ts b/src/model/metadata-private-key-request.ts index 07804f6..0c8da03 100644 --- a/src/model/metadata-private-key-request.ts +++ b/src/model/metadata-private-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 MetadataPrivateKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):MetadataPrivateKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):MetadataPrivateKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/metadata-public-key-request.ts b/src/model/metadata-public-key-request.ts index 9a1c588..2f2e772 100644 --- a/src/model/metadata-public-key-request.ts +++ b/src/model/metadata-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 MetadataPublicKeyRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):MetadataPublicKeyRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):MetadataPublicKeyRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/p-e-m-cipher.ts b/src/model/p-e-m-cipher.ts deleted file mode 100644 index 3c7a259..0000000 --- a/src/model/p-e-m-cipher.ts +++ /dev/null @@ -1,10 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -export enum PEMCipher{ - DES = 0, - D3DES = 1, - AES128 = 2, - AES192 = 3, - AES256 = 4 -} - diff --git a/src/model/pemcipher.ts b/src/model/pemcipher.ts new file mode 100644 index 0000000..5a3fb6f --- /dev/null +++ b/src/model/pemcipher.ts @@ -0,0 +1,11 @@ +// 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 */ + +export enum PEMCipher { + DES = 0, + D3DES = 1, + AES128 = 2, + AES192 = 3, + AES256 = 4 +} diff --git a/src/model/p-k-c-s12-key-pair-response.ts b/src/model/pkcs12-key-pair-response.ts similarity index 89% rename from src/model/p-k-c-s12-key-pair-response.ts rename to src/model/pkcs12-key-pair-response.ts index d563476..505097d 100644 --- a/src/model/p-k-c-s12-key-pair-response.ts +++ b/src/model/pkcs12-key-pair-response.ts @@ -1,14 +1,16 @@ // 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 { PKCS12KeyPair } from '../model/p-k-c-s12-key-pair'; +import { PKCS12KeyPair } from '../model/pkcs12-key-pair'; export class PKCS12KeyPairResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PKCS12KeyPairResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):PKCS12KeyPairResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/p-k-c-s12-key-pair.ts b/src/model/pkcs12-key-pair.ts similarity index 93% rename from src/model/p-k-c-s12-key-pair.ts rename to src/model/pkcs12-key-pair.ts index aa90a59..33adb93 100644 --- a/src/model/p-k-c-s12-key-pair.ts +++ b/src/model/pkcs12-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 PKCS12KeyPair { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PKCS12KeyPair { + __init(i:number, bb:flatbuffers.ByteBuffer):PKCS12KeyPair { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/private-key-info-response.ts b/src/model/private-key-info-response.ts index b71d08d..9364aa0 100644 --- a/src/model/private-key-info-response.ts +++ b/src/model/private-key-info-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 { PrivateKeyInfo } from '../model/private-key-info'; @@ -8,7 +10,7 @@ import { PrivateKeyInfo } from '../model/private-key-info'; export class PrivateKeyInfoResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyInfoResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyInfoResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/private-key-info.ts b/src/model/private-key-info.ts index c84a3fd..9e092d4 100644 --- a/src/model/private-key-info.ts +++ b/src/model/private-key-info.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 PrivateKeyInfo { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyInfo { + __init(i:number, bb:flatbuffers.ByteBuffer):PrivateKeyInfo { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/public-key-info-response.ts b/src/model/public-key-info-response.ts index c4a8614..88ab8c4 100644 --- a/src/model/public-key-info-response.ts +++ b/src/model/public-key-info-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 { PublicKeyInfo } from '../model/public-key-info'; @@ -8,7 +10,7 @@ import { PublicKeyInfo } from '../model/public-key-info'; export class PublicKeyInfoResponse { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyInfoResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyInfoResponse { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/public-key-info.ts b/src/model/public-key-info.ts index 551c4a6..a75b14b 100644 --- a/src/model/public-key-info.ts +++ b/src/model/public-key-info.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 PublicKeyInfo { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyInfo { + __init(i:number, bb:flatbuffers.ByteBuffer):PublicKeyInfo { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/salt-length.ts b/src/model/salt-length.ts index 20a872a..3c0ff16 100644 --- a/src/model/salt-length.ts +++ b/src/model/salt-length.ts @@ -1,7 +1,8 @@ // automatically generated by the FlatBuffers compiler, do not modify -export enum SaltLength{ +/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ + +export enum SaltLength { AUTO = 0, EQUALS_HASH = 1 } - diff --git a/src/model/sign-p-k-c-s1v15-bytes-request.ts b/src/model/sign-pkcs1v15-bytes-request.ts similarity index 94% rename from src/model/sign-p-k-c-s1v15-bytes-request.ts rename to src/model/sign-pkcs1v15-bytes-request.ts index a4d0aaf..f93da4e 100644 --- a/src/model/sign-p-k-c-s1v15-bytes-request.ts +++ b/src/model/sign-pkcs1v15-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class SignPKCS1v15BytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignPKCS1v15BytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignPKCS1v15BytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-p-k-c-s1v15-request.ts b/src/model/sign-pkcs1v15-request.ts similarity index 93% rename from src/model/sign-p-k-c-s1v15-request.ts rename to src/model/sign-pkcs1v15-request.ts index 803f4e9..650505e 100644 --- a/src/model/sign-p-k-c-s1v15-request.ts +++ b/src/model/sign-pkcs1v15-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class SignPKCS1v15Request { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignPKCS1v15Request { + __init(i:number, bb:flatbuffers.ByteBuffer):SignPKCS1v15Request { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-p-s-s-bytes-request.ts b/src/model/sign-pssbytes-request.ts similarity index 95% rename from src/model/sign-p-s-s-bytes-request.ts rename to src/model/sign-pssbytes-request.ts index 4a93443..0630274 100644 --- a/src/model/sign-p-s-s-bytes-request.ts +++ b/src/model/sign-pssbytes-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 { Hash } from '../model/hash'; @@ -9,7 +11,7 @@ import { SaltLength } from '../model/salt-length'; export class SignPSSBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignPSSBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignPSSBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/sign-p-s-s-request.ts b/src/model/sign-pssrequest.ts similarity index 94% rename from src/model/sign-p-s-s-request.ts rename to src/model/sign-pssrequest.ts index 943e377..80162d3 100644 --- a/src/model/sign-p-s-s-request.ts +++ b/src/model/sign-pssrequest.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 { Hash } from '../model/hash'; @@ -9,7 +11,7 @@ import { SaltLength } from '../model/salt-length'; export class SignPSSRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):SignPSSRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):SignPSSRequest { 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-p-k-c-s1v15-bytes-request.ts b/src/model/verify-pkcs1v15-bytes-request.ts similarity index 95% rename from src/model/verify-p-k-c-s1v15-bytes-request.ts rename to src/model/verify-pkcs1v15-bytes-request.ts index 97a46c6..c6c4b57 100644 --- a/src/model/verify-p-k-c-s1v15-bytes-request.ts +++ b/src/model/verify-pkcs1v15-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class VerifyPKCS1v15BytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyPKCS1v15BytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyPKCS1v15BytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-p-k-c-s1v15-request.ts b/src/model/verify-pkcs1v15-request.ts similarity index 94% rename from src/model/verify-p-k-c-s1v15-request.ts rename to src/model/verify-pkcs1v15-request.ts index 328c34a..ba97061 100644 --- a/src/model/verify-p-k-c-s1v15-request.ts +++ b/src/model/verify-pkcs1v15-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 { Hash } from '../model/hash'; @@ -8,7 +10,7 @@ import { Hash } from '../model/hash'; export class VerifyPKCS1v15Request { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyPKCS1v15Request { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyPKCS1v15Request { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-p-s-s-bytes-request.ts b/src/model/verify-pssbytes-request.ts similarity index 96% rename from src/model/verify-p-s-s-bytes-request.ts rename to src/model/verify-pssbytes-request.ts index cdf095b..12570f0 100644 --- a/src/model/verify-p-s-s-bytes-request.ts +++ b/src/model/verify-pssbytes-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 { Hash } from '../model/hash'; @@ -9,7 +11,7 @@ import { SaltLength } from '../model/salt-length'; export class VerifyPSSBytesRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyPSSBytesRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyPSSBytesRequest { this.bb_pos = i; this.bb = bb; return this; diff --git a/src/model/verify-p-s-s-request.ts b/src/model/verify-pssrequest.ts similarity index 95% rename from src/model/verify-p-s-s-request.ts rename to src/model/verify-pssrequest.ts index b46c8fb..ca136b7 100644 --- a/src/model/verify-p-s-s-request.ts +++ b/src/model/verify-pssrequest.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 { Hash } from '../model/hash'; @@ -9,7 +11,7 @@ import { SaltLength } from '../model/salt-length'; export class VerifyPSSRequest { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; -__init(i:number, bb:flatbuffers.ByteBuffer):VerifyPSSRequest { + __init(i:number, bb:flatbuffers.ByteBuffer):VerifyPSSRequest { 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 589a5a0..c16bdbc 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 `FastRSANativeModules.callJSI` * @see `FastRSANativeModules.call` */ type BridgeResponseNativeModules = Array; @@ -27,14 +26,6 @@ type BridgeResponse = BridgeResponseNativeModules | BridgeResponseJSI; * Contains all method available inside of `NativeModules` */ interface FastRSANativeModules { - /** - * 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 // FastRSA:FastRSAJSI /** diff --git a/yarn.lock b/yarn.lock index 4cbe9ee..b68eace 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7720,10 +7720,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 @@ -13172,7 +13172,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 @@ -13180,6 +13180,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: @@ -14877,6 +14878,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"