@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,82 @@
|
|
|
1
|
+
#
|
|
2
|
+
# keychainmodule+autolinking.cmake
|
|
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
|
+
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
+
# to the current CMake project.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your CMakeLists.txt:
|
|
12
|
+
# ```cmake
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/keychainmodule+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_KEYCHAINMODULE_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
22
|
+
# Add all headers that were generated by Nitrogen
|
|
23
|
+
include_directories(
|
|
24
|
+
"../nitrogen/generated/shared/c++"
|
|
25
|
+
"../nitrogen/generated/android/c++"
|
|
26
|
+
"../nitrogen/generated/android/"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
+
target_sources(
|
|
31
|
+
# CMake project name (Android C++ library name)
|
|
32
|
+
keychainmodule PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/keychainmoduleOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridKeychainModuleSpec.cpp
|
|
37
|
+
# Android-specific Nitrogen C++ sources
|
|
38
|
+
../nitrogen/generated/android/c++/JHybridKeychainModuleSpec.cpp
|
|
39
|
+
../nitrogen/generated/android/c++/JVariant_NullType_GetItemResult.cpp
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
43
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
44
|
+
target_compile_definitions(
|
|
45
|
+
keychainmodule PRIVATE
|
|
46
|
+
-DFOLLY_NO_CONFIG=1
|
|
47
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
48
|
+
-DFOLLY_USE_LIBCPP=1
|
|
49
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
50
|
+
-DFOLLY_MOBILE=1
|
|
51
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
52
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
53
|
+
# Once we target android-23 above, we can comment
|
|
54
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
55
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# Add all libraries required by the generated specs
|
|
59
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
60
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
61
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
62
|
+
|
|
63
|
+
# Link all libraries together
|
|
64
|
+
target_link_libraries(
|
|
65
|
+
keychainmodule
|
|
66
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
67
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
68
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
72
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
73
|
+
target_link_libraries(
|
|
74
|
+
keychainmodule
|
|
75
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
76
|
+
)
|
|
77
|
+
else()
|
|
78
|
+
target_link_libraries(
|
|
79
|
+
keychainmodule
|
|
80
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
81
|
+
)
|
|
82
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// keychainmodule+autolinking.gradle
|
|
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
|
+
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
+
/// to the current Gradle project.
|
|
10
|
+
///
|
|
11
|
+
/// To use it, add this to your build.gradle:
|
|
12
|
+
/// ```gradle
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/keychainmodule+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 keychainmodule is boosted by nitro!")
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
sourceSets {
|
|
20
|
+
main {
|
|
21
|
+
java.srcDirs += [
|
|
22
|
+
// Nitrogen files
|
|
23
|
+
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// keychainmoduleOnLoad.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
|
+
#ifndef BUILDING_KEYCHAINMODULE_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error keychainmoduleOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "keychainmoduleOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridKeychainModuleSpec.hpp"
|
|
19
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::keychainmodule {
|
|
22
|
+
|
|
23
|
+
int initialize(JavaVM* vm) {
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
using namespace margelo::nitro::keychainmodule;
|
|
26
|
+
using namespace facebook;
|
|
27
|
+
|
|
28
|
+
return facebook::jni::initialize(vm, [] {
|
|
29
|
+
// Register native JNI methods
|
|
30
|
+
margelo::nitro::keychainmodule::JHybridKeychainModuleSpec::registerNatives();
|
|
31
|
+
|
|
32
|
+
// Register Nitro Hybrid Objects
|
|
33
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
34
|
+
"KeychainModule",
|
|
35
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
36
|
+
static DefaultConstructableObject<JHybridKeychainModuleSpec::javaobject> object("com/margelo/nitro/keychainmodule/KeychainModule");
|
|
37
|
+
auto instance = object.create();
|
|
38
|
+
return instance->cthis()->shared();
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// keychainmoduleOnLoad.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
|
+
#include <jni.h>
|
|
9
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
10
|
+
|
|
11
|
+
namespace margelo::nitro::keychainmodule {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the native (C++) part of keychainmodule, and autolinks all Hybrid Objects.
|
|
15
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
|
|
16
|
+
* Example:
|
|
17
|
+
* ```cpp (cpp-adapter.cpp)
|
|
18
|
+
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
+
* return margelo::nitro::keychainmodule::initialize(vm);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
int initialize(JavaVM* vm);
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GetItemParams.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "GetItemParams".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class GetItemParams(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val key: String
|
|
23
|
+
) {
|
|
24
|
+
/* primary constructor */
|
|
25
|
+
|
|
26
|
+
private companion object {
|
|
27
|
+
/**
|
|
28
|
+
* Constructor called from C++
|
|
29
|
+
*/
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
@Suppress("unused")
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private fun fromCpp(key: String): GetItemParams {
|
|
35
|
+
return GetItemParams(key)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GetItemResult.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "GetItemResult".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class GetItemResult(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val key: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val value: String
|
|
26
|
+
) {
|
|
27
|
+
/* primary constructor */
|
|
28
|
+
|
|
29
|
+
private companion object {
|
|
30
|
+
/**
|
|
31
|
+
* Constructor called from C++
|
|
32
|
+
*/
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
@Suppress("unused")
|
|
36
|
+
@JvmStatic
|
|
37
|
+
private fun fromCpp(key: String, value: String): GetItemResult {
|
|
38
|
+
return GetItemResult(key, value)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HasItemParams.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "HasItemParams".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class HasItemParams(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val key: String
|
|
23
|
+
) {
|
|
24
|
+
/* primary constructor */
|
|
25
|
+
|
|
26
|
+
private companion object {
|
|
27
|
+
/**
|
|
28
|
+
* Constructor called from C++
|
|
29
|
+
*/
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
@Suppress("unused")
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private fun fromCpp(key: String): HasItemParams {
|
|
35
|
+
return HasItemParams(key)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridKeychainModuleSpec.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.Promise
|
|
14
|
+
import com.margelo.nitro.core.NullType
|
|
15
|
+
import com.margelo.nitro.core.HybridObject
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A Kotlin class representing the KeychainModule HybridObject.
|
|
19
|
+
* Implement this abstract class to create Kotlin-based instances of KeychainModule.
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress(
|
|
24
|
+
"KotlinJniMissingFunction", "unused",
|
|
25
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
26
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
27
|
+
)
|
|
28
|
+
abstract class HybridKeychainModuleSpec: HybridObject() {
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
private var mHybridData: HybridData = initHybrid()
|
|
31
|
+
|
|
32
|
+
init {
|
|
33
|
+
super.updateNative(mHybridData)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override fun updateNative(hybridData: HybridData) {
|
|
37
|
+
mHybridData = hybridData
|
|
38
|
+
super.updateNative(hybridData)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Default implementation of `HybridObject.toString()`
|
|
42
|
+
override fun toString(): String {
|
|
43
|
+
return "[HybridObject KeychainModule]"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Properties
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// Methods
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
abstract fun setItem(params: SetItemParams): Promise<Boolean>
|
|
53
|
+
|
|
54
|
+
@DoNotStrip
|
|
55
|
+
@Keep
|
|
56
|
+
abstract fun getItem(params: GetItemParams): Promise<Variant_NullType_GetItemResult>
|
|
57
|
+
|
|
58
|
+
@DoNotStrip
|
|
59
|
+
@Keep
|
|
60
|
+
abstract fun removeItem(params: RemoveItemParams): Promise<Boolean>
|
|
61
|
+
|
|
62
|
+
@DoNotStrip
|
|
63
|
+
@Keep
|
|
64
|
+
abstract fun hasItem(params: HasItemParams): Promise<Boolean>
|
|
65
|
+
|
|
66
|
+
@DoNotStrip
|
|
67
|
+
@Keep
|
|
68
|
+
abstract fun isICloudSyncEnabled(): Promise<Boolean>
|
|
69
|
+
|
|
70
|
+
private external fun initHybrid(): HybridData
|
|
71
|
+
|
|
72
|
+
companion object {
|
|
73
|
+
protected const val TAG = "HybridKeychainModuleSpec"
|
|
74
|
+
}
|
|
75
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/RemoveItemParams.kt
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RemoveItemParams.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "RemoveItemParams".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class RemoveItemParams(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val key: String
|
|
23
|
+
) {
|
|
24
|
+
/* primary constructor */
|
|
25
|
+
|
|
26
|
+
private companion object {
|
|
27
|
+
/**
|
|
28
|
+
* Constructor called from C++
|
|
29
|
+
*/
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
@Suppress("unused")
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private fun fromCpp(key: String): RemoveItemParams {
|
|
35
|
+
return RemoveItemParams(key)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SetItemParams.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "SetItemParams".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class SetItemParams(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val key: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val value: String,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val enableSync: Boolean?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val label: String?,
|
|
32
|
+
@DoNotStrip
|
|
33
|
+
@Keep
|
|
34
|
+
val description: String?
|
|
35
|
+
) {
|
|
36
|
+
/* primary constructor */
|
|
37
|
+
|
|
38
|
+
private companion object {
|
|
39
|
+
/**
|
|
40
|
+
* Constructor called from C++
|
|
41
|
+
*/
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
@Keep
|
|
44
|
+
@Suppress("unused")
|
|
45
|
+
@JvmStatic
|
|
46
|
+
private fun fromCpp(key: String, value: String, enableSync: Boolean?, label: String?, description: String?): SetItemParams {
|
|
47
|
+
return SetItemParams(key, value, enableSync, label, description)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Variant_NullType_GetItemResult.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
11
|
+
import com.margelo.nitro.core.NullType
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the TypeScript variant "NullType | GetItemResult".
|
|
15
|
+
*/
|
|
16
|
+
@Suppress("ClassName")
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
sealed class Variant_NullType_GetItemResult {
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
data class First(@DoNotStrip val value: NullType): Variant_NullType_GetItemResult()
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
data class Second(@DoNotStrip val value: GetItemResult): Variant_NullType_GetItemResult()
|
|
23
|
+
|
|
24
|
+
@Deprecated("getAs() is not type-safe. Use fold/asFirstOrNull/asSecondOrNull instead.", level = DeprecationLevel.ERROR)
|
|
25
|
+
inline fun <reified T> getAs(): T? = when (this) {
|
|
26
|
+
is First -> value as? T
|
|
27
|
+
is Second -> value as? T
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
val isFirst: Boolean
|
|
31
|
+
get() = this is First
|
|
32
|
+
val isSecond: Boolean
|
|
33
|
+
get() = this is Second
|
|
34
|
+
|
|
35
|
+
fun asFirstOrNull(): NullType? {
|
|
36
|
+
val value = (this as? First)?.value ?: return null
|
|
37
|
+
return value
|
|
38
|
+
}
|
|
39
|
+
fun asSecondOrNull(): GetItemResult? {
|
|
40
|
+
val value = (this as? Second)?.value ?: return null
|
|
41
|
+
return value
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
inline fun <R> match(first: (NullType) -> R, second: (GetItemResult) -> R): R {
|
|
45
|
+
return when (this) {
|
|
46
|
+
is First -> first(value)
|
|
47
|
+
is Second -> second(value)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
companion object {
|
|
52
|
+
@JvmStatic
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
fun create(value: NullType): Variant_NullType_GetItemResult = First(value)
|
|
55
|
+
@JvmStatic
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
fun create(value: GetItemResult): Variant_NullType_GetItemResult = Second(value)
|
|
58
|
+
}
|
|
59
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/keychainmoduleOnLoad.kt
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// keychainmoduleOnLoad.kt
|
|
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
|
+
package com.margelo.nitro.keychainmodule
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class keychainmoduleOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "keychainmoduleOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "keychainmodule".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading keychainmodule C++ library...")
|
|
25
|
+
System.loadLibrary("keychainmodule")
|
|
26
|
+
Log.i(TAG, "Successfully loaded keychainmodule C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load keychainmodule C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# KeychainModule+autolinking.rb
|
|
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
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/KeychainModule+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 KeychainModule is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/KeychainModule-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only C)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
})
|
|
60
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// KeychainModule-Swift-Cxx-Bridge.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 "KeychainModule-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridKeychainModuleSpecSwift.hpp"
|
|
12
|
+
#include "KeychainModule-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::keychainmodule::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::function<void(bool /* result */)>
|
|
18
|
+
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = KeychainModule::Func_void_bool::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
|
|
21
|
+
swiftClosure.call(result);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
26
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
27
|
+
auto swiftClosure = KeychainModule::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
|
|
28
|
+
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
|
|
29
|
+
swiftClosure.call(error);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// pragma MARK: std::function<void(const std::variant<nitro::NullType, GetItemResult>& /* result */)>
|
|
34
|
+
Func_void_std__variant_nitro__NullType__GetItemResult_ create_Func_void_std__variant_nitro__NullType__GetItemResult_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
|
+
auto swiftClosure = KeychainModule::Func_void_std__variant_nitro__NullType__GetItemResult_::fromUnsafe(swiftClosureWrapper);
|
|
36
|
+
return [swiftClosure = std::move(swiftClosure)](const std::variant<nitro::NullType, GetItemResult>& result) mutable -> void {
|
|
37
|
+
swiftClosure.call(result);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// pragma MARK: std::shared_ptr<HybridKeychainModuleSpec>
|
|
42
|
+
std::shared_ptr<HybridKeychainModuleSpec> create_std__shared_ptr_HybridKeychainModuleSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
43
|
+
KeychainModule::HybridKeychainModuleSpec_cxx swiftPart = KeychainModule::HybridKeychainModuleSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
44
|
+
return std::make_shared<margelo::nitro::keychainmodule::HybridKeychainModuleSpecSwift>(swiftPart);
|
|
45
|
+
}
|
|
46
|
+
void* NON_NULL get_std__shared_ptr_HybridKeychainModuleSpec_(std__shared_ptr_HybridKeychainModuleSpec_ cppType) {
|
|
47
|
+
std::shared_ptr<margelo::nitro::keychainmodule::HybridKeychainModuleSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::keychainmodule::HybridKeychainModuleSpecSwift>(cppType);
|
|
48
|
+
#ifdef NITRO_DEBUG
|
|
49
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
50
|
+
throw std::runtime_error("Class \"HybridKeychainModuleSpec\" is not implemented in Swift!");
|
|
51
|
+
}
|
|
52
|
+
#endif
|
|
53
|
+
KeychainModule::HybridKeychainModuleSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
54
|
+
return swiftPart.toUnsafe();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::keychainmodule::bridge::swift
|