Closed dboreham closed 2 years ago
see https://github.com/decentstack for a contained example of required migration work.
We cannot update to next hypercore-protocol yet. @substack just found that it doesn't work in the browser. It requires extra routines in sodium-universal that are not implemented. It will require aead methods to be implemented in https://github.com/sodium-friends/sodium-javascript
See the overview of methods not implemented in Javascript here: https://github.com/sodium-friends/sodium-universal
If it is crucial to update soon, it would be best to contract someone to complete this work. I don't expect that this is being prioritized by core maintainers.
Assigning to rich. We need to assess if this is now a priority, and if so, it will likely require an outside contract.
Do we know why hypercore depends on sodium-universal (and hence sodium-javascript in the browser environment), rather than libsodium.js ? (libsodium.js is a straight compilation of the stock C sodium source to wasm and therefore should have feature parity with sodium-native).
The problem is the loader of libsodium.js is async. So there is no easy way to provide a hybrid
solution for both worlds node and browser.
The only fix that it comes to my mind is to build an alias module for webpack and provide the same API of sodium-universal and during the initialization of the webapp wait for the libsodium to be loaded and then start the app.
Another good thing could be to organize a meeting with the mafintosh team to get a solution and help them to do it.
Another thing to note is that sodium-universal has a JS fallback for when you're running the code in older browsers / engines that don't have WASM. I ran into this when integrating with react-native
@substack also said he'd be willing to tackle this as part of a contract, and has an idea of how it'd get done
he's already started: https://github.com/sodium-friends/sodium-test/pull/6/files
Another thing to note is that sodium-universal has a JS fallback for when you're running the code in older browsers / engines that don't have WASM. I ran into this when integrating with react-native
Yeah I think that's actually the problem though -- the JS fallback is an incomplete implementation of the sodium library, missing stuff that's needed for noise protocol. As @tinchoz49 says above ideally we want a "universal" shim that selects between libsodium.js and sodium-native, falling back to sodium-javascript only if neither Node nor wasm is available.
he's already started: https://github.com/sodium-friends/sodium-test/pull/6/files
this is great!
Previous dup: https://github.com/wirelineio/specs/issues/9