-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[.NET] Add binary for web assembly to NuGet package #1204
Comments
libsodium can easily be compiled to WebAssembly using the Now for the "include the wasm binary in the NuGet package" part, I have no idea how to do that. |
I'm having some difficulty compiling to WASM using the
The process runs to completion, but every test fails. Logs attached. Looking at the diff for #1174 , would including a WASM binary in the NuGet package only be a matter of adding another procedure to the |
Running webassembly modules requires a webassembly runtime. So, in order to run the test suite, a runtime such as |
Installing a runtime did the trick. I am referring to output in my project's
However, when I make a call to |
If this comment still describes the current state of Web Assembly, then is trying to get a native version of libsodium (libsodium.a) running in the browser a fool's errand? Do I need to be pointed in the direction of emscripten.sh and the libsodium.js that it outputs? Given the issue I encountered with Edit: It appears the error I encountered appears as early as linking the libsodium.a from the wasm32-wasi script to my .net project:
|
Linking a WASI implementation would be the best way to go. And there has to be ways to do that in .NET. |
There has been some discussion on the linked issue. Sounds complicated. Will you elaborate on how we get from |
Is this what you are referring to by "linking a WASI implementation"? Someone would have implemented their own "random" code that works in the browser and I would instruct Libsodium to use that implementation?
|
Not sure why you keep referring to WASI adds the following functions to a WebAssembly environment: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md There's indeed a function that returns random data, that is absolutely required for libsodium. But is it the only one? I expect at least |
Maybe wasmer-js can help? |
I think your latest comments really help clear this up for me. I was struggling to understand why WASI was relevant in the context of a WASM application running in the browser. My understanding of WASI is that it was a technology intended for non-browser scenarios. But it sounds like the libsodium wasm-wasi build is intended for both browser and non-browser scenarios alike, assuming a WASI implementation is present (or linked, as you commented earlier). I'm eager to see if wasmer-js can help. I assume I just need to initialize the library on the webpage and everything else should just begin to work? wasmer-js initialization Thank you for your help. There are a few other folks who would also like to get libsodium working as a native dependency in their Blazor WASM projects; they have been commenting on the nsec C# repo It will be nice to get this working. |
Here is the latest on using wasmer-js. I don't think I can "load" the
It seems like the next option would be to somehow get the entire Blazor WASM application loaded into the wasmer-js wasi runtime. This way I can continue referring to |
Commenting here since @ektrah wants to use this issue as the central location for discussing a Blazor WASM solution. I really don't think using the wasm32-wasi package is the right way to go for Blazor WASM. It would have been really convenient to use the wasmer-js could work if we were really inclined, but I don't see any benefit to that over using libsodium-js since both methods are going to require JSInterop on every single call into libsodium (or so I think; I'm not equipped to write alternative bindings for .wasm modules). I started working on a small proof-of-concept to show how we could wrap a .NET class library over libsodium-js, but I'm having trouble working with the Maybe Running the example should be as simple as setting up |
I got For reference: dotnet/runtime#76672 |
@jedisct1 Thanks for putting up with me. I'd be fine closing this issue now that I have a path forward and discovered the impossibility of asking you (or other core maintainers) to provide a nuget package for Blazor WASM. I'll continue working on my "BlazorSodium" project for now. |
.NET 6 has supposedly made it very simple for Blazor WASM projects to refer to native code in the browser. Would it be possible to include a WASM binary in the libsodium NuGet package?
For reference, Steve Sanderson explains how SQLite recently accomplished this with their package: https://www.youtube.com/watch?v=lP_qdhAHFlg&t=724s
The text was updated successfully, but these errors were encountered: