Skip to content

Commit a6b9835

Browse files
authored
Merge pull request #13 from CoolBitX-Technology/chore/use-coolbix-config
🔧 chore: update config on v1 to publish to `@coolwallet-app/react-native-crypto` succeeded
2 parents ca27455 + b9a073f commit a6b9835

7 files changed

Lines changed: 231 additions & 169 deletions

File tree

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ find packages/react-native-quick-crypto/cpp -name "*.cpp" -o -name "*.hpp" | xar
1111
bun tsc
1212

1313
# Run prepare script
14-
bun --filter="react-native-quick-crypto" prepare
14+
bun --filter="@coolwallet-app/react-native-quick-crypto" prepare

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v24.14.1

README-origin.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
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>
8+
9+
# ⚡️ react-native-quick-crypto
10+
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
53+
```
54+
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+
```
69+
70+
Optional: override `global.Buffer` and `global.crypto` in your application as early as possible for example in index.js.
71+
72+
```ts
73+
import { install } from 'react-native-quick-crypto';
74+
75+
install();
76+
```
77+
78+
## Replace `crypto-browserify`
79+
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+
}
99+
```
100+
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.
104+
105+
```sh
106+
yarn add --dev babel-plugin-module-resolver
107+
```
108+
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`.
133+
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');
144+
```
145+
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.
149+
150+
## Community Discord
151+
152+
[Join the Margelo Community Discord](https://discord.gg/6CSHz2qAvA) to chat about react-native-quick-crypto or other Margelo libraries.
153+
154+
## Adopting at scale
155+
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>!
157+
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)
165+
166+
## License
167+
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).

README.md

Lines changed: 49 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,74 @@
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
82

9-
# ⚡️ react-native-quick-crypto
3+
# Install bun
104

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
538
```
549

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
6911

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`
7113

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:
7415

75-
install();
16+
```bash
17+
brew unlink bun@1.1.26
18+
brew link --overwrite bun@1.2.0
19+
bun --version
7620
```
7721

78-
## Replace `crypto-browserify`
22+
To preview what would be replaced before linking:
7923

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
9926
```
10027

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
10429

105-
```sh
106-
yarn add --dev babel-plugin-module-resolver
30+
```bash
31+
bun install
32+
bun prepare
10733
```
10834

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
13336

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
14440
```
14541

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:
14943

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
15151

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)
15353
154-
## Adopting at scale
15554
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
15756
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+
```
16566
166-
## License
67+
# Develop flow
16768
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

Comments
 (0)