react-native-quick-crypto 0.7.2 → 1.0.0-beta.1
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/QuickCrypto.podspec +34 -0
- package/android/CMakeLists.txt +32 -64
- package/android/build.gradle +52 -125
- package/android/gradle.properties +3 -3
- package/android/src/main/cpp/cpp-adapter.cpp +9 -54
- package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +38 -0
- package/ios/QuickCryptoOnLoad.mm +19 -0
- package/lib/commonjs/index.js +39 -39
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/random.js +26 -12
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/{NativeQuickCrypto/rsa.js → specs/random.nitro.js} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/aes.js.map → specs/random.nitro.js.map} +1 -1
- package/lib/commonjs/utils/conversion.js +22 -0
- package/lib/commonjs/utils/conversion.js.map +1 -0
- package/lib/commonjs/utils/index.js +12 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/types.js +2 -0
- package/lib/{module/NativeQuickCrypto/aes.js.map → commonjs/utils/types.js.map} +1 -1
- package/lib/module/index.js +40 -38
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/random.js +28 -12
- package/lib/module/random.js.map +1 -1
- package/lib/module/specs/random.nitro.js +4 -0
- package/lib/module/{NativeQuickCrypto/rsa.js.map → specs/random.nitro.js.map} +1 -1
- package/lib/module/utils/conversion.js +16 -0
- package/lib/module/utils/conversion.js.map +1 -0
- package/lib/module/utils/index.js +8 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/types.js +2 -0
- package/lib/{commonjs/NativeQuickCrypto/rsa.js.map → module/utils/types.js.map} +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/typescript/index.d.ts +10 -141
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/random.d.ts +4 -5
- package/lib/typescript/random.d.ts.map +1 -1
- package/lib/typescript/specs/random.nitro.d.ts +9 -0
- package/lib/typescript/specs/random.nitro.d.ts.map +1 -0
- package/lib/typescript/utils/conversion.d.ts +4 -0
- package/lib/typescript/utils/conversion.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/types.d.ts +5 -0
- package/lib/typescript/utils/types.d.ts.map +1 -0
- package/package.json +58 -108
- package/src/index.ts +38 -48
- package/src/random.ts +51 -48
- package/src/specs/random.nitro.ts +14 -0
- package/src/utils/conversion.ts +16 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/types.ts +15 -0
- package/LICENSE +0 -27
- package/README.md +0 -203
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +0 -70
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoPackage.java +0 -25
- package/cpp/Cipher/MGLCipherHostObject.cpp +0 -663
- package/cpp/Cipher/MGLCipherHostObject.h +0 -90
- package/cpp/Cipher/MGLCreateCipherInstaller.cpp +0 -75
- package/cpp/Cipher/MGLCreateCipherInstaller.h +0 -22
- package/cpp/Cipher/MGLCreateDecipherInstaller.cpp +0 -77
- package/cpp/Cipher/MGLCreateDecipherInstaller.h +0 -17
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp +0 -134
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +0 -35
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp +0 -63
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +0 -37
- package/cpp/Cipher/MGLPublicCipher.h +0 -120
- package/cpp/Cipher/MGLPublicCipherInstaller.h +0 -107
- package/cpp/Cipher/MGLRsa.cpp +0 -573
- package/cpp/Cipher/MGLRsa.h +0 -109
- package/cpp/HMAC/MGLHmacHostObject.cpp +0 -95
- package/cpp/HMAC/MGLHmacHostObject.h +0 -39
- package/cpp/HMAC/MGLHmacInstaller.cpp +0 -43
- package/cpp/HMAC/MGLHmacInstaller.h +0 -20
- package/cpp/Hash/MGLHashHostObject.cpp +0 -147
- package/cpp/Hash/MGLHashHostObject.h +0 -53
- package/cpp/Hash/MGLHashInstaller.cpp +0 -44
- package/cpp/Hash/MGLHashInstaller.h +0 -20
- package/cpp/JSIUtils/MGLJSIMacros.h +0 -110
- package/cpp/JSIUtils/MGLJSIUtils.h +0 -41
- package/cpp/JSIUtils/MGLSmartHostObject.cpp +0 -43
- package/cpp/JSIUtils/MGLSmartHostObject.h +0 -46
- package/cpp/JSIUtils/MGLThreadAwareHostObject.cpp +0 -24
- package/cpp/JSIUtils/MGLThreadAwareHostObject.h +0 -43
- package/cpp/JSIUtils/MGLTypedArray.cpp +0 -325
- package/cpp/JSIUtils/MGLTypedArray.h +0 -160
- package/cpp/MGLKeys.cpp +0 -1426
- package/cpp/MGLKeys.h +0 -203
- package/cpp/MGLQuickCryptoHostObject.cpp +0 -124
- package/cpp/MGLQuickCryptoHostObject.h +0 -30
- package/cpp/Random/MGLRandomHostObject.cpp +0 -96
- package/cpp/Random/MGLRandomHostObject.h +0 -27
- package/cpp/Sig/MGLSignHostObjects.cpp +0 -757
- package/cpp/Sig/MGLSignHostObjects.h +0 -128
- package/cpp/Sig/MGLSignInstaller.cpp +0 -24
- package/cpp/Sig/MGLSignInstaller.h +0 -29
- package/cpp/Sig/MGLVerifyInstaller.cpp +0 -24
- package/cpp/Sig/MGLVerifyInstaller.h +0 -22
- package/cpp/Utils/MGLDispatchQueue.cpp +0 -75
- package/cpp/Utils/MGLDispatchQueue.h +0 -55
- package/cpp/Utils/MGLUtils.cpp +0 -295
- package/cpp/Utils/MGLUtils.h +0 -358
- package/cpp/Utils/base64.h +0 -320
- package/cpp/Utils/logs.h +0 -38
- package/cpp/Utils/node.h +0 -13
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp +0 -164
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.h +0 -29
- package/cpp/fastpbkdf2/fastpbkdf2.c +0 -352
- package/cpp/fastpbkdf2/fastpbkdf2.h +0 -68
- package/cpp/webcrypto/MGLWebCrypto.cpp +0 -125
- package/cpp/webcrypto/MGLWebCrypto.h +0 -32
- package/cpp/webcrypto/crypto_aes.cpp +0 -516
- package/cpp/webcrypto/crypto_aes.h +0 -79
- package/cpp/webcrypto/crypto_ec.cpp +0 -424
- package/cpp/webcrypto/crypto_ec.h +0 -78
- package/cpp/webcrypto/crypto_keygen.cpp +0 -86
- package/cpp/webcrypto/crypto_keygen.h +0 -38
- package/ios/QuickCrypto.xcodeproj/project.pbxproj +0 -274
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/xcuserdata/brad.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/QuickCrypto.xcodeproj/xcuserdata/brad.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/QuickCryptoModule.h +0 -5
- package/ios/QuickCryptoModule.mm +0 -42
- package/lib/commonjs/Cipher.js +0 -502
- package/lib/commonjs/Cipher.js.map +0 -1
- package/lib/commonjs/Hash.js +0 -99
- package/lib/commonjs/Hash.js.map +0 -1
- package/lib/commonjs/Hashnames.js +0 -87
- package/lib/commonjs/Hashnames.js.map +0 -1
- package/lib/commonjs/Hmac.js +0 -79
- package/lib/commonjs/Hmac.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/Cipher.js +0 -30
- package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js +0 -52
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/aes.js +0 -6
- package/lib/commonjs/NativeQuickCrypto/hash.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/hash.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/hmac.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/hmac.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/keygen.js +0 -6
- package/lib/commonjs/NativeQuickCrypto/keygen.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/random.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/random.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/sig.js +0 -19
- package/lib/commonjs/NativeQuickCrypto/sig.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/webcrypto.js +0 -6
- package/lib/commonjs/NativeQuickCrypto/webcrypto.js.map +0 -1
- package/lib/commonjs/Utils.js +0 -608
- package/lib/commonjs/Utils.js.map +0 -1
- package/lib/commonjs/aes.js +0 -281
- package/lib/commonjs/aes.js.map +0 -1
- package/lib/commonjs/constants.js +0 -85
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/commonjs/ec.js +0 -276
- package/lib/commonjs/ec.js.map +0 -1
- package/lib/commonjs/keygen.js +0 -56
- package/lib/commonjs/keygen.js.map +0 -1
- package/lib/commonjs/keys.js +0 -492
- package/lib/commonjs/keys.js.map +0 -1
- package/lib/commonjs/pbkdf2.js +0 -90
- package/lib/commonjs/pbkdf2.js.map +0 -1
- package/lib/commonjs/rsa.js +0 -248
- package/lib/commonjs/rsa.js.map +0 -1
- package/lib/commonjs/sig.js +0 -129
- package/lib/commonjs/sig.js.map +0 -1
- package/lib/commonjs/subtle.js +0 -448
- package/lib/commonjs/subtle.js.map +0 -1
- package/lib/commonjs/webcrypto.js +0 -14
- package/lib/commonjs/webcrypto.js.map +0 -1
- package/lib/module/Cipher.js +0 -489
- package/lib/module/Cipher.js.map +0 -1
- package/lib/module/Hash.js +0 -91
- package/lib/module/Hash.js.map +0 -1
- package/lib/module/Hashnames.js +0 -83
- package/lib/module/Hashnames.js.map +0 -1
- package/lib/module/Hmac.js +0 -72
- package/lib/module/Hmac.js.map +0 -1
- package/lib/module/NativeQuickCrypto/Cipher.js +0 -24
- package/lib/module/NativeQuickCrypto/Cipher.js.map +0 -1
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js +0 -47
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
- package/lib/module/NativeQuickCrypto/aes.js +0 -2
- package/lib/module/NativeQuickCrypto/hash.js +0 -2
- package/lib/module/NativeQuickCrypto/hash.js.map +0 -1
- package/lib/module/NativeQuickCrypto/hmac.js +0 -2
- package/lib/module/NativeQuickCrypto/hmac.js.map +0 -1
- package/lib/module/NativeQuickCrypto/keygen.js +0 -2
- package/lib/module/NativeQuickCrypto/keygen.js.map +0 -1
- package/lib/module/NativeQuickCrypto/pbkdf2.js +0 -2
- package/lib/module/NativeQuickCrypto/pbkdf2.js.map +0 -1
- package/lib/module/NativeQuickCrypto/random.js +0 -2
- package/lib/module/NativeQuickCrypto/random.js.map +0 -1
- package/lib/module/NativeQuickCrypto/rsa.js +0 -2
- package/lib/module/NativeQuickCrypto/sig.js +0 -15
- package/lib/module/NativeQuickCrypto/sig.js.map +0 -1
- package/lib/module/NativeQuickCrypto/webcrypto.js +0 -2
- package/lib/module/NativeQuickCrypto/webcrypto.js.map +0 -1
- package/lib/module/Utils.js +0 -537
- package/lib/module/Utils.js.map +0 -1
- package/lib/module/aes.js +0 -272
- package/lib/module/aes.js.map +0 -1
- package/lib/module/constants.js +0 -79
- package/lib/module/constants.js.map +0 -1
- package/lib/module/ec.js +0 -265
- package/lib/module/ec.js.map +0 -1
- package/lib/module/keygen.js +0 -47
- package/lib/module/keygen.js.map +0 -1
- package/lib/module/keys.js +0 -475
- package/lib/module/keys.js.map +0 -1
- package/lib/module/pbkdf2.js +0 -82
- package/lib/module/pbkdf2.js.map +0 -1
- package/lib/module/rsa.js +0 -240
- package/lib/module/rsa.js.map +0 -1
- package/lib/module/sig.js +0 -122
- package/lib/module/sig.js.map +0 -1
- package/lib/module/subtle.js +0 -441
- package/lib/module/subtle.js.map +0 -1
- package/lib/module/webcrypto.js +0 -8
- package/lib/module/webcrypto.js.map +0 -1
- package/lib/typescript/Cipher.d.ts +0 -81
- package/lib/typescript/Cipher.d.ts.map +0 -1
- package/lib/typescript/Hash.d.ts +0 -44
- package/lib/typescript/Hash.d.ts.map +0 -1
- package/lib/typescript/Hashnames.d.ts +0 -11
- package/lib/typescript/Hashnames.d.ts.map +0 -1
- package/lib/typescript/Hmac.d.ts +0 -37
- package/lib/typescript/Hmac.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/Cipher.d.ts +0 -44
- package/lib/typescript/NativeQuickCrypto/Cipher.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts +0 -33
- package/lib/typescript/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/aes.d.ts +0 -5
- package/lib/typescript/NativeQuickCrypto/aes.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/hash.d.ts +0 -7
- package/lib/typescript/NativeQuickCrypto/hash.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/hmac.d.ts +0 -6
- package/lib/typescript/NativeQuickCrypto/hmac.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/keygen.d.ts +0 -4
- package/lib/typescript/NativeQuickCrypto/keygen.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts +0 -5
- package/lib/typescript/NativeQuickCrypto/pbkdf2.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/random.d.ts +0 -5
- package/lib/typescript/NativeQuickCrypto/random.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/rsa.d.ts +0 -5
- package/lib/typescript/NativeQuickCrypto/rsa.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/sig.d.ts +0 -23
- package/lib/typescript/NativeQuickCrypto/sig.d.ts.map +0 -1
- package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts +0 -39
- package/lib/typescript/NativeQuickCrypto/webcrypto.d.ts.map +0 -1
- package/lib/typescript/Utils.d.ts +0 -48
- package/lib/typescript/Utils.d.ts.map +0 -1
- package/lib/typescript/aes.d.ts +0 -22
- package/lib/typescript/aes.d.ts.map +0 -1
- package/lib/typescript/constants.d.ts +0 -76
- package/lib/typescript/constants.d.ts.map +0 -1
- package/lib/typescript/ec.d.ts +0 -7
- package/lib/typescript/ec.d.ts.map +0 -1
- package/lib/typescript/keygen.d.ts +0 -6
- package/lib/typescript/keygen.d.ts.map +0 -1
- package/lib/typescript/keys.d.ts +0 -206
- package/lib/typescript/keys.d.ts.map +0 -1
- package/lib/typescript/pbkdf2.d.ts +0 -12
- package/lib/typescript/pbkdf2.d.ts.map +0 -1
- package/lib/typescript/rsa.d.ts +0 -12
- package/lib/typescript/rsa.d.ts.map +0 -1
- package/lib/typescript/sig.d.ts +0 -21
- package/lib/typescript/sig.d.ts.map +0 -1
- package/lib/typescript/subtle.d.ts +0 -15
- package/lib/typescript/subtle.d.ts.map +0 -1
- package/lib/typescript/webcrypto.d.ts +0 -9
- package/lib/typescript/webcrypto.d.ts.map +0 -1
- package/react-native-quick-crypto.podspec +0 -40
- package/src/Cipher.ts +0 -832
- package/src/Hash.ts +0 -132
- package/src/Hashnames.ts +0 -93
- package/src/Hmac.ts +0 -106
- package/src/NativeQuickCrypto/Cipher.ts +0 -102
- package/src/NativeQuickCrypto/NativeQuickCrypto.ts +0 -102
- package/src/NativeQuickCrypto/aes.ts +0 -14
- package/src/NativeQuickCrypto/hash.ts +0 -10
- package/src/NativeQuickCrypto/hmac.ts +0 -9
- package/src/NativeQuickCrypto/keygen.ts +0 -7
- package/src/NativeQuickCrypto/pbkdf2.ts +0 -16
- package/src/NativeQuickCrypto/random.ts +0 -12
- package/src/NativeQuickCrypto/rsa.ts +0 -12
- package/src/NativeQuickCrypto/sig.ts +0 -44
- package/src/NativeQuickCrypto/webcrypto.ts +0 -72
- package/src/Utils.ts +0 -777
- package/src/aes.ts +0 -402
- package/src/constants.ts +0 -79
- package/src/ec.ts +0 -375
- package/src/keygen.ts +0 -80
- package/src/keys.ts +0 -787
- package/src/pbkdf2.ts +0 -169
- package/src/rsa.ts +0 -370
- package/src/sig.ts +0 -164
- package/src/subtle.ts +0 -639
- package/src/webcrypto.ts +0 -8
- /package/android/src/main/{AndroidManifestNew.xml → AndroidManifest.xml} +0 -0
package/README.md
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
<a href="https://margelo.io">
|
|
2
|
-
<img src="./docs/img/banner.svg" width="100%" />
|
|
3
|
-
</a>
|
|
4
|
-
|
|
5
|
-
# ⚡️ react-native-quick-crypto
|
|
6
|
-
|
|
7
|
-
A fast implementation of Node's `crypto` module.
|
|
8
|
-
|
|
9
|
-
Unlike any other current JS-based polyfills, react-native-quick-crypto is written in C/C++ JSI and provides much greater performance - especially on mobile devices.
|
|
10
|
-
QuickCrypto can be used as a drop-in replacement for your Web3/Crypto apps to speed up common cryptography functions.
|
|
11
|
-
|
|
12
|
-
- 🏎️ Up to 58x faster than all other solutions
|
|
13
|
-
- ⚡️ Lightning fast implementation with pure C++ and JSI, instead of JS
|
|
14
|
-
- 🧪 Well tested in JS and C++ (OpenSSL)
|
|
15
|
-
- 💰 Made for crypto apps and Wallets
|
|
16
|
-
- 🔢 Secure native compiled cryptography
|
|
17
|
-
- 🔁 Easy drop-in replacement for [crypto-browserify](https://github.com/browserify/crypto-browserify) or [react-native-crypto](https://github.com/tradle/react-native-crypto)
|
|
18
|
-
|
|
19
|
-
For example, creating a Wallet using ethers.js uses complex algorithms to generate a private-key/mnemonic-phrase pair:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
const start = performance.now();
|
|
23
|
-
const wallet = ethers.Wallet.createRandom();
|
|
24
|
-
const end = performance.now();
|
|
25
|
-
console.log(`Creating a Wallet took ${end - start} ms.`);
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**Without** react-native-quick-crypto 🐢:
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
Creating a Wallet took 16862 ms
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
**With** react-native-quick-crypto ⚡️:
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
Creating a Wallet took 289 ms
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Installation
|
|
43
|
-
|
|
44
|
-
<h3>
|
|
45
|
-
React Native <a href="#"><img src="./docs/img/react-native.png" height="15" /></a>
|
|
46
|
-
</h3>
|
|
47
|
-
|
|
48
|
-
```sh
|
|
49
|
-
yarn add react-native-quick-crypto
|
|
50
|
-
cd ios && pod install
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
<h3>
|
|
54
|
-
Expo <a href="#"><img src="./docs/img/expo.png" height="12" /></a>
|
|
55
|
-
</h3>
|
|
56
|
-
|
|
57
|
-
```sh
|
|
58
|
-
expo install react-native-quick-crypto
|
|
59
|
-
expo prebuild
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Optional: override `global.Buffer` and `global.crypto` in your application as early as possible for example in index.js.
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
import { install } from 'react-native-quick-crypto';
|
|
66
|
-
|
|
67
|
-
install();
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Replace `crypto-browserify`
|
|
71
|
-
|
|
72
|
-
If you are using a library that depends on `crypto`, instead of polyfilling it with `crypto-browserify` (or `react-native-crypto`) you can use `react-native-quick-crypto` for a fully native implementation. This way you can get much faster crypto operations with just a single-line change!
|
|
73
|
-
|
|
74
|
-
### Using metro config
|
|
75
|
-
|
|
76
|
-
Use the [`resolveRequest`](https://facebook.github.io/metro/docs/resolution#resolverequest-customresolver) configuration option in your `metro.config.js`
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
config.resolver.resolveRequest = (context, moduleName, platform) => {
|
|
80
|
-
if (moduleName === 'crypto') {
|
|
81
|
-
// when importing crypto, resolve to react-native-quick-crypto
|
|
82
|
-
return context.resolveRequest(
|
|
83
|
-
context,
|
|
84
|
-
'react-native-quick-crypto',
|
|
85
|
-
platform,
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
// otherwise chain to the standard Metro resolver.
|
|
89
|
-
return context.resolveRequest(context, moduleName, platform)
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Using babel-plugin-module-resolver
|
|
94
|
-
|
|
95
|
-
You need to install `babel-plugin-module-resolver`, it's a babel plugin that will alias any imports in the code with the values you pass to it. It tricks any module that will try to import certain dependencies with the native versions we require for React Native.
|
|
96
|
-
|
|
97
|
-
```sh
|
|
98
|
-
yarn add --dev babel-plugin-module-resolver
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Then, in your `babel.config.js`, add the plugin to swap the `crypto`, `stream` and `buffer` dependencies:
|
|
102
|
-
|
|
103
|
-
```diff
|
|
104
|
-
module.exports = {
|
|
105
|
-
presets: ['module:metro-react-native-babel-preset'],
|
|
106
|
-
plugins: [
|
|
107
|
-
+ [
|
|
108
|
-
+ 'module-resolver',
|
|
109
|
-
+ {
|
|
110
|
-
+ alias: {
|
|
111
|
-
+ 'crypto': 'react-native-quick-crypto',
|
|
112
|
-
+ 'stream': 'readable-stream',
|
|
113
|
-
+ 'buffer': '@craftzdog/react-native-buffer',
|
|
114
|
-
+ },
|
|
115
|
-
+ },
|
|
116
|
-
+ ],
|
|
117
|
-
...
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Then restart your bundler using `yarn start --reset-cache`.
|
|
123
|
-
|
|
124
|
-
## Usage
|
|
125
|
-
|
|
126
|
-
For example, to hash a string with SHA256 you can do the following:
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
import QuickCrypto from 'react-native-quick-crypto';
|
|
130
|
-
|
|
131
|
-
const hashed = QuickCrypto.createHash('sha256')
|
|
132
|
-
.update('Damn, Margelo writes hella good software!')
|
|
133
|
-
.digest('hex');
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
## Sponsors
|
|
139
|
-
|
|
140
|
-
<!-- Onin -->
|
|
141
|
-
<div align="center">
|
|
142
|
-
<img height="50" src="./docs/img/sponsors/onin.svg" align="center"><br/>
|
|
143
|
-
<a href="https://onin.co"><b>Onin</b></a> - This library is supported by Onin. Plan events without leaving the chat: <a href="https://onin.co">onin.co</a>
|
|
144
|
-
</div>
|
|
145
|
-
<br/>
|
|
146
|
-
<br/>
|
|
147
|
-
|
|
148
|
-
<!-- Steakwallet -->
|
|
149
|
-
<div align="center">
|
|
150
|
-
<img height="37" src="./docs/img/sponsors/omni.png" align="center"><br/>
|
|
151
|
-
<a href="https://steakwallet.fi"><b>Omni</b></a> - Web3 for all. Access all of Web3 in one easy to use wallet. Omni supports more blockchains so you get more tokens, more yields, more NFTs, and more fun!
|
|
152
|
-
</div>
|
|
153
|
-
<br/>
|
|
154
|
-
<br/>
|
|
155
|
-
|
|
156
|
-
<!-- Litentry -->
|
|
157
|
-
<div align="center">
|
|
158
|
-
<img height="70" src="./docs/img/sponsors/litentry.png" align="center"><br/>
|
|
159
|
-
<a href="https://litentry.com"><b>Litentry</b></a> - A decentralized identity aggregator, providing the structure and tools to empower you and your identity.
|
|
160
|
-
</div>
|
|
161
|
-
<br/>
|
|
162
|
-
<br/>
|
|
163
|
-
|
|
164
|
-
<!-- WalletConnect -->
|
|
165
|
-
<div align="center">
|
|
166
|
-
<img height="35" src="./docs/img/sponsors/walletconnect.png" align="center"><br/>
|
|
167
|
-
<a href="https://walletconnect.com"><b>WalletConnect</b></a> - The communications protocol for web3, WalletConnect brings the ecosystem together by enabling wallets and apps to securely connect and interact.
|
|
168
|
-
</div>
|
|
169
|
-
<br/>
|
|
170
|
-
<br/>
|
|
171
|
-
|
|
172
|
-
<!-- WalletConnect -->
|
|
173
|
-
|
|
174
|
-
<!-- THORSwap -->
|
|
175
|
-
<div align="center">
|
|
176
|
-
<img height="40" src="./docs/img/sponsors/thorswap.png" align="center"><br/>
|
|
177
|
-
<a href="https://thorswap.finance"><b>THORSwap</b></a> - THORSwap is a cross-chain DEX aggregator that enables users to swap native assets across chains, provide liquidity to earn yield, and more. THORSwap is fully permissionless and non-custodial. No account signup, your wallet, your keys, your coins.
|
|
178
|
-
</div>
|
|
179
|
-
<br/>
|
|
180
|
-
<br/>
|
|
181
|
-
|
|
182
|
-
## Limitations
|
|
183
|
-
|
|
184
|
-
As the library uses JSI for synchronous native methods access, remote debugging (e.g. with Chrome) is no longer possible. Instead, you should use [Flipper](https://fbflipper.com).
|
|
185
|
-
|
|
186
|
-
Not all cryptographic algorithms are supported yet. See the [implementation coverage](./docs/implementation-coverage.md) document for more details. If you need a specific algorithm, please open a `feature request` issue and we'll see what we can do.
|
|
187
|
-
|
|
188
|
-
## Community Discord
|
|
189
|
-
|
|
190
|
-
[Join the Margelo Community Discord](https://discord.gg/6CSHz2qAvA) to chat about react-native-quick-crypto or other Margelo libraries.
|
|
191
|
-
|
|
192
|
-
## Adopting at scale
|
|
193
|
-
|
|
194
|
-
react-native-quick-crypto was built at Margelo, an elite app development agency. For enterprise support or other business inquiries, contact us at <a href="mailto:hello@margelo.io?subject=Adopting react-native-quick-crypto at scale">hello@margelo.io</a>!
|
|
195
|
-
|
|
196
|
-
## Contributing
|
|
197
|
-
|
|
198
|
-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
199
|
-
|
|
200
|
-
## License
|
|
201
|
-
|
|
202
|
-
- react-native-quick-crypto is licensed under MIT.
|
|
203
|
-
- react-native-quick-crypto is heavily inspired by NodeJS Crypto, which is licensed under [nodejs/LICENSE](https://github.com/nodejs/node/blob/main/LICENSE).
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
package com.margelo.quickcrypto;
|
|
2
|
-
|
|
3
|
-
import android.util.Log;
|
|
4
|
-
|
|
5
|
-
import androidx.annotation.NonNull;
|
|
6
|
-
|
|
7
|
-
import com.facebook.jni.HybridData;
|
|
8
|
-
import com.facebook.proguard.annotations.DoNotStrip;
|
|
9
|
-
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
10
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
13
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
14
|
-
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
|
|
15
|
-
|
|
16
|
-
@ReactModule(name = QuickCryptoModule.NAME)
|
|
17
|
-
public class QuickCryptoModule extends ReactContextBaseJavaModule {
|
|
18
|
-
public static final String NAME = "QuickCrypto";
|
|
19
|
-
|
|
20
|
-
@DoNotStrip
|
|
21
|
-
private HybridData mHybridData;
|
|
22
|
-
|
|
23
|
-
private native HybridData initHybrid();
|
|
24
|
-
|
|
25
|
-
public QuickCryptoModule(ReactApplicationContext reactContext) {
|
|
26
|
-
super(reactContext);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@NonNull
|
|
30
|
-
@Override
|
|
31
|
-
public String getName() {
|
|
32
|
-
return NAME;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
36
|
-
public boolean install() {
|
|
37
|
-
try {
|
|
38
|
-
if (mHybridData != null) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
Log.i(NAME, "Loading C++ library...");
|
|
42
|
-
System.loadLibrary("reactnativequickcrypto");
|
|
43
|
-
|
|
44
|
-
JavaScriptContextHolder jsContext = getReactApplicationContext().getJavaScriptContextHolder();
|
|
45
|
-
CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl) getReactApplicationContext()
|
|
46
|
-
.getCatalystInstance()
|
|
47
|
-
.getJSCallInvokerHolder();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Log.i(NAME, "Installing JSI Bindings for react-native-quick-crypto...");
|
|
51
|
-
mHybridData = initHybrid();
|
|
52
|
-
nativeInstall(jsContext.get(), jsCallInvokerHolder);
|
|
53
|
-
Log.i(NAME, "Successfully installed JSI Bindings for react-native-quick-crypto!");
|
|
54
|
-
|
|
55
|
-
return true;
|
|
56
|
-
} catch (Exception exception) {
|
|
57
|
-
Log.e(NAME, "Failed to install JSI Bindings for react-native-quick-crypto!", exception);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public void destroy() {
|
|
63
|
-
if (mHybridData == null) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
mHybridData.resetNative();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private native void nativeInstall(long jsiPtr, CallInvokerHolderImpl jsCallInvokerHolder);
|
|
70
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.margelo.quickcrypto;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactPackage;
|
|
6
|
-
import com.facebook.react.bridge.NativeModule;
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
-
|
|
10
|
-
import java.util.Collections;
|
|
11
|
-
import java.util.List;
|
|
12
|
-
|
|
13
|
-
public class QuickCryptoPackage implements ReactPackage {
|
|
14
|
-
@NonNull
|
|
15
|
-
@Override
|
|
16
|
-
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
|
|
17
|
-
return Collections.singletonList(new QuickCryptoModule(reactContext));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@NonNull
|
|
21
|
-
@Override
|
|
22
|
-
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
23
|
-
return Collections.emptyList();
|
|
24
|
-
}
|
|
25
|
-
}
|