@qntx/wallet-native 0.12.0 → 0.14.0

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 (135) hide show
  1. package/README.md +184 -31
  2. package/WalletNative.podspec +11 -2
  3. package/android/CMakeLists.txt +7 -1
  4. package/android/build.gradle +4 -0
  5. package/android/src/main/AndroidManifest.xml +1 -2
  6. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  7. package/android/src/main/java/com/margelo/nitro/qntxwallet/CardReader.kt +316 -0
  8. package/android/src/main/java/com/margelo/nitro/qntxwallet/HybridGoogleDriveAuth.kt +142 -0
  9. package/android/src/main/java/com/margelo/nitro/qntxwallet/HybridSecureInputView.kt +25 -0
  10. package/android/src/main/java/com/margelo/nitro/qntxwallet/Keystore.kt +148 -9
  11. package/android/src/main/java/com/margelo/nitro/qntxwallet/SecureInputField.kt +422 -0
  12. package/android/src/main/java/com/margelo/nitro/qntxwallet/VaultAnchor.kt +90 -0
  13. package/android/src/main/java/com/margelo/nitro/qntxwallet/WalletNativePackage.java +10 -0
  14. package/cpp/host/CardReader.hpp +70 -0
  15. package/cpp/host/HybridKernelHost.cpp +90 -15
  16. package/cpp/host/HybridKernelHost.hpp +21 -5
  17. package/cpp/host/KernelFile.cpp +79 -15
  18. package/cpp/host/KernelFile.hpp +17 -6
  19. package/cpp/host/KernelSlot.hpp +103 -0
  20. package/cpp/host/Keystore.hpp +35 -11
  21. package/cpp/host/Lifecycle.cpp +11 -0
  22. package/cpp/host/Lifecycle.hpp +3 -0
  23. package/cpp/host/Passkey.hpp +8 -0
  24. package/cpp/host/SecureInput.cpp +233 -0
  25. package/cpp/host/SecureInput.hpp +103 -0
  26. package/cpp/host/VaultAnchor.cpp +39 -0
  27. package/cpp/host/VaultAnchor.hpp +28 -0
  28. package/cpp/host/VaultDirectory.hpp +1 -1
  29. package/cpp/platform/CardReaderAndroid.cpp +146 -0
  30. package/cpp/platform/CardReaderIos.mm +318 -0
  31. package/cpp/platform/KeystoreAndroid.cpp +48 -1
  32. package/cpp/platform/KeystoreIos.mm +109 -19
  33. package/cpp/platform/PasskeyAndroid.cpp +2 -0
  34. package/cpp/platform/PasskeyIos.mm +20 -18
  35. package/cpp/platform/QntxSecureInputField.h +24 -0
  36. package/cpp/platform/SecureInputAndroid.cpp +110 -0
  37. package/cpp/platform/SecureInputIos.mm +282 -0
  38. package/cpp/platform/VaultAnchorAndroid.cpp +76 -0
  39. package/cpp/platform/VaultAnchorIos.mm +76 -0
  40. package/cpp/runtime/KernelBackends.cpp +35 -28
  41. package/cpp/runtime/KernelBuffer.hpp +2 -5
  42. package/cpp/runtime/KernelCardReader.cpp +385 -0
  43. package/cpp/runtime/KernelCardReader.hpp +27 -0
  44. package/cpp/runtime/KernelGlobals.cpp +176 -63
  45. package/cpp/runtime/KernelGlobals.hpp +13 -7
  46. package/cpp/runtime/KernelJs.cpp +14 -0
  47. package/cpp/runtime/KernelJs.hpp +4 -0
  48. package/cpp/runtime/KernelKeystore.cpp +78 -2
  49. package/cpp/runtime/KernelKeystore.hpp +1 -0
  50. package/cpp/runtime/KernelPasskey.cpp +15 -12
  51. package/cpp/runtime/KernelRuntime.cpp +24 -7
  52. package/cpp/runtime/KernelRuntime.hpp +14 -6
  53. package/cpp/runtime/KernelSecureInput.cpp +154 -0
  54. package/cpp/runtime/KernelSecureInput.hpp +25 -0
  55. package/cpp/runtime/platform/KernelArgon2.cpp +34 -0
  56. package/cpp/runtime/platform/KernelArgon2.hpp +23 -0
  57. package/cpp/vendor/argon2/LICENSE +314 -0
  58. package/cpp/vendor/argon2/README.md +20 -0
  59. package/cpp/vendor/argon2/include/argon2.h +437 -0
  60. package/cpp/vendor/argon2/src/argon2.c +452 -0
  61. package/cpp/vendor/argon2/src/blake2/blake2-impl.h +156 -0
  62. package/cpp/vendor/argon2/src/blake2/blake2.h +89 -0
  63. package/cpp/vendor/argon2/src/blake2/blake2b.c +390 -0
  64. package/cpp/vendor/argon2/src/blake2/blamka-round-ref.h +56 -0
  65. package/cpp/vendor/argon2/src/core.c +648 -0
  66. package/cpp/vendor/argon2/src/core.h +228 -0
  67. package/cpp/vendor/argon2/src/encoding.c +463 -0
  68. package/cpp/vendor/argon2/src/encoding.h +57 -0
  69. package/cpp/vendor/argon2/src/ref.c +194 -0
  70. package/cpp/vendor/argon2/src/thread.c +57 -0
  71. package/cpp/vendor/argon2/src/thread.h +67 -0
  72. package/dist/cloud.d.mts +58 -0
  73. package/dist/cloud.mjs +114 -0
  74. package/dist/cloud.mjs.map +1 -0
  75. package/dist/index.d.mts +13 -4
  76. package/dist/index.mjs +89 -14
  77. package/dist/index.mjs.map +1 -1
  78. package/dist/secure-input.d.mts +24 -0
  79. package/dist/secure-input.mjs +25 -0
  80. package/dist/secure-input.mjs.map +1 -0
  81. package/ios/HybridCloudKitStore.swift +159 -0
  82. package/ios/HybridSecureInputView.swift +35 -0
  83. package/ios/cloud/CloudKitEnvelopeStore.swift +179 -0
  84. package/kernel/generated/kernel-entry.js +51913 -20526
  85. package/kernel/generated/kernel.manifest.json +17 -7
  86. package/nitrogen/generated/android/WalletNative+autolinking.cmake +7 -1
  87. package/nitrogen/generated/android/WalletNativeOnLoad.cpp +37 -2
  88. package/nitrogen/generated/android/c++/JFunc_void_SecureInputState.hpp +77 -0
  89. package/nitrogen/generated/android/c++/JHybridGoogleDriveAuthSpec.cpp +82 -0
  90. package/nitrogen/generated/android/c++/JHybridGoogleDriveAuthSpec.hpp +64 -0
  91. package/nitrogen/generated/android/c++/JHybridSecureInputViewSpec.cpp +70 -0
  92. package/nitrogen/generated/android/c++/JHybridSecureInputViewSpec.hpp +64 -0
  93. package/nitrogen/generated/android/c++/JSecureInputState.hpp +64 -0
  94. package/nitrogen/generated/android/c++/views/JHybridSecureInputViewStateUpdater.cpp +74 -0
  95. package/nitrogen/generated/android/c++/views/JHybridSecureInputViewStateUpdater.hpp +54 -0
  96. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/Func_void_SecureInputState.kt +78 -0
  97. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/HybridGoogleDriveAuthSpec.kt +61 -0
  98. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/HybridSecureInputViewSpec.kt +67 -0
  99. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/SecureInputState.kt +25 -0
  100. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/views/HybridSecureInputViewManager.kt +96 -0
  101. package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/views/HybridSecureInputViewStateUpdater.kt +23 -0
  102. package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Bridge.cpp +74 -1
  103. package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Bridge.hpp +252 -3
  104. package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Umbrella.hpp +21 -3
  105. package/nitrogen/generated/ios/WalletNativeAutolinking.mm +17 -1
  106. package/nitrogen/generated/ios/WalletNativeAutolinking.swift +22 -0
  107. package/nitrogen/generated/ios/c++/HybridCloudKitStoreSpecSwift.cpp +11 -0
  108. package/nitrogen/generated/ios/c++/HybridCloudKitStoreSpecSwift.hpp +116 -0
  109. package/nitrogen/generated/ios/c++/HybridSecureInputViewSpecSwift.cpp +11 -0
  110. package/nitrogen/generated/ios/c++/HybridSecureInputViewSpecSwift.hpp +83 -0
  111. package/nitrogen/generated/ios/c++/views/HybridSecureInputViewComponent.mm +144 -0
  112. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  113. package/nitrogen/generated/ios/swift/Func_void_SecureInputState.swift +46 -0
  114. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  115. package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
  116. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +46 -0
  117. package/nitrogen/generated/ios/swift/HybridCloudKitStoreSpec.swift +59 -0
  118. package/nitrogen/generated/ios/swift/HybridCloudKitStoreSpec_cxx.swift +230 -0
  119. package/nitrogen/generated/ios/swift/HybridSecureInputViewSpec.swift +55 -0
  120. package/nitrogen/generated/ios/swift/HybridSecureInputViewSpec_cxx.swift +164 -0
  121. package/nitrogen/generated/ios/swift/SecureInputState.swift +48 -0
  122. package/nitrogen/generated/shared/c++/HybridCloudKitStoreSpec.cpp +25 -0
  123. package/nitrogen/generated/shared/c++/HybridCloudKitStoreSpec.hpp +70 -0
  124. package/nitrogen/generated/shared/c++/HybridGoogleDriveAuthSpec.cpp +22 -0
  125. package/nitrogen/generated/shared/c++/HybridGoogleDriveAuthSpec.hpp +64 -0
  126. package/nitrogen/generated/shared/c++/HybridKernelHostSpec.cpp +1 -0
  127. package/nitrogen/generated/shared/c++/HybridKernelHostSpec.hpp +1 -0
  128. package/nitrogen/generated/shared/c++/HybridSecureInputViewSpec.cpp +22 -0
  129. package/nitrogen/generated/shared/c++/HybridSecureInputViewSpec.hpp +65 -0
  130. package/nitrogen/generated/shared/c++/SecureInputState.hpp +84 -0
  131. package/nitrogen/generated/shared/c++/views/HybridSecureInputViewComponent.cpp +34 -0
  132. package/nitrogen/generated/shared/c++/views/HybridSecureInputViewComponent.hpp +85 -0
  133. package/nitrogen/generated/shared/json/SecureInputViewConfig.json +10 -0
  134. package/package.json +24 -6
  135. package/scripts/compile-kernel.mjs +7 -3
@@ -0,0 +1,144 @@
1
+ ///
2
+ /// HybridSecureInputViewComponent.mm
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #import "HybridSecureInputViewComponent.hpp"
9
+ #import <memory>
10
+ #import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
11
+ #import <React/RCTViewComponentView.h>
12
+ #import <React/RCTComponentViewFactory.h>
13
+ #import <React/UIView+ComponentViewProtocol.h>
14
+ #import <NitroModules/NitroDefines.hpp>
15
+ #import <UIKit/UIKit.h>
16
+
17
+ #import "HybridSecureInputViewSpecSwift.hpp"
18
+ #import "WalletNative-Swift-Cxx-Umbrella.hpp"
19
+
20
+ #if __has_include(<cxxreact/ReactNativeVersion.h>)
21
+ #include <cxxreact/ReactNativeVersion.h>
22
+ #if REACT_NATIVE_VERSION_MINOR >= 82
23
+ #define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
24
+ #endif
25
+ #endif
26
+
27
+ using namespace facebook;
28
+ using namespace margelo::nitro::qntxwallet;
29
+ using namespace margelo::nitro::qntxwallet::views;
30
+
31
+ /**
32
+ * Represents the React Native View holder for the Nitro "SecureInputView" HybridView.
33
+ */
34
+ @interface HybridSecureInputViewComponent: RCTViewComponentView
35
+ + (BOOL)shouldBeRecycled;
36
+ @end
37
+
38
+ @implementation HybridSecureInputViewComponent {
39
+ std::shared_ptr<HybridSecureInputViewSpecSwift> _hybridView;
40
+ BOOL _didDropView;
41
+ }
42
+
43
+ + (void) load {
44
+ [super load];
45
+ [RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridSecureInputViewComponent class]];
46
+ }
47
+
48
+ + (react::ComponentDescriptorProvider) componentDescriptorProvider {
49
+ return react::concreteComponentDescriptorProvider<HybridSecureInputViewComponentDescriptor>();
50
+ }
51
+
52
+ - (instancetype) init {
53
+ if (self = [super init]) {
54
+ _props = HybridSecureInputViewShadowNode::defaultSharedProps();
55
+ std::shared_ptr<HybridSecureInputViewSpec> hybridView = WalletNative::WalletNativeAutolinking::createSecureInputView();
56
+ _hybridView = std::dynamic_pointer_cast<HybridSecureInputViewSpecSwift>(hybridView);
57
+ [self updateView];
58
+ }
59
+ return self;
60
+ }
61
+
62
+ - (void) updateView {
63
+ // 1. Get Swift part
64
+ WalletNative::HybridSecureInputViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
65
+
66
+ // 2. Get UIView*
67
+ void* viewUnsafe = swiftPart.getView();
68
+ UIView* view = (__bridge_transfer UIView*) viewUnsafe;
69
+
70
+ // 3. Update RCTViewComponentView's [contentView]
71
+ [self setContentView:view];
72
+ }
73
+
74
+ - (void) notifyOnDropView {
75
+ // A recycled component can later be invalidated. Notify only once per mount.
76
+ if (_didDropView) {
77
+ return;
78
+ }
79
+ WalletNative::HybridSecureInputViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
80
+ swiftPart.onDropView();
81
+ _didDropView = YES;
82
+ }
83
+
84
+ - (void) updateProps:(const std::shared_ptr<const react::Props>&)props
85
+ oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
86
+ // A props update marks a newly mounted or still-active component.
87
+ _didDropView = NO;
88
+
89
+ // 1. Downcast props
90
+ const auto& newViewProps = *std::static_pointer_cast<const HybridSecureInputViewProps>(props);
91
+ const auto* oldViewProps = static_cast<const HybridSecureInputViewProps*>(oldProps.get());
92
+ WalletNative::HybridSecureInputViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
93
+
94
+ // 2. Update only props that differ from the previous Props snapshot.
95
+ const bool hasTransactionPropChanges = oldViewProps == nullptr
96
+ ? newViewProps.hasAnyProvidedProps()
97
+ : !newViewProps.hasSameProps(*oldViewProps);
98
+ if (hasTransactionPropChanges) {
99
+ swiftPart.beforeUpdate();
100
+
101
+ // onStateChange: function
102
+ if (oldViewProps == nullptr
103
+ ? newViewProps.onStateChange.isProvided()
104
+ : !newViewProps.onStateChange.hasSameValue(oldViewProps->onStateChange)) {
105
+ swiftPart.setOnStateChange(newViewProps.onStateChange.get());
106
+ }
107
+
108
+ // Update hybridRef if it changed
109
+ if (oldViewProps == nullptr
110
+ ? newViewProps.hybridRef.isProvided()
111
+ : !newViewProps.hybridRef.hasSameValue(oldViewProps->hybridRef)) {
112
+ // hybridRef changed - call it with new this
113
+ const auto& maybeFunc = newViewProps.hybridRef.get();
114
+ if (maybeFunc.has_value()) {
115
+ maybeFunc.value()(_hybridView);
116
+ }
117
+ }
118
+
119
+ swiftPart.afterUpdate();
120
+ }
121
+
122
+ // 3. Continue in base class
123
+ [super updateProps:props oldProps:oldProps];
124
+ }
125
+
126
+ + (BOOL)shouldBeRecycled {
127
+ return WalletNative::WalletNativeAutolinking::isSecureInputViewRecyclable();
128
+ }
129
+
130
+ - (void)prepareForRecycle {
131
+ [self notifyOnDropView];
132
+ [super prepareForRecycle];
133
+ WalletNative::HybridSecureInputViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
134
+ swiftPart.maybePrepareForRecycle();
135
+ }
136
+
137
+ #ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
138
+ - (void)invalidate {
139
+ [self notifyOnDropView];
140
+ [super invalidate];
141
+ }
142
+ #endif
143
+
144
+ @end
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `() -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void {
15
+ public typealias bridge = margelo.nitro.qntxwallet.bridge.swift
16
+
17
+ private let closure: () -> Void
18
+
19
+ public init(_ closure: @escaping () -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call() -> Void {
25
+ self.closure()
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
44
+ return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_SecureInputState.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ state: SecureInputState) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_SecureInputState {
15
+ public typealias bridge = margelo.nitro.qntxwallet.bridge.swift
16
+
17
+ private let closure: (_ state: SecureInputState) -> Void
18
+
19
+ public init(_ closure: @escaping (_ state: SecureInputState) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(state: Int32) -> Void {
25
+ self.closure(margelo.nitro.qntxwallet.SecureInputState(rawValue: state)!)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_SecureInputState`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_SecureInputState>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_SecureInputState {
44
+ return Unmanaged<Func_void_SecureInputState>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.qntxwallet.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,53 @@
1
+ ///
2
+ /// Func_void_std__optional_std__string_.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ value: String?) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__optional_std__string_ {
15
+ public typealias bridge = margelo.nitro.qntxwallet.bridge.swift
16
+
17
+ private let closure: (_ value: String?) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: String?) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: bridge.std__optional_std__string_) -> Void {
25
+ self.closure({ () -> String? in
26
+ if bridge.has_value_std__optional_std__string_(value) {
27
+ let __unwrapped = bridge.get_std__optional_std__string_(value)
28
+ return String(__unwrapped)
29
+ } else {
30
+ return nil
31
+ }
32
+ }())
33
+ }
34
+
35
+ /**
36
+ * Casts this instance to a retained unsafe raw pointer.
37
+ * This acquires one additional strong reference on the object!
38
+ */
39
+ @inline(__always)
40
+ public func toUnsafe() -> UnsafeMutableRawPointer {
41
+ return Unmanaged.passRetained(self).toOpaque()
42
+ }
43
+
44
+ /**
45
+ * Casts an unsafe pointer to a `Func_void_std__optional_std__string_`.
46
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_std__string_>`.
47
+ * This removes one strong reference from the object!
48
+ */
49
+ @inline(__always)
50
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_std__string_ {
51
+ return Unmanaged<Func_void_std__optional_std__string_>.fromOpaque(pointer).takeRetainedValue()
52
+ }
53
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__vector_std__string_.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ value: [String]) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__vector_std__string_ {
15
+ public typealias bridge = margelo.nitro.qntxwallet.bridge.swift
16
+
17
+ private let closure: (_ value: [String]) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: [String]) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: bridge.std__vector_std__string_) -> Void {
25
+ self.closure(value.map({ __item in String(__item) }))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__vector_std__string_`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__vector_std__string_>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__vector_std__string_ {
44
+ return Unmanaged<Func_void_std__vector_std__string_>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// HybridCloudKitStoreSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /// See ``HybridCloudKitStoreSpec``
11
+ public protocol HybridCloudKitStoreSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func list(container: String) throws -> Promise<[String]>
17
+ func read(container: String, name: String) throws -> Promise<String?>
18
+ func write(container: String, name: String, text: String) throws -> Promise<Void>
19
+ func remove(container: String, name: String) throws -> Promise<Void>
20
+ func setAccountListener(listener: @escaping () -> Void) throws -> Void
21
+ }
22
+
23
+ public extension HybridCloudKitStoreSpec_protocol {
24
+ /// Default implementation of ``HybridObject.toString``
25
+ func toString() -> String {
26
+ return "[HybridObject CloudKitStore]"
27
+ }
28
+ }
29
+
30
+ /// See ``HybridCloudKitStoreSpec``
31
+ open class HybridCloudKitStoreSpec_base {
32
+ private weak var cxxWrapper: HybridCloudKitStoreSpec_cxx? = nil
33
+ public init() { }
34
+ public func getCxxWrapper() -> HybridCloudKitStoreSpec_cxx {
35
+ #if DEBUG
36
+ guard self is any HybridCloudKitStoreSpec else {
37
+ fatalError("`self` is not a `HybridCloudKitStoreSpec`! Did you accidentally inherit from `HybridCloudKitStoreSpec_base` instead of `HybridCloudKitStoreSpec`?")
38
+ }
39
+ #endif
40
+ if let cxxWrapper = self.cxxWrapper {
41
+ return cxxWrapper
42
+ } else {
43
+ let cxxWrapper = HybridCloudKitStoreSpec_cxx(self as! any HybridCloudKitStoreSpec)
44
+ self.cxxWrapper = cxxWrapper
45
+ return cxxWrapper
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * A Swift base-protocol representing the CloudKitStore HybridObject.
52
+ * Implement this protocol to create Swift-based instances of CloudKitStore.
53
+ * ```swift
54
+ * class HybridCloudKitStore : HybridCloudKitStoreSpec {
55
+ * // ...
56
+ * }
57
+ * ```
58
+ */
59
+ public typealias HybridCloudKitStoreSpec = HybridCloudKitStoreSpec_protocol & HybridCloudKitStoreSpec_base
@@ -0,0 +1,230 @@
1
+ ///
2
+ /// HybridCloudKitStoreSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * A class implementation that bridges HybridCloudKitStoreSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridCloudKitStoreSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::qntxwallet::bridge::swift`)
22
+ * from `WalletNative-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.qntxwallet.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridCloudKitStoreSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridCloudKitStoreSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridCloudKitStoreSpec_
36
+
37
+ /**
38
+ * Create a new `HybridCloudKitStoreSpec_cxx` that wraps the given `HybridCloudKitStoreSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridCloudKitStoreSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridCloudKitStoreSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridCloudKitStoreSpec() -> any HybridCloudKitStoreSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridCloudKitStoreSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridCloudKitStoreSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridCloudKitStoreSpec_cxx {
69
+ return Unmanaged<HybridCloudKitStoreSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridCloudKitStoreSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridCloudKitStoreSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridCloudKitStoreSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridCloudKitStoreSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridCloudKitStoreSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func list(container: std.string) -> bridge.Result_std__shared_ptr_Promise_std__vector_std__string____ {
129
+ do {
130
+ let __result = try self.__implementation.list(container: String(container))
131
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__vector_std__string___ in
132
+ let __promise = bridge.create_std__shared_ptr_Promise_std__vector_std__string___()
133
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__vector_std__string___(__promise)
134
+ __result
135
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__vector_std__string_ in
136
+ var __vector = bridge.create_std__vector_std__string_(__result.count)
137
+ for __item in __result {
138
+ __vector.push_back(std.string(__item))
139
+ }
140
+ return __vector
141
+ }()) })
142
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
143
+ return __promise
144
+ }()
145
+ return bridge.create_Result_std__shared_ptr_Promise_std__vector_std__string____(__resultCpp)
146
+ } catch (let __error) {
147
+ let __exceptionPtr = __error.toCpp()
148
+ return bridge.create_Result_std__shared_ptr_Promise_std__vector_std__string____(__exceptionPtr)
149
+ }
150
+ }
151
+
152
+ @inline(__always)
153
+ public final func read(container: std.string, name: std.string) -> bridge.Result_std__shared_ptr_Promise_std__optional_std__string____ {
154
+ do {
155
+ let __result = try self.__implementation.read(container: String(container), name: String(name))
156
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__optional_std__string___ in
157
+ let __promise = bridge.create_std__shared_ptr_Promise_std__optional_std__string___()
158
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__optional_std__string___(__promise)
159
+ __result
160
+ .then({ __result in __promiseHolder.resolve({ () -> bridge.std__optional_std__string_ in
161
+ if let __unwrappedValue = __result {
162
+ return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
163
+ } else {
164
+ return .init()
165
+ }
166
+ }()) })
167
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
168
+ return __promise
169
+ }()
170
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__resultCpp)
171
+ } catch (let __error) {
172
+ let __exceptionPtr = __error.toCpp()
173
+ return bridge.create_Result_std__shared_ptr_Promise_std__optional_std__string____(__exceptionPtr)
174
+ }
175
+ }
176
+
177
+ @inline(__always)
178
+ public final func write(container: std.string, name: std.string, text: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
179
+ do {
180
+ let __result = try self.__implementation.write(container: String(container), name: String(name), text: String(text))
181
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
182
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
183
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
184
+ __result
185
+ .then({ __result in __promiseHolder.resolve() })
186
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
187
+ return __promise
188
+ }()
189
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
190
+ } catch (let __error) {
191
+ let __exceptionPtr = __error.toCpp()
192
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
193
+ }
194
+ }
195
+
196
+ @inline(__always)
197
+ public final func remove(container: std.string, name: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
198
+ do {
199
+ let __result = try self.__implementation.remove(container: String(container), name: String(name))
200
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
201
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
202
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
203
+ __result
204
+ .then({ __result in __promiseHolder.resolve() })
205
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
206
+ return __promise
207
+ }()
208
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
209
+ } catch (let __error) {
210
+ let __exceptionPtr = __error.toCpp()
211
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
212
+ }
213
+ }
214
+
215
+ @inline(__always)
216
+ public final func setAccountListener(listener: bridge.Func_void) -> bridge.Result_void_ {
217
+ do {
218
+ try self.__implementation.setAccountListener(listener: { () -> () -> Void in
219
+ let __wrappedFunction = bridge.wrap_Func_void(listener)
220
+ return { () -> Void in
221
+ __wrappedFunction.call()
222
+ }
223
+ }())
224
+ return bridge.create_Result_void_()
225
+ } catch (let __error) {
226
+ let __exceptionPtr = __error.toCpp()
227
+ return bridge.create_Result_void_(__exceptionPtr)
228
+ }
229
+ }
230
+ }