How to Use window.crypto in Node.js
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!
One major problem with creating UI components with the MooTools JavaScript framework is that there isn't a great way of allowing customization of template and ease of node creation. As of today, there are two ways of creating:
new Element Madness
The first way to create UI-driven...
I remember the early days of JavaScript where you needed a simple function for just about everything because the browser vendors implemented features differently, and not just edge features, basic features, like addEventListener
and attachEvent
. Times have changed but there are still a few functions each developer should...
I released my first MooTools class over a year ago. It was a really minimalistic approach to zebra tables and a great first class to write. I took some time to update and improve the class.
The XHTML
You may have as many tables as...
One of my favorite social APIs was the Open Graph API adopted by Facebook. Adding just a few META tags to each page allowed links to my article to be styled and presented the way I wanted them to, giving me a bit of control...