forge icon indicating copy to clipboard operation
forge copied to clipboard

Cannot read property 'crypto' of undefined

Open xiuyu123123 opened this issue 1 year ago • 2 comments

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)

xiuyu123123 avatar Apr 06 '23 10:04 xiuyu123123

More information is needed to help with this.

  • What version of forge?
  • What environment?
  • What is the calling code?

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.

davidlehn avatar Apr 07 '23 18:04 davidlehn

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

iovreche avatar Apr 12 '23 14:04 iovreche