@onekeyfe/react-native-app-update 1.1.27 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/margelo/nitro/reactnativeappupdate/ReactNativeAppUpdate.kt +56 -2
- package/ios/ReactNativeAppUpdate.swift +10 -0
- package/lib/typescript/src/ReactNativeAppUpdate.nitro.d.ts +2 -0
- package/lib/typescript/src/ReactNativeAppUpdate.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridReactNativeAppUpdateSpec.cpp +32 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeAppUpdateSpec.hpp +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativeappupdate/HybridReactNativeAppUpdateSpec.kt +8 -0
- package/nitrogen/generated/ios/ReactNativeAppUpdate-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/ReactNativeAppUpdate-Swift-Cxx-Bridge.hpp +43 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeAppUpdateSpecSwift.hpp +16 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeAppUpdateSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeAppUpdateSpec_cxx.swift +38 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeAppUpdateSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeAppUpdateSpec.hpp +2 -0
- package/package.json +1 -1
- package/src/ReactNativeAppUpdate.nitro.ts +4 -0
package/android/src/main/java/com/margelo/nitro/reactnativeappupdate/ReactNativeAppUpdate.kt
CHANGED
|
@@ -237,8 +237,11 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
|
|
|
237
237
|
* Verify GPG signature of an ASC file and extract the SHA256 hash.
|
|
238
238
|
* Returns the SHA256 hash if signature is valid, null otherwise.
|
|
239
239
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Verify GPG signature of ASC content string and extract the SHA256 hash.
|
|
242
|
+
* Returns the SHA256 hash if signature is valid, null otherwise.
|
|
243
|
+
*/
|
|
244
|
+
private fun verifyAscContentAndExtractSha256(ascContent: String): String? {
|
|
242
245
|
if (!ascContent.contains("-----BEGIN PGP SIGNED MESSAGE-----")) return null
|
|
243
246
|
|
|
244
247
|
val lines = ascContent.lines()
|
|
@@ -277,6 +280,10 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
|
|
|
277
280
|
return sha256
|
|
278
281
|
}
|
|
279
282
|
|
|
283
|
+
private fun verifyAscAndExtractSha256(ascFile: File): String? {
|
|
284
|
+
return verifyAscContentAndExtractSha256(ascFile.readText())
|
|
285
|
+
}
|
|
286
|
+
|
|
280
287
|
/** Constant-time comparison to prevent timing attacks on hash values */
|
|
281
288
|
private fun secureCompare(a: String, b: String): Boolean {
|
|
282
289
|
val aBytes = a.toByteArray(Charsets.UTF_8)
|
|
@@ -837,6 +844,53 @@ class ReactNativeAppUpdate : HybridReactNativeAppUpdateSpec() {
|
|
|
837
844
|
}
|
|
838
845
|
}
|
|
839
846
|
|
|
847
|
+
override fun testVerification(): Promise<Boolean> {
|
|
848
|
+
return Promise.async {
|
|
849
|
+
val testSignature = """-----BEGIN PGP SIGNED MESSAGE-----
|
|
850
|
+
Hash: SHA256
|
|
851
|
+
|
|
852
|
+
{
|
|
853
|
+
"fileName": "metadata.json",
|
|
854
|
+
"sha256": "2ada9c871104fc40649fa3de67a7d8e33faadc18e9abd587e8bb85be0a003eba",
|
|
855
|
+
"size": 158590,
|
|
856
|
+
"generatedAt": "2025-09-19T07:49:13.000Z"
|
|
857
|
+
}
|
|
858
|
+
-----BEGIN PGP SIGNATURE-----
|
|
859
|
+
|
|
860
|
+
iQJCBAEBCAAsFiEE62iuVE8f3YzSZGJPs2mmepC/OHsFAmjNJ1IOHGRldkBvbmVr
|
|
861
|
+
ZXkuc28ACgkQs2mmepC/OHs6Rw/9FKHl5aNsE7V0IsFf/l+h16BYKFwVsL69alMk
|
|
862
|
+
CFLna8oUn0+tyECF6wKBKw5pHo5YR27o2pJfYbAER6dygDF6WTZ1lZdf5QcBMjGA
|
|
863
|
+
LCeXC0hzUBzSSOH4bKBTa3fHp//HdSV1F2OnkymbXqYN7WXvuQPLZ0nV6aU88hCk
|
|
864
|
+
HgFifcvkXAnWKoosUtj0Bban/YBRyvmQ5C2akxUPEkr4Yck1QXwzJeNRd7wMXHjH
|
|
865
|
+
JFK6lJcuABiB8wpJDXJkFzKs29pvHIK2B2vdOjU2rQzKOUwaKHofDi5C4+JitT2b
|
|
866
|
+
2pSeYP3PAxXYw6XDOmKTOiC7fPnfLjtcPjNYNFCezVKZT6LKvZW9obnW8Q9LNJ4W
|
|
867
|
+
okMPgHObkabv3OqUaTA9QNVfI/X9nvggzlPnaKDUrDWTf7n3vlrdexugkLtV/tJA
|
|
868
|
+
uguPlI5hY7Ue5OW7ckWP46hfmq1+UaIdeUY7dEO+rPZDz6KcArpaRwBiLPBhneIr
|
|
869
|
+
/X3KuMzS272YbPbavgCZGN9xJR5kZsEQE5HhPCbr6Nf0qDnh+X8mg0tAB/U6F+ZE
|
|
870
|
+
o90sJL1ssIaYvST+VWVaGRr4V5nMDcgHzWSF9Q/wm22zxe4alDaBdvOlUseW0iaM
|
|
871
|
+
n2DMz6gqk326W6SFynYtvuiXo7wG4Cmn3SuIU8xfv9rJqunpZGYchMd7nZektmEJ
|
|
872
|
+
91Js0rQ=
|
|
873
|
+
=A/Ii
|
|
874
|
+
-----END PGP SIGNATURE-----"""
|
|
875
|
+
val result = verifyAscContentAndExtractSha256(testSignature)
|
|
876
|
+
val isValid = result == "2ada9c871104fc40649fa3de67a7d8e33faadc18e9abd587e8bb85be0a003eba"
|
|
877
|
+
OneKeyLog.info("AppUpdate", "testVerification: GPG verification result: $isValid")
|
|
878
|
+
isValid
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
override fun testSkipVerification(): Promise<Boolean> {
|
|
883
|
+
return Promise.async {
|
|
884
|
+
val result = if (BuildConfig.ALLOW_SKIP_GPG_VERIFICATION) {
|
|
885
|
+
isDevSettingsEnabled() && isSkipGPGEnabled()
|
|
886
|
+
} else {
|
|
887
|
+
false
|
|
888
|
+
}
|
|
889
|
+
OneKeyLog.info("AppUpdate", "testSkipVerification: result=$result")
|
|
890
|
+
result
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
840
894
|
override fun clearCache(): Promise<Unit> {
|
|
841
895
|
return Promise.async {
|
|
842
896
|
OneKeyLog.info("AppUpdate", "clearCache: starting cleanup...")
|
|
@@ -30,6 +30,16 @@ class ReactNativeAppUpdate: HybridReactNativeAppUpdateSpec {
|
|
|
30
30
|
return Promise.resolved(withResult: ())
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
func testVerification() throws -> Promise<Bool> {
|
|
34
|
+
OneKeyLog.debug("AppUpdate", "testVerification not available on iOS")
|
|
35
|
+
return Promise.resolved(withResult: true)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func testSkipVerification() throws -> Promise<Bool> {
|
|
39
|
+
OneKeyLog.debug("AppUpdate", "testSkipVerification not available on iOS")
|
|
40
|
+
return Promise.resolved(withResult: false)
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
func clearCache() throws -> Promise<Void> {
|
|
34
44
|
return Promise.resolved(withResult: ())
|
|
35
45
|
}
|
|
@@ -22,6 +22,8 @@ export interface ReactNativeAppUpdate extends HybridObject<{
|
|
|
22
22
|
verifyAPK(params: AppUpdateFileParams): Promise<void>;
|
|
23
23
|
installAPK(params: AppUpdateFileParams): Promise<void>;
|
|
24
24
|
clearCache(): Promise<void>;
|
|
25
|
+
testVerification(): Promise<boolean>;
|
|
26
|
+
testSkipVerification(): Promise<boolean>;
|
|
25
27
|
addDownloadListener(callback: (event: DownloadEvent) => void): number;
|
|
26
28
|
removeDownloadListener(id: number): void;
|
|
27
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeAppUpdate.nitro.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeAppUpdate.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,WAAW,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ReactNativeAppUpdate.nitro.d.ts","sourceRoot":"","sources":["../../../src/ReactNativeAppUpdate.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,WAAW,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,SAAS,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,UAAU,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAG5B,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,CAAC;IACtE,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C"}
|
|
@@ -149,6 +149,38 @@ namespace margelo::nitro::reactnativeappupdate {
|
|
|
149
149
|
return __promise;
|
|
150
150
|
}();
|
|
151
151
|
}
|
|
152
|
+
std::shared_ptr<Promise<bool>> JHybridReactNativeAppUpdateSpec::testVerification() {
|
|
153
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("testVerification");
|
|
154
|
+
auto __result = method(_javaPart);
|
|
155
|
+
return [&]() {
|
|
156
|
+
auto __promise = Promise<bool>::create();
|
|
157
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
158
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
159
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
160
|
+
});
|
|
161
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
162
|
+
jni::JniException __jniError(__throwable);
|
|
163
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
164
|
+
});
|
|
165
|
+
return __promise;
|
|
166
|
+
}();
|
|
167
|
+
}
|
|
168
|
+
std::shared_ptr<Promise<bool>> JHybridReactNativeAppUpdateSpec::testSkipVerification() {
|
|
169
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("testSkipVerification");
|
|
170
|
+
auto __result = method(_javaPart);
|
|
171
|
+
return [&]() {
|
|
172
|
+
auto __promise = Promise<bool>::create();
|
|
173
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
174
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
175
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
176
|
+
});
|
|
177
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
178
|
+
jni::JniException __jniError(__throwable);
|
|
179
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
180
|
+
});
|
|
181
|
+
return __promise;
|
|
182
|
+
}();
|
|
183
|
+
}
|
|
152
184
|
double JHybridReactNativeAppUpdateSpec::addDownloadListener(const std::function<void(const DownloadEvent& /* event */)>& callback) {
|
|
153
185
|
static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<JFunc_void_DownloadEvent::javaobject> /* callback */)>("addDownloadListener_cxx");
|
|
154
186
|
auto __result = method(_javaPart, JFunc_void_DownloadEvent_cxx::fromCpp(callback));
|
|
@@ -60,6 +60,8 @@ namespace margelo::nitro::reactnativeappupdate {
|
|
|
60
60
|
std::shared_ptr<Promise<void>> verifyAPK(const AppUpdateFileParams& params) override;
|
|
61
61
|
std::shared_ptr<Promise<void>> installAPK(const AppUpdateFileParams& params) override;
|
|
62
62
|
std::shared_ptr<Promise<void>> clearCache() override;
|
|
63
|
+
std::shared_ptr<Promise<bool>> testVerification() override;
|
|
64
|
+
std::shared_ptr<Promise<bool>> testSkipVerification() override;
|
|
63
65
|
double addDownloadListener(const std::function<void(const DownloadEvent& /* event */)>& callback) override;
|
|
64
66
|
void removeDownloadListener(double id) override;
|
|
65
67
|
|
|
@@ -70,6 +70,14 @@ abstract class HybridReactNativeAppUpdateSpec: HybridObject() {
|
|
|
70
70
|
@Keep
|
|
71
71
|
abstract fun clearCache(): Promise<Unit>
|
|
72
72
|
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
abstract fun testVerification(): Promise<Boolean>
|
|
76
|
+
|
|
77
|
+
@DoNotStrip
|
|
78
|
+
@Keep
|
|
79
|
+
abstract fun testSkipVerification(): Promise<Boolean>
|
|
80
|
+
|
|
73
81
|
abstract fun addDownloadListener(callback: (event: DownloadEvent) -> Unit): Double
|
|
74
82
|
|
|
75
83
|
@DoNotStrip
|
|
@@ -30,6 +30,14 @@ namespace margelo::nitro::reactnativeappupdate::bridge::swift {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// pragma MARK: std::function<void(bool /* result */)>
|
|
34
|
+
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
|
+
auto swiftClosure = ReactNativeAppUpdate::Func_void_bool::fromUnsafe(swiftClosureWrapper);
|
|
36
|
+
return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
|
|
37
|
+
swiftClosure.call(result);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
// pragma MARK: std::function<void(const DownloadEvent& /* event */)>
|
|
34
42
|
Func_void_DownloadEvent create_Func_void_DownloadEvent(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
35
43
|
auto swiftClosure = ReactNativeAppUpdate::Func_void_DownloadEvent::fromUnsafe(swiftClosureWrapper);
|
|
@@ -90,6 +90,40 @@ namespace margelo::nitro::reactnativeappupdate::bridge::swift {
|
|
|
90
90
|
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// pragma MARK: std::shared_ptr<Promise<bool>>
|
|
94
|
+
/**
|
|
95
|
+
* Specialized version of `std::shared_ptr<Promise<bool>>`.
|
|
96
|
+
*/
|
|
97
|
+
using std__shared_ptr_Promise_bool__ = std::shared_ptr<Promise<bool>>;
|
|
98
|
+
inline std::shared_ptr<Promise<bool>> create_std__shared_ptr_Promise_bool__() noexcept {
|
|
99
|
+
return Promise<bool>::create();
|
|
100
|
+
}
|
|
101
|
+
inline PromiseHolder<bool> wrap_std__shared_ptr_Promise_bool__(std::shared_ptr<Promise<bool>> promise) noexcept {
|
|
102
|
+
return PromiseHolder<bool>(std::move(promise));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// pragma MARK: std::function<void(bool /* result */)>
|
|
106
|
+
/**
|
|
107
|
+
* Specialized version of `std::function<void(bool)>`.
|
|
108
|
+
*/
|
|
109
|
+
using Func_void_bool = std::function<void(bool /* result */)>;
|
|
110
|
+
/**
|
|
111
|
+
* Wrapper class for a `std::function<void(bool / * result * /)>`, this can be used from Swift.
|
|
112
|
+
*/
|
|
113
|
+
class Func_void_bool_Wrapper final {
|
|
114
|
+
public:
|
|
115
|
+
explicit Func_void_bool_Wrapper(std::function<void(bool /* result */)>&& func): _function(std::make_unique<std::function<void(bool /* result */)>>(std::move(func))) {}
|
|
116
|
+
inline void call(bool result) const noexcept {
|
|
117
|
+
_function->operator()(result);
|
|
118
|
+
}
|
|
119
|
+
private:
|
|
120
|
+
std::unique_ptr<std::function<void(bool /* result */)>> _function;
|
|
121
|
+
} SWIFT_NONCOPYABLE;
|
|
122
|
+
Func_void_bool create_Func_void_bool(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
123
|
+
inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) noexcept {
|
|
124
|
+
return Func_void_bool_Wrapper(std::move(value));
|
|
125
|
+
}
|
|
126
|
+
|
|
93
127
|
// pragma MARK: std::function<void(const DownloadEvent& /* event */)>
|
|
94
128
|
/**
|
|
95
129
|
* Specialized version of `std::function<void(const DownloadEvent&)>`.
|
|
@@ -133,6 +167,15 @@ namespace margelo::nitro::reactnativeappupdate::bridge::swift {
|
|
|
133
167
|
return Result<std::shared_ptr<Promise<void>>>::withError(error);
|
|
134
168
|
}
|
|
135
169
|
|
|
170
|
+
// pragma MARK: Result<std::shared_ptr<Promise<bool>>>
|
|
171
|
+
using Result_std__shared_ptr_Promise_bool___ = Result<std::shared_ptr<Promise<bool>>>;
|
|
172
|
+
inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::shared_ptr<Promise<bool>>& value) noexcept {
|
|
173
|
+
return Result<std::shared_ptr<Promise<bool>>>::withValue(value);
|
|
174
|
+
}
|
|
175
|
+
inline Result_std__shared_ptr_Promise_bool___ create_Result_std__shared_ptr_Promise_bool___(const std::exception_ptr& error) noexcept {
|
|
176
|
+
return Result<std::shared_ptr<Promise<bool>>>::withError(error);
|
|
177
|
+
}
|
|
178
|
+
|
|
136
179
|
// pragma MARK: Result<double>
|
|
137
180
|
using Result_double_ = Result<double>;
|
|
138
181
|
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
@@ -118,6 +118,22 @@ namespace margelo::nitro::reactnativeappupdate {
|
|
|
118
118
|
auto __value = std::move(__result.value());
|
|
119
119
|
return __value;
|
|
120
120
|
}
|
|
121
|
+
inline std::shared_ptr<Promise<bool>> testVerification() override {
|
|
122
|
+
auto __result = _swiftPart.testVerification();
|
|
123
|
+
if (__result.hasError()) [[unlikely]] {
|
|
124
|
+
std::rethrow_exception(__result.error());
|
|
125
|
+
}
|
|
126
|
+
auto __value = std::move(__result.value());
|
|
127
|
+
return __value;
|
|
128
|
+
}
|
|
129
|
+
inline std::shared_ptr<Promise<bool>> testSkipVerification() override {
|
|
130
|
+
auto __result = _swiftPart.testSkipVerification();
|
|
131
|
+
if (__result.hasError()) [[unlikely]] {
|
|
132
|
+
std::rethrow_exception(__result.error());
|
|
133
|
+
}
|
|
134
|
+
auto __value = std::move(__result.value());
|
|
135
|
+
return __value;
|
|
136
|
+
}
|
|
121
137
|
inline double addDownloadListener(const std::function<void(const DownloadEvent& /* event */)>& callback) override {
|
|
122
138
|
auto __result = _swiftPart.addDownloadListener(callback);
|
|
123
139
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_bool.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: Bool) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_bool {
|
|
16
|
+
public typealias bridge = margelo.nitro.reactnativeappupdate.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: Bool) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: Bool) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: Bool) -> Void {
|
|
26
|
+
self.closure(value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_bool`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_bool>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool {
|
|
45
|
+
return Unmanaged<Func_void_bool>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -20,6 +20,8 @@ public protocol HybridReactNativeAppUpdateSpec_protocol: HybridObject {
|
|
|
20
20
|
func verifyAPK(params: AppUpdateFileParams) throws -> Promise<Void>
|
|
21
21
|
func installAPK(params: AppUpdateFileParams) throws -> Promise<Void>
|
|
22
22
|
func clearCache() throws -> Promise<Void>
|
|
23
|
+
func testVerification() throws -> Promise<Bool>
|
|
24
|
+
func testSkipVerification() throws -> Promise<Bool>
|
|
23
25
|
func addDownloadListener(callback: @escaping (_ event: DownloadEvent) -> Void) throws -> Double
|
|
24
26
|
func removeDownloadListener(id: Double) throws -> Void
|
|
25
27
|
}
|
|
@@ -231,6 +231,44 @@ open class HybridReactNativeAppUpdateSpec_cxx {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
@inline(__always)
|
|
235
|
+
public final func testVerification() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
236
|
+
do {
|
|
237
|
+
let __result = try self.__implementation.testVerification()
|
|
238
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
239
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
240
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
241
|
+
__result
|
|
242
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
243
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
244
|
+
return __promise
|
|
245
|
+
}()
|
|
246
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
247
|
+
} catch (let __error) {
|
|
248
|
+
let __exceptionPtr = __error.toCpp()
|
|
249
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
@inline(__always)
|
|
254
|
+
public final func testSkipVerification() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
255
|
+
do {
|
|
256
|
+
let __result = try self.__implementation.testSkipVerification()
|
|
257
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
258
|
+
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
259
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
260
|
+
__result
|
|
261
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
262
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
263
|
+
return __promise
|
|
264
|
+
}()
|
|
265
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
266
|
+
} catch (let __error) {
|
|
267
|
+
let __exceptionPtr = __error.toCpp()
|
|
268
|
+
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
234
272
|
@inline(__always)
|
|
235
273
|
public final func addDownloadListener(callback: bridge.Func_void_DownloadEvent) -> bridge.Result_double_ {
|
|
236
274
|
do {
|
|
@@ -20,6 +20,8 @@ namespace margelo::nitro::reactnativeappupdate {
|
|
|
20
20
|
prototype.registerHybridMethod("verifyAPK", &HybridReactNativeAppUpdateSpec::verifyAPK);
|
|
21
21
|
prototype.registerHybridMethod("installAPK", &HybridReactNativeAppUpdateSpec::installAPK);
|
|
22
22
|
prototype.registerHybridMethod("clearCache", &HybridReactNativeAppUpdateSpec::clearCache);
|
|
23
|
+
prototype.registerHybridMethod("testVerification", &HybridReactNativeAppUpdateSpec::testVerification);
|
|
24
|
+
prototype.registerHybridMethod("testSkipVerification", &HybridReactNativeAppUpdateSpec::testSkipVerification);
|
|
23
25
|
prototype.registerHybridMethod("addDownloadListener", &HybridReactNativeAppUpdateSpec::addDownloadListener);
|
|
24
26
|
prototype.registerHybridMethod("removeDownloadListener", &HybridReactNativeAppUpdateSpec::removeDownloadListener);
|
|
25
27
|
});
|
|
@@ -63,6 +63,8 @@ namespace margelo::nitro::reactnativeappupdate {
|
|
|
63
63
|
virtual std::shared_ptr<Promise<void>> verifyAPK(const AppUpdateFileParams& params) = 0;
|
|
64
64
|
virtual std::shared_ptr<Promise<void>> installAPK(const AppUpdateFileParams& params) = 0;
|
|
65
65
|
virtual std::shared_ptr<Promise<void>> clearCache() = 0;
|
|
66
|
+
virtual std::shared_ptr<Promise<bool>> testVerification() = 0;
|
|
67
|
+
virtual std::shared_ptr<Promise<bool>> testSkipVerification() = 0;
|
|
66
68
|
virtual double addDownloadListener(const std::function<void(const DownloadEvent& /* event */)>& callback) = 0;
|
|
67
69
|
virtual void removeDownloadListener(double id) = 0;
|
|
68
70
|
|
package/package.json
CHANGED
|
@@ -25,6 +25,10 @@ export interface ReactNativeAppUpdate
|
|
|
25
25
|
installAPK(params: AppUpdateFileParams): Promise<void>;
|
|
26
26
|
clearCache(): Promise<void>;
|
|
27
27
|
|
|
28
|
+
// Verification & testing
|
|
29
|
+
testVerification(): Promise<boolean>;
|
|
30
|
+
testSkipVerification(): Promise<boolean>;
|
|
31
|
+
|
|
28
32
|
addDownloadListener(callback: (event: DownloadEvent) => void): number;
|
|
29
33
|
removeDownloadListener(id: number): void;
|
|
30
34
|
}
|