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

I have written a couple packages for SQLite3MultipleCiphers that work cross platform. #136

Open
nullrocket opened this issue Dec 8, 2022 · 2 comments

Comments

@nullrocket
Copy link

nullrocket commented Dec 8, 2022

Hi,
I have written a set of packages that can be used to load SQLite3MultipleCiphers similar to the the sqlcipher_flutter_libs package, along with a drift compatible database package. These work on all platforms including the browser.

I am probably not the right person to maintain these, as they must be updated on every change made here and on Drift. I wanted to reach out and see if you would be open to inclusion here for the sqlite3mc_flutter_lib package and in Drift for the drift specific database packages.

You can find it at https://github.com/thinkassembly/sqlite3mc.dart . I have put off publishing and housekeeping around docs until I find a home for it.

@simolus3
Copy link
Owner

simolus3 commented Dec 9, 2022

Thanks for your work on those packages. I think I can help maintain them, but I don't have the capacity to update three more packages.

I don't fully understand why these need to be updated with every change in drift and sqlite3.dart. Is it not ABI compatible with sqlite3? If so, don't we just need sqlite3mc_flutter_libs? Maybe we can restructure drift and sqlite3.dart to make it easier to use sqlite3 forks.

For SQLCipher, our recommendation in drift is to manually issue the pragma for encryption. Is there a similar mechanism in sqlite3mc?

@nullrocket
Copy link
Author

nullrocket commented Dec 10, 2022

You are right, sqlite3mc_flutter_libs is ABI compatible and can be substituted for either of the existing sqlite*_flutter_libs and use the encryption related pragma's in setup. This works fine for native builds.

What I actually meant by keeping up to date with changes is the sqlite3mc_drift_database package, I tried to adapt your current solution for the browser, it should have been straightforward but I never could get it to work reliably with the VFS in SQLite3MultipleCiiphers, I ended up rewriting that using the same atomics / SharedArrayBuffer techniques as absurdSQL for the file system calls, this isn't the first sqlite3 to idb shim I've written so I have some experience and this technique has been the most solid implementation I've worked with, I wouldn't like to regress it.

I think you are right about working towards restructuring drift to make it easier to add alternate sqlite3 forks. It isn't so much that I have to actually do anything every time a change is made upstream, its that I have to check to make sure I don't need to do anything. I rely on bindings and things like the function_store functions that could be changed, and some needed interfaces are marked internal and not exported, or experimental so I like to make sure none of that has changed since it isn't guaranteed by semver.

I don't mind cleaning up and publishing things myself, I just want to make sure I'm not causing users any issues by relying on something that I know wasn't public api.

Examples of some of the internals I have needed.

info: The member 'package:drift/src/sqlite3/database.dart' can only be used within its package. (invalid_use_of_internal_member at [sqlite3mc_drift_database] lib/src/native/sqlite3mc_native_database.dart:17)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/native/sqlite3mc_native_database.dart:17)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/native/sqlite3mc_native_database.dart:19)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/bindings.dart:15)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/bindings.dart:16)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/database.dart:7)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/database.dart:8)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/database.dart:9)
info: The value of the local variable 'cursor' isn't used. (unused_local_variable at [sqlite3mc_drift_database] lib/src/wasm/file.dart:28)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/function_store.dart:7)
info: Avoid using private types in public APIs. (library_private_types_in_public_api at [sqlite3mc_drift_database] lib/src/wasm/js_interop.dart:77)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/sqlite3.dart:5)
info: The member 'package:drift/src/sqlite3/database.dart' can only be used within its package. (invalid_use_of_internal_member at [sqlite3mc_drift_database] lib/src/wasm/sqlite3mc_wasm_database.dart:25)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/sqlite3mc_wasm_database.dart:25)
info: The value of the field '_fileSystem' isn't used. (unused_field at [sqlite3mc_drift_database] lib/src/wasm/sqlite3mc_wasm_database.dart:140)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/statement.dart:5)
info: Don't import implementation files from another package. (implementation_imports at [sqlite3mc_drift_database] lib/src/wasm/statement.dart:7)
info: The class 'Cursor' shouldn't be extended, mixed in, or implemented because it's sealed. (subtype_of_sealed_class at [sqlite3mc_drift_database] lib/src/wasm/statement.dart:316)

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

No branches or pull requests

3 participants
@nullrocket @simolus3 and others