Alan McKean and I just implemented some hooks for transforming documents during 
replication. The intended use for this feature is to let apps implement 
server-side encryption of documents. An app would implement these hooks to 
transform a document into encrypted form during a push replication, and decrypt 
an encrypted document during a pull.

This commit does not implement encryption for you, just the minimal 
infrastructure needed for implementing it yourself.

Below is the new API -- you'll find it in CBLReplication.h on the master 
branch. iOS-only for now.

--Jens

typedef NSDictionary *(^CBLPropertiesTransformationBlock)(NSDictionary *);

/** Optional callback for transforming document bodies during replication; can 
be used to encrypt documents stored on the remote server, for example.
    In a push replication, the block is called with document properties from 
the local database, and the transformed properties are what will be uploaded to 
the server.
    In a pull replication, the block is called with document properties 
downloaded from the server, and the transformed properties are what will be 
stored in the local database.
    The block takes an NSDictionary containing the document's properties 
(including the "_id" and "_rev" metadata), and returns a dictionary of 
transformed properties. It may return the input dictionary if it has no changes 
to make. The transformed dictionary MUST preserve the values of "_id" and 
"_rev".
    The block will be called on the background replicator thread, NOT on the 
CBLReplication's thread! It must be written in thread-safe fashion. */
@property (strong) CBLPropertiesTransformationBlock 
propertiesTransformationBlock;

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/338A8E20-E8A3-43E6-9C83-D1ED5184E28A%40couchbase.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to