@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,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// 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
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::keychainmodule {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (GetItemResult).
|
|
34
|
+
*/
|
|
35
|
+
struct GetItemResult {
|
|
36
|
+
public:
|
|
37
|
+
std::string key SWIFT_PRIVATE;
|
|
38
|
+
std::string value SWIFT_PRIVATE;
|
|
39
|
+
|
|
40
|
+
public:
|
|
41
|
+
GetItemResult() = default;
|
|
42
|
+
explicit GetItemResult(std::string key, std::string value): key(key), value(value) {}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace margelo::nitro::keychainmodule
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro {
|
|
48
|
+
|
|
49
|
+
// C++ GetItemResult <> JS GetItemResult (object)
|
|
50
|
+
template <>
|
|
51
|
+
struct JSIConverter<margelo::nitro::keychainmodule::GetItemResult> final {
|
|
52
|
+
static inline margelo::nitro::keychainmodule::GetItemResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
53
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
54
|
+
return margelo::nitro::keychainmodule::GetItemResult(
|
|
55
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "key")),
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "value"))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::keychainmodule::GetItemResult& arg) {
|
|
60
|
+
jsi::Object obj(runtime);
|
|
61
|
+
obj.setProperty(runtime, "key", JSIConverter<std::string>::toJSI(runtime, arg.key));
|
|
62
|
+
obj.setProperty(runtime, "value", JSIConverter<std::string>::toJSI(runtime, arg.value));
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
66
|
+
if (!value.isObject()) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
jsi::Object obj = value.getObject(runtime);
|
|
70
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "key"))) return false;
|
|
74
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "value"))) return false;
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HasItemParams.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
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::keychainmodule {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (HasItemParams).
|
|
34
|
+
*/
|
|
35
|
+
struct HasItemParams {
|
|
36
|
+
public:
|
|
37
|
+
std::string key SWIFT_PRIVATE;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
HasItemParams() = default;
|
|
41
|
+
explicit HasItemParams(std::string key): key(key) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::keychainmodule
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
// C++ HasItemParams <> JS HasItemParams (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<margelo::nitro::keychainmodule::HasItemParams> final {
|
|
51
|
+
static inline margelo::nitro::keychainmodule::HasItemParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return margelo::nitro::keychainmodule::HasItemParams(
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "key"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::keychainmodule::HasItemParams& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "key", JSIConverter<std::string>::toJSI(runtime, arg.key));
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
63
|
+
if (!value.isObject()) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
jsi::Object obj = value.getObject(runtime);
|
|
67
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "key"))) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridKeychainModuleSpec.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 "HybridKeychainModuleSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::keychainmodule {
|
|
11
|
+
|
|
12
|
+
void HybridKeychainModuleSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("setItem", &HybridKeychainModuleSpec::setItem);
|
|
18
|
+
prototype.registerHybridMethod("getItem", &HybridKeychainModuleSpec::getItem);
|
|
19
|
+
prototype.registerHybridMethod("removeItem", &HybridKeychainModuleSpec::removeItem);
|
|
20
|
+
prototype.registerHybridMethod("hasItem", &HybridKeychainModuleSpec::hasItem);
|
|
21
|
+
prototype.registerHybridMethod("isICloudSyncEnabled", &HybridKeychainModuleSpec::isICloudSyncEnabled);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `SetItemParams` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::keychainmodule { struct SetItemParams; }
|
|
18
|
+
// Forward declaration of `GetItemResult` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::keychainmodule { struct GetItemResult; }
|
|
20
|
+
// Forward declaration of `GetItemParams` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::keychainmodule { struct GetItemParams; }
|
|
22
|
+
// Forward declaration of `RemoveItemParams` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::keychainmodule { struct RemoveItemParams; }
|
|
24
|
+
// Forward declaration of `HasItemParams` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::keychainmodule { struct HasItemParams; }
|
|
26
|
+
|
|
27
|
+
#include <NitroModules/Promise.hpp>
|
|
28
|
+
#include "SetItemParams.hpp"
|
|
29
|
+
#include <NitroModules/Null.hpp>
|
|
30
|
+
#include "GetItemResult.hpp"
|
|
31
|
+
#include <variant>
|
|
32
|
+
#include "GetItemParams.hpp"
|
|
33
|
+
#include "RemoveItemParams.hpp"
|
|
34
|
+
#include "HasItemParams.hpp"
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::keychainmodule {
|
|
37
|
+
|
|
38
|
+
using namespace margelo::nitro;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An abstract base class for `KeychainModule`
|
|
42
|
+
* Inherit this class to create instances of `HybridKeychainModuleSpec` in C++.
|
|
43
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
44
|
+
* @example
|
|
45
|
+
* ```cpp
|
|
46
|
+
* class HybridKeychainModule: public HybridKeychainModuleSpec {
|
|
47
|
+
* public:
|
|
48
|
+
* HybridKeychainModule(...): HybridObject(TAG) { ... }
|
|
49
|
+
* // ...
|
|
50
|
+
* };
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
class HybridKeychainModuleSpec: public virtual HybridObject {
|
|
54
|
+
public:
|
|
55
|
+
// Constructor
|
|
56
|
+
explicit HybridKeychainModuleSpec(): HybridObject(TAG) { }
|
|
57
|
+
|
|
58
|
+
// Destructor
|
|
59
|
+
~HybridKeychainModuleSpec() override = default;
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
// Properties
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Methods
|
|
67
|
+
virtual std::shared_ptr<Promise<bool>> setItem(const SetItemParams& params) = 0;
|
|
68
|
+
virtual std::shared_ptr<Promise<std::variant<nitro::NullType, GetItemResult>>> getItem(const GetItemParams& params) = 0;
|
|
69
|
+
virtual std::shared_ptr<Promise<bool>> removeItem(const RemoveItemParams& params) = 0;
|
|
70
|
+
virtual std::shared_ptr<Promise<bool>> hasItem(const HasItemParams& params) = 0;
|
|
71
|
+
virtual std::shared_ptr<Promise<bool>> isICloudSyncEnabled() = 0;
|
|
72
|
+
|
|
73
|
+
protected:
|
|
74
|
+
// Hybrid Setup
|
|
75
|
+
void loadHybridMethods() override;
|
|
76
|
+
|
|
77
|
+
protected:
|
|
78
|
+
// Tag for logging
|
|
79
|
+
static constexpr auto TAG = "KeychainModule";
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
} // namespace margelo::nitro::keychainmodule
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RemoveItemParams.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
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::keychainmodule {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (RemoveItemParams).
|
|
34
|
+
*/
|
|
35
|
+
struct RemoveItemParams {
|
|
36
|
+
public:
|
|
37
|
+
std::string key SWIFT_PRIVATE;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
RemoveItemParams() = default;
|
|
41
|
+
explicit RemoveItemParams(std::string key): key(key) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::keychainmodule
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
// C++ RemoveItemParams <> JS RemoveItemParams (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<margelo::nitro::keychainmodule::RemoveItemParams> final {
|
|
51
|
+
static inline margelo::nitro::keychainmodule::RemoveItemParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return margelo::nitro::keychainmodule::RemoveItemParams(
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "key"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::keychainmodule::RemoveItemParams& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "key", JSIConverter<std::string>::toJSI(runtime, arg.key));
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
63
|
+
if (!value.isObject()) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
jsi::Object obj = value.getObject(runtime);
|
|
67
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "key"))) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SetItemParams.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
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::keychainmodule {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (SetItemParams).
|
|
35
|
+
*/
|
|
36
|
+
struct SetItemParams {
|
|
37
|
+
public:
|
|
38
|
+
std::string key SWIFT_PRIVATE;
|
|
39
|
+
std::string value SWIFT_PRIVATE;
|
|
40
|
+
std::optional<bool> enableSync SWIFT_PRIVATE;
|
|
41
|
+
std::optional<std::string> label SWIFT_PRIVATE;
|
|
42
|
+
std::optional<std::string> description SWIFT_PRIVATE;
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
SetItemParams() = default;
|
|
46
|
+
explicit SetItemParams(std::string key, std::string value, std::optional<bool> enableSync, std::optional<std::string> label, std::optional<std::string> description): key(key), value(value), enableSync(enableSync), label(label), description(description) {}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace margelo::nitro::keychainmodule
|
|
50
|
+
|
|
51
|
+
namespace margelo::nitro {
|
|
52
|
+
|
|
53
|
+
// C++ SetItemParams <> JS SetItemParams (object)
|
|
54
|
+
template <>
|
|
55
|
+
struct JSIConverter<margelo::nitro::keychainmodule::SetItemParams> final {
|
|
56
|
+
static inline margelo::nitro::keychainmodule::SetItemParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
57
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
58
|
+
return margelo::nitro::keychainmodule::SetItemParams(
|
|
59
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "key")),
|
|
60
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "value")),
|
|
61
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "enableSync")),
|
|
62
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "label")),
|
|
63
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "description"))
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::keychainmodule::SetItemParams& arg) {
|
|
67
|
+
jsi::Object obj(runtime);
|
|
68
|
+
obj.setProperty(runtime, "key", JSIConverter<std::string>::toJSI(runtime, arg.key));
|
|
69
|
+
obj.setProperty(runtime, "value", JSIConverter<std::string>::toJSI(runtime, arg.value));
|
|
70
|
+
obj.setProperty(runtime, "enableSync", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.enableSync));
|
|
71
|
+
obj.setProperty(runtime, "label", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.label));
|
|
72
|
+
obj.setProperty(runtime, "description", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.description));
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
76
|
+
if (!value.isObject()) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
jsi::Object obj = value.getObject(runtime);
|
|
80
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "key"))) return false;
|
|
84
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "value"))) return false;
|
|
85
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "enableSync"))) return false;
|
|
86
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "label"))) return false;
|
|
87
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "description"))) return false;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/react-native-keychain-module",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "react-native-keychain-module",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"example": "yarn workspace react-native-keychain-module-example",
|
|
38
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
39
|
+
"prepare": "bob build",
|
|
40
|
+
"nitrogen": "nitrogen",
|
|
41
|
+
"typecheck": "tsc",
|
|
42
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
43
|
+
"test": "jest",
|
|
44
|
+
"release": "yarn prepare && npm whoami && npm publish --access public"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react-native",
|
|
48
|
+
"ios",
|
|
49
|
+
"android"
|
|
50
|
+
],
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/OneKeyHQ/app-modules/react-native-keychain-module.git"
|
|
54
|
+
},
|
|
55
|
+
"author": "onekeyfe <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/OneKeyHQ/app-modules/react-native-keychain-module/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/OneKeyHQ/app-modules/react-native-keychain-module#readme",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
66
|
+
"@eslint/compat": "^1.3.2",
|
|
67
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
68
|
+
"@eslint/js": "^9.35.0",
|
|
69
|
+
"@react-native/babel-preset": "0.83.0",
|
|
70
|
+
"@react-native/eslint-config": "0.83.0",
|
|
71
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
72
|
+
"@types/jest": "^29.5.14",
|
|
73
|
+
"@types/react": "^19.2.0",
|
|
74
|
+
"commitlint": "^19.8.1",
|
|
75
|
+
"del-cli": "^6.0.0",
|
|
76
|
+
"eslint": "^9.35.0",
|
|
77
|
+
"eslint-config-prettier": "^10.1.8",
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"lefthook": "^2.0.3",
|
|
81
|
+
"nitrogen": "^0.31.10",
|
|
82
|
+
"prettier": "^2.8.8",
|
|
83
|
+
"react": "19.2.0",
|
|
84
|
+
"react-native": "0.83.0",
|
|
85
|
+
"react-native-builder-bob": "^0.40.13",
|
|
86
|
+
"react-native-nitro-modules": "^0.31.10",
|
|
87
|
+
"release-it": "^19.0.4",
|
|
88
|
+
"turbo": "^2.5.6",
|
|
89
|
+
"typescript": "^5.9.2"
|
|
90
|
+
},
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"react": "*",
|
|
93
|
+
"react-native": "*",
|
|
94
|
+
"react-native-nitro-modules": "^0.31.10"
|
|
95
|
+
},
|
|
96
|
+
"workspaces": [
|
|
97
|
+
"example"
|
|
98
|
+
],
|
|
99
|
+
"packageManager": "yarn@4.11.0",
|
|
100
|
+
"react-native-builder-bob": {
|
|
101
|
+
"source": "src",
|
|
102
|
+
"output": "lib",
|
|
103
|
+
"targets": [
|
|
104
|
+
[
|
|
105
|
+
"custom",
|
|
106
|
+
{
|
|
107
|
+
"script": "nitrogen",
|
|
108
|
+
"clean": "nitrogen/"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"module",
|
|
113
|
+
{
|
|
114
|
+
"esm": true
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"typescript",
|
|
119
|
+
{
|
|
120
|
+
"project": "tsconfig.build.json"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"prettier": {
|
|
126
|
+
"quoteProps": "consistent",
|
|
127
|
+
"singleQuote": true,
|
|
128
|
+
"tabWidth": 2,
|
|
129
|
+
"trailingComma": "es5",
|
|
130
|
+
"useTabs": false
|
|
131
|
+
},
|
|
132
|
+
"jest": {
|
|
133
|
+
"preset": "react-native",
|
|
134
|
+
"modulePathIgnorePatterns": [
|
|
135
|
+
"<rootDir>/example/node_modules",
|
|
136
|
+
"<rootDir>/lib/"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"commitlint": {
|
|
140
|
+
"extends": [
|
|
141
|
+
"@commitlint/config-conventional"
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"release-it": {
|
|
145
|
+
"git": {
|
|
146
|
+
"commitMessage": "chore: release ${version}",
|
|
147
|
+
"tagName": "v${version}"
|
|
148
|
+
},
|
|
149
|
+
"npm": {
|
|
150
|
+
"publish": true
|
|
151
|
+
},
|
|
152
|
+
"github": {
|
|
153
|
+
"release": true
|
|
154
|
+
},
|
|
155
|
+
"plugins": {
|
|
156
|
+
"@release-it/conventional-changelog": {
|
|
157
|
+
"preset": {
|
|
158
|
+
"name": "angular"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"create-react-native-library": {
|
|
164
|
+
"type": "nitro-module",
|
|
165
|
+
"languages": "kotlin-swift",
|
|
166
|
+
"tools": [
|
|
167
|
+
"eslint",
|
|
168
|
+
"jest",
|
|
169
|
+
"lefthook",
|
|
170
|
+
"release-it"
|
|
171
|
+
],
|
|
172
|
+
"version": "0.56.0"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface SetItemParams {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
enableSync?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface GetItemParams {
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface RemoveItemParams {
|
|
16
|
+
key: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface HasItemParams {
|
|
20
|
+
key: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GetItemResult {
|
|
24
|
+
key: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface KeychainModule
|
|
29
|
+
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
30
|
+
setItem(params: SetItemParams): Promise<boolean>;
|
|
31
|
+
getItem(params: GetItemParams): Promise<GetItemResult | null>;
|
|
32
|
+
removeItem(params: RemoveItemParams): Promise<boolean>;
|
|
33
|
+
hasItem(params: HasItemParams): Promise<boolean>;
|
|
34
|
+
isICloudSyncEnabled(): Promise<boolean>;
|
|
35
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { KeychainModule as KeychainModuleType } from './KeychainModule.nitro';
|
|
3
|
+
|
|
4
|
+
const KeychainModuleHybridObject =
|
|
5
|
+
NitroModules.createHybridObject<KeychainModuleType>('KeychainModule');
|
|
6
|
+
|
|
7
|
+
export const KeychainModule = KeychainModuleHybridObject;
|
|
8
|
+
export type * from './KeychainModule.nitro';
|