digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.06k stars 781 forks source link

Cannot read property 'crypto' of undefined #1028

Open xiuyu123123 opened 1 year ago

xiuyu123123 commented 1 year ago

app.js错误: TypeError: Cannot read property 'crypto' of undefined at Object.t (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at e (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at Object.t (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at e (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at Object.t (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at e (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at Object.t (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at e (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at Object.t (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952) at e (vendor.js?t=wechat&s=1680776449375&v=64a94e62456c2f5e6e877651680b0c61:8952)(env: macOS,mp,1.06.2301171; lib: 2.30.3)

davidlehn commented 1 year ago

More information is needed to help with this.

There's some code that uses globalScope.crypto, which should work in modern runtimes. Looks like there might be some older compatibility hacks from when globalScope was too new to use in util.globalScope. I'm unsure what the state of that might be these days. You might try code related to those spots to see what the issue is.

iovreche commented 1 year ago

This is probably react-native. You need to provide the crypto primitives in react-native via shims / babel.