Skip to content

Commit

Permalink
Make friends with Node v18 and v20
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-thompson committed Dec 20, 2024
1 parent 4a0e706 commit 58543ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions js/packages/offline-renderer/elementary-wasm.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/packages/web-renderer/raw/elementary-wasm.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions wasm/pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
// not available. An alternative solution would be to upstream a change to the stretch
// library to rely on an injected random device in C++ territory, so that for our case
// we could inject some simple PRNG.
globalThis.crypto = {
getRandomValues: (array) => {
if (typeof globalThis?.crypto?.getRandomValues !== 'function') {
function _shimGetRandomValues(array) {
for (var i = 0; i < array.length; i++) {
array[i] = (Math.random() * 256) | 0;
}
}
};

if (typeof globalThis.crypto === 'object') {
globalThis.crypto.getRandomValues = _shimGetRandomValues;
} else {
globalThis.crypto = {
getRandomValues: _shimGetRandomValues,
};
}
}

0 comments on commit 58543ac

Please sign in to comment.