@onekeyfe/react-native-bundle-crypto 3.0.39
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/LICENSE +21 -0
- package/README.md +36 -0
- package/ReactNativeBundleCrypto.podspec +35 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +136 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/reactnativebundlecrypto/BundleCryptoCore.kt +526 -0
- package/android/src/main/java/com/margelo/nitro/reactnativebundlecrypto/ReactNativeBundleCrypto.kt +110 -0
- package/android/src/main/java/com/margelo/nitro/reactnativebundlecrypto/ReactNativeBundleCryptoPackage.kt +24 -0
- package/ios/BundleCryptoCore.swift +529 -0
- package/ios/Frameworks/Gopenpgp.xcframework/Info.plist +52 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Gopenpgp +0 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Armor.objc.h +96 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Constants.objc.h +197 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Crypto.objc.h +1963 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Gopenpgp.h +23 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Mime.objc.h +59 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Mobile.objc.h +252 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Profile.objc.h +107 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/Universe.objc.h +29 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Headers/ref.h +35 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Info.plist +20 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64/Gopenpgp.framework/Modules/module.modulemap +13 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Gopenpgp +0 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Armor.objc.h +96 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Constants.objc.h +197 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Crypto.objc.h +1963 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Gopenpgp.h +23 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Mime.objc.h +59 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Mobile.objc.h +252 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Profile.objc.h +107 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/Universe.objc.h +29 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Headers/ref.h +35 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Info.plist +20 -0
- package/ios/Frameworks/Gopenpgp.xcframework/ios-arm64_x86_64-simulator/Gopenpgp.framework/Modules/module.modulemap +13 -0
- package/ios/ReactNativeBundleCrypto.swift +104 -0
- package/lib/module/ReactNativeBundleCrypto.nitro.js +4 -0
- package/lib/module/ReactNativeBundleCrypto.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/ReactNativeBundleCrypto.nitro.d.ts +35 -0
- package/lib/typescript/src/ReactNativeBundleCrypto.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JDirHashEntry.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeBundleCryptoSpec.cpp +240 -0
- package/nitrogen/generated/android/c++/JHybridReactNativeBundleCryptoSpec.hpp +74 -0
- package/nitrogen/generated/android/c++/JSha256Result.hpp +62 -0
- package/nitrogen/generated/android/c++/JVerifyDetachedAscResult.hpp +66 -0
- package/nitrogen/generated/android/c++/JVerifyGpgCleartextResult.hpp +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundlecrypto/DirHashEntry.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundlecrypto/HybridReactNativeBundleCryptoSpec.kt +94 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundlecrypto/Sha256Result.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundlecrypto/VerifyDetachedAscResult.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundlecrypto/VerifyGpgCleartextResult.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativebundlecrypto/reactnativebundlecryptoOnLoad.kt +35 -0
- package/nitrogen/generated/android/reactnativebundlecrypto+autolinking.cmake +81 -0
- package/nitrogen/generated/android/reactnativebundlecrypto+autolinking.gradle +27 -0
- package/nitrogen/generated/android/reactnativebundlecryptoOnLoad.cpp +44 -0
- package/nitrogen/generated/android/reactnativebundlecryptoOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/ReactNativeBundleCrypto+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ReactNativeBundleCrypto-Swift-Cxx-Bridge.cpp +97 -0
- package/nitrogen/generated/ios/ReactNativeBundleCrypto-Swift-Cxx-Bridge.hpp +429 -0
- package/nitrogen/generated/ios/ReactNativeBundleCrypto-Swift-Cxx-Umbrella.hpp +59 -0
- package/nitrogen/generated/ios/ReactNativeBundleCryptoAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeBundleCryptoAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeBundleCryptoSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridReactNativeBundleCryptoSpecSwift.hpp +162 -0
- package/nitrogen/generated/ios/swift/DirHashEntry.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_Sha256Result.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_VerifyDetachedAscResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_VerifyGpgCleartextResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_DirHashEntry_.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeBundleCryptoSpec.swift +65 -0
- package/nitrogen/generated/ios/swift/HybridReactNativeBundleCryptoSpec_cxx.swift +314 -0
- package/nitrogen/generated/ios/swift/Sha256Result.swift +85 -0
- package/nitrogen/generated/ios/swift/VerifyDetachedAscResult.swift +96 -0
- package/nitrogen/generated/ios/swift/VerifyGpgCleartextResult.swift +96 -0
- package/nitrogen/generated/shared/c++/DirHashEntry.hpp +79 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeBundleCryptoSpec.cpp +30 -0
- package/nitrogen/generated/shared/c++/HybridReactNativeBundleCryptoSpec.hpp +84 -0
- package/nitrogen/generated/shared/c++/Sha256Result.hpp +80 -0
- package/nitrogen/generated/shared/c++/VerifyDetachedAscResult.hpp +84 -0
- package/nitrogen/generated/shared/c++/VerifyGpgCleartextResult.hpp +84 -0
- package/package.json +169 -0
- package/src/ReactNativeBundleCrypto.nitro.ts +56 -0
- package/src/index.tsx +8 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativeBundleCryptoSpec.cpp
|
|
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
|
+
#include "HybridReactNativeBundleCryptoSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::reactnativebundlecrypto {
|
|
11
|
+
|
|
12
|
+
void HybridReactNativeBundleCryptoSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("verifyGpgCleartext", &HybridReactNativeBundleCryptoSpec::verifyGpgCleartext);
|
|
18
|
+
prototype.registerHybridMethod("verifyDetachedAsc", &HybridReactNativeBundleCryptoSpec::verifyDetachedAsc);
|
|
19
|
+
prototype.registerHybridMethod("sha256OfFile", &HybridReactNativeBundleCryptoSpec::sha256OfFile);
|
|
20
|
+
prototype.registerHybridMethod("secureEqualHex", &HybridReactNativeBundleCryptoSpec::secureEqualHex);
|
|
21
|
+
prototype.registerHybridMethod("verifyDirAgainstHashes", &HybridReactNativeBundleCryptoSpec::verifyDirAgainstHashes);
|
|
22
|
+
prototype.registerHybridMethod("hashDir", &HybridReactNativeBundleCryptoSpec::hashDir);
|
|
23
|
+
prototype.registerHybridMethod("validateExtractedPathSafety", &HybridReactNativeBundleCryptoSpec::validateExtractedPathSafety);
|
|
24
|
+
prototype.registerHybridMethod("atomicWriteFile", &HybridReactNativeBundleCryptoSpec::atomicWriteFile);
|
|
25
|
+
prototype.registerHybridMethod("safeRename", &HybridReactNativeBundleCryptoSpec::safeRename);
|
|
26
|
+
prototype.registerHybridMethod("listVersionDirs", &HybridReactNativeBundleCryptoSpec::listVersionDirs);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
} // namespace margelo::nitro::reactnativebundlecrypto
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridReactNativeBundleCryptoSpec.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `VerifyGpgCleartextResult` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::reactnativebundlecrypto { struct VerifyGpgCleartextResult; }
|
|
18
|
+
// Forward declaration of `VerifyDetachedAscResult` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::reactnativebundlecrypto { struct VerifyDetachedAscResult; }
|
|
20
|
+
// Forward declaration of `Sha256Result` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::reactnativebundlecrypto { struct Sha256Result; }
|
|
22
|
+
// Forward declaration of `DirHashEntry` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::reactnativebundlecrypto { struct DirHashEntry; }
|
|
24
|
+
|
|
25
|
+
#include "VerifyGpgCleartextResult.hpp"
|
|
26
|
+
#include <NitroModules/Promise.hpp>
|
|
27
|
+
#include <string>
|
|
28
|
+
#include "VerifyDetachedAscResult.hpp"
|
|
29
|
+
#include "Sha256Result.hpp"
|
|
30
|
+
#include "DirHashEntry.hpp"
|
|
31
|
+
#include <vector>
|
|
32
|
+
|
|
33
|
+
namespace margelo::nitro::reactnativebundlecrypto {
|
|
34
|
+
|
|
35
|
+
using namespace margelo::nitro;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* An abstract base class for `ReactNativeBundleCrypto`
|
|
39
|
+
* Inherit this class to create instances of `HybridReactNativeBundleCryptoSpec` in C++.
|
|
40
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
41
|
+
* @example
|
|
42
|
+
* ```cpp
|
|
43
|
+
* class HybridReactNativeBundleCrypto: public HybridReactNativeBundleCryptoSpec {
|
|
44
|
+
* public:
|
|
45
|
+
* HybridReactNativeBundleCrypto(...): HybridObject(TAG) { ... }
|
|
46
|
+
* // ...
|
|
47
|
+
* };
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
class HybridReactNativeBundleCryptoSpec: public virtual HybridObject {
|
|
51
|
+
public:
|
|
52
|
+
// Constructor
|
|
53
|
+
explicit HybridReactNativeBundleCryptoSpec(): HybridObject(TAG) { }
|
|
54
|
+
|
|
55
|
+
// Destructor
|
|
56
|
+
~HybridReactNativeBundleCryptoSpec() override = default;
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
// Properties
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
// Methods
|
|
64
|
+
virtual std::shared_ptr<Promise<VerifyGpgCleartextResult>> verifyGpgCleartext(const std::string& signedMessage) = 0;
|
|
65
|
+
virtual std::shared_ptr<Promise<VerifyDetachedAscResult>> verifyDetachedAsc(const std::string& ascContent) = 0;
|
|
66
|
+
virtual std::shared_ptr<Promise<Sha256Result>> sha256OfFile(const std::string& filePath) = 0;
|
|
67
|
+
virtual bool secureEqualHex(const std::string& a, const std::string& b) = 0;
|
|
68
|
+
virtual std::shared_ptr<Promise<bool>> verifyDirAgainstHashes(const std::string& dirPath, const std::vector<DirHashEntry>& entries) = 0;
|
|
69
|
+
virtual std::shared_ptr<Promise<std::vector<DirHashEntry>>> hashDir(const std::string& dirPath) = 0;
|
|
70
|
+
virtual std::shared_ptr<Promise<bool>> validateExtractedPathSafety(const std::string& destination) = 0;
|
|
71
|
+
virtual std::shared_ptr<Promise<void>> atomicWriteFile(const std::string& filePath, const std::string& contentUtf8) = 0;
|
|
72
|
+
virtual std::shared_ptr<Promise<void>> safeRename(const std::string& fromPath, const std::string& toPath) = 0;
|
|
73
|
+
virtual std::shared_ptr<Promise<std::vector<std::string>>> listVersionDirs(const std::string& parentDir) = 0;
|
|
74
|
+
|
|
75
|
+
protected:
|
|
76
|
+
// Hybrid Setup
|
|
77
|
+
void loadHybridMethods() override;
|
|
78
|
+
|
|
79
|
+
protected:
|
|
80
|
+
// Tag for logging
|
|
81
|
+
static constexpr auto TAG = "ReactNativeBundleCrypto";
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro::reactnativebundlecrypto
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Sha256Result.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::reactnativebundlecrypto {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (Sha256Result).
|
|
35
|
+
*/
|
|
36
|
+
struct Sha256Result {
|
|
37
|
+
public:
|
|
38
|
+
std::optional<std::string> sha256 SWIFT_PRIVATE;
|
|
39
|
+
std::optional<std::string> failureReason SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
Sha256Result() = default;
|
|
43
|
+
explicit Sha256Result(std::optional<std::string> sha256, std::optional<std::string> failureReason): sha256(sha256), failureReason(failureReason) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::reactnativebundlecrypto
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ Sha256Result <> JS Sha256Result (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::reactnativebundlecrypto::Sha256Result> final {
|
|
53
|
+
static inline margelo::nitro::reactnativebundlecrypto::Sha256Result fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::reactnativebundlecrypto::Sha256Result(
|
|
56
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "sha256")),
|
|
57
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "failureReason"))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativebundlecrypto::Sha256Result& arg) {
|
|
61
|
+
jsi::Object obj(runtime);
|
|
62
|
+
obj.setProperty(runtime, "sha256", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.sha256));
|
|
63
|
+
obj.setProperty(runtime, "failureReason", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.failureReason));
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isObject()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
jsi::Object obj = value.getObject(runtime);
|
|
71
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "sha256"))) return false;
|
|
75
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "failureReason"))) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VerifyDetachedAscResult.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::reactnativebundlecrypto {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (VerifyDetachedAscResult).
|
|
35
|
+
*/
|
|
36
|
+
struct VerifyDetachedAscResult {
|
|
37
|
+
public:
|
|
38
|
+
bool valid SWIFT_PRIVATE;
|
|
39
|
+
std::optional<std::string> sha256 SWIFT_PRIVATE;
|
|
40
|
+
std::optional<std::string> reason SWIFT_PRIVATE;
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
VerifyDetachedAscResult() = default;
|
|
44
|
+
explicit VerifyDetachedAscResult(bool valid, std::optional<std::string> sha256, std::optional<std::string> reason): valid(valid), sha256(sha256), reason(reason) {}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace margelo::nitro::reactnativebundlecrypto
|
|
48
|
+
|
|
49
|
+
namespace margelo::nitro {
|
|
50
|
+
|
|
51
|
+
// C++ VerifyDetachedAscResult <> JS VerifyDetachedAscResult (object)
|
|
52
|
+
template <>
|
|
53
|
+
struct JSIConverter<margelo::nitro::reactnativebundlecrypto::VerifyDetachedAscResult> final {
|
|
54
|
+
static inline margelo::nitro::reactnativebundlecrypto::VerifyDetachedAscResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
56
|
+
return margelo::nitro::reactnativebundlecrypto::VerifyDetachedAscResult(
|
|
57
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "valid")),
|
|
58
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "sha256")),
|
|
59
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "reason"))
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativebundlecrypto::VerifyDetachedAscResult& arg) {
|
|
63
|
+
jsi::Object obj(runtime);
|
|
64
|
+
obj.setProperty(runtime, "valid", JSIConverter<bool>::toJSI(runtime, arg.valid));
|
|
65
|
+
obj.setProperty(runtime, "sha256", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.sha256));
|
|
66
|
+
obj.setProperty(runtime, "reason", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.reason));
|
|
67
|
+
return obj;
|
|
68
|
+
}
|
|
69
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
70
|
+
if (!value.isObject()) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
jsi::Object obj = value.getObject(runtime);
|
|
74
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "valid"))) return false;
|
|
78
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "sha256"))) return false;
|
|
79
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "reason"))) return false;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// VerifyGpgCleartextResult.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::reactnativebundlecrypto {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (VerifyGpgCleartextResult).
|
|
35
|
+
*/
|
|
36
|
+
struct VerifyGpgCleartextResult {
|
|
37
|
+
public:
|
|
38
|
+
bool valid SWIFT_PRIVATE;
|
|
39
|
+
std::optional<std::string> sha256 SWIFT_PRIVATE;
|
|
40
|
+
std::optional<std::string> reason SWIFT_PRIVATE;
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
VerifyGpgCleartextResult() = default;
|
|
44
|
+
explicit VerifyGpgCleartextResult(bool valid, std::optional<std::string> sha256, std::optional<std::string> reason): valid(valid), sha256(sha256), reason(reason) {}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace margelo::nitro::reactnativebundlecrypto
|
|
48
|
+
|
|
49
|
+
namespace margelo::nitro {
|
|
50
|
+
|
|
51
|
+
// C++ VerifyGpgCleartextResult <> JS VerifyGpgCleartextResult (object)
|
|
52
|
+
template <>
|
|
53
|
+
struct JSIConverter<margelo::nitro::reactnativebundlecrypto::VerifyGpgCleartextResult> final {
|
|
54
|
+
static inline margelo::nitro::reactnativebundlecrypto::VerifyGpgCleartextResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
56
|
+
return margelo::nitro::reactnativebundlecrypto::VerifyGpgCleartextResult(
|
|
57
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "valid")),
|
|
58
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "sha256")),
|
|
59
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "reason"))
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativebundlecrypto::VerifyGpgCleartextResult& arg) {
|
|
63
|
+
jsi::Object obj(runtime);
|
|
64
|
+
obj.setProperty(runtime, "valid", JSIConverter<bool>::toJSI(runtime, arg.valid));
|
|
65
|
+
obj.setProperty(runtime, "sha256", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.sha256));
|
|
66
|
+
obj.setProperty(runtime, "reason", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.reason));
|
|
67
|
+
return obj;
|
|
68
|
+
}
|
|
69
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
70
|
+
if (!value.isObject()) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
jsi::Object obj = value.getObject(runtime);
|
|
74
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "valid"))) return false;
|
|
78
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "sha256"))) return false;
|
|
79
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "reason"))) return false;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
package/package.json
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@onekeyfe/react-native-bundle-crypto",
|
|
3
|
+
"version": "3.0.39",
|
|
4
|
+
"description": "react-native-bundle-crypto",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"nitrogen",
|
|
22
|
+
"nitro.json",
|
|
23
|
+
"*.podspec",
|
|
24
|
+
"react-native.config.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
38
|
+
"prepare": "bob build",
|
|
39
|
+
"nitrogen": "nitrogen",
|
|
40
|
+
"typecheck": "tsc",
|
|
41
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
42
|
+
"test": "jest",
|
|
43
|
+
"release": "yarn prepare && npm whoami && npm publish --access public"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"react-native",
|
|
47
|
+
"ios",
|
|
48
|
+
"android"
|
|
49
|
+
],
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/OneKeyHQ/app-modules/react-native-bundle-crypto.git"
|
|
53
|
+
},
|
|
54
|
+
"author": "onekeyfe <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/OneKeyHQ/app-modules/react-native-bundle-crypto/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/OneKeyHQ/app-modules/react-native-bundle-crypto#readme",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"registry": "https://registry.npmjs.org/"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
65
|
+
"@eslint/compat": "^1.3.2",
|
|
66
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
67
|
+
"@eslint/js": "^9.35.0",
|
|
68
|
+
"@react-native/babel-preset": "0.83.0",
|
|
69
|
+
"@react-native/eslint-config": "0.83.0",
|
|
70
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
71
|
+
"@types/jest": "^29.5.14",
|
|
72
|
+
"@types/react": "^19.2.0",
|
|
73
|
+
"commitlint": "^19.8.1",
|
|
74
|
+
"del-cli": "^6.0.0",
|
|
75
|
+
"eslint": "^9.35.0",
|
|
76
|
+
"eslint-config-prettier": "^10.1.8",
|
|
77
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
78
|
+
"jest": "^29.7.0",
|
|
79
|
+
"lefthook": "^2.0.3",
|
|
80
|
+
"nitrogen": "0.31.10",
|
|
81
|
+
"prettier": "^2.8.8",
|
|
82
|
+
"react": "19.2.0",
|
|
83
|
+
"react-native": "patch:react-native@npm%3A0.83.0#~/.yarn/patches/react-native-npm-0.83.0-577d0f2d83.patch",
|
|
84
|
+
"react-native-builder-bob": "^0.40.13",
|
|
85
|
+
"react-native-nitro-modules": "0.33.2",
|
|
86
|
+
"release-it": "^19.0.4",
|
|
87
|
+
"turbo": "^2.5.6",
|
|
88
|
+
"typescript": "^5.9.2"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"react": "*",
|
|
92
|
+
"react-native": "*",
|
|
93
|
+
"react-native-nitro-modules": "0.33.2"
|
|
94
|
+
},
|
|
95
|
+
"react-native-builder-bob": {
|
|
96
|
+
"source": "src",
|
|
97
|
+
"output": "lib",
|
|
98
|
+
"targets": [
|
|
99
|
+
[
|
|
100
|
+
"custom",
|
|
101
|
+
{
|
|
102
|
+
"script": "nitrogen",
|
|
103
|
+
"clean": "nitrogen/"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
[
|
|
107
|
+
"module",
|
|
108
|
+
{
|
|
109
|
+
"esm": true
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
"typescript",
|
|
114
|
+
{
|
|
115
|
+
"project": "tsconfig.build.json"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"prettier": {
|
|
121
|
+
"quoteProps": "consistent",
|
|
122
|
+
"singleQuote": true,
|
|
123
|
+
"tabWidth": 2,
|
|
124
|
+
"trailingComma": "es5",
|
|
125
|
+
"useTabs": false
|
|
126
|
+
},
|
|
127
|
+
"jest": {
|
|
128
|
+
"preset": "react-native",
|
|
129
|
+
"modulePathIgnorePatterns": [
|
|
130
|
+
"<rootDir>/example/node_modules",
|
|
131
|
+
"<rootDir>/lib/"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"commitlint": {
|
|
135
|
+
"extends": [
|
|
136
|
+
"@commitlint/config-conventional"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"release-it": {
|
|
140
|
+
"git": {
|
|
141
|
+
"commitMessage": "chore: release ${version}",
|
|
142
|
+
"tagName": "v${version}"
|
|
143
|
+
},
|
|
144
|
+
"npm": {
|
|
145
|
+
"publish": true
|
|
146
|
+
},
|
|
147
|
+
"github": {
|
|
148
|
+
"release": true
|
|
149
|
+
},
|
|
150
|
+
"plugins": {
|
|
151
|
+
"@release-it/conventional-changelog": {
|
|
152
|
+
"preset": {
|
|
153
|
+
"name": "angular"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"create-react-native-library": {
|
|
159
|
+
"type": "nitro-module",
|
|
160
|
+
"languages": "kotlin-swift",
|
|
161
|
+
"tools": [
|
|
162
|
+
"eslint",
|
|
163
|
+
"jest",
|
|
164
|
+
"lefthook",
|
|
165
|
+
"release-it"
|
|
166
|
+
],
|
|
167
|
+
"version": "0.56.0"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
|
|
3
|
+
export interface VerifyGpgCleartextResult {
|
|
4
|
+
valid: boolean;
|
|
5
|
+
sha256?: string; // taken from the signed JSON body when valid (mirrors bundle behavior)
|
|
6
|
+
reason?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface VerifyDetachedAscResult {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
sha256?: string; // mirrors APK behavior: taken from the detached SHA256SUMS.asc cleartext
|
|
12
|
+
reason?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Sha256Result {
|
|
16
|
+
sha256?: string;
|
|
17
|
+
failureReason?: string; // FILE_NOT_FOUND / IO_<code> / MISMATCH ... (mirrors current sub-types)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DirHashEntry {
|
|
21
|
+
relativePath: string;
|
|
22
|
+
sha256: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ReactNativeBundleCrypto
|
|
26
|
+
extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
|
|
27
|
+
// ---- GPG / ASC (public key embedded, single source; never exposed to JS) ----
|
|
28
|
+
// bundle form: PGP CLEARTEXT SIGNED MESSAGE whose body is JSON containing sha256
|
|
29
|
+
verifyGpgCleartext(signedMessage: string): Promise<VerifyGpgCleartextResult>;
|
|
30
|
+
// APK form: detached SHA256SUMS.asc (cleartext-signed SHA256SUMS text)
|
|
31
|
+
verifyDetachedAsc(ascContent: string): Promise<VerifyDetachedAscResult>;
|
|
32
|
+
|
|
33
|
+
// ---- sha256 ----
|
|
34
|
+
sha256OfFile(filePath: string): Promise<Sha256Result>;
|
|
35
|
+
// constant-time comparison of two hex strings (mirrors current secureCompare semantics)
|
|
36
|
+
secureEqualHex(a: string, b: string): boolean;
|
|
37
|
+
|
|
38
|
+
// ---- per-entry directory hash verification (mirrors validateAllFilesInDir) ----
|
|
39
|
+
// verify every file under dirPath has sha256 == expected[relativePath], plus completeness.
|
|
40
|
+
verifyDirAgainstHashes(
|
|
41
|
+
dirPath: string,
|
|
42
|
+
entries: DirHashEntry[]
|
|
43
|
+
): Promise<boolean>;
|
|
44
|
+
// compute relativePath -> sha256 for all files under dirPath (for chart to build its metadata)
|
|
45
|
+
hashDir(dirPath: string): Promise<DirHashEntry[]>;
|
|
46
|
+
|
|
47
|
+
// ---- safe file operations (verbs) ----
|
|
48
|
+
// guard against symlink / path traversal (mirrors validateExtractedPathSafety)
|
|
49
|
+
validateExtractedPathSafety(destination: string): Promise<boolean>;
|
|
50
|
+
// atomic write: temp file + rename
|
|
51
|
+
atomicWriteFile(filePath: string, contentUtf8: string): Promise<void>;
|
|
52
|
+
// safe rename (same-volume move, removes existing target first)
|
|
53
|
+
safeRename(fromPath: string, toPath: string): Promise<void>;
|
|
54
|
+
// enumerate version sub-directory names under a parent dir (e.g. "<appVersion>-<bundleVersion>")
|
|
55
|
+
listVersionDirs(parentDir: string): Promise<string[]>;
|
|
56
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import type { ReactNativeBundleCrypto as ReactNativeBundleCryptoType } from './ReactNativeBundleCrypto.nitro';
|
|
3
|
+
|
|
4
|
+
const ReactNativeBundleCryptoHybridObject =
|
|
5
|
+
NitroModules.createHybridObject<ReactNativeBundleCryptoType>('ReactNativeBundleCrypto');
|
|
6
|
+
|
|
7
|
+
export const ReactNativeBundleCrypto = ReactNativeBundleCryptoHybridObject;
|
|
8
|
+
export type * from './ReactNativeBundleCrypto.nitro';
|