Skip to content
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

dart2wasm support #230

Open
2 of 3 tasks
simolus3 opened this issue May 10, 2024 · 2 comments
Open
2 of 3 tasks

dart2wasm support #230

simolus3 opened this issue May 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@simolus3
Copy link
Owner

simolus3 commented May 10, 2024

Current state: package:sqlite3 experimentally supports being compiled with dart2wasm. Unit tests exercising the bindings themselves all pass, but persistence is broken. There are additional caveats and todos to be aware of:

  • (fixed in upcoming Dart SDK release) dart2wasm doesn't seem to support Random.secure(), which we use for our VFS implementations. You can work around this issue by supplying your own non-secure Random() instance to VFS constructors, but please be aware that this may be a security risk. sqlite3 docs require that "The xRandomness() function attempts to return nBytes bytes of good-quality randomness into zOut", so I won't use the non-secure random instance as a default in this package.
  • When binding over web APIs returning JavaScript ArrayBuffers, we're converting them to Dart TypedData subclasses for convenience. This is not sound for dart2wasm, which copies the bytes instead of referencing the original buffer. This may just be hugely inefficient, but it can also cause deadlocks for OPFS and data corruption issues on other VFS implementations.
  • We're currently loading an additional wasm module for sqlite3 (sqlite3.wasm). Once the native assets feature is stable and supports WebAssembly, obviously we want to link the Dart application and sqlite3 into the same wasm file for easier deployments.
@simolus3 simolus3 added the enhancement New feature or request label May 10, 2024
@ekuleshov
Copy link

For secure rng. Could you use one of the implementations from the pointycastle package?

@simolus3
Copy link
Owner Author

That doesn't help getting entropy. Secure random has been implemented, it's just not on stable yet. So we can just wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants