paulmillr / noble-hashes

Audited & minimal JS implementation of hash functions, MACs and KDFs.
https://paulmillr.com/noble
MIT License
573 stars 46 forks source link

fix: Uint8Array check #57

Closed janek26 closed 1 year ago

janek26 commented 1 year ago

This fixes issue #48

Firefox has the same issue as jest, so this will make the lib work in firefox.

paulmillr commented 1 year ago

Firefox does not have this issue, otherwise we'd have spotted this a long time ago. Proof:

Screenshot 2023-05-15 at 9 38 12 PM
janek26 commented 1 year ago

It does not work in Firefox when in an extension context as reported here https://bugzilla.mozilla.org/show_bug.cgi?id=1681809 I dont see a drawback to the proposed solution to not do it, do you? I could add a check to only cast it when the check fails

paulmillr commented 1 year ago

I didn't know about the bug. That makes sense.

I would of course prefer a generic solution that would allow the u8a check to be carried in various similar contexts, but the question is: which other contexts are we looking for?

Firefox extensions is a big one that absolutely warrants your fix.

JSDOM is meh, not too important.

Web Workers are important.

Anything else I could be missing?

janek26 commented 1 year ago

not sure honestly, probably edge envs like cloudflare and vercel

We just discovered this by accident. Also this does not fix the comparison, but the produced value. So if the value comes from something different than this lib, it will fail again/needs to be casted

janek26 commented 1 year ago

as inspiration: https://github.com/panva/jose#supported-runtimes

janek26 commented 1 year ago

we'll keep using patch-package for now, up to you what to do with this @paulmillr

paulmillr commented 1 year ago

Fixed by myself, thanks