mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-22 17:46:55 +00:00
According to the nodejs docs [0] the `crypto` module might be unavailable on
some platforms:
> It is possible for Node.js to be built without including support for the
> crypto module. In such cases, calling require('crypto') will result in an
> error being thrown
A description of such scenarios can be found here [1].
> * running non-standard node in a resource- or security-constrained
> environment
> * running in emulated environment (browserify, webpack etc.)
> * building node from source and omitting openssl/crypto for random reason
TypeScript guys dealt with this same issue and they resolved it in an elegant
way in [2].
We copy that approach here: if importing crypto fails at runtime, we replace
sha256 with djb2 [3], which is weaker, but works for our case.
The djb2 story is fun: see this Stack Overflow post [4], and the original
mailing list post from 1991 [5] by Daniel J. Bernstein [6].
He was 20 at the time!
[0] https://nodejs.org/docs/latest-v10.x/api/crypto.html#crypto_determining_if_crypto_support_is_unavailable
[1] https://github.com/microsoft/TypeScript/issues/19100#issuecomment-335871998
[2]
|
||
|---|---|---|
| .. | ||
| Abiword.js | ||
| AbsolutePaths.js | ||
| caching_middleware.js | ||
| Cli.js | ||
| customError.js | ||
| ExportEtherpad.js | ||
| ExportHelper.js | ||
| ExportHtml.js | ||
| ExportTxt.js | ||
| ImportEtherpad.js | ||
| ImportHtml.js | ||
| LibreOffice.js | ||
| Minify.js | ||
| NodeVersion.js | ||
| padDiff.js | ||
| path_exists.js | ||
| randomstring.js | ||
| RemoteAddress.js | ||
| Settings.js | ||
| tar.json | ||
| TidyHtml.js | ||
| toolbar.js | ||