Skip to content

crypto: validate `this` value for `webcrypto.getRandomValues`

const{getRandomValues}=crypto.webcrypto || crypto;
getRandomValues(new Uint16Array)
  • Chromium: TypeError: Illegal invocation
  • Firefox: TypeError: 'getRandomValues' called on an object that does not implement interface Crypto.
  • Safari: TypeError: Can only call Crypto.getRandomValues on instances of Crypto
  • Deno: TypeError: Illegal invocation
  • Node.js: no error

This PR aligns Node.js with the rest of the ecosystem.

Merge request reports

Loading