unjs / unenv

๐Ÿ•Š๏ธ Convert javaScript code to be runtime agnostic
MIT License
358 stars 19 forks source link

feat(node): export full node crypto exports #121

Closed pi0 closed 1 year ago

pi0 commented 1 year ago

๐Ÿ”— Linked issue

Resolves #91

Related PR: #111

โ“ Type of change

๐Ÿ“š Description

This PR adds all missing exports for node crypto shims to make sure it is compliant with Node.js types.

New methods are not implemented and will call an explicit runtime error if attempted to be called.

Note: Implementing the methods while possible, is not practical! A tree-shaked bundled version of browserify utils take ~550kb while with unenv with target modern runtimes (browser and workers) that all support crypto subtle. And new environments such as cloudflare workers and deno, offer their own runtime support for Node.js APIs.

Still (on a case by case basis) if there is a popular Node.js lib that needs some of them and there is a zero dep minimal implementation of some of them possible (optionally depending on web crypto and subtle crypto) it is more than welcome!

๐Ÿ“ Checklist