Cannot read property 'randomBytes' of undefined
- Dominant language
- JavaScript
- Stars
- 102
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
Bcrypto panics when rebuilded by electron.
From my investigation it seems that electron replaces openssl with boressl and this causes some incompatibilities. It seems that requiring of native random passes and doesn't fallback to node version.
I've mitigated it with (ELECTRON env is set by user , not electron itself):
```
if(process && process.env.ELECTRON) {
return require("bcrypto/lib/node/random").randomBytes(length);
} else {
return require("bcrypto/lib/random").randomBytes(length);
}
```
bcrypto 4.2.8
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by comparing bcrypto/lib/node/random with bcrypto/lib/random and reproduce the failure when bcrypto 4.2.8 is rebuilt by Electron. Trace how randomBytes is selected when Electron replaces OpenSSL. Done means randomBytes can be read successfully in the Electron environment without the undefined-property error, with the relevant behavior covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, javascript
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100