I’ve been writing a bunch of jest tests recently for libraries that use the underlying window.crypto
methods like getRandomValues()
and window.crypto.subtle
key management methods. One problem I run into is that the window.crypto
object isn’t available, so I need to shim it.
To use the window.crypto
methods, you will need Node 15+. You can set the window.crypto
by importing the crypto
package and setting it on the global:
const crypto = require('crypto').webcrypto; // Shims the crypto property onto global global.crypto = crypto;
I really loathe creating mock functions for missing libraries in Node because they can lead to faulty positives on tests; I really appreciate webcrypto
being available!
How to Create a RetroPie on Raspberry Pi – Graphical Guide
Today we get to play amazing games on our super powered game consoles, PCs, VR headsets, and even mobile devices. While I enjoy playing new games these days, I do long for the retro gaming systems I had when I was a kid: the original Nintendo…
Fixing sIFR Printing with CSS and MooTools
While I’m not a huge sIFR advocate I can understand its allure. A customer recently asked us to implement sIFR on their website but I ran into a problem: the sIFR headings wouldn’t print because they were Flash objects. Here’s how to fix…
Source link