Comments (2)
Thanks for creating this issue.
As of now, you can query nodes for unencypted version of data, which means that you necessarily does not have to be able to decrypt the payloads to receive decrypted copies of the documents.
If you include canRead
fn in your open
fn
async open(): Promise<void> {
await this.posts.open({
type: Post,
index: { key: "id" },
canAppend: async (entry) => {
await entry.verifySignatures();
const payload = await entry.getPayloadValue();
console.log('GOT PAYLOAD')
if (payload instanceof PutOperation) {
const post: Post = payload.getValue(
this.posts.index.valueEncoding
);
console.log('PUT POST', post)
return true;
} else if (payload instanceof DeleteOperation) {
return false;
}
return true
},
canRead: async (publicKey) => {
return publicKey?.equals(client3.identity.publicKey) || false;
}
});
}
you can control what publickeys can search for documents, and one who sits on the documents will decrypt them if the canRead check will pass. (canRead by default is () => true
which means everyone can read, even though the payloads are encrypted). The reason for why there is a separate way for peers to retrieve documents outside the "encryption at rest" which is what you define during .put
is that there are scenarios where you want to protect the data at rest, but leak things when certain conditions are met.
In your example, I also modified the print lines to this
console.log('Store1:')
await printPosts(store)
console.log('Store2:')
await printPosts(store2)
console.log('Store3:')
await printPosts(store3)
so that the prints are in order.
With the changes above the results will be:
Store1 will receive results because, it created them, which means it has an unencrypted local copy.
Store2 will receive no results
Store3 will receive results because it can decrypt the payload.
Though:
Issues/Bugs I have identified with Peerbit codebase when looking into this, which I ASAP look into.
- When using the
canRead
, and a node gets rejected. The node will wait until timeout for responses (that will never come). This is why the response times are so long if you make the change above. #128 - The documentation is lacking regarding canRead and that documents can leak by default if you are not modifying the canRead function. #129
* canRead, should perhaps be mandatory to define. - canRead should also be a callback that not only takes the publicKey of the query, but also the query itself, or some other information, so that more advanced behaviour could be created. Perhaps there should be to be a filter of what queries are performed, but then also a filter for controller what documents are returned. Perhaps there should be a
canSearch
(before querying) andcanRead
(after results has been obtained, but before returning them) #130 - By default, you open stores are as a replicator, but if peers put documents in them that you can not decrypt, should you reject in the canAppend (?). The search index duties are not conditioned on what documents you can encrypt/decrypt but the hash of the commit. #131
from peerbit.
All problems have now more or less been solved with the latest release
https://peerbit.org/#/modules/encryption/?id=encrypted-document-store
Only one issue left that I have not fully settled on:
- What should the default behaviour of
canRead
andcanSearch
be? False? Throw a Type error if not provided?
Sorry for the long delay of fixing these issues.
from peerbit.
Related Issues (20)
- `pubsub`: Add 'seqno' to pubsub data messages
- `shared-log`: Smartly fetch blocks
- IP privacy
- `Shared-log`: add option to automatically set minReplicas based on network dynamics
- `getDefaultMinRoleAge`: Make it adaptive the amount of data that exist HOT 1
- Improved Changelog and release notes
- `documents`: add "NOT" query
- `@peerbit/server`: cli does not show nodes deployed in multi-region with same name
- Saving 170k+ entries crashes process HOT 2
- `documents`: Allow for SQLLite WASM backend HOT 2
- `shared-log`: Efficient sync HOT 2
- Pinning documents and document deletions
- Uncaught exception and crash when peer disconnects
- setMaxListeners error example demo chat room HOT 1
- Add Tor integration
- Verify that Peerbit is working as expected on Windows HOT 1
- Bootstrap node terminating at random HOT 1
- graphs HOT 1
- Verify Signer Using Parent Key
- Implement stage 3 JS decorator syntax
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 peerbit.