I use some nodejs code (like `Crypto.randomBytes(1...
# javascript
j
I use some nodejs code (like
Crypto.randomBytes(16)
and
Buffer.from("AQ", "base64")
in actual implementations of multiplatform code I intended to replace with browser compatible code. Somehow if I run my tests in the browser, the node functions all work and tests succeed in all browsers. (Firefox/Safari/Chrome) How can this be explained? Can I expect these functions to run in a proper application? Or am I overlooking something?
b
Likely them were polyfilled, I think you can check it by debugging your code inside a browser.
j
Thanks for the reply! I debugged the code and it seems two npm packages where loaded that contained the relevant code: https://www.npmjs.com/package/randombytes https://www.npmjs.com/package/buffer randombytes indeed uses getRandomValues() Can I trust these npm packages to be there in future releases or would it be wise to manually add them?
Should random crypto bytes and base64 functionality maybe instead be exposed in the js or multiplatform standard library?
b
Can I trust these npm packages to be there in future releases or would it be wise to manually add them?
adding manually/explicitly could be more robust
Should random crypto bytes and base64 functionality maybe instead be exposed in the js or multiplatform standard library?
I doubt, but you can ask in #stdlib or youtrack
j
Thanks for the replies 😄