Comments (4)
Here's an idea for an API. The idea is that the application registers a block that when called creates an object that knows how to transform data. One transformer object is created for each attachment, and it's passed all the data of the attachment in one or more chunks, and returns the encoded (or decoded) data in chunks.
@protocol CBLAttachmentTransformer : NSObject
/** Transforms the next byte range of an attachment. This method will be called zero of more times, passing in
contiguous ranges of the attachment data with competed=false, and then once on the last section of the
data with completed=true. It should output contiguous portions of the encoded data. */
- (NSData*) transformBytes: (NSData*)inputBytes completed: (bool)completed;
@end
/** Returns a new CBLAttachmentTransformer instance that's ready to start encoding or decoding an
attachment, depending on the setting of the 'encoding' flag. */
typedef id<CBLAttachmentTransformer> (^CBLAttachmentTransformerFactory)(bool encoding);
Somewhere (either globally or on the CBLManager instance) there is a property of type CBLAttachmentTransformerFactory
that the application can set to its own block value.
from couchbase-lite-ios.
I would vote to have the SHA-1 digest of the encoded blob not the original.
My reasoning is:
-
I might wish to store the same data encrypted by two different private keys in the same blob store, not possible if the blob key is based on the unencrypted "in the clear" data.
-
Creating the digest from the original unencrypted data opens up the possibility of determining the content of an encrypted blob by comparing the digest with known "in the clear" data. A hacker would have to already have the original data or it's "in the clear" digest, but they could use this information to find out who has a copy of the data even when it is encrypted.
from couchbase-lite-ios.
The only way I got this to work was to hook the API into more places than described above.
-[CBLAttachment body]
is one of those places: it has a conditional branch which returns data from straight from a file URL. -getAttachmentForSequence:...
looks suspicious too.
from couchbase-lite-ios.
I've just finished implementing database/attachment encryption — see the feature/encryption
branch. Encrypting the attachments turned out to be hard because, as mentioned above, there were leaks in the abstraction where callers could discover the attachment file. So I had to do a lot of refactoring in CBLDatabase+Attachments. I didn't add a delegate API, I just implemented the encryption/decryption directly in CBLBlobStore.
from couchbase-lite-ios.
Related Issues (20)
- Module compiled with Swift 5.3.2 cannot be imported by the Swift 5.5 compiler HOT 6
- CouchbaseLite-Swift-Enterprise pod produces warning when compiling with Xcode 13 HOT 8
- Sync crashing CB lite 2.8.0 Ios 15.1 HOT 3
- Compiling issue after upgrading to Xcode 13.2.1 HOT 1
- Fleece crash during document retrieval HOT 12
- `ExpressionProtocol.isNotValued` and `isValued` functions are not available HOT 1
- setMapBlock is executing for all CBLView s instead of specific mentioned CBLView HOT 4
- Add Support for Combine Publishers HOT 1
- Add Linux Support HOT 5
- Add Nulls Ordering support HOT 2
- CouchbaseLite includes UIWebView, can it be changed to WKWebView? HOT 2
- Undefined symbol: _CBLVersion HOT 1
- “CouchbaseLiteSwift.framework” cannot be opened because the developer cannot be verified. HOT 3
- 【iOS Swift】CouchbaseLite Replicator ERROR: {Repl#935} Got LiteCore error: WebSocket error 1006, "connection closed abnormally" HOT 2
- Undefined symbols for CBLReplicatedDocument using CBL ObjC HOT 1
- After downloading the demo, it cannot be run. HOT 2
- Crash on `Query.removeChangeListener(withToken:)` HOT 14
- Swift Package Manager version of CouchbaseLiteSwift 3.1.3 crashes on `MutableDocument()` HOT 4
- `PrivacyInfo.xcprivacy` file is missing `NSPrivacyCollectedDataTypes` key HOT 5
- Couchbase Lite for iOS: Database Integrity Check Failures HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from couchbase-lite-ios.