@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.
Files changed (73) hide show
  1. package/KeychainModule.podspec +29 -0
  2. package/LICENSE +20 -0
  3. package/README.md +39 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +128 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  9. package/android/src/main/java/com/margelo/nitro/keychainmodule/KeychainModule.kt +28 -0
  10. package/android/src/main/java/com/margelo/nitro/keychainmodule/KeychainModulePackage.kt +22 -0
  11. package/ios/KeychainModule.swift +81 -0
  12. package/ios/KeychainModuleCore.swift +174 -0
  13. package/lib/module/KeychainModule.nitro.js +4 -0
  14. package/lib/module/KeychainModule.nitro.js.map +1 -0
  15. package/lib/module/index.js +6 -0
  16. package/lib/module/index.js.map +1 -0
  17. package/lib/module/package.json +1 -0
  18. package/lib/typescript/package.json +1 -0
  19. package/lib/typescript/src/KeychainModule.nitro.d.ts +32 -0
  20. package/lib/typescript/src/KeychainModule.nitro.d.ts.map +1 -0
  21. package/lib/typescript/src/index.d.ts +4 -0
  22. package/lib/typescript/src/index.d.ts.map +1 -0
  23. package/nitro.json +17 -0
  24. package/nitrogen/generated/android/c++/JGetItemParams.hpp +57 -0
  25. package/nitrogen/generated/android/c++/JGetItemResult.hpp +61 -0
  26. package/nitrogen/generated/android/c++/JHasItemParams.hpp +57 -0
  27. package/nitrogen/generated/android/c++/JHybridKeychainModuleSpec.cpp +153 -0
  28. package/nitrogen/generated/android/c++/JHybridKeychainModuleSpec.hpp +69 -0
  29. package/nitrogen/generated/android/c++/JRemoveItemParams.hpp +57 -0
  30. package/nitrogen/generated/android/c++/JSetItemParams.hpp +74 -0
  31. package/nitrogen/generated/android/c++/JVariant_NullType_GetItemResult.cpp +26 -0
  32. package/nitrogen/generated/android/c++/JVariant_NullType_GetItemResult.hpp +72 -0
  33. package/nitrogen/generated/android/keychainmodule+autolinking.cmake +82 -0
  34. package/nitrogen/generated/android/keychainmodule+autolinking.gradle +27 -0
  35. package/nitrogen/generated/android/keychainmoduleOnLoad.cpp +44 -0
  36. package/nitrogen/generated/android/keychainmoduleOnLoad.hpp +25 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/GetItemParams.kt +38 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/GetItemResult.kt +41 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/HasItemParams.kt +38 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/HybridKeychainModuleSpec.kt +75 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/RemoveItemParams.kt +38 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/SetItemParams.kt +50 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/Variant_NullType_GetItemResult.kt +59 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/keychainmodule/keychainmoduleOnLoad.kt +35 -0
  45. package/nitrogen/generated/ios/KeychainModule+autolinking.rb +60 -0
  46. package/nitrogen/generated/ios/KeychainModule-Swift-Cxx-Bridge.cpp +57 -0
  47. package/nitrogen/generated/ios/KeychainModule-Swift-Cxx-Bridge.hpp +219 -0
  48. package/nitrogen/generated/ios/KeychainModule-Swift-Cxx-Umbrella.hpp +63 -0
  49. package/nitrogen/generated/ios/KeychainModuleAutolinking.mm +33 -0
  50. package/nitrogen/generated/ios/KeychainModuleAutolinking.swift +25 -0
  51. package/nitrogen/generated/ios/c++/HybridKeychainModuleSpecSwift.cpp +11 -0
  52. package/nitrogen/generated/ios/c++/HybridKeychainModuleSpecSwift.hpp +126 -0
  53. package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
  54. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  55. package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__GetItemResult_.swift +59 -0
  56. package/nitrogen/generated/ios/swift/GetItemParams.swift +36 -0
  57. package/nitrogen/generated/ios/swift/GetItemResult.swift +47 -0
  58. package/nitrogen/generated/ios/swift/HasItemParams.swift +36 -0
  59. package/nitrogen/generated/ios/swift/HybridKeychainModuleSpec.swift +60 -0
  60. package/nitrogen/generated/ios/swift/HybridKeychainModuleSpec_cxx.swift +221 -0
  61. package/nitrogen/generated/ios/swift/RemoveItemParams.swift +36 -0
  62. package/nitrogen/generated/ios/swift/SetItemParams.swift +137 -0
  63. package/nitrogen/generated/ios/swift/Variant_NullType_GetItemResult.swift +18 -0
  64. package/nitrogen/generated/shared/c++/GetItemParams.hpp +75 -0
  65. package/nitrogen/generated/shared/c++/GetItemResult.hpp +79 -0
  66. package/nitrogen/generated/shared/c++/HasItemParams.hpp +75 -0
  67. package/nitrogen/generated/shared/c++/HybridKeychainModuleSpec.cpp +25 -0
  68. package/nitrogen/generated/shared/c++/HybridKeychainModuleSpec.hpp +82 -0
  69. package/nitrogen/generated/shared/c++/RemoveItemParams.hpp +75 -0
  70. package/nitrogen/generated/shared/c++/SetItemParams.hpp +92 -0
  71. package/package.json +174 -0
  72. package/src/KeychainModule.nitro.ts +35 -0
  73. package/src/index.tsx +8 -0
@@ -0,0 +1,47 @@
1
+ ///
2
+ /// GetItemResult.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `GetItemResult`, backed by a C++ struct.
13
+ */
14
+ public typealias GetItemResult = margelo.nitro.keychainmodule.GetItemResult
15
+
16
+ public extension GetItemResult {
17
+ private typealias bridge = margelo.nitro.keychainmodule.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `GetItemResult`.
21
+ */
22
+ init(key: String, value: String) {
23
+ self.init(std.string(key), std.string(value))
24
+ }
25
+
26
+ var key: String {
27
+ @inline(__always)
28
+ get {
29
+ return String(self.__key)
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__key = std.string(newValue)
34
+ }
35
+ }
36
+
37
+ var value: String {
38
+ @inline(__always)
39
+ get {
40
+ return String(self.__value)
41
+ }
42
+ @inline(__always)
43
+ set {
44
+ self.__value = std.string(newValue)
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,36 @@
1
+ ///
2
+ /// HasItemParams.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `HasItemParams`, backed by a C++ struct.
13
+ */
14
+ public typealias HasItemParams = margelo.nitro.keychainmodule.HasItemParams
15
+
16
+ public extension HasItemParams {
17
+ private typealias bridge = margelo.nitro.keychainmodule.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `HasItemParams`.
21
+ */
22
+ init(key: String) {
23
+ self.init(std.string(key))
24
+ }
25
+
26
+ var key: String {
27
+ @inline(__always)
28
+ get {
29
+ return String(self.__key)
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__key = std.string(newValue)
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,60 @@
1
+ ///
2
+ /// HybridKeychainModuleSpec.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /// See ``HybridKeychainModuleSpec``
12
+ public protocol HybridKeychainModuleSpec_protocol: HybridObject {
13
+ // Properties
14
+
15
+
16
+ // Methods
17
+ func setItem(params: SetItemParams) throws -> Promise<Bool>
18
+ func getItem(params: GetItemParams) throws -> Promise<Variant_NullType_GetItemResult>
19
+ func removeItem(params: RemoveItemParams) throws -> Promise<Bool>
20
+ func hasItem(params: HasItemParams) throws -> Promise<Bool>
21
+ func isICloudSyncEnabled() throws -> Promise<Bool>
22
+ }
23
+
24
+ public extension HybridKeychainModuleSpec_protocol {
25
+ /// Default implementation of ``HybridObject.toString``
26
+ func toString() -> String {
27
+ return "[HybridObject KeychainModule]"
28
+ }
29
+ }
30
+
31
+ /// See ``HybridKeychainModuleSpec``
32
+ open class HybridKeychainModuleSpec_base {
33
+ private weak var cxxWrapper: HybridKeychainModuleSpec_cxx? = nil
34
+ public init() { }
35
+ public func getCxxWrapper() -> HybridKeychainModuleSpec_cxx {
36
+ #if DEBUG
37
+ guard self is HybridKeychainModuleSpec else {
38
+ fatalError("`self` is not a `HybridKeychainModuleSpec`! Did you accidentally inherit from `HybridKeychainModuleSpec_base` instead of `HybridKeychainModuleSpec`?")
39
+ }
40
+ #endif
41
+ if let cxxWrapper = self.cxxWrapper {
42
+ return cxxWrapper
43
+ } else {
44
+ let cxxWrapper = HybridKeychainModuleSpec_cxx(self as! HybridKeychainModuleSpec)
45
+ self.cxxWrapper = cxxWrapper
46
+ return cxxWrapper
47
+ }
48
+ }
49
+ }
50
+
51
+ /**
52
+ * A Swift base-protocol representing the KeychainModule HybridObject.
53
+ * Implement this protocol to create Swift-based instances of KeychainModule.
54
+ * ```swift
55
+ * class HybridKeychainModule : HybridKeychainModuleSpec {
56
+ * // ...
57
+ * }
58
+ * ```
59
+ */
60
+ public typealias HybridKeychainModuleSpec = HybridKeychainModuleSpec_protocol & HybridKeychainModuleSpec_base
@@ -0,0 +1,221 @@
1
+ ///
2
+ /// HybridKeychainModuleSpec_cxx.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * A class implementation that bridges HybridKeychainModuleSpec over to C++.
13
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
14
+ *
15
+ * Also, some Swift types need to be bridged with special handling:
16
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
17
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
18
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
19
+ */
20
+ open class HybridKeychainModuleSpec_cxx {
21
+ /**
22
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::keychainmodule::bridge::swift`)
23
+ * from `KeychainModule-Swift-Cxx-Bridge.hpp`.
24
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
25
+ */
26
+ public typealias bridge = margelo.nitro.keychainmodule.bridge.swift
27
+
28
+ /**
29
+ * Holds an instance of the `HybridKeychainModuleSpec` Swift protocol.
30
+ */
31
+ private var __implementation: any HybridKeychainModuleSpec
32
+
33
+ /**
34
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
35
+ */
36
+ private var __cxxPart: bridge.std__weak_ptr_HybridKeychainModuleSpec_
37
+
38
+ /**
39
+ * Create a new `HybridKeychainModuleSpec_cxx` that wraps the given `HybridKeychainModuleSpec`.
40
+ * All properties and methods bridge to C++ types.
41
+ */
42
+ public init(_ implementation: any HybridKeychainModuleSpec) {
43
+ self.__implementation = implementation
44
+ self.__cxxPart = .init()
45
+ /* no base class */
46
+ }
47
+
48
+ /**
49
+ * Get the actual `HybridKeychainModuleSpec` instance this class wraps.
50
+ */
51
+ @inline(__always)
52
+ public func getHybridKeychainModuleSpec() -> any HybridKeychainModuleSpec {
53
+ return __implementation
54
+ }
55
+
56
+ /**
57
+ * Casts this instance to a retained unsafe raw pointer.
58
+ * This acquires one additional strong reference on the object!
59
+ */
60
+ public func toUnsafe() -> UnsafeMutableRawPointer {
61
+ return Unmanaged.passRetained(self).toOpaque()
62
+ }
63
+
64
+ /**
65
+ * Casts an unsafe pointer to a `HybridKeychainModuleSpec_cxx`.
66
+ * The pointer has to be a retained opaque `Unmanaged<HybridKeychainModuleSpec_cxx>`.
67
+ * This removes one strong reference from the object!
68
+ */
69
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridKeychainModuleSpec_cxx {
70
+ return Unmanaged<HybridKeychainModuleSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
71
+ }
72
+
73
+ /**
74
+ * Gets (or creates) the C++ part of this Hybrid Object.
75
+ * The C++ part is a `std::shared_ptr<HybridKeychainModuleSpec>`.
76
+ */
77
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridKeychainModuleSpec_ {
78
+ let cachedCxxPart = self.__cxxPart.lock()
79
+ if Bool(fromCxx: cachedCxxPart) {
80
+ return cachedCxxPart
81
+ } else {
82
+ let newCxxPart = bridge.create_std__shared_ptr_HybridKeychainModuleSpec_(self.toUnsafe())
83
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridKeychainModuleSpec_(newCxxPart)
84
+ return newCxxPart
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Get the memory size of the Swift class (plus size of any other allocations)
92
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
93
+ */
94
+ @inline(__always)
95
+ public var memorySize: Int {
96
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
97
+ }
98
+
99
+ /**
100
+ * Call dispose() on the Swift class.
101
+ * This _may_ be called manually from JS.
102
+ */
103
+ @inline(__always)
104
+ public func dispose() {
105
+ self.__implementation.dispose()
106
+ }
107
+
108
+ /**
109
+ * Call toString() on the Swift class.
110
+ */
111
+ @inline(__always)
112
+ public func toString() -> String {
113
+ return self.__implementation.toString()
114
+ }
115
+
116
+ // Properties
117
+
118
+
119
+ // Methods
120
+ @inline(__always)
121
+ public final func setItem(params: SetItemParams) -> bridge.Result_std__shared_ptr_Promise_bool___ {
122
+ do {
123
+ let __result = try self.__implementation.setItem(params: params)
124
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
125
+ let __promise = bridge.create_std__shared_ptr_Promise_bool__()
126
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
127
+ __result
128
+ .then({ __result in __promiseHolder.resolve(__result) })
129
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
130
+ return __promise
131
+ }()
132
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
133
+ } catch (let __error) {
134
+ let __exceptionPtr = __error.toCpp()
135
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
136
+ }
137
+ }
138
+
139
+ @inline(__always)
140
+ public final func getItem(params: GetItemParams) -> bridge.Result_std__shared_ptr_Promise_std__variant_nitro__NullType__GetItemResult____ {
141
+ do {
142
+ let __result = try self.__implementation.getItem(params: params)
143
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__variant_nitro__NullType__GetItemResult___ in
144
+ let __promise = bridge.create_std__shared_ptr_Promise_std__variant_nitro__NullType__GetItemResult___()
145
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__GetItemResult___(__promise)
146
+ __result
147
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__variant_nitro__NullType__GetItemResult_ in
148
+ switch __result {
149
+ case .first(let __value):
150
+ return bridge.create_std__variant_nitro__NullType__GetItemResult_(margelo.nitro.NullType.null)
151
+ case .second(let __value):
152
+ return bridge.create_std__variant_nitro__NullType__GetItemResult_(__value)
153
+ }
154
+ }().variant) })
155
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
156
+ return __promise
157
+ }()
158
+ return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__GetItemResult____(__resultCpp)
159
+ } catch (let __error) {
160
+ let __exceptionPtr = __error.toCpp()
161
+ return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__GetItemResult____(__exceptionPtr)
162
+ }
163
+ }
164
+
165
+ @inline(__always)
166
+ public final func removeItem(params: RemoveItemParams) -> bridge.Result_std__shared_ptr_Promise_bool___ {
167
+ do {
168
+ let __result = try self.__implementation.removeItem(params: params)
169
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
170
+ let __promise = bridge.create_std__shared_ptr_Promise_bool__()
171
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
172
+ __result
173
+ .then({ __result in __promiseHolder.resolve(__result) })
174
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
175
+ return __promise
176
+ }()
177
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
178
+ } catch (let __error) {
179
+ let __exceptionPtr = __error.toCpp()
180
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
181
+ }
182
+ }
183
+
184
+ @inline(__always)
185
+ public final func hasItem(params: HasItemParams) -> bridge.Result_std__shared_ptr_Promise_bool___ {
186
+ do {
187
+ let __result = try self.__implementation.hasItem(params: params)
188
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
189
+ let __promise = bridge.create_std__shared_ptr_Promise_bool__()
190
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
191
+ __result
192
+ .then({ __result in __promiseHolder.resolve(__result) })
193
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
194
+ return __promise
195
+ }()
196
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
197
+ } catch (let __error) {
198
+ let __exceptionPtr = __error.toCpp()
199
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
200
+ }
201
+ }
202
+
203
+ @inline(__always)
204
+ public final func isICloudSyncEnabled() -> bridge.Result_std__shared_ptr_Promise_bool___ {
205
+ do {
206
+ let __result = try self.__implementation.isICloudSyncEnabled()
207
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
208
+ let __promise = bridge.create_std__shared_ptr_Promise_bool__()
209
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
210
+ __result
211
+ .then({ __result in __promiseHolder.resolve(__result) })
212
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
213
+ return __promise
214
+ }()
215
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
216
+ } catch (let __error) {
217
+ let __exceptionPtr = __error.toCpp()
218
+ return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
219
+ }
220
+ }
221
+ }
@@ -0,0 +1,36 @@
1
+ ///
2
+ /// RemoveItemParams.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `RemoveItemParams`, backed by a C++ struct.
13
+ */
14
+ public typealias RemoveItemParams = margelo.nitro.keychainmodule.RemoveItemParams
15
+
16
+ public extension RemoveItemParams {
17
+ private typealias bridge = margelo.nitro.keychainmodule.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `RemoveItemParams`.
21
+ */
22
+ init(key: String) {
23
+ self.init(std.string(key))
24
+ }
25
+
26
+ var key: String {
27
+ @inline(__always)
28
+ get {
29
+ return String(self.__key)
30
+ }
31
+ @inline(__always)
32
+ set {
33
+ self.__key = std.string(newValue)
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,137 @@
1
+ ///
2
+ /// SetItemParams.swift
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
+ import Foundation
9
+ import NitroModules
10
+
11
+ /**
12
+ * Represents an instance of `SetItemParams`, backed by a C++ struct.
13
+ */
14
+ public typealias SetItemParams = margelo.nitro.keychainmodule.SetItemParams
15
+
16
+ public extension SetItemParams {
17
+ private typealias bridge = margelo.nitro.keychainmodule.bridge.swift
18
+
19
+ /**
20
+ * Create a new instance of `SetItemParams`.
21
+ */
22
+ init(key: String, value: String, enableSync: Bool?, label: String?, description: String?) {
23
+ self.init(std.string(key), std.string(value), { () -> bridge.std__optional_bool_ in
24
+ if let __unwrappedValue = enableSync {
25
+ return bridge.create_std__optional_bool_(__unwrappedValue)
26
+ } else {
27
+ return .init()
28
+ }
29
+ }(), { () -> bridge.std__optional_std__string_ in
30
+ if let __unwrappedValue = label {
31
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
32
+ } else {
33
+ return .init()
34
+ }
35
+ }(), { () -> bridge.std__optional_std__string_ in
36
+ if let __unwrappedValue = description {
37
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
38
+ } else {
39
+ return .init()
40
+ }
41
+ }())
42
+ }
43
+
44
+ var key: String {
45
+ @inline(__always)
46
+ get {
47
+ return String(self.__key)
48
+ }
49
+ @inline(__always)
50
+ set {
51
+ self.__key = std.string(newValue)
52
+ }
53
+ }
54
+
55
+ var value: String {
56
+ @inline(__always)
57
+ get {
58
+ return String(self.__value)
59
+ }
60
+ @inline(__always)
61
+ set {
62
+ self.__value = std.string(newValue)
63
+ }
64
+ }
65
+
66
+ var enableSync: Bool? {
67
+ @inline(__always)
68
+ get {
69
+ return { () -> Bool? in
70
+ if bridge.has_value_std__optional_bool_(self.__enableSync) {
71
+ let __unwrapped = bridge.get_std__optional_bool_(self.__enableSync)
72
+ return __unwrapped
73
+ } else {
74
+ return nil
75
+ }
76
+ }()
77
+ }
78
+ @inline(__always)
79
+ set {
80
+ self.__enableSync = { () -> bridge.std__optional_bool_ in
81
+ if let __unwrappedValue = newValue {
82
+ return bridge.create_std__optional_bool_(__unwrappedValue)
83
+ } else {
84
+ return .init()
85
+ }
86
+ }()
87
+ }
88
+ }
89
+
90
+ var label: String? {
91
+ @inline(__always)
92
+ get {
93
+ return { () -> String? in
94
+ if bridge.has_value_std__optional_std__string_(self.__label) {
95
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__label)
96
+ return String(__unwrapped)
97
+ } else {
98
+ return nil
99
+ }
100
+ }()
101
+ }
102
+ @inline(__always)
103
+ set {
104
+ self.__label = { () -> bridge.std__optional_std__string_ in
105
+ if let __unwrappedValue = newValue {
106
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
107
+ } else {
108
+ return .init()
109
+ }
110
+ }()
111
+ }
112
+ }
113
+
114
+ var description: String? {
115
+ @inline(__always)
116
+ get {
117
+ return { () -> String? in
118
+ if bridge.has_value_std__optional_std__string_(self.__description) {
119
+ let __unwrapped = bridge.get_std__optional_std__string_(self.__description)
120
+ return String(__unwrapped)
121
+ } else {
122
+ return nil
123
+ }
124
+ }()
125
+ }
126
+ @inline(__always)
127
+ set {
128
+ self.__description = { () -> bridge.std__optional_std__string_ in
129
+ if let __unwrappedValue = newValue {
130
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
131
+ } else {
132
+ return .init()
133
+ }
134
+ }()
135
+ }
136
+ }
137
+ }
@@ -0,0 +1,18 @@
1
+ ///
2
+ /// Variant_NullType_GetItemResult.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * An Swift enum with associated values representing a Variant/Union type.
12
+ * JS type: `null | struct`
13
+ */
14
+ @frozen
15
+ public indirect enum Variant_NullType_GetItemResult {
16
+ case first(NullType)
17
+ case second(GetItemResult)
18
+ }
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// GetItemParams.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 (GetItemParams).
34
+ */
35
+ struct GetItemParams {
36
+ public:
37
+ std::string key SWIFT_PRIVATE;
38
+
39
+ public:
40
+ GetItemParams() = default;
41
+ explicit GetItemParams(std::string key): key(key) {}
42
+ };
43
+
44
+ } // namespace margelo::nitro::keychainmodule
45
+
46
+ namespace margelo::nitro {
47
+
48
+ // C++ GetItemParams <> JS GetItemParams (object)
49
+ template <>
50
+ struct JSIConverter<margelo::nitro::keychainmodule::GetItemParams> final {
51
+ static inline margelo::nitro::keychainmodule::GetItemParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
+ jsi::Object obj = arg.asObject(runtime);
53
+ return margelo::nitro::keychainmodule::GetItemParams(
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::GetItemParams& 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