You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
letcrypto;try{crypto=require('crypto');}catch(err){console.log('crypto support is disabled!');}
That means on a reduced node environment the compiler crashes unnecessarily. By unnecessarily I mean the support for crypto is already optional in the compiler:
Note that one place in the code actually does rely on createHash unconditionally. Which should be a bug, considering that it's declared as optional in sys.ts line 67 (see above).
constnoCrypto=!process.versions.openssl;exports.assertCrypto=function(exports){if(noCrypto)thrownewError('Node.js is not compiled with openssl crypto support');};
We're going to need some sort of hashing mechanism at some point, we should just use that as a fallback for createHash. In the mean time, I'm not sure if there's any harm in being precautious.
Activity
mihailik commentedon Oct 11, 2017
Note that one place in the code actually does rely on
createHashunconditionally. Which should be a bug, considering that it's declared as optional insys.tsline 67 (see above).https://github.com/Microsoft/TypeScript/blob/a7fa187fb2ac58892593e8936ac728d61a57eacb/src/compiler/program.ts#L135
mhegazy commentedon Oct 11, 2017
Can you elaborate on what scenarios require node without crypto?
mihailik commentedon Oct 11, 2017
Mohamed Hegazy (@mhegazy) three scenarios [UPDATED]:
Here's a very relevant piece in node's lib/internal/util.js L100:
DanielRosenwasser commentedon Oct 18, 2017
We're going to need some sort of hashing mechanism at some point, we should just use that as a fallback for
createHash. In the mean time, I'm not sure if there's any harm in being precautious.rbuckton commentedon Jan 26, 2018
Daniel Rosenwasser (@DanielRosenwasser): https://github.com/Microsoft/TypeScript/blob/vfs/src/harness/core.ts#L609