ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript
https://zelark.github.io/nano-id-cc/
MIT License
24.22k stars 790 forks source link

fix(node): use webcrypto export from `node:crypto` #448

Closed brc-dd closed 10 months ago

brc-dd commented 10 months ago

Using crypto.webcrypto.getRandomValues() is recommended instead of directly using the aliased version from crypto.getRandomValues() as the latter is not meant to be compatible with the WebCrypto spec and is non-standard.

There was earlier discussion on this in the node repo - https://github.com/nodejs/node/pull/41779, https://github.com/nodejs/node/pull/41782, https://github.com/nodejs/node/pull/41760

This is breaking some downstream tools as well that are bundling / down-compiling nanoid (although that's not much of an nanoid issue).

PS: updating the clean script as well. Running test was failing for new contributors who don't already have a coverage directory.

ai commented 10 months ago

Thanks. The fix was released in 5.0.2.