|
1 | | -<a href="https://margelo.com"> |
2 | | - <picture> |
3 | | - <source media="(prefers-color-scheme: dark)" srcset="./.docs/img/banner-dark.png" /> |
4 | | - <source media="(prefers-color-scheme: light)" srcset="./.docs/img/banner-light.png" /> |
5 | | - <img alt="react-native-quick-crypto" src="./.docs/img/banner-light.png" /> |
6 | | - </picture> |
7 | | -</a> |
| 1 | +npm module: https://www.npmjs.com/package/@coolwallet-app/react-native-quick-crypto |
8 | 2 |
|
9 | | -# ⚡️ react-native-quick-crypto |
| 3 | +# Install bun |
10 | 4 |
|
11 | | -A fast implementation of Node's `crypto` module. |
12 | | - |
13 | | -## Features |
14 | | - |
15 | | -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. |
16 | | -QuickCrypto can be used as a drop-in replacement for your Web3/Crypto apps or CRDT-based local first databases to speed up common cryptography functions. |
17 | | - |
18 | | -- 🏎️ Hundreds of times faster than all JS-based solutions |
19 | | -- ⚡️ Lightning fast implementation with Nitro Modules (pure C++ and JSI) instead of JS |
20 | | -- 🧪 Well tested in JS and C++ (OpenSSL) |
21 | | -- 💰 Made for crypto apps and wallets |
22 | | -- 🔢 Secure native compiled cryptography |
23 | | -- 🔁 Easy drop-in replacement for [crypto-browserify](https://github.com/browserify/crypto-browserify) or [react-native-crypto](https://github.com/tradle/react-native-crypto) |
24 | | - |
25 | | -## Versions |
26 | | - |
27 | | -| Version | RN Architecture | Modules | |
28 | | -| ------- | ------ | ------- | |
29 | | -| `1.x` | new [->](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md) | Nitro Modules [->](https://github.com/mrousavy/nitro) | |
30 | | -| `0.x` | old, new 🤞 | Bridge & JSI | |
31 | | - |
32 | | -> Note: Minimum supported version of React Native is `0.75`. If you need to use earlier versions, please use `0.x` versions of this library. |
33 | | -
|
34 | | -## Migration |
35 | | - |
36 | | -Our goal in refactoring to v1.0 was to maintain API compatibility. If you are upgrading to v1.0 from v0.x, and find any discrepancies, please open an issue in this repo. |
37 | | - |
38 | | -## Benchmarks |
39 | | - |
40 | | -There is a benchmark suite in the Example app in this repo that has benchmarks of algorithms against their pure JS counterparts. This is not meant to disparage the other libraries. On the contrary, they perform amazingly well when used in a server-side Node environment. This library exists because React Native does not have that environment nor the Node Crypto API implementation at hand. So the benchmark suite is there to show you the speedup vs. the alternative of using a pure JS library on React Native. |
41 | | - |
42 | | ---- |
43 | | - |
44 | | -## Installation |
45 | | - |
46 | | -<h3> |
47 | | - React Native <a href="#"><img src="./.docs/img/react-native.png" height="15" /></a> |
48 | | -</h3> |
49 | | - |
50 | | -```sh |
51 | | -bun add react-native-quick-crypto react-native-nitro-modules react-native-quick-base64 |
52 | | -cd ios && pod install |
| 5 | +```bash |
| 6 | +brew install oven-sh/bun/bun@1.2.0 |
| 7 | +bun --version |
53 | 8 | ``` |
54 | 9 |
|
55 | | -<h3> |
56 | | - Expo <a href="#"> |
57 | | - <picture> |
58 | | - <source media="(prefers-color-scheme: dark)" srcset="./.docs/img/expo/dark.png" /> |
59 | | - <source media="(prefers-color-scheme: light)" srcset="./.docs/img/expo/light.png" /> |
60 | | - <img alt="Expo" src="./.docs/img/expo/light.png" height="12" /> |
61 | | - </picture> |
62 | | - </a> |
63 | | -</h3> |
64 | | - |
65 | | -```sh |
66 | | -expo install react-native-quick-crypto |
67 | | -expo prebuild |
68 | | -``` |
| 10 | +## Troubleshooting |
69 | 11 |
|
70 | | -Optional: override `global.Buffer` and `global.crypto` in your application as early as possible for example in index.js. |
| 12 | +### `brew install oven-sh/bun/bun@1.2.0` fails at `brew link` |
71 | 13 |
|
72 | | -```ts |
73 | | -import { install } from 'react-native-quick-crypto'; |
| 14 | +If Homebrew reports that `bun@1.2.0` is installed but cannot be symlinked because files belong to `bun@1.1.26`, run: |
74 | 15 |
|
75 | | -install(); |
| 16 | +```bash |
| 17 | +brew unlink bun@1.1.26 |
| 18 | +brew link --overwrite bun@1.2.0 |
| 19 | +bun --version |
76 | 20 | ``` |
77 | 21 |
|
78 | | -## Replace `crypto-browserify` |
| 22 | +To preview what would be replaced before linking: |
79 | 23 |
|
80 | | -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! |
81 | | - |
82 | | -### Using metro config |
83 | | - |
84 | | -Use the [`resolveRequest`](https://facebook.github.io/metro/docs/resolution#resolverequest-customresolver) configuration option in your `metro.config.js` |
85 | | - |
86 | | -```js |
87 | | -config.resolver.resolveRequest = (context, moduleName, platform) => { |
88 | | - if (moduleName === 'crypto') { |
89 | | - // when importing crypto, resolve to react-native-quick-crypto |
90 | | - return context.resolveRequest( |
91 | | - context, |
92 | | - 'react-native-quick-crypto', |
93 | | - platform, |
94 | | - ) |
95 | | - } |
96 | | - // otherwise chain to the standard Metro resolver. |
97 | | - return context.resolveRequest(context, moduleName, platform) |
98 | | -} |
| 24 | +```bash |
| 25 | +brew link --overwrite bun@1.2.0 --dry-run |
99 | 26 | ``` |
100 | 27 |
|
101 | | -### Using babel-plugin-module-resolver |
102 | | - |
103 | | -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. |
| 28 | +# Bundle libs |
104 | 29 |
|
105 | | -```sh |
106 | | -yarn add --dev babel-plugin-module-resolver |
| 30 | +```bash |
| 31 | +bun install |
| 32 | +bun prepare |
107 | 33 | ``` |
108 | 34 |
|
109 | | -Then, in your `babel.config.js`, add the plugin to swap the `crypto`, `stream` and `buffer` dependencies: |
110 | | - |
111 | | -```diff |
112 | | -module.exports = { |
113 | | - presets: ['module:metro-react-native-babel-preset'], |
114 | | - plugins: [ |
115 | | -+ [ |
116 | | -+ 'module-resolver', |
117 | | -+ { |
118 | | -+ alias: { |
119 | | -+ 'crypto': 'react-native-quick-crypto', |
120 | | -+ 'stream': 'readable-stream', |
121 | | -+ 'buffer': 'react-native-quick-crypto', |
122 | | -+ }, |
123 | | -+ }, |
124 | | -+ ], |
125 | | - ... |
126 | | - ], |
127 | | -}; |
128 | | -``` |
129 | | - |
130 | | -> **Note:** `react-native-quick-crypto` re-exports `Buffer` from `@craftzdog/react-native-buffer`, so you can use either as the buffer alias. Using `react-native-quick-crypto` ensures a single Buffer instance across your app. |
131 | | -
|
132 | | -Then restart your bundler using `yarn start --reset-cache`. |
| 35 | +# Publish |
133 | 36 |
|
134 | | -## Usage |
135 | | - |
136 | | -For example, to hash a string with SHA256 you can do the following: |
137 | | - |
138 | | -```ts |
139 | | -import QuickCrypto from 'react-native-quick-crypto'; |
140 | | - |
141 | | -const hashed = QuickCrypto.createHash('sha256') |
142 | | - .update('Damn, Margelo writes hella good software!') |
143 | | - .digest('hex'); |
| 37 | +```bash |
| 38 | +npm login |
| 39 | +bun release |
144 | 40 | ``` |
145 | 41 |
|
146 | | -## Limitations |
147 | | - |
148 | | -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. |
| 42 | +Example log for publishing: |
149 | 43 |
|
150 | | -## Community Discord |
| 44 | +```bash |
| 45 | +❯ bun release |
| 46 | +$ ./scripts/release.sh |
| 47 | +Starting the release process... |
| 48 | +Provided options: |
| 49 | +Publishing 'react-native-quick-crypto' to NPM |
| 50 | +$ release-it |
151 | 51 |
|
152 | | -[Join the Margelo Community Discord](https://discord.gg/6CSHz2qAvA) to chat about react-native-quick-crypto or other Margelo libraries. |
| 52 | +🚀 Let's release @coolwallet-app/react-native-quick-crypto (currently at 1.0.18) |
153 | 53 |
|
154 | | -## Adopting at scale |
155 | 54 |
|
156 | | -`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.com?subject=Adopting react-native-quick-crypto at scale">hello@margelo.com</a>! |
| 55 | +Empty changelog |
157 | 56 |
|
158 | | -## Contributing |
159 | | - |
160 | | -See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. |
161 | | - |
162 | | -For more detailed guides, check out our documentation website: |
163 | | -- [Contributing Guide]([prod-docs]/docs/guides/contributing) |
164 | | -- [Writing Documentation]([prod-docs]/docs/guides/writing-documentation) |
| 57 | +✔ Select increment (next version): Other, please specify... |
| 58 | +✔ Please enter a valid version: 1.0.18-cbx.0 |
| 59 | +✔ bun tsc && bun lint && bun format && bun prepare |
| 60 | +✔ Publish @coolwallet-app/react-native-quick-crypto@cbx to npm? Yes |
| 61 | +✔ Please enter OTP for npm: 056218 |
| 62 | +🔗 https://registry.npmjs.org/package/@coolwallet-app/react-native-quick-crypto |
| 63 | +🏁 Done (in 60s.) |
| 64 | +Successfully released QuickCrypto! |
| 65 | +``` |
165 | 66 |
|
166 | | -## License |
| 67 | +# Develop flow |
167 | 68 |
|
168 | | -- react-native-quick-crypto is licensed under MIT. |
169 | | -- react-native-quick-crypto is heavily inspired by NodeJS Crypto, which is licensed under [nodejs/LICENSE](https://github.com/nodejs/node/blob/main/LICENSE). |
| 69 | +- Create pull request into cbx branch |
| 70 | +- After the PR merged, publish to npm on cbx branch |
| 71 | +- Create pull request for the version change to cbx branch |
| 72 | +- After version change PR merged, Create git tag and github release |
| 73 | + - Example git tag: `v0.7.17-cbx.6` |
| 74 | + - Using auto-generate notes from GitHub GUI |
0 commit comments