crypto.subtle is undefined on React Native
See original GitHub issuecrypto.subtle is undefined here (and everywhere else even later on) on both iOS and Android.
I’m running react-native@0.53.3
and it was created with react-native init
. Tried looking around to find some culprit but haven’t managed to find anything.
Found the culprit, seems that it doesn’t work while remotely debugging. Might have something to do with the code being executed in Chrome.
It seems that msrcrypto
runs in a web worker while in remote debugging which causes this to be set to true, which in turn causes this (msrcryptoSubtle) not to be instantiated, ergo undefined everywhere while remotely debugging.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
How to use SubtleCrypto in chrome (window.crypto.subtle is ...
According to the spec (via Github issues) a la this Google page for WebCrypto: crypto.subtle is supposed to be undefined in insecure ...
Read more >SubtleCrypto API not supported/bro… | Apple Developer Forums
generateKey throws an error undefined is not an object (evaluating ... We've been using SubtleCrypto library in our React-Native app on an iPhone...
Read more >react-native-webview-crypto - npm
Start using react-native-webview-crypto in your project by running `npm i react-native-webview-crypto`. There are 2 other projects in the ...
Read more >Crypto.subtle - Web APIs - MDN Web Docs
Chrome Edge
subtle Full support. Chrome37. Toggle history Full support. Edge12. Togg...
Secure context required Full support. Chrome60. Toggle history Full support. Edge79. Togg...
Read more >Crypto - Expo Documentation
expo-crypto enables you to hash data in an equivalent manner to the Node.js ... If you're installing this in a bare React Native...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Good find. It’s interesting that remote debugging React Native will run the app’s code in the context of a Web Worker.
An
MSRCRYPTO_FORCE_SYNC
global variable that serves as an alternative to usingforceSync
seems reasonable, and it minimizes the changes needed tomsrCrypto
.Unfortunately anything not listed in @bunea’s msrCrypto list above isn’t supported. The AES-KW algorithms are listed in the legend, but haven’t been tested. The support grid
belowabove the legend shows everything that’s tested.The original issue seems to be fixed, but comment if this is still an issue. Closing for now.