Add encryption support through SQLite3MultipleCiphers #288
+3,560
−37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the
com.powersync:sqlite3multiplecipherspackage, providing encryption support.This package has to replicate what
:coreis using as a SQLite driver on all targets:static-sqlite3-driverdoes already (except that we link SQLite3MultipleCiphers instead of the normal SQLite library). Since these are ABI-compatible, we can use the native driver that is already part of the:commonpackage.androidx.sqlite:bundled-sqlite-driverdoes. I've copied the sources and kept copyright headers. The only change is that the package name has been updated tocom.powersync.encryption. The sources contain Kotlin classes and thesqlite_bindings.cppfile providing a JNI wrapper around SQLite.clangfrom a homebrew installation already installed on GitHub assets. Clang can cross-compile natively, but will need libc headers and compiler builtins for the target platform. I've added a shellscript that downloads these from Archlinux packages, the Gradle build task then points clang towards the relevant sysroot.I really don't like this build process, but at least it runs reliably in CI. I've opened a pull request to attach the output of this build to GitHub releases doing forward. After the next release, I'll configure the build to download assets from there by default.
There's no example for the new project yet, but there is a simple unit test for all JVM + native platforms. On Android, I'm running integration tests as part of the device check.