Allow specifying which fields are encrypted in SyncEngine#336
Allow specifying which fields are encrypted in SyncEngine#336finnvoor wants to merge 1 commit intopointfreeco:mainfrom
Conversation
|
@finnvoor I like the ergonomics of the First, as I understand it, this approach naively switches between Second, this approach would rule out the macro-based solution that @pfandrade and I proposed here. One advantage of that approach is that it can easily house additional CloudKit-related field configuration, such as custom field names or merge policies for custom conflict resolution, while keeping it close to the field definitions in the model types, rather than specifying everything in the detached There is still an unresolved clash with the type-level macro, which would need to be aware of the sync capability and therefore differ from |
|
@lukaskubanek RE your first point I think pretty much any changes to SyncEngine config after deploying a schema are going to cause huge issues with your app (containerIdentifier/defaultZone) and I think it's a bit overkill to try to avoid user error like this (it's easier to clearly warn in the docs against this). RE macros I definitely think it's worth considering/experimenting with, though I'd like to not have to flag every single one of my fields as unencrypted with a macro (IMO all fields should be unencrypted by default to match SwiftData/CoreData, but that would change the existing defaults). open to all feedback, definitely a big change! |
That’s fair. Though, from the discussions, it sounds like some devs might want to switch fields from encrypted to unencrypted retroactively, e.g. after a schema is already deployed and they later realize they need indices or want to access the data via JS. I’m on thin ice here since I don’t have this use case myself. Just throwing in my two cents…
Yep, I’d also prefer this over the current default in the library, but I agree it’s probably not something that can be easily changed at this point. (Using unencrypted fields by default would also likely have avoided the CloudKit bug #315 that I struggled with for quite a while. Thankfully, a workaround is now in place as of version 1.4.1.)
I see. Another option could be a type-level master switch, which could even be used to change the default behavior should that be desired in the library. For example, a plain That said, this might be leaning too far. It really depends on the overall direction of the library. My main motivation was to unify CloudKit configuration with the focus on custom conflict resolution, which is the area I’m most interested in (see #272). |
|
Hi Finn, I saw you closed this draft PR. Just for completeness, it looks like a |
I originally implemented
unencryptedFields: RemindersList.title, Reminder.titlewith an inverseencryptedFields: RemindersList.title, Reminder.title, but I think the API was very confusing since there also needed to be an init for all/none encryption.added unit tests and tested in a WIP app
see #244