sodium icon indicating copy to clipboard operation
sodium copied to clipboard

chore: support deno 2.0 by replacing __dirname -> import.meta.dirname.

Open mash8 opened this issue 1 year ago • 10 comments

For this issue https://github.com/denosaurs/sodium/issues/4

mash8 avatar Nov 04 '24 22:11 mash8

Tests keep failing because of Uncaught TypeError: h is not a function trying to figure it out.

On further investigation it's crashing while trying to print why it crashed...

Real error is

"Error: Both wasm and asm failed to loadTypeError: Cannot read properties of undefined (reading 'rc')\n    at file:///C:/Repos/sodium-fork/dist/browsers/sodium.js:49916:35"

mash8 avatar Nov 05 '24 09:11 mash8

Strange, and you get the same error locally when running the tests? Seems like the built code is somehow wrong.

eliassjogreen avatar Nov 05 '24 12:11 eliassjogreen

Getting it locally as well yeah. I'm gonna give it a shot on a Linux machine see if it makes a difference.

Also another idea.. do you know where the build code originally came from? Maybe there's an updated version?

mash8 avatar Nov 05 '24 21:11 mash8

Tried running the tests on deno 1.x and it worked. I guess the js build files don't work in deno 2.x. Need to figure out how to update them.

There wouldn't happen to be a un-uglified version of the sodium.js build file somewhere?

mash8 avatar Nov 05 '24 22:11 mash8

Looks like the files came from here originally https://github.com/jedisct1/libsodium.js. I'll try and update them and see what happens.

mash8 avatar Nov 06 '24 05:11 mash8

Have you tried using libsodiumjs (or even the web standard crypto if that fits your needs) directly? It may be easier to depend on it than this, honeslty ill-maintained wrapper module.

eliassjogreen avatar Nov 11 '24 08:11 eliassjogreen

I hadn't heard of libsodiumjs until I started looking into this. It would be easier to just use that... but I it'd be nice if this was working for Deno users. So they can use sodium without needing to think.

I don't mind continuing to work on this if no one else is gonna do it. It's an excuse to learn something on my end.

mash8 avatar Nov 12 '24 09:11 mash8

I hadn't heard of libsodiumjs until I started looking into this. It would be easier to just use that... but I it'd be nice if this was working for Deno users. So they can use sodium without needing to think.

Well, if you are doing anything requiring libsodium and crypto, I would hope the user thinks long and hard about the problem theyre trying to solve if it has anything to do with authentication, signing, etc. But I get the need for basic access to cryptographic functions when for example interacting with an API.

I don't mind continuing to work on this if no one else is gonna do it. It's an excuse to learn something on my end.

Go for it! I would appreciate it!

eliassjogreen avatar Nov 12 '24 12:11 eliassjogreen

Btw @eliassjogreen I noticed you're also apart of the https://github.com/denosaurs/opus repo. I created a fix for that repo here https://github.com/denosaurs/opus/pull/3. It's a lot simpler than this...

mash8 avatar Nov 15 '24 08:11 mash8

Found this issue trying earthstar, any updates?

amatiasq avatar Feb 04 '25 15:02 amatiasq