etherpad-lite/src/node/utils
muxator 4ee5ddb496 caching_midleware: also run when nodejs does not have crypto module
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] 9677b0641c
[3] http://www.cse.yorku.ca/~oz/hash.html#djb2
[4] https://stackoverflow.com/questions/1579721/why-are-5381-and-33-so-important-in-the-djb2-algorithm
[5] https://groups.google.com/forum/#!msg/comp.lang.c/lSKWXiuNOAk/zstZ3SRhCjgJ
[6] https://en.wikipedia.org/wiki/Daniel_J._Bernstein
2020-03-31 04:09:49 +02:00
..
Abiword.js Remove trailing whitespaces 2019-04-16 00:34:29 +02:00
AbsolutePaths.js utils/AbsolutePaths.js: do not break when running as a Windows manual install 2019-02-11 03:28:02 +01:00
caching_middleware.js caching_midleware: also run when nodejs does not have crypto module 2020-03-31 04:09:49 +02:00
Cli.js remove -k argument as it is currently for both sessionkey and apikey 2018-08-09 19:42:14 +02:00
customError.js Remove trailing whitespaces 2019-04-16 00:34:29 +02:00
ExportEtherpad.js import/export: conversion to Promises/async 2019-01-31 08:55:36 +00:00
ExportHelper.js Fix Unicode bug in HTML export 2019-08-12 00:41:17 +02:00
ExportHtml.js referer: change referrer policy. Stop sending referers as much as possible 2019-11-25 00:05:40 +01:00
ExportTxt.js import/export: conversion to Promises/async 2019-01-31 08:55:36 +00:00
ImportEtherpad.js import/export: conversion to Promises/async 2019-01-31 08:55:36 +00:00
ImportHtml.js import/export: conversion to Promises/async 2019-01-31 08:55:36 +00:00
LibreOffice.js LibreOffice: add debugging log statements 2018-11-01 00:22:27 +01:00
Minify.js minify: make conditional requests work. No HTTP/304 was ever generated and file were reminified uselessly. 2020-03-23 11:34:01 +01:00
NodeVersion.js NodeVersion.js: do not use callbacks, simplify calling style in server.js 2019-02-19 00:46:37 +01:00
padDiff.js padDiff.js: convert to Promises/async 2019-01-31 14:38:56 +00:00
path_exists.js Fixed path check 2016-06-20 00:22:29 +02:00
randomstring.js fix randomstring 2014-01-24 01:19:14 +01:00
RemoteAddress.js working handling of setting client ip and anonymizing etc 2014-11-04 23:25:18 +00:00
Settings.js settings: document the possibility of using Unix sockets 2020-03-30 03:36:55 +02:00
tar.json swap out jquery browser for bower but expose browser object to all pages also enable minification.. Seems to work well 2014-11-22 19:11:35 +00:00
TidyHtml.js TidyHtml.js: convert to promises 2019-01-31 13:42:41 +00:00
toolbar.js toolbar: don't show the "saved revision" button in timeslider 2020-03-30 01:59:49 +02:00