I have been writing a bunch of jest exams lately for libraries that use the underlying window.crypto
strategies like getRandomValues()
and window.crypto.refined
key administration strategies. One downside I run into is that the window.crypto
object is not obtainable, so I must shim it.
To make use of the window.crypto
strategies, you will want Node 15+. You’ll be able to set the window.crypto
by importing the crypto
bundle and setting it on the worldwide:
const crypto = require('crypto').webcrypto; // Shims the crypto property onto international international.crypto = crypto;
I actually detest creating mock capabilities for lacking libraries in Node as a result of they will result in defective positives on exams; I actually admire webcrypto
being obtainable!