zelark / nano-id

A unique string ID generator for Clojure and ClojureScript (・_・)ノ
MIT License
192 stars 9 forks source link

js/crypto unavailable in nodejs #14

Closed knubie closed 3 years ago

knubie commented 4 years ago

nano-id uses window.crypto, but that object is not defined in nodejs.

https://github.com/zelark/nano-id/blob/1467b6a0e9a36a73484463b5071655f0d30b55c1/src/nano_id/random.cljc#L7-L9

zelark commented 4 years ago

I will look at it soon, thanks for reporting.

zelark commented 3 years ago

@knubie sorry, I was away for a while. Do you still need support for nodejs?

knubie commented 3 years ago

@zelark No problem. I was able to resolve the issue by using this polyfill: @peculiar/webcrypto. I'm not sure this library should add any more dependencies, so I'm satisfied with that workaround.

zelark commented 3 years ago

@knubie thanks for sharing, I think I need to add an example to README.

zelark commented 3 years ago

Added an example https://github.com/zelark/nano-id#nodejs