nodejs / webcrypto

This repository has been archived. The WebCrypto API has been implemented in recent versions of Node.js and does not require additional packages.
69 stars 20 forks source link

feature request: exposing crypto interface directly #49

Closed SmartLayer closed 4 years ago

SmartLayer commented 4 years ago

I wrote a simple test that erred:

const crypto = require("webcrypto");
var iv = crypto.getRandomValues(new Uint8Array(16))
console.log(iv)

turns out I should do this:

const crypto = require("webcrypto");
var iv = crypto.crypto.getRandomValues(new Uint8Array(16))
console.log(iv)

compared to the straightforward interface provided by trust-webcrypto

const crypto = require("@trust/webcrypto");
var iv = crypto.getRandomValues(new Uint8Array(16))
console.log(iv)

I think it's more intuitive to provide crypto object directly.

tniessen commented 4 years ago

It just takes two more characters:

const { crypto } = require("webcrypto");
SmartLayer commented 4 years ago

Thanks!