@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
@@ -1,6 +1,6 @@
1
1
  {
2
- "protocol": 2,
3
- "vaultFormat": 3,
2
+ "protocol": 3,
3
+ "vaultFormat": 6,
4
4
  "backends": {
5
5
  "spark": {
6
6
  "abiVersion": 1
@@ -10,6 +10,11 @@
10
10
  }
11
11
  },
12
12
  "libraries": [
13
+ {
14
+ "name": "@blockchaincommons/dcbor",
15
+ "version": "1.0.0-beta.5",
16
+ "integrity": "sha512-dmuEkmfcJk6g/+m73F9Rosxb+sHb790fiNfOdE6CI/TFLZCnXCRr3+K1QR4Se+vtBllEBgv85s28zaC1Jnegkw=="
17
+ },
13
18
  {
14
19
  "name": "@noble/ciphers",
15
20
  "version": "2.4.0",
@@ -27,13 +32,13 @@
27
32
  },
28
33
  {
29
34
  "name": "@qntx/nostr",
30
- "version": "0.15.4",
31
- "integrity": "sha512-kxWfN3HxKm7bTDn7Mzd+X80J74fbzNwUHOx8in5qMcb89/FgytR0jXllnF6eqGyO7VYG3pKSj94JnhgbkV73BQ=="
35
+ "version": "0.16.0",
36
+ "integrity": "sha512-52tWXXYutmDisBRVJ2+b5mgIHlKufXzV4zBQ1LlKKPmUsHeSVr214R25GKh9QF2bNfOnkik10j3SZjEZ8O2ytA=="
32
37
  },
33
38
  {
34
39
  "name": "@qntx/nostr-native",
35
- "version": "0.15.4",
36
- "integrity": "sha512-CUBflKqmXeIMyZbm4FP0ssZRmbtbu1IXfsuDso9nxLekPsnXYfo+0gzQNKNxpYTwvQ5ay608nmLsSQ4PV4soMw=="
40
+ "version": "0.16.0",
41
+ "integrity": "sha512-qJsZpSeCyywolLSgbFD/62XTbugR6FgGJLIl5PpGZedv8kFrZxBT4Oneg9fcDTW7KZehk19Ti6Wf/SVc3qM19g=="
37
42
  },
38
43
  {
39
44
  "name": "@qntx/siwx",
@@ -50,6 +55,11 @@
50
55
  "version": "0.5.2",
51
56
  "integrity": "sha512-MclvFeazgWKxf98hIFlBcO+wVoQkv8r0ap6lXGUyfaVT4qqvf2r837DMJ1Bb3kNJUcgNCBmUd0Hej/L4honRpw=="
52
57
  },
58
+ {
59
+ "name": "@qntx/ur",
60
+ "version": "4.1.0",
61
+ "integrity": "sha512-eOJJLek5tKn3Ts/8wo3yt6/VVwhAKjv7l5l8k7SGLSXLxz2OggXzm7RUURIlpSgyBbGAAQqf5ecCGt81iZGoGw=="
62
+ },
53
63
  {
54
64
  "name": "@scure/base",
55
65
  "version": "2.4.0",
@@ -79,7 +89,7 @@
79
89
  "bundles": [
80
90
  {
81
91
  "file": "kernel-entry.js",
82
- "sha256": "9e09cbb8247ee2a2b04ca97037e6d3d734d7e473e11f478fd77efe7af845cde2"
92
+ "sha256": "55e5ae17e52d5723d32f1f8888cf04809b2d957289c0d63c9363e25640687ec3"
83
93
  }
84
94
  ]
85
95
  }
@@ -33,9 +33,15 @@ target_sources(
33
33
  # Autolinking Setup
34
34
  ../nitrogen/generated/android/WalletNativeOnLoad.cpp
35
35
  # Shared Nitrogen C++ sources
36
+ ../nitrogen/generated/shared/c++/HybridCloudKitStoreSpec.cpp
37
+ ../nitrogen/generated/shared/c++/HybridGoogleDriveAuthSpec.cpp
36
38
  ../nitrogen/generated/shared/c++/HybridKernelHostSpec.cpp
39
+ ../nitrogen/generated/shared/c++/HybridSecureInputViewSpec.cpp
40
+ ../nitrogen/generated/shared/c++/views/HybridSecureInputViewComponent.cpp
37
41
  # Android-specific Nitrogen C++ sources
38
-
42
+ ../nitrogen/generated/android/c++/JHybridGoogleDriveAuthSpec.cpp
43
+ ../nitrogen/generated/android/c++/JHybridSecureInputViewSpec.cpp
44
+ ../nitrogen/generated/android/c++/views/JHybridSecureInputViewStateUpdater.cpp
39
45
  )
40
46
 
41
47
  # From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
@@ -15,7 +15,12 @@
15
15
  #include <fbjni/fbjni.h>
16
16
  #include <NitroModules/HybridObjectRegistry.hpp>
17
17
 
18
+ #include "JHybridGoogleDriveAuthSpec.hpp"
19
+ #include "JHybridSecureInputViewSpec.hpp"
20
+ #include "JFunc_void_SecureInputState.hpp"
21
+ #include "views/JHybridSecureInputViewStateUpdater.hpp"
18
22
  #include "HybridKernelHost.hpp"
23
+ #include <NitroModules/DefaultConstructableObject.hpp>
19
24
 
20
25
  namespace margelo::nitro::qntxwallet {
21
26
 
@@ -25,14 +30,32 @@ int initialize(JavaVM* vm) {
25
30
  });
26
31
  }
27
32
 
28
-
33
+ struct JHybridSecureInputViewSpecImpl: public jni::JavaClass<JHybridSecureInputViewSpecImpl, JHybridSecureInputViewSpec::JavaPart> {
34
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/HybridSecureInputView;";
35
+ static std::shared_ptr<JHybridSecureInputViewSpec> create() {
36
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridSecureInputViewSpecImpl::javaobject()>();
37
+ jni::local_ref<JHybridSecureInputViewSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
38
+ return javaPart->getJHybridSecureInputViewSpec();
39
+ }
40
+ };
41
+ struct JHybridGoogleDriveAuthSpecImpl: public jni::JavaClass<JHybridGoogleDriveAuthSpecImpl, JHybridGoogleDriveAuthSpec::JavaPart> {
42
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/HybridGoogleDriveAuth;";
43
+ static std::shared_ptr<JHybridGoogleDriveAuthSpec> create() {
44
+ static const auto constructorFn = javaClassStatic()->getConstructor<JHybridGoogleDriveAuthSpecImpl::javaobject()>();
45
+ jni::local_ref<JHybridGoogleDriveAuthSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
46
+ return javaPart->getJHybridGoogleDriveAuthSpec();
47
+ }
48
+ };
29
49
 
30
50
  void registerAllNatives() {
31
51
  using namespace margelo::nitro;
32
52
  using namespace margelo::nitro::qntxwallet;
33
53
 
34
54
  // Register native JNI methods
35
-
55
+ margelo::nitro::qntxwallet::JHybridGoogleDriveAuthSpec::CxxPart::registerNatives();
56
+ margelo::nitro::qntxwallet::JHybridSecureInputViewSpec::CxxPart::registerNatives();
57
+ margelo::nitro::qntxwallet::JFunc_void_SecureInputState_cxx::registerNatives();
58
+ margelo::nitro::qntxwallet::views::JHybridSecureInputViewStateUpdater::registerNatives();
36
59
 
37
60
  // Register Nitro Hybrid Objects
38
61
  HybridObjectRegistry::registerHybridObjectConstructor(
@@ -44,6 +67,18 @@ void registerAllNatives() {
44
67
  return std::make_shared<HybridKernelHost>();
45
68
  }
46
69
  );
70
+ HybridObjectRegistry::registerHybridObjectConstructor(
71
+ "SecureInputView",
72
+ []() -> std::shared_ptr<HybridObject> {
73
+ return JHybridSecureInputViewSpecImpl::create();
74
+ }
75
+ );
76
+ HybridObjectRegistry::registerHybridObjectConstructor(
77
+ "GoogleDriveAuth",
78
+ []() -> std::shared_ptr<HybridObject> {
79
+ return JHybridGoogleDriveAuthSpecImpl::create();
80
+ }
81
+ );
47
82
  }
48
83
 
49
84
  } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_SecureInputState.hpp
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
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include "SecureInputState.hpp"
14
+ #include <functional>
15
+ #include <NitroModules/JNICallable.hpp>
16
+ #include "JSecureInputState.hpp"
17
+
18
+ namespace margelo::nitro::qntxwallet {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(state: SecureInputState) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_SecureInputState: public jni::JavaClass<JFunc_void_SecureInputState> {
27
+ public:
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/Func_void_SecureInputState;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_SecureInputState` instance holds through JNI.
33
+ */
34
+ void invoke(SecureInputState state) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSecureInputState> /* state */)>("invoke");
36
+ method(self(), JSecureInputState::fromCpp(state));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_SecureInputState that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ class JFunc_void_SecureInputState_cxx final: public jni::HybridClass<JFunc_void_SecureInputState_cxx, JFunc_void_SecureInputState> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_SecureInputState::javaobject> fromCpp(const std::function<void(SecureInputState /* state */)>& func) {
46
+ return JFunc_void_SecureInputState_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_SecureInputState_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JSecureInputState> state) {
54
+ _func(state->toCpp());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(SecureInputState /* state */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/Func_void_SecureInputState_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_SecureInputState_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_SecureInputState_cxx(const std::function<void(SecureInputState /* state */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(SecureInputState /* state */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,82 @@
1
+ ///
2
+ /// JHybridGoogleDriveAuthSpec.cpp
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
+ #include "JHybridGoogleDriveAuthSpec.hpp"
9
+
10
+
11
+
12
+ #include <string>
13
+ #include <NitroModules/Promise.hpp>
14
+ #include <NitroModules/JPromise.hpp>
15
+ #include <NitroModules/JUnit.hpp>
16
+
17
+ namespace margelo::nitro::qntxwallet {
18
+
19
+ std::shared_ptr<JHybridGoogleDriveAuthSpec> JHybridGoogleDriveAuthSpec::JavaPart::getJHybridGoogleDriveAuthSpec() {
20
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
21
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridGoogleDriveAuthSpec>(hybridObject);
22
+ if (castHybridObject == nullptr) [[unlikely]] {
23
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridGoogleDriveAuthSpec!");
24
+ }
25
+ return castHybridObject;
26
+ }
27
+
28
+ jni::local_ref<JHybridGoogleDriveAuthSpec::CxxPart::jhybriddata> JHybridGoogleDriveAuthSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
29
+ return makeCxxInstance(jThis);
30
+ }
31
+
32
+ std::shared_ptr<JHybridObject> JHybridGoogleDriveAuthSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
33
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridGoogleDriveAuthSpec::JavaPart>(javaPart);
34
+ if (castJavaPart == nullptr) [[unlikely]] {
35
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridGoogleDriveAuthSpec::JavaPart!");
36
+ }
37
+ return std::make_shared<JHybridGoogleDriveAuthSpec>(castJavaPart);
38
+ }
39
+
40
+ void JHybridGoogleDriveAuthSpec::CxxPart::registerNatives() {
41
+ registerHybrid({
42
+ makeNativeMethod("initHybrid", JHybridGoogleDriveAuthSpec::CxxPart::initHybrid),
43
+ });
44
+ }
45
+
46
+ // Properties
47
+
48
+
49
+ // Methods
50
+ std::shared_ptr<Promise<std::string>> JHybridGoogleDriveAuthSpec::accessToken(bool interactive) {
51
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jboolean /* interactive */)>("accessToken");
52
+ auto __result = method(_javaPart, interactive);
53
+ return [&]() {
54
+ auto __promise = Promise<std::string>::create();
55
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
56
+ auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
57
+ __promise->resolve(__result->toStdString());
58
+ });
59
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
60
+ jni::JniException __jniError(__throwable);
61
+ __promise->reject(std::make_exception_ptr(__jniError));
62
+ });
63
+ return __promise;
64
+ }();
65
+ }
66
+ std::shared_ptr<Promise<void>> JHybridGoogleDriveAuthSpec::clearToken(const std::string& token) {
67
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* token */)>("clearToken");
68
+ auto __result = method(_javaPart, jni::make_jstring(token));
69
+ return [&]() {
70
+ auto __promise = Promise<void>::create();
71
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
72
+ __promise->resolve();
73
+ });
74
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
75
+ jni::JniException __jniError(__throwable);
76
+ __promise->reject(std::make_exception_ptr(__jniError));
77
+ });
78
+ return __promise;
79
+ }();
80
+ }
81
+
82
+ } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// HybridGoogleDriveAuthSpec.hpp
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
+ #pragma once
9
+
10
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridGoogleDriveAuthSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::qntxwallet {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridGoogleDriveAuthSpec: public virtual HybridGoogleDriveAuthSpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/HybridGoogleDriveAuthSpec;";
25
+ std::shared_ptr<JHybridGoogleDriveAuthSpec> getJHybridGoogleDriveAuthSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/HybridGoogleDriveAuthSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridGoogleDriveAuthSpec(const jni::local_ref<JHybridGoogleDriveAuthSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridGoogleDriveAuthSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridGoogleDriveAuthSpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridGoogleDriveAuthSpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+
54
+
55
+ public:
56
+ // Methods
57
+ std::shared_ptr<Promise<std::string>> accessToken(bool interactive) override;
58
+ std::shared_ptr<Promise<void>> clearToken(const std::string& token) override;
59
+
60
+ private:
61
+ jni::global_ref<JHybridGoogleDriveAuthSpec::JavaPart> _javaPart;
62
+ };
63
+
64
+ } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,70 @@
1
+ ///
2
+ /// JHybridSecureInputViewSpec.cpp
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
+ #include "JHybridSecureInputViewSpec.hpp"
9
+
10
+ // Forward declaration of `SecureInputState` to properly resolve imports.
11
+ namespace margelo::nitro::qntxwallet { enum class SecureInputState; }
12
+
13
+ #include "SecureInputState.hpp"
14
+ #include <functional>
15
+ #include "JFunc_void_SecureInputState.hpp"
16
+ #include <NitroModules/JNICallable.hpp>
17
+ #include "JSecureInputState.hpp"
18
+
19
+ namespace margelo::nitro::qntxwallet {
20
+
21
+ std::shared_ptr<JHybridSecureInputViewSpec> JHybridSecureInputViewSpec::JavaPart::getJHybridSecureInputViewSpec() {
22
+ auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
23
+ auto castHybridObject = std::dynamic_pointer_cast<JHybridSecureInputViewSpec>(hybridObject);
24
+ if (castHybridObject == nullptr) [[unlikely]] {
25
+ throw std::runtime_error("Failed to downcast JHybridObject to JHybridSecureInputViewSpec!");
26
+ }
27
+ return castHybridObject;
28
+ }
29
+
30
+ jni::local_ref<JHybridSecureInputViewSpec::CxxPart::jhybriddata> JHybridSecureInputViewSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
31
+ return makeCxxInstance(jThis);
32
+ }
33
+
34
+ std::shared_ptr<JHybridObject> JHybridSecureInputViewSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
35
+ auto castJavaPart = jni::dynamic_ref_cast<JHybridSecureInputViewSpec::JavaPart>(javaPart);
36
+ if (castJavaPart == nullptr) [[unlikely]] {
37
+ throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridSecureInputViewSpec::JavaPart!");
38
+ }
39
+ return std::make_shared<JHybridSecureInputViewSpec>(castJavaPart);
40
+ }
41
+
42
+ void JHybridSecureInputViewSpec::CxxPart::registerNatives() {
43
+ registerHybrid({
44
+ makeNativeMethod("initHybrid", JHybridSecureInputViewSpec::CxxPart::initHybrid),
45
+ });
46
+ }
47
+
48
+ // Properties
49
+ std::function<void(SecureInputState /* state */)> JHybridSecureInputViewSpec::getOnStateChange() {
50
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_SecureInputState::javaobject>()>("getOnStateChange_cxx");
51
+ auto __result = method(_javaPart);
52
+ return [&]() -> std::function<void(SecureInputState /* state */)> {
53
+ if (__result->isInstanceOf(JFunc_void_SecureInputState_cxx::javaClassStatic())) [[likely]] {
54
+ auto downcast = jni::static_ref_cast<JFunc_void_SecureInputState_cxx::javaobject>(__result);
55
+ return downcast->cthis()->getFunction();
56
+ } else {
57
+ auto __resultRef = jni::make_global(__result);
58
+ return JNICallable<JFunc_void_SecureInputState, void(SecureInputState)>(std::move(__resultRef));
59
+ }
60
+ }();
61
+ }
62
+ void JHybridSecureInputViewSpec::setOnStateChange(const std::function<void(SecureInputState /* state */)>& onStateChange) {
63
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_SecureInputState::javaobject> /* onStateChange */)>("setOnStateChange_cxx");
64
+ method(_javaPart, JFunc_void_SecureInputState_cxx::fromCpp(onStateChange));
65
+ }
66
+
67
+ // Methods
68
+
69
+
70
+ } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// HybridSecureInputViewSpec.hpp
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
+ #pragma once
9
+
10
+ #include <NitroModules/JHybridObject.hpp>
11
+ #include <fbjni/fbjni.h>
12
+ #include "HybridSecureInputViewSpec.hpp"
13
+
14
+
15
+
16
+
17
+ namespace margelo::nitro::qntxwallet {
18
+
19
+ using namespace facebook;
20
+
21
+ class JHybridSecureInputViewSpec: public virtual HybridSecureInputViewSpec, public virtual JHybridObject {
22
+ public:
23
+ struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/HybridSecureInputViewSpec;";
25
+ std::shared_ptr<JHybridSecureInputViewSpec> getJHybridSecureInputViewSpec();
26
+ };
27
+ struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
28
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/HybridSecureInputViewSpec$CxxPart;";
29
+ static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
30
+ static void registerNatives();
31
+ using HybridBase::HybridBase;
32
+ protected:
33
+ std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
34
+ };
35
+
36
+ public:
37
+ explicit JHybridSecureInputViewSpec(const jni::local_ref<JHybridSecureInputViewSpec::JavaPart>& javaPart):
38
+ HybridObject(HybridSecureInputViewSpec::TAG),
39
+ JHybridObject(javaPart),
40
+ _javaPart(jni::make_global(javaPart)) {}
41
+ ~JHybridSecureInputViewSpec() override {
42
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
43
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
44
+ }
45
+
46
+ public:
47
+ inline const jni::global_ref<JHybridSecureInputViewSpec::JavaPart>& getJavaPart() const noexcept {
48
+ return _javaPart;
49
+ }
50
+
51
+ public:
52
+ // Properties
53
+ std::function<void(SecureInputState /* state */)> getOnStateChange() override;
54
+ void setOnStateChange(const std::function<void(SecureInputState /* state */)>& onStateChange) override;
55
+
56
+ public:
57
+ // Methods
58
+
59
+
60
+ private:
61
+ jni::global_ref<JHybridSecureInputViewSpec::JavaPart> _javaPart;
62
+ };
63
+
64
+ } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JSecureInputState.hpp
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
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "SecureInputState.hpp"
12
+
13
+ namespace margelo::nitro::qntxwallet {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "SecureInputState" and the Kotlin enum "SecureInputState".
19
+ */
20
+ struct JSecureInputState final: public jni::JavaClass<JSecureInputState> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/qntxwallet/SecureInputState;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum SecureInputState.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ SecureInputState toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<SecureInputState>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JSecureInputState> fromCpp(SecureInputState value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case SecureInputState::IDLE:
46
+ static const auto fieldIDLE = clazz->getStaticField<JSecureInputState>("IDLE");
47
+ return clazz->getStaticFieldValue(fieldIDLE);
48
+ case SecureInputState::EMPTY:
49
+ static const auto fieldEMPTY = clazz->getStaticField<JSecureInputState>("EMPTY");
50
+ return clazz->getStaticFieldValue(fieldEMPTY);
51
+ case SecureInputState::FILLED:
52
+ static const auto fieldFILLED = clazz->getStaticField<JSecureInputState>("FILLED");
53
+ return clazz->getStaticFieldValue(fieldFILLED);
54
+ case SecureInputState::SUBMITTED:
55
+ static const auto fieldSUBMITTED = clazz->getStaticField<JSecureInputState>("SUBMITTED");
56
+ return clazz->getStaticFieldValue(fieldSUBMITTED);
57
+ default:
58
+ std::string stringValue = std::to_string(static_cast<int>(value));
59
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
60
+ }
61
+ }
62
+ };
63
+
64
+ } // namespace margelo::nitro::qntxwallet
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// JHybridSecureInputViewStateUpdater.cpp
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
+ #include "JHybridSecureInputViewStateUpdater.hpp"
9
+ #include "views/HybridSecureInputViewComponent.hpp"
10
+ #include <NitroModules/NitroDefines.hpp>
11
+ #include <react/fabric/StateWrapperImpl.h>
12
+
13
+ namespace margelo::nitro::qntxwallet::views {
14
+
15
+ using namespace facebook;
16
+ using ConcreteStateData = react::ConcreteState<HybridSecureInputViewState>;
17
+
18
+ std::shared_ptr<const HybridSecureInputViewProps> JHybridSecureInputViewStateUpdater::getPropsFromStateWrapper(
19
+ jni::alias_ref<JStateWrapper::javaobject> stateWrapper) {
20
+ if (stateWrapper.get() == nullptr) {
21
+ return nullptr;
22
+ }
23
+ // Get concrete StateWrapperImpl from passed StateWrapper interface object
24
+ jobject rawStateWrapper = stateWrapper.get();
25
+ if (!stateWrapper->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
26
+ throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
27
+ }
28
+ auto stateWrapperImpl = jni::alias_ref<react::StateWrapperImpl::javaobject>{
29
+ static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)
30
+ };
31
+ std::shared_ptr<const react::State> state = stateWrapperImpl->cthis()->getState();
32
+ if (state == nullptr) {
33
+ return nullptr;
34
+ }
35
+ auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
36
+ const HybridSecureInputViewState& data = concreteState->getData();
37
+ const std::shared_ptr<const HybridSecureInputViewProps>& props = data.getProps();
38
+ if (props == nullptr) [[unlikely]] {
39
+ throw std::runtime_error("HybridSecureInputViewState's data doesn't contain any props!");
40
+ }
41
+ return props;
42
+ }
43
+
44
+ void JHybridSecureInputViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
45
+ jni::alias_ref<JHybridSecureInputViewSpec::JavaPart> javaView,
46
+ jni::alias_ref<JStateWrapper::javaobject> newState,
47
+ jni::alias_ref<JStateWrapper::javaobject> oldState) {
48
+ std::shared_ptr<JHybridSecureInputViewSpec> hybridView = javaView->getJHybridSecureInputViewSpec();
49
+ std::shared_ptr<const HybridSecureInputViewProps> newProps = getPropsFromStateWrapper(newState);
50
+ std::shared_ptr<const HybridSecureInputViewProps> oldProps = getPropsFromStateWrapper(oldState);
51
+ if (newProps == nullptr) [[unlikely]] {
52
+ throw std::runtime_error("Current StateWrapper doesn't contain any props!");
53
+ }
54
+
55
+ // Update only props that differ from the previous State snapshot.
56
+ if (oldProps == nullptr
57
+ ? newProps->onStateChange.isProvided()
58
+ : !newProps->onStateChange.hasSameValue(oldProps->onStateChange)) {
59
+ hybridView->setOnStateChange(newProps->onStateChange.get());
60
+ }
61
+
62
+ // Update hybridRef if it changed
63
+ if (oldProps == nullptr
64
+ ? newProps->hybridRef.isProvided()
65
+ : !newProps->hybridRef.hasSameValue(oldProps->hybridRef)) {
66
+ // hybridRef changed - call it with new this
67
+ const auto& maybeFunc = newProps->hybridRef.get();
68
+ if (maybeFunc.has_value()) {
69
+ maybeFunc.value()(hybridView);
70
+ }
71
+ }
72
+ }
73
+
74
+ } // namespace margelo::nitro::qntxwallet::views