@onekeyfe/react-native-keychain-module 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/KeychainModule.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +39 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/keychainmodule/KeychainModule.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/keychainmodule/KeychainModulePackage.kt +22 -0
- package/ios/KeychainModule.swift +81 -0
- package/ios/KeychainModuleCore.swift +174 -0
- package/lib/module/KeychainModule.nitro.js +4 -0
- package/lib/module/KeychainModule.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/KeychainModule.nitro.d.ts +32 -0
- package/lib/typescript/src/KeychainModule.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JGetItemParams.hpp +57 -0
- package/nitrogen/generated/android/c++/JGetItemResult.hpp +61 -0
- package/nitrogen/generated/android/c++/JHasItemParams.hpp +57 -0
- package/nitrogen/generated/android/c++/JHybridKeychainModuleSpec.cpp +153 -0
- package/nitrogen/generated/android/c++/JHybridKeychainModuleSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JRemoveItemParams.hpp +57 -0
- package/nitrogen/generated/android/c++/JSetItemParams.hpp +74 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_GetItemResult.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_GetItemResult.hpp +72 -0
- package/nitrogen/generated/android/keychainmodule+autolinking.cmake +82 -0
- package/nitrogen/generated/android/keychainmodule+autolinking.gradle +27 -0
- package/nitrogen/generated/android/keychainmoduleOnLoad.cpp +44 -0
- package/nitrogen/generated/android/keychainmoduleOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/GetItemParams.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/GetItemResult.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/HasItemParams.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/HybridKeychainModuleSpec.kt +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/RemoveItemParams.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/SetItemParams.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/Variant_NullType_GetItemResult.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/keychainmoduleOnLoad.kt +35 -0
- package/nitrogen/generated/ios/KeychainModule+autolinking.rb +60 -0
- package/nitrogen/generated/ios/KeychainModule-Swift-Cxx-Bridge.cpp +57 -0
- package/nitrogen/generated/ios/KeychainModule-Swift-Cxx-Bridge.hpp +219 -0
- package/nitrogen/generated/ios/KeychainModule-Swift-Cxx-Umbrella.hpp +63 -0
- package/nitrogen/generated/ios/KeychainModuleAutolinking.mm +33 -0
- package/nitrogen/generated/ios/KeychainModuleAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridKeychainModuleSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridKeychainModuleSpecSwift.hpp +126 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__GetItemResult_.swift +59 -0
- package/nitrogen/generated/ios/swift/GetItemParams.swift +36 -0
- package/nitrogen/generated/ios/swift/GetItemResult.swift +47 -0
- package/nitrogen/generated/ios/swift/HasItemParams.swift +36 -0
- package/nitrogen/generated/ios/swift/HybridKeychainModuleSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridKeychainModuleSpec_cxx.swift +221 -0
- package/nitrogen/generated/ios/swift/RemoveItemParams.swift +36 -0
- package/nitrogen/generated/ios/swift/SetItemParams.swift +137 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_GetItemResult.swift +18 -0
- package/nitrogen/generated/shared/c++/GetItemParams.hpp +75 -0
- package/nitrogen/generated/shared/c++/GetItemResult.hpp +79 -0
- package/nitrogen/generated/shared/c++/HasItemParams.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridKeychainModuleSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridKeychainModuleSpec.hpp +82 -0
- package/nitrogen/generated/shared/c++/RemoveItemParams.hpp +75 -0
- package/nitrogen/generated/shared/c++/SetItemParams.hpp +92 -0
- package/package.json +174 -0
- package/src/KeychainModule.nitro.ts +35 -0
- package/src/index.tsx +8 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGetItemParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "GetItemParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::keychainmodule {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "GetItemParams" and the the Kotlin data class "GetItemParams".
|
|
21
|
+
*/
|
|
22
|
+
struct JGetItemParams final: public jni::JavaClass<JGetItemParams> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/GetItemParams;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct GetItemParams by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
GetItemParams toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldKey = clazz->getField<jni::JString>("key");
|
|
35
|
+
jni::local_ref<jni::JString> key = this->getFieldValue(fieldKey);
|
|
36
|
+
return GetItemParams(
|
|
37
|
+
key->toStdString()
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
/**
|
|
43
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
44
|
+
*/
|
|
45
|
+
[[maybe_unused]]
|
|
46
|
+
static jni::local_ref<JGetItemParams::javaobject> fromCpp(const GetItemParams& value) {
|
|
47
|
+
using JSignature = JGetItemParams(jni::alias_ref<jni::JString>);
|
|
48
|
+
static const auto clazz = javaClassStatic();
|
|
49
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
50
|
+
return create(
|
|
51
|
+
clazz,
|
|
52
|
+
jni::make_jstring(value.key)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGetItemResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "GetItemResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::keychainmodule {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "GetItemResult" and the the Kotlin data class "GetItemResult".
|
|
21
|
+
*/
|
|
22
|
+
struct JGetItemResult final: public jni::JavaClass<JGetItemResult> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/GetItemResult;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct GetItemResult by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
GetItemResult toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldKey = clazz->getField<jni::JString>("key");
|
|
35
|
+
jni::local_ref<jni::JString> key = this->getFieldValue(fieldKey);
|
|
36
|
+
static const auto fieldValue = clazz->getField<jni::JString>("value");
|
|
37
|
+
jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
|
|
38
|
+
return GetItemResult(
|
|
39
|
+
key->toStdString(),
|
|
40
|
+
value->toStdString()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JGetItemResult::javaobject> fromCpp(const GetItemResult& value) {
|
|
50
|
+
using JSignature = JGetItemResult(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
|
51
|
+
static const auto clazz = javaClassStatic();
|
|
52
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
|
+
return create(
|
|
54
|
+
clazz,
|
|
55
|
+
jni::make_jstring(value.key),
|
|
56
|
+
jni::make_jstring(value.value)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHasItemParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HasItemParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::keychainmodule {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "HasItemParams" and the the Kotlin data class "HasItemParams".
|
|
21
|
+
*/
|
|
22
|
+
struct JHasItemParams final: public jni::JavaClass<JHasItemParams> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/HasItemParams;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct HasItemParams by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
HasItemParams toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldKey = clazz->getField<jni::JString>("key");
|
|
35
|
+
jni::local_ref<jni::JString> key = this->getFieldValue(fieldKey);
|
|
36
|
+
return HasItemParams(
|
|
37
|
+
key->toStdString()
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
/**
|
|
43
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
44
|
+
*/
|
|
45
|
+
[[maybe_unused]]
|
|
46
|
+
static jni::local_ref<JHasItemParams::javaobject> fromCpp(const HasItemParams& value) {
|
|
47
|
+
using JSignature = JHasItemParams(jni::alias_ref<jni::JString>);
|
|
48
|
+
static const auto clazz = javaClassStatic();
|
|
49
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
50
|
+
return create(
|
|
51
|
+
clazz,
|
|
52
|
+
jni::make_jstring(value.key)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridKeychainModuleSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridKeychainModuleSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `GetItemResult` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::keychainmodule { struct GetItemResult; }
|
|
12
|
+
// Forward declaration of `SetItemParams` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::keychainmodule { struct SetItemParams; }
|
|
14
|
+
// Forward declaration of `GetItemParams` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::keychainmodule { struct GetItemParams; }
|
|
16
|
+
// Forward declaration of `RemoveItemParams` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::keychainmodule { struct RemoveItemParams; }
|
|
18
|
+
// Forward declaration of `HasItemParams` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::keychainmodule { struct HasItemParams; }
|
|
20
|
+
|
|
21
|
+
#include <NitroModules/Promise.hpp>
|
|
22
|
+
#include <NitroModules/JPromise.hpp>
|
|
23
|
+
#include <NitroModules/Null.hpp>
|
|
24
|
+
#include "GetItemResult.hpp"
|
|
25
|
+
#include <variant>
|
|
26
|
+
#include "JVariant_NullType_GetItemResult.hpp"
|
|
27
|
+
#include <NitroModules/JNull.hpp>
|
|
28
|
+
#include "JGetItemResult.hpp"
|
|
29
|
+
#include <string>
|
|
30
|
+
#include "SetItemParams.hpp"
|
|
31
|
+
#include "JSetItemParams.hpp"
|
|
32
|
+
#include <optional>
|
|
33
|
+
#include "GetItemParams.hpp"
|
|
34
|
+
#include "JGetItemParams.hpp"
|
|
35
|
+
#include "RemoveItemParams.hpp"
|
|
36
|
+
#include "JRemoveItemParams.hpp"
|
|
37
|
+
#include "HasItemParams.hpp"
|
|
38
|
+
#include "JHasItemParams.hpp"
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro::keychainmodule {
|
|
41
|
+
|
|
42
|
+
jni::local_ref<JHybridKeychainModuleSpec::jhybriddata> JHybridKeychainModuleSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
43
|
+
return makeCxxInstance(jThis);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void JHybridKeychainModuleSpec::registerNatives() {
|
|
47
|
+
registerHybrid({
|
|
48
|
+
makeNativeMethod("initHybrid", JHybridKeychainModuleSpec::initHybrid),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
size_t JHybridKeychainModuleSpec::getExternalMemorySize() noexcept {
|
|
53
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
54
|
+
return method(_javaPart);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void JHybridKeychainModuleSpec::dispose() noexcept {
|
|
58
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
59
|
+
method(_javaPart);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
std::string JHybridKeychainModuleSpec::toString() {
|
|
63
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
64
|
+
auto javaString = method(_javaPart);
|
|
65
|
+
return javaString->toStdString();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Properties
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// Methods
|
|
72
|
+
std::shared_ptr<Promise<bool>> JHybridKeychainModuleSpec::setItem(const SetItemParams& params) {
|
|
73
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JSetItemParams> /* params */)>("setItem");
|
|
74
|
+
auto __result = method(_javaPart, JSetItemParams::fromCpp(params));
|
|
75
|
+
return [&]() {
|
|
76
|
+
auto __promise = Promise<bool>::create();
|
|
77
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
78
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
79
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
80
|
+
});
|
|
81
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
82
|
+
jni::JniException __jniError(__throwable);
|
|
83
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
84
|
+
});
|
|
85
|
+
return __promise;
|
|
86
|
+
}();
|
|
87
|
+
}
|
|
88
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, GetItemResult>>> JHybridKeychainModuleSpec::getItem(const GetItemParams& params) {
|
|
89
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JGetItemParams> /* params */)>("getItem");
|
|
90
|
+
auto __result = method(_javaPart, JGetItemParams::fromCpp(params));
|
|
91
|
+
return [&]() {
|
|
92
|
+
auto __promise = Promise<std::variant<nitro::NullType, GetItemResult>>::create();
|
|
93
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
94
|
+
auto __result = jni::static_ref_cast<JVariant_NullType_GetItemResult>(__boxedResult);
|
|
95
|
+
__promise->resolve(__result->toCpp());
|
|
96
|
+
});
|
|
97
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
98
|
+
jni::JniException __jniError(__throwable);
|
|
99
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
100
|
+
});
|
|
101
|
+
return __promise;
|
|
102
|
+
}();
|
|
103
|
+
}
|
|
104
|
+
std::shared_ptr<Promise<bool>> JHybridKeychainModuleSpec::removeItem(const RemoveItemParams& params) {
|
|
105
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JRemoveItemParams> /* params */)>("removeItem");
|
|
106
|
+
auto __result = method(_javaPart, JRemoveItemParams::fromCpp(params));
|
|
107
|
+
return [&]() {
|
|
108
|
+
auto __promise = Promise<bool>::create();
|
|
109
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
110
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
111
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
112
|
+
});
|
|
113
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
114
|
+
jni::JniException __jniError(__throwable);
|
|
115
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
116
|
+
});
|
|
117
|
+
return __promise;
|
|
118
|
+
}();
|
|
119
|
+
}
|
|
120
|
+
std::shared_ptr<Promise<bool>> JHybridKeychainModuleSpec::hasItem(const HasItemParams& params) {
|
|
121
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JHasItemParams> /* params */)>("hasItem");
|
|
122
|
+
auto __result = method(_javaPart, JHasItemParams::fromCpp(params));
|
|
123
|
+
return [&]() {
|
|
124
|
+
auto __promise = Promise<bool>::create();
|
|
125
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
126
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
127
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
128
|
+
});
|
|
129
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
130
|
+
jni::JniException __jniError(__throwable);
|
|
131
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
132
|
+
});
|
|
133
|
+
return __promise;
|
|
134
|
+
}();
|
|
135
|
+
}
|
|
136
|
+
std::shared_ptr<Promise<bool>> JHybridKeychainModuleSpec::isICloudSyncEnabled() {
|
|
137
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isICloudSyncEnabled");
|
|
138
|
+
auto __result = method(_javaPart);
|
|
139
|
+
return [&]() {
|
|
140
|
+
auto __promise = Promise<bool>::create();
|
|
141
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
142
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
143
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
144
|
+
});
|
|
145
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
146
|
+
jni::JniException __jniError(__throwable);
|
|
147
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
148
|
+
});
|
|
149
|
+
return __promise;
|
|
150
|
+
}();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridKeychainModuleSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridKeychainModuleSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::keychainmodule {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridKeychainModuleSpec: public jni::HybridClass<JHybridKeychainModuleSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridKeychainModuleSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/HybridKeychainModuleSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridKeychainModuleSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridKeychainModuleSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridKeychainModuleSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
void dispose() noexcept override;
|
|
44
|
+
std::string toString() override;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridKeychainModuleSpec::javaobject>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
std::shared_ptr<Promise<bool>> setItem(const SetItemParams& params) override;
|
|
58
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, GetItemResult>>> getItem(const GetItemParams& params) override;
|
|
59
|
+
std::shared_ptr<Promise<bool>> removeItem(const RemoveItemParams& params) override;
|
|
60
|
+
std::shared_ptr<Promise<bool>> hasItem(const HasItemParams& params) override;
|
|
61
|
+
std::shared_ptr<Promise<bool>> isICloudSyncEnabled() override;
|
|
62
|
+
|
|
63
|
+
private:
|
|
64
|
+
friend HybridBase;
|
|
65
|
+
using HybridBase::HybridBase;
|
|
66
|
+
jni::global_ref<JHybridKeychainModuleSpec::javaobject> _javaPart;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JRemoveItemParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "RemoveItemParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::keychainmodule {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "RemoveItemParams" and the the Kotlin data class "RemoveItemParams".
|
|
21
|
+
*/
|
|
22
|
+
struct JRemoveItemParams final: public jni::JavaClass<JRemoveItemParams> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/RemoveItemParams;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct RemoveItemParams by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
RemoveItemParams toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldKey = clazz->getField<jni::JString>("key");
|
|
35
|
+
jni::local_ref<jni::JString> key = this->getFieldValue(fieldKey);
|
|
36
|
+
return RemoveItemParams(
|
|
37
|
+
key->toStdString()
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
/**
|
|
43
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
44
|
+
*/
|
|
45
|
+
[[maybe_unused]]
|
|
46
|
+
static jni::local_ref<JRemoveItemParams::javaobject> fromCpp(const RemoveItemParams& value) {
|
|
47
|
+
using JSignature = JRemoveItemParams(jni::alias_ref<jni::JString>);
|
|
48
|
+
static const auto clazz = javaClassStatic();
|
|
49
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
50
|
+
return create(
|
|
51
|
+
clazz,
|
|
52
|
+
jni::make_jstring(value.key)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSetItemParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "SetItemParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::keychainmodule {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "SetItemParams" and the the Kotlin data class "SetItemParams".
|
|
22
|
+
*/
|
|
23
|
+
struct JSetItemParams final: public jni::JavaClass<JSetItemParams> {
|
|
24
|
+
public:
|
|
25
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/SetItemParams;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SetItemParams by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
SetItemParams toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldKey = clazz->getField<jni::JString>("key");
|
|
36
|
+
jni::local_ref<jni::JString> key = this->getFieldValue(fieldKey);
|
|
37
|
+
static const auto fieldValue = clazz->getField<jni::JString>("value");
|
|
38
|
+
jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
|
|
39
|
+
static const auto fieldEnableSync = clazz->getField<jni::JBoolean>("enableSync");
|
|
40
|
+
jni::local_ref<jni::JBoolean> enableSync = this->getFieldValue(fieldEnableSync);
|
|
41
|
+
static const auto fieldLabel = clazz->getField<jni::JString>("label");
|
|
42
|
+
jni::local_ref<jni::JString> label = this->getFieldValue(fieldLabel);
|
|
43
|
+
static const auto fieldDescription = clazz->getField<jni::JString>("description");
|
|
44
|
+
jni::local_ref<jni::JString> description = this->getFieldValue(fieldDescription);
|
|
45
|
+
return SetItemParams(
|
|
46
|
+
key->toStdString(),
|
|
47
|
+
value->toStdString(),
|
|
48
|
+
enableSync != nullptr ? std::make_optional(static_cast<bool>(enableSync->value())) : std::nullopt,
|
|
49
|
+
label != nullptr ? std::make_optional(label->toStdString()) : std::nullopt,
|
|
50
|
+
description != nullptr ? std::make_optional(description->toStdString()) : std::nullopt
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
/**
|
|
56
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
57
|
+
*/
|
|
58
|
+
[[maybe_unused]]
|
|
59
|
+
static jni::local_ref<JSetItemParams::javaobject> fromCpp(const SetItemParams& value) {
|
|
60
|
+
using JSignature = JSetItemParams(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
|
61
|
+
static const auto clazz = javaClassStatic();
|
|
62
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
63
|
+
return create(
|
|
64
|
+
clazz,
|
|
65
|
+
jni::make_jstring(value.key),
|
|
66
|
+
jni::make_jstring(value.value),
|
|
67
|
+
value.enableSync.has_value() ? jni::JBoolean::valueOf(value.enableSync.value()) : nullptr,
|
|
68
|
+
value.label.has_value() ? jni::make_jstring(value.label.value()) : nullptr,
|
|
69
|
+
value.description.has_value() ? jni::make_jstring(value.description.value()) : nullptr
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_NullType_GetItemResult.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JVariant_NullType_GetItemResult.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::keychainmodule {
|
|
11
|
+
/**
|
|
12
|
+
* Converts JVariant_NullType_GetItemResult to std::variant<nitro::NullType, GetItemResult>
|
|
13
|
+
*/
|
|
14
|
+
std::variant<nitro::NullType, GetItemResult> JVariant_NullType_GetItemResult::toCpp() const {
|
|
15
|
+
if (isInstanceOf(JVariant_NullType_GetItemResult_impl::First::javaClassStatic())) {
|
|
16
|
+
// It's a `nitro::NullType`
|
|
17
|
+
auto jniValue = static_cast<const JVariant_NullType_GetItemResult_impl::First*>(this)->getValue();
|
|
18
|
+
return nitro::null;
|
|
19
|
+
} else if (isInstanceOf(JVariant_NullType_GetItemResult_impl::Second::javaClassStatic())) {
|
|
20
|
+
// It's a `GetItemResult`
|
|
21
|
+
auto jniValue = static_cast<const JVariant_NullType_GetItemResult_impl::Second*>(this)->getValue();
|
|
22
|
+
return jniValue->toCpp();
|
|
23
|
+
}
|
|
24
|
+
throw std::invalid_argument("Variant is unknown Kotlin instance!");
|
|
25
|
+
}
|
|
26
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_NullType_GetItemResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/Null.hpp>
|
|
14
|
+
#include "GetItemResult.hpp"
|
|
15
|
+
#include <variant>
|
|
16
|
+
#include <NitroModules/JNull.hpp>
|
|
17
|
+
#include "JGetItemResult.hpp"
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::keychainmodule {
|
|
21
|
+
|
|
22
|
+
using namespace facebook;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_GetItemResult".
|
|
26
|
+
*/
|
|
27
|
+
class JVariant_NullType_GetItemResult: public jni::JavaClass<JVariant_NullType_GetItemResult> {
|
|
28
|
+
public:
|
|
29
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/Variant_NullType_GetItemResult;";
|
|
30
|
+
|
|
31
|
+
static jni::local_ref<JVariant_NullType_GetItemResult> create_0(jni::alias_ref<JNull> value) {
|
|
32
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_GetItemResult(jni::alias_ref<JNull>)>("create");
|
|
33
|
+
return method(javaClassStatic(), value);
|
|
34
|
+
}
|
|
35
|
+
static jni::local_ref<JVariant_NullType_GetItemResult> create_1(jni::alias_ref<JGetItemResult> value) {
|
|
36
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_GetItemResult(jni::alias_ref<JGetItemResult>)>("create");
|
|
37
|
+
return method(javaClassStatic(), value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static jni::local_ref<JVariant_NullType_GetItemResult> fromCpp(const std::variant<nitro::NullType, GetItemResult>& variant) {
|
|
41
|
+
switch (variant.index()) {
|
|
42
|
+
case 0: return create_0(JNull::null());
|
|
43
|
+
case 1: return create_1(JGetItemResult::fromCpp(std::get<1>(variant)));
|
|
44
|
+
default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[[nodiscard]] std::variant<nitro::NullType, GetItemResult> toCpp() const;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
namespace JVariant_NullType_GetItemResult_impl {
|
|
52
|
+
class First: public jni::JavaClass<First, JVariant_NullType_GetItemResult> {
|
|
53
|
+
public:
|
|
54
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/Variant_NullType_GetItemResult$First;";
|
|
55
|
+
|
|
56
|
+
[[nodiscard]] jni::local_ref<JNull> getValue() const {
|
|
57
|
+
static const auto field = javaClassStatic()->getField<JNull>("value");
|
|
58
|
+
return getFieldValue(field);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
class Second: public jni::JavaClass<Second, JVariant_NullType_GetItemResult> {
|
|
63
|
+
public:
|
|
64
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/keychainmodule/Variant_NullType_GetItemResult$Second;";
|
|
65
|
+
|
|
66
|
+
[[nodiscard]] jni::local_ref<JGetItemResult> getValue() const {
|
|
67
|
+
static const auto field = javaClassStatic()->getField<JGetItemResult>("value");
|
|
68
|
+
return getFieldValue(field);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
} // namespace JVariant_NullType_GetItemResult_impl
|
|
72
|
+
} // namespace margelo::nitro::keychainmodule
|