You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's necessary to shim support for [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto)
47
-
until it's added to react-native by default.
48
-
49
-
First install the necessary dependencies:
50
-
51
-
```console
52
-
$ npm i @peculiar/webcrypto
53
-
```
54
-
55
-
..and create a shim file:
56
-
57
-
```js
58
-
// globals-crypto.js - this should be imported at the top of your App.js file
59
-
// but AFTER globals.js
60
-
import { Crypto } from'@peculiar/webcrypto'
61
-
62
43
global.crypto.subtle=newCrypto().subtle
63
44
```
64
45
65
-
IMPORTANT: until [PeculiarVentures/webcrypto#67](https://github.com/PeculiarVentures/webcrypto/pull/67) is
66
-
merged, SubtleCrypto has to be shimmed *after* the node Buffer polyfill has
67
-
been added to the global context.
68
-
69
46
3. Enable modern JS features
70
47
71
48
- libp2p uses [ES2022 private properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties) in some places, so enable transpiling them for use with React Native. At the time of writing [loose mode](https://2ality.com/2015/12/babel6-loose-mode.html) is also required.
@@ -117,7 +94,7 @@ $ npx expo run:ios --device
117
94
118
95
## Notes
119
96
120
-
- By default this demo uses pure-js crypto - it's not efficient enough to run on an actual device, `crypto-browserify` should be replaced with `react-native-quick-crypto` in `bable.config.js` for native builds
97
+
- By default this demo uses pure-js crypto - it's not efficient enough to run on an actual device, `crypto-browserify` should be replaced with `react-native-quick-crypto` in `babel.config.js` for native builds
121
98
-`@libp2p/webrtc` can also only run on a device since it needs native code
0 commit comments