digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.05k stars 779 forks source link

[jsbn] Node 21 introduced `navigator` global object which has changed jsbn behaviour #1081

Open dhensby opened 4 months ago

dhensby commented 4 months ago

See https://github.com/digitalbazaar/forge/blob/v1.3.1/lib/jsbn.js#L120-L133

The JSBN library uses the global navigator object to make optimisation assumptions about the runtime. It is currently assumed that node has no navigator global object and, thus, will follow the typeof navigator === 'undefined' path. This is no longer the case in v21+ and so now a different path is taken.

For now this can be avoided by running node with the --no-experimental-global-navigator option, but presumably this will eventually become permanent and the optimisation logic will need to change.